Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
authorJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Aug 2013 18:08:24 +0000 (14:08 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Aug 2013 18:08:24 +0000 (14:08 -0400)
Conflicts:
drivers/net/wireless/iwlwifi/pcie/trans.c

2039 files changed:
.gitignore
Documentation/ABI/testing/sysfs-driver-xen-blkback [new file with mode: 0644]
Documentation/ABI/testing/sysfs-driver-xen-blkfront [new file with mode: 0644]
Documentation/DocBook/device-drivers.tmpl
Documentation/DocBook/media_api.tmpl
Documentation/bcache.txt
Documentation/cpu-hotplug.txt
Documentation/devicetree/bindings/clock/imx27-clock.txt
Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
Documentation/devicetree/bindings/net/micrel-ksz9021.txt [new file with mode: 0644]
Documentation/devicetree/bindings/net/moxa,moxart-mac.txt [new file with mode: 0644]
Documentation/devicetree/bindings/regulator/palmas-pmic.txt
Documentation/devicetree/bindings/vendor-prefixes.txt
Documentation/ja_JP/HOWTO
Documentation/kernel-parameters.txt
Documentation/networking/00-INDEX
Documentation/networking/e100.txt
Documentation/networking/e1000.txt
Documentation/networking/e1000e.txt
Documentation/networking/igb.txt
Documentation/networking/igbvf.txt
Documentation/networking/ip-sysctl.txt
Documentation/networking/ixgb.txt
Documentation/networking/ixgbe.txt
Documentation/networking/ixgbevf.txt
Documentation/networking/netdev-FAQ.txt [new file with mode: 0644]
Documentation/networking/openvswitch.txt
Documentation/networking/sctp.txt
Documentation/networking/tproxy.txt
Documentation/sysctl/net.txt
MAINTAINERS
Makefile
arch/Kconfig
arch/alpha/Kconfig
arch/alpha/include/asm/atomic.h
arch/alpha/include/asm/param.h
arch/alpha/include/asm/spinlock.h
arch/alpha/include/asm/unistd.h
arch/alpha/include/uapi/asm/param.h
arch/alpha/include/uapi/asm/unistd.h
arch/alpha/kernel/entry.S
arch/alpha/kernel/irq_alpha.c
arch/alpha/kernel/smp.c
arch/alpha/kernel/sys_dp264.c
arch/alpha/kernel/sys_marvel.c
arch/alpha/kernel/systbls.S
arch/alpha/kernel/time.c
arch/alpha/kernel/traps.c
arch/arc/include/asm/entry.h
arch/arm/Kconfig
arch/arm/Kconfig.debug
arch/arm/Makefile
arch/arm/boot/dts/at91sam9n12ek.dts
arch/arm/boot/dts/at91sam9x5ek.dtsi
arch/arm/boot/dts/atlas6.dtsi
arch/arm/boot/dts/imx28-apx4devkit.dts
arch/arm/boot/dts/imx28-evk.dts
arch/arm/boot/dts/imx28-m28evk.dts
arch/arm/boot/dts/imx28.dtsi
arch/arm/boot/dts/imx51-babbage.dts
arch/arm/boot/dts/imx53-mba53.dts
arch/arm/boot/dts/imx53.dtsi
arch/arm/boot/dts/msm8960-cdp.dts
arch/arm/boot/dts/omap5-uevm.dts
arch/arm/boot/dts/prima2.dtsi
arch/arm/boot/dts/sama5d3xmb.dtsi
arch/arm/boot/dts/stih416-pinctrl.dtsi
arch/arm/boot/dts/stih416.dtsi
arch/arm/boot/dts/stih41x.dtsi
arch/arm/boot/dts/tegra20-colibri-512.dtsi
arch/arm/boot/dts/tegra20-seaboard.dts
arch/arm/boot/dts/tegra20-trimslice.dts
arch/arm/boot/dts/tegra20-whistler.dts
arch/arm/boot/dts/twl4030.dtsi
arch/arm/boot/dts/vf610.dtsi
arch/arm/common/edma.c
arch/arm/common/mcpm_platsmp.c
arch/arm/configs/da8xx_omapl_defconfig
arch/arm/configs/davinci_all_defconfig
arch/arm/configs/multi_v7_defconfig
arch/arm/configs/nhk8815_defconfig
arch/arm/include/asm/a.out-core.h [deleted file]
arch/arm/include/asm/arch_timer.h
arch/arm/include/asm/cputype.h
arch/arm/include/asm/elf.h
arch/arm/include/asm/mmu.h
arch/arm/include/asm/mmu_context.h
arch/arm/include/asm/page.h
arch/arm/include/asm/processor.h
arch/arm/include/asm/smp_plat.h
arch/arm/include/asm/spinlock.h
arch/arm/include/asm/thread_info.h
arch/arm/include/asm/tlb.h
arch/arm/include/asm/tlbflush.h
arch/arm/include/asm/virt.h
arch/arm/include/uapi/asm/Kbuild
arch/arm/include/uapi/asm/a.out.h [deleted file]
arch/arm/kernel/entry-armv.S
arch/arm/kernel/entry-v7m.S
arch/arm/kernel/fiq.c
arch/arm/kernel/head-common.S
arch/arm/kernel/head-nommu.S
arch/arm/kernel/head.S
arch/arm/kernel/hw_breakpoint.c
arch/arm/kernel/hyp-stub.S
arch/arm/kernel/machine_kexec.c
arch/arm/kernel/perf_event.c
arch/arm/kernel/perf_event_cpu.c
arch/arm/kernel/process.c
arch/arm/kernel/psci_smp.c
arch/arm/kernel/setup.c
arch/arm/kernel/signal.c
arch/arm/kernel/signal.h [deleted file]
arch/arm/kernel/smp.c
arch/arm/kernel/smp_tlb.c
arch/arm/kernel/smp_twd.c
arch/arm/kernel/traps.c
arch/arm/kernel/vmlinux.lds.S
arch/arm/kvm/coproc.c
arch/arm/kvm/coproc.h
arch/arm/kvm/coproc_a15.c
arch/arm/kvm/mmio.c
arch/arm/kvm/mmu.c
arch/arm/lib/delay.c
arch/arm/mach-at91/at91sam9x5.c
arch/arm/mach-davinci/board-dm355-leopard.c
arch/arm/mach-davinci/board-dm365-evm.c
arch/arm/mach-davinci/board-dm644x-evm.c
arch/arm/mach-davinci/board-dm646x-evm.c
arch/arm/mach-davinci/board-neuros-osd2.c
arch/arm/mach-davinci/dm355.c
arch/arm/mach-davinci/dm365.c
arch/arm/mach-exynos/Kconfig
arch/arm/mach-exynos/Makefile
arch/arm/mach-exynos/common.c
arch/arm/mach-exynos/common.h
arch/arm/mach-exynos/cpuidle.c
arch/arm/mach-exynos/headsmp.S
arch/arm/mach-exynos/include/mach/memory.h
arch/arm/mach-exynos/platsmp.c
arch/arm/mach-exynos/pm.c
arch/arm/mach-footbridge/dc21285.c
arch/arm/mach-highbank/highbank.c
arch/arm/mach-highbank/platsmp.c
arch/arm/mach-imx/clk-imx6q.c
arch/arm/mach-imx/clk-vf610.c
arch/arm/mach-imx/mx27.h
arch/arm/mach-imx/platsmp.c
arch/arm/mach-keystone/keystone.c
arch/arm/mach-keystone/platsmp.c
arch/arm/mach-msm/Kconfig
arch/arm/mach-msm/gpiomux-v1.c [deleted file]
arch/arm/mach-msm/gpiomux.h
arch/arm/mach-msm/headsmp.S
arch/arm/mach-msm/platsmp.c
arch/arm/mach-msm/timer.c
arch/arm/mach-mvebu/coherency.c
arch/arm/mach-mvebu/headsmp.S
arch/arm/mach-mvebu/platsmp.c
arch/arm/mach-omap2/Kconfig
arch/arm/mach-omap2/board-generic.c
arch/arm/mach-omap2/board-n8x0.c
arch/arm/mach-omap2/board-rx51.c
arch/arm/mach-omap2/dss-common.c
arch/arm/mach-omap2/omap-headsmp.S
arch/arm/mach-omap2/omap-mpuss-lowpower.c
arch/arm/mach-omap2/omap-smp.c
arch/arm/mach-omap2/omap-wakeupgen.c
arch/arm/mach-omap2/omap_device.c
arch/arm/mach-omap2/omap_hwmod.c
arch/arm/mach-omap2/omap_hwmod.h
arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
arch/arm/mach-omap2/omap_hwmod_33xx_data.c
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
arch/arm/mach-omap2/omap_hwmod_44xx_data.c
arch/arm/mach-omap2/omap_hwmod_54xx_data.c
arch/arm/mach-omap2/serial.c
arch/arm/mach-omap2/usb-musb.c
arch/arm/mach-prima2/headsmp.S
arch/arm/mach-prima2/platsmp.c
arch/arm/mach-pxa/em-x270.c
arch/arm/mach-pxa/icontrol.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-pxa/pcm990-baseboard.c
arch/arm/mach-pxa/poodle.c
arch/arm/mach-pxa/spitz.c
arch/arm/mach-pxa/stargate2.c
arch/arm/mach-pxa/zeus.c
arch/arm/mach-s3c24xx/Kconfig
arch/arm/mach-s3c24xx/clock-s3c2410.c
arch/arm/mach-s3c24xx/clock-s3c2440.c
arch/arm/mach-shmobile/board-armadillo800eva.c
arch/arm/mach-shmobile/board-bockw.c
arch/arm/mach-shmobile/board-lager.c
arch/arm/mach-shmobile/headsmp-scu.S
arch/arm/mach-shmobile/headsmp.S
arch/arm/mach-shmobile/smp-emev2.c
arch/arm/mach-shmobile/smp-r8a7779.c
arch/arm/mach-shmobile/smp-sh73a0.c
arch/arm/mach-socfpga/headsmp.S
arch/arm/mach-socfpga/platsmp.c
arch/arm/mach-spear/generic.h
arch/arm/mach-spear/platsmp.c
arch/arm/mach-sti/Kconfig
arch/arm/mach-sti/headsmp.S
arch/arm/mach-sti/platsmp.c
arch/arm/mach-tegra/platsmp.c
arch/arm/mach-tegra/pm.c
arch/arm/mach-ux500/platsmp.c
arch/arm/mach-zynq/common.c
arch/arm/mach-zynq/common.h
arch/arm/mach-zynq/headsmp.S
arch/arm/mach-zynq/platsmp.c
arch/arm/mm/Kconfig
arch/arm/mm/context.c
arch/arm/mm/mmu.c
arch/arm/mm/proc-arm1020.S
arch/arm/mm/proc-arm1020e.S
arch/arm/mm/proc-arm1022.S
arch/arm/mm/proc-arm1026.S
arch/arm/mm/proc-arm720.S
arch/arm/mm/proc-arm740.S
arch/arm/mm/proc-arm7tdmi.S
arch/arm/mm/proc-arm920.S
arch/arm/mm/proc-arm922.S
arch/arm/mm/proc-arm925.S
arch/arm/mm/proc-arm926.S
arch/arm/mm/proc-arm940.S
arch/arm/mm/proc-arm946.S
arch/arm/mm/proc-arm9tdmi.S
arch/arm/mm/proc-fa526.S
arch/arm/mm/proc-feroceon.S
arch/arm/mm/proc-mohawk.S
arch/arm/mm/proc-sa110.S
arch/arm/mm/proc-sa1100.S
arch/arm/mm/proc-v6.S
arch/arm/mm/proc-v7-2level.S
arch/arm/mm/proc-v7-3level.S
arch/arm/mm/proc-v7.S
arch/arm/mm/proc-xsc3.S
arch/arm/mm/proc-xscale.S
arch/arm/plat-samsung/Kconfig
arch/arm/plat-samsung/Makefile
arch/arm/plat-samsung/include/plat/clock.h
arch/arm/plat-samsung/include/plat/pm.h
arch/arm/plat-samsung/init.c
arch/arm/plat-samsung/pm.c
arch/arm/plat-versatile/platsmp.c
arch/arm/xen/enlighten.c
arch/arm64/include/asm/arch_timer.h
arch/arm64/include/asm/debug-monitors.h
arch/arm64/include/asm/kvm_asm.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/include/asm/system_misc.h
arch/arm64/include/asm/thread_info.h
arch/arm64/include/asm/tlb.h
arch/arm64/include/asm/virt.h
arch/arm64/kernel/debug-monitors.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/hw_breakpoint.c
arch/arm64/kernel/perf_event.c
arch/arm64/kernel/process.c
arch/arm64/kernel/smp.c
arch/arm64/kvm/hyp.S
arch/arm64/kvm/sys_regs.c
arch/arm64/mm/fault.c
arch/avr32/boards/atngw100/mrmt.c
arch/blackfin/kernel/perf_event.c
arch/blackfin/kernel/setup.c
arch/blackfin/mach-bf561/smp.c
arch/blackfin/mach-common/cache-c.c
arch/blackfin/mach-common/ints-priority.c
arch/blackfin/mach-common/smp.c
arch/cris/arch-v32/kernel/smp.c
arch/frv/kernel/setup.c
arch/hexagon/Kconfig
arch/hexagon/kernel/setup.c
arch/hexagon/kernel/smp.c
arch/ia64/configs/generic_defconfig
arch/ia64/configs/gensparse_defconfig
arch/ia64/configs/tiger_defconfig
arch/ia64/configs/xen_domu_defconfig
arch/ia64/include/asm/tlb.h
arch/m32r/kernel/smpboot.c
arch/m68k/emu/natfeat.c
arch/m68k/include/asm/div64.h
arch/metag/kernel/perf/perf_event.c
arch/metag/kernel/smp.c
arch/metag/kernel/traps.c
arch/microblaze/Kconfig
arch/mips/Kconfig
arch/mips/ath79/setup.c
arch/mips/bcm47xx/Kconfig
arch/mips/cavium-octeon/octeon-irq.c
arch/mips/cavium-octeon/octeon-platform.c
arch/mips/cavium-octeon/smp.c
arch/mips/include/asm/cpu-features.h
arch/mips/include/asm/mach-generic/spaces.h
arch/mips/include/asm/uasm.h
arch/mips/include/uapi/asm/siginfo.h
arch/mips/kernel/bmips_vec.S
arch/mips/kernel/cevt-bcm1480.c
arch/mips/kernel/cevt-gic.c
arch/mips/kernel/cevt-r4k.c
arch/mips/kernel/cevt-sb1250.c
arch/mips/kernel/cevt-smtc.c
arch/mips/kernel/cpu-bugs64.c
arch/mips/kernel/cpu-probe.c
arch/mips/kernel/head.S
arch/mips/kernel/smp-bmips.c
arch/mips/kernel/smp-mt.c
arch/mips/kernel/smp-up.c
arch/mips/kernel/smp.c
arch/mips/kernel/smtc.c
arch/mips/kernel/spram.c
arch/mips/kernel/sync-r4k.c
arch/mips/kernel/traps.c
arch/mips/kernel/watch.c
arch/mips/kvm/Kconfig
arch/mips/lantiq/irq.c
arch/mips/lib/uncached.c
arch/mips/math-emu/cp1emu.c
arch/mips/mm/c-octeon.c
arch/mips/mm/c-r3k.c
arch/mips/mm/c-r4k.c
arch/mips/mm/c-tx39.c
arch/mips/mm/cache.c
arch/mips/mm/cex-sb1.S
arch/mips/mm/page.c
arch/mips/mm/sc-ip22.c
arch/mips/mm/sc-mips.c
arch/mips/mm/sc-r5k.c
arch/mips/mm/sc-rm7k.c
arch/mips/mm/tlb-r3k.c
arch/mips/mm/tlb-r4k.c
arch/mips/mm/tlb-r8k.c
arch/mips/mm/tlbex.c
arch/mips/mm/uasm-micromips.c
arch/mips/mm/uasm-mips.c
arch/mips/mm/uasm.c
arch/mips/mti-malta/malta-smtc.c
arch/mips/mti-malta/malta-time.c
arch/mips/mti-sead3/sead3-time.c
arch/mips/netlogic/common/irq.c
arch/mips/netlogic/common/smp.c
arch/mips/netlogic/common/smpboot.S
arch/mips/netlogic/common/time.c
arch/mips/netlogic/dts/xlp_evp.dts
arch/mips/netlogic/dts/xlp_svp.dts
arch/mips/netlogic/xlp/usb-init.c
arch/mips/netlogic/xlr/wakeup.c
arch/mips/oprofile/op_model_mipsxx.c
arch/mips/pci/pci-ip27.c
arch/mips/pmcs-msp71xx/msp_smtc.c
arch/mips/pmcs-msp71xx/msp_time.c
arch/mips/pnx833x/common/interrupts.c
arch/mips/pnx833x/common/platform.c
arch/mips/powertv/asic/asic_devices.c
arch/mips/powertv/time.c
arch/mips/ralink/irq.c
arch/mips/sgi-ip27/ip27-init.c
arch/mips/sgi-ip27/ip27-smp.c
arch/mips/sgi-ip27/ip27-timer.c
arch/mips/sgi-ip27/ip27-xtalk.c
arch/mips/sibyte/bcm1480/smp.c
arch/mips/sibyte/sb1250/smp.c
arch/openrisc/Kconfig
arch/openrisc/kernel/setup.c
arch/parisc/configs/c8000_defconfig [new file with mode: 0644]
arch/parisc/include/asm/parisc-device.h
arch/parisc/kernel/cache.c
arch/parisc/kernel/firmware.c
arch/parisc/kernel/hardware.c
arch/parisc/kernel/inventory.c
arch/parisc/kernel/processor.c
arch/parisc/kernel/signal.c
arch/parisc/kernel/signal32.c
arch/parisc/kernel/smp.c
arch/parisc/kernel/sys32.h [deleted file]
arch/parisc/kernel/sys_parisc32.c
arch/powerpc/Kconfig
arch/powerpc/configs/ppc64_defconfig
arch/powerpc/configs/ppc64e_defconfig
arch/powerpc/configs/pseries_defconfig
arch/powerpc/include/asm/eeh.h
arch/powerpc/include/asm/hw_irq.h
arch/powerpc/include/asm/module.h
arch/powerpc/include/asm/pci-bridge.h
arch/powerpc/include/asm/perf_event_server.h
arch/powerpc/include/asm/processor.h
arch/powerpc/include/asm/reg.h
arch/powerpc/include/asm/smp.h
arch/powerpc/include/asm/switch_to.h
arch/powerpc/include/uapi/asm/Kbuild
arch/powerpc/include/uapi/asm/perf_event.h [new file with mode: 0644]
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/kernel/cputable.c
arch/powerpc/kernel/eeh.c
arch/powerpc/kernel/eeh_cache.c
arch/powerpc/kernel/eeh_driver.c
arch/powerpc/kernel/eeh_pe.c
arch/powerpc/kernel/eeh_sysfs.c
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/exceptions-64s.S
arch/powerpc/kernel/irq.c
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/pci-hotplug.c
arch/powerpc/kernel/pci_of_scan.c
arch/powerpc/kernel/process.c
arch/powerpc/kernel/prom_init.c
arch/powerpc/kernel/tm.S
arch/powerpc/kernel/traps.c
arch/powerpc/kernel/vmlinux.lds.S
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_pr.c
arch/powerpc/mm/hash_native_64.c
arch/powerpc/mm/numa.c
arch/powerpc/perf/core-book3s.c
arch/powerpc/perf/power8-pmu.c
arch/powerpc/platforms/powernv/eeh-powernv.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/pseries/Kconfig
arch/powerpc/platforms/pseries/eeh_pseries.c
arch/powerpc/platforms/pseries/lpar.c
arch/powerpc/platforms/pseries/nvram.c
arch/powerpc/platforms/pseries/ras.c
arch/s390/Kconfig
arch/s390/boot/compressed/Makefile
arch/s390/boot/compressed/misc.c
arch/s390/include/asm/bitops.h
arch/s390/include/asm/processor.h
arch/s390/include/asm/switch_to.h
arch/s390/include/asm/tlb.h
arch/s390/include/uapi/asm/ptrace.h
arch/s390/kernel/cache.c
arch/s390/kernel/crash_dump.c
arch/s390/kernel/perf_cpum_cf.c
arch/s390/kernel/perf_event.c
arch/s390/kernel/processor.c
arch/s390/kernel/ptrace.c
arch/s390/kernel/setup.c
arch/s390/kernel/smp.c
arch/s390/kernel/sysinfo.c
arch/s390/kernel/vtime.c
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/priv.c
arch/s390/mm/fault.c
arch/s390/mm/init.c
arch/s390/net/bpf_jit_comp.c
arch/s390/oprofile/init.c
arch/score/Kconfig
arch/score/mm/tlb-score.c
arch/sh/boards/board-espt.c
arch/sh/boards/board-sh7757lcr.c
arch/sh/boards/mach-ecovec24/setup.c
arch/sh/boards/mach-se/7724/setup.c
arch/sh/boards/mach-sh7763rdp/setup.c
arch/sh/configs/sh03_defconfig
arch/sh/include/asm/tlb.h
arch/sh/kernel/cpu/init.c
arch/sh/kernel/cpu/sh2/probe.c
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/probe.c
arch/sh/kernel/cpu/sh3/probe.c
arch/sh/kernel/cpu/sh4/probe.c
arch/sh/kernel/cpu/sh4a/smp-shx3.c
arch/sh/kernel/cpu/sh5/probe.c
arch/sh/kernel/perf_event.c
arch/sh/kernel/process.c
arch/sh/kernel/setup.c
arch/sh/kernel/smp.c
arch/sh/kernel/traps_32.c
arch/sh/kernel/traps_64.c
arch/sh/mm/tlb-sh5.c
arch/sparc/kernel/ds.c
arch/sparc/kernel/entry.h
arch/sparc/kernel/hvtramp.S
arch/sparc/kernel/irq_64.c
arch/sparc/kernel/leon_smp.c
arch/sparc/kernel/mdesc.c
arch/sparc/kernel/smp_32.c
arch/sparc/kernel/smp_64.c
arch/sparc/kernel/sun4d_smp.c
arch/sparc/kernel/sun4m_smp.c
arch/sparc/kernel/sysfs.c
arch/sparc/kernel/trampoline_32.S
arch/sparc/kernel/trampoline_64.S
arch/sparc/mm/init_64.c
arch/sparc/mm/srmmu.c
arch/tile/gxio/iorpc_mpipe.c
arch/tile/gxio/iorpc_mpipe_info.c
arch/tile/gxio/mpipe.c
arch/tile/include/gxio/iorpc_mpipe.h
arch/tile/include/gxio/iorpc_mpipe_info.h
arch/tile/include/gxio/mpipe.h
arch/tile/include/hv/drv_mpipe_intf.h
arch/tile/kernel/irq.c
arch/tile/kernel/messaging.c
arch/tile/kernel/setup.c
arch/tile/kernel/smpboot.c
arch/tile/kernel/time.c
arch/um/include/asm/tlb.h
arch/um/include/shared/frame_kern.h
arch/um/kernel/signal.c
arch/um/kernel/skas/mmu.c
arch/um/kernel/skas/uaccess.c
arch/um/os-Linux/mem.c
arch/um/os-Linux/signal.c
arch/um/os-Linux/skas/process.c
arch/x86/boot/compressed/eboot.c
arch/x86/crypto/Makefile
arch/x86/crypto/crct10dif-pcl-asm_64.S [deleted file]
arch/x86/crypto/crct10dif-pclmul_glue.c [deleted file]
arch/x86/include/asm/bootparam_utils.h
arch/x86/include/asm/cpu.h
arch/x86/include/asm/microcode.h
arch/x86/include/asm/microcode_amd.h
arch/x86/include/asm/microcode_intel.h
arch/x86/include/asm/mmconfig.h
arch/x86/include/asm/mpspec.h
arch/x86/include/asm/numa.h
arch/x86/include/asm/pgtable-2level.h
arch/x86/include/asm/pgtable-3level.h
arch/x86/include/asm/pgtable.h
arch/x86/include/asm/pgtable_types.h
arch/x86/include/asm/processor.h
arch/x86/include/asm/prom.h
arch/x86/include/asm/smp.h
arch/x86/include/asm/spinlock.h
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/acpi/sleep.c
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/apic_numachip.c
arch/x86/kernel/apic/es7000_32.c
arch/x86/kernel/apic/numaq_32.c
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/centaur.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/cyrix.c
arch/x86/kernel/cpu/hypervisor.c
arch/x86/kernel/cpu/intel.c
arch/x86/kernel/cpu/intel_cacheinfo.c
arch/x86/kernel/cpu/mcheck/mce-severity.c
arch/x86/kernel/cpu/mcheck/mce.c
arch/x86/kernel/cpu/mcheck/mce_amd.c
arch/x86/kernel/cpu/mcheck/therm_throt.c
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpu/perf_event_amd_ibs.c
arch/x86/kernel/cpu/perf_event_amd_uncore.c
arch/x86/kernel/cpu/perf_event_intel.c
arch/x86/kernel/cpu/perf_event_intel_uncore.c
arch/x86/kernel/cpu/rdrand.c
arch/x86/kernel/cpu/scattered.c
arch/x86/kernel/cpu/topology.c
arch/x86/kernel/cpu/transmeta.c
arch/x86/kernel/cpu/umc.c
arch/x86/kernel/cpu/vmware.c
arch/x86/kernel/cpuid.c
arch/x86/kernel/devicetree.c
arch/x86/kernel/early-quirks.c
arch/x86/kernel/head_32.S
arch/x86/kernel/head_64.S
arch/x86/kernel/i387.c
arch/x86/kernel/irq_32.c
arch/x86/kernel/kvm.c
arch/x86/kernel/kvmclock.c
arch/x86/kernel/microcode_amd.c
arch/x86/kernel/microcode_amd_early.c
arch/x86/kernel/microcode_core.c
arch/x86/kernel/microcode_core_early.c
arch/x86/kernel/microcode_intel_early.c
arch/x86/kernel/mmconf-fam10h_64.c
arch/x86/kernel/msr.c
arch/x86/kernel/process.c
arch/x86/kernel/setup.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/sys_x86_64.c
arch/x86/kernel/tboot.c
arch/x86/kernel/tracepoint.c
arch/x86/kernel/traps.c
arch/x86/kernel/tsc.c
arch/x86/kernel/tsc_sync.c
arch/x86/kernel/vsyscall_64.c
arch/x86/kernel/x86_init.c
arch/x86/kernel/xsave.c
arch/x86/kvm/mmu.c
arch/x86/mm/mmap.c
arch/x86/mm/mmio-mod.c
arch/x86/mm/numa.c
arch/x86/mm/numa_emulation.c
arch/x86/mm/setup_nx.c
arch/x86/pci/amd_bus.c
arch/x86/platform/ce4100/ce4100.c
arch/x86/platform/efi/efi.c
arch/x86/platform/mrst/mrst.c
arch/x86/um/signal.c
arch/x86/xen/enlighten.c
arch/x86/xen/setup.c
arch/x86/xen/smp.c
arch/x86/xen/spinlock.c
arch/x86/xen/xen-ops.h
arch/xtensa/kernel/time.c
block/blk-iopoll.c
block/blk-softirq.c
crypto/Kconfig
crypto/Makefile
crypto/crct10dif.c [deleted file]
crypto/tcrypt.c
crypto/testmgr.c
crypto/testmgr.h
drivers/accessibility/braille/braille_console.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/acpi_processor.c
drivers/acpi/acpica/aclocal.h
drivers/acpi/battery.c
drivers/acpi/glue.c
drivers/acpi/internal.h
drivers/acpi/proc.c
drivers/acpi/processor_core.c
drivers/acpi/processor_driver.c
drivers/acpi/processor_idle.c
drivers/acpi/scan.c
drivers/acpi/video.c
drivers/acpi/video_detect.c
drivers/ata/Kconfig
drivers/ata/Makefile
drivers/ata/ahci.c
drivers/ata/ahci_imx.c [new file with mode: 0644]
drivers/ata/ata_piix.c
drivers/ata/libata-scsi.c
drivers/ata/pata_imx.c
drivers/ata/sata_inic162x.c
drivers/base/core.c
drivers/base/cpu.c
drivers/base/platform.c
drivers/base/regmap/regcache.c
drivers/base/regmap/regmap.c
drivers/base/topology.c
drivers/block/Kconfig
drivers/block/aoe/aoecmd.c
drivers/block/drbd/drbd_actlog.c
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_state.c
drivers/block/rsxx/core.c
drivers/block/rsxx/cregs.c
drivers/block/rsxx/dev.c
drivers/block/rsxx/dma.c
drivers/block/rsxx/rsxx_priv.h
drivers/block/xen-blkback/blkback.c
drivers/block/xen-blkback/common.h
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/char/agp/parisc-agp.c
drivers/char/virtio_console.c
drivers/clk/samsung/clk-exynos4.c
drivers/clk/zynq/clkc.c
drivers/clocksource/arm_arch_timer.c
drivers/clocksource/arm_global_timer.c
drivers/clocksource/dummy_timer.c
drivers/clocksource/exynos_mct.c
drivers/clocksource/metag_generic.c
drivers/clocksource/time-armada-370-xp.c
drivers/clocksource/timer-marco.c
drivers/cpufreq/cpufreq.c
drivers/cpufreq/cpufreq_conservative.c
drivers/cpufreq/cpufreq_governor.c
drivers/cpufreq/cpufreq_governor.h
drivers/cpufreq/cpufreq_ondemand.c
drivers/cpufreq/cpufreq_stats.c
drivers/cpufreq/dbx500-cpufreq.c
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/longhaul.c
drivers/cpufreq/longhaul.h
drivers/cpufreq/longrun.c
drivers/cpufreq/loongson2_cpufreq.c
drivers/cpufreq/omap-cpufreq.c
drivers/cpufreq/powernow-k7.c
drivers/cpufreq/powernow-k8.c
drivers/cpufreq/s3c24xx-cpufreq.c
drivers/cpuidle/governors/menu.c
drivers/crypto/caam/caamhash.c
drivers/dma/pch_dma.c
drivers/dma/pl330.c
drivers/dma/sh/shdma.c
drivers/edac/edac_mc.c
drivers/edac/edac_mc_sysfs.c
drivers/edac/i5100_edac.c
drivers/firewire/core-cdev.c
drivers/firewire/ohci.c
drivers/firmware/dmi_scan.c
drivers/firmware/efi/efivars.c
drivers/gpio/gpio-msm-v1.c
drivers/gpio/gpio-msm-v2.c
drivers/gpu/drm/ast/ast_ttm.c
drivers/gpu/drm/cirrus/cirrus_ttm.c
drivers/gpu/drm/drm_crtc_helper.c
drivers/gpu/drm/drm_irq.c
drivers/gpu/drm/exynos/exynos_ddc.c
drivers/gpu/drm/exynos/exynos_drm_fimc.c
drivers/gpu/drm/exynos/exynos_drm_fimd.c
drivers/gpu/drm/exynos/exynos_drm_g2d.c
drivers/gpu/drm/exynos/exynos_drm_gsc.c
drivers/gpu/drm/exynos/exynos_drm_hdmi.c
drivers/gpu/drm/exynos/exynos_drm_ipp.c
drivers/gpu/drm/exynos/exynos_drm_rotator.c
drivers/gpu/drm/exynos/exynos_drm_vidi.c
drivers/gpu/drm/exynos/exynos_hdmi.c
drivers/gpu/drm/exynos/exynos_hdmiphy.c
drivers/gpu/drm/exynos/exynos_mixer.c
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_dmabuf.c
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_panel.c
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/i915/intel_ringbuffer.c
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/mgag200/mgag200_ttm.c
drivers/gpu/drm/nouveau/core/engine/bsp/nvc0.c
drivers/gpu/drm/nouveau/core/engine/bsp/nve0.c
drivers/gpu/drm/nouveau/core/engine/disp/hdanva3.c
drivers/gpu/drm/nouveau/core/engine/disp/hdanvd0.c
drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
drivers/gpu/drm/nouveau/core/engine/falcon.c
drivers/gpu/drm/nouveau/core/engine/mpeg/nv31.c
drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
drivers/gpu/drm/nouveau/core/engine/ppp/nvc0.c
drivers/gpu/drm/nouveau/core/engine/vp/nvc0.c
drivers/gpu/drm/nouveau/core/engine/vp/nve0.c
drivers/gpu/drm/nouveau/core/engine/xtensa.c
drivers/gpu/drm/nouveau/core/include/engine/falcon.h
drivers/gpu/drm/nouveau/core/include/subdev/vm.h
drivers/gpu/drm/nouveau/core/subdev/fb/priv.h
drivers/gpu/drm/nouveau/core/subdev/fb/ramnv50.c
drivers/gpu/drm/nouveau/core/subdev/fb/ramnvc0.c
drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c
drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
drivers/gpu/drm/nouveau/core/subdev/vm/base.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nouveau_fbcon.c
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nv17_fence.c
drivers/gpu/drm/nouveau/nv50_display.c
drivers/gpu/drm/nouveau/nv50_fence.c
drivers/gpu/drm/qxl/qxl_cmd.c
drivers/gpu/drm/qxl/qxl_display.c
drivers/gpu/drm/qxl/qxl_draw.c
drivers/gpu/drm/qxl/qxl_drv.h
drivers/gpu/drm/qxl/qxl_fb.c
drivers/gpu/drm/qxl/qxl_fence.c
drivers/gpu/drm/qxl/qxl_gem.c
drivers/gpu/drm/qxl/qxl_image.c
drivers/gpu/drm/qxl/qxl_ioctl.c
drivers/gpu/drm/qxl/qxl_object.c
drivers/gpu/drm/qxl/qxl_object.h
drivers/gpu/drm/qxl/qxl_release.c
drivers/gpu/drm/qxl/qxl_ttm.c
drivers/gpu/drm/radeon/atom.c
drivers/gpu/drm/radeon/atombios_dp.c
drivers/gpu/drm/radeon/btc_dpm.c
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/radeon/cikd.h
drivers/gpu/drm/radeon/cypress_dpm.c
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/evergreen_hdmi.c
drivers/gpu/drm/radeon/evergreend.h
drivers/gpu/drm/radeon/ni.c
drivers/gpu/drm/radeon/ni_dpm.c
drivers/gpu/drm/radeon/nid.h
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/r600_dpm.c
drivers/gpu/drm/radeon/r600_hdmi.c
drivers/gpu/drm/radeon/r600d.h
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_atombios.c
drivers/gpu/drm/radeon/radeon_combios.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_gart.c
drivers/gpu/drm/radeon/radeon_irq_kms.c
drivers/gpu/drm/radeon/radeon_object.c
drivers/gpu/drm/radeon/radeon_object.h
drivers/gpu/drm/radeon/radeon_pm.c
drivers/gpu/drm/radeon/radeon_ring.c
drivers/gpu/drm/radeon/radeon_sa.c
drivers/gpu/drm/radeon/radeon_uvd.c
drivers/gpu/drm/radeon/rs780_dpm.c
drivers/gpu/drm/radeon/rs780d.h
drivers/gpu/drm/radeon/rv6xx_dpm.c
drivers/gpu/drm/radeon/rv770.c
drivers/gpu/drm/radeon/rv770_dpm.c
drivers/gpu/drm/radeon/rv770_dpm.h
drivers/gpu/drm/radeon/si.c
drivers/gpu/drm/radeon/si_dpm.c
drivers/gpu/drm/radeon/sid.h
drivers/gpu/drm/radeon/sumo_dpm.c
drivers/gpu/drm/rcar-du/rcar_du_drv.c
drivers/gpu/drm/shmobile/shmob_drm_drv.c
drivers/hid/hid-logitech-dj.c
drivers/hid/hid-logitech-dj.h
drivers/hid/hid-sony.c
drivers/hid/hidraw.c
drivers/hv/hv_balloon.c
drivers/hv/vmbus_drv.c
drivers/hwmon/abx500.c
drivers/hwmon/adt7470.c
drivers/hwmon/coretemp.c
drivers/hwmon/max6697.c
drivers/hwmon/via-cputemp.c
drivers/i2c/busses/i2c-kempld.c
drivers/i2c/busses/i2c-mxs.c
drivers/iio/adc/ti_am335x_adc.c
drivers/iio/dac/ad7303.c
drivers/iio/industrialio-trigger.c
drivers/iio/inkern.c
drivers/iio/pressure/st_pressure_core.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/mad.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/cxgb4/qp.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/nes/nes_hw.c
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/hw/ocrdma/ocrdma_ah.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/qib/qib_iba7322.c
drivers/infiniband/hw/qib/qib_sdma.c
drivers/infiniband/ulp/ipoib/ipoib_ib.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/ipoib/ipoib_netlink.c
drivers/irqchip/irq-gic.c
drivers/isdn/hardware/mISDN/hfcpci.c
drivers/macintosh/windfarm_rm31.c
drivers/md/bcache/alloc.c
drivers/md/bcache/bcache.h
drivers/md/bcache/bset.c
drivers/md/bcache/bset.h
drivers/md/bcache/btree.c
drivers/md/bcache/btree.h
drivers/md/bcache/closure.c
drivers/md/bcache/debug.c
drivers/md/bcache/debug.h
drivers/md/bcache/io.c
drivers/md/bcache/journal.c
drivers/md/bcache/movinggc.c
drivers/md/bcache/request.c
drivers/md/bcache/request.h
drivers/md/bcache/super.c
drivers/md/bcache/sysfs.c
drivers/md/bcache/trace.c
drivers/md/bcache/util.c
drivers/md/bcache/util.h
drivers/md/bcache/writeback.c
drivers/md/bcache/writeback.h [new file with mode: 0644]
drivers/md/dm-cache-policy-mq.c
drivers/md/md.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c
drivers/md/raid5.h
drivers/media/i2c/ml86v7667.c
drivers/media/pci/saa7134/saa7134-alsa.c
drivers/media/platform/coda.c
drivers/media/platform/s5p-g2d/g2d.c
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/usb/em28xx/em28xx-i2c.c
drivers/media/usb/hdpvr/hdpvr-core.c
drivers/media/usb/usbtv/Kconfig
drivers/media/usb/usbtv/usbtv.c
drivers/misc/atmel-ssc.c
drivers/misc/mei/hbm.c
drivers/misc/mei/hw-me.c
drivers/misc/mei/init.c
drivers/mmc/host/pxamci.c
drivers/net/arcnet/arcnet.c
drivers/net/bonding/bond_3ad.c
drivers/net/bonding/bond_alb.c
drivers/net/bonding/bond_main.c
drivers/net/bonding/bond_procfs.c
drivers/net/bonding/bond_sysfs.c
drivers/net/bonding/bonding.h
drivers/net/can/at91_can.c
drivers/net/can/c_can/c_can_platform.c
drivers/net/can/flexcan.c
drivers/net/can/mcp251x.c
drivers/net/can/usb/esd_usb2.c
drivers/net/can/usb/peak_usb/pcan_usb.c
drivers/net/can/usb/usb_8dev.c
drivers/net/ethernet/8390/ax88796.c
drivers/net/ethernet/Kconfig
drivers/net/ethernet/Makefile
drivers/net/ethernet/allwinner/Kconfig
drivers/net/ethernet/amd/pcnet32.c
drivers/net/ethernet/arc/emac_main.c
drivers/net/ethernet/atheros/atl1c/atl1c.h
drivers/net/ethernet/atheros/atl1c/atl1c_main.c
drivers/net/ethernet/atheros/atl1e/atl1e_main.c
drivers/net/ethernet/broadcom/Kconfig
drivers/net/ethernet/broadcom/bcm63xx_enet.c
drivers/net/ethernet/broadcom/bnx2.c
drivers/net/ethernet/broadcom/bnx2.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
drivers/net/ethernet/broadcom/cnic.c
drivers/net/ethernet/broadcom/cnic.h
drivers/net/ethernet/broadcom/cnic_defs.h
drivers/net/ethernet/broadcom/cnic_if.h
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/broadcom/tg3.h
drivers/net/ethernet/brocade/bna/bna_tx_rx.c
drivers/net/ethernet/brocade/bna/cna.h
drivers/net/ethernet/cadence/macb.c
drivers/net/ethernet/chelsio/cxgb3/sge.c
drivers/net/ethernet/cisco/enic/Makefile
drivers/net/ethernet/cisco/enic/enic.h
drivers/net/ethernet/cisco/enic/enic_api.c [new file with mode: 0644]
drivers/net/ethernet/cisco/enic/enic_api.h [new file with mode: 0644]
drivers/net/ethernet/cisco/enic/enic_dev.h
drivers/net/ethernet/cisco/enic/enic_ethtool.c [new file with mode: 0644]
drivers/net/ethernet/cisco/enic/enic_main.c
drivers/net/ethernet/cisco/enic/enic_res.h
drivers/net/ethernet/cisco/enic/vnic_devcmd.h
drivers/net/ethernet/cisco/enic/vnic_rq.c
drivers/net/ethernet/cisco/enic/vnic_rq.h
drivers/net/ethernet/cisco/enic/vnic_wq.c
drivers/net/ethernet/cisco/enic/vnic_wq.h
drivers/net/ethernet/dec/tulip/tulip_core.c
drivers/net/ethernet/dlink/sundance.c
drivers/net/ethernet/emulex/benet/be.h
drivers/net/ethernet/emulex/benet/be_cmds.c
drivers/net/ethernet/emulex/benet/be_cmds.h
drivers/net/ethernet/emulex/benet/be_ethtool.c
drivers/net/ethernet/emulex/benet/be_main.c
drivers/net/ethernet/emulex/benet/be_roce.c
drivers/net/ethernet/emulex/benet/be_roce.h
drivers/net/ethernet/freescale/fec.h
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
drivers/net/ethernet/freescale/fsl_pq_mdio.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/freescale/gianfar.h
drivers/net/ethernet/freescale/gianfar_ethtool.c
drivers/net/ethernet/freescale/ucc_geth.c
drivers/net/ethernet/i825xx/sun3_82586.h
drivers/net/ethernet/ibm/emac/core.c
drivers/net/ethernet/intel/e100.c
drivers/net/ethernet/intel/e1000e/82571.c
drivers/net/ethernet/intel/e1000e/e1000.h
drivers/net/ethernet/intel/e1000e/ethtool.c
drivers/net/ethernet/intel/e1000e/hw.h
drivers/net/ethernet/intel/e1000e/ich8lan.c
drivers/net/ethernet/intel/e1000e/ich8lan.h
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/igb/e1000_82575.c
drivers/net/ethernet/intel/igb/e1000_defines.h
drivers/net/ethernet/intel/igb/e1000_hw.h
drivers/net/ethernet/intel/igb/e1000_i210.c
drivers/net/ethernet/intel/igb/e1000_i210.h
drivers/net/ethernet/intel/igb/e1000_nvm.c
drivers/net/ethernet/intel/igb/e1000_nvm.h
drivers/net/ethernet/intel/igb/igb.h
drivers/net/ethernet/intel/igb/igb_ethtool.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igb/igb_ptp.c
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/marvell/skge.c
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_tx.c
drivers/net/ethernet/mellanox/mlx4/eq.c
drivers/net/ethernet/mellanox/mlx4/fw.c
drivers/net/ethernet/mellanox/mlx4/fw.h
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/mcg.c
drivers/net/ethernet/mellanox/mlx4/mlx4.h
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
drivers/net/ethernet/mellanox/mlx5/core/eq.c
drivers/net/ethernet/mellanox/mlx5/core/fw.c
drivers/net/ethernet/mellanox/mlx5/core/health.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
drivers/net/ethernet/mellanox/mlx5/core/uar.c
drivers/net/ethernet/micrel/ks8842.c
drivers/net/ethernet/micrel/ks8851_mll.c
drivers/net/ethernet/moxa/Kconfig [new file with mode: 0644]
drivers/net/ethernet/moxa/Makefile [new file with mode: 0644]
drivers/net/ethernet/moxa/moxart_ether.c [new file with mode: 0644]
drivers/net/ethernet/moxa/moxart_ether.h [new file with mode: 0644]
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
drivers/net/ethernet/nuvoton/w90p910_ether.c
drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h
drivers/net/ethernet/pasemi/pasemi_mac.c
drivers/net/ethernet/pasemi/pasemi_mac.h
drivers/net/ethernet/qlogic/Kconfig
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
drivers/net/ethernet/qlogic/qlcnic/Makefile
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c [new file with mode: 0644]
drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h [new file with mode: 0644]
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.h
drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
drivers/net/ethernet/qlogic/qlge/qlge.h
drivers/net/ethernet/realtek/8139cp.c
drivers/net/ethernet/realtek/r8169.c
drivers/net/ethernet/renesas/Kconfig
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/renesas/sh_eth.h
drivers/net/ethernet/sfc/Makefile
drivers/net/ethernet/sfc/efx.c
drivers/net/ethernet/sfc/efx.h
drivers/net/ethernet/sfc/enum.h
drivers/net/ethernet/sfc/ethtool.c
drivers/net/ethernet/sfc/falcon.c
drivers/net/ethernet/sfc/falcon_xmac.c [deleted file]
drivers/net/ethernet/sfc/farch.c [new file with mode: 0644]
drivers/net/ethernet/sfc/farch_regs.h [new file with mode: 0644]
drivers/net/ethernet/sfc/filter.c [deleted file]
drivers/net/ethernet/sfc/filter.h
drivers/net/ethernet/sfc/io.h
drivers/net/ethernet/sfc/mcdi.c
drivers/net/ethernet/sfc/mcdi.h
drivers/net/ethernet/sfc/mcdi_mac.c [deleted file]
drivers/net/ethernet/sfc/mcdi_mon.c
drivers/net/ethernet/sfc/mcdi_pcol.h
drivers/net/ethernet/sfc/mcdi_phy.c [deleted file]
drivers/net/ethernet/sfc/mcdi_port.c [new file with mode: 0644]
drivers/net/ethernet/sfc/mtd.c
drivers/net/ethernet/sfc/net_driver.h
drivers/net/ethernet/sfc/nic.c
drivers/net/ethernet/sfc/nic.h
drivers/net/ethernet/sfc/phy.h
drivers/net/ethernet/sfc/ptp.c
drivers/net/ethernet/sfc/regs.h [deleted file]
drivers/net/ethernet/sfc/rx.c
drivers/net/ethernet/sfc/selftest.c
drivers/net/ethernet/sfc/siena.c
drivers/net/ethernet/sfc/siena_sriov.c
drivers/net/ethernet/sfc/spi.h [deleted file]
drivers/net/ethernet/sfc/tx.c
drivers/net/ethernet/sfc/workarounds.h
drivers/net/ethernet/sis/sis190.c
drivers/net/ethernet/sis/sis900.c
drivers/net/ethernet/stmicro/stmmac/ring_mode.c
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
drivers/net/ethernet/sun/sunbmac.c
drivers/net/ethernet/sun/sunhme.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/ethernet/ti/cpsw.h [new file with mode: 0644]
drivers/net/ethernet/ti/davinci_cpdma.c
drivers/net/ethernet/ti/davinci_emac.c
drivers/net/ethernet/ti/davinci_mdio.c
drivers/net/ethernet/tile/Kconfig
drivers/net/ethernet/tile/tilegx.c
drivers/net/ethernet/tile/tilepro.c
drivers/net/ethernet/via/via-rhine.c
drivers/net/ethernet/via/via-velocity.c
drivers/net/ethernet/xilinx/xilinx_emaclite.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/irda/pxaficp_ir.c
drivers/net/irda/via-ircc.c
drivers/net/macvlan.c
drivers/net/macvtap.c
drivers/net/phy/mdio-mux-mmioreg.c
drivers/net/phy/mdio-octeon.c
drivers/net/phy/mdio-sun4i.c
drivers/net/phy/micrel.c
drivers/net/phy/realtek.c
drivers/net/ppp/pptp.c
drivers/net/team/team.c
drivers/net/tun.c
drivers/net/usb/asix.h
drivers/net/usb/asix_devices.c
drivers/net/usb/ax88172a.c
drivers/net/usb/ax88179_178a.c
drivers/net/usb/hso.c
drivers/net/usb/r8152.c
drivers/net/usb/r815x.c
drivers/net/usb/smsc75xx.c
drivers/net/usb/usbnet.c
drivers/net/veth.c
drivers/net/virtio_net.c
drivers/net/vmxnet3/vmxnet3_drv.c
drivers/net/vmxnet3/vmxnet3_int.h
drivers/net/vxlan.c
drivers/net/wan/sbni.c
drivers/net/xen-netback/common.h
drivers/net/xen-netback/interface.c
drivers/net/xen-netback/netback.c
drivers/net/xen-netfront.c
drivers/of/fdt.c
drivers/of/irq.c
drivers/oprofile/timer_int.c
drivers/parisc/iosapic.c
drivers/pci/host/pci-mvebu.c
drivers/pci/hotplug/Kconfig
drivers/pci/hotplug/pciehp_pci.c
drivers/pci/hotplug/rpadlpar_core.c
drivers/pci/pci-acpi.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/Kconfig
drivers/pci/probe.c
drivers/pci/setup-bus.c
drivers/pinctrl/core.c
drivers/pinctrl/pinctrl-single.c
drivers/pinctrl/pinctrl-sunxi.c
drivers/pinctrl/pinctrl-sunxi.h
drivers/pinctrl/sh-pfc/pfc-sh73a0.c
drivers/pinctrl/sirf/pinctrl-atlas6.c
drivers/platform/olpc/olpc-ec.c
drivers/platform/x86/hp-wmi.c
drivers/platform/x86/sony-laptop.c
drivers/pnp/pnpacpi/rsparser.c
drivers/pnp/resource.c
drivers/rapidio/rio.c
drivers/rtc/rtc-stmp3xxx.c
drivers/rtc/rtc-twl.c
drivers/s390/block/dasd.c
drivers/s390/cio/qdio_main.c
drivers/s390/crypto/ap_bus.c
drivers/scsi/bnx2i/57xx_iscsi_hsi.h
drivers/scsi/bnx2i/bnx2i_init.c
drivers/scsi/fnic/fnic.h
drivers/scsi/fnic/fnic_main.c
drivers/scsi/isci/request.c
drivers/scsi/isci/task.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/mvsas/mv_sas.c
drivers/scsi/mvsas/mv_sas.h
drivers/scsi/qla2xxx/qla_iocb.c
drivers/scsi/scsi.c
drivers/scsi/sd.c
drivers/scsi/virtio_scsi.c
drivers/spi/spi-altera.c
drivers/spi/spi-davinci.c
drivers/spi/spi-nuc900.c
drivers/spi/spi-s3c64xx.c
drivers/spi/spi-xilinx.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/android/logger.c
drivers/staging/comedi/TODO
drivers/staging/comedi/comedi_fops.c
drivers/staging/csr/Kconfig [deleted file]
drivers/staging/csr/LICENSE.txt [deleted file]
drivers/staging/csr/Makefile [deleted file]
drivers/staging/csr/bh.c [deleted file]
drivers/staging/csr/csr_framework_ext.c [deleted file]
drivers/staging/csr/csr_framework_ext.h [deleted file]
drivers/staging/csr/csr_framework_ext_types.h [deleted file]
drivers/staging/csr/csr_log.h [deleted file]
drivers/staging/csr/csr_log_configure.h [deleted file]
drivers/staging/csr/csr_log_text.h [deleted file]
drivers/staging/csr/csr_macro.h [deleted file]
drivers/staging/csr/csr_msg_transport.h [deleted file]
drivers/staging/csr/csr_msgconv.c [deleted file]
drivers/staging/csr/csr_msgconv.h [deleted file]
drivers/staging/csr/csr_prim_defs.h [deleted file]
drivers/staging/csr/csr_result.h [deleted file]
drivers/staging/csr/csr_sched.h [deleted file]
drivers/staging/csr/csr_sdio.h [deleted file]
drivers/staging/csr/csr_serialize_primitive_types.c [deleted file]
drivers/staging/csr/csr_time.c [deleted file]
drivers/staging/csr/csr_time.h [deleted file]
drivers/staging/csr/csr_util.c [deleted file]
drivers/staging/csr/csr_wifi_common.h [deleted file]
drivers/staging/csr/csr_wifi_fsm.h [deleted file]
drivers/staging/csr/csr_wifi_fsm_event.h [deleted file]
drivers/staging/csr/csr_wifi_fsm_types.h [deleted file]
drivers/staging/csr/csr_wifi_hip_card.h [deleted file]
drivers/staging/csr/csr_wifi_hip_card_sdio.c [deleted file]
drivers/staging/csr/csr_wifi_hip_card_sdio.h [deleted file]
drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c [deleted file]
drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c [deleted file]
drivers/staging/csr/csr_wifi_hip_chiphelper.c [deleted file]
drivers/staging/csr/csr_wifi_hip_chiphelper.h [deleted file]
drivers/staging/csr/csr_wifi_hip_chiphelper_private.h [deleted file]
drivers/staging/csr/csr_wifi_hip_conversions.h [deleted file]
drivers/staging/csr/csr_wifi_hip_download.c [deleted file]
drivers/staging/csr/csr_wifi_hip_dump.c [deleted file]
drivers/staging/csr/csr_wifi_hip_packing.c [deleted file]
drivers/staging/csr/csr_wifi_hip_send.c [deleted file]
drivers/staging/csr/csr_wifi_hip_signals.c [deleted file]
drivers/staging/csr/csr_wifi_hip_signals.h [deleted file]
drivers/staging/csr/csr_wifi_hip_sigs.h [deleted file]
drivers/staging/csr/csr_wifi_hip_ta_sampling.c [deleted file]
drivers/staging/csr/csr_wifi_hip_ta_sampling.h [deleted file]
drivers/staging/csr/csr_wifi_hip_udi.c [deleted file]
drivers/staging/csr/csr_wifi_hip_unifi.h [deleted file]
drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c [deleted file]
drivers/staging/csr/csr_wifi_hip_unifi_udi.h [deleted file]
drivers/staging/csr/csr_wifi_hip_unifihw.h [deleted file]
drivers/staging/csr/csr_wifi_hip_unifiversion.h [deleted file]
drivers/staging/csr/csr_wifi_hip_xbv.c [deleted file]
drivers/staging/csr/csr_wifi_hip_xbv.h [deleted file]
drivers/staging/csr/csr_wifi_hostio_prim.h [deleted file]
drivers/staging/csr/csr_wifi_lib.h [deleted file]
drivers/staging/csr/csr_wifi_msgconv.h [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_converter_init.c [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_converter_init.h [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_lib.h [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_prim.h [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_sef.c [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_sef.h [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_serialize.c [deleted file]
drivers/staging/csr/csr_wifi_nme_ap_serialize.h [deleted file]
drivers/staging/csr/csr_wifi_nme_converter_init.h [deleted file]
drivers/staging/csr/csr_wifi_nme_lib.h [deleted file]
drivers/staging/csr/csr_wifi_nme_prim.h [deleted file]
drivers/staging/csr/csr_wifi_nme_serialize.h [deleted file]
drivers/staging/csr/csr_wifi_nme_task.h [deleted file]
drivers/staging/csr/csr_wifi_private_common.h [deleted file]
drivers/staging/csr/csr_wifi_result.h [deleted file]
drivers/staging/csr/csr_wifi_router_converter_init.c [deleted file]
drivers/staging/csr/csr_wifi_router_converter_init.h [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_lib.h [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_prim.h [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_sef.c [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_sef.h [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_serialize.c [deleted file]
drivers/staging/csr/csr_wifi_router_ctrl_serialize.h [deleted file]
drivers/staging/csr/csr_wifi_router_free_downstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_router_free_upstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_router_lib.h [deleted file]
drivers/staging/csr/csr_wifi_router_prim.h [deleted file]
drivers/staging/csr/csr_wifi_router_sef.c [deleted file]
drivers/staging/csr/csr_wifi_router_sef.h [deleted file]
drivers/staging/csr/csr_wifi_router_serialize.c [deleted file]
drivers/staging/csr/csr_wifi_router_serialize.h [deleted file]
drivers/staging/csr/csr_wifi_router_task.h [deleted file]
drivers/staging/csr/csr_wifi_router_transport.c [deleted file]
drivers/staging/csr/csr_wifi_serialize_primitive_types.c [deleted file]
drivers/staging/csr/csr_wifi_sme_ap_lib.h [deleted file]
drivers/staging/csr/csr_wifi_sme_ap_prim.h [deleted file]
drivers/staging/csr/csr_wifi_sme_converter_init.c [deleted file]
drivers/staging/csr/csr_wifi_sme_converter_init.h [deleted file]
drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c [deleted file]
drivers/staging/csr/csr_wifi_sme_lib.h [deleted file]
drivers/staging/csr/csr_wifi_sme_prim.h [deleted file]
drivers/staging/csr/csr_wifi_sme_sef.c [deleted file]
drivers/staging/csr/csr_wifi_sme_sef.h [deleted file]
drivers/staging/csr/csr_wifi_sme_serialize.c [deleted file]
drivers/staging/csr/csr_wifi_sme_serialize.h [deleted file]
drivers/staging/csr/csr_wifi_sme_task.h [deleted file]
drivers/staging/csr/csr_wifi_vif_utils.h [deleted file]
drivers/staging/csr/data_tx.c [deleted file]
drivers/staging/csr/drv.c [deleted file]
drivers/staging/csr/firmware.c [deleted file]
drivers/staging/csr/inet.c [deleted file]
drivers/staging/csr/init_hw.c [deleted file]
drivers/staging/csr/io.c [deleted file]
drivers/staging/csr/mlme.c [deleted file]
drivers/staging/csr/monitor.c [deleted file]
drivers/staging/csr/netdev.c [deleted file]
drivers/staging/csr/os.c [deleted file]
drivers/staging/csr/putest.c [deleted file]
drivers/staging/csr/sdio_events.c [deleted file]
drivers/staging/csr/sdio_mmc.c [deleted file]
drivers/staging/csr/sdio_stubs.c [deleted file]
drivers/staging/csr/sme_blocking.c [deleted file]
drivers/staging/csr/sme_mgt.c [deleted file]
drivers/staging/csr/sme_native.c [deleted file]
drivers/staging/csr/sme_sys.c [deleted file]
drivers/staging/csr/sme_userspace.c [deleted file]
drivers/staging/csr/sme_userspace.h [deleted file]
drivers/staging/csr/sme_wext.c [deleted file]
drivers/staging/csr/ul_int.c [deleted file]
drivers/staging/csr/unifi_clients.h [deleted file]
drivers/staging/csr/unifi_config.h [deleted file]
drivers/staging/csr/unifi_dbg.c [deleted file]
drivers/staging/csr/unifi_event.c [deleted file]
drivers/staging/csr/unifi_native.h [deleted file]
drivers/staging/csr/unifi_os.h [deleted file]
drivers/staging/csr/unifi_pdu_processing.c [deleted file]
drivers/staging/csr/unifi_priv.h [deleted file]
drivers/staging/csr/unifi_sme.c [deleted file]
drivers/staging/csr/unifi_sme.h [deleted file]
drivers/staging/csr/unifi_wext.h [deleted file]
drivers/staging/csr/unifiio.h [deleted file]
drivers/staging/csr/wext_events.c [deleted file]
drivers/staging/frontier/alphatrack.c
drivers/staging/gdm72xx/gdm_qos.c
drivers/staging/iio/accel/lis3l02dq_core.c
drivers/staging/iio/adc/ad7291.c
drivers/staging/iio/adc/mxs-lradc.c
drivers/staging/imx-drm/Kconfig
drivers/staging/line6/pcm.c
drivers/staging/tidspbridge/pmgr/dbll.c
drivers/staging/zcache/zcache-main.c
drivers/staging/zram/zram_drv.c
drivers/thermal/x86_pkg_temp_thermal.c
drivers/tty/serial/8250/8250_early.c
drivers/tty/serial/8250/8250_gsc.c
drivers/tty/serial/Kconfig
drivers/tty/serial/arc_uart.c
drivers/tty/serial/mxs-auart.c
drivers/tty/synclinkmp.c
drivers/tty/tty_port.c
drivers/usb/chipidea/Kconfig
drivers/usb/chipidea/bits.h
drivers/usb/class/usbtmc.c
drivers/usb/core/hub.c
drivers/usb/core/hub.h
drivers/usb/core/quirks.c
drivers/usb/dwc3/Kconfig
drivers/usb/dwc3/core.c
drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/Kconfig
drivers/usb/gadget/at91_udc.c
drivers/usb/gadget/ether.c
drivers/usb/gadget/f_ecm.c
drivers/usb/gadget/f_eem.c
drivers/usb/gadget/f_ncm.c
drivers/usb/gadget/f_phonet.c
drivers/usb/gadget/f_rndis.c
drivers/usb/gadget/f_subset.c
drivers/usb/gadget/fotg210-udc.c
drivers/usb/gadget/multi.c
drivers/usb/gadget/mv_u3d_core.c
drivers/usb/gadget/udc-core.c
drivers/usb/host/ehci-hub.c
drivers/usb/host/ehci-sched.c
drivers/usb/host/pci-quirks.h
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c
drivers/usb/misc/adutux.c
drivers/usb/misc/sisusbvga/sisusb.c
drivers/usb/musb/omap2430.c
drivers/usb/musb/tusb6010.c
drivers/usb/phy/phy-omap-usb3.c
drivers/usb/phy/phy-samsung-usb2.c
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/serial/Kconfig
drivers/usb/serial/Makefile
drivers/usb/serial/cp210x.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ftdi_sio_ids.h
drivers/usb/serial/keyspan.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/option.c
drivers/usb/serial/suunto.c [new file with mode: 0644]
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/usb_wwan.c
drivers/usb/storage/unusual_devs.h
drivers/usb/wusbcore/wa-xfer.c
drivers/vfio/pci/vfio_pci.c
drivers/vfio/vfio.c
drivers/vhost/net.c
drivers/vhost/scsi.c
drivers/vhost/test.c
drivers/vhost/vhost.c
drivers/vhost/vhost.h
drivers/video/aty/atyfb_base.c
drivers/video/backlight/max8925_bl.c
drivers/video/mxsfb.c
drivers/video/nuc900fb.c
drivers/video/omap2/displays-new/connector-analog-tv.c
drivers/video/sgivwfb.c
drivers/video/sh7760fb.c
drivers/video/uvesafb.c
drivers/video/vga16fb.c
drivers/video/xilinxfb.c
drivers/xen/Kconfig
drivers/xen/Makefile
drivers/xen/events.c
drivers/xen/evtchn.c
drivers/xen/xen-acpi-cpuhotplug.c
drivers/xen/xenbus/xenbus_probe_frontend.c
fs/btrfs/backref.c
fs/btrfs/ctree.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/scrub.c
fs/btrfs/transaction.c
fs/btrfs/transaction.h
fs/btrfs/tree-log.c
fs/cifs/cifsencrypt.c
fs/cifs/cifsfs.c
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/connect.c
fs/cifs/file.c
fs/cifs/link.c
fs/cifs/readdir.c
fs/cifs/sess.c
fs/cifs/smb1ops.c
fs/cifs/smb2transport.c
fs/debugfs/inode.c
fs/dlm/user.c
fs/exec.c
fs/ext3/namei.c
fs/ext4/balloc.c
fs/ext4/ext4.h
fs/ext4/ext4_jbd2.c
fs/ext4/extents.c
fs/ext4/extents_status.c
fs/ext4/file.c
fs/ext4/ialloc.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/mballoc.c
fs/ext4/namei.c
fs/ext4/page-io.c
fs/ext4/super.c
fs/fcntl.c
fs/fuse/dir.c
fs/gfs2/glock.c
fs/gfs2/glops.c
fs/gfs2/inode.c
fs/gfs2/main.c
fs/hugetlbfs/inode.c
fs/lockd/clntlock.c
fs/lockd/clntproc.c
fs/lockd/svclock.c
fs/namei.c
fs/nfs/inode.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4xdr.c
fs/nfs/super.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfsd.h
fs/nfsd/nfssvc.c
fs/nfsd/vfs.c
fs/nilfs2/segbuf.c
fs/ocfs2/aops.c
fs/ocfs2/dir.c
fs/ocfs2/file.c
fs/ocfs2/journal.h
fs/ocfs2/move_extents.c
fs/ocfs2/refcounttree.c
fs/ocfs2/refcounttree.h
fs/open.c
fs/proc/generic.c
fs/proc/root.c
fs/proc/task_mmu.c
fs/proc/vmcore.c
fs/reiserfs/procfs.c
fs/reiserfs/super.c
fs/super.c
fs/sysfs/group.c
fs/xfs/xfs_dinode.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_log_recover.c
include/acpi/acpi_bus.h
include/acpi/acpixf.h
include/acpi/actypes.h
include/asm-generic/pgtable.h
include/asm-generic/tlb.h
include/drm/drm_fixed.h
include/dt-bindings/clock/vf610-clock.h
include/dt-bindings/pinctrl/am33xx.h
include/linux/can/platform/mcp251x.h
include/linux/cgroup.h
include/linux/cgroup_subsys.h
include/linux/cpu.h
include/linux/crc-t10dif.h
include/linux/dcache.h
include/linux/device.h
include/linux/dm9000.h
include/linux/drbd.h
include/linux/drbd_genl.h
include/linux/drbd_limits.h
include/linux/edac.h
include/linux/firewire.h
include/linux/fs_enet_pd.h
include/linux/ftrace_event.h
include/linux/ieee80211.h
include/linux/if_team.h
include/linux/if_vlan.h
include/linux/igmp.h
include/linux/iio/iio.h
include/linux/iio/trigger.h
include/linux/inetdevice.h
include/linux/ipv6.h
include/linux/kernel.h
include/linux/list.h
include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
include/linux/mfd/ti_am335x_tscadc.h
include/linux/mlx4/cmd.h
include/linux/mlx4/device.h
include/linux/mlx4/qp.h
include/linux/mlx5/device.h
include/linux/mlx5/driver.h
include/linux/mm_types.h
include/linux/mv643xx_eth.h
include/linux/netdevice.h
include/linux/netfilter.h
include/linux/netfilter/xt_HMARK.h [deleted file]
include/linux/netfilter/xt_rpfilter.h [deleted file]
include/linux/pci.h
include/linux/pci_hotplug.h
include/linux/perf_event.h
include/linux/platform_data/cpsw.h [deleted file]
include/linux/platform_data/mmc-pxamci.h
include/linux/pm_wakeup.h
include/linux/regmap.h
include/linux/sched.h
include/linux/sh_eth.h
include/linux/shdma-base.h
include/linux/skbuff.h
include/linux/smsc911x.h
include/linux/socket.h
include/linux/spinlock.h
include/linux/sunrpc/sched.h
include/linux/swapops.h
include/linux/syscalls.h
include/linux/sysfs.h
include/linux/tcp.h
include/linux/tick.h
include/linux/usb.h
include/linux/usb/usbnet.h
include/linux/user_namespace.h
include/linux/uwb/spec.h
include/linux/vmpressure.h
include/media/tveeprom.h
include/media/v4l2-ctrls.h
include/net/9p/transport.h
include/net/act_api.h
include/net/addrconf.h
include/net/af_rxrpc.h
include/net/af_unix.h
include/net/af_vsock.h [new file with mode: 0644]
include/net/arp.h
include/net/ax25.h
include/net/busy_poll.h
include/net/cfg80211.h
include/net/checksum.h
include/net/cls_cgroup.h
include/net/fib_rules.h
include/net/ip6_fib.h
include/net/ip6_route.h
include/net/ip6_tunnel.h
include/net/ip_tunnels.h
include/net/ipv6.h
include/net/irda/irlan_common.h
include/net/mac80211.h
include/net/ndisc.h
include/net/neighbour.h
include/net/net_namespace.h
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_conntrack_extend.h
include/net/netfilter/nf_conntrack_l4proto.h
include/net/netfilter/nf_conntrack_seqadj.h [new file with mode: 0644]
include/net/netfilter/nf_conntrack_synproxy.h [new file with mode: 0644]
include/net/netfilter/nf_nat.h
include/net/netfilter/nf_nat_helper.h
include/net/netfilter/nf_tproxy_core.h [deleted file]
include/net/netfilter/nfnetlink_queue.h
include/net/netns/ipv4.h
include/net/netns/ipv6.h
include/net/netprio_cgroup.h
include/net/pkt_cls.h
include/net/pkt_sched.h
include/net/sch_generic.h
include/net/sctp/auth.h
include/net/sctp/checksum.h
include/net/sctp/command.h
include/net/sctp/constants.h
include/net/sctp/sctp.h
include/net/sctp/sm.h
include/net/sctp/structs.h
include/net/sctp/tsnmap.h
include/net/sctp/ulpevent.h
include/net/sctp/ulpqueue.h
include/net/sock.h
include/net/tcp.h
include/net/udp.h
include/net/vsock_addr.h [new file with mode: 0644]
include/net/vxlan.h [new file with mode: 0644]
include/net/xfrm.h
include/trace/events/bcache.h
include/trace/ftrace.h
include/uapi/asm-generic/fcntl.h
include/uapi/linux/dn.h
include/uapi/linux/fib_rules.h
include/uapi/linux/firewire-cdev.h
include/uapi/linux/if_bridge.h
include/uapi/linux/if_link.h
include/uapi/linux/if_pppox.h
include/uapi/linux/if_tun.h
include/uapi/linux/ip.h
include/uapi/linux/ipv6.h
include/uapi/linux/netfilter/Kbuild
include/uapi/linux/netfilter/nf_conntrack_common.h
include/uapi/linux/netfilter/nfnetlink_conntrack.h
include/uapi/linux/netfilter/nfnetlink_queue.h
include/uapi/linux/netfilter/xt_HMARK.h [new file with mode: 0644]
include/uapi/linux/netfilter/xt_SYNPROXY.h [new file with mode: 0644]
include/uapi/linux/netfilter/xt_rpfilter.h [new file with mode: 0644]
include/uapi/linux/netfilter_bridge/ebt_802_3.h
include/uapi/linux/netfilter_ipv4/ipt_CLUSTERIP.h
include/uapi/linux/openvswitch.h
include/uapi/linux/pkt_sched.h
include/uapi/linux/sctp.h
include/uapi/linux/snmp.h
include/uapi/linux/tcp.h
include/uapi/linux/usb/ch11.h
include/uapi/linux/virtio_net.h
include/uapi/linux/wimax/i2400m.h
include/xen/interface/io/blkif.h
include/xen/interface/io/ring.h
init/Kconfig
init/calibrate.c
kernel/Makefile
kernel/cgroup.c
kernel/cpu.c
kernel/cpuset.c
kernel/events/core.c
kernel/fork.c
kernel/freezer.c
kernel/hrtimer.c
kernel/mutex.c
kernel/power/autosleep.c
kernel/power/process.c
kernel/power/qos.c
kernel/printk.c [deleted file]
kernel/printk/Makefile [new file with mode: 0644]
kernel/printk/braille.c [new file with mode: 0644]
kernel/printk/braille.h [new file with mode: 0644]
kernel/printk/console_cmdline.h [new file with mode: 0644]
kernel/printk/printk.c [new file with mode: 0644]
kernel/profile.c
kernel/ptrace.c
kernel/rcutorture.c
kernel/rcutree.c
kernel/rcutree.h
kernel/rcutree_plugin.h
kernel/relay.c
kernel/sched/core.c
kernel/sched/cpupri.c
kernel/sched/fair.c
kernel/smp.c
kernel/smpboot.c
kernel/softirq.c
kernel/sysctl.c
kernel/time/sched_clock.c
kernel/time/tick-sched.c
kernel/timer.c
kernel/trace/ftrace.c
kernel/trace/ring_buffer.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_event_perf.c
kernel/trace/trace_events.c
kernel/trace/trace_events_filter.c
kernel/trace/trace_functions.c
kernel/trace/trace_functions_graph.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_mmiotrace.c
kernel/trace/trace_output.c
kernel/trace/trace_syscalls.c
kernel/trace/trace_uprobe.c
kernel/user_namespace.c
kernel/wait.c
kernel/workqueue.c
lib/Kconfig
lib/Kconfig.debug
lib/crc-t10dif.c
lib/earlycpio.c
lib/lz4/lz4_compress.c
lib/lz4/lz4_decompress.c
lib/lz4/lz4hc_compress.c
lib/mpi/longlong.h
lib/percpu_counter.c
mm/backing-dev.c
mm/fremap.c
mm/huge_memory.c
mm/hugetlb.c
mm/memcontrol.c
mm/memory.c
mm/mempolicy.c
mm/mmap.c
mm/page-writeback.c
mm/rmap.c
mm/shmem.c
mm/slab.c
mm/slub.c
mm/swap.c
mm/swapfile.c
mm/vmpressure.c
mm/vmstat.c
mm/zbud.c
net/8021q/vlan.c
net/8021q/vlan_core.c
net/8021q/vlan_dev.c
net/9p/client.c
net/9p/trans_rdma.c
net/Kconfig
net/appletalk/atalk_proc.c
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/gateway_client.c
net/batman-adv/gateway_client.h
net/batman-adv/icmp_socket.c
net/batman-adv/main.c
net/batman-adv/main.h
net/batman-adv/routing.c
net/batman-adv/send.c
net/batman-adv/soft-interface.c
net/batman-adv/sysfs.c
net/batman-adv/translation-table.c
net/batman-adv/unicast.c
net/batman-adv/vis.c
net/bridge/br_device.c
net/bridge/br_fdb.c
net/bridge/br_if.c
net/bridge/br_input.c
net/bridge/br_mdb.c
net/bridge/br_multicast.c
net/bridge/br_netlink.c
net/bridge/br_notify.c
net/bridge/br_private.h
net/bridge/br_sysfs_br.c
net/bridge/br_vlan.c
net/ceph/messenger.c
net/core/datagram.c
net/core/dev.c
net/core/ethtool.c
net/core/fib_rules.c
net/core/flow.c
net/core/flow_dissector.c
net/core/iovec.c
net/core/neighbour.c
net/core/net-sysfs.c
net/core/pktgen.c
net/core/rtnetlink.c
net/core/skbuff.c
net/core/sock.c
net/core/stream.c
net/core/sysctl_net_core.c
net/dccp/proto.c
net/ethernet/eth.c
net/ieee802154/6lowpan.c
net/ieee802154/6lowpan.h
net/ipv4/devinet.c
net/ipv4/esp4.c
net/ipv4/fib_rules.c
net/ipv4/fib_trie.c
net/ipv4/igmp.c
net/ipv4/ip_gre.c
net/ipv4/ip_input.c
net/ipv4/ip_tunnel.c
net/ipv4/ip_tunnel_core.c
net/ipv4/ip_vti.c
net/ipv4/ipip.c
net/ipv4/ipmr.c
net/ipv4/netfilter/Kconfig
net/ipv4/netfilter/Makefile
net/ipv4/netfilter/ipt_MASQUERADE.c
net/ipv4/netfilter/ipt_REJECT.c
net/ipv4/netfilter/ipt_SYNPROXY.c [new file with mode: 0644]
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
net/ipv4/ping.c
net/ipv4/proc.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp.c
net/ipv4/tcp_cubic.c
net/ipv4/tcp_fastopen.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv4/tcp_probe.c
net/ipv4/udp.c
net/ipv6/addrconf.c
net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/esp6.c
net/ipv6/fib6_rules.c
net/ipv6/ip6_fib.c
net/ipv6/ip6_gre.c
net/ipv6/ip6_input.c
net/ipv6/ip6_tunnel.c
net/ipv6/ip6mr.c
net/ipv6/mcast.c
net/ipv6/ndisc.c
net/ipv6/netfilter/Kconfig
net/ipv6/netfilter/Makefile
net/ipv6/netfilter/ip6t_MASQUERADE.c
net/ipv6/netfilter/ip6t_REJECT.c
net/ipv6/netfilter/ip6t_SYNPROXY.c [new file with mode: 0644]
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
net/ipv6/proc.c
net/ipv6/raw.c
net/ipv6/reassembly.c
net/ipv6/route.c
net/ipv6/sit.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/ipx/ipx_proc.c
net/irda/irlan/irlan_eth.c
net/irda/irttp.c
net/iucv/iucv.c
net/key/af_key.c
net/llc/llc_proc.c
net/netfilter/Kconfig
net/netfilter/Makefile
net/netfilter/core.c
net/netfilter/ipvs/ip_vs_lblcr.c
net/netfilter/ipvs/ip_vs_proto_sctp.c
net/netfilter/ipvs/ip_vs_sh.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_expect.c
net/netfilter/nf_conntrack_labels.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_proto.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_seqadj.c [new file with mode: 0644]
net/netfilter/nf_nat_core.c
net/netfilter/nf_nat_helper.c
net/netfilter/nf_nat_proto_sctp.c
net/netfilter/nf_nat_sip.c
net/netfilter/nf_synproxy_core.c [new file with mode: 0644]
net/netfilter/nf_tproxy_core.c [deleted file]
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue_core.c
net/netfilter/nfnetlink_queue_ct.c
net/netfilter/xt_TCPMSS.c
net/netfilter/xt_TCPOPTSTRIP.c
net/netfilter/xt_TPROXY.c
net/netfilter/xt_addrtype.c
net/netfilter/xt_socket.c
net/netlabel/netlabel_cipso_v4.c
net/netlabel/netlabel_domainhash.c
net/netlabel/netlabel_domainhash.h
net/netlabel/netlabel_kapi.c
net/netlabel/netlabel_mgmt.c
net/netlabel/netlabel_unlabeled.c
net/netlink/af_netlink.c
net/netlink/af_netlink.h
net/netlink/genetlink.c
net/openvswitch/Kconfig
net/openvswitch/Makefile
net/openvswitch/actions.c
net/openvswitch/datapath.c
net/openvswitch/datapath.h
net/openvswitch/flow.c
net/openvswitch/flow.h
net/openvswitch/vport-gre.c
net/openvswitch/vport-netdev.c
net/openvswitch/vport-vxlan.c [new file with mode: 0644]
net/openvswitch/vport.c
net/openvswitch/vport.h
net/packet/af_packet.c
net/phonet/socket.c
net/sched/sch_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_generic.c
net/sched/sch_htb.c
net/sched/sch_netem.c
net/sched/sch_qfq.c
net/sctp/associola.c
net/sctp/auth.c
net/sctp/bind_addr.c
net/sctp/chunk.c
net/sctp/command.c
net/sctp/debug.c
net/sctp/endpointola.c
net/sctp/input.c
net/sctp/inqueue.c
net/sctp/ipv6.c
net/sctp/objcnt.c
net/sctp/output.c
net/sctp/outqueue.c
net/sctp/primitive.c
net/sctp/probe.c
net/sctp/proc.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c
net/sctp/sm_sideeffect.c
net/sctp/sm_statefuns.c
net/sctp/sm_statetable.c
net/sctp/socket.c
net/sctp/ssnmap.c
net/sctp/sysctl.c
net/sctp/transport.c
net/sctp/tsnmap.c
net/sctp/ulpevent.c
net/sctp/ulpqueue.c
net/socket.c
net/sunrpc/auth_gss/gss_rpc_upcall.c
net/sunrpc/auth_gss/gss_rpc_xdr.c
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/clnt.c
net/sunrpc/netns.h
net/sunrpc/rpcb_clnt.c
net/sunrpc/svcsock.c
net/sunrpc/xprtrdma/svc_rdma_marshal.c
net/sunrpc/xprtsock.c
net/tipc/bearer.c
net/tipc/server.c
net/unix/af_unix.c
net/vmw_vsock/af_vsock.c
net/vmw_vsock/af_vsock.h [deleted file]
net/vmw_vsock/vmci_transport.c
net/vmw_vsock/vmci_transport.h
net/vmw_vsock/vsock_addr.c
net/vmw_vsock/vsock_addr.h [deleted file]
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
security/selinux/include/xfrm.h
security/smack/smack_lsm.c
sound/arm/pxa2xx-pcm-lib.c
sound/core/compress_offload.c
sound/core/seq/oss/seq_oss_init.c
sound/core/seq/oss/seq_oss_midi.c
sound/oss/vwsnd.c
sound/pci/asihpi/asihpi.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/hda/hda_auto_parser.c
sound/pci/hda/hda_generic.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/soc/atmel/atmel-pcm-dma.c
sound/soc/au1x/ac97c.c
sound/soc/blackfin/bf5xx-ac97.c
sound/soc/blackfin/bf5xx-ac97.h
sound/soc/cirrus/ep93xx-ac97.c
sound/soc/codecs/cs42l52.c
sound/soc/codecs/max98088.c
sound/soc/codecs/sgtl5000.c
sound/soc/codecs/sgtl5000.h
sound/soc/codecs/wm0010.c
sound/soc/codecs/wm8978.c
sound/soc/codecs/wm8994.c
sound/soc/omap/mcbsp.c
sound/soc/omap/omap-dmic.c
sound/soc/omap/omap-mcpdm.c
sound/soc/omap/omap-pcm.c
sound/soc/s6000/s6000-pcm.c
sound/soc/samsung/i2s.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/tegra/tegra20_ac97.c
sound/soc/tegra/tegra20_spdif.c
sound/soc/tegra/tegra30_i2s.c
sound/usb/6fire/comm.c
sound/usb/6fire/comm.h
sound/usb/6fire/midi.c
sound/usb/6fire/midi.h
sound/usb/6fire/pcm.c
sound/usb/6fire/pcm.h
sound/usb/endpoint.c
sound/usb/hiface/pcm.c
sound/usb/misc/ua101.c
sound/usb/mixer.c
sound/usb/quirks.c
sound/usb/usx2y/usbusx2yaudio.c
tools/hv/hv_kvp_daemon.c

index 3b8b9b33be380b75f9a4d19a4680723f3febfce7..7e9932e55475cef2891a790e391011b77b9ff666 100644 (file)
@@ -29,6 +29,7 @@ modules.builtin
 *.bz2
 *.lzma
 *.xz
+*.lz4
 *.lzo
 *.patch
 *.gcno
diff --git a/Documentation/ABI/testing/sysfs-driver-xen-blkback b/Documentation/ABI/testing/sysfs-driver-xen-blkback
new file mode 100644 (file)
index 0000000..8bb43b6
--- /dev/null
@@ -0,0 +1,17 @@
+What:           /sys/module/xen_blkback/parameters/max_buffer_pages
+Date:           March 2013
+KernelVersion:  3.11
+Contact:        Roger Pau Monné <roger.pau@citrix.com>
+Description:
+                Maximum number of free pages to keep in each block
+                backend buffer.
+
+What:           /sys/module/xen_blkback/parameters/max_persistent_grants
+Date:           March 2013
+KernelVersion:  3.11
+Contact:        Roger Pau Monné <roger.pau@citrix.com>
+Description:
+                Maximum number of grants to map persistently in
+                blkback. If the frontend tries to use more than
+                max_persistent_grants, the LRU kicks in and starts
+                removing 5% of max_persistent_grants every 100ms.
diff --git a/Documentation/ABI/testing/sysfs-driver-xen-blkfront b/Documentation/ABI/testing/sysfs-driver-xen-blkfront
new file mode 100644 (file)
index 0000000..c0a6cb7
--- /dev/null
@@ -0,0 +1,10 @@
+What:           /sys/module/xen_blkfront/parameters/max
+Date:           June 2013
+KernelVersion:  3.11
+Contact:        Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Description:
+                Maximum number of segments that the frontend will negotiate
+                with the backend for indirect descriptors. The default value
+                is 32 - higher value means more potential throughput but more
+                memory usage. The backend picks the minimum of the frontend
+                and its default backend value.
index cbfdf5486639a144c414cc46334144fccee8a1e5..fe397f90a34f50153f5936cfa13635ed7bc85b7b 100644 (file)
@@ -84,7 +84,7 @@ X!Iinclude/linux/kobject.h
 
      <sect1><title>Kernel utility functions</title>
 !Iinclude/linux/kernel.h
-!Ekernel/printk.c
+!Ekernel/printk/printk.c
 !Ekernel/panic.c
 !Ekernel/sys.c
 !Ekernel/rcupdate.c
index 6a8b7158697f9ae58b33e82d2f7becd772a6c4aa..9c92bb879b6dc7b1468e247ae0dbb026ad519f2f 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
-       "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+       "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
 <!ENTITY % media-entities SYSTEM "./media-entities.tmpl"> %media-entities;
 <!ENTITY media-indices SYSTEM "./media-indices.tmpl">
 
index c3365f26b2d9f9da85d0ff5245bd6f89555f5256..32b6c3189d9826a53875ae6dc51ce62e9b86778b 100644 (file)
@@ -46,29 +46,33 @@ you format your backing devices and cache device at the same time, you won't
 have to manually attach:
   make-bcache -B /dev/sda /dev/sdb -C /dev/sdc
 
-To make bcache devices known to the kernel, echo them to /sys/fs/bcache/register:
+bcache-tools now ships udev rules, and bcache devices are known to the kernel
+immediately.  Without udev, you can manually register devices like this:
 
   echo /dev/sdb > /sys/fs/bcache/register
   echo /dev/sdc > /sys/fs/bcache/register
 
-To register your bcache devices automatically, you could add something like
-this to an init script:
+Registering the backing device makes the bcache device show up in /dev; you can
+now format it and use it as normal. But the first time using a new bcache
+device, it'll be running in passthrough mode until you attach it to a cache.
+See the section on attaching.
 
-  echo /dev/sd* > /sys/fs/bcache/register_quiet
+The devices show up as:
 
-It'll look for bcache superblocks and ignore everything that doesn't have one.
+  /dev/bcache<N>
 
-Registering the backing device makes the bcache show up in /dev; you can now
-format it and use it as normal. But the first time using a new bcache device,
-it'll be running in passthrough mode until you attach it to a cache. See the
-section on attaching.
+As well as (with udev):
 
-The devices show up at /dev/bcacheN, and can be controlled via sysfs from
-/sys/block/bcacheN/bcache:
+  /dev/bcache/by-uuid/<uuid>
+  /dev/bcache/by-label/<label>
+
+To get started:
 
   mkfs.ext4 /dev/bcache0
   mount /dev/bcache0 /mnt
 
+You can control bcache devices through sysfs at /sys/block/bcache<N>/bcache .
+
 Cache devices are managed as sets; multiple caches per set isn't supported yet
 but will allow for mirroring of metadata and dirty data in the future. Your new
 cache set shows up as /sys/fs/bcache/<UUID>
@@ -80,11 +84,11 @@ must be attached to your cache set to enable caching. Attaching a backing
 device to a cache set is done thusly, with the UUID of the cache set in
 /sys/fs/bcache:
 
-  echo <UUID> > /sys/block/bcache0/bcache/attach
+  echo <CSET-UUID> > /sys/block/bcache0/bcache/attach
 
 This only has to be done once. The next time you reboot, just reregister all
 your bcache devices. If a backing device has data in a cache somewhere, the
-/dev/bcache# device won't be created until the cache shows up - particularly
+/dev/bcache<N> device won't be created until the cache shows up - particularly
 important if you have writeback caching turned on.
 
 If you're booting up and your cache device is gone and never coming back, you
@@ -191,6 +195,9 @@ want for getting the best possible numbers when benchmarking.
 
 SYSFS - BACKING DEVICE:
 
+Available at /sys/block/<bdev>/bcache, /sys/block/bcache*/bcache and
+(if attached) /sys/fs/bcache/<cset-uuid>/bdev*
+
 attach
   Echo the UUID of a cache set to this file to enable caching.
 
@@ -300,6 +307,8 @@ cache_readaheads
 
 SYSFS - CACHE SET:
 
+Available at /sys/fs/bcache/<cset-uuid>
+
 average_key_size
   Average data per key in the btree.
 
@@ -390,6 +399,8 @@ trigger_gc
 
 SYSFS - CACHE DEVICE:
 
+Available at /sys/block/<cdev>/bcache
+
 block_size
   Minimum granularity of writes - should match hardware sector size.
 
index edd4b4df393202ac99b27269966b0ab15c44fff0..786dc82f98ce4833c0ec8b1ecbcf8ad2a8f29ddf 100644 (file)
@@ -267,8 +267,8 @@ Q: If i have some kernel code that needs to be aware of CPU arrival and
 A: This is what you would need in your kernel code to receive notifications.
 
        #include <linux/cpu.h>
-       static int __cpuinit foobar_cpu_callback(struct notifier_block *nfb,
-                                           unsigned long action, void *hcpu)
+       static int foobar_cpu_callback(struct notifier_block *nfb,
+                                      unsigned long action, void *hcpu)
        {
                unsigned int cpu = (unsigned long)hcpu;
 
@@ -285,7 +285,7 @@ A: This is what you would need in your kernel code to receive notifications.
                return NOTIFY_OK;
        }
 
-       static struct notifier_block __cpuinitdata foobar_cpu_notifer =
+       static struct notifier_block foobar_cpu_notifer =
        {
           .notifier_call = foobar_cpu_callback,
        };
index ab1a56e9de9dc5eea34126c907054c4c775c1885..7a2070393732aa84fc40d7a41220b4531a325248 100644 (file)
@@ -98,6 +98,7 @@ clocks and IDs.
        fpm                  83
        mpll_osc_sel         84
        mpll_sel             85
+       spll_gate            86
 
 Examples:
 
index a1ee681942ccc01aedbd335cc3e2aaa69b036489..6113f9275f42074d044199145b37d20feddf279e 100644 (file)
@@ -4,7 +4,7 @@
 Required properties :
 
  - reg             : Offset and length of the register set for the device
- - compatible      : Should be "marvell,mv64xxx-i2c"
+ - compatible      : Should be "marvell,mv64xxx-i2c" or "allwinner,sun4i-i2c"
  - interrupts      : The interrupt number
 
 Optional properties :
diff --git a/Documentation/devicetree/bindings/net/micrel-ksz9021.txt b/Documentation/devicetree/bindings/net/micrel-ksz9021.txt
new file mode 100644 (file)
index 0000000..997a63f
--- /dev/null
@@ -0,0 +1,49 @@
+Micrel KSZ9021 Gigabit Ethernet PHY
+
+Some boards require special tuning values, particularly when it comes to
+clock delays.  You can specify clock delay values by adding
+micrel-specific properties to an Ethernet OF device node.
+
+All skew control options are specified in picoseconds.  The minimum
+value is 0, and the maximum value is 3000.
+
+Optional properties:
+ - rxc-skew-ps : Skew control of RXC pad
+ - rxdv-skew-ps : Skew control of RX CTL pad
+ - txc-skew-ps : Skew control of TXC pad
+ - txen-skew-ps : Skew control of TX_CTL pad
+ - rxd0-skew-ps : Skew control of RX data 0 pad
+ - rxd1-skew-ps : Skew control of RX data 1 pad
+ - rxd2-skew-ps : Skew control of RX data 2 pad
+ - rxd3-skew-ps : Skew control of RX data 3 pad
+ - txd0-skew-ps : Skew control of TX data 0 pad
+ - txd1-skew-ps : Skew control of TX data 1 pad
+ - txd2-skew-ps : Skew control of TX data 2 pad
+ - txd3-skew-ps : Skew control of TX data 3 pad
+
+Examples:
+
+       /* Attach to an Ethernet device with autodetected PHY */
+       &enet {
+               rxc-skew-ps = <3000>;
+               rxdv-skew-ps = <0>;
+               txc-skew-ps = <3000>;
+               txen-skew-ps = <0>;
+               status = "okay";
+       };
+
+       /* Attach to an explicitly-specified PHY */
+       mdio {
+               phy0: ethernet-phy@0 {
+                       rxc-skew-ps = <3000>;
+                       rxdv-skew-ps = <0>;
+                       txc-skew-ps = <3000>;
+                       txen-skew-ps = <0>;
+                       reg = <0>;
+               };
+       };
+       ethernet@70000 {
+               status = "okay";
+               phy = <&phy0>;
+               phy-mode = "rgmii-id";
+       };
diff --git a/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt b/Documentation/devicetree/bindings/net/moxa,moxart-mac.txt
new file mode 100644 (file)
index 0000000..583418b
--- /dev/null
@@ -0,0 +1,21 @@
+MOXA ART Ethernet Controller
+
+Required properties:
+
+- compatible : Must be "moxa,moxart-mac"
+- reg : Should contain register location and length
+- interrupts : Should contain the mac interrupt number
+
+Example:
+
+       mac0: mac@90900000 {
+               compatible = "moxa,moxart-mac";
+               reg =   <0x90900000 0x100>;
+               interrupts = <25 0>;
+       };
+
+       mac1: mac@92000000 {
+               compatible = "moxa,moxart-mac";
+               reg =   <0x92000000 0x100>;
+               interrupts = <27 0>;
+       };
index d5a308629c5765093cf4111d8e42186cbe6b06d3..30b0581bb1ce63cbea673888e9fec22a5df72aa5 100644 (file)
@@ -31,9 +31,8 @@ Optional nodes:
               Optional sub-node properties:
               ti,warm-reset - maintain voltage during warm reset(boolean)
               ti,roof-floor - control voltage selection by pin(boolean)
-              ti,sleep-mode - mode to adopt in pmic sleep 0 - off, 1 - auto,
+              ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto,
               2 - eco, 3 - forced pwm
-              ti,tstep - slope control 0 - Jump, 1 10mV/us, 2 5mV/us, 3 2.5mV/us
               ti,smps-range - OTP has the wrong range set for the hardware so override
               0 - low range, 1 - high range.
 
@@ -59,7 +58,6 @@ pmic {
                        ti,warm-reset;
                        ti,roof-floor;
                        ti,mode-sleep = <0>;
-                       ti,tstep = <0>;
                        ti,smps-range = <1>;
                };
 
index d5a79caec147d36f993c769ddab2a6c15fb0686a..366ce9b872407e1dfb1964079da4fe95d6094df4 100644 (file)
@@ -26,6 +26,7 @@ est   ESTeem Wireless Modems
 fsl    Freescale Semiconductor
 GEFanuc        GE Fanuc Intelligent Platforms Embedded Systems, Inc.
 gef    GE Fanuc Intelligent Platforms Embedded Systems, Inc.
+hisilicon      Hisilicon Limited.
 hp     Hewlett Packard
 ibm    International Business Machines (IBM)
 idt    Integrated Device Technologies, Inc.
@@ -43,6 +44,7 @@ nxp   NXP Semiconductors
 onnn   ON Semiconductor Corp.
 picochip       Picochip Ltd
 powervr        PowerVR (deprecated, use img)
+qca    Qualcomm Atheros, Inc.
 qcom   Qualcomm, Inc.
 ralink Mediatek/Ralink Technology Corp.
 ramtron        Ramtron International
index 050d37fe6d40a566f684891a626e17d519144472..8148a47fc70e17cbf76be1c6d88ad09f16c983b9 100644 (file)
@@ -11,14 +11,14 @@ for non English (read: Japanese) speakers and is not intended as a
 fork. So if you have any comments or updates for this file, please try
 to update the original English file first.
 
-Last Updated: 2011/03/31
+Last Updated: 2013/07/19
 ==================================
 これは、
-linux-2.6.38/Documentation/HOWTO
+linux-3.10/Documentation/HOWTO
 の和訳です。
 
-翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
-翻訳日: 2011/3/28
+翻訳団体: JF プロジェクト < http://linuxjf.sourceforge.jp/ >
+翻訳日: 2013/7/19
 翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com>
 校正者: 松倉さん <nbh--mats at nifty dot com>
          小林 雅典さん (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp>
@@ -245,7 +245,7 @@ Linux カーネルソースツリーの中に含まれる、きれいにし、
 自己参照方式で、索引がついた web 形式で、ソースコードを参照することが
 できます。この最新の素晴しいカーネルコードのリポジトリは以下で見つかり
 ます-
-       http://sosdg.org/~qiyong/lxr/
+       http://lxr.linux.no/+trees
 
 開発プロセス
 -----------------------
@@ -253,24 +253,24 @@ Linux カーネルソースツリーの中に含まれる、きれいにし、
 Linux カーネルの開発プロセスは現在幾つかの異なるメインカーネル「ブラン
 チ」と多数のサブシステム毎のカーネルブランチから構成されます。
 これらのブランチとは-
-  - メインの 2.6.x カーネルツリー
-  - 2.6.x.y -stable カーネルツリー
-  - 2.6.x -git カーネルパッチ
+  - メインの 3.x カーネルツリー
+  - 3.x.y -stable カーネルツリー
+  - 3.x -git カーネルパッチ
   - サブシステム毎のカーネルツリーとパッチ
-  - 統合テストのための 2.6.x -next カーネルツリー
+  - 統合テストのための 3.x -next カーネルツリー
 
-2.6.x カーネルツリー
+3.x カーネルツリー
 -----------------
 
-2.6.x カーネルは Linus Torvalds によってメンテナンスされ、kernel.org
-の pub/linux/kernel/v2.6/ ディレクトリに存在します。この開発プロセスは
+3.x カーネルは Linus Torvalds によってメンテナンスされ、kernel.org
+の pub/linux/kernel/v3.x/ ディレクトリに存在します。この開発プロセスは
 以下のとおり-
 
   - 新しいカーネルがリリースされた直後に、2週間の特別期間が設けられ、
     この期間中に、メンテナ達は Linus に大きな差分を送ることができます。
     このような差分は通常 -next カーネルに数週間含まれてきたパッチです。
     大きな変更は git(カーネルのソース管理ツール、詳細は
-    http://git-scm.com/  参照) を使って送るのが好ましいやり方ですが、パッ
+    http://git-scm.com/ 参照) を使って送るのが好ましいやり方ですが、パッ
     チファイルの形式のまま送るのでも十分です。
 
   - 2週間後、-rc1 カーネルがリリースされ、この後にはカーネル全体の安定
@@ -302,20 +302,20 @@ Andrew Morton が Linux-kernel メーリングリストにカーネルリリー
   実に認識されたバグの状況によりリリースされるのであり、前もって決めら
   れた計画によってリリースされるものではないからです。」
 
-2.6.x.y -stable カーネルツリー
+3.x.y -stable カーネルツリー
 ---------------------------
 
-バージョン番号が4つの数字に分かれているカーネルは -stable カーネルです。
-これには、2.6.x カーネルで見つかったセキュリティ問題や重大な後戻りに対
+バージョン番号が3つの数字に分かれているカーネルは -stable カーネルです。
+これには、3.x カーネルで見つかったセキュリティ問題や重大な後戻りに対
 する比較的小さい重要な修正が含まれます。
 
 これは、開発/実験的バージョンのテストに協力することに興味が無く、
 最新の安定したカーネルを使いたいユーザに推奨するブランチです。
 
-もし、2.6.x.y カーネルが存在しない場合には、番号が一番大きい 2.6.x が
+もし、3.x.y カーネルが存在しない場合には、番号が一番大きい 3.x が
 最新の安定版カーネルです。
 
-2.6.x.y は "stable" チーム <stable@kernel.org> でメンテされており、必
+3.x.y は "stable" チーム <stable@kernel.org> でメンテされており、必
 要に応じてリリースされます。通常のリリース期間は 2週間毎ですが、差し迫っ
 た問題がなければもう少し長くなることもあります。セキュリティ関連の問題
 の場合はこれに対してだいたいの場合、すぐにリリースがされます。
@@ -324,7 +324,7 @@ Andrew Morton が Linux-kernel メーリングリストにカーネルリリー
 イルにはどのような種類の変更が -stable ツリーに受け入れ可能か、またリ
 リースプロセスがどう動くかが記述されています。
 
-2.6.x -git パッチ
+3.x -git パッチ
 ------------------
 
 git リポジトリで管理されているLinus のカーネルツリーの毎日のスナップ
@@ -358,14 +358,14 @@ quilt シリーズとして公開されているパッチキューも使われ
 をつけることができます。大部分のこれらの patchwork のサイトは
 http://patchwork.kernel.org/ でリストされています。
 
-統合テストのための 2.6.x -next カーネルツリー
+統合テストのための 3.x -next カーネルツリー
 ---------------------------------------------
 
-サブシステムツリーの更新内容がメインラインの 2.6.x ツリーにマージされ
+サブシステムツリーの更新内容がメインラインの 3.x ツリーにマージされ
 る前に、それらは統合テストされる必要があります。この目的のため、実質的
 に全サブシステムツリーからほぼ毎日プルされてできる特別なテスト用のリ
 ポジトリが存在します-
-       http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git
+       http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
        http://linux.f-seidel.de/linux-next/pmwiki/
 
 このやり方によって、-next カーネルは次のマージ機会でどんなものがメイン
index 15356aca938cd9a7bb2cdef09d8e7a19da36db90..7f9d4f53882c457ab8aa7f3e48c5fbbae7e903c2 100644 (file)
@@ -2953,7 +2953,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        improve throughput, but will also increase the
                        amount of memory reserved for use by the client.
 
-       swapaccount[=0|1]
+       swapaccount=[0|1]
                        [KNL] Enable accounting of swap in memory resource
                        controller if no parameter or 1 is given or disable
                        it if 0 is given (See Documentation/cgroups/memory.txt)
index 32dfbd924121f13747f220d692b0ad61a3a507d2..18b64b2b8a682552b4c3fd08f607a817218615c5 100644 (file)
@@ -124,6 +124,8 @@ multiqueue.txt
        - HOWTO for multiqueue network device support.
 netconsole.txt
        - The network console module netconsole.ko: configuration and notes.
+netdev-FAQ.txt
+       - FAQ describing how to submit net changes to netdev mailing list.
 netdev-features.txt
        - Network interface features API description.
 netdevices.txt
index fcb6c71cdb69e7c0e643abb8124309adf4061b24..13a32124bca074b9722818809969899ff602c407 100644 (file)
@@ -1,7 +1,7 @@
 Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
 ==============================================================
 
-November 15, 2005
+March 15, 2011
 
 Contents
 ========
@@ -122,7 +122,7 @@ Additional Configurations
   NOTE: This setting is not saved across reboots.
 
 
-  Ethtool
+  ethtool
   -------
 
   The driver utilizes the ethtool interface for driver configuration and
index 71ca9585567144a75e4209f385500080561cd42c..437b2099cced6e2c4b1285eefaf7f9adf7228c85 100644 (file)
@@ -1,8 +1,8 @@
-Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters
-===============================================================
+Linux* Base Driver for Intel(R) Ethernet Network Connection
+===========================================================
 
 Intel Gigabit Linux driver.
-Copyright(c) 1999 - 2010 Intel Corporation.
+Copyright(c) 1999 - 2013 Intel Corporation.
 
 Contents
 ========
@@ -420,15 +420,15 @@ Additional Configurations
   - The maximum MTU setting for Jumbo Frames is 16110.  This value coincides
     with the maximum Jumbo Frames size of 16128.
 
-  - Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or
-    loss of link.
+  - Using Jumbo frames at 10 or 100 Mbps is not supported and may result in
+    poor performance or loss of link.
 
   - Adapters based on the Intel(R) 82542 and 82573V/E controller do not
     support Jumbo Frames. These correspond to the following product names:
      Intel(R) PRO/1000 Gigabit Server Adapter
      Intel(R) PRO/1000 PM Network Connection
 
-  Ethtool
+  ethtool
   -------
   The driver utilizes the ethtool interface for driver configuration and
   diagnostics, as well as displaying statistical information.  The ethtool
index 97b5ba942ebf847781fbd2e0f2526d7b92646135..ad2d9f38ce1400ad0b02771010a249234837ee3b 100644 (file)
@@ -1,8 +1,8 @@
-Linux* Driver for Intel(R) Network Connection
-=============================================
+Linux* Driver for Intel(R) Ethernet Network Connection
+======================================================
 
 Intel Gigabit Linux driver.
-Copyright(c) 1999 - 2010 Intel Corporation.
+Copyright(c) 1999 - 2013 Intel Corporation.
 
 Contents
 ========
@@ -259,13 +259,16 @@ Additional Configurations
   - The maximum MTU setting for Jumbo Frames is 9216.  This value coincides
     with the maximum Jumbo Frames size of 9234 bytes.
 
-  - Using Jumbo Frames at 10 or 100 Mbps is not supported and may result in
+  - Using Jumbo frames at 10 or 100 Mbps is not supported and may result in
     poor performance or loss of link.
 
   - Some adapters limit Jumbo Frames sized packets to a maximum of
     4096 bytes and some adapters do not support Jumbo Frames.
 
-  Ethtool
+  - Jumbo Frames cannot be configured on an 82579-based Network device, if
+    MACSec is enabled on the system.
+
+  ethtool
   -------
   The driver utilizes the ethtool interface for driver configuration and
   diagnostics, as well as displaying statistical information.  We
@@ -273,6 +276,9 @@ Additional Configurations
 
   http://ftp.kernel.org/pub/software/network/ethtool/
 
+  NOTE: When validating enable/disable tests on some parts (82578, for example)
+  you need to add a few seconds between tests when working with ethtool.
+
   Speed and Duplex
   ----------------
   Speed and Duplex are configured through the ethtool* utility. For
index 9a2a037194a5679355918355f356bf0ab5e5aa95..4ebbd659256fbfe3cdf450bfed814066ae2df575 100644 (file)
@@ -1,8 +1,8 @@
-Linux* Base Driver for Intel(R) Network Connection
-==================================================
+Linux* Base Driver for Intel(R) Ethernet Network Connection
+===========================================================
 
 Intel Gigabit Linux driver.
-Copyright(c) 1999 - 2010 Intel Corporation.
+Copyright(c) 1999 - 2013 Intel Corporation.
 
 Contents
 ========
@@ -36,6 +36,53 @@ Default Value: 0
 This parameter adds support for SR-IOV.  It causes the driver to spawn up to
 max_vfs worth of virtual function.
 
+QueuePairs
+----------
+Valid Range:  0-1
+Default Value:  1 (TX and RX will be paired onto one interrupt vector)
+
+If set to 0, when MSI-X is enabled, the TX and RX will attempt to occupy
+separate vectors.
+
+This option can be overridden to 1 if there are not sufficient interrupts
+available.  This can occur if any combination of RSS, VMDQ, and max_vfs
+results in more than 4 queues being used.
+
+Node
+----
+Valid Range:   0-n
+Default Value: -1 (off)
+
+  0 - n: where n is the number of the NUMA node that should be used to
+         allocate memory for this adapter port.
+  -1: uses the driver default of allocating memory on whichever processor is
+      running insmod/modprobe.
+
+  The Node parameter will allow you to pick which NUMA node you want to have
+  the adapter allocate memory from.  All driver structures, in-memory queues,
+  and receive buffers will be allocated on the node specified.  This parameter
+  is only useful when interrupt affinity is specified, otherwise some portion
+  of the time the interrupt could run on a different core than the memory is
+  allocated on, causing slower memory access and impacting throughput, CPU, or
+  both.
+
+EEE
+---
+Valid Range:  0-1
+Default Value: 1 (enabled)
+
+  A link between two EEE-compliant devices will result in periodic bursts of
+  data followed by long periods where in the link is in an idle state. This Low
+  Power Idle (LPI) state is supported in both 1Gbps and 100Mbps link speeds.
+  NOTE: EEE support requires autonegotiation.
+
+DMAC
+----
+Valid Range: 0-1
+Default Value: 1 (enabled)
+  Enables or disables DMA Coalescing feature.
+
+
 
 Additional Configurations
 =========================
@@ -55,10 +102,10 @@ Additional Configurations
   - The maximum MTU setting for Jumbo Frames is 9216.  This value coincides
     with the maximum Jumbo Frames size of 9234 bytes.
 
-  - Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or
-    loss of link.
+  - Using Jumbo frames at 10 or 100 Mbps is not supported and may result in
+    poor performance or loss of link.
 
-  Ethtool
+  ethtool
   -------
   The driver utilizes the ethtool interface for driver configuration and
   diagnostics, as well as displaying statistical information. The latest
@@ -106,6 +153,14 @@ Additional Configurations
 
   Where n=the VF that attempted to do the spoofing.
 
+  Setting MAC Address, VLAN and Rate Limit Using IProute2 Tool
+  ------------------------------------------------------------
+  You can set a MAC address of a Virtual Function (VF), a default VLAN and the
+  rate limit using the IProute2 tool. Download the latest version of the
+  iproute2 tool from Sourceforge if your version does not have all the
+  features you require.
+
+
 Support
 =======
 
index cbfe4ee655335def89bdb41b5222e12d5431f094..40db17a6665b19ea6b9202ca19b2c62c68c4deb0 100644 (file)
@@ -1,8 +1,8 @@
-Linux* Base Driver for Intel(R) Network Connection
-==================================================
+Linux* Base Driver for Intel(R) Ethernet Network Connection
+===========================================================
 
 Intel Gigabit Linux driver.
-Copyright(c) 1999 - 2010 Intel Corporation.
+Copyright(c) 1999 - 2013 Intel Corporation.
 
 Contents
 ========
@@ -55,7 +55,7 @@ networking link on the left to search for your adapter:
 Additional Configurations
 =========================
 
-  Ethtool
+  ethtool
   -------
   The driver utilizes the ethtool interface for driver configuration and
   diagnostics, as well as displaying statistical information.  The ethtool
index 10742902146fc1da3ae1c84a94929b42a79e29d0..debfe857d8f9c8694f2483c9e41826973d24dac0 100644 (file)
@@ -440,6 +440,10 @@ tcp_syncookies - BOOLEAN
        SYN flood warnings in logs not being really flooded, your server
        is seriously misconfigured.
 
+       If you want to test which effects syncookies have to your
+       network connections you can set this knob to 2 to enable
+       unconditionally generation of syncookies.
+
 tcp_fastopen - INTEGER
        Enable TCP Fast Open feature (draft-ietf-tcpm-fastopen) to send data
        in the opening SYN packet. To use this feature, the client application
@@ -516,6 +520,19 @@ tcp_wmem - vector of 3 INTEGERs: min, default, max
        this value is ignored.
        Default: between 64K and 4MB, depending on RAM size.
 
+tcp_notsent_lowat - UNSIGNED INTEGER
+       A TCP socket can control the amount of unsent bytes in its write queue,
+       thanks to TCP_NOTSENT_LOWAT socket option. poll()/select()/epoll()
+       reports POLLOUT events if the amount of unsent bytes is below a per
+       socket value, and if the write queue is not full. sendmsg() will
+       also not add new buffers if the limit is hit.
+
+       This global variable controls the amount of unsent data for
+       sockets not using TCP_NOTSENT_LOWAT. For these sockets, a change
+       to the global variable has immediate effect.
+
+       Default: UINT_MAX (0xFFFFFFFF)
+
 tcp_workaround_signed_windows - BOOLEAN
        If set, assume no receipt of a window scaling option means the
        remote TCP is broken and treats the window as a signed quantity.
@@ -1022,7 +1039,15 @@ disable_policy - BOOLEAN
 disable_xfrm - BOOLEAN
        Disable IPSEC encryption on this interface, whatever the policy
 
+igmpv2_unsolicited_report_interval - INTEGER
+       The interval in milliseconds in which the next unsolicited
+       IGMPv1 or IGMPv2 report retransmit will take place.
+       Default: 10000 (10 seconds)
 
+igmpv3_unsolicited_report_interval - INTEGER
+       The interval in milliseconds in which the next unsolicited
+       IGMPv3 report retransmit will take place.
+       Default: 1000 (1 seconds)
 
 tag - INTEGER
        Allows you to write a number, which can be used as required.
@@ -1314,6 +1339,16 @@ ndisc_notify - BOOLEAN
        1 - Generate unsolicited neighbour advertisements when device is brought
            up or hardware address changes.
 
+mldv1_unsolicited_report_interval - INTEGER
+       The interval in milliseconds in which the next unsolicited
+       MLDv1 report retransmit will take place.
+       Default: 10000 (10 seconds)
+
+mldv2_unsolicited_report_interval - INTEGER
+       The interval in milliseconds in which the next unsolicited
+       MLDv2 report retransmit will take place.
+       Default: 1000 (1 second)
+
 icmp/*:
 ratelimit - INTEGER
        Limit the maximal rates for sending ICMPv6 packets.
index d75a1f9565bbfe5b8069ba05e36adf2619466171..1e0c045e89f7dc12f5c2ccf016020e6e2fdb2857 100644 (file)
@@ -1,7 +1,7 @@
-Linux Base Driver for 10 Gigabit Intel(R) Network Connection
-=============================================================
+Linux Base Driver for 10 Gigabit Intel(R) Ethernet Network Connection
+=====================================================================
 
-October 9, 2007
+March 14, 2011
 
 
 Contents
@@ -274,9 +274,9 @@ Additional Configurations
   -------------------------------------------------
   Configuring a network driver to load properly when the system is started is
   distribution dependent. Typically, the configuration process involves adding
-  an alias line to files in /etc/modprobe.d/ as well as editing other system
-  startup scripts and/or configuration files.  Many popular Linux distributions
-  ship with tools to make these changes for you.  To learn the proper way to
+  an alias line to /etc/modprobe.conf as well as editing other system startup
+  scripts and/or configuration files.  Many popular Linux distributions ship
+  with tools to make these changes for you.  To learn the proper way to
   configure a network device for your system, refer to your distribution
   documentation.  If during this process you are asked for the driver or module
   name, the name for the Linux Base Driver for the Intel 10GbE Family of
@@ -306,7 +306,7 @@ Additional Configurations
   with the maximum Jumbo Frames size of 16128.
 
 
-  Ethtool
+  ethtool
   -------
   The driver utilizes the ethtool interface for driver configuration and
   diagnostics, as well as displaying statistical information.  The ethtool
index af77ed3c4172088bf57b11d57183f003031b7cab..96cccebb839b3f52fcfd318f37731489e2be45f0 100644 (file)
@@ -1,8 +1,9 @@
-Linux Base Driver for 10 Gigabit PCI Express Intel(R) Network Connection
-========================================================================
+Linux* Base Driver for the Intel(R) Ethernet 10 Gigabit PCI Express Family of
+Adapters
+=============================================================================
 
-Intel Gigabit Linux driver.
-Copyright(c) 1999 - 2010 Intel Corporation.
+Intel 10 Gigabit Linux driver.
+Copyright(c) 1999 - 2013 Intel Corporation.
 
 Contents
 ========
@@ -16,8 +17,8 @@ Contents
 Identifying Your Adapter
 ========================
 
-The driver in this release is compatible with 82598 and 82599-based Intel
-Network Connections.
+The driver in this release is compatible with 82598, 82599 and X540-based
+Intel Network Connections.
 
 For more information on how to identify your adapter, go to the Adapter &
 Driver ID Guide at:
@@ -72,7 +73,7 @@ cables that comply with SFF-8431 v4.1 and SFF-8472 v10.4 specifications.
 Laser turns off for SFP+ when ifconfig down
 -------------------------------------------
 "ifconfig down" turns off the laser for 82599-based SFP+ fiber adapters.
-"ifconfig up" turns on the later.
+"ifconfig up" turns on the laser.
 
 
 82598-BASED ADAPTERS
@@ -118,6 +119,93 @@ NOTE: For 82598 backplane cards entering 1 gig mode, flow control default
 behavior is changed to off.  Flow control in 1 gig mode on these devices can
 lead to Tx hangs.
 
+Intel(R) Ethernet Flow Director
+-------------------------------
+Supports advanced filters that direct receive packets by their flows to
+different queues. Enables tight control on routing a flow in the platform.
+Matches flows and CPU cores for flow affinity. Supports multiple parameters
+for flexible flow classification and load balancing.
+
+Flow director is enabled only if the kernel is multiple TX queue capable.
+
+An included script (set_irq_affinity.sh) automates setting the IRQ to CPU
+affinity.
+
+You can verify that the driver is using Flow Director by looking at the counter
+in ethtool: fdir_miss and fdir_match.
+
+Other ethtool Commands:
+To enable Flow Director
+       ethtool -K ethX ntuple on
+To add a filter
+       Use -U switch. e.g., ethtool -U ethX flow-type tcp4 src-ip 0x178000a
+        action 1
+To see the list of filters currently present:
+       ethtool -u ethX
+
+Perfect Filter: Perfect filter is an interface to load the filter table that
+funnels all flow into queue_0 unless an alternative queue is specified using
+"action". In that case, any flow that matches the filter criteria will be
+directed to the appropriate queue.
+
+If the queue is defined as -1, filter will drop matching packets.
+
+To account for filter matches and misses, there are two stats in ethtool:
+fdir_match and fdir_miss. In addition, rx_queue_N_packets shows the number of
+packets processed by the Nth queue.
+
+NOTE: Receive Packet Steering (RPS) and Receive Flow Steering (RFS) are not
+compatible with Flow Director. IF Flow Director is enabled, these will be
+disabled.
+
+The following three parameters impact Flow Director.
+
+FdirMode
+--------
+Valid Range: 0-2 (0=off, 1=ATR, 2=Perfect filter mode)
+Default Value: 1
+
+  Flow Director filtering modes.
+
+FdirPballoc
+-----------
+Valid Range: 0-2 (0=64k, 1=128k, 2=256k)
+Default Value: 0
+
+  Flow Director allocated packet buffer size.
+
+AtrSampleRate
+--------------
+Valid Range: 1-100
+Default Value: 20
+
+  Software ATR Tx packet sample rate. For example, when set to 20, every 20th
+  packet, looks to see if the packet will create a new flow.
+
+Node
+----
+Valid Range:   0-n
+Default Value: 1 (off)
+
+  0 - n: where n is the number of NUMA nodes (i.e. 0 - 3) currently online in
+  your system
+  1: turns this option off
+
+  The Node parameter will allow you to pick which NUMA node you want to have
+  the adapter allocate memory on.
+
+max_vfs
+-------
+Valid Range:   1-63
+Default Value: 0
+
+  If the value is greater than 0 it will also force the VMDq parameter to be 1
+  or more.
+
+  This parameter adds support for SR-IOV.  It causes the driver to spawn up to
+  max_vfs worth of virtual function.
+
+
 Additional Configurations
 =========================
 
@@ -221,9 +309,10 @@ http://www.redhat.com/promo/summit/2008/downloads/pdf/Thursday/Mark_Wagner.pdf
 Known Issues
 ============
 
-  Enabling SR-IOV in a 32-bit Microsoft* Windows* Server 2008 Guest OS using
-  Intel (R) 82576-based GbE or Intel (R) 82599-based 10GbE controller under KVM
-  -----------------------------------------------------------------------------
+  Enabling SR-IOV in a 32-bit or 64-bit Microsoft* Windows* Server 2008/R2
+  Guest OS using Intel (R) 82576-based GbE or Intel (R) 82599-based 10GbE
+  controller under KVM
+  ------------------------------------------------------------------------
   KVM Hypervisor/VMM supports direct assignment of a PCIe device to a VM.  This
   includes traditional PCIe devices, as well as SR-IOV-capable devices using
   Intel 82576-based and 82599-based controllers.
index 5a91a41fa94619470c1d55c5b7d4525e553cd5be..53d8d2a5a6a31aa9936d04ed8d438b9957d3419f 100644 (file)
@@ -1,8 +1,8 @@
-Linux* Base Driver for Intel(R) Network Connection
-==================================================
+Linux* Base Driver for Intel(R) Ethernet Network Connection
+===========================================================
 
 Intel Gigabit Linux driver.
-Copyright(c) 1999 - 2010 Intel Corporation.
+Copyright(c) 1999 - 2013 Intel Corporation.
 
 Contents
 ========
diff --git a/Documentation/networking/netdev-FAQ.txt b/Documentation/networking/netdev-FAQ.txt
new file mode 100644 (file)
index 0000000..d9112f0
--- /dev/null
@@ -0,0 +1,224 @@
+
+Information you need to know about netdev
+-----------------------------------------
+
+Q: What is netdev?
+
+A: It is a mailing list for all network related linux stuff.  This includes
+   anything found under net/  (i.e. core code like IPv6) and drivers/net
+   (i.e. hardware specific drivers) in the linux source tree.
+
+   Note that some subsystems (e.g. wireless drivers) which have a high volume
+   of traffic have their own specific mailing lists.
+
+   The netdev list is managed (like many other linux mailing lists) through
+   VGER ( http://vger.kernel.org/ ) and archives can be found below:
+
+       http://marc.info/?l=linux-netdev
+       http://www.spinics.net/lists/netdev/
+
+   Aside from subsystems like that mentioned above, all network related linux
+   development (i.e. RFC, review, comments, etc) takes place on netdev.
+
+Q: How do the changes posted to netdev make their way into linux?
+
+A: There are always two trees (git repositories) in play.  Both are driven
+   by David Miller, the main network maintainer.  There is the "net" tree,
+   and the "net-next" tree.  As you can probably guess from the names, the
+   net tree is for fixes to existing code already in the mainline tree from
+   Linus, and net-next is where the new code goes for the future release.
+   You can find the trees here:
+
+       http://git.kernel.org/?p=linux/kernel/git/davem/net.git
+       http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git
+
+Q: How often do changes from these trees make it to the mainline Linus tree?
+
+A: To understand this, you need to know a bit of background information
+   on the cadence of linux development.  Each new release starts off with
+   a two week "merge window" where the main maintainers feed their new
+   stuff to Linus for merging into the mainline tree.  After the two weeks,
+   the merge window is closed, and it is called/tagged "-rc1".  No new
+   features get mainlined after this -- only fixes to the rc1 content
+   are expected.  After roughly a week of collecting fixes to the rc1
+   content, rc2 is released.  This repeats on a roughly weekly basis
+   until rc7 (typically; sometimes rc6 if things are quiet, or rc8 if
+   things are in a state of churn), and a week after the last vX.Y-rcN
+   was done, the official "vX.Y" is released.
+
+   Relating that to netdev:  At the beginning of the 2 week merge window,
+   the net-next tree will be closed - no new changes/features.  The
+   accumulated new content of the past ~10 weeks will be passed onto
+   mainline/Linus via a pull request for vX.Y -- at the same time,
+   the "net" tree will start accumulating fixes for this pulled content
+   relating to vX.Y
+
+   An announcement indicating when net-next has been closed is usually
+   sent to netdev, but knowing the above, you can predict that in advance.
+
+   IMPORTANT:  Do not send new net-next content to netdev during the
+   period during which net-next tree is closed.
+
+   Shortly after the two weeks have passed, (and vX.Y-rc1 is released) the
+   tree for net-next reopens to collect content for the next (vX.Y+1) release.
+
+   If you aren't subscribed to netdev and/or are simply unsure if net-next
+   has re-opened yet, simply check the net-next git repository link above for
+   any new networking related commits.
+
+   The "net" tree continues to collect fixes for the vX.Y content, and
+   is fed back to Linus at regular (~weekly) intervals.  Meaning that the
+   focus for "net" is on stablilization and bugfixes.
+
+   Finally, the vX.Y gets released, and the whole cycle starts over.
+
+Q: So where are we now in this cycle?
+
+A: Load the mainline (Linus) page here:
+
+       http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git
+
+   and note the top of the "tags" section.  If it is rc1, it is early
+   in the dev cycle.  If it was tagged rc7 a week ago, then a release
+   is probably imminent.
+
+Q: How do I indicate which tree (net vs. net-next) my patch should be in?
+
+A: Firstly, think whether you have a bug fix or new "next-like" content.
+   Then once decided, assuming that you use git, use the prefix flag, i.e.
+
+       git format-patch --subject-prefix='PATCH net-next' start..finish
+
+   Use "net" instead of "net-next" (always lower case) in the above for
+   bug-fix net content.  If you don't use git, then note the only magic in
+   the above is just the subject text of the outgoing e-mail, and you can
+   manually change it yourself with whatever MUA you are comfortable with.
+
+Q: I sent a patch and I'm wondering what happened to it.  How can I tell
+   whether it got merged?
+
+A: Start by looking at the main patchworks queue for netdev:
+
+       http://patchwork.ozlabs.org/project/netdev/list/
+
+   The "State" field will tell you exactly where things are at with
+   your patch.
+
+Q: The above only says "Under Review".  How can I find out more?
+
+A: Generally speaking, the patches get triaged quickly (in less than 48h).
+   So be patient.  Asking the maintainer for status updates on your
+   patch is a good way to ensure your patch is ignored or pushed to
+   the bottom of the priority list.
+
+Q: How can I tell what patches are queued up for backporting to the
+   various stable releases?
+
+A: Normally Greg Kroah-Hartman collects stable commits himself, but
+   for networking, Dave collects up patches he deems critical for the
+   networking subsystem, and then hands them off to Greg.
+
+   There is a patchworks queue that you can see here:
+       http://patchwork.ozlabs.org/bundle/davem/stable/?state=*
+
+   It contains the patches which Dave has selected, but not yet handed
+   off to Greg.  If Greg already has the patch, then it will be here:
+       http://git.kernel.org/cgit/linux/kernel/git/stable/stable-queue.git
+
+   A quick way to find whether the patch is in this stable-queue is
+   to simply clone the repo, and then git grep the mainline commit ID, e.g.
+
+       stable-queue$ git grep -l 284041ef21fdf2e
+       releases/3.0.84/ipv6-fix-possible-crashes-in-ip6_cork_release.patch
+       releases/3.4.51/ipv6-fix-possible-crashes-in-ip6_cork_release.patch
+       releases/3.9.8/ipv6-fix-possible-crashes-in-ip6_cork_release.patch
+       stable/stable-queue$
+
+Q: I see a network patch and I think it should be backported to stable.
+   Should I request it via "stable@vger.kernel.org" like the references in
+   the kernel's Documentation/stable_kernel_rules.txt file say?
+
+A: No, not for networking.  Check the stable queues as per above 1st to see
+   if it is already queued.  If not, then send a mail to netdev, listing
+   the upstream commit ID and why you think it should be a stable candidate.
+
+   Before you jump to go do the above, do note that the normal stable rules
+   in Documentation/stable_kernel_rules.txt still apply.  So you need to
+   explicitly indicate why it is a critical fix and exactly what users are
+   impacted.  In addition, you need to convince yourself that you _really_
+   think it has been overlooked, vs. having been considered and rejected.
+
+   Generally speaking, the longer it has had a chance to "soak" in mainline,
+   the better the odds that it is an OK candidate for stable.  So scrambling
+   to request a commit be added the day after it appears should be avoided.
+
+Q: I have created a network patch and I think it should be backported to
+   stable.  Should I add a "Cc: stable@vger.kernel.org" like the references
+   in the kernel's Documentation/ directory say?
+
+A: No.  See above answer.  In short, if you think it really belongs in
+   stable, then ensure you write a decent commit log that describes who
+   gets impacted by the bugfix and how it manifests itself, and when the
+   bug was introduced.  If you do that properly, then the commit will
+   get handled appropriately and most likely get put in the patchworks
+   stable queue if it really warrants it.
+
+   If you think there is some valid information relating to it being in
+   stable that does _not_ belong in the commit log, then use the three
+   dash marker line as described in Documentation/SubmittingPatches to
+   temporarily embed that information into the patch that you send.
+
+Q: Someone said that the comment style and coding convention is different
+   for the networking content.  Is this true?
+
+A: Yes, in a largely trivial way.  Instead of this:
+
+       /*
+        * foobar blah blah blah
+        * another line of text
+        */
+
+   it is requested that you make it look like this:
+
+       /* foobar blah blah blah
+        * another line of text
+        */
+
+Q: I am working in existing code that has the former comment style and not the
+   latter.  Should I submit new code in the former style or the latter?
+
+A: Make it the latter style, so that eventually all code in the domain of
+   netdev is of this format.
+
+Q: I found a bug that might have possible security implications or similar.
+   Should I mail the main netdev maintainer off-list?
+
+A: No. The current netdev maintainer has consistently requested that people
+   use the mailing lists and not reach out directly.  If you aren't OK with
+   that, then perhaps consider mailing "security@kernel.org" or reading about
+   http://oss-security.openwall.org/wiki/mailing-lists/distros
+   as possible alternative mechanisms.
+
+Q: What level of testing is expected before I submit my change?
+
+A: If your changes are against net-next, the expectation is that you
+   have tested by layering your changes on top of net-next.  Ideally you
+   will have done run-time testing specific to your change, but at a
+   minimum, your changes should survive an "allyesconfig" and an
+   "allmodconfig" build without new warnings or failures.
+
+Q: Any other tips to help ensure my net/net-next patch gets OK'd?
+
+A: Attention to detail.  Re-read your own work as if you were the
+   reviewer.  You can start with using checkpatch.pl, perhaps even
+   with the "--strict" flag.  But do not be mindlessly robotic in
+   doing so.  If your change is a bug-fix, make sure your commit log
+   indicates the end-user visible symptom, the underlying reason as
+   to why it happens, and then if necessary, explain why the fix proposed
+   is the best way to get things done.   Don't mangle whitespace, and as
+   is common, don't mis-indent function arguments that span multiple lines.
+   If it is your 1st patch, mail it to yourself so you can test apply
+   it to an unpatched tree to confirm infrastructure didn't mangle it.
+
+   Finally, go back and read Documentation/SubmittingPatches to be
+   sure you are not repeating some common mistake documented there.
index 8fa2dd1e792e3ae3a1555dbb99c2048981452c6f..37c20ee2455e0e54fe749cc4a617ca4463ad553b 100644 (file)
@@ -91,6 +91,46 @@ Often we ellipsize arguments not important to the discussion, e.g.:
     in_port(1), eth(...), eth_type(0x0800), ipv4(...), tcp(...)
 
 
+Wildcarded flow key format
+--------------------------
+
+A wildcarded flow is described with two sequences of Netlink attributes
+passed over the Netlink socket. A flow key, exactly as described above, and an
+optional corresponding flow mask.
+
+A wildcarded flow can represent a group of exact match flows. Each '1' bit
+in the mask specifies a exact match with the corresponding bit in the flow key.
+A '0' bit specifies a don't care bit, which will match either a '1' or '0' bit
+of a incoming packet. Using wildcarded flow can improve the flow set up rate
+by reduce the number of new flows need to be processed by the user space program.
+
+Support for the mask Netlink attribute is optional for both the kernel and user
+space program. The kernel can ignore the mask attribute, installing an exact
+match flow, or reduce the number of don't care bits in the kernel to less than
+what was specified by the user space program. In this case, variations in bits
+that the kernel does not implement will simply result in additional flow setups.
+The kernel module will also work with user space programs that neither support
+nor supply flow mask attributes.
+
+Since the kernel may ignore or modify wildcard bits, it can be difficult for
+the userspace program to know exactly what matches are installed. There are
+two possible approaches: reactively install flows as they miss the kernel
+flow table (and therefore not attempt to determine wildcard changes at all)
+or use the kernel's response messages to determine the installed wildcards.
+
+When interacting with userspace, the kernel should maintain the match portion
+of the key exactly as originally installed. This will provides a handle to
+identify the flow for all future operations. However, when reporting the
+mask of an installed flow, the mask should include any restrictions imposed
+by the kernel.
+
+The behavior when using overlapping wildcarded flows is undefined. It is the
+responsibility of the user space program to ensure that any incoming packet
+can match at most one flow, wildcarded or not. The current implementation
+performs best-effort detection of overlapping wildcarded flows and may reject
+some but not all of them. However, this behavior may change in future versions.
+
+
 Basic rule for evolving flow keys
 ---------------------------------
 
index 0c790a76910ef81052faeff278d57b5b4fe2499b..97b810ca9082dbad569c57b8b9bdd6f0a8dda1c1 100644 (file)
@@ -19,7 +19,6 @@ of SCTP that is RFC 2960 compliant and provides an programming interface
 referred to as the  UDP-style API of the Sockets Extensions for SCTP, as 
 proposed in IETF Internet-Drafts.    
 
-
 Caveats:  
 
 -lksctp can be built as statically or as a module.  However, be aware that 
@@ -33,6 +32,4 @@ For more information, please visit the lksctp project website:
    http://www.sf.net/projects/lksctp
 
 Or contact the lksctp developers through the mailing list:
-   <lksctp-developers@lists.sourceforge.net> 
-
-
+   <linux-sctp@vger.kernel.org>
index 7b5996d9357e017b8f05052522255a7405bf9248..ec11429e1d42a5bbbea2d21354a8b8dff1028fe0 100644 (file)
@@ -2,9 +2,8 @@ Transparent proxy support
 =========================
 
 This feature adds Linux 2.2-like transparent proxy support to current kernels.
-To use it, enable NETFILTER_TPROXY, the socket match and the TPROXY target in
-your kernel config. You will need policy routing too, so be sure to enable that
-as well.
+To use it, enable the socket match and the TPROXY target in your kernel config.
+You will need policy routing too, so be sure to enable that as well.
 
 
 1. Making non-local sockets work
index 1c15043aaee4c89bf2c76aca10633557c1327bd3..d569f2a424d511218f679258bbb246cae2438b25 100644 (file)
@@ -52,7 +52,7 @@ Default: 64
 
 busy_read
 ----------------
-Low latency busy poll timeout for socket reads. (needs CONFIG_NET_LL_RX_POLL)
+Low latency busy poll timeout for socket reads. (needs CONFIG_NET_RX_BUSY_POLL)
 Approximate time in us to busy loop waiting for packets on the device queue.
 This sets the default value of the SO_BUSY_POLL socket option.
 Can be set or overridden per socket by setting socket option SO_BUSY_POLL,
@@ -63,7 +63,7 @@ Default: 0 (off)
 
 busy_poll
 ----------------
-Low latency busy poll timeout for poll and select. (needs CONFIG_NET_LL_RX_POLL)
+Low latency busy poll timeout for poll and select. (needs CONFIG_NET_RX_BUSY_POLL)
 Approximate time in us to busy loop waiting for events.
 Recommended value depends on the number of sockets you poll on.
 For several sockets 50, for several hundreds 100.
index 2116b9a9374a7ff138c9bfbb03ae42bcfe8e35eb..705bb96bc37ebaddfc8e8bcd856695bd85dfee86 100644 (file)
@@ -965,6 +965,12 @@ M: Lennert Buytenhek <kernel@wantstofly.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
 
+ARM/TEXAS INSTRUMENT KEYSTONE ARCHITECTURE
+M:     Santosh Shilimkar <santosh.shilimkar@ti.com>
+L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:     Maintained
+F:     arch/arm/mach-keystone/
+
 ARM/LOGICPD PXA270 MACHINE SUPPORT
 M:     Lennert Buytenhek <kernel@wantstofly.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -1259,7 +1265,6 @@ F:        drivers/rtc/rtc-coh901331.c
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git
 
 ARM/Ux500 ARM ARCHITECTURE
-M:     Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
 M:     Linus Walleij <linus.walleij@linaro.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
@@ -1642,7 +1647,7 @@ S:        Maintained
 F:     drivers/net/hamradio/baycom*
 
 BCACHE (BLOCK LAYER CACHE)
-M:     Kent Overstreet <koverstreet@google.com>
+M:     Kent Overstreet <kmo@daterainc.com>
 L:     linux-bcache@vger.kernel.org
 W:     http://bcache.evilpiepirate.org
 S:     Maintained:
@@ -2871,7 +2876,7 @@ F:        drivers/media/usb/dvb-usb-v2/dvb_usb*
 F:     drivers/media/usb/dvb-usb-v2/usb_urb.c
 
 DYNAMIC DEBUG
-M:     Jason Baron <jbaron@redhat.com>
+M:     Jason Baron <jbaron@akamai.com>
 S:     Maintained
 F:     lib/dynamic_debug.c
 F:     include/linux/dynamic_debug.h
@@ -3346,7 +3351,7 @@ F:        Documentation/firmware_class/
 F:     drivers/base/firmware*.c
 F:     include/linux/firmware.h
 
-FLASHSYSTEM DRIVER (IBM FlashSystem 70/80 PCI SSD Flash Card)
+FLASH ADAPTER DRIVER (IBM Flash Adapter 900GB Full Height PCI Flash Card)
 M:     Joshua Morris <josh.h.morris@us.ibm.com>
 M:     Philip Kelleher <pjk1939@linux.vnet.ibm.com>
 S:     Maintained
@@ -3622,11 +3627,9 @@ F:       drivers/isdn/gigaset/
 F:     include/uapi/linux/gigaset_dev.h
 
 GPIO SUBSYSTEM
-M:     Grant Likely <grant.likely@linaro.org>
 M:     Linus Walleij <linus.walleij@linaro.org>
 S:     Maintained
 L:     linux-gpio@vger.kernel.org
-T:     git git://git.secretlab.ca/git/linux-2.6.git
 F:     Documentation/gpio.txt
 F:     drivers/gpio/
 F:     include/linux/gpio*
@@ -4472,8 +4475,6 @@ F:        drivers/irqchip/
 
 IRQ DOMAINS (IRQ NUMBER MAPPING LIBRARY)
 M:     Benjamin Herrenschmidt <benh@kernel.crashing.org>
-M:     Grant Likely <grant.likely@linaro.org>
-T:     git git://git.secretlab.ca/git/linux-2.6.git irqdomain/next
 S:     Maintained
 F:     Documentation/IRQ-domain.txt
 F:     include/linux/irqdomain.h
@@ -4990,7 +4991,7 @@ F:        arch/powerpc/platforms/44x/
 
 LINUX FOR POWERPC EMBEDDED XILINX VIRTEX
 L:     linuxppc-dev@lists.ozlabs.org
-S:     Unmaintained
+S:     Orphan
 F:     arch/powerpc/*/*virtex*
 F:     arch/powerpc/*/*/*virtex*
 
@@ -5580,9 +5581,9 @@ S:        Maintained
 F:     drivers/media/tuners/mxl5007t.*
 
 MYRICOM MYRI-10G 10GbE DRIVER (MYRI10GE)
-M:     Andrew Gallatin <gallatin@myri.com>
+M:     Hyong-Youb Kim <hykim@myri.com>
 L:     netdev@vger.kernel.org
-W:     http://www.myri.com/scs/download-Myri10GE.html
+W:     https://www.myricom.com/support/downloads/myri10ge.html
 S:     Supported
 F:     drivers/net/ethernet/myricom/myri10ge/
 
@@ -5883,10 +5884,10 @@ F:      drivers/i2c/busses/i2c-omap.c
 F:     include/linux/i2c-omap.h
 
 OMAP DEVICE TREE SUPPORT
-M:     Benoît Cousson <b-cousson@ti.com>
+M:     Benoît Cousson <bcousson@baylibre.com>
 M:     Tony Lindgren <tony@atomide.com>
 L:     linux-omap@vger.kernel.org
-L:     devicetree-discuss@lists.ozlabs.org (moderated for non-subscribers)
+L:     devicetree@vger.kernel.org
 S:     Maintained
 F:     arch/arm/boot/dts/*omap*
 F:     arch/arm/boot/dts/*am3*
@@ -5963,14 +5964,14 @@ S:      Maintained
 F:     drivers/char/hw_random/omap-rng.c
 
 OMAP HWMOD SUPPORT
-M:     Benoît Cousson <b-cousson@ti.com>
+M:     Benoît Cousson <bcousson@baylibre.com>
 M:     Paul Walmsley <paul@pwsan.com>
 L:     linux-omap@vger.kernel.org
 S:     Maintained
 F:     arch/arm/mach-omap2/omap_hwmod.*
 
 OMAP HWMOD DATA FOR OMAP4-BASED DEVICES
-M:     Benoît Cousson <b-cousson@ti.com>
+M:     Benoît Cousson <bcousson@baylibre.com>
 L:     linux-omap@vger.kernel.org
 S:     Maintained
 F:     arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -6050,17 +6051,28 @@ F:      drivers/i2c/busses/i2c-ocores.c
 OPEN FIRMWARE AND FLATTENED DEVICE TREE
 M:     Grant Likely <grant.likely@linaro.org>
 M:     Rob Herring <rob.herring@calxeda.com>
-L:     devicetree-discuss@lists.ozlabs.org (moderated for non-subscribers)
+L:     devicetree@vger.kernel.org
 W:     http://fdt.secretlab.ca
 T:     git git://git.secretlab.ca/git/linux-2.6.git
 S:     Maintained
-F:     Documentation/devicetree
-F:     drivers/of
+F:     drivers/of/
 F:     include/linux/of*.h
-F:     scripts/dtc
+F:     scripts/dtc/
 K:     of_get_property
 K:     of_match_table
 
+OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
+M:     Rob Herring <rob.herring@calxeda.com>
+M:     Pawel Moll <pawel.moll@arm.com>
+M:     Mark Rutland <mark.rutland@arm.com>
+M:     Stephen Warren <swarren@wwwdotorg.org>
+M:     Ian Campbell <ian.campbell@citrix.com>
+L:     devicetree@vger.kernel.org
+S:     Maintained
+F:     Documentation/devicetree/
+F:     arch/*/boot/dts/
+F:     include/dt-bindings/
+
 OPENRISC ARCHITECTURE
 M:     Jonas Bonn <jonas@southpole.se>
 W:     http://openrisc.net
@@ -7224,6 +7236,7 @@ W:        http://lksctp.sourceforge.net
 S:     Maintained
 F:     Documentation/networking/sctp.txt
 F:     include/linux/sctp.h
+F:     include/uapi/linux/sctp.h
 F:     include/net/sctp/
 F:     net/sctp/
 
@@ -7354,7 +7367,6 @@ F:        drivers/net/ethernet/sfc/
 
 SGI GRU DRIVER
 M:     Dimitri Sivanich <sivanich@sgi.com>
-M:     Robin Holt <holt@sgi.com>
 S:     Maintained
 F:     drivers/misc/sgi-gru/
 
@@ -7374,7 +7386,8 @@ S:        Maintained for 2.6.
 F:     Documentation/sgi-visws.txt
 
 SGI XP/XPC/XPNET DRIVER
-M:     Robin Holt <holt@sgi.com>
+M:     Cliff Whickman <cpw@sgi.com>
+M:     Robin Holt <robinmholt@gmail.com>
 S:     Maintained
 F:     drivers/misc/sgi-xp/
 
@@ -7754,7 +7767,6 @@ F:        drivers/clk/spear/
 
 SPI SUBSYSTEM
 M:     Mark Brown <broonie@kernel.org>
-M:     Grant Likely <grant.likely@linaro.org>
 L:     linux-spi@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
 Q:     http://patchwork.kernel.org/project/spi-devel-general/list/
@@ -7820,7 +7832,7 @@ F:        drivers/staging/asus_oled/
 
 STAGING - COMEDI
 M:     Ian Abbott <abbotti@mev.co.uk>
-M:     Mori Hess <fmhess@users.sourceforge.net>
+M:     H Hartley Sweeten <hsweeten@visionengravers.com>
 S:     Odd Fixes
 F:     drivers/staging/comedi/
 
@@ -7961,6 +7973,12 @@ F:       arch/m68k/sun3*/
 F:     arch/m68k/include/asm/sun3*
 F:     drivers/net/ethernet/i825xx/sun3*
 
+SUNDANCE NETWORK DRIVER
+M:     Denis Kirjanov <kda@linux-powerpc.org>
+L:     netdev@vger.kernel.org
+S:     Maintained
+F:     drivers/net/ethernet/dlink/sundance.c
+
 SUPERH
 M:     Paul Mundt <lethal@linux-sh.org>
 L:     linux-sh@vger.kernel.org
@@ -8658,6 +8676,11 @@ T:       git git://git.alsa-project.org/alsa-kernel.git
 S:     Maintained
 F:     sound/usb/midi.*
 
+USB NETWORKING DRIVERS
+L:     linux-usb@vger.kernel.org
+S:     Odd Fixes
+F:     drivers/net/usb/
+
 USB OHCI DRIVER
 M:     Alan Stern <stern@rowland.harvard.edu>
 L:     linux-usb@vger.kernel.org
@@ -9296,7 +9319,7 @@ S:        Maintained
 F:     drivers/net/ethernet/xilinx/xilinx_axienet*
 
 XILINX SYSTEMACE DRIVER
-S:     Unmaintained
+S:     Orphan
 F:     drivers/block/xsysace.c
 
 XILINX UARTLITE SERIAL DRIVER
index 9262ba8da4f9859e8cd86e340fb3c159ce261e7e..a5a55f4547c6e79fa17a0051dc5cce1daaec2a50 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 3
 PATCHLEVEL = 11
 SUBLEVEL = 0
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc6
 NAME = Linux for Workgroups
 
 # *DOCUMENTATION*
index 8d2ae24b9f4a815e253340c75c633be0a18fae9d..1feb169274fe613cc5f0360c797668bf84497c4b 100644 (file)
@@ -407,6 +407,12 @@ config CLONE_BACKWARDS2
        help
          Architecture has the first two arguments of clone(2) swapped.
 
+config CLONE_BACKWARDS3
+       bool
+       help
+         Architecture has tls passed as the 3rd argument of clone(2),
+         not the 5th one.
+
 config ODD_RT_SIGACTION
        bool
        help
index 837a1f2d8b965a60b61252521f21129be9e80afe..082d9b4b54723d0253e7ca3355387886b81f72f4 100644 (file)
@@ -15,6 +15,7 @@ config ALPHA
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARCH_WANT_IPC_PARSE_VERSION
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
+       select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
        select GENERIC_SMP_IDLE_THREAD
        select GENERIC_CMOS_UPDATE
        select GENERIC_STRNCPY_FROM_USER
index c2cbe4fc391cd7d77d319cb0cbeabd19f7e5ecbb..78b03ef39f6f0c2960e0b9c4b45eeae47eff07fa 100644 (file)
@@ -186,17 +186,24 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
  */
 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
 {
-       int c, old;
-       c = atomic_read(v);
-       for (;;) {
-               if (unlikely(c == (u)))
-                       break;
-               old = atomic_cmpxchg((v), c, c + (a));
-               if (likely(old == c))
-                       break;
-               c = old;
-       }
-       return c;
+       int c, new, old;
+       smp_mb();
+       __asm__ __volatile__(
+       "1:     ldl_l   %[old],%[mem]\n"
+       "       cmpeq   %[old],%[u],%[c]\n"
+       "       addl    %[old],%[a],%[new]\n"
+       "       bne     %[c],2f\n"
+       "       stl_c   %[new],%[mem]\n"
+       "       beq     %[new],3f\n"
+       "2:\n"
+       ".subsection 2\n"
+       "3:     br      1b\n"
+       ".previous"
+       : [old] "=&r"(old), [new] "=&r"(new), [c] "=&r"(c)
+       : [mem] "m"(*v), [a] "rI"(a), [u] "rI"((long)u)
+       : "memory");
+       smp_mb();
+       return old;
 }
 
 
@@ -207,21 +214,56 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
  * @u: ...unless v is equal to u.
  *
  * Atomically adds @a to @v, so long as it was not @u.
- * Returns the old value of @v.
+ * Returns true iff @v was not @u.
  */
 static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
 {
-       long c, old;
-       c = atomic64_read(v);
-       for (;;) {
-               if (unlikely(c == (u)))
-                       break;
-               old = atomic64_cmpxchg((v), c, c + (a));
-               if (likely(old == c))
-                       break;
-               c = old;
-       }
-       return c != (u);
+       long c, tmp;
+       smp_mb();
+       __asm__ __volatile__(
+       "1:     ldq_l   %[tmp],%[mem]\n"
+       "       cmpeq   %[tmp],%[u],%[c]\n"
+       "       addq    %[tmp],%[a],%[tmp]\n"
+       "       bne     %[c],2f\n"
+       "       stq_c   %[tmp],%[mem]\n"
+       "       beq     %[tmp],3f\n"
+       "2:\n"
+       ".subsection 2\n"
+       "3:     br      1b\n"
+       ".previous"
+       : [tmp] "=&r"(tmp), [c] "=&r"(c)
+       : [mem] "m"(*v), [a] "rI"(a), [u] "rI"(u)
+       : "memory");
+       smp_mb();
+       return !c;
+}
+
+/*
+ * atomic64_dec_if_positive - decrement by 1 if old value positive
+ * @v: pointer of type atomic_t
+ *
+ * The function returns the old value of *v minus 1, even if
+ * the atomic variable, v, was not decremented.
+ */
+static inline long atomic64_dec_if_positive(atomic64_t *v)
+{
+       long old, tmp;
+       smp_mb();
+       __asm__ __volatile__(
+       "1:     ldq_l   %[old],%[mem]\n"
+       "       subq    %[old],1,%[tmp]\n"
+       "       ble     %[old],2f\n"
+       "       stq_c   %[tmp],%[mem]\n"
+       "       beq     %[tmp],3f\n"
+       "2:\n"
+       ".subsection 2\n"
+       "3:     br      1b\n"
+       ".previous"
+       : [old] "=&r"(old), [tmp] "=&r"(tmp)
+       : [mem] "m"(*v)
+       : "memory");
+       smp_mb();
+       return old - 1;
 }
 
 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
index bf46af51941b058ad6b0de0df4156f796bbb5897..a5b68b268bcf34835a6376d8b8e2cb349d03feed 100644 (file)
@@ -3,7 +3,9 @@
 
 #include <uapi/asm/param.h>
 
-#define HZ             CONFIG_HZ
-#define USER_HZ                HZ
-# define CLOCKS_PER_SEC        HZ      /* frequency at which times() counts */
+# undef HZ
+# define HZ            CONFIG_HZ
+# define USER_HZ       1024
+# define CLOCKS_PER_SEC        USER_HZ /* frequency at which times() counts */
+
 #endif /* _ASM_ALPHA_PARAM_H */
index 3bba21e41b818e1ff8fb7f346721dc8e95f93950..37b570d01202e4ee62d5dcc11af345f1805e81a0 100644 (file)
@@ -168,8 +168,4 @@ static inline void arch_write_unlock(arch_rwlock_t * lock)
 #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
 #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define arch_spin_relax(lock)  cpu_relax()
-#define arch_read_relax(lock)  cpu_relax()
-#define arch_write_relax(lock) cpu_relax()
-
 #endif /* _ALPHA_SPINLOCK_H */
index 43baee17acdf43c065bc6a9bd59b2ffa2c391f80..f2c94402e2c8b95028bace631c3cbf6f2aeca5b1 100644 (file)
@@ -3,8 +3,7 @@
 
 #include <uapi/asm/unistd.h>
 
-
-#define NR_SYSCALLS                    506
+#define NR_SYSCALLS                    508
 
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
index 29daed819ebd0bd56bf3ca4fda4500cf4aaadfa4..dbcd9834af6d7f58eaad342356eee7a7dd12c5d2 100644 (file)
@@ -1,13 +1,7 @@
 #ifndef _UAPI_ASM_ALPHA_PARAM_H
 #define _UAPI_ASM_ALPHA_PARAM_H
 
-/* ??? Gross.  I don't want to parameterize this, and supposedly the
-   hardware ignores reprogramming.  We also need userland buy-in to the 
-   change in HZ, since this is visible in the wait4 resources etc.  */
-
-#ifndef __KERNEL__
 #define HZ             1024
-#endif
 
 #define EXEC_PAGESIZE  8192
 
@@ -17,5 +11,4 @@
 
 #define MAXHOSTNAMELEN 64      /* max length of hostname */
 
-
 #endif /* _UAPI_ASM_ALPHA_PARAM_H */
index 801d28bcea51f61c3b45a6fcd4504f01bc96b792..53ae7bb1bfd1b3841572ae69587b80dddd9c0657 100644 (file)
 #define __NR_sendmmsg                  503
 #define __NR_process_vm_readv          504
 #define __NR_process_vm_writev         505
+#define __NR_kcmp                      506
+#define __NR_finit_module              507
 
 #endif /* _UAPI_ALPHA_UNISTD_H */
index f62a994ef1263c1d9bea762371f7b797d5225cd3..a969b95ee5ac78a64d79dd4ffa815b4b4a0f5e98 100644 (file)
 
        .text
        .set noat
+       .cfi_sections   .debug_frame
 
 /* Stack offsets.  */
 #define SP_OFF                 184
 #define SWITCH_STACK_SIZE      320
 
+.macro CFI_START_OSF_FRAME     func
+       .align  4
+       .globl  \func
+       .type   \func,@function
+\func:
+       .cfi_startproc simple
+       .cfi_return_column 64
+       .cfi_def_cfa    $sp, 48
+       .cfi_rel_offset 64, 8
+       .cfi_rel_offset $gp, 16
+       .cfi_rel_offset $16, 24
+       .cfi_rel_offset $17, 32
+       .cfi_rel_offset $18, 40
+.endm
+
+.macro CFI_END_OSF_FRAME       func
+       .cfi_endproc
+       .size   \func, . - \func
+.endm
+
 /*
  * This defines the normal kernel pt-regs layout.
  *
  * the palcode-provided values are available to the signal handler.
  */
 
-#define SAVE_ALL                       \
-       subq    $sp, SP_OFF, $sp;       \
-       stq     $0, 0($sp);             \
-       stq     $1, 8($sp);             \
-       stq     $2, 16($sp);            \
-       stq     $3, 24($sp);            \
-       stq     $4, 32($sp);            \
-       stq     $28, 144($sp);          \
-       lda     $2, alpha_mv;           \
-       stq     $5, 40($sp);            \
-       stq     $6, 48($sp);            \
-       stq     $7, 56($sp);            \
-       stq     $8, 64($sp);            \
-       stq     $19, 72($sp);           \
-       stq     $20, 80($sp);           \
-       stq     $21, 88($sp);           \
-       ldq     $2, HAE_CACHE($2);      \
-       stq     $22, 96($sp);           \
-       stq     $23, 104($sp);          \
-       stq     $24, 112($sp);          \
-       stq     $25, 120($sp);          \
-       stq     $26, 128($sp);          \
-       stq     $27, 136($sp);          \
-       stq     $2, 152($sp);           \
-       stq     $16, 160($sp);          \
-       stq     $17, 168($sp);          \
+.macro SAVE_ALL
+       subq    $sp, SP_OFF, $sp
+       .cfi_adjust_cfa_offset  SP_OFF
+       stq     $0, 0($sp)
+       stq     $1, 8($sp)
+       stq     $2, 16($sp)
+       stq     $3, 24($sp)
+       stq     $4, 32($sp)
+       stq     $28, 144($sp)
+       .cfi_rel_offset $0, 0
+       .cfi_rel_offset $1, 8
+       .cfi_rel_offset $2, 16
+       .cfi_rel_offset $3, 24
+       .cfi_rel_offset $4, 32
+       .cfi_rel_offset $28, 144
+       lda     $2, alpha_mv
+       stq     $5, 40($sp)
+       stq     $6, 48($sp)
+       stq     $7, 56($sp)
+       stq     $8, 64($sp)
+       stq     $19, 72($sp)
+       stq     $20, 80($sp)
+       stq     $21, 88($sp)
+       ldq     $2, HAE_CACHE($2)
+       stq     $22, 96($sp)
+       stq     $23, 104($sp)
+       stq     $24, 112($sp)
+       stq     $25, 120($sp)
+       stq     $26, 128($sp)
+       stq     $27, 136($sp)
+       stq     $2, 152($sp)
+       stq     $16, 160($sp)
+       stq     $17, 168($sp)
        stq     $18, 176($sp)
+       .cfi_rel_offset $5, 40
+       .cfi_rel_offset $6, 48
+       .cfi_rel_offset $7, 56
+       .cfi_rel_offset $8, 64
+       .cfi_rel_offset $19, 72
+       .cfi_rel_offset $20, 80
+       .cfi_rel_offset $21, 88
+       .cfi_rel_offset $22, 96
+       .cfi_rel_offset $23, 104
+       .cfi_rel_offset $24, 112
+       .cfi_rel_offset $25, 120
+       .cfi_rel_offset $26, 128
+       .cfi_rel_offset $27, 136
+.endm
 
-#define RESTORE_ALL                    \
-       lda     $19, alpha_mv;          \
-       ldq     $0, 0($sp);             \
-       ldq     $1, 8($sp);             \
-       ldq     $2, 16($sp);            \
-       ldq     $3, 24($sp);            \
-       ldq     $21, 152($sp);          \
-       ldq     $20, HAE_CACHE($19);    \
-       ldq     $4, 32($sp);            \
-       ldq     $5, 40($sp);            \
-       ldq     $6, 48($sp);            \
-       ldq     $7, 56($sp);            \
-       subq    $20, $21, $20;          \
-       ldq     $8, 64($sp);            \
-       beq     $20, 99f;               \
-       ldq     $20, HAE_REG($19);      \
-       stq     $21, HAE_CACHE($19);    \
-       stq     $21, 0($20);            \
-99:;                                   \
-       ldq     $19, 72($sp);           \
-       ldq     $20, 80($sp);           \
-       ldq     $21, 88($sp);           \
-       ldq     $22, 96($sp);           \
-       ldq     $23, 104($sp);          \
-       ldq     $24, 112($sp);          \
-       ldq     $25, 120($sp);          \
-       ldq     $26, 128($sp);          \
-       ldq     $27, 136($sp);          \
-       ldq     $28, 144($sp);          \
+.macro RESTORE_ALL
+       lda     $19, alpha_mv
+       ldq     $0, 0($sp)
+       ldq     $1, 8($sp)
+       ldq     $2, 16($sp)
+       ldq     $3, 24($sp)
+       ldq     $21, 152($sp)
+       ldq     $20, HAE_CACHE($19)
+       ldq     $4, 32($sp)
+       ldq     $5, 40($sp)
+       ldq     $6, 48($sp)
+       ldq     $7, 56($sp)
+       subq    $20, $21, $20
+       ldq     $8, 64($sp)
+       beq     $20, 99f
+       ldq     $20, HAE_REG($19)
+       stq     $21, HAE_CACHE($19)
+       stq     $21, 0($20)
+99:    ldq     $19, 72($sp)
+       ldq     $20, 80($sp)
+       ldq     $21, 88($sp)
+       ldq     $22, 96($sp)
+       ldq     $23, 104($sp)
+       ldq     $24, 112($sp)
+       ldq     $25, 120($sp)
+       ldq     $26, 128($sp)
+       ldq     $27, 136($sp)
+       ldq     $28, 144($sp)
        addq    $sp, SP_OFF, $sp
+       .cfi_restore    $0
+       .cfi_restore    $1
+       .cfi_restore    $2
+       .cfi_restore    $3
+       .cfi_restore    $4
+       .cfi_restore    $5
+       .cfi_restore    $6
+       .cfi_restore    $7
+       .cfi_restore    $8
+       .cfi_restore    $19
+       .cfi_restore    $20
+       .cfi_restore    $21
+       .cfi_restore    $22
+       .cfi_restore    $23
+       .cfi_restore    $24
+       .cfi_restore    $25
+       .cfi_restore    $26
+       .cfi_restore    $27
+       .cfi_restore    $28
+       .cfi_adjust_cfa_offset  -SP_OFF
+.endm
+
+.macro DO_SWITCH_STACK
+       bsr     $1, do_switch_stack
+       .cfi_adjust_cfa_offset  SWITCH_STACK_SIZE
+       .cfi_rel_offset $9, 0
+       .cfi_rel_offset $10, 8
+       .cfi_rel_offset $11, 16
+       .cfi_rel_offset $12, 24
+       .cfi_rel_offset $13, 32
+       .cfi_rel_offset $14, 40
+       .cfi_rel_offset $15, 48
+       /* We don't really care about the FP registers for debugging.  */
+.endm
+
+.macro UNDO_SWITCH_STACK
+       bsr     $1, undo_switch_stack
+       .cfi_restore    $9
+       .cfi_restore    $10
+       .cfi_restore    $11
+       .cfi_restore    $12
+       .cfi_restore    $13
+       .cfi_restore    $14
+       .cfi_restore    $15
+       .cfi_adjust_cfa_offset  -SWITCH_STACK_SIZE
+.endm
 
 /*
  * Non-syscall kernel entry points.
  */
 
-       .align  4
-       .globl  entInt
-       .ent    entInt
-entInt:
+CFI_START_OSF_FRAME entInt
        SAVE_ALL
        lda     $8, 0x3fff
        lda     $26, ret_from_sys_call
        bic     $sp, $8, $8
        mov     $sp, $19
        jsr     $31, do_entInt
-.end entInt
+CFI_END_OSF_FRAME entInt
 
-       .align  4
-       .globl  entArith
-       .ent    entArith
-entArith:
+CFI_START_OSF_FRAME entArith
        SAVE_ALL
        lda     $8, 0x3fff
        lda     $26, ret_from_sys_call
        bic     $sp, $8, $8
        mov     $sp, $18
        jsr     $31, do_entArith
-.end entArith
+CFI_END_OSF_FRAME entArith
 
-       .align  4
-       .globl  entMM
-       .ent    entMM
-entMM:
+CFI_START_OSF_FRAME entMM
        SAVE_ALL
 /* save $9 - $15 so the inline exception code can manipulate them.  */
        subq    $sp, 56, $sp
+       .cfi_adjust_cfa_offset  56
        stq     $9, 0($sp)
        stq     $10, 8($sp)
        stq     $11, 16($sp)
@@ -128,6 +207,13 @@ entMM:
        stq     $13, 32($sp)
        stq     $14, 40($sp)
        stq     $15, 48($sp)
+       .cfi_rel_offset $9, 0
+       .cfi_rel_offset $10, 8
+       .cfi_rel_offset $11, 16
+       .cfi_rel_offset $12, 24
+       .cfi_rel_offset $13, 32
+       .cfi_rel_offset $14, 40
+       .cfi_rel_offset $15, 48
        addq    $sp, 56, $19
 /* handle the fault */
        lda     $8, 0x3fff
@@ -142,28 +228,33 @@ entMM:
        ldq     $14, 40($sp)
        ldq     $15, 48($sp)
        addq    $sp, 56, $sp
+       .cfi_restore    $9
+       .cfi_restore    $10
+       .cfi_restore    $11
+       .cfi_restore    $12
+       .cfi_restore    $13
+       .cfi_restore    $14
+       .cfi_restore    $15
+       .cfi_adjust_cfa_offset  -56
 /* finish up the syscall as normal.  */
        br      ret_from_sys_call
-.end entMM
+CFI_END_OSF_FRAME entMM
 
-       .align  4
-       .globl  entIF
-       .ent    entIF
-entIF:
+CFI_START_OSF_FRAME entIF
        SAVE_ALL
        lda     $8, 0x3fff
        lda     $26, ret_from_sys_call
        bic     $sp, $8, $8
        mov     $sp, $17
        jsr     $31, do_entIF
-.end entIF
+CFI_END_OSF_FRAME entIF
 
-       .align  4
-       .globl  entUna
-       .ent    entUna
-entUna:
+CFI_START_OSF_FRAME entUna
        lda     $sp, -256($sp)
+       .cfi_adjust_cfa_offset  256
        stq     $0, 0($sp)
+       .cfi_rel_offset $0, 0
+       .cfi_remember_state
        ldq     $0, 256($sp)    /* get PS */
        stq     $1, 8($sp)
        stq     $2, 16($sp)
@@ -195,6 +286,32 @@ entUna:
        stq     $28, 224($sp)
        mov     $sp, $19
        stq     $gp, 232($sp)
+       .cfi_rel_offset $1, 1*8
+       .cfi_rel_offset $2, 2*8
+       .cfi_rel_offset $3, 3*8
+       .cfi_rel_offset $4, 4*8
+       .cfi_rel_offset $5, 5*8
+       .cfi_rel_offset $6, 6*8
+       .cfi_rel_offset $7, 7*8
+       .cfi_rel_offset $8, 8*8
+       .cfi_rel_offset $9, 9*8
+       .cfi_rel_offset $10, 10*8
+       .cfi_rel_offset $11, 11*8
+       .cfi_rel_offset $12, 12*8
+       .cfi_rel_offset $13, 13*8
+       .cfi_rel_offset $14, 14*8
+       .cfi_rel_offset $15, 15*8
+       .cfi_rel_offset $19, 19*8
+       .cfi_rel_offset $20, 20*8
+       .cfi_rel_offset $21, 21*8
+       .cfi_rel_offset $22, 22*8
+       .cfi_rel_offset $23, 23*8
+       .cfi_rel_offset $24, 24*8
+       .cfi_rel_offset $25, 25*8
+       .cfi_rel_offset $26, 26*8
+       .cfi_rel_offset $27, 27*8
+       .cfi_rel_offset $28, 28*8
+       .cfi_rel_offset $29, 29*8
        lda     $8, 0x3fff
        stq     $31, 248($sp)
        bic     $sp, $8, $8
@@ -228,16 +345,45 @@ entUna:
        ldq     $28, 224($sp)
        ldq     $gp, 232($sp)
        lda     $sp, 256($sp)
+       .cfi_restore    $1
+       .cfi_restore    $2
+       .cfi_restore    $3
+       .cfi_restore    $4
+       .cfi_restore    $5
+       .cfi_restore    $6
+       .cfi_restore    $7
+       .cfi_restore    $8
+       .cfi_restore    $9
+       .cfi_restore    $10
+       .cfi_restore    $11
+       .cfi_restore    $12
+       .cfi_restore    $13
+       .cfi_restore    $14
+       .cfi_restore    $15
+       .cfi_restore    $19
+       .cfi_restore    $20
+       .cfi_restore    $21
+       .cfi_restore    $22
+       .cfi_restore    $23
+       .cfi_restore    $24
+       .cfi_restore    $25
+       .cfi_restore    $26
+       .cfi_restore    $27
+       .cfi_restore    $28
+       .cfi_restore    $29
+       .cfi_adjust_cfa_offset  -256
        call_pal PAL_rti
-.end entUna
 
        .align  4
-       .ent    entUnaUser
 entUnaUser:
+       .cfi_restore_state
        ldq     $0, 0($sp)      /* restore original $0 */
        lda     $sp, 256($sp)   /* pop entUna's stack frame */
+       .cfi_restore    $0
+       .cfi_adjust_cfa_offset  -256
        SAVE_ALL                /* setup normal kernel stack */
        lda     $sp, -56($sp)
+       .cfi_adjust_cfa_offset  56
        stq     $9, 0($sp)
        stq     $10, 8($sp)
        stq     $11, 16($sp)
@@ -245,6 +391,13 @@ entUnaUser:
        stq     $13, 32($sp)
        stq     $14, 40($sp)
        stq     $15, 48($sp)
+       .cfi_rel_offset $9, 0
+       .cfi_rel_offset $10, 8
+       .cfi_rel_offset $11, 16
+       .cfi_rel_offset $12, 24
+       .cfi_rel_offset $13, 32
+       .cfi_rel_offset $14, 40
+       .cfi_rel_offset $15, 48
        lda     $8, 0x3fff
        addq    $sp, 56, $19
        bic     $sp, $8, $8
@@ -257,20 +410,25 @@ entUnaUser:
        ldq     $14, 40($sp)
        ldq     $15, 48($sp)
        lda     $sp, 56($sp)
+       .cfi_restore    $9
+       .cfi_restore    $10
+       .cfi_restore    $11
+       .cfi_restore    $12
+       .cfi_restore    $13
+       .cfi_restore    $14
+       .cfi_restore    $15
+       .cfi_adjust_cfa_offset  -56
        br      ret_from_sys_call
-.end entUnaUser
+CFI_END_OSF_FRAME entUna
 
-       .align  4
-       .globl  entDbg
-       .ent    entDbg
-entDbg:
+CFI_START_OSF_FRAME entDbg
        SAVE_ALL
        lda     $8, 0x3fff
        lda     $26, ret_from_sys_call
        bic     $sp, $8, $8
        mov     $sp, $16
        jsr     $31, do_entDbg
-.end entDbg
+CFI_END_OSF_FRAME entDbg
 \f
 /*
  * The system call entry point is special.  Most importantly, it looks
@@ -285,8 +443,12 @@ entDbg:
 
        .align  4
        .globl  entSys
-       .globl  ret_from_sys_call
-       .ent    entSys
+       .type   entSys, @function
+       .cfi_startproc simple
+       .cfi_return_column 64
+       .cfi_def_cfa    $sp, 48
+       .cfi_rel_offset 64, 8
+       .cfi_rel_offset $gp, 16
 entSys:
        SAVE_ALL
        lda     $8, 0x3fff
@@ -300,6 +462,9 @@ entSys:
        stq     $17, SP_OFF+32($sp)
        s8addq  $0, $5, $5
        stq     $18, SP_OFF+40($sp)
+       .cfi_rel_offset $16, SP_OFF+24
+       .cfi_rel_offset $17, SP_OFF+32
+       .cfi_rel_offset $18, SP_OFF+40
        blbs    $3, strace
        beq     $4, 1f
        ldq     $27, 0($5)
@@ -310,6 +475,7 @@ entSys:
        stq     $31, 72($sp)            /* a3=0 => no error */
 
        .align  4
+       .globl  ret_from_sys_call
 ret_from_sys_call:
        cmovne  $26, 0, $18             /* $18 = 0 => non-restartable */
        ldq     $0, SP_OFF($sp)
@@ -324,10 +490,12 @@ ret_to_user:
        and     $17, _TIF_WORK_MASK, $2
        bne     $2, work_pending
 restore_all:
+       .cfi_remember_state
        RESTORE_ALL
        call_pal PAL_rti
 
 ret_to_kernel:
+       .cfi_restore_state
        lda     $16, 7
        call_pal PAL_swpipl
        br restore_all
@@ -356,7 +524,6 @@ $ret_success:
        stq     $0, 0($sp)
        stq     $31, 72($sp)    /* a3=0 => no error */
        br      ret_from_sys_call
-.end entSys
 
 /*
  * Do all cleanup when returning from all interrupts and system calls.
@@ -370,7 +537,7 @@ $ret_success:
  */
 
        .align  4
-       .ent    work_pending
+       .type   work_pending, @function
 work_pending:
        and     $17, _TIF_NOTIFY_RESUME | _TIF_SIGPENDING, $2
        bne     $2, $work_notifysig
@@ -387,23 +554,22 @@ $work_resched:
 
 $work_notifysig:
        mov     $sp, $16
-       bsr     $1, do_switch_stack
+       DO_SWITCH_STACK
        jsr     $26, do_work_pending
-       bsr     $1, undo_switch_stack
+       UNDO_SWITCH_STACK
        br      restore_all
-.end work_pending
 
 /*
  * PTRACE syscall handler
  */
 
        .align  4
-       .ent    strace
+       .type   strace, @function
 strace:
        /* set up signal stack, call syscall_trace */
-       bsr     $1, do_switch_stack
+       DO_SWITCH_STACK
        jsr     $26, syscall_trace_enter /* returns the syscall number */
-       bsr     $1, undo_switch_stack
+       UNDO_SWITCH_STACK
 
        /* get the arguments back.. */
        ldq     $16, SP_OFF+24($sp)
@@ -431,9 +597,9 @@ ret_from_straced:
 $strace_success:
        stq     $0, 0($sp)              /* save return value */
 
-       bsr     $1, do_switch_stack
+       DO_SWITCH_STACK
        jsr     $26, syscall_trace_leave
-       bsr     $1, undo_switch_stack
+       UNDO_SWITCH_STACK
        br      $31, ret_from_sys_call
 
        .align  3
@@ -447,26 +613,31 @@ $strace_error:
        stq     $0, 0($sp)
        stq     $1, 72($sp)     /* a3 for return */
 
-       bsr     $1, do_switch_stack
+       DO_SWITCH_STACK
        mov     $18, $9         /* save old syscall number */
        mov     $19, $10        /* save old a3 */
        jsr     $26, syscall_trace_leave
        mov     $9, $18
        mov     $10, $19
-       bsr     $1, undo_switch_stack
+       UNDO_SWITCH_STACK
 
        mov     $31, $26        /* tell "ret_from_sys_call" we can restart */
        br      ret_from_sys_call
-.end strace
+CFI_END_OSF_FRAME entSys
 \f
 /*
  * Save and restore the switch stack -- aka the balance of the user context.
  */
 
        .align  4
-       .ent    do_switch_stack
+       .type   do_switch_stack, @function
+       .cfi_startproc simple
+       .cfi_return_column 64
+       .cfi_def_cfa $sp, 0
+       .cfi_register 64, $1
 do_switch_stack:
        lda     $sp, -SWITCH_STACK_SIZE($sp)
+       .cfi_adjust_cfa_offset  SWITCH_STACK_SIZE
        stq     $9, 0($sp)
        stq     $10, 8($sp)
        stq     $11, 16($sp)
@@ -510,10 +681,14 @@ do_switch_stack:
        stt     $f0, 312($sp)   # save fpcr in slot of $f31
        ldt     $f0, 64($sp)    # dont let "do_switch_stack" change fp state.
        ret     $31, ($1), 1
-.end do_switch_stack
+       .cfi_endproc
+       .size   do_switch_stack, .-do_switch_stack
 
        .align  4
-       .ent    undo_switch_stack
+       .type   undo_switch_stack, @function
+       .cfi_startproc simple
+       .cfi_def_cfa $sp, 0
+       .cfi_register 64, $1
 undo_switch_stack:
        ldq     $9, 0($sp)
        ldq     $10, 8($sp)
@@ -558,7 +733,8 @@ undo_switch_stack:
        ldt     $f30, 304($sp)
        lda     $sp, SWITCH_STACK_SIZE($sp)
        ret     $31, ($1), 1
-.end undo_switch_stack
+       .cfi_endproc
+       .size   undo_switch_stack, .-undo_switch_stack
 \f
 /*
  * The meat of the context switch code.
@@ -566,17 +742,18 @@ undo_switch_stack:
 
        .align  4
        .globl  alpha_switch_to
-       .ent    alpha_switch_to
+       .type   alpha_switch_to, @function
+       .cfi_startproc
 alpha_switch_to:
-       .prologue 0
-       bsr     $1, do_switch_stack
+       DO_SWITCH_STACK
        call_pal PAL_swpctx
        lda     $8, 0x3fff
-       bsr     $1, undo_switch_stack
+       UNDO_SWITCH_STACK
        bic     $sp, $8, $8
        mov     $17, $0
        ret
-.end alpha_switch_to
+       .cfi_endproc
+       .size   alpha_switch_to, .-alpha_switch_to
 
 /*
  * New processes begin life here.
index f433fc11877a30ae096dd54d263b37b094132fac..28e4429596f3f208c1b868887112bad4faa33987 100644 (file)
@@ -236,7 +236,7 @@ void __init
 init_rtc_irq(void)
 {
        irq_set_chip_and_handler_name(RTC_IRQ, &dummy_irq_chip,
-                                     handle_simple_irq, "RTC");
+                                     handle_percpu_irq, "RTC");
        setup_irq(RTC_IRQ, &timer_irqaction);
 }
 
index 7b60834fb4b2f3e2b638c1cb6c73f6f179ef0752..9dbbcb3b914675f80e3e0f097ced7e4545b533f9 100644 (file)
@@ -116,7 +116,7 @@ wait_boot_cpu_to_stop(int cpuid)
 /*
  * Where secondaries begin a life of C.
  */
-void __cpuinit
+void
 smp_callin(void)
 {
        int cpuid = hard_smp_processor_id();
@@ -194,7 +194,7 @@ wait_for_txrdy (unsigned long cpumask)
  * Send a message to a secondary's console.  "START" is one such
  * interesting message.  ;-)
  */
-static void __cpuinit
+static void
 send_secondary_console_msg(char *str, int cpuid)
 {
        struct percpu_struct *cpu;
@@ -264,9 +264,10 @@ recv_secondary_console_msg(void)
                if (cnt <= 0 || cnt >= 80)
                        strcpy(buf, "<<< BOGUS MSG >>>");
                else {
-                       cp1 = (char *) &cpu->ipc_buffer[11];
+                       cp1 = (char *) &cpu->ipc_buffer[1];
                        cp2 = buf;
-                       strcpy(cp2, cp1);
+                       memcpy(cp2, cp1, cnt);
+                       cp2[cnt] = '\0';
                        
                        while ((cp2 = strchr(cp2, '\r')) != 0) {
                                *cp2 = ' ';
@@ -285,7 +286,7 @@ recv_secondary_console_msg(void)
 /*
  * Convince the console to have a secondary cpu begin execution.
  */
-static int __cpuinit
+static int
 secondary_cpu_start(int cpuid, struct task_struct *idle)
 {
        struct percpu_struct *cpu;
@@ -356,7 +357,7 @@ secondary_cpu_start(int cpuid, struct task_struct *idle)
 /*
  * Bring one cpu online.
  */
-static int __cpuinit
+static int
 smp_boot_one_cpu(int cpuid, struct task_struct *idle)
 {
        unsigned long timeout;
@@ -472,7 +473,7 @@ smp_prepare_boot_cpu(void)
 {
 }
 
-int __cpuinit
+int
 __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        smp_boot_one_cpu(cpu, tidle);
index 5bf401f7ea97f5379067facc21762c9dfdd1732d..6c35159bc00eb47860516bda8868801a74bbe868 100644 (file)
@@ -190,9 +190,6 @@ static struct irq_chip clipper_irq_type = {
 static void
 dp264_device_interrupt(unsigned long vector)
 {
-#if 1
-       printk("dp264_device_interrupt: NOT IMPLEMENTED YET!!\n");
-#else
        unsigned long pld;
        unsigned int i;
 
@@ -210,12 +207,7 @@ dp264_device_interrupt(unsigned long vector)
                        isa_device_interrupt(vector);
                else
                        handle_irq(16 + i);
-#if 0
-               TSUNAMI_cchip->dir0.csr = 1UL << i; mb();
-               tmp = TSUNAMI_cchip->dir0.csr;
-#endif
        }
-#endif
 }
 
 static void 
index 407accc808777bc4a6f36fa6b912b92686d09a0b..c92e389ff2192973f95f51073a5ce50e5f132a3b 100644 (file)
@@ -317,8 +317,9 @@ marvel_init_irq(void)
 }
 
 static int 
-marvel_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+marvel_map_irq(const struct pci_dev *cdev, u8 slot, u8 pin)
 {
+       struct pci_dev *dev = (struct pci_dev *)cdev;
        struct pci_controller *hose = dev->sysdata;
        struct io7_port *io7_port = hose->sysdata;
        struct io7 *io7 = io7_port->io7;
index 4284ec798ec94c89ebe0e4b05e1eb2d1c6dbb0ed..dca9b3fb0071d8c24c1c5e1048a0da8461e12d8e 100644 (file)
@@ -524,6 +524,8 @@ sys_call_table:
        .quad sys_sendmmsg
        .quad sys_process_vm_readv
        .quad sys_process_vm_writev             /* 505 */
+       .quad sys_kcmp
+       .quad sys_finit_module
 
        .size sys_call_table, . - sys_call_table
        .type sys_call_table, @object
index e336694ca042127c39a4cef780dee557b2f068cd..ea3395036556ceea61c74c08452d5e7a7061e566 100644 (file)
@@ -105,9 +105,7 @@ void arch_irq_work_raise(void)
 
 static inline __u32 rpcc(void)
 {
-    __u32 result;
-    asm volatile ("rpcc %0" : "=r"(result));
-    return result;
+       return __builtin_alpha_rpcc();
 }
 
 int update_persistent_clock(struct timespec now)
index affccb959a9e8c9a28977883cd9e5b916dd0b679..bd0665cdc840d3e9a79b752ec3a88279ede69344 100644 (file)
@@ -32,7 +32,7 @@
 
 static int opDEC_fix;
 
-static void __cpuinit
+static void
 opDEC_check(void)
 {
        __asm__ __volatile__ (
@@ -66,8 +66,8 @@ dik_show_regs(struct pt_regs *regs, unsigned long *r9_15)
 {
        printk("pc = [<%016lx>]  ra = [<%016lx>]  ps = %04lx    %s\n",
               regs->pc, regs->r26, regs->ps, print_tainted());
-       print_symbol("pc is at %s\n", regs->pc);
-       print_symbol("ra is at %s\n", regs->r26 );
+       printk("pc is at %pSR\n", (void *)regs->pc);
+       printk("ra is at %pSR\n", (void *)regs->r26);
        printk("v0 = %016lx  t0 = %016lx  t1 = %016lx\n",
               regs->r0, regs->r1, regs->r2);
        printk("t2 = %016lx  t3 = %016lx  t4 = %016lx\n",
@@ -132,9 +132,7 @@ dik_show_trace(unsigned long *sp)
                        continue;
                if (tmp >= (unsigned long) &_etext)
                        continue;
-               printk("[<%lx>]", tmp);
-               print_symbol(" %s", tmp);
-               printk("\n");
+               printk("[<%lx>] %pSR\n", tmp, (void *)tmp);
                if (i > 40) {
                        printk(" ...");
                        break;
@@ -1059,7 +1057,7 @@ give_sigbus:
        return;
 }
 
-void __cpuinit
+void
 trap_init(void)
 {
        /* Tell PAL-code what global pointer we want in the kernel.  */
index 8943c028d4bbe3ae2aea2875aae5c2d7e3dd2bda..df57611652e50b73322a6eaf7005598684208d4a 100644 (file)
@@ -38,6 +38,7 @@
 #include <asm/ptrace.h>
 #include <asm/processor.h>     /* For VMALLOC_START */
 #include <asm/thread_info.h>   /* For THREAD_SIZE */
+#include <asm/mmu.h>
 
 /* Note on the LD/ST addr modes with addr reg wback
  *
index ba412e02ec0c492abed190202cab324d976d0eec..43594d5116efce810798b763da8f3e7ea6891c93 100644 (file)
@@ -20,7 +20,6 @@ config ARM
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
        select HARDIRQS_SW_RESEND
-       select HAVE_AOUT
        select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
        select HAVE_ARCH_KGDB
        select HAVE_ARCH_SECCOMP_FILTER
@@ -218,7 +217,8 @@ config VECTORS_BASE
        default DRAM_BASE if REMAP_VECTORS_TO_RAM
        default 0x00000000
        help
-         The base address of exception vectors.
+         The base address of exception vectors.  This must be two pages
+         in size.
 
 config ARM_PATCH_PHYS_VIRT
        bool "Patch physical to virtual translations at runtime" if EMBEDDED
@@ -1600,8 +1600,7 @@ config LOCAL_TIMERS
 config ARCH_NR_GPIO
        int
        default 1024 if ARCH_SHMOBILE || ARCH_TEGRA
-       default 512 if SOC_OMAP5
-       default 512 if ARCH_KEYSTONE
+       default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5
        default 392 if ARCH_U8500
        default 352 if ARCH_VT8500
        default 288 if ARCH_SUNXI
index e401a766c0bdaf633f9dd14977eb231d2b2656e9..583f4a00ec3210bf6cb3cf58dac4ae7ac8a2807c 100644 (file)
@@ -804,9 +804,19 @@ config DEBUG_LL_INCLUDE
 
 config DEBUG_UNCOMPRESS
        bool
-       default y if ARCH_MULTIPLATFORM && DEBUG_LL && \
-                    !DEBUG_OMAP2PLUS_UART && \
+       depends on ARCH_MULTIPLATFORM
+       default y if DEBUG_LL && !DEBUG_OMAP2PLUS_UART && \
                     !DEBUG_TEGRA_UART
+       help
+         This option influences the normal decompressor output for
+         multiplatform kernels.  Normally, multiplatform kernels disable
+         decompressor output because it is not possible to know where to
+         send the decompressor output.
+
+         When this option is set, the selected DEBUG_LL output method
+         will be re-used for normal decompressor output on multiplatform
+         kernels.
+         
 
 config UNCOMPRESS_INCLUDE
        string
index c0ac0f5e5e5c0900c5e0e081390e0af900005738..6fd2ceae305a6a5cf6c5d2e766e4c91848b147f7 100644 (file)
@@ -153,6 +153,7 @@ machine-$(CONFIG_ARCH_DAVINCI)              += davinci
 machine-$(CONFIG_ARCH_DOVE)            += dove
 machine-$(CONFIG_ARCH_EBSA110)         += ebsa110
 machine-$(CONFIG_ARCH_EP93XX)          += ep93xx
+machine-$(CONFIG_ARCH_EXYNOS)          += exynos
 machine-$(CONFIG_ARCH_GEMINI)          += gemini
 machine-$(CONFIG_ARCH_HIGHBANK)                += highbank
 machine-$(CONFIG_ARCH_INTEGRATOR)      += integrator
@@ -160,15 +161,16 @@ machine-$(CONFIG_ARCH_IOP13XX)            += iop13xx
 machine-$(CONFIG_ARCH_IOP32X)          += iop32x
 machine-$(CONFIG_ARCH_IOP33X)          += iop33x
 machine-$(CONFIG_ARCH_IXP4XX)          += ixp4xx
+machine-$(CONFIG_ARCH_KEYSTONE)                += keystone
 machine-$(CONFIG_ARCH_KIRKWOOD)                += kirkwood
 machine-$(CONFIG_ARCH_KS8695)          += ks8695
 machine-$(CONFIG_ARCH_LPC32XX)         += lpc32xx
 machine-$(CONFIG_ARCH_MMP)             += mmp
 machine-$(CONFIG_ARCH_MSM)             += msm
 machine-$(CONFIG_ARCH_MV78XX0)         += mv78xx0
+machine-$(CONFIG_ARCH_MVEBU)           += mvebu
 machine-$(CONFIG_ARCH_MXC)             += imx
 machine-$(CONFIG_ARCH_MXS)             += mxs
-machine-$(CONFIG_ARCH_MVEBU)           += mvebu
 machine-$(CONFIG_ARCH_NETX)            += netx
 machine-$(CONFIG_ARCH_NOMADIK)         += nomadik
 machine-$(CONFIG_ARCH_NSPIRE)          += nspire
@@ -176,7 +178,6 @@ machine-$(CONFIG_ARCH_OMAP1)                += omap1
 machine-$(CONFIG_ARCH_OMAP2PLUS)       += omap2
 machine-$(CONFIG_ARCH_ORION5X)         += orion5x
 machine-$(CONFIG_ARCH_PICOXCELL)       += picoxcell
-machine-$(CONFIG_ARCH_SIRF)            += prima2
 machine-$(CONFIG_ARCH_PXA)             += pxa
 machine-$(CONFIG_ARCH_REALVIEW)                += realview
 machine-$(CONFIG_ARCH_ROCKCHIP)                += rockchip
@@ -186,25 +187,24 @@ machine-$(CONFIG_ARCH_S3C64XX)            += s3c64xx
 machine-$(CONFIG_ARCH_S5P64X0)         += s5p64x0
 machine-$(CONFIG_ARCH_S5PC100)         += s5pc100
 machine-$(CONFIG_ARCH_S5PV210)         += s5pv210
-machine-$(CONFIG_ARCH_EXYNOS)          += exynos
 machine-$(CONFIG_ARCH_SA1100)          += sa1100
 machine-$(CONFIG_ARCH_SHARK)           += shark
 machine-$(CONFIG_ARCH_SHMOBILE)        += shmobile
+machine-$(CONFIG_ARCH_SIRF)            += prima2
+machine-$(CONFIG_ARCH_SOCFPGA)         += socfpga
+machine-$(CONFIG_ARCH_STI)             += sti
+machine-$(CONFIG_ARCH_SUNXI)           += sunxi
 machine-$(CONFIG_ARCH_TEGRA)           += tegra
 machine-$(CONFIG_ARCH_U300)            += u300
 machine-$(CONFIG_ARCH_U8500)           += ux500
 machine-$(CONFIG_ARCH_VERSATILE)       += versatile
 machine-$(CONFIG_ARCH_VEXPRESS)                += vexpress
+machine-$(CONFIG_ARCH_VIRT)            += virt
 machine-$(CONFIG_ARCH_VT8500)          += vt8500
 machine-$(CONFIG_ARCH_W90X900)         += w90x900
+machine-$(CONFIG_ARCH_ZYNQ)            += zynq
 machine-$(CONFIG_FOOTBRIDGE)           += footbridge
-machine-$(CONFIG_ARCH_SOCFPGA)         += socfpga
 machine-$(CONFIG_PLAT_SPEAR)           += spear
-machine-$(CONFIG_ARCH_STI)             += sti
-machine-$(CONFIG_ARCH_VIRT)            += virt
-machine-$(CONFIG_ARCH_ZYNQ)            += zynq
-machine-$(CONFIG_ARCH_SUNXI)           += sunxi
-machine-$(CONFIG_ARCH_KEYSTONE)                += keystone
 
 # Platform directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
index d59b70c6a6a0dbadafcded2baaba38f12270aff4..3d77dbe406f4736aacb7a1d361f4f02758225aa0 100644 (file)
        compatible = "atmel,at91sam9n12ek", "atmel,at91sam9n12", "atmel,at91sam9";
 
        chosen {
-               bootargs = "mem=128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
+               bootargs = "console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
        };
 
        memory {
-               reg = <0x20000000 0x10000000>;
+               reg = <0x20000000 0x8000000>;
        };
 
        clocks {
index b753855b20584320d00c9b38c0a4c40d972a1b1b..49e3c45818c236caf750fe5f42137b963f0eb7c2 100644 (file)
@@ -94,8 +94,9 @@
 
                usb0: ohci@00600000 {
                        status = "okay";
-                       num-ports = <2>;
-                       atmel,vbus-gpio = <&pioD 19 GPIO_ACTIVE_LOW
+                       num-ports = <3>;
+                       atmel,vbus-gpio = <0 /* &pioD 18 GPIO_ACTIVE_LOW *//* Activate to have access to port A */
+                                          &pioD 19 GPIO_ACTIVE_LOW
                                           &pioD 20 GPIO_ACTIVE_LOW
                                          >;
                };
index 9866cd736deea9143ac684b3c5d5313e658ab391..a0f2721ea583bbc358452e7e415c0eadc353e2d6 100644 (file)
                                                 sirf,function = "usp0";
                                         };
                                 };
+                               usp0_uart_nostreamctrl_pins_a: usp0@1 {
+                                        usp0 {
+                                                sirf,pins = "usp0_uart_nostreamctrl_grp";
+                                                sirf,function = "usp0_uart_nostreamctrl";
+                                        };
+                                };
                                 usp1_pins_a: usp1@0 {
                                         usp1 {
                                                 sirf,pins = "usp1grp";
                                                 sirf,function = "pulse_count";
                                         };
                                 };
-                                cko0_rst_pins_a: cko0_rst@0 {
-                                        cko0_rst {
-                                                sirf,pins = "cko0_rstgrp";
-                                                sirf,function = "cko0_rst";
+                                cko0_pins_a: cko0@0 {
+                                        cko0 {
+                                                sirf,pins = "cko0grp";
+                                                sirf,function = "cko0";
                                         };
                                 };
-                                cko1_rst_pins_a: cko1_rst@0 {
-                                        cko1_rst {
-                                                sirf,pins = "cko1_rstgrp";
-                                                sirf,function = "cko1_rst";
+                                cko1_pins_a: cko1@0 {
+                                        cko1 {
+                                                sirf,pins = "cko1grp";
+                                                sirf,function = "cko1";
                                         };
                                 };
                        };
index 43bf3c796cba9cfef5d45032ebcf05b6807dcd4c..0e7fed47bd8d2941292ce8b7411036cf46883f44 100644 (file)
                                        reg = <0x0a>;
                                        VDDA-supply = <&reg_3p3v>;
                                        VDDIO-supply = <&reg_3p3v>;
-
+                                       clocks = <&saif0>;
                                };
 
                                pcf8563: rtc@51 {
index 1f0d38d7b16f5477d2f3b5ec41e6eb78e0f5068b..e035f4664b97493b2261b97b33cfbc97da8b539c 100644 (file)
                                        reg = <0x0a>;
                                        VDDA-supply = <&reg_3p3v>;
                                        VDDIO-supply = <&reg_3p3v>;
-
+                                       clocks = <&saif0>;
                                };
 
                                at24@51 {
index 880df2f13be8d761d679e980e4e756dd9e401d91..44d9da57736e637ef4fcc4a113fcef651a07d58d 100644 (file)
                                        reg = <0x0a>;
                                        VDDA-supply = <&reg_3p3v>;
                                        VDDIO-supply = <&reg_3p3v>;
-
+                                       clocks = <&saif0>;
                                };
 
                                eeprom: eeprom@51 {
index 6a8acb01b1d3ccef1b2a8c82cdacad41bf277f30..9524a05712810bba53382f2b066943cc03c7a675 100644 (file)
                                compatible = "fsl,imx28-saif";
                                reg = <0x80042000 0x2000>;
                                interrupts = <59 80>;
+                               #clock-cells = <0>;
                                clocks = <&clks 53>;
                                dmas = <&dma_apbx 4>;
                                dma-names = "rx-tx";
index 6dd9486c755ba7ac5c3f912a998c978e12602391..ad3471ca17c7aad36904f26b3f0070eac4b58d3a 100644 (file)
                mux-int-port = <2>;
                mux-ext-port = <3>;
        };
+
+       clocks {
+               clk_26M: codec_clock {
+                       compatible = "fixed-clock";
+                       reg=<0>;
+                       #clock-cells = <0>;
+                       clock-frequency = <26000000>;
+                       gpios = <&gpio4 26 1>;
+               };
+       };
 };
 
 &esdhc1 {
                                MX51_PAD_EIM_A27__GPIO2_21   0x5
                                MX51_PAD_CSPI1_SS0__GPIO4_24 0x85
                                MX51_PAD_CSPI1_SS1__GPIO4_25 0x85
+                               MX51_PAD_CSPI1_RDY__GPIO4_26 0x80000000
                        >;
                };
        };
        sgtl5000: codec@0a {
                compatible = "fsl,sgtl5000";
                reg = <0x0a>;
-               clock-frequency = <26000000>;
+               clocks = <&clk_26M>;
                VDDA-supply = <&vdig_reg>;
                VDDIO-supply = <&vvideo_reg>;
        };
index aaa33bc99f78fe6ea3877713482cc35203186868..a630902679410f9a4f356ab430a3199bf3ac852b 100644 (file)
@@ -27,7 +27,7 @@
 
        backlight {
                compatible = "pwm-backlight";
-               pwms = <&pwm2 0 50000 0 0>;
+               pwms = <&pwm2 0 50000>;
                brightness-levels = <0 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100>;
                default-brightness-level = <10>;
                enable-gpios = <&gpio7 7 0>;
index 3895fbba8fce7fff6302f9b30deb72049c24f003..569aa9f2c4eddb90736b47ea20c8a705b31e295b 100644 (file)
                                uart1 {
                                        pinctrl_uart1_1: uart1grp-1 {
                                                fsl,pins = <
-                                                       MX53_PAD_CSI0_DAT10__UART1_TXD_MUX 0x1c5
-                                                       MX53_PAD_CSI0_DAT11__UART1_RXD_MUX 0x1c5
+                                                       MX53_PAD_CSI0_DAT10__UART1_TXD_MUX 0x1e4
+                                                       MX53_PAD_CSI0_DAT11__UART1_RXD_MUX 0x1e4
                                                >;
                                        };
 
                                        pinctrl_uart1_2: uart1grp-2 {
                                                fsl,pins = <
-                                                       MX53_PAD_PATA_DIOW__UART1_TXD_MUX  0x1c5
-                                                       MX53_PAD_PATA_DMACK__UART1_RXD_MUX 0x1c5
+                                                       MX53_PAD_PATA_DIOW__UART1_TXD_MUX  0x1e4
+                                                       MX53_PAD_PATA_DMACK__UART1_RXD_MUX 0x1e4
                                                >;
                                        };
 
                                uart2 {
                                        pinctrl_uart2_1: uart2grp-1 {
                                                fsl,pins = <
-                                                       MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX 0x1c5
-                                                       MX53_PAD_PATA_DMARQ__UART2_TXD_MUX     0x1c5
+                                                       MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX 0x1e4
+                                                       MX53_PAD_PATA_DMARQ__UART2_TXD_MUX     0x1e4
                                                >;
                                        };
 
                                uart3 {
                                        pinctrl_uart3_1: uart3grp-1 {
                                                fsl,pins = <
-                                                       MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1c5
-                                                       MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1c5
-                                                       MX53_PAD_PATA_DA_1__UART3_CTS     0x1c5
-                                                       MX53_PAD_PATA_DA_2__UART3_RTS     0x1c5
+                                                       MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1e4
+                                                       MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1e4
+                                                       MX53_PAD_PATA_DA_1__UART3_CTS     0x1e4
+                                                       MX53_PAD_PATA_DA_2__UART3_RTS     0x1e4
                                                >;
                                        };
 
                                        pinctrl_uart3_2: uart3grp-2 {
                                                fsl,pins = <
-                                                       MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1c5
-                                                       MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1c5
+                                                       MX53_PAD_PATA_CS_0__UART3_TXD_MUX 0x1e4
+                                                       MX53_PAD_PATA_CS_1__UART3_RXD_MUX 0x1e4
                                                >;
                                        };
 
                                uart4 {
                                        pinctrl_uart4_1: uart4grp-1 {
                                                fsl,pins = <
-                                                       MX53_PAD_KEY_COL0__UART4_TXD_MUX 0x1c5
-                                                       MX53_PAD_KEY_ROW0__UART4_RXD_MUX 0x1c5
+                                                       MX53_PAD_KEY_COL0__UART4_TXD_MUX 0x1e4
+                                                       MX53_PAD_KEY_ROW0__UART4_RXD_MUX 0x1e4
                                                >;
                                        };
                                };
                                uart5 {
                                        pinctrl_uart5_1: uart5grp-1 {
                                                fsl,pins = <
-                                                       MX53_PAD_KEY_COL1__UART5_TXD_MUX 0x1c5
-                                                       MX53_PAD_KEY_ROW1__UART5_RXD_MUX 0x1c5
+                                                       MX53_PAD_KEY_COL1__UART5_TXD_MUX 0x1e4
+                                                       MX53_PAD_KEY_ROW1__UART5_RXD_MUX 0x1e4
                                                >;
                                        };
                                };
index db2060c465404d81faab3cd8d2c8427588c1354f..9c1167b0459b6b3e4afd9f2a7e60f1f2f8584e1a 100644 (file)
@@ -26,7 +26,7 @@
                cpu-offset = <0x80000>;
        };
 
-       msmgpio: gpio@fd510000 {
+       msmgpio: gpio@800000 {
                compatible = "qcom,msm-gpio";
                gpio-controller;
                #gpio-cells = <2>;
@@ -34,7 +34,7 @@
                interrupts = <0 32 0x4>;
                interrupt-controller;
                #interrupt-cells = <2>;
-               reg = <0xfd510000 0x4000>;
+               reg = <0x800000 0x4000>;
        };
 
        serial@16440000 {
index 08b72678abff0cc4dbd9058fb95bf26c4b779b01..65d7b601651c390f78272602c79d6fb3b172ce4f 100644 (file)
 };
 
 &mmc1 {
-       vmmc-supply = <&vmmcsd_fixed>;
+       vmmc-supply = <&ldo9_reg>;
        bus-width = <4>;
 };
 
 
                        regulators {
                                smps123_reg: smps123 {
+                                       /* VDD_OPP_MPU */
                                        regulator-name = "smps123";
                                        regulator-min-microvolt = < 600000>;
                                        regulator-max-microvolt = <1500000>;
                                };
 
                                smps45_reg: smps45 {
+                                       /* VDD_OPP_MM */
                                        regulator-name = "smps45";
                                        regulator-min-microvolt = < 600000>;
                                        regulator-max-microvolt = <1310000>;
                                };
 
                                smps6_reg: smps6 {
+                                       /* VDD_DDR3 - over VDD_SMPS6 */
                                        regulator-name = "smps6";
                                        regulator-min-microvolt = <1200000>;
                                        regulator-max-microvolt = <1200000>;
                                };
 
                                smps7_reg: smps7 {
+                                       /* VDDS_1v8_OMAP over VDDS_1v8_MAIN */
                                        regulator-name = "smps7";
                                        regulator-min-microvolt = <1800000>;
                                        regulator-max-microvolt = <1800000>;
                                };
 
                                smps8_reg: smps8 {
+                                       /* VDD_OPP_CORE */
                                        regulator-name = "smps8";
                                        regulator-min-microvolt = < 600000>;
                                        regulator-max-microvolt = <1310000>;
                                };
 
                                smps9_reg: smps9 {
+                                       /* VDDA_2v1_AUD over VDD_2v1 */
                                        regulator-name = "smps9";
                                        regulator-min-microvolt = <2100000>;
                                        regulator-max-microvolt = <2100000>;
-                                       regulator-always-on;
-                                       regulator-boot-on;
                                        ti,smps-range = <0x80>;
                                };
 
                                smps10_reg: smps10 {
+                                       /* VBUS_5V_OTG */
                                        regulator-name = "smps10";
                                        regulator-min-microvolt = <5000000>;
                                        regulator-max-microvolt = <5000000>;
                                };
 
                                ldo1_reg: ldo1 {
+                                       /* VDDAPHY_CAM: vdda_csiport */
                                        regulator-name = "ldo1";
-                                       regulator-min-microvolt = <2800000>;
-                                       regulator-max-microvolt = <2800000>;
-                                       regulator-always-on;
-                                       regulator-boot-on;
+                                       regulator-min-microvolt = <1500000>;
+                                       regulator-max-microvolt = <1800000>;
                                };
 
                                ldo2_reg: ldo2 {
+                                       /* VCC_2V8_DISP: Does not go anywhere */
                                        regulator-name = "ldo2";
-                                       regulator-min-microvolt = <2900000>;
-                                       regulator-max-microvolt = <2900000>;
-                                       regulator-always-on;
-                                       regulator-boot-on;
+                                       regulator-min-microvolt = <2800000>;
+                                       regulator-max-microvolt = <2800000>;
+                                       /* Unused */
+                                       status = "disabled";
                                };
 
                                ldo3_reg: ldo3 {
+                                       /* VDDAPHY_MDM: vdda_lli */
                                        regulator-name = "ldo3";
-                                       regulator-min-microvolt = <3000000>;
-                                       regulator-max-microvolt = <3000000>;
-                                       regulator-always-on;
+                                       regulator-min-microvolt = <1500000>;
+                                       regulator-max-microvolt = <1500000>;
                                        regulator-boot-on;
+                                       /* Only if Modem is used */
+                                       status = "disabled";
                                };
 
                                ldo4_reg: ldo4 {
+                                       /* VDDAPHY_DISP: vdda_dsiport/hdmi */
                                        regulator-name = "ldo4";
-                                       regulator-min-microvolt = <2200000>;
-                                       regulator-max-microvolt = <2200000>;
-                                       regulator-always-on;
-                                       regulator-boot-on;
+                                       regulator-min-microvolt = <1500000>;
+                                       regulator-max-microvolt = <1800000>;
                                };
 
                                ldo5_reg: ldo5 {
+                                       /* VDDA_1V8_PHY: usb/sata/hdmi.. */
                                        regulator-name = "ldo5";
                                        regulator-min-microvolt = <1800000>;
                                        regulator-max-microvolt = <1800000>;
                                };
 
                                ldo6_reg: ldo6 {
+                                       /* VDDS_1V2_WKUP: hsic/ldo_emu_wkup */
                                        regulator-name = "ldo6";
-                                       regulator-min-microvolt = <1500000>;
-                                       regulator-max-microvolt = <1500000>;
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
                                        regulator-always-on;
                                        regulator-boot-on;
                                };
 
                                ldo7_reg: ldo7 {
+                                       /* VDD_VPP: vpp1 */
                                        regulator-name = "ldo7";
-                                       regulator-min-microvolt = <1500000>;
-                                       regulator-max-microvolt = <1500000>;
-                                       regulator-always-on;
-                                       regulator-boot-on;
+                                       regulator-min-microvolt = <2000000>;
+                                       regulator-max-microvolt = <2000000>;
+                                       /* Only for efuse reprograming! */
+                                       status = "disabled";
                                };
 
                                ldo8_reg: ldo8 {
+                                       /* VDD_3v0: Does not go anywhere */
                                        regulator-name = "ldo8";
-                                       regulator-min-microvolt = <1500000>;
-                                       regulator-max-microvolt = <1500000>;
-                                       regulator-always-on;
+                                       regulator-min-microvolt = <3000000>;
+                                       regulator-max-microvolt = <3000000>;
                                        regulator-boot-on;
+                                       /* Unused */
+                                       status = "disabled";
                                };
 
                                ldo9_reg: ldo9 {
+                                       /* VCC_DV_SDIO: vdds_sdcard */
                                        regulator-name = "ldo9";
                                        regulator-min-microvolt = <1800000>;
-                                       regulator-max-microvolt = <3300000>;
-                                       regulator-always-on;
+                                       regulator-max-microvolt = <3000000>;
                                        regulator-boot-on;
                                };
 
                                ldoln_reg: ldoln {
+                                       /* VDDA_1v8_REF: vdds_osc/mm_l4per.. */
                                        regulator-name = "ldoln";
                                        regulator-min-microvolt = <1800000>;
                                        regulator-max-microvolt = <1800000>;
                                };
 
                                ldousb_reg: ldousb {
+                                       /* VDDA_3V_USB: VDDA_USBHS33 */
                                        regulator-name = "ldousb";
                                        regulator-min-microvolt = <3250000>;
                                        regulator-max-microvolt = <3250000>;
                                        regulator-always-on;
                                        regulator-boot-on;
                                };
+
+                               regen3_reg: regen3 {
+                                       /* REGEN3 controls LDO9 supply to card */
+                                       regulator-name = "regen3";
+                                       regulator-always-on;
+                                       regulator-boot-on;
+                               };
                        };
                };
        };
index 05e9489cf95c835f4442e90fb47fd3eb92900e79..bbeb623fc2c6f82dc9f92b1c77a90811946f9736 100644 (file)
                                                 sirf,function = "pulse_count";
                                         };
                                 };
-                                cko0_rst_pins_a: cko0_rst@0 {
-                                        cko0_rst {
-                                                sirf,pins = "cko0_rstgrp";
-                                                sirf,function = "cko0_rst";
+                                cko0_pins_a: cko0@0 {
+                                        cko0 {
+                                                sirf,pins = "cko0grp";
+                                                sirf,function = "cko0";
                                         };
                                 };
-                                cko1_rst_pins_a: cko1_rst@0 {
-                                        cko1_rst {
-                                                sirf,pins = "cko1_rstgrp";
-                                                sirf,function = "cko1_rst";
+                                cko1_pins_a: cko1@0 {
+                                        cko1 {
+                                                sirf,pins = "cko1grp";
+                                                sirf,function = "cko1";
                                         };
                                 };
                        };
index 8a9e05d8a4b87dc870bb293eb7b65c26f0241b19..e9521d58e9c11b8d6ed31119656514bfd52748fb 100644 (file)
 
                        macb1: ethernet@f802c000 {
                                phy-mode = "rmii";
+
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               phy0: ethernet-phy@0 {
+                                       interrupt-parent = <&pioE>;
+                                       interrupts = <30 IRQ_TYPE_EDGE_FALLING>;
+                                       reg = <1>;
+                               };
                        };
 
                        pinctrl@fffff200 {
index 957b21a71b4b7f24267908afe8aae4279eaa3c48..0f246c979262d3c39676576fdde4c2797cb0d118 100644 (file)
                                reg             = <0x9000 0x100>;
                                st,bank-name    = "PIO31";
                        };
+
+                       serial2-oe {
+                               pinctrl_serial2_oe: serial2-1 {
+                                       st,pins {
+                                               output-enable   = <&PIO11 3 ALT2 OUT>;
+                                       };
+                               };
+                       };
+
                };
 
                pin-controller-rear {
                                        st,pins {
                                                tx      = <&PIO17 4 ALT2 OUT>;
                                                rx      = <&PIO17 5 ALT2 IN>;
-                                               output-enable   = <&PIO11 3 ALT2 OUT>;
                                        };
                                };
                        };
index 3cecd9689a4999927d60aeb1f320dafed99d0965..1a0326ea7d070ad762d6f83719aa0fcc29a98dd2 100644 (file)
@@ -79,7 +79,7 @@
                        interrupts      = <0 197 0>;
                        clocks          = <&CLK_S_ICN_REG_0>;
                        pinctrl-names   = "default";
-                       pinctrl-0       = <&pinctrl_serial2>;
+                       pinctrl-0       = <&pinctrl_serial2 &pinctrl_serial2_oe>;
                };
 
                /* SBC_UART1 */
index 7321403cab8a2eaf6811bc93c8ee78b181afbe08..f5b9898d9c6e60330417abc3cfad494d27474d75 100644 (file)
@@ -6,10 +6,12 @@
                #address-cells = <1>;
                #size-cells = <0>;
                cpu@0 {
+                       device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
                };
                cpu@1 {
+                       device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <1>;
                };
index 2fcb3f2ca160411f12575672e0cdd68319605865..5592be6f2f7a7ad58cf9eb3cf0cd17cd38e207f8 100644 (file)
        };
 
        usb-phy@c5004000 {
+               status = "okay";
                nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1)
                        GPIO_ACTIVE_LOW>;
        };
index 365760b33a26e1ea9ac7bae3a7c32f7f4bde9878..40e6fb280333ec190864a0c3ef55ba6007371ac4 100644 (file)
                        regulator-max-microvolt = <5000000>;
                        enable-active-high;
                        gpio = <&gpio 24 0>; /* PD0 */
+                       regulator-always-on;
+                       regulator-boot-on;
                };
        };
 
index ed4b901b0227405f3cd687f1a832cad4db808f22..37c93d3c4812ec65d9ef7689bb173757d37d9060 100644 (file)
                        regulator-max-microvolt = <5000000>;
                        enable-active-high;
                        gpio = <&gpio 170 0>; /* PV2 */
+                       regulator-always-on;
+                       regulator-boot-on;
                };
        };
 
index ab67c94db280cebb2fc8c5e7126977a3fee8fb40..a3d0ebad78a1137eca61fea4781a178af0d516cc 100644 (file)
                        regulator-max-microvolt = <5000000>;
                        enable-active-high;
                        gpio = <&tca6416 0 0>; /* GPIO_PMU0 */
+                       regulator-always-on;
+                       regulator-boot-on;
                };
 
                vbus3_reg: regulator@3 {
                        regulator-max-microvolt = <5000000>;
                        enable-active-high;
                        gpio = <&tca6416 1 0>; /* GPIO_PMU1 */
+                       regulator-always-on;
+                       regulator-boot-on;
                };
        };
 
index b3034da00a37bfe6a5361420bc2fb8d99101fb5a..ae6a17aed9ee224c85498b2bc6b1e0fa43e75e56 100644 (file)
                regulator-max-microvolt = <3150000>;
        };
 
+       vmmc2: regulator-vmmc2 {
+               compatible = "ti,twl4030-vmmc2";
+               regulator-min-microvolt = <1850000>;
+               regulator-max-microvolt = <3150000>;
+       };
+
        vusb1v5: regulator-vusb1v5 {
                compatible = "ti,twl4030-vusb1v5";
        };
index e1eb7dadda80a56255c63d1a646885f41115d6e0..67d929cf98045235a1a39eeeb7c884c2b2bccddc 100644 (file)
                                compatible = "fsl,mvf600-fec";
                                reg = <0x400d0000 0x1000>;
                                interrupts = <0 78 0x04>;
-                               clocks = <&clks VF610_CLK_ENET>,
-                                       <&clks VF610_CLK_ENET>,
+                               clocks = <&clks VF610_CLK_ENET0>,
+                                       <&clks VF610_CLK_ENET0>,
                                        <&clks VF610_CLK_ENET>;
                                clock-names = "ipg", "ahb", "ptp";
                                status = "disabled";
                                compatible = "fsl,mvf600-fec";
                                reg = <0x400d1000 0x1000>;
                                interrupts = <0 79 0x04>;
-                               clocks = <&clks VF610_CLK_ENET>,
-                                       <&clks VF610_CLK_ENET>,
+                               clocks = <&clks VF610_CLK_ENET1>,
+                                       <&clks VF610_CLK_ENET1>,
                                        <&clks VF610_CLK_ENET>;
                                clock-names = "ipg", "ahb", "ptp";
                                status = "disabled";
index a432e6c1dac18fdf33d1b5d85bfb6c1b7e6cfed0..39ad030ac0c72b529b9cf3166a003b9feaa1f879 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/edma.h>
-#include <linux/err.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/of_dma.h>
index 510e5b13aa2e2a4e65c01de1ce9a82635b01bce4..1bc34c7567fdf890a5eea685c04d70f7de89ffbf 100644 (file)
@@ -19,7 +19,7 @@
 #include <asm/smp.h>
 #include <asm/smp_plat.h>
 
-static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int mcpm_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned int mpidr, pcpu, pcluster, ret;
        extern void secondary_startup(void);
@@ -40,7 +40,7 @@ static int __cpuinit mcpm_boot_secondary(unsigned int cpu, struct task_struct *i
        return 0;
 }
 
-static void __cpuinit mcpm_secondary_init(unsigned int cpu)
+static void mcpm_secondary_init(unsigned int cpu)
 {
        mcpm_cpu_powered_up();
 }
index 7c868139bdb0dd42e9b97d34b794d6cabe83dc64..1571bea48bed12b6702ea9d1e09deb7cffb803cf 100644 (file)
@@ -102,6 +102,8 @@ CONFIG_SND_SOC=m
 CONFIG_SND_DAVINCI_SOC=m
 # CONFIG_HID_SUPPORT is not set
 # CONFIG_USB_SUPPORT is not set
+CONFIG_DMADEVICES=y
+CONFIG_TI_EDMA=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 CONFIG_XFS_FS=m
index c86fd75e181ab003df201b1966f22594c2d24013..ab2f7378352c7e1861bac50cf4a21527a7d9564c 100644 (file)
@@ -162,6 +162,8 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 CONFIG_RTC_CLASS=y
+CONFIG_DMADEVICES=y
+CONFIG_TI_EDMA=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 CONFIG_XFS_FS=m
index fe0bdc361d2c2fea4ebf5a274415683e07445d1a..6e572c64cf5a1258008232a002301ab7925b0911 100644 (file)
@@ -53,6 +53,7 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_OMAP_OCP2SCP=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_ATA=y
 CONFIG_SATA_AHCI_PLATFORM=y
@@ -61,6 +62,7 @@ CONFIG_SATA_MV=y
 CONFIG_NETDEVICES=y
 CONFIG_SUN4I_EMAC=y
 CONFIG_NET_CALXEDA_XGMAC=y
+CONFIG_KS8851=y
 CONFIG_SMSC911X=y
 CONFIG_STMMAC_ETH=y
 CONFIG_MDIO_SUN4I=y
@@ -89,6 +91,7 @@ CONFIG_I2C_DESIGNWARE_PLATFORM=y
 CONFIG_I2C_SIRF=y
 CONFIG_I2C_TEGRA=y
 CONFIG_SPI=y
+CONFIG_SPI_OMAP24XX=y
 CONFIG_SPI_PL022=y
 CONFIG_SPI_SIRF=y
 CONFIG_SPI_TEGRA114=y
@@ -111,11 +114,12 @@ CONFIG_FB_SIMPLE=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
-CONFIG_USB_EHCI_MXC=y
 CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
 CONFIG_USB_ISP1760_HCD=y
 CONFIG_USB_STORAGE=y
+CONFIG_USB_CHIPIDEA=y
+CONFIG_USB_CHIPIDEA_HOST=y
 CONFIG_AB8500_USB=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_OMAP_USB2=y
index 35f8cf299fa2186f0f27ab42470dbd582f55d6f6..263ae3869e32c5f9ecf8bc2f2fd63b8ce8291eda 100644 (file)
@@ -1,6 +1,8 @@
 # CONFIG_LOCALVERSION_AUTO is not set
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
+CONFIG_NO_HZ_IDLE=y
+CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
@@ -48,7 +50,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_MTD=y
 CONFIG_MTD_TESTS=m
 CONFIG_MTD_CMDLINE_PARTS=y
-CONFIG_MTD_CHAR=y
 CONFIG_MTD_BLOCK=y
 CONFIG_MTD_NAND_ECC_SMC=y
 CONFIG_MTD_NAND=y
@@ -94,8 +95,10 @@ CONFIG_I2C_GPIO=y
 CONFIG_I2C_NOMADIK=y
 CONFIG_DEBUG_GPIO=y
 # CONFIG_HWMON is not set
+CONFIG_REGULATOR=y
 CONFIG_MMC=y
-CONFIG_MMC_CLKGATE=y
+CONFIG_MMC_UNSAFE_RESUME=y
+# CONFIG_MMC_BLOCK_BOUNCE is not set
 CONFIG_MMC_ARMMMCI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
diff --git a/arch/arm/include/asm/a.out-core.h b/arch/arm/include/asm/a.out-core.h
deleted file mode 100644 (file)
index 92f10cb..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/* a.out coredump register dumper
- *
- * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public Licence
- * as published by the Free Software Foundation; either version
- * 2 of the Licence, or (at your option) any later version.
- */
-
-#ifndef _ASM_A_OUT_CORE_H
-#define _ASM_A_OUT_CORE_H
-
-#ifdef __KERNEL__
-
-#include <linux/user.h>
-#include <linux/elfcore.h>
-
-/*
- * fill in the user structure for an a.out core dump
- */
-static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
-{
-       struct task_struct *tsk = current;
-
-       dump->magic = CMAGIC;
-       dump->start_code = tsk->mm->start_code;
-       dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1);
-
-       dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT;
-       dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       dump->u_ssize = 0;
-
-       memset(dump->u_debugreg, 0, sizeof(dump->u_debugreg));
-
-       if (dump->start_stack < 0x04000000)
-               dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT;
-
-       dump->regs = *regs;
-       dump->u_fpvalid = dump_fpu (regs, &dump->u_fp);
-}
-
-#endif /* __KERNEL__ */
-#endif /* _ASM_A_OUT_CORE_H */
index accefe0991828e2984c5c1ff49b25dece76edcc0..e406d575c94f500f962888a5240b64d6bfcecfb5 100644 (file)
@@ -89,7 +89,7 @@ static inline u64 arch_counter_get_cntvct(void)
        return cval;
 }
 
-static inline void __cpuinit arch_counter_set_user_access(void)
+static inline void arch_counter_set_user_access(void)
 {
        u32 cntkctl;
 
index 8c25dc4e98514d85db8ce77f4d9e7fa8f828262d..9672e978d50df67d94c3dd86d23f3bcdd187c54d 100644 (file)
@@ -89,13 +89,18 @@ extern unsigned int processor_id;
                __val;                                                  \
        })
 
+/*
+ * The memory clobber prevents gcc 4.5 from reordering the mrc before
+ * any is_smp() tests, which can cause undefined instruction aborts on
+ * ARM1136 r0 due to the missing extended CP15 registers.
+ */
 #define read_cpuid_ext(ext_reg)                                                \
        ({                                                              \
                unsigned int __val;                                     \
                asm("mrc        p15, 0, %0, c0, " ext_reg               \
                    : "=r" (__val)                                      \
                    :                                                   \
-                   : "cc");                                            \
+                   : "memory");                                        \
                __val;                                                  \
        })
 
index 38050b1c4800b90b190a415b7d173e9948e20b97..56211f2084ef871841215a0c4adfec6f778689d3 100644 (file)
@@ -130,4 +130,10 @@ struct mm_struct;
 extern unsigned long arch_randomize_brk(struct mm_struct *mm);
 #define arch_randomize_brk arch_randomize_brk
 
+#ifdef CONFIG_MMU
+#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
+struct linux_binprm;
+int arch_setup_additional_pages(struct linux_binprm *, int);
+#endif
+
 #endif
index e3d55547e75592a9eb98fa1704ee8df9e872c2c5..6f18da09668b5f324ad8c32e6fd6058e5b837e2a 100644 (file)
@@ -6,8 +6,11 @@
 typedef struct {
 #ifdef CONFIG_CPU_HAS_ASID
        atomic64_t      id;
+#else
+       int             switch_pending;
 #endif
        unsigned int    vmalloc_seq;
+       unsigned long   sigpage;
 } mm_context_t;
 
 #ifdef CONFIG_CPU_HAS_ASID
index b5792b7fd8d3149c94c87f5650410b3ece3a2bd2..9b32f76bb0ddaa6d6e485d79cc9f2bdfeb24d776 100644 (file)
@@ -56,7 +56,7 @@ static inline void check_and_switch_context(struct mm_struct *mm,
                 * on non-ASID CPUs, the old mm will remain valid until the
                 * finish_arch_post_lock_switch() call.
                 */
-               set_ti_thread_flag(task_thread_info(tsk), TIF_SWITCH_MM);
+               mm->context.switch_pending = 1;
        else
                cpu_switch_mm(mm->pgd, mm);
 }
@@ -65,9 +65,21 @@ static inline void check_and_switch_context(struct mm_struct *mm,
        finish_arch_post_lock_switch
 static inline void finish_arch_post_lock_switch(void)
 {
-       if (test_and_clear_thread_flag(TIF_SWITCH_MM)) {
-               struct mm_struct *mm = current->mm;
-               cpu_switch_mm(mm->pgd, mm);
+       struct mm_struct *mm = current->mm;
+
+       if (mm && mm->context.switch_pending) {
+               /*
+                * Preemption must be disabled during cpu_switch_mm() as we
+                * have some stateful cache flush implementations. Check
+                * switch_pending again in case we were preempted and the
+                * switch to this mm was already done.
+                */
+               preempt_disable();
+               if (mm->context.switch_pending) {
+                       mm->context.switch_pending = 0;
+                       cpu_switch_mm(mm->pgd, mm);
+               }
+               preempt_enable_no_resched();
        }
 }
 
index 6363f3d1d505292c57a26fbd3585b3f147738771..4355f0ec44d62e9b5d7c40132f28f0ff6710f387 100644 (file)
@@ -142,7 +142,9 @@ extern void __cpu_copy_user_highpage(struct page *to, struct page *from,
 #define clear_page(page)       memset((void *)(page), 0, PAGE_SIZE)
 extern void copy_page(void *to, const void *from);
 
+#ifdef CONFIG_KUSER_HELPERS
 #define __HAVE_ARCH_GATE_AREA 1
+#endif
 
 #ifdef CONFIG_ARM_LPAE
 #include <asm/pgtable-3level-types.h>
index 06e7d509eaac218864cc9d089ce9e6f4177c22f9..413f3876341cd6fd2e7bc4b1c6a71873cadaa887 100644 (file)
@@ -54,7 +54,6 @@ struct thread_struct {
 
 #define start_thread(regs,pc,sp)                                       \
 ({                                                                     \
-       unsigned long *stack = (unsigned long *)sp;                     \
        memset(regs->uregs, 0, sizeof(regs->uregs));                    \
        if (current->personality & ADDR_LIMIT_32BIT)                    \
                regs->ARM_cpsr = USR_MODE;                              \
@@ -65,9 +64,6 @@ struct thread_struct {
        regs->ARM_cpsr |= PSR_ENDSTATE;                                 \
        regs->ARM_pc = pc & ~1;         /* pc */                        \
        regs->ARM_sp = sp;              /* sp */                        \
-       regs->ARM_r2 = stack[2];        /* r2 (envp) */                 \
-       regs->ARM_r1 = stack[1];        /* r1 (argv) */                 \
-       regs->ARM_r0 = stack[0];        /* r0 (argc) */                 \
        nommu_start_thread(regs);                                       \
 })
 
index 6462a721ebd4cc52105fec3e8f6970614ca1d82e..a252c0bfacf50e5adb09d339e42ed0bedfd1ac08 100644 (file)
@@ -88,4 +88,7 @@ static inline u32 mpidr_hash_size(void)
 {
        return 1 << mpidr_hash.bits;
 }
+
+extern int platform_can_cpu_hotplug(void);
+
 #endif
index f8b8965666e9b14842786742f48ccdef49000802..b07c09e5a0ac86c6ddd5f7bc9ba25425c784e147 100644 (file)
@@ -107,7 +107,7 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
                "       subs    %1, %0, %0, ror #16\n"
                "       addeq   %0, %0, %4\n"
                "       strexeq %2, %0, [%3]"
-               : "=&r" (slock), "=&r" (contended), "=r" (res)
+               : "=&r" (slock), "=&r" (contended), "=&r" (res)
                : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
                : "cc");
        } while (res);
@@ -168,17 +168,20 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
 
 static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
-       unsigned long tmp;
+       unsigned long contended, res;
 
-       __asm__ __volatile__(
-"      ldrex   %0, [%1]\n"
-"      teq     %0, #0\n"
-"      strexeq %0, %2, [%1]"
-       : "=&r" (tmp)
-       : "r" (&rw->lock), "r" (0x80000000)
-       : "cc");
+       do {
+               __asm__ __volatile__(
+               "       ldrex   %0, [%2]\n"
+               "       mov     %1, #0\n"
+               "       teq     %0, #0\n"
+               "       strexeq %1, %3, [%2]"
+               : "=&r" (contended), "=&r" (res)
+               : "r" (&rw->lock), "r" (0x80000000)
+               : "cc");
+       } while (res);
 
-       if (tmp == 0) {
+       if (!contended) {
                smp_mb();
                return 1;
        } else {
@@ -254,18 +257,26 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
 
 static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
-       unsigned long tmp, tmp2 = 1;
+       unsigned long contended, res;
 
-       __asm__ __volatile__(
-"      ldrex   %0, [%2]\n"
-"      adds    %0, %0, #1\n"
-"      strexpl %1, %0, [%2]\n"
-       : "=&r" (tmp), "+r" (tmp2)
-       : "r" (&rw->lock)
-       : "cc");
+       do {
+               __asm__ __volatile__(
+               "       ldrex   %0, [%2]\n"
+               "       mov     %1, #0\n"
+               "       adds    %0, %0, #1\n"
+               "       strexpl %1, %0, [%2]"
+               : "=&r" (contended), "=&r" (res)
+               : "r" (&rw->lock)
+               : "cc");
+       } while (res);
 
-       smp_mb();
-       return tmp2 == 0;
+       /* If the lock is negative, then it is already held for write. */
+       if (contended < 0x80000000) {
+               smp_mb();
+               return 1;
+       } else {
+               return 0;
+       }
 }
 
 /* read_can_lock - would read_trylock() succeed? */
index 214d4158089afce9c04102604fe07c5257c454e5..2b8114fcba09a3c5b9d6aceefbc6e456a8c9050a 100644 (file)
@@ -156,7 +156,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
 #define TIF_USING_IWMMXT       17
 #define TIF_MEMDIE             18      /* is terminating due to OOM killer */
 #define TIF_RESTORE_SIGMASK    20
-#define TIF_SWITCH_MM          22      /* deferred switch_mm */
 
 #define _TIF_SIGPENDING                (1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED      (1 << TIF_NEED_RESCHED)
index 46e7cfb3e7219d2ac4db9013d5dc673c155167ed..0baf7f0d939484264b089c772112657cb9f15c75 100644 (file)
@@ -43,6 +43,7 @@ struct mmu_gather {
        struct mm_struct        *mm;
        unsigned int            fullmm;
        struct vm_area_struct   *vma;
+       unsigned long           start, end;
        unsigned long           range_start;
        unsigned long           range_end;
        unsigned int            nr;
@@ -107,10 +108,12 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int fullmm)
+tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
-       tlb->fullmm = fullmm;
+       tlb->fullmm = !(start | (end+1));
+       tlb->start = start;
+       tlb->end = end;
        tlb->vma = NULL;
        tlb->max = ARRAY_SIZE(tlb->local);
        tlb->pages = tlb->local;
index fdbb9e369745c4b09d776a4568caa52702b7e9a7..f467e9b3f8d5d5b35c1d6fce386c718eb1b21e8f 100644 (file)
@@ -443,7 +443,18 @@ static inline void local_flush_bp_all(void)
                isb();
 }
 
+#include <asm/cputype.h>
 #ifdef CONFIG_ARM_ERRATA_798181
+static inline int erratum_a15_798181(void)
+{
+       unsigned int midr = read_cpuid_id();
+
+       /* Cortex-A15 r0p0..r3p2 affected */
+       if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
+               return 0;
+       return 1;
+}
+
 static inline void dummy_flush_tlb_a15_erratum(void)
 {
        /*
@@ -453,6 +464,11 @@ static inline void dummy_flush_tlb_a15_erratum(void)
        dsb();
 }
 #else
+static inline int erratum_a15_798181(void)
+{
+       return 0;
+}
+
 static inline void dummy_flush_tlb_a15_erratum(void)
 {
 }
index 50af92bac7373eb7fbc01c8f38c4d7dfd6ccb05d..4371f45c578401c7f233e565dbb5fd36d9d59d52 100644 (file)
@@ -29,6 +29,7 @@
 #define BOOT_CPU_MODE_MISMATCH PSR_N_BIT
 
 #ifndef __ASSEMBLY__
+#include <asm/cacheflush.h>
 
 #ifdef CONFIG_ARM_VIRT_EXT
 /*
  */
 extern int __boot_cpu_mode;
 
+static inline void sync_boot_mode(void)
+{
+       /*
+        * As secondaries write to __boot_cpu_mode with caches disabled, we
+        * must flush the corresponding cache entries to ensure the visibility
+        * of their writes.
+        */
+       sync_cache_r(&__boot_cpu_mode);
+}
+
 void __hyp_set_vectors(unsigned long phys_vector_base);
 unsigned long __hyp_get_vectors(void);
 #else
 #define __boot_cpu_mode        (SVC_MODE)
+#define sync_boot_mode()
 #endif
 
 #ifndef ZIMAGE
index 47bcb2d254af8e4fdb3bacee96131d88a0e4f37e..18d76fd5a2afb2bf27b91980f29c77094e6638c0 100644 (file)
@@ -1,7 +1,6 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
 
-header-y += a.out.h
 header-y += byteorder.h
 header-y += fcntl.h
 header-y += hwcap.h
diff --git a/arch/arm/include/uapi/asm/a.out.h b/arch/arm/include/uapi/asm/a.out.h
deleted file mode 100644 (file)
index 083894b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __ARM_A_OUT_H__
-#define __ARM_A_OUT_H__
-
-#include <linux/personality.h>
-#include <linux/types.h>
-
-struct exec
-{
-  __u32 a_info;                /* Use macros N_MAGIC, etc for access */
-  __u32 a_text;                /* length of text, in bytes */
-  __u32 a_data;                /* length of data, in bytes */
-  __u32 a_bss;         /* length of uninitialized data area for file, in bytes */
-  __u32 a_syms;                /* length of symbol table data in file, in bytes */
-  __u32 a_entry;       /* start address */
-  __u32 a_trsize;      /* length of relocation info for text, in bytes */
-  __u32 a_drsize;      /* length of relocation info for data, in bytes */
-};
-
-/*
- * This is always the same
- */
-#define N_TXTADDR(a)   (0x00008000)
-
-#define N_TRSIZE(a)    ((a).a_trsize)
-#define N_DRSIZE(a)    ((a).a_drsize)
-#define N_SYMSIZE(a)   ((a).a_syms)
-
-#define M_ARM 103
-
-#ifndef LIBRARY_START_TEXT
-#define LIBRARY_START_TEXT     (0x00c00000)
-#endif
-
-#endif /* __A_OUT_GNU_H__ */
index a39cfc2a1f905f7a4e09d9db8810dcd4ce8ac995..9cbe70c8b0ef7b8d16a806602608fba205966d31 100644 (file)
@@ -357,7 +357,8 @@ ENDPROC(__pabt_svc)
        .endm
 
        .macro  kuser_cmpxchg_check
-#if !defined(CONFIG_CPU_32v6K) && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
+#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \
+    !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
 #ifndef CONFIG_MMU
 #warning "NPTL on non MMU needs fixing"
 #else
@@ -742,6 +743,18 @@ ENDPROC(__switch_to)
 #endif
        .endm
 
+       .macro  kuser_pad, sym, size
+       .if     (. - \sym) & 3
+       .rept   4 - (. - \sym) & 3
+       .byte   0
+       .endr
+       .endif
+       .rept   (\size - (. - \sym)) / 4
+       .word   0xe7fddef1
+       .endr
+       .endm
+
+#ifdef CONFIG_KUSER_HELPERS
        .align  5
        .globl  __kuser_helper_start
 __kuser_helper_start:
@@ -832,18 +845,13 @@ kuser_cmpxchg64_fixup:
 #error "incoherent kernel configuration"
 #endif
 
-       /* pad to next slot */
-       .rept   (16 - (. - __kuser_cmpxchg64)/4)
-       .word   0
-       .endr
-
-       .align  5
+       kuser_pad __kuser_cmpxchg64, 64
 
 __kuser_memory_barrier:                                @ 0xffff0fa0
        smp_dmb arm
        usr_ret lr
 
-       .align  5
+       kuser_pad __kuser_memory_barrier, 32
 
 __kuser_cmpxchg:                               @ 0xffff0fc0
 
@@ -916,13 +924,14 @@ kuser_cmpxchg32_fixup:
 
 #endif
 
-       .align  5
+       kuser_pad __kuser_cmpxchg, 32
 
 __kuser_get_tls:                               @ 0xffff0fe0
        ldr     r0, [pc, #(16 - 8)]     @ read TLS, set in kuser_get_tls_init
        usr_ret lr
        mrc     p15, 0, r0, c13, c0, 3  @ 0xffff0fe8 hardware TLS code
-       .rep    4
+       kuser_pad __kuser_get_tls, 16
+       .rep    3
        .word   0                       @ 0xffff0ff0 software TLS value, then
        .endr                           @ pad up to __kuser_helper_version
 
@@ -932,14 +941,16 @@ __kuser_helper_version:                           @ 0xffff0ffc
        .globl  __kuser_helper_end
 __kuser_helper_end:
 
+#endif
+
  THUMB(        .thumb  )
 
 /*
  * Vector stubs.
  *
- * This code is copied to 0xffff0200 so we can use branches in the
- * vectors, rather than ldr's.  Note that this code must not
- * exceed 0x300 bytes.
+ * This code is copied to 0xffff1000 so we can use branches in the
+ * vectors, rather than ldr's.  Note that this code must not exceed
+ * a page size.
  *
  * Common stub entry macro:
  *   Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
@@ -986,8 +997,17 @@ ENDPROC(vector_\name)
 1:
        .endm
 
-       .globl  __stubs_start
+       .section .stubs, "ax", %progbits
 __stubs_start:
+       @ This must be the first word
+       .word   vector_swi
+
+vector_rst:
+ ARM(  swi     SYS_ERROR0      )
+ THUMB(        svc     #0              )
+ THUMB(        nop                     )
+       b       vector_und
+
 /*
  * Interrupt dispatcher
  */
@@ -1081,6 +1101,16 @@ __stubs_start:
 
        .align  5
 
+/*=============================================================================
+ * Address exception handler
+ *-----------------------------------------------------------------------------
+ * These aren't too critical.
+ * (they're not supposed to happen, and won't happen in 32-bit data mode).
+ */
+
+vector_addrexcptn:
+       b       vector_addrexcptn
+
 /*=============================================================================
  * Undefined FIQs
  *-----------------------------------------------------------------------------
@@ -1094,45 +1124,19 @@ __stubs_start:
 vector_fiq:
        subs    pc, lr, #4
 
-/*=============================================================================
- * Address exception handler
- *-----------------------------------------------------------------------------
- * These aren't too critical.
- * (they're not supposed to happen, and won't happen in 32-bit data mode).
- */
-
-vector_addrexcptn:
-       b       vector_addrexcptn
-
-/*
- * We group all the following data together to optimise
- * for CPUs with separate I & D caches.
- */
-       .align  5
-
-.LCvswi:
-       .word   vector_swi
-
-       .globl  __stubs_end
-__stubs_end:
-
-       .equ    stubs_offset, __vectors_start + 0x200 - __stubs_start
+       .globl  vector_fiq_offset
+       .equ    vector_fiq_offset, vector_fiq
 
-       .globl  __vectors_start
+       .section .vectors, "ax", %progbits
 __vectors_start:
- ARM(  swi     SYS_ERROR0      )
- THUMB(        svc     #0              )
- THUMB(        nop                     )
-       W(b)    vector_und + stubs_offset
-       W(ldr)  pc, .LCvswi + stubs_offset
-       W(b)    vector_pabt + stubs_offset
-       W(b)    vector_dabt + stubs_offset
-       W(b)    vector_addrexcptn + stubs_offset
-       W(b)    vector_irq + stubs_offset
-       W(b)    vector_fiq + stubs_offset
-
-       .globl  __vectors_end
-__vectors_end:
+       W(b)    vector_rst
+       W(b)    vector_und
+       W(ldr)  pc, __vectors_start + 0x1000
+       W(b)    vector_pabt
+       W(b)    vector_dabt
+       W(b)    vector_addrexcptn
+       W(b)    vector_irq
+       W(b)    vector_fiq
 
        .data
 
index e00621f1403f7c44765103591cbefd6e3315702f..52b26432c9a9941e8281a4483dd7aed148a99995 100644 (file)
@@ -49,7 +49,7 @@ __irq_entry:
        mov     r1, sp
        stmdb   sp!, {lr}
        @ routine called with r0 = irq number, r1 = struct pt_regs *
-       bl      nvic_do_IRQ
+       bl      nvic_handle_irq
 
        pop     {lr}
        @
index 2adda11f712fe02fa2fdaa63e944e17199bd3748..fc7920288a3d90a3f9c3ca38be03ff845f84515a 100644 (file)
 #include <asm/irq.h>
 #include <asm/traps.h>
 
+#define FIQ_OFFSET ({                                  \
+               extern void *vector_fiq_offset;         \
+               (unsigned)&vector_fiq_offset;           \
+       })
+
 static unsigned long no_fiq_insn;
 
 /* Default reacquire function
@@ -79,14 +84,13 @@ int show_fiq_list(struct seq_file *p, int prec)
 
 void set_fiq_handler(void *start, unsigned int length)
 {
-#if defined(CONFIG_CPU_USE_DOMAINS)
-       memcpy((void *)0xffff001c, start, length);
-#else
-       memcpy(vectors_page + 0x1c, start, length);
-#endif
-       flush_icache_range(0xffff001c, 0xffff001c + length);
-       if (!vectors_high())
-               flush_icache_range(0x1c, 0x1c + length);
+       void *base = vectors_page;
+       unsigned offset = FIQ_OFFSET;
+
+       memcpy(base + offset, start, length);
+       if (!cache_is_vipt_nonaliasing())
+               flush_icache_range(base + offset, offset + length);
+       flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length);
 }
 
 int claim_fiq(struct fiq_handler *f)
@@ -144,6 +148,7 @@ EXPORT_SYMBOL(disable_fiq);
 
 void __init init_FIQ(int start)
 {
-       no_fiq_insn = *(unsigned long *)0xffff001c;
+       unsigned offset = FIQ_OFFSET;
+       no_fiq_insn = *(unsigned long *)(0xffff0000 + offset);
        fiq_start = start;
 }
index 76ab5ca506100c1883a8cebe57fd02eacd24a6d9..47cd974e57ea3ca0de7e9feccd9e527c2ba39f1f 100644 (file)
@@ -149,7 +149,6 @@ ENDPROC(lookup_processor_type)
  *     r5 = proc_info pointer in physical address space
  *     r9 = cpuid (preserved)
  */
-       __CPUINIT
 __lookup_processor_type:
        adr     r3, __lookup_processor_type_data
        ldmia   r3, {r4 - r6}
index 75f14cc3e07310050cec95feddcfa63f1191fe82..14235ba64a90736ecebad575f5d88ea4568e8eaf 100644 (file)
@@ -87,7 +87,7 @@ ENTRY(stext)
 ENDPROC(stext)
 
 #ifdef CONFIG_SMP
-       __CPUINIT
+       .text
 ENTRY(secondary_startup)
        /*
         * Common entry point for secondary CPUs.
index 45e8935cae4e44198ca4d197a66f219b7e7b8105..2c7cc1e03473aee9463e86d7dbedfc999f6e51f7 100644 (file)
@@ -343,7 +343,7 @@ __turn_mmu_on_loc:
        .long   __turn_mmu_on_end
 
 #if defined(CONFIG_SMP)
-       __CPUINIT
+       .text
 ENTRY(secondary_startup)
        /*
         * Common entry point for secondary CPUs.
index 1fd749ee4a1bb96c1740f4a131fde1d3cd53bfb0..7b95de6013571df3528716f2bba00f8dfd13badf 100644 (file)
@@ -1020,7 +1020,7 @@ out_mdbgen:
                cpumask_or(&debug_err_mask, &debug_err_mask, cpumask_of(cpu));
 }
 
-static int __cpuinit dbg_reset_notify(struct notifier_block *self,
+static int dbg_reset_notify(struct notifier_block *self,
                                      unsigned long action, void *cpu)
 {
        if ((action & ~CPU_TASKS_FROZEN) == CPU_ONLINE)
@@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata dbg_reset_nb = {
+static struct notifier_block dbg_reset_nb = {
        .notifier_call = dbg_reset_notify,
 };
 
index 4910232c48330d4dc857d6bf32754bfd781008b5..797b1a6a4906da0f8ca3f942186ac0e033250ce6 100644 (file)
@@ -56,8 +56,8 @@ ENTRY(__boot_cpu_mode)
        ldr     \reg3, [\reg2]
        ldr     \reg1, [\reg2, \reg3]
        cmp     \mode, \reg1            @ matches primary CPU boot mode?
-       orrne   r7, r7, #BOOT_CPU_MODE_MISMATCH
-       strne   r7, [r5, r6]            @ record what happened and give up
+       orrne   \reg1, \reg1, #BOOT_CPU_MODE_MISMATCH
+       strne   \reg1, [\reg2, \reg3]   @ record what happened and give up
        .endm
 
 #else  /* ZIMAGE */
index 4fb074c446bf901df288b3878341a169dacb843b..d7c82df692436df0248fa1a00502cf74b7fca23c 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
 #include <asm/mach-types.h>
+#include <asm/smp_plat.h>
 #include <asm/system_misc.h>
 
 extern const unsigned char relocate_new_kernel[];
@@ -38,6 +39,14 @@ int machine_kexec_prepare(struct kimage *image)
        __be32 header;
        int i, err;
 
+       /*
+        * Validate that if the current HW supports SMP, then the SW supports
+        * and implements CPU hotplug for the current HW. If not, we won't be
+        * able to kexec reliably, so fail the prepare operation.
+        */
+       if (num_possible_cpus() > 1 && !platform_can_cpu_hotplug())
+               return -EINVAL;
+
        /*
         * No segment at default ATAGs address. try to locate
         * a dtb using magic.
@@ -134,10 +143,13 @@ void machine_kexec(struct kimage *image)
        unsigned long reboot_code_buffer_phys;
        void *reboot_code_buffer;
 
-       if (num_online_cpus() > 1) {
-               pr_err("kexec: error: multiple CPUs still online\n");
-               return;
-       }
+       /*
+        * This can only happen if machine_shutdown() failed to disable some
+        * CPU, and that can only happen if the checks in
+        * machine_kexec_prepare() were not correct. If this fails, we can't
+        * reliably kexec anyway, so BUG_ON is appropriate.
+        */
+       BUG_ON(num_online_cpus() > 1);
 
        page_list = image->head & PAGE_MASK;
 
index d9f5cd4e533fef948f68510e3a6fb3b4996b750b..e186ee1e63f6c85261f96844a594080e719c2e07 100644 (file)
@@ -53,7 +53,12 @@ armpmu_map_cache_event(const unsigned (*cache_map)
 static int
 armpmu_map_hw_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
 {
-       int mapping = (*event_map)[config];
+       int mapping;
+
+       if (config >= PERF_COUNT_HW_MAX)
+               return -EINVAL;
+
+       mapping = (*event_map)[config];
        return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
 }
 
@@ -253,6 +258,9 @@ validate_event(struct pmu_hw_events *hw_events,
        struct arm_pmu *armpmu = to_arm_pmu(event->pmu);
        struct pmu *leader_pmu = event->group_leader->pmu;
 
+       if (is_software_event(event))
+               return 1;
+
        if (event->pmu != leader_pmu || event->state < PERF_EVENT_STATE_OFF)
                return 1;
 
index 1f2740e3dbc028c062c134d58ceb6344f2045d36..aebe0e99c153eaa6889efc7b36459ebdfaeb65cc 100644 (file)
@@ -157,8 +157,8 @@ static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
  * UNKNOWN at reset, the PMU must be explicitly reset to avoid reading
  * junk values out of them.
  */
-static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
-                                   unsigned long action, void *hcpu)
+static int cpu_pmu_notify(struct notifier_block *b, unsigned long action,
+                         void *hcpu)
 {
        if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING)
                return NOTIFY_DONE;
@@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
+static struct notifier_block cpu_pmu_hotplug_notifier = {
        .notifier_call = cpu_pmu_notify,
 };
 
index d3ca4f6915af746d5f13c4427cb42bacbd61b694..94f6b05f9e24e8cd1d79063f03a9b2dd16791c67 100644 (file)
@@ -197,6 +197,7 @@ void machine_shutdown(void)
  */
 void machine_halt(void)
 {
+       local_irq_disable();
        smp_send_stop();
 
        local_irq_disable();
@@ -211,6 +212,7 @@ void machine_halt(void)
  */
 void machine_power_off(void)
 {
+       local_irq_disable();
        smp_send_stop();
 
        if (pm_power_off)
@@ -230,6 +232,7 @@ void machine_power_off(void)
  */
 void machine_restart(char *cmd)
 {
+       local_irq_disable();
        smp_send_stop();
 
        arm_pm_restart(reboot_mode, cmd);
@@ -426,10 +429,11 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
 }
 
 #ifdef CONFIG_MMU
+#ifdef CONFIG_KUSER_HELPERS
 /*
  * The vectors page is always readable from user space for the
- * atomic helpers and the signal restart code. Insert it into the
- * gate_vma so that it is visible through ptrace and /proc/<pid>/mem.
+ * atomic helpers. Insert it into the gate_vma so that it is visible
+ * through ptrace and /proc/<pid>/mem.
  */
 static struct vm_area_struct gate_vma = {
        .vm_start       = 0xffff0000,
@@ -458,9 +462,48 @@ int in_gate_area_no_mm(unsigned long addr)
 {
        return in_gate_area(NULL, addr);
 }
+#define is_gate_vma(vma)       ((vma) == &gate_vma)
+#else
+#define is_gate_vma(vma)       0
+#endif
 
 const char *arch_vma_name(struct vm_area_struct *vma)
 {
-       return (vma == &gate_vma) ? "[vectors]" : NULL;
+       return is_gate_vma(vma) ? "[vectors]" :
+               (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
+                "[sigpage]" : NULL;
+}
+
+static struct page *signal_page;
+extern struct page *get_signal_page(void);
+
+int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+{
+       struct mm_struct *mm = current->mm;
+       unsigned long addr;
+       int ret;
+
+       if (!signal_page)
+               signal_page = get_signal_page();
+       if (!signal_page)
+               return -ENOMEM;
+
+       down_write(&mm->mmap_sem);
+       addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
+       if (IS_ERR_VALUE(addr)) {
+               ret = addr;
+               goto up_fail;
+       }
+
+       ret = install_special_mapping(mm, addr, PAGE_SIZE,
+               VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
+               &signal_page);
+
+       if (ret == 0)
+               mm->context.sigpage = addr;
+
+ up_fail:
+       up_write(&mm->mmap_sem);
+       return ret;
 }
 #endif
index 219f1d73572a588d431dca2e0bb7f7b598ea9899..70ded3fb42d9887c71293755aff8354784220d64 100644 (file)
@@ -46,8 +46,7 @@
 
 extern void secondary_startup(void);
 
-static int __cpuinit psci_boot_secondary(unsigned int cpu,
-                                        struct task_struct *idle)
+static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        if (psci_ops.cpu_on)
                return psci_ops.cpu_on(cpu_logical_map(cpu),
index 63af9a7ae5124f82484feb8b33a88114b915753d..afc2489ee13bc098523f92549baa4a69728c1ced 100644 (file)
@@ -836,6 +836,8 @@ static int __init meminfo_cmp(const void *_a, const void *_b)
 void __init hyp_mode_check(void)
 {
 #ifdef CONFIG_ARM_VIRT_EXT
+       sync_boot_mode();
+
        if (is_hyp_mode_available()) {
                pr_info("CPU: All CPU(s) started in HYP mode.\n");
                pr_info("CPU: Virtualization extensions available.\n");
@@ -971,6 +973,7 @@ static const char *hwcap_str[] = {
        "vfpv4",
        "idiva",
        "idivt",
+       "vfpd32",
        "lpae",
        NULL
 };
index 1c16c35c271af5a3cb4de53736344a9ed286d7d9..ab330422527203417472a21727b1062c8a38e70f 100644 (file)
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/errno.h>
+#include <linux/random.h>
 #include <linux/signal.h>
 #include <linux/personality.h>
 #include <linux/uaccess.h>
 
 #include <asm/elf.h>
 #include <asm/cacheflush.h>
+#include <asm/traps.h>
 #include <asm/ucontext.h>
 #include <asm/unistd.h>
 #include <asm/vfp.h>
 
-#include "signal.h"
-
 /*
  * For ARM syscalls, we encode the syscall number into the instruction.
  */
 #define SWI_THUMB_SIGRETURN    (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
 #define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
 
-const unsigned long sigreturn_codes[7] = {
+static const unsigned long sigreturn_codes[7] = {
        MOV_R7_NR_SIGRETURN,    SWI_SYS_SIGRETURN,    SWI_THUMB_SIGRETURN,
        MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
 };
 
+static unsigned long signal_return_offset;
+
 #ifdef CONFIG_CRUNCH
 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
 {
@@ -400,14 +402,20 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
                    __put_user(sigreturn_codes[idx+1], rc+1))
                        return 1;
 
-               if ((cpsr & MODE32_BIT) && !IS_ENABLED(CONFIG_ARM_MPU)) {
+#ifdef CONFIG_MMU
+               if (cpsr & MODE32_BIT) {
+                       struct mm_struct *mm = current->mm;
+
                        /*
-                        * 32-bit code can use the new high-page
-                        * signal return code support except when the MPU has
-                        * protected the vectors page from PL0
+                        * 32-bit code can use the signal return page
+                        * except when the MPU has protected the vectors
+                        * page from PL0
                         */
-                       retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
-               } else {
+                       retcode = mm->context.sigpage + signal_return_offset +
+                                 (idx << 2) + thumb;
+               } else
+#endif
+               {
                        /*
                         * Ensure that the instruction cache sees
                         * the return code written onto the stack.
@@ -608,3 +616,33 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
        } while (thread_flags & _TIF_WORK_MASK);
        return 0;
 }
+
+struct page *get_signal_page(void)
+{
+       unsigned long ptr;
+       unsigned offset;
+       struct page *page;
+       void *addr;
+
+       page = alloc_pages(GFP_KERNEL, 0);
+
+       if (!page)
+               return NULL;
+
+       addr = page_address(page);
+
+       /* Give the signal return code some randomness */
+       offset = 0x200 + (get_random_int() & 0x7fc);
+       signal_return_offset = offset;
+
+       /*
+        * Copy signal return handlers into the vector page, and
+        * set sigreturn to be a pointer to these.
+        */
+       memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
+
+       ptr = (unsigned long)addr + offset;
+       flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
+
+       return page;
+}
diff --git a/arch/arm/kernel/signal.h b/arch/arm/kernel/signal.h
deleted file mode 100644 (file)
index 5ff067b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- *  linux/arch/arm/kernel/signal.h
- *
- *  Copyright (C) 2005-2009 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#define KERN_SIGRETURN_CODE    (CONFIG_VECTORS_BASE + 0x00000500)
-
-extern const unsigned long sigreturn_codes[7];
index c5fb5469054bddea98b9ba9647f7ed75929481aa..2dc19349eb19fc23feafa1a2b93db17eb5e6394a 100644 (file)
@@ -58,7 +58,7 @@ struct secondary_data secondary_data;
  * control for which core is the next to come out of the secondary
  * boot "holding pen"
  */
-volatile int __cpuinitdata pen_release = -1;
+volatile int pen_release = -1;
 
 enum ipi_msg_type {
        IPI_WAKEUP,
@@ -86,7 +86,7 @@ static unsigned long get_arch_pgd(pgd_t *pgd)
        return pgdir >> ARCH_PGD_SHIFT;
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
+int __cpu_up(unsigned int cpu, struct task_struct *idle)
 {
        int ret;
 
@@ -138,13 +138,23 @@ void __init smp_init_cpus(void)
                smp_ops.smp_init_cpus();
 }
 
-int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
+int boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        if (smp_ops.smp_boot_secondary)
                return smp_ops.smp_boot_secondary(cpu, idle);
        return -ENOSYS;
 }
 
+int platform_can_cpu_hotplug(void)
+{
+#ifdef CONFIG_HOTPLUG_CPU
+       if (smp_ops.cpu_kill)
+               return 1;
+#endif
+
+       return 0;
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
 static void percpu_timer_stop(void);
 
@@ -170,7 +180,7 @@ static int platform_cpu_disable(unsigned int cpu)
 /*
  * __cpu_disable runs on the processor to be shutdown.
  */
-int __cpuinit __cpu_disable(void)
+int __cpu_disable(void)
 {
        unsigned int cpu = smp_processor_id();
        int ret;
@@ -216,7 +226,7 @@ static DECLARE_COMPLETION(cpu_died);
  * called on the thread which is asking for a CPU to be shutdown -
  * waits until shutdown has completed, or it is timed out.
  */
-void __cpuinit __cpu_die(unsigned int cpu)
+void __cpu_die(unsigned int cpu)
 {
        if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) {
                pr_err("CPU%u: cpu didn't die\n", cpu);
@@ -306,7 +316,7 @@ void __ref cpu_die(void)
  * Called by both boot and secondaries to move global data into
  * per-processor storage.
  */
-static void __cpuinit smp_store_cpu_info(unsigned int cpuid)
+static void smp_store_cpu_info(unsigned int cpuid)
 {
        struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
 
@@ -322,7 +332,7 @@ static void percpu_timer_setup(void);
  * This is the secondary CPU boot entry.  We're using this CPUs
  * idle thread stack, but a set of temporary page tables.
  */
-asmlinkage void __cpuinit secondary_start_kernel(void)
+asmlinkage void secondary_start_kernel(void)
 {
        struct mm_struct *mm = &init_mm;
        unsigned int cpu;
@@ -521,7 +531,7 @@ static void broadcast_timer_set_mode(enum clock_event_mode mode,
 {
 }
 
-static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt)
+static void broadcast_timer_setup(struct clock_event_device *evt)
 {
        evt->name       = "dummy_timer";
        evt->features   = CLOCK_EVT_FEAT_ONESHOT |
@@ -550,7 +560,7 @@ int local_timer_register(struct local_timer_ops *ops)
 }
 #endif
 
-static void __cpuinit percpu_timer_setup(void)
+static void percpu_timer_setup(void)
 {
        unsigned int cpu = smp_processor_id();
        struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
index a98b62dca2faf9bbce7fbcb786d4c325513f7231..c2edfff573c2c9e2e68193cf729a98f460ac1a2d 100644 (file)
@@ -70,23 +70,6 @@ static inline void ipi_flush_bp_all(void *ignored)
        local_flush_bp_all();
 }
 
-#ifdef CONFIG_ARM_ERRATA_798181
-static int erratum_a15_798181(void)
-{
-       unsigned int midr = read_cpuid_id();
-
-       /* Cortex-A15 r0p0..r3p2 affected */
-       if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
-               return 0;
-       return 1;
-}
-#else
-static int erratum_a15_798181(void)
-{
-       return 0;
-}
-#endif
-
 static void ipi_flush_tlb_a15_erratum(void *arg)
 {
        dmb();
index f6fd1d4398c6febcca070a90985d3585af9a6939..25956204ef23ee19b4aeb1b3e290342e484252d9 100644 (file)
@@ -187,7 +187,7 @@ core_initcall(twd_cpufreq_init);
 
 #endif
 
-static void __cpuinit twd_calibrate_rate(void)
+static void twd_calibrate_rate(void)
 {
        unsigned long count;
        u64 waitjiffies;
@@ -265,7 +265,7 @@ static void twd_get_clock(struct device_node *np)
 /*
  * Setup the local clock events for a CPU.
  */
-static int __cpuinit twd_timer_setup(struct clock_event_device *clk)
+static int twd_timer_setup(struct clock_event_device *clk)
 {
        struct clock_event_device **this_cpu_clk;
        int cpu = smp_processor_id();
@@ -308,7 +308,7 @@ static int __cpuinit twd_timer_setup(struct clock_event_device *clk)
        return 0;
 }
 
-static struct local_timer_ops twd_lt_ops __cpuinitdata = {
+static struct local_timer_ops twd_lt_ops = {
        .setup  = twd_timer_setup,
        .stop   = twd_timer_stop,
 };
index cab094c234ee85d646b9534d2044010c10c727ee..ab517fcce21b8308dc957bc5b6809039c2e5f1fe 100644 (file)
@@ -35,8 +35,6 @@
 #include <asm/tls.h>
 #include <asm/system_misc.h>
 
-#include "signal.h"
-
 static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" };
 
 void *vectors_page;
@@ -800,15 +798,26 @@ void __init trap_init(void)
        return;
 }
 
-static void __init kuser_get_tls_init(unsigned long vectors)
+#ifdef CONFIG_KUSER_HELPERS
+static void __init kuser_init(void *vectors)
 {
+       extern char __kuser_helper_start[], __kuser_helper_end[];
+       int kuser_sz = __kuser_helper_end - __kuser_helper_start;
+
+       memcpy(vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
+
        /*
         * vectors + 0xfe0 = __kuser_get_tls
         * vectors + 0xfe8 = hardware TLS instruction at 0xffff0fe8
         */
        if (tls_emu || has_tls_reg)
-               memcpy((void *)vectors + 0xfe0, (void *)vectors + 0xfe8, 4);
+               memcpy(vectors + 0xfe0, vectors + 0xfe8, 4);
 }
+#else
+static void __init kuser_init(void *vectors)
+{
+}
+#endif
 
 void __init early_trap_init(void *vectors_base)
 {
@@ -816,33 +825,30 @@ void __init early_trap_init(void *vectors_base)
        unsigned long vectors = (unsigned long)vectors_base;
        extern char __stubs_start[], __stubs_end[];
        extern char __vectors_start[], __vectors_end[];
-       extern char __kuser_helper_start[], __kuser_helper_end[];
-       int kuser_sz = __kuser_helper_end - __kuser_helper_start;
+       unsigned i;
 
        vectors_page = vectors_base;
 
+       /*
+        * Poison the vectors page with an undefined instruction.  This
+        * instruction is chosen to be undefined for both ARM and Thumb
+        * ISAs.  The Thumb version is an undefined instruction with a
+        * branch back to the undefined instruction.
+        */
+       for (i = 0; i < PAGE_SIZE / sizeof(u32); i++)
+               ((u32 *)vectors_base)[i] = 0xe7fddef1;
+
        /*
         * Copy the vectors, stubs and kuser helpers (in entry-armv.S)
         * into the vector page, mapped at 0xffff0000, and ensure these
         * are visible to the instruction stream.
         */
        memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
-       memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start);
-       memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
+       memcpy((void *)vectors + 0x1000, __stubs_start, __stubs_end - __stubs_start);
 
-       /*
-        * Do processor specific fixups for the kuser helpers
-        */
-       kuser_get_tls_init(vectors);
-
-       /*
-        * Copy signal return handlers into the vector page, and
-        * set sigreturn to be a pointer to these.
-        */
-       memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
-              sigreturn_codes, sizeof(sigreturn_codes));
+       kuser_init(vectors_base);
 
-       flush_icache_range(vectors, vectors + PAGE_SIZE);
+       flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
        modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
 #else /* ifndef CONFIG_CPU_V7M */
        /*
index fa25e4e425f6070c0a6055de98271f865dde3823..7bcee5c9b6049c2723df9e3e9fc9b0b088b5fe0b 100644 (file)
@@ -148,6 +148,23 @@ SECTIONS
        . = ALIGN(PAGE_SIZE);
        __init_begin = .;
 #endif
+       /*
+        * The vectors and stubs are relocatable code, and the
+        * only thing that matters is their relative offsets
+        */
+       __vectors_start = .;
+       .vectors 0 : AT(__vectors_start) {
+               *(.vectors)
+       }
+       . = __vectors_start + SIZEOF(.vectors);
+       __vectors_end = .;
+
+       __stubs_start = .;
+       .stubs 0x1000 : AT(__stubs_start) {
+               *(.stubs)
+       }
+       . = __stubs_start + SIZEOF(.stubs);
+       __stubs_end = .;
 
        INIT_TEXT_SECTION(8)
        .exit.text : {
index 4a5199070430672728c91dfe610047e83b78a964..db9cf692d4dded3e2a6cc7e5622ba90ee5bef2e8 100644 (file)
@@ -146,7 +146,11 @@ static bool pm_fake(struct kvm_vcpu *vcpu,
 #define access_pmintenclr pm_fake
 
 /* Architected CP15 registers.
- * Important: Must be sorted ascending by CRn, CRM, Op1, Op2
+ * CRn denotes the primary register number, but is copied to the CRm in the
+ * user space API for 64-bit register access in line with the terminology used
+ * in the ARM ARM.
+ * Important: Must be sorted ascending by CRn, CRM, Op1, Op2 and with 64-bit
+ *            registers preceding 32-bit ones.
  */
 static const struct coproc_reg cp15_regs[] = {
        /* CSSELR: swapped by interrupt.S. */
@@ -154,8 +158,8 @@ static const struct coproc_reg cp15_regs[] = {
                        NULL, reset_unknown, c0_CSSELR },
 
        /* TTBR0/TTBR1: swapped by interrupt.S. */
-       { CRm( 2), Op1( 0), is64, NULL, reset_unknown64, c2_TTBR0 },
-       { CRm( 2), Op1( 1), is64, NULL, reset_unknown64, c2_TTBR1 },
+       { CRm64( 2), Op1( 0), is64, NULL, reset_unknown64, c2_TTBR0 },
+       { CRm64( 2), Op1( 1), is64, NULL, reset_unknown64, c2_TTBR1 },
 
        /* TTBCR: swapped by interrupt.S. */
        { CRn( 2), CRm( 0), Op1( 0), Op2( 2), is32,
@@ -182,7 +186,7 @@ static const struct coproc_reg cp15_regs[] = {
                        NULL, reset_unknown, c6_IFAR },
 
        /* PAR swapped by interrupt.S */
-       { CRn( 7), Op1( 0), is64, NULL, reset_unknown64, c7_PAR },
+       { CRm64( 7), Op1( 0), is64, NULL, reset_unknown64, c7_PAR },
 
        /*
         * DC{C,I,CI}SW operations:
@@ -399,12 +403,13 @@ static bool index_to_params(u64 id, struct coproc_params *params)
                              | KVM_REG_ARM_OPC1_MASK))
                        return false;
                params->is_64bit = true;
-               params->CRm = ((id & KVM_REG_ARM_CRM_MASK)
+               /* CRm to CRn: see cp15_to_index for details */
+               params->CRn = ((id & KVM_REG_ARM_CRM_MASK)
                               >> KVM_REG_ARM_CRM_SHIFT);
                params->Op1 = ((id & KVM_REG_ARM_OPC1_MASK)
                               >> KVM_REG_ARM_OPC1_SHIFT);
                params->Op2 = 0;
-               params->CRn = 0;
+               params->CRm = 0;
                return true;
        default:
                return false;
@@ -898,7 +903,14 @@ static u64 cp15_to_index(const struct coproc_reg *reg)
        if (reg->is_64) {
                val |= KVM_REG_SIZE_U64;
                val |= (reg->Op1 << KVM_REG_ARM_OPC1_SHIFT);
-               val |= (reg->CRm << KVM_REG_ARM_CRM_SHIFT);
+               /*
+                * CRn always denotes the primary coproc. reg. nr. for the
+                * in-kernel representation, but the user space API uses the
+                * CRm for the encoding, because it is modelled after the
+                * MRRC/MCRR instructions: see the ARM ARM rev. c page
+                * B3-1445
+                */
+               val |= (reg->CRn << KVM_REG_ARM_CRM_SHIFT);
        } else {
                val |= KVM_REG_SIZE_U32;
                val |= (reg->Op1 << KVM_REG_ARM_OPC1_SHIFT);
index b7301d3e479921f4d8983a172c88ec6edababd81..0461d5c8d3de4f99c3ecfef669340ec6fa8e0411 100644 (file)
@@ -135,6 +135,8 @@ static inline int cmp_reg(const struct coproc_reg *i1,
                return -1;
        if (i1->CRn != i2->CRn)
                return i1->CRn - i2->CRn;
+       if (i1->is_64 != i2->is_64)
+               return i2->is_64 - i1->is_64;
        if (i1->CRm != i2->CRm)
                return i1->CRm - i2->CRm;
        if (i1->Op1 != i2->Op1)
@@ -145,6 +147,7 @@ static inline int cmp_reg(const struct coproc_reg *i1,
 
 #define CRn(_x)                .CRn = _x
 #define CRm(_x)        .CRm = _x
+#define CRm64(_x)       .CRn = _x, .CRm = 0
 #define Op1(_x)        .Op1 = _x
 #define Op2(_x)        .Op2 = _x
 #define is64           .is_64 = true
index 685063a6d0cf655296aaec9713d08f19b53fa260..cf93472b9dd60daf3da620cf3a44a9ff65a6eac6 100644 (file)
@@ -114,7 +114,11 @@ static bool access_l2ectlr(struct kvm_vcpu *vcpu,
 
 /*
  * A15-specific CP15 registers.
- * Important: Must be sorted ascending by CRn, CRM, Op1, Op2
+ * CRn denotes the primary register number, but is copied to the CRm in the
+ * user space API for 64-bit register access in line with the terminology used
+ * in the ARM ARM.
+ * Important: Must be sorted ascending by CRn, CRM, Op1, Op2 and with 64-bit
+ *            registers preceding 32-bit ones.
  */
 static const struct coproc_reg a15_regs[] = {
        /* MPIDR: we use VMPIDR for guest access. */
index b8e06b7a28331ede0a01ce6aefcb60d7be343f6e..0c25d9487d5382d2a19a1b3399398244f3718866 100644 (file)
@@ -63,7 +63,8 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
 static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                      struct kvm_exit_mmio *mmio)
 {
-       unsigned long rt, len;
+       unsigned long rt;
+       int len;
        bool is_write, sign_extend;
 
        if (kvm_vcpu_dabt_isextabt(vcpu)) {
index ca6bea4859b48c35e9c34d970fb02580840e23b4..0988d9e04dd4c21dab8eae53205e92fafe809dfd 100644 (file)
@@ -85,6 +85,12 @@ static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc)
        return p;
 }
 
+static bool page_empty(void *ptr)
+{
+       struct page *ptr_page = virt_to_page(ptr);
+       return page_count(ptr_page) == 1;
+}
+
 static void clear_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr)
 {
        pmd_t *pmd_table = pmd_offset(pud, 0);
@@ -103,12 +109,6 @@ static void clear_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr)
        put_page(virt_to_page(pmd));
 }
 
-static bool pmd_empty(pmd_t *pmd)
-{
-       struct page *pmd_page = virt_to_page(pmd);
-       return page_count(pmd_page) == 1;
-}
-
 static void clear_pte_entry(struct kvm *kvm, pte_t *pte, phys_addr_t addr)
 {
        if (pte_present(*pte)) {
@@ -118,12 +118,6 @@ static void clear_pte_entry(struct kvm *kvm, pte_t *pte, phys_addr_t addr)
        }
 }
 
-static bool pte_empty(pte_t *pte)
-{
-       struct page *pte_page = virt_to_page(pte);
-       return page_count(pte_page) == 1;
-}
-
 static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
                        unsigned long long start, u64 size)
 {
@@ -132,37 +126,37 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
        pmd_t *pmd;
        pte_t *pte;
        unsigned long long addr = start, end = start + size;
-       u64 range;
+       u64 next;
 
        while (addr < end) {
                pgd = pgdp + pgd_index(addr);
                pud = pud_offset(pgd, addr);
                if (pud_none(*pud)) {
-                       addr += PUD_SIZE;
+                       addr = pud_addr_end(addr, end);
                        continue;
                }
 
                pmd = pmd_offset(pud, addr);
                if (pmd_none(*pmd)) {
-                       addr += PMD_SIZE;
+                       addr = pmd_addr_end(addr, end);
                        continue;
                }
 
                pte = pte_offset_kernel(pmd, addr);
                clear_pte_entry(kvm, pte, addr);
-               range = PAGE_SIZE;
+               next = addr + PAGE_SIZE;
 
                /* If we emptied the pte, walk back up the ladder */
-               if (pte_empty(pte)) {
+               if (page_empty(pte)) {
                        clear_pmd_entry(kvm, pmd, addr);
-                       range = PMD_SIZE;
-                       if (pmd_empty(pmd)) {
+                       next = pmd_addr_end(addr, end);
+                       if (page_empty(pmd) && !page_empty(pud)) {
                                clear_pud_entry(kvm, pud, addr);
-                               range = PUD_SIZE;
+                               next = pud_addr_end(addr, end);
                        }
                }
 
-               addr += range;
+               addr = next;
        }
 }
 
index 64dbfa57204ae9c3fde48c6efaec7f60e3c6af89..5306de35013397994ec6873f2a713af5d47867a4 100644 (file)
@@ -86,7 +86,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
        }
 }
 
-unsigned long __cpuinit calibrate_delay_is_known(void)
+unsigned long calibrate_delay_is_known(void)
 {
        delay_calibrated = true;
        return lpj_fine;
index 2abee6626aace2cff322f2c22a3bab79786d5473..916e5a1429171bd39835da54b02fa444b1941905 100644 (file)
@@ -227,6 +227,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
        CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk),
        CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk),
        CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
+       CLKDEV_CON_DEV_ID("usart", "f8040000.serial", &uart0_clk),
+       CLKDEV_CON_DEV_ID("usart", "f8044000.serial", &uart1_clk),
        CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk),
        CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
        CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
index dff4ddc5ef81312590cd3a2cdb1ad4b40e3741ab..139e42da25f061baa0128c7615723da54e068592 100644 (file)
@@ -75,6 +75,7 @@ static struct davinci_nand_pdata davinci_nand_data = {
        .parts                  = davinci_nand_partitions,
        .nr_parts               = ARRAY_SIZE(davinci_nand_partitions),
        .ecc_mode               = NAND_ECC_HW_SYNDROME,
+       .ecc_bits               = 4,
        .bbt_options            = NAND_BBT_USE_FLASH,
 };
 
index afbc439f11d4fba53bd3882535eda6b41540fe2f..4cdb61c5445943d7aa2e9a50b23c151b0ecf6a9c 100644 (file)
@@ -505,7 +505,7 @@ static struct vpbe_output dm365evm_vpbe_outputs[] = {
 /*
  * Amplifiers on the board
  */
-struct ths7303_platform_data ths7303_pdata = {
+static struct ths7303_platform_data ths7303_pdata = {
        .ch_1 = 3,
        .ch_2 = 3,
        .ch_3 = 3,
index a33686a6fbb226f9b880c2268a87beeb6b6f98e9..fa4bfaf952d886abcc94fd20bbb46285bd4cada6 100644 (file)
@@ -153,6 +153,7 @@ static struct davinci_nand_pdata davinci_evm_nandflash_data = {
        .parts          = davinci_evm_nandflash_partition,
        .nr_parts       = ARRAY_SIZE(davinci_evm_nandflash_partition),
        .ecc_mode       = NAND_ECC_HW,
+       .ecc_bits       = 1,
        .bbt_options    = NAND_BBT_USE_FLASH,
        .timing         = &davinci_evm_nandflash_timing,
 };
index fbb8e5ab1dc19bbd56e3508a5505929bb6c71406..0c005e876cac6fbd226c1700cfe47818b80dc6ee 100644 (file)
@@ -90,6 +90,7 @@ static struct davinci_nand_pdata davinci_nand_data = {
        .parts                  = davinci_nand_partitions,
        .nr_parts               = ARRAY_SIZE(davinci_nand_partitions),
        .ecc_mode               = NAND_ECC_HW,
+       .ecc_bits               = 1,
        .options                = 0,
 };
 
index 2bc112adf565495aed9505bfc23a401e53341d52..808233b60e3d0047e257227d50d49955c816228d 100644 (file)
@@ -88,6 +88,7 @@ static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = {
        .parts          = davinci_ntosd2_nandflash_partition,
        .nr_parts       = ARRAY_SIZE(davinci_ntosd2_nandflash_partition),
        .ecc_mode       = NAND_ECC_HW,
+       .ecc_bits       = 1,
        .bbt_options    = NAND_BBT_USE_FLASH,
 };
 
index 42ef53f62c6ce44344a42ac49b71f2b8e34f6ecf..86100d17969473112cbea30c4b3d3a1113420eee 100644 (file)
@@ -860,7 +860,7 @@ static struct platform_device dm355_vpbe_display = {
        },
 };
 
-struct venc_platform_data dm355_venc_pdata = {
+static struct venc_platform_data dm355_venc_pdata = {
        .setup_pinmux   = dm355_vpbe_setup_pinmux,
        .setup_clock    = dm355_venc_setup_clock,
 };
index fa7af5eda52d1bcf17a6120e3a603251e2b6de7f..dad28029ba9bee623ccbc0c29efb0a773453b388 100644 (file)
@@ -1349,7 +1349,7 @@ static struct platform_device dm365_vpbe_display = {
        },
 };
 
-struct venc_platform_data dm365_venc_pdata = {
+static struct venc_platform_data dm365_venc_pdata = {
        .setup_pinmux   = dm365_vpbe_setup_pinmux,
        .setup_clock    = dm365_venc_setup_clock,
 };
index 855d4a7b462d12fd0fc67b4abd3a55b0b0522530..5952e68c76c40e622e828a9e1849542b69f12aad 100644 (file)
@@ -92,6 +92,7 @@ config SOC_EXYNOS5440
        bool "SAMSUNG EXYNOS5440"
        default y
        depends on ARCH_EXYNOS5
+       select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
        select ARCH_HAS_OPP
        select HAVE_ARM_ARCH_TIMER
        select AUTO_ZRELADDR
index e970a7a4e278c137f6dffc358811f55cfea1c45d..53696154aead3da032d710720cd45ca72e634827 100644 (file)
@@ -14,7 +14,7 @@ obj-                          :=
 
 obj-$(CONFIG_ARCH_EXYNOS)      += common.o
 
-obj-$(CONFIG_PM)               += pm.o
+obj-$(CONFIG_S5P_PM)           += pm.o
 obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 obj-$(CONFIG_CPU_IDLE)         += cpuidle.o
 
index 164685bd25c82ec0f01f1eaeb39f36a125fd4738..ba95e5db25011a0801c2ef1f7c27270b713280ee 100644 (file)
@@ -58,7 +58,6 @@ static const char name_exynos5440[] = "EXYNOS5440";
 
 static void exynos4_map_io(void);
 static void exynos5_map_io(void);
-static void exynos5440_map_io(void);
 static int exynos_init(void);
 
 static struct cpu_table cpu_ids[] __initdata = {
@@ -95,7 +94,6 @@ static struct cpu_table cpu_ids[] __initdata = {
        }, {
                .idcode         = EXYNOS5440_SOC_ID,
                .idmask         = EXYNOS5_SOC_MASK,
-               .map_io         = exynos5440_map_io,
                .init           = exynos_init,
                .name           = name_exynos5440,
        },
@@ -149,11 +147,6 @@ static struct map_desc exynos4_iodesc[] __initdata = {
                .pfn            = __phys_to_pfn(EXYNOS4_PA_GIC_DIST),
                .length         = SZ_64K,
                .type           = MT_DEVICE,
-       }, {
-               .virtual        = (unsigned long)S3C_VA_UART,
-               .pfn            = __phys_to_pfn(EXYNOS4_PA_UART),
-               .length         = SZ_512K,
-               .type           = MT_DEVICE,
        }, {
                .virtual        = (unsigned long)S5P_VA_CMU,
                .pfn            = __phys_to_pfn(EXYNOS4_PA_CMU),
@@ -268,20 +261,6 @@ static struct map_desc exynos5_iodesc[] __initdata = {
                .pfn            = __phys_to_pfn(EXYNOS5_PA_PMU),
                .length         = SZ_64K,
                .type           = MT_DEVICE,
-       }, {
-               .virtual        = (unsigned long)S3C_VA_UART,
-               .pfn            = __phys_to_pfn(EXYNOS5_PA_UART),
-               .length         = SZ_512K,
-               .type           = MT_DEVICE,
-       },
-};
-
-static struct map_desc exynos5440_iodesc0[] __initdata = {
-       {
-               .virtual        = (unsigned long)S3C_VA_UART,
-               .pfn            = __phys_to_pfn(EXYNOS5440_PA_UART0),
-               .length         = SZ_512K,
-               .type           = MT_DEVICE,
        },
 };
 
@@ -388,11 +367,6 @@ static void __init exynos5_map_io(void)
                iotable_init(exynos5250_iodesc, ARRAY_SIZE(exynos5250_iodesc));
 }
 
-static void __init exynos5440_map_io(void)
-{
-       iotable_init(exynos5440_iodesc0, ARRAY_SIZE(exynos5440_iodesc0));
-}
-
 void __init exynos_init_time(void)
 {
        of_clk_init(NULL);
index 3e156bcddcb4cc65586ab652c7de52b60d47208f..972490fc09d627241a1d3c63e7d234693b4f03d8 100644 (file)
@@ -97,6 +97,5 @@ struct exynos_pmu_conf {
 };
 
 extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
-extern void s3c_cpu_resume(void);
 
 #endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
index 17a18ff3d71e289df9909cb3976d6e414c768dff..225ee8431c7282d1301d17c255687189482e7042 100644 (file)
@@ -25,6 +25,7 @@
 #include <mach/regs-pmu.h>
 
 #include <plat/cpu.h>
+#include <plat/pm.h>
 
 #include "common.h"
 
index 5364d4bfa8bc79efe6d51b27ff361811d98b8227..cdd9d91e99330487926b3518343bc9e6906753bf 100644 (file)
@@ -13,8 +13,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __CPUINIT
-
 /*
  * exynos4 specific entry point for secondary CPUs.  This provides
  * a "holding pen" into which all secondary cores are held until we're
index 374ef2cf7152c366fe56388909f751dac4d658c0..2a4cdb7cb326a400060fd9c959042145dedb17c2 100644 (file)
 
 #define PLAT_PHYS_OFFSET               UL(0x40000000)
 
+#ifndef CONFIG_ARM_LPAE
 /* Maximum of 256MiB in one bank */
 #define MAX_PHYSMEM_BITS       32
 #define SECTION_SIZE_BITS      28
+#else
+#define MAX_PHYSMEM_BITS       36
+#define SECTION_SIZE_BITS      31
+#endif
 
 #endif /* __ASM_ARCH_MEMORY_H */
index deba1308ff162eddfb76578f3547e96eb16c8120..58b43e6f926212277c38257ff50956c1aca16776 100644 (file)
@@ -75,7 +75,7 @@ static void __iomem *scu_base_addr(void)
 
 static DEFINE_SPINLOCK(boot_lock);
 
-static void __cpuinit exynos_secondary_init(unsigned int cpu)
+static void exynos_secondary_init(unsigned int cpu)
 {
        /*
         * let the primary processor know we're out of the
@@ -90,7 +90,7 @@ static void __cpuinit exynos_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-static int __cpuinit exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
        unsigned long phys_cpu = cpu_logical_map(cpu);
index 41c20692a13f0f189c1acaf011831048b6944a0a..c679db57726934de2f0338fadbbda0be05e49e74 100644 (file)
@@ -217,6 +217,9 @@ static __init int exynos_pm_drvinit(void)
        struct clk *pll_base;
        unsigned int tmp;
 
+       if (soc_is_exynos5440())
+               return 0;
+
        s3c_pm_init();
 
        /* All wakeup disable */
@@ -340,6 +343,9 @@ static struct syscore_ops exynos_pm_syscore_ops = {
 
 static __init int exynos_pm_syscore_init(void)
 {
+       if (soc_is_exynos5440())
+               return 0;
+
        register_syscore_ops(&exynos_pm_syscore_ops);
        return 0;
 }
index a7cd2cf5e08de32c2ceafc508559d3201919dcc4..3490a24f969e4a0b450ef146cee72f37e1cb6c9f 100644 (file)
@@ -276,8 +276,6 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
 
        sys->mem_offset  = DC21285_PCI_MEM;
 
-       pci_ioremap_io(0, DC21285_PCI_IO);
-
        pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset);
        pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
index dc5d6becd8c7c13f54406eaebead83bf11ffd9d2..88815795fe2678f7c41e54fd296397ace8de9a62 100644 (file)
@@ -115,6 +115,7 @@ static int highbank_platform_notifier(struct notifier_block *nb,
 {
        struct resource *res;
        int reg = -1;
+       u32 val;
        struct device *dev = __dev;
 
        if (event != BUS_NOTIFY_ADD_DEVICE)
@@ -141,10 +142,10 @@ static int highbank_platform_notifier(struct notifier_block *nb,
                return NOTIFY_DONE;
 
        if (of_property_read_bool(dev->of_node, "dma-coherent")) {
-               writel(0xff31, sregs_base + reg);
+               val = readl(sregs_base + reg);
+               writel(val | 0xff01, sregs_base + reg);
                set_dma_ops(dev, &arm_coherent_dma_ops);
-       } else
-               writel(0, sregs_base + reg);
+       }
 
        return NOTIFY_OK;
 }
index a984573e0d02323c62cdfe11aadb12ae3f37ecda..32d75cf55cbc72d3e48281d7ade3ead1de793ba3 100644 (file)
@@ -24,7 +24,7 @@
 
 extern void secondary_startup(void);
 
-static int __cpuinit highbank_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int highbank_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        highbank_set_cpu_jump(cpu, secondary_startup);
        arch_send_wakeup_ipi_mask(cpumask_of(cpu));
index 4282e99f5ca1803254a44449aee835c653429c6b..86567d980b0743df9eadf44bfac489bc01634b9d 100644 (file)
@@ -199,7 +199,8 @@ static const char *pcie_axi_sels[]  = { "axi", "ahb", };
 static const char *ssi_sels[]          = { "pll3_pfd2_508m", "pll3_pfd3_454m", "pll4_post_div", };
 static const char *usdhc_sels[]        = { "pll2_pfd2_396m", "pll2_pfd0_352m", };
 static const char *enfc_sels[] = { "pll2_pfd0_352m", "pll2_bus", "pll3_usb_otg", "pll2_pfd2_396m", };
-static const char *emi_sels[]          = { "axi", "pll3_usb_otg", "pll2_pfd2_396m", "pll2_pfd0_352m", };
+static const char *emi_sels[]          = { "pll2_pfd2_396m", "pll3_usb_otg", "axi", "pll2_pfd0_352m", };
+static const char *emi_slow_sels[]      = { "axi", "pll3_usb_otg", "pll2_pfd2_396m", "pll2_pfd0_352m", };
 static const char *vdo_axi_sels[]      = { "axi", "ahb", };
 static const char *vpu_axi_sels[]      = { "axi", "pll2_pfd2_396m", "pll2_pfd0_352m", };
 static const char *cko1_sels[] = { "pll3_usb_otg", "pll2_bus", "pll1_sys", "pll5_video_div",
@@ -392,7 +393,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
        clk[usdhc4_sel]       = imx_clk_mux("usdhc4_sel",       base + 0x1c, 19, 1, usdhc_sels,        ARRAY_SIZE(usdhc_sels));
        clk[enfc_sel]         = imx_clk_mux("enfc_sel",         base + 0x2c, 16, 2, enfc_sels,         ARRAY_SIZE(enfc_sels));
        clk[emi_sel]          = imx_clk_mux("emi_sel",          base + 0x1c, 27, 2, emi_sels,          ARRAY_SIZE(emi_sels));
-       clk[emi_slow_sel]     = imx_clk_mux("emi_slow_sel",     base + 0x1c, 29, 2, emi_sels,          ARRAY_SIZE(emi_sels));
+       clk[emi_slow_sel]     = imx_clk_mux("emi_slow_sel",     base + 0x1c, 29, 2, emi_slow_sels,     ARRAY_SIZE(emi_slow_sels));
        clk[vdo_axi_sel]      = imx_clk_mux("vdo_axi_sel",      base + 0x18, 11, 1, vdo_axi_sels,      ARRAY_SIZE(vdo_axi_sels));
        clk[vpu_axi_sel]      = imx_clk_mux("vpu_axi_sel",      base + 0x18, 14, 2, vpu_axi_sels,      ARRAY_SIZE(vpu_axi_sels));
        clk[cko1_sel]         = imx_clk_mux("cko1_sel",         base + 0x60, 0,  4, cko1_sels,         ARRAY_SIZE(cko1_sels));
index d617c0b7c8095f23c3273c86aadd5421ad0d29d0..b169a396d93bfcf193c83d7329a6fdc290101425 100644 (file)
@@ -183,6 +183,8 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
        clk[VF610_CLK_ENET_TS_SEL] = imx_clk_mux("enet_ts_sel", CCM_CSCMR2, 0, 3, enet_ts_sels, 7);
        clk[VF610_CLK_ENET] = imx_clk_gate("enet", "enet_sel", CCM_CSCDR1, 24);
        clk[VF610_CLK_ENET_TS] = imx_clk_gate("enet_ts", "enet_ts_sel", CCM_CSCDR1, 23);
+       clk[VF610_CLK_ENET0] = imx_clk_gate2("enet0", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(0));
+       clk[VF610_CLK_ENET1] = imx_clk_gate2("enet1", "ipg_bus", CCM_CCGR9, CCM_CCGRx_CGn(1));
 
        clk[VF610_CLK_PIT] = imx_clk_gate2("pit", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(7));
 
index e074616d54ca5e034e0b6331b8235c7a72971a37..8a65f192e7f31fb82b998b9e094ae9e1f69441a7 100644 (file)
 #define MX27_INT_GPT4          (NR_IRQS_LEGACY + 4)
 #define MX27_INT_RTIC          (NR_IRQS_LEGACY + 5)
 #define MX27_INT_CSPI3         (NR_IRQS_LEGACY + 6)
-#define MX27_INT_SDHC          (NR_IRQS_LEGACY + 7)
+#define MX27_INT_MSHC          (NR_IRQS_LEGACY + 7)
 #define MX27_INT_GPIO          (NR_IRQS_LEGACY + 8)
 #define MX27_INT_SDHC3         (NR_IRQS_LEGACY + 9)
 #define MX27_INT_SDHC2         (NR_IRQS_LEGACY + 10)
index c6e1ab5448822c8aaed044413f726b0dc8c47a39..1f24c1fdfea4eec4dafaf2ed4072682145fdb3b1 100644 (file)
@@ -53,7 +53,7 @@ void imx_scu_standby_enable(void)
        writel_relaxed(val, scu_base);
 }
 
-static int __cpuinit imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int imx_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        imx_set_cpu_jump(cpu, v7_secondary_startup);
        imx_enable_cpu(cpu, true);
index fe4d9ff93a7ef8560cd6948aaa99720242df5865..b661c5c2870a88d09a76b51d7166650a693250ac 100644 (file)
@@ -49,7 +49,7 @@ static const char *keystone_match[] __initconst = {
        NULL,
 };
 
-void keystone_restart(char mode, const char *cmd)
+void keystone_restart(enum reboot_mode mode, const char *cmd)
 {
        u32 val;
 
index 1d4181e1daf2f83fafc38ce904dd2e14c5459af9..14378e3fef16309f2da2bb91ae6e558972bde938 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "keystone.h"
 
-static int __cpuinit keystone_smp_boot_secondary(unsigned int cpu,
+static int keystone_smp_boot_secondary(unsigned int cpu,
                                                struct task_struct *idle)
 {
        unsigned long start = virt_to_phys(&secondary_startup);
index 614e41e7881b538b77bc4c5ab0b5430de7175bea..905efc8cac797d5d30ae0db0ff0e28eba7fa140d 100644 (file)
@@ -121,8 +121,7 @@ config MSM_SMD
        bool
 
 config MSM_GPIOMUX
-       depends on !(ARCH_MSM8X60 || ARCH_MSM8960)
-       bool "MSM V1 TLMM GPIOMUX architecture"
+       bool
        help
          Support for MSM V1 TLMM GPIOMUX architecture.
 
diff --git a/arch/arm/mach-msm/gpiomux-v1.c b/arch/arm/mach-msm/gpiomux-v1.c
deleted file mode 100644 (file)
index 27de2ab..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-#include <linux/kernel.h>
-#include "gpiomux.h"
-#include "proc_comm.h"
-
-void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val)
-{
-       unsigned tlmm_config  = (val & ~GPIOMUX_CTL_MASK) |
-                               ((gpio & 0x3ff) << 4);
-       unsigned tlmm_disable = 0;
-       int rc;
-
-       rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX,
-                          &tlmm_config, &tlmm_disable);
-       if (rc)
-               pr_err("%s: unexpected proc_comm failure %d: %08x %08x\n",
-                      __func__, rc, tlmm_config, tlmm_disable);
-}
index 8e82f41a89235e4fbef3f7f2b7e0b7c26c84dbfc..4410d7766f93be5995c620c1c36cf2be8ce23877 100644 (file)
@@ -73,16 +73,6 @@ extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];
 int msm_gpiomux_write(unsigned gpio,
                      gpiomux_config_t active,
                      gpiomux_config_t suspended);
-
-/* Architecture-internal function for use by the framework only.
- * This function can assume the following:
- * - the gpio value has passed a bounds-check
- * - the gpiomux spinlock has been obtained
- *
- * This function is not for public consumption.  External users
- * should use msm_gpiomux_write.
- */
-void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);
 #else
 static inline int msm_gpiomux_write(unsigned gpio,
                                    gpiomux_config_t active,
index bcd5af223deabaf48451bf3a4d67cea23c82566e..6c62c3f82fe668b33cf5976a36edce8d572eb833 100644 (file)
@@ -11,8 +11,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __CPUINIT
-
 /*
  * MSM specific entry point for secondary CPUs.  This provides
  * a "holding pen" into which all secondary cores are held until we're
index 00cdb0a5dac8e7f81710922eb59795ffa1fe8f55..3f06edcdd0ce7a05e84aab9babd912a2033ffa97 100644 (file)
@@ -38,7 +38,7 @@ static inline int get_core_count(void)
        return ((read_cpuid_id() >> 4) & 3) + 1;
 }
 
-static void __cpuinit msm_secondary_init(unsigned int cpu)
+static void msm_secondary_init(unsigned int cpu)
 {
        /*
         * let the primary processor know we're out of the
@@ -54,7 +54,7 @@ static void __cpuinit msm_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-static __cpuinit void prepare_cold_cpu(unsigned int cpu)
+static void prepare_cold_cpu(unsigned int cpu)
 {
        int ret;
        ret = scm_set_boot_addr(virt_to_phys(msm_secondary_startup),
@@ -73,7 +73,7 @@ static __cpuinit void prepare_cold_cpu(unsigned int cpu)
                                  "address\n");
 }
 
-static int __cpuinit msm_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int msm_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
        static int cold_boot_done;
index b6418fd5fe0dc49eb6c6fbfef7d30b918ba2e193..8697cfc0d0b6a74538a59eaf92bd3266a10bab9f 100644 (file)
@@ -139,7 +139,7 @@ static struct clocksource msm_clocksource = {
 };
 
 #ifdef CONFIG_LOCAL_TIMERS
-static int __cpuinit msm_local_timer_setup(struct clock_event_device *evt)
+static int msm_local_timer_setup(struct clock_event_device *evt)
 {
        /* Use existing clock_event for cpu 0 */
        if (!smp_processor_id())
@@ -164,7 +164,7 @@ static void msm_local_timer_stop(struct clock_event_device *evt)
        disable_percpu_irq(evt->irq);
 }
 
-static struct local_timer_ops msm_local_timer_ops __cpuinitdata = {
+static struct local_timer_ops msm_local_timer_ops = {
        .setup  = msm_local_timer_setup,
        .stop   = msm_local_timer_stop,
 };
index be117591f7f256ca04c47c40d7fabd38aa081161..4c24303ec4816bfb6f1c4bc0695f57450a624517 100644 (file)
@@ -28,7 +28,7 @@
 #include <asm/cacheflush.h>
 #include "armada-370-xp.h"
 
-unsigned long __cpuinitdata coherency_phys_base;
+unsigned long coherency_phys_base;
 static void __iomem *coherency_base;
 static void __iomem *coherency_cpu_base;
 
index 7147300c8af25d20e90279632a1499f3e9dbb674..8a1b0c96e9ece9a05ba3c78a04e51c5d65c3f240 100644 (file)
@@ -21,8 +21,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __CPUINIT
-
 /*
  * Armada XP specific entry point for secondary CPUs.
  * We add the CPU to the coherency fabric and then jump to secondary
index 93f2f3ab45f1346925dc0a17db326a23e553ca1c..ce81d303140598debb8e5cb9c6bb557e28268f49 100644 (file)
@@ -71,13 +71,12 @@ void __init set_secondary_cpus_clock(void)
        }
 }
 
-static void __cpuinit armada_xp_secondary_init(unsigned int cpu)
+static void armada_xp_secondary_init(unsigned int cpu)
 {
        armada_xp_mpic_smp_cpu_init();
 }
 
-static int __cpuinit armada_xp_boot_secondary(unsigned int cpu,
-                                             struct task_struct *idle)
+static int armada_xp_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        pr_info("Booting CPU %d\n", cpu);
 
index 627fa7e41fbabbeccf38c1703dc26ed2a98d66db..3eed0006d189c0c0e88412485dba67e1800b2d6e 100644 (file)
@@ -62,7 +62,7 @@ config SOC_OMAP5
        select HAVE_SMP
        select COMMON_CLK
        select HAVE_ARM_ARCH_TIMER
-       select ARM_ERRATA_798181
+       select ARM_ERRATA_798181 if SMP
 
 config SOC_AM33XX
        bool "AM33XX support"
index e5fbfed69aa2bc5094b508a3219c8988d0d3dbe7..be5d005ebad2866ea7432586beba45e000330be9 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/irqdomain.h>
+#include <linux/clk.h>
 
 #include <asm/mach/arch.h>
 
@@ -35,6 +36,21 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
        { }
 };
 
+/*
+ * Create alias for USB host PHY clock.
+ * Remove this when clock phandle can be provided via DT
+ */
+static void __init legacy_init_ehci_clk(char *clkname)
+{
+       int ret;
+
+       ret = clk_add_alias("main_clk", NULL, clkname, NULL);
+       if (ret) {
+               pr_err("%s:Failed to add main_clk alias to %s :%d\n",
+                                               __func__, clkname, ret);
+       }
+}
+
 static void __init omap_generic_init(void)
 {
        omap_sdrc_init(NULL, NULL);
@@ -45,10 +61,15 @@ static void __init omap_generic_init(void)
         * HACK: call display setup code for selected boards to enable omapdss.
         * This will be removed when omapdss supports DT.
         */
-       if (of_machine_is_compatible("ti,omap4-panda"))
+       if (of_machine_is_compatible("ti,omap4-panda")) {
                omap4_panda_display_init_of();
+               legacy_init_ehci_clk("auxclk3_ck");
+
+       }
        else if (of_machine_is_compatible("ti,omap4-sdp"))
                omap_4430sdp_display_init_of();
+       else if (of_machine_is_compatible("ti,omap5-uevm"))
+               legacy_init_ehci_clk("auxclk1_ck");
 }
 
 #ifdef CONFIG_SOC_OMAP2420
index f6eeb87e4e955e425903475b733328656ffcaeda..827d15009a86c980a9577ad8951c2a94e0cbd17d 100644 (file)
@@ -122,11 +122,7 @@ static struct musb_hdrc_config musb_config = {
 };
 
 static struct musb_hdrc_platform_data tusb_data = {
-#ifdef CONFIG_USB_GADGET_MUSB_HDRC
        .mode           = MUSB_OTG,
-#else
-       .mode           = MUSB_HOST,
-#endif
        .set_power      = tusb_set_power,
        .min_power      = 25,   /* x2 = 50 mA drawn from VBUS as peripheral */
        .power          = 100,  /* Max 100 mA VBUS for host mode */
index d2ea68ea678af901715aa609b4c5f41175641ddf..7735105561d87dd218c436b357ade5211e5a6d2e 100644 (file)
@@ -85,7 +85,7 @@ static struct omap_board_mux board_mux[] __initdata = {
 
 static struct omap_musb_board_data musb_board_data = {
        .interface_type         = MUSB_INTERFACE_ULPI,
-       .mode                   = MUSB_PERIPHERAL,
+       .mode                   = MUSB_OTG,
        .power                  = 0,
 };
 
index 393aeefaebb05ebe28f903083501de2461b2eaf3..043e5705f2a60ce3c6ffecf70fad28be592ec214 100644 (file)
@@ -42,7 +42,7 @@
 
 /* Using generic display panel */
 static struct tfp410_platform_data omap4_dvi_panel = {
-       .i2c_bus_num            = 3,
+       .i2c_bus_num            = 2,
        .power_down_gpio        = PANDA_DVI_TFP410_POWER_DOWN_GPIO,
 };
 
index 4ea308114165689e1638eca94f1099d436cce803..75e92952c18efe3e597791e6798c2ee2ce5969a1 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "omap44xx.h"
 
-       __CPUINIT
-
 /* Physical address needed since MMU not enabled yet on secondary core */
 #define AUX_CORE_BOOT0_PA                      0x48281800
 
index f993a41887010f726e7bee233f3bb80754cc4a47..f991016e2a6ac38a6f444b48c31dac4a2e0cc332 100644 (file)
@@ -291,7 +291,7 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
  * @cpu : CPU ID
  * @power_state: CPU low power state.
  */
-int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
+int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
 {
        struct omap4_cpu_pm_info *pm_info = &per_cpu(omap4_pm_info, cpu);
        unsigned int cpu_state = 0;
index 98a11463a843afdaca3ef99680e0a7c785d5fc33..8708b2a9da453e91be9bc16590d48e9652b35508 100644 (file)
@@ -51,7 +51,7 @@ void __iomem *omap4_get_scu_base(void)
        return scu_base;
 }
 
-static void __cpuinit omap4_secondary_init(unsigned int cpu)
+static void omap4_secondary_init(unsigned int cpu)
 {
        /*
         * Configure ACTRL and enable NS SMP bit access on CPU1 on HS device.
@@ -72,7 +72,7 @@ static void __cpuinit omap4_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-static int __cpuinit omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        static struct clockdomain *cpu1_clkdm;
        static bool booted;
index f8bb3b9b6a76238af322ea1e9ee4fde52b7ac46b..813c61558a5fcc70dfafea59a2a7d14c5b893c10 100644 (file)
@@ -323,8 +323,8 @@ static void irq_save_secure_context(void)
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
-                                        unsigned long action, void *hcpu)
+static int irq_cpu_hotplug_notify(struct notifier_block *self,
+                                 unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned int)hcpu;
 
index 5cc92874be7e6f22d81767c0f75e141376ab83d6..f99f68e1e85bd3748c5965a0bd27c47d0f6d538e 100644 (file)
@@ -129,6 +129,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
        struct device_node *node = pdev->dev.of_node;
        const char *oh_name;
        int oh_cnt, i, ret = 0;
+       bool device_active = false;
 
        oh_cnt = of_property_count_strings(node, "ti,hwmods");
        if (oh_cnt <= 0) {
@@ -152,6 +153,8 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
                        goto odbfd_exit1;
                }
                hwmods[i] = oh;
+               if (oh->flags & HWMOD_INIT_NO_IDLE)
+                       device_active = true;
        }
 
        od = omap_device_alloc(pdev, hwmods, oh_cnt);
@@ -172,6 +175,11 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
 
        pdev->dev.pm_domain = &omap_device_pm_domain;
 
+       if (device_active) {
+               omap_device_enable(pdev);
+               pm_runtime_set_active(&pdev->dev);
+       }
+
 odbfd_exit1:
        kfree(hwmods);
 odbfd_exit:
@@ -842,6 +850,7 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct omap_device *od = to_omap_device(pdev);
+       int i;
 
        if (!od)
                return 0;
@@ -850,6 +859,15 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
         * If omap_device state is enabled, but has no driver bound,
         * idle it.
         */
+
+       /*
+        * Some devices (like memory controllers) are always kept
+        * enabled, and should not be idled even with no drivers.
+        */
+       for (i = 0; i < od->hwmods_cnt; i++)
+               if (od->hwmods[i]->flags & HWMOD_INIT_NO_IDLE)
+                       return 0;
+
        if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) {
                if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
                        dev_warn(dev, "%s: enabled but no driver.  Idling\n",
index 7341eff63f56df8f58d5b72d8db9a71feb86112d..7f4db12b1459881ddc2fcbf66d404bab28d89792 100644 (file)
@@ -2386,7 +2386,7 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
 
                np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh);
                if (np)
-                       va_start = of_iomap(np, 0);
+                       va_start = of_iomap(np, oh->mpu_rt_idx);
        } else {
                va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
        }
index aab33fd814c0329e178cbfe265fdf9ff5ffb766c..e1482a9b3bc22f7cd7de82ac9f66474e1efbccc8 100644 (file)
@@ -95,6 +95,54 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type3;
 #define MODULEMODE_HWCTRL              1
 #define MODULEMODE_SWCTRL              2
 
+#define DEBUG_OMAP2UART1_FLAGS 0
+#define DEBUG_OMAP2UART2_FLAGS 0
+#define DEBUG_OMAP2UART3_FLAGS 0
+#define DEBUG_OMAP3UART3_FLAGS 0
+#define DEBUG_OMAP3UART4_FLAGS 0
+#define DEBUG_OMAP4UART3_FLAGS 0
+#define DEBUG_OMAP4UART4_FLAGS 0
+#define DEBUG_TI81XXUART1_FLAGS        0
+#define DEBUG_TI81XXUART2_FLAGS        0
+#define DEBUG_TI81XXUART3_FLAGS        0
+#define DEBUG_AM33XXUART1_FLAGS        0
+
+#define DEBUG_OMAPUART_FLAGS   (HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET)
+
+#if defined(CONFIG_DEBUG_OMAP2UART1)
+#undef DEBUG_OMAP2UART1_FLAGS
+#define DEBUG_OMAP2UART1_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_OMAP2UART2)
+#undef DEBUG_OMAP2UART2_FLAGS
+#define DEBUG_OMAP2UART2_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_OMAP2UART3)
+#undef DEBUG_OMAP2UART3_FLAGS
+#define DEBUG_OMAP2UART3_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_OMAP3UART3)
+#undef DEBUG_OMAP3UART3_FLAGS
+#define DEBUG_OMAP3UART3_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_OMAP3UART4)
+#undef DEBUG_OMAP3UART4_FLAGS
+#define DEBUG_OMAP3UART4_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_OMAP4UART3)
+#undef DEBUG_OMAP4UART3_FLAGS
+#define DEBUG_OMAP4UART3_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_OMAP4UART4)
+#undef DEBUG_OMAP4UART4_FLAGS
+#define DEBUG_OMAP4UART4_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_TI81XXUART1)
+#undef DEBUG_TI81XXUART1_FLAGS
+#define DEBUG_TI81XXUART1_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_TI81XXUART2)
+#undef DEBUG_TI81XXUART2_FLAGS
+#define DEBUG_TI81XXUART2_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_TI81XXUART3)
+#undef DEBUG_TI81XXUART3_FLAGS
+#define DEBUG_TI81XXUART3_FLAGS DEBUG_OMAPUART_FLAGS
+#elif defined(CONFIG_DEBUG_AM33XXUART1)
+#undef DEBUG_AM33XXUART1_FLAGS
+#define DEBUG_AM33XXUART1_FLAGS DEBUG_OMAPUART_FLAGS
+#endif
 
 /**
  * struct omap_hwmod_mux_info - hwmod specific mux configuration
@@ -568,6 +616,7 @@ struct omap_hwmod_link {
  * @voltdm: pointer to voltage domain (filled in at runtime)
  * @dev_attr: arbitrary device attributes that can be passed to the driver
  * @_sysc_cache: internal-use hwmod flags
+ * @mpu_rt_idx: index of device address space for register target (for DT boot)
  * @_mpu_rt_va: cached register target start address (internal use)
  * @_mpu_port: cached MPU register target slave (internal use)
  * @opt_clks_cnt: number of @opt_clks
@@ -617,6 +666,7 @@ struct omap_hwmod {
        struct list_head                node;
        struct omap_hwmod_ocp_if        *_mpu_port;
        u16                             flags;
+       u8                              mpu_rt_idx;
        u8                              response_lat;
        u8                              rst_lines_cnt;
        u8                              opt_clks_cnt;
index d05fc7b54567f0dbb6597a1d641ce130caf7ee9b..56cebb05509e15c0054f342e158a21214b7a6603 100644 (file)
@@ -512,7 +512,7 @@ struct omap_hwmod omap2xxx_uart1_hwmod = {
        .mpu_irqs       = omap2_uart1_mpu_irqs,
        .sdma_reqs      = omap2_uart1_sdma_reqs,
        .main_clk       = "uart1_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP2UART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = CORE_MOD,
@@ -532,7 +532,7 @@ struct omap_hwmod omap2xxx_uart2_hwmod = {
        .mpu_irqs       = omap2_uart2_mpu_irqs,
        .sdma_reqs      = omap2_uart2_sdma_reqs,
        .main_clk       = "uart2_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP2UART2_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = CORE_MOD,
@@ -552,7 +552,7 @@ struct omap_hwmod omap2xxx_uart3_hwmod = {
        .mpu_irqs       = omap2_uart3_mpu_irqs,
        .sdma_reqs      = omap2_uart3_sdma_reqs,
        .main_clk       = "uart3_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP2UART3_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = CORE_MOD,
index 28bbd56346a93ab67fc377eb1ea066a8be8280f7..eb2f3b93b51c9a4d7ce32eed8f23d63cb3083d33 100644 (file)
@@ -562,6 +562,7 @@ static struct omap_hwmod am33xx_cpgmac0_hwmod = {
        .clkdm_name     = "cpsw_125mhz_clkdm",
        .flags          = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY),
        .main_clk       = "cpsw_125mhz_gclk",
+       .mpu_rt_idx     = 1,
        .prcm           = {
                .omap4  = {
                        .clkctrl_offs   = AM33XX_CM_PER_CPGMAC0_CLKCTRL_OFFSET,
@@ -1512,7 +1513,7 @@ static struct omap_hwmod am33xx_uart1_hwmod = {
        .name           = "uart1",
        .class          = &uart_class,
        .clkdm_name     = "l4_wkup_clkdm",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_AM33XXUART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .main_clk       = "dpll_per_m2_div4_wkupdm_ck",
        .prcm           = {
                .omap4  = {
index f7a3df2fb579613a761f9a484dbb0254cadcda9c..0c3a427da5445a5d2f990e05f2f3fcec50634143 100644 (file)
@@ -490,7 +490,7 @@ static struct omap_hwmod omap3xxx_uart1_hwmod = {
        .mpu_irqs       = omap2_uart1_mpu_irqs,
        .sdma_reqs      = omap2_uart1_sdma_reqs,
        .main_clk       = "uart1_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_TI81XXUART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = CORE_MOD,
@@ -509,7 +509,7 @@ static struct omap_hwmod omap3xxx_uart2_hwmod = {
        .mpu_irqs       = omap2_uart2_mpu_irqs,
        .sdma_reqs      = omap2_uart2_sdma_reqs,
        .main_clk       = "uart2_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_TI81XXUART2_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = CORE_MOD,
@@ -528,7 +528,8 @@ static struct omap_hwmod omap3xxx_uart3_hwmod = {
        .mpu_irqs       = omap2_uart3_mpu_irqs,
        .sdma_reqs      = omap2_uart3_sdma_reqs,
        .main_clk       = "uart3_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP3UART3_FLAGS | DEBUG_TI81XXUART3_FLAGS |
+                               HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = OMAP3430_PER_MOD,
@@ -558,7 +559,7 @@ static struct omap_hwmod omap36xx_uart4_hwmod = {
        .mpu_irqs       = uart4_mpu_irqs,
        .sdma_reqs      = uart4_sdma_reqs,
        .main_clk       = "uart4_fck",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP3UART4_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .prcm           = {
                .omap2 = {
                        .module_offs = OMAP3430_PER_MOD,
index d04b5e60fdbec74c6accf27c349a79f07a8c01fb..9c3b504477d7b341b4492ec350bb3404769fa219 100644 (file)
@@ -2858,8 +2858,7 @@ static struct omap_hwmod omap44xx_uart3_hwmod = {
        .name           = "uart3",
        .class          = &omap44xx_uart_hwmod_class,
        .clkdm_name     = "l4_per_clkdm",
-       .flags          = HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET |
-                               HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP4UART3_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .main_clk       = "func_48m_fclk",
        .prcm = {
                .omap4 = {
@@ -2875,7 +2874,7 @@ static struct omap_hwmod omap44xx_uart4_hwmod = {
        .name           = "uart4",
        .class          = &omap44xx_uart_hwmod_class,
        .clkdm_name     = "l4_per_clkdm",
-       .flags          = HWMOD_SWSUP_SIDLE_ACT,
+       .flags          = DEBUG_OMAP4UART4_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
        .main_clk       = "func_48m_fclk",
        .prcm = {
                .omap4 = {
index f37ae96b70a1a9e2c67085b2a0a466992358a4e6..3c70f5c1860fc2b96401fe6ad1256c1a975539e0 100644 (file)
@@ -1375,7 +1375,7 @@ static struct omap_hwmod omap54xx_uart3_hwmod = {
        .name           = "uart3",
        .class          = &omap54xx_uart_hwmod_class,
        .clkdm_name     = "l4per_clkdm",
-       .flags          = HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET,
+       .flags          = DEBUG_OMAP4UART3_FLAGS,
        .main_clk       = "func_48m_fclk",
        .prcm = {
                .omap4 = {
@@ -1391,6 +1391,7 @@ static struct omap_hwmod omap54xx_uart4_hwmod = {
        .name           = "uart4",
        .class          = &omap54xx_uart_hwmod_class,
        .clkdm_name     = "l4per_clkdm",
+       .flags          = DEBUG_OMAP4UART4_FLAGS,
        .main_clk       = "func_48m_fclk",
        .prcm = {
                .omap4 = {
index 3a674de6cb632d21dade993c9e0cb3ca2c7babd8..a388f8c1bcb3cb2c69a199613ee3710eeb333c7b 100644 (file)
@@ -208,17 +208,6 @@ static int __init omap_serial_early_init(void)
                                pr_info("%s used as console in debug mode: uart%d clocks will not be gated",
                                        uart_name, uart->num);
                        }
-
-                       /*
-                        * omap-uart can be used for earlyprintk logs
-                        * So if omap-uart is used as console then prevent
-                        * uart reset and idle to get logs from omap-uart
-                        * until uart console driver is available to take
-                        * care for console messages.
-                        * Idling or resetting omap-uart while printing logs
-                        * early boot logs can stall the boot-up.
-                        */
-                       oh->flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
                }
        } while (1);
 
index 8c4de2708cf28e6bf5f0011392c5fb15bbcb60fe..bc897231bd1098714ca602e7763442671e9f2fe5 100644 (file)
@@ -38,11 +38,8 @@ static struct musb_hdrc_config musb_config = {
 };
 
 static struct musb_hdrc_platform_data musb_plat = {
-#ifdef CONFIG_USB_GADGET_MUSB_HDRC
        .mode           = MUSB_OTG,
-#else
-       .mode           = MUSB_HOST,
-#endif
+
        /* .clock is set dynamically */
        .config         = &musb_config,
 
index 5b8a408d892173266bd2fc39c820e2104cd4ad17..d86fe33c5f538a206ed26421b54482d9058b1b3b 100644 (file)
@@ -9,8 +9,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __CPUINIT
-
 /*
  * SIRFSOC specific entry point for secondary CPUs.  This provides
  * a "holding pen" into which all secondary cores are held until we're
index 1c3de7bed841328a2f2d0020962a7e54309b2ced..3dbcb1ab6e37e5ea5eeedcc05c27e45b9e14ac2b 100644 (file)
@@ -44,7 +44,7 @@ void __init sirfsoc_map_scu(void)
        scu_base = (void __iomem *)SIRFSOC_VA(base);
 }
 
-static void __cpuinit sirfsoc_secondary_init(unsigned int cpu)
+static void sirfsoc_secondary_init(unsigned int cpu)
 {
        /*
         * let the primary processor know we're out of the
@@ -65,7 +65,7 @@ static struct of_device_id rsc_ids[]  = {
        {},
 };
 
-static int __cpuinit sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
        struct device_node *np;
index f6726bb4eb954bf1cdaf073b4940269137673916..3a3362fa793edd06e2dab0f4d88d08c8a1af4d0f 100644 (file)
@@ -477,16 +477,24 @@ static int em_x270_usb_hub_init(void)
        /* USB Hub power-on and reset */
        gpio_direction_output(usb_hub_reset, 1);
        gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
-       regulator_enable(em_x270_usb_ldo);
+       err = regulator_enable(em_x270_usb_ldo);
+       if (err)
+               goto err_free_rst_gpio;
+
        gpio_set_value(usb_hub_reset, 0);
        gpio_set_value(usb_hub_reset, 1);
        regulator_disable(em_x270_usb_ldo);
-       regulator_enable(em_x270_usb_ldo);
+       err = regulator_enable(em_x270_usb_ldo);
+       if (err)
+               goto err_free_rst_gpio;
+
        gpio_set_value(usb_hub_reset, 0);
        gpio_set_value(GPIO9_USB_VBUS_EN, 1);
 
        return 0;
 
+err_free_rst_gpio:
+       gpio_free(usb_hub_reset);
 err_free_vbus_gpio:
        gpio_free(GPIO9_USB_VBUS_EN);
 err_free_usb_ldo:
@@ -592,7 +600,7 @@ err_irq:
        return err;
 }
 
-static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
+static int em_x270_mci_setpower(struct device *dev, unsigned int vdd)
 {
        struct pxamci_platform_data* p_d = dev->platform_data;
 
@@ -600,10 +608,11 @@ static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
                int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
 
                regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
-               regulator_enable(em_x270_sdio_ldo);
+               return regulator_enable(em_x270_sdio_ldo);
        } else {
                regulator_disable(em_x270_sdio_ldo);
        }
+       return 0;
 }
 
 static void em_x270_mci_exit(struct device *dev, void *data)
index fe31bfcbb8dfb6b8c3112c7fe7ce65442a178b26..c98511c5abd10003818c0950841c3f7a4d0a3fd4 100644 (file)
@@ -73,9 +73,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
 
 static struct mcp251x_platform_data mcp251x_info = {
        .oscillator_frequency = 16E6,
-       .board_specific_setup = NULL,
-       .power_enable         = NULL,
-       .transceiver_enable   = NULL
 };
 
 static struct spi_board_info mcp251x_board_info[] = {
index d2c6523183764c2e809076bca2fc527826a209b1..dd70343c87085edf4da384fedd434a339802756c 100644 (file)
@@ -408,7 +408,7 @@ static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_in
        return err;
 }
 
-static void mainstone_mci_setpower(struct device *dev, unsigned int vdd)
+static int mainstone_mci_setpower(struct device *dev, unsigned int vdd)
 {
        struct pxamci_platform_data* p_d = dev->platform_data;
 
@@ -420,6 +420,7 @@ static void mainstone_mci_setpower(struct device *dev, unsigned int vdd)
                printk(KERN_DEBUG "%s: off\n", __func__);
                MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON;
        }
+       return 0;
 }
 
 static void mainstone_mci_exit(struct device *dev, void *data)
index fb7f1d1627dc1d11863ae4bcaeeabb0bccda4524..13e5b00eae900beb689a2c0293be84600913a890 100644 (file)
@@ -335,7 +335,7 @@ static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int,
        return err;
 }
 
-static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
+static int pcm990_mci_setpower(struct device *dev, unsigned int vdd)
 {
        struct pxamci_platform_data *p_d = dev->platform_data;
        u8 val;
@@ -348,6 +348,7 @@ static void pcm990_mci_setpower(struct device *dev, unsigned int vdd)
                val &= ~PCM990_CTRL_MMC2PWR;
 
        pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5);
+       return 0;
 }
 
 static void pcm990_mci_exit(struct device *dev, void *data)
index 711d37e26bd8111b1b4821c849b96394cc4f102b..aedf053a1de5ccac5f3505c93f802ef6dadbe50a 100644 (file)
@@ -258,7 +258,7 @@ err_free_2:
        return err;
 }
 
-static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
+static int poodle_mci_setpower(struct device *dev, unsigned int vdd)
 {
        struct pxamci_platform_data* p_d = dev->platform_data;
 
@@ -270,6 +270,8 @@ static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
                gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
                gpio_set_value(POODLE_GPIO_SD_PWR, 0);
        }
+
+       return 0;
 }
 
 static void poodle_mci_exit(struct device *dev, void *data)
index 2125df0444e7be24f7aa1e3c6ce153fe0b78655c..4c29173026e8e67ff6ec0409f1862e205e5ffc4c 100644 (file)
@@ -598,7 +598,7 @@ static inline void spitz_spi_init(void) {}
  * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to
  * give the card a chance to fully insert/eject.
  */
-static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
+static int spitz_mci_setpower(struct device *dev, unsigned int vdd)
 {
        struct pxamci_platform_data* p_d = dev->platform_data;
 
@@ -606,6 +606,8 @@ static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
                spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V);
        else
                spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0);
+
+       return 0;
 }
 
 static struct pxamci_platform_data spitz_mci_platform_data = {
index 88fde43c948c740a1bccd8f2520d4d3a8dc63f98..62aea3e835f315266ba887367310ec249503cd21 100644 (file)
@@ -734,9 +734,10 @@ static int stargate2_mci_init(struct device *dev,
  *
  * Very simple control. Either it is on or off and is controlled by
  * a gpio pin */
-static void stargate2_mci_setpower(struct device *dev, unsigned int vdd)
+static int stargate2_mci_setpower(struct device *dev, unsigned int vdd)
 {
        gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
+       return 0;
 }
 
 static void stargate2_mci_exit(struct device *dev, void *data)
index f5d4364345661ee0fc620653a72305beb539fc44..04a0aea238730b0ec4bb5426f66c3e0266ac6de6 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/i2c/pca953x.h>
 #include <linux/apm-emulation.h>
 #include <linux/can/platform/mcp251x.h>
+#include <linux/regulator/fixed.h>
+#include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
 #include <asm/suspend.h>
@@ -391,33 +393,34 @@ static struct pxa2xx_spi_master pxa2xx_spi_ssp3_master_info = {
 };
 
 /* CAN bus on SPI */
-static int zeus_mcp2515_setup(struct spi_device *sdev)
-{
-       int err;
-
-       err = gpio_request(ZEUS_CAN_SHDN_GPIO, "CAN shutdown");
-       if (err)
-               return err;
+static struct regulator_consumer_supply can_regulator_consumer =
+       REGULATOR_SUPPLY("vdd", "spi3.0");
 
-       err = gpio_direction_output(ZEUS_CAN_SHDN_GPIO, 1);
-       if (err) {
-               gpio_free(ZEUS_CAN_SHDN_GPIO);
-               return err;
-       }
+static struct regulator_init_data can_regulator_init_data = {
+       .constraints    = {
+               .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+       },
+       .consumer_supplies      = &can_regulator_consumer,
+       .num_consumer_supplies  = 1,
+};
 
-       return 0;
-}
+static struct fixed_voltage_config can_regulator_pdata = {
+       .supply_name    = "CAN_SHDN",
+       .microvolts     = 3300000,
+       .gpio           = ZEUS_CAN_SHDN_GPIO,
+       .init_data      = &can_regulator_init_data,
+};
 
-static int zeus_mcp2515_transceiver_enable(int enable)
-{
-       gpio_set_value(ZEUS_CAN_SHDN_GPIO, !enable);
-       return 0;
-}
+static struct platform_device can_regulator_device = {
+       .name   = "reg-fixed-volage",
+       .id     = -1,
+       .dev    = {
+               .platform_data  = &can_regulator_pdata,
+       },
+};
 
 static struct mcp251x_platform_data zeus_mcp2515_pdata = {
        .oscillator_frequency   = 16*1000*1000,
-       .board_specific_setup   = zeus_mcp2515_setup,
-       .power_enable           = zeus_mcp2515_transceiver_enable,
 };
 
 static struct spi_board_info zeus_spi_board_info[] = {
@@ -516,6 +519,7 @@ static struct platform_device *zeus_devices[] __initdata = {
        &zeus_leds_device,
        &zeus_pcmcia_device,
        &zeus_max6369_device,
+       &can_regulator_device,
 };
 
 /* AC'97 */
index 6d9252e081ce39af2b2e94452b36a6402c429197..7791ac76f945264e0d1cf2f88e3cbe49103b80e5 100644 (file)
@@ -208,7 +208,7 @@ config S3C24XX_GPIO_EXTRA128
 
 config S3C24XX_PLL
        bool "Support CPUfreq changing of PLL frequency (EXPERIMENTAL)"
-       depends on ARM_S3C24XX
+       depends on ARM_S3C24XX_CPUFREQ
        help
          Compile in support for changing the PLL frequency from the
          S3C24XX series CPUfreq driver. The PLL takes time to settle
index 34fffdf6fc1dc4b7f699418976e0b3d943c512a6..564553694b543d24df4eca3fa6a305c59520ce79 100644 (file)
@@ -119,66 +119,101 @@ static struct clk init_clocks_off[] = {
        }
 };
 
-static struct clk init_clocks[] = {
-       {
-               .name           = "lcd",
-               .parent         = &clk_h,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_LCDC,
-       }, {
-               .name           = "gpio",
-               .parent         = &clk_p,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_GPIO,
-       }, {
-               .name           = "usb-host",
-               .parent         = &clk_h,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_USBH,
-       }, {
-               .name           = "usb-device",
-               .parent         = &clk_h,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_USBD,
-       }, {
-               .name           = "timers",
-               .parent         = &clk_p,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_PWMT,
-       }, {
-               .name           = "uart",
-               .devname        = "s3c2410-uart.0",
-               .parent         = &clk_p,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_UART0,
-       }, {
-               .name           = "uart",
-               .devname        = "s3c2410-uart.1",
-               .parent         = &clk_p,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_UART1,
-       }, {
-               .name           = "uart",
-               .devname        = "s3c2410-uart.2",
-               .parent         = &clk_p,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_UART2,
-       }, {
-               .name           = "rtc",
-               .parent         = &clk_p,
-               .enable         = s3c2410_clkcon_enable,
-               .ctrlbit        = S3C2410_CLKCON_RTC,
-       }, {
-               .name           = "watchdog",
-               .parent         = &clk_p,
-               .ctrlbit        = 0,
-       }, {
-               .name           = "usb-bus-host",
-               .parent         = &clk_usb_bus,
-       }, {
-               .name           = "usb-bus-gadget",
-               .parent         = &clk_usb_bus,
-       },
+static struct clk clk_lcd = {
+       .name           = "lcd",
+       .parent         = &clk_h,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_LCDC,
+};
+
+static struct clk clk_gpio = {
+       .name           = "gpio",
+       .parent         = &clk_p,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_GPIO,
+};
+
+static struct clk clk_usb_host = {
+       .name           = "usb-host",
+       .parent         = &clk_h,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_USBH,
+};
+
+static struct clk clk_usb_device = {
+       .name           = "usb-device",
+       .parent         = &clk_h,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_USBD,
+};
+
+static struct clk clk_timers = {
+       .name           = "timers",
+       .parent         = &clk_p,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_PWMT,
+};
+
+struct clk s3c24xx_clk_uart0 = {
+       .name           = "uart",
+       .devname        = "s3c2410-uart.0",
+       .parent         = &clk_p,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_UART0,
+};
+
+struct clk s3c24xx_clk_uart1 = {
+       .name           = "uart",
+       .devname        = "s3c2410-uart.1",
+       .parent         = &clk_p,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_UART1,
+};
+
+struct clk s3c24xx_clk_uart2 = {
+       .name           = "uart",
+       .devname        = "s3c2410-uart.2",
+       .parent         = &clk_p,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_UART2,
+};
+
+static struct clk clk_rtc = {
+       .name           = "rtc",
+       .parent         = &clk_p,
+       .enable         = s3c2410_clkcon_enable,
+       .ctrlbit        = S3C2410_CLKCON_RTC,
+};
+
+static struct clk clk_watchdog = {
+       .name           = "watchdog",
+       .parent         = &clk_p,
+       .ctrlbit        = 0,
+};
+
+static struct clk clk_usb_bus_host = {
+       .name           = "usb-bus-host",
+       .parent         = &clk_usb_bus,
+};
+
+static struct clk clk_usb_bus_gadget = {
+       .name           = "usb-bus-gadget",
+       .parent         = &clk_usb_bus,
+};
+
+static struct clk *init_clocks[] = {
+       &clk_lcd,
+       &clk_gpio,
+       &clk_usb_host,
+       &clk_usb_device,
+       &clk_timers,
+       &s3c24xx_clk_uart0,
+       &s3c24xx_clk_uart1,
+       &s3c24xx_clk_uart2,
+       &clk_rtc,
+       &clk_watchdog,
+       &clk_usb_bus_host,
+       &clk_usb_bus_gadget,
 };
 
 /* s3c2410_baseclk_add()
@@ -195,7 +230,6 @@ int __init s3c2410_baseclk_add(void)
 {
        unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
        unsigned long clkcon  = __raw_readl(S3C2410_CLKCON);
-       struct clk *clkp;
        struct clk *xtal;
        int ret;
        int ptr;
@@ -207,8 +241,9 @@ int __init s3c2410_baseclk_add(void)
 
        /* register clocks from clock array */
 
-       clkp = init_clocks;
-       for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) {
+       for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++) {
+               struct clk *clkp = init_clocks[ptr];
+
                /* ensure that we note the clock state */
 
                clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0;
index 1069b56808265b5efaf9877b9ed6a1b7dc5ea833..aaf006d1d6dc9ec6111ae080e3e4f15350615561 100644 (file)
@@ -166,6 +166,9 @@ static struct clk_lookup s3c2440_clk_lookup[] = {
        CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk),
        CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p),
        CLKDEV_INIT(NULL, "clk_uart_baud3", &s3c2440_clk_fclk_n),
+       CLKDEV_INIT("s3c2440-uart.0", "uart", &s3c24xx_clk_uart0),
+       CLKDEV_INIT("s3c2440-uart.1", "uart", &s3c24xx_clk_uart1),
+       CLKDEV_INIT("s3c2440-uart.2", "uart", &s3c24xx_clk_uart2),
        CLKDEV_INIT("s3c2440-camif", "camera", &s3c2440_clk_cam_upll),
 };
 
index e115f67421078cd7390cc2cc92a6b0ae43c4b36c..3a6ffa250fb19c7221b127e231c3b2091720270d 100644 (file)
@@ -358,7 +358,6 @@ static struct platform_device usbhsf_device = {
 static struct sh_eth_plat_data sh_eth_platdata = {
        .phy                    = 0x00, /* LAN8710A */
        .edmac_endian           = EDMAC_LITTLE_ENDIAN,
-       .register_type          = SH_ETH_REG_GIGABIT,
        .phy_interface          = PHY_INTERFACE_MODE_MII,
 };
 
@@ -1162,9 +1161,6 @@ static void __init eva_init(void)
        gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
        gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */
 
-       /* Touchscreen */
-       gpio_request_one(166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */
-
        /* GETHER */
        gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */
 
index d5554646916c34a962a9e1790653fc22d8beefd0..fa8885b2d5a5fda2c345a23cfd75973c87a22c50 100644 (file)
@@ -89,7 +89,6 @@ static struct sh_mobile_sdhi_info sdhi0_info = {
 static struct sh_eth_plat_data ether_platform_data __initdata = {
        .phy            = 0x01,
        .edmac_endian   = EDMAC_LITTLE_ENDIAN,
-       .register_type  = SH_ETH_REG_FAST_RCAR,
        .phy_interface  = PHY_INTERFACE_MODE_RMII,
        /*
         * Although the LINK signal is available on the board, it's connected to
@@ -167,7 +166,13 @@ static const struct pinctrl_map bockw_pinctrl_map[] = {
                                  "usb1", "usb1"),
        /* SDHI0 */
        PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
-                                 "sdhi0", "sdhi0"),
+                                 "sdhi0_data4", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
+                                 "sdhi0_ctrl", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
+                                 "sdhi0_cd", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
+                                 "sdhi0_wp", "sdhi0"),
 };
 
 #define FPGA   0x18200000
index d73e21d3ea8ad9cf036483262a2010334ec0e062..8d6bd5c5efb9cd092fe4dd857057a1e6f59b9420 100644 (file)
@@ -59,7 +59,7 @@ static __initdata struct gpio_led_platform_data lager_leds_pdata = {
 #define GPIO_KEY(c, g, d, ...) \
        { .code = c, .gpio = g, .desc = d, .active_low = 1 }
 
-static __initdata struct gpio_keys_button gpio_buttons[] = {
+static struct gpio_keys_button gpio_buttons[] = {
        GPIO_KEY(KEY_4,         RCAR_GP_PIN(1, 28),     "SW2-pin4"),
        GPIO_KEY(KEY_3,         RCAR_GP_PIN(1, 26),     "SW2-pin3"),
        GPIO_KEY(KEY_2,         RCAR_GP_PIN(1, 24),     "SW2-pin2"),
index 6f986546725892df07a62fd097ab363a4e7270f7..bfd920083a3b294db1808d1cf9a145d2d6afa59e 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/init.h>
 #include <asm/memory.h>
 
-       __CPUINIT
 /*
  * Boot code for secondary CPUs.
  *
index 559d1ce5f57ee0a47ffbea3d1332b41aca0fc03d..a9d21249898701f2838507b5c7e5096a2874bccd 100644 (file)
@@ -14,8 +14,6 @@
 #include <linux/init.h>
 #include <asm/memory.h>
 
-       __CPUINIT
-
 ENTRY(shmobile_invalidate_start)
        bl      v7_invalidate_l1
        b       secondary_startup
index 80991b35f4ac0af6a7878c3e79cc97d2704995fb..22a05a869d2559ddf26bd2f3666f746218280d69 100644 (file)
@@ -30,7 +30,7 @@
 
 #define EMEV2_SCU_BASE 0x1e000000
 
-static int __cpuinit emev2_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int emev2_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        arch_send_wakeup_ipi_mask(cpumask_of(cpu_logical_map(cpu)));
        return 0;
index 526cfaae81c1bd35897735db73aa309cbe30028f..9bdf810f2a87489677394138a47f54f121bc3f91 100644 (file)
@@ -81,7 +81,7 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu)
        return ret ? ret : 1;
 }
 
-static int __cpuinit r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        struct r8a7779_pm_ch *ch = NULL;
        int ret = -EIO;
index d613113a04bda27f12042803a92fe239be567a9b..d5fc3ed4e31542c2bc1c8a68fb0ebe923105a21d 100644 (file)
@@ -48,7 +48,7 @@ void __init sh73a0_register_twd(void)
 }
 #endif
 
-static int __cpuinit sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int sh73a0_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        cpu = cpu_logical_map(cpu);
 
index 9004bfb1756ee345192d78c3f2a125c2b985a8e5..95c115d8b5eee5407feb99ce996f5793ceb34747 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __CPUINIT
        .arch   armv7-a
 
 ENTRY(secondary_trampoline)
index b51ce8c7929dcf16991d2f3e45914c7ede976b92..5356a72bc8ce901fdf82d0626f6ca59c9bfa85bf 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "core.h"
 
-static int __cpuinit socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int socfpga_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        int trampoline_size = &secondary_trampoline_end - &secondary_trampoline;
 
index 904f2c907b46d7a2a77229aa01812c0749670b6c..a99d90a4d09c522d0d01c5fd54d5dd2b3c1cdfda 100644 (file)
@@ -37,7 +37,7 @@ void __init spear13xx_l2x0_init(void);
 void spear_restart(enum reboot_mode, const char *);
 
 void spear13xx_secondary_startup(void);
-void __cpuinit spear13xx_cpu_die(unsigned int cpu);
+void spear13xx_cpu_die(unsigned int cpu);
 
 extern struct smp_operations spear13xx_smp_ops;
 
index 9c4c722c954e0b0b4eceb1f75c33b6777b4eed96..5c4a19887b2bb13b1c4779a6a676acc18ad35d52 100644 (file)
@@ -24,7 +24,7 @@ static DEFINE_SPINLOCK(boot_lock);
 
 static void __iomem *scu_base = IOMEM(VA_SCU_BASE);
 
-static void __cpuinit spear13xx_secondary_init(unsigned int cpu)
+static void spear13xx_secondary_init(unsigned int cpu)
 {
        /*
         * let the primary processor know we're out of the
@@ -40,7 +40,7 @@ static void __cpuinit spear13xx_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-static int __cpuinit spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int spear13xx_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
 
index d04e3bfe19189082823e4a74c60d1de1de9eed7f..835833e3c4f8fb193f6d177c88ef35199488b33f 100644 (file)
@@ -11,8 +11,9 @@ menuconfig ARCH_STI
        select HAVE_SMP
        select HAVE_ARM_SCU if SMP
        select ARCH_REQUIRE_GPIOLIB
-       select ARM_ERRATA_720789
        select ARM_ERRATA_754322
+       select ARM_ERRATA_764369
+       select ARM_ERRATA_775420
        select PL310_ERRATA_753970 if CACHE_PL310
        select PL310_ERRATA_769419 if CACHE_PL310
        help
index 78ebc7559f5309e025c3796ff90017293570bc6e..4c09bae86edf02cb4f9408821fea25cd84d9dddb 100644 (file)
@@ -16,8 +16,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __INIT
-
 /*
  * ST specific entry point for secondary CPUs.  This provides
  * a "holding pen" into which all secondary cores are held until we're
index 977a863468fcb715079540328da5d9d3041ef48b..dce50d983a8edc267c4157903952f07487a177c7 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "smp.h"
 
-static void __cpuinit write_pen_release(int val)
+static void write_pen_release(int val)
 {
        pen_release = val;
        smp_wmb();
@@ -37,7 +37,7 @@ static void __cpuinit write_pen_release(int val)
 
 static DEFINE_SPINLOCK(boot_lock);
 
-void __cpuinit sti_secondary_init(unsigned int cpu)
+void sti_secondary_init(unsigned int cpu)
 {
        trace_hardirqs_off();
 
@@ -54,7 +54,7 @@ void __cpuinit sti_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-int __cpuinit sti_boot_secondary(unsigned int cpu, struct task_struct *idle)
+int sti_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
 
index 24db4ac428ae9641e503a1cc1c3638ebf05c9142..97b33a2a2d75cee6b00e918c14db64a2865514e4 100644 (file)
@@ -35,7 +35,7 @@
 
 static cpumask_t tegra_cpu_init_mask;
 
-static void __cpuinit tegra_secondary_init(unsigned int cpu)
+static void tegra_secondary_init(unsigned int cpu)
 {
        cpumask_set_cpu(cpu, &tegra_cpu_init_mask);
 }
@@ -167,7 +167,7 @@ static int tegra114_boot_secondary(unsigned int cpu, struct task_struct *idle)
        return ret;
 }
 
-static int __cpuinit tegra_boot_secondary(unsigned int cpu,
+static int tegra_boot_secondary(unsigned int cpu,
                                          struct task_struct *idle)
 {
        if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) && tegra_chip_id == TEGRA20)
index 94e69bee3da50b12933ae419d4affac950150ca0..261fec140c06db03ca8240a64a1c8a6479124c4f 100644 (file)
@@ -191,7 +191,7 @@ static const char *lp_state[TEGRA_MAX_SUSPEND_MODE] = {
        [TEGRA_SUSPEND_LP0] = "LP0",
 };
 
-static int __cpuinit tegra_suspend_enter(suspend_state_t state)
+static int tegra_suspend_enter(suspend_state_t state)
 {
        enum tegra_suspend_mode mode = tegra_pmc_get_suspend_mode();
 
index 14d90469392f1545d418aeeb20573c7c9bc39a3c..1f296e796a4fe42a93972a06a5517033db1b3307 100644 (file)
@@ -54,7 +54,7 @@ static void __iomem *scu_base_addr(void)
 
 static DEFINE_SPINLOCK(boot_lock);
 
-static void __cpuinit ux500_secondary_init(unsigned int cpu)
+static void ux500_secondary_init(unsigned int cpu)
 {
        /*
         * let the primary processor know we're out of the
@@ -69,7 +69,7 @@ static void __cpuinit ux500_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-static int __cpuinit ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int ux500_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
 
index 5b799c29886e544778d115a0e7570f3f100875ad..5f252569c68987d908546b55bb921d5f7693c7af 100644 (file)
@@ -91,7 +91,7 @@ static void __init zynq_map_io(void)
        zynq_scu_map_io();
 }
 
-static void zynq_system_reset(char mode, const char *cmd)
+static void zynq_system_reset(enum reboot_mode mode, const char *cmd)
 {
        zynq_slcr_system_reset();
 }
index fbbd0e21c404d5f98bc4c6bf5387df045ceaa66f..3040d219570f23babca8b6cdbc81cfbfade17581 100644 (file)
@@ -27,7 +27,7 @@ extern void secondary_startup(void);
 extern char zynq_secondary_trampoline;
 extern char zynq_secondary_trampoline_jump;
 extern char zynq_secondary_trampoline_end;
-extern int __cpuinit zynq_cpun_start(u32 address, int cpu);
+extern int zynq_cpun_start(u32 address, int cpu);
 extern struct smp_operations zynq_smp_ops __initdata;
 #endif
 
index d183cd234a9bb68fe3c387718c89ed39d3499452..d4cd5f34fe5c6a0febdc473de016377f668ae5dd 100644 (file)
@@ -9,8 +9,6 @@
 #include <linux/linkage.h>
 #include <linux/init.h>
 
-       __CPUINIT
-
 ENTRY(zynq_secondary_trampoline)
        ldr     r0, [pc]
        bx      r0
index 023f225493f281e4109ece0fdcbbe22fb8a51dfc..689fbbc3d9c8860347f42f60c00c01f41c0a091a 100644 (file)
 /*
  * Store number of cores in the system
  * Because of scu_get_core_count() must be in __init section and can't
- * be called from zynq_cpun_start() because it is in __cpuinit section.
+ * be called from zynq_cpun_start() because it is not in __init section.
  */
 static int ncores;
 
-int __cpuinit zynq_cpun_start(u32 address, int cpu)
+int zynq_cpun_start(u32 address, int cpu)
 {
        u32 trampoline_code_size = &zynq_secondary_trampoline_end -
                                                &zynq_secondary_trampoline;
@@ -92,7 +92,7 @@ int __cpuinit zynq_cpun_start(u32 address, int cpu)
 }
 EXPORT_SYMBOL(zynq_cpun_start);
 
-static int __cpuinit zynq_boot_secondary(unsigned int cpu,
+static int zynq_boot_secondary(unsigned int cpu,
                                                struct task_struct *idle)
 {
        return zynq_cpun_start(virt_to_phys(secondary_startup), cpu);
index 6cacdc8dd654dd11ecbfb45f7576f1ead0a1062e..db5c2cab8fda4251bb636aa5567afafe5cfdb406 100644 (file)
@@ -421,24 +421,28 @@ config CPU_32v3
        select CPU_USE_DOMAINS if MMU
        select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
        select TLS_REG_EMUL if SMP || !MMU
+       select NEED_KUSER_HELPERS
 
 config CPU_32v4
        bool
        select CPU_USE_DOMAINS if MMU
        select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
        select TLS_REG_EMUL if SMP || !MMU
+       select NEED_KUSER_HELPERS
 
 config CPU_32v4T
        bool
        select CPU_USE_DOMAINS if MMU
        select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
        select TLS_REG_EMUL if SMP || !MMU
+       select NEED_KUSER_HELPERS
 
 config CPU_32v5
        bool
        select CPU_USE_DOMAINS if MMU
        select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
        select TLS_REG_EMUL if SMP || !MMU
+       select NEED_KUSER_HELPERS
 
 config CPU_32v6
        bool
@@ -776,6 +780,7 @@ config CPU_BPREDICT_DISABLE
 
 config TLS_REG_EMUL
        bool
+       select NEED_KUSER_HELPERS
        help
          An SMP system using a pre-ARMv6 processor (there are apparently
          a few prototypes like that in existence) and therefore access to
@@ -783,11 +788,40 @@ config TLS_REG_EMUL
 
 config NEEDS_SYSCALL_FOR_CMPXCHG
        bool
+       select NEED_KUSER_HELPERS
        help
          SMP on a pre-ARMv6 processor?  Well OK then.
          Forget about fast user space cmpxchg support.
          It is just not possible.
 
+config NEED_KUSER_HELPERS
+       bool
+
+config KUSER_HELPERS
+       bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
+       default y
+       help
+         Warning: disabling this option may break user programs.
+
+         Provide kuser helpers in the vector page.  The kernel provides
+         helper code to userspace in read only form at a fixed location
+         in the high vector page to allow userspace to be independent of
+         the CPU type fitted to the system.  This permits binaries to be
+         run on ARMv4 through to ARMv7 without modification.
+
+         However, the fixed address nature of these helpers can be used
+         by ROP (return orientated programming) authors when creating
+         exploits.
+
+         If all of the binaries and libraries which run on your platform
+         are built specifically for your platform, and make no use of
+         these helpers, then you can turn this option off.  However,
+         when such an binary or library is run, it will receive a SIGILL
+         signal, which will terminate the program.
+
+         Say N here only if you are absolutely certain that you do not
+         need these helpers; otherwise, the safe option is to say Y.
+
 config DMA_CACHE_RWFO
        bool "Enable read/write for ownership DMA cache maintenance"
        depends on CPU_V6K && SMP
index b55b1015724b56931c57ad7b2920d760b80529e8..4a0544492f10e4cd63d490f61d3cff3e54adbd19 100644 (file)
@@ -245,7 +245,8 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
        if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
                local_flush_bp_all();
                local_flush_tlb_all();
-               dummy_flush_tlb_a15_erratum();
+               if (erratum_a15_798181())
+                       dummy_flush_tlb_a15_erratum();
        }
 
        atomic64_set(&per_cpu(active_asids, cpu), asid);
index 4f56617a2392d58e52f96582a3631c4c49a4f5f2..53cdbd39ec8e23c1facab667f56fa9441aa870c6 100644 (file)
@@ -989,6 +989,7 @@ phys_addr_t arm_lowmem_limit __initdata = 0;
 
 void __init sanity_check_meminfo(void)
 {
+       phys_addr_t memblock_limit = 0;
        int i, j, highmem = 0;
        phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1;
 
@@ -1052,9 +1053,32 @@ void __init sanity_check_meminfo(void)
                        bank->size = size_limit;
                }
 #endif
-               if (!bank->highmem && bank->start + bank->size > arm_lowmem_limit)
-                       arm_lowmem_limit = bank->start + bank->size;
+               if (!bank->highmem) {
+                       phys_addr_t bank_end = bank->start + bank->size;
 
+                       if (bank_end > arm_lowmem_limit)
+                               arm_lowmem_limit = bank_end;
+
+                       /*
+                        * Find the first non-section-aligned page, and point
+                        * memblock_limit at it. This relies on rounding the
+                        * limit down to be section-aligned, which happens at
+                        * the end of this function.
+                        *
+                        * With this algorithm, the start or end of almost any
+                        * bank can be non-section-aligned. The only exception
+                        * is that the start of the bank 0 must be section-
+                        * aligned, since otherwise memory would need to be
+                        * allocated when mapping the start of bank 0, which
+                        * occurs before any free memory is mapped.
+                        */
+                       if (!memblock_limit) {
+                               if (!IS_ALIGNED(bank->start, SECTION_SIZE))
+                                       memblock_limit = bank->start;
+                               else if (!IS_ALIGNED(bank_end, SECTION_SIZE))
+                                       memblock_limit = bank_end;
+                       }
+               }
                j++;
        }
 #ifdef CONFIG_HIGHMEM
@@ -1079,7 +1103,18 @@ void __init sanity_check_meminfo(void)
 #endif
        meminfo.nr_banks = j;
        high_memory = __va(arm_lowmem_limit - 1) + 1;
-       memblock_set_current_limit(arm_lowmem_limit);
+
+       /*
+        * Round the memblock limit down to a section size.  This
+        * helps to ensure that we will allocate memory from the
+        * last full section, which should be mapped.
+        */
+       if (memblock_limit)
+               memblock_limit = round_down(memblock_limit, SECTION_SIZE);
+       if (!memblock_limit)
+               memblock_limit = arm_lowmem_limit;
+
+       memblock_set_current_limit(memblock_limit);
 }
 
 static inline void prepare_page_table(void)
@@ -1160,7 +1195,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
        /*
         * Allocate the vector page early.
         */
-       vectors = early_alloc(PAGE_SIZE);
+       vectors = early_alloc(PAGE_SIZE * 2);
 
        early_trap_init(vectors);
 
@@ -1205,15 +1240,27 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
        map.pfn = __phys_to_pfn(virt_to_phys(vectors));
        map.virtual = 0xffff0000;
        map.length = PAGE_SIZE;
+#ifdef CONFIG_KUSER_HELPERS
        map.type = MT_HIGH_VECTORS;
+#else
+       map.type = MT_LOW_VECTORS;
+#endif
        create_mapping(&map);
 
        if (!vectors_high()) {
                map.virtual = 0;
+               map.length = PAGE_SIZE * 2;
                map.type = MT_LOW_VECTORS;
                create_mapping(&map);
        }
 
+       /* Now create a kernel read-only mapping */
+       map.pfn += 1;
+       map.virtual = 0xffff0000 + PAGE_SIZE;
+       map.length = PAGE_SIZE;
+       map.type = MT_LOW_VECTORS;
+       create_mapping(&map);
+
        /*
         * Ask the machine support to map in the statically mapped devices.
         */
@@ -1276,8 +1323,6 @@ void __init paging_init(struct machine_desc *mdesc)
 {
        void *zero_page;
 
-       memblock_set_current_limit(arm_lowmem_limit);
-
        build_mem_type_table();
        prepare_page_table();
        map_lowmem();
index 2bb61e703d6c4d042cbbb86e6c655cbc0e94d762..d1a2d05971e02f00be78cc596e3b464292e18e3b 100644 (file)
@@ -443,8 +443,6 @@ ENTRY(cpu_arm1020_set_pte_ext)
 #endif /* CONFIG_MMU */
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __arm1020_setup, #function
 __arm1020_setup:
        mov     r0, #0
index 8f96aa40f5107987edf065c451d4d0879e5e108c..9d89405c3d03bf78e63fb206beb8b356bb6095f6 100644 (file)
@@ -425,8 +425,6 @@ ENTRY(cpu_arm1020e_set_pte_ext)
 #endif /* CONFIG_MMU */
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __arm1020e_setup, #function
 __arm1020e_setup:
        mov     r0, #0
index 8ebe4a469a22534c9a828681d57552a546fb820b..6f01a0ae3b30740218915dd0910aae84aa9ebe40 100644 (file)
@@ -407,8 +407,6 @@ ENTRY(cpu_arm1022_set_pte_ext)
 #endif /* CONFIG_MMU */
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __arm1022_setup, #function
 __arm1022_setup:
        mov     r0, #0
index 093fc7e520c341fb270b45e3ef2f4fbed694ae3c..4799a24b43e637b11de8e36d9cafb98071dbb83c 100644 (file)
@@ -396,9 +396,6 @@ ENTRY(cpu_arm1026_set_pte_ext)
 #endif /* CONFIG_MMU */
        mov     pc, lr
 
-
-       __CPUINIT
-
        .type   __arm1026_setup, #function
 __arm1026_setup:
        mov     r0, #0
index 0ac908c7ade1f178afe35a4c3d1c79e59aa8ceb2..d42c37f9f5bc465e35cf0f3da88457f1bf90be05 100644 (file)
@@ -116,8 +116,6 @@ ENTRY(cpu_arm720_reset)
 ENDPROC(cpu_arm720_reset)
                .popsection
 
-       __CPUINIT
-
        .type   __arm710_setup, #function
 __arm710_setup:
        mov     r0, #0
index fde2d2a794cfbc0b43c31619fff9668172aebad3..9b0ae90cbf17b09fdbf62ecb2c7ac42406e5c16e 100644 (file)
@@ -60,8 +60,6 @@ ENTRY(cpu_arm740_reset)
 ENDPROC(cpu_arm740_reset)
        .popsection
 
-       __CPUINIT
-
        .type   __arm740_setup, #function
 __arm740_setup:
        mov     r0, #0
index 6ddea3e464bd1e30ffc2115dc00b4a842949afdb..f6cc3f63ce397f2ef41e54f0939f69671a1bb1e3 100644 (file)
@@ -51,8 +51,6 @@ ENTRY(cpu_arm7tdmi_reset)
 ENDPROC(cpu_arm7tdmi_reset)
                .popsection
 
-               __CPUINIT
-
                .type   __arm7tdmi_setup, #function
 __arm7tdmi_setup:
                mov     pc, lr
index 2556cf1c2da1c8f40c09edbe7d43b7c0286f355f..549557df6d57a4273e99b2d0901b847af4382a39 100644 (file)
@@ -410,8 +410,6 @@ ENTRY(cpu_arm920_do_resume)
 ENDPROC(cpu_arm920_do_resume)
 #endif
 
-       __CPUINIT
-
        .type   __arm920_setup, #function
 __arm920_setup:
        mov     r0, #0
index 4464c49d7449b386b04c017f33fdeb79ef718f05..2a758b06c6f65fb9071a9f7faf73b3ccb720eef2 100644 (file)
@@ -388,8 +388,6 @@ ENTRY(cpu_arm922_set_pte_ext)
 #endif /* CONFIG_MMU */
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __arm922_setup, #function
 __arm922_setup:
        mov     r0, #0
index 281eb9b9c1d654061e0bc8d2e6d350f6d7a3b2ff..97448c3acf38a571cb96d1c9871952d56c605343 100644 (file)
@@ -438,8 +438,6 @@ ENTRY(cpu_arm925_set_pte_ext)
 #endif /* CONFIG_MMU */
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __arm925_setup, #function
 __arm925_setup:
        mov     r0, #0
index 344c8a548cc0ef95aea9653d883b26c629f016dd..0f098f407c9f12233b747e4bf1dac881d8b6d5a1 100644 (file)
@@ -425,8 +425,6 @@ ENTRY(cpu_arm926_do_resume)
 ENDPROC(cpu_arm926_do_resume)
 #endif
 
-       __CPUINIT
-
        .type   __arm926_setup, #function
 __arm926_setup:
        mov     r0, #0
index 8da189d4a4021a9184d1c78ac4cda76209406f02..1c39a704ff6e139fd409bb1e70617780491505c7 100644 (file)
@@ -273,8 +273,6 @@ ENDPROC(arm940_dma_unmap_area)
        @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
        define_cache_functions arm940
 
-       __CPUINIT
-
        .type   __arm940_setup, #function
 __arm940_setup:
        mov     r0, #0
index f666cf34075a1a8e7e496fd9c0a09657a0627040..0289cd905e734d8421c050014cbed60ca9baace7 100644 (file)
@@ -326,8 +326,6 @@ ENTRY(cpu_arm946_dcache_clean_area)
        mcr     p15, 0, r0, c7, c10, 4          @ drain WB
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __arm946_setup, #function
 __arm946_setup:
        mov     r0, #0
index 8881391dfb9ee42c819efd086de5b70711fee08d..f51197ba754a2951d2dac160470592de11fa0337 100644 (file)
@@ -51,8 +51,6 @@ ENTRY(cpu_arm9tdmi_reset)
 ENDPROC(cpu_arm9tdmi_reset)
                .popsection
 
-               __CPUINIT
-
                .type   __arm9tdmi_setup, #function
 __arm9tdmi_setup:
                mov     pc, lr
index aaeb6c127c7aa5766e9d1093477bc65e540bdca8..2dfc0f1d3bfdd99fe3534958dedd16ae13866e0b 100644 (file)
@@ -135,8 +135,6 @@ ENTRY(cpu_fa526_set_pte_ext)
 #endif
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __fa526_setup, #function
 __fa526_setup:
        /* On return of this routine, r0 must carry correct flags for CFG register */
index 4106b09e0c29ad07530e095ca361e84f92489d32..d5146b98c8d12bd59037017244bc0bf5ab9c4099 100644 (file)
@@ -514,8 +514,6 @@ ENTRY(cpu_feroceon_set_pte_ext)
 #endif
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __feroceon_setup, #function
 __feroceon_setup:
        mov     r0, #0
index 0b60dd3d742a1d909e4ffdf8d5162cd052754098..40acba595731c0ec4fa6c934f428222bcb95424e 100644 (file)
@@ -383,8 +383,6 @@ ENTRY(cpu_mohawk_do_resume)
 ENDPROC(cpu_mohawk_do_resume)
 #endif
 
-       __CPUINIT
-
        .type   __mohawk_setup, #function
 __mohawk_setup:
        mov     r0, #0
index 775d70fba93719e04c297d14c1a9a6491a9dcc8e..c45319c8f1d9821a396f8b453473614fe92a8ea6 100644 (file)
@@ -159,8 +159,6 @@ ENTRY(cpu_sa110_set_pte_ext)
 #endif
        mov     pc, lr
 
-       __CPUINIT
-
        .type   __sa110_setup, #function
 __sa110_setup:
        mov     r10, #0
index d92dfd081429294200875ddedfbd6beb4fd98735..09d241ae2dbe07620c5c86a7b8303d7a38619f89 100644 (file)
@@ -198,8 +198,6 @@ ENTRY(cpu_sa1100_do_resume)
 ENDPROC(cpu_sa1100_do_resume)
 #endif
 
-       __CPUINIT
-
        .type   __sa1100_setup, #function
 __sa1100_setup:
        mov     r0, #0
index 2d1ef87328a1783d309296a25889d8a37d2a9ae6..1128064fddcbd6c11754d5c2b4241e8b51c7d6a5 100644 (file)
@@ -180,8 +180,6 @@ ENDPROC(cpu_v6_do_resume)
 
        .align
 
-       __CPUINIT
-
 /*
  *     __v6_setup
  *
index 9704097c450e13300be619e73015c65b7bd08c4a..bdd3be4be77aa50c93dcc20c8afdaa3af3c0cf5f 100644 (file)
@@ -110,7 +110,7 @@ ENTRY(cpu_v7_set_pte_ext)
  ARM(  str     r3, [r0, #2048]! )
  THUMB(        add     r0, r0, #2048 )
  THUMB(        str     r3, [r0] )
-       ALT_SMP(mov     pc,lr)
+       ALT_SMP(W(nop))
        ALT_UP (mcr     p15, 0, r0, c7, c10, 1)         @ flush_pte
 #endif
        mov     pc, lr
@@ -160,8 +160,6 @@ ENDPROC(cpu_v7_set_pte_ext)
        mcr     p15, 0, \ttbr1, c2, c0, 1       @ load TTB1
        .endm
 
-       __CPUINIT
-
        /*   AT
         *  TFR   EV X F   I D LR    S
         * .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM
@@ -172,5 +170,3 @@ ENDPROC(cpu_v7_set_pte_ext)
        .type   v7_crval, #object
 v7_crval:
        crval   clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c
-
-       .previous
index 5ffe1956c6d95c5ba227986347caddec5d0dacda..01a719e18bb047c655694c336d5a42e1388d1062 100644 (file)
@@ -81,7 +81,7 @@ ENTRY(cpu_v7_set_pte_ext)
        tst     r3, #1 << (55 - 32)             @ L_PTE_DIRTY
        orreq   r2, #L_PTE_RDONLY
 1:     strd    r2, r3, [r0]
-       ALT_SMP(mov     pc, lr)
+       ALT_SMP(W(nop))
        ALT_UP (mcr     p15, 0, r0, c7, c10, 1)         @ flush_pte
 #endif
        mov     pc, lr
@@ -140,8 +140,6 @@ ENDPROC(cpu_v7_set_pte_ext)
        mcrr    p15, 0, \ttbr0, \zero, c2                       @ load TTBR0
        .endm
 
-       __CPUINIT
-
        /*
         *   AT
         *  TFR   EV X F   IHD LR    S
@@ -153,5 +151,3 @@ ENDPROC(cpu_v7_set_pte_ext)
        .type   v7_crval, #object
 v7_crval:
        crval   clear=0x0120c302, mmuset=0x30c23c7d, ucset=0x00c01c7c
-
-       .previous
index 7ef3ad05df398656d2f63302139288154fa1abfd..73398bcf9bd8ea8d7293803828cb837306742fb7 100644 (file)
@@ -75,13 +75,14 @@ ENTRY(cpu_v7_do_idle)
 ENDPROC(cpu_v7_do_idle)
 
 ENTRY(cpu_v7_dcache_clean_area)
-       ALT_SMP(mov     pc, lr)                 @ MP extensions imply L1 PTW
-       ALT_UP(W(nop))
-       dcache_line_size r2, r3
-1:     mcr     p15, 0, r0, c7, c10, 1          @ clean D entry
+       ALT_SMP(W(nop))                 @ MP extensions imply L1 PTW
+       ALT_UP_B(1f)
+       mov     pc, lr
+1:     dcache_line_size r2, r3
+2:     mcr     p15, 0, r0, c7, c10, 1          @ clean D entry
        add     r0, r0, r2
        subs    r1, r1, r2
-       bhi     1b
+       bhi     2b
        dsb
        mov     pc, lr
 ENDPROC(cpu_v7_dcache_clean_area)
@@ -167,8 +168,6 @@ ENDPROC(cpu_pj4b_do_idle)
 
 #endif
 
-       __CPUINIT
-
 /*
  *     __v7_setup
  *
index e8efd83b6f252f00b85b29eb45d24bbd4919d4ae..dc1645890042dd4bac11cdb4a2fdb83afb1dd752 100644 (file)
@@ -446,8 +446,6 @@ ENTRY(cpu_xsc3_do_resume)
 ENDPROC(cpu_xsc3_do_resume)
 #endif
 
-       __CPUINIT
-
        .type   __xsc3_setup, #function
 __xsc3_setup:
        mov     r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE
index e766f889bfd6d1b4159c6724a975468dbba56892..d19b1cfcad91e69934945d180c404298c33c2287 100644 (file)
@@ -558,8 +558,6 @@ ENTRY(cpu_xscale_do_resume)
 ENDPROC(cpu_xscale_do_resume)
 #endif
 
-       __CPUINIT
-
        .type   __xscale_setup, #function
 __xscale_setup:
        mcr     p15, 0, ip, c7, c7, 0           @ invalidate I, D caches & BTB
index 3dc5cbea86cc9cc838d5b864f0eabaed76777e23..a5b5ff6e68d2015e4080112c821fb6d0ac0bf3d6 100644 (file)
@@ -29,6 +29,13 @@ config PLAT_S5P
        help
          Base platform code for Samsung's S5P series SoC.
 
+config SAMSUNG_PM
+       bool
+       depends on PM && (PLAT_S3C24XX || ARCH_S3C64XX || ARCH_S5P64X0 || S5P_PM)
+       default y
+       help
+         Base platform power management code for samsung code
+
 if PLAT_SAMSUNG
 
 # boot configurations
index 98d07d8fc7a71ffa869fa397cc8f74977264f17c..199bbe304d02f1e70838c0f012a73e7688655436 100644 (file)
@@ -51,7 +51,7 @@ obj-$(CONFIG_SAMSUNG_DMADEV)  += dma-ops.o
 
 # PM support
 
-obj-$(CONFIG_PM)               += pm.o
+obj-$(CONFIG_SAMSUNG_PM)       += pm.o
 obj-$(CONFIG_SAMSUNG_PM_GPIO)  += pm-gpio.o
 obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o
 
index a62753dc15baf144ecfc2ea7efe53bfc6f13a9fe..df45d6edc98d9e723242f3890e1ea4df124d8888 100644 (file)
@@ -83,6 +83,11 @@ extern struct clk clk_ext;
 extern struct clksrc_clk clk_epllref;
 extern struct clksrc_clk clk_esysclk;
 
+/* S3C24XX UART clocks */
+extern struct clk s3c24xx_clk_uart0;
+extern struct clk s3c24xx_clk_uart1;
+extern struct clk s3c24xx_clk_uart2;
+
 /* S3C64XX specific clocks */
 extern struct clk clk_h2;
 extern struct clk clk_27m;
index 5d47ca35cabde40cfa56ae05344a275909ac9e72..6bc1a8f471e391e127be0dd7cfadf0eefa33a0f2 100644 (file)
@@ -19,7 +19,7 @@
 
 struct device;
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_SAMSUNG_PM
 
 extern __init int s3c_pm_init(void);
 extern __init int s3c64xx_pm_init(void);
@@ -58,8 +58,6 @@ extern unsigned char pm_uart_udivslot;  /* true to save UART UDIVSLOT */
 
 /* from sleep.S */
 
-extern void s3c_cpu_resume(void);
-
 extern int s3c2410_cpu_suspend(unsigned long);
 
 /* sleep save info */
@@ -106,12 +104,14 @@ extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
 extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
 extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_SAMSUNG_PM
 extern int s3c_irq_wake(struct irq_data *data, unsigned int state);
 extern int s3c_irqext_wake(struct irq_data *data, unsigned int state);
+extern void s3c_cpu_resume(void);
 #else
 #define s3c_irq_wake NULL
 #define s3c_irqext_wake NULL
+#define s3c_cpu_resume NULL
 #endif
 
 /* PM debug functions */
index 3e5c4619caa5ef26cc9fdea0940856c09f639390..50a3ea0037db10d2032e2ce020688b6fa74614b0 100644 (file)
@@ -55,12 +55,13 @@ void __init s3c_init_cpu(unsigned long idcode,
 
        printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
 
-       if (cpu->map_io == NULL || cpu->init == NULL) {
+       if (cpu->init == NULL) {
                printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
                panic("Unsupported Samsung CPU");
        }
 
-       cpu->map_io();
+       if (cpu->map_io)
+               cpu->map_io();
 }
 
 /* s3c24xx_init_clocks
index ea36136424511b4d3c7518b0e839897e266f7137..d0c23010b693a57625d002694528d0cd2fffaaa5 100644 (file)
@@ -80,7 +80,7 @@ unsigned char pm_uart_udivslot;
 
 #ifdef CONFIG_SAMSUNG_PM_DEBUG
 
-static struct pm_uart_save uart_save[CONFIG_SERIAL_SAMSUNG_UARTS];
+static struct pm_uart_save uart_save;
 
 static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save)
 {
@@ -101,11 +101,7 @@ static void s3c_pm_save_uart(unsigned int uart, struct pm_uart_save *save)
 
 static void s3c_pm_save_uarts(void)
 {
-       struct pm_uart_save *save = uart_save;
-       unsigned int uart;
-
-       for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
-               s3c_pm_save_uart(uart, save);
+       s3c_pm_save_uart(CONFIG_DEBUG_S3C_UART, &uart_save);
 }
 
 static void s3c_pm_restore_uart(unsigned int uart, struct pm_uart_save *save)
@@ -126,11 +122,7 @@ static void s3c_pm_restore_uart(unsigned int uart, struct pm_uart_save *save)
 
 static void s3c_pm_restore_uarts(void)
 {
-       struct pm_uart_save *save = uart_save;
-       unsigned int uart;
-
-       for (uart = 0; uart < CONFIG_SERIAL_SAMSUNG_UARTS; uart++, save++)
-               s3c_pm_restore_uart(uart, save);
+       s3c_pm_restore_uart(CONFIG_DEBUG_S3C_UART, &uart_save);
 }
 #else
 static void s3c_pm_save_uarts(void) { }
index 1e1b2d7697488ddb8c73ad80ea22afb5a2dd3f7d..39895d892c3be7d158093ddd930e0fa1ea7a8890 100644 (file)
@@ -23,7 +23,7 @@
  * observers, irrespective of whether they're taking part in coherency
  * or not.  This is necessary for the hotplug code to work reliably.
  */
-static void __cpuinit write_pen_release(int val)
+static void write_pen_release(int val)
 {
        pen_release = val;
        smp_wmb();
@@ -33,7 +33,7 @@ static void __cpuinit write_pen_release(int val)
 
 static DEFINE_SPINLOCK(boot_lock);
 
-void __cpuinit versatile_secondary_init(unsigned int cpu)
+void versatile_secondary_init(unsigned int cpu)
 {
        /*
         * let the primary processor know we're out of the
@@ -48,7 +48,7 @@ void __cpuinit versatile_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-int __cpuinit versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
+int versatile_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
 
index f71c37edca263a88038199514995cf92d8b79d9e..8a6295c86209cd982076a8f79662bd20c2c0f02b 100644 (file)
@@ -170,9 +170,10 @@ static void __init xen_percpu_init(void *unused)
        per_cpu(xen_vcpu, cpu) = vcpup;
 
        enable_percpu_irq(xen_events_irq, 0);
+       put_cpu();
 }
 
-static void xen_restart(char str, const char *cmd)
+static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
 {
        struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
        int rc;
index d56ed11ba9a387be20f835d5f7675f9e95eb4574..98abd476992db38b3acb227393a3e856cefa648e 100644 (file)
@@ -97,7 +97,7 @@ static inline u32 arch_timer_get_cntfrq(void)
        return val;
 }
 
-static inline void __cpuinit arch_counter_set_user_access(void)
+static inline void arch_counter_set_user_access(void)
 {
        u32 cntkctl;
 
index ef8235c68c092674ed0c628733bbc7a6b02404b5..a2232d07be9d6331e8eadaddf8eba57dda502d16 100644 (file)
@@ -83,14 +83,7 @@ static inline int reinstall_suspended_bps(struct pt_regs *regs)
 }
 #endif
 
-#ifdef CONFIG_COMPAT
 int aarch32_break_handler(struct pt_regs *regs);
-#else
-static int aarch32_break_handler(struct pt_regs *regs)
-{
-       return -EFAULT;
-}
-#endif
 
 #endif /* __ASSEMBLY */
 #endif /* __KERNEL__ */
index c92de4163eba519802dfaa4b63450259bb6d0395..b25763bc0ec4977a4eca6139ef7d84b3a15eeea0 100644 (file)
 #define        TPIDR_EL1       18      /* Thread ID, Privileged */
 #define        AMAIR_EL1       19      /* Aux Memory Attribute Indirection Register */
 #define        CNTKCTL_EL1     20      /* Timer Control Register (EL1) */
+#define        PAR_EL1         21      /* Physical Address Register */
 /* 32bit specific registers. Keep them at the end of the range */
-#define        DACR32_EL2      21      /* Domain Access Control Register */
-#define        IFSR32_EL2      22      /* Instruction Fault Status Register */
-#define        FPEXC32_EL2     23      /* Floating-Point Exception Control Register */
-#define        DBGVCR32_EL2    24      /* Debug Vector Catch Register */
-#define        TEECR32_EL1     25      /* ThumbEE Configuration Register */
-#define        TEEHBR32_EL1    26      /* ThumbEE Handler Base Register */
-#define        NR_SYS_REGS     27
+#define        DACR32_EL2      22      /* Domain Access Control Register */
+#define        IFSR32_EL2      23      /* Instruction Fault Status Register */
+#define        FPEXC32_EL2     24      /* Floating-Point Exception Control Register */
+#define        DBGVCR32_EL2    25      /* Debug Vector Catch Register */
+#define        TEECR32_EL1     26      /* ThumbEE Configuration Register */
+#define        TEEHBR32_EL1    27      /* ThumbEE Handler Base Register */
+#define        NR_SYS_REGS     28
 
 /* 32bit mapping */
 #define c0_MPIDR       (MPIDR_EL1 * 2) /* MultiProcessor ID Register */
@@ -69,6 +70,8 @@
 #define c5_AIFSR       (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */
 #define c6_DFAR                (FAR_EL1 * 2)   /* Data Fault Address Register */
 #define c6_IFAR                (c6_DFAR + 1)   /* Instruction Fault Address Register */
+#define c7_PAR         (PAR_EL1 * 2)   /* Physical Address Register */
+#define c7_PAR_high    (c7_PAR + 1)    /* PAR top 32 bits */
 #define c10_PRRR       (MAIR_EL1 * 2)  /* Primary Region Remap Register */
 #define c10_NMRR       (c10_PRRR + 1)  /* Normal Memory Remap Register */
 #define c12_VBAR       (VBAR_EL1 * 2)  /* Vector Base Address Register */
index 644d7395686493e371d01266c98597a00a104da4..0859a4ddd1e7d0e8b1792416b19a8f9908457af7 100644 (file)
@@ -129,7 +129,7 @@ struct kvm_vcpu_arch {
        struct kvm_mmu_memory_cache mmu_page_cache;
 
        /* Target CPU and feature flags */
-       u32 target;
+       int target;
        DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES);
 
        /* Detect first run of a vcpu */
index a6e1750369efcb32ea589b6450589515bda1c283..7a18fabbe0f6c5e6579bf4a0b4b88113d1d0adee 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/compiler.h>
 #include <linux/linkage.h>
 #include <linux/irqflags.h>
+#include <linux/reboot.h>
 
 struct pt_regs;
 
@@ -41,7 +42,7 @@ extern void show_pte(struct mm_struct *mm, unsigned long addr);
 extern void __show_regs(struct pt_regs *);
 
 void soft_restart(unsigned long);
-extern void (*arm_pm_restart)(char str, const char *cmd);
+extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
 #define UDBG_UNDEFINED (1 << 0)
 #define UDBG_SYSCALL   (1 << 1)
index 3659e460071ddfb1f84715ff7736c97ef9f9bb20..23a3c4791d86cb71f9a2520e2176212b1e107503 100644 (file)
 #include <linux/compiler.h>
 
 #ifndef CONFIG_ARM64_64K_PAGES
-#define THREAD_SIZE_ORDER      1
+#define THREAD_SIZE_ORDER      2
 #endif
 
-#define THREAD_SIZE            8192
+#define THREAD_SIZE            16384
 #define THREAD_START_SP                (THREAD_SIZE - 16)
 
 #ifndef __ASSEMBLY__
index 46b3beb4b773c85cd381f72301b8f2e9dfdc7a97..717031a762c27966aabc7786f6d2a900034b0b08 100644 (file)
@@ -35,6 +35,7 @@ struct mmu_gather {
        struct mm_struct        *mm;
        unsigned int            fullmm;
        struct vm_area_struct   *vma;
+       unsigned long           start, end;
        unsigned long           range_start;
        unsigned long           range_end;
        unsigned int            nr;
@@ -97,10 +98,12 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int fullmm)
+tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
-       tlb->fullmm = fullmm;
+       tlb->fullmm = !(start | (end+1));
+       tlb->start = start;
+       tlb->end = end;
        tlb->vma = NULL;
        tlb->max = ARRAY_SIZE(tlb->local);
        tlb->pages = tlb->local;
index 439827271e3d5bfada26390c9a226bbf6ec763e5..26e310c5434446c7bfc0a9a3f9b443139ffa3368 100644 (file)
@@ -21,6 +21,7 @@
 #define BOOT_CPU_MODE_EL2      (0x0e12b007)
 
 #ifndef __ASSEMBLY__
+#include <asm/cacheflush.h>
 
 /*
  * __boot_cpu_mode records what mode CPUs were booted in.
@@ -36,9 +37,20 @@ extern u32 __boot_cpu_mode[2];
 void __hyp_set_vectors(phys_addr_t phys_vector_base);
 phys_addr_t __hyp_get_vectors(void);
 
+static inline void sync_boot_mode(void)
+{
+       /*
+        * As secondaries write to __boot_cpu_mode with caches disabled, we
+        * must flush the corresponding cache entries to ensure the visibility
+        * of their writes.
+        */
+       __flush_dcache_area(__boot_cpu_mode, sizeof(__boot_cpu_mode));
+}
+
 /* Reports the availability of HYP mode */
 static inline bool is_hyp_mode_available(void)
 {
+       sync_boot_mode();
        return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 &&
                __boot_cpu_mode[1] == BOOT_CPU_MODE_EL2);
 }
@@ -46,6 +58,7 @@ static inline bool is_hyp_mode_available(void)
 /* Check if the bootloader has booted CPUs in different modes */
 static inline bool is_hyp_mode_mismatched(void)
 {
+       sync_boot_mode();
        return __boot_cpu_mode[0] != __boot_cpu_mode[1];
 }
 
index 08018e3df580c65d259470175fc95319d0589322..cbfacf7fb4387160862c906c38ad72dea395305c 100644 (file)
@@ -141,7 +141,7 @@ static void clear_os_lock(void *unused)
        isb();
 }
 
-static int __cpuinit os_lock_notify(struct notifier_block *self,
+static int os_lock_notify(struct notifier_block *self,
                                    unsigned long action, void *data)
 {
        int cpu = (unsigned long)data;
@@ -150,11 +150,11 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata os_lock_nb = {
+static struct notifier_block os_lock_nb = {
        .notifier_call = os_lock_notify,
 };
 
-static int __cpuinit debug_monitors_init(void)
+static int debug_monitors_init(void)
 {
        /* Clear the OS lock. */
        smp_call_function(clear_os_lock, NULL, 1);
index 1d1314280a03a678c4ef63092712d49079386cdd..6ad781b21c080a50c4c061dbd4037beafe8ba09b 100644 (file)
 
        .macro  get_thread_info, rd
        mov     \rd, sp
-       and     \rd, \rd, #~((1 << 13) - 1)     // top of 8K stack
+       and     \rd, \rd, #~(THREAD_SIZE - 1)   // top of stack
        .endm
 
 /*
index 5ab825c59db9f87ae70fb76d604d12ae1f0d7243..329218ca9ffbb74456155a44f827a7231e70da8a 100644 (file)
@@ -821,7 +821,7 @@ static void reset_ctrl_regs(void *unused)
        }
 }
 
-static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
+static int hw_breakpoint_reset_notify(struct notifier_block *self,
                                                unsigned long action,
                                                void *hcpu)
 {
@@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
+static struct notifier_block hw_breakpoint_reset_nb = {
        .notifier_call = hw_breakpoint_reset_notify,
 };
 
index 9ba33c40cdf8f841e974f68e599f0f97e87138ff..12e6ccb88691c65e6a20d761275babb1af369182 100644 (file)
@@ -107,7 +107,12 @@ armpmu_map_cache_event(const unsigned (*cache_map)
 static int
 armpmu_map_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
 {
-       int mapping = (*event_map)[config];
+       int mapping;
+
+       if (config >= PERF_COUNT_HW_MAX)
+               return -EINVAL;
+
+       mapping = (*event_map)[config];
        return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
 }
 
@@ -317,6 +322,9 @@ validate_event(struct pmu_hw_events *hw_events,
        struct hw_perf_event fake_event = event->hw;
        struct pmu *leader_pmu = event->group_leader->pmu;
 
+       if (is_software_event(event))
+               return 1;
+
        if (event->pmu != leader_pmu || event->state <= PERF_EVENT_STATE_OFF)
                return 1;
 
index 46f02c3b5015ece9b1ca0ab4d57d9540a3288e67..57fb55c44c901c19c7264f02ff44d6c481fadc56 100644 (file)
@@ -81,7 +81,7 @@ void soft_restart(unsigned long addr)
 void (*pm_power_off)(void);
 EXPORT_SYMBOL_GPL(pm_power_off);
 
-void (*arm_pm_restart)(char str, const char *cmd);
+void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 EXPORT_SYMBOL_GPL(arm_pm_restart);
 
 void arch_cpu_idle_prepare(void)
@@ -132,7 +132,7 @@ void machine_restart(char *cmd)
 
        /* Now call the architecture specific reboot code. */
        if (arm_pm_restart)
-               arm_pm_restart('h', cmd);
+               arm_pm_restart(reboot_mode, cmd);
 
        /*
         * Whoops - the architecture was unable to reboot.
index 5d54e3717bf81a54eedac2aabf0790745be85fd7..fee5cce834501cb9c13aaf6257b93be2b3e152e0 100644 (file)
@@ -71,7 +71,7 @@ static DEFINE_RAW_SPINLOCK(boot_lock);
  * in coherency or not.  This is necessary for the hotplug code to work
  * reliably.
  */
-static void __cpuinit write_pen_release(u64 val)
+static void write_pen_release(u64 val)
 {
        void *start = (void *)&secondary_holding_pen_release;
        unsigned long size = sizeof(secondary_holding_pen_release);
@@ -84,7 +84,7 @@ static void __cpuinit write_pen_release(u64 val)
  * Boot a secondary CPU, and assign it the specified idle task.
  * This also gives us the initial stack to use for this CPU.
  */
-static int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
+static int boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
 
@@ -122,7 +122,7 @@ static int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 
 static DECLARE_COMPLETION(cpu_running);
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
+int __cpu_up(unsigned int cpu, struct task_struct *idle)
 {
        int ret;
 
@@ -162,7 +162,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
  * This is the secondary CPU boot entry.  We're using this CPUs
  * idle thread stack, but a set of temporary page tables.
  */
-asmlinkage void __cpuinit secondary_start_kernel(void)
+asmlinkage void secondary_start_kernel(void)
 {
        struct mm_struct *mm = &init_mm;
        unsigned int cpu = smp_processor_id();
@@ -199,13 +199,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
        raw_spin_lock(&boot_lock);
        raw_spin_unlock(&boot_lock);
 
-       /*
-        * Enable local interrupts.
-        */
-       notify_cpu_starting(cpu);
-       local_irq_enable();
-       local_fiq_enable();
-
        /*
         * OK, now it's safe to let the boot CPU continue.  Wait for
         * the CPU migration code to notice that the CPU is online
@@ -214,6 +207,14 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
        set_cpu_online(cpu, true);
        complete(&cpu_running);
 
+       /*
+        * Enable GIC and timers.
+        */
+       notify_cpu_starting(cpu);
+
+       local_irq_enable();
+       local_fiq_enable();
+
        /*
         * OK, it's off to the idle thread for us
         */
index ff985e3d8b72db7861b1559cd42a59a59d957fad..1ac0bbbdddb27976ada4376fe4d28538fee7ccc4 100644 (file)
@@ -214,6 +214,7 @@ __kvm_hyp_code_start:
        mrs     x21,    tpidr_el1
        mrs     x22,    amair_el1
        mrs     x23,    cntkctl_el1
+       mrs     x24,    par_el1
 
        stp     x4, x5, [x3]
        stp     x6, x7, [x3, #16]
@@ -225,6 +226,7 @@ __kvm_hyp_code_start:
        stp     x18, x19, [x3, #112]
        stp     x20, x21, [x3, #128]
        stp     x22, x23, [x3, #144]
+       str     x24, [x3, #160]
 .endm
 
 .macro restore_sysregs
@@ -243,6 +245,7 @@ __kvm_hyp_code_start:
        ldp     x18, x19, [x3, #112]
        ldp     x20, x21, [x3, #128]
        ldp     x22, x23, [x3, #144]
+       ldr     x24, [x3, #160]
 
        msr     vmpidr_el2,     x4
        msr     csselr_el1,     x5
@@ -264,6 +267,7 @@ __kvm_hyp_code_start:
        msr     tpidr_el1,      x21
        msr     amair_el1,      x22
        msr     cntkctl_el1,    x23
+       msr     par_el1,        x24
 .endm
 
 .macro skip_32bit_state tmp, target
@@ -600,6 +604,8 @@ END(__kvm_vcpu_run)
 
 // void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
 ENTRY(__kvm_tlb_flush_vmid_ipa)
+       dsb     ishst
+
        kern_hyp_va     x0
        ldr     x2, [x0, #KVM_VTTBR]
        msr     vttbr_el2, x2
@@ -621,6 +627,7 @@ ENTRY(__kvm_tlb_flush_vmid_ipa)
 ENDPROC(__kvm_tlb_flush_vmid_ipa)
 
 ENTRY(__kvm_flush_vm_context)
+       dsb     ishst
        tlbi    alle1is
        ic      ialluis
        dsb     sy
@@ -753,6 +760,10 @@ el1_trap:
         */
        tbnz    x1, #7, 1f      // S1PTW is set
 
+       /* Preserve PAR_EL1 */
+       mrs     x3, par_el1
+       push    x3, xzr
+
        /*
         * Permission fault, HPFAR_EL2 is invalid.
         * Resolve the IPA the hard way using the guest VA.
@@ -766,6 +777,8 @@ el1_trap:
 
        /* Read result */
        mrs     x3, par_el1
+       pop     x0, xzr                 // Restore PAR_EL1 from the stack
+       msr     par_el1, x0
        tbnz    x3, #0, 3f              // Bail out if we failed the translation
        ubfx    x3, x3, #12, #36        // Extract IPA
        lsl     x3, x3, #4              // and present it like HPFAR
index 94923609753b2ae91715080fff2cd544281c8621..02e9d09e1d804b4e9344427037dd5a2b88d378ba 100644 (file)
@@ -211,6 +211,9 @@ static const struct sys_reg_desc sys_reg_descs[] = {
        /* FAR_EL1 */
        { Op0(0b11), Op1(0b000), CRn(0b0110), CRm(0b0000), Op2(0b000),
          NULL, reset_unknown, FAR_EL1 },
+       /* PAR_EL1 */
+       { Op0(0b11), Op1(0b000), CRn(0b0111), CRm(0b0100), Op2(0b000),
+         NULL, reset_unknown, PAR_EL1 },
 
        /* PMINTENSET_EL1 */
        { Op0(0b11), Op1(0b000), CRn(0b1001), CRm(0b1110), Op2(0b001),
index 0ecac8980aaefa799d063221666220c305c0de3d..6c8ba25bf6bb39eed908ea23edb05c9bb605fed2 100644 (file)
@@ -152,25 +152,8 @@ void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
 #define ESR_CM                 (1 << 8)
 #define ESR_LNX_EXEC           (1 << 24)
 
-/*
- * Check that the permissions on the VMA allow for the fault which occurred.
- * If we encountered a write fault, we must have write permission, otherwise
- * we allow any permission.
- */
-static inline bool access_error(unsigned int esr, struct vm_area_struct *vma)
-{
-       unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
-
-       if (esr & ESR_WRITE)
-               mask = VM_WRITE;
-       if (esr & ESR_LNX_EXEC)
-               mask = VM_EXEC;
-
-       return vma->vm_flags & mask ? false : true;
-}
-
 static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
-                          unsigned int esr, unsigned int flags,
+                          unsigned int mm_flags, unsigned long vm_flags,
                           struct task_struct *tsk)
 {
        struct vm_area_struct *vma;
@@ -188,12 +171,17 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
         * it.
         */
 good_area:
-       if (access_error(esr, vma)) {
+       /*
+        * Check that the permissions on the VMA allow for the fault which
+        * occurred. If we encountered a write or exec fault, we must have
+        * appropriate permissions, otherwise we allow any permission.
+        */
+       if (!(vma->vm_flags & vm_flags)) {
                fault = VM_FAULT_BADACCESS;
                goto out;
        }
 
-       return handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
+       return handle_mm_fault(mm, vma, addr & PAGE_MASK, mm_flags);
 
 check_stack:
        if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
@@ -208,9 +196,15 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
        struct task_struct *tsk;
        struct mm_struct *mm;
        int fault, sig, code;
-       bool write = (esr & ESR_WRITE) && !(esr & ESR_CM);
-       unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
-               (write ? FAULT_FLAG_WRITE : 0);
+       unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
+       unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
+
+       if (esr & ESR_LNX_EXEC) {
+               vm_flags = VM_EXEC;
+       } else if ((esr & ESR_WRITE) && !(esr & ESR_CM)) {
+               vm_flags = VM_WRITE;
+               mm_flags |= FAULT_FLAG_WRITE;
+       }
 
        tsk = current;
        mm  = tsk->mm;
@@ -248,7 +242,7 @@ retry:
 #endif
        }
 
-       fault = __do_page_fault(mm, addr, esr, flags, tsk);
+       fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk);
 
        /*
         * If we need to retry but a fatal signal is pending, handle the
@@ -265,7 +259,7 @@ retry:
         */
 
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
-       if (flags & FAULT_FLAG_ALLOW_RETRY) {
+       if (mm_flags & FAULT_FLAG_ALLOW_RETRY) {
                if (fault & VM_FAULT_MAJOR) {
                        tsk->maj_flt++;
                        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
@@ -280,7 +274,7 @@ retry:
                         * Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of
                         * starvation.
                         */
-                       flags &= ~FAULT_FLAG_ALLOW_RETRY;
+                       mm_flags &= ~FAULT_FLAG_ALLOW_RETRY;
                        goto retry;
                }
        }
index f9143196345271698a674b360769cf05c8173de4..7de083d19b7ee0b5cf9f63a14f953b7311a1564e 100644 (file)
@@ -150,7 +150,6 @@ static struct ac97c_platform_data __initdata ac97c0_data = {
 static struct platform_device rmt_ts_device = {
        .name   = "ucb1400_ts",
        .id     = -1,
-       }
 };
 #endif
 
index e47d19ae3e0634bc582eff8bf984e76c4b76bab2..974e55496db305cd5a17a07a5fcd9a5c25c48316 100644 (file)
@@ -468,7 +468,7 @@ static void bfin_pmu_setup(int cpu)
        memset(cpuhw, 0, sizeof(struct cpu_hw_events));
 }
 
-static int __cpuinit
+static int
 bfin_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (long)hcpu;
index 107b306b06f10819fe1fc6c3d1e3e87cdaa3afc6..19ad0637e8ff0e6081b8253c38a41a025da74ba8 100644 (file)
@@ -99,7 +99,7 @@ void __init generate_cplb_tables(void)
 }
 #endif
 
-void __cpuinit bfin_setup_caches(unsigned int cpu)
+void bfin_setup_caches(unsigned int cpu)
 {
 #ifdef CONFIG_BFIN_ICACHE
        bfin_icache_init(icplb_tbl[cpu]);
@@ -165,7 +165,7 @@ void __cpuinit bfin_setup_caches(unsigned int cpu)
 #endif
 }
 
-void __cpuinit bfin_setup_cpudata(unsigned int cpu)
+void bfin_setup_cpudata(unsigned int cpu)
 {
        struct blackfin_cpudata *cpudata = &per_cpu(cpu_data, cpu);
 
index c77a23bc9de3ff46693e4bfdb815adca8fc4164e..11789beca75a92fa041efc519b15c0ed3ca879c3 100644 (file)
@@ -48,7 +48,7 @@ int __init setup_profiling_timer(unsigned int multiplier) /* not supported */
        return -EINVAL;
 }
 
-void __cpuinit platform_secondary_init(unsigned int cpu)
+void platform_secondary_init(unsigned int cpu)
 {
        /* Clone setup for peripheral interrupt sources from CoreA. */
        bfin_write_SICB_IMASK0(bfin_read_SIC_IMASK0());
@@ -73,7 +73,7 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
        spin_unlock(&boot_lock);
 }
 
-int __cpuinit platform_boot_secondary(unsigned int cpu, struct task_struct *idle)
+int platform_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long timeout;
 
@@ -154,7 +154,7 @@ void platform_clear_ipi(unsigned int cpu, int irq)
  * Setup core B's local core timer.
  * In SMP, core timer is used for clock event device.
  */
-void __cpuinit bfin_local_timer_setup(void)
+void bfin_local_timer_setup(void)
 {
 #if defined(CONFIG_TICKSOURCE_CORETMR)
        struct irq_data *data = irq_get_irq_data(IRQ_CORETMR);
index a60a24f5035d3bb0ccc30a59bd073f611c9a5f85..0e1e451fd7d81aed622ef16bbbe0c0dcbf12502d 100644 (file)
@@ -52,7 +52,7 @@ bfin_cache_init(struct cplb_entry *cplb_tbl, unsigned long cplb_addr,
 }
 
 #ifdef CONFIG_BFIN_ICACHE
-void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl)
+void bfin_icache_init(struct cplb_entry *icplb_tbl)
 {
        bfin_cache_init(icplb_tbl, ICPLB_ADDR0, ICPLB_DATA0, IMEM_CONTROL,
                (IMC | ENICPLB));
@@ -60,7 +60,7 @@ void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl)
 #endif
 
 #ifdef CONFIG_BFIN_DCACHE
-void __cpuinit bfin_dcache_init(struct cplb_entry *dcplb_tbl)
+void bfin_dcache_init(struct cplb_entry *dcplb_tbl)
 {
        /*
         *  Anomaly notes:
index 6c0c6816a51a1f2c22ef7805d1c26999d1471874..d143fd8d2bc5075544e0bc6655306bd66bae90ca 100644 (file)
@@ -1281,7 +1281,7 @@ static struct irq_chip bfin_gpio_irqchip = {
        .irq_set_wake = bfin_gpio_set_wake,
 };
 
-void __cpuinit init_exception_vectors(void)
+void init_exception_vectors(void)
 {
        /* cannot program in software:
         * evt0 - emulation (jtag)
index 961d8392e5e338aad75200026600624273e9f7ce..82f301c117a508b562cf16bd698f61e1ed9f0797 100644 (file)
@@ -46,7 +46,7 @@ struct corelock_slot corelock __attribute__ ((__section__(".l2.bss")));
 unsigned long blackfin_iflush_l1_entry[NR_CPUS];
 #endif
 
-struct blackfin_initial_pda __cpuinitdata initial_pda_coreb;
+struct blackfin_initial_pda initial_pda_coreb;
 
 enum ipi_message_type {
        BFIN_IPI_NONE,
@@ -147,7 +147,7 @@ static irqreturn_t ipi_handler_int1(int irq, void *dev_instance)
        platform_clear_ipi(cpu, IRQ_SUPPLE_1);
 
        bfin_ipi_data = &__get_cpu_var(bfin_ipi);
-       while ((pending = xchg(&bfin_ipi_data->bits, 0)) != 0) {
+       while ((pending = atomic_xchg(&bfin_ipi_data->bits, 0)) != 0) {
                msg = 0;
                do {
                        msg = find_next_bit(&pending, BITS_PER_LONG, msg + 1);
@@ -182,8 +182,8 @@ static void bfin_ipi_init(void)
        struct ipi_data *bfin_ipi_data;
        for_each_possible_cpu(cpu) {
                bfin_ipi_data = &per_cpu(bfin_ipi, cpu);
-               bfin_ipi_data->bits = 0;
-               bfin_ipi_data->count = 0;
+               atomic_set(&bfin_ipi_data->bits, 0);
+               atomic_set(&bfin_ipi_data->count, 0);
        }
 }
 
@@ -246,7 +246,7 @@ void smp_send_stop(void)
        return;
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
+int __cpu_up(unsigned int cpu, struct task_struct *idle)
 {
        int ret;
 
@@ -259,7 +259,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
        return ret;
 }
 
-static void __cpuinit setup_secondary(unsigned int cpu)
+static void setup_secondary(unsigned int cpu)
 {
        unsigned long ilat;
 
@@ -277,7 +277,7 @@ static void __cpuinit setup_secondary(unsigned int cpu)
            IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
 }
 
-void __cpuinit secondary_start_kernel(void)
+void secondary_start_kernel(void)
 {
        unsigned int cpu = smp_processor_id();
        struct mm_struct *mm = &init_mm;
@@ -402,7 +402,7 @@ EXPORT_SYMBOL(resync_core_dcache);
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
-int __cpuexit __cpu_disable(void)
+int __cpu_disable(void)
 {
        unsigned int cpu = smp_processor_id();
 
@@ -415,7 +415,7 @@ int __cpuexit __cpu_disable(void)
 
 static DECLARE_COMPLETION(cpu_killed);
 
-int __cpuexit __cpu_die(unsigned int cpu)
+int __cpu_die(unsigned int cpu)
 {
        return wait_for_completion_timeout(&cpu_killed, 5000);
 }
index cdd12028de0c5254e1622b97a38e9d20e14c3095..fe8e6039db2a04aa3c133385322fe6573b7b2b11 100644 (file)
@@ -197,7 +197,7 @@ int setup_profiling_timer(unsigned int multiplier)
  */
 unsigned long cache_decay_ticks = 1;
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        smp_boot_one_cpu(cpu, tidle);
        return cpu_online(cpu) ? 0 : -ENOSYS;
index ae3a6706419bcf5b6ada7f12c95e3b68dbdbd3d0..9f3a7a62d7873dc29caa8bf66eaa35a7489edf66 100644 (file)
@@ -709,7 +709,7 @@ static void __init reserve_dma_coherent(void)
 /*
  * calibrate the delay loop
  */
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        loops_per_jiffy = __delay_loops_MHz * (1000000 / HZ);
 
index 33a97929d055ca9d1131ffce9c517b3a4597bb38..77d442ab28c8625860c1787df12ac9dd74d7f004 100644 (file)
@@ -158,6 +158,7 @@ source "kernel/Kconfig.hz"
 endmenu
 
 source "init/Kconfig"
+source "kernel/Kconfig.freezer"
 source "drivers/Kconfig"
 source "fs/Kconfig"
 
index bfe13311d70d5c853f6f6a65e7f41abe753d16ff..29d1f1b0001656376d1730020f6f27946ff067ff 100644 (file)
@@ -41,7 +41,7 @@ static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 
 int on_simulator;
 
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        loops_per_jiffy = thread_freq_mhz * 1000000 / HZ;
 }
index 0e364ca4319811b34ad71f213cb226e819ba7e9e..9faaa940452b98ad0f10ecd695af138133e990a6 100644 (file)
@@ -146,7 +146,7 @@ void __init smp_prepare_boot_cpu(void)
  * to point to current thread info
  */
 
-void __cpuinit start_secondary(void)
+void start_secondary(void)
 {
        unsigned int cpu;
        unsigned long thread_ptr;
@@ -194,7 +194,7 @@ void __cpuinit start_secondary(void)
  * maintains control until "cpu_online(cpu)" is set.
  */
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
+int __cpu_up(unsigned int cpu, struct task_struct *idle)
 {
        struct thread_info *thread = (struct thread_info *)idle->stack;
        void *stack_start;
index 7913695b2fcbe5605830b9e1da6441188a591b8b..efbd2929aeb75c563b5ccbf4b267be596ce921e2 100644 (file)
@@ -31,7 +31,7 @@ CONFIG_ACPI_FAN=m
 CONFIG_ACPI_DOCK=y
 CONFIG_ACPI_PROCESSOR=m
 CONFIG_ACPI_CONTAINER=m
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_ACPI=m
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index f8e91336542392236c878276ad8abcef4d786166..f64980dd20c3f3851174c25c63152578910f255d 100644 (file)
@@ -25,7 +25,7 @@ CONFIG_ACPI_BUTTON=m
 CONFIG_ACPI_FAN=m
 CONFIG_ACPI_PROCESSOR=m
 CONFIG_ACPI_CONTAINER=m
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_ACPI=m
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index a5a9e02e60a05c94e9b9a4c6c35a6cf78eecf429..0f4e9e41f130623baae948b022dbd01468869331 100644 (file)
@@ -31,7 +31,7 @@ CONFIG_ACPI_BUTTON=m
 CONFIG_ACPI_FAN=m
 CONFIG_ACPI_PROCESSOR=m
 CONFIG_ACPI_CONTAINER=m
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_ACPI=m
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index 37b9b422caadf9c89196aa63781d9cdb2a05830d..b025acfde5c1dc4fff39be616007fd7391f11276 100644 (file)
@@ -32,7 +32,7 @@ CONFIG_ACPI_BUTTON=m
 CONFIG_ACPI_FAN=m
 CONFIG_ACPI_PROCESSOR=m
 CONFIG_ACPI_CONTAINER=m
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_ACPI=m
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index ef3a9de01954511a352fa5b24285136789425e21..bc5efc7c3f3f8ead3608780ba5e2f5b9e212e20c 100644 (file)
@@ -22,7 +22,7 @@
  * unmapping a portion of the virtual address space, these hooks are called according to
  * the following template:
  *
- *     tlb <- tlb_gather_mmu(mm, full_mm_flush);       // start unmap for address space MM
+ *     tlb <- tlb_gather_mmu(mm, start, end);          // start unmap for address space MM
  *     {
  *       for each vma that needs a shootdown do {
  *         tlb_start_vma(tlb, vma);
@@ -58,6 +58,7 @@ struct mmu_gather {
        unsigned int            max;
        unsigned char           fullmm;         /* non-zero means full mm flush */
        unsigned char           need_flush;     /* really unmapped some PTEs? */
+       unsigned long           start, end;
        unsigned long           start_addr;
        unsigned long           end_addr;
        struct page             **pages;
@@ -155,13 +156,15 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb)
 
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
+tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
        tlb->max = ARRAY_SIZE(tlb->local);
        tlb->pages = tlb->local;
        tlb->nr = 0;
-       tlb->fullmm = full_mm_flush;
+       tlb->fullmm = !(start | (end+1));
+       tlb->start = start;
+       tlb->end = end;
        tlb->start_addr = ~0UL;
 }
 
index 0ac558adc60559cdd4e50ef95b02a547f71bdf30..bb21f4f63170053c3b2237ba6f73727d9e134d13 100644 (file)
@@ -343,7 +343,7 @@ static void __init do_boot_cpu(int phys_id)
        }
 }
 
-int __cpuinit __cpu_up(unsigned int cpu_id, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu_id, struct task_struct *tidle)
 {
        int timeout;
 
index 2291a7d69d49a27c541a4746492d7be01ba17727..fa277aecfb78f1256dae50e30b0d873afbb72949 100644 (file)
 #include <asm/machdep.h>
 #include <asm/natfeat.h>
 
+extern long nf_get_id2(const char *feature_name);
+
 asm("\n"
-"      .global nf_get_id,nf_call\n"
-"nf_get_id:\n"
+"      .global nf_get_id2,nf_call\n"
+"nf_get_id2:\n"
 "      .short  0x7300\n"
 "      rts\n"
 "nf_call:\n"
@@ -29,12 +31,25 @@ asm("\n"
 "1:    moveq.l #0,%d0\n"
 "      rts\n"
 "      .section __ex_table,\"a\"\n"
-"      .long   nf_get_id,1b\n"
+"      .long   nf_get_id2,1b\n"
 "      .long   nf_call,1b\n"
 "      .previous");
-EXPORT_SYMBOL_GPL(nf_get_id);
 EXPORT_SYMBOL_GPL(nf_call);
 
+long nf_get_id(const char *feature_name)
+{
+       /* feature_name may be in vmalloc()ed memory, so make a copy */
+       char name_copy[32];
+       size_t n;
+
+       n = strlcpy(name_copy, feature_name, sizeof(name_copy));
+       if (n >= sizeof(name_copy))
+               return 0;
+
+       return nf_get_id2(name_copy);
+}
+EXPORT_SYMBOL_GPL(nf_get_id);
+
 void nfprint(const char *fmt, ...)
 {
        static char buf[256];
index 444ea8a09e9f3386434e89d502c41d1f4107302e..ef881cfbbca90987bf0e93c9271537317c15886c 100644 (file)
                unsigned long long n64;                         \
        } __n;                                                  \
        unsigned long __rem, __upper;                           \
+       unsigned long __base = (base);                          \
                                                                \
        __n.n64 = (n);                                          \
        if ((__upper = __n.n32[0])) {                           \
                asm ("divul.l %2,%1:%0"                         \
-                       : "=d" (__n.n32[0]), "=d" (__upper)     \
-                       : "d" (base), "0" (__n.n32[0]));        \
+                    : "=d" (__n.n32[0]), "=d" (__upper)        \
+                    : "d" (__base), "0" (__n.n32[0]));         \
        }                                                       \
        asm ("divu.l %2,%1:%0"                                  \
-               : "=d" (__n.n32[1]), "=d" (__rem)               \
-               : "d" (base), "1" (__upper), "0" (__n.n32[1])); \
+            : "=d" (__n.n32[1]), "=d" (__rem)                  \
+            : "d" (__base), "1" (__upper), "0" (__n.n32[1]));  \
        (n) = __n.n64;                                          \
        __rem;                                                  \
 })
index 5b18888ee3648d5575e911499c3fd14c07260e99..5cc4d4dcf3cfda9113a3dbc25d14c18e05bae978 100644 (file)
@@ -813,8 +813,8 @@ static struct metag_pmu _metag_pmu = {
 };
 
 /* PMU CPU hotplug notifier */
-static int __cpuinit metag_pmu_cpu_notify(struct notifier_block *b,
-               unsigned long action, void *hcpu)
+static int metag_pmu_cpu_notify(struct notifier_block *b, unsigned long action,
+                               void *hcpu)
 {
        unsigned int cpu = (unsigned int)hcpu;
        struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
@@ -828,7 +828,7 @@ static int __cpuinit metag_pmu_cpu_notify(struct notifier_block *b,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata metag_pmu_notifier = {
+static struct notifier_block metag_pmu_notifier = {
        .notifier_call = metag_pmu_cpu_notify,
 };
 
index e413875cf6d2d7e5866daae7ab31d64a466c4e05..7c01131429817ab58ce63490cc97e5dba4f4b4c9 100644 (file)
@@ -68,7 +68,7 @@ static DECLARE_COMPLETION(cpu_running);
 /*
  * "thread" is assumed to be a valid Meta hardware thread ID.
  */
-int __cpuinit boot_secondary(unsigned int thread, struct task_struct *idle)
+int boot_secondary(unsigned int thread, struct task_struct *idle)
 {
        u32 val;
 
@@ -118,11 +118,9 @@ int __cpuinit boot_secondary(unsigned int thread, struct task_struct *idle)
  * If the cache partition has changed, prints a message to the log describing
  * those changes.
  */
-static __cpuinit void describe_cachepart_change(unsigned int thread,
-                                               const char *label,
-                                               unsigned int sz,
-                                               unsigned int old,
-                                               unsigned int new)
+static void describe_cachepart_change(unsigned int thread, const char *label,
+                                     unsigned int sz, unsigned int old,
+                                     unsigned int new)
 {
        unsigned int lor1, land1, gor1, gand1;
        unsigned int lor2, land2, gor2, gand2;
@@ -170,7 +168,7 @@ static __cpuinit void describe_cachepart_change(unsigned int thread,
  * Ensures that coherency is enabled and that the threads share the same cache
  * partitions.
  */
-static __cpuinit void setup_smp_cache(unsigned int thread)
+static void setup_smp_cache(unsigned int thread)
 {
        unsigned int this_thread, lflags;
        unsigned int dcsz, dcpart_this, dcpart_old, dcpart_new;
@@ -215,7 +213,7 @@ static __cpuinit void setup_smp_cache(unsigned int thread)
                                  icpart_old, icpart_new);
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
+int __cpu_up(unsigned int cpu, struct task_struct *idle)
 {
        unsigned int thread = cpu_2_hwthread_id[cpu];
        int ret;
@@ -268,7 +266,7 @@ static DECLARE_COMPLETION(cpu_killed);
 /*
  * __cpu_disable runs on the processor to be shutdown.
  */
-int __cpuexit __cpu_disable(void)
+int __cpu_disable(void)
 {
        unsigned int cpu = smp_processor_id();
 
@@ -299,7 +297,7 @@ int __cpuexit __cpu_disable(void)
  * called on the thread which is asking for a CPU to be shutdown -
  * waits until shutdown has completed, or it is timed out.
  */
-void __cpuexit __cpu_die(unsigned int cpu)
+void __cpu_die(unsigned int cpu)
 {
        if (!wait_for_completion_timeout(&cpu_killed, msecs_to_jiffies(1)))
                pr_err("CPU%u: unable to kill\n", cpu);
@@ -311,7 +309,7 @@ void __cpuexit __cpu_die(unsigned int cpu)
  * Note that we do not return from this function. If this cpu is
  * brought online again it will need to run secondary_startup().
  */
-void __cpuexit cpu_die(void)
+void cpu_die(void)
 {
        local_irq_disable();
        idle_task_exit();
@@ -326,7 +324,7 @@ void __cpuexit cpu_die(void)
  * Called by both boot and secondaries to move global data into
  * per-processor storage.
  */
-void __cpuinit smp_store_cpu_info(unsigned int cpuid)
+void smp_store_cpu_info(unsigned int cpuid)
 {
        struct cpuinfo_metag *cpu_info = &per_cpu(cpu_data, cpuid);
 
index c00ade0228ef8f11ff140577f0e712956e0003ee..25f9d1c2ffecd35f93b4517aa0f1baae815a9380 100644 (file)
@@ -812,7 +812,7 @@ static void set_trigger_mask(unsigned int mask)
 }
 #endif
 
-void __cpuinit per_cpu_trap_init(unsigned long cpu)
+void per_cpu_trap_init(unsigned long cpu)
 {
        TBIRES int_context;
        unsigned int thread = cpu_2_hwthread_id[cpu];
index d22a4ecffff422f542e96f81527b45a4e3f9c6c2..4fab52294d9874b5b07558682ec5160a470c1092 100644 (file)
@@ -28,7 +28,7 @@ config MICROBLAZE
        select GENERIC_CLOCKEVENTS
        select GENERIC_IDLE_POLL_SETUP
        select MODULES_USE_ELF_RELA
-       select CLONE_BACKWARDS
+       select CLONE_BACKWARDS3
 
 config SWAP
        def_bool n
index 4758a8fd3e99176feebe955f75ce048819d62064..e12764c2a9d08163e7d066f276f4b8b87e16e208 100644 (file)
@@ -114,6 +114,7 @@ config BCM47XX
        select FW_CFE
        select HW_HAS_PCI
        select IRQ_CPU
+       select SYS_HAS_CPU_MIPS32_R1
        select NO_EXCEPT_FILL
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
@@ -1702,6 +1703,7 @@ endchoice
 
 config KVM_GUEST
        bool "KVM Guest Kernel"
+       depends on BROKEN_ON_SMP
        help
          Select this option if building a guest kernel for KVM (Trap & Emulate) mode
 
index 8be4e856b8b8942e903c286c2004fb46c4d0df9d..80f4ecd42b0dc3ca21a57bf2e52745d0c389b769 100644 (file)
@@ -182,7 +182,7 @@ const char *get_system_type(void)
        return ath79_sys_type;
 }
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        return CP0_LEGACY_COMPARE_IRQ;
 }
index ba611927749b9f81def164126a2b2b1d00bf42c5..2b8b118398c458573652c5b9e058a302ddcaf766 100644 (file)
@@ -2,7 +2,6 @@ if BCM47XX
 
 config BCM47XX_SSB
        bool "SSB Support for Broadcom BCM47XX"
-       select SYS_HAS_CPU_MIPS32_R1
        select SSB
        select SSB_DRIVER_MIPS
        select SSB_DRIVER_EXTIF
index 7181def6037a174a80880502f3e3fb75565516ca..9d36774bded117b6658327e249d1fd4e4e187d0d 100644 (file)
@@ -1095,7 +1095,7 @@ static void octeon_irq_ip3_ciu(void)
 
 static bool octeon_irq_use_ip4;
 
-static void __cpuinit octeon_irq_local_enable_ip4(void *arg)
+static void octeon_irq_local_enable_ip4(void *arg)
 {
        set_c0_status(STATUSF_IP4);
 }
@@ -1110,21 +1110,21 @@ static void (*octeon_irq_ip2)(void);
 static void (*octeon_irq_ip3)(void);
 static void (*octeon_irq_ip4)(void);
 
-void __cpuinitdata (*octeon_irq_setup_secondary)(void);
+void (*octeon_irq_setup_secondary)(void);
 
-void __cpuinit octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t h)
+void octeon_irq_set_ip4_handler(octeon_irq_ip4_handler_t h)
 {
        octeon_irq_ip4 = h;
        octeon_irq_use_ip4 = true;
        on_each_cpu(octeon_irq_local_enable_ip4, NULL, 1);
 }
 
-static void __cpuinit octeon_irq_percpu_enable(void)
+static void octeon_irq_percpu_enable(void)
 {
        irq_cpu_online();
 }
 
-static void __cpuinit octeon_irq_init_ciu_percpu(void)
+static void octeon_irq_init_ciu_percpu(void)
 {
        int coreid = cvmx_get_core_num();
 
@@ -1167,7 +1167,7 @@ static void octeon_irq_init_ciu2_percpu(void)
        cvmx_read_csr(CVMX_CIU2_SUM_PPX_IP2(coreid));
 }
 
-static void __cpuinit octeon_irq_setup_secondary_ciu(void)
+static void octeon_irq_setup_secondary_ciu(void)
 {
        octeon_irq_init_ciu_percpu();
        octeon_irq_percpu_enable();
index 7b746e7bf7a1aad7672986bb8b986b7a18716a12..1830874ff1e24e4ddab1150e438edbb6342cc000 100644 (file)
@@ -334,9 +334,10 @@ static void __init octeon_fdt_pip_iface(int pip, int idx, u64 *pmac)
        char name_buffer[20];
        int iface;
        int p;
-       int count;
+       int count = 0;
 
-       count = cvmx_helper_interface_enumerate(idx);
+       if (cvmx_helper_interface_enumerate(idx) == 0)
+               count = cvmx_helper_ports_on_interface(idx);
 
        snprintf(name_buffer, sizeof(name_buffer), "interface@%d", idx);
        iface = fdt_subnode_offset(initial_boot_params, pip, name_buffer);
index 295137dfdc37ce61d323e45c1f7839e84f2245bc..138cc80c592817d523b4b7a82c2f2aadaa37eae8 100644 (file)
@@ -173,7 +173,7 @@ static void octeon_boot_secondary(int cpu, struct task_struct *idle)
  * After we've done initial boot, this function is called to allow the
  * board code to clean up state, if needed
  */
-static void __cpuinit octeon_init_secondary(void)
+static void octeon_init_secondary(void)
 {
        unsigned int sr;
 
@@ -375,7 +375,7 @@ static int octeon_update_boot_vector(unsigned int cpu)
        return 0;
 }
 
-static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb,
+static int octeon_cpu_callback(struct notifier_block *nfb,
        unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
@@ -394,7 +394,7 @@ static int __cpuinit octeon_cpu_callback(struct notifier_block *nfb,
        return NOTIFY_OK;
 }
 
-static int __cpuinit register_cavium_notifier(void)
+static int register_cavium_notifier(void)
 {
        hotcpu_notifier(octeon_cpu_callback, 0);
        return 0;
index 1dc086087a723fd9c90c427d05f4eb3c8ca919f6..fa44f3ec530214f5014664cda4611b1a5a027251 100644 (file)
@@ -17,6 +17,8 @@
 #define current_cpu_type()     current_cpu_data.cputype
 #endif
 
+#define boot_cpu_type()                cpu_data[0].cputype
+
 /*
  * SMP assumption: Options of CPU 0 are a superset of all processors.
  * This is true for all known MIPS systems.
index 5b2f2e68e57f08210be7d4a98370cb3895111adf..9488fa5f886603fdef1ac258182bf82d61004faf 100644 (file)
 #else
 #define CAC_BASE               _AC(0x80000000, UL)
 #endif
+#ifndef IO_BASE
 #define IO_BASE                        _AC(0xa0000000, UL)
+#endif
+#ifndef UNCAC_BASE
 #define UNCAC_BASE             _AC(0xa0000000, UL)
+#endif
 
 #ifndef MAP_BASE
 #ifdef CONFIG_KVM_GUEST
index 370d967725c28d0e59d26ad8726f2ad052d5d2fa..c33a9564fb41bc6d5a7aff644d7520c2adf7c0ce 100644 (file)
 
 #ifdef CONFIG_EXPORT_UASM
 #include <linux/export.h>
-#define __uasminit
-#define __uasminitdata
 #define UASM_EXPORT_SYMBOL(sym) EXPORT_SYMBOL(sym)
 #else
-#define __uasminit __cpuinit
-#define __uasminitdata __cpuinitdata
 #define UASM_EXPORT_SYMBOL(sym)
 #endif
 
 #endif
 
 #define Ip_u1u2u3(op)                                                  \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
 
 #define Ip_u2u1u3(op)                                                  \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
 
 #define Ip_u3u1u2(op)                                                  \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c)
 
 #define Ip_u1u2s3(op)                                                  \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
 
 #define Ip_u2s3u1(op)                                                  \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c)
+void ISAOPC(op)(u32 **buf, unsigned int a, signed int b, unsigned int c)
 
 #define Ip_u2u1s3(op)                                                  \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, signed int c)
 
 #define Ip_u2u1msbu3(op)                                               \
-void __uasminit                                                                \
-ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c,  \
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b, unsigned int c, \
           unsigned int d)
 
 #define Ip_u1u2(op)                                                    \
-void __uasminit ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b)
+void ISAOPC(op)(u32 **buf, unsigned int a, unsigned int b)
 
 #define Ip_u1s2(op)                                                    \
-void __uasminit ISAOPC(op)(u32 **buf, unsigned int a, signed int b)
+void ISAOPC(op)(u32 **buf, unsigned int a, signed int b)
 
-#define Ip_u1(op) void __uasminit ISAOPC(op)(u32 **buf, unsigned int a)
+#define Ip_u1(op) void ISAOPC(op)(u32 **buf, unsigned int a)
 
-#define Ip_0(op) void __uasminit ISAOPC(op)(u32 **buf)
+#define Ip_0(op) void ISAOPC(op)(u32 **buf)
 
 Ip_u2u1s3(_addiu);
 Ip_u3u1u2(_addu);
@@ -163,7 +152,7 @@ struct uasm_label {
        int lab;
 };
 
-void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr,
+void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr,
                        int lid);
 #ifdef CONFIG_64BIT
 int ISAFUNC(uasm_in_compat_space_p)(long addr);
@@ -174,7 +163,7 @@ void ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr);
 void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr);
 
 #define UASM_L_LA(lb)                                                  \
-static inline void __uasminit ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \
+static inline void ISAFUNC(uasm_l##lb)(struct uasm_label **lab, u32 *addr) \
 {                                                                      \
        ISAFUNC(uasm_build_label)(lab, addr, label##lb);                \
 }
index b7a23064841f2171173dbaca04027381000e02d4..88e292b7719e99963f74692f0ffbd36e60e79c83 100644 (file)
@@ -25,11 +25,12 @@ struct siginfo;
 /*
  * Careful to keep union _sifields from shifting ...
  */
-#if __SIZEOF_LONG__ == 4
+#if _MIPS_SZLONG == 32
 #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
-#endif
-#if __SIZEOF_LONG__ == 8
+#elif _MIPS_SZLONG == 64
 #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
+#else
+#error _MIPS_SZLONG neither 32 nor 64
 #endif
 
 #include <asm-generic/siginfo.h>
index 64c4fd62cf08b2577ac40186469dd65dc5ccd334..bd79c4f9bff403eeb2e320343b83d81d70855852 100644 (file)
@@ -28,8 +28,6 @@
        .set    mips0
        .endm
 
-       __CPUINIT
-
 /***********************************************************************
  * Alternate CPU1 startup vector for BMIPS4350
  *
@@ -56,7 +54,11 @@ LEAF(bmips_smp_movevec)
        /* set up CPU1 CBR; move BASE to 0xa000_0000 */
        li      k0, 0xff400000
        mtc0    k0, $22, 6
-       li      k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_1
+       /* set up relocation vector address based on thread ID */
+       mfc0    k1, $22, 3
+       srl     k1, 16
+       andi    k1, 0x8000
+       or      k1, CKSEG1 | BMIPS_RELO_VECTOR_CONTROL_0
        or      k0, k1
        li      k1, 0xa0080000
        sw      k1, 0(k0)
@@ -216,8 +218,6 @@ END(bmips_smp_int_vec)
  * Certain CPUs support extending kseg0 to 1024MB.
  ***********************************************************************/
 
-       __CPUINIT
-
 LEAF(bmips_enable_xks01)
 
 #if defined(CONFIG_XKS01)
index 15f618b40cf6c1dcaf8f8c835f7e2d1f7d89382a..7976457184b1801771fdcd31e7b9e40b3633992b 100644 (file)
@@ -109,7 +109,7 @@ static DEFINE_PER_CPU(struct clock_event_device, sibyte_hpt_clockevent);
 static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction);
 static DEFINE_PER_CPU(char [18], sibyte_hpt_name);
 
-void __cpuinit sb1480_clockevent_init(void)
+void sb1480_clockevent_init(void)
 {
        unsigned int cpu = smp_processor_id();
        unsigned int irq = K_BCM1480_INT_TIMER_0 + cpu;
index 730eaf92c0189a8c12f7a91ad58f4a164fea1d77..594cbbf16d627815383fa5385ad852848dcae16c 100644 (file)
@@ -59,7 +59,7 @@ void gic_event_handler(struct clock_event_device *dev)
 {
 }
 
-int __cpuinit gic_clockevent_init(void)
+int gic_clockevent_init(void)
 {
        unsigned int cpu = smp_processor_id();
        struct clock_event_device *cd;
index 02033eaf8825420eea30105e92edcc795d8b5b70..50d3f5a8d6bb1a9657ec9baa5ccd6852734ad6cf 100644 (file)
@@ -171,7 +171,7 @@ int c0_compare_int_usable(void)
 }
 
 #ifndef CONFIG_MIPS_MT_SMTC
-int __cpuinit r4k_clockevent_init(void)
+int r4k_clockevent_init(void)
 {
        unsigned int cpu = smp_processor_id();
        struct clock_event_device *cd;
index 200f2778bf3660f8acb6cbc4b9eef72f37f0418e..5ea6d6b1de1504f39f5d0e670c7439775dab1083 100644 (file)
@@ -107,7 +107,7 @@ static DEFINE_PER_CPU(struct clock_event_device, sibyte_hpt_clockevent);
 static DEFINE_PER_CPU(struct irqaction, sibyte_hpt_irqaction);
 static DEFINE_PER_CPU(char [18], sibyte_hpt_name);
 
-void __cpuinit sb1250_clockevent_init(void)
+void sb1250_clockevent_init(void)
 {
        unsigned int cpu = smp_processor_id();
        unsigned int irq = K_INT_TIMER_0 + cpu;
index 9de5ed7ef1a36f79da437e377a2d69d0a4d1bca5..b6cf0a60d89681b2c05e33acb756b893f1a7ffec 100644 (file)
@@ -248,7 +248,7 @@ irqreturn_t c0_compare_interrupt(int irq, void *dev_id)
 }
 
 
-int __cpuinit smtc_clockevent_init(void)
+int smtc_clockevent_init(void)
 {
        uint64_t mips_freq = mips_hpt_frequency;
        unsigned int cpu = smp_processor_id();
index 0c61df281ce6788a299d655df68d874d02c6f71d..2d80b5f1aeae29361843640d1d0c4148cbf489fd 100644 (file)
@@ -168,7 +168,7 @@ static inline void check_mult_sh(void)
        panic(bug64hit, !R4000_WAR ? r4kwar : nowar);
 }
 
-static volatile int daddi_ov __cpuinitdata;
+static volatile int daddi_ov;
 
 asmlinkage void __init do_daddi_ov(struct pt_regs *regs)
 {
index c7b1b3c5a761c0c46067ee940a722eb5ab490e5d..4c6167a178754ecab7b0b456129c6d979626b399 100644 (file)
@@ -27,7 +27,7 @@
 #include <asm/spram.h>
 #include <asm/uaccess.h>
 
-static int __cpuinitdata mips_fpu_disabled;
+static int mips_fpu_disabled;
 
 static int __init fpu_disable(char *s)
 {
@@ -39,7 +39,7 @@ static int __init fpu_disable(char *s)
 
 __setup("nofpu", fpu_disable);
 
-int __cpuinitdata mips_dsp_disabled;
+int mips_dsp_disabled;
 
 static int __init dsp_disable(char *s)
 {
@@ -134,7 +134,7 @@ static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
 #endif
 }
 
-static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa)
+static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
 {
        switch (isa) {
        case MIPS_CPU_ISA_M64R2:
@@ -159,7 +159,7 @@ static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa)
        }
 }
 
-static char unknown_isa[] __cpuinitdata = KERN_ERR \
+static char unknown_isa[] = KERN_ERR \
        "Unsupported ISA type, c0.config0: %d.";
 
 static inline unsigned int decode_config0(struct cpuinfo_mips *c)
@@ -290,7 +290,7 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c)
        return config4 & MIPS_CONF_M;
 }
 
-static void __cpuinit decode_configs(struct cpuinfo_mips *c)
+static void decode_configs(struct cpuinfo_mips *c)
 {
        int ok;
 
@@ -962,7 +962,7 @@ EXPORT_SYMBOL(__ua_limit);
 const char *__cpu_name[NR_CPUS];
 const char *__elf_platform;
 
-__cpuinit void cpu_probe(void)
+void cpu_probe(void)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        unsigned int cpu = smp_processor_id();
@@ -1047,7 +1047,7 @@ __cpuinit void cpu_probe(void)
 #endif
 }
 
-__cpuinit void cpu_report(void)
+void cpu_report(void)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
 
index 09991232442394d68964efd5ac1d978afa706b5b..7b6a5b3e3acf6af099f8fe30a980cc43ac120ace 100644 (file)
@@ -158,8 +158,6 @@ NESTED(kernel_entry, 16, sp)                        # kernel entry point
        j               start_kernel
        END(kernel_entry)
 
-       __CPUINIT
-
 #ifdef CONFIG_SMP
 /*
  * SMP slave cpus entry point. Board specific code for bootstrap calls this
@@ -188,5 +186,3 @@ NESTED(smp_bootstrap, 16, sp)
        j       start_secondary
        END(smp_bootstrap)
 #endif /* CONFIG_SMP */
-
-       __FINIT
index aea6c088583847d93092f4125cdfa1dca35fa495..126da74d4c5559faf40962b80bddef9a39721757 100644 (file)
@@ -66,6 +66,8 @@ static void __init bmips_smp_setup(void)
        int i, cpu = 1, boot_cpu = 0;
 
 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
+       int cpu_hw_intr;
+
        /* arbitration priority */
        clear_c0_brcm_cmt_ctrl(0x30);
 
@@ -79,15 +81,13 @@ static void __init bmips_smp_setup(void)
         * MIPS interrupts 0,1 (SW INT 0,1) cross over to the other thread
         * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output
         * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output
-        *
-        * If booting from TP1, leave the existing CMT interrupt routing
-        * such that TP0 responds to SW1 and TP1 responds to SW0.
         */
        if (boot_cpu == 0)
-               change_c0_brcm_cmt_intr(0xf8018000,
-                                       (0x02 << 27) | (0x03 << 15));
+               cpu_hw_intr = 0x02;
        else
-               change_c0_brcm_cmt_intr(0xf8018000, (0x1d << 27));
+               cpu_hw_intr = 0x1d;
+
+       change_c0_brcm_cmt_intr(0xf8018000, (cpu_hw_intr << 27) | (0x03 << 15));
 
        /* single core, 2 threads (2 pipelines) */
        max_cpus = 2;
@@ -173,7 +173,7 @@ static void bmips_boot_secondary(int cpu, struct task_struct *idle)
        else {
 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
                /* Reset slave TP1 if booting from TP0 */
-               if (cpu_logical_map(cpu) == 0)
+               if (cpu_logical_map(cpu) == 1)
                        set_c0_brcm_cmt_ctrl(0x01);
 #elif defined(CONFIG_CPU_BMIPS5000)
                if (cpu & 0x01)
@@ -202,9 +202,15 @@ static void bmips_init_secondary(void)
 #if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
        void __iomem *cbr = BMIPS_GET_CBR();
        unsigned long old_vec;
+       unsigned long relo_vector;
+       int boot_cpu;
+
+       boot_cpu = !!(read_c0_brcm_cmt_local() & (1 << 31));
+       relo_vector = boot_cpu ? BMIPS_RELO_VECTOR_CONTROL_0 :
+                         BMIPS_RELO_VECTOR_CONTROL_1;
 
-       old_vec = __raw_readl(cbr + BMIPS_RELO_VECTOR_CONTROL_1);
-       __raw_writel(old_vec & ~0x20000000, cbr + BMIPS_RELO_VECTOR_CONTROL_1);
+       old_vec = __raw_readl(cbr + relo_vector);
+       __raw_writel(old_vec & ~0x20000000, cbr + relo_vector);
 
        clear_c0_cause(smp_processor_id() ? C_SW1 : C_SW0);
 #elif defined(CONFIG_CPU_BMIPS5000)
@@ -398,7 +404,7 @@ struct plat_smp_ops bmips_smp_ops = {
  * UP BMIPS systems as well.
  ***********************************************************************/
 
-static void __cpuinit bmips_wr_vec(unsigned long dst, char *start, char *end)
+static void bmips_wr_vec(unsigned long dst, char *start, char *end)
 {
        memcpy((void *)dst, start, end - start);
        dma_cache_wback((unsigned long)start, end - start);
@@ -406,7 +412,7 @@ static void __cpuinit bmips_wr_vec(unsigned long dst, char *start, char *end)
        instruction_hazard();
 }
 
-static inline void __cpuinit bmips_nmi_handler_setup(void)
+static inline void bmips_nmi_handler_setup(void)
 {
        bmips_wr_vec(BMIPS_NMI_RESET_VEC, &bmips_reset_nmi_vec,
                &bmips_reset_nmi_vec_end);
@@ -414,7 +420,7 @@ static inline void __cpuinit bmips_nmi_handler_setup(void)
                &bmips_smp_int_vec_end);
 }
 
-void __cpuinit bmips_ebase_setup(void)
+void bmips_ebase_setup(void)
 {
        unsigned long new_ebase = ebase;
        void __iomem __maybe_unused *cbr;
index 3e5164c11cacabe66ea021cb29c979b93d920e00..57a3f7a2b370c1af38296b7439b26bf60f387833 100644 (file)
@@ -149,7 +149,7 @@ static void vsmp_send_ipi_mask(const struct cpumask *mask, unsigned int action)
                vsmp_send_ipi_single(i, action);
 }
 
-static void __cpuinit vsmp_init_secondary(void)
+static void vsmp_init_secondary(void)
 {
 #ifdef CONFIG_IRQ_GIC
        /* This is Malta specific: IPI,performance and timer interrupts */
@@ -162,7 +162,7 @@ static void __cpuinit vsmp_init_secondary(void)
                                         STATUSF_IP6 | STATUSF_IP7);
 }
 
-static void __cpuinit vsmp_smp_finish(void)
+static void vsmp_smp_finish(void)
 {
        /* CDFIXME: remove this? */
        write_c0_compare(read_c0_count() + (8* mips_hpt_frequency/HZ));
@@ -188,7 +188,7 @@ static void vsmp_cpus_done(void)
  * (unsigned long)idle->thread_info the gp
  * assumes a 1:1 mapping of TC => VPE
  */
-static void __cpuinit vsmp_boot_secondary(int cpu, struct task_struct *idle)
+static void vsmp_boot_secondary(int cpu, struct task_struct *idle)
 {
        struct thread_info *gp = task_thread_info(idle);
        dvpe();
index 00500fea275078e837c6f6dcc245720e921f7f03..7fde3e4d978f98da02842d0da60d43720017f07e 100644 (file)
@@ -28,11 +28,11 @@ static inline void up_send_ipi_mask(const struct cpumask *mask,
  *  After we've done initial boot, this function is called to allow the
  *  board code to clean up state, if needed
  */
-static void __cpuinit up_init_secondary(void)
+static void up_init_secondary(void)
 {
 }
 
-static void __cpuinit up_smp_finish(void)
+static void up_smp_finish(void)
 {
 }
 
@@ -44,7 +44,7 @@ static void up_cpus_done(void)
 /*
  * Firmware CPU startup hook
  */
-static void __cpuinit up_boot_secondary(int cpu, struct task_struct *idle)
+static void up_boot_secondary(int cpu, struct task_struct *idle)
 {
 }
 
index 6e7862ab46cc4a6fef3c31e1ade85e04b357824f..5c208ed8f8561b461e3b2a8b1f0e49a8a458f8d2 100644 (file)
@@ -86,7 +86,7 @@ static inline void set_cpu_sibling_map(int cpu)
 struct plat_smp_ops *mp_ops;
 EXPORT_SYMBOL(mp_ops);
 
-__cpuinit void register_smp_ops(struct plat_smp_ops *ops)
+void register_smp_ops(struct plat_smp_ops *ops)
 {
        if (mp_ops)
                printk(KERN_WARNING "Overriding previously set SMP ops\n");
@@ -98,7 +98,7 @@ __cpuinit void register_smp_ops(struct plat_smp_ops *ops)
  * First C code run on the secondary CPUs after being started up by
  * the master.
  */
-asmlinkage __cpuinit void start_secondary(void)
+asmlinkage void start_secondary(void)
 {
        unsigned int cpu;
 
@@ -197,7 +197,7 @@ void smp_prepare_boot_cpu(void)
        cpu_set(0, cpu_callin_map);
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        mp_ops->boot_secondary(cpu, tidle);
 
index 75a4fd709841a9df42d4eba3218e053f7bf8c351..dfc1b911be04b7480cb30809ba59583cc76598b6 100644 (file)
@@ -645,7 +645,7 @@ void smtc_prepare_cpus(int cpus)
  * (unsigned long)idle->thread_info the gp
  *
  */
-void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle)
+void smtc_boot_secondary(int cpu, struct task_struct *idle)
 {
        extern u32 kernelsp[NR_CPUS];
        unsigned long flags;
index 6af08d896e20bdfd3ffc03bd7b03c99d6e7246d1..93f86817f20a64aae37b136d7fa3f2429e18852b 100644 (file)
@@ -37,7 +37,7 @@
 /*
  * Different semantics to the set_c0_* function built by __BUILD_SET_C0
  */
-static __cpuinit unsigned int bis_c0_errctl(unsigned int set)
+static unsigned int bis_c0_errctl(unsigned int set)
 {
        unsigned int res;
        res = read_c0_errctl();
@@ -45,7 +45,7 @@ static __cpuinit unsigned int bis_c0_errctl(unsigned int set)
        return res;
 }
 
-static __cpuinit void ispram_store_tag(unsigned int offset, unsigned int data)
+static void ispram_store_tag(unsigned int offset, unsigned int data)
 {
        unsigned int errctl;
 
@@ -64,7 +64,7 @@ static __cpuinit void ispram_store_tag(unsigned int offset, unsigned int data)
 }
 
 
-static __cpuinit unsigned int ispram_load_tag(unsigned int offset)
+static unsigned int ispram_load_tag(unsigned int offset)
 {
        unsigned int data;
        unsigned int errctl;
@@ -82,7 +82,7 @@ static __cpuinit unsigned int ispram_load_tag(unsigned int offset)
        return data;
 }
 
-static __cpuinit void dspram_store_tag(unsigned int offset, unsigned int data)
+static void dspram_store_tag(unsigned int offset, unsigned int data)
 {
        unsigned int errctl;
 
@@ -98,7 +98,7 @@ static __cpuinit void dspram_store_tag(unsigned int offset, unsigned int data)
 }
 
 
-static __cpuinit unsigned int dspram_load_tag(unsigned int offset)
+static unsigned int dspram_load_tag(unsigned int offset)
 {
        unsigned int data;
        unsigned int errctl;
@@ -115,7 +115,7 @@ static __cpuinit unsigned int dspram_load_tag(unsigned int offset)
        return data;
 }
 
-static __cpuinit void probe_spram(char *type,
+static void probe_spram(char *type,
            unsigned int base,
            unsigned int (*read)(unsigned int),
            void (*write)(unsigned int, unsigned int))
@@ -196,7 +196,7 @@ static __cpuinit void probe_spram(char *type,
                offset += 2 * SPRAM_TAG_STRIDE;
        }
 }
-void __cpuinit spram_config(void)
+void spram_config(void)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        unsigned int config0;
index 1ff43d5ac2c4e56bd6b4cda1be5d442131691b9d..84536bf4a15403157296bf0324d144cbb5e87a34 100644 (file)
 #include <asm/barrier.h>
 #include <asm/mipsregs.h>
 
-static atomic_t __cpuinitdata count_start_flag = ATOMIC_INIT(0);
-static atomic_t __cpuinitdata count_count_start = ATOMIC_INIT(0);
-static atomic_t __cpuinitdata count_count_stop = ATOMIC_INIT(0);
-static atomic_t __cpuinitdata count_reference = ATOMIC_INIT(0);
+static atomic_t count_start_flag = ATOMIC_INIT(0);
+static atomic_t count_count_start = ATOMIC_INIT(0);
+static atomic_t count_count_stop = ATOMIC_INIT(0);
+static atomic_t count_reference = ATOMIC_INIT(0);
 
 #define COUNTON 100
 #define NR_LOOPS 5
 
-void __cpuinit synchronise_count_master(int cpu)
+void synchronise_count_master(int cpu)
 {
        int i;
        unsigned long flags;
@@ -106,7 +106,7 @@ void __cpuinit synchronise_count_master(int cpu)
        printk("done.\n");
 }
 
-void __cpuinit synchronise_count_slave(int cpu)
+void synchronise_count_slave(int cpu)
 {
        int i;
        unsigned int initcount;
index 0903d70b2cfe7940a154b8f66e8ded3762b3035b..aec3408edd4b9c52d6d1b69bc68ac60368e60b48 100644 (file)
@@ -90,7 +90,7 @@ void (*board_nmi_handler_setup)(void);
 void (*board_ejtag_handler_setup)(void);
 void (*board_bind_eic_interrupt)(int irq, int regset);
 void (*board_ebase_setup)(void);
-void __cpuinitdata(*board_cache_error_setup)(void);
+void(*board_cache_error_setup)(void);
 
 static void show_raw_backtrace(unsigned long reg29)
 {
@@ -1242,7 +1242,6 @@ asmlinkage void do_mcheck(struct pt_regs *regs)
        panic("Caught Machine Check exception - %scaused by multiple "
              "matching entries in the TLB.",
              (multi_match) ? "" : "not ");
-       exception_exit(prev_state);
 }
 
 asmlinkage void do_mt(struct pt_regs *regs)
@@ -1682,7 +1681,7 @@ int cp0_compare_irq_shift;
 int cp0_perfcount_irq;
 EXPORT_SYMBOL_GPL(cp0_perfcount_irq);
 
-static int __cpuinitdata noulri;
+static int noulri;
 
 static int __init ulri_disable(char *s)
 {
@@ -1693,7 +1692,7 @@ static int __init ulri_disable(char *s)
 }
 __setup("noulri", ulri_disable);
 
-void __cpuinit per_cpu_trap_init(bool is_boot_cpu)
+void per_cpu_trap_init(bool is_boot_cpu)
 {
        unsigned int cpu = smp_processor_id();
        unsigned int status_set = ST0_CU0;
@@ -1810,7 +1809,7 @@ void __cpuinit per_cpu_trap_init(bool is_boot_cpu)
 }
 
 /* Install CPU exception handler */
-void __cpuinit set_handler(unsigned long offset, void *addr, unsigned long size)
+void set_handler(unsigned long offset, void *addr, unsigned long size)
 {
 #ifdef CONFIG_CPU_MICROMIPS
        memcpy((void *)(ebase + offset), ((unsigned char *)addr - 1), size);
@@ -1820,7 +1819,7 @@ void __cpuinit set_handler(unsigned long offset, void *addr, unsigned long size)
        local_flush_icache_range(ebase + offset, ebase + offset + size);
 }
 
-static char panic_null_cerr[] __cpuinitdata =
+static char panic_null_cerr[] =
        "Trying to set NULL cache error exception handler";
 
 /*
@@ -1828,7 +1827,7 @@ static char panic_null_cerr[] __cpuinitdata =
  * This is suitable only for the cache error exception which is the only
  * exception handler that is being run uncached.
  */
-void __cpuinit set_uncached_handler(unsigned long offset, void *addr,
+void set_uncached_handler(unsigned long offset, void *addr,
        unsigned long size)
 {
        unsigned long uncached_ebase = CKSEG1ADDR(ebase);
index cbdc4de85bb43ddd95c66a102918e9fee785bb82..2a03abb5bd2cc24e9aa7d4dd6c6fcfa29cb253ed 100644 (file)
@@ -100,7 +100,7 @@ void mips_clear_watch_registers(void)
        }
 }
 
-__cpuinit void mips_probe_watch_registers(struct cpuinfo_mips *c)
+void mips_probe_watch_registers(struct cpuinfo_mips *c)
 {
        unsigned int t;
 
index 2c15590e55f774356fd575ae688b4cef70031a84..30e334e823bd60822285efa9da808a991e6e19bb 100644 (file)
@@ -5,7 +5,6 @@ source "virt/kvm/Kconfig"
 
 menuconfig VIRTUALIZATION
        bool "Virtualization"
-       depends on HAVE_KVM
        ---help---
          Say Y here to get to see options for using your Linux host to run
          other operating systems inside virtual machines (guests).
index 51194875f1582ddb0507070c27ebe802b6924821..eb3e186596304f480987400ae731f30726923564 100644 (file)
@@ -461,7 +461,7 @@ int __init icu_of_init(struct device_node *node, struct device_node *parent)
        return 0;
 }
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        return MIPS_CPU_TIMER_IRQ;
 }
index 65e3dfc4e58555dec499212a293f2b721749eec1..d8522f8e842a29d2615af700e449a3dd77ef0da8 100644 (file)
@@ -36,7 +36,7 @@
  * values, so we can avoid sharing the same stack area between a cached
  * and the uncached mode.
  */
-unsigned long __cpuinit run_uncached(void *func)
+unsigned long run_uncached(void *func)
 {
        register long sp __asm__("$sp");
        register long ret __asm__("$2");
index e773659ccf9f8f607db709109e39b0cacb6f7989..46048d24328c759b0bf4189c612929015f139f69 100644 (file)
@@ -803,6 +803,32 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
                                dec_insn.next_pc_inc;
                return 1;
                break;
+#ifdef CONFIG_CPU_CAVIUM_OCTEON
+       case lwc2_op: /* This is bbit0 on Octeon */
+               if ((regs->regs[insn.i_format.rs] & (1ull<<insn.i_format.rt)) == 0)
+                       *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
+               else
+                       *contpc = regs->cp0_epc + 8;
+               return 1;
+       case ldc2_op: /* This is bbit032 on Octeon */
+               if ((regs->regs[insn.i_format.rs] & (1ull<<(insn.i_format.rt + 32))) == 0)
+                       *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
+               else
+                       *contpc = regs->cp0_epc + 8;
+               return 1;
+       case swc2_op: /* This is bbit1 on Octeon */
+               if (regs->regs[insn.i_format.rs] & (1ull<<insn.i_format.rt))
+                       *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
+               else
+                       *contpc = regs->cp0_epc + 8;
+               return 1;
+       case sdc2_op: /* This is bbit132 on Octeon */
+               if (regs->regs[insn.i_format.rs] & (1ull<<(insn.i_format.rt + 32)))
+                       *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
+               else
+                       *contpc = regs->cp0_epc + 8;
+               return 1;
+#endif
        case cop0_op:
        case cop1_op:
        case cop2_op:
index 8557fb55286321fe0af21e67ea212212d4c294da..a0bcdbb81d410c31fd41507dd4f0d200e3eb865b 100644 (file)
@@ -180,7 +180,7 @@ static void octeon_flush_kernel_vmap_range(unsigned long vaddr, int size)
  * Probe Octeon's caches
  *
  */
-static void __cpuinit probe_octeon(void)
+static void probe_octeon(void)
 {
        unsigned long icache_size;
        unsigned long dcache_size;
@@ -251,7 +251,7 @@ static void __cpuinit probe_octeon(void)
        }
 }
 
-static void  __cpuinit octeon_cache_error_setup(void)
+static void  octeon_cache_error_setup(void)
 {
        extern char except_vec2_octeon;
        set_handler(0x100, &except_vec2_octeon, 0x80);
@@ -261,7 +261,7 @@ static void  __cpuinit octeon_cache_error_setup(void)
  * Setup the Octeon cache flush routines
  *
  */
-void __cpuinit octeon_cache_init(void)
+void octeon_cache_init(void)
 {
        probe_octeon();
 
index 704dc735a59dfcd1cc368197730f6f279c2ea845..2fcde0c8ea029ccfa48f4a52c4fe19af29099333 100644 (file)
@@ -26,7 +26,7 @@
 static unsigned long icache_size, dcache_size;         /* Size in bytes */
 static unsigned long icache_lsize, dcache_lsize;       /* Size in bytes */
 
-unsigned long __cpuinit r3k_cache_size(unsigned long ca_flags)
+unsigned long r3k_cache_size(unsigned long ca_flags)
 {
        unsigned long flags, status, dummy, size;
        volatile unsigned long *p;
@@ -61,7 +61,7 @@ unsigned long __cpuinit r3k_cache_size(unsigned long ca_flags)
        return size * sizeof(*p);
 }
 
-unsigned long __cpuinit r3k_cache_lsize(unsigned long ca_flags)
+unsigned long r3k_cache_lsize(unsigned long ca_flags)
 {
        unsigned long flags, status, lsize, i;
        volatile unsigned long *p;
@@ -90,7 +90,7 @@ unsigned long __cpuinit r3k_cache_lsize(unsigned long ca_flags)
        return lsize * sizeof(*p);
 }
 
-static void __cpuinit r3k_probe_cache(void)
+static void r3k_probe_cache(void)
 {
        dcache_size = r3k_cache_size(ST0_ISC);
        if (dcache_size)
@@ -312,7 +312,7 @@ static void r3k_dma_cache_wback_inv(unsigned long start, unsigned long size)
        r3k_flush_dcache_range(start, start + size);
 }
 
-void __cpuinit r3k_cache_init(void)
+void r3k_cache_init(void)
 {
        extern void build_clear_page(void);
        extern void build_copy_page(void);
index 21813beec7a56f8c17ff493ca6000324168850fe..f749f687ee87796e118a13d9807a917b54549d69 100644 (file)
@@ -107,7 +107,7 @@ static inline void r4k_blast_dcache_page_dc64(unsigned long addr)
        blast_dcache64_page(addr);
 }
 
-static void __cpuinit r4k_blast_dcache_page_setup(void)
+static void r4k_blast_dcache_page_setup(void)
 {
        unsigned long  dc_lsize = cpu_dcache_line_size();
 
@@ -123,7 +123,7 @@ static void __cpuinit r4k_blast_dcache_page_setup(void)
 
 static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
 
-static void __cpuinit r4k_blast_dcache_page_indexed_setup(void)
+static void r4k_blast_dcache_page_indexed_setup(void)
 {
        unsigned long dc_lsize = cpu_dcache_line_size();
 
@@ -140,7 +140,7 @@ static void __cpuinit r4k_blast_dcache_page_indexed_setup(void)
 void (* r4k_blast_dcache)(void);
 EXPORT_SYMBOL(r4k_blast_dcache);
 
-static void __cpuinit r4k_blast_dcache_setup(void)
+static void r4k_blast_dcache_setup(void)
 {
        unsigned long dc_lsize = cpu_dcache_line_size();
 
@@ -227,7 +227,7 @@ static inline void tx49_blast_icache32_page_indexed(unsigned long page)
 
 static void (* r4k_blast_icache_page)(unsigned long addr);
 
-static void __cpuinit r4k_blast_icache_page_setup(void)
+static void r4k_blast_icache_page_setup(void)
 {
        unsigned long ic_lsize = cpu_icache_line_size();
 
@@ -244,7 +244,7 @@ static void __cpuinit r4k_blast_icache_page_setup(void)
 
 static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
 
-static void __cpuinit r4k_blast_icache_page_indexed_setup(void)
+static void r4k_blast_icache_page_indexed_setup(void)
 {
        unsigned long ic_lsize = cpu_icache_line_size();
 
@@ -269,7 +269,7 @@ static void __cpuinit r4k_blast_icache_page_indexed_setup(void)
 void (* r4k_blast_icache)(void);
 EXPORT_SYMBOL(r4k_blast_icache);
 
-static void __cpuinit r4k_blast_icache_setup(void)
+static void r4k_blast_icache_setup(void)
 {
        unsigned long ic_lsize = cpu_icache_line_size();
 
@@ -290,7 +290,7 @@ static void __cpuinit r4k_blast_icache_setup(void)
 
 static void (* r4k_blast_scache_page)(unsigned long addr);
 
-static void __cpuinit r4k_blast_scache_page_setup(void)
+static void r4k_blast_scache_page_setup(void)
 {
        unsigned long sc_lsize = cpu_scache_line_size();
 
@@ -308,7 +308,7 @@ static void __cpuinit r4k_blast_scache_page_setup(void)
 
 static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
 
-static void __cpuinit r4k_blast_scache_page_indexed_setup(void)
+static void r4k_blast_scache_page_indexed_setup(void)
 {
        unsigned long sc_lsize = cpu_scache_line_size();
 
@@ -326,7 +326,7 @@ static void __cpuinit r4k_blast_scache_page_indexed_setup(void)
 
 static void (* r4k_blast_scache)(void);
 
-static void __cpuinit r4k_blast_scache_setup(void)
+static void r4k_blast_scache_setup(void)
 {
        unsigned long sc_lsize = cpu_scache_line_size();
 
@@ -797,11 +797,11 @@ static inline void alias_74k_erratum(struct cpuinfo_mips *c)
        }
 }
 
-static char *way_string[] __cpuinitdata = { NULL, "direct mapped", "2-way",
+static char *way_string[] = { NULL, "direct mapped", "2-way",
        "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
 };
 
-static void __cpuinit probe_pcache(void)
+static void probe_pcache(void)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        unsigned int config = read_c0_config();
@@ -1119,7 +1119,7 @@ static void __cpuinit probe_pcache(void)
  * executes in KSEG1 space or else you will crash and burn badly.  You have
  * been warned.
  */
-static int __cpuinit probe_scache(void)
+static int probe_scache(void)
 {
        unsigned long flags, addr, begin, end, pow2;
        unsigned int config = read_c0_config();
@@ -1196,7 +1196,7 @@ extern int r5k_sc_init(void);
 extern int rm7k_sc_init(void);
 extern int mips_sc_init(void);
 
-static void __cpuinit setup_scache(void)
+static void setup_scache(void)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        unsigned int config = read_c0_config();
@@ -1329,7 +1329,7 @@ static void nxp_pr4450_fixup_config(void)
        NXP_BARRIER();
 }
 
-static int __cpuinitdata cca = -1;
+static int cca = -1;
 
 static int __init cca_setup(char *str)
 {
@@ -1340,7 +1340,7 @@ static int __init cca_setup(char *str)
 
 early_param("cca", cca_setup);
 
-static void __cpuinit coherency_setup(void)
+static void coherency_setup(void)
 {
        if (cca < 0 || cca > 7)
                cca = read_c0_config() & CONF_CM_CMASK;
@@ -1380,7 +1380,7 @@ static void __cpuinit coherency_setup(void)
        }
 }
 
-static void __cpuinit r4k_cache_error_setup(void)
+static void r4k_cache_error_setup(void)
 {
        extern char __weak except_vec2_generic;
        extern char __weak except_vec2_sb1;
@@ -1398,7 +1398,7 @@ static void __cpuinit r4k_cache_error_setup(void)
        }
 }
 
-void __cpuinit r4k_cache_init(void)
+void r4k_cache_init(void)
 {
        extern void build_clear_page(void);
        extern void build_copy_page(void);
index ba9da270289fa9924a01df6a819989a6a23a19e6..8d909dbbf37f56e545a0451cad028dc061b7fbe8 100644 (file)
@@ -344,7 +344,7 @@ static __init void tx39_probe_cache(void)
        }
 }
 
-void __cpuinit tx39_cache_init(void)
+void tx39_cache_init(void)
 {
        extern void build_clear_page(void);
        extern void build_copy_page(void);
index 5aeb3eb0b72f87b5f108a6d287517e53d038be2a..15f813c303b45bcb35f253249bd3571b6f4b8d8c 100644 (file)
@@ -182,7 +182,7 @@ static inline void setup_protection_map(void)
        }
 }
 
-void __cpuinit cpu_cache_init(void)
+void cpu_cache_init(void)
 {
        if (cpu_has_3k_cache) {
                extern void __weak r3k_cache_init(void);
index fe1d887e8d7056f9471ed54c0f57bafd89bcfe33..191cf6e0c7258b16217725084650a5043ec34cdd 100644 (file)
@@ -49,8 +49,6 @@
         * (0x170-0x17f) are used to preserve k0, k1, and ra.
         */
 
-       __CPUINIT
-
 LEAF(except_vec2_sb1)
        /*
         * If this error is recoverable, we need to exit the handler
@@ -142,8 +140,6 @@ unrecoverable:
 
 END(except_vec2_sb1)
 
-       __FINIT
-
        LEAF(handle_vec2_sb1)
        mfc0    k0,CP0_CONFIG
        li      k1,~CONF_CM_CMASK
index 2c0bd580b9daafd2d650851083869a0300cc0afa..218c2109a55d7fd6f4be10e1e860f00e50c2bc7f 100644 (file)
@@ -66,29 +66,29 @@ UASM_L_LA(_copy_pref_both)
 UASM_L_LA(_copy_pref_store)
 
 /* We need one branch and therefore one relocation per target label. */
-static struct uasm_label __cpuinitdata labels[5];
-static struct uasm_reloc __cpuinitdata relocs[5];
+static struct uasm_label labels[5];
+static struct uasm_reloc relocs[5];
 
 #define cpu_is_r4600_v1_x()    ((read_c0_prid() & 0xfffffff0) == 0x00002010)
 #define cpu_is_r4600_v2_x()    ((read_c0_prid() & 0xfffffff0) == 0x00002020)
 
-static int pref_bias_clear_store __cpuinitdata;
-static int pref_bias_copy_load __cpuinitdata;
-static int pref_bias_copy_store __cpuinitdata;
+static int pref_bias_clear_store;
+static int pref_bias_copy_load;
+static int pref_bias_copy_store;
 
-static u32 pref_src_mode __cpuinitdata;
-static u32 pref_dst_mode __cpuinitdata;
+static u32 pref_src_mode;
+static u32 pref_dst_mode;
 
-static int clear_word_size __cpuinitdata;
-static int copy_word_size __cpuinitdata;
+static int clear_word_size;
+static int copy_word_size;
 
-static int half_clear_loop_size __cpuinitdata;
-static int half_copy_loop_size __cpuinitdata;
+static int half_clear_loop_size;
+static int half_copy_loop_size;
 
-static int cache_line_size __cpuinitdata;
+static int cache_line_size;
 #define cache_line_mask() (cache_line_size - 1)
 
-static inline void __cpuinit
+static inline void
 pg_addiu(u32 **buf, unsigned int reg1, unsigned int reg2, unsigned int off)
 {
        if (cpu_has_64bit_gp_regs && DADDI_WAR && r4k_daddiu_bug()) {
@@ -108,7 +108,7 @@ pg_addiu(u32 **buf, unsigned int reg1, unsigned int reg2, unsigned int off)
        }
 }
 
-static void __cpuinit set_prefetch_parameters(void)
+static void set_prefetch_parameters(void)
 {
        if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg)
                clear_word_size = 8;
@@ -199,7 +199,7 @@ static void __cpuinit set_prefetch_parameters(void)
                                      4 * copy_word_size));
 }
 
-static void __cpuinit build_clear_store(u32 **buf, int off)
+static void build_clear_store(u32 **buf, int off)
 {
        if (cpu_has_64bit_gp_regs || cpu_has_64bit_zero_reg) {
                uasm_i_sd(buf, ZERO, off, A0);
@@ -208,7 +208,7 @@ static void __cpuinit build_clear_store(u32 **buf, int off)
        }
 }
 
-static inline void __cpuinit build_clear_pref(u32 **buf, int off)
+static inline void build_clear_pref(u32 **buf, int off)
 {
        if (off & cache_line_mask())
                return;
@@ -240,7 +240,7 @@ extern u32 __clear_page_end;
 extern u32 __copy_page_start;
 extern u32 __copy_page_end;
 
-void __cpuinit build_clear_page(void)
+void build_clear_page(void)
 {
        int off;
        u32 *buf = &__clear_page_start;
@@ -333,7 +333,7 @@ void __cpuinit build_clear_page(void)
        pr_debug("\t.set pop\n");
 }
 
-static void __cpuinit build_copy_load(u32 **buf, int reg, int off)
+static void build_copy_load(u32 **buf, int reg, int off)
 {
        if (cpu_has_64bit_gp_regs) {
                uasm_i_ld(buf, reg, off, A1);
@@ -342,7 +342,7 @@ static void __cpuinit build_copy_load(u32 **buf, int reg, int off)
        }
 }
 
-static void __cpuinit build_copy_store(u32 **buf, int reg, int off)
+static void build_copy_store(u32 **buf, int reg, int off)
 {
        if (cpu_has_64bit_gp_regs) {
                uasm_i_sd(buf, reg, off, A0);
@@ -387,7 +387,7 @@ static inline void build_copy_store_pref(u32 **buf, int off)
        }
 }
 
-void __cpuinit build_copy_page(void)
+void build_copy_page(void)
 {
        int off;
        u32 *buf = &__copy_page_start;
index c6aaed934d536ff9bddacb1a65aee337585c4af7..dc7c5a5214a9e1a9fb06600ba67f55b7054e1425 100644 (file)
@@ -167,7 +167,7 @@ static struct bcache_ops indy_sc_ops = {
        .bc_inv = indy_sc_wback_invalidate
 };
 
-void __cpuinit indy_sc_init(void)
+void indy_sc_init(void)
 {
        if (indy_sc_probe()) {
                indy_sc_enable();
index df96da7e939b540f9b1b9c73dae3f73162845d8e..5d01392e3518d1166b1cf82c6bee69475a30021e 100644 (file)
@@ -132,7 +132,7 @@ static inline int __init mips_sc_probe(void)
        return 1;
 }
 
-int __cpuinit mips_sc_init(void)
+int mips_sc_init(void)
 {
        int found = mips_sc_probe();
        if (found) {
index 8bc67720e145f5ab6b7b91718b45c88baf924238..0216ed6eaa2a931cda5c7a425c5327d8342dd53a 100644 (file)
@@ -98,7 +98,7 @@ static struct bcache_ops r5k_sc_ops = {
        .bc_inv = r5k_dma_cache_inv_sc
 };
 
-void __cpuinit r5k_sc_init(void)
+void r5k_sc_init(void)
 {
        if (r5k_sc_probe()) {
                r5k_sc_enable();
index 274af3be1442b42fa41d3cb960b598ddcbf5b8c2..aaffbba33706400c05701f31313d835c7debdbff 100644 (file)
@@ -104,7 +104,7 @@ static void blast_rm7k_tcache(void)
 /*
  * This function is executed in uncached address space.
  */
-static __cpuinit void __rm7k_tc_enable(void)
+static void __rm7k_tc_enable(void)
 {
        int i;
 
@@ -117,7 +117,7 @@ static __cpuinit void __rm7k_tc_enable(void)
                cache_op(Index_Store_Tag_T, CKSEG0ADDR(i));
 }
 
-static __cpuinit void rm7k_tc_enable(void)
+static void rm7k_tc_enable(void)
 {
        if (read_c0_config() & RM7K_CONF_TE)
                return;
@@ -130,7 +130,7 @@ static __cpuinit void rm7k_tc_enable(void)
 /*
  * This function is executed in uncached address space.
  */
-static __cpuinit void __rm7k_sc_enable(void)
+static void __rm7k_sc_enable(void)
 {
        int i;
 
@@ -143,7 +143,7 @@ static __cpuinit void __rm7k_sc_enable(void)
                cache_op(Index_Store_Tag_SD, CKSEG0ADDR(i));
 }
 
-static __cpuinit void rm7k_sc_enable(void)
+static void rm7k_sc_enable(void)
 {
        if (read_c0_config() & RM7K_CONF_SE)
                return;
@@ -184,7 +184,7 @@ static struct bcache_ops rm7k_sc_ops = {
  * This is a probing function like the one found in c-r4k.c, we look for the
  * wrap around point with different addresses.
  */
-static __cpuinit void __probe_tcache(void)
+static void __probe_tcache(void)
 {
        unsigned long flags, addr, begin, end, pow2;
 
@@ -226,7 +226,7 @@ static __cpuinit void __probe_tcache(void)
        local_irq_restore(flags);
 }
 
-void __cpuinit rm7k_sc_init(void)
+void rm7k_sc_init(void)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        unsigned int config = read_c0_config();
index a63d1ed0827fefe36520b2d21877b5bd6a6767f4..9aca10994cd22b4af8c1900ffa5592a0ea42788e 100644 (file)
@@ -276,7 +276,7 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
        }
 }
 
-void __cpuinit tlb_init(void)
+void tlb_init(void)
 {
        local_flush_tlb_all();
 
index c643de4c473a8d67115c7f0d304ebe1dc1e8c4ce..00b26a67a06d8c0693f15999aa08db864dbe2a93 100644 (file)
@@ -389,7 +389,7 @@ int __init has_transparent_hugepage(void)
 
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE  */
 
-static int __cpuinitdata ntlb;
+static int ntlb;
 static int __init set_ntlb(char *str)
 {
        get_option(&str, &ntlb);
@@ -398,7 +398,7 @@ static int __init set_ntlb(char *str)
 
 __setup("ntlb=", set_ntlb);
 
-void __cpuinit tlb_init(void)
+void tlb_init(void)
 {
        /*
         * You should never change this register:
index 91c2499f806a25809259a0b9682667ce2d7f31d5..6a99733a44402b71a198c5d18e5d6e1e3eff7b8e 100644 (file)
@@ -213,14 +213,14 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
        local_irq_restore(flags);
 }
 
-static void __cpuinit probe_tlb(unsigned long config)
+static void probe_tlb(unsigned long config)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
 
        c->tlbsize = 3 * 128;           /* 3 sets each 128 entries */
 }
 
-void __cpuinit tlb_init(void)
+void tlb_init(void)
 {
        unsigned int config = read_c0_config();
        unsigned long status;
index 9ab0f907a52c60b2efc61a59e7340aa1f1543d89..556cb48157704d8c576da3fc0dda6fb10c375c3e 100644 (file)
@@ -136,7 +136,7 @@ static int scratchpad_offset(int i)
  * why; it's not an issue caused by the core RTL.
  *
  */
-static int __cpuinit m4kc_tlbp_war(void)
+static int m4kc_tlbp_war(void)
 {
        return (current_cpu_data.processor_id & 0xffff00) ==
               (PRID_COMP_MIPS | PRID_IMP_4KC);
@@ -181,11 +181,9 @@ UASM_L_LA(_large_segbits_fault)
 UASM_L_LA(_tlb_huge_update)
 #endif
 
-static int __cpuinitdata hazard_instance;
+static int hazard_instance;
 
-static void __cpuinit uasm_bgezl_hazard(u32 **p,
-                                       struct uasm_reloc **r,
-                                       int instance)
+static void uasm_bgezl_hazard(u32 **p, struct uasm_reloc **r, int instance)
 {
        switch (instance) {
        case 0 ... 7:
@@ -196,9 +194,7 @@ static void __cpuinit uasm_bgezl_hazard(u32 **p,
        }
 }
 
-static void __cpuinit uasm_bgezl_label(struct uasm_label **l,
-                                      u32 **p,
-                                      int instance)
+static void uasm_bgezl_label(struct uasm_label **l, u32 **p, int instance)
 {
        switch (instance) {
        case 0 ... 7:
@@ -295,15 +291,15 @@ static inline void dump_handler(const char *symbol, const u32 *handler, int coun
  * We deliberately chose a buffer size of 128, so we won't scribble
  * over anything important on overflow before we panic.
  */
-static u32 tlb_handler[128] __cpuinitdata;
+static u32 tlb_handler[128];
 
 /* simply assume worst case size for labels and relocs */
-static struct uasm_label labels[128] __cpuinitdata;
-static struct uasm_reloc relocs[128] __cpuinitdata;
+static struct uasm_label labels[128];
+static struct uasm_reloc relocs[128];
 
-static int check_for_high_segbits __cpuinitdata;
+static int check_for_high_segbits;
 
-static unsigned int kscratch_used_mask __cpuinitdata;
+static unsigned int kscratch_used_mask;
 
 static inline int __maybe_unused c0_kscratch(void)
 {
@@ -316,7 +312,7 @@ static inline int __maybe_unused c0_kscratch(void)
        }
 }
 
-static int __cpuinit allocate_kscratch(void)
+static int allocate_kscratch(void)
 {
        int r;
        unsigned int a = cpu_data[0].kscratch_mask & ~kscratch_used_mask;
@@ -333,11 +329,11 @@ static int __cpuinit allocate_kscratch(void)
        return r;
 }
 
-static int scratch_reg __cpuinitdata;
-static int pgd_reg __cpuinitdata;
+static int scratch_reg;
+static int pgd_reg;
 enum vmalloc64_mode {not_refill, refill_scratch, refill_noscratch};
 
-static struct work_registers __cpuinit build_get_work_registers(u32 **p)
+static struct work_registers build_get_work_registers(u32 **p)
 {
        struct work_registers r;
 
@@ -393,7 +389,7 @@ static struct work_registers __cpuinit build_get_work_registers(u32 **p)
        return r;
 }
 
-static void __cpuinit build_restore_work_registers(u32 **p)
+static void build_restore_work_registers(u32 **p)
 {
        if (scratch_reg >= 0) {
                UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg);
@@ -418,7 +414,7 @@ extern unsigned long pgd_current[];
 /*
  * The R3000 TLB handler is simple.
  */
-static void __cpuinit build_r3000_tlb_refill_handler(void)
+static void build_r3000_tlb_refill_handler(void)
 {
        long pgdc = (long)pgd_current;
        u32 *p;
@@ -463,7 +459,7 @@ static void __cpuinit build_r3000_tlb_refill_handler(void)
  * other one.To keep things simple, we first assume linear space,
  * then we relocate it to the final handler layout as needed.
  */
-static u32 final_handler[64] __cpuinitdata;
+static u32 final_handler[64];
 
 /*
  * Hazards
@@ -487,7 +483,7 @@ static u32 final_handler[64] __cpuinitdata;
  *
  * As if we MIPS hackers wouldn't know how to nop pipelines happy ...
  */
-static void __cpuinit __maybe_unused build_tlb_probe_entry(u32 **p)
+static void __maybe_unused build_tlb_probe_entry(u32 **p)
 {
        switch (current_cpu_type()) {
        /* Found by experiment: R4600 v2.0/R4700 needs this, too.  */
@@ -511,9 +507,9 @@ static void __cpuinit __maybe_unused build_tlb_probe_entry(u32 **p)
  */
 enum tlb_write_entry { tlb_random, tlb_indexed };
 
-static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
-                                        struct uasm_reloc **r,
-                                        enum tlb_write_entry wmode)
+static void build_tlb_write_entry(u32 **p, struct uasm_label **l,
+                                 struct uasm_reloc **r,
+                                 enum tlb_write_entry wmode)
 {
        void(*tlbw)(u32 **) = NULL;
 
@@ -647,8 +643,8 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
        }
 }
 
-static __cpuinit __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
-                                                                 unsigned int reg)
+static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
+                                                       unsigned int reg)
 {
        if (cpu_has_rixi) {
                UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL));
@@ -663,11 +659,9 @@ static __cpuinit __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
 
 #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT
 
-static __cpuinit void build_restore_pagemask(u32 **p,
-                                            struct uasm_reloc **r,
-                                            unsigned int tmp,
-                                            enum label_id lid,
-                                            int restore_scratch)
+static void build_restore_pagemask(u32 **p, struct uasm_reloc **r,
+                                  unsigned int tmp, enum label_id lid,
+                                  int restore_scratch)
 {
        if (restore_scratch) {
                /* Reset default page size */
@@ -706,12 +700,11 @@ static __cpuinit void build_restore_pagemask(u32 **p,
        }
 }
 
-static __cpuinit void build_huge_tlb_write_entry(u32 **p,
-                                                struct uasm_label **l,
-                                                struct uasm_reloc **r,
-                                                unsigned int tmp,
-                                                enum tlb_write_entry wmode,
-                                                int restore_scratch)
+static void build_huge_tlb_write_entry(u32 **p, struct uasm_label **l,
+                                      struct uasm_reloc **r,
+                                      unsigned int tmp,
+                                      enum tlb_write_entry wmode,
+                                      int restore_scratch)
 {
        /* Set huge page tlb entry size */
        uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16);
@@ -726,9 +719,9 @@ static __cpuinit void build_huge_tlb_write_entry(u32 **p,
 /*
  * Check if Huge PTE is present, if so then jump to LABEL.
  */
-static void __cpuinit
+static void
 build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp,
-               unsigned int pmd, int lid)
+                 unsigned int pmd, int lid)
 {
        UASM_i_LW(p, tmp, 0, pmd);
        if (use_bbit_insns()) {
@@ -739,9 +732,8 @@ build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp,
        }
 }
 
-static __cpuinit void build_huge_update_entries(u32 **p,
-                                               unsigned int pte,
-                                               unsigned int tmp)
+static void build_huge_update_entries(u32 **p, unsigned int pte,
+                                     unsigned int tmp)
 {
        int small_sequence;
 
@@ -771,11 +763,10 @@ static __cpuinit void build_huge_update_entries(u32 **p,
        UASM_i_MTC0(p, pte, C0_ENTRYLO1); /* load it */
 }
 
-static __cpuinit void build_huge_handler_tail(u32 **p,
-                                             struct uasm_reloc **r,
-                                             struct uasm_label **l,
-                                             unsigned int pte,
-                                             unsigned int ptr)
+static void build_huge_handler_tail(u32 **p, struct uasm_reloc **r,
+                                   struct uasm_label **l,
+                                   unsigned int pte,
+                                   unsigned int ptr)
 {
 #ifdef CONFIG_SMP
        UASM_i_SC(p, pte, 0, ptr);
@@ -794,7 +785,7 @@ static __cpuinit void build_huge_handler_tail(u32 **p,
  * TMP and PTR are scratch.
  * TMP will be clobbered, PTR will hold the pmd entry.
  */
-static void __cpuinit
+static void
 build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
                 unsigned int tmp, unsigned int ptr)
 {
@@ -886,7 +877,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
  * BVADDR is the faulting address, PTR is scratch.
  * PTR will hold the pgd for vmalloc.
  */
-static void __cpuinit
+static void
 build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
                        unsigned int bvaddr, unsigned int ptr,
                        enum vmalloc64_mode mode)
@@ -956,7 +947,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
  * TMP and PTR are scratch.
  * TMP will be clobbered, PTR will hold the pgd entry.
  */
-static void __cpuinit __maybe_unused
+static void __maybe_unused
 build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
 {
        long pgdc = (long)pgd_current;
@@ -991,7 +982,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
 
 #endif /* !CONFIG_64BIT */
 
-static void __cpuinit build_adjust_context(u32 **p, unsigned int ctx)
+static void build_adjust_context(u32 **p, unsigned int ctx)
 {
        unsigned int shift = 4 - (PTE_T_LOG2 + 1) + PAGE_SHIFT - 12;
        unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1);
@@ -1017,7 +1008,7 @@ static void __cpuinit build_adjust_context(u32 **p, unsigned int ctx)
        uasm_i_andi(p, ctx, ctx, mask);
 }
 
-static void __cpuinit build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr)
+static void build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr)
 {
        /*
         * Bug workaround for the Nevada. It seems as if under certain
@@ -1042,8 +1033,7 @@ static void __cpuinit build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr
        UASM_i_ADDU(p, ptr, ptr, tmp); /* add in offset */
 }
 
-static void __cpuinit build_update_entries(u32 **p, unsigned int tmp,
-                                       unsigned int ptep)
+static void build_update_entries(u32 **p, unsigned int tmp, unsigned int ptep)
 {
        /*
         * 64bit address support (36bit on a 32bit CPU) in a 32bit
@@ -1104,7 +1094,7 @@ struct mips_huge_tlb_info {
        int restore_scratch;
 };
 
-static struct mips_huge_tlb_info __cpuinit
+static struct mips_huge_tlb_info
 build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
                               struct uasm_reloc **r, unsigned int tmp,
                               unsigned int ptr, int c0_scratch_reg)
@@ -1282,7 +1272,7 @@ build_fast_tlb_refill_handler (u32 **p, struct uasm_label **l,
  */
 #define MIPS64_REFILL_INSNS 32
 
-static void __cpuinit build_r4000_tlb_refill_handler(void)
+static void build_r4000_tlb_refill_handler(void)
 {
        u32 *p = tlb_handler;
        struct uasm_label *l = labels;
@@ -1462,11 +1452,11 @@ extern u32 handle_tlbm[], handle_tlbm_end[];
 #ifdef CONFIG_MIPS_PGD_C0_CONTEXT
 extern u32 tlbmiss_handler_setup_pgd[], tlbmiss_handler_setup_pgd_end[];
 
-static void __cpuinit build_r4000_setup_pgd(void)
+static void build_r4000_setup_pgd(void)
 {
        const int a0 = 4;
        const int a1 = 5;
-       u32 *p = tlbmiss_handler_setup_pgd_array;
+       u32 *p = tlbmiss_handler_setup_pgd;
        const int tlbmiss_handler_setup_pgd_size =
                tlbmiss_handler_setup_pgd_end - tlbmiss_handler_setup_pgd;
        struct uasm_label *l = labels;
@@ -1513,7 +1503,7 @@ static void __cpuinit build_r4000_setup_pgd(void)
 }
 #endif
 
-static void __cpuinit
+static void
 iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr)
 {
 #ifdef CONFIG_SMP
@@ -1533,7 +1523,7 @@ iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr)
 #endif
 }
 
-static void __cpuinit
+static void
 iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr,
        unsigned int mode)
 {
@@ -1593,7 +1583,7 @@ iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr,
  * the page table where this PTE is located, PTE will be re-loaded
  * with it's original value.
  */
-static void __cpuinit
+static void
 build_pte_present(u32 **p, struct uasm_reloc **r,
                  int pte, int ptr, int scratch, enum label_id lid)
 {
@@ -1621,7 +1611,7 @@ build_pte_present(u32 **p, struct uasm_reloc **r,
 }
 
 /* Make PTE valid, store result in PTR. */
-static void __cpuinit
+static void
 build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte,
                 unsigned int ptr)
 {
@@ -1634,7 +1624,7 @@ build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte,
  * Check if PTE can be written to, if not branch to LABEL. Regardless
  * restore PTE with value from PTR when done.
  */
-static void __cpuinit
+static void
 build_pte_writable(u32 **p, struct uasm_reloc **r,
                   unsigned int pte, unsigned int ptr, int scratch,
                   enum label_id lid)
@@ -1654,7 +1644,7 @@ build_pte_writable(u32 **p, struct uasm_reloc **r,
 /* Make PTE writable, update software status bits as well, then store
  * at PTR.
  */
-static void __cpuinit
+static void
 build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte,
                 unsigned int ptr)
 {
@@ -1668,7 +1658,7 @@ build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte,
  * Check if PTE can be modified, if not branch to LABEL. Regardless
  * restore PTE with value from PTR when done.
  */
-static void __cpuinit
+static void
 build_pte_modifiable(u32 **p, struct uasm_reloc **r,
                     unsigned int pte, unsigned int ptr, int scratch,
                     enum label_id lid)
@@ -1697,7 +1687,7 @@ build_pte_modifiable(u32 **p, struct uasm_reloc **r,
  * This places the pte into ENTRYLO0 and writes it with tlbwi.
  * Then it returns.
  */
-static void __cpuinit
+static void
 build_r3000_pte_reload_tlbwi(u32 **p, unsigned int pte, unsigned int tmp)
 {
        uasm_i_mtc0(p, pte, C0_ENTRYLO0); /* cp0 delay */
@@ -1713,7 +1703,7 @@ build_r3000_pte_reload_tlbwi(u32 **p, unsigned int pte, unsigned int tmp)
  * may have the probe fail bit set as a result of a trap on a
  * kseg2 access, i.e. without refill.  Then it returns.
  */
-static void __cpuinit
+static void
 build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l,
                             struct uasm_reloc **r, unsigned int pte,
                             unsigned int tmp)
@@ -1731,7 +1721,7 @@ build_r3000_tlb_reload_write(u32 **p, struct uasm_label **l,
        uasm_i_rfe(p); /* branch delay */
 }
 
-static void __cpuinit
+static void
 build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte,
                                   unsigned int ptr)
 {
@@ -1751,7 +1741,7 @@ build_r3000_tlbchange_handler_head(u32 **p, unsigned int pte,
        uasm_i_tlbp(p); /* load delay */
 }
 
-static void __cpuinit build_r3000_tlb_load_handler(void)
+static void build_r3000_tlb_load_handler(void)
 {
        u32 *p = handle_tlbl;
        const int handle_tlbl_size = handle_tlbl_end - handle_tlbl;
@@ -1782,7 +1772,7 @@ static void __cpuinit build_r3000_tlb_load_handler(void)
        dump_handler("r3000_tlb_load", handle_tlbl, handle_tlbl_size);
 }
 
-static void __cpuinit build_r3000_tlb_store_handler(void)
+static void build_r3000_tlb_store_handler(void)
 {
        u32 *p = handle_tlbs;
        const int handle_tlbs_size = handle_tlbs_end - handle_tlbs;
@@ -1803,7 +1793,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void)
        uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff);
        uasm_i_nop(&p);
 
-       if (p >= handle_tlbs)
+       if (p >= handle_tlbs_end)
                panic("TLB store handler fastpath space exceeded");
 
        uasm_resolve_relocs(relocs, labels);
@@ -1813,7 +1803,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void)
        dump_handler("r3000_tlb_store", handle_tlbs, handle_tlbs_size);
 }
 
-static void __cpuinit build_r3000_tlb_modify_handler(void)
+static void build_r3000_tlb_modify_handler(void)
 {
        u32 *p = handle_tlbm;
        const int handle_tlbm_size = handle_tlbm_end - handle_tlbm;
@@ -1848,7 +1838,7 @@ static void __cpuinit build_r3000_tlb_modify_handler(void)
 /*
  * R4000 style TLB load/store/modify handlers.
  */
-static struct work_registers __cpuinit
+static struct work_registers
 build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
                                   struct uasm_reloc **r)
 {
@@ -1884,7 +1874,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
        return wr;
 }
 
-static void __cpuinit
+static void
 build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l,
                                   struct uasm_reloc **r, unsigned int tmp,
                                   unsigned int ptr)
@@ -1902,7 +1892,7 @@ build_r4000_tlbchange_handler_tail(u32 **p, struct uasm_label **l,
 #endif
 }
 
-static void __cpuinit build_r4000_tlb_load_handler(void)
+static void build_r4000_tlb_load_handler(void)
 {
        u32 *p = handle_tlbl;
        const int handle_tlbl_size = handle_tlbl_end - handle_tlbl;
@@ -2085,7 +2075,7 @@ static void __cpuinit build_r4000_tlb_load_handler(void)
        dump_handler("r4000_tlb_load", handle_tlbl, handle_tlbl_size);
 }
 
-static void __cpuinit build_r4000_tlb_store_handler(void)
+static void build_r4000_tlb_store_handler(void)
 {
        u32 *p = handle_tlbs;
        const int handle_tlbs_size = handle_tlbs_end - handle_tlbs;
@@ -2140,7 +2130,7 @@ static void __cpuinit build_r4000_tlb_store_handler(void)
        dump_handler("r4000_tlb_store", handle_tlbs, handle_tlbs_size);
 }
 
-static void __cpuinit build_r4000_tlb_modify_handler(void)
+static void build_r4000_tlb_modify_handler(void)
 {
        u32 *p = handle_tlbm;
        const int handle_tlbm_size = handle_tlbm_end - handle_tlbm;
@@ -2196,7 +2186,7 @@ static void __cpuinit build_r4000_tlb_modify_handler(void)
        dump_handler("r4000_tlb_modify", handle_tlbm, handle_tlbm_size);
 }
 
-static void __cpuinit flush_tlb_handlers(void)
+static void flush_tlb_handlers(void)
 {
        local_flush_icache_range((unsigned long)handle_tlbl,
                           (unsigned long)handle_tlbl_end);
@@ -2210,7 +2200,7 @@ static void __cpuinit flush_tlb_handlers(void)
 #endif
 }
 
-void __cpuinit build_tlb_refill_handler(void)
+void build_tlb_refill_handler(void)
 {
        /*
         * The refill handler is generated per-CPU, multi-node systems
index 162ee6d62788ccc3cf989a2f312ebf9b451dda36..060000fa653c3c939835381f45d56c5cf162194a 100644 (file)
@@ -49,7 +49,7 @@
 
 #include "uasm.c"
 
-static struct insn insn_table_MM[] __uasminitdata = {
+static struct insn insn_table_MM[] = {
        { insn_addu, M(mm_pool32a_op, 0, 0, 0, 0, mm_addu32_op), RT | RS | RD },
        { insn_addiu, M(mm_addiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
        { insn_and, M(mm_pool32a_op, 0, 0, 0, 0, mm_and_op), RT | RS | RD },
@@ -118,7 +118,7 @@ static struct insn insn_table_MM[] __uasminitdata = {
 
 #undef M
 
-static inline __uasminit u32 build_bimm(s32 arg)
+static inline u32 build_bimm(s32 arg)
 {
        WARN(arg > 0xffff || arg < -0x10000,
             KERN_WARNING "Micro-assembler field overflow\n");
@@ -128,7 +128,7 @@ static inline __uasminit u32 build_bimm(s32 arg)
        return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 1) & 0x7fff);
 }
 
-static inline __uasminit u32 build_jimm(u32 arg)
+static inline u32 build_jimm(u32 arg)
 {
 
        WARN(arg & ~((JIMM_MASK << 2) | 1),
@@ -141,7 +141,7 @@ static inline __uasminit u32 build_jimm(u32 arg)
  * The order of opcode arguments is implicitly left to right,
  * starting with RS and ending with FUNC or IMM.
  */
-static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
+static void build_insn(u32 **buf, enum opcode opc, ...)
 {
        struct insn *ip = NULL;
        unsigned int i;
@@ -199,7 +199,7 @@ static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
        (*buf)++;
 }
 
-static inline void __uasminit
+static inline void
 __resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab)
 {
        long laddr = (long)lab->addr;
index 5fcdd8fe3e83f683f5fb26ae73c378f6280e2b01..0c724589854e7216e470d59d4359b984bd15375a 100644 (file)
@@ -49,7 +49,7 @@
 
 #include "uasm.c"
 
-static struct insn insn_table[] __uasminitdata = {
+static struct insn insn_table[] = {
        { insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
        { insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD },
        { insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
@@ -119,7 +119,7 @@ static struct insn insn_table[] __uasminitdata = {
 
 #undef M
 
-static inline __uasminit u32 build_bimm(s32 arg)
+static inline u32 build_bimm(s32 arg)
 {
        WARN(arg > 0x1ffff || arg < -0x20000,
             KERN_WARNING "Micro-assembler field overflow\n");
@@ -129,7 +129,7 @@ static inline __uasminit u32 build_bimm(s32 arg)
        return ((arg < 0) ? (1 << 15) : 0) | ((arg >> 2) & 0x7fff);
 }
 
-static inline __uasminit u32 build_jimm(u32 arg)
+static inline u32 build_jimm(u32 arg)
 {
        WARN(arg & ~(JIMM_MASK << 2),
             KERN_WARNING "Micro-assembler field overflow\n");
@@ -141,7 +141,7 @@ static inline __uasminit u32 build_jimm(u32 arg)
  * The order of opcode arguments is implicitly left to right,
  * starting with RS and ending with FUNC or IMM.
  */
-static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
+static void build_insn(u32 **buf, enum opcode opc, ...)
 {
        struct insn *ip = NULL;
        unsigned int i;
@@ -187,7 +187,7 @@ static void __uasminit build_insn(u32 **buf, enum opcode opc, ...)
        (*buf)++;
 }
 
-static inline void __uasminit
+static inline void
 __resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab)
 {
        long laddr = (long)lab->addr;
index 7eb5e4355d25c467fd1241ffda14715dfc69c1c7..b9d14b6c7f58ebf1c51fa4aba6a85c60c04d9e4e 100644 (file)
@@ -63,35 +63,35 @@ struct insn {
        enum fields fields;
 };
 
-static inline __uasminit u32 build_rs(u32 arg)
+static inline u32 build_rs(u32 arg)
 {
        WARN(arg & ~RS_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return (arg & RS_MASK) << RS_SH;
 }
 
-static inline __uasminit u32 build_rt(u32 arg)
+static inline u32 build_rt(u32 arg)
 {
        WARN(arg & ~RT_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return (arg & RT_MASK) << RT_SH;
 }
 
-static inline __uasminit u32 build_rd(u32 arg)
+static inline u32 build_rd(u32 arg)
 {
        WARN(arg & ~RD_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return (arg & RD_MASK) << RD_SH;
 }
 
-static inline __uasminit u32 build_re(u32 arg)
+static inline u32 build_re(u32 arg)
 {
        WARN(arg & ~RE_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return (arg & RE_MASK) << RE_SH;
 }
 
-static inline __uasminit u32 build_simm(s32 arg)
+static inline u32 build_simm(s32 arg)
 {
        WARN(arg > 0x7fff || arg < -0x8000,
             KERN_WARNING "Micro-assembler field overflow\n");
@@ -99,14 +99,14 @@ static inline __uasminit u32 build_simm(s32 arg)
        return arg & 0xffff;
 }
 
-static inline __uasminit u32 build_uimm(u32 arg)
+static inline u32 build_uimm(u32 arg)
 {
        WARN(arg & ~IMM_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return arg & IMM_MASK;
 }
 
-static inline __uasminit u32 build_scimm(u32 arg)
+static inline u32 build_scimm(u32 arg)
 {
        WARN(arg & ~SCIMM_MASK,
             KERN_WARNING "Micro-assembler field overflow\n");
@@ -114,21 +114,21 @@ static inline __uasminit u32 build_scimm(u32 arg)
        return (arg & SCIMM_MASK) << SCIMM_SH;
 }
 
-static inline __uasminit u32 build_func(u32 arg)
+static inline u32 build_func(u32 arg)
 {
        WARN(arg & ~FUNC_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return arg & FUNC_MASK;
 }
 
-static inline __uasminit u32 build_set(u32 arg)
+static inline u32 build_set(u32 arg)
 {
        WARN(arg & ~SET_MASK, KERN_WARNING "Micro-assembler field overflow\n");
 
        return arg & SET_MASK;
 }
 
-static void __uasminit build_insn(u32 **buf, enum opcode opc, ...);
+static void build_insn(u32 **buf, enum opcode opc, ...);
 
 #define I_u1u2u3(op)                                   \
 Ip_u1u2u3(op)                                          \
@@ -286,7 +286,7 @@ I_u3u1u2(_ldx)
 
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
 #include <asm/octeon/octeon.h>
-void __uasminit ISAFUNC(uasm_i_pref)(u32 **buf, unsigned int a, signed int b,
+void ISAFUNC(uasm_i_pref)(u32 **buf, unsigned int a, signed int b,
                            unsigned int c)
 {
        if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X) && a <= 24 && a != 5)
@@ -304,7 +304,7 @@ I_u2s3u1(_pref)
 #endif
 
 /* Handle labels. */
-void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid)
+void ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, int lid)
 {
        (*lab)->addr = addr;
        (*lab)->lab = lid;
@@ -312,7 +312,7 @@ void __uasminit ISAFUNC(uasm_build_label)(struct uasm_label **lab, u32 *addr, in
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_build_label));
 
-int __uasminit ISAFUNC(uasm_in_compat_space_p)(long addr)
+int ISAFUNC(uasm_in_compat_space_p)(long addr)
 {
        /* Is this address in 32bit compat space? */
 #ifdef CONFIG_64BIT
@@ -323,7 +323,7 @@ int __uasminit ISAFUNC(uasm_in_compat_space_p)(long addr)
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_in_compat_space_p));
 
-static int __uasminit uasm_rel_highest(long val)
+static int uasm_rel_highest(long val)
 {
 #ifdef CONFIG_64BIT
        return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000;
@@ -332,7 +332,7 @@ static int __uasminit uasm_rel_highest(long val)
 #endif
 }
 
-static int __uasminit uasm_rel_higher(long val)
+static int uasm_rel_higher(long val)
 {
 #ifdef CONFIG_64BIT
        return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000;
@@ -341,19 +341,19 @@ static int __uasminit uasm_rel_higher(long val)
 #endif
 }
 
-int __uasminit ISAFUNC(uasm_rel_hi)(long val)
+int ISAFUNC(uasm_rel_hi)(long val)
 {
        return ((((val + 0x8000L) >> 16) & 0xffff) ^ 0x8000) - 0x8000;
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_hi));
 
-int __uasminit ISAFUNC(uasm_rel_lo)(long val)
+int ISAFUNC(uasm_rel_lo)(long val)
 {
        return ((val & 0xffff) ^ 0x8000) - 0x8000;
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_rel_lo));
 
-void __uasminit ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr)
+void ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr)
 {
        if (!ISAFUNC(uasm_in_compat_space_p)(addr)) {
                ISAFUNC(uasm_i_lui)(buf, rs, uasm_rel_highest(addr));
@@ -371,7 +371,7 @@ void __uasminit ISAFUNC(UASM_i_LA_mostly)(u32 **buf, unsigned int rs, long addr)
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA_mostly));
 
-void __uasminit ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr)
+void ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr)
 {
        ISAFUNC(UASM_i_LA_mostly)(buf, rs, addr);
        if (ISAFUNC(uasm_rel_lo(addr))) {
@@ -386,8 +386,7 @@ void __uasminit ISAFUNC(UASM_i_LA)(u32 **buf, unsigned int rs, long addr)
 UASM_EXPORT_SYMBOL(ISAFUNC(UASM_i_LA));
 
 /* Handle relocations. */
-void __uasminit
-ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid)
+void ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid)
 {
        (*rel)->addr = addr;
        (*rel)->type = R_MIPS_PC16;
@@ -396,11 +395,11 @@ ISAFUNC(uasm_r_mips_pc16)(struct uasm_reloc **rel, u32 *addr, int lid)
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_r_mips_pc16));
 
-static inline void __uasminit
-__resolve_relocs(struct uasm_reloc *rel, struct uasm_label *lab);
+static inline void __resolve_relocs(struct uasm_reloc *rel,
+                                   struct uasm_label *lab);
 
-void __uasminit
-ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, struct uasm_label *lab)
+void ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel,
+                                 struct uasm_label *lab)
 {
        struct uasm_label *l;
 
@@ -411,8 +410,8 @@ ISAFUNC(uasm_resolve_relocs)(struct uasm_reloc *rel, struct uasm_label *lab)
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_resolve_relocs));
 
-void __uasminit
-ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end, long off)
+void ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end,
+                              long off)
 {
        for (; rel->lab != UASM_LABEL_INVALID; rel++)
                if (rel->addr >= first && rel->addr < end)
@@ -420,8 +419,8 @@ ISAFUNC(uasm_move_relocs)(struct uasm_reloc *rel, u32 *first, u32 *end, long off
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_relocs));
 
-void __uasminit
-ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end, long off)
+void ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end,
+                              long off)
 {
        for (; lab->lab != UASM_LABEL_INVALID; lab++)
                if (lab->addr >= first && lab->addr < end)
@@ -429,9 +428,8 @@ ISAFUNC(uasm_move_labels)(struct uasm_label *lab, u32 *first, u32 *end, long off
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_move_labels));
 
-void __uasminit
-ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, u32 *first,
-                 u32 *end, u32 *target)
+void ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab,
+                               u32 *first, u32 *end, u32 *target)
 {
        long off = (long)(target - first);
 
@@ -442,7 +440,7 @@ ISAFUNC(uasm_copy_handler)(struct uasm_reloc *rel, struct uasm_label *lab, u32 *
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_copy_handler));
 
-int __uasminit ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr)
+int ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr)
 {
        for (; rel->lab != UASM_LABEL_INVALID; rel++) {
                if (rel->addr == addr
@@ -456,83 +454,79 @@ int __uasminit ISAFUNC(uasm_insn_has_bdelay)(struct uasm_reloc *rel, u32 *addr)
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_insn_has_bdelay));
 
 /* Convenience functions for labeled branches. */
-void __uasminit
-ISAFUNC(uasm_il_bltz)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid)
+void ISAFUNC(uasm_il_bltz)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                          int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bltz)(p, reg, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bltz));
 
-void __uasminit
-ISAFUNC(uasm_il_b)(u32 **p, struct uasm_reloc **r, int lid)
+void ISAFUNC(uasm_il_b)(u32 **p, struct uasm_reloc **r, int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_b)(p, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_b));
 
-void __uasminit
-ISAFUNC(uasm_il_beqz)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid)
+void ISAFUNC(uasm_il_beqz)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                          int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_beqz)(p, reg, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqz));
 
-void __uasminit
-ISAFUNC(uasm_il_beqzl)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid)
+void ISAFUNC(uasm_il_beqzl)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                           int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_beqzl)(p, reg, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_beqzl));
 
-void __uasminit
-ISAFUNC(uasm_il_bne)(u32 **p, struct uasm_reloc **r, unsigned int reg1,
-       unsigned int reg2, int lid)
+void ISAFUNC(uasm_il_bne)(u32 **p, struct uasm_reloc **r, unsigned int reg1,
+                         unsigned int reg2, int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bne)(p, reg1, reg2, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bne));
 
-void __uasminit
-ISAFUNC(uasm_il_bnez)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid)
+void ISAFUNC(uasm_il_bnez)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                          int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bnez)(p, reg, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bnez));
 
-void __uasminit
-ISAFUNC(uasm_il_bgezl)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid)
+void ISAFUNC(uasm_il_bgezl)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                           int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bgezl)(p, reg, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgezl));
 
-void __uasminit
-ISAFUNC(uasm_il_bgez)(u32 **p, struct uasm_reloc **r, unsigned int reg, int lid)
+void ISAFUNC(uasm_il_bgez)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                          int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bgez)(p, reg, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bgez));
 
-void __uasminit
-ISAFUNC(uasm_il_bbit0)(u32 **p, struct uasm_reloc **r, unsigned int reg,
-             unsigned int bit, int lid)
+void ISAFUNC(uasm_il_bbit0)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                           unsigned int bit, int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bbit0)(p, reg, bit, 0);
 }
 UASM_EXPORT_SYMBOL(ISAFUNC(uasm_il_bbit0));
 
-void __uasminit
-ISAFUNC(uasm_il_bbit1)(u32 **p, struct uasm_reloc **r, unsigned int reg,
-             unsigned int bit, int lid)
+void ISAFUNC(uasm_il_bbit1)(u32 **p, struct uasm_reloc **r, unsigned int reg,
+                           unsigned int bit, int lid)
 {
        uasm_r_mips_pc16(r, *p, lid);
        ISAFUNC(uasm_i_bbit1)(p, reg, bit, 0);
index becbf47506a59a0face9b35ba5ec7900e75e2d72..c4849904f0139b4cb8284e51f3efa47798ac534e 100644 (file)
@@ -32,7 +32,7 @@ static void msmtc_send_ipi_mask(const struct cpumask *mask, unsigned int action)
 /*
  * Post-config but pre-boot cleanup entry point
  */
-static void __cpuinit msmtc_init_secondary(void)
+static void msmtc_init_secondary(void)
 {
        int myvpe;
 
@@ -53,7 +53,7 @@ static void __cpuinit msmtc_init_secondary(void)
 /*
  * Platform "CPU" startup hook
  */
-static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle)
+static void msmtc_boot_secondary(int cpu, struct task_struct *idle)
 {
        smtc_boot_secondary(cpu, idle);
 }
@@ -61,7 +61,7 @@ static void __cpuinit msmtc_boot_secondary(int cpu, struct task_struct *idle)
 /*
  * SMP initialization finalization entry point
  */
-static void __cpuinit msmtc_smp_finish(void)
+static void msmtc_smp_finish(void)
 {
        smtc_smp_finish();
 }
index 0ad305f75802bc64250ad01be6e76b1826ea95a2..53aad4a3537569d3a33b1953c1d42b76db6e40e3 100644 (file)
@@ -150,7 +150,7 @@ static void __init plat_perf_setup(void)
        }
 }
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
 #ifdef MSC01E_INT_BASE
        if (cpu_has_veic) {
index 96b42eb9b5e221cccdc4cf861fe48f5455cb4d0f..a43ea3cc0a3bf61bdbe458f3e38b639ea896b319 100644 (file)
@@ -91,7 +91,7 @@ static void __init plat_perf_setup(void)
        }
 }
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        if (cpu_has_vint)
                set_vi_handler(cp0_compare_irq, mips_timer_dispatch);
index 73facb2b33bbb05dcee6ed3fc782effc6028ce9c..1c7e3a1b81abd622477997fa6b30f5ef861ba1d3 100644 (file)
 #include <linux/slab.h>
 #include <linux/irq.h>
 
+#include <linux/irqdomain.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+
 #include <asm/errno.h>
 #include <asm/signal.h>
 #include <asm/ptrace.h>
@@ -223,17 +227,6 @@ static void nlm_init_node_irqs(int node)
        nodep->irqmask = irqmask;
 }
 
-void __init arch_init_irq(void)
-{
-       /* Initialize the irq descriptors */
-       nlm_init_percpu_irqs();
-       nlm_init_node_irqs(0);
-       write_c0_eimr(nlm_current_node()->irqmask);
-#if defined(CONFIG_CPU_XLR)
-       nlm_setup_fmn_irq();
-#endif
-}
-
 void nlm_smp_irq_init(int hwcpuid)
 {
        int node, cpu;
@@ -266,3 +259,56 @@ asmlinkage void plat_irq_dispatch(void)
        /* top level irq handling */
        do_IRQ(nlm_irq_to_xirq(node, i));
 }
+
+#ifdef CONFIG_OF
+static struct irq_domain *xlp_pic_domain;
+
+static const struct irq_domain_ops xlp_pic_irq_domain_ops = {
+       .xlate = irq_domain_xlate_onetwocell,
+};
+
+static int __init xlp_of_pic_init(struct device_node *node,
+                                       struct device_node *parent)
+{
+       const int n_picirqs = PIC_IRT_LAST_IRQ - PIC_IRQ_BASE + 1;
+       struct resource res;
+       int socid, ret;
+
+       /* we need a hack to get the PIC's SoC chip id */
+       ret = of_address_to_resource(node, 0, &res);
+       if (ret < 0) {
+               pr_err("PIC %s: reg property not found!\n", node->name);
+               return -EINVAL;
+       }
+       socid = (res.start >> 18) & 0x3;
+       xlp_pic_domain = irq_domain_add_legacy(node, n_picirqs,
+               nlm_irq_to_xirq(socid, PIC_IRQ_BASE), PIC_IRQ_BASE,
+               &xlp_pic_irq_domain_ops, NULL);
+       if (xlp_pic_domain == NULL) {
+               pr_err("PIC %s: Creating legacy domain failed!\n", node->name);
+               return -EINVAL;
+       }
+       pr_info("Node %d: IRQ domain created for PIC@%pa\n", socid,
+                                                       &res.start);
+       return 0;
+}
+
+static struct of_device_id __initdata xlp_pic_irq_ids[] = {
+       { .compatible = "netlogic,xlp-pic", .data = xlp_of_pic_init },
+       {},
+};
+#endif
+
+void __init arch_init_irq(void)
+{
+       /* Initialize the irq descriptors */
+       nlm_init_percpu_irqs();
+       nlm_init_node_irqs(0);
+       write_c0_eimr(nlm_current_node()->irqmask);
+#if defined(CONFIG_CPU_XLR)
+       nlm_setup_fmn_irq();
+#endif
+#if defined(CONFIG_OF)
+       of_irq_init(xlp_pic_irq_ids);
+#endif
+}
index 885d293b61da1379fc550f855a64bba61236d074..4e35d9c453e2d98cb99555af3f16ad634bb9a7fb 100644 (file)
@@ -116,7 +116,7 @@ void nlm_early_init_secondary(int cpu)
 /*
  * Code to run on secondary just after probing the CPU
  */
-static void __cpuinit nlm_init_secondary(void)
+static void nlm_init_secondary(void)
 {
        int hwtid;
 
@@ -252,7 +252,7 @@ unsupp:
        return 0;
 }
 
-int __cpuinit nlm_wakeup_secondary_cpus(void)
+int nlm_wakeup_secondary_cpus(void)
 {
        u32 *reset_data;
        int threadmode;
index 528c46c5a17028996cec33db25cb39ba258d8c9f..aa6cff0a229b0c00d2421cdaffc624e47f2b6d8d 100644 (file)
@@ -70,7 +70,6 @@ FEXPORT(xlp_boot_core0_siblings)      /* "Master" cpu starts from here */
        nop
        /* not reached */
 
-       __CPUINIT
 NESTED(nlm_boot_secondary_cpus, 16, sp)
        /* Initialize CP0 Status */
        move    t1, zero
@@ -94,7 +93,6 @@ NESTED(nlm_boot_secondary_cpus, 16, sp)
        jr      t0
        nop
 END(nlm_boot_secondary_cpus)
-       __FINIT
 
 /*
  * In case of RMIboot bootloader which is used on XLR boards, the CPUs
@@ -102,7 +100,6 @@ END(nlm_boot_secondary_cpus)
  * This will get them out of the bootloader code and into linux. Needed
  *  because the bootloader area will be taken and initialized by linux.
  */
-       __CPUINIT
 NESTED(nlm_rmiboot_preboot, 16, sp)
        mfc0    t0, $15, 1      /* read ebase */
        andi    t0, 0x1f        /* t0 has the processor_id() */
@@ -140,4 +137,3 @@ NESTED(nlm_rmiboot_preboot, 16, sp)
        b       1b
        nop
 END(nlm_rmiboot_preboot)
-       __FINIT
index 5c56555380bb18b86d49fea7321ebcd4df16eea5..045a396c57ced6bf25736c6ee6ef3f734ed6cf7f 100644 (file)
@@ -54,7 +54,7 @@
 #error "Unknown CPU"
 #endif
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        return IRQ_TIMER;
 }
index e14f4230806427bfb481d4e46d7a757cd2c82114..06407033678e67262b04d747b9fe957c87cff99f 100644 (file)
                        };
                };
                pic: pic@4000 {
-                       interrupt-controller;
+                       compatible = "netlogic,xlp-pic";
                        #address-cells = <0>;
                        #interrupt-cells = <1>;
                        reg = <0 0x4000 0x200>;
+                       interrupt-controller;
                };
 
                nor_flash@1,0 {
index 8af4bdbe5d993694a49fe614197088f93f65aa39..9c5db102df53a7223e1e04ad1cd64d7460fede60 100644 (file)
                        };
                };
                pic: pic@4000 {
-                       interrupt-controller;
+                       compatible = "netlogic,xlp-pic";
                        #address-cells = <0>;
                        #interrupt-cells = <1>;
                        reg = <0 0x4000 0x200>;
+                       interrupt-controller;
                };
 
                nor_flash@1,0 {
index 9c401dd78337384d1d95050c26ad3b38935d3f50..ef3897ef0dc711d05ea06383b2080f17d2eaa643 100644 (file)
@@ -119,7 +119,7 @@ static u64 xlp_usb_dmamask = ~(u32)0;
 static void nlm_usb_fixup_final(struct pci_dev *dev)
 {
        dev->dev.dma_mask               = &xlp_usb_dmamask;
-       dev->dev.coherent_dma_mask      = DMA_BIT_MASK(64);
+       dev->dev.coherent_dma_mask      = DMA_BIT_MASK(32);
        switch (dev->devfn) {
        case 0x10:
                dev->irq = PIC_EHCI_0_IRQ;
index c06e4c9f0478ced2baea56071b14365043ea425d..9fb81fa6272a753b805952166dd5e8dc45cb93ee 100644 (file)
@@ -49,7 +49,7 @@
 #include <asm/netlogic/xlr/iomap.h>
 #include <asm/netlogic/xlr/pic.h>
 
-int __cpuinit xlr_wakeup_secondary_cpus(void)
+int xlr_wakeup_secondary_cpus(void)
 {
        struct nlm_soc_info *nodep;
        unsigned int i, j, boot_cpu;
index e4b1140cdae060dca0de8bfdd6a5985b1429de58..3a2b6e9f25cfb95ab0f2f5ee1eeccf069bde8f22 100644 (file)
@@ -166,7 +166,7 @@ static void mipsxx_reg_setup(struct op_counter_config *ctr)
                        reg.control[i] |= M_PERFCTL_USER;
                if (ctr[i].exl)
                        reg.control[i] |= M_PERFCTL_EXL;
-               if (current_cpu_type() == CPU_XLR)
+               if (boot_cpu_type() == CPU_XLR)
                        reg.control[i] |= M_PERFCTL_COUNT_ALL_THREADS;
                reg.counter[i] = 0x80000000 - ctr[i].count;
        }
index 7b2ac81e1f598fb2553edc1cd4c4659cd75882c3..162b4cb29dbaa32d0e09edfd2615abe2f0f4f815 100644 (file)
@@ -42,7 +42,7 @@ int irq_to_slot[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS];
 
 extern struct pci_ops bridge_pci_ops;
 
-int __cpuinit bridge_probe(nasid_t nasid, int widget_id, int masterwid)
+int bridge_probe(nasid_t nasid, int widget_id, int masterwid)
 {
        unsigned long offset = NODE_OFFSET(nasid);
        struct bridge_controller *bc;
index c8dcc1c01e181a17e6bad92ff202cdfdeee84b5c..6b5607fce279d267f6bd0a74af023107faef6ca5 100644 (file)
@@ -33,7 +33,7 @@ static void msp_smtc_send_ipi_mask(const struct cpumask *mask,
 /*
  * Post-config but pre-boot cleanup entry point
  */
-static void __cpuinit msp_smtc_init_secondary(void)
+static void msp_smtc_init_secondary(void)
 {
        int myvpe;
 
@@ -48,8 +48,7 @@ static void __cpuinit msp_smtc_init_secondary(void)
 /*
  * Platform "CPU" startup hook
  */
-static void __cpuinit msp_smtc_boot_secondary(int cpu,
-                                       struct task_struct *idle)
+static void msp_smtc_boot_secondary(int cpu, struct task_struct *idle)
 {
        smtc_boot_secondary(cpu, idle);
 }
@@ -57,7 +56,7 @@ static void __cpuinit msp_smtc_boot_secondary(int cpu,
 /*
  * SMP initialization finalization entry point
  */
-static void __cpuinit msp_smtc_smp_finish(void)
+static void msp_smtc_smp_finish(void)
 {
        smtc_smp_finish();
 }
index 8f12ecc55ace5daf90eed56a53c9c489b2ca427f..fea917be0ff10d1100f35a237b2ee1d1732b28cf 100644 (file)
@@ -88,7 +88,7 @@ void __init plat_time_init(void)
        mips_hpt_frequency = cpu_rate/2;
 }
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        /* MIPS_MT modes may want timer for second VPE */
        if ((get_current_vpe()) && !tim_installed) {
index a4a90596c0ad4a2d30113972abcee14b7bea85ab..e460865873c1cdafc021d83938ee7cd178bb0d7d 100644 (file)
@@ -281,7 +281,7 @@ void __init arch_init_irq(void)
        write_c0_status(read_c0_status() | IE_IRQ2);
 }
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        if (cpu_has_vint)
                set_vi_handler(cp0_compare_irq, pnx833x_timer_dispatch);
index d22dc0d6f28922e0f6beefbc2cabad28da0d70e1..2b7e837dc2e2c275e698e101eb1fd961bc44d7ee 100644 (file)
@@ -206,11 +206,13 @@ static struct resource pnx833x_ethernet_resources[] = {
                .end   = PNX8335_IP3902_PORTS_END,
                .flags = IORESOURCE_MEM,
        },
+#ifdef CONFIG_SOC_PNX8335
        [1] = {
                .start = PNX8335_PIC_ETHERNET_INT,
                .end   = PNX8335_PIC_ETHERNET_INT,
                .flags = IORESOURCE_IRQ,
        },
+#endif
 };
 
 static struct platform_device pnx833x_ethernet_device = {
index 9f64c23878082c7e5622733486652381af0315b4..0238af1ba50383689138a929c268a1a592a1464d 100644 (file)
@@ -529,8 +529,7 @@ EXPORT_SYMBOL(asic_resource_get);
  */
 void platform_release_memory(void *ptr, int size)
 {
-       free_reserved_area((unsigned long)ptr, (unsigned long)(ptr + size),
-                          -1, NULL);
+       free_reserved_area(ptr, ptr + size, -1, NULL);
 }
 EXPORT_SYMBOL(platform_release_memory);
 
index 9fd7b67f2af7c42f9c5782a71a732af8caa12ac3..f38b0d45eca90b0ffb6e9691d58b760fef5af5f8 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "powertv-clock.h"
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        return irq_mips_timer;
 }
index 320b1f1043fff108854ac7bab56ae1cf37e5699f..781b3d14a489e60bc8f3da33b3b0a9eac55911b9 100644 (file)
@@ -73,7 +73,7 @@ static struct irq_chip ralink_intc_irq_chip = {
        .irq_mask_ack   = ralink_intc_irq_mask,
 };
 
-unsigned int __cpuinit get_c0_compare_int(void)
+unsigned int get_c0_compare_int(void)
 {
        return CP0_LEGACY_COMPARE_IRQ;
 }
index d41b1c6fb0329a2ee6ca7c8b139632c685369dd2..ee736bd103f85dd77de320f6e78ef0a6bf92f645 100644 (file)
@@ -54,7 +54,7 @@ extern void pcibr_setup(cnodeid_t);
 
 extern void xtalk_probe_node(cnodeid_t nid);
 
-static void __cpuinit per_hub_init(cnodeid_t cnode)
+static void per_hub_init(cnodeid_t cnode)
 {
        struct hub_data *hub = hub_data(cnode);
        nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode);
@@ -110,7 +110,7 @@ static void __cpuinit per_hub_init(cnodeid_t cnode)
        }
 }
 
-void __cpuinit per_cpu_init(void)
+void per_cpu_init(void)
 {
        int cpu = smp_processor_id();
        int slice = LOCAL_HUB_L(PI_CPU_NUM);
index f94638141b20ef18f465e36a8a587374693ad67b..f4ea8aa79ba2daaf341e2fec9be76a1d72aeedde 100644 (file)
@@ -173,12 +173,12 @@ static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action)
                ip27_send_ipi_single(i, action);
 }
 
-static void __cpuinit ip27_init_secondary(void)
+static void ip27_init_secondary(void)
 {
        per_cpu_init();
 }
 
-static void __cpuinit ip27_smp_finish(void)
+static void ip27_smp_finish(void)
 {
        extern void hub_rt_clock_event_init(void);
 
@@ -195,7 +195,7 @@ static void __init ip27_cpus_done(void)
  * set sp to the kernel stack of the newly created idle process, gp to the proc
  * struct so that current_thread_info() will work.
  */
-static void __cpuinit ip27_boot_secondary(int cpu, struct task_struct *idle)
+static void ip27_boot_secondary(int cpu, struct task_struct *idle)
 {
        unsigned long gp = (unsigned long)task_thread_info(idle);
        unsigned long sp = __KSTK_TOS(idle);
index 2e21b761cb9c771586797a50f5eda5666368a81e..1d97eaba0c5f0a86f1022913727fc05cf85bb712 100644 (file)
@@ -106,7 +106,7 @@ struct irqaction hub_rt_irqaction = {
 #define NSEC_PER_CYCLE         800
 #define CYCLES_PER_SEC         (NSEC_PER_SEC / NSEC_PER_CYCLE)
 
-void __cpuinit hub_rt_clock_event_init(void)
+void hub_rt_clock_event_init(void)
 {
        unsigned int cpu = smp_processor_id();
        struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu);
@@ -173,7 +173,7 @@ void __init plat_time_init(void)
        hub_rt_clock_event_init();
 }
 
-void __cpuinit cpu_time_init(void)
+void cpu_time_init(void)
 {
        lboard_t *board;
        klcpu_t *cpu;
@@ -194,7 +194,7 @@ void __cpuinit cpu_time_init(void)
        set_c0_status(SRB_TIMOCLK);
 }
 
-void __cpuinit hub_rtc_init(cnodeid_t cnode)
+void hub_rtc_init(cnodeid_t cnode)
 {
 
        /*
index a4df7d0f6f12d0811ba457207d4db35d9afbb194..d59b820f528d1b5bc5042555a1ede083a0814430 100644 (file)
@@ -23,7 +23,7 @@
 
 extern int bridge_probe(nasid_t nasid, int widget, int masterwid);
 
-static int __cpuinit probe_one_port(nasid_t nasid, int widget, int masterwid)
+static int probe_one_port(nasid_t nasid, int widget, int masterwid)
 {
        widgetreg_t             widget_id;
        xwidget_part_num_t      partnum;
@@ -47,7 +47,7 @@ static int __cpuinit probe_one_port(nasid_t nasid, int widget, int masterwid)
        return 0;
 }
 
-static int __cpuinit xbow_probe(nasid_t nasid)
+static int xbow_probe(nasid_t nasid)
 {
        lboard_t *brd;
        klxbow_t *xbow_p;
@@ -100,7 +100,7 @@ static int __cpuinit xbow_probe(nasid_t nasid)
        return 0;
 }
 
-void __cpuinit xtalk_probe_node(cnodeid_t nid)
+void xtalk_probe_node(cnodeid_t nid)
 {
        volatile u64            hubreg;
        nasid_t                 nasid;
index de88e22694a05940b4dae2fd123688f7849fcdf8..54e2c4de15c1638706879b6356c85c13c10165a0 100644 (file)
@@ -60,7 +60,7 @@ static void *mailbox_0_regs[] = {
 /*
  * SMP init and finish on secondary CPUs
  */
-void __cpuinit bcm1480_smp_init(void)
+void bcm1480_smp_init(void)
 {
        unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
                STATUSF_IP1 | STATUSF_IP0;
@@ -95,7 +95,7 @@ static void bcm1480_send_ipi_mask(const struct cpumask *mask,
 /*
  * Code to run on secondary just after probing the CPU
  */
-static void __cpuinit bcm1480_init_secondary(void)
+static void bcm1480_init_secondary(void)
 {
        extern void bcm1480_smp_init(void);
 
@@ -106,7 +106,7 @@ static void __cpuinit bcm1480_init_secondary(void)
  * Do any tidying up before marking online and running the idle
  * loop
  */
-static void __cpuinit bcm1480_smp_finish(void)
+static void bcm1480_smp_finish(void)
 {
        extern void sb1480_clockevent_init(void);
 
@@ -125,7 +125,7 @@ static void bcm1480_cpus_done(void)
  * Setup the PC, SP, and GP of a secondary processor and start it
  * running!
  */
-static void __cpuinit bcm1480_boot_secondary(int cpu, struct task_struct *idle)
+static void bcm1480_boot_secondary(int cpu, struct task_struct *idle)
 {
        int retval;
 
index 285cfef4ebc083cc24a554c3bb4a534a9092f48c..d7b942db0ea519e0c5f6f8b39c69fa21589a5eaa 100644 (file)
@@ -48,7 +48,7 @@ static void *mailbox_regs[] = {
 /*
  * SMP init and finish on secondary CPUs
  */
-void __cpuinit sb1250_smp_init(void)
+void sb1250_smp_init(void)
 {
        unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |
                STATUSF_IP1 | STATUSF_IP0;
@@ -83,7 +83,7 @@ static inline void sb1250_send_ipi_mask(const struct cpumask *mask,
 /*
  * Code to run on secondary just after probing the CPU
  */
-static void __cpuinit sb1250_init_secondary(void)
+static void sb1250_init_secondary(void)
 {
        extern void sb1250_smp_init(void);
 
@@ -94,7 +94,7 @@ static void __cpuinit sb1250_init_secondary(void)
  * Do any tidying up before marking online and running the idle
  * loop
  */
-static void __cpuinit sb1250_smp_finish(void)
+static void sb1250_smp_finish(void)
 {
        extern void sb1250_clockevent_init(void);
 
@@ -113,7 +113,7 @@ static void sb1250_cpus_done(void)
  * Setup the PC, SP, and GP of a secondary processor and start it
  * running!
  */
-static void __cpuinit sb1250_boot_secondary(int cpu, struct task_struct *idle)
+static void sb1250_boot_secondary(int cpu, struct task_struct *idle)
 {
        int retval;
 
index 99dbab1c59ac2ef78d4f4566da9c47b3e3a6350f..d60bf98fa5cf399430d5beaaed9e3cd9c7188e67 100644 (file)
@@ -55,6 +55,7 @@ config GENERIC_CSUM
 
 source "init/Kconfig"
 
+source "kernel/Kconfig.freezer"
 
 menu "Processor type and features"
 
index f4d5bedc3b4f72bc92a939d0cb84b71215fbd929..d7359ffbcbdd325b32bebd1aed3aea02bdd5d8ef 100644 (file)
@@ -267,7 +267,7 @@ void __init detect_unit_config(unsigned long upr, unsigned long mask,
  *
  */
 
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        const int *val;
        struct device_node *cpu = NULL;
diff --git a/arch/parisc/configs/c8000_defconfig b/arch/parisc/configs/c8000_defconfig
new file mode 100644 (file)
index 0000000..f110063
--- /dev/null
@@ -0,0 +1,279 @@
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_FHANDLE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_RD_BZIP2=y
+CONFIG_RD_LZMA=y
+CONFIG_RD_LZO=y
+CONFIG_EXPERT=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_SLAB=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_PA8X00=y
+CONFIG_MLONGCALLS=y
+CONFIG_64BIT=y
+CONFIG_SMP=y
+CONFIG_PREEMPT=y
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+CONFIG_IOMMU_CCIO=y
+CONFIG_PCI=y
+CONFIG_PCI_LBA=y
+# CONFIG_SUPERIO is not set
+# CONFIG_CHASSIS_LCD_LED is not set
+# CONFIG_PDC_CHASSIS is not set
+# CONFIG_PDC_CHASSIS_WARN is not set
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_BINFMT_MISC=m
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_XFRM_USER=m
+CONFIG_XFRM_SUB_POLICY=y
+CONFIG_NET_KEY=m
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_DIAG=m
+# CONFIG_IPV6 is not set
+CONFIG_IP_DCCP=m
+# CONFIG_IP_DCCP_CCID3 is not set
+CONFIG_TIPC=m
+CONFIG_LLC2=m
+CONFIG_DNS_RESOLVER=y
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_STANDALONE is not set
+CONFIG_PARPORT=y
+CONFIG_PARPORT_PC=y
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_BLK_DEV_UMEM=m
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_SX8=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=6144
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDECD=y
+CONFIG_BLK_DEV_PLATFORM=y
+CONFIG_BLK_DEV_GENERIC=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_FC_ATTRS=y
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_ISCSI_TCP=m
+CONFIG_ISCSI_BOOT_SYSFS=m
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=y
+CONFIG_FUSION_SAS=y
+CONFIG_NETDEVICES=y
+CONFIG_DUMMY=m
+CONFIG_NETCONSOLE=m
+CONFIG_TUN=y
+CONFIG_E1000=y
+CONFIG_PPP=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+# CONFIG_WLAN is not set
+CONFIG_INPUT_FF_MEMLESS=m
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_HIL_OLD is not set
+# CONFIG_KEYBOARD_HIL is not set
+CONFIG_MOUSE_PS2=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_CM109=m
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_GSCPS2=m
+# CONFIG_HP_SDC is not set
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_SERIAL_8250=y
+# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=8
+CONFIG_SERIAL_8250_RUNTIME_UARTS=8
+CONFIG_SERIAL_8250_EXTENDED=y
+# CONFIG_SERIAL_MUX is not set
+CONFIG_SERIAL_JSM=m
+CONFIG_PRINTER=y
+CONFIG_HW_RANDOM=y
+CONFIG_RAW_DRIVER=m
+CONFIG_PTP_1588_CLOCK=y
+CONFIG_SSB=m
+CONFIG_SSB_DRIVER_PCICORE=y
+CONFIG_AGP=y
+CONFIG_AGP_PARISC=y
+CONFIG_DRM=y
+CONFIG_DRM_RADEON=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_FOREIGN_ENDIAN=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+# CONFIG_FB_STI is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_GENERIC is not set
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_STI_CONSOLE is not set
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+# CONFIG_LOGO_LINUX_CLUT224 is not set
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_AD1889=m
+# CONFIG_SND_USB is not set
+# CONFIG_SND_GSC is not set
+CONFIG_HID_A4TECH=m
+CONFIG_HID_APPLE=m
+CONFIG_HID_BELKIN=m
+CONFIG_HID_CHERRY=m
+CONFIG_HID_CHICONY=m
+CONFIG_HID_CYPRESS=m
+CONFIG_HID_DRAGONRISE=m
+CONFIG_HID_EZKEY=m
+CONFIG_HID_KYE=m
+CONFIG_HID_GYRATION=m
+CONFIG_HID_TWINHAN=m
+CONFIG_HID_KENSINGTON=m
+CONFIG_HID_LOGITECH=m
+CONFIG_HID_LOGITECH_DJ=m
+CONFIG_HID_MICROSOFT=m
+CONFIG_HID_MONTEREY=m
+CONFIG_HID_NTRIG=m
+CONFIG_HID_ORTEK=m
+CONFIG_HID_PANTHERLORD=m
+CONFIG_HID_PETALYNX=m
+CONFIG_HID_SAMSUNG=m
+CONFIG_HID_SUNPLUS=m
+CONFIG_HID_GREENASIA=m
+CONFIG_HID_SMARTJOYPLUS=m
+CONFIG_HID_TOPSEED=m
+CONFIG_HID_THRUSTMASTER=m
+CONFIG_HID_ZEROPLUS=m
+CONFIG_USB_HID=m
+CONFIG_USB=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_STORAGE=y
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+CONFIG_EXT4_FS=m
+CONFIG_REISERFS_FS=m
+CONFIG_REISERFS_PROC_INFO=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_QUOTA=y
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_PROC_KCORE=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_XATTR=y
+CONFIG_NFS_FS=m
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_SLAB=y
+CONFIG_DEBUG_SLAB_LEAK=y
+CONFIG_DEBUG_MEMORY_INIT=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+CONFIG_LOCKUP_DETECTOR=y
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y
+CONFIG_PANIC_ON_OOPS=y
+CONFIG_DEBUG_RT_MUTEXES=y
+CONFIG_RT_MUTEX_TESTER=y
+CONFIG_PROVE_RCU_DELAY=y
+CONFIG_DEBUG_BLOCK_EXT_DEVT=y
+CONFIG_LATENCYTOP=y
+CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
+CONFIG_KEYS=y
+# CONFIG_CRYPTO_HW is not set
+CONFIG_FONTS=y
index 9afdad6c2ffb81db7f8ffb68dd003bd3b5cd4980..eaf4dc1c729440688a169bd11fe81b250b8c776f 100644 (file)
@@ -23,6 +23,7 @@ struct parisc_device {
        /* generic info returned from pdc_pat_cell_module() */
        unsigned long   mod_info;       /* PAT specific - Misc Module info */
        unsigned long   pmod_loc;       /* physical Module location */
+       unsigned long   mod0;
 #endif
        u64             dma_mask;       /* DMA mask for I/O */
        struct device   dev;
@@ -61,4 +62,6 @@ parisc_get_drvdata(struct parisc_device *d)
 
 extern struct bus_type parisc_bus_type;
 
+int iosapic_serial_irq(struct parisc_device *dev);
+
 #endif /*_ASM_PARISC_PARISC_DEVICE_H_*/
index 2e65aa54bd101b7dc5600297858929687e90d549..c035673209f732f0850aaa4dc98d2d49eee3b74c 100644 (file)
@@ -71,18 +71,27 @@ flush_cache_all_local(void)
 }
 EXPORT_SYMBOL(flush_cache_all_local);
 
+/* Virtual address of pfn.  */
+#define pfn_va(pfn)    __va(PFN_PHYS(pfn))
+
 void
 update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
 {
-       struct page *page = pte_page(*ptep);
+       unsigned long pfn = pte_pfn(*ptep);
+       struct page *page;
 
-       if (pfn_valid(page_to_pfn(page)) && page_mapping(page) &&
-           test_bit(PG_dcache_dirty, &page->flags)) {
+       /* We don't have pte special.  As a result, we can be called with
+          an invalid pfn and we don't need to flush the kernel dcache page.
+          This occurs with FireGL card in C8000.  */
+       if (!pfn_valid(pfn))
+               return;
 
-               flush_kernel_dcache_page(page);
+       page = pfn_to_page(pfn);
+       if (page_mapping(page) && test_bit(PG_dcache_dirty, &page->flags)) {
+               flush_kernel_dcache_page_addr(pfn_va(pfn));
                clear_bit(PG_dcache_dirty, &page->flags);
        } else if (parisc_requires_coherency())
-               flush_kernel_dcache_page(page);
+               flush_kernel_dcache_page_addr(pfn_va(pfn));
 }
 
 void
@@ -495,44 +504,42 @@ static inline pte_t *get_ptep(pgd_t *pgd, unsigned long addr)
 
 void flush_cache_mm(struct mm_struct *mm)
 {
+       struct vm_area_struct *vma;
+       pgd_t *pgd;
+
        /* Flushing the whole cache on each cpu takes forever on
           rp3440, etc.  So, avoid it if the mm isn't too big.  */
-       if (mm_total_size(mm) < parisc_cache_flush_threshold) {
-               struct vm_area_struct *vma;
-
-               if (mm->context == mfsp(3)) {
-                       for (vma = mm->mmap; vma; vma = vma->vm_next) {
-                               flush_user_dcache_range_asm(vma->vm_start,
-                                       vma->vm_end);
-                               if (vma->vm_flags & VM_EXEC)
-                                       flush_user_icache_range_asm(
-                                         vma->vm_start, vma->vm_end);
-                       }
-               } else {
-                       pgd_t *pgd = mm->pgd;
-
-                       for (vma = mm->mmap; vma; vma = vma->vm_next) {
-                               unsigned long addr;
-
-                               for (addr = vma->vm_start; addr < vma->vm_end;
-                                    addr += PAGE_SIZE) {
-                                       pte_t *ptep = get_ptep(pgd, addr);
-                                       if (ptep != NULL) {
-                                               pte_t pte = *ptep;
-                                               __flush_cache_page(vma, addr,
-                                                 page_to_phys(pte_page(pte)));
-                                       }
-                               }
-                       }
+       if (mm_total_size(mm) >= parisc_cache_flush_threshold) {
+               flush_cache_all();
+               return;
+       }
+
+       if (mm->context == mfsp(3)) {
+               for (vma = mm->mmap; vma; vma = vma->vm_next) {
+                       flush_user_dcache_range_asm(vma->vm_start, vma->vm_end);
+                       if ((vma->vm_flags & VM_EXEC) == 0)
+                               continue;
+                       flush_user_icache_range_asm(vma->vm_start, vma->vm_end);
                }
                return;
        }
 
-#ifdef CONFIG_SMP
-       flush_cache_all();
-#else
-       flush_cache_all_local();
-#endif
+       pgd = mm->pgd;
+       for (vma = mm->mmap; vma; vma = vma->vm_next) {
+               unsigned long addr;
+
+               for (addr = vma->vm_start; addr < vma->vm_end;
+                    addr += PAGE_SIZE) {
+                       unsigned long pfn;
+                       pte_t *ptep = get_ptep(pgd, addr);
+                       if (!ptep)
+                               continue;
+                       pfn = pte_pfn(*ptep);
+                       if (!pfn_valid(pfn))
+                               continue;
+                       __flush_cache_page(vma, addr, PFN_PHYS(pfn));
+               }
+       }
 }
 
 void
@@ -556,33 +563,32 @@ flush_user_icache_range(unsigned long start, unsigned long end)
 void flush_cache_range(struct vm_area_struct *vma,
                unsigned long start, unsigned long end)
 {
+       unsigned long addr;
+       pgd_t *pgd;
+
        BUG_ON(!vma->vm_mm->context);
 
-       if ((end - start) < parisc_cache_flush_threshold) {
-               if (vma->vm_mm->context == mfsp(3)) {
-                       flush_user_dcache_range_asm(start, end);
-                       if (vma->vm_flags & VM_EXEC)
-                               flush_user_icache_range_asm(start, end);
-               } else {
-                       unsigned long addr;
-                       pgd_t *pgd = vma->vm_mm->pgd;
-
-                       for (addr = start & PAGE_MASK; addr < end;
-                            addr += PAGE_SIZE) {
-                               pte_t *ptep = get_ptep(pgd, addr);
-                               if (ptep != NULL) {
-                                       pte_t pte = *ptep;
-                                       flush_cache_page(vma,
-                                          addr, pte_pfn(pte));
-                               }
-                       }
-               }
-       } else {
-#ifdef CONFIG_SMP
+       if ((end - start) >= parisc_cache_flush_threshold) {
                flush_cache_all();
-#else
-               flush_cache_all_local();
-#endif
+               return;
+       }
+
+       if (vma->vm_mm->context == mfsp(3)) {
+               flush_user_dcache_range_asm(start, end);
+               if (vma->vm_flags & VM_EXEC)
+                       flush_user_icache_range_asm(start, end);
+               return;
+       }
+
+       pgd = vma->vm_mm->pgd;
+       for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
+               unsigned long pfn;
+               pte_t *ptep = get_ptep(pgd, addr);
+               if (!ptep)
+                       continue;
+               pfn = pte_pfn(*ptep);
+               if (pfn_valid(pfn))
+                       __flush_cache_page(vma, addr, PFN_PHYS(pfn));
        }
 }
 
@@ -591,9 +597,10 @@ flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long
 {
        BUG_ON(!vma->vm_mm->context);
 
-       flush_tlb_page(vma, vmaddr);
-       __flush_cache_page(vma, vmaddr, page_to_phys(pfn_to_page(pfn)));
-
+       if (pfn_valid(pfn)) {
+               flush_tlb_page(vma, vmaddr);
+               __flush_cache_page(vma, vmaddr, PFN_PHYS(pfn));
+       }
 }
 
 #ifdef CONFIG_PARISC_TMPALIAS
index f65fa480c905fd4d06052da6afd01029a3202a5a..22395901d47bc8a541d4e8ee39ed7d4979031905 100644 (file)
@@ -150,7 +150,7 @@ static void convert_to_wide(unsigned long *addr)
 }
 
 #ifdef CONFIG_64BIT
-void __cpuinit set_firmware_width_unlocked(void)
+void set_firmware_width_unlocked(void)
 {
        int ret;
 
@@ -167,7 +167,7 @@ void __cpuinit set_firmware_width_unlocked(void)
  * This function must be called before any pdc_* function that uses the
  * convert_to_wide function.
  */
-void __cpuinit set_firmware_width(void)
+void set_firmware_width(void)
 {
        unsigned long flags;
        spin_lock_irqsave(&pdc_lock, flags);
@@ -175,11 +175,13 @@ void __cpuinit set_firmware_width(void)
        spin_unlock_irqrestore(&pdc_lock, flags);
 }
 #else
-void __cpuinit set_firmware_width_unlocked(void) {
+void set_firmware_width_unlocked(void)
+{
        return;
 }
 
-void __cpuinit set_firmware_width(void) {
+void set_firmware_width(void)
+{
        return;
 }
 #endif /*CONFIG_64BIT*/
@@ -301,7 +303,7 @@ int pdc_chassis_warn(unsigned long *warn)
        return retval;
 }
 
-int __cpuinit pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info)
+int pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info)
 {
        int ret;
 
@@ -322,7 +324,7 @@ int __cpuinit pdc_coproc_cfg_unlocked(struct pdc_coproc_cfg *pdc_coproc_info)
  * This PDC call returns the presence and status of all the coprocessors
  * attached to the processor.
  */
-int __cpuinit pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info)
+int pdc_coproc_cfg(struct pdc_coproc_cfg *pdc_coproc_info)
 {
        int ret;
        unsigned long flags;
index 872275659d986f0b4357b35db888740895c2211e..06cb3992907e67e9847b84259e5a61f3e42c2b71 100644 (file)
@@ -1367,7 +1367,7 @@ const char *parisc_hardware_description(struct parisc_device_id *id)
 
 
 /* Interpret hversion (ret[0]) from PDC_MODEL(4)/PDC_MODEL_INFO(0) */
-enum cpu_type __cpuinit
+enum cpu_type
 parisc_get_cpu_type(unsigned long hversion)
 {
        struct hp_cpu_type_mask *ptr;
index 3295ef4a185d06327c84b806276f31ac4c7cdaab..f0b6722fc706169b37a407a1fad6b063984722e8 100644 (file)
@@ -211,6 +211,7 @@ pat_query_module(ulong pcell_loc, ulong mod_index)
        /* REVISIT: who is the consumer of this? not sure yet... */
        dev->mod_info = pa_pdc_cell->mod_info;  /* pass to PAT_GET_ENTITY() */
        dev->pmod_loc = pa_pdc_cell->mod_location;
+       dev->mod0 = pa_pdc_cell->mod[0];
 
        register_parisc_device(dev);    /* advertise device */
 
index 8a96c8ab9fe61a7bacf79b9653761616b5d70c5b..b68d977ce30fbf80e90497da5363bac01a7115a9 100644 (file)
@@ -73,7 +73,7 @@ extern int update_cr16_clocksource(void);     /* from time.c */
  *
  * FIXME: doesn't do much yet...
  */
-static void __cpuinit
+static void
 init_percpu_prof(unsigned long cpunum)
 {
        struct cpuinfo_parisc *p;
@@ -92,7 +92,7 @@ init_percpu_prof(unsigned long cpunum)
  * (return 1).  If so, initialize the chip and tell other partners in crime 
  * they have work to do.
  */
-static int __cpuinit processor_probe(struct parisc_device *dev)
+static int processor_probe(struct parisc_device *dev)
 {
        unsigned long txn_addr;
        unsigned long cpuid;
@@ -299,7 +299,7 @@ void __init collect_boot_cpu_data(void)
  *
  * o Enable CPU profiling hooks.
  */
-int __cpuinit init_per_cpu(int cpunum)
+int init_per_cpu(int cpunum)
 {
        int ret;
        struct pdc_coproc_cfg coproc_cfg;
index 940188d1942caeb993ffc58aa7148fea50c91683..07349b00268750581d1badb79b2c2487732831b8 100644 (file)
  * this. */
 #define A(__x) ((unsigned long)(__x))
 
-/*
- * Atomically swap in the new signal mask, and wait for a signal.
- */
-#ifdef CONFIG_64BIT
-#include "sys32.h"
-#endif
-
 /*
  * Do a signal return - restore sigcontext.
  */
index 33eca1b04926ad09184d703e9c2fcb55cd127069..6c6a271a6140e639183334a70a470860f906d7bf 100644 (file)
@@ -34,7 +34,6 @@
 #include <asm/uaccess.h>
 
 #include "signal32.h"
-#include "sys32.h"
 
 #define DEBUG_COMPAT_SIG 0 
 #define DEBUG_COMPAT_SIG_LEVEL 2
index e3614fb343e5eca796f919482e8873ae48e17c19..8a252f2d6c087aad6248e98178c79eef818c14da 100644 (file)
@@ -62,9 +62,9 @@ static int smp_debug_lvl = 0;
 volatile struct task_struct *smp_init_current_idle_task;
 
 /* track which CPU is booting */
-static volatile int cpu_now_booting __cpuinitdata;
+static volatile int cpu_now_booting;
 
-static int parisc_max_cpus __cpuinitdata = 1;
+static int parisc_max_cpus = 1;
 
 static DEFINE_PER_CPU(spinlock_t, ipi_lock);
 
@@ -328,7 +328,7 @@ void __init smp_callin(void)
 /*
  * Bring one cpu online.
  */
-int __cpuinit smp_boot_one_cpu(int cpuid, struct task_struct *idle)
+int smp_boot_one_cpu(int cpuid, struct task_struct *idle)
 {
        const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
        long timeout;
@@ -424,7 +424,7 @@ void smp_cpus_done(unsigned int cpu_max)
 }
 
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        if (cpu != 0 && cpu < parisc_max_cpus)
                smp_boot_one_cpu(cpu, tidle);
diff --git a/arch/parisc/kernel/sys32.h b/arch/parisc/kernel/sys32.h
deleted file mode 100644 (file)
index 60dd470..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* 
- *    Copyright (C) 2002 Richard Hirst <rhirst at parisc-linux.org>
- *    Copyright (C) 2003 James Bottomley <jejb at parisc-linux.org>
- *    Copyright (C) 2003 Randolph Chung <tausq with parisc-linux.org>
- *
- *    This program is free software; you can redistribute it and/or modify
- *    it under the terms of the GNU General Public License as published by
- *    the Free Software Foundation; either version 2 of the License, or
- *    (at your option) any later version.
- *
- *    This program is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#ifndef _PARISC64_KERNEL_SYS32_H
-#define _PARISC64_KERNEL_SYS32_H
-
-#include <linux/compat.h>
-
-/* Call a kernel syscall which will use kernel space instead of user
- * space for its copy_to/from_user.
- */
-#define KERNEL_SYSCALL(ret, syscall, args...) \
-{ \
-    mm_segment_t old_fs = get_fs(); \
-    set_fs(KERNEL_DS); \
-    ret = syscall(args); \
-    set_fs (old_fs); \
-}
-
-#endif
index a134ff4da12ee1e4ad39a78e514328f578573ca3..bb9f3b64de55b2583f9fc930b6a1fa368237fd49 100644 (file)
@@ -42,8 +42,6 @@
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 
-#include "sys32.h"
-
 #undef DEBUG
 
 #ifdef DEBUG
index 3bf72cd2c8fcbf0f8feebe915d4dc2aca3f44f28..dbd9d3c991e86ca61e16fff87047bd6956b21420 100644 (file)
@@ -566,7 +566,7 @@ config SCHED_SMT
 config PPC_DENORMALISATION
        bool "PowerPC denormalisation exception handling"
        depends on PPC_BOOK3S_64
-       default "n"
+       default "y" if PPC_POWERNV
        ---help---
          Add support for handling denormalisation of single precision
          values.  Useful for bare metal only.  If unsure say Y here.
index c86fcb92358e27bc93bd723375d04c9e1c247071..0e8cfd09da2f65dd95197c2e8ca86d5ae6dfbf24 100644 (file)
@@ -58,7 +58,7 @@ CONFIG_SCHED_SMT=y
 CONFIG_PPC_DENORMALISATION=y
 CONFIG_PCCARD=y
 CONFIG_ELECTRA_CF=y
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_RPA=m
 CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
 CONFIG_PACKET=y
index 4b20f76172e2efb2f2d3d1e1c5a8c8bdbc6656dc..0085dc4642c5bb107b61bcbe80c9935449d64b8d 100644 (file)
@@ -32,7 +32,7 @@ CONFIG_IRQ_ALL_CPUS=y
 CONFIG_SPARSEMEM_MANUAL=y
 CONFIG_PCI_MSI=y
 CONFIG_PCCARD=y
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
 CONFIG_XFRM_USER=m
index bea8587c3af509b1540fe6138614f73dcbf97c9c..1d4b9763895df77dafcfd61bb4eea7bed6a18621 100644 (file)
@@ -53,7 +53,7 @@ CONFIG_PPC_64K_PAGES=y
 CONFIG_PPC_SUBPAGE_PROT=y
 CONFIG_SCHED_SMT=y
 CONFIG_PPC_DENORMALISATION=y
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_RPA=m
 CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
 CONFIG_PACKET=y
index 09a8743143f37a046e8d57e3d65f58f9a1bd3cb4..d3e5e9bc8f946fa3fd7158a3ecc931561c71c1a3 100644 (file)
@@ -55,6 +55,8 @@ struct device_node;
 #define EEH_PE_RECOVERING      (1 << 1)        /* Recovering PE        */
 #define EEH_PE_PHB_DEAD                (1 << 2)        /* Dead PHB             */
 
+#define EEH_PE_KEEP            (1 << 8)        /* Keep PE on hotplug   */
+
 struct eeh_pe {
        int type;                       /* PE type: PHB/Bus/Device      */
        int state;                      /* PE EEH dependent mode        */
@@ -72,8 +74,8 @@ struct eeh_pe {
        struct list_head child;         /* Child PEs                    */
 };
 
-#define eeh_pe_for_each_dev(pe, edev) \
-               list_for_each_entry(edev, &pe->edevs, list)
+#define eeh_pe_for_each_dev(pe, edev, tmp) \
+               list_for_each_entry_safe(edev, tmp, &pe->edevs, list)
 
 /*
  * The struct is used to trace EEH state for the associated
@@ -82,7 +84,13 @@ struct eeh_pe {
  * another tree except the currently existing tree of PCI
  * buses and PCI devices
  */
-#define EEH_DEV_IRQ_DISABLED   (1<<0)  /* Interrupt disabled           */
+#define EEH_DEV_BRIDGE         (1 << 0)        /* PCI bridge           */
+#define EEH_DEV_ROOT_PORT      (1 << 1)        /* PCIe root port       */
+#define EEH_DEV_DS_PORT                (1 << 2)        /* Downstream port      */
+#define EEH_DEV_IRQ_DISABLED   (1 << 3)        /* Interrupt disabled   */
+#define EEH_DEV_DISCONNECTED   (1 << 4)        /* Removing from PE     */
+
+#define EEH_DEV_SYSFS          (1 << 8)        /* Sysfs created        */
 
 struct eeh_dev {
        int mode;                       /* EEH mode                     */
@@ -90,11 +98,13 @@ struct eeh_dev {
        int config_addr;                /* Config address               */
        int pe_config_addr;             /* PE config address            */
        u32 config_space[16];           /* Saved PCI config space       */
+       u8 pcie_cap;                    /* Saved PCIe capability        */
        struct eeh_pe *pe;              /* Associated PE                */
        struct list_head list;          /* Form link list in the PE     */
        struct pci_controller *phb;     /* Associated PHB               */
        struct device_node *dn;         /* Associated device node       */
        struct pci_dev *pdev;           /* Associated PCI device        */
+       struct pci_bus *bus;            /* PCI bus for partial hotplug  */
 };
 
 static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
@@ -193,8 +203,10 @@ int eeh_phb_pe_create(struct pci_controller *phb);
 struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
 struct eeh_pe *eeh_pe_get(struct eeh_dev *edev);
 int eeh_add_to_parent_pe(struct eeh_dev *edev);
-int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe);
+int eeh_rmv_from_parent_pe(struct eeh_dev *edev);
 void eeh_pe_update_time_stamp(struct eeh_pe *pe);
+void *eeh_pe_traverse(struct eeh_pe *root,
+               eeh_traverse_func fn, void *flag);
 void *eeh_pe_dev_traverse(struct eeh_pe *root,
                eeh_traverse_func fn, void *flag);
 void eeh_pe_restore_bars(struct eeh_pe *pe);
@@ -209,10 +221,12 @@ unsigned long eeh_check_failure(const volatile void __iomem *token,
                                unsigned long val);
 int eeh_dev_check_failure(struct eeh_dev *edev);
 void eeh_addr_cache_build(void);
+void eeh_add_device_early(struct device_node *);
 void eeh_add_device_tree_early(struct device_node *);
+void eeh_add_device_late(struct pci_dev *);
 void eeh_add_device_tree_late(struct pci_bus *);
 void eeh_add_sysfs_files(struct pci_bus *);
-void eeh_remove_bus_device(struct pci_dev *, int);
+void eeh_remove_device(struct pci_dev *);
 
 /**
  * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
@@ -252,13 +266,17 @@ static inline unsigned long eeh_check_failure(const volatile void __iomem *token
 
 static inline void eeh_addr_cache_build(void) { }
 
+static inline void eeh_add_device_early(struct device_node *dn) { }
+
 static inline void eeh_add_device_tree_early(struct device_node *dn) { }
 
+static inline void eeh_add_device_late(struct pci_dev *dev) { }
+
 static inline void eeh_add_device_tree_late(struct pci_bus *bus) { }
 
 static inline void eeh_add_sysfs_files(struct pci_bus *bus) { }
 
-static inline void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) { }
+static inline void eeh_remove_device(struct pci_dev *dev) { }
 
 #define EEH_POSSIBLE_ERROR(val, type) (0)
 #define EEH_IO_ERROR_VALUE(size) (-1UL)
index ba713f166fa57fb2f9b08002a8a5cf8c0162d196..10be1dd01c6b4bcd79f88725f9b5067dc8a0db8a 100644 (file)
@@ -96,10 +96,11 @@ static inline bool arch_irqs_disabled(void)
 #endif
 
 #define hard_irq_disable()     do {                    \
-       u8 _was_enabled = get_paca()->soft_enabled;     \
+       u8 _was_enabled;                                \
        __hard_irq_disable();                           \
-       get_paca()->soft_enabled = 0;                   \
-       get_paca()->irq_happened |= PACA_IRQ_HARD_DIS;  \
+       _was_enabled = local_paca->soft_enabled;        \
+       local_paca->soft_enabled = 0;                   \
+       local_paca->irq_happened |= PACA_IRQ_HARD_DIS;  \
        if (_was_enabled)                               \
                trace_hardirqs_off();                   \
 } while(0)
index c1df590ec4440a96f81b97f6048ad79a7f326179..49fa55bfbac4fba38f26368cbbdcdf1513aa590c 100644 (file)
@@ -82,10 +82,9 @@ struct exception_table_entry;
 void sort_ex_table(struct exception_table_entry *start,
                   struct exception_table_entry *finish);
 
-#ifdef CONFIG_MODVERSIONS
+#if defined(CONFIG_MODVERSIONS) && defined(CONFIG_PPC64)
 #define ARCH_RELOCATES_KCRCTAB
-
-extern const unsigned long reloc_start[];
+#define reloc_start PHYSICAL_START
 #endif
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_MODULE_H */
index 2c1d8cb9b26562a295ab6b6016261b0d692df30b..32d0d2018faf84afe15814f13cb7f1fe4933fa4e 100644 (file)
@@ -209,7 +209,6 @@ static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
 extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn);
 
 /** Remove all of the PCI devices under this bus */
-extern void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe);
 extern void pcibios_remove_pci_devices(struct pci_bus *bus);
 
 /** Discover new pci devices under this bus, and add them */
index 2dd7bfc459bed73eba9f1be705acf44d7fb36c3d..8b24926447544c2fed3eb44de6464071a20f15dc 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/types.h>
 #include <asm/hw_irq.h>
 #include <linux/device.h>
+#include <uapi/asm/perf_event.h>
 
 #define MAX_HWEVENTS           8
 #define MAX_EVENT_ALTERNATIVES 8
@@ -69,11 +70,6 @@ struct power_pmu {
 #define PPMU_LIMITED_PMC_REQD  2       /* have to put this on a limited PMC */
 #define PPMU_ONLY_COUNT_RUN    4       /* only counting in run state */
 
-/*
- * We use the event config bit 63 as a flag to request EBB.
- */
-#define EVENT_CONFIG_EBB_SHIFT 63
-
 extern int register_power_pmu(struct power_pmu *);
 
 struct pt_regs;
index 47a35b08b9635ce375e266a6c12fd3b02869302b..e378cccfca55bb20db094f12a2009ad3ba7bf1a4 100644 (file)
@@ -247,6 +247,10 @@ struct thread_struct {
        unsigned long   tm_orig_msr;    /* Thread's MSR on ctx switch */
        struct pt_regs  ckpt_regs;      /* Checkpointed registers */
 
+       unsigned long   tm_tar;
+       unsigned long   tm_ppr;
+       unsigned long   tm_dscr;
+
        /*
         * Transactional FP and VSX 0-31 register set.
         * NOTE: the sense of these is the opposite of the integer ckpt_regs!
index 5d7d9c2a547373dbb692ebded8b519df476bb2e4..99222e27f1739c543faa916d3d766be5f99e5fbd 100644 (file)
 #define SPRN_HRMOR     0x139   /* Real mode offset register */
 #define SPRN_HSRR0     0x13A   /* Hypervisor Save/Restore 0 */
 #define SPRN_HSRR1     0x13B   /* Hypervisor Save/Restore 1 */
+/* HFSCR and FSCR bit numbers are the same */
+#define FSCR_TAR_LG    8       /* Enable Target Address Register */
+#define FSCR_EBB_LG    7       /* Enable Event Based Branching */
+#define FSCR_TM_LG     5       /* Enable Transactional Memory */
+#define FSCR_PM_LG     4       /* Enable prob/priv access to PMU SPRs */
+#define FSCR_BHRB_LG   3       /* Enable Branch History Rolling Buffer*/
+#define FSCR_DSCR_LG   2       /* Enable Data Stream Control Register */
+#define FSCR_VECVSX_LG 1       /* Enable VMX/VSX  */
+#define FSCR_FP_LG     0       /* Enable Floating Point */
 #define SPRN_FSCR      0x099   /* Facility Status & Control Register */
-#define   FSCR_TAR     (1 << (63-55)) /* Enable Target Address Register */
-#define   FSCR_EBB     (1 << (63-56)) /* Enable Event Based Branching */
-#define   FSCR_DSCR    (1 << (63-61)) /* Enable Data Stream Control Register */
+#define   FSCR_TAR     __MASK(FSCR_TAR_LG)
+#define   FSCR_EBB     __MASK(FSCR_EBB_LG)
+#define   FSCR_DSCR    __MASK(FSCR_DSCR_LG)
 #define SPRN_HFSCR     0xbe    /* HV=1 Facility Status & Control Register */
-#define   HFSCR_TAR    (1 << (63-55)) /* Enable Target Address Register */
-#define   HFSCR_EBB    (1 << (63-56)) /* Enable Event Based Branching */
-#define   HFSCR_TM     (1 << (63-58)) /* Enable Transactional Memory */
-#define   HFSCR_PM     (1 << (63-60)) /* Enable prob/priv access to PMU SPRs */
-#define   HFSCR_BHRB   (1 << (63-59)) /* Enable Branch History Rolling Buffer*/
-#define   HFSCR_DSCR   (1 << (63-61)) /* Enable Data Stream Control Register */
-#define   HFSCR_VECVSX (1 << (63-62)) /* Enable VMX/VSX  */
-#define   HFSCR_FP     (1 << (63-63)) /* Enable Floating Point */
+#define   HFSCR_TAR    __MASK(FSCR_TAR_LG)
+#define   HFSCR_EBB    __MASK(FSCR_EBB_LG)
+#define   HFSCR_TM     __MASK(FSCR_TM_LG)
+#define   HFSCR_PM     __MASK(FSCR_PM_LG)
+#define   HFSCR_BHRB   __MASK(FSCR_BHRB_LG)
+#define   HFSCR_DSCR   __MASK(FSCR_DSCR_LG)
+#define   HFSCR_VECVSX __MASK(FSCR_VECVSX_LG)
+#define   HFSCR_FP     __MASK(FSCR_FP_LG)
 #define SPRN_TAR       0x32f   /* Target Address Register */
 #define SPRN_LPCR      0x13E   /* LPAR Control Register */
 #define   LPCR_VPM0    (1ul << (63-0))
 #define PVR_970MP      0x0044
 #define PVR_970GX      0x0045
 #define PVR_POWER7p    0x004A
-#define PVR_POWER8     0x004B
+#define PVR_POWER8E    0x004B
+#define PVR_POWER8     0x004D
 #define PVR_BE         0x0070
 #define PVR_PA6T       0x0090
 
index ffbaabebcdca71eb1130ccaf12cfcf36c82501c4..48cfc858abd6dfa70c4c95172a5e4003fa62c53d 100644 (file)
@@ -145,6 +145,10 @@ extern void __cpu_die(unsigned int cpu);
 #define smp_setup_cpu_maps()
 static inline void inhibit_secondary_onlining(void) {}
 static inline void uninhibit_secondary_onlining(void) {}
+static inline const struct cpumask *cpu_sibling_mask(int cpu)
+{
+       return cpumask_of(cpu);
+}
 
 #endif /* CONFIG_SMP */
 
index 49a13e0ef2344fb83c6dd89ed4ab8fd179d34c01..294c2cedcf7a622b478b748a1c5c3ddb8f537674 100644 (file)
@@ -15,6 +15,15 @@ extern struct task_struct *__switch_to(struct task_struct *,
 struct thread_struct;
 extern struct task_struct *_switch(struct thread_struct *prev,
                                   struct thread_struct *next);
+#ifdef CONFIG_PPC_BOOK3S_64
+static inline void save_tar(struct thread_struct *prev)
+{
+       if (cpu_has_feature(CPU_FTR_ARCH_207S))
+               prev->tar = mfspr(SPRN_TAR);
+}
+#else
+static inline void save_tar(struct thread_struct *prev) {}
+#endif
 
 extern void giveup_fpu(struct task_struct *);
 extern void load_up_fpu(void);
index 5182c8622b54eea94ba18cfad7236872ae056865..48be855ef37b294cf034db138842cf56526ff4ea 100644 (file)
@@ -20,6 +20,7 @@ header-y += mman.h
 header-y += msgbuf.h
 header-y += nvram.h
 header-y += param.h
+header-y += perf_event.h
 header-y += poll.h
 header-y += posix_types.h
 header-y += ps3fb.h
diff --git a/arch/powerpc/include/uapi/asm/perf_event.h b/arch/powerpc/include/uapi/asm/perf_event.h
new file mode 100644 (file)
index 0000000..80a4d40
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2013 Michael Ellerman, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2 of the
+ * License.
+ */
+
+#ifndef _UAPI_ASM_POWERPC_PERF_EVENT_H
+#define _UAPI_ASM_POWERPC_PERF_EVENT_H
+
+/*
+ * We use bit 63 of perf_event_attr.config as a flag to request EBB.
+ */
+#define PERF_EVENT_CONFIG_EBB_SHIFT    63
+
+#endif /* _UAPI_ASM_POWERPC_PERF_EVENT_H */
index c7e8afc2ead0cde5d75b68244990092a0dea5bc3..8207459efe5619e4b9e2d824221104d111507e67 100644 (file)
@@ -138,6 +138,9 @@ int main(void)
        DEFINE(THREAD_TM_TFHAR, offsetof(struct thread_struct, tm_tfhar));
        DEFINE(THREAD_TM_TEXASR, offsetof(struct thread_struct, tm_texasr));
        DEFINE(THREAD_TM_TFIAR, offsetof(struct thread_struct, tm_tfiar));
+       DEFINE(THREAD_TM_TAR, offsetof(struct thread_struct, tm_tar));
+       DEFINE(THREAD_TM_PPR, offsetof(struct thread_struct, tm_ppr));
+       DEFINE(THREAD_TM_DSCR, offsetof(struct thread_struct, tm_dscr));
        DEFINE(PT_CKPT_REGS, offsetof(struct thread_struct, ckpt_regs));
        DEFINE(THREAD_TRANSACT_VR0, offsetof(struct thread_struct,
                                         transact_vr[0]));
index 2a45d0f043852a33cc41826c7835c59471b1ed60..22973a74df7342b1146a3dd2881432c3cd8ad2b8 100644 (file)
@@ -494,9 +494,27 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .cpu_restore            = __restore_cpu_power7,
                .platform               = "power7+",
        },
-       {       /* Power8 */
+       {       /* Power8E */
                .pvr_mask               = 0xffff0000,
                .pvr_value              = 0x004b0000,
+               .cpu_name               = "POWER8E (raw)",
+               .cpu_features           = CPU_FTRS_POWER8,
+               .cpu_user_features      = COMMON_USER_POWER8,
+               .cpu_user_features2     = COMMON_USER2_POWER8,
+               .mmu_features           = MMU_FTRS_POWER8,
+               .icache_bsize           = 128,
+               .dcache_bsize           = 128,
+               .num_pmcs               = 6,
+               .pmc_type               = PPC_PMC_IBM,
+               .oprofile_cpu_type      = "ppc64/power8",
+               .oprofile_type          = PPC_OPROFILE_INVALID,
+               .cpu_setup              = __setup_cpu_power8,
+               .cpu_restore            = __restore_cpu_power8,
+               .platform               = "power8",
+       },
+       {       /* Power8 */
+               .pvr_mask               = 0xffff0000,
+               .pvr_value              = 0x004d0000,
                .cpu_name               = "POWER8 (raw)",
                .cpu_features           = CPU_FTRS_POWER8,
                .cpu_user_features      = COMMON_USER_POWER8,
index 39954fe941b87e45a95951f9c39bb2beae6724db..55593ee2d5aacfee6ef9e86c5adfd4057c5cab10 100644 (file)
@@ -231,7 +231,7 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len)
 void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
 {
        size_t loglen = 0;
-       struct eeh_dev *edev;
+       struct eeh_dev *edev, *tmp;
        bool valid_cfg_log = true;
 
        /*
@@ -251,7 +251,7 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
                eeh_pe_restore_bars(pe);
 
                pci_regs_buf[0] = 0;
-               eeh_pe_for_each_dev(pe, edev) {
+               eeh_pe_for_each_dev(pe, edev, tmp) {
                        loglen += eeh_gather_pci_data(edev, pci_regs_buf + loglen,
                                                      EEH_PCI_REGS_LOG_LEN - loglen);
                }
@@ -499,8 +499,6 @@ unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned lon
        }
 
        eeh_dev_check_failure(edev);
-
-       pci_dev_put(eeh_dev_to_pci_dev(edev));
        return val;
 }
 
@@ -838,7 +836,7 @@ core_initcall_sync(eeh_init);
  * on the CEC architecture, type of the device, on earlier boot
  * command-line arguments & etc.
  */
-static void eeh_add_device_early(struct device_node *dn)
+void eeh_add_device_early(struct device_node *dn)
 {
        struct pci_controller *phb;
 
@@ -886,7 +884,7 @@ EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
  * This routine must be used to complete EEH initialization for PCI
  * devices that were added after system boot (e.g. hotplug, dlpar).
  */
-static void eeh_add_device_late(struct pci_dev *dev)
+void eeh_add_device_late(struct pci_dev *dev)
 {
        struct device_node *dn;
        struct eeh_dev *edev;
@@ -902,9 +900,23 @@ static void eeh_add_device_late(struct pci_dev *dev)
                pr_debug("EEH: Already referenced !\n");
                return;
        }
-       WARN_ON(edev->pdev);
 
-       pci_dev_get(dev);
+       /*
+        * The EEH cache might not be removed correctly because of
+        * unbalanced kref to the device during unplug time, which
+        * relies on pcibios_release_device(). So we have to remove
+        * that here explicitly.
+        */
+       if (edev->pdev) {
+               eeh_rmv_from_parent_pe(edev);
+               eeh_addr_cache_rmv_dev(edev->pdev);
+               eeh_sysfs_remove_device(edev->pdev);
+               edev->mode &= ~EEH_DEV_SYSFS;
+
+               edev->pdev = NULL;
+               dev->dev.archdata.edev = NULL;
+       }
+
        edev->pdev = dev;
        dev->dev.archdata.edev = edev;
 
@@ -967,7 +979,6 @@ EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
 /**
  * eeh_remove_device - Undo EEH setup for the indicated pci device
  * @dev: pci device to be removed
- * @purge_pe: remove the PE or not
  *
  * This routine should be called when a device is removed from
  * a running system (e.g. by hotplug or dlpar).  It unregisters
@@ -975,7 +986,7 @@ EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
  * this device will no longer be detected after this call; thus,
  * i/o errors affecting this slot may leave this device unusable.
  */
-static void eeh_remove_device(struct pci_dev *dev, int purge_pe)
+void eeh_remove_device(struct pci_dev *dev)
 {
        struct eeh_dev *edev;
 
@@ -986,42 +997,29 @@ static void eeh_remove_device(struct pci_dev *dev, int purge_pe)
        /* Unregister the device with the EEH/PCI address search system */
        pr_debug("EEH: Removing device %s\n", pci_name(dev));
 
-       if (!edev || !edev->pdev) {
+       if (!edev || !edev->pdev || !edev->pe) {
                pr_debug("EEH: Not referenced !\n");
                return;
        }
+
+       /*
+        * During the hotplug for EEH error recovery, we need the EEH
+        * device attached to the parent PE in order for BAR restore
+        * a bit later. So we keep it for BAR restore and remove it
+        * from the parent PE during the BAR resotre.
+        */
        edev->pdev = NULL;
        dev->dev.archdata.edev = NULL;
-       pci_dev_put(dev);
+       if (!(edev->pe->state & EEH_PE_KEEP))
+               eeh_rmv_from_parent_pe(edev);
+       else
+               edev->mode |= EEH_DEV_DISCONNECTED;
 
-       eeh_rmv_from_parent_pe(edev, purge_pe);
        eeh_addr_cache_rmv_dev(dev);
        eeh_sysfs_remove_device(dev);
+       edev->mode &= ~EEH_DEV_SYSFS;
 }
 
-/**
- * eeh_remove_bus_device - Undo EEH setup for the indicated PCI device
- * @dev: PCI device
- * @purge_pe: remove the corresponding PE or not
- *
- * This routine must be called when a device is removed from the
- * running system through hotplug or dlpar. The corresponding
- * PCI address cache will be removed.
- */
-void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe)
-{
-       struct pci_bus *bus = dev->subordinate;
-       struct pci_dev *child, *tmp;
-
-       eeh_remove_device(dev, purge_pe);
-
-       if (bus && dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
-               list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
-                        eeh_remove_bus_device(child, purge_pe);
-       }
-}
-EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
-
 static int proc_eeh_show(struct seq_file *m, void *v)
 {
        if (0 == eeh_subsystem_enabled) {
@@ -1063,7 +1061,7 @@ static const struct file_operations proc_eeh_operations = {
 
 static int __init eeh_init_proc(void)
 {
-       if (machine_is(pseries))
+       if (machine_is(pseries) || machine_is(powernv))
                proc_create("powerpc/eeh", 0, NULL, &proc_eeh_operations);
        return 0;
 }
index f9ac1232a746c595d696ef7b66469a093070c877..e8c9fd546a5c477b4c7755527ffb19dd64c04eca 100644 (file)
@@ -68,16 +68,12 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr)
                struct pci_io_addr_range *piar;
                piar = rb_entry(n, struct pci_io_addr_range, rb_node);
 
-               if (addr < piar->addr_lo) {
+               if (addr < piar->addr_lo)
                        n = n->rb_left;
-               } else {
-                       if (addr > piar->addr_hi) {
-                               n = n->rb_right;
-                       } else {
-                               pci_dev_get(piar->pcidev);
-                               return piar->edev;
-                       }
-               }
+               else if (addr > piar->addr_hi)
+                       n = n->rb_right;
+               else
+                       return piar->edev;
        }
 
        return NULL;
@@ -156,7 +152,6 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
        if (!piar)
                return NULL;
 
-       pci_dev_get(dev);
        piar->addr_lo = alo;
        piar->addr_hi = ahi;
        piar->edev = pci_dev_to_eeh_dev(dev);
@@ -250,7 +245,6 @@ restart:
 
                if (piar->pcidev == dev) {
                        rb_erase(n, &pci_io_addr_cache_root.rb_root);
-                       pci_dev_put(piar->pcidev);
                        kfree(piar);
                        goto restart;
                }
@@ -302,12 +296,10 @@ void eeh_addr_cache_build(void)
                if (!edev)
                        continue;
 
-               pci_dev_get(dev);  /* matching put is in eeh_remove_device() */
                dev->dev.archdata.edev = edev;
                edev->pdev = dev;
 
                eeh_addr_cache_insert_dev(dev);
-
                eeh_sysfs_add_device(dev);
        }
 
index 2b1ce17cae504d95a5be5e04e16828a5e3f7516e..36bed5a12750b639e2c305153585869be536ddef 100644 (file)
@@ -143,10 +143,14 @@ static void eeh_disable_irq(struct pci_dev *dev)
 static void eeh_enable_irq(struct pci_dev *dev)
 {
        struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
+       struct irq_desc *desc;
 
        if ((edev->mode) & EEH_DEV_IRQ_DISABLED) {
                edev->mode &= ~EEH_DEV_IRQ_DISABLED;
-               enable_irq(dev->irq);
+
+               desc = irq_to_desc(dev->irq);
+               if (desc && desc->depth > 0)
+                       enable_irq(dev->irq);
        }
 }
 
@@ -338,6 +342,54 @@ static void *eeh_report_failure(void *data, void *userdata)
        return NULL;
 }
 
+static void *eeh_rmv_device(void *data, void *userdata)
+{
+       struct pci_driver *driver;
+       struct eeh_dev *edev = (struct eeh_dev *)data;
+       struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
+       int *removed = (int *)userdata;
+
+       /*
+        * Actually, we should remove the PCI bridges as well.
+        * However, that's lots of complexity to do that,
+        * particularly some of devices under the bridge might
+        * support EEH. So we just care about PCI devices for
+        * simplicity here.
+        */
+       if (!dev || (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE))
+               return NULL;
+       driver = eeh_pcid_get(dev);
+       if (driver && driver->err_handler)
+               return NULL;
+
+       /* Remove it from PCI subsystem */
+       pr_debug("EEH: Removing %s without EEH sensitive driver\n",
+                pci_name(dev));
+       edev->bus = dev->bus;
+       edev->mode |= EEH_DEV_DISCONNECTED;
+       (*removed)++;
+
+       pci_stop_and_remove_bus_device(dev);
+
+       return NULL;
+}
+
+static void *eeh_pe_detach_dev(void *data, void *userdata)
+{
+       struct eeh_pe *pe = (struct eeh_pe *)data;
+       struct eeh_dev *edev, *tmp;
+
+       eeh_pe_for_each_dev(pe, edev, tmp) {
+               if (!(edev->mode & EEH_DEV_DISCONNECTED))
+                       continue;
+
+               edev->mode &= ~(EEH_DEV_DISCONNECTED | EEH_DEV_IRQ_DISABLED);
+               eeh_rmv_from_parent_pe(edev);
+       }
+
+       return NULL;
+}
+
 /**
  * eeh_reset_device - Perform actual reset of a pci slot
  * @pe: EEH PE
@@ -349,8 +401,9 @@ static void *eeh_report_failure(void *data, void *userdata)
  */
 static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
 {
+       struct pci_bus *frozen_bus = eeh_pe_bus_get(pe);
        struct timeval tstamp;
-       int cnt, rc;
+       int cnt, rc, removed = 0;
 
        /* pcibios will clear the counter; save the value */
        cnt = pe->freeze_count;
@@ -362,8 +415,11 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
         * devices are expected to be attached soon when calling
         * into pcibios_add_pci_devices().
         */
+       eeh_pe_state_mark(pe, EEH_PE_KEEP);
        if (bus)
-               __pcibios_remove_pci_devices(bus, 0);
+               pcibios_remove_pci_devices(bus);
+       else if (frozen_bus)
+               eeh_pe_dev_traverse(pe, eeh_rmv_device, &removed);
 
        /* Reset the pci controller. (Asserts RST#; resets config space).
         * Reconfigure bridges and devices. Don't try to bring the system
@@ -384,9 +440,24 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
         * potentially weird things happen.
         */
        if (bus) {
+               pr_info("EEH: Sleep 5s ahead of complete hotplug\n");
                ssleep(5);
+
+               /*
+                * The EEH device is still connected with its parent
+                * PE. We should disconnect it so the binding can be
+                * rebuilt when adding PCI devices.
+                */
+               eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
                pcibios_add_pci_devices(bus);
+       } else if (frozen_bus && removed) {
+               pr_info("EEH: Sleep 5s ahead of partial hotplug\n");
+               ssleep(5);
+
+               eeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);
+               pcibios_add_pci_devices(frozen_bus);
        }
+       eeh_pe_state_clear(pe, EEH_PE_KEEP);
 
        pe->tstamp = tstamp;
        pe->freeze_count = cnt;
index 016588a6f5ede19c9c45b0ab6a3bd44cfce962ae..f9450537e335a350354dec35ff5fdf15876ef0a6 100644 (file)
@@ -149,8 +149,8 @@ static struct eeh_pe *eeh_pe_next(struct eeh_pe *pe,
  * callback returns something other than NULL, or no more PEs
  * to be traversed.
  */
-static void *eeh_pe_traverse(struct eeh_pe *root,
-                       eeh_traverse_func fn, void *flag)
+void *eeh_pe_traverse(struct eeh_pe *root,
+                     eeh_traverse_func fn, void *flag)
 {
        struct eeh_pe *pe;
        void *ret;
@@ -176,7 +176,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
                eeh_traverse_func fn, void *flag)
 {
        struct eeh_pe *pe;
-       struct eeh_dev *edev;
+       struct eeh_dev *edev, *tmp;
        void *ret;
 
        if (!root) {
@@ -186,7 +186,7 @@ void *eeh_pe_dev_traverse(struct eeh_pe *root,
 
        /* Traverse root PE */
        for (pe = root; pe; pe = eeh_pe_next(pe, root)) {
-               eeh_pe_for_each_dev(pe, edev) {
+               eeh_pe_for_each_dev(pe, edev, tmp) {
                        ret = fn(edev, flag);
                        if (ret)
                                return ret;
@@ -333,7 +333,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
                while (parent) {
                        if (!(parent->type & EEH_PE_INVALID))
                                break;
-                       parent->type &= ~EEH_PE_INVALID;
+                       parent->type &= ~(EEH_PE_INVALID | EEH_PE_KEEP);
                        parent = parent->parent;
                }
                pr_debug("EEH: Add %s to Device PE#%x, Parent PE#%x\n",
@@ -397,21 +397,20 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
 /**
  * eeh_rmv_from_parent_pe - Remove one EEH device from the associated PE
  * @edev: EEH device
- * @purge_pe: remove PE or not
  *
  * The PE hierarchy tree might be changed when doing PCI hotplug.
  * Also, the PCI devices or buses could be removed from the system
  * during EEH recovery. So we have to call the function remove the
  * corresponding PE accordingly if necessary.
  */
-int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe)
+int eeh_rmv_from_parent_pe(struct eeh_dev *edev)
 {
        struct eeh_pe *pe, *parent, *child;
        int cnt;
 
        if (!edev->pe) {
-               pr_warning("%s: No PE found for EEH device %s\n",
-                       __func__, edev->dn->full_name);
+               pr_debug("%s: No PE found for EEH device %s\n",
+                        __func__, edev->dn->full_name);
                return -EEXIST;
        }
 
@@ -431,7 +430,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe)
                if (pe->type & EEH_PE_PHB)
                        break;
 
-               if (purge_pe) {
+               if (!(pe->state & EEH_PE_KEEP)) {
                        if (list_empty(&pe->edevs) &&
                            list_empty(&pe->child_list)) {
                                list_del(&pe->child);
@@ -502,7 +501,7 @@ static void *__eeh_pe_state_mark(void *data, void *flag)
 {
        struct eeh_pe *pe = (struct eeh_pe *)data;
        int state = *((int *)flag);
-       struct eeh_dev *tmp;
+       struct eeh_dev *edev, *tmp;
        struct pci_dev *pdev;
 
        /*
@@ -512,8 +511,8 @@ static void *__eeh_pe_state_mark(void *data, void *flag)
         * the PCI device driver.
         */
        pe->state |= state;
-       eeh_pe_for_each_dev(pe, tmp) {
-               pdev = eeh_dev_to_pci_dev(tmp);
+       eeh_pe_for_each_dev(pe, edev, tmp) {
+               pdev = eeh_dev_to_pci_dev(edev);
                if (pdev)
                        pdev->error_state = pci_channel_io_frozen;
        }
@@ -579,7 +578,7 @@ void eeh_pe_state_clear(struct eeh_pe *pe, int state)
  * blocked on normal path during the stage. So we need utilize
  * eeh operations, which is always permitted.
  */
-static void eeh_bridge_check_link(struct pci_dev *pdev,
+static void eeh_bridge_check_link(struct eeh_dev *edev,
                                  struct device_node *dn)
 {
        int cap;
@@ -590,16 +589,17 @@ static void eeh_bridge_check_link(struct pci_dev *pdev,
         * We only check root port and downstream ports of
         * PCIe switches
         */
-       if (!pci_is_pcie(pdev) ||
-           (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT &&
-            pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM))
+       if (!(edev->mode & (EEH_DEV_ROOT_PORT | EEH_DEV_DS_PORT)))
                return;
 
-       pr_debug("%s: Check PCIe link for %s ...\n",
-                __func__, pci_name(pdev));
+       pr_debug("%s: Check PCIe link for %04x:%02x:%02x.%01x ...\n",
+                __func__, edev->phb->global_number,
+                edev->config_addr >> 8,
+                PCI_SLOT(edev->config_addr & 0xFF),
+                PCI_FUNC(edev->config_addr & 0xFF));
 
        /* Check slot status */
-       cap = pdev->pcie_cap;
+       cap = edev->pcie_cap;
        eeh_ops->read_config(dn, cap + PCI_EXP_SLTSTA, 2, &val);
        if (!(val & PCI_EXP_SLTSTA_PDS)) {
                pr_debug("  No card in the slot (0x%04x) !\n", val);
@@ -653,8 +653,7 @@ static void eeh_bridge_check_link(struct pci_dev *pdev,
 #define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))
 #define SAVED_BYTE(OFF)        (((u8 *)(edev->config_space))[BYTE_SWAP(OFF)])
 
-static void eeh_restore_bridge_bars(struct pci_dev *pdev,
-                                   struct eeh_dev *edev,
+static void eeh_restore_bridge_bars(struct eeh_dev *edev,
                                    struct device_node *dn)
 {
        int i;
@@ -680,7 +679,7 @@ static void eeh_restore_bridge_bars(struct pci_dev *pdev,
        eeh_ops->write_config(dn, PCI_COMMAND, 4, edev->config_space[1]);
 
        /* Check the PCIe link is ready */
-       eeh_bridge_check_link(pdev, dn);
+       eeh_bridge_check_link(edev, dn);
 }
 
 static void eeh_restore_device_bars(struct eeh_dev *edev,
@@ -729,19 +728,12 @@ static void eeh_restore_device_bars(struct eeh_dev *edev,
  */
 static void *eeh_restore_one_device_bars(void *data, void *flag)
 {
-       struct pci_dev *pdev = NULL;
        struct eeh_dev *edev = (struct eeh_dev *)data;
        struct device_node *dn = eeh_dev_to_of_node(edev);
 
-       /* Trace the PCI bridge */
-       if (eeh_probe_mode_dev()) {
-               pdev = eeh_dev_to_pci_dev(edev);
-               if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE)
-                        pdev = NULL;
-        }
-
-       if (pdev)
-               eeh_restore_bridge_bars(pdev, edev, dn);
+       /* Do special restore for bridges */
+       if (edev->mode & EEH_DEV_BRIDGE)
+               eeh_restore_bridge_bars(edev, dn);
        else
                eeh_restore_device_bars(edev, dn);
 
index e7ae3484918c29639ff1a1baa597579a973fe6cd..5d753d4f2c75938e5fdd2c75b821ff98877cd2c9 100644 (file)
@@ -56,19 +56,40 @@ EEH_SHOW_ATTR(eeh_pe_config_addr,  pe_config_addr,  "0x%x");
 
 void eeh_sysfs_add_device(struct pci_dev *pdev)
 {
+       struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
        int rc=0;
 
+       if (edev && (edev->mode & EEH_DEV_SYSFS))
+               return;
+
        rc += device_create_file(&pdev->dev, &dev_attr_eeh_mode);
        rc += device_create_file(&pdev->dev, &dev_attr_eeh_config_addr);
        rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);
 
        if (rc)
                printk(KERN_WARNING "EEH: Unable to create sysfs entries\n");
+       else if (edev)
+               edev->mode |= EEH_DEV_SYSFS;
 }
 
 void eeh_sysfs_remove_device(struct pci_dev *pdev)
 {
+       struct eeh_dev *edev = pci_dev_to_eeh_dev(pdev);
+
+       /*
+        * The parent directory might have been removed. We needn't
+        * continue for that case.
+        */
+       if (!pdev->dev.kobj.sd) {
+               if (edev)
+                       edev->mode &= ~EEH_DEV_SYSFS;
+               return;
+       }
+
        device_remove_file(&pdev->dev, &dev_attr_eeh_mode);
        device_remove_file(&pdev->dev, &dev_attr_eeh_config_addr);
        device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);
+
+       if (edev)
+               edev->mode &= ~EEH_DEV_SYSFS;
 }
index ab15b8d057ad361f609b06277eb0a993574098cd..2bd0b885b0fe901328d9ae44f7703cca0a159676 100644 (file)
@@ -449,15 +449,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_DSCR)
 
 #ifdef CONFIG_PPC_BOOK3S_64
 BEGIN_FTR_SECTION
-       /*
-        * Back up the TAR across context switches.  Note that the TAR is not
-        * available for use in the kernel.  (To provide this, the TAR should
-        * be backed up/restored on exception entry/exit instead, and be in
-        * pt_regs.  FIXME, this should be in pt_regs anyway (for debug).)
-        */
-       mfspr   r0,SPRN_TAR
-       std     r0,THREAD_TAR(r3)
-
        /* Event based branch registers */
        mfspr   r0, SPRN_BESCR
        std     r0, THREAD_BESCR(r3)
@@ -584,9 +575,34 @@ BEGIN_FTR_SECTION
        ld      r7,DSCR_DEFAULT@toc(2)
        ld      r0,THREAD_DSCR(r4)
        cmpwi   r6,0
+       li      r8, FSCR_DSCR
        bne     1f
        ld      r0,0(r7)
-1:     cmpd    r0,r25
+       b       3f
+1:
+  BEGIN_FTR_SECTION_NESTED(70)
+       mfspr   r6, SPRN_FSCR
+       or      r6, r6, r8
+       mtspr   SPRN_FSCR, r6
+    BEGIN_FTR_SECTION_NESTED(69)
+       mfspr   r6, SPRN_HFSCR
+       or      r6, r6, r8
+       mtspr   SPRN_HFSCR, r6
+    END_FTR_SECTION_NESTED(CPU_FTR_HVMODE, CPU_FTR_HVMODE, 69)
+       b       4f
+  END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
+3:
+  BEGIN_FTR_SECTION_NESTED(70)
+       mfspr   r6, SPRN_FSCR
+       andc    r6, r6, r8
+       mtspr   SPRN_FSCR, r6
+    BEGIN_FTR_SECTION_NESTED(69)
+       mfspr   r6, SPRN_HFSCR
+       andc    r6, r6, r8
+       mtspr   SPRN_HFSCR, r6
+    END_FTR_SECTION_NESTED(CPU_FTR_HVMODE, CPU_FTR_HVMODE, 69)
+  END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
+4:     cmpd    r0,r25
        beq     2f
        mtspr   SPRN_DSCR,r0
 2:
index 4e00d223b2e30924dba5e82370d5bae09e7b56dc..902ca3c6b4b6496d8e606623187c9f1da1500f2a 100644 (file)
@@ -848,7 +848,7 @@ hv_facility_unavailable_relon_trampoline:
        . = 0x4f80
        SET_SCRATCH0(r13)
        EXCEPTION_PROLOG_0(PACA_EXGEN)
-       b       facility_unavailable_relon_hv
+       b       hv_facility_unavailable_relon_hv
 
        STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint)
 #ifdef CONFIG_PPC_DENORMALISATION
@@ -1175,6 +1175,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
        b       .ret_from_except
 
        STD_EXCEPTION_COMMON(0xf60, facility_unavailable, .facility_unavailable_exception)
+       STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, .facility_unavailable_exception)
 
        .align  7
        .globl  __end_handlers
@@ -1188,7 +1189,7 @@ __end_handlers:
        STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
        STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
        STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
-       STD_RELON_EXCEPTION_HV_OOL(0xf80, facility_unavailable)
+       STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
 
 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
 /*
index 2e51cde616d2de1fc93cdb75547debab72cf66c2..c69440cef7af43413987f3cd4b2c936cd0e8f788 100644 (file)
@@ -362,7 +362,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
                seq_printf(p, "%10u ", per_cpu(irq_stat, j).spurious_irqs);
        seq_printf(p, "  Spurious interrupts\n");
 
-       seq_printf(p, "%*s: ", prec, "CNT");
+       seq_printf(p, "%*s: ", prec, "PMI");
        for_each_online_cpu(j)
                seq_printf(p, "%10u ", per_cpu(irq_stat, j).pmu_irqs);
        seq_printf(p, "  Performance monitoring interrupts\n");
index f46914a0f33ea6fd3cacbdddb76288722dfb42cb..7d22a675fe1a3338d5f1a9d64eb44ce70d8f8f7b 100644 (file)
@@ -1462,6 +1462,8 @@ void pcibios_finish_adding_to_bus(struct pci_bus *bus)
        /* Allocate bus and devices resources */
        pcibios_allocate_bus_resources(bus);
        pcibios_claim_one_bus(bus);
+       if (!pci_has_flag(PCI_PROBE_ONLY))
+               pci_assign_unassigned_bus_resources(bus);
 
        /* Fixup EEH */
        eeh_add_device_tree_late(bus);
index 3f608800c06b59082116c3bcd642d26146b357c2..c1e17ae68a08047a0a60154aed49684d8b4aad2f 100644 (file)
 #include <asm/eeh.h>
 
 /**
- * __pcibios_remove_pci_devices - remove all devices under this bus
+ * pcibios_release_device - release PCI device
+ * @dev: PCI device
+ *
+ * The function is called before releasing the indicated PCI device.
+ */
+void pcibios_release_device(struct pci_dev *dev)
+{
+       eeh_remove_device(dev);
+}
+
+/**
+ * pcibios_remove_pci_devices - remove all devices under this bus
  * @bus: the indicated PCI bus
- * @purge_pe: destroy the PE on removal of PCI devices
  *
  * Remove all of the PCI devices under this bus both from the
  * linux pci device tree, and from the powerpc EEH address cache.
- * By default, the corresponding PE will be destroied during the
- * normal PCI hotplug path. For PCI hotplug during EEH recovery,
- * the corresponding PE won't be destroied and deallocated.
  */
-void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe)
+void pcibios_remove_pci_devices(struct pci_bus *bus)
 {
        struct pci_dev *dev, *tmp;
        struct pci_bus *child_bus;
 
        /* First go down child busses */
        list_for_each_entry(child_bus, &bus->children, node)
-               __pcibios_remove_pci_devices(child_bus, purge_pe);
+               pcibios_remove_pci_devices(child_bus);
 
        pr_debug("PCI: Removing devices on bus %04x:%02x\n",
                 pci_domain_nr(bus),  bus->number);
        list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
-               pr_debug("     * Removing %s...\n", pci_name(dev));
-               eeh_remove_bus_device(dev, purge_pe);
+               pr_debug("   Removing %s...\n", pci_name(dev));
                pci_stop_and_remove_bus_device(dev);
        }
 }
 
-/**
- * pcibios_remove_pci_devices - remove all devices under this bus
- * @bus: the indicated PCI bus
- *
- * Remove all of the PCI devices under this bus both from the
- * linux pci device tree, and from the powerpc EEH address cache.
- */
-void pcibios_remove_pci_devices(struct pci_bus *bus)
-{
-       __pcibios_remove_pci_devices(bus, 1);
-}
 EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices);
 
 /**
@@ -76,7 +71,7 @@ EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices);
  */
 void pcibios_add_pci_devices(struct pci_bus * bus)
 {
-       int slotno, num, mode, pass, max;
+       int slotno, mode, pass, max;
        struct pci_dev *dev;
        struct device_node *dn = pci_bus_to_OF_node(bus);
 
@@ -90,11 +85,15 @@ void pcibios_add_pci_devices(struct pci_bus * bus)
                /* use ofdt-based probe */
                of_rescan_bus(dn, bus);
        } else if (mode == PCI_PROBE_NORMAL) {
-               /* use legacy probe */
+               /*
+                * Use legacy probe. In the partial hotplug case, we
+                * probably have grandchildren devices unplugged. So
+                * we don't check the return value from pci_scan_slot() in
+                * order for fully rescan all the way down to pick them up.
+                * They can have been removed during partial hotplug.
+                */
                slotno = PCI_SLOT(PCI_DN(dn->child)->devfn);
-               num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
-               if (!num)
-                       return;
+               pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
                pcibios_setup_bus_devices(bus);
                max = bus->busn_res.start;
                for (pass = 0; pass < 2; pass++) {
index 6b0ba5854d9960aff03bbd01b810543c9e369588..15d9105323bf5048009428c4bfc83d06edffb38f 100644 (file)
@@ -230,11 +230,14 @@ void of_scan_pci_bridge(struct pci_dev *dev)
                return;
        }
 
-       bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
+       bus = pci_find_bus(pci_domain_nr(dev->bus), busrange[0]);
        if (!bus) {
-               printk(KERN_ERR "Failed to create pci bus for %s\n",
-                      node->full_name);
-               return;
+               bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
+               if (!bus) {
+                       printk(KERN_ERR "Failed to create pci bus for %s\n",
+                              node->full_name);
+                       return;
+               }
        }
 
        bus->primary = dev->bus->number;
@@ -292,6 +295,38 @@ void of_scan_pci_bridge(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(of_scan_pci_bridge);
 
+static struct pci_dev *of_scan_pci_dev(struct pci_bus *bus,
+                           struct device_node *dn)
+{
+       struct pci_dev *dev = NULL;
+       const u32 *reg;
+       int reglen, devfn;
+
+       pr_debug("  * %s\n", dn->full_name);
+       if (!of_device_is_available(dn))
+               return NULL;
+
+       reg = of_get_property(dn, "reg", &reglen);
+       if (reg == NULL || reglen < 20)
+               return NULL;
+       devfn = (reg[0] >> 8) & 0xff;
+
+       /* Check if the PCI device is already there */
+       dev = pci_get_slot(bus, devfn);
+       if (dev) {
+               pci_dev_put(dev);
+               return dev;
+       }
+
+       /* create a new pci_dev for this device */
+       dev = of_create_pci_dev(dn, bus, devfn);
+       if (!dev)
+               return NULL;
+
+       pr_debug("  dev header type: %x\n", dev->hdr_type);
+       return dev;
+}
+
 /**
  * __of_scan_bus - given a PCI bus node, setup bus and scan for child devices
  * @node: device tree node for the PCI bus
@@ -302,8 +337,6 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus,
                          int rescan_existing)
 {
        struct device_node *child;
-       const u32 *reg;
-       int reglen, devfn;
        struct pci_dev *dev;
 
        pr_debug("of_scan_bus(%s) bus no %d...\n",
@@ -311,16 +344,7 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus,
 
        /* Scan direct children */
        for_each_child_of_node(node, child) {
-               pr_debug("  * %s\n", child->full_name);
-               if (!of_device_is_available(child))
-                       continue;
-               reg = of_get_property(child, "reg", &reglen);
-               if (reg == NULL || reglen < 20)
-                       continue;
-               devfn = (reg[0] >> 8) & 0xff;
-
-               /* create a new pci_dev for this device */
-               dev = of_create_pci_dev(child, bus, devfn);
+               dev = of_scan_pci_dev(bus, child);
                if (!dev)
                        continue;
                pr_debug("    dev header type: %x\n", dev->hdr_type);
index c517dbe705fdd5fd5944ae693c04aaaf52510e85..8083be20fe5ec2c6608ab979f988cc0d31eb6862 100644 (file)
@@ -600,6 +600,16 @@ struct task_struct *__switch_to(struct task_struct *prev,
        struct ppc64_tlb_batch *batch;
 #endif
 
+       /* Back up the TAR across context switches.
+        * Note that the TAR is not available for use in the kernel.  (To
+        * provide this, the TAR should be backed up/restored on exception
+        * entry/exit instead, and be in pt_regs.  FIXME, this should be in
+        * pt_regs anyway (for debug).)
+        * Save the TAR here before we do treclaim/trecheckpoint as these
+        * will change the TAR.
+        */
+       save_tar(&prev->thread);
+
        __switch_to_tm(prev);
 
 #ifdef CONFIG_SMP
index 5eccda9fd33f5396b5a5c231db1c8051bcacf747..607902424e7377046943a14f7a8aeb56471327e4 100644 (file)
@@ -644,7 +644,8 @@ unsigned char ibm_architecture_vec[] = {
        W(0xfffe0000), W(0x003a0000),   /* POWER5/POWER5+ */
        W(0xffff0000), W(0x003e0000),   /* POWER6 */
        W(0xffff0000), W(0x003f0000),   /* POWER7 */
-       W(0xffff0000), W(0x004b0000),   /* POWER8 */
+       W(0xffff0000), W(0x004b0000),   /* POWER8E */
+       W(0xffff0000), W(0x004d0000),   /* POWER8 */
        W(0xffffffff), W(0x0f000004),   /* all 2.07-compliant */
        W(0xffffffff), W(0x0f000003),   /* all 2.06-compliant */
        W(0xffffffff), W(0x0f000002),   /* all 2.05-compliant */
@@ -706,7 +707,7 @@ unsigned char ibm_architecture_vec[] = {
         * must match by the macro below. Update the definition if
         * the structure layout changes.
         */
-#define IBM_ARCH_VEC_NRCORES_OFFSET    117
+#define IBM_ARCH_VEC_NRCORES_OFFSET    125
        W(NR_CPUS),                     /* number of cores supported */
        0,
        0,
index 51be8fb2480313610b5971b6ef70a89f58f794a2..0554d1f6d70dae8eeb964806ccd869b9e2a5e89f 100644 (file)
@@ -233,6 +233,16 @@ dont_backup_fp:
        std     r5, _CCR(r7)
        std     r6, _XER(r7)
 
+
+       /* ******************** TAR, PPR, DSCR ********** */
+       mfspr   r3, SPRN_TAR
+       mfspr   r4, SPRN_PPR
+       mfspr   r5, SPRN_DSCR
+
+       std     r3, THREAD_TM_TAR(r12)
+       std     r4, THREAD_TM_PPR(r12)
+       std     r5, THREAD_TM_DSCR(r12)
+
        /* MSR and flags:  We don't change CRs, and we don't need to alter
         * MSR.
         */
@@ -347,6 +357,16 @@ dont_restore_fp:
        mtmsr   r6                              /* FP/Vec off again! */
 
 restore_gprs:
+
+       /* ******************** TAR, PPR, DSCR ********** */
+       ld      r4, THREAD_TM_TAR(r3)
+       ld      r5, THREAD_TM_PPR(r3)
+       ld      r6, THREAD_TM_DSCR(r3)
+
+       mtspr   SPRN_TAR,       r4
+       mtspr   SPRN_PPR,       r5
+       mtspr   SPRN_DSCR,      r6
+
        /* ******************** CR,LR,CCR,MSR ********** */
        ld      r3, _CTR(r7)
        ld      r4, _LINK(r7)
index bf33c22e38a40848221762497ca1a7b704a27f9f..e435bc089ea3ccccb98d0acbc490071e9d75bb18 100644 (file)
@@ -44,9 +44,7 @@
 #include <asm/machdep.h>
 #include <asm/rtas.h>
 #include <asm/pmc.h>
-#ifdef CONFIG_PPC32
 #include <asm/reg.h>
-#endif
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
 #endif
@@ -1296,43 +1294,54 @@ void vsx_unavailable_exception(struct pt_regs *regs)
        die("Unrecoverable VSX Unavailable Exception", regs, SIGABRT);
 }
 
+#ifdef CONFIG_PPC64
 void facility_unavailable_exception(struct pt_regs *regs)
 {
        static char *facility_strings[] = {
-               "FPU",
-               "VMX/VSX",
-               "DSCR",
-               "PMU SPRs",
-               "BHRB",
-               "TM",
-               "AT",
-               "EBB",
-               "TAR",
+               [FSCR_FP_LG] = "FPU",
+               [FSCR_VECVSX_LG] = "VMX/VSX",
+               [FSCR_DSCR_LG] = "DSCR",
+               [FSCR_PM_LG] = "PMU SPRs",
+               [FSCR_BHRB_LG] = "BHRB",
+               [FSCR_TM_LG] = "TM",
+               [FSCR_EBB_LG] = "EBB",
+               [FSCR_TAR_LG] = "TAR",
        };
-       char *facility, *prefix;
+       char *facility = "unknown";
        u64 value;
+       u8 status;
+       bool hv;
 
-       if (regs->trap == 0xf60) {
-               value = mfspr(SPRN_FSCR);
-               prefix = "";
-       } else {
+       hv = (regs->trap == 0xf80);
+       if (hv)
                value = mfspr(SPRN_HFSCR);
-               prefix = "Hypervisor ";
+       else
+               value = mfspr(SPRN_FSCR);
+
+       status = value >> 56;
+       if (status == FSCR_DSCR_LG) {
+               /* User is acessing the DSCR.  Set the inherit bit and allow
+                * the user to set it directly in future by setting via the
+                * H/FSCR DSCR bit.
+                */
+               current->thread.dscr_inherit = 1;
+               if (hv)
+                       mtspr(SPRN_HFSCR, value | HFSCR_DSCR);
+               else
+                       mtspr(SPRN_FSCR,  value | FSCR_DSCR);
+               return;
        }
 
-       value = value >> 56;
+       if ((status < ARRAY_SIZE(facility_strings)) &&
+           facility_strings[status])
+               facility = facility_strings[status];
 
        /* We restore the interrupt state now */
        if (!arch_irq_disabled_regs(regs))
                local_irq_enable();
 
-       if (value < ARRAY_SIZE(facility_strings))
-               facility = facility_strings[value];
-       else
-               facility = "unknown";
-
        pr_err("%sFacility '%s' unavailable, exception at 0x%lx, MSR=%lx\n",
-               prefix, facility, regs->nip, regs->msr);
+              hv ? "Hypervisor " : "", facility, regs->nip, regs->msr);
 
        if (user_mode(regs)) {
                _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
@@ -1341,6 +1350,7 @@ void facility_unavailable_exception(struct pt_regs *regs)
 
        die("Unexpected facility unavailable exception", regs, SIGABRT);
 }
+#endif
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 
index 654e479802f2098afb74c0fea0bb0b68e25707f5..f096e72262f41d121398f8fa27d5286bd8641bf4 100644 (file)
@@ -38,9 +38,6 @@ jiffies = jiffies_64 + 4;
 #endif
 SECTIONS
 {
-       . = 0;
-       reloc_start = .;
-
        . = KERNELBASE;
 
 /*
index 2efa9dde741a1aad3ed206481e9c272a94eb7cdf..7629cd3eb91ad69e9460204a7f7c2e8d081a1084 100644 (file)
@@ -1809,7 +1809,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
                rma_size <<= PAGE_SHIFT;
                rmls = lpcr_rmls(rma_size);
                err = -EINVAL;
-               if (rmls < 0) {
+               if ((long)rmls < 0) {
                        pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size);
                        goto out_srcu;
                }
@@ -1874,7 +1874,7 @@ int kvmppc_core_init_vm(struct kvm *kvm)
        /* Allocate the guest's logical partition ID */
 
        lpid = kvmppc_alloc_lpid();
-       if (lpid < 0)
+       if ((long)lpid < 0)
                return -ENOMEM;
        kvm->arch.lpid = lpid;
 
index 19498a567a81f25c67c7f1b3f010182fcb680e2b..c6e13d9a9e15b0be5f2b75a1151c7eea4b93b8e5 100644 (file)
@@ -1047,11 +1047,12 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
        if (err)
                goto free_shadow_vcpu;
 
+       err = -ENOMEM;
        p = __get_free_page(GFP_KERNEL|__GFP_ZERO);
-       /* the real shared page fills the last 4k of our page */
-       vcpu->arch.shared = (void*)(p + PAGE_SIZE - 4096);
        if (!p)
                goto uninit_vcpu;
+       /* the real shared page fills the last 4k of our page */
+       vcpu->arch.shared = (void *)(p + PAGE_SIZE - 4096);
 
 #ifdef CONFIG_PPC_BOOK3S_64
        /* default to book3s_64 (970fx) */
index 3f0c30ae4791db7597c3fac74740e09e0fb3b7c1..c33d939120c970f3f800b42b5dfa3739e28ac16f 100644 (file)
@@ -43,6 +43,7 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
 {
        unsigned long va;
        unsigned int penc;
+       unsigned long sllp;
 
        /*
         * We need 14 to 65 bits of va for a tlibe of 4K page
@@ -64,7 +65,9 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
                /* clear out bits after (52) [0....52.....63] */
                va &= ~((1ul << (64 - 52)) - 1);
                va |= ssize << 8;
-               va |= mmu_psize_defs[apsize].sllp << 6;
+               sllp = ((mmu_psize_defs[apsize].sllp & SLB_VSID_L) >> 6) |
+                       ((mmu_psize_defs[apsize].sllp & SLB_VSID_LP) >> 4);
+               va |= sllp << 5;
                asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2)
                             : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
                             : "memory");
@@ -98,6 +101,7 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
 {
        unsigned long va;
        unsigned int penc;
+       unsigned long sllp;
 
        /* VPN_SHIFT can be atmost 12 */
        va = vpn << VPN_SHIFT;
@@ -113,7 +117,9 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
                /* clear out bits after(52) [0....52.....63] */
                va &= ~((1ul << (64 - 52)) - 1);
                va |= ssize << 8;
-               va |= mmu_psize_defs[apsize].sllp << 6;
+               sllp = ((mmu_psize_defs[apsize].sllp & SLB_VSID_L) >> 6) |
+                       ((mmu_psize_defs[apsize].sllp & SLB_VSID_LP) >> 4);
+               va |= sllp << 5;
                asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)"
                             : : "r"(va) : "memory");
                break;
@@ -554,6 +560,7 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
                        seg_off |= vpi << shift;
                }
                *vpn = vsid << (SID_SHIFT - VPN_SHIFT) | seg_off >> VPN_SHIFT;
+               break;
        case MMU_SEGSIZE_1T:
                /* We only have 40 - 23 bits of seg_off in avpn */
                seg_off = (avpn & 0x1ffff) << 23;
@@ -563,6 +570,7 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
                        seg_off |= vpi << shift;
                }
                *vpn = vsid << (SID_SHIFT_1T - VPN_SHIFT) | seg_off >> VPN_SHIFT;
+               break;
        default:
                *vpn = size = 0;
        }
index 08397217e8ace2d6ce3abc1a09a4fcc14977413f..5850798826cde0be9570368cb7968a9ea279b1e1 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/seq_file.h>
 #include <linux/uaccess.h>
 #include <linux/slab.h>
+#include <asm/cputhreads.h>
 #include <asm/sparsemem.h>
 #include <asm/prom.h>
 #include <asm/smp.h>
@@ -1318,7 +1319,8 @@ static int update_cpu_associativity_changes_mask(void)
                        }
                }
                if (changed) {
-                       cpumask_set_cpu(cpu, changes);
+                       cpumask_or(changes, changes, cpu_sibling_mask(cpu));
+                       cpu = cpu_last_thread_sibling(cpu);
                }
        }
 
@@ -1426,7 +1428,7 @@ static int update_cpu_topology(void *data)
        if (!data)
                return -EINVAL;
 
-       cpu = get_cpu();
+       cpu = smp_processor_id();
 
        for (update = data; update; update = update->next) {
                if (cpu != update->cpu)
@@ -1446,12 +1448,12 @@ static int update_cpu_topology(void *data)
  */
 int arch_update_cpu_topology(void)
 {
-       unsigned int cpu, changed = 0;
+       unsigned int cpu, sibling, changed = 0;
        struct topology_update_data *updates, *ud;
        unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0};
        cpumask_t updated_cpus;
        struct device *dev;
-       int weight, i = 0;
+       int weight, new_nid, i = 0;
 
        weight = cpumask_weight(&cpu_associativity_changes_mask);
        if (!weight)
@@ -1464,19 +1466,46 @@ int arch_update_cpu_topology(void)
        cpumask_clear(&updated_cpus);
 
        for_each_cpu(cpu, &cpu_associativity_changes_mask) {
-               ud = &updates[i++];
-               ud->cpu = cpu;
-               vphn_get_associativity(cpu, associativity);
-               ud->new_nid = associativity_to_nid(associativity);
-
-               if (ud->new_nid < 0 || !node_online(ud->new_nid))
-                       ud->new_nid = first_online_node;
+               /*
+                * If siblings aren't flagged for changes, updates list
+                * will be too short. Skip on this update and set for next
+                * update.
+                */
+               if (!cpumask_subset(cpu_sibling_mask(cpu),
+                                       &cpu_associativity_changes_mask)) {
+                       pr_info("Sibling bits not set for associativity "
+                                       "change, cpu%d\n", cpu);
+                       cpumask_or(&cpu_associativity_changes_mask,
+                                       &cpu_associativity_changes_mask,
+                                       cpu_sibling_mask(cpu));
+                       cpu = cpu_last_thread_sibling(cpu);
+                       continue;
+               }
 
-               ud->old_nid = numa_cpu_lookup_table[cpu];
-               cpumask_set_cpu(cpu, &updated_cpus);
+               /* Use associativity from first thread for all siblings */
+               vphn_get_associativity(cpu, associativity);
+               new_nid = associativity_to_nid(associativity);
+               if (new_nid < 0 || !node_online(new_nid))
+                       new_nid = first_online_node;
+
+               if (new_nid == numa_cpu_lookup_table[cpu]) {
+                       cpumask_andnot(&cpu_associativity_changes_mask,
+                                       &cpu_associativity_changes_mask,
+                                       cpu_sibling_mask(cpu));
+                       cpu = cpu_last_thread_sibling(cpu);
+                       continue;
+               }
 
-               if (i < weight)
-                       ud->next = &updates[i];
+               for_each_cpu(sibling, cpu_sibling_mask(cpu)) {
+                       ud = &updates[i++];
+                       ud->cpu = sibling;
+                       ud->new_nid = new_nid;
+                       ud->old_nid = numa_cpu_lookup_table[sibling];
+                       cpumask_set_cpu(sibling, &updated_cpus);
+                       if (i < weight)
+                               ud->next = &updates[i];
+               }
+               cpu = cpu_last_thread_sibling(cpu);
        }
 
        stop_machine(update_cpu_topology, &updates[0], &updated_cpus);
index a3985aee77fec1ecd2fe9756257e3a46b9643b94..eeae308cf98253888a1af8792dd150e4410b08ef 100644 (file)
@@ -484,7 +484,7 @@ static bool is_ebb_event(struct perf_event *event)
         * use bit 63 of the event code for something else if they wish.
         */
        return (ppmu->flags & PPMU_EBB) &&
-              ((event->attr.config >> EVENT_CONFIG_EBB_SHIFT) & 1);
+              ((event->attr.config >> PERF_EVENT_CONFIG_EBB_SHIFT) & 1);
 }
 
 static int ebb_event_check(struct perf_event *event)
@@ -1252,8 +1252,11 @@ nocheck:
 
        ret = 0;
  out:
-       if (has_branch_stack(event))
+       if (has_branch_stack(event)) {
                power_pmu_bhrb_enable(event);
+               cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
+                                       event->attr.branch_sample_type);
+       }
 
        perf_pmu_enable(event->pmu);
        local_irq_restore(flags);
index 96a64d6a8bdf3dfbba1c5a57f16bcb38d3c8a7ce..2ee4a707f0df85c37dba15c6ab5f4e7f84e553fc 100644 (file)
         (EVENT_UNIT_MASK      << EVENT_UNIT_SHIFT)             |       \
         (EVENT_COMBINE_MASK   << EVENT_COMBINE_SHIFT)          |       \
         (EVENT_MARKED_MASK    << EVENT_MARKED_SHIFT)           |       \
-        (EVENT_EBB_MASK       << EVENT_CONFIG_EBB_SHIFT)       |       \
+        (EVENT_EBB_MASK       << PERF_EVENT_CONFIG_EBB_SHIFT)  |       \
          EVENT_PSEL_MASK)
 
 /* MMCRA IFM bits - POWER8 */
@@ -233,10 +233,10 @@ static int power8_get_constraint(u64 event, unsigned long *maskp, unsigned long
        pmc   = (event >> EVENT_PMC_SHIFT)        & EVENT_PMC_MASK;
        unit  = (event >> EVENT_UNIT_SHIFT)       & EVENT_UNIT_MASK;
        cache = (event >> EVENT_CACHE_SEL_SHIFT)  & EVENT_CACHE_SEL_MASK;
-       ebb   = (event >> EVENT_CONFIG_EBB_SHIFT) & EVENT_EBB_MASK;
+       ebb   = (event >> PERF_EVENT_CONFIG_EBB_SHIFT) & EVENT_EBB_MASK;
 
        /* Clear the EBB bit in the event, so event checks work below */
-       event &= ~(EVENT_EBB_MASK << EVENT_CONFIG_EBB_SHIFT);
+       event &= ~(EVENT_EBB_MASK << PERF_EVENT_CONFIG_EBB_SHIFT);
 
        if (pmc) {
                if (pmc > 6)
@@ -561,18 +561,13 @@ static int power8_generic_events[] = {
 static u64 power8_bhrb_filter_map(u64 branch_sample_type)
 {
        u64 pmu_bhrb_filter = 0;
-       u64 br_privilege = branch_sample_type & ONLY_PLM;
 
-       /* BHRB and regular PMU events share the same prvillege state
+       /* BHRB and regular PMU events share the same privilege state
         * filter configuration. BHRB is always recorded along with a
-        * regular PMU event. So privilege state filter criteria for BHRB
-        * and the companion PMU events has to be the same. As a default
-        * "perf record" tool sets all privillege bits ON when no filter
-        * criteria is provided in the command line. So as along as all
-        * privillege bits are ON or they are OFF, we are good to go.
+        * regular PMU event. As the privilege state filter is handled
+        * in the basic PMC configuration of the accompanying regular
+        * PMU event, we ignore any separate BHRB specific request.
         */
-       if ((br_privilege != 7) && (br_privilege != 0))
-               return -1;
 
        /* No branch filter requested */
        if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY)
@@ -621,10 +616,19 @@ static struct power_pmu power8_pmu = {
 
 static int __init init_power8_pmu(void)
 {
+       int rc;
+
        if (!cur_cpu_spec->oprofile_cpu_type ||
            strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power8"))
                return -ENODEV;
 
-       return register_power_pmu(&power8_pmu);
+       rc = register_power_pmu(&power8_pmu);
+       if (rc)
+               return rc;
+
+       /* Tell userspace that EBB is supported */
+       cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_EBB;
+
+       return 0;
 }
 early_initcall(init_power8_pmu);
index 969cce73055af337f3b15c9c12df27dc3aebb4ed..79663d26e6eaa1de8749c6994316737f991106ab 100644 (file)
@@ -114,7 +114,7 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
         * the root bridge. So it's not reasonable to continue
         * the probing.
         */
-       if (!dn || !edev)
+       if (!dn || !edev || edev->pe)
                return 0;
 
        /* Skip for PCI-ISA bridge */
@@ -122,8 +122,19 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
                return 0;
 
        /* Initialize eeh device */
-       edev->class_code        = dev->class;
-       edev->mode              = 0;
+       edev->class_code = dev->class;
+       edev->mode      &= 0xFFFFFF00;
+       if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
+               edev->mode |= EEH_DEV_BRIDGE;
+       if (pci_is_pcie(dev)) {
+               edev->pcie_cap = pci_pcie_cap(dev);
+
+               if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
+                       edev->mode |= EEH_DEV_ROOT_PORT;
+               else if (pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM)
+                       edev->mode |= EEH_DEV_DS_PORT;
+       }
+
        edev->config_addr       = ((dev->bus->number << 8) | dev->devfn);
        edev->pe_config_addr    = phb->bdfn_to_pe(phb, dev->bus, dev->devfn & 0xff);
 
index 49b57b9f835d787977817db8f093d40c354ac7d5..d8140b125e62508720388d683a5028199d62ff28 100644 (file)
@@ -1266,7 +1266,7 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
                opal_pci_set_pe(phb_id, 0, 0, 7, 1, 1 , OPAL_MAP_PE);
 }
 
-void pnv_pci_init_ioda2_phb(struct device_node *np)
+void __init pnv_pci_init_ioda2_phb(struct device_node *np)
 {
        pnv_pci_init_ioda_phb(np, 0, PNV_PHB_IODA2);
 }
index 1bd3399146ed6f945f24308ea95883bffdce8d28..62b4f8025de005ad77bdbfcd42024d25614eb79c 100644 (file)
@@ -19,7 +19,6 @@ config PPC_PSERIES
        select ZLIB_DEFLATE
        select PPC_DOORBELL
        select HAVE_CONTEXT_TRACKING
-       select HOTPLUG if SMP
        select HOTPLUG_CPU if SMP
        default y
 
index b456b157d33d107842a42d3b0c3d0da36e9ea121..7fbc25b1813fe59ea80eceba65cb2a76027c0eec 100644 (file)
@@ -133,6 +133,48 @@ static int pseries_eeh_init(void)
        return 0;
 }
 
+static int pseries_eeh_cap_start(struct device_node *dn)
+{
+       struct pci_dn *pdn = PCI_DN(dn);
+       u32 status;
+
+       if (!pdn)
+               return 0;
+
+       rtas_read_config(pdn, PCI_STATUS, 2, &status);
+       if (!(status & PCI_STATUS_CAP_LIST))
+               return 0;
+
+       return PCI_CAPABILITY_LIST;
+}
+
+
+static int pseries_eeh_find_cap(struct device_node *dn, int cap)
+{
+       struct pci_dn *pdn = PCI_DN(dn);
+       int pos = pseries_eeh_cap_start(dn);
+       int cnt = 48;   /* Maximal number of capabilities */
+       u32 id;
+
+       if (!pos)
+               return 0;
+
+        while (cnt--) {
+               rtas_read_config(pdn, pos, 1, &pos);
+               if (pos < 0x40)
+                       break;
+               pos &= ~3;
+               rtas_read_config(pdn, pos + PCI_CAP_LIST_ID, 1, &id);
+               if (id == 0xff)
+                       break;
+               if (id == cap)
+                       return pos;
+               pos += PCI_CAP_LIST_NEXT;
+       }
+
+       return 0;
+}
+
 /**
  * pseries_eeh_of_probe - EEH probe on the given device
  * @dn: OF node
@@ -146,14 +188,16 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag)
 {
        struct eeh_dev *edev;
        struct eeh_pe pe;
+       struct pci_dn *pdn = PCI_DN(dn);
        const u32 *class_code, *vendor_id, *device_id;
        const u32 *regs;
+       u32 pcie_flags;
        int enable = 0;
        int ret;
 
        /* Retrieve OF node and eeh device */
        edev = of_node_to_eeh_dev(dn);
-       if (!of_device_is_available(dn))
+       if (edev->pe || !of_device_is_available(dn))
                return NULL;
 
        /* Retrieve class/vendor/device IDs */
@@ -167,9 +211,26 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag)
        if (dn->type && !strcmp(dn->type, "isa"))
                return NULL;
 
-       /* Update class code and mode of eeh device */
+       /*
+        * Update class code and mode of eeh device. We need
+        * correctly reflects that current device is root port
+        * or PCIe switch downstream port.
+        */
        edev->class_code = *class_code;
-       edev->mode = 0;
+       edev->pcie_cap = pseries_eeh_find_cap(dn, PCI_CAP_ID_EXP);
+       edev->mode &= 0xFFFFFF00;
+       if ((edev->class_code >> 8) == PCI_CLASS_BRIDGE_PCI) {
+               edev->mode |= EEH_DEV_BRIDGE;
+               if (edev->pcie_cap) {
+                       rtas_read_config(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
+                                        2, &pcie_flags);
+                       pcie_flags = (pcie_flags & PCI_EXP_FLAGS_TYPE) >> 4;
+                       if (pcie_flags == PCI_EXP_TYPE_ROOT_PORT)
+                               edev->mode |= EEH_DEV_ROOT_PORT;
+                       else if (pcie_flags == PCI_EXP_TYPE_DOWNSTREAM)
+                               edev->mode |= EEH_DEV_DS_PORT;
+               }
+       }
 
        /* Retrieve the device address */
        regs = of_get_property(dn, "reg", NULL);
index 02d6e21619bb6c677771c0dc6ecaabb5e1d417d5..8bad880bd177a2efaf9887b0509593401112aee4 100644 (file)
@@ -146,7 +146,7 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
        flags = 0;
 
        /* Make pHyp happy */
-       if ((rflags & _PAGE_NO_CACHE) & !(rflags & _PAGE_WRITETHRU))
+       if ((rflags & _PAGE_NO_CACHE) && !(rflags & _PAGE_WRITETHRU))
                hpte_r &= ~_PAGE_COHERENT;
        if (firmware_has_feature(FW_FEATURE_XCMO) && !(hpte_r & HPTE_R_N))
                flags |= H_COALESCE_CAND;
index 9f8671a44551481b25a8c5b1404dd152c9f6df02..6a5f2b1f32ca167d3ec6b39b0dfd69067d6b37d2 100644 (file)
@@ -569,35 +569,6 @@ error:
        return ret;
 }
 
-static int unzip_oops(char *oops_buf, char *big_buf)
-{
-       struct oops_log_info *oops_hdr = (struct oops_log_info *)oops_buf;
-       u64 timestamp = oops_hdr->timestamp;
-       char *big_oops_data = NULL;
-       char *oops_data_buf = NULL;
-       size_t big_oops_data_sz;
-       int unzipped_len;
-
-       big_oops_data = big_buf + sizeof(struct oops_log_info);
-       big_oops_data_sz = big_oops_buf_sz - sizeof(struct oops_log_info);
-       oops_data_buf = oops_buf + sizeof(struct oops_log_info);
-
-       unzipped_len = nvram_decompress(oops_data_buf, big_oops_data,
-                                       oops_hdr->report_length,
-                                       big_oops_data_sz);
-
-       if (unzipped_len < 0) {
-               pr_err("nvram: decompression failed; returned %d\n",
-                                                               unzipped_len);
-               return -1;
-       }
-       oops_hdr = (struct oops_log_info *)big_buf;
-       oops_hdr->version = OOPS_HDR_VERSION;
-       oops_hdr->report_length = (u16) unzipped_len;
-       oops_hdr->timestamp = timestamp;
-       return 0;
-}
-
 static int nvram_pstore_open(struct pstore_info *psi)
 {
        /* Reset the iterator to start reading partitions again */
@@ -685,10 +656,9 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
        unsigned int err_type, id_no, size = 0;
        struct nvram_os_partition *part = NULL;
        char *buff = NULL, *big_buff = NULL;
-       int rc, sig = 0;
+       int sig = 0;
        loff_t p;
 
-read_partition:
        read_type++;
 
        switch (nvram_type_ids[read_type]) {
@@ -749,30 +719,46 @@ read_partition:
                *id = id_no;
 
        if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) {
+               int length, unzipped_len;
+               size_t hdr_size;
+
                oops_hdr = (struct oops_log_info *)buff;
-               *buf = buff + sizeof(*oops_hdr);
+               if (oops_hdr->version < OOPS_HDR_VERSION) {
+                       /* Old format oops header had 2-byte record size */
+                       hdr_size = sizeof(u16);
+                       length = oops_hdr->version;
+                       time->tv_sec = 0;
+                       time->tv_nsec = 0;
+               } else {
+                       hdr_size = sizeof(*oops_hdr);
+                       length = oops_hdr->report_length;
+                       time->tv_sec = oops_hdr->timestamp;
+                       time->tv_nsec = 0;
+               }
+               *buf = kmalloc(length, GFP_KERNEL);
+               if (*buf == NULL)
+                       return -ENOMEM;
+               memcpy(*buf, buff + hdr_size, length);
+               kfree(buff);
 
                if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) {
                        big_buff = kmalloc(big_oops_buf_sz, GFP_KERNEL);
                        if (!big_buff)
                                return -ENOMEM;
 
-                       rc = unzip_oops(buff, big_buff);
+                       unzipped_len = nvram_decompress(*buf, big_buff,
+                                               length, big_oops_buf_sz);
 
-                       if (rc != 0) {
-                               kfree(buff);
+                       if (unzipped_len < 0) {
+                               pr_err("nvram: decompression failed, returned "
+                                       "rc %d\n", unzipped_len);
                                kfree(big_buff);
-                               goto read_partition;
+                       } else {
+                               *buf = big_buff;
+                               length = unzipped_len;
                        }
-
-                       oops_hdr = (struct oops_log_info *)big_buff;
-                       *buf = big_buff + sizeof(*oops_hdr);
-                       kfree(buff);
                }
-
-               time->tv_sec = oops_hdr->timestamp;
-               time->tv_nsec = 0;
-               return oops_hdr->report_length;
+               return length;
        }
 
        *buf = buff;
@@ -816,6 +802,7 @@ static int nvram_pstore_init(void)
 static void __init nvram_init_oops_partition(int rtas_partition_exists)
 {
        int rc;
+       size_t size;
 
        rc = pseries_nvram_init_os_partition(&oops_log_partition);
        if (rc != 0) {
@@ -844,8 +831,9 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
        big_oops_buf_sz = (oops_data_sz * 100) / 45;
        big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
        if (big_oops_buf) {
-               stream.workspace = kmalloc(zlib_deflate_workspacesize(
-                               WINDOW_BITS, MEM_LEVEL), GFP_KERNEL);
+               size = max(zlib_deflate_workspacesize(WINDOW_BITS, MEM_LEVEL),
+                       zlib_inflate_workspacesize());
+               stream.workspace = kmalloc(size, GFP_KERNEL);
                if (!stream.workspace) {
                        pr_err("nvram: No memory for compression workspace; "
                                "skipping compression of %s partition data\n",
index 7b3cbde8c78378e25fb0d82ca60b58e20ffe51f5..721c0586b284d42aec0dfe69bdc178e191bcf222 100644 (file)
@@ -287,6 +287,9 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
        unsigned long *savep;
        struct rtas_error_log *h, *errhdr = NULL;
 
+       /* Mask top two bits */
+       regs->gpr[3] &= ~(0x3UL << 62);
+
        if (!VALID_FWNMI_BUFFER(regs->gpr[3])) {
                printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]);
                return NULL;
index 22f75b504f7f9bb8ef91ef80e8a1433995e6c6dc..8a4cae78f03c91e510f307d25e8f5467211725c3 100644 (file)
@@ -118,6 +118,7 @@ config S390
        select HAVE_FUNCTION_TRACE_MCOUNT_TEST
        select HAVE_KERNEL_BZIP2
        select HAVE_KERNEL_GZIP
+       select HAVE_KERNEL_LZ4
        select HAVE_KERNEL_LZMA
        select HAVE_KERNEL_LZO
        select HAVE_KERNEL_XZ
@@ -227,11 +228,12 @@ config MARCH_Z196
          not work on older machines.
 
 config MARCH_ZEC12
-       bool "IBM zEC12"
+       bool "IBM zBC12 and zEC12"
        select HAVE_MARCH_ZEC12_FEATURES if 64BIT
        help
-         Select this to enable optimizations for IBM zEC12 (2827 series). The
-         kernel will be slightly faster but will not work on older machines.
+         Select this to enable optimizations for IBM zBC12 and zEC12 (2828 and
+         2827 series). The kernel will be slightly faster but will not work on
+         older machines.
 
 endchoice
 
@@ -709,6 +711,7 @@ config S390_GUEST
        def_bool y
        prompt "s390 support for virtio devices"
        depends on 64BIT
+       select TTY
        select VIRTUALIZATION
        select VIRTIO
        select VIRTIO_CONSOLE
index 3ad8f61c99852c3fe7183a15aacfcd96ace3535a..866ecbe670e499632ef59d514dd04a280f46b890 100644 (file)
@@ -6,9 +6,9 @@
 
 BITS := $(if $(CONFIG_64BIT),64,31)
 
-targets        := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
-          vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo misc.o piggy.o \
-          sizes.h head$(BITS).o
+targets        := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
+targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
+targets += misc.o piggy.o sizes.h head$(BITS).o
 
 KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
 KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
@@ -48,6 +48,7 @@ vmlinux.bin.all-y := $(obj)/vmlinux.bin
 
 suffix-$(CONFIG_KERNEL_GZIP)  := gz
 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
+suffix-$(CONFIG_KERNEL_LZ4)  := lz4
 suffix-$(CONFIG_KERNEL_LZMA)  := lzma
 suffix-$(CONFIG_KERNEL_LZO)  := lzo
 suffix-$(CONFIG_KERNEL_XZ)  := xz
@@ -56,6 +57,8 @@ $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
        $(call if_changed,gzip)
 $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
        $(call if_changed,bzip2)
+$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
+       $(call if_changed,lz4)
 $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
        $(call if_changed,lzma)
 $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
index c4c6a1cf221bde749673b59dccb6e3c6113a0b4c..57cbaff1f39778b98b1de870e34f99cc14043687 100644 (file)
@@ -47,6 +47,10 @@ static unsigned long free_mem_end_ptr;
 #include "../../../../lib/decompress_bunzip2.c"
 #endif
 
+#ifdef CONFIG_KERNEL_LZ4
+#include "../../../../lib/decompress_unlz4.c"
+#endif
+
 #ifdef CONFIG_KERNEL_LZMA
 #include "../../../../lib/decompress_unlzma.c"
 #endif
index 4d8604e311f3aaf6b1799bd78760bcc52a5befab..7d46767587337c3874bd61c43e01a0a72f965303 100644 (file)
@@ -693,7 +693,7 @@ static inline int find_next_bit_left(const unsigned long *addr,
        size -= offset;
        p = addr + offset / BITS_PER_LONG;
        if (bit) {
-               set = __flo_word(0, *p & (~0UL << bit));
+               set = __flo_word(0, *p & (~0UL >> bit));
                if (set >= size)
                        return size + offset;
                if (set < BITS_PER_LONG)
index 6b499870662f2dddbb14dd613943ef10e6303b89..b0e6435b2f02195e60303a9c46f0c199220c5225 100644 (file)
@@ -91,7 +91,15 @@ struct thread_struct {
 #endif
 };
 
-#define PER_FLAG_NO_TE         1UL     /* Flag to disable transactions. */
+/* Flag to disable transactions. */
+#define PER_FLAG_NO_TE                 1UL
+/* Flag to enable random transaction aborts. */
+#define PER_FLAG_TE_ABORT_RAND         2UL
+/* Flag to specify random transaction abort mode:
+ * - abort each transaction at a random instruction before TEND if set.
+ * - abort random transactions at a random instruction if cleared.
+ */
+#define PER_FLAG_TE_ABORT_RAND_TEND    4UL
 
 typedef struct thread_struct thread_struct;
 
index f3a9e0f9270451056c674f854d49bbcd0817ea25..80b6f11263c456233a6defaac28fd502bc7ad9f4 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/thread_info.h>
 
 extern struct task_struct *__switch_to(void *, void *);
-extern void update_per_regs(struct task_struct *task);
+extern void update_cr_regs(struct task_struct *task);
 
 static inline void save_fp_regs(s390_fp_regs *fpregs)
 {
@@ -86,7 +86,7 @@ static inline void restore_access_regs(unsigned int *acrs)
                restore_fp_regs(&next->thread.fp_regs);                 \
                restore_access_regs(&next->thread.acrs[0]);             \
                restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb);  \
-               update_per_regs(next);                                  \
+               update_cr_regs(next);                                   \
        }                                                               \
        prev = __switch_to(prev,next);                                  \
 } while (0)
index b75d7d686684975278e1881a9aaf74590a6949ed..6d6d92b4ea113fbc692cf4dda3cac36d803128fc 100644 (file)
@@ -32,6 +32,7 @@ struct mmu_gather {
        struct mm_struct *mm;
        struct mmu_table_batch *batch;
        unsigned int fullmm;
+       unsigned long start, end;
 };
 
 struct mmu_table_batch {
@@ -48,10 +49,13 @@ extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
 
 static inline void tlb_gather_mmu(struct mmu_gather *tlb,
                                  struct mm_struct *mm,
-                                 unsigned int full_mm_flush)
+                                 unsigned long start,
+                                 unsigned long end)
 {
        tlb->mm = mm;
-       tlb->fullmm = full_mm_flush;
+       tlb->start = start;
+       tlb->end = end;
+       tlb->fullmm = !(start | (end+1));
        tlb->batch = NULL;
        if (tlb->fullmm)
                __tlb_flush_mm(mm);
index 3aa9f1ec5b295f0c530998610d04fa7de34dc93f..7a84619e315e804af6d7c6a535c4df7981e082e3 100644 (file)
@@ -400,6 +400,7 @@ typedef struct
 #define PTRACE_POKE_SYSTEM_CALL              0x5008
 #define PTRACE_ENABLE_TE             0x5009
 #define PTRACE_DISABLE_TE            0x5010
+#define PTRACE_TE_ABORT_RAND         0x5011
 
 /*
  * PT_PROT definition is loosely based on hppa bsd definition in
index 64b24650e4f8c1d43f5cf151b46478f5a602e277..dd62071624be349ca1913ed4404e826ecd6b673e 100644 (file)
@@ -173,7 +173,7 @@ error:
        }
 }
 
-static struct cache_dir *__cpuinit cache_create_cache_dir(int cpu)
+static struct cache_dir *cache_create_cache_dir(int cpu)
 {
        struct cache_dir *cache_dir;
        struct kobject *kobj = NULL;
@@ -289,9 +289,8 @@ static struct kobj_type cache_index_type = {
        .default_attrs = cache_index_default_attrs,
 };
 
-static int __cpuinit cache_create_index_dir(struct cache_dir *cache_dir,
-                                           struct cache *cache, int index,
-                                           int cpu)
+static int cache_create_index_dir(struct cache_dir *cache_dir,
+                                 struct cache *cache, int index, int cpu)
 {
        struct cache_index_dir *index_dir;
        int rc;
@@ -313,7 +312,7 @@ out:
        return rc;
 }
 
-static int __cpuinit cache_add_cpu(int cpu)
+static int cache_add_cpu(int cpu)
 {
        struct cache_dir *cache_dir;
        struct cache *cache;
@@ -335,7 +334,7 @@ static int __cpuinit cache_add_cpu(int cpu)
        return 0;
 }
 
-static void __cpuinit cache_remove_cpu(int cpu)
+static void cache_remove_cpu(int cpu)
 {
        struct cache_index_dir *index, *next;
        struct cache_dir *cache_dir;
@@ -354,8 +353,8 @@ static void __cpuinit cache_remove_cpu(int cpu)
        cache_dir_cpu[cpu] = NULL;
 }
 
-static int __cpuinit cache_hotplug(struct notifier_block *nfb,
-                                  unsigned long action, void *hcpu)
+static int cache_hotplug(struct notifier_block *nfb, unsigned long action,
+                        void *hcpu)
 {
        int cpu = (long)hcpu;
        int rc = 0;
index f703d91bf720ab2756cec8f859855e9c739fcd89..d8f3556571717dd7cc8b4c21efc07268110fb15c 100644 (file)
 #define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))
 #define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y))))
 
+
+/*
+ * Return physical address for virtual address
+ */
+static inline void *load_real_addr(void *addr)
+{
+       unsigned long real_addr;
+
+       asm volatile(
+                  "    lra     %0,0(%1)\n"
+                  "    jz      0f\n"
+                  "    la      %0,0\n"
+                  "0:"
+                  : "=a" (real_addr) : "a" (addr) : "cc");
+       return (void *)real_addr;
+}
+
+/*
+ * Copy up to one page to vmalloc or real memory
+ */
+static ssize_t copy_page_real(void *buf, void *src, size_t csize)
+{
+       size_t size;
+
+       if (is_vmalloc_addr(buf)) {
+               BUG_ON(csize >= PAGE_SIZE);
+               /* If buf is not page aligned, copy first part */
+               size = min(roundup(__pa(buf), PAGE_SIZE) - __pa(buf), csize);
+               if (size) {
+                       if (memcpy_real(load_real_addr(buf), src, size))
+                               return -EFAULT;
+                       buf += size;
+                       src += size;
+               }
+               /* Copy second part */
+               size = csize - size;
+               return (size) ? memcpy_real(load_real_addr(buf), src, size) : 0;
+       } else {
+               return memcpy_real(buf, src, csize);
+       }
+}
+
 /*
  * Copy one page from "oldmem"
  *
@@ -32,6 +74,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
                         size_t csize, unsigned long offset, int userbuf)
 {
        unsigned long src;
+       int rc;
 
        if (!csize)
                return 0;
@@ -43,11 +86,11 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
                 src < OLDMEM_BASE + OLDMEM_SIZE)
                src -= OLDMEM_BASE;
        if (userbuf)
-               copy_to_user_real((void __force __user *) buf, (void *) src,
-                                 csize);
+               rc = copy_to_user_real((void __force __user *) buf,
+                                      (void *) src, csize);
        else
-               memcpy_real(buf, (void *) src, csize);
-       return csize;
+               rc = copy_page_real(buf, (void *) src, csize);
+       return (rc == 0) ? csize : rc;
 }
 
 /*
index 390d9ae57bb2d5fbc563f1069334978a349882da..fb99c2057b85366c96b5f5795e1fdc51580eb595 100644 (file)
@@ -639,8 +639,8 @@ static struct pmu cpumf_pmu = {
        .cancel_txn   = cpumf_pmu_cancel_txn,
 };
 
-static int __cpuinit cpumf_pmu_notifier(struct notifier_block *self,
-                                       unsigned long action, void *hcpu)
+static int cpumf_pmu_notifier(struct notifier_block *self, unsigned long action,
+                             void *hcpu)
 {
        unsigned int cpu = (long) hcpu;
        int flags;
index a6fc037671b11d0a2e96226256f9e36cd8e4d65d..500aa1029bcb2d2ed12ae352a91cec068322615b 100644 (file)
@@ -52,12 +52,13 @@ static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
 
 static bool is_in_guest(struct pt_regs *regs)
 {
-       unsigned long ip = instruction_pointer(regs);
-
        if (user_mode(regs))
                return false;
-
-       return ip == (unsigned long) &sie_exit;
+#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
+       return instruction_pointer(regs) == (unsigned long) &sie_exit;
+#else
+       return false;
+#endif
 }
 
 static unsigned long guest_is_user_mode(struct pt_regs *regs)
index 753c41d0ffd3ae186e01a2345cd8f6b27e878dd1..24612029f4502064b64c53ba52426c52a9337adc 100644 (file)
@@ -21,7 +21,7 @@ static DEFINE_PER_CPU(struct cpuid, cpu_id);
 /*
  * cpu_init - initializes state that is per-CPU.
  */
-void __cpuinit cpu_init(void)
+void cpu_init(void)
 {
        struct s390_idle_data *idle = &__get_cpu_var(s390_idle);
        struct cpuid *id = &__get_cpu_var(cpu_id);
index a314c57f4e94a5a91c162de68360556babd71f8a..e9fadb04e3c61e0b71b6eb238a12941359edba0d 100644 (file)
@@ -47,7 +47,7 @@ enum s390_regset {
        REGSET_GENERAL_EXTENDED,
 };
 
-void update_per_regs(struct task_struct *task)
+void update_cr_regs(struct task_struct *task)
 {
        struct pt_regs *regs = task_pt_regs(task);
        struct thread_struct *thread = &task->thread;
@@ -56,17 +56,25 @@ void update_per_regs(struct task_struct *task)
 #ifdef CONFIG_64BIT
        /* Take care of the enable/disable of transactional execution. */
        if (MACHINE_HAS_TE) {
-               unsigned long cr0, cr0_new;
+               unsigned long cr[3], cr_new[3];
 
-               __ctl_store(cr0, 0, 0);
-               /* set or clear transaction execution bits 8 and 9. */
+               __ctl_store(cr, 0, 2);
+               cr_new[1] = cr[1];
+               /* Set or clear transaction execution TXC/PIFO bits 8 and 9. */
                if (task->thread.per_flags & PER_FLAG_NO_TE)
-                       cr0_new = cr0 & ~(3UL << 54);
+                       cr_new[0] = cr[0] & ~(3UL << 54);
                else
-                       cr0_new = cr0 | (3UL << 54);
-               /* Only load control register 0 if necessary. */
-               if (cr0 != cr0_new)
-                       __ctl_load(cr0_new, 0, 0);
+                       cr_new[0] = cr[0] | (3UL << 54);
+               /* Set or clear transaction execution TDC bits 62 and 63. */
+               cr_new[2] = cr[2] & ~3UL;
+               if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND) {
+                       if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND_TEND)
+                               cr_new[2] |= 1UL;
+                       else
+                               cr_new[2] |= 2UL;
+               }
+               if (memcmp(&cr_new, &cr, sizeof(cr)))
+                       __ctl_load(cr_new, 0, 2);
        }
 #endif
        /* Copy user specified PER registers */
@@ -100,14 +108,14 @@ void user_enable_single_step(struct task_struct *task)
 {
        set_tsk_thread_flag(task, TIF_SINGLE_STEP);
        if (task == current)
-               update_per_regs(task);
+               update_cr_regs(task);
 }
 
 void user_disable_single_step(struct task_struct *task)
 {
        clear_tsk_thread_flag(task, TIF_SINGLE_STEP);
        if (task == current)
-               update_per_regs(task);
+               update_cr_regs(task);
 }
 
 /*
@@ -447,6 +455,26 @@ long arch_ptrace(struct task_struct *child, long request,
                if (!MACHINE_HAS_TE)
                        return -EIO;
                child->thread.per_flags |= PER_FLAG_NO_TE;
+               child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND;
+               return 0;
+       case PTRACE_TE_ABORT_RAND:
+               if (!MACHINE_HAS_TE || (child->thread.per_flags & PER_FLAG_NO_TE))
+                       return -EIO;
+               switch (data) {
+               case 0UL:
+                       child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND;
+                       break;
+               case 1UL:
+                       child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND;
+                       child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND_TEND;
+                       break;
+               case 2UL:
+                       child->thread.per_flags |= PER_FLAG_TE_ABORT_RAND;
+                       child->thread.per_flags &= ~PER_FLAG_TE_ABORT_RAND_TEND;
+                       break;
+               default:
+                       return -EINVAL;
+               }
                return 0;
        default:
                /* Removing high order bit from addr (only for 31 bit). */
index 497451ec5e267f3be025b9b719cf4f2278262d97..aeed8a61fa0d4f1b4862a98cab44e29beda63699 100644 (file)
@@ -994,6 +994,7 @@ static void __init setup_hwcaps(void)
                strcpy(elf_platform, "z196");
                break;
        case 0x2827:
+       case 0x2828:
                strcpy(elf_platform, "zEC12");
                break;
        }
index 15a016c1056392969bf84af7d4c1afe34aace480..d386c4e9d2e5924a55b635cdcd28c967548fd7b6 100644 (file)
@@ -165,7 +165,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit)
        pcpu_sigp_retry(pcpu, order, 0);
 }
 
-static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
+static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
 {
        struct _lowcore *lc;
 
@@ -616,10 +616,9 @@ static struct sclp_cpu_info *smp_get_cpu_info(void)
        return info;
 }
 
-static int __cpuinit smp_add_present_cpu(int cpu);
+static int smp_add_present_cpu(int cpu);
 
-static int __cpuinit __smp_rescan_cpus(struct sclp_cpu_info *info,
-                                      int sysfs_add)
+static int __smp_rescan_cpus(struct sclp_cpu_info *info, int sysfs_add)
 {
        struct pcpu *pcpu;
        cpumask_t avail;
@@ -685,7 +684,7 @@ static void __init smp_detect_cpus(void)
 /*
  *     Activate a secondary processor.
  */
-static void __cpuinit smp_start_secondary(void *cpuvoid)
+static void smp_start_secondary(void *cpuvoid)
 {
        S390_lowcore.last_update_clock = get_tod_clock();
        S390_lowcore.restart_stack = (unsigned long) restart_stack;
@@ -708,7 +707,7 @@ static void __cpuinit smp_start_secondary(void *cpuvoid)
 }
 
 /* Upping and downing of CPUs */
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        struct pcpu *pcpu;
        int rc;
@@ -964,8 +963,8 @@ static struct attribute_group cpu_online_attr_group = {
        .attrs = cpu_online_attrs,
 };
 
-static int __cpuinit smp_cpu_notify(struct notifier_block *self,
-                                   unsigned long action, void *hcpu)
+static int smp_cpu_notify(struct notifier_block *self, unsigned long action,
+                         void *hcpu)
 {
        unsigned int cpu = (unsigned int)(long)hcpu;
        struct cpu *c = &pcpu_devices[cpu].cpu;
@@ -983,7 +982,7 @@ static int __cpuinit smp_cpu_notify(struct notifier_block *self,
        return notifier_from_errno(err);
 }
 
-static int __cpuinit smp_add_present_cpu(int cpu)
+static int smp_add_present_cpu(int cpu)
 {
        struct cpu *c = &pcpu_devices[cpu].cpu;
        struct device *s = &c->dev;
index 62f89d98e880715f2ebbe30a5a99fc16a220a1de..811f542b8ed4adc3e209924e57c618e2d32e923c 100644 (file)
@@ -418,7 +418,7 @@ void s390_adjust_jiffies(void)
 /*
  * calibrate the delay loop
  */
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        s390_adjust_jiffies();
        /* Print the good old Bogomips line .. */
index 3fb09359eda621b65eba743a2c704376225fb844..9b9c1b78ec67487cbb53439866a8cf56a790d24f 100644 (file)
@@ -371,14 +371,14 @@ EXPORT_SYMBOL(del_virt_timer);
 /*
  * Start the virtual CPU timer on the current CPU.
  */
-void __cpuinit init_cpu_vtimer(void)
+void init_cpu_vtimer(void)
 {
        /* set initial cpu timer */
        set_vtimer(VTIMER_MAX_SLICE);
 }
 
-static int __cpuinit s390_nohz_notify(struct notifier_block *self,
-                                     unsigned long action, void *hcpu)
+static int s390_nohz_notify(struct notifier_block *self, unsigned long action,
+                           void *hcpu)
 {
        struct s390_idle_data *idle;
        long cpu = (long) hcpu;
index ba694d2ba51e36a2933ad722db76b00e09735f37..34c1c9a90be288d9080d93373660d020bedf2a90 100644 (file)
@@ -702,14 +702,25 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
                return rc;
 
        vcpu->arch.sie_block->icptcode = 0;
-       preempt_disable();
-       kvm_guest_enter();
-       preempt_enable();
        VCPU_EVENT(vcpu, 6, "entering sie flags %x",
                   atomic_read(&vcpu->arch.sie_block->cpuflags));
        trace_kvm_s390_sie_enter(vcpu,
                                 atomic_read(&vcpu->arch.sie_block->cpuflags));
+
+       /*
+        * As PF_VCPU will be used in fault handler, between guest_enter
+        * and guest_exit should be no uaccess.
+        */
+       preempt_disable();
+       kvm_guest_enter();
+       preempt_enable();
        rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
+       kvm_guest_exit();
+
+       VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
+                  vcpu->arch.sie_block->icptcode);
+       trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
+
        if (rc > 0)
                rc = 0;
        if (rc < 0) {
@@ -721,10 +732,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
                        rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
                }
        }
-       VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
-                  vcpu->arch.sie_block->icptcode);
-       trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
-       kvm_guest_exit();
 
        memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
        return rc;
index 0da3e6eb6be6cec4d55780b838492e52d093f08d..4cdc54e63ebcb366786347de18437f327ee8e2b2 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/compat.h>
 #include <asm/asm-offsets.h>
+#include <asm/facility.h>
 #include <asm/current.h>
 #include <asm/debug.h>
 #include <asm/ebcdic.h>
@@ -532,8 +533,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
                return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
        /* Only provide non-quiescing support if the host supports it */
-       if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ &&
-           S390_lowcore.stfl_fac_list & 0x00020000)
+       if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && !test_facility(14))
                return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 
        /* No support for conditional-SSKE */
index 047c3e4c59a2e4ad03ea7812b8a5da8a6ab20f9a..f00aefb66a4e03144a3283c04186e1a5e1177e1e 100644 (file)
@@ -639,8 +639,8 @@ out:
        put_task_struct(tsk);
 }
 
-static int __cpuinit pfault_cpu_notify(struct notifier_block *self,
-                                      unsigned long action, void *hcpu)
+static int pfault_cpu_notify(struct notifier_block *self, unsigned long action,
+                            void *hcpu)
 {
        struct thread_struct *thread, *next;
        struct task_struct *tsk;
index ce36ea80e4f9157f5c754b51c1ff9c700106d689..ad446b0c55b6076d5aaf7f095f1ddc91b5e38bf4 100644 (file)
@@ -69,6 +69,7 @@ static void __init setup_zero_pages(void)
                order = 2;
                break;
        case 0x2827:    /* zEC12 */
+       case 0x2828:    /* zEC12 */
        default:
                order = 5;
                break;
index 82f165f8078c1b2fc209495bcc2847b2602e210d..d5f10a43a58fb145b5514b897121fd9471fdabb2 100644 (file)
@@ -9,6 +9,8 @@
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
 #include <linux/filter.h>
+#include <linux/random.h>
+#include <linux/init.h>
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
 #include <asm/facility.h>
@@ -221,6 +223,37 @@ static void bpf_jit_epilogue(struct bpf_jit *jit)
        EMIT2(0x07fe);
 }
 
+/* Helper to find the offset of pkt_type in sk_buff
+ * Make sure its still a 3bit field starting at the MSBs within a byte.
+ */
+#define PKT_TYPE_MAX 0xe0
+static int pkt_type_offset;
+
+static int __init bpf_pkt_type_offset_init(void)
+{
+       struct sk_buff skb_probe = {
+               .pkt_type = ~0,
+       };
+       char *ct = (char *)&skb_probe;
+       int off;
+
+       pkt_type_offset = -1;
+       for (off = 0; off < sizeof(struct sk_buff); off++) {
+               if (!ct[off])
+                       continue;
+               if (ct[off] == PKT_TYPE_MAX)
+                       pkt_type_offset = off;
+               else {
+                       /* Found non matching bit pattern, fix needed. */
+                       WARN_ON_ONCE(1);
+                       pkt_type_offset = -1;
+                       return -1;
+               }
+       }
+       return 0;
+}
+device_initcall(bpf_pkt_type_offset_init);
+
 /*
  * make sure we dont leak kernel information to user
  */
@@ -720,6 +753,16 @@ call_fn:   /* lg %r1,<d(function)>(%r13) */
                        EMIT4_DISP(0x88500000, 12);
                }
                break;
+       case BPF_S_ANC_PKTTYPE:
+               if (pkt_type_offset < 0)
+                       goto out;
+               /* lhi %r5,0 */
+               EMIT4(0xa7580000);
+               /* ic %r5,<d(pkt_type_offset)>(%r2) */
+               EMIT4_DISP(0x43502000, pkt_type_offset);
+               /* srl %r5,5 */
+               EMIT4_DISP(0x88500000, 5);
+               break;
        case BPF_S_ANC_CPU: /* A = smp_processor_id() */
 #ifdef CONFIG_SMP
                /* l %r5,<d(cpu_nr)> */
@@ -738,8 +781,41 @@ out:
        return -1;
 }
 
+/*
+ * Note: for security reasons, bpf code will follow a randomly
+ *      sized amount of illegal instructions.
+ */
+struct bpf_binary_header {
+       unsigned int pages;
+       u8 image[];
+};
+
+static struct bpf_binary_header *bpf_alloc_binary(unsigned int bpfsize,
+                                                 u8 **image_ptr)
+{
+       struct bpf_binary_header *header;
+       unsigned int sz, hole;
+
+       /* Most BPF filters are really small, but if some of them fill a page,
+        * allow at least 128 extra bytes for illegal instructions.
+        */
+       sz = round_up(bpfsize + sizeof(*header) + 128, PAGE_SIZE);
+       header = module_alloc(sz);
+       if (!header)
+               return NULL;
+       memset(header, 0, sz);
+       header->pages = sz / PAGE_SIZE;
+       hole = sz - bpfsize + sizeof(*header);
+       /* Insert random number of illegal instructions before BPF code
+        * and make sure the first instruction starts at an even address.
+        */
+       *image_ptr = &header->image[(prandom_u32() % hole) & -2];
+       return header;
+}
+
 void bpf_jit_compile(struct sk_filter *fp)
 {
+       struct bpf_binary_header *header = NULL;
        unsigned long size, prg_len, lit_len;
        struct bpf_jit jit, cjit;
        unsigned int *addrs;
@@ -772,12 +848,11 @@ void bpf_jit_compile(struct sk_filter *fp)
                } else if (jit.prg == cjit.prg && jit.lit == cjit.lit) {
                        prg_len = jit.prg - jit.start;
                        lit_len = jit.lit - jit.mid;
-                       size = max_t(unsigned long, prg_len + lit_len,
-                                    sizeof(struct work_struct));
+                       size = prg_len + lit_len;
                        if (size >= BPF_SIZE_MAX)
                                goto out;
-                       jit.start = module_alloc(size);
-                       if (!jit.start)
+                       header = bpf_alloc_binary(size, &jit.start);
+                       if (!header)
                                goto out;
                        jit.prg = jit.mid = jit.start + prg_len;
                        jit.lit = jit.end = jit.start + prg_len + lit_len;
@@ -788,37 +863,25 @@ void bpf_jit_compile(struct sk_filter *fp)
                cjit = jit;
        }
        if (bpf_jit_enable > 1) {
-               pr_err("flen=%d proglen=%lu pass=%d image=%p\n",
-                      fp->len, jit.end - jit.start, pass, jit.start);
-               if (jit.start) {
-                       printk(KERN_ERR "JIT code:\n");
+               bpf_jit_dump(fp->len, jit.end - jit.start, pass, jit.start);
+               if (jit.start)
                        print_fn_code(jit.start, jit.mid - jit.start);
-                       print_hex_dump(KERN_ERR, "JIT literals:\n",
-                                      DUMP_PREFIX_ADDRESS, 16, 1,
-                                      jit.mid, jit.end - jit.mid, false);
-               }
        }
-       if (jit.start)
+       if (jit.start) {
+               set_memory_ro((unsigned long)header, header->pages);
                fp->bpf_func = (void *) jit.start;
+       }
 out:
        kfree(addrs);
 }
 
-static void jit_free_defer(struct work_struct *arg)
-{
-       module_free(NULL, arg);
-}
-
-/* run from softirq, we must use a work_struct to call
- * module_free() from process context
- */
 void bpf_jit_free(struct sk_filter *fp)
 {
-       struct work_struct *work;
+       unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
+       struct bpf_binary_header *header = (void *)addr;
 
        if (fp->bpf_func == sk_run_filter)
                return;
-       work = (struct work_struct *)fp->bpf_func;
-       INIT_WORK(work, jit_free_defer);
-       schedule_work(work);
+       set_memory_rw(addr, header->pages);
+       module_free(NULL, header);
 }
index ffeb17ce7f313d914a38de3ee21dad5867991b9d..930783d2c99beb305b2346a220f414d98a4ba406 100644 (file)
@@ -440,7 +440,7 @@ static int oprofile_hwsampler_init(struct oprofile_operations *ops)
                switch (id.machine) {
                case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break;
                case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break;
-               case 0x2827:              ops->cpu_type = "s390/zEC12"; break;
+               case 0x2827: case 0x2828: ops->cpu_type = "s390/zEC12"; break;
                default: return -ENODEV;
                }
        }
index c8def8bc90209578a5a6d5cfaf8f9f258c4ec7fb..5fc237581caf3a6f3b40c41246f4d39d28f8ee55 100644 (file)
@@ -87,6 +87,8 @@ config STACKTRACE_SUPPORT
 
 source "init/Kconfig"
 
+source "kernel/Kconfig.freezer"
+
 config MMU
        def_bool y
 
index 6fdb100244c8193076087ab3c274405d2e9d5e85..004073717de03f3360021959625bf714883518e0 100644 (file)
@@ -240,7 +240,7 @@ void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
        local_irq_restore(flags);
 }
 
-void __cpuinit tlb_init(void)
+void tlb_init(void)
 {
        tlblock_set(0);
        local_flush_tlb_all();
index 4d94dff9015c97fe27a58affaab8c8a4c37b132b..7291e2f11a4748e64f22475b6b1be2efc8fba304 100644 (file)
@@ -80,7 +80,6 @@ static struct resource sh_eth_resources[] = {
 static struct sh_eth_plat_data sh7763_eth_pdata = {
        .phy = 0,
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_GIGABIT,
        .phy_interface = PHY_INTERFACE_MODE_MII,
 };
 
index 4f114d1cd0198ea78160adf44450c8420ac8cfa1..25c5a932f9fed68f104283d9d64e71de2c158a2d 100644 (file)
@@ -77,7 +77,6 @@ static struct resource sh_eth0_resources[] = {
 static struct sh_eth_plat_data sh7757_eth0_pdata = {
        .phy = 1,
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_FAST_SH4,
        .set_mdio_gate = sh7757_eth_set_mdio_gate,
 };
 
@@ -106,7 +105,6 @@ static struct resource sh_eth1_resources[] = {
 static struct sh_eth_plat_data sh7757_eth1_pdata = {
        .phy = 1,
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_FAST_SH4,
        .set_mdio_gate = sh7757_eth_set_mdio_gate,
 };
 
@@ -151,7 +149,6 @@ static struct resource sh_eth_giga0_resources[] = {
 static struct sh_eth_plat_data sh7757_eth_giga0_pdata = {
        .phy = 18,
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_GIGABIT,
        .set_mdio_gate = sh7757_eth_giga_set_mdio_gate,
        .phy_interface = PHY_INTERFACE_MODE_RGMII_ID,
 };
@@ -186,7 +183,6 @@ static struct resource sh_eth_giga1_resources[] = {
 static struct sh_eth_plat_data sh7757_eth_giga1_pdata = {
        .phy = 19,
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_GIGABIT,
        .set_mdio_gate = sh7757_eth_giga_set_mdio_gate,
        .phy_interface = PHY_INTERFACE_MODE_RGMII_ID,
 };
index 61fade0ffa965736427b2b2091ad50d097b59d39..a4f630f04ea3a0e73740fadfed834806fdc78ef8 100644 (file)
@@ -159,7 +159,6 @@ static struct resource sh_eth_resources[] = {
 static struct sh_eth_plat_data sh_eth_plat = {
        .phy = 0x1f, /* SMSC LAN8700 */
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_FAST_SH4,
        .phy_interface = PHY_INTERFACE_MODE_MII,
        .ether_link_active_low = 1
 };
index b70180ef3e2978832f33f2aec85322a183978b22..21e4230659a57d978ac7631016ca42adf1ddc795 100644 (file)
@@ -365,7 +365,7 @@ static struct platform_device keysc_device = {
 static struct resource sh_eth_resources[] = {
        [0] = {
                .start = SH_ETH_ADDR,
-               .end   = SH_ETH_ADDR + 0x1FC,
+               .end   = SH_ETH_ADDR + 0x1FC - 1,
                .flags = IORESOURCE_MEM,
        },
        [1] = {
@@ -377,6 +377,7 @@ static struct resource sh_eth_resources[] = {
 static struct sh_eth_plat_data sh_eth_plat = {
        .phy = 0x1f, /* SMSC LAN8187 */
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
+       .phy_interface = PHY_INTERFACE_MODE_MII,
 };
 
 static struct platform_device sh_eth_device = {
index 50ba481fa240c155c0764572d11c5ef74cedaac8..2c8fb04685d4c05cf2aa2954c615290505f200b8 100644 (file)
@@ -88,7 +88,6 @@ static struct resource sh_eth_resources[] = {
 static struct sh_eth_plat_data sh7763_eth_pdata = {
        .phy = 1,
        .edmac_endian = EDMAC_LITTLE_ENDIAN,
-       .register_type = SH_ETH_REG_GIGABIT,
        .phy_interface = PHY_INTERFACE_MODE_MII,
 };
 
index 2051821724c6db6d33ac89b333bc5214b61b68ea..0cf4097b71e8d02051a3976d86b63226ab2b8924 100644 (file)
@@ -22,7 +22,7 @@ CONFIG_PREEMPT=y
 CONFIG_CMDLINE_OVERWRITE=y
 CONFIG_CMDLINE="console=ttySC1,115200 mem=64M root=/dev/nfs"
 CONFIG_PCI=y
-CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI=y
 CONFIG_BINFMT_MISC=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index e61d43d9f689c0ef61bc0e1e5e43b3826b66a760..362192ed12fef1789d2c23d21c654f19632006a0 100644 (file)
@@ -36,10 +36,12 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
+tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
-       tlb->fullmm = full_mm_flush;
+       tlb->start = start;
+       tlb->end = end;
+       tlb->fullmm = !(start | (end+1));
 
        init_tlb_gather(tlb);
 }
index 61a07dafcd46cbaaae3c1c36ad48218e47944f82..ecf83cd158dc38fefb91f2fa83cdb452cfa5c6bf 100644 (file)
@@ -43,9 +43,9 @@
  * peripherals (nofpu, nodsp, and so forth).
  */
 #define onchip_setup(x)                                        \
-static int x##_disabled __cpuinitdata = !cpu_has_##x;  \
+static int x##_disabled = !cpu_has_##x;                        \
                                                        \
-static int __cpuinit x##_setup(char *opts)                     \
+static int x##_setup(char *opts)                       \
 {                                                      \
        x##_disabled = 1;                               \
        return 1;                                       \
@@ -59,7 +59,7 @@ onchip_setup(dsp);
 #define CPUOPM         0xff2f0000
 #define CPUOPM_RABD    (1 << 5)
 
-static void __cpuinit speculative_execution_init(void)
+static void speculative_execution_init(void)
 {
        /* Clear RABD */
        __raw_writel(__raw_readl(CPUOPM) & ~CPUOPM_RABD, CPUOPM);
@@ -78,7 +78,7 @@ static void __cpuinit speculative_execution_init(void)
 #define EXPMASK_BRDSSLP                (1 << 1)
 #define EXPMASK_MMCAW          (1 << 4)
 
-static void __cpuinit expmask_init(void)
+static void expmask_init(void)
 {
        unsigned long expmask = __raw_readl(EXPMASK);
 
@@ -217,7 +217,7 @@ static void detect_cache_shape(void)
                l2_cache_shape = -1; /* No S-cache */
 }
 
-static void __cpuinit fpu_init(void)
+static void fpu_init(void)
 {
        /* Disable the FPU */
        if (fpu_disabled && (current_cpu_data.flags & CPU_HAS_FPU)) {
@@ -230,7 +230,7 @@ static void __cpuinit fpu_init(void)
 }
 
 #ifdef CONFIG_SH_DSP
-static void __cpuinit release_dsp(void)
+static void release_dsp(void)
 {
        unsigned long sr;
 
@@ -244,7 +244,7 @@ static void __cpuinit release_dsp(void)
        );
 }
 
-static void __cpuinit dsp_init(void)
+static void dsp_init(void)
 {
        unsigned long sr;
 
@@ -276,7 +276,7 @@ static void __cpuinit dsp_init(void)
        release_dsp();
 }
 #else
-static inline void __cpuinit dsp_init(void) { }
+static inline void dsp_init(void) { }
 #endif /* CONFIG_SH_DSP */
 
 /**
@@ -295,7 +295,7 @@ static inline void __cpuinit dsp_init(void) { }
  * Each processor family is still responsible for doing its own probing
  * and cache configuration in cpu_probe().
  */
-asmlinkage void __cpuinit cpu_init(void)
+asmlinkage void cpu_init(void)
 {
        current_thread_info()->cpu = hard_smp_processor_id();
 
index bab8e75958aee5b962b1953bf7cdc33702756d94..6c687ae812ef6aa89087d3bced828ee580d2a325 100644 (file)
@@ -13,7 +13,7 @@
 #include <asm/processor.h>
 #include <asm/cache.h>
 
-void __cpuinit cpu_probe(void)
+void cpu_probe(void)
 {
 #if defined(CONFIG_CPU_SUBTYPE_SH7619)
        boot_cpu_data.type                      = CPU_SH7619;
index bb11e19251784289f50ed7ce089af68ff23674eb..4df4d4ffe39ba245b8b551afe80abf338c5ce527 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/serial.h>
 #include <linux/serial_sci.h>
+#include <linux/sh_eth.h>
 #include <linux/sh_timer.h>
 #include <linux/io.h>
 
@@ -110,10 +111,16 @@ static struct platform_device scif2_device = {
        },
 };
 
+static struct sh_eth_plat_data eth_platform_data = {
+       .phy            = 1,
+       .edmac_endian   = EDMAC_LITTLE_ENDIAN,
+       .phy_interface  = PHY_INTERFACE_MODE_MII,
+};
+
 static struct resource eth_resources[] = {
        [0] = {
                .start = 0xfb000000,
-               .end =   0xfb0001c8,
+               .end = 0xfb0001c7,
                .flags = IORESOURCE_MEM,
        },
        [1] = {
@@ -127,7 +134,7 @@ static struct platform_device eth_device = {
        .name = "sh7619-ether",
        .id = -1,
        .dev = {
-               .platform_data = (void *)1,
+               .platform_data = &eth_platform_data,
        },
        .num_resources = ARRAY_SIZE(eth_resources),
        .resource = eth_resources,
index 5170b6aa4129e5d0f6648e6ec6014d9289f75d86..3f87971082f117b7d5fb1e5bbef048c67603d6e0 100644 (file)
@@ -13,7 +13,7 @@
 #include <asm/processor.h>
 #include <asm/cache.h>
 
-void __cpuinit cpu_probe(void)
+void cpu_probe(void)
 {
        boot_cpu_data.family                    = CPU_FAMILY_SH2A;
 
index bf23c322e164b591a200c1206791d6d2d869d962..426e1e1dcedc7c08213cad2b971366516fff6771 100644 (file)
@@ -16,7 +16,7 @@
 #include <asm/cache.h>
 #include <asm/io.h>
 
-void __cpuinit cpu_probe(void)
+void cpu_probe(void)
 {
        unsigned long addr0, addr1, data0, data1, data2, data3;
 
index 0fbbd50bc8ad3fe81e6b963e8041da0e605f3ce1..a521bcf506956cd6022846a37680061d212a0548 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/processor.h>
 #include <asm/cache.h>
 
-void __cpuinit cpu_probe(void)
+void cpu_probe(void)
 {
        unsigned long pvr, prr, cvr;
        unsigned long size;
index 03f2b55757cfc497ed548d57f830c6ba876308fc..4a298808789c46cc3502348b283f3b22b02be7dd 100644 (file)
@@ -124,7 +124,7 @@ static void shx3_update_boot_vector(unsigned int cpu)
        __raw_writel(STBCR_RESET, STBCR_REG(cpu));
 }
 
-static int __cpuinit
+static int
 shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned int)hcpu;
@@ -143,11 +143,11 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
+static struct notifier_block shx3_cpu_notifier = {
        .notifier_call          = shx3_cpu_callback,
 };
 
-static int __cpuinit register_shx3_cpu_notifier(void)
+static int register_shx3_cpu_notifier(void)
 {
        register_hotcpu_notifier(&shx3_cpu_notifier);
        return 0;
index 9e882409e4e981ae90ca3f262d6010df594c9216..eca427c2f2f3de6c9d7b7665ea69d831377993a8 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/cache.h>
 #include <asm/tlb.h>
 
-void __cpuinit cpu_probe(void)
+void cpu_probe(void)
 {
        unsigned long long cir;
 
index 068b8a2759b5208bf0067cee27b9b3a6559263cb..b9cefebda55c09def5a294c735a20c7408f0bb6b 100644 (file)
@@ -367,7 +367,7 @@ static void sh_pmu_setup(int cpu)
        memset(cpuhw, 0, sizeof(struct cpu_hw_events));
 }
 
-static int __cpuinit
+static int
 sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (long)hcpu;
@@ -384,7 +384,7 @@ sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
        return NOTIFY_OK;
 }
 
-int __cpuinit register_sh_pmu(struct sh_pmu *_pmu)
+int register_sh_pmu(struct sh_pmu *_pmu)
 {
        if (sh_pmu)
                return -EBUSY;
index 055d91b70305f3f2a45bf176507d484a4e49e619..53bc6c4c84ecdf1984bd422f69a3b46ef9032873 100644 (file)
@@ -65,7 +65,7 @@ void arch_task_cache_init(void)
 # define HAVE_SOFTFP   0
 #endif
 
-void __cpuinit init_thread_xstate(void)
+void init_thread_xstate(void)
 {
        if (boot_cpu_data.flags & CPU_HAS_FPU)
                xstate_size = sizeof(struct sh_fpu_hard_struct);
index ebe7a7d97215e4978252af8a3512821e64148064..1cf90e947dbf19962bbf86d685b0d8b142331e99 100644 (file)
@@ -172,7 +172,7 @@ disable:
 #endif
 }
 
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        struct clk *clk = clk_get(NULL, "cpu_clk");
 
index 45696451f0ea3ee3ec5452d78ddd2d55ab50d38c..86a7936a980b6c2afd31ff61682a05aed39ece69 100644 (file)
@@ -37,7 +37,7 @@ struct plat_smp_ops *mp_ops = NULL;
 /* State of each CPU */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
 
-void __cpuinit register_smp_ops(struct plat_smp_ops *ops)
+void register_smp_ops(struct plat_smp_ops *ops)
 {
        if (mp_ops)
                printk(KERN_WARNING "Overriding previously set SMP ops\n");
@@ -45,7 +45,7 @@ void __cpuinit register_smp_ops(struct plat_smp_ops *ops)
        mp_ops = ops;
 }
 
-static inline void __cpuinit smp_store_cpu_info(unsigned int cpu)
+static inline void smp_store_cpu_info(unsigned int cpu)
 {
        struct sh_cpuinfo *c = cpu_data + cpu;
 
@@ -174,7 +174,7 @@ void native_play_dead(void)
 }
 #endif
 
-asmlinkage void __cpuinit start_secondary(void)
+asmlinkage void start_secondary(void)
 {
        unsigned int cpu = smp_processor_id();
        struct mm_struct *mm = &init_mm;
@@ -215,7 +215,7 @@ extern struct {
        void *thread_info;
 } stack_start;
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tsk)
+int __cpu_up(unsigned int cpu, struct task_struct *tsk)
 {
        unsigned long timeout;
 
index 5f513a64dedfc8f3afa1593a253505d3ce2254eb..68e99f09171dd668248489499e9e10073b23d579 100644 (file)
@@ -741,7 +741,7 @@ asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
        die_if_kernel("exception", regs, ex);
 }
 
-void __cpuinit per_cpu_trap_init(void)
+void per_cpu_trap_init(void)
 {
        extern void *vbr_base;
 
index f87d20da17916cc0c3cf8c6cfb286cbbb0d50d5b..112ea11c030d68ef6bcfbd0ec1ab8148b7db327f 100644 (file)
@@ -810,7 +810,7 @@ asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
        poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);
 }
 
-void __cpuinit per_cpu_trap_init(void)
+void per_cpu_trap_init(void)
 {
        /* Nothing to do for now, VBR initialization later. */
 }
index ff1c40a31cbc05ea888721f601f1ca581a2fbae4..e4bb2a8e0a69df74edda42afde7a13b91d521e91 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * sh64_tlb_init - Perform initial setup for the DTLB and ITLB.
  */
-int __cpuinit sh64_tlb_init(void)
+int sh64_tlb_init(void)
 {
        /* Assign some sane DTLB defaults */
        cpu_data->dtlb.entries  = 64;
index 11d460f6f9cc70ddbf37b75bed4803b782672dad..62d6b153ffa2e82d895a4e81b51b2abe9490aee8 100644 (file)
@@ -528,10 +528,8 @@ static void dr_cpu_mark(struct ds_data *resp, int cpu, int ncpus,
        }
 }
 
-static int __cpuinit dr_cpu_configure(struct ds_info *dp,
-                                     struct ds_cap_state *cp,
-                                     u64 req_num,
-                                     cpumask_t *mask)
+static int dr_cpu_configure(struct ds_info *dp, struct ds_cap_state *cp,
+                           u64 req_num, cpumask_t *mask)
 {
        struct ds_data *resp;
        int resp_len, ncpus, cpu;
@@ -627,9 +625,8 @@ static int dr_cpu_unconfigure(struct ds_info *dp,
        return 0;
 }
 
-static void __cpuinit dr_cpu_data(struct ds_info *dp,
-                                 struct ds_cap_state *cp,
-                                 void *buf, int len)
+static void dr_cpu_data(struct ds_info *dp, struct ds_cap_state *cp, void *buf,
+                       int len)
 {
        struct ds_data *data = buf;
        struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1);
index cc3c5cb47cdaa4d18e14533f5078b2dbd5f51649..9c179fbfb219c12b20f49e23aaf44db5567840e7 100644 (file)
@@ -250,7 +250,7 @@ extern struct ino_bucket *ivector_table;
 extern unsigned long ivector_table_pa;
 
 extern void init_irqwork_curcpu(void);
-extern void __cpuinit sun4v_register_mondo_queues(int this_cpu);
+extern void sun4v_register_mondo_queues(int this_cpu);
 
 #endif /* CONFIG_SPARC32 */
 #endif /* _ENTRY_H */
index 605c960b2fa642df6030c7f3a1b9ae12bc6f1eba..4eb1a5a1d5440642aefbef171c527767cc722063 100644 (file)
@@ -16,7 +16,6 @@
 #include <asm/asi.h>
 #include <asm/pil.h>
 
-       __CPUINIT
        .align          8
        .globl          hv_cpu_startup, hv_cpu_startup_end
 
index 9bcbbe2c4e7e1f79e95cf35ff4a4567648d5e4d2..d4840cec2c55c156203463ec27e3d8d716f0e309 100644 (file)
@@ -835,7 +835,8 @@ void notrace init_irqwork_curcpu(void)
  * Therefore you cannot make any OBP calls, not even prom_printf,
  * from these two routines.
  */
-static void __cpuinit notrace register_one_mondo(unsigned long paddr, unsigned long type, unsigned long qmask)
+static void notrace register_one_mondo(unsigned long paddr, unsigned long type,
+                                      unsigned long qmask)
 {
        unsigned long num_entries = (qmask + 1) / 64;
        unsigned long status;
@@ -848,7 +849,7 @@ static void __cpuinit notrace register_one_mondo(unsigned long paddr, unsigned l
        }
 }
 
-void __cpuinit notrace sun4v_register_mondo_queues(int this_cpu)
+void notrace sun4v_register_mondo_queues(int this_cpu)
 {
        struct trap_per_cpu *tb = &trap_block[this_cpu];
 
index d7aa524b72832d2555dcf2ffe831e5816641f840..6edf955f987caabd6427eb3bd80b8c7603b02563 100644 (file)
@@ -54,7 +54,7 @@ extern ctxd_t *srmmu_ctx_table_phys;
 static int smp_processors_ready;
 extern volatile unsigned long cpu_callin_map[NR_CPUS];
 extern cpumask_t smp_commenced_mask;
-void __cpuinit leon_configure_cache_smp(void);
+void leon_configure_cache_smp(void);
 static void leon_ipi_init(void);
 
 /* IRQ number of LEON IPIs */
@@ -69,12 +69,12 @@ static inline unsigned long do_swap(volatile unsigned long *ptr,
        return val;
 }
 
-void __cpuinit leon_cpu_pre_starting(void *arg)
+void leon_cpu_pre_starting(void *arg)
 {
        leon_configure_cache_smp();
 }
 
-void __cpuinit leon_cpu_pre_online(void *arg)
+void leon_cpu_pre_online(void *arg)
 {
        int cpuid = hard_smp_processor_id();
 
@@ -106,7 +106,7 @@ void __cpuinit leon_cpu_pre_online(void *arg)
 
 extern struct linux_prom_registers smp_penguin_ctable;
 
-void __cpuinit leon_configure_cache_smp(void)
+void leon_configure_cache_smp(void)
 {
        unsigned long cfg = sparc_leon3_get_dcachecfg();
        int me = smp_processor_id();
@@ -186,7 +186,7 @@ void __init leon_boot_cpus(void)
 
 }
 
-int __cpuinit leon_boot_one_cpu(int i, struct task_struct *idle)
+int leon_boot_one_cpu(int i, struct task_struct *idle)
 {
        int timeout;
 
index 831c001604e8e9bf431b2993ec577b40b6e3f776..b90bf23e3aabf36950c03383afe215a8af6006ee 100644 (file)
@@ -571,9 +571,7 @@ static void __init report_platform_properties(void)
        mdesc_release(hp);
 }
 
-static void __cpuinit fill_in_one_cache(cpuinfo_sparc *c,
-                                       struct mdesc_handle *hp,
-                                       u64 mp)
+static void fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_handle *hp, u64 mp)
 {
        const u64 *level = mdesc_get_property(hp, mp, "level", NULL);
        const u64 *size = mdesc_get_property(hp, mp, "size", NULL);
@@ -616,7 +614,7 @@ static void __cpuinit fill_in_one_cache(cpuinfo_sparc *c,
        }
 }
 
-static void __cpuinit mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id)
+static void mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id)
 {
        u64 a;
 
@@ -649,7 +647,7 @@ static void __cpuinit mark_core_ids(struct mdesc_handle *hp, u64 mp, int core_id
        }
 }
 
-static void __cpuinit set_core_ids(struct mdesc_handle *hp)
+static void set_core_ids(struct mdesc_handle *hp)
 {
        int idx;
        u64 mp;
@@ -674,7 +672,7 @@ static void __cpuinit set_core_ids(struct mdesc_handle *hp)
        }
 }
 
-static void __cpuinit mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id)
+static void mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id)
 {
        u64 a;
 
@@ -693,7 +691,7 @@ static void __cpuinit mark_proc_ids(struct mdesc_handle *hp, u64 mp, int proc_id
        }
 }
 
-static void __cpuinit __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name)
+static void __set_proc_ids(struct mdesc_handle *hp, const char *exec_unit_name)
 {
        int idx;
        u64 mp;
@@ -714,14 +712,14 @@ static void __cpuinit __set_proc_ids(struct mdesc_handle *hp, const char *exec_u
        }
 }
 
-static void __cpuinit set_proc_ids(struct mdesc_handle *hp)
+static void set_proc_ids(struct mdesc_handle *hp)
 {
        __set_proc_ids(hp, "exec_unit");
        __set_proc_ids(hp, "exec-unit");
 }
 
-static void __cpuinit get_one_mondo_bits(const u64 *p, unsigned int *mask,
-                                        unsigned long def, unsigned long max)
+static void get_one_mondo_bits(const u64 *p, unsigned int *mask,
+                              unsigned long def, unsigned long max)
 {
        u64 val;
 
@@ -742,8 +740,8 @@ use_default:
        *mask = ((1U << def) * 64U) - 1U;
 }
 
-static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp,
-                                    struct trap_per_cpu *tb)
+static void get_mondo_data(struct mdesc_handle *hp, u64 mp,
+                          struct trap_per_cpu *tb)
 {
        static int printed;
        const u64 *val;
@@ -769,7 +767,7 @@ static void __cpuinit get_mondo_data(struct mdesc_handle *hp, u64 mp,
        }
 }
 
-static void * __cpuinit mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask)
+static void *mdesc_iterate_over_cpus(void *(*func)(struct mdesc_handle *, u64, int, void *), void *arg, cpumask_t *mask)
 {
        struct mdesc_handle *hp = mdesc_grab();
        void *ret = NULL;
@@ -799,7 +797,8 @@ out:
        return ret;
 }
 
-static void * __cpuinit record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg)
+static void *record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid,
+                           void *arg)
 {
        ncpus_probed++;
 #ifdef CONFIG_SMP
@@ -808,7 +807,7 @@ static void * __cpuinit record_one_cpu(struct mdesc_handle *hp, u64 mp, int cpui
        return NULL;
 }
 
-void __cpuinit mdesc_populate_present_mask(cpumask_t *mask)
+void mdesc_populate_present_mask(cpumask_t *mask)
 {
        if (tlb_type != hypervisor)
                return;
@@ -841,7 +840,8 @@ void __init mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask)
        mdesc_iterate_over_cpus(check_one_pgsz, pgsz_mask, mask);
 }
 
-static void * __cpuinit fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid, void *arg)
+static void *fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpuid,
+                            void *arg)
 {
        const u64 *cfreq = mdesc_get_property(hp, mp, "clock-frequency", NULL);
        struct trap_per_cpu *tb;
@@ -890,7 +890,7 @@ static void * __cpuinit fill_in_one_cpu(struct mdesc_handle *hp, u64 mp, int cpu
        return NULL;
 }
 
-void __cpuinit mdesc_fill_in_cpu_data(cpumask_t *mask)
+void mdesc_fill_in_cpu_data(cpumask_t *mask)
 {
        struct mdesc_handle *hp;
 
index e3f2b81c23f14cfd9513b01b0b4c7365e61d9d77..a102bfba6ea866e2495e52647b845b4333d32e98 100644 (file)
@@ -39,7 +39,7 @@
 #include "kernel.h"
 #include "irq.h"
 
-volatile unsigned long cpu_callin_map[NR_CPUS] __cpuinitdata = {0,};
+volatile unsigned long cpu_callin_map[NR_CPUS] = {0,};
 
 cpumask_t smp_commenced_mask = CPU_MASK_NONE;
 
@@ -53,7 +53,7 @@ const struct sparc32_ipi_ops *sparc32_ipi_ops;
  * instruction which is much better...
  */
 
-void __cpuinit smp_store_cpu_info(int id)
+void smp_store_cpu_info(int id)
 {
        int cpu_node;
        int mid;
@@ -120,7 +120,7 @@ void cpu_panic(void)
        panic("SMP bolixed\n");
 }
 
-struct linux_prom_registers smp_penguin_ctable __cpuinitdata = { 0 };
+struct linux_prom_registers smp_penguin_ctable = { 0 };
 
 void smp_send_reschedule(int cpu)
 {
@@ -259,10 +259,10 @@ void __init smp_prepare_boot_cpu(void)
        set_cpu_possible(cpuid, true);
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
-       extern int __cpuinit smp4m_boot_one_cpu(int, struct task_struct *);
-       extern int __cpuinit smp4d_boot_one_cpu(int, struct task_struct *);
+       extern int smp4m_boot_one_cpu(int, struct task_struct *);
+       extern int smp4d_boot_one_cpu(int, struct task_struct *);
        int ret=0;
 
        switch(sparc_cpu_model) {
@@ -297,7 +297,7 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
        return ret;
 }
 
-void __cpuinit arch_cpu_pre_starting(void *arg)
+void arch_cpu_pre_starting(void *arg)
 {
        local_ops->cache_all();
        local_ops->tlb_all();
@@ -317,7 +317,7 @@ void __cpuinit arch_cpu_pre_starting(void *arg)
        }
 }
 
-void __cpuinit arch_cpu_pre_online(void *arg)
+void arch_cpu_pre_online(void *arg)
 {
        unsigned int cpuid = hard_smp_processor_id();
 
@@ -344,7 +344,7 @@ void __cpuinit arch_cpu_pre_online(void *arg)
        }
 }
 
-void __cpuinit sparc_start_secondary(void *arg)
+void sparc_start_secondary(void *arg)
 {
        unsigned int cpu;
 
@@ -375,7 +375,7 @@ void __cpuinit sparc_start_secondary(void *arg)
        BUG();
 }
 
-void __cpuinit smp_callin(void)
+void smp_callin(void)
 {
        sparc_start_secondary(NULL);
 }
index 77539eda928c93d05683d57612f9edec907e48e6..e142545244f2767c1baef029a1b3c3f7ccf0a8b3 100644 (file)
@@ -87,7 +87,7 @@ extern void setup_sparc64_timer(void);
 
 static volatile unsigned long callin_flag = 0;
 
-void __cpuinit smp_callin(void)
+void smp_callin(void)
 {
        int cpuid = hard_smp_processor_id();
 
@@ -281,7 +281,8 @@ static unsigned long kimage_addr_to_ra(void *p)
        return kern_base + (val - KERNBASE);
 }
 
-static void __cpuinit ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg, void **descrp)
+static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg,
+                               void **descrp)
 {
        extern unsigned long sparc64_ttable_tl0;
        extern unsigned long kern_locked_tte_data;
@@ -342,7 +343,7 @@ extern unsigned long sparc64_cpu_startup;
  */
 static struct thread_info *cpu_new_thread = NULL;
 
-static int __cpuinit smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle)
+static int smp_boot_one_cpu(unsigned int cpu, struct task_struct *idle)
 {
        unsigned long entry =
                (unsigned long)(&sparc64_cpu_startup);
@@ -1266,7 +1267,7 @@ void smp_fill_in_sib_core_maps(void)
        }
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        int ret = smp_boot_one_cpu(cpu, tidle);
 
index c9eb82f23d92843a7878bac4b60f7cd766b54420..d5c319553fd0874903515106920d283c066d8fbd 100644 (file)
@@ -50,7 +50,7 @@ static inline void show_leds(int cpuid)
                              "i" (ASI_M_CTL));
 }
 
-void __cpuinit sun4d_cpu_pre_starting(void *arg)
+void sun4d_cpu_pre_starting(void *arg)
 {
        int cpuid = hard_smp_processor_id();
 
@@ -62,7 +62,7 @@ void __cpuinit sun4d_cpu_pre_starting(void *arg)
        cc_set_imsk((cc_get_imsk() & ~0x8000) | 0x4000);
 }
 
-void __cpuinit sun4d_cpu_pre_online(void *arg)
+void sun4d_cpu_pre_online(void *arg)
 {
        unsigned long flags;
        int cpuid;
@@ -118,7 +118,7 @@ void __init smp4d_boot_cpus(void)
        local_ops->cache_all();
 }
 
-int __cpuinit smp4d_boot_one_cpu(int i, struct task_struct *idle)
+int smp4d_boot_one_cpu(int i, struct task_struct *idle)
 {
        unsigned long *entry = &sun4d_cpu_startup;
        int timeout;
index 8a65f158153ddcc26deb2cb820e6387d775cd079..d3408e72d20c0a9b4a834735eadffe5208224fb1 100644 (file)
@@ -34,11 +34,11 @@ swap_ulong(volatile unsigned long *ptr, unsigned long val)
        return val;
 }
 
-void __cpuinit sun4m_cpu_pre_starting(void *arg)
+void sun4m_cpu_pre_starting(void *arg)
 {
 }
 
-void __cpuinit sun4m_cpu_pre_online(void *arg)
+void sun4m_cpu_pre_online(void *arg)
 {
        int cpuid = hard_smp_processor_id();
 
@@ -75,7 +75,7 @@ void __init smp4m_boot_cpus(void)
        local_ops->cache_all();
 }
 
-int __cpuinit smp4m_boot_one_cpu(int i, struct task_struct *idle)
+int smp4m_boot_one_cpu(int i, struct task_struct *idle)
 {
        unsigned long *entry = &sun4m_cpu_startup;
        int timeout;
index 654e8aad3bbef81f742beb4c2e88468207e930a5..c21c673e5f7cde71cdeca0c4b48bf565df96bfd7 100644 (file)
@@ -246,7 +246,7 @@ static void unregister_cpu_online(unsigned int cpu)
 }
 #endif
 
-static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
+static int sysfs_cpu_notify(struct notifier_block *self,
                                      unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned int)(long)hcpu;
@@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
+static struct notifier_block sysfs_cpu_nb = {
        .notifier_call  = sysfs_cpu_notify,
 };
 
index 6cdb08cdabf092459d209f3a1f2f52ede68fb8d1..76dcbd3c988aed9445de17442e8cb1076ef5cc49 100644 (file)
@@ -18,7 +18,6 @@
        .globl sun4m_cpu_startup
        .globl sun4d_cpu_startup
 
-       __CPUINIT
        .align 4
 
 /* When we start up a cpu for the first time it enters this routine.
@@ -94,7 +93,6 @@ smp_panic:
 /* CPUID in bootbus can be found at PA 0xff0140000 */
 #define SUN4D_BOOTBUS_CPUID    0xf0140000
 
-       __CPUINIT
        .align  4
 
 sun4d_cpu_startup:
@@ -146,7 +144,6 @@ sun4d_cpu_startup:
 
        b,a     smp_panic
 
-       __CPUINIT
        .align  4
         .global leon_smp_cpu_startup, smp_penguin_ctable
 
index 2e973a26fbda9cd9ddbc2c30017fc316eb691af4..e0b1e13a073610da16810288dab254c43b9feb49 100644 (file)
@@ -32,13 +32,11 @@ itlb_load:
 dtlb_load:
        .asciz  "SUNW,dtlb-load"
 
-       /* XXX __cpuinit this thing XXX */
 #define TRAMP_STACK_SIZE       1024
        .align  16
 tramp_stack:
        .skip   TRAMP_STACK_SIZE
 
-       __CPUINIT
        .align          8
        .globl          sparc64_cpu_startup, sparc64_cpu_startup_end
 sparc64_cpu_startup:
index a9c42a7ffb6a611a4b39129d3d698a2e710b863e..ed82edad1a392864dd3919ce2010b8a0474e8f15 100644 (file)
@@ -1694,7 +1694,7 @@ static void __init sun4v_ktsb_init(void)
 #endif
 }
 
-void __cpuinit sun4v_ktsb_register(void)
+void sun4v_ktsb_register(void)
 {
        unsigned long pa, ret;
 
index 036c2797dece1c6443894b9e3ce95c066e4142fe..5d721df48a72d10dfe56095e0a8cf67d258fd7f9 100644 (file)
@@ -858,7 +858,7 @@ static void __init map_kernel(void)
        }
 }
 
-void (*poke_srmmu)(void) __cpuinitdata = NULL;
+void (*poke_srmmu)(void) = NULL;
 
 extern unsigned long bootmem_init(unsigned long *pages_avail);
 
@@ -1055,7 +1055,7 @@ static void __init init_vac_layout(void)
               (int)vac_cache_size, (int)vac_line_size);
 }
 
-static void __cpuinit poke_hypersparc(void)
+static void poke_hypersparc(void)
 {
        volatile unsigned long clear;
        unsigned long mreg = srmmu_get_mmureg();
@@ -1107,7 +1107,7 @@ static void __init init_hypersparc(void)
        hypersparc_setup_blockops();
 }
 
-static void __cpuinit poke_swift(void)
+static void poke_swift(void)
 {
        unsigned long mreg;
 
@@ -1287,7 +1287,7 @@ static void turbosparc_flush_tlb_page(struct vm_area_struct *vma, unsigned long
 }
 
 
-static void __cpuinit poke_turbosparc(void)
+static void poke_turbosparc(void)
 {
        unsigned long mreg = srmmu_get_mmureg();
        unsigned long ccreg;
@@ -1350,7 +1350,7 @@ static void __init init_turbosparc(void)
        poke_srmmu = poke_turbosparc;
 }
 
-static void __cpuinit poke_tsunami(void)
+static void poke_tsunami(void)
 {
        unsigned long mreg = srmmu_get_mmureg();
 
@@ -1391,7 +1391,7 @@ static void __init init_tsunami(void)
        tsunami_setup_blockops();
 }
 
-static void __cpuinit poke_viking(void)
+static void poke_viking(void)
 {
        unsigned long mreg = srmmu_get_mmureg();
        static int smp_catch;
index 31b87bf8c027e201fbc853e46bd5b99cbac864d6..4f8f3d619c4a652b428029f0bc2c0362775d79dd 100644 (file)
@@ -387,6 +387,27 @@ int gxio_mpipe_link_close_aux(gxio_mpipe_context_t * context, int mac)
 
 EXPORT_SYMBOL(gxio_mpipe_link_close_aux);
 
+struct link_set_attr_aux_param {
+       int mac;
+       uint32_t attr;
+       int64_t val;
+};
+
+int gxio_mpipe_link_set_attr_aux(gxio_mpipe_context_t * context, int mac,
+                                uint32_t attr, int64_t val)
+{
+       struct link_set_attr_aux_param temp;
+       struct link_set_attr_aux_param *params = &temp;
+
+       params->mac = mac;
+       params->attr = attr;
+       params->val = val;
+
+       return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
+                            sizeof(*params), GXIO_MPIPE_OP_LINK_SET_ATTR_AUX);
+}
+
+EXPORT_SYMBOL(gxio_mpipe_link_set_attr_aux);
 
 struct get_timestamp_aux_param {
        uint64_t sec;
@@ -454,6 +475,51 @@ int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context,
 
 EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_aux);
 
+struct adjust_timestamp_freq_param {
+       int32_t ppb;
+};
+
+int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t * context,
+                                    int32_t ppb)
+{
+       struct adjust_timestamp_freq_param temp;
+       struct adjust_timestamp_freq_param *params = &temp;
+
+       params->ppb = ppb;
+
+       return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
+                            sizeof(*params),
+                            GXIO_MPIPE_OP_ADJUST_TIMESTAMP_FREQ);
+}
+
+EXPORT_SYMBOL(gxio_mpipe_adjust_timestamp_freq);
+
+struct config_edma_ring_blks_param {
+       unsigned int ering;
+       unsigned int max_blks;
+       unsigned int min_snf_blks;
+       unsigned int db;
+};
+
+int gxio_mpipe_config_edma_ring_blks(gxio_mpipe_context_t * context,
+                                    unsigned int ering, unsigned int max_blks,
+                                    unsigned int min_snf_blks, unsigned int db)
+{
+       struct config_edma_ring_blks_param temp;
+       struct config_edma_ring_blks_param *params = &temp;
+
+       params->ering = ering;
+       params->max_blks = max_blks;
+       params->min_snf_blks = min_snf_blks;
+       params->db = db;
+
+       return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
+                            sizeof(*params),
+                            GXIO_MPIPE_OP_CONFIG_EDMA_RING_BLKS);
+}
+
+EXPORT_SYMBOL(gxio_mpipe_config_edma_ring_blks);
+
 struct arm_pollfd_param {
        union iorpc_pollfd pollfd;
 };
index d0254aa60cbac3966e0f5c6a3ce9d6bb2995c907..64883aabeb9c19d2ce3d5e72f4c4040813c33e83 100644 (file)
 #include "gxio/iorpc_mpipe_info.h"
 
 
+struct instance_aux_param {
+       _gxio_mpipe_link_name_t name;
+};
+
+int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context,
+                                _gxio_mpipe_link_name_t name)
+{
+       struct instance_aux_param temp;
+       struct instance_aux_param *params = &temp;
+
+       params->name = name;
+
+       return hv_dev_pwrite(context->fd, 0, (HV_VirtAddr) params,
+                            sizeof(*params), GXIO_MPIPE_INFO_OP_INSTANCE_AUX);
+}
+
+EXPORT_SYMBOL(gxio_mpipe_info_instance_aux);
+
 struct enumerate_aux_param {
        _gxio_mpipe_link_name_t name;
        _gxio_mpipe_link_mac_t mac;
index e71c63390acc03b35ed8678fa70d5c959aefee56..5301a9ffbae10917d1a7bd38ffd0ea136d8def6c 100644 (file)
@@ -36,8 +36,14 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
        int fd;
        int i;
 
+       if (mpipe_index >= GXIO_MPIPE_INSTANCE_MAX)
+               return -EINVAL;
+
        snprintf(file, sizeof(file), "mpipe/%d/iorpc", mpipe_index);
        fd = hv_dev_open((HV_VirtAddr) file, 0);
+
+       context->fd = fd;
+
        if (fd < 0) {
                if (fd >= GXIO_ERR_MIN && fd <= GXIO_ERR_MAX)
                        return fd;
@@ -45,8 +51,6 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
                        return -ENODEV;
        }
 
-       context->fd = fd;
-
        /* Map in the MMIO space. */
        context->mmio_cfg_base = (void __force *)
                iorpc_ioremap(fd, HV_MPIPE_CONFIG_MMIO_OFFSET,
@@ -64,12 +68,15 @@ int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
        for (i = 0; i < 8; i++)
                context->__stacks.stacks[i] = 255;
 
+       context->instance = mpipe_index;
+
        return 0;
 
       fast_failed:
        iounmap((void __force __iomem *)(context->mmio_cfg_base));
       cfg_failed:
        hv_dev_close(context->fd);
+       context->fd = -1;
        return -ENODEV;
 }
 
@@ -383,7 +390,7 @@ EXPORT_SYMBOL_GPL(gxio_mpipe_iqueue_init);
 
 int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
                           gxio_mpipe_context_t *context,
-                          unsigned int edma_ring_id,
+                          unsigned int ering,
                           unsigned int channel,
                           void *mem, unsigned int mem_size,
                           unsigned int mem_flags)
@@ -394,7 +401,7 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
        /* Offset used to read number of completed commands. */
        MPIPE_EDMA_POST_REGION_ADDR_t offset;
 
-       int result = gxio_mpipe_init_edma_ring(context, edma_ring_id, channel,
+       int result = gxio_mpipe_init_edma_ring(context, ering, channel,
                                               mem, mem_size, mem_flags);
        if (result < 0)
                return result;
@@ -405,7 +412,7 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
        offset.region =
                MPIPE_MMIO_ADDR__REGION_VAL_EDMA -
                MPIPE_MMIO_ADDR__REGION_VAL_IDMA;
-       offset.ring = edma_ring_id;
+       offset.ring = ering;
 
        __gxio_dma_queue_init(&equeue->dma_queue,
                              context->mmio_fast_base + offset.word,
@@ -413,6 +420,9 @@ int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
        equeue->edescs = mem;
        equeue->mask_num_entries = num_entries - 1;
        equeue->log2_num_entries = __builtin_ctz(num_entries);
+       equeue->context = context;
+       equeue->ering = ering;
+       equeue->channel = channel;
 
        return 0;
 }
@@ -493,6 +503,20 @@ static gxio_mpipe_context_t *_gxio_get_link_context(void)
        return contextp;
 }
 
+int gxio_mpipe_link_instance(const char *link_name)
+{
+       _gxio_mpipe_link_name_t name;
+       gxio_mpipe_context_t *context = _gxio_get_link_context();
+
+       if (!context)
+               return GXIO_ERR_NO_DEVICE;
+
+       strncpy(name.name, link_name, sizeof(name.name));
+       name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
+
+       return gxio_mpipe_info_instance_aux(context, name);
+}
+
 int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)
 {
        int rv;
@@ -543,3 +567,12 @@ int gxio_mpipe_link_close(gxio_mpipe_link_t *link)
 }
 
 EXPORT_SYMBOL_GPL(gxio_mpipe_link_close);
+
+int gxio_mpipe_link_set_attr(gxio_mpipe_link_t *link, uint32_t attr,
+                            int64_t val)
+{
+       return gxio_mpipe_link_set_attr_aux(link->context, link->mac, attr,
+                                           val);
+}
+
+EXPORT_SYMBOL_GPL(gxio_mpipe_link_set_attr);
index 9d50fce1b1a7961aa15b6409ecdc587fce0959fa..fdd07f88cfd7124458a4d31fb1a098764e15bb9a 100644 (file)
 #define GXIO_MPIPE_OP_REGISTER_CLIENT_MEMORY IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1210)
 #define GXIO_MPIPE_OP_LINK_OPEN_AUX    IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1211)
 #define GXIO_MPIPE_OP_LINK_CLOSE_AUX   IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1212)
+#define GXIO_MPIPE_OP_LINK_SET_ATTR_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1213)
 
-#define GXIO_MPIPE_OP_GET_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x121e)
-#define GXIO_MPIPE_OP_SET_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x121f)
-#define GXIO_MPIPE_OP_ADJUST_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x1220)
+#define GXIO_MPIPE_OP_GET_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x121e)
+#define GXIO_MPIPE_OP_SET_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x121f)
+#define GXIO_MPIPE_OP_ADJUST_TIMESTAMP_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1220)
+#define GXIO_MPIPE_OP_CONFIG_EDMA_RING_BLKS IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1221)
+#define GXIO_MPIPE_OP_ADJUST_TIMESTAMP_FREQ IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1222)
 #define GXIO_MPIPE_OP_ARM_POLLFD       IORPC_OPCODE(IORPC_FORMAT_KERNEL_POLLFD, 0x9000)
 #define GXIO_MPIPE_OP_CLOSE_POLLFD     IORPC_OPCODE(IORPC_FORMAT_KERNEL_POLLFD, 0x9001)
 #define GXIO_MPIPE_OP_GET_MMIO_BASE    IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
@@ -114,6 +117,8 @@ int gxio_mpipe_link_open_aux(gxio_mpipe_context_t * context,
 
 int gxio_mpipe_link_close_aux(gxio_mpipe_context_t * context, int mac);
 
+int gxio_mpipe_link_set_attr_aux(gxio_mpipe_context_t * context, int mac,
+                                uint32_t attr, int64_t val);
 
 int gxio_mpipe_get_timestamp_aux(gxio_mpipe_context_t * context, uint64_t * sec,
                                 uint64_t * nsec, uint64_t * cycles);
@@ -124,6 +129,9 @@ int gxio_mpipe_set_timestamp_aux(gxio_mpipe_context_t * context, uint64_t sec,
 int gxio_mpipe_adjust_timestamp_aux(gxio_mpipe_context_t * context,
                                    int64_t nsec);
 
+int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t * context,
+                                    int32_t ppb);
+
 int gxio_mpipe_arm_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie);
 
 int gxio_mpipe_close_pollfd(gxio_mpipe_context_t * context, int pollfd_cookie);
index 0bcf3f71ce8be0150237efde998b1ac8998b9512..476c5e5ca22cfe53714e699b667abf2995a192de 100644 (file)
 #include <asm/pgtable.h>
 
 
+#define GXIO_MPIPE_INFO_OP_INSTANCE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1250)
 #define GXIO_MPIPE_INFO_OP_ENUMERATE_AUX IORPC_OPCODE(IORPC_FORMAT_NONE, 0x1251)
 #define GXIO_MPIPE_INFO_OP_GET_MMIO_BASE IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8000)
 #define GXIO_MPIPE_INFO_OP_CHECK_MMIO_OFFSET IORPC_OPCODE(IORPC_FORMAT_NONE_NOUSER, 0x8001)
 
 
+int gxio_mpipe_info_instance_aux(gxio_mpipe_info_context_t * context,
+                                _gxio_mpipe_link_name_t name);
+
 int gxio_mpipe_info_enumerate_aux(gxio_mpipe_info_context_t * context,
                                  unsigned int idx,
                                  _gxio_mpipe_link_name_t * name,
index b74f470ed11e58c9f8515ee50347db59ff9027e5..e37cf4f0cffd42a14f3d392d9701ef8a4da746f5 100644 (file)
@@ -220,6 +220,13 @@ typedef MPIPE_PDESC_t gxio_mpipe_idesc_t;
  */
 typedef MPIPE_EDMA_DESC_t gxio_mpipe_edesc_t;
 
+/*
+ * Max # of mpipe instances. 2 currently.
+ */
+#define GXIO_MPIPE_INSTANCE_MAX  HV_MPIPE_INSTANCE_MAX
+
+#define NR_MPIPE_MAX   GXIO_MPIPE_INSTANCE_MAX
+
 /* Get the "va" field from an "idesc".
  *
  * This is the address at which the ingress hardware copied the first
@@ -311,6 +318,9 @@ typedef struct {
        /* File descriptor for calling up to Linux (and thus the HV). */
        int fd;
 
+       /* Corresponding mpipe instance #. */
+       int instance;
+
        /* The VA at which configuration registers are mapped. */
        char *mmio_cfg_base;
 
@@ -810,7 +820,7 @@ extern int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t *context,
 /* Initialize an eDMA ring, using the given memory and size.
  *
  * @param context An initialized mPIPE context.
- * @param ring The eDMA ring index.
+ * @param ering The eDMA ring index.
  * @param channel The channel to use.  This must be one of the channels
  * associated with the context's set of open links.
  * @param mem A physically contiguous region of memory to be filled
@@ -823,10 +833,37 @@ extern int gxio_mpipe_alloc_edma_rings(gxio_mpipe_context_t *context,
  * ::GXIO_ERR_INVAL_MEMORY_SIZE on failure.
  */
 extern int gxio_mpipe_init_edma_ring(gxio_mpipe_context_t *context,
-                                    unsigned int ring, unsigned int channel,
+                                    unsigned int ering, unsigned int channel,
                                     void *mem, size_t mem_size,
                                     unsigned int mem_flags);
 
+/* Set the "max_blks", "min_snf_blks", and "db" fields of
+ * ::MPIPE_EDMA_RG_INIT_DAT_THRESH_t for a given edma ring.
+ *
+ * The global pool of dynamic blocks will be automatically adjusted.
+ *
+ * This function should not be called after any egress has been done
+ * on the edma ring.
+ *
+ * Most applications should just use gxio_mpipe_equeue_set_snf_size().
+ *
+ * @param context An initialized mPIPE context.
+ * @param ering The eDMA ring index.
+ * @param max_blks The number of blocks to dedicate to the ring
+ * (normally min_snf_blks + 1).  Must be greater than min_snf_blocks.
+ * @param min_snf_blks The number of blocks which must be stored
+ * prior to starting to send the packet (normally 12).
+ * @param db Whether to allow use of dynamic blocks by the ring
+ * (normally 1).
+ *
+ * @return 0 on success, negative on error.
+ */
+extern int gxio_mpipe_config_edma_ring_blks(gxio_mpipe_context_t *context,
+                                           unsigned int ering,
+                                           unsigned int max_blks,
+                                           unsigned int min_snf_blks,
+                                           unsigned int db);
+
 /*****************************************************************
  *                      Classifier Program                        *
  ******************************************************************/
@@ -1288,15 +1325,39 @@ typedef struct {
        /* The log2() of the number of entries. */
        unsigned long log2_num_entries;
 
+       /* The context. */
+       gxio_mpipe_context_t *context;
+
+       /* The ering. */
+       unsigned int ering;
+
+       /* The channel. */
+       unsigned int channel;
+
 } gxio_mpipe_equeue_t;
 
 /* Initialize an "equeue".
  *
- * Takes the equeue plus the same args as gxio_mpipe_init_edma_ring().
+ * This function uses gxio_mpipe_init_edma_ring() to initialize the
+ * underlying edma_ring using the provided arguments.
+ *
+ * @param equeue An egress queue to be initialized.
+ * @param context An initialized mPIPE context.
+ * @param ering The eDMA ring index.
+ * @param channel The channel to use.  This must be one of the channels
+ * associated with the context's set of open links.
+ * @param mem A physically contiguous region of memory to be filled
+ * with a ring of ::gxio_mpipe_edesc_t structures.
+ * @param mem_size Number of bytes in the ring.  Must be 512, 2048,
+ * 8192 or 65536, times 16 (i.e. sizeof(gxio_mpipe_edesc_t)).
+ * @param mem_flags ::gxio_mpipe_mem_flags_e memory flags.
+ *
+ * @return 0 on success, ::GXIO_MPIPE_ERR_BAD_EDMA_RING or
+ * ::GXIO_ERR_INVAL_MEMORY_SIZE on failure.
  */
 extern int gxio_mpipe_equeue_init(gxio_mpipe_equeue_t *equeue,
                                  gxio_mpipe_context_t *context,
-                                 unsigned int edma_ring_id,
+                                 unsigned int ering,
                                  unsigned int channel,
                                  void *mem, unsigned int mem_size,
                                  unsigned int mem_flags);
@@ -1494,6 +1555,37 @@ static inline int gxio_mpipe_equeue_is_complete(gxio_mpipe_equeue_t *equeue,
                                            completion_slot, update);
 }
 
+/* Set the snf (store and forward) size for an equeue.
+ *
+ * The snf size for an equeue defaults to 1536, and encodes the size
+ * of the largest packet for which egress is guaranteed to avoid
+ * transmission underruns and/or corrupt checksums under heavy load.
+ *
+ * The snf size affects a global resource pool which cannot support,
+ * for example, all 24 equeues each requesting an snf size of 8K.
+ *
+ * To ensure that jumbo packets can be egressed properly, the snf size
+ * should be set to the size of the largest possible packet, which
+ * will usually be limited by the size of the app's largest buffer.
+ *
+ * This is a convenience wrapper around
+ * gxio_mpipe_config_edma_ring_blks().
+ *
+ * This function should not be called after any egress has been done
+ * on the equeue.
+ *
+ * @param equeue An egress queue initialized via gxio_mpipe_equeue_init().
+ * @param size The snf size, in bytes.
+ * @return Zero on success, negative error otherwise.
+ */
+static inline int gxio_mpipe_equeue_set_snf_size(gxio_mpipe_equeue_t *equeue,
+                                                size_t size)
+{
+       int blks = (size + 127) / 128;
+       return gxio_mpipe_config_edma_ring_blks(equeue->context, equeue->ering,
+                                               blks + 1, blks, 1);
+}
+
 /*****************************************************************
  *                        Link Management                         *
  ******************************************************************/
@@ -1634,6 +1726,24 @@ typedef struct {
        uint8_t mac;
 } gxio_mpipe_link_t;
 
+/* Translate a link name to the instance number of the mPIPE shim which is
+ *  connected to that link.  This call does not verify whether the link is
+ *  currently available, and does not reserve any link resources;
+ *  gxio_mpipe_link_open() must be called to perform those functions.
+ *
+ *  Typically applications will call this function to translate a link name
+ *  to an mPIPE instance number; call gxio_mpipe_init(), passing it that
+ *  instance number, to initialize the mPIPE shim; and then call
+ *  gxio_mpipe_link_open(), passing it the same link name plus the mPIPE
+ *  context, to configure the link.
+ *
+ * @param link_name Name of the link; see @ref gxio_mpipe_link_names.
+ * @return The mPIPE instance number which is associated with the named
+ *  link, or a negative error code (::GXIO_ERR_NO_DEVICE) if the link does
+ *  not exist.
+ */
+extern int gxio_mpipe_link_instance(const char *link_name);
+
 /* Retrieve one of this system's legal link names, and its MAC address.
  *
  * @param index Link name index.  If a system supports N legal link names,
@@ -1697,6 +1807,17 @@ static inline int gxio_mpipe_link_channel(gxio_mpipe_link_t *link)
        return link->channel;
 }
 
+/* Set a link attribute.
+ *
+ * @param link A properly initialized link state object.
+ * @param attr An attribute from the set of @ref gxio_mpipe_link_attrs.
+ * @param val New value of the attribute.
+ * @return 0 if the attribute was successfully set, or a negative error
+ *  code.
+ */
+extern int gxio_mpipe_link_set_attr(gxio_mpipe_link_t *link, uint32_t attr,
+                                   int64_t val);
+
 ///////////////////////////////////////////////////////////////////
 //                             Timestamp                         //
 ///////////////////////////////////////////////////////////////////
@@ -1733,4 +1854,18 @@ extern int gxio_mpipe_set_timestamp(gxio_mpipe_context_t *context,
 extern int gxio_mpipe_adjust_timestamp(gxio_mpipe_context_t *context,
                                       int64_t delta);
 
+/** Adjust the mPIPE timestamp clock frequency.
+ *
+ * @param context An initialized mPIPE context.
+ * @param ppb A 32-bit signed PPB (Parts Per Billion) value to adjust.
+ * The absolute value of ppb must be less than or equal to 1000000000.
+ * Values less than about 30000 will generally cause a GXIO_ERR_INVAL
+ * return due to the granularity of the hardware that converts reference
+ * clock cycles into seconds and nanoseconds.
+ * @return If the call was successful, zero; otherwise, a negative error
+ *  code.
+ */
+extern int gxio_mpipe_adjust_timestamp_freq(gxio_mpipe_context_t* context,
+                                            int32_t ppb);
+
 #endif /* !_GXIO_MPIPE_H_ */
index 6cdae3bf046efb8e8cfd9e815ef6a2856b848593..c97e416dd963b585c8907097408fa53aebf55bcb 100644 (file)
@@ -23,6 +23,9 @@
 #include <arch/mpipe_constants.h>
 
 
+/** Number of mPIPE instances supported */
+#define HV_MPIPE_INSTANCE_MAX   (2)
+
 /** Number of buffer stacks (32). */
 #define HV_MPIPE_NUM_BUFFER_STACKS \
   (MPIPE_MMIO_INIT_DAT_GX36_1__BUFFER_STACK_MASK_WIDTH)
index 02e62806501256ad63f322d26461bd34f8bcc4e9..3ccf2cd7182eb73b8789489f30a6786cb4ec25d7 100644 (file)
@@ -220,7 +220,7 @@ void __init init_IRQ(void)
        ipi_init();
 }
 
-void __cpuinit setup_irq_regs(void)
+void setup_irq_regs(void)
 {
        /* Enable interrupt delivery. */
        unmask_irqs(~0UL);
index 0858ee6b520f6acf4c23b3a27c8491267919b943..00331af9525dcf52c990f3ee30abb13d367d7889 100644 (file)
@@ -25,7 +25,7 @@
 /* All messages are stored here */
 static DEFINE_PER_CPU(HV_MsgState, msg_state);
 
-void __cpuinit init_messaging(void)
+void init_messaging(void)
 {
        /* Allocate storage for messages in kernel space */
        HV_MsgState *state = &__get_cpu_var(msg_state);
index 68b542677f6ab51006e567c10023a132145fcdb4..eceb8344280f27ee1906dbfb52d150d836ff4e9c 100644 (file)
@@ -58,8 +58,8 @@ struct pglist_data node_data[MAX_NUMNODES] __read_mostly;
 EXPORT_SYMBOL(node_data);
 
 /* Information on the NUMA nodes that we compute early */
-unsigned long __cpuinitdata node_start_pfn[MAX_NUMNODES];
-unsigned long __cpuinitdata node_end_pfn[MAX_NUMNODES];
+unsigned long node_start_pfn[MAX_NUMNODES];
+unsigned long node_end_pfn[MAX_NUMNODES];
 unsigned long __initdata node_memmap_pfn[MAX_NUMNODES];
 unsigned long __initdata node_percpu_pfn[MAX_NUMNODES];
 unsigned long __initdata node_free_pfn[MAX_NUMNODES];
@@ -84,7 +84,7 @@ unsigned long __initdata boot_pc = (unsigned long)start_kernel;
 
 #ifdef CONFIG_HIGHMEM
 /* Page frame index of end of lowmem on each controller. */
-unsigned long __cpuinitdata node_lowmem_end_pfn[MAX_NUMNODES];
+unsigned long node_lowmem_end_pfn[MAX_NUMNODES];
 
 /* Number of pages that can be mapped into lowmem. */
 static unsigned long __initdata mappable_physpages;
@@ -290,7 +290,7 @@ static void *__init setup_pa_va_mapping(void)
  * This is up to 4 mappings for lowmem, one mapping per memory
  * controller, plus one for our text segment.
  */
-static void __cpuinit store_permanent_mappings(void)
+static void store_permanent_mappings(void)
 {
        int i;
 
@@ -935,7 +935,7 @@ subsys_initcall(topology_init);
  * So the values we set up here in the hypervisor may be overridden on
  * the boot cpu as arguments are parsed.
  */
-static __cpuinit void init_super_pages(void)
+static void init_super_pages(void)
 {
 #ifdef CONFIG_HUGETLB_SUPER_PAGES
        int i;
@@ -950,7 +950,7 @@ static __cpuinit void init_super_pages(void)
  *
  * Called from setup_arch() on the boot cpu, or online_secondary().
  */
-void __cpuinit setup_cpu(int boot)
+void setup_cpu(int boot)
 {
        /* The boot cpu sets up its permanent mappings much earlier. */
        if (!boot)
index 44bab29bf2f3a540fddff97500e81bf7fbe44cca..a535655b7089676756ed847bc93ad9aed7a07cea 100644 (file)
@@ -133,14 +133,14 @@ static __init int reset_init_affinity(void)
 }
 late_initcall(reset_init_affinity);
 
-static struct cpumask cpu_started __cpuinitdata;
+static struct cpumask cpu_started;
 
 /*
  * Activate a secondary processor.  Very minimal; don't add anything
  * to this path without knowing what you're doing, since SMP booting
  * is pretty fragile.
  */
-static void __cpuinit start_secondary(void)
+static void start_secondary(void)
 {
        int cpuid = smp_processor_id();
 
@@ -183,7 +183,7 @@ static void __cpuinit start_secondary(void)
 /*
  * Bring a secondary processor online.
  */
-void __cpuinit online_secondary(void)
+void online_secondary(void)
 {
        /*
         * low-memory mappings have been cleared, flush them from
@@ -210,7 +210,7 @@ void __cpuinit online_secondary(void)
        cpu_startup_entry(CPUHP_ONLINE);
 }
 
-int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        /* Wait 5s total for all CPUs for them to come online */
        static int timeout;
index 5ac397ec6986cc3d8b132df2f4fd467fd69a7d44..7c353d8c2da926c9b057616db17f269fd6981f66 100644 (file)
@@ -159,7 +159,7 @@ static DEFINE_PER_CPU(struct clock_event_device, tile_timer) = {
        .set_mode = tile_timer_set_mode,
 };
 
-void __cpuinit setup_tile_timer(void)
+void setup_tile_timer(void)
 {
        struct clock_event_device *evt = &__get_cpu_var(tile_timer);
 
index 4febacd1a8a1a3dee2c24e3b3447081e7ca94ebb..29b0301c18aab26f2a613d397da9856a8d1eec3b 100644 (file)
@@ -45,10 +45,12 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
 }
 
 static inline void
-tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
+tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
-       tlb->fullmm = full_mm_flush;
+       tlb->start = start;
+       tlb->end = end;
+       tlb->fullmm = !(start | (end+1));
 
        init_tlb_gather(tlb);
 }
index e584e40ee8320f62e82e67abe6230a40ac75b19d..f2ca5702a4e2ae2b418382712c93aeed03736450 100644 (file)
@@ -6,13 +6,13 @@
 #ifndef __FRAME_KERN_H_
 #define __FRAME_KERN_H_
 
-extern int setup_signal_stack_sc(unsigned long stack_top, int sig, 
+extern int setup_signal_stack_sc(unsigned long stack_top, int sig,
                                 struct k_sigaction *ka,
-                                struct pt_regs *regs, 
+                                struct pt_regs *regs,
                                 sigset_t *mask);
-extern int setup_signal_stack_si(unsigned long stack_top, int sig, 
+extern int setup_signal_stack_si(unsigned long stack_top, int sig,
                                 struct k_sigaction *ka,
-                                struct pt_regs *regs, siginfo_t *info, 
+                                struct pt_regs *regs, struct siginfo *info,
                                 sigset_t *mask);
 
 #endif
index 3e831b3fd07bb4f547db12eadb6ccecb99df86c9..f57e02e7910f66a6346d7454f7fd612ec6d0735f 100644 (file)
@@ -19,7 +19,7 @@ EXPORT_SYMBOL(unblock_signals);
  * OK, we're invoking a handler
  */
 static void handle_signal(struct pt_regs *regs, unsigned long signr,
-                        struct k_sigaction *ka, siginfo_t *info)
+                        struct k_sigaction *ka, struct siginfo *info)
 {
        sigset_t *oldset = sigmask_to_save();
        int singlestep = 0;
@@ -71,7 +71,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
 static int kern_do_signal(struct pt_regs *regs)
 {
        struct k_sigaction ka_copy;
-       siginfo_t info;
+       struct siginfo info;
        int sig, handled_sig = 0;
 
        while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
index ff03067a3b1496acf3725019b31ed17020ea5233..007d5503f49b79bfccbfbe842bbe630fbc625ac1 100644 (file)
@@ -123,7 +123,7 @@ void uml_setup_stubs(struct mm_struct *mm)
        /* dup_mmap already holds mmap_sem */
        err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
                                      VM_READ | VM_MAYREAD | VM_EXEC |
-                                     VM_MAYEXEC | VM_DONTCOPY,
+                                     VM_MAYEXEC | VM_DONTCOPY | VM_PFNMAP,
                                      mm->context.stub_pages);
        if (err) {
                printk(KERN_ERR "install_special_mapping returned %d\n", err);
index 1d3e0c17340b1e12442e5e61a50ce05bd5a6c1b4..4ffb644d6c079a441628309b4ff0375b49e1f515 100644 (file)
@@ -254,6 +254,6 @@ int strnlen_user(const void __user *str, int len)
        n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
        if (n == 0)
                return count + 1;
-       return -EFAULT;
+       return 0;
 }
 EXPORT_SYMBOL(strnlen_user);
index ba4398056fe904d3fc85e024eee8687151cd5804..3c4af77e51a2f9047ad603fe1032334111d08e9f 100644 (file)
@@ -52,6 +52,25 @@ static void __init find_tempdir(void)
        strcat(tempdir, "/");
 }
 
+/*
+ * Remove bytes from the front of the buffer and refill it so that if there's a
+ * partial string that we care about, it will be completed, and we can recognize
+ * it.
+ */
+static int pop(int fd, char *buf, size_t size, size_t npop)
+{
+       ssize_t n;
+       size_t len = strlen(&buf[npop]);
+
+       memmove(buf, &buf[npop], len + 1);
+       n = read(fd, &buf[len], size - len - 1);
+       if (n < 0)
+               return -errno;
+
+       buf[len + n] = '\0';
+       return 1;
+}
+
 /*
  * This will return 1, with the first character in buf being the
  * character following the next instance of c in the file.  This will
@@ -61,7 +80,6 @@ static void __init find_tempdir(void)
 static int next(int fd, char *buf, size_t size, char c)
 {
        ssize_t n;
-       size_t len;
        char *ptr;
 
        while ((ptr = strchr(buf, c)) == NULL) {
@@ -74,20 +92,129 @@ static int next(int fd, char *buf, size_t size, char c)
                buf[n] = '\0';
        }
 
-       ptr++;
-       len = strlen(ptr);
-       memmove(buf, ptr, len + 1);
+       return pop(fd, buf, size, ptr - buf + 1);
+}
+
+/*
+ * Decode an octal-escaped and space-terminated path of the form used by
+ * /proc/mounts. May be used to decode a path in-place. "out" must be at least
+ * as large as the input. The output is always null-terminated. "len" gets the
+ * length of the output, excluding the trailing null. Returns 0 if a full path
+ * was successfully decoded, otherwise an error.
+ */
+static int decode_path(const char *in, char *out, size_t *len)
+{
+       char *first = out;
+       int c;
+       int i;
+       int ret = -EINVAL;
+       while (1) {
+               switch (*in) {
+               case '\0':
+                       goto out;
+
+               case ' ':
+                       ret = 0;
+                       goto out;
+
+               case '\\':
+                       in++;
+                       c = 0;
+                       for (i = 0; i < 3; i++) {
+                               if (*in < '0' || *in > '7')
+                                       goto out;
+                               c = (c << 3) | (*in++ - '0');
+                       }
+                       *(unsigned char *)out++ = (unsigned char) c;
+                       break;
+
+               default:
+                       *out++ = *in++;
+                       break;
+               }
+       }
+
+out:
+       *out = '\0';
+       *len = out - first;
+       return ret;
+}
+
+/*
+ * Computes the length of s when encoded with three-digit octal escape sequences
+ * for the characters in chars.
+ */
+static size_t octal_encoded_length(const char *s, const char *chars)
+{
+       size_t len = strlen(s);
+       while ((s = strpbrk(s, chars)) != NULL) {
+               len += 3;
+               s++;
+       }
+
+       return len;
+}
+
+enum {
+       OUTCOME_NOTHING_MOUNTED,
+       OUTCOME_TMPFS_MOUNT,
+       OUTCOME_NON_TMPFS_MOUNT,
+};
+
+/* Read a line of /proc/mounts data looking for a tmpfs mount at "path". */
+static int read_mount(int fd, char *buf, size_t bufsize, const char *path,
+                     int *outcome)
+{
+       int found;
+       int match;
+       char *space;
+       size_t len;
+
+       enum {
+               MATCH_NONE,
+               MATCH_EXACT,
+               MATCH_PARENT,
+       };
+
+       found = next(fd, buf, bufsize, ' ');
+       if (found != 1)
+               return found;
 
        /*
-        * Refill the buffer so that if there's a partial string that we care
-        * about, it will be completed, and we can recognize it.
+        * If there's no following space in the buffer, then this path is
+        * truncated, so it can't be the one we're looking for.
         */
-       n = read(fd, &buf[len], size - len - 1);
-       if (n < 0)
-               return -errno;
+       space = strchr(buf, ' ');
+       if (space) {
+               match = MATCH_NONE;
+               if (!decode_path(buf, buf, &len)) {
+                       if (!strcmp(buf, path))
+                               match = MATCH_EXACT;
+                       else if (!strncmp(buf, path, len)
+                                && (path[len] == '/' || !strcmp(buf, "/")))
+                               match = MATCH_PARENT;
+               }
+
+               found = pop(fd, buf, bufsize, space - buf + 1);
+               if (found != 1)
+                       return found;
+
+               switch (match) {
+               case MATCH_EXACT:
+                       if (!strncmp(buf, "tmpfs", strlen("tmpfs")))
+                               *outcome = OUTCOME_TMPFS_MOUNT;
+                       else
+                               *outcome = OUTCOME_NON_TMPFS_MOUNT;
+                       break;
 
-       buf[len + n] = '\0';
-       return 1;
+               case MATCH_PARENT:
+                       /* This mount obscures any previous ones. */
+                       *outcome = OUTCOME_NOTHING_MOUNTED;
+                       break;
+               }
+       }
+
+       return next(fd, buf, bufsize, '\n');
 }
 
 /* which_tmpdir is called only during early boot */
@@ -106,8 +233,12 @@ static int checked_tmpdir = 0;
  */
 static void which_tmpdir(void)
 {
-       int fd, found;
-       char buf[128] = { '\0' };
+       int fd;
+       int found;
+       int outcome;
+       char *path;
+       char *buf;
+       size_t bufsize;
 
        if (checked_tmpdir)
                return;
@@ -116,49 +247,66 @@ static void which_tmpdir(void)
 
        printf("Checking for tmpfs mount on /dev/shm...");
 
+       path = realpath("/dev/shm", NULL);
+       if (!path) {
+               printf("failed to check real path, errno = %d\n", errno);
+               return;
+       }
+       printf("%s...", path);
+
+       /*
+        * The buffer needs to be able to fit the full octal-escaped path, a
+        * space, and a trailing null in order to successfully decode it.
+        */
+       bufsize = octal_encoded_length(path, " \t\n\\") + 2;
+
+       if (bufsize < 128)
+               bufsize = 128;
+
+       buf = malloc(bufsize);
+       if (!buf) {
+               printf("malloc failed, errno = %d\n", errno);
+               goto out;
+       }
+       buf[0] = '\0';
+
        fd = open("/proc/mounts", O_RDONLY);
        if (fd < 0) {
                printf("failed to open /proc/mounts, errno = %d\n", errno);
-               return;
+               goto out1;
        }
 
+       outcome = OUTCOME_NOTHING_MOUNTED;
        while (1) {
-               found = next(fd, buf, ARRAY_SIZE(buf), ' ');
-               if (found != 1)
-                       break;
-
-               if (!strncmp(buf, "/dev/shm", strlen("/dev/shm")))
-                       goto found;
-
-               found = next(fd, buf, ARRAY_SIZE(buf), '\n');
+               found = read_mount(fd, buf, bufsize, path, &outcome);
                if (found != 1)
                        break;
        }
 
-err:
-       if (found == 0)
-               printf("nothing mounted on /dev/shm\n");
-       else if (found < 0)
+       if (found < 0) {
                printf("read returned errno %d\n", -found);
+       } else {
+               switch (outcome) {
+               case OUTCOME_TMPFS_MOUNT:
+                       printf("OK\n");
+                       default_tmpdir = "/dev/shm";
+                       break;
 
-out:
-       close(fd);
-
-       return;
-
-found:
-       found = next(fd, buf, ARRAY_SIZE(buf), ' ');
-       if (found != 1)
-               goto err;
+               case OUTCOME_NON_TMPFS_MOUNT:
+                       printf("not tmpfs\n");
+                       break;
 
-       if (strncmp(buf, "tmpfs", strlen("tmpfs"))) {
-               printf("not tmpfs\n");
-               goto out;
+               default:
+                       printf("nothing mounted on /dev/shm\n");
+                       break;
+               }
        }
 
-       printf("OK\n");
-       default_tmpdir = "/dev/shm";
-       goto out;
+       close(fd);
+out1:
+       free(buf);
+out:
+       free(path);
 }
 
 static int __init make_tempfile(const char *template, char **out_tempname,
index 9d9f1b4bf8269d89af35a08b5e24064337a410e4..905924b773d345b8f49de2905e62a546f6461cd9 100644 (file)
@@ -25,7 +25,7 @@ void (*sig_info[NSIG])(int, struct siginfo *, struct uml_pt_regs *) = {
        [SIGIO]         = sigio_handler,
        [SIGVTALRM]     = timer_handler };
 
-static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc)
+static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)
 {
        struct uml_pt_regs r;
        int save_errno = errno;
@@ -61,7 +61,7 @@ static void sig_handler_common(int sig, siginfo_t *si, mcontext_t *mc)
 static int signals_enabled;
 static unsigned int signals_pending;
 
-void sig_handler(int sig, siginfo_t *si, mcontext_t *mc)
+void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
 {
        int enabled;
 
@@ -120,7 +120,7 @@ void set_sigstack(void *sig_stack, int size)
                panic("enabling signal stack failed, errno = %d\n", errno);
 }
 
-static void (*handlers[_NSIG])(int sig, siginfo_t *si, mcontext_t *mc) = {
+static void (*handlers[_NSIG])(int sig, struct siginfo *si, mcontext_t *mc) = {
        [SIGSEGV] = sig_handler,
        [SIGBUS] = sig_handler,
        [SIGILL] = sig_handler,
@@ -162,7 +162,7 @@ static void hard_handler(int sig, siginfo_t *si, void *p)
                while ((sig = ffs(pending)) != 0){
                        sig--;
                        pending &= ~(1 << sig);
-                       (*handlers[sig])(sig, si, mc);
+                       (*handlers[sig])(sig, (struct siginfo *)si, mc);
                }
 
                /*
index 4625949bf1e4cd4ee9c424aa3eab1bfec6458ff7..d531879a4617695e02df3c1550922cfede7ea4e3 100644 (file)
@@ -54,7 +54,7 @@ static int ptrace_dump_regs(int pid)
 
 void wait_stub_done(int pid)
 {
-       int n, status, err;
+       int n, status, err, bad_stop = 0;
 
        while (1) {
                CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
@@ -74,6 +74,8 @@ void wait_stub_done(int pid)
 
        if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0)
                return;
+       else
+               bad_stop = 1;
 
 bad_wait:
        err = ptrace_dump_regs(pid);
@@ -83,7 +85,10 @@ bad_wait:
        printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, "
               "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno,
               status);
-       fatal_sigsegv();
+       if (bad_stop)
+               kill(pid, SIGKILL);
+       else
+               fatal_sigsegv();
 }
 
 extern unsigned long current_stub_stack(void);
@@ -409,7 +414,7 @@ void userspace(struct uml_pt_regs *regs)
                if (WIFSTOPPED(status)) {
                        int sig = WSTOPSIG(status);
 
-                       ptrace(PTRACE_GETSIGINFO, pid, 0, &si);
+                       ptrace(PTRACE_GETSIGINFO, pid, 0, (struct siginfo *)&si);
 
                        switch (sig) {
                        case SIGSEGV:
@@ -417,7 +422,7 @@ void userspace(struct uml_pt_regs *regs)
                                    !ptrace_faultinfo) {
                                        get_skas_faultinfo(pid,
                                                           &regs->faultinfo);
-                                       (*sig_info[SIGSEGV])(SIGSEGV, &si,
+                                       (*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si,
                                                             regs);
                                }
                                else handle_segv(pid, regs);
@@ -426,14 +431,14 @@ void userspace(struct uml_pt_regs *regs)
                                handle_trap(pid, regs, local_using_sysemu);
                                break;
                        case SIGTRAP:
-                               relay_signal(SIGTRAP, &si, regs);
+                               relay_signal(SIGTRAP, (struct siginfo *)&si, regs);
                                break;
                        case SIGVTALRM:
                                now = os_nsecs();
                                if (now < nsecs)
                                        break;
                                block_signals();
-                               (*sig_info[sig])(sig, &si, regs);
+                               (*sig_info[sig])(sig, (struct siginfo *)&si, regs);
                                unblock_signals();
                                nsecs = timer.it_value.tv_sec *
                                        UM_NSEC_PER_SEC +
@@ -447,7 +452,7 @@ void userspace(struct uml_pt_regs *regs)
                        case SIGFPE:
                        case SIGWINCH:
                                block_signals();
-                               (*sig_info[sig])(sig, &si, regs);
+                               (*sig_info[sig])(sig, (struct siginfo *)&si, regs);
                                unblock_signals();
                                break;
                        default:
index d606463aa6d63bfdab5641e6bd7e6b68545e32d9..b7388a425f0994ba87a30a27fe8ba57d7e3e5457 100644 (file)
@@ -225,7 +225,7 @@ static void low_free(unsigned long size, unsigned long addr)
        unsigned long nr_pages;
 
        nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
-       efi_call_phys2(sys_table->boottime->free_pages, addr, size);
+       efi_call_phys2(sys_table->boottime->free_pages, addr, nr_pages);
 }
 
 static void find_bits(unsigned long mask, u8 *pos, u8 *size)
index 7d6ba9db1be99696784aeba62343eeebff9c32dd..6c63c358a7e689070881361b003f102c154e9c96 100644 (file)
@@ -27,7 +27,6 @@ obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o
 obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o
 obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o
 obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o
-obj-$(CONFIG_CRYPTO_CRCT10DIF_PCLMUL) += crct10dif-pclmul.o
 
 # These modules require assembler to support AVX.
 ifeq ($(avx_supported),yes)
@@ -82,4 +81,3 @@ crc32c-intel-$(CONFIG_64BIT) += crc32c-pcl-intel-asm_64.o
 crc32-pclmul-y := crc32-pclmul_asm.o crc32-pclmul_glue.o
 sha256-ssse3-y := sha256-ssse3-asm.o sha256-avx-asm.o sha256-avx2-asm.o sha256_ssse3_glue.o
 sha512-ssse3-y := sha512-ssse3-asm.o sha512-avx-asm.o sha512-avx2-asm.o sha512_ssse3_glue.o
-crct10dif-pclmul-y := crct10dif-pcl-asm_64.o crct10dif-pclmul_glue.o
diff --git a/arch/x86/crypto/crct10dif-pcl-asm_64.S b/arch/x86/crypto/crct10dif-pcl-asm_64.S
deleted file mode 100644 (file)
index 35e9756..0000000
+++ /dev/null
@@ -1,643 +0,0 @@
-########################################################################
-# Implement fast CRC-T10DIF computation with SSE and PCLMULQDQ instructions
-#
-# Copyright (c) 2013, Intel Corporation
-#
-# Authors:
-#     Erdinc Ozturk <erdinc.ozturk@intel.com>
-#     Vinodh Gopal <vinodh.gopal@intel.com>
-#     James Guilford <james.guilford@intel.com>
-#     Tim Chen <tim.c.chen@linux.intel.com>
-#
-# This software is available to you under a choice of one of two
-# licenses.  You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the
-#   distribution.
-#
-# * Neither the name of the Intel Corporation nor the names of its
-#   contributors may be used to endorse or promote products derived from
-#   this software without specific prior written permission.
-#
-#
-# THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-########################################################################
-#       Function API:
-#       UINT16 crc_t10dif_pcl(
-#               UINT16 init_crc, //initial CRC value, 16 bits
-#               const unsigned char *buf, //buffer pointer to calculate CRC on
-#               UINT64 len //buffer length in bytes (64-bit data)
-#       );
-#
-#       Reference paper titled "Fast CRC Computation for Generic
-#      Polynomials Using PCLMULQDQ Instruction"
-#       URL: http://www.intel.com/content/dam/www/public/us/en/documents
-#  /white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
-#
-#
-
-#include <linux/linkage.h>
-
-.text
-
-#define        arg1 %rdi
-#define        arg2 %rsi
-#define        arg3 %rdx
-
-#define        arg1_low32 %edi
-
-ENTRY(crc_t10dif_pcl)
-.align 16
-
-       # adjust the 16-bit initial_crc value, scale it to 32 bits
-       shl     $16, arg1_low32
-
-       # Allocate Stack Space
-       mov     %rsp, %rcx
-       sub     $16*2, %rsp
-       # align stack to 16 byte boundary
-       and     $~(0x10 - 1), %rsp
-
-       # check if smaller than 256
-       cmp     $256, arg3
-
-       # for sizes less than 128, we can't fold 64B at a time...
-       jl      _less_than_128
-
-
-       # load the initial crc value
-       movd    arg1_low32, %xmm10      # initial crc
-
-       # crc value does not need to be byte-reflected, but it needs
-       # to be moved to the high part of the register.
-       # because data will be byte-reflected and will align with
-       # initial crc at correct place.
-       pslldq  $12, %xmm10
-
-       movdqa  SHUF_MASK(%rip), %xmm11
-       # receive the initial 64B data, xor the initial crc value
-       movdqu  16*0(arg2), %xmm0
-       movdqu  16*1(arg2), %xmm1
-       movdqu  16*2(arg2), %xmm2
-       movdqu  16*3(arg2), %xmm3
-       movdqu  16*4(arg2), %xmm4
-       movdqu  16*5(arg2), %xmm5
-       movdqu  16*6(arg2), %xmm6
-       movdqu  16*7(arg2), %xmm7
-
-       pshufb  %xmm11, %xmm0
-       # XOR the initial_crc value
-       pxor    %xmm10, %xmm0
-       pshufb  %xmm11, %xmm1
-       pshufb  %xmm11, %xmm2
-       pshufb  %xmm11, %xmm3
-       pshufb  %xmm11, %xmm4
-       pshufb  %xmm11, %xmm5
-       pshufb  %xmm11, %xmm6
-       pshufb  %xmm11, %xmm7
-
-       movdqa  rk3(%rip), %xmm10       #xmm10 has rk3 and rk4
-                                       #imm value of pclmulqdq instruction
-                                       #will determine which constant to use
-
-       #################################################################
-       # we subtract 256 instead of 128 to save one instruction from the loop
-       sub     $256, arg3
-
-       # at this section of the code, there is 64*x+y (0<=y<64) bytes of
-       # buffer. The _fold_64_B_loop will fold 64B at a time
-       # until we have 64+y Bytes of buffer
-
-
-       # fold 64B at a time. This section of the code folds 4 xmm
-       # registers in parallel
-_fold_64_B_loop:
-
-       # update the buffer pointer
-       add     $128, arg2              #    buf += 64#
-
-       movdqu  16*0(arg2), %xmm9
-       movdqu  16*1(arg2), %xmm12
-       pshufb  %xmm11, %xmm9
-       pshufb  %xmm11, %xmm12
-       movdqa  %xmm0, %xmm8
-       movdqa  %xmm1, %xmm13
-       pclmulqdq       $0x0 , %xmm10, %xmm0
-       pclmulqdq       $0x11, %xmm10, %xmm8
-       pclmulqdq       $0x0 , %xmm10, %xmm1
-       pclmulqdq       $0x11, %xmm10, %xmm13
-       pxor    %xmm9 , %xmm0
-       xorps   %xmm8 , %xmm0
-       pxor    %xmm12, %xmm1
-       xorps   %xmm13, %xmm1
-
-       movdqu  16*2(arg2), %xmm9
-       movdqu  16*3(arg2), %xmm12
-       pshufb  %xmm11, %xmm9
-       pshufb  %xmm11, %xmm12
-       movdqa  %xmm2, %xmm8
-       movdqa  %xmm3, %xmm13
-       pclmulqdq       $0x0, %xmm10, %xmm2
-       pclmulqdq       $0x11, %xmm10, %xmm8
-       pclmulqdq       $0x0, %xmm10, %xmm3
-       pclmulqdq       $0x11, %xmm10, %xmm13
-       pxor    %xmm9 , %xmm2
-       xorps   %xmm8 , %xmm2
-       pxor    %xmm12, %xmm3
-       xorps   %xmm13, %xmm3
-
-       movdqu  16*4(arg2), %xmm9
-       movdqu  16*5(arg2), %xmm12
-       pshufb  %xmm11, %xmm9
-       pshufb  %xmm11, %xmm12
-       movdqa  %xmm4, %xmm8
-       movdqa  %xmm5, %xmm13
-       pclmulqdq       $0x0,  %xmm10, %xmm4
-       pclmulqdq       $0x11, %xmm10, %xmm8
-       pclmulqdq       $0x0,  %xmm10, %xmm5
-       pclmulqdq       $0x11, %xmm10, %xmm13
-       pxor    %xmm9 ,  %xmm4
-       xorps   %xmm8 ,  %xmm4
-       pxor    %xmm12,  %xmm5
-       xorps   %xmm13,  %xmm5
-
-       movdqu  16*6(arg2), %xmm9
-       movdqu  16*7(arg2), %xmm12
-       pshufb  %xmm11, %xmm9
-       pshufb  %xmm11, %xmm12
-       movdqa  %xmm6 , %xmm8
-       movdqa  %xmm7 , %xmm13
-       pclmulqdq       $0x0 , %xmm10, %xmm6
-       pclmulqdq       $0x11, %xmm10, %xmm8
-       pclmulqdq       $0x0 , %xmm10, %xmm7
-       pclmulqdq       $0x11, %xmm10, %xmm13
-       pxor    %xmm9 , %xmm6
-       xorps   %xmm8 , %xmm6
-       pxor    %xmm12, %xmm7
-       xorps   %xmm13, %xmm7
-
-       sub     $128, arg3
-
-       # check if there is another 64B in the buffer to be able to fold
-       jge     _fold_64_B_loop
-       ##################################################################
-
-
-       add     $128, arg2
-       # at this point, the buffer pointer is pointing at the last y Bytes
-       # of the buffer the 64B of folded data is in 4 of the xmm
-       # registers: xmm0, xmm1, xmm2, xmm3
-
-
-       # fold the 8 xmm registers to 1 xmm register with different constants
-
-       movdqa  rk9(%rip), %xmm10
-       movdqa  %xmm0, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm0
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       xorps   %xmm0, %xmm7
-
-       movdqa  rk11(%rip), %xmm10
-       movdqa  %xmm1, %xmm8
-       pclmulqdq        $0x11, %xmm10, %xmm1
-       pclmulqdq        $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       xorps   %xmm1, %xmm7
-
-       movdqa  rk13(%rip), %xmm10
-       movdqa  %xmm2, %xmm8
-       pclmulqdq        $0x11, %xmm10, %xmm2
-       pclmulqdq        $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       pxor    %xmm2, %xmm7
-
-       movdqa  rk15(%rip), %xmm10
-       movdqa  %xmm3, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm3
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       xorps   %xmm3, %xmm7
-
-       movdqa  rk17(%rip), %xmm10
-       movdqa  %xmm4, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm4
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       pxor    %xmm4, %xmm7
-
-       movdqa  rk19(%rip), %xmm10
-       movdqa  %xmm5, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm5
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       xorps   %xmm5, %xmm7
-
-       movdqa  rk1(%rip), %xmm10       #xmm10 has rk1 and rk2
-                                       #imm value of pclmulqdq instruction
-                                       #will determine which constant to use
-       movdqa  %xmm6, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm6
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       pxor    %xmm6, %xmm7
-
-
-       # instead of 64, we add 48 to the loop counter to save 1 instruction
-       # from the loop instead of a cmp instruction, we use the negative
-       # flag with the jl instruction
-       add     $128-16, arg3
-       jl      _final_reduction_for_128
-
-       # now we have 16+y bytes left to reduce. 16 Bytes is in register xmm7
-       # and the rest is in memory. We can fold 16 bytes at a time if y>=16
-       # continue folding 16B at a time
-
-_16B_reduction_loop:
-       movdqa  %xmm7, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm7
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       movdqu  (arg2), %xmm0
-       pshufb  %xmm11, %xmm0
-       pxor    %xmm0 , %xmm7
-       add     $16, arg2
-       sub     $16, arg3
-       # instead of a cmp instruction, we utilize the flags with the
-       # jge instruction equivalent of: cmp arg3, 16-16
-       # check if there is any more 16B in the buffer to be able to fold
-       jge     _16B_reduction_loop
-
-       #now we have 16+z bytes left to reduce, where 0<= z < 16.
-       #first, we reduce the data in the xmm7 register
-
-
-_final_reduction_for_128:
-       # check if any more data to fold. If not, compute the CRC of
-       # the final 128 bits
-       add     $16, arg3
-       je      _128_done
-
-       # here we are getting data that is less than 16 bytes.
-       # since we know that there was data before the pointer, we can
-       # offset the input pointer before the actual point, to receive
-       # exactly 16 bytes. after that the registers need to be adjusted.
-_get_last_two_xmms:
-       movdqa  %xmm7, %xmm2
-
-       movdqu  -16(arg2, arg3), %xmm1
-       pshufb  %xmm11, %xmm1
-
-       # get rid of the extra data that was loaded before
-       # load the shift constant
-       lea     pshufb_shf_table+16(%rip), %rax
-       sub     arg3, %rax
-       movdqu  (%rax), %xmm0
-
-       # shift xmm2 to the left by arg3 bytes
-       pshufb  %xmm0, %xmm2
-
-       # shift xmm7 to the right by 16-arg3 bytes
-       pxor    mask1(%rip), %xmm0
-       pshufb  %xmm0, %xmm7
-       pblendvb        %xmm2, %xmm1    #xmm0 is implicit
-
-       # fold 16 Bytes
-       movdqa  %xmm1, %xmm2
-       movdqa  %xmm7, %xmm8
-       pclmulqdq       $0x11, %xmm10, %xmm7
-       pclmulqdq       $0x0 , %xmm10, %xmm8
-       pxor    %xmm8, %xmm7
-       pxor    %xmm2, %xmm7
-
-_128_done:
-       # compute crc of a 128-bit value
-       movdqa  rk5(%rip), %xmm10       # rk5 and rk6 in xmm10
-       movdqa  %xmm7, %xmm0
-
-       #64b fold
-       pclmulqdq       $0x1, %xmm10, %xmm7
-       pslldq  $8   ,  %xmm0
-       pxor    %xmm0,  %xmm7
-
-       #32b fold
-       movdqa  %xmm7, %xmm0
-
-       pand    mask2(%rip), %xmm0
-
-       psrldq  $12, %xmm7
-       pclmulqdq       $0x10, %xmm10, %xmm7
-       pxor    %xmm0, %xmm7
-
-       #barrett reduction
-_barrett:
-       movdqa  rk7(%rip), %xmm10       # rk7 and rk8 in xmm10
-       movdqa  %xmm7, %xmm0
-       pclmulqdq       $0x01, %xmm10, %xmm7
-       pslldq  $4, %xmm7
-       pclmulqdq       $0x11, %xmm10, %xmm7
-
-       pslldq  $4, %xmm7
-       pxor    %xmm0, %xmm7
-       pextrd  $1, %xmm7, %eax
-
-_cleanup:
-       # scale the result back to 16 bits
-       shr     $16, %eax
-       mov     %rcx, %rsp
-       ret
-
-########################################################################
-
-.align 16
-_less_than_128:
-
-       # check if there is enough buffer to be able to fold 16B at a time
-       cmp     $32, arg3
-       jl      _less_than_32
-       movdqa  SHUF_MASK(%rip), %xmm11
-
-       # now if there is, load the constants
-       movdqa  rk1(%rip), %xmm10       # rk1 and rk2 in xmm10
-
-       movd    arg1_low32, %xmm0       # get the initial crc value
-       pslldq  $12, %xmm0      # align it to its correct place
-       movdqu  (arg2), %xmm7   # load the plaintext
-       pshufb  %xmm11, %xmm7   # byte-reflect the plaintext
-       pxor    %xmm0, %xmm7
-
-
-       # update the buffer pointer
-       add     $16, arg2
-
-       # update the counter. subtract 32 instead of 16 to save one
-       # instruction from the loop
-       sub     $32, arg3
-
-       jmp     _16B_reduction_loop
-
-
-.align 16
-_less_than_32:
-       # mov initial crc to the return value. this is necessary for
-       # zero-length buffers.
-       mov     arg1_low32, %eax
-       test    arg3, arg3
-       je      _cleanup
-
-       movdqa  SHUF_MASK(%rip), %xmm11
-
-       movd    arg1_low32, %xmm0       # get the initial crc value
-       pslldq  $12, %xmm0      # align it to its correct place
-
-       cmp     $16, arg3
-       je      _exact_16_left
-       jl      _less_than_16_left
-
-       movdqu  (arg2), %xmm7   # load the plaintext
-       pshufb  %xmm11, %xmm7   # byte-reflect the plaintext
-       pxor    %xmm0 , %xmm7   # xor the initial crc value
-       add     $16, arg2
-       sub     $16, arg3
-       movdqa  rk1(%rip), %xmm10       # rk1 and rk2 in xmm10
-       jmp     _get_last_two_xmms
-
-
-.align 16
-_less_than_16_left:
-       # use stack space to load data less than 16 bytes, zero-out
-       # the 16B in memory first.
-
-       pxor    %xmm1, %xmm1
-       mov     %rsp, %r11
-       movdqa  %xmm1, (%r11)
-
-       cmp     $4, arg3
-       jl      _only_less_than_4
-
-       # backup the counter value
-       mov     arg3, %r9
-       cmp     $8, arg3
-       jl      _less_than_8_left
-
-       # load 8 Bytes
-       mov     (arg2), %rax
-       mov     %rax, (%r11)
-       add     $8, %r11
-       sub     $8, arg3
-       add     $8, arg2
-_less_than_8_left:
-
-       cmp     $4, arg3
-       jl      _less_than_4_left
-
-       # load 4 Bytes
-       mov     (arg2), %eax
-       mov     %eax, (%r11)
-       add     $4, %r11
-       sub     $4, arg3
-       add     $4, arg2
-_less_than_4_left:
-
-       cmp     $2, arg3
-       jl      _less_than_2_left
-
-       # load 2 Bytes
-       mov     (arg2), %ax
-       mov     %ax, (%r11)
-       add     $2, %r11
-       sub     $2, arg3
-       add     $2, arg2
-_less_than_2_left:
-       cmp     $1, arg3
-        jl      _zero_left
-
-       # load 1 Byte
-       mov     (arg2), %al
-       mov     %al, (%r11)
-_zero_left:
-       movdqa  (%rsp), %xmm7
-       pshufb  %xmm11, %xmm7
-       pxor    %xmm0 , %xmm7   # xor the initial crc value
-
-       # shl r9, 4
-       lea     pshufb_shf_table+16(%rip), %rax
-       sub     %r9, %rax
-       movdqu  (%rax), %xmm0
-       pxor    mask1(%rip), %xmm0
-
-       pshufb  %xmm0, %xmm7
-       jmp     _128_done
-
-.align 16
-_exact_16_left:
-       movdqu  (arg2), %xmm7
-       pshufb  %xmm11, %xmm7
-       pxor    %xmm0 , %xmm7   # xor the initial crc value
-
-       jmp     _128_done
-
-_only_less_than_4:
-       cmp     $3, arg3
-       jl      _only_less_than_3
-
-       # load 3 Bytes
-       mov     (arg2), %al
-       mov     %al, (%r11)
-
-       mov     1(arg2), %al
-       mov     %al, 1(%r11)
-
-       mov     2(arg2), %al
-       mov     %al, 2(%r11)
-
-       movdqa   (%rsp), %xmm7
-       pshufb   %xmm11, %xmm7
-       pxor     %xmm0 , %xmm7  # xor the initial crc value
-
-       psrldq  $5, %xmm7
-
-       jmp     _barrett
-_only_less_than_3:
-       cmp     $2, arg3
-       jl      _only_less_than_2
-
-       # load 2 Bytes
-       mov     (arg2), %al
-       mov     %al, (%r11)
-
-       mov     1(arg2), %al
-       mov     %al, 1(%r11)
-
-       movdqa  (%rsp), %xmm7
-       pshufb  %xmm11, %xmm7
-       pxor    %xmm0 , %xmm7   # xor the initial crc value
-
-       psrldq  $6, %xmm7
-
-       jmp     _barrett
-_only_less_than_2:
-
-       # load 1 Byte
-       mov     (arg2), %al
-       mov     %al, (%r11)
-
-       movdqa  (%rsp), %xmm7
-       pshufb  %xmm11, %xmm7
-       pxor    %xmm0 , %xmm7   # xor the initial crc value
-
-       psrldq  $7, %xmm7
-
-       jmp     _barrett
-
-ENDPROC(crc_t10dif_pcl)
-
-.data
-
-# precomputed constants
-# these constants are precomputed from the poly:
-# 0x8bb70000 (0x8bb7 scaled to 32 bits)
-.align 16
-# Q = 0x18BB70000
-# rk1 = 2^(32*3) mod Q << 32
-# rk2 = 2^(32*5) mod Q << 32
-# rk3 = 2^(32*15) mod Q << 32
-# rk4 = 2^(32*17) mod Q << 32
-# rk5 = 2^(32*3) mod Q << 32
-# rk6 = 2^(32*2) mod Q << 32
-# rk7 = floor(2^64/Q)
-# rk8 = Q
-rk1:
-.quad 0x2d56000000000000
-rk2:
-.quad 0x06df000000000000
-rk3:
-.quad 0x9d9d000000000000
-rk4:
-.quad 0x7cf5000000000000
-rk5:
-.quad 0x2d56000000000000
-rk6:
-.quad 0x1368000000000000
-rk7:
-.quad 0x00000001f65a57f8
-rk8:
-.quad 0x000000018bb70000
-
-rk9:
-.quad 0xceae000000000000
-rk10:
-.quad 0xbfd6000000000000
-rk11:
-.quad 0x1e16000000000000
-rk12:
-.quad 0x713c000000000000
-rk13:
-.quad 0xf7f9000000000000
-rk14:
-.quad 0x80a6000000000000
-rk15:
-.quad 0x044c000000000000
-rk16:
-.quad 0xe658000000000000
-rk17:
-.quad 0xad18000000000000
-rk18:
-.quad 0xa497000000000000
-rk19:
-.quad 0x6ee3000000000000
-rk20:
-.quad 0xe7b5000000000000
-
-
-
-mask1:
-.octa 0x80808080808080808080808080808080
-mask2:
-.octa 0x00000000FFFFFFFFFFFFFFFFFFFFFFFF
-
-SHUF_MASK:
-.octa 0x000102030405060708090A0B0C0D0E0F
-
-pshufb_shf_table:
-# use these values for shift constants for the pshufb instruction
-# different alignments result in values as shown:
-#      DDQ 0x008f8e8d8c8b8a898887868584838281 # shl 15 (16-1) / shr1
-#      DDQ 0x01008f8e8d8c8b8a8988878685848382 # shl 14 (16-3) / shr2
-#      DDQ 0x0201008f8e8d8c8b8a89888786858483 # shl 13 (16-4) / shr3
-#      DDQ 0x030201008f8e8d8c8b8a898887868584 # shl 12 (16-4) / shr4
-#      DDQ 0x04030201008f8e8d8c8b8a8988878685 # shl 11 (16-5) / shr5
-#      DDQ 0x0504030201008f8e8d8c8b8a89888786 # shl 10 (16-6) / shr6
-#      DDQ 0x060504030201008f8e8d8c8b8a898887 # shl 9  (16-7) / shr7
-#      DDQ 0x07060504030201008f8e8d8c8b8a8988 # shl 8  (16-8) / shr8
-#      DDQ 0x0807060504030201008f8e8d8c8b8a89 # shl 7  (16-9) / shr9
-#      DDQ 0x090807060504030201008f8e8d8c8b8a # shl 6  (16-10) / shr10
-#      DDQ 0x0a090807060504030201008f8e8d8c8b # shl 5  (16-11) / shr11
-#      DDQ 0x0b0a090807060504030201008f8e8d8c # shl 4  (16-12) / shr12
-#      DDQ 0x0c0b0a090807060504030201008f8e8d # shl 3  (16-13) / shr13
-#      DDQ 0x0d0c0b0a090807060504030201008f8e # shl 2  (16-14) / shr14
-#      DDQ 0x0e0d0c0b0a090807060504030201008f # shl 1  (16-15) / shr15
-.octa 0x8f8e8d8c8b8a89888786858483828100
-.octa 0x000e0d0c0b0a09080706050403020100
diff --git a/arch/x86/crypto/crct10dif-pclmul_glue.c b/arch/x86/crypto/crct10dif-pclmul_glue.c
deleted file mode 100644 (file)
index 7845d7f..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Cryptographic API.
- *
- * T10 Data Integrity Field CRC16 Crypto Transform using PCLMULQDQ Instructions
- *
- * Copyright (C) 2013 Intel Corporation
- * Author: Tim Chen <tim.c.chen@linux.intel.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <linux/types.h>
-#include <linux/module.h>
-#include <linux/crc-t10dif.h>
-#include <crypto/internal/hash.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <asm/i387.h>
-#include <asm/cpufeature.h>
-#include <asm/cpu_device_id.h>
-
-asmlinkage __u16 crc_t10dif_pcl(__u16 crc, const unsigned char *buf,
-                               size_t len);
-
-struct chksum_desc_ctx {
-       __u16 crc;
-};
-
-/*
- * Steps through buffer one byte at at time, calculates reflected
- * crc using table.
- */
-
-static int chksum_init(struct shash_desc *desc)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       ctx->crc = 0;
-
-       return 0;
-}
-
-static int chksum_update(struct shash_desc *desc, const u8 *data,
-                        unsigned int length)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       if (irq_fpu_usable()) {
-               kernel_fpu_begin();
-               ctx->crc = crc_t10dif_pcl(ctx->crc, data, length);
-               kernel_fpu_end();
-       } else
-               ctx->crc = crc_t10dif_generic(ctx->crc, data, length);
-       return 0;
-}
-
-static int chksum_final(struct shash_desc *desc, u8 *out)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       *(__u16 *)out = ctx->crc;
-       return 0;
-}
-
-static int __chksum_finup(__u16 *crcp, const u8 *data, unsigned int len,
-                       u8 *out)
-{
-       if (irq_fpu_usable()) {
-               kernel_fpu_begin();
-               *(__u16 *)out = crc_t10dif_pcl(*crcp, data, len);
-               kernel_fpu_end();
-       } else
-               *(__u16 *)out = crc_t10dif_generic(*crcp, data, len);
-       return 0;
-}
-
-static int chksum_finup(struct shash_desc *desc, const u8 *data,
-                       unsigned int len, u8 *out)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       return __chksum_finup(&ctx->crc, data, len, out);
-}
-
-static int chksum_digest(struct shash_desc *desc, const u8 *data,
-                        unsigned int length, u8 *out)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       return __chksum_finup(&ctx->crc, data, length, out);
-}
-
-static struct shash_alg alg = {
-       .digestsize             =       CRC_T10DIF_DIGEST_SIZE,
-       .init           =       chksum_init,
-       .update         =       chksum_update,
-       .final          =       chksum_final,
-       .finup          =       chksum_finup,
-       .digest         =       chksum_digest,
-       .descsize               =       sizeof(struct chksum_desc_ctx),
-       .base                   =       {
-               .cra_name               =       "crct10dif",
-               .cra_driver_name        =       "crct10dif-pclmul",
-               .cra_priority           =       200,
-               .cra_blocksize          =       CRC_T10DIF_BLOCK_SIZE,
-               .cra_module             =       THIS_MODULE,
-       }
-};
-
-static const struct x86_cpu_id crct10dif_cpu_id[] = {
-       X86_FEATURE_MATCH(X86_FEATURE_PCLMULQDQ),
-       {}
-};
-MODULE_DEVICE_TABLE(x86cpu, crct10dif_cpu_id);
-
-static int __init crct10dif_intel_mod_init(void)
-{
-       if (!x86_match_cpu(crct10dif_cpu_id))
-               return -ENODEV;
-
-       return crypto_register_shash(&alg);
-}
-
-static void __exit crct10dif_intel_mod_fini(void)
-{
-       crypto_unregister_shash(&alg);
-}
-
-module_init(crct10dif_intel_mod_init);
-module_exit(crct10dif_intel_mod_fini);
-
-MODULE_AUTHOR("Tim Chen <tim.c.chen@linux.intel.com>");
-MODULE_DESCRIPTION("T10 DIF CRC calculation accelerated with PCLMULQDQ.");
-MODULE_LICENSE("GPL");
-
-MODULE_ALIAS("crct10dif");
-MODULE_ALIAS("crct10dif-pclmul");
index 653668d140f994e543ad52e46d0c8402d5fe9259..4a8cb8d7cbd5d2b0febd4333931b459e75f1ea1d 100644 (file)
@@ -35,9 +35,9 @@ static void sanitize_boot_params(struct boot_params *boot_params)
         */
        if (boot_params->sentinel) {
                /* fields in boot_params are left uninitialized, clear them */
-               memset(&boot_params->olpc_ofw_header, 0,
+               memset(&boot_params->ext_ramdisk_image, 0,
                       (char *)&boot_params->efi_info -
-                       (char *)&boot_params->olpc_ofw_header);
+                       (char *)&boot_params->ext_ramdisk_image);
                memset(&boot_params->kbd_status, 0,
                       (char *)&boot_params->hdr -
                       (char *)&boot_params->kbd_status);
index 5f9a1243190e8456aaa48f7b77cfa776e08ea7b8..d2b12988d2ed19b355b09347582c81db15c41a3d 100644 (file)
@@ -28,7 +28,7 @@ struct x86_cpu {
 #ifdef CONFIG_HOTPLUG_CPU
 extern int arch_register_cpu(int num);
 extern void arch_unregister_cpu(int);
-extern void __cpuinit start_cpu0(void);
+extern void start_cpu0(void);
 #ifdef CONFIG_DEBUG_HOTPLUG_CPU0
 extern int _debug_hotplug_cpu(int cpu, int action);
 #endif
index 6bc3985ee473d52ae74f16a2cec2e1fbd2fb693f..f98bd6625318210adb03615f3b282b6454db319d 100644 (file)
@@ -60,11 +60,11 @@ static inline void __exit exit_amd_microcode(void) {}
 #ifdef CONFIG_MICROCODE_EARLY
 #define MAX_UCODE_COUNT 128
 extern void __init load_ucode_bsp(void);
-extern void __cpuinit load_ucode_ap(void);
+extern void load_ucode_ap(void);
 extern int __init save_microcode_in_initrd(void);
 #else
 static inline void __init load_ucode_bsp(void) {}
-static inline void __cpuinit load_ucode_ap(void) {}
+static inline void load_ucode_ap(void) {}
 static inline int __init save_microcode_in_initrd(void)
 {
        return 0;
index c6b043f402712f069006d2b73c4d8299b0701245..4c019179a57dd97d6b48ae064ef1faea0dc2e7f7 100644 (file)
@@ -59,7 +59,7 @@ static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table,
 
 extern int __apply_microcode_amd(struct microcode_amd *mc_amd);
 extern int apply_microcode_amd(int cpu);
-extern enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size);
+extern enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size);
 
 #ifdef CONFIG_MICROCODE_AMD_EARLY
 #ifdef CONFIG_X86_32
@@ -67,11 +67,11 @@ extern enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size)
 extern u8 amd_bsp_mpb[MPB_MAX_SIZE];
 #endif
 extern void __init load_ucode_amd_bsp(void);
-extern void __cpuinit load_ucode_amd_ap(void);
+extern void load_ucode_amd_ap(void);
 extern int __init save_microcode_in_initrd_amd(void);
 #else
 static inline void __init load_ucode_amd_bsp(void) {}
-static inline void __cpuinit load_ucode_amd_ap(void) {}
+static inline void load_ucode_amd_ap(void) {}
 static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; }
 #endif
 
index 87a085333cbf563f2e0cc1ad8845fa7d822cfc99..9067166409bfe32b07358b74596032194628ef14 100644 (file)
@@ -65,12 +65,12 @@ update_match_revision(struct microcode_header_intel *mc_header, int rev);
 
 #ifdef CONFIG_MICROCODE_INTEL_EARLY
 extern void __init load_ucode_intel_bsp(void);
-extern void __cpuinit load_ucode_intel_ap(void);
+extern void load_ucode_intel_ap(void);
 extern void show_ucode_info_early(void);
 extern int __init save_microcode_in_initrd_intel(void);
 #else
 static inline __init void load_ucode_intel_bsp(void) {}
-static inline __cpuinit void load_ucode_intel_ap(void) {}
+static inline void load_ucode_intel_ap(void) {}
 static inline void show_ucode_info_early(void) {}
 static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; }
 #endif
index 9b119da1d105f18c4bb0e6cad2380a7b110d04c9..04a3fed22cfe05c9d2615a98c22da67ff1e2a5ce 100644 (file)
@@ -2,8 +2,8 @@
 #define _ASM_X86_MMCONFIG_H
 
 #ifdef CONFIG_PCI_MMCONFIG
-extern void __cpuinit fam10h_check_enable_mmcfg(void);
-extern void __cpuinit check_enable_amd_mmconf_dmi(void);
+extern void fam10h_check_enable_mmcfg(void);
+extern void check_enable_amd_mmconf_dmi(void);
 #else
 static inline void fam10h_check_enable_mmcfg(void) { }
 static inline void check_enable_amd_mmconf_dmi(void) { }
index 3e2f42a4b872a2832f10b4d5cb1f2c5de3e18ac4..626cf70082d7c8229b14a529625652f5646fcf09 100644 (file)
@@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { }
 #define default_get_smp_config x86_init_uint_noop
 #endif
 
-void __cpuinit generic_processor_info(int apicid, int version);
+void generic_processor_info(int apicid, int version);
 #ifdef CONFIG_ACPI
 extern void mp_register_ioapic(int id, u32 address, u32 gsi_base);
 extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
index 1b99ee5c9f00d3ee77a6dad30f8f01d4a7d452d0..4064acae625d95ebc904dbaa3d3ad10add9c4443 100644 (file)
@@ -39,7 +39,7 @@ static inline void set_apicid_to_node(int apicid, s16 node)
        __apicid_to_node[apicid] = node;
 }
 
-extern int __cpuinit numa_cpu_node(int cpu);
+extern int numa_cpu_node(int cpu);
 
 #else  /* CONFIG_NUMA */
 static inline void set_apicid_to_node(int apicid, s16 node)
@@ -60,8 +60,8 @@ static inline int numa_cpu_node(int cpu)
 extern void numa_set_node(int cpu, int node);
 extern void numa_clear_node(int cpu);
 extern void __init init_cpu_to_node(void);
-extern void __cpuinit numa_add_cpu(int cpu);
-extern void __cpuinit numa_remove_cpu(int cpu);
+extern void numa_add_cpu(int cpu);
+extern void numa_remove_cpu(int cpu);
 #else  /* CONFIG_NUMA */
 static inline void numa_set_node(int cpu, int node)    { }
 static inline void numa_clear_node(int cpu)            { }
index f2b489cf1602349092d26d6ea68109cca3589c4d..3bf2dd0cf61fec9615253fe3b70d3c3764a35e93 100644 (file)
@@ -55,9 +55,53 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
 #define native_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp)
 #endif
 
+#ifdef CONFIG_MEM_SOFT_DIRTY
+
+/*
+ * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE, _PAGE_BIT_SOFT_DIRTY and
+ * _PAGE_BIT_PROTNONE are taken, split up the 28 bits of offset
+ * into this range.
+ */
+#define PTE_FILE_MAX_BITS      28
+#define PTE_FILE_SHIFT1                (_PAGE_BIT_PRESENT + 1)
+#define PTE_FILE_SHIFT2                (_PAGE_BIT_FILE + 1)
+#define PTE_FILE_SHIFT3                (_PAGE_BIT_PROTNONE + 1)
+#define PTE_FILE_SHIFT4                (_PAGE_BIT_SOFT_DIRTY + 1)
+#define PTE_FILE_BITS1         (PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1)
+#define PTE_FILE_BITS2         (PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1)
+#define PTE_FILE_BITS3         (PTE_FILE_SHIFT4 - PTE_FILE_SHIFT3 - 1)
+
+#define pte_to_pgoff(pte)                                              \
+       ((((pte).pte_low >> (PTE_FILE_SHIFT1))                          \
+         & ((1U << PTE_FILE_BITS1) - 1)))                              \
+       + ((((pte).pte_low >> (PTE_FILE_SHIFT2))                        \
+           & ((1U << PTE_FILE_BITS2) - 1))                             \
+          << (PTE_FILE_BITS1))                                         \
+       + ((((pte).pte_low >> (PTE_FILE_SHIFT3))                        \
+           & ((1U << PTE_FILE_BITS3) - 1))                             \
+          << (PTE_FILE_BITS1 + PTE_FILE_BITS2))                        \
+       + ((((pte).pte_low >> (PTE_FILE_SHIFT4)))                       \
+           << (PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3))
+
+#define pgoff_to_pte(off)                                              \
+       ((pte_t) { .pte_low =                                           \
+        ((((off)) & ((1U << PTE_FILE_BITS1) - 1)) << PTE_FILE_SHIFT1)  \
+        + ((((off) >> PTE_FILE_BITS1)                                  \
+            & ((1U << PTE_FILE_BITS2) - 1))                            \
+           << PTE_FILE_SHIFT2)                                         \
+        + ((((off) >> (PTE_FILE_BITS1 + PTE_FILE_BITS2))               \
+            & ((1U << PTE_FILE_BITS3) - 1))                            \
+           << PTE_FILE_SHIFT3)                                         \
+        + ((((off) >>                                                  \
+             (PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3)))      \
+           << PTE_FILE_SHIFT4)                                         \
+        + _PAGE_FILE })
+
+#else /* CONFIG_MEM_SOFT_DIRTY */
+
 /*
  * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken,
- * split up the 29 bits of offset into this range:
+ * split up the 29 bits of offset into this range.
  */
 #define PTE_FILE_MAX_BITS      29
 #define PTE_FILE_SHIFT1                (_PAGE_BIT_PRESENT + 1)
@@ -88,6 +132,8 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
            << PTE_FILE_SHIFT3)                                         \
         + _PAGE_FILE })
 
+#endif /* CONFIG_MEM_SOFT_DIRTY */
+
 /* Encode and de-code a swap entry */
 #if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
index 4cc9f2b7cdc35a854f185b2ab91d49a9fcd1be4f..81bb91b49a88fa22b2c07fae620e76d674692419 100644 (file)
@@ -179,6 +179,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp)
 /*
  * Bits 0, 6 and 7 are taken in the low part of the pte,
  * put the 32 bits of offset into the high part.
+ *
+ * For soft-dirty tracking 11 bit is taken from
+ * the low part of pte as well.
  */
 #define pte_to_pgoff(pte) ((pte).pte_high)
 #define pgoff_to_pte(off)                                              \
index 7dc305a46058a230ad5eef2df9f5e54b66ac0017..1c00631164c29c1d2d676f8c384141931483363b 100644 (file)
@@ -314,6 +314,36 @@ static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
        return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
 }
 
+static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
+{
+       return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
+}
+
+static inline int pte_swp_soft_dirty(pte_t pte)
+{
+       return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
+}
+
+static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
+{
+       return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
+}
+
+static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
+{
+       return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
+}
+
+static inline pte_t pte_file_mksoft_dirty(pte_t pte)
+{
+       return pte_set_flags(pte, _PAGE_SOFT_DIRTY);
+}
+
+static inline int pte_file_soft_dirty(pte_t pte)
+{
+       return pte_flags(pte) & _PAGE_SOFT_DIRTY;
+}
+
 /*
  * Mask out unsupported bits in a present pgprot.  Non-present pgprots
  * can use those bits for other purposes, so leave them be.
index c98ac63aae487580727cac5d9f194ef04d9913cb..f4843e031131d224280c4c0d845def9a094f3082 100644 (file)
  * they do not conflict with each other.
  */
 
+#define _PAGE_BIT_SOFT_DIRTY   _PAGE_BIT_HIDDEN
+
 #ifdef CONFIG_MEM_SOFT_DIRTY
-#define _PAGE_SOFT_DIRTY       (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
+#define _PAGE_SOFT_DIRTY       (_AT(pteval_t, 1) << _PAGE_BIT_SOFT_DIRTY)
 #else
 #define _PAGE_SOFT_DIRTY       (_AT(pteval_t, 0))
 #endif
 
+/*
+ * Tracking soft dirty bit when a page goes to a swap is tricky.
+ * We need a bit which can be stored in pte _and_ not conflict
+ * with swap entry format. On x86 bits 6 and 7 are *not* involved
+ * into swap entry computation, but bit 6 is used for nonlinear
+ * file mapping, so we borrow bit 7 for soft dirty tracking.
+ */
+#ifdef CONFIG_MEM_SOFT_DIRTY
+#define _PAGE_SWP_SOFT_DIRTY   _PAGE_PSE
+#else
+#define _PAGE_SWP_SOFT_DIRTY   (_AT(pteval_t, 0))
+#endif
+
 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
 #define _PAGE_NX       (_AT(pteval_t, 1) << _PAGE_BIT_NX)
 #else
index 29937c4f6ff8d560900bfbad9a79c919a24aa710..24cf5aefb7048b496082fd271755e3b186e23540 100644 (file)
@@ -164,7 +164,7 @@ extern const struct seq_operations cpuinfo_op;
 #define cache_line_size()      (boot_cpu_data.x86_cache_alignment)
 
 extern void cpu_detect(struct cpuinfo_x86 *c);
-extern void __cpuinit fpu_detect(struct cpuinfo_x86 *c);
+extern void fpu_detect(struct cpuinfo_x86 *c);
 
 extern void early_cpu_init(void);
 extern void identify_boot_cpu(void);
index 60bef663609a4df36c235cfddcb34b1aa07ef2df..bade6ac3b14fc881ee038f85a9fa3233c48f60b6 100644 (file)
@@ -27,7 +27,7 @@ extern int of_ioapic;
 extern u64 initial_dtb;
 extern void add_dtb(u64 data);
 extern void x86_add_irq_domains(void);
-void __cpuinit x86_of_pci_init(void);
+void x86_of_pci_init(void);
 void x86_dtb_init(void);
 #else
 static inline void add_dtb(u64 data) { }
index b073aaea747c200bd5a87db18ff6e33423529153..4137890e88e3ad6144a7bde7910674b7801e84b7 100644 (file)
@@ -179,7 +179,7 @@ static inline int wbinvd_on_all_cpus(void)
 }
 #endif /* CONFIG_SMP */
 
-extern unsigned disabled_cpus __cpuinitdata;
+extern unsigned disabled_cpus;
 
 #ifdef CONFIG_X86_32_SMP
 /*
index 33692eaabab58619c7481cbfc7c6f01be929e5e9..e3ddd7db723f666a98c1baefce55282632fd711b 100644 (file)
@@ -233,8 +233,4 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
 #define arch_read_relax(lock)  cpu_relax()
 #define arch_write_relax(lock) cpu_relax()
 
-/* The {read|write|spin}_lock() on x86 are full memory barriers. */
-static inline void smp_mb__after_lock(void) { }
-#define ARCH_HAS_SMP_MB_AFTER_LOCK
-
 #endif /* _ASM_X86_SPINLOCK_H */
index d81a972dd506f24059bcaa19a5259ca9ff908ede..2627a81253eeaf03336f36ed4ea13dc49baa7183 100644 (file)
@@ -195,7 +195,7 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
        return 0;
 }
 
-static void __cpuinit acpi_register_lapic(int id, u8 enabled)
+static void acpi_register_lapic(int id, u8 enabled)
 {
        unsigned int ver = 0;
 
@@ -607,7 +607,7 @@ void __init acpi_set_irq_model_ioapic(void)
 #ifdef CONFIG_ACPI_HOTPLUG_CPU
 #include <acpi/processor.h>
 
-static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
+static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
 {
 #ifdef CONFIG_ACPI_NUMA
        int nid;
@@ -620,7 +620,7 @@ static void __cpuinit acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
 #endif
 }
 
-static int __cpuinit _acpi_map_lsapic(acpi_handle handle, int *pcpu)
+static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
 {
        struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        union acpi_object *obj;
index 2a34aaf3c8f139ff8bd35f702b7431ff75895c9c..33120100ff5e50486e306f35688620ee8c05754f 100644 (file)
@@ -48,9 +48,20 @@ int x86_acpi_suspend_lowlevel(void)
 #ifndef CONFIG_64BIT
        native_store_gdt((struct desc_ptr *)&header->pmode_gdt);
 
+       /*
+        * We have to check that we can write back the value, and not
+        * just read it.  At least on 90 nm Pentium M (Family 6, Model
+        * 13), reading an invalid MSR is not guaranteed to trap, see
+        * Erratum X4 in "Intel Pentium M Processor on 90 nm Process
+        * with 2-MB L2 Cache and Intel® Processor A100 and A110 on 90
+        * nm process with 512-KB L2 Cache Specification Update".
+        */
        if (!rdmsr_safe(MSR_EFER,
                        &header->pmode_efer_low,
-                       &header->pmode_efer_high))
+                       &header->pmode_efer_high) &&
+           !wrmsr_safe(MSR_EFER,
+                       header->pmode_efer_low,
+                       header->pmode_efer_high))
                header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER);
 #endif /* !CONFIG_64BIT */
 
@@ -61,7 +72,10 @@ int x86_acpi_suspend_lowlevel(void)
        }
        if (!rdmsr_safe(MSR_IA32_MISC_ENABLE,
                        &header->pmode_misc_en_low,
-                       &header->pmode_misc_en_high))
+                       &header->pmode_misc_en_high) &&
+           !wrmsr_safe(MSR_IA32_MISC_ENABLE,
+                       header->pmode_misc_en_low,
+                       header->pmode_misc_en_high))
                header->pmode_behavior |=
                        (1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE);
        header->realmode_flags = acpi_realmode_flags;
index 99663b59123a0066fe42a427bb2a2cb51b8b8a55..eca89c53a7f50598c94ddb6ebab399649b7e747a 100644 (file)
@@ -58,7 +58,7 @@
 
 unsigned int num_processors;
 
-unsigned disabled_cpus __cpuinitdata;
+unsigned disabled_cpus;
 
 /* Processor that is doing the boot up */
 unsigned int boot_cpu_physical_apicid = -1U;
@@ -544,7 +544,7 @@ static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
  * Setup the local APIC timer for this CPU. Copy the initialized values
  * of the boot CPU and register the clock event in the framework.
  */
-static void __cpuinit setup_APIC_timer(void)
+static void setup_APIC_timer(void)
 {
        struct clock_event_device *levt = &__get_cpu_var(lapic_events);
 
@@ -866,7 +866,7 @@ void __init setup_boot_APIC_clock(void)
        setup_APIC_timer();
 }
 
-void __cpuinit setup_secondary_APIC_clock(void)
+void setup_secondary_APIC_clock(void)
 {
        setup_APIC_timer();
 }
@@ -1229,7 +1229,7 @@ void __init init_bsp_APIC(void)
        apic_write(APIC_LVT1, value);
 }
 
-static void __cpuinit lapic_setup_esr(void)
+static void lapic_setup_esr(void)
 {
        unsigned int oldvalue, value, maxlvt;
 
@@ -1276,7 +1276,7 @@ static void __cpuinit lapic_setup_esr(void)
  * Used to setup local APIC while initializing BSP or bringin up APs.
  * Always called with preemption disabled.
  */
-void __cpuinit setup_local_APIC(void)
+void setup_local_APIC(void)
 {
        int cpu = smp_processor_id();
        unsigned int value, queued;
@@ -1471,7 +1471,7 @@ void __cpuinit setup_local_APIC(void)
 #endif
 }
 
-void __cpuinit end_local_APIC_setup(void)
+void end_local_APIC_setup(void)
 {
        lapic_setup_esr();
 
@@ -2107,7 +2107,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
        apic_write(APIC_LVT1, value);
 }
 
-void __cpuinit generic_processor_info(int apicid, int version)
+void generic_processor_info(int apicid, int version)
 {
        int cpu, max = nr_cpu_ids;
        bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2377,7 +2377,7 @@ static struct syscore_ops lapic_syscore_ops = {
        .suspend        = lapic_suspend,
 };
 
-static void __cpuinit apic_pm_activate(void)
+static void apic_pm_activate(void)
 {
        apic_pm_state.active = 1;
 }
@@ -2402,7 +2402,7 @@ static void apic_pm_activate(void) { }
 
 #ifdef CONFIG_X86_64
 
-static int __cpuinit apic_cluster_num(void)
+static int apic_cluster_num(void)
 {
        int i, clusters, zeros;
        unsigned id;
@@ -2447,10 +2447,10 @@ static int __cpuinit apic_cluster_num(void)
        return clusters;
 }
 
-static int __cpuinitdata multi_checked;
-static int __cpuinitdata multi;
+static int multi_checked;
+static int multi;
 
-static int __cpuinit set_multi(const struct dmi_system_id *d)
+static int set_multi(const struct dmi_system_id *d)
 {
        if (multi)
                return 0;
@@ -2459,7 +2459,7 @@ static int __cpuinit set_multi(const struct dmi_system_id *d)
        return 0;
 }
 
-static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = {
+static const struct dmi_system_id multi_dmi_table[] = {
        {
                .callback = set_multi,
                .ident = "IBM System Summit2",
@@ -2471,7 +2471,7 @@ static const __cpuinitconst struct dmi_system_id multi_dmi_table[] = {
        {}
 };
 
-static void __cpuinit dmi_check_multi(void)
+static void dmi_check_multi(void)
 {
        if (multi_checked)
                return;
@@ -2488,7 +2488,7 @@ static void __cpuinit dmi_check_multi(void)
  * multi-chassis.
  * Use DMI to check them
  */
-__cpuinit int apic_is_clustered_box(void)
+int apic_is_clustered_box(void)
 {
        dmi_check_multi();
        if (multi)
index 9a9110918ca719b3a0d2b6a7917899d2762a24bb..3e67f9e3d7ef1e8eb093d9e8398b21aaf1a7b93e 100644 (file)
@@ -74,7 +74,7 @@ static int numachip_phys_pkg_id(int initial_apic_id, int index_msb)
        return initial_apic_id >> index_msb;
 }
 
-static int __cpuinit numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip)
+static int numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip)
 {
        union numachip_csr_g3_ext_irq_gen int_gen;
 
index 0874799a98c6fbe37ee34baaad7cbdc3bd616744..c55224731b2d7f0de89d6a37a00e71bd4d8792ec 100644 (file)
@@ -130,7 +130,7 @@ int                                 es7000_plat;
  */
 
 
-static int __cpuinit wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip)
+static int wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip)
 {
        unsigned long vect = 0, psaival = 0;
 
index d661ee95cabfa0b2619b94f75971cfd33cd3ea7f..1e42e8f305ee2096ed52c20f6c569fe8a8339b7b 100644 (file)
@@ -105,7 +105,7 @@ static void __init smp_dump_qct(void)
        }
 }
 
-void __cpuinit numaq_tsc_disable(void)
+void numaq_tsc_disable(void)
 {
        if (!found_numaq)
                return;
index c88baa4ff0e5650061dbed84fca55b89d4c1b55e..140e29db478d78b9b16dc9cda9c58ed89fe8650d 100644 (file)
@@ -148,7 +148,7 @@ static void init_x2apic_ldr(void)
  /*
   * At CPU state changes, update the x2apic cluster sibling info.
   */
-static int __cpuinit
+static int
 update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
        unsigned int this_cpu = (unsigned long)hcpu;
index 63092afb142e7c3e1e645554134b4bd1be115e3a..1191ac1c9d2598e64d13a1419b4a7a383933ce03 100644 (file)
@@ -209,7 +209,7 @@ EXPORT_SYMBOL_GPL(uv_possible_blades);
 unsigned long sn_rtc_cycles_per_second;
 EXPORT_SYMBOL(sn_rtc_cycles_per_second);
 
-static int __cpuinit uv_wakeup_secondary(int phys_apicid, unsigned long start_rip)
+static int uv_wakeup_secondary(int phys_apicid, unsigned long start_rip)
 {
 #ifdef CONFIG_SMP
        unsigned long val;
@@ -416,7 +416,7 @@ static struct apic __refdata apic_x2apic_uv_x = {
        .safe_wait_icr_idle             = native_safe_x2apic_wait_icr_idle,
 };
 
-static __cpuinit void set_x2apic_extra_bits(int pnode)
+static void set_x2apic_extra_bits(int pnode)
 {
        __this_cpu_write(x2apic_extra_bits, pnode << uvh_apicid.s.pnode_shift);
 }
@@ -735,7 +735,7 @@ static void uv_heartbeat(unsigned long ignored)
        mod_timer_pinned(timer, jiffies + SCIR_CPU_HB_INTERVAL);
 }
 
-static void __cpuinit uv_heartbeat_enable(int cpu)
+static void uv_heartbeat_enable(int cpu)
 {
        while (!uv_cpu_hub_info(cpu)->scir.enabled) {
                struct timer_list *timer = &uv_cpu_hub_info(cpu)->scir.timer;
@@ -752,7 +752,7 @@ static void __cpuinit uv_heartbeat_enable(int cpu)
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static void __cpuinit uv_heartbeat_disable(int cpu)
+static void uv_heartbeat_disable(int cpu)
 {
        if (uv_cpu_hub_info(cpu)->scir.enabled) {
                uv_cpu_hub_info(cpu)->scir.enabled = 0;
@@ -764,8 +764,8 @@ static void __cpuinit uv_heartbeat_disable(int cpu)
 /*
  * cpu hotplug notifier
  */
-static __cpuinit int uv_scir_cpu_notify(struct notifier_block *self,
-                                      unsigned long action, void *hcpu)
+static int uv_scir_cpu_notify(struct notifier_block *self, unsigned long action,
+                             void *hcpu)
 {
        long cpu = (long)hcpu;
 
@@ -835,7 +835,7 @@ int uv_set_vga_state(struct pci_dev *pdev, bool decode,
  * Called on each cpu to initialize the per_cpu UV data area.
  * FIXME: hotplug not supported yet
  */
-void __cpuinit uv_cpu_init(void)
+void uv_cpu_init(void)
 {
        /* CPU 0 initilization will be done via uv_system_init. */
        if (!uv_blade_info)
index c587a8757227b2b5297e1d5607218a2d96802608..08a089043ccfbb669c889ac034091a55aaa92b75 100644 (file)
@@ -69,7 +69,7 @@ static inline int wrmsrl_amd_safe(unsigned msr, unsigned long long val)
 extern void vide(void);
 __asm__(".align 4\nvide: ret");
 
-static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
+static void init_amd_k5(struct cpuinfo_x86 *c)
 {
 /*
  * General Systems BIOSen alias the cpu frequency registers
@@ -87,7 +87,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
 }
 
 
-static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
+static void init_amd_k6(struct cpuinfo_x86 *c)
 {
        u32 l, h;
        int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
@@ -179,7 +179,7 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c)
+static void amd_k7_smp_check(struct cpuinfo_x86 *c)
 {
        /* calling is from identify_secondary_cpu() ? */
        if (!c->cpu_index)
@@ -222,7 +222,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c)
        add_taint(TAINT_UNSAFE_SMP, LOCKDEP_NOW_UNRELIABLE);
 }
 
-static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
+static void init_amd_k7(struct cpuinfo_x86 *c)
 {
        u32 l, h;
 
@@ -267,7 +267,7 @@ static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
  * To workaround broken NUMA config.  Read the comment in
  * srat_detect_node().
  */
-static int __cpuinit nearby_node(int apicid)
+static int nearby_node(int apicid)
 {
        int i, node;
 
@@ -292,7 +292,7 @@ static int __cpuinit nearby_node(int apicid)
  * (2) AMD processors supporting compute units
  */
 #ifdef CONFIG_X86_HT
-static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
+static void amd_get_topology(struct cpuinfo_x86 *c)
 {
        u32 nodes, cores_per_cu = 1;
        u8 node_id;
@@ -342,7 +342,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
  * On a AMD dual core setup the lower bits of the APIC id distingush the cores.
  * Assumes number of cores is a power of two.
  */
-static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
+static void amd_detect_cmp(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_HT
        unsigned bits;
@@ -369,7 +369,7 @@ u16 amd_get_nb_id(int cpu)
 }
 EXPORT_SYMBOL_GPL(amd_get_nb_id);
 
-static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
+static void srat_detect_node(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_NUMA
        int cpu = smp_processor_id();
@@ -421,7 +421,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
 #endif
 }
 
-static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
+static void early_init_amd_mc(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_HT
        unsigned bits, ecx;
@@ -447,7 +447,7 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c)
 #endif
 }
 
-static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c)
+static void bsp_init_amd(struct cpuinfo_x86 *c)
 {
        if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
 
@@ -475,7 +475,7 @@ static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
+static void early_init_amd(struct cpuinfo_x86 *c)
 {
        early_init_amd_mc(c);
 
@@ -512,9 +512,9 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
 
 static const int amd_erratum_383[];
 static const int amd_erratum_400[];
-static bool cpu_has_amd_erratum(const int *erratum);
+static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
 
-static void __cpuinit init_amd(struct cpuinfo_x86 *c)
+static void init_amd(struct cpuinfo_x86 *c)
 {
        u32 dummy;
        unsigned long long value;
@@ -729,19 +729,18 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
                value &= ~(1ULL << 24);
                wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
 
-               if (cpu_has_amd_erratum(amd_erratum_383))
+               if (cpu_has_amd_erratum(c, amd_erratum_383))
                        set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
        }
 
-       if (cpu_has_amd_erratum(amd_erratum_400))
+       if (cpu_has_amd_erratum(c, amd_erratum_400))
                set_cpu_bug(c, X86_BUG_AMD_APIC_C1E);
 
        rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy);
 }
 
 #ifdef CONFIG_X86_32
-static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
-                                                       unsigned int size)
+static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 {
        /* AMD errata T13 (order #21922) */
        if ((c->x86 == 6)) {
@@ -757,7 +756,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
 }
 #endif
 
-static void __cpuinit cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c)
+static void cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c)
 {
        tlb_flushall_shift = 5;
 
@@ -765,7 +764,7 @@ static void __cpuinit cpu_set_tlb_flushall_shift(struct cpuinfo_x86 *c)
                tlb_flushall_shift = 4;
 }
 
-static void __cpuinit cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
+static void cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
 {
        u32 ebx, eax, ecx, edx;
        u16 mask = 0xfff;
@@ -820,7 +819,7 @@ static void __cpuinit cpu_detect_tlb_amd(struct cpuinfo_x86 *c)
        cpu_set_tlb_flushall_shift(c);
 }
 
-static const struct cpu_dev __cpuinitconst amd_cpu_dev = {
+static const struct cpu_dev amd_cpu_dev = {
        .c_vendor       = "AMD",
        .c_ident        = { "AuthenticAMD" },
 #ifdef CONFIG_X86_32
@@ -879,23 +878,13 @@ static const int amd_erratum_400[] =
 static const int amd_erratum_383[] =
        AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
 
-static bool cpu_has_amd_erratum(const int *erratum)
+
+static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
 {
-       struct cpuinfo_x86 *cpu = __this_cpu_ptr(&cpu_info);
        int osvw_id = *erratum++;
        u32 range;
        u32 ms;
 
-       /*
-        * If called early enough that current_cpu_data hasn't been initialized
-        * yet, fall back to boot_cpu_data.
-        */
-       if (cpu->x86 == 0)
-               cpu = &boot_cpu_data;
-
-       if (cpu->x86_vendor != X86_VENDOR_AMD)
-               return false;
-
        if (osvw_id >= 0 && osvw_id < 65536 &&
            cpu_has(cpu, X86_FEATURE_OSVW)) {
                u64 osvw_len;
index 159103c0b1f4b137d40ebca03ce5b3103f6bdccf..fbf6c3bc2400a7f64db2a1118384b82379e453c0 100644 (file)
@@ -11,7 +11,7 @@
 
 #ifdef CONFIG_X86_OOSTORE
 
-static u32 __cpuinit power2(u32 x)
+static u32 power2(u32 x)
 {
        u32 s = 1;
 
@@ -25,7 +25,7 @@ static u32 __cpuinit power2(u32 x)
 /*
  * Set up an actual MCR
  */
-static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key)
+static void centaur_mcr_insert(int reg, u32 base, u32 size, int key)
 {
        u32 lo, hi;
 
@@ -42,7 +42,7 @@ static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key)
  *
  * Shortcut: We know you can't put 4Gig of RAM on a winchip
  */
-static u32 __cpuinit ramtop(void)
+static u32 ramtop(void)
 {
        u32 clip = 0xFFFFFFFFUL;
        u32 top = 0;
@@ -91,7 +91,7 @@ static u32 __cpuinit ramtop(void)
 /*
  * Compute a set of MCR's to give maximum coverage
  */
-static int __cpuinit centaur_mcr_compute(int nr, int key)
+static int centaur_mcr_compute(int nr, int key)
 {
        u32 mem = ramtop();
        u32 root = power2(mem);
@@ -157,7 +157,7 @@ static int __cpuinit centaur_mcr_compute(int nr, int key)
        return ct;
 }
 
-static void __cpuinit centaur_create_optimal_mcr(void)
+static void centaur_create_optimal_mcr(void)
 {
        int used;
        int i;
@@ -181,7 +181,7 @@ static void __cpuinit centaur_create_optimal_mcr(void)
                wrmsr(MSR_IDT_MCR0+i, 0, 0);
 }
 
-static void __cpuinit winchip2_create_optimal_mcr(void)
+static void winchip2_create_optimal_mcr(void)
 {
        u32 lo, hi;
        int used;
@@ -217,7 +217,7 @@ static void __cpuinit winchip2_create_optimal_mcr(void)
 /*
  * Handle the MCR key on the Winchip 2.
  */
-static void __cpuinit winchip2_unprotect_mcr(void)
+static void winchip2_unprotect_mcr(void)
 {
        u32 lo, hi;
        u32 key;
@@ -229,7 +229,7 @@ static void __cpuinit winchip2_unprotect_mcr(void)
        wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
 }
 
-static void __cpuinit winchip2_protect_mcr(void)
+static void winchip2_protect_mcr(void)
 {
        u32 lo, hi;
 
@@ -247,7 +247,7 @@ static void __cpuinit winchip2_protect_mcr(void)
 #define RNG_ENABLED    (1 << 3)
 #define RNG_ENABLE     (1 << 6)        /* MSR_VIA_RNG */
 
-static void __cpuinit init_c3(struct cpuinfo_x86 *c)
+static void init_c3(struct cpuinfo_x86 *c)
 {
        u32  lo, hi;
 
@@ -318,7 +318,7 @@ enum {
                EAMD3D          = 1<<20,
 };
 
-static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
+static void early_init_centaur(struct cpuinfo_x86 *c)
 {
        switch (c->x86) {
 #ifdef CONFIG_X86_32
@@ -337,7 +337,7 @@ static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
 #endif
 }
 
-static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
+static void init_centaur(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_32
        char *name;
@@ -468,7 +468,7 @@ static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
 #endif
 }
 
-static unsigned int __cpuinit
+static unsigned int
 centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 {
 #ifdef CONFIG_X86_32
@@ -488,7 +488,7 @@ centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)
        return size;
 }
 
-static const struct cpu_dev __cpuinitconst centaur_cpu_dev = {
+static const struct cpu_dev centaur_cpu_dev = {
        .c_vendor       = "Centaur",
        .c_ident        = { "CentaurHauls" },
        .c_early_init   = early_init_centaur,
index 548bd039784e631570a7628137d16cb8213ec411..25eb2747b06365fd0cd1a3d276a266a970f36a32 100644 (file)
@@ -63,7 +63,7 @@ void __init setup_cpu_local_masks(void)
        alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask);
 }
 
-static void __cpuinit default_init(struct cpuinfo_x86 *c)
+static void default_init(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_64
        cpu_detect_cache_sizes(c);
@@ -80,13 +80,13 @@ static void __cpuinit default_init(struct cpuinfo_x86 *c)
 #endif
 }
 
-static const struct cpu_dev __cpuinitconst default_cpu = {
+static const struct cpu_dev default_cpu = {
        .c_init         = default_init,
        .c_vendor       = "Unknown",
        .c_x86_vendor   = X86_VENDOR_UNKNOWN,
 };
 
-static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
+static const struct cpu_dev *this_cpu = &default_cpu;
 
 DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
 #ifdef CONFIG_X86_64
@@ -160,8 +160,8 @@ static int __init x86_xsaveopt_setup(char *s)
 __setup("noxsaveopt", x86_xsaveopt_setup);
 
 #ifdef CONFIG_X86_32
-static int cachesize_override __cpuinitdata = -1;
-static int disable_x86_serial_nr __cpuinitdata = 1;
+static int cachesize_override = -1;
+static int disable_x86_serial_nr = 1;
 
 static int __init cachesize_setup(char *str)
 {
@@ -215,12 +215,12 @@ static inline int flag_is_changeable_p(u32 flag)
 }
 
 /* Probe for the CPUID instruction */
-int __cpuinit have_cpuid_p(void)
+int have_cpuid_p(void)
 {
        return flag_is_changeable_p(X86_EFLAGS_ID);
 }
 
-static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
+static void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
 {
        unsigned long lo, hi;
 
@@ -298,7 +298,7 @@ struct cpuid_dependent_feature {
        u32 level;
 };
 
-static const struct cpuid_dependent_feature __cpuinitconst
+static const struct cpuid_dependent_feature
 cpuid_dependent_features[] = {
        { X86_FEATURE_MWAIT,            0x00000005 },
        { X86_FEATURE_DCA,              0x00000009 },
@@ -306,7 +306,7 @@ cpuid_dependent_features[] = {
        { 0, 0 }
 };
 
-static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
+static void filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
 {
        const struct cpuid_dependent_feature *df;
 
@@ -344,7 +344,7 @@ static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
  */
 
 /* Look up CPU names by table lookup. */
-static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c)
+static const char *table_lookup_model(struct cpuinfo_x86 *c)
 {
        const struct cpu_model_info *info;
 
@@ -364,8 +364,8 @@ static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c)
        return NULL;            /* Not found */
 }
 
-__u32 cpu_caps_cleared[NCAPINTS] __cpuinitdata;
-__u32 cpu_caps_set[NCAPINTS] __cpuinitdata;
+__u32 cpu_caps_cleared[NCAPINTS];
+__u32 cpu_caps_set[NCAPINTS];
 
 void load_percpu_segment(int cpu)
 {
@@ -394,9 +394,9 @@ void switch_to_new_gdt(int cpu)
        load_percpu_segment(cpu);
 }
 
-static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {};
+static const struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = {};
 
-static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
+static void get_model_name(struct cpuinfo_x86 *c)
 {
        unsigned int *v;
        char *p, *q;
@@ -425,7 +425,7 @@ static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
        }
 }
 
-void __cpuinit cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
+void cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
 {
        unsigned int n, dummy, ebx, ecx, edx, l2size;
 
@@ -479,7 +479,7 @@ u16 __read_mostly tlb_lld_4m[NR_INFO];
  */
 s8  __read_mostly tlb_flushall_shift = -1;
 
-void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c)
+void cpu_detect_tlb(struct cpuinfo_x86 *c)
 {
        if (this_cpu->c_detect_tlb)
                this_cpu->c_detect_tlb(c);
@@ -493,7 +493,7 @@ void __cpuinit cpu_detect_tlb(struct cpuinfo_x86 *c)
                tlb_flushall_shift);
 }
 
-void __cpuinit detect_ht(struct cpuinfo_x86 *c)
+void detect_ht(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_HT
        u32 eax, ebx, ecx, edx;
@@ -544,7 +544,7 @@ out:
 #endif
 }
 
-static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
+static void get_cpu_vendor(struct cpuinfo_x86 *c)
 {
        char *v = c->x86_vendor_id;
        int i;
@@ -571,7 +571,7 @@ static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
        this_cpu = &default_cpu;
 }
 
-void __cpuinit cpu_detect(struct cpuinfo_x86 *c)
+void cpu_detect(struct cpuinfo_x86 *c)
 {
        /* Get vendor name */
        cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
@@ -601,7 +601,7 @@ void __cpuinit cpu_detect(struct cpuinfo_x86 *c)
        }
 }
 
-void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
+void get_cpu_cap(struct cpuinfo_x86 *c)
 {
        u32 tfms, xlvl;
        u32 ebx;
@@ -652,7 +652,7 @@ void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
        init_scattered_cpuid_features(c);
 }
 
-static void __cpuinit identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
+static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_32
        int i;
@@ -769,7 +769,7 @@ void __init early_cpu_init(void)
  * unless we can find a reliable way to detect all the broken cases.
  * Enable it explicitly on 64-bit for non-constant inputs of cpu_has().
  */
-static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
+static void detect_nopl(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_X86_32
        clear_cpu_cap(c, X86_FEATURE_NOPL);
@@ -778,7 +778,7 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
 #endif
 }
 
-static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
+static void generic_identify(struct cpuinfo_x86 *c)
 {
        c->extended_cpuid_level = 0;
 
@@ -815,7 +815,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 /*
  * This does the hard work of actually picking apart the CPU stuff...
  */
-static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
+static void identify_cpu(struct cpuinfo_x86 *c)
 {
        int i;
 
@@ -960,7 +960,7 @@ void __init identify_boot_cpu(void)
        cpu_detect_tlb(&boot_cpu_data);
 }
 
-void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
+void identify_secondary_cpu(struct cpuinfo_x86 *c)
 {
        BUG_ON(c == &boot_cpu_data);
        identify_cpu(c);
@@ -975,14 +975,14 @@ struct msr_range {
        unsigned        max;
 };
 
-static const struct msr_range msr_range_array[] __cpuinitconst = {
+static const struct msr_range msr_range_array[] = {
        { 0x00000000, 0x00000418},
        { 0xc0000000, 0xc000040b},
        { 0xc0010000, 0xc0010142},
        { 0xc0011000, 0xc001103b},
 };
 
-static void __cpuinit __print_cpu_msr(void)
+static void __print_cpu_msr(void)
 {
        unsigned index_min, index_max;
        unsigned index;
@@ -1001,7 +1001,7 @@ static void __cpuinit __print_cpu_msr(void)
        }
 }
 
-static int show_msr __cpuinitdata;
+static int show_msr;
 
 static __init int setup_show_msr(char *arg)
 {
@@ -1022,7 +1022,7 @@ static __init int setup_noclflush(char *arg)
 }
 __setup("noclflush", setup_noclflush);
 
-void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
+void print_cpu_info(struct cpuinfo_x86 *c)
 {
        const char *vendor = NULL;
 
@@ -1051,7 +1051,7 @@ void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
        print_cpu_msr(c);
 }
 
-void __cpuinit print_cpu_msr(struct cpuinfo_x86 *c)
+void print_cpu_msr(struct cpuinfo_x86 *c)
 {
        if (c->cpu_index < show_msr)
                __print_cpu_msr();
@@ -1216,7 +1216,7 @@ static void dbg_restore_debug_regs(void)
  */
 #ifdef CONFIG_X86_64
 
-void __cpuinit cpu_init(void)
+void cpu_init(void)
 {
        struct orig_ist *oist;
        struct task_struct *me;
@@ -1315,7 +1315,7 @@ void __cpuinit cpu_init(void)
 
 #else
 
-void __cpuinit cpu_init(void)
+void cpu_init(void)
 {
        int cpu = smp_processor_id();
        struct task_struct *curr = current;
index 7582f475b1637479e9125843475f326fe05e5f71..d0969c75ab54bb6bf8f41f41981e27a62478ddd8 100644 (file)
@@ -15,7 +15,7 @@
 /*
  * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU
  */
-static void __cpuinit __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
+static void __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
 {
        unsigned char ccr2, ccr3;
 
@@ -44,7 +44,7 @@ static void __cpuinit __do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
        }
 }
 
-static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
+static void do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
 {
        unsigned long flags;
 
@@ -59,25 +59,25 @@ static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
  * Actually since bugs.h doesn't even reference this perhaps someone should
  * fix the documentation ???
  */
-static unsigned char Cx86_dir0_msb __cpuinitdata = 0;
+static unsigned char Cx86_dir0_msb = 0;
 
-static const char __cpuinitconst Cx86_model[][9] = {
+static const char Cx86_model[][9] = {
        "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ",
        "M II ", "Unknown"
 };
-static const char __cpuinitconst Cx486_name[][5] = {
+static const char Cx486_name[][5] = {
        "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx",
        "SRx2", "DRx2"
 };
-static const char __cpuinitconst Cx486S_name[][4] = {
+static const char Cx486S_name[][4] = {
        "S", "S2", "Se", "S2e"
 };
-static const char __cpuinitconst Cx486D_name[][4] = {
+static const char Cx486D_name[][4] = {
        "DX", "DX2", "?", "?", "?", "DX4"
 };
-static char Cx86_cb[] __cpuinitdata = "?.5x Core/Bus Clock";
-static const char __cpuinitconst cyrix_model_mult1[] = "12??43";
-static const char __cpuinitconst cyrix_model_mult2[] = "12233445";
+static char Cx86_cb[] = "?.5x Core/Bus Clock";
+static const char cyrix_model_mult1[] = "12??43";
+static const char cyrix_model_mult2[] = "12233445";
 
 /*
  * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old
@@ -87,7 +87,7 @@ static const char __cpuinitconst cyrix_model_mult2[] = "12233445";
  * FIXME: our newer udelay uses the tsc. We don't need to frob with SLOP
  */
 
-static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c)
+static void check_cx686_slop(struct cpuinfo_x86 *c)
 {
        unsigned long flags;
 
@@ -112,7 +112,7 @@ static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c)
 }
 
 
-static void __cpuinit set_cx86_reorder(void)
+static void set_cx86_reorder(void)
 {
        u8 ccr3;
 
@@ -127,7 +127,7 @@ static void __cpuinit set_cx86_reorder(void)
        setCx86(CX86_CCR3, ccr3);
 }
 
-static void __cpuinit set_cx86_memwb(void)
+static void set_cx86_memwb(void)
 {
        printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n");
 
@@ -143,7 +143,7 @@ static void __cpuinit set_cx86_memwb(void)
  *     Configure later MediaGX and/or Geode processor.
  */
 
-static void __cpuinit geode_configure(void)
+static void geode_configure(void)
 {
        unsigned long flags;
        u8 ccr3;
@@ -166,7 +166,7 @@ static void __cpuinit geode_configure(void)
        local_irq_restore(flags);
 }
 
-static void __cpuinit early_init_cyrix(struct cpuinfo_x86 *c)
+static void early_init_cyrix(struct cpuinfo_x86 *c)
 {
        unsigned char dir0, dir0_msn, dir1 = 0;
 
@@ -185,7 +185,7 @@ static void __cpuinit early_init_cyrix(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
+static void init_cyrix(struct cpuinfo_x86 *c)
 {
        unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0;
        char *buf = c->x86_model_id;
@@ -356,7 +356,7 @@ static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
 /*
  * Handle National Semiconductor branded processors
  */
-static void __cpuinit init_nsc(struct cpuinfo_x86 *c)
+static void init_nsc(struct cpuinfo_x86 *c)
 {
        /*
         * There may be GX1 processors in the wild that are branded
@@ -405,7 +405,7 @@ static inline int test_cyrix_52div(void)
        return (unsigned char) (test >> 8) == 0x02;
 }
 
-static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c)
+static void cyrix_identify(struct cpuinfo_x86 *c)
 {
        /* Detect Cyrix with disabled CPUID */
        if (c->x86 == 4 && test_cyrix_52div()) {
@@ -441,7 +441,7 @@ static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c)
        }
 }
 
-static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = {
+static const struct cpu_dev cyrix_cpu_dev = {
        .c_vendor       = "Cyrix",
        .c_ident        = { "CyrixInstead" },
        .c_early_init   = early_init_cyrix,
@@ -452,7 +452,7 @@ static const struct cpu_dev __cpuinitconst cyrix_cpu_dev = {
 
 cpu_dev_register(cyrix_cpu_dev);
 
-static const struct cpu_dev __cpuinitconst nsc_cpu_dev = {
+static const struct cpu_dev nsc_cpu_dev = {
        .c_vendor       = "NSC",
        .c_ident        = { "Geode by NSC" },
        .c_init         = init_nsc,
index 1e7e84a02ebaf4924702019c18cc5d1101609c30..87279212d318664dd51ddc0d6c6dc6a3c458c848 100644 (file)
@@ -60,7 +60,7 @@ detect_hypervisor_vendor(void)
        }
 }
 
-void __cpuinit init_hypervisor(struct cpuinfo_x86 *c)
+void init_hypervisor(struct cpuinfo_x86 *c)
 {
        if (x86_hyper && x86_hyper->set_cpu_features)
                x86_hyper->set_cpu_features(c);
index 9b0c441c03f5fef93c4d1f25fcb3cf7368370601..ec7299566f797b1d77a05b0c6be01178d9677e17 100644 (file)
@@ -26,7 +26,7 @@
 #include <asm/apic.h>
 #endif
 
-static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
+static void early_init_intel(struct cpuinfo_x86 *c)
 {
        u64 misc_enable;
 
@@ -163,7 +163,7 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
  *     This is called before we do cpu ident work
  */
 
-int __cpuinit ppro_with_ram_bug(void)
+int ppro_with_ram_bug(void)
 {
        /* Uses data from early_cpu_detect now */
        if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
@@ -176,7 +176,7 @@ int __cpuinit ppro_with_ram_bug(void)
        return 0;
 }
 
-static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c)
+static void intel_smp_check(struct cpuinfo_x86 *c)
 {
        /* calling is from identify_secondary_cpu() ? */
        if (!c->cpu_index)
@@ -196,7 +196,7 @@ static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
+static void intel_workarounds(struct cpuinfo_x86 *c)
 {
        unsigned long lo, hi;
 
@@ -275,12 +275,12 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
        intel_smp_check(c);
 }
 #else
-static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
+static void intel_workarounds(struct cpuinfo_x86 *c)
 {
 }
 #endif
 
-static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
+static void srat_detect_node(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_NUMA
        unsigned node;
@@ -300,7 +300,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
 /*
  * find out the number of processor cores on the die
  */
-static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
+static int intel_num_cpu_cores(struct cpuinfo_x86 *c)
 {
        unsigned int eax, ebx, ecx, edx;
 
@@ -315,7 +315,7 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
                return 1;
 }
 
-static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
+static void detect_vmx_virtcap(struct cpuinfo_x86 *c)
 {
        /* Intel VMX MSR indicated features */
 #define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW   0x00200000
@@ -353,7 +353,7 @@ static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit init_intel(struct cpuinfo_x86 *c)
+static void init_intel(struct cpuinfo_x86 *c)
 {
        unsigned int l2 = 0;
 
@@ -472,7 +472,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
 }
 
 #ifdef CONFIG_X86_32
-static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
+static unsigned int intel_size_cache(struct cpuinfo_x86 *c, unsigned int size)
 {
        /*
         * Intel PIII Tualatin. This comes in two flavours.
@@ -506,7 +506,7 @@ static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 *c, unsigned i
 
 #define STLB_4K                0x41
 
-static const struct _tlb_table intel_tlb_table[] __cpuinitconst = {
+static const struct _tlb_table intel_tlb_table[] = {
        { 0x01, TLB_INST_4K,            32,     " TLB_INST 4 KByte pages, 4-way set associative" },
        { 0x02, TLB_INST_4M,            2,      " TLB_INST 4 MByte pages, full associative" },
        { 0x03, TLB_DATA_4K,            64,     " TLB_DATA 4 KByte pages, 4-way set associative" },
@@ -536,7 +536,7 @@ static const struct _tlb_table intel_tlb_table[] __cpuinitconst = {
        { 0x00, 0, 0 }
 };
 
-static void __cpuinit intel_tlb_lookup(const unsigned char desc)
+static void intel_tlb_lookup(const unsigned char desc)
 {
        unsigned char k;
        if (desc == 0)
@@ -605,7 +605,7 @@ static void __cpuinit intel_tlb_lookup(const unsigned char desc)
        }
 }
 
-static void __cpuinit intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c)
+static void intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c)
 {
        switch ((c->x86 << 8) + c->x86_model) {
        case 0x60f: /* original 65 nm celeron/pentium/core2/xeon, "Merom"/"Conroe" */
@@ -634,7 +634,7 @@ static void __cpuinit intel_tlb_flushall_shift_set(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c)
+static void intel_detect_tlb(struct cpuinfo_x86 *c)
 {
        int i, j, n;
        unsigned int regs[4];
@@ -661,7 +661,7 @@ static void __cpuinit intel_detect_tlb(struct cpuinfo_x86 *c)
        intel_tlb_flushall_shift_set(c);
 }
 
-static const struct cpu_dev __cpuinitconst intel_cpu_dev = {
+static const struct cpu_dev intel_cpu_dev = {
        .c_vendor       = "Intel",
        .c_ident        = { "GenuineIntel" },
 #ifdef CONFIG_X86_32
index 8dc72dda66fe0a301a8eb87ab3fd9ac078bd5200..1414c90feabaa25014d6b4dfb5ecde1eafceb37f 100644 (file)
@@ -37,7 +37,7 @@ struct _cache_table {
 /* All the cache descriptor types we care about (no TLB or
    trace cache entries) */
 
-static const struct _cache_table __cpuinitconst cache_table[] =
+static const struct _cache_table cache_table[] =
 {
        { 0x06, LVL_1_INST, 8 },        /* 4-way set assoc, 32 byte line size */
        { 0x08, LVL_1_INST, 16 },       /* 4-way set assoc, 32 byte line size */
@@ -203,7 +203,7 @@ union l3_cache {
        unsigned val;
 };
 
-static const unsigned short __cpuinitconst assocs[] = {
+static const unsigned short assocs[] = {
        [1] = 1,
        [2] = 2,
        [4] = 4,
@@ -217,10 +217,10 @@ static const unsigned short __cpuinitconst assocs[] = {
        [0xf] = 0xffff /* fully associative - no way to show this currently */
 };
 
-static const unsigned char __cpuinitconst levels[] = { 1, 1, 2, 3 };
-static const unsigned char __cpuinitconst types[] = { 1, 2, 3, 3 };
+static const unsigned char levels[] = { 1, 1, 2, 3 };
+static const unsigned char types[] = { 1, 2, 3, 3 };
 
-static void __cpuinit
+static void
 amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
                     union _cpuid4_leaf_ebx *ebx,
                     union _cpuid4_leaf_ecx *ecx)
@@ -302,7 +302,7 @@ struct _cache_attr {
 /*
  * L3 cache descriptors
  */
-static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb)
+static void amd_calc_l3_indices(struct amd_northbridge *nb)
 {
        struct amd_l3_cache *l3 = &nb->l3_cache;
        unsigned int sc0, sc1, sc2, sc3;
@@ -325,7 +325,7 @@ static void __cpuinit amd_calc_l3_indices(struct amd_northbridge *nb)
        l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1;
 }
 
-static void __cpuinit amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index)
+static void amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf, int index)
 {
        int node;
 
@@ -528,8 +528,7 @@ static struct _cache_attr subcaches =
 #endif  /* CONFIG_AMD_NB && CONFIG_SYSFS */
 
 static int
-__cpuinit cpuid4_cache_lookup_regs(int index,
-                                  struct _cpuid4_info_regs *this_leaf)
+cpuid4_cache_lookup_regs(int index, struct _cpuid4_info_regs *this_leaf)
 {
        union _cpuid4_leaf_eax  eax;
        union _cpuid4_leaf_ebx  ebx;
@@ -560,7 +559,7 @@ __cpuinit cpuid4_cache_lookup_regs(int index,
        return 0;
 }
 
-static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c)
+static int find_num_cache_leaves(struct cpuinfo_x86 *c)
 {
        unsigned int            eax, ebx, ecx, edx, op;
        union _cpuid4_leaf_eax  cache_eax;
@@ -580,7 +579,7 @@ static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c)
        return i;
 }
 
-void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c)
+void init_amd_cacheinfo(struct cpuinfo_x86 *c)
 {
 
        if (cpu_has_topoext) {
@@ -593,7 +592,7 @@ void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c)
        }
 }
 
-unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
+unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c)
 {
        /* Cache sizes */
        unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0;
@@ -744,7 +743,7 @@ static DEFINE_PER_CPU(struct _cpuid4_info *, ici_cpuid4_info);
 
 #ifdef CONFIG_SMP
 
-static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
+static int cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
 {
        struct _cpuid4_info *this_leaf;
        int i, sibling;
@@ -793,7 +792,7 @@ static int __cpuinit cache_shared_amd_cpu_map_setup(unsigned int cpu, int index)
        return 1;
 }
 
-static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
+static void cache_shared_cpu_map_setup(unsigned int cpu, int index)
 {
        struct _cpuid4_info *this_leaf, *sibling_leaf;
        unsigned long num_threads_sharing;
@@ -828,7 +827,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
                }
        }
 }
-static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
+static void cache_remove_shared_cpu_map(unsigned int cpu, int index)
 {
        struct _cpuid4_info     *this_leaf, *sibling_leaf;
        int sibling;
@@ -841,16 +840,16 @@ static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
        }
 }
 #else
-static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
+static void cache_shared_cpu_map_setup(unsigned int cpu, int index)
 {
 }
 
-static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
+static void cache_remove_shared_cpu_map(unsigned int cpu, int index)
 {
 }
 #endif
 
-static void __cpuinit free_cache_attributes(unsigned int cpu)
+static void free_cache_attributes(unsigned int cpu)
 {
        int i;
 
@@ -861,7 +860,7 @@ static void __cpuinit free_cache_attributes(unsigned int cpu)
        per_cpu(ici_cpuid4_info, cpu) = NULL;
 }
 
-static void __cpuinit get_cpu_leaves(void *_retval)
+static void get_cpu_leaves(void *_retval)
 {
        int j, *retval = _retval, cpu = smp_processor_id();
 
@@ -881,7 +880,7 @@ static void __cpuinit get_cpu_leaves(void *_retval)
        }
 }
 
-static int __cpuinit detect_cache_attributes(unsigned int cpu)
+static int detect_cache_attributes(unsigned int cpu)
 {
        int                     retval;
 
@@ -1015,7 +1014,7 @@ static struct attribute *default_attrs[] = {
 };
 
 #ifdef CONFIG_AMD_NB
-static struct attribute ** __cpuinit amd_l3_attrs(void)
+static struct attribute **amd_l3_attrs(void)
 {
        static struct attribute **attrs;
        int n;
@@ -1091,7 +1090,7 @@ static struct kobj_type ktype_percpu_entry = {
        .sysfs_ops      = &sysfs_ops,
 };
 
-static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu)
+static void cpuid4_cache_sysfs_exit(unsigned int cpu)
 {
        kfree(per_cpu(ici_cache_kobject, cpu));
        kfree(per_cpu(ici_index_kobject, cpu));
@@ -1100,7 +1099,7 @@ static void __cpuinit cpuid4_cache_sysfs_exit(unsigned int cpu)
        free_cache_attributes(cpu);
 }
 
-static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu)
+static int cpuid4_cache_sysfs_init(unsigned int cpu)
 {
        int err;
 
@@ -1132,7 +1131,7 @@ err_out:
 static DECLARE_BITMAP(cache_dev_map, NR_CPUS);
 
 /* Add/Remove cache interface for CPU device */
-static int __cpuinit cache_add_dev(struct device *dev)
+static int cache_add_dev(struct device *dev)
 {
        unsigned int cpu = dev->id;
        unsigned long i, j;
@@ -1183,7 +1182,7 @@ static int __cpuinit cache_add_dev(struct device *dev)
        return 0;
 }
 
-static void __cpuinit cache_remove_dev(struct device *dev)
+static void cache_remove_dev(struct device *dev)
 {
        unsigned int cpu = dev->id;
        unsigned long i;
@@ -1200,8 +1199,8 @@ static void __cpuinit cache_remove_dev(struct device *dev)
        cpuid4_cache_sysfs_exit(cpu);
 }
 
-static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
-                                       unsigned long action, void *hcpu)
+static int cacheinfo_cpu_callback(struct notifier_block *nfb,
+                                 unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
        struct device *dev;
@@ -1220,7 +1219,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
+static struct notifier_block cacheinfo_cpu_notifier = {
        .notifier_call = cacheinfo_cpu_callback,
 };
 
index e2703520d1208539d21447d6f570a767b7e51f48..c370e1c4468ba1a82d98eaef03d7100c05922eeb 100644 (file)
@@ -111,8 +111,8 @@ static struct severity {
 #ifdef CONFIG_MEMORY_FAILURE
        MCESEV(
                KEEP, "Action required but unaffected thread is continuable",
-               SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR|MCACOD, MCI_UC_SAR|MCI_ADDR),
-               MCGMASK(MCG_STATUS_RIPV, MCG_STATUS_RIPV)
+               SER, MASK(MCI_STATUS_OVER|MCI_UC_SAR|MCI_ADDR, MCI_UC_SAR|MCI_ADDR),
+               MCGMASK(MCG_STATUS_RIPV|MCG_STATUS_EIPV, MCG_STATUS_RIPV)
                ),
        MCESEV(
                AR, "Action required: data load error in a user process",
index bf49cdbb010f3d519fa7f33eb07ba396877960d5..87a65c939bcdb27c61c636804646c941b2ba892a 100644 (file)
@@ -1363,7 +1363,7 @@ int mce_notify_irq(void)
 }
 EXPORT_SYMBOL_GPL(mce_notify_irq);
 
-static int __cpuinit __mcheck_cpu_mce_banks_init(void)
+static int __mcheck_cpu_mce_banks_init(void)
 {
        int i;
        u8 num_banks = mca_cfg.banks;
@@ -1384,7 +1384,7 @@ static int __cpuinit __mcheck_cpu_mce_banks_init(void)
 /*
  * Initialize Machine Checks for a CPU.
  */
-static int __cpuinit __mcheck_cpu_cap_init(void)
+static int __mcheck_cpu_cap_init(void)
 {
        unsigned b;
        u64 cap;
@@ -1483,7 +1483,7 @@ static void quirk_sandybridge_ifu(int bank, struct mce *m, struct pt_regs *regs)
 }
 
 /* Add per CPU specific workarounds here */
-static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
+static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
 {
        struct mca_config *cfg = &mca_cfg;
 
@@ -1593,7 +1593,7 @@ static int __cpuinit __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
        return 0;
 }
 
-static int __cpuinit __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
+static int __mcheck_cpu_ancient_init(struct cpuinfo_x86 *c)
 {
        if (c->x86 != 5)
                return 0;
@@ -1664,7 +1664,7 @@ void (*machine_check_vector)(struct pt_regs *, long error_code) =
  * Called for each booted CPU to set up machine checks.
  * Must be called with preempt off:
  */
-void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
+void mcheck_cpu_init(struct cpuinfo_x86 *c)
 {
        if (mca_cfg.disabled)
                return;
@@ -2082,7 +2082,6 @@ static struct bus_type mce_subsys = {
 
 DEFINE_PER_CPU(struct device *, mce_device);
 
-__cpuinitdata
 void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
 
 static inline struct mce_bank *attr_to_bank(struct device_attribute *attr)
@@ -2228,7 +2227,7 @@ static void mce_device_release(struct device *dev)
 }
 
 /* Per cpu device init. All of the cpus still share the same ctrl bank: */
-static __cpuinit int mce_device_create(unsigned int cpu)
+static int mce_device_create(unsigned int cpu)
 {
        struct device *dev;
        int err;
@@ -2274,7 +2273,7 @@ error:
        return err;
 }
 
-static __cpuinit void mce_device_remove(unsigned int cpu)
+static void mce_device_remove(unsigned int cpu)
 {
        struct device *dev = per_cpu(mce_device, cpu);
        int i;
@@ -2294,7 +2293,7 @@ static __cpuinit void mce_device_remove(unsigned int cpu)
 }
 
 /* Make sure there are no machine checks on offlined CPUs. */
-static void __cpuinit mce_disable_cpu(void *h)
+static void mce_disable_cpu(void *h)
 {
        unsigned long action = *(unsigned long *)h;
        int i;
@@ -2312,7 +2311,7 @@ static void __cpuinit mce_disable_cpu(void *h)
        }
 }
 
-static void __cpuinit mce_reenable_cpu(void *h)
+static void mce_reenable_cpu(void *h)
 {
        unsigned long action = *(unsigned long *)h;
        int i;
@@ -2331,7 +2330,7 @@ static void __cpuinit mce_reenable_cpu(void *h)
 }
 
 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
-static int __cpuinit
+static int
 mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
@@ -2367,7 +2366,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
        return NOTIFY_OK;
 }
 
-static struct notifier_block mce_cpu_notifier __cpuinitdata = {
+static struct notifier_block mce_cpu_notifier = {
        .notifier_call = mce_cpu_callback,
 };
 
index 9cb52767999aa62bc54df600f87f3b7ec80f73cf..603df4f74640c827db1c889f793be31e1f853075 100644 (file)
@@ -458,10 +458,8 @@ static struct kobj_type threshold_ktype = {
        .default_attrs          = default_attrs,
 };
 
-static __cpuinit int allocate_threshold_blocks(unsigned int cpu,
-                                              unsigned int bank,
-                                              unsigned int block,
-                                              u32 address)
+static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
+                                    unsigned int block, u32 address)
 {
        struct threshold_block *b = NULL;
        u32 low, high;
@@ -543,7 +541,7 @@ out_free:
        return err;
 }
 
-static __cpuinit int __threshold_add_blocks(struct threshold_bank *b)
+static int __threshold_add_blocks(struct threshold_bank *b)
 {
        struct list_head *head = &b->blocks->miscj;
        struct threshold_block *pos = NULL;
@@ -567,7 +565,7 @@ static __cpuinit int __threshold_add_blocks(struct threshold_bank *b)
        return err;
 }
 
-static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
+static int threshold_create_bank(unsigned int cpu, unsigned int bank)
 {
        struct device *dev = per_cpu(mce_device, cpu);
        struct amd_northbridge *nb = NULL;
@@ -632,7 +630,7 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
 }
 
 /* create dir/files for all valid threshold banks */
-static __cpuinit int threshold_create_device(unsigned int cpu)
+static int threshold_create_device(unsigned int cpu)
 {
        unsigned int bank;
        struct threshold_bank **bp;
@@ -736,7 +734,7 @@ static void threshold_remove_device(unsigned int cpu)
 }
 
 /* get notified when a cpu comes on/off */
-static void __cpuinit
+static void
 amd_64_threshold_cpu_callback(unsigned long action, unsigned int cpu)
 {
        switch (action) {
index 41e8e00a663703df0592eec7be74aea5c181979c..3eec7de76efbb4650ea760f5163d495f47fd1f1d 100644 (file)
@@ -240,8 +240,7 @@ __setup("int_pln_enable", int_pln_enable_setup);
 
 #ifdef CONFIG_SYSFS
 /* Add/Remove thermal_throttle interface for CPU device: */
-static __cpuinit int thermal_throttle_add_dev(struct device *dev,
-                               unsigned int cpu)
+static int thermal_throttle_add_dev(struct device *dev, unsigned int cpu)
 {
        int err;
        struct cpuinfo_x86 *c = &cpu_data(cpu);
@@ -267,7 +266,7 @@ static __cpuinit int thermal_throttle_add_dev(struct device *dev,
        return err;
 }
 
-static __cpuinit void thermal_throttle_remove_dev(struct device *dev)
+static void thermal_throttle_remove_dev(struct device *dev)
 {
        sysfs_remove_group(&dev->kobj, &thermal_attr_group);
 }
@@ -276,7 +275,7 @@ static __cpuinit void thermal_throttle_remove_dev(struct device *dev)
 static DEFINE_MUTEX(therm_cpu_lock);
 
 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
-static __cpuinit int
+static int
 thermal_throttle_cpu_callback(struct notifier_block *nfb,
                              unsigned long action,
                              void *hcpu)
@@ -307,7 +306,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
        return notifier_from_errno(err);
 }
 
-static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
+static struct notifier_block thermal_throttle_cpu_notifier =
 {
        .notifier_call = thermal_throttle_cpu_callback,
 };
index 9e581c5cf6d0db026e524a1dd881abe6cc61e7bb..a7c7305030cc6c9600a601c1dd51f19560ac3830 100644 (file)
@@ -1295,7 +1295,7 @@ perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs)
 struct event_constraint emptyconstraint;
 struct event_constraint unconstrained;
 
-static int __cpuinit
+static int
 x86_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (long)hcpu;
index 5f0581e713c2dff7f00b02d26428a777a95e1b17..e09f0bfb7b8f23b3206ed623289df4b9bff67605 100644 (file)
@@ -851,7 +851,7 @@ static void clear_APIC_ibs(void *dummy)
                setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1);
 }
 
-static int __cpuinit
+static int
 perf_ibs_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
 {
        switch (action & ~CPU_TASKS_FROZEN) {
index c0c661adf03e2efd9f0735719864913ca886a1f7..754291adec338b34317d5c07a359741e5e298d80 100644 (file)
@@ -288,13 +288,13 @@ static struct pmu amd_l2_pmu = {
        .read           = amd_uncore_read,
 };
 
-static struct amd_uncore * __cpuinit amd_uncore_alloc(unsigned int cpu)
+static struct amd_uncore *amd_uncore_alloc(unsigned int cpu)
 {
        return kzalloc_node(sizeof(struct amd_uncore), GFP_KERNEL,
                        cpu_to_node(cpu));
 }
 
-static void __cpuinit amd_uncore_cpu_up_prepare(unsigned int cpu)
+static void amd_uncore_cpu_up_prepare(unsigned int cpu)
 {
        struct amd_uncore *uncore;
 
@@ -322,8 +322,8 @@ static void __cpuinit amd_uncore_cpu_up_prepare(unsigned int cpu)
 }
 
 static struct amd_uncore *
-__cpuinit amd_uncore_find_online_sibling(struct amd_uncore *this,
-                                        struct amd_uncore * __percpu *uncores)
+amd_uncore_find_online_sibling(struct amd_uncore *this,
+                              struct amd_uncore * __percpu *uncores)
 {
        unsigned int cpu;
        struct amd_uncore *that;
@@ -348,7 +348,7 @@ __cpuinit amd_uncore_find_online_sibling(struct amd_uncore *this,
        return this;
 }
 
-static void __cpuinit amd_uncore_cpu_starting(unsigned int cpu)
+static void amd_uncore_cpu_starting(unsigned int cpu)
 {
        unsigned int eax, ebx, ecx, edx;
        struct amd_uncore *uncore;
@@ -376,8 +376,8 @@ static void __cpuinit amd_uncore_cpu_starting(unsigned int cpu)
        }
 }
 
-static void __cpuinit uncore_online(unsigned int cpu,
-                                   struct amd_uncore * __percpu *uncores)
+static void uncore_online(unsigned int cpu,
+                         struct amd_uncore * __percpu *uncores)
 {
        struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu);
 
@@ -388,7 +388,7 @@ static void __cpuinit uncore_online(unsigned int cpu,
                cpumask_set_cpu(cpu, uncore->active_mask);
 }
 
-static void __cpuinit amd_uncore_cpu_online(unsigned int cpu)
+static void amd_uncore_cpu_online(unsigned int cpu)
 {
        if (amd_uncore_nb)
                uncore_online(cpu, amd_uncore_nb);
@@ -397,8 +397,8 @@ static void __cpuinit amd_uncore_cpu_online(unsigned int cpu)
                uncore_online(cpu, amd_uncore_l2);
 }
 
-static void __cpuinit uncore_down_prepare(unsigned int cpu,
-                                         struct amd_uncore * __percpu *uncores)
+static void uncore_down_prepare(unsigned int cpu,
+                               struct amd_uncore * __percpu *uncores)
 {
        unsigned int i;
        struct amd_uncore *this = *per_cpu_ptr(uncores, cpu);
@@ -423,7 +423,7 @@ static void __cpuinit uncore_down_prepare(unsigned int cpu,
        }
 }
 
-static void __cpuinit amd_uncore_cpu_down_prepare(unsigned int cpu)
+static void amd_uncore_cpu_down_prepare(unsigned int cpu)
 {
        if (amd_uncore_nb)
                uncore_down_prepare(cpu, amd_uncore_nb);
@@ -432,8 +432,7 @@ static void __cpuinit amd_uncore_cpu_down_prepare(unsigned int cpu)
                uncore_down_prepare(cpu, amd_uncore_l2);
 }
 
-static void __cpuinit uncore_dead(unsigned int cpu,
-                                 struct amd_uncore * __percpu *uncores)
+static void uncore_dead(unsigned int cpu, struct amd_uncore * __percpu *uncores)
 {
        struct amd_uncore *uncore = *per_cpu_ptr(uncores, cpu);
 
@@ -445,7 +444,7 @@ static void __cpuinit uncore_dead(unsigned int cpu,
        *per_cpu_ptr(amd_uncore_nb, cpu) = NULL;
 }
 
-static void __cpuinit amd_uncore_cpu_dead(unsigned int cpu)
+static void amd_uncore_cpu_dead(unsigned int cpu)
 {
        if (amd_uncore_nb)
                uncore_dead(cpu, amd_uncore_nb);
@@ -454,7 +453,7 @@ static void __cpuinit amd_uncore_cpu_dead(unsigned int cpu)
                uncore_dead(cpu, amd_uncore_l2);
 }
 
-static int __cpuinit
+static int
 amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action,
                        void *hcpu)
 {
@@ -489,7 +488,7 @@ amd_uncore_cpu_notifier(struct notifier_block *self, unsigned long action,
        return NOTIFY_OK;
 }
 
-static struct notifier_block amd_uncore_cpu_notifier_block __cpuinitdata = {
+static struct notifier_block amd_uncore_cpu_notifier_block = {
        .notifier_call  = amd_uncore_cpu_notifier,
        .priority       = CPU_PRI_PERF + 1,
 };
index fbc9210b45bcbe62fd2c1b765a46701c2eb21212..a45d8d4ace1016b2ea7903569c6cacb43884df20 100644 (file)
@@ -2270,6 +2270,7 @@ __init int intel_pmu_init(void)
        case 70:
        case 71:
        case 63:
+       case 69:
                x86_pmu.late_ack = true;
                memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, sizeof(hw_cache_event_ids));
                memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
index 9dd99751ccf9eb205643a539d3b654e7a0867d26..1fb6c72717bd9e721a19e634852dc06d0af6f485 100644 (file)
@@ -314,8 +314,8 @@ static struct uncore_event_desc snbep_uncore_imc_events[] = {
 static struct uncore_event_desc snbep_uncore_qpi_events[] = {
        INTEL_UNCORE_EVENT_DESC(clockticks,       "event=0x14"),
        INTEL_UNCORE_EVENT_DESC(txl_flits_active, "event=0x00,umask=0x06"),
-       INTEL_UNCORE_EVENT_DESC(drs_data,         "event=0x02,umask=0x08"),
-       INTEL_UNCORE_EVENT_DESC(ncb_data,         "event=0x03,umask=0x04"),
+       INTEL_UNCORE_EVENT_DESC(drs_data,         "event=0x102,umask=0x08"),
+       INTEL_UNCORE_EVENT_DESC(ncb_data,         "event=0x103,umask=0x04"),
        { /* end: all zeroes */ },
 };
 
@@ -3297,7 +3297,7 @@ static void __init uncore_pci_exit(void)
 /* CPU hot plug/unplug are serialized by cpu_add_remove_lock mutex */
 static LIST_HEAD(boxes_to_free);
 
-static void __cpuinit uncore_kfree_boxes(void)
+static void uncore_kfree_boxes(void)
 {
        struct intel_uncore_box *box;
 
@@ -3309,7 +3309,7 @@ static void __cpuinit uncore_kfree_boxes(void)
        }
 }
 
-static void __cpuinit uncore_cpu_dying(int cpu)
+static void uncore_cpu_dying(int cpu)
 {
        struct intel_uncore_type *type;
        struct intel_uncore_pmu *pmu;
@@ -3328,7 +3328,7 @@ static void __cpuinit uncore_cpu_dying(int cpu)
        }
 }
 
-static int __cpuinit uncore_cpu_starting(int cpu)
+static int uncore_cpu_starting(int cpu)
 {
        struct intel_uncore_type *type;
        struct intel_uncore_pmu *pmu;
@@ -3371,7 +3371,7 @@ static int __cpuinit uncore_cpu_starting(int cpu)
        return 0;
 }
 
-static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id)
+static int uncore_cpu_prepare(int cpu, int phys_id)
 {
        struct intel_uncore_type *type;
        struct intel_uncore_pmu *pmu;
@@ -3397,7 +3397,7 @@ static int __cpuinit uncore_cpu_prepare(int cpu, int phys_id)
        return 0;
 }
 
-static void __cpuinit
+static void
 uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_cpu)
 {
        struct intel_uncore_type *type;
@@ -3435,7 +3435,7 @@ uncore_change_context(struct intel_uncore_type **uncores, int old_cpu, int new_c
        }
 }
 
-static void __cpuinit uncore_event_exit_cpu(int cpu)
+static void uncore_event_exit_cpu(int cpu)
 {
        int i, phys_id, target;
 
@@ -3463,7 +3463,7 @@ static void __cpuinit uncore_event_exit_cpu(int cpu)
        uncore_change_context(pci_uncores, cpu, target);
 }
 
-static void __cpuinit uncore_event_init_cpu(int cpu)
+static void uncore_event_init_cpu(int cpu)
 {
        int i, phys_id;
 
@@ -3479,8 +3479,8 @@ static void __cpuinit uncore_event_init_cpu(int cpu)
        uncore_change_context(pci_uncores, -1, cpu);
 }
 
-static int
__cpuinit uncore_cpu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
+static int uncore_cpu_notifier(struct notifier_block *self,
                             unsigned long action, void *hcpu)
 {
        unsigned int cpu = (long)hcpu;
 
@@ -3520,7 +3520,7 @@ static int
        return NOTIFY_OK;
 }
 
-static struct notifier_block uncore_cpu_nb __cpuinitdata = {
+static struct notifier_block uncore_cpu_nb = {
        .notifier_call  = uncore_cpu_notifier,
        /*
         * to migrate uncore events, our notifier should be executed
index feca286c2bb4a510a7f10c4cb6a1a67d06e3621c..88db010845cb26a2594170acc2387cee75a20bbc 100644 (file)
@@ -52,7 +52,7 @@ static inline int rdrand_long(unsigned long *v)
  */
 #define RESEED_LOOP ((512*128)/sizeof(unsigned long))
 
-void __cpuinit x86_init_rdrand(struct cpuinfo_x86 *c)
+void x86_init_rdrand(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_ARCH_RANDOM
        unsigned long tmp;
index d92b5dad15dd43069115d179f9487e2ba9603ffc..f2cc63e9cf08f94f50b5f618e1c07b438ac5071e 100644 (file)
@@ -24,13 +24,13 @@ enum cpuid_regs {
        CR_EBX
 };
 
-void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
+void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
 {
        u32 max_level;
        u32 regs[4];
        const struct cpuid_bit *cb;
 
-       static const struct cpuid_bit __cpuinitconst cpuid_bits[] = {
+       static const struct cpuid_bit cpuid_bits[] = {
                { X86_FEATURE_DTHERM,           CR_EAX, 0, 0x00000006, 0 },
                { X86_FEATURE_IDA,              CR_EAX, 1, 0x00000006, 0 },
                { X86_FEATURE_ARAT,             CR_EAX, 2, 0x00000006, 0 },
index 4397e987a1cfbc062dbf087e7d6a5b6577abeafb..4c60eaf0571c2fb1a6d73258861398fc6bcc963e 100644 (file)
@@ -26,7 +26,7 @@
  * exists, use it for populating initial_apicid and cpu topology
  * detection.
  */
-void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
+void detect_extended_topology(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_SMP
        unsigned int eax, ebx, ecx, edx, sub_index;
index 28000743bbb06984b0b7182caca09833fed756b9..aa0430d69b900ba0eabdb8d2764ee5fc4b902f67 100644 (file)
@@ -5,7 +5,7 @@
 #include <asm/msr.h>
 #include "cpu.h"
 
-static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c)
+static void early_init_transmeta(struct cpuinfo_x86 *c)
 {
        u32 xlvl;
 
@@ -17,7 +17,7 @@ static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c)
        }
 }
 
-static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
+static void init_transmeta(struct cpuinfo_x86 *c)
 {
        unsigned int cap_mask, uk, max, dummy;
        unsigned int cms_rev1, cms_rev2;
@@ -98,7 +98,7 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
 #endif
 }
 
-static const struct cpu_dev __cpuinitconst transmeta_cpu_dev = {
+static const struct cpu_dev transmeta_cpu_dev = {
        .c_vendor       = "Transmeta",
        .c_ident        = { "GenuineTMx86", "TransmetaCPU" },
        .c_early_init   = early_init_transmeta,
index fd2c37bf7acb6c6cc9a322600dc2c9dade028dbb..202759a141212241f7e8e607476796edaaddbdd4 100644 (file)
@@ -8,7 +8,7 @@
  * so no special init takes place.
  */
 
-static const struct cpu_dev __cpuinitconst umc_cpu_dev = {
+static const struct cpu_dev umc_cpu_dev = {
        .c_vendor       = "UMC",
        .c_ident        = { "UMC UMC UMC" },
        .c_models = {
index 03a36321ec54428b098a3a874f7db83e4daafcfd..7076878404ec0c450daa78a743eef9190db3d592 100644 (file)
@@ -122,7 +122,7 @@ static bool __init vmware_platform(void)
  * so that the kernel could just trust the hypervisor with providing a
  * reliable virtual TSC that is suitable for timekeeping.
  */
-static void __cpuinit vmware_set_cpu_features(struct cpuinfo_x86 *c)
+static void vmware_set_cpu_features(struct cpuinfo_x86 *c)
 {
        set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
        set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
index 1e4dbcfe6d3160fa7da9482f5b661c4eac853988..7d9481c743f8439ae3a36256f008c45380ee49e8 100644 (file)
@@ -137,7 +137,7 @@ static const struct file_operations cpuid_fops = {
        .open = cpuid_open,
 };
 
-static __cpuinit int cpuid_device_create(int cpu)
+static int cpuid_device_create(int cpu)
 {
        struct device *dev;
 
@@ -151,9 +151,8 @@ static void cpuid_device_destroy(int cpu)
        device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
 }
 
-static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
-                                             unsigned long action,
-                                             void *hcpu)
+static int cpuid_class_cpu_callback(struct notifier_block *nfb,
+                                   unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
        int err = 0;
index 4934890e4db2647496ac0f3c7a903e7862995d1a..69eb2fa254942e23537266c4e8a4d0a77c7ee04f 100644 (file)
@@ -133,7 +133,7 @@ static void x86_of_pci_irq_disable(struct pci_dev *dev)
 {
 }
 
-void __cpuinit x86_of_pci_init(void)
+void x86_of_pci_init(void)
 {
        pcibios_enable_irq = x86_of_pci_irq_enable;
        pcibios_disable_irq = x86_of_pci_irq_disable;
index 94ab6b90dd3fabdaf2856a5d7fc2abfd4ed2af88..63bdb29b25497edfb0a97ec7cfb9aa5b746d200a 100644 (file)
@@ -196,15 +196,23 @@ static void __init ati_bugs_contd(int num, int slot, int func)
 static void __init intel_remapping_check(int num, int slot, int func)
 {
        u8 revision;
+       u16 device;
 
+       device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID);
        revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID);
 
        /*
-        * Revision 0x13 of this chipset supports irq remapping
-        * but has an erratum that breaks its behavior, flag it as such
+        * Revision 13 of all triggering devices id in this quirk have
+        * a problem draining interrupts when irq remapping is enabled,
+        * and should be flagged as broken.  Additionally revisions 0x12
+        * and 0x22 of device id 0x3405 has this problem.
         */
        if (revision == 0x13)
                set_irq_remapping_broken();
+       else if ((device == 0x3405) &&
+           ((revision == 0x12) ||
+            (revision == 0x22)))
+               set_irq_remapping_broken();
 
 }
 
@@ -239,6 +247,8 @@ static struct chipset early_qrk[] __initdata = {
          PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
        { PCI_VENDOR_ID_INTEL, 0x3403, PCI_CLASS_BRIDGE_HOST,
          PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
+       { PCI_VENDOR_ID_INTEL, 0x3405, PCI_CLASS_BRIDGE_HOST,
+         PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
        { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST,
          PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
        {}
index e65ddc62e1137a8a6f6f4cab04bfe28b9482e905..5dd87a89f011d89d5098fc582e794c5250fce3dd 100644 (file)
@@ -292,7 +292,6 @@ ENDPROC(start_cpu0)
  * If cpu hotplug is not supported then this code can go in init section
  * which will be freed later
  */
-__CPUINIT
 ENTRY(startup_32_smp)
        cld
        movl $(__BOOT_DS),%eax
index 5e4d8a8a5c407b7cae67f3d7f86392962c506d0d..e1aabdb314c83740dd686eb4c70a6f40c312e258 100644 (file)
@@ -512,21 +512,6 @@ ENTRY(phys_base)
 
 #include "../../x86/xen/xen-head.S"
        
-       .section .bss, "aw", @nobits
-       .align L1_CACHE_BYTES
-ENTRY(idt_table)
-       .skip IDT_ENTRIES * 16
-
-       .align L1_CACHE_BYTES
-ENTRY(debug_idt_table)
-       .skip IDT_ENTRIES * 16
-
-#ifdef CONFIG_TRACING
-       .align L1_CACHE_BYTES
-ENTRY(trace_idt_table)
-       .skip IDT_ENTRIES * 16
-#endif
-
        __PAGE_ALIGNED_BSS
 NEXT_PAGE(empty_zero_page)
        .skip PAGE_SIZE
index b627746f6b1a81a5fc0c6e9e30adb1bb502f0b87..5d576ab344030832617450ac2330d63f135596a4 100644 (file)
@@ -108,15 +108,15 @@ EXPORT_SYMBOL(unlazy_fpu);
 unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu;
 unsigned int xstate_size;
 EXPORT_SYMBOL_GPL(xstate_size);
-static struct i387_fxsave_struct fx_scratch __cpuinitdata;
+static struct i387_fxsave_struct fx_scratch;
 
-static void __cpuinit mxcsr_feature_mask_init(void)
+static void mxcsr_feature_mask_init(void)
 {
        unsigned long mask = 0;
 
        if (cpu_has_fxsr) {
                memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
-               asm volatile("fxsave %0" : : "m" (fx_scratch));
+               asm volatile("fxsave %0" : "+m" (fx_scratch));
                mask = fx_scratch.mxcsr_mask;
                if (mask == 0)
                        mask = 0x0000ffbf;
@@ -124,7 +124,7 @@ static void __cpuinit mxcsr_feature_mask_init(void)
        mxcsr_feature_mask &= mask;
 }
 
-static void __cpuinit init_thread_xstate(void)
+static void init_thread_xstate(void)
 {
        /*
         * Note that xstate_size might be overwriten later during
@@ -153,7 +153,7 @@ static void __cpuinit init_thread_xstate(void)
  * into all processes.
  */
 
-void __cpuinit fpu_init(void)
+void fpu_init(void)
 {
        unsigned long cr0;
        unsigned long cr4_mask = 0;
@@ -608,7 +608,7 @@ static int __init no_387(char *s)
 
 __setup("no387", no_387);
 
-void __cpuinit fpu_detect(struct cpuinfo_x86 *c)
+void fpu_detect(struct cpuinfo_x86 *c)
 {
        unsigned long cr0;
        u16 fsw, fcw;
index 344faf8d0d62188b64d7b9dac28ab8982e9848f5..4186755f1d7cf350f82540fdb76f731f58b455c3 100644 (file)
@@ -119,7 +119,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
 /*
  * allocate per-cpu stacks for hardirq and for softirq processing
  */
-void __cpuinit irq_ctx_init(int cpu)
+void irq_ctx_init(int cpu)
 {
        union irq_ctx *irqctx;
 
index cd6d9a5a42f60dcb93a528853fe65b8773b0832e..a96d32cc55b8456e8567cd66f8848b62a449150b 100644 (file)
@@ -320,7 +320,7 @@ static void kvm_guest_apic_eoi_write(u32 reg, u32 val)
        apic_write(APIC_EOI, APIC_EOI_ACK);
 }
 
-void __cpuinit kvm_guest_cpu_init(void)
+void kvm_guest_cpu_init(void)
 {
        if (!kvm_para_available())
                return;
@@ -421,7 +421,7 @@ static void __init kvm_smp_prepare_boot_cpu(void)
        native_smp_prepare_boot_cpu();
 }
 
-static void __cpuinit kvm_guest_cpu_online(void *dummy)
+static void kvm_guest_cpu_online(void *dummy)
 {
        kvm_guest_cpu_init();
 }
@@ -435,8 +435,8 @@ static void kvm_guest_cpu_offline(void *dummy)
        apf_task_wake_all();
 }
 
-static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
-                                   unsigned long action, void *hcpu)
+static int kvm_cpu_notify(struct notifier_block *self, unsigned long action,
+                         void *hcpu)
 {
        int cpu = (unsigned long)hcpu;
        switch (action) {
@@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
+static struct notifier_block kvm_cpu_notifier = {
         .notifier_call  = kvm_cpu_notify,
 };
 #endif
index 1f354f4b602be9e251dbdc02dcf607c1c4463f89..1570e07413445845691c4850c7aa6348a4f371af 100644 (file)
@@ -182,7 +182,7 @@ static void kvm_restore_sched_clock_state(void)
 }
 
 #ifdef CONFIG_X86_LOCAL_APIC
-static void __cpuinit kvm_setup_secondary_clock(void)
+static void kvm_setup_secondary_clock(void)
 {
        /*
         * Now that the first cpu already had this clocksource initialized,
index 47ebb1dbfbcb2413ddaf9d4cc86b7d8558eb3c72..7123b5df479d872def8ff437fcd407c5c4d5ca50 100644 (file)
@@ -145,10 +145,9 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
        return 0;
 }
 
-static unsigned int verify_patch_size(int cpu, u32 patch_size,
+static unsigned int verify_patch_size(u8 family, u32 patch_size,
                                      unsigned int size)
 {
-       struct cpuinfo_x86 *c = &cpu_data(cpu);
        u32 max_size;
 
 #define F1XH_MPB_MAX_SIZE 2048
@@ -156,7 +155,7 @@ static unsigned int verify_patch_size(int cpu, u32 patch_size,
 #define F15H_MPB_MAX_SIZE 4096
 #define F16H_MPB_MAX_SIZE 3458
 
-       switch (c->x86) {
+       switch (family) {
        case 0x14:
                max_size = F14H_MPB_MAX_SIZE;
                break;
@@ -220,12 +219,13 @@ int apply_microcode_amd(int cpu)
                return 0;
        }
 
-       if (__apply_microcode_amd(mc_amd))
+       if (__apply_microcode_amd(mc_amd)) {
                pr_err("CPU%d: update failed for patch_level=0x%08x\n",
                        cpu, mc_amd->hdr.patch_id);
-       else
-               pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
-                       mc_amd->hdr.patch_id);
+               return -1;
+       }
+       pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
+               mc_amd->hdr.patch_id);
 
        uci->cpu_sig.rev = mc_amd->hdr.patch_id;
        c->microcode = mc_amd->hdr.patch_id;
@@ -276,9 +276,8 @@ static void cleanup(void)
  * driver cannot continue functioning normally. In such cases, we tear
  * down everything we've used up so far and exit.
  */
-static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
+static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)
 {
-       struct cpuinfo_x86 *c = &cpu_data(cpu);
        struct microcode_header_amd *mc_hdr;
        struct ucode_patch *patch;
        unsigned int patch_size, crnt_size, ret;
@@ -298,7 +297,7 @@ static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
 
        /* check if patch is for the current family */
        proc_fam = ((proc_fam >> 8) & 0xf) + ((proc_fam >> 20) & 0xff);
-       if (proc_fam != c->x86)
+       if (proc_fam != family)
                return crnt_size;
 
        if (mc_hdr->nb_dev_id || mc_hdr->sb_dev_id) {
@@ -307,7 +306,7 @@ static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
                return crnt_size;
        }
 
-       ret = verify_patch_size(cpu, patch_size, leftover);
+       ret = verify_patch_size(family, patch_size, leftover);
        if (!ret) {
                pr_err("Patch-ID 0x%08x: size mismatch.\n", mc_hdr->patch_id);
                return crnt_size;
@@ -338,7 +337,8 @@ static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
        return crnt_size;
 }
 
-static enum ucode_state __load_microcode_amd(int cpu, const u8 *data, size_t size)
+static enum ucode_state __load_microcode_amd(u8 family, const u8 *data,
+                                            size_t size)
 {
        enum ucode_state ret = UCODE_ERROR;
        unsigned int leftover;
@@ -361,7 +361,7 @@ static enum ucode_state __load_microcode_amd(int cpu, const u8 *data, size_t siz
        }
 
        while (leftover) {
-               crnt_size = verify_and_add_patch(cpu, fw, leftover);
+               crnt_size = verify_and_add_patch(family, fw, leftover);
                if (crnt_size < 0)
                        return ret;
 
@@ -372,22 +372,22 @@ static enum ucode_state __load_microcode_amd(int cpu, const u8 *data, size_t siz
        return UCODE_OK;
 }
 
-enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size)
+enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size)
 {
        enum ucode_state ret;
 
        /* free old equiv table */
        free_equiv_cpu_table();
 
-       ret = __load_microcode_amd(cpu, data, size);
+       ret = __load_microcode_amd(family, data, size);
 
        if (ret != UCODE_OK)
                cleanup();
 
 #if defined(CONFIG_MICROCODE_AMD_EARLY) && defined(CONFIG_X86_32)
        /* save BSP's matching patch for early load */
-       if (cpu_data(cpu).cpu_index == boot_cpu_data.cpu_index) {
-               struct ucode_patch *p = find_patch(cpu);
+       if (cpu_data(smp_processor_id()).cpu_index == boot_cpu_data.cpu_index) {
+               struct ucode_patch *p = find_patch(smp_processor_id());
                if (p) {
                        memset(amd_bsp_mpb, 0, MPB_MAX_SIZE);
                        memcpy(amd_bsp_mpb, p->data, min_t(u32, ksize(p->data),
@@ -440,7 +440,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device,
                goto fw_release;
        }
 
-       ret = load_microcode_amd(cpu, fw->data, fw->size);
+       ret = load_microcode_amd(c->x86, fw->data, fw->size);
 
  fw_release:
        release_firmware(fw);
index 1ac6e9aee766d225b36b2230ac93a6c95af1ab9c..6073104ccaa36bca776290155e42a30bdd444a8d 100644 (file)
@@ -82,7 +82,7 @@ static struct cpio_data __init find_ucode_in_initrd(void)
  * load_microcode_amd() to save equivalent cpu table and microcode patches in
  * kernel heap memory.
  */
-static void __cpuinit apply_ucode_in_initrd(void *ucode, size_t size)
+static void apply_ucode_in_initrd(void *ucode, size_t size)
 {
        struct equiv_cpu_entry *eq;
        u32 *header;
@@ -206,7 +206,7 @@ u8 amd_bsp_mpb[MPB_MAX_SIZE];
  * save_microcode_in_initrd_amd() BSP's patch is copied to amd_bsp_mpb, which
  * is used upon resume from suspend.
  */
-void __cpuinit load_ucode_amd_ap(void)
+void load_ucode_amd_ap(void)
 {
        struct microcode_amd *mc;
        unsigned long *initrd;
@@ -238,25 +238,17 @@ static void __init collect_cpu_sig_on_bsp(void *arg)
        uci->cpu_sig.sig = cpuid_eax(0x00000001);
 }
 #else
-static void __cpuinit collect_cpu_info_amd_early(struct cpuinfo_x86 *c,
-                                                struct ucode_cpu_info *uci)
+void load_ucode_amd_ap(void)
 {
+       unsigned int cpu = smp_processor_id();
+       struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
        u32 rev, eax;
 
        rdmsr(MSR_AMD64_PATCH_LEVEL, rev, eax);
        eax = cpuid_eax(0x00000001);
 
-       uci->cpu_sig.sig = eax;
        uci->cpu_sig.rev = rev;
-       c->microcode = rev;
-       c->x86 = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
-}
-
-void __cpuinit load_ucode_amd_ap(void)
-{
-       unsigned int cpu = smp_processor_id();
-
-       collect_cpu_info_amd_early(&cpu_data(cpu), ucode_cpu_info + cpu);
+       uci->cpu_sig.sig = eax;
 
        if (cpu && !ucode_loaded) {
                void *ucode;
@@ -265,8 +257,10 @@ void __cpuinit load_ucode_amd_ap(void)
                        return;
 
                ucode = (void *)(initrd_start + ucode_offset);
-               if (load_microcode_amd(0, ucode, ucode_size) != UCODE_OK)
+               eax   = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+               if (load_microcode_amd(eax, ucode, ucode_size) != UCODE_OK)
                        return;
+
                ucode_loaded = true;
        }
 
@@ -278,6 +272,8 @@ int __init save_microcode_in_initrd_amd(void)
 {
        enum ucode_state ret;
        void *ucode;
+       u32 eax;
+
 #ifdef CONFIG_X86_32
        unsigned int bsp = boot_cpu_data.cpu_index;
        struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
@@ -293,7 +289,10 @@ int __init save_microcode_in_initrd_amd(void)
                return 0;
 
        ucode = (void *)(initrd_start + ucode_offset);
-       ret = load_microcode_amd(0, ucode, ucode_size);
+       eax   = cpuid_eax(0x00000001);
+       eax   = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+
+       ret = load_microcode_amd(eax, ucode, ucode_size);
        if (ret != UCODE_OK)
                return -EINVAL;
 
index 22db92bbdf1a41f24185368fe0fe634749e3c8de..15c987698b0f730ed47b3f0daaf1021e6b1abdff 100644 (file)
@@ -468,7 +468,7 @@ static struct syscore_ops mc_syscore_ops = {
        .resume                 = mc_bp_resume,
 };
 
-static __cpuinit int
+static int
 mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
index 86119f63db0ce0fbecc41b7357fa108f37860416..be7f8514f57752f0414094e6649f258ffbbc063c 100644 (file)
@@ -41,7 +41,7 @@
  *
  * x86_vendor() gets vendor information directly through cpuid.
  */
-static int __cpuinit x86_vendor(void)
+static int x86_vendor(void)
 {
        u32 eax = 0x00000000;
        u32 ebx, ecx = 0, edx;
@@ -57,7 +57,7 @@ static int __cpuinit x86_vendor(void)
        return X86_VENDOR_UNKNOWN;
 }
 
-static int __cpuinit x86_family(void)
+static int x86_family(void)
 {
        u32 eax = 0x00000001;
        u32 ebx, ecx = 0, edx;
@@ -96,7 +96,7 @@ void __init load_ucode_bsp(void)
        }
 }
 
-void __cpuinit load_ucode_ap(void)
+void load_ucode_ap(void)
 {
        int vendor, x86;
 
index dabef95506f39e23c58fa74a177736eccd62ccb6..1575deb2e636af5699e20af86a0ba63818c9ae5c 100644 (file)
@@ -34,7 +34,7 @@ struct mc_saved_data {
        struct microcode_intel **mc_saved;
 } mc_saved_data;
 
-static enum ucode_state __cpuinit
+static enum ucode_state
 generic_load_microcode_early(struct microcode_intel **mc_saved_p,
                             unsigned int mc_saved_count,
                             struct ucode_cpu_info *uci)
@@ -69,7 +69,7 @@ out:
        return state;
 }
 
-static void __cpuinit
+static void
 microcode_pointer(struct microcode_intel **mc_saved,
                  unsigned long *mc_saved_in_initrd,
                  unsigned long initrd_start, int mc_saved_count)
@@ -82,7 +82,7 @@ microcode_pointer(struct microcode_intel **mc_saved,
 }
 
 #ifdef CONFIG_X86_32
-static void __cpuinit
+static void
 microcode_phys(struct microcode_intel **mc_saved_tmp,
               struct mc_saved_data *mc_saved_data)
 {
@@ -101,7 +101,7 @@ microcode_phys(struct microcode_intel **mc_saved_tmp,
 }
 #endif
 
-static enum ucode_state __cpuinit
+static enum ucode_state
 load_microcode(struct mc_saved_data *mc_saved_data,
               unsigned long *mc_saved_in_initrd,
               unsigned long initrd_start,
@@ -375,7 +375,7 @@ do {                                                \
 #define native_wrmsr(msr, low, high)           \
        native_write_msr(msr, low, high);
 
-static int __cpuinit collect_cpu_info_early(struct ucode_cpu_info *uci)
+static int collect_cpu_info_early(struct ucode_cpu_info *uci)
 {
        unsigned int val[2];
        u8 x86, x86_model;
@@ -584,7 +584,7 @@ scan_microcode(unsigned long start, unsigned long end,
 /*
  * Print ucode update info.
  */
-static void __cpuinit
+static void
 print_ucode_info(struct ucode_cpu_info *uci, unsigned int date)
 {
        int cpu = smp_processor_id();
@@ -605,7 +605,7 @@ static int current_mc_date;
 /*
  * Print early updated ucode info after printk works. This is delayed info dump.
  */
-void __cpuinit show_ucode_info_early(void)
+void show_ucode_info_early(void)
 {
        struct ucode_cpu_info uci;
 
@@ -621,7 +621,7 @@ void __cpuinit show_ucode_info_early(void)
  * mc_saved_data.mc_saved and delay printing microcode info in
  * show_ucode_info_early() until printk() works.
  */
-static void __cpuinit print_ucode(struct ucode_cpu_info *uci)
+static void print_ucode(struct ucode_cpu_info *uci)
 {
        struct microcode_intel *mc_intel;
        int *delay_ucode_info_p;
@@ -643,12 +643,12 @@ static void __cpuinit print_ucode(struct ucode_cpu_info *uci)
  * Flush global tlb. We only do this in x86_64 where paging has been enabled
  * already and PGE should be enabled as well.
  */
-static inline void __cpuinit flush_tlb_early(void)
+static inline void flush_tlb_early(void)
 {
        __native_flush_tlb_global_irq_disabled();
 }
 
-static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci)
+static inline void print_ucode(struct ucode_cpu_info *uci)
 {
        struct microcode_intel *mc_intel;
 
@@ -660,8 +660,8 @@ static inline void __cpuinit print_ucode(struct ucode_cpu_info *uci)
 }
 #endif
 
-static int __cpuinit apply_microcode_early(struct mc_saved_data *mc_saved_data,
-                                          struct ucode_cpu_info *uci)
+static int apply_microcode_early(struct mc_saved_data *mc_saved_data,
+                                struct ucode_cpu_info *uci)
 {
        struct microcode_intel *mc_intel;
        unsigned int val[2];
@@ -763,7 +763,7 @@ load_ucode_intel_bsp(void)
 #endif
 }
 
-void __cpuinit load_ucode_intel_ap(void)
+void load_ucode_intel_ap(void)
 {
        struct mc_saved_data *mc_saved_data_p;
        struct ucode_cpu_info uci;
index ac861b8348e2d9dd3f863dece898a2974d7bff51..f4c886d9165c5915968d7bf10c7c3fc961280d54 100644 (file)
@@ -24,14 +24,14 @@ struct pci_hostbridge_probe {
        u32 device;
 };
 
-static u64 __cpuinitdata fam10h_pci_mmconf_base;
+static u64 fam10h_pci_mmconf_base;
 
-static struct pci_hostbridge_probe pci_probes[] __cpuinitdata = {
+static struct pci_hostbridge_probe pci_probes[] = {
        { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 },
        { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 },
 };
 
-static int __cpuinit cmp_range(const void *x1, const void *x2)
+static int cmp_range(const void *x1, const void *x2)
 {
        const struct range *r1 = x1;
        const struct range *r2 = x2;
@@ -49,7 +49,7 @@ static int __cpuinit cmp_range(const void *x1, const void *x2)
 /* need to avoid (0xfd<<32), (0xfe<<32), and (0xff<<32), ht used space */
 #define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32)
 #define BASE_VALID(b) ((b) + MMCONF_SIZE <= (0xfdULL<<32) || (b) >= (1ULL<<40))
-static void __cpuinit get_fam10h_pci_mmconf_base(void)
+static void get_fam10h_pci_mmconf_base(void)
 {
        int i;
        unsigned bus;
@@ -166,7 +166,7 @@ out:
        fam10h_pci_mmconf_base = base;
 }
 
-void __cpuinit fam10h_check_enable_mmcfg(void)
+void fam10h_check_enable_mmcfg(void)
 {
        u64 val;
        u32 address;
@@ -230,7 +230,7 @@ static const struct dmi_system_id __initconst mmconf_dmi_table[] = {
        {}
 };
 
-/* Called from a __cpuinit function, but only on the BSP. */
+/* Called from a non __init function, but only on the BSP. */
 void __ref check_enable_amd_mmconf_dmi(void)
 {
        dmi_check_system(mmconf_dmi_table);
index ce130493b8020aa05edf555234ebfd8cac9e9f9a..88458faea2f8f0ace5ae6d2b02a451bf43a2d9af 100644 (file)
@@ -200,7 +200,7 @@ static const struct file_operations msr_fops = {
        .compat_ioctl = msr_ioctl,
 };
 
-static int __cpuinit msr_device_create(int cpu)
+static int msr_device_create(int cpu)
 {
        struct device *dev;
 
@@ -214,8 +214,8 @@ static void msr_device_destroy(int cpu)
        device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
 }
 
-static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
-                               unsigned long action, void *hcpu)
+static int msr_class_cpu_callback(struct notifier_block *nfb,
+                                 unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
        int err = 0;
index 81a5f5e8f142a867b56a5e335d1b2a6598a8fbbe..83369e5a1d277b5a3150799bc3f762abef8e58fc 100644 (file)
@@ -398,7 +398,7 @@ static void amd_e400_idle(void)
                default_idle();
 }
 
-void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
+void select_idle_routine(const struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_SMP
        if (boot_option_idle_override == IDLE_POLL && smp_num_siblings > 1)
index e68709da8251b4b7b559e4d73b8db05cdff0d47d..f8ec57815c05729baa90ac4df52b990975796e2e 100644 (file)
@@ -170,7 +170,7 @@ static struct resource bss_resource = {
 
 #ifdef CONFIG_X86_32
 /* cpu data as detected by the assembly code in head.S */
-struct cpuinfo_x86 new_cpu_data __cpuinitdata = {
+struct cpuinfo_x86 new_cpu_data = {
        .wp_works_ok = -1,
 };
 /* common cpu data for all cpus */
index bfd348e9936926f56e13ffee8b67cc77ec4a4338..aecc98a93d1b42f39261fcc9102be5515185d78a 100644 (file)
@@ -130,7 +130,7 @@ atomic_t init_deasserted;
  * Report back to the Boot Processor during boot time or to the caller processor
  * during CPU online.
  */
-static void __cpuinit smp_callin(void)
+static void smp_callin(void)
 {
        int cpuid, phys_id;
        unsigned long timeout;
@@ -237,7 +237,7 @@ static int enable_start_cpu0;
 /*
  * Activate a secondary processor.
  */
-notrace static void __cpuinit start_secondary(void *unused)
+static void notrace start_secondary(void *unused)
 {
        /*
         * Don't put *anything* before cpu_init(), SMP booting is too
@@ -300,7 +300,7 @@ void __init smp_store_boot_cpu_info(void)
  * The bootstrap kernel entry code has set these up. Save them for
  * a given CPU
  */
-void __cpuinit smp_store_cpu_info(int id)
+void smp_store_cpu_info(int id)
 {
        struct cpuinfo_x86 *c = &cpu_data(id);
 
@@ -313,7 +313,7 @@ void __cpuinit smp_store_cpu_info(int id)
        identify_secondary_cpu(c);
 }
 
-static bool __cpuinit
+static bool
 topology_sane(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o, const char *name)
 {
        int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
@@ -330,7 +330,7 @@ do {                                                                        \
        cpumask_set_cpu((c2), cpu_##_m##_mask(c1));                     \
 } while (0)
 
-static bool __cpuinit match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
+static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
 {
        if (cpu_has_topoext) {
                int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
@@ -348,7 +348,7 @@ static bool __cpuinit match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
        return false;
 }
 
-static bool __cpuinit match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
+static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
 {
        int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
 
@@ -359,7 +359,7 @@ static bool __cpuinit match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
        return false;
 }
 
-static bool __cpuinit match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
+static bool match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
 {
        if (c->phys_proc_id == o->phys_proc_id) {
                if (cpu_has(c, X86_FEATURE_AMD_DCM))
@@ -370,7 +370,7 @@ static bool __cpuinit match_mc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
        return false;
 }
 
-void __cpuinit set_cpu_sibling_map(int cpu)
+void set_cpu_sibling_map(int cpu)
 {
        bool has_smt = smp_num_siblings > 1;
        bool has_mp = has_smt || boot_cpu_data.x86_max_cores > 1;
@@ -499,7 +499,7 @@ void __inquire_remote_apic(int apicid)
  * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this
  * won't ... remember to clear down the APIC, etc later.
  */
-int __cpuinit
+int
 wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
 {
        unsigned long send_status, accept_status = 0;
@@ -533,7 +533,7 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
        return (send_status | accept_status);
 }
 
-static int __cpuinit
+static int
 wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
 {
        unsigned long send_status, accept_status = 0;
@@ -649,7 +649,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
 }
 
 /* reduce the number of lines printed when booting a large cpu count system */
-static void __cpuinit announce_cpu(int cpu, int apicid)
+static void announce_cpu(int cpu, int apicid)
 {
        static int current_node = -1;
        int node = early_cpu_to_node(cpu);
@@ -691,7 +691,7 @@ static int wakeup_cpu0_nmi(unsigned int cmd, struct pt_regs *regs)
  * We'll change this code in the future to wake up hard offlined CPU0 if
  * real platform and request are available.
  */
-static int __cpuinit
+static int
 wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid,
               int *cpu0_nmi_registered)
 {
@@ -731,7 +731,7 @@ wakeup_cpu_via_init_nmi(int cpu, unsigned long start_ip, int apicid,
  * Returns zero if CPU booted OK, else error code from
  * ->wakeup_secondary_cpu.
  */
-static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
+static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
 {
        volatile u32 *trampoline_status =
                (volatile u32 *) __va(real_mode_header->trampoline_status);
@@ -872,7 +872,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
        return boot_error;
 }
 
-int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
+int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        int apicid = apic->cpu_present_to_apicid(cpu);
        unsigned long flags;
index dbded5aedb818d511a46967ccb1d26d77233110f..30277e27431acde9a9320e0b1be4470bddb40e3a 100644 (file)
@@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
                                *begin = new_begin;
                }
        } else {
-               *begin = TASK_UNMAPPED_BASE;
+               *begin = current->mm->mmap_legacy_base;
                *end = TASK_SIZE;
        }
 }
index 3ff42d2f046d0dd0b73475fabcc3b82979675254..addf7b58f4e839f171cb8d3b68594e6a36e77344 100644 (file)
@@ -320,8 +320,8 @@ static int tboot_wait_for_aps(int num_aps)
        return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
 }
 
-static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
-                       unsigned long action, void *hcpu)
+static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
+                             void *hcpu)
 {
        switch (action) {
        case CPU_DYING:
@@ -334,7 +334,7 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
        return NOTIFY_OK;
 }
 
-static struct notifier_block tboot_cpu_notifier __cpuinitdata =
+static struct notifier_block tboot_cpu_notifier =
 {
        .notifier_call = tboot_cpu_callback,
 };
index 4e584a8d6eddf1fa2dbd8c540ce0f6542850bb79..1c113db9ed573c3d8723fccc177431861df2bd19 100644 (file)
@@ -12,10 +12,8 @@ atomic_t trace_idt_ctr = ATOMIC_INIT(0);
 struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
                                (unsigned long) trace_idt_table };
 
-#ifndef CONFIG_X86_64
-gate_desc trace_idt_table[NR_VECTORS] __page_aligned_data
-                                       = { { { { 0, 0 } } }, };
-#endif
+/* No need to be aligned, but done to keep all IDTs defined the same way. */
+gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
 
 static int trace_irq_vector_refcount;
 static DEFINE_MUTEX(irq_vector_mutex);
index b0865e88d3ccf4e272e5dbf654ff5de25492e672..1b23a1c9274696f108dcf2ad2482445523930de0 100644 (file)
 #include <asm/x86_init.h>
 #include <asm/pgalloc.h>
 #include <asm/proto.h>
+
+/* No need to be aligned, but done to keep all IDTs defined the same way. */
+gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
 #else
 #include <asm/processor-flags.h>
 #include <asm/setup.h>
 
 asmlinkage int system_call(void);
-
-/*
- * The IDT has to be page-aligned to simplify the Pentium
- * F0 0F bug workaround.
- */
-gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
 #endif
 
+/* Must be page-aligned because the real IDT is used in a fixmap. */
+gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
+
 DECLARE_BITMAP(used_vectors, NR_VECTORS);
 EXPORT_SYMBOL_GPL(used_vectors);
 
index 098b3cfda72ee152ab3ce5505ad5843b3778b699..6ff49247edf8f1e67bbd24dd15e34685bcafb010 100644 (file)
@@ -824,7 +824,7 @@ static void __init check_system_tsc_reliable(void)
  * Make an educated guess if the TSC is trustworthy and synchronized
  * over all CPUs.
  */
-__cpuinit int unsynchronized_tsc(void)
+int unsynchronized_tsc(void)
 {
        if (!cpu_has_tsc || tsc_unstable)
                return 1;
@@ -1020,7 +1020,7 @@ void __init tsc_init(void)
  * been calibrated. This assumes that CONSTANT_TSC applies to all
  * cpus in the socket - this should be a safe assumption.
  */
-unsigned long __cpuinit calibrate_delay_is_known(void)
+unsigned long calibrate_delay_is_known(void)
 {
        int i, cpu = smp_processor_id();
 
index fc25e60a588458078e7d66a4ba8a7e995624b585..adfdf56a3714ec3386dc61812cd5af56a88e8d40 100644 (file)
  * Entry/exit counters that make sure that both CPUs
  * run the measurement code at once:
  */
-static __cpuinitdata atomic_t start_count;
-static __cpuinitdata atomic_t stop_count;
+static atomic_t start_count;
+static atomic_t stop_count;
 
 /*
  * We use a raw spinlock in this exceptional case, because
  * we want to have the fastest, inlined, non-debug version
  * of a critical section, to be able to prove TSC time-warps:
  */
-static __cpuinitdata arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 
-static __cpuinitdata cycles_t last_tsc;
-static __cpuinitdata cycles_t max_warp;
-static __cpuinitdata int nr_warps;
+static cycles_t last_tsc;
+static cycles_t max_warp;
+static int nr_warps;
 
 /*
  * TSC-warp measurement loop running on both CPUs:
  */
-static __cpuinit void check_tsc_warp(unsigned int timeout)
+static void check_tsc_warp(unsigned int timeout)
 {
        cycles_t start, now, prev, end;
        int i;
@@ -121,7 +121,7 @@ static inline unsigned int loop_timeout(int cpu)
  * Source CPU calls into this - it waits for the freshly booted
  * target CPU to arrive and then starts the measurement:
  */
-void __cpuinit check_tsc_sync_source(int cpu)
+void check_tsc_sync_source(int cpu)
 {
        int cpus = 2;
 
@@ -187,7 +187,7 @@ void __cpuinit check_tsc_sync_source(int cpu)
 /*
  * Freshly booted CPUs call into this:
  */
-void __cpuinit check_tsc_sync_target(void)
+void check_tsc_sync_target(void)
 {
        int cpus = 2;
 
index 9a907a67be8f48abc0399017865a4697968ae2c3..1f96f9347ed972d6df62cad2f0edee13927fdf4a 100644 (file)
@@ -331,7 +331,7 @@ sigsegv:
  * Assume __initcall executes before all user space. Hopefully kmod
  * doesn't violate that. We'll find out if it does.
  */
-static void __cpuinit vsyscall_set_cpu(int cpu)
+static void vsyscall_set_cpu(int cpu)
 {
        unsigned long d;
        unsigned long node = 0;
@@ -353,13 +353,13 @@ static void __cpuinit vsyscall_set_cpu(int cpu)
        write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_PER_CPU, &d, DESCTYPE_S);
 }
 
-static void __cpuinit cpu_vsyscall_init(void *arg)
+static void cpu_vsyscall_init(void *arg)
 {
        /* preemption should be already off */
        vsyscall_set_cpu(raw_smp_processor_id());
 }
 
-static int __cpuinit
+static int
 cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
 {
        long cpu = (long)arg;
index 45a14dbbddafe602a4910ce90fc59b5b7ac08ee2..5f24c71accaaf2f9c6f1b17566fc142f9c157535 100644 (file)
@@ -25,7 +25,7 @@
 #include <asm/iommu.h>
 #include <asm/mach_traps.h>
 
-void __cpuinit x86_init_noop(void) { }
+void x86_init_noop(void) { }
 void __init x86_init_uint_noop(unsigned int unused) { }
 int __init iommu_init_noop(void) { return 0; }
 void iommu_shutdown_noop(void) { }
@@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
        },
 };
 
-struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
+struct x86_cpuinit_ops x86_cpuinit = {
        .early_percpu_clock_init        = x86_init_noop,
        .setup_percpu_clockev           = setup_secondary_APIC_clock,
 };
index d6c28acdf99c19abd1f5554561b1b3030c057b3b..422fd82234700fe46f7ac12fe150665d0977e3b9 100644 (file)
@@ -573,7 +573,7 @@ static void __init xstate_enable_boot_cpu(void)
  * This is somewhat obfuscated due to the lack of powerful enough
  * overrides for the section checks.
  */
-void __cpuinit xsave_init(void)
+void xsave_init(void)
 {
        static __refdata void (*next_func)(void) = xstate_enable_boot_cpu;
        void (*this_func)(void);
@@ -594,7 +594,7 @@ static inline void __init eager_fpu_init_bp(void)
                setup_init_fpu_buf();
 }
 
-void __cpuinit eager_fpu_init(void)
+void eager_fpu_init(void)
 {
        static __refdata void (*boot_func)(void) = eager_fpu_init_bp;
 
index 0d094da49541d171e7218c7340e63dce6d35674c..9e9285ae9b946ac1fbcb3b1dfd02159107c0f221 100644 (file)
@@ -2810,6 +2810,13 @@ exit:
 
 static bool page_fault_can_be_fast(struct kvm_vcpu *vcpu, u32 error_code)
 {
+       /*
+        * Do not fix the mmio spte with invalid generation number which
+        * need to be updated by slow page fault path.
+        */
+       if (unlikely(error_code & PFERR_RSVD_MASK))
+               return false;
+
        /*
         * #PF can be fast only if the shadow page table is present and it
         * is caused by write-protect, that means we just need change the
index 62c29a5bfe26aeb67bf63fb545294b79765e445f..25e7e1372bb26e961b580c753407edf28a320aa3 100644 (file)
@@ -112,11 +112,13 @@ static unsigned long mmap_legacy_base(void)
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
+       mm->mmap_legacy_base = mmap_legacy_base();
+       mm->mmap_base = mmap_base();
+
        if (mmap_is_legacy()) {
-               mm->mmap_base = mmap_legacy_base();
+               mm->mmap_base = mm->mmap_legacy_base;
                mm->get_unmapped_area = arch_get_unmapped_area;
        } else {
-               mm->mmap_base = mmap_base();
                mm->get_unmapped_area = arch_get_unmapped_area_topdown;
        }
 }
index dc0b727742f475514a46348892cc0b2a5e5e4ac1..0057a7accfb17467600eac646a7c489a9deb7be3 100644 (file)
@@ -410,9 +410,7 @@ out:
                pr_warning("multiple CPUs still online, may miss events.\n");
 }
 
-/* __ref because leave_uniprocessor calls cpu_up which is __cpuinit,
-   but this whole function is ifdefed CONFIG_HOTPLUG_CPU */
-static void __ref leave_uniprocessor(void)
+static void leave_uniprocessor(void)
 {
        int cpu;
        int err;
index a71c4e207679abf96c7b45747d84e6e7bac19bb0..8bf93bae1f13f939e2ca88faccd244c2b39df780 100644 (file)
@@ -60,7 +60,7 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] = {
        [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
 };
 
-int __cpuinit numa_cpu_node(int cpu)
+int numa_cpu_node(int cpu)
 {
        int apicid = early_per_cpu(x86_cpu_to_apicid, cpu);
 
@@ -691,12 +691,12 @@ void __init init_cpu_to_node(void)
 #ifndef CONFIG_DEBUG_PER_CPU_MAPS
 
 # ifndef CONFIG_NUMA_EMU
-void __cpuinit numa_add_cpu(int cpu)
+void numa_add_cpu(int cpu)
 {
        cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);
 }
 
-void __cpuinit numa_remove_cpu(int cpu)
+void numa_remove_cpu(int cpu)
 {
        cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);
 }
@@ -763,17 +763,17 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)
 }
 
 # ifndef CONFIG_NUMA_EMU
-static void __cpuinit numa_set_cpumask(int cpu, bool enable)
+static void numa_set_cpumask(int cpu, bool enable)
 {
        debug_cpumask_set_cpu(cpu, early_cpu_to_node(cpu), enable);
 }
 
-void __cpuinit numa_add_cpu(int cpu)
+void numa_add_cpu(int cpu)
 {
        numa_set_cpumask(cpu, true);
 }
 
-void __cpuinit numa_remove_cpu(int cpu)
+void numa_remove_cpu(int cpu)
 {
        numa_set_cpumask(cpu, false);
 }
index dbbbb47260ccc28b8dad5bb14f82420187a83ff3..a8f90ce3dedff5e0ddae9f618893da8afcf2e07d 100644 (file)
@@ -10,7 +10,7 @@
 
 #include "numa_internal.h"
 
-static int emu_nid_to_phys[MAX_NUMNODES] __cpuinitdata;
+static int emu_nid_to_phys[MAX_NUMNODES];
 static char *emu_cmdline __initdata;
 
 void __init numa_emu_cmdline(char *str)
@@ -444,7 +444,7 @@ no_emu:
 }
 
 #ifndef CONFIG_DEBUG_PER_CPU_MAPS
-void __cpuinit numa_add_cpu(int cpu)
+void numa_add_cpu(int cpu)
 {
        int physnid, nid;
 
@@ -462,7 +462,7 @@ void __cpuinit numa_add_cpu(int cpu)
                        cpumask_set_cpu(cpu, node_to_cpumask_map[nid]);
 }
 
-void __cpuinit numa_remove_cpu(int cpu)
+void numa_remove_cpu(int cpu)
 {
        int i;
 
@@ -470,7 +470,7 @@ void __cpuinit numa_remove_cpu(int cpu)
                cpumask_clear_cpu(cpu, node_to_cpumask_map[i]);
 }
 #else  /* !CONFIG_DEBUG_PER_CPU_MAPS */
-static void __cpuinit numa_set_cpumask(int cpu, bool enable)
+static void numa_set_cpumask(int cpu, bool enable)
 {
        int nid, physnid;
 
@@ -490,12 +490,12 @@ static void __cpuinit numa_set_cpumask(int cpu, bool enable)
        }
 }
 
-void __cpuinit numa_add_cpu(int cpu)
+void numa_add_cpu(int cpu)
 {
        numa_set_cpumask(cpu, true);
 }
 
-void __cpuinit numa_remove_cpu(int cpu)
+void numa_remove_cpu(int cpu)
 {
        numa_set_cpumask(cpu, false);
 }
index 410531d3c292d20cde9b40a487711930eab51eb2..90555bf60aa45dce625c0171e4783e6014529490 100644 (file)
@@ -5,7 +5,7 @@
 #include <asm/pgtable.h>
 #include <asm/proto.h>
 
-static int disable_nx __cpuinitdata;
+static int disable_nx;
 
 /*
  * noexec = on|off
@@ -29,7 +29,7 @@ static int __init noexec_setup(char *str)
 }
 early_param("noexec", noexec_setup);
 
-void __cpuinit x86_configure_nx(void)
+void x86_configure_nx(void)
 {
        if (cpu_has_nx && !disable_nx)
                __supported_pte_mask |= _PAGE_NX;
index e9e6ed5cdf9460b080e64b1bf3def3861979fb98..a48be98e9ded5a48be34fd8139d37a97a3748cc4 100644 (file)
@@ -312,7 +312,7 @@ static int __init early_fill_mp_bus_info(void)
 
 #define ENABLE_CF8_EXT_CFG      (1ULL << 46)
 
-static void __cpuinit enable_pci_io_ecs(void *unused)
+static void enable_pci_io_ecs(void *unused)
 {
        u64 reg;
        rdmsrl(MSR_AMD64_NB_CFG, reg);
@@ -322,8 +322,8 @@ static void __cpuinit enable_pci_io_ecs(void *unused)
        }
 }
 
-static int __cpuinit amd_cpu_notify(struct notifier_block *self,
-                                   unsigned long action, void *hcpu)
+static int amd_cpu_notify(struct notifier_block *self, unsigned long action,
+                         void *hcpu)
 {
        int cpu = (long)hcpu;
        switch (action) {
@@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata amd_cpu_notifier = {
+static struct notifier_block amd_cpu_notifier = {
        .notifier_call  = amd_cpu_notify,
 };
 
index f8ab4945892ee8f484006e568c1def8f1beff8bd..8244f5ec2f4c7520284ff2388c328a17c10e3440 100644 (file)
 #include <linux/kernel.h>
 #include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/reboot.h>
 #include <linux/serial_reg.h>
 #include <linux/serial_8250.h>
+#include <linux/reboot.h>
 
 #include <asm/ce4100.h>
 #include <asm/prom.h>
@@ -134,7 +136,7 @@ static void __init sdv_arch_setup(void)
 }
 
 #ifdef CONFIG_X86_IO_APIC
-static void __cpuinit sdv_pci_init(void)
+static void sdv_pci_init(void)
 {
        x86_of_pci_init();
        /* We can't set this earlier, because we need to calibrate the timer */
index c8d5577044bb678412d7c1d528e926a29f29f6c1..90f6ed127096566ab06c0a9e6f25a355ccdfc048 100644 (file)
@@ -931,13 +931,6 @@ void __init efi_enter_virtual_mode(void)
                        va = efi_ioremap(md->phys_addr, size,
                                         md->type, md->attribute);
 
-               if (!(md->attribute & EFI_MEMORY_RUNTIME)) {
-                       if (!va)
-                               pr_err("ioremap of 0x%llX failed!\n",
-                                      (unsigned long long)md->phys_addr);
-                       continue;
-               }
-
                md->virt_addr = (u64) (unsigned long) va;
 
                if (!va) {
index a0a0a4389bbd9d5c15ed4ca988259d4ff8c6e117..47fe66fe61f120dcc1142629708064774728ae2c 100644 (file)
@@ -65,7 +65,7 @@
  * lapic (always-on,ARAT) ------ 150
  */
 
-__cpuinitdata enum mrst_timer_options mrst_timer_options;
+enum mrst_timer_options mrst_timer_options;
 
 static u32 sfi_mtimer_usage[SFI_MTMR_MAX_NUM];
 static struct sfi_timer_table_entry sfi_mtimer_array[SFI_MTMR_MAX_NUM];
@@ -248,7 +248,7 @@ static void __init mrst_time_init(void)
        apbt_time_init();
 }
 
-static void __cpuinit mrst_arch_setup(void)
+static void mrst_arch_setup(void)
 {
        if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27)
                __mrst_cpu_chip = MRST_CPU_CHIP_PENWELL;
index ae7319db18ee36d1e8aec541e30bbbb99cc77d08..5e04a1c899fa6563cd8809c84dd41cf02b1a950e 100644 (file)
@@ -508,7 +508,6 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
 {
        struct rt_sigframe __user *frame;
        int err = 0;
-       struct task_struct *me = current;
 
        frame = (struct rt_sigframe __user *)
                round_down(stack_top - sizeof(struct rt_sigframe), 16);
index 2fa02bc50034773290712429f6593af6051614fa..193097ef3d7d0d886ffa88b6c735571b9f66c1ec 100644 (file)
@@ -1681,8 +1681,8 @@ static void __init init_hvm_pv_info(void)
        xen_domain_type = XEN_HVM_DOMAIN;
 }
 
-static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
-                                   unsigned long action, void *hcpu)
+static int xen_hvm_cpu_notify(struct notifier_block *self, unsigned long action,
+                             void *hcpu)
 {
        int cpu = (long)hcpu;
        switch (action) {
@@ -1700,7 +1700,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
+static struct notifier_block xen_hvm_cpu_notifier = {
        .notifier_call  = xen_hvm_cpu_notify,
 };
 
index 94eac5c85cdc9eea7b32ac1d07d94252cac3087e..8f3eea6b80c527bd65fbbe80c6c8c8b7513805c6 100644 (file)
@@ -313,6 +313,17 @@ static void xen_align_and_add_e820_region(u64 start, u64 size, int type)
        e820_add_region(start, end - start, type);
 }
 
+void xen_ignore_unusable(struct e820entry *list, size_t map_size)
+{
+       struct e820entry *entry;
+       unsigned int i;
+
+       for (i = 0, entry = list; i < map_size; i++, entry++) {
+               if (entry->type == E820_UNUSABLE)
+                       entry->type = E820_RAM;
+       }
+}
+
 /**
  * machine_specific_memory_setup - Hook for machine specific memory setup.
  **/
@@ -353,6 +364,17 @@ char * __init xen_memory_setup(void)
        }
        BUG_ON(rc);
 
+       /*
+        * Xen won't allow a 1:1 mapping to be created to UNUSABLE
+        * regions, so if we're using the machine memory map leave the
+        * region as RAM as it is in the pseudo-physical map.
+        *
+        * UNUSABLE regions in domUs are not handled and will need
+        * a patch in the future.
+        */
+       if (xen_initial_domain())
+               xen_ignore_unusable(map, memmap.nr_entries);
+
        /* Make sure the Xen-supplied memory map is well-ordered. */
        sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
 
@@ -475,7 +497,7 @@ static void __init fiddle_vdso(void)
 #endif
 }
 
-static int __cpuinit register_callback(unsigned type, const void *func)
+static int register_callback(unsigned type, const void *func)
 {
        struct callback_register callback = {
                .type = type,
@@ -486,7 +508,7 @@ static int __cpuinit register_callback(unsigned type, const void *func)
        return HYPERVISOR_callback_op(CALLBACKOP_register, &callback);
 }
 
-void __cpuinit xen_enable_sysenter(void)
+void xen_enable_sysenter(void)
 {
        int ret;
        unsigned sysenter_feature;
@@ -505,7 +527,7 @@ void __cpuinit xen_enable_sysenter(void)
                setup_clear_cpu_cap(sysenter_feature);
 }
 
-void __cpuinit xen_enable_syscall(void)
+void xen_enable_syscall(void)
 {
 #ifdef CONFIG_X86_64
        int ret;
index c1367b29c3b13c7b1a796aaee8cfa101c90689fa..b81c88e51daa3d412a147f2088c1f51be1649d26 100644 (file)
@@ -65,7 +65,7 @@ static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static void __cpuinit cpu_bringup(void)
+static void cpu_bringup(void)
 {
        int cpu;
 
@@ -97,7 +97,7 @@ static void __cpuinit cpu_bringup(void)
        wmb();                  /* make sure everything is out */
 }
 
-static void __cpuinit cpu_bringup_and_idle(void)
+static void cpu_bringup_and_idle(void)
 {
        cpu_bringup();
        cpu_startup_entry(CPUHP_ONLINE);
@@ -326,7 +326,7 @@ static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
                set_cpu_present(cpu, true);
 }
 
-static int __cpuinit
+static int
 cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 {
        struct vcpu_guest_context *ctxt;
@@ -397,7 +397,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
        return 0;
 }
 
-static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
+static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
 {
        int rc;
 
@@ -470,7 +470,7 @@ static void xen_cpu_die(unsigned int cpu)
        xen_teardown_timer(cpu);
 }
 
-static void __cpuinit xen_play_dead(void) /* used only with HOTPLUG_CPU */
+static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
 {
        play_dead_common();
        HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
@@ -691,11 +691,18 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
        xen_init_lock_cpu(0);
 }
 
-static int __cpuinit xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
+static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
 {
        int rc;
-       rc = native_cpu_up(cpu, tidle);
-       WARN_ON (xen_smp_intr_init(cpu));
+       /*
+        * xen_smp_intr_init() needs to run before native_cpu_up()
+        * so that IPI vectors are set up on the booting CPU before
+        * it is marked online in native_cpu_up().
+       */
+       rc = xen_smp_intr_init(cpu);
+       WARN_ON(rc);
+       if (!rc)
+               rc =  native_cpu_up(cpu, tidle);
        return rc;
 }
 
index a40f8508e760d0259e6016903be5fdb1e5d69aa9..cf3caee356b35da57edb00141286abeeb650d2ef 100644 (file)
@@ -361,7 +361,7 @@ static irqreturn_t dummy_handler(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-void __cpuinit xen_init_lock_cpu(int cpu)
+void xen_init_lock_cpu(int cpu)
 {
        int irq;
        char *name;
index a95b41744ad0bafdcde069cb965cabb67ab0f61b..86782c5d7e2a6f1a3b4b8788583bd017bd0a1e78 100644 (file)
@@ -73,7 +73,7 @@ static inline void xen_hvm_smp_init(void) {}
 
 #ifdef CONFIG_PARAVIRT_SPINLOCKS
 void __init xen_init_spinlocks(void);
-void __cpuinit xen_init_lock_cpu(int cpu);
+void xen_init_lock_cpu(int cpu);
 void xen_uninit_lock_cpu(int cpu);
 #else
 static inline void xen_init_spinlocks(void)
index bdbb173125269afdf9a0bff5981a27e995fa05dc..24bb0c1776ba860fb03a72b94e0107ac8bcfe1f1 100644 (file)
@@ -162,7 +162,7 @@ irqreturn_t timer_interrupt (int irq, void *dev_id)
 }
 
 #ifndef CONFIG_GENERIC_CALIBRATE_DELAY
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        loops_per_jiffy = CCOUNT_PER_JIFFY;
        printk("Calibrating delay loop (skipped)... "
index 58916afbbda5d9801fc4f960d0b9b003e1112bee..4b8d9b541112017e14e0f72755124a2f3cf91f47 100644 (file)
@@ -189,8 +189,8 @@ void blk_iopoll_init(struct blk_iopoll *iop, int weight, blk_iopoll_fn *poll_fn)
 }
 EXPORT_SYMBOL(blk_iopoll_init);
 
-static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
-                                         unsigned long action, void *hcpu)
+static int blk_iopoll_cpu_notify(struct notifier_block *self,
+                                unsigned long action, void *hcpu)
 {
        /*
         * If a CPU goes away, splice its entries to the current CPU
@@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
+static struct notifier_block blk_iopoll_cpu_notifier = {
        .notifier_call  = blk_iopoll_cpu_notify,
 };
 
index 467c8de8864200cad58d66a283183d5ed5868f70..ec9e60636f4335c8e6af0617f9fbc61335c9fea5 100644 (file)
@@ -78,8 +78,8 @@ static int raise_blk_irq(int cpu, struct request *rq)
 }
 #endif
 
-static int __cpuinit blk_cpu_notify(struct notifier_block *self,
-                                   unsigned long action, void *hcpu)
+static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
+                         void *hcpu)
 {
        /*
         * If a CPU goes away, splice its entries to the current CPU
@@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata blk_cpu_notifier = {
+static struct notifier_block blk_cpu_notifier = {
        .notifier_call  = blk_cpu_notify,
 };
 
index 69ce573f1224560b4f5c7532e21053b27c651da4..aca01164f00200a8d14efa8a82e4a400b67d0bf1 100644 (file)
@@ -376,25 +376,6 @@ config CRYPTO_CRC32_PCLMUL
          which will enable any routine to use the CRC-32-IEEE 802.3 checksum
          and gain better performance as compared with the table implementation.
 
-config CRYPTO_CRCT10DIF
-       tristate "CRCT10DIF algorithm"
-       select CRYPTO_HASH
-       help
-         CRC T10 Data Integrity Field computation is being cast as
-         a crypto transform.  This allows for faster crc t10 diff
-         transforms to be used if they are available.
-
-config CRYPTO_CRCT10DIF_PCLMUL
-       tristate "CRCT10DIF PCLMULQDQ hardware acceleration"
-       depends on X86 && 64BIT && CRC_T10DIF
-       select CRYPTO_HASH
-       help
-         For x86_64 processors with SSE4.2 and PCLMULQDQ supported,
-         CRC T10 DIF PCLMULQDQ computation can be hardware
-         accelerated PCLMULQDQ instruction. This option will create
-         'crct10dif-plcmul' module, which is faster when computing the
-         crct10dif checksum as compared with the generic table implementation.
-
 config CRYPTO_GHASH
        tristate "GHASH digest algorithm"
        select CRYPTO_GF128MUL
index 2d5ed08a239fa3e79110c9dfd077d30da8954192..2ba0df2f908f5985ef23f0794c1f49e6fd5f3720 100644 (file)
@@ -83,7 +83,6 @@ obj-$(CONFIG_CRYPTO_ZLIB) += zlib.o
 obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
 obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
 obj-$(CONFIG_CRYPTO_CRC32) += crc32.o
-obj-$(CONFIG_CRYPTO_CRCT10DIF) += crct10dif.o
 obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
 obj-$(CONFIG_CRYPTO_LZO) += lzo.o
 obj-$(CONFIG_CRYPTO_LZ4) += lz4.o
diff --git a/crypto/crct10dif.c b/crypto/crct10dif.c
deleted file mode 100644 (file)
index 92aca96..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Cryptographic API.
- *
- * T10 Data Integrity Field CRC16 Crypto Transform
- *
- * Copyright (c) 2007 Oracle Corporation.  All rights reserved.
- * Written by Martin K. Petersen <martin.petersen@oracle.com>
- * Copyright (C) 2013 Intel Corporation
- * Author: Tim Chen <tim.c.chen@linux.intel.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <linux/types.h>
-#include <linux/module.h>
-#include <linux/crc-t10dif.h>
-#include <crypto/internal/hash.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/kernel.h>
-
-struct chksum_desc_ctx {
-       __u16 crc;
-};
-
-/* Table generated using the following polynomium:
- * x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
- * gt: 0x8bb7
- */
-static const __u16 t10_dif_crc_table[256] = {
-       0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B,
-       0xEFBD, 0x640A, 0x7364, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6,
-       0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F, 0x7A11, 0xF1A6,
-       0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B,
-       0xA99A, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1,
-       0x4627, 0xCD90, 0xDAFE, 0x5149, 0xF422, 0x7F95, 0x68FB, 0xE34C,
-       0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B, 0x583C,
-       0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781,
-       0xD883, 0x5334, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8,
-       0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B, 0x0E8C, 0x19E2, 0x9255,
-       0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925,
-       0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698,
-       0x7119, 0xFAAE, 0xEDC0, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472,
-       0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716, 0xB078, 0x3BCF,
-       0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF,
-       0xCA69, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02,
-       0x3AB1, 0xB106, 0xA668, 0x2DDF, 0x88B4, 0x0303, 0x146D, 0x9FDA,
-       0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0, 0x7067,
-       0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17,
-       0x81C1, 0x0A76, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA,
-       0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E, 0xAA99, 0xBDF7, 0x3640,
-       0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD,
-       0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D,
-       0x285B, 0xA3EC, 0xB482, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30,
-       0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80, 0xCCEE, 0x4759,
-       0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4,
-       0xB6FF, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394,
-       0x5942, 0xD2F5, 0xC59B, 0x4E2C, 0xEB47, 0x60F0, 0x779E, 0xFC29,
-       0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574, 0xEEC3,
-       0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E,
-       0x1F65, 0x94D2, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E,
-       0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD, 0xC96A, 0xDE04, 0x55B3
-};
-
-__u16 crc_t10dif_generic(__u16 crc, const unsigned char *buffer, size_t len)
-{
-       unsigned int i;
-
-       for (i = 0 ; i < len ; i++)
-               crc = (crc << 8) ^ t10_dif_crc_table[((crc >> 8) ^ buffer[i]) & 0xff];
-
-       return crc;
-}
-EXPORT_SYMBOL(crc_t10dif_generic);
-
-/*
- * Steps through buffer one byte at at time, calculates reflected
- * crc using table.
- */
-
-static int chksum_init(struct shash_desc *desc)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       ctx->crc = 0;
-
-       return 0;
-}
-
-static int chksum_update(struct shash_desc *desc, const u8 *data,
-                        unsigned int length)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       ctx->crc = crc_t10dif_generic(ctx->crc, data, length);
-       return 0;
-}
-
-static int chksum_final(struct shash_desc *desc, u8 *out)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       *(__u16 *)out = ctx->crc;
-       return 0;
-}
-
-static int __chksum_finup(__u16 *crcp, const u8 *data, unsigned int len,
-                       u8 *out)
-{
-       *(__u16 *)out = crc_t10dif_generic(*crcp, data, len);
-       return 0;
-}
-
-static int chksum_finup(struct shash_desc *desc, const u8 *data,
-                       unsigned int len, u8 *out)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       return __chksum_finup(&ctx->crc, data, len, out);
-}
-
-static int chksum_digest(struct shash_desc *desc, const u8 *data,
-                        unsigned int length, u8 *out)
-{
-       struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
-
-       return __chksum_finup(&ctx->crc, data, length, out);
-}
-
-static struct shash_alg alg = {
-       .digestsize             =       CRC_T10DIF_DIGEST_SIZE,
-       .init           =       chksum_init,
-       .update         =       chksum_update,
-       .final          =       chksum_final,
-       .finup          =       chksum_finup,
-       .digest         =       chksum_digest,
-       .descsize               =       sizeof(struct chksum_desc_ctx),
-       .base                   =       {
-               .cra_name               =       "crct10dif",
-               .cra_driver_name        =       "crct10dif-generic",
-               .cra_priority           =       100,
-               .cra_blocksize          =       CRC_T10DIF_BLOCK_SIZE,
-               .cra_module             =       THIS_MODULE,
-       }
-};
-
-static int __init crct10dif_mod_init(void)
-{
-       int ret;
-
-       ret = crypto_register_shash(&alg);
-       return ret;
-}
-
-static void __exit crct10dif_mod_fini(void)
-{
-       crypto_unregister_shash(&alg);
-}
-
-module_init(crct10dif_mod_init);
-module_exit(crct10dif_mod_fini);
-
-MODULE_AUTHOR("Tim Chen <tim.c.chen@linux.intel.com>");
-MODULE_DESCRIPTION("T10 DIF CRC calculation.");
-MODULE_LICENSE("GPL");
index 25a5934f0e50a011f73db08a84735ae76b2a7f60..66d254ce0d11b35ca55e07b8b0fd786c0b0f0c10 100644 (file)
@@ -1174,10 +1174,6 @@ static int do_test(int m)
                ret += tcrypt_test("ghash");
                break;
 
-       case 47:
-               ret += tcrypt_test("crct10dif");
-               break;
-
        case 100:
                ret += tcrypt_test("hmac(md5)");
                break;
@@ -1502,10 +1498,6 @@ static int do_test(int m)
                test_hash_speed("crc32c", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
 
-       case 320:
-               test_hash_speed("crct10dif", sec, generic_hash_speed_template);
-               if (mode > 300 && mode < 400) break;
-
        case 399:
                break;
 
index 2f00607039e2ad7c808d273f08756a8e463732d4..ecddf921a9db401ee30bea1bf24b30f0ee8dd85d 100644 (file)
@@ -2045,16 +2045,6 @@ static const struct alg_test_desc alg_test_descs[] = {
                                .count = CRC32C_TEST_VECTORS
                        }
                }
-       }, {
-               .alg = "crct10dif",
-               .test = alg_test_hash,
-               .fips_allowed = 1,
-               .suite = {
-                       .hash = {
-                               .vecs = crct10dif_tv_template,
-                               .count = CRCT10DIF_TEST_VECTORS
-                       }
-               }
        }, {
                .alg = "cryptd(__driver-cbc-aes-aesni)",
                .test = alg_test_null,
index 7d44aa3d6b4472646dd9b93a77d97a0a58762eae..1e701bc075b907521c0e0cd4a06e41858cda0a5f 100644 (file)
@@ -450,39 +450,6 @@ static struct hash_testvec rmd320_tv_template[] = {
        }
 };
 
-#define CRCT10DIF_TEST_VECTORS 3
-static struct hash_testvec crct10dif_tv_template[] = {
-       {
-               .plaintext = "abc",
-               .psize  = 3,
-#ifdef __LITTLE_ENDIAN
-               .digest = "\x3b\x44",
-#else
-               .digest = "\x44\x3b",
-#endif
-       }, {
-               .plaintext = "1234567890123456789012345678901234567890"
-                            "123456789012345678901234567890123456789",
-               .psize  = 79,
-#ifdef __LITTLE_ENDIAN
-               .digest = "\x70\x4b",
-#else
-               .digest = "\x4b\x70",
-#endif
-       }, {
-               .plaintext =
-               "abcddddddddddddddddddddddddddddddddddddddddddddddddddddd",
-               .psize  = 56,
-#ifdef __LITTLE_ENDIAN
-               .digest = "\xe3\x9c",
-#else
-               .digest = "\x9c\xe3",
-#endif
-               .np     = 2,
-               .tap    = { 28, 28 }
-       }
-};
-
 /*
  * SHA1 test vectors  from from FIPS PUB 180-1
  * Long vector from CAVS 5.0
index d21167bfc86564b480f21c9b690fe263a0609a73..dc34a5b8bceeea2d9dfac6ccccee6bb7ed64c0e2 100644 (file)
@@ -359,6 +359,9 @@ int braille_register_console(struct console *console, int index,
                char *console_options, char *braille_options)
 {
        int ret;
+
+       if (!(console->flags & CON_BRL))
+               return 0;
        if (!console_options)
                /* Only support VisioBraille for now */
                console_options = "57600o8";
@@ -374,15 +377,17 @@ int braille_register_console(struct console *console, int index,
        braille_co = console;
        register_keyboard_notifier(&keyboard_notifier_block);
        register_vt_notifier(&vt_notifier_block);
-       return 0;
+       return 1;
 }
 
 int braille_unregister_console(struct console *console)
 {
        if (braille_co != console)
                return -EINVAL;
+       if (!(console->flags & CON_BRL))
+               return 0;
        unregister_keyboard_notifier(&keyboard_notifier_block);
        unregister_vt_notifier(&vt_notifier_block);
        braille_co = NULL;
-       return 0;
+       return 1;
 }
index c711d1144044ec18b47a8aad9f0c0f43e5f5f690..999adb5499c7270626466a7d74870531c3e3ae28 100644 (file)
@@ -323,6 +323,7 @@ static int acpi_memory_device_add(struct acpi_device *device,
        /* Get the range from the _CRS */
        result = acpi_memory_get_device_resources(mem_device);
        if (result) {
+               device->driver_data = NULL;
                kfree(mem_device);
                return result;
        }
index e9b01e35ac375efd62609bd628b9a8edf1ad1eb3..5a74a9c1e42c85a6999f9a4ef780728f8bdc5bcb 100644 (file)
@@ -340,7 +340,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
  */
 static DEFINE_PER_CPU(void *, processor_device_array);
 
-static int __cpuinit acpi_processor_add(struct acpi_device *device,
+static int acpi_processor_add(struct acpi_device *device,
                                        const struct acpi_device_id *id)
 {
        struct acpi_processor *pr;
@@ -451,7 +451,6 @@ static void acpi_processor_remove(struct acpi_device *device)
        /* Clean up. */
        per_cpu(processor_device_array, pr->id) = NULL;
        per_cpu(processors, pr->id) = NULL;
-       try_offline_node(cpu_to_node(pr->id));
 
        /* Remove the CPU. */
        get_online_cpus();
@@ -459,6 +458,8 @@ static void acpi_processor_remove(struct acpi_device *device)
        acpi_unmap_lsapic(pr->id);
        put_online_cpus();
 
+       try_offline_node(cpu_to_node(pr->id));
+
  out:
        free_cpumask_var(pr->throttling.shared_cpu_map);
        kfree(pr);
index dfed26545ba28bb7858ce832fdce823460407992..d4a4901637cd01f06e2646a145abdeaff16773ec 100644 (file)
@@ -931,19 +931,6 @@ struct acpi_bit_register_info {
 
 /* Structs and definitions for _OSI support and I/O port validation */
 
-#define ACPI_OSI_WIN_2000               0x01
-#define ACPI_OSI_WIN_XP                 0x02
-#define ACPI_OSI_WIN_XP_SP1             0x03
-#define ACPI_OSI_WINSRV_2003            0x04
-#define ACPI_OSI_WIN_XP_SP2             0x05
-#define ACPI_OSI_WINSRV_2003_SP1        0x06
-#define ACPI_OSI_WIN_VISTA              0x07
-#define ACPI_OSI_WINSRV_2008            0x08
-#define ACPI_OSI_WIN_VISTA_SP1          0x09
-#define ACPI_OSI_WIN_VISTA_SP2          0x0A
-#define ACPI_OSI_WIN_7                  0x0B
-#define ACPI_OSI_WIN_8                  0x0C
-
 #define ACPI_ALWAYS_ILLEGAL             0x00
 
 struct acpi_interface_info {
index 082b4dd252a82ab17f7fe7249913e1f7030d35fd..d405fbad406ac75cc9bb41c8734a457d60e14222 100644 (file)
@@ -117,6 +117,7 @@ struct acpi_battery {
        struct acpi_device *device;
        struct notifier_block pm_nb;
        unsigned long update_time;
+       int revision;
        int rate_now;
        int capacity_now;
        int voltage_now;
@@ -359,6 +360,7 @@ static struct acpi_offsets info_offsets[] = {
 };
 
 static struct acpi_offsets extended_info_offsets[] = {
+       {offsetof(struct acpi_battery, revision), 0},
        {offsetof(struct acpi_battery, power_unit), 0},
        {offsetof(struct acpi_battery, design_capacity), 0},
        {offsetof(struct acpi_battery, full_charge_capacity), 0},
index f68095756fb7465bc034ca5335f9345a806dd97d..408f6b2a5fa8ee5c6578cd9e555a8386e112e370 100644 (file)
@@ -31,6 +31,7 @@ static LIST_HEAD(bus_type_list);
 static DECLARE_RWSEM(bus_type_sem);
 
 #define PHYSICAL_NODE_STRING "physical_node"
+#define PHYSICAL_NODE_NAME_SIZE (sizeof(PHYSICAL_NODE_STRING) + 10)
 
 int register_acpi_bus_type(struct acpi_bus_type *type)
 {
@@ -78,41 +79,108 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
        return ret;
 }
 
-static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
-                                     void *addr_p, void **ret_p)
+static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used,
+                                 void *not_used, void **ret_p)
 {
-       unsigned long long addr, sta;
-       acpi_status status;
+       struct acpi_device *adev = NULL;
 
-       status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
-       if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) {
+       acpi_bus_get_device(handle, &adev);
+       if (adev) {
                *ret_p = handle;
-               status = acpi_bus_get_status_handle(handle, &sta);
-               if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_ENABLED))
-                       return AE_CTRL_TERMINATE;
+               return AE_CTRL_TERMINATE;
        }
        return AE_OK;
 }
 
-acpi_handle acpi_get_child(acpi_handle parent, u64 address)
+static bool acpi_extra_checks_passed(acpi_handle handle, bool is_bridge)
 {
-       void *ret = NULL;
+       unsigned long long sta;
+       acpi_status status;
+
+       status = acpi_bus_get_status_handle(handle, &sta);
+       if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
+               return false;
+
+       if (is_bridge) {
+               void *test = NULL;
+
+               /* Check if this object has at least one child device. */
+               acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
+                                   acpi_dev_present, NULL, NULL, &test);
+               return !!test;
+       }
+       return true;
+}
+
+struct find_child_context {
+       u64 addr;
+       bool is_bridge;
+       acpi_handle ret;
+       bool ret_checked;
+};
+
+static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used,
+                                void *data, void **not_used)
+{
+       struct find_child_context *context = data;
+       unsigned long long addr;
+       acpi_status status;
 
-       if (!parent)
-               return NULL;
+       status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
+       if (ACPI_FAILURE(status) || addr != context->addr)
+               return AE_OK;
 
-       acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, NULL,
-                           do_acpi_find_child, &address, &ret);
-       return (acpi_handle)ret;
+       if (!context->ret) {
+               /* This is the first matching object.  Save its handle. */
+               context->ret = handle;
+               return AE_OK;
+       }
+       /*
+        * There is more than one matching object with the same _ADR value.
+        * That really is unexpected, so we are kind of beyond the scope of the
+        * spec here.  We have to choose which one to return, though.
+        *
+        * First, check if the previously found object is good enough and return
+        * its handle if so.  Second, check the same for the object that we've
+        * just found.
+        */
+       if (!context->ret_checked) {
+               if (acpi_extra_checks_passed(context->ret, context->is_bridge))
+                       return AE_CTRL_TERMINATE;
+               else
+                       context->ret_checked = true;
+       }
+       if (acpi_extra_checks_passed(handle, context->is_bridge)) {
+               context->ret = handle;
+               return AE_CTRL_TERMINATE;
+       }
+       return AE_OK;
 }
-EXPORT_SYMBOL(acpi_get_child);
+
+acpi_handle acpi_find_child(acpi_handle parent, u64 addr, bool is_bridge)
+{
+       if (parent) {
+               struct find_child_context context = {
+                       .addr = addr,
+                       .is_bridge = is_bridge,
+               };
+
+               acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_find_child,
+                                   NULL, &context, NULL);
+               return context.ret;
+       }
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(acpi_find_child);
 
 int acpi_bind_one(struct device *dev, acpi_handle handle)
 {
        struct acpi_device *acpi_dev;
        acpi_status status;
        struct acpi_device_physical_node *physical_node, *pn;
-       char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2];
+       char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
+       struct list_head *physnode_list;
+       unsigned int node_id;
        int retval = -EINVAL;
 
        if (ACPI_HANDLE(dev)) {
@@ -139,25 +207,27 @@ int acpi_bind_one(struct device *dev, acpi_handle handle)
 
        mutex_lock(&acpi_dev->physical_node_lock);
 
-       /* Sanity check. */
-       list_for_each_entry(pn, &acpi_dev->physical_node_list, node)
+       /*
+        * Keep the list sorted by node_id so that the IDs of removed nodes can
+        * be recycled easily.
+        */
+       physnode_list = &acpi_dev->physical_node_list;
+       node_id = 0;
+       list_for_each_entry(pn, &acpi_dev->physical_node_list, node) {
+               /* Sanity check. */
                if (pn->dev == dev) {
                        dev_warn(dev, "Already associated with ACPI node\n");
                        goto err_free;
                }
-
-       /* allocate physical node id according to physical_node_id_bitmap */
-       physical_node->node_id =
-               find_first_zero_bit(acpi_dev->physical_node_id_bitmap,
-               ACPI_MAX_PHYSICAL_NODE);
-       if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
-               retval = -ENOSPC;
-               goto err_free;
+               if (pn->node_id == node_id) {
+                       physnode_list = &pn->node;
+                       node_id++;
+               }
        }
 
-       set_bit(physical_node->node_id, acpi_dev->physical_node_id_bitmap);
+       physical_node->node_id = node_id;
        physical_node->dev = dev;
-       list_add_tail(&physical_node->node, &acpi_dev->physical_node_list);
+       list_add(&physical_node->node, physnode_list);
        acpi_dev->physical_node_count++;
 
        mutex_unlock(&acpi_dev->physical_node_lock);
@@ -208,7 +278,7 @@ int acpi_unbind_one(struct device *dev)
 
        mutex_lock(&acpi_dev->physical_node_lock);
        list_for_each_safe(node, next, &acpi_dev->physical_node_list) {
-               char physical_node_name[sizeof(PHYSICAL_NODE_STRING) + 2];
+               char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
 
                entry = list_entry(node, struct acpi_device_physical_node,
                        node);
@@ -216,7 +286,6 @@ int acpi_unbind_one(struct device *dev)
                        continue;
 
                list_del(node);
-               clear_bit(entry->node_id, acpi_dev->physical_node_id_bitmap);
 
                acpi_dev->physical_node_count--;
 
index 3a50a34fe176b34bb77a3ff8cfff9588fe523da8..5da44e81dd4d70f7ed42ae1f1587734c0b6a5a55 100644 (file)
@@ -164,4 +164,13 @@ struct platform_device;
 int acpi_create_platform_device(struct acpi_device *adev,
                                const struct acpi_device_id *id);
 
+/*--------------------------------------------------------------------------
+                                       Video
+  -------------------------------------------------------------------------- */
+#if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
+bool acpi_video_backlight_quirks(void);
+#else
+static inline bool acpi_video_backlight_quirks(void) { return false; }
+#endif
+
 #endif /* _ACPI_INTERNAL_H_ */
index aa1227a7e3f23e349ed5050680d4fef8c135cfc8..04a13784dd20a4a7e42b15b98eedcff90cb67299 100644 (file)
@@ -311,6 +311,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
                           dev->pnp.bus_id,
                           (u32) dev->wakeup.sleep_state);
 
+               mutex_lock(&dev->physical_node_lock);
+
                if (!dev->physical_node_count) {
                        seq_printf(seq, "%c%-8s\n",
                                dev->wakeup.flags.run_wake ? '*' : ' ',
@@ -338,6 +340,8 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
                                put_device(ldev);
                        }
                }
+
+               mutex_unlock(&dev->physical_node_lock);
        }
        mutex_unlock(&acpi_device_lock);
        return 0;
@@ -347,12 +351,16 @@ static void physical_device_enable_wakeup(struct acpi_device *adev)
 {
        struct acpi_device_physical_node *entry;
 
+       mutex_lock(&adev->physical_node_lock);
+
        list_for_each_entry(entry,
                &adev->physical_node_list, node)
                if (entry->dev && device_can_wakeup(entry->dev)) {
                        bool enable = !device_may_wakeup(entry->dev);
                        device_set_wakeup_enable(entry->dev, enable);
                }
+
+       mutex_unlock(&adev->physical_node_lock);
 }
 
 static ssize_t
index 164d49569aebfbd3e15991bf68aa2eb13c42fe6a..a5e9f4a5b2816a9473942b229bc4632ec640bf5c 100644 (file)
@@ -253,7 +253,7 @@ static bool __init processor_physically_present(acpi_handle handle)
        return true;
 }
 
-static void __cpuinit acpi_set_pdc_bits(u32 *buf)
+static void acpi_set_pdc_bits(u32 *buf)
 {
        buf[0] = ACPI_PDC_REVISION_ID;
        buf[1] = 1;
@@ -265,7 +265,7 @@ static void __cpuinit acpi_set_pdc_bits(u32 *buf)
        arch_acpi_set_pdc_bits(buf);
 }
 
-static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void)
+static struct acpi_object_list *acpi_processor_alloc_pdc(void)
 {
        struct acpi_object_list *obj_list;
        union acpi_object *obj;
@@ -308,7 +308,7 @@ static struct acpi_object_list *__cpuinit acpi_processor_alloc_pdc(void)
  * _PDC is required for a BIOS-OS handshake for most of the newer
  * ACPI processor features.
  */
-static int __cpuinit
+static int
 acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
 {
        acpi_status status = AE_OK;
@@ -336,7 +336,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
        return status;
 }
 
-void __cpuinit acpi_processor_set_pdc(acpi_handle handle)
+void acpi_processor_set_pdc(acpi_handle handle)
 {
        struct acpi_object_list *obj_list;
 
index 823be116619e9d802ed2ca7cc9fc2f1c924b5119..870eaf5fa547b935bdde1fe31a7bf31d2ab3d222 100644 (file)
@@ -118,9 +118,9 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
        return;
 }
 
-static __cpuinit int __acpi_processor_start(struct acpi_device *device);
+static int __acpi_processor_start(struct acpi_device *device);
 
-static int __cpuinit acpi_cpu_soft_notify(struct notifier_block *nfb,
+static int acpi_cpu_soft_notify(struct notifier_block *nfb,
                                          unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
@@ -162,7 +162,7 @@ static struct notifier_block __refdata acpi_cpu_notifier =
            .notifier_call = acpi_cpu_soft_notify,
 };
 
-static __cpuinit int __acpi_processor_start(struct acpi_device *device)
+static int __acpi_processor_start(struct acpi_device *device)
 {
        struct acpi_processor *pr = acpi_driver_data(device);
        acpi_status status;
@@ -226,7 +226,7 @@ static __cpuinit int __acpi_processor_start(struct acpi_device *device)
        return result;
 }
 
-static int __cpuinit acpi_processor_start(struct device *dev)
+static int acpi_processor_start(struct device *dev)
 {
        struct acpi_device *device;
 
index 0461ccc92c54912142098a7d9b30dcb30685d21d..f98dd00b51a94b2d7e2d7dc9cd15f3e941e81bff 100644 (file)
@@ -96,9 +96,7 @@ static int set_max_cstate(const struct dmi_system_id *id)
        return 0;
 }
 
-/* Actually this shouldn't be __cpuinitdata, would be better to fix the
-   callers to only run once -AK */
-static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
+static struct dmi_system_id processor_power_dmi_table[] = {
        { set_max_cstate, "Clevo 5600D", {
          DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
          DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307")},
@@ -1165,7 +1163,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 
 static int acpi_processor_registered;
 
-int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
+int acpi_processor_power_init(struct acpi_processor *pr)
 {
        acpi_status status = 0;
        int retval;
index 10985573aaa7c680613c1412c958d81d7af22f64..8a46c924effd4e5bef09cb645429170e70ed380a 100644 (file)
@@ -352,10 +352,12 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
        mutex_lock(&acpi_scan_lock);
        lock_device_hotplug();
 
-       acpi_bus_get_device(handle, &device);
-       if (device) {
-               dev_warn(&device->dev, "Attempt to re-insert\n");
-               goto out;
+       if (ost_source != ACPI_NOTIFY_BUS_CHECK) {
+               acpi_bus_get_device(handle, &device);
+               if (device) {
+                       dev_warn(&device->dev, "Attempt to re-insert\n");
+                       goto out;
+               }
        }
        acpi_evaluate_hotplug_ost(handle, ost_source,
                                  ACPI_OST_SC_INSERT_IN_PROGRESS, NULL);
@@ -1981,6 +1983,9 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
        if (acpi_bus_get_device(handle, &device))
                return AE_CTRL_DEPTH;
 
+       if (device->handler)
+               return AE_OK;
+
        ret = acpi_scan_attach_handler(device);
        if (ret)
                return ret > 0 ? AE_OK : AE_CTRL_DEPTH;
index 5d7075d25700b3bbd2cbe65772391155d1a10d30..e1284b8dc6eef9b800f997ecbf6bc5e60214eacc 100644 (file)
@@ -44,6 +44,8 @@
 #include <linux/suspend.h>
 #include <acpi/video.h>
 
+#include "internal.h"
+
 #define PREFIX "ACPI: "
 
 #define ACPI_VIDEO_BUS_NAME            "Video Bus"
@@ -448,6 +450,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
                DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"),
                },
        },
+       {
+        .callback = video_ignore_initial_backlight,
+        .ident = "Fujitsu E753",
+        .matches = {
+               DMI_MATCH(DMI_BOARD_VENDOR, "FUJITSU"),
+               DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E753"),
+               },
+       },
        {
         .callback = video_ignore_initial_backlight,
         .ident = "HP Pavilion dm4",
@@ -679,7 +689,7 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
         * Some systems always report current brightness level as maximum
         * through _BQC, we need to test another value for them.
         */
-       test_level = current_level == max_level ? br->levels[2] : max_level;
+       test_level = current_level == max_level ? br->levels[3] : max_level;
 
        result = acpi_video_device_lcd_set_level(device, test_level);
        if (result)
@@ -898,6 +908,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                device->cap._DDC = 1;
        }
 
+       if (acpi_video_init_brightness(device))
+               return;
+
        if (acpi_video_backlight_support()) {
                struct backlight_properties props;
                struct pci_dev *pdev;
@@ -907,9 +920,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                static int count = 0;
                char *name;
 
-               result = acpi_video_init_brightness(device);
-               if (result)
-                       return;
                name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
                if (!name)
                        return;
@@ -969,6 +979,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                if (result)
                        printk(KERN_ERR PREFIX "Create sysfs link\n");
 
+       } else {
+               /* Remove the brightness object. */
+               kfree(device->brightness->levels);
+               kfree(device->brightness);
+               device->brightness = NULL;
        }
 }
 
@@ -1532,14 +1547,20 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
 
 /* acpi_video interface */
 
+/*
+ * Win8 requires setting bit2 of _DOS to let firmware know it shouldn't
+ * preform any automatic brightness change on receiving a notification.
+ */
 static int acpi_video_bus_start_devices(struct acpi_video_bus *video)
 {
-       return acpi_video_bus_DOS(video, 0, 0);
+       return acpi_video_bus_DOS(video, 0,
+                                 acpi_video_backlight_quirks() ? 1 : 0);
 }
 
 static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
 {
-       return acpi_video_bus_DOS(video, 0, 1);
+       return acpi_video_bus_DOS(video, 0,
+                                 acpi_video_backlight_quirks() ? 0 : 1);
 }
 
 static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
index e6bd910bc6edee4b55e3b6de7888bdd5c5ec06f6..c3397748ba466ca13f41c664b4c374c7dea5d028 100644 (file)
@@ -38,6 +38,8 @@
 #include <linux/dmi.h>
 #include <linux/pci.h>
 
+#include "internal.h"
+
 #define PREFIX "ACPI: "
 
 ACPI_MODULE_NAME("video");
@@ -234,6 +236,12 @@ static void acpi_video_caps_check(void)
                acpi_video_get_capabilities(NULL);
 }
 
+bool acpi_video_backlight_quirks(void)
+{
+       return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
+}
+EXPORT_SYMBOL(acpi_video_backlight_quirks);
+
 /* Promote the vendor interface instead of the generic video module.
  * This function allow DMI blacklists to be implemented by externals
  * platform drivers instead of putting a big blacklist in video_detect.c
index 80dc988f01e4f1eebb7d12311ab98c8ac48dc013..4e737728aee207a5d644d6fa0d39b0e3c402bd47 100644 (file)
@@ -97,6 +97,15 @@ config SATA_AHCI_PLATFORM
 
          If unsure, say N.
 
+config AHCI_IMX
+       tristate "Freescale i.MX AHCI SATA support"
+       depends on SATA_AHCI_PLATFORM && MFD_SYSCON
+       help
+         This option enables support for the Freescale i.MX SoC's
+         onboard AHCI SATA.
+
+         If unsure, say N.
+
 config SATA_FSL
        tristate "Freescale 3.0Gbps SATA support"
        depends on FSL_SOC
@@ -107,7 +116,7 @@ config SATA_FSL
          If unsure, say N.
 
 config SATA_INIC162X
-       tristate "Initio 162x SATA support"
+       tristate "Initio 162x SATA support (Very Experimental)"
        depends on PCI
        help
          This option enables support for Initio 162x Serial ATA.
index c04d0fd038a312485712ed2be8a42d77b32df5c9..46518c622460942cdf8e2971dd95f3b069961ada 100644 (file)
@@ -10,6 +10,7 @@ obj-$(CONFIG_SATA_INIC162X)   += sata_inic162x.o
 obj-$(CONFIG_SATA_SIL24)       += sata_sil24.o
 obj-$(CONFIG_SATA_DWC)         += sata_dwc_460ex.o
 obj-$(CONFIG_SATA_HIGHBANK)    += sata_highbank.o libahci.o
+obj-$(CONFIG_AHCI_IMX)         += ahci_imx.o
 
 # SFF w/ custom DMA
 obj-$(CONFIG_PDC_ADMA)         += pdc_adma.o
index 5064f3ea20f1b6f362928bd7a5b3cce39894b259..db4380d7003115ef8c4d05c1ca3543adce0efecb 100644 (file)
@@ -1146,11 +1146,18 @@ int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis)
                return rc;
 
        for (i = 0; i < host->n_ports; i++) {
+               const char* desc;
                struct ahci_port_priv *pp = host->ports[i]->private_data;
 
+               /* pp is NULL for dummy ports */
+               if (pp)
+                       desc = pp->irq_desc;
+               else
+                       desc = dev_driver_string(host->dev);
+
                rc = devm_request_threaded_irq(host->dev,
                        irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED,
-                       pp->irq_desc, host->ports[i]);
+                       desc, host->ports[i]);
                if (rc)
                        goto out_free_irqs;
        }
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
new file mode 100644 (file)
index 0000000..58debb0
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * Freescale IMX AHCI SATA platform driver
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/ahci_platform.h>
+#include <linux/of_device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
+#include "ahci.h"
+
+enum {
+       HOST_TIMER1MS = 0xe0, /* Timer 1-ms */
+};
+
+struct imx_ahci_priv {
+       struct platform_device *ahci_pdev;
+       struct clk *sata_ref_clk;
+       struct clk *ahb_clk;
+       struct regmap *gpr;
+};
+
+static int imx6q_sata_init(struct device *dev, void __iomem *mmio)
+{
+       int ret = 0;
+       unsigned int reg_val;
+       struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent);
+
+       imxpriv->gpr =
+               syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
+       if (IS_ERR(imxpriv->gpr)) {
+               dev_err(dev, "failed to find fsl,imx6q-iomux-gpr regmap\n");
+               return PTR_ERR(imxpriv->gpr);
+       }
+
+       ret = clk_prepare_enable(imxpriv->sata_ref_clk);
+       if (ret < 0) {
+               dev_err(dev, "prepare-enable sata_ref clock err:%d\n", ret);
+               return ret;
+       }
+
+       /*
+        * set PHY Paremeters, two steps to configure the GPR13,
+        * one write for rest of parameters, mask of first write
+        * is 0x07fffffd, and the other one write for setting
+        * the mpll_clk_en.
+        */
+       regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK
+                       | IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK
+                       | IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK
+                       | IMX6Q_GPR13_SATA_SPD_MODE_MASK
+                       | IMX6Q_GPR13_SATA_MPLL_SS_EN
+                       | IMX6Q_GPR13_SATA_TX_ATTEN_MASK
+                       | IMX6Q_GPR13_SATA_TX_BOOST_MASK
+                       | IMX6Q_GPR13_SATA_TX_LVL_MASK
+                       | IMX6Q_GPR13_SATA_TX_EDGE_RATE
+                       , IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB
+                       | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M
+                       | IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F
+                       | IMX6Q_GPR13_SATA_SPD_MODE_3P0G
+                       | IMX6Q_GPR13_SATA_MPLL_SS_EN
+                       | IMX6Q_GPR13_SATA_TX_ATTEN_9_16
+                       | IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB
+                       | IMX6Q_GPR13_SATA_TX_LVL_1_025_V);
+       regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_MPLL_CLK_EN,
+                       IMX6Q_GPR13_SATA_MPLL_CLK_EN);
+       usleep_range(100, 200);
+
+       /*
+        * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL,
+        * and IP vendor specific register HOST_TIMER1MS.
+        * Configure CAP_SSS (support stagered spin up).
+        * Implement the port0.
+        * Get the ahb clock rate, and configure the TIMER1MS register.
+        */
+       reg_val = readl(mmio + HOST_CAP);
+       if (!(reg_val & HOST_CAP_SSS)) {
+               reg_val |= HOST_CAP_SSS;
+               writel(reg_val, mmio + HOST_CAP);
+       }
+       reg_val = readl(mmio + HOST_PORTS_IMPL);
+       if (!(reg_val & 0x1)) {
+               reg_val |= 0x1;
+               writel(reg_val, mmio + HOST_PORTS_IMPL);
+       }
+
+       reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000;
+       writel(reg_val, mmio + HOST_TIMER1MS);
+
+       return 0;
+}
+
+static void imx6q_sata_exit(struct device *dev)
+{
+       struct imx_ahci_priv *imxpriv =  dev_get_drvdata(dev->parent);
+
+       regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_MPLL_CLK_EN,
+                       !IMX6Q_GPR13_SATA_MPLL_CLK_EN);
+       clk_disable_unprepare(imxpriv->sata_ref_clk);
+}
+
+static struct ahci_platform_data imx6q_sata_pdata = {
+       .init = imx6q_sata_init,
+       .exit = imx6q_sata_exit,
+};
+
+static const struct of_device_id imx_ahci_of_match[] = {
+       { .compatible = "fsl,imx6q-ahci", .data = &imx6q_sata_pdata},
+       {},
+};
+MODULE_DEVICE_TABLE(of, imx_ahci_of_match);
+
+static int imx_ahci_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct resource *mem, *irq, res[2];
+       const struct of_device_id *of_id;
+       const struct ahci_platform_data *pdata = NULL;
+       struct imx_ahci_priv *imxpriv;
+       struct device *ahci_dev;
+       struct platform_device *ahci_pdev;
+       int ret;
+
+       imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL);
+       if (!imxpriv) {
+               dev_err(dev, "can't alloc ahci_host_priv\n");
+               return -ENOMEM;
+       }
+
+       ahci_pdev = platform_device_alloc("ahci", -1);
+       if (!ahci_pdev)
+               return -ENODEV;
+
+       ahci_dev = &ahci_pdev->dev;
+       ahci_dev->parent = dev;
+
+       imxpriv->ahb_clk = devm_clk_get(dev, "ahb");
+       if (IS_ERR(imxpriv->ahb_clk)) {
+               dev_err(dev, "can't get ahb clock.\n");
+               ret = PTR_ERR(imxpriv->ahb_clk);
+               goto err_out;
+       }
+
+       imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref");
+       if (IS_ERR(imxpriv->sata_ref_clk)) {
+               dev_err(dev, "can't get sata_ref clock.\n");
+               ret = PTR_ERR(imxpriv->sata_ref_clk);
+               goto err_out;
+       }
+
+       imxpriv->ahci_pdev = ahci_pdev;
+       platform_set_drvdata(pdev, imxpriv);
+
+       of_id = of_match_device(imx_ahci_of_match, dev);
+       if (of_id) {
+               pdata = of_id->data;
+       } else {
+               ret = -EINVAL;
+               goto err_out;
+       }
+
+       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (!mem || !irq) {
+               dev_err(dev, "no mmio/irq resource\n");
+               ret = -ENOMEM;
+               goto err_out;
+       }
+
+       res[0] = *mem;
+       res[1] = *irq;
+
+       ahci_dev->coherent_dma_mask = DMA_BIT_MASK(32);
+       ahci_dev->dma_mask = &ahci_dev->coherent_dma_mask;
+       ahci_dev->of_node = dev->of_node;
+
+       ret = platform_device_add_resources(ahci_pdev, res, 2);
+       if (ret)
+               goto err_out;
+
+       ret = platform_device_add_data(ahci_pdev, pdata, sizeof(*pdata));
+       if (ret)
+               goto err_out;
+
+       ret = platform_device_add(ahci_pdev);
+       if (ret) {
+err_out:
+               platform_device_put(ahci_pdev);
+               return ret;
+       }
+
+       return 0;
+}
+
+static int imx_ahci_remove(struct platform_device *pdev)
+{
+       struct imx_ahci_priv *imxpriv = platform_get_drvdata(pdev);
+       struct platform_device *ahci_pdev = imxpriv->ahci_pdev;
+
+       platform_device_unregister(ahci_pdev);
+       return 0;
+}
+
+static struct platform_driver imx_ahci_driver = {
+       .probe = imx_ahci_probe,
+       .remove = imx_ahci_remove,
+       .driver = {
+               .name = "ahci-imx",
+               .owner = THIS_MODULE,
+               .of_match_table = imx_ahci_of_match,
+       },
+};
+module_platform_driver(imx_ahci_driver);
+
+MODULE_DESCRIPTION("Freescale i.MX AHCI SATA platform driver");
+MODULE_AUTHOR("Richard Zhu <Hong-Xing.Zhu@freescale.com>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("ahci:imx");
index b52a10c8eeb9b775cd1c7fd438ace85571e2ca27..513ad7ed0c997e19c3b3c4190b09221199c3d16c 100644 (file)
@@ -330,7 +330,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
        /* SATA Controller IDE (Wellsburg) */
        { 0x8086, 0x8d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
        /* SATA Controller IDE (Wellsburg) */
-       { 0x8086, 0x8d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
+       { 0x8086, 0x8d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_snb },
        /* SATA Controller IDE (Wellsburg) */
        { 0x8086, 0x8d60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb },
        /* SATA Controller IDE (Wellsburg) */
index 83c08907e0428bd44c6fad7f1f634357ea5606cd..b1e880a3c3dabb9b5bd253da522c8879632d993c 100644 (file)
@@ -206,8 +206,10 @@ static ssize_t ata_scsi_park_store(struct device *device,
        unsigned long flags;
        int rc;
 
-       rc = strict_strtol(buf, 10, &input);
-       if (rc || input < -2)
+       rc = kstrtol(buf, 10, &input);
+       if (rc)
+               return rc;
+       if (input < -2)
                return -EINVAL;
        if (input > ATA_TMOUT_MAX_PARK) {
                rc = -EOVERFLOW;
index 4ec7c04b3f8279dff1f2e39f356106e92815e39f..26386f0b89a8f4583c397ca9da154a9c499c6d2f 100644 (file)
@@ -237,6 +237,7 @@ static const struct of_device_id imx_pata_dt_ids[] = {
                /* sentinel */
        }
 };
+MODULE_DEVICE_TABLE(of, imx_pata_dt_ids);
 
 static struct platform_driver pata_imx_driver = {
        .probe          = pata_imx_probe,
index e4513174824830fa67d3e000ec97a449245fb0c8..5c54d957370afcaf9cf6c0d1962d87cc1b98eaac 100644 (file)
@@ -6,6 +6,18 @@
  *
  * This file is released under GPL v2.
  *
+ * **** WARNING ****
+ *
+ * This driver never worked properly and unfortunately data corruption is
+ * relatively common.  There isn't anyone working on the driver and there's
+ * no support from the vendor.  Do not use this driver in any production
+ * environment.
+ *
+ * http://thread.gmane.org/gmane.linux.debian.devel.bugs.rc/378525/focus=54491
+ * https://bugzilla.kernel.org/show_bug.cgi?id=60565
+ *
+ * *****************
+ *
  * This controller is eccentric and easily locks up if something isn't
  * right.  Documentation is available at initio's website but it only
  * documents registers (not programming model).
@@ -807,6 +819,8 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        ata_print_version_once(&pdev->dev, DRV_VERSION);
 
+       dev_alert(&pdev->dev, "inic162x support is broken with common data corruption issues and will be disabled by default, contact linux-ide@vger.kernel.org if in production use\n");
+
        /* alloc host */
        host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS);
        hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
index dc3ea237f086948ec5fe4a5ccd74bb47050fc336..8856d74545d988271986f9152380ba3f615f9f8a 100644 (file)
@@ -528,9 +528,12 @@ static int device_add_attrs(struct device *dev)
        int error;
 
        if (class) {
-               error = device_add_attributes(dev, class->dev_attrs);
+               error = device_add_groups(dev, class->dev_groups);
                if (error)
                        return error;
+               error = device_add_attributes(dev, class->dev_attrs);
+               if (error)
+                       goto err_remove_class_groups;
                error = device_add_bin_attributes(dev, class->dev_bin_attrs);
                if (error)
                        goto err_remove_class_attrs;
@@ -563,6 +566,9 @@ static int device_add_attrs(struct device *dev)
  err_remove_class_attrs:
        if (class)
                device_remove_attributes(dev, class->dev_attrs);
+ err_remove_class_groups:
+       if (class)
+               device_remove_groups(dev, class->dev_groups);
 
        return error;
 }
@@ -581,6 +587,7 @@ static void device_remove_attrs(struct device *dev)
        if (class) {
                device_remove_attributes(dev, class->dev_attrs);
                device_remove_bin_attributes(dev, class->dev_bin_attrs);
+               device_remove_groups(dev, class->dev_groups);
        }
 }
 
@@ -1667,34 +1674,11 @@ static void device_create_release(struct device *dev)
        kfree(dev);
 }
 
-/**
- * device_create_vargs - creates a device and registers it with sysfs
- * @class: pointer to the struct class that this device should be registered to
- * @parent: pointer to the parent struct device of this new device, if any
- * @devt: the dev_t for the char device to be added
- * @drvdata: the data to be added to the device for callbacks
- * @fmt: string for the device's name
- * @args: va_list for the device's name
- *
- * This function can be used by char device classes.  A struct device
- * will be created in sysfs, registered to the specified class.
- *
- * A "dev" file will be created, showing the dev_t for the device, if
- * the dev_t is not 0,0.
- * If a pointer to a parent struct device is passed in, the newly created
- * struct device will be a child of that device in sysfs.
- * The pointer to the struct device will be returned from the call.
- * Any further sysfs files that might be required can be created using this
- * pointer.
- *
- * Returns &struct device pointer on success, or ERR_PTR() on error.
- *
- * Note: the struct class passed to this function must have previously
- * been created with a call to class_create().
- */
-struct device *device_create_vargs(struct class *class, struct device *parent,
-                                  dev_t devt, void *drvdata, const char *fmt,
-                                  va_list args)
+static struct device *
+device_create_groups_vargs(struct class *class, struct device *parent,
+                          dev_t devt, void *drvdata,
+                          const struct attribute_group **groups,
+                          const char *fmt, va_list args)
 {
        struct device *dev = NULL;
        int retval = -ENODEV;
@@ -1711,6 +1695,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
        dev->devt = devt;
        dev->class = class;
        dev->parent = parent;
+       dev->groups = groups;
        dev->release = device_create_release;
        dev_set_drvdata(dev, drvdata);
 
@@ -1728,6 +1713,39 @@ error:
        put_device(dev);
        return ERR_PTR(retval);
 }
+
+/**
+ * device_create_vargs - creates a device and registers it with sysfs
+ * @class: pointer to the struct class that this device should be registered to
+ * @parent: pointer to the parent struct device of this new device, if any
+ * @devt: the dev_t for the char device to be added
+ * @drvdata: the data to be added to the device for callbacks
+ * @fmt: string for the device's name
+ * @args: va_list for the device's name
+ *
+ * This function can be used by char device classes.  A struct device
+ * will be created in sysfs, registered to the specified class.
+ *
+ * A "dev" file will be created, showing the dev_t for the device, if
+ * the dev_t is not 0,0.
+ * If a pointer to a parent struct device is passed in, the newly created
+ * struct device will be a child of that device in sysfs.
+ * The pointer to the struct device will be returned from the call.
+ * Any further sysfs files that might be required can be created using this
+ * pointer.
+ *
+ * Returns &struct device pointer on success, or ERR_PTR() on error.
+ *
+ * Note: the struct class passed to this function must have previously
+ * been created with a call to class_create().
+ */
+struct device *device_create_vargs(struct class *class, struct device *parent,
+                                  dev_t devt, void *drvdata, const char *fmt,
+                                  va_list args)
+{
+       return device_create_groups_vargs(class, parent, devt, drvdata, NULL,
+                                         fmt, args);
+}
 EXPORT_SYMBOL_GPL(device_create_vargs);
 
 /**
@@ -1767,6 +1785,50 @@ struct device *device_create(struct class *class, struct device *parent,
 }
 EXPORT_SYMBOL_GPL(device_create);
 
+/**
+ * device_create_with_groups - creates a device and registers it with sysfs
+ * @class: pointer to the struct class that this device should be registered to
+ * @parent: pointer to the parent struct device of this new device, if any
+ * @devt: the dev_t for the char device to be added
+ * @drvdata: the data to be added to the device for callbacks
+ * @groups: NULL-terminated list of attribute groups to be created
+ * @fmt: string for the device's name
+ *
+ * This function can be used by char device classes.  A struct device
+ * will be created in sysfs, registered to the specified class.
+ * Additional attributes specified in the groups parameter will also
+ * be created automatically.
+ *
+ * A "dev" file will be created, showing the dev_t for the device, if
+ * the dev_t is not 0,0.
+ * If a pointer to a parent struct device is passed in, the newly created
+ * struct device will be a child of that device in sysfs.
+ * The pointer to the struct device will be returned from the call.
+ * Any further sysfs files that might be required can be created using this
+ * pointer.
+ *
+ * Returns &struct device pointer on success, or ERR_PTR() on error.
+ *
+ * Note: the struct class passed to this function must have previously
+ * been created with a call to class_create().
+ */
+struct device *device_create_with_groups(struct class *class,
+                                        struct device *parent, dev_t devt,
+                                        void *drvdata,
+                                        const struct attribute_group **groups,
+                                        const char *fmt, ...)
+{
+       va_list vargs;
+       struct device *dev;
+
+       va_start(vargs, fmt);
+       dev = device_create_groups_vargs(class, parent, devt, drvdata, groups,
+                                        fmt, vargs);
+       va_end(vargs);
+       return dev;
+}
+EXPORT_SYMBOL_GPL(device_create_with_groups);
+
 static int __match_devt(struct device *dev, const void *data)
 {
        const dev_t *devt = data;
index a16d20e389f0f2fead522d97edee5f3c66bc9112..4c358bc44c72b1082d5576ed2ba6a93415b00563 100644 (file)
@@ -278,7 +278,7 @@ static void cpu_device_release(struct device *dev)
  *
  * Initialize and register the CPU device.
  */
-int __cpuinit register_cpu(struct cpu *cpu, int num)
+int register_cpu(struct cpu *cpu, int num)
 {
        int error;
 
index 15789875128e87668a5693712adc5ecbaf45b77c..3c3197a8de41699dcde5164ba7a11ffff870304f 100644 (file)
@@ -522,6 +522,7 @@ static void platform_drv_shutdown(struct device *_dev)
 /**
  * __platform_driver_register - register a driver for platform-level devices
  * @drv: platform driver structure
+ * @owner: owning module/driver
  */
 int __platform_driver_register(struct platform_driver *drv,
                                struct module *owner)
index e69102696533e7224b74a1237f64c478eeb2ab18..3455f833e473c8a053898c4e96e540612dd1d10e 100644 (file)
@@ -719,7 +719,8 @@ static int regcache_sync_block_raw(struct regmap *map, void *block,
                }
        }
 
-       return regcache_sync_block_raw_flush(map, &data, base, regtmp);
+       return regcache_sync_block_raw_flush(map, &data, base, regtmp +
+                       map->reg_stride);
 }
 
 int regcache_sync_block(struct regmap *map, void *block,
index 95920583e31e6dfb5cd0ad18cd9a599e9e34e155..e0d0c7d8a5c527867fb4ba05f4f21e74c43fcff2 100644 (file)
@@ -1853,7 +1853,7 @@ int regmap_async_complete(struct regmap *map)
        int ret;
 
        /* Nothing to do with no async support */
-       if (!map->bus->async_write)
+       if (!map->bus || !map->bus->async_write)
                return 0;
 
        trace_regmap_async_complete_start(map->dev);
index ae989c57cd5ec33cd1564ee949e0fab51b158b4a..2f5919ed91aba9f4d025c7f899b2da78ff2bc625 100644 (file)
@@ -143,22 +143,22 @@ static struct attribute_group topology_attr_group = {
 };
 
 /* Add/Remove cpu_topology interface for CPU device */
-static int __cpuinit topology_add_dev(unsigned int cpu)
+static int topology_add_dev(unsigned int cpu)
 {
        struct device *dev = get_cpu_device(cpu);
 
        return sysfs_create_group(&dev->kobj, &topology_attr_group);
 }
 
-static void __cpuinit topology_remove_dev(unsigned int cpu)
+static void topology_remove_dev(unsigned int cpu)
 {
        struct device *dev = get_cpu_device(cpu);
 
        sysfs_remove_group(&dev->kobj, &topology_attr_group);
 }
 
-static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
-                                          unsigned long action, void *hcpu)
+static int topology_cpu_callback(struct notifier_block *nfb,
+                                unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
        int rc = 0;
@@ -178,7 +178,7 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
        return notifier_from_errno(rc);
 }
 
-static int __cpuinit topology_sysfs_init(void)
+static int topology_sysfs_init(void)
 {
        int cpu;
        int rc;
index b81ddfea1da075ad3c1d0cbeb9ab7bf854593436..e07a5fd58ad7463f8775f7334fd692c7e51df2ad 100644 (file)
@@ -532,11 +532,11 @@ config BLK_DEV_RBD
          If unsure, say N.
 
 config BLK_DEV_RSXX
-       tristate "IBM FlashSystem 70/80 PCIe SSD Device Driver"
+       tristate "IBM Flash Adapter 900GB Full Height PCIe Device Driver"
        depends on PCI
        help
          Device driver for IBM's high speed PCIe SSD
-         storage devices: FlashSystem-70 and FlashSystem-80.
+         storage device: Flash Adapter 900GB Full Height.
 
          To compile this driver as a module, choose M here: the
          module will be called rsxx.
index 99cb944a002dc4dfd5f2010a6f2de9d75c09ebc8..4d45dba7fb8f9f1c6e97d8fa4192ff4e63d6230d 100644 (file)
@@ -906,16 +906,10 @@ bio_pageinc(struct bio *bio)
        int i;
 
        bio_for_each_segment(bv, bio, i) {
-               page = bv->bv_page;
                /* Non-zero page count for non-head members of
-                * compound pages is no longer allowed by the kernel,
-                * but this has never been seen here.
+                * compound pages is no longer allowed by the kernel.
                 */
-               if (unlikely(PageCompound(page)))
-                       if (compound_trans_head(page) != page) {
-                               pr_crit("page tail used for block I/O\n");
-                               BUG();
-                       }
+               page = compound_trans_head(bv->bv_page);
                atomic_inc(&page->_count);
        }
 }
@@ -924,10 +918,13 @@ static void
 bio_pagedec(struct bio *bio)
 {
        struct bio_vec *bv;
+       struct page *page;
        int i;
 
-       bio_for_each_segment(bv, bio, i)
-               atomic_dec(&bv->bv_page->_count);
+       bio_for_each_segment(bv, bio, i) {
+               page = compound_trans_head(bv->bv_page);
+               atomic_dec(&page->_count);
+       }
 }
 
 static void
index 6608076dc39e73cda5f3aaf705579e3189421e3e..28c73ca320a8f7f9b1741492785fa2f18e042d8c 100644 (file)
@@ -659,6 +659,27 @@ void drbd_al_shrink(struct drbd_conf *mdev)
        wake_up(&mdev->al_wait);
 }
 
+int drbd_initialize_al(struct drbd_conf *mdev, void *buffer)
+{
+       struct al_transaction_on_disk *al = buffer;
+       struct drbd_md *md = &mdev->ldev->md;
+       sector_t al_base = md->md_offset + md->al_offset;
+       int al_size_4k = md->al_stripes * md->al_stripe_size_4k;
+       int i;
+
+       memset(al, 0, 4096);
+       al->magic = cpu_to_be32(DRBD_AL_MAGIC);
+       al->transaction_type = cpu_to_be16(AL_TR_INITIALIZED);
+       al->crc32c = cpu_to_be32(crc32c(0, al, 4096));
+
+       for (i = 0; i < al_size_4k; i++) {
+               int err = drbd_md_sync_page_io(mdev, mdev->ldev, al_base + i * 8, WRITE);
+               if (err)
+                       return err;
+       }
+       return 0;
+}
+
 static int w_update_odbm(struct drbd_work *w, int unused)
 {
        struct update_odbm_work *udw = container_of(w, struct update_odbm_work, w);
index f943aacfdad8a90aa07416d905fa2a0bb207b665..2d7f608d181ce8cf2eb26ab3859dcccb0ec38474 100644 (file)
@@ -832,6 +832,7 @@ struct drbd_tconn {                 /* is a resource from the config file */
        unsigned susp_nod:1;            /* IO suspended because no data */
        unsigned susp_fen:1;            /* IO suspended because fence peer handler runs */
        struct mutex cstate_mutex;      /* Protects graceful disconnects */
+       unsigned int connect_cnt;       /* Inc each time a connection is established */
 
        unsigned long flags;
        struct net_conf *net_conf;      /* content protected by rcu */
@@ -1132,6 +1133,7 @@ extern void drbd_mdev_cleanup(struct drbd_conf *mdev);
 void drbd_print_uuids(struct drbd_conf *mdev, const char *text);
 
 extern void conn_md_sync(struct drbd_tconn *tconn);
+extern void drbd_md_write(struct drbd_conf *mdev, void *buffer);
 extern void drbd_md_sync(struct drbd_conf *mdev);
 extern int  drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev);
 extern void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local);
@@ -1466,8 +1468,16 @@ extern void drbd_suspend_io(struct drbd_conf *mdev);
 extern void drbd_resume_io(struct drbd_conf *mdev);
 extern char *ppsize(char *buf, unsigned long long size);
 extern sector_t drbd_new_dev_size(struct drbd_conf *, struct drbd_backing_dev *, sector_t, int);
-enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew = 2 };
-extern enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local);
+enum determine_dev_size {
+       DS_ERROR_SHRINK = -3,
+       DS_ERROR_SPACE_MD = -2,
+       DS_ERROR = -1,
+       DS_UNCHANGED = 0,
+       DS_SHRUNK = 1,
+       DS_GREW = 2
+};
+extern enum determine_dev_size
+drbd_determine_dev_size(struct drbd_conf *, enum dds_flags, struct resize_parms *) __must_hold(local);
 extern void resync_after_online_grow(struct drbd_conf *);
 extern void drbd_reconsider_max_bio_size(struct drbd_conf *mdev);
 extern enum drbd_state_rv drbd_set_role(struct drbd_conf *mdev,
@@ -1633,6 +1643,7 @@ extern int __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector,
 #define drbd_set_out_of_sync(mdev, sector, size) \
        __drbd_set_out_of_sync(mdev, sector, size, __FILE__, __LINE__)
 extern void drbd_al_shrink(struct drbd_conf *mdev);
+extern int drbd_initialize_al(struct drbd_conf *, void *);
 
 /* drbd_nl.c */
 /* state info broadcast */
index a5dca6affcbb894dc2c5d97c63c84f8972503d4e..55635edf563be741d56cccda715ab70ff23248a4 100644 (file)
@@ -2762,8 +2762,6 @@ int __init drbd_init(void)
        /*
         * allocate all necessary structs
         */
-       err = -ENOMEM;
-
        init_waitqueue_head(&drbd_pp_wait);
 
        drbd_proc = NULL; /* play safe for drbd_cleanup */
@@ -2773,6 +2771,7 @@ int __init drbd_init(void)
        if (err)
                goto fail;
 
+       err = -ENOMEM;
        drbd_proc = proc_create_data("drbd", S_IFREG | S_IRUGO , NULL, &drbd_proc_fops, NULL);
        if (!drbd_proc) {
                printk(KERN_ERR "drbd: unable to register proc file\n");
@@ -2803,7 +2802,6 @@ int __init drbd_init(void)
 fail:
        drbd_cleanup();
        if (err == -ENOMEM)
-               /* currently always the case */
                printk(KERN_ERR "drbd: ran out of memory\n");
        else
                printk(KERN_ERR "drbd: initialization failure\n");
@@ -2881,34 +2879,14 @@ struct meta_data_on_disk {
        u8 reserved_u8[4096 - (7*8 + 10*4)];
 } __packed;
 
-/**
- * drbd_md_sync() - Writes the meta data super block if the MD_DIRTY flag bit is set
- * @mdev:      DRBD device.
- */
-void drbd_md_sync(struct drbd_conf *mdev)
+
+
+void drbd_md_write(struct drbd_conf *mdev, void *b)
 {
-       struct meta_data_on_disk *buffer;
+       struct meta_data_on_disk *buffer = b;
        sector_t sector;
        int i;
 
-       /* Don't accidentally change the DRBD meta data layout. */
-       BUILD_BUG_ON(UI_SIZE != 4);
-       BUILD_BUG_ON(sizeof(struct meta_data_on_disk) != 4096);
-
-       del_timer(&mdev->md_sync_timer);
-       /* timer may be rearmed by drbd_md_mark_dirty() now. */
-       if (!test_and_clear_bit(MD_DIRTY, &mdev->flags))
-               return;
-
-       /* We use here D_FAILED and not D_ATTACHING because we try to write
-        * metadata even if we detach due to a disk failure! */
-       if (!get_ldev_if_state(mdev, D_FAILED))
-               return;
-
-       buffer = drbd_md_get_buffer(mdev);
-       if (!buffer)
-               goto out;
-
        memset(buffer, 0, sizeof(*buffer));
 
        buffer->la_size_sect = cpu_to_be64(drbd_get_capacity(mdev->this_bdev));
@@ -2937,6 +2915,35 @@ void drbd_md_sync(struct drbd_conf *mdev)
                dev_err(DEV, "meta data update failed!\n");
                drbd_chk_io_error(mdev, 1, DRBD_META_IO_ERROR);
        }
+}
+
+/**
+ * drbd_md_sync() - Writes the meta data super block if the MD_DIRTY flag bit is set
+ * @mdev:      DRBD device.
+ */
+void drbd_md_sync(struct drbd_conf *mdev)
+{
+       struct meta_data_on_disk *buffer;
+
+       /* Don't accidentally change the DRBD meta data layout. */
+       BUILD_BUG_ON(UI_SIZE != 4);
+       BUILD_BUG_ON(sizeof(struct meta_data_on_disk) != 4096);
+
+       del_timer(&mdev->md_sync_timer);
+       /* timer may be rearmed by drbd_md_mark_dirty() now. */
+       if (!test_and_clear_bit(MD_DIRTY, &mdev->flags))
+               return;
+
+       /* We use here D_FAILED and not D_ATTACHING because we try to write
+        * metadata even if we detach due to a disk failure! */
+       if (!get_ldev_if_state(mdev, D_FAILED))
+               return;
+
+       buffer = drbd_md_get_buffer(mdev);
+       if (!buffer)
+               goto out;
+
+       drbd_md_write(mdev, buffer);
 
        /* Update mdev->ldev->md.la_size_sect,
         * since we updated it on metadata. */
index 9e3f441e7e8441e83d61273ed0f34f1c309c518b..8cc1e640f485b4620ff39d8f3de915d36a38487e 100644 (file)
@@ -417,6 +417,7 @@ static enum drbd_fencing_p highest_fencing_policy(struct drbd_tconn *tconn)
 
 bool conn_try_outdate_peer(struct drbd_tconn *tconn)
 {
+       unsigned int connect_cnt;
        union drbd_state mask = { };
        union drbd_state val = { };
        enum drbd_fencing_p fp;
@@ -428,6 +429,10 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
                return false;
        }
 
+       spin_lock_irq(&tconn->req_lock);
+       connect_cnt = tconn->connect_cnt;
+       spin_unlock_irq(&tconn->req_lock);
+
        fp = highest_fencing_policy(tconn);
        switch (fp) {
        case FP_NOT_AVAIL:
@@ -492,8 +497,14 @@ bool conn_try_outdate_peer(struct drbd_tconn *tconn)
           here, because we might were able to re-establish the connection in the
           meantime. */
        spin_lock_irq(&tconn->req_lock);
-       if (tconn->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &tconn->flags))
-               _conn_request_state(tconn, mask, val, CS_VERBOSE);
+       if (tconn->cstate < C_WF_REPORT_PARAMS && !test_bit(STATE_SENT, &tconn->flags)) {
+               if (tconn->connect_cnt != connect_cnt)
+                       /* In case the connection was established and droped
+                          while the fence-peer handler was running, ignore it */
+                       conn_info(tconn, "Ignoring fence-peer exit code\n");
+               else
+                       _conn_request_state(tconn, mask, val, CS_VERBOSE);
+       }
        spin_unlock_irq(&tconn->req_lock);
 
        return conn_highest_pdsk(tconn) <= D_OUTDATED;
@@ -816,15 +827,20 @@ void drbd_resume_io(struct drbd_conf *mdev)
  * Returns 0 on success, negative return values indicate errors.
  * You should call drbd_md_sync() after calling this function.
  */
-enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds_flags flags) __must_hold(local)
+enum determine_dev_size
+drbd_determine_dev_size(struct drbd_conf *mdev, enum dds_flags flags, struct resize_parms *rs) __must_hold(local)
 {
        sector_t prev_first_sect, prev_size; /* previous meta location */
        sector_t la_size_sect, u_size;
+       struct drbd_md *md = &mdev->ldev->md;
+       u32 prev_al_stripe_size_4k;
+       u32 prev_al_stripes;
        sector_t size;
        char ppb[10];
+       void *buffer;
 
        int md_moved, la_size_changed;
-       enum determine_dev_size rv = unchanged;
+       enum determine_dev_size rv = DS_UNCHANGED;
 
        /* race:
         * application request passes inc_ap_bio,
@@ -836,6 +852,11 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
         * still lock the act_log to not trigger ASSERTs there.
         */
        drbd_suspend_io(mdev);
+       buffer = drbd_md_get_buffer(mdev); /* Lock meta-data IO */
+       if (!buffer) {
+               drbd_resume_io(mdev);
+               return DS_ERROR;
+       }
 
        /* no wait necessary anymore, actually we could assert that */
        wait_event(mdev->al_wait, lc_try_lock(mdev->act_log));
@@ -844,7 +865,17 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
        prev_size = mdev->ldev->md.md_size_sect;
        la_size_sect = mdev->ldev->md.la_size_sect;
 
-       /* TODO: should only be some assert here, not (re)init... */
+       if (rs) {
+               /* rs is non NULL if we should change the AL layout only */
+
+               prev_al_stripes = md->al_stripes;
+               prev_al_stripe_size_4k = md->al_stripe_size_4k;
+
+               md->al_stripes = rs->al_stripes;
+               md->al_stripe_size_4k = rs->al_stripe_size / 4;
+               md->al_size_4k = (u64)rs->al_stripes * rs->al_stripe_size / 4;
+       }
+
        drbd_md_set_sector_offsets(mdev, mdev->ldev);
 
        rcu_read_lock();
@@ -852,6 +883,21 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
        rcu_read_unlock();
        size = drbd_new_dev_size(mdev, mdev->ldev, u_size, flags & DDSF_FORCED);
 
+       if (size < la_size_sect) {
+               if (rs && u_size == 0) {
+                       /* Remove "rs &&" later. This check should always be active, but
+                          right now the receiver expects the permissive behavior */
+                       dev_warn(DEV, "Implicit shrink not allowed. "
+                                "Use --size=%llus for explicit shrink.\n",
+                                (unsigned long long)size);
+                       rv = DS_ERROR_SHRINK;
+               }
+               if (u_size > size)
+                       rv = DS_ERROR_SPACE_MD;
+               if (rv != DS_UNCHANGED)
+                       goto err_out;
+       }
+
        if (drbd_get_capacity(mdev->this_bdev) != size ||
            drbd_bm_capacity(mdev) != size) {
                int err;
@@ -867,7 +913,7 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
                                    "Leaving size unchanged at size = %lu KB\n",
                                    (unsigned long)size);
                        }
-                       rv = dev_size_error;
+                       rv = DS_ERROR;
                }
                /* racy, see comments above. */
                drbd_set_my_capacity(mdev, size);
@@ -875,38 +921,57 @@ enum determine_dev_size drbd_determine_dev_size(struct drbd_conf *mdev, enum dds
                dev_info(DEV, "size = %s (%llu KB)\n", ppsize(ppb, size>>1),
                     (unsigned long long)size>>1);
        }
-       if (rv == dev_size_error)
-               goto out;
+       if (rv <= DS_ERROR)
+               goto err_out;
 
        la_size_changed = (la_size_sect != mdev->ldev->md.la_size_sect);
 
        md_moved = prev_first_sect != drbd_md_first_sector(mdev->ldev)
                || prev_size       != mdev->ldev->md.md_size_sect;
 
-       if (la_size_changed || md_moved) {
-               int err;
+       if (la_size_changed || md_moved || rs) {
+               u32 prev_flags;
 
                drbd_al_shrink(mdev); /* All extents inactive. */
+
+               prev_flags = md->flags;
+               md->flags &= ~MDF_PRIMARY_IND;
+               drbd_md_write(mdev, buffer);
+
                dev_info(DEV, "Writing the whole bitmap, %s\n",
                         la_size_changed && md_moved ? "size changed and md moved" :
                         la_size_changed ? "size changed" : "md moved");
                /* next line implicitly does drbd_suspend_io()+drbd_resume_io() */
-               err = drbd_bitmap_io(mdev, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
-                                    "size changed", BM_LOCKED_MASK);
-               if (err) {
-                       rv = dev_size_error;
-                       goto out;
-               }
-               drbd_md_mark_dirty(mdev);
+               drbd_bitmap_io(mdev, md_moved ? &drbd_bm_write_all : &drbd_bm_write,
+                              "size changed", BM_LOCKED_MASK);
+               drbd_initialize_al(mdev, buffer);
+
+               md->flags = prev_flags;
+               drbd_md_write(mdev, buffer);
+
+               if (rs)
+                       dev_info(DEV, "Changed AL layout to al-stripes = %d, al-stripe-size-kB = %d\n",
+                                md->al_stripes, md->al_stripe_size_4k * 4);
        }
 
        if (size > la_size_sect)
-               rv = grew;
+               rv = DS_GREW;
        if (size < la_size_sect)
-               rv = shrunk;
-out:
+               rv = DS_SHRUNK;
+
+       if (0) {
+       err_out:
+               if (rs) {
+                       md->al_stripes = prev_al_stripes;
+                       md->al_stripe_size_4k = prev_al_stripe_size_4k;
+                       md->al_size_4k = (u64)prev_al_stripes * prev_al_stripe_size_4k;
+
+                       drbd_md_set_sector_offsets(mdev, mdev->ldev);
+               }
+       }
        lc_unlock(mdev->act_log);
        wake_up(&mdev->al_wait);
+       drbd_md_put_buffer(mdev);
        drbd_resume_io(mdev);
 
        return rv;
@@ -1607,11 +1672,11 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info)
            !drbd_md_test_flag(mdev->ldev, MDF_CONNECTED_IND))
                set_bit(USE_DEGR_WFC_T, &mdev->flags);
 
-       dd = drbd_determine_dev_size(mdev, 0);
-       if (dd == dev_size_error) {
+       dd = drbd_determine_dev_size(mdev, 0, NULL);
+       if (dd <= DS_ERROR) {
                retcode = ERR_NOMEM_BITMAP;
                goto force_diskless_dec;
-       } else if (dd == grew)
+       } else if (dd == DS_GREW)
                set_bit(RESYNC_AFTER_NEG, &mdev->flags);
 
        if (drbd_md_test_flag(mdev->ldev, MDF_FULL_SYNC) ||
@@ -2305,6 +2370,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
        struct drbd_conf *mdev;
        enum drbd_ret_code retcode;
        enum determine_dev_size dd;
+       bool change_al_layout = false;
        enum dds_flags ddsf;
        sector_t u_size;
        int err;
@@ -2315,31 +2381,33 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
        if (retcode != NO_ERROR)
                goto fail;
 
+       mdev = adm_ctx.mdev;
+       if (!get_ldev(mdev)) {
+               retcode = ERR_NO_DISK;
+               goto fail;
+       }
+
        memset(&rs, 0, sizeof(struct resize_parms));
+       rs.al_stripes = mdev->ldev->md.al_stripes;
+       rs.al_stripe_size = mdev->ldev->md.al_stripe_size_4k * 4;
        if (info->attrs[DRBD_NLA_RESIZE_PARMS]) {
                err = resize_parms_from_attrs(&rs, info);
                if (err) {
                        retcode = ERR_MANDATORY_TAG;
                        drbd_msg_put_info(from_attrs_err_to_txt(err));
-                       goto fail;
+                       goto fail_ldev;
                }
        }
 
-       mdev = adm_ctx.mdev;
        if (mdev->state.conn > C_CONNECTED) {
                retcode = ERR_RESIZE_RESYNC;
-               goto fail;
+               goto fail_ldev;
        }
 
        if (mdev->state.role == R_SECONDARY &&
            mdev->state.peer == R_SECONDARY) {
                retcode = ERR_NO_PRIMARY;
-               goto fail;
-       }
-
-       if (!get_ldev(mdev)) {
-               retcode = ERR_NO_DISK;
-               goto fail;
+               goto fail_ldev;
        }
 
        if (rs.no_resync && mdev->tconn->agreed_pro_version < 93) {
@@ -2358,6 +2426,28 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
                }
        }
 
+       if (mdev->ldev->md.al_stripes != rs.al_stripes ||
+           mdev->ldev->md.al_stripe_size_4k != rs.al_stripe_size / 4) {
+               u32 al_size_k = rs.al_stripes * rs.al_stripe_size;
+
+               if (al_size_k > (16 * 1024 * 1024)) {
+                       retcode = ERR_MD_LAYOUT_TOO_BIG;
+                       goto fail_ldev;
+               }
+
+               if (al_size_k < MD_32kB_SECT/2) {
+                       retcode = ERR_MD_LAYOUT_TOO_SMALL;
+                       goto fail_ldev;
+               }
+
+               if (mdev->state.conn != C_CONNECTED) {
+                       retcode = ERR_MD_LAYOUT_CONNECTED;
+                       goto fail_ldev;
+               }
+
+               change_al_layout = true;
+       }
+
        if (mdev->ldev->known_size != drbd_get_capacity(mdev->ldev->backing_bdev))
                mdev->ldev->known_size = drbd_get_capacity(mdev->ldev->backing_bdev);
 
@@ -2373,16 +2463,22 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
        }
 
        ddsf = (rs.resize_force ? DDSF_FORCED : 0) | (rs.no_resync ? DDSF_NO_RESYNC : 0);
-       dd = drbd_determine_dev_size(mdev, ddsf);
+       dd = drbd_determine_dev_size(mdev, ddsf, change_al_layout ? &rs : NULL);
        drbd_md_sync(mdev);
        put_ldev(mdev);
-       if (dd == dev_size_error) {
+       if (dd == DS_ERROR) {
                retcode = ERR_NOMEM_BITMAP;
                goto fail;
+       } else if (dd == DS_ERROR_SPACE_MD) {
+               retcode = ERR_MD_LAYOUT_NO_FIT;
+               goto fail;
+       } else if (dd == DS_ERROR_SHRINK) {
+               retcode = ERR_IMPLICIT_SHRINK;
+               goto fail;
        }
 
        if (mdev->state.conn == C_CONNECTED) {
-               if (dd == grew)
+               if (dd == DS_GREW)
                        set_bit(RESIZE_PENDING, &mdev->flags);
 
                drbd_send_uuids(mdev);
@@ -2658,7 +2754,6 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
                const struct sib_info *sib)
 {
        struct state_info *si = NULL; /* for sizeof(si->member); */
-       struct net_conf *nc;
        struct nlattr *nla;
        int got_ldev;
        int err = 0;
@@ -2688,13 +2783,19 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
                goto nla_put_failure;
 
        rcu_read_lock();
-       if (got_ldev)
-               if (disk_conf_to_skb(skb, rcu_dereference(mdev->ldev->disk_conf), exclude_sensitive))
-                       goto nla_put_failure;
+       if (got_ldev) {
+               struct disk_conf *disk_conf;
 
-       nc = rcu_dereference(mdev->tconn->net_conf);
-       if (nc)
-               err = net_conf_to_skb(skb, nc, exclude_sensitive);
+               disk_conf = rcu_dereference(mdev->ldev->disk_conf);
+               err = disk_conf_to_skb(skb, disk_conf, exclude_sensitive);
+       }
+       if (!err) {
+               struct net_conf *nc;
+
+               nc = rcu_dereference(mdev->tconn->net_conf);
+               if (nc)
+                       err = net_conf_to_skb(skb, nc, exclude_sensitive);
+       }
        rcu_read_unlock();
        if (err)
                goto nla_put_failure;
index 4222affff488bc15c116187e2eb382af5f2d0508..cc29cd3bf78b6a758f85255f56f6cdeca1b2cc4b 100644 (file)
@@ -1039,6 +1039,8 @@ randomize:
        rcu_read_lock();
        idr_for_each_entry(&tconn->volumes, mdev, vnr) {
                kref_get(&mdev->kref);
+               rcu_read_unlock();
+
                /* Prevent a race between resync-handshake and
                 * being promoted to Primary.
                 *
@@ -1049,8 +1051,6 @@ randomize:
                mutex_lock(mdev->state_mutex);
                mutex_unlock(mdev->state_mutex);
 
-               rcu_read_unlock();
-
                if (discard_my_data)
                        set_bit(DISCARD_MY_DATA, &mdev->flags);
                else
@@ -3545,7 +3545,7 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
 {
        struct drbd_conf *mdev;
        struct p_sizes *p = pi->data;
-       enum determine_dev_size dd = unchanged;
+       enum determine_dev_size dd = DS_UNCHANGED;
        sector_t p_size, p_usize, my_usize;
        int ldsc = 0; /* local disk size changed */
        enum dds_flags ddsf;
@@ -3617,9 +3617,9 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
 
        ddsf = be16_to_cpu(p->dds_flags);
        if (get_ldev(mdev)) {
-               dd = drbd_determine_dev_size(mdev, ddsf);
+               dd = drbd_determine_dev_size(mdev, ddsf, NULL);
                put_ldev(mdev);
-               if (dd == dev_size_error)
+               if (dd == DS_ERROR)
                        return -EIO;
                drbd_md_sync(mdev);
        } else {
@@ -3647,7 +3647,7 @@ static int receive_sizes(struct drbd_tconn *tconn, struct packet_info *pi)
                        drbd_send_sizes(mdev, 0, ddsf);
                }
                if (test_and_clear_bit(RESIZE_PENDING, &mdev->flags) ||
-                   (dd == grew && mdev->state.conn == C_CONNECTED)) {
+                   (dd == DS_GREW && mdev->state.conn == C_CONNECTED)) {
                        if (mdev->state.pdsk >= D_INCONSISTENT &&
                            mdev->state.disk >= D_INCONSISTENT) {
                                if (ddsf & DDSF_NO_RESYNC)
index 90c5be2b1d309bf041927891f2f8be24fc491bc1..216d47b7e88b72f59e26ede29a758116adc2f687 100644 (file)
@@ -1115,8 +1115,10 @@ __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns,
                drbd_thread_restart_nowait(&mdev->tconn->receiver);
 
        /* Resume AL writing if we get a connection */
-       if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED)
+       if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) {
                drbd_resume_al(mdev);
+               mdev->tconn->connect_cnt++;
+       }
 
        /* remember last attach time so request_timer_fn() won't
         * kill newly established sessions while we are still trying to thaw
index 5af21f2db29cd1246397e3b4eed8627ba314adf2..6e85e21445eb13896d19f16a58a0107b4f9baa4e 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/slab.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 
 #include <linux/genhd.h>
 #include <linux/idr.h>
@@ -39,8 +41,9 @@
 #include "rsxx_cfg.h"
 
 #define NO_LEGACY 0
+#define SYNC_START_TIMEOUT (10 * 60) /* 10 minutes */
 
-MODULE_DESCRIPTION("IBM FlashSystem 70/80 PCIe SSD Device Driver");
+MODULE_DESCRIPTION("IBM Flash Adapter 900GB Full Height Device Driver");
 MODULE_AUTHOR("Joshua Morris/Philip Kelleher, IBM");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRIVER_VERSION);
@@ -49,9 +52,282 @@ static unsigned int force_legacy = NO_LEGACY;
 module_param(force_legacy, uint, 0444);
 MODULE_PARM_DESC(force_legacy, "Force the use of legacy type PCI interrupts");
 
+static unsigned int sync_start = 1;
+module_param(sync_start, uint, 0444);
+MODULE_PARM_DESC(sync_start, "On by Default: Driver load will not complete "
+                            "until the card startup has completed.");
+
 static DEFINE_IDA(rsxx_disk_ida);
 static DEFINE_SPINLOCK(rsxx_ida_lock);
 
+/* --------------------Debugfs Setup ------------------- */
+
+struct rsxx_cram {
+       u32 f_pos;
+       u32 offset;
+       void *i_private;
+};
+
+static int rsxx_attr_pci_regs_show(struct seq_file *m, void *p)
+{
+       struct rsxx_cardinfo *card = m->private;
+
+       seq_printf(m, "HWID             0x%08x\n",
+                                       ioread32(card->regmap + HWID));
+       seq_printf(m, "SCRATCH          0x%08x\n",
+                                       ioread32(card->regmap + SCRATCH));
+       seq_printf(m, "IER              0x%08x\n",
+                                       ioread32(card->regmap + IER));
+       seq_printf(m, "IPR              0x%08x\n",
+                                       ioread32(card->regmap + IPR));
+       seq_printf(m, "CREG_CMD         0x%08x\n",
+                                       ioread32(card->regmap + CREG_CMD));
+       seq_printf(m, "CREG_ADD         0x%08x\n",
+                                       ioread32(card->regmap + CREG_ADD));
+       seq_printf(m, "CREG_CNT         0x%08x\n",
+                                       ioread32(card->regmap + CREG_CNT));
+       seq_printf(m, "CREG_STAT        0x%08x\n",
+                                       ioread32(card->regmap + CREG_STAT));
+       seq_printf(m, "CREG_DATA0       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA0));
+       seq_printf(m, "CREG_DATA1       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA1));
+       seq_printf(m, "CREG_DATA2       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA2));
+       seq_printf(m, "CREG_DATA3       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA3));
+       seq_printf(m, "CREG_DATA4       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA4));
+       seq_printf(m, "CREG_DATA5       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA5));
+       seq_printf(m, "CREG_DATA6       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA6));
+       seq_printf(m, "CREG_DATA7       0x%08x\n",
+                                       ioread32(card->regmap + CREG_DATA7));
+       seq_printf(m, "INTR_COAL        0x%08x\n",
+                                       ioread32(card->regmap + INTR_COAL));
+       seq_printf(m, "HW_ERROR         0x%08x\n",
+                                       ioread32(card->regmap + HW_ERROR));
+       seq_printf(m, "DEBUG0           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG0));
+       seq_printf(m, "DEBUG1           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG1));
+       seq_printf(m, "DEBUG2           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG2));
+       seq_printf(m, "DEBUG3           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG3));
+       seq_printf(m, "DEBUG4           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG4));
+       seq_printf(m, "DEBUG5           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG5));
+       seq_printf(m, "DEBUG6           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG6));
+       seq_printf(m, "DEBUG7           0x%08x\n",
+                                       ioread32(card->regmap + PCI_DEBUG7));
+       seq_printf(m, "RECONFIG         0x%08x\n",
+                                       ioread32(card->regmap + PCI_RECONFIG));
+
+       return 0;
+}
+
+static int rsxx_attr_stats_show(struct seq_file *m, void *p)
+{
+       struct rsxx_cardinfo *card = m->private;
+       int i;
+
+       for (i = 0; i < card->n_targets; i++) {
+               seq_printf(m, "Ctrl %d CRC Errors       = %d\n",
+                               i, card->ctrl[i].stats.crc_errors);
+               seq_printf(m, "Ctrl %d Hard Errors      = %d\n",
+                               i, card->ctrl[i].stats.hard_errors);
+               seq_printf(m, "Ctrl %d Soft Errors      = %d\n",
+                               i, card->ctrl[i].stats.soft_errors);
+               seq_printf(m, "Ctrl %d Writes Issued    = %d\n",
+                               i, card->ctrl[i].stats.writes_issued);
+               seq_printf(m, "Ctrl %d Writes Failed    = %d\n",
+                               i, card->ctrl[i].stats.writes_failed);
+               seq_printf(m, "Ctrl %d Reads Issued     = %d\n",
+                               i, card->ctrl[i].stats.reads_issued);
+               seq_printf(m, "Ctrl %d Reads Failed     = %d\n",
+                               i, card->ctrl[i].stats.reads_failed);
+               seq_printf(m, "Ctrl %d Reads Retried    = %d\n",
+                               i, card->ctrl[i].stats.reads_retried);
+               seq_printf(m, "Ctrl %d Discards Issued  = %d\n",
+                               i, card->ctrl[i].stats.discards_issued);
+               seq_printf(m, "Ctrl %d Discards Failed  = %d\n",
+                               i, card->ctrl[i].stats.discards_failed);
+               seq_printf(m, "Ctrl %d DMA SW Errors    = %d\n",
+                               i, card->ctrl[i].stats.dma_sw_err);
+               seq_printf(m, "Ctrl %d DMA HW Faults    = %d\n",
+                               i, card->ctrl[i].stats.dma_hw_fault);
+               seq_printf(m, "Ctrl %d DMAs Cancelled   = %d\n",
+                               i, card->ctrl[i].stats.dma_cancelled);
+               seq_printf(m, "Ctrl %d SW Queue Depth   = %d\n",
+                               i, card->ctrl[i].stats.sw_q_depth);
+               seq_printf(m, "Ctrl %d HW Queue Depth   = %d\n",
+                       i, atomic_read(&card->ctrl[i].stats.hw_q_depth));
+       }
+
+       return 0;
+}
+
+static int rsxx_attr_stats_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, rsxx_attr_stats_show, inode->i_private);
+}
+
+static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, rsxx_attr_pci_regs_show, inode->i_private);
+}
+
+static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
+                             size_t cnt, loff_t *ppos)
+{
+       struct rsxx_cram *info = fp->private_data;
+       struct rsxx_cardinfo *card = info->i_private;
+       char *buf;
+       int st;
+
+       buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
+       info->f_pos = (u32)*ppos + info->offset;
+
+       st = rsxx_creg_read(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
+       if (st)
+               return st;
+
+       st = copy_to_user(ubuf, buf, cnt);
+       if (st)
+               return st;
+
+       info->offset += cnt;
+
+       kfree(buf);
+
+       return cnt;
+}
+
+static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
+                              size_t cnt, loff_t *ppos)
+{
+       struct rsxx_cram *info = fp->private_data;
+       struct rsxx_cardinfo *card = info->i_private;
+       char *buf;
+       int st;
+
+       buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
+       st = copy_from_user(buf, ubuf, cnt);
+       if (st)
+               return st;
+
+       info->f_pos = (u32)*ppos + info->offset;
+
+       st = rsxx_creg_write(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
+       if (st)
+               return st;
+
+       info->offset += cnt;
+
+       kfree(buf);
+
+       return cnt;
+}
+
+static int rsxx_cram_open(struct inode *inode, struct file *file)
+{
+       struct rsxx_cram *info = kzalloc(sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
+       info->i_private = inode->i_private;
+       info->f_pos = file->f_pos;
+       file->private_data = info;
+
+       return 0;
+}
+
+static int rsxx_cram_release(struct inode *inode, struct file *file)
+{
+       struct rsxx_cram *info = file->private_data;
+
+       if (!info)
+               return 0;
+
+       kfree(info);
+       file->private_data = NULL;
+
+       return 0;
+}
+
+static const struct file_operations debugfs_cram_fops = {
+       .owner          = THIS_MODULE,
+       .open           = rsxx_cram_open,
+       .read           = rsxx_cram_read,
+       .write          = rsxx_cram_write,
+       .release        = rsxx_cram_release,
+};
+
+static const struct file_operations debugfs_stats_fops = {
+       .owner          = THIS_MODULE,
+       .open           = rsxx_attr_stats_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static const struct file_operations debugfs_pci_regs_fops = {
+       .owner          = THIS_MODULE,
+       .open           = rsxx_attr_pci_regs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card)
+{
+       struct dentry *debugfs_stats;
+       struct dentry *debugfs_pci_regs;
+       struct dentry *debugfs_cram;
+
+       card->debugfs_dir = debugfs_create_dir(card->gendisk->disk_name, NULL);
+       if (IS_ERR_OR_NULL(card->debugfs_dir))
+               goto failed_debugfs_dir;
+
+       debugfs_stats = debugfs_create_file("stats", S_IRUGO,
+                                           card->debugfs_dir, card,
+                                           &debugfs_stats_fops);
+       if (IS_ERR_OR_NULL(debugfs_stats))
+               goto failed_debugfs_stats;
+
+       debugfs_pci_regs = debugfs_create_file("pci_regs", S_IRUGO,
+                                              card->debugfs_dir, card,
+                                              &debugfs_pci_regs_fops);
+       if (IS_ERR_OR_NULL(debugfs_pci_regs))
+               goto failed_debugfs_pci_regs;
+
+       debugfs_cram = debugfs_create_file("cram", S_IRUGO | S_IWUSR,
+                                          card->debugfs_dir, card,
+                                          &debugfs_cram_fops);
+       if (IS_ERR_OR_NULL(debugfs_cram))
+               goto failed_debugfs_cram;
+
+       return;
+failed_debugfs_cram:
+       debugfs_remove(debugfs_pci_regs);
+failed_debugfs_pci_regs:
+       debugfs_remove(debugfs_stats);
+failed_debugfs_stats:
+       debugfs_remove(card->debugfs_dir);
+failed_debugfs_dir:
+       card->debugfs_dir = NULL;
+}
+
 /*----------------- Interrupt Control & Handling -------------------*/
 
 static void rsxx_mask_interrupts(struct rsxx_cardinfo *card)
@@ -163,12 +439,13 @@ static irqreturn_t rsxx_isr(int irq, void *pdata)
                }
 
                if (isr & CR_INTR_CREG) {
-                       schedule_work(&card->creg_ctrl.done_work);
+                       queue_work(card->creg_ctrl.creg_wq,
+                                  &card->creg_ctrl.done_work);
                        handled++;
                }
 
                if (isr & CR_INTR_EVENT) {
-                       schedule_work(&card->event_work);
+                       queue_work(card->event_wq, &card->event_work);
                        rsxx_disable_ier_and_isr(card, CR_INTR_EVENT);
                        handled++;
                }
@@ -329,7 +606,7 @@ static int rsxx_eeh_frozen(struct pci_dev *dev)
        int i;
        int st;
 
-       dev_warn(&dev->dev, "IBM FlashSystem PCI: preparing for slot reset.\n");
+       dev_warn(&dev->dev, "IBM Flash Adapter PCI: preparing for slot reset.\n");
 
        card->eeh_state = 1;
        rsxx_mask_interrupts(card);
@@ -367,15 +644,26 @@ static void rsxx_eeh_failure(struct pci_dev *dev)
 {
        struct rsxx_cardinfo *card = pci_get_drvdata(dev);
        int i;
+       int cnt = 0;
 
-       dev_err(&dev->dev, "IBM FlashSystem PCI: disabling failed card.\n");
+       dev_err(&dev->dev, "IBM Flash Adapter PCI: disabling failed card.\n");
 
        card->eeh_state = 1;
+       card->halt = 1;
 
-       for (i = 0; i < card->n_targets; i++)
-               del_timer_sync(&card->ctrl[i].activity_timer);
+       for (i = 0; i < card->n_targets; i++) {
+               spin_lock_bh(&card->ctrl[i].queue_lock);
+               cnt = rsxx_cleanup_dma_queue(&card->ctrl[i],
+                                            &card->ctrl[i].queue);
+               spin_unlock_bh(&card->ctrl[i].queue_lock);
+
+               cnt += rsxx_dma_cancel(&card->ctrl[i]);
 
-       rsxx_eeh_cancel_dmas(card);
+               if (cnt)
+                       dev_info(CARD_TO_DEV(card),
+                               "Freed %d queued DMAs on channel %d\n",
+                               cnt, card->ctrl[i].id);
+       }
 }
 
 static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card)
@@ -432,7 +720,7 @@ static pci_ers_result_t rsxx_slot_reset(struct pci_dev *dev)
        int st;
 
        dev_warn(&dev->dev,
-               "IBM FlashSystem PCI: recovering from slot reset.\n");
+               "IBM Flash Adapter PCI: recovering from slot reset.\n");
 
        st = pci_enable_device(dev);
        if (st)
@@ -485,7 +773,7 @@ static pci_ers_result_t rsxx_slot_reset(struct pci_dev *dev)
                                &card->ctrl[i].issue_dma_work);
        }
 
-       dev_info(&dev->dev, "IBM FlashSystem PCI: recovery complete.\n");
+       dev_info(&dev->dev, "IBM Flash Adapter PCI: recovery complete.\n");
 
        return PCI_ERS_RESULT_RECOVERED;
 
@@ -528,6 +816,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
 {
        struct rsxx_cardinfo *card;
        int st;
+       unsigned int sync_timeout;
 
        dev_info(&dev->dev, "PCI-Flash SSD discovered\n");
 
@@ -610,7 +899,11 @@ static int rsxx_pci_probe(struct pci_dev *dev,
        }
 
        /************* Setup Processor Command Interface *************/
-       rsxx_creg_setup(card);
+       st = rsxx_creg_setup(card);
+       if (st) {
+               dev_err(CARD_TO_DEV(card), "Failed to setup creg interface.\n");
+               goto failed_creg_setup;
+       }
 
        spin_lock_irq(&card->irq_lock);
        rsxx_enable_ier_and_isr(card, CR_INTR_CREG);
@@ -650,6 +943,12 @@ static int rsxx_pci_probe(struct pci_dev *dev,
        }
 
        /************* Setup Card Event Handler *************/
+       card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
+       if (!card->event_wq) {
+               dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
+               goto failed_event_handler;
+       }
+
        INIT_WORK(&card->event_work, card_event_handler);
 
        st = rsxx_setup_dev(card);
@@ -676,6 +975,33 @@ static int rsxx_pci_probe(struct pci_dev *dev,
                if (st)
                        dev_crit(CARD_TO_DEV(card),
                                "Failed issuing card startup\n");
+               if (sync_start) {
+                       sync_timeout = SYNC_START_TIMEOUT;
+
+                       dev_info(CARD_TO_DEV(card),
+                                "Waiting for card to startup\n");
+
+                       do {
+                               ssleep(1);
+                               sync_timeout--;
+
+                               rsxx_get_card_state(card, &card->state);
+                       } while (sync_timeout &&
+                               (card->state == CARD_STATE_STARTING));
+
+                       if (card->state == CARD_STATE_STARTING) {
+                               dev_warn(CARD_TO_DEV(card),
+                                        "Card startup timed out\n");
+                               card->size8 = 0;
+                       } else {
+                               dev_info(CARD_TO_DEV(card),
+                                       "card state: %s\n",
+                                       rsxx_card_state_to_str(card->state));
+                               st = rsxx_get_card_size8(card, &card->size8);
+                               if (st)
+                                       card->size8 = 0;
+                       }
+               }
        } else if (card->state == CARD_STATE_GOOD ||
                   card->state == CARD_STATE_RD_ONLY_FAULT) {
                st = rsxx_get_card_size8(card, &card->size8);
@@ -685,12 +1011,21 @@ static int rsxx_pci_probe(struct pci_dev *dev,
 
        rsxx_attach_dev(card);
 
+       /************* Setup Debugfs *************/
+       rsxx_debugfs_dev_new(card);
+
        return 0;
 
 failed_create_dev:
+       destroy_workqueue(card->event_wq);
+       card->event_wq = NULL;
+failed_event_handler:
        rsxx_dma_destroy(card);
 failed_dma_setup:
 failed_compatiblity_check:
+       destroy_workqueue(card->creg_ctrl.creg_wq);
+       card->creg_ctrl.creg_wq = NULL;
+failed_creg_setup:
        spin_lock_irq(&card->irq_lock);
        rsxx_disable_ier_and_isr(card, CR_INTR_ALL);
        spin_unlock_irq(&card->irq_lock);
@@ -756,6 +1091,8 @@ static void rsxx_pci_remove(struct pci_dev *dev)
        /* Prevent work_structs from re-queuing themselves. */
        card->halt = 1;
 
+       debugfs_remove_recursive(card->debugfs_dir);
+
        free_irq(dev->irq, card);
 
        if (!force_legacy)
index 4b5c020a0a65ad8831d75bf3407dd81b2d82b306..926dce9c452faf927d79fb0b99fd1a4e473aea6e 100644 (file)
@@ -431,6 +431,15 @@ static int __issue_creg_rw(struct rsxx_cardinfo *card,
        *hw_stat = completion.creg_status;
 
        if (completion.st) {
+               /*
+               * This read is needed to verify that there has not been any
+               * extreme errors that might have occurred, i.e. EEH. The
+               * function iowrite32 will not detect EEH errors, so it is
+               * necessary that we recover if such an error is the reason
+               * for the timeout. This is a dummy read.
+               */
+               ioread32(card->regmap + SCRATCH);
+
                dev_warn(CARD_TO_DEV(card),
                        "creg command failed(%d x%08x)\n",
                        completion.st, addr);
@@ -727,6 +736,11 @@ int rsxx_creg_setup(struct rsxx_cardinfo *card)
 {
        card->creg_ctrl.active_cmd = NULL;
 
+       card->creg_ctrl.creg_wq =
+                       create_singlethread_workqueue(DRIVER_NAME"_creg");
+       if (!card->creg_ctrl.creg_wq)
+               return -ENOMEM;
+
        INIT_WORK(&card->creg_ctrl.done_work, creg_cmd_done);
        mutex_init(&card->creg_ctrl.reset_lock);
        INIT_LIST_HEAD(&card->creg_ctrl.queue);
index 4346d17d29496b65316db8fc2f1133b9e0d116cd..d7af441880befc1c6aeb7cdd4dbfc128a8014bb8 100644 (file)
@@ -155,7 +155,8 @@ static void bio_dma_done_cb(struct rsxx_cardinfo *card,
                atomic_set(&meta->error, 1);
 
        if (atomic_dec_and_test(&meta->pending_dmas)) {
-               disk_stats_complete(card, meta->bio, meta->start_time);
+               if (!card->eeh_state && card->gendisk)
+                       disk_stats_complete(card, meta->bio, meta->start_time);
 
                bio_endio(meta->bio, atomic_read(&meta->error) ? -EIO : 0);
                kmem_cache_free(bio_meta_pool, meta);
@@ -170,6 +171,12 @@ static void rsxx_make_request(struct request_queue *q, struct bio *bio)
 
        might_sleep();
 
+       if (!card)
+               goto req_err;
+
+       if (bio->bi_sector + (bio->bi_size >> 9) > get_capacity(card->gendisk))
+               goto req_err;
+
        if (unlikely(card->halt)) {
                st = -EFAULT;
                goto req_err;
@@ -196,7 +203,8 @@ static void rsxx_make_request(struct request_queue *q, struct bio *bio)
        atomic_set(&bio_meta->pending_dmas, 0);
        bio_meta->start_time = jiffies;
 
-       disk_stats_start(card, bio);
+       if (!unlikely(card->halt))
+               disk_stats_start(card, bio);
 
        dev_dbg(CARD_TO_DEV(card), "BIO[%c]: meta: %p addr8: x%llx size: %d\n",
                 bio_data_dir(bio) ? 'W' : 'R', bio_meta,
@@ -225,24 +233,6 @@ static bool rsxx_discard_supported(struct rsxx_cardinfo *card)
        return (pci_rev >= RSXX_DISCARD_SUPPORT);
 }
 
-static unsigned short rsxx_get_logical_block_size(
-                                       struct rsxx_cardinfo *card)
-{
-       u32 capabilities = 0;
-       int st;
-
-       st = rsxx_get_card_capabilities(card, &capabilities);
-       if (st)
-               dev_warn(CARD_TO_DEV(card),
-                       "Failed reading card capabilities register\n");
-
-       /* Earlier firmware did not have support for 512 byte accesses */
-       if (capabilities & CARD_CAP_SUBPAGE_WRITES)
-               return 512;
-       else
-               return RSXX_HW_BLK_SIZE;
-}
-
 int rsxx_attach_dev(struct rsxx_cardinfo *card)
 {
        mutex_lock(&card->dev_lock);
@@ -305,7 +295,7 @@ int rsxx_setup_dev(struct rsxx_cardinfo *card)
                return -ENOMEM;
        }
 
-       blk_size = rsxx_get_logical_block_size(card);
+       blk_size = card->config.data.block_size;
 
        blk_queue_make_request(card->queue, rsxx_make_request);
        blk_queue_bounce_limit(card->queue, BLK_BOUNCE_ANY);
@@ -347,6 +337,7 @@ void rsxx_destroy_dev(struct rsxx_cardinfo *card)
        card->gendisk = NULL;
 
        blk_cleanup_queue(card->queue);
+       card->queue->queuedata = NULL;
        unregister_blkdev(card->major, DRIVER_NAME);
 }
 
index 0607513cfb41fa4b2ff88bac32be0665c645a2bb..bed32f16b084bdd46f7b881b32f95775effaa499 100644 (file)
@@ -245,6 +245,22 @@ static void rsxx_complete_dma(struct rsxx_dma_ctrl *ctrl,
        kmem_cache_free(rsxx_dma_pool, dma);
 }
 
+int rsxx_cleanup_dma_queue(struct rsxx_dma_ctrl *ctrl,
+                          struct list_head *q)
+{
+       struct rsxx_dma *dma;
+       struct rsxx_dma *tmp;
+       int cnt = 0;
+
+       list_for_each_entry_safe(dma, tmp, q, list) {
+               list_del(&dma->list);
+               rsxx_complete_dma(ctrl, dma, DMA_CANCELLED);
+               cnt++;
+       }
+
+       return cnt;
+}
+
 static void rsxx_requeue_dma(struct rsxx_dma_ctrl *ctrl,
                                 struct rsxx_dma *dma)
 {
@@ -252,9 +268,10 @@ static void rsxx_requeue_dma(struct rsxx_dma_ctrl *ctrl,
         * Requeued DMAs go to the front of the queue so they are issued
         * first.
         */
-       spin_lock(&ctrl->queue_lock);
+       spin_lock_bh(&ctrl->queue_lock);
+       ctrl->stats.sw_q_depth++;
        list_add(&dma->list, &ctrl->queue);
-       spin_unlock(&ctrl->queue_lock);
+       spin_unlock_bh(&ctrl->queue_lock);
 }
 
 static void rsxx_handle_dma_error(struct rsxx_dma_ctrl *ctrl,
@@ -329,6 +346,7 @@ static void rsxx_handle_dma_error(struct rsxx_dma_ctrl *ctrl,
 static void dma_engine_stalled(unsigned long data)
 {
        struct rsxx_dma_ctrl *ctrl = (struct rsxx_dma_ctrl *)data;
+       int cnt;
 
        if (atomic_read(&ctrl->stats.hw_q_depth) == 0 ||
            unlikely(ctrl->card->eeh_state))
@@ -349,18 +367,28 @@ static void dma_engine_stalled(unsigned long data)
                        "DMA channel %d has stalled, faulting interface.\n",
                        ctrl->id);
                ctrl->card->dma_fault = 1;
+
+               /* Clean up the DMA queue */
+               spin_lock(&ctrl->queue_lock);
+               cnt = rsxx_cleanup_dma_queue(ctrl, &ctrl->queue);
+               spin_unlock(&ctrl->queue_lock);
+
+               cnt += rsxx_dma_cancel(ctrl);
+
+               if (cnt)
+                       dev_info(CARD_TO_DEV(ctrl->card),
+                               "Freed %d queued DMAs on channel %d\n",
+                               cnt, ctrl->id);
        }
 }
 
-static void rsxx_issue_dmas(struct work_struct *work)
+static void rsxx_issue_dmas(struct rsxx_dma_ctrl *ctrl)
 {
-       struct rsxx_dma_ctrl *ctrl;
        struct rsxx_dma *dma;
        int tag;
        int cmds_pending = 0;
        struct hw_cmd *hw_cmd_buf;
 
-       ctrl = container_of(work, struct rsxx_dma_ctrl, issue_dma_work);
        hw_cmd_buf = ctrl->cmd.buf;
 
        if (unlikely(ctrl->card->halt) ||
@@ -368,22 +396,22 @@ static void rsxx_issue_dmas(struct work_struct *work)
                return;
 
        while (1) {
-               spin_lock(&ctrl->queue_lock);
+               spin_lock_bh(&ctrl->queue_lock);
                if (list_empty(&ctrl->queue)) {
-                       spin_unlock(&ctrl->queue_lock);
+                       spin_unlock_bh(&ctrl->queue_lock);
                        break;
                }
-               spin_unlock(&ctrl->queue_lock);
+               spin_unlock_bh(&ctrl->queue_lock);
 
                tag = pop_tracker(ctrl->trackers);
                if (tag == -1)
                        break;
 
-               spin_lock(&ctrl->queue_lock);
+               spin_lock_bh(&ctrl->queue_lock);
                dma = list_entry(ctrl->queue.next, struct rsxx_dma, list);
                list_del(&dma->list);
                ctrl->stats.sw_q_depth--;
-               spin_unlock(&ctrl->queue_lock);
+               spin_unlock_bh(&ctrl->queue_lock);
 
                /*
                 * This will catch any DMAs that slipped in right before the
@@ -440,9 +468,8 @@ static void rsxx_issue_dmas(struct work_struct *work)
        }
 }
 
-static void rsxx_dma_done(struct work_struct *work)
+static void rsxx_dma_done(struct rsxx_dma_ctrl *ctrl)
 {
-       struct rsxx_dma_ctrl *ctrl;
        struct rsxx_dma *dma;
        unsigned long flags;
        u16 count;
@@ -450,7 +477,6 @@ static void rsxx_dma_done(struct work_struct *work)
        u8 tag;
        struct hw_status *hw_st_buf;
 
-       ctrl = container_of(work, struct rsxx_dma_ctrl, dma_done_work);
        hw_st_buf = ctrl->status.buf;
 
        if (unlikely(ctrl->card->halt) ||
@@ -520,33 +546,32 @@ static void rsxx_dma_done(struct work_struct *work)
        rsxx_enable_ier(ctrl->card, CR_INTR_DMA(ctrl->id));
        spin_unlock_irqrestore(&ctrl->card->irq_lock, flags);
 
-       spin_lock(&ctrl->queue_lock);
+       spin_lock_bh(&ctrl->queue_lock);
        if (ctrl->stats.sw_q_depth)
                queue_work(ctrl->issue_wq, &ctrl->issue_dma_work);
-       spin_unlock(&ctrl->queue_lock);
+       spin_unlock_bh(&ctrl->queue_lock);
 }
 
-static int rsxx_cleanup_dma_queue(struct rsxx_cardinfo *card,
-                                     struct list_head *q)
+static void rsxx_schedule_issue(struct work_struct *work)
 {
-       struct rsxx_dma *dma;
-       struct rsxx_dma *tmp;
-       int cnt = 0;
+       struct rsxx_dma_ctrl *ctrl;
 
-       list_for_each_entry_safe(dma, tmp, q, list) {
-               list_del(&dma->list);
+       ctrl = container_of(work, struct rsxx_dma_ctrl, issue_dma_work);
 
-               if (dma->dma_addr)
-                       pci_unmap_page(card->dev, dma->dma_addr,
-                                      get_dma_size(dma),
-                                      (dma->cmd == HW_CMD_BLK_WRITE) ?
-                                      PCI_DMA_TODEVICE :
-                                      PCI_DMA_FROMDEVICE);
-               kmem_cache_free(rsxx_dma_pool, dma);
-               cnt++;
-       }
+       mutex_lock(&ctrl->work_lock);
+       rsxx_issue_dmas(ctrl);
+       mutex_unlock(&ctrl->work_lock);
+}
 
-       return cnt;
+static void rsxx_schedule_done(struct work_struct *work)
+{
+       struct rsxx_dma_ctrl *ctrl;
+
+       ctrl = container_of(work, struct rsxx_dma_ctrl, dma_done_work);
+
+       mutex_lock(&ctrl->work_lock);
+       rsxx_dma_done(ctrl);
+       mutex_unlock(&ctrl->work_lock);
 }
 
 static int rsxx_queue_discard(struct rsxx_cardinfo *card,
@@ -698,10 +723,10 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
 
        for (i = 0; i < card->n_targets; i++) {
                if (!list_empty(&dma_list[i])) {
-                       spin_lock(&card->ctrl[i].queue_lock);
+                       spin_lock_bh(&card->ctrl[i].queue_lock);
                        card->ctrl[i].stats.sw_q_depth += dma_cnt[i];
                        list_splice_tail(&dma_list[i], &card->ctrl[i].queue);
-                       spin_unlock(&card->ctrl[i].queue_lock);
+                       spin_unlock_bh(&card->ctrl[i].queue_lock);
 
                        queue_work(card->ctrl[i].issue_wq,
                                   &card->ctrl[i].issue_dma_work);
@@ -711,8 +736,11 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
        return 0;
 
 bvec_err:
-       for (i = 0; i < card->n_targets; i++)
-               rsxx_cleanup_dma_queue(card, &dma_list[i]);
+       for (i = 0; i < card->n_targets; i++) {
+               spin_lock_bh(&card->ctrl[i].queue_lock);
+               rsxx_cleanup_dma_queue(&card->ctrl[i], &dma_list[i]);
+               spin_unlock_bh(&card->ctrl[i].queue_lock);
+       }
 
        return st;
 }
@@ -780,6 +808,7 @@ static int rsxx_dma_ctrl_init(struct pci_dev *dev,
        spin_lock_init(&ctrl->trackers->lock);
 
        spin_lock_init(&ctrl->queue_lock);
+       mutex_init(&ctrl->work_lock);
        INIT_LIST_HEAD(&ctrl->queue);
 
        setup_timer(&ctrl->activity_timer, dma_engine_stalled,
@@ -793,8 +822,8 @@ static int rsxx_dma_ctrl_init(struct pci_dev *dev,
        if (!ctrl->done_wq)
                return -ENOMEM;
 
-       INIT_WORK(&ctrl->issue_dma_work, rsxx_issue_dmas);
-       INIT_WORK(&ctrl->dma_done_work, rsxx_dma_done);
+       INIT_WORK(&ctrl->issue_dma_work, rsxx_schedule_issue);
+       INIT_WORK(&ctrl->dma_done_work, rsxx_schedule_done);
 
        st = rsxx_hw_buffers_init(dev, ctrl);
        if (st)
@@ -918,13 +947,30 @@ failed_dma_setup:
        return st;
 }
 
+int rsxx_dma_cancel(struct rsxx_dma_ctrl *ctrl)
+{
+       struct rsxx_dma *dma;
+       int i;
+       int cnt = 0;
+
+       /* Clean up issued DMAs */
+       for (i = 0; i < RSXX_MAX_OUTSTANDING_CMDS; i++) {
+               dma = get_tracker_dma(ctrl->trackers, i);
+               if (dma) {
+                       atomic_dec(&ctrl->stats.hw_q_depth);
+                       rsxx_complete_dma(ctrl, dma, DMA_CANCELLED);
+                       push_tracker(ctrl->trackers, i);
+                       cnt++;
+               }
+       }
+
+       return cnt;
+}
 
 void rsxx_dma_destroy(struct rsxx_cardinfo *card)
 {
        struct rsxx_dma_ctrl *ctrl;
-       struct rsxx_dma *dma;
-       int i, j;
-       int cnt = 0;
+       int i;
 
        for (i = 0; i < card->n_targets; i++) {
                ctrl = &card->ctrl[i];
@@ -943,33 +989,11 @@ void rsxx_dma_destroy(struct rsxx_cardinfo *card)
                        del_timer_sync(&ctrl->activity_timer);
 
                /* Clean up the DMA queue */
-               spin_lock(&ctrl->queue_lock);
-               cnt = rsxx_cleanup_dma_queue(card, &ctrl->queue);
-               spin_unlock(&ctrl->queue_lock);
-
-               if (cnt)
-                       dev_info(CARD_TO_DEV(card),
-                               "Freed %d queued DMAs on channel %d\n",
-                               cnt, i);
-
-               /* Clean up issued DMAs */
-               for (j = 0; j < RSXX_MAX_OUTSTANDING_CMDS; j++) {
-                       dma = get_tracker_dma(ctrl->trackers, j);
-                       if (dma) {
-                               pci_unmap_page(card->dev, dma->dma_addr,
-                                              get_dma_size(dma),
-                                              (dma->cmd == HW_CMD_BLK_WRITE) ?
-                                              PCI_DMA_TODEVICE :
-                                              PCI_DMA_FROMDEVICE);
-                               kmem_cache_free(rsxx_dma_pool, dma);
-                               cnt++;
-                       }
-               }
+               spin_lock_bh(&ctrl->queue_lock);
+               rsxx_cleanup_dma_queue(ctrl, &ctrl->queue);
+               spin_unlock_bh(&ctrl->queue_lock);
 
-               if (cnt)
-                       dev_info(CARD_TO_DEV(card),
-                               "Freed %d pending DMAs on channel %d\n",
-                               cnt, i);
+               rsxx_dma_cancel(ctrl);
 
                vfree(ctrl->trackers);
 
@@ -1013,7 +1037,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
                        cnt++;
                }
 
-               spin_lock(&card->ctrl[i].queue_lock);
+               spin_lock_bh(&card->ctrl[i].queue_lock);
                list_splice(&issued_dmas[i], &card->ctrl[i].queue);
 
                atomic_sub(cnt, &card->ctrl[i].stats.hw_q_depth);
@@ -1028,7 +1052,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
                                               PCI_DMA_TODEVICE :
                                               PCI_DMA_FROMDEVICE);
                }
-               spin_unlock(&card->ctrl[i].queue_lock);
+               spin_unlock_bh(&card->ctrl[i].queue_lock);
        }
 
        kfree(issued_dmas);
@@ -1036,30 +1060,13 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
        return 0;
 }
 
-void rsxx_eeh_cancel_dmas(struct rsxx_cardinfo *card)
-{
-       struct rsxx_dma *dma;
-       struct rsxx_dma *tmp;
-       int i;
-
-       for (i = 0; i < card->n_targets; i++) {
-               spin_lock(&card->ctrl[i].queue_lock);
-               list_for_each_entry_safe(dma, tmp, &card->ctrl[i].queue, list) {
-                       list_del(&dma->list);
-
-                       rsxx_complete_dma(&card->ctrl[i], dma, DMA_CANCELLED);
-               }
-               spin_unlock(&card->ctrl[i].queue_lock);
-       }
-}
-
 int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card)
 {
        struct rsxx_dma *dma;
        int i;
 
        for (i = 0; i < card->n_targets; i++) {
-               spin_lock(&card->ctrl[i].queue_lock);
+               spin_lock_bh(&card->ctrl[i].queue_lock);
                list_for_each_entry(dma, &card->ctrl[i].queue, list) {
                        dma->dma_addr = pci_map_page(card->dev, dma->page,
                                        dma->pg_off, get_dma_size(dma),
@@ -1067,12 +1074,12 @@ int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card)
                                        PCI_DMA_TODEVICE :
                                        PCI_DMA_FROMDEVICE);
                        if (!dma->dma_addr) {
-                               spin_unlock(&card->ctrl[i].queue_lock);
+                               spin_unlock_bh(&card->ctrl[i].queue_lock);
                                kmem_cache_free(rsxx_dma_pool, dma);
                                return -ENOMEM;
                        }
                }
-               spin_unlock(&card->ctrl[i].queue_lock);
+               spin_unlock_bh(&card->ctrl[i].queue_lock);
        }
 
        return 0;
index 382e8bf5c03b73dae35fd1ae8865110cc1a85168..5ad5055a4104d9341fc1f55054d1c872c58467d1 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/vmalloc.h>
 #include <linux/timer.h>
 #include <linux/ioctl.h>
+#include <linux/delay.h>
 
 #include "rsxx.h"
 #include "rsxx_cfg.h"
@@ -114,6 +115,7 @@ struct rsxx_dma_ctrl {
        struct timer_list               activity_timer;
        struct dma_tracker_list         *trackers;
        struct rsxx_dma_stats           stats;
+       struct mutex                    work_lock;
 };
 
 struct rsxx_cardinfo {
@@ -134,6 +136,7 @@ struct rsxx_cardinfo {
                spinlock_t              lock;
                bool                    active;
                struct creg_cmd         *active_cmd;
+               struct workqueue_struct *creg_wq;
                struct work_struct      done_work;
                struct list_head        queue;
                unsigned int            q_depth;
@@ -154,6 +157,7 @@ struct rsxx_cardinfo {
                int buf_len;
        } log;
 
+       struct workqueue_struct *event_wq;
        struct work_struct      event_work;
        unsigned int            state;
        u64                     size8;
@@ -181,6 +185,8 @@ struct rsxx_cardinfo {
 
        int                     n_targets;
        struct rsxx_dma_ctrl    *ctrl;
+
+       struct dentry           *debugfs_dir;
 };
 
 enum rsxx_pci_regmap {
@@ -283,6 +289,7 @@ enum rsxx_creg_addr {
        CREG_ADD_CAPABILITIES           = 0x80001050,
        CREG_ADD_LOG                    = 0x80002000,
        CREG_ADD_NUM_TARGETS            = 0x80003000,
+       CREG_ADD_CRAM                   = 0xA0000000,
        CREG_ADD_CONFIG                 = 0xB0000000,
 };
 
@@ -372,6 +379,8 @@ typedef void (*rsxx_dma_cb)(struct rsxx_cardinfo *card,
 int rsxx_dma_setup(struct rsxx_cardinfo *card);
 void rsxx_dma_destroy(struct rsxx_cardinfo *card);
 int rsxx_dma_init(void);
+int rsxx_cleanup_dma_queue(struct rsxx_dma_ctrl *ctrl, struct list_head *q);
+int rsxx_dma_cancel(struct rsxx_dma_ctrl *ctrl);
 void rsxx_dma_cleanup(void);
 void rsxx_dma_queue_reset(struct rsxx_cardinfo *card);
 int rsxx_dma_configure(struct rsxx_cardinfo *card);
@@ -382,7 +391,6 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
                           void *cb_data);
 int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl);
 int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card);
-void rsxx_eeh_cancel_dmas(struct rsxx_cardinfo *card);
 int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card);
 
 /***** cregs.c *****/
index dd5b2fed97e9ae2b7665f13ec3c42db6ee6fb462..bf4b9d282c042ec4d5b3c31a9d3192bd059afcc5 100644 (file)
 #include "common.h"
 
 /*
- * These are rather arbitrary. They are fairly large because adjacent requests
- * pulled from a communication ring are quite likely to end up being part of
- * the same scatter/gather request at the disc.
+ * Maximum number of unused free pages to keep in the internal buffer.
+ * Setting this to a value too low will reduce memory used in each backend,
+ * but can have a performance penalty.
  *
- * ** TRY INCREASING 'xen_blkif_reqs' IF WRITE SPEEDS SEEM TOO LOW **
- *
- * This will increase the chances of being able to write whole tracks.
- * 64 should be enough to keep us competitive with Linux.
+ * A sane value is xen_blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST, but can
+ * be set to a lower value that might degrade performance on some intensive
+ * IO workloads.
  */
-static int xen_blkif_reqs = 64;
-module_param_named(reqs, xen_blkif_reqs, int, 0);
-MODULE_PARM_DESC(reqs, "Number of blkback requests to allocate");
 
-/* Run-time switchable: /sys/module/blkback/parameters/ */
-static unsigned int log_stats;
-module_param(log_stats, int, 0644);
+static int xen_blkif_max_buffer_pages = 1024;
+module_param_named(max_buffer_pages, xen_blkif_max_buffer_pages, int, 0644);
+MODULE_PARM_DESC(max_buffer_pages,
+"Maximum number of free pages to keep in each block backend buffer");
 
 /*
- * Each outstanding request that we've passed to the lower device layers has a
- * 'pending_req' allocated to it. Each buffer_head that completes decrements
- * the pendcnt towards zero. When it hits zero, the specified domain has a
- * response queued for it, with the saved 'id' passed back.
+ * Maximum number of grants to map persistently in blkback. For maximum
+ * performance this should be the total numbers of grants that can be used
+ * to fill the ring, but since this might become too high, specially with
+ * the use of indirect descriptors, we set it to a value that provides good
+ * performance without using too much memory.
+ *
+ * When the list of persistent grants is full we clean it up using a LRU
+ * algorithm.
  */
-struct pending_req {
-       struct xen_blkif        *blkif;
-       u64                     id;
-       int                     nr_pages;
-       atomic_t                pendcnt;
-       unsigned short          operation;
-       int                     status;
-       struct list_head        free_list;
-       DECLARE_BITMAP(unmap_seg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
-};
 
-#define BLKBACK_INVALID_HANDLE (~0)
+static int xen_blkif_max_pgrants = 1056;
+module_param_named(max_persistent_grants, xen_blkif_max_pgrants, int, 0644);
+MODULE_PARM_DESC(max_persistent_grants,
+                 "Maximum number of grants to map persistently");
 
-struct xen_blkbk {
-       struct pending_req      *pending_reqs;
-       /* List of all 'pending_req' available */
-       struct list_head        pending_free;
-       /* And its spinlock. */
-       spinlock_t              pending_free_lock;
-       wait_queue_head_t       pending_free_wq;
-       /* The list of all pages that are available. */
-       struct page             **pending_pages;
-       /* And the grant handles that are available. */
-       grant_handle_t          *pending_grant_handles;
-};
-
-static struct xen_blkbk *blkbk;
+/*
+ * The LRU mechanism to clean the lists of persistent grants needs to
+ * be executed periodically. The time interval between consecutive executions
+ * of the purge mechanism is set in ms.
+ */
+#define LRU_INTERVAL 100
 
 /*
- * Maximum number of grant pages that can be mapped in blkback.
- * BLKIF_MAX_SEGMENTS_PER_REQUEST * RING_SIZE is the maximum number of
- * pages that blkback will persistently map.
- * Currently, this is:
- * RING_SIZE = 32 (for all known ring types)
- * BLKIF_MAX_SEGMENTS_PER_REQUEST = 11
- * sizeof(struct persistent_gnt) = 48
- * So the maximum memory used to store the grants is:
- * 32 * 11 * 48 = 16896 bytes
+ * When the persistent grants list is full we will remove unused grants
+ * from the list. The percent number of grants to be removed at each LRU
+ * execution.
  */
-static inline unsigned int max_mapped_grant_pages(enum blkif_protocol protocol)
+#define LRU_PERCENT_CLEAN 5
+
+/* Run-time switchable: /sys/module/blkback/parameters/ */
+static unsigned int log_stats;
+module_param(log_stats, int, 0644);
+
+#define BLKBACK_INVALID_HANDLE (~0)
+
+/* Number of free pages to remove on each call to free_xenballooned_pages */
+#define NUM_BATCH_FREE_PAGES 10
+
+static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
 {
-       switch (protocol) {
-       case BLKIF_PROTOCOL_NATIVE:
-               return __CONST_RING_SIZE(blkif, PAGE_SIZE) *
-                          BLKIF_MAX_SEGMENTS_PER_REQUEST;
-       case BLKIF_PROTOCOL_X86_32:
-               return __CONST_RING_SIZE(blkif_x86_32, PAGE_SIZE) *
-                          BLKIF_MAX_SEGMENTS_PER_REQUEST;
-       case BLKIF_PROTOCOL_X86_64:
-               return __CONST_RING_SIZE(blkif_x86_64, PAGE_SIZE) *
-                          BLKIF_MAX_SEGMENTS_PER_REQUEST;
-       default:
-               BUG();
+       unsigned long flags;
+
+       spin_lock_irqsave(&blkif->free_pages_lock, flags);
+       if (list_empty(&blkif->free_pages)) {
+               BUG_ON(blkif->free_pages_num != 0);
+               spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
+               return alloc_xenballooned_pages(1, page, false);
        }
+       BUG_ON(blkif->free_pages_num == 0);
+       page[0] = list_first_entry(&blkif->free_pages, struct page, lru);
+       list_del(&page[0]->lru);
+       blkif->free_pages_num--;
+       spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
+
        return 0;
 }
 
-
-/*
- * Little helpful macro to figure out the index and virtual address of the
- * pending_pages[..]. For each 'pending_req' we have have up to
- * BLKIF_MAX_SEGMENTS_PER_REQUEST (11) pages. The seg would be from 0 through
- * 10 and would index in the pending_pages[..].
- */
-static inline int vaddr_pagenr(struct pending_req *req, int seg)
+static inline void put_free_pages(struct xen_blkif *blkif, struct page **page,
+                                  int num)
 {
-       return (req - blkbk->pending_reqs) *
-               BLKIF_MAX_SEGMENTS_PER_REQUEST + seg;
-}
+       unsigned long flags;
+       int i;
 
-#define pending_page(req, seg) pending_pages[vaddr_pagenr(req, seg)]
+       spin_lock_irqsave(&blkif->free_pages_lock, flags);
+       for (i = 0; i < num; i++)
+               list_add(&page[i]->lru, &blkif->free_pages);
+       blkif->free_pages_num += num;
+       spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
+}
 
-static inline unsigned long vaddr(struct pending_req *req, int seg)
+static inline void shrink_free_pagepool(struct xen_blkif *blkif, int num)
 {
-       unsigned long pfn = page_to_pfn(blkbk->pending_page(req, seg));
-       return (unsigned long)pfn_to_kaddr(pfn);
-}
+       /* Remove requested pages in batches of NUM_BATCH_FREE_PAGES */
+       struct page *page[NUM_BATCH_FREE_PAGES];
+       unsigned int num_pages = 0;
+       unsigned long flags;
 
-#define pending_handle(_req, _seg) \
-       (blkbk->pending_grant_handles[vaddr_pagenr(_req, _seg)])
+       spin_lock_irqsave(&blkif->free_pages_lock, flags);
+       while (blkif->free_pages_num > num) {
+               BUG_ON(list_empty(&blkif->free_pages));
+               page[num_pages] = list_first_entry(&blkif->free_pages,
+                                                  struct page, lru);
+               list_del(&page[num_pages]->lru);
+               blkif->free_pages_num--;
+               if (++num_pages == NUM_BATCH_FREE_PAGES) {
+                       spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
+                       free_xenballooned_pages(num_pages, page);
+                       spin_lock_irqsave(&blkif->free_pages_lock, flags);
+                       num_pages = 0;
+               }
+       }
+       spin_unlock_irqrestore(&blkif->free_pages_lock, flags);
+       if (num_pages != 0)
+               free_xenballooned_pages(num_pages, page);
+}
 
+#define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page)))
 
 static int do_block_io_op(struct xen_blkif *blkif);
 static int dispatch_rw_block_io(struct xen_blkif *blkif,
@@ -170,13 +178,29 @@ static void make_response(struct xen_blkif *blkif, u64 id,
             (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)
 
 
-static void add_persistent_gnt(struct rb_root *root,
+/*
+ * We don't need locking around the persistent grant helpers
+ * because blkback uses a single-thread for each backed, so we
+ * can be sure that this functions will never be called recursively.
+ *
+ * The only exception to that is put_persistent_grant, that can be called
+ * from interrupt context (by xen_blkbk_unmap), so we have to use atomic
+ * bit operations to modify the flags of a persistent grant and to count
+ * the number of used grants.
+ */
+static int add_persistent_gnt(struct xen_blkif *blkif,
                               struct persistent_gnt *persistent_gnt)
 {
-       struct rb_node **new = &(root->rb_node), *parent = NULL;
+       struct rb_node **new = NULL, *parent = NULL;
        struct persistent_gnt *this;
 
+       if (blkif->persistent_gnt_c >= xen_blkif_max_pgrants) {
+               if (!blkif->vbd.overflow_max_grants)
+                       blkif->vbd.overflow_max_grants = 1;
+               return -EBUSY;
+       }
        /* Figure out where to put new node */
+       new = &blkif->persistent_gnts.rb_node;
        while (*new) {
                this = container_of(*new, struct persistent_gnt, node);
 
@@ -186,22 +210,28 @@ static void add_persistent_gnt(struct rb_root *root,
                else if (persistent_gnt->gnt > this->gnt)
                        new = &((*new)->rb_right);
                else {
-                       pr_alert(DRV_PFX " trying to add a gref that's already in the tree\n");
-                       BUG();
+                       pr_alert_ratelimited(DRV_PFX " trying to add a gref that's already in the tree\n");
+                       return -EINVAL;
                }
        }
 
+       bitmap_zero(persistent_gnt->flags, PERSISTENT_GNT_FLAGS_SIZE);
+       set_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags);
        /* Add new node and rebalance tree. */
        rb_link_node(&(persistent_gnt->node), parent, new);
-       rb_insert_color(&(persistent_gnt->node), root);
+       rb_insert_color(&(persistent_gnt->node), &blkif->persistent_gnts);
+       blkif->persistent_gnt_c++;
+       atomic_inc(&blkif->persistent_gnt_in_use);
+       return 0;
 }
 
-static struct persistent_gnt *get_persistent_gnt(struct rb_root *root,
+static struct persistent_gnt *get_persistent_gnt(struct xen_blkif *blkif,
                                                 grant_ref_t gref)
 {
        struct persistent_gnt *data;
-       struct rb_node *node = root->rb_node;
+       struct rb_node *node = NULL;
 
+       node = blkif->persistent_gnts.rb_node;
        while (node) {
                data = container_of(node, struct persistent_gnt, node);
 
@@ -209,13 +239,31 @@ static struct persistent_gnt *get_persistent_gnt(struct rb_root *root,
                        node = node->rb_left;
                else if (gref > data->gnt)
                        node = node->rb_right;
-               else
+               else {
+                       if(test_bit(PERSISTENT_GNT_ACTIVE, data->flags)) {
+                               pr_alert_ratelimited(DRV_PFX " requesting a grant already in use\n");
+                               return NULL;
+                       }
+                       set_bit(PERSISTENT_GNT_ACTIVE, data->flags);
+                       atomic_inc(&blkif->persistent_gnt_in_use);
                        return data;
+               }
        }
        return NULL;
 }
 
-static void free_persistent_gnts(struct rb_root *root, unsigned int num)
+static void put_persistent_gnt(struct xen_blkif *blkif,
+                               struct persistent_gnt *persistent_gnt)
+{
+       if(!test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags))
+                 pr_alert_ratelimited(DRV_PFX " freeing a grant already unused");
+       set_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
+       clear_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags);
+       atomic_dec(&blkif->persistent_gnt_in_use);
+}
+
+static void free_persistent_gnts(struct xen_blkif *blkif, struct rb_root *root,
+                                 unsigned int num)
 {
        struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
@@ -240,7 +288,7 @@ static void free_persistent_gnts(struct rb_root *root, unsigned int num)
                        ret = gnttab_unmap_refs(unmap, NULL, pages,
                                segs_to_unmap);
                        BUG_ON(ret);
-                       free_xenballooned_pages(segs_to_unmap, pages);
+                       put_free_pages(blkif, pages, segs_to_unmap);
                        segs_to_unmap = 0;
                }
 
@@ -251,21 +299,148 @@ static void free_persistent_gnts(struct rb_root *root, unsigned int num)
        BUG_ON(num != 0);
 }
 
+static void unmap_purged_grants(struct work_struct *work)
+{
+       struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct persistent_gnt *persistent_gnt;
+       int ret, segs_to_unmap = 0;
+       struct xen_blkif *blkif = container_of(work, typeof(*blkif), persistent_purge_work);
+
+       while(!list_empty(&blkif->persistent_purge_list)) {
+               persistent_gnt = list_first_entry(&blkif->persistent_purge_list,
+                                                 struct persistent_gnt,
+                                                 remove_node);
+               list_del(&persistent_gnt->remove_node);
+
+               gnttab_set_unmap_op(&unmap[segs_to_unmap],
+                       vaddr(persistent_gnt->page),
+                       GNTMAP_host_map,
+                       persistent_gnt->handle);
+
+               pages[segs_to_unmap] = persistent_gnt->page;
+
+               if (++segs_to_unmap == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
+                       ret = gnttab_unmap_refs(unmap, NULL, pages,
+                               segs_to_unmap);
+                       BUG_ON(ret);
+                       put_free_pages(blkif, pages, segs_to_unmap);
+                       segs_to_unmap = 0;
+               }
+               kfree(persistent_gnt);
+       }
+       if (segs_to_unmap > 0) {
+               ret = gnttab_unmap_refs(unmap, NULL, pages, segs_to_unmap);
+               BUG_ON(ret);
+               put_free_pages(blkif, pages, segs_to_unmap);
+       }
+}
+
+static void purge_persistent_gnt(struct xen_blkif *blkif)
+{
+       struct persistent_gnt *persistent_gnt;
+       struct rb_node *n;
+       unsigned int num_clean, total;
+       bool scan_used = false, clean_used = false;
+       struct rb_root *root;
+
+       if (blkif->persistent_gnt_c < xen_blkif_max_pgrants ||
+           (blkif->persistent_gnt_c == xen_blkif_max_pgrants &&
+           !blkif->vbd.overflow_max_grants)) {
+               return;
+       }
+
+       if (work_pending(&blkif->persistent_purge_work)) {
+               pr_alert_ratelimited(DRV_PFX "Scheduled work from previous purge is still pending, cannot purge list\n");
+               return;
+       }
+
+       num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN;
+       num_clean = blkif->persistent_gnt_c - xen_blkif_max_pgrants + num_clean;
+       num_clean = min(blkif->persistent_gnt_c, num_clean);
+       if ((num_clean == 0) ||
+           (num_clean > (blkif->persistent_gnt_c - atomic_read(&blkif->persistent_gnt_in_use))))
+               return;
+
+       /*
+        * At this point, we can assure that there will be no calls
+         * to get_persistent_grant (because we are executing this code from
+         * xen_blkif_schedule), there can only be calls to put_persistent_gnt,
+         * which means that the number of currently used grants will go down,
+         * but never up, so we will always be able to remove the requested
+         * number of grants.
+        */
+
+       total = num_clean;
+
+       pr_debug(DRV_PFX "Going to purge %u persistent grants\n", num_clean);
+
+       INIT_LIST_HEAD(&blkif->persistent_purge_list);
+       root = &blkif->persistent_gnts;
+purge_list:
+       foreach_grant_safe(persistent_gnt, n, root, node) {
+               BUG_ON(persistent_gnt->handle ==
+                       BLKBACK_INVALID_HANDLE);
+
+               if (clean_used) {
+                       clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
+                       continue;
+               }
+
+               if (test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags))
+                       continue;
+               if (!scan_used &&
+                   (test_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags)))
+                       continue;
+
+               rb_erase(&persistent_gnt->node, root);
+               list_add(&persistent_gnt->remove_node,
+                        &blkif->persistent_purge_list);
+               if (--num_clean == 0)
+                       goto finished;
+       }
+       /*
+        * If we get here it means we also need to start cleaning
+        * grants that were used since last purge in order to cope
+        * with the requested num
+        */
+       if (!scan_used && !clean_used) {
+               pr_debug(DRV_PFX "Still missing %u purged frames\n", num_clean);
+               scan_used = true;
+               goto purge_list;
+       }
+finished:
+       if (!clean_used) {
+               pr_debug(DRV_PFX "Finished scanning for grants to clean, removing used flag\n");
+               clean_used = true;
+               goto purge_list;
+       }
+
+       blkif->persistent_gnt_c -= (total - num_clean);
+       blkif->vbd.overflow_max_grants = 0;
+
+       /* We can defer this work */
+       INIT_WORK(&blkif->persistent_purge_work, unmap_purged_grants);
+       schedule_work(&blkif->persistent_purge_work);
+       pr_debug(DRV_PFX "Purged %u/%u\n", (total - num_clean), total);
+       return;
+}
+
 /*
  * Retrieve from the 'pending_reqs' a free pending_req structure to be used.
  */
-static struct pending_req *alloc_req(void)
+static struct pending_req *alloc_req(struct xen_blkif *blkif)
 {
        struct pending_req *req = NULL;
        unsigned long flags;
 
-       spin_lock_irqsave(&blkbk->pending_free_lock, flags);
-       if (!list_empty(&blkbk->pending_free)) {
-               req = list_entry(blkbk->pending_free.next, struct pending_req,
+       spin_lock_irqsave(&blkif->pending_free_lock, flags);
+       if (!list_empty(&blkif->pending_free)) {
+               req = list_entry(blkif->pending_free.next, struct pending_req,
                                 free_list);
                list_del(&req->free_list);
        }
-       spin_unlock_irqrestore(&blkbk->pending_free_lock, flags);
+       spin_unlock_irqrestore(&blkif->pending_free_lock, flags);
        return req;
 }
 
@@ -273,17 +448,17 @@ static struct pending_req *alloc_req(void)
  * Return the 'pending_req' structure back to the freepool. We also
  * wake up the thread if it was waiting for a free page.
  */
-static void free_req(struct pending_req *req)
+static void free_req(struct xen_blkif *blkif, struct pending_req *req)
 {
        unsigned long flags;
        int was_empty;
 
-       spin_lock_irqsave(&blkbk->pending_free_lock, flags);
-       was_empty = list_empty(&blkbk->pending_free);
-       list_add(&req->free_list, &blkbk->pending_free);
-       spin_unlock_irqrestore(&blkbk->pending_free_lock, flags);
+       spin_lock_irqsave(&blkif->pending_free_lock, flags);
+       was_empty = list_empty(&blkif->pending_free);
+       list_add(&req->free_list, &blkif->pending_free);
+       spin_unlock_irqrestore(&blkif->pending_free_lock, flags);
        if (was_empty)
-               wake_up(&blkbk->pending_free_wq);
+               wake_up(&blkif->pending_free_wq);
 }
 
 /*
@@ -382,10 +557,12 @@ irqreturn_t xen_blkif_be_int(int irq, void *dev_id)
 static void print_stats(struct xen_blkif *blkif)
 {
        pr_info("xen-blkback (%s): oo %3llu  |  rd %4llu  |  wr %4llu  |  f %4llu"
-                "  |  ds %4llu\n",
+                "  |  ds %4llu | pg: %4u/%4d\n",
                 current->comm, blkif->st_oo_req,
                 blkif->st_rd_req, blkif->st_wr_req,
-                blkif->st_f_req, blkif->st_ds_req);
+                blkif->st_f_req, blkif->st_ds_req,
+                blkif->persistent_gnt_c,
+                xen_blkif_max_pgrants);
        blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000);
        blkif->st_rd_req = 0;
        blkif->st_wr_req = 0;
@@ -397,6 +574,8 @@ int xen_blkif_schedule(void *arg)
 {
        struct xen_blkif *blkif = arg;
        struct xen_vbd *vbd = &blkif->vbd;
+       unsigned long timeout;
+       int ret;
 
        xen_blkif_get(blkif);
 
@@ -406,27 +585,52 @@ int xen_blkif_schedule(void *arg)
                if (unlikely(vbd->size != vbd_sz(vbd)))
                        xen_vbd_resize(blkif);
 
-               wait_event_interruptible(
+               timeout = msecs_to_jiffies(LRU_INTERVAL);
+
+               timeout = wait_event_interruptible_timeout(
                        blkif->wq,
-                       blkif->waiting_reqs || kthread_should_stop());
-               wait_event_interruptible(
-                       blkbk->pending_free_wq,
-                       !list_empty(&blkbk->pending_free) ||
-                       kthread_should_stop());
+                       blkif->waiting_reqs || kthread_should_stop(),
+                       timeout);
+               if (timeout == 0)
+                       goto purge_gnt_list;
+               timeout = wait_event_interruptible_timeout(
+                       blkif->pending_free_wq,
+                       !list_empty(&blkif->pending_free) ||
+                       kthread_should_stop(),
+                       timeout);
+               if (timeout == 0)
+                       goto purge_gnt_list;
 
                blkif->waiting_reqs = 0;
                smp_mb(); /* clear flag *before* checking for work */
 
-               if (do_block_io_op(blkif))
+               ret = do_block_io_op(blkif);
+               if (ret > 0)
                        blkif->waiting_reqs = 1;
+               if (ret == -EACCES)
+                       wait_event_interruptible(blkif->shutdown_wq,
+                                                kthread_should_stop());
+
+purge_gnt_list:
+               if (blkif->vbd.feature_gnt_persistent &&
+                   time_after(jiffies, blkif->next_lru)) {
+                       purge_persistent_gnt(blkif);
+                       blkif->next_lru = jiffies + msecs_to_jiffies(LRU_INTERVAL);
+               }
+
+               /* Shrink if we have more than xen_blkif_max_buffer_pages */
+               shrink_free_pagepool(blkif, xen_blkif_max_buffer_pages);
 
                if (log_stats && time_after(jiffies, blkif->st_print))
                        print_stats(blkif);
        }
 
+       /* Since we are shutting down remove all pages from the buffer */
+       shrink_free_pagepool(blkif, 0 /* All */);
+
        /* Free all persistent grant pages */
        if (!RB_EMPTY_ROOT(&blkif->persistent_gnts))
-               free_persistent_gnts(&blkif->persistent_gnts,
+               free_persistent_gnts(blkif, &blkif->persistent_gnts,
                        blkif->persistent_gnt_c);
 
        BUG_ON(!RB_EMPTY_ROOT(&blkif->persistent_gnts));
@@ -441,148 +645,98 @@ int xen_blkif_schedule(void *arg)
        return 0;
 }
 
-struct seg_buf {
-       unsigned int offset;
-       unsigned int nsec;
-};
 /*
  * Unmap the grant references, and also remove the M2P over-rides
  * used in the 'pending_req'.
  */
-static void xen_blkbk_unmap(struct pending_req *req)
+static void xen_blkbk_unmap(struct xen_blkif *blkif,
+                            struct grant_page *pages[],
+                            int num)
 {
        struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-       struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct page *unmap_pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        unsigned int i, invcount = 0;
-       grant_handle_t handle;
        int ret;
 
-       for (i = 0; i < req->nr_pages; i++) {
-               if (!test_bit(i, req->unmap_seg))
+       for (i = 0; i < num; i++) {
+               if (pages[i]->persistent_gnt != NULL) {
+                       put_persistent_gnt(blkif, pages[i]->persistent_gnt);
                        continue;
-               handle = pending_handle(req, i);
-               if (handle == BLKBACK_INVALID_HANDLE)
+               }
+               if (pages[i]->handle == BLKBACK_INVALID_HANDLE)
                        continue;
-               gnttab_set_unmap_op(&unmap[invcount], vaddr(req, i),
-                                   GNTMAP_host_map, handle);
-               pending_handle(req, i) = BLKBACK_INVALID_HANDLE;
-               pages[invcount] = virt_to_page(vaddr(req, i));
-               invcount++;
+               unmap_pages[invcount] = pages[i]->page;
+               gnttab_set_unmap_op(&unmap[invcount], vaddr(pages[i]->page),
+                                   GNTMAP_host_map, pages[i]->handle);
+               pages[i]->handle = BLKBACK_INVALID_HANDLE;
+               if (++invcount == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
+                       ret = gnttab_unmap_refs(unmap, NULL, unmap_pages,
+                                               invcount);
+                       BUG_ON(ret);
+                       put_free_pages(blkif, unmap_pages, invcount);
+                       invcount = 0;
+               }
+       }
+       if (invcount) {
+               ret = gnttab_unmap_refs(unmap, NULL, unmap_pages, invcount);
+               BUG_ON(ret);
+               put_free_pages(blkif, unmap_pages, invcount);
        }
-
-       ret = gnttab_unmap_refs(unmap, NULL, pages, invcount);
-       BUG_ON(ret);
 }
 
-static int xen_blkbk_map(struct blkif_request *req,
-                        struct pending_req *pending_req,
-                        struct seg_buf seg[],
-                        struct page *pages[])
+static int xen_blkbk_map(struct xen_blkif *blkif,
+                        struct grant_page *pages[],
+                        int num, bool ro)
 {
        struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-       struct persistent_gnt *persistent_gnts[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        struct page *pages_to_gnt[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        struct persistent_gnt *persistent_gnt = NULL;
-       struct xen_blkif *blkif = pending_req->blkif;
        phys_addr_t addr = 0;
-       int i, j;
-       bool new_map;
-       int nseg = req->u.rw.nr_segments;
+       int i, seg_idx, new_map_idx;
        int segs_to_map = 0;
        int ret = 0;
+       int last_map = 0, map_until = 0;
        int use_persistent_gnts;
 
        use_persistent_gnts = (blkif->vbd.feature_gnt_persistent);
 
-       BUG_ON(blkif->persistent_gnt_c >
-                  max_mapped_grant_pages(pending_req->blkif->blk_protocol));
-
        /*
         * Fill out preq.nr_sects with proper amount of sectors, and setup
         * assign map[..] with the PFN of the page in our domain with the
         * corresponding grant reference for each page.
         */
-       for (i = 0; i < nseg; i++) {
+again:
+       for (i = map_until; i < num; i++) {
                uint32_t flags;
 
                if (use_persistent_gnts)
                        persistent_gnt = get_persistent_gnt(
-                               &blkif->persistent_gnts,
-                               req->u.rw.seg[i].gref);
+                               blkif,
+                               pages[i]->gref);
 
                if (persistent_gnt) {
                        /*
                         * We are using persistent grants and
                         * the grant is already mapped
                         */
-                       new_map = false;
-               } else if (use_persistent_gnts &&
-                          blkif->persistent_gnt_c <
-                          max_mapped_grant_pages(blkif->blk_protocol)) {
-                       /*
-                        * We are using persistent grants, the grant is
-                        * not mapped but we have room for it
-                        */
-                       new_map = true;
-                       persistent_gnt = kmalloc(
-                               sizeof(struct persistent_gnt),
-                               GFP_KERNEL);
-                       if (!persistent_gnt)
-                               return -ENOMEM;
-                       if (alloc_xenballooned_pages(1, &persistent_gnt->page,
-                           false)) {
-                               kfree(persistent_gnt);
-                               return -ENOMEM;
-                       }
-                       persistent_gnt->gnt = req->u.rw.seg[i].gref;
-                       persistent_gnt->handle = BLKBACK_INVALID_HANDLE;
-
-                       pages_to_gnt[segs_to_map] =
-                               persistent_gnt->page;
-                       addr = (unsigned long) pfn_to_kaddr(
-                               page_to_pfn(persistent_gnt->page));
-
-                       add_persistent_gnt(&blkif->persistent_gnts,
-                               persistent_gnt);
-                       blkif->persistent_gnt_c++;
-                       pr_debug(DRV_PFX " grant %u added to the tree of persistent grants, using %u/%u\n",
-                                persistent_gnt->gnt, blkif->persistent_gnt_c,
-                                max_mapped_grant_pages(blkif->blk_protocol));
+                       pages[i]->page = persistent_gnt->page;
+                       pages[i]->persistent_gnt = persistent_gnt;
                } else {
-                       /*
-                        * We are either using persistent grants and
-                        * hit the maximum limit of grants mapped,
-                        * or we are not using persistent grants.
-                        */
-                       if (use_persistent_gnts &&
-                               !blkif->vbd.overflow_max_grants) {
-                               blkif->vbd.overflow_max_grants = 1;
-                               pr_alert(DRV_PFX " domain %u, device %#x is using maximum number of persistent grants\n",
-                                        blkif->domid, blkif->vbd.handle);
-                       }
-                       new_map = true;
-                       pages[i] = blkbk->pending_page(pending_req, i);
-                       addr = vaddr(pending_req, i);
-                       pages_to_gnt[segs_to_map] =
-                               blkbk->pending_page(pending_req, i);
-               }
-
-               if (persistent_gnt) {
-                       pages[i] = persistent_gnt->page;
-                       persistent_gnts[i] = persistent_gnt;
-               } else {
-                       persistent_gnts[i] = NULL;
-               }
-
-               if (new_map) {
+                       if (get_free_page(blkif, &pages[i]->page))
+                               goto out_of_memory;
+                       addr = vaddr(pages[i]->page);
+                       pages_to_gnt[segs_to_map] = pages[i]->page;
+                       pages[i]->persistent_gnt = NULL;
                        flags = GNTMAP_host_map;
-                       if (!persistent_gnt &&
-                           (pending_req->operation != BLKIF_OP_READ))
+                       if (!use_persistent_gnts && ro)
                                flags |= GNTMAP_readonly;
                        gnttab_set_map_op(&map[segs_to_map++], addr,
-                                         flags, req->u.rw.seg[i].gref,
+                                         flags, pages[i]->gref,
                                          blkif->domid);
                }
+               map_until = i + 1;
+               if (segs_to_map == BLKIF_MAX_SEGMENTS_PER_REQUEST)
+                       break;
        }
 
        if (segs_to_map) {
@@ -595,49 +749,133 @@ static int xen_blkbk_map(struct blkif_request *req,
         * so that when we access vaddr(pending_req,i) it has the contents of
         * the page from the other domain.
         */
-       bitmap_zero(pending_req->unmap_seg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
-       for (i = 0, j = 0; i < nseg; i++) {
-               if (!persistent_gnts[i] ||
-                   persistent_gnts[i]->handle == BLKBACK_INVALID_HANDLE) {
+       for (seg_idx = last_map, new_map_idx = 0; seg_idx < map_until; seg_idx++) {
+               if (!pages[seg_idx]->persistent_gnt) {
                        /* This is a newly mapped grant */
-                       BUG_ON(j >= segs_to_map);
-                       if (unlikely(map[j].status != 0)) {
+                       BUG_ON(new_map_idx >= segs_to_map);
+                       if (unlikely(map[new_map_idx].status != 0)) {
                                pr_debug(DRV_PFX "invalid buffer -- could not remap it\n");
-                               map[j].handle = BLKBACK_INVALID_HANDLE;
+                               pages[seg_idx]->handle = BLKBACK_INVALID_HANDLE;
                                ret |= 1;
-                               if (persistent_gnts[i]) {
-                                       rb_erase(&persistent_gnts[i]->node,
-                                                &blkif->persistent_gnts);
-                                       blkif->persistent_gnt_c--;
-                                       kfree(persistent_gnts[i]);
-                                       persistent_gnts[i] = NULL;
-                               }
+                               goto next;
                        }
+                       pages[seg_idx]->handle = map[new_map_idx].handle;
+               } else {
+                       continue;
                }
-               if (persistent_gnts[i]) {
-                       if (persistent_gnts[i]->handle ==
-                           BLKBACK_INVALID_HANDLE) {
+               if (use_persistent_gnts &&
+                   blkif->persistent_gnt_c < xen_blkif_max_pgrants) {
+                       /*
+                        * We are using persistent grants, the grant is
+                        * not mapped but we might have room for it.
+                        */
+                       persistent_gnt = kmalloc(sizeof(struct persistent_gnt),
+                                                GFP_KERNEL);
+                       if (!persistent_gnt) {
                                /*
-                                * If this is a new persistent grant
-                                * save the handler
+                                * If we don't have enough memory to
+                                * allocate the persistent_gnt struct
+                                * map this grant non-persistenly
                                 */
-                               persistent_gnts[i]->handle = map[j++].handle;
+                               goto next;
                        }
-                       pending_handle(pending_req, i) =
-                               persistent_gnts[i]->handle;
+                       persistent_gnt->gnt = map[new_map_idx].ref;
+                       persistent_gnt->handle = map[new_map_idx].handle;
+                       persistent_gnt->page = pages[seg_idx]->page;
+                       if (add_persistent_gnt(blkif,
+                                              persistent_gnt)) {
+                               kfree(persistent_gnt);
+                               persistent_gnt = NULL;
+                               goto next;
+                       }
+                       pages[seg_idx]->persistent_gnt = persistent_gnt;
+                       pr_debug(DRV_PFX " grant %u added to the tree of persistent grants, using %u/%u\n",
+                                persistent_gnt->gnt, blkif->persistent_gnt_c,
+                                xen_blkif_max_pgrants);
+                       goto next;
+               }
+               if (use_persistent_gnts && !blkif->vbd.overflow_max_grants) {
+                       blkif->vbd.overflow_max_grants = 1;
+                       pr_debug(DRV_PFX " domain %u, device %#x is using maximum number of persistent grants\n",
+                                blkif->domid, blkif->vbd.handle);
+               }
+               /*
+                * We could not map this grant persistently, so use it as
+                * a non-persistent grant.
+                */
+next:
+               new_map_idx++;
+       }
+       segs_to_map = 0;
+       last_map = map_until;
+       if (map_until != num)
+               goto again;
 
-                       if (ret)
-                               continue;
-               } else {
-                       pending_handle(pending_req, i) = map[j++].handle;
-                       bitmap_set(pending_req->unmap_seg, i, 1);
+       return ret;
+
+out_of_memory:
+       pr_alert(DRV_PFX "%s: out of memory\n", __func__);
+       put_free_pages(blkif, pages_to_gnt, segs_to_map);
+       return -ENOMEM;
+}
+
+static int xen_blkbk_map_seg(struct pending_req *pending_req)
+{
+       int rc;
+
+       rc = xen_blkbk_map(pending_req->blkif, pending_req->segments,
+                          pending_req->nr_pages,
+                          (pending_req->operation != BLKIF_OP_READ));
+
+       return rc;
+}
 
-                       if (ret)
-                               continue;
+static int xen_blkbk_parse_indirect(struct blkif_request *req,
+                                   struct pending_req *pending_req,
+                                   struct seg_buf seg[],
+                                   struct phys_req *preq)
+{
+       struct grant_page **pages = pending_req->indirect_pages;
+       struct xen_blkif *blkif = pending_req->blkif;
+       int indirect_grefs, rc, n, nseg, i;
+       struct blkif_request_segment_aligned *segments = NULL;
+
+       nseg = pending_req->nr_pages;
+       indirect_grefs = INDIRECT_PAGES(nseg);
+       BUG_ON(indirect_grefs > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
+
+       for (i = 0; i < indirect_grefs; i++)
+               pages[i]->gref = req->u.indirect.indirect_grefs[i];
+
+       rc = xen_blkbk_map(blkif, pages, indirect_grefs, true);
+       if (rc)
+               goto unmap;
+
+       for (n = 0, i = 0; n < nseg; n++) {
+               if ((n % SEGS_PER_INDIRECT_FRAME) == 0) {
+                       /* Map indirect segments */
+                       if (segments)
+                               kunmap_atomic(segments);
+                       segments = kmap_atomic(pages[n/SEGS_PER_INDIRECT_FRAME]->page);
+               }
+               i = n % SEGS_PER_INDIRECT_FRAME;
+               pending_req->segments[n]->gref = segments[i].gref;
+               seg[n].nsec = segments[i].last_sect -
+                       segments[i].first_sect + 1;
+               seg[n].offset = (segments[i].first_sect << 9);
+               if ((segments[i].last_sect >= (PAGE_SIZE >> 9)) ||
+                   (segments[i].last_sect < segments[i].first_sect)) {
+                       rc = -EINVAL;
+                       goto unmap;
                }
-               seg[i].offset = (req->u.rw.seg[i].first_sect << 9);
+               preq->nr_sects += seg[n].nsec;
        }
-       return ret;
+
+unmap:
+       if (segments)
+               kunmap_atomic(segments);
+       xen_blkbk_unmap(blkif, pages, indirect_grefs);
+       return rc;
 }
 
 static int dispatch_discard_io(struct xen_blkif *blkif,
@@ -647,7 +885,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
        int status = BLKIF_RSP_OKAY;
        struct block_device *bdev = blkif->vbd.bdev;
        unsigned long secure;
+       struct phys_req preq;
+
+       preq.sector_number = req->u.discard.sector_number;
+       preq.nr_sects      = req->u.discard.nr_sectors;
 
+       err = xen_vbd_translate(&preq, blkif, WRITE);
+       if (err) {
+               pr_warn(DRV_PFX "access denied: DISCARD [%llu->%llu] on dev=%04x\n",
+                       preq.sector_number,
+                       preq.sector_number + preq.nr_sects, blkif->vbd.pdevice);
+               goto fail_response;
+       }
        blkif->st_ds_req++;
 
        xen_blkif_get(blkif);
@@ -658,7 +907,7 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
        err = blkdev_issue_discard(bdev, req->u.discard.sector_number,
                                   req->u.discard.nr_sectors,
                                   GFP_KERNEL, secure);
-
+fail_response:
        if (err == -EOPNOTSUPP) {
                pr_debug(DRV_PFX "discard op failed, not supported\n");
                status = BLKIF_RSP_EOPNOTSUPP;
@@ -674,7 +923,7 @@ static int dispatch_other_io(struct xen_blkif *blkif,
                             struct blkif_request *req,
                             struct pending_req *pending_req)
 {
-       free_req(pending_req);
+       free_req(blkif, pending_req);
        make_response(blkif, req->u.other.id, req->operation,
                      BLKIF_RSP_EOPNOTSUPP);
        return -EIO;
@@ -726,7 +975,9 @@ static void __end_block_io_op(struct pending_req *pending_req, int error)
         * the proper response on the ring.
         */
        if (atomic_dec_and_test(&pending_req->pendcnt)) {
-               xen_blkbk_unmap(pending_req);
+               xen_blkbk_unmap(pending_req->blkif,
+                               pending_req->segments,
+                               pending_req->nr_pages);
                make_response(pending_req->blkif, pending_req->id,
                              pending_req->operation, pending_req->status);
                xen_blkif_put(pending_req->blkif);
@@ -734,7 +985,7 @@ static void __end_block_io_op(struct pending_req *pending_req, int error)
                        if (atomic_read(&pending_req->blkif->drain))
                                complete(&pending_req->blkif->drain_complete);
                }
-               free_req(pending_req);
+               free_req(pending_req->blkif, pending_req);
        }
 }
 
@@ -767,6 +1018,12 @@ __do_block_io_op(struct xen_blkif *blkif)
        rp = blk_rings->common.sring->req_prod;
        rmb(); /* Ensure we see queued requests up to 'rp'. */
 
+       if (RING_REQUEST_PROD_OVERFLOW(&blk_rings->common, rp)) {
+               rc = blk_rings->common.rsp_prod_pvt;
+               pr_warn(DRV_PFX "Frontend provided bogus ring requests (%d - %d = %d). Halting ring processing on dev=%04x\n",
+                       rp, rc, rp - rc, blkif->vbd.pdevice);
+               return -EACCES;
+       }
        while (rc != rp) {
 
                if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc))
@@ -777,7 +1034,7 @@ __do_block_io_op(struct xen_blkif *blkif)
                        break;
                }
 
-               pending_req = alloc_req();
+               pending_req = alloc_req(blkif);
                if (NULL == pending_req) {
                        blkif->st_oo_req++;
                        more_to_do = 1;
@@ -807,11 +1064,12 @@ __do_block_io_op(struct xen_blkif *blkif)
                case BLKIF_OP_WRITE:
                case BLKIF_OP_WRITE_BARRIER:
                case BLKIF_OP_FLUSH_DISKCACHE:
+               case BLKIF_OP_INDIRECT:
                        if (dispatch_rw_block_io(blkif, &req, pending_req))
                                goto done;
                        break;
                case BLKIF_OP_DISCARD:
-                       free_req(pending_req);
+                       free_req(blkif, pending_req);
                        if (dispatch_discard_io(blkif, &req))
                                goto done;
                        break;
@@ -853,17 +1111,28 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
                                struct pending_req *pending_req)
 {
        struct phys_req preq;
-       struct seg_buf seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct seg_buf *seg = pending_req->seg;
        unsigned int nseg;
        struct bio *bio = NULL;
-       struct bio *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct bio **biolist = pending_req->biolist;
        int i, nbio = 0;
        int operation;
        struct blk_plug plug;
        bool drain = false;
-       struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct grant_page **pages = pending_req->segments;
+       unsigned short req_operation;
+
+       req_operation = req->operation == BLKIF_OP_INDIRECT ?
+                       req->u.indirect.indirect_op : req->operation;
+       if ((req->operation == BLKIF_OP_INDIRECT) &&
+           (req_operation != BLKIF_OP_READ) &&
+           (req_operation != BLKIF_OP_WRITE)) {
+               pr_debug(DRV_PFX "Invalid indirect operation (%u)\n",
+                        req_operation);
+               goto fail_response;
+       }
 
-       switch (req->operation) {
+       switch (req_operation) {
        case BLKIF_OP_READ:
                blkif->st_rd_req++;
                operation = READ;
@@ -885,33 +1154,47 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
        }
 
        /* Check that the number of segments is sane. */
-       nseg = req->u.rw.nr_segments;
+       nseg = req->operation == BLKIF_OP_INDIRECT ?
+              req->u.indirect.nr_segments : req->u.rw.nr_segments;
 
        if (unlikely(nseg == 0 && operation != WRITE_FLUSH) ||
-           unlikely(nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
+           unlikely((req->operation != BLKIF_OP_INDIRECT) &&
+                    (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST)) ||
+           unlikely((req->operation == BLKIF_OP_INDIRECT) &&
+                    (nseg > MAX_INDIRECT_SEGMENTS))) {
                pr_debug(DRV_PFX "Bad number of segments in request (%d)\n",
                         nseg);
                /* Haven't submitted any bio's yet. */
                goto fail_response;
        }
 
-       preq.sector_number = req->u.rw.sector_number;
        preq.nr_sects      = 0;
 
        pending_req->blkif     = blkif;
        pending_req->id        = req->u.rw.id;
-       pending_req->operation = req->operation;
+       pending_req->operation = req_operation;
        pending_req->status    = BLKIF_RSP_OKAY;
        pending_req->nr_pages  = nseg;
 
-       for (i = 0; i < nseg; i++) {
-               seg[i].nsec = req->u.rw.seg[i].last_sect -
-                       req->u.rw.seg[i].first_sect + 1;
-               if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) ||
-                   (req->u.rw.seg[i].last_sect < req->u.rw.seg[i].first_sect))
+       if (req->operation != BLKIF_OP_INDIRECT) {
+               preq.dev               = req->u.rw.handle;
+               preq.sector_number     = req->u.rw.sector_number;
+               for (i = 0; i < nseg; i++) {
+                       pages[i]->gref = req->u.rw.seg[i].gref;
+                       seg[i].nsec = req->u.rw.seg[i].last_sect -
+                               req->u.rw.seg[i].first_sect + 1;
+                       seg[i].offset = (req->u.rw.seg[i].first_sect << 9);
+                       if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) ||
+                           (req->u.rw.seg[i].last_sect <
+                            req->u.rw.seg[i].first_sect))
+                               goto fail_response;
+                       preq.nr_sects += seg[i].nsec;
+               }
+       } else {
+               preq.dev               = req->u.indirect.handle;
+               preq.sector_number     = req->u.indirect.sector_number;
+               if (xen_blkbk_parse_indirect(req, pending_req, seg, &preq))
                        goto fail_response;
-               preq.nr_sects += seg[i].nsec;
-
        }
 
        if (xen_vbd_translate(&preq, blkif, operation) != 0) {
@@ -948,7 +1231,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
         * the hypercall to unmap the grants - that is all done in
         * xen_blkbk_unmap.
         */
-       if (xen_blkbk_map(req, pending_req, seg, pages))
+       if (xen_blkbk_map_seg(pending_req))
                goto fail_flush;
 
        /*
@@ -960,11 +1243,12 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
        for (i = 0; i < nseg; i++) {
                while ((bio == NULL) ||
                       (bio_add_page(bio,
-                                    pages[i],
+                                    pages[i]->page,
                                     seg[i].nsec << 9,
                                     seg[i].offset) == 0)) {
 
-                       bio = bio_alloc(GFP_KERNEL, nseg-i);
+                       int nr_iovecs = min_t(int, (nseg-i), BIO_MAX_PAGES);
+                       bio = bio_alloc(GFP_KERNEL, nr_iovecs);
                        if (unlikely(bio == NULL))
                                goto fail_put_bio;
 
@@ -1009,11 +1293,12 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
        return 0;
 
  fail_flush:
-       xen_blkbk_unmap(pending_req);
+       xen_blkbk_unmap(blkif, pending_req->segments,
+                       pending_req->nr_pages);
  fail_response:
        /* Haven't submitted any bio's yet. */
-       make_response(blkif, req->u.rw.id, req->operation, BLKIF_RSP_ERROR);
-       free_req(pending_req);
+       make_response(blkif, req->u.rw.id, req_operation, BLKIF_RSP_ERROR);
+       free_req(blkif, pending_req);
        msleep(1); /* back off a bit */
        return -EIO;
 
@@ -1070,73 +1355,20 @@ static void make_response(struct xen_blkif *blkif, u64 id,
 
 static int __init xen_blkif_init(void)
 {
-       int i, mmap_pages;
        int rc = 0;
 
        if (!xen_domain())
                return -ENODEV;
 
-       blkbk = kzalloc(sizeof(struct xen_blkbk), GFP_KERNEL);
-       if (!blkbk) {
-               pr_alert(DRV_PFX "%s: out of memory!\n", __func__);
-               return -ENOMEM;
-       }
-
-       mmap_pages = xen_blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
-
-       blkbk->pending_reqs          = kzalloc(sizeof(blkbk->pending_reqs[0]) *
-                                       xen_blkif_reqs, GFP_KERNEL);
-       blkbk->pending_grant_handles = kmalloc(sizeof(blkbk->pending_grant_handles[0]) *
-                                       mmap_pages, GFP_KERNEL);
-       blkbk->pending_pages         = kzalloc(sizeof(blkbk->pending_pages[0]) *
-                                       mmap_pages, GFP_KERNEL);
-
-       if (!blkbk->pending_reqs || !blkbk->pending_grant_handles ||
-           !blkbk->pending_pages) {
-               rc = -ENOMEM;
-               goto out_of_memory;
-       }
-
-       for (i = 0; i < mmap_pages; i++) {
-               blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
-               blkbk->pending_pages[i] = alloc_page(GFP_KERNEL);
-               if (blkbk->pending_pages[i] == NULL) {
-                       rc = -ENOMEM;
-                       goto out_of_memory;
-               }
-       }
        rc = xen_blkif_interface_init();
        if (rc)
                goto failed_init;
 
-       INIT_LIST_HEAD(&blkbk->pending_free);
-       spin_lock_init(&blkbk->pending_free_lock);
-       init_waitqueue_head(&blkbk->pending_free_wq);
-
-       for (i = 0; i < xen_blkif_reqs; i++)
-               list_add_tail(&blkbk->pending_reqs[i].free_list,
-                             &blkbk->pending_free);
-
        rc = xen_blkif_xenbus_init();
        if (rc)
                goto failed_init;
 
-       return 0;
-
- out_of_memory:
-       pr_alert(DRV_PFX "%s: out of memory\n", __func__);
  failed_init:
-       kfree(blkbk->pending_reqs);
-       kfree(blkbk->pending_grant_handles);
-       if (blkbk->pending_pages) {
-               for (i = 0; i < mmap_pages; i++) {
-                       if (blkbk->pending_pages[i])
-                               __free_page(blkbk->pending_pages[i]);
-               }
-               kfree(blkbk->pending_pages);
-       }
-       kfree(blkbk);
-       blkbk = NULL;
        return rc;
 }
 
index 60103e2517ba28ac5c946f32e1bd9e0e6eb7f668..8d8807563d9967afd28b70dcb0cd072bed35e8ec 100644 (file)
                 __func__, __LINE__, ##args)
 
 
+/*
+ * This is the maximum number of segments that would be allowed in indirect
+ * requests. This value will also be passed to the frontend.
+ */
+#define MAX_INDIRECT_SEGMENTS 256
+
+#define SEGS_PER_INDIRECT_FRAME \
+       (PAGE_SIZE/sizeof(struct blkif_request_segment_aligned))
+#define MAX_INDIRECT_PAGES \
+       ((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
+#define INDIRECT_PAGES(_segs) \
+       ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
+
 /* Not a real protocol.  Used to generate ring structs which contain
  * the elements common to all protocols only.  This way we get a
  * compiler-checkable way to use common struct elements, so we can
@@ -83,12 +96,31 @@ struct blkif_x86_32_request_other {
        uint64_t       id;           /* private guest value, echoed in resp  */
 } __attribute__((__packed__));
 
+struct blkif_x86_32_request_indirect {
+       uint8_t        indirect_op;
+       uint16_t       nr_segments;
+       uint64_t       id;
+       blkif_sector_t sector_number;
+       blkif_vdev_t   handle;
+       uint16_t       _pad1;
+       grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
+       /*
+        * The maximum number of indirect segments (and pages) that will
+        * be used is determined by MAX_INDIRECT_SEGMENTS, this value
+        * is also exported to the guest (via xenstore
+        * feature-max-indirect-segments entry), so the frontend knows how
+        * many indirect segments the backend supports.
+        */
+       uint64_t       _pad2;        /* make it 64 byte aligned */
+} __attribute__((__packed__));
+
 struct blkif_x86_32_request {
        uint8_t        operation;    /* BLKIF_OP_???                         */
        union {
                struct blkif_x86_32_request_rw rw;
                struct blkif_x86_32_request_discard discard;
                struct blkif_x86_32_request_other other;
+               struct blkif_x86_32_request_indirect indirect;
        } u;
 } __attribute__((__packed__));
 
@@ -127,12 +159,32 @@ struct blkif_x86_64_request_other {
        uint64_t       id;           /* private guest value, echoed in resp  */
 } __attribute__((__packed__));
 
+struct blkif_x86_64_request_indirect {
+       uint8_t        indirect_op;
+       uint16_t       nr_segments;
+       uint32_t       _pad1;        /* offsetof(blkif_..,u.indirect.id)==8   */
+       uint64_t       id;
+       blkif_sector_t sector_number;
+       blkif_vdev_t   handle;
+       uint16_t       _pad2;
+       grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
+       /*
+        * The maximum number of indirect segments (and pages) that will
+        * be used is determined by MAX_INDIRECT_SEGMENTS, this value
+        * is also exported to the guest (via xenstore
+        * feature-max-indirect-segments entry), so the frontend knows how
+        * many indirect segments the backend supports.
+        */
+       uint32_t       _pad3;        /* make it 64 byte aligned */
+} __attribute__((__packed__));
+
 struct blkif_x86_64_request {
        uint8_t        operation;    /* BLKIF_OP_???                         */
        union {
                struct blkif_x86_64_request_rw rw;
                struct blkif_x86_64_request_discard discard;
                struct blkif_x86_64_request_other other;
+               struct blkif_x86_64_request_indirect indirect;
        } u;
 } __attribute__((__packed__));
 
@@ -182,12 +234,26 @@ struct xen_vbd {
 
 struct backend_info;
 
+/* Number of available flags */
+#define PERSISTENT_GNT_FLAGS_SIZE      2
+/* This persistent grant is currently in use */
+#define PERSISTENT_GNT_ACTIVE          0
+/*
+ * This persistent grant has been used, this flag is set when we remove the
+ * PERSISTENT_GNT_ACTIVE, to know that this grant has been used recently.
+ */
+#define PERSISTENT_GNT_WAS_ACTIVE      1
+
+/* Number of requests that we can fit in a ring */
+#define XEN_BLKIF_REQS                 32
 
 struct persistent_gnt {
        struct page *page;
        grant_ref_t gnt;
        grant_handle_t handle;
+       DECLARE_BITMAP(flags, PERSISTENT_GNT_FLAGS_SIZE);
        struct rb_node node;
+       struct list_head remove_node;
 };
 
 struct xen_blkif {
@@ -219,6 +285,23 @@ struct xen_blkif {
        /* tree to store persistent grants */
        struct rb_root          persistent_gnts;
        unsigned int            persistent_gnt_c;
+       atomic_t                persistent_gnt_in_use;
+       unsigned long           next_lru;
+
+       /* used by the kworker that offload work from the persistent purge */
+       struct list_head        persistent_purge_list;
+       struct work_struct      persistent_purge_work;
+
+       /* buffer of free pages to map grant refs */
+       spinlock_t              free_pages_lock;
+       int                     free_pages_num;
+       struct list_head        free_pages;
+
+       /* List of all 'pending_req' available */
+       struct list_head        pending_free;
+       /* And its spinlock. */
+       spinlock_t              pending_free_lock;
+       wait_queue_head_t       pending_free_wq;
 
        /* statistics */
        unsigned long           st_print;
@@ -231,6 +314,41 @@ struct xen_blkif {
        unsigned long long                      st_wr_sect;
 
        wait_queue_head_t       waiting_to_free;
+       /* Thread shutdown wait queue. */
+       wait_queue_head_t       shutdown_wq;
+};
+
+struct seg_buf {
+       unsigned long offset;
+       unsigned int nsec;
+};
+
+struct grant_page {
+       struct page             *page;
+       struct persistent_gnt   *persistent_gnt;
+       grant_handle_t          handle;
+       grant_ref_t             gref;
+};
+
+/*
+ * Each outstanding request that we've passed to the lower device layers has a
+ * 'pending_req' allocated to it. Each buffer_head that completes decrements
+ * the pendcnt towards zero. When it hits zero, the specified domain has a
+ * response queued for it, with the saved 'id' passed back.
+ */
+struct pending_req {
+       struct xen_blkif        *blkif;
+       u64                     id;
+       int                     nr_pages;
+       atomic_t                pendcnt;
+       unsigned short          operation;
+       int                     status;
+       struct list_head        free_list;
+       struct grant_page       *segments[MAX_INDIRECT_SEGMENTS];
+       /* Indirect descriptors */
+       struct grant_page       *indirect_pages[MAX_INDIRECT_PAGES];
+       struct seg_buf          seg[MAX_INDIRECT_SEGMENTS];
+       struct bio              *biolist[MAX_INDIRECT_SEGMENTS];
 };
 
 
@@ -257,6 +375,7 @@ int xen_blkif_xenbus_init(void);
 
 irqreturn_t xen_blkif_be_int(int irq, void *dev_id);
 int xen_blkif_schedule(void *arg);
+int xen_blkif_purge_persistent(void *arg);
 
 int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
                              struct backend_info *be, int state);
@@ -268,7 +387,7 @@ struct xenbus_device *xen_blkbk_xenbus(struct backend_info *be);
 static inline void blkif_get_x86_32_req(struct blkif_request *dst,
                                        struct blkif_x86_32_request *src)
 {
-       int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST;
+       int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j;
        dst->operation = src->operation;
        switch (src->operation) {
        case BLKIF_OP_READ:
@@ -291,6 +410,18 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst,
                dst->u.discard.sector_number = src->u.discard.sector_number;
                dst->u.discard.nr_sectors = src->u.discard.nr_sectors;
                break;
+       case BLKIF_OP_INDIRECT:
+               dst->u.indirect.indirect_op = src->u.indirect.indirect_op;
+               dst->u.indirect.nr_segments = src->u.indirect.nr_segments;
+               dst->u.indirect.handle = src->u.indirect.handle;
+               dst->u.indirect.id = src->u.indirect.id;
+               dst->u.indirect.sector_number = src->u.indirect.sector_number;
+               barrier();
+               j = min(MAX_INDIRECT_PAGES, INDIRECT_PAGES(dst->u.indirect.nr_segments));
+               for (i = 0; i < j; i++)
+                       dst->u.indirect.indirect_grefs[i] =
+                               src->u.indirect.indirect_grefs[i];
+               break;
        default:
                /*
                 * Don't know how to translate this op. Only get the
@@ -304,7 +435,7 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst,
 static inline void blkif_get_x86_64_req(struct blkif_request *dst,
                                        struct blkif_x86_64_request *src)
 {
-       int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST;
+       int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j;
        dst->operation = src->operation;
        switch (src->operation) {
        case BLKIF_OP_READ:
@@ -327,6 +458,18 @@ static inline void blkif_get_x86_64_req(struct blkif_request *dst,
                dst->u.discard.sector_number = src->u.discard.sector_number;
                dst->u.discard.nr_sectors = src->u.discard.nr_sectors;
                break;
+       case BLKIF_OP_INDIRECT:
+               dst->u.indirect.indirect_op = src->u.indirect.indirect_op;
+               dst->u.indirect.nr_segments = src->u.indirect.nr_segments;
+               dst->u.indirect.handle = src->u.indirect.handle;
+               dst->u.indirect.id = src->u.indirect.id;
+               dst->u.indirect.sector_number = src->u.indirect.sector_number;
+               barrier();
+               j = min(MAX_INDIRECT_PAGES, INDIRECT_PAGES(dst->u.indirect.nr_segments));
+               for (i = 0; i < j; i++)
+                       dst->u.indirect.indirect_grefs[i] =
+                               src->u.indirect.indirect_grefs[i];
+               break;
        default:
                /*
                 * Don't know how to translate this op. Only get the
index 04608a6502d7b25bec73a51da69e1e2748e960c4..fe5c3cd10c341045ca63aeacb15edc93c185a88b 100644 (file)
@@ -98,12 +98,17 @@ static void xen_update_blkif_status(struct xen_blkif *blkif)
                err = PTR_ERR(blkif->xenblkd);
                blkif->xenblkd = NULL;
                xenbus_dev_error(blkif->be->dev, err, "start xenblkd");
+               return;
        }
 }
 
 static struct xen_blkif *xen_blkif_alloc(domid_t domid)
 {
        struct xen_blkif *blkif;
+       struct pending_req *req, *n;
+       int i, j;
+
+       BUILD_BUG_ON(MAX_INDIRECT_PAGES > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
 
        blkif = kmem_cache_zalloc(xen_blkif_cachep, GFP_KERNEL);
        if (!blkif)
@@ -118,8 +123,57 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
        blkif->st_print = jiffies;
        init_waitqueue_head(&blkif->waiting_to_free);
        blkif->persistent_gnts.rb_node = NULL;
+       spin_lock_init(&blkif->free_pages_lock);
+       INIT_LIST_HEAD(&blkif->free_pages);
+       blkif->free_pages_num = 0;
+       atomic_set(&blkif->persistent_gnt_in_use, 0);
+
+       INIT_LIST_HEAD(&blkif->pending_free);
+
+       for (i = 0; i < XEN_BLKIF_REQS; i++) {
+               req = kzalloc(sizeof(*req), GFP_KERNEL);
+               if (!req)
+                       goto fail;
+               list_add_tail(&req->free_list,
+                             &blkif->pending_free);
+               for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) {
+                       req->segments[j] = kzalloc(sizeof(*req->segments[0]),
+                                                  GFP_KERNEL);
+                       if (!req->segments[j])
+                               goto fail;
+               }
+               for (j = 0; j < MAX_INDIRECT_PAGES; j++) {
+                       req->indirect_pages[j] = kzalloc(sizeof(*req->indirect_pages[0]),
+                                                        GFP_KERNEL);
+                       if (!req->indirect_pages[j])
+                               goto fail;
+               }
+       }
+       spin_lock_init(&blkif->pending_free_lock);
+       init_waitqueue_head(&blkif->pending_free_wq);
+       init_waitqueue_head(&blkif->shutdown_wq);
 
        return blkif;
+
+fail:
+       list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
+               list_del(&req->free_list);
+               for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) {
+                       if (!req->segments[j])
+                               break;
+                       kfree(req->segments[j]);
+               }
+               for (j = 0; j < MAX_INDIRECT_PAGES; j++) {
+                       if (!req->indirect_pages[j])
+                               break;
+                       kfree(req->indirect_pages[j]);
+               }
+               kfree(req);
+       }
+
+       kmem_cache_free(xen_blkif_cachep, blkif);
+
+       return ERR_PTR(-ENOMEM);
 }
 
 static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
@@ -178,6 +232,7 @@ static void xen_blkif_disconnect(struct xen_blkif *blkif)
 {
        if (blkif->xenblkd) {
                kthread_stop(blkif->xenblkd);
+               wake_up(&blkif->shutdown_wq);
                blkif->xenblkd = NULL;
        }
 
@@ -198,8 +253,28 @@ static void xen_blkif_disconnect(struct xen_blkif *blkif)
 
 static void xen_blkif_free(struct xen_blkif *blkif)
 {
+       struct pending_req *req, *n;
+       int i = 0, j;
+
        if (!atomic_dec_and_test(&blkif->refcnt))
                BUG();
+
+       /* Check that there is no request in use */
+       list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
+               list_del(&req->free_list);
+
+               for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++)
+                       kfree(req->segments[j]);
+
+               for (j = 0; j < MAX_INDIRECT_PAGES; j++)
+                       kfree(req->indirect_pages[j]);
+
+               kfree(req);
+               i++;
+       }
+
+       WARN_ON(i != XEN_BLKIF_REQS);
+
        kmem_cache_free(xen_blkif_cachep, blkif);
 }
 
@@ -678,6 +753,11 @@ again:
                                 dev->nodename);
                goto abort;
        }
+       err = xenbus_printf(xbt, dev->nodename, "feature-max-indirect-segments", "%u",
+                           MAX_INDIRECT_SEGMENTS);
+       if (err)
+               dev_warn(&dev->dev, "writing %s/feature-max-indirect-segments (%d)",
+                        dev->nodename, err);
 
        err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
                            (unsigned long long)vbd_sz(&be->blkif->vbd));
@@ -704,6 +784,11 @@ again:
                                 dev->nodename);
                goto abort;
        }
+       err = xenbus_printf(xbt, dev->nodename, "physical-sector-size", "%u",
+                           bdev_physical_block_size(be->blkif->vbd.bdev));
+       if (err)
+               xenbus_dev_error(dev, err, "writing %s/physical-sector-size",
+                                dev->nodename);
 
        err = xenbus_transaction_end(xbt, 0);
        if (err == -EAGAIN)
index d89ef86220f4a55a247083d36d5f8dd3ce74e0d5..a4660bbee8a6279bd4cc1a6def776ddc85bcf169 100644 (file)
@@ -74,12 +74,30 @@ struct grant {
 struct blk_shadow {
        struct blkif_request req;
        struct request *request;
-       struct grant *grants_used[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+       struct grant **grants_used;
+       struct grant **indirect_grants;
+       struct scatterlist *sg;
+};
+
+struct split_bio {
+       struct bio *bio;
+       atomic_t pending;
+       int err;
 };
 
 static DEFINE_MUTEX(blkfront_mutex);
 static const struct block_device_operations xlvbd_block_fops;
 
+/*
+ * Maximum number of segments in indirect requests, the actual value used by
+ * the frontend driver is the minimum of this value and the value provided
+ * by the backend driver.
+ */
+
+static unsigned int xen_blkif_max_segments = 32;
+module_param_named(max, xen_blkif_max_segments, int, S_IRUGO);
+MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests (default is 32)");
+
 #define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE)
 
 /*
@@ -98,7 +116,6 @@ struct blkfront_info
        enum blkif_state connected;
        int ring_ref;
        struct blkif_front_ring ring;
-       struct scatterlist sg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        unsigned int evtchn, irq;
        struct request_queue *rq;
        struct work_struct work;
@@ -114,6 +131,7 @@ struct blkfront_info
        unsigned int discard_granularity;
        unsigned int discard_alignment;
        unsigned int feature_persistent:1;
+       unsigned int max_indirect_segments;
        int is_ready;
 };
 
@@ -142,6 +160,13 @@ static DEFINE_SPINLOCK(minor_lock);
 
 #define DEV_NAME       "xvd"   /* name in /dev */
 
+#define SEGS_PER_INDIRECT_FRAME \
+       (PAGE_SIZE/sizeof(struct blkif_request_segment_aligned))
+#define INDIRECT_GREFS(_segs) \
+       ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
+
+static int blkfront_setup_indirect(struct blkfront_info *info);
+
 static int get_id_from_freelist(struct blkfront_info *info)
 {
        unsigned long free = info->shadow_free;
@@ -358,7 +383,8 @@ static int blkif_queue_request(struct request *req)
        struct blkif_request *ring_req;
        unsigned long id;
        unsigned int fsect, lsect;
-       int i, ref;
+       int i, ref, n;
+       struct blkif_request_segment_aligned *segments = NULL;
 
        /*
         * Used to store if we are able to queue the request by just using
@@ -369,21 +395,27 @@ static int blkif_queue_request(struct request *req)
        grant_ref_t gref_head;
        struct grant *gnt_list_entry = NULL;
        struct scatterlist *sg;
+       int nseg, max_grefs;
 
        if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
                return 1;
 
-       /* Check if we have enought grants to allocate a requests */
-       if (info->persistent_gnts_c < BLKIF_MAX_SEGMENTS_PER_REQUEST) {
+       max_grefs = info->max_indirect_segments ?
+                   info->max_indirect_segments +
+                   INDIRECT_GREFS(info->max_indirect_segments) :
+                   BLKIF_MAX_SEGMENTS_PER_REQUEST;
+
+       /* Check if we have enough grants to allocate a requests */
+       if (info->persistent_gnts_c < max_grefs) {
                new_persistent_gnts = 1;
                if (gnttab_alloc_grant_references(
-                   BLKIF_MAX_SEGMENTS_PER_REQUEST - info->persistent_gnts_c,
+                   max_grefs - info->persistent_gnts_c,
                    &gref_head) < 0) {
                        gnttab_request_free_callback(
                                &info->callback,
                                blkif_restart_queue_callback,
                                info,
-                               BLKIF_MAX_SEGMENTS_PER_REQUEST);
+                               max_grefs);
                        return 1;
                }
        } else
@@ -394,42 +426,67 @@ static int blkif_queue_request(struct request *req)
        id = get_id_from_freelist(info);
        info->shadow[id].request = req;
 
-       ring_req->u.rw.id = id;
-       ring_req->u.rw.sector_number = (blkif_sector_t)blk_rq_pos(req);
-       ring_req->u.rw.handle = info->handle;
-
-       ring_req->operation = rq_data_dir(req) ?
-               BLKIF_OP_WRITE : BLKIF_OP_READ;
-
-       if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
-               /*
-                * Ideally we can do an unordered flush-to-disk. In case the
-                * backend onlysupports barriers, use that. A barrier request
-                * a superset of FUA, so we can implement it the same
-                * way.  (It's also a FLUSH+FUA, since it is
-                * guaranteed ordered WRT previous writes.)
-                */
-               ring_req->operation = info->flush_op;
-       }
-
        if (unlikely(req->cmd_flags & (REQ_DISCARD | REQ_SECURE))) {
-               /* id, sector_number and handle are set above. */
                ring_req->operation = BLKIF_OP_DISCARD;
                ring_req->u.discard.nr_sectors = blk_rq_sectors(req);
+               ring_req->u.discard.id = id;
+               ring_req->u.discard.sector_number = (blkif_sector_t)blk_rq_pos(req);
                if ((req->cmd_flags & REQ_SECURE) && info->feature_secdiscard)
                        ring_req->u.discard.flag = BLKIF_DISCARD_SECURE;
                else
                        ring_req->u.discard.flag = 0;
        } else {
-               ring_req->u.rw.nr_segments = blk_rq_map_sg(req->q, req,
-                                                          info->sg);
-               BUG_ON(ring_req->u.rw.nr_segments >
-                      BLKIF_MAX_SEGMENTS_PER_REQUEST);
-
-               for_each_sg(info->sg, sg, ring_req->u.rw.nr_segments, i) {
+               BUG_ON(info->max_indirect_segments == 0 &&
+                      req->nr_phys_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
+               BUG_ON(info->max_indirect_segments &&
+                      req->nr_phys_segments > info->max_indirect_segments);
+               nseg = blk_rq_map_sg(req->q, req, info->shadow[id].sg);
+               ring_req->u.rw.id = id;
+               if (nseg > BLKIF_MAX_SEGMENTS_PER_REQUEST) {
+                       /*
+                        * The indirect operation can only be a BLKIF_OP_READ or
+                        * BLKIF_OP_WRITE
+                        */
+                       BUG_ON(req->cmd_flags & (REQ_FLUSH | REQ_FUA));
+                       ring_req->operation = BLKIF_OP_INDIRECT;
+                       ring_req->u.indirect.indirect_op = rq_data_dir(req) ?
+                               BLKIF_OP_WRITE : BLKIF_OP_READ;
+                       ring_req->u.indirect.sector_number = (blkif_sector_t)blk_rq_pos(req);
+                       ring_req->u.indirect.handle = info->handle;
+                       ring_req->u.indirect.nr_segments = nseg;
+               } else {
+                       ring_req->u.rw.sector_number = (blkif_sector_t)blk_rq_pos(req);
+                       ring_req->u.rw.handle = info->handle;
+                       ring_req->operation = rq_data_dir(req) ?
+                               BLKIF_OP_WRITE : BLKIF_OP_READ;
+                       if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
+                               /*
+                                * Ideally we can do an unordered flush-to-disk. In case the
+                                * backend onlysupports barriers, use that. A barrier request
+                                * a superset of FUA, so we can implement it the same
+                                * way.  (It's also a FLUSH+FUA, since it is
+                                * guaranteed ordered WRT previous writes.)
+                                */
+                               ring_req->operation = info->flush_op;
+                       }
+                       ring_req->u.rw.nr_segments = nseg;
+               }
+               for_each_sg(info->shadow[id].sg, sg, nseg, i) {
                        fsect = sg->offset >> 9;
                        lsect = fsect + (sg->length >> 9) - 1;
 
+                       if ((ring_req->operation == BLKIF_OP_INDIRECT) &&
+                           (i % SEGS_PER_INDIRECT_FRAME == 0)) {
+                               if (segments)
+                                       kunmap_atomic(segments);
+
+                               n = i / SEGS_PER_INDIRECT_FRAME;
+                               gnt_list_entry = get_grant(&gref_head, info);
+                               info->shadow[id].indirect_grants[n] = gnt_list_entry;
+                               segments = kmap_atomic(pfn_to_page(gnt_list_entry->pfn));
+                               ring_req->u.indirect.indirect_grefs[n] = gnt_list_entry->gref;
+                       }
+
                        gnt_list_entry = get_grant(&gref_head, info);
                        ref = gnt_list_entry->gref;
 
@@ -441,8 +498,7 @@ static int blkif_queue_request(struct request *req)
 
                                BUG_ON(sg->offset + sg->length > PAGE_SIZE);
 
-                               shared_data = kmap_atomic(
-                                       pfn_to_page(gnt_list_entry->pfn));
+                               shared_data = kmap_atomic(pfn_to_page(gnt_list_entry->pfn));
                                bvec_data = kmap_atomic(sg_page(sg));
 
                                /*
@@ -461,13 +517,23 @@ static int blkif_queue_request(struct request *req)
                                kunmap_atomic(bvec_data);
                                kunmap_atomic(shared_data);
                        }
-
-                       ring_req->u.rw.seg[i] =
-                                       (struct blkif_request_segment) {
-                                               .gref       = ref,
-                                               .first_sect = fsect,
-                                               .last_sect  = lsect };
+                       if (ring_req->operation != BLKIF_OP_INDIRECT) {
+                               ring_req->u.rw.seg[i] =
+                                               (struct blkif_request_segment) {
+                                                       .gref       = ref,
+                                                       .first_sect = fsect,
+                                                       .last_sect  = lsect };
+                       } else {
+                               n = i % SEGS_PER_INDIRECT_FRAME;
+                               segments[n] =
+                                       (struct blkif_request_segment_aligned) {
+                                                       .gref       = ref,
+                                                       .first_sect = fsect,
+                                                       .last_sect  = lsect };
+                       }
                }
+               if (segments)
+                       kunmap_atomic(segments);
        }
 
        info->ring.req_prod_pvt++;
@@ -542,7 +608,9 @@ wait:
                flush_requests(info);
 }
 
-static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
+static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size,
+                               unsigned int physical_sector_size,
+                               unsigned int segments)
 {
        struct request_queue *rq;
        struct blkfront_info *info = gd->private_data;
@@ -564,14 +632,15 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
 
        /* Hard sector size and max sectors impersonate the equiv. hardware. */
        blk_queue_logical_block_size(rq, sector_size);
-       blk_queue_max_hw_sectors(rq, 512);
+       blk_queue_physical_block_size(rq, physical_sector_size);
+       blk_queue_max_hw_sectors(rq, (segments * PAGE_SIZE) / 512);
 
        /* Each segment in a request is up to an aligned page in size. */
        blk_queue_segment_boundary(rq, PAGE_SIZE - 1);
        blk_queue_max_segment_size(rq, PAGE_SIZE);
 
        /* Ensure a merged request will fit in a single I/O ring slot. */
-       blk_queue_max_segments(rq, BLKIF_MAX_SEGMENTS_PER_REQUEST);
+       blk_queue_max_segments(rq, segments);
 
        /* Make sure buffer addresses are sector-aligned. */
        blk_queue_dma_alignment(rq, 511);
@@ -588,13 +657,16 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
 static void xlvbd_flush(struct blkfront_info *info)
 {
        blk_queue_flush(info->rq, info->feature_flush);
-       printk(KERN_INFO "blkfront: %s: %s: %s %s\n",
+       printk(KERN_INFO "blkfront: %s: %s: %s %s %s %s %s\n",
               info->gd->disk_name,
               info->flush_op == BLKIF_OP_WRITE_BARRIER ?
                "barrier" : (info->flush_op == BLKIF_OP_FLUSH_DISKCACHE ?
                "flush diskcache" : "barrier or flush"),
-              info->feature_flush ? "enabled" : "disabled",
-              info->feature_persistent ? "using persistent grants" : "");
+              info->feature_flush ? "enabled;" : "disabled;",
+              "persistent grants:",
+              info->feature_persistent ? "enabled;" : "disabled;",
+              "indirect descriptors:",
+              info->max_indirect_segments ? "enabled;" : "disabled;");
 }
 
 static int xen_translate_vdev(int vdevice, int *minor, unsigned int *offset)
@@ -667,7 +739,8 @@ static char *encode_disk_name(char *ptr, unsigned int n)
 
 static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
                               struct blkfront_info *info,
-                              u16 vdisk_info, u16 sector_size)
+                              u16 vdisk_info, u16 sector_size,
+                              unsigned int physical_sector_size)
 {
        struct gendisk *gd;
        int nr_minors = 1;
@@ -734,7 +807,9 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
        gd->driverfs_dev = &(info->xbdev->dev);
        set_capacity(gd, capacity);
 
-       if (xlvbd_init_blk_queue(gd, sector_size)) {
+       if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size,
+                                info->max_indirect_segments ? :
+                                BLKIF_MAX_SEGMENTS_PER_REQUEST)) {
                del_gendisk(gd);
                goto release;
        }
@@ -818,6 +893,7 @@ static void blkif_free(struct blkfront_info *info, int suspend)
 {
        struct grant *persistent_gnt;
        struct grant *n;
+       int i, j, segs;
 
        /* Prevent new requests being issued until we fix things up. */
        spin_lock_irq(&info->io_lock);
@@ -843,6 +919,47 @@ static void blkif_free(struct blkfront_info *info, int suspend)
        }
        BUG_ON(info->persistent_gnts_c != 0);
 
+       for (i = 0; i < BLK_RING_SIZE; i++) {
+               /*
+                * Clear persistent grants present in requests already
+                * on the shared ring
+                */
+               if (!info->shadow[i].request)
+                       goto free_shadow;
+
+               segs = info->shadow[i].req.operation == BLKIF_OP_INDIRECT ?
+                      info->shadow[i].req.u.indirect.nr_segments :
+                      info->shadow[i].req.u.rw.nr_segments;
+               for (j = 0; j < segs; j++) {
+                       persistent_gnt = info->shadow[i].grants_used[j];
+                       gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
+                       __free_page(pfn_to_page(persistent_gnt->pfn));
+                       kfree(persistent_gnt);
+               }
+
+               if (info->shadow[i].req.operation != BLKIF_OP_INDIRECT)
+                       /*
+                        * If this is not an indirect operation don't try to
+                        * free indirect segments
+                        */
+                       goto free_shadow;
+
+               for (j = 0; j < INDIRECT_GREFS(segs); j++) {
+                       persistent_gnt = info->shadow[i].indirect_grants[j];
+                       gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
+                       __free_page(pfn_to_page(persistent_gnt->pfn));
+                       kfree(persistent_gnt);
+               }
+
+free_shadow:
+               kfree(info->shadow[i].grants_used);
+               info->shadow[i].grants_used = NULL;
+               kfree(info->shadow[i].indirect_grants);
+               info->shadow[i].indirect_grants = NULL;
+               kfree(info->shadow[i].sg);
+               info->shadow[i].sg = NULL;
+       }
+
        /* No more gnttab callback work. */
        gnttab_cancel_free_callback(&info->callback);
        spin_unlock_irq(&info->io_lock);
@@ -867,12 +984,13 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
                             struct blkif_response *bret)
 {
        int i = 0;
-       struct bio_vec *bvec;
-       struct req_iterator iter;
-       unsigned long flags;
+       struct scatterlist *sg;
        char *bvec_data;
        void *shared_data;
-       unsigned int offset = 0;
+       int nseg;
+
+       nseg = s->req.operation == BLKIF_OP_INDIRECT ?
+               s->req.u.indirect.nr_segments : s->req.u.rw.nr_segments;
 
        if (bret->operation == BLKIF_OP_READ) {
                /*
@@ -881,26 +999,29 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
                 * than PAGE_SIZE, we have to keep track of the current offset,
                 * to be sure we are copying the data from the right shared page.
                 */
-               rq_for_each_segment(bvec, s->request, iter) {
-                       BUG_ON((bvec->bv_offset + bvec->bv_len) > PAGE_SIZE);
-                       if (bvec->bv_offset < offset)
-                               i++;
-                       BUG_ON(i >= s->req.u.rw.nr_segments);
+               for_each_sg(s->sg, sg, nseg, i) {
+                       BUG_ON(sg->offset + sg->length > PAGE_SIZE);
                        shared_data = kmap_atomic(
                                pfn_to_page(s->grants_used[i]->pfn));
-                       bvec_data = bvec_kmap_irq(bvec, &flags);
-                       memcpy(bvec_data, shared_data + bvec->bv_offset,
-                               bvec->bv_len);
-                       bvec_kunmap_irq(bvec_data, &flags);
+                       bvec_data = kmap_atomic(sg_page(sg));
+                       memcpy(bvec_data   + sg->offset,
+                              shared_data + sg->offset,
+                              sg->length);
+                       kunmap_atomic(bvec_data);
                        kunmap_atomic(shared_data);
-                       offset = bvec->bv_offset + bvec->bv_len;
                }
        }
        /* Add the persistent grant into the list of free grants */
-       for (i = 0; i < s->req.u.rw.nr_segments; i++) {
+       for (i = 0; i < nseg; i++) {
                list_add(&s->grants_used[i]->node, &info->persistent_gnts);
                info->persistent_gnts_c++;
        }
+       if (s->req.operation == BLKIF_OP_INDIRECT) {
+               for (i = 0; i < INDIRECT_GREFS(nseg); i++) {
+                       list_add(&s->indirect_grants[i]->node, &info->persistent_gnts);
+                       info->persistent_gnts_c++;
+               }
+       }
 }
 
 static irqreturn_t blkif_interrupt(int irq, void *dev_id)
@@ -1034,14 +1155,6 @@ static int setup_blkring(struct xenbus_device *dev,
        SHARED_RING_INIT(sring);
        FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
 
-       sg_init_table(info->sg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
-
-       /* Allocate memory for grants */
-       err = fill_grant_buffer(info, BLK_RING_SIZE *
-                                     BLKIF_MAX_SEGMENTS_PER_REQUEST);
-       if (err)
-               goto fail;
-
        err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
        if (err < 0) {
                free_page((unsigned long)sring);
@@ -1223,13 +1336,84 @@ static int blkfront_probe(struct xenbus_device *dev,
        return 0;
 }
 
+/*
+ * This is a clone of md_trim_bio, used to split a bio into smaller ones
+ */
+static void trim_bio(struct bio *bio, int offset, int size)
+{
+       /* 'bio' is a cloned bio which we need to trim to match
+        * the given offset and size.
+        * This requires adjusting bi_sector, bi_size, and bi_io_vec
+        */
+       int i;
+       struct bio_vec *bvec;
+       int sofar = 0;
+
+       size <<= 9;
+       if (offset == 0 && size == bio->bi_size)
+               return;
+
+       bio->bi_sector += offset;
+       bio->bi_size = size;
+       offset <<= 9;
+       clear_bit(BIO_SEG_VALID, &bio->bi_flags);
+
+       while (bio->bi_idx < bio->bi_vcnt &&
+              bio->bi_io_vec[bio->bi_idx].bv_len <= offset) {
+               /* remove this whole bio_vec */
+               offset -= bio->bi_io_vec[bio->bi_idx].bv_len;
+               bio->bi_idx++;
+       }
+       if (bio->bi_idx < bio->bi_vcnt) {
+               bio->bi_io_vec[bio->bi_idx].bv_offset += offset;
+               bio->bi_io_vec[bio->bi_idx].bv_len -= offset;
+       }
+       /* avoid any complications with bi_idx being non-zero*/
+       if (bio->bi_idx) {
+               memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx,
+                       (bio->bi_vcnt - bio->bi_idx) * sizeof(struct bio_vec));
+               bio->bi_vcnt -= bio->bi_idx;
+               bio->bi_idx = 0;
+       }
+       /* Make sure vcnt and last bv are not too big */
+       bio_for_each_segment(bvec, bio, i) {
+               if (sofar + bvec->bv_len > size)
+                       bvec->bv_len = size - sofar;
+               if (bvec->bv_len == 0) {
+                       bio->bi_vcnt = i;
+                       break;
+               }
+               sofar += bvec->bv_len;
+       }
+}
+
+static void split_bio_end(struct bio *bio, int error)
+{
+       struct split_bio *split_bio = bio->bi_private;
+
+       if (error)
+               split_bio->err = error;
+
+       if (atomic_dec_and_test(&split_bio->pending)) {
+               split_bio->bio->bi_phys_segments = 0;
+               bio_endio(split_bio->bio, split_bio->err);
+               kfree(split_bio);
+       }
+       bio_put(bio);
+}
 
 static int blkif_recover(struct blkfront_info *info)
 {
        int i;
-       struct blkif_request *req;
+       struct request *req, *n;
        struct blk_shadow *copy;
-       int j;
+       int rc;
+       struct bio *bio, *cloned_bio;
+       struct bio_list bio_list, merge_bio;
+       unsigned int segs, offset;
+       int pending, size;
+       struct split_bio *split_bio;
+       struct list_head requests;
 
        /* Stage 1: Make a safe copy of the shadow state. */
        copy = kmemdup(info->shadow, sizeof(info->shadow),
@@ -1244,36 +1428,64 @@ static int blkif_recover(struct blkfront_info *info)
        info->shadow_free = info->ring.req_prod_pvt;
        info->shadow[BLK_RING_SIZE-1].req.u.rw.id = 0x0fffffff;
 
-       /* Stage 3: Find pending requests and requeue them. */
+       rc = blkfront_setup_indirect(info);
+       if (rc) {
+               kfree(copy);
+               return rc;
+       }
+
+       segs = info->max_indirect_segments ? : BLKIF_MAX_SEGMENTS_PER_REQUEST;
+       blk_queue_max_segments(info->rq, segs);
+       bio_list_init(&bio_list);
+       INIT_LIST_HEAD(&requests);
        for (i = 0; i < BLK_RING_SIZE; i++) {
                /* Not in use? */
                if (!copy[i].request)
                        continue;
 
-               /* Grab a request slot and copy shadow state into it. */
-               req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
-               *req = copy[i].req;
-
-               /* We get a new request id, and must reset the shadow state. */
-               req->u.rw.id = get_id_from_freelist(info);
-               memcpy(&info->shadow[req->u.rw.id], &copy[i], sizeof(copy[i]));
-
-               if (req->operation != BLKIF_OP_DISCARD) {
-               /* Rewrite any grant references invalidated by susp/resume. */
-                       for (j = 0; j < req->u.rw.nr_segments; j++)
-                               gnttab_grant_foreign_access_ref(
-                                       req->u.rw.seg[j].gref,
-                                       info->xbdev->otherend_id,
-                                       pfn_to_mfn(copy[i].grants_used[j]->pfn),
-                                       0);
+               /*
+                * Get the bios in the request so we can re-queue them.
+                */
+               if (copy[i].request->cmd_flags &
+                   (REQ_FLUSH | REQ_FUA | REQ_DISCARD | REQ_SECURE)) {
+                       /*
+                        * Flush operations don't contain bios, so
+                        * we need to requeue the whole request
+                        */
+                       list_add(&copy[i].request->queuelist, &requests);
+                       continue;
                }
-               info->shadow[req->u.rw.id].req = *req;
-
-               info->ring.req_prod_pvt++;
+               merge_bio.head = copy[i].request->bio;
+               merge_bio.tail = copy[i].request->biotail;
+               bio_list_merge(&bio_list, &merge_bio);
+               copy[i].request->bio = NULL;
+               blk_put_request(copy[i].request);
        }
 
        kfree(copy);
 
+       /*
+        * Empty the queue, this is important because we might have
+        * requests in the queue with more segments than what we
+        * can handle now.
+        */
+       spin_lock_irq(&info->io_lock);
+       while ((req = blk_fetch_request(info->rq)) != NULL) {
+               if (req->cmd_flags &
+                   (REQ_FLUSH | REQ_FUA | REQ_DISCARD | REQ_SECURE)) {
+                       list_add(&req->queuelist, &requests);
+                       continue;
+               }
+               merge_bio.head = req->bio;
+               merge_bio.tail = req->biotail;
+               bio_list_merge(&bio_list, &merge_bio);
+               req->bio = NULL;
+               if (req->cmd_flags & (REQ_FLUSH | REQ_FUA))
+                       pr_alert("diskcache flush request found!\n");
+               __blk_put_request(info->rq, req);
+       }
+       spin_unlock_irq(&info->io_lock);
+
        xenbus_switch_state(info->xbdev, XenbusStateConnected);
 
        spin_lock_irq(&info->io_lock);
@@ -1281,14 +1493,50 @@ static int blkif_recover(struct blkfront_info *info)
        /* Now safe for us to use the shared ring */
        info->connected = BLKIF_STATE_CONNECTED;
 
-       /* Send off requeued requests */
-       flush_requests(info);
-
        /* Kick any other new requests queued since we resumed */
        kick_pending_request_queues(info);
 
+       list_for_each_entry_safe(req, n, &requests, queuelist) {
+               /* Requeue pending requests (flush or discard) */
+               list_del_init(&req->queuelist);
+               BUG_ON(req->nr_phys_segments > segs);
+               blk_requeue_request(info->rq, req);
+       }
        spin_unlock_irq(&info->io_lock);
 
+       while ((bio = bio_list_pop(&bio_list)) != NULL) {
+               /* Traverse the list of pending bios and re-queue them */
+               if (bio_segments(bio) > segs) {
+                       /*
+                        * This bio has more segments than what we can
+                        * handle, we have to split it.
+                        */
+                       pending = (bio_segments(bio) + segs - 1) / segs;
+                       split_bio = kzalloc(sizeof(*split_bio), GFP_NOIO);
+                       BUG_ON(split_bio == NULL);
+                       atomic_set(&split_bio->pending, pending);
+                       split_bio->bio = bio;
+                       for (i = 0; i < pending; i++) {
+                               offset = (i * segs * PAGE_SIZE) >> 9;
+                               size = min((unsigned int)(segs * PAGE_SIZE) >> 9,
+                                          (unsigned int)(bio->bi_size >> 9) - offset);
+                               cloned_bio = bio_clone(bio, GFP_NOIO);
+                               BUG_ON(cloned_bio == NULL);
+                               trim_bio(cloned_bio, offset, size);
+                               cloned_bio->bi_private = split_bio;
+                               cloned_bio->bi_end_io = split_bio_end;
+                               submit_bio(cloned_bio->bi_rw, cloned_bio);
+                       }
+                       /*
+                        * Now we have to wait for all those smaller bios to
+                        * end, so we can also end the "parent" bio.
+                        */
+                       continue;
+               }
+               /* We don't need to split this bio */
+               submit_bio(bio->bi_rw, bio);
+       }
+
        return 0;
 }
 
@@ -1308,8 +1556,12 @@ static int blkfront_resume(struct xenbus_device *dev)
        blkif_free(info, info->connected == BLKIF_STATE_CONNECTED);
 
        err = talk_to_blkback(dev, info);
-       if (info->connected == BLKIF_STATE_SUSPENDED && !err)
-               err = blkif_recover(info);
+
+       /*
+        * We have to wait for the backend to switch to
+        * connected state, since we want to read which
+        * features it supports.
+        */
 
        return err;
 }
@@ -1387,6 +1639,60 @@ static void blkfront_setup_discard(struct blkfront_info *info)
        kfree(type);
 }
 
+static int blkfront_setup_indirect(struct blkfront_info *info)
+{
+       unsigned int indirect_segments, segs;
+       int err, i;
+
+       err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
+                           "feature-max-indirect-segments", "%u", &indirect_segments,
+                           NULL);
+       if (err) {
+               info->max_indirect_segments = 0;
+               segs = BLKIF_MAX_SEGMENTS_PER_REQUEST;
+       } else {
+               info->max_indirect_segments = min(indirect_segments,
+                                                 xen_blkif_max_segments);
+               segs = info->max_indirect_segments;
+       }
+
+       err = fill_grant_buffer(info, (segs + INDIRECT_GREFS(segs)) * BLK_RING_SIZE);
+       if (err)
+               goto out_of_memory;
+
+       for (i = 0; i < BLK_RING_SIZE; i++) {
+               info->shadow[i].grants_used = kzalloc(
+                       sizeof(info->shadow[i].grants_used[0]) * segs,
+                       GFP_NOIO);
+               info->shadow[i].sg = kzalloc(sizeof(info->shadow[i].sg[0]) * segs, GFP_NOIO);
+               if (info->max_indirect_segments)
+                       info->shadow[i].indirect_grants = kzalloc(
+                               sizeof(info->shadow[i].indirect_grants[0]) *
+                               INDIRECT_GREFS(segs),
+                               GFP_NOIO);
+               if ((info->shadow[i].grants_used == NULL) ||
+                       (info->shadow[i].sg == NULL) ||
+                    (info->max_indirect_segments &&
+                    (info->shadow[i].indirect_grants == NULL)))
+                       goto out_of_memory;
+               sg_init_table(info->shadow[i].sg, segs);
+       }
+
+
+       return 0;
+
+out_of_memory:
+       for (i = 0; i < BLK_RING_SIZE; i++) {
+               kfree(info->shadow[i].grants_used);
+               info->shadow[i].grants_used = NULL;
+               kfree(info->shadow[i].sg);
+               info->shadow[i].sg = NULL;
+               kfree(info->shadow[i].indirect_grants);
+               info->shadow[i].indirect_grants = NULL;
+       }
+       return -ENOMEM;
+}
+
 /*
  * Invoked when the backend is finally 'ready' (and has told produced
  * the details about the physical device - #sectors, size, etc).
@@ -1395,6 +1701,7 @@ static void blkfront_connect(struct blkfront_info *info)
 {
        unsigned long long sectors;
        unsigned long sector_size;
+       unsigned int physical_sector_size;
        unsigned int binfo;
        int err;
        int barrier, flush, discard, persistent;
@@ -1414,8 +1721,15 @@ static void blkfront_connect(struct blkfront_info *info)
                set_capacity(info->gd, sectors);
                revalidate_disk(info->gd);
 
-               /* fall through */
+               return;
        case BLKIF_STATE_SUSPENDED:
+               /*
+                * If we are recovering from suspension, we need to wait
+                * for the backend to announce it's features before
+                * reconnecting, at least we need to know if the backend
+                * supports indirect descriptors, and how many.
+                */
+               blkif_recover(info);
                return;
 
        default:
@@ -1437,6 +1751,16 @@ static void blkfront_connect(struct blkfront_info *info)
                return;
        }
 
+       /*
+        * physcial-sector-size is a newer field, so old backends may not
+        * provide this. Assume physical sector size to be the same as
+        * sector_size in that case.
+        */
+       err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
+                          "physical-sector-size", "%u", &physical_sector_size);
+       if (err != 1)
+               physical_sector_size = sector_size;
+
        info->feature_flush = 0;
        info->flush_op = 0;
 
@@ -1483,7 +1807,15 @@ static void blkfront_connect(struct blkfront_info *info)
        else
                info->feature_persistent = persistent;
 
-       err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size);
+       err = blkfront_setup_indirect(info);
+       if (err) {
+               xenbus_dev_fatal(info->xbdev, err, "setup_indirect at %s",
+                                info->xbdev->otherend);
+               return;
+       }
+
+       err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size,
+                                 physical_sector_size);
        if (err) {
                xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s",
                                 info->xbdev->otherend);
index bf5d2477cb77c296dac3a63b3aea2e8a2ec5ce0a..15f2e7025b78e20abcdafc61dee7718800ff1824 100644 (file)
@@ -129,7 +129,8 @@ parisc_agp_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
        off_t j, io_pg_start;
        int io_pg_count;
 
-       if (type != 0 || mem->type != 0) {
+       if (type != mem->type ||
+               agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type)) {
                return -EINVAL;
        }
 
@@ -175,7 +176,8 @@ parisc_agp_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
        struct _parisc_agp_info *info = &parisc_agp_info;
        int i, io_pg_start, io_pg_count;
 
-       if (type != 0 || mem->type != 0) {
+       if (type != mem->type ||
+               agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type)) {
                return -EINVAL;
        }
 
index 1b456fe9b87a12f98e8a6d691487c252271cb3e6..fc45567ad3acef079db496c9a2f495e19e5b5bba 100644 (file)
@@ -272,9 +272,12 @@ static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev,
        unsigned long flags;
 
        spin_lock_irqsave(&portdev->ports_lock, flags);
-       list_for_each_entry(port, &portdev->ports, list)
-               if (port->cdev->dev == dev)
+       list_for_each_entry(port, &portdev->ports, list) {
+               if (port->cdev->dev == dev) {
+                       kref_get(&port->kref);
                        goto out;
+               }
+       }
        port = NULL;
 out:
        spin_unlock_irqrestore(&portdev->ports_lock, flags);
@@ -746,6 +749,10 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
 
        port = filp->private_data;
 
+       /* Port is hot-unplugged. */
+       if (!port->guest_connected)
+               return -ENODEV;
+
        if (!port_has_data(port)) {
                /*
                 * If nothing's connected on the host just return 0 in
@@ -762,7 +769,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
                if (ret < 0)
                        return ret;
        }
-       /* Port got hot-unplugged. */
+       /* Port got hot-unplugged while we were waiting above. */
        if (!port->guest_connected)
                return -ENODEV;
        /*
@@ -932,13 +939,25 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
        if (is_rproc_serial(port->out_vq->vdev))
                return -EINVAL;
 
+       /*
+        * pipe->nrbufs == 0 means there are no data to transfer,
+        * so this returns just 0 for no data.
+        */
+       pipe_lock(pipe);
+       if (!pipe->nrbufs) {
+               ret = 0;
+               goto error_out;
+       }
+
        ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
        if (ret < 0)
-               return ret;
+               goto error_out;
 
        buf = alloc_buf(port->out_vq, 0, pipe->nrbufs);
-       if (!buf)
-               return -ENOMEM;
+       if (!buf) {
+               ret = -ENOMEM;
+               goto error_out;
+       }
 
        sgl.n = 0;
        sgl.len = 0;
@@ -946,12 +965,17 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
        sgl.sg = buf->sg;
        sg_init_table(sgl.sg, sgl.size);
        ret = __splice_from_pipe(pipe, &sd, pipe_to_sg);
+       pipe_unlock(pipe);
        if (likely(ret > 0))
                ret = __send_to_port(port, buf->sg, sgl.n, sgl.len, buf, true);
 
        if (unlikely(ret <= 0))
                free_buf(buf, true);
        return ret;
+
+error_out:
+       pipe_unlock(pipe);
+       return ret;
 }
 
 static unsigned int port_fops_poll(struct file *filp, poll_table *wait)
@@ -1019,14 +1043,14 @@ static int port_fops_open(struct inode *inode, struct file *filp)
        struct port *port;
        int ret;
 
+       /* We get the port with a kref here */
        port = find_port_by_devt(cdev->dev);
+       if (!port) {
+               /* Port was unplugged before we could proceed */
+               return -ENXIO;
+       }
        filp->private_data = port;
 
-       /* Prevent against a port getting hot-unplugged at the same time */
-       spin_lock_irq(&port->portdev->ports_lock);
-       kref_get(&port->kref);
-       spin_unlock_irq(&port->portdev->ports_lock);
-
        /*
         * Don't allow opening of console port devices -- that's done
         * via /dev/hvc
@@ -1498,14 +1522,6 @@ static void remove_port(struct kref *kref)
 
        port = container_of(kref, struct port, kref);
 
-       sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
-       device_destroy(pdrvdata.class, port->dev->devt);
-       cdev_del(port->cdev);
-
-       kfree(port->name);
-
-       debugfs_remove(port->debugfs_file);
-
        kfree(port);
 }
 
@@ -1539,12 +1555,14 @@ static void unplug_port(struct port *port)
        spin_unlock_irq(&port->portdev->ports_lock);
 
        if (port->guest_connected) {
+               /* Let the app know the port is going down. */
+               send_sigio_to_port(port);
+
+               /* Do this after sigio is actually sent */
                port->guest_connected = false;
                port->host_connected = false;
-               wake_up_interruptible(&port->waitqueue);
 
-               /* Let the app know the port is going down. */
-               send_sigio_to_port(port);
+               wake_up_interruptible(&port->waitqueue);
        }
 
        if (is_console_port(port)) {
@@ -1563,6 +1581,14 @@ static void unplug_port(struct port *port)
         */
        port->portdev = NULL;
 
+       sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
+       device_destroy(pdrvdata.class, port->dev->devt);
+       cdev_del(port->cdev);
+
+       kfree(port->name);
+
+       debugfs_remove(port->debugfs_file);
+
        /*
         * Locks around here are not necessary - a port can't be
         * opened after we removed the port struct from ports_list
index 1bdb882c845bd48a96597bb8f65c2cbe2a3c03c2..4e5739773c33a25f6bf5503e9261b18a11a473d2 100644 (file)
@@ -581,11 +581,15 @@ struct samsung_div_clock exynos4x12_div_clks[] __initdata = {
        DIV(none, "div_spi1_isp", "mout_spi1_isp", E4X12_DIV_ISP, 16, 4),
        DIV(none, "div_spi1_isp_pre", "div_spi1_isp", E4X12_DIV_ISP, 20, 8),
        DIV(none, "div_uart_isp", "mout_uart_isp", E4X12_DIV_ISP, 28, 4),
-       DIV(div_isp0, "div_isp0", "aclk200", E4X12_DIV_ISP0, 0, 3),
-       DIV(div_isp1, "div_isp1", "aclk200", E4X12_DIV_ISP0, 4, 3),
+       DIV_F(div_isp0, "div_isp0", "aclk200", E4X12_DIV_ISP0, 0, 3,
+                                               CLK_GET_RATE_NOCACHE, 0),
+       DIV_F(div_isp1, "div_isp1", "aclk200", E4X12_DIV_ISP0, 4, 3,
+                                               CLK_GET_RATE_NOCACHE, 0),
        DIV(none, "div_mpwm", "div_isp1", E4X12_DIV_ISP1, 0, 3),
-       DIV(div_mcuisp0, "div_mcuisp0", "aclk400_mcuisp", E4X12_DIV_ISP1, 4, 3),
-       DIV(div_mcuisp1, "div_mcuisp1", "div_mcuisp0", E4X12_DIV_ISP1, 8, 3),
+       DIV_F(div_mcuisp0, "div_mcuisp0", "aclk400_mcuisp", E4X12_DIV_ISP1,
+                                               4, 3, CLK_GET_RATE_NOCACHE, 0),
+       DIV_F(div_mcuisp1, "div_mcuisp1", "div_mcuisp0", E4X12_DIV_ISP1,
+                                               8, 3, CLK_GET_RATE_NOCACHE, 0),
        DIV(sclk_fimg2d, "sclk_fimg2d", "mout_g2d", DIV_DMC1, 0, 4),
 };
 
@@ -863,57 +867,57 @@ struct samsung_gate_clock exynos4x12_gate_clks[] __initdata = {
        GATE_DA(i2s0, "samsung-i2s.0", "i2s0", "aclk100",
                        E4X12_GATE_IP_MAUDIO, 3, 0, 0, "iis"),
        GATE(fimc_isp, "isp", "aclk200", E4X12_GATE_ISP0, 0,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(fimc_drc, "drc", "aclk200", E4X12_GATE_ISP0, 1,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(fimc_fd, "fd", "aclk200", E4X12_GATE_ISP0, 2,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(fimc_lite0, "lite0", "aclk200", E4X12_GATE_ISP0, 3,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(fimc_lite1, "lite1", "aclk200", E4X12_GATE_ISP0, 4,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(mcuisp, "mcuisp", "aclk200", E4X12_GATE_ISP0, 5,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(gicisp, "gicisp", "aclk200", E4X12_GATE_ISP0, 7,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(smmu_isp, "smmu_isp", "aclk200", E4X12_GATE_ISP0, 8,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(smmu_drc, "smmu_drc", "aclk200", E4X12_GATE_ISP0, 9,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(smmu_fd, "smmu_fd", "aclk200", E4X12_GATE_ISP0, 10,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(smmu_lite0, "smmu_lite0", "aclk200", E4X12_GATE_ISP0, 11,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(smmu_lite1, "smmu_lite1", "aclk200", E4X12_GATE_ISP0, 12,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(ppmuispmx, "ppmuispmx", "aclk200", E4X12_GATE_ISP0, 20,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(ppmuispx, "ppmuispx", "aclk200", E4X12_GATE_ISP0, 21,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(mcuctl_isp, "mcuctl_isp", "aclk200", E4X12_GATE_ISP0, 23,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(mpwm_isp, "mpwm_isp", "aclk200", E4X12_GATE_ISP0, 24,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(i2c0_isp, "i2c0_isp", "aclk200", E4X12_GATE_ISP0, 25,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(i2c1_isp, "i2c1_isp", "aclk200", E4X12_GATE_ISP0, 26,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(mtcadc_isp, "mtcadc_isp", "aclk200", E4X12_GATE_ISP0, 27,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(pwm_isp, "pwm_isp", "aclk200", E4X12_GATE_ISP0, 28,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(wdt_isp, "wdt_isp", "aclk200", E4X12_GATE_ISP0, 30,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(uart_isp, "uart_isp", "aclk200", E4X12_GATE_ISP0, 31,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(asyncaxim, "asyncaxim", "aclk200", E4X12_GATE_ISP1, 0,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(smmu_ispcx, "smmu_ispcx", "aclk200", E4X12_GATE_ISP1, 4,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(spi0_isp, "spi0_isp", "aclk200", E4X12_GATE_ISP1, 12,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(spi1_isp, "spi1_isp", "aclk200", E4X12_GATE_ISP1, 13,
-                       CLK_IGNORE_UNUSED, 0),
+                       CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
        GATE(g2d, "g2d", "aclk200", GATE_IP_DMC, 23, 0, 0),
 };
 
index 5c205b60a82a21aa7bd780f17133c9d6a00bcf5c..089d3e30e2216e44b20067fdaf9ded66708d0bb2 100644 (file)
@@ -71,6 +71,7 @@ static DEFINE_SPINLOCK(armpll_lock);
 static DEFINE_SPINLOCK(ddrpll_lock);
 static DEFINE_SPINLOCK(iopll_lock);
 static DEFINE_SPINLOCK(armclk_lock);
+static DEFINE_SPINLOCK(swdtclk_lock);
 static DEFINE_SPINLOCK(ddrclk_lock);
 static DEFINE_SPINLOCK(dciclk_lock);
 static DEFINE_SPINLOCK(gem0clk_lock);
@@ -293,7 +294,7 @@ static void __init zynq_clk_setup(struct device_node *np)
        }
        clks[swdt] = clk_register_mux(NULL, clk_output_name[swdt],
                        swdt_ext_clk_mux_parents, 2, CLK_SET_RATE_PARENT,
-                       SLCR_SWDT_CLK_SEL, 0, 1, 0, &gem0clk_lock);
+                       SLCR_SWDT_CLK_SEL, 0, 1, 0, &swdtclk_lock);
 
        /* DDR clocks */
        clk = clk_register_divider(NULL, "ddr2x_div", "ddrpll", 0,
@@ -364,8 +365,9 @@ static void __init zynq_clk_setup(struct device_node *np)
                        CLK_SET_RATE_PARENT, SLCR_GEM0_CLK_CTRL, 20, 6,
                        CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
                        &gem0clk_lock);
-       clk = clk_register_mux(NULL, "gem0_emio_mux", gem0_mux_parents, 2, 0,
-                       SLCR_GEM0_CLK_CTRL, 6, 1, 0, &gem0clk_lock);
+       clk = clk_register_mux(NULL, "gem0_emio_mux", gem0_mux_parents, 2,
+                       CLK_SET_RATE_PARENT, SLCR_GEM0_CLK_CTRL, 6, 1, 0,
+                       &gem0clk_lock);
        clks[gem0] = clk_register_gate(NULL, clk_output_name[gem0],
                        "gem0_emio_mux", CLK_SET_RATE_PARENT,
                        SLCR_GEM0_CLK_CTRL, 0, 0, &gem0clk_lock);
@@ -386,8 +388,9 @@ static void __init zynq_clk_setup(struct device_node *np)
                        CLK_SET_RATE_PARENT, SLCR_GEM1_CLK_CTRL, 20, 6,
                        CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
                        &gem1clk_lock);
-       clk = clk_register_mux(NULL, "gem1_emio_mux", gem1_mux_parents, 2, 0,
-                       SLCR_GEM1_CLK_CTRL, 6, 1, 0, &gem1clk_lock);
+       clk = clk_register_mux(NULL, "gem1_emio_mux", gem1_mux_parents, 2,
+                       CLK_SET_RATE_PARENT, SLCR_GEM1_CLK_CTRL, 6, 1, 0,
+                       &gem1clk_lock);
        clks[gem1] = clk_register_gate(NULL, clk_output_name[gem1],
                        "gem1_emio_mux", CLK_SET_RATE_PARENT,
                        SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock);
index 053d846ab5b108931ccbeacb67ebc7c85696d0f6..ffadd836e0b5173a96d30f20b2f16faeda823c57 100644 (file)
@@ -123,7 +123,7 @@ static int arch_timer_set_next_event_phys(unsigned long evt,
        return 0;
 }
 
-static int __cpuinit arch_timer_setup(struct clock_event_device *clk)
+static int arch_timer_setup(struct clock_event_device *clk)
 {
        clk->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP;
        clk->name = "arch_sys_timer";
@@ -221,7 +221,7 @@ struct timecounter *arch_timer_get_timecounter(void)
        return &timecounter;
 }
 
-static void __cpuinit arch_timer_stop(struct clock_event_device *clk)
+static void arch_timer_stop(struct clock_event_device *clk)
 {
        pr_debug("arch_timer_teardown disable IRQ%d cpu #%d\n",
                 clk->irq, smp_processor_id());
@@ -237,7 +237,7 @@ static void __cpuinit arch_timer_stop(struct clock_event_device *clk)
        clk->set_mode(CLOCK_EVT_MODE_UNUSED, clk);
 }
 
-static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
+static int arch_timer_cpu_notify(struct notifier_block *self,
                                           unsigned long action, void *hcpu)
 {
        /*
@@ -256,7 +256,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
+static struct notifier_block arch_timer_cpu_nb = {
        .notifier_call = arch_timer_cpu_notify,
 };
 
index db8afc7427a6b6a3c9548b9dd60d4ba2d1dbc54e..b66c1f36066ced2f7bc8ae68677397fddfb3f4f0 100644 (file)
@@ -164,7 +164,7 @@ static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static int __cpuinit gt_clockevents_init(struct clock_event_device *clk)
+static int gt_clockevents_init(struct clock_event_device *clk)
 {
        int cpu = smp_processor_id();
 
@@ -221,8 +221,8 @@ static void __init gt_clocksource_init(void)
        clocksource_register_hz(&gt_clocksource, gt_clk_rate);
 }
 
-static int __cpuinit gt_cpu_notify(struct notifier_block *self,
-                                          unsigned long action, void *hcpu)
+static int gt_cpu_notify(struct notifier_block *self, unsigned long action,
+                        void *hcpu)
 {
        switch (action & ~CPU_TASKS_FROZEN) {
        case CPU_STARTING:
@@ -235,7 +235,7 @@ static int __cpuinit gt_cpu_notify(struct notifier_block *self,
 
        return NOTIFY_OK;
 }
-static struct notifier_block gt_cpu_nb __cpuinitdata = {
+static struct notifier_block gt_cpu_nb = {
        .notifier_call = gt_cpu_notify,
 };
 
index 1f55f96203381bd361197bd954ddaafa399b3acb..b3eb582d6a6f1956bc870067188bb03a090fd30b 100644 (file)
@@ -25,7 +25,7 @@ static void dummy_timer_set_mode(enum clock_event_mode mode,
         */
 }
 
-static void __cpuinit dummy_timer_setup(void)
+static void dummy_timer_setup(void)
 {
        int cpu = smp_processor_id();
        struct clock_event_device *evt = __this_cpu_ptr(&dummy_timer_evt);
@@ -41,7 +41,7 @@ static void __cpuinit dummy_timer_setup(void)
        clockevents_register_device(evt);
 }
 
-static int __cpuinit dummy_timer_cpu_notify(struct notifier_block *self,
+static int dummy_timer_cpu_notify(struct notifier_block *self,
                                      unsigned long action, void *hcpu)
 {
        if ((action & ~CPU_TASKS_FROZEN) == CPU_STARTING)
@@ -50,7 +50,7 @@ static int __cpuinit dummy_timer_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block dummy_timer_cpu_nb __cpuinitdata = {
+static struct notifier_block dummy_timer_cpu_nb = {
        .notifier_call = dummy_timer_cpu_notify,
 };
 
index a70480409ea526a9233e9af6025c50ade2497167..b2bbc415f12055886a53288d1cca2d11a91a304c 100644 (file)
@@ -400,7 +400,7 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-static int __cpuinit exynos4_local_timer_setup(struct clock_event_device *evt)
+static int exynos4_local_timer_setup(struct clock_event_device *evt)
 {
        struct mct_clock_event_device *mevt;
        unsigned int cpu = smp_processor_id();
@@ -448,7 +448,7 @@ static void exynos4_local_timer_stop(struct clock_event_device *evt)
                disable_percpu_irq(mct_irqs[MCT_L0_IRQ]);
 }
 
-static struct local_timer_ops exynos4_mct_tick_ops __cpuinitdata = {
+static struct local_timer_ops exynos4_mct_tick_ops = {
        .setup  = exynos4_local_timer_setup,
        .stop   = exynos4_local_timer_stop,
 };
index 6722f0e2fe40bc9f4767928905df04c737b549fe..9e4db41abe3ccc0a84b350e159f7fa2ed6b001b2 100644 (file)
@@ -109,7 +109,7 @@ unsigned long long sched_clock(void)
        return ticks << HARDWARE_TO_NS_SHIFT;
 }
 
-static void __cpuinit arch_timer_setup(unsigned int cpu)
+static void arch_timer_setup(unsigned int cpu)
 {
        unsigned int txdivtime;
        struct clock_event_device *clk = &per_cpu(local_clockevent, cpu);
@@ -154,7 +154,7 @@ static void __cpuinit arch_timer_setup(unsigned int cpu)
        }
 }
 
-static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
+static int arch_timer_cpu_notify(struct notifier_block *self,
                                           unsigned long action, void *hcpu)
 {
        int cpu = (long)hcpu;
@@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
+static struct notifier_block arch_timer_cpu_nb = {
        .notifier_call = arch_timer_cpu_notify,
 };
 
index efdca3263afef24fc557862dc7f0e622effdb72f..1b04b7e1d39b91c223c993baa88b44d408c3609e 100644 (file)
@@ -167,7 +167,7 @@ static irqreturn_t armada_370_xp_timer_interrupt(int irq, void *dev_id)
 /*
  * Setup the local clock events for a CPU.
  */
-static int __cpuinit armada_370_xp_timer_setup(struct clock_event_device *evt)
+static int armada_370_xp_timer_setup(struct clock_event_device *evt)
 {
        u32 u;
        int cpu = smp_processor_id();
@@ -205,7 +205,7 @@ static void  armada_370_xp_timer_stop(struct clock_event_device *evt)
        disable_percpu_irq(evt->irq);
 }
 
-static struct local_timer_ops armada_370_xp_local_timer_ops __cpuinitdata = {
+static struct local_timer_ops armada_370_xp_local_timer_ops = {
        .setup  = armada_370_xp_timer_setup,
        .stop   =  armada_370_xp_timer_stop,
 };
index e5dc9129ca263f0a9cba409f7d866e1dc73b086c..62876baa3ab9c2f69c680e316a4801b11e89777f 100644 (file)
@@ -184,7 +184,7 @@ static struct irqaction sirfsoc_timer1_irq = {
        .handler = sirfsoc_timer_interrupt,
 };
 
-static int __cpuinit sirfsoc_local_timer_setup(struct clock_event_device *ce)
+static int sirfsoc_local_timer_setup(struct clock_event_device *ce)
 {
        /* Use existing clock_event for cpu 0 */
        if (!smp_processor_id())
@@ -216,7 +216,7 @@ static void sirfsoc_local_timer_stop(struct clock_event_device *ce)
        remove_irq(sirfsoc_timer1_irq.irq, &sirfsoc_timer1_irq);
 }
 
-static struct local_timer_ops sirfsoc_local_timer_ops __cpuinitdata = {
+static struct local_timer_ops sirfsoc_local_timer_ops = {
        .setup  = sirfsoc_local_timer_setup,
        .stop   = sirfsoc_local_timer_stop,
 };
index 0937b8d6c2a4cebe904bbc9c5cdbf24afd2a681f..f0a5e2b0eb8a9584f1e1d55ffac92bfd2800fbba 100644 (file)
@@ -1177,14 +1177,11 @@ static int __cpufreq_remove_dev(struct device *dev,
                                __func__, cpu_dev->id, cpu);
        }
 
-       if ((cpus == 1) && (cpufreq_driver->target))
-               __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT);
-
-       pr_debug("%s: removing link, cpu: %d\n", __func__, cpu);
-       cpufreq_cpu_put(data);
-
        /* If cpu is last user of policy, free policy */
        if (cpus == 1) {
+               if (cpufreq_driver->target)
+                       __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT);
+
                lock_policy_rwsem_read(cpu);
                kobj = &data->kobj;
                cmp = &data->kobj_unregister;
@@ -1205,9 +1202,13 @@ static int __cpufreq_remove_dev(struct device *dev,
                free_cpumask_var(data->related_cpus);
                free_cpumask_var(data->cpus);
                kfree(data);
-       } else if (cpufreq_driver->target) {
-               __cpufreq_governor(data, CPUFREQ_GOV_START);
-               __cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
+       } else {
+               pr_debug("%s: removing link, cpu: %d\n", __func__, cpu);
+               cpufreq_cpu_put(data);
+               if (cpufreq_driver->target) {
+                       __cpufreq_governor(data, CPUFREQ_GOV_START);
+                       __cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
+               }
        }
 
        per_cpu(cpufreq_policy_cpu, cpu) = -1;
@@ -1932,7 +1933,7 @@ no_policy:
 }
 EXPORT_SYMBOL(cpufreq_update_policy);
 
-static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
+static int cpufreq_cpu_callback(struct notifier_block *nfb,
                                        unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long)hcpu;
@@ -1942,13 +1943,15 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
        if (dev) {
                switch (action) {
                case CPU_ONLINE:
+               case CPU_ONLINE_FROZEN:
                        cpufreq_add_dev(dev, NULL);
                        break;
                case CPU_DOWN_PREPARE:
-               case CPU_UP_CANCELED_FROZEN:
+               case CPU_DOWN_PREPARE_FROZEN:
                        __cpufreq_remove_dev(dev, NULL);
                        break;
                case CPU_DOWN_FAILED:
+               case CPU_DOWN_FAILED_FROZEN:
                        cpufreq_add_dev(dev, NULL);
                        break;
                }
index 0ceb2eff5a7e7044adfcf37a5522b131017d6088..f97cb3d8c5a232a60f319e04da5c0616624925d4 100644 (file)
@@ -221,8 +221,8 @@ static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf,
        return count;
 }
 
-static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
-               size_t count)
+static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data,
+               const char *buf, size_t count)
 {
        struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
        unsigned int input, j;
@@ -235,10 +235,10 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
        if (input > 1)
                input = 1;
 
-       if (input == cs_tuners->ignore_nice) /* nothing to do */
+       if (input == cs_tuners->ignore_nice_load) /* nothing to do */
                return count;
 
-       cs_tuners->ignore_nice = input;
+       cs_tuners->ignore_nice_load = input;
 
        /* we need to re-evaluate prev_cpu_idle */
        for_each_online_cpu(j) {
@@ -246,7 +246,7 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
                dbs_info = &per_cpu(cs_cpu_dbs_info, j);
                dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
                                        &dbs_info->cdbs.prev_cpu_wall, 0);
-               if (cs_tuners->ignore_nice)
+               if (cs_tuners->ignore_nice_load)
                        dbs_info->cdbs.prev_cpu_nice =
                                kcpustat_cpu(j).cpustat[CPUTIME_NICE];
        }
@@ -279,7 +279,7 @@ show_store_one(cs, sampling_rate);
 show_store_one(cs, sampling_down_factor);
 show_store_one(cs, up_threshold);
 show_store_one(cs, down_threshold);
-show_store_one(cs, ignore_nice);
+show_store_one(cs, ignore_nice_load);
 show_store_one(cs, freq_step);
 declare_show_sampling_rate_min(cs);
 
@@ -287,7 +287,7 @@ gov_sys_pol_attr_rw(sampling_rate);
 gov_sys_pol_attr_rw(sampling_down_factor);
 gov_sys_pol_attr_rw(up_threshold);
 gov_sys_pol_attr_rw(down_threshold);
-gov_sys_pol_attr_rw(ignore_nice);
+gov_sys_pol_attr_rw(ignore_nice_load);
 gov_sys_pol_attr_rw(freq_step);
 gov_sys_pol_attr_ro(sampling_rate_min);
 
@@ -297,7 +297,7 @@ static struct attribute *dbs_attributes_gov_sys[] = {
        &sampling_down_factor_gov_sys.attr,
        &up_threshold_gov_sys.attr,
        &down_threshold_gov_sys.attr,
-       &ignore_nice_gov_sys.attr,
+       &ignore_nice_load_gov_sys.attr,
        &freq_step_gov_sys.attr,
        NULL
 };
@@ -313,7 +313,7 @@ static struct attribute *dbs_attributes_gov_pol[] = {
        &sampling_down_factor_gov_pol.attr,
        &up_threshold_gov_pol.attr,
        &down_threshold_gov_pol.attr,
-       &ignore_nice_gov_pol.attr,
+       &ignore_nice_load_gov_pol.attr,
        &freq_step_gov_pol.attr,
        NULL
 };
@@ -338,7 +338,7 @@ static int cs_init(struct dbs_data *dbs_data)
        tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD;
        tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD;
        tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
-       tuners->ignore_nice = 0;
+       tuners->ignore_nice_load = 0;
        tuners->freq_step = DEF_FREQUENCY_STEP;
 
        dbs_data->tuners = tuners;
index 464587697561d177bf5d9675b58a2eae0c89e507..e59afaa9da23af0dfd826751e817ab6b41e94a0b 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
-#include <linux/cpu.h>
 
 #include "cpufreq_governor.h"
 
@@ -48,9 +47,9 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
        unsigned int j;
 
        if (dbs_data->cdata->governor == GOV_ONDEMAND)
-               ignore_nice = od_tuners->ignore_nice;
+               ignore_nice = od_tuners->ignore_nice_load;
        else
-               ignore_nice = cs_tuners->ignore_nice;
+               ignore_nice = cs_tuners->ignore_nice_load;
 
        policy = cdbs->cur_policy;
 
@@ -137,10 +136,8 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
        if (!all_cpus) {
                __gov_queue_work(smp_processor_id(), dbs_data, delay);
        } else {
-               get_online_cpus();
                for_each_cpu(i, policy->cpus)
                        __gov_queue_work(i, dbs_data, delay);
-               put_online_cpus();
        }
 }
 EXPORT_SYMBOL_GPL(gov_queue_work);
@@ -301,12 +298,12 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
                cs_tuners = dbs_data->tuners;
                cs_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu);
                sampling_rate = cs_tuners->sampling_rate;
-               ignore_nice = cs_tuners->ignore_nice;
+               ignore_nice = cs_tuners->ignore_nice_load;
        } else {
                od_tuners = dbs_data->tuners;
                od_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu);
                sampling_rate = od_tuners->sampling_rate;
-               ignore_nice = od_tuners->ignore_nice;
+               ignore_nice = od_tuners->ignore_nice_load;
                od_ops = dbs_data->cdata->gov_ops;
                io_busy = od_tuners->io_is_busy;
        }
index 6663ec3b30565ac7efb6a7b5842e301ad2160bba..d5f12b4b11b8af09c608bd6f74f01601e0a91f2d 100644 (file)
@@ -165,7 +165,7 @@ struct cs_cpu_dbs_info_s {
 
 /* Per policy Governers sysfs tunables */
 struct od_dbs_tuners {
-       unsigned int ignore_nice;
+       unsigned int ignore_nice_load;
        unsigned int sampling_rate;
        unsigned int sampling_down_factor;
        unsigned int up_threshold;
@@ -175,7 +175,7 @@ struct od_dbs_tuners {
 };
 
 struct cs_dbs_tuners {
-       unsigned int ignore_nice;
+       unsigned int ignore_nice_load;
        unsigned int sampling_rate;
        unsigned int sampling_down_factor;
        unsigned int up_threshold;
index 93eb5cbcc1f639bf1ec52479a169a49deecd72f5..c087347d66884f03a4f1b2a94bf4fcbaceeda7a0 100644 (file)
@@ -403,8 +403,8 @@ static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data,
        return count;
 }
 
-static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
-               size_t count)
+static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data,
+               const char *buf, size_t count)
 {
        struct od_dbs_tuners *od_tuners = dbs_data->tuners;
        unsigned int input;
@@ -419,10 +419,10 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
        if (input > 1)
                input = 1;
 
-       if (input == od_tuners->ignore_nice) { /* nothing to do */
+       if (input == od_tuners->ignore_nice_load) { /* nothing to do */
                return count;
        }
-       od_tuners->ignore_nice = input;
+       od_tuners->ignore_nice_load = input;
 
        /* we need to re-evaluate prev_cpu_idle */
        for_each_online_cpu(j) {
@@ -430,7 +430,7 @@ static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
                dbs_info = &per_cpu(od_cpu_dbs_info, j);
                dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
                        &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy);
-               if (od_tuners->ignore_nice)
+               if (od_tuners->ignore_nice_load)
                        dbs_info->cdbs.prev_cpu_nice =
                                kcpustat_cpu(j).cpustat[CPUTIME_NICE];
 
@@ -461,7 +461,7 @@ show_store_one(od, sampling_rate);
 show_store_one(od, io_is_busy);
 show_store_one(od, up_threshold);
 show_store_one(od, sampling_down_factor);
-show_store_one(od, ignore_nice);
+show_store_one(od, ignore_nice_load);
 show_store_one(od, powersave_bias);
 declare_show_sampling_rate_min(od);
 
@@ -469,7 +469,7 @@ gov_sys_pol_attr_rw(sampling_rate);
 gov_sys_pol_attr_rw(io_is_busy);
 gov_sys_pol_attr_rw(up_threshold);
 gov_sys_pol_attr_rw(sampling_down_factor);
-gov_sys_pol_attr_rw(ignore_nice);
+gov_sys_pol_attr_rw(ignore_nice_load);
 gov_sys_pol_attr_rw(powersave_bias);
 gov_sys_pol_attr_ro(sampling_rate_min);
 
@@ -478,7 +478,7 @@ static struct attribute *dbs_attributes_gov_sys[] = {
        &sampling_rate_gov_sys.attr,
        &up_threshold_gov_sys.attr,
        &sampling_down_factor_gov_sys.attr,
-       &ignore_nice_gov_sys.attr,
+       &ignore_nice_load_gov_sys.attr,
        &powersave_bias_gov_sys.attr,
        &io_is_busy_gov_sys.attr,
        NULL
@@ -494,7 +494,7 @@ static struct attribute *dbs_attributes_gov_pol[] = {
        &sampling_rate_gov_pol.attr,
        &up_threshold_gov_pol.attr,
        &sampling_down_factor_gov_pol.attr,
-       &ignore_nice_gov_pol.attr,
+       &ignore_nice_load_gov_pol.attr,
        &powersave_bias_gov_pol.attr,
        &io_is_busy_gov_pol.attr,
        NULL
@@ -544,7 +544,7 @@ static int od_init(struct dbs_data *dbs_data)
        }
 
        tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
-       tuners->ignore_nice = 0;
+       tuners->ignore_nice_load = 0;
        tuners->powersave_bias = default_powersave_bias;
        tuners->io_is_busy = should_io_be_busy();
 
index cd9e81713a71343b00f4c2e761f5f32c56824ab3..d37568c5ca9c36b32dc69a8361337450c0ca1ddc 100644 (file)
@@ -341,7 +341,7 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
        return 0;
 }
 
-static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
+static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
                                               unsigned long action,
                                               void *hcpu)
 {
@@ -353,13 +353,11 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
                cpufreq_update_policy(cpu);
                break;
        case CPU_DOWN_PREPARE:
+       case CPU_DOWN_PREPARE_FROZEN:
                cpufreq_stats_free_sysfs(cpu);
                break;
        case CPU_DEAD:
-               cpufreq_stats_free_table(cpu);
-               break;
-       case CPU_UP_CANCELED_FROZEN:
-               cpufreq_stats_free_sysfs(cpu);
+       case CPU_DEAD_FROZEN:
                cpufreq_stats_free_table(cpu);
                break;
        }
index 1fdb02b9f1ec84f221e8ba26dfeefd53105eb9a3..26321cdc19464f1cd3b23f7bf6575d5d97fa6ffc 100644 (file)
@@ -82,7 +82,7 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
        return freq_table[i].frequency;
 }
 
-static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy)
+static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
 {
        int res;
 
index 07f2840ad80596b529488f40808e10c70782f498..7cde885011ed3d1b15809f6d25c1a7f3ddc3adf1 100644 (file)
@@ -103,10 +103,10 @@ struct pstate_adjust_policy {
 static struct pstate_adjust_policy default_policy = {
        .sample_rate_ms = 10,
        .deadband = 0,
-       .setpoint = 109,
-       .p_gain_pct = 17,
+       .setpoint = 97,
+       .p_gain_pct = 20,
        .d_gain_pct = 0,
-       .i_gain_pct = 4,
+       .i_gain_pct = 0,
 };
 
 struct perf_limits {
@@ -468,12 +468,12 @@ static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
 static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu)
 {
        int32_t busy_scaled;
-       int32_t core_busy, turbo_pstate, current_pstate;
+       int32_t core_busy, max_pstate, current_pstate;
 
        core_busy = int_tofp(cpu->samples[cpu->sample_ptr].core_pct_busy);
-       turbo_pstate = int_tofp(cpu->pstate.turbo_pstate);
+       max_pstate = int_tofp(cpu->pstate.max_pstate);
        current_pstate = int_tofp(cpu->pstate.current_pstate);
-       busy_scaled = mul_fp(core_busy, div_fp(turbo_pstate, current_pstate));
+       busy_scaled = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
 
        return fp_toint(busy_scaled);
 }
@@ -617,7 +617,7 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
        return 0;
 }
 
-static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy)
+static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
 {
        int cpu = policy->cpu;
 
@@ -627,7 +627,7 @@ static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy)
        return 0;
 }
 
-static int __cpuinit intel_pstate_cpu_init(struct cpufreq_policy *policy)
+static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
 {
        int rc, min_pstate, max_pstate;
        struct cpudata *cpu;
index b6a0a7a406b06bf415de8e07f5d3730560d41ba0..8c49261df57dff642f63921d08a9d61ee41d95e3 100644 (file)
@@ -422,7 +422,7 @@ static int guess_fsb(int mult)
 }
 
 
-static int __cpuinit longhaul_get_ranges(void)
+static int longhaul_get_ranges(void)
 {
        unsigned int i, j, k = 0;
        unsigned int ratio;
@@ -526,7 +526,7 @@ static int __cpuinit longhaul_get_ranges(void)
 }
 
 
-static void __cpuinit longhaul_setup_voltagescaling(void)
+static void longhaul_setup_voltagescaling(void)
 {
        union msr_longhaul longhaul;
        struct mV_pos minvid, maxvid, vid;
@@ -780,7 +780,7 @@ static int longhaul_setup_southbridge(void)
        return 0;
 }
 
-static int __cpuinit longhaul_cpu_init(struct cpufreq_policy *policy)
+static int longhaul_cpu_init(struct cpufreq_policy *policy)
 {
        struct cpuinfo_x86 *c = &cpu_data(0);
        char *cpuname = NULL;
index e2dc436099d1006ed9d879cc802eedda7eae9deb..1928b923a57babb410da59091a2884bec7818ce4 100644 (file)
@@ -56,7 +56,7 @@ union msr_longhaul {
 /*
  * VIA C3 Samuel 1  & Samuel 2 (stepping 0)
  */
-static const int __cpuinitconst samuel1_mults[16] = {
+static const int samuel1_mults[16] = {
        -1, /* 0000 -> RESERVED */
        30, /* 0001 ->  3.0x */
        40, /* 0010 ->  4.0x */
@@ -75,7 +75,7 @@ static const int __cpuinitconst samuel1_mults[16] = {
        -1, /* 1111 -> RESERVED */
 };
 
-static const int __cpuinitconst samuel1_eblcr[16] = {
+static const int samuel1_eblcr[16] = {
        50, /* 0000 -> RESERVED */
        30, /* 0001 ->  3.0x */
        40, /* 0010 ->  4.0x */
@@ -97,7 +97,7 @@ static const int __cpuinitconst samuel1_eblcr[16] = {
 /*
  * VIA C3 Samuel2 Stepping 1->15
  */
-static const int __cpuinitconst samuel2_eblcr[16] = {
+static const int samuel2_eblcr[16] = {
        50,  /* 0000 ->  5.0x */
        30,  /* 0001 ->  3.0x */
        40,  /* 0010 ->  4.0x */
@@ -119,7 +119,7 @@ static const int __cpuinitconst samuel2_eblcr[16] = {
 /*
  * VIA C3 Ezra
  */
-static const int __cpuinitconst ezra_mults[16] = {
+static const int ezra_mults[16] = {
        100, /* 0000 -> 10.0x */
        30,  /* 0001 ->  3.0x */
        40,  /* 0010 ->  4.0x */
@@ -138,7 +138,7 @@ static const int __cpuinitconst ezra_mults[16] = {
        120, /* 1111 -> 12.0x */
 };
 
-static const int __cpuinitconst ezra_eblcr[16] = {
+static const int ezra_eblcr[16] = {
        50,  /* 0000 ->  5.0x */
        30,  /* 0001 ->  3.0x */
        40,  /* 0010 ->  4.0x */
@@ -160,7 +160,7 @@ static const int __cpuinitconst ezra_eblcr[16] = {
 /*
  * VIA C3 (Ezra-T) [C5M].
  */
-static const int __cpuinitconst ezrat_mults[32] = {
+static const int ezrat_mults[32] = {
        100, /* 0000 -> 10.0x */
        30,  /* 0001 ->  3.0x */
        40,  /* 0010 ->  4.0x */
@@ -196,7 +196,7 @@ static const int __cpuinitconst ezrat_mults[32] = {
        -1,  /* 1111 -> RESERVED (12.0x) */
 };
 
-static const int __cpuinitconst ezrat_eblcr[32] = {
+static const int ezrat_eblcr[32] = {
        50,  /* 0000 ->  5.0x */
        30,  /* 0001 ->  3.0x */
        40,  /* 0010 ->  4.0x */
@@ -235,7 +235,7 @@ static const int __cpuinitconst ezrat_eblcr[32] = {
 /*
  * VIA C3 Nehemiah */
 
-static const int __cpuinitconst nehemiah_mults[32] = {
+static const int nehemiah_mults[32] = {
        100, /* 0000 -> 10.0x */
        -1, /* 0001 -> 16.0x */
        40,  /* 0010 ->  4.0x */
@@ -270,7 +270,7 @@ static const int __cpuinitconst nehemiah_mults[32] = {
        -1, /* 1111 -> 12.0x */
 };
 
-static const int __cpuinitconst nehemiah_eblcr[32] = {
+static const int nehemiah_eblcr[32] = {
        50,  /* 0000 ->  5.0x */
        160, /* 0001 -> 16.0x */
        40,  /* 0010 ->  4.0x */
@@ -315,7 +315,7 @@ struct mV_pos {
        unsigned short pos;
 };
 
-static const struct mV_pos __cpuinitconst vrm85_mV[32] = {
+static const struct mV_pos vrm85_mV[32] = {
        {1250, 8},      {1200, 6},      {1150, 4},      {1100, 2},
        {1050, 0},      {1800, 30},     {1750, 28},     {1700, 26},
        {1650, 24},     {1600, 22},     {1550, 20},     {1500, 18},
@@ -326,14 +326,14 @@ static const struct mV_pos __cpuinitconst vrm85_mV[32] = {
        {1475, 17},     {1425, 15},     {1375, 13},     {1325, 11}
 };
 
-static const unsigned char __cpuinitconst mV_vrm85[32] = {
+static const unsigned char mV_vrm85[32] = {
        0x04,   0x14,   0x03,   0x13,   0x02,   0x12,   0x01,   0x11,
        0x00,   0x10,   0x0f,   0x1f,   0x0e,   0x1e,   0x0d,   0x1d,
        0x0c,   0x1c,   0x0b,   0x1b,   0x0a,   0x1a,   0x09,   0x19,
        0x08,   0x18,   0x07,   0x17,   0x06,   0x16,   0x05,   0x15
 };
 
-static const struct mV_pos __cpuinitconst mobilevrm_mV[32] = {
+static const struct mV_pos mobilevrm_mV[32] = {
        {1750, 31},     {1700, 30},     {1650, 29},     {1600, 28},
        {1550, 27},     {1500, 26},     {1450, 25},     {1400, 24},
        {1350, 23},     {1300, 22},     {1250, 21},     {1200, 20},
@@ -344,7 +344,7 @@ static const struct mV_pos __cpuinitconst mobilevrm_mV[32] = {
        {675, 3},       {650, 2},       {625, 1},       {600, 0}
 };
 
-static const unsigned char __cpuinitconst mV_mobilevrm[32] = {
+static const unsigned char mV_mobilevrm[32] = {
        0x1f,   0x1e,   0x1d,   0x1c,   0x1b,   0x1a,   0x19,   0x18,
        0x17,   0x16,   0x15,   0x14,   0x13,   0x12,   0x11,   0x10,
        0x0f,   0x0e,   0x0d,   0x0c,   0x0b,   0x0a,   0x09,   0x08,
index 8bc9f5fbbaeb25a07b29c3ea27245afac0e75d4b..0fe041d1f77f4a48f84542b11db0c4d07ee97b46 100644 (file)
@@ -33,7 +33,7 @@ static unsigned int longrun_low_freq, longrun_high_freq;
  * Reads the current LongRun policy by access to MSR_TMTA_LONGRUN_FLAGS
  * and MSR_TMTA_LONGRUN_CTRL
  */
-static void __cpuinit longrun_get_policy(struct cpufreq_policy *policy)
+static void longrun_get_policy(struct cpufreq_policy *policy)
 {
        u32 msr_lo, msr_hi;
 
@@ -163,7 +163,7 @@ static unsigned int longrun_get(unsigned int cpu)
  * TMTA rules:
  * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq)
  */
-static int __cpuinit longrun_determine_freqs(unsigned int *low_freq,
+static int longrun_determine_freqs(unsigned int *low_freq,
                                                      unsigned int *high_freq)
 {
        u32 msr_lo, msr_hi;
@@ -256,7 +256,7 @@ static int __cpuinit longrun_determine_freqs(unsigned int *low_freq,
 }
 
 
-static int __cpuinit longrun_cpu_init(struct cpufreq_policy *policy)
+static int longrun_cpu_init(struct cpufreq_policy *policy)
 {
        int result = 0;
 
index bb838b98507747a02ade005d99074a4c2a1d95a8..9536852c504a559865bc023a2d75ebed22a0ffd9 100644 (file)
@@ -118,11 +118,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
                clk_put(cpuclk);
                return -EINVAL;
        }
-       ret = clk_set_rate(cpuclk, rate);
-       if (ret) {
-               clk_put(cpuclk);
-               return ret;
-       }
 
        /* clock table init */
        for (i = 2;
@@ -130,6 +125,12 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
             i++)
                loongson2_clockmod_table[i].frequency = (rate * i) / 8;
 
+       ret = clk_set_rate(cpuclk, rate);
+       if (ret) {
+               clk_put(cpuclk);
+               return ret;
+       }
+
        policy->cur = loongson2_cpufreq_get(policy->cpu);
 
        cpufreq_frequency_table_get_attr(&loongson2_clockmod_table[0],
index 29468a522ee9a799180b8cf18b178bb43d16acb7..f31fcfcad514330ca856bcfd015aba3927de8241 100644 (file)
@@ -165,7 +165,7 @@ static inline void freq_table_free(void)
                opp_free_cpufreq_table(mpu_dev, &freq_table);
 }
 
-static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
+static int omap_cpu_init(struct cpufreq_policy *policy)
 {
        int result = 0;
 
index b9f80b713fda939c469472f7ad9193b37b374966..9558708779350a9b00ee6951241ac9bf24551766 100644 (file)
@@ -563,7 +563,7 @@ static int powernow_verify(struct cpufreq_policy *policy)
  * We will then get the same kind of behaviour already tested under
  * the "well-known" other OS.
  */
-static int __cpuinit fixup_sgtc(void)
+static int fixup_sgtc(void)
 {
        unsigned int sgtc;
        unsigned int m;
@@ -597,7 +597,7 @@ static unsigned int powernow_get(unsigned int cpu)
 }
 
 
-static int __cpuinit acer_cpufreq_pst(const struct dmi_system_id *d)
+static int acer_cpufreq_pst(const struct dmi_system_id *d)
 {
        printk(KERN_WARNING PFX
                "%s laptop with broken PST tables in BIOS detected.\n",
@@ -615,7 +615,7 @@ static int __cpuinit acer_cpufreq_pst(const struct dmi_system_id *d)
  * A BIOS update is all that can save them.
  * Mention this, and disable cpufreq.
  */
-static struct dmi_system_id __cpuinitdata powernow_dmi_table[] = {
+static struct dmi_system_id powernow_dmi_table[] = {
        {
                .callback = acer_cpufreq_pst,
                .ident = "Acer Aspire",
@@ -627,7 +627,7 @@ static struct dmi_system_id __cpuinitdata powernow_dmi_table[] = {
        { }
 };
 
-static int __cpuinit powernow_cpu_init(struct cpufreq_policy *policy)
+static int powernow_cpu_init(struct cpufreq_policy *policy)
 {
        union msr_fidvidstatus fidvidstatus;
        int result;
index 78f018f2a5deb5db485a718068825723ffeabba1..c39d189217cb6d5fedd521c602464d296b4d47bf 100644 (file)
@@ -1069,7 +1069,7 @@ struct init_on_cpu {
        int rc;
 };
 
-static void __cpuinit powernowk8_cpu_init_on_cpu(void *_init_on_cpu)
+static void powernowk8_cpu_init_on_cpu(void *_init_on_cpu)
 {
        struct init_on_cpu *init_on_cpu = _init_on_cpu;
 
@@ -1096,7 +1096,7 @@ static const char missing_pss_msg[] =
        FW_BUG PFX "If that doesn't help, try upgrading your BIOS.\n";
 
 /* per CPU init entry point to the driver */
-static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
+static int powernowk8_cpu_init(struct cpufreq_policy *pol)
 {
        struct powernow_k8_data *data;
        struct init_on_cpu init_on_cpu;
@@ -1263,7 +1263,7 @@ static void __request_acpi_cpufreq(void)
 }
 
 /* driver entry point for init */
-static int __cpuinit powernowk8_init(void)
+static int powernowk8_init(void)
 {
        unsigned int i, supported_cpus = 0;
        int ret;
index 3513e747716007f0700dc58df1e8c96bffdc2151..87781eb20d6dce41c4b6c376f4937f67d808d0be 100644 (file)
@@ -49,7 +49,7 @@ static struct clk *clk_hclk;
 static struct clk *clk_pclk;
 static struct clk *clk_arm;
 
-#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS
+#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS
 struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void)
 {
        return &cpu_cur;
@@ -59,7 +59,7 @@ struct s3c_iotimings *s3c_cpufreq_getiotimings(void)
 {
        return &s3c24xx_iotiming;
 }
-#endif /* CONFIG_CPU_FREQ_S3C24XX_DEBUGFS */
+#endif /* CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS */
 
 static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg)
 {
index fe343a06b7da3278ba68c9c15c261ea14afde685..bc580b67a65298a8bf65e699d562dfd6f237b697 100644 (file)
 #define MAX_INTERESTING 50000
 #define STDDEV_THRESH 400
 
-/* 60 * 60 > STDDEV_THRESH * INTERVALS = 400 * 8 */
-#define MAX_DEVIATION 60
-
-static DEFINE_PER_CPU(struct hrtimer, menu_hrtimer);
-static DEFINE_PER_CPU(int, hrtimer_status);
-/* menu hrtimer mode */
-enum {MENU_HRTIMER_STOP, MENU_HRTIMER_REPEAT, MENU_HRTIMER_GENERAL};
 
 /*
  * Concepts and ideas behind the menu governor
@@ -116,13 +109,6 @@ enum {MENU_HRTIMER_STOP, MENU_HRTIMER_REPEAT, MENU_HRTIMER_GENERAL};
  *
  */
 
-/*
- * The C-state residency is so long that is is worthwhile to exit
- * from the shallow C-state and re-enter into a deeper C-state.
- */
-static unsigned int perfect_cstate_ms __read_mostly = 30;
-module_param(perfect_cstate_ms, uint, 0000);
-
 struct menu_device {
        int             last_state_idx;
        int             needs_update;
@@ -205,52 +191,17 @@ static u64 div_round64(u64 dividend, u32 divisor)
        return div_u64(dividend + (divisor / 2), divisor);
 }
 
-/* Cancel the hrtimer if it is not triggered yet */
-void menu_hrtimer_cancel(void)
-{
-       int cpu = smp_processor_id();
-       struct hrtimer *hrtmr = &per_cpu(menu_hrtimer, cpu);
-
-       /* The timer is still not time out*/
-       if (per_cpu(hrtimer_status, cpu)) {
-               hrtimer_cancel(hrtmr);
-               per_cpu(hrtimer_status, cpu) = MENU_HRTIMER_STOP;
-       }
-}
-EXPORT_SYMBOL_GPL(menu_hrtimer_cancel);
-
-/* Call back for hrtimer is triggered */
-static enum hrtimer_restart menu_hrtimer_notify(struct hrtimer *hrtimer)
-{
-       int cpu = smp_processor_id();
-       struct menu_device *data = &per_cpu(menu_devices, cpu);
-
-       /* In general case, the expected residency is much larger than
-        *  deepest C-state target residency, but prediction logic still
-        *  predicts a small predicted residency, so the prediction
-        *  history is totally broken if the timer is triggered.
-        *  So reset the correction factor.
-        */
-       if (per_cpu(hrtimer_status, cpu) == MENU_HRTIMER_GENERAL)
-               data->correction_factor[data->bucket] = RESOLUTION * DECAY;
-
-       per_cpu(hrtimer_status, cpu) = MENU_HRTIMER_STOP;
-
-       return HRTIMER_NORESTART;
-}
-
 /*
  * Try detecting repeating patterns by keeping track of the last 8
  * intervals, and checking if the standard deviation of that set
  * of points is below a threshold. If it is... then use the
  * average of these 8 points as the estimated value.
  */
-static u32 get_typical_interval(struct menu_device *data)
+static void get_typical_interval(struct menu_device *data)
 {
        int i = 0, divisor = 0;
        uint64_t max = 0, avg = 0, stddev = 0;
        int64_t thresh = LLONG_MAX; /* Discard outliers above this value. */
-       unsigned int ret = 0;
 
 again:
 
@@ -291,16 +242,13 @@ again:
        if (((avg > stddev * 6) && (divisor * 4 >= INTERVALS * 3))
                                                        || stddev <= 20) {
                data->predicted_us = avg;
-               ret = 1;
-               return ret;
+               return;
 
        } else if ((divisor * 4) > INTERVALS * 3) {
                /* Exclude the max interval */
                thresh = max - 1;
                goto again;
        }
-
-       return ret;
 }
 
 /**
@@ -315,9 +263,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
        int i;
        int multiplier;
        struct timespec t;
-       int repeat = 0, low_predicted = 0;
-       int cpu = smp_processor_id();
-       struct hrtimer *hrtmr = &per_cpu(menu_hrtimer, cpu);
 
        if (data->needs_update) {
                menu_update(drv, dev);
@@ -352,7 +297,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
        data->predicted_us = div_round64(data->expected_us * data->correction_factor[data->bucket],
                                         RESOLUTION * DECAY);
 
-       repeat = get_typical_interval(data);
+       get_typical_interval(data);
 
        /*
         * We want to default to C1 (hlt), not to busy polling
@@ -373,10 +318,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 
                if (s->disabled || su->disable)
                        continue;
-               if (s->target_residency > data->predicted_us) {
-                       low_predicted = 1;
+               if (s->target_residency > data->predicted_us)
                        continue;
-               }
                if (s->exit_latency > latency_req)
                        continue;
                if (s->exit_latency * multiplier > data->predicted_us)
@@ -386,44 +329,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
                data->exit_us = s->exit_latency;
        }
 
-       /* not deepest C-state chosen for low predicted residency */
-       if (low_predicted) {
-               unsigned int timer_us = 0;
-               unsigned int perfect_us = 0;
-
-               /*
-                * Set a timer to detect whether this sleep is much
-                * longer than repeat mode predicted.  If the timer
-                * triggers, the code will evaluate whether to put
-                * the CPU into a deeper C-state.
-                * The timer is cancelled on CPU wakeup.
-                */
-               timer_us = 2 * (data->predicted_us + MAX_DEVIATION);
-
-               perfect_us = perfect_cstate_ms * 1000;
-
-               if (repeat && (4 * timer_us < data->expected_us)) {
-                       RCU_NONIDLE(hrtimer_start(hrtmr,
-                               ns_to_ktime(1000 * timer_us),
-                               HRTIMER_MODE_REL_PINNED));
-                       /* In repeat case, menu hrtimer is started */
-                       per_cpu(hrtimer_status, cpu) = MENU_HRTIMER_REPEAT;
-               } else if (perfect_us < data->expected_us) {
-                       /*
-                        * The next timer is long. This could be because
-                        * we did not make a useful prediction.
-                        * In that case, it makes sense to re-enter
-                        * into a deeper C-state after some time.
-                        */
-                       RCU_NONIDLE(hrtimer_start(hrtmr,
-                               ns_to_ktime(1000 * timer_us),
-                               HRTIMER_MODE_REL_PINNED));
-                       /* In general case, menu hrtimer is started */
-                       per_cpu(hrtimer_status, cpu) = MENU_HRTIMER_GENERAL;
-               }
-
-       }
-
        return data->last_state_idx;
 }
 
@@ -514,9 +419,6 @@ static int menu_enable_device(struct cpuidle_driver *drv,
                                struct cpuidle_device *dev)
 {
        struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
-       struct hrtimer *t = &per_cpu(menu_hrtimer, dev->cpu);
-       hrtimer_init(t, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       t->function = menu_hrtimer_notify;
 
        memset(data, 0, sizeof(struct menu_device));
 
index 5996521a1caff11068e9b2e1e417cdf729f474df..84573b4d6f92809d5cd98fa968f6dd1a617482d3 100644 (file)
@@ -429,7 +429,7 @@ static int hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in,
        dma_addr_t src_dma, dst_dma;
        int ret = 0;
 
-       desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA);
+       desc = kmalloc(CAAM_CMD_SZ * 8 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA);
        if (!desc) {
                dev_err(jrdev, "unable to allocate key input memory\n");
                return -ENOMEM;
index ce3dc3e9688c86ea30e3be7757094b78749a6ec9..0bbdea5059f3b693a8929a4d6ee82db24c90b768 100644 (file)
@@ -867,6 +867,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
 
        if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
                dev_err(&pdev->dev, "Cannot find proper base address\n");
+               err = -ENODEV;
                goto err_disable_pdev;
        }
 
index 593827b3fdd4fd8556724da998934a7c191b8d49..fa645d8250091943ba8d47aa42852b99b74ca1ce 100644 (file)
@@ -2505,6 +2505,10 @@ static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx)
        /* Assign cookies to all nodes */
        while (!list_empty(&last->node)) {
                desc = list_entry(last->node.next, struct dma_pl330_desc, node);
+               if (pch->cyclic) {
+                       desc->txd.callback = last->txd.callback;
+                       desc->txd.callback_param = last->txd.callback_param;
+               }
 
                dma_cookie_assign(&desc->txd);
 
@@ -2688,45 +2692,82 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic(
                size_t period_len, enum dma_transfer_direction direction,
                unsigned long flags, void *context)
 {
-       struct dma_pl330_desc *desc;
+       struct dma_pl330_desc *desc = NULL, *first = NULL;
        struct dma_pl330_chan *pch = to_pchan(chan);
+       struct dma_pl330_dmac *pdmac = pch->dmac;
+       unsigned int i;
        dma_addr_t dst;
        dma_addr_t src;
 
-       desc = pl330_get_desc(pch);
-       if (!desc) {
-               dev_err(pch->dmac->pif.dev, "%s:%d Unable to fetch desc\n",
-                       __func__, __LINE__);
+       if (len % period_len != 0)
                return NULL;
-       }
 
-       switch (direction) {
-       case DMA_MEM_TO_DEV:
-               desc->rqcfg.src_inc = 1;
-               desc->rqcfg.dst_inc = 0;
-               desc->req.rqtype = MEMTODEV;
-               src = dma_addr;
-               dst = pch->fifo_addr;
-               break;
-       case DMA_DEV_TO_MEM:
-               desc->rqcfg.src_inc = 0;
-               desc->rqcfg.dst_inc = 1;
-               desc->req.rqtype = DEVTOMEM;
-               src = pch->fifo_addr;
-               dst = dma_addr;
-               break;
-       default:
+       if (!is_slave_direction(direction)) {
                dev_err(pch->dmac->pif.dev, "%s:%d Invalid dma direction\n",
                __func__, __LINE__);
                return NULL;
        }
 
-       desc->rqcfg.brst_size = pch->burst_sz;
-       desc->rqcfg.brst_len = 1;
+       for (i = 0; i < len / period_len; i++) {
+               desc = pl330_get_desc(pch);
+               if (!desc) {
+                       dev_err(pch->dmac->pif.dev, "%s:%d Unable to fetch desc\n",
+                               __func__, __LINE__);
 
-       pch->cyclic = true;
+                       if (!first)
+                               return NULL;
+
+                       spin_lock_irqsave(&pdmac->pool_lock, flags);
+
+                       while (!list_empty(&first->node)) {
+                               desc = list_entry(first->node.next,
+                                               struct dma_pl330_desc, node);
+                               list_move_tail(&desc->node, &pdmac->desc_pool);
+                       }
+
+                       list_move_tail(&first->node, &pdmac->desc_pool);
 
-       fill_px(&desc->px, dst, src, period_len);
+                       spin_unlock_irqrestore(&pdmac->pool_lock, flags);
+
+                       return NULL;
+               }
+
+               switch (direction) {
+               case DMA_MEM_TO_DEV:
+                       desc->rqcfg.src_inc = 1;
+                       desc->rqcfg.dst_inc = 0;
+                       desc->req.rqtype = MEMTODEV;
+                       src = dma_addr;
+                       dst = pch->fifo_addr;
+                       break;
+               case DMA_DEV_TO_MEM:
+                       desc->rqcfg.src_inc = 0;
+                       desc->rqcfg.dst_inc = 1;
+                       desc->req.rqtype = DEVTOMEM;
+                       src = pch->fifo_addr;
+                       dst = dma_addr;
+                       break;
+               default:
+                       break;
+               }
+
+               desc->rqcfg.brst_size = pch->burst_sz;
+               desc->rqcfg.brst_len = 1;
+               fill_px(&desc->px, dst, src, period_len);
+
+               if (!first)
+                       first = desc;
+               else
+                       list_add_tail(&desc->node, &first->node);
+
+               dma_addr += period_len;
+       }
+
+       if (!desc)
+               return NULL;
+
+       pch->cyclic = true;
+       desc->txd.flags = flags;
 
        return &desc->txd;
 }
index b67f45f5c2712a8c16be7afad085bd745649a708..5039fbc88254eabd570e9da6d50d51ed0cff8240 100644 (file)
@@ -400,8 +400,8 @@ static size_t sh_dmae_get_partial(struct shdma_chan *schan,
                                                    shdma_chan);
        struct sh_dmae_desc *sh_desc = container_of(sdesc,
                                        struct sh_dmae_desc, shdma_desc);
-       return (sh_desc->hw.tcr - sh_dmae_readl(sh_chan, TCR)) <<
-               sh_chan->xmit_shift;
+       return sh_desc->hw.tcr -
+               (sh_dmae_readl(sh_chan, TCR) << sh_chan->xmit_shift);
 }
 
 /* Called from error IRQ or NMI */
index 27e86d93826280a62744a559332bf0cd9bc03b3b..89e109022d78a27cf506d995c1c16de2feffea0f 100644 (file)
@@ -48,6 +48,8 @@ static LIST_HEAD(mc_devices);
  */
 static void const *edac_mc_owner;
 
+static struct bus_type mc_bus[EDAC_MAX_MCS];
+
 unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
                                 unsigned len)
 {
@@ -723,6 +725,11 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
        int ret = -EINVAL;
        edac_dbg(0, "\n");
 
+       if (mci->mc_idx >= EDAC_MAX_MCS) {
+               pr_warn_once("Too many memory controllers: %d\n", mci->mc_idx);
+               return -ENODEV;
+       }
+
 #ifdef CONFIG_EDAC_DEBUG
        if (edac_debug_level >= 3)
                edac_mc_dump_mci(mci);
@@ -762,6 +769,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
        /* set load time so that error rate can be tracked */
        mci->start_time = jiffies;
 
+       mci->bus = &mc_bus[mci->mc_idx];
+
        if (edac_create_sysfs_mci_device(mci)) {
                edac_mc_printk(mci, KERN_WARNING,
                        "failed to create sysfs device\n");
index ef15a7e613bc6b1d1feec75733a86e20cb23efa7..e7c32c4f783737962b575a232f03b5ed19d3629b 100644 (file)
@@ -370,7 +370,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
                return -ENODEV;
 
        csrow->dev.type = &csrow_attr_type;
-       csrow->dev.bus = &mci->bus;
+       csrow->dev.bus = mci->bus;
        device_initialize(&csrow->dev);
        csrow->dev.parent = &mci->dev;
        csrow->mci = mci;
@@ -605,7 +605,7 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci,
        dimm->mci = mci;
 
        dimm->dev.type = &dimm_attr_type;
-       dimm->dev.bus = &mci->bus;
+       dimm->dev.bus = mci->bus;
        device_initialize(&dimm->dev);
 
        dimm->dev.parent = &mci->dev;
@@ -975,11 +975,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
         * The memory controller needs its own bus, in order to avoid
         * namespace conflicts at /sys/bus/edac.
         */
-       mci->bus.name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
-       if (!mci->bus.name)
+       mci->bus->name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
+       if (!mci->bus->name)
                return -ENOMEM;
-       edac_dbg(0, "creating bus %s\n", mci->bus.name);
-       err = bus_register(&mci->bus);
+
+       edac_dbg(0, "creating bus %s\n", mci->bus->name);
+
+       err = bus_register(mci->bus);
        if (err < 0)
                return err;
 
@@ -988,7 +990,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
        device_initialize(&mci->dev);
 
        mci->dev.parent = mci_pdev;
-       mci->dev.bus = &mci->bus;
+       mci->dev.bus = mci->bus;
        dev_set_name(&mci->dev, "mc%d", mci->mc_idx);
        dev_set_drvdata(&mci->dev, mci);
        pm_runtime_forbid(&mci->dev);
@@ -997,8 +999,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
        err = device_add(&mci->dev);
        if (err < 0) {
                edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
-               bus_unregister(&mci->bus);
-               kfree(mci->bus.name);
+               bus_unregister(mci->bus);
+               kfree(mci->bus->name);
                return err;
        }
 
@@ -1064,8 +1066,8 @@ fail:
        }
 fail2:
        device_unregister(&mci->dev);
-       bus_unregister(&mci->bus);
-       kfree(mci->bus.name);
+       bus_unregister(mci->bus);
+       kfree(mci->bus->name);
        return err;
 }
 
@@ -1098,8 +1100,8 @@ void edac_unregister_sysfs(struct mem_ctl_info *mci)
 {
        edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev));
        device_unregister(&mci->dev);
-       bus_unregister(&mci->bus);
-       kfree(mci->bus.name);
+       bus_unregister(mci->bus);
+       kfree(mci->bus->name);
 }
 
 static void mc_attr_release(struct device *dev)
index 1b635178cc44ff31b8ed224560ebdf86851165f0..157b934e8ce3a528468e45a735ab41dee6043cea 100644 (file)
@@ -974,7 +974,7 @@ static int i5100_setup_debugfs(struct mem_ctl_info *mci)
        if (!i5100_debugfs)
                return -ENODEV;
 
-       priv->debugfs = debugfs_create_dir(mci->bus.name, i5100_debugfs);
+       priv->debugfs = debugfs_create_dir(mci->bus->name, i5100_debugfs);
 
        if (!priv->debugfs)
                return -ENOMEM;
index 7ef316fdc4d964cc8d1f87bd7be0cb9995223612..ac1b43a0428531273c4fdaefd56a0b83f1545ce2 100644 (file)
@@ -54,6 +54,7 @@
 #define FW_CDEV_KERNEL_VERSION                 5
 #define FW_CDEV_VERSION_EVENT_REQUEST2         4
 #define FW_CDEV_VERSION_ALLOCATE_REGION_END    4
+#define FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW        5
 
 struct client {
        u32 version;
@@ -1005,6 +1006,8 @@ static int ioctl_create_iso_context(struct client *client, union ioctl_arg *arg)
                        a->channel, a->speed, a->header_size, cb, client);
        if (IS_ERR(context))
                return PTR_ERR(context);
+       if (client->version < FW_CDEV_VERSION_AUTO_FLUSH_ISO_OVERFLOW)
+               context->drop_overflow_headers = true;
 
        /* We only support one context at this time. */
        spin_lock_irq(&client->lock);
index 9e1db6490b9a3bb497b7911d94c42d9fc6190be7..afb701ec90cabd50ceb03b1298beba38e97717b4 100644 (file)
@@ -2749,8 +2749,11 @@ static void copy_iso_headers(struct iso_context *ctx, const u32 *dma_hdr)
 {
        u32 *ctx_hdr;
 
-       if (ctx->header_length + ctx->base.header_size > PAGE_SIZE)
+       if (ctx->header_length + ctx->base.header_size > PAGE_SIZE) {
+               if (ctx->base.drop_overflow_headers)
+                       return;
                flush_iso_completions(ctx);
+       }
 
        ctx_hdr = ctx->header + ctx->header_length;
        ctx->last_timestamp = (u16)le32_to_cpu((__force __le32)dma_hdr[0]);
@@ -2910,8 +2913,11 @@ static int handle_it_packet(struct context *context,
 
        sync_it_packet_for_cpu(context, d);
 
-       if (ctx->header_length + 4 > PAGE_SIZE)
+       if (ctx->header_length + 4 > PAGE_SIZE) {
+               if (ctx->base.drop_overflow_headers)
+                       return 1;
                flush_iso_completions(ctx);
+       }
 
        ctx_hdr = ctx->header + ctx->header_length;
        ctx->last_timestamp = le16_to_cpu(last->res_count);
index eb760a218da4292f7c208ddc145deffb833df7ab..232fa8fce26a5d0ffddf5fdc3ee01ed3c63eed7f 100644 (file)
@@ -419,6 +419,13 @@ static void __init dmi_format_ids(char *buf, size_t len)
                            dmi_get_system_info(DMI_BIOS_DATE));
 }
 
+/*
+ * Check for DMI/SMBIOS headers in the system firmware image.  Any
+ * SMBIOS header must start 16 bytes before the DMI header, so take a
+ * 32 byte buffer and check for DMI at offset 16 and SMBIOS at offset
+ * 0.  If the DMI header is present, set dmi_ver accordingly (SMBIOS
+ * takes precedence) and return 0.  Otherwise return 1.
+ */
 static int __init dmi_present(const u8 *buf)
 {
        int smbios_ver;
@@ -506,6 +513,13 @@ void __init dmi_scan_machine(void)
                if (p == NULL)
                        goto error;
 
+               /*
+                * Iterate over all possible DMI header addresses q.
+                * Maintain the 32 bytes around q in buf.  On the
+                * first iteration, substitute zero for the
+                * out-of-range bytes so there is no chance of falsely
+                * detecting an SMBIOS header.
+                */
                memset(buf, 0, 16);
                for (q = p; q < p + 0x10000; q += 16) {
                        memcpy_fromio(buf + 16, q, 16);
index 8bd1bb6dbe4739cf0914a129a12363c1bf157820..8a7432a4b4136807ad9a00015a00f5a249d6b112 100644 (file)
@@ -583,6 +583,9 @@ int efivars_sysfs_init(void)
        struct kobject *parent_kobj = efivars_kobject();
        int error = 0;
 
+       if (!efi_enabled(EFI_RUNTIME_SERVICES))
+               return -ENODEV;
+
        /* No efivars has been registered yet */
        if (!parent_kobj)
                return 0;
index e3ceaacde45c111990c534c887a47cda3a5ec61e..73b73969d361c10a42968ee5eaaa142f72894ef6 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
+#include <linux/err.h>
 
 #include <mach/msm_gpiomux.h>
 
index f4491a497cc8760ef59484ac2c6c264573b3b8a9..c2fa77086eb58cf9de7f2c2a453c900a9771f0b5 100644 (file)
@@ -378,7 +378,7 @@ static int msm_gpio_probe(struct platform_device *pdev)
        int ret, ngpio;
        struct resource *res;
 
-       if (!of_property_read_u32(pdev->dev.of_node, "ngpio", &ngpio)) {
+       if (of_property_read_u32(pdev->dev.of_node, "ngpio", &ngpio)) {
                dev_err(&pdev->dev, "%s: ngpio property missing\n", __func__);
                return -EINVAL;
        }
index 98d670825a1a115a43fd5c6d49bd494ce839c94b..6e8887fe6c1b44fb83d09df82d10d50483924de5 100644 (file)
@@ -323,6 +323,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
 
        astbo->gem.driver_private = NULL;
        astbo->bo.bdev = &ast->ttm.bdev;
+       astbo->bo.bdev->dev_mapping = dev->dev_mapping;
 
        ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
 
index 0047012045c27cff7cfa8dbd386ca239d850e4be..69fd8f1ac8df192729c89f4dd981a5bb5b7611db 100644 (file)
@@ -328,6 +328,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align,
 
        cirrusbo->gem.driver_private = NULL;
        cirrusbo->bo.bdev = &cirrus->ttm.bdev;
+       cirrusbo->bo.bdev->dev_mapping = dev->dev_mapping;
 
        cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
 
index 738a4294d820e164d7534f830dd4eed7c880aa4d..6a647493ca7f0741cd39d03134f0614c74451d48 100644 (file)
@@ -677,6 +677,11 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
                                        /* don't break so fail path works correct */
                                        fail = 1;
                                break;
+
+                               if (connector->dpms != DRM_MODE_DPMS_ON) {
+                                       DRM_DEBUG_KMS("connector dpms not on, full mode switch\n");
+                                       mode_changed = true;
+                               }
                        }
                }
 
@@ -754,6 +759,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
                                ret = -EINVAL;
                                goto fail;
                        }
+                       DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
+                       for (i = 0; i < set->num_connectors; i++) {
+                               DRM_DEBUG_KMS("\t[CONNECTOR:%d:%s] set DPMS on\n", set->connectors[i]->base.id,
+                                             drm_get_connector_name(set->connectors[i]));
+                               set->connectors[i]->funcs->dpms(set->connectors[i], DRM_MODE_DPMS_ON);
+                       }
                }
                drm_helper_disable_unused_functions(dev);
        } else if (fb_changed) {
@@ -771,22 +782,6 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
                }
        }
 
-       /*
-        * crtc set_config helpers implicit set the crtc and all connected
-        * encoders to DPMS on for a full mode set. But for just an fb update it
-        * doesn't do that. To not confuse userspace, do an explicit DPMS_ON
-        * unconditionally. This will also ensure driver internal dpms state is
-        * consistent again.
-        */
-       if (set->crtc->enabled) {
-               DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
-               for (i = 0; i < set->num_connectors; i++) {
-                       DRM_DEBUG_KMS("\t[CONNECTOR:%d:%s] set DPMS on\n", set->connectors[i]->base.id,
-                                     drm_get_connector_name(set->connectors[i]));
-                       set->connectors[i]->funcs->dpms(set->connectors[i], DRM_MODE_DPMS_ON);
-               }
-       }
-
        kfree(save_connectors);
        kfree(save_encoders);
        kfree(save_crtcs);
index 8bcce7866d368e12df7c86edb17ff235ba58f4a7..f92da0a32f0d30d02fe8afeb09f5272a16b8a060 100644 (file)
@@ -708,7 +708,10 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
        /* Subtract time delta from raw timestamp to get final
         * vblank_time timestamp for end of vblank.
         */
-       etime = ktime_sub_ns(etime, delta_ns);
+       if (delta_ns < 0)
+               etime = ktime_add_ns(etime, -delta_ns);
+       else
+               etime = ktime_sub_ns(etime, delta_ns);
        *vblank_time = ktime_to_timeval(etime);
 
        DRM_DEBUG("crtc %d : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
index 95c75edef01a0440303a36f2692ce963fe6a135e..30ef41bcd7b8fa5ed0554adf8bc3332cf19a1320 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/kernel.h>
 #include <linux/i2c.h>
-#include <linux/module.h>
 
 
 #include "exynos_drm_drv.h"
index 61b094f689a72c56666decd1b6b4361d12be6291..6e047bd53e2f00dd8f0d494194be7cda4f02ceda 100644 (file)
@@ -12,7 +12,6 @@
  *
  */
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
index 3e106beca5b6c132f1dea2407652deac449fcc59..1c263dac3c1c8ddcbee197d13143a428ac4b01a2 100644 (file)
@@ -14,7 +14,6 @@
 #include <drm/drmP.h>
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/of_device.h>
@@ -130,7 +129,6 @@ static const struct of_device_id fimd_driver_dt_match[] = {
          .data = &exynos5_fimd_driver_data },
        {},
 };
-MODULE_DEVICE_TABLE(of, fimd_driver_dt_match);
 #endif
 
 static inline struct fimd_driver_data *drm_fimd_get_driver_data(
@@ -1082,7 +1080,6 @@ static struct platform_device_id fimd_driver_ids[] = {
        },
        {},
 };
-MODULE_DEVICE_TABLE(platform, fimd_driver_ids);
 
 static const struct dev_pm_ops fimd_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume)
index 42a5a5466075a7d2d25b8ab30fa6155383a0befa..eddea4941483228a68530513e4f04aa94cb0f84e 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
@@ -806,9 +805,20 @@ static void g2d_dma_start(struct g2d_data *g2d,
        struct g2d_cmdlist_node *node =
                                list_first_entry(&runqueue_node->run_cmdlist,
                                                struct g2d_cmdlist_node, list);
+       int ret;
+
+       ret = pm_runtime_get_sync(g2d->dev);
+       if (ret < 0) {
+               dev_warn(g2d->dev, "failed pm power on.\n");
+               return;
+       }
 
-       pm_runtime_get_sync(g2d->dev);
-       clk_enable(g2d->gate_clk);
+       ret = clk_prepare_enable(g2d->gate_clk);
+       if (ret < 0) {
+               dev_warn(g2d->dev, "failed to enable clock.\n");
+               pm_runtime_put_sync(g2d->dev);
+               return;
+       }
 
        writel_relaxed(node->dma_addr, g2d->regs + G2D_DMA_SFR_BASE_ADDR);
        writel_relaxed(G2D_DMA_START, g2d->regs + G2D_DMA_COMMAND);
@@ -861,7 +871,7 @@ static void g2d_runqueue_worker(struct work_struct *work)
                                            runqueue_work);
 
        mutex_lock(&g2d->runqueue_mutex);
-       clk_disable(g2d->gate_clk);
+       clk_disable_unprepare(g2d->gate_clk);
        pm_runtime_put_sync(g2d->dev);
 
        complete(&g2d->runqueue_node->complete);
@@ -1521,7 +1531,6 @@ static const struct of_device_id exynos_g2d_match[] = {
        { .compatible = "samsung,exynos5250-g2d" },
        {},
 };
-MODULE_DEVICE_TABLE(of, exynos_g2d_match);
 #endif
 
 struct platform_driver g2d_driver = {
index 472e3b25e7f2cc6f5e05c1db002e5117bfca8685..90b8a1a5344cef0528b3bad82ab4b0b993002415 100644 (file)
@@ -12,7 +12,6 @@
  *
  */
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/pm_runtime.h>
index aaa550d622f03c047ca2ecf7c19fec8722f52747..8d3bc01d6834f7b8fca2c2320e67b151a4df3d0c 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/kernel.h>
 #include <linux/wait.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 
index b1ef8e7ff9c91fff7ecc11fc21cf25f7f20fbb3b..d2b6ab4def93ab7421d30fea9c9f86880a0b0e10 100644 (file)
@@ -12,7 +12,6 @@
  *
  */
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 #include <linux/clk.h>
@@ -342,10 +341,10 @@ int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
                 */
                ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
                                                prop_list->ipp_id);
-               if (!ippdrv) {
+               if (IS_ERR(ippdrv)) {
                        DRM_ERROR("not found ipp%d driver.\n",
                                        prop_list->ipp_id);
-                       return -EINVAL;
+                       return PTR_ERR(ippdrv);
                }
 
                prop_list = ippdrv->prop_list;
@@ -970,9 +969,9 @@ int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
        /* find command node */
        c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
                qbuf->prop_id);
-       if (!c_node) {
+       if (IS_ERR(c_node)) {
                DRM_ERROR("failed to get command node.\n");
-               return -EFAULT;
+               return PTR_ERR(c_node);
        }
 
        /* buffer control */
@@ -1106,9 +1105,9 @@ int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
 
        c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
                cmd_ctrl->prop_id);
-       if (!c_node) {
+       if (IS_ERR(c_node)) {
                DRM_ERROR("invalid command node list.\n");
-               return -EINVAL;
+               return PTR_ERR(c_node);
        }
 
        if (!exynos_drm_ipp_check_valid(ippdrv->dev, cmd_ctrl->ctrl,
index 427640aa51481777976391fa51d856f7bbc7512f..49669aa24c4510168d003b4677b3da5548ef2b94 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
index 41cc74d83e4ec885bab33adf02182402938d27d3..c57c56519adda3d2240d57aa1fe6d90900efe680 100644 (file)
@@ -13,7 +13,6 @@
 #include <drm/drmP.h>
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 
 #include <drm/exynos_drm.h>
index 62ef5971ac3c6c40f2d269251a1d098386e024c4..2f5c6942c968bd7a1f9ed4e16adcb8f4c7a99d35 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/spinlock.h>
 #include <linux/wait.h>
 #include <linux/i2c.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
index ef04255076c7f30bd293aa97f95fdaa7d6c5fdcd..6e320ae9afedc758b4a61282e030c099adf152db 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/kernel.h>
 #include <linux/i2c.h>
-#include <linux/module.h>
 
 #include "exynos_drm_drv.h"
 #include "exynos_hdmi.h"
index 42ffb71c63bca254fd5ac753b1d6dcd84c284371..c9a137caea41108a18b8c179a39110c3d64e6a5b 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/spinlock.h>
 #include <linux/wait.h>
 #include <linux/i2c.h>
-#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
index adb319b53ecd4acb98e1ce35f599ea935ff83dce..f4669802a0fb35a6a1ae99b6f7c7cdaeb21d9df5 100644 (file)
@@ -1495,6 +1495,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        dev_priv->dev = dev;
        dev_priv->info = info;
 
+       spin_lock_init(&dev_priv->irq_lock);
+       spin_lock_init(&dev_priv->gpu_error.lock);
+       spin_lock_init(&dev_priv->rps.lock);
+       spin_lock_init(&dev_priv->gt_lock);
+       spin_lock_init(&dev_priv->backlight.lock);
+       mutex_init(&dev_priv->dpio_lock);
+       mutex_init(&dev_priv->rps.hw_lock);
+       mutex_init(&dev_priv->modeset_restore_lock);
+
        i915_dump_device_info(dev_priv);
 
        if (i915_get_bridge_dev(dev)) {
@@ -1585,6 +1594,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        intel_detect_pch(dev);
 
        intel_irq_init(dev);
+       intel_pm_init(dev);
+       intel_gt_sanitize(dev);
        intel_gt_init(dev);
 
        /* Try to make sure MCHBAR is enabled before poking at it */
@@ -1610,15 +1621,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        if (!IS_I945G(dev) && !IS_I945GM(dev))
                pci_enable_msi(dev->pdev);
 
-       spin_lock_init(&dev_priv->irq_lock);
-       spin_lock_init(&dev_priv->gpu_error.lock);
-       spin_lock_init(&dev_priv->rps.lock);
-       spin_lock_init(&dev_priv->backlight.lock);
-       mutex_init(&dev_priv->dpio_lock);
-
-       mutex_init(&dev_priv->rps.hw_lock);
-       mutex_init(&dev_priv->modeset_restore_lock);
-
        dev_priv->num_plane = 1;
        if (IS_VALLEYVIEW(dev))
                dev_priv->num_plane = 2;
index 062cbda1bf4a6c76acb4a0086209161d2b5d5bf7..45b3c030f48393b6921e66406e48f92e2f1d643e 100644 (file)
@@ -123,10 +123,10 @@ module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 060
 MODULE_PARM_DESC(preliminary_hw_support,
                "Enable preliminary hardware support. (default: false)");
 
-int i915_disable_power_well __read_mostly = 0;
+int i915_disable_power_well __read_mostly = 1;
 module_param_named(disable_power_well, i915_disable_power_well, int, 0600);
 MODULE_PARM_DESC(disable_power_well,
-                "Disable the power well when possible (default: false)");
+                "Disable the power well when possible (default: true)");
 
 int i915_enable_ips __read_mostly = 1;
 module_param_named(enable_ips, i915_enable_ips, int, 0600);
@@ -706,7 +706,7 @@ static int i915_drm_thaw(struct drm_device *dev)
 {
        int error = 0;
 
-       intel_gt_reset(dev);
+       intel_gt_sanitize(dev);
 
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
                mutex_lock(&dev->struct_mutex);
@@ -732,7 +732,7 @@ int i915_resume(struct drm_device *dev)
 
        pci_set_master(dev->pdev);
 
-       intel_gt_reset(dev);
+       intel_gt_sanitize(dev);
 
        /*
         * Platforms with opregion should have sane BIOS, older ones (gen3 and
@@ -1253,21 +1253,21 @@ hsw_unclaimed_reg_check(struct drm_i915_private *dev_priv, u32 reg)
 
 #define __i915_read(x, y) \
 u##x i915_read##x(struct drm_i915_private *dev_priv, u32 reg) { \
+       unsigned long irqflags; \
        u##x val = 0; \
+       spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
        if (IS_GEN5(dev_priv->dev)) \
                ilk_dummy_write(dev_priv); \
        if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
-               unsigned long irqflags; \
-               spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
                if (dev_priv->forcewake_count == 0) \
                        dev_priv->gt.force_wake_get(dev_priv); \
                val = read##y(dev_priv->regs + reg); \
                if (dev_priv->forcewake_count == 0) \
                        dev_priv->gt.force_wake_put(dev_priv); \
-               spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
        } else { \
                val = read##y(dev_priv->regs + reg); \
        } \
+       spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
        trace_i915_reg_rw(false, reg, val, sizeof(val)); \
        return val; \
 }
@@ -1280,8 +1280,10 @@ __i915_read(64, q)
 
 #define __i915_write(x, y) \
 void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
+       unsigned long irqflags; \
        u32 __fifo_ret = 0; \
        trace_i915_reg_rw(true, reg, val, sizeof(val)); \
+       spin_lock_irqsave(&dev_priv->gt_lock, irqflags); \
        if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \
                __fifo_ret = __gen6_gt_wait_for_fifo(dev_priv); \
        } \
@@ -1293,6 +1295,7 @@ void i915_write##x(struct drm_i915_private *dev_priv, u32 reg, u##x val) { \
                gen6_gt_check_fifodbg(dev_priv); \
        } \
        hsw_unclaimed_reg_check(dev_priv, reg); \
+       spin_unlock_irqrestore(&dev_priv->gt_lock, irqflags); \
 }
 __i915_write(8, b)
 __i915_write(16, w)
index a416645bcd23364bb9793100da286b7f74858794..1929bffc1c77f645a920c9b4037f0b5eb646a145 100644 (file)
@@ -555,6 +555,7 @@ enum intel_sbi_destination {
 #define QUIRK_PIPEA_FORCE (1<<0)
 #define QUIRK_LVDS_SSC_DISABLE (1<<1)
 #define QUIRK_INVERT_BRIGHTNESS (1<<2)
+#define QUIRK_NO_PCH_PWM_ENABLE (1<<3)
 
 struct intel_fbdev;
 struct intel_fbc_work;
@@ -1581,9 +1582,10 @@ void i915_hangcheck_elapsed(unsigned long data);
 void i915_handle_error(struct drm_device *dev, bool wedged);
 
 extern void intel_irq_init(struct drm_device *dev);
+extern void intel_pm_init(struct drm_device *dev);
 extern void intel_hpd_init(struct drm_device *dev);
 extern void intel_gt_init(struct drm_device *dev);
-extern void intel_gt_reset(struct drm_device *dev);
+extern void intel_gt_sanitize(struct drm_device *dev);
 
 void i915_error_state_free(struct kref *error_ref);
 
index 4200c32407ecfef57557517b36c7c03b389d6930..d9e2208cfe98f2fdcb3957bf4ee13f0497e06dfb 100644 (file)
@@ -1880,6 +1880,10 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
        u32 seqno = intel_ring_get_seqno(ring);
 
        BUG_ON(ring == NULL);
+       if (obj->ring != ring && obj->last_write_seqno) {
+               /* Keep the seqno relative to the current ring */
+               obj->last_write_seqno = seqno;
+       }
        obj->ring = ring;
 
        /* Add a reference if we're newly entering the active list. */
@@ -2254,7 +2258,17 @@ void i915_gem_restore_fences(struct drm_device *dev)
 
        for (i = 0; i < dev_priv->num_fence_regs; i++) {
                struct drm_i915_fence_reg *reg = &dev_priv->fence_regs[i];
-               i915_gem_write_fence(dev, i, reg->obj);
+
+               /*
+                * Commit delayed tiling changes if we have an object still
+                * attached to the fence, otherwise just clear the fence.
+                */
+               if (reg->obj) {
+                       i915_gem_object_update_fence(reg->obj, reg,
+                                                    reg->obj->tiling_mode);
+               } else {
+                       i915_gem_write_fence(dev, i, NULL);
+               }
        }
 }
 
@@ -2653,7 +2667,6 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
        drm_i915_private_t *dev_priv = dev->dev_private;
        int fence_reg;
        int fence_pitch_shift;
-       uint64_t val;
 
        if (INTEL_INFO(dev)->gen >= 6) {
                fence_reg = FENCE_REG_SANDYBRIDGE_0;
@@ -2663,8 +2676,23 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
                fence_pitch_shift = I965_FENCE_PITCH_SHIFT;
        }
 
+       fence_reg += reg * 8;
+
+       /* To w/a incoherency with non-atomic 64-bit register updates,
+        * we split the 64-bit update into two 32-bit writes. In order
+        * for a partial fence not to be evaluated between writes, we
+        * precede the update with write to turn off the fence register,
+        * and only enable the fence as the last step.
+        *
+        * For extra levels of paranoia, we make sure each step lands
+        * before applying the next step.
+        */
+       I915_WRITE(fence_reg, 0);
+       POSTING_READ(fence_reg);
+
        if (obj) {
                u32 size = obj->gtt_space->size;
+               uint64_t val;
 
                val = (uint64_t)((obj->gtt_offset + size - 4096) &
                                 0xfffff000) << 32;
@@ -2673,12 +2701,16 @@ static void i965_write_fence_reg(struct drm_device *dev, int reg,
                if (obj->tiling_mode == I915_TILING_Y)
                        val |= 1 << I965_FENCE_TILING_Y_SHIFT;
                val |= I965_FENCE_REG_VALID;
-       } else
-               val = 0;
 
-       fence_reg += reg * 8;
-       I915_WRITE64(fence_reg, val);
-       POSTING_READ(fence_reg);
+               I915_WRITE(fence_reg + 4, val >> 32);
+               POSTING_READ(fence_reg + 4);
+
+               I915_WRITE(fence_reg + 0, val);
+               POSTING_READ(fence_reg);
+       } else {
+               I915_WRITE(fence_reg + 4, 0);
+               POSTING_READ(fence_reg + 4);
+       }
 }
 
 static void i915_write_fence_reg(struct drm_device *dev, int reg,
@@ -2773,6 +2805,10 @@ static void i915_gem_write_fence(struct drm_device *dev, int reg,
        if (i915_gem_object_needs_mb(dev_priv->fence_regs[reg].obj))
                mb();
 
+       WARN(obj && (!obj->stride || !obj->tiling_mode),
+            "bogus fence setup with stride: 0x%x, tiling mode: %i\n",
+            obj->stride, obj->tiling_mode);
+
        switch (INTEL_INFO(dev)->gen) {
        case 7:
        case 6:
@@ -2796,56 +2832,17 @@ static inline int fence_number(struct drm_i915_private *dev_priv,
        return fence - dev_priv->fence_regs;
 }
 
-struct write_fence {
-       struct drm_device *dev;
-       struct drm_i915_gem_object *obj;
-       int fence;
-};
-
-static void i915_gem_write_fence__ipi(void *data)
-{
-       struct write_fence *args = data;
-
-       /* Required for SNB+ with LLC */
-       wbinvd();
-
-       /* Required for VLV */
-       i915_gem_write_fence(args->dev, args->fence, args->obj);
-}
-
 static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
                                         struct drm_i915_fence_reg *fence,
                                         bool enable)
 {
        struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
-       struct write_fence args = {
-               .dev = obj->base.dev,
-               .fence = fence_number(dev_priv, fence),
-               .obj = enable ? obj : NULL,
-       };
-
-       /* In order to fully serialize access to the fenced region and
-        * the update to the fence register we need to take extreme
-        * measures on SNB+. In theory, the write to the fence register
-        * flushes all memory transactions before, and coupled with the
-        * mb() placed around the register write we serialise all memory
-        * operations with respect to the changes in the tiler. Yet, on
-        * SNB+ we need to take a step further and emit an explicit wbinvd()
-        * on each processor in order to manually flush all memory
-        * transactions before updating the fence register.
-        *
-        * However, Valleyview complicates matter. There the wbinvd is
-        * insufficient and unlike SNB/IVB requires the serialising
-        * register write. (Note that that register write by itself is
-        * conversely not sufficient for SNB+.) To compromise, we do both.
-        */
-       if (INTEL_INFO(args.dev)->gen >= 6)
-               on_each_cpu(i915_gem_write_fence__ipi, &args, 1);
-       else
-               i915_gem_write_fence(args.dev, args.fence, args.obj);
+       int reg = fence_number(dev_priv, fence);
+
+       i915_gem_write_fence(obj->base.dev, reg, enable ? obj : NULL);
 
        if (enable) {
-               obj->fence_reg = args.fence;
+               obj->fence_reg = reg;
                fence->obj = obj;
                list_move_tail(&fence->lru_list, &dev_priv->mm.fence_list);
        } else {
@@ -2853,6 +2850,7 @@ static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
                fence->obj = NULL;
                list_del_init(&fence->lru_list);
        }
+       obj->fence_dirty = false;
 }
 
 static int
@@ -2982,7 +2980,6 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
                return 0;
 
        i915_gem_object_update_fence(obj, reg, enable);
-       obj->fence_dirty = false;
 
        return 0;
 }
@@ -4611,7 +4608,7 @@ i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)
        list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list)
                if (obj->pages_pin_count == 0)
                        cnt += obj->base.size >> PAGE_SHIFT;
-       list_for_each_entry(obj, &dev_priv->mm.inactive_list, global_list)
+       list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list)
                if (obj->pin_count == 0 && obj->pages_pin_count == 0)
                        cnt += obj->base.size >> PAGE_SHIFT;
 
index dc53a527126b0569800ff2df3a8a36ebbf904855..9e6578330801638caeb91e7f92e8e0139660eb6f 100644 (file)
@@ -85,9 +85,17 @@ static void i915_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
                                   struct sg_table *sg,
                                   enum dma_data_direction dir)
 {
+       struct drm_i915_gem_object *obj = attachment->dmabuf->priv;
+
+       mutex_lock(&obj->base.dev->struct_mutex);
+
        dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
        sg_free_table(sg);
        kfree(sg);
+
+       i915_gem_object_unpin_pages(obj);
+
+       mutex_unlock(&obj->base.dev->struct_mutex);
 }
 
 static void i915_gem_dmabuf_release(struct dma_buf *dma_buf)
index f2326fc60ac93d4a2f1c760333945fb33bbe0524..6f514297c4837882a64f9480b9f944c3913f7b0c 100644 (file)
 #define CRT_HOTPLUG_DETECT_VOLTAGE_475MV       (1 << 2)
 
 #define PORT_HOTPLUG_STAT      (dev_priv->info->display_mmio_offset + 0x61114)
-/* HDMI/DP bits are gen4+ */
-#define   PORTB_HOTPLUG_LIVE_STATUS               (1 << 29)
+/*
+ * HDMI/DP bits are gen4+
+ *
+ * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused.
+ * Please check the detailed lore in the commit message for for experimental
+ * evidence.
+ */
+#define   PORTD_HOTPLUG_LIVE_STATUS               (1 << 29)
 #define   PORTC_HOTPLUG_LIVE_STATUS               (1 << 28)
-#define   PORTD_HOTPLUG_LIVE_STATUS               (1 << 27)
+#define   PORTB_HOTPLUG_LIVE_STATUS               (1 << 27)
 #define   PORTD_HOTPLUG_INT_STATUS             (3 << 21)
 #define   PORTC_HOTPLUG_INT_STATUS             (3 << 19)
 #define   PORTB_HOTPLUG_INT_STATUS             (3 << 17)
index 324211ac9c555486d56acd36584af7468e762f01..b042ee5c40704a8beaa1e5b99f3d6a1b2082d722 100644 (file)
@@ -301,7 +301,7 @@ static void intel_ddi_mode_set(struct drm_encoder *encoder,
                struct intel_digital_port *intel_dig_port =
                        enc_to_dig_port(encoder);
 
-               intel_dp->DP = intel_dig_port->port_reversal |
+               intel_dp->DP = intel_dig_port->saved_port_bits |
                               DDI_BUF_CTL_ENABLE | DDI_BUF_EMP_400MV_0DB_HSW;
                intel_dp->DP |= DDI_PORT_WIDTH(intel_dp->lane_count);
 
@@ -1109,7 +1109,8 @@ static void intel_enable_ddi(struct intel_encoder *intel_encoder)
                 * enabling the port.
                 */
                I915_WRITE(DDI_BUF_CTL(port),
-                          intel_dig_port->port_reversal | DDI_BUF_CTL_ENABLE);
+                          intel_dig_port->saved_port_bits |
+                          DDI_BUF_CTL_ENABLE);
        } else if (type == INTEL_OUTPUT_EDP) {
                struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
@@ -1347,8 +1348,9 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
        intel_encoder->get_config = intel_ddi_get_config;
 
        intel_dig_port->port = port;
-       intel_dig_port->port_reversal = I915_READ(DDI_BUF_CTL(port)) &
-                                       DDI_BUF_PORT_REVERSAL;
+       intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
+                                         (DDI_BUF_PORT_REVERSAL |
+                                          DDI_A_4_LANES);
        intel_dig_port->dp.output_reg = DDI_BUF_CTL(port);
 
        intel_encoder->type = INTEL_OUTPUT_UNKNOWN;
index 85f3eb74d2b75dbf48f7d9afcf3d5626de4187ca..be79f477a38f9e48de386332e4062f09484a3453 100644 (file)
@@ -4913,22 +4913,19 @@ static void i9xx_get_pfit_config(struct intel_crtc *crtc,
        uint32_t tmp;
 
        tmp = I915_READ(PFIT_CONTROL);
+       if (!(tmp & PFIT_ENABLE))
+               return;
 
+       /* Check whether the pfit is attached to our pipe. */
        if (INTEL_INFO(dev)->gen < 4) {
                if (crtc->pipe != PIPE_B)
                        return;
-
-               /* gen2/3 store dither state in pfit control, needs to match */
-               pipe_config->gmch_pfit.control = tmp & PANEL_8TO6_DITHER_ENABLE;
        } else {
                if ((tmp & PFIT_PIPE_MASK) != (crtc->pipe << PFIT_PIPE_SHIFT))
                        return;
        }
 
-       if (!(tmp & PFIT_ENABLE))
-               return;
-
-       pipe_config->gmch_pfit.control = I915_READ(PFIT_CONTROL);
+       pipe_config->gmch_pfit.control = tmp;
        pipe_config->gmch_pfit.pgm_ratios = I915_READ(PFIT_PGM_RATIOS);
        if (INTEL_INFO(dev)->gen < 5)
                pipe_config->gmch_pfit.lvds_border_bits =
@@ -8272,9 +8269,11 @@ check_crtc_state(struct drm_device *dev)
 
                list_for_each_entry(encoder, &dev->mode_config.encoder_list,
                                    base.head) {
+                       enum pipe pipe;
                        if (encoder->base.crtc != &crtc->base)
                                continue;
-                       if (encoder->get_config)
+                       if (encoder->get_config &&
+                           encoder->get_hw_state(encoder, &pipe))
                                encoder->get_config(encoder, &pipe_config);
                }
 
@@ -8317,6 +8316,8 @@ check_shared_dpll_state(struct drm_device *dev)
                     pll->active, pll->refcount);
                WARN(pll->active && !pll->on,
                     "pll in active use but not on in sw tracking\n");
+               WARN(pll->on && !pll->active,
+                    "pll in on but not on in use in sw tracking\n");
                WARN(pll->on != active,
                     "pll on state mismatch (expected %i, found %i)\n",
                     pll->on, active);
@@ -8541,15 +8542,20 @@ static void intel_set_config_restore_state(struct drm_device *dev,
 }
 
 static bool
-is_crtc_connector_off(struct drm_crtc *crtc, struct drm_connector *connectors,
-                     int num_connectors)
+is_crtc_connector_off(struct drm_mode_set *set)
 {
        int i;
 
-       for (i = 0; i < num_connectors; i++)
-               if (connectors[i].encoder &&
-                   connectors[i].encoder->crtc == crtc &&
-                   connectors[i].dpms != DRM_MODE_DPMS_ON)
+       if (set->num_connectors == 0)
+               return false;
+
+       if (WARN_ON(set->connectors == NULL))
+               return false;
+
+       for (i = 0; i < set->num_connectors; i++)
+               if (set->connectors[i]->encoder &&
+                   set->connectors[i]->encoder->crtc == set->crtc &&
+                   set->connectors[i]->dpms != DRM_MODE_DPMS_ON)
                        return true;
 
        return false;
@@ -8562,10 +8568,8 @@ intel_set_config_compute_mode_changes(struct drm_mode_set *set,
 
        /* We should be able to check here if the fb has the same properties
         * and then just flip_or_move it */
-       if (set->connectors != NULL &&
-           is_crtc_connector_off(set->crtc, *set->connectors,
-                                 set->num_connectors)) {
-                       config->mode_changed = true;
+       if (is_crtc_connector_off(set)) {
+               config->mode_changed = true;
        } else if (set->crtc->fb != set->fb) {
                /* If we have no fb then treat it as a full mode set */
                if (set->crtc->fb == NULL) {
@@ -9398,6 +9402,17 @@ static void quirk_invert_brightness(struct drm_device *dev)
        DRM_INFO("applying inverted panel brightness quirk\n");
 }
 
+/*
+ * Some machines (Dell XPS13) suffer broken backlight controls if
+ * BLM_PCH_PWM_ENABLE is set.
+ */
+static void quirk_no_pcm_pwm_enable(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       dev_priv->quirks |= QUIRK_NO_PCH_PWM_ENABLE;
+       DRM_INFO("applying no-PCH_PWM_ENABLE quirk\n");
+}
+
 struct intel_quirk {
        int device;
        int subsystem_vendor;
@@ -9467,6 +9482,11 @@ static struct intel_quirk intel_quirks[] = {
 
        /* Acer Aspire 4736Z */
        { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
+
+       /* Dell XPS13 HD Sandy Bridge */
+       { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable },
+       /* Dell XPS13 HD and XPS13 FHD Ivy Bridge */
+       { 0x0166, 0x1028, 0x058b, quirk_no_pcm_pwm_enable },
 };
 
 static void intel_init_quirks(struct drm_device *dev)
@@ -9817,8 +9837,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
                }
                pll->refcount = pll->active;
 
-               DRM_DEBUG_KMS("%s hw state readout: refcount %i\n",
-                             pll->name, pll->refcount);
+               DRM_DEBUG_KMS("%s hw state readout: refcount %i, on %i\n",
+                             pll->name, pll->refcount, pll->on);
        }
 
        list_for_each_entry(encoder, &dev->mode_config.encoder_list,
@@ -9869,6 +9889,7 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
        struct drm_plane *plane;
        struct intel_crtc *crtc;
        struct intel_encoder *encoder;
+       int i;
 
        intel_modeset_readout_hw_state(dev);
 
@@ -9884,6 +9905,18 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
                intel_dump_pipe_config(crtc, &crtc->config, "[setup_hw_state]");
        }
 
+       for (i = 0; i < dev_priv->num_shared_dpll; i++) {
+               struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
+
+               if (!pll->on || pll->active)
+                       continue;
+
+               DRM_DEBUG_KMS("%s enabled but not in use, disabling\n", pll->name);
+
+               pll->disable(dev_priv, pll);
+               pll->on = false;
+       }
+
        if (force_restore) {
                /*
                 * We need to use raw interfaces for restoring state to avoid
@@ -10009,6 +10042,8 @@ struct intel_display_error_state {
 
        u32 power_well_driver;
 
+       int num_transcoders;
+
        struct intel_cursor_error_state {
                u32 control;
                u32 position;
@@ -10017,16 +10052,7 @@ struct intel_display_error_state {
        } cursor[I915_MAX_PIPES];
 
        struct intel_pipe_error_state {
-               enum transcoder cpu_transcoder;
-               u32 conf;
                u32 source;
-
-               u32 htotal;
-               u32 hblank;
-               u32 hsync;
-               u32 vtotal;
-               u32 vblank;
-               u32 vsync;
        } pipe[I915_MAX_PIPES];
 
        struct intel_plane_error_state {
@@ -10038,6 +10064,19 @@ struct intel_display_error_state {
                u32 surface;
                u32 tile_offset;
        } plane[I915_MAX_PIPES];
+
+       struct intel_transcoder_error_state {
+               enum transcoder cpu_transcoder;
+
+               u32 conf;
+
+               u32 htotal;
+               u32 hblank;
+               u32 hsync;
+               u32 vtotal;
+               u32 vblank;
+               u32 vsync;
+       } transcoder[4];
 };
 
 struct intel_display_error_state *
@@ -10045,9 +10084,17 @@ intel_display_capture_error_state(struct drm_device *dev)
 {
        drm_i915_private_t *dev_priv = dev->dev_private;
        struct intel_display_error_state *error;
-       enum transcoder cpu_transcoder;
+       int transcoders[] = {
+               TRANSCODER_A,
+               TRANSCODER_B,
+               TRANSCODER_C,
+               TRANSCODER_EDP,
+       };
        int i;
 
+       if (INTEL_INFO(dev)->num_pipes == 0)
+               return NULL;
+
        error = kmalloc(sizeof(*error), GFP_ATOMIC);
        if (error == NULL)
                return NULL;
@@ -10056,9 +10103,6 @@ intel_display_capture_error_state(struct drm_device *dev)
                error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER);
 
        for_each_pipe(i) {
-               cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, i);
-               error->pipe[i].cpu_transcoder = cpu_transcoder;
-
                if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) {
                        error->cursor[i].control = I915_READ(CURCNTR(i));
                        error->cursor[i].position = I915_READ(CURPOS(i));
@@ -10082,14 +10126,25 @@ intel_display_capture_error_state(struct drm_device *dev)
                        error->plane[i].tile_offset = I915_READ(DSPTILEOFF(i));
                }
 
-               error->pipe[i].conf = I915_READ(PIPECONF(cpu_transcoder));
                error->pipe[i].source = I915_READ(PIPESRC(i));
-               error->pipe[i].htotal = I915_READ(HTOTAL(cpu_transcoder));
-               error->pipe[i].hblank = I915_READ(HBLANK(cpu_transcoder));
-               error->pipe[i].hsync = I915_READ(HSYNC(cpu_transcoder));
-               error->pipe[i].vtotal = I915_READ(VTOTAL(cpu_transcoder));
-               error->pipe[i].vblank = I915_READ(VBLANK(cpu_transcoder));
-               error->pipe[i].vsync = I915_READ(VSYNC(cpu_transcoder));
+       }
+
+       error->num_transcoders = INTEL_INFO(dev)->num_pipes;
+       if (HAS_DDI(dev_priv->dev))
+               error->num_transcoders++; /* Account for eDP. */
+
+       for (i = 0; i < error->num_transcoders; i++) {
+               enum transcoder cpu_transcoder = transcoders[i];
+
+               error->transcoder[i].cpu_transcoder = cpu_transcoder;
+
+               error->transcoder[i].conf = I915_READ(PIPECONF(cpu_transcoder));
+               error->transcoder[i].htotal = I915_READ(HTOTAL(cpu_transcoder));
+               error->transcoder[i].hblank = I915_READ(HBLANK(cpu_transcoder));
+               error->transcoder[i].hsync = I915_READ(HSYNC(cpu_transcoder));
+               error->transcoder[i].vtotal = I915_READ(VTOTAL(cpu_transcoder));
+               error->transcoder[i].vblank = I915_READ(VBLANK(cpu_transcoder));
+               error->transcoder[i].vsync = I915_READ(VSYNC(cpu_transcoder));
        }
 
        /* In the code above we read the registers without checking if the power
@@ -10111,22 +10166,16 @@ intel_display_print_error_state(struct drm_i915_error_state_buf *m,
 {
        int i;
 
+       if (!error)
+               return;
+
        err_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes);
        if (HAS_POWER_WELL(dev))
                err_printf(m, "PWR_WELL_CTL2: %08x\n",
                           error->power_well_driver);
        for_each_pipe(i) {
                err_printf(m, "Pipe [%d]:\n", i);
-               err_printf(m, "  CPU transcoder: %c\n",
-                          transcoder_name(error->pipe[i].cpu_transcoder));
-               err_printf(m, "  CONF: %08x\n", error->pipe[i].conf);
                err_printf(m, "  SRC: %08x\n", error->pipe[i].source);
-               err_printf(m, "  HTOTAL: %08x\n", error->pipe[i].htotal);
-               err_printf(m, "  HBLANK: %08x\n", error->pipe[i].hblank);
-               err_printf(m, "  HSYNC: %08x\n", error->pipe[i].hsync);
-               err_printf(m, "  VTOTAL: %08x\n", error->pipe[i].vtotal);
-               err_printf(m, "  VBLANK: %08x\n", error->pipe[i].vblank);
-               err_printf(m, "  VSYNC: %08x\n", error->pipe[i].vsync);
 
                err_printf(m, "Plane [%d]:\n", i);
                err_printf(m, "  CNTR: %08x\n", error->plane[i].control);
@@ -10147,5 +10196,17 @@ intel_display_print_error_state(struct drm_i915_error_state_buf *m,
                err_printf(m, "  POS: %08x\n", error->cursor[i].position);
                err_printf(m, "  BASE: %08x\n", error->cursor[i].base);
        }
+
+       for (i = 0; i < error->num_transcoders; i++) {
+               err_printf(m, "  CPU transcoder: %c\n",
+                          transcoder_name(error->transcoder[i].cpu_transcoder));
+               err_printf(m, "  CONF: %08x\n", error->transcoder[i].conf);
+               err_printf(m, "  HTOTAL: %08x\n", error->transcoder[i].htotal);
+               err_printf(m, "  HBLANK: %08x\n", error->transcoder[i].hblank);
+               err_printf(m, "  HSYNC: %08x\n", error->transcoder[i].hsync);
+               err_printf(m, "  VTOTAL: %08x\n", error->transcoder[i].vtotal);
+               err_printf(m, "  VBLANK: %08x\n", error->transcoder[i].vblank);
+               err_printf(m, "  VSYNC: %08x\n", error->transcoder[i].vsync);
+       }
 }
 #endif
index b739712340131dae2e35f56613fae22f2ca819f0..26e162bb3a5158d5da3f1b5e9b2614c7515ede6b 100644 (file)
@@ -75,7 +75,12 @@ intel_dp_max_link_bw(struct intel_dp *intel_dp)
        case DP_LINK_BW_1_62:
        case DP_LINK_BW_2_7:
                break;
+       case DP_LINK_BW_5_4: /* 1.2 capable displays may advertise higher bw */
+               max_link_bw = DP_LINK_BW_2_7;
+               break;
        default:
+               WARN(1, "invalid max DP link bw val %x, using 1.62Gbps\n",
+                    max_link_bw);
                max_link_bw = DP_LINK_BW_1_62;
                break;
        }
index c8c9b6f48230489b0cccdf37413e5b4d8fbb28d7..b7d6e09456ce372f8a87e8f3b1ebd75df1779e70 100644 (file)
@@ -504,7 +504,7 @@ struct intel_dp {
 struct intel_digital_port {
        struct intel_encoder base;
        enum port port;
-       u32 port_reversal;
+       u32 saved_port_bits;
        struct intel_dp dp;
        struct intel_hdmi hdmi;
 };
index 98df2a0c85bdf43f9ed545489700470392b11ca1..2fd3fd5b943ee57aff93415c707798d9069cea7e 100644 (file)
@@ -785,10 +785,22 @@ static void intel_disable_hdmi(struct intel_encoder *encoder)
        }
 }
 
+static int hdmi_portclock_limit(struct intel_hdmi *hdmi)
+{
+       struct drm_device *dev = intel_hdmi_to_dev(hdmi);
+
+       if (IS_G4X(dev))
+               return 165000;
+       else if (IS_HASWELL(dev))
+               return 300000;
+       else
+               return 225000;
+}
+
 static int intel_hdmi_mode_valid(struct drm_connector *connector,
                                 struct drm_display_mode *mode)
 {
-       if (mode->clock > 165000)
+       if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector)))
                return MODE_CLOCK_HIGH;
        if (mode->clock < 20000)
                return MODE_CLOCK_LOW;
@@ -806,6 +818,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
        struct drm_device *dev = encoder->base.dev;
        struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
        int clock_12bpc = pipe_config->requested_mode.clock * 3 / 2;
+       int portclock_limit = hdmi_portclock_limit(intel_hdmi);
        int desired_bpp;
 
        if (intel_hdmi->color_range_auto) {
@@ -829,7 +842,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
         * outputs. We also need to check that the higher clock still fits
         * within limits.
         */
-       if (pipe_config->pipe_bpp > 8*3 && clock_12bpc <= 225000
+       if (pipe_config->pipe_bpp > 8*3 && clock_12bpc <= portclock_limit
            && HAS_PCH_SPLIT(dev)) {
                DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n");
                desired_bpp = 12*3;
@@ -846,7 +859,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
                pipe_config->pipe_bpp = desired_bpp;
        }
 
-       if (adjusted_mode->clock > 225000) {
+       if (adjusted_mode->clock > portclock_limit) {
                DRM_DEBUG_KMS("too high HDMI clock, rejecting mode\n");
                return false;
        }
index 021e8daa022d34485583e53eeea71d7f9ba33fb5..61348eae2f0436a05f7b5d88fec4242db918655d 100644 (file)
@@ -109,6 +109,13 @@ static void intel_lvds_get_config(struct intel_encoder *encoder,
                flags |= DRM_MODE_FLAG_PVSYNC;
 
        pipe_config->adjusted_mode.flags |= flags;
+
+       /* gen2/3 store dither state in pfit control, needs to match */
+       if (INTEL_INFO(dev)->gen < 4) {
+               tmp = I915_READ(PFIT_CONTROL);
+
+               pipe_config->gmch_pfit.control |= tmp & PANEL_8TO6_DITHER_ENABLE;
+       }
 }
 
 /* The LVDS pin pair needs to be on before the DPLLs are enabled.
@@ -290,14 +297,11 @@ static bool intel_lvds_compute_config(struct intel_encoder *intel_encoder,
 
                intel_pch_panel_fitting(intel_crtc, pipe_config,
                                        intel_connector->panel.fitting_mode);
-               return true;
        } else {
                intel_gmch_panel_fitting(intel_crtc, pipe_config,
                                         intel_connector->panel.fitting_mode);
-       }
 
-       drm_mode_set_crtcinfo(adjusted_mode, 0);
-       pipe_config->timings_set = true;
+       }
 
        /*
         * XXX: It would be nice to support lower refresh rates on the
index 80bea1d3209fad623a9d189f5ac1b3e1c12b6f0f..5950888ae1d00bd7cf70ebb18d5595ee0ee8446e 100644 (file)
@@ -194,6 +194,9 @@ void intel_gmch_panel_fitting(struct intel_crtc *intel_crtc,
            adjusted_mode->vdisplay == mode->vdisplay)
                goto out;
 
+       drm_mode_set_crtcinfo(adjusted_mode, 0);
+       pipe_config->timings_set = true;
+
        switch (fitting_mode) {
        case DRM_MODE_SCALE_CENTER:
                /*
@@ -494,8 +497,11 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max)
                goto out;
        }
 
-       /* scale to hardware */
-       level = level * freq / max;
+       /* scale to hardware, but be careful to not overflow */
+       if (freq < max)
+               level = level * freq / max;
+       else
+               level = freq / max * level;
 
        dev_priv->backlight.level = level;
        if (dev_priv->backlight.device)
@@ -512,6 +518,17 @@ void intel_panel_disable_backlight(struct drm_device *dev)
        struct drm_i915_private *dev_priv = dev->dev_private;
        unsigned long flags;
 
+       /*
+        * Do not disable backlight on the vgaswitcheroo path. When switching
+        * away from i915, the other client may depend on i915 to handle the
+        * backlight. This will leave the backlight on unnecessarily when
+        * another client is not activated.
+        */
+       if (dev->switch_power_state == DRM_SWITCH_POWER_CHANGING) {
+               DRM_DEBUG_DRIVER("Skipping backlight disable on vga switch\n");
+               return;
+       }
+
        spin_lock_irqsave(&dev_priv->backlight.lock, flags);
 
        dev_priv->backlight.enabled = false;
@@ -580,7 +597,8 @@ void intel_panel_enable_backlight(struct drm_device *dev,
                POSTING_READ(reg);
                I915_WRITE(reg, tmp | BLM_PWM_ENABLE);
 
-               if (HAS_PCH_SPLIT(dev)) {
+               if (HAS_PCH_SPLIT(dev) &&
+                   !(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) {
                        tmp = I915_READ(BLC_PWM_PCH_CTL1);
                        tmp |= BLM_PCH_PWM_ENABLE;
                        tmp &= ~BLM_PCH_OVERRIDE_ENABLE;
index ccbdd83f5220e2811a1c6f86cb2068c7aac493e3..b0e4a0bd1313c0dafac84df1b6af56e7ccced950 100644 (file)
@@ -5063,8 +5063,26 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
                }
        } else {
                if (enable_requested) {
+                       unsigned long irqflags;
+                       enum pipe p;
+
                        I915_WRITE(HSW_PWR_WELL_DRIVER, 0);
+                       POSTING_READ(HSW_PWR_WELL_DRIVER);
                        DRM_DEBUG_KMS("Requesting to disable the power well\n");
+
+                       /*
+                        * After this, the registers on the pipes that are part
+                        * of the power well will become zero, so we have to
+                        * adjust our counters according to that.
+                        *
+                        * FIXME: Should we do this in general in
+                        * drm_vblank_post_modeset?
+                        */
+                       spin_lock_irqsave(&dev->vbl_lock, irqflags);
+                       for_each_pipe(p)
+                               if (p != PIPE_A)
+                                       dev->last_vblank[p] = 0;
+                       spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
                }
        }
 }
@@ -5476,7 +5494,7 @@ static void vlv_force_wake_put(struct drm_i915_private *dev_priv)
        gen6_gt_check_fifodbg(dev_priv);
 }
 
-void intel_gt_reset(struct drm_device *dev)
+void intel_gt_sanitize(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -5487,26 +5505,61 @@ void intel_gt_reset(struct drm_device *dev)
                if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
                        __gen6_gt_force_wake_mt_reset(dev_priv);
        }
+
+       /* BIOS often leaves RC6 enabled, but disable it for hw init */
+       if (INTEL_INFO(dev)->gen >= 6)
+               intel_disable_gt_powersave(dev);
 }
 
 void intel_gt_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
 
-       spin_lock_init(&dev_priv->gt_lock);
-
-       intel_gt_reset(dev);
-
        if (IS_VALLEYVIEW(dev)) {
                dev_priv->gt.force_wake_get = vlv_force_wake_get;
                dev_priv->gt.force_wake_put = vlv_force_wake_put;
-       } else if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) {
+       } else if (IS_HASWELL(dev)) {
                dev_priv->gt.force_wake_get = __gen6_gt_force_wake_mt_get;
                dev_priv->gt.force_wake_put = __gen6_gt_force_wake_mt_put;
+       } else if (IS_IVYBRIDGE(dev)) {
+               u32 ecobus;
+
+               /* IVB configs may use multi-threaded forcewake */
+
+               /* A small trick here - if the bios hasn't configured
+                * MT forcewake, and if the device is in RC6, then
+                * force_wake_mt_get will not wake the device and the
+                * ECOBUS read will return zero. Which will be
+                * (correctly) interpreted by the test below as MT
+                * forcewake being disabled.
+                */
+               mutex_lock(&dev->struct_mutex);
+               __gen6_gt_force_wake_mt_get(dev_priv);
+               ecobus = I915_READ_NOTRACE(ECOBUS);
+               __gen6_gt_force_wake_mt_put(dev_priv);
+               mutex_unlock(&dev->struct_mutex);
+
+               if (ecobus & FORCEWAKE_MT_ENABLE) {
+                       dev_priv->gt.force_wake_get =
+                                               __gen6_gt_force_wake_mt_get;
+                       dev_priv->gt.force_wake_put =
+                                               __gen6_gt_force_wake_mt_put;
+               } else {
+                       DRM_INFO("No MT forcewake available on Ivybridge, this can result in issues\n");
+                       DRM_INFO("when using vblank-synced partial screen updates.\n");
+                       dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get;
+                       dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put;
+               }
        } else if (IS_GEN6(dev)) {
                dev_priv->gt.force_wake_get = __gen6_gt_force_wake_get;
                dev_priv->gt.force_wake_put = __gen6_gt_force_wake_put;
        }
+}
+
+void intel_pm_init(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
        INIT_DELAYED_WORK(&dev_priv->rps.delayed_resume_work,
                          intel_gen6_powersave_work);
 }
index e51ab552046c9ef943ec7d7bb1de5b5e24467154..664118d8c1d6426353ed97bb61b1113369a7678a 100644 (file)
@@ -379,6 +379,17 @@ u32 intel_ring_get_active_head(struct intel_ring_buffer *ring)
        return I915_READ(acthd_reg);
 }
 
+static void ring_setup_phys_status_page(struct intel_ring_buffer *ring)
+{
+       struct drm_i915_private *dev_priv = ring->dev->dev_private;
+       u32 addr;
+
+       addr = dev_priv->status_page_dmah->busaddr;
+       if (INTEL_INFO(ring->dev)->gen >= 4)
+               addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0;
+       I915_WRITE(HWS_PGA, addr);
+}
+
 static int init_ring_common(struct intel_ring_buffer *ring)
 {
        struct drm_device *dev = ring->dev;
@@ -390,6 +401,11 @@ static int init_ring_common(struct intel_ring_buffer *ring)
        if (HAS_FORCE_WAKE(dev))
                gen6_gt_force_wake_get(dev_priv);
 
+       if (I915_NEED_GFX_HWS(dev))
+               intel_ring_setup_status_page(ring);
+       else
+               ring_setup_phys_status_page(ring);
+
        /* Stop the ring if it's running. */
        I915_WRITE_CTL(ring, 0);
        I915_WRITE_HEAD(ring, 0);
@@ -518,9 +534,6 @@ cleanup_pipe_control(struct intel_ring_buffer *ring)
        struct pipe_control *pc = ring->private;
        struct drm_i915_gem_object *obj;
 
-       if (!ring->private)
-               return;
-
        obj = pc->obj;
 
        kunmap(sg_page(obj->pages->sgl));
@@ -528,7 +541,6 @@ cleanup_pipe_control(struct intel_ring_buffer *ring)
        drm_gem_object_unreference(&obj->base);
 
        kfree(pc);
-       ring->private = NULL;
 }
 
 static int init_render_ring(struct intel_ring_buffer *ring)
@@ -601,7 +613,10 @@ static void render_ring_cleanup(struct intel_ring_buffer *ring)
        if (HAS_BROKEN_CS_TLB(dev))
                drm_gem_object_unreference(to_gem_object(ring->private));
 
-       cleanup_pipe_control(ring);
+       if (INTEL_INFO(dev)->gen >= 5)
+               cleanup_pipe_control(ring);
+
+       ring->private = NULL;
 }
 
 static void
@@ -1223,7 +1238,6 @@ static int init_status_page(struct intel_ring_buffer *ring)
        ring->status_page.obj = obj;
        memset(ring->status_page.page_addr, 0, PAGE_SIZE);
 
-       intel_ring_setup_status_page(ring);
        DRM_DEBUG_DRIVER("%s hws offset: 0x%08x\n",
                        ring->name, ring->status_page.gfx_addr);
 
@@ -1237,10 +1251,9 @@ err:
        return ret;
 }
 
-static int init_phys_hws_pga(struct intel_ring_buffer *ring)
+static int init_phys_status_page(struct intel_ring_buffer *ring)
 {
        struct drm_i915_private *dev_priv = ring->dev->dev_private;
-       u32 addr;
 
        if (!dev_priv->status_page_dmah) {
                dev_priv->status_page_dmah =
@@ -1249,11 +1262,6 @@ static int init_phys_hws_pga(struct intel_ring_buffer *ring)
                        return -ENOMEM;
        }
 
-       addr = dev_priv->status_page_dmah->busaddr;
-       if (INTEL_INFO(ring->dev)->gen >= 4)
-               addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0;
-       I915_WRITE(HWS_PGA, addr);
-
        ring->status_page.page_addr = dev_priv->status_page_dmah->vaddr;
        memset(ring->status_page.page_addr, 0, PAGE_SIZE);
 
@@ -1281,7 +1289,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
                        return ret;
        } else {
                BUG_ON(ring->id != RCS);
-               ret = init_phys_hws_pga(ring);
+               ret = init_phys_status_page(ring);
                if (ret)
                        return ret;
        }
@@ -1893,7 +1901,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
        }
 
        if (!I915_NEED_GFX_HWS(dev)) {
-               ret = init_phys_hws_pga(ring);
+               ret = init_phys_status_page(ring);
                if (ret)
                        return ret;
        }
index 251784aa22259a44baec12749d21c9b1e2163f35..503a414cbdad2ef83db8f10c9eaadd80522c515d 100644 (file)
@@ -29,6 +29,7 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
        struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct mga_device *mdev = dev->dev_private;
+       struct drm_framebuffer *fb = crtc->fb;
        int i;
 
        if (!crtc->enabled)
@@ -36,6 +37,28 @@ static void mga_crtc_load_lut(struct drm_crtc *crtc)
 
        WREG8(DAC_INDEX + MGA1064_INDEX, 0);
 
+       if (fb && fb->bits_per_pixel == 16) {
+               int inc = (fb->depth == 15) ? 8 : 4;
+               u8 r, b;
+               for (i = 0; i < MGAG200_LUT_SIZE; i += inc) {
+                       if (fb->depth == 16) {
+                               if (i > (MGAG200_LUT_SIZE >> 1)) {
+                                       r = b = 0;
+                               } else {
+                                       r = mga_crtc->lut_r[i << 1];
+                                       b = mga_crtc->lut_b[i << 1];
+                               }
+                       } else {
+                               r = mga_crtc->lut_r[i];
+                               b = mga_crtc->lut_b[i];
+                       }
+                       /* VGA registers */
+                       WREG8(DAC_INDEX + MGA1064_COL_PAL, r);
+                       WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]);
+                       WREG8(DAC_INDEX + MGA1064_COL_PAL, b);
+               }
+               return;
+       }
        for (i = 0; i < MGAG200_LUT_SIZE; i++) {
                /* VGA registers */
                WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_r[i]);
@@ -877,7 +900,7 @@ static int mga_crtc_mode_set(struct drm_crtc *crtc,
 
        pitch = crtc->fb->pitches[0] / (crtc->fb->bits_per_pixel / 8);
        if (crtc->fb->bits_per_pixel == 24)
-               pitch = pitch >> (4 - bppshift);
+               pitch = (pitch * 3) >> (4 - bppshift);
        else
                pitch = pitch >> (4 - bppshift);
 
@@ -1251,6 +1274,24 @@ static void mga_crtc_destroy(struct drm_crtc *crtc)
        kfree(mga_crtc);
 }
 
+static void mga_crtc_disable(struct drm_crtc *crtc)
+{
+       int ret;
+       DRM_DEBUG_KMS("\n");
+       mga_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+       if (crtc->fb) {
+               struct mga_framebuffer *mga_fb = to_mga_framebuffer(crtc->fb);
+               struct drm_gem_object *obj = mga_fb->obj;
+               struct mgag200_bo *bo = gem_to_mga_bo(obj);
+               ret = mgag200_bo_reserve(bo, false);
+               if (ret)
+                       return;
+               mgag200_bo_push_sysram(bo);
+               mgag200_bo_unreserve(bo);
+       }
+       crtc->fb = NULL;
+}
+
 /* These provide the minimum set of functions required to handle a CRTC */
 static const struct drm_crtc_funcs mga_crtc_funcs = {
        .cursor_set = mga_crtc_cursor_set,
@@ -1261,6 +1302,7 @@ static const struct drm_crtc_funcs mga_crtc_funcs = {
 };
 
 static const struct drm_crtc_helper_funcs mga_helper_funcs = {
+       .disable = mga_crtc_disable,
        .dpms = mga_crtc_dpms,
        .mode_fixup = mga_crtc_mode_fixup,
        .mode_set = mga_crtc_mode_set,
@@ -1581,6 +1623,8 @@ static struct drm_connector *mga_vga_init(struct drm_device *dev)
 
        drm_connector_helper_add(connector, &mga_vga_connector_helper_funcs);
 
+       drm_sysfs_connector_add(connector);
+
        mga_connector->i2c = mgag200_i2c_create(dev);
        if (!mga_connector->i2c)
                DRM_ERROR("failed to add ddc bus\n");
index 3acb2b044c7b2d626c4efb9741c39a89f92a5ebc..d70e4a92773bfda96079b1406ffffa9a2f65a0e7 100644 (file)
@@ -323,6 +323,7 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align,
 
        mgabo->gem.driver_private = NULL;
        mgabo->bo.bdev = &mdev->ttm.bdev;
+       mgabo->bo.bdev->dev_mapping = dev->dev_mapping;
 
        mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
 
@@ -353,6 +354,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr)
                bo->pin_count++;
                if (gpu_addr)
                        *gpu_addr = mgag200_bo_gpu_offset(bo);
+               return 0;
        }
 
        mgag200_ttm_placement(bo, pl_flag);
index 262c9f5f5f60b322d1a122fe44d99e86d079c818..ce860de43e614a31c73cc6a265a152cbed191233 100644 (file)
@@ -90,6 +90,7 @@ nvc0_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                return ret;
 
        nv_subdev(priv)->unit = 0x00008000;
+       nv_subdev(priv)->intr = nouveau_falcon_intr;
        nv_engine(priv)->cclass = &nvc0_bsp_cclass;
        nv_engine(priv)->sclass = nvc0_bsp_sclass;
        return 0;
index c46882c8398253ceb1739d82dc31739fef8e09e4..ba6aeca0285ee14afac488166432c5d392ba9a01 100644 (file)
@@ -90,6 +90,7 @@ nve0_bsp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                return ret;
 
        nv_subdev(priv)->unit = 0x00008000;
+       nv_subdev(priv)->intr = nouveau_falcon_intr;
        nv_engine(priv)->cclass = &nve0_bsp_cclass;
        nv_engine(priv)->sclass = nve0_bsp_sclass;
        return 0;
index 373dbcc523b23a1cc5c16e3aa5d1c8ca271e8e98..a19e7d79b847b2447d7254c1c77aeac623fb44cc 100644 (file)
@@ -36,6 +36,8 @@ nva3_hda_eld(struct nv50_disp_priv *priv, int or, u8 *data, u32 size)
        if (data && data[0]) {
                for (i = 0; i < size; i++)
                        nv_wr32(priv, 0x61c440 + soff, (i << 8) | data[i]);
+               for (; i < 0x60; i++)
+                       nv_wr32(priv, 0x61c440 + soff, (i << 8));
                nv_mask(priv, 0x61c448 + soff, 0x80000003, 0x80000003);
        } else
        if (data) {
index dc57e24fc1df955253d1f447d8404c4d43d29fc6..717639386ced2c3e881dbf102ba39e24a5737293 100644 (file)
@@ -41,6 +41,8 @@ nvd0_hda_eld(struct nv50_disp_priv *priv, int or, u8 *data, u32 size)
        if (data && data[0]) {
                for (i = 0; i < size; i++)
                        nv_wr32(priv, 0x10ec00 + soff, (i << 8) | data[i]);
+               for (; i < 0x60; i++)
+                       nv_wr32(priv, 0x10ec00 + soff, (i << 8));
                nv_mask(priv, 0x10ec10 + soff, 0x80000003, 0x80000003);
        } else
        if (data) {
index ab1e918469a822f76bc09f4c09eb215f97a56990..526b75242899fb6e97e0abc3bd48cd228affe151 100644 (file)
@@ -47,14 +47,8 @@ int
 nv50_sor_mthd(struct nouveau_object *object, u32 mthd, void *args, u32 size)
 {
        struct nv50_disp_priv *priv = (void *)object->engine;
-       struct nouveau_bios *bios = nouveau_bios(priv);
-       const u16 type = (mthd & NV50_DISP_SOR_MTHD_TYPE) >> 12;
        const u8  head = (mthd & NV50_DISP_SOR_MTHD_HEAD) >> 3;
-       const u8  link = (mthd & NV50_DISP_SOR_MTHD_LINK) >> 2;
        const u8    or = (mthd & NV50_DISP_SOR_MTHD_OR);
-       const u16 mask = (0x0100 << head) | (0x0040 << link) | (0x0001 << or);
-       struct dcb_output outp;
-       u8  ver, hdr;
        u32 data;
        int ret = -EINVAL;
 
@@ -62,8 +56,6 @@ nv50_sor_mthd(struct nouveau_object *object, u32 mthd, void *args, u32 size)
                return -EINVAL;
        data = *(u32 *)args;
 
-       if (type && !dcb_outp_match(bios, type, mask, &ver, &hdr, &outp))
-               return -ENODEV;
 
        switch (mthd & ~0x3f) {
        case NV50_DISP_SOR_PWR:
index 3c7a31f7590edd973b84376427dfeb8d60387b0a..e03fc8e4dc1dac8c8262a93b2b0b812dcae60841 100644 (file)
 #include <engine/falcon.h>
 #include <subdev/timer.h>
 
+void
+nouveau_falcon_intr(struct nouveau_subdev *subdev)
+{
+       struct nouveau_falcon *falcon = (void *)subdev;
+       u32 dispatch = nv_ro32(falcon, 0x01c);
+       u32 intr = nv_ro32(falcon, 0x008) & dispatch & ~(dispatch >> 16);
+
+       if (intr & 0x00000010) {
+               nv_debug(falcon, "ucode halted\n");
+               nv_wo32(falcon, 0x004, 0x00000010);
+               intr &= ~0x00000010;
+       }
+
+       if (intr)  {
+               nv_error(falcon, "unhandled intr 0x%08x\n", intr);
+               nv_wo32(falcon, 0x004, intr);
+       }
+}
+
 u32
 _nouveau_falcon_rd32(struct nouveau_object *object, u64 addr)
 {
index 49ecbb859b251974eefd6c5767d1b31ae2b624dc..c19004301309ea0c039fe8336d7fffdb906b24e7 100644 (file)
@@ -265,8 +265,8 @@ nv31_mpeg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 int
 nv31_mpeg_init(struct nouveau_object *object)
 {
-       struct nouveau_engine *engine = nv_engine(object->engine);
-       struct nv31_mpeg_priv *priv = (void *)engine;
+       struct nouveau_engine *engine = nv_engine(object);
+       struct nv31_mpeg_priv *priv = (void *)object;
        struct nouveau_fb *pfb = nouveau_fb(object);
        int ret, i;
 
@@ -284,7 +284,10 @@ nv31_mpeg_init(struct nouveau_object *object)
        /* PMPEG init */
        nv_wr32(priv, 0x00b32c, 0x00000000);
        nv_wr32(priv, 0x00b314, 0x00000100);
-       nv_wr32(priv, 0x00b220, nv44_graph_class(priv) ? 0x00000044 : 0x00000031);
+       if (nv_device(priv)->chipset >= 0x40 && nv44_graph_class(priv))
+               nv_wr32(priv, 0x00b220, 0x00000044);
+       else
+               nv_wr32(priv, 0x00b220, 0x00000031);
        nv_wr32(priv, 0x00b300, 0x02001ec1);
        nv_mask(priv, 0x00b32c, 0x00000001, 0x00000001);
 
index f7c581ad1991b880b3abe6590f0250b68261a9d2..dd6196072e9c7f58062c7e500ea8c57ba19cb580 100644 (file)
@@ -61,6 +61,7 @@ nv40_mpeg_context_ctor(struct nouveau_object *parent,
        if (ret)
                return ret;
 
+       nv_wo32(&chan->base.base, 0x78, 0x02001ec1);
        return 0;
 }
 
index 98072c1ff3606117e477cb294435e0e75bc11116..73719aaa62d6474ea66fbe85ca252de826f6cff9 100644 (file)
@@ -90,6 +90,7 @@ nvc0_ppp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                return ret;
 
        nv_subdev(priv)->unit = 0x00000002;
+       nv_subdev(priv)->intr = nouveau_falcon_intr;
        nv_engine(priv)->cclass = &nvc0_ppp_cclass;
        nv_engine(priv)->sclass = nvc0_ppp_sclass;
        return 0;
index 1879229b60eb8ef4e347d16c07f78fed8a8b3f82..ac1f62aace72eb99ff1ca47849aa4828a160a2b5 100644 (file)
@@ -90,6 +90,7 @@ nvc0_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                return ret;
 
        nv_subdev(priv)->unit = 0x00020000;
+       nv_subdev(priv)->intr = nouveau_falcon_intr;
        nv_engine(priv)->cclass = &nvc0_vp_cclass;
        nv_engine(priv)->sclass = nvc0_vp_sclass;
        return 0;
index d28ecbf7bc49ee6c2fd521c6ab652237e04bb6ae..d4c3108479c9344967759c134a9d96802181b8ba 100644 (file)
@@ -90,6 +90,7 @@ nve0_vp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
                return ret;
 
        nv_subdev(priv)->unit = 0x00020000;
+       nv_subdev(priv)->intr = nouveau_falcon_intr;
        nv_engine(priv)->cclass = &nve0_vp_cclass;
        nv_engine(priv)->sclass = nve0_vp_sclass;
        return 0;
index 0639bc59d0a513725195ea64be7af30ed2dadbf0..5f6ede7c48928a799e3a2084371e5bb86a2388d4 100644 (file)
@@ -118,7 +118,13 @@ _nouveau_xtensa_init(struct nouveau_object *object)
                        return ret;
                }
 
-               ret = nouveau_gpuobj_new(object, NULL, fw->size, 0x1000, 0,
+               if (fw->size > 0x40000) {
+                       nv_warn(xtensa, "firmware %s too large\n", name);
+                       release_firmware(fw);
+                       return -EINVAL;
+               }
+
+               ret = nouveau_gpuobj_new(object, NULL, 0x40000, 0x1000, 0,
                                         &xtensa->gpu_fw);
                if (ret) {
                        release_firmware(fw);
index 1edec386ab36008e2a50272c2c2200d4ddb3f80b..181aa7da524dd1c05779f21da4aad367ce4c0e94 100644 (file)
@@ -72,6 +72,8 @@ int nouveau_falcon_create_(struct nouveau_object *, struct nouveau_object *,
                           struct nouveau_oclass *, u32, bool, const char *,
                           const char *, int, void **);
 
+void nouveau_falcon_intr(struct nouveau_subdev *subdev);
+
 #define _nouveau_falcon_dtor _nouveau_engine_dtor
 int  _nouveau_falcon_init(struct nouveau_object *);
 int  _nouveau_falcon_fini(struct nouveau_object *, bool);
index f2e87b105666f344c46e0c96c9870a062dd76340..fcf57fa309bfd54bbcbba86bdfc53ef5fcc481f6 100644 (file)
@@ -55,7 +55,7 @@ struct nouveau_vma {
 struct nouveau_vm {
        struct nouveau_vmmgr *vmm;
        struct nouveau_mm mm;
-       int refcount;
+       struct kref refcount;
 
        struct list_head pgd_list;
        atomic_t engref[NVDEV_SUBDEV_NR];
index 6c974dd83e8bcbe43daf5ac6e44f6b9690180e91..db9d6ddde52c31cc7395de7cca70ceaf0671d015 100644 (file)
@@ -81,7 +81,7 @@ void nv44_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *);
 void nv46_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size,
                       u32 pitch, u32 flags, struct nouveau_fb_tile *);
 
-void nv50_ram_put(struct nouveau_fb *, struct nouveau_mem **);
+void __nv50_ram_put(struct nouveau_fb *, struct nouveau_mem *);
 extern int nv50_fb_memtype[0x80];
 
 #endif
index af5aa7ee8ad954a465f4b6ec3183e7091731afdb..903baff77fddcc20e8e2f18a6df808d66c0d316d 100644 (file)
 #include "priv.h"
 
 void
-nv50_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
+__nv50_ram_put(struct nouveau_fb *pfb, struct nouveau_mem *mem)
 {
        struct nouveau_mm_node *this;
-       struct nouveau_mem *mem;
 
-       mem = *pmem;
-       *pmem = NULL;
-       if (unlikely(mem == NULL))
-               return;
-
-       mutex_lock(&pfb->base.mutex);
        while (!list_empty(&mem->regions)) {
                this = list_first_entry(&mem->regions, typeof(*this), rl_entry);
 
@@ -46,6 +39,19 @@ nv50_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
        }
 
        nouveau_mm_free(&pfb->tags, &mem->tag);
+}
+
+void
+nv50_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
+{
+       struct nouveau_mem *mem = *pmem;
+
+       *pmem = NULL;
+       if (unlikely(mem == NULL))
+               return;
+
+       mutex_lock(&pfb->base.mutex);
+       __nv50_ram_put(pfb, mem);
        mutex_unlock(&pfb->base.mutex);
 
        kfree(mem);
index 9c3634acbb9d8e3c404a8e251470636552d4fc6d..cf97c4de4a6b2911722da3b1799487f217cfb560 100644 (file)
@@ -33,11 +33,19 @@ void
 nvc0_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
 {
        struct nouveau_ltcg *ltcg = nouveau_ltcg(pfb);
+       struct nouveau_mem *mem = *pmem;
 
-       if ((*pmem)->tag)
-               ltcg->tags_free(ltcg, &(*pmem)->tag);
+       *pmem = NULL;
+       if (unlikely(mem == NULL))
+               return;
 
-       nv50_ram_put(pfb, pmem);
+       mutex_lock(&pfb->base.mutex);
+       if (mem->tag)
+               ltcg->tags_free(ltcg, &mem->tag);
+       __nv50_ram_put(pfb, mem);
+       mutex_unlock(&pfb->base.mutex);
+
+       kfree(mem);
 }
 
 int
index bf489dcf46e2796fed5e0e1b1f109ae2dcfe015b..c4c1d415e7feb871329c275e894558f44c60aff8 100644 (file)
@@ -103,7 +103,7 @@ nv50_gpio_intr(struct nouveau_subdev *subdev)
        int i;
 
        intr0 = nv_rd32(priv, 0xe054) & nv_rd32(priv, 0xe050);
-       if (nv_device(priv)->chipset >= 0x90)
+       if (nv_device(priv)->chipset > 0x92)
                intr1 = nv_rd32(priv, 0xe074) & nv_rd32(priv, 0xe070);
 
        hi = (intr0 & 0x0000ffff) | (intr1 << 16);
@@ -115,7 +115,7 @@ nv50_gpio_intr(struct nouveau_subdev *subdev)
        }
 
        nv_wr32(priv, 0xe054, intr0);
-       if (nv_device(priv)->chipset >= 0x90)
+       if (nv_device(priv)->chipset > 0x92)
                nv_wr32(priv, 0xe074, intr1);
 }
 
@@ -146,7 +146,7 @@ nv50_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        int ret;
 
        ret = nouveau_gpio_create(parent, engine, oclass,
-                                 nv_device(parent)->chipset >= 0x90 ? 32 : 16,
+                                 nv_device(parent)->chipset > 0x92 ? 32 : 16,
                                  &priv);
        *pobject = nv_object(priv);
        if (ret)
@@ -182,7 +182,7 @@ nv50_gpio_init(struct nouveau_object *object)
        /* disable, and ack any pending gpio interrupts */
        nv_wr32(priv, 0xe050, 0x00000000);
        nv_wr32(priv, 0xe054, 0xffffffff);
-       if (nv_device(priv)->chipset >= 0x90) {
+       if (nv_device(priv)->chipset > 0x92) {
                nv_wr32(priv, 0xe070, 0x00000000);
                nv_wr32(priv, 0xe074, 0xffffffff);
        }
@@ -195,7 +195,7 @@ nv50_gpio_fini(struct nouveau_object *object, bool suspend)
 {
        struct nv50_gpio_priv *priv = (void *)object;
        nv_wr32(priv, 0xe050, 0x00000000);
-       if (nv_device(priv)->chipset >= 0x90)
+       if (nv_device(priv)->chipset > 0x92)
                nv_wr32(priv, 0xe070, 0x00000000);
        return nouveau_gpio_fini(&priv->base, suspend);
 }
index 0cb322a5e72cdaab4f29dc7f2e6306963c110ba0..f25fc5fc7dd11a773e6743a3df5d3ae5e1235532 100644 (file)
@@ -41,7 +41,7 @@ nv50_mc_intr[] = {
        { 0x04000000, NVDEV_ENGINE_DISP },
        { 0x10000000, NVDEV_SUBDEV_BUS },
        { 0x80000000, NVDEV_ENGINE_SW },
-       { 0x0000d101, NVDEV_SUBDEV_FB },
+       { 0x0002d101, NVDEV_SUBDEV_FB },
        {},
 };
 
index 67fcb6c852ac008539548f8271889998b64043d5..ef3133e7575c8eaf937520cf750bd51effcd7505 100644 (file)
@@ -361,7 +361,7 @@ nouveau_vm_create(struct nouveau_vmmgr *vmm, u64 offset, u64 length,
 
        INIT_LIST_HEAD(&vm->pgd_list);
        vm->vmm = vmm;
-       vm->refcount = 1;
+       kref_init(&vm->refcount);
        vm->fpde = offset >> (vmm->pgt_bits + 12);
        vm->lpde = (offset + length - 1) >> (vmm->pgt_bits + 12);
 
@@ -441,8 +441,9 @@ nouveau_vm_unlink(struct nouveau_vm *vm, struct nouveau_gpuobj *mpgd)
 }
 
 static void
-nouveau_vm_del(struct nouveau_vm *vm)
+nouveau_vm_del(struct kref *kref)
 {
+       struct nouveau_vm *vm = container_of(kref, typeof(*vm), refcount);
        struct nouveau_vm_pgd *vpgd, *tmp;
 
        list_for_each_entry_safe(vpgd, tmp, &vm->pgd_list, head) {
@@ -458,27 +459,19 @@ int
 nouveau_vm_ref(struct nouveau_vm *ref, struct nouveau_vm **ptr,
               struct nouveau_gpuobj *pgd)
 {
-       struct nouveau_vm *vm;
-       int ret;
-
-       vm = ref;
-       if (vm) {
-               ret = nouveau_vm_link(vm, pgd);
+       if (ref) {
+               int ret = nouveau_vm_link(ref, pgd);
                if (ret)
                        return ret;
 
-               vm->refcount++;
+               kref_get(&ref->refcount);
        }
 
-       vm = *ptr;
-       *ptr = ref;
-
-       if (vm) {
-               nouveau_vm_unlink(vm, pgd);
-
-               if (--vm->refcount == 0)
-                       nouveau_vm_del(vm);
+       if (*ptr) {
+               nouveau_vm_unlink(*ptr, pgd);
+               kref_put(&(*ptr)->refcount, nouveau_vm_del);
        }
 
+       *ptr = ref;
        return 0;
 }
index 4b1afb131380312bc971117635c9ac072fbdba1a..af20fba3a1a47ae441f8c587d79670d445ed6374 100644 (file)
@@ -148,6 +148,7 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
 
        if (unlikely(nvbo->gem))
                DRM_ERROR("bo %p still attached to GEM object\n", bo);
+       WARN_ON(nvbo->pin_refcnt > 0);
        nv10_bo_put_tile_region(dev, nvbo->tile, NULL);
        kfree(nvbo);
 }
@@ -197,6 +198,17 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
        size_t acc_size;
        int ret;
        int type = ttm_bo_type_device;
+       int lpg_shift = 12;
+       int max_size;
+
+       if (drm->client.base.vm)
+               lpg_shift = drm->client.base.vm->vmm->lpg_shift;
+       max_size = INT_MAX & ~((1 << lpg_shift) - 1);
+
+       if (size <= 0 || size > max_size) {
+               nv_warn(drm, "skipped size %x\n", (u32)size);
+               return -EINVAL;
+       }
 
        if (sg)
                type = ttm_bo_type_sg;
@@ -340,13 +352,15 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
 {
        struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
        struct ttm_buffer_object *bo = &nvbo->bo;
-       int ret;
+       int ret, ref;
 
        ret = ttm_bo_reserve(bo, false, false, false, 0);
        if (ret)
                return ret;
 
-       if (--nvbo->pin_refcnt)
+       ref = --nvbo->pin_refcnt;
+       WARN_ON_ONCE(ref < 0);
+       if (ref)
                goto out;
 
        nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);
@@ -578,7 +592,7 @@ nve0_bo_move_init(struct nouveau_channel *chan, u32 handle)
        int ret = RING_SPACE(chan, 2);
        if (ret == 0) {
                BEGIN_NVC0(chan, NvSubCopy, 0x0000, 1);
-               OUT_RING  (chan, handle);
+               OUT_RING  (chan, handle & 0x0000ffff);
                FIRE_RING (chan);
        }
        return ret;
@@ -973,7 +987,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
        struct ttm_mem_reg *old_mem = &bo->mem;
        int ret;
 
-       mutex_lock(&chan->cli->mutex);
+       mutex_lock_nested(&chan->cli->mutex, SINGLE_DEPTH_NESTING);
 
        /* create temporary vmas for the transfer and attach them to the
         * old nouveau_mem node, these will get cleaned up after ttm has
@@ -1014,7 +1028,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
                            struct ttm_mem_reg *, struct ttm_mem_reg *);
                int (*init)(struct nouveau_channel *, u32 handle);
        } _methods[] = {
-               {  "COPY", 0, 0xa0b5, nve0_bo_move_copy, nve0_bo_move_init },
+               {  "COPY", 4, 0xa0b5, nve0_bo_move_copy, nve0_bo_move_init },
                {  "GRCE", 0, 0xa0b5, nve0_bo_move_copy, nvc0_bo_move_init },
                { "COPY1", 5, 0x90b8, nvc0_bo_move_copy, nvc0_bo_move_init },
                { "COPY0", 4, 0x90b5, nvc0_bo_move_copy, nvc0_bo_move_init },
@@ -1034,7 +1048,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
                struct nouveau_channel *chan;
                u32 handle = (mthd->engine << 16) | mthd->oclass;
 
-               if (mthd->init == nve0_bo_move_init)
+               if (mthd->engine)
                        chan = drm->cechan;
                else
                        chan = drm->channel;
index 708b2d1c0037e689b579b860d812463c01a9bf2e..907d20ef6d4d119f81c06fe1801edf3867f01673 100644 (file)
@@ -138,7 +138,7 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
 {
        struct nouveau_framebuffer *nouveau_fb;
        struct drm_gem_object *gem;
-       int ret;
+       int ret = -ENOMEM;
 
        gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
        if (!gem)
@@ -146,15 +146,19 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
 
        nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL);
        if (!nouveau_fb)
-               return ERR_PTR(-ENOMEM);
+               goto err_unref;
 
        ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem));
-       if (ret) {
-               drm_gem_object_unreference(gem);
-               return ERR_PTR(ret);
-       }
+       if (ret)
+               goto err;
 
        return &nouveau_fb->base;
+
+err:
+       kfree(nouveau_fb);
+err_unref:
+       drm_gem_object_unreference(gem);
+       return ERR_PTR(ret);
 }
 
 static const struct drm_mode_config_funcs nouveau_mode_config_funcs = {
@@ -524,9 +528,12 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        struct nouveau_page_flip_state *s;
        struct nouveau_channel *chan = NULL;
        struct nouveau_fence *fence;
-       struct list_head res;
-       struct ttm_validate_buffer res_val[2];
+       struct ttm_validate_buffer resv[2] = {
+               { .bo = &old_bo->bo },
+               { .bo = &new_bo->bo },
+       };
        struct ww_acquire_ctx ticket;
+       LIST_HEAD(res);
        int ret;
 
        if (!drm->channel)
@@ -545,27 +552,19 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
                chan = drm->channel;
        spin_unlock(&old_bo->bo.bdev->fence_lock);
 
-       mutex_lock(&chan->cli->mutex);
-
        if (new_bo != old_bo) {
                ret = nouveau_bo_pin(new_bo, TTM_PL_FLAG_VRAM);
-               if (likely(!ret)) {
-                       res_val[0].bo = &old_bo->bo;
-                       res_val[1].bo = &new_bo->bo;
-                       INIT_LIST_HEAD(&res);
-                       list_add_tail(&res_val[0].head, &res);
-                       list_add_tail(&res_val[1].head, &res);
-                       ret = ttm_eu_reserve_buffers(&ticket, &res);
-                       if (ret)
-                               nouveau_bo_unpin(new_bo);
-               }
-       } else
-               ret = ttm_bo_reserve(&new_bo->bo, false, false, false, 0);
+               if (ret)
+                       goto fail_free;
 
-       if (ret) {
-               mutex_unlock(&chan->cli->mutex);
-               goto fail_free;
+               list_add(&resv[1].head, &res);
        }
+       list_add(&resv[0].head, &res);
+
+       mutex_lock(&chan->cli->mutex);
+       ret = ttm_eu_reserve_buffers(&ticket, &res);
+       if (ret)
+               goto fail_unpin;
 
        /* Initialize a page flip struct */
        *s = (struct nouveau_page_flip_state)
@@ -576,10 +575,8 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        /* Emit a page flip */
        if (nv_device(drm->device)->card_type >= NV_50) {
                ret = nv50_display_flip_next(crtc, fb, chan, 0);
-               if (ret) {
-                       mutex_unlock(&chan->cli->mutex);
+               if (ret)
                        goto fail_unreserve;
-               }
        }
 
        ret = nouveau_page_flip_emit(chan, old_bo, new_bo, s, &fence);
@@ -590,22 +587,18 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        /* Update the crtc struct and cleanup */
        crtc->fb = fb;
 
-       if (old_bo != new_bo) {
-               ttm_eu_fence_buffer_objects(&ticket, &res, fence);
+       ttm_eu_fence_buffer_objects(&ticket, &res, fence);
+       if (old_bo != new_bo)
                nouveau_bo_unpin(old_bo);
-       } else {
-               nouveau_bo_fence(new_bo, fence);
-               ttm_bo_unreserve(&new_bo->bo);
-       }
        nouveau_fence_unref(&fence);
        return 0;
 
 fail_unreserve:
-       if (old_bo != new_bo) {
-               ttm_eu_backoff_reservation(&ticket, &res);
+       ttm_eu_backoff_reservation(&ticket, &res);
+fail_unpin:
+       mutex_unlock(&chan->cli->mutex);
+       if (old_bo != new_bo)
                nouveau_bo_unpin(new_bo);
-       } else
-               ttm_bo_unreserve(&new_bo->bo);
 fail_free:
        kfree(s);
        return ret;
index 218a4b522fe591ecca92eee558afc2e1baf9ff0c..61972668fd0532f9f29e6ea540ab925713d5cf7d 100644 (file)
@@ -192,6 +192,18 @@ nouveau_accel_init(struct nouveau_drm *drm)
 
                arg0 = NVE0_CHANNEL_IND_ENGINE_GR;
                arg1 = 1;
+       } else
+       if (device->chipset >= 0xa3 &&
+           device->chipset != 0xaa &&
+           device->chipset != 0xac) {
+               ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE,
+                                         NVDRM_CHAN + 1, NvDmaFB, NvDmaTT,
+                                         &drm->cechan);
+               if (ret)
+                       NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
+
+               arg0 = NvDmaFB;
+               arg1 = NvDmaTT;
        } else {
                arg0 = NvDmaFB;
                arg1 = NvDmaTT;
@@ -284,8 +296,6 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
        return 0;
 }
 
-static struct lock_class_key drm_client_lock_class_key;
-
 static int
 nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 {
@@ -297,7 +307,6 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
        ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm);
        if (ret)
                return ret;
-       lockdep_set_class(&drm->client.mutex, &drm_client_lock_class_key);
 
        dev->dev_private = drm;
        drm->dev = dev;
index 9352010030e9fd6f885834aca9e81c769fa61e10..8f6d63d7edd314c4f6a6ff7e492c3b37be88930e 100644 (file)
@@ -385,6 +385,7 @@ out_unlock:
        mutex_unlock(&dev->struct_mutex);
        if (chan)
                nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma);
+       nouveau_bo_unmap(nvbo);
 out_unpin:
        nouveau_bo_unpin(nvbo);
 out_unref:
@@ -397,7 +398,8 @@ void
 nouveau_fbcon_output_poll_changed(struct drm_device *dev)
 {
        struct nouveau_drm *drm = nouveau_drm(dev);
-       drm_fb_helper_hotplug_event(&drm->fbcon->helper);
+       if (drm->fbcon)
+               drm_fb_helper_hotplug_event(&drm->fbcon->helper);
 }
 
 static int
index 1680d9187bab6623cc958be6f3fa603b9f9e6941..be3149932c2d4c3035a36cf40e68f04af8ffd808 100644 (file)
@@ -143,7 +143,7 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan)
        int ret;
 
        fence->channel  = chan;
-       fence->timeout  = jiffies + (3 * DRM_HZ);
+       fence->timeout  = jiffies + (15 * DRM_HZ);
        fence->sequence = ++fctx->sequence;
 
        ret = fctx->emit(fence);
index e72d09c068a8e8bcb8de4b47abd1ea0340415c12..830cb7bad922bba909a6c5129c16a786cb9ee969 100644 (file)
@@ -50,12 +50,6 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
                return;
        nvbo->gem = NULL;
 
-       /* Lockdep hates you for doing reserve with gem object lock held */
-       if (WARN_ON_ONCE(nvbo->pin_refcnt)) {
-               nvbo->pin_refcnt = 1;
-               nouveau_bo_unpin(nvbo);
-       }
-
        if (gem->import_attach)
                drm_prime_gem_destroy(gem, nvbo->bo.sg);
 
index 8e47a9bae8c301e1ac205a0140ef650ed9d7aa5f..22aa9963ea6fd46b36f28b457fa7cfeecac0372b 100644 (file)
@@ -76,7 +76,7 @@ nv17_fence_context_new(struct nouveau_channel *chan)
        struct ttm_mem_reg *mem = &priv->bo->bo.mem;
        struct nouveau_object *object;
        u32 start = mem->start * PAGE_SIZE;
-       u32 limit = mem->start + mem->size - 1;
+       u32 limit = start + mem->size - 1;
        int ret = 0;
 
        fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
index 54dc6355b0c2a02b7629440248a3cfb5e22a234c..8b40a36c1b57eb2f4e1eeac30a20478e7f563974 100644 (file)
@@ -355,6 +355,7 @@ struct nv50_oimm {
 
 struct nv50_head {
        struct nouveau_crtc base;
+       struct nouveau_bo *image;
        struct nv50_curs curs;
        struct nv50_sync sync;
        struct nv50_ovly ovly;
@@ -517,9 +518,10 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 {
        struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+       struct nv50_head *head = nv50_head(crtc);
        struct nv50_sync *sync = nv50_sync(crtc);
-       int head = nv_crtc->index, ret;
        u32 *push;
+       int ret;
 
        swap_interval <<= 4;
        if (swap_interval == 0)
@@ -537,7 +539,7 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
                        return ret;
 
                BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2);
-               OUT_RING  (chan, NvEvoSema0 + head);
+               OUT_RING  (chan, NvEvoSema0 + nv_crtc->index);
                OUT_RING  (chan, sync->addr ^ 0x10);
                BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1);
                OUT_RING  (chan, sync->data + 1);
@@ -546,7 +548,7 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
                OUT_RING  (chan, sync->data);
        } else
        if (chan && nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) {
-               u64 addr = nv84_fence_crtc(chan, head) + sync->addr;
+               u64 addr = nv84_fence_crtc(chan, nv_crtc->index) + sync->addr;
                ret = RING_SPACE(chan, 12);
                if (ret)
                        return ret;
@@ -565,7 +567,7 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
                OUT_RING  (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL);
        } else
        if (chan) {
-               u64 addr = nv84_fence_crtc(chan, head) + sync->addr;
+               u64 addr = nv84_fence_crtc(chan, nv_crtc->index) + sync->addr;
                ret = RING_SPACE(chan, 10);
                if (ret)
                        return ret;
@@ -630,6 +632,8 @@ nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
        evo_mthd(push, 0x0080, 1);
        evo_data(push, 0x00000000);
        evo_kick(push, sync);
+
+       nouveau_bo_ref(nv_fb->nvbo, &head->image);
        return 0;
 }
 
@@ -1038,18 +1042,17 @@ static int
 nv50_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb)
 {
        struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb);
+       struct nv50_head *head = nv50_head(crtc);
        int ret;
 
        ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM);
-       if (ret)
-               return ret;
-
-       if (old_fb) {
-               nvfb = nouveau_framebuffer(old_fb);
-               nouveau_bo_unpin(nvfb->nvbo);
+       if (ret == 0) {
+               if (head->image)
+                       nouveau_bo_unpin(head->image);
+               nouveau_bo_ref(nvfb->nvbo, &head->image);
        }
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -1198,6 +1201,15 @@ nv50_crtc_lut_load(struct drm_crtc *crtc)
        }
 }
 
+static void
+nv50_crtc_disable(struct drm_crtc *crtc)
+{
+       struct nv50_head *head = nv50_head(crtc);
+       if (head->image)
+               nouveau_bo_unpin(head->image);
+       nouveau_bo_ref(NULL, &head->image);
+}
+
 static int
 nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
                     uint32_t handle, uint32_t width, uint32_t height)
@@ -1271,18 +1283,29 @@ nv50_crtc_destroy(struct drm_crtc *crtc)
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
        struct nv50_disp *disp = nv50_disp(crtc->dev);
        struct nv50_head *head = nv50_head(crtc);
+
        nv50_dmac_destroy(disp->core, &head->ovly.base);
        nv50_pioc_destroy(disp->core, &head->oimm.base);
        nv50_dmac_destroy(disp->core, &head->sync.base);
        nv50_pioc_destroy(disp->core, &head->curs.base);
+
+       /*XXX: this shouldn't be necessary, but the core doesn't call
+        *     disconnect() during the cleanup paths
+        */
+       if (head->image)
+               nouveau_bo_unpin(head->image);
+       nouveau_bo_ref(NULL, &head->image);
+
        nouveau_bo_unmap(nv_crtc->cursor.nvbo);
        if (nv_crtc->cursor.nvbo)
                nouveau_bo_unpin(nv_crtc->cursor.nvbo);
        nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
+
        nouveau_bo_unmap(nv_crtc->lut.nvbo);
        if (nv_crtc->lut.nvbo)
                nouveau_bo_unpin(nv_crtc->lut.nvbo);
        nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
+
        drm_crtc_cleanup(crtc);
        kfree(crtc);
 }
@@ -1296,6 +1319,7 @@ static const struct drm_crtc_helper_funcs nv50_crtc_hfunc = {
        .mode_set_base = nv50_crtc_mode_set_base,
        .mode_set_base_atomic = nv50_crtc_mode_set_base_atomic,
        .load_lut = nv50_crtc_lut_load,
+       .disable = nv50_crtc_disable,
 };
 
 static const struct drm_crtc_funcs nv50_crtc_func = {
index f9701e567db89793136c52e02bf11d59baba4ce4..0ee363840035b1e67bd3e6c6b8bb63afbf4d8ea3 100644 (file)
@@ -39,6 +39,8 @@ nv50_fence_context_new(struct nouveau_channel *chan)
        struct nv10_fence_chan *fctx;
        struct ttm_mem_reg *mem = &priv->bo->bo.mem;
        struct nouveau_object *object;
+       u32 start = mem->start * PAGE_SIZE;
+       u32 limit = start + mem->size - 1;
        int ret, i;
 
        fctx = chan->fence = kzalloc(sizeof(*fctx), GFP_KERNEL);
@@ -51,26 +53,28 @@ nv50_fence_context_new(struct nouveau_channel *chan)
        fctx->base.sync = nv17_fence_sync;
 
        ret = nouveau_object_new(nv_object(chan->cli), chan->handle,
-                                NvSema, 0x0002,
+                                NvSema, 0x003d,
                                 &(struct nv_dma_class) {
                                        .flags = NV_DMA_TARGET_VRAM |
                                                 NV_DMA_ACCESS_RDWR,
-                                       .start = mem->start * PAGE_SIZE,
-                                       .limit = mem->size - 1,
+                                       .start = start,
+                                       .limit = limit,
                                 }, sizeof(struct nv_dma_class),
                                 &object);
 
        /* dma objects for display sync channel semaphore blocks */
        for (i = 0; !ret && i < dev->mode_config.num_crtc; i++) {
                struct nouveau_bo *bo = nv50_display_crtc_sema(dev, i);
+               u32 start = bo->bo.mem.start * PAGE_SIZE;
+               u32 limit = start + bo->bo.mem.size - 1;
 
                ret = nouveau_object_new(nv_object(chan->cli), chan->handle,
                                         NvEvoSema0 + i, 0x003d,
                                         &(struct nv_dma_class) {
                                                .flags = NV_DMA_TARGET_VRAM |
                                                         NV_DMA_ACCESS_RDWR,
-                                               .start = bo->bo.offset,
-                                               .limit = bo->bo.offset + 0xfff,
+                                               .start = start,
+                                               .limit = limit,
                                         }, sizeof(struct nv_dma_class),
                                         &object);
        }
index 93c2f2cceb5165c25e80c6480c60c3e2e9e7fd62..eb89653a7a1710adf2842a2d2fb811cbe6c62737 100644 (file)
@@ -179,9 +179,10 @@ qxl_push_command_ring_release(struct qxl_device *qdev, struct qxl_release *relea
                              uint32_t type, bool interruptible)
 {
        struct qxl_command cmd;
+       struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
 
        cmd.type = type;
-       cmd.data = qxl_bo_physical_address(qdev, release->bos[0], release->release_offset);
+       cmd.data = qxl_bo_physical_address(qdev, to_qxl_bo(entry->tv.bo), release->release_offset);
 
        return qxl_ring_push(qdev->command_ring, &cmd, interruptible);
 }
@@ -191,9 +192,10 @@ qxl_push_cursor_ring_release(struct qxl_device *qdev, struct qxl_release *releas
                             uint32_t type, bool interruptible)
 {
        struct qxl_command cmd;
+       struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
 
        cmd.type = type;
-       cmd.data = qxl_bo_physical_address(qdev, release->bos[0], release->release_offset);
+       cmd.data = qxl_bo_physical_address(qdev, to_qxl_bo(entry->tv.bo), release->release_offset);
 
        return qxl_ring_push(qdev->cursor_ring, &cmd, interruptible);
 }
@@ -214,7 +216,6 @@ int qxl_garbage_collect(struct qxl_device *qdev)
        struct qxl_release *release;
        uint64_t id, next_id;
        int i = 0;
-       int ret;
        union qxl_release_info *info;
 
        while (qxl_ring_pop(qdev->release_ring, &id)) {
@@ -224,17 +225,10 @@ int qxl_garbage_collect(struct qxl_device *qdev)
                        if (release == NULL)
                                break;
 
-                       ret = qxl_release_reserve(qdev, release, false);
-                       if (ret) {
-                               qxl_io_log(qdev, "failed to reserve release on garbage collect %lld\n", id);
-                               DRM_ERROR("failed to reserve release %lld\n", id);
-                       }
-
                        info = qxl_release_map(qdev, release);
                        next_id = info->next;
                        qxl_release_unmap(qdev, release, info);
 
-                       qxl_release_unreserve(qdev, release);
                        QXL_INFO(qdev, "popped %lld, next %lld\n", id,
                                next_id);
 
@@ -259,27 +253,29 @@ int qxl_garbage_collect(struct qxl_device *qdev)
        return i;
 }
 
-int qxl_alloc_bo_reserved(struct qxl_device *qdev, unsigned long size,
+int qxl_alloc_bo_reserved(struct qxl_device *qdev,
+                         struct qxl_release *release,
+                         unsigned long size,
                          struct qxl_bo **_bo)
 {
        struct qxl_bo *bo;
        int ret;
 
        ret = qxl_bo_create(qdev, size, false /* not kernel - device */,
-                           QXL_GEM_DOMAIN_VRAM, NULL, &bo);
+                           false, QXL_GEM_DOMAIN_VRAM, NULL, &bo);
        if (ret) {
                DRM_ERROR("failed to allocate VRAM BO\n");
                return ret;
        }
-       ret = qxl_bo_reserve(bo, false);
-       if (unlikely(ret != 0))
+       ret = qxl_release_list_add(release, bo);
+       if (ret)
                goto out_unref;
 
        *_bo = bo;
        return 0;
 out_unref:
        qxl_bo_unref(&bo);
-       return 0;
+       return ret;
 }
 
 static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port, bool intr)
@@ -503,6 +499,10 @@ int qxl_hw_surface_alloc(struct qxl_device *qdev,
        if (ret)
                return ret;
 
+       ret = qxl_release_reserve_list(release, true);
+       if (ret)
+               return ret;
+
        cmd = (struct qxl_surface_cmd *)qxl_release_map(qdev, release);
        cmd->type = QXL_SURFACE_CMD_CREATE;
        cmd->u.surface_create.format = surf->surf.format;
@@ -524,14 +524,11 @@ int qxl_hw_surface_alloc(struct qxl_device *qdev,
 
        surf->surf_create = release;
 
-       /* no need to add a release to the fence for this bo,
+       /* no need to add a release to the fence for this surface bo,
           since it is only released when we ask to destroy the surface
           and it would never signal otherwise */
-       qxl_fence_releaseable(qdev, release);
-
        qxl_push_command_ring_release(qdev, release, QXL_CMD_SURFACE, false);
-
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
 
        surf->hw_surf_alloc = true;
        spin_lock(&qdev->surf_id_idr_lock);
@@ -573,12 +570,9 @@ int qxl_hw_surface_dealloc(struct qxl_device *qdev,
        cmd->surface_id = id;
        qxl_release_unmap(qdev, release, &cmd->release_info);
 
-       qxl_fence_releaseable(qdev, release);
-
        qxl_push_command_ring_release(qdev, release, QXL_CMD_SURFACE, false);
 
-       qxl_release_unreserve(qdev, release);
-
+       qxl_release_fence_buffer_objects(release);
 
        return 0;
 }
index f76f5dd7bfc43281b8c5fed9d06ffd6f0876eb92..835caba026d399d4e3750fbc3b47d44c7c6b7df5 100644 (file)
@@ -179,7 +179,7 @@ static void qxl_crtc_destroy(struct drm_crtc *crtc)
        kfree(qxl_crtc);
 }
 
-static void
+static int
 qxl_hide_cursor(struct qxl_device *qdev)
 {
        struct qxl_release *release;
@@ -188,14 +188,22 @@ qxl_hide_cursor(struct qxl_device *qdev)
 
        ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), QXL_RELEASE_CURSOR_CMD,
                                         &release, NULL);
+       if (ret)
+               return ret;
+
+       ret = qxl_release_reserve_list(release, true);
+       if (ret) {
+               qxl_release_free(qdev, release);
+               return ret;
+       }
 
        cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
        cmd->type = QXL_CURSOR_HIDE;
        qxl_release_unmap(qdev, release, &cmd->release_info);
 
-       qxl_fence_releaseable(qdev, release);
        qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
+       return 0;
 }
 
 static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
@@ -216,10 +224,8 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
 
        int size = 64*64*4;
        int ret = 0;
-       if (!handle) {
-               qxl_hide_cursor(qdev);
-               return 0;
-       }
+       if (!handle)
+               return qxl_hide_cursor(qdev);
 
        obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
        if (!obj) {
@@ -234,8 +240,9 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
                goto out_unref;
 
        ret = qxl_bo_pin(user_bo, QXL_GEM_DOMAIN_CPU, NULL);
+       qxl_bo_unreserve(user_bo);
        if (ret)
-               goto out_unreserve;
+               goto out_unref;
 
        ret = qxl_bo_kmap(user_bo, &user_ptr);
        if (ret)
@@ -246,14 +253,20 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
                                         &release, NULL);
        if (ret)
                goto out_kunmap;
-       ret = qxl_alloc_bo_reserved(qdev, sizeof(struct qxl_cursor) + size,
-                                   &cursor_bo);
+
+       ret = qxl_alloc_bo_reserved(qdev, release, sizeof(struct qxl_cursor) + size,
+                          &cursor_bo);
        if (ret)
                goto out_free_release;
-       ret = qxl_bo_kmap(cursor_bo, (void **)&cursor);
+
+       ret = qxl_release_reserve_list(release, false);
        if (ret)
                goto out_free_bo;
 
+       ret = qxl_bo_kmap(cursor_bo, (void **)&cursor);
+       if (ret)
+               goto out_backoff;
+
        cursor->header.unique = 0;
        cursor->header.type = SPICE_CURSOR_TYPE_ALPHA;
        cursor->header.width = 64;
@@ -269,11 +282,7 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
 
        qxl_bo_kunmap(cursor_bo);
 
-       /* finish with the userspace bo */
        qxl_bo_kunmap(user_bo);
-       qxl_bo_unpin(user_bo);
-       qxl_bo_unreserve(user_bo);
-       drm_gem_object_unreference_unlocked(obj);
 
        cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
        cmd->type = QXL_CURSOR_SET;
@@ -281,30 +290,35 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
        cmd->u.set.position.y = qcrtc->cur_y;
 
        cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
-       qxl_release_add_res(qdev, release, cursor_bo);
 
        cmd->u.set.visible = 1;
        qxl_release_unmap(qdev, release, &cmd->release_info);
 
-       qxl_fence_releaseable(qdev, release);
        qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
+
+       /* finish with the userspace bo */
+       ret = qxl_bo_reserve(user_bo, false);
+       if (!ret) {
+               qxl_bo_unpin(user_bo);
+               qxl_bo_unreserve(user_bo);
+       }
+       drm_gem_object_unreference_unlocked(obj);
 
-       qxl_bo_unreserve(cursor_bo);
        qxl_bo_unref(&cursor_bo);
 
        return ret;
+
+out_backoff:
+       qxl_release_backoff_reserve_list(release);
 out_free_bo:
        qxl_bo_unref(&cursor_bo);
 out_free_release:
-       qxl_release_unreserve(qdev, release);
        qxl_release_free(qdev, release);
 out_kunmap:
        qxl_bo_kunmap(user_bo);
 out_unpin:
        qxl_bo_unpin(user_bo);
-out_unreserve:
-       qxl_bo_unreserve(user_bo);
 out_unref:
        drm_gem_object_unreference_unlocked(obj);
        return ret;
@@ -322,6 +336,14 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
 
        ret = qxl_alloc_release_reserved(qdev, sizeof(*cmd), QXL_RELEASE_CURSOR_CMD,
                                   &release, NULL);
+       if (ret)
+               return ret;
+
+       ret = qxl_release_reserve_list(release, true);
+       if (ret) {
+               qxl_release_free(qdev, release);
+               return ret;
+       }
 
        qcrtc->cur_x = x;
        qcrtc->cur_y = y;
@@ -332,9 +354,9 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
        cmd->u.position.y = qcrtc->cur_y;
        qxl_release_unmap(qdev, release, &cmd->release_info);
 
-       qxl_fence_releaseable(qdev, release);
        qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
+
        return 0;
 }
 
index 3c8c3dbf93782522eac671a3d6c8cf5f1af3e4bc..56e1d633875e2772b6a3f767e3af44e013f3519d 100644 (file)
 #include "qxl_drv.h"
 #include "qxl_object.h"
 
+static int alloc_clips(struct qxl_device *qdev,
+                      struct qxl_release *release,
+                      unsigned num_clips,
+                      struct qxl_bo **clips_bo)
+{
+       int size = sizeof(struct qxl_clip_rects) + sizeof(struct qxl_rect) * num_clips;
+
+       return qxl_alloc_bo_reserved(qdev, release, size, clips_bo);
+}
+
 /* returns a pointer to the already allocated qxl_rect array inside
  * the qxl_clip_rects. This is *not* the same as the memory allocated
  * on the device, it is offset to qxl_clip_rects.chunk.data */
 static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev,
                                              struct qxl_drawable *drawable,
                                              unsigned num_clips,
-                                             struct qxl_bo **clips_bo,
-                                             struct qxl_release *release)
+                                             struct qxl_bo *clips_bo)
 {
        struct qxl_clip_rects *dev_clips;
        int ret;
-       int size = sizeof(*dev_clips) + sizeof(struct qxl_rect) * num_clips;
-       ret = qxl_alloc_bo_reserved(qdev, size, clips_bo);
-       if (ret)
-               return NULL;
 
-       ret = qxl_bo_kmap(*clips_bo, (void **)&dev_clips);
+       ret = qxl_bo_kmap(clips_bo, (void **)&dev_clips);
        if (ret) {
-               qxl_bo_unref(clips_bo);
                return NULL;
        }
        dev_clips->num_rects = num_clips;
@@ -51,21 +55,35 @@ static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev,
        return (struct qxl_rect *)dev_clips->chunk.data;
 }
 
+static int
+alloc_drawable(struct qxl_device *qdev, struct qxl_release **release)
+{
+       int ret;
+       ret = qxl_alloc_release_reserved(qdev, sizeof(struct qxl_drawable),
+                                        QXL_RELEASE_DRAWABLE, release,
+                                        NULL);
+       return ret;
+}
+
+static void
+free_drawable(struct qxl_device *qdev, struct qxl_release *release)
+{
+       qxl_release_free(qdev, release);
+}
+
+/* release needs to be reserved at this point */
 static int
 make_drawable(struct qxl_device *qdev, int surface, uint8_t type,
              const struct qxl_rect *rect,
-             struct qxl_release **release)
+             struct qxl_release *release)
 {
        struct qxl_drawable *drawable;
-       int i, ret;
+       int i;
 
-       ret = qxl_alloc_release_reserved(qdev, sizeof(*drawable),
-                                        QXL_RELEASE_DRAWABLE, release,
-                                        NULL);
-       if (ret)
-               return ret;
+       drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
+       if (!drawable)
+               return -ENOMEM;
 
-       drawable = (struct qxl_drawable *)qxl_release_map(qdev, *release);
        drawable->type = type;
 
        drawable->surface_id = surface;         /* Only primary for now */
@@ -91,14 +109,23 @@ make_drawable(struct qxl_device *qdev, int surface, uint8_t type,
                drawable->bbox = *rect;
 
        drawable->mm_time = qdev->rom->mm_clock;
-       qxl_release_unmap(qdev, *release, &drawable->release_info);
+       qxl_release_unmap(qdev, release, &drawable->release_info);
        return 0;
 }
 
-static int qxl_palette_create_1bit(struct qxl_bo **palette_bo,
+static int alloc_palette_object(struct qxl_device *qdev,
+                               struct qxl_release *release,
+                               struct qxl_bo **palette_bo)
+{
+       return qxl_alloc_bo_reserved(qdev, release,
+                                    sizeof(struct qxl_palette) + sizeof(uint32_t) * 2,
+                                    palette_bo);
+}
+
+static int qxl_palette_create_1bit(struct qxl_bo *palette_bo,
+                                  struct qxl_release *release,
                                   const struct qxl_fb_image *qxl_fb_image)
 {
-       struct qxl_device *qdev = qxl_fb_image->qdev;
        const struct fb_image *fb_image = &qxl_fb_image->fb_image;
        uint32_t visual = qxl_fb_image->visual;
        const uint32_t *pseudo_palette = qxl_fb_image->pseudo_palette;
@@ -108,12 +135,7 @@ static int qxl_palette_create_1bit(struct qxl_bo **palette_bo,
        static uint64_t unique; /* we make no attempt to actually set this
                                 * correctly globaly, since that would require
                                 * tracking all of our palettes. */
-
-       ret = qxl_alloc_bo_reserved(qdev,
-                                   sizeof(struct qxl_palette) + sizeof(uint32_t) * 2,
-                                   palette_bo);
-
-       ret = qxl_bo_kmap(*palette_bo, (void **)&pal);
+       ret = qxl_bo_kmap(palette_bo, (void **)&pal);
        pal->num_ents = 2;
        pal->unique = unique++;
        if (visual == FB_VISUAL_TRUECOLOR || visual == FB_VISUAL_DIRECTCOLOR) {
@@ -126,7 +148,7 @@ static int qxl_palette_create_1bit(struct qxl_bo **palette_bo,
        }
        pal->ents[0] = bgcolor;
        pal->ents[1] = fgcolor;
-       qxl_bo_kunmap(*palette_bo);
+       qxl_bo_kunmap(palette_bo);
        return 0;
 }
 
@@ -144,44 +166,63 @@ void qxl_draw_opaque_fb(const struct qxl_fb_image *qxl_fb_image,
        const char *src = fb_image->data;
        int depth = fb_image->depth;
        struct qxl_release *release;
-       struct qxl_bo *image_bo;
        struct qxl_image *image;
        int ret;
-
+       struct qxl_drm_image *dimage;
+       struct qxl_bo *palette_bo = NULL;
        if (stride == 0)
                stride = depth * width / 8;
 
+       ret = alloc_drawable(qdev, &release);
+       if (ret)
+               return;
+
+       ret = qxl_image_alloc_objects(qdev, release,
+                                     &dimage,
+                                     height, stride);
+       if (ret)
+               goto out_free_drawable;
+
+       if (depth == 1) {
+               ret = alloc_palette_object(qdev, release, &palette_bo);
+               if (ret)
+                       goto out_free_image;
+       }
+
+       /* do a reservation run over all the objects we just allocated */
+       ret = qxl_release_reserve_list(release, true);
+       if (ret)
+               goto out_free_palette;
+
        rect.left = x;
        rect.right = x + width;
        rect.top = y;
        rect.bottom = y + height;
 
-       ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &rect, &release);
-       if (ret)
-               return;
+       ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &rect, release);
+       if (ret) {
+               qxl_release_backoff_reserve_list(release);
+               goto out_free_palette;
+       }
 
-       ret = qxl_image_create(qdev, release, &image_bo,
-                              (const uint8_t *)src, 0, 0,
-                              width, height, depth, stride);
+       ret = qxl_image_init(qdev, release, dimage,
+                            (const uint8_t *)src, 0, 0,
+                            width, height, depth, stride);
        if (ret) {
-               qxl_release_unreserve(qdev, release);
+               qxl_release_backoff_reserve_list(release);
                qxl_release_free(qdev, release);
                return;
        }
 
        if (depth == 1) {
-               struct qxl_bo *palette_bo;
                void *ptr;
-               ret = qxl_palette_create_1bit(&palette_bo, qxl_fb_image);
-               qxl_release_add_res(qdev, release, palette_bo);
+               ret = qxl_palette_create_1bit(palette_bo, release, qxl_fb_image);
 
-               ptr = qxl_bo_kmap_atomic_page(qdev, image_bo, 0);
+               ptr = qxl_bo_kmap_atomic_page(qdev, dimage->bo, 0);
                image = ptr;
                image->u.bitmap.palette =
                        qxl_bo_physical_address(qdev, palette_bo, 0);
-               qxl_bo_kunmap_atomic_page(qdev, image_bo, ptr);
-               qxl_bo_unreserve(palette_bo);
-               qxl_bo_unref(&palette_bo);
+               qxl_bo_kunmap_atomic_page(qdev, dimage->bo, ptr);
        }
 
        drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
@@ -199,16 +240,20 @@ void qxl_draw_opaque_fb(const struct qxl_fb_image *qxl_fb_image,
        drawable->u.copy.mask.bitmap = 0;
 
        drawable->u.copy.src_bitmap =
-               qxl_bo_physical_address(qdev, image_bo, 0);
+               qxl_bo_physical_address(qdev, dimage->bo, 0);
        qxl_release_unmap(qdev, release, &drawable->release_info);
 
-       qxl_release_add_res(qdev, release, image_bo);
-       qxl_bo_unreserve(image_bo);
-       qxl_bo_unref(&image_bo);
-
-       qxl_fence_releaseable(qdev, release);
        qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
+
+out_free_palette:
+       if (palette_bo)
+               qxl_bo_unref(&palette_bo);
+out_free_image:
+       qxl_image_free_objects(qdev, dimage);
+out_free_drawable:
+       if (ret)
+               free_drawable(qdev, release);
 }
 
 /* push a draw command using the given clipping rectangles as
@@ -243,10 +288,14 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
        int depth = qxl_fb->base.bits_per_pixel;
        uint8_t *surface_base;
        struct qxl_release *release;
-       struct qxl_bo *image_bo;
        struct qxl_bo *clips_bo;
+       struct qxl_drm_image *dimage;
        int ret;
 
+       ret = alloc_drawable(qdev, &release);
+       if (ret)
+               return;
+
        left = clips->x1;
        right = clips->x2;
        top = clips->y1;
@@ -263,36 +312,52 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
 
        width = right - left;
        height = bottom - top;
+
+       ret = alloc_clips(qdev, release, num_clips, &clips_bo);
+       if (ret)
+               goto out_free_drawable;
+
+       ret = qxl_image_alloc_objects(qdev, release,
+                                     &dimage,
+                                     height, stride);
+       if (ret)
+               goto out_free_clips;
+
+       /* do a reservation run over all the objects we just allocated */
+       ret = qxl_release_reserve_list(release, true);
+       if (ret)
+               goto out_free_image;
+
        drawable_rect.left = left;
        drawable_rect.right = right;
        drawable_rect.top = top;
        drawable_rect.bottom = bottom;
+
        ret = make_drawable(qdev, 0, QXL_DRAW_COPY, &drawable_rect,
-                           &release);
+                           release);
        if (ret)
-               return;
+               goto out_release_backoff;
 
        ret = qxl_bo_kmap(bo, (void **)&surface_base);
        if (ret)
-               goto out_unref;
+               goto out_release_backoff;
 
-       ret = qxl_image_create(qdev, release, &image_bo, surface_base,
-                              left, top, width, height, depth, stride);
+
+       ret = qxl_image_init(qdev, release, dimage, surface_base,
+                            left, top, width, height, depth, stride);
        qxl_bo_kunmap(bo);
        if (ret)
-               goto out_unref;
+               goto out_release_backoff;
+
+       rects = drawable_set_clipping(qdev, drawable, num_clips, clips_bo);
+       if (!rects)
+               goto out_release_backoff;
 
-       rects = drawable_set_clipping(qdev, drawable, num_clips, &clips_bo, release);
-       if (!rects) {
-               qxl_bo_unref(&image_bo);
-               goto out_unref;
-       }
        drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
 
        drawable->clip.type = SPICE_CLIP_TYPE_RECTS;
        drawable->clip.data = qxl_bo_physical_address(qdev,
                                                      clips_bo, 0);
-       qxl_release_add_res(qdev, release, clips_bo);
 
        drawable->u.copy.src_area.top = 0;
        drawable->u.copy.src_area.bottom = height;
@@ -306,11 +371,9 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
        drawable->u.copy.mask.pos.y = 0;
        drawable->u.copy.mask.bitmap = 0;
 
-       drawable->u.copy.src_bitmap = qxl_bo_physical_address(qdev, image_bo, 0);
+       drawable->u.copy.src_bitmap = qxl_bo_physical_address(qdev, dimage->bo, 0);
        qxl_release_unmap(qdev, release, &drawable->release_info);
-       qxl_release_add_res(qdev, release, image_bo);
-       qxl_bo_unreserve(image_bo);
-       qxl_bo_unref(&image_bo);
+
        clips_ptr = clips;
        for (i = 0; i < num_clips; i++, clips_ptr += inc) {
                rects[i].left   = clips_ptr->x1;
@@ -319,17 +382,22 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
                rects[i].bottom = clips_ptr->y2;
        }
        qxl_bo_kunmap(clips_bo);
-       qxl_bo_unreserve(clips_bo);
-       qxl_bo_unref(&clips_bo);
 
-       qxl_fence_releaseable(qdev, release);
        qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
-       qxl_release_unreserve(qdev, release);
-       return;
+       qxl_release_fence_buffer_objects(release);
+
+out_release_backoff:
+       if (ret)
+               qxl_release_backoff_reserve_list(release);
+out_free_image:
+       qxl_image_free_objects(qdev, dimage);
+out_free_clips:
+       qxl_bo_unref(&clips_bo);
+out_free_drawable:
+       /* only free drawable on error */
+       if (ret)
+               free_drawable(qdev, release);
 
-out_unref:
-       qxl_release_unreserve(qdev, release);
-       qxl_release_free(qdev, release);
 }
 
 void qxl_draw_copyarea(struct qxl_device *qdev,
@@ -342,22 +410,36 @@ void qxl_draw_copyarea(struct qxl_device *qdev,
        struct qxl_release *release;
        int ret;
 
+       ret = alloc_drawable(qdev, &release);
+       if (ret)
+               return;
+
+       /* do a reservation run over all the objects we just allocated */
+       ret = qxl_release_reserve_list(release, true);
+       if (ret)
+               goto out_free_release;
+
        rect.left = dx;
        rect.top = dy;
        rect.right = dx + width;
        rect.bottom = dy + height;
-       ret = make_drawable(qdev, 0, QXL_COPY_BITS, &rect, &release);
-       if (ret)
-               return;
+       ret = make_drawable(qdev, 0, QXL_COPY_BITS, &rect, release);
+       if (ret) {
+               qxl_release_backoff_reserve_list(release);
+               goto out_free_release;
+       }
 
        drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
        drawable->u.copy_bits.src_pos.x = sx;
        drawable->u.copy_bits.src_pos.y = sy;
-
        qxl_release_unmap(qdev, release, &drawable->release_info);
-       qxl_fence_releaseable(qdev, release);
+
        qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
+
+out_free_release:
+       if (ret)
+               free_drawable(qdev, release);
 }
 
 void qxl_draw_fill(struct qxl_draw_fill *qxl_draw_fill_rec)
@@ -370,10 +452,21 @@ void qxl_draw_fill(struct qxl_draw_fill *qxl_draw_fill_rec)
        struct qxl_release *release;
        int ret;
 
-       ret = make_drawable(qdev, 0, QXL_DRAW_FILL, &rect, &release);
+       ret = alloc_drawable(qdev, &release);
        if (ret)
                return;
 
+       /* do a reservation run over all the objects we just allocated */
+       ret = qxl_release_reserve_list(release, true);
+       if (ret)
+               goto out_free_release;
+
+       ret = make_drawable(qdev, 0, QXL_DRAW_FILL, &rect, release);
+       if (ret) {
+               qxl_release_backoff_reserve_list(release);
+               goto out_free_release;
+       }
+
        drawable = (struct qxl_drawable *)qxl_release_map(qdev, release);
        drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;
        drawable->u.fill.brush.u.color = color;
@@ -384,7 +477,11 @@ void qxl_draw_fill(struct qxl_draw_fill *qxl_draw_fill_rec)
        drawable->u.fill.mask.bitmap = 0;
 
        qxl_release_unmap(qdev, release, &drawable->release_info);
-       qxl_fence_releaseable(qdev, release);
+
        qxl_push_command_ring_release(qdev, release, QXL_CMD_DRAW, false);
-       qxl_release_unreserve(qdev, release);
+       qxl_release_fence_buffer_objects(release);
+
+out_free_release:
+       if (ret)
+               free_drawable(qdev, release);
 }
index aacb791464a34b770be0cd776fd7162d0fd0f344..7e96f4f117384faea9bad6b29826888f91973cf3 100644 (file)
@@ -42,6 +42,9 @@
 #include <ttm/ttm_placement.h>
 #include <ttm/ttm_module.h>
 
+/* just for ttm_validate_buffer */
+#include <ttm/ttm_execbuf_util.h>
+
 #include <drm/qxl_drm.h>
 #include "qxl_dev.h"
 
@@ -118,9 +121,9 @@ struct qxl_bo {
        uint32_t surface_id;
        struct qxl_fence fence; /* per bo fence  - list of releases */
        struct qxl_release *surf_create;
-       atomic_t reserve_count;
 };
 #define gem_to_qxl_bo(gobj) container_of((gobj), struct qxl_bo, gem_base)
+#define to_qxl_bo(tobj) container_of((tobj), struct qxl_bo, tbo)
 
 struct qxl_gem {
        struct mutex            mutex;
@@ -128,12 +131,7 @@ struct qxl_gem {
 };
 
 struct qxl_bo_list {
-       struct list_head lhead;
-       struct qxl_bo *bo;
-};
-
-struct qxl_reloc_list {
-       struct list_head bos;
+       struct ttm_validate_buffer tv;
 };
 
 struct qxl_crtc {
@@ -195,10 +193,20 @@ enum {
 struct qxl_release {
        int id;
        int type;
-       int bo_count;
        uint32_t release_offset;
        uint32_t surface_release_id;
-       struct qxl_bo *bos[QXL_MAX_RES];
+       struct ww_acquire_ctx ticket;
+       struct list_head bos;
+};
+
+struct qxl_drm_chunk {
+       struct list_head head;
+       struct qxl_bo *bo;
+};
+
+struct qxl_drm_image {
+       struct qxl_bo *bo;
+       struct list_head chunk_list;
 };
 
 struct qxl_fb_image {
@@ -314,6 +322,7 @@ struct qxl_device {
        struct workqueue_struct *gc_queue;
        struct work_struct gc_work;
 
+       struct work_struct fb_work;
 };
 
 /* forward declaration for QXL_INFO_IO */
@@ -433,12 +442,19 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma);
 
 /* qxl image */
 
-int qxl_image_create(struct qxl_device *qdev,
-                    struct qxl_release *release,
-                    struct qxl_bo **image_bo,
-                    const uint8_t *data,
-                    int x, int y, int width, int height,
-                    int depth, int stride);
+int qxl_image_init(struct qxl_device *qdev,
+                  struct qxl_release *release,
+                  struct qxl_drm_image *dimage,
+                  const uint8_t *data,
+                  int x, int y, int width, int height,
+                  int depth, int stride);
+int
+qxl_image_alloc_objects(struct qxl_device *qdev,
+                       struct qxl_release *release,
+                       struct qxl_drm_image **image_ptr,
+                       int height, int stride);
+void qxl_image_free_objects(struct qxl_device *qdev, struct qxl_drm_image *dimage);
+
 void qxl_update_screen(struct qxl_device *qxl);
 
 /* qxl io operations (qxl_cmd.c) */
@@ -459,20 +475,15 @@ int qxl_ring_push(struct qxl_ring *ring, const void *new_elt, bool interruptible
 void qxl_io_flush_release(struct qxl_device *qdev);
 void qxl_io_flush_surfaces(struct qxl_device *qdev);
 
-int qxl_release_reserve(struct qxl_device *qdev,
-                       struct qxl_release *release, bool no_wait);
-void qxl_release_unreserve(struct qxl_device *qdev,
-                          struct qxl_release *release);
 union qxl_release_info *qxl_release_map(struct qxl_device *qdev,
                                        struct qxl_release *release);
 void qxl_release_unmap(struct qxl_device *qdev,
                       struct qxl_release *release,
                       union qxl_release_info *info);
-/*
- * qxl_bo_add_resource.
- *
- */
-void qxl_bo_add_resource(struct qxl_bo *main_bo, struct qxl_bo *resource);
+int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo);
+int qxl_release_reserve_list(struct qxl_release *release, bool no_intr);
+void qxl_release_backoff_reserve_list(struct qxl_release *release);
+void qxl_release_fence_buffer_objects(struct qxl_release *release);
 
 int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
                                       enum qxl_surface_cmd_type surface_cmd_type,
@@ -481,15 +492,16 @@ int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
 int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
                               int type, struct qxl_release **release,
                               struct qxl_bo **rbo);
-int qxl_fence_releaseable(struct qxl_device *qdev,
-                         struct qxl_release *release);
+
 int
 qxl_push_command_ring_release(struct qxl_device *qdev, struct qxl_release *release,
                              uint32_t type, bool interruptible);
 int
 qxl_push_cursor_ring_release(struct qxl_device *qdev, struct qxl_release *release,
                             uint32_t type, bool interruptible);
-int qxl_alloc_bo_reserved(struct qxl_device *qdev, unsigned long size,
+int qxl_alloc_bo_reserved(struct qxl_device *qdev,
+                         struct qxl_release *release,
+                         unsigned long size,
                          struct qxl_bo **_bo);
 /* qxl drawing commands */
 
@@ -510,15 +522,9 @@ void qxl_draw_copyarea(struct qxl_device *qdev,
                       u32 sx, u32 sy,
                       u32 dx, u32 dy);
 
-uint64_t
-qxl_release_alloc(struct qxl_device *qdev, int type,
-                 struct qxl_release **ret);
-
 void qxl_release_free(struct qxl_device *qdev,
                      struct qxl_release *release);
-void qxl_release_add_res(struct qxl_device *qdev,
-                        struct qxl_release *release,
-                        struct qxl_bo *bo);
+
 /* used by qxl_debugfs_release */
 struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
                                                   uint64_t id);
@@ -561,7 +567,7 @@ void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool freein
 int qxl_update_surface(struct qxl_device *qdev, struct qxl_bo *surf);
 
 /* qxl_fence.c */
-int qxl_fence_add_release(struct qxl_fence *qfence, uint32_t rel_id);
+void qxl_fence_add_release_locked(struct qxl_fence *qfence, uint32_t rel_id);
 int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id);
 int qxl_fence_init(struct qxl_device *qdev, struct qxl_fence *qfence);
 void qxl_fence_fini(struct qxl_fence *qfence);
index 76f39d88d684fbd979bc50ebf2047eceaa9ad632..88722f233430a3d0f7eb4e8b35ad929b709c5b35 100644 (file)
 
 #define QXL_DIRTY_DELAY (HZ / 30)
 
+#define QXL_FB_OP_FILLRECT 1
+#define QXL_FB_OP_COPYAREA 2
+#define QXL_FB_OP_IMAGEBLIT 3
+
+struct qxl_fb_op {
+       struct list_head head;
+       int op_type;
+       union {
+               struct fb_fillrect fr;
+               struct fb_copyarea ca;
+               struct fb_image ib;
+       } op;
+       void *img_data;
+};
+
 struct qxl_fbdev {
        struct drm_fb_helper helper;
        struct qxl_framebuffer  qfb;
        struct list_head        fbdev_list;
        struct qxl_device       *qdev;
 
+       spinlock_t delayed_ops_lock;
+       struct list_head delayed_ops;
        void *shadow;
        int size;
 
@@ -164,8 +181,69 @@ static struct fb_deferred_io qxl_defio = {
        .deferred_io    = qxl_deferred_io,
 };
 
-static void qxl_fb_fillrect(struct fb_info *info,
-                           const struct fb_fillrect *fb_rect)
+static void qxl_fb_delayed_fillrect(struct qxl_fbdev *qfbdev,
+                                   const struct fb_fillrect *fb_rect)
+{
+       struct qxl_fb_op *op;
+       unsigned long flags;
+
+       op = kmalloc(sizeof(struct qxl_fb_op), GFP_ATOMIC | __GFP_NOWARN);
+       if (!op)
+               return;
+
+       op->op.fr = *fb_rect;
+       op->img_data = NULL;
+       op->op_type = QXL_FB_OP_FILLRECT;
+
+       spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
+       list_add_tail(&op->head, &qfbdev->delayed_ops);
+       spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
+}
+
+static void qxl_fb_delayed_copyarea(struct qxl_fbdev *qfbdev,
+                                   const struct fb_copyarea *fb_copy)
+{
+       struct qxl_fb_op *op;
+       unsigned long flags;
+
+       op = kmalloc(sizeof(struct qxl_fb_op), GFP_ATOMIC | __GFP_NOWARN);
+       if (!op)
+               return;
+
+       op->op.ca = *fb_copy;
+       op->img_data = NULL;
+       op->op_type = QXL_FB_OP_COPYAREA;
+
+       spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
+       list_add_tail(&op->head, &qfbdev->delayed_ops);
+       spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
+}
+
+static void qxl_fb_delayed_imageblit(struct qxl_fbdev *qfbdev,
+                                    const struct fb_image *fb_image)
+{
+       struct qxl_fb_op *op;
+       unsigned long flags;
+       uint32_t size = fb_image->width * fb_image->height * (fb_image->depth >= 8 ? fb_image->depth / 8 : 1);
+
+       op = kmalloc(sizeof(struct qxl_fb_op) + size, GFP_ATOMIC | __GFP_NOWARN);
+       if (!op)
+               return;
+
+       op->op.ib = *fb_image;
+       op->img_data = (void *)(op + 1);
+       op->op_type = QXL_FB_OP_IMAGEBLIT;
+
+       memcpy(op->img_data, fb_image->data, size);
+
+       op->op.ib.data = op->img_data;
+       spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
+       list_add_tail(&op->head, &qfbdev->delayed_ops);
+       spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
+}
+
+static void qxl_fb_fillrect_internal(struct fb_info *info,
+                                    const struct fb_fillrect *fb_rect)
 {
        struct qxl_fbdev *qfbdev = info->par;
        struct qxl_device *qdev = qfbdev->qdev;
@@ -203,17 +281,28 @@ static void qxl_fb_fillrect(struct fb_info *info,
        qxl_draw_fill_rec.rect = rect;
        qxl_draw_fill_rec.color = color;
        qxl_draw_fill_rec.rop = rop;
+
+       qxl_draw_fill(&qxl_draw_fill_rec);
+}
+
+static void qxl_fb_fillrect(struct fb_info *info,
+                           const struct fb_fillrect *fb_rect)
+{
+       struct qxl_fbdev *qfbdev = info->par;
+       struct qxl_device *qdev = qfbdev->qdev;
+
        if (!drm_can_sleep()) {
-               qxl_io_log(qdev,
-                       "%s: TODO use RCU, mysterious locks with spin_lock\n",
-                       __func__);
+               qxl_fb_delayed_fillrect(qfbdev, fb_rect);
+               schedule_work(&qdev->fb_work);
                return;
        }
-       qxl_draw_fill(&qxl_draw_fill_rec);
+       /* make sure any previous work is done */
+       flush_work(&qdev->fb_work);
+       qxl_fb_fillrect_internal(info, fb_rect);
 }
 
-static void qxl_fb_copyarea(struct fb_info *info,
-                           const struct fb_copyarea *region)
+static void qxl_fb_copyarea_internal(struct fb_info *info,
+                                    const struct fb_copyarea *region)
 {
        struct qxl_fbdev *qfbdev = info->par;
 
@@ -223,37 +312,89 @@ static void qxl_fb_copyarea(struct fb_info *info,
                          region->dx, region->dy);
 }
 
+static void qxl_fb_copyarea(struct fb_info *info,
+                           const struct fb_copyarea *region)
+{
+       struct qxl_fbdev *qfbdev = info->par;
+       struct qxl_device *qdev = qfbdev->qdev;
+
+       if (!drm_can_sleep()) {
+               qxl_fb_delayed_copyarea(qfbdev, region);
+               schedule_work(&qdev->fb_work);
+               return;
+       }
+       /* make sure any previous work is done */
+       flush_work(&qdev->fb_work);
+       qxl_fb_copyarea_internal(info, region);
+}
+
 static void qxl_fb_imageblit_safe(struct qxl_fb_image *qxl_fb_image)
 {
        qxl_draw_opaque_fb(qxl_fb_image, 0);
 }
 
+static void qxl_fb_imageblit_internal(struct fb_info *info,
+                                     const struct fb_image *image)
+{
+       struct qxl_fbdev *qfbdev = info->par;
+       struct qxl_fb_image qxl_fb_image;
+
+       /* ensure proper order  rendering operations - TODO: must do this
+        * for everything. */
+       qxl_fb_image_init(&qxl_fb_image, qfbdev->qdev, info, image);
+       qxl_fb_imageblit_safe(&qxl_fb_image);
+}
+
 static void qxl_fb_imageblit(struct fb_info *info,
                             const struct fb_image *image)
 {
        struct qxl_fbdev *qfbdev = info->par;
        struct qxl_device *qdev = qfbdev->qdev;
-       struct qxl_fb_image qxl_fb_image;
 
        if (!drm_can_sleep()) {
-               /* we cannot do any ttm_bo allocation since that will fail on
-                * ioremap_wc..__get_vm_area_node, so queue the work item
-                * instead This can happen from printk inside an interrupt
-                * context, i.e.: smp_apic_timer_interrupt..check_cpu_stall */
-               qxl_io_log(qdev,
-                       "%s: TODO use RCU, mysterious locks with spin_lock\n",
-                          __func__);
+               qxl_fb_delayed_imageblit(qfbdev, image);
+               schedule_work(&qdev->fb_work);
                return;
        }
+       /* make sure any previous work is done */
+       flush_work(&qdev->fb_work);
+       qxl_fb_imageblit_internal(info, image);
+}
 
-       /* ensure proper order of rendering operations - TODO: must do this
-        * for everything. */
-       qxl_fb_image_init(&qxl_fb_image, qfbdev->qdev, info, image);
-       qxl_fb_imageblit_safe(&qxl_fb_image);
+static void qxl_fb_work(struct work_struct *work)
+{
+       struct qxl_device *qdev = container_of(work, struct qxl_device, fb_work);
+       unsigned long flags;
+       struct qxl_fb_op *entry, *tmp;
+       struct qxl_fbdev *qfbdev = qdev->mode_info.qfbdev;
+
+       /* since the irq context just adds entries to the end of the
+          list dropping the lock should be fine, as entry isn't modified
+          in the operation code */
+       spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
+       list_for_each_entry_safe(entry, tmp, &qfbdev->delayed_ops, head) {
+               spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
+               switch (entry->op_type) {
+               case QXL_FB_OP_FILLRECT:
+                       qxl_fb_fillrect_internal(qfbdev->helper.fbdev, &entry->op.fr);
+                       break;
+               case QXL_FB_OP_COPYAREA:
+                       qxl_fb_copyarea_internal(qfbdev->helper.fbdev, &entry->op.ca);
+                       break;
+               case QXL_FB_OP_IMAGEBLIT:
+                       qxl_fb_imageblit_internal(qfbdev->helper.fbdev, &entry->op.ib);
+                       break;
+               }
+               spin_lock_irqsave(&qfbdev->delayed_ops_lock, flags);
+               list_del(&entry->head);
+               kfree(entry);
+       }
+       spin_unlock_irqrestore(&qfbdev->delayed_ops_lock, flags);
 }
 
 int qxl_fb_init(struct qxl_device *qdev)
 {
+       INIT_WORK(&qdev->fb_work, qxl_fb_work);
        return 0;
 }
 
@@ -536,7 +677,8 @@ int qxl_fbdev_init(struct qxl_device *qdev)
        qfbdev->qdev = qdev;
        qdev->mode_info.qfbdev = qfbdev;
        qfbdev->helper.funcs = &qxl_fb_helper_funcs;
-
+       spin_lock_init(&qfbdev->delayed_ops_lock);
+       INIT_LIST_HEAD(&qfbdev->delayed_ops);
        ret = drm_fb_helper_init(qdev->ddev, &qfbdev->helper,
                                 qxl_num_crtc /* num_crtc - QXL supports just 1 */,
                                 QXLFB_CONN_LIMIT);
index 63c6715ad38565d5ad5c04243b00d4482c54b7b5..ae59e91cfb9ab1694aee3047e094166130e7b123 100644 (file)
 
    For some reason every so often qxl hw fails to release, things go wrong.
 */
-
-
-int qxl_fence_add_release(struct qxl_fence *qfence, uint32_t rel_id)
+/* must be called with the fence lock held */
+void qxl_fence_add_release_locked(struct qxl_fence *qfence, uint32_t rel_id)
 {
-       struct qxl_bo *bo = container_of(qfence, struct qxl_bo, fence);
-
-       spin_lock(&bo->tbo.bdev->fence_lock);
        radix_tree_insert(&qfence->tree, rel_id, qfence);
        qfence->num_active_releases++;
-       spin_unlock(&bo->tbo.bdev->fence_lock);
-       return 0;
 }
 
 int qxl_fence_remove_release(struct qxl_fence *qfence, uint32_t rel_id)
index a235693aabba331284fca3017c519002789c1ab9..25e1777fb0a28551ac1d43d8a7a5b183812f54a7 100644 (file)
@@ -55,7 +55,7 @@ int qxl_gem_object_create(struct qxl_device *qdev, int size,
        /* At least align on page size */
        if (alignment < PAGE_SIZE)
                alignment = PAGE_SIZE;
-       r = qxl_bo_create(qdev, size, kernel, initial_domain, surf, &qbo);
+       r = qxl_bo_create(qdev, size, kernel, false, initial_domain, surf, &qbo);
        if (r) {
                if (r != -ERESTARTSYS)
                        DRM_ERROR(
index cf856206996b86a6b2293723faafc1c14810a64d..7fbcc35e8ad35bfa8cce9f3323a4f4e5d574f21e 100644 (file)
 #include "qxl_object.h"
 
 static int
-qxl_image_create_helper(struct qxl_device *qdev,
+qxl_allocate_chunk(struct qxl_device *qdev,
+                  struct qxl_release *release,
+                  struct qxl_drm_image *image,
+                  unsigned int chunk_size)
+{
+       struct qxl_drm_chunk *chunk;
+       int ret;
+
+       chunk = kmalloc(sizeof(struct qxl_drm_chunk), GFP_KERNEL);
+       if (!chunk)
+               return -ENOMEM;
+
+       ret = qxl_alloc_bo_reserved(qdev, release, chunk_size, &chunk->bo);
+       if (ret) {
+               kfree(chunk);
+               return ret;
+       }
+
+       list_add_tail(&chunk->head, &image->chunk_list);
+       return 0;
+}
+
+int
+qxl_image_alloc_objects(struct qxl_device *qdev,
                        struct qxl_release *release,
-                       struct qxl_bo **image_bo,
-                       const uint8_t *data,
-                       int width, int height,
-                       int depth, unsigned int hash,
-                       int stride)
+                       struct qxl_drm_image **image_ptr,
+                       int height, int stride)
+{
+       struct qxl_drm_image *image;
+       int ret;
+
+       image = kmalloc(sizeof(struct qxl_drm_image), GFP_KERNEL);
+       if (!image)
+               return -ENOMEM;
+
+       INIT_LIST_HEAD(&image->chunk_list);
+
+       ret = qxl_alloc_bo_reserved(qdev, release, sizeof(struct qxl_image), &image->bo);
+       if (ret) {
+               kfree(image);
+               return ret;
+       }
+
+       ret = qxl_allocate_chunk(qdev, release, image, sizeof(struct qxl_data_chunk) + stride * height);
+       if (ret) {
+               qxl_bo_unref(&image->bo);
+               kfree(image);
+               return ret;
+       }
+       *image_ptr = image;
+       return 0;
+}
+
+void qxl_image_free_objects(struct qxl_device *qdev, struct qxl_drm_image *dimage)
 {
+       struct qxl_drm_chunk *chunk, *tmp;
+
+       list_for_each_entry_safe(chunk, tmp, &dimage->chunk_list, head) {
+               qxl_bo_unref(&chunk->bo);
+               kfree(chunk);
+       }
+
+       qxl_bo_unref(&dimage->bo);
+       kfree(dimage);
+}
+
+static int
+qxl_image_init_helper(struct qxl_device *qdev,
+                     struct qxl_release *release,
+                     struct qxl_drm_image *dimage,
+                     const uint8_t *data,
+                     int width, int height,
+                     int depth, unsigned int hash,
+                     int stride)
+{
+       struct qxl_drm_chunk *drv_chunk;
        struct qxl_image *image;
        struct qxl_data_chunk *chunk;
        int i;
        int chunk_stride;
        int linesize = width * depth / 8;
-       struct qxl_bo *chunk_bo;
-       int ret;
+       struct qxl_bo *chunk_bo, *image_bo;
        void *ptr;
        /* Chunk */
        /* FIXME: Check integer overflow */
        /* TODO: variable number of chunks */
+
+       drv_chunk = list_first_entry(&dimage->chunk_list, struct qxl_drm_chunk, head);
+
+       chunk_bo = drv_chunk->bo;
        chunk_stride = stride; /* TODO: should use linesize, but it renders
                                  wrong (check the bitmaps are sent correctly
                                  first) */
-       ret = qxl_alloc_bo_reserved(qdev, sizeof(*chunk) + height * chunk_stride,
-                                   &chunk_bo);
-       
+
        ptr = qxl_bo_kmap_atomic_page(qdev, chunk_bo, 0);
        chunk = ptr;
        chunk->data_size = height * chunk_stride;
@@ -102,7 +171,6 @@ qxl_image_create_helper(struct qxl_device *qdev,
                                while (remain > 0) {
                                        page_base = out_offset & PAGE_MASK;
                                        page_offset = offset_in_page(out_offset);
-                                       
                                        size = min((int)(PAGE_SIZE - page_offset), remain);
 
                                        ptr = qxl_bo_kmap_atomic_page(qdev, chunk_bo, page_base);
@@ -116,14 +184,10 @@ qxl_image_create_helper(struct qxl_device *qdev,
                        }
                }
        }
-
-
        qxl_bo_kunmap(chunk_bo);
 
-       /* Image */
-       ret = qxl_alloc_bo_reserved(qdev, sizeof(*image), image_bo);
-
-       ptr = qxl_bo_kmap_atomic_page(qdev, *image_bo, 0);
+       image_bo = dimage->bo;
+       ptr = qxl_bo_kmap_atomic_page(qdev, image_bo, 0);
        image = ptr;
 
        image->descriptor.id = 0;
@@ -154,23 +218,20 @@ qxl_image_create_helper(struct qxl_device *qdev,
        image->u.bitmap.stride = chunk_stride;
        image->u.bitmap.palette = 0;
        image->u.bitmap.data = qxl_bo_physical_address(qdev, chunk_bo, 0);
-       qxl_release_add_res(qdev, release, chunk_bo);
-       qxl_bo_unreserve(chunk_bo);
-       qxl_bo_unref(&chunk_bo);
 
-       qxl_bo_kunmap_atomic_page(qdev, *image_bo, ptr);
+       qxl_bo_kunmap_atomic_page(qdev, image_bo, ptr);
 
        return 0;
 }
 
-int qxl_image_create(struct qxl_device *qdev,
+int qxl_image_init(struct qxl_device *qdev,
                     struct qxl_release *release,
-                    struct qxl_bo **image_bo,
+                    struct qxl_drm_image *dimage,
                     const uint8_t *data,
                     int x, int y, int width, int height,
                     int depth, int stride)
 {
        data += y * stride + x * (depth / 8);
-       return qxl_image_create_helper(qdev, release, image_bo, data,
+       return qxl_image_init_helper(qdev, release, dimage, data,
                                       width, height, depth, 0, stride);
 }
index 27f45e49250d72e48efd1bce5cc86b1f7442334e..6de33563d6f186fe56745137a7e8b3c3b324e5a8 100644 (file)
@@ -68,55 +68,60 @@ static int qxl_map_ioctl(struct drm_device *dev, void *data,
                                  &qxl_map->offset);
 }
 
+struct qxl_reloc_info {
+       int type;
+       struct qxl_bo *dst_bo;
+       uint32_t dst_offset;
+       struct qxl_bo *src_bo;
+       int src_offset;
+};
+
 /*
  * dst must be validated, i.e. whole bo on vram/surfacesram (right now all bo's
  * are on vram).
  * *(dst + dst_off) = qxl_bo_physical_address(src, src_off)
  */
 static void
-apply_reloc(struct qxl_device *qdev, struct qxl_bo *dst, uint64_t dst_off,
-           struct qxl_bo *src, uint64_t src_off)
+apply_reloc(struct qxl_device *qdev, struct qxl_reloc_info *info)
 {
        void *reloc_page;
-
-       reloc_page = qxl_bo_kmap_atomic_page(qdev, dst, dst_off & PAGE_MASK);
-       *(uint64_t *)(reloc_page + (dst_off & ~PAGE_MASK)) = qxl_bo_physical_address(qdev,
-                                                                    src, src_off);
-       qxl_bo_kunmap_atomic_page(qdev, dst, reloc_page);
+       reloc_page = qxl_bo_kmap_atomic_page(qdev, info->dst_bo, info->dst_offset & PAGE_MASK);
+       *(uint64_t *)(reloc_page + (info->dst_offset & ~PAGE_MASK)) = qxl_bo_physical_address(qdev,
+                                                                                             info->src_bo,
+                                                                                             info->src_offset);
+       qxl_bo_kunmap_atomic_page(qdev, info->dst_bo, reloc_page);
 }
 
 static void
-apply_surf_reloc(struct qxl_device *qdev, struct qxl_bo *dst, uint64_t dst_off,
-                struct qxl_bo *src)
+apply_surf_reloc(struct qxl_device *qdev, struct qxl_reloc_info *info)
 {
        uint32_t id = 0;
        void *reloc_page;
 
-       if (src && !src->is_primary)
-               id = src->surface_id;
+       if (info->src_bo && !info->src_bo->is_primary)
+               id = info->src_bo->surface_id;
 
-       reloc_page = qxl_bo_kmap_atomic_page(qdev, dst, dst_off & PAGE_MASK);
-       *(uint32_t *)(reloc_page + (dst_off & ~PAGE_MASK)) = id;
-       qxl_bo_kunmap_atomic_page(qdev, dst, reloc_page);
+       reloc_page = qxl_bo_kmap_atomic_page(qdev, info->dst_bo, info->dst_offset & PAGE_MASK);
+       *(uint32_t *)(reloc_page + (info->dst_offset & ~PAGE_MASK)) = id;
+       qxl_bo_kunmap_atomic_page(qdev, info->dst_bo, reloc_page);
 }
 
 /* return holding the reference to this object */
 static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev,
                                         struct drm_file *file_priv, uint64_t handle,
-                                        struct qxl_reloc_list *reloc_list)
+                                        struct qxl_release *release)
 {
        struct drm_gem_object *gobj;
        struct qxl_bo *qobj;
        int ret;
 
        gobj = drm_gem_object_lookup(qdev->ddev, file_priv, handle);
-       if (!gobj) {
-               DRM_ERROR("bad bo handle %lld\n", handle);
+       if (!gobj)
                return NULL;
-       }
+
        qobj = gem_to_qxl_bo(gobj);
 
-       ret = qxl_bo_list_add(reloc_list, qobj);
+       ret = qxl_release_list_add(release, qobj);
        if (ret)
                return NULL;
 
@@ -129,151 +134,177 @@ static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev,
  * However, the command as passed from user space must *not* contain the initial
  * QXLReleaseInfo struct (first XXX bytes)
  */
-static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
-                               struct drm_file *file_priv)
+static int qxl_process_single_command(struct qxl_device *qdev,
+                                     struct drm_qxl_command *cmd,
+                                     struct drm_file *file_priv)
 {
-       struct qxl_device *qdev = dev->dev_private;
-       struct drm_qxl_execbuffer *execbuffer = data;
-       struct drm_qxl_command user_cmd;
-       int cmd_num;
-       struct qxl_bo *reloc_src_bo;
-       struct qxl_bo *reloc_dst_bo;
-       struct drm_qxl_reloc reloc;
+       struct qxl_reloc_info *reloc_info;
+       int release_type;
+       struct qxl_release *release;
+       struct qxl_bo *cmd_bo;
        void *fb_cmd;
-       int i, ret;
-       struct qxl_reloc_list reloc_list;
+       int i, j, ret, num_relocs;
        int unwritten;
-       uint32_t reloc_dst_offset;
-       INIT_LIST_HEAD(&reloc_list.bos);
 
-       for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
-               struct qxl_release *release;
-               struct qxl_bo *cmd_bo;
-               int release_type;
-               struct drm_qxl_command *commands =
-                       (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
+       switch (cmd->type) {
+       case QXL_CMD_DRAW:
+               release_type = QXL_RELEASE_DRAWABLE;
+               break;
+       case QXL_CMD_SURFACE:
+       case QXL_CMD_CURSOR:
+       default:
+               DRM_DEBUG("Only draw commands in execbuffers\n");
+               return -EINVAL;
+               break;
+       }
 
-               if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num],
-                                      sizeof(user_cmd)))
-                       return -EFAULT;
-               switch (user_cmd.type) {
-               case QXL_CMD_DRAW:
-                       release_type = QXL_RELEASE_DRAWABLE;
-                       break;
-               case QXL_CMD_SURFACE:
-               case QXL_CMD_CURSOR:
-               default:
-                       DRM_DEBUG("Only draw commands in execbuffers\n");
-                       return -EINVAL;
-                       break;
-               }
+       if (cmd->command_size > PAGE_SIZE - sizeof(union qxl_release_info))
+               return -EINVAL;
 
-               if (user_cmd.command_size > PAGE_SIZE - sizeof(union qxl_release_info))
-                       return -EINVAL;
+       if (!access_ok(VERIFY_READ,
+                      (void *)(unsigned long)cmd->command,
+                      cmd->command_size))
+               return -EFAULT;
 
-               if (!access_ok(VERIFY_READ,
-                              (void *)(unsigned long)user_cmd.command,
-                              user_cmd.command_size))
-                       return -EFAULT;
+       reloc_info = kmalloc(sizeof(struct qxl_reloc_info) * cmd->relocs_num, GFP_KERNEL);
+       if (!reloc_info)
+               return -ENOMEM;
 
-               ret = qxl_alloc_release_reserved(qdev,
-                                                sizeof(union qxl_release_info) +
-                                                user_cmd.command_size,
-                                                release_type,
-                                                &release,
-                                                &cmd_bo);
-               if (ret)
-                       return ret;
+       ret = qxl_alloc_release_reserved(qdev,
+                                        sizeof(union qxl_release_info) +
+                                        cmd->command_size,
+                                        release_type,
+                                        &release,
+                                        &cmd_bo);
+       if (ret)
+               goto out_free_reloc;
 
-               /* TODO copy slow path code from i915 */
-               fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
-               unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)user_cmd.command, user_cmd.command_size);
+       /* TODO copy slow path code from i915 */
+       fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE));
+       unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)cmd->command, cmd->command_size);
 
-               {
-                       struct qxl_drawable *draw = fb_cmd;
+       {
+               struct qxl_drawable *draw = fb_cmd;
+               draw->mm_time = qdev->rom->mm_clock;
+       }
 
-                       draw->mm_time = qdev->rom->mm_clock;
-               }
-               qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd);
-               if (unwritten) {
-                       DRM_ERROR("got unwritten %d\n", unwritten);
-                       qxl_release_unreserve(qdev, release);
-                       qxl_release_free(qdev, release);
-                       return -EFAULT;
+       qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd);
+       if (unwritten) {
+               DRM_ERROR("got unwritten %d\n", unwritten);
+               ret = -EFAULT;
+               goto out_free_release;
+       }
+
+       /* fill out reloc info structs */
+       num_relocs = 0;
+       for (i = 0; i < cmd->relocs_num; ++i) {
+               struct drm_qxl_reloc reloc;
+
+               if (DRM_COPY_FROM_USER(&reloc,
+                                      &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i],
+                                      sizeof(reloc))) {
+                       ret = -EFAULT;
+                       goto out_free_bos;
                }
 
-               for (i = 0 ; i < user_cmd.relocs_num; ++i) {
-                       if (DRM_COPY_FROM_USER(&reloc,
-                                              &((struct drm_qxl_reloc *)(uintptr_t)user_cmd.relocs)[i],
-                                              sizeof(reloc))) {
-                               qxl_bo_list_unreserve(&reloc_list, true);
-                               qxl_release_unreserve(qdev, release);
-                               qxl_release_free(qdev, release);
-                               return -EFAULT;
-                       }
+               /* add the bos to the list of bos to validate -
+                  need to validate first then process relocs? */
+               if (reloc.reloc_type != QXL_RELOC_TYPE_BO && reloc.reloc_type != QXL_RELOC_TYPE_SURF) {
+                       DRM_DEBUG("unknown reloc type %d\n", reloc_info[i].type);
 
-                       /* add the bos to the list of bos to validate -
-                          need to validate first then process relocs? */
-                       if (reloc.dst_handle) {
-                               reloc_dst_bo = qxlhw_handle_to_bo(qdev, file_priv,
-                                                                 reloc.dst_handle, &reloc_list);
-                               if (!reloc_dst_bo) {
-                                       qxl_bo_list_unreserve(&reloc_list, true);
-                                       qxl_release_unreserve(qdev, release);
-                                       qxl_release_free(qdev, release);
-                                       return -EINVAL;
-                               }
-                               reloc_dst_offset = 0;
-                       } else {
-                               reloc_dst_bo = cmd_bo;
-                               reloc_dst_offset = release->release_offset;
+                       ret = -EINVAL;
+                       goto out_free_bos;
+               }
+               reloc_info[i].type = reloc.reloc_type;
+
+               if (reloc.dst_handle) {
+                       reloc_info[i].dst_bo = qxlhw_handle_to_bo(qdev, file_priv,
+                                                                 reloc.dst_handle, release);
+                       if (!reloc_info[i].dst_bo) {
+                               ret = -EINVAL;
+                               reloc_info[i].src_bo = NULL;
+                               goto out_free_bos;
                        }
-
-                       /* reserve and validate the reloc dst bo */
-                       if (reloc.reloc_type == QXL_RELOC_TYPE_BO || reloc.src_handle > 0) {
-                               reloc_src_bo =
-                                       qxlhw_handle_to_bo(qdev, file_priv,
-                                                          reloc.src_handle, &reloc_list);
-                               if (!reloc_src_bo) {
-                                       if (reloc_dst_bo != cmd_bo)
-                                               drm_gem_object_unreference_unlocked(&reloc_dst_bo->gem_base);
-                                       qxl_bo_list_unreserve(&reloc_list, true);
-                                       qxl_release_unreserve(qdev, release);
-                                       qxl_release_free(qdev, release);
-                                       return -EINVAL;
-                               }
-                       } else
-                               reloc_src_bo = NULL;
-                       if (reloc.reloc_type == QXL_RELOC_TYPE_BO) {
-                               apply_reloc(qdev, reloc_dst_bo, reloc_dst_offset + reloc.dst_offset,
-                                           reloc_src_bo, reloc.src_offset);
-                       } else if (reloc.reloc_type == QXL_RELOC_TYPE_SURF) {
-                               apply_surf_reloc(qdev, reloc_dst_bo, reloc_dst_offset + reloc.dst_offset, reloc_src_bo);
-                       } else {
-                               DRM_ERROR("unknown reloc type %d\n", reloc.reloc_type);
-                               return -EINVAL;
+                       reloc_info[i].dst_offset = reloc.dst_offset;
+               } else {
+                       reloc_info[i].dst_bo = cmd_bo;
+                       reloc_info[i].dst_offset = reloc.dst_offset + release->release_offset;
+               }
+               num_relocs++;
+
+               /* reserve and validate the reloc dst bo */
+               if (reloc.reloc_type == QXL_RELOC_TYPE_BO || reloc.src_handle > 0) {
+                       reloc_info[i].src_bo =
+                               qxlhw_handle_to_bo(qdev, file_priv,
+                                                  reloc.src_handle, release);
+                       if (!reloc_info[i].src_bo) {
+                               if (reloc_info[i].dst_bo != cmd_bo)
+                                       drm_gem_object_unreference_unlocked(&reloc_info[i].dst_bo->gem_base);
+                               ret = -EINVAL;
+                               goto out_free_bos;
                        }
+                       reloc_info[i].src_offset = reloc.src_offset;
+               } else {
+                       reloc_info[i].src_bo = NULL;
+                       reloc_info[i].src_offset = 0;
+               }
+       }
 
-                       if (reloc_src_bo && reloc_src_bo != cmd_bo) {
-                               qxl_release_add_res(qdev, release, reloc_src_bo);
-                               drm_gem_object_unreference_unlocked(&reloc_src_bo->gem_base);
-                       }
+       /* validate all buffers */
+       ret = qxl_release_reserve_list(release, false);
+       if (ret)
+               goto out_free_bos;
 
-                       if (reloc_dst_bo != cmd_bo)
-                               drm_gem_object_unreference_unlocked(&reloc_dst_bo->gem_base);
-               }
-               qxl_fence_releaseable(qdev, release);
+       for (i = 0; i < cmd->relocs_num; ++i) {
+               if (reloc_info[i].type == QXL_RELOC_TYPE_BO)
+                       apply_reloc(qdev, &reloc_info[i]);
+               else if (reloc_info[i].type == QXL_RELOC_TYPE_SURF)
+                       apply_surf_reloc(qdev, &reloc_info[i]);
+       }
 
-               ret = qxl_push_command_ring_release(qdev, release, user_cmd.type, true);
-               if (ret == -ERESTARTSYS) {
-                       qxl_release_unreserve(qdev, release);
-                       qxl_release_free(qdev, release);
-                       qxl_bo_list_unreserve(&reloc_list, true);
+       ret = qxl_push_command_ring_release(qdev, release, cmd->type, true);
+       if (ret)
+               qxl_release_backoff_reserve_list(release);
+       else
+               qxl_release_fence_buffer_objects(release);
+
+out_free_bos:
+       for (j = 0; j < num_relocs; j++) {
+               if (reloc_info[j].dst_bo != cmd_bo)
+                       drm_gem_object_unreference_unlocked(&reloc_info[j].dst_bo->gem_base);
+               if (reloc_info[j].src_bo && reloc_info[j].src_bo != cmd_bo)
+                       drm_gem_object_unreference_unlocked(&reloc_info[j].src_bo->gem_base);
+       }
+out_free_release:
+       if (ret)
+               qxl_release_free(qdev, release);
+out_free_reloc:
+       kfree(reloc_info);
+       return ret;
+}
+
+static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv)
+{
+       struct qxl_device *qdev = dev->dev_private;
+       struct drm_qxl_execbuffer *execbuffer = data;
+       struct drm_qxl_command user_cmd;
+       int cmd_num;
+       int ret;
+
+       for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) {
+
+               struct drm_qxl_command *commands =
+                       (struct drm_qxl_command *)(uintptr_t)execbuffer->commands;
+
+               if (DRM_COPY_FROM_USER(&user_cmd, &commands[cmd_num],
+                                      sizeof(user_cmd)))
+                       return -EFAULT;
+
+               ret = qxl_process_single_command(qdev, &user_cmd, file_priv);
+               if (ret)
                        return ret;
-               }
-               qxl_release_unreserve(qdev, release);
        }
-       qxl_bo_list_unreserve(&reloc_list, 0);
        return 0;
 }
 
@@ -305,7 +336,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
                goto out;
 
        if (!qobj->pin_count) {
-               qxl_ttm_placement_from_domain(qobj, qobj->type);
+               qxl_ttm_placement_from_domain(qobj, qobj->type, false);
                ret = ttm_bo_validate(&qobj->tbo, &qobj->placement,
                                      true, false);
                if (unlikely(ret))
index 1191fe7788c932d6c10e678815724c1dd44b8f16..aa161cddd87e4a018c601e25e722663d4e0e3207 100644 (file)
@@ -51,20 +51,21 @@ bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo)
        return false;
 }
 
-void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain)
+void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned)
 {
        u32 c = 0;
+       u32 pflag = pinned ? TTM_PL_FLAG_NO_EVICT : 0;
 
        qbo->placement.fpfn = 0;
        qbo->placement.lpfn = 0;
        qbo->placement.placement = qbo->placements;
        qbo->placement.busy_placement = qbo->placements;
        if (domain == QXL_GEM_DOMAIN_VRAM)
-               qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_VRAM;
+               qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_VRAM | pflag;
        if (domain == QXL_GEM_DOMAIN_SURFACE)
-               qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_PRIV0;
+               qbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_PRIV0 | pflag;
        if (domain == QXL_GEM_DOMAIN_CPU)
-               qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+               qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM | pflag;
        if (!c)
                qbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
        qbo->placement.num_placement = c;
@@ -73,7 +74,7 @@ void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain)
 
 
 int qxl_bo_create(struct qxl_device *qdev,
-                 unsigned long size, bool kernel, u32 domain,
+                 unsigned long size, bool kernel, bool pinned, u32 domain,
                  struct qxl_surface *surf,
                  struct qxl_bo **bo_ptr)
 {
@@ -99,15 +100,15 @@ int qxl_bo_create(struct qxl_device *qdev,
        }
        bo->gem_base.driver_private = NULL;
        bo->type = domain;
-       bo->pin_count = 0;
+       bo->pin_count = pinned ? 1 : 0;
        bo->surface_id = 0;
        qxl_fence_init(qdev, &bo->fence);
        INIT_LIST_HEAD(&bo->list);
-       atomic_set(&bo->reserve_count, 0);
+
        if (surf)
                bo->surf = *surf;
 
-       qxl_ttm_placement_from_domain(bo, domain);
+       qxl_ttm_placement_from_domain(bo, domain, pinned);
 
        r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
                        &bo->placement, 0, !kernel, NULL, size,
@@ -228,7 +229,7 @@ struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo)
 int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr)
 {
        struct qxl_device *qdev = (struct qxl_device *)bo->gem_base.dev->dev_private;
-       int r, i;
+       int r;
 
        if (bo->pin_count) {
                bo->pin_count++;
@@ -236,9 +237,7 @@ int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr)
                        *gpu_addr = qxl_bo_gpu_offset(bo);
                return 0;
        }
-       qxl_ttm_placement_from_domain(bo, domain);
-       for (i = 0; i < bo->placement.num_placement; i++)
-               bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
+       qxl_ttm_placement_from_domain(bo, domain, true);
        r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
        if (likely(r == 0)) {
                bo->pin_count = 1;
@@ -317,53 +316,6 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo)
        return 0;
 }
 
-void qxl_bo_list_unreserve(struct qxl_reloc_list *reloc_list, bool failed)
-{
-       struct qxl_bo_list *entry, *sf;
-
-       list_for_each_entry_safe(entry, sf, &reloc_list->bos, lhead) {
-               qxl_bo_unreserve(entry->bo);
-               list_del(&entry->lhead);
-               kfree(entry);
-       }
-}
-
-int qxl_bo_list_add(struct qxl_reloc_list *reloc_list, struct qxl_bo *bo)
-{
-       struct qxl_bo_list *entry;
-       int ret;
-
-       list_for_each_entry(entry, &reloc_list->bos, lhead) {
-               if (entry->bo == bo)
-                       return 0;
-       }
-
-       entry = kmalloc(sizeof(struct qxl_bo_list), GFP_KERNEL);
-       if (!entry)
-               return -ENOMEM;
-
-       entry->bo = bo;
-       list_add(&entry->lhead, &reloc_list->bos);
-
-       ret = qxl_bo_reserve(bo, false);
-       if (ret)
-               return ret;
-
-       if (!bo->pin_count) {
-               qxl_ttm_placement_from_domain(bo, bo->type);
-               ret = ttm_bo_validate(&bo->tbo, &bo->placement,
-                                     true, false);
-               if (ret)
-                       return ret;
-       }
-
-       /* allocate a surface for reserved + validated buffers */
-       ret = qxl_bo_check_id(bo->gem_base.dev->dev_private, bo);
-       if (ret)
-               return ret;
-       return 0;
-}
-
 int qxl_surf_evict(struct qxl_device *qdev)
 {
        return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV0);
index ee7ad79ce781b163fdc31836184af2b44fb10d70..8cb6167038e544625ec666a6fef7b4308d8e832d 100644 (file)
@@ -88,7 +88,7 @@ static inline int qxl_bo_wait(struct qxl_bo *bo, u32 *mem_type,
 
 extern int qxl_bo_create(struct qxl_device *qdev,
                         unsigned long size,
-                        bool kernel, u32 domain,
+                        bool kernel, bool pinned, u32 domain,
                         struct qxl_surface *surf,
                         struct qxl_bo **bo_ptr);
 extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr);
@@ -99,9 +99,7 @@ extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo);
 extern void qxl_bo_unref(struct qxl_bo **bo);
 extern int qxl_bo_pin(struct qxl_bo *bo, u32 domain, u64 *gpu_addr);
 extern int qxl_bo_unpin(struct qxl_bo *bo);
-extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain);
+extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned);
 extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
 
-extern int qxl_bo_list_add(struct qxl_reloc_list *reloc_list, struct qxl_bo *bo);
-extern void qxl_bo_list_unreserve(struct qxl_reloc_list *reloc_list, bool failed);
 #endif
index b443d6751d5f2da675dda7fccec24b2637312ba7..b61449e52cd5695c7c024548ecedfc3340b11156 100644 (file)
@@ -38,7 +38,8 @@
 
 static const int release_size_per_bo[] = { RELEASE_SIZE, SURFACE_RELEASE_SIZE, RELEASE_SIZE };
 static const int releases_per_bo[] = { RELEASES_PER_BO, SURFACE_RELEASES_PER_BO, RELEASES_PER_BO };
-uint64_t
+
+static uint64_t
 qxl_release_alloc(struct qxl_device *qdev, int type,
                  struct qxl_release **ret)
 {
@@ -53,9 +54,9 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
                return 0;
        }
        release->type = type;
-       release->bo_count = 0;
        release->release_offset = 0;
        release->surface_release_id = 0;
+       INIT_LIST_HEAD(&release->bos);
 
        idr_preload(GFP_KERNEL);
        spin_lock(&qdev->release_idr_lock);
@@ -77,20 +78,20 @@ void
 qxl_release_free(struct qxl_device *qdev,
                 struct qxl_release *release)
 {
-       int i;
-
-       QXL_INFO(qdev, "release %d, type %d, %d bos\n", release->id,
-                release->type, release->bo_count);
+       struct qxl_bo_list *entry, *tmp;
+       QXL_INFO(qdev, "release %d, type %d\n", release->id,
+                release->type);
 
        if (release->surface_release_id)
                qxl_surface_id_dealloc(qdev, release->surface_release_id);
 
-       for (i = 0 ; i < release->bo_count; ++i) {
+       list_for_each_entry_safe(entry, tmp, &release->bos, tv.head) {
+               struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
                QXL_INFO(qdev, "release %llx\n",
-                       release->bos[i]->tbo.addr_space_offset
+                       entry->tv.bo->addr_space_offset
                                                - DRM_FILE_OFFSET);
-               qxl_fence_remove_release(&release->bos[i]->fence, release->id);
-               qxl_bo_unref(&release->bos[i]);
+               qxl_fence_remove_release(&bo->fence, release->id);
+               qxl_bo_unref(&bo);
        }
        spin_lock(&qdev->release_idr_lock);
        idr_remove(&qdev->release_idr, release->id);
@@ -98,83 +99,117 @@ qxl_release_free(struct qxl_device *qdev,
        kfree(release);
 }
 
-void
-qxl_release_add_res(struct qxl_device *qdev, struct qxl_release *release,
-                   struct qxl_bo *bo)
-{
-       int i;
-       for (i = 0; i < release->bo_count; i++)
-               if (release->bos[i] == bo)
-                       return;
-
-       if (release->bo_count >= QXL_MAX_RES) {
-               DRM_ERROR("exceeded max resource on a qxl_release item\n");
-               return;
-       }
-       release->bos[release->bo_count++] = qxl_bo_ref(bo);
-}
-
 static int qxl_release_bo_alloc(struct qxl_device *qdev,
                                struct qxl_bo **bo)
 {
        int ret;
-       ret = qxl_bo_create(qdev, PAGE_SIZE, false, QXL_GEM_DOMAIN_VRAM, NULL,
+       /* pin releases bo's they are too messy to evict */
+       ret = qxl_bo_create(qdev, PAGE_SIZE, false, true,
+                           QXL_GEM_DOMAIN_VRAM, NULL,
                            bo);
        return ret;
 }
 
-int qxl_release_reserve(struct qxl_device *qdev,
-                       struct qxl_release *release, bool no_wait)
+int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)
+{
+       struct qxl_bo_list *entry;
+
+       list_for_each_entry(entry, &release->bos, tv.head) {
+               if (entry->tv.bo == &bo->tbo)
+                       return 0;
+       }
+
+       entry = kmalloc(sizeof(struct qxl_bo_list), GFP_KERNEL);
+       if (!entry)
+               return -ENOMEM;
+
+       qxl_bo_ref(bo);
+       entry->tv.bo = &bo->tbo;
+       list_add_tail(&entry->tv.head, &release->bos);
+       return 0;
+}
+
+static int qxl_release_validate_bo(struct qxl_bo *bo)
 {
        int ret;
-       if (atomic_inc_return(&release->bos[0]->reserve_count) == 1) {
-               ret = qxl_bo_reserve(release->bos[0], no_wait);
+
+       if (!bo->pin_count) {
+               qxl_ttm_placement_from_domain(bo, bo->type, false);
+               ret = ttm_bo_validate(&bo->tbo, &bo->placement,
+                                     true, false);
                if (ret)
                        return ret;
        }
+
+       /* allocate a surface for reserved + validated buffers */
+       ret = qxl_bo_check_id(bo->gem_base.dev->dev_private, bo);
+       if (ret)
+               return ret;
+       return 0;
+}
+
+int qxl_release_reserve_list(struct qxl_release *release, bool no_intr)
+{
+       int ret;
+       struct qxl_bo_list *entry;
+
+       /* if only one object on the release its the release itself
+          since these objects are pinned no need to reserve */
+       if (list_is_singular(&release->bos))
+               return 0;
+
+       ret = ttm_eu_reserve_buffers(&release->ticket, &release->bos);
+       if (ret)
+               return ret;
+
+       list_for_each_entry(entry, &release->bos, tv.head) {
+               struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
+
+               ret = qxl_release_validate_bo(bo);
+               if (ret) {
+                       ttm_eu_backoff_reservation(&release->ticket, &release->bos);
+                       return ret;
+               }
+       }
        return 0;
 }
 
-void qxl_release_unreserve(struct qxl_device *qdev,
-                         struct qxl_release *release)
+void qxl_release_backoff_reserve_list(struct qxl_release *release)
 {
-       if (atomic_dec_and_test(&release->bos[0]->reserve_count))
-               qxl_bo_unreserve(release->bos[0]);
+       /* if only one object on the release its the release itself
+          since these objects are pinned no need to reserve */
+       if (list_is_singular(&release->bos))
+               return;
+
+       ttm_eu_backoff_reservation(&release->ticket, &release->bos);
 }
 
+
 int qxl_alloc_surface_release_reserved(struct qxl_device *qdev,
                                       enum qxl_surface_cmd_type surface_cmd_type,
                                       struct qxl_release *create_rel,
                                       struct qxl_release **release)
 {
-       int ret;
-
        if (surface_cmd_type == QXL_SURFACE_CMD_DESTROY && create_rel) {
                int idr_ret;
+               struct qxl_bo_list *entry = list_first_entry(&create_rel->bos, struct qxl_bo_list, tv.head);
                struct qxl_bo *bo;
                union qxl_release_info *info;
 
                /* stash the release after the create command */
                idr_ret = qxl_release_alloc(qdev, QXL_RELEASE_SURFACE_CMD, release);
-               bo = qxl_bo_ref(create_rel->bos[0]);
+               bo = qxl_bo_ref(to_qxl_bo(entry->tv.bo));
 
                (*release)->release_offset = create_rel->release_offset + 64;
 
-               qxl_release_add_res(qdev, *release, bo);
+               qxl_release_list_add(*release, bo);
 
-               ret = qxl_release_reserve(qdev, *release, false);
-               if (ret) {
-                       DRM_ERROR("release reserve failed\n");
-                       goto out_unref;
-               }
                info = qxl_release_map(qdev, *release);
                info->id = idr_ret;
                qxl_release_unmap(qdev, *release, info);
 
-
-out_unref:
                qxl_bo_unref(&bo);
-               return ret;
+               return 0;
        }
 
        return qxl_alloc_release_reserved(qdev, sizeof(struct qxl_surface_cmd),
@@ -187,7 +222,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
 {
        struct qxl_bo *bo;
        int idr_ret;
-       int ret;
+       int ret = 0;
        union qxl_release_info *info;
        int cur_idx;
 
@@ -216,11 +251,6 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
                        mutex_unlock(&qdev->release_mutex);
                        return ret;
                }
-
-               /* pin releases bo's they are too messy to evict */
-               ret = qxl_bo_reserve(qdev->current_release_bo[cur_idx], false);
-               qxl_bo_pin(qdev->current_release_bo[cur_idx], QXL_GEM_DOMAIN_VRAM, NULL);
-               qxl_bo_unreserve(qdev->current_release_bo[cur_idx]);
        }
 
        bo = qxl_bo_ref(qdev->current_release_bo[cur_idx]);
@@ -231,36 +261,18 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
        if (rbo)
                *rbo = bo;
 
-       qxl_release_add_res(qdev, *release, bo);
-
-       ret = qxl_release_reserve(qdev, *release, false);
        mutex_unlock(&qdev->release_mutex);
-       if (ret)
-               goto out_unref;
+
+       qxl_release_list_add(*release, bo);
 
        info = qxl_release_map(qdev, *release);
        info->id = idr_ret;
        qxl_release_unmap(qdev, *release, info);
 
-out_unref:
        qxl_bo_unref(&bo);
        return ret;
 }
 
-int qxl_fence_releaseable(struct qxl_device *qdev,
-                         struct qxl_release *release)
-{
-       int i, ret;
-       for (i = 0; i < release->bo_count; i++) {
-               if (!release->bos[i]->tbo.sync_obj)
-                       release->bos[i]->tbo.sync_obj = &release->bos[i]->fence;
-               ret = qxl_fence_add_release(&release->bos[i]->fence, release->id);
-               if (ret)
-                       return ret;
-       }
-       return 0;
-}
-
 struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
                                                   uint64_t id)
 {
@@ -273,10 +285,7 @@ struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev,
                DRM_ERROR("failed to find id in release_idr\n");
                return NULL;
        }
-       if (release->bo_count < 1) {
-               DRM_ERROR("read a released resource with 0 bos\n");
-               return NULL;
-       }
+
        return release;
 }
 
@@ -285,9 +294,12 @@ union qxl_release_info *qxl_release_map(struct qxl_device *qdev,
 {
        void *ptr;
        union qxl_release_info *info;
-       struct qxl_bo *bo = release->bos[0];
+       struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
+       struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
 
        ptr = qxl_bo_kmap_atomic_page(qdev, bo, release->release_offset & PAGE_SIZE);
+       if (!ptr)
+               return NULL;
        info = ptr + (release->release_offset & ~PAGE_SIZE);
        return info;
 }
@@ -296,9 +308,51 @@ void qxl_release_unmap(struct qxl_device *qdev,
                       struct qxl_release *release,
                       union qxl_release_info *info)
 {
-       struct qxl_bo *bo = release->bos[0];
+       struct qxl_bo_list *entry = list_first_entry(&release->bos, struct qxl_bo_list, tv.head);
+       struct qxl_bo *bo = to_qxl_bo(entry->tv.bo);
        void *ptr;
 
        ptr = ((void *)info) - (release->release_offset & ~PAGE_SIZE);
        qxl_bo_kunmap_atomic_page(qdev, bo, ptr);
 }
+
+void qxl_release_fence_buffer_objects(struct qxl_release *release)
+{
+       struct ttm_validate_buffer *entry;
+       struct ttm_buffer_object *bo;
+       struct ttm_bo_global *glob;
+       struct ttm_bo_device *bdev;
+       struct ttm_bo_driver *driver;
+       struct qxl_bo *qbo;
+
+       /* if only one object on the release its the release itself
+          since these objects are pinned no need to reserve */
+       if (list_is_singular(&release->bos))
+               return;
+
+       bo = list_first_entry(&release->bos, struct ttm_validate_buffer, head)->bo;
+       bdev = bo->bdev;
+       driver = bdev->driver;
+       glob = bo->glob;
+
+       spin_lock(&glob->lru_lock);
+       spin_lock(&bdev->fence_lock);
+
+       list_for_each_entry(entry, &release->bos, head) {
+               bo = entry->bo;
+               qbo = to_qxl_bo(bo);
+
+               if (!entry->bo->sync_obj)
+                       entry->bo->sync_obj = &qbo->fence;
+
+               qxl_fence_add_release_locked(&qbo->fence, release->id);
+
+               ttm_bo_add_to_lru(bo);
+               ww_mutex_unlock(&bo->resv->lock);
+               entry->reserved = false;
+       }
+       spin_unlock(&bdev->fence_lock);
+       spin_unlock(&glob->lru_lock);
+       ww_acquire_fini(&release->ticket);
+}
+
index 489cb8cece4da553b9f5c36c4dc9c610e617c3ea..1dfd84cda2a128e39f4e8143c43b3d0c6a99f30b 100644 (file)
@@ -206,7 +206,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
                return;
        }
        qbo = container_of(bo, struct qxl_bo, tbo);
-       qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU);
+       qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU, false);
        *placement = qbo->placement;
 }
 
index fb441a790f3dc5a56fa6c65bf4384f2d098906fb..15da7ef344a4e55fa11d604c21269e97ab361386 100644 (file)
@@ -1222,12 +1222,17 @@ int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
        int r;
 
        mutex_lock(&ctx->mutex);
+       /* reset data block */
+       ctx->data_block = 0;
        /* reset reg block */
        ctx->reg_block = 0;
        /* reset fb window */
        ctx->fb_base = 0;
        /* reset io mode */
        ctx->io_mode = ATOM_IO_MM;
+       /* reset divmul */
+       ctx->divmul[0] = 0;
+       ctx->divmul[1] = 0;
        r = atom_execute_table_locked(ctx, index, params);
        mutex_unlock(&ctx->mutex);
        return r;
index 064023bed480fb84eae64d505465601499ac4dfc..32501f6ec991169917af2446db4acbd37f8fbba0 100644 (file)
@@ -44,6 +44,41 @@ static char *pre_emph_names[] = {
 };
 
 /***** radeon AUX functions *****/
+
+/* Atom needs data in little endian format
+ * so swap as appropriate when copying data to
+ * or from atom. Note that atom operates on
+ * dw units.
+ */
+static void radeon_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
+{
+#ifdef __BIG_ENDIAN
+       u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
+       u32 *dst32, *src32;
+       int i;
+
+       memcpy(src_tmp, src, num_bytes);
+       src32 = (u32 *)src_tmp;
+       dst32 = (u32 *)dst_tmp;
+       if (to_le) {
+               for (i = 0; i < ((num_bytes + 3) / 4); i++)
+                       dst32[i] = cpu_to_le32(src32[i]);
+               memcpy(dst, dst_tmp, num_bytes);
+       } else {
+               u8 dws = num_bytes & ~3;
+               for (i = 0; i < ((num_bytes + 3) / 4); i++)
+                       dst32[i] = le32_to_cpu(src32[i]);
+               memcpy(dst, dst_tmp, dws);
+               if (num_bytes % 4) {
+                       for (i = 0; i < (num_bytes % 4); i++)
+                               dst[dws+i] = dst_tmp[dws+i];
+               }
+       }
+#else
+       memcpy(dst, src, num_bytes);
+#endif
+}
+
 union aux_channel_transaction {
        PROCESS_AUX_CHANNEL_TRANSACTION_PS_ALLOCATION v1;
        PROCESS_AUX_CHANNEL_TRANSACTION_PARAMETERS_V2 v2;
@@ -65,10 +100,10 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
 
        base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);
 
-       memcpy(base, send, send_bytes);
+       radeon_copy_swap(base, send, send_bytes, true);
 
-       args.v1.lpAuxRequest = 0 + 4;
-       args.v1.lpDataOut = 16 + 4;
+       args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4));
+       args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4));
        args.v1.ucDataOutLen = 0;
        args.v1.ucChannelID = chan->rec.i2c_id;
        args.v1.ucDelay = delay / 10;
@@ -102,7 +137,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
                recv_bytes = recv_size;
 
        if (recv && recv_size)
-               memcpy(recv, base + 16, recv_bytes);
+               radeon_copy_swap(recv, base + 16, recv_bytes, false);
 
        return recv_bytes;
 }
index 0bfd55e088201d79e3499b8c98585895f2c736c8..9953e1fbc46d74e53adf50eab2eb05e602287f54 100644 (file)
@@ -2548,9 +2548,6 @@ int btc_dpm_init(struct radeon_device *rdev)
 {
        struct rv7xx_power_info *pi;
        struct evergreen_power_info *eg_pi;
-       int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
-       u16 data_offset, size;
-       u8 frev, crev;
        struct atom_clock_dividers dividers;
        int ret;
 
@@ -2633,16 +2630,7 @@ int btc_dpm_init(struct radeon_device *rdev)
        eg_pi->vddci_control =
                radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
 
-       if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size,
-                                   &frev, &crev, &data_offset)) {
-               pi->sclk_ss = true;
-               pi->mclk_ss = true;
-               pi->dynamic_ss = true;
-       } else {
-               pi->sclk_ss = false;
-               pi->mclk_ss = false;
-               pi->dynamic_ss = true;
-       }
+       rv770_get_engine_memory_ss(rdev);
 
        pi->asi = RV770_ASI_DFLT;
        pi->pasi = CYPRESS_HASI_DFLT;
@@ -2659,8 +2647,7 @@ int btc_dpm_init(struct radeon_device *rdev)
 
        pi->dynamic_pcie_gen2 = true;
 
-       if (pi->gfx_clock_gating &&
-           (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
+       if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
                pi->thermal_protection = true;
        else
                pi->thermal_protection = false;
index ed1d910259289c899ff6b0306ef600fd05f96313..8928bd109c1647b684293cb49ed91198419eb33c 100644 (file)
@@ -22,7 +22,6 @@
  * Authors: Alex Deucher
  */
 #include <linux/firmware.h>
-#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include "drmP.h"
@@ -742,7 +741,6 @@ static int ci_mc_load_microcode(struct radeon_device *rdev)
  */
 static int cik_init_microcode(struct radeon_device *rdev)
 {
-       struct platform_device *pdev;
        const char *chip_name;
        size_t pfp_req_size, me_req_size, ce_req_size,
                mec_req_size, rlc_req_size, mc_req_size,
@@ -752,13 +750,6 @@ static int cik_init_microcode(struct radeon_device *rdev)
 
        DRM_DEBUG("\n");
 
-       pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
-       err = IS_ERR(pdev);
-       if (err) {
-               printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
-               return -EINVAL;
-       }
-
        switch (rdev->family) {
        case CHIP_BONAIRE:
                chip_name = "BONAIRE";
@@ -794,7 +785,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        DRM_INFO("Loading %s Microcode\n", chip_name);
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
-       err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->pfp_fw->size != pfp_req_size) {
@@ -806,7 +797,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
-       err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->me_fw->size != me_req_size) {
@@ -817,7 +808,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
-       err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->ce_fw->size != ce_req_size) {
@@ -828,7 +819,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name);
-       err = request_firmware(&rdev->mec_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->mec_fw->size != mec_req_size) {
@@ -839,7 +830,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name);
-       err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->rlc_fw->size != rlc_req_size) {
@@ -850,7 +841,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name);
-       err = request_firmware(&rdev->sdma_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->sdma_fw->size != sdma_req_size) {
@@ -863,7 +854,7 @@ static int cik_init_microcode(struct radeon_device *rdev)
        /* No MC ucode on APUs */
        if (!(rdev->flags & RADEON_IS_IGP)) {
                snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
-               err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev);
+               err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
                if (err)
                        goto out;
                if (rdev->mc_fw->size != mc_req_size) {
@@ -875,8 +866,6 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
 out:
-       platform_device_unregister(pdev);
-
        if (err) {
                if (err != -EINVAL)
                        printk(KERN_ERR
@@ -2598,9 +2587,11 @@ u32 cik_compute_ring_get_rptr(struct radeon_device *rdev,
        if (rdev->wb.enabled) {
                rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]);
        } else {
+               mutex_lock(&rdev->srbm_mutex);
                cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0);
                rptr = RREG32(CP_HQD_PQ_RPTR);
                cik_srbm_select(rdev, 0, 0, 0, 0);
+               mutex_unlock(&rdev->srbm_mutex);
        }
        rptr = (rptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
 
@@ -2615,9 +2606,11 @@ u32 cik_compute_ring_get_wptr(struct radeon_device *rdev,
        if (rdev->wb.enabled) {
                wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]);
        } else {
+               mutex_lock(&rdev->srbm_mutex);
                cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0);
                wptr = RREG32(CP_HQD_PQ_WPTR);
                cik_srbm_select(rdev, 0, 0, 0, 0);
+               mutex_unlock(&rdev->srbm_mutex);
        }
        wptr = (wptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
 
@@ -2908,6 +2901,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
        WREG32(CP_CPF_DEBUG, tmp);
 
        /* init the pipes */
+       mutex_lock(&rdev->srbm_mutex);
        for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) {
                int me = (i < 4) ? 1 : 2;
                int pipe = (i < 4) ? i : (i - 4);
@@ -2930,6 +2924,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
                WREG32(CP_HPD_EOP_CONTROL, tmp);
        }
        cik_srbm_select(rdev, 0, 0, 0, 0);
+       mutex_unlock(&rdev->srbm_mutex);
 
        /* init the queues.  Just two for now. */
        for (i = 0; i < 2; i++) {
@@ -2983,6 +2978,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
                mqd->static_thread_mgmt23[0] = 0xffffffff;
                mqd->static_thread_mgmt23[1] = 0xffffffff;
 
+               mutex_lock(&rdev->srbm_mutex);
                cik_srbm_select(rdev, rdev->ring[idx].me,
                                rdev->ring[idx].pipe,
                                rdev->ring[idx].queue, 0);
@@ -3110,6 +3106,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
                WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active);
 
                cik_srbm_select(rdev, 0, 0, 0, 0);
+               mutex_unlock(&rdev->srbm_mutex);
 
                radeon_bo_kunmap(rdev->ring[idx].mqd_obj);
                radeon_bo_unreserve(rdev->ring[idx].mqd_obj);
@@ -4331,6 +4328,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
 
        /* XXX SH_MEM regs */
        /* where to put LDS, scratch, GPUVM in FSA64 space */
+       mutex_lock(&rdev->srbm_mutex);
        for (i = 0; i < 16; i++) {
                cik_srbm_select(rdev, 0, 0, 0, i);
                /* CP and shaders */
@@ -4346,6 +4344,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
                /* XXX SDMA RLC - todo */
        }
        cik_srbm_select(rdev, 0, 0, 0, 0);
+       mutex_unlock(&rdev->srbm_mutex);
 
        cik_pcie_gart_tlb_flush(rdev);
        DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
@@ -4452,6 +4451,29 @@ void cik_vm_fini(struct radeon_device *rdev)
 {
 }
 
+/**
+ * cik_vm_decode_fault - print human readable fault info
+ *
+ * @rdev: radeon_device pointer
+ * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
+ * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
+ *
+ * Print human readable fault information (CIK).
+ */
+static void cik_vm_decode_fault(struct radeon_device *rdev,
+                               u32 status, u32 addr, u32 mc_client)
+{
+       u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT;
+       u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT;
+       u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT;
+       char *block = (char *)&mc_client;
+
+       printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n",
+              protections, vmid, addr,
+              (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read",
+              block, mc_id);
+}
+
 /**
  * cik_vm_flush - cik vm flush using the CP
  *
@@ -5507,6 +5529,7 @@ int cik_irq_process(struct radeon_device *rdev)
        u32 ring_index;
        bool queue_hotplug = false;
        bool queue_reset = false;
+       u32 addr, status, mc_client;
 
        if (!rdev->ih.enabled || rdev->shutdown)
                return IRQ_NONE;
@@ -5742,11 +5765,15 @@ restart_ih:
                        break;
                case 146:
                case 147:
+                       addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
+                       status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
+                       mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT);
                        dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
                        dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_ADDR   0x%08X\n",
-                               RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR));
+                               addr);
                        dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
-                               RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS));
+                               status);
+                       cik_vm_decode_fault(rdev, status, addr, mc_client);
                        /* reset addr and status */
                        WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
                        break;
@@ -5937,6 +5964,8 @@ static int cik_startup(struct radeon_device *rdev)
        struct radeon_ring *ring;
        int r;
 
+       cik_mc_program(rdev);
+
        if (rdev->flags & RADEON_IS_IGP) {
                if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
                    !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) {
@@ -5968,7 +5997,6 @@ static int cik_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       cik_mc_program(rdev);
        r = cik_pcie_gart_enable(rdev);
        if (r)
                return r;
@@ -6177,7 +6205,7 @@ int cik_suspend(struct radeon_device *rdev)
        radeon_vm_manager_fini(rdev);
        cik_cp_enable(rdev, false);
        cik_sdma_enable(rdev, false);
-       r600_uvd_rbc_stop(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_suspend(rdev);
        cik_irq_suspend(rdev);
        radeon_wb_disable(rdev);
@@ -6341,6 +6369,7 @@ void cik_fini(struct radeon_device *rdev)
        radeon_vm_manager_fini(rdev);
        radeon_ib_pool_fini(rdev);
        radeon_irq_kms_fini(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_fini(rdev);
        cik_pcie_gart_fini(rdev);
        r600_vram_scratch_fini(rdev);
index 63514b95889a52c5a3a47081e7d15c59e98bea3f..7e9275eaef8020d90b41a31dc46e9eaca8f84e24 100644 (file)
 #define VM_INVALIDATE_RESPONSE                         0x147c
 
 #define        VM_CONTEXT1_PROTECTION_FAULT_STATUS             0x14DC
+#define                PROTECTIONS_MASK                        (0xf << 0)
+#define                PROTECTIONS_SHIFT                       0
+               /* bit 0: range
+                * bit 1: pde0
+                * bit 2: valid
+                * bit 3: read
+                * bit 4: write
+                */
+#define                MEMORY_CLIENT_ID_MASK                   (0xff << 12)
+#define                MEMORY_CLIENT_ID_SHIFT                  12
+#define                MEMORY_CLIENT_RW_MASK                   (1 << 24)
+#define                MEMORY_CLIENT_RW_SHIFT                  24
+#define                FAULT_VMID_MASK                         (0xf << 25)
+#define                FAULT_VMID_SHIFT                        25
+
+#define        VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT           0x14E4
 
 #define        VM_CONTEXT1_PROTECTION_FAULT_ADDR               0x14FC
 
index 9bcdd174780f2a8ec618cf255ad2c37690a2237f..7e5d0b570a30531a8752e6b4f29bb732528bb7fe 100644 (file)
@@ -2038,9 +2038,6 @@ int cypress_dpm_init(struct radeon_device *rdev)
 {
        struct rv7xx_power_info *pi;
        struct evergreen_power_info *eg_pi;
-       int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
-       uint16_t data_offset, size;
-       uint8_t frev, crev;
        struct atom_clock_dividers dividers;
        int ret;
 
@@ -2092,16 +2089,7 @@ int cypress_dpm_init(struct radeon_device *rdev)
        eg_pi->vddci_control =
                radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
 
-       if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size,
-                                   &frev, &crev, &data_offset)) {
-               pi->sclk_ss = true;
-               pi->mclk_ss = true;
-               pi->dynamic_ss = true;
-       } else {
-               pi->sclk_ss = false;
-               pi->mclk_ss = false;
-               pi->dynamic_ss = true;
-       }
+       rv770_get_engine_memory_ss(rdev);
 
        pi->asi = RV770_ASI_DFLT;
        pi->pasi = CYPRESS_HASI_DFLT;
@@ -2122,8 +2110,7 @@ int cypress_dpm_init(struct radeon_device *rdev)
 
        pi->dynamic_pcie_gen2 = true;
 
-       if (pi->gfx_clock_gating &&
-           (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
+       if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
                pi->thermal_protection = true;
        else
                pi->thermal_protection = false;
index e49059dc9b8fbe8d3e4baf7d09cbd2c8355d7ed1..d5b49e33315e299aa4b2a2085d0fdd3d1c8a99bc 100644 (file)
@@ -139,6 +139,8 @@ void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
 void evergreen_program_aspm(struct radeon_device *rdev);
 extern void cayman_cp_int_cntl_setup(struct radeon_device *rdev,
                                     int ring, u32 cp_int_cntl);
+extern void cayman_vm_decode_fault(struct radeon_device *rdev,
+                                  u32 status, u32 addr);
 
 static const u32 evergreen_golden_registers[] =
 {
@@ -4586,6 +4588,7 @@ int evergreen_irq_process(struct radeon_device *rdev)
        bool queue_hotplug = false;
        bool queue_hdmi = false;
        bool queue_thermal = false;
+       u32 status, addr;
 
        if (!rdev->ih.enabled || rdev->shutdown)
                return IRQ_NONE;
@@ -4872,11 +4875,14 @@ restart_ih:
                        break;
                case 146:
                case 147:
+                       addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
+                       status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
                        dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
                        dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_ADDR   0x%08X\n",
-                               RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR));
+                               addr);
                        dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
-                               RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS));
+                               status);
+                       cayman_vm_decode_fault(rdev, status, addr);
                        /* reset addr and status */
                        WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
                        break;
@@ -5100,6 +5106,8 @@ static int evergreen_startup(struct radeon_device *rdev)
        /* enable aspm */
        evergreen_program_aspm(rdev);
 
+       evergreen_mc_program(rdev);
+
        if (ASIC_IS_DCE5(rdev)) {
                if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) {
                        r = ni_init_microcode(rdev);
@@ -5127,7 +5135,6 @@ static int evergreen_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       evergreen_mc_program(rdev);
        if (rdev->flags & RADEON_IS_AGP) {
                evergreen_agp_enable(rdev);
        } else {
@@ -5285,10 +5292,10 @@ int evergreen_resume(struct radeon_device *rdev)
 int evergreen_suspend(struct radeon_device *rdev)
 {
        r600_audio_fini(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_suspend(rdev);
        r700_cp_stop(rdev);
        r600_dma_stop(rdev);
-       r600_uvd_rbc_stop(rdev);
        evergreen_irq_suspend(rdev);
        radeon_wb_disable(rdev);
        evergreen_pcie_gart_disable(rdev);
@@ -5423,6 +5430,7 @@ void evergreen_fini(struct radeon_device *rdev)
        radeon_ib_pool_fini(rdev);
        radeon_irq_kms_fini(rdev);
        evergreen_pcie_gart_fini(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_fini(rdev);
        r600_vram_scratch_fini(rdev);
        radeon_gem_fini(rdev);
@@ -5509,6 +5517,9 @@ void evergreen_program_aspm(struct radeon_device *rdev)
         */
        bool fusion_platform = false;
 
+       if (radeon_aspm == 0)
+               return;
+
        if (!(rdev->flags & RADEON_IS_PCIE))
                return;
 
index b9c6f7675e599d7ee0ab31795af5864e434fabd7..b0e280058b9b09ea22eb75f5c13ab6395e1698ba 100644 (file)
@@ -148,18 +148,40 @@ static void evergreen_audio_set_dto(struct drm_encoder *encoder, u32 clock)
        struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
        u32 base_rate = 24000;
+       u32 max_ratio = clock / base_rate;
+       u32 dto_phase;
+       u32 dto_modulo = clock;
+       u32 wallclock_ratio;
+       u32 dto_cntl;
 
        if (!dig || !dig->afmt)
                return;
 
+       if (max_ratio >= 8) {
+               dto_phase = 192 * 1000;
+               wallclock_ratio = 3;
+       } else if (max_ratio >= 4) {
+               dto_phase = 96 * 1000;
+               wallclock_ratio = 2;
+       } else if (max_ratio >= 2) {
+               dto_phase = 48 * 1000;
+               wallclock_ratio = 1;
+       } else {
+               dto_phase = 24 * 1000;
+               wallclock_ratio = 0;
+       }
+       dto_cntl = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
+       dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
+       WREG32(DCCG_AUDIO_DTO0_CNTL, dto_cntl);
+
        /* XXX two dtos; generally use dto0 for hdmi */
        /* Express [24MHz / target pixel clock] as an exact rational
         * number (coefficient of two integer numbers.  DCCG_AUDIO_DTOx_PHASE
         * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
         */
-       WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100);
-       WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100);
        WREG32(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL(radeon_crtc->crtc_id));
+       WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
+       WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo);
 }
 
 
@@ -177,6 +199,9 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
        uint32_t offset;
        ssize_t err;
 
+       if (!dig || !dig->afmt)
+               return;
+
        /* Silent, r600_hdmi_enable will raise WARN for us */
        if (!dig->afmt->enabled)
                return;
@@ -280,6 +305,9 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
        struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
 
+       if (!dig || !dig->afmt)
+               return;
+
        /* Silent, r600_hdmi_enable will raise WARN for us */
        if (enable && dig->afmt->enabled)
                return;
index a7baf67aef6cae99eacdd958b1aa00e2fd925841..0d582ac1dc31841b0844df7cfe4b186bd7b6da0e 100644 (file)
 #define DCCG_AUDIO_DTO0_MODULE            0x05b4
 #define DCCG_AUDIO_DTO0_LOAD              0x05b8
 #define DCCG_AUDIO_DTO0_CNTL              0x05bc
+#       define DCCG_AUDIO_DTO_WALLCLOCK_RATIO(x) (((x) & 7) << 0)
+#       define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK 7
+#       define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_SHIFT 0
 
 #define DCCG_AUDIO_DTO1_PHASE             0x05c0
 #define DCCG_AUDIO_DTO1_MODULE            0x05c4
index f30127cb30ef5e6c546980eae38e6beebb6c50e4..ccb4f8b548524b46900f6d88444179c9f6a3069f 100644 (file)
@@ -22,7 +22,6 @@
  * Authors: Alex Deucher
  */
 #include <linux/firmware.h>
-#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <drm/drmP.h>
@@ -684,7 +683,6 @@ int ni_mc_load_microcode(struct radeon_device *rdev)
 
 int ni_init_microcode(struct radeon_device *rdev)
 {
-       struct platform_device *pdev;
        const char *chip_name;
        const char *rlc_chip_name;
        size_t pfp_req_size, me_req_size, rlc_req_size, mc_req_size;
@@ -694,13 +692,6 @@ int ni_init_microcode(struct radeon_device *rdev)
 
        DRM_DEBUG("\n");
 
-       pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
-       err = IS_ERR(pdev);
-       if (err) {
-               printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
-               return -EINVAL;
-       }
-
        switch (rdev->family) {
        case CHIP_BARTS:
                chip_name = "BARTS";
@@ -753,7 +744,7 @@ int ni_init_microcode(struct radeon_device *rdev)
        DRM_INFO("Loading %s Microcode\n", chip_name);
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
-       err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->pfp_fw->size != pfp_req_size) {
@@ -765,7 +756,7 @@ int ni_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
-       err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->me_fw->size != me_req_size) {
@@ -776,7 +767,7 @@ int ni_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
-       err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->rlc_fw->size != rlc_req_size) {
@@ -789,7 +780,7 @@ int ni_init_microcode(struct radeon_device *rdev)
        /* no MC ucode on TN */
        if (!(rdev->flags & RADEON_IS_IGP)) {
                snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
-               err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev);
+               err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
                if (err)
                        goto out;
                if (rdev->mc_fw->size != mc_req_size) {
@@ -802,10 +793,14 @@ int ni_init_microcode(struct radeon_device *rdev)
 
        if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) {
                snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
-               err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev);
-               if (err)
-                       goto out;
-               if (rdev->smc_fw->size != smc_req_size) {
+               err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
+               if (err) {
+                       printk(KERN_ERR
+                              "smc: error loading firmware \"%s\"\n",
+                              fw_name);
+                       release_firmware(rdev->smc_fw);
+                       rdev->smc_fw = NULL;
+               } else if (rdev->smc_fw->size != smc_req_size) {
                        printk(KERN_ERR
                               "ni_mc: Bogus length %zu in firmware \"%s\"\n",
                               rdev->mc_fw->size, fw_name);
@@ -814,8 +809,6 @@ int ni_init_microcode(struct radeon_device *rdev)
        }
 
 out:
-       platform_device_unregister(pdev);
-
        if (err) {
                if (err != -EINVAL)
                        printk(KERN_ERR
@@ -2090,6 +2083,8 @@ static int cayman_startup(struct radeon_device *rdev)
        /* enable aspm */
        evergreen_program_aspm(rdev);
 
+       evergreen_mc_program(rdev);
+
        if (rdev->flags & RADEON_IS_IGP) {
                if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
                        r = ni_init_microcode(rdev);
@@ -2118,7 +2113,6 @@ static int cayman_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       evergreen_mc_program(rdev);
        r = cayman_pcie_gart_enable(rdev);
        if (r)
                return r;
@@ -2297,7 +2291,7 @@ int cayman_suspend(struct radeon_device *rdev)
        radeon_vm_manager_fini(rdev);
        cayman_cp_enable(rdev, false);
        cayman_dma_stop(rdev);
-       r600_uvd_rbc_stop(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_suspend(rdev);
        evergreen_irq_suspend(rdev);
        radeon_wb_disable(rdev);
@@ -2429,6 +2423,7 @@ void cayman_fini(struct radeon_device *rdev)
        radeon_vm_manager_fini(rdev);
        radeon_ib_pool_fini(rdev);
        radeon_irq_kms_fini(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_fini(rdev);
        cayman_pcie_gart_fini(rdev);
        r600_vram_scratch_fini(rdev);
@@ -2461,6 +2456,167 @@ void cayman_vm_fini(struct radeon_device *rdev)
 {
 }
 
+/**
+ * cayman_vm_decode_fault - print human readable fault info
+ *
+ * @rdev: radeon_device pointer
+ * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
+ * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
+ *
+ * Print human readable fault information (cayman/TN).
+ */
+void cayman_vm_decode_fault(struct radeon_device *rdev,
+                           u32 status, u32 addr)
+{
+       u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT;
+       u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT;
+       u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT;
+       char *block;
+
+       switch (mc_id) {
+       case 32:
+       case 16:
+       case 96:
+       case 80:
+       case 160:
+       case 144:
+       case 224:
+       case 208:
+               block = "CB";
+               break;
+       case 33:
+       case 17:
+       case 97:
+       case 81:
+       case 161:
+       case 145:
+       case 225:
+       case 209:
+               block = "CB_FMASK";
+               break;
+       case 34:
+       case 18:
+       case 98:
+       case 82:
+       case 162:
+       case 146:
+       case 226:
+       case 210:
+               block = "CB_CMASK";
+               break;
+       case 35:
+       case 19:
+       case 99:
+       case 83:
+       case 163:
+       case 147:
+       case 227:
+       case 211:
+               block = "CB_IMMED";
+               break;
+       case 36:
+       case 20:
+       case 100:
+       case 84:
+       case 164:
+       case 148:
+       case 228:
+       case 212:
+               block = "DB";
+               break;
+       case 37:
+       case 21:
+       case 101:
+       case 85:
+       case 165:
+       case 149:
+       case 229:
+       case 213:
+               block = "DB_HTILE";
+               break;
+       case 38:
+       case 22:
+       case 102:
+       case 86:
+       case 166:
+       case 150:
+       case 230:
+       case 214:
+               block = "SX";
+               break;
+       case 39:
+       case 23:
+       case 103:
+       case 87:
+       case 167:
+       case 151:
+       case 231:
+       case 215:
+               block = "DB_STEN";
+               break;
+       case 40:
+       case 24:
+       case 104:
+       case 88:
+       case 232:
+       case 216:
+       case 168:
+       case 152:
+               block = "TC_TFETCH";
+               break;
+       case 41:
+       case 25:
+       case 105:
+       case 89:
+       case 233:
+       case 217:
+       case 169:
+       case 153:
+               block = "TC_VFETCH";
+               break;
+       case 42:
+       case 26:
+       case 106:
+       case 90:
+       case 234:
+       case 218:
+       case 170:
+       case 154:
+               block = "VC";
+               break;
+       case 112:
+               block = "CP";
+               break;
+       case 113:
+       case 114:
+               block = "SH";
+               break;
+       case 115:
+               block = "VGT";
+               break;
+       case 178:
+               block = "IH";
+               break;
+       case 51:
+               block = "RLC";
+               break;
+       case 55:
+               block = "DMA";
+               break;
+       case 56:
+               block = "HDP";
+               break;
+       default:
+               block = "unknown";
+               break;
+       }
+
+       printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n",
+              protections, vmid, addr,
+              (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read",
+              block, mc_id);
+}
+
 #define R600_ENTRY_VALID   (1 << 0)
 #define R600_PTE_SYSTEM    (1 << 1)
 #define R600_PTE_SNOOPED   (1 << 2)
index 559cf24d51af8dbe7304caa443e7e15118c750ca..f0f5f748938ad6c30292d2b109bef4c3a2f8fc29 100644 (file)
@@ -1054,10 +1054,6 @@ static int ni_restrict_performance_levels_before_switch(struct radeon_device *rd
 int ni_dpm_force_performance_level(struct radeon_device *rdev,
                                   enum radeon_dpm_forced_level level)
 {
-       struct radeon_ps *rps = rdev->pm.dpm.current_ps;
-       struct ni_ps *ps = ni_get_ps(rps);
-       u32 levels;
-
        if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
                if (ni_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 0) != PPSMC_Result_OK)
                        return -EINVAL;
@@ -1068,8 +1064,7 @@ int ni_dpm_force_performance_level(struct radeon_device *rdev,
                if (ni_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
                        return -EINVAL;
 
-               levels = ps->performance_level_count - 1;
-               if (ni_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
+               if (ni_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK)
                        return -EINVAL;
        } else if (level == RADEON_DPM_FORCED_LEVEL_AUTO) {
                if (ni_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
@@ -4072,9 +4067,6 @@ int ni_dpm_init(struct radeon_device *rdev)
        struct rv7xx_power_info *pi;
        struct evergreen_power_info *eg_pi;
        struct ni_power_info *ni_pi;
-       int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
-       u16 data_offset, size;
-       u8 frev, crev;
        struct atom_clock_dividers dividers;
        int ret;
 
@@ -4167,16 +4159,7 @@ int ni_dpm_init(struct radeon_device *rdev)
        eg_pi->vddci_control =
                radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
 
-       if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size,
-                                   &frev, &crev, &data_offset)) {
-               pi->sclk_ss = true;
-               pi->mclk_ss = true;
-               pi->dynamic_ss = true;
-       } else {
-               pi->sclk_ss = false;
-               pi->mclk_ss = false;
-               pi->dynamic_ss = true;
-       }
+       rv770_get_engine_memory_ss(rdev);
 
        pi->asi = RV770_ASI_DFLT;
        pi->pasi = CYPRESS_HASI_DFLT;
@@ -4193,8 +4176,7 @@ int ni_dpm_init(struct radeon_device *rdev)
 
        pi->dynamic_pcie_gen2 = true;
 
-       if (pi->gfx_clock_gating &&
-           (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
+       if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
                pi->thermal_protection = true;
        else
                pi->thermal_protection = false;
index fe24a93542ecdb654c5a5597611ff76ff341ef00..22421bc80c0d0d0d33c8b87ef9922c3cf982fc15 100644 (file)
 #define VM_CONTEXT1_CNTL2                              0x1434
 #define VM_INVALIDATE_REQUEST                          0x1478
 #define VM_INVALIDATE_RESPONSE                         0x147c
+#define        VM_CONTEXT1_PROTECTION_FAULT_ADDR               0x14FC
+#define        VM_CONTEXT1_PROTECTION_FAULT_STATUS             0x14DC
+#define                PROTECTIONS_MASK                        (0xf << 0)
+#define                PROTECTIONS_SHIFT                       0
+               /* bit 0: range
+                * bit 2: pde0
+                * bit 3: valid
+                * bit 4: read
+                * bit 5: write
+                */
+#define                MEMORY_CLIENT_ID_MASK                   (0xff << 12)
+#define                MEMORY_CLIENT_ID_SHIFT                  12
+#define                MEMORY_CLIENT_RW_MASK                   (1 << 24)
+#define                MEMORY_CLIENT_RW_SHIFT                  24
+#define                FAULT_VMID_MASK                         (0x7 << 25)
+#define                FAULT_VMID_SHIFT                        25
 #define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR      0x1518
 #define VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR      0x151c
 #define        VM_CONTEXT0_PAGE_TABLE_BASE_ADDR                0x153C
index c9affefd79f63341d30992331b09242d52aa8fe7..75349cdaa84b181186d6dee878d582437521a96a 100644 (file)
@@ -39,7 +39,6 @@
 #include "atom.h"
 
 #include <linux/firmware.h>
-#include <linux/platform_device.h>
 #include <linux/module.h>
 
 #include "r100_reg_safe.h"
@@ -989,18 +988,11 @@ void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring)
 /* Load the microcode for the CP */
 static int r100_cp_init_microcode(struct radeon_device *rdev)
 {
-       struct platform_device *pdev;
        const char *fw_name = NULL;
        int err;
 
        DRM_DEBUG_KMS("\n");
 
-       pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
-       err = IS_ERR(pdev);
-       if (err) {
-               printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
-               return -EINVAL;
-       }
        if ((rdev->family == CHIP_R100) || (rdev->family == CHIP_RV100) ||
            (rdev->family == CHIP_RV200) || (rdev->family == CHIP_RS100) ||
            (rdev->family == CHIP_RS200)) {
@@ -1042,8 +1034,7 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)
                fw_name = FIRMWARE_R520;
        }
 
-       err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
-       platform_device_unregister(pdev);
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
        if (err) {
                printk(KERN_ERR "radeon_cp: Failed to load firmware \"%s\"\n",
                       fw_name);
index 2d3655f7f41e5a72bf898618e836cb7f816fd633..e66e7207735036e2ffab5e18f37854384595bf80 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/firmware.h>
-#include <linux/platform_device.h>
 #include <linux/module.h>
 #include <drm/drmP.h>
 #include <drm/radeon_drm.h>
@@ -2144,7 +2143,6 @@ void r600_cp_stop(struct radeon_device *rdev)
 
 int r600_init_microcode(struct radeon_device *rdev)
 {
-       struct platform_device *pdev;
        const char *chip_name;
        const char *rlc_chip_name;
        const char *smc_chip_name = "RV770";
@@ -2154,13 +2152,6 @@ int r600_init_microcode(struct radeon_device *rdev)
 
        DRM_DEBUG("\n");
 
-       pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
-       err = IS_ERR(pdev);
-       if (err) {
-               printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
-               return -EINVAL;
-       }
-
        switch (rdev->family) {
        case CHIP_R600:
                chip_name = "R600";
@@ -2272,7 +2263,7 @@ int r600_init_microcode(struct radeon_device *rdev)
        DRM_INFO("Loading %s Microcode\n", chip_name);
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
-       err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->pfp_fw->size != pfp_req_size) {
@@ -2284,7 +2275,7 @@ int r600_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
-       err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->me_fw->size != me_req_size) {
@@ -2295,7 +2286,7 @@ int r600_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
-       err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->rlc_fw->size != rlc_req_size) {
@@ -2307,10 +2298,14 @@ int r600_init_microcode(struct radeon_device *rdev)
 
        if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) {
                snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name);
-               err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev);
-               if (err)
-                       goto out;
-               if (rdev->smc_fw->size != smc_req_size) {
+               err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
+               if (err) {
+                       printk(KERN_ERR
+                              "smc: error loading firmware \"%s\"\n",
+                              fw_name);
+                       release_firmware(rdev->smc_fw);
+                       rdev->smc_fw = NULL;
+               } else if (rdev->smc_fw->size != smc_req_size) {
                        printk(KERN_ERR
                               "smc: Bogus length %zu in firmware \"%s\"\n",
                               rdev->smc_fw->size, fw_name);
@@ -2319,8 +2314,6 @@ int r600_init_microcode(struct radeon_device *rdev)
        }
 
 out:
-       platform_device_unregister(pdev);
-
        if (err) {
                if (err != -EINVAL)
                        printk(KERN_ERR
@@ -2708,12 +2701,29 @@ int r600_uvd_rbc_start(struct radeon_device *rdev)
        return 0;
 }
 
-void r600_uvd_rbc_stop(struct radeon_device *rdev)
+void r600_uvd_stop(struct radeon_device *rdev)
 {
        struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
 
        /* force RBC into idle state */
        WREG32(UVD_RBC_RB_CNTL, 0x11010101);
+
+       /* Stall UMC and register bus before resetting VCPU */
+       WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
+       WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
+       mdelay(1);
+
+       /* put VCPU into reset */
+       WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET);
+       mdelay(5);
+
+       /* disable VCPU clock */
+       WREG32(UVD_VCPU_CNTL, 0x0);
+
+       /* Unstall UMC and register bus */
+       WREG32_P(UVD_LMI_CTRL2, 0, ~(1 << 8));
+       WREG32_P(UVD_RB_ARB_CTRL, 0, ~(1 << 3));
+
        ring->ready = false;
 }
 
@@ -2733,6 +2743,11 @@ int r600_uvd_init(struct radeon_device *rdev)
        /* disable interupt */
        WREG32_P(UVD_MASTINT_EN, 0, ~(1 << 1));
 
+       /* Stall UMC and register bus before resetting VCPU */
+       WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
+       WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
+       mdelay(1);
+
        /* put LMI, VCPU, RBC etc... into reset */
        WREG32(UVD_SOFT_RESET, LMI_SOFT_RESET | VCPU_SOFT_RESET |
               LBSI_SOFT_RESET | RBC_SOFT_RESET | CSM_SOFT_RESET |
@@ -2762,10 +2777,6 @@ int r600_uvd_init(struct radeon_device *rdev)
        WREG32(UVD_MPC_SET_ALU, 0);
        WREG32(UVD_MPC_SET_MUX, 0x88);
 
-       /* Stall UMC */
-       WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
-       WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
-
        /* take all subblocks out of reset, except VCPU */
        WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET);
        mdelay(5);
@@ -3019,7 +3030,7 @@ void r600_uvd_fence_emit(struct radeon_device *rdev,
                         struct radeon_fence *fence)
 {
        struct radeon_ring *ring = &rdev->ring[fence->ring];
-       uint32_t addr = rdev->fence_drv[fence->ring].gpu_addr;
+       uint64_t addr = rdev->fence_drv[fence->ring].gpu_addr;
 
        radeon_ring_write(ring, PACKET0(UVD_CONTEXT_ID, 0));
        radeon_ring_write(ring, fence->seq);
@@ -3144,6 +3155,90 @@ int r600_copy_blit(struct radeon_device *rdev,
        return 0;
 }
 
+/**
+ * r600_copy_cpdma - copy pages using the CP DMA engine
+ *
+ * @rdev: radeon_device pointer
+ * @src_offset: src GPU address
+ * @dst_offset: dst GPU address
+ * @num_gpu_pages: number of GPU pages to xfer
+ * @fence: radeon fence object
+ *
+ * Copy GPU paging using the CP DMA engine (r6xx+).
+ * Used by the radeon ttm implementation to move pages if
+ * registered as the asic copy callback.
+ */
+int r600_copy_cpdma(struct radeon_device *rdev,
+                   uint64_t src_offset, uint64_t dst_offset,
+                   unsigned num_gpu_pages,
+                   struct radeon_fence **fence)
+{
+       struct radeon_semaphore *sem = NULL;
+       int ring_index = rdev->asic->copy.blit_ring_index;
+       struct radeon_ring *ring = &rdev->ring[ring_index];
+       u32 size_in_bytes, cur_size_in_bytes, tmp;
+       int i, num_loops;
+       int r = 0;
+
+       r = radeon_semaphore_create(rdev, &sem);
+       if (r) {
+               DRM_ERROR("radeon: moving bo (%d).\n", r);
+               return r;
+       }
+
+       size_in_bytes = (num_gpu_pages << RADEON_GPU_PAGE_SHIFT);
+       num_loops = DIV_ROUND_UP(size_in_bytes, 0x1fffff);
+       r = radeon_ring_lock(rdev, ring, num_loops * 6 + 24);
+       if (r) {
+               DRM_ERROR("radeon: moving bo (%d).\n", r);
+               radeon_semaphore_free(rdev, &sem, NULL);
+               return r;
+       }
+
+       if (radeon_fence_need_sync(*fence, ring->idx)) {
+               radeon_semaphore_sync_rings(rdev, sem, (*fence)->ring,
+                                           ring->idx);
+               radeon_fence_note_sync(*fence, ring->idx);
+       } else {
+               radeon_semaphore_free(rdev, &sem, NULL);
+       }
+
+       radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
+       radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
+       radeon_ring_write(ring, WAIT_3D_IDLE_bit);
+       for (i = 0; i < num_loops; i++) {
+               cur_size_in_bytes = size_in_bytes;
+               if (cur_size_in_bytes > 0x1fffff)
+                       cur_size_in_bytes = 0x1fffff;
+               size_in_bytes -= cur_size_in_bytes;
+               tmp = upper_32_bits(src_offset) & 0xff;
+               if (size_in_bytes == 0)
+                       tmp |= PACKET3_CP_DMA_CP_SYNC;
+               radeon_ring_write(ring, PACKET3(PACKET3_CP_DMA, 4));
+               radeon_ring_write(ring, src_offset & 0xffffffff);
+               radeon_ring_write(ring, tmp);
+               radeon_ring_write(ring, dst_offset & 0xffffffff);
+               radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xff);
+               radeon_ring_write(ring, cur_size_in_bytes);
+               src_offset += cur_size_in_bytes;
+               dst_offset += cur_size_in_bytes;
+       }
+       radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
+       radeon_ring_write(ring, (WAIT_UNTIL - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
+       radeon_ring_write(ring, WAIT_CP_DMA_IDLE_bit);
+
+       r = radeon_fence_emit(rdev, fence, ring->idx);
+       if (r) {
+               radeon_ring_unlock_undo(rdev, ring);
+               return r;
+       }
+
+       radeon_ring_unlock_commit(rdev, ring);
+       radeon_semaphore_free(rdev, &sem, *fence);
+
+       return r;
+}
+
 /**
  * r600_copy_dma - copy pages using the DMA engine
  *
@@ -3239,6 +3334,8 @@ static int r600_startup(struct radeon_device *rdev)
        /* enable pcie gen2 link */
        r600_pcie_gen2_enable(rdev);
 
+       r600_mc_program(rdev);
+
        if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
                r = r600_init_microcode(rdev);
                if (r) {
@@ -3251,7 +3348,6 @@ static int r600_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r600_mc_program(rdev);
        if (rdev->flags & RADEON_IS_AGP) {
                r600_agp_enable(rdev);
        } else {
index b88f54b134abaa838b44dc0a5e614df2c06f3be5..e5c860f4ccbe4f7641745c018b6dda9650a4a5e7 100644 (file)
@@ -278,9 +278,9 @@ bool r600_dynamicpm_enabled(struct radeon_device *rdev)
 void r600_enable_sclk_control(struct radeon_device *rdev, bool enable)
 {
        if (enable)
-               WREG32_P(GENERAL_PWRMGT, 0, ~SCLK_PWRMGT_OFF);
+               WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF);
        else
-               WREG32_P(GENERAL_PWRMGT, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
+               WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
 }
 
 void r600_enable_mclk_control(struct radeon_device *rdev, bool enable)
index e73b2a73494a55675f63c9f2aea785822c79145d..f264df5470f7fd6bd0ba0cabf3d31e7396829c2b 100644 (file)
@@ -226,10 +226,29 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
        struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
        u32 base_rate = 24000;
+       u32 max_ratio = clock / base_rate;
+       u32 dto_phase;
+       u32 dto_modulo = clock;
+       u32 wallclock_ratio;
+       u32 dto_cntl;
 
        if (!dig || !dig->afmt)
                return;
 
+       if (max_ratio >= 8) {
+               dto_phase = 192 * 1000;
+               wallclock_ratio = 3;
+       } else if (max_ratio >= 4) {
+               dto_phase = 96 * 1000;
+               wallclock_ratio = 2;
+       } else if (max_ratio >= 2) {
+               dto_phase = 48 * 1000;
+               wallclock_ratio = 1;
+       } else {
+               dto_phase = 24 * 1000;
+               wallclock_ratio = 0;
+       }
+
        /* there are two DTOs selected by DCCG_AUDIO_DTO_SELECT.
         * doesn't matter which one you use.  Just use the first one.
         */
@@ -242,9 +261,21 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
                /* according to the reg specs, this should DCE3.2 only, but in
                 * practice it seems to cover DCE3.0 as well.
                 */
-               WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100);
-               WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100);
-               WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */
+               if (dig->dig_encoder == 0) {
+                       dto_cntl = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
+                       dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
+                       WREG32(DCCG_AUDIO_DTO0_CNTL, dto_cntl);
+                       WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
+                       WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo);
+                       WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */
+               } else {
+                       dto_cntl = RREG32(DCCG_AUDIO_DTO1_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
+                       dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
+                       WREG32(DCCG_AUDIO_DTO1_CNTL, dto_cntl);
+                       WREG32(DCCG_AUDIO_DTO1_PHASE, dto_phase);
+                       WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo);
+                       WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
+               }
        } else {
                /* according to the reg specs, this should be DCE2.0 and DCE3.0 */
                WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) |
@@ -266,6 +297,9 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
        uint32_t offset;
        ssize_t err;
 
+       if (!dig || !dig->afmt)
+               return;
+
        /* Silent, r600_hdmi_enable will raise WARN for us */
        if (!dig->afmt->enabled)
                return;
@@ -448,6 +482,9 @@ void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
        struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
        u32 hdmi = HDMI0_ERROR_ACK;
 
+       if (!dig || !dig->afmt)
+               return;
+
        /* Silent, r600_hdmi_enable will raise WARN for us */
        if (enable && dig->afmt->enabled)
                return;
index f1b3084d8f5162d56515992facc21842a9e15fea..7c780839a7f43858395bdb4ec309bc6a9b1e37fd 100644 (file)
 #define                L2_BUSY                                         (1 << 0)
 
 #define        WAIT_UNTIL                                      0x8040
+#define         WAIT_CP_DMA_IDLE_bit                            (1 << 8)
 #define         WAIT_2D_IDLE_bit                                (1 << 14)
 #define         WAIT_3D_IDLE_bit                                (1 << 15)
 #define         WAIT_2D_IDLECLEAN_bit                           (1 << 16)
 #define DCCG_AUDIO_DTO0_LOAD              0x051c
 #       define DTO_LOAD                   (1 << 31)
 #define DCCG_AUDIO_DTO0_CNTL              0x0520
+#       define DCCG_AUDIO_DTO_WALLCLOCK_RATIO(x) (((x) & 7) << 0)
+#       define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK 7
+#       define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_SHIFT 0
 
 #define DCCG_AUDIO_DTO1_PHASE             0x0524
 #define DCCG_AUDIO_DTO1_MODULE            0x0528
index 9b7025d02cd0cf42504d08fca87d6daf640c876d..9f19259667dfa71e254052735be72ce0f14e75d9 100644 (file)
@@ -97,6 +97,7 @@ extern int radeon_msi;
 extern int radeon_lockup_timeout;
 extern int radeon_fastfb;
 extern int radeon_dpm;
+extern int radeon_aspm;
 
 /*
  * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -455,6 +456,7 @@ struct radeon_sa_manager {
        uint64_t                gpu_addr;
        void                    *cpu_ptr;
        uint32_t                domain;
+       uint32_t                align;
 };
 
 struct radeon_sa_bo;
@@ -783,6 +785,11 @@ struct radeon_mec {
 /* number of entries in page table */
 #define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
 
+/* PTBs (Page Table Blocks) need to be aligned to 32K */
+#define RADEON_VM_PTB_ALIGN_SIZE   32768
+#define RADEON_VM_PTB_ALIGN_MASK (RADEON_VM_PTB_ALIGN_SIZE - 1)
+#define RADEON_VM_PTB_ALIGN(a) (((a) + RADEON_VM_PTB_ALIGN_MASK) & ~RADEON_VM_PTB_ALIGN_MASK)
+
 struct radeon_vm {
        struct list_head                list;
        struct list_head                va;
@@ -1460,6 +1467,7 @@ struct radeon_uvd {
        struct radeon_bo        *vcpu_bo;
        void                    *cpu_addr;
        uint64_t                gpu_addr;
+       void                    *saved_bo;
        atomic_t                handles[RADEON_MAX_UVD_HANDLES];
        struct drm_file         *filp[RADEON_MAX_UVD_HANDLES];
        struct delayed_work     idle_work;
@@ -2054,10 +2062,10 @@ struct radeon_device {
        const struct firmware *rlc_fw;  /* r6/700 RLC firmware */
        const struct firmware *mc_fw;   /* NI MC firmware */
        const struct firmware *ce_fw;   /* SI CE firmware */
-       const struct firmware *uvd_fw;  /* UVD firmware */
        const struct firmware *mec_fw;  /* CIK MEC firmware */
        const struct firmware *sdma_fw; /* CIK SDMA firmware */
        const struct firmware *smc_fw;  /* SMC firmware */
+       const struct firmware *uvd_fw;  /* UVD firmware */
        struct r600_blit r600_blit;
        struct r600_vram_scratch vram_scratch;
        int msi_enabled; /* msi enabled */
@@ -2087,6 +2095,8 @@ struct radeon_device {
        /* ACPI interface */
        struct radeon_atif              atif;
        struct radeon_atcs              atcs;
+       /* srbm instance registers */
+       struct mutex                    srbm_mutex;
 };
 
 int radeon_device_init(struct radeon_device *rdev,
@@ -2153,7 +2163,7 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v);
                WREG32(reg, tmp_);                              \
        } while (0)
 #define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
-#define WREG32_OR(reg, or) WREG32_P(reg, or, ~or)
+#define WREG32_OR(reg, or) WREG32_P(reg, or, ~(or))
 #define WREG32_PLL_P(reg, val, mask)                           \
        do {                                                    \
                uint32_t tmp_ = RREG32_PLL(reg);                \
index 097077499cc643751211a989449468a93dc1fa36..f8f8b3113dddd140bb6bc51455dc86307cc267e3 100644 (file)
@@ -1026,8 +1026,8 @@ static struct radeon_asic r600_asic = {
                .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
                .dma = &r600_copy_dma,
                .dma_ring_index = R600_RING_TYPE_DMA_INDEX,
-               .copy = &r600_copy_dma,
-               .copy_ring_index = R600_RING_TYPE_DMA_INDEX,
+               .copy = &r600_copy_cpdma,
+               .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
        },
        .surface = {
                .set_reg = r600_set_surface_reg,
@@ -1119,8 +1119,8 @@ static struct radeon_asic rv6xx_asic = {
                .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
                .dma = &r600_copy_dma,
                .dma_ring_index = R600_RING_TYPE_DMA_INDEX,
-               .copy = &r600_copy_dma,
-               .copy_ring_index = R600_RING_TYPE_DMA_INDEX,
+               .copy = &r600_copy_cpdma,
+               .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
        },
        .surface = {
                .set_reg = r600_set_surface_reg,
@@ -1161,6 +1161,7 @@ static struct radeon_asic rv6xx_asic = {
                .get_mclk = &rv6xx_dpm_get_mclk,
                .print_power_state = &rv6xx_dpm_print_power_state,
                .debugfs_print_current_performance_level = &rv6xx_dpm_debugfs_print_current_performance_level,
+               .force_performance_level = &rv6xx_dpm_force_performance_level,
        },
        .pflip = {
                .pre_page_flip = &rs600_pre_page_flip,
@@ -1229,8 +1230,8 @@ static struct radeon_asic rs780_asic = {
                .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
                .dma = &r600_copy_dma,
                .dma_ring_index = R600_RING_TYPE_DMA_INDEX,
-               .copy = &r600_copy_dma,
-               .copy_ring_index = R600_RING_TYPE_DMA_INDEX,
+               .copy = &r600_copy_cpdma,
+               .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
        },
        .surface = {
                .set_reg = r600_set_surface_reg,
@@ -1270,6 +1271,7 @@ static struct radeon_asic rs780_asic = {
                .get_sclk = &rs780_dpm_get_sclk,
                .get_mclk = &rs780_dpm_get_mclk,
                .print_power_state = &rs780_dpm_print_power_state,
+               .debugfs_print_current_performance_level = &rs780_dpm_debugfs_print_current_performance_level,
        },
        .pflip = {
                .pre_page_flip = &rs600_pre_page_flip,
index 45d0693cddd5cc2493abc7247d78a1e1651f4d10..3d61d5aac18ff4e01d3f89934807d9abb261dcdc 100644 (file)
@@ -340,6 +340,9 @@ int r600_uvd_ring_test(struct radeon_device *rdev, struct radeon_ring *ring);
 int r600_copy_blit(struct radeon_device *rdev,
                   uint64_t src_offset, uint64_t dst_offset,
                   unsigned num_gpu_pages, struct radeon_fence **fence);
+int r600_copy_cpdma(struct radeon_device *rdev,
+                   uint64_t src_offset, uint64_t dst_offset,
+                   unsigned num_gpu_pages, struct radeon_fence **fence);
 int r600_copy_dma(struct radeon_device *rdev,
                  uint64_t src_offset, uint64_t dst_offset,
                  unsigned num_gpu_pages, struct radeon_fence **fence);
@@ -418,6 +421,8 @@ void rv6xx_dpm_print_power_state(struct radeon_device *rdev,
                                 struct radeon_ps *ps);
 void rv6xx_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
                                                       struct seq_file *m);
+int rv6xx_dpm_force_performance_level(struct radeon_device *rdev,
+                                     enum radeon_dpm_forced_level level);
 /* rs780 dpm */
 int rs780_dpm_init(struct radeon_device *rdev);
 int rs780_dpm_enable(struct radeon_device *rdev);
@@ -430,11 +435,13 @@ u32 rs780_dpm_get_sclk(struct radeon_device *rdev, bool low);
 u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low);
 void rs780_dpm_print_power_state(struct radeon_device *rdev,
                                 struct radeon_ps *ps);
+void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
+                                                      struct seq_file *m);
 
 /* uvd */
 int r600_uvd_init(struct radeon_device *rdev);
 int r600_uvd_rbc_start(struct radeon_device *rdev);
-void r600_uvd_rbc_stop(struct radeon_device *rdev);
+void r600_uvd_stop(struct radeon_device *rdev);
 int r600_uvd_ib_test(struct radeon_device *rdev, struct radeon_ring *ring);
 void r600_uvd_fence_emit(struct radeon_device *rdev,
                         struct radeon_fence *fence);
index fbdaff55556bc4810437b0196b2a841be86a1f77..4ccd61f60eb6cd23849940c3c25ed0e9eec675fd 100644 (file)
@@ -2782,7 +2782,7 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev,
                                                             ATOM_PLL_CNTL_FLAG_PLL_POST_DIV_EN) ? true : false;
                                dividers->enable_dithen = (args.v3.ucCntlFlag &
                                                           ATOM_PLL_CNTL_FLAG_FRACTION_DISABLE) ? false : true;
-                               dividers->fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDiv);
+                               dividers->whole_fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDiv);
                                dividers->frac_fb_div = le16_to_cpu(args.v3.ulFbDiv.usFbDivFrac);
                                dividers->ref_div = args.v3.ucRefDiv;
                                dividers->vco_mode = (args.v3.ucCntlFlag &
@@ -3513,7 +3513,6 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
        u8 frev, crev, i;
        u16 data_offset, size;
        union vram_info *vram_info;
-       u8 *p;
 
        memset(mem_info, 0, sizeof(struct atom_memory_info));
 
@@ -3529,13 +3528,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
                                if (module_index < vram_info->v1_3.ucNumOfVRAMModule) {
                                        ATOM_VRAM_MODULE_V3 *vram_module =
                                                (ATOM_VRAM_MODULE_V3 *)vram_info->v1_3.aVramInfo;
-                                       p = (u8 *)vram_info->v1_3.aVramInfo;
 
                                        for (i = 0; i < module_index; i++) {
-                                               vram_module = (ATOM_VRAM_MODULE_V3 *)p;
                                                if (le16_to_cpu(vram_module->usSize) == 0)
                                                        return -EINVAL;
-                                               p += le16_to_cpu(vram_module->usSize);
+                                               vram_module = (ATOM_VRAM_MODULE_V3 *)
+                                                       ((u8 *)vram_module + le16_to_cpu(vram_module->usSize));
                                        }
                                        mem_info->mem_vendor = vram_module->asMemory.ucMemoryVenderID & 0xf;
                                        mem_info->mem_type = vram_module->asMemory.ucMemoryType & 0xf0;
@@ -3547,13 +3545,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
                                if (module_index < vram_info->v1_4.ucNumOfVRAMModule) {
                                        ATOM_VRAM_MODULE_V4 *vram_module =
                                                (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo;
-                                       p = (u8 *)vram_info->v1_4.aVramInfo;
 
                                        for (i = 0; i < module_index; i++) {
-                                               vram_module = (ATOM_VRAM_MODULE_V4 *)p;
                                                if (le16_to_cpu(vram_module->usModuleSize) == 0)
                                                        return -EINVAL;
-                                               p += le16_to_cpu(vram_module->usModuleSize);
+                                               vram_module = (ATOM_VRAM_MODULE_V4 *)
+                                                       ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize));
                                        }
                                        mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf;
                                        mem_info->mem_type = vram_module->ucMemoryType & 0xf0;
@@ -3572,13 +3569,12 @@ int radeon_atom_get_memory_info(struct radeon_device *rdev,
                                if (module_index < vram_info->v2_1.ucNumOfVRAMModule) {
                                        ATOM_VRAM_MODULE_V7 *vram_module =
                                                (ATOM_VRAM_MODULE_V7 *)vram_info->v2_1.aVramInfo;
-                                       p = (u8 *)vram_info->v2_1.aVramInfo;
 
                                        for (i = 0; i < module_index; i++) {
-                                               vram_module = (ATOM_VRAM_MODULE_V7 *)p;
                                                if (le16_to_cpu(vram_module->usModuleSize) == 0)
                                                        return -EINVAL;
-                                               p += le16_to_cpu(vram_module->usModuleSize);
+                                               vram_module = (ATOM_VRAM_MODULE_V7 *)
+                                                       ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize));
                                        }
                                        mem_info->mem_vendor = vram_module->ucMemoryVenderID & 0xf;
                                        mem_info->mem_type = vram_module->ucMemoryType & 0xf0;
@@ -3628,21 +3624,19 @@ int radeon_atom_get_mclk_range_table(struct radeon_device *rdev,
                                if (module_index < vram_info->v1_4.ucNumOfVRAMModule) {
                                        ATOM_VRAM_MODULE_V4 *vram_module =
                                                (ATOM_VRAM_MODULE_V4 *)vram_info->v1_4.aVramInfo;
-                                       ATOM_MEMORY_TIMING_FORMAT *format;
-                                       p = (u8 *)vram_info->v1_4.aVramInfo;
 
                                        for (i = 0; i < module_index; i++) {
-                                               vram_module = (ATOM_VRAM_MODULE_V4 *)p;
                                                if (le16_to_cpu(vram_module->usModuleSize) == 0)
                                                        return -EINVAL;
-                                               p += le16_to_cpu(vram_module->usModuleSize);
+                                               vram_module = (ATOM_VRAM_MODULE_V4 *)
+                                                       ((u8 *)vram_module + le16_to_cpu(vram_module->usModuleSize));
                                        }
                                        mclk_range_table->num_entries = (u8)
-                                               ((vram_module->usModuleSize - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) /
+                                               ((le16_to_cpu(vram_module->usModuleSize) - offsetof(ATOM_VRAM_MODULE_V4, asMemTiming)) /
                                                 mem_timing_size);
-                                       p = (u8 *)vram_module->asMemTiming;
+                                       p = (u8 *)&vram_module->asMemTiming[0];
                                        for (i = 0; i < mclk_range_table->num_entries; i++) {
-                                               format = (ATOM_MEMORY_TIMING_FORMAT *)p;
+                                               ATOM_MEMORY_TIMING_FORMAT *format = (ATOM_MEMORY_TIMING_FORMAT *)p;
                                                mclk_range_table->mclk[i] = le32_to_cpu(format->ulClkRange);
                                                p += mem_timing_size;
                                        }
@@ -3705,17 +3699,21 @@ int radeon_atom_init_mc_reg_table(struct radeon_device *rdev,
                                                (ATOM_MEMORY_SETTING_DATA_BLOCK *)
                                                ((u8 *)reg_block + (2 * sizeof(u16)) +
                                                 le16_to_cpu(reg_block->usRegIndexTblSize));
+                                       ATOM_INIT_REG_INDEX_FORMAT *format = &reg_block->asRegIndexBuf[0];
                                        num_entries = (u8)((le16_to_cpu(reg_block->usRegIndexTblSize)) /
                                                           sizeof(ATOM_INIT_REG_INDEX_FORMAT)) - 1;
                                        if (num_entries > VBIOS_MC_REGISTER_ARRAY_SIZE)
                                                return -EINVAL;
-                                       while (!(reg_block->asRegIndexBuf[i].ucPreRegDataLength & ACCESS_PLACEHOLDER) &&
-                                             (i < num_entries)) {
+                                       while (i < num_entries) {
+                                               if (format->ucPreRegDataLength & ACCESS_PLACEHOLDER)
+                                                       break;
                                                reg_table->mc_reg_address[i].s1 =
-                                                       (u16)(le16_to_cpu(reg_block->asRegIndexBuf[i].usRegIndex));
+                                                       (u16)(le16_to_cpu(format->usRegIndex));
                                                reg_table->mc_reg_address[i].pre_reg_data =
-                                                       (u8)(reg_block->asRegIndexBuf[i].ucPreRegDataLength);
+                                                       (u8)(format->ucPreRegDataLength);
                                                i++;
+                                               format = (ATOM_INIT_REG_INDEX_FORMAT *)
+                                                       ((u8 *)format + sizeof(ATOM_INIT_REG_INDEX_FORMAT));
                                        }
                                        reg_table->last = i;
                                        while ((*(u32 *)reg_data != END_OF_REG_DATA_BLOCK) &&
index 78edadc9e86b22b8ec64d5877f4b98365cafcffd..68ce360560190af6505856452658e450d3f6878a 100644 (file)
@@ -147,7 +147,7 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
                                         enum radeon_combios_table_offset table)
 {
        struct radeon_device *rdev = dev->dev_private;
-       int rev;
+       int rev, size;
        uint16_t offset = 0, check_offset;
 
        if (!rdev->bios)
@@ -156,174 +156,106 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
        switch (table) {
                /* absolute offset tables */
        case COMBIOS_ASIC_INIT_1_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0xc);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0xc;
                break;
        case COMBIOS_BIOS_SUPPORT_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x14);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x14;
                break;
        case COMBIOS_DAC_PROGRAMMING_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x2a);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x2a;
                break;
        case COMBIOS_MAX_COLOR_DEPTH_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x2c);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x2c;
                break;
        case COMBIOS_CRTC_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x2e);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x2e;
                break;
        case COMBIOS_PLL_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x30);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x30;
                break;
        case COMBIOS_TV_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x32);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x32;
                break;
        case COMBIOS_DFP_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x34);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x34;
                break;
        case COMBIOS_HW_CONFIG_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x36);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x36;
                break;
        case COMBIOS_MULTIMEDIA_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x38);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x38;
                break;
        case COMBIOS_TV_STD_PATCH_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x3e);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x3e;
                break;
        case COMBIOS_LCD_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x40);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x40;
                break;
        case COMBIOS_MOBILE_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x42);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x42;
                break;
        case COMBIOS_PLL_INIT_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x46);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x46;
                break;
        case COMBIOS_MEM_CONFIG_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x48);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x48;
                break;
        case COMBIOS_SAVE_MASK_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x4a);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x4a;
                break;
        case COMBIOS_HARDCODED_EDID_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x4c);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x4c;
                break;
        case COMBIOS_ASIC_INIT_2_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x4e);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x4e;
                break;
        case COMBIOS_CONNECTOR_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x50);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x50;
                break;
        case COMBIOS_DYN_CLK_1_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x52);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x52;
                break;
        case COMBIOS_RESERVED_MEM_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x54);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x54;
                break;
        case COMBIOS_EXT_TMDS_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x58);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x58;
                break;
        case COMBIOS_MEM_CLK_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x5a);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x5a;
                break;
        case COMBIOS_EXT_DAC_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x5c);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x5c;
                break;
        case COMBIOS_MISC_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x5e);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x5e;
                break;
        case COMBIOS_CRT_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x60);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x60;
                break;
        case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x62);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x62;
                break;
        case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x64);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x64;
                break;
        case COMBIOS_FAN_SPEED_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x66);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x66;
                break;
        case COMBIOS_OVERDRIVE_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x68);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x68;
                break;
        case COMBIOS_OEM_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x6a);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x6a;
                break;
        case COMBIOS_DYN_CLK_2_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x6c);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x6c;
                break;
        case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x6e);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x6e;
                break;
        case COMBIOS_I2C_INFO_TABLE:
-               check_offset = RBIOS16(rdev->bios_header_start + 0x70);
-               if (check_offset)
-                       offset = check_offset;
+               check_offset = 0x70;
                break;
                /* relative offset tables */
        case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */
@@ -439,11 +371,16 @@ static uint16_t combios_get_table_offset(struct drm_device *dev,
                }
                break;
        default:
+               check_offset = 0;
                break;
        }
 
-       return offset;
+       size = RBIOS8(rdev->bios_header_start + 0x6);
+       /* check absolute offset tables */
+       if (table < COMBIOS_ASIC_INIT_3_TABLE && check_offset && check_offset < size)
+               offset = RBIOS16(rdev->bios_header_start + check_offset);
 
+       return offset;
 }
 
 bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
@@ -965,16 +902,22 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
                        dac = RBIOS8(dac_info + 0x3) & 0xf;
                        p_dac->ps2_pdac_adj = (bg << 8) | (dac);
                }
-               /* if the values are all zeros, use the table */
-               if (p_dac->ps2_pdac_adj)
+               /* if the values are zeros, use the table */
+               if ((dac == 0) || (bg == 0))
+                       found = 0;
+               else
                        found = 1;
        }
 
        /* quirks */
+       /* Radeon 7000 (RV100) */
+       if (((dev->pdev->device == 0x5159) &&
+           (dev->pdev->subsystem_vendor == 0x174B) &&
+           (dev->pdev->subsystem_device == 0x7c28)) ||
        /* Radeon 9100 (R200) */
-       if ((dev->pdev->device == 0x514D) &&
+          ((dev->pdev->device == 0x514D) &&
            (dev->pdev->subsystem_vendor == 0x174B) &&
-           (dev->pdev->subsystem_device == 0x7149)) {
+           (dev->pdev->subsystem_device == 0x7149))) {
                /* vbios value is bad, use the default */
                found = 0;
        }
index 82335e38ec4f268e05f9d4bc1cbd875eae8523a5..63398ae1dbf51fb682fe7e51623de255c58ae0c7 100644 (file)
@@ -1163,6 +1163,7 @@ int radeon_device_init(struct radeon_device *rdev,
        mutex_init(&rdev->gem.mutex);
        mutex_init(&rdev->pm.mutex);
        mutex_init(&rdev->gpu_clock_mutex);
+       mutex_init(&rdev->srbm_mutex);
        init_rwsem(&rdev->pm.mclk_lock);
        init_rwsem(&rdev->exclusive_lock);
        init_waitqueue_head(&rdev->irq.vblank_queue);
@@ -1519,6 +1520,7 @@ int radeon_gpu_reset(struct radeon_device *rdev)
        radeon_save_bios_scratch_regs(rdev);
        /* block TTM */
        resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
+       radeon_pm_suspend(rdev);
        radeon_suspend(rdev);
 
        for (i = 0; i < RADEON_NUM_RINGS; ++i) {
@@ -1564,6 +1566,7 @@ retry:
                }
        }
 
+       radeon_pm_resume(rdev);
        drm_helper_resume_force_mode(rdev->ddev);
 
        ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched);
index e5419b3501708ead90d8f9a82e984e37adc60e6d..29876b1be8ecae78b15bc8690804307c15885f12 100644 (file)
@@ -167,6 +167,7 @@ int radeon_msi = -1;
 int radeon_lockup_timeout = 10000;
 int radeon_fastfb = 0;
 int radeon_dpm = -1;
+int radeon_aspm = -1;
 
 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
 module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -225,6 +226,9 @@ module_param_named(fastfb, radeon_fastfb, int, 0444);
 MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)");
 module_param_named(dpm, radeon_dpm, int, 0444);
 
+MODULE_PARM_DESC(aspm, "ASPM support (1 = enable, 0 = disable, -1 = auto)");
+module_param_named(aspm, radeon_aspm, int, 0444);
+
 static struct pci_device_id pciidlist[] = {
        radeon_PCI_IDS
 };
index 43ec4a401f077809371e0360f22aa7f10c21af3b..b990b1a2bd50af523e93a7715050a534ba84d987 100644 (file)
@@ -207,7 +207,6 @@ void radeon_gart_table_vram_free(struct radeon_device *rdev)
        if (rdev->gart.robj == NULL) {
                return;
        }
-       radeon_gart_table_vram_unpin(rdev);
        radeon_bo_unref(&rdev->gart.robj);
 }
 
@@ -467,6 +466,7 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
                size *= 2;
                r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager,
                                              RADEON_GPU_PAGE_ALIGN(size),
+                                             RADEON_VM_PTB_ALIGN_SIZE,
                                              RADEON_GEM_DOMAIN_VRAM);
                if (r) {
                        dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n",
@@ -620,10 +620,10 @@ int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm)
        }
 
 retry:
-       pd_size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev));
+       pd_size = radeon_vm_directory_size(rdev);
        r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
                             &vm->page_directory, pd_size,
-                            RADEON_GPU_PAGE_SIZE, false);
+                            RADEON_VM_PTB_ALIGN_SIZE, false);
        if (r == -ENOMEM) {
                r = radeon_vm_evict(rdev, vm);
                if (r)
index bcdefd1dcd43f7b7276a78947e938e86e9dcd2bf..081886b0642da479033bdc1937b0fdbc8480eb5c 100644 (file)
@@ -260,10 +260,6 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
 {
        int r = 0;
 
-       INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
-       INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
-       INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
-
        spin_lock_init(&rdev->irq.lock);
        r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
        if (r) {
@@ -285,6 +281,11 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
                rdev->irq.installed = false;
                return r;
        }
+
+       INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
+       INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
+       INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
+
        DRM_INFO("radeon: irq initialized.\n");
        return 0;
 }
@@ -304,8 +305,8 @@ void radeon_irq_kms_fini(struct radeon_device *rdev)
                rdev->irq.installed = false;
                if (rdev->msi_enabled)
                        pci_disable_msi(rdev->pdev);
+               flush_work(&rdev->hotplug_work);
        }
-       flush_work(&rdev->hotplug_work);
 }
 
 /**
index 0219d263e2df81c4427a3cc94c429b27b7853f72..2020bf4a38302385c5c815d0d1a1d19407d53ab3 100644 (file)
@@ -377,6 +377,7 @@ int radeon_bo_list_validate(struct ww_acquire_ctx *ticket,
                                        domain = lobj->alt_domain;
                                        goto retry;
                                }
+                               ttm_eu_backoff_reservation(ticket, head);
                                return r;
                        }
                }
index 91519a5622b4358b6fa82e24698427bb0278a554..49c82c4800134aa5500c8999c1e2e7c196330d2c 100644 (file)
@@ -174,7 +174,7 @@ static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo)
 
 extern int radeon_sa_bo_manager_init(struct radeon_device *rdev,
                                     struct radeon_sa_manager *sa_manager,
-                                    unsigned size, u32 domain);
+                                    unsigned size, u32 align, u32 domain);
 extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev,
                                      struct radeon_sa_manager *sa_manager);
 extern int radeon_sa_bo_manager_start(struct radeon_device *rdev,
index f374c467aacaf57c9a46c7c655250ef91a44516c..c557850cd3450a5b0f363f24315d3051cb96cf3c 100644 (file)
@@ -1176,7 +1176,14 @@ int radeon_pm_init(struct radeon_device *rdev)
        case CHIP_VERDE:
        case CHIP_OLAND:
        case CHIP_HAINAN:
-               if (radeon_dpm == 1)
+               /* DPM requires the RLC, RV770+ dGPU requires SMC */
+               if (!rdev->rlc_fw)
+                       rdev->pm.pm_method = PM_METHOD_PROFILE;
+               else if ((rdev->family >= CHIP_RV770) &&
+                        (!(rdev->flags & RADEON_IS_IGP)) &&
+                        (!rdev->smc_fw))
+                       rdev->pm.pm_method = PM_METHOD_PROFILE;
+               else if (radeon_dpm == 1)
                        rdev->pm.pm_method = PM_METHOD_DPM;
                else
                        rdev->pm.pm_method = PM_METHOD_PROFILE;
index 5f1c51a776edca912da7d3e64d2f4cfd1d03c2ba..fb5ea6208970638d67240f16b0cd3947108ad624 100644 (file)
@@ -224,6 +224,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
        }
        r = radeon_sa_bo_manager_init(rdev, &rdev->ring_tmp_bo,
                                      RADEON_IB_POOL_SIZE*64*1024,
+                                     RADEON_GPU_PAGE_SIZE,
                                      RADEON_GEM_DOMAIN_GTT);
        if (r) {
                return r;
index 0abe5a9431bb0a6abecd239919ac64bb68f32d5f..f0bac68254b79a5dd31cfdc14ce80a98bca91065 100644 (file)
@@ -49,7 +49,7 @@ static void radeon_sa_bo_try_free(struct radeon_sa_manager *sa_manager);
 
 int radeon_sa_bo_manager_init(struct radeon_device *rdev,
                              struct radeon_sa_manager *sa_manager,
-                             unsigned size, u32 domain)
+                             unsigned size, u32 align, u32 domain)
 {
        int i, r;
 
@@ -57,13 +57,14 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev,
        sa_manager->bo = NULL;
        sa_manager->size = size;
        sa_manager->domain = domain;
+       sa_manager->align = align;
        sa_manager->hole = &sa_manager->olist;
        INIT_LIST_HEAD(&sa_manager->olist);
        for (i = 0; i < RADEON_NUM_RINGS; ++i) {
                INIT_LIST_HEAD(&sa_manager->flist[i]);
        }
 
-       r = radeon_bo_create(rdev, size, RADEON_GPU_PAGE_SIZE, true,
+       r = radeon_bo_create(rdev, size, align, true,
                             domain, NULL, &sa_manager->bo);
        if (r) {
                dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r);
@@ -317,7 +318,7 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
        unsigned tries[RADEON_NUM_RINGS];
        int i, r;
 
-       BUG_ON(align > RADEON_GPU_PAGE_SIZE);
+       BUG_ON(align > sa_manager->align);
        BUG_ON(size > sa_manager->size);
 
        *sa_bo = kmalloc(sizeof(struct radeon_sa_bo), GFP_KERNEL);
index 41efcec28cd806620961505380e34860644b1f3d..b79f4f5cdd626108c8790394cc6e57ddd9b27bce 100644 (file)
@@ -56,20 +56,12 @@ static void radeon_uvd_idle_work_handler(struct work_struct *work);
 
 int radeon_uvd_init(struct radeon_device *rdev)
 {
-       struct platform_device *pdev;
        unsigned long bo_size;
        const char *fw_name;
        int i, r;
 
        INIT_DELAYED_WORK(&rdev->uvd.idle_work, radeon_uvd_idle_work_handler);
 
-       pdev = platform_device_register_simple("radeon_uvd", 0, NULL, 0);
-       r = IS_ERR(pdev);
-       if (r) {
-               dev_err(rdev->dev, "radeon_uvd: Failed to register firmware\n");
-               return -EINVAL;
-       }
-
        switch (rdev->family) {
        case CHIP_RV710:
        case CHIP_RV730:
@@ -112,16 +104,13 @@ int radeon_uvd_init(struct radeon_device *rdev)
                return -EINVAL;
        }
 
-       r = request_firmware(&rdev->uvd_fw, fw_name, &pdev->dev);
+       r = request_firmware(&rdev->uvd_fw, fw_name, rdev->dev);
        if (r) {
                dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
                        fw_name);
-               platform_device_unregister(pdev);
                return r;
        }
 
-       platform_device_unregister(pdev);
-
        bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) +
                  RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE;
        r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
@@ -131,16 +120,29 @@ int radeon_uvd_init(struct radeon_device *rdev)
                return r;
        }
 
-       r = radeon_uvd_resume(rdev);
-       if (r)
+       r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false);
+       if (r) {
+               radeon_bo_unref(&rdev->uvd.vcpu_bo);
+               dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r);
                return r;
+       }
 
-       memset(rdev->uvd.cpu_addr, 0, bo_size);
-       memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size);
+       r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM,
+                         &rdev->uvd.gpu_addr);
+       if (r) {
+               radeon_bo_unreserve(rdev->uvd.vcpu_bo);
+               radeon_bo_unref(&rdev->uvd.vcpu_bo);
+               dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r);
+               return r;
+       }
 
-       r = radeon_uvd_suspend(rdev);
-       if (r)
+       r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
+       if (r) {
+               dev_err(rdev->dev, "(%d) UVD map failed\n", r);
                return r;
+       }
+
+       radeon_bo_unreserve(rdev->uvd.vcpu_bo);
 
        for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
                atomic_set(&rdev->uvd.handles[i], 0);
@@ -151,71 +153,74 @@ int radeon_uvd_init(struct radeon_device *rdev)
 }
 
 void radeon_uvd_fini(struct radeon_device *rdev)
-{
-       radeon_uvd_suspend(rdev);
-       radeon_bo_unref(&rdev->uvd.vcpu_bo);
-}
-
-int radeon_uvd_suspend(struct radeon_device *rdev)
 {
        int r;
 
        if (rdev->uvd.vcpu_bo == NULL)
-               return 0;
+               return;
 
        r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false);
        if (!r) {
                radeon_bo_kunmap(rdev->uvd.vcpu_bo);
                radeon_bo_unpin(rdev->uvd.vcpu_bo);
-               rdev->uvd.cpu_addr = NULL;
-               if (!radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_CPU, NULL)) {
-                       radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
-               }
                radeon_bo_unreserve(rdev->uvd.vcpu_bo);
-
-               if (rdev->uvd.cpu_addr) {
-                       radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_UVD_INDEX);
-               } else {
-                       rdev->fence_drv[R600_RING_TYPE_UVD_INDEX].cpu_addr = NULL;
-               }
        }
-       return r;
+
+       radeon_bo_unref(&rdev->uvd.vcpu_bo);
+
+       release_firmware(rdev->uvd_fw);
+}
+
+int radeon_uvd_suspend(struct radeon_device *rdev)
+{
+       unsigned size;
+       void *ptr;
+       int i;
+
+       if (rdev->uvd.vcpu_bo == NULL)
+               return 0;
+
+       for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i)
+               if (atomic_read(&rdev->uvd.handles[i]))
+                       break;
+
+       if (i == RADEON_MAX_UVD_HANDLES)
+               return 0;
+
+       size = radeon_bo_size(rdev->uvd.vcpu_bo);
+       size -= rdev->uvd_fw->size;
+
+       ptr = rdev->uvd.cpu_addr;
+       ptr += rdev->uvd_fw->size;
+
+       rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+       memcpy(rdev->uvd.saved_bo, ptr, size);
+
+       return 0;
 }
 
 int radeon_uvd_resume(struct radeon_device *rdev)
 {
-       int r;
+       unsigned size;
+       void *ptr;
 
        if (rdev->uvd.vcpu_bo == NULL)
                return -EINVAL;
 
-       r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false);
-       if (r) {
-               radeon_bo_unref(&rdev->uvd.vcpu_bo);
-               dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r);
-               return r;
-       }
+       memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size);
 
-       /* Have been pin in cpu unmap unpin */
-       radeon_bo_kunmap(rdev->uvd.vcpu_bo);
-       radeon_bo_unpin(rdev->uvd.vcpu_bo);
+       size = radeon_bo_size(rdev->uvd.vcpu_bo);
+       size -= rdev->uvd_fw->size;
 
-       r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM,
-                         &rdev->uvd.gpu_addr);
-       if (r) {
-               radeon_bo_unreserve(rdev->uvd.vcpu_bo);
-               radeon_bo_unref(&rdev->uvd.vcpu_bo);
-               dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r);
-               return r;
-       }
+       ptr = rdev->uvd.cpu_addr;
+       ptr += rdev->uvd_fw->size;
 
-       r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
-       if (r) {
-               dev_err(rdev->dev, "(%d) UVD map failed\n", r);
-               return r;
-       }
-
-       radeon_bo_unreserve(rdev->uvd.vcpu_bo);
+       if (rdev->uvd.saved_bo != NULL) {
+               memcpy(ptr, rdev->uvd.saved_bo, size);
+               kfree(rdev->uvd.saved_bo);
+               rdev->uvd.saved_bo = NULL;
+       } else
+               memset(ptr, 0, size);
 
        return 0;
 }
@@ -230,8 +235,8 @@ void radeon_uvd_free_handles(struct radeon_device *rdev, struct drm_file *filp)
 {
        int i, r;
        for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
-               if (rdev->uvd.filp[i] == filp) {
-                       uint32_t handle = atomic_read(&rdev->uvd.handles[i]);
+               uint32_t handle = atomic_read(&rdev->uvd.handles[i]);
+               if (handle != 0 && rdev->uvd.filp[i] == filp) {
                        struct radeon_fence *fence;
 
                        r = radeon_uvd_get_destroy_msg(rdev,
@@ -351,9 +356,19 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
                return -EINVAL;
        }
 
+       if (bo->tbo.sync_obj) {
+               r = radeon_fence_wait(bo->tbo.sync_obj, false);
+               if (r) {
+                       DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
+                       return r;
+               }
+       }
+
        r = radeon_bo_kmap(bo, &ptr);
-       if (r)
+       if (r) {
+               DRM_ERROR("Failed mapping the UVD message (%d)!\n", r);
                return r;
+       }
 
        msg = ptr + offset;
 
@@ -379,8 +394,14 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
                radeon_bo_kunmap(bo);
                return 0;
        } else {
-               /* it's a create msg, no special handling needed */
                radeon_bo_kunmap(bo);
+
+               if (msg_type != 0) {
+                       DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
+                       return -EINVAL;
+               }
+
+               /* it's a create msg, no special handling needed */
        }
 
        /* create or decode, validate the handle */
@@ -403,7 +424,7 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
 
 static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
                               int data0, int data1,
-                              unsigned buf_sizes[])
+                              unsigned buf_sizes[], bool *has_msg_cmd)
 {
        struct radeon_cs_chunk *relocs_chunk;
        struct radeon_cs_reloc *reloc;
@@ -432,7 +453,7 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
 
        if (cmd < 0x4) {
                if ((end - start) < buf_sizes[cmd]) {
-                       DRM_ERROR("buffer to small (%d / %d)!\n",
+                       DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,
                                  (unsigned)(end - start), buf_sizes[cmd]);
                        return -EINVAL;
                }
@@ -457,9 +478,17 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
        }
 
        if (cmd == 0) {
+               if (*has_msg_cmd) {
+                       DRM_ERROR("More than one message in a UVD-IB!\n");
+                       return -EINVAL;
+               }
+               *has_msg_cmd = true;
                r = radeon_uvd_cs_msg(p, reloc->robj, offset, buf_sizes);
                if (r)
                        return r;
+       } else if (!*has_msg_cmd) {
+               DRM_ERROR("Message needed before other commands are send!\n");
+               return -EINVAL;
        }
 
        return 0;
@@ -468,7 +497,8 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
 static int radeon_uvd_cs_reg(struct radeon_cs_parser *p,
                             struct radeon_cs_packet *pkt,
                             int *data0, int *data1,
-                            unsigned buf_sizes[])
+                            unsigned buf_sizes[],
+                            bool *has_msg_cmd)
 {
        int i, r;
 
@@ -482,7 +512,8 @@ static int radeon_uvd_cs_reg(struct radeon_cs_parser *p,
                        *data1 = p->idx;
                        break;
                case UVD_GPCOM_VCPU_CMD:
-                       r = radeon_uvd_cs_reloc(p, *data0, *data1, buf_sizes);
+                       r = radeon_uvd_cs_reloc(p, *data0, *data1,
+                                               buf_sizes, has_msg_cmd);
                        if (r)
                                return r;
                        break;
@@ -503,6 +534,9 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
        struct radeon_cs_packet pkt;
        int r, data0 = 0, data1 = 0;
 
+       /* does the IB has a msg command */
+       bool has_msg_cmd = false;
+
        /* minimum buffer sizes */
        unsigned buf_sizes[] = {
                [0x00000000]    =       2048,
@@ -529,8 +563,8 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
                        return r;
                switch (pkt.type) {
                case RADEON_PACKET_TYPE0:
-                       r = radeon_uvd_cs_reg(p, &pkt, &data0,
-                                             &data1, buf_sizes);
+                       r = radeon_uvd_cs_reg(p, &pkt, &data0, &data1,
+                                             buf_sizes, &has_msg_cmd);
                        if (r)
                                return r;
                        break;
@@ -542,6 +576,12 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
                        return -EINVAL;
                }
        } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
+
+       if (!has_msg_cmd) {
+               DRM_ERROR("UVD-IBs need a msg command!\n");
+               return -EINVAL;
+       }
+
        return 0;
 }
 
index bef832a62fee54f04709e359e46becbe020b677f..d1a1ce73bd45548392deabbef5815e463a97dcd2 100644 (file)
@@ -28,6 +28,7 @@
 #include "r600_dpm.h"
 #include "rs780_dpm.h"
 #include "atom.h"
+#include <linux/seq_file.h>
 
 static struct igp_ps *rs780_get_ps(struct radeon_ps *rps)
 {
@@ -961,3 +962,27 @@ u32 rs780_dpm_get_mclk(struct radeon_device *rdev, bool low)
 
        return pi->bootup_uma_clk;
 }
+
+void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rdev,
+                                                      struct seq_file *m)
+{
+       struct radeon_ps *rps = rdev->pm.dpm.current_ps;
+       struct igp_ps *ps = rs780_get_ps(rps);
+       u32 current_fb_div = RREG32(FVTHROT_STATUS_REG0) & CURRENT_FEEDBACK_DIV_MASK;
+       u32 func_cntl = RREG32(CG_SPLL_FUNC_CNTL);
+       u32 ref_div = ((func_cntl & SPLL_REF_DIV_MASK) >> SPLL_REF_DIV_SHIFT) + 1;
+       u32 post_div = ((func_cntl & SPLL_SW_HILEN_MASK) >> SPLL_SW_HILEN_SHIFT) + 1 +
+               ((func_cntl & SPLL_SW_LOLEN_MASK) >> SPLL_SW_LOLEN_SHIFT) + 1;
+       u32 sclk = (rdev->clock.spll.reference_freq * current_fb_div) /
+               (post_div * ref_div);
+
+       seq_printf(m, "uvd    vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
+
+       /* guess based on the current sclk */
+       if (sclk < (ps->sclk_low + 500))
+               seq_printf(m, "power level 0    sclk: %u vddc_index: %d\n",
+                          ps->sclk_low, ps->min_voltage);
+       else
+               seq_printf(m, "power level 1    sclk: %u vddc_index: %d\n",
+                          ps->sclk_high, ps->max_voltage);
+}
index b1142ed1c628cb585220ac9f1779a02161c6d764..cfbe9a43d97b4064022a0bcf36dfdeeecddbcb1b 100644 (file)
@@ -28,6 +28,7 @@
 #       define SPLL_SLEEP                                (1 << 1)
 #       define SPLL_REF_DIV(x)                           ((x) << 2)
 #       define SPLL_REF_DIV_MASK                         (7 << 2)
+#       define SPLL_REF_DIV_SHIFT                        2
 #       define SPLL_FB_DIV(x)                            ((x) << 5)
 #       define SPLL_FB_DIV_MASK                          (0xff << 2)
 #       define SPLL_FB_DIV_SHIFT                         2
 #       define SPLL_PULSENUM_MASK                        (3 << 14)
 #       define SPLL_SW_HILEN(x)                          ((x) << 16)
 #       define SPLL_SW_HILEN_MASK                        (0xf << 16)
+#       define SPLL_SW_HILEN_SHIFT                       16
 #       define SPLL_SW_LOLEN(x)                          ((x) << 20)
 #       define SPLL_SW_LOLEN_MASK                        (0xf << 20)
+#       define SPLL_SW_LOLEN_SHIFT                       20
 #       define SPLL_DIVEN                                (1 << 24)
 #       define SPLL_BYPASS_EN                            (1 << 25)
 #       define SPLL_CHG_STATUS                           (1 << 29)
index 8303de267ee5deb6c08ba03e7dfb36a1e82c84aa..bdd888b4db2bbc7bf4f6f2cc718512fa999e223f 100644 (file)
@@ -819,7 +819,7 @@ static void rv6xx_program_memory_timing_parameters(struct radeon_device *rdev)
                 POWERMODE1(calculate_memory_refresh_rate(rdev,
                                                          pi->hw.sclks[R600_POWER_LEVEL_MEDIUM])) |
                 POWERMODE2(calculate_memory_refresh_rate(rdev,
-                                                         pi->hw.sclks[R600_POWER_LEVEL_MEDIUM])) |
+                                                         pi->hw.sclks[R600_POWER_LEVEL_HIGH])) |
                 POWERMODE3(calculate_memory_refresh_rate(rdev,
                                                          pi->hw.sclks[R600_POWER_LEVEL_HIGH])));
        WREG32(ARB_RFSH_RATE, arb_refresh_rate);
@@ -1182,10 +1182,10 @@ static void rv6xx_program_display_gap(struct radeon_device *rdev)
        u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
 
        tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
-       if (RREG32(AVIVO_D1CRTC_CONTROL) & AVIVO_CRTC_EN) {
+       if (rdev->pm.dpm.new_active_crtcs & 1) {
                tmp |= DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK);
                tmp |= DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE);
-       } else if (RREG32(AVIVO_D2CRTC_CONTROL) & AVIVO_CRTC_EN) {
+       } else if (rdev->pm.dpm.new_active_crtcs & 2) {
                tmp |= DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE);
                tmp |= DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK);
        } else {
@@ -1670,6 +1670,8 @@ int rv6xx_dpm_set_power_state(struct radeon_device *rdev)
        struct radeon_ps *old_ps = rdev->pm.dpm.current_ps;
        int ret;
 
+       pi->restricted_levels = 0;
+
        rv6xx_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps);
 
        rv6xx_clear_vc(rdev);
@@ -1756,6 +1758,8 @@ int rv6xx_dpm_set_power_state(struct radeon_device *rdev)
 
        rv6xx_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps);
 
+       rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
+
        return 0;
 }
 
@@ -1763,12 +1767,14 @@ void rv6xx_setup_asic(struct radeon_device *rdev)
 {
        r600_enable_acpi_pm(rdev);
 
-       if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s)
-               rv6xx_enable_l0s(rdev);
-       if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1)
-               rv6xx_enable_l1(rdev);
-       if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1)
-               rv6xx_enable_pll_sleep_in_l1(rdev);
+       if (radeon_aspm != 0) {
+               if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s)
+                       rv6xx_enable_l0s(rdev);
+               if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1)
+                       rv6xx_enable_l1(rdev);
+               if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1)
+                       rv6xx_enable_pll_sleep_in_l1(rdev);
+       }
 }
 
 void rv6xx_dpm_display_configuration_changed(struct radeon_device *rdev)
@@ -1938,9 +1944,7 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev)
 
 int rv6xx_dpm_init(struct radeon_device *rdev)
 {
-       int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
-       uint16_t data_offset, size;
-       uint8_t frev, crev;
+       struct radeon_atom_ss ss;
        struct atom_clock_dividers dividers;
        struct rv6xx_power_info *pi;
        int ret;
@@ -1983,16 +1987,18 @@ int rv6xx_dpm_init(struct radeon_device *rdev)
 
        pi->gfx_clock_gating = true;
 
-       if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size,
-                                   &frev, &crev, &data_offset)) {
-               pi->sclk_ss = true;
-               pi->mclk_ss = true;
+       pi->sclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
+                                                      ASIC_INTERNAL_ENGINE_SS, 0);
+       pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
+                                                      ASIC_INTERNAL_MEMORY_SS, 0);
+
+       /* Disable sclk ss, causes hangs on a lot of systems */
+       pi->sclk_ss = false;
+
+       if (pi->sclk_ss || pi->mclk_ss)
                pi->dynamic_ss = true;
-       } else {
-               pi->sclk_ss = false;
-               pi->mclk_ss = false;
+       else
                pi->dynamic_ss = false;
-       }
 
        pi->dynamic_pcie_gen2 = true;
 
@@ -2083,3 +2089,34 @@ u32 rv6xx_dpm_get_mclk(struct radeon_device *rdev, bool low)
        else
                return requested_state->high.mclk;
 }
+
+int rv6xx_dpm_force_performance_level(struct radeon_device *rdev,
+                                     enum radeon_dpm_forced_level level)
+{
+       struct rv6xx_power_info *pi = rv6xx_get_pi(rdev);
+
+       if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
+               pi->restricted_levels = 3;
+       } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
+               pi->restricted_levels = 2;
+       } else {
+               pi->restricted_levels = 0;
+       }
+
+       rv6xx_clear_vc(rdev);
+       r600_power_level_enable(rdev, R600_POWER_LEVEL_LOW, true);
+       r600_set_at(rdev, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);
+       r600_wait_for_power_level(rdev, R600_POWER_LEVEL_LOW);
+       r600_power_level_enable(rdev, R600_POWER_LEVEL_HIGH, false);
+       r600_power_level_enable(rdev, R600_POWER_LEVEL_MEDIUM, false);
+       rv6xx_enable_medium(rdev);
+       rv6xx_enable_high(rdev);
+       if (pi->restricted_levels == 3)
+               r600_power_level_enable(rdev, R600_POWER_LEVEL_LOW, false);
+       rv6xx_program_vc(rdev);
+       rv6xx_program_at(rdev);
+
+       rdev->pm.dpm.forced_level = level;
+
+       return 0;
+}
index 4a62ad2e539944ffaefc73b7169733bfefff86ff..f5e92cfcc140984bd63e1a892fa88277bb7530c3 100644 (file)
@@ -744,10 +744,10 @@ static void rv770_init_golden_registers(struct radeon_device *rdev)
                                                 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers));
                radeon_program_register_sequence(rdev,
                                                 rv730_golden_registers,
-                                                (const u32)ARRAY_SIZE(rv770_golden_registers));
+                                                (const u32)ARRAY_SIZE(rv730_golden_registers));
                radeon_program_register_sequence(rdev,
                                                 rv730_mgcg_init,
-                                                (const u32)ARRAY_SIZE(rv770_mgcg_init));
+                                                (const u32)ARRAY_SIZE(rv730_mgcg_init));
                break;
        case CHIP_RV710:
                radeon_program_register_sequence(rdev,
@@ -758,18 +758,18 @@ static void rv770_init_golden_registers(struct radeon_device *rdev)
                                                 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers));
                radeon_program_register_sequence(rdev,
                                                 rv710_golden_registers,
-                                                (const u32)ARRAY_SIZE(rv770_golden_registers));
+                                                (const u32)ARRAY_SIZE(rv710_golden_registers));
                radeon_program_register_sequence(rdev,
                                                 rv710_mgcg_init,
-                                                (const u32)ARRAY_SIZE(rv770_mgcg_init));
+                                                (const u32)ARRAY_SIZE(rv710_mgcg_init));
                break;
        case CHIP_RV740:
                radeon_program_register_sequence(rdev,
                                                 rv740_golden_registers,
-                                                (const u32)ARRAY_SIZE(rv770_golden_registers));
+                                                (const u32)ARRAY_SIZE(rv740_golden_registers));
                radeon_program_register_sequence(rdev,
                                                 rv740_mgcg_init,
-                                                (const u32)ARRAY_SIZE(rv770_mgcg_init));
+                                                (const u32)ARRAY_SIZE(rv740_mgcg_init));
                break;
        default:
                break;
@@ -1829,6 +1829,8 @@ static int rv770_startup(struct radeon_device *rdev)
        /* enable pcie gen2 link */
        rv770_pcie_gen2_enable(rdev);
 
+       rv770_mc_program(rdev);
+
        if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
                r = r600_init_microcode(rdev);
                if (r) {
@@ -1841,7 +1843,6 @@ static int rv770_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       rv770_mc_program(rdev);
        if (rdev->flags & RADEON_IS_AGP) {
                rv770_agp_enable(rdev);
        } else {
@@ -1983,6 +1984,7 @@ int rv770_resume(struct radeon_device *rdev)
 int rv770_suspend(struct radeon_device *rdev)
 {
        r600_audio_fini(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_suspend(rdev);
        r700_cp_stop(rdev);
        r600_dma_stop(rdev);
@@ -2098,6 +2100,7 @@ void rv770_fini(struct radeon_device *rdev)
        radeon_ib_pool_fini(rdev);
        radeon_irq_kms_fini(rdev);
        rv770_pcie_gart_fini(rdev);
+       r600_uvd_stop(rdev);
        radeon_uvd_fini(rdev);
        r600_vram_scratch_fini(rdev);
        radeon_gem_fini(rdev);
index d914e04ea39a19e3f2013dafdac2fddd3ec18837..094c67a29d0deb7789d6b0d38a1d0a718515b81b 100644 (file)
@@ -2099,12 +2099,14 @@ void rv770_dpm_setup_asic(struct radeon_device *rdev)
 
        rv770_enable_acpi_pm(rdev);
 
-       if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s)
-               rv770_enable_l0s(rdev);
-       if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1)
-               rv770_enable_l1(rdev);
-       if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1)
-               rv770_enable_pll_sleep_in_l1(rdev);
+       if (radeon_aspm != 0) {
+               if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L0s)
+                       rv770_enable_l0s(rdev);
+               if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_ASPM_L1)
+                       rv770_enable_l1(rdev);
+               if (rdev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1)
+                       rv770_enable_pll_sleep_in_l1(rdev);
+       }
 }
 
 void rv770_dpm_display_configuration_changed(struct radeon_device *rdev)
@@ -2317,12 +2319,25 @@ int rv7xx_parse_power_table(struct radeon_device *rdev)
        return 0;
 }
 
+void rv770_get_engine_memory_ss(struct radeon_device *rdev)
+{
+       struct rv7xx_power_info *pi = rv770_get_pi(rdev);
+       struct radeon_atom_ss ss;
+
+       pi->sclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
+                                                      ASIC_INTERNAL_ENGINE_SS, 0);
+       pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
+                                                      ASIC_INTERNAL_MEMORY_SS, 0);
+
+       if (pi->sclk_ss || pi->mclk_ss)
+               pi->dynamic_ss = true;
+       else
+               pi->dynamic_ss = false;
+}
+
 int rv770_dpm_init(struct radeon_device *rdev)
 {
        struct rv7xx_power_info *pi;
-       int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
-       uint16_t data_offset, size;
-       uint8_t frev, crev;
        struct atom_clock_dividers dividers;
        int ret;
 
@@ -2367,16 +2382,7 @@ int rv770_dpm_init(struct radeon_device *rdev)
        pi->mvdd_control =
                radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0);
 
-       if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size,
-                                   &frev, &crev, &data_offset)) {
-               pi->sclk_ss = true;
-               pi->mclk_ss = true;
-               pi->dynamic_ss = true;
-       } else {
-               pi->sclk_ss = false;
-               pi->mclk_ss = false;
-               pi->dynamic_ss = false;
-       }
+       rv770_get_engine_memory_ss(rdev);
 
        pi->asi = RV770_ASI_DFLT;
        pi->pasi = RV770_HASI_DFLT;
@@ -2391,8 +2397,7 @@ int rv770_dpm_init(struct radeon_device *rdev)
 
        pi->dynamic_pcie_gen2 = true;
 
-       if (pi->gfx_clock_gating &&
-           (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
+       if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
                pi->thermal_protection = true;
        else
                pi->thermal_protection = false;
index 96b1b2a62a8a2a0d5950574788d0936aba6ec730..9244effc6b59e2e69c6882b0d4dc35dd2517379c 100644 (file)
@@ -275,6 +275,7 @@ void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
 void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
                                             struct radeon_ps *new_ps,
                                             struct radeon_ps *old_ps);
+void rv770_get_engine_memory_ss(struct radeon_device *rdev);
 
 /* smc */
 int rv770_read_smc_soft_register(struct radeon_device *rdev,
index 234906709067041c56aca57e39d0ed442cb40d2d..daa8d2df8ec502ca72a5b9897be75ae59a9a797c 100644 (file)
@@ -22,7 +22,6 @@
  * Authors: Alex Deucher
  */
 #include <linux/firmware.h>
-#include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <drm/drmP.h>
@@ -1541,7 +1540,6 @@ static int si_mc_load_microcode(struct radeon_device *rdev)
 
 static int si_init_microcode(struct radeon_device *rdev)
 {
-       struct platform_device *pdev;
        const char *chip_name;
        const char *rlc_chip_name;
        size_t pfp_req_size, me_req_size, ce_req_size, rlc_req_size, mc_req_size;
@@ -1551,13 +1549,6 @@ static int si_init_microcode(struct radeon_device *rdev)
 
        DRM_DEBUG("\n");
 
-       pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
-       err = IS_ERR(pdev);
-       if (err) {
-               printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
-               return -EINVAL;
-       }
-
        switch (rdev->family) {
        case CHIP_TAHITI:
                chip_name = "TAHITI";
@@ -1615,7 +1606,7 @@ static int si_init_microcode(struct radeon_device *rdev)
        DRM_INFO("Loading %s Microcode\n", chip_name);
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
-       err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->pfp_fw->size != pfp_req_size) {
@@ -1627,7 +1618,7 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
-       err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->me_fw->size != me_req_size) {
@@ -1638,7 +1629,7 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
-       err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->ce_fw->size != ce_req_size) {
@@ -1649,7 +1640,7 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
-       err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->rlc_fw->size != rlc_req_size) {
@@ -1660,7 +1651,7 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
-       err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev);
+       err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
        if (err)
                goto out;
        if (rdev->mc_fw->size != mc_req_size) {
@@ -1671,10 +1662,14 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
-       err = request_firmware(&rdev->smc_fw, fw_name, &pdev->dev);
-       if (err)
-               goto out;
-       if (rdev->smc_fw->size != smc_req_size) {
+       err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
+       if (err) {
+               printk(KERN_ERR
+                      "smc: error loading firmware \"%s\"\n",
+                      fw_name);
+               release_firmware(rdev->smc_fw);
+               rdev->smc_fw = NULL;
+       } else if (rdev->smc_fw->size != smc_req_size) {
                printk(KERN_ERR
                       "si_smc: Bogus length %zu in firmware \"%s\"\n",
                       rdev->smc_fw->size, fw_name);
@@ -1682,8 +1677,6 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
 out:
-       platform_device_unregister(pdev);
-
        if (err) {
                if (err != -EINVAL)
                        printk(KERN_ERR
@@ -4400,6 +4393,270 @@ void si_vm_fini(struct radeon_device *rdev)
 {
 }
 
+/**
+ * si_vm_decode_fault - print human readable fault info
+ *
+ * @rdev: radeon_device pointer
+ * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
+ * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
+ *
+ * Print human readable fault information (SI).
+ */
+static void si_vm_decode_fault(struct radeon_device *rdev,
+                              u32 status, u32 addr)
+{
+       u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT;
+       u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT;
+       u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT;
+       char *block;
+
+       if (rdev->family == CHIP_TAHITI) {
+               switch (mc_id) {
+               case 160:
+               case 144:
+               case 96:
+               case 80:
+               case 224:
+               case 208:
+               case 32:
+               case 16:
+                       block = "CB";
+                       break;
+               case 161:
+               case 145:
+               case 97:
+               case 81:
+               case 225:
+               case 209:
+               case 33:
+               case 17:
+                       block = "CB_FMASK";
+                       break;
+               case 162:
+               case 146:
+               case 98:
+               case 82:
+               case 226:
+               case 210:
+               case 34:
+               case 18:
+                       block = "CB_CMASK";
+                       break;
+               case 163:
+               case 147:
+               case 99:
+               case 83:
+               case 227:
+               case 211:
+               case 35:
+               case 19:
+                       block = "CB_IMMED";
+                       break;
+               case 164:
+               case 148:
+               case 100:
+               case 84:
+               case 228:
+               case 212:
+               case 36:
+               case 20:
+                       block = "DB";
+                       break;
+               case 165:
+               case 149:
+               case 101:
+               case 85:
+               case 229:
+               case 213:
+               case 37:
+               case 21:
+                       block = "DB_HTILE";
+                       break;
+               case 167:
+               case 151:
+               case 103:
+               case 87:
+               case 231:
+               case 215:
+               case 39:
+               case 23:
+                       block = "DB_STEN";
+                       break;
+               case 72:
+               case 68:
+               case 64:
+               case 8:
+               case 4:
+               case 0:
+               case 136:
+               case 132:
+               case 128:
+               case 200:
+               case 196:
+               case 192:
+                       block = "TC";
+                       break;
+               case 112:
+               case 48:
+                       block = "CP";
+                       break;
+               case 49:
+               case 177:
+               case 50:
+               case 178:
+                       block = "SH";
+                       break;
+               case 53:
+               case 190:
+                       block = "VGT";
+                       break;
+               case 117:
+                       block = "IH";
+                       break;
+               case 51:
+               case 115:
+                       block = "RLC";
+                       break;
+               case 119:
+               case 183:
+                       block = "DMA0";
+                       break;
+               case 61:
+                       block = "DMA1";
+                       break;
+               case 248:
+               case 120:
+                       block = "HDP";
+                       break;
+               default:
+                       block = "unknown";
+                       break;
+               }
+       } else {
+               switch (mc_id) {
+               case 32:
+               case 16:
+               case 96:
+               case 80:
+               case 160:
+               case 144:
+               case 224:
+               case 208:
+                       block = "CB";
+                       break;
+               case 33:
+               case 17:
+               case 97:
+               case 81:
+               case 161:
+               case 145:
+               case 225:
+               case 209:
+                       block = "CB_FMASK";
+                       break;
+               case 34:
+               case 18:
+               case 98:
+               case 82:
+               case 162:
+               case 146:
+               case 226:
+               case 210:
+                       block = "CB_CMASK";
+                       break;
+               case 35:
+               case 19:
+               case 99:
+               case 83:
+               case 163:
+               case 147:
+               case 227:
+               case 211:
+                       block = "CB_IMMED";
+                       break;
+               case 36:
+               case 20:
+               case 100:
+               case 84:
+               case 164:
+               case 148:
+               case 228:
+               case 212:
+                       block = "DB";
+                       break;
+               case 37:
+               case 21:
+               case 101:
+               case 85:
+               case 165:
+               case 149:
+               case 229:
+               case 213:
+                       block = "DB_HTILE";
+                       break;
+               case 39:
+               case 23:
+               case 103:
+               case 87:
+               case 167:
+               case 151:
+               case 231:
+               case 215:
+                       block = "DB_STEN";
+                       break;
+               case 72:
+               case 68:
+               case 8:
+               case 4:
+               case 136:
+               case 132:
+               case 200:
+               case 196:
+                       block = "TC";
+                       break;
+               case 112:
+               case 48:
+                       block = "CP";
+                       break;
+               case 49:
+               case 177:
+               case 50:
+               case 178:
+                       block = "SH";
+                       break;
+               case 53:
+                       block = "VGT";
+                       break;
+               case 117:
+                       block = "IH";
+                       break;
+               case 51:
+               case 115:
+                       block = "RLC";
+                       break;
+               case 119:
+               case 183:
+                       block = "DMA0";
+                       break;
+               case 61:
+                       block = "DMA1";
+                       break;
+               case 248:
+               case 120:
+                       block = "HDP";
+                       break;
+               default:
+                       block = "unknown";
+                       break;
+               }
+       }
+
+       printk("VM fault (0x%02x, vmid %d) at page %u, %s from %s (%d)\n",
+              protections, vmid, addr,
+              (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read",
+              block, mc_id);
+}
+
 /**
  * si_vm_set_page - update the page tables using the CP
  *
@@ -4962,14 +5219,12 @@ static void si_enable_mc_ls(struct radeon_device *rdev,
 
 static void si_init_cg(struct radeon_device *rdev)
 {
-       bool has_uvd = true;
-
        si_enable_mgcg(rdev, true);
-       si_enable_cgcg(rdev, true);
+       si_enable_cgcg(rdev, false);
        /* disable MC LS on Tahiti */
        if (rdev->family == CHIP_TAHITI)
                si_enable_mc_ls(rdev, false);
-       if (has_uvd) {
+       if (rdev->has_uvd) {
                si_enable_uvd_mgcg(rdev, true);
                si_init_uvd_internal_cg(rdev);
        }
@@ -4977,9 +5232,7 @@ static void si_init_cg(struct radeon_device *rdev)
 
 static void si_fini_cg(struct radeon_device *rdev)
 {
-       bool has_uvd = true;
-
-       if (has_uvd)
+       if (rdev->has_uvd)
                si_enable_uvd_mgcg(rdev, false);
        si_enable_cgcg(rdev, false);
        si_enable_mgcg(rdev, false);
@@ -4988,11 +5241,11 @@ static void si_fini_cg(struct radeon_device *rdev)
 static void si_init_pg(struct radeon_device *rdev)
 {
        bool has_pg = false;
-
+#if 0
        /* only cape verde supports PG */
        if (rdev->family == CHIP_VERDE)
                has_pg = true;
-
+#endif
        if (has_pg) {
                si_init_ao_cu_mask(rdev);
                si_init_dma_pg(rdev);
@@ -5766,6 +6019,7 @@ int si_irq_process(struct radeon_device *rdev)
        u32 ring_index;
        bool queue_hotplug = false;
        bool queue_thermal = false;
+       u32 status, addr;
 
        if (!rdev->ih.enabled || rdev->shutdown)
                return IRQ_NONE;
@@ -6001,11 +6255,14 @@ restart_ih:
                        break;
                case 146:
                case 147:
+                       addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
+                       status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
                        dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
                        dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_ADDR   0x%08X\n",
-                               RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR));
+                               addr);
                        dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
-                               RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS));
+                               status);
+                       si_vm_decode_fault(rdev, status, addr);
                        /* reset addr and status */
                        WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
                        break;
@@ -6165,6 +6422,8 @@ static int si_startup(struct radeon_device *rdev)
        /* enable aspm */
        si_program_aspm(rdev);
 
+       si_mc_program(rdev);
+
        if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
            !rdev->rlc_fw || !rdev->mc_fw) {
                r = si_init_microcode(rdev);
@@ -6184,7 +6443,6 @@ static int si_startup(struct radeon_device *rdev)
        if (r)
                return r;
 
-       si_mc_program(rdev);
        r = si_pcie_gart_enable(rdev);
        if (r)
                return r;
@@ -6368,7 +6626,7 @@ int si_suspend(struct radeon_device *rdev)
        si_cp_enable(rdev, false);
        cayman_dma_stop(rdev);
        if (rdev->has_uvd) {
-               r600_uvd_rbc_stop(rdev);
+               r600_uvd_stop(rdev);
                radeon_uvd_suspend(rdev);
        }
        si_irq_suspend(rdev);
@@ -6510,8 +6768,10 @@ void si_fini(struct radeon_device *rdev)
        radeon_vm_manager_fini(rdev);
        radeon_ib_pool_fini(rdev);
        radeon_irq_kms_fini(rdev);
-       if (rdev->has_uvd)
+       if (rdev->has_uvd) {
+               r600_uvd_stop(rdev);
                radeon_uvd_fini(rdev);
+       }
        si_pcie_gart_fini(rdev);
        r600_vram_scratch_fini(rdev);
        radeon_gem_fini(rdev);
@@ -6796,6 +7056,9 @@ static void si_program_aspm(struct radeon_device *rdev)
        bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false;
        bool disable_clkreq = false;
 
+       if (radeon_aspm == 0)
+               return;
+
        if (!(rdev->flags & RADEON_IS_PCIE))
                return;
 
index 73aaa2e4c31272b6f4a28341f05e700e0c7bf42c..88699e3cd868047555ce426ecb2251c7f9f3850e 100644 (file)
@@ -37,8 +37,6 @@
 
 #define SMC_RAM_END                 0x20000
 
-#define DDR3_DRAM_ROWS              0x2000
-
 #define SCLK_MIN_DEEPSLEEP_FREQ     1350
 
 static const struct si_cac_config_reg cac_weights_tahiti[] =
@@ -1767,8 +1765,9 @@ static void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coe
 {
        s64 kt, kv, leakage_w, i_leakage, vddc;
        s64 temperature, t_slope, t_intercept, av, bv, t_ref;
+       s64 tmp;
 
-       i_leakage = drm_int2fixp(ileakage / 100);
+       i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
        vddc = div64_s64(drm_int2fixp(v), 1000);
        temperature = div64_s64(drm_int2fixp(t), 1000);
 
@@ -1778,8 +1777,9 @@ static void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coe
        bv = div64_s64(drm_int2fixp(coeff->bv), 100000000);
        t_ref = drm_int2fixp(coeff->t_ref);
 
-       kt = drm_fixp_div(drm_fixp_exp(drm_fixp_mul(drm_fixp_mul(t_slope, vddc) + t_intercept, temperature)),
-                         drm_fixp_exp(drm_fixp_mul(drm_fixp_mul(t_slope, vddc) + t_intercept, t_ref)));
+       tmp = drm_fixp_mul(t_slope, vddc) + t_intercept;
+       kt = drm_fixp_exp(drm_fixp_mul(tmp, temperature));
+       kt = drm_fixp_div(kt, drm_fixp_exp(drm_fixp_mul(tmp, t_ref)));
        kv = drm_fixp_mul(av, drm_fixp_exp(drm_fixp_mul(bv, vddc)));
 
        leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
@@ -1931,6 +1931,7 @@ static void si_initialize_powertune_defaults(struct radeon_device *rdev)
                        si_pi->cac_override = cac_override_pitcairn;
                        si_pi->powertune_data = &powertune_data_pitcairn;
                        si_pi->dte_data = dte_data_pitcairn;
+                       break;
                }
        } else if (rdev->family == CHIP_VERDE) {
                si_pi->lcac_config = lcac_cape_verde;
@@ -1941,6 +1942,7 @@ static void si_initialize_powertune_defaults(struct radeon_device *rdev)
                case 0x683B:
                case 0x683F:
                case 0x6829:
+               case 0x6835:
                        si_pi->cac_weights = cac_weights_cape_verde_pro;
                        si_pi->dte_data = dte_data_cape_verde;
                        break;
@@ -2901,7 +2903,8 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
 {
        struct ni_ps *ps = ni_get_ps(rps);
        struct radeon_clock_and_voltage_limits *max_limits;
-       bool disable_mclk_switching;
+       bool disable_mclk_switching = false;
+       bool disable_sclk_switching = false;
        u32 mclk, sclk;
        u16 vddc, vddci;
        int i;
@@ -2909,8 +2912,11 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
        if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
            ni_dpm_vblank_too_short(rdev))
                disable_mclk_switching = true;
-       else
-               disable_mclk_switching = false;
+
+       if (rps->vclk || rps->dclk) {
+               disable_mclk_switching = true;
+               disable_sclk_switching = true;
+       }
 
        if (rdev->pm.dpm.ac_power)
                max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
@@ -2938,27 +2944,43 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
 
        if (disable_mclk_switching) {
                mclk  = ps->performance_levels[ps->performance_level_count - 1].mclk;
-               sclk = ps->performance_levels[0].sclk;
-               vddc = ps->performance_levels[0].vddc;
                vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
        } else {
-               sclk = ps->performance_levels[0].sclk;
                mclk = ps->performance_levels[0].mclk;
-               vddc = ps->performance_levels[0].vddc;
                vddci = ps->performance_levels[0].vddci;
        }
 
+       if (disable_sclk_switching) {
+               sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
+               vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
+       } else {
+               sclk = ps->performance_levels[0].sclk;
+               vddc = ps->performance_levels[0].vddc;
+       }
+
        /* adjusted low state */
        ps->performance_levels[0].sclk = sclk;
        ps->performance_levels[0].mclk = mclk;
        ps->performance_levels[0].vddc = vddc;
        ps->performance_levels[0].vddci = vddci;
 
-       for (i = 1; i < ps->performance_level_count; i++) {
-               if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
-                       ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
-               if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
-                       ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
+       if (disable_sclk_switching) {
+               sclk = ps->performance_levels[0].sclk;
+               for (i = 1; i < ps->performance_level_count; i++) {
+                       if (sclk < ps->performance_levels[i].sclk)
+                               sclk = ps->performance_levels[i].sclk;
+               }
+               for (i = 0; i < ps->performance_level_count; i++) {
+                       ps->performance_levels[i].sclk = sclk;
+                       ps->performance_levels[i].vddc = vddc;
+               }
+       } else {
+               for (i = 1; i < ps->performance_level_count; i++) {
+                       if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
+                               ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
+                       if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
+                               ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
+               }
        }
 
        if (disable_mclk_switching) {
@@ -3237,10 +3259,10 @@ int si_dpm_force_performance_level(struct radeon_device *rdev,
 {
        struct radeon_ps *rps = rdev->pm.dpm.current_ps;
        struct ni_ps *ps = ni_get_ps(rps);
-       u32 levels;
+       u32 levels = ps->performance_level_count;
 
        if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
-               if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 0) != PPSMC_Result_OK)
+               if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
                        return -EINVAL;
 
                if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK)
@@ -3249,14 +3271,13 @@ int si_dpm_force_performance_level(struct radeon_device *rdev,
                if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
                        return -EINVAL;
 
-               levels = ps->performance_level_count - 1;
-               if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
+               if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK)
                        return -EINVAL;
        } else if (level == RADEON_DPM_FORCED_LEVEL_AUTO) {
                if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
                        return -EINVAL;
 
-               if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, 0) != PPSMC_Result_OK)
+               if (si_send_msg_to_smc_with_parameter(rdev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
                        return -EINVAL;
        }
 
@@ -3620,8 +3641,12 @@ static void si_enable_display_gap(struct radeon_device *rdev)
 {
        u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
 
+       tmp &= ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
+       tmp |= (DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE) |
+               DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE));
+
        tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
-       tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE) |
+       tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK) |
                DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE));
        WREG32(CG_DISPLAY_GAP_CNTL, tmp);
 }
@@ -4036,16 +4061,15 @@ static int si_force_switch_to_arb_f0(struct radeon_device *rdev)
 static u32 si_calculate_memory_refresh_rate(struct radeon_device *rdev,
                                            u32 engine_clock)
 {
-       struct rv7xx_power_info *pi = rv770_get_pi(rdev);
        u32 dram_rows;
        u32 dram_refresh_rate;
        u32 mc_arb_rfsh_rate;
        u32 tmp = (RREG32(MC_ARB_RAMCFG) & NOOFROWS_MASK) >> NOOFROWS_SHIFT;
 
-       if (pi->mem_gddr5)
-               dram_rows = 1 << (tmp + 10);
+       if (tmp >= 4)
+               dram_rows = 16384;
        else
-               dram_rows = DDR3_DRAM_ROWS;
+               dram_rows = 1 << (tmp + 10);
 
        dram_refresh_rate = 1 << ((RREG32(MC_SEQ_MISC0) & 0x3) + 3);
        mc_arb_rfsh_rate = ((engine_clock * 10) * dram_refresh_rate / dram_rows - 32) / 64;
@@ -6013,16 +6037,11 @@ int si_dpm_set_power_state(struct radeon_device *rdev)
                return ret;
        }
 
-#if 0
-       /* XXX */
        ret = si_dpm_force_performance_level(rdev, RADEON_DPM_FORCED_LEVEL_AUTO);
        if (ret) {
                DRM_ERROR("si_dpm_force_performance_level failed\n");
                return ret;
        }
-#else
-       rdev->pm.dpm.forced_level = RADEON_DPM_FORCED_LEVEL_AUTO;
-#endif
 
        return 0;
 }
@@ -6254,9 +6273,6 @@ int si_dpm_init(struct radeon_device *rdev)
        struct evergreen_power_info *eg_pi;
        struct ni_power_info *ni_pi;
        struct si_power_info *si_pi;
-       int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
-       u16 data_offset, size;
-       u8 frev, crev;
        struct atom_clock_dividers dividers;
        int ret;
        u32 mask;
@@ -6347,16 +6363,7 @@ int si_dpm_init(struct radeon_device *rdev)
        si_pi->vddc_phase_shed_control =
                radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, VOLTAGE_OBJ_PHASE_LUT);
 
-       if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size,
-                                   &frev, &crev, &data_offset)) {
-               pi->sclk_ss = true;
-               pi->mclk_ss = true;
-               pi->dynamic_ss = true;
-       } else {
-               pi->sclk_ss = false;
-               pi->mclk_ss = false;
-               pi->dynamic_ss = true;
-       }
+       rv770_get_engine_memory_ss(rdev);
 
        pi->asi = RV770_ASI_DFLT;
        pi->pasi = CYPRESS_HASI_DFLT;
@@ -6367,8 +6374,7 @@ int si_dpm_init(struct radeon_device *rdev)
        eg_pi->sclk_deep_sleep = true;
        si_pi->sclk_deep_sleep_above_low = false;
 
-       if (pi->gfx_clock_gating &&
-           (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
+       if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
                pi->thermal_protection = true;
        else
                pi->thermal_protection = false;
index 12a20eb77d0c533b201b2bdb10beb5cc2adcd61c..2c8da27a929f888a5f17fab08dd355f25370377d 100644 (file)
 
 #define        VM_CONTEXT1_PROTECTION_FAULT_ADDR               0x14FC
 #define        VM_CONTEXT1_PROTECTION_FAULT_STATUS             0x14DC
+#define                PROTECTIONS_MASK                        (0xf << 0)
+#define                PROTECTIONS_SHIFT                       0
+               /* bit 0: range
+                * bit 1: pde0
+                * bit 2: valid
+                * bit 3: read
+                * bit 4: write
+                */
+#define                MEMORY_CLIENT_ID_MASK                   (0xff << 12)
+#define                MEMORY_CLIENT_ID_SHIFT                  12
+#define                MEMORY_CLIENT_RW_MASK                   (1 << 24)
+#define                MEMORY_CLIENT_RW_SHIFT                  24
+#define                FAULT_VMID_MASK                         (0xf << 25)
+#define                FAULT_VMID_SHIFT                        25
 
 #define VM_INVALIDATE_REQUEST                          0x1478
 #define VM_INVALIDATE_RESPONSE                         0x147c
index 11b6b9924f1bc54656ec0d4f85307d658c2d0ffc..c0a85031990841728dd0a11877f1c107f81a01a1 100644 (file)
@@ -1732,7 +1732,13 @@ int sumo_dpm_init(struct radeon_device *rdev)
        pi->enable_sclk_ds = true;
        pi->enable_dynamic_m3_arbiter = false;
        pi->enable_dynamic_patch_ps = true;
-       pi->enable_gfx_power_gating = true;
+       /* Some PALM chips don't seem to properly ungate gfx when UVD is in use;
+        * for now just disable gfx PG.
+        */
+       if (rdev->family == CHIP_PALM)
+               pi->enable_gfx_power_gating = false;
+       else
+               pi->enable_gfx_power_gating = true;
        pi->enable_gfx_clock_gating = true;
        pi->enable_mg_clock_gating = true;
        pi->enable_auto_thermal_throttling = true;
@@ -1845,6 +1851,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev,
                return 0;
 
        if (level == RADEON_DPM_FORCED_LEVEL_HIGH) {
+               if (pi->enable_boost)
+                       sumo_enable_boost(rdev, rps, false);
                sumo_power_level_enable(rdev, ps->num_levels - 1, true);
                sumo_set_forced_level(rdev, ps->num_levels - 1);
                sumo_set_forced_mode_enabled(rdev);
@@ -1855,6 +1863,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev,
                sumo_set_forced_mode_enabled(rdev);
                sumo_set_forced_mode(rdev, false);
        } else if (level == RADEON_DPM_FORCED_LEVEL_LOW) {
+               if (pi->enable_boost)
+                       sumo_enable_boost(rdev, rps, false);
                sumo_power_level_enable(rdev, 0, true);
                sumo_set_forced_level(rdev, 0);
                sumo_set_forced_mode_enabled(rdev);
@@ -1868,6 +1878,8 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev,
                for (i = 0; i < ps->num_levels; i++) {
                        sumo_power_level_enable(rdev, i, true);
                }
+               if (pi->enable_boost)
+                       sumo_enable_boost(rdev, rps, true);
        }
 
        rdev->pm.dpm.forced_level = level;
index ff82877de876295690c67b0ceb2c68e04405ef3a..dc0fe09b2ba10d8b39f51e29a9340818f8c253ff 100644 (file)
@@ -249,8 +249,13 @@ static struct drm_driver rcar_du_driver = {
        .gem_vm_ops             = &drm_gem_cma_vm_ops,
        .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
        .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
-       .gem_prime_import       = drm_gem_cma_dmabuf_import,
-       .gem_prime_export       = drm_gem_cma_dmabuf_export,
+       .gem_prime_import       = drm_gem_prime_import,
+       .gem_prime_export       = drm_gem_prime_export,
+       .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+       .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+       .gem_prime_vmap         = drm_gem_cma_prime_vmap,
+       .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
+       .gem_prime_mmap         = drm_gem_cma_prime_mmap,
        .dumb_create            = rcar_du_dumb_create,
        .dumb_map_offset        = drm_gem_cma_dumb_map_offset,
        .dumb_destroy           = drm_gem_cma_dumb_destroy,
index edc10181f551a83150404c6f891e9828905983a6..5f83f9a3ef593503867cace33ff8dd6ae865db86 100644 (file)
@@ -276,8 +276,13 @@ static struct drm_driver shmob_drm_driver = {
        .gem_vm_ops             = &drm_gem_cma_vm_ops,
        .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
        .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
-       .gem_prime_import       = drm_gem_cma_dmabuf_import,
-       .gem_prime_export       = drm_gem_cma_dmabuf_export,
+       .gem_prime_import       = drm_gem_prime_import,
+       .gem_prime_export       = drm_gem_prime_export,
+       .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+       .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+       .gem_prime_vmap         = drm_gem_cma_prime_vmap,
+       .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
+       .gem_prime_mmap         = drm_gem_cma_prime_mmap,
        .dumb_create            = drm_gem_cma_dumb_create,
        .dumb_map_offset        = drm_gem_cma_dumb_map_offset,
        .dumb_destroy           = drm_gem_cma_dumb_destroy,
index 5207591a598c05944a348be2252c4a346e0e5cfa..cd33084c78602146d42efca60e358d08f00da219 100644 (file)
@@ -192,6 +192,7 @@ static struct hid_ll_driver logi_dj_ll_driver;
 static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf,
                                        size_t count,
                                        unsigned char report_type);
+static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev);
 
 static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev,
                                                struct dj_report *dj_report)
@@ -232,6 +233,7 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
        if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] &
            SPFUNCTION_DEVICE_LIST_EMPTY) {
                dbg_hid("%s: device list is empty\n", __func__);
+               djrcv_dev->querying_devices = false;
                return;
        }
 
@@ -242,6 +244,12 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
                return;
        }
 
+       if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {
+               /* The device is already known. No need to reallocate it. */
+               dbg_hid("%s: device is already known\n", __func__);
+               return;
+       }
+
        dj_hiddev = hid_allocate_device();
        if (IS_ERR(dj_hiddev)) {
                dev_err(&djrcv_hdev->dev, "%s: hid_allocate_device failed\n",
@@ -305,6 +313,7 @@ static void delayedwork_callback(struct work_struct *work)
        struct dj_report dj_report;
        unsigned long flags;
        int count;
+       int retval;
 
        dbg_hid("%s\n", __func__);
 
@@ -337,6 +346,25 @@ static void delayedwork_callback(struct work_struct *work)
                logi_dj_recv_destroy_djhid_device(djrcv_dev, &dj_report);
                break;
        default:
+       /* A normal report (i. e. not belonging to a pair/unpair notification)
+        * arriving here, means that the report arrived but we did not have a
+        * paired dj_device associated to the report's device_index, this
+        * means that the original "device paired" notification corresponding
+        * to this dj_device never arrived to this driver. The reason is that
+        * hid-core discards all packets coming from a device while probe() is
+        * executing. */
+       if (!djrcv_dev->paired_dj_devices[dj_report.device_index]) {
+               /* ok, we don't know the device, just re-ask the
+                * receiver for the list of connected devices. */
+               retval = logi_dj_recv_query_paired_devices(djrcv_dev);
+               if (!retval) {
+                       /* everything went fine, so just leave */
+                       break;
+               }
+               dev_err(&djrcv_dev->hdev->dev,
+                       "%s:logi_dj_recv_query_paired_devices "
+                       "error:%d\n", __func__, retval);
+               }
                dbg_hid("%s: unexpected report type\n", __func__);
        }
 }
@@ -367,6 +395,12 @@ static void logi_dj_recv_forward_null_report(struct dj_receiver_dev *djrcv_dev,
        if (!djdev) {
                dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]"
                        " is NULL, index %d\n", dj_report->device_index);
+               kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report));
+
+               if (schedule_work(&djrcv_dev->work) == 0) {
+                       dbg_hid("%s: did not schedule the work item, was already "
+                       "queued\n", __func__);
+               }
                return;
        }
 
@@ -397,6 +431,12 @@ static void logi_dj_recv_forward_report(struct dj_receiver_dev *djrcv_dev,
        if (dj_device == NULL) {
                dbg_hid("djrcv_dev->paired_dj_devices[dj_report->device_index]"
                        " is NULL, index %d\n", dj_report->device_index);
+               kfifo_in(&djrcv_dev->notif_fifo, dj_report, sizeof(struct dj_report));
+
+               if (schedule_work(&djrcv_dev->work) == 0) {
+                       dbg_hid("%s: did not schedule the work item, was already "
+                       "queued\n", __func__);
+               }
                return;
        }
 
@@ -444,6 +484,10 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
        struct dj_report *dj_report;
        int retval;
 
+       /* no need to protect djrcv_dev->querying_devices */
+       if (djrcv_dev->querying_devices)
+               return 0;
+
        dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
        if (!dj_report)
                return -ENOMEM;
@@ -455,6 +499,7 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
        return retval;
 }
 
+
 static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
                                          unsigned timeout)
 {
index fd28a5e0ca3b84b8407791421b25f8b17bf7815a..4a4000340ce1ed8cf6be1f81ee8e0f21d8ba5f5a 100644 (file)
@@ -101,6 +101,7 @@ struct dj_receiver_dev {
        struct work_struct work;
        struct kfifo notif_fifo;
        spinlock_t lock;
+       bool querying_devices;
 };
 
 struct dj_device {
index ecbc74923d063d6494aaa4648f08d91a6c44e686..87fbe2924cfac3852ee8b202b8aaeb8500de0080 100644 (file)
@@ -369,7 +369,8 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi,
        if (sc->quirks & PS3REMOTE)
                return ps3remote_mapping(hdev, hi, field, usage, bit, max);
 
-       return -1;
+       /* Let hid-core decide for the others */
+       return 0;
 }
 
 /*
index a7451632ceb46bad87845c444fc1897973e94ef9..6f1feb2c2e97b5defb0628d92bfc98a719449685 100644 (file)
@@ -518,7 +518,6 @@ int hidraw_connect(struct hid_device *hid)
                goto out;
        }
 
-       mutex_unlock(&minors_lock);
        init_waitqueue_head(&dev->wait);
        INIT_LIST_HEAD(&dev->list);
 
@@ -528,6 +527,7 @@ int hidraw_connect(struct hid_device *hid)
        dev->exist = 1;
        hid->hidraw = dev;
 
+       mutex_unlock(&minors_lock);
 out:
        return result;
 
index 4c605c70ebf9ed858d014d94383ebfab86851b1f..deb5c25305aff4622ceb8f84a1598902e484a6ce 100644 (file)
@@ -562,7 +562,7 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
                                struct hv_hotadd_state *has)
 {
        int ret = 0;
-       int i, nid, t;
+       int i, nid;
        unsigned long start_pfn;
        unsigned long processed_pfn;
        unsigned long total_pfn = pfn_count;
@@ -607,14 +607,11 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
 
                /*
                 * Wait for the memory block to be onlined.
+                * Since the hot add has succeeded, it is ok to
+                * proceed even if the pages in the hot added region
+                * have not been "onlined" within the allowed time.
                 */
-               t = wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ);
-               if (t == 0) {
-                       pr_info("hot_add memory timedout\n");
-                       has->ha_end_pfn -= HA_CHUNK;
-                       has->covered_end_pfn -=  processed_pfn;
-                       break;
-               }
+               wait_for_completion_timeout(&dm_device.ol_waitevent, 5*HZ);
 
        }
 
@@ -978,6 +975,14 @@ static void post_status(struct hv_dynmem_device *dm)
                                dm->num_pages_ballooned +
                                compute_balloon_floor();
 
+       /*
+        * If our transaction ID is no longer current, just don't
+        * send the status. This can happen if we were interrupted
+        * after we picked our transaction ID.
+        */
+       if (status.hdr.trans_id != atomic_read(&trans_id))
+               return;
+
        vmbus_sendpacket(dm->dev->channel, &status,
                                sizeof(struct dm_status),
                                (unsigned long)NULL,
index a2464bf07c49b03342c0dfcd79852cc0a232a703..e8e071fc1d6d1ab265d858772fc94bbd5cd8930c 100644 (file)
@@ -690,7 +690,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
        if (ret)
                pr_err("Unable to register child device\n");
        else
-               pr_info("child device %s registered\n",
+               pr_debug("child device %s registered\n",
                        dev_name(&child_device_obj->device));
 
        return ret;
@@ -702,14 +702,14 @@ int vmbus_device_register(struct hv_device *child_device_obj)
  */
 void vmbus_device_unregister(struct hv_device *device_obj)
 {
+       pr_debug("child device %s unregistered\n",
+               dev_name(&device_obj->device));
+
        /*
         * Kick off the process of unregistering the device.
         * This will call vmbus_remove() and eventually vmbus_device_release()
         */
        device_unregister(&device_obj->device);
-
-       pr_info("child device %s unregistered\n",
-               dev_name(&device_obj->device));
 }
 
 
index eee1134274c8bb931d445322644e0f0fac73b757..769fe20ec9389b14e019ea685c48092b7455c2b8 100644 (file)
@@ -315,7 +315,7 @@ static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IWUSR | S_IRUGO,
 static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3);
 static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3);
 
-struct attribute *abx500_temp_attributes[] = {
+static struct attribute *abx500_temp_attributes[] = {
        &sensor_dev_attr_name.dev_attr.attr,
 
        &sensor_dev_attr_temp1_label.dev_attr.attr,
index 0f34bca9f5e577c1f1e04d43908bc9a7a91f4bce..6099f50b28aaa80f74e9ac69373f73efe4e852f1 100644 (file)
@@ -215,7 +215,7 @@ static inline int adt7470_write_word_data(struct i2c_client *client, u8 reg,
                                          u16 value)
 {
        return i2c_smbus_write_byte_data(client, reg, value & 0xFF)
-              && i2c_smbus_write_byte_data(client, reg + 1, value >> 8);
+              || i2c_smbus_write_byte_data(client, reg + 1, value >> 8);
 }
 
 static void adt7470_init_client(struct i2c_client *client)
index ade35cf3f48880ee2dad3744428624bbd71d76d3..2e5e2dc47eafdca62ae3513bee1e471cbdb1276d 100644 (file)
@@ -195,7 +195,7 @@ struct tjmax {
        int tjmax;
 };
 
-static const struct tjmax __cpuinitconst tjmax_table[] = {
+static const struct tjmax tjmax_table[] = {
        { "CPU  230", 100000 },         /* Model 0x1c, stepping 2       */
        { "CPU  330", 125000 },         /* Model 0x1c, stepping 2       */
        { "CPU CE4110", 110000 },       /* Model 0x1c, stepping 10 Sodaville */
@@ -211,7 +211,7 @@ struct tjmax_model {
 
 #define ANY 0xff
 
-static const struct tjmax_model __cpuinitconst tjmax_model_table[] = {
+static const struct tjmax_model tjmax_model_table[] = {
        { 0x1c, 10, 100000 },   /* D4xx, K4xx, N4xx, D5xx, K5xx, N5xx */
        { 0x1c, ANY, 90000 },   /* Z5xx, N2xx, possibly others
                                 * Note: Also matches 230 and 330,
@@ -226,8 +226,7 @@ static const struct tjmax_model __cpuinitconst tjmax_model_table[] = {
        { 0x36, ANY, 100000 },  /* Atom Cedar Trail/Cedarview (N2xxx, D2xxx) */
 };
 
-static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
-                                 struct device *dev)
+static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
 {
        /* The 100C is default for both mobile and non mobile CPUs */
 
@@ -317,8 +316,7 @@ static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
        return tjmax;
 }
 
-static int __cpuinit get_tjmax(struct cpuinfo_x86 *c, u32 id,
-                              struct device *dev)
+static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
 {
        int err;
        u32 eax, edx;
@@ -367,8 +365,8 @@ static int create_name_attr(struct platform_data *pdata,
        return device_create_file(dev, &pdata->name_attr);
 }
 
-static int __cpuinit create_core_attrs(struct temp_data *tdata,
-                                      struct device *dev, int attr_no)
+static int create_core_attrs(struct temp_data *tdata, struct device *dev,
+                            int attr_no)
 {
        int err, i;
        static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev,
@@ -401,7 +399,7 @@ exit_free:
 }
 
 
-static int __cpuinit chk_ucode_version(unsigned int cpu)
+static int chk_ucode_version(unsigned int cpu)
 {
        struct cpuinfo_x86 *c = &cpu_data(cpu);
 
@@ -417,7 +415,7 @@ static int __cpuinit chk_ucode_version(unsigned int cpu)
        return 0;
 }
 
-static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu)
+static struct platform_device *coretemp_get_pdev(unsigned int cpu)
 {
        u16 phys_proc_id = TO_PHYS_ID(cpu);
        struct pdev_entry *p;
@@ -434,8 +432,7 @@ static struct platform_device __cpuinit *coretemp_get_pdev(unsigned int cpu)
        return NULL;
 }
 
-static struct temp_data __cpuinit *init_temp_data(unsigned int cpu,
-                                                 int pkg_flag)
+static struct temp_data *init_temp_data(unsigned int cpu, int pkg_flag)
 {
        struct temp_data *tdata;
 
@@ -453,8 +450,8 @@ static struct temp_data __cpuinit *init_temp_data(unsigned int cpu,
        return tdata;
 }
 
-static int __cpuinit create_core_data(struct platform_device *pdev,
-                               unsigned int cpu, int pkg_flag)
+static int create_core_data(struct platform_device *pdev, unsigned int cpu,
+                           int pkg_flag)
 {
        struct temp_data *tdata;
        struct platform_data *pdata = platform_get_drvdata(pdev);
@@ -524,7 +521,7 @@ exit_free:
        return err;
 }
 
-static void __cpuinit coretemp_add_core(unsigned int cpu, int pkg_flag)
+static void coretemp_add_core(unsigned int cpu, int pkg_flag)
 {
        struct platform_device *pdev = coretemp_get_pdev(cpu);
        int err;
@@ -607,7 +604,7 @@ static struct platform_driver coretemp_driver = {
        .remove = coretemp_remove,
 };
 
-static int __cpuinit coretemp_device_add(unsigned int cpu)
+static int coretemp_device_add(unsigned int cpu)
 {
        int err;
        struct platform_device *pdev;
@@ -651,7 +648,7 @@ exit:
        return err;
 }
 
-static void __cpuinit coretemp_device_remove(unsigned int cpu)
+static void coretemp_device_remove(unsigned int cpu)
 {
        struct pdev_entry *p, *n;
        u16 phys_proc_id = TO_PHYS_ID(cpu);
@@ -667,7 +664,7 @@ static void __cpuinit coretemp_device_remove(unsigned int cpu)
        mutex_unlock(&pdev_list_mutex);
 }
 
-static bool __cpuinit is_any_core_online(struct platform_data *pdata)
+static bool is_any_core_online(struct platform_data *pdata)
 {
        int i;
 
@@ -681,7 +678,7 @@ static bool __cpuinit is_any_core_online(struct platform_data *pdata)
        return false;
 }
 
-static void __cpuinit get_core_online(unsigned int cpu)
+static void get_core_online(unsigned int cpu)
 {
        struct cpuinfo_x86 *c = &cpu_data(cpu);
        struct platform_device *pdev = coretemp_get_pdev(cpu);
@@ -723,7 +720,7 @@ static void __cpuinit get_core_online(unsigned int cpu)
        coretemp_add_core(cpu, 0);
 }
 
-static void __cpuinit put_core_offline(unsigned int cpu)
+static void put_core_offline(unsigned int cpu)
 {
        int i, indx;
        struct platform_data *pdata;
@@ -771,7 +768,7 @@ static void __cpuinit put_core_offline(unsigned int cpu)
                coretemp_device_remove(cpu);
 }
 
-static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
+static int coretemp_cpu_callback(struct notifier_block *nfb,
                                 unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long) hcpu;
index 328fb0353c171a1b879af1040185afa1be109ea4..a41b5f3fc5069596d7c9a0c0c164dcefefc7e621 100644 (file)
@@ -605,12 +605,12 @@ static int max6697_init_chip(struct i2c_client *client)
                if (ret < 0)
                        return ret;
                ret = i2c_smbus_write_byte_data(client, MAX6581_REG_IDEALITY,
-                                               pdata->ideality_mask >> 1);
+                                               pdata->ideality_value);
                if (ret < 0)
                        return ret;
                ret = i2c_smbus_write_byte_data(client,
                                                MAX6581_REG_IDEALITY_SELECT,
-                                               pdata->ideality_value);
+                                               pdata->ideality_mask >> 1);
                if (ret < 0)
                        return ret;
        }
index 76f157b568ed7ac245ef9aaaf23436edef4e4ba2..38944e94f65fbd27692100d4d78b2868f13a2982 100644 (file)
@@ -221,7 +221,7 @@ struct pdev_entry {
 static LIST_HEAD(pdev_list);
 static DEFINE_MUTEX(pdev_list_mutex);
 
-static int __cpuinit via_cputemp_device_add(unsigned int cpu)
+static int via_cputemp_device_add(unsigned int cpu)
 {
        int err;
        struct platform_device *pdev;
@@ -262,7 +262,7 @@ exit:
        return err;
 }
 
-static void __cpuinit via_cputemp_device_remove(unsigned int cpu)
+static void via_cputemp_device_remove(unsigned int cpu)
 {
        struct pdev_entry *p;
 
@@ -279,8 +279,8 @@ static void __cpuinit via_cputemp_device_remove(unsigned int cpu)
        mutex_unlock(&pdev_list_mutex);
 }
 
-static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
-                                unsigned long action, void *hcpu)
+static int via_cputemp_cpu_callback(struct notifier_block *nfb,
+                                   unsigned long action, void *hcpu)
 {
        unsigned int cpu = (unsigned long) hcpu;
 
index ccec916bc3eb58f9b6376ff109965cd1529f5d7c..af8f65fb1c050192e7a21234dd6dc855ca55c923 100644 (file)
@@ -246,9 +246,9 @@ static void kempld_i2c_device_init(struct kempld_i2c_data *i2c)
                bus_frequency = KEMPLD_I2C_FREQ_MAX;
 
        if (pld->info.spec_major == 1)
-               prescale = pld->pld_clock / bus_frequency * 5 - 1000;
+               prescale = pld->pld_clock / (bus_frequency * 5) - 1000;
        else
-               prescale = pld->pld_clock / bus_frequency * 4 - 3000;
+               prescale = pld->pld_clock / (bus_frequency * 4) - 3000;
 
        if (prescale < 0)
                prescale = 0;
index df8ff5aea5b5b2b4aea8191f66b18f45408fd6ea..e2e9a0dade9665ec0d89598754c5734d2480c09c 100644 (file)
@@ -493,7 +493,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
         * based on this empirical measurement and a lot of previous frobbing.
         */
        i2c->cmd_err = 0;
-       if (msg->len < 8) {
+       if (0) {        /* disable PIO mode until a proper fix is made */
                ret = mxs_i2c_pio_setup_xfer(adap, msg, flags);
                if (ret)
                        mxs_i2c_reset(i2c);
index 4427e8e46a7fee759c3d7dd2782ff9307ea3941e..3ceac3e91dde4cd30339bc3c61feb4ad570a03c7 100644 (file)
@@ -60,7 +60,6 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
 {
        unsigned int stepconfig;
        int i, steps;
-       u32 step_en;
 
        /*
         * There are 16 configurable steps and 8 analog input
@@ -86,8 +85,7 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
                adc_dev->channel_step[i] = steps;
                steps++;
        }
-       step_en = get_adc_step_mask(adc_dev);
-       am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
+
 }
 
 static const char * const chan_name_ain[] = {
@@ -142,10 +140,22 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
                int *val, int *val2, long mask)
 {
        struct tiadc_device *adc_dev = iio_priv(indio_dev);
-       int i;
-       unsigned int fifo1count, read;
+       int i, map_val;
+       unsigned int fifo1count, read, stepid;
        u32 step = UINT_MAX;
        bool found = false;
+       u32 step_en;
+       unsigned long timeout = jiffies + usecs_to_jiffies
+                               (IDLE_TIMEOUT * adc_dev->channels);
+       step_en = get_adc_step_mask(adc_dev);
+       am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
+
+       /* Wait for ADC sequencer to complete sampling */
+       while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) {
+               if (time_after(jiffies, timeout))
+                       return -EAGAIN;
+               }
+       map_val = chan->channel + TOTAL_CHANNELS;
 
        /*
         * When the sub-system is first enabled,
@@ -170,12 +180,16 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
        fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
        for (i = 0; i < fifo1count; i++) {
                read = tiadc_readl(adc_dev, REG_FIFO1);
-               if (read >> 16 == step) {
-                       *val = read & 0xfff;
+               stepid = read & FIFOREAD_CHNLID_MASK;
+               stepid = stepid >> 0x10;
+
+               if (stepid == map_val) {
+                       read = read & FIFOREAD_DATA_MASK;
                        found = true;
+                       *val = read;
                }
        }
-       am335x_tsc_se_update(adc_dev->mfd_tscadc);
+
        if (found == false)
                return -EBUSY;
        return IIO_VAL_INT;
@@ -183,6 +197,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_info tiadc_info = {
        .read_raw = &tiadc_read_raw,
+       .driver_module = THIS_MODULE,
 };
 
 static int tiadc_probe(struct platform_device *pdev)
index 85aeef60dc5f6166a4f197677cab270867c11ec9..d546f50f9258b391891d0889c82cd0a826b959f0 100644 (file)
@@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi)
 
        if (ext_ref) {
                st->vref_reg = regulator_get(&spi->dev, "REF");
-               if (IS_ERR(st->vref_reg))
+               if (IS_ERR(st->vref_reg)) {
+                       ret = PTR_ERR(st->vref_reg);
                        goto err_disable_vdd_reg;
+               }
 
                ret = regulator_enable(st->vref_reg);
                if (ret)
index 4d6c7d84e1552fb3564c224897c36f1923050b2e..0dd9bb8731301e755dc29ef2851371f70deb819d 100644 (file)
@@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
 
        ida_simple_remove(&iio_trigger_ida, trig_info->id);
        /* Possible issue in here */
-       device_unregister(&trig_info->dev);
+       device_del(&trig_info->dev);
 }
 EXPORT_SYMBOL(iio_trigger_unregister);
 
@@ -127,12 +127,17 @@ static struct iio_trigger *iio_trigger_find_by_name(const char *name,
 void iio_trigger_poll(struct iio_trigger *trig, s64 time)
 {
        int i;
-       if (!trig->use_count)
-               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
-                       if (trig->subirqs[i].enabled) {
-                               trig->use_count++;
+
+       if (!atomic_read(&trig->use_count)) {
+               atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+
+               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
+                       if (trig->subirqs[i].enabled)
                                generic_handle_irq(trig->subirq_base + i);
-                       }
+                       else
+                               iio_trigger_notify_done(trig);
+               }
+       }
 }
 EXPORT_SYMBOL(iio_trigger_poll);
 
@@ -146,19 +151,24 @@ EXPORT_SYMBOL(iio_trigger_generic_data_rdy_poll);
 void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time)
 {
        int i;
-       if (!trig->use_count)
-               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
-                       if (trig->subirqs[i].enabled) {
-                               trig->use_count++;
+
+       if (!atomic_read(&trig->use_count)) {
+               atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
+
+               for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
+                       if (trig->subirqs[i].enabled)
                                handle_nested_irq(trig->subirq_base + i);
-                       }
+                       else
+                               iio_trigger_notify_done(trig);
+               }
+       }
 }
 EXPORT_SYMBOL(iio_trigger_poll_chained);
 
 void iio_trigger_notify_done(struct iio_trigger *trig)
 {
-       trig->use_count--;
-       if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable)
+       if (atomic_dec_and_test(&trig->use_count) && trig->ops &&
+               trig->ops->try_reenable)
                if (trig->ops->try_reenable(trig))
                        /* Missed an interrupt so launch new poll now */
                        iio_trigger_poll(trig, 0);
index 98ddc323add011fe84e45abc4f8902ce9e7f09af..0cf5f8e06cfcc6b6bc8c059871e153a391cbd122 100644 (file)
@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
        int ret;
 
        ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
-       if (ret == 0)
+       if (ret >= 0)
                raw64 += offset;
 
        scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
index 9c343b40665ebc0b28bb291a6b4fdf33556b7d49..3ffbc56917b48256d1654145e899556d7f191ba5 100644 (file)
@@ -28,7 +28,9 @@
 #include <linux/iio/common/st_sensors.h>
 #include "st_pressure.h"
 
-#define ST_PRESS_MBAR_TO_KPASCAL(x)            (x * 10)
+#define ST_PRESS_LSB_PER_MBAR                  4096UL
+#define ST_PRESS_KPASCAL_NANO_SCALE            (100000000UL / \
+                                                ST_PRESS_LSB_PER_MBAR)
 #define ST_PRESS_NUMBER_DATA_CHANNELS          1
 
 /* DEFAULT VALUE FOR SENSORS */
@@ -51,8 +53,8 @@
 #define ST_PRESS_1_FS_ADDR                     0x23
 #define ST_PRESS_1_FS_MASK                     0x30
 #define ST_PRESS_1_FS_AVL_1260_VAL             0x00
-#define ST_PRESS_1_FS_AVL_1260_GAIN            ST_PRESS_MBAR_TO_KPASCAL(244141)
 #define ST_PRESS_1_FS_AVL_TEMP_GAIN            2083000
+#define ST_PRESS_1_FS_AVL_1260_GAIN            ST_PRESS_KPASCAL_NANO_SCALE
 #define ST_PRESS_1_BDU_ADDR                    0x20
 #define ST_PRESS_1_BDU_MASK                    0x04
 #define ST_PRESS_1_DRDY_IRQ_ADDR               0x22
index f1c279fabe646f80d3962f3354475087f9c37bf8..7c0f9535fb7d443bf2c4b1647b3494816292020a 100644 (file)
@@ -423,7 +423,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
        struct sockaddr_ib *addr;
        union ib_gid gid, sgid, *dgid;
        u16 pkey, index;
-       u8 port, p;
+       u8 p;
        int i;
 
        cma_dev = NULL;
@@ -443,7 +443,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
                                if (!memcmp(&gid, dgid, sizeof(gid))) {
                                        cma_dev = cur_dev;
                                        sgid = gid;
-                                       port = p;
+                                       id_priv->id.port_num = p;
                                        goto found;
                                }
 
@@ -451,7 +451,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
                                                 dgid->global.subnet_prefix)) {
                                        cma_dev = cur_dev;
                                        sgid = gid;
-                                       port = p;
+                                       id_priv->id.port_num = p;
                                }
                        }
                }
@@ -462,7 +462,6 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
 
 found:
        cma_attach_to_dev(id_priv, cma_dev);
-       id_priv->id.port_num = port;
        addr = (struct sockaddr_ib *) cma_src_addr(id_priv);
        memcpy(&addr->sib_addr, &sgid, sizeof sgid);
        cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
@@ -880,7 +879,8 @@ static int cma_save_net_info(struct rdma_cm_id *id, struct rdma_cm_id *listen_id
 {
        struct cma_hdr *hdr;
 
-       if (listen_id->route.addr.src_addr.ss_family == AF_IB) {
+       if ((listen_id->route.addr.src_addr.ss_family == AF_IB) &&
+           (ib_event->event == IB_CM_REQ_RECEIVED)) {
                cma_save_ib_info(id, listen_id, ib_event->param.req_rcvd.primary_path);
                return 0;
        }
@@ -2677,29 +2677,32 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
 {
        struct ib_cm_sidr_req_param req;
        struct ib_cm_id *id;
+       void *private_data;
        int offset, ret;
 
+       memset(&req, 0, sizeof req);
        offset = cma_user_data_offset(id_priv);
        req.private_data_len = offset + conn_param->private_data_len;
        if (req.private_data_len < conn_param->private_data_len)
                return -EINVAL;
 
        if (req.private_data_len) {
-               req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
-               if (!req.private_data)
+               private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
+               if (!private_data)
                        return -ENOMEM;
        } else {
-               req.private_data = NULL;
+               private_data = NULL;
        }
 
        if (conn_param->private_data && conn_param->private_data_len)
-               memcpy((void *) req.private_data + offset,
-                      conn_param->private_data, conn_param->private_data_len);
+               memcpy(private_data + offset, conn_param->private_data,
+                      conn_param->private_data_len);
 
-       if (req.private_data) {
-               ret = cma_format_hdr((void *) req.private_data, id_priv);
+       if (private_data) {
+               ret = cma_format_hdr(private_data, id_priv);
                if (ret)
                        goto out;
+               req.private_data = private_data;
        }
 
        id = ib_create_cm_id(id_priv->id.device, cma_sidr_rep_handler,
@@ -2721,7 +2724,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
                id_priv->cm_id.ib = NULL;
        }
 out:
-       kfree(req.private_data);
+       kfree(private_data);
        return ret;
 }
 
index dc3fd1e8af07f0f8f4c6da455c38e315074a8e1e..4c837e66516b894f88f689d93c9a84c501fa6b47 100644 (file)
@@ -2663,6 +2663,7 @@ static int ib_mad_port_start(struct ib_mad_port_private *port_priv)
        int ret, i;
        struct ib_qp_attr *attr;
        struct ib_qp *qp;
+       u16 pkey_index;
 
        attr = kmalloc(sizeof *attr, GFP_KERNEL);
        if (!attr) {
@@ -2670,6 +2671,11 @@ static int ib_mad_port_start(struct ib_mad_port_private *port_priv)
                return -ENOMEM;
        }
 
+       ret = ib_find_pkey(port_priv->device, port_priv->port_num,
+                          IB_DEFAULT_PKEY_FULL, &pkey_index);
+       if (ret)
+               pkey_index = 0;
+
        for (i = 0; i < IB_MAD_QPS_CORE; i++) {
                qp = port_priv->qp_info[i].qp;
                if (!qp)
@@ -2680,7 +2686,7 @@ static int ib_mad_port_start(struct ib_mad_port_private *port_priv)
                 * one is needed for the Reset to Init transition
                 */
                attr->qp_state = IB_QPS_INIT;
-               attr->pkey_index = 0;
+               attr->pkey_index = pkey_index;
                attr->qkey = (qp->qp_num == 0) ? 0 : IB_QP1_QKEY;
                ret = ib_modify_qp(qp, attr, IB_QP_STATE |
                                             IB_QP_PKEY_INDEX | IB_QP_QKEY);
index e87f2201b220673030ca18a3957642b623d065a7..d2283837d45168070707eba5ac11aab4c2fe9c5e 100644 (file)
@@ -226,6 +226,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve
                        mm->len = PAGE_ALIGN(((1UL << uresp.size_log2) + 1) *
                                             sizeof(struct t3_cqe));
                        uresp.memsize = mm->len;
+                       uresp.reserved = 0;
                        resplen = sizeof uresp;
                }
                if (ib_copy_to_udata(udata, &uresp, resplen)) {
index 232040447e8a23803cc73e64c203734d36492c2e..a4975e1654a639960b214114648593564fcb0b27 100644 (file)
@@ -1657,6 +1657,8 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
                if (mm5) {
                        uresp.ma_sync_key = ucontext->key;
                        ucontext->key += PAGE_SIZE;
+               } else {
+                       uresp.ma_sync_key =  0;
                }
                uresp.sq_key = ucontext->key;
                ucontext->key += PAGE_SIZE;
index 4d599cedbb0b1ccceab997a4945be0d8d6e89fde..f2a3f48107e71e1d53b0abb61757f1f0ba38bb59 100644 (file)
@@ -1511,8 +1511,14 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
 
        memset(&attr, 0, sizeof attr);
        attr.qp_state = IB_QPS_INIT;
-       attr.pkey_index =
-               to_mdev(ctx->ib_dev)->pkeys.virt2phys_pkey[ctx->slave][ctx->port - 1][0];
+       ret = 0;
+       if (create_tun)
+               ret = find_slave_port_pkey_ix(to_mdev(ctx->ib_dev), ctx->slave,
+                                             ctx->port, IB_DEFAULT_PKEY_FULL,
+                                             &attr.pkey_index);
+       if (ret || !create_tun)
+               attr.pkey_index =
+                       to_mdev(ctx->ib_dev)->pkeys.virt2phys_pkey[ctx->slave][ctx->port - 1][0];
        attr.qkey = IB_QP1_QKEY;
        attr.port_num = ctx->port;
        ret = ib_modify_qp(tun_qp->qp, &attr, qp_attr_mask_INIT);
index 8000fff4d4444168ac4091a78112593d11b212dd..3f831de9a4d8a901607afc26c81827cc5c1e3bd5 100644 (file)
@@ -619,7 +619,8 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
 
        resp.tot_uuars = req.total_num_uuars;
        resp.num_ports = dev->mdev.caps.num_ports;
-       err = ib_copy_to_udata(udata, &resp, sizeof(resp));
+       err = ib_copy_to_udata(udata, &resp,
+                              sizeof(resp) - sizeof(resp.reserved));
        if (err)
                goto out_uars;
 
@@ -1426,7 +1427,8 @@ static int init_one(struct pci_dev *pdev,
        if (err)
                goto err_eqs;
 
-       if (ib_register_device(&dev->ib_dev, NULL))
+       err = ib_register_device(&dev->ib_dev, NULL);
+       if (err)
                goto err_rsrc;
 
        err = create_umr_res(dev);
@@ -1434,8 +1436,9 @@ static int init_one(struct pci_dev *pdev,
                goto err_dev;
 
        for (i = 0; i < ARRAY_SIZE(mlx5_class_attributes); i++) {
-               if (device_create_file(&dev->ib_dev.dev,
-                                      mlx5_class_attributes[i]))
+               err = device_create_file(&dev->ib_dev.dev,
+                                        mlx5_class_attributes[i]);
+               if (err)
                        goto err_umrc;
        }
 
index 16ac54c9819f24c113ad02f594a47608a004a828..045f8cdbd303deba81e60c5f1f52330b536b9617 100644 (file)
@@ -199,7 +199,7 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap,
 
 static int sq_overhead(enum ib_qp_type qp_type)
 {
-       int size;
+       int size = 0;
 
        switch (qp_type) {
        case IB_QPT_XRC_INI:
index 418004c93feb772c641dde6b102620fc2be45900..90200245c5ebfd5fe71000d17b78e52bfa8d4734 100644 (file)
@@ -3570,10 +3570,10 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
        tcp_state = (aeq_info & NES_AEQE_TCP_STATE_MASK) >> NES_AEQE_TCP_STATE_SHIFT;
        iwarp_state = (aeq_info & NES_AEQE_IWARP_STATE_MASK) >> NES_AEQE_IWARP_STATE_SHIFT;
        nes_debug(NES_DBG_AEQ, "aeid = 0x%04X, qp-cq id = %d, aeqe = %p,"
-                       " Tcp state = %d, iWARP state = %d\n",
+                       " Tcp state = %s, iWARP state = %s\n",
                        async_event_id,
                        le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX]), aeqe,
-                       tcp_state, iwarp_state);
+                       nes_tcp_state_str[tcp_state], nes_iwarp_state_str[iwarp_state]);
 
        aeqe_cq_id = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX]);
        if (aeq_info & NES_AEQE_QP) {
index 8f67fe2e91e623a87878a8790ff9f2e28db0c0b8..5b53ca5a22840c14e31ddb0d7e978dfac5c179b7 100644 (file)
@@ -1384,6 +1384,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
 
                        if (ibpd->uobject) {
                                uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index;
+                               uresp.mmap_rq_db_index = 0;
                                uresp.actual_sq_size = sq_size;
                                uresp.actual_rq_size = rq_size;
                                uresp.qp_id = nesqp->hwqp.qp_id;
@@ -1767,7 +1768,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
                resp.cq_id = nescq->hw_cq.cq_number;
                resp.cq_size = nescq->hw_cq.cq_size;
                resp.mmap_db_index = 0;
-               if (ib_copy_to_udata(udata, &resp, sizeof resp)) {
+               if (ib_copy_to_udata(udata, &resp, sizeof resp - sizeof resp.reserved)) {
                        nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
                        kfree(nescq);
                        return ERR_PTR(-EFAULT);
index a877a8ed79077dbd085d28d1fd834b3f1e01d019..f4c587c68f648055546deafce7f8708798f4d109 100644 (file)
@@ -29,7 +29,6 @@
 #include <net/netevent.h>
 
 #include <rdma/ib_addr.h>
-#include <rdma/ib_cache.h>
 
 #include "ocrdma.h"
 #include "ocrdma_verbs.h"
index dcfbab177faa63eee063a428ac7848e5763f8125..f36630e4b6be182c735b7aa81d357b4207266c82 100644 (file)
@@ -242,6 +242,7 @@ struct ib_ucontext *ocrdma_alloc_ucontext(struct ib_device *ibdev,
        memset(ctx->ah_tbl.va, 0, map_len);
        ctx->ah_tbl.len = map_len;
 
+       memset(&resp, 0, sizeof(resp));
        resp.ah_tbl_len = ctx->ah_tbl.len;
        resp.ah_tbl_page = ctx->ah_tbl.pa;
 
@@ -253,7 +254,6 @@ struct ib_ucontext *ocrdma_alloc_ucontext(struct ib_device *ibdev,
        resp.wqe_size = dev->attr.wqe_size;
        resp.rqe_size = dev->attr.rqe_size;
        resp.dpp_wqe_size = dev->attr.wqe_size;
-       resp.rsvd = 0;
 
        memcpy(resp.fw_ver, dev->attr.fw_ver, sizeof(resp.fw_ver));
        status = ib_copy_to_udata(udata, &resp, sizeof(resp));
@@ -338,6 +338,7 @@ static int ocrdma_copy_pd_uresp(struct ocrdma_pd *pd,
        struct ocrdma_alloc_pd_uresp rsp;
        struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ib_ctx);
 
+       memset(&rsp, 0, sizeof(rsp));
        rsp.id = pd->id;
        rsp.dpp_enabled = pd->dpp_enabled;
        db_page_addr = pd->dev->nic_info.unmapped_db +
@@ -692,6 +693,7 @@ static int ocrdma_copy_cq_uresp(struct ocrdma_cq *cq, struct ib_udata *udata,
        struct ocrdma_ucontext *uctx;
        struct ocrdma_create_cq_uresp uresp;
 
+       memset(&uresp, 0, sizeof(uresp));
        uresp.cq_id = cq->id;
        uresp.page_size = cq->len;
        uresp.num_pages = 1;
@@ -1460,6 +1462,7 @@ static int ocrdma_copy_srq_uresp(struct ocrdma_srq *srq, struct ib_udata *udata)
        int status;
        struct ocrdma_create_srq_uresp uresp;
 
+       memset(&uresp, 0, sizeof(uresp));
        uresp.rq_dbid = srq->rq.dbid;
        uresp.num_rq_pages = 1;
        uresp.rq_page_addr[0] = srq->rq.pa;
index 21e8b09d4bf87687a9c569ac87dae42108b7cd8a..016e7429adf66b9ffb945cb4fed168e358c57742 100644 (file)
@@ -1596,6 +1596,8 @@ static void sdma_7322_p_errors(struct qib_pportdata *ppd, u64 errs)
        struct qib_devdata *dd = ppd->dd;
 
        errs &= QIB_E_P_SDMAERRS;
+       err_decode(ppd->cpspec->sdmamsgbuf, sizeof(ppd->cpspec->sdmamsgbuf),
+                  errs, qib_7322p_error_msgs);
 
        if (errs & QIB_E_P_SDMAUNEXPDATA)
                qib_dev_err(dd, "IB%u:%u SDmaUnexpData\n", dd->unit,
index 32162d355370f95b56970b19da33783052c24c36..9b5322d8cd5accca85737745ba06973ca7212efe 100644 (file)
@@ -717,7 +717,7 @@ void dump_sdma_state(struct qib_pportdata *ppd)
        struct qib_sdma_txreq *txp, *txpnext;
        __le64 *descqp;
        u64 desc[2];
-       dma_addr_t addr;
+       u64 addr;
        u16 gen, dwlen, dwoffset;
        u16 head, tail, cnt;
 
index 2cfa76f5d99eac87bf788eb41bb2a7c3815ec700..196b1d13cbcbc09548e92a4be6c9a18cdc6aae36 100644 (file)
@@ -932,12 +932,47 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
        return 0;
 }
 
+/*
+ * Takes whatever value which is in pkey index 0 and updates priv->pkey
+ * returns 0 if the pkey value was changed.
+ */
+static inline int update_parent_pkey(struct ipoib_dev_priv *priv)
+{
+       int result;
+       u16 prev_pkey;
+
+       prev_pkey = priv->pkey;
+       result = ib_query_pkey(priv->ca, priv->port, 0, &priv->pkey);
+       if (result) {
+               ipoib_warn(priv, "ib_query_pkey port %d failed (ret = %d)\n",
+                          priv->port, result);
+               return result;
+       }
+
+       priv->pkey |= 0x8000;
+
+       if (prev_pkey != priv->pkey) {
+               ipoib_dbg(priv, "pkey changed from 0x%x to 0x%x\n",
+                         prev_pkey, priv->pkey);
+               /*
+                * Update the pkey in the broadcast address, while making sure to set
+                * the full membership bit, so that we join the right broadcast group.
+                */
+               priv->dev->broadcast[8] = priv->pkey >> 8;
+               priv->dev->broadcast[9] = priv->pkey & 0xff;
+               return 0;
+       }
+
+       return 1;
+}
+
 static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
                                enum ipoib_flush_level level)
 {
        struct ipoib_dev_priv *cpriv;
        struct net_device *dev = priv->dev;
        u16 new_index;
+       int result;
 
        mutex_lock(&priv->vlan_mutex);
 
@@ -951,6 +986,10 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
        mutex_unlock(&priv->vlan_mutex);
 
        if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags)) {
+               /* for non-child devices must check/update the pkey value here */
+               if (level == IPOIB_FLUSH_HEAVY &&
+                   !test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags))
+                       update_parent_pkey(priv);
                ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
                return;
        }
@@ -961,21 +1000,32 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
        }
 
        if (level == IPOIB_FLUSH_HEAVY) {
-               if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
-                       clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
-                       ipoib_ib_dev_down(dev, 0);
-                       ipoib_ib_dev_stop(dev, 0);
-                       if (ipoib_pkey_dev_delay_open(dev))
+               /* child devices chase their origin pkey value, while non-child
+                * (parent) devices should always takes what present in pkey index 0
+                */
+               if (test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
+                       if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
+                               clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
+                               ipoib_ib_dev_down(dev, 0);
+                               ipoib_ib_dev_stop(dev, 0);
+                               if (ipoib_pkey_dev_delay_open(dev))
+                                       return;
+                       }
+                       /* restart QP only if P_Key index is changed */
+                       if (test_and_set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags) &&
+                           new_index == priv->pkey_index) {
+                               ipoib_dbg(priv, "Not flushing - P_Key index not changed.\n");
                                return;
+                       }
+                       priv->pkey_index = new_index;
+               } else {
+                       result = update_parent_pkey(priv);
+                       /* restart QP only if P_Key value changed */
+                       if (result) {
+                               ipoib_dbg(priv, "Not flushing - P_Key value not changed.\n");
+                               return;
+                       }
                }
-
-               /* restart QP only if P_Key index is changed */
-               if (test_and_set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags) &&
-                   new_index == priv->pkey_index) {
-                       ipoib_dbg(priv, "Not flushing - P_Key index not changed.\n");
-                       return;
-               }
-               priv->pkey_index = new_index;
        }
 
        if (level == IPOIB_FLUSH_LIGHT) {
index b6e049a3c7a853b92d5c9d126c61a2d850f290cb..c6f71a88c55ca9649b6098cc81d64de229857055 100644 (file)
@@ -1461,7 +1461,7 @@ static ssize_t create_child(struct device *dev,
        if (sscanf(buf, "%i", &pkey) != 1)
                return -EINVAL;
 
-       if (pkey < 0 || pkey > 0xffff)
+       if (pkey <= 0 || pkey > 0xffff || pkey == 0x8000)
                return -EINVAL;
 
        /*
index 74685936c9482be96c09a09e5af6f314bdc2b741..f81abe16cf093d6c74ad31dd179f03f7dc90b997 100644 (file)
@@ -119,6 +119,15 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,
        } else
                child_pkey  = nla_get_u16(data[IFLA_IPOIB_PKEY]);
 
+       if (child_pkey == 0 || child_pkey == 0x8000)
+               return -EINVAL;
+
+       /*
+        * Set the full membership bit, so that we join the right
+        * broadcast group, etc.
+        */
+       child_pkey |= 0x8000;
+
        err = __ipoib_vlan_add(ppriv, netdev_priv(dev), child_pkey, IPOIB_RTNL_CHILD);
 
        if (!err && data)
index 19ceaa60e0f45c755fd67d840e8ee90de320d1ca..ee7c50312066cc4b750ee592fdd2956809eeebd8 100644 (file)
@@ -414,7 +414,7 @@ static void __init gic_dist_init(struct gic_chip_data *gic)
        writel_relaxed(1, base + GIC_DIST_CTRL);
 }
 
-static void __cpuinit gic_cpu_init(struct gic_chip_data *gic)
+static void gic_cpu_init(struct gic_chip_data *gic)
 {
        void __iomem *dist_base = gic_data_dist_base(gic);
        void __iomem *base = gic_data_cpu_base(gic);
@@ -702,8 +702,8 @@ static int gic_irq_domain_xlate(struct irq_domain *d,
 }
 
 #ifdef CONFIG_SMP
-static int __cpuinit gic_secondary_init(struct notifier_block *nfb,
-                                       unsigned long action, void *hcpu)
+static int gic_secondary_init(struct notifier_block *nfb, unsigned long action,
+                             void *hcpu)
 {
        if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
                gic_cpu_init(&gic_data[0]);
@@ -714,7 +714,7 @@ static int __cpuinit gic_secondary_init(struct notifier_block *nfb,
  * Notifier for enabling the GIC CPU interface. Set an arbitrarily high
  * priority because the GIC needs to be up before the ARM generic timers.
  */
-static struct notifier_block __cpuinitdata gic_cpu_notifier = {
+static struct notifier_block gic_cpu_notifier = {
        .notifier_call = gic_secondary_init,
        .priority = 100,
 };
index a7e4939787c957a0f7975c4ea3d8aaaa390e6d2b..7f910c76ca0a340a967737345c7e733e2c4eced4 100644 (file)
@@ -1307,11 +1307,11 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
                }
                if (fifo2 & 2) {
                        hc->hw.fifo_en &= ~HFCPCI_FIFOEN_B2;
-                       hc->hw.int_m1 &= ~(HFCPCI_INTS_B2TRANS +
+                       hc->hw.int_m1 &= ~(HFCPCI_INTS_B2TRANS |
                                           HFCPCI_INTS_B2REC);
                } else {
                        hc->hw.fifo_en &= ~HFCPCI_FIFOEN_B1;
-                       hc->hw.int_m1 &= ~(HFCPCI_INTS_B1TRANS +
+                       hc->hw.int_m1 &= ~(HFCPCI_INTS_B1TRANS |
                                           HFCPCI_INTS_B1REC);
                }
 #ifdef REVERSE_BITORDER
@@ -1346,14 +1346,14 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
                if (fifo2 & 2) {
                        hc->hw.fifo_en |= HFCPCI_FIFOEN_B2;
                        if (!tics)
-                               hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS +
+                               hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS |
                                                  HFCPCI_INTS_B2REC);
                        hc->hw.ctmt |= 2;
                        hc->hw.conn &= ~0x18;
                } else {
                        hc->hw.fifo_en |= HFCPCI_FIFOEN_B1;
                        if (!tics)
-                               hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS +
+                               hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS |
                                                  HFCPCI_INTS_B1REC);
                        hc->hw.ctmt |= 1;
                        hc->hw.conn &= ~0x03;
@@ -1375,14 +1375,14 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
                if (fifo2 & 2) {
                        hc->hw.last_bfifo_cnt[1] = 0;
                        hc->hw.fifo_en |= HFCPCI_FIFOEN_B2;
-                       hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS +
+                       hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS |
                                          HFCPCI_INTS_B2REC);
                        hc->hw.ctmt &= ~2;
                        hc->hw.conn &= ~0x18;
                } else {
                        hc->hw.last_bfifo_cnt[0] = 0;
                        hc->hw.fifo_en |= HFCPCI_FIFOEN_B1;
-                       hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS +
+                       hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS |
                                          HFCPCI_INTS_B1REC);
                        hc->hw.ctmt &= ~1;
                        hc->hw.conn &= ~0x03;
index 0b9a79b2f48aaded2397762ce500b032f25f77e1..82fc86a90c1a436d94ab8500334b62f4cce47dbc 100644 (file)
@@ -439,15 +439,15 @@ static void backside_setup_pid(void)
 
 /* Slots fan */
 static const struct wf_pid_param slots_param = {
-       .interval       = 5,
-       .history_len    = 2,
-       .gd             = 30 << 20,
-       .gp             = 5 << 20,
-       .gr             = 0,
-       .itarget        = 40 << 16,
-       .additive       = 1,
-       .min            = 300,
-       .max            = 4000,
+       .interval       = 1,
+       .history_len    = 20,
+       .gd             = 0,
+       .gp             = 0,
+       .gr             = 0x00100000,
+       .itarget        = 3200000,
+       .additive       = 0,
+       .min            = 20,
+       .max            = 100,
 };
 
 static void slots_fan_tick(void)
index 048f2947e08b1721a6ffab0de2ba5dd24d1a23de..e45f5575fd4dde8d2768daaa553ab57b9d0023b1 100644 (file)
 #include "bcache.h"
 #include "btree.h"
 
+#include <linux/freezer.h>
+#include <linux/kthread.h>
 #include <linux/random.h>
+#include <trace/events/bcache.h>
 
 #define MAX_IN_FLIGHT_DISCARDS         8U
 
@@ -151,7 +154,7 @@ static void discard_finish(struct work_struct *w)
        mutex_unlock(&ca->set->bucket_lock);
 
        closure_wake_up(&ca->set->bucket_wait);
-       wake_up(&ca->set->alloc_wait);
+       wake_up_process(ca->alloc_thread);
 
        closure_put(&ca->set->cl);
 }
@@ -350,38 +353,30 @@ static void invalidate_buckets(struct cache *ca)
                break;
        }
 
-       pr_debug("free %zu/%zu free_inc %zu/%zu unused %zu/%zu",
-                fifo_used(&ca->free), ca->free.size,
-                fifo_used(&ca->free_inc), ca->free_inc.size,
-                fifo_used(&ca->unused), ca->unused.size);
+       trace_bcache_alloc_invalidate(ca);
 }
 
 #define allocator_wait(ca, cond)                                       \
 do {                                                                   \
-       DEFINE_WAIT(__wait);                                            \
-                                                                       \
        while (1) {                                                     \
-               prepare_to_wait(&ca->set->alloc_wait,                   \
-                               &__wait, TASK_INTERRUPTIBLE);           \
+               set_current_state(TASK_INTERRUPTIBLE);                  \
                if (cond)                                               \
                        break;                                          \
                                                                        \
                mutex_unlock(&(ca)->set->bucket_lock);                  \
-               if (test_bit(CACHE_SET_STOPPING_2, &ca->set->flags)) {  \
-                       finish_wait(&ca->set->alloc_wait, &__wait);     \
-                       closure_return(cl);                             \
-               }                                                       \
+               if (kthread_should_stop())                              \
+                       return 0;                                       \
                                                                        \
+               try_to_freeze();                                        \
                schedule();                                             \
                mutex_lock(&(ca)->set->bucket_lock);                    \
        }                                                               \
-                                                                       \
-       finish_wait(&ca->set->alloc_wait, &__wait);                     \
+       __set_current_state(TASK_RUNNING);                              \
 } while (0)
 
-void bch_allocator_thread(struct closure *cl)
+static int bch_allocator_thread(void *arg)
 {
-       struct cache *ca = container_of(cl, struct cache, alloc);
+       struct cache *ca = arg;
 
        mutex_lock(&ca->set->bucket_lock);
 
@@ -442,7 +437,7 @@ long bch_bucket_alloc(struct cache *ca, unsigned watermark, struct closure *cl)
 {
        long r = -1;
 again:
-       wake_up(&ca->set->alloc_wait);
+       wake_up_process(ca->alloc_thread);
 
        if (fifo_used(&ca->free) > ca->watermark[watermark] &&
            fifo_pop(&ca->free, r)) {
@@ -476,9 +471,7 @@ again:
                return r;
        }
 
-       pr_debug("alloc failure: blocked %i free %zu free_inc %zu unused %zu",
-                atomic_read(&ca->set->prio_blocked), fifo_used(&ca->free),
-                fifo_used(&ca->free_inc), fifo_used(&ca->unused));
+       trace_bcache_alloc_fail(ca);
 
        if (cl) {
                closure_wait(&ca->set->bucket_wait, cl);
@@ -552,6 +545,17 @@ int bch_bucket_alloc_set(struct cache_set *c, unsigned watermark,
 
 /* Init */
 
+int bch_cache_allocator_start(struct cache *ca)
+{
+       struct task_struct *k = kthread_run(bch_allocator_thread,
+                                           ca, "bcache_allocator");
+       if (IS_ERR(k))
+               return PTR_ERR(k);
+
+       ca->alloc_thread = k;
+       return 0;
+}
+
 void bch_cache_allocator_exit(struct cache *ca)
 {
        struct discard *d;
index d3e15b42a4ab97655d989c3fe8240b09613acdc4..b39f6f0b45f27b89f29e580844e41d8d315d9c18 100644 (file)
 #define pr_fmt(fmt) "bcache: %s() " fmt "\n", __func__
 
 #include <linux/bio.h>
-#include <linux/blktrace_api.h>
 #include <linux/kobject.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
@@ -388,8 +387,6 @@ struct keybuf_key {
 typedef bool (keybuf_pred_fn)(struct keybuf *, struct bkey *);
 
 struct keybuf {
-       keybuf_pred_fn          *key_predicate;
-
        struct bkey             last_scanned;
        spinlock_t              lock;
 
@@ -437,9 +434,12 @@ struct bcache_device {
 
        /* If nonzero, we're detaching/unregistering from cache set */
        atomic_t                detaching;
+       int                     flush_done;
+
+       uint64_t                nr_stripes;
+       unsigned                stripe_size_bits;
+       atomic_t                *stripe_sectors_dirty;
 
-       atomic_long_t           sectors_dirty;
-       unsigned long           sectors_dirty_gc;
        unsigned long           sectors_dirty_last;
        long                    sectors_dirty_derivative;
 
@@ -531,6 +531,7 @@ struct cached_dev {
        unsigned                sequential_merge:1;
        unsigned                verify:1;
 
+       unsigned                partial_stripes_expensive:1;
        unsigned                writeback_metadata:1;
        unsigned                writeback_running:1;
        unsigned char           writeback_percent;
@@ -565,8 +566,7 @@ struct cache {
 
        unsigned                watermark[WATERMARK_MAX];
 
-       struct closure          alloc;
-       struct workqueue_struct *alloc_workqueue;
+       struct task_struct      *alloc_thread;
 
        struct closure          prio;
        struct prio_set         *disk_buckets;
@@ -664,13 +664,9 @@ struct gc_stat {
  * CACHE_SET_STOPPING always gets set first when we're closing down a cache set;
  * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e.
  * flushing dirty data).
- *
- * CACHE_SET_STOPPING_2 gets set at the last phase, when it's time to shut down
- * the allocation thread.
  */
 #define CACHE_SET_UNREGISTERING                0
 #define        CACHE_SET_STOPPING              1
-#define        CACHE_SET_STOPPING_2            2
 
 struct cache_set {
        struct closure          cl;
@@ -703,9 +699,6 @@ struct cache_set {
        /* For the btree cache */
        struct shrinker         shrink;
 
-       /* For the allocator itself */
-       wait_queue_head_t       alloc_wait;
-
        /* For the btree cache and anything allocation related */
        struct mutex            bucket_lock;
 
@@ -823,10 +816,9 @@ struct cache_set {
 
        /*
         * A btree node on disk could have too many bsets for an iterator to fit
-        * on the stack - this is a single element mempool for btree_read_work()
+        * on the stack - have to dynamically allocate them
         */
-       struct mutex            fill_lock;
-       struct btree_iter       *fill_iter;
+       mempool_t               *fill_iter;
 
        /*
         * btree_sort() is a merge sort and requires temporary space - single
@@ -834,6 +826,7 @@ struct cache_set {
         */
        struct mutex            sort_lock;
        struct bset             *sort;
+       unsigned                sort_crit_factor;
 
        /* List of buckets we're currently writing data to */
        struct list_head        data_buckets;
@@ -906,8 +899,6 @@ static inline unsigned local_clock_us(void)
        return local_clock() >> 10;
 }
 
-#define MAX_BSETS              4U
-
 #define BTREE_PRIO             USHRT_MAX
 #define INITIAL_PRIO           32768
 
@@ -1112,23 +1103,6 @@ static inline void __bkey_put(struct cache_set *c, struct bkey *k)
                atomic_dec_bug(&PTR_BUCKET(c, k, i)->pin);
 }
 
-/* Blktrace macros */
-
-#define blktrace_msg(c, fmt, ...)                                      \
-do {                                                                   \
-       struct request_queue *q = bdev_get_queue(c->bdev);              \
-       if (q)                                                          \
-               blk_add_trace_msg(q, fmt, ##__VA_ARGS__);               \
-} while (0)
-
-#define blktrace_msg_all(s, fmt, ...)                                  \
-do {                                                                   \
-       struct cache *_c;                                               \
-       unsigned i;                                                     \
-       for_each_cache(_c, (s), i)                                      \
-               blktrace_msg(_c, fmt, ##__VA_ARGS__);                   \
-} while (0)
-
 static inline void cached_dev_put(struct cached_dev *dc)
 {
        if (atomic_dec_and_test(&dc->count))
@@ -1173,10 +1147,16 @@ static inline uint8_t bucket_disk_gen(struct bucket *b)
        static struct kobj_attribute ksysfs_##n =                       \
                __ATTR(n, S_IWUSR|S_IRUSR, show, store)
 
-/* Forward declarations */
+static inline void wake_up_allocators(struct cache_set *c)
+{
+       struct cache *ca;
+       unsigned i;
+
+       for_each_cache(ca, c, i)
+               wake_up_process(ca->alloc_thread);
+}
 
-void bch_writeback_queue(struct cached_dev *);
-void bch_writeback_add(struct cached_dev *, unsigned);
+/* Forward declarations */
 
 void bch_count_io_errors(struct cache *, int, const char *);
 void bch_bbio_count_io_errors(struct cache_set *, struct bio *,
@@ -1193,7 +1173,6 @@ void bch_submit_bbio(struct bio *, struct cache_set *, struct bkey *, unsigned);
 uint8_t bch_inc_gen(struct cache *, struct bucket *);
 void bch_rescale_priorities(struct cache_set *, int);
 bool bch_bucket_add_unused(struct cache *, struct bucket *);
-void bch_allocator_thread(struct closure *);
 
 long bch_bucket_alloc(struct cache *, unsigned, struct closure *);
 void bch_bucket_free(struct cache_set *, struct bkey *);
@@ -1241,9 +1220,9 @@ void bch_cache_set_stop(struct cache_set *);
 struct cache_set *bch_cache_set_alloc(struct cache_sb *);
 void bch_btree_cache_free(struct cache_set *);
 int bch_btree_cache_alloc(struct cache_set *);
-void bch_cached_dev_writeback_init(struct cached_dev *);
 void bch_moving_init_cache_set(struct cache_set *);
 
+int bch_cache_allocator_start(struct cache *ca);
 void bch_cache_allocator_exit(struct cache *ca);
 int bch_cache_allocator_init(struct cache *ca);
 
index 1d27d3af32514055e7512a677395c709a713c28c..8010eed06a51c8320786a1c49463c98c8aa70555 100644 (file)
@@ -78,6 +78,7 @@ struct bkey *bch_keylist_pop(struct keylist *l)
 bool __bch_ptr_invalid(struct cache_set *c, int level, const struct bkey *k)
 {
        unsigned i;
+       char buf[80];
 
        if (level && (!KEY_PTRS(k) || !KEY_SIZE(k) || KEY_DIRTY(k)))
                goto bad;
@@ -102,7 +103,8 @@ bool __bch_ptr_invalid(struct cache_set *c, int level, const struct bkey *k)
 
        return false;
 bad:
-       cache_bug(c, "spotted bad key %s: %s", pkey(k), bch_ptr_status(c, k));
+       bch_bkey_to_text(buf, sizeof(buf), k);
+       cache_bug(c, "spotted bad key %s: %s", buf, bch_ptr_status(c, k));
        return true;
 }
 
@@ -162,10 +164,16 @@ bool bch_ptr_bad(struct btree *b, const struct bkey *k)
 #ifdef CONFIG_BCACHE_EDEBUG
 bug:
        mutex_unlock(&b->c->bucket_lock);
-       btree_bug(b,
+
+       {
+               char buf[80];
+
+               bch_bkey_to_text(buf, sizeof(buf), k);
+               btree_bug(b,
 "inconsistent pointer %s: bucket %zu pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i",
-                 pkey(k), PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin),
-                 g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen);
+                         buf, PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin),
+                         g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen);
+       }
        return true;
 #endif
 }
@@ -1084,33 +1092,39 @@ void bch_btree_sort_into(struct btree *b, struct btree *new)
        new->sets->size = 0;
 }
 
+#define SORT_CRIT      (4096 / sizeof(uint64_t))
+
 void bch_btree_sort_lazy(struct btree *b)
 {
-       if (b->nsets) {
-               unsigned i, j, keys = 0, total;
+       unsigned crit = SORT_CRIT;
+       int i;
 
-               for (i = 0; i <= b->nsets; i++)
-                       keys += b->sets[i].data->keys;
-
-               total = keys;
+       /* Don't sort if nothing to do */
+       if (!b->nsets)
+               goto out;
 
-               for (j = 0; j < b->nsets; j++) {
-                       if (keys * 2 < total ||
-                           keys < 1000) {
-                               bch_btree_sort_partial(b, j);
-                               return;
-                       }
+       /* If not a leaf node, always sort */
+       if (b->level) {
+               bch_btree_sort(b);
+               return;
+       }
 
-                       keys -= b->sets[j].data->keys;
-               }
+       for (i = b->nsets - 1; i >= 0; --i) {
+               crit *= b->c->sort_crit_factor;
 
-               /* Must sort if b->nsets == 3 or we'll overflow */
-               if (b->nsets >= (MAX_BSETS - 1) - b->level) {
-                       bch_btree_sort(b);
+               if (b->sets[i].data->keys < crit) {
+                       bch_btree_sort_partial(b, i);
                        return;
                }
        }
 
+       /* Sort if we'd overflow */
+       if (b->nsets + 1 == MAX_BSETS) {
+               bch_btree_sort(b);
+               return;
+       }
+
+out:
        bset_build_written_tree(b);
 }
 
index 57a9cff4154613900f31307ee33015527f953d87..ae115a253d7312f81422a4b162e2ca4952556a44 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _BCACHE_BSET_H
 #define _BCACHE_BSET_H
 
+#include <linux/slab.h>
+
 /*
  * BKEYS:
  *
 
 /* Btree key comparison/iteration */
 
+#define MAX_BSETS              4U
+
 struct btree_iter {
        size_t size, used;
        struct btree_iter_set {
index 7a5658f04e62092610b2144faab12ae5fa3976a0..ee372884c405444886671901e45c3834626f383a 100644 (file)
@@ -24,6 +24,7 @@
 #include "btree.h"
 #include "debug.h"
 #include "request.h"
+#include "writeback.h"
 
 #include <linux/slab.h>
 #include <linux/bitops.h>
@@ -134,44 +135,17 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
        return crc ^ 0xffffffffffffffffULL;
 }
 
-static void btree_bio_endio(struct bio *bio, int error)
+static void bch_btree_node_read_done(struct btree *b)
 {
-       struct closure *cl = bio->bi_private;
-       struct btree *b = container_of(cl, struct btree, io.cl);
-
-       if (error)
-               set_btree_node_io_error(b);
-
-       bch_bbio_count_io_errors(b->c, bio, error, (bio->bi_rw & WRITE)
-                                ? "writing btree" : "reading btree");
-       closure_put(cl);
-}
-
-static void btree_bio_init(struct btree *b)
-{
-       BUG_ON(b->bio);
-       b->bio = bch_bbio_alloc(b->c);
-
-       b->bio->bi_end_io       = btree_bio_endio;
-       b->bio->bi_private      = &b->io.cl;
-}
-
-void bch_btree_read_done(struct closure *cl)
-{
-       struct btree *b = container_of(cl, struct btree, io.cl);
-       struct bset *i = b->sets[0].data;
-       struct btree_iter *iter = b->c->fill_iter;
        const char *err = "bad btree header";
-       BUG_ON(b->nsets || b->written);
-
-       bch_bbio_free(b->bio, b->c);
-       b->bio = NULL;
+       struct bset *i = b->sets[0].data;
+       struct btree_iter *iter;
 
-       mutex_lock(&b->c->fill_lock);
+       iter = mempool_alloc(b->c->fill_iter, GFP_NOWAIT);
+       iter->size = b->c->sb.bucket_size / b->c->sb.block_size;
        iter->used = 0;
 
-       if (btree_node_io_error(b) ||
-           !i->seq)
+       if (!i->seq)
                goto err;
 
        for (;
@@ -228,17 +202,8 @@ void bch_btree_read_done(struct closure *cl)
        if (b->written < btree_blocks(b))
                bch_bset_init_next(b);
 out:
-
-       mutex_unlock(&b->c->fill_lock);
-
-       spin_lock(&b->c->btree_read_time_lock);
-       bch_time_stats_update(&b->c->btree_read_time, b->io_start_time);
-       spin_unlock(&b->c->btree_read_time_lock);
-
-       smp_wmb(); /* read_done is our write lock */
-       set_btree_node_read_done(b);
-
-       closure_return(cl);
+       mempool_free(iter, b->c->fill_iter);
+       return;
 err:
        set_btree_node_io_error(b);
        bch_cache_set_error(b->c, "%s at bucket %zu, block %zu, %u keys",
@@ -247,48 +212,69 @@ err:
        goto out;
 }
 
-void bch_btree_read(struct btree *b)
+static void btree_node_read_endio(struct bio *bio, int error)
+{
+       struct closure *cl = bio->bi_private;
+       closure_put(cl);
+}
+
+void bch_btree_node_read(struct btree *b)
 {
-       BUG_ON(b->nsets || b->written);
+       uint64_t start_time = local_clock();
+       struct closure cl;
+       struct bio *bio;
+
+       trace_bcache_btree_read(b);
+
+       closure_init_stack(&cl);
+
+       bio = bch_bbio_alloc(b->c);
+       bio->bi_rw      = REQ_META|READ_SYNC;
+       bio->bi_size    = KEY_SIZE(&b->key) << 9;
+       bio->bi_end_io  = btree_node_read_endio;
+       bio->bi_private = &cl;
+
+       bch_bio_map(bio, b->sets[0].data);
+
+       bch_submit_bbio(bio, b->c, &b->key, 0);
+       closure_sync(&cl);
 
-       if (!closure_trylock(&b->io.cl, &b->c->cl))
-               BUG();
+       if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
+               set_btree_node_io_error(b);
 
-       b->io_start_time = local_clock();
+       bch_bbio_free(bio, b->c);
 
-       btree_bio_init(b);
-       b->bio->bi_rw   = REQ_META|READ_SYNC;
-       b->bio->bi_size = KEY_SIZE(&b->key) << 9;
+       if (btree_node_io_error(b))
+               goto err;
 
-       bch_bio_map(b->bio, b->sets[0].data);
+       bch_btree_node_read_done(b);
 
-       pr_debug("%s", pbtree(b));
-       trace_bcache_btree_read(b->bio);
-       bch_submit_bbio(b->bio, b->c, &b->key, 0);
+       spin_lock(&b->c->btree_read_time_lock);
+       bch_time_stats_update(&b->c->btree_read_time, start_time);
+       spin_unlock(&b->c->btree_read_time_lock);
 
-       continue_at(&b->io.cl, bch_btree_read_done, system_wq);
+       return;
+err:
+       bch_cache_set_error(b->c, "io error reading bucket %lu",
+                           PTR_BUCKET_NR(b->c, &b->key, 0));
 }
 
 static void btree_complete_write(struct btree *b, struct btree_write *w)
 {
        if (w->prio_blocked &&
            !atomic_sub_return(w->prio_blocked, &b->c->prio_blocked))
-               wake_up(&b->c->alloc_wait);
+               wake_up_allocators(b->c);
 
        if (w->journal) {
                atomic_dec_bug(w->journal);
                __closure_wake_up(&b->c->journal.wait);
        }
 
-       if (w->owner)
-               closure_put(w->owner);
-
        w->prio_blocked = 0;
        w->journal      = NULL;
-       w->owner        = NULL;
 }
 
-static void __btree_write_done(struct closure *cl)
+static void __btree_node_write_done(struct closure *cl)
 {
        struct btree *b = container_of(cl, struct btree, io.cl);
        struct btree_write *w = btree_prev_write(b);
@@ -304,7 +290,7 @@ static void __btree_write_done(struct closure *cl)
        closure_return(cl);
 }
 
-static void btree_write_done(struct closure *cl)
+static void btree_node_write_done(struct closure *cl)
 {
        struct btree *b = container_of(cl, struct btree, io.cl);
        struct bio_vec *bv;
@@ -313,10 +299,22 @@ static void btree_write_done(struct closure *cl)
        __bio_for_each_segment(bv, b->bio, n, 0)
                __free_page(bv->bv_page);
 
-       __btree_write_done(cl);
+       __btree_node_write_done(cl);
 }
 
-static void do_btree_write(struct btree *b)
+static void btree_node_write_endio(struct bio *bio, int error)
+{
+       struct closure *cl = bio->bi_private;
+       struct btree *b = container_of(cl, struct btree, io.cl);
+
+       if (error)
+               set_btree_node_io_error(b);
+
+       bch_bbio_count_io_errors(b->c, bio, error, "writing btree");
+       closure_put(cl);
+}
+
+static void do_btree_node_write(struct btree *b)
 {
        struct closure *cl = &b->io.cl;
        struct bset *i = b->sets[b->nsets].data;
@@ -325,15 +323,34 @@ static void do_btree_write(struct btree *b)
        i->version      = BCACHE_BSET_VERSION;
        i->csum         = btree_csum_set(b, i);
 
-       btree_bio_init(b);
-       b->bio->bi_rw   = REQ_META|WRITE_SYNC;
-       b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c);
+       BUG_ON(b->bio);
+       b->bio = bch_bbio_alloc(b->c);
+
+       b->bio->bi_end_io       = btree_node_write_endio;
+       b->bio->bi_private      = &b->io.cl;
+       b->bio->bi_rw           = REQ_META|WRITE_SYNC|REQ_FUA;
+       b->bio->bi_size         = set_blocks(i, b->c) * block_bytes(b->c);
        bch_bio_map(b->bio, i);
 
+       /*
+        * If we're appending to a leaf node, we don't technically need FUA -
+        * this write just needs to be persisted before the next journal write,
+        * which will be marked FLUSH|FUA.
+        *
+        * Similarly if we're writing a new btree root - the pointer is going to
+        * be in the next journal entry.
+        *
+        * But if we're writing a new btree node (that isn't a root) or
+        * appending to a non leaf btree node, we need either FUA or a flush
+        * when we write the parent with the new pointer. FUA is cheaper than a
+        * flush, and writes appending to leaf nodes aren't blocking anything so
+        * just make all btree node writes FUA to keep things sane.
+        */
+
        bkey_copy(&k.key, &b->key);
        SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i));
 
-       if (!bch_bio_alloc_pages(b->bio, GFP_NOIO)) {
+       if (!bio_alloc_pages(b->bio, GFP_NOIO)) {
                int j;
                struct bio_vec *bv;
                void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
@@ -342,40 +359,41 @@ static void do_btree_write(struct btree *b)
                        memcpy(page_address(bv->bv_page),
                               base + j * PAGE_SIZE, PAGE_SIZE);
 
-               trace_bcache_btree_write(b->bio);
                bch_submit_bbio(b->bio, b->c, &k.key, 0);
 
-               continue_at(cl, btree_write_done, NULL);
+               continue_at(cl, btree_node_write_done, NULL);
        } else {
                b->bio->bi_vcnt = 0;
                bch_bio_map(b->bio, i);
 
-               trace_bcache_btree_write(b->bio);
                bch_submit_bbio(b->bio, b->c, &k.key, 0);
 
                closure_sync(cl);
-               __btree_write_done(cl);
+               __btree_node_write_done(cl);
        }
 }
 
-static void __btree_write(struct btree *b)
+void bch_btree_node_write(struct btree *b, struct closure *parent)
 {
        struct bset *i = b->sets[b->nsets].data;
 
+       trace_bcache_btree_write(b);
+
        BUG_ON(current->bio_list);
+       BUG_ON(b->written >= btree_blocks(b));
+       BUG_ON(b->written && !i->keys);
+       BUG_ON(b->sets->data->seq != i->seq);
+       bch_check_key_order(b, i);
 
-       closure_lock(&b->io, &b->c->cl);
        cancel_delayed_work(&b->work);
 
+       /* If caller isn't waiting for write, parent refcount is cache set */
+       closure_lock(&b->io, parent ?: &b->c->cl);
+
        clear_bit(BTREE_NODE_dirty,      &b->flags);
        change_bit(BTREE_NODE_write_idx, &b->flags);
 
-       bch_check_key_order(b, i);
-       BUG_ON(b->written && !i->keys);
-
-       do_btree_write(b);
-
-       pr_debug("%s block %i keys %i", pbtree(b), b->written, i->keys);
+       do_btree_node_write(b);
 
        b->written += set_blocks(i, b->c);
        atomic_long_add(set_blocks(i, b->c) * b->c->sb.block_size,
@@ -387,37 +405,31 @@ static void __btree_write(struct btree *b)
                bch_bset_init_next(b);
 }
 
-static void btree_write_work(struct work_struct *w)
+static void btree_node_write_work(struct work_struct *w)
 {
        struct btree *b = container_of(to_delayed_work(w), struct btree, work);
 
-       down_write(&b->lock);
+       rw_lock(true, b, b->level);
 
        if (btree_node_dirty(b))
-               __btree_write(b);
-       up_write(&b->lock);
+               bch_btree_node_write(b, NULL);
+       rw_unlock(true, b);
 }
 
-void bch_btree_write(struct btree *b, bool now, struct btree_op *op)
+static void bch_btree_leaf_dirty(struct btree *b, struct btree_op *op)
 {
        struct bset *i = b->sets[b->nsets].data;
        struct btree_write *w = btree_current_write(b);
 
-       BUG_ON(b->written &&
-              (b->written >= btree_blocks(b) ||
-               i->seq != b->sets[0].data->seq ||
-               !i->keys));
+       BUG_ON(!b->written);
+       BUG_ON(!i->keys);
 
-       if (!btree_node_dirty(b)) {
-               set_btree_node_dirty(b);
-               queue_delayed_work(btree_io_wq, &b->work,
-                                  msecs_to_jiffies(30000));
-       }
+       if (!btree_node_dirty(b))
+               queue_delayed_work(btree_io_wq, &b->work, 30 * HZ);
 
-       w->prio_blocked += b->prio_blocked;
-       b->prio_blocked = 0;
+       set_btree_node_dirty(b);
 
-       if (op && op->journal && !b->level) {
+       if (op && op->journal) {
                if (w->journal &&
                    journal_pin_cmp(b->c, w, op)) {
                        atomic_dec_bug(w->journal);
@@ -430,23 +442,10 @@ void bch_btree_write(struct btree *b, bool now, struct btree_op *op)
                }
        }
 
-       if (current->bio_list)
-               return;
-
        /* Force write if set is too big */
-       if (now ||
-           b->level ||
-           set_bytes(i) > PAGE_SIZE - 48) {
-               if (op && now) {
-                       /* Must wait on multiple writes */
-                       BUG_ON(w->owner);
-                       w->owner = &op->cl;
-                       closure_get(&op->cl);
-               }
-
-               __btree_write(b);
-       }
-       BUG_ON(!b->written);
+       if (set_bytes(i) > PAGE_SIZE - 48 &&
+           !current->bio_list)
+               bch_btree_node_write(b, NULL);
 }
 
 /*
@@ -559,7 +558,7 @@ static struct btree *mca_bucket_alloc(struct cache_set *c,
        init_rwsem(&b->lock);
        lockdep_set_novalidate_class(&b->lock);
        INIT_LIST_HEAD(&b->list);
-       INIT_DELAYED_WORK(&b->work, btree_write_work);
+       INIT_DELAYED_WORK(&b->work, btree_node_write_work);
        b->c = c;
        closure_init_unlocked(&b->io);
 
@@ -582,7 +581,7 @@ static int mca_reap(struct btree *b, struct closure *cl, unsigned min_order)
        BUG_ON(btree_node_dirty(b) && !b->sets[0].data);
 
        if (cl && btree_node_dirty(b))
-               bch_btree_write(b, true, NULL);
+               bch_btree_node_write(b, NULL);
 
        if (cl)
                closure_wait_event_async(&b->io.wait, cl,
@@ -623,6 +622,13 @@ static int bch_mca_shrink(struct shrinker *shrink, struct shrink_control *sc)
        else if (!mutex_trylock(&c->bucket_lock))
                return -1;
 
+       /*
+        * It's _really_ critical that we don't free too many btree nodes - we
+        * have to always leave ourselves a reserve. The reserve is how we
+        * guarantee that allocating memory for a new btree node can always
+        * succeed, so that inserting keys into the btree can always succeed and
+        * IO can always make forward progress:
+        */
        nr /= c->btree_pages;
        nr = min_t(unsigned long, nr, mca_can_free(c));
 
@@ -766,6 +772,8 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct bkey *k,
        int ret = -ENOMEM;
        struct btree *i;
 
+       trace_bcache_btree_cache_cannibalize(c);
+
        if (!cl)
                return ERR_PTR(-ENOMEM);
 
@@ -784,7 +792,6 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct bkey *k,
                return ERR_PTR(-EAGAIN);
        }
 
-       /* XXX: tracepoint */
        c->try_harder = cl;
        c->try_harder_start = local_clock();
 retry:
@@ -905,6 +912,9 @@ retry:
        b = mca_find(c, k);
 
        if (!b) {
+               if (current->bio_list)
+                       return ERR_PTR(-EAGAIN);
+
                mutex_lock(&c->bucket_lock);
                b = mca_alloc(c, k, level, &op->cl);
                mutex_unlock(&c->bucket_lock);
@@ -914,7 +924,7 @@ retry:
                if (IS_ERR(b))
                        return b;
 
-               bch_btree_read(b);
+               bch_btree_node_read(b);
 
                if (!write)
                        downgrade_write(&b->lock);
@@ -937,15 +947,12 @@ retry:
        for (; i <= b->nsets; i++)
                prefetch(b->sets[i].data);
 
-       if (!closure_wait_event(&b->io.wait, &op->cl,
-                               btree_node_read_done(b))) {
-               rw_unlock(write, b);
-               b = ERR_PTR(-EAGAIN);
-       } else if (btree_node_io_error(b)) {
+       if (btree_node_io_error(b)) {
                rw_unlock(write, b);
-               b = ERR_PTR(-EIO);
-       } else
-               BUG_ON(!b->written);
+               return ERR_PTR(-EIO);
+       }
+
+       BUG_ON(!b->written);
 
        return b;
 }
@@ -959,7 +966,7 @@ static void btree_node_prefetch(struct cache_set *c, struct bkey *k, int level)
        mutex_unlock(&c->bucket_lock);
 
        if (!IS_ERR_OR_NULL(b)) {
-               bch_btree_read(b);
+               bch_btree_node_read(b);
                rw_unlock(true, b);
        }
 }
@@ -970,24 +977,19 @@ static void btree_node_free(struct btree *b, struct btree_op *op)
 {
        unsigned i;
 
+       trace_bcache_btree_node_free(b);
+
        /*
         * The BUG_ON() in btree_node_get() implies that we must have a write
         * lock on parent to free or even invalidate a node
         */
        BUG_ON(op->lock <= b->level);
        BUG_ON(b == b->c->root);
-       pr_debug("bucket %s", pbtree(b));
 
        if (btree_node_dirty(b))
                btree_complete_write(b, btree_current_write(b));
        clear_bit(BTREE_NODE_dirty, &b->flags);
 
-       if (b->prio_blocked &&
-           !atomic_sub_return(b->prio_blocked, &b->c->prio_blocked))
-               wake_up(&b->c->alloc_wait);
-
-       b->prio_blocked = 0;
-
        cancel_delayed_work(&b->work);
 
        mutex_lock(&b->c->bucket_lock);
@@ -1028,17 +1030,20 @@ retry:
                goto retry;
        }
 
-       set_btree_node_read_done(b);
        b->accessed = 1;
        bch_bset_init_next(b);
 
        mutex_unlock(&c->bucket_lock);
+
+       trace_bcache_btree_node_alloc(b);
        return b;
 err_free:
        bch_bucket_free(c, &k.key);
        __bkey_put(c, &k.key);
 err:
        mutex_unlock(&c->bucket_lock);
+
+       trace_bcache_btree_node_alloc_fail(b);
        return b;
 }
 
@@ -1137,11 +1142,8 @@ static int btree_gc_mark_node(struct btree *b, unsigned *keys,
                gc->nkeys++;
 
                gc->data += KEY_SIZE(k);
-               if (KEY_DIRTY(k)) {
+               if (KEY_DIRTY(k))
                        gc->dirty += KEY_SIZE(k);
-                       if (d)
-                               d->sectors_dirty_gc += KEY_SIZE(k);
-               }
        }
 
        for (t = b->sets; t <= &b->sets[b->nsets]; t++)
@@ -1166,14 +1168,11 @@ static struct btree *btree_gc_alloc(struct btree *b, struct bkey *k,
 
        if (!IS_ERR_OR_NULL(n)) {
                swap(b, n);
+               __bkey_put(b->c, &b->key);
 
                memcpy(k->ptr, b->key.ptr,
                       sizeof(uint64_t) * KEY_PTRS(&b->key));
 
-               __bkey_put(b->c, &b->key);
-               atomic_inc(&b->c->prio_blocked);
-               b->prio_blocked++;
-
                btree_node_free(n, op);
                up_write(&n->lock);
        }
@@ -1278,7 +1277,7 @@ static void btree_gc_coalesce(struct btree *b, struct btree_op *op,
        btree_node_free(r->b, op);
        up_write(&r->b->lock);
 
-       pr_debug("coalesced %u nodes", nodes);
+       trace_bcache_btree_gc_coalesce(nodes);
 
        gc->nodes--;
        nodes--;
@@ -1293,14 +1292,9 @@ static int btree_gc_recurse(struct btree *b, struct btree_op *op,
        void write(struct btree *r)
        {
                if (!r->written)
-                       bch_btree_write(r, true, op);
-               else if (btree_node_dirty(r)) {
-                       BUG_ON(btree_current_write(r)->owner);
-                       btree_current_write(r)->owner = writes;
-                       closure_get(writes);
-
-                       bch_btree_write(r, true, NULL);
-               }
+                       bch_btree_node_write(r, &op->cl);
+               else if (btree_node_dirty(r))
+                       bch_btree_node_write(r, writes);
 
                up_write(&r->lock);
        }
@@ -1386,9 +1380,7 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op,
                ret = btree_gc_recurse(b, op, writes, gc);
 
        if (!b->written || btree_node_dirty(b)) {
-               atomic_inc(&b->c->prio_blocked);
-               b->prio_blocked++;
-               bch_btree_write(b, true, n ? op : NULL);
+               bch_btree_node_write(b, n ? &op->cl : NULL);
        }
 
        if (!IS_ERR_OR_NULL(n)) {
@@ -1405,7 +1397,6 @@ static void btree_gc_start(struct cache_set *c)
 {
        struct cache *ca;
        struct bucket *b;
-       struct bcache_device **d;
        unsigned i;
 
        if (!c->gc_mark_valid)
@@ -1419,16 +1410,12 @@ static void btree_gc_start(struct cache_set *c)
        for_each_cache(ca, c, i)
                for_each_bucket(b, ca) {
                        b->gc_gen = b->gen;
-                       if (!atomic_read(&b->pin))
+                       if (!atomic_read(&b->pin)) {
                                SET_GC_MARK(b, GC_MARK_RECLAIMABLE);
+                               SET_GC_SECTORS_USED(b, 0);
+                       }
                }
 
-       for (d = c->devices;
-            d < c->devices + c->nr_uuids;
-            d++)
-               if (*d)
-                       (*d)->sectors_dirty_gc = 0;
-
        mutex_unlock(&c->bucket_lock);
 }
 
@@ -1437,7 +1424,6 @@ size_t bch_btree_gc_finish(struct cache_set *c)
        size_t available = 0;
        struct bucket *b;
        struct cache *ca;
-       struct bcache_device **d;
        unsigned i;
 
        mutex_lock(&c->bucket_lock);
@@ -1480,22 +1466,6 @@ size_t bch_btree_gc_finish(struct cache_set *c)
                }
        }
 
-       for (d = c->devices;
-            d < c->devices + c->nr_uuids;
-            d++)
-               if (*d) {
-                       unsigned long last =
-                               atomic_long_read(&((*d)->sectors_dirty));
-                       long difference = (*d)->sectors_dirty_gc - last;
-
-                       pr_debug("sectors dirty off by %li", difference);
-
-                       (*d)->sectors_dirty_last += difference;
-
-                       atomic_long_set(&((*d)->sectors_dirty),
-                                       (*d)->sectors_dirty_gc);
-               }
-
        mutex_unlock(&c->bucket_lock);
        return available;
 }
@@ -1508,10 +1478,9 @@ static void bch_btree_gc(struct closure *cl)
        struct gc_stat stats;
        struct closure writes;
        struct btree_op op;
-
        uint64_t start_time = local_clock();
-       trace_bcache_gc_start(c->sb.set_uuid);
-       blktrace_msg_all(c, "Starting gc");
+
+       trace_bcache_gc_start(c);
 
        memset(&stats, 0, sizeof(struct gc_stat));
        closure_init_stack(&writes);
@@ -1520,14 +1489,14 @@ static void bch_btree_gc(struct closure *cl)
 
        btree_gc_start(c);
 
+       atomic_inc(&c->prio_blocked);
+
        ret = btree_root(gc_root, c, &op, &writes, &stats);
        closure_sync(&op.cl);
        closure_sync(&writes);
 
        if (ret) {
-               blktrace_msg_all(c, "Stopped gc");
                pr_warn("gc failed!");
-
                continue_at(cl, bch_btree_gc, bch_gc_wq);
        }
 
@@ -1537,6 +1506,9 @@ static void bch_btree_gc(struct closure *cl)
 
        available = bch_btree_gc_finish(c);
 
+       atomic_dec(&c->prio_blocked);
+       wake_up_allocators(c);
+
        bch_time_stats_update(&c->btree_gc_time, start_time);
 
        stats.key_bytes *= sizeof(uint64_t);
@@ -1544,10 +1516,8 @@ static void bch_btree_gc(struct closure *cl)
        stats.data      <<= 9;
        stats.in_use    = (c->nbuckets - available) * 100 / c->nbuckets;
        memcpy(&c->gc_stats, &stats, sizeof(struct gc_stat));
-       blktrace_msg_all(c, "Finished gc");
 
-       trace_bcache_gc_end(c->sb.set_uuid);
-       wake_up(&c->alloc_wait);
+       trace_bcache_gc_end(c);
 
        continue_at(cl, bch_moving_gc, bch_gc_wq);
 }
@@ -1654,14 +1624,14 @@ static bool fix_overlapping_extents(struct btree *b,
                                    struct btree_iter *iter,
                                    struct btree_op *op)
 {
-       void subtract_dirty(struct bkey *k, int sectors)
+       void subtract_dirty(struct bkey *k, uint64_t offset, int sectors)
        {
-               struct bcache_device *d = b->c->devices[KEY_INODE(k)];
-
-               if (KEY_DIRTY(k) && d)
-                       atomic_long_sub(sectors, &d->sectors_dirty);
+               if (KEY_DIRTY(k))
+                       bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
+                                                    offset, -sectors);
        }
 
+       uint64_t old_offset;
        unsigned old_size, sectors_found = 0;
 
        while (1) {
@@ -1673,6 +1643,7 @@ static bool fix_overlapping_extents(struct btree *b,
                if (bkey_cmp(k, &START_KEY(insert)) <= 0)
                        continue;
 
+               old_offset = KEY_START(k);
                old_size = KEY_SIZE(k);
 
                /*
@@ -1728,7 +1699,7 @@ static bool fix_overlapping_extents(struct btree *b,
 
                        struct bkey *top;
 
-                       subtract_dirty(k, KEY_SIZE(insert));
+                       subtract_dirty(k, KEY_START(insert), KEY_SIZE(insert));
 
                        if (bkey_written(b, k)) {
                                /*
@@ -1775,7 +1746,7 @@ static bool fix_overlapping_extents(struct btree *b,
                        }
                }
 
-               subtract_dirty(k, old_size - KEY_SIZE(k));
+               subtract_dirty(k, old_offset, old_size - KEY_SIZE(k));
        }
 
 check_failed:
@@ -1798,7 +1769,7 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
 {
        struct bset *i = b->sets[b->nsets].data;
        struct bkey *m, *prev;
-       const char *status = "insert";
+       unsigned status = BTREE_INSERT_STATUS_INSERT;
 
        BUG_ON(bkey_cmp(k, &b->key) > 0);
        BUG_ON(b->level && !KEY_PTRS(k));
@@ -1831,17 +1802,17 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
                        goto insert;
 
                /* prev is in the tree, if we merge we're done */
-               status = "back merging";
+               status = BTREE_INSERT_STATUS_BACK_MERGE;
                if (prev &&
                    bch_bkey_try_merge(b, prev, k))
                        goto merged;
 
-               status = "overwrote front";
+               status = BTREE_INSERT_STATUS_OVERWROTE;
                if (m != end(i) &&
                    KEY_PTRS(m) == KEY_PTRS(k) && !KEY_SIZE(m))
                        goto copy;
 
-               status = "front merge";
+               status = BTREE_INSERT_STATUS_FRONT_MERGE;
                if (m != end(i) &&
                    bch_bkey_try_merge(b, k, m))
                        goto copy;
@@ -1851,21 +1822,21 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
 insert:        shift_keys(b, m, k);
 copy:  bkey_copy(m, k);
 merged:
-       bch_check_keys(b, "%s for %s at %s: %s", status,
-                      op_type(op), pbtree(b), pkey(k));
-       bch_check_key_order_msg(b, i, "%s for %s at %s: %s", status,
-                               op_type(op), pbtree(b), pkey(k));
+       if (KEY_DIRTY(k))
+               bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
+                                            KEY_START(k), KEY_SIZE(k));
+
+       bch_check_keys(b, "%u for %s", status, op_type(op));
 
        if (b->level && !KEY_OFFSET(k))
-               b->prio_blocked++;
+               btree_current_write(b)->prio_blocked++;
 
-       pr_debug("%s for %s at %s: %s", status,
-                op_type(op), pbtree(b), pkey(k));
+       trace_bcache_btree_insert_key(b, k, op->type, status);
 
        return true;
 }
 
-bool bch_btree_insert_keys(struct btree *b, struct btree_op *op)
+static bool bch_btree_insert_keys(struct btree *b, struct btree_op *op)
 {
        bool ret = false;
        struct bkey *k;
@@ -1896,7 +1867,7 @@ bool bch_btree_insert_check_key(struct btree *b, struct btree_op *op,
            should_split(b))
                goto out;
 
-       op->replace = KEY(op->inode, bio_end(bio), bio_sectors(bio));
+       op->replace = KEY(op->inode, bio_end_sector(bio), bio_sectors(bio));
 
        SET_KEY_PTRS(&op->replace, 1);
        get_random_bytes(&op->replace.ptr[0], sizeof(uint64_t));
@@ -1907,7 +1878,6 @@ bool bch_btree_insert_check_key(struct btree *b, struct btree_op *op,
 
        BUG_ON(op->type != BTREE_INSERT);
        BUG_ON(!btree_insert_key(b, op, &tmp.k));
-       bch_btree_write(b, false, NULL);
        ret = true;
 out:
        downgrade_write(&b->lock);
@@ -1929,12 +1899,11 @@ static int btree_split(struct btree *b, struct btree_op *op)
 
        split = set_blocks(n1->sets[0].data, n1->c) > (btree_blocks(b) * 4) / 5;
 
-       pr_debug("%ssplitting at %s keys %i", split ? "" : "not ",
-                pbtree(b), n1->sets[0].data->keys);
-
        if (split) {
                unsigned keys = 0;
 
+               trace_bcache_btree_node_split(b, n1->sets[0].data->keys);
+
                n2 = bch_btree_node_alloc(b->c, b->level, &op->cl);
                if (IS_ERR(n2))
                        goto err_free1;
@@ -1967,18 +1936,21 @@ static int btree_split(struct btree *b, struct btree_op *op)
                bkey_copy_key(&n2->key, &b->key);
 
                bch_keylist_add(&op->keys, &n2->key);
-               bch_btree_write(n2, true, op);
+               bch_btree_node_write(n2, &op->cl);
                rw_unlock(true, n2);
-       } else
+       } else {
+               trace_bcache_btree_node_compact(b, n1->sets[0].data->keys);
+
                bch_btree_insert_keys(n1, op);
+       }
 
        bch_keylist_add(&op->keys, &n1->key);
-       bch_btree_write(n1, true, op);
+       bch_btree_node_write(n1, &op->cl);
 
        if (n3) {
                bkey_copy_key(&n3->key, &MAX_KEY);
                bch_btree_insert_keys(n3, op);
-               bch_btree_write(n3, true, op);
+               bch_btree_node_write(n3, &op->cl);
 
                closure_sync(&op->cl);
                bch_btree_set_root(n3);
@@ -2082,8 +2054,12 @@ static int bch_btree_insert_recurse(struct btree *b, struct btree_op *op,
 
                BUG_ON(write_block(b) != b->sets[b->nsets].data);
 
-               if (bch_btree_insert_keys(b, op))
-                       bch_btree_write(b, false, op);
+               if (bch_btree_insert_keys(b, op)) {
+                       if (!b->level)
+                               bch_btree_leaf_dirty(b, op);
+                       else
+                               bch_btree_node_write(b, &op->cl);
+               }
        }
 
        return 0;
@@ -2140,6 +2116,11 @@ int bch_btree_insert(struct btree_op *op, struct cache_set *c)
 void bch_btree_set_root(struct btree *b)
 {
        unsigned i;
+       struct closure cl;
+
+       closure_init_stack(&cl);
+
+       trace_bcache_btree_set_root(b);
 
        BUG_ON(!b->written);
 
@@ -2153,8 +2134,8 @@ void bch_btree_set_root(struct btree *b)
        b->c->root = b;
        __bkey_put(b->c, &b->key);
 
-       bch_journal_meta(b->c, NULL);
-       pr_debug("%s for %pf", pbtree(b), __builtin_return_address(0));
+       bch_journal_meta(b->c, &cl);
+       closure_sync(&cl);
 }
 
 /* Cache lookup */
@@ -2215,9 +2196,6 @@ static int submit_partial_cache_hit(struct btree *b, struct btree_op *op,
                                         KEY_OFFSET(k) - bio->bi_sector);
 
                n = bch_bio_split(bio, sectors, GFP_NOIO, s->d->bio_split);
-               if (!n)
-                       return -EAGAIN;
-
                if (n == bio)
                        op->lookup_done = true;
 
@@ -2240,7 +2218,6 @@ static int submit_partial_cache_hit(struct btree *b, struct btree_op *op,
                n->bi_end_io    = bch_cache_read_endio;
                n->bi_private   = &s->cl;
 
-               trace_bcache_cache_hit(n);
                __bch_submit_bbio(n, b->c);
        }
 
@@ -2257,9 +2234,6 @@ int bch_btree_search_recurse(struct btree *b, struct btree_op *op)
        struct btree_iter iter;
        bch_btree_iter_init(b, &iter, &KEY(op->inode, bio->bi_sector, 0));
 
-       pr_debug("at %s searching for %u:%llu", pbtree(b), op->inode,
-                (uint64_t) bio->bi_sector);
-
        do {
                k = bch_btree_iter_next_filter(&iter, b, bch_ptr_bad);
                if (!k) {
@@ -2303,7 +2277,8 @@ static inline int keybuf_nonoverlapping_cmp(struct keybuf_key *l,
 }
 
 static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op,
-                                  struct keybuf *buf, struct bkey *end)
+                                  struct keybuf *buf, struct bkey *end,
+                                  keybuf_pred_fn *pred)
 {
        struct btree_iter iter;
        bch_btree_iter_init(b, &iter, &buf->last_scanned);
@@ -2322,11 +2297,9 @@ static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op,
                        if (bkey_cmp(&buf->last_scanned, end) >= 0)
                                break;
 
-                       if (buf->key_predicate(buf, k)) {
+                       if (pred(buf, k)) {
                                struct keybuf_key *w;
 
-                               pr_debug("%s", pkey(k));
-
                                spin_lock(&buf->lock);
 
                                w = array_alloc(&buf->freelist);
@@ -2343,7 +2316,7 @@ static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op,
                        if (!k)
                                break;
 
-                       btree(refill_keybuf, k, b, op, buf, end);
+                       btree(refill_keybuf, k, b, op, buf, end, pred);
                        /*
                         * Might get an error here, but can't really do anything
                         * and it'll get logged elsewhere. Just read what we
@@ -2361,7 +2334,7 @@ static int bch_btree_refill_keybuf(struct btree *b, struct btree_op *op,
 }
 
 void bch_refill_keybuf(struct cache_set *c, struct keybuf *buf,
-                         struct bkey *end)
+                      struct bkey *end, keybuf_pred_fn *pred)
 {
        struct bkey start = buf->last_scanned;
        struct btree_op op;
@@ -2369,7 +2342,7 @@ void bch_refill_keybuf(struct cache_set *c, struct keybuf *buf,
 
        cond_resched();
 
-       btree_root(refill_keybuf, c, &op, buf, end);
+       btree_root(refill_keybuf, c, &op, buf, end, pred);
        closure_sync(&op.cl);
 
        pr_debug("found %s keys from %llu:%llu to %llu:%llu",
@@ -2455,7 +2428,8 @@ struct keybuf_key *bch_keybuf_next(struct keybuf *buf)
 
 struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
                                             struct keybuf *buf,
-                                            struct bkey *end)
+                                            struct bkey *end,
+                                            keybuf_pred_fn *pred)
 {
        struct keybuf_key *ret;
 
@@ -2469,15 +2443,14 @@ struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *c,
                        break;
                }
 
-               bch_refill_keybuf(c, buf, end);
+               bch_refill_keybuf(c, buf, end, pred);
        }
 
        return ret;
 }
 
-void bch_keybuf_init(struct keybuf *buf, keybuf_pred_fn *fn)
+void bch_keybuf_init(struct keybuf *buf)
 {
-       buf->key_predicate      = fn;
        buf->last_scanned       = MAX_KEY;
        buf->keys               = RB_ROOT;
 
index af4a7092a28c89d47bf2b4165312b7988f1921a6..3333d3723633c424e0a22d51d7475969392c1130 100644 (file)
 #include "debug.h"
 
 struct btree_write {
-       struct closure          *owner;
        atomic_t                *journal;
 
        /* If btree_split() frees a btree node, it writes a new pointer to that
@@ -142,16 +141,12 @@ struct btree {
         */
        struct bset_tree        sets[MAX_BSETS];
 
-       /* Used to refcount bio splits, also protects b->bio */
+       /* For outstanding btree writes, used as a lock - protects write_idx */
        struct closure_with_waitlist    io;
 
-       /* Gets transferred to w->prio_blocked - see the comment there */
-       int                     prio_blocked;
-
        struct list_head        list;
        struct delayed_work     work;
 
-       uint64_t                io_start_time;
        struct btree_write      writes[2];
        struct bio              *bio;
 };
@@ -164,13 +159,11 @@ static inline void set_btree_node_ ## flag(struct btree *b)               \
 {      set_bit(BTREE_NODE_ ## flag, &b->flags); }                      \
 
 enum btree_flags {
-       BTREE_NODE_read_done,
        BTREE_NODE_io_error,
        BTREE_NODE_dirty,
        BTREE_NODE_write_idx,
 };
 
-BTREE_FLAG(read_done);
 BTREE_FLAG(io_error);
 BTREE_FLAG(dirty);
 BTREE_FLAG(write_idx);
@@ -278,6 +271,13 @@ struct btree_op {
        BKEY_PADDED(replace);
 };
 
+enum {
+       BTREE_INSERT_STATUS_INSERT,
+       BTREE_INSERT_STATUS_BACK_MERGE,
+       BTREE_INSERT_STATUS_OVERWROTE,
+       BTREE_INSERT_STATUS_FRONT_MERGE,
+};
+
 void bch_btree_op_init_stack(struct btree_op *);
 
 static inline void rw_lock(bool w, struct btree *b, int level)
@@ -293,9 +293,7 @@ static inline void rw_unlock(bool w, struct btree *b)
 #ifdef CONFIG_BCACHE_EDEBUG
        unsigned i;
 
-       if (w &&
-           b->key.ptr[0] &&
-           btree_node_read_done(b))
+       if (w && b->key.ptr[0])
                for (i = 0; i <= b->nsets; i++)
                        bch_check_key_order(b, b->sets[i].data);
 #endif
@@ -370,9 +368,8 @@ static inline bool should_split(struct btree *b)
                 > btree_blocks(b));
 }
 
-void bch_btree_read_done(struct closure *);
-void bch_btree_read(struct btree *);
-void bch_btree_write(struct btree *b, bool now, struct btree_op *op);
+void bch_btree_node_read(struct btree *);
+void bch_btree_node_write(struct btree *, struct closure *);
 
 void bch_cannibalize_unlock(struct cache_set *, struct closure *);
 void bch_btree_set_root(struct btree *);
@@ -380,7 +377,6 @@ struct btree *bch_btree_node_alloc(struct cache_set *, int, struct closure *);
 struct btree *bch_btree_node_get(struct cache_set *, struct bkey *,
                                int, struct btree_op *);
 
-bool bch_btree_insert_keys(struct btree *, struct btree_op *);
 bool bch_btree_insert_check_key(struct btree *, struct btree_op *,
                                   struct bio *);
 int bch_btree_insert(struct btree_op *, struct cache_set *);
@@ -393,13 +389,14 @@ void bch_moving_gc(struct closure *);
 int bch_btree_check(struct cache_set *, struct btree_op *);
 uint8_t __bch_btree_mark_key(struct cache_set *, int, struct bkey *);
 
-void bch_keybuf_init(struct keybuf *, keybuf_pred_fn *);
-void bch_refill_keybuf(struct cache_set *, struct keybuf *, struct bkey *);
+void bch_keybuf_init(struct keybuf *);
+void bch_refill_keybuf(struct cache_set *, struct keybuf *, struct bkey *,
+                      keybuf_pred_fn *);
 bool bch_keybuf_check_overlapping(struct keybuf *, struct bkey *,
                                  struct bkey *);
 void bch_keybuf_del(struct keybuf *, struct keybuf_key *);
 struct keybuf_key *bch_keybuf_next(struct keybuf *);
-struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *,
-                                         struct keybuf *, struct bkey *);
+struct keybuf_key *bch_keybuf_next_rescan(struct cache_set *, struct keybuf *,
+                                         struct bkey *, keybuf_pred_fn *);
 
 #endif
index bd05a9a8c7cf933e028be5eefbd1cd178681e495..9aba2017f0d1685ac5858ccf716c1f829681c853 100644 (file)
@@ -66,16 +66,18 @@ static inline void closure_put_after_sub(struct closure *cl, int flags)
                } else {
                        struct closure *parent = cl->parent;
                        struct closure_waitlist *wait = closure_waitlist(cl);
+                       closure_fn *destructor = cl->fn;
 
                        closure_debug_destroy(cl);
 
+                       smp_mb();
                        atomic_set(&cl->remaining, -1);
 
                        if (wait)
                                closure_wake_up(wait);
 
-                       if (cl->fn)
-                               cl->fn(cl);
+                       if (destructor)
+                               destructor(cl);
 
                        if (parent)
                                closure_put(parent);
index 89fd5204924e88bc2486d0616c291279161c51bb..88e6411eab4f15829ba22c535a7b100b370bc5a6 100644 (file)
@@ -47,11 +47,10 @@ const char *bch_ptr_status(struct cache_set *c, const struct bkey *k)
        return "";
 }
 
-struct keyprint_hack bch_pkey(const struct bkey *k)
+int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k)
 {
        unsigned i = 0;
-       struct keyprint_hack r;
-       char *out = r.s, *end = r.s + KEYHACK_SIZE;
+       char *out = buf, *end = buf + size;
 
 #define p(...) (out += scnprintf(out, end - out, __VA_ARGS__))
 
@@ -75,16 +74,14 @@ struct keyprint_hack bch_pkey(const struct bkey *k)
        if (KEY_CSUM(k))
                p(" cs%llu %llx", KEY_CSUM(k), k->ptr[1]);
 #undef p
-       return r;
+       return out - buf;
 }
 
-struct keyprint_hack bch_pbtree(const struct btree *b)
+int bch_btree_to_text(char *buf, size_t size, const struct btree *b)
 {
-       struct keyprint_hack r;
-
-       snprintf(r.s, 40, "%zu level %i/%i", PTR_BUCKET_NR(b->c, &b->key, 0),
-                b->level, b->c->root ? b->c->root->level : -1);
-       return r;
+       return scnprintf(buf, size, "%zu level %i/%i",
+                        PTR_BUCKET_NR(b->c, &b->key, 0),
+                        b->level, b->c->root ? b->c->root->level : -1);
 }
 
 #if defined(CONFIG_BCACHE_DEBUG) || defined(CONFIG_BCACHE_EDEBUG)
@@ -100,10 +97,12 @@ static void dump_bset(struct btree *b, struct bset *i)
 {
        struct bkey *k;
        unsigned j;
+       char buf[80];
 
        for (k = i->start; k < end(i); k = bkey_next(k)) {
+               bch_bkey_to_text(buf, sizeof(buf), k);
                printk(KERN_ERR "block %zu key %zi/%u: %s", index(i, b),
-                      (uint64_t *) k - i->d, i->keys, pkey(k));
+                      (uint64_t *) k - i->d, i->keys, buf);
 
                for (j = 0; j < KEY_PTRS(k); j++) {
                        size_t n = PTR_BUCKET_NR(b->c, k, j);
@@ -144,7 +143,7 @@ void bch_btree_verify(struct btree *b, struct bset *new)
        v->written = 0;
        v->level = b->level;
 
-       bch_btree_read(v);
+       bch_btree_node_read(v);
        closure_wait_event(&v->io.wait, &cl,
                           atomic_read(&b->io.cl.remaining) == -1);
 
@@ -200,7 +199,7 @@ void bch_data_verify(struct search *s)
        if (!check)
                return;
 
-       if (bch_bio_alloc_pages(check, GFP_NOIO))
+       if (bio_alloc_pages(check, GFP_NOIO))
                goto out_put;
 
        check->bi_rw            = READ_SYNC;
@@ -252,6 +251,7 @@ static void vdump_bucket_and_panic(struct btree *b, const char *fmt,
                                   va_list args)
 {
        unsigned i;
+       char buf[80];
 
        console_lock();
 
@@ -262,7 +262,8 @@ static void vdump_bucket_and_panic(struct btree *b, const char *fmt,
 
        console_unlock();
 
-       panic("at %s\n", pbtree(b));
+       bch_btree_to_text(buf, sizeof(buf), b);
+       panic("at %s\n", buf);
 }
 
 void bch_check_key_order_msg(struct btree *b, struct bset *i,
@@ -337,6 +338,7 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf,
 {
        struct dump_iterator *i = file->private_data;
        ssize_t ret = 0;
+       char kbuf[80];
 
        while (size) {
                struct keybuf_key *w;
@@ -355,11 +357,12 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf,
                if (i->bytes)
                        break;
 
-               w = bch_keybuf_next_rescan(i->c, &i->keys, &MAX_KEY);
+               w = bch_keybuf_next_rescan(i->c, &i->keys, &MAX_KEY, dump_pred);
                if (!w)
                        break;
 
-               i->bytes = snprintf(i->buf, PAGE_SIZE, "%s\n", pkey(&w->key));
+               bch_bkey_to_text(kbuf, sizeof(kbuf), &w->key);
+               i->bytes = snprintf(i->buf, PAGE_SIZE, "%s\n", kbuf);
                bch_keybuf_del(&i->keys, w);
        }
 
@@ -377,7 +380,7 @@ static int bch_dump_open(struct inode *inode, struct file *file)
 
        file->private_data = i;
        i->c = c;
-       bch_keybuf_init(&i->keys, dump_pred);
+       bch_keybuf_init(&i->keys);
        i->keys.last_scanned = KEY(0, 0, 0);
 
        return 0;
@@ -409,142 +412,6 @@ void bch_debug_init_cache_set(struct cache_set *c)
 
 #endif
 
-/* Fuzz tester has rotted: */
-#if 0
-
-static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a,
-                         const char *buffer, size_t size)
-{
-       void dump(struct btree *b)
-       {
-               struct bset *i;
-
-               for (i = b->sets[0].data;
-                    index(i, b) < btree_blocks(b) &&
-                    i->seq == b->sets[0].data->seq;
-                    i = ((void *) i) + set_blocks(i, b->c) * block_bytes(b->c))
-                       dump_bset(b, i);
-       }
-
-       struct cache_sb *sb;
-       struct cache_set *c;
-       struct btree *all[3], *b, *fill, *orig;
-       int j;
-
-       struct btree_op op;
-       bch_btree_op_init_stack(&op);
-
-       sb = kzalloc(sizeof(struct cache_sb), GFP_KERNEL);
-       if (!sb)
-               return -ENOMEM;
-
-       sb->bucket_size = 128;
-       sb->block_size = 4;
-
-       c = bch_cache_set_alloc(sb);
-       if (!c)
-               return -ENOMEM;
-
-       for (j = 0; j < 3; j++) {
-               BUG_ON(list_empty(&c->btree_cache));
-               all[j] = list_first_entry(&c->btree_cache, struct btree, list);
-               list_del_init(&all[j]->list);
-
-               all[j]->key = KEY(0, 0, c->sb.bucket_size);
-               bkey_copy_key(&all[j]->key, &MAX_KEY);
-       }
-
-       b = all[0];
-       fill = all[1];
-       orig = all[2];
-
-       while (1) {
-               for (j = 0; j < 3; j++)
-                       all[j]->written = all[j]->nsets = 0;
-
-               bch_bset_init_next(b);
-
-               while (1) {
-                       struct bset *i = write_block(b);
-                       struct bkey *k = op.keys.top;
-                       unsigned rand;
-
-                       bkey_init(k);
-                       rand = get_random_int();
-
-                       op.type = rand & 1
-                               ? BTREE_INSERT
-                               : BTREE_REPLACE;
-                       rand >>= 1;
-
-                       SET_KEY_SIZE(k, bucket_remainder(c, rand));
-                       rand >>= c->bucket_bits;
-                       rand &= 1024 * 512 - 1;
-                       rand += c->sb.bucket_size;
-                       SET_KEY_OFFSET(k, rand);
-#if 0
-                       SET_KEY_PTRS(k, 1);
-#endif
-                       bch_keylist_push(&op.keys);
-                       bch_btree_insert_keys(b, &op);
-
-                       if (should_split(b) ||
-                           set_blocks(i, b->c) !=
-                           __set_blocks(i, i->keys + 15, b->c)) {
-                               i->csum = csum_set(i);
-
-                               memcpy(write_block(fill),
-                                      i, set_bytes(i));
-
-                               b->written += set_blocks(i, b->c);
-                               fill->written = b->written;
-                               if (b->written == btree_blocks(b))
-                                       break;
-
-                               bch_btree_sort_lazy(b);
-                               bch_bset_init_next(b);
-                       }
-               }
-
-               memcpy(orig->sets[0].data,
-                      fill->sets[0].data,
-                      btree_bytes(c));
-
-               bch_btree_sort(b);
-               fill->written = 0;
-               bch_btree_read_done(&fill->io.cl);
-
-               if (b->sets[0].data->keys != fill->sets[0].data->keys ||
-                   memcmp(b->sets[0].data->start,
-                          fill->sets[0].data->start,
-                          b->sets[0].data->keys * sizeof(uint64_t))) {
-                       struct bset *i = b->sets[0].data;
-                       struct bkey *k, *l;
-
-                       for (k = i->start,
-                            l = fill->sets[0].data->start;
-                            k < end(i);
-                            k = bkey_next(k), l = bkey_next(l))
-                               if (bkey_cmp(k, l) ||
-                                   KEY_SIZE(k) != KEY_SIZE(l))
-                                       pr_err("key %zi differs: %s != %s",
-                                              (uint64_t *) k - i->d,
-                                              pkey(k), pkey(l));
-
-                       for (j = 0; j < 3; j++) {
-                               pr_err("**** Set %i ****", j);
-                               dump(all[j]);
-                       }
-                       panic("\n");
-               }
-
-               pr_info("fuzz complete: %i keys", b->sets[0].data->keys);
-       }
-}
-
-kobj_attribute_write(fuzz, btree_fuzz);
-#endif
-
 void bch_debug_exit(void)
 {
        if (!IS_ERR_OR_NULL(debug))
@@ -554,11 +421,6 @@ void bch_debug_exit(void)
 int __init bch_debug_init(struct kobject *kobj)
 {
        int ret = 0;
-#if 0
-       ret = sysfs_create_file(kobj, &ksysfs_fuzz.attr);
-       if (ret)
-               return ret;
-#endif
 
        debug = debugfs_create_dir("bcache", NULL);
        return ret;
index f9378a21814871033a9bc2218d184e6e422d2bd4..1c39b5a2489bd1158782f0afb1a28ef4fcb0a7a4 100644 (file)
@@ -3,15 +3,8 @@
 
 /* Btree/bkey debug printing */
 
-#define KEYHACK_SIZE 80
-struct keyprint_hack {
-       char s[KEYHACK_SIZE];
-};
-
-struct keyprint_hack bch_pkey(const struct bkey *k);
-struct keyprint_hack bch_pbtree(const struct btree *b);
-#define pkey(k)                (&bch_pkey(k).s[0])
-#define pbtree(b)      (&bch_pbtree(b).s[0])
+int bch_bkey_to_text(char *buf, size_t size, const struct bkey *k);
+int bch_btree_to_text(char *buf, size_t size, const struct btree *b);
 
 #ifdef CONFIG_BCACHE_EDEBUG
 
index 48efd4dea645bde1b12cf69927e9f628fd1ae077..9056632995b1b8a2de9de607c60cd693704c9c65 100644 (file)
@@ -9,6 +9,8 @@
 #include "bset.h"
 #include "debug.h"
 
+#include <linux/blkdev.h>
+
 static void bch_bi_idx_hack_endio(struct bio *bio, int error)
 {
        struct bio *p = bio->bi_private;
@@ -66,13 +68,6 @@ static void bch_generic_make_request_hack(struct bio *bio)
  * The newly allocated bio will point to @bio's bi_io_vec, if the split was on a
  * bvec boundry; it is the caller's responsibility to ensure that @bio is not
  * freed before the split.
- *
- * If bch_bio_split() is running under generic_make_request(), it's not safe to
- * allocate more than one bio from the same bio set. Therefore, if it is running
- * under generic_make_request() it masks out __GFP_WAIT when doing the
- * allocation. The caller must check for failure if there's any possibility of
- * it being called from under generic_make_request(); it is then the caller's
- * responsibility to retry from a safe context (by e.g. punting to workqueue).
  */
 struct bio *bch_bio_split(struct bio *bio, int sectors,
                          gfp_t gfp, struct bio_set *bs)
@@ -83,20 +78,13 @@ struct bio *bch_bio_split(struct bio *bio, int sectors,
 
        BUG_ON(sectors <= 0);
 
-       /*
-        * If we're being called from underneath generic_make_request() and we
-        * already allocated any bios from this bio set, we risk deadlock if we
-        * use the mempool. So instead, we possibly fail and let the caller punt
-        * to workqueue or somesuch and retry in a safe context.
-        */
-       if (current->bio_list)
-               gfp &= ~__GFP_WAIT;
-
        if (sectors >= bio_sectors(bio))
                return bio;
 
        if (bio->bi_rw & REQ_DISCARD) {
                ret = bio_alloc_bioset(gfp, 1, bs);
+               if (!ret)
+                       return NULL;
                idx = 0;
                goto out;
        }
@@ -160,17 +148,18 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
        struct request_queue *q = bdev_get_queue(bio->bi_bdev);
        unsigned max_segments = min_t(unsigned, BIO_MAX_PAGES,
                                      queue_max_segments(q));
-       struct bio_vec *bv, *end = bio_iovec(bio) +
-               min_t(int, bio_segments(bio), max_segments);
 
        if (bio->bi_rw & REQ_DISCARD)
                return min(ret, q->limits.max_discard_sectors);
 
        if (bio_segments(bio) > max_segments ||
            q->merge_bvec_fn) {
+               struct bio_vec *bv;
+               int i, seg = 0;
+
                ret = 0;
 
-               for (bv = bio_iovec(bio); bv < end; bv++) {
+               bio_for_each_segment(bv, bio, i) {
                        struct bvec_merge_data bvm = {
                                .bi_bdev        = bio->bi_bdev,
                                .bi_sector      = bio->bi_sector,
@@ -178,10 +167,14 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
                                .bi_rw          = bio->bi_rw,
                        };
 
+                       if (seg == max_segments)
+                               break;
+
                        if (q->merge_bvec_fn &&
                            q->merge_bvec_fn(q, &bvm, bv) < (int) bv->bv_len)
                                break;
 
+                       seg++;
                        ret += bv->bv_len >> 9;
                }
        }
@@ -218,30 +211,10 @@ static void bch_bio_submit_split_endio(struct bio *bio, int error)
        closure_put(cl);
 }
 
-static void __bch_bio_submit_split(struct closure *cl)
-{
-       struct bio_split_hook *s = container_of(cl, struct bio_split_hook, cl);
-       struct bio *bio = s->bio, *n;
-
-       do {
-               n = bch_bio_split(bio, bch_bio_max_sectors(bio),
-                                 GFP_NOIO, s->p->bio_split);
-               if (!n)
-                       continue_at(cl, __bch_bio_submit_split, system_wq);
-
-               n->bi_end_io    = bch_bio_submit_split_endio;
-               n->bi_private   = cl;
-
-               closure_get(cl);
-               bch_generic_make_request_hack(n);
-       } while (n != bio);
-
-       continue_at(cl, bch_bio_submit_split_done, NULL);
-}
-
 void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p)
 {
        struct bio_split_hook *s;
+       struct bio *n;
 
        if (!bio_has_data(bio) && !(bio->bi_rw & REQ_DISCARD))
                goto submit;
@@ -250,6 +223,7 @@ void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p)
                goto submit;
 
        s = mempool_alloc(p->bio_split_hook, GFP_NOIO);
+       closure_init(&s->cl, NULL);
 
        s->bio          = bio;
        s->p            = p;
@@ -257,8 +231,18 @@ void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p)
        s->bi_private   = bio->bi_private;
        bio_get(bio);
 
-       closure_call(&s->cl, __bch_bio_submit_split, NULL, NULL);
-       return;
+       do {
+               n = bch_bio_split(bio, bch_bio_max_sectors(bio),
+                                 GFP_NOIO, s->p->bio_split);
+
+               n->bi_end_io    = bch_bio_submit_split_endio;
+               n->bi_private   = &s->cl;
+
+               closure_get(&s->cl);
+               bch_generic_make_request_hack(n);
+       } while (n != bio);
+
+       continue_at(&s->cl, bch_bio_submit_split_done, NULL);
 submit:
        bch_generic_make_request_hack(bio);
 }
index 8c8dfdcd9d4cc9bc4a3d0799b98401855b280bcc..ba95ab84b2be5a5a32292625d229bb29e051a53d 100644 (file)
@@ -9,6 +9,8 @@
 #include "debug.h"
 #include "request.h"
 
+#include <trace/events/bcache.h>
+
 /*
  * Journal replay/recovery:
  *
@@ -182,9 +184,14 @@ bsearch:
                pr_debug("starting binary search, l %u r %u", l, r);
 
                while (l + 1 < r) {
+                       seq = list_entry(list->prev, struct journal_replay,
+                                        list)->j.seq;
+
                        m = (l + r) >> 1;
+                       read_bucket(m);
 
-                       if (read_bucket(m))
+                       if (seq != list_entry(list->prev, struct journal_replay,
+                                             list)->j.seq)
                                l = m;
                        else
                                r = m;
@@ -300,7 +307,8 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list,
                for (k = i->j.start;
                     k < end(&i->j);
                     k = bkey_next(k)) {
-                       pr_debug("%s", pkey(k));
+                       trace_bcache_journal_replay_key(k);
+
                        bkey_copy(op->keys.top, k);
                        bch_keylist_push(&op->keys);
 
@@ -384,7 +392,7 @@ out:
                return;
 found:
        if (btree_node_dirty(best))
-               bch_btree_write(best, true, NULL);
+               bch_btree_node_write(best, NULL);
        rw_unlock(true, best);
 }
 
@@ -617,7 +625,7 @@ static void journal_write_unlocked(struct closure *cl)
                bio_reset(bio);
                bio->bi_sector  = PTR_OFFSET(k, i);
                bio->bi_bdev    = ca->bdev;
-               bio->bi_rw      = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH;
+               bio->bi_rw      = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH|REQ_FUA;
                bio->bi_size    = sectors << 9;
 
                bio->bi_end_io  = journal_write_endio;
@@ -712,7 +720,8 @@ void bch_journal(struct closure *cl)
        spin_lock(&c->journal.lock);
 
        if (journal_full(&c->journal)) {
-               /* XXX: tracepoint */
+               trace_bcache_journal_full(c);
+
                closure_wait(&c->journal.wait, cl);
 
                journal_reclaim(c);
@@ -728,13 +737,15 @@ void bch_journal(struct closure *cl)
 
        if (b * c->sb.block_size > PAGE_SECTORS << JSET_BITS ||
            b > c->journal.blocks_free) {
-               /* XXX: If we were inserting so many keys that they won't fit in
+               trace_bcache_journal_entry_full(c);
+
+               /*
+                * XXX: If we were inserting so many keys that they won't fit in
                 * an _empty_ journal write, we'll deadlock. For now, handle
                 * this in bch_keylist_realloc() - but something to think about.
                 */
                BUG_ON(!w->data->keys);
 
-               /* XXX: tracepoint */
                BUG_ON(!closure_wait(&w->wait, cl));
 
                closure_flush(&c->journal.io);
index 8589512c972e3cfd1e973d53783313802b4db6ca..1a3b4f4786c3cee411d16c3a9a453e1fcd33b681 100644 (file)
@@ -9,6 +9,8 @@
 #include "debug.h"
 #include "request.h"
 
+#include <trace/events/bcache.h>
+
 struct moving_io {
        struct keybuf_key       *w;
        struct search           s;
@@ -44,14 +46,14 @@ static void write_moving_finish(struct closure *cl)
 {
        struct moving_io *io = container_of(cl, struct moving_io, s.cl);
        struct bio *bio = &io->bio.bio;
-       struct bio_vec *bv = bio_iovec_idx(bio, bio->bi_vcnt);
+       struct bio_vec *bv;
+       int i;
 
-       while (bv-- != bio->bi_io_vec)
+       bio_for_each_segment_all(bv, bio, i)
                __free_page(bv->bv_page);
 
-       pr_debug("%s %s", io->s.op.insert_collision
-                ? "collision moving" : "moved",
-                pkey(&io->w->key));
+       if (io->s.op.insert_collision)
+               trace_bcache_gc_copy_collision(&io->w->key);
 
        bch_keybuf_del(&io->s.op.c->moving_gc_keys, io->w);
 
@@ -94,8 +96,6 @@ static void write_moving(struct closure *cl)
        struct moving_io *io = container_of(s, struct moving_io, s);
 
        if (!s->error) {
-               trace_bcache_write_moving(&io->bio.bio);
-
                moving_init(io);
 
                io->bio.bio.bi_sector   = KEY_START(&io->w->key);
@@ -122,7 +122,6 @@ static void read_moving_submit(struct closure *cl)
        struct moving_io *io = container_of(s, struct moving_io, s);
        struct bio *bio = &io->bio.bio;
 
-       trace_bcache_read_moving(bio);
        bch_submit_bbio(bio, s->op.c, &io->w->key, 0);
 
        continue_at(cl, write_moving, bch_gc_wq);
@@ -138,7 +137,8 @@ static void read_moving(struct closure *cl)
        /* XXX: if we error, background writeback could stall indefinitely */
 
        while (!test_bit(CACHE_SET_STOPPING, &c->flags)) {
-               w = bch_keybuf_next_rescan(c, &c->moving_gc_keys, &MAX_KEY);
+               w = bch_keybuf_next_rescan(c, &c->moving_gc_keys,
+                                          &MAX_KEY, moving_pred);
                if (!w)
                        break;
 
@@ -159,10 +159,10 @@ static void read_moving(struct closure *cl)
                bio->bi_rw      = READ;
                bio->bi_end_io  = read_moving_endio;
 
-               if (bch_bio_alloc_pages(bio, GFP_KERNEL))
+               if (bio_alloc_pages(bio, GFP_KERNEL))
                        goto err;
 
-               pr_debug("%s", pkey(&w->key));
+               trace_bcache_gc_copy(&w->key);
 
                closure_call(&io->s.cl, read_moving_submit, NULL, &c->gc.cl);
 
@@ -250,5 +250,5 @@ void bch_moving_gc(struct closure *cl)
 
 void bch_moving_init_cache_set(struct cache_set *c)
 {
-       bch_keybuf_init(&c->moving_gc_keys, moving_pred);
+       bch_keybuf_init(&c->moving_gc_keys);
 }
index e5ff12e52d5b277bea9cc4fa4aa5eb5bdf23540a..786a1a4f74d853fafe3ab2ae263d2ecf780134aa 100644 (file)
@@ -10,6 +10,7 @@
 #include "btree.h"
 #include "debug.h"
 #include "request.h"
+#include "writeback.h"
 
 #include <linux/cgroup.h>
 #include <linux/module.h>
@@ -21,8 +22,6 @@
 
 #define CUTOFF_CACHE_ADD       95
 #define CUTOFF_CACHE_READA     90
-#define CUTOFF_WRITEBACK       50
-#define CUTOFF_WRITEBACK_SYNC  75
 
 struct kmem_cache *bch_search_cache;
 
@@ -489,6 +488,12 @@ static void bch_insert_data_loop(struct closure *cl)
                bch_queue_gc(op->c);
        }
 
+       /*
+        * Journal writes are marked REQ_FLUSH; if the original write was a
+        * flush, it'll wait on the journal write.
+        */
+       bio->bi_rw &= ~(REQ_FLUSH|REQ_FUA);
+
        do {
                unsigned i;
                struct bkey *k;
@@ -510,10 +515,6 @@ static void bch_insert_data_loop(struct closure *cl)
                        goto err;
 
                n = bch_bio_split(bio, KEY_SIZE(k), GFP_NOIO, split);
-               if (!n) {
-                       __bkey_put(op->c, k);
-                       continue_at(cl, bch_insert_data_loop, bcache_wq);
-               }
 
                n->bi_end_io    = bch_insert_data_endio;
                n->bi_private   = cl;
@@ -530,10 +531,9 @@ static void bch_insert_data_loop(struct closure *cl)
                if (KEY_CSUM(k))
                        bio_csum(n, k);
 
-               pr_debug("%s", pkey(k));
+               trace_bcache_cache_insert(k);
                bch_keylist_push(&op->keys);
 
-               trace_bcache_cache_insert(n, n->bi_sector, n->bi_bdev);
                n->bi_rw |= REQ_WRITE;
                bch_submit_bbio(n, op->c, k, 0);
        } while (n != bio);
@@ -716,7 +716,7 @@ static struct search *search_alloc(struct bio *bio, struct bcache_device *d)
        s->task                 = current;
        s->orig_bio             = bio;
        s->write                = (bio->bi_rw & REQ_WRITE) != 0;
-       s->op.flush_journal     = (bio->bi_rw & REQ_FLUSH) != 0;
+       s->op.flush_journal     = (bio->bi_rw & (REQ_FLUSH|REQ_FUA)) != 0;
        s->op.skip              = (bio->bi_rw & REQ_DISCARD) != 0;
        s->recoverable          = 1;
        s->start_time           = jiffies;
@@ -784,11 +784,8 @@ static void request_read_error(struct closure *cl)
        int i;
 
        if (s->recoverable) {
-               /* The cache read failed, but we can retry from the backing
-                * device.
-                */
-               pr_debug("recovering at sector %llu",
-                        (uint64_t) s->orig_bio->bi_sector);
+               /* Retry from the backing device: */
+               trace_bcache_read_retry(s->orig_bio);
 
                s->error = 0;
                bv = s->bio.bio.bi_io_vec;
@@ -806,7 +803,6 @@ static void request_read_error(struct closure *cl)
 
                /* XXX: invalidate cache */
 
-               trace_bcache_read_retry(&s->bio.bio);
                closure_bio_submit(&s->bio.bio, &s->cl, s->d);
        }
 
@@ -827,53 +823,13 @@ static void request_read_done(struct closure *cl)
         */
 
        if (s->op.cache_bio) {
-               struct bio_vec *src, *dst;
-               unsigned src_offset, dst_offset, bytes;
-               void *dst_ptr;
-
                bio_reset(s->op.cache_bio);
                s->op.cache_bio->bi_sector      = s->cache_miss->bi_sector;
                s->op.cache_bio->bi_bdev        = s->cache_miss->bi_bdev;
                s->op.cache_bio->bi_size        = s->cache_bio_sectors << 9;
                bch_bio_map(s->op.cache_bio, NULL);
 
-               src = bio_iovec(s->op.cache_bio);
-               dst = bio_iovec(s->cache_miss);
-               src_offset = src->bv_offset;
-               dst_offset = dst->bv_offset;
-               dst_ptr = kmap(dst->bv_page);
-
-               while (1) {
-                       if (dst_offset == dst->bv_offset + dst->bv_len) {
-                               kunmap(dst->bv_page);
-                               dst++;
-                               if (dst == bio_iovec_idx(s->cache_miss,
-                                               s->cache_miss->bi_vcnt))
-                                       break;
-
-                               dst_offset = dst->bv_offset;
-                               dst_ptr = kmap(dst->bv_page);
-                       }
-
-                       if (src_offset == src->bv_offset + src->bv_len) {
-                               src++;
-                               if (src == bio_iovec_idx(s->op.cache_bio,
-                                                s->op.cache_bio->bi_vcnt))
-                                       BUG();
-
-                               src_offset = src->bv_offset;
-                       }
-
-                       bytes = min(dst->bv_offset + dst->bv_len - dst_offset,
-                                   src->bv_offset + src->bv_len - src_offset);
-
-                       memcpy(dst_ptr + dst_offset,
-                              page_address(src->bv_page) + src_offset,
-                              bytes);
-
-                       src_offset      += bytes;
-                       dst_offset      += bytes;
-               }
+               bio_copy_data(s->cache_miss, s->op.cache_bio);
 
                bio_put(s->cache_miss);
                s->cache_miss = NULL;
@@ -899,6 +855,7 @@ static void request_read_done_bh(struct closure *cl)
        struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
 
        bch_mark_cache_accounting(s, !s->cache_miss, s->op.skip);
+       trace_bcache_read(s->orig_bio, !s->cache_miss, s->op.skip);
 
        if (s->error)
                continue_at_nobarrier(cl, request_read_error, bcache_wq);
@@ -917,9 +874,6 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
        struct bio *miss;
 
        miss = bch_bio_split(bio, sectors, GFP_NOIO, s->d->bio_split);
-       if (!miss)
-               return -EAGAIN;
-
        if (miss == bio)
                s->op.lookup_done = true;
 
@@ -938,8 +892,9 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
                reada = min(dc->readahead >> 9,
                            sectors - bio_sectors(miss));
 
-               if (bio_end(miss) + reada > bdev_sectors(miss->bi_bdev))
-                       reada = bdev_sectors(miss->bi_bdev) - bio_end(miss);
+               if (bio_end_sector(miss) + reada > bdev_sectors(miss->bi_bdev))
+                       reada = bdev_sectors(miss->bi_bdev) -
+                               bio_end_sector(miss);
        }
 
        s->cache_bio_sectors = bio_sectors(miss) + reada;
@@ -963,13 +918,12 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
                goto out_put;
 
        bch_bio_map(s->op.cache_bio, NULL);
-       if (bch_bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
+       if (bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
                goto out_put;
 
        s->cache_miss = miss;
        bio_get(s->op.cache_bio);
 
-       trace_bcache_cache_miss(s->orig_bio);
        closure_bio_submit(s->op.cache_bio, &s->cl, s->d);
 
        return ret;
@@ -1002,24 +956,13 @@ static void cached_dev_write_complete(struct closure *cl)
        cached_dev_bio_complete(cl);
 }
 
-static bool should_writeback(struct cached_dev *dc, struct bio *bio)
-{
-       unsigned threshold = (bio->bi_rw & REQ_SYNC)
-               ? CUTOFF_WRITEBACK_SYNC
-               : CUTOFF_WRITEBACK;
-
-       return !atomic_read(&dc->disk.detaching) &&
-               cache_mode(dc, bio) == CACHE_MODE_WRITEBACK &&
-               dc->disk.c->gc_stats.in_use < threshold;
-}
-
 static void request_write(struct cached_dev *dc, struct search *s)
 {
        struct closure *cl = &s->cl;
        struct bio *bio = &s->bio.bio;
        struct bkey start, end;
        start = KEY(dc->disk.id, bio->bi_sector, 0);
-       end = KEY(dc->disk.id, bio_end(bio), 0);
+       end = KEY(dc->disk.id, bio_end_sector(bio), 0);
 
        bch_keybuf_check_overlapping(&s->op.c->moving_gc_keys, &start, &end);
 
@@ -1034,22 +977,37 @@ static void request_write(struct cached_dev *dc, struct search *s)
        if (bio->bi_rw & REQ_DISCARD)
                goto skip;
 
+       if (should_writeback(dc, s->orig_bio,
+                            cache_mode(dc, bio),
+                            s->op.skip)) {
+               s->op.skip = false;
+               s->writeback = true;
+       }
+
        if (s->op.skip)
                goto skip;
 
-       if (should_writeback(dc, s->orig_bio))
-               s->writeback = true;
+       trace_bcache_write(s->orig_bio, s->writeback, s->op.skip);
 
        if (!s->writeback) {
                s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO,
                                                   dc->disk.bio_split);
 
-               trace_bcache_writethrough(s->orig_bio);
                closure_bio_submit(bio, cl, s->d);
        } else {
-               s->op.cache_bio = bio;
-               trace_bcache_writeback(s->orig_bio);
-               bch_writeback_add(dc, bio_sectors(bio));
+               bch_writeback_add(dc);
+
+               if (s->op.flush_journal) {
+                       /* Also need to send a flush to the backing device */
+                       s->op.cache_bio = bio_clone_bioset(bio, GFP_NOIO,
+                                                          dc->disk.bio_split);
+
+                       bio->bi_size = 0;
+                       bio->bi_vcnt = 0;
+                       closure_bio_submit(bio, cl, s->d);
+               } else {
+                       s->op.cache_bio = bio;
+               }
        }
 out:
        closure_call(&s->op.cl, bch_insert_data, NULL, cl);
@@ -1058,7 +1016,6 @@ skip:
        s->op.skip = true;
        s->op.cache_bio = s->orig_bio;
        bio_get(s->op.cache_bio);
-       trace_bcache_write_skip(s->orig_bio);
 
        if ((bio->bi_rw & REQ_DISCARD) &&
            !blk_queue_discard(bdev_get_queue(dc->bdev)))
@@ -1088,9 +1045,10 @@ static void request_nodata(struct cached_dev *dc, struct search *s)
 
 /* Cached devices - read & write stuff */
 
-int bch_get_congested(struct cache_set *c)
+unsigned bch_get_congested(struct cache_set *c)
 {
        int i;
+       long rand;
 
        if (!c->congested_read_threshold_us &&
            !c->congested_write_threshold_us)
@@ -1106,7 +1064,13 @@ int bch_get_congested(struct cache_set *c)
 
        i += CONGESTED_MAX;
 
-       return i <= 0 ? 1 : fract_exp_two(i, 6);
+       if (i > 0)
+               i = fract_exp_two(i, 6);
+
+       rand = get_random_int();
+       i -= bitmap_weight(&rand, BITS_PER_LONG);
+
+       return i > 0 ? i : 1;
 }
 
 static void add_sequential(struct task_struct *t)
@@ -1126,10 +1090,8 @@ static void check_should_skip(struct cached_dev *dc, struct search *s)
 {
        struct cache_set *c = s->op.c;
        struct bio *bio = &s->bio.bio;
-
-       long rand;
-       int cutoff = bch_get_congested(c);
        unsigned mode = cache_mode(dc, bio);
+       unsigned sectors, congested = bch_get_congested(c);
 
        if (atomic_read(&dc->disk.detaching) ||
            c->gc_stats.in_use > CUTOFF_CACHE_ADD ||
@@ -1147,17 +1109,14 @@ static void check_should_skip(struct cached_dev *dc, struct search *s)
                goto skip;
        }
 
-       if (!cutoff) {
-               cutoff = dc->sequential_cutoff >> 9;
+       if (!congested && !dc->sequential_cutoff)
+               goto rescale;
 
-               if (!cutoff)
-                       goto rescale;
-
-               if (mode == CACHE_MODE_WRITEBACK &&
-                   (bio->bi_rw & REQ_WRITE) &&
-                   (bio->bi_rw & REQ_SYNC))
-                       goto rescale;
-       }
+       if (!congested &&
+           mode == CACHE_MODE_WRITEBACK &&
+           (bio->bi_rw & REQ_WRITE) &&
+           (bio->bi_rw & REQ_SYNC))
+               goto rescale;
 
        if (dc->sequential_merge) {
                struct io *i;
@@ -1177,7 +1136,7 @@ found:
                if (i->sequential + bio->bi_size > i->sequential)
                        i->sequential   += bio->bi_size;
 
-               i->last                  = bio_end(bio);
+               i->last                  = bio_end_sector(bio);
                i->jiffies               = jiffies + msecs_to_jiffies(5000);
                s->task->sequential_io   = i->sequential;
 
@@ -1192,12 +1151,19 @@ found:
                add_sequential(s->task);
        }
 
-       rand = get_random_int();
-       cutoff -= bitmap_weight(&rand, BITS_PER_LONG);
+       sectors = max(s->task->sequential_io,
+                     s->task->sequential_io_avg) >> 9;
 
-       if (cutoff <= (int) (max(s->task->sequential_io,
-                                s->task->sequential_io_avg) >> 9))
+       if (dc->sequential_cutoff &&
+           sectors >= dc->sequential_cutoff >> 9) {
+               trace_bcache_bypass_sequential(s->orig_bio);
                goto skip;
+       }
+
+       if (congested && sectors >= congested) {
+               trace_bcache_bypass_congested(s->orig_bio);
+               goto skip;
+       }
 
 rescale:
        bch_rescale_priorities(c, bio_sectors(bio));
@@ -1288,30 +1254,25 @@ void bch_cached_dev_request_init(struct cached_dev *dc)
 static int flash_dev_cache_miss(struct btree *b, struct search *s,
                                struct bio *bio, unsigned sectors)
 {
+       struct bio_vec *bv;
+       int i;
+
        /* Zero fill bio */
 
-       while (bio->bi_idx != bio->bi_vcnt) {
-               struct bio_vec *bv = bio_iovec(bio);
+       bio_for_each_segment(bv, bio, i) {
                unsigned j = min(bv->bv_len >> 9, sectors);
 
                void *p = kmap(bv->bv_page);
                memset(p + bv->bv_offset, 0, j << 9);
                kunmap(bv->bv_page);
 
-               bv->bv_len      -= j << 9;
-               bv->bv_offset   += j << 9;
-
-               if (bv->bv_len)
-                       return 0;
-
-               bio->bi_sector  += j;
-               bio->bi_size    -= j << 9;
-
-               bio->bi_idx++;
-               sectors         -= j;
+               sectors -= j;
        }
 
-       s->op.lookup_done = true;
+       bio_advance(bio, min(sectors << 9, bio->bi_size));
+
+       if (!bio->bi_size)
+               s->op.lookup_done = true;
 
        return 0;
 }
@@ -1338,8 +1299,8 @@ static void flash_dev_make_request(struct request_queue *q, struct bio *bio)
                closure_call(&s->op.cl, btree_read_async, NULL, cl);
        } else if (bio_has_data(bio) || s->op.skip) {
                bch_keybuf_check_overlapping(&s->op.c->moving_gc_keys,
-                                            &KEY(d->id, bio->bi_sector, 0),
-                                            &KEY(d->id, bio_end(bio), 0));
+                                       &KEY(d->id, bio->bi_sector, 0),
+                                       &KEY(d->id, bio_end_sector(bio), 0));
 
                s->writeback    = true;
                s->op.cache_bio = bio;
index 254d9ab5707cf4629e186d512d5f43e7eca3f94a..57dc4784f4f48c06b6816232d352d4992e45cee1 100644 (file)
@@ -30,7 +30,7 @@ struct search {
 };
 
 void bch_cache_read_endio(struct bio *, int);
-int bch_get_congested(struct cache_set *);
+unsigned bch_get_congested(struct cache_set *);
 void bch_insert_data(struct closure *cl);
 void bch_btree_insert_async(struct closure *);
 void bch_cache_read_endio(struct bio *, int);
index f88e2b653a3fc9c82a7b308c8988cd10eda0c96b..547c4c57b052efbb6fcd3df67c4b52c505023606 100644 (file)
 #include "btree.h"
 #include "debug.h"
 #include "request.h"
+#include "writeback.h"
 
+#include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/debugfs.h>
 #include <linux/genhd.h>
+#include <linux/kthread.h>
 #include <linux/module.h>
 #include <linux/random.h>
 #include <linux/reboot.h>
@@ -342,6 +345,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
        struct closure *cl = &c->uuid_write.cl;
        struct uuid_entry *u;
        unsigned i;
+       char buf[80];
 
        BUG_ON(!parent);
        closure_lock(&c->uuid_write, parent);
@@ -362,8 +366,8 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
                        break;
        }
 
-       pr_debug("%s UUIDs at %s", rw & REQ_WRITE ? "wrote" : "read",
-                pkey(&c->uuid_bucket));
+       bch_bkey_to_text(buf, sizeof(buf), k);
+       pr_debug("%s UUIDs at %s", rw & REQ_WRITE ? "wrote" : "read", buf);
 
        for (u = c->uuids; u < c->uuids + c->nr_uuids; u++)
                if (!bch_is_zero(u->uuid, 16))
@@ -543,7 +547,6 @@ void bch_prio_write(struct cache *ca)
 
        pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free),
                 fifo_used(&ca->free_inc), fifo_used(&ca->unused));
-       blktrace_msg(ca, "Starting priorities: " buckets_free(ca));
 
        for (i = prio_buckets(ca) - 1; i >= 0; --i) {
                long bucket;
@@ -704,7 +707,8 @@ static void bcache_device_detach(struct bcache_device *d)
                atomic_set(&d->detaching, 0);
        }
 
-       bcache_device_unlink(d);
+       if (!d->flush_done)
+               bcache_device_unlink(d);
 
        d->c->devices[d->id] = NULL;
        closure_put(&d->c->caching);
@@ -743,13 +747,35 @@ static void bcache_device_free(struct bcache_device *d)
                mempool_destroy(d->unaligned_bvec);
        if (d->bio_split)
                bioset_free(d->bio_split);
+       if (is_vmalloc_addr(d->stripe_sectors_dirty))
+               vfree(d->stripe_sectors_dirty);
+       else
+               kfree(d->stripe_sectors_dirty);
 
        closure_debug_destroy(&d->cl);
 }
 
-static int bcache_device_init(struct bcache_device *d, unsigned block_size)
+static int bcache_device_init(struct bcache_device *d, unsigned block_size,
+                             sector_t sectors)
 {
        struct request_queue *q;
+       size_t n;
+
+       if (!d->stripe_size_bits)
+               d->stripe_size_bits = 31;
+
+       d->nr_stripes = round_up(sectors, 1 << d->stripe_size_bits) >>
+               d->stripe_size_bits;
+
+       if (!d->nr_stripes || d->nr_stripes > SIZE_MAX / sizeof(atomic_t))
+               return -ENOMEM;
+
+       n = d->nr_stripes * sizeof(atomic_t);
+       d->stripe_sectors_dirty = n < PAGE_SIZE << 6
+               ? kzalloc(n, GFP_KERNEL)
+               : vzalloc(n);
+       if (!d->stripe_sectors_dirty)
+               return -ENOMEM;
 
        if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
            !(d->unaligned_bvec = mempool_create_kmalloc_pool(1,
@@ -759,6 +785,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size)
            !(q = blk_alloc_queue(GFP_KERNEL)))
                return -ENOMEM;
 
+       set_capacity(d->disk, sectors);
        snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", bcache_minor);
 
        d->disk->major          = bcache_major;
@@ -781,6 +808,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size)
        set_bit(QUEUE_FLAG_NONROT,      &d->disk->queue->queue_flags);
        set_bit(QUEUE_FLAG_DISCARD,     &d->disk->queue->queue_flags);
 
+       blk_queue_flush(q, REQ_FLUSH|REQ_FUA);
+
        return 0;
 }
 
@@ -800,6 +829,17 @@ static void calc_cached_dev_sectors(struct cache_set *c)
 void bch_cached_dev_run(struct cached_dev *dc)
 {
        struct bcache_device *d = &dc->disk;
+       char buf[SB_LABEL_SIZE + 1];
+       char *env[] = {
+               "DRIVER=bcache",
+               kasprintf(GFP_KERNEL, "CACHED_UUID=%pU", dc->sb.uuid),
+               NULL,
+               NULL,
+       };
+
+       memcpy(buf, dc->sb.label, SB_LABEL_SIZE);
+       buf[SB_LABEL_SIZE] = '\0';
+       env[2] = kasprintf(GFP_KERNEL, "CACHED_LABEL=%s", buf);
 
        if (atomic_xchg(&dc->running, 1))
                return;
@@ -816,10 +856,12 @@ void bch_cached_dev_run(struct cached_dev *dc)
 
        add_disk(d->disk);
        bd_link_disk_holder(dc->bdev, dc->disk.disk);
-#if 0
-       char *env[] = { "SYMLINK=label" , NULL };
+       /* won't show up in the uevent file, use udevadm monitor -e instead
+        * only class / kset properties are persistent */
        kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env);
-#endif
+       kfree(env[1]);
+       kfree(env[2]);
+
        if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") ||
            sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache"))
                pr_debug("error creating sysfs link");
@@ -960,6 +1002,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
        atomic_set(&dc->count, 1);
 
        if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY) {
+               bch_sectors_dirty_init(dc);
                atomic_set(&dc->has_dirty, 1);
                atomic_inc(&dc->count);
                bch_writeback_queue(dc);
@@ -1014,6 +1057,14 @@ static void cached_dev_flush(struct closure *cl)
        struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl);
        struct bcache_device *d = &dc->disk;
 
+       mutex_lock(&bch_register_lock);
+       d->flush_done = 1;
+
+       if (d->c)
+               bcache_device_unlink(d);
+
+       mutex_unlock(&bch_register_lock);
+
        bch_cache_accounting_destroy(&dc->accounting);
        kobject_del(&d->kobj);
 
@@ -1045,7 +1096,8 @@ static int cached_dev_init(struct cached_dev *dc, unsigned block_size)
                hlist_add_head(&io->hash, dc->io_hash + RECENT_IO);
        }
 
-       ret = bcache_device_init(&dc->disk, block_size);
+       ret = bcache_device_init(&dc->disk, block_size,
+                        dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
        if (ret)
                return ret;
 
@@ -1144,11 +1196,10 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
 
        kobject_init(&d->kobj, &bch_flash_dev_ktype);
 
-       if (bcache_device_init(d, block_bytes(c)))
+       if (bcache_device_init(d, block_bytes(c), u->sectors))
                goto err;
 
        bcache_device_attach(d, c, u - c->uuids);
-       set_capacity(d->disk, u->sectors);
        bch_flash_dev_request_init(d);
        add_disk(d->disk);
 
@@ -1255,9 +1306,10 @@ static void cache_set_free(struct closure *cl)
        free_pages((unsigned long) c->uuids, ilog2(bucket_pages(c)));
        free_pages((unsigned long) c->sort, ilog2(bucket_pages(c)));
 
-       kfree(c->fill_iter);
        if (c->bio_split)
                bioset_free(c->bio_split);
+       if (c->fill_iter)
+               mempool_destroy(c->fill_iter);
        if (c->bio_meta)
                mempool_destroy(c->bio_meta);
        if (c->search)
@@ -1278,11 +1330,9 @@ static void cache_set_free(struct closure *cl)
 static void cache_set_flush(struct closure *cl)
 {
        struct cache_set *c = container_of(cl, struct cache_set, caching);
+       struct cache *ca;
        struct btree *b;
-
-       /* Shut down allocator threads */
-       set_bit(CACHE_SET_STOPPING_2, &c->flags);
-       wake_up(&c->alloc_wait);
+       unsigned i;
 
        bch_cache_accounting_destroy(&c->accounting);
 
@@ -1295,7 +1345,11 @@ static void cache_set_flush(struct closure *cl)
        /* Should skip this if we're unregistering because of an error */
        list_for_each_entry(b, &c->btree_cache, list)
                if (btree_node_dirty(b))
-                       bch_btree_write(b, true, NULL);
+                       bch_btree_node_write(b, NULL);
+
+       for_each_cache(ca, c, i)
+               if (ca->alloc_thread)
+                       kthread_stop(ca->alloc_thread);
 
        closure_return(cl);
 }
@@ -1303,18 +1357,22 @@ static void cache_set_flush(struct closure *cl)
 static void __cache_set_unregister(struct closure *cl)
 {
        struct cache_set *c = container_of(cl, struct cache_set, caching);
-       struct cached_dev *dc, *t;
+       struct cached_dev *dc;
        size_t i;
 
        mutex_lock(&bch_register_lock);
 
-       if (test_bit(CACHE_SET_UNREGISTERING, &c->flags))
-               list_for_each_entry_safe(dc, t, &c->cached_devs, list)
-                       bch_cached_dev_detach(dc);
-
        for (i = 0; i < c->nr_uuids; i++)
-               if (c->devices[i] && UUID_FLASH_ONLY(&c->uuids[i]))
-                       bcache_device_stop(c->devices[i]);
+               if (c->devices[i]) {
+                       if (!UUID_FLASH_ONLY(&c->uuids[i]) &&
+                           test_bit(CACHE_SET_UNREGISTERING, &c->flags)) {
+                               dc = container_of(c->devices[i],
+                                                 struct cached_dev, disk);
+                               bch_cached_dev_detach(dc);
+                       } else {
+                               bcache_device_stop(c->devices[i]);
+                       }
+               }
 
        mutex_unlock(&bch_register_lock);
 
@@ -1373,9 +1431,9 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
                c->btree_pages = max_t(int, c->btree_pages / 4,
                                       BTREE_MAX_PAGES);
 
-       init_waitqueue_head(&c->alloc_wait);
+       c->sort_crit_factor = int_sqrt(c->btree_pages);
+
        mutex_init(&c->bucket_lock);
-       mutex_init(&c->fill_lock);
        mutex_init(&c->sort_lock);
        spin_lock_init(&c->sort_time_lock);
        closure_init_unlocked(&c->sb_write);
@@ -1401,8 +1459,8 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
            !(c->bio_meta = mempool_create_kmalloc_pool(2,
                                sizeof(struct bbio) + sizeof(struct bio_vec) *
                                bucket_pages(c))) ||
+           !(c->fill_iter = mempool_create_kmalloc_pool(1, iter_size)) ||
            !(c->bio_split = bioset_create(4, offsetof(struct bbio, bio))) ||
-           !(c->fill_iter = kmalloc(iter_size, GFP_KERNEL)) ||
            !(c->sort = alloc_bucket_pages(GFP_KERNEL, c)) ||
            !(c->uuids = alloc_bucket_pages(GFP_KERNEL, c)) ||
            bch_journal_alloc(c) ||
@@ -1410,8 +1468,6 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
            bch_open_buckets_alloc(c))
                goto err;
 
-       c->fill_iter->size = sb->bucket_size / sb->block_size;
-
        c->congested_read_threshold_us  = 2000;
        c->congested_write_threshold_us = 20000;
        c->error_limit  = 8 << IO_ERROR_SHIFT;
@@ -1496,9 +1552,10 @@ static void run_cache_set(struct cache_set *c)
                 */
                bch_journal_next(&c->journal);
 
+               err = "error starting allocator thread";
                for_each_cache(ca, c, i)
-                       closure_call(&ca->alloc, bch_allocator_thread,
-                                    system_wq, &c->cl);
+                       if (bch_cache_allocator_start(ca))
+                               goto err;
 
                /*
                 * First place it's safe to allocate: btree_check() and
@@ -1531,17 +1588,16 @@ static void run_cache_set(struct cache_set *c)
 
                bch_btree_gc_finish(c);
 
+               err = "error starting allocator thread";
                for_each_cache(ca, c, i)
-                       closure_call(&ca->alloc, bch_allocator_thread,
-                                    ca->alloc_workqueue, &c->cl);
+                       if (bch_cache_allocator_start(ca))
+                               goto err;
 
                mutex_lock(&c->bucket_lock);
                for_each_cache(ca, c, i)
                        bch_prio_write(ca);
                mutex_unlock(&c->bucket_lock);
 
-               wake_up(&c->alloc_wait);
-
                err = "cannot allocate new UUID bucket";
                if (__uuid_write(c))
                        goto err_unlock_gc;
@@ -1552,7 +1608,7 @@ static void run_cache_set(struct cache_set *c)
                        goto err_unlock_gc;
 
                bkey_copy_key(&c->root->key, &MAX_KEY);
-               bch_btree_write(c->root, true, &op);
+               bch_btree_node_write(c->root, &op.cl);
 
                bch_btree_set_root(c->root);
                rw_unlock(true, c->root);
@@ -1673,9 +1729,6 @@ void bch_cache_release(struct kobject *kobj)
 
        bio_split_pool_free(&ca->bio_split_hook);
 
-       if (ca->alloc_workqueue)
-               destroy_workqueue(ca->alloc_workqueue);
-
        free_pages((unsigned long) ca->disk_buckets, ilog2(bucket_pages(ca)));
        kfree(ca->prio_buckets);
        vfree(ca->buckets);
@@ -1723,7 +1776,6 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca)
            !(ca->prio_buckets  = kzalloc(sizeof(uint64_t) * prio_buckets(ca) *
                                          2, GFP_KERNEL)) ||
            !(ca->disk_buckets  = alloc_bucket_pages(GFP_KERNEL, ca)) ||
-           !(ca->alloc_workqueue = alloc_workqueue("bch_allocator", 0, 1)) ||
            bio_split_pool_init(&ca->bio_split_hook))
                return -ENOMEM;
 
@@ -1786,6 +1838,36 @@ static ssize_t register_bcache(struct kobject *, struct kobj_attribute *,
 kobj_attribute_write(register,         register_bcache);
 kobj_attribute_write(register_quiet,   register_bcache);
 
+static bool bch_is_open_backing(struct block_device *bdev) {
+       struct cache_set *c, *tc;
+       struct cached_dev *dc, *t;
+
+       list_for_each_entry_safe(c, tc, &bch_cache_sets, list)
+               list_for_each_entry_safe(dc, t, &c->cached_devs, list)
+                       if (dc->bdev == bdev)
+                               return true;
+       list_for_each_entry_safe(dc, t, &uncached_devices, list)
+               if (dc->bdev == bdev)
+                       return true;
+       return false;
+}
+
+static bool bch_is_open_cache(struct block_device *bdev) {
+       struct cache_set *c, *tc;
+       struct cache *ca;
+       unsigned i;
+
+       list_for_each_entry_safe(c, tc, &bch_cache_sets, list)
+               for_each_cache(ca, c, i)
+                       if (ca->bdev == bdev)
+                               return true;
+       return false;
+}
+
+static bool bch_is_open(struct block_device *bdev) {
+       return bch_is_open_cache(bdev) || bch_is_open_backing(bdev);
+}
+
 static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
                               const char *buffer, size_t size)
 {
@@ -1810,8 +1892,13 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
                                  FMODE_READ|FMODE_WRITE|FMODE_EXCL,
                                  sb);
        if (IS_ERR(bdev)) {
-               if (bdev == ERR_PTR(-EBUSY))
-                       err = "device busy";
+               if (bdev == ERR_PTR(-EBUSY)) {
+                       bdev = lookup_bdev(strim(path));
+                       if (!IS_ERR(bdev) && bch_is_open(bdev))
+                               err = "device already registered";
+                       else
+                               err = "device busy";
+               }
                goto err;
        }
 
index 4d9cca47e4c6006cd20919080410007f75c3bc60..12a2c2846f994a1e2d51bf79374426df96893418 100644 (file)
@@ -9,7 +9,9 @@
 #include "sysfs.h"
 #include "btree.h"
 #include "request.h"
+#include "writeback.h"
 
+#include <linux/blkdev.h>
 #include <linux/sort.h>
 
 static const char * const cache_replacement_policies[] = {
@@ -79,6 +81,9 @@ rw_attribute(writeback_rate_p_term_inverse);
 rw_attribute(writeback_rate_d_smooth);
 read_attribute(writeback_rate_debug);
 
+read_attribute(stripe_size);
+read_attribute(partial_stripes_expensive);
+
 rw_attribute(synchronous);
 rw_attribute(journal_delay_ms);
 rw_attribute(discard);
@@ -127,7 +132,7 @@ SHOW(__bch_cached_dev)
                char derivative[20];
                char target[20];
                bch_hprint(dirty,
-                      atomic_long_read(&dc->disk.sectors_dirty) << 9);
+                          bcache_dev_sectors_dirty(&dc->disk) << 9);
                bch_hprint(derivative,  dc->writeback_rate_derivative << 9);
                bch_hprint(target,      dc->writeback_rate_target << 9);
 
@@ -143,7 +148,10 @@ SHOW(__bch_cached_dev)
        }
 
        sysfs_hprint(dirty_data,
-                    atomic_long_read(&dc->disk.sectors_dirty) << 9);
+                    bcache_dev_sectors_dirty(&dc->disk) << 9);
+
+       sysfs_hprint(stripe_size,       (1 << dc->disk.stripe_size_bits) << 9);
+       var_printf(partial_stripes_expensive,   "%u");
 
        var_printf(sequential_merge,    "%i");
        var_hprint(sequential_cutoff);
@@ -170,6 +178,7 @@ STORE(__cached_dev)
                                             disk.kobj);
        unsigned v = size;
        struct cache_set *c;
+       struct kobj_uevent_env *env;
 
 #define d_strtoul(var)         sysfs_strtoul(var, dc->var)
 #define d_strtoi_h(var)                sysfs_hatoi(var, dc->var)
@@ -214,6 +223,7 @@ STORE(__cached_dev)
        }
 
        if (attr == &sysfs_label) {
+               /* note: endlines are preserved */
                memcpy(dc->sb.label, buf, SB_LABEL_SIZE);
                bch_write_bdev_super(dc, NULL);
                if (dc->disk.c) {
@@ -221,6 +231,15 @@ STORE(__cached_dev)
                               buf, SB_LABEL_SIZE);
                        bch_uuid_write(dc->disk.c);
                }
+               env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
+               if (!env)
+                       return -ENOMEM;
+               add_uevent_var(env, "DRIVER=bcache");
+               add_uevent_var(env, "CACHED_UUID=%pU", dc->sb.uuid),
+               add_uevent_var(env, "CACHED_LABEL=%s", buf);
+               kobject_uevent_env(
+                       &disk_to_dev(dc->disk.disk)->kobj, KOBJ_CHANGE, env->envp);
+               kfree(env);
        }
 
        if (attr == &sysfs_attach) {
@@ -284,6 +303,8 @@ static struct attribute *bch_cached_dev_files[] = {
        &sysfs_writeback_rate_d_smooth,
        &sysfs_writeback_rate_debug,
        &sysfs_dirty_data,
+       &sysfs_stripe_size,
+       &sysfs_partial_stripes_expensive,
        &sysfs_sequential_cutoff,
        &sysfs_sequential_merge,
        &sysfs_clear_stats,
@@ -665,12 +686,10 @@ SHOW(__bch_cache)
                int cmp(const void *l, const void *r)
                {       return *((uint16_t *) r) - *((uint16_t *) l); }
 
-               /* Number of quantiles we compute */
-               const unsigned nq = 31;
-
                size_t n = ca->sb.nbuckets, i, unused, btree;
                uint64_t sum = 0;
-               uint16_t q[nq], *p, *cached;
+               /* Compute 31 quantiles */
+               uint16_t q[31], *p, *cached;
                ssize_t ret;
 
                cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t));
@@ -703,26 +722,29 @@ SHOW(__bch_cache)
                if (n)
                        do_div(sum, n);
 
-               for (i = 0; i < nq; i++)
-                       q[i] = INITIAL_PRIO - cached[n * (i + 1) / (nq + 1)];
+               for (i = 0; i < ARRAY_SIZE(q); i++)
+                       q[i] = INITIAL_PRIO - cached[n * (i + 1) /
+                               (ARRAY_SIZE(q) + 1)];
 
                vfree(p);
 
-               ret = snprintf(buf, PAGE_SIZE,
-                              "Unused:         %zu%%\n"
-                              "Metadata:       %zu%%\n"
-                              "Average:        %llu\n"
-                              "Sectors per Q:  %zu\n"
-                              "Quantiles:      [",
-                              unused * 100 / (size_t) ca->sb.nbuckets,
-                              btree * 100 / (size_t) ca->sb.nbuckets, sum,
-                              n * ca->sb.bucket_size / (nq + 1));
-
-               for (i = 0; i < nq && ret < (ssize_t) PAGE_SIZE; i++)
-                       ret += snprintf(buf + ret, PAGE_SIZE - ret,
-                                       i < nq - 1 ? "%u " : "%u]\n", q[i]);
-
-               buf[PAGE_SIZE - 1] = '\0';
+               ret = scnprintf(buf, PAGE_SIZE,
+                               "Unused:                %zu%%\n"
+                               "Metadata:      %zu%%\n"
+                               "Average:       %llu\n"
+                               "Sectors per Q: %zu\n"
+                               "Quantiles:     [",
+                               unused * 100 / (size_t) ca->sb.nbuckets,
+                               btree * 100 / (size_t) ca->sb.nbuckets, sum,
+                               n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
+
+               for (i = 0; i < ARRAY_SIZE(q); i++)
+                       ret += scnprintf(buf + ret, PAGE_SIZE - ret,
+                                        "%u ", q[i]);
+               ret--;
+
+               ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n");
+
                return ret;
        }
 
index 983f9bb411bc13e73be8d98cf6ef2fc0a48b07b8..f7b6c197f90f94f6aeb8ec59159265962af663c1 100644 (file)
@@ -2,6 +2,7 @@
 #include "btree.h"
 #include "request.h"
 
+#include <linux/blktrace_api.h>
 #include <linux/module.h>
 
 #define CREATE_TRACE_POINTS
 
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_request_start);
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_request_end);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_passthrough);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_hit);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_miss);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_bypass_sequential);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_bypass_congested);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_write);
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read_retry);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writethrough);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writeback);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_write_skip);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_insert);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_replay_key);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_write);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_full);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_entry_full);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_cache_cannibalize);
+
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_read);
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_write);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_write_dirty);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_read_dirty);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_journal_write);
-EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_cache_insert);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_alloc);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_alloc_fail);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_free);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_gc_coalesce);
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_start);
 EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_end);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_copy);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_gc_copy_collision);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_insert_key);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_split);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_node_compact);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_btree_set_root);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_alloc_invalidate);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_alloc_fail);
+
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writeback);
+EXPORT_TRACEPOINT_SYMBOL_GPL(bcache_writeback_collision);
index da3a99e85b1e0db79a35a2735769b7595f2be159..98eb81159a22ba9f9e88fec53127e2e338ae3d4d 100644 (file)
@@ -228,23 +228,6 @@ start:             bv->bv_len      = min_t(size_t, PAGE_SIZE - bv->bv_offset,
        }
 }
 
-int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp)
-{
-       int i;
-       struct bio_vec *bv;
-
-       bio_for_each_segment(bv, bio, i) {
-               bv->bv_page = alloc_page(gfp);
-               if (!bv->bv_page) {
-                       while (bv-- != bio->bi_io_vec + bio->bi_idx)
-                               __free_page(bv->bv_page);
-                       return -ENOMEM;
-               }
-       }
-
-       return 0;
-}
-
 /*
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
  * use permitted, subject to terms of PostgreSQL license; see.)
index 577393e38c3ac3c05076d7a24ce0707a946a0402..1ae2a73ad85f5628b5292b769d79b0f28252f4ca 100644 (file)
@@ -15,8 +15,6 @@
 
 struct closure;
 
-#include <trace/events/bcache.h>
-
 #ifdef CONFIG_BCACHE_EDEBUG
 
 #define atomic_dec_bug(v)      BUG_ON(atomic_dec_return(v) < 0)
@@ -566,12 +564,8 @@ static inline unsigned fract_exp_two(unsigned x, unsigned fract_bits)
        return x;
 }
 
-#define bio_end(bio)   ((bio)->bi_sector + bio_sectors(bio))
-
 void bch_bio_map(struct bio *bio, void *base);
 
-int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp);
-
 static inline sector_t bdev_sectors(struct block_device *bdev)
 {
        return bdev->bd_inode->i_size >> 9;
index 2714ed3991d1b747518aeb22d70222d1653d5e40..22cbff551628f3c9cff87ccc35563c09974f03b3 100644 (file)
@@ -9,6 +9,9 @@
 #include "bcache.h"
 #include "btree.h"
 #include "debug.h"
+#include "writeback.h"
+
+#include <trace/events/bcache.h>
 
 static struct workqueue_struct *dirty_wq;
 
@@ -36,7 +39,7 @@ static void __update_writeback_rate(struct cached_dev *dc)
 
        int change = 0;
        int64_t error;
-       int64_t dirty = atomic_long_read(&dc->disk.sectors_dirty);
+       int64_t dirty = bcache_dev_sectors_dirty(&dc->disk);
        int64_t derivative = dirty - dc->disk.sectors_dirty_last;
 
        dc->disk.sectors_dirty_last = dirty;
@@ -105,6 +108,31 @@ static bool dirty_pred(struct keybuf *buf, struct bkey *k)
        return KEY_DIRTY(k);
 }
 
+static bool dirty_full_stripe_pred(struct keybuf *buf, struct bkey *k)
+{
+       uint64_t stripe;
+       unsigned nr_sectors = KEY_SIZE(k);
+       struct cached_dev *dc = container_of(buf, struct cached_dev,
+                                            writeback_keys);
+       unsigned stripe_size = 1 << dc->disk.stripe_size_bits;
+
+       if (!KEY_DIRTY(k))
+               return false;
+
+       stripe = KEY_START(k) >> dc->disk.stripe_size_bits;
+       while (1) {
+               if (atomic_read(dc->disk.stripe_sectors_dirty + stripe) !=
+                   stripe_size)
+                       return false;
+
+               if (nr_sectors <= stripe_size)
+                       return true;
+
+               nr_sectors -= stripe_size;
+               stripe++;
+       }
+}
+
 static void dirty_init(struct keybuf_key *w)
 {
        struct dirty_io *io = w->private;
@@ -149,7 +177,22 @@ static void refill_dirty(struct closure *cl)
                searched_from_start = true;
        }
 
-       bch_refill_keybuf(dc->disk.c, buf, &end);
+       if (dc->partial_stripes_expensive) {
+               uint64_t i;
+
+               for (i = 0; i < dc->disk.nr_stripes; i++)
+                       if (atomic_read(dc->disk.stripe_sectors_dirty + i) ==
+                           1 << dc->disk.stripe_size_bits)
+                               goto full_stripes;
+
+               goto normal_refill;
+full_stripes:
+               bch_refill_keybuf(dc->disk.c, buf, &end,
+                                 dirty_full_stripe_pred);
+       } else {
+normal_refill:
+               bch_refill_keybuf(dc->disk.c, buf, &end, dirty_pred);
+       }
 
        if (bkey_cmp(&buf->last_scanned, &end) >= 0 && searched_from_start) {
                /* Searched the entire btree  - delay awhile */
@@ -181,10 +224,8 @@ void bch_writeback_queue(struct cached_dev *dc)
        }
 }
 
-void bch_writeback_add(struct cached_dev *dc, unsigned sectors)
+void bch_writeback_add(struct cached_dev *dc)
 {
-       atomic_long_add(sectors, &dc->disk.sectors_dirty);
-
        if (!atomic_read(&dc->has_dirty) &&
            !atomic_xchg(&dc->has_dirty, 1)) {
                atomic_inc(&dc->count);
@@ -203,6 +244,34 @@ void bch_writeback_add(struct cached_dev *dc, unsigned sectors)
        }
 }
 
+void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,
+                                 uint64_t offset, int nr_sectors)
+{
+       struct bcache_device *d = c->devices[inode];
+       unsigned stripe_size, stripe_offset;
+       uint64_t stripe;
+
+       if (!d)
+               return;
+
+       stripe_size = 1 << d->stripe_size_bits;
+       stripe = offset >> d->stripe_size_bits;
+       stripe_offset = offset & (stripe_size - 1);
+
+       while (nr_sectors) {
+               int s = min_t(unsigned, abs(nr_sectors),
+                             stripe_size - stripe_offset);
+
+               if (nr_sectors < 0)
+                       s = -s;
+
+               atomic_add(s, d->stripe_sectors_dirty + stripe);
+               nr_sectors -= s;
+               stripe_offset = 0;
+               stripe++;
+       }
+}
+
 /* Background writeback - IO loop */
 
 static void dirty_io_destructor(struct closure *cl)
@@ -216,9 +285,10 @@ static void write_dirty_finish(struct closure *cl)
        struct dirty_io *io = container_of(cl, struct dirty_io, cl);
        struct keybuf_key *w = io->bio.bi_private;
        struct cached_dev *dc = io->dc;
-       struct bio_vec *bv = bio_iovec_idx(&io->bio, io->bio.bi_vcnt);
+       struct bio_vec *bv;
+       int i;
 
-       while (bv-- != io->bio.bi_io_vec)
+       bio_for_each_segment_all(bv, &io->bio, i)
                __free_page(bv->bv_page);
 
        /* This is kind of a dumb way of signalling errors. */
@@ -236,10 +306,12 @@ static void write_dirty_finish(struct closure *cl)
                for (i = 0; i < KEY_PTRS(&w->key); i++)
                        atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin);
 
-               pr_debug("clearing %s", pkey(&w->key));
                bch_btree_insert(&op, dc->disk.c);
                closure_sync(&op.cl);
 
+               if (op.insert_collision)
+                       trace_bcache_writeback_collision(&w->key);
+
                atomic_long_inc(op.insert_collision
                                ? &dc->disk.c->writeback_keys_failed
                                : &dc->disk.c->writeback_keys_done);
@@ -275,7 +347,6 @@ static void write_dirty(struct closure *cl)
        io->bio.bi_bdev         = io->dc->bdev;
        io->bio.bi_end_io       = dirty_endio;
 
-       trace_bcache_write_dirty(&io->bio);
        closure_bio_submit(&io->bio, cl, &io->dc->disk);
 
        continue_at(cl, write_dirty_finish, dirty_wq);
@@ -296,7 +367,6 @@ static void read_dirty_submit(struct closure *cl)
 {
        struct dirty_io *io = container_of(cl, struct dirty_io, cl);
 
-       trace_bcache_read_dirty(&io->bio);
        closure_bio_submit(&io->bio, cl, &io->dc->disk);
 
        continue_at(cl, write_dirty, dirty_wq);
@@ -349,10 +419,10 @@ static void read_dirty(struct closure *cl)
                io->bio.bi_rw           = READ;
                io->bio.bi_end_io       = read_dirty_endio;
 
-               if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL))
+               if (bio_alloc_pages(&io->bio, GFP_KERNEL))
                        goto err_free;
 
-               pr_debug("%s", pkey(&w->key));
+               trace_bcache_writeback(&w->key);
 
                closure_call(&io->cl, read_dirty_submit, NULL, &dc->disk.cl);
 
@@ -375,12 +445,49 @@ err:
        refill_dirty(cl);
 }
 
+/* Init */
+
+static int bch_btree_sectors_dirty_init(struct btree *b, struct btree_op *op,
+                                       struct cached_dev *dc)
+{
+       struct bkey *k;
+       struct btree_iter iter;
+
+       bch_btree_iter_init(b, &iter, &KEY(dc->disk.id, 0, 0));
+       while ((k = bch_btree_iter_next_filter(&iter, b, bch_ptr_bad)))
+               if (!b->level) {
+                       if (KEY_INODE(k) > dc->disk.id)
+                               break;
+
+                       if (KEY_DIRTY(k))
+                               bcache_dev_sectors_dirty_add(b->c, dc->disk.id,
+                                                            KEY_START(k),
+                                                            KEY_SIZE(k));
+               } else {
+                       btree(sectors_dirty_init, k, b, op, dc);
+                       if (KEY_INODE(k) > dc->disk.id)
+                               break;
+
+                       cond_resched();
+               }
+
+       return 0;
+}
+
+void bch_sectors_dirty_init(struct cached_dev *dc)
+{
+       struct btree_op op;
+
+       bch_btree_op_init_stack(&op);
+       btree_root(sectors_dirty_init, dc->disk.c, &op, dc);
+}
+
 void bch_cached_dev_writeback_init(struct cached_dev *dc)
 {
        closure_init_unlocked(&dc->writeback);
        init_rwsem(&dc->writeback_lock);
 
-       bch_keybuf_init(&dc->writeback_keys, dirty_pred);
+       bch_keybuf_init(&dc->writeback_keys);
 
        dc->writeback_metadata          = true;
        dc->writeback_running           = true;
diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h
new file mode 100644 (file)
index 0000000..c91f61b
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef _BCACHE_WRITEBACK_H
+#define _BCACHE_WRITEBACK_H
+
+#define CUTOFF_WRITEBACK       40
+#define CUTOFF_WRITEBACK_SYNC  70
+
+static inline uint64_t bcache_dev_sectors_dirty(struct bcache_device *d)
+{
+       uint64_t i, ret = 0;
+
+       for (i = 0; i < d->nr_stripes; i++)
+               ret += atomic_read(d->stripe_sectors_dirty + i);
+
+       return ret;
+}
+
+static inline bool bcache_dev_stripe_dirty(struct bcache_device *d,
+                                          uint64_t offset,
+                                          unsigned nr_sectors)
+{
+       uint64_t stripe = offset >> d->stripe_size_bits;
+
+       while (1) {
+               if (atomic_read(d->stripe_sectors_dirty + stripe))
+                       return true;
+
+               if (nr_sectors <= 1 << d->stripe_size_bits)
+                       return false;
+
+               nr_sectors -= 1 << d->stripe_size_bits;
+               stripe++;
+       }
+}
+
+static inline bool should_writeback(struct cached_dev *dc, struct bio *bio,
+                                   unsigned cache_mode, bool would_skip)
+{
+       unsigned in_use = dc->disk.c->gc_stats.in_use;
+
+       if (cache_mode != CACHE_MODE_WRITEBACK ||
+           atomic_read(&dc->disk.detaching) ||
+           in_use > CUTOFF_WRITEBACK_SYNC)
+               return false;
+
+       if (dc->partial_stripes_expensive &&
+           bcache_dev_stripe_dirty(&dc->disk, bio->bi_sector,
+                                   bio_sectors(bio)))
+               return true;
+
+       if (would_skip)
+               return false;
+
+       return bio->bi_rw & REQ_SYNC ||
+               in_use <= CUTOFF_WRITEBACK;
+}
+
+void bcache_dev_sectors_dirty_add(struct cache_set *, unsigned, uint64_t, int);
+void bch_writeback_queue(struct cached_dev *);
+void bch_writeback_add(struct cached_dev *);
+
+void bch_sectors_dirty_init(struct cached_dev *dc);
+void bch_cached_dev_writeback_init(struct cached_dev *);
+
+#endif
index dc112a7137fe9280fca348908ed99b77f36f9417..4296155090b2b181f5840e21d97402ae0351d739 100644 (file)
@@ -959,23 +959,21 @@ out:
        return r;
 }
 
-static void remove_mapping(struct mq_policy *mq, dm_oblock_t oblock)
+static void mq_remove_mapping(struct dm_cache_policy *p, dm_oblock_t oblock)
 {
-       struct entry *e = hash_lookup(mq, oblock);
+       struct mq_policy *mq = to_mq_policy(p);
+       struct entry *e;
+
+       mutex_lock(&mq->lock);
+
+       e = hash_lookup(mq, oblock);
 
        BUG_ON(!e || !e->in_cache);
 
        del(mq, e);
        e->in_cache = false;
        push(mq, e);
-}
 
-static void mq_remove_mapping(struct dm_cache_policy *p, dm_oblock_t oblock)
-{
-       struct mq_policy *mq = to_mq_policy(p);
-
-       mutex_lock(&mq->lock);
-       remove_mapping(mq, oblock);
        mutex_unlock(&mq->lock);
 }
 
index dddc87bcf64aa3ef24ba9bda56d3347a457ed544..9f13e13506efbb3859786879ed6a5ff42eb72e8f 100644 (file)
@@ -7716,20 +7716,6 @@ static int remove_and_add_spares(struct mddev *mddev,
                        continue;
 
                rdev->recovery_offset = 0;
-               if (rdev->saved_raid_disk >= 0 && mddev->in_sync) {
-                       spin_lock_irq(&mddev->write_lock);
-                       if (mddev->in_sync)
-                               /* OK, this device, which is in_sync,
-                                * will definitely be noticed before
-                                * the next write, so recovery isn't
-                                * needed.
-                                */
-                               rdev->recovery_offset = mddev->recovery_cp;
-                       spin_unlock_irq(&mddev->write_lock);
-               }
-               if (mddev->ro && rdev->recovery_offset != MaxSector)
-                       /* not safe to add this disk now */
-                       continue;
                if (mddev->pers->
                    hot_add_disk(mddev, rdev) == 0) {
                        if (sysfs_link_rdev(mddev, rdev))
index ec734588a1c62c546800de9919e3ec63202c9cf8..d60412c7f9952a350e85002f6578bd66ee416a44 100644 (file)
@@ -1849,6 +1849,36 @@ static int process_checks(struct r1bio *r1_bio)
        int i;
        int vcnt;
 
+       /* Fix variable parts of all bios */
+       vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
+       for (i = 0; i < conf->raid_disks * 2; i++) {
+               int j;
+               int size;
+               struct bio *b = r1_bio->bios[i];
+               if (b->bi_end_io != end_sync_read)
+                       continue;
+               /* fixup the bio for reuse */
+               bio_reset(b);
+               b->bi_vcnt = vcnt;
+               b->bi_size = r1_bio->sectors << 9;
+               b->bi_sector = r1_bio->sector +
+                       conf->mirrors[i].rdev->data_offset;
+               b->bi_bdev = conf->mirrors[i].rdev->bdev;
+               b->bi_end_io = end_sync_read;
+               b->bi_private = r1_bio;
+
+               size = b->bi_size;
+               for (j = 0; j < vcnt ; j++) {
+                       struct bio_vec *bi;
+                       bi = &b->bi_io_vec[j];
+                       bi->bv_offset = 0;
+                       if (size > PAGE_SIZE)
+                               bi->bv_len = PAGE_SIZE;
+                       else
+                               bi->bv_len = size;
+                       size -= PAGE_SIZE;
+               }
+       }
        for (primary = 0; primary < conf->raid_disks * 2; primary++)
                if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
                    test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) {
@@ -1857,12 +1887,10 @@ static int process_checks(struct r1bio *r1_bio)
                        break;
                }
        r1_bio->read_disk = primary;
-       vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
        for (i = 0; i < conf->raid_disks * 2; i++) {
                int j;
                struct bio *pbio = r1_bio->bios[primary];
                struct bio *sbio = r1_bio->bios[i];
-               int size;
 
                if (sbio->bi_end_io != end_sync_read)
                        continue;
@@ -1888,27 +1916,6 @@ static int process_checks(struct r1bio *r1_bio)
                        rdev_dec_pending(conf->mirrors[i].rdev, mddev);
                        continue;
                }
-               /* fixup the bio for reuse */
-               bio_reset(sbio);
-               sbio->bi_vcnt = vcnt;
-               sbio->bi_size = r1_bio->sectors << 9;
-               sbio->bi_sector = r1_bio->sector +
-                       conf->mirrors[i].rdev->data_offset;
-               sbio->bi_bdev = conf->mirrors[i].rdev->bdev;
-               sbio->bi_end_io = end_sync_read;
-               sbio->bi_private = r1_bio;
-
-               size = sbio->bi_size;
-               for (j = 0; j < vcnt ; j++) {
-                       struct bio_vec *bi;
-                       bi = &sbio->bi_io_vec[j];
-                       bi->bv_offset = 0;
-                       if (size > PAGE_SIZE)
-                               bi->bv_len = PAGE_SIZE;
-                       else
-                               bi->bv_len = size;
-                       size -= PAGE_SIZE;
-               }
 
                bio_copy_data(sbio, pbio);
        }
index cd066b63bdafea61ae1175428f2c261575cfd4d1..df7b0a06b0ea2d820aec6ad5a752a13bb64e13e8 100644 (file)
@@ -2097,11 +2097,17 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
                         * both 'first' and 'i', so we just compare them.
                         * All vec entries are PAGE_SIZE;
                         */
-                       for (j = 0; j < vcnt; j++)
+                       int sectors = r10_bio->sectors;
+                       for (j = 0; j < vcnt; j++) {
+                               int len = PAGE_SIZE;
+                               if (sectors < (len / 512))
+                                       len = sectors * 512;
                                if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
                                           page_address(tbio->bi_io_vec[j].bv_page),
-                                          fbio->bi_io_vec[j].bv_len))
+                                          len))
                                        break;
+                               sectors -= len/512;
+                       }
                        if (j == vcnt)
                                continue;
                        atomic64_add(r10_bio->sectors, &mddev->resync_mismatches);
@@ -2284,12 +2290,18 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)
        d = r10_bio->devs[1].devnum;
        wbio = r10_bio->devs[1].bio;
        wbio2 = r10_bio->devs[1].repl_bio;
+       /* Need to test wbio2->bi_end_io before we call
+        * generic_make_request as if the former is NULL,
+        * the latter is free to free wbio2.
+        */
+       if (wbio2 && !wbio2->bi_end_io)
+               wbio2 = NULL;
        if (wbio->bi_end_io) {
                atomic_inc(&conf->mirrors[d].rdev->nr_pending);
                md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio));
                generic_make_request(wbio);
        }
-       if (wbio2 && wbio2->bi_end_io) {
+       if (wbio2) {
                atomic_inc(&conf->mirrors[d].replacement->nr_pending);
                md_sync_acct(conf->mirrors[d].replacement->bdev,
                             bio_sectors(wbio2));
@@ -3407,6 +3419,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
 
                if (bio->bi_end_io == end_sync_read) {
                        md_sync_acct(bio->bi_bdev, nr_sectors);
+                       set_bit(BIO_UPTODATE, &bio->bi_flags);
                        generic_make_request(bio);
                }
        }
index 2bf094a587cb8ff2efb7e1bcabe6f40cd7b52602..78ea44336e75e06d5769b4a6158f2a1e506214e0 100644 (file)
@@ -3462,6 +3462,7 @@ static void handle_stripe(struct stripe_head *sh)
                    test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
                        set_bit(STRIPE_SYNCING, &sh->state);
                        clear_bit(STRIPE_INSYNC, &sh->state);
+                       clear_bit(STRIPE_REPLACED, &sh->state);
                }
                spin_unlock(&sh->stripe_lock);
        }
@@ -3607,19 +3608,23 @@ static void handle_stripe(struct stripe_head *sh)
                        handle_parity_checks5(conf, sh, &s, disks);
        }
 
-       if (s.replacing && s.locked == 0
-           && !test_bit(STRIPE_INSYNC, &sh->state)) {
+       if ((s.replacing || s.syncing) && s.locked == 0
+           && !test_bit(STRIPE_COMPUTE_RUN, &sh->state)
+           && !test_bit(STRIPE_REPLACED, &sh->state)) {
                /* Write out to replacement devices where possible */
                for (i = 0; i < conf->raid_disks; i++)
-                       if (test_bit(R5_UPTODATE, &sh->dev[i].flags) &&
-                           test_bit(R5_NeedReplace, &sh->dev[i].flags)) {
+                       if (test_bit(R5_NeedReplace, &sh->dev[i].flags)) {
+                               WARN_ON(!test_bit(R5_UPTODATE, &sh->dev[i].flags));
                                set_bit(R5_WantReplace, &sh->dev[i].flags);
                                set_bit(R5_LOCKED, &sh->dev[i].flags);
                                s.locked++;
                        }
-               set_bit(STRIPE_INSYNC, &sh->state);
+               if (s.replacing)
+                       set_bit(STRIPE_INSYNC, &sh->state);
+               set_bit(STRIPE_REPLACED, &sh->state);
        }
        if ((s.syncing || s.replacing) && s.locked == 0 &&
+           !test_bit(STRIPE_COMPUTE_RUN, &sh->state) &&
            test_bit(STRIPE_INSYNC, &sh->state)) {
                md_done_sync(conf->mddev, STRIPE_SECTORS, 1);
                clear_bit(STRIPE_SYNCING, &sh->state);
index b0b663b119a8f324ba7fa3b58953b42c81030fa4..70c49329ca9a23fbbad73061477ac0a0cfe80e6e 100644 (file)
@@ -306,6 +306,7 @@ enum {
        STRIPE_SYNC_REQUESTED,
        STRIPE_SYNCING,
        STRIPE_INSYNC,
+       STRIPE_REPLACED,
        STRIPE_PREREAD_ACTIVE,
        STRIPE_DELAYED,
        STRIPE_DEGRADED,
index efdc873e58d122d322d53a3876f88a46f4ddb04f..a9857022f71d424a02baa2aaf84652781db58fa7 100644 (file)
@@ -117,7 +117,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl)
 {
        struct v4l2_subdev *sd = to_sd(ctrl);
        struct i2c_client *client = v4l2_get_subdevdata(sd);
-       int ret;
+       int ret = -EINVAL;
 
        switch (ctrl->id) {
        case V4L2_CID_BRIGHTNESS:
@@ -157,7 +157,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl)
                break;
        }
 
-       return 0;
+       return ret;
 }
 
 static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
index 10460fd3ce3994c5865e11e4f990407b2b583c47..dbcdfbf8aed0bdeae1f5d6ffff71bbe7a4e7d9da 100644 (file)
@@ -172,7 +172,9 @@ static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
                dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
                        dev->dmasound.bufsize, dev->dmasound.blocks);
                spin_unlock(&dev->slock);
+               snd_pcm_stream_lock(dev->dmasound.substream);
                snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock(dev->dmasound.substream);
                return;
        }
 
index df4ada880e4215519b33cc81ab3cdb5d2c8e6dce..bd9405df1bd67abf3a8051d0cefabe3a7ad0c362 100644 (file)
@@ -1987,7 +1987,7 @@ MODULE_DEVICE_TABLE(platform, coda_platform_ids);
 
 #ifdef CONFIG_OF
 static const struct of_device_id coda_dt_ids[] = {
-       { .compatible = "fsl,imx27-vpu", .data = &coda_platform_ids[CODA_IMX27] },
+       { .compatible = "fsl,imx27-vpu", .data = &coda_devdata[CODA_IMX27] },
        { .compatible = "fsl,imx53-vpu", .data = &coda_devdata[CODA_IMX53] },
        { /* sentinel */ }
 };
index 553d87e5ceab41b9d2d081c6fc55dbe4b17db1ed..fd6289d60cde2c8a25450f6cb6d24c18923f0e81 100644 (file)
@@ -784,6 +784,7 @@ static int g2d_probe(struct platform_device *pdev)
        }
        *vfd = g2d_videodev;
        vfd->lock = &dev->mutex;
+       vfd->v4l2_dev = &dev->v4l2_dev;
        ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
        if (ret) {
                v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
index 5296385153d5d17ce0a3c3d6f6bf0d8513bb10f4..4f6dd42c9adb06755eebbc520ba57124f77a5e35 100644 (file)
@@ -344,7 +344,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
                pix_mp->num_planes = 2;
                /* Set pixelformat to the format in which MFC
                   outputs the decoded frame */
-               pix_mp->pixelformat = V4L2_PIX_FMT_NV12MT;
+               pix_mp->pixelformat = ctx->dst_fmt->fourcc;
                pix_mp->plane_fmt[0].bytesperline = ctx->buf_width;
                pix_mp->plane_fmt[0].sizeimage = ctx->luma_size;
                pix_mp->plane_fmt[1].bytesperline = ctx->buf_width;
@@ -382,10 +382,16 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
                        mfc_err("Unsupported format for source.\n");
                        return -EINVAL;
                }
-               if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
-                       mfc_err("Not supported format.\n");
+               if (fmt->codec_mode == S5P_FIMV_CODEC_NONE) {
+                       mfc_err("Unknown codec\n");
                        return -EINVAL;
                }
+               if (!IS_MFCV6(dev)) {
+                       if (fmt->fourcc == V4L2_PIX_FMT_VP8) {
+                               mfc_err("Not supported format.\n");
+                               return -EINVAL;
+                       }
+               }
        } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                fmt = find_format(f, MFC_FMT_RAW);
                if (!fmt) {
@@ -411,7 +417,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
        struct s5p_mfc_dev *dev = video_drvdata(file);
        struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
        int ret = 0;
-       struct s5p_mfc_fmt *fmt;
        struct v4l2_pix_format_mplane *pix_mp;
 
        mfc_debug_enter();
@@ -425,54 +430,32 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                goto out;
        }
        if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-               fmt = find_format(f, MFC_FMT_RAW);
-               if (!fmt) {
-                       mfc_err("Unsupported format for source.\n");
-                       return -EINVAL;
-               }
-               if (!IS_MFCV6(dev) && (fmt->fourcc != V4L2_PIX_FMT_NV12MT)) {
-                       mfc_err("Not supported format.\n");
-                       return -EINVAL;
-               } else if (IS_MFCV6(dev) &&
-                               (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
-                       mfc_err("Not supported format.\n");
-                       return -EINVAL;
-               }
-               ctx->dst_fmt = fmt;
-               mfc_debug_leave();
-               return ret;
-       } else if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-               mfc_err("Wrong type error for S_FMT : %d", f->type);
-               return -EINVAL;
-       }
-       fmt = find_format(f, MFC_FMT_DEC);
-       if (!fmt || fmt->codec_mode == S5P_MFC_CODEC_NONE) {
-               mfc_err("Unknown codec\n");
-               ret = -EINVAL;
+               /* dst_fmt is validated by call to vidioc_try_fmt */
+               ctx->dst_fmt = find_format(f, MFC_FMT_RAW);
+               ret = 0;
                goto out;
-       }
-       if (fmt->type != MFC_FMT_DEC) {
-               mfc_err("Wrong format selected, you should choose "
-                                       "format for decoding\n");
+       } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+               /* src_fmt is validated by call to vidioc_try_fmt */
+               ctx->src_fmt = find_format(f, MFC_FMT_DEC);
+               ctx->codec_mode = ctx->src_fmt->codec_mode;
+               mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
+               pix_mp->height = 0;
+               pix_mp->width = 0;
+               if (pix_mp->plane_fmt[0].sizeimage)
+                       ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
+               else
+                       pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
+                                                               DEF_CPB_SIZE;
+               pix_mp->plane_fmt[0].bytesperline = 0;
+               ctx->state = MFCINST_INIT;
+               ret = 0;
+               goto out;
+       } else {
+               mfc_err("Wrong type error for S_FMT : %d", f->type);
                ret = -EINVAL;
                goto out;
        }
-       if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) {
-               mfc_err("Not supported format.\n");
-               return -EINVAL;
-       }
-       ctx->src_fmt = fmt;
-       ctx->codec_mode = fmt->codec_mode;
-       mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
-       pix_mp->height = 0;
-       pix_mp->width = 0;
-       if (pix_mp->plane_fmt[0].sizeimage)
-               ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
-       else
-               pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
-                                                               DEF_CPB_SIZE;
-       pix_mp->plane_fmt[0].bytesperline = 0;
-       ctx->state = MFCINST_INIT;
+
 out:
        mfc_debug_leave();
        return ret;
index 2549967b2f8589bb46007b8282520250392287b7..59e56f4c8ce34ded878308537b5de1a57595acf1 100644 (file)
@@ -906,6 +906,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
 
 static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
+       struct s5p_mfc_dev *dev = video_drvdata(file);
        struct s5p_mfc_fmt *fmt;
        struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
 
@@ -930,6 +931,18 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
                        return -EINVAL;
                }
 
+               if (!IS_MFCV6(dev)) {
+                       if (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
+                               mfc_err("Not supported format.\n");
+                               return -EINVAL;
+                       }
+               } else if (IS_MFCV6(dev)) {
+                       if (fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
+                               mfc_err("Not supported format.\n");
+                               return -EINVAL;
+                       }
+               }
+
                if (fmt->num_planes != pix_fmt_mp->num_planes) {
                        mfc_err("failed to try output format\n");
                        return -EINVAL;
@@ -947,7 +960,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
        struct s5p_mfc_dev *dev = video_drvdata(file);
        struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
-       struct s5p_mfc_fmt *fmt;
        struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
        int ret = 0;
 
@@ -960,13 +972,9 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                goto out;
        }
        if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-               fmt = find_format(f, MFC_FMT_ENC);
-               if (!fmt) {
-                       mfc_err("failed to set capture format\n");
-                       return -EINVAL;
-               }
+               /* dst_fmt is validated by call to vidioc_try_fmt */
+               ctx->dst_fmt = find_format(f, MFC_FMT_ENC);
                ctx->state = MFCINST_INIT;
-               ctx->dst_fmt = fmt;
                ctx->codec_mode = ctx->dst_fmt->codec_mode;
                ctx->enc_dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage;
                pix_fmt_mp->plane_fmt[0].bytesperline = 0;
@@ -987,28 +995,8 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
                }
                mfc_debug(2, "Got instance number: %d\n", ctx->inst_no);
        } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
-               fmt = find_format(f, MFC_FMT_RAW);
-               if (!fmt) {
-                       mfc_err("failed to set output format\n");
-                       return -EINVAL;
-               }
-
-               if (!IS_MFCV6(dev) &&
-                               (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)) {
-                       mfc_err("Not supported format.\n");
-                       return -EINVAL;
-               } else if (IS_MFCV6(dev) &&
-                               (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
-                       mfc_err("Not supported format.\n");
-                       return -EINVAL;
-               }
-
-               if (fmt->num_planes != pix_fmt_mp->num_planes) {
-                       mfc_err("failed to set output format\n");
-                       ret = -EINVAL;
-                       goto out;
-               }
-               ctx->src_fmt = fmt;
+               /* src_fmt is validated by call to vidioc_try_fmt */
+               ctx->src_fmt = find_format(f, MFC_FMT_RAW);
                ctx->img_width = pix_fmt_mp->width;
                ctx->img_height = pix_fmt_mp->height;
                mfc_debug(2, "codec number: %d\n", ctx->src_fmt->codec_mode);
index 4851cc2e4a4d3227b59df97c8020298b41796c77..c4ff9739a7ae8cb099b21637dc23723e5e170d1b 100644 (file)
@@ -726,7 +726,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
 
        *eedata = data;
        *eedata_len = len;
-       dev_config = (void *)eedata;
+       dev_config = (void *)*eedata;
 
        switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) {
        case 0:
index cb694055ba7d103ad75bfd73b2f41a0b0cb1e315..6e5070774dc2ca480fe3970c75bb79c0a893e47b 100644 (file)
@@ -303,6 +303,11 @@ static int hdpvr_probe(struct usb_interface *interface,
 
        dev->workqueue = 0;
 
+       /* init video transfer queues first of all */
+       /* to prevent oops in hdpvr_delete() on error paths */
+       INIT_LIST_HEAD(&dev->free_buff_list);
+       INIT_LIST_HEAD(&dev->rec_buff_list);
+
        /* register v4l2_device early so it can be used for printks */
        if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
                dev_err(&interface->dev, "v4l2_device_register failed\n");
@@ -325,10 +330,6 @@ static int hdpvr_probe(struct usb_interface *interface,
        if (!dev->workqueue)
                goto error;
 
-       /* init video transfer queues */
-       INIT_LIST_HEAD(&dev->free_buff_list);
-       INIT_LIST_HEAD(&dev->rec_buff_list);
-
        dev->options = hdpvr_default_options;
 
        if (default_video_input < HDPVR_VIDEO_INPUTS)
@@ -405,7 +406,7 @@ static int hdpvr_probe(struct usb_interface *interface,
                                    video_nr[atomic_inc_return(&dev_nr)]);
        if (retval < 0) {
                v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
-               goto error;
+               goto reg_fail;
        }
 
        /* let the user know what node this device is now attached to */
index 8864436464bf2d9e6aaf3199fb58a5d9e10294ab..7c5b86006ee627c43a52003fb816c7fceb10b6f4 100644 (file)
@@ -1,6 +1,6 @@
 config VIDEO_USBTV
         tristate "USBTV007 video capture support"
-        depends on VIDEO_DEV
+        depends on VIDEO_V4L2
         select VIDEOBUF2_VMALLOC
 
         ---help---
index bf43f874685e2e5ba6acf97e891b8a09a7676432..91650173941ad5629a56cae9bacff0a4072002f1 100644 (file)
@@ -57,7 +57,7 @@
 #define USBTV_CHUNK_SIZE       256
 #define USBTV_CHUNK            240
 #define USBTV_CHUNKS           (USBTV_WIDTH * USBTV_HEIGHT \
-                                       / 2 / USBTV_CHUNK)
+                                       / 4 / USBTV_CHUNK)
 
 /* Chunk header. */
 #define USBTV_MAGIC_OK(chunk)  ((be32_to_cpu(chunk[0]) & 0xff000000) \
@@ -89,6 +89,7 @@ struct usbtv {
        /* Number of currently processed frame, useful find
         * out when a new one begins. */
        u32 frame_id;
+       int chunks_done;
 
        int iso_size;
        unsigned int sequence;
@@ -202,6 +203,26 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
        return 0;
 }
 
+/* Copy data from chunk into a frame buffer, deinterlacing the data
+ * into every second line. Unfortunately, they don't align nicely into
+ * 720 pixel lines, as the chunk is 240 words long, which is 480 pixels.
+ * Therefore, we break down the chunk into two halves before copyting,
+ * so that we can interleave a line if needed. */
+static void usbtv_chunk_to_vbuf(u32 *frame, u32 *src, int chunk_no, int odd)
+{
+       int half;
+
+       for (half = 0; half < 2; half++) {
+               int part_no = chunk_no * 2 + half;
+               int line = part_no / 3;
+               int part_index = (line * 2 + !odd) * 3 + (part_no % 3);
+
+               u32 *dst = &frame[part_index * USBTV_CHUNK/2];
+               memcpy(dst, src, USBTV_CHUNK/2 * sizeof(*src));
+               src += USBTV_CHUNK/2;
+       }
+}
+
 /* Called for each 256-byte image chunk.
  * First word identifies the chunk, followed by 240 words of image
  * data and padding. */
@@ -218,17 +239,17 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
        frame_id = USBTV_FRAME_ID(chunk);
        odd = USBTV_ODD(chunk);
        chunk_no = USBTV_CHUNK_NO(chunk);
-
-       /* Deinterlace. TODO: Use interlaced frame format. */
-       chunk_no = (chunk_no - chunk_no % 3) * 2 + chunk_no % 3;
-       chunk_no += !odd * 3;
-
        if (chunk_no >= USBTV_CHUNKS)
                return;
 
        /* Beginning of a frame. */
-       if (chunk_no == 0)
+       if (chunk_no == 0) {
                usbtv->frame_id = frame_id;
+               usbtv->chunks_done = 0;
+       }
+
+       if (usbtv->frame_id != frame_id)
+               return;
 
        spin_lock_irqsave(&usbtv->buflock, flags);
        if (list_empty(&usbtv->bufs)) {
@@ -241,19 +262,23 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
        buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list);
        frame = vb2_plane_vaddr(&buf->vb, 0);
 
-       /* Copy the chunk. */
-       memcpy(&frame[chunk_no * USBTV_CHUNK], &chunk[1],
-                       USBTV_CHUNK * sizeof(chunk[1]));
+       /* Copy the chunk data. */
+       usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd);
+       usbtv->chunks_done++;
 
        /* Last chunk in a frame, signalling an end */
-       if (usbtv->frame_id && chunk_no == USBTV_CHUNKS-1) {
+       if (odd && chunk_no == USBTV_CHUNKS-1) {
                int size = vb2_plane_size(&buf->vb, 0);
+               enum vb2_buffer_state state = usbtv->chunks_done ==
+                                               USBTV_CHUNKS ?
+                                               VB2_BUF_STATE_DONE :
+                                               VB2_BUF_STATE_ERROR;
 
                buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
                buf->vb.v4l2_buf.sequence = usbtv->sequence++;
                v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
                vb2_set_plane_payload(&buf->vb, 0, size);
-               vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE);
+               vb2_buffer_done(&buf->vb, state);
                list_del(&buf->list);
        }
 
@@ -518,7 +543,7 @@ static int usbtv_queue_setup(struct vb2_queue *vq,
        if (*nbuffers < 2)
                *nbuffers = 2;
        *nplanes = 1;
-       sizes[0] = USBTV_CHUNK * USBTV_CHUNKS * sizeof(u32);
+       sizes[0] = USBTV_WIDTH * USBTV_HEIGHT / 2 * sizeof(u32);
 
        return 0;
 }
index f7b90661e3213668310274b445f51d972ef4b9a5..e068a76a5f6f268bf183097007efb3aa571acb89 100644 (file)
@@ -66,14 +66,19 @@ EXPORT_SYMBOL(ssc_request);
 
 void ssc_free(struct ssc_device *ssc)
 {
+       bool disable_clk = true;
+
        spin_lock(&user_lock);
-       if (ssc->user) {
+       if (ssc->user)
                ssc->user--;
-               clk_disable_unprepare(ssc->clk);
-       } else {
+       else {
+               disable_clk = false;
                dev_dbg(&ssc->pdev->dev, "device already free\n");
        }
        spin_unlock(&user_lock);
+
+       if (disable_clk)
+               clk_disable_unprepare(ssc->clk);
 }
 EXPORT_SYMBOL(ssc_free);
 
index f9296abcf02ad88dd2b2fd6675c8c27bd7e0eda7..6127ab64bb399323e57e418e9742c2f5b8a9d86d 100644 (file)
@@ -167,7 +167,7 @@ int mei_hbm_start_req(struct mei_device *dev)
 
        dev->hbm_state = MEI_HBM_IDLE;
        if (mei_write_message(dev, mei_hdr, dev->wr_msg.data)) {
-               dev_err(&dev->pdev->dev, "version message writet failed\n");
+               dev_err(&dev->pdev->dev, "version message write failed\n");
                dev->dev_state = MEI_DEV_RESETTING;
                mei_reset(dev, 1);
                return -ENODEV;
index e4f8dec4dc3ccf134317abbd70594f503e9a5344..b22c7e2472254b89dbacc20c20772dfd297d575e 100644 (file)
@@ -239,14 +239,18 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)
        if (mei_me_hw_is_ready(dev))
                return 0;
 
+       dev->recvd_hw_ready = false;
        mutex_unlock(&dev->device_lock);
        err = wait_event_interruptible_timeout(dev->wait_hw_ready,
-                       dev->recvd_hw_ready, MEI_INTEROP_TIMEOUT);
+                       dev->recvd_hw_ready,
+                       mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT));
        mutex_lock(&dev->device_lock);
        if (!err && !dev->recvd_hw_ready) {
+               if (!err)
+                       err = -ETIMEDOUT;
                dev_err(&dev->pdev->dev,
-                       "wait hw ready failed. status = 0x%x\n", err);
-               return -ETIMEDOUT;
+                       "wait hw ready failed. status = %d\n", err);
+               return err;
        }
 
        dev->recvd_hw_ready = false;
@@ -483,7 +487,9 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
        /* check if ME wants a reset */
        if (!mei_hw_is_ready(dev) &&
            dev->dev_state != MEI_DEV_RESETTING &&
-           dev->dev_state != MEI_DEV_INITIALIZING) {
+           dev->dev_state != MEI_DEV_INITIALIZING &&
+           dev->dev_state != MEI_DEV_POWER_DOWN &&
+           dev->dev_state != MEI_DEV_POWER_UP) {
                dev_dbg(&dev->pdev->dev, "FW not ready.\n");
                mei_reset(dev, 1);
                mutex_unlock(&dev->device_lock);
index ed1d75203af6e702de1e7a5c3fbdb6b6e8a765d6..e6f16f83ecdee479bfd679f169e078866bd3354a 100644 (file)
@@ -148,7 +148,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)
 
        dev->hbm_state = MEI_HBM_IDLE;
 
-       if (dev->dev_state != MEI_DEV_INITIALIZING) {
+       if (dev->dev_state != MEI_DEV_INITIALIZING &&
+           dev->dev_state != MEI_DEV_POWER_UP) {
                if (dev->dev_state != MEI_DEV_DISABLED &&
                    dev->dev_state != MEI_DEV_POWER_DOWN)
                        dev->dev_state = MEI_DEV_RESETTING;
index 847b1996ce8ea105eeec31366dad87621a320ee2..2c5a91bb8ec3dbcf1433e114625e94b7d4c3cfe6 100644 (file)
@@ -128,7 +128,7 @@ static inline int pxamci_set_power(struct pxamci_host *host,
                               !!on ^ host->pdata->gpio_power_invert);
        }
        if (!host->vcc && host->pdata && host->pdata->setpower)
-               host->pdata->setpower(mmc_dev(host->mmc), vdd);
+               return host->pdata->setpower(mmc_dev(host->mmc), vdd);
 
        return 0;
 }
index a746ba272f04b5e3b77a4e45f65809a398c73585..a956053608f9f6a9fdb94c877917150e6a25680e 100644 (file)
@@ -1007,7 +1007,7 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
 
        soft = &pkt.soft.rfc1201;
 
-       lp->hw.copy_from_card(dev, bufnum, 0, &pkt, sizeof(ARC_HDR_SIZE));
+       lp->hw.copy_from_card(dev, bufnum, 0, &pkt, ARC_HDR_SIZE);
        if (pkt.hard.offset[0]) {
                ofs = pkt.hard.offset[0];
                length = 256 - ofs;
index 390061d096934f83c04171a1a8a62bf9d8345ec5..90102652c82a9651a09a49741453fd76dbeb47a4 100644 (file)
@@ -143,10 +143,9 @@ static inline struct bonding *__get_bond_by_port(struct port *port)
  */
 static inline struct port *__get_first_port(struct bonding *bond)
 {
-       if (bond->slave_cnt == 0)
-               return NULL;
+       struct slave *first_slave = bond_first_slave(bond);
 
-       return &(SLAVE_AD_INFO(bond->first_slave).port);
+       return first_slave ? &(SLAVE_AD_INFO(first_slave).port) : NULL;
 }
 
 /**
@@ -159,13 +158,16 @@ static inline struct port *__get_first_port(struct bonding *bond)
 static inline struct port *__get_next_port(struct port *port)
 {
        struct bonding *bond = __get_bond_by_port(port);
-       struct slave *slave = port->slave;
+       struct slave *slave = port->slave, *slave_next;
 
        // If there's no bond for this port, or this is the last slave
-       if ((bond == NULL) || (slave->next == bond->first_slave))
+       if (bond == NULL)
+               return NULL;
+       slave_next = bond_next_slave(bond, slave);
+       if (!slave_next || bond_is_first_slave(bond, slave_next))
                return NULL;
 
-       return &(SLAVE_AD_INFO(slave->next).port);
+       return &(SLAVE_AD_INFO(slave_next).port);
 }
 
 /**
@@ -178,12 +180,14 @@ static inline struct port *__get_next_port(struct port *port)
 static inline struct aggregator *__get_first_agg(struct port *port)
 {
        struct bonding *bond = __get_bond_by_port(port);
+       struct slave *first_slave;
 
        // If there's no bond for this port, or bond has no slaves
-       if ((bond == NULL) || (bond->slave_cnt == 0))
+       if (bond == NULL)
                return NULL;
+       first_slave = bond_first_slave(bond);
 
-       return &(SLAVE_AD_INFO(bond->first_slave).aggregator);
+       return first_slave ? &(SLAVE_AD_INFO(first_slave).aggregator) : NULL;
 }
 
 /**
@@ -195,14 +199,17 @@ static inline struct aggregator *__get_first_agg(struct port *port)
  */
 static inline struct aggregator *__get_next_agg(struct aggregator *aggregator)
 {
-       struct slave *slave = aggregator->slave;
+       struct slave *slave = aggregator->slave, *slave_next;
        struct bonding *bond = bond_get_bond_by_slave(slave);
 
        // If there's no bond for this aggregator, or this is the last slave
-       if ((bond == NULL) || (slave->next == bond->first_slave))
+       if (bond == NULL)
+               return NULL;
+       slave_next = bond_next_slave(bond, slave);
+       if (!slave_next || bond_is_first_slave(bond, slave_next))
                return NULL;
 
-       return &(SLAVE_AD_INFO(slave->next).aggregator);
+       return &(SLAVE_AD_INFO(slave_next).aggregator);
 }
 
 /*
@@ -2110,7 +2117,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
        read_lock(&bond->lock);
 
        //check if there are any slaves
-       if (bond->slave_cnt == 0)
+       if (list_empty(&bond->slave_list))
                goto re_arm;
 
        // check if agg_select_timer timer after initialize is timed out
@@ -2336,8 +2343,12 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 int bond_3ad_set_carrier(struct bonding *bond)
 {
        struct aggregator *active;
+       struct slave *first_slave;
 
-       active = __get_active_agg(&(SLAVE_AD_INFO(bond->first_slave).aggregator));
+       first_slave = bond_first_slave(bond);
+       if (!first_slave)
+               return 0;
+       active = __get_active_agg(&(SLAVE_AD_INFO(first_slave).aggregator));
        if (active) {
                /* are enough slaves available to consider link up? */
                if (active->num_of_ports < bond->params.min_links) {
@@ -2415,6 +2426,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
        struct ad_info ad_info;
        int res = 1;
 
+       read_lock(&bond->lock);
        if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
                pr_debug("%s: Error: __bond_3ad_get_active_agg_info failed\n",
                         dev->name);
@@ -2432,7 +2444,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
 
        slave_agg_no = bond->xmit_hash_policy(skb, slaves_in_agg);
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator;
 
                if (agg && (agg->aggregator_identifier == agg_id)) {
@@ -2464,6 +2476,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
        }
 
 out:
+       read_unlock(&bond->lock);
        if (res) {
                /* no suitable interface, frame not sent */
                kfree_skb(skb);
@@ -2501,7 +2514,6 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
  */
 void bond_3ad_update_lacp_rate(struct bonding *bond)
 {
-       int i;
        struct slave *slave;
        struct port *port = NULL;
        int lacp_fast;
@@ -2509,7 +2521,7 @@ void bond_3ad_update_lacp_rate(struct bonding *bond)
        write_lock_bh(&bond->lock);
        lacp_fast = bond->params.lacp_fast;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                port = &(SLAVE_AD_INFO(slave).port);
                if (port->slave == NULL)
                        continue;
index 4ea8ed150d469d55c741d63c09fa4fc7f7a29fa5..3a5db7b1df6845829c686bd8cece52e0467190e5 100644 (file)
@@ -224,13 +224,12 @@ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
 {
        struct slave *slave, *least_loaded;
        long long max_gap;
-       int i;
 
        least_loaded = NULL;
        max_gap = LLONG_MIN;
 
        /* Find the slave with the largest gap */
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (SLAVE_IS_OK(slave)) {
                        long long gap = compute_gap(slave);
 
@@ -386,11 +385,10 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
        struct slave *rx_slave, *slave, *start_at;
        int i = 0;
 
-       if (bond_info->next_rx_slave) {
+       if (bond_info->next_rx_slave)
                start_at = bond_info->next_rx_slave;
-       } else {
-               start_at = bond->first_slave;
-       }
+       else
+               start_at = bond_first_slave(bond);
 
        rx_slave = NULL;
 
@@ -405,7 +403,8 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond)
        }
 
        if (rx_slave) {
-               bond_info->next_rx_slave = rx_slave->next;
+               slave = bond_next_slave(bond, rx_slave);
+               bond_info->next_rx_slave = slave;
        }
 
        return rx_slave;
@@ -1173,9 +1172,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
 {
        struct slave *tmp_slave1, *free_mac_slave = NULL;
        struct slave *has_bond_addr = bond->curr_active_slave;
-       int i;
 
-       if (bond->slave_cnt == 0) {
+       if (list_empty(&bond->slave_list)) {
                /* this is the first slave */
                return 0;
        }
@@ -1196,7 +1194,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
        /* The slave's address is equal to the address of the bond.
         * Search for a spare address in the bond for this slave.
         */
-       bond_for_each_slave(bond, tmp_slave1, i) {
+       bond_for_each_slave(bond, tmp_slave1) {
                if (!bond_slave_has_mac(bond, tmp_slave1->perm_hwaddr)) {
                        /* no slave has tmp_slave1's perm addr
                         * as its curr addr
@@ -1246,17 +1244,15 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
  */
 static int alb_set_mac_address(struct bonding *bond, void *addr)
 {
-       struct sockaddr sa;
-       struct slave *slave, *stop_at;
        char tmp_addr[ETH_ALEN];
+       struct slave *slave;
+       struct sockaddr sa;
        int res;
-       int i;
 
-       if (bond->alb_info.rlb_enabled) {
+       if (bond->alb_info.rlb_enabled)
                return 0;
-       }
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                /* save net_device's current hw address */
                memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
 
@@ -1276,8 +1272,7 @@ unwind:
        sa.sa_family = bond->dev->type;
 
        /* unwind from head to the slave that failed */
-       stop_at = slave;
-       bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
+       bond_for_each_slave_continue_reverse(bond, slave) {
                memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
                dev_set_mac_address(slave->dev, &sa);
                memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
@@ -1342,6 +1337,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
 
        /* make sure that the curr_active_slave do not change during tx
         */
+       read_lock(&bond->lock);
        read_lock(&bond->curr_slave_lock);
 
        switch (ntohs(skb->protocol)) {
@@ -1446,11 +1442,12 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
        }
 
        read_unlock(&bond->curr_slave_lock);
-
+       read_unlock(&bond->lock);
        if (res) {
                /* no suitable interface, frame not sent */
                kfree_skb(skb);
        }
+
        return NETDEV_TX_OK;
 }
 
@@ -1460,11 +1457,10 @@ void bond_alb_monitor(struct work_struct *work)
                                            alb_work.work);
        struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
        struct slave *slave;
-       int i;
 
        read_lock(&bond->lock);
 
-       if (bond->slave_cnt == 0) {
+       if (list_empty(&bond->slave_list)) {
                bond_info->tx_rebalance_counter = 0;
                bond_info->lp_counter = 0;
                goto re_arm;
@@ -1482,9 +1478,8 @@ void bond_alb_monitor(struct work_struct *work)
                 */
                read_lock(&bond->curr_slave_lock);
 
-               bond_for_each_slave(bond, slave, i) {
+               bond_for_each_slave(bond, slave)
                        alb_send_learning_packets(slave, slave->dev->dev_addr);
-               }
 
                read_unlock(&bond->curr_slave_lock);
 
@@ -1496,7 +1491,7 @@ void bond_alb_monitor(struct work_struct *work)
 
                read_lock(&bond->curr_slave_lock);
 
-               bond_for_each_slave(bond, slave, i) {
+               bond_for_each_slave(bond, slave) {
                        tlb_clear_slave(bond, slave, 1);
                        if (slave == bond->curr_active_slave) {
                                SLAVE_TLB_INFO(slave).load =
@@ -1602,9 +1597,8 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
  */
 void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave)
 {
-       if (bond->slave_cnt > 1) {
+       if (!list_empty(&bond->slave_list))
                alb_change_hw_addr_on_detach(bond, slave);
-       }
 
        tlb_clear_slave(bond, slave, 0);
 
@@ -1661,9 +1655,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
 {
        struct slave *swap_slave;
 
-       if (bond->curr_active_slave == new_slave) {
+       if (bond->curr_active_slave == new_slave)
                return;
-       }
 
        if (bond->curr_active_slave && bond->alb_info.primary_is_promisc) {
                dev_set_promiscuity(bond->curr_active_slave->dev, -1);
@@ -1672,11 +1665,10 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
        }
 
        swap_slave = bond->curr_active_slave;
-       bond->curr_active_slave = new_slave;
+       rcu_assign_pointer(bond->curr_active_slave, new_slave);
 
-       if (!new_slave || (bond->slave_cnt == 0)) {
+       if (!new_slave || list_empty(&bond->slave_list))
                return;
-       }
 
        /* set the new curr_active_slave to the bonds mac address
         * i.e. swap mac addresses of old curr_active_slave and new curr_active_slave
@@ -1689,9 +1681,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
         * ignored so we can mess with their MAC addresses without
         * fear of interference from transmit activity.
         */
-       if (swap_slave) {
+       if (swap_slave)
                tlb_clear_slave(bond, swap_slave, 1);
-       }
        tlb_clear_slave(bond, new_slave, 1);
 
        write_unlock_bh(&bond->curr_slave_lock);
index 07f257d44a1e00a67b84a58685c5a2e490ce5ca8..7407e65f5d96c8012ca439c67e0ab7f9492a6d8b 100644 (file)
@@ -77,6 +77,7 @@
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 #include <net/pkt_sched.h>
+#include <linux/rculist.h>
 #include "bonding.h"
 #include "bond_3ad.h"
 #include "bond_alb.h"
@@ -106,7 +107,7 @@ static char *arp_ip_target[BOND_MAX_ARP_TARGETS];
 static char *arp_validate;
 static char *arp_all_targets;
 static char *fail_over_mac;
-static int all_slaves_active = 0;
+static int all_slaves_active;
 static struct bond_params bonding_defaults;
 static int resend_igmp = BOND_DEFAULT_RESEND_IGMP;
 
@@ -273,7 +274,7 @@ const char *bond_mode_name(int mode)
                [BOND_MODE_ALB] = "adaptive load balancing",
        };
 
-       if (mode < 0 || mode > BOND_MODE_ALB)
+       if (mode < BOND_MODE_ROUNDROBIN || mode > BOND_MODE_ALB)
                return "unknown";
 
        return names[mode];
@@ -441,10 +442,10 @@ static int bond_vlan_rx_add_vid(struct net_device *bond_dev,
                                __be16 proto, u16 vid)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct slave *slave, *stop_at;
-       int i, res;
+       struct slave *slave;
+       int res;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                res = vlan_vid_add(slave->dev, proto, vid);
                if (res)
                        goto unwind;
@@ -454,15 +455,14 @@ static int bond_vlan_rx_add_vid(struct net_device *bond_dev,
        if (res) {
                pr_err("%s: Error: Failed to add vlan id %d\n",
                       bond_dev->name, vid);
-               return res;
+               goto unwind;
        }
 
        return 0;
 
 unwind:
-       /* unwind from head to the slave that failed */
-       stop_at = slave;
-       bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at)
+       /* unwind from the slave that failed */
+       bond_for_each_slave_continue_reverse(bond, slave)
                vlan_vid_del(slave->dev, proto, vid);
 
        return res;
@@ -478,9 +478,9 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev,
 {
        struct bonding *bond = netdev_priv(bond_dev);
        struct slave *slave;
-       int i, res;
+       int res;
 
-       bond_for_each_slave(bond, slave, i)
+       bond_for_each_slave(bond, slave)
                vlan_vid_del(slave->dev, proto, vid);
 
        res = bond_del_vlan(bond, vid);
@@ -493,33 +493,6 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev,
        return 0;
 }
 
-static void bond_add_vlans_on_slave(struct bonding *bond, struct net_device *slave_dev)
-{
-       struct vlan_entry *vlan;
-       int res;
-
-       list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-               res = vlan_vid_add(slave_dev, htons(ETH_P_8021Q),
-                                  vlan->vlan_id);
-               if (res)
-                       pr_warning("%s: Failed to add vlan id %d to device %s\n",
-                                  bond->dev->name, vlan->vlan_id,
-                                  slave_dev->name);
-       }
-}
-
-static void bond_del_vlans_from_slave(struct bonding *bond,
-                                     struct net_device *slave_dev)
-{
-       struct vlan_entry *vlan;
-
-       list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-               if (!vlan->vlan_id)
-                       continue;
-               vlan_vid_del(slave_dev, htons(ETH_P_8021Q), vlan->vlan_id);
-       }
-}
-
 /*------------------------------- Link status -------------------------------*/
 
 /*
@@ -532,15 +505,14 @@ static void bond_del_vlans_from_slave(struct bonding *bond,
 static int bond_set_carrier(struct bonding *bond)
 {
        struct slave *slave;
-       int i;
 
-       if (bond->slave_cnt == 0)
+       if (list_empty(&bond->slave_list))
                goto down;
 
        if (bond->params.mode == BOND_MODE_8023AD)
                return bond_3ad_set_carrier(bond);
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (slave->link == BOND_LINK_UP) {
                        if (!netif_carrier_ok(bond->dev)) {
                                netif_carrier_on(bond->dev);
@@ -681,8 +653,8 @@ static int bond_set_promiscuity(struct bonding *bond, int inc)
                }
        } else {
                struct slave *slave;
-               int i;
-               bond_for_each_slave(bond, slave, i) {
+
+               bond_for_each_slave(bond, slave) {
                        err = dev_set_promiscuity(slave->dev, inc);
                        if (err)
                                return err;
@@ -705,8 +677,8 @@ static int bond_set_allmulti(struct bonding *bond, int inc)
                }
        } else {
                struct slave *slave;
-               int i;
-               bond_for_each_slave(bond, slave, i) {
+
+               bond_for_each_slave(bond, slave) {
                        err = dev_set_allmulti(slave->dev, inc);
                        if (err)
                                return err;
@@ -715,15 +687,6 @@ static int bond_set_allmulti(struct bonding *bond, int inc)
        return err;
 }
 
-static void __bond_resend_igmp_join_requests(struct net_device *dev)
-{
-       struct in_device *in_dev;
-
-       in_dev = __in_dev_get_rcu(dev);
-       if (in_dev)
-               ip_mc_rejoin_groups(in_dev);
-}
-
 /*
  * Retrieve the list of registered multicast addresses for the bonding
  * device and retransmit an IGMP JOIN request to the current active
@@ -731,33 +694,12 @@ static void __bond_resend_igmp_join_requests(struct net_device *dev)
  */
 static void bond_resend_igmp_join_requests(struct bonding *bond)
 {
-       struct net_device *bond_dev, *vlan_dev, *upper_dev;
-       struct vlan_entry *vlan;
-
-       read_lock(&bond->lock);
-       rcu_read_lock();
-
-       bond_dev = bond->dev;
-
-       /* rejoin all groups on bond device */
-       __bond_resend_igmp_join_requests(bond_dev);
-
-       /*
-        * if bond is enslaved to a bridge,
-        * then rejoin all groups on its master
-        */
-       upper_dev = netdev_master_upper_dev_get_rcu(bond_dev);
-       if (upper_dev && upper_dev->priv_flags & IFF_EBRIDGE)
-               __bond_resend_igmp_join_requests(upper_dev);
-
-       /* rejoin all groups on vlan devices */
-       list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
-               vlan_dev = __vlan_find_dev_deep(bond_dev, htons(ETH_P_8021Q),
-                                               vlan->vlan_id);
-               if (vlan_dev)
-                       __bond_resend_igmp_join_requests(vlan_dev);
+       if (!rtnl_trylock()) {
+               queue_delayed_work(bond->wq, &bond->mcast_work, 1);
+               return;
        }
-       rcu_read_unlock();
+       call_netdevice_notifiers(NETDEV_RESEND_IGMP, bond->dev);
+       rtnl_unlock();
 
        /* We use curr_slave_lock to protect against concurrent access to
         * igmp_retrans from multiple running instances of this function and
@@ -769,7 +711,6 @@ static void bond_resend_igmp_join_requests(struct bonding *bond)
                queue_delayed_work(bond->wq, &bond->mcast_work, HZ/5);
        }
        write_unlock_bh(&bond->curr_slave_lock);
-       read_unlock(&bond->lock);
 }
 
 static void bond_resend_igmp_join_requests_delayed(struct work_struct *work)
@@ -808,6 +749,8 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,
 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
                              struct slave *old_active)
 {
+       ASSERT_RTNL();
+
        if (old_active) {
                if (bond->dev->flags & IFF_PROMISC)
                        dev_set_promiscuity(old_active->dev, -1);
@@ -966,9 +909,8 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
        new_active = bond->curr_active_slave;
 
        if (!new_active) { /* there were no active slaves left */
-               if (bond->slave_cnt > 0)   /* found one slave */
-                       new_active = bond->first_slave;
-               else
+               new_active = bond_first_slave(bond);
+               if (!new_active)
                        return NULL; /* still no slave, return NULL */
        }
 
@@ -1071,7 +1013,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
                if (new_active)
                        bond_set_slave_active_flags(new_active);
        } else {
-               bond->curr_active_slave = new_active;
+               rcu_assign_pointer(bond->curr_active_slave, new_active);
        }
 
        if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
@@ -1115,7 +1057,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
            ((USES_PRIMARY(bond->params.mode) && new_active) ||
             bond->params.mode == BOND_MODE_ROUNDROBIN)) {
                bond->igmp_retrans = bond->params.resend_igmp;
-               queue_delayed_work(bond->wq, &bond->mcast_work, 0);
+               queue_delayed_work(bond->wq, &bond->mcast_work, 1);
        }
 }
 
@@ -1161,17 +1103,7 @@ void bond_select_active_slave(struct bonding *bond)
  */
 static void bond_attach_slave(struct bonding *bond, struct slave *new_slave)
 {
-       if (bond->first_slave == NULL) { /* attaching the first slave */
-               new_slave->next = new_slave;
-               new_slave->prev = new_slave;
-               bond->first_slave = new_slave;
-       } else {
-               new_slave->next = bond->first_slave;
-               new_slave->prev = bond->first_slave->prev;
-               new_slave->next->prev = new_slave;
-               new_slave->prev->next = new_slave;
-       }
-
+       list_add_tail_rcu(&new_slave->list, &bond->slave_list);
        bond->slave_cnt++;
 }
 
@@ -1187,22 +1119,7 @@ static void bond_attach_slave(struct bonding *bond, struct slave *new_slave)
  */
 static void bond_detach_slave(struct bonding *bond, struct slave *slave)
 {
-       if (slave->next)
-               slave->next->prev = slave->prev;
-
-       if (slave->prev)
-               slave->prev->next = slave->next;
-
-       if (bond->first_slave == slave) { /* slave is the first slave */
-               if (bond->slave_cnt > 1) { /* there are more slave */
-                       bond->first_slave = slave->next;
-               } else {
-                       bond->first_slave = NULL; /* slave was the last one */
-               }
-       }
-
-       slave->next = NULL;
-       slave->prev = NULL;
+       list_del_rcu(&slave->list);
        bond->slave_cnt--;
 }
 
@@ -1249,47 +1166,31 @@ static void bond_poll_controller(struct net_device *bond_dev)
 {
 }
 
-static void __bond_netpoll_cleanup(struct bonding *bond)
+static void bond_netpoll_cleanup(struct net_device *bond_dev)
 {
+       struct bonding *bond = netdev_priv(bond_dev);
        struct slave *slave;
-       int i;
 
-       bond_for_each_slave(bond, slave, i)
+       bond_for_each_slave(bond, slave)
                if (IS_UP(slave->dev))
                        slave_disable_netpoll(slave);
 }
-static void bond_netpoll_cleanup(struct net_device *bond_dev)
-{
-       struct bonding *bond = netdev_priv(bond_dev);
-
-       read_lock(&bond->lock);
-       __bond_netpoll_cleanup(bond);
-       read_unlock(&bond->lock);
-}
 
 static int bond_netpoll_setup(struct net_device *dev, struct netpoll_info *ni, gfp_t gfp)
 {
        struct bonding *bond = netdev_priv(dev);
        struct slave *slave;
-       int i, err = 0;
+       int err = 0;
 
-       read_lock(&bond->lock);
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                err = slave_enable_netpoll(slave);
                if (err) {
-                       __bond_netpoll_cleanup(bond);
+                       bond_netpoll_cleanup(dev);
                        break;
                }
        }
-       read_unlock(&bond->lock);
        return err;
 }
-
-static struct netpoll_info *bond_netpoll_info(struct bonding *bond)
-{
-       return bond->dev->npinfo;
-}
-
 #else
 static inline int slave_enable_netpoll(struct slave *slave)
 {
@@ -1311,11 +1212,10 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
        struct slave *slave;
        struct bonding *bond = netdev_priv(dev);
        netdev_features_t mask;
-       int i;
 
        read_lock(&bond->lock);
 
-       if (!bond->first_slave) {
+       if (list_empty(&bond->slave_list)) {
                /* Disable adding VLANs to empty bond. But why? --mq */
                features |= NETIF_F_VLAN_CHALLENGED;
                goto out;
@@ -1325,7 +1225,7 @@ static netdev_features_t bond_fix_features(struct net_device *dev,
        features &= ~NETIF_F_ONE_FOR_ALL;
        features |= NETIF_F_ALL_FOR_ALL;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                features = netdev_increment_features(features,
                                                     slave->dev->features,
                                                     mask);
@@ -1349,15 +1249,14 @@ static void bond_compute_features(struct bonding *bond)
        unsigned short max_hard_header_len = ETH_HLEN;
        unsigned int gso_max_size = GSO_MAX_SIZE;
        u16 gso_max_segs = GSO_MAX_SEGS;
-       int i;
        unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE;
 
        read_lock(&bond->lock);
 
-       if (!bond->first_slave)
+       if (list_empty(&bond->slave_list))
                goto done;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                vlan_features = netdev_increment_features(vlan_features,
                        slave->dev->vlan_features, BOND_VLAN_FEATURES);
 
@@ -1545,7 +1444,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
         * bond ether type mutual exclusion - don't allow slaves of dissimilar
         * ether type (eg ARPHRD_ETHER and ARPHRD_INFINIBAND) share the same bond
         */
-       if (bond->slave_cnt == 0) {
+       if (list_empty(&bond->slave_list)) {
                if (bond_dev->type != slave_dev->type) {
                        pr_debug("%s: change device type from %d to %d\n",
                                 bond_dev->name,
@@ -1584,7 +1483,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        }
 
        if (slave_ops->ndo_set_mac_address == NULL) {
-               if (bond->slave_cnt == 0) {
+               if (list_empty(&bond->slave_list)) {
                        pr_warning("%s: Warning: The first slave device specified does not support setting the MAC address. Setting fail_over_mac to active.",
                                   bond_dev->name);
                        bond->params.fail_over_mac = BOND_FOM_ACTIVE;
@@ -1600,7 +1499,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 
        /* If this is the first slave, then we need to set the master's hardware
         * address to be the same as the slave's. */
-       if (!bond->slave_cnt && bond->dev->addr_assign_type == NET_ADDR_RANDOM)
+       if (list_empty(&bond->slave_list) &&
+           bond->dev->addr_assign_type == NET_ADDR_RANDOM)
                bond_set_dev_addr(bond->dev, slave_dev);
 
        new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL);
@@ -1608,7 +1508,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                res = -ENOMEM;
                goto err_undo_flags;
        }
-
+       INIT_LIST_HEAD(&new_slave->list);
        /*
         * Set the new_slave's queue_id to be zero.  Queue ID mapping
         * is set via sysfs or module option if desired.
@@ -1703,7 +1603,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                dev_mc_add(slave_dev, lacpdu_multicast);
        }
 
-       bond_add_vlans_on_slave(bond, slave_dev);
+       res = vlan_vids_add_by_dev(slave_dev, bond_dev);
+       if (res) {
+               pr_err("%s: Error: Couldn't add bond vlan ids to %s\n",
+                      bond_dev->name, slave_dev->name);
+               goto err_close;
+       }
 
        write_lock_bh(&bond->lock);
 
@@ -1794,15 +1699,18 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                 */
                bond_set_slave_inactive_flags(new_slave);
                /* if this is the first slave */
-               if (bond->slave_cnt == 1) {
+               if (bond_first_slave(bond) == new_slave) {
                        SLAVE_AD_INFO(new_slave).id = 1;
                        /* Initialize AD with the number of times that the AD timer is called in 1 second
                         * can be called only after the mac address of the bond is set
                         */
                        bond_3ad_initialize(bond, 1000/AD_TIMER_INTERVAL);
                } else {
+                       struct slave *prev_slave;
+
+                       prev_slave = bond_prev_slave(bond, new_slave);
                        SLAVE_AD_INFO(new_slave).id =
-                               SLAVE_AD_INFO(new_slave->prev).id + 1;
+                               SLAVE_AD_INFO(prev_slave).id + 1;
                }
 
                bond_3ad_bind_slave(new_slave);
@@ -1824,7 +1732,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                 * so we can change it without calling change_active_interface()
                 */
                if (!bond->curr_active_slave && new_slave->link == BOND_LINK_UP)
-                       bond->curr_active_slave = new_slave;
+                       rcu_assign_pointer(bond->curr_active_slave, new_slave);
 
                break;
        } /* switch(bond_mode) */
@@ -1834,7 +1742,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        bond_set_carrier(bond);
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
-       slave_dev->npinfo = bond_netpoll_info(bond);
+       slave_dev->npinfo = bond->dev->npinfo;
        if (slave_dev->npinfo) {
                if (slave_enable_netpoll(new_slave)) {
                        read_unlock(&bond->lock);
@@ -1876,7 +1784,7 @@ err_detach:
        if (!USES_PRIMARY(bond->params.mode))
                bond_hw_addr_flush(bond_dev, slave_dev);
 
-       bond_del_vlans_from_slave(bond, slave_dev);
+       vlan_vids_del_by_dev(slave_dev, bond_dev);
        write_lock_bh(&bond->lock);
        bond_detach_slave(bond, new_slave);
        if (bond->primary_slave == new_slave)
@@ -1921,7 +1829,7 @@ err_free:
 err_undo_flags:
        bond_compute_features(bond);
        /* Enslave of first slave has failed and we need to fix master's mac */
-       if (bond->slave_cnt == 0 &&
+       if (list_empty(&bond->slave_list) &&
            ether_addr_equal(bond_dev->dev_addr, slave_dev->dev_addr))
                eth_hw_addr_random(bond_dev);
 
@@ -1977,15 +1885,6 @@ static int __bond_release_one(struct net_device *bond_dev,
        netdev_rx_handler_unregister(slave_dev);
        write_lock_bh(&bond->lock);
 
-       if (!all && !bond->params.fail_over_mac) {
-               if (ether_addr_equal(bond_dev->dev_addr, slave->perm_hwaddr) &&
-                   bond->slave_cnt > 1)
-                       pr_warning("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",
-                                  bond_dev->name, slave_dev->name,
-                                  slave->perm_hwaddr,
-                                  bond_dev->name, slave_dev->name);
-       }
-
        /* Inform AD package of unbinding of slave. */
        if (bond->params.mode == BOND_MODE_8023AD) {
                /* must be called before the slave is
@@ -2006,6 +1905,15 @@ static int __bond_release_one(struct net_device *bond_dev,
        /* release the slave from its bond */
        bond_detach_slave(bond, slave);
 
+       if (!all && !bond->params.fail_over_mac) {
+               if (ether_addr_equal(bond_dev->dev_addr, slave->perm_hwaddr) &&
+                   !list_empty(&bond->slave_list))
+                       pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",
+                                  bond_dev->name, slave_dev->name,
+                                  slave->perm_hwaddr,
+                                  bond_dev->name, slave_dev->name);
+       }
+
        if (bond->primary_slave == slave)
                bond->primary_slave = NULL;
 
@@ -2024,7 +1932,7 @@ static int __bond_release_one(struct net_device *bond_dev,
        }
 
        if (all) {
-               bond->curr_active_slave = NULL;
+               rcu_assign_pointer(bond->curr_active_slave, NULL);
        } else if (oldcurrent == slave) {
                /*
                 * Note that we hold RTNL over this sequence, so there
@@ -2042,7 +1950,7 @@ static int __bond_release_one(struct net_device *bond_dev,
                write_lock_bh(&bond->lock);
        }
 
-       if (bond->slave_cnt == 0) {
+       if (list_empty(&bond->slave_list)) {
                bond_set_carrier(bond);
                eth_hw_addr_random(bond_dev);
 
@@ -2056,8 +1964,9 @@ static int __bond_release_one(struct net_device *bond_dev,
 
        write_unlock_bh(&bond->lock);
        unblock_netpoll_tx();
+       synchronize_rcu();
 
-       if (bond->slave_cnt == 0) {
+       if (list_empty(&bond->slave_list)) {
                call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
                call_netdevice_notifiers(NETDEV_RELEASE, bond->dev);
        }
@@ -2071,7 +1980,7 @@ static int __bond_release_one(struct net_device *bond_dev,
        /* must do this from outside any spinlocks */
        bond_destroy_slave_symlinks(bond_dev, slave_dev);
 
-       bond_del_vlans_from_slave(bond, slave_dev);
+       vlan_vids_del_by_dev(slave_dev, bond_dev);
 
        /* If the mode USES_PRIMARY, then this cases was handled above by
         * bond_change_active_slave(..., NULL)
@@ -2128,7 +2037,7 @@ static int  bond_release_and_destroy(struct net_device *bond_dev,
        int ret;
 
        ret = bond_release(bond_dev, slave_dev);
-       if ((ret == 0) && (bond->slave_cnt == 0)) {
+       if (ret == 0 && list_empty(&bond->slave_list)) {
                bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
                pr_info("%s: destroying bond %s.\n",
                        bond_dev->name, bond_dev->name);
@@ -2165,23 +2074,19 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi
 
        read_lock(&bond->lock);
 
-       read_lock(&bond->curr_slave_lock);
        old_active = bond->curr_active_slave;
-       read_unlock(&bond->curr_slave_lock);
-
        new_active = bond_get_slave_by_dev(bond, slave_dev);
-
        /*
         * Changing to the current active: do nothing; return success.
         */
-       if (new_active && (new_active == old_active)) {
+       if (new_active && new_active == old_active) {
                read_unlock(&bond->lock);
                return 0;
        }
 
-       if ((new_active) &&
-           (old_active) &&
-           (new_active->link == BOND_LINK_UP) &&
+       if (new_active &&
+           old_active &&
+           new_active->link == BOND_LINK_UP &&
            IS_UP(new_active->dev)) {
                block_netpoll_tx();
                write_lock_bh(&bond->curr_slave_lock);
@@ -2213,13 +2118,12 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info)
 static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *info)
 {
        struct bonding *bond = netdev_priv(bond_dev);
+       int i = 0, res = -ENODEV;
        struct slave *slave;
-       int i, res = -ENODEV;
 
        read_lock(&bond->lock);
-
-       bond_for_each_slave(bond, slave, i) {
-               if (i == (int)info->slave_id) {
+       bond_for_each_slave(bond, slave) {
+               if (i++ == (int)info->slave_id) {
                        res = 0;
                        strcpy(info->slave_name, slave->dev->name);
                        info->link = slave->link;
@@ -2228,7 +2132,6 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
                        break;
                }
        }
-
        read_unlock(&bond->lock);
 
        return res;
@@ -2239,13 +2142,13 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
 
 static int bond_miimon_inspect(struct bonding *bond)
 {
+       int link_state, commit = 0;
        struct slave *slave;
-       int i, link_state, commit = 0;
        bool ignore_updelay;
 
        ignore_updelay = !bond->curr_active_slave ? true : false;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                slave->new_link = BOND_LINK_NOCHANGE;
 
                link_state = bond_check_dev_link(bond, slave->dev, 0);
@@ -2340,9 +2243,8 @@ static int bond_miimon_inspect(struct bonding *bond)
 static void bond_miimon_commit(struct bonding *bond)
 {
        struct slave *slave;
-       int i;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                switch (slave->new_link) {
                case BOND_LINK_NOCHANGE:
                        continue;
@@ -2447,7 +2349,7 @@ void bond_mii_monitor(struct work_struct *work)
 
        delay = msecs_to_jiffies(bond->params.miimon);
 
-       if (bond->slave_cnt == 0)
+       if (list_empty(&bond->slave_list))
                goto re_arm;
 
        should_notify_peers = bond_should_notify_peers(bond);
@@ -2713,6 +2615,20 @@ out_unlock:
        return RX_HANDLER_ANOTHER;
 }
 
+/* function to verify if we're in the arp_interval timeslice, returns true if
+ * (last_act - arp_interval) <= jiffies <= (last_act + mod * arp_interval +
+ * arp_interval/2) . the arp_interval/2 is needed for really fast networks.
+ */
+static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act,
+                                 int mod)
+{
+       int delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
+
+       return time_in_range(jiffies,
+                            last_act - delta_in_ticks,
+                            last_act + mod * delta_in_ticks + delta_in_ticks/2);
+}
+
 /*
  * this function is called regularly to monitor each slave's link
  * ensuring that traffic is being sent and received when arp monitoring
@@ -2726,21 +2642,13 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
                                            arp_work.work);
        struct slave *slave, *oldcurrent;
        int do_failover = 0;
-       int delta_in_ticks, extra_ticks;
-       int i;
 
        read_lock(&bond->lock);
 
-       delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
-       extra_ticks = delta_in_ticks / 2;
-
-       if (bond->slave_cnt == 0)
+       if (list_empty(&bond->slave_list))
                goto re_arm;
 
-       read_lock(&bond->curr_slave_lock);
        oldcurrent = bond->curr_active_slave;
-       read_unlock(&bond->curr_slave_lock);
-
        /* see if any of the previous devices are up now (i.e. they have
         * xmt and rcv traffic). the curr_active_slave does not come into
         * the picture unless it is null. also, slave->jiffies is not needed
@@ -2749,16 +2657,12 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
         * TODO: what about up/down delay in arp mode? it wasn't here before
         *       so it can wait
         */
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                unsigned long trans_start = dev_trans_start(slave->dev);
 
                if (slave->link != BOND_LINK_UP) {
-                       if (time_in_range(jiffies,
-                               trans_start - delta_in_ticks,
-                               trans_start + delta_in_ticks + extra_ticks) &&
-                           time_in_range(jiffies,
-                               slave->dev->last_rx - delta_in_ticks,
-                               slave->dev->last_rx + delta_in_ticks + extra_ticks)) {
+                       if (bond_time_in_interval(bond, trans_start, 1) &&
+                           bond_time_in_interval(bond, slave->dev->last_rx, 1)) {
 
                                slave->link  = BOND_LINK_UP;
                                bond_set_active_slave(slave);
@@ -2786,12 +2690,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
                         * when the source ip is 0, so don't take the link down
                         * if we don't know our ip yet
                         */
-                       if (!time_in_range(jiffies,
-                               trans_start - delta_in_ticks,
-                               trans_start + 2 * delta_in_ticks + extra_ticks) ||
-                           !time_in_range(jiffies,
-                               slave->dev->last_rx - delta_in_ticks,
-                               slave->dev->last_rx + 2 * delta_in_ticks + extra_ticks)) {
+                       if (!bond_time_in_interval(bond, trans_start, 2) ||
+                           !bond_time_in_interval(bond, slave->dev->last_rx, 2)) {
 
                                slave->link  = BOND_LINK_DOWN;
                                bond_set_backup_slave(slave);
@@ -2831,7 +2731,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
 
 re_arm:
        if (bond->params.arp_interval)
-               queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
+               queue_delayed_work(bond->wq, &bond->arp_work,
+                                  msecs_to_jiffies(bond->params.arp_interval));
 
        read_unlock(&bond->lock);
 }
@@ -2844,32 +2745,21 @@ re_arm:
  *
  * Called with bond->lock held for read.
  */
-static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
+static int bond_ab_arp_inspect(struct bonding *bond)
 {
+       unsigned long trans_start, last_rx;
        struct slave *slave;
-       int i, commit = 0;
-       unsigned long trans_start;
-       int extra_ticks;
+       int commit = 0;
 
-       /* All the time comparisons below need some extra time. Otherwise, on
-        * fast networks the ARP probe/reply may arrive within the same jiffy
-        * as it was sent.  Then, the next time the ARP monitor is run, one
-        * arp_interval will already have passed in the comparisons.
-        */
-       extra_ticks = delta_in_ticks / 2;
-
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                slave->new_link = BOND_LINK_NOCHANGE;
+               last_rx = slave_last_rx(bond, slave);
 
                if (slave->link != BOND_LINK_UP) {
-                       if (time_in_range(jiffies,
-                               slave_last_rx(bond, slave) - delta_in_ticks,
-                               slave_last_rx(bond, slave) + delta_in_ticks + extra_ticks)) {
-
+                       if (bond_time_in_interval(bond, last_rx, 1)) {
                                slave->new_link = BOND_LINK_UP;
                                commit++;
                        }
-
                        continue;
                }
 
@@ -2878,9 +2768,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
                 * active.  This avoids bouncing, as the last receive
                 * times need a full ARP monitor cycle to be updated.
                 */
-               if (time_in_range(jiffies,
-                                 slave->jiffies - delta_in_ticks,
-                                 slave->jiffies + 2 * delta_in_ticks + extra_ticks))
+               if (bond_time_in_interval(bond, slave->jiffies, 2))
                        continue;
 
                /*
@@ -2898,10 +2786,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
                 */
                if (!bond_is_active_slave(slave) &&
                    !bond->current_arp_slave &&
-                   !time_in_range(jiffies,
-                       slave_last_rx(bond, slave) - delta_in_ticks,
-                       slave_last_rx(bond, slave) + 3 * delta_in_ticks + extra_ticks)) {
-
+                   !bond_time_in_interval(bond, last_rx, 3)) {
                        slave->new_link = BOND_LINK_DOWN;
                        commit++;
                }
@@ -2914,13 +2799,8 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
                 */
                trans_start = dev_trans_start(slave->dev);
                if (bond_is_active_slave(slave) &&
-                   (!time_in_range(jiffies,
-                       trans_start - delta_in_ticks,
-                       trans_start + 2 * delta_in_ticks + extra_ticks) ||
-                    !time_in_range(jiffies,
-                       slave_last_rx(bond, slave) - delta_in_ticks,
-                       slave_last_rx(bond, slave) + 2 * delta_in_ticks + extra_ticks))) {
-
+                   (!bond_time_in_interval(bond, trans_start, 2) ||
+                    !bond_time_in_interval(bond, last_rx, 2))) {
                        slave->new_link = BOND_LINK_DOWN;
                        commit++;
                }
@@ -2935,24 +2815,21 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
  *
  * Called with RTNL and bond->lock for read.
  */
-static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
+static void bond_ab_arp_commit(struct bonding *bond)
 {
-       struct slave *slave;
-       int i;
        unsigned long trans_start;
+       struct slave *slave;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                switch (slave->new_link) {
                case BOND_LINK_NOCHANGE:
                        continue;
 
                case BOND_LINK_UP:
                        trans_start = dev_trans_start(slave->dev);
-                       if ((!bond->curr_active_slave &&
-                            time_in_range(jiffies,
-                                          trans_start - delta_in_ticks,
-                                          trans_start + delta_in_ticks + delta_in_ticks / 2)) ||
-                           bond->curr_active_slave != slave) {
+                       if (bond->curr_active_slave != slave ||
+                           (!bond->curr_active_slave &&
+                            bond_time_in_interval(bond, trans_start, 1))) {
                                slave->link = BOND_LINK_UP;
                                if (bond->current_arp_slave) {
                                        bond_set_slave_inactive_flags(
@@ -3014,7 +2891,7 @@ do_failover:
  */
 static void bond_ab_arp_probe(struct bonding *bond)
 {
-       struct slave *slave;
+       struct slave *slave, *next_slave;
        int i;
 
        read_lock(&bond->curr_slave_lock);
@@ -3038,7 +2915,7 @@ static void bond_ab_arp_probe(struct bonding *bond)
         */
 
        if (!bond->current_arp_slave) {
-               bond->current_arp_slave = bond->first_slave;
+               bond->current_arp_slave = bond_first_slave(bond);
                if (!bond->current_arp_slave)
                        return;
        }
@@ -3046,7 +2923,8 @@ static void bond_ab_arp_probe(struct bonding *bond)
        bond_set_slave_inactive_flags(bond->current_arp_slave);
 
        /* search for next candidate */
-       bond_for_each_slave_from(bond, slave, i, bond->current_arp_slave->next) {
+       next_slave = bond_next_slave(bond, bond->current_arp_slave);
+       bond_for_each_slave_from(bond, slave, i, next_slave) {
                if (IS_UP(slave->dev)) {
                        slave->link = BOND_LINK_BACK;
                        bond_set_slave_active_flags(slave);
@@ -3087,12 +2965,12 @@ void bond_activebackup_arp_mon(struct work_struct *work)
 
        delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
 
-       if (bond->slave_cnt == 0)
+       if (list_empty(&bond->slave_list))
                goto re_arm;
 
        should_notify_peers = bond_should_notify_peers(bond);
 
-       if (bond_ab_arp_inspect(bond, delta_in_ticks)) {
+       if (bond_ab_arp_inspect(bond)) {
                read_unlock(&bond->lock);
 
                /* Race avoidance with bond_close flush of workqueue */
@@ -3105,7 +2983,7 @@ void bond_activebackup_arp_mon(struct work_struct *work)
 
                read_lock(&bond->lock);
 
-               bond_ab_arp_commit(bond, delta_in_ticks);
+               bond_ab_arp_commit(bond);
 
                read_unlock(&bond->lock);
                rtnl_unlock();
@@ -3234,6 +3112,10 @@ static int bond_slave_netdev_event(unsigned long event,
        case NETDEV_FEAT_CHANGE:
                bond_compute_features(bond);
                break;
+       case NETDEV_RESEND_IGMP:
+               /* Propagate to master device */
+               call_netdevice_notifiers(event, slave->bond->dev);
+               break;
        default:
                break;
        }
@@ -3403,13 +3285,12 @@ static int bond_open(struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
        struct slave *slave;
-       int i;
 
        /* reset slave->backup and slave->inactive */
        read_lock(&bond->lock);
-       if (bond->slave_cnt > 0) {
+       if (!list_empty(&bond->slave_list)) {
                read_lock(&bond->curr_slave_lock);
-               bond_for_each_slave(bond, slave, i) {
+               bond_for_each_slave(bond, slave) {
                        if ((bond->params.mode == BOND_MODE_ACTIVEBACKUP)
                                && (slave != bond->curr_active_slave)) {
                                bond_set_slave_inactive_flags(slave);
@@ -3477,13 +3358,11 @@ static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev,
        struct bonding *bond = netdev_priv(bond_dev);
        struct rtnl_link_stats64 temp;
        struct slave *slave;
-       int i;
 
        memset(stats, 0, sizeof(*stats));
 
        read_lock_bh(&bond->lock);
-
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                const struct rtnl_link_stats64 *sstats =
                        dev_get_stats(slave->dev, &temp);
 
@@ -3513,7 +3392,6 @@ static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev,
                stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
                stats->tx_window_errors += sstats->tx_window_errors;
        }
-
        read_unlock_bh(&bond->lock);
 
        return stats;
@@ -3652,41 +3530,35 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
        struct slave *slave;
-       int i;
 
-       read_lock(&bond->lock);
+       ASSERT_RTNL();
 
        if (USES_PRIMARY(bond->params.mode)) {
-               read_lock(&bond->curr_slave_lock);
-               slave = bond->curr_active_slave;
+               slave = rtnl_dereference(bond->curr_active_slave);
                if (slave) {
                        dev_uc_sync(slave->dev, bond_dev);
                        dev_mc_sync(slave->dev, bond_dev);
                }
-               read_unlock(&bond->curr_slave_lock);
        } else {
-               bond_for_each_slave(bond, slave, i) {
+               bond_for_each_slave(bond, slave) {
                        dev_uc_sync_multiple(slave->dev, bond_dev);
                        dev_mc_sync_multiple(slave->dev, bond_dev);
                }
        }
-
-       read_unlock(&bond->lock);
 }
 
 static int bond_neigh_init(struct neighbour *n)
 {
        struct bonding *bond = netdev_priv(n->dev);
-       struct slave *slave = bond->first_slave;
        const struct net_device_ops *slave_ops;
        struct neigh_parms parms;
+       struct slave *slave;
        int ret;
 
+       slave = bond_first_slave(bond);
        if (!slave)
                return 0;
-
        slave_ops = slave->dev->netdev_ops;
-
        if (!slave_ops->ndo_neigh_setup)
                return 0;
 
@@ -3714,11 +3586,17 @@ static int bond_neigh_init(struct neighbour *n)
  * The bonding ndo_neigh_setup is called at init time beofre any
  * slave exists. So we must declare proxy setup function which will
  * be used at run time to resolve the actual slave neigh param setup.
+ *
+ * It's also called by master devices (such as vlans) to setup their
+ * underlying devices. In that case - do nothing, we're already set up from
+ * our init.
  */
 static int bond_neigh_setup(struct net_device *dev,
                            struct neigh_parms *parms)
 {
-       parms->neigh_setup   = bond_neigh_init;
+       /* modify only our neigh_parms */
+       if (parms->dev == dev)
+               parms->neigh_setup = bond_neigh_init;
 
        return 0;
 }
@@ -3729,9 +3607,8 @@ static int bond_neigh_setup(struct net_device *dev,
 static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct slave *slave, *stop_at;
+       struct slave *slave;
        int res = 0;
-       int i;
 
        pr_debug("bond=%p, name=%s, new_mtu=%d\n", bond,
                 (bond_dev ? bond_dev->name : "None"), new_mtu);
@@ -3751,10 +3628,10 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
         * call to the base driver.
         */
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                pr_debug("s %p s->p %p c_m %p\n",
                         slave,
-                        slave->prev,
+                        bond_prev_slave(bond, slave),
                         slave->dev->netdev_ops->ndo_change_mtu);
 
                res = dev_set_mtu(slave->dev, new_mtu);
@@ -3779,8 +3656,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
 
 unwind:
        /* unwind from head to the slave that failed */
-       stop_at = slave;
-       bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
+       bond_for_each_slave_continue_reverse(bond, slave) {
                int tmp_res;
 
                tmp_res = dev_set_mtu(slave->dev, bond_dev->mtu);
@@ -3804,9 +3680,8 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
 {
        struct bonding *bond = netdev_priv(bond_dev);
        struct sockaddr *sa = addr, tmp_sa;
-       struct slave *slave, *stop_at;
+       struct slave *slave;
        int res = 0;
-       int i;
 
        if (bond->params.mode == BOND_MODE_ALB)
                return bond_alb_set_mac_address(bond_dev, addr);
@@ -3839,7 +3714,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
         * call to the base driver.
         */
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                const struct net_device_ops *slave_ops = slave->dev->netdev_ops;
                pr_debug("slave %p %s\n", slave, slave->dev->name);
 
@@ -3871,8 +3746,7 @@ unwind:
        tmp_sa.sa_family = bond_dev->type;
 
        /* unwind from head to the slave that failed */
-       stop_at = slave;
-       bond_for_each_slave_from_to(bond, slave, i, bond->first_slave, stop_at) {
+       bond_for_each_slave_continue_reverse(bond, slave) {
                int tmp_res;
 
                tmp_res = dev_set_mac_address(slave->dev, &tmp_sa);
@@ -3885,12 +3759,50 @@ unwind:
        return res;
 }
 
+/**
+ * bond_xmit_slave_id - transmit skb through slave with slave_id
+ * @bond: bonding device that is transmitting
+ * @skb: buffer to transmit
+ * @slave_id: slave id up to slave_cnt-1 through which to transmit
+ *
+ * This function tries to transmit through slave with slave_id but in case
+ * it fails, it tries to find the first available slave for transmission.
+ * The skb is consumed in all cases, thus the function is void.
+ */
+void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id)
+{
+       struct slave *slave;
+       int i = slave_id;
+
+       /* Here we start from the slave with slave_id */
+       bond_for_each_slave_rcu(bond, slave) {
+               if (--i < 0) {
+                       if (slave_can_tx(slave)) {
+                               bond_dev_queue_xmit(bond, skb, slave->dev);
+                               return;
+                       }
+               }
+       }
+
+       /* Here we start from the first slave up to slave_id */
+       i = slave_id;
+       bond_for_each_slave_rcu(bond, slave) {
+               if (--i < 0)
+                       break;
+               if (slave_can_tx(slave)) {
+                       bond_dev_queue_xmit(bond, skb, slave->dev);
+                       return;
+               }
+       }
+       /* no slave that can tx has been found */
+       kfree_skb(skb);
+}
+
 static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct slave *slave, *start_at;
-       int i, slave_no, res = 1;
        struct iphdr *iph = ip_hdr(skb);
+       struct slave *slave;
 
        /*
         * Start with the curr_active_slave that joined the bond as the
@@ -3899,50 +3811,20 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
         * send the join/membership reports.  The curr_active_slave found
         * will send all of this type of traffic.
         */
-       if ((iph->protocol == IPPROTO_IGMP) &&
-           (skb->protocol == htons(ETH_P_IP))) {
-
-               read_lock(&bond->curr_slave_lock);
-               slave = bond->curr_active_slave;
-               read_unlock(&bond->curr_slave_lock);
-
-               if (!slave)
-                       goto out;
+       if (iph->protocol == IPPROTO_IGMP && skb->protocol == htons(ETH_P_IP)) {
+               slave = rcu_dereference(bond->curr_active_slave);
+               if (slave && slave_can_tx(slave))
+                       bond_dev_queue_xmit(bond, skb, slave->dev);
+               else
+                       bond_xmit_slave_id(bond, skb, 0);
        } else {
-               /*
-                * Concurrent TX may collide on rr_tx_counter; we accept
-                * that as being rare enough not to justify using an
-                * atomic op here.
-                */
-               slave_no = bond->rr_tx_counter++ % bond->slave_cnt;
-
-               bond_for_each_slave(bond, slave, i) {
-                       slave_no--;
-                       if (slave_no < 0)
-                               break;
-               }
-       }
-
-       start_at = slave;
-       bond_for_each_slave_from(bond, slave, i, start_at) {
-               if (IS_UP(slave->dev) &&
-                   (slave->link == BOND_LINK_UP) &&
-                   bond_is_active_slave(slave)) {
-                       res = bond_dev_queue_xmit(bond, skb, slave->dev);
-                       break;
-               }
-       }
-
-out:
-       if (res) {
-               /* no suitable interface, frame not sent */
-               kfree_skb(skb);
+               bond_xmit_slave_id(bond, skb,
+                                  bond->rr_tx_counter++ % bond->slave_cnt);
        }
 
        return NETDEV_TX_OK;
 }
 
-
 /*
  * in active-backup mode, we know that bond->curr_active_slave is always valid if
  * the bond has a usable interface.
@@ -3950,18 +3832,12 @@ out:
 static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       int res = 1;
-
-       read_lock(&bond->curr_slave_lock);
-
-       if (bond->curr_active_slave)
-               res = bond_dev_queue_xmit(bond, skb,
-                       bond->curr_active_slave->dev);
-
-       read_unlock(&bond->curr_slave_lock);
+       struct slave *slave;
 
-       if (res)
-               /* no suitable interface, frame not sent */
+       slave = rcu_dereference(bond->curr_active_slave);
+       if (slave)
+               bond_dev_queue_xmit(bond, skb, slave->dev);
+       else
                kfree_skb(skb);
 
        return NETDEV_TX_OK;
@@ -3975,87 +3851,39 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
 static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct slave *slave, *start_at;
-       int slave_no;
-       int i;
-       int res = 1;
 
-       slave_no = bond->xmit_hash_policy(skb, bond->slave_cnt);
-
-       bond_for_each_slave(bond, slave, i) {
-               slave_no--;
-               if (slave_no < 0)
-                       break;
-       }
-
-       start_at = slave;
-
-       bond_for_each_slave_from(bond, slave, i, start_at) {
-               if (IS_UP(slave->dev) &&
-                   (slave->link == BOND_LINK_UP) &&
-                   bond_is_active_slave(slave)) {
-                       res = bond_dev_queue_xmit(bond, skb, slave->dev);
-                       break;
-               }
-       }
-
-       if (res) {
-               /* no suitable interface, frame not sent */
-               kfree_skb(skb);
-       }
+       bond_xmit_slave_id(bond, skb,
+                          bond->xmit_hash_policy(skb, bond->slave_cnt));
 
        return NETDEV_TX_OK;
 }
 
-/*
- * in broadcast mode, we send everything to all usable interfaces.
- */
+/* in broadcast mode, we send everything to all usable interfaces. */
 static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct slave *slave, *start_at;
-       struct net_device *tx_dev = NULL;
-       int i;
-       int res = 1;
-
-       read_lock(&bond->curr_slave_lock);
-       start_at = bond->curr_active_slave;
-       read_unlock(&bond->curr_slave_lock);
-
-       if (!start_at)
-               goto out;
+       struct slave *slave = NULL;
 
-       bond_for_each_slave_from(bond, slave, i, start_at) {
-               if (IS_UP(slave->dev) &&
-                   (slave->link == BOND_LINK_UP) &&
-                   bond_is_active_slave(slave)) {
-                       if (tx_dev) {
-                               struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
-                               if (!skb2) {
-                                       pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
-                                              bond_dev->name);
-                                       continue;
-                               }
+       bond_for_each_slave_rcu(bond, slave) {
+               if (bond_is_last_slave(bond, slave))
+                       break;
+               if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP) {
+                       struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
 
-                               res = bond_dev_queue_xmit(bond, skb2, tx_dev);
-                               if (res) {
-                                       kfree_skb(skb2);
-                                       continue;
-                               }
+                       if (!skb2) {
+                               pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
+                                      bond_dev->name);
+                               continue;
                        }
-                       tx_dev = slave->dev;
+                       /* bond_dev_queue_xmit always returns 0 */
+                       bond_dev_queue_xmit(bond, skb2, slave->dev);
                }
        }
-
-       if (tx_dev)
-               res = bond_dev_queue_xmit(bond, skb, tx_dev);
-
-out:
-       if (res)
-               /* no suitable interface, frame not sent */
+       if (slave && IS_UP(slave->dev) && slave->link == BOND_LINK_UP)
+               bond_dev_queue_xmit(bond, skb, slave->dev);
+       else
                kfree_skb(skb);
 
-       /* frame sent to all suitable interfaces */
        return NETDEV_TX_OK;
 }
 
@@ -4083,15 +3911,15 @@ static void bond_set_xmit_hash_policy(struct bonding *bond)
 static inline int bond_slave_override(struct bonding *bond,
                                      struct sk_buff *skb)
 {
-       int i, res = 1;
        struct slave *slave = NULL;
        struct slave *check_slave;
+       int res = 1;
 
        if (!skb->queue_mapping)
                return 1;
 
        /* Find out if any slaves have the same mapping as this skb. */
-       bond_for_each_slave(bond, check_slave, i) {
+       bond_for_each_slave_rcu(bond, check_slave) {
                if (check_slave->queue_id == skb->queue_mapping) {
                        slave = check_slave;
                        break;
@@ -4176,14 +4004,12 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (is_netpoll_tx_blocked(dev))
                return NETDEV_TX_BUSY;
 
-       read_lock(&bond->lock);
-
-       if (bond->slave_cnt)
+       rcu_read_lock();
+       if (!list_empty(&bond->slave_list))
                ret = __bond_start_xmit(skb, dev);
        else
                kfree_skb(skb);
-
-       read_unlock(&bond->lock);
+       rcu_read_unlock();
 
        return ret;
 }
@@ -4224,9 +4050,8 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev,
                                     struct ethtool_cmd *ecmd)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct slave *slave;
-       int i;
        unsigned long speed = 0;
+       struct slave *slave;
 
        ecmd->duplex = DUPLEX_UNKNOWN;
        ecmd->port = PORT_OTHER;
@@ -4237,7 +4062,7 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev,
         * this is an accurate maximum.
         */
        read_lock(&bond->lock);
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (SLAVE_IS_OK(slave)) {
                        if (slave->speed != SPEED_UNKNOWN)
                                speed += slave->speed;
@@ -4248,6 +4073,7 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev,
        }
        ethtool_cmd_speed_set(ecmd, speed ? : SPEED_UNKNOWN);
        read_unlock(&bond->lock);
+
        return 0;
 }
 
@@ -4311,7 +4137,7 @@ static void bond_setup(struct net_device *bond_dev)
        /* initialize rwlocks */
        rwlock_init(&bond->lock);
        rwlock_init(&bond->curr_slave_lock);
-
+       INIT_LIST_HEAD(&bond->slave_list);
        bond->params = bonding_defaults;
 
        /* Initialize pointers */
@@ -4368,13 +4194,14 @@ static void bond_setup(struct net_device *bond_dev)
 static void bond_uninit(struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
+       struct slave *slave, *tmp_slave;
        struct vlan_entry *vlan, *tmp;
 
        bond_netpoll_cleanup(bond_dev);
 
        /* Release the bonded slaves */
-       while (bond->first_slave != NULL)
-               __bond_release_one(bond_dev, bond->first_slave->dev, true);
+       list_for_each_entry_safe(slave, tmp_slave, &bond->slave_list, list)
+               __bond_release_one(bond_dev, slave->dev, true);
        pr_info("%s: released all slaves\n", bond_dev->name);
 
        list_del(&bond->bond_list);
index 4060d41f0ee7b15bc228b6bda9488a9e6cc9c821..20a6ee25bb63e42cdf89c0273d8e1afa30234f26 100644 (file)
@@ -12,7 +12,6 @@ static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
        struct bonding *bond = seq->private;
        loff_t off = 0;
        struct slave *slave;
-       int i;
 
        /* make sure the bond won't be taken away */
        rcu_read_lock();
@@ -21,10 +20,9 @@ static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave)
                if (++off == *pos)
                        return slave;
-       }
 
        return NULL;
 }
@@ -36,11 +34,13 @@ static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        ++*pos;
        if (v == SEQ_START_TOKEN)
-               return bond->first_slave;
+               return bond_first_slave(bond);
 
-       slave = slave->next;
+       if (bond_is_last_slave(bond, slave))
+               return NULL;
+       slave = bond_next_slave(bond, slave);
 
-       return (slave == bond->first_slave) ? NULL : slave;
+       return slave;
 }
 
 static void bond_info_seq_stop(struct seq_file *seq, void *v)
index dc36a3d7d9e983a15583260a572e6dac7451acb5..0f539de640dcb6f471378a5d44e47c0946a01d0c 100644 (file)
@@ -209,12 +209,12 @@ void bond_destroy_slave_symlinks(struct net_device *master,
 static ssize_t bonding_show_slaves(struct device *d,
                                   struct device_attribute *attr, char *buf)
 {
-       struct slave *slave;
-       int i, res = 0;
        struct bonding *bond = to_bond(d);
+       struct slave *slave;
+       int res = 0;
 
        read_lock(&bond->lock);
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (res > (PAGE_SIZE - IFNAMSIZ)) {
                        /* not enough space for another interface name */
                        if ((PAGE_SIZE - res) > 10)
@@ -227,6 +227,7 @@ static ssize_t bonding_show_slaves(struct device *d,
        read_unlock(&bond->lock);
        if (res)
                buf[res-1] = '\n'; /* eat the leftover space */
+
        return res;
 }
 
@@ -325,7 +326,7 @@ static ssize_t bonding_store_mode(struct device *d,
                goto out;
        }
 
-       if (bond->slave_cnt > 0) {
+       if (!list_empty(&bond->slave_list)) {
                pr_err("unable to update mode of %s because it has slaves.\n",
                        bond->dev->name);
                ret = -EPERM;
@@ -501,20 +502,25 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
                                           struct device_attribute *attr,
                                           const char *buf, size_t count)
 {
-       int new_value;
+       int new_value, ret = count;
        struct bonding *bond = to_bond(d);
 
-       if (bond->slave_cnt != 0) {
+       if (!rtnl_trylock())
+               return restart_syscall();
+
+       if (!list_empty(&bond->slave_list)) {
                pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
                       bond->dev->name);
-               return -EPERM;
+               ret = -EPERM;
+               goto out;
        }
 
        new_value = bond_parse_parm(buf, fail_over_mac_tbl);
        if (new_value < 0) {
                pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
                       bond->dev->name, buf);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out;
        }
 
        bond->params.fail_over_mac = new_value;
@@ -522,7 +528,9 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
                bond->dev->name, fail_over_mac_tbl[new_value].modename,
                new_value);
 
-       return count;
+out:
+       rtnl_unlock();
+       return ret;
 }
 
 static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR,
@@ -661,7 +669,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
                         &newtarget);
                /* not to race with bond_arp_rcv */
                write_lock_bh(&bond->lock);
-               bond_for_each_slave(bond, slave, i)
+               bond_for_each_slave(bond, slave)
                        slave->target_last_arp_rx[ind] = jiffies;
                targets[ind] = newtarget;
                write_unlock_bh(&bond->lock);
@@ -687,7 +695,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
                        &newtarget);
 
                write_lock_bh(&bond->lock);
-               bond_for_each_slave(bond, slave, i) {
+               bond_for_each_slave(bond, slave) {
                        targets_rx = slave->target_last_arp_rx;
                        j = ind;
                        for (; (j < BOND_MAX_ARP_TARGETS-1) && targets[j+1]; j++)
@@ -1078,10 +1086,9 @@ static ssize_t bonding_store_primary(struct device *d,
                                     struct device_attribute *attr,
                                     const char *buf, size_t count)
 {
-       int i;
-       struct slave *slave;
        struct bonding *bond = to_bond(d);
        char ifname[IFNAMSIZ];
+       struct slave *slave;
 
        if (!rtnl_trylock())
                return restart_syscall();
@@ -1107,7 +1114,7 @@ static ssize_t bonding_store_primary(struct device *d,
                goto out;
        }
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
                        pr_info("%s: Setting %s as primary slave.\n",
                                bond->dev->name, slave->dev->name);
@@ -1236,16 +1243,16 @@ static ssize_t bonding_show_active_slave(struct device *d,
                                         struct device_attribute *attr,
                                         char *buf)
 {
-       struct slave *curr;
        struct bonding *bond = to_bond(d);
+       struct slave *curr;
        int count = 0;
 
-       read_lock(&bond->curr_slave_lock);
-       curr = bond->curr_active_slave;
-       read_unlock(&bond->curr_slave_lock);
-
+       rcu_read_lock();
+       curr = rcu_dereference(bond->curr_active_slave);
        if (USES_PRIMARY(bond->params.mode) && curr)
                count = sprintf(buf, "%s\n", curr->dev->name);
+       rcu_read_unlock();
+
        return count;
 }
 
@@ -1253,16 +1260,14 @@ static ssize_t bonding_store_active_slave(struct device *d,
                                          struct device_attribute *attr,
                                          const char *buf, size_t count)
 {
-       int i;
-       struct slave *slave;
-       struct slave *old_active = NULL;
-       struct slave *new_active = NULL;
+       struct slave *slave, *old_active, *new_active;
        struct bonding *bond = to_bond(d);
        char ifname[IFNAMSIZ];
 
        if (!rtnl_trylock())
                return restart_syscall();
 
+       old_active = new_active = NULL;
        block_netpoll_tx();
        read_lock(&bond->lock);
        write_lock_bh(&bond->curr_slave_lock);
@@ -1279,12 +1284,12 @@ static ssize_t bonding_store_active_slave(struct device *d,
        if (!strlen(ifname) || buf[0] == '\n') {
                pr_info("%s: Clearing current active slave.\n",
                        bond->dev->name);
-               bond->curr_active_slave = NULL;
+               rcu_assign_pointer(bond->curr_active_slave, NULL);
                bond_select_active_slave(bond);
                goto out;
        }
 
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (strncmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
                        old_active = bond->curr_active_slave;
                        new_active = slave;
@@ -1295,8 +1300,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
                                        bond->dev->name,
                                        slave->dev->name);
                                goto out;
-                       }
-                       else {
+                       } else {
                                if ((new_active) &&
                                    (old_active) &&
                                    (new_active->link == BOND_LINK_UP) &&
@@ -1307,8 +1311,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
                                                slave->dev->name);
                                        bond_change_active_slave(bond,
                                                                 new_active);
-                               }
-                               else {
+                               } else {
                                        pr_info("%s: Could not set %s as"
                                                " active slave; either %s is"
                                                " down or the link is down.\n",
@@ -1344,14 +1347,9 @@ static ssize_t bonding_show_mii_status(struct device *d,
                                       struct device_attribute *attr,
                                       char *buf)
 {
-       struct slave *curr;
        struct bonding *bond = to_bond(d);
 
-       read_lock(&bond->curr_slave_lock);
-       curr = bond->curr_active_slave;
-       read_unlock(&bond->curr_slave_lock);
-
-       return sprintf(buf, "%s\n", curr ? "up" : "down");
+       return sprintf(buf, "%s\n", bond->curr_active_slave ? "up" : "down");
 }
 static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
 
@@ -1470,15 +1468,15 @@ static ssize_t bonding_show_queue_id(struct device *d,
                                     struct device_attribute *attr,
                                     char *buf)
 {
-       struct slave *slave;
-       int i, res = 0;
        struct bonding *bond = to_bond(d);
+       struct slave *slave;
+       int res = 0;
 
        if (!rtnl_trylock())
                return restart_syscall();
 
        read_lock(&bond->lock);
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (res > (PAGE_SIZE - IFNAMSIZ - 6)) {
                        /* not enough space for another interface_name:queue_id pair */
                        if ((PAGE_SIZE - res) > 10)
@@ -1493,6 +1491,7 @@ static ssize_t bonding_show_queue_id(struct device *d,
        if (res)
                buf[res-1] = '\n'; /* eat the leftover space */
        rtnl_unlock();
+
        return res;
 }
 
@@ -1507,7 +1506,7 @@ static ssize_t bonding_store_queue_id(struct device *d,
        struct slave *slave, *update_slave;
        struct bonding *bond = to_bond(d);
        u16 qid;
-       int i, ret = count;
+       int ret = count;
        char *delim;
        struct net_device *sdev = NULL;
 
@@ -1542,7 +1541,7 @@ static ssize_t bonding_store_queue_id(struct device *d,
 
        /* Search for thes slave and check for duplicate qids */
        update_slave = NULL;
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (sdev == slave->dev)
                        /*
                         * We don't need to check the matching
@@ -1594,8 +1593,8 @@ static ssize_t bonding_store_slaves_active(struct device *d,
                                           struct device_attribute *attr,
                                           const char *buf, size_t count)
 {
-       int i, new_value, ret = count;
        struct bonding *bond = to_bond(d);
+       int new_value, ret = count;
        struct slave *slave;
 
        if (sscanf(buf, "%d", &new_value) != 1) {
@@ -1618,7 +1617,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
        }
 
        read_lock(&bond->lock);
-       bond_for_each_slave(bond, slave, i) {
+       bond_for_each_slave(bond, slave) {
                if (!bond_is_active_slave(slave)) {
                        if (new_value)
                                slave->inactive = 0;
index 42d1c6599cba944cd1854759f010b5c6776c438b..4bf52d5f637ef687ef5bd9f31e848212c2b3ff62 100644 (file)
        set_fs(fs);                     \
        res; })
 
+/* slave list primitives */
+#define bond_to_slave(ptr) list_entry(ptr, struct slave, list)
+
+/* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */
+#define bond_first_slave(bond) \
+       list_first_entry_or_null(&(bond)->slave_list, struct slave, list)
+#define bond_last_slave(bond) \
+       (list_empty(&(bond)->slave_list) ? NULL : \
+                                          bond_to_slave((bond)->slave_list.prev))
+
+#define bond_is_first_slave(bond, pos) ((pos)->list.prev == &(bond)->slave_list)
+#define bond_is_last_slave(bond, pos) ((pos)->list.next == &(bond)->slave_list)
+
+/* Since bond_first/last_slave can return NULL, these can return NULL too */
+#define bond_next_slave(bond, pos) \
+       (bond_is_last_slave(bond, pos) ? bond_first_slave(bond) : \
+                                        bond_to_slave((pos)->list.next))
+
+#define bond_prev_slave(bond, pos) \
+       (bond_is_first_slave(bond, pos) ? bond_last_slave(bond) : \
+                                         bond_to_slave((pos)->list.prev))
+
 /**
  * bond_for_each_slave_from - iterate the slaves list from a starting point
  * @bond:      the bond holding this list.
  *
  * Caller must hold bond->lock
  */
-#define bond_for_each_slave_from(bond, pos, cnt, start)        \
-       for (cnt = 0, pos = start;                              \
-            cnt < (bond)->slave_cnt;                           \
-             cnt++, pos = (pos)->next)
+#define bond_for_each_slave_from(bond, pos, cnt, start) \
+       for (cnt = 0, pos = start; pos && cnt < (bond)->slave_cnt; \
+            cnt++, pos = bond_next_slave(bond, pos))
 
 /**
- * bond_for_each_slave_from_to - iterate the slaves list from start point to stop point
- * @bond:      the bond holding this list.
- * @pos:       current slave.
- * @cnt:       counter for number max of moves
- * @start:     start point.
- * @stop:      stop point.
+ * bond_for_each_slave - iterate over all slaves
+ * @bond:      the bond holding this list
+ * @pos:       current slave
  *
  * Caller must hold bond->lock
  */
-#define bond_for_each_slave_from_to(bond, pos, cnt, start, stop)       \
-       for (cnt = 0, pos = start;                                      \
-            ((cnt < (bond)->slave_cnt) && (pos != (stop)->next));      \
-             cnt++, pos = (pos)->next)
+#define bond_for_each_slave(bond, pos) \
+       list_for_each_entry(pos, &(bond)->slave_list, list)
+
+/* Caller must have rcu_read_lock */
+#define bond_for_each_slave_rcu(bond, pos) \
+       list_for_each_entry_rcu(pos, &(bond)->slave_list, list)
 
 /**
- * bond_for_each_slave - iterate the slaves list from head
- * @bond:      the bond holding this list.
- * @pos:       current slave.
- * @cnt:       counter for max number of moves
+ * bond_for_each_slave_reverse - iterate in reverse from a given position
+ * @bond:      the bond holding this list
+ * @pos:       slave to continue from
  *
  * Caller must hold bond->lock
  */
-#define bond_for_each_slave(bond, pos, cnt)    \
-               bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave)
-
+#define bond_for_each_slave_continue_reverse(bond, pos) \
+       list_for_each_entry_continue_reverse(pos, &(bond)->slave_list, list)
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 extern atomic_t netpoll_block_tx;
@@ -174,8 +192,7 @@ struct vlan_entry {
 
 struct slave {
        struct net_device *dev; /* first - useful for panic debug */
-       struct slave *next;
-       struct slave *prev;
+       struct list_head list;
        struct bonding *bond; /* our master */
        int    delay;
        unsigned long jiffies;
@@ -215,7 +232,7 @@ struct slave {
  */
 struct bonding {
        struct   net_device *dev; /* first - useful for panic debug */
-       struct   slave *first_slave;
+       struct   list_head slave_list;
        struct   slave *curr_active_slave;
        struct   slave *current_arp_slave;
        struct   slave *primary_slave;
@@ -270,13 +287,10 @@ static inline struct slave *bond_get_slave_by_dev(struct bonding *bond,
                                                  struct net_device *slave_dev)
 {
        struct slave *slave = NULL;
-       int i;
 
-       bond_for_each_slave(bond, slave, i) {
-               if (slave->dev == slave_dev) {
+       bond_for_each_slave(bond, slave)
+               if (slave->dev == slave_dev)
                        return slave;
-               }
-       }
 
        return NULL;
 }
@@ -416,10 +430,20 @@ static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be3
        return addr;
 }
 
+static inline bool slave_can_tx(struct slave *slave)
+{
+       if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP &&
+           bond_is_active_slave(slave))
+               return true;
+       else
+               return false;
+}
+
 struct bond_net;
 
 struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
 int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
+void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id);
 int bond_create(struct net *net, const char *name);
 int bond_create_sysfs(struct bond_net *net);
 void bond_destroy_sysfs(struct bond_net *net);
@@ -477,10 +501,9 @@ static inline void bond_destroy_proc_dir(struct bond_net *bn)
 static inline struct slave *bond_slave_has_mac(struct bonding *bond,
                                               const u8 *mac)
 {
-       int i = 0;
        struct slave *tmp;
 
-       bond_for_each_slave(bond, tmp, i)
+       bond_for_each_slave(bond, tmp)
                if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr))
                        return tmp;
 
index dbbe97ae121e50a97610ed35a84e793d79fbf900..3b1ff6148702beb3818fbae7da2b0206f7d1c7f4 100644 (file)
@@ -1355,7 +1355,7 @@ static int at91_can_probe(struct platform_device *pdev)
        if (at91_is_sam9263(priv))
                dev->sysfs_groups[0] = &at91_sysfs_attr_group;
 
-       dev_set_drvdata(&pdev->dev, dev);
+       platform_set_drvdata(pdev, dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        err = register_candev(dev);
index c6f838d922a51b3883f1dea9ba26f2e0a9c63c4b..294ced3cc227520883c6ebe50ac255634d0f0f7c 100644 (file)
@@ -195,7 +195,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
 
                res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
                priv->raminit_ctrlreg = devm_ioremap_resource(&pdev->dev, res);
-               if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
+               if (IS_ERR(priv->raminit_ctrlreg) || (int)priv->instance < 0)
                        dev_info(&pdev->dev, "control memory is not used for raminit\n");
                else
                        priv->raminit = c_can_hw_raminit;
index 7b0be0910f4be5116901b1ff25668bb089a033df..71c677e651d7cbead0f673f53a93e89514e74eb3 100644 (file)
@@ -850,12 +850,17 @@ static int flexcan_open(struct net_device *dev)
        struct flexcan_priv *priv = netdev_priv(dev);
        int err;
 
-       clk_prepare_enable(priv->clk_ipg);
-       clk_prepare_enable(priv->clk_per);
+       err = clk_prepare_enable(priv->clk_ipg);
+       if (err)
+               return err;
+
+       err = clk_prepare_enable(priv->clk_per);
+       if (err)
+               goto out_disable_ipg;
 
        err = open_candev(dev);
        if (err)
-               goto out;
+               goto out_disable_per;
 
        err = request_irq(dev->irq, flexcan_irq, IRQF_SHARED, dev->name, dev);
        if (err)
@@ -875,8 +880,9 @@ static int flexcan_open(struct net_device *dev)
 
  out_close:
        close_candev(dev);
- out:
+ out_disable_per:
        clk_disable_unprepare(priv->clk_per);
+ out_disable_ipg:
        clk_disable_unprepare(priv->clk_ipg);
 
        return err;
@@ -933,8 +939,13 @@ static int register_flexcandev(struct net_device *dev)
        struct flexcan_regs __iomem *regs = priv->base;
        u32 reg, err;
 
-       clk_prepare_enable(priv->clk_ipg);
-       clk_prepare_enable(priv->clk_per);
+       err = clk_prepare_enable(priv->clk_ipg);
+       if (err)
+               return err;
+
+       err = clk_prepare_enable(priv->clk_per);
+       if (err)
+               goto out_disable_ipg;
 
        /* select "bus clock", chip must be disabled */
        flexcan_chip_disable(priv);
@@ -959,15 +970,16 @@ static int register_flexcandev(struct net_device *dev)
        if (!(reg & FLEXCAN_MCR_FEN)) {
                netdev_err(dev, "Could not enable RX FIFO, unsupported core\n");
                err = -ENODEV;
-               goto out;
+               goto out_disable_per;
        }
 
        err = register_candev(dev);
 
- out:
+ out_disable_per:
        /* disable core and turn off clocks */
        flexcan_chip_disable(priv);
        clk_disable_unprepare(priv->clk_per);
+ out_disable_ipg:
        clk_disable_unprepare(priv->clk_ipg);
 
        return err;
@@ -1001,7 +1013,6 @@ static int flexcan_probe(struct platform_device *pdev)
        struct resource *mem;
        struct clk *clk_ipg = NULL, *clk_per = NULL;
        void __iomem *base;
-       resource_size_t mem_size;
        int err, irq;
        u32 clock_freq = 0;
 
@@ -1013,43 +1024,25 @@ static int flexcan_probe(struct platform_device *pdev)
                clk_ipg = devm_clk_get(&pdev->dev, "ipg");
                if (IS_ERR(clk_ipg)) {
                        dev_err(&pdev->dev, "no ipg clock defined\n");
-                       err = PTR_ERR(clk_ipg);
-                       goto failed_clock;
+                       return PTR_ERR(clk_ipg);
                }
                clock_freq = clk_get_rate(clk_ipg);
 
                clk_per = devm_clk_get(&pdev->dev, "per");
                if (IS_ERR(clk_per)) {
                        dev_err(&pdev->dev, "no per clock defined\n");
-                       err = PTR_ERR(clk_per);
-                       goto failed_clock;
+                       return PTR_ERR(clk_per);
                }
        }
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!mem || irq <= 0) {
-               err = -ENODEV;
-               goto failed_get;
-       }
+       if (irq <= 0)
+               return -ENODEV;
 
-       mem_size = resource_size(mem);
-       if (!request_mem_region(mem->start, mem_size, pdev->name)) {
-               err = -EBUSY;
-               goto failed_get;
-       }
-
-       base = ioremap(mem->start, mem_size);
-       if (!base) {
-               err = -ENOMEM;
-               goto failed_map;
-       }
-
-       dev = alloc_candev(sizeof(struct flexcan_priv), 1);
-       if (!dev) {
-               err = -ENOMEM;
-               goto failed_alloc;
-       }
+       base = devm_ioremap_resource(&pdev->dev, mem);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
 
        of_id = of_match_device(flexcan_of_match, &pdev->dev);
        if (of_id) {
@@ -1058,10 +1051,13 @@ static int flexcan_probe(struct platform_device *pdev)
                devtype_data = (struct flexcan_devtype_data *)
                        pdev->id_entry->driver_data;
        } else {
-               err = -ENODEV;
-               goto failed_devtype;
+               return -ENODEV;
        }
 
+       dev = alloc_candev(sizeof(struct flexcan_priv), 1);
+       if (!dev)
+               return -ENOMEM;
+
        dev->netdev_ops = &flexcan_netdev_ops;
        dev->irq = irq;
        dev->flags |= IFF_ECHO;
@@ -1087,7 +1083,7 @@ static int flexcan_probe(struct platform_device *pdev)
 
        netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
 
-       dev_set_drvdata(&pdev->dev, dev);
+       platform_set_drvdata(pdev, dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        err = register_flexcandev(dev);
@@ -1104,28 +1100,15 @@ static int flexcan_probe(struct platform_device *pdev)
        return 0;
 
  failed_register:
- failed_devtype:
        free_candev(dev);
- failed_alloc:
-       iounmap(base);
- failed_map:
-       release_mem_region(mem->start, mem_size);
- failed_get:
- failed_clock:
        return err;
 }
 
 static int flexcan_remove(struct platform_device *pdev)
 {
        struct net_device *dev = platform_get_drvdata(pdev);
-       struct flexcan_priv *priv = netdev_priv(dev);
-       struct resource *mem;
 
        unregister_flexcandev(dev);
-       iounmap(priv->base);
-
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       release_mem_region(mem->start, resource_size(mem));
 
        free_candev(dev);
 
index 8cda23bf0614a1ebe383660300e3ec0cd34d20e2..fe7dd696957ea3d8c4f7e34b21baa866bb797b55 100644 (file)
@@ -37,9 +37,6 @@
  *
  * static struct mcp251x_platform_data mcp251x_info = {
  *         .oscillator_frequency = 8000000,
- *         .board_specific_setup = &mcp251x_setup,
- *         .power_enable = mcp251x_power_enable,
- *         .transceiver_enable = NULL,
  * };
  *
  * static struct spi_board_info spi_board_info[] = {
@@ -76,6 +73,7 @@
 #include <linux/slab.h>
 #include <linux/spi/spi.h>
 #include <linux/uaccess.h>
+#include <linux/regulator/consumer.h>
 
 /* SPI interface instruction set */
 #define INSTRUCTION_WRITE      0x02
@@ -264,6 +262,8 @@ struct mcp251x_priv {
 #define AFTER_SUSPEND_POWER 4
 #define AFTER_SUSPEND_RESTART 8
        int restart_tx;
+       struct regulator *power;
+       struct regulator *transceiver;
 };
 
 #define MCP251X_IS(_model) \
@@ -667,16 +667,25 @@ static int mcp251x_hw_probe(struct spi_device *spi)
        return (st1 == 0x80 && st2 == 0x07) ? 1 : 0;
 }
 
+static int mcp251x_power_enable(struct regulator *reg, int enable)
+{
+       if (IS_ERR(reg))
+               return 0;
+
+       if (enable)
+               return regulator_enable(reg);
+       else
+               return regulator_disable(reg);
+}
+
 static void mcp251x_open_clean(struct net_device *net)
 {
        struct mcp251x_priv *priv = netdev_priv(net);
        struct spi_device *spi = priv->spi;
-       struct mcp251x_platform_data *pdata = spi->dev.platform_data;
 
        free_irq(spi->irq, priv);
        mcp251x_hw_sleep(spi);
-       if (pdata->transceiver_enable)
-               pdata->transceiver_enable(0);
+       mcp251x_power_enable(priv->transceiver, 0);
        close_candev(net);
 }
 
@@ -684,7 +693,6 @@ static int mcp251x_stop(struct net_device *net)
 {
        struct mcp251x_priv *priv = netdev_priv(net);
        struct spi_device *spi = priv->spi;
-       struct mcp251x_platform_data *pdata = spi->dev.platform_data;
 
        close_candev(net);
 
@@ -704,8 +712,7 @@ static int mcp251x_stop(struct net_device *net)
 
        mcp251x_hw_sleep(spi);
 
-       if (pdata->transceiver_enable)
-               pdata->transceiver_enable(0);
+       mcp251x_power_enable(priv->transceiver, 0);
 
        priv->can.state = CAN_STATE_STOPPED;
 
@@ -928,8 +935,7 @@ static int mcp251x_open(struct net_device *net)
 {
        struct mcp251x_priv *priv = netdev_priv(net);
        struct spi_device *spi = priv->spi;
-       struct mcp251x_platform_data *pdata = spi->dev.platform_data;
-       unsigned long flags;
+       unsigned long flags = IRQF_ONESHOT | IRQF_TRIGGER_FALLING;
        int ret;
 
        ret = open_candev(net);
@@ -939,25 +945,17 @@ static int mcp251x_open(struct net_device *net)
        }
 
        mutex_lock(&priv->mcp_lock);
-       if (pdata->transceiver_enable)
-               pdata->transceiver_enable(1);
+       mcp251x_power_enable(priv->transceiver, 1);
 
        priv->force_quit = 0;
        priv->tx_skb = NULL;
        priv->tx_len = 0;
 
-       flags = IRQF_ONESHOT;
-       if (pdata->irq_flags)
-               flags |= pdata->irq_flags;
-       else
-               flags |= IRQF_TRIGGER_FALLING;
-
        ret = request_threaded_irq(spi->irq, NULL, mcp251x_can_ist,
                                   flags, DEVICE_NAME, priv);
        if (ret) {
                dev_err(&spi->dev, "failed to acquire irq %d\n", spi->irq);
-               if (pdata->transceiver_enable)
-                       pdata->transceiver_enable(0);
+               mcp251x_power_enable(priv->transceiver, 0);
                close_candev(net);
                goto open_unlock;
        }
@@ -1026,6 +1024,19 @@ static int mcp251x_can_probe(struct spi_device *spi)
                CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
        priv->model = spi_get_device_id(spi)->driver_data;
        priv->net = net;
+
+       priv->power = devm_regulator_get(&spi->dev, "vdd");
+       priv->transceiver = devm_regulator_get(&spi->dev, "xceiver");
+       if ((PTR_ERR(priv->power) == -EPROBE_DEFER) ||
+           (PTR_ERR(priv->transceiver) == -EPROBE_DEFER)) {
+               ret = -EPROBE_DEFER;
+               goto error_power;
+       }
+
+       ret = mcp251x_power_enable(priv->power, 1);
+       if (ret)
+               goto error_power;
+
        spi_set_drvdata(spi, priv);
 
        priv->spi = spi;
@@ -1068,30 +1079,24 @@ static int mcp251x_can_probe(struct spi_device *spi)
                }
        }
 
-       if (pdata->power_enable)
-               pdata->power_enable(1);
-
-       /* Call out to platform specific setup */
-       if (pdata->board_specific_setup)
-               pdata->board_specific_setup(spi);
-
        SET_NETDEV_DEV(net, &spi->dev);
 
        /* Configure the SPI bus */
-       spi->mode = SPI_MODE_0;
+       spi->mode = spi->mode ? : SPI_MODE_0;
+       if (mcp251x_is_2510(spi))
+               spi->max_speed_hz = spi->max_speed_hz ? : 5 * 1000 * 1000;
+       else
+               spi->max_speed_hz = spi->max_speed_hz ? : 10 * 1000 * 1000;
        spi->bits_per_word = 8;
        spi_setup(spi);
 
        /* Here is OK to not lock the MCP, no one knows about it yet */
        if (!mcp251x_hw_probe(spi)) {
-               dev_info(&spi->dev, "Probe failed\n");
+               ret = -ENODEV;
                goto error_probe;
        }
        mcp251x_hw_sleep(spi);
 
-       if (pdata->transceiver_enable)
-               pdata->transceiver_enable(0);
-
        ret = register_candev(net);
        if (ret)
                goto error_probe;
@@ -1109,13 +1114,13 @@ error_rx_buf:
        if (!mcp251x_enable_dma)
                kfree(priv->spi_tx_buf);
 error_tx_buf:
-       free_candev(net);
        if (mcp251x_enable_dma)
                dma_free_coherent(&spi->dev, PAGE_SIZE,
                                  priv->spi_tx_buf, priv->spi_tx_dma);
+       mcp251x_power_enable(priv->power, 0);
+error_power:
+       free_candev(net);
 error_alloc:
-       if (pdata->power_enable)
-               pdata->power_enable(0);
        dev_err(&spi->dev, "probe failed\n");
 error_out:
        return ret;
@@ -1123,12 +1128,10 @@ error_out:
 
 static int mcp251x_can_remove(struct spi_device *spi)
 {
-       struct mcp251x_platform_data *pdata = spi->dev.platform_data;
        struct mcp251x_priv *priv = spi_get_drvdata(spi);
        struct net_device *net = priv->net;
 
        unregister_candev(net);
-       free_candev(net);
 
        if (mcp251x_enable_dma) {
                dma_free_coherent(&spi->dev, PAGE_SIZE,
@@ -1138,8 +1141,9 @@ static int mcp251x_can_remove(struct spi_device *spi)
                kfree(priv->spi_rx_buf);
        }
 
-       if (pdata->power_enable)
-               pdata->power_enable(0);
+       mcp251x_power_enable(priv->power, 0);
+
+       free_candev(net);
 
        return 0;
 }
@@ -1149,7 +1153,6 @@ static int mcp251x_can_remove(struct spi_device *spi)
 static int mcp251x_can_suspend(struct device *dev)
 {
        struct spi_device *spi = to_spi_device(dev);
-       struct mcp251x_platform_data *pdata = spi->dev.platform_data;
        struct mcp251x_priv *priv = spi_get_drvdata(spi);
        struct net_device *net = priv->net;
 
@@ -1163,15 +1166,14 @@ static int mcp251x_can_suspend(struct device *dev)
                netif_device_detach(net);
 
                mcp251x_hw_sleep(spi);
-               if (pdata->transceiver_enable)
-                       pdata->transceiver_enable(0);
+               mcp251x_power_enable(priv->transceiver, 0);
                priv->after_suspend = AFTER_SUSPEND_UP;
        } else {
                priv->after_suspend = AFTER_SUSPEND_DOWN;
        }
 
-       if (pdata->power_enable) {
-               pdata->power_enable(0);
+       if (!IS_ERR(priv->power)) {
+               regulator_disable(priv->power);
                priv->after_suspend |= AFTER_SUSPEND_POWER;
        }
 
@@ -1181,16 +1183,14 @@ static int mcp251x_can_suspend(struct device *dev)
 static int mcp251x_can_resume(struct device *dev)
 {
        struct spi_device *spi = to_spi_device(dev);
-       struct mcp251x_platform_data *pdata = spi->dev.platform_data;
        struct mcp251x_priv *priv = spi_get_drvdata(spi);
 
        if (priv->after_suspend & AFTER_SUSPEND_POWER) {
-               pdata->power_enable(1);
+               mcp251x_power_enable(priv->power, 1);
                queue_work(priv->wq, &priv->restart_work);
        } else {
                if (priv->after_suspend & AFTER_SUSPEND_UP) {
-                       if (pdata->transceiver_enable)
-                               pdata->transceiver_enable(1);
+                       mcp251x_power_enable(priv->transceiver, 1);
                        queue_work(priv->wq, &priv->restart_work);
                } else {
                        priv->after_suspend = 0;
index 6aa7b3266c80904d8d2f2106869085a8b19d5248..ac6177d3befca611242f26906a9168f11ad3c23c 100644 (file)
@@ -412,10 +412,20 @@ static void esd_usb2_read_bulk_callback(struct urb *urb)
 
                switch (msg->msg.hdr.cmd) {
                case CMD_CAN_RX:
+                       if (msg->msg.rx.net >= dev->net_count) {
+                               dev_err(dev->udev->dev.parent, "format error\n");
+                               break;
+                       }
+
                        esd_usb2_rx_can_msg(dev->nets[msg->msg.rx.net], msg);
                        break;
 
                case CMD_CAN_TX:
+                       if (msg->msg.txdone.net >= dev->net_count) {
+                               dev_err(dev->udev->dev.parent, "format error\n");
+                               break;
+                       }
+
                        esd_usb2_tx_done_msg(dev->nets[msg->msg.txdone.net],
                                             msg);
                        break;
index 25723d8ee20130b19ad95b885a99e5c1ba019517..925ab8ec9329b5bbfadb6e94faa12de0b7f91ceb 100644 (file)
@@ -649,7 +649,7 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
                if ((mc->ptr + rec_len) > mc->end)
                        goto decode_failed;
 
-               memcpy(cf->data, mc->ptr, rec_len);
+               memcpy(cf->data, mc->ptr, cf->can_dlc);
                mc->ptr += rec_len;
        }
 
index cbd388eea68271c8ab7eaa2581ffb9145a4be429..8becd3d838b5eab2a520be8835c9fba3f3703482 100644 (file)
@@ -779,6 +779,7 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
                        usb_unanchor_urb(urb);
                        usb_free_coherent(priv->udev, RX_BUFFER_SIZE, buf,
                                          urb->transfer_dma);
+                       usb_free_urb(urb);
                        break;
                }
 
index e1d26433d61921b3e0460421212006bcb5e0e9ee..b7232a9b7756cb48f8fd143b4f5a31f45757151a 100644 (file)
@@ -707,7 +707,7 @@ static int ax_init_dev(struct net_device *dev)
 
 #ifdef CONFIG_AX88796_93CX6
        if (ax->plat->flags & AXFLG_HAS_93CX6) {
-               unsigned char mac_addr[6];
+               unsigned char mac_addr[ETH_ALEN];
                struct eeprom_93cx6 eeprom;
 
                eeprom.data = ei_local;
@@ -719,7 +719,7 @@ static int ax_init_dev(struct net_device *dev)
                                       (__le16 __force *)mac_addr,
                                       sizeof(mac_addr) >> 1);
 
-               memcpy(dev->dev_addr, mac_addr, 6);
+               memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
        }
 #endif
        if (ax->plat->wordlength == 2) {
index 2037080c504d67e6128797f4a920891fed5a6d0e..506b0248c4001b48382f3ef6be2ccbc47724c8fa 100644 (file)
@@ -90,6 +90,7 @@ source "drivers/net/ethernet/marvell/Kconfig"
 source "drivers/net/ethernet/mellanox/Kconfig"
 source "drivers/net/ethernet/micrel/Kconfig"
 source "drivers/net/ethernet/microchip/Kconfig"
+source "drivers/net/ethernet/moxa/Kconfig"
 source "drivers/net/ethernet/myricom/Kconfig"
 
 config FEALNX
index 390bd0bfaa2721b655a80f5c1f74b848f2665cd5..c0b8789952e711fb77e44fc214d06ee8cac5e8f3 100644 (file)
@@ -42,6 +42,7 @@ obj-$(CONFIG_NET_VENDOR_MARVELL) += marvell/
 obj-$(CONFIG_NET_VENDOR_MELLANOX) += mellanox/
 obj-$(CONFIG_NET_VENDOR_MICREL) += micrel/
 obj-$(CONFIG_NET_VENDOR_MICROCHIP) += microchip/
+obj-$(CONFIG_NET_VENDOR_MOXART) += moxa/
 obj-$(CONFIG_NET_VENDOR_MYRI) += myricom/
 obj-$(CONFIG_FEALNX) += fealnx.o
 obj-$(CONFIG_NET_VENDOR_NATSEMI) += natsemi/
index 53ad213e865ba350176ac8b59d83bac0dc58ca09..d8d95d4cd45a9ef00ffa7c9c919188bc66d39465 100644 (file)
@@ -3,19 +3,20 @@
 #
 
 config NET_VENDOR_ALLWINNER
-       bool "Allwinner devices"
-       default y
-       depends on ARCH_SUNXI
-       ---help---
-         If you have a network (Ethernet) card belonging to this
-        class, say Y and read the Ethernet-HOWTO, available from
-        <http://www.tldp.org/docs.html#howto>.
+       bool "Allwinner devices"
+       default y
 
-        Note that the answer to this question doesn't directly
-        affect the kernel: saying N will just cause the configurator
-        to skip all the questions about Allwinner cards. If you say Y,
-        you will be asked for your specific card in the following
-        questions.
+       depends on ARCH_SUNXI
+       ---help---
+         If you have a network (Ethernet) card belonging to this
+         class, say Y and read the Ethernet-HOWTO, available from
+         <http://www.tldp.org/docs.html#howto>.
+
+         Note that the answer to this question doesn't directly
+         affect the kernel: saying N will just cause the configurator
+         to skip all the questions about Allwinner cards. If you say Y,
+         you will be asked for your specific card in the following
+         questions.
 
 if NET_VENDOR_ALLWINNER
 
@@ -26,6 +27,7 @@ config SUN4I_EMAC
        select CRC32
        select MII
        select PHYLIB
+       select MDIO_SUN4I
         ---help---
           Support for Allwinner A10 EMAC ethernet driver.
 
index ed21307276430895fadc736b16f8539afe1713cf..2d8e28819779eed0388109791fe0126f5af763f8 100644 (file)
@@ -1521,7 +1521,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
        char *chipname;
        struct net_device *dev;
        const struct pcnet32_access *a = NULL;
-       u8 promaddr[6];
+       u8 promaddr[ETH_ALEN];
        int ret = -ENODEV;
 
        /* reset the chip */
@@ -1665,10 +1665,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
        }
 
        /* read PROM address and compare with CSR address */
-       for (i = 0; i < 6; i++)
+       for (i = 0; i < ETH_ALEN; i++)
                promaddr[i] = inb(ioaddr + i);
 
-       if (memcmp(promaddr, dev->dev_addr, 6) ||
+       if (memcmp(promaddr, dev->dev_addr, ETH_ALEN) ||
            !is_valid_ether_addr(dev->dev_addr)) {
                if (is_valid_ether_addr(promaddr)) {
                        if (pcnet32_debug & NETIF_MSG_PROBE) {
index f1b121ee5525bfa974010663da5807e9b4d038e5..55d79cb53a79637bb09297d49f1cf1d1ed533147 100644 (file)
@@ -199,7 +199,7 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
        struct arc_emac_priv *priv = netdev_priv(ndev);
        unsigned int work_done;
 
-       for (work_done = 0; work_done <= budget; work_done++) {
+       for (work_done = 0; work_done < budget; work_done++) {
                unsigned int *last_rx_bd = &priv->last_rx_bd;
                struct net_device_stats *stats = &priv->stats;
                struct buffer_state *rx_buff = &priv->rx_buff[*last_rx_bd];
index b2bf324631dc89f7902f9d7322c549331daa1c78..0f0556526ba90bff7f764c4005d6f6e850220dd7 100644 (file)
@@ -520,6 +520,9 @@ struct atl1c_adapter {
        struct net_device   *netdev;
        struct pci_dev      *pdev;
        struct napi_struct  napi;
+       struct page         *rx_page;
+       unsigned int        rx_page_offset;
+       unsigned int        rx_frag_size;
        struct atl1c_hw        hw;
        struct atl1c_hw_stats  hw_stats;
        struct mii_if_info  mii;    /* MII interface info */
index 786a87483298ea400733b987da389144e297824b..a36a760ada28af64272a5132a60648c543963bed 100644 (file)
@@ -481,10 +481,15 @@ static int atl1c_set_mac_addr(struct net_device *netdev, void *p)
 static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter,
                                struct net_device *dev)
 {
+       unsigned int head_size;
        int mtu = dev->mtu;
 
        adapter->rx_buffer_len = mtu > AT_RX_BUF_SIZE ?
                roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE;
+
+       head_size = SKB_DATA_ALIGN(adapter->rx_buffer_len + NET_SKB_PAD) +
+                   SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+       adapter->rx_frag_size = roundup_pow_of_two(head_size);
 }
 
 static netdev_features_t atl1c_fix_features(struct net_device *netdev,
@@ -952,6 +957,10 @@ static void atl1c_free_ring_resources(struct atl1c_adapter *adapter)
                kfree(adapter->tpd_ring[0].buffer_info);
                adapter->tpd_ring[0].buffer_info = NULL;
        }
+       if (adapter->rx_page) {
+               put_page(adapter->rx_page);
+               adapter->rx_page = NULL;
+       }
 }
 
 /**
@@ -1639,6 +1648,35 @@ static inline void atl1c_rx_checksum(struct atl1c_adapter *adapter,
        skb_checksum_none_assert(skb);
 }
 
+static struct sk_buff *atl1c_alloc_skb(struct atl1c_adapter *adapter)
+{
+       struct sk_buff *skb;
+       struct page *page;
+
+       if (adapter->rx_frag_size > PAGE_SIZE)
+               return netdev_alloc_skb(adapter->netdev,
+                                       adapter->rx_buffer_len);
+
+       page = adapter->rx_page;
+       if (!page) {
+               adapter->rx_page = page = alloc_page(GFP_ATOMIC);
+               if (unlikely(!page))
+                       return NULL;
+               adapter->rx_page_offset = 0;
+       }
+
+       skb = build_skb(page_address(page) + adapter->rx_page_offset,
+                       adapter->rx_frag_size);
+       if (likely(skb)) {
+               adapter->rx_page_offset += adapter->rx_frag_size;
+               if (adapter->rx_page_offset >= PAGE_SIZE)
+                       adapter->rx_page = NULL;
+               else
+                       get_page(page);
+       }
+       return skb;
+}
+
 static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter)
 {
        struct atl1c_rfd_ring *rfd_ring = &adapter->rfd_ring;
@@ -1660,7 +1698,7 @@ static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter)
        while (next_info->flags & ATL1C_BUFFER_FREE) {
                rfd_desc = ATL1C_RFD_DESC(rfd_ring, rfd_next_to_use);
 
-               skb = netdev_alloc_skb(adapter->netdev, adapter->rx_buffer_len);
+               skb = atl1c_alloc_skb(adapter);
                if (unlikely(!skb)) {
                        if (netif_msg_rx_err(adapter))
                                dev_warn(&pdev->dev, "alloc rx buffer failed\n");
index 6d1a62a84c9d04b3309354f241bcef9061098341..1966444590f6192e862a713216182ab09052ebef 100644 (file)
@@ -1678,6 +1678,7 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
        u16 f;
        int segment;
        int ring_start = adapter->tx_ring.next_to_use;
+       int ring_end;
 
        nr_frags = skb_shinfo(skb)->nr_frags;
        segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK;
@@ -1721,6 +1722,15 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
                                        map_len, PCI_DMA_TODEVICE);
 
                if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) {
+                       /* We need to unwind the mappings we've done */
+                       ring_end = adapter->tx_ring.next_to_use;
+                       adapter->tx_ring.next_to_use = ring_start;
+                       while (adapter->tx_ring.next_to_use != ring_end) {
+                               tpd = atl1e_get_tpd(adapter);
+                               tx_buffer = atl1e_get_tx_buffer(adapter, tpd);
+                               pci_unmap_single(adapter->pdev, tx_buffer->dma,
+                                                tx_buffer->length, PCI_DMA_TODEVICE);
+                       }
                        /* Reset the tx rings next pointer */
                        adapter->tx_ring.next_to_use = ring_start;
                        return -ENOSPC;
@@ -1763,6 +1773,16 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
                                                          DMA_TO_DEVICE);
 
                        if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) {
+                               /* We need to unwind the mappings we've done */
+                               ring_end = adapter->tx_ring.next_to_use;
+                               adapter->tx_ring.next_to_use = ring_start;
+                               while (adapter->tx_ring.next_to_use != ring_end) {
+                                       tpd = atl1e_get_tpd(adapter);
+                                       tx_buffer = atl1e_get_tx_buffer(adapter, tpd);
+                                       dma_unmap_page(&adapter->pdev->dev, tx_buffer->dma,
+                                                      tx_buffer->length, DMA_TO_DEVICE);
+                               }
+
                                /* Reset the ring next to use pointer */
                                adapter->tx_ring.next_to_use = ring_start;
                                return -ENOSPC;
@@ -1853,8 +1873,10 @@ static netdev_tx_t atl1e_xmit_frame(struct sk_buff *skb,
                return NETDEV_TX_OK;
        }
 
-       if (atl1e_tx_map(adapter, skb, tpd))
+       if (atl1e_tx_map(adapter, skb, tpd)) {
+               dev_kfree_skb_any(skb);
                goto out;
+       }
 
        atl1e_tx_queue(adapter, tpd_req, tpd);
 
index 7b839bf5bb7a4d54349443bedc97def4d1dff7c0..2fa5b86f139db626f1839c7b3bc9087444179b28 100644 (file)
@@ -131,6 +131,7 @@ config BNX2X_SRIOV
 config BGMAC
        tristate "BCMA bus GBit core support"
        depends on BCMA_HOST_SOC && HAS_DMA && BCM47XX
+       select PHYLIB
        ---help---
          This driver supports GBit MAC and BCM4706 GBit MAC cores on BCMA bus.
          They can be found on BCM47xx SoCs and provide gigabit ethernet.
index b1bcd4ba47444e0f36c1bc4f9d8a2ff446ba5882..190219e0240062549973be2f8ea9191763625e47 100644 (file)
@@ -1747,11 +1747,10 @@ static int bcm_enet_probe(struct platform_device *pdev)
        if (!bcm_enet_shared_base[0])
                return -ENODEV;
 
-       res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        res_irq_rx = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
        res_irq_tx = platform_get_resource(pdev, IORESOURCE_IRQ, 2);
-       if (!res_mem || !res_irq || !res_irq_rx || !res_irq_tx)
+       if (!res_irq || !res_irq_rx || !res_irq_tx)
                return -ENODEV;
 
        ret = 0;
@@ -1767,9 +1766,10 @@ static int bcm_enet_probe(struct platform_device *pdev)
        if (ret)
                goto out;
 
-       priv->base = devm_request_and_ioremap(&pdev->dev, res_mem);
-       if (priv->base == NULL) {
-               ret = -ENOMEM;
+       res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       priv->base = devm_ioremap_resource(&pdev->dev, res_mem);
+       if (IS_ERR(priv->base)) {
+               ret = PTR_ERR(priv->base);
                goto out;
        }
 
@@ -2836,7 +2836,6 @@ static int bcm_enetsw_remove(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        release_mem_region(res->start, resource_size(res));
 
-       platform_set_drvdata(pdev, NULL);
        free_netdev(dev);
        return 0;
 }
index 6a2de1d79ff6c011188f2ccfb8e48c315d93825c..4148058cef8165e374f3eb0c9c85275b036d33b8 100644 (file)
@@ -1,6 +1,6 @@
 /* bnx2.c: Broadcom NX2 network driver.
  *
- * Copyright (c) 2004-2011 Broadcom Corporation
+ * Copyright (c) 2004-2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -58,8 +58,8 @@
 #include "bnx2_fw.h"
 
 #define DRV_MODULE_NAME                "bnx2"
-#define DRV_MODULE_VERSION     "2.2.3"
-#define DRV_MODULE_RELDATE     "June 27, 2012"
+#define DRV_MODULE_VERSION     "2.2.4"
+#define DRV_MODULE_RELDATE     "Aug 05, 2013"
 #define FW_MIPS_FILE_06                "bnx2/bnx2-mips-06-6.2.3.fw"
 #define FW_RV2P_FILE_06                "bnx2/bnx2-rv2p-06-6.0.15.fw"
 #define FW_MIPS_FILE_09                "bnx2/bnx2-mips-09-6.2.1b.fw"
@@ -3908,136 +3908,121 @@ init_cpu_err:
        return rc;
 }
 
-static int
-bnx2_set_power_state(struct bnx2 *bp, pci_power_t state)
+static void
+bnx2_setup_wol(struct bnx2 *bp)
 {
-       u16 pmcsr;
+       int i;
+       u32 val, wol_msg;
 
-       pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr);
+       if (bp->wol) {
+               u32 advertising;
+               u8 autoneg;
 
-       switch (state) {
-       case PCI_D0: {
-               u32 val;
+               autoneg = bp->autoneg;
+               advertising = bp->advertising;
 
-               pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL,
-                       (pmcsr & ~PCI_PM_CTRL_STATE_MASK) |
-                       PCI_PM_CTRL_PME_STATUS);
+               if (bp->phy_port == PORT_TP) {
+                       bp->autoneg = AUTONEG_SPEED;
+                       bp->advertising = ADVERTISED_10baseT_Half |
+                               ADVERTISED_10baseT_Full |
+                               ADVERTISED_100baseT_Half |
+                               ADVERTISED_100baseT_Full |
+                               ADVERTISED_Autoneg;
+               }
 
-               if (pmcsr & PCI_PM_CTRL_STATE_MASK)
-                       /* delay required during transition out of D3hot */
-                       msleep(20);
+               spin_lock_bh(&bp->phy_lock);
+               bnx2_setup_phy(bp, bp->phy_port);
+               spin_unlock_bh(&bp->phy_lock);
 
-               val = BNX2_RD(bp, BNX2_EMAC_MODE);
-               val |= BNX2_EMAC_MODE_MPKT_RCVD | BNX2_EMAC_MODE_ACPI_RCVD;
-               val &= ~BNX2_EMAC_MODE_MPKT;
-               BNX2_WR(bp, BNX2_EMAC_MODE, val);
+               bp->autoneg = autoneg;
+               bp->advertising = advertising;
 
-               val = BNX2_RD(bp, BNX2_RPM_CONFIG);
-               val &= ~BNX2_RPM_CONFIG_ACPI_ENA;
-               BNX2_WR(bp, BNX2_RPM_CONFIG, val);
-               break;
-       }
-       case PCI_D3hot: {
-               int i;
-               u32 val, wol_msg;
-
-               if (bp->wol) {
-                       u32 advertising;
-                       u8 autoneg;
-
-                       autoneg = bp->autoneg;
-                       advertising = bp->advertising;
-
-                       if (bp->phy_port == PORT_TP) {
-                               bp->autoneg = AUTONEG_SPEED;
-                               bp->advertising = ADVERTISED_10baseT_Half |
-                                       ADVERTISED_10baseT_Full |
-                                       ADVERTISED_100baseT_Half |
-                                       ADVERTISED_100baseT_Full |
-                                       ADVERTISED_Autoneg;
-                       }
+               bnx2_set_mac_addr(bp, bp->dev->dev_addr, 0);
 
-                       spin_lock_bh(&bp->phy_lock);
-                       bnx2_setup_phy(bp, bp->phy_port);
-                       spin_unlock_bh(&bp->phy_lock);
+               val = BNX2_RD(bp, BNX2_EMAC_MODE);
 
-                       bp->autoneg = autoneg;
-                       bp->advertising = advertising;
+               /* Enable port mode. */
+               val &= ~BNX2_EMAC_MODE_PORT;
+               val |= BNX2_EMAC_MODE_MPKT_RCVD |
+                      BNX2_EMAC_MODE_ACPI_RCVD |
+                      BNX2_EMAC_MODE_MPKT;
+               if (bp->phy_port == PORT_TP) {
+                       val |= BNX2_EMAC_MODE_PORT_MII;
+               } else {
+                       val |= BNX2_EMAC_MODE_PORT_GMII;
+                       if (bp->line_speed == SPEED_2500)
+                               val |= BNX2_EMAC_MODE_25G_MODE;
+               }
 
-                       bnx2_set_mac_addr(bp, bp->dev->dev_addr, 0);
+               BNX2_WR(bp, BNX2_EMAC_MODE, val);
 
-                       val = BNX2_RD(bp, BNX2_EMAC_MODE);
+               /* receive all multicast */
+               for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
+                       BNX2_WR(bp, BNX2_EMAC_MULTICAST_HASH0 + (i * 4),
+                               0xffffffff);
+               }
+               BNX2_WR(bp, BNX2_EMAC_RX_MODE, BNX2_EMAC_RX_MODE_SORT_MODE);
 
-                       /* Enable port mode. */
-                       val &= ~BNX2_EMAC_MODE_PORT;
-                       val |= BNX2_EMAC_MODE_MPKT_RCVD |
-                              BNX2_EMAC_MODE_ACPI_RCVD |
-                              BNX2_EMAC_MODE_MPKT;
-                       if (bp->phy_port == PORT_TP)
-                               val |= BNX2_EMAC_MODE_PORT_MII;
-                       else {
-                               val |= BNX2_EMAC_MODE_PORT_GMII;
-                               if (bp->line_speed == SPEED_2500)
-                                       val |= BNX2_EMAC_MODE_25G_MODE;
-                       }
+               val = 1 | BNX2_RPM_SORT_USER0_BC_EN | BNX2_RPM_SORT_USER0_MC_EN;
+               BNX2_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
+               BNX2_WR(bp, BNX2_RPM_SORT_USER0, val);
+               BNX2_WR(bp, BNX2_RPM_SORT_USER0, val | BNX2_RPM_SORT_USER0_ENA);
 
-                       BNX2_WR(bp, BNX2_EMAC_MODE, val);
+               /* Need to enable EMAC and RPM for WOL. */
+               BNX2_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
+                       BNX2_MISC_ENABLE_SET_BITS_RX_PARSER_MAC_ENABLE |
+                       BNX2_MISC_ENABLE_SET_BITS_TX_HEADER_Q_ENABLE |
+                       BNX2_MISC_ENABLE_SET_BITS_EMAC_ENABLE);
 
-                       /* receive all multicast */
-                       for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
-                               BNX2_WR(bp, BNX2_EMAC_MULTICAST_HASH0 + (i * 4),
-                                       0xffffffff);
-                       }
-                       BNX2_WR(bp, BNX2_EMAC_RX_MODE,
-                               BNX2_EMAC_RX_MODE_SORT_MODE);
+               val = BNX2_RD(bp, BNX2_RPM_CONFIG);
+               val &= ~BNX2_RPM_CONFIG_ACPI_ENA;
+               BNX2_WR(bp, BNX2_RPM_CONFIG, val);
 
-                       val = 1 | BNX2_RPM_SORT_USER0_BC_EN |
-                             BNX2_RPM_SORT_USER0_MC_EN;
-                       BNX2_WR(bp, BNX2_RPM_SORT_USER0, 0x0);
-                       BNX2_WR(bp, BNX2_RPM_SORT_USER0, val);
-                       BNX2_WR(bp, BNX2_RPM_SORT_USER0, val |
-                               BNX2_RPM_SORT_USER0_ENA);
+               wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
+       } else {
+                       wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
+       }
 
-                       /* Need to enable EMAC and RPM for WOL. */
-                       BNX2_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
-                               BNX2_MISC_ENABLE_SET_BITS_RX_PARSER_MAC_ENABLE |
-                               BNX2_MISC_ENABLE_SET_BITS_TX_HEADER_Q_ENABLE |
-                               BNX2_MISC_ENABLE_SET_BITS_EMAC_ENABLE);
+       if (!(bp->flags & BNX2_FLAG_NO_WOL))
+               bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT3 | wol_msg, 1, 0);
 
-                       val = BNX2_RD(bp, BNX2_RPM_CONFIG);
-                       val &= ~BNX2_RPM_CONFIG_ACPI_ENA;
-                       BNX2_WR(bp, BNX2_RPM_CONFIG, val);
+}
 
-                       wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
-               }
-               else {
-                       wol_msg = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
-               }
+static int
+bnx2_set_power_state(struct bnx2 *bp, pci_power_t state)
+{
+       switch (state) {
+       case PCI_D0: {
+               u32 val;
+
+               pci_enable_wake(bp->pdev, PCI_D0, false);
+               pci_set_power_state(bp->pdev, PCI_D0);
 
-               if (!(bp->flags & BNX2_FLAG_NO_WOL))
-                       bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT3 | wol_msg,
-                                    1, 0);
+               val = BNX2_RD(bp, BNX2_EMAC_MODE);
+               val |= BNX2_EMAC_MODE_MPKT_RCVD | BNX2_EMAC_MODE_ACPI_RCVD;
+               val &= ~BNX2_EMAC_MODE_MPKT;
+               BNX2_WR(bp, BNX2_EMAC_MODE, val);
 
-               pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
+               val = BNX2_RD(bp, BNX2_RPM_CONFIG);
+               val &= ~BNX2_RPM_CONFIG_ACPI_ENA;
+               BNX2_WR(bp, BNX2_RPM_CONFIG, val);
+               break;
+       }
+       case PCI_D3hot: {
+               bnx2_setup_wol(bp);
+               pci_wake_from_d3(bp->pdev, bp->wol);
                if ((BNX2_CHIP_ID(bp) == BNX2_CHIP_ID_5706_A0) ||
                    (BNX2_CHIP_ID(bp) == BNX2_CHIP_ID_5706_A1)) {
 
                        if (bp->wol)
-                               pmcsr |= 3;
-               }
-               else {
-                       pmcsr |= 3;
-               }
-               if (bp->wol) {
-                       pmcsr |= PCI_PM_CTRL_PME_ENABLE;
+                               pci_set_power_state(bp->pdev, PCI_D3hot);
+               } else {
+                       pci_set_power_state(bp->pdev, PCI_D3hot);
                }
-               pci_write_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL,
-                                     pmcsr);
 
                /* No more memory access after this point until
                 * device is brought back to D0.
                 */
-               udelay(50);
                break;
        }
        default:
@@ -6317,7 +6302,6 @@ bnx2_open(struct net_device *dev)
 
        netif_carrier_off(dev);
 
-       bnx2_set_power_state(bp, PCI_D0);
        bnx2_disable_int(bp);
 
        rc = bnx2_setup_int_mode(bp, disable_msi);
@@ -6724,7 +6708,6 @@ bnx2_close(struct net_device *dev)
        bnx2_del_napi(bp);
        bp->link_up = 0;
        netif_carrier_off(bp->dev);
-       bnx2_set_power_state(bp, PCI_D3hot);
        return 0;
 }
 
@@ -7081,6 +7064,9 @@ bnx2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
        else {
                bp->wol = 0;
        }
+
+       device_set_wakeup_enable(&bp->pdev->dev, bp->wol);
+
        return 0;
 }
 
@@ -7156,9 +7142,6 @@ bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
        struct bnx2 *bp = netdev_priv(dev);
        int rc;
 
-       if (!netif_running(dev))
-               return -EAGAIN;
-
        /* parameters already validated in ethtool_get_eeprom */
 
        rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
@@ -7173,9 +7156,6 @@ bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
        struct bnx2 *bp = netdev_priv(dev);
        int rc;
 
-       if (!netif_running(dev))
-               return -EAGAIN;
-
        /* parameters already validated in ethtool_set_eeprom */
 
        rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
@@ -7535,8 +7515,6 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
 {
        struct bnx2 *bp = netdev_priv(dev);
 
-       bnx2_set_power_state(bp, PCI_D0);
-
        memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
        if (etest->flags & ETH_TEST_FL_OFFLINE) {
                int i;
@@ -7585,8 +7563,6 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
                etest->flags |= ETH_TEST_FL_FAILED;
 
        }
-       if (!netif_running(bp->dev))
-               bnx2_set_power_state(bp, PCI_D3hot);
 }
 
 static void
@@ -7658,8 +7634,6 @@ bnx2_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state)
 
        switch (state) {
        case ETHTOOL_ID_ACTIVE:
-               bnx2_set_power_state(bp, PCI_D0);
-
                bp->leds_save = BNX2_RD(bp, BNX2_MISC_CFG);
                BNX2_WR(bp, BNX2_MISC_CFG, BNX2_MISC_CFG_LEDMODE_MAC);
                return 1;       /* cycle on/off once per second */
@@ -7680,9 +7654,6 @@ bnx2_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state)
        case ETHTOOL_ID_INACTIVE:
                BNX2_WR(bp, BNX2_EMAC_LED, 0);
                BNX2_WR(bp, BNX2_MISC_CFG, bp->leds_save);
-
-               if (!netif_running(dev))
-                       bnx2_set_power_state(bp, PCI_D3hot);
                break;
        }
 
@@ -8130,8 +8101,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                goto err_out_release;
        }
 
-       bnx2_set_power_state(bp, PCI_D0);
-
        /* Configure byte swap and enable write to the reg_window registers.
         * Rely on CPU to do target byte swapping on big endian systems
         * The chip's target access swapping will not swap all accesses
@@ -8170,13 +8139,13 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 
        if (BNX2_CHIP(bp) == BNX2_CHIP_5709 &&
            BNX2_CHIP_REV(bp) != BNX2_CHIP_REV_Ax) {
-               if (pci_find_capability(pdev, PCI_CAP_ID_MSIX))
+               if (pdev->msix_cap)
                        bp->flags |= BNX2_FLAG_MSIX_CAP;
        }
 
        if (BNX2_CHIP_ID(bp) != BNX2_CHIP_ID_5706_A0 &&
            BNX2_CHIP_ID(bp) != BNX2_CHIP_ID_5706_A1) {
-               if (pci_find_capability(pdev, PCI_CAP_ID_MSI))
+               if (pdev->msi_cap)
                        bp->flags |= BNX2_FLAG_MSI_CAP;
        }
 
@@ -8369,6 +8338,11 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
                bp->wol = 0;
        }
 
+       if (bp->flags & BNX2_FLAG_NO_WOL)
+               device_set_wakeup_capable(&bp->pdev->dev, false);
+       else
+               device_set_wakeup_enable(&bp->pdev->dev, bp->wol);
+
        if (BNX2_CHIP_ID(bp) == BNX2_CHIP_ID_5706_A0) {
                bp->tx_quick_cons_trip_int =
                        bp->tx_quick_cons_trip;
@@ -8609,46 +8583,52 @@ bnx2_remove_one(struct pci_dev *pdev)
 }
 
 static int
-bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
+bnx2_suspend(struct device *device)
 {
+       struct pci_dev *pdev = to_pci_dev(device);
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnx2 *bp = netdev_priv(dev);
 
-       /* PCI register 4 needs to be saved whether netif_running() or not.
-        * MSI address and data need to be saved if using MSI and
-        * netif_running().
-        */
-       pci_save_state(pdev);
-       if (!netif_running(dev))
-               return 0;
-
-       cancel_work_sync(&bp->reset_task);
-       bnx2_netif_stop(bp, true);
-       netif_device_detach(dev);
-       del_timer_sync(&bp->timer);
-       bnx2_shutdown_chip(bp);
-       bnx2_free_skbs(bp);
-       bnx2_set_power_state(bp, pci_choose_state(pdev, state));
+       if (netif_running(dev)) {
+               cancel_work_sync(&bp->reset_task);
+               bnx2_netif_stop(bp, true);
+               netif_device_detach(dev);
+               del_timer_sync(&bp->timer);
+               bnx2_shutdown_chip(bp);
+               __bnx2_free_irq(bp);
+               bnx2_free_skbs(bp);
+       }
+       bnx2_setup_wol(bp);
        return 0;
 }
 
 static int
-bnx2_resume(struct pci_dev *pdev)
+bnx2_resume(struct device *device)
 {
+       struct pci_dev *pdev = to_pci_dev(device);
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnx2 *bp = netdev_priv(dev);
 
-       pci_restore_state(pdev);
        if (!netif_running(dev))
                return 0;
 
        bnx2_set_power_state(bp, PCI_D0);
        netif_device_attach(dev);
+       bnx2_request_irq(bp);
        bnx2_init_nic(bp, 1);
        bnx2_netif_start(bp, true);
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static SIMPLE_DEV_PM_OPS(bnx2_pm_ops, bnx2_suspend, bnx2_resume);
+#define BNX2_PM_OPS (&bnx2_pm_ops)
+
+#else
+
+#define BNX2_PM_OPS NULL
+
+#endif /* CONFIG_PM_SLEEP */
 /**
  * bnx2_io_error_detected - called when PCI error is detected
  * @pdev: Pointer to PCI device
@@ -8694,24 +8674,28 @@ static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnx2 *bp = netdev_priv(dev);
-       pci_ers_result_t result;
-       int err;
+       pci_ers_result_t result = PCI_ERS_RESULT_DISCONNECT;
+       int err = 0;
 
        rtnl_lock();
        if (pci_enable_device(pdev)) {
                dev_err(&pdev->dev,
                        "Cannot re-enable PCI device after reset\n");
-               result = PCI_ERS_RESULT_DISCONNECT;
        } else {
                pci_set_master(pdev);
                pci_restore_state(pdev);
                pci_save_state(pdev);
 
-               if (netif_running(dev)) {
-                       bnx2_set_power_state(bp, PCI_D0);
-                       bnx2_init_nic(bp, 1);
-               }
-               result = PCI_ERS_RESULT_RECOVERED;
+               if (netif_running(dev))
+                       err = bnx2_init_nic(bp, 1);
+
+               if (!err)
+                       result = PCI_ERS_RESULT_RECOVERED;
+       }
+
+       if (result != PCI_ERS_RESULT_RECOVERED && netif_running(dev)) {
+               bnx2_napi_enable(bp);
+               dev_close(dev);
        }
        rtnl_unlock();
 
@@ -8748,6 +8732,28 @@ static void bnx2_io_resume(struct pci_dev *pdev)
        rtnl_unlock();
 }
 
+static void bnx2_shutdown(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct bnx2 *bp;
+
+       if (!dev)
+               return;
+
+       bp = netdev_priv(dev);
+       if (!bp)
+               return;
+
+       rtnl_lock();
+       if (netif_running(dev))
+               dev_close(bp->dev);
+
+       if (system_state == SYSTEM_POWER_OFF)
+               bnx2_set_power_state(bp, PCI_D3hot);
+
+       rtnl_unlock();
+}
+
 static const struct pci_error_handlers bnx2_err_handler = {
        .error_detected = bnx2_io_error_detected,
        .slot_reset     = bnx2_io_slot_reset,
@@ -8759,9 +8765,9 @@ static struct pci_driver bnx2_pci_driver = {
        .id_table       = bnx2_pci_tbl,
        .probe          = bnx2_init_one,
        .remove         = bnx2_remove_one,
-       .suspend        = bnx2_suspend,
-       .resume         = bnx2_resume,
+       .driver.pm      = BNX2_PM_OPS,
        .err_handler    = &bnx2_err_handler,
+       .shutdown       = bnx2_shutdown,
 };
 
 module_pci_driver(bnx2_pci_driver);
index 172efbecfea2b502c26cf8043770575b229743d4..18cb2d23e56b344db90f8c7cef007f02f256f64e 100644 (file)
@@ -1,6 +1,6 @@
 /* bnx2.h: Broadcom NX2 network driver.
  *
- * Copyright (c) 2004-2011 Broadcom Corporation
+ * Copyright (c) 2004-2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index dedbd76c033ede4d695e3c7498f99ff263ca860b..12202f81735cc944a7072f6d50a74580fce04eed 100644 (file)
@@ -486,7 +486,7 @@ struct bnx2x_fastpath {
 
        struct napi_struct      napi;
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        unsigned int state;
 #define BNX2X_FP_STATE_IDLE                  0
 #define BNX2X_FP_STATE_NAPI            (1 << 0)    /* NAPI owns this FP */
@@ -498,7 +498,7 @@ struct bnx2x_fastpath {
 #define BNX2X_FP_USER_PEND (BNX2X_FP_STATE_POLL | BNX2X_FP_STATE_POLL_YIELD)
        /* protect state */
        spinlock_t lock;
-#endif /* CONFIG_NET_LL_RX_POLL */
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 
        union host_hc_status_block      status_blk;
        /* chip independent shortcuts into sb structure */
@@ -572,7 +572,7 @@ struct bnx2x_fastpath {
 #define bnx2x_fp_stats(bp, fp) (&((bp)->fp_stats[(fp)->index]))
 #define bnx2x_fp_qstats(bp, fp)        (&((bp)->fp_stats[(fp)->index].eth_q_stats))
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 static inline void bnx2x_fp_init_lock(struct bnx2x_fastpath *fp)
 {
        spin_lock_init(&fp->lock);
@@ -680,7 +680,7 @@ static inline bool bnx2x_fp_ll_polling(struct bnx2x_fastpath *fp)
 {
        return false;
 }
-#endif /* CONFIG_NET_LL_RX_POLL */
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 
 /* Use 2500 as a mini-jumbo MTU for FCoE */
 #define BNX2X_FCOE_MINI_JUMBO_MTU      2500
@@ -1331,8 +1331,10 @@ enum {
        BNX2X_SP_RTNL_ENABLE_SRIOV,
        BNX2X_SP_RTNL_VFPF_MCAST,
        BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
-       BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
+       BNX2X_SP_RTNL_RX_MODE,
        BNX2X_SP_RTNL_HYPERVISOR_VLAN,
+       BNX2X_SP_RTNL_TX_STOP,
+       BNX2X_SP_RTNL_TX_RESUME,
 };
 
 struct bnx2x_prev_path_list {
@@ -1502,6 +1504,7 @@ struct bnx2x {
 #define BC_SUPPORTS_DCBX_MSG_NON_PMF   (1 << 21)
 #define IS_VF_FLAG                     (1 << 22)
 #define INTERRUPTS_ENABLED_FLAG                (1 << 23)
+#define BC_SUPPORTS_RMMOD_CMD          (1 << 24)
 
 #define BP_NOMCP(bp)                   ((bp)->flags & NO_MCP_FLAG)
 
@@ -1830,6 +1833,8 @@ struct bnx2x {
 
        int fp_array_size;
        u32 dump_preset_idx;
+       bool                                    stats_started;
+       struct semaphore                        stats_sema;
 };
 
 /* Tx queues may be less or equal to Rx queues */
@@ -2451,4 +2456,6 @@ enum bnx2x_pci_bus_speed {
        BNX2X_PCI_LINK_SPEED_5000 = 5000,
        BNX2X_PCI_LINK_SPEED_8000 = 8000
 };
+
+void bnx2x_set_local_cmng(struct bnx2x *bp);
 #endif /* bnx2x.h */
index ee350bde1818cc38c4a20a0db70a466bf158ee2e..2e90868a9276edad8c754494f32d714ee1bc0620 100644 (file)
@@ -2060,7 +2060,11 @@ void bnx2x_squeeze_objects(struct bnx2x *bp)
        rparam.mcast_obj = &bp->mcast_obj;
        __set_bit(RAMROD_DRV_CLR_ONLY, &rparam.ramrod_flags);
 
-       /* Add a DEL command... */
+       /* Add a DEL command... - Since we're doing a driver cleanup only,
+        * we take a lock surrounding both the initial send and the CONTs,
+        * as we don't want a true completion to disrupt us in the middle.
+        */
+       netif_addr_lock_bh(bp->dev);
        rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_DEL);
        if (rc < 0)
                BNX2X_ERR("Failed to add a new DEL command to a multi-cast object: %d\n",
@@ -2072,11 +2076,13 @@ void bnx2x_squeeze_objects(struct bnx2x *bp)
                if (rc < 0) {
                        BNX2X_ERR("Failed to clean multi-cast object: %d\n",
                                  rc);
+                       netif_addr_unlock_bh(bp->dev);
                        return;
                }
 
                rc = bnx2x_config_mcast(bp, &rparam, BNX2X_MCAST_CMD_CONT);
        }
+       netif_addr_unlock_bh(bp->dev);
 }
 
 #ifndef BNX2X_STOP_ON_ERROR
@@ -2432,9 +2438,7 @@ int bnx2x_load_cnic(struct bnx2x *bp)
        }
 
        /* Initialize Rx filter. */
-       netif_addr_lock_bh(bp->dev);
-       bnx2x_set_rx_mode(bp->dev);
-       netif_addr_unlock_bh(bp->dev);
+       bnx2x_set_rx_mode_inner(bp);
 
        /* re-read iscsi info */
        bnx2x_get_iscsi_info(bp);
@@ -2704,9 +2708,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
        /* Start fast path */
 
        /* Initialize Rx filter. */
-       netif_addr_lock_bh(bp->dev);
-       bnx2x_set_rx_mode(bp->dev);
-       netif_addr_unlock_bh(bp->dev);
+       bnx2x_set_rx_mode_inner(bp);
 
        /* Start the Tx */
        switch (load_mode) {
@@ -3117,7 +3119,7 @@ int bnx2x_poll(struct napi_struct *napi, int budget)
        return work_done;
 }
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 /* must be called with local_bh_disable()d */
 int bnx2x_low_latency_recv(struct napi_struct *napi)
 {
index c07a6d054cfe970b031582400ef71212bd45780c..38be494ffa6eb65f6013127832c87d3b07491323 100644 (file)
@@ -418,6 +418,7 @@ int bnx2x_set_eth_mac(struct bnx2x *bp, bool set);
  * netif_addr_lock_bh()
  */
 void bnx2x_set_rx_mode(struct net_device *dev);
+void bnx2x_set_rx_mode_inner(struct bnx2x *bp);
 
 /**
  * bnx2x_set_storm_rx_mode - configure MAC filtering rules in a FW.
index 0c94df47e0e8ee46d273488413be3d56d9c29ef6..fcf2761d8828804d3edf7ca8e2ad245576d23685 100644 (file)
 #include "bnx2x_dcb.h"
 
 /* forward declarations of dcbx related functions */
-static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
 static void bnx2x_pfc_set_pfc(struct bnx2x *bp);
 static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp);
-static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);
 static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp,
                                          u32 *set_configuration_ets_pg,
                                          u32 *pri_pg_tbl);
@@ -425,30 +423,52 @@ static void bnx2x_pfc_set_pfc(struct bnx2x *bp)
                bnx2x_pfc_clear(bp);
 }
 
-static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp)
+int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp)
 {
        struct bnx2x_func_state_params func_params = {NULL};
+       int rc;
 
        func_params.f_obj = &bp->func_obj;
        func_params.cmd = BNX2X_F_CMD_TX_STOP;
 
+       __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+       __set_bit(RAMROD_RETRY, &func_params.ramrod_flags);
+
        DP(BNX2X_MSG_DCB, "STOP TRAFFIC\n");
-       return bnx2x_func_state_change(bp, &func_params);
+
+       rc = bnx2x_func_state_change(bp, &func_params);
+       if (rc) {
+               BNX2X_ERR("Unable to hold traffic for HW configuration\n");
+               bnx2x_panic();
+       }
+
+       return rc;
 }
 
-static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp)
+int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp)
 {
        struct bnx2x_func_state_params func_params = {NULL};
        struct bnx2x_func_tx_start_params *tx_params =
                &func_params.params.tx_start;
+       int rc;
 
        func_params.f_obj = &bp->func_obj;
        func_params.cmd = BNX2X_F_CMD_TX_START;
 
+       __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
+       __set_bit(RAMROD_RETRY, &func_params.ramrod_flags);
+
        bnx2x_dcbx_fw_struct(bp, tx_params);
 
        DP(BNX2X_MSG_DCB, "START TRAFFIC\n");
-       return bnx2x_func_state_change(bp, &func_params);
+
+       rc = bnx2x_func_state_change(bp, &func_params);
+       if (rc) {
+               BNX2X_ERR("Unable to resume traffic after HW configuration\n");
+               bnx2x_panic();
+       }
+
+       return rc;
 }
 
 static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x *bp)
@@ -744,7 +764,9 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
                        if (IS_MF(bp))
                                bnx2x_link_sync_notify(bp);
 
-                       bnx2x_dcbx_stop_hw_tx(bp);
+                       set_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state);
+
+                       schedule_delayed_work(&bp->sp_rtnl_task, 0);
 
                        return;
                }
@@ -753,7 +775,13 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
                bnx2x_pfc_set_pfc(bp);
 
                bnx2x_dcbx_update_ets_params(bp);
-               bnx2x_dcbx_resume_hw_tx(bp);
+
+               /* ets may affect cmng configuration: reinit it in hw */
+               bnx2x_set_local_cmng(bp);
+
+               set_bit(BNX2X_SP_RTNL_TX_RESUME, &bp->sp_rtnl_state);
+
+               schedule_delayed_work(&bp->sp_rtnl_task, 0);
 
                return;
        case BNX2X_DCBX_STATE_TX_RELEASED:
@@ -2363,21 +2391,24 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
                case DCB_FEATCFG_ATTR_PG:
                        if (bp->dcbx_local_feat.ets.enabled)
                                *flags |= DCB_FEATCFG_ENABLE;
-                       if (bp->dcbx_error & DCBX_LOCAL_ETS_ERROR)
+                       if (bp->dcbx_error & (DCBX_LOCAL_ETS_ERROR |
+                                             DCBX_REMOTE_MIB_ERROR))
                                *flags |= DCB_FEATCFG_ERROR;
                        break;
                case DCB_FEATCFG_ATTR_PFC:
                        if (bp->dcbx_local_feat.pfc.enabled)
                                *flags |= DCB_FEATCFG_ENABLE;
                        if (bp->dcbx_error & (DCBX_LOCAL_PFC_ERROR |
-                           DCBX_LOCAL_PFC_MISMATCH))
+                                             DCBX_LOCAL_PFC_MISMATCH |
+                                             DCBX_REMOTE_MIB_ERROR))
                                *flags |= DCB_FEATCFG_ERROR;
                        break;
                case DCB_FEATCFG_ATTR_APP:
                        if (bp->dcbx_local_feat.app.enabled)
                                *flags |= DCB_FEATCFG_ENABLE;
                        if (bp->dcbx_error & (DCBX_LOCAL_APP_ERROR |
-                           DCBX_LOCAL_APP_MISMATCH))
+                                             DCBX_LOCAL_APP_MISMATCH |
+                                             DCBX_REMOTE_MIB_ERROR))
                                *flags |= DCB_FEATCFG_ERROR;
                        break;
                default:
index 125bd1b6586ffc1f96b5fc946a4ee5a4613ce5a4..804b8f64463e80a1fcb45f51bda976b4d8544062 100644 (file)
@@ -199,4 +199,7 @@ extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops;
 int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall);
 #endif /* BCM_DCBNL */
 
+int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
+int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);
+
 #endif /* BNX2X_DCB_H */
index 5018e52ae2ad8fac5a194b0f137b66d5b8aaf0b4..32767f6aa33f473a126259e4877fa608ed51b3bf 100644 (file)
@@ -1300,6 +1300,9 @@ struct drv_func_mb {
 
        #define DRV_MSG_CODE_EEE_RESULTS_ACK            0xda000000
 
+       #define DRV_MSG_CODE_RMMOD                      0xdb000000
+       #define REQ_BC_VER_4_RMMOD_CMD                  0x0007080f
+
        #define DRV_MSG_CODE_SET_MF_BW                  0xe0000000
        #define REQ_BC_VER_4_SET_MF_BW                  0x00060202
        #define DRV_MSG_CODE_SET_MF_BW_ACK              0xe1000000
@@ -1372,6 +1375,8 @@ struct drv_func_mb {
 
        #define FW_MSG_CODE_EEE_RESULS_ACK              0xda100000
 
+       #define FW_MSG_CODE_RMMOD_ACK                   0xdb100000
+
        #define FW_MSG_CODE_SET_MF_BW_SENT              0xe0000000
        #define FW_MSG_CODE_SET_MF_BW_DONE              0xe1000000
 
index e5da07858a2f0d5dca0747e1b7fe58992b799d5e..17f117c1d8d2588f888b0832b126e9f2de4e3cae 100644 (file)
@@ -2261,6 +2261,23 @@ static void bnx2x_set_requested_fc(struct bnx2x *bp)
                bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH;
 }
 
+static void bnx2x_init_dropless_fc(struct bnx2x *bp)
+{
+       u32 pause_enabled = 0;
+
+       if (!CHIP_IS_E1(bp) && bp->dropless_fc && bp->link_vars.link_up) {
+               if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX)
+                       pause_enabled = 1;
+
+               REG_WR(bp, BAR_USTRORM_INTMEM +
+                          USTORM_ETH_PAUSE_ENABLED_OFFSET(BP_PORT(bp)),
+                      pause_enabled);
+       }
+
+       DP(NETIF_MSG_IFUP | NETIF_MSG_LINK, "dropless_fc is %s\n",
+          pause_enabled ? "enabled" : "disabled");
+}
+
 int bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode)
 {
        int rc, cfx_idx = bnx2x_get_link_cfg_idx(bp);
@@ -2294,6 +2311,8 @@ int bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode)
 
                bnx2x_release_phy_lock(bp);
 
+               bnx2x_init_dropless_fc(bp);
+
                bnx2x_calc_fc_adv(bp);
 
                if (bp->link_vars.link_up) {
@@ -2315,6 +2334,8 @@ void bnx2x_link_set(struct bnx2x *bp)
                bnx2x_phy_init(&bp->link_params, &bp->link_vars);
                bnx2x_release_phy_lock(bp);
 
+               bnx2x_init_dropless_fc(bp);
+
                bnx2x_calc_fc_adv(bp);
        } else
                BNX2X_ERR("Bootcode is missing - can not set link\n");
@@ -2476,7 +2497,7 @@ static void bnx2x_cmng_fns_init(struct bnx2x *bp, u8 read_cfg, u8 cmng_type)
 
        input.port_rate = bp->link_vars.line_speed;
 
-       if (cmng_type == CMNG_FNS_MINMAX) {
+       if (cmng_type == CMNG_FNS_MINMAX && input.port_rate) {
                int vn;
 
                /* read mf conf from shmem */
@@ -2533,6 +2554,21 @@ static void storm_memset_cmng(struct bnx2x *bp,
        }
 }
 
+/* init cmng mode in HW according to local configuration */
+void bnx2x_set_local_cmng(struct bnx2x *bp)
+{
+       int cmng_fns = bnx2x_get_cmng_fns_mode(bp);
+
+       if (cmng_fns != CMNG_FNS_NONE) {
+               bnx2x_cmng_fns_init(bp, false, cmng_fns);
+               storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp));
+       } else {
+               /* rate shaping and fairness are disabled */
+               DP(NETIF_MSG_IFUP,
+                  "single function mode without fairness\n");
+       }
+}
+
 /* This function is called upon link interrupt */
 static void bnx2x_link_attn(struct bnx2x *bp)
 {
@@ -2541,20 +2577,9 @@ static void bnx2x_link_attn(struct bnx2x *bp)
 
        bnx2x_link_update(&bp->link_params, &bp->link_vars);
 
-       if (bp->link_vars.link_up) {
-
-               /* dropless flow control */
-               if (!CHIP_IS_E1(bp) && bp->dropless_fc) {
-                       int port = BP_PORT(bp);
-                       u32 pause_enabled = 0;
-
-                       if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX)
-                               pause_enabled = 1;
+       bnx2x_init_dropless_fc(bp);
 
-                       REG_WR(bp, BAR_USTRORM_INTMEM +
-                              USTORM_ETH_PAUSE_ENABLED_OFFSET(port),
-                              pause_enabled);
-               }
+       if (bp->link_vars.link_up) {
 
                if (bp->link_vars.mac_type != MAC_TYPE_EMAC) {
                        struct host_port_stats *pstats;
@@ -2568,17 +2593,8 @@ static void bnx2x_link_attn(struct bnx2x *bp)
                        bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP);
        }
 
-       if (bp->link_vars.link_up && bp->link_vars.line_speed) {
-               int cmng_fns = bnx2x_get_cmng_fns_mode(bp);
-
-               if (cmng_fns != CMNG_FNS_NONE) {
-                       bnx2x_cmng_fns_init(bp, false, cmng_fns);
-                       storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp));
-               } else
-                       /* rate shaping and fairness are disabled */
-                       DP(NETIF_MSG_IFUP,
-                          "single function mode without fairness\n");
-       }
+       if (bp->link_vars.link_up && bp->link_vars.line_speed)
+               bnx2x_set_local_cmng(bp);
 
        __bnx2x_link_report(bp);
 
@@ -9628,17 +9644,21 @@ sp_rtnl_not_reset:
                }
        }
 
-       if (test_and_clear_bit(BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
-                              &bp->sp_rtnl_state)) {
-               DP(BNX2X_MSG_SP,
-                  "sending set storm rx mode vf pf channel message from rtnl sp-task\n");
-               bnx2x_vfpf_storm_rx_mode(bp);
+       if (test_and_clear_bit(BNX2X_SP_RTNL_RX_MODE, &bp->sp_rtnl_state)) {
+               DP(BNX2X_MSG_SP, "Handling Rx Mode setting\n");
+               bnx2x_set_rx_mode_inner(bp);
        }
 
        if (test_and_clear_bit(BNX2X_SP_RTNL_HYPERVISOR_VLAN,
                               &bp->sp_rtnl_state))
                bnx2x_pf_set_vfs_vlan(bp);
 
+       if (test_and_clear_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state))
+               bnx2x_dcbx_stop_hw_tx(bp);
+
+       if (test_and_clear_bit(BNX2X_SP_RTNL_TX_RESUME, &bp->sp_rtnl_state))
+               bnx2x_dcbx_resume_hw_tx(bp);
+
        /* work which needs rtnl lock not-taken (as it takes the lock itself and
         * can be called from other contexts as well)
         */
@@ -10362,6 +10382,10 @@ static void bnx2x_get_common_hwinfo(struct bnx2x *bp)
 
        bp->flags |= (val >= REQ_BC_VER_4_DCBX_ADMIN_MSG_NON_PMF) ?
                        BC_SUPPORTS_DCBX_MSG_NON_PMF : 0;
+
+       bp->flags |= (val >= REQ_BC_VER_4_RMMOD_CMD) ?
+                       BC_SUPPORTS_RMMOD_CMD : 0;
+
        boot_mode = SHMEM_RD(bp,
                        dev_info.port_feature_config[BP_PORT(bp)].mba_config) &
                        PORT_FEATURE_MBA_BOOT_AGENT_TYPE_MASK;
@@ -11137,6 +11161,9 @@ static bool bnx2x_get_dropless_info(struct bnx2x *bp)
        int tmp;
        u32 cfg;
 
+       if (IS_VF(bp))
+               return 0;
+
        if (IS_MF(bp) && !CHIP_IS_E1x(bp)) {
                /* Take function: tmp = func */
                tmp = BP_ABS_FUNC(bp);
@@ -11524,6 +11551,7 @@ static int bnx2x_init_bp(struct bnx2x *bp)
        mutex_init(&bp->port.phy_mutex);
        mutex_init(&bp->fw_mb_mutex);
        spin_lock_init(&bp->stats_lock);
+       sema_init(&bp->stats_sema, 1);
 
        INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
        INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task);
@@ -11849,34 +11877,48 @@ static int bnx2x_set_mc_list(struct bnx2x *bp)
 void bnx2x_set_rx_mode(struct net_device *dev)
 {
        struct bnx2x *bp = netdev_priv(dev);
-       u32 rx_mode = BNX2X_RX_MODE_NORMAL;
 
        if (bp->state != BNX2X_STATE_OPEN) {
                DP(NETIF_MSG_IFUP, "state is %x, returning\n", bp->state);
                return;
+       } else {
+               /* Schedule an SP task to handle rest of change */
+               DP(NETIF_MSG_IFUP, "Scheduling an Rx mode change\n");
+               smp_mb__before_clear_bit();
+               set_bit(BNX2X_SP_RTNL_RX_MODE, &bp->sp_rtnl_state);
+               smp_mb__after_clear_bit();
+               schedule_delayed_work(&bp->sp_rtnl_task, 0);
        }
+}
+
+void bnx2x_set_rx_mode_inner(struct bnx2x *bp)
+{
+       u32 rx_mode = BNX2X_RX_MODE_NORMAL;
 
        DP(NETIF_MSG_IFUP, "dev->flags = %x\n", bp->dev->flags);
 
-       if (dev->flags & IFF_PROMISC)
+       netif_addr_lock_bh(bp->dev);
+
+       if (bp->dev->flags & IFF_PROMISC) {
                rx_mode = BNX2X_RX_MODE_PROMISC;
-       else if ((dev->flags & IFF_ALLMULTI) ||
-                ((netdev_mc_count(dev) > BNX2X_MAX_MULTICAST) &&
-                 CHIP_IS_E1(bp)))
+       } else if ((bp->dev->flags & IFF_ALLMULTI) ||
+                  ((netdev_mc_count(bp->dev) > BNX2X_MAX_MULTICAST) &&
+                   CHIP_IS_E1(bp))) {
                rx_mode = BNX2X_RX_MODE_ALLMULTI;
-       else {
+       else {
                if (IS_PF(bp)) {
                        /* some multicasts */
                        if (bnx2x_set_mc_list(bp) < 0)
                                rx_mode = BNX2X_RX_MODE_ALLMULTI;
 
+                       /* release bh lock, as bnx2x_set_uc_list might sleep */
+                       netif_addr_unlock_bh(bp->dev);
                        if (bnx2x_set_uc_list(bp) < 0)
                                rx_mode = BNX2X_RX_MODE_PROMISC;
+                       netif_addr_lock_bh(bp->dev);
                } else {
                        /* configuring mcast to a vf involves sleeping (when we
-                        * wait for the pf's response). Since this function is
-                        * called from non sleepable context we must schedule
-                        * a work item for this purpose
+                        * wait for the pf's response).
                         */
                        smp_mb__before_clear_bit();
                        set_bit(BNX2X_SP_RTNL_VFPF_MCAST,
@@ -11894,22 +11936,20 @@ void bnx2x_set_rx_mode(struct net_device *dev)
        /* Schedule the rx_mode command */
        if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state)) {
                set_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state);
+               netif_addr_unlock_bh(bp->dev);
                return;
        }
 
        if (IS_PF(bp)) {
                bnx2x_set_storm_rx_mode(bp);
+               netif_addr_unlock_bh(bp->dev);
        } else {
-               /* configuring rx mode to storms in a vf involves sleeping (when
-                * we wait for the pf's response). Since this function is
-                * called from non sleepable context we must schedule
-                * a work item for this purpose
+               /* VF will need to request the PF to make this change, and so
+                * the VF needs to release the bottom-half lock prior to the
+                * request (as it will likely require sleep on the VF side)
                 */
-               smp_mb__before_clear_bit();
-               set_bit(BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
-                       &bp->sp_rtnl_state);
-               smp_mb__after_clear_bit();
-               schedule_delayed_work(&bp->sp_rtnl_task, 0);
+               netif_addr_unlock_bh(bp->dev);
+               bnx2x_vfpf_storm_rx_mode(bp);
        }
 }
 
@@ -12026,7 +12066,7 @@ static const struct net_device_ops bnx2x_netdev_ops = {
        .ndo_fcoe_get_wwn       = bnx2x_fcoe_get_wwn,
 #endif
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        .ndo_busy_poll          = bnx2x_low_latency_recv,
 #endif
 };
@@ -12534,16 +12574,14 @@ static int bnx2x_set_qm_cid_count(struct bnx2x *bp)
 static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev,
                                     int cnic_cnt, bool is_vf)
 {
-       int pos, index;
+       int index;
        u16 control = 0;
 
-       pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-
        /*
         * If MSI-X is not supported - return number of SBs needed to support
         * one fast path queue: one FP queue + SB for CNIC
         */
-       if (!pos) {
+       if (!pdev->msix_cap) {
                dev_info(&pdev->dev, "no msix capability found\n");
                return 1 + cnic_cnt;
        }
@@ -12556,7 +12594,7 @@ static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev,
         * without the default SB.
         * For VFs there is no default SB, then we return (index+1).
         */
-       pci_read_config_word(pdev, pos  + PCI_MSI_FLAGS, &control);
+       pci_read_config_word(pdev, pdev->msix_cap + PCI_MSI_FLAGS, &control);
 
        index = control & PCI_MSIX_FLAGS_QSIZE;
 
@@ -12817,13 +12855,17 @@ static void __bnx2x_remove(struct pci_dev *pdev,
        bnx2x_dcbnl_update_applist(bp, true);
 #endif
 
+       if (IS_PF(bp) &&
+           !BP_NOMCP(bp) &&
+           (bp->flags & BC_SUPPORTS_RMMOD_CMD))
+               bnx2x_fw_command(bp, DRV_MSG_CODE_RMMOD, 0);
+
        /* Close the interface - either directly or implicitly */
        if (remove_netdev) {
                unregister_netdev(dev);
        } else {
                rtnl_lock();
-               if (netif_running(dev))
-                       bnx2x_close(dev);
+               dev_close(dev);
                rtnl_unlock();
        }
 
index 8f03c984550f328c88764d83f04813b344445b1d..1d46b68fb7664d69ca0e26b66d6340d9d18cb233 100644 (file)
@@ -159,16 +159,6 @@ static inline void __bnx2x_exe_queue_reset_pending(
        }
 }
 
-static inline void bnx2x_exe_queue_reset_pending(struct bnx2x *bp,
-                                                struct bnx2x_exe_queue_obj *o)
-{
-       spin_lock_bh(&o->lock);
-
-       __bnx2x_exe_queue_reset_pending(bp, o);
-
-       spin_unlock_bh(&o->lock);
-}
-
 /**
  * bnx2x_exe_queue_step - execute one execution chunk atomically
  *
@@ -176,7 +166,7 @@ static inline void bnx2x_exe_queue_reset_pending(struct bnx2x *bp,
  * @o:                 queue
  * @ramrod_flags:      flags
  *
- * (Atomicity is ensured using the exe_queue->lock).
+ * (Should be called while holding the exe_queue->lock).
  */
 static inline int bnx2x_exe_queue_step(struct bnx2x *bp,
                                       struct bnx2x_exe_queue_obj *o,
@@ -187,8 +177,6 @@ static inline int bnx2x_exe_queue_step(struct bnx2x *bp,
 
        memset(&spacer, 0, sizeof(spacer));
 
-       spin_lock_bh(&o->lock);
-
        /* Next step should not be performed until the current is finished,
         * unless a DRV_CLEAR_ONLY bit is set. In this case we just want to
         * properly clear object internals without sending any command to the FW
@@ -200,7 +188,6 @@ static inline int bnx2x_exe_queue_step(struct bnx2x *bp,
                        DP(BNX2X_MSG_SP, "RAMROD_DRV_CLR_ONLY requested: resetting a pending_comp list\n");
                        __bnx2x_exe_queue_reset_pending(bp, o);
                } else {
-                       spin_unlock_bh(&o->lock);
                        return 1;
                }
        }
@@ -228,10 +215,8 @@ static inline int bnx2x_exe_queue_step(struct bnx2x *bp,
        }
 
        /* Sanity check */
-       if (!cur_len) {
-               spin_unlock_bh(&o->lock);
+       if (!cur_len)
                return 0;
-       }
 
        rc = o->execute(bp, o->owner, &o->pending_comp, ramrod_flags);
        if (rc < 0)
@@ -245,7 +230,6 @@ static inline int bnx2x_exe_queue_step(struct bnx2x *bp,
                 */
                __bnx2x_exe_queue_reset_pending(bp, o);
 
-       spin_unlock_bh(&o->lock);
        return rc;
 }
 
@@ -432,12 +416,219 @@ static bool bnx2x_put_credit_vlan_mac(struct bnx2x_vlan_mac_obj *o)
        return true;
 }
 
+/**
+ * __bnx2x_vlan_mac_h_write_trylock - try getting the vlan mac writer lock
+ *
+ * @bp:                device handle
+ * @o:         vlan_mac object
+ *
+ * @details: Non-blocking implementation; should be called under execution
+ *           queue lock.
+ */
+static int __bnx2x_vlan_mac_h_write_trylock(struct bnx2x *bp,
+                                           struct bnx2x_vlan_mac_obj *o)
+{
+       if (o->head_reader) {
+               DP(BNX2X_MSG_SP, "vlan_mac_lock writer - There are readers; Busy\n");
+               return -EBUSY;
+       }
+
+       DP(BNX2X_MSG_SP, "vlan_mac_lock writer - Taken\n");
+       return 0;
+}
+
+/**
+ * __bnx2x_vlan_mac_h_exec_pending - execute step instead of a previous step
+ *
+ * @bp:                device handle
+ * @o:         vlan_mac object
+ *
+ * @details Should be called under execution queue lock; notice it might release
+ *          and reclaim it during its run.
+ */
+static void __bnx2x_vlan_mac_h_exec_pending(struct bnx2x *bp,
+                                           struct bnx2x_vlan_mac_obj *o)
+{
+       int rc;
+       unsigned long ramrod_flags = o->saved_ramrod_flags;
+
+       DP(BNX2X_MSG_SP, "vlan_mac_lock execute pending command with ramrod flags %lu\n",
+          ramrod_flags);
+       o->head_exe_request = false;
+       o->saved_ramrod_flags = 0;
+       rc = bnx2x_exe_queue_step(bp, &o->exe_queue, &ramrod_flags);
+       if (rc != 0) {
+               BNX2X_ERR("execution of pending commands failed with rc %d\n",
+                         rc);
+#ifdef BNX2X_STOP_ON_ERROR
+               bnx2x_panic();
+#endif
+       }
+}
+
+/**
+ * __bnx2x_vlan_mac_h_pend - Pend an execution step which couldn't run
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ * @ramrod_flags:      ramrod flags of missed execution
+ *
+ * @details Should be called under execution queue lock.
+ */
+static void __bnx2x_vlan_mac_h_pend(struct bnx2x *bp,
+                                   struct bnx2x_vlan_mac_obj *o,
+                                   unsigned long ramrod_flags)
+{
+       o->head_exe_request = true;
+       o->saved_ramrod_flags = ramrod_flags;
+       DP(BNX2X_MSG_SP, "Placing pending execution with ramrod flags %lu\n",
+          ramrod_flags);
+}
+
+/**
+ * __bnx2x_vlan_mac_h_write_unlock - unlock the vlan mac head list writer lock
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ *
+ * @details Should be called under execution queue lock. Notice if a pending
+ *          execution exists, it would perform it - possibly releasing and
+ *          reclaiming the execution queue lock.
+ */
+static void __bnx2x_vlan_mac_h_write_unlock(struct bnx2x *bp,
+                                           struct bnx2x_vlan_mac_obj *o)
+{
+       /* It's possible a new pending execution was added since this writer
+        * executed. If so, execute again. [Ad infinitum]
+        */
+       while (o->head_exe_request) {
+               DP(BNX2X_MSG_SP, "vlan_mac_lock - writer release encountered a pending request\n");
+               __bnx2x_vlan_mac_h_exec_pending(bp, o);
+       }
+}
+
+/**
+ * bnx2x_vlan_mac_h_write_unlock - unlock the vlan mac head list writer lock
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ *
+ * @details Notice if a pending execution exists, it would perform it -
+ *          possibly releasing and reclaiming the execution queue lock.
+ */
+void bnx2x_vlan_mac_h_write_unlock(struct bnx2x *bp,
+                                  struct bnx2x_vlan_mac_obj *o)
+{
+       spin_lock_bh(&o->exe_queue.lock);
+       __bnx2x_vlan_mac_h_write_unlock(bp, o);
+       spin_unlock_bh(&o->exe_queue.lock);
+}
+
+/**
+ * __bnx2x_vlan_mac_h_read_lock - lock the vlan mac head list reader lock
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ *
+ * @details Should be called under the execution queue lock. May sleep. May
+ *          release and reclaim execution queue lock during its run.
+ */
+static int __bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp,
+                                       struct bnx2x_vlan_mac_obj *o)
+{
+       /* If we got here, we're holding lock --> no WRITER exists */
+       o->head_reader++;
+       DP(BNX2X_MSG_SP, "vlan_mac_lock - locked reader - number %d\n",
+          o->head_reader);
+
+       return 0;
+}
+
+/**
+ * bnx2x_vlan_mac_h_read_lock - lock the vlan mac head list reader lock
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ *
+ * @details May sleep. Claims and releases execution queue lock during its run.
+ */
+int bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp,
+                              struct bnx2x_vlan_mac_obj *o)
+{
+       int rc;
+
+       spin_lock_bh(&o->exe_queue.lock);
+       rc = __bnx2x_vlan_mac_h_read_lock(bp, o);
+       spin_unlock_bh(&o->exe_queue.lock);
+
+       return rc;
+}
+
+/**
+ * __bnx2x_vlan_mac_h_read_unlock - unlock the vlan mac head list reader lock
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ *
+ * @details Should be called under execution queue lock. Notice if a pending
+ *          execution exists, it would be performed if this was the last
+ *          reader. possibly releasing and reclaiming the execution queue lock.
+ */
+static void __bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp,
+                                         struct bnx2x_vlan_mac_obj *o)
+{
+       if (!o->head_reader) {
+               BNX2X_ERR("Need to release vlan mac reader lock, but lock isn't taken\n");
+#ifdef BNX2X_STOP_ON_ERROR
+               bnx2x_panic();
+#endif
+       } else {
+               o->head_reader--;
+               DP(BNX2X_MSG_SP, "vlan_mac_lock - decreased readers to %d\n",
+                  o->head_reader);
+       }
+
+       /* It's possible a new pending execution was added, and that this reader
+        * was last - if so we need to execute the command.
+        */
+       if (!o->head_reader && o->head_exe_request) {
+               DP(BNX2X_MSG_SP, "vlan_mac_lock - reader release encountered a pending request\n");
+
+               /* Writer release will do the trick */
+               __bnx2x_vlan_mac_h_write_unlock(bp, o);
+       }
+}
+
+/**
+ * bnx2x_vlan_mac_h_read_unlock - unlock the vlan mac head list reader lock
+ *
+ * @bp:                        device handle
+ * @o:                 vlan_mac object
+ *
+ * @details Notice if a pending execution exists, it would be performed if this
+ *          was the last reader. Claims and releases the execution queue lock
+ *          during its run.
+ */
+void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp,
+                                 struct bnx2x_vlan_mac_obj *o)
+{
+       spin_lock_bh(&o->exe_queue.lock);
+       __bnx2x_vlan_mac_h_read_unlock(bp, o);
+       spin_unlock_bh(&o->exe_queue.lock);
+}
+
 static int bnx2x_get_n_elements(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
                                int n, u8 *base, u8 stride, u8 size)
 {
        struct bnx2x_vlan_mac_registry_elem *pos;
        u8 *next = base;
        int counter = 0;
+       int read_lock;
+
+       DP(BNX2X_MSG_SP, "get_n_elements - taking vlan_mac_lock (reader)\n");
+       read_lock = bnx2x_vlan_mac_h_read_lock(bp, o);
+       if (read_lock != 0)
+               BNX2X_ERR("get_n_elements failed to get vlan mac reader lock; Access without lock\n");
 
        /* traverse list */
        list_for_each_entry(pos, &o->head, link) {
@@ -449,6 +640,12 @@ static int bnx2x_get_n_elements(struct bnx2x *bp, struct bnx2x_vlan_mac_obj *o,
                        next += stride + size;
                }
        }
+
+       if (read_lock == 0) {
+               DP(BNX2X_MSG_SP, "get_n_elements - releasing vlan_mac_lock (reader)\n");
+               bnx2x_vlan_mac_h_read_unlock(bp, o);
+       }
+
        return counter * ETH_ALEN;
 }
 
@@ -1397,6 +1594,32 @@ static int bnx2x_wait_vlan_mac(struct bnx2x *bp,
        return -EBUSY;
 }
 
+static int __bnx2x_vlan_mac_execute_step(struct bnx2x *bp,
+                                        struct bnx2x_vlan_mac_obj *o,
+                                        unsigned long *ramrod_flags)
+{
+       int rc = 0;
+
+       spin_lock_bh(&o->exe_queue.lock);
+
+       DP(BNX2X_MSG_SP, "vlan_mac_execute_step - trying to take writer lock\n");
+       rc = __bnx2x_vlan_mac_h_write_trylock(bp, o);
+
+       if (rc != 0) {
+               __bnx2x_vlan_mac_h_pend(bp, o, *ramrod_flags);
+
+               /* Calling function should not diffrentiate between this case
+                * and the case in which there is already a pending ramrod
+                */
+               rc = 1;
+       } else {
+               rc = bnx2x_exe_queue_step(bp, &o->exe_queue, ramrod_flags);
+       }
+       spin_unlock_bh(&o->exe_queue.lock);
+
+       return rc;
+}
+
 /**
  * bnx2x_complete_vlan_mac - complete one VLAN-MAC ramrod
  *
@@ -1414,19 +1637,27 @@ static int bnx2x_complete_vlan_mac(struct bnx2x *bp,
        struct bnx2x_raw_obj *r = &o->raw;
        int rc;
 
+       /* Clearing the pending list & raw state should be made
+        * atomically (as execution flow assumes they represent the same).
+        */
+       spin_lock_bh(&o->exe_queue.lock);
+
        /* Reset pending list */
-       bnx2x_exe_queue_reset_pending(bp, &o->exe_queue);
+       __bnx2x_exe_queue_reset_pending(bp, &o->exe_queue);
 
        /* Clear pending */
        r->clear_pending(r);
 
+       spin_unlock_bh(&o->exe_queue.lock);
+
        /* If ramrod failed this is most likely a SW bug */
        if (cqe->message.error)
                return -EINVAL;
 
        /* Run the next bulk of pending commands if requested */
        if (test_bit(RAMROD_CONT, ramrod_flags)) {
-               rc = bnx2x_exe_queue_step(bp, &o->exe_queue, ramrod_flags);
+               rc = __bnx2x_vlan_mac_execute_step(bp, o, ramrod_flags);
+
                if (rc < 0)
                        return rc;
        }
@@ -1719,9 +1950,8 @@ static inline int bnx2x_vlan_mac_push_new_cmd(
  * @p:
  *
  */
-int bnx2x_config_vlan_mac(
-       struct bnx2x *bp,
-       struct bnx2x_vlan_mac_ramrod_params *p)
+int bnx2x_config_vlan_mac(struct bnx2x *bp,
+                          struct bnx2x_vlan_mac_ramrod_params *p)
 {
        int rc = 0;
        struct bnx2x_vlan_mac_obj *o = p->vlan_mac_obj;
@@ -1752,7 +1982,8 @@ int bnx2x_config_vlan_mac(
        /* Execute commands if required */
        if (cont || test_bit(RAMROD_EXEC, ramrod_flags) ||
            test_bit(RAMROD_COMP_WAIT, ramrod_flags)) {
-               rc = bnx2x_exe_queue_step(bp, &o->exe_queue, ramrod_flags);
+               rc = __bnx2x_vlan_mac_execute_step(bp, p->vlan_mac_obj,
+                                                  &p->ramrod_flags);
                if (rc < 0)
                        return rc;
        }
@@ -1775,8 +2006,9 @@ int bnx2x_config_vlan_mac(
                                return rc;
 
                        /* Make a next step */
-                       rc = bnx2x_exe_queue_step(bp, &o->exe_queue,
-                                                 ramrod_flags);
+                       rc = __bnx2x_vlan_mac_execute_step(bp,
+                                                          p->vlan_mac_obj,
+                                                          &p->ramrod_flags);
                        if (rc < 0)
                                return rc;
                }
@@ -1806,10 +2038,11 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
                                  unsigned long *ramrod_flags)
 {
        struct bnx2x_vlan_mac_registry_elem *pos = NULL;
-       int rc = 0;
        struct bnx2x_vlan_mac_ramrod_params p;
        struct bnx2x_exe_queue_obj *exeq = &o->exe_queue;
        struct bnx2x_exeq_elem *exeq_pos, *exeq_pos_n;
+       int read_lock;
+       int rc = 0;
 
        /* Clear pending commands first */
 
@@ -1844,6 +2077,11 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
        __clear_bit(RAMROD_EXEC, &p.ramrod_flags);
        __clear_bit(RAMROD_CONT, &p.ramrod_flags);
 
+       DP(BNX2X_MSG_SP, "vlan_mac_del_all -- taking vlan_mac_lock (reader)\n");
+       read_lock = bnx2x_vlan_mac_h_read_lock(bp, o);
+       if (read_lock != 0)
+               return read_lock;
+
        list_for_each_entry(pos, &o->head, link) {
                if (pos->vlan_mac_flags == *vlan_mac_flags) {
                        p.user_req.vlan_mac_flags = pos->vlan_mac_flags;
@@ -1851,11 +2089,15 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
                        rc = bnx2x_config_vlan_mac(bp, &p);
                        if (rc < 0) {
                                BNX2X_ERR("Failed to add a new DEL command\n");
+                               bnx2x_vlan_mac_h_read_unlock(bp, o);
                                return rc;
                        }
                }
        }
 
+       DP(BNX2X_MSG_SP, "vlan_mac_del_all -- releasing vlan_mac_lock (reader)\n");
+       bnx2x_vlan_mac_h_read_unlock(bp, o);
+
        p.ramrod_flags = *ramrod_flags;
        __set_bit(RAMROD_CONT, &p.ramrod_flags);
 
@@ -1887,6 +2129,9 @@ static inline void bnx2x_init_vlan_mac_common(struct bnx2x_vlan_mac_obj *o,
        struct bnx2x_credit_pool_obj *vlans_pool)
 {
        INIT_LIST_HEAD(&o->head);
+       o->head_reader = 0;
+       o->head_exe_request = false;
+       o->saved_ramrod_flags = 0;
 
        o->macs_pool = macs_pool;
        o->vlans_pool = vlans_pool;
index 798dfe9967336fedc4a5e07806c7216c83a955ed..533a3abd8c827b341ef0ca0ed9fc69262de1f646 100644 (file)
@@ -285,6 +285,12 @@ struct bnx2x_vlan_mac_obj {
         * entries.
         */
        struct list_head                head;
+       /* Implement a simple reader/writer lock on the head list.
+        * all these fields should only be accessed under the exe_queue lock
+        */
+       u8              head_reader; /* Num. of readers accessing head list */
+       bool            head_exe_request; /* Pending execution request. */
+       unsigned long   saved_ramrod_flags; /* Ramrods of pending execution */
 
        /* TODO: Add it's initialization in the init functions */
        struct bnx2x_exe_queue_obj      exe_queue;
@@ -1302,8 +1308,16 @@ void bnx2x_init_vlan_mac_obj(struct bnx2x *bp,
                             struct bnx2x_credit_pool_obj *macs_pool,
                             struct bnx2x_credit_pool_obj *vlans_pool);
 
+int bnx2x_vlan_mac_h_read_lock(struct bnx2x *bp,
+                                       struct bnx2x_vlan_mac_obj *o);
+void bnx2x_vlan_mac_h_read_unlock(struct bnx2x *bp,
+                                 struct bnx2x_vlan_mac_obj *o);
+int bnx2x_vlan_mac_h_write_lock(struct bnx2x *bp,
+                               struct bnx2x_vlan_mac_obj *o);
+void bnx2x_vlan_mac_h_write_unlock(struct bnx2x *bp,
+                                         struct bnx2x_vlan_mac_obj *o);
 int bnx2x_config_vlan_mac(struct bnx2x *bp,
-                         struct bnx2x_vlan_mac_ramrod_params *p);
+                          struct bnx2x_vlan_mac_ramrod_params *p);
 
 int bnx2x_vlan_mac_move(struct bnx2x *bp,
                        struct bnx2x_vlan_mac_ramrod_params *p,
index 95861efb505187f07bd1a176640e4f44af14a5de..fbc026c4cab2d7d3b100c635f95c6dc295cd44b3 100644 (file)
@@ -491,12 +491,20 @@ static inline void bnx2x_vfop_credit(struct bnx2x *bp,
         * and a valid credit counter
         */
        if (!vfop->rc && args->credit) {
-               int cnt = 0;
                struct list_head *pos;
+               int read_lock;
+               int cnt = 0;
+
+               read_lock = bnx2x_vlan_mac_h_read_lock(bp, obj);
+               if (read_lock)
+                       DP(BNX2X_MSG_SP, "Failed to take vlan mac read head; continuing anyway\n");
 
                list_for_each(pos, &obj->head)
                        cnt++;
 
+               if (!read_lock)
+                       bnx2x_vlan_mac_h_read_unlock(bp, obj);
+
                atomic_set(args->credit, cnt);
        }
 }
@@ -1747,11 +1755,8 @@ void bnx2x_iov_init_dq(struct bnx2x *bp)
 
 void bnx2x_iov_init_dmae(struct bnx2x *bp)
 {
-       DP(BNX2X_MSG_IOV, "SRIOV is %s\n", IS_SRIOV(bp) ? "ON" : "OFF");
-       if (!IS_SRIOV(bp))
-               return;
-
-       REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
+       if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV))
+               REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
 }
 
 static int bnx2x_vf_bus(struct bnx2x *bp, int vfid)
@@ -3084,8 +3089,9 @@ void bnx2x_disable_sriov(struct bnx2x *bp)
        pci_disable_sriov(bp->pdev);
 }
 
-static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx,
-                              struct bnx2x_virtf *vf)
+static int bnx2x_vf_ndo_prep(struct bnx2x *bp, int vfidx,
+                            struct bnx2x_virtf **vf,
+                            struct pf_vf_bulletin_content **bulletin)
 {
        if (bp->state != BNX2X_STATE_OPEN) {
                BNX2X_ERR("vf ndo called though PF is down\n");
@@ -3103,12 +3109,22 @@ static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx,
                return -EINVAL;
        }
 
-       if (!vf) {
+       /* init members */
+       *vf = BP_VF(bp, vfidx);
+       *bulletin = BP_VF_BULLETIN(bp, vfidx);
+
+       if (!*vf) {
                BNX2X_ERR("vf ndo called but vf was null. vfidx was %d\n",
                          vfidx);
                return -EINVAL;
        }
 
+       if (!*bulletin) {
+               BNX2X_ERR("vf ndo called but Bulletin Board struct is null. vfidx was %d\n",
+                         vfidx);
+               return -EINVAL;
+       }
+
        return 0;
 }
 
@@ -3116,17 +3132,19 @@ int bnx2x_get_vf_config(struct net_device *dev, int vfidx,
                        struct ifla_vf_info *ivi)
 {
        struct bnx2x *bp = netdev_priv(dev);
-       struct bnx2x_virtf *vf = BP_VF(bp, vfidx);
-       struct bnx2x_vlan_mac_obj *mac_obj = &bnx2x_vfq(vf, 0, mac_obj);
-       struct bnx2x_vlan_mac_obj *vlan_obj = &bnx2x_vfq(vf, 0, vlan_obj);
-       struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx);
+       struct bnx2x_virtf *vf = NULL;
+       struct pf_vf_bulletin_content *bulletin = NULL;
+       struct bnx2x_vlan_mac_obj *mac_obj;
+       struct bnx2x_vlan_mac_obj *vlan_obj;
        int rc;
 
-       /* sanity */
-       rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf);
+       /* sanity and init */
+       rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
        if (rc)
                return rc;
-       if (!mac_obj || !vlan_obj || !bulletin) {
+       mac_obj = &bnx2x_vfq(vf, 0, mac_obj);
+       vlan_obj = &bnx2x_vfq(vf, 0, vlan_obj);
+       if (!mac_obj || !vlan_obj) {
                BNX2X_ERR("VF partially initialized\n");
                return -EINVAL;
        }
@@ -3183,11 +3201,11 @@ int bnx2x_set_vf_mac(struct net_device *dev, int vfidx, u8 *mac)
 {
        struct bnx2x *bp = netdev_priv(dev);
        int rc, q_logical_state;
-       struct bnx2x_virtf *vf = BP_VF(bp, vfidx);
-       struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx);
+       struct bnx2x_virtf *vf = NULL;
+       struct pf_vf_bulletin_content *bulletin = NULL;
 
-       /* sanity */
-       rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf);
+       /* sanity and init */
+       rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
        if (rc)
                return rc;
        if (!is_valid_ether_addr(mac)) {
@@ -3249,11 +3267,11 @@ int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
 {
        struct bnx2x *bp = netdev_priv(dev);
        int rc, q_logical_state;
-       struct bnx2x_virtf *vf = BP_VF(bp, vfidx);
-       struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx);
+       struct bnx2x_virtf *vf = NULL;
+       struct pf_vf_bulletin_content *bulletin = NULL;
 
-       /* sanity */
-       rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf);
+       /* sanity and init */
+       rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
        if (rc)
                return rc;
 
@@ -3463,7 +3481,7 @@ int bnx2x_vf_pci_alloc(struct bnx2x *bp)
 alloc_mem_err:
        BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping,
                       sizeof(struct bnx2x_vf_mbx_msg));
-       BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping,
+       BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->pf2vf_bulletin_mapping,
                       sizeof(union pf_vf_bulletin));
        return -ENOMEM;
 }
index 98366abd02bda520cf1876189cced5926175288f..d63d1327b051e4a80c76027b03e723c332d0a317 100644 (file)
@@ -221,7 +221,8 @@ static int bnx2x_stats_comp(struct bnx2x *bp)
  * Statistics service functions
  */
 
-static void bnx2x_stats_pmf_update(struct bnx2x *bp)
+/* should be called under stats_sema */
+static void __bnx2x_stats_pmf_update(struct bnx2x *bp)
 {
        struct dmae_command *dmae;
        u32 opcode;
@@ -518,7 +519,8 @@ static void bnx2x_func_stats_init(struct bnx2x *bp)
        *stats_comp = 0;
 }
 
-static void bnx2x_stats_start(struct bnx2x *bp)
+/* should be called under stats_sema */
+static void __bnx2x_stats_start(struct bnx2x *bp)
 {
        /* vfs travel through here as part of the statistics FSM, but no action
         * is required
@@ -534,13 +536,34 @@ static void bnx2x_stats_start(struct bnx2x *bp)
 
        bnx2x_hw_stats_post(bp);
        bnx2x_storm_stats_post(bp);
+
+       bp->stats_started = true;
+}
+
+static void bnx2x_stats_start(struct bnx2x *bp)
+{
+       if (down_timeout(&bp->stats_sema, HZ/10))
+               BNX2X_ERR("Unable to acquire stats lock\n");
+       __bnx2x_stats_start(bp);
+       up(&bp->stats_sema);
 }
 
 static void bnx2x_stats_pmf_start(struct bnx2x *bp)
 {
+       if (down_timeout(&bp->stats_sema, HZ/10))
+               BNX2X_ERR("Unable to acquire stats lock\n");
        bnx2x_stats_comp(bp);
-       bnx2x_stats_pmf_update(bp);
-       bnx2x_stats_start(bp);
+       __bnx2x_stats_pmf_update(bp);
+       __bnx2x_stats_start(bp);
+       up(&bp->stats_sema);
+}
+
+static void bnx2x_stats_pmf_update(struct bnx2x *bp)
+{
+       if (down_timeout(&bp->stats_sema, HZ/10))
+               BNX2X_ERR("Unable to acquire stats lock\n");
+       __bnx2x_stats_pmf_update(bp);
+       up(&bp->stats_sema);
 }
 
 static void bnx2x_stats_restart(struct bnx2x *bp)
@@ -550,8 +573,11 @@ static void bnx2x_stats_restart(struct bnx2x *bp)
         */
        if (IS_VF(bp))
                return;
+       if (down_timeout(&bp->stats_sema, HZ/10))
+               BNX2X_ERR("Unable to acquire stats lock\n");
        bnx2x_stats_comp(bp);
-       bnx2x_stats_start(bp);
+       __bnx2x_stats_start(bp);
+       up(&bp->stats_sema);
 }
 
 static void bnx2x_bmac_stats_update(struct bnx2x *bp)
@@ -888,9 +914,7 @@ static int bnx2x_storm_stats_validate_counters(struct bnx2x *bp)
        /* Make sure we use the value of the counter
         * used for sending the last stats ramrod.
         */
-       spin_lock_bh(&bp->stats_lock);
        cur_stats_counter = bp->stats_counter - 1;
-       spin_unlock_bh(&bp->stats_lock);
 
        /* are storm stats valid? */
        if (le16_to_cpu(counters->xstats_counter) != cur_stats_counter) {
@@ -1227,12 +1251,18 @@ static void bnx2x_stats_update(struct bnx2x *bp)
 {
        u32 *stats_comp = bnx2x_sp(bp, stats_comp);
 
-       if (bnx2x_edebug_stats_stopped(bp))
+       /* we run update from timer context, so give up
+        * if somebody is in the middle of transition
+        */
+       if (down_trylock(&bp->stats_sema))
                return;
 
+       if (bnx2x_edebug_stats_stopped(bp) || !bp->stats_started)
+               goto out;
+
        if (IS_PF(bp)) {
                if (*stats_comp != DMAE_COMP_VAL)
-                       return;
+                       goto out;
 
                if (bp->port.pmf)
                        bnx2x_hw_stats_update(bp);
@@ -1242,7 +1272,7 @@ static void bnx2x_stats_update(struct bnx2x *bp)
                                BNX2X_ERR("storm stats were not updated for 3 times\n");
                                bnx2x_panic();
                        }
-                       return;
+                       goto out;
                }
        } else {
                /* vf doesn't collect HW statistics, and doesn't get completions
@@ -1256,7 +1286,7 @@ static void bnx2x_stats_update(struct bnx2x *bp)
 
        /* vf is done */
        if (IS_VF(bp))
-               return;
+               goto out;
 
        if (netif_msg_timer(bp)) {
                struct bnx2x_eth_stats *estats = &bp->eth_stats;
@@ -1267,6 +1297,9 @@ static void bnx2x_stats_update(struct bnx2x *bp)
 
        bnx2x_hw_stats_post(bp);
        bnx2x_storm_stats_post(bp);
+
+out:
+       up(&bp->stats_sema);
 }
 
 static void bnx2x_port_stats_stop(struct bnx2x *bp)
@@ -1332,6 +1365,11 @@ static void bnx2x_stats_stop(struct bnx2x *bp)
 {
        int update = 0;
 
+       if (down_timeout(&bp->stats_sema, HZ/10))
+               BNX2X_ERR("Unable to acquire stats lock\n");
+
+       bp->stats_started = false;
+
        bnx2x_stats_comp(bp);
 
        if (bp->port.pmf)
@@ -1348,6 +1386,8 @@ static void bnx2x_stats_stop(struct bnx2x *bp)
                bnx2x_hw_stats_post(bp);
                bnx2x_stats_comp(bp);
        }
+
+       up(&bp->stats_sema);
 }
 
 static void bnx2x_stats_do_nothing(struct bnx2x *bp)
@@ -1376,15 +1416,17 @@ static const struct {
 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event)
 {
        enum bnx2x_stats_state state;
+       void (*action)(struct bnx2x *bp);
        if (unlikely(bp->panic))
                return;
 
        spin_lock_bh(&bp->stats_lock);
        state = bp->stats_state;
        bp->stats_state = bnx2x_stats_stm[state][event].next_state;
+       action = bnx2x_stats_stm[state][event].action;
        spin_unlock_bh(&bp->stats_lock);
 
-       bnx2x_stats_stm[state][event].action(bp);
+       action(bp);
 
        if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp))
                DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n",
index d78d4cf140ed6d20a0e513d3c974740cf6c145cd..4f8a5357cedc4b93e7dd592805f0ca30e40e456f 100644 (file)
@@ -1,6 +1,6 @@
 /* cnic.c: Broadcom CNIC core network driver.
  *
- * Copyright (c) 2006-2012 Broadcom Corporation
+ * Copyright (c) 2006-2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1427,6 +1427,28 @@ static void cnic_reply_bnx2x_kcqes(struct cnic_dev *dev, int ulp_type,
        rcu_read_unlock();
 }
 
+static void cnic_bnx2x_set_tcp_options(struct cnic_dev *dev, int time_stamps,
+                                      int en_tcp_dack)
+{
+       struct cnic_local *cp = dev->cnic_priv;
+       struct bnx2x *bp = netdev_priv(dev->netdev);
+       u8 xstorm_flags = XSTORM_L5CM_TCP_FLAGS_WND_SCL_EN;
+       u16 tstorm_flags = 0;
+
+       if (time_stamps) {
+               xstorm_flags |= XSTORM_L5CM_TCP_FLAGS_TS_ENABLED;
+               tstorm_flags |= TSTORM_L5CM_TCP_FLAGS_TS_ENABLED;
+       }
+       if (en_tcp_dack)
+               tstorm_flags |= TSTORM_L5CM_TCP_FLAGS_DELAYED_ACK_EN;
+
+       CNIC_WR8(dev, BAR_XSTRORM_INTMEM +
+                XSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->pfid), xstorm_flags);
+
+       CNIC_WR16(dev, BAR_TSTRORM_INTMEM +
+                 TSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->pfid), tstorm_flags);
+}
+
 static int cnic_bnx2x_iscsi_init1(struct cnic_dev *dev, struct kwqe *kwqe)
 {
        struct cnic_local *cp = dev->cnic_priv;
@@ -1506,6 +1528,10 @@ static int cnic_bnx2x_iscsi_init1(struct cnic_dev *dev, struct kwqe *kwqe)
        CNIC_WR16(dev, BAR_CSTRORM_INTMEM + CSTORM_ISCSI_HQ_SIZE_OFFSET(pfid),
                  hq_bds);
 
+       cnic_bnx2x_set_tcp_options(dev,
+                       req1->flags & ISCSI_KWQE_INIT1_TIME_STAMPS_ENABLE,
+                       req1->flags & ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE);
+
        return 0;
 }
 
@@ -2035,9 +2061,6 @@ static void cnic_init_storm_conn_bufs(struct cnic_dev *dev,
        xstorm_buf->pseudo_header_checksum =
                swab16(~csum_ipv6_magic(&src_ip, &dst_ip, 0, IPPROTO_TCP, 0));
 
-       if (!(kwqe1->tcp_flags & L4_KWQ_CONNECT_REQ1_NO_DELAY_ACK))
-               tstorm_buf->params |=
-                       L5CM_TSTORM_CONN_BUFFER_DELAYED_ACK_ENABLE;
        if (kwqe3->ka_timeout) {
                tstorm_buf->ka_enable = 1;
                tstorm_buf->ka_timeout = kwqe3->ka_timeout;
@@ -2084,25 +2107,6 @@ static void cnic_init_bnx2x_mac(struct cnic_dev *dev)
                 mac[0]);
 }
 
-static void cnic_bnx2x_set_tcp_timestamp(struct cnic_dev *dev, int tcp_ts)
-{
-       struct cnic_local *cp = dev->cnic_priv;
-       struct bnx2x *bp = netdev_priv(dev->netdev);
-       u8 xstorm_flags = XSTORM_L5CM_TCP_FLAGS_WND_SCL_EN;
-       u16 tstorm_flags = 0;
-
-       if (tcp_ts) {
-               xstorm_flags |= XSTORM_L5CM_TCP_FLAGS_TS_ENABLED;
-               tstorm_flags |= TSTORM_L5CM_TCP_FLAGS_TS_ENABLED;
-       }
-
-       CNIC_WR8(dev, BAR_XSTRORM_INTMEM +
-                XSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->pfid), xstorm_flags);
-
-       CNIC_WR16(dev, BAR_TSTRORM_INTMEM +
-                 TSTORM_ISCSI_TCP_VARS_FLAGS_OFFSET(cp->pfid), tstorm_flags);
-}
-
 static int cnic_bnx2x_connect(struct cnic_dev *dev, struct kwqe *wqes[],
                              u32 num, int *work)
 {
@@ -2178,9 +2182,6 @@ static int cnic_bnx2x_connect(struct cnic_dev *dev, struct kwqe *wqes[],
        CNIC_WR16(dev, BAR_XSTRORM_INTMEM +
                  XSTORM_ISCSI_LOCAL_VLAN_OFFSET(cp->pfid), csk->vlan_id);
 
-       cnic_bnx2x_set_tcp_timestamp(dev,
-               kwqe1->tcp_flags & L4_KWQ_CONNECT_REQ1_TIME_STAMP);
-
        ret = cnic_submit_kwqe_16(dev, L5CM_RAMROD_CMD_ID_TCP_CONNECT,
                        kwqe1->cid, ISCSI_CONNECTION_TYPE, &l5_data);
        if (!ret)
@@ -3603,6 +3604,7 @@ static int cnic_cm_create(struct cnic_dev *dev, int ulp_type, u32 cid,
        csk1->rcv_buf = DEF_RCV_BUF;
        csk1->snd_buf = DEF_SND_BUF;
        csk1->seed = DEF_SEED;
+       csk1->tcp_flags = 0;
 
        *csk = csk1;
        return 0;
@@ -4020,15 +4022,18 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
                cnic_cm_upcall(cp, csk, opcode);
                break;
 
-       case L5CM_RAMROD_CMD_ID_CLOSE:
-               if (l4kcqe->status != 0) {
-                       netdev_warn(dev->netdev, "RAMROD CLOSE compl with "
-                                   "status 0x%x\n", l4kcqe->status);
+       case L5CM_RAMROD_CMD_ID_CLOSE: {
+               struct iscsi_kcqe *l5kcqe = (struct iscsi_kcqe *) kcqe;
+
+               if (l4kcqe->status != 0 || l5kcqe->completion_status != 0) {
+                       netdev_warn(dev->netdev, "RAMROD CLOSE compl with status 0x%x completion status 0x%x\n",
+                                   l4kcqe->status, l5kcqe->completion_status);
                        opcode = L4_KCQE_OPCODE_VALUE_CLOSE_COMP;
                        /* Fall through */
                } else {
                        break;
                }
+       }
        case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED:
        case L4_KCQE_OPCODE_VALUE_CLOSE_COMP:
        case L4_KCQE_OPCODE_VALUE_RESET_COMP:
@@ -4219,7 +4224,7 @@ static int cnic_cm_init_bnx2x_hw(struct cnic_dev *dev)
        u32 port = CNIC_PORT(cp);
 
        cnic_init_bnx2x_mac(dev);
-       cnic_bnx2x_set_tcp_timestamp(dev, 1);
+       cnic_bnx2x_set_tcp_options(dev, 0, 1);
 
        CNIC_WR16(dev, BAR_XSTRORM_INTMEM +
                  XSTORM_ISCSI_LOCAL_VLAN_OFFSET(pfid), 0);
@@ -5271,6 +5276,13 @@ static int cnic_register_netdev(struct cnic_dev *dev)
        if (err)
                netdev_err(dev->netdev, "register_cnic failed\n");
 
+       /* Read iSCSI config again.  On some bnx2x device, iSCSI config
+        * can change after firmware is downloaded.
+        */
+       dev->max_iscsi_conn = ethdev->max_iscsi_conn;
+       if (ethdev->drv_state & CNIC_DRV_STATE_NO_ISCSI)
+               dev->max_iscsi_conn = 0;
+
        return err;
 }
 
@@ -5628,7 +5640,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
 
        dev = cnic_from_netdev(netdev);
 
-       if (!dev && (event == NETDEV_REGISTER || netif_running(netdev))) {
+       if (!dev && event == NETDEV_REGISTER) {
                /* Check for the hot-plug device */
                dev = is_cnic_dev(netdev);
                if (dev) {
@@ -5644,7 +5656,7 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
                else if (event == NETDEV_UNREGISTER)
                        cnic_ulp_exit(dev);
 
-               if (event == NETDEV_UP || (new_dev && netif_running(netdev))) {
+               if (event == NETDEV_UP) {
                        if (cnic_register_netdev(dev) != 0) {
                                cnic_put(dev);
                                goto done;
@@ -5693,21 +5705,8 @@ static struct notifier_block cnic_netdev_notifier = {
 
 static void cnic_release(void)
 {
-       struct cnic_dev *dev;
        struct cnic_uio_dev *udev;
 
-       while (!list_empty(&cnic_dev_list)) {
-               dev = list_entry(cnic_dev_list.next, struct cnic_dev, list);
-               if (test_bit(CNIC_F_CNIC_UP, &dev->flags)) {
-                       cnic_ulp_stop(dev);
-                       cnic_stop_hw(dev);
-               }
-
-               cnic_ulp_exit(dev);
-               cnic_unregister_netdev(dev);
-               list_del_init(&dev->list);
-               cnic_free_dev(dev);
-       }
        while (!list_empty(&cnic_udev_list)) {
                udev = list_entry(cnic_udev_list.next, struct cnic_uio_dev,
                                  list);
index 62c670619ae6600a631bad3a351ceb1abec08e5f..e7a247473596ebcbf10688935ab088ac9157a016 100644 (file)
@@ -1,6 +1,6 @@
 /* cnic.h: Broadcom CNIC core network driver.
  *
- * Copyright (c) 2006-2011 Broadcom Corporation
+ * Copyright (c) 2006-2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index ede3db35d757e9c51a5f07cef320ecf323515295..95a8e4b11c9fcce45a0f24acea5bd1b86fa53ab9 100644 (file)
@@ -1,7 +1,7 @@
 
 /* cnic.c: Broadcom CNIC core network driver.
  *
- * Copyright (c) 2006-2012 Broadcom Corporation
+ * Copyright (c) 2006-2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -5400,8 +5400,8 @@ struct tstorm_l5cm_tcp_flags {
        u16 flags;
 #define TSTORM_L5CM_TCP_FLAGS_VLAN_ID (0xFFF<<0)
 #define TSTORM_L5CM_TCP_FLAGS_VLAN_ID_SHIFT 0
-#define TSTORM_L5CM_TCP_FLAGS_RSRV0 (0x1<<12)
-#define TSTORM_L5CM_TCP_FLAGS_RSRV0_SHIFT 12
+#define TSTORM_L5CM_TCP_FLAGS_DELAYED_ACK_EN (0x1<<12)
+#define TSTORM_L5CM_TCP_FLAGS_DELAYED_ACK_SHIFT 12
 #define TSTORM_L5CM_TCP_FLAGS_TS_ENABLED (0x1<<13)
 #define TSTORM_L5CM_TCP_FLAGS_TS_ENABLED_SHIFT 13
 #define TSTORM_L5CM_TCP_FLAGS_RSRV1 (0x3<<14)
index ec9bb9ad4bb35c852ef5f0ff62d86118ec6cbaa7..95aff7642b853c58c281e8fd78c3e9e86a8aa254 100644 (file)
@@ -1,6 +1,6 @@
 /* cnic_if.h: Broadcom CNIC core network driver.
  *
- * Copyright (c) 2006-2012 Broadcom Corporation
+ * Copyright (c) 2006-2013 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,8 +14,8 @@
 
 #include "bnx2x/bnx2x_mfw_req.h"
 
-#define CNIC_MODULE_VERSION    "2.5.16"
-#define CNIC_MODULE_RELDATE    "Dec 05, 2012"
+#define CNIC_MODULE_VERSION    "2.5.17"
+#define CNIC_MODULE_RELDATE    "July 28, 2013"
 
 #define CNIC_ULP_RDMA          0
 #define CNIC_ULP_ISCSI         1
@@ -238,8 +238,8 @@ struct cnic_sock {
        u16     src_port;
        u16     dst_port;
        u16     vlan_id;
-       unsigned char old_ha[6];
-       unsigned char ha[6];
+       unsigned char old_ha[ETH_ALEN];
+       unsigned char ha[ETH_ALEN];
        u32     mtu;
        u32     cid;
        u32     l5_cid;
@@ -308,7 +308,7 @@ struct cnic_dev {
 #define CNIC_F_BNX2_CLASS      3
 #define CNIC_F_BNX2X_CLASS     4
        atomic_t        ref_count;
-       u8              mac_addr[6];
+       u8              mac_addr[ETH_ALEN];
 
        int             max_iscsi_conn;
        int             max_fcoe_conn;
index d964f302ac94163f32780c4d1ed6667d4fb4165f..95b8995187d73958d048f9da89c8658c3b97ea39 100644 (file)
@@ -94,10 +94,10 @@ static inline void _tg3_flag_clear(enum TG3_FLAGS flag, unsigned long *bits)
 
 #define DRV_MODULE_NAME                "tg3"
 #define TG3_MAJ_NUM                    3
-#define TG3_MIN_NUM                    132
+#define TG3_MIN_NUM                    133
 #define DRV_MODULE_VERSION     \
        __stringify(TG3_MAJ_NUM) "." __stringify(TG3_MIN_NUM)
-#define DRV_MODULE_RELDATE     "May 21, 2013"
+#define DRV_MODULE_RELDATE     "Jul 29, 2013"
 
 #define RESET_KIND_SHUTDOWN    0
 #define RESET_KIND_INIT                1
@@ -4226,8 +4226,6 @@ static int tg3_power_down_prepare(struct tg3 *tp)
 
 static void tg3_power_down(struct tg3 *tp)
 {
-       tg3_power_down_prepare(tp);
-
        pci_wake_from_d3(tp->pdev, tg3_flag(tp, WOL_ENABLE));
        pci_set_power_state(tp->pdev, PCI_D3hot);
 }
@@ -6095,10 +6093,12 @@ static u64 tg3_refclk_read(struct tg3 *tp)
 /* tp->lock must be held */
 static void tg3_refclk_write(struct tg3 *tp, u64 newval)
 {
-       tw32(TG3_EAV_REF_CLCK_CTL, TG3_EAV_REF_CLCK_CTL_STOP);
+       u32 clock_ctl = tr32(TG3_EAV_REF_CLCK_CTL);
+
+       tw32(TG3_EAV_REF_CLCK_CTL, clock_ctl | TG3_EAV_REF_CLCK_CTL_STOP);
        tw32(TG3_EAV_REF_CLCK_LSB, newval & 0xffffffff);
        tw32(TG3_EAV_REF_CLCK_MSB, newval >> 32);
-       tw32_f(TG3_EAV_REF_CLCK_CTL, TG3_EAV_REF_CLCK_CTL_RESUME);
+       tw32_f(TG3_EAV_REF_CLCK_CTL, clock_ctl | TG3_EAV_REF_CLCK_CTL_RESUME);
 }
 
 static inline void tg3_full_lock(struct tg3 *tp, int irq_sync);
@@ -6214,6 +6214,59 @@ static int tg3_ptp_settime(struct ptp_clock_info *ptp,
 static int tg3_ptp_enable(struct ptp_clock_info *ptp,
                          struct ptp_clock_request *rq, int on)
 {
+       struct tg3 *tp = container_of(ptp, struct tg3, ptp_info);
+       u32 clock_ctl;
+       int rval = 0;
+
+       switch (rq->type) {
+       case PTP_CLK_REQ_PEROUT:
+               if (rq->perout.index != 0)
+                       return -EINVAL;
+
+               tg3_full_lock(tp, 0);
+               clock_ctl = tr32(TG3_EAV_REF_CLCK_CTL);
+               clock_ctl &= ~TG3_EAV_CTL_TSYNC_GPIO_MASK;
+
+               if (on) {
+                       u64 nsec;
+
+                       nsec = rq->perout.start.sec * 1000000000ULL +
+                              rq->perout.start.nsec;
+
+                       if (rq->perout.period.sec || rq->perout.period.nsec) {
+                               netdev_warn(tp->dev,
+                                           "Device supports only a one-shot timesync output, period must be 0\n");
+                               rval = -EINVAL;
+                               goto err_out;
+                       }
+
+                       if (nsec & (1ULL << 63)) {
+                               netdev_warn(tp->dev,
+                                           "Start value (nsec) is over limit. Maximum size of start is only 63 bits\n");
+                               rval = -EINVAL;
+                               goto err_out;
+                       }
+
+                       tw32(TG3_EAV_WATCHDOG0_LSB, (nsec & 0xffffffff));
+                       tw32(TG3_EAV_WATCHDOG0_MSB,
+                            TG3_EAV_WATCHDOG0_EN |
+                            ((nsec >> 32) & TG3_EAV_WATCHDOG_MSB_MASK));
+
+                       tw32(TG3_EAV_REF_CLCK_CTL,
+                            clock_ctl | TG3_EAV_CTL_TSYNC_WDOG0);
+               } else {
+                       tw32(TG3_EAV_WATCHDOG0_MSB, 0);
+                       tw32(TG3_EAV_REF_CLCK_CTL, clock_ctl);
+               }
+
+err_out:
+               tg3_full_unlock(tp);
+               return rval;
+
+       default:
+               break;
+       }
+
        return -EOPNOTSUPP;
 }
 
@@ -6223,7 +6276,7 @@ static const struct ptp_clock_info tg3_ptp_caps = {
        .max_adj        = 250000000,
        .n_alarm        = 0,
        .n_ext_ts       = 0,
-       .n_per_out      = 0,
+       .n_per_out      = 1,
        .pps            = 0,
        .adjfreq        = tg3_ptp_adjfreq,
        .adjtime        = tg3_ptp_adjtime,
@@ -10367,6 +10420,9 @@ static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)
        if (tg3_flag(tp, 5755_PLUS))
                tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE;
 
+       if (tg3_asic_rev(tp) == ASIC_REV_5762)
+               tp->rx_mode |= RX_MODE_IPV4_FRAG_FIX;
+
        if (tg3_flag(tp, ENABLE_RSS))
                tp->rx_mode |= RX_MODE_RSS_ENABLE |
                               RX_MODE_RSS_ITBL_HASH_BITS_7 |
@@ -11502,7 +11558,7 @@ static int tg3_close(struct net_device *dev)
        memset(&tp->net_stats_prev, 0, sizeof(tp->net_stats_prev));
        memset(&tp->estats_prev, 0, sizeof(tp->estats_prev));
 
-       tg3_power_down(tp);
+       tg3_power_down_prepare(tp);
 
        tg3_carrier_off(tp);
 
@@ -11724,9 +11780,6 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
        if (tg3_flag(tp, NO_NVRAM))
                return -EINVAL;
 
-       if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
-               return -EAGAIN;
-
        offset = eeprom->offset;
        len = eeprom->len;
        eeprom->len = 0;
@@ -11784,9 +11837,6 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
        u8 *buf;
        __be32 start, end;
 
-       if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
-               return -EAGAIN;
-
        if (tg3_flag(tp, NO_NVRAM) ||
            eeprom->magic != TG3_EEPROM_MAGIC)
                return -EINVAL;
@@ -13515,7 +13565,7 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest,
                        tg3_phy_start(tp);
        }
        if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER)
-               tg3_power_down(tp);
+               tg3_power_down_prepare(tp);
 
 }
 
@@ -15917,7 +15967,7 @@ static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent)
         */
        if (tg3_flag(tp, 5780_CLASS)) {
                tg3_flag_set(tp, 40BIT_DMA_BUG);
-               tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI);
+               tp->msi_cap = tp->pdev->msi_cap;
        } else {
                struct pci_dev *bridge = NULL;
 
@@ -17547,11 +17597,6 @@ static int tg3_init_one(struct pci_dev *pdev,
            tg3_asic_rev(tp) == ASIC_REV_5762)
                tg3_flag_set(tp, PTP_CAPABLE);
 
-       if (tg3_flag(tp, 5717_PLUS)) {
-               /* Resume a low-power mode */
-               tg3_frob_aux_power(tp, false);
-       }
-
        tg3_timer_init(tp);
 
        tg3_carrier_off(tp);
@@ -17625,7 +17670,8 @@ err_out_free_res:
        pci_release_regions(pdev);
 
 err_out_disable_pdev:
-       pci_disable_device(pdev);
+       if (pci_is_enabled(pdev))
+               pci_disable_device(pdev);
        pci_set_drvdata(pdev, NULL);
        return err;
 }
@@ -17754,6 +17800,23 @@ out:
 
 static SIMPLE_DEV_PM_OPS(tg3_pm_ops, tg3_suspend, tg3_resume);
 
+static void tg3_shutdown(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       struct tg3 *tp = netdev_priv(dev);
+
+       rtnl_lock();
+       netif_device_detach(dev);
+
+       if (netif_running(dev))
+               dev_close(dev);
+
+       if (system_state == SYSTEM_POWER_OFF)
+               tg3_power_down(tp);
+
+       rtnl_unlock();
+}
+
 /**
  * tg3_io_error_detected - called when PCI error is detected
  * @pdev: Pointer to PCI device
@@ -17773,7 +17836,8 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
 
        rtnl_lock();
 
-       if (!netif_running(netdev))
+       /* We probably don't have netdev yet */
+       if (!netdev || !netif_running(netdev))
                goto done;
 
        tg3_phy_stop(tp);
@@ -17794,8 +17858,10 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
 
 done:
        if (state == pci_channel_io_perm_failure) {
-               tg3_napi_enable(tp);
-               dev_close(netdev);
+               if (netdev) {
+                       tg3_napi_enable(tp);
+                       dev_close(netdev);
+               }
                err = PCI_ERS_RESULT_DISCONNECT;
        } else {
                pci_disable_device(pdev);
@@ -17825,7 +17891,8 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
        rtnl_lock();
 
        if (pci_enable_device(pdev)) {
-               netdev_err(netdev, "Cannot re-enable PCI device after reset.\n");
+               dev_err(&pdev->dev,
+                       "Cannot re-enable PCI device after reset.\n");
                goto done;
        }
 
@@ -17833,7 +17900,7 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
        pci_restore_state(pdev);
        pci_save_state(pdev);
 
-       if (!netif_running(netdev)) {
+       if (!netdev || !netif_running(netdev)) {
                rc = PCI_ERS_RESULT_RECOVERED;
                goto done;
        }
@@ -17845,7 +17912,7 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
        rc = PCI_ERS_RESULT_RECOVERED;
 
 done:
-       if (rc != PCI_ERS_RESULT_RECOVERED && netif_running(netdev)) {
+       if (rc != PCI_ERS_RESULT_RECOVERED && netdev && netif_running(netdev)) {
                tg3_napi_enable(tp);
                dev_close(netdev);
        }
@@ -17909,6 +17976,7 @@ static struct pci_driver tg3_driver = {
        .remove         = tg3_remove_one,
        .err_handler    = &tg3_err_handler,
        .driver.pm      = &tg3_pm_ops,
+       .shutdown       = tg3_shutdown,
 };
 
 module_pci_driver(tg3_driver);
index cd63d1189aae9fdfbcceb5615d76b8d6d74704d2..ddb8be1298eab2b66eac319a4abce91a72da8896 100644 (file)
 #define  RX_MODE_RSS_ITBL_HASH_BITS_7   0x00700000
 #define  RX_MODE_RSS_ENABLE             0x00800000
 #define  RX_MODE_IPV6_CSUM_ENABLE       0x01000000
+#define  RX_MODE_IPV4_FRAG_FIX          0x02000000
 #define MAC_RX_STATUS                  0x0000046c
 #define  RX_STATUS_REMOTE_TX_XOFFED     0x00000001
 #define  RX_STATUS_XOFF_RCVD            0x00000002
 #define TG3_EAV_REF_CLCK_CTL           0x00006908
 #define  TG3_EAV_REF_CLCK_CTL_STOP      0x00000002
 #define  TG3_EAV_REF_CLCK_CTL_RESUME    0x00000004
+#define  TG3_EAV_CTL_TSYNC_GPIO_MASK    (0x3 << 16)
+#define  TG3_EAV_CTL_TSYNC_WDOG0        (1 << 17)
+
+#define TG3_EAV_WATCHDOG0_LSB          0x00006918
+#define TG3_EAV_WATCHDOG0_MSB          0x0000691c
+#define  TG3_EAV_WATCHDOG0_EN           (1 << 31)
+#define  TG3_EAV_WATCHDOG_MSB_MASK     0x7fffffff
+
 #define TG3_EAV_REF_CLK_CORRECT_CTL    0x00006928
 #define  TG3_EAV_REF_CLK_CORRECT_EN     (1 << 31)
 #define  TG3_EAV_REF_CLK_CORRECT_NEG    (1 << 30)
 
 #define TG3_EAV_REF_CLK_CORRECT_MASK   0xffffff
-/* 0x690c --> 0x7000 unused */
+
+/* 0x692c --> 0x7000 unused */
 
 /* NVRAM Control registers */
 #define NVRAM_CMD                      0x00007000
index 57cd1bff59f1cd056f5d7b68755612ef7e985426..3c07064b2bc44f2bf0d25c760e98f92a42a031ab 100644 (file)
@@ -1419,7 +1419,7 @@ static void bna_rx_sm_start_wait_entry(struct bna_rx *rx)
        bna_bfi_rx_enet_start(rx);
 }
 
-void
+static void
 bna_rx_sm_stop_wait_entry(struct bna_rx *rx)
 {
 }
@@ -1472,7 +1472,7 @@ static void bna_rx_sm_rxf_start_wait_entry(struct bna_rx *rx)
        bna_rxf_start(&rx->rxf);
 }
 
-void
+static void
 bna_rx_sm_rxf_stop_wait_entry(struct bna_rx *rx)
 {
 }
@@ -1528,7 +1528,7 @@ bna_rx_sm_start_stop_wait(struct bna_rx *rx, enum bna_rx_event event)
        }
 }
 
-void
+static void
 bna_rx_sm_started_entry(struct bna_rx *rx)
 {
        struct bna_rxp *rxp;
@@ -1593,12 +1593,12 @@ static void bna_rx_sm_rxf_start_wait(struct bna_rx *rx,
        }
 }
 
-void
+static void
 bna_rx_sm_cleanup_wait_entry(struct bna_rx *rx)
 {
 }
 
-void
+static void
 bna_rx_sm_cleanup_wait(struct bna_rx *rx, enum bna_rx_event event)
 {
        switch (event) {
index c37f706d9992fadcfbd90016d8d23c7472452672..43405f654b4aa0018ae739efc0ff7b247512f7f6 100644 (file)
@@ -37,8 +37,8 @@
 
 extern char bfa_version[];
 
-#define CNA_FW_FILE_CT "ctfw-3.2.1.0.bin"
-#define CNA_FW_FILE_CT2        "ct2fw-3.2.1.0.bin"
+#define CNA_FW_FILE_CT "ctfw-3.2.1.1.bin"
+#define CNA_FW_FILE_CT2        "ct2fw-3.2.1.1.bin"
 #define FC_SYMNAME_MAX 256     /*!< max name server symbolic name size */
 
 #pragma pack(1)
index e866608d7d91f36cbd9e46532e474d2b02bf0bac..fe06ab0f73755ce2cca23f22a8e61620eb59eb98 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/phy.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_mdio.h>
 #include <linux/of_net.h>
 #include <linux/pinctrl/consumer.h>
 
@@ -314,6 +315,7 @@ static int macb_mii_probe(struct net_device *dev)
 int macb_mii_init(struct macb *bp)
 {
        struct macb_platform_data *pdata;
+       struct device_node *np;
        int err = -ENXIO, i;
 
        /* Enable management port */
@@ -335,21 +337,46 @@ int macb_mii_init(struct macb *bp)
        bp->mii_bus->parent = &bp->dev->dev;
        pdata = bp->pdev->dev.platform_data;
 
-       if (pdata)
-               bp->mii_bus->phy_mask = pdata->phy_mask;
-
        bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
        if (!bp->mii_bus->irq) {
                err = -ENOMEM;
                goto err_out_free_mdiobus;
        }
 
-       for (i = 0; i < PHY_MAX_ADDR; i++)
-               bp->mii_bus->irq[i] = PHY_POLL;
-
        dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
 
-       if (mdiobus_register(bp->mii_bus))
+       np = bp->pdev->dev.of_node;
+       if (np) {
+               /* try dt phy registration */
+               err = of_mdiobus_register(bp->mii_bus, np);
+
+               /* fallback to standard phy registration if no phy were
+                  found during dt phy registration */
+               if (!err && !phy_find_first(bp->mii_bus)) {
+                       for (i = 0; i < PHY_MAX_ADDR; i++) {
+                               struct phy_device *phydev;
+
+                               phydev = mdiobus_scan(bp->mii_bus, i);
+                               if (IS_ERR(phydev)) {
+                                       err = PTR_ERR(phydev);
+                                       break;
+                               }
+                       }
+
+                       if (err)
+                               goto err_out_unregister_bus;
+               }
+       } else {
+               for (i = 0; i < PHY_MAX_ADDR; i++)
+                       bp->mii_bus->irq[i] = PHY_POLL;
+
+               if (pdata)
+                       bp->mii_bus->phy_mask = pdata->phy_mask;
+
+               err = mdiobus_register(bp->mii_bus);
+       }
+
+       if (err)
                goto err_out_free_mdio_irq;
 
        if (macb_mii_probe(bp->dev) != 0) {
index 687ec4a8bb48de001cfa9d39ef233ee7c69a5d96..9c89dc8fe1057dc1c410728bd252f135f9a80879 100644 (file)
@@ -455,11 +455,6 @@ static int alloc_pg_chunk(struct adapter *adapter, struct sge_fl *q,
                q->pg_chunk.offset = 0;
                mapping = pci_map_page(adapter->pdev, q->pg_chunk.page,
                                       0, q->alloc_size, PCI_DMA_FROMDEVICE);
-               if (unlikely(pci_dma_mapping_error(adapter->pdev, mapping))) {
-                       __free_pages(q->pg_chunk.page, order);
-                       q->pg_chunk.page = NULL;
-                       return -EIO;
-               }
                q->pg_chunk.mapping = mapping;
        }
        sd->pg_chunk = q->pg_chunk;
@@ -954,75 +949,40 @@ static inline unsigned int calc_tx_descs(const struct sk_buff *skb)
        return flits_to_desc(flits);
 }
 
-
-/*     map_skb - map a packet main body and its page fragments
- *     @pdev: the PCI device
- *     @skb: the packet
- *     @addr: placeholder to save the mapped addresses
- *
- *     map the main body of an sk_buff and its page fragments, if any.
- */
-static int map_skb(struct pci_dev *pdev, const struct sk_buff *skb,
-                  dma_addr_t *addr)
-{
-       const skb_frag_t *fp, *end;
-       const struct skb_shared_info *si;
-
-       *addr = pci_map_single(pdev, skb->data, skb_headlen(skb),
-                              PCI_DMA_TODEVICE);
-       if (pci_dma_mapping_error(pdev, *addr))
-               goto out_err;
-
-       si = skb_shinfo(skb);
-       end = &si->frags[si->nr_frags];
-
-       for (fp = si->frags; fp < end; fp++) {
-               *++addr = skb_frag_dma_map(&pdev->dev, fp, 0, skb_frag_size(fp),
-                                          DMA_TO_DEVICE);
-               if (pci_dma_mapping_error(pdev, *addr))
-                       goto unwind;
-       }
-       return 0;
-
-unwind:
-       while (fp-- > si->frags)
-               dma_unmap_page(&pdev->dev, *--addr, skb_frag_size(fp),
-                              DMA_TO_DEVICE);
-
-       pci_unmap_single(pdev, addr[-1], skb_headlen(skb), PCI_DMA_TODEVICE);
-out_err:
-       return -ENOMEM;
-}
-
 /**
- *     write_sgl - populate a scatter/gather list for a packet
+ *     make_sgl - populate a scatter/gather list for a packet
  *     @skb: the packet
  *     @sgp: the SGL to populate
  *     @start: start address of skb main body data to include in the SGL
  *     @len: length of skb main body data to include in the SGL
- *     @addr: the list of the mapped addresses
+ *     @pdev: the PCI device
  *
- *     Copies the scatter/gather list for the buffers that make up a packet
+ *     Generates a scatter/gather list for the buffers that make up a packet
  *     and returns the SGL size in 8-byte words.  The caller must size the SGL
  *     appropriately.
  */
-static inline unsigned int write_sgl(const struct sk_buff *skb,
+static inline unsigned int make_sgl(const struct sk_buff *skb,
                                    struct sg_ent *sgp, unsigned char *start,
-                                   unsigned int len, const dma_addr_t *addr)
+                                   unsigned int len, struct pci_dev *pdev)
 {
-       unsigned int i, j = 0, k = 0, nfrags;
+       dma_addr_t mapping;
+       unsigned int i, j = 0, nfrags;
 
        if (len) {
+               mapping = pci_map_single(pdev, start, len, PCI_DMA_TODEVICE);
                sgp->len[0] = cpu_to_be32(len);
-               sgp->addr[j++] = cpu_to_be64(addr[k++]);
+               sgp->addr[0] = cpu_to_be64(mapping);
+               j = 1;
        }
 
        nfrags = skb_shinfo(skb)->nr_frags;
        for (i = 0; i < nfrags; i++) {
                const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
 
+               mapping = skb_frag_dma_map(&pdev->dev, frag, 0, skb_frag_size(frag),
+                                          DMA_TO_DEVICE);
                sgp->len[j] = cpu_to_be32(skb_frag_size(frag));
-               sgp->addr[j] = cpu_to_be64(addr[k++]);
+               sgp->addr[j] = cpu_to_be64(mapping);
                j ^= 1;
                if (j == 0)
                        ++sgp;
@@ -1178,7 +1138,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
                            const struct port_info *pi,
                            unsigned int pidx, unsigned int gen,
                            struct sge_txq *q, unsigned int ndesc,
-                           unsigned int compl, const dma_addr_t *addr)
+                           unsigned int compl)
 {
        unsigned int flits, sgl_flits, cntrl, tso_info;
        struct sg_ent *sgp, sgl[MAX_SKB_FRAGS / 2 + 1];
@@ -1236,7 +1196,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
        }
 
        sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
-       sgl_flits = write_sgl(skb, sgp, skb->data, skb_headlen(skb), addr);
+       sgl_flits = make_sgl(skb, sgp, skb->data, skb_headlen(skb), adap->pdev);
 
        write_wr_hdr_sgl(ndesc, skb, d, pidx, q, sgl, flits, sgl_flits, gen,
                         htonl(V_WR_OP(FW_WROPCODE_TUNNEL_TX_PKT) | compl),
@@ -1267,7 +1227,6 @@ netdev_tx_t t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
        struct netdev_queue *txq;
        struct sge_qset *qs;
        struct sge_txq *q;
-       dma_addr_t addr[MAX_SKB_FRAGS + 1];
 
        /*
         * The chip min packet length is 9 octets but play safe and reject
@@ -1296,11 +1255,6 @@ netdev_tx_t t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                return NETDEV_TX_BUSY;
        }
 
-       if (unlikely(map_skb(adap->pdev, skb, addr) < 0)) {
-               dev_kfree_skb(skb);
-               return NETDEV_TX_OK;
-       }
-
        q->in_use += ndesc;
        if (unlikely(credits - ndesc < q->stop_thres)) {
                t3_stop_tx_queue(txq, qs, q);
@@ -1358,7 +1312,7 @@ netdev_tx_t t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
        if (likely(!skb_shared(skb)))
                skb_orphan(skb);
 
-       write_tx_pkt_wr(adap, skb, pi, pidx, gen, q, ndesc, compl, addr);
+       write_tx_pkt_wr(adap, skb, pi, pidx, gen, q, ndesc, compl);
        check_ring_tx_db(adap, q);
        return NETDEV_TX_OK;
 }
@@ -1623,8 +1577,7 @@ static void setup_deferred_unmapping(struct sk_buff *skb, struct pci_dev *pdev,
  */
 static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
                          struct sge_txq *q, unsigned int pidx,
-                         unsigned int gen, unsigned int ndesc,
-                         const dma_addr_t *addr)
+                         unsigned int gen, unsigned int ndesc)
 {
        unsigned int sgl_flits, flits;
        struct work_request_hdr *from;
@@ -1645,9 +1598,9 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
 
        flits = skb_transport_offset(skb) / 8;
        sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
-       sgl_flits = write_sgl(skb, sgp, skb_transport_header(skb),
-                            skb_tail_pointer(skb) -
-                            skb_transport_header(skb), addr);
+       sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
+                            skb->tail - skb->transport_header,
+                            adap->pdev);
        if (need_skb_unmap()) {
                setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
                skb->destructor = deferred_unmap_destructor;
@@ -1705,11 +1658,6 @@ again:   reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
                goto again;
        }
 
-       if (map_skb(adap->pdev, skb, (dma_addr_t *)skb->head)) {
-               spin_unlock(&q->lock);
-               return NET_XMIT_SUCCESS;
-       }
-
        gen = q->gen;
        q->in_use += ndesc;
        pidx = q->pidx;
@@ -1720,7 +1668,7 @@ again:    reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
        }
        spin_unlock(&q->lock);
 
-       write_ofld_wr(adap, skb, q, pidx, gen, ndesc, (dma_addr_t *)skb->head);
+       write_ofld_wr(adap, skb, q, pidx, gen, ndesc);
        check_ring_tx_db(adap, q);
        return NET_XMIT_SUCCESS;
 }
@@ -1738,7 +1686,6 @@ static void restart_offloadq(unsigned long data)
        struct sge_txq *q = &qs->txq[TXQ_OFLD];
        const struct port_info *pi = netdev_priv(qs->netdev);
        struct adapter *adap = pi->adapter;
-       unsigned int written = 0;
 
        spin_lock(&q->lock);
 again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
@@ -1758,14 +1705,10 @@ again:  reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
                        break;
                }
 
-               if (map_skb(adap->pdev, skb, (dma_addr_t *)skb->head))
-                       break;
-
                gen = q->gen;
                q->in_use += ndesc;
                pidx = q->pidx;
                q->pidx += ndesc;
-               written += ndesc;
                if (q->pidx >= q->size) {
                        q->pidx -= q->size;
                        q->gen ^= 1;
@@ -1773,8 +1716,7 @@ again:    reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
                __skb_unlink(skb, &q->sendq);
                spin_unlock(&q->lock);
 
-               write_ofld_wr(adap, skb, q, pidx, gen, ndesc,
-                            (dma_addr_t *)skb->head);
+               write_ofld_wr(adap, skb, q, pidx, gen, ndesc);
                spin_lock(&q->lock);
        }
        spin_unlock(&q->lock);
@@ -1784,9 +1726,8 @@ again:    reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
        set_bit(TXQ_LAST_PKT_DB, &q->flags);
 #endif
        wmb();
-       if (likely(written))
-               t3_write_reg(adap, A_SG_KDOORBELL,
-                            F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id));
+       t3_write_reg(adap, A_SG_KDOORBELL,
+                    F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id));
 }
 
 /**
index 9d4974bba247904162de48e382ae8989be8f1a7b..239e1e46545de438a2482c5c0a721de9800335cc 100644 (file)
@@ -1,5 +1,6 @@
 obj-$(CONFIG_ENIC) := enic.o
 
 enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \
-       enic_res.o enic_dev.o enic_pp.o vnic_dev.o vnic_rq.o vnic_vic.o
+       enic_res.o enic_dev.o enic_pp.o vnic_dev.o vnic_rq.o vnic_vic.o \
+       enic_ethtool.o enic_api.o
 
index afe9b1662b8cef8c2ba09c73febdca3583f2642a..be167318015a47aa63c09164293cc64f0939c387 100644 (file)
@@ -32,8 +32,8 @@
 
 #define DRV_NAME               "enic"
 #define DRV_DESCRIPTION                "Cisco VIC Ethernet NIC Driver"
-#define DRV_VERSION            "2.1.1.39"
-#define DRV_COPYRIGHT          "Copyright 2008-2011 Cisco Systems, Inc"
+#define DRV_VERSION            "2.1.1.43"
+#define DRV_COPYRIGHT          "Copyright 2008-2013 Cisco Systems, Inc"
 
 #define ENIC_BARS_MAX          6
 
@@ -96,6 +96,7 @@ struct enic {
 #ifdef CONFIG_PCI_IOV
        u16 num_vfs;
 #endif
+       spinlock_t enic_api_lock;
        struct enic_port_profile *pp;
 
        /* work queue cache line section */
@@ -127,9 +128,57 @@ static inline struct device *enic_get_dev(struct enic *enic)
        return &(enic->pdev->dev);
 }
 
+static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
+{
+       return rq;
+}
+
+static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq)
+{
+       return enic->rq_count + wq;
+}
+
+static inline unsigned int enic_legacy_io_intr(void)
+{
+       return 0;
+}
+
+static inline unsigned int enic_legacy_err_intr(void)
+{
+       return 1;
+}
+
+static inline unsigned int enic_legacy_notify_intr(void)
+{
+       return 2;
+}
+
+static inline unsigned int enic_msix_rq_intr(struct enic *enic,
+       unsigned int rq)
+{
+       return enic->cq[enic_cq_rq(enic, rq)].interrupt_offset;
+}
+
+static inline unsigned int enic_msix_wq_intr(struct enic *enic,
+       unsigned int wq)
+{
+       return enic->cq[enic_cq_wq(enic, wq)].interrupt_offset;
+}
+
+static inline unsigned int enic_msix_err_intr(struct enic *enic)
+{
+       return enic->rq_count + enic->wq_count;
+}
+
+static inline unsigned int enic_msix_notify_intr(struct enic *enic)
+{
+       return enic->rq_count + enic->wq_count + 1;
+}
+
 void enic_reset_addr_lists(struct enic *enic);
 int enic_sriov_enabled(struct enic *enic);
 int enic_is_valid_vf(struct enic *enic, int vf);
 int enic_is_dynamic(struct enic *enic);
+void enic_set_ethtool_ops(struct net_device *netdev);
 
 #endif /* _ENIC_H_ */
diff --git a/drivers/net/ethernet/cisco/enic/enic_api.c b/drivers/net/ethernet/cisco/enic/enic_api.c
new file mode 100644 (file)
index 0000000..e13efbd
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2013 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
+
+#include "vnic_dev.h"
+#include "vnic_devcmd.h"
+
+#include "enic_res.h"
+#include "enic.h"
+#include "enic_api.h"
+
+int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,
+       enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait)
+{
+       int err;
+       struct enic *enic = netdev_priv(netdev);
+       struct vnic_dev *vdev = enic->vdev;
+
+       spin_lock(&enic->enic_api_lock);
+       spin_lock(&enic->devcmd_lock);
+
+       vnic_dev_cmd_proxy_by_index_start(vdev, vf);
+       err = vnic_dev_cmd(vdev, cmd, a0, a1, wait);
+       vnic_dev_cmd_proxy_end(vdev);
+
+       spin_unlock(&enic->devcmd_lock);
+       spin_unlock(&enic->enic_api_lock);
+
+       return err;
+}
+EXPORT_SYMBOL(enic_api_devcmd_proxy_by_index);
diff --git a/drivers/net/ethernet/cisco/enic/enic_api.h b/drivers/net/ethernet/cisco/enic/enic_api.h
new file mode 100644 (file)
index 0000000..6b9f925
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2013 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef __ENIC_API_H__
+#define __ENIC_API_H__
+
+#include <linux/netdevice.h>
+
+#include "vnic_dev.h"
+#include "vnic_devcmd.h"
+
+int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,
+       enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait);
+
+#endif
index 08bded051b93c1c0b3436056f20655fc08691a24..129b14a4efb088ef4c83212090a4c5a4125bee1a 100644 (file)
@@ -20,6 +20,7 @@
 #define _ENIC_DEV_H_
 
 #include "vnic_dev.h"
+#include "vnic_vic.h"
 
 /*
  * Calls the devcmd function given by argument vnicdevcmdfn.
diff --git a/drivers/net/ethernet/cisco/enic/enic_ethtool.c b/drivers/net/ethernet/cisco/enic/enic_ethtool.c
new file mode 100644 (file)
index 0000000..47e3562
--- /dev/null
@@ -0,0 +1,257 @@
+/**
+ * Copyright 2013 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <linux/netdevice.h>
+#include <linux/ethtool.h>
+
+#include "enic_res.h"
+#include "enic.h"
+#include "enic_dev.h"
+
+struct enic_stat {
+       char name[ETH_GSTRING_LEN];
+       unsigned int index;
+};
+
+#define ENIC_TX_STAT(stat) { \
+       .name = #stat, \
+       .index = offsetof(struct vnic_tx_stats, stat) / sizeof(u64) \
+}
+
+#define ENIC_RX_STAT(stat) { \
+       .name = #stat, \
+       .index = offsetof(struct vnic_rx_stats, stat) / sizeof(u64) \
+}
+
+static const struct enic_stat enic_tx_stats[] = {
+       ENIC_TX_STAT(tx_frames_ok),
+       ENIC_TX_STAT(tx_unicast_frames_ok),
+       ENIC_TX_STAT(tx_multicast_frames_ok),
+       ENIC_TX_STAT(tx_broadcast_frames_ok),
+       ENIC_TX_STAT(tx_bytes_ok),
+       ENIC_TX_STAT(tx_unicast_bytes_ok),
+       ENIC_TX_STAT(tx_multicast_bytes_ok),
+       ENIC_TX_STAT(tx_broadcast_bytes_ok),
+       ENIC_TX_STAT(tx_drops),
+       ENIC_TX_STAT(tx_errors),
+       ENIC_TX_STAT(tx_tso),
+};
+
+static const struct enic_stat enic_rx_stats[] = {
+       ENIC_RX_STAT(rx_frames_ok),
+       ENIC_RX_STAT(rx_frames_total),
+       ENIC_RX_STAT(rx_unicast_frames_ok),
+       ENIC_RX_STAT(rx_multicast_frames_ok),
+       ENIC_RX_STAT(rx_broadcast_frames_ok),
+       ENIC_RX_STAT(rx_bytes_ok),
+       ENIC_RX_STAT(rx_unicast_bytes_ok),
+       ENIC_RX_STAT(rx_multicast_bytes_ok),
+       ENIC_RX_STAT(rx_broadcast_bytes_ok),
+       ENIC_RX_STAT(rx_drop),
+       ENIC_RX_STAT(rx_no_bufs),
+       ENIC_RX_STAT(rx_errors),
+       ENIC_RX_STAT(rx_rss),
+       ENIC_RX_STAT(rx_crc_errors),
+       ENIC_RX_STAT(rx_frames_64),
+       ENIC_RX_STAT(rx_frames_127),
+       ENIC_RX_STAT(rx_frames_255),
+       ENIC_RX_STAT(rx_frames_511),
+       ENIC_RX_STAT(rx_frames_1023),
+       ENIC_RX_STAT(rx_frames_1518),
+       ENIC_RX_STAT(rx_frames_to_max),
+};
+
+static const unsigned int enic_n_tx_stats = ARRAY_SIZE(enic_tx_stats);
+static const unsigned int enic_n_rx_stats = ARRAY_SIZE(enic_rx_stats);
+
+static int enic_get_settings(struct net_device *netdev,
+       struct ethtool_cmd *ecmd)
+{
+       struct enic *enic = netdev_priv(netdev);
+
+       ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
+       ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
+       ecmd->port = PORT_FIBRE;
+       ecmd->transceiver = XCVR_EXTERNAL;
+
+       if (netif_carrier_ok(netdev)) {
+               ethtool_cmd_speed_set(ecmd, vnic_dev_port_speed(enic->vdev));
+               ecmd->duplex = DUPLEX_FULL;
+       } else {
+               ethtool_cmd_speed_set(ecmd, -1);
+               ecmd->duplex = -1;
+       }
+
+       ecmd->autoneg = AUTONEG_DISABLE;
+
+       return 0;
+}
+
+static void enic_get_drvinfo(struct net_device *netdev,
+       struct ethtool_drvinfo *drvinfo)
+{
+       struct enic *enic = netdev_priv(netdev);
+       struct vnic_devcmd_fw_info *fw_info;
+
+       enic_dev_fw_info(enic, &fw_info);
+
+       strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
+       strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version));
+       strlcpy(drvinfo->fw_version, fw_info->fw_version,
+               sizeof(drvinfo->fw_version));
+       strlcpy(drvinfo->bus_info, pci_name(enic->pdev),
+               sizeof(drvinfo->bus_info));
+}
+
+static void enic_get_strings(struct net_device *netdev, u32 stringset,
+       u8 *data)
+{
+       unsigned int i;
+
+       switch (stringset) {
+       case ETH_SS_STATS:
+               for (i = 0; i < enic_n_tx_stats; i++) {
+                       memcpy(data, enic_tx_stats[i].name, ETH_GSTRING_LEN);
+                       data += ETH_GSTRING_LEN;
+               }
+               for (i = 0; i < enic_n_rx_stats; i++) {
+                       memcpy(data, enic_rx_stats[i].name, ETH_GSTRING_LEN);
+                       data += ETH_GSTRING_LEN;
+               }
+               break;
+       }
+}
+
+static int enic_get_sset_count(struct net_device *netdev, int sset)
+{
+       switch (sset) {
+       case ETH_SS_STATS:
+               return enic_n_tx_stats + enic_n_rx_stats;
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+static void enic_get_ethtool_stats(struct net_device *netdev,
+       struct ethtool_stats *stats, u64 *data)
+{
+       struct enic *enic = netdev_priv(netdev);
+       struct vnic_stats *vstats;
+       unsigned int i;
+
+       enic_dev_stats_dump(enic, &vstats);
+
+       for (i = 0; i < enic_n_tx_stats; i++)
+               *(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].index];
+       for (i = 0; i < enic_n_rx_stats; i++)
+               *(data++) = ((u64 *)&vstats->rx)[enic_rx_stats[i].index];
+}
+
+static u32 enic_get_msglevel(struct net_device *netdev)
+{
+       struct enic *enic = netdev_priv(netdev);
+       return enic->msg_enable;
+}
+
+static void enic_set_msglevel(struct net_device *netdev, u32 value)
+{
+       struct enic *enic = netdev_priv(netdev);
+       enic->msg_enable = value;
+}
+
+static int enic_get_coalesce(struct net_device *netdev,
+       struct ethtool_coalesce *ecmd)
+{
+       struct enic *enic = netdev_priv(netdev);
+
+       ecmd->tx_coalesce_usecs = enic->tx_coalesce_usecs;
+       ecmd->rx_coalesce_usecs = enic->rx_coalesce_usecs;
+
+       return 0;
+}
+
+static int enic_set_coalesce(struct net_device *netdev,
+       struct ethtool_coalesce *ecmd)
+{
+       struct enic *enic = netdev_priv(netdev);
+       u32 tx_coalesce_usecs;
+       u32 rx_coalesce_usecs;
+       unsigned int i, intr;
+
+       tx_coalesce_usecs = min_t(u32, ecmd->tx_coalesce_usecs,
+               vnic_dev_get_intr_coal_timer_max(enic->vdev));
+       rx_coalesce_usecs = min_t(u32, ecmd->rx_coalesce_usecs,
+               vnic_dev_get_intr_coal_timer_max(enic->vdev));
+
+       switch (vnic_dev_get_intr_mode(enic->vdev)) {
+       case VNIC_DEV_INTR_MODE_INTX:
+               if (tx_coalesce_usecs != rx_coalesce_usecs)
+                       return -EINVAL;
+
+               intr = enic_legacy_io_intr();
+               vnic_intr_coalescing_timer_set(&enic->intr[intr],
+                       tx_coalesce_usecs);
+               break;
+       case VNIC_DEV_INTR_MODE_MSI:
+               if (tx_coalesce_usecs != rx_coalesce_usecs)
+                       return -EINVAL;
+
+               vnic_intr_coalescing_timer_set(&enic->intr[0],
+                       tx_coalesce_usecs);
+               break;
+       case VNIC_DEV_INTR_MODE_MSIX:
+               for (i = 0; i < enic->wq_count; i++) {
+                       intr = enic_msix_wq_intr(enic, i);
+                       vnic_intr_coalescing_timer_set(&enic->intr[intr],
+                               tx_coalesce_usecs);
+               }
+
+               for (i = 0; i < enic->rq_count; i++) {
+                       intr = enic_msix_rq_intr(enic, i);
+                       vnic_intr_coalescing_timer_set(&enic->intr[intr],
+                               rx_coalesce_usecs);
+               }
+
+               break;
+       default:
+               break;
+       }
+
+       enic->tx_coalesce_usecs = tx_coalesce_usecs;
+       enic->rx_coalesce_usecs = rx_coalesce_usecs;
+
+       return 0;
+}
+
+static const struct ethtool_ops enic_ethtool_ops = {
+       .get_settings = enic_get_settings,
+       .get_drvinfo = enic_get_drvinfo,
+       .get_msglevel = enic_get_msglevel,
+       .set_msglevel = enic_set_msglevel,
+       .get_link = ethtool_op_get_link,
+       .get_strings = enic_get_strings,
+       .get_sset_count = enic_get_sset_count,
+       .get_ethtool_stats = enic_get_ethtool_stats,
+       .get_coalesce = enic_get_coalesce,
+       .set_coalesce = enic_set_coalesce,
+};
+
+void enic_set_ethtool_ops(struct net_device *netdev)
+{
+       SET_ETHTOOL_OPS(netdev, &enic_ethtool_ops);
+}
index 992ec2ee64d919333ec1c28151a9a3acd52d25e0..bcf15b176f4147da05431b037354e2bfa9dc5734 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/if.h>
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
-#include <linux/ethtool.h>
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
@@ -73,57 +72,6 @@ MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 MODULE_DEVICE_TABLE(pci, enic_id_table);
 
-struct enic_stat {
-       char name[ETH_GSTRING_LEN];
-       unsigned int offset;
-};
-
-#define ENIC_TX_STAT(stat)     \
-       { .name = #stat, .offset = offsetof(struct vnic_tx_stats, stat) / 8 }
-#define ENIC_RX_STAT(stat)     \
-       { .name = #stat, .offset = offsetof(struct vnic_rx_stats, stat) / 8 }
-
-static const struct enic_stat enic_tx_stats[] = {
-       ENIC_TX_STAT(tx_frames_ok),
-       ENIC_TX_STAT(tx_unicast_frames_ok),
-       ENIC_TX_STAT(tx_multicast_frames_ok),
-       ENIC_TX_STAT(tx_broadcast_frames_ok),
-       ENIC_TX_STAT(tx_bytes_ok),
-       ENIC_TX_STAT(tx_unicast_bytes_ok),
-       ENIC_TX_STAT(tx_multicast_bytes_ok),
-       ENIC_TX_STAT(tx_broadcast_bytes_ok),
-       ENIC_TX_STAT(tx_drops),
-       ENIC_TX_STAT(tx_errors),
-       ENIC_TX_STAT(tx_tso),
-};
-
-static const struct enic_stat enic_rx_stats[] = {
-       ENIC_RX_STAT(rx_frames_ok),
-       ENIC_RX_STAT(rx_frames_total),
-       ENIC_RX_STAT(rx_unicast_frames_ok),
-       ENIC_RX_STAT(rx_multicast_frames_ok),
-       ENIC_RX_STAT(rx_broadcast_frames_ok),
-       ENIC_RX_STAT(rx_bytes_ok),
-       ENIC_RX_STAT(rx_unicast_bytes_ok),
-       ENIC_RX_STAT(rx_multicast_bytes_ok),
-       ENIC_RX_STAT(rx_broadcast_bytes_ok),
-       ENIC_RX_STAT(rx_drop),
-       ENIC_RX_STAT(rx_no_bufs),
-       ENIC_RX_STAT(rx_errors),
-       ENIC_RX_STAT(rx_rss),
-       ENIC_RX_STAT(rx_crc_errors),
-       ENIC_RX_STAT(rx_frames_64),
-       ENIC_RX_STAT(rx_frames_127),
-       ENIC_RX_STAT(rx_frames_255),
-       ENIC_RX_STAT(rx_frames_511),
-       ENIC_RX_STAT(rx_frames_1023),
-       ENIC_RX_STAT(rx_frames_1518),
-       ENIC_RX_STAT(rx_frames_to_max),
-};
-
-static const unsigned int enic_n_tx_stats = ARRAY_SIZE(enic_tx_stats);
-static const unsigned int enic_n_rx_stats = ARRAY_SIZE(enic_rx_stats);
-
 int enic_is_dynamic(struct enic *enic)
 {
        return enic->pdev->device == PCI_DEVICE_ID_CISCO_VIC_ENET_DYN;
@@ -148,222 +96,6 @@ int enic_is_valid_vf(struct enic *enic, int vf)
 #endif
 }
 
-static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
-{
-       return rq;
-}
-
-static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq)
-{
-       return enic->rq_count + wq;
-}
-
-static inline unsigned int enic_legacy_io_intr(void)
-{
-       return 0;
-}
-
-static inline unsigned int enic_legacy_err_intr(void)
-{
-       return 1;
-}
-
-static inline unsigned int enic_legacy_notify_intr(void)
-{
-       return 2;
-}
-
-static inline unsigned int enic_msix_rq_intr(struct enic *enic, unsigned int rq)
-{
-       return enic->cq[enic_cq_rq(enic, rq)].interrupt_offset;
-}
-
-static inline unsigned int enic_msix_wq_intr(struct enic *enic, unsigned int wq)
-{
-       return enic->cq[enic_cq_wq(enic, wq)].interrupt_offset;
-}
-
-static inline unsigned int enic_msix_err_intr(struct enic *enic)
-{
-       return enic->rq_count + enic->wq_count;
-}
-
-static inline unsigned int enic_msix_notify_intr(struct enic *enic)
-{
-       return enic->rq_count + enic->wq_count + 1;
-}
-
-static int enic_get_settings(struct net_device *netdev,
-       struct ethtool_cmd *ecmd)
-{
-       struct enic *enic = netdev_priv(netdev);
-
-       ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
-       ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
-       ecmd->port = PORT_FIBRE;
-       ecmd->transceiver = XCVR_EXTERNAL;
-
-       if (netif_carrier_ok(netdev)) {
-               ethtool_cmd_speed_set(ecmd, vnic_dev_port_speed(enic->vdev));
-               ecmd->duplex = DUPLEX_FULL;
-       } else {
-               ethtool_cmd_speed_set(ecmd, -1);
-               ecmd->duplex = -1;
-       }
-
-       ecmd->autoneg = AUTONEG_DISABLE;
-
-       return 0;
-}
-
-static void enic_get_drvinfo(struct net_device *netdev,
-       struct ethtool_drvinfo *drvinfo)
-{
-       struct enic *enic = netdev_priv(netdev);
-       struct vnic_devcmd_fw_info *fw_info;
-
-       enic_dev_fw_info(enic, &fw_info);
-
-       strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
-       strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version));
-       strlcpy(drvinfo->fw_version, fw_info->fw_version,
-               sizeof(drvinfo->fw_version));
-       strlcpy(drvinfo->bus_info, pci_name(enic->pdev),
-               sizeof(drvinfo->bus_info));
-}
-
-static void enic_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
-{
-       unsigned int i;
-
-       switch (stringset) {
-       case ETH_SS_STATS:
-               for (i = 0; i < enic_n_tx_stats; i++) {
-                       memcpy(data, enic_tx_stats[i].name, ETH_GSTRING_LEN);
-                       data += ETH_GSTRING_LEN;
-               }
-               for (i = 0; i < enic_n_rx_stats; i++) {
-                       memcpy(data, enic_rx_stats[i].name, ETH_GSTRING_LEN);
-                       data += ETH_GSTRING_LEN;
-               }
-               break;
-       }
-}
-
-static int enic_get_sset_count(struct net_device *netdev, int sset)
-{
-       switch (sset) {
-       case ETH_SS_STATS:
-               return enic_n_tx_stats + enic_n_rx_stats;
-       default:
-               return -EOPNOTSUPP;
-       }
-}
-
-static void enic_get_ethtool_stats(struct net_device *netdev,
-       struct ethtool_stats *stats, u64 *data)
-{
-       struct enic *enic = netdev_priv(netdev);
-       struct vnic_stats *vstats;
-       unsigned int i;
-
-       enic_dev_stats_dump(enic, &vstats);
-
-       for (i = 0; i < enic_n_tx_stats; i++)
-               *(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].offset];
-       for (i = 0; i < enic_n_rx_stats; i++)
-               *(data++) = ((u64 *)&vstats->rx)[enic_rx_stats[i].offset];
-}
-
-static u32 enic_get_msglevel(struct net_device *netdev)
-{
-       struct enic *enic = netdev_priv(netdev);
-       return enic->msg_enable;
-}
-
-static void enic_set_msglevel(struct net_device *netdev, u32 value)
-{
-       struct enic *enic = netdev_priv(netdev);
-       enic->msg_enable = value;
-}
-
-static int enic_get_coalesce(struct net_device *netdev,
-       struct ethtool_coalesce *ecmd)
-{
-       struct enic *enic = netdev_priv(netdev);
-
-       ecmd->tx_coalesce_usecs = enic->tx_coalesce_usecs;
-       ecmd->rx_coalesce_usecs = enic->rx_coalesce_usecs;
-
-       return 0;
-}
-
-static int enic_set_coalesce(struct net_device *netdev,
-       struct ethtool_coalesce *ecmd)
-{
-       struct enic *enic = netdev_priv(netdev);
-       u32 tx_coalesce_usecs;
-       u32 rx_coalesce_usecs;
-       unsigned int i, intr;
-
-       tx_coalesce_usecs = min_t(u32, ecmd->tx_coalesce_usecs,
-               vnic_dev_get_intr_coal_timer_max(enic->vdev));
-       rx_coalesce_usecs = min_t(u32, ecmd->rx_coalesce_usecs,
-               vnic_dev_get_intr_coal_timer_max(enic->vdev));
-
-       switch (vnic_dev_get_intr_mode(enic->vdev)) {
-       case VNIC_DEV_INTR_MODE_INTX:
-               if (tx_coalesce_usecs != rx_coalesce_usecs)
-                       return -EINVAL;
-
-               intr = enic_legacy_io_intr();
-               vnic_intr_coalescing_timer_set(&enic->intr[intr],
-                       tx_coalesce_usecs);
-               break;
-       case VNIC_DEV_INTR_MODE_MSI:
-               if (tx_coalesce_usecs != rx_coalesce_usecs)
-                       return -EINVAL;
-
-               vnic_intr_coalescing_timer_set(&enic->intr[0],
-                       tx_coalesce_usecs);
-               break;
-       case VNIC_DEV_INTR_MODE_MSIX:
-               for (i = 0; i < enic->wq_count; i++) {
-                       intr = enic_msix_wq_intr(enic, i);
-                       vnic_intr_coalescing_timer_set(&enic->intr[intr],
-                               tx_coalesce_usecs);
-               }
-
-               for (i = 0; i < enic->rq_count; i++) {
-                       intr = enic_msix_rq_intr(enic, i);
-                       vnic_intr_coalescing_timer_set(&enic->intr[intr],
-                               rx_coalesce_usecs);
-               }
-
-               break;
-       default:
-               break;
-       }
-
-       enic->tx_coalesce_usecs = tx_coalesce_usecs;
-       enic->rx_coalesce_usecs = rx_coalesce_usecs;
-
-       return 0;
-}
-
-static const struct ethtool_ops enic_ethtool_ops = {
-       .get_settings = enic_get_settings,
-       .get_drvinfo = enic_get_drvinfo,
-       .get_msglevel = enic_get_msglevel,
-       .set_msglevel = enic_set_msglevel,
-       .get_link = ethtool_op_get_link,
-       .get_strings = enic_get_strings,
-       .get_sset_count = enic_get_sset_count,
-       .get_ethtool_stats = enic_get_ethtool_stats,
-       .get_coalesce = enic_get_coalesce,
-       .set_coalesce = enic_set_coalesce,
-};
-
 static void enic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
 {
        struct enic *enic = vnic_dev_priv(wq->vdev);
@@ -2001,6 +1733,7 @@ static void enic_reset(struct work_struct *work)
 
        rtnl_lock();
 
+       spin_lock(&enic->enic_api_lock);
        enic_dev_hang_notify(enic);
        enic_stop(enic->netdev);
        enic_dev_hang_reset(enic);
@@ -2009,6 +1742,8 @@ static void enic_reset(struct work_struct *work)
        enic_set_rss_nic_cfg(enic);
        enic_dev_set_ig_vlan_rewrite_mode(enic);
        enic_open(enic->netdev);
+       spin_unlock(&enic->enic_api_lock);
+       call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev);
 
        rtnl_unlock();
 }
@@ -2421,6 +2156,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
         */
 
        spin_lock_init(&enic->devcmd_lock);
+       spin_lock_init(&enic->enic_api_lock);
 
        /*
         * Set ingress vlan rewrite mode before vnic initialization
@@ -2496,7 +2232,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                netdev->netdev_ops = &enic_netdev_ops;
 
        netdev->watchdog_timeo = 2 * HZ;
-       netdev->ethtool_ops = &enic_ethtool_ops;
+       enic_set_ethtool_ops(netdev);
 
        netdev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
        if (ENIC_SETTING(enic, LOOP)) {
index 25be2734c3feba3cf0d3fa631f64da360248fa80..69f60afd6577ec2d7c5c41540f81fbc59b7049a6 100644 (file)
@@ -47,6 +47,9 @@ static inline void enic_queue_wq_desc_ex(struct vnic_wq *wq,
        int offload_mode, int cq_entry, int sop, int eop, int loopback)
 {
        struct wq_enet_desc *desc = vnic_wq_next_desc(wq);
+       u8 desc_skip_cnt = 1;
+       u8 compressed_send = 0;
+       u64 wrid = 0;
 
        wq_enet_desc_enc(desc,
                (u64)dma_addr | VNIC_PADDR_TARGET,
@@ -59,7 +62,8 @@ static inline void enic_queue_wq_desc_ex(struct vnic_wq *wq,
                (u16)vlan_tag,
                (u8)loopback);
 
-       vnic_wq_post(wq, os_buf, dma_addr, len, sop, eop);
+       vnic_wq_post(wq, os_buf, dma_addr, len, sop, eop, desc_skip_cnt,
+                       (u8)cq_entry, compressed_send, wrid);
 }
 
 static inline void enic_queue_wq_desc_cont(struct vnic_wq *wq,
@@ -120,6 +124,7 @@ static inline void enic_queue_rq_desc(struct vnic_rq *rq,
        dma_addr_t dma_addr, unsigned int len)
 {
        struct rq_enet_desc *desc = vnic_rq_next_desc(rq);
+       u64 wrid = 0;
        u8 type = os_buf_index ?
                RQ_ENET_TYPE_NOT_SOP : RQ_ENET_TYPE_ONLY_SOP;
 
@@ -127,7 +132,7 @@ static inline void enic_queue_rq_desc(struct vnic_rq *rq,
                (u64)dma_addr | VNIC_PADDR_TARGET,
                type, (u16)len);
 
-       vnic_rq_post(rq, os_buf, os_buf_index, dma_addr, len);
+       vnic_rq_post(rq, os_buf, os_buf_index, dma_addr, len, wrid);
 }
 
 struct enic;
index 23d555255cf8ed99ef3c949ceeb0c3b42822ff9b..b9a0d78fd6391698a15a169cf206ec27b098b2c0 100644 (file)
@@ -281,11 +281,25 @@ enum vnic_devcmd_cmd {
         *              0 if no VIF-CONFIG-INFO TLV was ever received. */
        CMD_CONFIG_INFO_GET     = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 44),
 
+       /* INT13 API: (u64)a0=paddr to vnic_int13_params struct
+        *            (u32)a1=INT13_CMD_xxx
+        */
+       CMD_INT13_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 45),
+
+       /* Set default vlan:
+        * in: (u16)a0=new default vlan
+        *     (u16)a1=zero for overriding vlan with param a0,
+        *                     non-zero for resetting vlan to the default
+        * out: (u16)a0=old default vlan
+        */
+       CMD_SET_DEFAULT_VLAN = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 46),
+
        /* init_prov_info2:
         * Variant of CMD_INIT_PROV_INFO, where it will not try to enable
         * the vnic until CMD_ENABLE2 is issued.
         *     (u64)a0=paddr of vnic_devcmd_provinfo
-        *     (u32)a1=sizeof provision info */
+        *     (u32)a1=sizeof provision info
+        */
        CMD_INIT_PROV_INFO2  = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 47),
 
        /* enable2:
@@ -339,16 +353,57 @@ enum vnic_devcmd_cmd {
        CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50),
 
        /*
-        * cmd_set_mac_addr
-        *      set mac address
+        * Set the predefined mac address as default
         * in:
         *   (u48)a0 = mac addr
-        *
         */
        CMD_SET_MAC_ADDR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 55),
+
+       /* Update the provisioning info of the given VIF
+        *     (u64)a0=paddr of vnic_devcmd_provinfo
+        *     (u32)a1=sizeof provision info
+        */
+       CMD_PROV_INFO_UPDATE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 56),
+
+       /* Add a filter.
+        * in: (u64) a0= filter address
+        *     (u32) a1= size of filter
+        * out: (u32) a0=filter identifier
+        */
+       CMD_ADD_FILTER = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ENET, 58),
+
+       /* Delete a filter.
+        * in: (u32) a0=filter identifier
+        */
+       CMD_DEL_FILTER = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 59),
+
+       /* Enable a Queue Pair in User space NIC
+        * in: (u32) a0=Queue Pair number
+        *     (u32) a1= command
+        */
+       CMD_QP_ENABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 60),
+
+       /* Disable a Queue Pair in User space NIC
+        * in: (u32) a0=Queue Pair number
+        *     (u32) a1= command
+        */
+       CMD_QP_DISABLE = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 61),
+
+       /* Stats dump Queue Pair in User space NIC
+        * in: (u32) a0=Queue Pair number
+        *     (u64) a1=host buffer addr for status dump
+        *     (u32) a2=length of the buffer
+        */
+       CMD_QP_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 62),
+
+       /* Clear stats for Queue Pair in User space NIC
+        * in: (u32) a0=Queue Pair number
+        */
+       CMD_QP_STATS_CLEAR = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 63),
 };
 
 /* CMD_ENABLE2 flags */
+#define CMD_ENABLE2_STANDBY 0x0
 #define CMD_ENABLE2_ACTIVE  0x1
 
 /* flags for CMD_OPEN */
@@ -364,6 +419,9 @@ enum vnic_devcmd_cmd {
 #define CMD_PFILTER_PROMISCUOUS                0x08
 #define CMD_PFILTER_ALL_MULTICAST      0x10
 
+/* Commands for CMD_QP_ENABLE/CM_QP_DISABLE */
+#define CMD_QP_RQWQ                     0x0
+
 /* rewrite modes for CMD_IG_VLAN_REWRITE_MODE */
 #define IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK              0
 #define IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN         1
@@ -390,6 +448,7 @@ enum vnic_devcmd_error {
        ERR_EMAXRES = 10,
        ERR_ENOTSUPPORTED = 11,
        ERR_EINPROGRESS = 12,
+       ERR_MAX
 };
 
 /*
@@ -435,6 +494,115 @@ struct vnic_devcmd_provinfo {
        u8 data[0];
 };
 
+/* These are used in flags field of different filters to denote
+ * valid fields used.
+ */
+#define FILTER_FIELD_VALID(fld) (1 << (fld - 1))
+
+#define FILTER_FIELDS_USNIC ( \
+                       FILTER_FIELD_VALID(1) | \
+                       FILTER_FIELD_VALID(2) | \
+                       FILTER_FIELD_VALID(3) | \
+                       FILTER_FIELD_VALID(4))
+
+#define FILTER_FIELDS_IPV4_5TUPLE ( \
+                       FILTER_FIELD_VALID(1) | \
+                       FILTER_FIELD_VALID(2) | \
+                       FILTER_FIELD_VALID(3) | \
+                       FILTER_FIELD_VALID(4) | \
+                       FILTER_FIELD_VALID(5))
+
+#define FILTER_FIELDS_MAC_VLAN ( \
+                       FILTER_FIELD_VALID(1) | \
+                       FILTER_FIELD_VALID(2))
+
+#define FILTER_FIELD_USNIC_VLAN    FILTER_FIELD_VALID(1)
+#define FILTER_FIELD_USNIC_ETHTYPE FILTER_FIELD_VALID(2)
+#define FILTER_FIELD_USNIC_PROTO   FILTER_FIELD_VALID(3)
+#define FILTER_FIELD_USNIC_ID      FILTER_FIELD_VALID(4)
+
+struct filter_usnic_id {
+       u32 flags;
+       u16 vlan;
+       u16 ethtype;
+       u8 proto_version;
+       u32 usnic_id;
+} __packed;
+
+#define FILTER_FIELD_5TUP_PROTO  FILTER_FIELD_VALID(1)
+#define FILTER_FIELD_5TUP_SRC_AD FILTER_FIELD_VALID(2)
+#define FILTER_FIELD_5TUP_DST_AD FILTER_FIELD_VALID(3)
+#define FILTER_FIELD_5TUP_SRC_PT FILTER_FIELD_VALID(4)
+#define FILTER_FIELD_5TUP_DST_PT FILTER_FIELD_VALID(5)
+
+/* Enums for the protocol field. */
+enum protocol_e {
+       PROTO_UDP = 0,
+       PROTO_TCP = 1,
+};
+
+struct filter_ipv4_5tuple {
+       u32 flags;
+       u32 protocol;
+       u32 src_addr;
+       u32 dst_addr;
+       u16 src_port;
+       u16 dst_port;
+} __packed;
+
+#define FILTER_FIELD_VMQ_VLAN   FILTER_FIELD_VALID(1)
+#define FILTER_FIELD_VMQ_MAC    FILTER_FIELD_VALID(2)
+
+struct filter_mac_vlan {
+       u32 flags;
+       u16 vlan;
+       u8 mac_addr[6];
+} __packed;
+
+/* Specifies the filter_action type. */
+enum {
+       FILTER_ACTION_RQ_STEERING = 0,
+       FILTER_ACTION_MAX
+};
+
+struct filter_action {
+       u32 type;
+       union {
+               u32 rq_idx;
+       } u;
+} __packed;
+
+/* Specifies the filter type. */
+enum filter_type {
+       FILTER_USNIC_ID = 0,
+       FILTER_IPV4_5TUPLE = 1,
+       FILTER_MAC_VLAN = 2,
+       FILTER_MAX
+};
+
+struct filter {
+       u32 type;
+       union {
+               struct filter_usnic_id usnic;
+               struct filter_ipv4_5tuple ipv4;
+               struct filter_mac_vlan mac_vlan;
+       } u;
+} __packed;
+
+enum {
+       CLSF_TLV_FILTER = 0,
+       CLSF_TLV_ACTION = 1,
+};
+
+/* Maximum size of buffer to CMD_ADD_FILTER */
+#define FILTER_MAX_BUF_SIZE 100
+
+struct filter_tlv {
+       u_int32_t type;
+       u_int32_t length;
+       u_int32_t val[0];
+};
+
 /*
  * Writing cmd register causes STAT_BUSY to get set in status register.
  * When cmd completes, STAT_BUSY will be cleared.
index 7e1488fc8ab28bc3ab6c5f6565e9cf61c70f62d9..36a2ed606c911f21355360fad81eb39b18162c59 100644 (file)
 static int vnic_rq_alloc_bufs(struct vnic_rq *rq)
 {
        struct vnic_rq_buf *buf;
-       struct vnic_dev *vdev;
        unsigned int i, j, count = rq->ring.desc_count;
        unsigned int blks = VNIC_RQ_BUF_BLKS_NEEDED(count);
 
-       vdev = rq->vdev;
-
        for (i = 0; i < blks; i++) {
                rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ(count), GFP_ATOMIC);
                if (!rq->bufs[i])
@@ -141,7 +138,7 @@ void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index,
        unsigned int error_interrupt_enable,
        unsigned int error_interrupt_offset)
 {
-       u32 fetch_index;
+       u32 fetch_index = 0;
 
        /* Use current fetch_index as the ring starting point */
        fetch_index = ioread32(&rq->ctrl->fetch_index);
index 2056586f4d4b02641ec9609e3858b3c0368822ff..ee7bc95af278c691acebb358341a9885017863f3 100644 (file)
@@ -72,6 +72,7 @@ struct vnic_rq_buf {
        unsigned int len;
        unsigned int index;
        void *desc;
+       uint64_t wr_id;
 };
 
 struct vnic_rq {
@@ -110,7 +111,8 @@ static inline unsigned int vnic_rq_next_index(struct vnic_rq *rq)
 
 static inline void vnic_rq_post(struct vnic_rq *rq,
        void *os_buf, unsigned int os_buf_index,
-       dma_addr_t dma_addr, unsigned int len)
+       dma_addr_t dma_addr, unsigned int len,
+       uint64_t wrid)
 {
        struct vnic_rq_buf *buf = rq->to_use;
 
@@ -118,6 +120,7 @@ static inline void vnic_rq_post(struct vnic_rq *rq,
        buf->os_buf_index = os_buf_index;
        buf->dma_addr = dma_addr;
        buf->len = len;
+       buf->wr_id = wrid;
 
        buf = buf->next;
        rq->to_use = buf;
index 5e0d7a2be9bc4a95c32864ba7fc25d14b0b5f3c9..3e6b8d54dafcbac2e7c628b850378b89cb8ab7fe 100644 (file)
 static int vnic_wq_alloc_bufs(struct vnic_wq *wq)
 {
        struct vnic_wq_buf *buf;
-       struct vnic_dev *vdev;
        unsigned int i, j, count = wq->ring.desc_count;
        unsigned int blks = VNIC_WQ_BUF_BLKS_NEEDED(count);
 
-       vdev = wq->vdev;
-
        for (i = 0; i < blks; i++) {
                wq->bufs[i] = kzalloc(VNIC_WQ_BUF_BLK_SZ(count), GFP_ATOMIC);
                if (!wq->bufs[i])
index 7dd937ac11c23e51fefdedf7ce72f70d7f2b76e9..2c6c70804a39edb475d4c97e1f3e617aad387ed4 100644 (file)
@@ -58,6 +58,10 @@ struct vnic_wq_buf {
        unsigned int index;
        int sop;
        void *desc;
+       uint64_t wr_id; /* Cookie */
+       uint8_t cq_entry; /* Gets completion event from hw */
+       uint8_t desc_skip_cnt; /* Num descs to occupy */
+       uint8_t compressed_send; /* Both hdr and payload in one desc */
 };
 
 /* Break the vnic_wq_buf allocations into blocks of 32/64 entries */
@@ -102,14 +106,20 @@ static inline void *vnic_wq_next_desc(struct vnic_wq *wq)
 
 static inline void vnic_wq_post(struct vnic_wq *wq,
        void *os_buf, dma_addr_t dma_addr,
-       unsigned int len, int sop, int eop)
+       unsigned int len, int sop, int eop,
+       uint8_t desc_skip_cnt, uint8_t cq_entry,
+       uint8_t compressed_send, uint64_t wrid)
 {
        struct vnic_wq_buf *buf = wq->to_use;
 
        buf->sop = sop;
+       buf->cq_entry = cq_entry;
+       buf->compressed_send = compressed_send;
+       buf->desc_skip_cnt = desc_skip_cnt;
        buf->os_buf = eop ? os_buf : NULL;
        buf->dma_addr = dma_addr;
        buf->len = len;
+       buf->wr_id = wrid;
 
        buf = buf->next;
        if (eop) {
@@ -123,7 +133,7 @@ static inline void vnic_wq_post(struct vnic_wq *wq,
        }
        wq->to_use = buf;
 
-       wq->ring.desc_avail--;
+       wq->ring.desc_avail -= desc_skip_cnt;
 }
 
 static inline void vnic_wq_service(struct vnic_wq *wq,
index c94152f1c6be5396b511902a28478bae1c00e442..4e8cfa2ac803abb13c9c692ef971618cc26d664b 100644 (file)
@@ -1304,7 +1304,9 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        struct tulip_private *tp;
        /* See note below on the multiport cards. */
-       static unsigned char last_phys_addr[6] = {0x00, 'L', 'i', 'n', 'u', 'x'};
+       static unsigned char last_phys_addr[ETH_ALEN] = {
+               0x00, 'L', 'i', 'n', 'u', 'x'
+       };
        static int last_irq;
        static int multiport_cnt;       /* For four-port boards w/one EEPROM */
        int i, irq;
@@ -1627,8 +1629,8 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                dev->dev_addr[i] = last_phys_addr[i] + 1;
 #if defined(CONFIG_SPARC)
                addr = of_get_property(dp, "local-mac-address", &len);
-               if (addr && len == 6)
-                       memcpy(dev->dev_addr, addr, 6);
+               if (addr && len == ETH_ALEN)
+                       memcpy(dev->dev_addr, addr, ETH_ALEN);
 #endif
 #if defined(__i386__) || defined(__x86_64__)   /* Patch up x86 BIOS bug. */
                if (last_irq)
index 50d9c631593090e8d2b335fcb4d947346091fa42..bf3bf6f22c998b7c7ef2563be2041737a15959fe 100644 (file)
@@ -469,6 +469,17 @@ static void sundance_reset(struct net_device *dev, unsigned long reset_cmd)
        }
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void sundance_poll_controller(struct net_device *dev)
+{
+       struct netdev_private *np = netdev_priv(dev);
+
+       disable_irq(np->pci_dev->irq);
+       intr_handler(np->pci_dev->irq, dev);
+       enable_irq(np->pci_dev->irq);
+}
+#endif
+
 static const struct net_device_ops netdev_ops = {
        .ndo_open               = netdev_open,
        .ndo_stop               = netdev_close,
@@ -480,6 +491,9 @@ static const struct net_device_ops netdev_ops = {
        .ndo_change_mtu         = change_mtu,
        .ndo_set_mac_address    = sundance_set_mac_addr,
        .ndo_validate_addr      = eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = sundance_poll_controller,
+#endif
 };
 
 static int sundance_probe1(struct pci_dev *pdev,
index c827b1b6b1ceb81c5d10bdc2db6fcea3192701a3..ace5050dba3877ca8a3fe4995469ee3d16837c55 100644 (file)
@@ -34,7 +34,7 @@
 #include "be_hw.h"
 #include "be_roce.h"
 
-#define DRV_VER                        "4.6.62.0u"
+#define DRV_VER                        "4.9.134.0u"
 #define DRV_NAME               "be2net"
 #define BE_NAME                        "Emulex BladeEngine2"
 #define BE3_NAME               "Emulex BladeEngine3"
@@ -99,14 +99,18 @@ static inline char *nic_name(struct pci_dev *pdev)
 #define MCC_Q_LEN              128     /* total size not to exceed 8 pages */
 #define MCC_CQ_LEN             256
 
-#define BE3_MAX_RSS_QS         8
 #define BE2_MAX_RSS_QS         4
-#define MAX_RSS_QS             BE3_MAX_RSS_QS
-#define MAX_RX_QS              (MAX_RSS_QS + 1) /* RSS qs + 1 def Rx */
+#define BE3_MAX_RSS_QS         16
+#define BE3_MAX_TX_QS          16
+#define BE3_MAX_EVT_QS         16
+
+#define MAX_RX_QS              32
+#define MAX_EVT_QS             32
+#define MAX_TX_QS              32
 
-#define MAX_TX_QS              8
 #define MAX_ROCE_EQS           5
-#define MAX_MSIX_VECTORS       (MAX_RSS_QS + MAX_ROCE_EQS) /* RSS qs + RoCE */
+#define MAX_MSIX_VECTORS       32
+#define MIN_MSIX_VECTORS       1
 #define BE_TX_BUDGET           256
 #define BE_NAPI_WEIGHT         64
 #define MAX_RX_POST            BE_NAPI_WEIGHT /* Frags posted at a time */
@@ -189,6 +193,7 @@ struct be_eq_obj {
        u32 cur_eqd;            /* in usecs */
 
        u8 idx;                 /* array index */
+       u8 msix_idx;
        u16 tx_budget;
        u16 spurious_intr;
        struct napi_struct napi;
@@ -352,6 +357,18 @@ struct phy_info {
        u32 supported;
 };
 
+struct be_resources {
+       u16 max_vfs;            /* Total VFs "really" supported by FW/HW */
+       u16 max_mcast_mac;
+       u16 max_tx_qs;
+       u16 max_rss_qs;
+       u16 max_rx_qs;
+       u16 max_uc_mac;         /* Max UC MACs programmable */
+       u16 max_vlans;          /* Number of vlans supported */
+       u16 max_evt_qs;
+       u32 if_cap_flags;
+};
+
 struct be_adapter {
        struct pci_dev *pdev;
        struct net_device *netdev;
@@ -369,18 +386,19 @@ struct be_adapter {
        spinlock_t mcc_lock;    /* For serializing mcc cmds to BE card */
        spinlock_t mcc_cq_lock;
 
-       u32 num_msix_vec;
-       u32 num_evt_qs;
-       struct be_eq_obj eq_obj[MAX_MSIX_VECTORS];
+       u16 cfg_num_qs;         /* configured via set-channels */
+       u16 num_evt_qs;
+       u16 num_msix_vec;
+       struct be_eq_obj eq_obj[MAX_EVT_QS];
        struct msix_entry msix_entries[MAX_MSIX_VECTORS];
        bool isr_registered;
 
        /* TX Rings */
-       u32 num_tx_qs;
+       u16 num_tx_qs;
        struct be_tx_obj tx_obj[MAX_TX_QS];
 
        /* Rx rings */
-       u32 num_rx_qs;
+       u16 num_rx_qs;
        struct be_rx_obj rx_obj[MAX_RX_QS];
        u32 big_page_size;      /* Compounded page size shared by rx wrbs */
 
@@ -430,8 +448,8 @@ struct be_adapter {
        u32 flash_status;
        struct completion flash_compl;
 
-       u32 num_vfs;            /* Number of VFs provisioned by PF driver */
-       u32 dev_num_vfs;        /* Number of VFs supported by HW */
+       struct be_resources res;        /* resources available for the func */
+       u16 num_vfs;                    /* Number of VFs provisioned by PF */
        u8 virtfn;
        struct be_vf_cfg *vf_cfg;
        bool be3_native;
@@ -446,21 +464,13 @@ struct be_adapter {
        u16 qnq_vid;
        u32 msg_enable;
        int be_get_temp_freq;
-       u16 max_mcast_mac;
-       u16 max_tx_queues;
-       u16 max_rss_queues;
-       u16 max_rx_queues;
-       u16 max_pmac_cnt;
-       u16 max_vlans;
-       u16 max_event_queues;
-       u32 if_cap_flags;
        u8 pf_number;
        u64 rss_flags;
 };
 
 #define be_physfn(adapter)             (!adapter->virtfn)
 #define        sriov_enabled(adapter)          (adapter->num_vfs > 0)
-#define        sriov_want(adapter)             (adapter->dev_num_vfs && num_vfs && \
+#define sriov_want(adapter)             (be_max_vfs(adapter) && num_vfs && \
                                         be_physfn(adapter))
 #define for_all_vfs(adapter, vf_cfg, i)                                        \
        for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \
@@ -469,6 +479,26 @@ struct be_adapter {
 #define ON                             1
 #define OFF                            0
 
+#define be_max_vlans(adapter)          (adapter->res.max_vlans)
+#define be_max_uc(adapter)             (adapter->res.max_uc_mac)
+#define be_max_mc(adapter)             (adapter->res.max_mcast_mac)
+#define be_max_vfs(adapter)            (adapter->res.max_vfs)
+#define be_max_rss(adapter)            (adapter->res.max_rss_qs)
+#define be_max_txqs(adapter)           (adapter->res.max_tx_qs)
+#define be_max_prio_txqs(adapter)      (adapter->res.max_prio_tx_qs)
+#define be_max_rxqs(adapter)           (adapter->res.max_rx_qs)
+#define be_max_eqs(adapter)            (adapter->res.max_evt_qs)
+#define be_if_cap_flags(adapter)       (adapter->res.if_cap_flags)
+
+static inline u16 be_max_qs(struct be_adapter *adapter)
+{
+       /* If no RSS, need atleast the one def RXQ */
+       u16 num = max_t(u16, be_max_rss(adapter), 1);
+
+       num = min(num, be_max_eqs(adapter));
+       return min_t(u16, num, num_online_cpus());
+}
+
 #define lancer_chip(adapter)   (adapter->pdev->device == OC_DEVICE_ID3 || \
                                 adapter->pdev->device == OC_DEVICE_ID4)
 
@@ -672,6 +702,8 @@ extern int be_load_fw(struct be_adapter *adapter, u8 *func);
 extern bool be_is_wol_supported(struct be_adapter *adapter);
 extern bool be_pause_supported(struct be_adapter *adapter);
 extern u32 be_get_fw_log_level(struct be_adapter *adapter);
+int be_update_queues(struct be_adapter *adapter);
+int be_poll(struct napi_struct *napi, int budget);
 
 /*
  * internal function to initialize-cleanup roce device.
index 6e6e0a117ee2fe16061ae8e0b77a51aaacd3336b..52c9085ba5a15af2fff3b5281a2eb655f6c4cab7 100644 (file)
@@ -258,7 +258,8 @@ static void be_async_grp5_evt_process(struct be_adapter *adapter,
                (struct be_async_event_grp5_pvid_state *)evt);
        break;
        default:
-               dev_warn(&adapter->pdev->dev, "Unknown grp5 event!\n");
+               dev_warn(&adapter->pdev->dev, "Unknown grp5 event 0x%x!\n",
+                        event_type);
                break;
        }
 }
@@ -279,7 +280,8 @@ static void be_async_dbg_evt_process(struct be_adapter *adapter,
                adapter->flags |= BE_FLAGS_QNQ_ASYNC_EVT_RCVD;
        break;
        default:
-               dev_warn(&adapter->pdev->dev, "Unknown debug event\n");
+               dev_warn(&adapter->pdev->dev, "Unknown debug event 0x%x!\n",
+                        event_type);
        break;
        }
 }
@@ -631,6 +633,12 @@ static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
        return &wrb->payload.sgl[0];
 }
 
+static inline void fill_wrb_tags(struct be_mcc_wrb *wrb,
+                                unsigned long addr)
+{
+       wrb->tag0 = addr & 0xFFFFFFFF;
+       wrb->tag1 = upper_32_bits(addr);
+}
 
 /* Don't touch the hdr after it's prepared */
 /* mem will be NULL for embedded commands */
@@ -639,17 +647,12 @@ static void be_wrb_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
                                struct be_mcc_wrb *wrb, struct be_dma_mem *mem)
 {
        struct be_sge *sge;
-       unsigned long addr = (unsigned long)req_hdr;
-       u64 req_addr = addr;
 
        req_hdr->opcode = opcode;
        req_hdr->subsystem = subsystem;
        req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr));
        req_hdr->version = 0;
-
-       wrb->tag0 = req_addr & 0xFFFFFFFF;
-       wrb->tag1 = upper_32_bits(req_addr);
-
+       fill_wrb_tags(wrb, (ulong) req_hdr);
        wrb->payload_length = cmd_len;
        if (mem) {
                wrb->embedded |= (1 & MCC_WRB_SGE_CNT_MASK) <<
@@ -676,31 +679,6 @@ static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages,
        }
 }
 
-/* Converts interrupt delay in microseconds to multiplier value */
-static u32 eq_delay_to_mult(u32 usec_delay)
-{
-#define MAX_INTR_RATE                  651042
-       const u32 round = 10;
-       u32 multiplier;
-
-       if (usec_delay == 0)
-               multiplier = 0;
-       else {
-               u32 interrupt_rate = 1000000 / usec_delay;
-               /* Max delay, corresponding to the lowest interrupt rate */
-               if (interrupt_rate == 0)
-                       multiplier = 1023;
-               else {
-                       multiplier = (MAX_INTR_RATE - interrupt_rate) * round;
-                       multiplier /= interrupt_rate;
-                       /* Round the multiplier to the closest value.*/
-                       multiplier = (multiplier + round/2) / round;
-                       multiplier = min(multiplier, (u32)1023);
-               }
-       }
-       return multiplier;
-}
-
 static inline struct be_mcc_wrb *wrb_from_mbox(struct be_adapter *adapter)
 {
        struct be_dma_mem *mbox_mem = &adapter->mbox_mem;
@@ -728,6 +706,78 @@ static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter)
        return wrb;
 }
 
+static bool use_mcc(struct be_adapter *adapter)
+{
+       return adapter->mcc_obj.q.created;
+}
+
+/* Must be used only in process context */
+static int be_cmd_lock(struct be_adapter *adapter)
+{
+       if (use_mcc(adapter)) {
+               spin_lock_bh(&adapter->mcc_lock);
+               return 0;
+       } else {
+               return mutex_lock_interruptible(&adapter->mbox_lock);
+       }
+}
+
+/* Must be used only in process context */
+static void be_cmd_unlock(struct be_adapter *adapter)
+{
+       if (use_mcc(adapter))
+               spin_unlock_bh(&adapter->mcc_lock);
+       else
+               return mutex_unlock(&adapter->mbox_lock);
+}
+
+static struct be_mcc_wrb *be_cmd_copy(struct be_adapter *adapter,
+                                     struct be_mcc_wrb *wrb)
+{
+       struct be_mcc_wrb *dest_wrb;
+
+       if (use_mcc(adapter)) {
+               dest_wrb = wrb_from_mccq(adapter);
+               if (!dest_wrb)
+                       return NULL;
+       } else {
+               dest_wrb = wrb_from_mbox(adapter);
+       }
+
+       memcpy(dest_wrb, wrb, sizeof(*wrb));
+       if (wrb->embedded & cpu_to_le32(MCC_WRB_EMBEDDED_MASK))
+               fill_wrb_tags(dest_wrb, (ulong) embedded_payload(wrb));
+
+       return dest_wrb;
+}
+
+/* Must be used only in process context */
+static int be_cmd_notify_wait(struct be_adapter *adapter,
+                             struct be_mcc_wrb *wrb)
+{
+       struct be_mcc_wrb *dest_wrb;
+       int status;
+
+       status = be_cmd_lock(adapter);
+       if (status)
+               return status;
+
+       dest_wrb = be_cmd_copy(adapter, wrb);
+       if (!dest_wrb)
+               return -EBUSY;
+
+       if (use_mcc(adapter))
+               status = be_mcc_notify_wait(adapter);
+       else
+               status = be_mbox_notify_wait(adapter);
+
+       if (!status)
+               memcpy(wrb, dest_wrb, sizeof(*wrb));
+
+       be_cmd_unlock(adapter);
+       return status;
+}
+
 /* Tell fw we're about to start firing cmds by writing a
  * special pattern across the wrb hdr; uses mbox
  */
@@ -788,13 +838,12 @@ int be_cmd_fw_clean(struct be_adapter *adapter)
        return status;
 }
 
-int be_cmd_eq_create(struct be_adapter *adapter,
-               struct be_queue_info *eq, int eq_delay)
+int be_cmd_eq_create(struct be_adapter *adapter, struct be_eq_obj *eqo)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_eq_create *req;
-       struct be_dma_mem *q_mem = &eq->dma_mem;
-       int status;
+       struct be_dma_mem *q_mem = &eqo->q.dma_mem;
+       int status, ver = 0;
 
        if (mutex_lock_interruptible(&adapter->mbox_lock))
                return -1;
@@ -805,15 +854,18 @@ int be_cmd_eq_create(struct be_adapter *adapter,
        be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
                OPCODE_COMMON_EQ_CREATE, sizeof(*req), wrb, NULL);
 
+       /* Support for EQ_CREATEv2 available only SH-R onwards */
+       if (!(BEx_chip(adapter) || lancer_chip(adapter)))
+               ver = 2;
+
+       req->hdr.version = ver;
        req->num_pages =  cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
 
        AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1);
        /* 4byte eqe*/
        AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0);
        AMAP_SET_BITS(struct amap_eq_context, count, req->context,
-                       __ilog2_u32(eq->len/256));
-       AMAP_SET_BITS(struct amap_eq_context, delaymult, req->context,
-                       eq_delay_to_mult(eq_delay));
+                     __ilog2_u32(eqo->q.len / 256));
        be_dws_cpu_to_le(req->context, sizeof(req->context));
 
        be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
@@ -821,8 +873,10 @@ int be_cmd_eq_create(struct be_adapter *adapter,
        status = be_mbox_notify_wait(adapter);
        if (!status) {
                struct be_cmd_resp_eq_create *resp = embedded_payload(wrb);
-               eq->id = le16_to_cpu(resp->eq_id);
-               eq->created = true;
+               eqo->q.id = le16_to_cpu(resp->eq_id);
+               eqo->msix_idx =
+                       (ver == 2) ? le16_to_cpu(resp->msix_idx) : eqo->idx;
+               eqo->q.created = true;
        }
 
        mutex_unlock(&adapter->mbox_lock);
@@ -1010,9 +1064,9 @@ static u32 be_encoded_q_len(int q_len)
        return len_encoded;
 }
 
-int be_cmd_mccq_ext_create(struct be_adapter *adapter,
-                       struct be_queue_info *mccq,
-                       struct be_queue_info *cq)
+static int be_cmd_mccq_ext_create(struct be_adapter *adapter,
+                               struct be_queue_info *mccq,
+                               struct be_queue_info *cq)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_mcc_ext_create *req;
@@ -1068,9 +1122,9 @@ int be_cmd_mccq_ext_create(struct be_adapter *adapter,
        return status;
 }
 
-int be_cmd_mccq_org_create(struct be_adapter *adapter,
-                       struct be_queue_info *mccq,
-                       struct be_queue_info *cq)
+static int be_cmd_mccq_org_create(struct be_adapter *adapter,
+                               struct be_queue_info *mccq,
+                               struct be_queue_info *cq)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_mcc_create *req;
@@ -1128,25 +1182,16 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
 
 int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
 {
-       struct be_mcc_wrb *wrb;
+       struct be_mcc_wrb wrb = {0};
        struct be_cmd_req_eth_tx_create *req;
        struct be_queue_info *txq = &txo->q;
        struct be_queue_info *cq = &txo->cq;
        struct be_dma_mem *q_mem = &txq->dma_mem;
        int status, ver = 0;
 
-       spin_lock_bh(&adapter->mcc_lock);
-
-       wrb = wrb_from_mccq(adapter);
-       if (!wrb) {
-               status = -EBUSY;
-               goto err;
-       }
-
-       req = embedded_payload(wrb);
-
+       req = embedded_payload(&wrb);
        be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH,
-               OPCODE_ETH_TX_CREATE, sizeof(*req), wrb, NULL);
+                               OPCODE_ETH_TX_CREATE, sizeof(*req), &wrb, NULL);
 
        if (lancer_chip(adapter)) {
                req->hdr.version = 1;
@@ -1164,12 +1209,11 @@ int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
        req->cq_id = cpu_to_le16(cq->id);
        req->queue_size = be_encoded_q_len(txq->len);
        be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
-
        ver = req->hdr.version;
 
-       status = be_mcc_notify_wait(adapter);
+       status = be_cmd_notify_wait(adapter, &wrb);
        if (!status) {
-               struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb);
+               struct be_cmd_resp_eth_tx_create *resp = embedded_payload(&wrb);
                txq->id = le16_to_cpu(resp->cid);
                if (ver == 2)
                        txo->db_offset = le32_to_cpu(resp->db_offset);
@@ -1178,9 +1222,6 @@ int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
                txq->created = true;
        }
 
-err:
-       spin_unlock_bh(&adapter->mcc_lock);
-
        return status;
 }
 
@@ -1309,40 +1350,32 @@ err:
 }
 
 /* Create an rx filtering policy configuration on an i/f
- * Uses MCCQ
+ * Will use MBOX only if MCCQ has not been created.
  */
 int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
                     u32 *if_handle, u32 domain)
 {
-       struct be_mcc_wrb *wrb;
+       struct be_mcc_wrb wrb = {0};
        struct be_cmd_req_if_create *req;
        int status;
 
-       spin_lock_bh(&adapter->mcc_lock);
-
-       wrb = wrb_from_mccq(adapter);
-       if (!wrb) {
-               status = -EBUSY;
-               goto err;
-       }
-       req = embedded_payload(wrb);
-
+       req = embedded_payload(&wrb);
        be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
-               OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req), wrb, NULL);
+               OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req), &wrb, NULL);
        req->hdr.domain = domain;
        req->capability_flags = cpu_to_le32(cap_flags);
        req->enable_flags = cpu_to_le32(en_flags);
-
        req->pmac_invalid = true;
 
-       status = be_mcc_notify_wait(adapter);
+       status = be_cmd_notify_wait(adapter, &wrb);
        if (!status) {
-               struct be_cmd_resp_if_create *resp = embedded_payload(wrb);
+               struct be_cmd_resp_if_create *resp = embedded_payload(&wrb);
                *if_handle = le32_to_cpu(resp->interface_id);
-       }
 
-err:
-       spin_unlock_bh(&adapter->mcc_lock);
+               /* Hack to retrieve VF's pmac-id on BE3 */
+               if (BE3_chip(adapter) && !be_physfn(adapter))
+                       adapter->pmac_id[0] = le32_to_cpu(resp->pmac_id);
+       }
        return status;
 }
 
@@ -1460,6 +1493,12 @@ static int be_mac_to_link_speed(int mac_speed)
                return 1000;
        case PHY_LINK_SPEED_10GBPS:
                return 10000;
+       case PHY_LINK_SPEED_20GBPS:
+               return 20000;
+       case PHY_LINK_SPEED_25GBPS:
+               return 25000;
+       case PHY_LINK_SPEED_40GBPS:
+               return 40000;
        }
        return 0;
 }
@@ -1520,7 +1559,7 @@ int be_cmd_get_die_temperature(struct be_adapter *adapter)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_get_cntl_addnl_attribs *req;
-       int status;
+       int status = 0;
 
        spin_lock_bh(&adapter->mcc_lock);
 
@@ -1785,8 +1824,7 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
                 */
                req->if_flags_mask |=
                        cpu_to_le32(BE_IF_FLAGS_MCAST_PROMISCUOUS &
-                                   adapter->if_cap_flags);
-
+                                   be_if_cap_flags(adapter));
                req->mcast_num = cpu_to_le32(netdev_mc_count(adapter->netdev));
                netdev_for_each_mc_addr(ha, adapter->netdev)
                        memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN);
@@ -2444,6 +2482,12 @@ int be_cmd_get_phy_info(struct be_adapter *adapter)
                        le16_to_cpu(resp_phy_info->fixed_speeds_supported);
                adapter->phy.misc_params =
                        le32_to_cpu(resp_phy_info->misc_params);
+
+               if (BE2_chip(adapter)) {
+                       adapter->phy.fixed_speeds_supported =
+                               BE_SUPPORTED_SPEED_10GBPS |
+                               BE_SUPPORTED_SPEED_1GBPS;
+               }
        }
        pci_free_consistent(adapter->pdev, cmd.size,
                                cmd.va, cmd.dma);
@@ -2606,9 +2650,44 @@ err:
        return status;
 }
 
-/* Uses synchronous MCCQ */
+/* Set privilege(s) for a function */
+int be_cmd_set_fn_privileges(struct be_adapter *adapter, u32 privileges,
+                            u32 domain)
+{
+       struct be_mcc_wrb *wrb;
+       struct be_cmd_req_set_fn_privileges *req;
+       int status;
+
+       spin_lock_bh(&adapter->mcc_lock);
+
+       wrb = wrb_from_mccq(adapter);
+       if (!wrb) {
+               status = -EBUSY;
+               goto err;
+       }
+
+       req = embedded_payload(wrb);
+       be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
+                              OPCODE_COMMON_SET_FN_PRIVILEGES, sizeof(*req),
+                              wrb, NULL);
+       req->hdr.domain = domain;
+       if (lancer_chip(adapter))
+               req->privileges_lancer = cpu_to_le32(privileges);
+       else
+               req->privileges = cpu_to_le32(privileges);
+
+       status = be_mcc_notify_wait(adapter);
+err:
+       spin_unlock_bh(&adapter->mcc_lock);
+       return status;
+}
+
+/* pmac_id_valid: true => pmac_id is supplied and MAC address is requested.
+ * pmac_id_valid: false => pmac_id or MAC address is requested.
+ *               If pmac_id is returned, pmac_id_valid is returned as true
+ */
 int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
-                            bool *pmac_id_active, u32 *pmac_id, u8 domain)
+                            bool *pmac_id_valid, u32 *pmac_id, u8 domain)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_get_mac_list *req;
@@ -2644,12 +2723,25 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
                               get_mac_list_cmd.size, wrb, &get_mac_list_cmd);
        req->hdr.domain = domain;
        req->mac_type = MAC_ADDRESS_TYPE_NETWORK;
-       req->perm_override = 1;
+       if (*pmac_id_valid) {
+               req->mac_id = cpu_to_le32(*pmac_id);
+               req->iface_id = cpu_to_le16(adapter->if_handle);
+               req->perm_override = 0;
+       } else {
+               req->perm_override = 1;
+       }
 
        status = be_mcc_notify_wait(adapter);
        if (!status) {
                struct be_cmd_resp_get_mac_list *resp =
                                                get_mac_list_cmd.va;
+
+               if (*pmac_id_valid) {
+                       memcpy(mac, resp->macid_macaddr.mac_addr_id.macaddr,
+                              ETH_ALEN);
+                       goto out;
+               }
+
                mac_count = resp->true_mac_count + resp->pseudo_mac_count;
                /* Mac list returned could contain one or more active mac_ids
                 * or one or more true or pseudo permanant mac addresses.
@@ -2667,14 +2759,14 @@ int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
                         * is 6 bytes
                         */
                        if (mac_addr_size == sizeof(u32)) {
-                               *pmac_id_active = true;
+                               *pmac_id_valid = true;
                                mac_id = mac_entry->mac_addr_id.s_mac_id.mac_id;
                                *pmac_id = le32_to_cpu(mac_id);
                                goto out;
                        }
                }
                /* If no active mac_id found, return first mac addr */
-               *pmac_id_active = false;
+               *pmac_id_valid = false;
                memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr,
                                                                ETH_ALEN);
        }
@@ -2686,6 +2778,41 @@ out:
        return status;
 }
 
+int be_cmd_get_active_mac(struct be_adapter *adapter, u32 curr_pmac_id, u8 *mac)
+{
+       bool active = true;
+
+       if (BEx_chip(adapter))
+               return be_cmd_mac_addr_query(adapter, mac, false,
+                                            adapter->if_handle, curr_pmac_id);
+       else
+               /* Fetch the MAC address using pmac_id */
+               return be_cmd_get_mac_from_list(adapter, mac, &active,
+                                               &curr_pmac_id, 0);
+}
+
+int be_cmd_get_perm_mac(struct be_adapter *adapter, u8 *mac)
+{
+       int status;
+       bool pmac_valid = false;
+
+       memset(mac, 0, ETH_ALEN);
+
+       if (BEx_chip(adapter)) {
+               if (be_physfn(adapter))
+                       status = be_cmd_mac_addr_query(adapter, mac, true, 0,
+                                                      0);
+               else
+                       status = be_cmd_mac_addr_query(adapter, mac, false,
+                                                      adapter->if_handle, 0);
+       } else {
+               status = be_cmd_get_mac_from_list(adapter, mac, &pmac_valid,
+                                                 NULL, 0);
+       }
+
+       return status;
+}
+
 /* Uses synchronous MCCQ */
 int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
                        u8 mac_count, u32 domain)
@@ -2729,6 +2856,25 @@ err:
        return status;
 }
 
+/* Wrapper to delete any active MACs and provision the new mac.
+ * Changes to MAC_LIST are allowed iff none of the MAC addresses in the
+ * current list are active.
+ */
+int be_cmd_set_mac(struct be_adapter *adapter, u8 *mac, int if_id, u32 dom)
+{
+       bool active_mac = false;
+       u8 old_mac[ETH_ALEN];
+       u32 pmac_id;
+       int status;
+
+       status = be_cmd_get_mac_from_list(adapter, old_mac, &active_mac,
+                                         &pmac_id, dom);
+       if (!status && active_mac)
+               be_cmd_pmac_del(adapter, if_id, pmac_id, dom);
+
+       return be_cmd_set_mac_list(adapter, mac, mac ? 1 : 0, dom);
+}
+
 int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid,
                        u32 domain, u16 intf_id)
 {
@@ -2967,30 +3113,63 @@ err:
        return status;
 }
 
-static struct be_nic_resource_desc *be_get_nic_desc(u8 *buf, u32 desc_count,
-                                                   u32 max_buf_size)
+static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count)
 {
-       struct be_nic_resource_desc *desc = (struct be_nic_resource_desc *)buf;
+       struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
        int i;
 
        for (i = 0; i < desc_count; i++) {
-               desc->desc_len = desc->desc_len ? : RESOURCE_DESC_SIZE;
-               if (((void *)desc + desc->desc_len) >
-                   (void *)(buf + max_buf_size))
-                       return NULL;
+               if (hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
+                   hdr->desc_type == NIC_RESOURCE_DESC_TYPE_V1)
+                       return (struct be_nic_res_desc *)hdr;
 
-               if (desc->desc_type == NIC_RESOURCE_DESC_TYPE_V0 ||
-                   desc->desc_type == NIC_RESOURCE_DESC_TYPE_V1)
-                       return desc;
-
-               desc = (void *)desc + desc->desc_len;
+               hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
+               hdr = (void *)hdr + hdr->desc_len;
        }
+       return NULL;
+}
 
+static struct be_pcie_res_desc *be_get_pcie_desc(u8 devfn, u8 *buf,
+                                                u32 desc_count)
+{
+       struct be_res_desc_hdr *hdr = (struct be_res_desc_hdr *)buf;
+       struct be_pcie_res_desc *pcie;
+       int i;
+
+       for (i = 0; i < desc_count; i++) {
+               if ((hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V0 ||
+                    hdr->desc_type == PCIE_RESOURCE_DESC_TYPE_V1)) {
+                       pcie = (struct be_pcie_res_desc *)hdr;
+                       if (pcie->pf_num == devfn)
+                               return pcie;
+               }
+
+               hdr->desc_len = hdr->desc_len ? : RESOURCE_DESC_SIZE_V0;
+               hdr = (void *)hdr + hdr->desc_len;
+       }
        return NULL;
 }
 
+static void be_copy_nic_desc(struct be_resources *res,
+                            struct be_nic_res_desc *desc)
+{
+       res->max_uc_mac = le16_to_cpu(desc->unicast_mac_count);
+       res->max_vlans = le16_to_cpu(desc->vlan_count);
+       res->max_mcast_mac = le16_to_cpu(desc->mcast_mac_count);
+       res->max_tx_qs = le16_to_cpu(desc->txq_count);
+       res->max_rss_qs = le16_to_cpu(desc->rssq_count);
+       res->max_rx_qs = le16_to_cpu(desc->rq_count);
+       res->max_evt_qs = le16_to_cpu(desc->eq_count);
+       /* Clear flags that driver is not interested in */
+       res->if_cap_flags = le32_to_cpu(desc->cap_flags) &
+                               BE_IF_CAP_FLAGS_WANT;
+       /* Need 1 RXQ as the default RXQ */
+       if (res->max_rss_qs && res->max_rss_qs == res->max_rx_qs)
+               res->max_rss_qs -= 1;
+}
+
 /* Uses Mbox */
-int be_cmd_get_func_config(struct be_adapter *adapter)
+int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_get_func_config *req;
@@ -3029,25 +3208,16 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
        if (!status) {
                struct be_cmd_resp_get_func_config *resp = cmd.va;
                u32 desc_count = le32_to_cpu(resp->desc_count);
-               struct be_nic_resource_desc *desc;
+               struct be_nic_res_desc *desc;
 
-               desc = be_get_nic_desc(resp->func_param, desc_count,
-                                      sizeof(resp->func_param));
+               desc = be_get_nic_desc(resp->func_param, desc_count);
                if (!desc) {
                        status = -EINVAL;
                        goto err;
                }
 
                adapter->pf_number = desc->pf_num;
-               adapter->max_pmac_cnt = le16_to_cpu(desc->unicast_mac_count);
-               adapter->max_vlans = le16_to_cpu(desc->vlan_count);
-               adapter->max_mcast_mac = le16_to_cpu(desc->mcast_mac_count);
-               adapter->max_tx_queues = le16_to_cpu(desc->txq_count);
-               adapter->max_rss_queues = le16_to_cpu(desc->rssq_count);
-               adapter->max_rx_queues = le16_to_cpu(desc->rq_count);
-
-               adapter->max_event_queues = le16_to_cpu(desc->eq_count);
-               adapter->if_cap_flags = le32_to_cpu(desc->cap_flags);
+               be_copy_nic_desc(res, desc);
        }
 err:
        mutex_unlock(&adapter->mbox_lock);
@@ -3057,8 +3227,8 @@ err:
 }
 
 /* Uses mbox */
-int be_cmd_get_profile_config_mbox(struct be_adapter *adapter,
-                                  u8 domain, struct be_dma_mem *cmd)
+static int be_cmd_get_profile_config_mbox(struct be_adapter *adapter,
+                                       u8 domain, struct be_dma_mem *cmd)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_get_profile_config *req;
@@ -3085,8 +3255,8 @@ int be_cmd_get_profile_config_mbox(struct be_adapter *adapter,
 }
 
 /* Uses sync mcc */
-int be_cmd_get_profile_config_mccq(struct be_adapter *adapter,
-                                  u8 domain, struct be_dma_mem *cmd)
+static int be_cmd_get_profile_config_mccq(struct be_adapter *adapter,
+                                       u8 domain, struct be_dma_mem *cmd)
 {
        struct be_mcc_wrb *wrb;
        struct be_cmd_req_get_profile_config *req;
@@ -3118,54 +3288,51 @@ err:
 }
 
 /* Uses sync mcc, if MCCQ is already created otherwise mbox */
-int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags,
-                             u16 *txq_count, u8 domain)
+int be_cmd_get_profile_config(struct be_adapter *adapter,
+                             struct be_resources *res, u8 domain)
 {
+       struct be_cmd_resp_get_profile_config *resp;
+       struct be_pcie_res_desc *pcie;
+       struct be_nic_res_desc *nic;
        struct be_queue_info *mccq = &adapter->mcc_obj.q;
        struct be_dma_mem cmd;
+       u32 desc_count;
        int status;
 
        memset(&cmd, 0, sizeof(struct be_dma_mem));
-       if (!lancer_chip(adapter))
-               cmd.size = sizeof(struct be_cmd_resp_get_profile_config_v1);
-       else
-               cmd.size = sizeof(struct be_cmd_resp_get_profile_config);
-       cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size,
-                                     &cmd.dma);
-       if (!cmd.va) {
-               dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
+       cmd.size = sizeof(struct be_cmd_resp_get_profile_config);
+       cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
+       if (!cmd.va)
                return -ENOMEM;
-       }
 
        if (!mccq->created)
                status = be_cmd_get_profile_config_mbox(adapter, domain, &cmd);
        else
                status = be_cmd_get_profile_config_mccq(adapter, domain, &cmd);
-       if (!status) {
-               struct be_cmd_resp_get_profile_config *resp = cmd.va;
-               u32 desc_count = le32_to_cpu(resp->desc_count);
-               struct be_nic_resource_desc *desc;
+       if (status)
+               goto err;
 
-               desc = be_get_nic_desc(resp->func_param, desc_count,
-                                      sizeof(resp->func_param));
+       resp = cmd.va;
+       desc_count = le32_to_cpu(resp->desc_count);
+
+       pcie =  be_get_pcie_desc(adapter->pdev->devfn, resp->func_param,
+                                desc_count);
+       if (pcie)
+               res->max_vfs = le16_to_cpu(pcie->num_vfs);
+
+       nic = be_get_nic_desc(resp->func_param, desc_count);
+       if (nic)
+               be_copy_nic_desc(res, nic);
 
-               if (!desc) {
-                       status = -EINVAL;
-                       goto err;
-               }
-               if (cap_flags)
-                       *cap_flags = le32_to_cpu(desc->cap_flags);
-               if (txq_count)
-                       *txq_count = le32_to_cpu(desc->txq_count);
-       }
 err:
        if (cmd.va)
-               pci_free_consistent(adapter->pdev, cmd.size,
-                                   cmd.va, cmd.dma);
+               pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
        return status;
 }
 
-/* Uses sync mcc */
+/* Currently only Lancer uses this command and it supports version 0 only
+ * Uses sync mcc
+ */
 int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
                              u8 domain)
 {
@@ -3186,12 +3353,10 @@ int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
        be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
                               OPCODE_COMMON_SET_PROFILE_CONFIG, sizeof(*req),
                               wrb, NULL);
-
        req->hdr.domain = domain;
        req->desc_count = cpu_to_le32(1);
-
-       req->nic_desc.desc_type = NIC_RESOURCE_DESC_TYPE_V0;
-       req->nic_desc.desc_len = RESOURCE_DESC_SIZE;
+       req->nic_desc.hdr.desc_type = NIC_RESOURCE_DESC_TYPE_V0;
+       req->nic_desc.hdr.desc_len = RESOURCE_DESC_SIZE_V0;
        req->nic_desc.flags = (1 << QUN) | (1 << IMM) | (1 << NOSV);
        req->nic_desc.pf_num = adapter->pf_number;
        req->nic_desc.vf_num = domain;
index 5228d88c5a024e8e20be18e4f9fec69de7865e42..52f3d4ca00565f08be6d24510095f1466fc2d5f7 100644 (file)
@@ -202,6 +202,7 @@ struct be_mcc_mailbox {
 #define OPCODE_COMMON_READ_TRANSRECV_DATA              73
 #define OPCODE_COMMON_GET_PORT_NAME                    77
 #define OPCODE_COMMON_SET_INTERRUPT_ENABLE             89
+#define OPCODE_COMMON_SET_FN_PRIVILEGES                        100
 #define OPCODE_COMMON_GET_PHY_DETAILS                  102
 #define OPCODE_COMMON_SET_DRIVER_FUNCTION_CAP          103
 #define OPCODE_COMMON_GET_CNTL_ADDITIONAL_ATTRIBUTES   121
@@ -306,7 +307,7 @@ struct be_cmd_req_eq_create {
 struct be_cmd_resp_eq_create {
        struct be_cmd_resp_hdr resp_hdr;
        u16 eq_id;              /* sword */
-       u16 rsvd0;              /* sword */
+       u16 msix_idx;           /* available only in v2 */
 } __packed;
 
 /******************** Mac query ***************************/
@@ -563,6 +564,12 @@ enum be_if_flags {
        BE_IF_FLAGS_MULTICAST = 0x1000
 };
 
+#define BE_IF_CAP_FLAGS_WANT (BE_IF_FLAGS_RSS | BE_IF_FLAGS_PROMISCUOUS |\
+                        BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_VLAN_PROMISCUOUS |\
+                        BE_IF_FLAGS_VLAN | BE_IF_FLAGS_MCAST_PROMISCUOUS |\
+                        BE_IF_FLAGS_PASS_L3L4_ERRORS | BE_IF_FLAGS_MULTICAST |\
+                        BE_IF_FLAGS_UNTAGGED)
+
 /* An RX interface is an object with one or more MAC addresses and
  * filtering capabilities. */
 struct be_cmd_req_if_create {
@@ -959,7 +966,10 @@ enum {
        PHY_LINK_SPEED_10MBPS = 0x1,
        PHY_LINK_SPEED_100MBPS = 0x2,
        PHY_LINK_SPEED_1GBPS = 0x3,
-       PHY_LINK_SPEED_10GBPS = 0x4
+       PHY_LINK_SPEED_10GBPS = 0x4,
+       PHY_LINK_SPEED_20GBPS = 0x5,
+       PHY_LINK_SPEED_25GBPS = 0x6,
+       PHY_LINK_SPEED_40GBPS = 0x7
 };
 
 struct be_cmd_resp_link_status {
@@ -1474,6 +1484,11 @@ struct be_cmd_resp_get_fn_privileges {
        u32 privilege_mask;
 };
 
+struct be_cmd_req_set_fn_privileges {
+       struct be_cmd_req_hdr hdr;
+       u32 privileges;         /* Used by BE3, SH-R */
+       u32 privileges_lancer;  /* Used by Lancer */
+};
 
 /******************** GET/SET_MACLIST  **************************/
 #define BE_MAX_MAC                     64
@@ -1703,11 +1718,13 @@ struct be_cmd_req_set_ext_fat_caps {
        struct be_fat_conf_params set_params;
 };
 
-#define RESOURCE_DESC_SIZE                     88
+#define RESOURCE_DESC_SIZE_V0                  72
+#define RESOURCE_DESC_SIZE_V1                  88
+#define PCIE_RESOURCE_DESC_TYPE_V0             0x40
 #define NIC_RESOURCE_DESC_TYPE_V0              0x41
+#define PCIE_RESOURCE_DESC_TYPE_V1             0x50
 #define NIC_RESOURCE_DESC_TYPE_V1              0x51
-#define MAX_RESOURCE_DESC                      4
-#define MAX_RESOURCE_DESC_V1                   32
+#define MAX_RESOURCE_DESC                      264
 
 /* QOS unit number */
 #define QUN                                    4
@@ -1716,9 +1733,30 @@ struct be_cmd_req_set_ext_fat_caps {
 /* No save */
 #define NOSV                                   7
 
-struct be_nic_resource_desc {
+struct be_res_desc_hdr {
        u8 desc_type;
        u8 desc_len;
+} __packed;
+
+struct be_pcie_res_desc {
+       struct be_res_desc_hdr hdr;
+       u8 rsvd0;
+       u8 flags;
+       u16 rsvd1;
+       u8 pf_num;
+       u8 rsvd2;
+       u32 rsvd3;
+       u8 sriov_state;
+       u8 pf_state;
+       u8 pf_type;
+       u8 rsvd4;
+       u16 num_vfs;
+       u16 rsvd5;
+       u32 rsvd6[17];
+} __packed;
+
+struct be_nic_res_desc {
+       struct be_res_desc_hdr hdr;
        u8 rsvd1;
        u8 flags;
        u8 vf_num;
@@ -1747,7 +1785,7 @@ struct be_nic_resource_desc {
        u8 wol_param;
        u16 rsvd7;
        u32 rsvd8[3];
-};
+} __packed;
 
 struct be_cmd_req_get_func_config {
        struct be_cmd_req_hdr hdr;
@@ -1756,7 +1794,7 @@ struct be_cmd_req_get_func_config {
 struct be_cmd_resp_get_func_config {
        struct be_cmd_resp_hdr hdr;
        u32 desc_count;
-       u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE];
+       u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE_V1];
 };
 
 #define ACTIVE_PROFILE_TYPE                    0x2
@@ -1768,26 +1806,20 @@ struct be_cmd_req_get_profile_config {
 };
 
 struct be_cmd_resp_get_profile_config {
-       struct be_cmd_req_hdr hdr;
-       u32 desc_count;
-       u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE];
-};
-
-struct be_cmd_resp_get_profile_config_v1 {
-       struct be_cmd_req_hdr hdr;
+       struct be_cmd_resp_hdr hdr;
        u32 desc_count;
-       u8 func_param[MAX_RESOURCE_DESC_V1 * RESOURCE_DESC_SIZE];
+       u8 func_param[MAX_RESOURCE_DESC * RESOURCE_DESC_SIZE_V1];
 };
 
 struct be_cmd_req_set_profile_config {
        struct be_cmd_req_hdr hdr;
        u32 rsvd;
        u32 desc_count;
-       struct be_nic_resource_desc nic_desc;
+       struct be_nic_res_desc nic_desc;
 };
 
 struct be_cmd_resp_set_profile_config {
-       struct be_cmd_req_hdr hdr;
+       struct be_cmd_resp_hdr hdr;
 };
 
 struct be_cmd_enable_disable_vf {
@@ -1836,8 +1868,7 @@ extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
                            u32 en_flags, u32 *if_handle, u32 domain);
 extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle,
                        u32 domain);
-extern int be_cmd_eq_create(struct be_adapter *adapter,
-                       struct be_queue_info *eq, int eq_delay);
+extern int be_cmd_eq_create(struct be_adapter *adapter, struct be_eq_obj *eqo);
 extern int be_cmd_cq_create(struct be_adapter *adapter,
                        struct be_queue_info *cq, struct be_queue_info *eq,
                        bool no_delay, int num_cqe_dma_coalesce);
@@ -1921,11 +1952,18 @@ extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size);
 extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf);
 extern int be_cmd_get_fn_privileges(struct be_adapter *adapter,
                                    u32 *privilege, u32 domain);
+extern int be_cmd_set_fn_privileges(struct be_adapter *adapter,
+                                   u32 privileges, u32 vf_num);
 extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
                                    bool *pmac_id_active, u32 *pmac_id,
                                    u8 domain);
+extern int be_cmd_get_active_mac(struct be_adapter *adapter, u32 pmac_id,
+                                u8 *mac);
+extern int be_cmd_get_perm_mac(struct be_adapter *adapter, u8 *mac);
 extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
                                                u8 mac_count, u32 domain);
+extern int be_cmd_set_mac(struct be_adapter *adapter, u8 *mac, int if_id,
+                         u32 dom);
 extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid,
                        u32 domain, u16 intf_id);
 extern int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid,
@@ -1942,10 +1980,10 @@ extern int lancer_initiate_dump(struct be_adapter *adapter);
 extern bool dump_present(struct be_adapter *adapter);
 extern int lancer_test_and_set_rdy_state(struct be_adapter *adapter);
 extern int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name);
-extern int be_cmd_get_func_config(struct be_adapter *adapter);
-extern int be_cmd_get_profile_config(struct be_adapter *adapter, u32 *cap_flags,
-                                    u16 *txq_count, u8 domain);
-
+int be_cmd_get_func_config(struct be_adapter *adapter,
+                          struct be_resources *res);
+int be_cmd_get_profile_config(struct be_adapter *adapter,
+                             struct be_resources *res, u8 domain);
 extern int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps,
                                     u8 domain);
 extern int be_cmd_get_if_id(struct be_adapter *adapter,
index 4f8c941217cc017495736129373fe5d2ba40db60..b440a1fac77b2883b3417eeab76861cc02ad42b9 100644 (file)
@@ -1119,6 +1119,29 @@ static int be_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
        return status;
 }
 
+static void be_get_channels(struct net_device *netdev,
+                           struct ethtool_channels *ch)
+{
+       struct be_adapter *adapter = netdev_priv(netdev);
+
+       ch->combined_count = adapter->num_evt_qs;
+       ch->max_combined = be_max_qs(adapter);
+}
+
+static int be_set_channels(struct net_device  *netdev,
+                          struct ethtool_channels *ch)
+{
+       struct be_adapter *adapter = netdev_priv(netdev);
+
+       if (ch->rx_count || ch->tx_count || ch->other_count ||
+           !ch->combined_count || ch->combined_count > be_max_qs(adapter))
+               return -EINVAL;
+
+       adapter->cfg_num_qs = ch->combined_count;
+
+       return be_update_queues(adapter);
+}
+
 const struct ethtool_ops be_ethtool_ops = {
        .get_settings = be_get_settings,
        .get_drvinfo = be_get_drvinfo,
@@ -1145,4 +1168,6 @@ const struct ethtool_ops be_ethtool_ops = {
        .self_test = be_self_test,
        .get_rxnfc = be_get_rxnfc,
        .set_rxnfc = be_set_rxnfc,
+       .get_channels = be_get_channels,
+       .set_channels = be_set_channels
 };
index 2df48bb0f1cab26350d30add2b5076761c30ecef..50116f8ed576c0ae76d051e63d0d767c2df2fb49 100644 (file)
@@ -247,54 +247,54 @@ void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, u16 num_popped)
 static int be_mac_addr_set(struct net_device *netdev, void *p)
 {
        struct be_adapter *adapter = netdev_priv(netdev);
+       struct device *dev = &adapter->pdev->dev;
        struct sockaddr *addr = p;
-       int status = 0;
-       u8 current_mac[ETH_ALEN];
-       u32 pmac_id = adapter->pmac_id[0];
-       bool active_mac = true;
+       int status;
+       u8 mac[ETH_ALEN];
+       u32 old_pmac_id = adapter->pmac_id[0], curr_pmac_id = 0;
 
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
 
-       /* For BE VF, MAC address is already activated by PF.
-        * Hence only operation left is updating netdev->devaddr.
-        * Update it if user is passing the same MAC which was used
-        * during configuring VF MAC from PF(Hypervisor).
+       /* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT
+        * privilege or if PF did not provision the new MAC address.
+        * On BE3, this cmd will always fail if the VF doesn't have the
+        * FILTMGMT privilege. This failure is OK, only if the PF programmed
+        * the MAC for the VF.
         */
-       if (!lancer_chip(adapter) && !be_physfn(adapter)) {
-               status = be_cmd_mac_addr_query(adapter, current_mac,
-                                              false, adapter->if_handle, 0);
-               if (!status && !memcmp(current_mac, addr->sa_data, ETH_ALEN))
-                       goto done;
-               else
-                       goto err;
-       }
+       status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
+                                adapter->if_handle, &adapter->pmac_id[0], 0);
+       if (!status) {
+               curr_pmac_id = adapter->pmac_id[0];
 
-       if (!memcmp(addr->sa_data, netdev->dev_addr, ETH_ALEN))
-               goto done;
+               /* Delete the old programmed MAC. This call may fail if the
+                * old MAC was already deleted by the PF driver.
+                */
+               if (adapter->pmac_id[0] != old_pmac_id)
+                       be_cmd_pmac_del(adapter, adapter->if_handle,
+                                       old_pmac_id, 0);
+       }
 
-       /* For Lancer check if any MAC is active.
-        * If active, get its mac id.
+       /* Decide if the new MAC is successfully activated only after
+        * querying the FW
         */
-       if (lancer_chip(adapter) && !be_physfn(adapter))
-               be_cmd_get_mac_from_list(adapter, current_mac, &active_mac,
-                                        &pmac_id, 0);
-
-       status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
-                                adapter->if_handle,
-                                &adapter->pmac_id[0], 0);
-
+       status = be_cmd_get_active_mac(adapter, curr_pmac_id, mac);
        if (status)
                goto err;
 
-       if (active_mac)
-               be_cmd_pmac_del(adapter, adapter->if_handle,
-                               pmac_id, 0);
-done:
+       /* The MAC change did not happen, either due to lack of privilege
+        * or PF didn't pre-provision.
+        */
+       if (memcmp(addr->sa_data, mac, ETH_ALEN)) {
+               status = -EPERM;
+               goto err;
+       }
+
        memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
+       dev_info(dev, "MAC address changed to %pM\n", mac);
        return 0;
 err:
-       dev_err(&adapter->pdev->dev, "MAC %pM set Failed\n", addr->sa_data);
+       dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data);
        return status;
 }
 
@@ -472,7 +472,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
        ACCESS_ONCE(*acc) = newacc;
 }
 
-void populate_erx_stats(struct be_adapter *adapter,
+static void populate_erx_stats(struct be_adapter *adapter,
                        struct be_rx_obj *rxo,
                        u32 erx_stat)
 {
@@ -782,16 +782,22 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
 
        if (vlan_tx_tag_present(skb))
                vlan_tag = be_get_tx_vlan_tag(adapter, skb);
-       else if (qnq_async_evt_rcvd(adapter) && adapter->pvid)
-               vlan_tag = adapter->pvid;
+
+       if (qnq_async_evt_rcvd(adapter) && adapter->pvid) {
+               if (!vlan_tag)
+                       vlan_tag = adapter->pvid;
+               /* f/w workaround to set skip_hw_vlan = 1, informs the F/W to
+                * skip VLAN insertion
+                */
+               if (skip_hw_vlan)
+                       *skip_hw_vlan = true;
+       }
 
        if (vlan_tag) {
                skb = __vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
                if (unlikely(!skb))
                        return skb;
                skb->vlan_tci = 0;
-               if (skip_hw_vlan)
-                       *skip_hw_vlan = true;
        }
 
        /* Insert the outer VLAN, if any */
@@ -995,7 +1001,7 @@ static int be_vid_config(struct be_adapter *adapter)
        if (adapter->promiscuous)
                return 0;
 
-       if (adapter->vlans_added > adapter->max_vlans)
+       if (adapter->vlans_added > be_max_vlans(adapter))
                goto set_vlan_promisc;
 
        /* Construct VLAN Table to give to HW */
@@ -1036,7 +1042,7 @@ static int be_vlan_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
                goto ret;
 
        adapter->vlan_tag[vid] = 1;
-       if (adapter->vlans_added <= (adapter->max_vlans + 1))
+       if (adapter->vlans_added <= (be_max_vlans(adapter) + 1))
                status = be_vid_config(adapter);
 
        if (!status)
@@ -1062,7 +1068,7 @@ static int be_vlan_rem_vid(struct net_device *netdev, __be16 proto, u16 vid)
                goto ret;
 
        adapter->vlan_tag[vid] = 0;
-       if (adapter->vlans_added <= adapter->max_vlans)
+       if (adapter->vlans_added <= be_max_vlans(adapter))
                status = be_vid_config(adapter);
 
        if (!status)
@@ -1095,7 +1101,7 @@ static void be_set_rx_mode(struct net_device *netdev)
 
        /* Enable multicast promisc if num configured exceeds what we support */
        if (netdev->flags & IFF_ALLMULTI ||
-           netdev_mc_count(netdev) > adapter->max_mcast_mac) {
+           netdev_mc_count(netdev) > be_max_mc(adapter)) {
                be_cmd_rx_filter(adapter, IFF_ALLMULTI, ON);
                goto done;
        }
@@ -1109,7 +1115,7 @@ static void be_set_rx_mode(struct net_device *netdev)
                                        adapter->pmac_id[i], 0);
                }
 
-               if (netdev_uc_count(netdev) > adapter->max_pmac_cnt) {
+               if (netdev_uc_count(netdev) > be_max_uc(adapter)) {
                        be_cmd_rx_filter(adapter, IFF_PROMISC, ON);
                        adapter->promiscuous = true;
                        goto done;
@@ -1140,9 +1146,6 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
        struct be_adapter *adapter = netdev_priv(netdev);
        struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
        int status;
-       bool active_mac = false;
-       u32 pmac_id;
-       u8 old_mac[ETH_ALEN];
 
        if (!sriov_enabled(adapter))
                return -EPERM;
@@ -1150,20 +1153,15 @@ static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
        if (!is_valid_ether_addr(mac) || vf >= adapter->num_vfs)
                return -EINVAL;
 
-       if (lancer_chip(adapter)) {
-               status = be_cmd_get_mac_from_list(adapter, old_mac, &active_mac,
-                                                 &pmac_id, vf + 1);
-               if (!status && active_mac)
-                       be_cmd_pmac_del(adapter, vf_cfg->if_handle,
-                                       pmac_id, vf + 1);
-
-               status = be_cmd_set_mac_list(adapter,  mac, 1, vf + 1);
-       } else {
-               status = be_cmd_pmac_del(adapter, vf_cfg->if_handle,
-                                        vf_cfg->pmac_id, vf + 1);
+       if (BEx_chip(adapter)) {
+               be_cmd_pmac_del(adapter, vf_cfg->if_handle, vf_cfg->pmac_id,
+                               vf + 1);
 
                status = be_cmd_pmac_add(adapter, mac, vf_cfg->if_handle,
                                         &vf_cfg->pmac_id, vf + 1);
+       } else {
+               status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle,
+                                       vf + 1);
        }
 
        if (status)
@@ -1484,8 +1482,9 @@ static void be_rx_compl_process(struct be_rx_obj *rxo,
 }
 
 /* Process the RX completion indicated by rxcp when GRO is enabled */
-void be_rx_compl_process_gro(struct be_rx_obj *rxo, struct napi_struct *napi,
-                            struct be_rx_compl_info *rxcp)
+static void be_rx_compl_process_gro(struct be_rx_obj *rxo,
+                                   struct napi_struct *napi,
+                                   struct be_rx_compl_info *rxcp)
 {
        struct be_adapter *adapter = rxo->adapter;
        struct be_rx_page_info *page_info;
@@ -1914,6 +1913,7 @@ static void be_evt_queues_destroy(struct be_adapter *adapter)
                if (eqo->q.created) {
                        be_eq_clean(eqo);
                        be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ);
+                       netif_napi_del(&eqo->napi);
                }
                be_queue_free(adapter, &eqo->q);
        }
@@ -1925,9 +1925,12 @@ static int be_evt_queues_create(struct be_adapter *adapter)
        struct be_eq_obj *eqo;
        int i, rc;
 
-       adapter->num_evt_qs = num_irqs(adapter);
+       adapter->num_evt_qs = min_t(u16, num_irqs(adapter),
+                                   adapter->cfg_num_qs);
 
        for_all_evt_queues(adapter, eqo, i) {
+               netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
+                              BE_NAPI_WEIGHT);
                eqo->adapter = adapter;
                eqo->tx_budget = BE_TX_BUDGET;
                eqo->idx = i;
@@ -1940,7 +1943,7 @@ static int be_evt_queues_create(struct be_adapter *adapter)
                if (rc)
                        return rc;
 
-               rc = be_cmd_eq_create(adapter, eq, eqo->cur_eqd);
+               rc = be_cmd_eq_create(adapter, eqo);
                if (rc)
                        return rc;
        }
@@ -2014,31 +2017,13 @@ static void be_tx_queues_destroy(struct be_adapter *adapter)
        }
 }
 
-static int be_num_txqs_want(struct be_adapter *adapter)
-{
-       if ((!lancer_chip(adapter) && sriov_want(adapter)) ||
-           be_is_mc(adapter) ||
-           (!lancer_chip(adapter) && !be_physfn(adapter)) ||
-           BE2_chip(adapter))
-               return 1;
-       else
-               return adapter->max_tx_queues;
-}
-
-static int be_tx_cqs_create(struct be_adapter *adapter)
+static int be_tx_qs_create(struct be_adapter *adapter)
 {
        struct be_queue_info *cq, *eq;
-       int status;
        struct be_tx_obj *txo;
-       u8 i;
+       int status, i;
 
-       adapter->num_tx_qs = be_num_txqs_want(adapter);
-       if (adapter->num_tx_qs != MAX_TX_QS) {
-               rtnl_lock();
-               netif_set_real_num_tx_queues(adapter->netdev,
-                       adapter->num_tx_qs);
-               rtnl_unlock();
-       }
+       adapter->num_tx_qs = min(adapter->num_evt_qs, be_max_txqs(adapter));
 
        for_all_tx_queues(adapter, txo, i) {
                cq = &txo->cq;
@@ -2054,16 +2039,7 @@ static int be_tx_cqs_create(struct be_adapter *adapter)
                status = be_cmd_cq_create(adapter, cq, eq, false, 3);
                if (status)
                        return status;
-       }
-       return 0;
-}
 
-static int be_tx_qs_create(struct be_adapter *adapter)
-{
-       struct be_tx_obj *txo;
-       int i, status;
-
-       for_all_tx_queues(adapter, txo, i) {
                status = be_queue_alloc(adapter, &txo->q, TX_Q_LEN,
                                        sizeof(struct be_eth_wrb));
                if (status)
@@ -2099,17 +2075,14 @@ static int be_rx_cqs_create(struct be_adapter *adapter)
        struct be_rx_obj *rxo;
        int rc, i;
 
-       /* We'll create as many RSS rings as there are irqs.
-        * But when there's only one irq there's no use creating RSS rings
+       /* We can create as many RSS rings as there are EQs. */
+       adapter->num_rx_qs = adapter->num_evt_qs;
+
+       /* We'll use RSS only if atleast 2 RSS rings are supported.
+        * When RSS is used, we'll need a default RXQ for non-IP traffic.
         */
-       adapter->num_rx_qs = (num_irqs(adapter) > 1) ?
-                               num_irqs(adapter) + 1 : 1;
-       if (adapter->num_rx_qs != MAX_RX_QS) {
-               rtnl_lock();
-               netif_set_real_num_rx_queues(adapter->netdev,
-                                            adapter->num_rx_qs);
-               rtnl_unlock();
-       }
+       if (adapter->num_rx_qs > 1)
+               adapter->num_rx_qs++;
 
        adapter->big_page_size = (1 << get_order(rx_frag_size)) * PAGE_SIZE;
        for_all_rx_queues(adapter, rxo, i) {
@@ -2373,38 +2346,24 @@ static void be_msix_disable(struct be_adapter *adapter)
        if (msix_enabled(adapter)) {
                pci_disable_msix(adapter->pdev);
                adapter->num_msix_vec = 0;
+               adapter->num_msix_roce_vec = 0;
        }
 }
 
-static uint be_num_rss_want(struct be_adapter *adapter)
-{
-       u32 num = 0;
-
-       if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) &&
-           (lancer_chip(adapter) ||
-            (!sriov_want(adapter) && be_physfn(adapter)))) {
-               num = adapter->max_rss_queues;
-               num = min_t(u32, num, (u32)netif_get_num_default_rss_queues());
-       }
-       return num;
-}
-
 static int be_msix_enable(struct be_adapter *adapter)
 {
-#define BE_MIN_MSIX_VECTORS            1
-       int i, status, num_vec, num_roce_vec = 0;
+       int i, status, num_vec;
        struct device *dev = &adapter->pdev->dev;
 
-       /* If RSS queues are not used, need a vec for default RX Q */
-       num_vec = min(be_num_rss_want(adapter), num_online_cpus());
-       if (be_roce_supported(adapter)) {
-               num_roce_vec = min_t(u32, MAX_ROCE_MSIX_VECTORS,
-                                       (num_online_cpus() + 1));
-               num_roce_vec = min(num_roce_vec, MAX_ROCE_EQS);
-               num_vec += num_roce_vec;
-               num_vec = min(num_vec, MAX_MSIX_VECTORS);
-       }
-       num_vec = max(num_vec, BE_MIN_MSIX_VECTORS);
+       /* If RoCE is supported, program the max number of NIC vectors that
+        * may be configured via set-channels, along with vectors needed for
+        * RoCe. Else, just program the number we'll use initially.
+        */
+       if (be_roce_supported(adapter))
+               num_vec = min_t(int, 2 * be_max_eqs(adapter),
+                               2 * num_online_cpus());
+       else
+               num_vec = adapter->cfg_num_qs;
 
        for (i = 0; i < num_vec; i++)
                adapter->msix_entries[i].entry = i;
@@ -2412,7 +2371,7 @@ static int be_msix_enable(struct be_adapter *adapter)
        status = pci_enable_msix(adapter->pdev, adapter->msix_entries, num_vec);
        if (status == 0) {
                goto done;
-       } else if (status >= BE_MIN_MSIX_VECTORS) {
+       } else if (status >= MIN_MSIX_VECTORS) {
                num_vec = status;
                status = pci_enable_msix(adapter->pdev, adapter->msix_entries,
                                         num_vec);
@@ -2421,30 +2380,29 @@ static int be_msix_enable(struct be_adapter *adapter)
        }
 
        dev_warn(dev, "MSIx enable failed\n");
+
        /* INTx is not supported in VFs, so fail probe if enable_msix fails */
        if (!be_physfn(adapter))
                return status;
        return 0;
 done:
-       if (be_roce_supported(adapter)) {
-               if (num_vec > num_roce_vec) {
-                       adapter->num_msix_vec = num_vec - num_roce_vec;
-                       adapter->num_msix_roce_vec =
-                               num_vec - adapter->num_msix_vec;
-               } else {
-                       adapter->num_msix_vec = num_vec;
-                       adapter->num_msix_roce_vec = 0;
-               }
-       } else
-               adapter->num_msix_vec = num_vec;
-       dev_info(dev, "enabled %d MSI-x vector(s)\n", adapter->num_msix_vec);
+       if (be_roce_supported(adapter) && num_vec > MIN_MSIX_VECTORS) {
+               adapter->num_msix_roce_vec = num_vec / 2;
+               dev_info(dev, "enabled %d MSI-x vector(s) for RoCE\n",
+                        adapter->num_msix_roce_vec);
+       }
+
+       adapter->num_msix_vec = num_vec - adapter->num_msix_roce_vec;
+
+       dev_info(dev, "enabled %d MSI-x vector(s) for NIC\n",
+                adapter->num_msix_vec);
        return 0;
 }
 
 static inline int be_msix_vec_get(struct be_adapter *adapter,
                                struct be_eq_obj *eqo)
 {
-       return adapter->msix_entries[eqo->idx].vector;
+       return adapter->msix_entries[eqo->msix_idx].vector;
 }
 
 static int be_msix_register(struct be_adapter *adapter)
@@ -2557,8 +2515,8 @@ static int be_close(struct net_device *netdev)
        /* Wait for all pending tx completions to arrive so that
         * all tx skbs are freed.
         */
-       be_tx_compl_clean(adapter);
        netif_tx_disable(netdev);
+       be_tx_compl_clean(adapter);
 
        be_rx_qs_destroy(adapter);
 
@@ -2729,13 +2687,13 @@ static int be_vf_eth_addr_config(struct be_adapter *adapter)
        be_vf_eth_addr_generate(adapter, mac);
 
        for_all_vfs(adapter, vf_cfg, vf) {
-               if (lancer_chip(adapter)) {
-                       status = be_cmd_set_mac_list(adapter,  mac, 1, vf + 1);
-               } else {
+               if (BEx_chip(adapter))
                        status = be_cmd_pmac_add(adapter, mac,
                                                 vf_cfg->if_handle,
                                                 &vf_cfg->pmac_id, vf + 1);
-               }
+               else
+                       status = be_cmd_set_mac(adapter, mac, vf_cfg->if_handle,
+                                               vf + 1);
 
                if (status)
                        dev_err(&adapter->pdev->dev,
@@ -2753,7 +2711,7 @@ static int be_vfs_mac_query(struct be_adapter *adapter)
        int status, vf;
        u8 mac[ETH_ALEN];
        struct be_vf_cfg *vf_cfg;
-       bool active;
+       bool active = false;
 
        for_all_vfs(adapter, vf_cfg, vf) {
                be_cmd_get_mac_from_list(adapter, mac, &active,
@@ -2782,11 +2740,12 @@ static void be_vf_clear(struct be_adapter *adapter)
        pci_disable_sriov(adapter->pdev);
 
        for_all_vfs(adapter, vf_cfg, vf) {
-               if (lancer_chip(adapter))
-                       be_cmd_set_mac_list(adapter, NULL, 0, vf + 1);
-               else
+               if (BEx_chip(adapter))
                        be_cmd_pmac_del(adapter, vf_cfg->if_handle,
                                        vf_cfg->pmac_id, vf + 1);
+               else
+                       be_cmd_set_mac(adapter, NULL, vf_cfg->if_handle,
+                                      vf + 1);
 
                be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1);
        }
@@ -2795,28 +2754,40 @@ done:
        adapter->num_vfs = 0;
 }
 
-static int be_clear(struct be_adapter *adapter)
+static void be_clear_queues(struct be_adapter *adapter)
 {
-       int i = 1;
+       be_mcc_queues_destroy(adapter);
+       be_rx_cqs_destroy(adapter);
+       be_tx_queues_destroy(adapter);
+       be_evt_queues_destroy(adapter);
+}
 
+static void be_cancel_worker(struct be_adapter *adapter)
+{
        if (adapter->flags & BE_FLAGS_WORKER_SCHEDULED) {
                cancel_delayed_work_sync(&adapter->work);
                adapter->flags &= ~BE_FLAGS_WORKER_SCHEDULED;
        }
+}
+
+static int be_clear(struct be_adapter *adapter)
+{
+       int i;
+
+       be_cancel_worker(adapter);
 
        if (sriov_enabled(adapter))
                be_vf_clear(adapter);
 
-       for (; adapter->uc_macs > 0; adapter->uc_macs--, i++)
+       /* delete the primary mac along with the uc-mac list */
+       for (i = 0; i < (adapter->uc_macs + 1); i++)
                be_cmd_pmac_del(adapter, adapter->if_handle,
-                       adapter->pmac_id[i], 0);
+                               adapter->pmac_id[i], 0);
+       adapter->uc_macs = 0;
 
        be_cmd_if_destroy(adapter, adapter->if_handle,  0);
 
-       be_mcc_queues_destroy(adapter);
-       be_rx_cqs_destroy(adapter);
-       be_tx_queues_destroy(adapter);
-       be_evt_queues_destroy(adapter);
+       be_clear_queues(adapter);
 
        kfree(adapter->pmac_id);
        adapter->pmac_id = NULL;
@@ -2827,6 +2798,7 @@ static int be_clear(struct be_adapter *adapter)
 
 static int be_vfs_if_create(struct be_adapter *adapter)
 {
+       struct be_resources res = {0};
        struct be_vf_cfg *vf_cfg;
        u32 cap_flags, en_flags, vf;
        int status;
@@ -2835,9 +2807,12 @@ static int be_vfs_if_create(struct be_adapter *adapter)
                    BE_IF_FLAGS_MULTICAST;
 
        for_all_vfs(adapter, vf_cfg, vf) {
-               if (!BE3_chip(adapter))
-                       be_cmd_get_profile_config(adapter, &cap_flags,
-                                                 NULL, vf + 1);
+               if (!BE3_chip(adapter)) {
+                       status = be_cmd_get_profile_config(adapter, &res,
+                                                          vf + 1);
+                       if (!status)
+                               cap_flags = res.if_cap_flags;
+               }
 
                /* If a FW profile exists, then cap_flags are updated */
                en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED |
@@ -2874,6 +2849,7 @@ static int be_vf_setup(struct be_adapter *adapter)
        u16 def_vlan, lnk_speed;
        int status, old_vfs, vf;
        struct device *dev = &adapter->pdev->dev;
+       u32 privileges;
 
        old_vfs = pci_num_vf(adapter->pdev);
        if (old_vfs) {
@@ -2882,10 +2858,10 @@ static int be_vf_setup(struct be_adapter *adapter)
                        dev_warn(dev, "Ignoring num_vfs=%d setting\n", num_vfs);
                adapter->num_vfs = old_vfs;
        } else {
-               if (num_vfs > adapter->dev_num_vfs)
+               if (num_vfs > be_max_vfs(adapter))
                        dev_info(dev, "Device supports %d VFs and not %d\n",
-                                adapter->dev_num_vfs, num_vfs);
-               adapter->num_vfs = min_t(u16, num_vfs, adapter->dev_num_vfs);
+                                be_max_vfs(adapter), num_vfs);
+               adapter->num_vfs = min_t(u16, num_vfs, be_max_vfs(adapter));
                if (!adapter->num_vfs)
                        return 0;
        }
@@ -2917,6 +2893,18 @@ static int be_vf_setup(struct be_adapter *adapter)
        }
 
        for_all_vfs(adapter, vf_cfg, vf) {
+               /* Allow VFs to programs MAC/VLAN filters */
+               status = be_cmd_get_fn_privileges(adapter, &privileges, vf + 1);
+               if (!status && !(privileges & BE_PRIV_FILTMGMT)) {
+                       status = be_cmd_set_fn_privileges(adapter,
+                                                         privileges |
+                                                         BE_PRIV_FILTMGMT,
+                                                         vf + 1);
+                       if (!status)
+                               dev_info(dev, "VF%d has FILTMGMT privilege\n",
+                                        vf);
+               }
+
                /* BE3 FW, by default, caps VF TX-rate to 100mbps.
                 * Allow full available bandwidth
                 */
@@ -2952,6 +2940,51 @@ err:
        return status;
 }
 
+/* On BE2/BE3 FW does not suggest the supported limits */
+static void BEx_get_resources(struct be_adapter *adapter,
+                             struct be_resources *res)
+{
+       struct pci_dev *pdev = adapter->pdev;
+       bool use_sriov = false;
+
+       if (BE3_chip(adapter) && be_physfn(adapter)) {
+               int max_vfs;
+
+               max_vfs = pci_sriov_get_totalvfs(pdev);
+               res->max_vfs = max_vfs > 0 ? min(MAX_VFS, max_vfs) : 0;
+               use_sriov = res->max_vfs && num_vfs;
+       }
+
+       if (be_physfn(adapter))
+               res->max_uc_mac = BE_UC_PMAC_COUNT;
+       else
+               res->max_uc_mac = BE_VF_UC_PMAC_COUNT;
+
+       if (adapter->function_mode & FLEX10_MODE)
+               res->max_vlans = BE_NUM_VLANS_SUPPORTED/8;
+       else
+               res->max_vlans = BE_NUM_VLANS_SUPPORTED;
+       res->max_mcast_mac = BE_MAX_MC;
+
+       if (BE2_chip(adapter) || use_sriov || be_is_mc(adapter) ||
+           !be_physfn(adapter))
+               res->max_tx_qs = 1;
+       else
+               res->max_tx_qs = BE3_MAX_TX_QS;
+
+       if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) &&
+           !use_sriov && be_physfn(adapter))
+               res->max_rss_qs = (adapter->be3_native) ?
+                                          BE3_MAX_RSS_QS : BE2_MAX_RSS_QS;
+       res->max_rx_qs = res->max_rss_qs + 1;
+
+       res->max_evt_qs = be_physfn(adapter) ? BE3_MAX_EVT_QS : 1;
+
+       res->if_cap_flags = BE_IF_CAP_FLAGS_WANT;
+       if (!(adapter->function_caps & BE_FUNCTION_CAPS_RSS))
+               res->if_cap_flags &= ~BE_IF_FLAGS_RSS;
+}
+
 static void be_setup_init(struct be_adapter *adapter)
 {
        adapter->vlan_prio_bmap = 0xff;
@@ -2965,118 +2998,56 @@ static void be_setup_init(struct be_adapter *adapter)
                adapter->cmd_privileges = MIN_PRIVILEGES;
 }
 
-static int be_get_mac_addr(struct be_adapter *adapter, u8 *mac, u32 if_handle,
-                          bool *active_mac, u32 *pmac_id)
+static int be_get_resources(struct be_adapter *adapter)
 {
-       int status = 0;
-
-       if (!is_zero_ether_addr(adapter->netdev->perm_addr)) {
-               memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN);
-               if (!lancer_chip(adapter) && !be_physfn(adapter))
-                       *active_mac = true;
-               else
-                       *active_mac = false;
+       struct device *dev = &adapter->pdev->dev;
+       struct be_resources res = {0};
+       int status;
 
-               return status;
+       if (BEx_chip(adapter)) {
+               BEx_get_resources(adapter, &res);
+               adapter->res = res;
        }
 
-       if (lancer_chip(adapter)) {
-               status = be_cmd_get_mac_from_list(adapter, mac,
-                                                 active_mac, pmac_id, 0);
-               if (*active_mac) {
-                       status = be_cmd_mac_addr_query(adapter, mac, false,
-                                                      if_handle, *pmac_id);
-               }
-       } else if (be_physfn(adapter)) {
-               /* For BE3, for PF get permanent MAC */
-               status = be_cmd_mac_addr_query(adapter, mac, true, 0, 0);
-               *active_mac = false;
-       } else {
-               /* For BE3, for VF get soft MAC assigned by PF*/
-               status = be_cmd_mac_addr_query(adapter, mac, false,
-                                              if_handle, 0);
-               *active_mac = true;
+       /* For BE3 only check if FW suggests a different max-txqs value */
+       if (BE3_chip(adapter)) {
+               status = be_cmd_get_profile_config(adapter, &res, 0);
+               if (!status && res.max_tx_qs)
+                       adapter->res.max_tx_qs =
+                               min(adapter->res.max_tx_qs, res.max_tx_qs);
        }
-       return status;
-}
-
-static void be_get_resources(struct be_adapter *adapter)
-{
-       u16 dev_num_vfs;
-       int pos, status;
-       bool profile_present = false;
-       u16 txq_count = 0;
 
+       /* For Lancer, SH etc read per-function resource limits from FW.
+        * GET_FUNC_CONFIG returns per function guaranteed limits.
+        * GET_PROFILE_CONFIG returns PCI-E related limits PF-pool limits
+        */
        if (!BEx_chip(adapter)) {
-               status = be_cmd_get_func_config(adapter);
-               if (!status)
-                       profile_present = true;
-       } else if (BE3_chip(adapter) && be_physfn(adapter)) {
-               be_cmd_get_profile_config(adapter, NULL, &txq_count, 0);
-       }
-
-       if (profile_present) {
-               /* Sanity fixes for Lancer */
-               adapter->max_pmac_cnt = min_t(u16, adapter->max_pmac_cnt,
-                                             BE_UC_PMAC_COUNT);
-               adapter->max_vlans = min_t(u16, adapter->max_vlans,
-                                          BE_NUM_VLANS_SUPPORTED);
-               adapter->max_mcast_mac = min_t(u16, adapter->max_mcast_mac,
-                                              BE_MAX_MC);
-               adapter->max_tx_queues = min_t(u16, adapter->max_tx_queues,
-                                              MAX_TX_QS);
-               adapter->max_rss_queues = min_t(u16, adapter->max_rss_queues,
-                                               BE3_MAX_RSS_QS);
-               adapter->max_event_queues = min_t(u16,
-                                                 adapter->max_event_queues,
-                                                 BE3_MAX_RSS_QS);
-
-               if (adapter->max_rss_queues &&
-                   adapter->max_rss_queues == adapter->max_rx_queues)
-                       adapter->max_rss_queues -= 1;
-
-               if (adapter->max_event_queues < adapter->max_rss_queues)
-                       adapter->max_rss_queues = adapter->max_event_queues;
-
-       } else {
-               if (be_physfn(adapter))
-                       adapter->max_pmac_cnt = BE_UC_PMAC_COUNT;
-               else
-                       adapter->max_pmac_cnt = BE_VF_UC_PMAC_COUNT;
-
-               if (adapter->function_mode & FLEX10_MODE)
-                       adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/8;
-               else
-                       adapter->max_vlans = BE_NUM_VLANS_SUPPORTED;
+               status = be_cmd_get_func_config(adapter, &res);
+               if (status)
+                       return status;
 
-               adapter->max_mcast_mac = BE_MAX_MC;
-               adapter->max_tx_queues = txq_count ? txq_count : MAX_TX_QS;
-               adapter->max_tx_queues = min_t(u16, adapter->max_tx_queues,
-                                              MAX_TX_QS);
-               adapter->max_rss_queues = (adapter->be3_native) ?
-                                          BE3_MAX_RSS_QS : BE2_MAX_RSS_QS;
-               adapter->max_event_queues = BE3_MAX_RSS_QS;
+               /* If RoCE may be enabled stash away half the EQs for RoCE */
+               if (be_roce_supported(adapter))
+                       res.max_evt_qs /= 2;
+               adapter->res = res;
 
-               adapter->if_cap_flags = BE_IF_FLAGS_UNTAGGED |
-                                       BE_IF_FLAGS_BROADCAST |
-                                       BE_IF_FLAGS_MULTICAST |
-                                       BE_IF_FLAGS_PASS_L3L4_ERRORS |
-                                       BE_IF_FLAGS_MCAST_PROMISCUOUS |
-                                       BE_IF_FLAGS_VLAN_PROMISCUOUS |
-                                       BE_IF_FLAGS_PROMISCUOUS;
+               if (be_physfn(adapter)) {
+                       status = be_cmd_get_profile_config(adapter, &res, 0);
+                       if (status)
+                               return status;
+                       adapter->res.max_vfs = res.max_vfs;
+               }
 
-               if (adapter->function_caps & BE_FUNCTION_CAPS_RSS)
-                       adapter->if_cap_flags |= BE_IF_FLAGS_RSS;
+               dev_info(dev, "Max: txqs %d, rxqs %d, rss %d, eqs %d, vfs %d\n",
+                        be_max_txqs(adapter), be_max_rxqs(adapter),
+                        be_max_rss(adapter), be_max_eqs(adapter),
+                        be_max_vfs(adapter));
+               dev_info(dev, "Max: uc-macs %d, mc-macs %d, vlans %d\n",
+                        be_max_uc(adapter), be_max_mc(adapter),
+                        be_max_vlans(adapter));
        }
 
-       pos = pci_find_ext_capability(adapter->pdev, PCI_EXT_CAP_ID_SRIOV);
-       if (pos) {
-               pci_read_config_word(adapter->pdev, pos + PCI_SRIOV_TOTAL_VF,
-                                    &dev_num_vfs);
-               if (BE3_chip(adapter))
-                       dev_num_vfs = min_t(u16, dev_num_vfs, MAX_VFS);
-               adapter->dev_num_vfs = dev_num_vfs;
-       }
+       return 0;
 }
 
 /* Routine to query per function resource limits */
@@ -3089,100 +3060,171 @@ static int be_get_config(struct be_adapter *adapter)
                                     &adapter->function_caps,
                                     &adapter->asic_rev);
        if (status)
-               goto err;
+               return status;
 
-       be_get_resources(adapter);
+       status = be_get_resources(adapter);
+       if (status)
+               return status;
 
        /* primary mac needs 1 pmac entry */
-       adapter->pmac_id = kcalloc(adapter->max_pmac_cnt + 1,
-                                  sizeof(u32), GFP_KERNEL);
-       if (!adapter->pmac_id) {
-               status = -ENOMEM;
-               goto err;
-       }
+       adapter->pmac_id = kcalloc(be_max_uc(adapter) + 1, sizeof(u32),
+                                  GFP_KERNEL);
+       if (!adapter->pmac_id)
+               return -ENOMEM;
 
-err:
-       return status;
+       /* Sanitize cfg_num_qs based on HW and platform limits */
+       adapter->cfg_num_qs = min(adapter->cfg_num_qs, be_max_qs(adapter));
+
+       return 0;
 }
 
-static int be_setup(struct be_adapter *adapter)
+static int be_mac_setup(struct be_adapter *adapter)
 {
-       struct device *dev = &adapter->pdev->dev;
-       u32 en_flags;
-       u32 tx_fc, rx_fc;
-       int status;
        u8 mac[ETH_ALEN];
-       bool active_mac;
+       int status;
 
-       be_setup_init(adapter);
+       if (is_zero_ether_addr(adapter->netdev->dev_addr)) {
+               status = be_cmd_get_perm_mac(adapter, mac);
+               if (status)
+                       return status;
 
-       if (!lancer_chip(adapter))
-               be_cmd_req_native_mode(adapter);
+               memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
+               memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
+       } else {
+               /* Maybe the HW was reset; dev_addr must be re-programmed */
+               memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN);
+       }
 
-       status = be_get_config(adapter);
+       /* On BE3 VFs this cmd may fail due to lack of privilege.
+        * Ignore the failure as in this case pmac_id is fetched
+        * in the IFACE_CREATE cmd.
+        */
+       be_cmd_pmac_add(adapter, mac, adapter->if_handle,
+                       &adapter->pmac_id[0], 0);
+       return 0;
+}
+
+static void be_schedule_worker(struct be_adapter *adapter)
+{
+       schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000));
+       adapter->flags |= BE_FLAGS_WORKER_SCHEDULED;
+}
+
+static int be_setup_queues(struct be_adapter *adapter)
+{
+       struct net_device *netdev = adapter->netdev;
+       int status;
+
+       status = be_evt_queues_create(adapter);
        if (status)
                goto err;
 
-       status = be_msix_enable(adapter);
+       status = be_tx_qs_create(adapter);
        if (status)
                goto err;
 
-       status = be_evt_queues_create(adapter);
+       status = be_rx_cqs_create(adapter);
        if (status)
                goto err;
 
-       status = be_tx_cqs_create(adapter);
+       status = be_mcc_queues_create(adapter);
        if (status)
                goto err;
 
-       status = be_rx_cqs_create(adapter);
+       status = netif_set_real_num_rx_queues(netdev, adapter->num_rx_qs);
        if (status)
                goto err;
 
-       status = be_mcc_queues_create(adapter);
+       status = netif_set_real_num_tx_queues(netdev, adapter->num_tx_qs);
        if (status)
                goto err;
 
-       be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0);
-       /* In UMC mode FW does not return right privileges.
-        * Override with correct privilege equivalent to PF.
+       return 0;
+err:
+       dev_err(&adapter->pdev->dev, "queue_setup failed\n");
+       return status;
+}
+
+int be_update_queues(struct be_adapter *adapter)
+{
+       struct net_device *netdev = adapter->netdev;
+       int status;
+
+       if (netif_running(netdev))
+               be_close(netdev);
+
+       be_cancel_worker(adapter);
+
+       /* If any vectors have been shared with RoCE we cannot re-program
+        * the MSIx table.
         */
-       if (be_is_mc(adapter))
-               adapter->cmd_privileges = MAX_PRIVILEGES;
+       if (!adapter->num_msix_roce_vec)
+               be_msix_disable(adapter);
 
-       en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
-                       BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
+       be_clear_queues(adapter);
 
-       if (adapter->function_caps & BE_FUNCTION_CAPS_RSS)
-               en_flags |= BE_IF_FLAGS_RSS;
+       if (!msix_enabled(adapter)) {
+               status = be_msix_enable(adapter);
+               if (status)
+                       return status;
+       }
 
-       en_flags = en_flags & adapter->if_cap_flags;
+       status = be_setup_queues(adapter);
+       if (status)
+               return status;
 
-       status = be_cmd_if_create(adapter, adapter->if_cap_flags, en_flags,
-                                 &adapter->if_handle, 0);
-       if (status != 0)
+       be_schedule_worker(adapter);
+
+       if (netif_running(netdev))
+               status = be_open(netdev);
+
+       return status;
+}
+
+static int be_setup(struct be_adapter *adapter)
+{
+       struct device *dev = &adapter->pdev->dev;
+       u32 tx_fc, rx_fc, en_flags;
+       int status;
+
+       be_setup_init(adapter);
+
+       if (!lancer_chip(adapter))
+               be_cmd_req_native_mode(adapter);
+
+       status = be_get_config(adapter);
+       if (status)
                goto err;
 
-       memset(mac, 0, ETH_ALEN);
-       active_mac = false;
-       status = be_get_mac_addr(adapter, mac, adapter->if_handle,
-                                &active_mac, &adapter->pmac_id[0]);
-       if (status != 0)
+       status = be_msix_enable(adapter);
+       if (status)
                goto err;
 
-       if (!active_mac) {
-               status = be_cmd_pmac_add(adapter, mac, adapter->if_handle,
-                                        &adapter->pmac_id[0], 0);
-               if (status != 0)
-                       goto err;
-       }
+       en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
+                  BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
+       if (adapter->function_caps & BE_FUNCTION_CAPS_RSS)
+               en_flags |= BE_IF_FLAGS_RSS;
+       en_flags = en_flags & be_if_cap_flags(adapter);
+       status = be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags,
+                                 &adapter->if_handle, 0);
+       if (status)
+               goto err;
 
-       if (is_zero_ether_addr(adapter->netdev->dev_addr)) {
-               memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
-               memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
-       }
+       /* Updating real_num_tx/rx_queues() requires rtnl_lock() */
+       rtnl_lock();
+       status = be_setup_queues(adapter);
+       rtnl_unlock();
+       if (status)
+               goto err;
 
-       status = be_tx_qs_create(adapter);
+       be_cmd_get_fn_privileges(adapter, &adapter->cmd_privileges, 0);
+       /* In UMC mode FW does not return right privileges.
+        * Override with correct privilege equivalent to PF.
+        */
+       if (be_is_mc(adapter))
+               adapter->cmd_privileges = MAX_PRIVILEGES;
+
+       status = be_mac_setup(adapter);
        if (status)
                goto err;
 
@@ -3199,8 +3241,8 @@ static int be_setup(struct be_adapter *adapter)
                be_cmd_set_flow_control(adapter, adapter->tx_fc,
                                        adapter->rx_fc);
 
-       if (be_physfn(adapter)) {
-               if (adapter->dev_num_vfs)
+       if (be_physfn(adapter) && num_vfs) {
+               if (be_max_vfs(adapter))
                        be_vf_setup(adapter);
                else
                        dev_warn(dev, "device doesn't support SRIOV\n");
@@ -3210,8 +3252,7 @@ static int be_setup(struct be_adapter *adapter)
        if (!status && be_pause_supported(adapter))
                adapter->phy.fc_autoneg = 1;
 
-       schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000));
-       adapter->flags |= BE_FLAGS_WORKER_SCHEDULED;
+       be_schedule_worker(adapter);
        return 0;
 err:
        be_clear(adapter);
@@ -3235,7 +3276,7 @@ static void be_netpoll(struct net_device *netdev)
 #endif
 
 #define FW_FILE_HDR_SIGN       "ServerEngines Corp. "
-char flash_cookie[2][16] =      {"*** SE FLAS", "H DIRECTORY *** "};
+static char flash_cookie[2][16] =      {"*** SE FLAS", "H DIRECTORY *** "};
 
 static bool be_flash_redboot(struct be_adapter *adapter,
                        const u8 *p, u32 img_start, int image_size,
@@ -3292,7 +3333,7 @@ static bool is_comp_in_ufi(struct be_adapter *adapter,
 
 }
 
-struct flash_section_info *get_fsec_info(struct be_adapter *adapter,
+static struct flash_section_info *get_fsec_info(struct be_adapter *adapter,
                                         int header_size,
                                         const struct firmware *fw)
 {
@@ -3777,8 +3818,6 @@ static const struct net_device_ops be_netdev_ops = {
 static void be_netdev_init(struct net_device *netdev)
 {
        struct be_adapter *adapter = netdev_priv(netdev);
-       struct be_eq_obj *eqo;
-       int i;
 
        netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 |
                NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
@@ -3801,9 +3840,6 @@ static void be_netdev_init(struct net_device *netdev)
        netdev->netdev_ops = &be_netdev_ops;
 
        SET_ETHTOOL_OPS(netdev, &be_ethtool_ops);
-
-       for_all_evt_queues(adapter, eqo, i)
-               netif_napi_add(netdev, &eqo->napi, be_poll, BE_NAPI_WEIGHT);
 }
 
 static void be_unmap_pci_bars(struct be_adapter *adapter)
@@ -4066,6 +4102,7 @@ static int be_get_initial_config(struct be_adapter *adapter)
        level = be_get_fw_log_level(adapter);
        adapter->msg_enable = level <= FW_LOG_LEVEL_DEFAULT ? NETIF_MSG_HW : 0;
 
+       adapter->cfg_num_qs = netif_get_num_default_rss_queues();
        return 0;
 }
 
@@ -4158,7 +4195,8 @@ static void be_worker(struct work_struct *work)
                        be_cmd_get_stats(adapter, &adapter->stats_cmd);
        }
 
-       if (MODULO(adapter->work_counter, adapter->be_get_temp_freq) == 0)
+       if (be_physfn(adapter) &&
+           MODULO(adapter->work_counter, adapter->be_get_temp_freq) == 0)
                be_cmd_get_die_temperature(adapter);
 
        for_all_rx_queues(adapter, rxo, i) {
@@ -4247,7 +4285,7 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
 
        status = pci_enable_pcie_error_reporting(pdev);
        if (status)
-               dev_err(&pdev->dev, "Could not use PCIe error reporting\n");
+               dev_info(&pdev->dev, "Could not use PCIe error reporting\n");
 
        status = be_ctrl_init(adapter);
        if (status)
index f3d126dcc104fa88c8385cb235449fdbf0cdd99e..9cd5415fe017dc359d2aae2e679eddc40e75f5e0 100644 (file)
@@ -60,7 +60,7 @@ static void _be_roce_dev_add(struct be_adapter *adapter)
                 */
                num_vec = adapter->num_msix_vec + adapter->num_msix_roce_vec;
                dev_info.intr_mode = BE_INTERRUPT_MODE_MSIX;
-               dev_info.msix.num_vectors = min(num_vec, MAX_ROCE_MSIX_VECTORS);
+               dev_info.msix.num_vectors = min(num_vec, MAX_MSIX_VECTORS);
                /* provide start index of the vector,
                 * so in case of linear usage,
                 * it can use the base as starting point.
@@ -93,7 +93,7 @@ void be_roce_dev_add(struct be_adapter *adapter)
        }
 }
 
-void _be_roce_dev_remove(struct be_adapter *adapter)
+static void _be_roce_dev_remove(struct be_adapter *adapter)
 {
        if (ocrdma_drv && ocrdma_drv->remove && adapter->ocrdma_dev)
                ocrdma_drv->remove(adapter->ocrdma_dev);
@@ -110,7 +110,7 @@ void be_roce_dev_remove(struct be_adapter *adapter)
        }
 }
 
-void _be_roce_dev_open(struct be_adapter *adapter)
+static void _be_roce_dev_open(struct be_adapter *adapter)
 {
        if (ocrdma_drv && adapter->ocrdma_dev &&
            ocrdma_drv->state_change_handler)
@@ -126,7 +126,7 @@ void be_roce_dev_open(struct be_adapter *adapter)
        }
 }
 
-void _be_roce_dev_close(struct be_adapter *adapter)
+static void _be_roce_dev_close(struct be_adapter *adapter)
 {
        if (ocrdma_drv && adapter->ocrdma_dev &&
            ocrdma_drv->state_change_handler)
index 27657299846337eafec3321f3b8e9c3afde72d8b..2cd1129e19af960185a3f706d9ab5ed165e409a7 100644 (file)
@@ -29,7 +29,7 @@ enum be_interrupt_mode {
        BE_INTERRUPT_MODE_MSI   = 2,
 };
 
-#define MAX_ROCE_MSIX_VECTORS   16
+#define MAX_MSIX_VECTORS               32
 struct be_dev_info {
        u8 __iomem *db;
        u64 unmapped_db;
@@ -45,7 +45,7 @@ struct be_dev_info {
        struct {
                int num_vectors;
                int start_vector;
-               u32 vector_list[MAX_ROCE_MSIX_VECTORS];
+               u32 vector_list[MAX_MSIX_VECTORS];
        } msix;
 };
 
index 2b0a0ea4f8e7eab210535c703b2a3d4987546d1d..ae236009f1a8c5dc857326751ce28ea68b2a4681 100644 (file)
@@ -259,6 +259,7 @@ struct bufdesc_ex {
 struct fec_enet_delayed_work {
        struct delayed_work delay_work;
        bool timeout;
+       bool trig_tx;
 };
 
 /* The FEC buffer descriptors track the ring buffers.  The rx_bd_base and
index d3ad5ea711d316e1455cbe7d8eab61ecad8cb3d4..fdf9307ba9e6ee412e832266d5f05edcf9269334 100644 (file)
@@ -93,6 +93,20 @@ static void set_multicast_list(struct net_device *ndev);
 #define FEC_QUIRK_HAS_CSUM             (1 << 5)
 /* Controller has hardware vlan support */
 #define FEC_QUIRK_HAS_VLAN             (1 << 6)
+/* ENET IP errata ERR006358
+ *
+ * If the ready bit in the transmit buffer descriptor (TxBD[R]) is previously
+ * detected as not set during a prior frame transmission, then the
+ * ENET_TDAR[TDAR] bit is cleared at a later time, even if additional TxBDs
+ * were added to the ring and the ENET_TDAR[TDAR] bit is set. This results in
+ * If the ready bit in the transmit buffer descriptor (TxBD[R]) is previously
+ * detected as not set during a prior frame transmission, then the
+ * ENET_TDAR[TDAR] bit is cleared at a later time, even if additional TxBDs
+ * were added to the ring and the ENET_TDAR[TDAR] bit is set. This results in
+ * frames not being transmitted until there is a 0-to-1 transition on
+ * ENET_TDAR[TDAR].
+ */
+#define FEC_QUIRK_ERR006358            (1 << 7)
 
 static struct platform_device_id fec_devtype[] = {
        {
@@ -112,7 +126,7 @@ static struct platform_device_id fec_devtype[] = {
                .name = "imx6q-fec",
                .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
                                FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
-                               FEC_QUIRK_HAS_VLAN,
+                               FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358,
        }, {
                .name = "mvf600-fec",
                .driver_data = FEC_QUIRK_ENET_MAC,
@@ -275,16 +289,11 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
        struct fec_enet_private *fep = netdev_priv(ndev);
        const struct platform_device_id *id_entry =
                                platform_get_device_id(fep->pdev);
-       struct bufdesc *bdp;
+       struct bufdesc *bdp, *bdp_pre;
        void *bufaddr;
        unsigned short  status;
        unsigned int index;
 
-       if (!fep->link) {
-               /* Link is down or auto-negotiation is in progress. */
-               return NETDEV_TX_BUSY;
-       }
-
        /* Fill in a Tx ring entry */
        bdp = fep->cur_tx;
 
@@ -370,6 +379,15 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                ebdp->cbd_esc |= BD_ENET_TX_PINS;
                }
        }
+
+       bdp_pre = fec_enet_get_prevdesc(bdp, fep->bufdesc_ex);
+       if ((id_entry->driver_data & FEC_QUIRK_ERR006358) &&
+           !(bdp_pre->cbd_sc & BD_ENET_TX_READY)) {
+               fep->delay_work.trig_tx = true;
+               schedule_delayed_work(&(fep->delay_work.delay_work),
+                                       msecs_to_jiffies(1));
+       }
+
        /* If this was the last BD in the ring, start at the beginning again. */
        if (status & BD_ENET_TX_WRAP)
                bdp = fep->tx_bd_base;
@@ -689,6 +707,11 @@ static void fec_enet_work(struct work_struct *work)
                fec_restart(fep->netdev, fep->full_duplex);
                netif_wake_queue(fep->netdev);
        }
+
+       if (fep->delay_work.trig_tx) {
+               fep->delay_work.trig_tx = false;
+               writel(0, fep->hwp + FEC_X_DES_ACTIVE);
+       }
 }
 
 static void
@@ -2033,10 +2056,6 @@ fec_probe(struct platform_device *pdev)
        if (of_id)
                pdev->id_entry = of_id->data;
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!r)
-               return -ENXIO;
-
        /* Init network device */
        ndev = alloc_etherdev(sizeof(struct fec_enet_private));
        if (!ndev)
@@ -2054,6 +2073,7 @@ fec_probe(struct platform_device *pdev)
                fep->pause_flag |= FEC_PAUSE_FLAG_AUTONEG;
 #endif
 
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        fep->hwp = devm_ioremap_resource(&pdev->dev, r);
        if (IS_ERR(fep->hwp)) {
                ret = PTR_ERR(fep->hwp);
@@ -2103,10 +2123,25 @@ fec_probe(struct platform_device *pdev)
                fep->bufdesc_ex = 0;
        }
 
-       clk_prepare_enable(fep->clk_ahb);
-       clk_prepare_enable(fep->clk_ipg);
-       clk_prepare_enable(fep->clk_enet_out);
-       clk_prepare_enable(fep->clk_ptp);
+       ret = clk_prepare_enable(fep->clk_ahb);
+       if (ret)
+               goto failed_clk;
+
+       ret = clk_prepare_enable(fep->clk_ipg);
+       if (ret)
+               goto failed_clk_ipg;
+
+       if (fep->clk_enet_out) {
+               ret = clk_prepare_enable(fep->clk_enet_out);
+               if (ret)
+                       goto failed_clk_enet_out;
+       }
+
+       if (fep->clk_ptp) {
+               ret = clk_prepare_enable(fep->clk_ptp);
+               if (ret)
+                       goto failed_clk_ptp;
+       }
 
        fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
        if (!IS_ERR(fep->reg_phy)) {
@@ -2137,14 +2172,10 @@ fec_probe(struct platform_device *pdev)
                        ret = irq;
                        goto failed_irq;
                }
-               ret = request_irq(irq, fec_enet_interrupt, IRQF_DISABLED, pdev->name, ndev);
-               if (ret) {
-                       while (--i >= 0) {
-                               irq = platform_get_irq(pdev, i);
-                               free_irq(irq, ndev);
-                       }
+               ret = devm_request_irq(&pdev->dev, irq, fec_enet_interrupt,
+                                      IRQF_DISABLED, pdev->name, ndev);
+               if (ret)
                        goto failed_irq;
-               }
        }
 
        ret = fec_enet_mii_init(pdev);
@@ -2168,19 +2199,19 @@ failed_register:
        fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_irq:
-       for (i = 0; i < FEC_IRQ_NUM; i++) {
-               irq = platform_get_irq(pdev, i);
-               if (irq > 0)
-                       free_irq(irq, ndev);
-       }
 failed_init:
        if (fep->reg_phy)
                regulator_disable(fep->reg_phy);
 failed_regulator:
-       clk_disable_unprepare(fep->clk_ahb);
+       if (fep->clk_ptp)
+               clk_disable_unprepare(fep->clk_ptp);
+failed_clk_ptp:
+       if (fep->clk_enet_out)
+               clk_disable_unprepare(fep->clk_enet_out);
+failed_clk_enet_out:
        clk_disable_unprepare(fep->clk_ipg);
-       clk_disable_unprepare(fep->clk_enet_out);
-       clk_disable_unprepare(fep->clk_ptp);
+failed_clk_ipg:
+       clk_disable_unprepare(fep->clk_ahb);
 failed_clk:
 failed_ioremap:
        free_netdev(ndev);
@@ -2193,25 +2224,21 @@ fec_drv_remove(struct platform_device *pdev)
 {
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct fec_enet_private *fep = netdev_priv(ndev);
-       int i;
 
        cancel_delayed_work_sync(&(fep->delay_work.delay_work));
        unregister_netdev(ndev);
        fec_enet_mii_remove(fep);
        del_timer_sync(&fep->time_keep);
-       for (i = 0; i < FEC_IRQ_NUM; i++) {
-               int irq = platform_get_irq(pdev, i);
-               if (irq > 0)
-                       free_irq(irq, ndev);
-       }
        if (fep->reg_phy)
                regulator_disable(fep->reg_phy);
-       clk_disable_unprepare(fep->clk_ptp);
+       if (fep->clk_ptp)
+               clk_disable_unprepare(fep->clk_ptp);
        if (fep->ptp_clock)
                ptp_clock_unregister(fep->ptp_clock);
-       clk_disable_unprepare(fep->clk_enet_out);
-       clk_disable_unprepare(fep->clk_ahb);
+       if (fep->clk_enet_out)
+               clk_disable_unprepare(fep->clk_enet_out);
        clk_disable_unprepare(fep->clk_ipg);
+       clk_disable_unprepare(fep->clk_ahb);
        free_netdev(ndev);
 
        return 0;
@@ -2228,9 +2255,12 @@ fec_suspend(struct device *dev)
                fec_stop(ndev);
                netif_device_detach(ndev);
        }
-       clk_disable_unprepare(fep->clk_enet_out);
-       clk_disable_unprepare(fep->clk_ahb);
+       if (fep->clk_ptp)
+               clk_disable_unprepare(fep->clk_ptp);
+       if (fep->clk_enet_out)
+               clk_disable_unprepare(fep->clk_enet_out);
        clk_disable_unprepare(fep->clk_ipg);
+       clk_disable_unprepare(fep->clk_ahb);
 
        if (fep->reg_phy)
                regulator_disable(fep->reg_phy);
@@ -2251,15 +2281,44 @@ fec_resume(struct device *dev)
                        return ret;
        }
 
-       clk_prepare_enable(fep->clk_enet_out);
-       clk_prepare_enable(fep->clk_ahb);
-       clk_prepare_enable(fep->clk_ipg);
+       ret = clk_prepare_enable(fep->clk_ahb);
+       if (ret)
+               goto failed_clk_ahb;
+
+       ret = clk_prepare_enable(fep->clk_ipg);
+       if (ret)
+               goto failed_clk_ipg;
+
+       if (fep->clk_enet_out) {
+               ret = clk_prepare_enable(fep->clk_enet_out);
+               if (ret)
+                       goto failed_clk_enet_out;
+       }
+
+       if (fep->clk_ptp) {
+               ret = clk_prepare_enable(fep->clk_ptp);
+               if (ret)
+                       goto failed_clk_ptp;
+       }
+
        if (netif_running(ndev)) {
                fec_restart(ndev, fep->full_duplex);
                netif_device_attach(ndev);
        }
 
        return 0;
+
+failed_clk_ptp:
+       if (fep->clk_enet_out)
+               clk_disable_unprepare(fep->clk_enet_out);
+failed_clk_enet_out:
+       clk_disable_unprepare(fep->clk_ipg);
+failed_clk_ipg:
+       clk_disable_unprepare(fep->clk_ahb);
+failed_clk_ahb:
+       if (fep->reg_phy)
+               regulator_disable(fep->reg_phy);
+       return ret;
 }
 #endif /* CONFIG_PM_SLEEP */
 
@@ -2279,4 +2338,5 @@ static struct platform_driver fec_driver = {
 
 module_platform_driver(fec_driver);
 
+MODULE_ALIAS("platform:"DRIVER_NAME);
 MODULE_LICENSE("GPL");
index 360a578c2bb7feffb7e36592a4750f577574fd52..e0528900db023cada5870329317996511e407e73 100644 (file)
@@ -123,12 +123,10 @@ static int mpc52xx_fec_mdio_probe(struct platform_device *of)
 
 static int mpc52xx_fec_mdio_remove(struct platform_device *of)
 {
-       struct device *dev = &of->dev;
-       struct mii_bus *bus = dev_get_drvdata(dev);
+       struct mii_bus *bus = platform_get_drvdata(of);
        struct mpc52xx_fec_mdio_priv *priv = bus->priv;
 
        mdiobus_unregister(bus);
-       dev_set_drvdata(dev, NULL);
        iounmap(priv->regs);
        kfree(priv);
        mdiobus_free(bus);
index 8de53a14a6f48895bc107c6f8ec40910d35ced7b..6b60582ce8cf1c7a82dd3da1d69acb64981014f4 100644 (file)
@@ -583,7 +583,6 @@ static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
                                               struct sk_buff *skb)
 {
        struct sk_buff *new_skb;
-       struct fs_enet_private *fep = netdev_priv(dev);
 
        /* Alloc new skb */
        new_skb = netdev_alloc_skb(dev, skb->len + 4);
@@ -1000,6 +999,8 @@ static int fs_enet_probe(struct platform_device *ofdev)
        struct fs_enet_private *fep;
        struct fs_platform_info *fpi;
        const u32 *data;
+       struct clk *clk;
+       int err;
        const u8 *mac_addr;
        const char *phy_connection_type;
        int privsize, len, ret = -ENODEV;
@@ -1037,6 +1038,20 @@ static int fs_enet_probe(struct platform_device *ofdev)
                        fpi->use_rmii = 1;
        }
 
+       /* make clock lookup non-fatal (the driver is shared among platforms),
+        * but require enable to succeed when a clock was specified/found,
+        * keep a reference to the clock upon successful acquisition
+        */
+       clk = devm_clk_get(&ofdev->dev, "per");
+       if (!IS_ERR(clk)) {
+               err = clk_prepare_enable(clk);
+               if (err) {
+                       ret = err;
+                       goto out_free_fpi;
+               }
+               fpi->clk_per = clk;
+       }
+
        privsize = sizeof(*fep) +
                   sizeof(struct sk_buff **) *
                   (fpi->rx_ring + fpi->tx_ring);
@@ -1108,6 +1123,8 @@ out_free_dev:
        free_netdev(ndev);
 out_put:
        of_node_put(fpi->phy_node);
+       if (fpi->clk_per)
+               clk_disable_unprepare(fpi->clk_per);
 out_free_fpi:
        kfree(fpi);
        return ret;
@@ -1124,6 +1141,8 @@ static int fs_enet_remove(struct platform_device *ofdev)
        fep->ops->cleanup_data(ndev);
        dev_set_drvdata(fep->dev, NULL);
        of_node_put(fep->fpi->phy_node);
+       if (fep->fpi->clk_per)
+               clk_disable_unprepare(fep->fpi->clk_per);
        free_netdev(ndev);
        return 0;
 }
index c93a05654b46125b6eeda59cf6e0bbfc83c5f9ef..c4f65067cf7c30d94482b400ff86532da5546171 100644 (file)
@@ -409,7 +409,7 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
        priv->regs = priv->map + data->mii_offset;
 
        new_bus->parent = &pdev->dev;
-       dev_set_drvdata(&pdev->dev, new_bus);
+       platform_set_drvdata(pdev, new_bus);
 
        if (data->get_tbipa) {
                for_each_child_of_node(np, tbi) {
@@ -468,8 +468,6 @@ static int fsl_pq_mdio_remove(struct platform_device *pdev)
 
        mdiobus_unregister(bus);
 
-       dev_set_drvdata(device, NULL);
-
        iounmap(priv->map);
        mdiobus_free(bus);
 
index 8d2db7b808b7cb4321dbc6edeb12ebab94b7b0f0..b2c91dcd245f7985b66da22346a9b6f7ec5f3fb8 100644 (file)
@@ -593,7 +593,6 @@ static int gfar_parse_group(struct device_node *np,
                        return -EINVAL;
        }
 
-       grp->grp_id = priv->num_grps;
        grp->priv = priv;
        spin_lock_init(&grp->grplock);
        if (priv->mode == MQ_MG_MODE) {
@@ -1017,7 +1016,14 @@ static int gfar_probe(struct platform_device *ofdev)
        /* We need to delay at least 3 TX clocks */
        udelay(2);
 
-       tempval = (MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
+       tempval = 0;
+       if (!priv->pause_aneg_en && priv->tx_pause_en)
+               tempval |= MACCFG1_TX_FLOW;
+       if (!priv->pause_aneg_en && priv->rx_pause_en)
+               tempval |= MACCFG1_RX_FLOW;
+       /* the soft reset bit is not self-resetting, so we need to
+        * clear it before resuming normal operation
+        */
        gfar_write(&regs->maccfg1, tempval);
 
        /* Initialize MACCFG2. */
@@ -1461,7 +1467,7 @@ static int init_phy(struct net_device *dev)
        struct gfar_private *priv = netdev_priv(dev);
        uint gigabit_support =
                priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
-               SUPPORTED_1000baseT_Full : 0;
+               GFAR_SUPPORTED_GBIT : 0;
        phy_interface_t interface;
 
        priv->oldlink = 0;
@@ -2052,6 +2058,24 @@ static inline struct txbd8 *next_txbd(struct txbd8 *bdp, struct txbd8 *base,
        return skip_txbd(bdp, 1, base, ring_size);
 }
 
+/* eTSEC12: csum generation not supported for some fcb offsets */
+static inline bool gfar_csum_errata_12(struct gfar_private *priv,
+                                      unsigned long fcb_addr)
+{
+       return (gfar_has_errata(priv, GFAR_ERRATA_12) &&
+              (fcb_addr % 0x20) > 0x18);
+}
+
+/* eTSEC76: csum generation for frames larger than 2500 may
+ * cause excess delays before start of transmission
+ */
+static inline bool gfar_csum_errata_76(struct gfar_private *priv,
+                                      unsigned int len)
+{
+       return (gfar_has_errata(priv, GFAR_ERRATA_76) &&
+              (len > 2500));
+}
+
 /* This is called by the kernel when a frame is ready for transmission.
  * It is pointed to by the dev->hard_start_xmit function pointer
  */
@@ -2064,23 +2088,11 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct txfcb *fcb = NULL;
        struct txbd8 *txbdp, *txbdp_start, *base, *txbdp_tstamp = NULL;
        u32 lstatus;
-       int i, rq = 0, do_tstamp = 0;
+       int i, rq = 0;
+       int do_tstamp, do_csum, do_vlan;
        u32 bufaddr;
        unsigned long flags;
-       unsigned int nr_frags, nr_txbds, length, fcb_length = GMAC_FCB_LEN;
-
-       /* TOE=1 frames larger than 2500 bytes may see excess delays
-        * before start of transmission.
-        */
-       if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_76) &&
-                    skb->ip_summed == CHECKSUM_PARTIAL &&
-                    skb->len > 2500)) {
-               int ret;
-
-               ret = skb_checksum_help(skb);
-               if (ret)
-                       return ret;
-       }
+       unsigned int nr_frags, nr_txbds, length, fcb_len = 0;
 
        rq = skb->queue_mapping;
        tx_queue = priv->tx_queue[rq];
@@ -2088,21 +2100,23 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        base = tx_queue->tx_bd_base;
        regs = tx_queue->grp->regs;
 
+       do_csum = (CHECKSUM_PARTIAL == skb->ip_summed);
+       do_vlan = vlan_tx_tag_present(skb);
+       do_tstamp = (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
+                   priv->hwts_tx_en;
+
+       if (do_csum || do_vlan)
+               fcb_len = GMAC_FCB_LEN;
+
        /* check if time stamp should be generated */
-       if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
-                    priv->hwts_tx_en)) {
-               do_tstamp = 1;
-               fcb_length = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
-       }
+       if (unlikely(do_tstamp))
+               fcb_len = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
 
        /* make space for additional header when fcb is needed */
-       if (((skb->ip_summed == CHECKSUM_PARTIAL) ||
-            vlan_tx_tag_present(skb) ||
-            unlikely(do_tstamp)) &&
-           (skb_headroom(skb) < fcb_length)) {
+       if (fcb_len && unlikely(skb_headroom(skb) < fcb_len)) {
                struct sk_buff *skb_new;
 
-               skb_new = skb_realloc_headroom(skb, fcb_length);
+               skb_new = skb_realloc_headroom(skb, fcb_len);
                if (!skb_new) {
                        dev->stats.tx_errors++;
                        kfree_skb(skb);
@@ -2185,36 +2199,38 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
                memset(skb->data, 0, GMAC_TXPAL_LEN);
        }
 
-       /* Set up checksumming */
-       if (CHECKSUM_PARTIAL == skb->ip_summed) {
+       /* Add TxFCB if required */
+       if (fcb_len) {
                fcb = gfar_add_fcb(skb);
-               /* as specified by errata */
-               if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12) &&
-                            ((unsigned long)fcb % 0x20) > 0x18)) {
+               lstatus |= BD_LFLAG(TXBD_TOE);
+       }
+
+       /* Set up checksumming */
+       if (do_csum) {
+               gfar_tx_checksum(skb, fcb, fcb_len);
+
+               if (unlikely(gfar_csum_errata_12(priv, (unsigned long)fcb)) ||
+                   unlikely(gfar_csum_errata_76(priv, skb->len))) {
                        __skb_pull(skb, GMAC_FCB_LEN);
                        skb_checksum_help(skb);
-               } else {
-                       lstatus |= BD_LFLAG(TXBD_TOE);
-                       gfar_tx_checksum(skb, fcb, fcb_length);
+                       if (do_vlan || do_tstamp) {
+                               /* put back a new fcb for vlan/tstamp TOE */
+                               fcb = gfar_add_fcb(skb);
+                       } else {
+                               /* Tx TOE not used */
+                               lstatus &= ~(BD_LFLAG(TXBD_TOE));
+                               fcb = NULL;
+                       }
                }
        }
 
-       if (vlan_tx_tag_present(skb)) {
-               if (unlikely(NULL == fcb)) {
-                       fcb = gfar_add_fcb(skb);
-                       lstatus |= BD_LFLAG(TXBD_TOE);
-               }
-
+       if (do_vlan)
                gfar_tx_vlan(skb, fcb);
-       }
 
        /* Setup tx hardware time stamping if requested */
        if (unlikely(do_tstamp)) {
                skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-               if (fcb == NULL)
-                       fcb = gfar_add_fcb(skb);
                fcb->ptp = 1;
-               lstatus |= BD_LFLAG(TXBD_TOE);
        }
 
        txbdp_start->bufPtr = dma_map_single(priv->dev, skb->data,
@@ -2226,9 +2242,9 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
         * the full frame length.
         */
        if (unlikely(do_tstamp)) {
-               txbdp_tstamp->bufPtr = txbdp_start->bufPtr + fcb_length;
+               txbdp_tstamp->bufPtr = txbdp_start->bufPtr + fcb_len;
                txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_READY) |
-                                        (skb_headlen(skb) - fcb_length);
+                                        (skb_headlen(skb) - fcb_len);
                lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN;
        } else {
                lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);
@@ -3014,6 +3030,41 @@ static irqreturn_t gfar_interrupt(int irq, void *grp_id)
        return IRQ_HANDLED;
 }
 
+static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
+{
+       struct phy_device *phydev = priv->phydev;
+       u32 val = 0;
+
+       if (!phydev->duplex)
+               return val;
+
+       if (!priv->pause_aneg_en) {
+               if (priv->tx_pause_en)
+                       val |= MACCFG1_TX_FLOW;
+               if (priv->rx_pause_en)
+                       val |= MACCFG1_RX_FLOW;
+       } else {
+               u16 lcl_adv, rmt_adv;
+               u8 flowctrl;
+               /* get link partner capabilities */
+               rmt_adv = 0;
+               if (phydev->pause)
+                       rmt_adv = LPA_PAUSE_CAP;
+               if (phydev->asym_pause)
+                       rmt_adv |= LPA_PAUSE_ASYM;
+
+               lcl_adv = mii_advertise_flowctrl(phydev->advertising);
+
+               flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
+               if (flowctrl & FLOW_CTRL_TX)
+                       val |= MACCFG1_TX_FLOW;
+               if (flowctrl & FLOW_CTRL_RX)
+                       val |= MACCFG1_RX_FLOW;
+       }
+
+       return val;
+}
+
 /* Called every time the controller might need to be made
  * aware of new link state.  The PHY code conveys this
  * information through variables in the phydev structure, and this
@@ -3032,6 +3083,7 @@ static void adjust_link(struct net_device *dev)
        lock_tx_qs(priv);
 
        if (phydev->link) {
+               u32 tempval1 = gfar_read(&regs->maccfg1);
                u32 tempval = gfar_read(&regs->maccfg2);
                u32 ecntrl = gfar_read(&regs->ecntrl);
 
@@ -3080,6 +3132,10 @@ static void adjust_link(struct net_device *dev)
                        priv->oldspeed = phydev->speed;
                }
 
+               tempval1 &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
+               tempval1 |= gfar_get_flowctrl_cfg(priv);
+
+               gfar_write(&regs->maccfg1, tempval1);
                gfar_write(&regs->maccfg2, tempval);
                gfar_write(&regs->ecntrl, ecntrl);
 
index 04b552cd419d5f2d8b1546c8371b5ebbe13bf8ff..46f56f36118f8c34e8fa818dc27e0906c386dfcc 100644 (file)
@@ -146,6 +146,10 @@ extern const char gfar_driver_version[];
                | SUPPORTED_Autoneg \
                | SUPPORTED_MII)
 
+#define GFAR_SUPPORTED_GBIT (SUPPORTED_1000baseT_Full \
+               | SUPPORTED_Pause \
+               | SUPPORTED_Asym_Pause)
+
 /* TBI register addresses */
 #define MII_TBICON             0x11
 
@@ -1009,7 +1013,6 @@ struct gfar_irqinfo {
  *     @napi: the napi poll function
  *     @priv: back pointer to the priv structure
  *     @regs: the ioremapped register space for this group
- *     @grp_id: group id for this group
  *     @irqinfo: TX/RX/ER irq data for this group
  */
 
@@ -1018,11 +1021,10 @@ struct gfar_priv_grp {
        struct  napi_struct napi;
        struct gfar_private *priv;
        struct gfar __iomem *regs;
-       unsigned int grp_id;
+       unsigned int rstat;
        unsigned long num_rx_queues;
        unsigned long rx_bit_map;
        /* cacheline 3 */
-       unsigned int rstat;
        unsigned int tstat;
        unsigned long num_tx_queues;
        unsigned long tx_bit_map;
@@ -1102,7 +1104,11 @@ struct gfar_private {
                /* Wake-on-LAN enabled */
                wol_en:1,
                /* Enable priorty based Tx scheduling in Hw */
-               prio_sched_en:1;
+               prio_sched_en:1,
+               /* Flow control flags */
+               pause_aneg_en:1,
+               tx_pause_en:1,
+               rx_pause_en:1;
 
        /* The total tx and rx ring size for the enabled queues */
        unsigned int total_tx_ring_size;
index 21cd88124ca96a2ad3342358531868175c958fc8..d3d7ede27ef14854f11b2f7c4a9648d34574dbeb 100644 (file)
@@ -535,6 +535,78 @@ static int gfar_sringparam(struct net_device *dev,
        return err;
 }
 
+static void gfar_gpauseparam(struct net_device *dev,
+                            struct ethtool_pauseparam *epause)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+
+       epause->autoneg = !!priv->pause_aneg_en;
+       epause->rx_pause = !!priv->rx_pause_en;
+       epause->tx_pause = !!priv->tx_pause_en;
+}
+
+static int gfar_spauseparam(struct net_device *dev,
+                           struct ethtool_pauseparam *epause)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+       struct phy_device *phydev = priv->phydev;
+       struct gfar __iomem *regs = priv->gfargrp[0].regs;
+       u32 oldadv, newadv;
+
+       if (!(phydev->supported & SUPPORTED_Pause) ||
+           (!(phydev->supported & SUPPORTED_Asym_Pause) &&
+            (epause->rx_pause != epause->tx_pause)))
+               return -EINVAL;
+
+       priv->rx_pause_en = priv->tx_pause_en = 0;
+       if (epause->rx_pause) {
+               priv->rx_pause_en = 1;
+
+               if (epause->tx_pause) {
+                       priv->tx_pause_en = 1;
+                       /* FLOW_CTRL_RX & TX */
+                       newadv = ADVERTISED_Pause;
+               } else  /* FLOW_CTLR_RX */
+                       newadv = ADVERTISED_Pause | ADVERTISED_Asym_Pause;
+       } else if (epause->tx_pause) {
+               priv->tx_pause_en = 1;
+               /* FLOW_CTLR_TX */
+               newadv = ADVERTISED_Asym_Pause;
+       } else
+               newadv = 0;
+
+       if (epause->autoneg)
+               priv->pause_aneg_en = 1;
+       else
+               priv->pause_aneg_en = 0;
+
+       oldadv = phydev->advertising &
+               (ADVERTISED_Pause | ADVERTISED_Asym_Pause);
+       if (oldadv != newadv) {
+               phydev->advertising &=
+                       ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause);
+               phydev->advertising |= newadv;
+               if (phydev->autoneg)
+                       /* inform link partner of our
+                        * new flow ctrl settings
+                        */
+                       return phy_start_aneg(phydev);
+
+               if (!epause->autoneg) {
+                       u32 tempval;
+                       tempval = gfar_read(&regs->maccfg1);
+                       tempval &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
+                       if (priv->tx_pause_en)
+                               tempval |= MACCFG1_TX_FLOW;
+                       if (priv->rx_pause_en)
+                               tempval |= MACCFG1_RX_FLOW;
+                       gfar_write(&regs->maccfg1, tempval);
+               }
+       }
+
+       return 0;
+}
+
 int gfar_set_features(struct net_device *dev, netdev_features_t features)
 {
        struct gfar_private *priv = netdev_priv(dev);
@@ -1806,6 +1878,8 @@ const struct ethtool_ops gfar_ethtool_ops = {
        .set_coalesce = gfar_scoalesce,
        .get_ringparam = gfar_gringparam,
        .set_ringparam = gfar_sringparam,
+       .get_pauseparam = gfar_gpauseparam,
+       .set_pauseparam = gfar_spauseparam,
        .get_strings = gfar_gstrings,
        .get_sset_count = gfar_sset_count,
        .get_ethtool_stats = gfar_fill_stats,
index 3c43dac894ecddde910e2ce8e784c455944af915..5930c39672db25eee560dabd16cf38d1ca54636b 100644 (file)
@@ -3911,14 +3911,12 @@ static int ucc_geth_probe(struct platform_device* ofdev)
 
 static int ucc_geth_remove(struct platform_device* ofdev)
 {
-       struct device *device = &ofdev->dev;
-       struct net_device *dev = dev_get_drvdata(device);
+       struct net_device *dev = platform_get_drvdata(ofdev);
        struct ucc_geth_private *ugeth = netdev_priv(dev);
 
        unregister_netdev(dev);
        free_netdev(dev);
        ucc_geth_memclean(ugeth);
-       dev_set_drvdata(device, NULL);
 
        return 0;
 }
index 93346f00486ba78ddf719a23de6ab71fd9058ea7..79aef681ac85db206d65f0a31944c7ee1a6a3374 100644 (file)
@@ -133,8 +133,8 @@ struct rfd_struct
   unsigned char  last;         /* Bit15,Last Frame on List / Bit14,suspend */
   unsigned short next;         /* linkoffset to next RFD */
   unsigned short rbd_offset;   /* pointeroffset to RBD-buffer */
-  unsigned char  dest[6];      /* ethernet-address, destination */
-  unsigned char  source[6];    /* ethernet-address, source */
+  unsigned char  dest[ETH_ALEN];       /* ethernet-address, destination */
+  unsigned char  source[ETH_ALEN];     /* ethernet-address, source */
   unsigned short length;       /* 802.3 frame-length */
   unsigned short zero_dummy;   /* dummy */
 };
index d300a0c0eafc0521a4e86688abd7e54afd0ce58e..2d3b064d6924a90ee4e9715615faf83e50a53512 100644 (file)
@@ -2955,8 +2955,6 @@ static int emac_remove(struct platform_device *ofdev)
 
        DBG(dev, "remove" NL);
 
-       dev_set_drvdata(&ofdev->dev, NULL);
-
        unregister_netdev(dev->ndev);
 
        cancel_work_sync(&dev->reset_work);
index 5115ae76a5d1c02f0788138e68fac4acdb551767..ada6e210279f3750e26ea5720ca3bbe5057abf2c 100644 (file)
@@ -1175,15 +1175,12 @@ static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
                config->rx_discard_short_frames = 0x0;  /* 1=discard, 0=save */
        }
 
-       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
-                    "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
-                    c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
-       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
-                    "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
-                    c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]);
-       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
-                    "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
-                    c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[00-07]=%8ph\n",
+                    c + 0);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[08-15]=%8ph\n",
+                    c + 8);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev, "[16-23]=%8ph\n",
+                    c + 16);
        return 0;
 }
 
index 4c303e2a7cb3f3aae1ed974d6a066168c7e82c4a..8fed74e3fa53da73ff781a215ac26714911a015f 100644 (file)
@@ -1011,6 +1011,11 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
 
        /* Must release MDIO ownership and mutex after MAC reset. */
        switch (hw->mac.type) {
+       case e1000_82573:
+               /* Release mutex only if the hw semaphore is acquired */
+               if (!ret_val)
+                       e1000_put_hw_semaphore_82573(hw);
+               break;
        case e1000_82574:
        case e1000_82583:
                /* Release mutex only if the hw semaphore is acquired */
@@ -2057,6 +2062,7 @@ const struct e1000_info e1000_82583_info = {
                                  | FLAG_HAS_JUMBO_FRAMES
                                  | FLAG_HAS_CTRLEXT_ON_LOAD,
        .flags2                 = FLAG2_DISABLE_ASPM_L0S
+                                 | FLAG2_DISABLE_ASPM_L1
                                  | FLAG2_NO_DISABLE_RX,
        .pba                    = 32,
        .max_hw_frame_size      = DEFAULT_JUMBO,
index ffbc08f56c40cd9f55c2753b74d294b5caa540b4..ad0edd11015d7b40a14d79f06afdab8ecec76cef 100644 (file)
@@ -90,9 +90,6 @@ struct e1000_info;
 
 #define E1000_MNG_VLAN_NONE            (-1)
 
-/* Number of packet split data buffers (not including the header buffer) */
-#define PS_PAGE_BUFFERS                        (MAX_PS_BUFFERS - 1)
-
 #define DEFAULT_JUMBO                  9234
 
 /* Time to wait before putting the device into D3 if there's no link (in ms). */
index 59c22bf18701bf6505b13c0f16228a43694e2bb7..a8633b8f0ac5aaff57b2be97d8e0ac5dfe3ff36a 100644 (file)
@@ -173,7 +173,7 @@ static int e1000_get_settings(struct net_device *netdev,
                        speed = adapter->link_speed;
                        ecmd->duplex = adapter->link_duplex - 1;
                }
-       } else {
+       } else if (!pm_runtime_suspended(netdev->dev.parent)) {
                u32 status = er32(STATUS);
                if (status & E1000_STATUS_LU) {
                        if (status & E1000_STATUS_SPEED_1000)
@@ -264,6 +264,9 @@ static int e1000_set_settings(struct net_device *netdev,
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
+       int ret_val = 0;
+
+       pm_runtime_get_sync(netdev->dev.parent);
 
        /* When SoL/IDER sessions are active, autoneg/speed/duplex
         * cannot be changed
@@ -271,7 +274,8 @@ static int e1000_set_settings(struct net_device *netdev,
        if (hw->phy.ops.check_reset_block &&
            hw->phy.ops.check_reset_block(hw)) {
                e_err("Cannot change link characteristics when SoL/IDER is active.\n");
-               return -EINVAL;
+               ret_val = -EINVAL;
+               goto out;
        }
 
        /* MDI setting is only allowed when autoneg enabled because
@@ -279,13 +283,16 @@ static int e1000_set_settings(struct net_device *netdev,
         * duplex is forced.
         */
        if (ecmd->eth_tp_mdix_ctrl) {
-               if (hw->phy.media_type != e1000_media_type_copper)
-                       return -EOPNOTSUPP;
+               if (hw->phy.media_type != e1000_media_type_copper) {
+                       ret_val = -EOPNOTSUPP;
+                       goto out;
+               }
 
                if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) &&
                    (ecmd->autoneg != AUTONEG_ENABLE)) {
                        e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n");
-                       return -EINVAL;
+                       ret_val = -EINVAL;
+                       goto out;
                }
        }
 
@@ -307,8 +314,8 @@ static int e1000_set_settings(struct net_device *netdev,
                u32 speed = ethtool_cmd_speed(ecmd);
                /* calling this overrides forced MDI setting */
                if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
-                       clear_bit(__E1000_RESETTING, &adapter->state);
-                       return -EINVAL;
+                       ret_val = -EINVAL;
+                       goto out;
                }
        }
 
@@ -331,8 +338,10 @@ static int e1000_set_settings(struct net_device *netdev,
                e1000e_reset(adapter);
        }
 
+out:
+       pm_runtime_put_sync(netdev->dev.parent);
        clear_bit(__E1000_RESETTING, &adapter->state);
-       return 0;
+       return ret_val;
 }
 
 static void e1000_get_pauseparam(struct net_device *netdev,
@@ -366,6 +375,8 @@ static int e1000_set_pauseparam(struct net_device *netdev,
        while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
                usleep_range(1000, 2000);
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        if (adapter->fc_autoneg == AUTONEG_ENABLE) {
                hw->fc.requested_mode = e1000_fc_default;
                if (netif_running(adapter->netdev)) {
@@ -398,6 +409,7 @@ static int e1000_set_pauseparam(struct net_device *netdev,
        }
 
 out:
+       pm_runtime_put_sync(netdev->dev.parent);
        clear_bit(__E1000_RESETTING, &adapter->state);
        return retval;
 }
@@ -428,6 +440,8 @@ static void e1000_get_regs(struct net_device *netdev,
        u32 *regs_buff = p;
        u16 phy_data;
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        memset(p, 0, E1000_REGS_LEN * sizeof(u32));
 
        regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
@@ -472,6 +486,8 @@ static void e1000_get_regs(struct net_device *netdev,
        e1e_rphy(hw, MII_STAT1000, &phy_data);
        regs_buff[24] = (u32)phy_data;  /* phy local receiver status */
        regs_buff[25] = regs_buff[24];  /* phy remote receiver status */
+
+       pm_runtime_put_sync(netdev->dev.parent);
 }
 
 static int e1000_get_eeprom_len(struct net_device *netdev)
@@ -504,6 +520,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
        if (!eeprom_buff)
                return -ENOMEM;
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        if (hw->nvm.type == e1000_nvm_eeprom_spi) {
                ret_val = e1000_read_nvm(hw, first_word,
                                         last_word - first_word + 1,
@@ -517,6 +535,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
                }
        }
 
+       pm_runtime_put_sync(netdev->dev.parent);
+
        if (ret_val) {
                /* a read error occurred, throw away the result */
                memset(eeprom_buff, 0xff, sizeof(u16) *
@@ -566,6 +586,8 @@ static int e1000_set_eeprom(struct net_device *netdev,
 
        ptr = (void *)eeprom_buff;
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        if (eeprom->offset & 1) {
                /* need read/modify/write of first changed EEPROM word */
                /* only the second byte of the word is being modified */
@@ -606,6 +628,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
                ret_val = e1000e_update_nvm_checksum(hw);
 
 out:
+       pm_runtime_put_sync(netdev->dev.parent);
        kfree(eeprom_buff);
        return ret_val;
 }
@@ -701,6 +724,8 @@ static int e1000_set_ringparam(struct net_device *netdev,
                }
        }
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        e1000e_down(adapter);
 
        /* We can't just free everything and then setup again, because the
@@ -739,6 +764,7 @@ err_setup_rx:
                e1000e_free_tx_resources(temp_tx);
 err_setup:
        e1000e_up(adapter);
+       pm_runtime_put_sync(netdev->dev.parent);
 free_temp:
        vfree(temp_tx);
        vfree(temp_rx);
@@ -1639,7 +1665,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)
                        ret_val = 13;   /* ret_val is the same as mis-compare */
                        break;
                }
-               if (jiffies >= (time + 20)) {
+               if (time_after(jiffies, time + 20)) {
                        ret_val = 14;   /* error code for time out error */
                        break;
                }
@@ -1732,6 +1758,8 @@ static void e1000_diag_test(struct net_device *netdev,
        u8 autoneg;
        bool if_running = netif_running(netdev);
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        set_bit(__E1000_TESTING, &adapter->state);
 
        if (!if_running) {
@@ -1817,6 +1845,8 @@ static void e1000_diag_test(struct net_device *netdev,
        }
 
        msleep_interruptible(4 * 1000);
+
+       pm_runtime_put_sync(netdev->dev.parent);
 }
 
 static void e1000_get_wol(struct net_device *netdev,
@@ -1891,6 +1921,8 @@ static int e1000_set_phys_id(struct net_device *netdev,
 
        switch (state) {
        case ETHTOOL_ID_ACTIVE:
+               pm_runtime_get_sync(netdev->dev.parent);
+
                if (!hw->mac.ops.blink_led)
                        return 2;       /* cycle on/off twice per second */
 
@@ -1902,6 +1934,7 @@ static int e1000_set_phys_id(struct net_device *netdev,
                        e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
                hw->mac.ops.led_off(hw);
                hw->mac.ops.cleanup_led(hw);
+               pm_runtime_put_sync(netdev->dev.parent);
                break;
 
        case ETHTOOL_ID_ON:
@@ -1912,6 +1945,7 @@ static int e1000_set_phys_id(struct net_device *netdev,
                hw->mac.ops.led_off(hw);
                break;
        }
+
        return 0;
 }
 
@@ -1950,11 +1984,15 @@ static int e1000_set_coalesce(struct net_device *netdev,
                adapter->itr_setting = adapter->itr & ~3;
        }
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        if (adapter->itr_setting != 0)
                e1000e_write_itr(adapter, adapter->itr);
        else
                e1000e_write_itr(adapter, 0);
 
+       pm_runtime_put_sync(netdev->dev.parent);
+
        return 0;
 }
 
@@ -1968,7 +2006,9 @@ static int e1000_nway_reset(struct net_device *netdev)
        if (!adapter->hw.mac.autoneg)
                return -EINVAL;
 
+       pm_runtime_get_sync(netdev->dev.parent);
        e1000e_reinit_locked(adapter);
+       pm_runtime_put_sync(netdev->dev.parent);
 
        return 0;
 }
@@ -1982,7 +2022,12 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
        int i;
        char *p = NULL;
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        e1000e_get_stats64(netdev, &net_stats);
+
+       pm_runtime_put_sync(netdev->dev.parent);
+
        for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
                switch (e1000_gstrings_stats[i].type) {
                case NETDEV_STATS:
@@ -2033,7 +2078,11 @@ static int e1000_get_rxnfc(struct net_device *netdev,
        case ETHTOOL_GRXFH: {
                struct e1000_adapter *adapter = netdev_priv(netdev);
                struct e1000_hw *hw = &adapter->hw;
-               u32 mrqc = er32(MRQC);
+               u32 mrqc;
+
+               pm_runtime_get_sync(netdev->dev.parent);
+               mrqc = er32(MRQC);
+               pm_runtime_put_sync(netdev->dev.parent);
 
                if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK))
                        return 0;
@@ -2096,9 +2145,13 @@ static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
                return -EOPNOTSUPP;
        }
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        ret_val = hw->phy.ops.acquire(hw);
-       if (ret_val)
+       if (ret_val) {
+               pm_runtime_put_sync(netdev->dev.parent);
                return -EBUSY;
+       }
 
        /* EEE Capability */
        ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data);
@@ -2117,14 +2170,11 @@ static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
 
        /* EEE PCS Status */
        ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data);
+       if (ret_val)
+               goto release;
        if (hw->phy.type == e1000_phy_82579)
                phy_data <<= 8;
 
-release:
-       hw->phy.ops.release(hw);
-       if (ret_val)
-               return -ENODATA;
-
        /* Result of the EEE auto negotiation - there is no register that
         * has the status of the EEE negotiation so do a best-guess based
         * on whether Tx or Rx LPI indications have been received.
@@ -2136,7 +2186,14 @@ release:
        edata->tx_lpi_enabled = true;
        edata->tx_lpi_timer = er32(LPIC) >> E1000_LPIC_LPIET_SHIFT;
 
-       return 0;
+release:
+       hw->phy.ops.release(hw);
+       if (ret_val)
+               ret_val = -ENODATA;
+
+       pm_runtime_put_sync(netdev->dev.parent);
+
+       return ret_val;
 }
 
 static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
@@ -2169,12 +2226,16 @@ static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
 
        hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled;
 
+       pm_runtime_get_sync(netdev->dev.parent);
+
        /* reset the link */
        if (netif_running(netdev))
                e1000e_reinit_locked(adapter);
        else
                e1000e_reset(adapter);
 
+       pm_runtime_put_sync(netdev->dev.parent);
+
        return 0;
 }
 
@@ -2212,19 +2273,7 @@ static int e1000e_get_ts_info(struct net_device *netdev,
        return 0;
 }
 
-static int e1000e_ethtool_begin(struct net_device *netdev)
-{
-       return pm_runtime_get_sync(netdev->dev.parent);
-}
-
-static void e1000e_ethtool_complete(struct net_device *netdev)
-{
-       pm_runtime_put_sync(netdev->dev.parent);
-}
-
 static const struct ethtool_ops e1000_ethtool_ops = {
-       .begin                  = e1000e_ethtool_begin,
-       .complete               = e1000e_ethtool_complete,
        .get_settings           = e1000_get_settings,
        .set_settings           = e1000_set_settings,
        .get_drvinfo            = e1000_get_drvinfo,
index a6f903a9b7731cd3460d5337b98d3ae79a4d3661..b7f38435d1fdb90336dd0c9511d78c7cd273e8d7 100644 (file)
@@ -90,6 +90,10 @@ struct e1000_hw;
 #define E1000_DEV_ID_PCH_LPT_I217_V            0x153B
 #define E1000_DEV_ID_PCH_LPTLP_I218_LM         0x155A
 #define E1000_DEV_ID_PCH_LPTLP_I218_V          0x1559
+#define E1000_DEV_ID_PCH_I218_LM2              0x15A0
+#define E1000_DEV_ID_PCH_I218_V2               0x15A1
+#define E1000_DEV_ID_PCH_I218_LM3              0x15A2  /* Wildcat Point PCH */
+#define E1000_DEV_ID_PCH_I218_V3               0x15A3  /* Wildcat Point PCH */
 
 #define E1000_REVISION_4       4
 
@@ -227,6 +231,10 @@ union e1000_rx_desc_extended {
 };
 
 #define MAX_PS_BUFFERS 4
+
+/* Number of packet split data buffers (not including the header buffer) */
+#define PS_PAGE_BUFFERS        (MAX_PS_BUFFERS - 1)
+
 /* Receive Descriptor - Packet Split */
 union e1000_rx_desc_packet_split {
        struct {
@@ -251,7 +259,8 @@ union e1000_rx_desc_packet_split {
                } middle;
                struct {
                        __le16 header_status;
-                       __le16 length[3];       /* length of buffers 1-3 */
+                       /* length of buffers 1-3 */
+                       __le16 length[PS_PAGE_BUFFERS];
                } upper;
                __le64 reserved;
        } wb; /* writeback */
index 9dde390f7e71c34f327f1e1bc213dce5338b917c..af08188d7e624471ed3e8b87df7d39fd24ba3815 100644 (file)
@@ -185,6 +185,7 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
        u32 phy_id = 0;
        s32 ret_val;
        u16 retry_count;
+       u32 mac_reg = 0;
 
        for (retry_count = 0; retry_count < 2; retry_count++) {
                ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg);
@@ -203,11 +204,11 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
 
        if (hw->phy.id) {
                if (hw->phy.id == phy_id)
-                       return true;
+                       goto out;
        } else if (phy_id) {
                hw->phy.id = phy_id;
                hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
-               return true;
+               goto out;
        }
 
        /* In case the PHY needs to be in mdio slow mode,
@@ -219,7 +220,22 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
                ret_val = e1000e_get_phy_id(hw);
        hw->phy.ops.acquire(hw);
 
-       return !ret_val;
+       if (ret_val)
+               return false;
+out:
+       if (hw->mac.type == e1000_pch_lpt) {
+               /* Unforce SMBus mode in PHY */
+               e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
+               phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
+               e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
+
+               /* Unforce SMBus mode in MAC */
+               mac_reg = er32(CTRL_EXT);
+               mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
+               ew32(CTRL_EXT, mac_reg);
+       }
+
+       return true;
 }
 
 /**
@@ -233,7 +249,6 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
 {
        u32 mac_reg, fwsm = er32(FWSM);
        s32 ret_val;
-       u16 phy_reg;
 
        /* Gate automatic PHY configuration by hardware on managed and
         * non-managed 82579 and newer adapters.
@@ -262,22 +277,16 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
                mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
                ew32(CTRL_EXT, mac_reg);
 
+               /* Wait 50 milliseconds for MAC to finish any retries
+                * that it might be trying to perform from previous
+                * attempts to acknowledge any phy read requests.
+                */
+               msleep(50);
+
                /* fall-through */
        case e1000_pch2lan:
-               if (e1000_phy_is_accessible_pchlan(hw)) {
-                       if (hw->mac.type == e1000_pch_lpt) {
-                               /* Unforce SMBus mode in PHY */
-                               e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
-                               phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
-                               e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
-
-                               /* Unforce SMBus mode in MAC */
-                               mac_reg = er32(CTRL_EXT);
-                               mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
-                               ew32(CTRL_EXT, mac_reg);
-                       }
+               if (e1000_phy_is_accessible_pchlan(hw))
                        break;
-               }
 
                /* fall-through */
        case e1000_pchlan:
@@ -287,6 +296,7 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
 
                if (hw->phy.ops.check_reset_block(hw)) {
                        e_dbg("Required LANPHYPC toggle blocked by ME\n");
+                       ret_val = -E1000_ERR_PHY;
                        break;
                }
 
@@ -298,15 +308,6 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
                mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
                ew32(FEXTNVM3, mac_reg);
 
-               if (hw->mac.type == e1000_pch_lpt) {
-                       /* Toggling LANPHYPC brings the PHY out of SMBus mode
-                        * So ensure that the MAC is also out of SMBus mode
-                        */
-                       mac_reg = er32(CTRL_EXT);
-                       mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
-                       ew32(CTRL_EXT, mac_reg);
-               }
-
                /* Toggle LANPHYPC Value bit */
                mac_reg = er32(CTRL);
                mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
@@ -325,6 +326,21 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
                                usleep_range(5000, 10000);
                        } while (!(er32(CTRL_EXT) &
                                   E1000_CTRL_EXT_LPCD) && count--);
+                       usleep_range(30000, 60000);
+                       if (e1000_phy_is_accessible_pchlan(hw))
+                               break;
+
+                       /* Toggling LANPHYPC brings the PHY out of SMBus mode
+                        * so ensure that the MAC is also out of SMBus mode
+                        */
+                       mac_reg = er32(CTRL_EXT);
+                       mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
+                       ew32(CTRL_EXT, mac_reg);
+
+                       if (e1000_phy_is_accessible_pchlan(hw))
+                               break;
+
+                       ret_val = -E1000_ERR_PHY;
                }
                break;
        default:
@@ -332,13 +348,14 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
        }
 
        hw->phy.ops.release(hw);
-
-       /* Reset the PHY before any access to it.  Doing so, ensures
-        * that the PHY is in a known good state before we read/write
-        * PHY registers.  The generic reset is sufficient here,
-        * because we haven't determined the PHY type yet.
-        */
-       ret_val = e1000e_phy_hw_reset_generic(hw);
+       if (!ret_val) {
+               /* Reset the PHY before any access to it.  Doing so, ensures
+                * that the PHY is in a known good state before we read/write
+                * PHY registers.  The generic reset is sufficient here,
+                * because we haven't determined the PHY type yet.
+                */
+               ret_val = e1000e_phy_hw_reset_generic(hw);
+       }
 
 out:
        /* Ungate automatic PHY configuration on non-managed 82579 */
@@ -793,29 +810,31 @@ release:
  *  When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
  *  preventing further DMA write requests.  Workaround the issue by disabling
  *  the de-assertion of the clock request when in 1Gpbs mode.
+ *  Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
+ *  speeds in order to avoid Tx hangs.
  **/
 static s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
 {
        u32 fextnvm6 = er32(FEXTNVM6);
+       u32 status = er32(STATUS);
        s32 ret_val = 0;
+       u16 reg;
 
-       if (link && (er32(STATUS) & E1000_STATUS_SPEED_1000)) {
-               u16 kmrn_reg;
-
+       if (link && (status & E1000_STATUS_SPEED_1000)) {
                ret_val = hw->phy.ops.acquire(hw);
                if (ret_val)
                        return ret_val;
 
                ret_val =
                    e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
-                                               &kmrn_reg);
+                                               &reg);
                if (ret_val)
                        goto release;
 
                ret_val =
                    e1000e_write_kmrn_reg_locked(hw,
                                                 E1000_KMRNCTRLSTA_K1_CONFIG,
-                                                kmrn_reg &
+                                                reg &
                                                 ~E1000_KMRNCTRLSTA_K1_ENABLE);
                if (ret_val)
                        goto release;
@@ -827,12 +846,45 @@ static s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
                ret_val =
                    e1000e_write_kmrn_reg_locked(hw,
                                                 E1000_KMRNCTRLSTA_K1_CONFIG,
-                                                kmrn_reg);
+                                                reg);
 release:
                hw->phy.ops.release(hw);
        } else {
                /* clear FEXTNVM6 bit 8 on link down or 10/100 */
-               ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
+               fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
+
+               if (!link || ((status & E1000_STATUS_SPEED_100) &&
+                             (status & E1000_STATUS_FD)))
+                       goto update_fextnvm6;
+
+               ret_val = e1e_rphy(hw, I217_INBAND_CTRL, &reg);
+               if (ret_val)
+                       return ret_val;
+
+               /* Clear link status transmit timeout */
+               reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
+
+               if (status & E1000_STATUS_SPEED_100) {
+                       /* Set inband Tx timeout to 5x10us for 100Half */
+                       reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
+
+                       /* Do not extend the K1 entry latency for 100Half */
+                       fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
+               } else {
+                       /* Set inband Tx timeout to 50x10us for 10Full/Half */
+                       reg |= 50 <<
+                           I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
+
+                       /* Extend the K1 entry latency for 10 Mbps */
+                       fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
+               }
+
+               ret_val = e1e_wphy(hw, I217_INBAND_CTRL, reg);
+               if (ret_val)
+                       return ret_val;
+
+update_fextnvm6:
+               ew32(FEXTNVM6, fextnvm6);
        }
 
        return ret_val;
@@ -993,7 +1045,9 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
 
        /* Work-around I218 hang issue */
        if ((hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
-           (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_V)) {
+           (hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
+           (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM3) ||
+           (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V3)) {
                ret_val = e1000_k1_workaround_lpt_lp(hw, link);
                if (ret_val)
                        return ret_val;
@@ -4168,7 +4222,9 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
                u16 phy_reg, device_id = hw->adapter->pdev->device;
 
                if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
-                   (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V)) {
+                   (device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
+                   (device_id == E1000_DEV_ID_PCH_I218_LM3) ||
+                   (device_id == E1000_DEV_ID_PCH_I218_V3)) {
                        u32 fextnvm6 = er32(FEXTNVM6);
 
                        ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
index 80034a2b297c1c17f39f5f66d6dbacfab512e5eb..59865695b2826a388b721b2313253e25d86a7c94 100644 (file)
@@ -93,6 +93,7 @@
 #define E1000_FEXTNVM4_BEACON_DURATION_16USEC  0x3
 
 #define E1000_FEXTNVM6_REQ_PLL_CLK     0x00000100
+#define E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION       0x00000200
 
 #define PCIE_ICH8_SNOOP_ALL    PCIE_NO_SNOOP_ALL
 
 
 #define SW_FLAG_TIMEOUT                1000    /* SW Semaphore flag timeout in ms */
 
+/* Inband Control */
+#define I217_INBAND_CTRL                               PHY_REG(770, 18)
+#define I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK     0x3F00
+#define I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT    8
+
 /* PHY Low Power Idle Control */
 #define I82579_LPI_CTRL                                PHY_REG(772, 20)
 #define I82579_LPI_CTRL_100_ENABLE             0x2000
index 77f81cbb601a4b248f4018f76a3d6efbb94726bc..e87e9b01f404446dfca553146fa4734c2af45f79 100644 (file)
@@ -64,8 +64,6 @@ static int debug = -1;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 
-static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
-
 static const struct e1000_info *e1000_info_tbl[] = {
        [board_82571]           = &e1000_82571_info,
        [board_82572]           = &e1000_82572_info,
@@ -2979,17 +2977,10 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
        u32 pages = 0;
 
        /* Workaround Si errata on PCHx - configure jumbo frame flow */
-       if (hw->mac.type >= e1000_pch2lan) {
-               s32 ret_val;
-
-               if (adapter->netdev->mtu > ETH_DATA_LEN)
-                       ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
-               else
-                       ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
-
-               if (ret_val)
-                       e_dbg("failed to enable jumbo frame workaround mode\n");
-       }
+       if ((hw->mac.type >= e1000_pch2lan) &&
+           (adapter->netdev->mtu > ETH_DATA_LEN) &&
+           e1000_lv_jumbo_workaround_ich8lan(hw, true))
+               e_dbg("failed to enable jumbo frame workaround mode\n");
 
        /* Program MC offset vector base */
        rctl = er32(RCTL);
@@ -3826,6 +3817,8 @@ void e1000e_reset(struct e1000_adapter *adapter)
                        break;
                }
 
+               pba = 14;
+               ew32(PBA, pba);
                fc->high_water = ((pba << 10) * 9 / 10) & E1000_FCRTH_RTH;
                fc->low_water = ((pba << 10) * 8 / 10) & E1000_FCRTL_RTL;
                break;
@@ -4034,6 +4027,12 @@ void e1000e_down(struct e1000_adapter *adapter)
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
 
+       /* Disable Si errata workaround on PCHx for jumbo frame flow */
+       if ((hw->mac.type >= e1000_pch2lan) &&
+           (adapter->netdev->mtu > ETH_DATA_LEN) &&
+           e1000_lv_jumbo_workaround_ich8lan(hw, false))
+               e_dbg("failed to disable jumbo frame workaround mode\n");
+
        if (!pci_channel_offline(adapter->pdev))
                e1000e_reset(adapter);
 
@@ -4683,11 +4682,11 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        struct e1000_phy_regs *phy = &adapter->phy_regs;
 
-       if ((er32(STATUS) & E1000_STATUS_LU) &&
+       if (!pm_runtime_suspended((&adapter->pdev->dev)->parent) &&
+           (er32(STATUS) & E1000_STATUS_LU) &&
            (adapter->hw.phy.media_type == e1000_media_type_copper)) {
                int ret_val;
 
-               pm_runtime_get_sync(&adapter->pdev->dev);
                ret_val = e1e_rphy(hw, MII_BMCR, &phy->bmcr);
                ret_val |= e1e_rphy(hw, MII_BMSR, &phy->bmsr);
                ret_val |= e1e_rphy(hw, MII_ADVERTISE, &phy->advertise);
@@ -4698,7 +4697,6 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
                ret_val |= e1e_rphy(hw, MII_ESTATUS, &phy->estatus);
                if (ret_val)
                        e_warn("Error reading PHY register\n");
-               pm_runtime_put_sync(&adapter->pdev->dev);
        } else {
                /* Do not read PHY registers if link is not up
                 * Set values to typical power-on defaults
@@ -5995,15 +5993,24 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
         */
        e1000e_release_hw_control(adapter);
 
+       pci_clear_master(pdev);
+
        /* The pci-e switch on some quad port adapters will report a
         * correctable error when the MAC transitions from D0 to D3.  To
         * prevent this we need to mask off the correctable errors on the
         * downstream port of the pci-e switch.
+        *
+        * We don't have the associated upstream bridge while assigning
+        * the PCI device into guest. For example, the KVM on power is
+        * one of the cases.
         */
        if (adapter->flags & FLAG_IS_QUAD_PORT) {
                struct pci_dev *us_dev = pdev->bus->self;
                u16 devctl;
 
+               if (!us_dev)
+                       return 0;
+
                pcie_capability_read_word(us_dev, PCI_EXP_DEVCTL, &devctl);
                pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL,
                                           (devctl & ~PCI_EXP_DEVCTL_CERE));
@@ -6017,38 +6024,73 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
        return 0;
 }
 
-#ifdef CONFIG_PCIEASPM
-static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
+/**
+ * e1000e_disable_aspm - Disable ASPM states
+ * @pdev: pointer to PCI device struct
+ * @state: bit-mask of ASPM states to disable
+ *
+ * Some devices *must* have certain ASPM states disabled per hardware errata.
+ **/
+static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
 {
+       struct pci_dev *parent = pdev->bus->self;
+       u16 aspm_dis_mask = 0;
+       u16 pdev_aspmc, parent_aspmc;
+
+       switch (state) {
+       case PCIE_LINK_STATE_L0S:
+       case PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1:
+               aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L0S;
+               /* fall-through - can't have L1 without L0s */
+       case PCIE_LINK_STATE_L1:
+               aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L1;
+               break;
+       default:
+               return;
+       }
+
+       pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &pdev_aspmc);
+       pdev_aspmc &= PCI_EXP_LNKCTL_ASPMC;
+
+       if (parent) {
+               pcie_capability_read_word(parent, PCI_EXP_LNKCTL,
+                                         &parent_aspmc);
+               parent_aspmc &= PCI_EXP_LNKCTL_ASPMC;
+       }
+
+       /* Nothing to do if the ASPM states to be disabled already are */
+       if (!(pdev_aspmc & aspm_dis_mask) &&
+           (!parent || !(parent_aspmc & aspm_dis_mask)))
+               return;
+
+       dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
+                (aspm_dis_mask & pdev_aspmc & PCI_EXP_LNKCTL_ASPM_L0S) ?
+                "L0s" : "",
+                (aspm_dis_mask & pdev_aspmc & PCI_EXP_LNKCTL_ASPM_L1) ?
+                "L1" : "");
+
+#ifdef CONFIG_PCIEASPM
        pci_disable_link_state_locked(pdev, state);
-}
-#else
-static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
-{
-       u16 aspm_ctl = 0;
 
-       if (state & PCIE_LINK_STATE_L0S)
-               aspm_ctl |= PCI_EXP_LNKCTL_ASPM_L0S;
-       if (state & PCIE_LINK_STATE_L1)
-               aspm_ctl |= PCI_EXP_LNKCTL_ASPM_L1;
+       /* Double-check ASPM control.  If not disabled by the above, the
+        * BIOS is preventing that from happening (or CONFIG_PCIEASPM is
+        * not enabled); override by writing PCI config space directly.
+        */
+       pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &pdev_aspmc);
+       pdev_aspmc &= PCI_EXP_LNKCTL_ASPMC;
+
+       if (!(aspm_dis_mask & pdev_aspmc))
+               return;
+#endif
 
        /* Both device and parent should have the same ASPM setting.
         * Disable ASPM in downstream component first and then upstream.
         */
-       pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_ctl);
+       pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_dis_mask);
 
-       if (pdev->bus->self)
-               pcie_capability_clear_word(pdev->bus->self, PCI_EXP_LNKCTL,
-                                          aspm_ctl);
-}
-#endif
-static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
-{
-       dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
-                (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
-                (state & PCIE_LINK_STATE_L1) ? "L1" : "");
-
-       __e1000e_disable_aspm(pdev, state);
+       if (parent)
+               pcie_capability_clear_word(parent, PCI_EXP_LNKCTL,
+                                          aspm_dis_mask);
 }
 
 #ifdef CONFIG_PM
@@ -6723,10 +6765,6 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        adapter->hw.fc.current_mode = e1000_fc_default;
        adapter->hw.phy.autoneg_advertised = 0x2f;
 
-       /* ring size defaults */
-       adapter->rx_ring->count = E1000_DEFAULT_RXD;
-       adapter->tx_ring->count = E1000_DEFAULT_TXD;
-
        /* Initial Wake on LAN setting - If APM wake is enabled in
         * the EEPROM, enable the ACPI Magic Packet filter
         */
@@ -6976,6 +7014,10 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPT_I217_V), board_pch_lpt },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPTLP_I218_LM), board_pch_lpt },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_LPTLP_I218_V), board_pch_lpt },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_I218_LM2), board_pch_lpt },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_I218_V2), board_pch_lpt },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_I218_LM3), board_pch_lpt },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_I218_V3), board_pch_lpt },
 
        { 0, 0, 0, 0, 0, 0, 0 } /* terminate list */
 };
index f21a91a299a2200995be96c6a92dd05d80060c9b..d398fad6eedc78d2a8f080f7dd0ec32182548979 100644 (file)
@@ -238,6 +238,7 @@ static s32 igb_init_nvm_params_82575(struct e1000_hw *hw)
 
        size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
                     E1000_EECD_SIZE_EX_SHIFT);
+
        /* Added to a constant, "size" becomes the left-shift value
         * for setting word_size.
         */
@@ -250,86 +251,52 @@ static s32 igb_init_nvm_params_82575(struct e1000_hw *hw)
                size = 15;
 
        nvm->word_size = 1 << size;
-       if (hw->mac.type < e1000_i210) {
-               nvm->opcode_bits = 8;
-               nvm->delay_usec = 1;
-
-               switch (nvm->override) {
-               case e1000_nvm_override_spi_large:
-                       nvm->page_size = 32;
-                       nvm->address_bits = 16;
-                       break;
-               case e1000_nvm_override_spi_small:
-                       nvm->page_size = 8;
-                       nvm->address_bits = 8;
-                       break;
-               default:
-                       nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
-                       nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ?
-                                           16 : 8;
-                       break;
-               }
-               if (nvm->word_size == (1 << 15))
-                       nvm->page_size = 128;
+       nvm->opcode_bits = 8;
+       nvm->delay_usec = 1;
 
-               nvm->type = e1000_nvm_eeprom_spi;
-       } else {
-               nvm->type = e1000_nvm_flash_hw;
+       switch (nvm->override) {
+       case e1000_nvm_override_spi_large:
+               nvm->page_size = 32;
+               nvm->address_bits = 16;
+               break;
+       case e1000_nvm_override_spi_small:
+               nvm->page_size = 8;
+               nvm->address_bits = 8;
+               break;
+       default:
+               nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
+               nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ?
+                                   16 : 8;
+               break;
        }
+       if (nvm->word_size == (1 << 15))
+               nvm->page_size = 128;
+
+       nvm->type = e1000_nvm_eeprom_spi;
 
        /* NVM Function Pointers */
+       nvm->ops.acquire = igb_acquire_nvm_82575;
+       nvm->ops.release = igb_release_nvm_82575;
+       nvm->ops.write = igb_write_nvm_spi;
+       nvm->ops.validate = igb_validate_nvm_checksum;
+       nvm->ops.update = igb_update_nvm_checksum;
+       if (nvm->word_size < (1 << 15))
+               nvm->ops.read = igb_read_nvm_eerd;
+       else
+               nvm->ops.read = igb_read_nvm_spi;
+
+       /* override generic family function pointers for specific descendants */
        switch (hw->mac.type) {
        case e1000_82580:
                nvm->ops.validate = igb_validate_nvm_checksum_82580;
                nvm->ops.update = igb_update_nvm_checksum_82580;
-               nvm->ops.acquire = igb_acquire_nvm_82575;
-               nvm->ops.release = igb_release_nvm_82575;
-               if (nvm->word_size < (1 << 15))
-                       nvm->ops.read = igb_read_nvm_eerd;
-               else
-                       nvm->ops.read = igb_read_nvm_spi;
-               nvm->ops.write = igb_write_nvm_spi;
                break;
        case e1000_i354:
        case e1000_i350:
                nvm->ops.validate = igb_validate_nvm_checksum_i350;
                nvm->ops.update = igb_update_nvm_checksum_i350;
-               nvm->ops.acquire = igb_acquire_nvm_82575;
-               nvm->ops.release = igb_release_nvm_82575;
-               if (nvm->word_size < (1 << 15))
-                       nvm->ops.read = igb_read_nvm_eerd;
-               else
-                       nvm->ops.read = igb_read_nvm_spi;
-               nvm->ops.write = igb_write_nvm_spi;
-               break;
-       case e1000_i210:
-               nvm->ops.validate = igb_validate_nvm_checksum_i210;
-               nvm->ops.update   = igb_update_nvm_checksum_i210;
-               nvm->ops.acquire = igb_acquire_nvm_i210;
-               nvm->ops.release = igb_release_nvm_i210;
-               nvm->ops.read    = igb_read_nvm_srrd_i210;
-               nvm->ops.write   = igb_write_nvm_srwr_i210;
-               nvm->ops.valid_led_default = igb_valid_led_default_i210;
-               break;
-       case e1000_i211:
-               nvm->ops.acquire  = igb_acquire_nvm_i210;
-               nvm->ops.release  = igb_release_nvm_i210;
-               nvm->ops.read     = igb_read_nvm_i211;
-               nvm->ops.valid_led_default = igb_valid_led_default_i210;
-               nvm->ops.validate = NULL;
-               nvm->ops.update   = NULL;
-               nvm->ops.write    = NULL;
                break;
        default:
-               nvm->ops.validate = igb_validate_nvm_checksum;
-               nvm->ops.update = igb_update_nvm_checksum;
-               nvm->ops.acquire = igb_acquire_nvm_82575;
-               nvm->ops.release = igb_release_nvm_82575;
-               if (nvm->word_size < (1 << 15))
-                       nvm->ops.read = igb_read_nvm_eerd;
-               else
-                       nvm->ops.read = igb_read_nvm_spi;
-               nvm->ops.write = igb_write_nvm_spi;
                break;
        }
 
@@ -516,6 +483,8 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
        case E1000_DEV_ID_I210_FIBER:
        case E1000_DEV_ID_I210_SERDES:
        case E1000_DEV_ID_I210_SGMII:
+       case E1000_DEV_ID_I210_COPPER_FLASHLESS:
+       case E1000_DEV_ID_I210_SERDES_FLASHLESS:
                mac->type = e1000_i210;
                break;
        case E1000_DEV_ID_I211_COPPER:
@@ -601,6 +570,15 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
 
        /* NVM initialization */
        ret_val = igb_init_nvm_params_82575(hw);
+       switch (hw->mac.type) {
+       case e1000_i210:
+       case e1000_i211:
+               ret_val = igb_init_nvm_params_i210(hw);
+               break;
+       default:
+               break;
+       }
+
        if (ret_val)
                goto out;
 
@@ -1320,7 +1298,7 @@ void igb_shutdown_serdes_link_82575(struct e1000_hw *hw)
  **/
 static s32 igb_reset_hw_82575(struct e1000_hw *hw)
 {
-       u32 ctrl, icr;
+       u32 ctrl;
        s32 ret_val;
 
        /* Prevent the PCI-E bus from sticking if there is no TLP connection
@@ -1365,7 +1343,7 @@ static s32 igb_reset_hw_82575(struct e1000_hw *hw)
 
        /* Clear any pending interrupt events. */
        wr32(E1000_IMC, 0xffffffff);
-       icr = rd32(E1000_ICR);
+       rd32(E1000_ICR);
 
        /* Install any alternate MAC address into RAR0 */
        ret_val = igb_check_alt_mac_addr(hw);
@@ -2103,10 +2081,9 @@ static s32 igb_reset_hw_82580(struct e1000_hw *hw)
        s32 ret_val = 0;
        /* BH SW mailbox bit in SW_FW_SYNC */
        u16 swmbsw_mask = E1000_SW_SYNCH_MB;
-       u32 ctrl, icr;
+       u32 ctrl;
        bool global_device_reset = hw->dev_spec._82575.global_device_reset;
 
-
        hw->dev_spec._82575.global_device_reset = false;
 
        /* due to hw errata, global device reset doesn't always
@@ -2165,7 +2142,7 @@ static s32 igb_reset_hw_82580(struct e1000_hw *hw)
 
        /* Clear any pending interrupt events. */
        wr32(E1000_IMC, 0xffffffff);
-       icr = rd32(E1000_ICR);
+       rd32(E1000_ICR);
 
        ret_val = igb_reset_mdicnfg_82580(hw);
        if (ret_val)
index aa201abb8ad2809aeadbfbea73f00bc4f913e132..60559af39a98b09e091fc30298dd1991a73f2bf1 100644 (file)
 #define E1000_EECD_SIZE_EX_SHIFT     11
 #define E1000_EECD_FLUPD_I210          0x00800000 /* Update FLASH */
 #define E1000_EECD_FLUDONE_I210                0x04000000 /* Update FLASH done*/
+#define E1000_EECD_FLASH_DETECTED_I210 0x00080000 /* FLASH detected */
 #define E1000_FLUDONE_ATTEMPTS         20000
 #define E1000_EERD_EEWR_MAX_COUNT      512 /* buffered EEPROM words rw */
 #define E1000_I210_FIFO_SEL_RX         0x00
 #define E1000_I210_FIFO_SEL_TX_LEGACY  E1000_I210_FIFO_SEL_TX_QAV(0)
 #define E1000_I210_FIFO_SEL_BMC2OS_TX  0x06
 #define E1000_I210_FIFO_SEL_BMC2OS_RX  0x01
+#define E1000_I210_FLASH_SECTOR_SIZE   0x1000 /* 4KB FLASH sector unit size */
+/* Secure FLASH mode requires removing MSb */
+#define E1000_I210_FW_PTR_MASK         0x7FFF
+/* Firmware code revision field word offset*/
+#define E1000_I210_FW_VER_OFFSET       328
 #define E1000_EECD_FLUPD_I210          0x00800000 /* Update FLASH */
 #define E1000_EECD_FLUDONE_I210                0x04000000 /* Update FLASH done*/
 #define E1000_FLUDONE_ATTEMPTS         20000
 #define NVM_INIT_CTRL_4            0x0013
 #define NVM_LED_1_CFG              0x001C
 #define NVM_LED_0_2_CFG            0x001F
-
-/* NVM version defines */
 #define NVM_ETRACK_WORD            0x0042
+#define NVM_ETRACK_HIWORD          0x0043
 #define NVM_COMB_VER_OFF           0x0083
 #define NVM_COMB_VER_PTR           0x003d
-#define NVM_MAJOR_MASK             0xF000
-#define NVM_MINOR_MASK             0x0FF0
-#define NVM_BUILD_MASK             0x000F
-#define NVM_COMB_VER_MASK          0x00FF
-#define NVM_MAJOR_SHIFT                12
-#define NVM_MINOR_SHIFT                 4
-#define NVM_COMB_VER_SHFT               8
-#define NVM_VER_INVALID            0xFFFF
-#define NVM_ETRACK_SHIFT               16
+
+/* NVM version defines */
+#define NVM_MAJOR_MASK                 0xF000
+#define NVM_MINOR_MASK                 0x0FF0
+#define NVM_IMAGE_ID_MASK              0x000F
+#define NVM_COMB_VER_MASK              0x00FF
+#define NVM_MAJOR_SHIFT                        12
+#define NVM_MINOR_SHIFT                        4
+#define NVM_COMB_VER_SHFT              8
+#define NVM_VER_INVALID                        0xFFFF
+#define NVM_ETRACK_SHIFT               16
+#define NVM_ETRACK_VALID               0x8000
+#define NVM_NEW_DEC_MASK               0x0F00
+#define NVM_HEX_CONV                   16
+#define NVM_HEX_TENS                   10
+
 #define NVM_ETS_CFG                    0x003E
 #define NVM_ETS_LTHRES_DELTA_MASK      0x07C0
 #define NVM_ETS_LTHRES_DELTA_SHIFT     6
index 94d7866b9c2086b4d0919711a7b6eec2f889bf20..37a9c06a6c6816bf3f87c82986851504d79d7b71 100644 (file)
@@ -67,6 +67,8 @@ struct e1000_hw;
 #define E1000_DEV_ID_I210_FIBER                        0x1536
 #define E1000_DEV_ID_I210_SERDES               0x1537
 #define E1000_DEV_ID_I210_SGMII                        0x1538
+#define E1000_DEV_ID_I210_COPPER_FLASHLESS     0x157B
+#define E1000_DEV_ID_I210_SERDES_FLASHLESS     0x157C
 #define E1000_DEV_ID_I211_COPPER               0x1539
 #define E1000_DEV_ID_I354_BACKPLANE_1GBPS      0x1F40
 #define E1000_DEV_ID_I354_SGMII                        0x1F41
@@ -110,6 +112,7 @@ enum e1000_nvm_type {
        e1000_nvm_none,
        e1000_nvm_eeprom_spi,
        e1000_nvm_flash_hw,
+       e1000_nvm_invm,
        e1000_nvm_flash_sw
 };
 
index ddb3cf51b9b91825875fa2ecbb84e69fef09dff0..0c0393316a3a4eb0b3784e72003cf6367bba8061 100644 (file)
@@ -335,57 +335,101 @@ s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
 }
 
 /**
- *  igb_read_nvm_i211 - Read NVM wrapper function for I211
+ *  igb_read_invm_word_i210 - Reads OTP
+ *  @hw: pointer to the HW structure
+ *  @address: the word address (aka eeprom offset) to read
+ *  @data: pointer to the data read
+ *
+ *  Reads 16-bit words from the OTP. Return error when the word is not
+ *  stored in OTP.
+ **/
+static s32 igb_read_invm_word_i210(struct e1000_hw *hw, u8 address, u16 *data)
+{
+       s32 status = -E1000_ERR_INVM_VALUE_NOT_FOUND;
+       u32 invm_dword;
+       u16 i;
+       u8 record_type, word_address;
+
+       for (i = 0; i < E1000_INVM_SIZE; i++) {
+               invm_dword = rd32(E1000_INVM_DATA_REG(i));
+               /* Get record type */
+               record_type = INVM_DWORD_TO_RECORD_TYPE(invm_dword);
+               if (record_type == E1000_INVM_UNINITIALIZED_STRUCTURE)
+                       break;
+               if (record_type == E1000_INVM_CSR_AUTOLOAD_STRUCTURE)
+                       i += E1000_INVM_CSR_AUTOLOAD_DATA_SIZE_IN_DWORDS;
+               if (record_type == E1000_INVM_RSA_KEY_SHA256_STRUCTURE)
+                       i += E1000_INVM_RSA_KEY_SHA256_DATA_SIZE_IN_DWORDS;
+               if (record_type == E1000_INVM_WORD_AUTOLOAD_STRUCTURE) {
+                       word_address = INVM_DWORD_TO_WORD_ADDRESS(invm_dword);
+                       if (word_address == address) {
+                               *data = INVM_DWORD_TO_WORD_DATA(invm_dword);
+                               hw_dbg("Read INVM Word 0x%02x = %x",
+                                         address, *data);
+                               status = E1000_SUCCESS;
+                               break;
+                       }
+               }
+       }
+       if (status != E1000_SUCCESS)
+               hw_dbg("Requested word 0x%02x not found in OTP\n", address);
+       return status;
+}
+
+/**
+ * igb_read_invm_i210 - Read invm wrapper function for I210/I211
  *  @hw: pointer to the HW structure
  *  @words: number of words to read
  *  @data: pointer to the data read
  *
  *  Wrapper function to return data formerly found in the NVM.
  **/
-s32 igb_read_nvm_i211(struct e1000_hw *hw, u16 offset, u16 words,
-                              u16 *data)
+static s32 igb_read_invm_i210(struct e1000_hw *hw, u16 offset,
+                               u16 words __always_unused, u16 *data)
 {
        s32 ret_val = E1000_SUCCESS;
 
        /* Only the MAC addr is required to be present in the iNVM */
        switch (offset) {
        case NVM_MAC_ADDR:
-               ret_val = igb_read_invm_i211(hw, offset, &data[0]);
-               ret_val |= igb_read_invm_i211(hw, offset+1, &data[1]);
-               ret_val |= igb_read_invm_i211(hw, offset+2, &data[2]);
+               ret_val = igb_read_invm_word_i210(hw, (u8)offset, &data[0]);
+               ret_val |= igb_read_invm_word_i210(hw, (u8)offset+1,
+                                                    &data[1]);
+               ret_val |= igb_read_invm_word_i210(hw, (u8)offset+2,
+                                                    &data[2]);
                if (ret_val != E1000_SUCCESS)
                        hw_dbg("MAC Addr not found in iNVM\n");
                break;
        case NVM_INIT_CTRL_2:
-               ret_val = igb_read_invm_i211(hw, (u8)offset, data);
+               ret_val = igb_read_invm_word_i210(hw, (u8)offset, data);
                if (ret_val != E1000_SUCCESS) {
                        *data = NVM_INIT_CTRL_2_DEFAULT_I211;
                        ret_val = E1000_SUCCESS;
                }
                break;
        case NVM_INIT_CTRL_4:
-               ret_val = igb_read_invm_i211(hw, (u8)offset, data);
+               ret_val = igb_read_invm_word_i210(hw, (u8)offset, data);
                if (ret_val != E1000_SUCCESS) {
                        *data = NVM_INIT_CTRL_4_DEFAULT_I211;
                        ret_val = E1000_SUCCESS;
                }
                break;
        case NVM_LED_1_CFG:
-               ret_val = igb_read_invm_i211(hw, (u8)offset, data);
+               ret_val = igb_read_invm_word_i210(hw, (u8)offset, data);
                if (ret_val != E1000_SUCCESS) {
                        *data = NVM_LED_1_CFG_DEFAULT_I211;
                        ret_val = E1000_SUCCESS;
                }
                break;
        case NVM_LED_0_2_CFG:
-               igb_read_invm_i211(hw, offset, data);
+               ret_val = igb_read_invm_word_i210(hw, (u8)offset, data);
                if (ret_val != E1000_SUCCESS) {
                        *data = NVM_LED_0_2_CFG_DEFAULT_I211;
                        ret_val = E1000_SUCCESS;
                }
                break;
        case NVM_ID_LED_SETTINGS:
-               ret_val = igb_read_invm_i211(hw, (u8)offset, data);
+               ret_val = igb_read_invm_word_i210(hw, (u8)offset, data);
                if (ret_val != E1000_SUCCESS) {
                        *data = ID_LED_RESERVED_FFFF;
                        ret_val = E1000_SUCCESS;
@@ -410,48 +454,6 @@ s32 igb_read_nvm_i211(struct e1000_hw *hw, u16 offset, u16 words,
        return ret_val;
 }
 
-/**
- *  igb_read_invm_i211 - Reads OTP
- *  @hw: pointer to the HW structure
- *  @address: the word address (aka eeprom offset) to read
- *  @data: pointer to the data read
- *
- *  Reads 16-bit words from the OTP. Return error when the word is not
- *  stored in OTP.
- **/
-s32 igb_read_invm_i211(struct e1000_hw *hw, u16 address, u16 *data)
-{
-       s32 status = -E1000_ERR_INVM_VALUE_NOT_FOUND;
-       u32 invm_dword;
-       u16 i;
-       u8 record_type, word_address;
-
-       for (i = 0; i < E1000_INVM_SIZE; i++) {
-               invm_dword = rd32(E1000_INVM_DATA_REG(i));
-               /* Get record type */
-               record_type = INVM_DWORD_TO_RECORD_TYPE(invm_dword);
-               if (record_type == E1000_INVM_UNINITIALIZED_STRUCTURE)
-                       break;
-               if (record_type == E1000_INVM_CSR_AUTOLOAD_STRUCTURE)
-                       i += E1000_INVM_CSR_AUTOLOAD_DATA_SIZE_IN_DWORDS;
-               if (record_type == E1000_INVM_RSA_KEY_SHA256_STRUCTURE)
-                       i += E1000_INVM_RSA_KEY_SHA256_DATA_SIZE_IN_DWORDS;
-               if (record_type == E1000_INVM_WORD_AUTOLOAD_STRUCTURE) {
-                       word_address = INVM_DWORD_TO_WORD_ADDRESS(invm_dword);
-                       if (word_address == (u8)address) {
-                               *data = INVM_DWORD_TO_WORD_DATA(invm_dword);
-                               hw_dbg("Read INVM Word 0x%02x = %x",
-                                         address, *data);
-                               status = E1000_SUCCESS;
-                               break;
-                       }
-               }
-       }
-       if (status != E1000_SUCCESS)
-               hw_dbg("Requested word 0x%02x not found in OTP\n", address);
-       return status;
-}
-
 /**
  *  igb_read_invm_version - Reads iNVM version and image type
  *  @hw: pointer to the HW structure
@@ -660,6 +662,23 @@ static s32 igb_pool_flash_update_done_i210(struct e1000_hw *hw)
        return ret_val;
 }
 
+/**
+ *  igb_get_flash_presence_i210 - Check if flash device is detected.
+ *  @hw: pointer to the HW structure
+ *
+ **/
+bool igb_get_flash_presence_i210(struct e1000_hw *hw)
+{
+       u32 eec = 0;
+       bool ret_val = false;
+
+       eec = rd32(E1000_EECD);
+       if (eec & E1000_EECD_FLASH_DETECTED_I210)
+               ret_val = true;
+
+       return ret_val;
+}
+
 /**
  *  igb_update_flash_i210 - Commit EEPROM to the flash
  *  @hw: pointer to the HW structure
@@ -786,3 +805,33 @@ s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data)
 {
        return __igb_access_xmdio_reg(hw, addr, dev_addr, &data, false);
 }
+
+/**
+ *  igb_init_nvm_params_i210 - Init NVM func ptrs.
+ *  @hw: pointer to the HW structure
+ **/
+s32 igb_init_nvm_params_i210(struct e1000_hw *hw)
+{
+       s32 ret_val = 0;
+       struct e1000_nvm_info *nvm = &hw->nvm;
+
+       nvm->ops.acquire = igb_acquire_nvm_i210;
+       nvm->ops.release = igb_release_nvm_i210;
+       nvm->ops.valid_led_default = igb_valid_led_default_i210;
+
+       /* NVM Function Pointers */
+       if (igb_get_flash_presence_i210(hw)) {
+               hw->nvm.type = e1000_nvm_flash_hw;
+               nvm->ops.read    = igb_read_nvm_srrd_i210;
+               nvm->ops.write   = igb_write_nvm_srwr_i210;
+               nvm->ops.validate = igb_validate_nvm_checksum_i210;
+               nvm->ops.update   = igb_update_nvm_checksum_i210;
+       } else {
+               hw->nvm.type = e1000_nvm_invm;
+               nvm->ops.read     = igb_read_invm_i210;
+               nvm->ops.write    = NULL;
+               nvm->ops.validate = NULL;
+               nvm->ops.update   = NULL;
+       }
+       return ret_val;
+}
index 5caa332e7556628806491b186ada8e43ec88abf0..dde3c4b7ea9971db46981bc319faeb5fe56e452c 100644 (file)
@@ -35,20 +35,19 @@ extern s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset,
                              u16 words, u16 *data);
 extern s32 igb_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset,
                             u16 words, u16 *data);
-extern s32 igb_read_invm_i211(struct e1000_hw *hw, u16 address, u16 *data);
 extern s32 igb_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
 extern void igb_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
 extern s32 igb_acquire_nvm_i210(struct e1000_hw *hw);
 extern void igb_release_nvm_i210(struct e1000_hw *hw);
 extern s32 igb_valid_led_default_i210(struct e1000_hw *hw, u16 *data);
-extern s32 igb_read_nvm_i211(struct e1000_hw *hw, u16 offset, u16 words,
-                              u16 *data);
 extern s32 igb_read_invm_version(struct e1000_hw *hw,
                                 struct e1000_fw_version *invm_ver);
 extern s32 igb_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr,
                              u16 *data);
 extern s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr,
                               u16 data);
+extern s32 igb_init_nvm_params_i210(struct e1000_hw *hw);
+extern bool igb_get_flash_presence_i210(struct e1000_hw *hw);
 
 #define E1000_STM_OPCODE               0xDB00
 #define E1000_EEPROM_FLASH_SIZE_WORD   0x11
index 7f9cd7cbd353debcbb5eb20ba44ebd36ec61abcc..a7db7f3db914daafb957d11372b885614152020c 100644 (file)
@@ -709,11 +709,16 @@ out:
  **/
 void igb_get_fw_version(struct e1000_hw *hw, struct e1000_fw_version *fw_vers)
 {
-       u16 eeprom_verh, eeprom_verl, comb_verh, comb_verl, comb_offset;
-       u16 fw_version;
+       u16 eeprom_verh, eeprom_verl, etrack_test, fw_version;
+       u8 q, hval, rem, result;
+       u16 comb_verh, comb_verl, comb_offset;
 
        memset(fw_vers, 0, sizeof(struct e1000_fw_version));
 
+       /* basic eeprom version numbers and bits used vary by part and by tool
+        * used to create the nvm images. Check which data format we have.
+        */
+       hw->nvm.ops.read(hw, NVM_ETRACK_HIWORD, 1, &etrack_test);
        switch (hw->mac.type) {
        case e1000_i211:
                igb_read_invm_version(hw, fw_vers);
@@ -721,30 +726,30 @@ void igb_get_fw_version(struct e1000_hw *hw, struct e1000_fw_version *fw_vers)
        case e1000_82575:
        case e1000_82576:
        case e1000_82580:
-       case e1000_i354:
-       case e1000_i350:
-       case e1000_i210:
+               /* Use this format, unless EETRACK ID exists,
+                * then use alternate format
+                */
+               if ((etrack_test &  NVM_MAJOR_MASK) != NVM_ETRACK_VALID) {
+                       hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version);
+                       fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK)
+                                             >> NVM_MAJOR_SHIFT;
+                       fw_vers->eep_minor = (fw_version & NVM_MINOR_MASK)
+                                             >> NVM_MINOR_SHIFT;
+                       fw_vers->eep_build = (fw_version & NVM_IMAGE_ID_MASK);
+                       goto etrack_id;
+               }
                break;
-       default:
-               return;
-       }
-       /* basic eeprom version numbers */
-       hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version);
-       fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK) >> NVM_MAJOR_SHIFT;
-       fw_vers->eep_minor = (fw_version & NVM_MINOR_MASK);
-
-       /* etrack id */
-       hw->nvm.ops.read(hw, NVM_ETRACK_WORD, 1, &eeprom_verl);
-       hw->nvm.ops.read(hw, (NVM_ETRACK_WORD + 1), 1, &eeprom_verh);
-       fw_vers->etrack_id = (eeprom_verh << NVM_ETRACK_SHIFT) | eeprom_verl;
-
-       switch (hw->mac.type) {
        case e1000_i210:
-       case e1000_i354:
+               if (!(igb_get_flash_presence_i210(hw))) {
+                       igb_read_invm_version(hw, fw_vers);
+                       return;
+               }
+               /* fall through */
        case e1000_i350:
                /* find combo image version */
                hw->nvm.ops.read(hw, NVM_COMB_VER_PTR, 1, &comb_offset);
-               if ((comb_offset != 0x0) && (comb_offset != NVM_VER_INVALID)) {
+               if ((comb_offset != 0x0) &&
+                   (comb_offset != NVM_VER_INVALID)) {
 
                        hw->nvm.ops.read(hw, (NVM_COMB_VER_OFF + comb_offset
                                         + 1), 1, &comb_verh);
@@ -760,15 +765,42 @@ void igb_get_fw_version(struct e1000_hw *hw, struct e1000_fw_version *fw_vers)
                                fw_vers->or_major =
                                        comb_verl >> NVM_COMB_VER_SHFT;
                                fw_vers->or_build =
-                                       ((comb_verl << NVM_COMB_VER_SHFT)
-                                       | (comb_verh >> NVM_COMB_VER_SHFT));
+                                       (comb_verl << NVM_COMB_VER_SHFT)
+                                       | (comb_verh >> NVM_COMB_VER_SHFT);
                                fw_vers->or_patch =
                                        comb_verh & NVM_COMB_VER_MASK;
                        }
                }
                break;
        default:
-               break;
+               return;
+       }
+       hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version);
+       fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK)
+                             >> NVM_MAJOR_SHIFT;
+
+       /* check for old style version format in newer images*/
+       if ((fw_version & NVM_NEW_DEC_MASK) == 0x0) {
+               eeprom_verl = (fw_version & NVM_COMB_VER_MASK);
+       } else {
+               eeprom_verl = (fw_version & NVM_MINOR_MASK)
+                               >> NVM_MINOR_SHIFT;
+       }
+       /* Convert minor value to hex before assigning to output struct
+        * Val to be converted will not be higher than 99, per tool output
+        */
+       q = eeprom_verl / NVM_HEX_CONV;
+       hval = q * NVM_HEX_TENS;
+       rem = eeprom_verl % NVM_HEX_CONV;
+       result = hval + rem;
+       fw_vers->eep_minor = result;
+
+etrack_id:
+       if ((etrack_test &  NVM_MAJOR_MASK) == NVM_ETRACK_VALID) {
+               hw->nvm.ops.read(hw, NVM_ETRACK_WORD, 1, &eeprom_verl);
+               hw->nvm.ops.read(hw, (NVM_ETRACK_WORD + 1), 1, &eeprom_verh);
+               fw_vers->etrack_id = (eeprom_verh << NVM_ETRACK_SHIFT)
+                       | eeprom_verl;
        }
        return;
 }
index 6bfc0c43aace635084b265441c1fb91cb6c86bdc..433b7419cb98ad15bb3da0532fb120ff25ff4596 100644 (file)
@@ -44,6 +44,7 @@ struct e1000_fw_version {
        u32 etrack_id;
        u16 eep_major;
        u16 eep_minor;
+       u16 eep_build;
 
        u8 invm_major;
        u8 invm_minor;
index 15ea8dc9dad3dc1c5c86e6682882802da574d9d3..c1fae7aa0bd55b278205f493701337b2f9eaac4b 100644 (file)
@@ -343,6 +343,8 @@ struct hwmon_buff {
        };
 #endif
 
+#define IGB_RETA_SIZE  128
+
 /* board specific private data structure */
 struct igb_adapter {
        unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
@@ -444,6 +446,8 @@ struct igb_adapter {
        struct i2c_algo_bit_data i2c_algo;
        struct i2c_adapter i2c_adap;
        struct i2c_client *i2c_client;
+       u32 rss_indir_tbl_init;
+       u8 rss_indir_tbl[IGB_RETA_SIZE];
 };
 
 #define IGB_FLAG_HAS_MSI               (1 << 0)
@@ -480,6 +484,7 @@ extern int igb_up(struct igb_adapter *);
 extern void igb_down(struct igb_adapter *);
 extern void igb_reinit_locked(struct igb_adapter *);
 extern void igb_reset(struct igb_adapter *);
+extern void igb_write_rss_indir_tbl(struct igb_adapter *);
 extern int igb_set_spd_dplx(struct igb_adapter *, u32, u8);
 extern int igb_setup_tx_resources(struct igb_ring *);
 extern int igb_setup_rx_resources(struct igb_ring *);
index 85fe7b52f435cf9444cab5d1c466e9e604e3f40b..ce9b5a9e480cd953086a6986d841e72a330ef7f6 100644 (file)
@@ -1335,12 +1335,23 @@ static int igb_reg_test(struct igb_adapter *adapter, u64 *data)
 
 static int igb_eeprom_test(struct igb_adapter *adapter, u64 *data)
 {
+       struct e1000_hw *hw = &adapter->hw;
+
        *data = 0;
 
-       /* Validate eeprom on all parts but i211 */
-       if (adapter->hw.mac.type != e1000_i211) {
+       /* Validate eeprom on all parts but flashless */
+       switch (hw->mac.type) {
+       case e1000_i210:
+       case e1000_i211:
+               if (igb_get_flash_presence_i210(hw)) {
+                       if (adapter->hw.nvm.ops.validate(&adapter->hw) < 0)
+                               *data = 2;
+               }
+               break;
+       default:
                if (adapter->hw.nvm.ops.validate(&adapter->hw) < 0)
                        *data = 2;
+               break;
        }
 
        return *data;
@@ -2672,7 +2683,9 @@ static int igb_set_eee(struct net_device *netdev,
                igb_set_eee_i350(hw);
 
                /* reset link */
-               if (!netif_running(netdev))
+               if (netif_running(netdev))
+                       igb_reinit_locked(adapter);
+               else
                        igb_reset(adapter);
        }
 
@@ -2771,6 +2784,90 @@ static void igb_ethtool_complete(struct net_device *netdev)
        pm_runtime_put(&adapter->pdev->dev);
 }
 
+static u32 igb_get_rxfh_indir_size(struct net_device *netdev)
+{
+       return IGB_RETA_SIZE;
+}
+
+static int igb_get_rxfh_indir(struct net_device *netdev, u32 *indir)
+{
+       struct igb_adapter *adapter = netdev_priv(netdev);
+       int i;
+
+       for (i = 0; i < IGB_RETA_SIZE; i++)
+               indir[i] = adapter->rss_indir_tbl[i];
+
+       return 0;
+}
+
+void igb_write_rss_indir_tbl(struct igb_adapter *adapter)
+{
+       struct e1000_hw *hw = &adapter->hw;
+       u32 reg = E1000_RETA(0);
+       u32 shift = 0;
+       int i = 0;
+
+       switch (hw->mac.type) {
+       case e1000_82575:
+               shift = 6;
+               break;
+       case e1000_82576:
+               /* 82576 supports 2 RSS queues for SR-IOV */
+               if (adapter->vfs_allocated_count)
+                       shift = 3;
+               break;
+       default:
+               break;
+       }
+
+       while (i < IGB_RETA_SIZE) {
+               u32 val = 0;
+               int j;
+
+               for (j = 3; j >= 0; j--) {
+                       val <<= 8;
+                       val |= adapter->rss_indir_tbl[i + j];
+               }
+
+               wr32(reg, val << shift);
+               reg += 4;
+               i += 4;
+       }
+}
+
+static int igb_set_rxfh_indir(struct net_device *netdev, const u32 *indir)
+{
+       struct igb_adapter *adapter = netdev_priv(netdev);
+       struct e1000_hw *hw = &adapter->hw;
+       int i;
+       u32 num_queues;
+
+       num_queues = adapter->rss_queues;
+
+       switch (hw->mac.type) {
+       case e1000_82576:
+               /* 82576 supports 2 RSS queues for SR-IOV */
+               if (adapter->vfs_allocated_count)
+                       num_queues = 2;
+               break;
+       default:
+               break;
+       }
+
+       /* Verify user input. */
+       for (i = 0; i < IGB_RETA_SIZE; i++)
+               if (indir[i] >= num_queues)
+                       return -EINVAL;
+
+
+       for (i = 0; i < IGB_RETA_SIZE; i++)
+               adapter->rss_indir_tbl[i] = indir[i];
+
+       igb_write_rss_indir_tbl(adapter);
+
+       return 0;
+}
+
 static const struct ethtool_ops igb_ethtool_ops = {
        .get_settings           = igb_get_settings,
        .set_settings           = igb_set_settings,
@@ -2804,6 +2901,9 @@ static const struct ethtool_ops igb_ethtool_ops = {
        .set_eee                = igb_set_eee,
        .get_module_info        = igb_get_module_info,
        .get_module_eeprom      = igb_get_module_eeprom,
+       .get_rxfh_indir_size    = igb_get_rxfh_indir_size,
+       .get_rxfh_indir         = igb_get_rxfh_indir,
+       .set_rxfh_indir         = igb_set_rxfh_indir,
        .begin                  = igb_ethtool_begin,
        .complete               = igb_ethtool_complete,
 };
index 6a0c1b66ce54116b88a8aaf33bcf0518a7ef7ca3..df33c4b8fa8198846a024df90b70b37afa9c2260 100644 (file)
@@ -85,6 +85,8 @@ static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_FIBER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_SERDES), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_SGMII), board_82575 },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_COPPER_FLASHLESS), board_82575 },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_SERDES_FLASHLESS), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_COPPER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_FIBER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_SERDES), board_82575 },
@@ -1013,7 +1015,7 @@ static void igb_free_q_vector(struct igb_adapter *adapter, int v_idx)
        adapter->q_vector[v_idx] = NULL;
        netif_napi_del(&q_vector->napi);
 
-       /* ixgbe_get_stats64() might access the rings on this vector,
+       /* igb_get_stats64() might access the rings on this vector,
         * we must wait a grace period before freeing it.
         */
        kfree_rcu(q_vector, rcu);
@@ -1929,12 +1931,17 @@ void igb_set_fw_version(struct igb_adapter *adapter)
        igb_get_fw_version(hw, &fw);
 
        switch (hw->mac.type) {
+       case e1000_i210:
        case e1000_i211:
-               snprintf(adapter->fw_version, sizeof(adapter->fw_version),
-                        "%2d.%2d-%d",
-                        fw.invm_major, fw.invm_minor, fw.invm_img_type);
-               break;
-
+               if (!(igb_get_flash_presence_i210(hw))) {
+                       snprintf(adapter->fw_version,
+                                sizeof(adapter->fw_version),
+                                "%2d.%2d-%d",
+                                fw.invm_major, fw.invm_minor,
+                                fw.invm_img_type);
+                       break;
+               }
+               /* fall through */
        default:
                /* if option is rom valid, display its version too */
                if (fw.or_valid) {
@@ -1944,11 +1951,16 @@ void igb_set_fw_version(struct igb_adapter *adapter)
                                 fw.eep_major, fw.eep_minor, fw.etrack_id,
                                 fw.or_major, fw.or_build, fw.or_patch);
                /* no option rom */
-               } else {
+               } else if (fw.etrack_id != 0X0000) {
                        snprintf(adapter->fw_version,
-                                sizeof(adapter->fw_version),
-                                "%d.%d, 0x%08x",
-                                fw.eep_major, fw.eep_minor, fw.etrack_id);
+                           sizeof(adapter->fw_version),
+                           "%d.%d, 0x%08x",
+                           fw.eep_major, fw.eep_minor, fw.etrack_id);
+               } else {
+               snprintf(adapter->fw_version,
+                   sizeof(adapter->fw_version),
+                   "%d.%d.%d",
+                   fw.eep_major, fw.eep_minor, fw.eep_build);
                }
                break;
        }
@@ -2166,15 +2178,28 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
         */
        hw->mac.ops.reset_hw(hw);
 
-       /* make sure the NVM is good , i211 parts have special NVM that
-        * doesn't contain a checksum
+       /* make sure the NVM is good , i211/i210 parts can have special NVM
+        * that doesn't contain a checksum
         */
-       if (hw->mac.type != e1000_i211) {
+       switch (hw->mac.type) {
+       case e1000_i210:
+       case e1000_i211:
+               if (igb_get_flash_presence_i210(hw)) {
+                       if (hw->nvm.ops.validate(hw) < 0) {
+                               dev_err(&pdev->dev,
+                                       "The NVM Checksum Is Not Valid\n");
+                               err = -EIO;
+                               goto err_eeprom;
+                       }
+               }
+               break;
+       default:
                if (hw->nvm.ops.validate(hw) < 0) {
                        dev_err(&pdev->dev, "The NVM Checksum Is Not Valid\n");
                        err = -EIO;
                        goto err_eeprom;
                }
+               break;
        }
 
        /* copy the MAC address out of the NVM */
@@ -2436,6 +2461,11 @@ static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs)
        int err = 0;
        int i;
 
+       if (!adapter->msix_entries) {
+               err = -EPERM;
+               goto out;
+       }
+
        if (!num_vfs)
                goto out;
        else if (old_vfs && old_vfs == num_vfs)
@@ -3096,7 +3126,7 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 mrqc, rxcsum;
-       u32 j, num_rx_queues, shift = 0;
+       u32 j, num_rx_queues;
        static const u32 rsskey[10] = { 0xDA565A6D, 0xC20E5B25, 0x3D256741,
                                        0xB08FA343, 0xCB2BCAD0, 0xB4307BAE,
                                        0xA32DCB77, 0x0CF23080, 0x3BB7426A,
@@ -3109,35 +3139,21 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)
        num_rx_queues = adapter->rss_queues;
 
        switch (hw->mac.type) {
-       case e1000_82575:
-               shift = 6;
-               break;
        case e1000_82576:
                /* 82576 supports 2 RSS queues for SR-IOV */
-               if (adapter->vfs_allocated_count) {
-                       shift = 3;
+               if (adapter->vfs_allocated_count)
                        num_rx_queues = 2;
-               }
                break;
        default:
                break;
        }
 
-       /* Populate the indirection table 4 entries at a time.  To do this
-        * we are generating the results for n and n+2 and then interleaving
-        * those with the results with n+1 and n+3.
-        */
-       for (j = 0; j < 32; j++) {
-               /* first pass generates n and n+2 */
-               u32 base = ((j * 0x00040004) + 0x00020000) * num_rx_queues;
-               u32 reta = (base & 0x07800780) >> (7 - shift);
-
-               /* second pass generates n+1 and n+3 */
-               base += 0x00010001 * num_rx_queues;
-               reta |= (base & 0x07800780) << (1 + shift);
-
-               wr32(E1000_RETA(j), reta);
+       if (adapter->rss_indir_tbl_init != num_rx_queues) {
+               for (j = 0; j < IGB_RETA_SIZE; j++)
+                       adapter->rss_indir_tbl[j] = (j * num_rx_queues) / IGB_RETA_SIZE;
+               adapter->rss_indir_tbl_init = num_rx_queues;
        }
+       igb_write_rss_indir_tbl(adapter);
 
        /* Disable raw packet checksumming so that RSS hash is placed in
         * descriptor on writeback.  No need to enable TCP/UDP/IP checksum
@@ -3739,9 +3755,8 @@ static void igb_set_rx_mode(struct net_device *netdev)
        rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_VFE);
 
        if (netdev->flags & IFF_PROMISC) {
-               u32 mrqc = rd32(E1000_MRQC);
                /* retain VLAN HW filtering if in VT mode */
-               if (mrqc & E1000_MRQC_ENABLE_VMDQ)
+               if (adapter->vfs_allocated_count)
                        rctl |= E1000_RCTL_VFE;
                rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
                vmolr |= (E1000_VMOLR_ROPE | E1000_VMOLR_MPME);
@@ -3845,7 +3860,6 @@ bool igb_has_link(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        bool link_active = false;
-       s32 ret_val = 0;
 
        /* get_link_status is set on LSC (link status) interrupt or
         * rx sequence error interrupt.  get_link_status will stay
@@ -3854,16 +3868,11 @@ bool igb_has_link(struct igb_adapter *adapter)
         */
        switch (hw->phy.media_type) {
        case e1000_media_type_copper:
-               if (hw->mac.get_link_status) {
-                       ret_val = hw->mac.ops.check_for_link(hw);
-                       link_active = !hw->mac.get_link_status;
-               } else {
-                       link_active = true;
-               }
-               break;
+               if (!hw->mac.get_link_status)
+                       return true;
        case e1000_media_type_internal_serdes:
-               ret_val = hw->mac.ops.check_for_link(hw);
-               link_active = hw->mac.serdes_has_link;
+               hw->mac.ops.check_for_link(hw);
+               link_active = !hw->mac.get_link_status;
                break;
        default:
        case e1000_media_type_unknown:
@@ -4815,6 +4824,10 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
                return -EINVAL;
        }
 
+       /* adjust max frame to be at least the size of a standard frame */
+       if (max_frame < (ETH_FRAME_LEN + ETH_FCS_LEN))
+               max_frame = ETH_FRAME_LEN + ETH_FCS_LEN;
+
        while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
                msleep(1);
 
@@ -4866,6 +4879,8 @@ void igb_update_stats(struct igb_adapter *adapter,
 
        bytes = 0;
        packets = 0;
+
+       rcu_read_lock();
        for (i = 0; i < adapter->num_rx_queues; i++) {
                u32 rqdpc = rd32(E1000_RQDPC(i));
                struct igb_ring *ring = adapter->rx_ring[i];
@@ -4901,6 +4916,7 @@ void igb_update_stats(struct igb_adapter *adapter,
        }
        net_stats->tx_bytes = bytes;
        net_stats->tx_packets = packets;
+       rcu_read_unlock();
 
        /* read stats registers */
        adapter->stats.crcerrs += rd32(E1000_CRCERRS);
index 7e8c477b0ab9fb6e2758a763411dbde42ae57769..5a54e3dc535de95e9525ccf4bc24ae6f8dcdbcaf 100644 (file)
@@ -97,14 +97,14 @@ static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc)
 {
        struct igb_adapter *igb = container_of(cc, struct igb_adapter, cc);
        struct e1000_hw *hw = &igb->hw;
+       u32 lo, hi;
        u64 val;
-       u32 lo, hi, jk;
 
        /* The timestamp latches on lowest register read. For the 82580
         * the lowest register is SYSTIMR instead of SYSTIML.  However we only
         * need to provide nanosecond resolution, so we just ignore it.
         */
-       jk = rd32(E1000_SYSTIMR);
+       rd32(E1000_SYSTIMR);
        lo = rd32(E1000_SYSTIML);
        hi = rd32(E1000_SYSTIMH);
 
@@ -118,13 +118,13 @@ static cycle_t igb_ptp_read_82580(const struct cyclecounter *cc)
 static void igb_ptp_read_i210(struct igb_adapter *adapter, struct timespec *ts)
 {
        struct e1000_hw *hw = &adapter->hw;
-       u32 sec, nsec, jk;
+       u32 sec, nsec;
 
        /* The timestamp latches on lowest register read. For I210/I211, the
         * lowest register is SYSTIMR. Since we only need to provide nanosecond
         * resolution, we can ignore it.
         */
-       jk = rd32(E1000_SYSTIMR);
+       rd32(E1000_SYSTIMR);
        nsec = rd32(E1000_SYSTIML);
        sec = rd32(E1000_SYSTIMH);
 
index 7be725cdfea8d3b3c7f414a500dd83b965f24d99..0ac6b11c6e4ec323aaa50db976e2a996b1b02d19 100644 (file)
@@ -54,7 +54,7 @@
 
 #include <net/busy_poll.h>
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 #define LL_EXTENDED_STATS
 #endif
 /* common prefix used by pr_<> macros */
@@ -366,7 +366,7 @@ struct ixgbe_q_vector {
        struct rcu_head rcu;    /* to avoid race with update stats on free */
        char name[IFNAMSIZ + 9];
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        unsigned int state;
 #define IXGBE_QV_STATE_IDLE        0
 #define IXGBE_QV_STATE_NAPI       1    /* NAPI owns this QV */
@@ -377,12 +377,12 @@ struct ixgbe_q_vector {
 #define IXGBE_QV_YIELD (IXGBE_QV_STATE_NAPI_YIELD | IXGBE_QV_STATE_POLL_YIELD)
 #define IXGBE_QV_USER_PEND (IXGBE_QV_STATE_POLL | IXGBE_QV_STATE_POLL_YIELD)
        spinlock_t lock;
-#endif  /* CONFIG_NET_LL_RX_POLL */
+#endif  /* CONFIG_NET_RX_BUSY_POLL */
 
        /* for dynamic allocation of rings associated with this q_vector */
        struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp;
 };
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 static inline void ixgbe_qv_init_lock(struct ixgbe_q_vector *q_vector)
 {
 
@@ -462,7 +462,7 @@ static inline bool ixgbe_qv_ll_polling(struct ixgbe_q_vector *q_vector)
        WARN_ON(!(q_vector->state & IXGBE_QV_LOCKED));
        return q_vector->state & IXGBE_QV_USER_PEND;
 }
-#else /* CONFIG_NET_LL_RX_POLL */
+#else /* CONFIG_NET_RX_BUSY_POLL */
 static inline void ixgbe_qv_init_lock(struct ixgbe_q_vector *q_vector)
 {
 }
@@ -491,7 +491,7 @@ static inline bool ixgbe_qv_ll_polling(struct ixgbe_q_vector *q_vector)
 {
        return false;
 }
-#endif /* CONFIG_NET_LL_RX_POLL */
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 
 #ifdef CONFIG_IXGBE_HWMON
 
@@ -618,9 +618,8 @@ struct ixgbe_adapter {
 #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT        (u32)(1 << 7)
 #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP         (u32)(1 << 8)
 #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP         (u32)(1 << 9)
-#define IXGBE_FLAG2_PTP_ENABLED                        (u32)(1 << 10)
-#define IXGBE_FLAG2_PTP_PPS_ENABLED            (u32)(1 << 11)
-#define IXGBE_FLAG2_BRIDGE_MODE_VEB            (u32)(1 << 12)
+#define IXGBE_FLAG2_PTP_PPS_ENABLED            (u32)(1 << 10)
+#define IXGBE_FLAG2_BRIDGE_MODE_VEB            (u32)(1 << 11)
 
        /* Tx fast path data */
        int num_tx_queues;
@@ -754,7 +753,7 @@ enum ixgbe_state_t {
        __IXGBE_DOWN,
        __IXGBE_SERVICE_SCHED,
        __IXGBE_IN_SFP_INIT,
-       __IXGBE_READ_I2C,
+       __IXGBE_PTP_RUNNING,
 };
 
 struct ixgbe_cb {
index 4a5bfb6b3af05b09e5d5895e0a2b82bf04e10d0b..a26f3fee4f359be56b4346b9a5d871efedc8ca1d 100644 (file)
@@ -1018,8 +1018,17 @@ static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
        u16 sfp_addr = 0;
        u16 sfp_data = 0;
        u16 sfp_stat = 0;
+       u16 gssr;
        u32 i;
 
+       if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
+               gssr = IXGBE_GSSR_PHY1_SM;
+       else
+               gssr = IXGBE_GSSR_PHY0_SM;
+
+       if (hw->mac.ops.acquire_swfw_sync(hw, gssr) != 0)
+               return IXGBE_ERR_SWFW_SYNC;
+
        if (hw->phy.type == ixgbe_phy_nl) {
                /*
                 * phy SDA/SCL registers are at addresses 0xC30A to
@@ -1028,17 +1037,17 @@ static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
                 */
                sfp_addr = (dev_addr << 8) + byte_offset;
                sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
-               hw->phy.ops.write_reg(hw,
-                                     IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
-                                     MDIO_MMD_PMAPMD,
-                                     sfp_addr);
+               hw->phy.ops.write_reg_mdi(hw,
+                                         IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
+                                         MDIO_MMD_PMAPMD,
+                                         sfp_addr);
 
                /* Poll status */
                for (i = 0; i < 100; i++) {
-                       hw->phy.ops.read_reg(hw,
-                                            IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
-                                            MDIO_MMD_PMAPMD,
-                                            &sfp_stat);
+                       hw->phy.ops.read_reg_mdi(hw,
+                                               IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
+                                               MDIO_MMD_PMAPMD,
+                                               &sfp_stat);
                        sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
                        if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
                                break;
@@ -1052,8 +1061,8 @@ static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
                }
 
                /* Read data */
-               hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
-                                    MDIO_MMD_PMAPMD, &sfp_data);
+               hw->phy.ops.read_reg_mdi(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
+                                       MDIO_MMD_PMAPMD, &sfp_data);
 
                *eeprom_data = (u8)(sfp_data >> 8);
        } else {
@@ -1061,6 +1070,7 @@ static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr,
        }
 
 out:
+       hw->mac.ops.release_swfw_sync(hw, gssr);
        return status;
 }
 
@@ -1321,11 +1331,13 @@ static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
 
 static struct ixgbe_phy_operations phy_ops_82598 = {
        .identify               = &ixgbe_identify_phy_generic,
-       .identify_sfp           = &ixgbe_identify_sfp_module_generic,
+       .identify_sfp           = &ixgbe_identify_module_generic,
        .init                   = &ixgbe_init_phy_ops_82598,
        .reset                  = &ixgbe_reset_phy_generic,
        .read_reg               = &ixgbe_read_phy_reg_generic,
        .write_reg              = &ixgbe_write_phy_reg_generic,
+       .read_reg_mdi           = &ixgbe_read_phy_reg_mdi,
+       .write_reg_mdi          = &ixgbe_write_phy_reg_mdi,
        .setup_link             = &ixgbe_setup_phy_link_generic,
        .setup_link_speed       = &ixgbe_setup_phy_link_speed_generic,
        .read_i2c_sff8472       = &ixgbe_read_i2c_sff8472_82598,
index 0b82d38bc97daf6e67c6cd7a0d65caafa70ccd11..207f68fbe3d3c3c01d9b842f06c377a891962a14 100644 (file)
@@ -58,6 +58,10 @@ static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,
                                          ixgbe_link_speed speed,
                                          bool autoneg_wait_to_complete);
 static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw);
+static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
+                                    u8 dev_addr, u8 *data);
+static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
+                                     u8 dev_addr, u8 data);
 
 static bool ixgbe_mng_enabled(struct ixgbe_hw *hw)
 {
@@ -219,6 +223,25 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)
        struct ixgbe_mac_info *mac = &hw->mac;
        struct ixgbe_phy_info *phy = &hw->phy;
        s32 ret_val = 0;
+       u32 esdp;
+
+       if (hw->device_id == IXGBE_DEV_ID_82599_QSFP_SF_QP) {
+               /* Store flag indicating I2C bus access control unit. */
+               hw->phy.qsfp_shared_i2c_bus = true;
+
+               /* Initialize access to QSFP+ I2C bus */
+               esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+               esdp |= IXGBE_ESDP_SDP0_DIR;
+               esdp &= ~IXGBE_ESDP_SDP1_DIR;
+               esdp &= ~IXGBE_ESDP_SDP0;
+               esdp &= ~IXGBE_ESDP_SDP0_NATIVE;
+               esdp &= ~IXGBE_ESDP_SDP1_NATIVE;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+               IXGBE_WRITE_FLUSH(hw);
+
+               phy->ops.read_i2c_byte = &ixgbe_read_i2c_byte_82599;
+               phy->ops.write_i2c_byte = &ixgbe_write_i2c_byte_82599;
+       }
 
        /* Identify the PHY or SFP module */
        ret_val = phy->ops.identify(hw);
@@ -397,6 +420,9 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
        case IXGBE_DEV_ID_82599_LS:
                media_type = ixgbe_media_type_fiber_lco;
                break;
+       case IXGBE_DEV_ID_82599_QSFP_SF_QP:
+               media_type = ixgbe_media_type_fiber_qsfp;
+               break;
        default:
                media_type = ixgbe_media_type_unknown;
                break;
@@ -526,6 +552,75 @@ static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
        }
 }
 
+/**
+ *  ixgbe_set_fiber_fixed_speed - Set module link speed for fixed fiber
+ *  @hw: pointer to hardware structure
+ *  @speed: link speed to set
+ *
+ *  We set the module speed differently for fixed fiber.  For other
+ *  multi-speed devices we don't have an error value so here if we
+ *  detect an error we just log it and exit.
+ */
+static void ixgbe_set_fiber_fixed_speed(struct ixgbe_hw *hw,
+                                       ixgbe_link_speed speed)
+{
+       s32 status;
+       u8 rs, eeprom_data;
+
+       switch (speed) {
+       case IXGBE_LINK_SPEED_10GB_FULL:
+               /* one bit mask same as setting on */
+               rs = IXGBE_SFF_SOFT_RS_SELECT_10G;
+               break;
+       case IXGBE_LINK_SPEED_1GB_FULL:
+               rs = IXGBE_SFF_SOFT_RS_SELECT_1G;
+               break;
+       default:
+               hw_dbg(hw, "Invalid fixed module speed\n");
+               return;
+       }
+
+       /* Set RS0 */
+       status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
+                                          IXGBE_I2C_EEPROM_DEV_ADDR2,
+                                          &eeprom_data);
+       if (status) {
+               hw_dbg(hw, "Failed to read Rx Rate Select RS0\n");
+               goto out;
+       }
+
+       eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
+
+       status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_OSCB,
+                                           IXGBE_I2C_EEPROM_DEV_ADDR2,
+                                           eeprom_data);
+       if (status) {
+               hw_dbg(hw, "Failed to write Rx Rate Select RS0\n");
+               goto out;
+       }
+
+       /* Set RS1 */
+       status = hw->phy.ops.read_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
+                                          IXGBE_I2C_EEPROM_DEV_ADDR2,
+                                          &eeprom_data);
+       if (status) {
+               hw_dbg(hw, "Failed to read Rx Rate Select RS1\n");
+               goto out;
+       }
+
+       eeprom_data = (eeprom_data & ~IXGBE_SFF_SOFT_RS_SELECT_MASK) & rs;
+
+       status = hw->phy.ops.write_i2c_byte(hw, IXGBE_SFF_SFF_8472_ESCB,
+                                           IXGBE_I2C_EEPROM_DEV_ADDR2,
+                                           eeprom_data);
+       if (status) {
+               hw_dbg(hw, "Failed to write Rx Rate Select RS1\n");
+               goto out;
+       }
+out:
+       return;
+}
+
 /**
  *  ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
  *  @hw: pointer to hardware structure
@@ -573,9 +668,14 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                        goto out;
 
                /* Set the module link speed */
-               esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
-               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
-               IXGBE_WRITE_FLUSH(hw);
+               if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
+                       ixgbe_set_fiber_fixed_speed(hw,
+                                       IXGBE_LINK_SPEED_10GB_FULL);
+               } else {
+                       esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
+                       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
+                       IXGBE_WRITE_FLUSH(hw);
+               }
 
                /* Allow module to change analog characteristics (1G->10G) */
                msleep(40);
@@ -625,10 +725,15 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
                        goto out;
 
                /* Set the module link speed */
-               esdp_reg &= ~IXGBE_ESDP_SDP5;
-               esdp_reg |= IXGBE_ESDP_SDP5_DIR;
-               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
-               IXGBE_WRITE_FLUSH(hw);
+               if (hw->phy.media_type == ixgbe_media_type_fiber_fixed) {
+                       ixgbe_set_fiber_fixed_speed(hw,
+                                               IXGBE_LINK_SPEED_1GB_FULL);
+               } else {
+                       esdp_reg &= ~IXGBE_ESDP_SDP5;
+                       esdp_reg |= IXGBE_ESDP_SDP5_DIR;
+                       IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
+                       IXGBE_WRITE_FLUSH(hw);
+               }
 
                /* Allow module to change analog characteristics (10G->1G) */
                msleep(40);
@@ -1872,7 +1977,7 @@ static s32 ixgbe_identify_phy_82599(struct ixgbe_hw *hw)
                if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)
                        goto out;
                else
-                       status = ixgbe_identify_sfp_module_generic(hw);
+                       status = ixgbe_identify_module_generic(hw);
        }
 
        /* Set PHY type none if no PHY detected */
@@ -1978,10 +2083,12 @@ sfp_check:
        switch (hw->phy.type) {
        case ixgbe_phy_sfp_passive_tyco:
        case ixgbe_phy_sfp_passive_unknown:
+       case ixgbe_phy_qsfp_passive_unknown:
                physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
                break;
        case ixgbe_phy_sfp_ftl_active:
        case ixgbe_phy_sfp_active_unknown:
+       case ixgbe_phy_qsfp_active_unknown:
                physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
                break;
        case ixgbe_phy_sfp_avago:
@@ -1999,6 +2106,15 @@ sfp_check:
                else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
                        physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
                break;
+       case ixgbe_phy_qsfp_intel:
+       case ixgbe_phy_qsfp_unknown:
+               hw->phy.ops.read_i2c_eeprom(hw,
+                       IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
+               if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
+                       physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
+               else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
+                       physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
+               break;
        default:
                break;
        }
@@ -2236,6 +2352,112 @@ reset_pipeline_out:
        return ret_val;
 }
 
+/**
+ *  ixgbe_read_i2c_byte_82599 - Reads 8 bit word over I2C
+ *  @hw: pointer to hardware structure
+ *  @byte_offset: byte offset to read
+ *  @data: value read
+ *
+ *  Performs byte read operation to SFP module's EEPROM over I2C interface at
+ *  a specified device address.
+ **/
+static s32 ixgbe_read_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
+                                    u8 dev_addr, u8 *data)
+{
+       u32 esdp;
+       s32 status;
+       s32 timeout = 200;
+
+       if (hw->phy.qsfp_shared_i2c_bus == true) {
+               /* Acquire I2C bus ownership. */
+               esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+               esdp |= IXGBE_ESDP_SDP0;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+               IXGBE_WRITE_FLUSH(hw);
+
+               while (timeout) {
+                       esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+                       if (esdp & IXGBE_ESDP_SDP1)
+                               break;
+
+                       usleep_range(5000, 10000);
+                       timeout--;
+               }
+
+               if (!timeout) {
+                       hw_dbg(hw, "Driver can't access resource, acquiring I2C bus timeout.\n");
+                       status = IXGBE_ERR_I2C;
+                       goto release_i2c_access;
+               }
+       }
+
+       status = ixgbe_read_i2c_byte_generic(hw, byte_offset, dev_addr, data);
+
+release_i2c_access:
+       if (hw->phy.qsfp_shared_i2c_bus == true) {
+               /* Release I2C bus ownership. */
+               esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+               esdp &= ~IXGBE_ESDP_SDP0;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+               IXGBE_WRITE_FLUSH(hw);
+       }
+
+       return status;
+}
+
+/**
+ *  ixgbe_write_i2c_byte_82599 - Writes 8 bit word over I2C
+ *  @hw: pointer to hardware structure
+ *  @byte_offset: byte offset to write
+ *  @data: value to write
+ *
+ *  Performs byte write operation to SFP module's EEPROM over I2C interface at
+ *  a specified device address.
+ **/
+static s32 ixgbe_write_i2c_byte_82599(struct ixgbe_hw *hw, u8 byte_offset,
+                                     u8 dev_addr, u8 data)
+{
+       u32 esdp;
+       s32 status;
+       s32 timeout = 200;
+
+       if (hw->phy.qsfp_shared_i2c_bus == true) {
+               /* Acquire I2C bus ownership. */
+               esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+               esdp |= IXGBE_ESDP_SDP0;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+               IXGBE_WRITE_FLUSH(hw);
+
+               while (timeout) {
+                       esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+                       if (esdp & IXGBE_ESDP_SDP1)
+                               break;
+
+                       usleep_range(5000, 10000);
+                       timeout--;
+               }
+
+               if (!timeout) {
+                       hw_dbg(hw, "Driver can't access resource, acquiring I2C bus timeout.\n");
+                       status = IXGBE_ERR_I2C;
+                       goto release_i2c_access;
+               }
+       }
+
+       status = ixgbe_write_i2c_byte_generic(hw, byte_offset, dev_addr, data);
+
+release_i2c_access:
+       if (hw->phy.qsfp_shared_i2c_bus == true) {
+               /* Release I2C bus ownership. */
+               esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+               esdp &= ~IXGBE_ESDP_SDP0;
+               IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+               IXGBE_WRITE_FLUSH(hw);
+       }
+
+       return status;
+}
+
 static struct ixgbe_mac_operations mac_ops_82599 = {
        .init_hw                = &ixgbe_init_hw_generic,
        .reset_hw               = &ixgbe_reset_hw_82599,
@@ -2300,7 +2522,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_82599 = {
 
 static struct ixgbe_phy_operations phy_ops_82599 = {
        .identify               = &ixgbe_identify_phy_82599,
-       .identify_sfp           = &ixgbe_identify_sfp_module_generic,
+       .identify_sfp           = &ixgbe_identify_module_generic,
        .init                   = &ixgbe_init_phy_ops_82599,
        .reset                  = &ixgbe_reset_phy_generic,
        .read_reg               = &ixgbe_read_phy_reg_generic,
index 9bcdeb89af5a0a532689cb7b91b2b3b64fca380a..50e62a2b1a65f905709c9ffffdff66fa8273a296 100644 (file)
@@ -65,17 +65,42 @@ static s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw);
  *  function check the device id to see if the associated phy supports
  *  autoneg flow control.
  **/
-s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
+bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
 {
+       bool supported = false;
+       ixgbe_link_speed speed;
+       bool link_up;
 
-       switch (hw->device_id) {
-       case IXGBE_DEV_ID_X540T:
-       case IXGBE_DEV_ID_X540T1:
-       case IXGBE_DEV_ID_82599_T3_LOM:
-               return 0;
+       switch (hw->phy.media_type) {
+       case ixgbe_media_type_fiber_fixed:
+       case ixgbe_media_type_fiber:
+               hw->mac.ops.check_link(hw, &speed, &link_up, false);
+               /* if link is down, assume supported */
+               if (link_up)
+                       supported = speed == IXGBE_LINK_SPEED_1GB_FULL ?
+                               true : false;
+               else
+                       supported = true;
+               break;
+       case ixgbe_media_type_backplane:
+               supported = true;
+               break;
+       case ixgbe_media_type_copper:
+               /* only some copper devices support flow control autoneg */
+               switch (hw->device_id) {
+               case IXGBE_DEV_ID_82599_T3_LOM:
+               case IXGBE_DEV_ID_X540T:
+               case IXGBE_DEV_ID_X540T1:
+                       supported = true;
+                       break;
+               default:
+                       break;
+               }
        default:
-               return IXGBE_ERR_FC_NOT_SUPPORTED;
+               break;
        }
+
+       return supported;
 }
 
 /**
@@ -114,6 +139,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
         * we link at 10G, the 1G advertisement is harmless and vice versa.
         */
        switch (hw->phy.media_type) {
+       case ixgbe_media_type_fiber_fixed:
        case ixgbe_media_type_fiber:
        case ixgbe_media_type_backplane:
                reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
@@ -234,7 +260,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw)
                                                      IXGBE_GSSR_MAC_CSR_SM);
 
        } else if ((hw->phy.media_type == ixgbe_media_type_copper) &&
-                   (ixgbe_device_supports_autoneg_fc(hw) == 0)) {
+                   ixgbe_device_supports_autoneg_fc(hw)) {
                hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
                                      MDIO_MMD_AN, reg_cu);
        }
@@ -2380,6 +2406,7 @@ void ixgbe_fc_autoneg(struct ixgbe_hw *hw)
 
        switch (hw->phy.media_type) {
        /* Autoneg flow control on fiber adapters */
+       case ixgbe_media_type_fiber_fixed:
        case ixgbe_media_type_fiber:
                if (speed == IXGBE_LINK_SPEED_1GB_FULL)
                        ret_val = ixgbe_fc_autoneg_fiber(hw);
@@ -2392,7 +2419,7 @@ void ixgbe_fc_autoneg(struct ixgbe_hw *hw)
 
        /* Autoneg flow control on copper adapters */
        case ixgbe_media_type_copper:
-               if (ixgbe_device_supports_autoneg_fc(hw) == 0)
+               if (ixgbe_device_supports_autoneg_fc(hw))
                        ret_val = ixgbe_fc_autoneg_copper(hw);
                break;
 
@@ -2479,42 +2506,39 @@ out:
  **/
 s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask)
 {
-       u32 gssr;
+       u32 gssr = 0;
        u32 swmask = mask;
        u32 fwmask = mask << 5;
-       s32 timeout = 200;
+       u32 timeout = 200;
+       u32 i;
 
-       while (timeout) {
+       for (i = 0; i < timeout; i++) {
                /*
-                * SW EEPROM semaphore bit is used for access to all
-                * SW_FW_SYNC/GSSR bits (not just EEPROM)
+                * SW NVM semaphore bit is used for access to all
+                * SW_FW_SYNC bits (not just NVM)
                 */
                if (ixgbe_get_eeprom_semaphore(hw))
                        return IXGBE_ERR_SWFW_SYNC;
 
                gssr = IXGBE_READ_REG(hw, IXGBE_GSSR);
-               if (!(gssr & (fwmask | swmask)))
-                       break;
-
-               /*
-                * Firmware currently using resource (fwmask) or other software
-                * thread currently using resource (swmask)
-                */
-               ixgbe_release_eeprom_semaphore(hw);
-               usleep_range(5000, 10000);
-               timeout--;
-       }
-
-       if (!timeout) {
-               hw_dbg(hw, "Driver can't access resource, SW_FW_SYNC timeout.\n");
-               return IXGBE_ERR_SWFW_SYNC;
+               if (!(gssr & (fwmask | swmask))) {
+                       gssr |= swmask;
+                       IXGBE_WRITE_REG(hw, IXGBE_GSSR, gssr);
+                       ixgbe_release_eeprom_semaphore(hw);
+                       return 0;
+               } else {
+                       /* Resource is currently in use by FW or SW */
+                       ixgbe_release_eeprom_semaphore(hw);
+                       usleep_range(5000, 10000);
+               }
        }
 
-       gssr |= swmask;
-       IXGBE_WRITE_REG(hw, IXGBE_GSSR, gssr);
+       /* If time expired clear the bits holding the lock and retry */
+       if (gssr & (fwmask | swmask))
+               ixgbe_release_swfw_sync(hw, gssr & (fwmask | swmask));
 
-       ixgbe_release_eeprom_semaphore(hw);
-       return 0;
+       usleep_range(5000, 10000);
+       return IXGBE_ERR_SWFW_SYNC;
 }
 
 /**
index 22eee38868f1aa2801137e3b26eb2131efe9ec56..1315b8ac7f586f9ef05b346aa070e847ac481f2a 100644 (file)
@@ -80,7 +80,7 @@ s32 ixgbe_disable_rx_buff_generic(struct ixgbe_hw *hw);
 s32 ixgbe_enable_rx_buff_generic(struct ixgbe_hw *hw);
 s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval);
 s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw);
-s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw);
+bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw);
 void ixgbe_fc_autoneg(struct ixgbe_hw *hw);
 
 s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask);
index ac780770863dfb3a338f3dfe4550f5bd87d2e66e..7a77f37a7cbcbd6b7b5b87dd78e9e50b677e778c 100644 (file)
@@ -108,9 +108,8 @@ s32 ixgbe_dcb_config_tx_desc_arbiter_82598(struct ixgbe_hw *hw,
 
        /* Enable arbiter */
        reg &= ~IXGBE_DPMCS_ARBDIS;
-       /* Enable DFP and Recycle mode */
-       reg |= (IXGBE_DPMCS_TDPAC | IXGBE_DPMCS_TRM);
        reg |= IXGBE_DPMCS_TSOEF;
+
        /* Configure Max TSO packet size 34KB including payload and headers */
        reg |= (0x4 << IXGBE_DPMCS_MTSOS_SHIFT);
 
index 24e2e7aafda2d42201541ef9ee855ee26e1661cb..50c1e9b2fd806584b69e650d9bf551093f7445d8 100644 (file)
@@ -355,10 +355,11 @@ static void ixgbe_get_pauseparam(struct net_device *netdev,
        struct ixgbe_adapter *adapter = netdev_priv(netdev);
        struct ixgbe_hw *hw = &adapter->hw;
 
-       if (hw->fc.disable_fc_autoneg)
-               pause->autoneg = 0;
-       else
+       if (ixgbe_device_supports_autoneg_fc(hw) &&
+           !hw->fc.disable_fc_autoneg)
                pause->autoneg = 1;
+       else
+               pause->autoneg = 0;
 
        if (hw->fc.current_mode == ixgbe_fc_rx_pause) {
                pause->rx_pause = 1;
@@ -384,7 +385,7 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
 
        /* some devices do not support autoneg of link flow control */
        if ((pause->autoneg == AUTONEG_ENABLE) &&
-           (ixgbe_device_supports_autoneg_fc(hw) != 0))
+           !ixgbe_device_supports_autoneg_fc(hw))
                return -EINVAL;
 
        fc.disable_fc_autoneg = (pause->autoneg != AUTONEG_ENABLE);
@@ -1140,11 +1141,11 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
                        sprintf(p, "tx_queue_%u_bytes", i);
                        p += ETH_GSTRING_LEN;
 #ifdef LL_EXTENDED_STATS
-                       sprintf(p, "tx_q_%u_napi_yield", i);
+                       sprintf(p, "tx_queue_%u_ll_napi_yield", i);
                        p += ETH_GSTRING_LEN;
-                       sprintf(p, "tx_q_%u_misses", i);
+                       sprintf(p, "tx_queue_%u_ll_misses", i);
                        p += ETH_GSTRING_LEN;
-                       sprintf(p, "tx_q_%u_cleaned", i);
+                       sprintf(p, "tx_queue_%u_ll_cleaned", i);
                        p += ETH_GSTRING_LEN;
 #endif /* LL_EXTENDED_STATS */
                }
@@ -1154,11 +1155,11 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
                        sprintf(p, "rx_queue_%u_bytes", i);
                        p += ETH_GSTRING_LEN;
 #ifdef LL_EXTENDED_STATS
-                       sprintf(p, "rx_q_%u_ll_poll_yield", i);
+                       sprintf(p, "rx_queue_%u_ll_poll_yield", i);
                        p += ETH_GSTRING_LEN;
-                       sprintf(p, "rx_q_%u_misses", i);
+                       sprintf(p, "rx_queue_%u_ll_misses", i);
                        p += ETH_GSTRING_LEN;
-                       sprintf(p, "rx_q_%u_cleaned", i);
+                       sprintf(p, "rx_queue_%u_ll_cleaned", i);
                        p += ETH_GSTRING_LEN;
 #endif /* LL_EXTENDED_STATS */
                }
@@ -2909,33 +2910,21 @@ static int ixgbe_get_module_info(struct net_device *dev,
        struct ixgbe_hw *hw = &adapter->hw;
        u32 status;
        u8 sff8472_rev, addr_mode;
-       int ret_val = 0;
        bool page_swap = false;
 
-       /* avoid concurent i2c reads */
-       while (test_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
-               msleep(100);
-
-       /* used by the service task */
-       set_bit(__IXGBE_READ_I2C, &adapter->state);
-
        /* Check whether we support SFF-8472 or not */
        status = hw->phy.ops.read_i2c_eeprom(hw,
                                             IXGBE_SFF_SFF_8472_COMP,
                                             &sff8472_rev);
-       if (status != 0) {
-               ret_val = -EIO;
-               goto err_out;
-       }
+       if (status != 0)
+               return -EIO;
 
        /* addressing mode is not supported */
        status = hw->phy.ops.read_i2c_eeprom(hw,
                                             IXGBE_SFF_SFF_8472_SWAP,
                                             &addr_mode);
-       if (status != 0) {
-               ret_val = -EIO;
-               goto err_out;
-       }
+       if (status != 0)
+               return -EIO;
 
        if (addr_mode & IXGBE_SFF_ADDRESSING_MODE) {
                e_err(drv, "Address change required to access page 0xA2, but not supported. Please report the module type to the driver maintainers.\n");
@@ -2952,9 +2941,7 @@ static int ixgbe_get_module_info(struct net_device *dev,
                modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
        }
 
-err_out:
-       clear_bit(__IXGBE_READ_I2C, &adapter->state);
-       return ret_val;
+       return 0;
 }
 
 static int ixgbe_get_module_eeprom(struct net_device *dev,
@@ -2968,48 +2955,25 @@ static int ixgbe_get_module_eeprom(struct net_device *dev,
        int i = 0;
        int ret_val = 0;
 
-       /* ixgbe_get_module_info is called before this function in all
-        * cases, so we do not need any checks we already do above,
-        * and can trust ee->len to be a known value.
-        */
+       if (ee->len == 0)
+               return -EINVAL;
+
+       for (i = ee->offset; i < ee->len; i++) {
+               /* I2C reads can take long time */
+               if (test_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
+                       return -EBUSY;
 
-       while (test_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
-               msleep(100);
-       set_bit(__IXGBE_READ_I2C, &adapter->state);
+               if (i < ETH_MODULE_SFF_8079_LEN)
+                       status  = hw->phy.ops.read_i2c_eeprom(hw, i, &databyte);
+               else
+                       status = hw->phy.ops.read_i2c_sff8472(hw, i, &databyte);
 
-       /* Read the first block, SFF-8079 */
-       for (i = 0; i < ETH_MODULE_SFF_8079_LEN; i++) {
-               status = hw->phy.ops.read_i2c_eeprom(hw, i, &databyte);
-               if (status != 0) {
-                       /* Error occured while reading module */
+               if (status != 0)
                        ret_val = -EIO;
-                       goto err_out;
-               }
-               data[i] = databyte;
-       }
 
-       /* If the second block is requested, check if SFF-8472 is supported. */
-       if (ee->len == ETH_MODULE_SFF_8472_LEN) {
-               if (data[IXGBE_SFF_SFF_8472_COMP] == IXGBE_SFF_SFF_8472_UNSUP)
-                       return -EOPNOTSUPP;
-
-               /* Read the second block, SFF-8472 */
-               for (i = ETH_MODULE_SFF_8079_LEN;
-                    i < ETH_MODULE_SFF_8472_LEN; i++) {
-                       status = hw->phy.ops.read_i2c_sff8472(hw,
-                               i - ETH_MODULE_SFF_8079_LEN, &databyte);
-                       if (status != 0) {
-                               /* Error occured while reading module */
-                               ret_val = -EIO;
-                               goto err_out;
-                       }
-                       data[i] = databyte;
-               }
+               data[i - ee->offset] = databyte;
        }
 
-err_out:
-       clear_bit(__IXGBE_READ_I2C, &adapter->state);
-
        return ret_val;
 }
 
index bad8f14b194107b7d77ac5f89f194998c4c0f514..128d6b88532630693acc9f92ce99387140b2aec8 100644 (file)
@@ -63,7 +63,7 @@ char ixgbe_default_device_descr[] =
 static char ixgbe_default_device_descr[] =
                              "Intel(R) 10 Gigabit Network Connection";
 #endif
-#define DRV_VERSION "3.13.10-k"
+#define DRV_VERSION "3.15.1-k"
 const char ixgbe_driver_version[] = DRV_VERSION;
 static const char ixgbe_copyright[] =
                                "Copyright (c) 1999-2013 Intel Corporation.";
@@ -109,6 +109,7 @@ static DEFINE_PCI_DEVICE_TABLE(ixgbe_pci_tbl) = {
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X540T), board_X540 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP_SF2), board_82599 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_LS), board_82599 },
+       {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_QSFP_SF_QP), board_82599 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599EN_SFP), board_82599 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP_SF_QP), board_82599 },
        {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X540T1), board_X540 },
@@ -195,6 +196,86 @@ static s32 ixgbe_get_parent_bus_info(struct ixgbe_adapter *adapter)
        return 0;
 }
 
+/**
+ * ixgbe_check_from_parent - Determine whether PCIe info should come from parent
+ * @hw: hw specific details
+ *
+ * This function is used by probe to determine whether a device's PCI-Express
+ * bandwidth details should be gathered from the parent bus instead of from the
+ * device. Used to ensure that various locations all have the correct device ID
+ * checks.
+ */
+static inline bool ixgbe_pcie_from_parent(struct ixgbe_hw *hw)
+{
+       switch (hw->device_id) {
+       case IXGBE_DEV_ID_82599_SFP_SF_QP:
+       case IXGBE_DEV_ID_82599_QSFP_SF_QP:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static void ixgbe_check_minimum_link(struct ixgbe_adapter *adapter,
+                                    int expected_gts)
+{
+       int max_gts = 0;
+       enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;
+       enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
+       struct pci_dev *pdev;
+
+       /* determine whether to use the the parent device
+        */
+       if (ixgbe_pcie_from_parent(&adapter->hw))
+               pdev = adapter->pdev->bus->parent->self;
+       else
+               pdev = adapter->pdev;
+
+       if (pcie_get_minimum_link(pdev, &speed, &width) ||
+           speed == PCI_SPEED_UNKNOWN || width == PCIE_LNK_WIDTH_UNKNOWN) {
+               e_dev_warn("Unable to determine PCI Express bandwidth.\n");
+               return;
+       }
+
+       switch (speed) {
+       case PCIE_SPEED_2_5GT:
+               /* 8b/10b encoding reduces max throughput by 20% */
+               max_gts = 2 * width;
+               break;
+       case PCIE_SPEED_5_0GT:
+               /* 8b/10b encoding reduces max throughput by 20% */
+               max_gts = 4 * width;
+               break;
+       case PCIE_SPEED_8_0GT:
+               /* 128b/130b encoding only reduces throughput by 1% */
+               max_gts = 8 * width;
+               break;
+       default:
+               e_dev_warn("Unable to determine PCI Express bandwidth.\n");
+               return;
+       }
+
+       e_dev_info("PCI Express bandwidth of %dGT/s available\n",
+                  max_gts);
+       e_dev_info("(Speed:%s, Width: x%d, Encoding Loss:%s)\n",
+                  (speed == PCIE_SPEED_8_0GT ? "8.0GT/s" :
+                   speed == PCIE_SPEED_5_0GT ? "5.0GT/s" :
+                   speed == PCIE_SPEED_2_5GT ? "2.5GT/s" :
+                   "Unknown"),
+                  width,
+                  (speed == PCIE_SPEED_2_5GT ? "20%" :
+                   speed == PCIE_SPEED_5_0GT ? "20%" :
+                   speed == PCIE_SPEED_8_0GT ? "N/a" :
+                   "Unknown"));
+
+       if (max_gts < expected_gts) {
+               e_dev_warn("This is not sufficient for optimal performance of this card.\n");
+               e_dev_warn("For optimal performance, at least %dGT/s of bandwidth is required.\n",
+                       expected_gts);
+               e_dev_warn("A slot with more lanes and/or higher speed is suggested.\n");
+       }
+}
+
 static void ixgbe_service_event_schedule(struct ixgbe_adapter *adapter)
 {
        if (!test_bit(__IXGBE_DOWN, &adapter->state) &&
@@ -1998,7 +2079,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
        return total_rx_packets;
 }
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 /* must be called with local_bh_disable()d */
 static int ixgbe_low_latency_recv(struct napi_struct *napi)
 {
@@ -2030,7 +2111,7 @@ static int ixgbe_low_latency_recv(struct napi_struct *napi)
 
        return found;
 }
-#endif /* CONFIG_NET_LL_RX_POLL */
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 
 /**
  * ixgbe_configure_msix - Configure MSI-X hardware
@@ -3724,8 +3805,15 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
                hw->addr_ctrl.user_set_promisc = true;
                fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
                vmolr |= (IXGBE_VMOLR_ROPE | IXGBE_VMOLR_MPE);
-               /* don't hardware filter vlans in promisc mode */
-               ixgbe_vlan_filter_disable(adapter);
+               /* Only disable hardware filter vlans in promiscuous mode
+                * if SR-IOV and VMDQ are disabled - otherwise ensure
+                * that hardware VLAN filters remain enabled.
+                */
+               if (!(adapter->flags & (IXGBE_FLAG_VMDQ_ENABLED |
+                                       IXGBE_FLAG_SRIOV_ENABLED)))
+                       ixgbe_vlan_filter_disable(adapter);
+               else
+                       ixgbe_vlan_filter_enable(adapter);
        } else {
                if (netdev->flags & IFF_ALLMULTI) {
                        fctrl |= IXGBE_FCTRL_MPE;
@@ -4352,7 +4440,7 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)
        if (hw->mac.san_mac_rar_index)
                hw->mac.ops.set_vmdq_san_mac(hw, VMDQ_P(0));
 
-       if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
+       if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state))
                ixgbe_ptp_reset(adapter);
 }
 
@@ -4714,8 +4802,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)
        ixgbe_pbthresh_setup(adapter);
        hw->fc.pause_time = IXGBE_DEFAULT_FCPAUSE;
        hw->fc.send_xon = true;
-       hw->fc.disable_fc_autoneg =
-               (ixgbe_device_supports_autoneg_fc(hw) == 0) ? false : true;
+       hw->fc.disable_fc_autoneg = ixgbe_device_supports_autoneg_fc(hw);
 
 #ifdef CONFIG_PCI_IOV
        /* assign number of SR-IOV VFs */
@@ -5681,7 +5768,7 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
 
        adapter->last_rx_ptp_check = jiffies;
 
-       if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
+       if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state))
                ixgbe_ptp_start_cyclecounter(adapter);
 
        e_info(drv, "NIC Link is Up %s, Flow Control: %s\n",
@@ -5727,7 +5814,7 @@ static void ixgbe_watchdog_link_is_down(struct ixgbe_adapter *adapter)
        if (ixgbe_is_sfp(hw) && hw->mac.type == ixgbe_mac_82598EB)
                adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP;
 
-       if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)
+       if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state))
                ixgbe_ptp_start_cyclecounter(adapter);
 
        e_info(drv, "NIC Link is Down\n");
@@ -5826,10 +5913,6 @@ static void ixgbe_sfp_detection_subtask(struct ixgbe_adapter *adapter)
            !(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET))
                return;
 
-       /* concurent i2c reads are not supported */
-       if (test_bit(__IXGBE_READ_I2C, &adapter->state))
-               return;
-
        /* someone else is in init, wait until next service event */
        if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
                return;
@@ -6038,7 +6121,7 @@ static void ixgbe_service_task(struct work_struct *work)
        ixgbe_fdir_reinit_subtask(adapter);
        ixgbe_check_hang_subtask(adapter);
 
-       if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED) {
+       if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) {
                ixgbe_ptp_overflow_check(adapter);
                ixgbe_ptp_rx_hang(adapter);
        }
@@ -7227,7 +7310,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
 #ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller    = ixgbe_netpoll,
 #endif
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        .ndo_busy_poll          = ixgbe_low_latency_recv,
 #endif
 #ifdef IXGBE_FCOE
@@ -7246,6 +7329,42 @@ static const struct net_device_ops ixgbe_netdev_ops = {
        .ndo_bridge_getlink     = ixgbe_ndo_bridge_getlink,
 };
 
+/**
+ * ixgbe_enumerate_functions - Get the number of ports this device has
+ * @adapter: adapter structure
+ *
+ * This function enumerates the phsyical functions co-located on a single slot,
+ * in order to determine how many ports a device has. This is most useful in
+ * determining the required GT/s of PCIe bandwidth necessary for optimal
+ * performance.
+ **/
+static inline int ixgbe_enumerate_functions(struct ixgbe_adapter *adapter)
+{
+       struct ixgbe_hw *hw = &adapter->hw;
+       struct list_head *entry;
+       int physfns = 0;
+
+       /* Some cards can not use the generic count PCIe functions method, and
+        * so must be hardcoded to the correct value.
+        */
+       switch (hw->device_id) {
+       case IXGBE_DEV_ID_82599_SFP_SF_QP:
+       case IXGBE_DEV_ID_82599_QSFP_SF_QP:
+               physfns = 4;
+               break;
+       default:
+               list_for_each(entry, &adapter->pdev->bus_list) {
+                       struct pci_dev *pdev =
+                               list_entry(entry, struct pci_dev, bus_list);
+                       /* don't count virtual functions */
+                       if (!pdev->is_virtfn)
+                               physfns++;
+               }
+       }
+
+       return physfns;
+}
+
 /**
  * ixgbe_wol_supported - Check whether device supports WoL
  * @hw: hw specific details
@@ -7328,7 +7447,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ixgbe_hw *hw;
        const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data];
        static int cards_found;
-       int i, err, pci_using_dac;
+       int i, err, pci_using_dac, expected_gts;
        unsigned int indices = MAX_TX_QUEUES;
        u8 part_str[IXGBE_PBANUM_LENGTH];
 #ifdef IXGBE_FCOE
@@ -7617,7 +7736,7 @@ skip_sriov:
 
        /* pick up the PCI bus settings for reporting later */
        hw->mac.ops.get_bus_info(hw);
-       if (hw->device_id == IXGBE_DEV_ID_82599_SFP_SF_QP)
+       if (ixgbe_pcie_from_parent(hw))
                ixgbe_get_parent_bus_info(adapter);
 
        /* print bus type/speed/width info */
@@ -7643,12 +7762,20 @@ skip_sriov:
                e_dev_info("MAC: %d, PHY: %d, PBA No: %s\n",
                           hw->mac.type, hw->phy.type, part_str);
 
-       if (hw->bus.width <= ixgbe_bus_width_pcie_x4) {
-               e_dev_warn("PCI-Express bandwidth available for this card is "
-                          "not sufficient for optimal performance.\n");
-               e_dev_warn("For optimal performance a x8 PCI-Express slot "
-                          "is required.\n");
+       /* calculate the expected PCIe bandwidth required for optimal
+        * performance. Note that some older parts will never have enough
+        * bandwidth due to being older generation PCIe parts. We clamp these
+        * parts to ensure no warning is displayed if it can't be fixed.
+        */
+       switch (hw->mac.type) {
+       case ixgbe_mac_82598EB:
+               expected_gts = min(ixgbe_enumerate_functions(adapter) * 10, 16);
+               break;
+       default:
+               expected_gts = ixgbe_enumerate_functions(adapter) * 10;
+               break;
        }
+       ixgbe_check_minimum_link(adapter, expected_gts);
 
        /* reset the hardware with the new settings */
        err = hw->mac.ops.start_hw(hw);
index e5691ccbce9dd09eac8caa20120531b5e3ad1a2a..369eef526bc19f3d9e15809e9821ef13ae46afe9 100644 (file)
@@ -203,8 +203,84 @@ out:
        return status;
 }
 
+/**
+ *  ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
+ *  the SWFW lock
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit address of PHY register to read
+ *  @phy_data: Pointer to read data from PHY register
+ **/
+s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
+                      u16 *phy_data)
+{
+       u32 i, data, command;
+
+       /* Setup and write the address cycle command */
+       command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+                  (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+                  (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+                  (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
+
+       IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+       /* Check every 10 usec to see if the address cycle completed.
+        * The MDI Command bit will clear when the operation is
+        * complete
+        */
+       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+               udelay(10);
+
+               command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+               if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
+                               break;
+       }
+
+
+       if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
+               hw_dbg(hw, "PHY address command did not complete.\n");
+               return IXGBE_ERR_PHY;
+       }
+
+       /* Address cycle complete, setup and write the read
+        * command
+        */
+       command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+                  (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+                  (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+                  (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
+
+       IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+       /* Check every 10 usec to see if the address cycle
+        * completed. The MDI Command bit will clear when the
+        * operation is complete
+        */
+       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+               udelay(10);
+
+               command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+               if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
+                       break;
+       }
+
+       if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
+               hw_dbg(hw, "PHY read command didn't complete\n");
+               return IXGBE_ERR_PHY;
+       }
+
+       /* Read operation is complete.  Get the data
+        * from MSRWD
+        */
+       data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
+       data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
+       *phy_data = (u16)(data);
+
+       return 0;
+}
+
 /**
  *  ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
+ *  using the SWFW lock - this function is needed in most cases
  *  @hw: pointer to hardware structure
  *  @reg_addr: 32 bit address of PHY register to read
  *  @phy_data: Pointer to read data from PHY register
@@ -212,10 +288,7 @@ out:
 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
                                u32 device_type, u16 *phy_data)
 {
-       u32 command;
-       u32 i;
-       u32 data;
-       s32 status = 0;
+       s32 status;
        u16 gssr;
 
        if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
@@ -223,86 +296,93 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
        else
                gssr = IXGBE_GSSR_PHY0_SM;
 
-       if (hw->mac.ops.acquire_swfw_sync(hw, gssr) != 0)
+       if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == 0) {
+               status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
+                                               phy_data);
+               hw->mac.ops.release_swfw_sync(hw, gssr);
+       } else {
                status = IXGBE_ERR_SWFW_SYNC;
+       }
 
-       if (status == 0) {
-               /* Setup and write the address cycle command */
-               command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
-                          (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
-                          (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
-                          (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
+       return status;
+}
 
-               IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+/**
+ *  ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
+ *  without SWFW lock
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit PHY register to write
+ *  @device_type: 5 bit device type
+ *  @phy_data: Data to write to the PHY register
+ **/
+s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
+                               u32 device_type, u16 phy_data)
+{
+       u32 i, command;
 
-               /*
-                * Check every 10 usec to see if the address cycle completed.
-                * The MDI Command bit will clear when the operation is
-                * complete
-                */
-               for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
-                       udelay(10);
+       /* Put the data in the MDI single read and write data register*/
+       IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
 
-                       command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+       /* Setup and write the address cycle command */
+       command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+                  (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+                  (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+                  (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
 
-                       if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
-                               break;
-               }
+       IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
 
-               if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
-                       hw_dbg(hw, "PHY address command did not complete.\n");
-                       status = IXGBE_ERR_PHY;
-               }
+       /*
+        * Check every 10 usec to see if the address cycle completed.
+        * The MDI Command bit will clear when the operation is
+        * complete
+        */
+       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+               udelay(10);
 
-               if (status == 0) {
-                       /*
-                        * Address cycle complete, setup and write the read
-                        * command
-                        */
-                       command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
-                                  (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
-                                  (hw->phy.mdio.prtad <<
-                                   IXGBE_MSCA_PHY_ADDR_SHIFT) |
-                                  (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
-
-                       IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
-
-                       /*
-                        * Check every 10 usec to see if the address cycle
-                        * completed. The MDI Command bit will clear when the
-                        * operation is complete
-                        */
-                       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
-                               udelay(10);
-
-                               command = IXGBE_READ_REG(hw, IXGBE_MSCA);
-
-                               if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
-                                       break;
-                       }
+               command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+               if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
+                       break;
+       }
 
-                       if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
-                               hw_dbg(hw, "PHY read command didn't complete\n");
-                               status = IXGBE_ERR_PHY;
-                       } else {
-                               /*
-                                * Read operation is complete.  Get the data
-                                * from MSRWD
-                                */
-                               data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
-                               data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
-                               *phy_data = (u16)(data);
-                       }
-               }
+       if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
+               hw_dbg(hw, "PHY address cmd didn't complete\n");
+               return IXGBE_ERR_PHY;
+       }
 
-               hw->mac.ops.release_swfw_sync(hw, gssr);
+       /*
+        * Address cycle complete, setup and write the write
+        * command
+        */
+       command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+                  (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+                  (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+                  (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
+
+       IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+       /* Check every 10 usec to see if the address cycle
+        * completed. The MDI Command bit will clear when the
+        * operation is complete
+        */
+       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+               udelay(10);
+
+               command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+               if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
+                       break;
        }
 
-       return status;
+       if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
+               hw_dbg(hw, "PHY write cmd didn't complete\n");
+               return IXGBE_ERR_PHY;
+       }
+
+       return 0;
 }
 
 /**
  *  ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
+ *  using SWFW lock- this function is needed in most cases
  *  @hw: pointer to hardware structure
  *  @reg_addr: 32 bit PHY register to write
  *  @device_type: 5 bit device type
@@ -311,9 +391,7 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
                                 u32 device_type, u16 phy_data)
 {
-       u32 command;
-       u32 i;
-       s32 status = 0;
+       s32 status;
        u16 gssr;
 
        if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
@@ -321,74 +399,12 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
        else
                gssr = IXGBE_GSSR_PHY0_SM;
 
-       if (hw->mac.ops.acquire_swfw_sync(hw, gssr) != 0)
-               status = IXGBE_ERR_SWFW_SYNC;
-
-       if (status == 0) {
-               /* Put the data in the MDI single read and write data register*/
-               IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
-
-               /* Setup and write the address cycle command */
-               command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
-                          (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
-                          (hw->phy.mdio.prtad << IXGBE_MSCA_PHY_ADDR_SHIFT) |
-                          (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
-
-               IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
-
-               /*
-                * Check every 10 usec to see if the address cycle completed.
-                * The MDI Command bit will clear when the operation is
-                * complete
-                */
-               for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
-                       udelay(10);
-
-                       command = IXGBE_READ_REG(hw, IXGBE_MSCA);
-
-                       if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
-                               break;
-               }
-
-               if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
-                       hw_dbg(hw, "PHY address cmd didn't complete\n");
-                       status = IXGBE_ERR_PHY;
-               }
-
-               if (status == 0) {
-                       /*
-                        * Address cycle complete, setup and write the write
-                        * command
-                        */
-                       command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
-                                  (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
-                                  (hw->phy.mdio.prtad <<
-                                   IXGBE_MSCA_PHY_ADDR_SHIFT) |
-                                  (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
-
-                       IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
-
-                       /*
-                        * Check every 10 usec to see if the address cycle
-                        * completed. The MDI Command bit will clear when the
-                        * operation is complete
-                        */
-                       for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
-                               udelay(10);
-
-                               command = IXGBE_READ_REG(hw, IXGBE_MSCA);
-
-                               if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
-                                       break;
-                       }
-
-                       if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
-                               hw_dbg(hw, "PHY address cmd didn't complete\n");
-                               status = IXGBE_ERR_PHY;
-                       }
-               }
-
+       if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == 0) {
+               status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
+                                                phy_data);
                hw->mac.ops.release_swfw_sync(hw, gssr);
+       } else {
+               status = IXGBE_ERR_SWFW_SYNC;
        }
 
        return status;
@@ -825,9 +841,35 @@ out:
 }
 
 /**
- *  ixgbe_identify_sfp_module_generic - Identifies SFP modules
+ *  ixgbe_identify_module_generic - Identifies module type
  *  @hw: pointer to hardware structure
  *
+ *  Determines HW type and calls appropriate function.
+ **/
+s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
+{
+       s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
+
+       switch (hw->mac.ops.get_media_type(hw)) {
+       case ixgbe_media_type_fiber:
+               status = ixgbe_identify_sfp_module_generic(hw);
+               break;
+       case ixgbe_media_type_fiber_qsfp:
+               status = ixgbe_identify_qsfp_module_generic(hw);
+               break;
+       default:
+               hw->phy.sfp_type = ixgbe_sfp_type_not_present;
+               status = IXGBE_ERR_SFP_NOT_PRESENT;
+               break;
+       }
+
+       return status;
+}
+
+/**
+ *  ixgbe_identify_sfp_module_generic - Identifies SFP modules
+ *  @hw: pointer to hardware structure
+*
  *  Searches for and identifies the SFP module and assigns appropriate PHY type.
  **/
 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
@@ -1105,6 +1147,156 @@ err_read_i2c_eeprom:
        return IXGBE_ERR_SFP_NOT_PRESENT;
 }
 
+/**
+ * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
+ * @hw: pointer to hardware structure
+ *
+ * Searches for and identifies the QSFP module and assigns appropriate PHY type
+ **/
+s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
+{
+       struct ixgbe_adapter *adapter = hw->back;
+       s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
+       u32 vendor_oui = 0;
+       enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
+       u8 identifier = 0;
+       u8 comp_codes_1g = 0;
+       u8 comp_codes_10g = 0;
+       u8 oui_bytes[3] = {0, 0, 0};
+       u16 enforce_sfp = 0;
+
+       if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
+               hw->phy.sfp_type = ixgbe_sfp_type_not_present;
+               status = IXGBE_ERR_SFP_NOT_PRESENT;
+               goto out;
+       }
+
+       status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
+                                            &identifier);
+
+       if (status != 0)
+               goto err_read_i2c_eeprom;
+
+       if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
+               hw->phy.type = ixgbe_phy_sfp_unsupported;
+               status = IXGBE_ERR_SFP_NOT_SUPPORTED;
+               goto out;
+       }
+
+       hw->phy.id = identifier;
+
+       /* LAN ID is needed for sfp_type determination */
+       hw->mac.ops.set_lan_id(hw);
+
+       status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
+                                            &comp_codes_10g);
+
+       if (status != 0)
+               goto err_read_i2c_eeprom;
+
+       if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
+               hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
+               if (hw->bus.lan_id == 0)
+                       hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
+               else
+                       hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
+       } else if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE) {
+               hw->phy.type = ixgbe_phy_qsfp_active_unknown;
+               if (hw->bus.lan_id == 0)
+                       hw->phy.sfp_type = ixgbe_sfp_type_da_act_lmt_core0;
+               else
+                       hw->phy.sfp_type = ixgbe_sfp_type_da_act_lmt_core1;
+       } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
+                                    IXGBE_SFF_10GBASELR_CAPABLE)) {
+               if (hw->bus.lan_id == 0)
+                       hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
+               else
+                       hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
+       } else {
+               /* unsupported module type */
+               hw->phy.type = ixgbe_phy_sfp_unsupported;
+               status = IXGBE_ERR_SFP_NOT_SUPPORTED;
+               goto out;
+       }
+
+       if (hw->phy.sfp_type != stored_sfp_type)
+               hw->phy.sfp_setup_needed = true;
+
+       /* Determine if the QSFP+ PHY is dual speed or not. */
+       hw->phy.multispeed_fiber = false;
+       if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
+            (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
+           ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
+            (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
+               hw->phy.multispeed_fiber = true;
+
+       /* Determine PHY vendor for optical modules */
+       if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
+                             IXGBE_SFF_10GBASELR_CAPABLE)) {
+               status = hw->phy.ops.read_i2c_eeprom(hw,
+                                       IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
+                                       &oui_bytes[0]);
+
+               if (status != 0)
+                       goto err_read_i2c_eeprom;
+
+               status = hw->phy.ops.read_i2c_eeprom(hw,
+                                       IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
+                                       &oui_bytes[1]);
+
+               if (status != 0)
+                       goto err_read_i2c_eeprom;
+
+               status = hw->phy.ops.read_i2c_eeprom(hw,
+                                       IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
+                                       &oui_bytes[2]);
+
+               if (status != 0)
+                       goto err_read_i2c_eeprom;
+
+               vendor_oui =
+                       ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
+                        (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
+                        (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
+
+               if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
+                       hw->phy.type = ixgbe_phy_qsfp_intel;
+               else
+                       hw->phy.type = ixgbe_phy_qsfp_unknown;
+
+               hw->mac.ops.get_device_caps(hw, &enforce_sfp);
+               if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
+                       /* Make sure we're a supported PHY type */
+                       if (hw->phy.type == ixgbe_phy_qsfp_intel) {
+                               status = 0;
+                       } else {
+                               if (hw->allow_unsupported_sfp == true) {
+                                       e_warn(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
+                                       status = 0;
+                               } else {
+                                       hw_dbg(hw,
+                                              "QSFP module not supported\n");
+                                       hw->phy.type =
+                                               ixgbe_phy_sfp_unsupported;
+                                       status = IXGBE_ERR_SFP_NOT_SUPPORTED;
+                               }
+                       }
+               } else {
+                       status = 0;
+               }
+       }
+
+out:
+       return status;
+
+err_read_i2c_eeprom:
+       hw->phy.sfp_type = ixgbe_sfp_type_not_present;
+       hw->phy.id = 0;
+       hw->phy.type = ixgbe_phy_unknown;
+
+       return IXGBE_ERR_SFP_NOT_PRESENT;
+}
+
 /**
  *  ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
  *  @hw: pointer to hardware structure
index 886a3431cf5bc36e3c38a22b5964fb4488b8ed66..138dadd7cf336e94ae84254653052d351cb3258b 100644 (file)
 #define IXGBE_I2C_EEPROM_DEV_ADDR2   0xA2
 
 /* EEPROM byte offsets */
-#define IXGBE_SFF_IDENTIFIER         0x0
-#define IXGBE_SFF_IDENTIFIER_SFP     0x3
-#define IXGBE_SFF_VENDOR_OUI_BYTE0   0x25
-#define IXGBE_SFF_VENDOR_OUI_BYTE1   0x26
-#define IXGBE_SFF_VENDOR_OUI_BYTE2   0x27
-#define IXGBE_SFF_1GBE_COMP_CODES    0x6
-#define IXGBE_SFF_10GBE_COMP_CODES   0x3
-#define IXGBE_SFF_CABLE_TECHNOLOGY   0x8
-#define IXGBE_SFF_CABLE_SPEC_COMP    0x3C
-#define IXGBE_SFF_SFF_8472_SWAP      0x5C
-#define IXGBE_SFF_SFF_8472_COMP      0x5E
+#define IXGBE_SFF_IDENTIFIER           0x0
+#define IXGBE_SFF_IDENTIFIER_SFP       0x3
+#define IXGBE_SFF_VENDOR_OUI_BYTE0     0x25
+#define IXGBE_SFF_VENDOR_OUI_BYTE1     0x26
+#define IXGBE_SFF_VENDOR_OUI_BYTE2     0x27
+#define IXGBE_SFF_1GBE_COMP_CODES      0x6
+#define IXGBE_SFF_10GBE_COMP_CODES     0x3
+#define IXGBE_SFF_CABLE_TECHNOLOGY     0x8
+#define IXGBE_SFF_CABLE_SPEC_COMP      0x3C
+#define IXGBE_SFF_SFF_8472_SWAP                0x5C
+#define IXGBE_SFF_SFF_8472_COMP                0x5E
+#define IXGBE_SFF_SFF_8472_OSCB                0x6E
+#define IXGBE_SFF_SFF_8472_ESCB                0x76
+#define IXGBE_SFF_IDENTIFIER_QSFP_PLUS 0xD
+#define IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0        0xA5
+#define IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1        0xA6
+#define IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2        0xA7
+#define IXGBE_SFF_QSFP_10GBE_COMP      0x83
+#define IXGBE_SFF_QSFP_1GBE_COMP       0x86
 
 /* Bitmasks */
 #define IXGBE_SFF_DA_PASSIVE_CABLE           0x4
 #define IXGBE_SFF_1GBASET_CAPABLE            0x8
 #define IXGBE_SFF_10GBASESR_CAPABLE          0x10
 #define IXGBE_SFF_10GBASELR_CAPABLE          0x20
+#define IXGBE_SFF_SOFT_RS_SELECT_MASK  0x8
+#define IXGBE_SFF_SOFT_RS_SELECT_10G   0x8
+#define IXGBE_SFF_SOFT_RS_SELECT_1G    0x0
 #define IXGBE_SFF_ADDRESSING_MODE           0x4
+#define IXGBE_SFF_QSFP_DA_ACTIVE_CABLE       0x1
+#define IXGBE_SFF_QSFP_DA_PASSIVE_CABLE      0x8
 #define IXGBE_I2C_EEPROM_READ_MASK           0x100
 #define IXGBE_I2C_EEPROM_STATUS_MASK         0x3
 #define IXGBE_I2C_EEPROM_STATUS_NO_OPERATION 0x0
@@ -102,6 +115,10 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
                                u32 device_type, u16 *phy_data);
 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
                                 u32 device_type, u16 phy_data);
+s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
+                          u32 device_type, u16 *phy_data);
+s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
+                           u32 device_type, u16 phy_data);
 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw);
 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
                                        ixgbe_link_speed speed,
@@ -121,7 +138,9 @@ s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
                                            u16 *firmware_version);
 
 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw);
+s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw);
 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw);
+s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw);
 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
                                         u16 *list_offset,
                                         u16 *data_offset);
index 331987d6815c91ef7f6296c1d3062821c3268a1b..5184e2a1a7d8249bc746ce6496e55f5789a0e949 100644 (file)
@@ -885,8 +885,8 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
 
        ixgbe_ptp_reset(adapter);
 
-       /* set the flag that PTP has been enabled */
-       adapter->flags2 |= IXGBE_FLAG2_PTP_ENABLED;
+       /* enter the IXGBE_PTP_RUNNING state */
+       set_bit(__IXGBE_PTP_RUNNING, &adapter->state);
 
        return;
 }
@@ -899,10 +899,12 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)
  */
 void ixgbe_ptp_stop(struct ixgbe_adapter *adapter)
 {
-       /* stop the overflow check task */
-       adapter->flags2 &= ~(IXGBE_FLAG2_PTP_ENABLED |
-                            IXGBE_FLAG2_PTP_PPS_ENABLED);
+       /* Leave the IXGBE_PTP_RUNNING state. */
+       if (!test_and_clear_bit(__IXGBE_PTP_RUNNING, &adapter->state))
+               return;
 
+       /* stop the PPS signal */
+       adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED;
        ixgbe_ptp_setup_sdp(adapter);
 
        cancel_work_sync(&adapter->ptp_tx_work);
index 1e7d587c4e572f9efdd3f876b98e906cb3963561..73c8e73bb6e74754b36e2637c07ada9510e1fe4c 100644 (file)
@@ -173,39 +173,6 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
        ixgbe_disable_sriov(adapter);
 }
 
-static bool ixgbe_vfs_are_assigned(struct ixgbe_adapter *adapter)
-{
-       struct pci_dev *pdev = adapter->pdev;
-       struct pci_dev *vfdev;
-       int dev_id;
-
-       switch (adapter->hw.mac.type) {
-       case ixgbe_mac_82599EB:
-               dev_id = IXGBE_DEV_ID_82599_VF;
-               break;
-       case ixgbe_mac_X540:
-               dev_id = IXGBE_DEV_ID_X540_VF;
-               break;
-       default:
-               return false;
-       }
-
-       /* loop through all the VFs to see if we own any that are assigned */
-       vfdev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, NULL);
-       while (vfdev) {
-               /* if we don't own it we don't care */
-               if (vfdev->is_virtfn && vfdev->physfn == pdev) {
-                       /* if it is assigned we cannot release it */
-                       if (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED)
-                               return true;
-               }
-
-               vfdev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, vfdev);
-       }
-
-       return false;
-}
-
 #endif /* #ifdef CONFIG_PCI_IOV */
 int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
 {
@@ -235,7 +202,7 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
         * without causing issues, so just leave the hardware
         * available but disabled
         */
-       if (ixgbe_vfs_are_assigned(adapter)) {
+       if (pci_vfs_assigned(adapter->pdev)) {
                e_dev_warn("Unloading driver while VFs are assigned - VFs will not be deallocated\n");
                return -EPERM;
        }
@@ -768,6 +735,29 @@ static int ixgbe_set_vf_mac_addr(struct ixgbe_adapter *adapter,
        return ixgbe_set_vf_mac(adapter, vf, new_mac) < 0;
 }
 
+static int ixgbe_find_vlvf_entry(struct ixgbe_hw *hw, u32 vlan)
+{
+       u32 vlvf;
+       s32 regindex;
+
+       /* short cut the special case */
+       if (vlan == 0)
+               return 0;
+
+       /* Search for the vlan id in the VLVF entries */
+       for (regindex = 1; regindex < IXGBE_VLVF_ENTRIES; regindex++) {
+               vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(regindex));
+               if ((vlvf & VLAN_VID_MASK) == vlan)
+                       break;
+       }
+
+       /* Return a negative value if not found */
+       if (regindex >= IXGBE_VLVF_ENTRIES)
+               regindex = -1;
+
+       return regindex;
+}
+
 static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter,
                                 u32 *msgbuf, u32 vf)
 {
@@ -775,6 +765,9 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter,
        int add = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >> IXGBE_VT_MSGINFO_SHIFT;
        int vid = (msgbuf[1] & IXGBE_VLVF_VLANID_MASK);
        int err;
+       s32 reg_ndx;
+       u32 vlvf;
+       u32 bits;
        u8 tcs = netdev_get_num_tc(adapter->netdev);
 
        if (adapter->vfinfo[vf].pf_vlan || tcs) {
@@ -790,10 +783,50 @@ static int ixgbe_set_vf_vlan_msg(struct ixgbe_adapter *adapter,
        else if (adapter->vfinfo[vf].vlan_count)
                adapter->vfinfo[vf].vlan_count--;
 
+       /* in case of promiscuous mode any VLAN filter set for a VF must
+        * also have the PF pool added to it.
+        */
+       if (add && adapter->netdev->flags & IFF_PROMISC)
+               err = ixgbe_set_vf_vlan(adapter, add, vid, VMDQ_P(0));
+
        err = ixgbe_set_vf_vlan(adapter, add, vid, vf);
        if (!err && adapter->vfinfo[vf].spoofchk_enabled)
                hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf);
 
+       /* Go through all the checks to see if the VLAN filter should
+        * be wiped completely.
+        */
+       if (!add && adapter->netdev->flags & IFF_PROMISC) {
+               reg_ndx = ixgbe_find_vlvf_entry(hw, vid);
+               if (reg_ndx < 0)
+                       goto out;
+               vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(reg_ndx));
+               /* See if any other pools are set for this VLAN filter
+                * entry other than the PF.
+                */
+               if (VMDQ_P(0) < 32) {
+                       bits = IXGBE_READ_REG(hw, IXGBE_VLVFB(reg_ndx * 2));
+                       bits &= ~(1 << VMDQ_P(0));
+                       bits |= IXGBE_READ_REG(hw,
+                                              IXGBE_VLVFB(reg_ndx * 2) + 1);
+               } else {
+                       bits = IXGBE_READ_REG(hw,
+                                             IXGBE_VLVFB(reg_ndx * 2) + 1);
+                       bits &= ~(1 << (VMDQ_P(0) - 32));
+                       bits |= IXGBE_READ_REG(hw, IXGBE_VLVFB(reg_ndx * 2));
+               }
+
+               /* If the filter was removed then ensure PF pool bit
+                * is cleared if the PF only added itself to the pool
+                * because the PF is in promiscuous mode.
+                */
+               if ((vlvf & VLAN_VID_MASK) == vid &&
+                   !test_bit(vid, adapter->active_vlans) && !bits)
+                       ixgbe_set_vf_vlan(adapter, add, vid, VMDQ_P(0));
+       }
+
+out:
+
        return err;
 }
 
index 70c6aa3d3f959fc6f86fa032fc874376f714efe9..161ff18be77550bd71386b2d05fd5ec16ee7c4f3 100644 (file)
@@ -69,6 +69,7 @@
 #define IXGBE_DEV_ID_82599_LS            0x154F
 #define IXGBE_DEV_ID_X540T               0x1528
 #define IXGBE_DEV_ID_82599_SFP_SF_QP     0x154A
+#define IXGBE_DEV_ID_82599_QSFP_SF_QP    0x1558
 #define IXGBE_DEV_ID_X540T1              0x1560
 
 /* VF Device IDs */
@@ -1520,9 +1521,11 @@ enum {
 #define IXGBE_ESDP_SDP5 0x00000020 /* SDP5 Data Value */
 #define IXGBE_ESDP_SDP6 0x00000040 /* SDP6 Data Value */
 #define IXGBE_ESDP_SDP0_DIR     0x00000100 /* SDP0 IO direction */
+#define IXGBE_ESDP_SDP1_DIR     0x00000200 /* SDP1 IO direction */
 #define IXGBE_ESDP_SDP4_DIR     0x00000004 /* SDP4 IO direction */
 #define IXGBE_ESDP_SDP5_DIR     0x00002000 /* SDP5 IO direction */
 #define IXGBE_ESDP_SDP0_NATIVE  0x00010000 /* SDP0 Native Function */
+#define IXGBE_ESDP_SDP1_NATIVE  0x00020000 /* SDP1 IO mode */
 
 /* LEDCTL Bit Masks */
 #define IXGBE_LED_IVRT_BASE      0x00000040
@@ -2582,6 +2585,10 @@ enum ixgbe_phy_type {
        ixgbe_phy_sfp_ftl_active,
        ixgbe_phy_sfp_unknown,
        ixgbe_phy_sfp_intel,
+       ixgbe_phy_qsfp_passive_unknown,
+       ixgbe_phy_qsfp_active_unknown,
+       ixgbe_phy_qsfp_intel,
+       ixgbe_phy_qsfp_unknown,
        ixgbe_phy_sfp_unsupported,
        ixgbe_phy_generic
 };
@@ -2622,6 +2629,8 @@ enum ixgbe_sfp_type {
 enum ixgbe_media_type {
        ixgbe_media_type_unknown = 0,
        ixgbe_media_type_fiber,
+       ixgbe_media_type_fiber_fixed,
+       ixgbe_media_type_fiber_qsfp,
        ixgbe_media_type_fiber_lco,
        ixgbe_media_type_copper,
        ixgbe_media_type_backplane,
@@ -2885,6 +2894,8 @@ struct ixgbe_phy_operations {
        s32 (*reset)(struct ixgbe_hw *);
        s32 (*read_reg)(struct ixgbe_hw *, u32, u32, u16 *);
        s32 (*write_reg)(struct ixgbe_hw *, u32, u32, u16);
+       s32 (*read_reg_mdi)(struct ixgbe_hw *, u32, u32, u16 *);
+       s32 (*write_reg_mdi)(struct ixgbe_hw *, u32, u32, u16);
        s32 (*setup_link)(struct ixgbe_hw *);
        s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool);
        s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *);
@@ -2953,6 +2964,7 @@ struct ixgbe_phy_info {
        bool                            smart_speed_active;
        bool                            multispeed_fiber;
        bool                            reset_if_overtemp;
+       bool                            qsfp_shared_i2c_bus;
 };
 
 #include "ixgbe_mbx.h"
index 712779fb12b7d80416db0a4349257f046ae0d11d..2777c70c603b550676b77027fd96e7b9a79fbe6b 100644 (file)
 #define MVNETA_MAC_ADDR_HIGH                     0x2418
 #define MVNETA_SDMA_CONFIG                       0x241c
 #define      MVNETA_SDMA_BRST_SIZE_16            4
-#define      MVNETA_NO_DESC_SWAP                 0x0
 #define      MVNETA_RX_BRST_SZ_MASK(burst)       ((burst) << 1)
 #define      MVNETA_RX_NO_DATA_SWAP              BIT(4)
 #define      MVNETA_TX_NO_DATA_SWAP              BIT(5)
+#define      MVNETA_DESC_SWAP                    BIT(6)
 #define      MVNETA_TX_BRST_SZ_MASK(burst)       ((burst) << 22)
 #define MVNETA_PORT_STATUS                       0x2444
 #define      MVNETA_TX_IN_PRGRS                  BIT(1)
 #define      MVNETA_TX_FIFO_EMPTY                BIT(8)
 #define MVNETA_RX_MIN_FRAME_SIZE                 0x247c
+#define MVNETA_SGMII_SERDES_CFG                         0x24A0
+#define      MVNETA_SGMII_SERDES_PROTO          0x0cc7
 #define MVNETA_TYPE_PRIO                         0x24bc
 #define      MVNETA_FORCE_UNI                    BIT(21)
 #define MVNETA_TXQ_CMD_1                         0x24e4
@@ -262,8 +264,7 @@ struct mvneta_port {
  * layout of the transmit and reception DMA descriptors, and their
  * layout is therefore defined by the hardware design
  */
-struct mvneta_tx_desc {
-       u32  command;           /* Options used by HW for packet transmitting.*/
+
 #define MVNETA_TX_L3_OFF_SHIFT 0
 #define MVNETA_TX_IP_HLEN_SHIFT        8
 #define MVNETA_TX_L4_UDP       BIT(16)
@@ -278,15 +279,6 @@ struct mvneta_tx_desc {
 #define MVNETA_TX_L4_CSUM_FULL BIT(30)
 #define MVNETA_TX_L4_CSUM_NOT  BIT(31)
 
-       u16  reserverd1;        /* csum_l4 (for future use)             */
-       u16  data_size;         /* Data size of transmitted packet in bytes */
-       u32  buf_phys_addr;     /* Physical addr of transmitted buffer  */
-       u32  reserved2;         /* hw_cmd - (for future use, PMT)       */
-       u32  reserved3[4];      /* Reserved - (for future use)          */
-};
-
-struct mvneta_rx_desc {
-       u32  status;            /* Info about received packet           */
 #define MVNETA_RXD_ERR_CRC             0x0
 #define MVNETA_RXD_ERR_SUMMARY         BIT(16)
 #define MVNETA_RXD_ERR_OVERRUN         BIT(17)
@@ -297,16 +289,57 @@ struct mvneta_rx_desc {
 #define MVNETA_RXD_FIRST_LAST_DESC     (BIT(26) | BIT(27))
 #define MVNETA_RXD_L4_CSUM_OK          BIT(30)
 
+#if defined(__LITTLE_ENDIAN)
+struct mvneta_tx_desc {
+       u32  command;           /* Options used by HW for packet transmitting.*/
+       u16  reserverd1;        /* csum_l4 (for future use)             */
+       u16  data_size;         /* Data size of transmitted packet in bytes */
+       u32  buf_phys_addr;     /* Physical addr of transmitted buffer  */
+       u32  reserved2;         /* hw_cmd - (for future use, PMT)       */
+       u32  reserved3[4];      /* Reserved - (for future use)          */
+};
+
+struct mvneta_rx_desc {
+       u32  status;            /* Info about received packet           */
        u16  reserved1;         /* pnc_info - (for future use, PnC)     */
        u16  data_size;         /* Size of received packet in bytes     */
+
        u32  buf_phys_addr;     /* Physical address of the buffer       */
        u32  reserved2;         /* pnc_flow_id  (for future use, PnC)   */
+
        u32  buf_cookie;        /* cookie for access to RX buffer in rx path */
        u16  reserved3;         /* prefetch_cmd, for future use         */
        u16  reserved4;         /* csum_l4 - (for future use, PnC)      */
+
+       u32  reserved5;         /* pnc_extra PnC (for future use, PnC)  */
+       u32  reserved6;         /* hw_cmd (for future use, PnC and HWF) */
+};
+#else
+struct mvneta_tx_desc {
+       u16  data_size;         /* Data size of transmitted packet in bytes */
+       u16  reserverd1;        /* csum_l4 (for future use)             */
+       u32  command;           /* Options used by HW for packet transmitting.*/
+       u32  reserved2;         /* hw_cmd - (for future use, PMT)       */
+       u32  buf_phys_addr;     /* Physical addr of transmitted buffer  */
+       u32  reserved3[4];      /* Reserved - (for future use)          */
+};
+
+struct mvneta_rx_desc {
+       u16  data_size;         /* Size of received packet in bytes     */
+       u16  reserved1;         /* pnc_info - (for future use, PnC)     */
+       u32  status;            /* Info about received packet           */
+
+       u32  reserved2;         /* pnc_flow_id  (for future use, PnC)   */
+       u32  buf_phys_addr;     /* Physical address of the buffer       */
+
+       u16  reserved4;         /* csum_l4 - (for future use, PnC)      */
+       u16  reserved3;         /* prefetch_cmd, for future use         */
+       u32  buf_cookie;        /* cookie for access to RX buffer in rx path */
+
        u32  reserved5;         /* pnc_extra PnC (for future use, PnC)  */
        u32  reserved6;         /* hw_cmd (for future use, PnC and HWF) */
 };
+#endif
 
 struct mvneta_tx_queue {
        /* Number of this TX queue, in the range 0-7 */
@@ -655,6 +688,8 @@ static void mvneta_port_sgmii_config(struct mvneta_port *pp)
        val = mvreg_read(pp, MVNETA_GMAC_CTRL_2);
        val |= MVNETA_GMAC2_PSC_ENABLE;
        mvreg_write(pp, MVNETA_GMAC_CTRL_2, val);
+
+       mvreg_write(pp, MVNETA_SGMII_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
 }
 
 /* Start the Ethernet port RX and TX activity */
@@ -904,9 +939,11 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
        /* Default burst size */
        val |= MVNETA_TX_BRST_SZ_MASK(MVNETA_SDMA_BRST_SIZE_16);
        val |= MVNETA_RX_BRST_SZ_MASK(MVNETA_SDMA_BRST_SIZE_16);
+       val |= MVNETA_RX_NO_DATA_SWAP | MVNETA_TX_NO_DATA_SWAP;
 
-       val |= (MVNETA_RX_NO_DATA_SWAP | MVNETA_TX_NO_DATA_SWAP |
-               MVNETA_NO_DESC_SWAP);
+#if defined(__BIG_ENDIAN)
+       val |= MVNETA_DESC_SWAP;
+#endif
 
        /* Assign port SDMA configuration */
        mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
@@ -2728,28 +2765,24 @@ static int mvneta_probe(struct platform_device *pdev)
 
        pp = netdev_priv(dev);
 
-       pp->tx_done_timer.function = mvneta_tx_done_timer_callback;
-       init_timer(&pp->tx_done_timer);
-       clear_bit(MVNETA_F_TX_DONE_TIMER_BIT, &pp->flags);
-
        pp->weight = MVNETA_RX_POLL_WEIGHT;
        pp->phy_node = phy_node;
        pp->phy_interface = phy_mode;
 
-       pp->base = of_iomap(dn, 0);
-       if (pp->base == NULL) {
-               err = -ENOMEM;
-               goto err_free_irq;
-       }
-
        pp->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(pp->clk)) {
                err = PTR_ERR(pp->clk);
-               goto err_unmap;
+               goto err_free_irq;
        }
 
        clk_prepare_enable(pp->clk);
 
+       pp->base = of_iomap(dn, 0);
+       if (pp->base == NULL) {
+               err = -ENOMEM;
+               goto err_clk;
+       }
+
        dt_mac_addr = of_get_mac_address(dn);
        if (dt_mac_addr && is_valid_ether_addr(dt_mac_addr)) {
                mac_from = "device tree";
@@ -2766,6 +2799,9 @@ static int mvneta_probe(struct platform_device *pdev)
        }
 
        pp->tx_done_timer.data = (unsigned long)dev;
+       pp->tx_done_timer.function = mvneta_tx_done_timer_callback;
+       init_timer(&pp->tx_done_timer);
+       clear_bit(MVNETA_F_TX_DONE_TIMER_BIT, &pp->flags);
 
        pp->tx_ring_size = MVNETA_MAX_TXD;
        pp->rx_ring_size = MVNETA_MAX_RXD;
@@ -2776,7 +2812,7 @@ static int mvneta_probe(struct platform_device *pdev)
        err = mvneta_init(pp, phy_addr);
        if (err < 0) {
                dev_err(&pdev->dev, "can't init eth hal\n");
-               goto err_clk;
+               goto err_unmap;
        }
        mvneta_port_power_up(pp, phy_mode);
 
@@ -2806,10 +2842,10 @@ static int mvneta_probe(struct platform_device *pdev)
 
 err_deinit:
        mvneta_deinit(pp);
-err_clk:
-       clk_disable_unprepare(pp->clk);
 err_unmap:
        iounmap(pp->base);
+err_clk:
+       clk_disable_unprepare(pp->clk);
 err_free_irq:
        irq_dispose_mapping(dev->irq);
 err_free_netdev:
index c896079728e1312893fdf03f0b0e111f2a6676cc..ef94a591f9e550ed31d654c2cc1fa2ba7bc1bef9 100644 (file)
@@ -931,17 +931,20 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
 }
 
 /* Allocate and setup a new buffer for receiving */
-static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
-                         struct sk_buff *skb, unsigned int bufsize)
+static int skge_rx_setup(struct skge_port *skge, struct skge_element *e,
+                        struct sk_buff *skb, unsigned int bufsize)
 {
        struct skge_rx_desc *rd = e->desc;
-       u64 map;
+       dma_addr_t map;
 
        map = pci_map_single(skge->hw->pdev, skb->data, bufsize,
                             PCI_DMA_FROMDEVICE);
 
-       rd->dma_lo = map;
-       rd->dma_hi = map >> 32;
+       if (pci_dma_mapping_error(skge->hw->pdev, map))
+               return -1;
+
+       rd->dma_lo = lower_32_bits(map);
+       rd->dma_hi = upper_32_bits(map);
        e->skb = skb;
        rd->csum1_start = ETH_HLEN;
        rd->csum2_start = ETH_HLEN;
@@ -953,6 +956,7 @@ static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
        rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize;
        dma_unmap_addr_set(e, mapaddr, map);
        dma_unmap_len_set(e, maplen, bufsize);
+       return 0;
 }
 
 /* Resume receiving using existing skb,
@@ -1014,7 +1018,10 @@ static int skge_rx_fill(struct net_device *dev)
                        return -ENOMEM;
 
                skb_reserve(skb, NET_IP_ALIGN);
-               skge_rx_setup(skge, e, skb, skge->rx_buf_size);
+               if (skge_rx_setup(skge, e, skb, skge->rx_buf_size) < 0) {
+                       dev_kfree_skb(skb);
+                       return -EIO;
+               }
        } while ((e = e->next) != ring->start);
 
        ring->to_clean = ring->start;
@@ -2544,7 +2551,7 @@ static int skge_up(struct net_device *dev)
 
        BUG_ON(skge->dma & 7);
 
-       if ((u64)skge->dma >> 32 != ((u64) skge->dma + skge->mem_size) >> 32) {
+       if (upper_32_bits(skge->dma) != upper_32_bits(skge->dma + skge->mem_size)) {
                dev_err(&hw->pdev->dev, "pci_alloc_consistent region crosses 4G boundary\n");
                err = -EINVAL;
                goto free_pci_mem;
@@ -2729,7 +2736,7 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
        struct skge_tx_desc *td;
        int i;
        u32 control, len;
-       u64 map;
+       dma_addr_t map;
 
        if (skb_padto(skb, ETH_ZLEN))
                return NETDEV_TX_OK;
@@ -2743,11 +2750,14 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
        e->skb = skb;
        len = skb_headlen(skb);
        map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
+       if (pci_dma_mapping_error(hw->pdev, map))
+               goto mapping_error;
+
        dma_unmap_addr_set(e, mapaddr, map);
        dma_unmap_len_set(e, maplen, len);
 
-       td->dma_lo = map;
-       td->dma_hi = map >> 32;
+       td->dma_lo = lower_32_bits(map);
+       td->dma_hi = upper_32_bits(map);
 
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                const int offset = skb_checksum_start_offset(skb);
@@ -2778,14 +2788,16 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
 
                        map = skb_frag_dma_map(&hw->pdev->dev, frag, 0,
                                               skb_frag_size(frag), DMA_TO_DEVICE);
+                       if (dma_mapping_error(&hw->pdev->dev, map))
+                               goto mapping_unwind;
 
                        e = e->next;
                        e->skb = skb;
                        tf = e->desc;
                        BUG_ON(tf->control & BMU_OWN);
 
-                       tf->dma_lo = map;
-                       tf->dma_hi = (u64) map >> 32;
+                       tf->dma_lo = lower_32_bits(map);
+                       tf->dma_hi = upper_32_bits(map);
                        dma_unmap_addr_set(e, mapaddr, map);
                        dma_unmap_len_set(e, maplen, skb_frag_size(frag));
 
@@ -2815,6 +2827,26 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
        }
 
        return NETDEV_TX_OK;
+
+mapping_unwind:
+       e = skge->tx_ring.to_use;
+       pci_unmap_single(hw->pdev,
+                        dma_unmap_addr(e, mapaddr),
+                        dma_unmap_len(e, maplen),
+                        PCI_DMA_TODEVICE);
+       while (i-- > 0) {
+               e = e->next;
+               pci_unmap_page(hw->pdev,
+                              dma_unmap_addr(e, mapaddr),
+                              dma_unmap_len(e, maplen),
+                              PCI_DMA_TODEVICE);
+       }
+
+mapping_error:
+       if (net_ratelimit())
+               dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name);
+       dev_kfree_skb(skb);
+       return NETDEV_TX_OK;
 }
 
 
@@ -3045,11 +3077,13 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
 
                pci_dma_sync_single_for_cpu(skge->hw->pdev,
                                            dma_unmap_addr(e, mapaddr),
-                                           len, PCI_DMA_FROMDEVICE);
+                                           dma_unmap_len(e, maplen),
+                                           PCI_DMA_FROMDEVICE);
                skb_copy_from_linear_data(e->skb, skb->data, len);
                pci_dma_sync_single_for_device(skge->hw->pdev,
                                               dma_unmap_addr(e, mapaddr),
-                                              len, PCI_DMA_FROMDEVICE);
+                                              dma_unmap_len(e, maplen),
+                                              PCI_DMA_FROMDEVICE);
                skge_rx_reuse(e, skge->rx_buf_size);
        } else {
                struct sk_buff *nskb;
@@ -3058,13 +3092,17 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
                if (!nskb)
                        goto resubmit;
 
+               if (skge_rx_setup(skge, e, nskb, skge->rx_buf_size) < 0) {
+                       dev_kfree_skb(nskb);
+                       goto resubmit;
+               }
+
                pci_unmap_single(skge->hw->pdev,
                                 dma_unmap_addr(e, mapaddr),
                                 dma_unmap_len(e, maplen),
                                 PCI_DMA_FROMDEVICE);
                skb = e->skb;
                prefetch(skb->data);
-               skge_rx_setup(skge, e, nskb, skge->rx_buf_size);
        }
 
        skb_put(skb, len);
index 299d0184f983c95c1b68d043b1f5d28f0fe329f8..ea20182c6969245e53a3a9da563c76461555f7f5 100644 (file)
@@ -800,7 +800,16 @@ static int mlx4_MAD_IFC_wrapper(struct mlx4_dev *dev, int slave,
                                    vhcr->op, MLX4_CMD_TIME_CLASS_C, MLX4_CMD_NATIVE);
 }
 
-int MLX4_CMD_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave,
+static int MLX4_CMD_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave,
+                    struct mlx4_vhcr *vhcr,
+                    struct mlx4_cmd_mailbox *inbox,
+                    struct mlx4_cmd_mailbox *outbox,
+                    struct mlx4_cmd_info *cmd)
+{
+       return -EPERM;
+}
+
+static int MLX4_CMD_GET_OP_REQ_wrapper(struct mlx4_dev *dev, int slave,
                     struct mlx4_vhcr *vhcr,
                     struct mlx4_cmd_mailbox *inbox,
                     struct mlx4_cmd_mailbox *outbox,
@@ -1251,6 +1260,15 @@ static struct mlx4_cmd_info cmd_info[] = {
                .verify = NULL,
                .wrapper = MLX4_CMD_UPDATE_QP_wrapper
        },
+       {
+               .opcode = MLX4_CMD_GET_OP_REQ,
+               .has_inbox = false,
+               .has_outbox = false,
+               .out_is_imm = false,
+               .encode_slave_id = false,
+               .verify = NULL,
+               .wrapper = MLX4_CMD_GET_OP_REQ_wrapper,
+       },
        {
                .opcode = MLX4_CMD_CONF_SPECIAL_QP,
                .has_inbox = false,
@@ -1526,7 +1544,7 @@ static int calculate_transition(u16 oper_vlan, u16 admin_vlan)
        return (2 * (oper_vlan == MLX4_VGT) + (admin_vlan == MLX4_VGT));
 }
 
-int mlx4_master_immediate_activate_vlan_qos(struct mlx4_priv *priv,
+static int mlx4_master_immediate_activate_vlan_qos(struct mlx4_priv *priv,
                                            int slave, int port)
 {
        struct mlx4_vport_oper_state *vp_oper;
index 9d4a1ea030d84a95055afbc07a08dd131d885f8d..b4881b6861590c16c55644fd2752abfcf569ad8e 100644 (file)
@@ -160,6 +160,7 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
                struct ieee_pfc *pfc)
 {
        struct mlx4_en_priv *priv = netdev_priv(dev);
+       struct mlx4_en_port_profile *prof = priv->prof;
        struct mlx4_en_dev *mdev = priv->mdev;
        int err;
 
@@ -169,15 +170,17 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
                        pfc->mbc,
                        pfc->delay);
 
-       priv->prof->rx_pause = priv->prof->tx_pause = !!pfc->pfc_en;
-       priv->prof->rx_ppp = priv->prof->tx_ppp = pfc->pfc_en;
+       prof->rx_pause = !pfc->pfc_en;
+       prof->tx_pause = !pfc->pfc_en;
+       prof->rx_ppp = pfc->pfc_en;
+       prof->tx_ppp = pfc->pfc_en;
 
        err = mlx4_SET_PORT_general(mdev->dev, priv->port,
                                    priv->rx_skb_size + ETH_FCS_LEN,
-                                   priv->prof->tx_pause,
-                                   priv->prof->tx_ppp,
-                                   priv->prof->rx_pause,
-                                   priv->prof->rx_ppp);
+                                   prof->tx_pause,
+                                   prof->tx_ppp,
+                                   prof->rx_pause,
+                                   prof->rx_ppp);
        if (err)
                en_err(priv, "Failed setting pause params\n");
 
index 727874f575cedc80e65d52d4918007151feb3c09..a28cd801a236e5a674de67009a5b872ed29e9e71 100644 (file)
@@ -223,7 +223,7 @@ static int mlx4_en_get_sset_count(struct net_device *dev, int sset)
        case ETH_SS_STATS:
                return (priv->stats_bitmap ? bit_count : NUM_ALL_STATS) +
                        (priv->tx_ring_num * 2) +
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
                        (priv->rx_ring_num * 5);
 #else
                        (priv->rx_ring_num * 2);
@@ -276,7 +276,7 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
        for (i = 0; i < priv->rx_ring_num; i++) {
                data[index++] = priv->rx_ring[i].packets;
                data[index++] = priv->rx_ring[i].bytes;
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
                data[index++] = priv->rx_ring[i].yields;
                data[index++] = priv->rx_ring[i].misses;
                data[index++] = priv->rx_ring[i].cleaned;
@@ -344,7 +344,7 @@ static void mlx4_en_get_strings(struct net_device *dev,
                                "rx%d_packets", i);
                        sprintf(data + (index++) * ETH_GSTRING_LEN,
                                "rx%d_bytes", i);
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
                        sprintf(data + (index++) * ETH_GSTRING_LEN,
                                "rx%d_napi_yield", i);
                        sprintf(data + (index++) * ETH_GSTRING_LEN,
index 5eac871399d8ecedf4fcffff06ed4372753df77f..fa37b7a612133c739263346a5d6f372af0fd9dda 100644 (file)
@@ -68,7 +68,7 @@ int mlx4_en_setup_tc(struct net_device *dev, u8 up)
        return 0;
 }
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 /* must be called with local_bh_disable()d */
 static int mlx4_en_low_latency_recv(struct napi_struct *napi)
 {
@@ -94,7 +94,7 @@ static int mlx4_en_low_latency_recv(struct napi_struct *napi)
 
        return done;
 }
-#endif /* CONFIG_NET_LL_RX_POLL */
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 
 #ifdef CONFIG_RFS_ACCEL
 
@@ -2140,7 +2140,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
 #ifdef CONFIG_RFS_ACCEL
        .ndo_rx_flow_steer      = mlx4_en_filter_rfs,
 #endif
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        .ndo_busy_poll          = mlx4_en_low_latency_recv,
 #endif
 };
index 7c492382da09937764e8c6bb9a835d1c05771021..0698c82d6ff1bf94598b4ed577b446289c4178be 100644 (file)
@@ -191,6 +191,39 @@ void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv,
                       MLX4_QP_STATE_RST, NULL, 0, 0, &ring->qp);
 }
 
+static void mlx4_en_stamp_wqe(struct mlx4_en_priv *priv,
+                             struct mlx4_en_tx_ring *ring, int index,
+                             u8 owner)
+{
+       __be32 stamp = cpu_to_be32(STAMP_VAL | (!!owner << STAMP_SHIFT));
+       struct mlx4_en_tx_desc *tx_desc = ring->buf + index * TXBB_SIZE;
+       struct mlx4_en_tx_info *tx_info = &ring->tx_info[index];
+       void *end = ring->buf + ring->buf_size;
+       __be32 *ptr = (__be32 *)tx_desc;
+       int i;
+
+       /* Optimize the common case when there are no wraparounds */
+       if (likely((void *)tx_desc + tx_info->nr_txbb * TXBB_SIZE <= end)) {
+               /* Stamp the freed descriptor */
+               for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE;
+                    i += STAMP_STRIDE) {
+                       *ptr = stamp;
+                       ptr += STAMP_DWORDS;
+               }
+       } else {
+               /* Stamp the freed descriptor */
+               for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE;
+                    i += STAMP_STRIDE) {
+                       *ptr = stamp;
+                       ptr += STAMP_DWORDS;
+                       if ((void *)ptr >= end) {
+                               ptr = ring->buf;
+                               stamp ^= cpu_to_be32(0x80000000);
+                       }
+               }
+       }
+}
+
 
 static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
                                struct mlx4_en_tx_ring *ring,
@@ -205,8 +238,6 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
        void *end = ring->buf + ring->buf_size;
        int frags = skb_shinfo(skb)->nr_frags;
        int i;
-       __be32 *ptr = (__be32 *)tx_desc;
-       __be32 stamp = cpu_to_be32(STAMP_VAL | (!!owner << STAMP_SHIFT));
        struct skb_shared_hwtstamps hwts;
 
        if (timestamp) {
@@ -232,12 +263,6 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
                                        skb_frag_size(frag), PCI_DMA_TODEVICE);
                        }
                }
-               /* Stamp the freed descriptor */
-               for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) {
-                       *ptr = stamp;
-                       ptr += STAMP_DWORDS;
-               }
-
        } else {
                if (!tx_info->inl) {
                        if ((void *) data >= end) {
@@ -263,16 +288,6 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
                                ++data;
                        }
                }
-               /* Stamp the freed descriptor */
-               for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) {
-                       *ptr = stamp;
-                       ptr += STAMP_DWORDS;
-                       if ((void *) ptr >= end) {
-                               ptr = ring->buf;
-                               stamp ^= cpu_to_be32(0x80000000);
-                       }
-               }
-
        }
        dev_kfree_skb_any(skb);
        return tx_info->nr_txbb;
@@ -318,8 +333,9 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
        struct mlx4_en_tx_ring *ring = &priv->tx_ring[cq->ring];
        struct mlx4_cqe *cqe;
        u16 index;
-       u16 new_index, ring_index;
+       u16 new_index, ring_index, stamp_index;
        u32 txbbs_skipped = 0;
+       u32 txbbs_stamp = 0;
        u32 cons_index = mcq->cons_index;
        int size = cq->size;
        u32 size_mask = ring->size_mask;
@@ -335,6 +351,7 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
        index = cons_index & size_mask;
        cqe = &buf[(index << factor) + factor];
        ring_index = ring->cons & size_mask;
+       stamp_index = ring_index;
 
        /* Process all completed CQEs */
        while (XNOR(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK,
@@ -345,6 +362,15 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
                 */
                rmb();
 
+               if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
+                            MLX4_CQE_OPCODE_ERROR)) {
+                       struct mlx4_err_cqe *cqe_err = (struct mlx4_err_cqe *)cqe;
+
+                       en_err(priv, "CQE error - vendor syndrome: 0x%x syndrome: 0x%x\n",
+                              cqe_err->vendor_err_syndrome,
+                              cqe_err->syndrome);
+               }
+
                /* Skip over last polled CQE */
                new_index = be16_to_cpu(cqe->wqe_index) & size_mask;
 
@@ -359,6 +385,12 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq)
                                        priv, ring, ring_index,
                                        !!((ring->cons + txbbs_skipped) &
                                        ring->size), timestamp);
+
+                       mlx4_en_stamp_wqe(priv, ring, stamp_index,
+                                         !!((ring->cons + txbbs_stamp) &
+                                               ring->size));
+                       stamp_index = ring_index;
+                       txbbs_stamp = txbbs_skipped;
                        packets++;
                        bytes += ring->tx_info[ring_index].nr_bytes;
                } while (ring_index != new_index);
@@ -556,17 +588,15 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct mlx4_en_priv *priv = netdev_priv(dev);
        struct mlx4_en_dev *mdev = priv->mdev;
+       struct device *ddev = priv->ddev;
        struct mlx4_en_tx_ring *ring;
        struct mlx4_en_tx_desc *tx_desc;
        struct mlx4_wqe_data_seg *data;
-       struct skb_frag_struct *frag;
        struct mlx4_en_tx_info *tx_info;
-       struct ethhdr *ethh;
        int tx_ind = 0;
        int nr_txbb;
        int desc_size;
        int real_size;
-       dma_addr_t dma;
        u32 index, bf_index;
        __be32 op_own;
        u16 vlan_tag = 0;
@@ -642,6 +672,61 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
        tx_info->skb = skb;
        tx_info->nr_txbb = nr_txbb;
 
+       if (lso_header_size)
+               data = ((void *)&tx_desc->lso + ALIGN(lso_header_size + 4,
+                                                     DS_SIZE));
+       else
+               data = &tx_desc->data;
+
+       /* valid only for none inline segments */
+       tx_info->data_offset = (void *)data - (void *)tx_desc;
+
+       tx_info->linear = (lso_header_size < skb_headlen(skb) &&
+                          !is_inline(skb, NULL)) ? 1 : 0;
+
+       data += skb_shinfo(skb)->nr_frags + tx_info->linear - 1;
+
+       if (is_inline(skb, &fragptr)) {
+               tx_info->inl = 1;
+       } else {
+               /* Map fragments */
+               for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) {
+                       struct skb_frag_struct *frag;
+                       dma_addr_t dma;
+
+                       frag = &skb_shinfo(skb)->frags[i];
+                       dma = skb_frag_dma_map(ddev, frag,
+                                              0, skb_frag_size(frag),
+                                              DMA_TO_DEVICE);
+                       if (dma_mapping_error(ddev, dma))
+                               goto tx_drop_unmap;
+
+                       data->addr = cpu_to_be64(dma);
+                       data->lkey = cpu_to_be32(mdev->mr.key);
+                       wmb();
+                       data->byte_count = cpu_to_be32(skb_frag_size(frag));
+                       --data;
+               }
+
+               /* Map linear part */
+               if (tx_info->linear) {
+                       u32 byte_count = skb_headlen(skb) - lso_header_size;
+                       dma_addr_t dma;
+
+                       dma = dma_map_single(ddev, skb->data +
+                                            lso_header_size, byte_count,
+                                            PCI_DMA_TODEVICE);
+                       if (dma_mapping_error(ddev, dma))
+                               goto tx_drop_unmap;
+
+                       data->addr = cpu_to_be64(dma);
+                       data->lkey = cpu_to_be32(mdev->mr.key);
+                       wmb();
+                       data->byte_count = cpu_to_be32(byte_count);
+               }
+               tx_info->inl = 0;
+       }
+
        /*
         * For timestamping add flag to skb_shinfo and
         * set flag for further reference
@@ -666,6 +751,8 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        if (priv->flags & MLX4_EN_FLAG_ENABLE_HW_LOOPBACK) {
+               struct ethhdr *ethh;
+
                /* Copy dst mac address to wqe. This allows loopback in eSwitch,
                 * so that VFs and PF can communicate with each other
                 */
@@ -688,8 +775,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
                /* Copy headers;
                 * note that we already verified that it is linear */
                memcpy(tx_desc->lso.header, skb->data, lso_header_size);
-               data = ((void *) &tx_desc->lso +
-                       ALIGN(lso_header_size + 4, DS_SIZE));
 
                priv->port_stats.tso_packets++;
                i = ((skb->len - lso_header_size) / skb_shinfo(skb)->gso_size) +
@@ -701,7 +786,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
                op_own = cpu_to_be32(MLX4_OPCODE_SEND) |
                        ((ring->prod & ring->size) ?
                         cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0);
-               data = &tx_desc->data;
                tx_info->nr_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
                ring->packets++;
 
@@ -710,38 +794,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
        netdev_tx_sent_queue(ring->tx_queue, tx_info->nr_bytes);
        AVG_PERF_COUNTER(priv->pstats.tx_pktsz_avg, skb->len);
 
-
-       /* valid only for none inline segments */
-       tx_info->data_offset = (void *) data - (void *) tx_desc;
-
-       tx_info->linear = (lso_header_size < skb_headlen(skb) && !is_inline(skb, NULL)) ? 1 : 0;
-       data += skb_shinfo(skb)->nr_frags + tx_info->linear - 1;
-
-       if (!is_inline(skb, &fragptr)) {
-               /* Map fragments */
-               for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) {
-                       frag = &skb_shinfo(skb)->frags[i];
-                       dma = skb_frag_dma_map(priv->ddev, frag,
-                                              0, skb_frag_size(frag),
-                                              DMA_TO_DEVICE);
-                       data->addr = cpu_to_be64(dma);
-                       data->lkey = cpu_to_be32(mdev->mr.key);
-                       wmb();
-                       data->byte_count = cpu_to_be32(skb_frag_size(frag));
-                       --data;
-               }
-
-               /* Map linear part */
-               if (tx_info->linear) {
-                       dma = dma_map_single(priv->ddev, skb->data + lso_header_size,
-                                            skb_headlen(skb) - lso_header_size, PCI_DMA_TODEVICE);
-                       data->addr = cpu_to_be64(dma);
-                       data->lkey = cpu_to_be32(mdev->mr.key);
-                       wmb();
-                       data->byte_count = cpu_to_be32(skb_headlen(skb) - lso_header_size);
-               }
-               tx_info->inl = 0;
-       } else {
+       if (tx_info->inl) {
                build_inline_wqe(tx_desc, skb, real_size, &vlan_tag, tx_ind, fragptr);
                tx_info->inl = 1;
        }
@@ -781,6 +834,16 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 
        return NETDEV_TX_OK;
 
+tx_drop_unmap:
+       en_err(priv, "DMA mapping error\n");
+
+       for (i++; i < skb_shinfo(skb)->nr_frags; i++) {
+               data++;
+               dma_unmap_page(ddev, (dma_addr_t) be64_to_cpu(data->addr),
+                              be32_to_cpu(data->byte_count),
+                              PCI_DMA_TODEVICE);
+       }
+
 tx_drop:
        dev_kfree_skb_any(skb);
        priv->stats.tx_dropped++;
index 7e042869ef0cd2d9c5884147edd7b1c7d582b868..0416c5b3b35cc721c9e312e6b7b2ca0c0917cbf7 100644 (file)
@@ -79,6 +79,7 @@ enum {
                               (1ull << MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE)    | \
                               (1ull << MLX4_EVENT_TYPE_SRQ_LIMIT)          | \
                               (1ull << MLX4_EVENT_TYPE_CMD)                | \
+                              (1ull << MLX4_EVENT_TYPE_OP_REQUIRED)        | \
                               (1ull << MLX4_EVENT_TYPE_COMM_CHANNEL)       | \
                               (1ull << MLX4_EVENT_TYPE_FLR_EVENT)          | \
                               (1ull << MLX4_EVENT_TYPE_FATAL_WARNING))
@@ -629,6 +630,14 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
                        mlx4_warn(dev, "EQ overrun on EQN %d\n", eq->eqn);
                        break;
 
+               case MLX4_EVENT_TYPE_OP_REQUIRED:
+                       atomic_inc(&priv->opreq_count);
+                       /* FW commands can't be executed from interrupt context
+                        * working in deferred task
+                        */
+                       queue_work(mlx4_wq, &priv->opreq_task);
+                       break;
+
                case MLX4_EVENT_TYPE_COMM_CHANNEL:
                        if (!mlx4_is_master(dev)) {
                                mlx4_warn(dev, "Received comm channel event "
index 8873d6802c80dd8c5359f7c1e19834236f2c9ae6..0d63daa2f422e082d85fd627a892c9fb5f5c1945 100644 (file)
@@ -845,16 +845,7 @@ int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
                           MLX4_CMD_NATIVE);
 
        if (!err && dev->caps.function != slave) {
-               /* if config MAC in DB use it */
-               if (priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac)
-                       def_mac = priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac;
-               else {
-                       /* set slave default_mac address */
-                       MLX4_GET(def_mac, outbox->buf, QUERY_PORT_MAC_OFFSET);
-                       def_mac += slave << 8;
-                       priv->mfunc.master.vf_admin[slave].vport[vhcr->in_modifier].mac = def_mac;
-               }
-
+               def_mac = priv->mfunc.master.vf_oper[slave].vport[vhcr->in_modifier].state.mac;
                MLX4_PUT(outbox->buf, def_mac, QUERY_PORT_MAC_OFFSET);
 
                /* get port type - currently only eth is enabled */
@@ -1705,3 +1696,107 @@ int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port)
                        MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
 }
 EXPORT_SYMBOL_GPL(mlx4_wol_write);
+
+enum {
+       ADD_TO_MCG = 0x26,
+};
+
+
+void mlx4_opreq_action(struct work_struct *work)
+{
+       struct mlx4_priv *priv = container_of(work, struct mlx4_priv,
+                                             opreq_task);
+       struct mlx4_dev *dev = &priv->dev;
+       int num_tasks = atomic_read(&priv->opreq_count);
+       struct mlx4_cmd_mailbox *mailbox;
+       struct mlx4_mgm *mgm;
+       u32 *outbox;
+       u32 modifier;
+       u16 token;
+       u16 type_m;
+       u16 type;
+       int err;
+       u32 num_qps;
+       struct mlx4_qp qp;
+       int i;
+       u8 rem_mcg;
+       u8 prot;
+
+#define GET_OP_REQ_MODIFIER_OFFSET     0x08
+#define GET_OP_REQ_TOKEN_OFFSET                0x14
+#define GET_OP_REQ_TYPE_OFFSET         0x1a
+#define GET_OP_REQ_DATA_OFFSET         0x20
+
+       mailbox = mlx4_alloc_cmd_mailbox(dev);
+       if (IS_ERR(mailbox)) {
+               mlx4_err(dev, "Failed to allocate mailbox for GET_OP_REQ\n");
+               return;
+       }
+       outbox = mailbox->buf;
+
+       while (num_tasks) {
+               err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 0,
+                                  MLX4_CMD_GET_OP_REQ, MLX4_CMD_TIME_CLASS_A,
+                                  MLX4_CMD_NATIVE);
+               if (err) {
+                       mlx4_err(dev, "Failed to retreive required operation: %d\n",
+                                err);
+                       return;
+               }
+               MLX4_GET(modifier, outbox, GET_OP_REQ_MODIFIER_OFFSET);
+               MLX4_GET(token, outbox, GET_OP_REQ_TOKEN_OFFSET);
+               MLX4_GET(type, outbox, GET_OP_REQ_TYPE_OFFSET);
+               type_m = type >> 12;
+               type &= 0xfff;
+
+               switch (type) {
+               case ADD_TO_MCG:
+                       if (dev->caps.steering_mode ==
+                           MLX4_STEERING_MODE_DEVICE_MANAGED) {
+                               mlx4_warn(dev, "ADD MCG operation is not supported in DEVICE_MANAGED steering mode\n");
+                               err = EPERM;
+                               break;
+                       }
+                       mgm = (struct mlx4_mgm *)((u8 *)(outbox) +
+                                                 GET_OP_REQ_DATA_OFFSET);
+                       num_qps = be32_to_cpu(mgm->members_count) &
+                                 MGM_QPN_MASK;
+                       rem_mcg = ((u8 *)(&mgm->members_count))[0] & 1;
+                       prot = ((u8 *)(&mgm->members_count))[0] >> 6;
+
+                       for (i = 0; i < num_qps; i++) {
+                               qp.qpn = be32_to_cpu(mgm->qp[i]);
+                               if (rem_mcg)
+                                       err = mlx4_multicast_detach(dev, &qp,
+                                                                   mgm->gid,
+                                                                   prot, 0);
+                               else
+                                       err = mlx4_multicast_attach(dev, &qp,
+                                                                   mgm->gid,
+                                                                   mgm->gid[5]
+                                                                   , 0, prot,
+                                                                   NULL);
+                               if (err)
+                                       break;
+                       }
+                       break;
+               default:
+                       mlx4_warn(dev, "Bad type for required operation\n");
+                       err = EINVAL;
+                       break;
+               }
+               err = mlx4_cmd(dev, 0, ((u32) err | cpu_to_be32(token) << 16),
+                              1, MLX4_CMD_GET_OP_REQ, MLX4_CMD_TIME_CLASS_A,
+                              MLX4_CMD_NATIVE);
+               if (err) {
+                       mlx4_err(dev, "Failed to acknowledge required request: %d\n",
+                                err);
+                       goto out;
+               }
+               memset(outbox, 0, 0xffc);
+               num_tasks = atomic_dec_return(&priv->opreq_count);
+       }
+
+out:
+       mlx4_free_cmd_mailbox(dev, mailbox);
+}
index fdf41665a05931d3574a2dd7f3d53467d0e4d3f6..a0a368b7c93996724f49f8c5ece01ff3d5a86bc3 100644 (file)
@@ -220,5 +220,6 @@ int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm);
 int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev);
 int mlx4_NOP(struct mlx4_dev *dev);
 int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg);
+void mlx4_opreq_action(struct work_struct *work);
 
 #endif /* MLX4_FW_H */
index e85af922dcdcc237ea5e7c7f227088fe77e90802..60c9f4f103fce1a2c7d815ccc303b7b94805068c 100644 (file)
@@ -371,7 +371,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 
        dev->caps.sqp_demux = (mlx4_is_master(dev)) ? MLX4_MAX_NUM_SLAVES : 0;
 
-       if (!enable_64b_cqe_eqe) {
+       if (!enable_64b_cqe_eqe && !mlx4_is_slave(dev)) {
                if (dev_cap->flags &
                    (MLX4_DEV_CAP_FLAG_64B_CQE | MLX4_DEV_CAP_FLAG_64B_EQE)) {
                        mlx4_warn(dev, "64B EQEs/CQEs supported by the device but not enabled\n");
@@ -1692,11 +1692,19 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
                goto err_xrcd_table_free;
        }
 
+       if (!mlx4_is_slave(dev)) {
+               err = mlx4_init_mcg_table(dev);
+               if (err) {
+                       mlx4_err(dev, "Failed to initialize multicast group table, aborting.\n");
+                       goto err_mr_table_free;
+               }
+       }
+
        err = mlx4_init_eq_table(dev);
        if (err) {
                mlx4_err(dev, "Failed to initialize "
                         "event queue table, aborting.\n");
-               goto err_mr_table_free;
+               goto err_mcg_table_free;
        }
 
        err = mlx4_cmd_use_events(dev);
@@ -1746,19 +1754,10 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
                goto err_srq_table_free;
        }
 
-       if (!mlx4_is_slave(dev)) {
-               err = mlx4_init_mcg_table(dev);
-               if (err) {
-                       mlx4_err(dev, "Failed to initialize "
-                                "multicast group table, aborting.\n");
-                       goto err_qp_table_free;
-               }
-       }
-
        err = mlx4_init_counters_table(dev);
        if (err && err != -ENOENT) {
                mlx4_err(dev, "Failed to initialize counters table, aborting.\n");
-               goto err_mcg_table_free;
+               goto err_qp_table_free;
        }
 
        if (!mlx4_is_slave(dev)) {
@@ -1803,9 +1802,6 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
 err_counters_table_free:
        mlx4_cleanup_counters_table(dev);
 
-err_mcg_table_free:
-       mlx4_cleanup_mcg_table(dev);
-
 err_qp_table_free:
        mlx4_cleanup_qp_table(dev);
 
@@ -1821,6 +1817,10 @@ err_cmd_poll:
 err_eq_table_free:
        mlx4_cleanup_eq_table(dev);
 
+err_mcg_table_free:
+       if (!mlx4_is_slave(dev))
+               mlx4_cleanup_mcg_table(dev);
+
 err_mr_table_free:
        mlx4_cleanup_mr_table(dev);
 
@@ -2197,6 +2197,9 @@ static int __mlx4_init_one(struct pci_dev *pdev, int pci_dev_data)
                        }
                }
 
+               atomic_set(&priv->opreq_count, 0);
+               INIT_WORK(&priv->opreq_task, mlx4_opreq_action);
+
                /*
                 * Now reset the HCA before we touch the PCI capabilities or
                 * attempt a firmware command, since a boot ROM may have left
@@ -2315,12 +2318,12 @@ err_port:
                mlx4_cleanup_port_info(&priv->port[port]);
 
        mlx4_cleanup_counters_table(dev);
-       mlx4_cleanup_mcg_table(dev);
        mlx4_cleanup_qp_table(dev);
        mlx4_cleanup_srq_table(dev);
        mlx4_cleanup_cq_table(dev);
        mlx4_cmd_use_polling(dev);
        mlx4_cleanup_eq_table(dev);
+       mlx4_cleanup_mcg_table(dev);
        mlx4_cleanup_mr_table(dev);
        mlx4_cleanup_xrcd_table(dev);
        mlx4_cleanup_pd_table(dev);
@@ -2403,12 +2406,12 @@ static void mlx4_remove_one(struct pci_dev *pdev)
                                                   RES_TR_FREE_SLAVES_ONLY);
 
                mlx4_cleanup_counters_table(dev);
-               mlx4_cleanup_mcg_table(dev);
                mlx4_cleanup_qp_table(dev);
                mlx4_cleanup_srq_table(dev);
                mlx4_cleanup_cq_table(dev);
                mlx4_cmd_use_polling(dev);
                mlx4_cleanup_eq_table(dev);
+               mlx4_cleanup_mcg_table(dev);
                mlx4_cleanup_mr_table(dev);
                mlx4_cleanup_xrcd_table(dev);
                mlx4_cleanup_pd_table(dev);
index f3e804f2a35f0bd2a9be0e32b7b577bed5518cfa..55f6245efb6cd250f2efda4e6941bdb81b1fd9f3 100644 (file)
 
 #include "mlx4.h"
 
-#define MGM_QPN_MASK       0x00FFFFFF
-#define MGM_BLCK_LB_BIT    30
-
 static const u8 zero_gid[16];  /* automatically initialized to 0 */
 
-struct mlx4_mgm {
-       __be32                  next_gid_index;
-       __be32                  members_count;
-       u32                     reserved[2];
-       u8                      gid[16];
-       __be32                  qp[MLX4_MAX_QP_PER_MGM];
-};
-
 int mlx4_get_mgm_entry_size(struct mlx4_dev *dev)
 {
        return 1 << dev->oper_log_mgm_entry_size;
index 17d9277e33ef978f89828a83e44642986383e06a..348bb8c7d9a70bc58d1c51c4e7aca6ec495dcb8f 100644 (file)
@@ -554,6 +554,17 @@ struct mlx4_mfunc {
        struct mlx4_mfunc_master_ctx    master;
 };
 
+#define MGM_QPN_MASK       0x00FFFFFF
+#define MGM_BLCK_LB_BIT    30
+
+struct mlx4_mgm {
+       __be32                  next_gid_index;
+       __be32                  members_count;
+       u32                     reserved[2];
+       u8                      gid[16];
+       __be32                  qp[MLX4_MAX_QP_PER_MGM];
+};
+
 struct mlx4_cmd {
        struct pci_pool        *pool;
        void __iomem           *hcr;
@@ -802,6 +813,8 @@ struct mlx4_priv {
        u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
        __be64                  slave_node_guids[MLX4_MFUNC_MAX];
 
+       atomic_t                opreq_count;
+       struct work_struct      opreq_task;
 };
 
 static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
index 35fb60e2320c2a896e8b241c2c9dbbe575a2dd02..5e0aa569306aab2f6c8185cd1574cdd4abeb4aab 100644 (file)
@@ -292,7 +292,7 @@ struct mlx4_en_rx_ring {
        void *rx_info;
        unsigned long bytes;
        unsigned long packets;
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        unsigned long yields;
        unsigned long misses;
        unsigned long cleaned;
@@ -318,7 +318,7 @@ struct mlx4_en_cq {
        struct mlx4_cqe *buf;
 #define MLX4_EN_OPCODE_ERROR   0x1e
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        unsigned int state;
 #define MLX4_EN_CQ_STATE_IDLE        0
 #define MLX4_EN_CQ_STATE_NAPI     1    /* NAPI owns this CQ */
@@ -329,7 +329,7 @@ struct mlx4_en_cq {
 #define CQ_YIELD (MLX4_EN_CQ_STATE_NAPI_YIELD | MLX4_EN_CQ_STATE_POLL_YIELD)
 #define CQ_USER_PEND (MLX4_EN_CQ_STATE_POLL | MLX4_EN_CQ_STATE_POLL_YIELD)
        spinlock_t poll_lock; /* protects from LLS/napi conflicts */
-#endif  /* CONFIG_NET_LL_RX_POLL */
+#endif  /* CONFIG_NET_RX_BUSY_POLL */
 };
 
 struct mlx4_en_port_profile {
@@ -580,7 +580,7 @@ struct mlx4_mac_entry {
        struct rcu_head rcu;
 };
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 static inline void mlx4_en_cq_init_lock(struct mlx4_en_cq *cq)
 {
        spin_lock_init(&cq->poll_lock);
@@ -687,7 +687,7 @@ static inline bool mlx4_en_cq_ll_polling(struct mlx4_en_cq *cq)
 {
        return false;
 }
-#endif /* CONFIG_NET_LL_RX_POLL */
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 
 #define MLX4_EN_WOL_DO_MODIFY (1ULL << 63)
 
index 205753a04cfcb22e8904dbe2e3e203d82df32552..5472cbd34028d9038539824c4167a0c3010a3a01 100644 (file)
@@ -46,7 +46,7 @@
 #include "mlx5_core.h"
 
 enum {
-       CMD_IF_REV = 3,
+       CMD_IF_REV = 5,
 };
 
 enum {
@@ -282,6 +282,12 @@ const char *mlx5_command_str(int command)
        case MLX5_CMD_OP_TEARDOWN_HCA:
                return "TEARDOWN_HCA";
 
+       case MLX5_CMD_OP_ENABLE_HCA:
+               return "MLX5_CMD_OP_ENABLE_HCA";
+
+       case MLX5_CMD_OP_DISABLE_HCA:
+               return "MLX5_CMD_OP_DISABLE_HCA";
+
        case MLX5_CMD_OP_QUERY_PAGES:
                return "QUERY_PAGES";
 
@@ -1113,7 +1119,13 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, unsigned long vector)
 
        for (i = 0; i < (1 << cmd->log_sz); i++) {
                if (test_bit(i, &vector)) {
+                       struct semaphore *sem;
+
                        ent = cmd->ent_arr[i];
+                       if (ent->page_queue)
+                               sem = &cmd->pages_sem;
+                       else
+                               sem = &cmd->sem;
                        ktime_get_ts(&ent->ts2);
                        memcpy(ent->out->first.data, ent->lay->out, sizeof(ent->lay->out));
                        dump_command(dev, ent, 0);
@@ -1136,10 +1148,7 @@ void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, unsigned long vector)
                        } else {
                                complete(&ent->done);
                        }
-                       if (ent->page_queue)
-                               up(&cmd->pages_sem);
-                       else
-                               up(&cmd->sem);
+                       up(sem);
                }
        }
 }
index 4273c06e2e967be08db5bcc99862b723e667eca7..9c7194b26ee2dbf3aa3dd1b1f19b3de290d13f57 100644 (file)
@@ -156,7 +156,7 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count,
        stats = filp->private_data;
        spin_lock(&stats->lock);
        if (stats->n)
-               field = stats->sum / stats->n;
+               field = div64_u64(stats->sum, stats->n);
        spin_unlock(&stats->lock);
        ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field);
        if (ret > 0) {
index c02cbcfd0fb83a4b10d198888c88f67fc4670cc9..443cc4d7b024c02d2cc77861868e1c1b17ee2524 100644 (file)
@@ -268,7 +268,7 @@ static int mlx5_eq_int(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
                case MLX5_EVENT_TYPE_PAGE_REQUEST:
                        {
                                u16 func_id = be16_to_cpu(eqe->data.req_pages.func_id);
-                               s16 npages = be16_to_cpu(eqe->data.req_pages.num_pages);
+                               s32 npages = be32_to_cpu(eqe->data.req_pages.num_pages);
 
                                mlx5_core_dbg(dev, "page request for func 0x%x, napges %d\n", func_id, npages);
                                mlx5_core_req_pages_handler(dev, func_id, npages);
index 72a5222447f558b3e4a118ccaac70de358af8c64..f012658b6a927baf1fca6a2d39d806346c61a1a6 100644 (file)
@@ -113,7 +113,7 @@ int mlx5_cmd_query_hca_cap(struct mlx5_core_dev *dev,
        caps->log_max_srq = out->hca_cap.log_max_srqs & 0x1f;
        caps->local_ca_ack_delay = out->hca_cap.local_ca_ack_delay & 0x1f;
        caps->log_max_mcg = out->hca_cap.log_max_mcg;
-       caps->max_qp_mcg = be16_to_cpu(out->hca_cap.max_qp_mcg);
+       caps->max_qp_mcg = be32_to_cpu(out->hca_cap.max_qp_mcg) & 0xffffff;
        caps->max_ra_res_qp = 1 << (out->hca_cap.log_max_ra_res_qp & 0x3f);
        caps->max_ra_req_qp = 1 << (out->hca_cap.log_max_ra_req_qp & 0x3f);
        caps->max_srq_wqes = 1 << out->hca_cap.log_max_srq_sz;
index 748f10a155c42e4923850f718df8b2142eeff01b..3e6670c4a7cd215998bf2302f2573acb8540ffb7 100644 (file)
@@ -55,33 +55,9 @@ enum {
 };
 
 static DEFINE_SPINLOCK(health_lock);
-
 static LIST_HEAD(health_list);
 static struct work_struct health_work;
 
-static health_handler_t reg_handler;
-int mlx5_register_health_report_handler(health_handler_t handler)
-{
-       spin_lock_irq(&health_lock);
-       if (reg_handler) {
-               spin_unlock_irq(&health_lock);
-               return -EEXIST;
-       }
-       reg_handler = handler;
-       spin_unlock_irq(&health_lock);
-
-       return 0;
-}
-EXPORT_SYMBOL(mlx5_register_health_report_handler);
-
-void mlx5_unregister_health_report_handler(void)
-{
-       spin_lock_irq(&health_lock);
-       reg_handler = NULL;
-       spin_unlock_irq(&health_lock);
-}
-EXPORT_SYMBOL(mlx5_unregister_health_report_handler);
-
 static void health_care(struct work_struct *work)
 {
        struct mlx5_core_health *health, *n;
@@ -98,11 +74,8 @@ static void health_care(struct work_struct *work)
                priv = container_of(health, struct mlx5_priv, health);
                dev = container_of(priv, struct mlx5_core_dev, priv);
                mlx5_core_warn(dev, "handling bad device here\n");
+               /* nothing yet */
                spin_lock_irq(&health_lock);
-               if (reg_handler)
-                       reg_handler(dev->pdev, health->health,
-                                   sizeof(health->health));
-
                list_del_init(&health->list);
                spin_unlock_irq(&health_lock);
        }
index 12242de2b0e3ec7950a01f966def239e4b1ce74f..b47739b0b5f6dfb34139ad74e02ac10db1d4fbbd 100644 (file)
@@ -249,6 +249,44 @@ static int set_hca_ctrl(struct mlx5_core_dev *dev)
        return err;
 }
 
+static int mlx5_core_enable_hca(struct mlx5_core_dev *dev)
+{
+       int err;
+       struct mlx5_enable_hca_mbox_in in;
+       struct mlx5_enable_hca_mbox_out out;
+
+       memset(&in, 0, sizeof(in));
+       memset(&out, 0, sizeof(out));
+       in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ENABLE_HCA);
+       err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
+       if (err)
+               return err;
+
+       if (out.hdr.status)
+               return mlx5_cmd_status_to_err(&out.hdr);
+
+       return 0;
+}
+
+static int mlx5_core_disable_hca(struct mlx5_core_dev *dev)
+{
+       int err;
+       struct mlx5_disable_hca_mbox_in in;
+       struct mlx5_disable_hca_mbox_out out;
+
+       memset(&in, 0, sizeof(in));
+       memset(&out, 0, sizeof(out));
+       in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DISABLE_HCA);
+       err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
+       if (err)
+               return err;
+
+       if (out.hdr.status)
+               return mlx5_cmd_status_to_err(&out.hdr);
+
+       return 0;
+}
+
 int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev)
 {
        struct mlx5_priv *priv = &dev->priv;
@@ -304,28 +342,41 @@ int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev)
        }
 
        mlx5_pagealloc_init(dev);
+
+       err = mlx5_core_enable_hca(dev);
+       if (err) {
+               dev_err(&pdev->dev, "enable hca failed\n");
+               goto err_pagealloc_cleanup;
+       }
+
+       err = mlx5_satisfy_startup_pages(dev, 1);
+       if (err) {
+               dev_err(&pdev->dev, "failed to allocate boot pages\n");
+               goto err_disable_hca;
+       }
+
        err = set_hca_ctrl(dev);
        if (err) {
                dev_err(&pdev->dev, "set_hca_ctrl failed\n");
-               goto err_pagealloc_cleanup;
+               goto reclaim_boot_pages;
        }
 
        err = handle_hca_cap(dev);
        if (err) {
                dev_err(&pdev->dev, "handle_hca_cap failed\n");
-               goto err_pagealloc_cleanup;
+               goto reclaim_boot_pages;
        }
 
-       err = mlx5_satisfy_startup_pages(dev);
+       err = mlx5_satisfy_startup_pages(dev, 0);
        if (err) {
-               dev_err(&pdev->dev, "failed to allocate startup pages\n");
-               goto err_pagealloc_cleanup;
+               dev_err(&pdev->dev, "failed to allocate init pages\n");
+               goto reclaim_boot_pages;
        }
 
        err = mlx5_pagealloc_start(dev);
        if (err) {
                dev_err(&pdev->dev, "mlx5_pagealloc_start failed\n");
-               goto err_reclaim_pages;
+               goto reclaim_boot_pages;
        }
 
        err = mlx5_cmd_init_hca(dev);
@@ -396,9 +447,12 @@ err_stop_poll:
 err_pagealloc_stop:
        mlx5_pagealloc_stop(dev);
 
-err_reclaim_pages:
+reclaim_boot_pages:
        mlx5_reclaim_startup_pages(dev);
 
+err_disable_hca:
+       mlx5_core_disable_hca(dev);
+
 err_pagealloc_cleanup:
        mlx5_pagealloc_cleanup(dev);
        mlx5_cmd_cleanup(dev);
@@ -434,6 +488,7 @@ void mlx5_dev_cleanup(struct mlx5_core_dev *dev)
        mlx5_cmd_teardown_hca(dev);
        mlx5_pagealloc_stop(dev);
        mlx5_reclaim_startup_pages(dev);
+       mlx5_core_disable_hca(dev);
        mlx5_pagealloc_cleanup(dev);
        mlx5_cmd_cleanup(dev);
        iounmap(dev->iseg);
index f0bf46339b2805d745c89eca8a413a5cd002efb8..3a2408d448203623754d0aa87e35c16e809da43f 100644 (file)
@@ -43,10 +43,16 @@ enum {
        MLX5_PAGES_TAKE         = 2
 };
 
+enum {
+       MLX5_BOOT_PAGES         = 1,
+       MLX5_INIT_PAGES         = 2,
+       MLX5_POST_INIT_PAGES    = 3
+};
+
 struct mlx5_pages_req {
        struct mlx5_core_dev *dev;
        u32     func_id;
-       s16     npages;
+       s32     npages;
        struct work_struct work;
 };
 
@@ -64,27 +70,23 @@ struct mlx5_query_pages_inbox {
 
 struct mlx5_query_pages_outbox {
        struct mlx5_outbox_hdr  hdr;
-       u8                      reserved[2];
+       __be16                  rsvd;
        __be16                  func_id;
-       __be16                  init_pages;
-       __be16                  num_pages;
+       __be32                  num_pages;
 };
 
 struct mlx5_manage_pages_inbox {
        struct mlx5_inbox_hdr   hdr;
-       __be16                  rsvd0;
+       __be16                  rsvd;
        __be16                  func_id;
-       __be16                  rsvd1;
-       __be16                  num_entries;
-       u8                      rsvd2[16];
+       __be32                  num_entries;
        __be64                  pas[0];
 };
 
 struct mlx5_manage_pages_outbox {
        struct mlx5_outbox_hdr  hdr;
-       u8                      rsvd0[2];
-       __be16                  num_entries;
-       u8                      rsvd1[20];
+       __be32                  num_entries;
+       u8                      rsvd[4];
        __be64                  pas[0];
 };
 
@@ -146,7 +148,7 @@ static struct page *remove_page(struct mlx5_core_dev *dev, u64 addr)
 }
 
 static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
-                               s16 *pages, s16 *init_pages)
+                               s32 *npages, int boot)
 {
        struct mlx5_query_pages_inbox   in;
        struct mlx5_query_pages_outbox  out;
@@ -155,6 +157,8 @@ static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
        memset(&in, 0, sizeof(in));
        memset(&out, 0, sizeof(out));
        in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_PAGES);
+       in.hdr.opmod = boot ? cpu_to_be16(MLX5_BOOT_PAGES) : cpu_to_be16(MLX5_INIT_PAGES);
+
        err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
        if (err)
                return err;
@@ -162,10 +166,7 @@ static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
        if (out.hdr.status)
                return mlx5_cmd_status_to_err(&out.hdr);
 
-       if (pages)
-               *pages = be16_to_cpu(out.num_pages);
-       if (init_pages)
-               *init_pages = be16_to_cpu(out.init_pages);
+       *npages = be32_to_cpu(out.num_pages);
        *func_id = be16_to_cpu(out.func_id);
 
        return err;
@@ -219,7 +220,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
        in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
        in->hdr.opmod = cpu_to_be16(MLX5_PAGES_GIVE);
        in->func_id = cpu_to_be16(func_id);
-       in->num_entries = cpu_to_be16(npages);
+       in->num_entries = cpu_to_be32(npages);
        err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out));
        mlx5_core_dbg(dev, "err %d\n", err);
        if (err) {
@@ -287,7 +288,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
        in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
        in.hdr.opmod = cpu_to_be16(MLX5_PAGES_TAKE);
        in.func_id = cpu_to_be16(func_id);
-       in.num_entries = cpu_to_be16(npages);
+       in.num_entries = cpu_to_be32(npages);
        mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen);
        err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen);
        if (err) {
@@ -301,7 +302,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
                goto out_free;
        }
 
-       num_claimed = be16_to_cpu(out->num_entries);
+       num_claimed = be32_to_cpu(out->num_entries);
        if (nclaimed)
                *nclaimed = num_claimed;
 
@@ -340,7 +341,7 @@ static void pages_work_handler(struct work_struct *work)
 }
 
 void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
-                                s16 npages)
+                                s32 npages)
 {
        struct mlx5_pages_req *req;
 
@@ -357,19 +358,20 @@ void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
        queue_work(dev->priv.pg_wq, &req->work);
 }
 
-int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev)
+int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot)
 {
-       s16 uninitialized_var(init_pages);
        u16 uninitialized_var(func_id);
+       s32 uninitialized_var(npages);
        int err;
 
-       err = mlx5_cmd_query_pages(dev, &func_id, NULL, &init_pages);
+       err = mlx5_cmd_query_pages(dev, &func_id, &npages, boot);
        if (err)
                return err;
 
-       mlx5_core_dbg(dev, "requested %d init pages for func_id 0x%x\n", init_pages, func_id);
+       mlx5_core_dbg(dev, "requested %d %s pages for func_id 0x%x\n",
+                     npages, boot ? "boot" : "init", func_id);
 
-       return give_pages(dev, func_id, init_pages, 0);
+       return give_pages(dev, func_id, npages, 0);
 }
 
 static int optimal_reclaimed_pages(void)
index 71d4a39372009847b7d03b11c58e8ccf695e61b3..68f5d9c77c7b13b9038cf5bc4e920e09ac3c33a9 100644 (file)
@@ -164,6 +164,7 @@ int mlx5_alloc_uuars(struct mlx5_core_dev *dev, struct mlx5_uuar_info *uuari)
                uuari->uars[i].map = ioremap(addr, PAGE_SIZE);
                if (!uuari->uars[i].map) {
                        mlx5_cmd_free_uar(dev, uuari->uars[i].index);
+                       err = -ENOMEM;
                        goto out_count;
                }
                mlx5_core_dbg(dev, "allocated uar index 0x%x, mmaped at %p\n",
index e393d998be89dd2128fccaef65efd36a92c09d26..94b3bd6fb5fd15a079fe3e47b18cffd6fde4e89d 100644 (file)
@@ -705,7 +705,8 @@ static void ks8842_rx_frame(struct net_device *netdev,
        ks8842_enable_bits(adapter, 0, 1 << 12, REG_QRFCR);
 }
 
-void ks8842_handle_rx(struct net_device *netdev, struct ks8842_adapter *adapter)
+static void ks8842_handle_rx(struct net_device *netdev,
+       struct ks8842_adapter *adapter)
 {
        u16 rx_data = ks8842_read16(adapter, 16, REG_RXMIR) & 0x1fff;
        netdev_dbg(netdev, "%s Entry - rx_data: %d\n", __func__, rx_data);
@@ -715,7 +716,8 @@ void ks8842_handle_rx(struct net_device *netdev, struct ks8842_adapter *adapter)
        }
 }
 
-void ks8842_handle_tx(struct net_device *netdev, struct ks8842_adapter *adapter)
+static void ks8842_handle_tx(struct net_device *netdev,
+       struct ks8842_adapter *adapter)
 {
        u16 sr = ks8842_read16(adapter, 16, REG_TXSR);
        netdev_dbg(netdev, "%s - entry, sr: %x\n", __func__, sr);
@@ -724,7 +726,7 @@ void ks8842_handle_tx(struct net_device *netdev, struct ks8842_adapter *adapter)
                netif_wake_queue(netdev);
 }
 
-void ks8842_handle_rx_overrun(struct net_device *netdev,
+static void ks8842_handle_rx_overrun(struct net_device *netdev,
        struct ks8842_adapter *adapter)
 {
        netdev_dbg(netdev, "%s: entry\n", __func__);
@@ -732,7 +734,7 @@ void ks8842_handle_rx_overrun(struct net_device *netdev,
        netdev->stats.rx_fifo_errors++;
 }
 
-void ks8842_tasklet(unsigned long arg)
+static void ks8842_tasklet(unsigned long arg)
 {
        struct net_device *netdev = (struct net_device *)arg;
        struct ks8842_adapter *adapter = netdev_priv(netdev);
index ac20098b542a37697f8e78989428653d6d29ba67..9f3f5dbe1d303352e6213db9d43aea6e30e6573a 100644 (file)
@@ -688,7 +688,7 @@ static void ks_soft_reset(struct ks_net *ks, unsigned op)
 }
 
 
-void ks_enable_qmu(struct ks_net *ks)
+static void ks_enable_qmu(struct ks_net *ks)
 {
        u16 w;
 
diff --git a/drivers/net/ethernet/moxa/Kconfig b/drivers/net/ethernet/moxa/Kconfig
new file mode 100644 (file)
index 0000000..1731e05
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# MOXART device configuration
+#
+
+config NET_VENDOR_MOXART
+       bool "MOXA ART devices"
+       default y
+       depends on (ARM && ARCH_MOXART)
+       ---help---
+         If you have a network (Ethernet) card belonging to this class, say Y
+         and read the Ethernet-HOWTO, available from
+         <http://www.tldp.org/docs.html#howto>.
+
+         Note that the answer to this question doesn't directly affect the
+         kernel: saying N will just cause the configurator to skip all
+         the questions about MOXA ART devices. If you say Y, you will be asked
+         for your specific card in the following questions.
+
+if NET_VENDOR_MOXART
+
+config ARM_MOXART_ETHER
+       tristate "MOXART Ethernet support"
+       depends on ARM && ARCH_MOXART
+       select NET_CORE
+       ---help---
+         If you wish to compile a kernel for a hardware with MOXA ART SoC and
+         want to use the internal ethernet then you should answer Y to this.
+
+
+endif # NET_VENDOR_MOXART
diff --git a/drivers/net/ethernet/moxa/Makefile b/drivers/net/ethernet/moxa/Makefile
new file mode 100644 (file)
index 0000000..aa3c73e
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# Makefile for the MOXART network device drivers.
+#
+
+obj-$(CONFIG_ARM_MOXART_ETHER) += moxart_ether.o
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
new file mode 100644 (file)
index 0000000..83c2091
--- /dev/null
@@ -0,0 +1,559 @@
+/* MOXA ART Ethernet (RTL8201CP) driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen <jonas.jensen@gmail.com>
+ *
+ * Based on code from
+ * Moxa Technology Co., Ltd. <www.moxa.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/dma-mapping.h>
+#include <linux/ethtool.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/crc32.h>
+#include <linux/crc32c.h>
+#include <linux/dma-mapping.h>
+
+#include "moxart_ether.h"
+
+static inline void moxart_emac_write(struct net_device *ndev,
+                                    unsigned int reg, unsigned long value)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       writel(value, priv->base + reg);
+}
+
+static void moxart_update_mac_address(struct net_device *ndev)
+{
+       moxart_emac_write(ndev, REG_MAC_MS_ADDRESS,
+                         ((ndev->dev_addr[0] << 8) | (ndev->dev_addr[1])));
+       moxart_emac_write(ndev, REG_MAC_MS_ADDRESS + 4,
+                         ((ndev->dev_addr[2] << 24) |
+                          (ndev->dev_addr[3] << 16) |
+                          (ndev->dev_addr[4] << 8) |
+                          (ndev->dev_addr[5])));
+}
+
+static int moxart_set_mac_address(struct net_device *ndev, void *addr)
+{
+       struct sockaddr *address = addr;
+
+       if (!is_valid_ether_addr(address->sa_data))
+               return -EADDRNOTAVAIL;
+
+       memcpy(ndev->dev_addr, address->sa_data, ndev->addr_len);
+       moxart_update_mac_address(ndev);
+
+       return 0;
+}
+
+static void moxart_mac_free_memory(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       int i;
+
+       for (i = 0; i < RX_DESC_NUM; i++)
+               dma_unmap_single(&ndev->dev, priv->rx_mapping[i],
+                                priv->rx_buf_size, DMA_FROM_DEVICE);
+
+       if (priv->tx_desc_base)
+               dma_free_coherent(NULL, TX_REG_DESC_SIZE * TX_DESC_NUM,
+                                 priv->tx_desc_base, priv->tx_base);
+
+       if (priv->rx_desc_base)
+               dma_free_coherent(NULL, RX_REG_DESC_SIZE * RX_DESC_NUM,
+                                 priv->rx_desc_base, priv->rx_base);
+
+       kfree(priv->tx_buf_base);
+       kfree(priv->rx_buf_base);
+}
+
+static void moxart_mac_reset(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       writel(SW_RST, priv->base + REG_MAC_CTRL);
+       while (readl(priv->base + REG_MAC_CTRL) & SW_RST)
+               mdelay(10);
+
+       writel(0, priv->base + REG_INTERRUPT_MASK);
+
+       priv->reg_maccr = RX_BROADPKT | FULLDUP | CRC_APD | RX_FTL;
+}
+
+static void moxart_mac_enable(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       writel(0x00001010, priv->base + REG_INT_TIMER_CTRL);
+       writel(0x00000001, priv->base + REG_APOLL_TIMER_CTRL);
+       writel(0x00000390, priv->base + REG_DMA_BLEN_CTRL);
+
+       priv->reg_imr |= (RPKT_FINISH_M | XPKT_FINISH_M);
+       writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
+
+       priv->reg_maccr |= (RCV_EN | XMT_EN | RDMA_EN | XDMA_EN);
+       writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
+}
+
+static void moxart_mac_setup_desc_ring(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       void __iomem *desc;
+       int i;
+
+       for (i = 0; i < TX_DESC_NUM; i++) {
+               desc = priv->tx_desc_base + i * TX_REG_DESC_SIZE;
+               memset(desc, 0, TX_REG_DESC_SIZE);
+
+               priv->tx_buf[i] = priv->tx_buf_base + priv->tx_buf_size * i;
+       }
+       writel(TX_DESC1_END, desc + TX_REG_OFFSET_DESC1);
+
+       priv->tx_head = 0;
+       priv->tx_tail = 0;
+
+       for (i = 0; i < RX_DESC_NUM; i++) {
+               desc = priv->rx_desc_base + i * RX_REG_DESC_SIZE;
+               memset(desc, 0, RX_REG_DESC_SIZE);
+               writel(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0);
+               writel(RX_BUF_SIZE & RX_DESC1_BUF_SIZE_MASK,
+                      desc + RX_REG_OFFSET_DESC1);
+
+               priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i;
+               priv->rx_mapping[i] = dma_map_single(&ndev->dev,
+                                                    priv->rx_buf[i],
+                                                    priv->rx_buf_size,
+                                                    DMA_FROM_DEVICE);
+               if (dma_mapping_error(&ndev->dev, priv->rx_mapping[i]))
+                       netdev_err(ndev, "DMA mapping error\n");
+
+               writel(priv->rx_mapping[i],
+                      desc + RX_REG_OFFSET_DESC2 + RX_DESC2_ADDRESS_PHYS);
+               writel(priv->rx_buf[i],
+                      desc + RX_REG_OFFSET_DESC2 + RX_DESC2_ADDRESS_VIRT);
+       }
+       writel(RX_DESC1_END, desc + RX_REG_OFFSET_DESC1);
+
+       priv->rx_head = 0;
+
+       /* reset the MAC controler TX/RX desciptor base address */
+       writel(priv->tx_base, priv->base + REG_TXR_BASE_ADDRESS);
+       writel(priv->rx_base, priv->base + REG_RXR_BASE_ADDRESS);
+}
+
+static int moxart_mac_open(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       if (!is_valid_ether_addr(ndev->dev_addr))
+               return -EADDRNOTAVAIL;
+
+       napi_enable(&priv->napi);
+
+       moxart_mac_reset(ndev);
+       moxart_update_mac_address(ndev);
+       moxart_mac_setup_desc_ring(ndev);
+       moxart_mac_enable(ndev);
+       netif_start_queue(ndev);
+
+       netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n",
+                  __func__, readl(priv->base + REG_INTERRUPT_MASK),
+                  readl(priv->base + REG_MAC_CTRL));
+
+       return 0;
+}
+
+static int moxart_mac_stop(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       napi_disable(&priv->napi);
+
+       netif_stop_queue(ndev);
+
+       /* disable all interrupts */
+       writel(0, priv->base + REG_INTERRUPT_MASK);
+
+       /* disable all functions */
+       writel(0, priv->base + REG_MAC_CTRL);
+
+       return 0;
+}
+
+static int moxart_rx_poll(struct napi_struct *napi, int budget)
+{
+       struct moxart_mac_priv_t *priv = container_of(napi,
+                                                     struct moxart_mac_priv_t,
+                                                     napi);
+       struct net_device *ndev = priv->ndev;
+       struct sk_buff *skb;
+       void __iomem *desc;
+       unsigned int desc0, len;
+       int rx_head = priv->rx_head;
+       int rx = 0;
+
+       while (1) {
+               desc = priv->rx_desc_base + (RX_REG_DESC_SIZE * rx_head);
+               desc0 = readl(desc + RX_REG_OFFSET_DESC0);
+
+               if (desc0 & RX_DESC0_DMA_OWN)
+                       break;
+
+               if (desc0 & (RX_DESC0_ERR | RX_DESC0_CRC_ERR | RX_DESC0_FTL |
+                            RX_DESC0_RUNT | RX_DESC0_ODD_NB)) {
+                       net_dbg_ratelimited("packet error\n");
+                       priv->stats.rx_dropped++;
+                       priv->stats.rx_errors++;
+                       continue;
+               }
+
+               len = desc0 & RX_DESC0_FRAME_LEN_MASK;
+
+               if (len > RX_BUF_SIZE)
+                       len = RX_BUF_SIZE;
+
+               skb = build_skb(priv->rx_buf[rx_head], priv->rx_buf_size);
+               if (unlikely(!skb)) {
+                       net_dbg_ratelimited("build_skb failed\n");
+                       priv->stats.rx_dropped++;
+                       priv->stats.rx_errors++;
+               }
+
+               skb_put(skb, len);
+               skb->protocol = eth_type_trans(skb, ndev);
+               napi_gro_receive(&priv->napi, skb);
+               rx++;
+
+               ndev->last_rx = jiffies;
+               priv->stats.rx_packets++;
+               priv->stats.rx_bytes += len;
+               if (desc0 & RX_DESC0_MULTICAST)
+                       priv->stats.multicast++;
+
+               writel(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0);
+
+               rx_head = RX_NEXT(rx_head);
+               priv->rx_head = rx_head;
+
+               if (rx >= budget)
+                       break;
+       }
+
+       if (rx < budget) {
+               napi_gro_flush(napi, false);
+               __napi_complete(napi);
+       }
+
+       priv->reg_imr |= RPKT_FINISH_M;
+       writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
+
+       return rx;
+}
+
+static void moxart_tx_finished(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       unsigned tx_head = priv->tx_head;
+       unsigned tx_tail = priv->tx_tail;
+
+       while (tx_tail != tx_head) {
+               dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail],
+                                priv->tx_len[tx_tail], DMA_TO_DEVICE);
+
+               priv->stats.tx_packets++;
+               priv->stats.tx_bytes += priv->tx_skb[tx_tail]->len;
+
+               dev_kfree_skb_irq(priv->tx_skb[tx_tail]);
+               priv->tx_skb[tx_tail] = NULL;
+
+               tx_tail = TX_NEXT(tx_tail);
+       }
+       priv->tx_tail = tx_tail;
+}
+
+static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
+{
+       struct net_device *ndev = (struct net_device *) dev_id;
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       unsigned int ists = readl(priv->base + REG_INTERRUPT_STATUS);
+
+       if (ists & XPKT_OK_INT_STS)
+               moxart_tx_finished(ndev);
+
+       if (ists & RPKT_FINISH) {
+               if (napi_schedule_prep(&priv->napi)) {
+                       priv->reg_imr &= ~RPKT_FINISH_M;
+                       writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
+                       __napi_schedule(&priv->napi);
+               }
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       void __iomem *desc;
+       unsigned int len;
+       unsigned int tx_head = priv->tx_head;
+       u32 txdes1;
+       int ret = NETDEV_TX_BUSY;
+
+       desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head);
+
+       spin_lock_irq(&priv->txlock);
+       if (readl(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) {
+               net_dbg_ratelimited("no TX space for packet\n");
+               priv->stats.tx_dropped++;
+               goto out_unlock;
+       }
+
+       len = skb->len > TX_BUF_SIZE ? TX_BUF_SIZE : skb->len;
+
+       priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data,
+                                                  len, DMA_TO_DEVICE);
+       if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) {
+               netdev_err(ndev, "DMA mapping error\n");
+               goto out_unlock;
+       }
+
+       priv->tx_len[tx_head] = len;
+       priv->tx_skb[tx_head] = skb;
+
+       writel(priv->tx_mapping[tx_head],
+              desc + TX_REG_OFFSET_DESC2 + TX_DESC2_ADDRESS_PHYS);
+       writel(skb->data,
+              desc + TX_REG_OFFSET_DESC2 + TX_DESC2_ADDRESS_VIRT);
+
+       if (skb->len < ETH_ZLEN) {
+               memset(&skb->data[skb->len],
+                      0, ETH_ZLEN - skb->len);
+               len = ETH_ZLEN;
+       }
+
+       txdes1 = readl(desc + TX_REG_OFFSET_DESC1);
+       txdes1 |= TX_DESC1_LTS | TX_DESC1_FTS;
+       txdes1 &= ~(TX_DESC1_FIFO_COMPLETE | TX_DESC1_INTR_COMPLETE);
+       txdes1 |= (len & TX_DESC1_BUF_SIZE_MASK);
+       writel(txdes1, desc + TX_REG_OFFSET_DESC1);
+       writel(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
+
+       /* start to send packet */
+       writel(0xffffffff, priv->base + REG_TX_POLL_DEMAND);
+
+       priv->tx_head = TX_NEXT(tx_head);
+
+       ndev->trans_start = jiffies;
+       ret = NETDEV_TX_OK;
+out_unlock:
+       spin_unlock_irq(&priv->txlock);
+
+       return ret;
+}
+
+static struct net_device_stats *moxart_mac_get_stats(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       return &priv->stats;
+}
+
+static void moxart_mac_setmulticast(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+       struct netdev_hw_addr *ha;
+       int crc_val;
+
+       netdev_for_each_mc_addr(ha, ndev) {
+               crc_val = crc32_le(~0, ha->addr, ETH_ALEN);
+               crc_val = (crc_val >> 26) & 0x3f;
+               if (crc_val >= 32) {
+                       writel(readl(priv->base + REG_MCAST_HASH_TABLE1) |
+                              (1UL << (crc_val - 32)),
+                              priv->base + REG_MCAST_HASH_TABLE1);
+               } else {
+                       writel(readl(priv->base + REG_MCAST_HASH_TABLE0) |
+                              (1UL << crc_val),
+                              priv->base + REG_MCAST_HASH_TABLE0);
+               }
+       }
+}
+
+static void moxart_mac_set_rx_mode(struct net_device *ndev)
+{
+       struct moxart_mac_priv_t *priv = netdev_priv(ndev);
+
+       spin_lock_irq(&priv->txlock);
+
+       (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) :
+                                     (priv->reg_maccr &= ~RCV_ALL);
+
+       (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) :
+                                      (priv->reg_maccr &= ~RX_MULTIPKT);
+
+       if ((ndev->flags & IFF_MULTICAST) && netdev_mc_count(ndev)) {
+               priv->reg_maccr |= HT_MULTI_EN;
+               moxart_mac_setmulticast(ndev);
+       } else {
+               priv->reg_maccr &= ~HT_MULTI_EN;
+       }
+
+       writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
+
+       spin_unlock_irq(&priv->txlock);
+}
+
+static struct net_device_ops moxart_netdev_ops = {
+       .ndo_open               = moxart_mac_open,
+       .ndo_stop               = moxart_mac_stop,
+       .ndo_start_xmit         = moxart_mac_start_xmit,
+       .ndo_get_stats          = moxart_mac_get_stats,
+       .ndo_set_rx_mode        = moxart_mac_set_rx_mode,
+       .ndo_set_mac_address    = moxart_set_mac_address,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_change_mtu         = eth_change_mtu,
+};
+
+static int moxart_mac_probe(struct platform_device *pdev)
+{
+       struct device *p_dev = &pdev->dev;
+       struct device_node *node = p_dev->of_node;
+       struct net_device *ndev;
+       struct moxart_mac_priv_t *priv;
+       struct resource *res;
+       unsigned int irq;
+       int ret;
+
+       ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t));
+       if (!ndev)
+               return -ENOMEM;
+
+       irq = irq_of_parse_and_map(node, 0);
+       if (irq <= 0) {
+               netdev_err(ndev, "irq_of_parse_and_map failed\n");
+               return -EINVAL;
+       }
+
+       priv = netdev_priv(ndev);
+       priv->ndev = ndev;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       ndev->base_addr = res->start;
+       priv->base = devm_ioremap_resource(p_dev, res);
+       ret = IS_ERR(priv->base);
+       if (ret) {
+               dev_err(p_dev, "devm_ioremap_resource failed\n");
+               goto init_fail;
+       }
+
+       spin_lock_init(&priv->txlock);
+
+       priv->tx_buf_size = TX_BUF_SIZE;
+       priv->rx_buf_size = RX_BUF_SIZE +
+                           SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
+
+       priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
+                                               TX_DESC_NUM, &priv->tx_base,
+                                               GFP_DMA | GFP_KERNEL);
+       if (priv->tx_desc_base == NULL)
+               goto init_fail;
+
+       priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE *
+                                               RX_DESC_NUM, &priv->rx_base,
+                                               GFP_DMA | GFP_KERNEL);
+       if (priv->rx_desc_base == NULL)
+               goto init_fail;
+
+       priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM,
+                                   GFP_ATOMIC);
+       if (!priv->tx_buf_base)
+               goto init_fail;
+
+       priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM,
+                                   GFP_ATOMIC);
+       if (!priv->rx_buf_base)
+               goto init_fail;
+
+       platform_set_drvdata(pdev, ndev);
+
+       ret = devm_request_irq(p_dev, irq, moxart_mac_interrupt, 0,
+                              pdev->name, ndev);
+       if (ret) {
+               netdev_err(ndev, "devm_request_irq failed\n");
+               goto init_fail;
+       }
+
+       ether_setup(ndev);
+       ndev->netdev_ops = &moxart_netdev_ops;
+       netif_napi_add(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM);
+       ndev->priv_flags |= IFF_UNICAST_FLT;
+       ndev->irq = irq;
+
+       SET_NETDEV_DEV(ndev, &pdev->dev);
+
+       ret = register_netdev(ndev);
+       if (ret) {
+               free_netdev(ndev);
+               goto init_fail;
+       }
+
+       netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n",
+                  __func__, ndev->irq, ndev->dev_addr);
+
+       return 0;
+
+init_fail:
+       netdev_err(ndev, "init failed\n");
+       moxart_mac_free_memory(ndev);
+
+       return ret;
+}
+
+static int moxart_remove(struct platform_device *pdev)
+{
+       struct net_device *ndev = platform_get_drvdata(pdev);
+
+       unregister_netdev(ndev);
+       free_irq(ndev->irq, ndev);
+       moxart_mac_free_memory(ndev);
+       free_netdev(ndev);
+
+       return 0;
+}
+
+static const struct of_device_id moxart_mac_match[] = {
+       { .compatible = "moxa,moxart-mac" },
+       { }
+};
+
+struct __initdata platform_driver moxart_mac_driver = {
+       .probe  = moxart_mac_probe,
+       .remove = moxart_remove,
+       .driver = {
+               .name           = "moxart-ethernet",
+               .owner          = THIS_MODULE,
+               .of_match_table = moxart_mac_match,
+       },
+};
+module_platform_driver(moxart_mac_driver);
+
+MODULE_DESCRIPTION("MOXART RTL8201CP Ethernet driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Jonas Jensen <jonas.jensen@gmail.com>");
diff --git a/drivers/net/ethernet/moxa/moxart_ether.h b/drivers/net/ethernet/moxa/moxart_ether.h
new file mode 100644 (file)
index 0000000..2be9280
--- /dev/null
@@ -0,0 +1,330 @@
+/* MOXA ART Ethernet (RTL8201CP) driver.
+ *
+ * Copyright (C) 2013 Jonas Jensen
+ *
+ * Jonas Jensen <jonas.jensen@gmail.com>
+ *
+ * Based on code from
+ * Moxa Technology Co., Ltd. <www.moxa.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef _MOXART_ETHERNET_H
+#define _MOXART_ETHERNET_H
+
+#define TX_REG_OFFSET_DESC0    0
+#define TX_REG_OFFSET_DESC1    4
+#define TX_REG_OFFSET_DESC2    8
+#define TX_REG_DESC_SIZE       16
+
+#define RX_REG_OFFSET_DESC0    0
+#define RX_REG_OFFSET_DESC1    4
+#define RX_REG_OFFSET_DESC2    8
+#define RX_REG_DESC_SIZE       16
+
+#define TX_DESC0_PKT_LATE_COL  0x1             /* abort, late collision */
+#define TX_DESC0_RX_PKT_EXS_COL        0x2             /* abort, >16 collisions */
+#define TX_DESC0_DMA_OWN       0x80000000      /* owned by controller */
+#define TX_DESC1_BUF_SIZE_MASK 0x7ff
+#define TX_DESC1_LTS           0x8000000       /* last TX packet */
+#define TX_DESC1_FTS           0x10000000      /* first TX packet */
+#define TX_DESC1_FIFO_COMPLETE 0x20000000
+#define TX_DESC1_INTR_COMPLETE 0x40000000
+#define TX_DESC1_END           0x80000000
+#define TX_DESC2_ADDRESS_PHYS  0
+#define TX_DESC2_ADDRESS_VIRT  4
+
+#define RX_DESC0_FRAME_LEN     0
+#define RX_DESC0_FRAME_LEN_MASK        0x7FF
+#define RX_DESC0_MULTICAST     0x10000
+#define RX_DESC0_BROADCAST     0x20000
+#define RX_DESC0_ERR           0x40000
+#define RX_DESC0_CRC_ERR       0x80000
+#define RX_DESC0_FTL           0x100000
+#define RX_DESC0_RUNT          0x200000        /* packet less than 64 bytes */
+#define RX_DESC0_ODD_NB                0x400000        /* receive odd nibbles */
+#define RX_DESC0_LRS           0x10000000      /* last receive segment */
+#define RX_DESC0_FRS           0x20000000      /* first receive segment */
+#define RX_DESC0_DMA_OWN       0x80000000
+#define RX_DESC1_BUF_SIZE_MASK 0x7FF
+#define RX_DESC1_END           0x80000000
+#define RX_DESC2_ADDRESS_PHYS  0
+#define RX_DESC2_ADDRESS_VIRT  4
+
+#define TX_DESC_NUM            64
+#define TX_DESC_NUM_MASK       (TX_DESC_NUM-1)
+#define TX_NEXT(N)             (((N) + 1) & (TX_DESC_NUM_MASK))
+#define TX_BUF_SIZE            1600
+#define TX_BUF_SIZE_MAX                (TX_DESC1_BUF_SIZE_MASK+1)
+
+#define RX_DESC_NUM            64
+#define RX_DESC_NUM_MASK       (RX_DESC_NUM-1)
+#define RX_NEXT(N)             (((N) + 1) & (RX_DESC_NUM_MASK))
+#define RX_BUF_SIZE            1600
+#define RX_BUF_SIZE_MAX                (RX_DESC1_BUF_SIZE_MASK+1)
+
+#define REG_INTERRUPT_STATUS   0
+#define REG_INTERRUPT_MASK     4
+#define REG_MAC_MS_ADDRESS     8
+#define REG_MAC_LS_ADDRESS     12
+#define REG_MCAST_HASH_TABLE0  16
+#define REG_MCAST_HASH_TABLE1  20
+#define REG_TX_POLL_DEMAND     24
+#define REG_RX_POLL_DEMAND     28
+#define REG_TXR_BASE_ADDRESS   32
+#define REG_RXR_BASE_ADDRESS   36
+#define REG_INT_TIMER_CTRL     40
+#define REG_APOLL_TIMER_CTRL   44
+#define REG_DMA_BLEN_CTRL      48
+#define REG_RESERVED1          52
+#define REG_MAC_CTRL           136
+#define REG_MAC_STATUS         140
+#define REG_PHY_CTRL           144
+#define REG_PHY_WRITE_DATA     148
+#define REG_FLOW_CTRL          152
+#define REG_BACK_PRESSURE      156
+#define REG_RESERVED2          160
+#define REG_TEST_SEED          196
+#define REG_DMA_FIFO_STATE     200
+#define REG_TEST_MODE          204
+#define REG_RESERVED3          208
+#define REG_TX_COL_COUNTER     212
+#define REG_RPF_AEP_COUNTER    216
+#define REG_XM_PG_COUNTER      220
+#define REG_RUNT_TLC_COUNTER   224
+#define REG_CRC_FTL_COUNTER    228
+#define REG_RLC_RCC_COUNTER    232
+#define REG_BROC_COUNTER       236
+#define REG_MULCA_COUNTER      240
+#define REG_RP_COUNTER         244
+#define REG_XP_COUNTER         248
+
+#define REG_PHY_CTRL_OFFSET    0x0
+#define REG_PHY_STATUS         0x1
+#define REG_PHY_ID1            0x2
+#define REG_PHY_ID2            0x3
+#define REG_PHY_ANA            0x4
+#define REG_PHY_ANLPAR         0x5
+#define REG_PHY_ANE            0x6
+#define REG_PHY_ECTRL1         0x10
+#define REG_PHY_QPDS           0x11
+#define REG_PHY_10BOP          0x12
+#define REG_PHY_ECTRL2         0x13
+#define REG_PHY_FTMAC100_WRITE 0x8000000
+#define REG_PHY_FTMAC100_READ  0x4000000
+
+/* REG_INTERRUPT_STATUS */
+#define RPKT_FINISH            BIT(0)  /* DMA data received */
+#define NORXBUF                        BIT(1)  /* receive buffer unavailable */
+#define XPKT_FINISH            BIT(2)  /* DMA moved data to TX FIFO */
+#define NOTXBUF                        BIT(3)  /* transmit buffer unavailable */
+#define XPKT_OK_INT_STS                BIT(4)  /* transmit to ethernet success */
+#define XPKT_LOST_INT_STS      BIT(5)  /* transmit ethernet lost (collision) */
+#define RPKT_SAV               BIT(6)  /* FIFO receive success */
+#define RPKT_LOST_INT_STS      BIT(7)  /* FIFO full, receive failed */
+#define AHB_ERR                        BIT(8)  /* AHB error */
+#define PHYSTS_CHG             BIT(9)  /* PHY link status change */
+
+/* REG_INTERRUPT_MASK */
+#define RPKT_FINISH_M          BIT(0)
+#define NORXBUF_M              BIT(1)
+#define XPKT_FINISH_M          BIT(2)
+#define NOTXBUF_M              BIT(3)
+#define XPKT_OK_M              BIT(4)
+#define XPKT_LOST_M            BIT(5)
+#define RPKT_SAV_M             BIT(6)
+#define RPKT_LOST_M            BIT(7)
+#define AHB_ERR_M              BIT(8)
+#define PHYSTS_CHG_M           BIT(9)
+
+/* REG_MAC_MS_ADDRESS */
+#define MAC_MADR_MASK          0xffff  /* 2 MSB MAC address */
+
+/* REG_INT_TIMER_CTRL */
+#define TXINT_TIME_SEL         BIT(15) /* TX cycle time period */
+#define TXINT_THR_MASK         0x7000
+#define TXINT_CNT_MASK         0xf00
+#define RXINT_TIME_SEL         BIT(7)  /* RX cycle time period */
+#define RXINT_THR_MASK         0x70
+#define RXINT_CNT_MASK         0xF
+
+/* REG_APOLL_TIMER_CTRL */
+#define TXPOLL_TIME_SEL                BIT(12) /* TX poll time period */
+#define TXPOLL_CNT_MASK                0xf00
+#define TXPOLL_CNT_SHIFT_BIT   8
+#define RXPOLL_TIME_SEL                BIT(4)  /* RX poll time period */
+#define RXPOLL_CNT_MASK                0xF
+#define RXPOLL_CNT_SHIFT_BIT   0
+
+/* REG_DMA_BLEN_CTRL */
+#define RX_THR_EN              BIT(9)  /* RX FIFO threshold arbitration */
+#define RXFIFO_HTHR_MASK       0x1c0
+#define RXFIFO_LTHR_MASK       0x38
+#define INCR16_EN              BIT(2)  /* AHB bus INCR16 burst command */
+#define INCR8_EN               BIT(1)  /* AHB bus INCR8 burst command */
+#define INCR4_EN               BIT(0)  /* AHB bus INCR4 burst command */
+
+/* REG_MAC_CTRL */
+#define RX_BROADPKT            BIT(17) /* receive broadcast packets */
+#define RX_MULTIPKT            BIT(16) /* receive all multicast packets */
+#define FULLDUP                        BIT(15) /* full duplex */
+#define CRC_APD                        BIT(14) /* append CRC to transmitted packet */
+#define RCV_ALL                        BIT(12) /* ignore incoming packet destination */
+#define RX_FTL                 BIT(11) /* accept packets larger than 1518 B */
+#define RX_RUNT                        BIT(10) /* accept packets smaller than 64 B */
+#define HT_MULTI_EN            BIT(9)  /* accept on hash and mcast pass */
+#define RCV_EN                 BIT(8)  /* receiver enable */
+#define ENRX_IN_HALFTX         BIT(6)  /* enable receive in half duplex mode */
+#define XMT_EN                 BIT(5)  /* transmit enable */
+#define CRC_DIS                        BIT(4)  /* disable CRC check when receiving */
+#define LOOP_EN                        BIT(3)  /* internal loop-back */
+#define SW_RST                 BIT(2)  /* software reset, last 64 AHB clocks */
+#define RDMA_EN                        BIT(1)  /* enable receive DMA chan */
+#define XDMA_EN                        BIT(0)  /* enable transmit DMA chan */
+
+/* REG_MAC_STATUS */
+#define COL_EXCEED             BIT(11) /* more than 16 collisions */
+#define LATE_COL               BIT(10) /* transmit late collision detected */
+#define XPKT_LOST              BIT(9)  /* transmit to ethernet lost */
+#define XPKT_OK                        BIT(8)  /* transmit to ethernet success */
+#define RUNT_MAC_STS           BIT(7)  /* receive runt detected */
+#define FTL_MAC_STS            BIT(6)  /* receive frame too long detected */
+#define CRC_ERR_MAC_STS                BIT(5)
+#define RPKT_LOST              BIT(4)  /* RX FIFO full, receive failed */
+#define RPKT_SAVE              BIT(3)  /* RX FIFO receive success */
+#define COL                    BIT(2)  /* collision, incoming packet dropped */
+#define MCPU_BROADCAST         BIT(1)
+#define MCPU_MULTICAST         BIT(0)
+
+/* REG_PHY_CTRL */
+#define MIIWR                  BIT(27) /* init write sequence (auto cleared)*/
+#define MIIRD                  BIT(26)
+#define REGAD_MASK             0x3e00000
+#define PHYAD_MASK             0x1f0000
+#define MIIRDATA_MASK          0xffff
+
+/* REG_PHY_WRITE_DATA */
+#define MIIWDATA_MASK          0xffff
+
+/* REG_FLOW_CTRL */
+#define PAUSE_TIME_MASK                0xffff0000
+#define FC_HIGH_MASK           0xf000
+#define FC_LOW_MASK            0xf00
+#define RX_PAUSE               BIT(4)  /* receive pause frame */
+#define TX_PAUSED              BIT(3)  /* transmit pause due to receive */
+#define FCTHR_EN               BIT(2)  /* enable threshold mode. */
+#define TX_PAUSE               BIT(1)  /* transmit pause frame */
+#define FC_EN                  BIT(0)  /* flow control mode enable */
+
+/* REG_BACK_PRESSURE */
+#define BACKP_LOW_MASK         0xf00
+#define BACKP_JAM_LEN_MASK     0xf0
+#define BACKP_MODE             BIT(1)  /* address mode */
+#define BACKP_ENABLE           BIT(0)
+
+/* REG_TEST_SEED */
+#define TEST_SEED_MASK         0x3fff
+
+/* REG_DMA_FIFO_STATE */
+#define TX_DMA_REQUEST         BIT(31)
+#define RX_DMA_REQUEST         BIT(30)
+#define TX_DMA_GRANT           BIT(29)
+#define RX_DMA_GRANT           BIT(28)
+#define TX_FIFO_EMPTY          BIT(27)
+#define RX_FIFO_EMPTY          BIT(26)
+#define TX_DMA2_SM_MASK                0x7000
+#define TX_DMA1_SM_MASK                0xf00
+#define RX_DMA2_SM_MASK                0x70
+#define RX_DMA1_SM_MASK                0xF
+
+/* REG_TEST_MODE */
+#define SINGLE_PKT             BIT(26) /* single packet mode */
+#define PTIMER_TEST            BIT(25) /* automatic polling timer test mode */
+#define ITIMER_TEST            BIT(24) /* interrupt timer test mode */
+#define TEST_SEED_SELECT       BIT(22)
+#define SEED_SELECT            BIT(21)
+#define TEST_MODE              BIT(20)
+#define TEST_TIME_MASK         0xffc00
+#define TEST_EXCEL_MASK                0x3e0
+
+/* REG_TX_COL_COUNTER */
+#define TX_MCOL_MASK           0xffff0000
+#define TX_MCOL_SHIFT_BIT      16
+#define TX_SCOL_MASK           0xffff
+#define TX_SCOL_SHIFT_BIT      0
+
+/* REG_RPF_AEP_COUNTER */
+#define RPF_MASK               0xffff0000
+#define RPF_SHIFT_BIT          16
+#define AEP_MASK               0xffff
+#define AEP_SHIFT_BIT          0
+
+/* REG_XM_PG_COUNTER */
+#define XM_MASK                        0xffff0000
+#define XM_SHIFT_BIT           16
+#define PG_MASK                        0xffff
+#define PG_SHIFT_BIT           0
+
+/* REG_RUNT_TLC_COUNTER */
+#define RUNT_CNT_MASK          0xffff0000
+#define RUNT_CNT_SHIFT_BIT     16
+#define TLCC_MASK              0xffff
+#define TLCC_SHIFT_BIT         0
+
+/* REG_CRC_FTL_COUNTER */
+#define CRCER_CNT_MASK         0xffff0000
+#define CRCER_CNT_SHIFT_BIT    16
+#define FTL_CNT_MASK           0xffff
+#define FTL_CNT_SHIFT_BIT      0
+
+/* REG_RLC_RCC_COUNTER */
+#define RLC_MASK               0xffff0000
+#define RLC_SHIFT_BIT          16
+#define RCC_MASK               0xffff
+#define RCC_SHIFT_BIT          0
+
+/* REG_PHY_STATUS */
+#define AN_COMPLETE            0x20
+#define LINK_STATUS            0x4
+
+struct moxart_mac_priv_t {
+       void __iomem *base;
+       struct net_device_stats stats;
+       unsigned int reg_maccr;
+       unsigned int reg_imr;
+       struct napi_struct napi;
+       struct net_device *ndev;
+
+       dma_addr_t rx_base;
+       dma_addr_t rx_mapping[RX_DESC_NUM];
+       void __iomem *rx_desc_base;
+       unsigned char *rx_buf_base;
+       unsigned char *rx_buf[RX_DESC_NUM];
+       unsigned int rx_head;
+       unsigned int rx_buf_size;
+
+       dma_addr_t tx_base;
+       dma_addr_t tx_mapping[TX_DESC_NUM];
+       void __iomem *tx_desc_base;
+       unsigned char *tx_buf_base;
+       unsigned char *tx_buf[RX_DESC_NUM];
+       unsigned int tx_head;
+       unsigned int tx_buf_size;
+
+       spinlock_t txlock;
+       unsigned int tx_len[TX_DESC_NUM];
+       struct sk_buff *tx_skb[TX_DESC_NUM];
+       unsigned int tx_tail;
+};
+
+#if TX_BUF_SIZE >= TX_BUF_SIZE_MAX
+#error MOXA ART Ethernet device driver TX buffer is too large!
+#endif
+#if RX_BUF_SIZE >= RX_BUF_SIZE_MAX
+#error MOXA ART Ethernet device driver RX buffer is too large!
+#endif
+
+#endif
index 967bae8b85c5f6c9bb0a720d97b3c0c17c940430..50a1d4a04eb010259ca5f33d34d92e877cc25e1b 100644 (file)
@@ -74,6 +74,7 @@
 #ifdef CONFIG_MTRR
 #include <asm/mtrr.h>
 #endif
+#include <net/busy_poll.h>
 
 #include "myri10ge_mcp.h"
 #include "myri10ge_mcp_gen_header.h"
@@ -194,6 +195,21 @@ struct myri10ge_slice_state {
        int cpu;
        __be32 __iomem *dca_tag;
 #endif
+#ifdef CONFIG_NET_RX_BUSY_POLL
+       unsigned int state;
+#define SLICE_STATE_IDLE       0
+#define SLICE_STATE_NAPI       1       /* NAPI owns this slice */
+#define SLICE_STATE_POLL       2       /* poll owns this slice */
+#define SLICE_LOCKED (SLICE_STATE_NAPI | SLICE_STATE_POLL)
+#define SLICE_STATE_NAPI_YIELD 4       /* NAPI yielded this slice */
+#define SLICE_STATE_POLL_YIELD 8       /* poll yielded this slice */
+#define SLICE_USER_PEND (SLICE_STATE_POLL | SLICE_STATE_POLL_YIELD)
+       spinlock_t lock;
+       unsigned long lock_napi_yield;
+       unsigned long lock_poll_yield;
+       unsigned long busy_poll_miss;
+       unsigned long busy_poll_cnt;
+#endif /* CONFIG_NET_RX_BUSY_POLL */
        char irq_desc[32];
 };
 
@@ -244,7 +260,7 @@ struct myri10ge_priv {
        int fw_ver_minor;
        int fw_ver_tiny;
        int adopted_rx_filter_bug;
-       u8 mac_addr[6];         /* eeprom mac address */
+       u8 mac_addr[ETH_ALEN];          /* eeprom mac address */
        unsigned long serial_number;
        int vendor_specific_offset;
        int fw_multicast_support;
@@ -909,6 +925,92 @@ abort:
        return status;
 }
 
+#ifdef CONFIG_NET_RX_BUSY_POLL
+static inline void myri10ge_ss_init_lock(struct myri10ge_slice_state *ss)
+{
+       spin_lock_init(&ss->lock);
+       ss->state = SLICE_STATE_IDLE;
+}
+
+static inline bool myri10ge_ss_lock_napi(struct myri10ge_slice_state *ss)
+{
+       int rc = true;
+       spin_lock(&ss->lock);
+       if ((ss->state & SLICE_LOCKED)) {
+               WARN_ON((ss->state & SLICE_STATE_NAPI));
+               ss->state |= SLICE_STATE_NAPI_YIELD;
+               rc = false;
+               ss->lock_napi_yield++;
+       } else
+               ss->state = SLICE_STATE_NAPI;
+       spin_unlock(&ss->lock);
+       return rc;
+}
+
+static inline void myri10ge_ss_unlock_napi(struct myri10ge_slice_state *ss)
+{
+       spin_lock(&ss->lock);
+       WARN_ON((ss->state & (SLICE_STATE_POLL | SLICE_STATE_NAPI_YIELD)));
+       ss->state = SLICE_STATE_IDLE;
+       spin_unlock(&ss->lock);
+}
+
+static inline bool myri10ge_ss_lock_poll(struct myri10ge_slice_state *ss)
+{
+       int rc = true;
+       spin_lock_bh(&ss->lock);
+       if ((ss->state & SLICE_LOCKED)) {
+               ss->state |= SLICE_STATE_POLL_YIELD;
+               rc = false;
+               ss->lock_poll_yield++;
+       } else
+               ss->state |= SLICE_STATE_POLL;
+       spin_unlock_bh(&ss->lock);
+       return rc;
+}
+
+static inline void myri10ge_ss_unlock_poll(struct myri10ge_slice_state *ss)
+{
+       spin_lock_bh(&ss->lock);
+       WARN_ON((ss->state & SLICE_STATE_NAPI));
+       ss->state = SLICE_STATE_IDLE;
+       spin_unlock_bh(&ss->lock);
+}
+
+static inline bool myri10ge_ss_busy_polling(struct myri10ge_slice_state *ss)
+{
+       WARN_ON(!(ss->state & SLICE_LOCKED));
+       return (ss->state & SLICE_USER_PEND);
+}
+#else /* CONFIG_NET_RX_BUSY_POLL */
+static inline void myri10ge_ss_init_lock(struct myri10ge_slice_state *ss)
+{
+}
+
+static inline bool myri10ge_ss_lock_napi(struct myri10ge_slice_state *ss)
+{
+       return false;
+}
+
+static inline void myri10ge_ss_unlock_napi(struct myri10ge_slice_state *ss)
+{
+}
+
+static inline bool myri10ge_ss_lock_poll(struct myri10ge_slice_state *ss)
+{
+       return false;
+}
+
+static inline void myri10ge_ss_unlock_poll(struct myri10ge_slice_state *ss)
+{
+}
+
+static inline bool myri10ge_ss_busy_polling(struct myri10ge_slice_state *ss)
+{
+       return false;
+}
+#endif
+
 static int myri10ge_reset(struct myri10ge_priv *mgp)
 {
        struct myri10ge_cmd cmd;
@@ -1300,6 +1402,8 @@ myri10ge_vlan_rx(struct net_device *dev, void *addr, struct sk_buff *skb)
        }
 }
 
+#define MYRI10GE_HLEN 64 /* Bytes to copy from page to skb linear memory */
+
 static inline int
 myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum)
 {
@@ -1311,6 +1415,7 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum)
        struct pci_dev *pdev = mgp->pdev;
        struct net_device *dev = mgp->dev;
        u8 *va;
+       bool polling;
 
        if (len <= mgp->small_bytes) {
                rx = &ss->rx_small;
@@ -1325,7 +1430,15 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum)
        va = page_address(rx->info[idx].page) + rx->info[idx].page_offset;
        prefetch(va);
 
-       skb = napi_get_frags(&ss->napi);
+       /* When busy polling in user context, allocate skb and copy headers to
+        * skb's linear memory ourselves.  When not busy polling, use the napi
+        * gro api.
+        */
+       polling = myri10ge_ss_busy_polling(ss);
+       if (polling)
+               skb = netdev_alloc_skb(dev, MYRI10GE_HLEN + 16);
+       else
+               skb = napi_get_frags(&ss->napi);
        if (unlikely(skb == NULL)) {
                ss->stats.rx_dropped++;
                for (i = 0, remainder = len; remainder > 0; i++) {
@@ -1364,8 +1477,29 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum)
        }
        myri10ge_vlan_rx(mgp->dev, va, skb);
        skb_record_rx_queue(skb, ss - &mgp->ss[0]);
+       skb_mark_napi_id(skb, &ss->napi);
+
+       if (polling) {
+               int hlen;
+
+               /* myri10ge_vlan_rx might have moved the header, so compute
+                * length and address again.
+                */
+               hlen = MYRI10GE_HLEN > skb->len ? skb->len : MYRI10GE_HLEN;
+               va = page_address(skb_frag_page(&rx_frags[0])) +
+                       rx_frags[0].page_offset;
+               /* Copy header into the skb linear memory */
+               skb_copy_to_linear_data(skb, va, hlen);
+               rx_frags[0].page_offset += hlen;
+               rx_frags[0].size -= hlen;
+               skb->data_len -= hlen;
+               skb->tail += hlen;
+               skb->protocol = eth_type_trans(skb, dev);
+               netif_receive_skb(skb);
+       }
+       else
+               napi_gro_frags(&ss->napi);
 
-       napi_gro_frags(&ss->napi);
        return 1;
 }
 
@@ -1524,10 +1658,14 @@ static int myri10ge_poll(struct napi_struct *napi, int budget)
        if (ss->mgp->dca_enabled)
                myri10ge_update_dca(ss);
 #endif
+       /* Try later if the busy_poll handler is running. */
+       if (!myri10ge_ss_lock_napi(ss))
+               return budget;
 
        /* process as many rx events as NAPI will allow */
        work_done = myri10ge_clean_rx_done(ss, budget);
 
+       myri10ge_ss_unlock_napi(ss);
        if (work_done < budget) {
                napi_complete(napi);
                put_be32(htonl(3), ss->irq_claim);
@@ -1535,6 +1673,34 @@ static int myri10ge_poll(struct napi_struct *napi, int budget)
        return work_done;
 }
 
+#ifdef CONFIG_NET_RX_BUSY_POLL
+static int myri10ge_busy_poll(struct napi_struct *napi)
+{
+       struct myri10ge_slice_state *ss =
+           container_of(napi, struct myri10ge_slice_state, napi);
+       struct myri10ge_priv *mgp = ss->mgp;
+       int work_done;
+
+       /* Poll only when the link is up */
+       if (mgp->link_state != MXGEFW_LINK_UP)
+               return LL_FLUSH_FAILED;
+
+       if (!myri10ge_ss_lock_poll(ss))
+               return LL_FLUSH_BUSY;
+
+       /* Process a small number of packets */
+       work_done = myri10ge_clean_rx_done(ss, 4);
+       if (work_done)
+               ss->busy_poll_cnt += work_done;
+       else
+               ss->busy_poll_miss++;
+
+       myri10ge_ss_unlock_poll(ss);
+
+       return work_done;
+}
+#endif /* CONFIG_NET_RX_BUSY_POLL */
+
 static irqreturn_t myri10ge_intr(int irq, void *arg)
 {
        struct myri10ge_slice_state *ss = arg;
@@ -1742,6 +1908,10 @@ static const char myri10ge_gstrings_slice_stats[][ETH_GSTRING_LEN] = {
        "tx_pkt_start", "tx_pkt_done", "tx_req", "tx_done",
        "rx_small_cnt", "rx_big_cnt",
        "wake_queue", "stop_queue", "tx_linearized",
+#ifdef CONFIG_NET_RX_BUSY_POLL
+       "rx_lock_napi_yield", "rx_lock_poll_yield", "rx_busy_poll_miss",
+       "rx_busy_poll_cnt",
+#endif
 };
 
 #define MYRI10GE_NET_STATS_LEN      21
@@ -1842,6 +2012,12 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
                data[i++] = (unsigned int)ss->tx.wake_queue;
                data[i++] = (unsigned int)ss->tx.stop_queue;
                data[i++] = (unsigned int)ss->tx.linearized;
+#ifdef CONFIG_NET_RX_BUSY_POLL
+               data[i++] = ss->lock_napi_yield;
+               data[i++] = ss->lock_poll_yield;
+               data[i++] = ss->busy_poll_miss;
+               data[i++] = ss->busy_poll_cnt;
+#endif
        }
 }
 
@@ -2405,6 +2581,9 @@ static int myri10ge_open(struct net_device *dev)
                        goto abort_with_rings;
                }
 
+               /* Initialize the slice spinlock and state used for polling */
+               myri10ge_ss_init_lock(ss);
+
                /* must happen prior to any irq */
                napi_enable(&(ss)->napi);
        }
@@ -2481,9 +2660,19 @@ static int myri10ge_close(struct net_device *dev)
 
        del_timer_sync(&mgp->watchdog_timer);
        mgp->running = MYRI10GE_ETH_STOPPING;
+       local_bh_disable(); /* myri10ge_ss_lock_napi needs bh disabled */
        for (i = 0; i < mgp->num_slices; i++) {
                napi_disable(&mgp->ss[i].napi);
+               /* Lock the slice to prevent the busy_poll handler from
+                * accessing it.  Later when we bring the NIC up, myri10ge_open
+                * resets the slice including this lock.
+                */
+               while (!myri10ge_ss_lock_napi(&mgp->ss[i])) {
+                       pr_info("Slice %d locked\n", i);
+                       mdelay(1);
+               }
        }
+       local_bh_enable();
        netif_carrier_off(dev);
 
        netif_tx_stop_all_queues(dev);
@@ -3569,8 +3758,11 @@ static void myri10ge_free_slices(struct myri10ge_priv *mgp)
                                          ss->fw_stats, ss->fw_stats_bus);
                        ss->fw_stats = NULL;
                }
+               napi_hash_del(&ss->napi);
                netif_napi_del(&ss->napi);
        }
+       /* Wait till napi structs are no longer used, and then free ss. */
+       synchronize_rcu();
        kfree(mgp->ss);
        mgp->ss = NULL;
 }
@@ -3606,6 +3798,7 @@ static int myri10ge_alloc_slices(struct myri10ge_priv *mgp)
                ss->dev = mgp->dev;
                netif_napi_add(ss->dev, &ss->napi, myri10ge_poll,
                               myri10ge_napi_weight);
+               napi_hash_add(&ss->napi);
        }
        return 0;
 abort:
@@ -3625,13 +3818,12 @@ static void myri10ge_probe_slices(struct myri10ge_priv *mgp)
        struct pci_dev *pdev = mgp->pdev;
        char *old_fw;
        bool old_allocated;
-       int i, status, ncpus, msix_cap;
+       int i, status, ncpus;
 
        mgp->num_slices = 1;
-       msix_cap = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
        ncpus = netif_get_num_default_rss_queues();
 
-       if (myri10ge_max_slices == 1 || msix_cap == 0 ||
+       if (myri10ge_max_slices == 1 || !pdev->msix_cap ||
            (myri10ge_max_slices == -1 && ncpus < 2))
                return;
 
@@ -3749,6 +3941,9 @@ static const struct net_device_ops myri10ge_netdev_ops = {
        .ndo_change_mtu         = myri10ge_change_mtu,
        .ndo_set_rx_mode        = myri10ge_set_multicast_list,
        .ndo_set_mac_address    = myri10ge_set_mac_address,
+#ifdef CONFIG_NET_RX_BUSY_POLL
+       .ndo_busy_poll          = myri10ge_busy_poll,
+#endif
 };
 
 static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
index e88bdb1aa669c1f60c9b161f2b81fb10150c7777..dcfe58fa3b8a1abc9eb858a91a171db7a7bfcc3d 100644 (file)
@@ -922,7 +922,7 @@ static void __init get_mac_address(struct net_device *dev)
 {
        struct w90p910_ether *ether = netdev_priv(dev);
        struct platform_device *pdev;
-       char addr[6];
+       char addr[ETH_ALEN];
 
        pdev = ether->pdev;
 
@@ -934,7 +934,7 @@ static void __init get_mac_address(struct net_device *dev)
        addr[5] = 0xa8;
 
        if (is_valid_ether_addr(addr))
-               memcpy(dev->dev_addr, &addr, 0x06);
+               memcpy(dev->dev_addr, &addr, ETH_ALEN);
        else
                dev_err(&pdev->dev, "invalid mac address\n");
 }
index cb22341a14a8c03fd7627c0d2d2a31f9f68ce126..a588ffde970041def37cae92b215011d88b6eea6 100644 (file)
@@ -4,7 +4,7 @@
 
 config PCH_GBE
        tristate "OKI SEMICONDUCTOR IOH(ML7223/ML7831) GbE"
-       depends on PCI
+       depends on PCI && (X86 || COMPILE_TEST)
        select MII
        select PTP_1588_CLOCK_PCH
        ---help---
index 7779036690cca239265ddbe27eeac8076a546933..6797b1075874ae26cca6756bf450559ed7c7e6be 100644 (file)
@@ -581,6 +581,19 @@ struct pch_gbe_hw_stats {
        u32 intr_tcpip_err_count;
 };
 
+/**
+ * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_tx_clk_delay:          Bool, configure the PHY TX delay in software
+ * @phy_disable_hibernate:     Bool, disable PHY hibernation
+ * @platform_init:             Platform initialization callback, called from
+ *                             probe, prior to PHY initialization.
+ */
+struct pch_gbe_privdata {
+       bool phy_tx_clk_delay;
+       bool phy_disable_hibernate;
+       int (*platform_init)(struct pci_dev *pdev);
+};
+
 /**
  * struct pch_gbe_adapter - board specific private data structure
  * @stats_lock:        Spinlock structure for status
@@ -604,6 +617,7 @@ struct pch_gbe_hw_stats {
  * @rx_buffer_len:     Receive buffer length
  * @tx_queue_len:      Transmit queue length
  * @have_msi:          PCI MSI mode flag
+ * @pch_gbe_privdata:  PCI Device ID driver_data
  */
 
 struct pch_gbe_adapter {
@@ -631,6 +645,7 @@ struct pch_gbe_adapter {
        int hwts_tx_en;
        int hwts_rx_en;
        struct pci_dev *ptp_pdev;
+       struct pch_gbe_privdata *pdata;
 };
 
 #define pch_gbe_hw_to_adapter(hw)      container_of(hw, struct pch_gbe_adapter, hw)
index 1129db0cdf82886c90494e92d963b36a2e574dc2..f0ceb89af93110c874eee7ec3d23cce82871d8a9 100644 (file)
@@ -118,6 +118,7 @@ static int pch_gbe_set_settings(struct net_device *netdev,
         * filled by get_settings() on a down link, speed is -1: */
        if (speed == UINT_MAX) {
                speed = SPEED_1000;
+               ethtool_cmd_speed_set(ecmd, speed);
                ecmd->duplex = DUPLEX_FULL;
        }
        ret = mii_ethtool_sset(&adapter->mii, ecmd);
index ab1039a95bf9e3ed883862515bc59a6f921df946..e19f1be60d5e40fc8428a766825f6815f9ce7e29 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_classify.h>
+#include <linux/gpio.h>
 
 #define DRV_VERSION     "1.01"
 const char pch_driver_version[] = DRV_VERSION;
@@ -111,6 +112,8 @@ const char pch_driver_version[] = DRV_VERSION;
 #define PTP_L4_MULTICAST_SA "01:00:5e:00:01:81"
 #define PTP_L2_MULTICAST_SA "01:1b:19:00:00:00"
 
+#define MINNOW_PHY_RESET_GPIO          13
+
 static unsigned int copybreak __read_mostly = PCH_GBE_COPYBREAK_DEFAULT;
 
 static int pch_gbe_mdio_read(struct net_device *netdev, int addr, int reg);
@@ -682,7 +685,7 @@ static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
        }
        adapter->hw.phy.addr = adapter->mii.phy_id;
        netdev_dbg(netdev, "phy_addr = %d\n", adapter->mii.phy_id);
-       if (addr == 32)
+       if (addr == PCH_GBE_PHY_REGS_LEN)
                return -EAGAIN;
        /* Selected the phy and isolate the rest */
        for (addr = 0; addr < PCH_GBE_PHY_REGS_LEN; addr++) {
@@ -2635,6 +2638,9 @@ static int pch_gbe_probe(struct pci_dev *pdev,
        adapter->pdev = pdev;
        adapter->hw.back = adapter;
        adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
+       adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
+       if (adapter->pdata && adapter->pdata->platform_init)
+               adapter->pdata->platform_init(pdev);
 
        adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number,
                                               PCI_DEVFN(12, 4));
@@ -2710,6 +2716,10 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 
        dev_dbg(&pdev->dev, "PCH Network Connection\n");
 
+       /* Disable hibernation on certain platforms */
+       if (adapter->pdata && adapter->pdata->phy_disable_hibernate)
+               pch_gbe_phy_disable_hibernate(&adapter->hw);
+
        device_set_wakeup_enable(&pdev->dev, 1);
        return 0;
 
@@ -2720,7 +2730,46 @@ err_free_netdev:
        return ret;
 }
 
+/* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
+ * ensure it is awake for probe and init. Request the line and reset the PHY.
+ */
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+{
+       unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
+       unsigned gpio = MINNOW_PHY_RESET_GPIO;
+       int ret;
+
+       ret = devm_gpio_request_one(&pdev->dev, gpio, flags,
+                                   "minnow_phy_reset");
+       if (ret) {
+               dev_err(&pdev->dev,
+                       "ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
+               return ret;
+       }
+
+       gpio_set_value(gpio, 0);
+       usleep_range(1250, 1500);
+       gpio_set_value(gpio, 1);
+       usleep_range(1250, 1500);
+
+       return ret;
+}
+
+static struct pch_gbe_privdata pch_gbe_minnow_privdata = {
+       .phy_tx_clk_delay = true,
+       .phy_disable_hibernate = true,
+       .platform_init = pch_gbe_minnow_platform_init,
+};
+
 static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = {
+       {.vendor = PCI_VENDOR_ID_INTEL,
+        .device = PCI_DEVICE_ID_INTEL_IOH1_GBE,
+        .subvendor = PCI_VENDOR_ID_CIRCUITCO,
+        .subdevice = PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD,
+        .class = (PCI_CLASS_NETWORK_ETHERNET << 8),
+        .class_mask = (0xFFFF00),
+        .driver_data = (kernel_ulong_t)&pch_gbe_minnow_privdata
+        },
        {.vendor = PCI_VENDOR_ID_INTEL,
         .device = PCI_DEVICE_ID_INTEL_IOH1_GBE,
         .subvendor = PCI_ANY_ID,
index da079073a6c63e18528f51e359793b43bd001af2..8b7ff75fc8e0d5201c94a014c64781b632a896cc 100644 (file)
 #define MII_SR_100X_FD_CAPS      0x4000        /* 100X  Full Duplex Capable */
 #define MII_SR_100T4_CAPS        0x8000        /* 100T4 Capable */
 
+/* AR8031 PHY Debug Registers */
+#define PHY_AR803X_ID           0x00001374
+#define PHY_AR8031_DBG_OFF      0x1D
+#define PHY_AR8031_DBG_DAT      0x1E
+#define PHY_AR8031_SERDES       0x05
+#define PHY_AR8031_HIBERNATE    0x0B
+#define PHY_AR8031_SERDES_TX_CLK_DLY   0x0100 /* TX clock delay of 2.0ns */
+#define PHY_AR8031_PS_HIB_EN           0x8000 /* Hibernate enable */
+
 /* Phy Id Register (word 2) */
 #define PHY_REVISION_MASK        0x000F
 
@@ -248,6 +257,51 @@ void pch_gbe_phy_set_rgmii(struct pch_gbe_hw *hw)
        pch_gbe_phy_sw_reset(hw);
 }
 
+/**
+ * pch_gbe_phy_tx_clk_delay - Setup TX clock delay via the PHY
+ * @hw:                    Pointer to the HW structure
+ * Returns
+ *     0:              Successful.
+ *     -EINVAL:        Invalid argument.
+ */
+static int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)
+{
+       /* The RGMII interface requires a ~2ns TX clock delay. This is typically
+        * done in layout with a longer trace or via PHY strapping, but can also
+        * be done via PHY configuration registers.
+        */
+       struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+       u16 mii_reg;
+       int ret = 0;
+
+       switch (hw->phy.id) {
+       case PHY_AR803X_ID:
+               netdev_dbg(adapter->netdev,
+                          "Configuring AR803X PHY for 2ns TX clock delay\n");
+               pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_OFF, &mii_reg);
+               ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_OFF,
+                                                PHY_AR8031_SERDES);
+               if (ret)
+                       break;
+
+               pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_DAT, &mii_reg);
+               mii_reg |= PHY_AR8031_SERDES_TX_CLK_DLY;
+               ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_DAT,
+                                                mii_reg);
+               break;
+       default:
+               netdev_err(adapter->netdev,
+                          "Unknown PHY (%x), could not set TX clock delay\n",
+                          hw->phy.id);
+               return -EINVAL;
+       }
+
+       if (ret)
+               netdev_err(adapter->netdev,
+                          "Could not configure tx clock delay for PHY\n");
+       return ret;
+}
+
 /**
  * pch_gbe_phy_init_setting - PHY initial setting
  * @hw:                    Pointer to the HW structure
@@ -277,4 +331,48 @@ void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw)
        pch_gbe_phy_read_reg_miic(hw, PHY_PHYSP_CONTROL, &mii_reg);
        mii_reg |= PHYSP_CTRL_ASSERT_CRS_TX;
        pch_gbe_phy_write_reg_miic(hw, PHY_PHYSP_CONTROL, mii_reg);
+
+       /* Setup a TX clock delay on certain platforms */
+       if (adapter->pdata && adapter->pdata->phy_tx_clk_delay)
+               pch_gbe_phy_tx_clk_delay(hw);
+}
+
+/**
+ * pch_gbe_phy_disable_hibernate - Disable the PHY low power state
+ * @hw:                    Pointer to the HW structure
+ * Returns
+ *     0:              Successful.
+ *     -EINVAL:        Invalid argument.
+ */
+int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw)
+{
+       struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+       u16 mii_reg;
+       int ret = 0;
+
+       switch (hw->phy.id) {
+       case PHY_AR803X_ID:
+               netdev_dbg(adapter->netdev,
+                          "Disabling hibernation for AR803X PHY\n");
+               ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_OFF,
+                                                PHY_AR8031_HIBERNATE);
+               if (ret)
+                       break;
+
+               pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_DAT, &mii_reg);
+               mii_reg &= ~PHY_AR8031_PS_HIB_EN;
+               ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_DAT,
+                                                mii_reg);
+               break;
+       default:
+               netdev_err(adapter->netdev,
+                          "Unknown PHY (%x), could not disable hibernation\n",
+                          hw->phy.id);
+               return -EINVAL;
+       }
+
+       if (ret)
+               netdev_err(adapter->netdev,
+                          "Could not disable PHY hibernation\n");
+       return ret;
 }
index 03264dc7b5ec8a294da8c4e662f348ca74230d32..0cbe69206e04db47eb77956d7466937e6c357144 100644 (file)
@@ -33,5 +33,6 @@ void pch_gbe_phy_power_up(struct pch_gbe_hw *hw);
 void pch_gbe_phy_power_down(struct pch_gbe_hw *hw);
 void pch_gbe_phy_set_rgmii(struct pch_gbe_hw *hw);
 void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw);
+int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw);
 
 #endif /* _PCH_GBE_PHY_H_ */
index a5f0b5da614933c74ebbf005edba139b4bb74b88..f21ae7b6c766c3353e33faeab6fd32a14270e0cf 100644 (file)
@@ -191,7 +191,7 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
        struct device_node *dn = pci_device_to_OF_node(pdev);
        int len;
        const u8 *maddr;
-       u8 addr[6];
+       u8 addr[ETH_ALEN];
 
        if (!dn) {
                dev_dbg(&pdev->dev,
@@ -201,8 +201,8 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
 
        maddr = of_get_property(dn, "local-mac-address", &len);
 
-       if (maddr && len == 6) {
-               memcpy(mac->mac_addr, maddr, 6);
+       if (maddr && len == ETH_ALEN) {
+               memcpy(mac->mac_addr, maddr, ETH_ALEN);
                return 0;
        }
 
@@ -219,14 +219,15 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac)
                return -ENOENT;
        }
 
-       if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[0],
-                  &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]) != 6) {
+       if (sscanf(maddr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+                  &addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5])
+           != ETH_ALEN) {
                dev_warn(&pdev->dev,
                         "can't parse mac address, not configuring\n");
                return -EINVAL;
        }
 
-       memcpy(mac->mac_addr, addr, 6);
+       memcpy(mac->mac_addr, addr, ETH_ALEN);
 
        return 0;
 }
index e2f4efa8ad46a5d79384a2afd6e441a1552f02a0..f2749d46c125f738ce38e406958015fc37246640 100644 (file)
@@ -83,7 +83,7 @@ struct pasemi_mac {
 #define MAC_TYPE_GMAC  1
 #define MAC_TYPE_XAUI  2
 
-       u8              mac_addr[6];
+       u8              mac_addr[ETH_ALEN];
 
        struct net_lro_mgr      lro_mgr;
        struct net_lro_desc     lro_desc[MAX_LRO_DESCRIPTORS];
index 0e1797295a48dca4578d65fbce6a8608d4ca2afb..f59e6be4a66e1747be369912f75f06fabfe64ee5 100644 (file)
@@ -45,6 +45,17 @@ config QLCNIC_SRIOV
          This allows for virtual function acceleration in virtualized
          environments.
 
+config QLCNIC_DCB
+       bool "QLOGIC QLCNIC 82XX and 83XX family DCB Support"
+       depends on QLCNIC && DCB
+       default y
+       ---help---
+         This configuration parameter enables DCB support in QLE83XX
+         and QLE82XX Converged Ethernet devices. This allows for DCB
+         get operations support through rtNetlink interface. Only CEE
+         mode of DCB is supported. PG and PFC values are related only
+         to Tx.
+
 config QLGE
        tristate "QLogic QLGE 10Gb Ethernet Driver Support"
        depends on PCI
index 9fbb1cdbfa4764b48d010f5ca43a851b33234e20..8375cbde996976047475b9c5e6c16f33fd365df4 100644 (file)
@@ -536,10 +536,10 @@ static void netxen_p2_nic_set_multi(struct net_device *netdev)
 {
        struct netxen_adapter *adapter = netdev_priv(netdev);
        struct netdev_hw_addr *ha;
-       u8 null_addr[6];
+       u8 null_addr[ETH_ALEN];
        int i;
 
-       memset(null_addr, 0, 6);
+       memset(null_addr, 0, ETH_ALEN);
 
        if (netdev->flags & IFF_PROMISC) {
 
index c401b0b4353d94d543e357c16c184c8771eafe7a..1046e9461509a57d314bb78052d88f7b26e2d6aa 100644 (file)
@@ -459,16 +459,14 @@ static void netxen_pcie_strap_init(struct netxen_adapter *adapter)
 static void netxen_set_msix_bit(struct pci_dev *pdev, int enable)
 {
        u32 control;
-       int pos;
 
-       pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
-       if (pos) {
-               pci_read_config_dword(pdev, pos, &control);
+       if (pdev->msix_cap) {
+               pci_read_config_dword(pdev, pdev->msix_cap, &control);
                if (enable)
                        control |= PCI_MSIX_FLAGS_ENABLE;
                else
                        control = 0;
-               pci_write_config_dword(pdev, pos, control);
+               pci_write_config_dword(pdev, pdev->msix_cap, control);
        }
 }
 
index 4b1fb3faa3b76ad71ffa39d1d7083374181d5665..a848d2979722486b4489cc479f2bae166f0c6038 100644 (file)
@@ -11,3 +11,5 @@ qlcnic-y := qlcnic_hw.o qlcnic_main.o qlcnic_init.o \
        qlcnic_minidump.o qlcnic_sriov_common.o
 
 qlcnic-$(CONFIG_QLCNIC_SRIOV) += qlcnic_sriov_pf.o
+
+qlcnic-$(CONFIG_QLCNIC_DCB) += qlcnic_dcb.o
index b00cf5665eabee735b1e218e6aeda7111380fe69..22bd425cfd84ebef33d7222ed8583de2b6598923 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/tcp.h>
 #include <linux/skbuff.h>
 #include <linux/firmware.h>
-
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/timer.h>
 #include "qlcnic_hdr.h"
 #include "qlcnic_hw.h"
 #include "qlcnic_83xx_hw.h"
+#include "qlcnic_dcb.h"
 
 #define _QLCNIC_LINUX_MAJOR 5
-#define _QLCNIC_LINUX_MINOR 2
-#define _QLCNIC_LINUX_SUBVERSION 44
-#define QLCNIC_LINUX_VERSIONID  "5.2.44"
+#define _QLCNIC_LINUX_MINOR 3
+#define _QLCNIC_LINUX_SUBVERSION 49
+#define QLCNIC_LINUX_VERSIONID  "5.3.49"
 #define QLCNIC_DRV_IDC_VER  0x01
 #define QLCNIC_DRIVER_VERSION  ((_QLCNIC_LINUX_MAJOR << 16) |\
                 (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION))
@@ -98,6 +98,9 @@
 #define TX_STOP_THRESH         ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \
                                                        + MGMT_CMD_DESC_RESV)
 #define QLCNIC_MAX_TX_TIMEOUTS 2
+#define QLCNIC_MAX_TX_RINGS    8
+#define QLCNIC_MAX_SDS_RINGS   8
+
 /*
  * Following are the states of the Phantom. Phantom will set them and
  * Host will read to check if the fields are correct.
@@ -467,7 +470,9 @@ struct qlcnic_hardware_context {
        u32 *ext_reg_tbl;
        u32 mbox_aen[QLC_83XX_MBX_AEN_CNT];
        u32 mbox_reg[4];
-       spinlock_t mbx_lock;
+       struct qlcnic_mailbox *mailbox;
+       u8 extend_lb_time;
+       u8 phys_port_id[ETH_ALEN];
 };
 
 struct qlcnic_adapter_stats {
@@ -515,6 +520,7 @@ struct qlcnic_host_sds_ring {
        u32 num_desc;
        void __iomem *crb_sts_consumer;
 
+       struct qlcnic_host_tx_ring *tx_ring;
        struct status_desc *desc_head;
        struct qlcnic_adapter *adapter;
        struct napi_struct napi;
@@ -532,9 +538,17 @@ struct qlcnic_host_tx_ring {
        void __iomem *crb_intr_mask;
        char name[IFNAMSIZ + 12];
        u16 ctx_id;
+
+       u32 state;
        u32 producer;
        u32 sw_consumer;
        u32 num_desc;
+
+       u64 xmit_on;
+       u64 xmit_off;
+       u64 xmit_called;
+       u64 xmit_finished;
+
        void __iomem *crb_cmd_producer;
        struct cmd_desc_type0 *desc_head;
        struct qlcnic_adapter *adapter;
@@ -559,7 +573,6 @@ struct qlcnic_recv_context {
        u32 state;
        u16 context_id;
        u16 virt_port;
-
 };
 
 /* HW context creation */
@@ -604,6 +617,7 @@ struct qlcnic_recv_context {
 #define QLCNIC_CAP0_LRO_CONTIGUOUS     (1 << 8)
 #define QLCNIC_CAP0_VALIDOFF           (1 << 11)
 #define QLCNIC_CAP0_LRO_MSS            (1 << 21)
+#define QLCNIC_CAP0_TX_MULTI           (1 << 22)
 
 /*
  * Context state
@@ -631,7 +645,7 @@ struct qlcnic_hostrq_rds_ring {
 
 struct qlcnic_hostrq_rx_ctx {
        __le64 host_rsp_dma_addr;       /* Response dma'd here */
-       __le32 capabilities[4]; /* Flag bit vector */
+       __le32 capabilities[4];         /* Flag bit vector */
        __le32 host_int_crb_mode;       /* Interrupt crb usage */
        __le32 host_rds_crb_mode;       /* RDS crb usage */
        /* These ring offsets are relative to data[0] below */
@@ -802,6 +816,7 @@ struct qlcnic_mac_list_s {
 
 #define QLCNIC_C2H_OPCODE_CONFIG_LOOPBACK              0x8f
 #define QLCNIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE       0x8D
+#define QLCNIC_C2H_OPCODE_GET_DCB_AEN                  0x90
 
 #define VPORT_MISS_MODE_DROP           0 /* drop all unmatched */
 #define VPORT_MISS_MODE_ACCEPT_ALL     1 /* accept all packets */
@@ -814,6 +829,7 @@ struct qlcnic_mac_list_s {
 #define QLCNIC_FW_CAPABILITY_BDG               BIT_8
 #define QLCNIC_FW_CAPABILITY_FVLANTX           BIT_9
 #define QLCNIC_FW_CAPABILITY_HW_LRO            BIT_10
+#define QLCNIC_FW_CAPABILITY_2_MULTI_TX                BIT_4
 #define QLCNIC_FW_CAPABILITY_MULTI_LOOPBACK    BIT_27
 #define QLCNIC_FW_CAPABILITY_MORE_CAPS         BIT_31
 
@@ -913,6 +929,8 @@ struct qlcnic_ipaddr {
 #define QLCNIC_FW_LRO_MSS_CAP          0x8000
 #define QLCNIC_TX_INTR_SHARED          0x10000
 #define QLCNIC_APP_CHANGED_FLAGS       0x20000
+#define QLCNIC_HAS_PHYS_PORT_ID                0x40000
+
 #define QLCNIC_IS_MSI_FAMILY(adapter) \
        ((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED))
 #define QLCNIC_IS_TSO_CAPABLE(adapter)  \
@@ -922,6 +940,7 @@ struct qlcnic_ipaddr {
 #define QLCNIC_BEACON_DISABLE          0xD
 
 #define QLCNIC_DEF_NUM_STS_DESC_RINGS  4
+#define QLCNIC_DEF_NUM_TX_RINGS                4
 #define QLCNIC_MSIX_TBL_SPACE          8192
 #define QLCNIC_PCI_REG_MSIX_TBL        0x44
 #define QLCNIC_MSIX_TBL_PGSIZE         4096
@@ -937,10 +956,13 @@ struct qlcnic_ipaddr {
 #define __QLCNIC_DIAG_RES_ALLOC                6
 #define __QLCNIC_LED_ENABLE            7
 #define __QLCNIC_ELB_INPROGRESS                8
+#define __QLCNIC_MULTI_TX_UNIQUE       9
 #define __QLCNIC_SRIOV_ENABLE          10
 #define __QLCNIC_SRIOV_CAPABLE         11
 #define __QLCNIC_MBX_POLL_ENABLE       12
 #define __QLCNIC_DIAG_MODE             13
+#define __QLCNIC_DCB_STATE             14
+#define __QLCNIC_DCB_IN_AEN            15
 
 #define QLCNIC_INTERRUPT_TEST          1
 #define QLCNIC_LOOPBACK_TEST           2
@@ -950,12 +972,6 @@ struct qlcnic_ipaddr {
 #define QLCNIC_READD_AGE       20
 #define QLCNIC_LB_MAX_FILTERS  64
 #define QLCNIC_LB_BUCKET_SIZE  32
-
-/* QLCNIC Driver Error Code */
-#define QLCNIC_FW_NOT_RESPOND          51
-#define QLCNIC_TEST_IN_PROGRESS                52
-#define QLCNIC_UNDEFINED_ERROR         53
-#define QLCNIC_LB_CABLE_NOT_CONN       54
 #define QLCNIC_ILB_MAX_RCV_LOOP        10
 
 struct qlcnic_filter {
@@ -972,6 +988,21 @@ struct qlcnic_filter_hash {
        u16 fbucket_size;
 };
 
+/* Mailbox specific data structures */
+struct qlcnic_mailbox {
+       struct workqueue_struct *work_q;
+       struct qlcnic_adapter   *adapter;
+       struct qlcnic_mbx_ops   *ops;
+       struct work_struct      work;
+       struct completion       completion;
+       struct list_head        cmd_q;
+       unsigned long           status;
+       spinlock_t              queue_lock;     /* Mailbox queue lock */
+       spinlock_t              aen_lock;       /* Mailbox response/AEN lock */
+       atomic_t                rsp_status;
+       u32                     num_cmds;
+};
+
 struct qlcnic_adapter {
        struct qlcnic_hardware_context *ahw;
        struct qlcnic_recv_context *recv_ctx;
@@ -1035,6 +1066,7 @@ struct qlcnic_adapter {
        struct delayed_work fw_work;
        struct delayed_work idc_aen_work;
        struct delayed_work mbx_poll_work;
+       struct qlcnic_dcb *dcb;
 
        struct qlcnic_filter_hash fhash;
        struct qlcnic_filter_hash rx_fhash;
@@ -1385,9 +1417,20 @@ struct _cdrp_cmd {
 };
 
 struct qlcnic_cmd_args {
-       struct _cdrp_cmd req;
-       struct _cdrp_cmd rsp;
-       int op_type;
+       struct completion       completion;
+       struct list_head        list;
+       struct _cdrp_cmd        req;
+       struct _cdrp_cmd        rsp;
+       atomic_t                rsp_status;
+       int                     pay_size;
+       u32                     rsp_opcode;
+       u32                     total_cmds;
+       u32                     op_type;
+       u32                     type;
+       u32                     cmd_op;
+       u32                     *hdr;   /* Back channel message header */
+       u32                     *pay;   /* Back channel message payload */
+       u8                      func_num;
 };
 
 int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter);
@@ -1400,8 +1443,8 @@ void qlcnic_pci_camqm_write_2M(struct qlcnic_adapter *, u64, u64);
 #define ADDR_IN_RANGE(addr, low, high) \
        (((addr) < (high)) && ((addr) >= (low)))
 
-#define QLCRD32(adapter, off) \
-       (adapter->ahw->hw_ops->read_reg)(adapter, off)
+#define QLCRD32(adapter, off, err) \
+       (adapter->ahw->hw_ops->read_reg)(adapter, off, err)
 
 #define QLCWR32(adapter, off, val) \
        adapter->ahw->hw_ops->write_reg(adapter, off, val)
@@ -1462,7 +1505,8 @@ void qlcnic_fw_destroy_ctx(struct qlcnic_adapter *adapter);
 
 void qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter);
 void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter);
-void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter);
+void qlcnic_release_tx_buffers(struct qlcnic_adapter *,
+                              struct qlcnic_host_tx_ring *);
 
 int qlcnic_check_fw_status(struct qlcnic_adapter *adapter);
 void qlcnic_watchdog_task(struct work_struct *work);
@@ -1474,6 +1518,7 @@ void __qlcnic_set_multi(struct net_device *, u16);
 int qlcnic_nic_add_mac(struct qlcnic_adapter *, const u8 *, u16);
 int qlcnic_nic_del_mac(struct qlcnic_adapter *, const u8 *);
 void qlcnic_82xx_free_mac_list(struct qlcnic_adapter *adapter);
+int qlcnic_82xx_read_phys_port_id(struct qlcnic_adapter *);
 
 int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu);
 int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *, u32);
@@ -1495,8 +1540,9 @@ int qlcnic_reset_context(struct qlcnic_adapter *);
 void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings);
 int qlcnic_diag_alloc_res(struct net_device *netdev, int test);
 netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
-int qlcnic_set_max_rss(struct qlcnic_adapter *, u8, size_t);
+int qlcnic_set_max_rss(struct qlcnic_adapter *, u8, int);
 int qlcnic_validate_max_rss(struct qlcnic_adapter *, __u32);
+int qlcnic_validate_max_tx_rings(struct qlcnic_adapter *, u32 txq);
 void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter);
 void qlcnic_82xx_set_mac_filter_count(struct qlcnic_adapter *);
 int qlcnic_enable_msix(struct qlcnic_adapter *, u32);
@@ -1523,6 +1569,7 @@ void qlcnic_free_sds_rings(struct qlcnic_recv_context *);
 void qlcnic_advert_link_change(struct qlcnic_adapter *, int);
 void qlcnic_free_tx_rings(struct qlcnic_adapter *);
 int qlcnic_alloc_tx_rings(struct qlcnic_adapter *, struct net_device *);
+void qlcnic_dump_mbx(struct qlcnic_adapter *, struct qlcnic_cmd_args *);
 
 void qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter);
 void qlcnic_remove_sysfs_entries(struct qlcnic_adapter *adapter);
@@ -1585,6 +1632,26 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring)
                                tx_ring->producer;
 }
 
+static inline int qlcnic_set_real_num_queues(struct qlcnic_adapter *adapter,
+                                            struct net_device *netdev)
+{
+       int err, tx_q;
+
+       tx_q = adapter->max_drv_tx_rings;
+
+       netdev->num_tx_queues = tx_q;
+       netdev->real_num_tx_queues = tx_q;
+
+       err = netif_set_real_num_tx_queues(netdev, tx_q);
+       if (err)
+               dev_err(&adapter->pdev->dev, "failed to set %d Tx queues\n",
+                       tx_q);
+       else
+               dev_info(&adapter->pdev->dev, "set %d Tx queues\n", tx_q);
+
+       return err;
+}
+
 struct qlcnic_nic_template {
        int (*config_bridged_mode) (struct qlcnic_adapter *, u32);
        int (*config_led) (struct qlcnic_adapter *, u32, u32);
@@ -1600,15 +1667,29 @@ struct qlcnic_nic_template {
        int (*resume)(struct qlcnic_adapter *);
 };
 
+struct qlcnic_mbx_ops {
+       int (*enqueue_cmd) (struct qlcnic_adapter *,
+                           struct qlcnic_cmd_args *, unsigned long *);
+       void (*dequeue_cmd) (struct qlcnic_adapter *, struct qlcnic_cmd_args *);
+       void (*decode_resp) (struct qlcnic_adapter *, struct qlcnic_cmd_args *);
+       void (*encode_cmd) (struct qlcnic_adapter *, struct qlcnic_cmd_args *);
+       void (*nofity_fw) (struct qlcnic_adapter *, u8);
+};
+
+int qlcnic_83xx_init_mailbox_work(struct qlcnic_adapter *);
+void qlcnic_83xx_detach_mailbox_work(struct qlcnic_adapter *);
+void qlcnic_83xx_reinit_mbx_work(struct qlcnic_mailbox *mbx);
+void qlcnic_83xx_free_mailbox(struct qlcnic_mailbox *mbx);
+
 /* Adapter hardware abstraction */
 struct qlcnic_hardware_ops {
        void (*read_crb) (struct qlcnic_adapter *, char *, loff_t, size_t);
        void (*write_crb) (struct qlcnic_adapter *, char *, loff_t, size_t);
-       int (*read_reg) (struct qlcnic_adapter *, ulong);
+       int (*read_reg) (struct qlcnic_adapter *, ulong, int *);
        int (*write_reg) (struct qlcnic_adapter *, ulong, u32);
        void (*get_ocm_win) (struct qlcnic_hardware_context *);
-       int (*get_mac_address) (struct qlcnic_adapter *, u8 *);
-       int (*setup_intr) (struct qlcnic_adapter *, u8);
+       int (*get_mac_address) (struct qlcnic_adapter *, u8 *, u8);
+       int (*setup_intr) (struct qlcnic_adapter *, u8, int);
        int (*alloc_mbx_args)(struct qlcnic_cmd_args *,
                              struct qlcnic_adapter *, u32);
        int (*mbx_cmd) (struct qlcnic_adapter *, struct qlcnic_cmd_args *);
@@ -1641,6 +1722,7 @@ struct qlcnic_hardware_ops {
        int (*get_board_info) (struct qlcnic_adapter *);
        void (*set_mac_filter_count) (struct qlcnic_adapter *);
        void (*free_mac_list) (struct qlcnic_adapter *);
+       int (*read_phys_port_id) (struct qlcnic_adapter *);
 };
 
 extern struct qlcnic_nic_template qlcnic_vf_ops;
@@ -1662,12 +1744,6 @@ static inline void qlcnic_write_crb(struct qlcnic_adapter *adapter, char *buf,
        adapter->ahw->hw_ops->write_crb(adapter, buf, offset, size);
 }
 
-static inline int qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter,
-                                      ulong off)
-{
-       return adapter->ahw->hw_ops->read_reg(adapter, off);
-}
-
 static inline int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *adapter,
                                        ulong off, u32 data)
 {
@@ -1675,14 +1751,15 @@ static inline int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *adapter,
 }
 
 static inline int qlcnic_get_mac_address(struct qlcnic_adapter *adapter,
-                                        u8 *mac)
+                                        u8 *mac, u8 function)
 {
-       return adapter->ahw->hw_ops->get_mac_address(adapter, mac);
+       return adapter->ahw->hw_ops->get_mac_address(adapter, mac, function);
 }
 
-static inline int qlcnic_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
+static inline int qlcnic_setup_intr(struct qlcnic_adapter *adapter,
+                                   u8 num_intr, int txq)
 {
-       return adapter->ahw->hw_ops->setup_intr(adapter, num_intr);
+       return adapter->ahw->hw_ops->setup_intr(adapter, num_intr, txq);
 }
 
 static inline int qlcnic_alloc_mbx_args(struct qlcnic_cmd_args *mbx,
@@ -1869,7 +1946,14 @@ static inline void qlcnic_free_mac_list(struct qlcnic_adapter *adapter)
 
 static inline void qlcnic_set_mac_filter_count(struct qlcnic_adapter *adapter)
 {
-       adapter->ahw->hw_ops->set_mac_filter_count(adapter);
+       if (adapter->ahw->hw_ops->set_mac_filter_count)
+               adapter->ahw->hw_ops->set_mac_filter_count(adapter);
+}
+
+static inline void qlcnic_read_phys_port_id(struct qlcnic_adapter *adapter)
+{
+       if (adapter->ahw->hw_ops->read_phys_port_id)
+               adapter->ahw->hw_ops->read_phys_port_id(adapter);
 }
 
 static inline void qlcnic_dev_request_reset(struct qlcnic_adapter *adapter,
@@ -1903,16 +1987,45 @@ static inline void qlcnic_config_ipaddr(struct qlcnic_adapter *adapter,
        adapter->nic_ops->config_ipaddr(adapter, ip, cmd);
 }
 
+static inline bool qlcnic_check_multi_tx(struct qlcnic_adapter *adapter)
+{
+       return test_bit(__QLCNIC_MULTI_TX_UNIQUE, &adapter->state);
+}
+
+static inline void qlcnic_disable_multi_tx(struct qlcnic_adapter *adapter)
+{
+       test_and_clear_bit(__QLCNIC_MULTI_TX_UNIQUE, &adapter->state);
+       adapter->max_drv_tx_rings = 1;
+}
+
+/* When operating in a muti tx mode, driver needs to write 0x1
+ * to src register, instead of 0x0 to disable receiving interrupt.
+ */
 static inline void qlcnic_disable_int(struct qlcnic_host_sds_ring *sds_ring)
 {
-       writel(0, sds_ring->crb_intr_mask);
+       struct qlcnic_adapter *adapter = sds_ring->adapter;
+
+       if (qlcnic_check_multi_tx(adapter) &&
+           !adapter->ahw->diag_test &&
+           (adapter->flags & QLCNIC_MSIX_ENABLED))
+               writel(0x1, sds_ring->crb_intr_mask);
+       else
+               writel(0, sds_ring->crb_intr_mask);
 }
 
+/* When operating in a muti tx mode, driver needs to write 0x0
+ * to src register, instead of 0x1 to enable receiving interrupts.
+ */
 static inline void qlcnic_enable_int(struct qlcnic_host_sds_ring *sds_ring)
 {
        struct qlcnic_adapter *adapter = sds_ring->adapter;
 
-       writel(0x1, sds_ring->crb_intr_mask);
+       if (qlcnic_check_multi_tx(adapter) &&
+           !adapter->ahw->diag_test &&
+           (adapter->flags & QLCNIC_MSIX_ENABLED))
+               writel(0, sds_ring->crb_intr_mask);
+       else
+               writel(0x1, sds_ring->crb_intr_mask);
 
        if (!QLCNIC_IS_MSI_FAMILY(adapter))
                writel(0xfbff, adapter->tgt_mask_reg);
@@ -1944,9 +2057,11 @@ extern const struct ethtool_ops qlcnic_ethtool_failed_ops;
                        __func__, ##_args);             \
        } while (0)
 
-#define PCI_DEVICE_ID_QLOGIC_QLE834X    0x8030
+#define PCI_DEVICE_ID_QLOGIC_QLE824X           0x8020
+#define PCI_DEVICE_ID_QLOGIC_QLE834X           0x8030
 #define PCI_DEVICE_ID_QLOGIC_VF_QLE834X        0x8430
-#define PCI_DEVICE_ID_QLOGIC_QLE824X   0x8020
+#define PCI_DEVICE_ID_QLOGIC_QLE844X           0x8040
+#define PCI_DEVICE_ID_QLOGIC_VF_QLE844X        0x8440
 
 static inline bool qlcnic_82xx_check(struct qlcnic_adapter *adapter)
 {
@@ -1960,6 +2075,8 @@ static inline bool qlcnic_83xx_check(struct qlcnic_adapter *adapter)
        bool status;
 
        status = ((device == PCI_DEVICE_ID_QLOGIC_QLE834X) ||
+                 (device == PCI_DEVICE_ID_QLOGIC_QLE844X) ||
+                 (device == PCI_DEVICE_ID_QLOGIC_VF_QLE844X) ||
                  (device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X)) ? true : false;
 
        return status;
@@ -1973,7 +2090,105 @@ static inline bool qlcnic_sriov_pf_check(struct qlcnic_adapter *adapter)
 static inline bool qlcnic_sriov_vf_check(struct qlcnic_adapter *adapter)
 {
        unsigned short device = adapter->pdev->device;
+       bool status;
+
+       status = ((device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X) ||
+                 (device == PCI_DEVICE_ID_QLOGIC_VF_QLE844X)) ? true : false;
+
+       return status;
+}
+
+static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->get_hw_capability)
+               return dcb->ops->get_hw_capability(adapter);
+
+       return 0;
+}
+
+static inline void qlcnic_dcb_free(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->free)
+               dcb->ops->free(adapter);
+}
+
+static inline int qlcnic_dcb_attach(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->attach)
+               return dcb->ops->attach(adapter);
+
+       return 0;
+}
+
+static inline int
+qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *adapter, char *buf)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->query_hw_capability)
+               return dcb->ops->query_hw_capability(adapter, buf);
+
+       return 0;
+}
+
+static inline void qlcnic_dcb_get_info(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->get_info)
+               dcb->ops->get_info(adapter);
+}
+
+static inline int
+qlcnic_dcb_query_cee_param(struct qlcnic_adapter *adapter, char *buf, u8 type)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->query_cee_param)
+               return dcb->ops->query_cee_param(adapter, buf, type);
+
+       return 0;
+}
+
+static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->get_cee_cfg)
+               return dcb->ops->get_cee_cfg(adapter);
+
+       return 0;
+}
+
+static inline void
+qlcnic_dcb_register_aen(struct qlcnic_adapter *adapter, u8 flag)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->register_aen)
+               dcb->ops->register_aen(adapter, flag);
+}
+
+static inline void qlcnic_dcb_handle_aen(struct qlcnic_adapter *adapter,
+                                        void *msg)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (dcb && dcb->ops->handle_aen)
+               dcb->ops->handle_aen(adapter, msg);
+}
+
+static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
 
-       return (device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X) ? true : false;
+       if (dcb && dcb->ops->init_dcbnl_ops)
+               dcb->ops->init_dcbnl_ops(adapter);
 }
 #endif                         /* __QLCNIC_H_ */
index 0913c623a67efd238e7d989d50cb2b1c7238cefa..8fce1d36a79c9f0a4b2aa88023a281d3689d0f21 100644 (file)
@@ -67,6 +67,8 @@ static const struct qlcnic_mailbox_metadata qlcnic_83xx_mbx_tbl[] = {
        {QLCNIC_CMD_ADD_RCV_RINGS, 130, 26},
        {QLCNIC_CMD_CONFIG_VPORT, 4, 4},
        {QLCNIC_CMD_BC_EVENT_SETUP, 2, 1},
+       {QLCNIC_CMD_DCB_QUERY_CAP, 1, 2},
+       {QLCNIC_CMD_DCB_QUERY_PARAM, 2, 50},
 };
 
 const u32 qlcnic_83xx_ext_reg_tbl[] = {
@@ -149,7 +151,7 @@ static struct qlcnic_hardware_ops qlcnic_83xx_hw_ops = {
        .get_mac_address                = qlcnic_83xx_get_mac_address,
        .setup_intr                     = qlcnic_83xx_setup_intr,
        .alloc_mbx_args                 = qlcnic_83xx_alloc_mbx_args,
-       .mbx_cmd                        = qlcnic_83xx_mbx_op,
+       .mbx_cmd                        = qlcnic_83xx_issue_cmd,
        .get_func_no                    = qlcnic_83xx_get_func_no,
        .api_lock                       = qlcnic_83xx_cam_lock,
        .api_unlock                     = qlcnic_83xx_cam_unlock,
@@ -228,17 +230,17 @@ static int __qlcnic_set_win_base(struct qlcnic_adapter *adapter, u32 addr)
        return 0;
 }
 
-int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *adapter, ulong addr)
+int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *adapter, ulong addr,
+                               int *err)
 {
-       int ret;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
 
-       ret = __qlcnic_set_win_base(adapter, (u32) addr);
-       if (!ret) {
+       *err = __qlcnic_set_win_base(adapter, (u32) addr);
+       if (!*err) {
                return QLCRDX(ahw, QLCNIC_WILDCARD);
        } else {
                dev_err(&adapter->pdev->dev,
-                       "%s failed, addr = 0x%x\n", __func__, (int)addr);
+                       "%s failed, addr = 0x%lx\n", __func__, addr);
                return -EIO;
        }
 }
@@ -261,7 +263,7 @@ int qlcnic_83xx_wrt_reg_indirect(struct qlcnic_adapter *adapter, ulong addr,
        }
 }
 
-int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
+int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr, int txq)
 {
        int err, i, num_msix;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
@@ -362,6 +364,10 @@ static inline void qlcnic_83xx_get_mbx_data(struct qlcnic_adapter *adapter,
                                     struct qlcnic_cmd_args *cmd)
 {
        int i;
+
+       if (cmd->op_type == QLC_83XX_MBX_POST_BC_OP)
+               return;
+
        for (i = 0; i < cmd->rsp.num; i++)
                cmd->rsp.arg[i] = readl(QLCNIC_MBX_FW(adapter->ahw, i));
 }
@@ -398,24 +404,33 @@ irqreturn_t qlcnic_83xx_clear_legacy_intr(struct qlcnic_adapter *adapter)
        return IRQ_HANDLED;
 }
 
+static inline void qlcnic_83xx_notify_mbx_response(struct qlcnic_mailbox *mbx)
+{
+       atomic_set(&mbx->rsp_status, QLC_83XX_MBX_RESPONSE_ARRIVED);
+       complete(&mbx->completion);
+}
+
 static void qlcnic_83xx_poll_process_aen(struct qlcnic_adapter *adapter)
 {
-       u32 resp, event;
+       u32 resp, event, rsp_status = QLC_83XX_MBX_RESPONSE_ARRIVED;
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
        unsigned long flags;
 
-       spin_lock_irqsave(&adapter->ahw->mbx_lock, flags);
-
+       spin_lock_irqsave(&mbx->aen_lock, flags);
        resp = QLCRDX(adapter->ahw, QLCNIC_FW_MBX_CTRL);
        if (!(resp & QLCNIC_SET_OWNER))
                goto out;
 
        event = readl(QLCNIC_MBX_FW(adapter->ahw, 0));
-       if (event &  QLCNIC_MBX_ASYNC_EVENT)
+       if (event &  QLCNIC_MBX_ASYNC_EVENT) {
                __qlcnic_83xx_process_aen(adapter);
-
+       } else {
+               if (atomic_read(&mbx->rsp_status) != rsp_status)
+                       qlcnic_83xx_notify_mbx_response(mbx);
+       }
 out:
        qlcnic_83xx_enable_legacy_msix_mbx_intr(adapter);
-       spin_unlock_irqrestore(&adapter->ahw->mbx_lock, flags);
+       spin_unlock_irqrestore(&mbx->aen_lock, flags);
 }
 
 irqreturn_t qlcnic_83xx_intr(int irq, void *data)
@@ -515,7 +530,7 @@ int qlcnic_83xx_setup_mbx_intr(struct qlcnic_adapter *adapter)
        }
 
        /* Enable mailbox interrupt */
-       qlcnic_83xx_enable_mbx_intrpt(adapter);
+       qlcnic_83xx_enable_mbx_interrupt(adapter);
 
        return err;
 }
@@ -561,7 +576,7 @@ void qlcnic_83xx_cam_unlock(struct qlcnic_adapter *adapter)
 void qlcnic_83xx_read_crb(struct qlcnic_adapter *adapter, char *buf,
                          loff_t offset, size_t size)
 {
-       int ret;
+       int ret = 0;
        u32 data;
 
        if (qlcnic_api_lock(adapter)) {
@@ -571,7 +586,7 @@ void qlcnic_83xx_read_crb(struct qlcnic_adapter *adapter, char *buf,
                return;
        }
 
-       ret = qlcnic_83xx_rd_reg_indirect(adapter, (u32) offset);
+       data = QLCRD32(adapter, (u32) offset, &ret);
        qlcnic_api_unlock(adapter);
 
        if (ret == -EIO) {
@@ -580,7 +595,6 @@ void qlcnic_83xx_read_crb(struct qlcnic_adapter *adapter, char *buf,
                        __func__, (u32)offset);
                return;
        }
-       data = ret;
        memcpy(buf, &data, size);
 }
 
@@ -629,7 +643,7 @@ void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *adapter)
        ahw->max_uc_count = count;
 }
 
-void qlcnic_83xx_enable_mbx_intrpt(struct qlcnic_adapter *adapter)
+void qlcnic_83xx_enable_mbx_interrupt(struct qlcnic_adapter *adapter)
 {
        u32 val;
 
@@ -683,11 +697,14 @@ static void qlcnic_83xx_handle_link_aen(struct qlcnic_adapter *adapter,
 static void qlcnic_83xx_handle_idc_comp_aen(struct qlcnic_adapter *adapter,
                                            u32 data[]);
 
-static void qlcnic_dump_mbx(struct qlcnic_adapter *adapter,
-                           struct qlcnic_cmd_args *cmd)
+void qlcnic_dump_mbx(struct qlcnic_adapter *adapter,
+                    struct qlcnic_cmd_args *cmd)
 {
        int i;
 
+       if (cmd->op_type == QLC_83XX_MBX_POST_BC_OP)
+               return;
+
        dev_info(&adapter->pdev->dev,
                 "Host MBX regs(%d)\n", cmd->req.num);
        for (i = 0; i < cmd->req.num; i++) {
@@ -706,120 +723,74 @@ static void qlcnic_dump_mbx(struct qlcnic_adapter *adapter,
        pr_info("\n");
 }
 
-/* Mailbox response for mac rcode */
-u32 qlcnic_83xx_mac_rcode(struct qlcnic_adapter *adapter)
+static inline void
+qlcnic_83xx_poll_for_mbx_completion(struct qlcnic_adapter *adapter,
+                                   struct qlcnic_cmd_args *cmd)
 {
-       u32 fw_data;
-       u8 mac_cmd_rcode;
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       int opcode = LSW(cmd->req.arg[0]);
+       unsigned long max_loops;
 
-       fw_data = readl(QLCNIC_MBX_FW(adapter->ahw, 2));
-       mac_cmd_rcode = (u8)fw_data;
-       if (mac_cmd_rcode == QLC_83XX_NO_NIC_RESOURCE ||
-           mac_cmd_rcode == QLC_83XX_MAC_PRESENT ||
-           mac_cmd_rcode == QLC_83XX_MAC_ABSENT)
-               return QLCNIC_RCODE_SUCCESS;
-       return 1;
-}
+       max_loops = cmd->total_cmds * QLC_83XX_MBX_CMD_LOOP;
 
-u32 qlcnic_83xx_mbx_poll(struct qlcnic_adapter *adapter, u32 *wait_time)
-{
-       u32 data;
-       struct qlcnic_hardware_context *ahw = adapter->ahw;
-       /* wait for mailbox completion */
-       do {
-               data = QLCRDX(ahw, QLCNIC_FW_MBX_CTRL);
-               if (++(*wait_time) > QLCNIC_MBX_TIMEOUT) {
-                       data = QLCNIC_RCODE_TIMEOUT;
-                       break;
-               }
-               mdelay(1);
-       } while (!data);
-       return data;
+       for (; max_loops; max_loops--) {
+               if (atomic_read(&cmd->rsp_status) ==
+                   QLC_83XX_MBX_RESPONSE_ARRIVED)
+                       return;
+
+               udelay(1);
+       }
+
+       dev_err(&adapter->pdev->dev,
+               "%s: Mailbox command timed out, cmd_op=0x%x, cmd_type=0x%x, pci_func=0x%x, op_mode=0x%x\n",
+               __func__, opcode, cmd->type, ahw->pci_func, ahw->op_mode);
+       flush_workqueue(ahw->mailbox->work_q);
+       return;
 }
 
-int qlcnic_83xx_mbx_op(struct qlcnic_adapter *adapter,
-                      struct qlcnic_cmd_args *cmd)
+int qlcnic_83xx_issue_cmd(struct qlcnic_adapter *adapter,
+                         struct qlcnic_cmd_args *cmd)
 {
-       int i;
-       u16 opcode;
-       u8 mbx_err_code;
-       unsigned long flags;
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
-       u32 rsp, mbx_val, fw_data, rsp_num, mbx_cmd, wait_time = 0;
+       int cmd_type, err, opcode;
+       unsigned long timeout;
 
        opcode = LSW(cmd->req.arg[0]);
-       if (!test_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status)) {
-               dev_info(&adapter->pdev->dev,
-                        "Mailbox cmd attempted, 0x%x\n", opcode);
-               dev_info(&adapter->pdev->dev, "Mailbox detached\n");
-               return 0;
+       cmd_type = cmd->type;
+       err = mbx->ops->enqueue_cmd(adapter, cmd, &timeout);
+       if (err) {
+               dev_err(&adapter->pdev->dev,
+                       "%s: Mailbox not available, cmd_op=0x%x, cmd_context=0x%x, pci_func=0x%x, op_mode=0x%x\n",
+                       __func__, opcode, cmd->type, ahw->pci_func,
+                       ahw->op_mode);
+               return err;
        }
 
-       spin_lock_irqsave(&adapter->ahw->mbx_lock, flags);
-       mbx_val = QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL);
-
-       if (mbx_val) {
-               QLCDB(adapter, DRV,
-                     "Mailbox cmd attempted, 0x%x\n", opcode);
-               QLCDB(adapter, DRV,
-                     "Mailbox not available, 0x%x, collect FW dump\n",
-                     mbx_val);
-               cmd->rsp.arg[0] = QLCNIC_RCODE_TIMEOUT;
-               spin_unlock_irqrestore(&adapter->ahw->mbx_lock, flags);
-               return cmd->rsp.arg[0];
-       }
-
-       /* Fill in mailbox registers */
-       mbx_cmd = cmd->req.arg[0];
-       writel(mbx_cmd, QLCNIC_MBX_HOST(ahw, 0));
-       for (i = 1; i < cmd->req.num; i++)
-               writel(cmd->req.arg[i], QLCNIC_MBX_HOST(ahw, i));
-
-       /* Signal FW about the impending command */
-       QLCWRX(ahw, QLCNIC_HOST_MBX_CTRL, QLCNIC_SET_OWNER);
-poll:
-       rsp = qlcnic_83xx_mbx_poll(adapter, &wait_time);
-       if (rsp != QLCNIC_RCODE_TIMEOUT) {
-               /* Get the FW response data */
-               fw_data = readl(QLCNIC_MBX_FW(ahw, 0));
-               if (fw_data &  QLCNIC_MBX_ASYNC_EVENT) {
-                       __qlcnic_83xx_process_aen(adapter);
-                       goto poll;
-               }
-               mbx_err_code = QLCNIC_MBX_STATUS(fw_data);
-               rsp_num = QLCNIC_MBX_NUM_REGS(fw_data);
-               opcode = QLCNIC_MBX_RSP(fw_data);
-               qlcnic_83xx_get_mbx_data(adapter, cmd);
-
-               switch (mbx_err_code) {
-               case QLCNIC_MBX_RSP_OK:
-               case QLCNIC_MBX_PORT_RSP_OK:
-                       rsp = QLCNIC_RCODE_SUCCESS;
-                       break;
-               default:
-                       if (opcode == QLCNIC_CMD_CONFIG_MAC_VLAN) {
-                               rsp = qlcnic_83xx_mac_rcode(adapter);
-                               if (!rsp)
-                                       goto out;
-                       }
+       switch (cmd_type) {
+       case QLC_83XX_MBX_CMD_WAIT:
+               if (!wait_for_completion_timeout(&cmd->completion, timeout)) {
                        dev_err(&adapter->pdev->dev,
-                               "MBX command 0x%x failed with err:0x%x\n",
-                               opcode, mbx_err_code);
-                       rsp = mbx_err_code;
-                       qlcnic_dump_mbx(adapter, cmd);
-                       break;
+                               "%s: Mailbox command timed out, cmd_op=0x%x, cmd_type=0x%x, pci_func=0x%x, op_mode=0x%x\n",
+                               __func__, opcode, cmd_type, ahw->pci_func,
+                               ahw->op_mode);
+                       flush_workqueue(mbx->work_q);
                }
-               goto out;
+               break;
+       case QLC_83XX_MBX_CMD_NO_WAIT:
+               return 0;
+       case QLC_83XX_MBX_CMD_BUSY_WAIT:
+               qlcnic_83xx_poll_for_mbx_completion(adapter, cmd);
+               break;
+       default:
+               dev_err(&adapter->pdev->dev,
+                       "%s: Invalid mailbox command, cmd_op=0x%x, cmd_type=0x%x, pci_func=0x%x, op_mode=0x%x\n",
+                       __func__, opcode, cmd_type, ahw->pci_func,
+                       ahw->op_mode);
+               qlcnic_83xx_detach_mailbox_work(adapter);
        }
 
-       dev_err(&adapter->pdev->dev, "MBX command 0x%x timed out\n",
-               QLCNIC_MBX_RSP(mbx_cmd));
-       rsp = QLCNIC_RCODE_TIMEOUT;
-out:
-       /* clear fw mbx control register */
-       QLCWRX(ahw, QLCNIC_FW_MBX_CTRL, QLCNIC_CLR_OWNER);
-       spin_unlock_irqrestore(&adapter->ahw->mbx_lock, flags);
-       return rsp;
+       return cmd->rsp_opcode;
 }
 
 int qlcnic_83xx_alloc_mbx_args(struct qlcnic_cmd_args *mbx,
@@ -829,6 +800,7 @@ int qlcnic_83xx_alloc_mbx_args(struct qlcnic_cmd_args *mbx,
        u32 temp;
        const struct qlcnic_mailbox_metadata *mbx_tbl;
 
+       memset(mbx, 0, sizeof(struct qlcnic_cmd_args));
        mbx_tbl = qlcnic_83xx_mbx_tbl;
        size = ARRAY_SIZE(qlcnic_83xx_mbx_tbl);
        for (i = 0; i < size; i++) {
@@ -851,6 +823,7 @@ int qlcnic_83xx_alloc_mbx_args(struct qlcnic_cmd_args *mbx,
                        memset(mbx->rsp.arg, 0, sizeof(u32) * mbx->rsp.num);
                        temp = adapter->ahw->fw_hal_version << 29;
                        mbx->req.arg[0] = (type | (mbx->req.num << 16) | temp);
+                       mbx->cmd_op = type;
                        return 0;
                }
        }
@@ -889,9 +862,9 @@ static void qlcnic_83xx_handle_idc_comp_aen(struct qlcnic_adapter *adapter,
 
 void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
 {
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
        u32 event[QLC_83XX_MBX_AEN_CNT];
        int i;
-       struct qlcnic_hardware_context *ahw = adapter->ahw;
 
        for (i = 0; i < QLC_83XX_MBX_AEN_CNT; i++)
                event[i] = readl(QLCNIC_MBX_FW(ahw, i));
@@ -911,6 +884,7 @@ void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
                                   &adapter->idc_aen_work, 0);
                break;
        case QLCNIC_MBX_TIME_EXTEND_EVENT:
+               ahw->extend_lb_time = event[1] >> 8 & 0xf;
                break;
        case QLCNIC_MBX_BC_EVENT:
                qlcnic_sriov_handle_bc_event(adapter, event[1]);
@@ -923,6 +897,9 @@ void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
                dev_info(&adapter->pdev->dev, "SFP Removed AEN:0x%x.\n",
                         QLCNIC_MBX_RSP(event[0]));
                break;
+       case QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT:
+               qlcnic_dcb_handle_aen(adapter, (void *)&event[1]);
+               break;
        default:
                dev_dbg(&adapter->pdev->dev, "Unsupported AEN:0x%x.\n",
                        QLCNIC_MBX_RSP(event[0]));
@@ -934,20 +911,23 @@ void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
 
 static void qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
 {
+       u32 resp, event, rsp_status = QLC_83XX_MBX_RESPONSE_ARRIVED;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
-       u32 resp, event;
+       struct qlcnic_mailbox *mbx = ahw->mailbox;
        unsigned long flags;
 
-       spin_lock_irqsave(&ahw->mbx_lock, flags);
-
+       spin_lock_irqsave(&mbx->aen_lock, flags);
        resp = QLCRDX(ahw, QLCNIC_FW_MBX_CTRL);
        if (resp & QLCNIC_SET_OWNER) {
                event = readl(QLCNIC_MBX_FW(ahw, 0));
-               if (event &  QLCNIC_MBX_ASYNC_EVENT)
+               if (event &  QLCNIC_MBX_ASYNC_EVENT) {
                        __qlcnic_83xx_process_aen(adapter);
+               } else {
+                       if (atomic_read(&mbx->rsp_status) != rsp_status)
+                               qlcnic_83xx_notify_mbx_response(mbx);
+               }
        }
-
-       spin_unlock_irqrestore(&ahw->mbx_lock, flags);
+       spin_unlock_irqrestore(&mbx->aen_lock, flags);
 }
 
 static void qlcnic_83xx_mbx_poll_work(struct work_struct *work)
@@ -970,6 +950,7 @@ void qlcnic_83xx_enable_mbx_poll(struct qlcnic_adapter *adapter)
                return;
 
        INIT_DELAYED_WORK(&adapter->mbx_poll_work, qlcnic_83xx_mbx_poll_work);
+       queue_delayed_work(adapter->qlcnic_wq, &adapter->mbx_poll_work, 0);
 }
 
 void qlcnic_83xx_disable_mbx_poll(struct qlcnic_adapter *adapter)
@@ -1356,8 +1337,10 @@ static int qlcnic_83xx_diag_alloc_res(struct net_device *netdev, int test,
 
        if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) {
                /* disable and free mailbox interrupt */
-               if (!(adapter->flags & QLCNIC_MSIX_ENABLED))
+               if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) {
+                       qlcnic_83xx_enable_mbx_poll(adapter);
                        qlcnic_83xx_free_mbx_intr(adapter);
+               }
                adapter->ahw->loopback_state = 0;
                adapter->ahw->hw_ops->setup_link_event(adapter, 1);
        }
@@ -1378,6 +1361,8 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev,
                for (ring = 0; ring < adapter->max_sds_rings; ring++) {
                        sds_ring = &adapter->recv_ctx->sds_rings[ring];
                        qlcnic_83xx_disable_intr(adapter, sds_ring);
+                       if (!(adapter->flags & QLCNIC_MSIX_ENABLED))
+                               qlcnic_83xx_enable_mbx_poll(adapter);
                }
        }
 
@@ -1387,6 +1372,7 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev,
        if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) {
                if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) {
                        err = qlcnic_83xx_setup_mbx_intr(adapter);
+                       qlcnic_83xx_disable_mbx_poll(adapter);
                        if (err) {
                                dev_err(&adapter->pdev->dev,
                                        "%s: failed to setup mbx interrupt\n",
@@ -1403,6 +1389,10 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev,
 
        if (netif_running(netdev))
                __qlcnic_up(adapter, netdev);
+
+       if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST &&
+           !(adapter->flags & QLCNIC_MSIX_ENABLED))
+               qlcnic_83xx_disable_mbx_poll(adapter);
 out:
        netif_device_attach(netdev);
 }
@@ -1620,26 +1610,33 @@ static void qlcnic_83xx_set_interface_id_promisc(struct qlcnic_adapter *adapter,
 
 int qlcnic_83xx_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode)
 {
-       int err;
+       struct qlcnic_cmd_args *cmd = NULL;
        u32 temp = 0;
-       struct qlcnic_cmd_args cmd;
+       int err;
 
        if (adapter->recv_ctx->state == QLCNIC_HOST_CTX_STATE_FREED)
                return -EIO;
 
-       err = qlcnic_alloc_mbx_args(&cmd, adapter,
+       cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
+       if (!cmd)
+               return -ENOMEM;
+
+       err = qlcnic_alloc_mbx_args(cmd, adapter,
                                    QLCNIC_CMD_CONFIGURE_MAC_RX_MODE);
        if (err)
-               return err;
+               goto out;
 
+       cmd->type = QLC_83XX_MBX_CMD_NO_WAIT;
        qlcnic_83xx_set_interface_id_promisc(adapter, &temp);
-       cmd.req.arg[1] = (mode ? 1 : 0) | temp;
-       err = qlcnic_issue_cmd(adapter, &cmd);
-       if (err)
-               dev_info(&adapter->pdev->dev,
-                        "Promiscous mode config failed\n");
+       cmd->req.arg[1] = (mode ? 1 : 0) | temp;
+       err = qlcnic_issue_cmd(adapter, cmd);
+       if (!err)
+               return err;
 
-       qlcnic_free_mbx_args(&cmd);
+       qlcnic_free_mbx_args(cmd);
+
+out:
+       kfree(cmd);
        return err;
 }
 
@@ -1652,7 +1649,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
        if (ahw->op_mode == QLCNIC_NON_PRIV_FUNC) {
                netdev_warn(netdev,
                            "Loopback test not supported in non privileged mode\n");
-               return ret;
+               return -ENOTSUPP;
        }
 
        if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
@@ -1680,19 +1677,17 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
        /* Poll for link up event before running traffic */
        do {
                msleep(QLC_83XX_LB_MSLEEP_COUNT);
-               if (!(adapter->flags & QLCNIC_MSIX_ENABLED))
-                       qlcnic_83xx_process_aen(adapter);
 
                if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
                        netdev_info(netdev,
                                    "Device is resetting, free LB test resources\n");
-                       ret = -EIO;
+                       ret = -EBUSY;
                        goto free_diag_res;
                }
                if (loop++ > QLC_83XX_LB_WAIT_COUNT) {
                        netdev_info(netdev,
                                    "Firmware didn't sent link up event to loopback request\n");
-                       ret = -QLCNIC_FW_NOT_RESPOND;
+                       ret = -ETIMEDOUT;
                        qlcnic_83xx_clear_lb_mode(adapter, mode);
                        goto free_diag_res;
                }
@@ -1701,7 +1696,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
        /* Make sure carrier is off and queue is stopped during loopback */
        if (netif_running(netdev)) {
                netif_carrier_off(netdev);
-               netif_stop_queue(netdev);
+               netif_tx_stop_all_queues(netdev);
        }
 
        ret = qlcnic_do_lb_test(adapter, mode);
@@ -1717,18 +1712,42 @@ fail_diag_alloc:
        return ret;
 }
 
+static void qlcnic_extend_lb_idc_cmpltn_wait(struct qlcnic_adapter *adapter,
+                                            u32 *max_wait_count)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       int temp;
+
+       netdev_info(adapter->netdev, "Recieved loopback IDC time extend event for 0x%x seconds\n",
+                   ahw->extend_lb_time);
+       temp = ahw->extend_lb_time * 1000;
+       *max_wait_count += temp / QLC_83XX_LB_MSLEEP_COUNT;
+       ahw->extend_lb_time = 0;
+}
+
 int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        struct net_device *netdev = adapter->netdev;
+       u32 config, max_wait_count;
        int status = 0, loop = 0;
-       u32 config;
 
+       ahw->extend_lb_time = 0;
+       max_wait_count = QLC_83XX_LB_WAIT_COUNT;
        status = qlcnic_83xx_get_port_config(adapter);
        if (status)
                return status;
 
        config = ahw->port_config;
+
+       /* Check if port is already in loopback mode */
+       if ((config & QLC_83XX_CFG_LOOPBACK_HSS) ||
+           (config & QLC_83XX_CFG_LOOPBACK_EXT)) {
+               netdev_err(netdev,
+                          "Port already in Loopback mode.\n");
+               return -EINPROGRESS;
+       }
+
        set_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
 
        if (mode == QLCNIC_ILB_MODE)
@@ -1749,21 +1768,24 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
        /* Wait for Link and IDC Completion AEN */
        do {
                msleep(QLC_83XX_LB_MSLEEP_COUNT);
-               if (!(adapter->flags & QLCNIC_MSIX_ENABLED))
-                       qlcnic_83xx_process_aen(adapter);
 
                if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
                        netdev_info(netdev,
                                    "Device is resetting, free LB test resources\n");
                        clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
-                       return -EIO;
+                       return -EBUSY;
                }
-               if (loop++ > QLC_83XX_LB_WAIT_COUNT) {
-                       netdev_err(netdev,
-                                  "Did not receive IDC completion AEN\n");
+
+               if (ahw->extend_lb_time)
+                       qlcnic_extend_lb_idc_cmpltn_wait(adapter,
+                                                        &max_wait_count);
+
+               if (loop++ > max_wait_count) {
+                       netdev_err(netdev, "%s: Did not receive loopback IDC completion AEN\n",
+                                  __func__);
                        clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
                        qlcnic_83xx_clear_lb_mode(adapter, mode);
-                       return -EIO;
+                       return -ETIMEDOUT;
                }
        } while (test_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status));
 
@@ -1775,10 +1797,12 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
 int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
+       u32 config = ahw->port_config, max_wait_count;
        struct net_device *netdev = adapter->netdev;
        int status = 0, loop = 0;
-       u32 config = ahw->port_config;
 
+       ahw->extend_lb_time = 0;
+       max_wait_count = QLC_83XX_LB_WAIT_COUNT;
        set_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
        if (mode == QLCNIC_ILB_MODE)
                ahw->port_config &= ~QLC_83XX_CFG_LOOPBACK_HSS;
@@ -1798,21 +1822,23 @@ int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
        /* Wait for Link and IDC Completion AEN */
        do {
                msleep(QLC_83XX_LB_MSLEEP_COUNT);
-               if (!(adapter->flags & QLCNIC_MSIX_ENABLED))
-                       qlcnic_83xx_process_aen(adapter);
 
                if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
                        netdev_info(netdev,
                                    "Device is resetting, free LB test resources\n");
                        clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
-                       return -EIO;
+                       return -EBUSY;
                }
 
-               if (loop++ > QLC_83XX_LB_WAIT_COUNT) {
-                       netdev_err(netdev,
-                                  "Did not receive IDC completion AEN\n");
+               if (ahw->extend_lb_time)
+                       qlcnic_extend_lb_idc_cmpltn_wait(adapter,
+                                                        &max_wait_count);
+
+               if (loop++ > max_wait_count) {
+                       netdev_err(netdev, "%s: Did not receive loopback IDC completion AEN\n",
+                                  __func__);
                        clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
-                       return -EIO;
+                       return -ETIMEDOUT;
                }
        } while (test_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status));
 
@@ -1951,25 +1977,31 @@ static void qlcnic_83xx_set_interface_id_macaddr(struct qlcnic_adapter *adapter,
 int qlcnic_83xx_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr,
                                   u16 vlan_id, u8 op)
 {
-       int err;
-       u32 *buf, temp = 0;
-       struct qlcnic_cmd_args cmd;
+       struct qlcnic_cmd_args *cmd = NULL;
        struct qlcnic_macvlan_mbx mv;
+       u32 *buf, temp = 0;
+       int err;
 
        if (adapter->recv_ctx->state == QLCNIC_HOST_CTX_STATE_FREED)
                return -EIO;
 
-       err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_CONFIG_MAC_VLAN);
+       cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
+       if (!cmd)
+               return -ENOMEM;
+
+       err = qlcnic_alloc_mbx_args(cmd, adapter, QLCNIC_CMD_CONFIG_MAC_VLAN);
        if (err)
-               return err;
+               goto out;
+
+       cmd->type = QLC_83XX_MBX_CMD_NO_WAIT;
 
        if (vlan_id)
                op = (op == QLCNIC_MAC_ADD || op == QLCNIC_MAC_VLAN_ADD) ?
                     QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_VLAN_DEL;
 
-       cmd.req.arg[1] = op | (1 << 8);
+       cmd->req.arg[1] = op | (1 << 8);
        qlcnic_83xx_set_interface_id_macaddr(adapter, &temp);
-       cmd.req.arg[1] |= temp;
+       cmd->req.arg[1] |= temp;
        mv.vlan = vlan_id;
        mv.mac_addr0 = addr[0];
        mv.mac_addr1 = addr[1];
@@ -1977,14 +2009,15 @@ int qlcnic_83xx_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr,
        mv.mac_addr3 = addr[3];
        mv.mac_addr4 = addr[4];
        mv.mac_addr5 = addr[5];
-       buf = &cmd.req.arg[2];
+       buf = &cmd->req.arg[2];
        memcpy(buf, &mv, sizeof(struct qlcnic_macvlan_mbx));
-       err = qlcnic_issue_cmd(adapter, &cmd);
-       if (err)
-               dev_err(&adapter->pdev->dev,
-                       "MAC-VLAN %s to CAM failed, err=%d.\n",
-                       ((op == 1) ? "add " : "delete "), err);
-       qlcnic_free_mbx_args(&cmd);
+       err = qlcnic_issue_cmd(adapter, cmd);
+       if (!err)
+               return err;
+
+       qlcnic_free_mbx_args(cmd);
+out:
+       kfree(cmd);
        return err;
 }
 
@@ -2009,12 +2042,14 @@ void qlcnic_83xx_configure_mac(struct qlcnic_adapter *adapter, u8 *mac,
        cmd->req.arg[1] = type;
 }
 
-int qlcnic_83xx_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac)
+int qlcnic_83xx_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac,
+                               u8 function)
 {
        int err, i;
        struct qlcnic_cmd_args cmd;
        u32 mac_low, mac_high;
 
+       function = 0;
        err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_MAC_ADDRESS);
        if (err)
                return err;
@@ -2075,28 +2110,37 @@ void qlcnic_83xx_config_intr_coal(struct qlcnic_adapter *adapter)
 static void qlcnic_83xx_handle_link_aen(struct qlcnic_adapter *adapter,
                                        u32 data[])
 {
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
        u8 link_status, duplex;
        /* link speed */
        link_status = LSB(data[3]) & 1;
-       adapter->ahw->link_speed = MSW(data[2]);
-       adapter->ahw->link_autoneg = MSB(MSW(data[3]));
-       adapter->ahw->module_type = MSB(LSW(data[3]));
-       duplex = LSB(MSW(data[3]));
-       if (duplex)
-               adapter->ahw->link_duplex = DUPLEX_FULL;
-       else
-               adapter->ahw->link_duplex = DUPLEX_HALF;
-       adapter->ahw->has_link_events = 1;
+       if (link_status) {
+               ahw->link_speed = MSW(data[2]);
+               duplex = LSB(MSW(data[3]));
+               if (duplex)
+                       ahw->link_duplex = DUPLEX_FULL;
+               else
+                       ahw->link_duplex = DUPLEX_HALF;
+       } else {
+               ahw->link_speed = SPEED_UNKNOWN;
+               ahw->link_duplex = DUPLEX_UNKNOWN;
+       }
+
+       ahw->link_autoneg = MSB(MSW(data[3]));
+       ahw->module_type = MSB(LSW(data[3]));
+       ahw->has_link_events = 1;
        qlcnic_advert_link_change(adapter, link_status);
 }
 
 irqreturn_t qlcnic_83xx_handle_aen(int irq, void *data)
 {
        struct qlcnic_adapter *adapter = data;
-       unsigned long flags;
+       struct qlcnic_mailbox *mbx;
        u32 mask, resp, event;
+       unsigned long flags;
 
-       spin_lock_irqsave(&adapter->ahw->mbx_lock, flags);
+       mbx = adapter->ahw->mailbox;
+       spin_lock_irqsave(&mbx->aen_lock, flags);
        resp = QLCRDX(adapter->ahw, QLCNIC_FW_MBX_CTRL);
        if (!(resp & QLCNIC_SET_OWNER))
                goto out;
@@ -2104,11 +2148,13 @@ irqreturn_t qlcnic_83xx_handle_aen(int irq, void *data)
        event = readl(QLCNIC_MBX_FW(adapter->ahw, 0));
        if (event &  QLCNIC_MBX_ASYNC_EVENT)
                __qlcnic_83xx_process_aen(adapter);
+       else
+               qlcnic_83xx_notify_mbx_response(mbx);
+
 out:
        mask = QLCRDX(adapter->ahw, QLCNIC_DEF_INT_MASK);
        writel(0, adapter->ahw->pci_base0 + mask);
-       spin_unlock_irqrestore(&adapter->ahw->mbx_lock, flags);
-
+       spin_unlock_irqrestore(&mbx->aen_lock, flags);
        return IRQ_HANDLED;
 }
 
@@ -2384,9 +2430,9 @@ int qlcnic_83xx_lockless_flash_read32(struct qlcnic_adapter *adapter,
                                      u32 flash_addr, u8 *p_data,
                                      int count)
 {
-       int i, ret;
-       u32 word, range, flash_offset, addr = flash_addr;
+       u32 word, range, flash_offset, addr = flash_addr, ret;
        ulong indirect_add, direct_window;
+       int i, err = 0;
 
        flash_offset = addr & (QLCNIC_FLASH_SECTOR_SIZE - 1);
        if (addr & 0x3) {
@@ -2404,10 +2450,9 @@ int qlcnic_83xx_lockless_flash_read32(struct qlcnic_adapter *adapter,
                /* Multi sector read */
                for (i = 0; i < count; i++) {
                        indirect_add = QLC_83XX_FLASH_DIRECT_DATA(addr);
-                       ret = qlcnic_83xx_rd_reg_indirect(adapter,
-                                                         indirect_add);
-                       if (ret == -EIO)
-                               return -EIO;
+                       ret = QLCRD32(adapter, indirect_add, &err);
+                       if (err == -EIO)
+                               return err;
 
                        word = ret;
                        *(u32 *)p_data  = word;
@@ -2428,10 +2473,9 @@ int qlcnic_83xx_lockless_flash_read32(struct qlcnic_adapter *adapter,
                /* Single sector read */
                for (i = 0; i < count; i++) {
                        indirect_add = QLC_83XX_FLASH_DIRECT_DATA(addr);
-                       ret = qlcnic_83xx_rd_reg_indirect(adapter,
-                                                         indirect_add);
-                       if (ret == -EIO)
-                               return -EIO;
+                       ret = QLCRD32(adapter, indirect_add, &err);
+                       if (err == -EIO)
+                               return err;
 
                        word = ret;
                        *(u32 *)p_data  = word;
@@ -2447,10 +2491,13 @@ static int qlcnic_83xx_poll_flash_status_reg(struct qlcnic_adapter *adapter)
 {
        u32 status;
        int retries = QLC_83XX_FLASH_READ_RETRY_COUNT;
+       int err = 0;
 
        do {
-               status = qlcnic_83xx_rd_reg_indirect(adapter,
-                                                    QLC_83XX_FLASH_STATUS);
+               status = QLCRD32(adapter, QLC_83XX_FLASH_STATUS, &err);
+               if (err == -EIO)
+                       return err;
+
                if ((status & QLC_83XX_FLASH_STATUS_READY) ==
                    QLC_83XX_FLASH_STATUS_READY)
                        break;
@@ -2502,7 +2549,8 @@ int qlcnic_83xx_disable_flash_write(struct qlcnic_adapter *adapter)
 
 int qlcnic_83xx_read_flash_mfg_id(struct qlcnic_adapter *adapter)
 {
-       int ret, mfg_id;
+       int ret, err = 0;
+       u32 mfg_id;
 
        if (qlcnic_83xx_lock_flash(adapter))
                return -EIO;
@@ -2517,9 +2565,11 @@ int qlcnic_83xx_read_flash_mfg_id(struct qlcnic_adapter *adapter)
                return -EIO;
        }
 
-       mfg_id = qlcnic_83xx_rd_reg_indirect(adapter, QLC_83XX_FLASH_RDDATA);
-       if (mfg_id == -EIO)
-               return -EIO;
+       mfg_id = QLCRD32(adapter, QLC_83XX_FLASH_RDDATA, &err);
+       if (err == -EIO) {
+               qlcnic_83xx_unlock_flash(adapter);
+               return err;
+       }
 
        adapter->flash_mfg_id = (mfg_id & 0xFF);
        qlcnic_83xx_unlock_flash(adapter);
@@ -2636,7 +2686,7 @@ int qlcnic_83xx_flash_bulk_write(struct qlcnic_adapter *adapter, u32 addr,
                                 u32 *p_data, int count)
 {
        u32 temp;
-       int ret = -EIO;
+       int ret = -EIO, err = 0;
 
        if ((count < QLC_83XX_FLASH_WRITE_MIN) ||
            (count > QLC_83XX_FLASH_WRITE_MAX)) {
@@ -2645,8 +2695,10 @@ int qlcnic_83xx_flash_bulk_write(struct qlcnic_adapter *adapter, u32 addr,
                return -EIO;
        }
 
-       temp = qlcnic_83xx_rd_reg_indirect(adapter,
-                                          QLC_83XX_FLASH_SPI_CONTROL);
+       temp = QLCRD32(adapter, QLC_83XX_FLASH_SPI_CONTROL, &err);
+       if (err == -EIO)
+               return err;
+
        qlcnic_83xx_wrt_reg_indirect(adapter, QLC_83XX_FLASH_SPI_CONTROL,
                                     (temp | QLC_83XX_FLASH_SPI_CTRL));
        qlcnic_83xx_wrt_reg_indirect(adapter, QLC_83XX_FLASH_ADDR,
@@ -2695,13 +2747,18 @@ int qlcnic_83xx_flash_bulk_write(struct qlcnic_adapter *adapter, u32 addr,
                return -EIO;
        }
 
-       ret = qlcnic_83xx_rd_reg_indirect(adapter, QLC_83XX_FLASH_SPI_STATUS);
+       ret = QLCRD32(adapter, QLC_83XX_FLASH_SPI_STATUS, &err);
+       if (err == -EIO)
+               return err;
+
        if ((ret & QLC_83XX_FLASH_SPI_CTRL) == QLC_83XX_FLASH_SPI_CTRL) {
                dev_err(&adapter->pdev->dev, "%s: failed at %d\n",
                        __func__, __LINE__);
                /* Operation failed, clear error bit */
-               temp = qlcnic_83xx_rd_reg_indirect(adapter,
-                                                  QLC_83XX_FLASH_SPI_CONTROL);
+               temp = QLCRD32(adapter, QLC_83XX_FLASH_SPI_CONTROL, &err);
+               if (err == -EIO)
+                       return err;
+
                qlcnic_83xx_wrt_reg_indirect(adapter,
                                             QLC_83XX_FLASH_SPI_CONTROL,
                                             (temp | QLC_83XX_FLASH_SPI_CTRL));
@@ -2823,6 +2880,7 @@ int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *adapter, u64 addr,
 {
        int i, j, ret = 0;
        u32 temp;
+       int err = 0;
 
        /* Check alignment */
        if (addr & 0xF)
@@ -2855,8 +2913,12 @@ int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *adapter, u64 addr,
                                             QLCNIC_TA_WRITE_START);
 
                for (j = 0; j < MAX_CTL_CHECK; j++) {
-                       temp = qlcnic_83xx_rd_reg_indirect(adapter,
-                                                          QLCNIC_MS_CTRL);
+                       temp = QLCRD32(adapter, QLCNIC_MS_CTRL, &err);
+                       if (err == -EIO) {
+                               mutex_unlock(&adapter->ahw->mem_lock);
+                               return err;
+                       }
+
                        if ((temp & TA_CTL_BUSY) == 0)
                                break;
                }
@@ -2878,9 +2940,9 @@ int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *adapter, u64 addr,
 int qlcnic_83xx_flash_read32(struct qlcnic_adapter *adapter, u32 flash_addr,
                             u8 *p_data, int count)
 {
-       int i, ret;
-       u32 word, addr = flash_addr;
+       u32 word, addr = flash_addr, ret;
        ulong  indirect_addr;
+       int i, err = 0;
 
        if (qlcnic_83xx_lock_flash(adapter) != 0)
                return -EIO;
@@ -2900,10 +2962,10 @@ int qlcnic_83xx_flash_read32(struct qlcnic_adapter *adapter, u32 flash_addr,
                }
 
                indirect_addr = QLC_83XX_FLASH_DIRECT_DATA(addr);
-               ret = qlcnic_83xx_rd_reg_indirect(adapter,
-                                                 indirect_addr);
-               if (ret == -EIO)
-                       return -EIO;
+               ret = QLCRD32(adapter, indirect_addr, &err);
+               if (err == -EIO)
+                       return err;
+
                word = ret;
                *(u32 *)p_data  = word;
                p_data = p_data + 4;
@@ -3014,8 +3076,8 @@ int qlcnic_83xx_get_settings(struct qlcnic_adapter *adapter,
        }
 
        if (ahw->port_type == QLCNIC_XGBE) {
-               ecmd->supported = SUPPORTED_1000baseT_Full;
-               ecmd->advertising = ADVERTISED_1000baseT_Full;
+               ecmd->supported = SUPPORTED_10000baseT_Full;
+               ecmd->advertising = ADVERTISED_10000baseT_Full;
        } else {
                ecmd->supported = (SUPPORTED_10baseT_Half |
                                   SUPPORTED_10baseT_Full |
@@ -3244,6 +3306,11 @@ int qlcnic_83xx_interrupt_test(struct net_device *netdev)
        u8 val;
        int ret, max_sds_rings = adapter->max_sds_rings;
 
+       if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
+               netdev_info(netdev, "Device is resetting\n");
+               return -EBUSY;
+       }
+
        if (qlcnic_get_diag_lock(adapter)) {
                netdev_info(netdev, "Device in diagnostics mode\n");
                return -EBUSY;
@@ -3369,7 +3436,8 @@ int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *adapter,
 
 static int qlcnic_83xx_read_flash_status_reg(struct qlcnic_adapter *adapter)
 {
-       int ret;
+       int ret, err = 0;
+       u32 temp;
 
        qlcnic_83xx_wrt_reg_indirect(adapter, QLC_83XX_FLASH_ADDR,
                                     QLC_83XX_FLASH_OEM_READ_SIG);
@@ -3379,8 +3447,11 @@ static int qlcnic_83xx_read_flash_status_reg(struct qlcnic_adapter *adapter)
        if (ret)
                return -EIO;
 
-       ret = qlcnic_83xx_rd_reg_indirect(adapter, QLC_83XX_FLASH_RDDATA);
-       return ret & 0xFF;
+       temp = QLCRD32(adapter, QLC_83XX_FLASH_RDDATA, &err);
+       if (err == -EIO)
+               return err;
+
+       return temp & 0xFF;
 }
 
 int qlcnic_83xx_flash_test(struct qlcnic_adapter *adapter)
@@ -3446,3 +3517,306 @@ int qlcnic_83xx_resume(struct qlcnic_adapter *adapter)
                             idc->delay);
        return err;
 }
+
+void qlcnic_83xx_reinit_mbx_work(struct qlcnic_mailbox *mbx)
+{
+       INIT_COMPLETION(mbx->completion);
+       set_bit(QLC_83XX_MBX_READY, &mbx->status);
+}
+
+void qlcnic_83xx_free_mailbox(struct qlcnic_mailbox *mbx)
+{
+       destroy_workqueue(mbx->work_q);
+       kfree(mbx);
+}
+
+static inline void
+qlcnic_83xx_notify_cmd_completion(struct qlcnic_adapter *adapter,
+                                 struct qlcnic_cmd_args *cmd)
+{
+       atomic_set(&cmd->rsp_status, QLC_83XX_MBX_RESPONSE_ARRIVED);
+
+       if (cmd->type == QLC_83XX_MBX_CMD_NO_WAIT) {
+               qlcnic_free_mbx_args(cmd);
+               kfree(cmd);
+               return;
+       }
+       complete(&cmd->completion);
+}
+
+static inline void qlcnic_83xx_flush_mbx_queue(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
+       struct list_head *head = &mbx->cmd_q;
+       struct qlcnic_cmd_args *cmd = NULL;
+
+       spin_lock(&mbx->queue_lock);
+
+       while (!list_empty(head)) {
+               cmd = list_entry(head->next, struct qlcnic_cmd_args, list);
+               dev_info(&adapter->pdev->dev, "%s: Mailbox command 0x%x\n",
+                        __func__, cmd->cmd_op);
+               list_del(&cmd->list);
+               mbx->num_cmds--;
+               qlcnic_83xx_notify_cmd_completion(adapter, cmd);
+       }
+
+       spin_unlock(&mbx->queue_lock);
+}
+
+static inline int qlcnic_83xx_check_mbx_status(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_mailbox *mbx = ahw->mailbox;
+       u32 host_mbx_ctrl;
+
+       if (!test_bit(QLC_83XX_MBX_READY, &mbx->status))
+               return -EBUSY;
+
+       host_mbx_ctrl = QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL);
+       if (host_mbx_ctrl) {
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
+               ahw->idc.collect_dump = 1;
+               return -EIO;
+       }
+
+       return 0;
+}
+
+static inline void qlcnic_83xx_signal_mbx_cmd(struct qlcnic_adapter *adapter,
+                                             u8 issue_cmd)
+{
+       if (issue_cmd)
+               QLCWRX(adapter->ahw, QLCNIC_HOST_MBX_CTRL, QLCNIC_SET_OWNER);
+       else
+               QLCWRX(adapter->ahw, QLCNIC_FW_MBX_CTRL, QLCNIC_CLR_OWNER);
+}
+
+static inline void qlcnic_83xx_dequeue_mbx_cmd(struct qlcnic_adapter *adapter,
+                                              struct qlcnic_cmd_args *cmd)
+{
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
+
+       spin_lock(&mbx->queue_lock);
+
+       list_del(&cmd->list);
+       mbx->num_cmds--;
+
+       spin_unlock(&mbx->queue_lock);
+
+       qlcnic_83xx_notify_cmd_completion(adapter, cmd);
+}
+
+static void qlcnic_83xx_encode_mbx_cmd(struct qlcnic_adapter *adapter,
+                                      struct qlcnic_cmd_args *cmd)
+{
+       u32 mbx_cmd, fw_hal_version, hdr_size, total_size, tmp;
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       int i, j;
+
+       if (cmd->op_type != QLC_83XX_MBX_POST_BC_OP) {
+               mbx_cmd = cmd->req.arg[0];
+               writel(mbx_cmd, QLCNIC_MBX_HOST(ahw, 0));
+               for (i = 1; i < cmd->req.num; i++)
+                       writel(cmd->req.arg[i], QLCNIC_MBX_HOST(ahw, i));
+       } else {
+               fw_hal_version = ahw->fw_hal_version;
+               hdr_size = sizeof(struct qlcnic_bc_hdr) / sizeof(u32);
+               total_size = cmd->pay_size + hdr_size;
+               tmp = QLCNIC_CMD_BC_EVENT_SETUP | total_size << 16;
+               mbx_cmd = tmp | fw_hal_version << 29;
+               writel(mbx_cmd, QLCNIC_MBX_HOST(ahw, 0));
+
+               /* Back channel specific operations bits */
+               mbx_cmd = 0x1 | 1 << 4;
+
+               if (qlcnic_sriov_pf_check(adapter))
+                       mbx_cmd |= cmd->func_num << 5;
+
+               writel(mbx_cmd, QLCNIC_MBX_HOST(ahw, 1));
+
+               for (i = 2, j = 0; j < hdr_size; i++, j++)
+                       writel(*(cmd->hdr++), QLCNIC_MBX_HOST(ahw, i));
+               for (j = 0; j < cmd->pay_size; j++, i++)
+                       writel(*(cmd->pay++), QLCNIC_MBX_HOST(ahw, i));
+       }
+}
+
+void qlcnic_83xx_detach_mailbox_work(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
+
+       clear_bit(QLC_83XX_MBX_READY, &mbx->status);
+       complete(&mbx->completion);
+       cancel_work_sync(&mbx->work);
+       flush_workqueue(mbx->work_q);
+       qlcnic_83xx_flush_mbx_queue(adapter);
+}
+
+static inline int qlcnic_83xx_enqueue_mbx_cmd(struct qlcnic_adapter *adapter,
+                                             struct qlcnic_cmd_args *cmd,
+                                             unsigned long *timeout)
+{
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
+
+       if (test_bit(QLC_83XX_MBX_READY, &mbx->status)) {
+               atomic_set(&cmd->rsp_status, QLC_83XX_MBX_RESPONSE_WAIT);
+               init_completion(&cmd->completion);
+               cmd->rsp_opcode = QLC_83XX_MBX_RESPONSE_UNKNOWN;
+
+               spin_lock(&mbx->queue_lock);
+
+               list_add_tail(&cmd->list, &mbx->cmd_q);
+               mbx->num_cmds++;
+               cmd->total_cmds = mbx->num_cmds;
+               *timeout = cmd->total_cmds * QLC_83XX_MBX_TIMEOUT;
+               queue_work(mbx->work_q, &mbx->work);
+
+               spin_unlock(&mbx->queue_lock);
+
+               return 0;
+       }
+
+       return -EBUSY;
+}
+
+static inline int qlcnic_83xx_check_mac_rcode(struct qlcnic_adapter *adapter,
+                                             struct qlcnic_cmd_args *cmd)
+{
+       u8 mac_cmd_rcode;
+       u32 fw_data;
+
+       if (cmd->cmd_op == QLCNIC_CMD_CONFIG_MAC_VLAN) {
+               fw_data = readl(QLCNIC_MBX_FW(adapter->ahw, 2));
+               mac_cmd_rcode = (u8)fw_data;
+               if (mac_cmd_rcode == QLC_83XX_NO_NIC_RESOURCE ||
+                   mac_cmd_rcode == QLC_83XX_MAC_PRESENT ||
+                   mac_cmd_rcode == QLC_83XX_MAC_ABSENT) {
+                       cmd->rsp_opcode = QLCNIC_RCODE_SUCCESS;
+                       return QLCNIC_RCODE_SUCCESS;
+               }
+       }
+
+       return -EINVAL;
+}
+
+static void qlcnic_83xx_decode_mbx_rsp(struct qlcnic_adapter *adapter,
+                                      struct qlcnic_cmd_args *cmd)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct device *dev = &adapter->pdev->dev;
+       u8 mbx_err_code;
+       u32 fw_data;
+
+       fw_data = readl(QLCNIC_MBX_FW(ahw, 0));
+       mbx_err_code = QLCNIC_MBX_STATUS(fw_data);
+       qlcnic_83xx_get_mbx_data(adapter, cmd);
+
+       switch (mbx_err_code) {
+       case QLCNIC_MBX_RSP_OK:
+       case QLCNIC_MBX_PORT_RSP_OK:
+               cmd->rsp_opcode = QLCNIC_RCODE_SUCCESS;
+               break;
+       default:
+               if (!qlcnic_83xx_check_mac_rcode(adapter, cmd))
+                       break;
+
+               dev_err(dev, "%s: Mailbox command failed, opcode=0x%x, cmd_type=0x%x, func=0x%x, op_mode=0x%x, error=0x%x\n",
+                       __func__, cmd->cmd_op, cmd->type, ahw->pci_func,
+                       ahw->op_mode, mbx_err_code);
+               cmd->rsp_opcode = QLC_83XX_MBX_RESPONSE_FAILED;
+               qlcnic_dump_mbx(adapter, cmd);
+       }
+
+       return;
+}
+
+static void qlcnic_83xx_mailbox_worker(struct work_struct *work)
+{
+       struct qlcnic_mailbox *mbx = container_of(work, struct qlcnic_mailbox,
+                                                 work);
+       struct qlcnic_adapter *adapter = mbx->adapter;
+       struct qlcnic_mbx_ops *mbx_ops = mbx->ops;
+       struct device *dev = &adapter->pdev->dev;
+       atomic_t *rsp_status = &mbx->rsp_status;
+       struct list_head *head = &mbx->cmd_q;
+       struct qlcnic_hardware_context *ahw;
+       struct qlcnic_cmd_args *cmd = NULL;
+
+       ahw = adapter->ahw;
+
+       while (true) {
+               if (qlcnic_83xx_check_mbx_status(adapter)) {
+                       qlcnic_83xx_flush_mbx_queue(adapter);
+                       return;
+               }
+
+               atomic_set(rsp_status, QLC_83XX_MBX_RESPONSE_WAIT);
+
+               spin_lock(&mbx->queue_lock);
+
+               if (list_empty(head)) {
+                       spin_unlock(&mbx->queue_lock);
+                       return;
+               }
+               cmd = list_entry(head->next, struct qlcnic_cmd_args, list);
+
+               spin_unlock(&mbx->queue_lock);
+
+               mbx_ops->encode_cmd(adapter, cmd);
+               mbx_ops->nofity_fw(adapter, QLC_83XX_MBX_REQUEST);
+
+               if (wait_for_completion_timeout(&mbx->completion,
+                                               QLC_83XX_MBX_TIMEOUT)) {
+                       mbx_ops->decode_resp(adapter, cmd);
+                       mbx_ops->nofity_fw(adapter, QLC_83XX_MBX_COMPLETION);
+               } else {
+                       dev_err(dev, "%s: Mailbox command timeout, opcode=0x%x, cmd_type=0x%x, func=0x%x, op_mode=0x%x\n",
+                               __func__, cmd->cmd_op, cmd->type, ahw->pci_func,
+                               ahw->op_mode);
+                       clear_bit(QLC_83XX_MBX_READY, &mbx->status);
+                       qlcnic_dump_mbx(adapter, cmd);
+                       qlcnic_83xx_idc_request_reset(adapter,
+                                                     QLCNIC_FORCE_FW_DUMP_KEY);
+                       cmd->rsp_opcode = QLCNIC_RCODE_TIMEOUT;
+               }
+               mbx_ops->dequeue_cmd(adapter, cmd);
+       }
+}
+
+static struct qlcnic_mbx_ops qlcnic_83xx_mbx_ops = {
+       .enqueue_cmd    = qlcnic_83xx_enqueue_mbx_cmd,
+       .dequeue_cmd    = qlcnic_83xx_dequeue_mbx_cmd,
+       .decode_resp    = qlcnic_83xx_decode_mbx_rsp,
+       .encode_cmd     = qlcnic_83xx_encode_mbx_cmd,
+       .nofity_fw      = qlcnic_83xx_signal_mbx_cmd,
+};
+
+int qlcnic_83xx_init_mailbox_work(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_mailbox *mbx;
+
+       ahw->mailbox = kzalloc(sizeof(*mbx), GFP_KERNEL);
+       if (!ahw->mailbox)
+               return -ENOMEM;
+
+       mbx = ahw->mailbox;
+       mbx->ops = &qlcnic_83xx_mbx_ops;
+       mbx->adapter = adapter;
+
+       spin_lock_init(&mbx->queue_lock);
+       spin_lock_init(&mbx->aen_lock);
+       INIT_LIST_HEAD(&mbx->cmd_q);
+       init_completion(&mbx->completion);
+
+       mbx->work_q = create_singlethread_workqueue("qlcnic_mailbox");
+       if (mbx->work_q == NULL) {
+               kfree(mbx);
+               return -ENOMEM;
+       }
+
+       INIT_WORK(&mbx->work, qlcnic_83xx_mailbox_worker);
+       set_bit(QLC_83XX_MBX_READY, &mbx->status);
+       return 0;
+}
index 2548d1403d75a7668434d53db5013f3969dd8f78..0fc56160d5844b06f67da66f06fc18aed1dcf222 100644 (file)
 /* Firmware image definitions */
 #define QLC_83XX_BOOTLOADER_FLASH_ADDR 0x10000
 #define QLC_83XX_FW_FILE_NAME          "83xx_fw.bin"
+#define QLC_84XX_FW_FILE_NAME          "84xx_fw.bin"
 #define QLC_83XX_BOOT_FROM_FLASH       0
 #define QLC_83XX_BOOT_FROM_FILE                0x12345678
 
+#define QLC_FW_FILE_NAME_LEN           20
 #define QLC_83XX_MAX_RESET_SEQ_ENTRIES 16
 
+#define QLC_83XX_MBX_POST_BC_OP                0x1
+#define QLC_83XX_MBX_COMPLETION                0x0
+#define QLC_83XX_MBX_REQUEST           0x1
+
+#define QLC_83XX_MBX_TIMEOUT           (5 * HZ)
+#define QLC_83XX_MBX_CMD_LOOP          5000000
+
 /* status descriptor mailbox data
  * @phy_addr_{low|high}: physical address of buffer
  * @sds_ring_size: buffer size
@@ -397,6 +406,7 @@ enum qlcnic_83xx_states {
 #define QLC_83XX_MAX_MC_COUNT                  38
 #define QLC_83XX_MAX_UC_COUNT                  4096
 
+#define QLC_83XX_PVID_STRIP_CAPABILITY         BIT_22
 #define QLC_83XX_GET_FUNC_MODE_FROM_NPAR_INFO(val)     (val & 0x80000000)
 #define QLC_83XX_GET_LRO_CAPABILITY(val)               (val & 0x20)
 #define QLC_83XX_GET_LSO_CAPABILITY(val)               (val & 0x40)
@@ -449,6 +459,20 @@ enum qlcnic_83xx_states {
 #define QLC_83xx_FLASH_MAX_WAIT_USEC           100
 #define QLC_83XX_FLASH_LOCK_TIMEOUT            10000
 
+enum qlc_83xx_mbx_cmd_type {
+       QLC_83XX_MBX_CMD_WAIT = 0,
+       QLC_83XX_MBX_CMD_NO_WAIT,
+       QLC_83XX_MBX_CMD_BUSY_WAIT,
+};
+
+enum qlc_83xx_mbx_response_states {
+       QLC_83XX_MBX_RESPONSE_WAIT = 0,
+       QLC_83XX_MBX_RESPONSE_ARRIVED,
+};
+
+#define QLC_83XX_MBX_RESPONSE_FAILED   0x2
+#define QLC_83XX_MBX_RESPONSE_UNKNOWN  0x3
+
 /* Additional registers in 83xx */
 enum qlc_83xx_ext_regs {
        QLCNIC_GLOBAL_RESET = 0,
@@ -498,8 +522,8 @@ enum qlc_83xx_ext_regs {
 
 /* 83xx funcitons */
 int qlcnic_83xx_get_fw_version(struct qlcnic_adapter *);
-int qlcnic_83xx_mbx_op(struct qlcnic_adapter *, struct qlcnic_cmd_args *);
-int qlcnic_83xx_setup_intr(struct qlcnic_adapter *, u8);
+int qlcnic_83xx_issue_cmd(struct qlcnic_adapter *, struct qlcnic_cmd_args *);
+int qlcnic_83xx_setup_intr(struct qlcnic_adapter *, u8, int);
 void qlcnic_83xx_get_func_no(struct qlcnic_adapter *);
 int qlcnic_83xx_cam_lock(struct qlcnic_adapter *);
 void qlcnic_83xx_cam_unlock(struct qlcnic_adapter *);
@@ -508,7 +532,7 @@ void qlcnic_83xx_add_sysfs(struct qlcnic_adapter *);
 void qlcnic_83xx_remove_sysfs(struct qlcnic_adapter *);
 void qlcnic_83xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
 void qlcnic_83xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
-int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *, ulong);
+int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *, ulong, int *);
 int qlcnic_83xx_wrt_reg_indirect(struct qlcnic_adapter *, ulong, u32);
 void qlcnic_83xx_process_rcv_diag(struct qlcnic_adapter *, int, u64 []);
 int qlcnic_83xx_nic_set_promisc(struct qlcnic_adapter *, u32);
@@ -540,7 +564,7 @@ int qlcnic_83xx_setup_link_event(struct qlcnic_adapter *, int);
 void qlcnic_83xx_process_rcv_ring_diag(struct qlcnic_host_sds_ring *);
 int qlcnic_83xx_config_intrpt(struct qlcnic_adapter *, bool);
 int qlcnic_83xx_sre_macaddr_change(struct qlcnic_adapter *, u8 *, u16, u8);
-int qlcnic_83xx_get_mac_address(struct qlcnic_adapter *, u8 *);
+int qlcnic_83xx_get_mac_address(struct qlcnic_adapter *, u8 *, u8);
 void qlcnic_83xx_configure_mac(struct qlcnic_adapter *, u8 *, u8,
                               struct qlcnic_cmd_args *);
 int qlcnic_83xx_alloc_mbx_args(struct qlcnic_cmd_args *,
@@ -551,7 +575,7 @@ void qlcnic_set_npar_data(struct qlcnic_adapter *, const struct qlcnic_info *,
 void qlcnic_83xx_config_intr_coal(struct qlcnic_adapter *);
 irqreturn_t qlcnic_83xx_handle_aen(int, void *);
 int qlcnic_83xx_get_port_info(struct qlcnic_adapter *);
-void qlcnic_83xx_enable_mbx_intrpt(struct qlcnic_adapter *);
+void qlcnic_83xx_enable_mbx_interrupt(struct qlcnic_adapter *);
 void qlcnic_83xx_disable_mbx_intr(struct qlcnic_adapter *);
 irqreturn_t qlcnic_83xx_clear_legacy_intr(struct qlcnic_adapter *);
 irqreturn_t qlcnic_83xx_intr(int, void *);
@@ -623,8 +647,6 @@ int qlcnic_83xx_set_led(struct net_device *, enum ethtool_phys_id_state);
 int qlcnic_83xx_flash_test(struct qlcnic_adapter *);
 int qlcnic_83xx_enable_flash_write(struct qlcnic_adapter *);
 int qlcnic_83xx_disable_flash_write(struct qlcnic_adapter *);
-u32 qlcnic_83xx_mac_rcode(struct qlcnic_adapter *);
-u32 qlcnic_83xx_mbx_poll(struct qlcnic_adapter *, u32 *);
 void qlcnic_83xx_enable_mbx_poll(struct qlcnic_adapter *);
 void qlcnic_83xx_disable_mbx_poll(struct qlcnic_adapter *);
 void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *);
index f41dfab1e9a35d3fc4b3d72c820b2d5db84f59e0..a969ac27633c601743122f7bc8bd8e52bc1489e4 100644 (file)
@@ -399,6 +399,7 @@ static void qlcnic_83xx_idc_detach_driver(struct qlcnic_adapter *adapter)
        struct net_device *netdev = adapter->netdev;
 
        netif_device_detach(netdev);
+       qlcnic_83xx_detach_mailbox_work(adapter);
 
        /* Disable mailbox interrupt */
        qlcnic_83xx_disable_mbx_intr(adapter);
@@ -610,6 +611,9 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter)
 {
        int err;
 
+       qlcnic_83xx_reinit_mbx_work(adapter->ahw->mailbox);
+       qlcnic_83xx_enable_mbx_interrupt(adapter);
+
        /* register for NIC IDC AEN Events */
        qlcnic_83xx_register_nic_idc_func(adapter, 1);
 
@@ -617,7 +621,7 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter)
        if (err)
                return err;
 
-       qlcnic_83xx_enable_mbx_intrpt(adapter);
+       qlcnic_83xx_enable_mbx_interrupt(adapter);
 
        if (qlcnic_83xx_configure_opmode(adapter)) {
                qlcnic_83xx_idc_enter_failed_state(adapter, 1);
@@ -629,7 +633,10 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter)
                return -EIO;
        }
 
-       qlcnic_set_drv_version(adapter);
+       if (adapter->portnum == 0)
+               qlcnic_set_drv_version(adapter);
+
+       qlcnic_dcb_get_info(adapter);
        qlcnic_83xx_idc_attach_driver(adapter);
 
        return 0;
@@ -640,7 +647,6 @@ static void qlcnic_83xx_idc_update_idc_params(struct qlcnic_adapter *adapter)
        struct qlcnic_hardware_context *ahw = adapter->ahw;
 
        qlcnic_83xx_idc_update_drv_presence_reg(adapter, 1, 1);
-       set_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
        qlcnic_83xx_idc_update_audit_reg(adapter, 0, 1);
        set_bit(QLC_83XX_MODULE_LOADED, &adapter->ahw->idc.status);
 
@@ -810,9 +816,10 @@ static int qlcnic_83xx_idc_init_state(struct qlcnic_adapter *adapter)
  **/
 static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter)
 {
-       u32 val;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_mailbox *mbx = ahw->mailbox;
        int ret = 0;
+       u32 val;
 
        /* Perform NIC configuration based ready state entry actions */
        if (ahw->idc.state_entry(adapter))
@@ -824,7 +831,7 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter)
                        dev_err(&adapter->pdev->dev,
                                "Error: device temperature %d above limits\n",
                                adapter->ahw->temp);
-                       clear_bit(QLC_83XX_MBX_READY, &ahw->idc.status);
+                       clear_bit(QLC_83XX_MBX_READY, &mbx->status);
                        set_bit(__QLCNIC_RESETTING, &adapter->state);
                        qlcnic_83xx_idc_detach_driver(adapter);
                        qlcnic_83xx_idc_enter_failed_state(adapter, 1);
@@ -837,7 +844,7 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter)
        if (ret) {
                adapter->flags |= QLCNIC_FW_HANG;
                if (!(val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY)) {
-                       clear_bit(QLC_83XX_MBX_READY, &ahw->idc.status);
+                       clear_bit(QLC_83XX_MBX_READY, &mbx->status);
                        set_bit(__QLCNIC_RESETTING, &adapter->state);
                        qlcnic_83xx_idc_enter_need_reset_state(adapter, 1);
                }
@@ -845,6 +852,8 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter)
        }
 
        if ((val & QLC_83XX_IDC_GRACEFULL_RESET) || ahw->idc.collect_dump) {
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
+
                /* Move to need reset state and prepare for reset */
                qlcnic_83xx_idc_enter_need_reset_state(adapter, 1);
                return ret;
@@ -882,12 +891,13 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter)
  **/
 static int qlcnic_83xx_idc_need_reset_state(struct qlcnic_adapter *adapter)
 {
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
        int ret = 0;
 
        if (adapter->ahw->idc.prev_state != QLC_83XX_IDC_DEV_NEED_RESET) {
                qlcnic_83xx_idc_update_audit_reg(adapter, 0, 1);
                set_bit(__QLCNIC_RESETTING, &adapter->state);
-               clear_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
                if (adapter->ahw->nic_mode == QLC_83XX_VIRTUAL_NIC_MODE)
                        qlcnic_83xx_disable_vnic_mode(adapter, 1);
 
@@ -1079,7 +1089,6 @@ static void qlcnic_83xx_setup_idc_parameters(struct qlcnic_adapter *adapter)
        adapter->ahw->idc.name = (char **)qlc_83xx_idc_states;
 
        clear_bit(__QLCNIC_RESETTING, &adapter->state);
-       set_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
        set_bit(QLC_83XX_MODULE_LOADED, &adapter->ahw->idc.status);
 
        /* Check if reset recovery is disabled */
@@ -1190,6 +1199,9 @@ void qlcnic_83xx_idc_request_reset(struct qlcnic_adapter *adapter, u32 key)
 {
        u32 val;
 
+       if (qlcnic_sriov_vf_check(adapter))
+               return;
+
        if (qlcnic_83xx_lock_driver(adapter)) {
                dev_err(&adapter->pdev->dev,
                        "%s:failed, please retry\n", __func__);
@@ -1303,8 +1315,11 @@ static void qlcnic_83xx_dump_pause_control_regs(struct qlcnic_adapter *adapter)
 {
        int i, j;
        u32 val = 0, val1 = 0, reg = 0;
+       int err = 0;
 
-       val = QLCRD32(adapter, QLC_83XX_SRE_SHIM_REG);
+       val = QLCRD32(adapter, QLC_83XX_SRE_SHIM_REG, &err);
+       if (err == -EIO)
+               return;
        dev_info(&adapter->pdev->dev, "SRE-Shim Ctrl:0x%x\n", val);
 
        for (j = 0; j < 2; j++) {
@@ -1318,7 +1333,9 @@ static void qlcnic_83xx_dump_pause_control_regs(struct qlcnic_adapter *adapter)
                        reg = QLC_83XX_PORT1_THRESHOLD;
                }
                for (i = 0; i < 8; i++) {
-                       val = QLCRD32(adapter, reg + (i * 0x4));
+                       val = QLCRD32(adapter, reg + (i * 0x4), &err);
+                       if (err == -EIO)
+                               return;
                        dev_info(&adapter->pdev->dev, "0x%x  ", val);
                }
                dev_info(&adapter->pdev->dev, "\n");
@@ -1335,8 +1352,10 @@ static void qlcnic_83xx_dump_pause_control_regs(struct qlcnic_adapter *adapter)
                        reg = QLC_83XX_PORT1_TC_MC_REG;
                }
                for (i = 0; i < 4; i++) {
-                       val = QLCRD32(adapter, reg + (i * 0x4));
-                        dev_info(&adapter->pdev->dev, "0x%x  ", val);
+                       val = QLCRD32(adapter, reg + (i * 0x4), &err);
+                       if (err == -EIO)
+                               return;
+                       dev_info(&adapter->pdev->dev, "0x%x  ", val);
                }
                dev_info(&adapter->pdev->dev, "\n");
        }
@@ -1352,17 +1371,25 @@ static void qlcnic_83xx_dump_pause_control_regs(struct qlcnic_adapter *adapter)
                        reg = QLC_83XX_PORT1_TC_STATS;
                }
                for (i = 7; i >= 0; i--) {
-                       val = QLCRD32(adapter, reg);
+                       val = QLCRD32(adapter, reg, &err);
+                       if (err == -EIO)
+                               return;
                        val &= ~(0x7 << 29);    /* Reset bits 29 to 31 */
                        QLCWR32(adapter, reg, (val | (i << 29)));
-                       val = QLCRD32(adapter, reg);
+                       val = QLCRD32(adapter, reg, &err);
+                       if (err == -EIO)
+                               return;
                        dev_info(&adapter->pdev->dev, "0x%x  ", val);
                }
                dev_info(&adapter->pdev->dev, "\n");
        }
 
-       val = QLCRD32(adapter, QLC_83XX_PORT2_IFB_THRESHOLD);
-       val1 = QLCRD32(adapter, QLC_83XX_PORT3_IFB_THRESHOLD);
+       val = QLCRD32(adapter, QLC_83XX_PORT2_IFB_THRESHOLD, &err);
+       if (err == -EIO)
+               return;
+       val1 = QLCRD32(adapter, QLC_83XX_PORT3_IFB_THRESHOLD, &err);
+       if (err == -EIO)
+               return;
        dev_info(&adapter->pdev->dev,
                 "IFB-Pause Thresholds: Port 2:0x%x, Port 3:0x%x\n",
                 val, val1);
@@ -1425,7 +1452,7 @@ static void qlcnic_83xx_take_eport_out_of_reset(struct qlcnic_adapter *adapter)
 static int qlcnic_83xx_check_heartbeat(struct qlcnic_adapter *p_dev)
 {
        u32 heartbeat, peg_status;
-       int retries, ret = -EIO;
+       int retries, ret = -EIO, err = 0;
 
        retries = QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT;
        p_dev->heartbeat = QLC_SHARED_REG_RD32(p_dev,
@@ -1453,11 +1480,11 @@ static int qlcnic_83xx_check_heartbeat(struct qlcnic_adapter *p_dev)
                         "PEG_NET_2_PC: 0x%x, PEG_NET_3_PC: 0x%x,\n"
                         "PEG_NET_4_PC: 0x%x\n", peg_status,
                         QLC_SHARED_REG_RD32(p_dev, QLCNIC_PEG_HALT_STATUS2),
-                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_0),
-                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_1),
-                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_2),
-                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_3),
-                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_4));
+                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_0, &err),
+                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_1, &err),
+                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_2, &err),
+                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_3, &err),
+                        QLCRD32(p_dev, QLC_83XX_CRB_PEG_NET_4, &err));
 
                if (QLCNIC_FWERROR_CODE(peg_status) == 0x67)
                        dev_err(&p_dev->pdev->dev,
@@ -1501,18 +1528,22 @@ int qlcnic_83xx_check_hw_status(struct qlcnic_adapter *p_dev)
 static int qlcnic_83xx_poll_reg(struct qlcnic_adapter *p_dev, u32 addr,
                                int duration, u32 mask, u32 status)
 {
+       int timeout_error, err = 0;
        u32 value;
-       int timeout_error;
        u8 retries;
 
-       value = qlcnic_83xx_rd_reg_indirect(p_dev, addr);
+       value = QLCRD32(p_dev, addr, &err);
+       if (err == -EIO)
+               return err;
        retries = duration / 10;
 
        do {
                if ((value & mask) != status) {
                        timeout_error = 1;
                        msleep(duration / 10);
-                       value = qlcnic_83xx_rd_reg_indirect(p_dev, addr);
+                       value = QLCRD32(p_dev, addr, &err);
+                       if (err == -EIO)
+                               return err;
                } else {
                        timeout_error = 0;
                        break;
@@ -1606,9 +1637,12 @@ int qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *p_dev)
 static void qlcnic_83xx_read_write_crb_reg(struct qlcnic_adapter *p_dev,
                                           u32 raddr, u32 waddr)
 {
-       int value;
+       int err = 0;
+       u32 value;
 
-       value = qlcnic_83xx_rd_reg_indirect(p_dev, raddr);
+       value = QLCRD32(p_dev, raddr, &err);
+       if (err == -EIO)
+               return;
        qlcnic_83xx_wrt_reg_indirect(p_dev, waddr, value);
 }
 
@@ -1617,12 +1651,16 @@ static void qlcnic_83xx_rmw_crb_reg(struct qlcnic_adapter *p_dev,
                                    u32 raddr, u32 waddr,
                                    struct qlc_83xx_rmw *p_rmw_hdr)
 {
-       int value;
+       int err = 0;
+       u32 value;
 
-       if (p_rmw_hdr->index_a)
+       if (p_rmw_hdr->index_a) {
                value = p_dev->ahw->reset.array[p_rmw_hdr->index_a];
-       else
-               value = qlcnic_83xx_rd_reg_indirect(p_dev, raddr);
+       } else {
+               value = QLCRD32(p_dev, raddr, &err);
+               if (err == -EIO)
+                       return;
+       }
 
        value &= p_rmw_hdr->mask;
        value <<= p_rmw_hdr->shl;
@@ -1675,7 +1713,7 @@ static void qlcnic_83xx_poll_list(struct qlcnic_adapter *p_dev,
        long delay;
        struct qlc_83xx_entry *entry;
        struct qlc_83xx_poll *poll;
-       int i;
+       int i, err = 0;
        unsigned long arg1, arg2;
 
        poll = (struct qlc_83xx_poll *)((char *)p_hdr +
@@ -1699,10 +1737,12 @@ static void qlcnic_83xx_poll_list(struct qlcnic_adapter *p_dev,
                                                         arg1, delay,
                                                         poll->mask,
                                                         poll->status)){
-                                       qlcnic_83xx_rd_reg_indirect(p_dev,
-                                                                   arg1);
-                                       qlcnic_83xx_rd_reg_indirect(p_dev,
-                                                                   arg2);
+                                       QLCRD32(p_dev, arg1, &err);
+                                       if (err == -EIO)
+                                               return;
+                                       QLCRD32(p_dev, arg2, &err);
+                                       if (err == -EIO)
+                                               return;
                                }
                        }
                }
@@ -1768,7 +1808,7 @@ static void qlcnic_83xx_poll_read_list(struct qlcnic_adapter *p_dev,
                                       struct qlc_83xx_entry_hdr *p_hdr)
 {
        long delay;
-       int index, i, j;
+       int index, i, j, err;
        struct qlc_83xx_quad_entry *entry;
        struct qlc_83xx_poll *poll;
        unsigned long addr;
@@ -1788,7 +1828,10 @@ static void qlcnic_83xx_poll_read_list(struct qlcnic_adapter *p_dev,
                                                  poll->mask, poll->status)){
                                index = p_dev->ahw->reset.array_index;
                                addr = entry->dr_addr;
-                               j = qlcnic_83xx_rd_reg_indirect(p_dev, addr);
+                               j = QLCRD32(p_dev, addr, &err);
+                               if (err == -EIO)
+                                       return;
+
                                p_dev->ahw->reset.array[index++] = j;
 
                                if (index == QLC_83XX_MAX_RESET_SEQ_ENTRIES)
@@ -1907,12 +1950,36 @@ static void qlcnic_83xx_init_hw(struct qlcnic_adapter *p_dev)
                dev_err(&p_dev->pdev->dev, "%s: failed\n", __func__);
 }
 
+static inline void qlcnic_83xx_get_fw_file_name(struct qlcnic_adapter *adapter,
+                                               char *file_name)
+{
+       struct pci_dev *pdev = adapter->pdev;
+
+       memset(file_name, 0, QLC_FW_FILE_NAME_LEN);
+
+       switch (pdev->device) {
+       case PCI_DEVICE_ID_QLOGIC_QLE834X:
+               strncpy(file_name, QLC_83XX_FW_FILE_NAME,
+                       QLC_FW_FILE_NAME_LEN);
+               break;
+       case PCI_DEVICE_ID_QLOGIC_QLE844X:
+               strncpy(file_name, QLC_84XX_FW_FILE_NAME,
+                       QLC_FW_FILE_NAME_LEN);
+               break;
+       default:
+               dev_err(&pdev->dev, "%s: Invalid device id\n",
+                       __func__);
+       }
+}
+
 static int qlcnic_83xx_load_fw_image_from_host(struct qlcnic_adapter *adapter)
 {
+       char fw_file_name[QLC_FW_FILE_NAME_LEN];
        int err = -EIO;
 
-       if (request_firmware(&adapter->ahw->fw_info.fw,
-                            QLC_83XX_FW_FILE_NAME, &(adapter->pdev->dev))) {
+       qlcnic_83xx_get_fw_file_name(adapter, fw_file_name);
+       if (request_firmware(&adapter->ahw->fw_info.fw, fw_file_name,
+                            &(adapter->pdev->dev))) {
                dev_err(&adapter->pdev->dev,
                        "No file FW image, loading flash FW image.\n");
                QLC_SHARED_REG_WR32(adapter, QLCNIC_FW_IMG_VALID,
@@ -2110,40 +2177,75 @@ static void qlcnic_83xx_clear_function_resources(struct qlcnic_adapter *adapter)
 int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
+       int err = 0;
 
-       if (qlcnic_sriov_vf_check(adapter))
-               return qlcnic_sriov_vf_init(adapter, pci_using_dac);
+       ahw->msix_supported = !!qlcnic_use_msi_x;
+       err = qlcnic_83xx_init_mailbox_work(adapter);
+       if (err)
+               goto exit;
 
-       if (qlcnic_83xx_check_hw_status(adapter))
-               return -EIO;
+       if (qlcnic_sriov_vf_check(adapter)) {
+               err = qlcnic_sriov_vf_init(adapter, pci_using_dac);
+               if (err)
+                       goto detach_mbx;
+               else
+                       return err;
+       }
+
+       err = qlcnic_83xx_check_hw_status(adapter);
+       if (err)
+               goto detach_mbx;
 
-       /* Initilaize 83xx mailbox spinlock */
-       spin_lock_init(&ahw->mbx_lock);
+       if (!qlcnic_83xx_read_flash_descriptor_table(adapter))
+               qlcnic_83xx_read_flash_mfg_id(adapter);
+
+       err = qlcnic_83xx_idc_init(adapter);
+       if (err)
+               goto detach_mbx;
+
+       err = qlcnic_setup_intr(adapter, 0, 0);
+       if (err) {
+               dev_err(&adapter->pdev->dev, "Failed to setup interrupt\n");
+               goto disable_intr;
+       }
+
+       err = qlcnic_83xx_setup_mbx_intr(adapter);
+       if (err)
+               goto disable_mbx_intr;
 
-       set_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
        qlcnic_83xx_clear_function_resources(adapter);
 
+       INIT_DELAYED_WORK(&adapter->idc_aen_work, qlcnic_83xx_idc_aen_work);
+
        /* register for NIC IDC AEN Events */
        qlcnic_83xx_register_nic_idc_func(adapter, 1);
 
-       if (!qlcnic_83xx_read_flash_descriptor_table(adapter))
-               qlcnic_83xx_read_flash_mfg_id(adapter);
-
-       if (qlcnic_83xx_idc_init(adapter))
-               return -EIO;
-
        /* Configure default, SR-IOV or Virtual NIC mode of operation */
-       if (qlcnic_83xx_configure_opmode(adapter))
-               return -EIO;
+       err = qlcnic_83xx_configure_opmode(adapter);
+       if (err)
+               goto disable_mbx_intr;
 
        /* Perform operating mode specific initialization */
-       if (adapter->nic_ops->init_driver(adapter))
-               return -EIO;
+       err = adapter->nic_ops->init_driver(adapter);
+       if (err)
+               goto disable_mbx_intr;
 
-       INIT_DELAYED_WORK(&adapter->idc_aen_work, qlcnic_83xx_idc_aen_work);
+       if (adapter->dcb && qlcnic_dcb_attach(adapter))
+               qlcnic_clear_dcb_ops(adapter);
 
        /* Periodically monitor device status */
        qlcnic_83xx_idc_poll_dev_state(&adapter->fw_work.work);
+       return 0;
+
+disable_mbx_intr:
+       qlcnic_83xx_free_mbx_intr(adapter);
 
-       return adapter->ahw->idc.err_code;
+disable_intr:
+       qlcnic_teardown_intr(adapter);
+
+detach_mbx:
+       qlcnic_83xx_detach_mailbox_work(adapter);
+       qlcnic_83xx_free_mailbox(ahw->mailbox);
+exit:
+       return err;
 }
index 0581a484ceb519dc8e6b11b6d08b06e4461bab46..bf3b17eaf8b884031911544ac482f5e2d65eb04e 100644 (file)
@@ -38,6 +38,9 @@ static const struct qlcnic_mailbox_metadata qlcnic_mbx_tbl[] = {
        {QLCNIC_CMD_GET_TEMP_HDR, 4, 1},
        {QLCNIC_CMD_82XX_SET_DRV_VER, 4, 1},
        {QLCNIC_CMD_GET_LED_STATUS, 4, 2},
+       {QLCNIC_CMD_MQ_TX_CONFIG_INTR, 2, 3},
+       {QLCNIC_CMD_DCB_QUERY_CAP, 1, 2},
+       {QLCNIC_CMD_DCB_QUERY_PARAM, 4, 1},
 };
 
 static inline u32 qlcnic_get_cmd_signature(struct qlcnic_hardware_context *ahw)
@@ -104,7 +107,7 @@ static u32
 qlcnic_poll_rsp(struct qlcnic_adapter *adapter)
 {
        u32 rsp;
-       int timeout = 0;
+       int timeout = 0, err = 0;
 
        do {
                /* give atleast 1ms for firmware to respond */
@@ -113,7 +116,7 @@ qlcnic_poll_rsp(struct qlcnic_adapter *adapter)
                if (++timeout > QLCNIC_OS_CRB_RETRY_COUNT)
                        return QLCNIC_CDRP_RSP_TIMEOUT;
 
-               rsp = QLCRD32(adapter, QLCNIC_CDRP_CRB_OFFSET);
+               rsp = QLCRD32(adapter, QLCNIC_CDRP_CRB_OFFSET, &err);
        } while (!QLCNIC_CDRP_IS_RSP(rsp));
 
        return rsp;
@@ -122,7 +125,7 @@ qlcnic_poll_rsp(struct qlcnic_adapter *adapter)
 int qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
                          struct qlcnic_cmd_args *cmd)
 {
-       int i;
+       int i, err = 0;
        u32 rsp;
        u32 signature;
        struct pci_dev *pdev = adapter->pdev;
@@ -148,7 +151,7 @@ int qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
                dev_err(&pdev->dev, "card response timeout.\n");
                cmd->rsp.arg[0] = QLCNIC_RCODE_TIMEOUT;
        } else if (rsp == QLCNIC_CDRP_RSP_FAIL) {
-               cmd->rsp.arg[0] = QLCRD32(adapter, QLCNIC_CDRP_ARG(1));
+               cmd->rsp.arg[0] = QLCRD32(adapter, QLCNIC_CDRP_ARG(1), &err);
                switch (cmd->rsp.arg[0]) {
                case QLCNIC_RCODE_INVALID_ARGS:
                        fmt = "CDRP invalid args: [%d]\n";
@@ -171,11 +174,12 @@ int qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
                        break;
                }
                dev_err(&pdev->dev, fmt, cmd->rsp.arg[0]);
+               qlcnic_dump_mbx(adapter, cmd);
        } else if (rsp == QLCNIC_CDRP_RSP_OK)
                cmd->rsp.arg[0] = QLCNIC_RCODE_SUCCESS;
 
        for (i = 1; i < cmd->rsp.num; i++)
-               cmd->rsp.arg[i] = QLCRD32(adapter, QLCNIC_CDRP_ARG(i));
+               cmd->rsp.arg[i] = QLCRD32(adapter, QLCNIC_CDRP_ARG(i), &err);
 
        /* Release semaphore */
        qlcnic_api_unlock(adapter);
@@ -210,10 +214,10 @@ int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *adapter, u32 fw_cmd)
        if (err) {
                dev_info(&adapter->pdev->dev,
                         "Failed to set driver version in firmware\n");
-               return -EIO;
+               err = -EIO;
        }
-
-       return 0;
+       qlcnic_free_mbx_args(&cmd);
+       return err;
 }
 
 int
@@ -243,40 +247,38 @@ qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu)
 
 int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
 {
-       void *addr;
-       struct qlcnic_hostrq_rx_ctx *prq;
-       struct qlcnic_cardrsp_rx_ctx *prsp;
-       struct qlcnic_hostrq_rds_ring *prq_rds;
-       struct qlcnic_hostrq_sds_ring *prq_sds;
+       struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       dma_addr_t hostrq_phys_addr, cardrsp_phys_addr;
+       struct net_device *netdev = adapter->netdev;
+       u32 temp_intr_crb_mode, temp_rds_crb_mode;
        struct qlcnic_cardrsp_rds_ring *prsp_rds;
        struct qlcnic_cardrsp_sds_ring *prsp_sds;
+       struct qlcnic_hostrq_rds_ring *prq_rds;
+       struct qlcnic_hostrq_sds_ring *prq_sds;
        struct qlcnic_host_rds_ring *rds_ring;
        struct qlcnic_host_sds_ring *sds_ring;
-       struct qlcnic_cmd_args cmd;
-
-       dma_addr_t hostrq_phys_addr, cardrsp_phys_addr;
-       u64 phys_addr;
-
+       struct qlcnic_cardrsp_rx_ctx *prsp;
+       struct qlcnic_hostrq_rx_ctx *prq;
        u8 i, nrds_rings, nsds_rings;
-       u16 temp_u16;
+       struct qlcnic_cmd_args cmd;
        size_t rq_size, rsp_size;
        u32 cap, reg, val, reg2;
+       u64 phys_addr;
+       u16 temp_u16;
+       void *addr;
        int err;
 
-       struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
-
        nrds_rings = adapter->max_rds_rings;
        nsds_rings = adapter->max_sds_rings;
 
-       rq_size =
-               SIZEOF_HOSTRQ_RX(struct qlcnic_hostrq_rx_ctx, nrds_rings,
-                                               nsds_rings);
-       rsp_size =
-               SIZEOF_CARDRSP_RX(struct qlcnic_cardrsp_rx_ctx, nrds_rings,
-                                               nsds_rings);
+       rq_size = SIZEOF_HOSTRQ_RX(struct qlcnic_hostrq_rx_ctx, nrds_rings,
+                                  nsds_rings);
+       rsp_size = SIZEOF_CARDRSP_RX(struct qlcnic_cardrsp_rx_ctx, nrds_rings,
+                                    nsds_rings);
 
        addr = dma_alloc_coherent(&adapter->pdev->dev, rq_size,
-                       &hostrq_phys_addr, GFP_KERNEL);
+                                 &hostrq_phys_addr, GFP_KERNEL);
        if (addr == NULL)
                return -ENOMEM;
        prq = addr;
@@ -295,15 +297,20 @@ int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
                                                | QLCNIC_CAP0_VALIDOFF);
        cap |= (QLCNIC_CAP0_JUMBO_CONTIGUOUS | QLCNIC_CAP0_LRO_CONTIGUOUS);
 
-       temp_u16 = offsetof(struct qlcnic_hostrq_rx_ctx, msix_handler);
-       prq->valid_field_offset = cpu_to_le16(temp_u16);
-       prq->txrx_sds_binding = nsds_rings - 1;
+       if (qlcnic_check_multi_tx(adapter) &&
+           !adapter->ahw->diag_test) {
+               cap |= QLCNIC_CAP0_TX_MULTI;
+       } else {
+               temp_u16 = offsetof(struct qlcnic_hostrq_rx_ctx, msix_handler);
+               prq->valid_field_offset = cpu_to_le16(temp_u16);
+               prq->txrx_sds_binding = nsds_rings - 1;
+               temp_intr_crb_mode = QLCNIC_HOST_INT_CRB_MODE_SHARED;
+               prq->host_int_crb_mode = cpu_to_le32(temp_intr_crb_mode);
+               temp_rds_crb_mode = QLCNIC_HOST_RDS_CRB_MODE_UNIQUE;
+               prq->host_rds_crb_mode = cpu_to_le32(temp_rds_crb_mode);
+       }
 
        prq->capabilities[0] = cpu_to_le32(cap);
-       prq->host_int_crb_mode =
-               cpu_to_le32(QLCNIC_HOST_INT_CRB_MODE_SHARED);
-       prq->host_rds_crb_mode =
-               cpu_to_le32(QLCNIC_HOST_RDS_CRB_MODE_UNIQUE);
 
        prq->num_rds_rings = cpu_to_le16(nrds_rings);
        prq->num_sds_rings = cpu_to_le16(nsds_rings);
@@ -317,10 +324,8 @@ int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
                        le32_to_cpu(prq->rds_ring_offset));
 
        for (i = 0; i < nrds_rings; i++) {
-
                rds_ring = &recv_ctx->rds_rings[i];
                rds_ring->producer = 0;
-
                prq_rds[i].host_phys_addr = cpu_to_le64(rds_ring->phys_addr);
                prq_rds[i].ring_size = cpu_to_le32(rds_ring->num_desc);
                prq_rds[i].ring_kind = cpu_to_le32(i);
@@ -331,14 +336,16 @@ int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
                        le32_to_cpu(prq->sds_ring_offset));
 
        for (i = 0; i < nsds_rings; i++) {
-
                sds_ring = &recv_ctx->sds_rings[i];
                sds_ring->consumer = 0;
                memset(sds_ring->desc_head, 0, STATUS_DESC_RINGSIZE(sds_ring));
-
                prq_sds[i].host_phys_addr = cpu_to_le64(sds_ring->phys_addr);
                prq_sds[i].ring_size = cpu_to_le32(sds_ring->num_desc);
-               prq_sds[i].msi_index = cpu_to_le16(i);
+               if (qlcnic_check_multi_tx(adapter) &&
+                   !adapter->ahw->diag_test)
+                       prq_sds[i].msi_index = cpu_to_le16(ahw->intr_tbl[i].id);
+               else
+                       prq_sds[i].msi_index = cpu_to_le16(i);
        }
 
        phys_addr = hostrq_phys_addr;
@@ -361,9 +368,8 @@ int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
 
        for (i = 0; i < le16_to_cpu(prsp->num_rds_rings); i++) {
                rds_ring = &recv_ctx->rds_rings[i];
-
                reg = le32_to_cpu(prsp_rds[i].host_producer_crb);
-               rds_ring->crb_rcv_producer = adapter->ahw->pci_base0 + reg;
+               rds_ring->crb_rcv_producer = ahw->pci_base0 + reg;
        }
 
        prsp_sds = ((struct qlcnic_cardrsp_sds_ring *)
@@ -371,24 +377,30 @@ int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter)
 
        for (i = 0; i < le16_to_cpu(prsp->num_sds_rings); i++) {
                sds_ring = &recv_ctx->sds_rings[i];
-
                reg = le32_to_cpu(prsp_sds[i].host_consumer_crb);
-               reg2 = le32_to_cpu(prsp_sds[i].interrupt_crb);
+               if (qlcnic_check_multi_tx(adapter) && !adapter->ahw->diag_test)
+                       reg2 = ahw->intr_tbl[i].src;
+               else
+                       reg2 = le32_to_cpu(prsp_sds[i].interrupt_crb);
 
-               sds_ring->crb_sts_consumer = adapter->ahw->pci_base0 + reg;
-               sds_ring->crb_intr_mask = adapter->ahw->pci_base0 + reg2;
+               sds_ring->crb_intr_mask = ahw->pci_base0 + reg2;
+               sds_ring->crb_sts_consumer = ahw->pci_base0 + reg;
        }
 
        recv_ctx->state = le32_to_cpu(prsp->host_ctx_state);
        recv_ctx->context_id = le16_to_cpu(prsp->context_id);
        recv_ctx->virt_port = prsp->virt_port;
 
+       netdev_info(netdev, "Rx Context[%d] Created, state 0x%x\n",
+                   recv_ctx->context_id, recv_ctx->state);
        qlcnic_free_mbx_args(&cmd);
+
 out_free_rsp:
        dma_free_coherent(&adapter->pdev->dev, rsp_size, prsp,
                          cardrsp_phys_addr);
 out_free_rq:
        dma_free_coherent(&adapter->pdev->dev, rq_size, prq, hostrq_phys_addr);
+
        return err;
 }
 
@@ -416,16 +428,19 @@ int qlcnic_82xx_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter,
                                     struct qlcnic_host_tx_ring *tx_ring,
                                     int ring)
 {
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct net_device *netdev = adapter->netdev;
        struct qlcnic_hostrq_tx_ctx     *prq;
        struct qlcnic_hostrq_cds_ring   *prq_cds;
        struct qlcnic_cardrsp_tx_ctx    *prsp;
-       void    *rq_addr, *rsp_addr;
-       size_t  rq_size, rsp_size;
-       u32     temp;
        struct qlcnic_cmd_args cmd;
-       int     err;
-       u64     phys_addr;
-       dma_addr_t      rq_phys_addr, rsp_phys_addr;
+       u32 temp, intr_mask, temp_int_crb_mode;
+       dma_addr_t rq_phys_addr, rsp_phys_addr;
+       int temp_nsds_rings, index, err;
+       void *rq_addr, *rsp_addr;
+       size_t rq_size, rsp_size;
+       u64 phys_addr;
+       u16 msix_id;
 
        /* reset host resources */
        tx_ring->producer = 0;
@@ -447,18 +462,28 @@ int qlcnic_82xx_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter,
        }
 
        prq = rq_addr;
-
        prsp = rsp_addr;
 
        prq->host_rsp_dma_addr = cpu_to_le64(rsp_phys_addr);
 
        temp = (QLCNIC_CAP0_LEGACY_CONTEXT | QLCNIC_CAP0_LEGACY_MN |
-                                       QLCNIC_CAP0_LSO);
+               QLCNIC_CAP0_LSO);
+       if (qlcnic_check_multi_tx(adapter) && !adapter->ahw->diag_test)
+               temp |= QLCNIC_CAP0_TX_MULTI;
+
        prq->capabilities[0] = cpu_to_le32(temp);
 
-       prq->host_int_crb_mode =
-               cpu_to_le32(QLCNIC_HOST_INT_CRB_MODE_SHARED);
-       prq->msi_index = 0;
+       if (qlcnic_check_multi_tx(adapter) &&
+           !adapter->ahw->diag_test) {
+               temp_nsds_rings = adapter->max_sds_rings;
+               index = temp_nsds_rings + ring;
+               msix_id = ahw->intr_tbl[index].id;
+               prq->msi_index = cpu_to_le16(msix_id);
+       } else {
+               temp_int_crb_mode = QLCNIC_HOST_INT_CRB_MODE_SHARED;
+               prq->host_int_crb_mode = cpu_to_le32(temp_int_crb_mode);
+               prq->msi_index = 0;
+       }
 
        prq->interrupt_ctl = 0;
        prq->cmd_cons_dma_addr = cpu_to_le64(tx_ring->hw_cons_phys_addr);
@@ -480,15 +505,25 @@ int qlcnic_82xx_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter,
        err = qlcnic_issue_cmd(adapter, &cmd);
 
        if (err == QLCNIC_RCODE_SUCCESS) {
+               tx_ring->state = le32_to_cpu(prsp->host_ctx_state);
                temp = le32_to_cpu(prsp->cds_ring.host_producer_crb);
                tx_ring->crb_cmd_producer = adapter->ahw->pci_base0 + temp;
                tx_ring->ctx_id = le16_to_cpu(prsp->context_id);
+               if (qlcnic_check_multi_tx(adapter) &&
+                   !adapter->ahw->diag_test &&
+                   (adapter->flags & QLCNIC_MSIX_ENABLED)) {
+                       index = adapter->max_sds_rings + ring;
+                       intr_mask = ahw->intr_tbl[index].src;
+                       tx_ring->crb_intr_mask = ahw->pci_base0 + intr_mask;
+               }
+
+               netdev_info(netdev, "Tx Context[0x%x] Created, state 0x%x\n",
+                           tx_ring->ctx_id, tx_ring->state);
        } else {
-               dev_err(&adapter->pdev->dev,
-                       "Failed to create tx ctx in firmware%d\n", err);
+               netdev_err(netdev, "Failed to create tx ctx in firmware%d\n",
+                          err);
                err = -EIO;
        }
-
        qlcnic_free_mbx_args(&cmd);
 
 out_free_rsp:
@@ -618,6 +653,13 @@ int qlcnic_fw_create_ctx(struct qlcnic_adapter *dev)
                }
        }
 
+       if (qlcnic_82xx_check(dev) && (dev->flags & QLCNIC_MSIX_ENABLED) &&
+           qlcnic_check_multi_tx(dev) && !dev->ahw->diag_test) {
+               err = qlcnic_82xx_mq_intrpt(dev, 1);
+               if (err)
+                       return err;
+       }
+
        err = qlcnic_fw_cmd_create_rx_ctx(dev);
        if (err)
                goto err_out;
@@ -639,13 +681,19 @@ int qlcnic_fw_create_ctx(struct qlcnic_adapter *dev)
        }
 
        set_bit(__QLCNIC_FW_ATTACHED, &dev->state);
+
        return 0;
 
 err_out:
+       if (qlcnic_82xx_check(dev) && (dev->flags & QLCNIC_MSIX_ENABLED) &&
+           qlcnic_check_multi_tx(dev) && !dev->ahw->diag_test)
+                       qlcnic_82xx_config_intrpt(dev, 0);
+
        if (qlcnic_83xx_check(dev) && (dev->flags & QLCNIC_MSIX_ENABLED)) {
                if (dev->ahw->diag_test != QLCNIC_LOOPBACK_TEST)
                        qlcnic_83xx_config_intrpt(dev, 0);
        }
+
        return err;
 }
 
@@ -659,6 +707,12 @@ void qlcnic_fw_destroy_ctx(struct qlcnic_adapter *adapter)
                        qlcnic_fw_cmd_del_tx_ctx(adapter,
                                                 &adapter->tx_ring[ring]);
 
+               if (qlcnic_82xx_check(adapter) &&
+                   (adapter->flags & QLCNIC_MSIX_ENABLED) &&
+                   qlcnic_check_multi_tx(adapter) &&
+                   !adapter->ahw->diag_test)
+                               qlcnic_82xx_config_intrpt(adapter, 0);
+
                if (qlcnic_83xx_check(adapter) &&
                    (adapter->flags & QLCNIC_MSIX_ENABLED)) {
                        if (adapter->ahw->diag_test != QLCNIC_LOOPBACK_TEST)
@@ -723,8 +777,54 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter)
        }
 }
 
+int qlcnic_82xx_config_intrpt(struct qlcnic_adapter *adapter, u8 op_type)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct net_device *netdev = adapter->netdev;
+       struct qlcnic_cmd_args cmd;
+       u32 type, val;
+       int i, err = 0;
+
+       for (i = 0; i < ahw->num_msix; i++) {
+               qlcnic_alloc_mbx_args(&cmd, adapter,
+                                     QLCNIC_CMD_MQ_TX_CONFIG_INTR);
+               type = op_type ? QLCNIC_INTRPT_ADD : QLCNIC_INTRPT_DEL;
+               val = type | (ahw->intr_tbl[i].type << 4);
+               if (ahw->intr_tbl[i].type == QLCNIC_INTRPT_MSIX)
+                       val |= (ahw->intr_tbl[i].id << 16);
+               cmd.req.arg[1] = val;
+               err = qlcnic_issue_cmd(adapter, &cmd);
+               if (err) {
+                       netdev_err(netdev, "Failed to %s interrupts %d\n",
+                                  op_type == QLCNIC_INTRPT_ADD ? "Add" :
+                                  "Delete", err);
+                       qlcnic_free_mbx_args(&cmd);
+                       return err;
+               }
+               val = cmd.rsp.arg[1];
+               if (LSB(val)) {
+                       netdev_info(netdev,
+                                   "failed to configure interrupt for %d\n",
+                                   ahw->intr_tbl[i].id);
+                       continue;
+               }
+               if (op_type) {
+                       ahw->intr_tbl[i].id = MSW(val);
+                       ahw->intr_tbl[i].enabled = 1;
+                       ahw->intr_tbl[i].src = cmd.rsp.arg[2];
+               } else {
+                       ahw->intr_tbl[i].id = i;
+                       ahw->intr_tbl[i].enabled = 0;
+                       ahw->intr_tbl[i].src = 0;
+               }
+               qlcnic_free_mbx_args(&cmd);
+       }
+
+       return err;
+}
 
-int qlcnic_82xx_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac)
+int qlcnic_82xx_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac,
+                               u8 function)
 {
        int err, i;
        struct qlcnic_cmd_args cmd;
@@ -734,7 +834,7 @@ int qlcnic_82xx_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac)
        if (err)
                return err;
 
-       cmd.req.arg[1] = adapter->ahw->pci_func | BIT_8;
+       cmd.req.arg[1] = function | BIT_8;
        err = qlcnic_issue_cmd(adapter, &cmd);
 
        if (err == QLCNIC_RCODE_SUCCESS) {
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
new file mode 100644 (file)
index 0000000..2e10e79
--- /dev/null
@@ -0,0 +1,1179 @@
+/*
+ * QLogic qlcnic NIC Driver
+ * Copyright (c)  2009-2013 QLogic Corporation
+ *
+ * See LICENSE.qlcnic for copyright and licensing details.
+ */
+
+#include <linux/types.h>
+#include "qlcnic.h"
+
+#define QLC_DCB_NUM_PARAM              3
+#define QLC_DCB_LOCAL_IDX              0
+#define QLC_DCB_OPER_IDX               1
+#define QLC_DCB_PEER_IDX               2
+
+#define QLC_DCB_GET_MAP(V)             (1 << V)
+
+#define QLC_DCB_AEN_BIT                        0x2
+#define QLC_DCB_FW_VER                 0x2
+#define QLC_DCB_MAX_TC                 0x8
+#define QLC_DCB_MAX_APP                        0x8
+#define QLC_DCB_MAX_PRIO               QLC_DCB_MAX_TC
+#define QLC_DCB_MAX_PG                 QLC_DCB_MAX_TC
+
+#define QLC_DCB_TSA_SUPPORT(V)         (V & 0x1)
+#define QLC_DCB_ETS_SUPPORT(V)         ((V >> 1) & 0x1)
+#define QLC_DCB_VERSION_SUPPORT(V)     ((V >> 2) & 0xf)
+#define QLC_DCB_MAX_NUM_TC(V)          ((V >> 20) & 0xf)
+#define QLC_DCB_MAX_NUM_ETS_TC(V)      ((V >> 24) & 0xf)
+#define QLC_DCB_MAX_NUM_PFC_TC(V)      ((V >> 28) & 0xf)
+#define QLC_DCB_GET_TC_PRIO(X, P)      ((X >> (P * 3)) & 0x7)
+#define QLC_DCB_GET_PGID_PRIO(X, P)    ((X >> (P * 8)) & 0xff)
+#define QLC_DCB_GET_BWPER_PG(X, P)     ((X >> (P * 8)) & 0xff)
+#define QLC_DCB_GET_TSA_PG(X, P)       ((X >> (P * 8)) & 0xff)
+#define QLC_DCB_GET_PFC_PRIO(X, P)     (((X >> 24) >> P) & 0x1)
+#define QLC_DCB_GET_PROTO_ID_APP(X)    ((X >> 8) & 0xffff)
+#define QLC_DCB_GET_SELECTOR_APP(X)    (X & 0xff)
+
+#define QLC_DCB_LOCAL_PARAM_FWID       0x3
+#define QLC_DCB_OPER_PARAM_FWID                0x1
+#define QLC_DCB_PEER_PARAM_FWID                0x2
+
+#define QLC_83XX_DCB_GET_NUMAPP(X)     ((X >> 2) & 0xf)
+#define QLC_83XX_DCB_TSA_VALID(X)      (X & 0x1)
+#define QLC_83XX_DCB_PFC_VALID(X)      ((X >> 1) & 0x1)
+#define QLC_83XX_DCB_GET_PRIOMAP_APP(X)        (X >> 24)
+
+#define QLC_82XX_DCB_GET_NUMAPP(X)     ((X >> 12) & 0xf)
+#define QLC_82XX_DCB_TSA_VALID(X)      ((X >> 4) & 0x1)
+#define QLC_82XX_DCB_PFC_VALID(X)      ((X >> 5) & 0x1)
+#define QLC_82XX_DCB_GET_PRIOVAL_APP(X)        ((X >> 24) & 0x7)
+#define QLC_82XX_DCB_GET_PRIOMAP_APP(X)        (1 << X)
+#define QLC_82XX_DCB_PRIO_TC_MAP       (0x76543210)
+
+static const struct dcbnl_rtnl_ops qlcnic_dcbnl_ops;
+
+static void qlcnic_dcb_aen_work(struct work_struct *);
+static void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *);
+
+static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_adapter *);
+static void __qlcnic_dcb_free(struct qlcnic_adapter *);
+static int __qlcnic_dcb_attach(struct qlcnic_adapter *);
+static int __qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *, char *);
+static void __qlcnic_dcb_get_info(struct qlcnic_adapter *);
+
+static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_adapter *);
+static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_adapter *, char *, u8);
+static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_adapter *);
+static void qlcnic_82xx_dcb_handle_aen(struct qlcnic_adapter *, void *);
+
+static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_adapter *);
+static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_adapter *, char *, u8);
+static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_adapter *);
+static int qlcnic_83xx_dcb_register_aen(struct qlcnic_adapter *, bool);
+static void qlcnic_83xx_dcb_handle_aen(struct qlcnic_adapter *, void *);
+
+struct qlcnic_dcb_capability {
+       bool    tsa_capability;
+       bool    ets_capability;
+       u8      max_num_tc;
+       u8      max_ets_tc;
+       u8      max_pfc_tc;
+       u8      dcb_capability;
+};
+
+struct qlcnic_dcb_param {
+       u32 hdr_prio_pfc_map[2];
+       u32 prio_pg_map[2];
+       u32 pg_bw_map[2];
+       u32 pg_tsa_map[2];
+       u32 app[QLC_DCB_MAX_APP];
+};
+
+struct qlcnic_dcb_mbx_params {
+       /* 1st local, 2nd operational 3rd remote */
+       struct qlcnic_dcb_param type[3];
+       u32 prio_tc_map;
+};
+
+struct qlcnic_82xx_dcb_param_mbx_le {
+       __le32 hdr_prio_pfc_map[2];
+       __le32 prio_pg_map[2];
+       __le32 pg_bw_map[2];
+       __le32 pg_tsa_map[2];
+       __le32 app[QLC_DCB_MAX_APP];
+};
+
+enum qlcnic_dcb_selector {
+       QLC_SELECTOR_DEF = 0x0,
+       QLC_SELECTOR_ETHER,
+       QLC_SELECTOR_TCP,
+       QLC_SELECTOR_UDP,
+};
+
+enum qlcnic_dcb_prio_type {
+       QLC_PRIO_NONE = 0,
+       QLC_PRIO_GROUP,
+       QLC_PRIO_LINK,
+};
+
+enum qlcnic_dcb_pfc_type {
+       QLC_PFC_DISABLED = 0,
+       QLC_PFC_FULL,
+       QLC_PFC_TX,
+       QLC_PFC_RX
+};
+
+struct qlcnic_dcb_prio_cfg {
+       bool valid;
+       enum qlcnic_dcb_pfc_type pfc_type;
+};
+
+struct qlcnic_dcb_pg_cfg {
+       bool valid;
+       u8 total_bw_percent;            /* of Link/ port BW */
+       u8 prio_count;
+       u8 tsa_type;
+};
+
+struct qlcnic_dcb_tc_cfg {
+       bool valid;
+       struct qlcnic_dcb_prio_cfg prio_cfg[QLC_DCB_MAX_PRIO];
+       enum qlcnic_dcb_prio_type prio_type;    /* always prio_link */
+       u8 link_percent;                        /* % of link bandwidth */
+       u8 bwg_percent;                         /* % of BWG's bandwidth */
+       u8 up_tc_map;
+       u8 pgid;
+};
+
+struct qlcnic_dcb_app {
+       bool valid;
+       enum qlcnic_dcb_selector selector;
+       u16 protocol;
+       u8 priority;
+};
+
+struct qlcnic_dcb_cee {
+       struct qlcnic_dcb_tc_cfg tc_cfg[QLC_DCB_MAX_TC];
+       struct qlcnic_dcb_pg_cfg pg_cfg[QLC_DCB_MAX_PG];
+       struct qlcnic_dcb_app app[QLC_DCB_MAX_APP];
+       bool tc_param_valid;
+       bool pfc_mode_enable;
+};
+
+struct qlcnic_dcb_cfg {
+       /* 0 - local, 1 - operational, 2 - remote */
+       struct qlcnic_dcb_cee type[QLC_DCB_NUM_PARAM];
+       struct qlcnic_dcb_capability capability;
+       u32 version;
+};
+
+static struct qlcnic_dcb_ops qlcnic_83xx_dcb_ops = {
+       .init_dcbnl_ops         = __qlcnic_init_dcbnl_ops,
+       .free                   = __qlcnic_dcb_free,
+       .attach                 = __qlcnic_dcb_attach,
+       .query_hw_capability    = __qlcnic_dcb_query_hw_capability,
+       .get_info               = __qlcnic_dcb_get_info,
+
+       .get_hw_capability      = qlcnic_83xx_dcb_get_hw_capability,
+       .query_cee_param        = qlcnic_83xx_dcb_query_cee_param,
+       .get_cee_cfg            = qlcnic_83xx_dcb_get_cee_cfg,
+       .register_aen           = qlcnic_83xx_dcb_register_aen,
+       .handle_aen             = qlcnic_83xx_dcb_handle_aen,
+};
+
+static struct qlcnic_dcb_ops qlcnic_82xx_dcb_ops = {
+       .init_dcbnl_ops         = __qlcnic_init_dcbnl_ops,
+       .free                   = __qlcnic_dcb_free,
+       .attach                 = __qlcnic_dcb_attach,
+       .query_hw_capability    = __qlcnic_dcb_query_hw_capability,
+       .get_info               = __qlcnic_dcb_get_info,
+
+       .get_hw_capability      = qlcnic_82xx_dcb_get_hw_capability,
+       .query_cee_param        = qlcnic_82xx_dcb_query_cee_param,
+       .get_cee_cfg            = qlcnic_82xx_dcb_get_cee_cfg,
+       .handle_aen             = qlcnic_82xx_dcb_handle_aen,
+};
+
+static u8 qlcnic_dcb_get_num_app(struct qlcnic_adapter *adapter, u32 val)
+{
+       if (qlcnic_82xx_check(adapter))
+               return QLC_82XX_DCB_GET_NUMAPP(val);
+       else
+               return QLC_83XX_DCB_GET_NUMAPP(val);
+}
+
+static inline u8 qlcnic_dcb_pfc_hdr_valid(struct qlcnic_adapter *adapter,
+                                         u32 val)
+{
+       if (qlcnic_82xx_check(adapter))
+               return QLC_82XX_DCB_PFC_VALID(val);
+       else
+               return QLC_83XX_DCB_PFC_VALID(val);
+}
+
+static inline u8 qlcnic_dcb_tsa_hdr_valid(struct qlcnic_adapter *adapter,
+                                         u32 val)
+{
+       if (qlcnic_82xx_check(adapter))
+               return QLC_82XX_DCB_TSA_VALID(val);
+       else
+               return QLC_83XX_DCB_TSA_VALID(val);
+}
+
+static inline u8 qlcnic_dcb_get_prio_map_app(struct qlcnic_adapter *adapter,
+                                            u32 val)
+{
+       if (qlcnic_82xx_check(adapter))
+               return QLC_82XX_DCB_GET_PRIOMAP_APP(val);
+       else
+               return QLC_83XX_DCB_GET_PRIOMAP_APP(val);
+}
+
+static int qlcnic_dcb_prio_count(u8 up_tc_map)
+{
+       int j;
+
+       for (j = 0; j < QLC_DCB_MAX_TC; j++)
+               if (up_tc_map & QLC_DCB_GET_MAP(j))
+                       break;
+
+       return j;
+}
+
+static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_adapter *adapter)
+{
+       if (test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               adapter->netdev->dcbnl_ops = &qlcnic_dcbnl_ops;
+}
+
+void qlcnic_set_dcb_ops(struct qlcnic_adapter *adapter)
+{
+       if (qlcnic_82xx_check(adapter))
+               adapter->dcb->ops = &qlcnic_82xx_dcb_ops;
+       else if (qlcnic_83xx_check(adapter))
+               adapter->dcb->ops = &qlcnic_83xx_dcb_ops;
+}
+
+int __qlcnic_register_dcb(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb;
+
+       dcb = kzalloc(sizeof(struct qlcnic_dcb), GFP_ATOMIC);
+       if (!dcb)
+               return -ENOMEM;
+
+       adapter->dcb = dcb;
+       dcb->adapter = adapter;
+       qlcnic_set_dcb_ops(adapter);
+
+       return 0;
+}
+
+static void __qlcnic_dcb_free(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (!dcb)
+               return;
+
+       qlcnic_dcb_register_aen(adapter, 0);
+
+       while (test_bit(__QLCNIC_DCB_IN_AEN, &adapter->state))
+               usleep_range(10000, 11000);
+
+       cancel_delayed_work_sync(&dcb->aen_work);
+
+       if (dcb->wq) {
+               destroy_workqueue(dcb->wq);
+               dcb->wq = NULL;
+       }
+
+       kfree(dcb->cfg);
+       dcb->cfg = NULL;
+       kfree(dcb->param);
+       dcb->param = NULL;
+       kfree(dcb);
+       adapter->dcb = NULL;
+}
+
+static void __qlcnic_dcb_get_info(struct qlcnic_adapter *adapter)
+{
+       qlcnic_dcb_get_hw_capability(adapter);
+       qlcnic_dcb_get_cee_cfg(adapter);
+       qlcnic_dcb_register_aen(adapter, 1);
+}
+
+static int __qlcnic_dcb_attach(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+       int err = 0;
+
+       INIT_DELAYED_WORK(&dcb->aen_work, qlcnic_dcb_aen_work);
+
+       dcb->wq = create_singlethread_workqueue("qlcnic-dcb");
+       if (!dcb->wq) {
+               dev_err(&adapter->pdev->dev,
+                       "DCB workqueue allocation failed. DCB will be disabled\n");
+               return -1;
+       }
+
+       dcb->cfg = kzalloc(sizeof(struct qlcnic_dcb_cfg), GFP_ATOMIC);
+       if (!dcb->cfg) {
+               err = -ENOMEM;
+               goto out_free_wq;
+       }
+
+       dcb->param = kzalloc(sizeof(struct qlcnic_dcb_mbx_params), GFP_ATOMIC);
+       if (!dcb->param) {
+               err = -ENOMEM;
+               goto out_free_cfg;
+       }
+
+       qlcnic_dcb_get_info(adapter);
+
+       return 0;
+out_free_cfg:
+       kfree(dcb->cfg);
+       dcb->cfg = NULL;
+
+out_free_wq:
+       destroy_workqueue(dcb->wq);
+       dcb->wq = NULL;
+
+       return err;
+}
+
+static int __qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *adapter,
+                                           char *buf)
+{
+       struct qlcnic_cmd_args cmd;
+       u32 mbx_out;
+       int err;
+
+       err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_DCB_QUERY_CAP);
+       if (err)
+               return err;
+
+       err = qlcnic_issue_cmd(adapter, &cmd);
+       if (err) {
+               dev_err(&adapter->pdev->dev,
+                       "Failed to query DCBX capability, err %d\n", err);
+       } else {
+               mbx_out = cmd.rsp.arg[1];
+               if (buf)
+                       memcpy(buf, &mbx_out, sizeof(u32));
+       }
+
+       qlcnic_free_mbx_args(&cmd);
+
+       return err;
+}
+
+static int __qlcnic_dcb_get_capability(struct qlcnic_adapter *adapter, u32 *val)
+{
+       struct qlcnic_dcb_capability *cap = &adapter->dcb->cfg->capability;
+       u32 mbx_out;
+       int err;
+
+       memset(cap, 0, sizeof(struct qlcnic_dcb_capability));
+
+       err = qlcnic_dcb_query_hw_capability(adapter, (char *)val);
+       if (err)
+               return err;
+
+       mbx_out = *val;
+       if (QLC_DCB_TSA_SUPPORT(mbx_out))
+               cap->tsa_capability = true;
+
+       if (QLC_DCB_ETS_SUPPORT(mbx_out))
+               cap->ets_capability = true;
+
+       cap->max_num_tc = QLC_DCB_MAX_NUM_TC(mbx_out);
+       cap->max_ets_tc = QLC_DCB_MAX_NUM_ETS_TC(mbx_out);
+       cap->max_pfc_tc = QLC_DCB_MAX_NUM_PFC_TC(mbx_out);
+
+       if (cap->max_num_tc > QLC_DCB_MAX_TC ||
+           cap->max_ets_tc > cap->max_num_tc ||
+           cap->max_pfc_tc > cap->max_num_tc) {
+               dev_err(&adapter->pdev->dev, "Invalid DCB configuration\n");
+               return -EINVAL;
+       }
+
+       return err;
+}
+
+static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg;
+       struct qlcnic_dcb_capability *cap;
+       u32 mbx_out;
+       int err;
+
+       err = __qlcnic_dcb_get_capability(adapter, &mbx_out);
+       if (err)
+               return err;
+
+       cap = &cfg->capability;
+       cap->dcb_capability = DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_LLD_MANAGED;
+
+       if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability)
+               set_bit(__QLCNIC_DCB_STATE, &adapter->state);
+
+       return err;
+}
+
+static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_adapter *adapter,
+                                          char *buf, u8 type)
+{
+       u16 size = sizeof(struct qlcnic_82xx_dcb_param_mbx_le);
+       struct qlcnic_82xx_dcb_param_mbx_le *prsp_le;
+       struct device *dev = &adapter->pdev->dev;
+       dma_addr_t cardrsp_phys_addr;
+       struct qlcnic_dcb_param rsp;
+       struct qlcnic_cmd_args cmd;
+       u64 phys_addr;
+       void *addr;
+       int err, i;
+
+       switch (type) {
+       case QLC_DCB_LOCAL_PARAM_FWID:
+       case QLC_DCB_OPER_PARAM_FWID:
+       case QLC_DCB_PEER_PARAM_FWID:
+               break;
+       default:
+               dev_err(dev, "Invalid parameter type %d\n", type);
+               return -EINVAL;
+       }
+
+       addr = dma_alloc_coherent(&adapter->pdev->dev, size, &cardrsp_phys_addr,
+                                 GFP_KERNEL);
+       if (addr == NULL)
+               return -ENOMEM;
+
+       prsp_le = addr;
+
+       err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_DCB_QUERY_PARAM);
+       if (err)
+               goto out_free_rsp;
+
+       phys_addr = cardrsp_phys_addr;
+       cmd.req.arg[1] = size | (type << 16);
+       cmd.req.arg[2] = MSD(phys_addr);
+       cmd.req.arg[3] = LSD(phys_addr);
+
+       err = qlcnic_issue_cmd(adapter, &cmd);
+       if (err) {
+               dev_err(dev, "Failed to query DCBX parameter, err %d\n", err);
+               goto out;
+       }
+
+       memset(&rsp, 0, sizeof(struct qlcnic_dcb_param));
+       rsp.hdr_prio_pfc_map[0] = le32_to_cpu(prsp_le->hdr_prio_pfc_map[0]);
+       rsp.hdr_prio_pfc_map[1] = le32_to_cpu(prsp_le->hdr_prio_pfc_map[1]);
+       rsp.prio_pg_map[0] = le32_to_cpu(prsp_le->prio_pg_map[0]);
+       rsp.prio_pg_map[1] = le32_to_cpu(prsp_le->prio_pg_map[1]);
+       rsp.pg_bw_map[0] = le32_to_cpu(prsp_le->pg_bw_map[0]);
+       rsp.pg_bw_map[1] = le32_to_cpu(prsp_le->pg_bw_map[1]);
+       rsp.pg_tsa_map[0] = le32_to_cpu(prsp_le->pg_tsa_map[0]);
+       rsp.pg_tsa_map[1] = le32_to_cpu(prsp_le->pg_tsa_map[1]);
+
+       for (i = 0; i < QLC_DCB_MAX_APP; i++)
+               rsp.app[i] = le32_to_cpu(prsp_le->app[i]);
+
+       if (buf)
+               memcpy(buf, &rsp, size);
+out:
+       qlcnic_free_mbx_args(&cmd);
+
+out_free_rsp:
+       dma_free_coherent(&adapter->pdev->dev, size, addr, cardrsp_phys_addr);
+
+       return err;
+}
+
+static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb_mbx_params *mbx;
+       int err;
+
+       mbx = adapter->dcb->param;
+       if (!mbx)
+               return 0;
+
+       err = qlcnic_dcb_query_cee_param(adapter, (char *)&mbx->type[0],
+                                        QLC_DCB_LOCAL_PARAM_FWID);
+       if (err)
+               return err;
+
+       err = qlcnic_dcb_query_cee_param(adapter, (char *)&mbx->type[1],
+                                        QLC_DCB_OPER_PARAM_FWID);
+       if (err)
+               return err;
+
+       err = qlcnic_dcb_query_cee_param(adapter, (char *)&mbx->type[2],
+                                        QLC_DCB_PEER_PARAM_FWID);
+       if (err)
+               return err;
+
+       mbx->prio_tc_map = QLC_82XX_DCB_PRIO_TC_MAP;
+
+       qlcnic_dcb_data_cee_param_map(adapter);
+
+       return err;
+}
+
+static void qlcnic_dcb_aen_work(struct work_struct *work)
+{
+       struct qlcnic_adapter *adapter;
+       struct qlcnic_dcb *dcb;
+
+       dcb = container_of(work, struct qlcnic_dcb, aen_work.work);
+       adapter = dcb->adapter;
+
+       qlcnic_dcb_get_cee_cfg(adapter);
+       clear_bit(__QLCNIC_DCB_IN_AEN, &adapter->state);
+}
+
+static void qlcnic_82xx_dcb_handle_aen(struct qlcnic_adapter *adapter,
+                                      void *data)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (test_and_set_bit(__QLCNIC_DCB_IN_AEN, &adapter->state))
+               return;
+
+       queue_delayed_work(dcb->wq, &dcb->aen_work, 0);
+}
+
+static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb_capability *cap = &adapter->dcb->cfg->capability;
+       u32 mbx_out;
+       int err;
+
+       err = __qlcnic_dcb_get_capability(adapter, &mbx_out);
+       if (err)
+               return err;
+
+       if (mbx_out & BIT_2)
+               cap->dcb_capability = DCB_CAP_DCBX_VER_CEE;
+       if (mbx_out & BIT_3)
+               cap->dcb_capability |= DCB_CAP_DCBX_VER_IEEE;
+       if (cap->dcb_capability)
+               cap->dcb_capability |= DCB_CAP_DCBX_LLD_MANAGED;
+
+       if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability)
+               set_bit(__QLCNIC_DCB_STATE, &adapter->state);
+
+       return err;
+}
+
+static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_adapter *adapter,
+                                          char *buf, u8 idx)
+{
+       struct qlcnic_dcb_mbx_params mbx_out;
+       int err, i, j, k, max_app, size;
+       struct qlcnic_dcb_param *each;
+       struct qlcnic_cmd_args cmd;
+       u32 val;
+       char *p;
+
+       size = 0;
+       memset(&mbx_out, 0, sizeof(struct qlcnic_dcb_mbx_params));
+       memset(buf, 0, sizeof(struct qlcnic_dcb_mbx_params));
+
+       err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_DCB_QUERY_PARAM);
+       if (err)
+               return err;
+
+       cmd.req.arg[0] |= QLC_DCB_FW_VER << 29;
+       err = qlcnic_issue_cmd(adapter, &cmd);
+       if (err) {
+               dev_err(&adapter->pdev->dev,
+                       "Failed to query DCBX param, err %d\n", err);
+               goto out;
+       }
+
+       mbx_out.prio_tc_map = cmd.rsp.arg[1];
+       p = memcpy(buf, &mbx_out, sizeof(u32));
+       k = 2;
+       p += sizeof(u32);
+
+       for (j = 0; j < QLC_DCB_NUM_PARAM; j++) {
+               each = &mbx_out.type[j];
+
+               each->hdr_prio_pfc_map[0] = cmd.rsp.arg[k++];
+               each->hdr_prio_pfc_map[1] = cmd.rsp.arg[k++];
+               each->prio_pg_map[0] = cmd.rsp.arg[k++];
+               each->prio_pg_map[1] = cmd.rsp.arg[k++];
+               each->pg_bw_map[0] = cmd.rsp.arg[k++];
+               each->pg_bw_map[1] = cmd.rsp.arg[k++];
+               each->pg_tsa_map[0] = cmd.rsp.arg[k++];
+               each->pg_tsa_map[1] = cmd.rsp.arg[k++];
+               val = each->hdr_prio_pfc_map[0];
+
+               max_app = qlcnic_dcb_get_num_app(adapter, val);
+               for (i = 0; i < max_app; i++)
+                       each->app[i] = cmd.rsp.arg[i + k];
+
+               size = 16 * sizeof(u32);
+               memcpy(p, &each->hdr_prio_pfc_map[0], size);
+               p += size;
+               if (j == 0)
+                       k = 18;
+               else
+                       k = 34;
+       }
+out:
+       qlcnic_free_mbx_args(&cmd);
+
+       return err;
+}
+
+static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+       int err;
+
+       err = qlcnic_dcb_query_cee_param(adapter, (char *)dcb->param, 0);
+       if (err)
+               return err;
+
+       qlcnic_dcb_data_cee_param_map(adapter);
+
+       return err;
+}
+
+static int qlcnic_83xx_dcb_register_aen(struct qlcnic_adapter *adapter,
+                                       bool flag)
+{
+       u8 val = (flag ? QLCNIC_CMD_INIT_NIC_FUNC : QLCNIC_CMD_STOP_NIC_FUNC);
+       struct qlcnic_cmd_args cmd;
+       int err;
+
+       err = qlcnic_alloc_mbx_args(&cmd, adapter, val);
+       if (err)
+               return err;
+
+       cmd.req.arg[1] = QLC_DCB_AEN_BIT;
+
+       err = qlcnic_issue_cmd(adapter, &cmd);
+       if (err)
+               dev_err(&adapter->pdev->dev, "Failed to %s DCBX AEN, err %d\n",
+                       (flag ? "register" : "unregister"), err);
+
+       qlcnic_free_mbx_args(&cmd);
+
+       return err;
+}
+
+static void qlcnic_83xx_dcb_handle_aen(struct qlcnic_adapter *adapter,
+                                      void *data)
+{
+       struct qlcnic_dcb *dcb = adapter->dcb;
+       u32 *val = data;
+
+       if (test_and_set_bit(__QLCNIC_DCB_IN_AEN, &adapter->state))
+               return;
+
+       if (*val & BIT_8)
+               set_bit(__QLCNIC_DCB_STATE, &adapter->state);
+       else
+               clear_bit(__QLCNIC_DCB_STATE, &adapter->state);
+
+       queue_delayed_work(dcb->wq, &dcb->aen_work, 0);
+}
+
+static void qlcnic_dcb_fill_cee_tc_params(struct qlcnic_dcb_mbx_params *mbx,
+                                         struct qlcnic_dcb_param *each,
+                                         struct qlcnic_dcb_cee *type)
+{
+       struct qlcnic_dcb_tc_cfg *tc_cfg;
+       u8 i, tc, pgid;
+
+       for (i = 0; i < QLC_DCB_MAX_PRIO; i++) {
+               tc = QLC_DCB_GET_TC_PRIO(mbx->prio_tc_map, i);
+               tc_cfg = &type->tc_cfg[tc];
+               tc_cfg->valid = true;
+               tc_cfg->up_tc_map |= QLC_DCB_GET_MAP(i);
+
+               if (QLC_DCB_GET_PFC_PRIO(each->hdr_prio_pfc_map[1], i) &&
+                   type->pfc_mode_enable) {
+                       tc_cfg->prio_cfg[i].valid = true;
+                       tc_cfg->prio_cfg[i].pfc_type = QLC_PFC_FULL;
+               }
+
+               if (i < 4)
+                       pgid = QLC_DCB_GET_PGID_PRIO(each->prio_pg_map[0], i);
+               else
+                       pgid = QLC_DCB_GET_PGID_PRIO(each->prio_pg_map[1], i);
+
+               tc_cfg->pgid = pgid;
+
+               tc_cfg->prio_type = QLC_PRIO_LINK;
+               type->pg_cfg[tc_cfg->pgid].prio_count++;
+       }
+}
+
+static void qlcnic_dcb_fill_cee_pg_params(struct qlcnic_dcb_param *each,
+                                         struct qlcnic_dcb_cee *type)
+{
+       struct qlcnic_dcb_pg_cfg *pg_cfg;
+       u8 i, tsa, bw_per;
+
+       for (i = 0; i < QLC_DCB_MAX_PG; i++) {
+               pg_cfg = &type->pg_cfg[i];
+               pg_cfg->valid = true;
+
+               if (i < 4) {
+                       bw_per = QLC_DCB_GET_BWPER_PG(each->pg_bw_map[0], i);
+                       tsa = QLC_DCB_GET_TSA_PG(each->pg_tsa_map[0], i);
+               } else {
+                       bw_per = QLC_DCB_GET_BWPER_PG(each->pg_bw_map[1], i);
+                       tsa = QLC_DCB_GET_TSA_PG(each->pg_tsa_map[1], i);
+               }
+
+               pg_cfg->total_bw_percent = bw_per;
+               pg_cfg->tsa_type = tsa;
+       }
+}
+
+static void
+qlcnic_dcb_fill_cee_app_params(struct qlcnic_adapter *adapter, u8 idx,
+                              struct qlcnic_dcb_param *each,
+                              struct qlcnic_dcb_cee *type)
+{
+       struct qlcnic_dcb_app *app;
+       u8 i, num_app, map, cnt;
+       struct dcb_app new_app;
+
+       num_app = qlcnic_dcb_get_num_app(adapter, each->hdr_prio_pfc_map[0]);
+       for (i = 0; i < num_app; i++) {
+               app = &type->app[i];
+               app->valid = true;
+
+               /* Only for CEE (-1) */
+               app->selector = QLC_DCB_GET_SELECTOR_APP(each->app[i]) - 1;
+               new_app.selector = app->selector;
+               app->protocol = QLC_DCB_GET_PROTO_ID_APP(each->app[i]);
+               new_app.protocol = app->protocol;
+               map = qlcnic_dcb_get_prio_map_app(adapter, each->app[i]);
+               cnt = qlcnic_dcb_prio_count(map);
+
+               if (cnt >= QLC_DCB_MAX_TC)
+                       cnt = 0;
+
+               app->priority = cnt;
+               new_app.priority = cnt;
+
+               if (idx == QLC_DCB_OPER_IDX && adapter->netdev->dcbnl_ops)
+                       dcb_setapp(adapter->netdev, &new_app);
+       }
+}
+
+static void qlcnic_dcb_map_cee_params(struct qlcnic_adapter *adapter, u8 idx)
+{
+       struct qlcnic_dcb_mbx_params *mbx = adapter->dcb->param;
+       struct qlcnic_dcb_param *each = &mbx->type[idx];
+       struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg;
+       struct qlcnic_dcb_cee *type = &cfg->type[idx];
+
+       type->tc_param_valid = false;
+       type->pfc_mode_enable = false;
+       memset(type->tc_cfg, 0,
+              sizeof(struct qlcnic_dcb_tc_cfg) * QLC_DCB_MAX_TC);
+       memset(type->pg_cfg, 0,
+              sizeof(struct qlcnic_dcb_pg_cfg) * QLC_DCB_MAX_TC);
+
+       if (qlcnic_dcb_pfc_hdr_valid(adapter, each->hdr_prio_pfc_map[0]) &&
+           cfg->capability.max_pfc_tc)
+               type->pfc_mode_enable = true;
+
+       if (qlcnic_dcb_tsa_hdr_valid(adapter, each->hdr_prio_pfc_map[0]) &&
+           cfg->capability.max_ets_tc)
+               type->tc_param_valid = true;
+
+       qlcnic_dcb_fill_cee_tc_params(mbx, each, type);
+       qlcnic_dcb_fill_cee_pg_params(each, type);
+       qlcnic_dcb_fill_cee_app_params(adapter, idx, each, type);
+}
+
+static void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *adapter)
+{
+       int i;
+
+       for (i = 0; i < QLC_DCB_NUM_PARAM; i++)
+               qlcnic_dcb_map_cee_params(adapter, i);
+
+       dcbnl_cee_notify(adapter->netdev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0);
+}
+
+static u8 qlcnic_dcb_get_state(struct net_device *netdev)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+
+       return test_bit(__QLCNIC_DCB_STATE, &adapter->state);
+}
+
+static void qlcnic_dcb_get_perm_hw_addr(struct net_device *netdev, u8 *addr)
+{
+       memcpy(addr, netdev->dev_addr, netdev->addr_len);
+}
+
+static void
+qlcnic_dcb_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, u8 *prio,
+                           u8 *pgid, u8 *bw_per, u8 *up_tc_map)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_tc_cfg *tc_cfg, *temp;
+       struct qlcnic_dcb_cee *type;
+       u8 i, cnt, pg;
+
+       type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX];
+       *prio = *pgid = *bw_per = *up_tc_map = 0;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state) ||
+           !type->tc_param_valid)
+               return;
+
+       if (tc < 0 || (tc > QLC_DCB_MAX_TC))
+               return;
+
+       tc_cfg = &type->tc_cfg[tc];
+       if (!tc_cfg->valid)
+               return;
+
+       *pgid = tc_cfg->pgid;
+       *prio = tc_cfg->prio_type;
+       *up_tc_map = tc_cfg->up_tc_map;
+       pg = *pgid;
+
+       for (i = 0, cnt = 0; i < QLC_DCB_MAX_TC; i++) {
+               temp = &type->tc_cfg[i];
+               if (temp->valid && (pg == temp->pgid))
+                       cnt++;
+       }
+
+       tc_cfg->bwg_percent = (100 / cnt);
+       *bw_per = tc_cfg->bwg_percent;
+}
+
+static void qlcnic_dcb_get_pg_bwg_cfg_tx(struct net_device *netdev, int pgid,
+                                        u8 *bw_pct)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_pg_cfg *pgcfg;
+       struct qlcnic_dcb_cee *type;
+
+       *bw_pct = 0;
+       type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX];
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state) ||
+           !type->tc_param_valid)
+               return;
+
+       if (pgid < 0 || pgid > QLC_DCB_MAX_PG)
+               return;
+
+       pgcfg = &type->pg_cfg[pgid];
+       if (!pgcfg->valid)
+               return;
+
+       *bw_pct = pgcfg->total_bw_percent;
+}
+
+static void qlcnic_dcb_get_pfc_cfg(struct net_device *netdev, int prio,
+                                  u8 *setting)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_tc_cfg *tc_cfg;
+       u8 val = QLC_DCB_GET_MAP(prio);
+       struct qlcnic_dcb_cee *type;
+       u8 i;
+
+       *setting = 0;
+       type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX];
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state) ||
+           !type->pfc_mode_enable)
+               return;
+
+       for (i = 0; i < QLC_DCB_MAX_TC; i++) {
+               tc_cfg = &type->tc_cfg[i];
+               if (!tc_cfg->valid)
+                       continue;
+
+               if ((val & tc_cfg->up_tc_map) && (tc_cfg->prio_cfg[prio].valid))
+                       *setting = tc_cfg->prio_cfg[prio].pfc_type;
+       }
+}
+
+static u8 qlcnic_dcb_get_capability(struct net_device *netdev, int capid,
+                                   u8 *cap)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       switch (capid) {
+       case DCB_CAP_ATTR_PG:
+       case DCB_CAP_ATTR_UP2TC:
+       case DCB_CAP_ATTR_PFC:
+       case DCB_CAP_ATTR_GSP:
+               *cap = true;
+               break;
+       case DCB_CAP_ATTR_PG_TCS:
+       case DCB_CAP_ATTR_PFC_TCS:
+               *cap = 0x80;    /* 8 priorities for PGs */
+               break;
+       case DCB_CAP_ATTR_DCBX:
+               *cap = adapter->dcb->cfg->capability.dcb_capability;
+               break;
+       default:
+               *cap = false;
+       }
+
+       return 0;
+}
+
+static int qlcnic_dcb_get_num_tcs(struct net_device *netdev, int attr, u8 *num)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return -EINVAL;
+
+       switch (attr) {
+       case DCB_NUMTCS_ATTR_PG:
+               *num = cfg->capability.max_ets_tc;
+               return 0;
+       case DCB_NUMTCS_ATTR_PFC:
+               *num = cfg->capability.max_pfc_tc;
+               return 0;
+       default:
+               return -EINVAL;
+       }
+}
+
+static u8 qlcnic_dcb_get_app(struct net_device *netdev, u8 idtype, u16 id)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct dcb_app app = {
+                               .selector = idtype,
+                               .protocol = id,
+                            };
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       return dcb_getapp(netdev, &app);
+}
+
+static u8 qlcnic_dcb_get_pfc_state(struct net_device *netdev)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb *dcb = adapter->dcb;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       return dcb->cfg->type[QLC_DCB_OPER_IDX].pfc_mode_enable;
+}
+
+static u8 qlcnic_dcb_get_dcbx(struct net_device *netdev)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       return cfg->capability.dcb_capability;
+}
+
+static u8 qlcnic_dcb_get_feat_cfg(struct net_device *netdev, int fid, u8 *flag)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cee *type;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 1;
+
+       type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX];
+       *flag = 0;
+
+       switch (fid) {
+       case DCB_FEATCFG_ATTR_PG:
+               if (type->tc_param_valid)
+                       *flag |= DCB_FEATCFG_ENABLE;
+               else
+                       *flag |= DCB_FEATCFG_ERROR;
+               break;
+       case DCB_FEATCFG_ATTR_PFC:
+               if (type->pfc_mode_enable) {
+                       if (type->tc_cfg[0].prio_cfg[0].pfc_type)
+                               *flag |= DCB_FEATCFG_ENABLE;
+               } else {
+                       *flag |= DCB_FEATCFG_ERROR;
+               }
+               break;
+       case DCB_FEATCFG_ATTR_APP:
+               *flag |= DCB_FEATCFG_ENABLE;
+               break;
+       default:
+               netdev_err(netdev, "Invalid Feature ID %d\n", fid);
+               return 1;
+       }
+
+       return 0;
+}
+
+static inline void
+qlcnic_dcb_get_pg_tc_cfg_rx(struct net_device *netdev, int prio, u8 *prio_type,
+                           u8 *pgid, u8 *bw_pct, u8 *up_map)
+{
+       *prio_type = *pgid = *bw_pct = *up_map = 0;
+}
+
+static inline void
+qlcnic_dcb_get_pg_bwg_cfg_rx(struct net_device *netdev, int pgid, u8 *bw_pct)
+{
+       *bw_pct = 0;
+}
+
+static int qlcnic_dcb_peer_app_info(struct net_device *netdev,
+                                   struct dcb_peer_app_info *info,
+                                   u16 *app_count)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cee *peer;
+       int i;
+
+       *app_count = 0;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX];
+
+       for (i = 0; i < QLC_DCB_MAX_APP; i++) {
+               if (peer->app[i].valid)
+                       (*app_count)++;
+       }
+
+       return 0;
+}
+
+static int qlcnic_dcb_peer_app_table(struct net_device *netdev,
+                                    struct dcb_app *table)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cee *peer;
+       struct qlcnic_dcb_app *app;
+       int i, j;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX];
+
+       for (i = 0, j = 0; i < QLC_DCB_MAX_APP; i++) {
+               app = &peer->app[i];
+               if (!app->valid)
+                       continue;
+
+               table[j].selector = app->selector;
+               table[j].priority = app->priority;
+               table[j++].protocol = app->protocol;
+       }
+
+       return 0;
+}
+
+static int qlcnic_dcb_cee_peer_get_pg(struct net_device *netdev,
+                                     struct cee_pg *pg)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cee *peer;
+       u8 i, j, k, map;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX];
+
+       for (i = 0, j = 0; i < QLC_DCB_MAX_PG; i++) {
+               if (!peer->pg_cfg[i].valid)
+                       continue;
+
+               pg->pg_bw[j] = peer->pg_cfg[i].total_bw_percent;
+
+               for (k = 0; k < QLC_DCB_MAX_TC; k++) {
+                       if (peer->tc_cfg[i].valid &&
+                           (peer->tc_cfg[i].pgid == i)) {
+                               map = peer->tc_cfg[i].up_tc_map;
+                               pg->prio_pg[j++] = map;
+                               break;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+static int qlcnic_dcb_cee_peer_get_pfc(struct net_device *netdev,
+                                      struct cee_pfc *pfc)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg;
+       struct qlcnic_dcb_tc_cfg *tc;
+       struct qlcnic_dcb_cee *peer;
+       u8 i, setting, prio;
+
+       pfc->pfc_en = 0;
+
+       if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state))
+               return 0;
+
+       peer = &cfg->type[QLC_DCB_PEER_IDX];
+
+       for (i = 0; i < QLC_DCB_MAX_TC; i++) {
+               tc = &peer->tc_cfg[i];
+               prio = qlcnic_dcb_prio_count(tc->up_tc_map);
+
+               setting = 0;
+               qlcnic_dcb_get_pfc_cfg(netdev, prio, &setting);
+               if (setting)
+                       pfc->pfc_en |= QLC_DCB_GET_MAP(i);
+       }
+
+       pfc->tcs_supported = cfg->capability.max_pfc_tc;
+
+       return 0;
+}
+
+static const struct dcbnl_rtnl_ops qlcnic_dcbnl_ops = {
+       .getstate               = qlcnic_dcb_get_state,
+       .getpermhwaddr          = qlcnic_dcb_get_perm_hw_addr,
+       .getpgtccfgtx           = qlcnic_dcb_get_pg_tc_cfg_tx,
+       .getpgbwgcfgtx          = qlcnic_dcb_get_pg_bwg_cfg_tx,
+       .getpfccfg              = qlcnic_dcb_get_pfc_cfg,
+       .getcap                 = qlcnic_dcb_get_capability,
+       .getnumtcs              = qlcnic_dcb_get_num_tcs,
+       .getapp                 = qlcnic_dcb_get_app,
+       .getpfcstate            = qlcnic_dcb_get_pfc_state,
+       .getdcbx                = qlcnic_dcb_get_dcbx,
+       .getfeatcfg             = qlcnic_dcb_get_feat_cfg,
+
+       .getpgtccfgrx           = qlcnic_dcb_get_pg_tc_cfg_rx,
+       .getpgbwgcfgrx          = qlcnic_dcb_get_pg_bwg_cfg_rx,
+
+       .peer_getappinfo        = qlcnic_dcb_peer_app_info,
+       .peer_getapptable       = qlcnic_dcb_peer_app_table,
+       .cee_peer_getpg         = qlcnic_dcb_cee_peer_get_pg,
+       .cee_peer_getpfc        = qlcnic_dcb_cee_peer_get_pfc,
+};
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h
new file mode 100644 (file)
index 0000000..b87ce9f
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * QLogic qlcnic NIC Driver
+ * Copyright (c)  2009-2013 QLogic Corporation
+ *
+ * See LICENSE.qlcnic for copyright and licensing details.
+ */
+
+#ifndef __QLCNIC_DCBX_H
+#define __QLCNIC_DCBX_H
+
+void qlcnic_clear_dcb_ops(struct qlcnic_adapter *);
+
+#ifdef CONFIG_QLCNIC_DCB
+int __qlcnic_register_dcb(struct qlcnic_adapter *);
+#else
+static inline int __qlcnic_register_dcb(struct qlcnic_adapter *adapter)
+{ return 0; }
+#endif
+
+struct qlcnic_dcb_ops {
+       void (*init_dcbnl_ops) (struct qlcnic_adapter *);
+       void (*free) (struct qlcnic_adapter *);
+       int (*attach) (struct qlcnic_adapter *);
+       int (*query_hw_capability) (struct qlcnic_adapter *, char *);
+       int (*get_hw_capability) (struct qlcnic_adapter *);
+       void (*get_info) (struct qlcnic_adapter *);
+       int (*query_cee_param) (struct qlcnic_adapter *, char *, u8);
+       int (*get_cee_cfg) (struct qlcnic_adapter *);
+       int (*register_aen) (struct qlcnic_adapter *, bool);
+       void (*handle_aen) (struct qlcnic_adapter *, void *);
+};
+
+struct qlcnic_dcb {
+       struct qlcnic_dcb_mbx_params    *param;
+       struct qlcnic_adapter           *adapter;
+       struct delayed_work             aen_work;
+       struct workqueue_struct         *wq;
+       struct qlcnic_dcb_ops           *ops;
+       struct qlcnic_dcb_cfg           *cfg;
+};
+#endif
index 700a46324d09230b8d8ba6e6fc820bc0e56b9526..7b0c90efb365e27c7c35fec7068348e37f0d3974 100644 (file)
@@ -125,6 +125,14 @@ static const char qlcnic_83xx_mac_stats_strings[][ETH_GSTRING_LEN] = {
 };
 
 #define QLCNIC_STATS_LEN       ARRAY_SIZE(qlcnic_gstrings_stats)
+
+static const char qlcnic_tx_ring_stats_strings[][ETH_GSTRING_LEN] = {
+       "xmit_on",
+       "xmit_off",
+       "xmit_called",
+       "xmit_finished",
+};
+
 static const char qlcnic_83xx_rx_stats_strings[][ETH_GSTRING_LEN] = {
        "ctx_rx_bytes",
        "ctx_rx_pkts",
@@ -150,6 +158,7 @@ static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = {
        "Link_Test_on_offline",
        "Interrupt_Test_offline",
        "Internal_Loopback_offline",
+       "External_Loopback_offline",
        "EEPROM_Test_offline"
 };
 
@@ -266,7 +275,7 @@ int qlcnic_82xx_get_settings(struct qlcnic_adapter *adapter,
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        u32 speed, reg;
-       int check_sfp_module = 0;
+       int check_sfp_module = 0, err = 0;
        u16 pcifn = ahw->pci_func;
 
        /* read which mode */
@@ -289,7 +298,7 @@ int qlcnic_82xx_get_settings(struct qlcnic_adapter *adapter,
 
        } else if (adapter->ahw->port_type == QLCNIC_XGBE) {
                u32 val = 0;
-               val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR);
+               val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR, &err);
 
                if (val == QLCNIC_PORT_MODE_802_3_AP) {
                        ecmd->supported = SUPPORTED_1000baseT_Full;
@@ -300,9 +309,13 @@ int qlcnic_82xx_get_settings(struct qlcnic_adapter *adapter,
                }
 
                if (netif_running(adapter->netdev) && ahw->has_link_events) {
-                       reg = QLCRD32(adapter, P3P_LINK_SPEED_REG(pcifn));
-                       speed = P3P_LINK_SPEED_VAL(pcifn, reg);
-                       ahw->link_speed = speed * P3P_LINK_SPEED_MHZ;
+                       if (ahw->linkup) {
+                               reg = QLCRD32(adapter,
+                                             P3P_LINK_SPEED_REG(pcifn), &err);
+                               speed = P3P_LINK_SPEED_VAL(pcifn, reg);
+                               ahw->link_speed = speed * P3P_LINK_SPEED_MHZ;
+                       }
+
                        ethtool_cmd_speed_set(ecmd, ahw->link_speed);
                        ecmd->autoneg = ahw->link_autoneg;
                        ecmd->duplex = ahw->link_duplex;
@@ -463,13 +476,14 @@ static int qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 static int qlcnic_82xx_get_registers(struct qlcnic_adapter *adapter,
                                     u32 *regs_buff)
 {
-       int i, j = 0;
+       int i, j = 0, err = 0;
 
        for (i = QLCNIC_DEV_INFO_SIZE + 1; diag_registers[j] != -1; j++, i++)
                regs_buff[i] = QLC_SHARED_REG_RD32(adapter, diag_registers[j]);
        j = 0;
        while (ext_diag_registers[j] != -1)
-               regs_buff[i++] = QLCRD32(adapter, ext_diag_registers[j++]);
+               regs_buff[i++] = QLCRD32(adapter, ext_diag_registers[j++],
+                                        &err);
        return i;
 }
 
@@ -519,13 +533,16 @@ qlcnic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
 static u32 qlcnic_test_link(struct net_device *dev)
 {
        struct qlcnic_adapter *adapter = netdev_priv(dev);
+       int err = 0;
        u32 val;
 
        if (qlcnic_83xx_check(adapter)) {
                val = qlcnic_83xx_test_link(adapter);
                return (val & 1) ? 0 : 1;
        }
-       val = QLCRD32(adapter, CRB_XG_STATE_P3P);
+       val = QLCRD32(adapter, CRB_XG_STATE_P3P, &err);
+       if (err == -EIO)
+               return err;
        val = XG_LINK_STATE_P3P(adapter->ahw->pci_func, val);
        return (val == XG_LINK_UP_P3P) ? 0 : 1;
 }
@@ -621,15 +638,15 @@ qlcnic_set_ringparam(struct net_device *dev,
 static void qlcnic_get_channels(struct net_device *dev,
                struct ethtool_channels *channel)
 {
-       int min;
        struct qlcnic_adapter *adapter = netdev_priv(dev);
+       int min;
 
        min = min_t(int, adapter->ahw->max_rx_ques, num_online_cpus());
        channel->max_rx = rounddown_pow_of_two(min);
-       channel->max_tx = adapter->ahw->max_tx_ques;
+       channel->max_tx = min_t(int, QLCNIC_MAX_TX_RINGS, num_online_cpus());
 
        channel->rx_count = adapter->max_sds_rings;
-       channel->tx_count = adapter->ahw->max_tx_ques;
+       channel->tx_count = adapter->max_drv_tx_rings;
 }
 
 static int qlcnic_set_channels(struct net_device *dev,
@@ -637,18 +654,27 @@ static int qlcnic_set_channels(struct net_device *dev,
 {
        struct qlcnic_adapter *adapter = netdev_priv(dev);
        int err;
+       int txq = 0;
 
-       if (channel->other_count || channel->combined_count ||
-           channel->tx_count != channel->max_tx)
+       if (channel->other_count || channel->combined_count)
                return -EINVAL;
 
-       err = qlcnic_validate_max_rss(adapter, channel->rx_count);
-       if (err)
-               return err;
+       if (channel->rx_count) {
+               err = qlcnic_validate_max_rss(adapter, channel->rx_count);
+               if (err)
+                       return err;
+       }
+
+       if (channel->tx_count) {
+               err = qlcnic_validate_max_tx_rings(adapter, channel->tx_count);
+               if (err)
+                       return err;
+               txq = channel->tx_count;
+       }
 
-       err = qlcnic_set_max_rss(adapter, channel->rx_count, 0);
-       netdev_info(dev, "allocated 0x%x sds rings\n",
-                                adapter->max_sds_rings);
+       err = qlcnic_set_max_rss(adapter, channel->rx_count, txq);
+       netdev_info(dev, "allocated 0x%x sds rings and  0x%x tx rings\n",
+                   adapter->max_sds_rings, adapter->max_drv_tx_rings);
        return err;
 }
 
@@ -658,6 +684,7 @@ qlcnic_get_pauseparam(struct net_device *netdev,
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
        int port = adapter->ahw->physical_port;
+       int err = 0;
        __u32 val;
 
        if (qlcnic_83xx_check(adapter)) {
@@ -668,9 +695,13 @@ qlcnic_get_pauseparam(struct net_device *netdev,
                if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS))
                        return;
                /* get flow control settings */
-               val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port));
+               val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), &err);
+               if (err == -EIO)
+                       return;
                pause->rx_pause = qlcnic_gb_get_rx_flowctl(val);
-               val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL);
+               val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, &err);
+               if (err == -EIO)
+                       return;
                switch (port) {
                case 0:
                        pause->tx_pause = !(qlcnic_gb_get_gb0_mask(val));
@@ -690,7 +721,9 @@ qlcnic_get_pauseparam(struct net_device *netdev,
                if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS))
                        return;
                pause->rx_pause = 1;
-               val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL);
+               val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, &err);
+               if (err == -EIO)
+                       return;
                if (port == 0)
                        pause->tx_pause = !(qlcnic_xg_get_xg0_mask(val));
                else
@@ -707,6 +740,7 @@ qlcnic_set_pauseparam(struct net_device *netdev,
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
        int port = adapter->ahw->physical_port;
+       int err = 0;
        __u32 val;
 
        if (qlcnic_83xx_check(adapter))
@@ -717,7 +751,9 @@ qlcnic_set_pauseparam(struct net_device *netdev,
                if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS))
                        return -EIO;
                /* set flow control */
-               val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port));
+               val = QLCRD32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), &err);
+               if (err == -EIO)
+                       return err;
 
                if (pause->rx_pause)
                        qlcnic_gb_rx_flowctl(val);
@@ -728,7 +764,9 @@ qlcnic_set_pauseparam(struct net_device *netdev,
                                val);
                QLCWR32(adapter, QLCNIC_NIU_GB_MAC_CONFIG_0(port), val);
                /* set autoneg */
-               val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL);
+               val = QLCRD32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, &err);
+               if (err == -EIO)
+                       return err;
                switch (port) {
                case 0:
                        if (pause->tx_pause)
@@ -764,7 +802,9 @@ qlcnic_set_pauseparam(struct net_device *netdev,
                if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS))
                        return -EIO;
 
-               val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL);
+               val = QLCRD32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, &err);
+               if (err == -EIO)
+                       return err;
                if (port == 0) {
                        if (pause->tx_pause)
                                qlcnic_xg_unset_xg0_mask(val);
@@ -788,11 +828,14 @@ static int qlcnic_reg_test(struct net_device *dev)
 {
        struct qlcnic_adapter *adapter = netdev_priv(dev);
        u32 data_read;
+       int err = 0;
 
        if (qlcnic_83xx_check(adapter))
                return qlcnic_83xx_reg_test(adapter);
 
-       data_read = QLCRD32(adapter, QLCNIC_PCIX_PH_REG(0));
+       data_read = QLCRD32(adapter, QLCNIC_PCIX_PH_REG(0), &err);
+       if (err == -EIO)
+               return err;
        if ((data_read & 0xffff) != adapter->pdev->vendor)
                return 1;
 
@@ -867,6 +910,7 @@ free_diag_res:
 clear_diag_irq:
        adapter->max_sds_rings = max_sds_rings;
        clear_bit(__QLCNIC_RESETTING, &adapter->state);
+
        return ret;
 }
 
@@ -940,6 +984,7 @@ int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode)
 int qlcnic_loopback_test(struct net_device *netdev, u8 mode)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       int max_drv_tx_rings = adapter->max_drv_tx_rings;
        int max_sds_rings = adapter->max_sds_rings;
        struct qlcnic_host_sds_ring *sds_ring;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
@@ -980,9 +1025,9 @@ int qlcnic_loopback_test(struct net_device *netdev, u8 mode)
                msleep(500);
                qlcnic_process_rcv_ring_diag(sds_ring);
                if (loop++ > QLCNIC_ILB_MAX_RCV_LOOP) {
-                       netdev_info(netdev, "firmware didnt respond to loopback"
-                               " configure request\n");
-                       ret = -QLCNIC_FW_NOT_RESPOND;
+                       netdev_info(netdev,
+                                   "Firmware didn't sent link up event to loopback request\n");
+                       ret = -ETIMEDOUT;
                        goto free_res;
                } else if (adapter->ahw->diag_cnt) {
                        ret = adapter->ahw->diag_cnt;
@@ -999,6 +1044,7 @@ int qlcnic_loopback_test(struct net_device *netdev, u8 mode)
 
  clear_it:
        adapter->max_sds_rings = max_sds_rings;
+       adapter->max_drv_tx_rings = max_drv_tx_rings;
        clear_bit(__QLCNIC_RESETTING, &adapter->state);
        return ret;
 }
@@ -1026,8 +1072,15 @@ qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
                if (data[3])
                        eth_test->flags |= ETH_TEST_FL_FAILED;
 
-               data[4] = qlcnic_eeprom_test(dev);
-               if (data[4])
+               if (eth_test->flags & ETH_TEST_FL_EXTERNAL_LB) {
+                       data[4] = qlcnic_loopback_test(dev, QLCNIC_ELB_MODE);
+                       if (data[4])
+                               eth_test->flags |= ETH_TEST_FL_FAILED;
+                       eth_test->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE;
+               }
+
+               data[5] = qlcnic_eeprom_test(dev);
+               if (data[5])
                        eth_test->flags |= ETH_TEST_FL_FAILED;
        }
 }
@@ -1044,11 +1097,21 @@ qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 *data)
                       QLCNIC_TEST_LEN * ETH_GSTRING_LEN);
                break;
        case ETH_SS_STATS:
+               num_stats = ARRAY_SIZE(qlcnic_tx_ring_stats_strings);
+               for (i = 0; i < adapter->max_drv_tx_rings; i++) {
+                       for (index = 0; index < num_stats; index++) {
+                               sprintf(data, "tx_ring_%d %s", i,
+                                       qlcnic_tx_ring_stats_strings[index]);
+                               data += ETH_GSTRING_LEN;
+                       }
+               }
+
                for (index = 0; index < QLCNIC_STATS_LEN; index++) {
                        memcpy(data + index * ETH_GSTRING_LEN,
                               qlcnic_gstrings_stats[index].stat_string,
                               ETH_GSTRING_LEN);
                }
+
                if (qlcnic_83xx_check(adapter)) {
                        num_stats = ARRAY_SIZE(qlcnic_83xx_tx_stats_strings);
                        for (i = 0; i < num_stats; i++, index++)
@@ -1140,11 +1203,22 @@ static void qlcnic_get_ethtool_stats(struct net_device *dev,
                                     struct ethtool_stats *stats, u64 *data)
 {
        struct qlcnic_adapter *adapter = netdev_priv(dev);
+       struct qlcnic_host_tx_ring *tx_ring;
        struct qlcnic_esw_statistics port_stats;
        struct qlcnic_mac_statistics mac_stats;
-       int index, ret, length, size;
+       int index, ret, length, size, ring;
        char *p;
 
+       memset(data, 0, adapter->max_drv_tx_rings * 4 * sizeof(u64));
+       for (ring = 0, index = 0; ring < adapter->max_drv_tx_rings; ring++) {
+               if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
+                       tx_ring = &adapter->tx_ring[ring];
+                       *data++ = tx_ring->xmit_on;
+                       *data++ = tx_ring->xmit_off;
+                       *data++ = tx_ring->xmit_called;
+                       *data++ = tx_ring->xmit_finished;
+               }
+       }
        memset(data, 0, stats->n_stats * sizeof(u64));
        length = QLCNIC_STATS_LEN;
        for (index = 0; index < length; index++) {
@@ -1257,17 +1331,20 @@ qlcnic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
        struct qlcnic_adapter *adapter = netdev_priv(dev);
        u32 wol_cfg;
+       int err = 0;
 
        if (qlcnic_83xx_check(adapter))
                return;
        wol->supported = 0;
        wol->wolopts = 0;
 
-       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV);
+       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV, &err);
+       if (err == -EIO)
+               return;
        if (wol_cfg & (1UL << adapter->portnum))
                wol->supported |= WAKE_MAGIC;
 
-       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG);
+       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG, &err);
        if (wol_cfg & (1UL << adapter->portnum))
                wol->wolopts |= WAKE_MAGIC;
 }
@@ -1277,17 +1354,22 @@ qlcnic_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
        struct qlcnic_adapter *adapter = netdev_priv(dev);
        u32 wol_cfg;
+       int err = 0;
 
        if (qlcnic_83xx_check(adapter))
                return -EOPNOTSUPP;
        if (wol->wolopts & ~WAKE_MAGIC)
                return -EINVAL;
 
-       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV);
+       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV, &err);
+       if (err == -EIO)
+               return err;
        if (!(wol_cfg & (1 << adapter->portnum)))
                return -EOPNOTSUPP;
 
-       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG);
+       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG, &err);
+       if (err == -EIO)
+               return err;
        if (wol->wolopts & WAKE_MAGIC)
                wol_cfg |= 1UL << adapter->portnum;
        else
@@ -1540,7 +1622,7 @@ qlcnic_set_dump(struct net_device *netdev, struct ethtool_dump *val)
                return 0;
        case QLCNIC_SET_QUIESCENT:
        case QLCNIC_RESET_QUIESCENT:
-               state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
+               state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
                if (state == QLCNIC_DEV_FAILED || (state == QLCNIC_DEV_BADBAD))
                        netdev_info(netdev, "Device in FAILED state\n");
                return 0;
index 5b5d2edf125d9f93920b13d83fbfa802c96140fc..f8adc7b01f1f5ef9e62899a9c68c5eea9d2e2cba 100644 (file)
@@ -317,16 +317,20 @@ static void qlcnic_write_window_reg(u32 addr, void __iomem *bar0, u32 data)
 int
 qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg)
 {
-       int done = 0, timeout = 0;
+       int timeout = 0;
+       int err = 0;
+       u32 done = 0;
 
        while (!done) {
-               done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem)));
+               done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem)),
+                              &err);
                if (done == 1)
                        break;
                if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) {
                        dev_err(&adapter->pdev->dev,
                                "Failed to acquire sem=%d lock; holdby=%d\n",
-                               sem, id_reg ? QLCRD32(adapter, id_reg) : -1);
+                               sem,
+                               id_reg ? QLCRD32(adapter, id_reg, &err) : -1);
                        return -EIO;
                }
                msleep(1);
@@ -341,19 +345,22 @@ qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg)
 void
 qlcnic_pcie_sem_unlock(struct qlcnic_adapter *adapter, int sem)
 {
-       QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_UNLOCK(sem)));
+       int err = 0;
+
+       QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_UNLOCK(sem)), &err);
 }
 
 int qlcnic_ind_rd(struct qlcnic_adapter *adapter, u32 addr)
 {
+       int err = 0;
        u32 data;
 
        if (qlcnic_82xx_check(adapter))
                qlcnic_read_window_reg(addr, adapter->ahw->pci_base0, &data);
        else {
-               data = qlcnic_83xx_rd_reg_indirect(adapter, addr);
-               if (data == -EIO)
-                       return -EIO;
+               data = QLCRD32(adapter, addr, &err);
+               if (err == -EIO)
+                       return err;
        }
        return data;
 }
@@ -380,7 +387,7 @@ qlcnic_send_cmd_descs(struct qlcnic_adapter *adapter,
        if (!test_bit(__QLCNIC_FW_ATTACHED, &adapter->state))
                return -EIO;
 
-       tx_ring = adapter->tx_ring;
+       tx_ring = &adapter->tx_ring[0];
        __netif_tx_lock_bh(tx_ring->txq);
 
        producer = tx_ring->producer;
@@ -516,20 +523,18 @@ void __qlcnic_set_multi(struct net_device *netdev, u16 vlan)
        if (netdev->flags & IFF_PROMISC) {
                if (!(adapter->flags & QLCNIC_PROMISC_DISABLED))
                        mode = VPORT_MISS_MODE_ACCEPT_ALL;
-       } else if (netdev->flags & IFF_ALLMULTI) {
-               if (netdev_mc_count(netdev) > ahw->max_mc_count) {
-                       mode = VPORT_MISS_MODE_ACCEPT_MULTI;
-               } else if (!netdev_mc_empty(netdev) &&
-                          !qlcnic_sriov_vf_check(adapter)) {
-                               netdev_for_each_mc_addr(ha, netdev)
-                                       qlcnic_nic_add_mac(adapter, ha->addr,
-                                                          vlan);
-               }
-               if (mode != VPORT_MISS_MODE_ACCEPT_MULTI &&
-                   qlcnic_sriov_vf_check(adapter))
-                       qlcnic_vf_add_mc_list(netdev, vlan);
+       } else if ((netdev->flags & IFF_ALLMULTI) ||
+                  (netdev_mc_count(netdev) > ahw->max_mc_count)) {
+               mode = VPORT_MISS_MODE_ACCEPT_MULTI;
+       } else if (!netdev_mc_empty(netdev) &&
+                  !qlcnic_sriov_vf_check(adapter)) {
+               netdev_for_each_mc_addr(ha, netdev)
+                       qlcnic_nic_add_mac(adapter, ha->addr, vlan);
        }
 
+       if (qlcnic_sriov_vf_check(adapter))
+               qlcnic_vf_add_mc_list(netdev, vlan);
+
        /* configure unicast MAC address, if there is not sufficient space
         * to store all the unicast addresses then enable promiscuous mode
         */
@@ -735,6 +740,22 @@ int qlcnic_82xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
        return 0;
 }
 
+int qlcnic_82xx_read_phys_port_id(struct qlcnic_adapter *adapter)
+{
+       u8 mac[ETH_ALEN];
+       int ret;
+
+       ret = qlcnic_get_mac_address(adapter, mac,
+                                    adapter->ahw->physical_port);
+       if (ret)
+               return ret;
+
+       memcpy(adapter->ahw->phys_port_id, mac, ETH_ALEN);
+       adapter->flags |= QLCNIC_HAS_PHYS_PORT_ID;
+
+       return 0;
+}
+
 /*
  * Send the interrupt coalescing parameter set by ethtool to the card.
  */
@@ -1161,7 +1182,8 @@ int qlcnic_82xx_hw_write_wx_2M(struct qlcnic_adapter *adapter, ulong off,
        return -EIO;
 }
 
-int qlcnic_82xx_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off)
+int qlcnic_82xx_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off,
+                             int *err)
 {
        unsigned long flags;
        int rv;
@@ -1417,7 +1439,7 @@ int qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter, u64 off, u64 *data)
 
 int qlcnic_82xx_get_board_info(struct qlcnic_adapter *adapter)
 {
-       int offset, board_type, magic;
+       int offset, board_type, magic, err = 0;
        struct pci_dev *pdev = adapter->pdev;
 
        offset = QLCNIC_FW_MAGIC_OFFSET;
@@ -1437,7 +1459,9 @@ int qlcnic_82xx_get_board_info(struct qlcnic_adapter *adapter)
        adapter->ahw->board_type = board_type;
 
        if (board_type == QLCNIC_BRDTYPE_P3P_4_GB_MM) {
-               u32 gpio = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_PAD_GPIO_I);
+               u32 gpio = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_PAD_GPIO_I, &err);
+               if (err == -EIO)
+                       return err;
                if ((gpio & 0x8000) == 0)
                        board_type = QLCNIC_BRDTYPE_P3P_10G_TP;
        }
@@ -1477,10 +1501,13 @@ int
 qlcnic_wol_supported(struct qlcnic_adapter *adapter)
 {
        u32 wol_cfg;
+       int err = 0;
 
-       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV);
+       wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG_NV, &err);
        if (wol_cfg & (1UL << adapter->portnum)) {
-               wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG);
+               wol_cfg = QLCRD32(adapter, QLCNIC_WOL_CONFIG, &err);
+               if (err == -EIO)
+                       return err;
                if (wol_cfg & (1 << adapter->portnum))
                        return 1;
        }
@@ -1541,6 +1568,7 @@ void qlcnic_82xx_get_func_no(struct qlcnic_adapter *adapter)
 void qlcnic_82xx_read_crb(struct qlcnic_adapter *adapter, char *buf,
                          loff_t offset, size_t size)
 {
+       int err = 0;
        u32 data;
        u64 qmdata;
 
@@ -1548,7 +1576,7 @@ void qlcnic_82xx_read_crb(struct qlcnic_adapter *adapter, char *buf,
                qlcnic_pci_camqm_read_2M(adapter, offset, &qmdata);
                memcpy(buf, &qmdata, size);
        } else {
-               data = QLCRD32(adapter, offset);
+               data = QLCRD32(adapter, offset, &err);
                memcpy(buf, &data, size);
        }
 }
index 2c22504f57aac090b5cfecf9ec819f876b2ef6ed..272c356cf9b2a860beab0ec327f4b27bb47744bc 100644 (file)
@@ -85,8 +85,11 @@ enum qlcnic_regs {
 #define QLCNIC_CMD_GET_TEMP_HDR                        0x30
 #define QLCNIC_CMD_BC_EVENT_SETUP              0x31
 #define        QLCNIC_CMD_CONFIG_VPORT                 0x32
+#define        QLCNIC_CMD_DCB_QUERY_CAP                0x34
+#define        QLCNIC_CMD_DCB_QUERY_PARAM              0x35
 #define QLCNIC_CMD_GET_MAC_STATS               0x37
 #define QLCNIC_CMD_82XX_SET_DRV_VER            0x38
+#define QLCNIC_CMD_MQ_TX_CONFIG_INTR           0x39
 #define QLCNIC_CMD_GET_LED_STATUS              0x3C
 #define QLCNIC_CMD_CONFIGURE_RSS               0x41
 #define QLCNIC_CMD_CONFIG_INTR_COAL            0x43
@@ -122,6 +125,7 @@ enum qlcnic_regs {
 #define QLCNIC_MBX_COMP_EVENT          0x8100
 #define QLCNIC_MBX_REQUEST_EVENT       0x8101
 #define QLCNIC_MBX_TIME_EXTEND_EVENT   0x8102
+#define QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT    0x8110
 #define QLCNIC_MBX_SFP_INSERT_EVENT    0x8130
 #define QLCNIC_MBX_SFP_REMOVE_EVENT    0x8131
 
@@ -149,12 +153,11 @@ struct ethtool_stats;
 struct pci_device_id;
 struct qlcnic_host_sds_ring;
 struct qlcnic_host_tx_ring;
-struct qlcnic_host_tx_ring;
 struct qlcnic_hardware_context;
 struct qlcnic_adapter;
 
 int qlcnic_82xx_start_firmware(struct qlcnic_adapter *);
-int qlcnic_82xx_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong);
+int qlcnic_82xx_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong, int *);
 int qlcnic_82xx_hw_write_wx_2M(struct qlcnic_adapter *, ulong, u32);
 int qlcnic_82xx_config_hw_lro(struct qlcnic_adapter *adapter, int);
 int qlcnic_82xx_nic_set_promisc(struct qlcnic_adapter *adapter, u32);
@@ -173,10 +176,12 @@ int qlcnic_82xx_set_lb_mode(struct qlcnic_adapter *, u8);
 void qlcnic_82xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
 void qlcnic_82xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
 void qlcnic_82xx_dev_request_reset(struct qlcnic_adapter *, u32);
-int qlcnic_82xx_setup_intr(struct qlcnic_adapter *, u8);
+int qlcnic_82xx_setup_intr(struct qlcnic_adapter *, u8, int);
 irqreturn_t qlcnic_82xx_clear_legacy_intr(struct qlcnic_adapter *);
 int qlcnic_82xx_issue_cmd(struct qlcnic_adapter *adapter,
                          struct qlcnic_cmd_args *);
+int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *, int);
+int qlcnic_82xx_config_intrpt(struct qlcnic_adapter *, u8);
 int qlcnic_82xx_fw_cmd_create_rx_ctx(struct qlcnic_adapter *);
 int qlcnic_82xx_fw_cmd_create_tx_ctx(struct qlcnic_adapter *,
                                     struct qlcnic_host_tx_ring *tx_ring, int);
@@ -184,7 +189,7 @@ void qlcnic_82xx_fw_cmd_del_rx_ctx(struct qlcnic_adapter *);
 void qlcnic_82xx_fw_cmd_del_tx_ctx(struct qlcnic_adapter *,
                                   struct qlcnic_host_tx_ring *);
 int qlcnic_82xx_sre_macaddr_change(struct qlcnic_adapter *, u8 *, u16, u8);
-int qlcnic_82xx_get_mac_address(struct qlcnic_adapter *, u8*);
+int qlcnic_82xx_get_mac_address(struct qlcnic_adapter *, u8*, u8);
 int qlcnic_82xx_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8);
 int qlcnic_82xx_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *);
 int qlcnic_82xx_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info*);
index d28336fc65abe5752f4a295ae54708edf9d3b0ae..66c26cf7a2b89290524a2d85005ee847f43e925b 100644 (file)
@@ -127,12 +127,12 @@ void qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter)
        }
 }
 
-void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter)
+void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter,
+                              struct qlcnic_host_tx_ring *tx_ring)
 {
        struct qlcnic_cmd_buffer *cmd_buf;
        struct qlcnic_skb_frag *buffrag;
        int i, j;
-       struct qlcnic_host_tx_ring *tx_ring = adapter->tx_ring;
 
        cmd_buf = tx_ring->cmd_buf_arr;
        for (i = 0; i < tx_ring->num_desc; i++) {
@@ -142,7 +142,7 @@ void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter)
                                         buffrag->length, PCI_DMA_TODEVICE);
                        buffrag->dma = 0ULL;
                }
-               for (j = 0; j < cmd_buf->frag_count; j++) {
+               for (j = 1; j < cmd_buf->frag_count; j++) {
                        buffrag++;
                        if (buffrag->dma) {
                                pci_unmap_page(adapter->pdev, buffrag->dma,
@@ -241,7 +241,13 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
                sds_ring->irq = adapter->msix_entries[ring].vector;
                sds_ring->adapter = adapter;
                sds_ring->num_desc = adapter->num_rxd;
-
+               if (qlcnic_82xx_check(adapter)) {
+                       if (qlcnic_check_multi_tx(adapter) &&
+                           !adapter->ahw->diag_test)
+                               sds_ring->tx_ring = &adapter->tx_ring[ring];
+                       else
+                               sds_ring->tx_ring = &adapter->tx_ring[0];
+               }
                for (i = 0; i < NUM_RCV_DESC_RINGS; i++)
                        INIT_LIST_HEAD(&sds_ring->free_list[i]);
        }
@@ -286,10 +292,11 @@ static int qlcnic_wait_rom_done(struct qlcnic_adapter *adapter)
 {
        long timeout = 0;
        long done = 0;
+       int err = 0;
 
        cond_resched();
        while (done == 0) {
-               done = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_STATUS);
+               done = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_STATUS, &err);
                done &= 2;
                if (++timeout >= QLCNIC_MAX_ROM_WAIT_USEC) {
                        dev_err(&adapter->pdev->dev,
@@ -304,6 +311,8 @@ static int qlcnic_wait_rom_done(struct qlcnic_adapter *adapter)
 static int do_rom_fast_read(struct qlcnic_adapter *adapter,
                            u32 addr, u32 *valp)
 {
+       int err = 0;
+
        QLCWR32(adapter, QLCNIC_ROMUSB_ROM_ADDRESS, addr);
        QLCWR32(adapter, QLCNIC_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
        QLCWR32(adapter, QLCNIC_ROMUSB_ROM_ABYTE_CNT, 3);
@@ -317,7 +326,9 @@ static int do_rom_fast_read(struct qlcnic_adapter *adapter,
        udelay(10);
        QLCWR32(adapter, QLCNIC_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
 
-       *valp = QLCRD32(adapter, QLCNIC_ROMUSB_ROM_RDATA);
+       *valp = QLCRD32(adapter, QLCNIC_ROMUSB_ROM_RDATA, &err);
+       if (err == -EIO)
+               return err;
        return 0;
 }
 
@@ -369,11 +380,11 @@ int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, u32 addr, u32 *valp)
 
 int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
 {
-       int addr, val;
+       int addr, err = 0;
        int i, n, init_delay;
        struct crb_addr_pair *buf;
        unsigned offset;
-       u32 off;
+       u32 off, val;
        struct pci_dev *pdev = adapter->pdev;
 
        QLC_SHARED_REG_WR32(adapter, QLCNIC_CMDPEG_STATE, 0);
@@ -402,7 +413,9 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
        QLCWR32(adapter, QLCNIC_CRB_NIU + 0xb0000, 0x00);
 
        /* halt sre */
-       val = QLCRD32(adapter, QLCNIC_CRB_SRE + 0x1000);
+       val = QLCRD32(adapter, QLCNIC_CRB_SRE + 0x1000, &err);
+       if (err == -EIO)
+               return err;
        QLCWR32(adapter, QLCNIC_CRB_SRE + 0x1000, val & (~(0x1)));
 
        /* halt epg */
@@ -719,10 +732,12 @@ qlcnic_check_flash_fw_ver(struct qlcnic_adapter *adapter)
 static int
 qlcnic_has_mn(struct qlcnic_adapter *adapter)
 {
-       u32 capability;
-       capability = 0;
+       u32 capability = 0;
+       int err = 0;
 
-       capability = QLCRD32(adapter, QLCNIC_PEG_TUNE_CAPABILITY);
+       capability = QLCRD32(adapter, QLCNIC_PEG_TUNE_CAPABILITY, &err);
+       if (err == -EIO)
+               return err;
        if (capability & QLCNIC_PEG_TUNE_MN_PRESENT)
                return 1;
 
index d3f8797efcc3d7a6012ea56ddb4feda210727f22..8d06f884818dfbc804fc7369a07fa3ef73c9ece0 100644 (file)
 struct sk_buff *qlcnic_process_rxbuf(struct qlcnic_adapter *,
                                     struct qlcnic_host_rds_ring *, u16, u16);
 
+inline void qlcnic_enable_tx_intr(struct qlcnic_adapter *adapter,
+                                 struct qlcnic_host_tx_ring *tx_ring)
+{
+       if (qlcnic_check_multi_tx(adapter) &&
+           !adapter->ahw->diag_test)
+               writel(0x0, tx_ring->crb_intr_mask);
+}
+
+
+static inline void qlcnic_disable_tx_int(struct qlcnic_adapter *adapter,
+                                        struct qlcnic_host_tx_ring *tx_ring)
+{
+       if (qlcnic_check_multi_tx(adapter) &&
+           !adapter->ahw->diag_test)
+               writel(1, tx_ring->crb_intr_mask);
+}
+
 inline void qlcnic_83xx_enable_tx_intr(struct qlcnic_adapter *adapter,
                                       struct qlcnic_host_tx_ring *tx_ring)
 {
@@ -147,10 +164,7 @@ static inline u8 qlcnic_mac_hash(u64 mac)
 static inline u32 qlcnic_get_ref_handle(struct qlcnic_adapter *adapter,
                                        u16 handle, u8 ring_id)
 {
-       unsigned short device = adapter->pdev->device;
-
-       if ((device == PCI_DEVICE_ID_QLOGIC_QLE834X) ||
-           (device == PCI_DEVICE_ID_QLOGIC_VF_QLE834X))
+       if (qlcnic_83xx_check(adapter))
                return handle | (ring_id << 15);
        else
                return handle;
@@ -161,36 +175,68 @@ static inline int qlcnic_82xx_is_lb_pkt(u64 sts_data)
        return (qlcnic_get_sts_status(sts_data) == STATUS_CKSUM_LOOP) ? 1 : 0;
 }
 
+static void qlcnic_delete_rx_list_mac(struct qlcnic_adapter *adapter,
+                                     struct qlcnic_filter *fil,
+                                     void *addr, u16 vlan_id)
+{
+       int ret;
+       u8 op;
+
+       op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
+       ret = qlcnic_sre_macaddr_change(adapter, addr, vlan_id, op);
+       if (ret)
+               return;
+
+       op = vlan_id ? QLCNIC_MAC_VLAN_DEL : QLCNIC_MAC_DEL;
+       ret = qlcnic_sre_macaddr_change(adapter, addr, vlan_id, op);
+       if (!ret) {
+               hlist_del(&fil->fnode);
+               adapter->rx_fhash.fnum--;
+       }
+}
+
+static struct qlcnic_filter *qlcnic_find_mac_filter(struct hlist_head *head,
+                                                   void *addr, u16 vlan_id)
+{
+       struct qlcnic_filter *tmp_fil = NULL;
+       struct hlist_node *n;
+
+       hlist_for_each_entry_safe(tmp_fil, n, head, fnode) {
+               if (!memcmp(tmp_fil->faddr, addr, ETH_ALEN) &&
+                   tmp_fil->vlan_id == vlan_id)
+                       return tmp_fil;
+       }
+
+       return NULL;
+}
+
 void qlcnic_add_lb_filter(struct qlcnic_adapter *adapter, struct sk_buff *skb,
                          int loopback_pkt, u16 vlan_id)
 {
        struct ethhdr *phdr = (struct ethhdr *)(skb->data);
        struct qlcnic_filter *fil, *tmp_fil;
-       struct hlist_node *n;
        struct hlist_head *head;
        unsigned long time;
        u64 src_addr = 0;
-       u8 hindex, found = 0, op;
+       u8 hindex, op;
        int ret;
 
        memcpy(&src_addr, phdr->h_source, ETH_ALEN);
+       hindex = qlcnic_mac_hash(src_addr) &
+                (adapter->fhash.fbucket_size - 1);
 
        if (loopback_pkt) {
                if (adapter->rx_fhash.fnum >= adapter->rx_fhash.fmax)
                        return;
 
-               hindex = qlcnic_mac_hash(src_addr) &
-                        (adapter->fhash.fbucket_size - 1);
                head = &(adapter->rx_fhash.fhead[hindex]);
 
-               hlist_for_each_entry_safe(tmp_fil, n, head, fnode) {
-                       if (!memcmp(tmp_fil->faddr, &src_addr, ETH_ALEN) &&
-                           tmp_fil->vlan_id == vlan_id) {
-                               time = tmp_fil->ftime;
-                               if (jiffies > (QLCNIC_READD_AGE * HZ + time))
-                                       tmp_fil->ftime = jiffies;
-                               return;
-                       }
+               tmp_fil = qlcnic_find_mac_filter(head, &src_addr, vlan_id);
+               if (tmp_fil) {
+                       time = tmp_fil->ftime;
+                       if (time_after(jiffies, QLCNIC_READD_AGE * HZ + time))
+                               tmp_fil->ftime = jiffies;
+                       return;
                }
 
                fil = kzalloc(sizeof(struct qlcnic_filter), GFP_ATOMIC);
@@ -205,36 +251,37 @@ void qlcnic_add_lb_filter(struct qlcnic_adapter *adapter, struct sk_buff *skb,
                adapter->rx_fhash.fnum++;
                spin_unlock(&adapter->rx_mac_learn_lock);
        } else {
-               hindex = qlcnic_mac_hash(src_addr) &
-                        (adapter->fhash.fbucket_size - 1);
-               head = &(adapter->rx_fhash.fhead[hindex]);
-               spin_lock(&adapter->rx_mac_learn_lock);
-               hlist_for_each_entry_safe(tmp_fil, n, head, fnode) {
-                       if (!memcmp(tmp_fil->faddr, &src_addr, ETH_ALEN) &&
-                           tmp_fil->vlan_id == vlan_id) {
-                               found = 1;
-                               break;
-                       }
-               }
+               head = &adapter->fhash.fhead[hindex];
 
-               if (!found) {
-                       spin_unlock(&adapter->rx_mac_learn_lock);
-                       return;
-               }
+               spin_lock(&adapter->mac_learn_lock);
 
-               op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
-               ret = qlcnic_sre_macaddr_change(adapter, (u8 *)&src_addr,
-                                               vlan_id, op);
-               if (!ret) {
+               tmp_fil = qlcnic_find_mac_filter(head, &src_addr, vlan_id);
+               if (tmp_fil) {
                        op = vlan_id ? QLCNIC_MAC_VLAN_DEL : QLCNIC_MAC_DEL;
                        ret = qlcnic_sre_macaddr_change(adapter,
                                                        (u8 *)&src_addr,
                                                        vlan_id, op);
                        if (!ret) {
-                               hlist_del(&(tmp_fil->fnode));
-                               adapter->rx_fhash.fnum--;
+                               hlist_del(&tmp_fil->fnode);
+                               adapter->fhash.fnum--;
                        }
+
+                       spin_unlock(&adapter->mac_learn_lock);
+
+                       return;
                }
+
+               spin_unlock(&adapter->mac_learn_lock);
+
+               head = &adapter->rx_fhash.fhead[hindex];
+
+               spin_lock(&adapter->rx_mac_learn_lock);
+
+               tmp_fil = qlcnic_find_mac_filter(head, &src_addr, vlan_id);
+               if (tmp_fil)
+                       qlcnic_delete_rx_list_mac(adapter, tmp_fil, &src_addr,
+                                                 vlan_id);
+
                spin_unlock(&adapter->rx_mac_learn_lock);
        }
 }
@@ -262,7 +309,7 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr,
 
        mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
        mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
-       memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
+       memcpy(mac_req->mac_addr, uaddr, ETH_ALEN);
 
        vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
        vlan_req->vlan_id = cpu_to_le16(vlan_id);
@@ -324,14 +371,14 @@ static void qlcnic_send_filter(struct qlcnic_adapter *adapter,
 }
 
 static int qlcnic_tx_pkt(struct qlcnic_adapter *adapter,
-                        struct cmd_desc_type0 *first_desc, struct sk_buff *skb)
+                        struct cmd_desc_type0 *first_desc, struct sk_buff *skb,
+                        struct qlcnic_host_tx_ring *tx_ring)
 {
        u8 l4proto, opcode = 0, hdr_len = 0;
        u16 flags = 0, vlan_tci = 0;
        int copied, offset, copy_len, size;
        struct cmd_desc_type0 *hwdesc;
        struct vlan_ethhdr *vh;
-       struct qlcnic_host_tx_ring *tx_ring = adapter->tx_ring;
        u16 protocol = ntohs(skb->protocol);
        u32 producer = tx_ring->producer;
 
@@ -514,7 +561,7 @@ static inline void qlcnic_clear_cmddesc(u64 *desc)
 netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
-       struct qlcnic_host_tx_ring *tx_ring = adapter->tx_ring;
+       struct qlcnic_host_tx_ring *tx_ring;
        struct qlcnic_cmd_buffer *pbuf;
        struct qlcnic_skb_frag *buffrag;
        struct cmd_desc_type0 *hwdesc, *first_desc;
@@ -523,10 +570,8 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        int i, k, frag_count, delta = 0;
        u32 producer, num_txd;
 
-       num_txd = tx_ring->num_desc;
-
        if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
-               netif_stop_queue(netdev);
+               netif_tx_stop_all_queues(netdev);
                return NETDEV_TX_BUSY;
        }
 
@@ -536,7 +581,14 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                        goto drop_packet;
        }
 
+       if (qlcnic_check_multi_tx(adapter))
+               tx_ring = &adapter->tx_ring[skb_get_queue_mapping(skb)];
+       else
+               tx_ring = &adapter->tx_ring[0];
+       num_txd = tx_ring->num_desc;
+
        frag_count = skb_shinfo(skb)->nr_frags + 1;
+
        /* 14 frags supported for normal packet and
         * 32 frags supported for TSO packet
         */
@@ -551,11 +603,12 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        }
 
        if (unlikely(qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH)) {
-               netif_stop_queue(netdev);
+               netif_tx_stop_queue(tx_ring->txq);
                if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) {
-                       netif_start_queue(netdev);
+                       netif_tx_start_queue(tx_ring->txq);
                } else {
                        adapter->stats.xmit_off++;
+                       tx_ring->xmit_off++;
                        return NETDEV_TX_BUSY;
                }
        }
@@ -610,7 +663,7 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        tx_ring->producer = get_next_index(producer, num_txd);
        smp_mb();
 
-       if (unlikely(qlcnic_tx_pkt(adapter, first_desc, skb)))
+       if (unlikely(qlcnic_tx_pkt(adapter, first_desc, skb, tx_ring)))
                goto unwind_buff;
 
        if (adapter->drv_mac_learn)
@@ -618,6 +671,7 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 
        adapter->stats.txbytes += skb->len;
        adapter->stats.xmitcalled++;
+       tx_ring->xmit_called++;
 
        qlcnic_update_cmd_producer(tx_ring);
 
@@ -640,7 +694,7 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup)
                adapter->ahw->linkup = 0;
                if (netif_running(netdev)) {
                        netif_carrier_off(netdev);
-                       netif_stop_queue(netdev);
+                       netif_tx_stop_all_queues(netdev);
                }
        } else if (!adapter->ahw->linkup && linkup) {
                netdev_info(netdev, "NIC Link is up\n");
@@ -735,9 +789,6 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
        struct net_device *netdev = adapter->netdev;
        struct qlcnic_skb_frag *frag;
 
-       if (!spin_trylock(&adapter->tx_clean_lock))
-               return 1;
-
        sw_consumer = tx_ring->sw_consumer;
        hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
 
@@ -755,6 +806,7 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
                                frag->dma = 0ULL;
                        }
                        adapter->stats.xmitfinished++;
+                       tx_ring->xmit_finished++;
                        dev_kfree_skb_any(buffer->skb);
                        buffer->skb = NULL;
                }
@@ -767,10 +819,12 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
        if (count && netif_running(netdev)) {
                tx_ring->sw_consumer = sw_consumer;
                smp_mb();
-               if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) {
+               if (netif_tx_queue_stopped(tx_ring->txq) &&
+                   netif_carrier_ok(netdev)) {
                        if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) {
-                               netif_wake_queue(netdev);
+                               netif_tx_wake_queue(tx_ring->txq);
                                adapter->stats.xmit_on++;
+                               tx_ring->xmit_on++;
                        }
                }
                adapter->tx_timeo_cnt = 0;
@@ -790,7 +844,6 @@ static int qlcnic_process_cmd_ring(struct qlcnic_adapter *adapter,
         */
        hw_consumer = le32_to_cpu(*(tx_ring->hw_consumer));
        done = (sw_consumer == hw_consumer);
-       spin_unlock(&adapter->tx_clean_lock);
 
        return done;
 }
@@ -800,16 +853,40 @@ static int qlcnic_poll(struct napi_struct *napi, int budget)
        int tx_complete, work_done;
        struct qlcnic_host_sds_ring *sds_ring;
        struct qlcnic_adapter *adapter;
+       struct qlcnic_host_tx_ring *tx_ring;
 
        sds_ring = container_of(napi, struct qlcnic_host_sds_ring, napi);
        adapter = sds_ring->adapter;
-       tx_complete = qlcnic_process_cmd_ring(adapter, adapter->tx_ring,
+       tx_ring = sds_ring->tx_ring;
+
+       tx_complete = qlcnic_process_cmd_ring(adapter, tx_ring,
                                              budget);
        work_done = qlcnic_process_rcv_ring(sds_ring, budget);
        if ((work_done < budget) && tx_complete) {
                napi_complete(&sds_ring->napi);
-               if (test_bit(__QLCNIC_DEV_UP, &adapter->state))
+               if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
                        qlcnic_enable_int(sds_ring);
+                       qlcnic_enable_tx_intr(adapter, tx_ring);
+               }
+       }
+
+       return work_done;
+}
+
+static int qlcnic_tx_poll(struct napi_struct *napi, int budget)
+{
+       struct qlcnic_host_tx_ring *tx_ring;
+       struct qlcnic_adapter *adapter;
+       int work_done;
+
+       tx_ring = container_of(napi, struct qlcnic_host_tx_ring, napi);
+       adapter = tx_ring->adapter;
+
+       work_done = qlcnic_process_cmd_ring(adapter, tx_ring, budget);
+       if (work_done) {
+               napi_complete(&tx_ring->napi);
+               if (test_bit(__QLCNIC_DEV_UP, &adapter->state))
+                       qlcnic_enable_tx_intr(adapter, tx_ring);
        }
 
        return work_done;
@@ -919,20 +996,23 @@ static void qlcnic_handle_fw_message(int desc_cnt, int index,
                        break;
                case 1:
                        dev_info(dev, "loopback already in progress\n");
-                       adapter->ahw->diag_cnt = -QLCNIC_TEST_IN_PROGRESS;
+                       adapter->ahw->diag_cnt = -EINPROGRESS;
                        break;
                case 2:
                        dev_info(dev, "loopback cable is not connected\n");
-                       adapter->ahw->diag_cnt = -QLCNIC_LB_CABLE_NOT_CONN;
+                       adapter->ahw->diag_cnt = -ENODEV;
                        break;
                default:
                        dev_info(dev,
                                 "loopback configure request failed, err %x\n",
                                 ret);
-                       adapter->ahw->diag_cnt = -QLCNIC_UNDEFINED_ERROR;
+                       adapter->ahw->diag_cnt = -EIO;
                        break;
                }
                break;
+       case QLCNIC_C2H_OPCODE_GET_DCB_AEN:
+               qlcnic_dcb_handle_aen(adapter, (void *)&msg);
+               break;
        default:
                break;
        }
@@ -1381,6 +1461,7 @@ int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,
        int ring, max_sds_rings;
        struct qlcnic_host_sds_ring *sds_ring;
        struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
+       struct qlcnic_host_tx_ring *tx_ring;
 
        if (qlcnic_alloc_sds_rings(recv_ctx, adapter->max_sds_rings))
                return -ENOMEM;
@@ -1389,12 +1470,22 @@ int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,
 
        for (ring = 0; ring < adapter->max_sds_rings; ring++) {
                sds_ring = &recv_ctx->sds_rings[ring];
-               if (ring == adapter->max_sds_rings - 1)
-                       netif_napi_add(netdev, &sds_ring->napi, qlcnic_poll,
-                                      QLCNIC_NETDEV_WEIGHT / max_sds_rings);
-               else
+               if (qlcnic_check_multi_tx(adapter) &&
+                   !adapter->ahw->diag_test &&
+                   (adapter->max_drv_tx_rings > 1)) {
                        netif_napi_add(netdev, &sds_ring->napi, qlcnic_rx_poll,
-                                      QLCNIC_NETDEV_WEIGHT*2);
+                                       QLCNIC_NETDEV_WEIGHT * 2);
+               } else {
+                       if (ring == (adapter->max_sds_rings - 1))
+                               netif_napi_add(netdev, &sds_ring->napi,
+                                              qlcnic_poll,
+                                              QLCNIC_NETDEV_WEIGHT /
+                                              max_sds_rings);
+                       else
+                               netif_napi_add(netdev, &sds_ring->napi,
+                                              qlcnic_rx_poll,
+                                              QLCNIC_NETDEV_WEIGHT * 2);
+               }
        }
 
        if (qlcnic_alloc_tx_rings(adapter, netdev)) {
@@ -1402,6 +1493,14 @@ int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,
                return -ENOMEM;
        }
 
+       if (qlcnic_check_multi_tx(adapter) && !adapter->ahw->diag_test) {
+               for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
+                       tx_ring = &adapter->tx_ring[ring];
+                       netif_napi_add(netdev, &tx_ring->napi, qlcnic_tx_poll,
+                                      QLCNIC_NETDEV_WEIGHT);
+               }
+       }
+
        return 0;
 }
 
@@ -1410,6 +1509,7 @@ void qlcnic_82xx_napi_del(struct qlcnic_adapter *adapter)
        int ring;
        struct qlcnic_host_sds_ring *sds_ring;
        struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
+       struct qlcnic_host_tx_ring *tx_ring;
 
        for (ring = 0; ring < adapter->max_sds_rings; ring++) {
                sds_ring = &recv_ctx->sds_rings[ring];
@@ -1417,6 +1517,14 @@ void qlcnic_82xx_napi_del(struct qlcnic_adapter *adapter)
        }
 
        qlcnic_free_sds_rings(adapter->recv_ctx);
+
+       if (qlcnic_check_multi_tx(adapter) && !adapter->ahw->diag_test) {
+               for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
+                       tx_ring = &adapter->tx_ring[ring];
+                       netif_napi_del(&tx_ring->napi);
+               }
+       }
+
        qlcnic_free_tx_rings(adapter);
 }
 
@@ -1424,6 +1532,7 @@ void qlcnic_82xx_napi_enable(struct qlcnic_adapter *adapter)
 {
        int ring;
        struct qlcnic_host_sds_ring *sds_ring;
+       struct qlcnic_host_tx_ring *tx_ring;
        struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
 
        if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
@@ -1434,12 +1543,24 @@ void qlcnic_82xx_napi_enable(struct qlcnic_adapter *adapter)
                napi_enable(&sds_ring->napi);
                qlcnic_enable_int(sds_ring);
        }
+
+       if (qlcnic_check_multi_tx(adapter) &&
+           (adapter->flags & QLCNIC_MSIX_ENABLED) &&
+           !adapter->ahw->diag_test &&
+           (adapter->max_drv_tx_rings > 1)) {
+               for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
+                       tx_ring = &adapter->tx_ring[ring];
+                       napi_enable(&tx_ring->napi);
+                       qlcnic_enable_tx_intr(adapter, tx_ring);
+               }
+       }
 }
 
 void qlcnic_82xx_napi_disable(struct qlcnic_adapter *adapter)
 {
        int ring;
        struct qlcnic_host_sds_ring *sds_ring;
+       struct qlcnic_host_tx_ring *tx_ring;
        struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx;
 
        if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
@@ -1451,6 +1572,17 @@ void qlcnic_82xx_napi_disable(struct qlcnic_adapter *adapter)
                napi_synchronize(&sds_ring->napi);
                napi_disable(&sds_ring->napi);
        }
+
+       if ((adapter->flags & QLCNIC_MSIX_ENABLED) &&
+           !adapter->ahw->diag_test &&
+           qlcnic_check_multi_tx(adapter)) {
+               for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
+                       tx_ring = &adapter->tx_ring[ring];
+                       qlcnic_disable_tx_int(adapter, tx_ring);
+                       napi_synchronize(&tx_ring->napi);
+                       napi_disable(&tx_ring->napi);
+               }
+       }
 }
 
 #define QLC_83XX_NORMAL_LB_PKT (1ULL << 36)
index 4528f8ec333bb50d01c116958cb1a86c7392ef7c..7dde3ba6d9a4e754f3f4e2529f7f3e701d271a8c 100644 (file)
@@ -100,6 +100,8 @@ static DEFINE_PCI_DEVICE_TABLE(qlcnic_pci_tbl) = {
        ENTRY(PCI_DEVICE_ID_QLOGIC_QLE824X),
        ENTRY(PCI_DEVICE_ID_QLOGIC_QLE834X),
        ENTRY(PCI_DEVICE_ID_QLOGIC_VF_QLE834X),
+       ENTRY(PCI_DEVICE_ID_QLOGIC_QLE844X),
+       ENTRY(PCI_DEVICE_ID_QLOGIC_VF_QLE844X),
        {0,}
 };
 
@@ -145,6 +147,11 @@ static const u32 qlcnic_reg_tbl[] = {
 };
 
 static const struct qlcnic_board_info qlcnic_boards[] = {
+       { PCI_VENDOR_ID_QLOGIC,
+         PCI_DEVICE_ID_QLOGIC_QLE844X,
+         0x0,
+         0x0,
+         "8400 series 10GbE Converged Network Adapter (TCP/IP Networking)" },
        { PCI_VENDOR_ID_QLOGIC,
          PCI_DEVICE_ID_QLOGIC_QLE834X,
          PCI_VENDOR_ID_QLOGIC,
@@ -254,7 +261,6 @@ static const struct qlcnic_board_info qlcnic_boards[] = {
 };
 
 #define NUM_SUPPORTED_BOARDS ARRAY_SIZE(qlcnic_boards)
-#define QLC_MAX_SDS_RINGS      8
 
 static const
 struct qlcnic_legacy_intr_set legacy_intr[] = QLCNIC_LEGACY_INTR_CONFIG;
@@ -278,12 +284,15 @@ void qlcnic_free_sds_rings(struct qlcnic_recv_context *recv_ctx)
 
 int qlcnic_read_mac_addr(struct qlcnic_adapter *adapter)
 {
-       u8 mac_addr[ETH_ALEN];
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
+       u8 mac_addr[ETH_ALEN];
+       int ret;
 
-       if (qlcnic_get_mac_address(adapter, mac_addr) != 0)
-               return -EIO;
+       ret = qlcnic_get_mac_address(adapter, mac_addr,
+                                    adapter->ahw->pci_func);
+       if (ret)
+               return ret;
 
        memcpy(netdev->dev_addr, mac_addr, ETH_ALEN);
        memcpy(adapter->mac_addr, netdev->dev_addr, netdev->addr_len);
@@ -425,6 +434,21 @@ static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter)
        cancel_delayed_work_sync(&adapter->fw_work);
 }
 
+static int qlcnic_get_phys_port_id(struct net_device *netdev,
+                                  struct netdev_phys_port_id *ppid)
+{
+       struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+
+       if (!(adapter->flags & QLCNIC_HAS_PHYS_PORT_ID))
+               return -EOPNOTSUPP;
+
+       ppid->id_len = sizeof(ahw->phys_port_id);
+       memcpy(ppid->id, ahw->phys_port_id, ppid->id_len);
+
+       return 0;
+}
+
 static const struct net_device_ops qlcnic_netdev_ops = {
        .ndo_open          = qlcnic_open,
        .ndo_stop          = qlcnic_close,
@@ -442,6 +466,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
        .ndo_fdb_add            = qlcnic_fdb_add,
        .ndo_fdb_del            = qlcnic_fdb_del,
        .ndo_fdb_dump           = qlcnic_fdb_dump,
+       .ndo_get_phys_port_id   = qlcnic_get_phys_port_id,
 #ifdef CONFIG_NET_POLL_CONTROLLER
        .ndo_poll_controller = qlcnic_poll_controller,
 #endif
@@ -514,13 +539,33 @@ static struct qlcnic_hardware_ops qlcnic_hw_ops = {
        .get_board_info                 = qlcnic_82xx_get_board_info,
        .set_mac_filter_count           = qlcnic_82xx_set_mac_filter_count,
        .free_mac_list                  = qlcnic_82xx_free_mac_list,
+       .read_phys_port_id              = qlcnic_82xx_read_phys_port_id,
 };
 
+static void qlcnic_get_multiq_capability(struct qlcnic_adapter *adapter)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       int num_tx_q;
+
+       if (ahw->msix_supported &&
+           (ahw->extra_capability[0] & QLCNIC_FW_CAPABILITY_2_MULTI_TX)) {
+               num_tx_q = min_t(int, QLCNIC_DEF_NUM_TX_RINGS,
+                                num_online_cpus());
+               if (num_tx_q > 1) {
+                       test_and_set_bit(__QLCNIC_MULTI_TX_UNIQUE,
+                                        &adapter->state);
+                       adapter->max_drv_tx_rings = num_tx_q;
+               }
+       } else {
+               adapter->max_drv_tx_rings = 1;
+       }
+}
+
 int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
 {
        struct pci_dev *pdev = adapter->pdev;
+       int max_tx_rings, max_sds_rings, tx_vector;
        int err = -1, i;
-       int max_tx_rings, tx_vector;
 
        if (adapter->flags & QLCNIC_TX_INTR_SHARED) {
                max_tx_rings = 0;
@@ -554,7 +599,15 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
                                adapter->max_sds_rings = num_msix -
                                                         max_tx_rings - 1;
                        } else {
-                               adapter->max_sds_rings = num_msix;
+                               adapter->ahw->num_msix = num_msix;
+                               if (qlcnic_check_multi_tx(adapter) &&
+                                   !adapter->ahw->diag_test &&
+                                   (adapter->max_drv_tx_rings > 1))
+                                       max_sds_rings = num_msix - max_tx_rings;
+                               else
+                                       max_sds_rings = num_msix;
+
+                               adapter->max_sds_rings = max_sds_rings;
                        }
                        dev_info(&pdev->dev, "using msi-x interrupts\n");
                        return err;
@@ -570,6 +623,8 @@ int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
                                num_msix += (max_tx_rings + 1);
                        } else {
                                num_msix = rounddown_pow_of_two(err);
+                               if (qlcnic_check_multi_tx(adapter))
+                                       num_msix += max_tx_rings;
                        }
 
                        if (num_msix) {
@@ -605,6 +660,7 @@ static int qlcnic_enable_msi_legacy(struct qlcnic_adapter *adapter)
                adapter->msix_entries[0].vector = pdev->irq;
                return err;
        }
+
        if (qlcnic_use_msi || qlcnic_use_msi_x)
                return -EOPNOTSUPP;
 
@@ -621,28 +677,69 @@ static int qlcnic_enable_msi_legacy(struct qlcnic_adapter *adapter)
        return err;
 }
 
-int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
+int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr, int txq)
 {
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
        int num_msix, err = 0;
 
        if (!num_intr)
                num_intr = QLCNIC_DEF_NUM_STS_DESC_RINGS;
 
-       if (adapter->ahw->msix_supported)
+       if (ahw->msix_supported) {
                num_msix = rounddown_pow_of_two(min_t(int, num_online_cpus(),
                                                num_intr));
-       else
+               if (qlcnic_check_multi_tx(adapter)) {
+                       if (txq)
+                               adapter->max_drv_tx_rings = txq;
+                       num_msix += adapter->max_drv_tx_rings;
+               }
+       } else {
                num_msix = 1;
+       }
 
        err = qlcnic_enable_msix(adapter, num_msix);
-       if (err == -ENOMEM || !err)
+       if (err == -ENOMEM)
                return err;
 
-       err = qlcnic_enable_msi_legacy(adapter);
-       if (!err)
+       if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) {
+               qlcnic_disable_multi_tx(adapter);
+
+               err = qlcnic_enable_msi_legacy(adapter);
+               if (!err)
+                       return err;
+       }
+
+       return 0;
+}
+
+int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type)
+{
+       struct qlcnic_hardware_context *ahw = adapter->ahw;
+       int err, i;
+
+       if (qlcnic_check_multi_tx(adapter) &&
+           !ahw->diag_test &&
+           (adapter->flags & QLCNIC_MSIX_ENABLED)) {
+               ahw->intr_tbl = vzalloc(ahw->num_msix *
+                                       sizeof(struct qlcnic_intrpt_config));
+               if (!ahw->intr_tbl)
+                       return -ENOMEM;
+
+               for (i = 0; i < ahw->num_msix; i++) {
+                       ahw->intr_tbl[i].type = QLCNIC_INTRPT_MSIX;
+                       ahw->intr_tbl[i].id = i;
+                       ahw->intr_tbl[i].src = 0;
+               }
+
+               err = qlcnic_82xx_config_intrpt(adapter, 1);
+               if (err)
+                       dev_err(&adapter->pdev->dev,
+                               "Failed to configure Interrupt for %d vector\n",
+                               ahw->num_msix);
                return err;
+       }
 
-       return -EIO;
+       return 0;
 }
 
 void qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
@@ -829,7 +926,9 @@ static void qlcnic_get_bar_length(u32 dev_id, ulong *bar)
                *bar = QLCNIC_82XX_BAR0_LENGTH;
                break;
        case PCI_DEVICE_ID_QLOGIC_QLE834X:
+       case PCI_DEVICE_ID_QLOGIC_QLE844X:
        case PCI_DEVICE_ID_QLOGIC_VF_QLE834X:
+       case PCI_DEVICE_ID_QLOGIC_VF_QLE844X:
                *bar = QLCNIC_83XX_BAR0_LENGTH;
                break;
        default:
@@ -977,8 +1076,8 @@ qlcnic_check_options(struct qlcnic_adapter *adapter)
 static int
 qlcnic_initialize_nic(struct qlcnic_adapter *adapter)
 {
-       int err;
        struct qlcnic_info nic_info;
+       int err = 0;
 
        memset(&nic_info, 0, sizeof(struct qlcnic_info));
        err = qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw->pci_func);
@@ -993,7 +1092,9 @@ qlcnic_initialize_nic(struct qlcnic_adapter *adapter)
 
        if (adapter->ahw->capabilities & QLCNIC_FW_CAPABILITY_MORE_CAPS) {
                u32 temp;
-               temp = QLCRD32(adapter, CRB_FW_CAPABILITIES_2);
+               temp = QLCRD32(adapter, CRB_FW_CAPABILITIES_2, &err);
+               if (err == -EIO)
+                       return err;
                adapter->ahw->extra_capability[0] = temp;
        }
        adapter->ahw->max_mac_filters = nic_info.max_mac_filters;
@@ -1383,6 +1484,8 @@ qlcnic_request_irq(struct qlcnic_adapter *adapter)
        if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) {
                if (qlcnic_82xx_check(adapter))
                        handler = qlcnic_tmp_intr;
+               else
+                       handler = qlcnic_83xx_tmp_intr;
                if (!QLCNIC_IS_MSI_FAMILY(adapter))
                        flags |= IRQF_SHARED;
 
@@ -1409,6 +1512,7 @@ qlcnic_request_irq(struct qlcnic_adapter *adapter)
                        for (ring = 0; ring < num_sds_rings; ring++) {
                                sds_ring = &recv_ctx->sds_rings[ring];
                                if (qlcnic_82xx_check(adapter) &&
+                                   !qlcnic_check_multi_tx(adapter) &&
                                    (ring == (num_sds_rings - 1))) {
                                        if (!(adapter->flags &
                                              QLCNIC_MSIX_ENABLED))
@@ -1432,9 +1536,11 @@ qlcnic_request_irq(struct qlcnic_adapter *adapter)
                                        return err;
                        }
                }
-               if (qlcnic_83xx_check(adapter) &&
-                   (adapter->flags & QLCNIC_MSIX_ENABLED) &&
-                   !(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
+               if ((qlcnic_82xx_check(adapter) &&
+                    qlcnic_check_multi_tx(adapter)) ||
+                   (qlcnic_83xx_check(adapter) &&
+                    (adapter->flags & QLCNIC_MSIX_ENABLED) &&
+                    !(adapter->flags & QLCNIC_TX_INTR_SHARED))) {
                        handler = qlcnic_msix_tx_intr;
                        for (ring = 0; ring < adapter->max_drv_tx_rings;
                             ring++) {
@@ -1469,8 +1575,10 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter)
                                free_irq(sds_ring->irq, sds_ring);
                        }
                }
-               if (qlcnic_83xx_check(adapter) &&
-                   !(adapter->flags & QLCNIC_TX_INTR_SHARED)) {
+               if ((qlcnic_83xx_check(adapter) &&
+                    !(adapter->flags & QLCNIC_TX_INTR_SHARED)) ||
+                   (qlcnic_82xx_check(adapter) &&
+                    qlcnic_check_multi_tx(adapter))) {
                        for (ring = 0; ring < adapter->max_drv_tx_rings;
                             ring++) {
                                tx_ring = &adapter->tx_ring[ring];
@@ -1506,8 +1614,10 @@ int __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
 
        if (test_bit(__QLCNIC_DEV_UP, &adapter->state))
                return 0;
+
        if (qlcnic_set_eswitch_port_config(adapter))
                return -EIO;
+
        qlcnic_get_lro_mss_capability(adapter);
 
        if (qlcnic_fw_create_ctx(adapter))
@@ -1531,12 +1641,12 @@ int __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
        if (netdev->features & NETIF_F_LRO)
                qlcnic_config_hw_lro(adapter, QLCNIC_LRO_ENABLED);
 
+       set_bit(__QLCNIC_DEV_UP, &adapter->state);
        qlcnic_napi_enable(adapter);
 
        qlcnic_linkevent_request(adapter, 1);
 
        adapter->ahw->reset_context = 0;
-       set_bit(__QLCNIC_DEV_UP, &adapter->state);
        return 0;
 }
 
@@ -1554,6 +1664,8 @@ int qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
 
 void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
 {
+       int ring;
+
        if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
                return;
 
@@ -1563,7 +1675,6 @@ void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
        if (qlcnic_sriov_vf_check(adapter))
                qlcnic_sriov_cleanup_async_list(&adapter->ahw->sriov->bc);
        smp_mb();
-       spin_lock(&adapter->tx_clean_lock);
        netif_carrier_off(netdev);
        adapter->ahw->linkup = 0;
        netif_tx_disable(netdev);
@@ -1581,8 +1692,9 @@ void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
        adapter->flags &= ~QLCNIC_FW_LRO_MSS_CAP;
 
        qlcnic_reset_rx_buffers_list(adapter);
-       qlcnic_release_tx_buffers(adapter);
-       spin_unlock(&adapter->tx_clean_lock);
+
+       for (ring = 0; ring < adapter->max_drv_tx_rings; ring++)
+               qlcnic_release_tx_buffers(adapter, &adapter->tx_ring[ring]);
 }
 
 /* Usage: During suspend and firmware recovery module */
@@ -1662,6 +1774,7 @@ void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
        struct qlcnic_host_sds_ring *sds_ring;
+       int max_tx_rings = adapter->max_drv_tx_rings;
        int ring;
 
        clear_bit(__QLCNIC_DEV_UP, &adapter->state);
@@ -1678,6 +1791,7 @@ void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings)
 
        adapter->ahw->diag_test = 0;
        adapter->max_sds_rings = max_sds_rings;
+       adapter->max_drv_tx_rings = max_tx_rings;
 
        if (qlcnic_attach(adapter))
                goto out;
@@ -1746,6 +1860,7 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test)
        adapter->max_sds_rings = 1;
        adapter->ahw->diag_test = test;
        adapter->ahw->linkup = 0;
+       adapter->max_drv_tx_rings = 1;
 
        ret = qlcnic_attach(adapter);
        if (ret) {
@@ -1903,12 +2018,18 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev,
        netdev->priv_flags |= IFF_UNICAST_FLT;
        netdev->irq = adapter->msix_entries[0].vector;
 
+       err = qlcnic_set_real_num_queues(adapter, netdev);
+       if (err)
+               return err;
+
        err = register_netdev(netdev);
        if (err) {
                dev_err(&pdev->dev, "failed to register net device\n");
                return err;
        }
 
+       qlcnic_dcb_init_dcbnl_ops(adapter);
+
        return 0;
 }
 
@@ -1971,7 +2092,8 @@ int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
                tx_ring->cmd_buf_arr = cmd_buf_arr;
        }
 
-       if (qlcnic_83xx_check(adapter)) {
+       if (qlcnic_83xx_check(adapter) ||
+           (qlcnic_82xx_check(adapter) && qlcnic_check_multi_tx(adapter))) {
                for (ring = 0; ring < adapter->max_drv_tx_rings; ring++) {
                        tx_ring = &adapter->tx_ring[ring];
                        tx_ring->adapter = adapter;
@@ -1982,6 +2104,7 @@ int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
                        }
                }
        }
+
        return 0;
 }
 
@@ -2000,6 +2123,17 @@ void qlcnic_set_drv_version(struct qlcnic_adapter *adapter)
                qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd);
 }
 
+static int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
+{
+       return __qlcnic_register_dcb(adapter);
+}
+
+void qlcnic_clear_dcb_ops(struct qlcnic_adapter *adapter)
+{
+       kfree(adapter->dcb);
+       adapter->dcb = NULL;
+}
+
 static int
 qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -2044,9 +2178,11 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                ahw->reg_tbl = (u32 *) qlcnic_reg_tbl;
                break;
        case PCI_DEVICE_ID_QLOGIC_QLE834X:
+       case PCI_DEVICE_ID_QLOGIC_QLE844X:
                qlcnic_83xx_register_map(ahw);
                break;
        case PCI_DEVICE_ID_QLOGIC_VF_QLE834X:
+       case PCI_DEVICE_ID_QLOGIC_VF_QLE844X:
                qlcnic_sriov_vf_register_map(ahw);
                break;
        default:
@@ -2057,7 +2193,8 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                goto err_out_free_hw_res;
 
-       netdev = alloc_etherdev(sizeof(struct qlcnic_adapter));
+       netdev = alloc_etherdev_mq(sizeof(struct qlcnic_adapter),
+                                  QLCNIC_MAX_TX_RINGS);
        if (!netdev) {
                err = -ENOMEM;
                goto err_out_iounmap;
@@ -2087,14 +2224,14 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                adapter->fdb_mac_learn = true;
        else if (qlcnic_mac_learn == DRV_MAC_LEARN)
                adapter->drv_mac_learn = true;
-       adapter->max_drv_tx_rings = 1;
 
        rwlock_init(&adapter->ahw->crb_lock);
        mutex_init(&adapter->ahw->mem_lock);
 
-       spin_lock_init(&adapter->tx_clean_lock);
        INIT_LIST_HEAD(&adapter->mac_list);
 
+       qlcnic_register_dcb(adapter);
+
        if (qlcnic_82xx_check(adapter)) {
                qlcnic_check_vf(adapter, ent);
                adapter->portnum = adapter->ahw->pci_func;
@@ -2104,12 +2241,31 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        goto err_out_free_hw;
                }
 
+               qlcnic_get_multiq_capability(adapter);
+
+               if ((adapter->ahw->act_pci_func > 2) &&
+                   qlcnic_check_multi_tx(adapter)) {
+                       adapter->max_drv_tx_rings = QLCNIC_DEF_NUM_TX_RINGS;
+                       dev_info(&adapter->pdev->dev,
+                                "vNIC mode enabled, Set max TX rings = %d\n",
+                                adapter->max_drv_tx_rings);
+               }
+
+               if (!qlcnic_check_multi_tx(adapter)) {
+                       clear_bit(__QLCNIC_MULTI_TX_UNIQUE, &adapter->state);
+                       adapter->max_drv_tx_rings = 1;
+               }
                err = qlcnic_setup_idc_param(adapter);
                if (err)
                        goto err_out_free_hw;
 
                adapter->flags |= QLCNIC_NEED_FLR;
+
+               if (adapter->dcb && qlcnic_dcb_attach(adapter))
+                       qlcnic_clear_dcb_ops(adapter);
+
        } else if (qlcnic_83xx_check(adapter)) {
+               adapter->max_drv_tx_rings = 1;
                qlcnic_83xx_check_vf(adapter, ent);
                adapter->portnum = adapter->ahw->pci_func;
                err = qlcnic_83xx_init(adapter, pci_using_dac);
@@ -2128,6 +2284,8 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (qlcnic_read_mac_addr(adapter))
                dev_warn(&pdev->dev, "failed to read mac addr\n");
 
+       qlcnic_read_phys_port_id(adapter);
+
        if (adapter->portnum == 0) {
                qlcnic_get_board_name(adapter, board_name);
 
@@ -2139,18 +2297,14 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (qlcnic_83xx_check(adapter) && !qlcnic_use_msi_x &&
            !!qlcnic_use_msi)
                dev_warn(&pdev->dev,
-                        "83xx adapter do not support MSI interrupts\n");
+                        "Device does not support MSI interrupts\n");
 
-       err = qlcnic_setup_intr(adapter, 0);
-       if (err) {
-               dev_err(&pdev->dev, "Failed to setup interrupt\n");
-               goto err_out_disable_msi;
-       }
-
-       if (qlcnic_83xx_check(adapter)) {
-               err = qlcnic_83xx_setup_mbx_intr(adapter);
-               if (err)
+       if (qlcnic_82xx_check(adapter)) {
+               err = qlcnic_setup_intr(adapter, 0, 0);
+               if (err) {
+                       dev_err(&pdev->dev, "Failed to setup interrupt\n");
                        goto err_out_disable_msi;
+               }
        }
 
        err = qlcnic_get_act_pci_func(adapter);
@@ -2161,7 +2315,8 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                goto err_out_disable_mbx_intr;
 
-       qlcnic_set_drv_version(adapter);
+       if (adapter->portnum == 0)
+               qlcnic_set_drv_version(adapter);
 
        pci_set_drvdata(pdev, adapter);
 
@@ -2233,13 +2388,17 @@ static void qlcnic_remove(struct pci_dev *pdev)
        qlcnic_cancel_idc_work(adapter);
        ahw = adapter->ahw;
 
+       qlcnic_dcb_free(adapter);
+
        unregister_netdev(netdev);
        qlcnic_sriov_cleanup(adapter);
 
        if (qlcnic_83xx_check(adapter)) {
-               qlcnic_83xx_free_mbx_intr(adapter);
                qlcnic_83xx_register_nic_idc_func(adapter, 0);
                cancel_delayed_work_sync(&adapter->idc_aen_work);
+               qlcnic_83xx_free_mbx_intr(adapter);
+               qlcnic_83xx_detach_mailbox_work(adapter);
+               qlcnic_83xx_free_mailbox(ahw->mailbox);
        }
 
        qlcnic_detach(adapter);
@@ -2273,6 +2432,7 @@ static void qlcnic_remove(struct pci_dev *pdev)
                destroy_workqueue(adapter->qlcnic_wq);
                adapter->qlcnic_wq = NULL;
        }
+
        qlcnic_free_adapter_resources(adapter);
        kfree(ahw);
        free_netdev(netdev);
@@ -2331,7 +2491,7 @@ static int qlcnic_open(struct net_device *netdev)
        if (err)
                goto err_out;
 
-       netif_start_queue(netdev);
+       netif_tx_start_all_queues(netdev);
 
        return 0;
 
@@ -2463,6 +2623,8 @@ int qlcnic_check_temp(struct qlcnic_adapter *adapter)
 static void qlcnic_tx_timeout(struct net_device *netdev)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
+       struct qlcnic_host_tx_ring *tx_ring;
+       int ring;
 
        if (test_bit(__QLCNIC_RESETTING, &adapter->state))
                return;
@@ -2476,6 +2638,25 @@ static void qlcnic_tx_timeout(struct net_device *netdev)
                                                      QLCNIC_FORCE_FW_DUMP_KEY);
        } else {
                netdev_info(netdev, "Tx timeout, reset adapter context.\n");
+               if (qlcnic_82xx_check(adapter)) {
+                       for (ring = 0; ring < adapter->max_drv_tx_rings;
+                            ring++) {
+                               tx_ring = &adapter->tx_ring[ring];
+                               dev_info(&netdev->dev, "ring=%d\n", ring);
+                               dev_info(&netdev->dev, "crb_intr_mask=%d\n",
+                                        readl(tx_ring->crb_intr_mask));
+                               dev_info(&netdev->dev, "producer=%d\n",
+                                        readl(tx_ring->crb_cmd_producer));
+                               dev_info(&netdev->dev, "sw_consumer = %d\n",
+                                        tx_ring->sw_consumer);
+                               dev_info(&netdev->dev, "hw_consumer = %d\n",
+                                        le32_to_cpu(*(tx_ring->hw_consumer)));
+                               dev_info(&netdev->dev, "xmit-on=%llu\n",
+                                        tx_ring->xmit_on);
+                               dev_info(&netdev->dev, "xmit-off=%llu\n",
+                                        tx_ring->xmit_off);
+                       }
+               }
                adapter->ahw->reset_context = 1;
        }
 }
@@ -3069,6 +3250,8 @@ qlcnic_attach_work(struct work_struct *work)
                return;
        }
 attach:
+       qlcnic_dcb_get_info(adapter);
+
        if (netif_running(netdev)) {
                if (qlcnic_up(adapter, netdev))
                        goto done;
@@ -3081,7 +3264,8 @@ done:
        adapter->fw_fail_cnt = 0;
        adapter->flags &= ~QLCNIC_FW_HANG;
        clear_bit(__QLCNIC_RESETTING, &adapter->state);
-       qlcnic_set_drv_version(adapter);
+       if (adapter->portnum == 0)
+               qlcnic_set_drv_version(adapter);
 
        if (!qlcnic_clr_drv_state(adapter))
                qlcnic_schedule_work(adapter, qlcnic_fw_poll_work,
@@ -3093,6 +3277,7 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
 {
        u32 state = 0, heartbeat;
        u32 peg_status;
+       int err = 0;
 
        if (qlcnic_check_temp(adapter))
                goto detach;
@@ -3139,11 +3324,11 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
                        "PEG_NET_4_PC: 0x%x\n",
                        peg_status,
                        QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS2),
-                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x3c),
-                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x3c),
-                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_2 + 0x3c),
-                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c),
-                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c));
+                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x3c, &err),
+                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x3c, &err),
+                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_2 + 0x3c, &err),
+                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c, &err),
+                       QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c, &err));
        if (QLCNIC_FWERROR_CODE(peg_status) == 0x67)
                dev_err(&adapter->pdev->dev,
                        "Firmware aborted with error code 0x00006700. "
@@ -3238,7 +3423,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev)
        qlcnic_clr_drv_state(adapter);
        kfree(adapter->msix_entries);
        adapter->msix_entries = NULL;
-       err = qlcnic_setup_intr(adapter, 0);
+       err = qlcnic_setup_intr(adapter, 0, 0);
 
        if (err) {
                kfree(adapter->msix_entries);
@@ -3363,16 +3548,65 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)
        return err;
 }
 
+int qlcnic_validate_max_tx_rings(struct qlcnic_adapter *adapter, u32 txq)
+{
+       struct net_device *netdev = adapter->netdev;
+       u8 max_hw = QLCNIC_MAX_TX_RINGS;
+       u32 max_allowed;
+
+       if (!qlcnic_82xx_check(adapter)) {
+               netdev_err(netdev, "No Multi TX-Q support\n");
+               return -EINVAL;
+       }
+
+       if (!qlcnic_use_msi_x && !qlcnic_use_msi) {
+               netdev_err(netdev, "No Multi TX-Q support in INT-x mode\n");
+               return -EINVAL;
+       }
+
+       if (!qlcnic_check_multi_tx(adapter)) {
+               netdev_err(netdev, "No Multi TX-Q support\n");
+               return -EINVAL;
+       }
+
+       if (txq > QLCNIC_MAX_TX_RINGS) {
+               netdev_err(netdev, "Invalid ring count\n");
+               return -EINVAL;
+       }
+
+       max_allowed = rounddown_pow_of_two(min_t(int, max_hw,
+                                                num_online_cpus()));
+       if ((txq > max_allowed) || !is_power_of_2(txq)) {
+               if (!is_power_of_2(txq))
+                       netdev_err(netdev,
+                                  "TX queue should be a power of 2\n");
+               if (txq > num_online_cpus())
+                       netdev_err(netdev,
+                                  "Tx queue should not be higher than [%u], number of online CPUs in the system\n",
+                                  num_online_cpus());
+               netdev_err(netdev, "Unable to configure %u Tx rings\n", txq);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 int qlcnic_validate_max_rss(struct qlcnic_adapter *adapter,
-                           __u32 val)
+                               __u32 val)
 {
        struct net_device *netdev = adapter->netdev;
        u8 max_hw = adapter->ahw->max_rx_ques;
        u32 max_allowed;
 
-       if (val > QLC_MAX_SDS_RINGS) {
+       if (qlcnic_82xx_check(adapter) && !qlcnic_use_msi_x &&
+           !qlcnic_use_msi) {
+               netdev_err(netdev, "No RSS support in INT-x mode\n");
+               return -EINVAL;
+       }
+
+       if (val > QLCNIC_MAX_SDS_RINGS) {
                netdev_err(netdev, "RSS value should not be higher than %u\n",
-                          QLC_MAX_SDS_RINGS);
+                          QLCNIC_MAX_SDS_RINGS);
                return -EINVAL;
        }
 
@@ -3402,27 +3636,48 @@ int qlcnic_validate_max_rss(struct qlcnic_adapter *adapter,
        return 0;
 }
 
-int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data, size_t len)
+int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data, int txq)
 {
        int err;
        struct net_device *netdev = adapter->netdev;
+       int num_msix;
 
        if (test_bit(__QLCNIC_RESETTING, &adapter->state))
                return -EBUSY;
 
+       if (qlcnic_82xx_check(adapter) && !qlcnic_use_msi_x &&
+           !qlcnic_use_msi) {
+               netdev_err(netdev, "No RSS support in INT-x mode\n");
+               return -EINVAL;
+       }
+
        netif_device_detach(netdev);
        if (netif_running(netdev))
                __qlcnic_down(adapter, netdev);
 
        qlcnic_detach(adapter);
 
+       if (qlcnic_82xx_check(adapter)) {
+               if (txq != 0)
+                       adapter->max_drv_tx_rings = txq;
+
+               if (qlcnic_check_multi_tx(adapter) &&
+                   (txq > adapter->max_drv_tx_rings))
+                       num_msix = adapter->max_drv_tx_rings;
+               else
+                       num_msix = data;
+       }
+
        if (qlcnic_83xx_check(adapter)) {
                qlcnic_83xx_free_mbx_intr(adapter);
                qlcnic_83xx_enable_mbx_poll(adapter);
        }
 
+       netif_set_real_num_tx_queues(netdev, adapter->max_drv_tx_rings);
+
        qlcnic_teardown_intr(adapter);
-       err = qlcnic_setup_intr(adapter, data);
+
+       err = qlcnic_setup_intr(adapter, data, txq);
        if (err) {
                kfree(adapter->msix_entries);
                netdev_err(netdev, "failed to setup interrupt\n");
@@ -3450,8 +3705,7 @@ int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data, size_t len)
                        goto done;
                qlcnic_restore_indev_addr(netdev, NETDEV_UP);
        }
-       err = len;
- done:
+done:
        netif_device_attach(netdev);
        clear_bit(__QLCNIC_RESETTING, &adapter->state);
        return err;
index ab8a6744d402f43e794007db16ee218916051675..79e54efe07b921cc2d7e1986c7d45e16ee9e7ecb 100644 (file)
@@ -1084,7 +1084,7 @@ flash_temp:
        tmpl_hdr = ahw->fw_dump.tmpl_hdr;
        tmpl_hdr->drv_cap_mask = QLCNIC_DUMP_MASK_DEF;
 
-       if ((tmpl_hdr->version & 0xffffff) >= 0x20001)
+       if ((tmpl_hdr->version & 0xfffff) >= 0x20001)
                ahw->fw_dump.use_pex_dma = true;
        else
                ahw->fw_dump.use_pex_dma = false;
index 62380ce8990555a2b120fd768cae0f2192508a8e..26f9aa66403d7ebb36fc58b6e052cc01a45e5890 100644 (file)
@@ -33,7 +33,7 @@ static int qlcnic_sriov_alloc_bc_mbx_args(struct qlcnic_cmd_args *, u32);
 static void qlcnic_sriov_vf_poll_dev_state(struct work_struct *);
 static void qlcnic_sriov_vf_cancel_fw_work(struct qlcnic_adapter *);
 static void qlcnic_sriov_cleanup_transaction(struct qlcnic_bc_trans *);
-static int qlcnic_sriov_vf_mbx_op(struct qlcnic_adapter *,
+static int qlcnic_sriov_issue_cmd(struct qlcnic_adapter *,
                                  struct qlcnic_cmd_args *);
 static void qlcnic_sriov_process_bc_cmd(struct work_struct *);
 
@@ -45,7 +45,7 @@ static struct qlcnic_hardware_ops qlcnic_sriov_vf_hw_ops = {
        .get_mac_address                = qlcnic_83xx_get_mac_address,
        .setup_intr                     = qlcnic_83xx_setup_intr,
        .alloc_mbx_args                 = qlcnic_83xx_alloc_mbx_args,
-       .mbx_cmd                        = qlcnic_sriov_vf_mbx_op,
+       .mbx_cmd                        = qlcnic_sriov_issue_cmd,
        .get_func_no                    = qlcnic_83xx_get_func_no,
        .api_lock                       = qlcnic_83xx_cam_lock,
        .api_unlock                     = qlcnic_83xx_cam_unlock,
@@ -286,96 +286,38 @@ void qlcnic_sriov_cleanup(struct qlcnic_adapter *adapter)
 static int qlcnic_sriov_post_bc_msg(struct qlcnic_adapter *adapter, u32 *hdr,
                                    u32 *pay, u8 pci_func, u8 size)
 {
-       u32 rsp, mbx_val, fw_data, rsp_num, mbx_cmd, val, wait_time = 0;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
-       unsigned long flags;
-       u16 opcode;
-       u8 mbx_err_code;
-       int i, j;
-
-       opcode = ((struct qlcnic_bc_hdr *)hdr)->cmd_op;
-
-       if (!test_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status)) {
-               dev_info(&adapter->pdev->dev,
-                        "Mailbox cmd attempted, 0x%x\n", opcode);
-               dev_info(&adapter->pdev->dev, "Mailbox detached\n");
-               return 0;
-       }
-
-       spin_lock_irqsave(&ahw->mbx_lock, flags);
-
-       mbx_val = QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL);
-       if (mbx_val) {
-               QLCDB(adapter, DRV, "Mailbox cmd attempted, 0x%x\n", opcode);
-               spin_unlock_irqrestore(&ahw->mbx_lock, flags);
-               return QLCNIC_RCODE_TIMEOUT;
-       }
-       /* Fill in mailbox registers */
-       val = size + (sizeof(struct qlcnic_bc_hdr) / sizeof(u32));
-       mbx_cmd = 0x31 | (val << 16) | (adapter->ahw->fw_hal_version << 29);
-
-       writel(mbx_cmd, QLCNIC_MBX_HOST(ahw, 0));
-       mbx_cmd = 0x1 | (1 << 4);
+       struct qlcnic_mailbox *mbx = ahw->mailbox;
+       struct qlcnic_cmd_args cmd;
+       unsigned long timeout;
+       int err;
 
-       if (qlcnic_sriov_pf_check(adapter))
-               mbx_cmd |= (pci_func << 5);
+       memset(&cmd, 0, sizeof(struct qlcnic_cmd_args));
+       cmd.hdr = hdr;
+       cmd.pay = pay;
+       cmd.pay_size = size;
+       cmd.func_num = pci_func;
+       cmd.op_type = QLC_83XX_MBX_POST_BC_OP;
+       cmd.cmd_op = ((struct qlcnic_bc_hdr *)hdr)->cmd_op;
 
-       writel(mbx_cmd, QLCNIC_MBX_HOST(ahw, 1));
-       for (i = 2, j = 0; j < (sizeof(struct qlcnic_bc_hdr) / sizeof(u32));
-                       i++, j++) {
-               writel(*(hdr++), QLCNIC_MBX_HOST(ahw, i));
+       err = mbx->ops->enqueue_cmd(adapter, &cmd, &timeout);
+       if (err) {
+               dev_err(&adapter->pdev->dev,
+                       "%s: Mailbox not available, cmd_op=0x%x, cmd_type=0x%x, pci_func=0x%x, op_mode=0x%x\n",
+                       __func__, cmd.cmd_op, cmd.type, ahw->pci_func,
+                       ahw->op_mode);
+               return err;
        }
-       for (j = 0; j < size; j++, i++)
-               writel(*(pay++), QLCNIC_MBX_HOST(ahw, i));
 
-       /* Signal FW about the impending command */
-       QLCWRX(ahw, QLCNIC_HOST_MBX_CTRL, QLCNIC_SET_OWNER);
-
-       /* Waiting for the mailbox cmd to complete and while waiting here
-        * some AEN might arrive. If more than 5 seconds expire we can
-        * assume something is wrong.
-        */
-poll:
-       rsp = qlcnic_83xx_mbx_poll(adapter, &wait_time);
-       if (rsp != QLCNIC_RCODE_TIMEOUT) {
-               /* Get the FW response data */
-               fw_data = readl(QLCNIC_MBX_FW(ahw, 0));
-               if (fw_data &  QLCNIC_MBX_ASYNC_EVENT) {
-                       __qlcnic_83xx_process_aen(adapter);
-                       goto poll;
-               }
-               mbx_err_code = QLCNIC_MBX_STATUS(fw_data);
-               rsp_num = QLCNIC_MBX_NUM_REGS(fw_data);
-               opcode = QLCNIC_MBX_RSP(fw_data);
-
-               switch (mbx_err_code) {
-               case QLCNIC_MBX_RSP_OK:
-               case QLCNIC_MBX_PORT_RSP_OK:
-                       rsp = QLCNIC_RCODE_SUCCESS;
-                       break;
-               default:
-                       if (opcode == QLCNIC_CMD_CONFIG_MAC_VLAN) {
-                               rsp = qlcnic_83xx_mac_rcode(adapter);
-                               if (!rsp)
-                                       goto out;
-                       }
-                       dev_err(&adapter->pdev->dev,
-                               "MBX command 0x%x failed with err:0x%x\n",
-                               opcode, mbx_err_code);
-                       rsp = mbx_err_code;
-                       break;
-               }
-               goto out;
+       if (!wait_for_completion_timeout(&cmd.completion, timeout)) {
+               dev_err(&adapter->pdev->dev,
+                       "%s: Mailbox command timed out, cmd_op=0x%x, cmd_type=0x%x, pci_func=0x%x, op_mode=0x%x\n",
+                       __func__, cmd.cmd_op, cmd.type, ahw->pci_func,
+                       ahw->op_mode);
+               flush_workqueue(mbx->work_q);
        }
 
-       dev_err(&adapter->pdev->dev, "MBX command 0x%x timed out\n",
-               QLCNIC_MBX_RSP(mbx_cmd));
-       rsp = QLCNIC_RCODE_TIMEOUT;
-out:
-       /* clear fw mbx control register */
-       QLCWRX(ahw, QLCNIC_FW_MBX_CTRL, QLCNIC_CLR_OWNER);
-       spin_unlock_irqrestore(&adapter->ahw->mbx_lock, flags);
-       return rsp;
+       return cmd.rsp_opcode;
 }
 
 static void qlcnic_sriov_vf_cfg_buff_desc(struct qlcnic_adapter *adapter)
@@ -456,10 +398,14 @@ int qlcnic_sriov_get_vf_vport_info(struct qlcnic_adapter *adapter,
 }
 
 static int qlcnic_sriov_set_pvid_mode(struct qlcnic_adapter *adapter,
-                                     struct qlcnic_cmd_args *cmd)
+                                     struct qlcnic_cmd_args *cmd, u32 cap)
 {
-       adapter->rx_pvid = (cmd->rsp.arg[1] >> 16) & 0xffff;
-       adapter->flags &= ~QLCNIC_TAGGING_ENABLED;
+       if (cap & QLC_83XX_PVID_STRIP_CAPABILITY) {
+               adapter->rx_pvid = 0;
+       } else {
+               adapter->rx_pvid = (cmd->rsp.arg[1] >> 16) & 0xffff;
+               adapter->flags &= ~QLCNIC_TAGGING_ENABLED;
+       }
        return 0;
 }
 
@@ -490,12 +436,14 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter,
        return 0;
 }
 
-static int qlcnic_sriov_get_vf_acl(struct qlcnic_adapter *adapter)
+static int qlcnic_sriov_get_vf_acl(struct qlcnic_adapter *adapter,
+                                  struct qlcnic_info *info)
 {
        struct qlcnic_sriov *sriov = adapter->ahw->sriov;
        struct qlcnic_cmd_args cmd;
-       int ret;
+       int ret, cap;
 
+       cap = info->capabilities;
        ret = qlcnic_sriov_alloc_bc_mbx_args(&cmd, QLCNIC_BC_CMD_GET_ACL);
        if (ret)
                return ret;
@@ -511,7 +459,7 @@ static int qlcnic_sriov_get_vf_acl(struct qlcnic_adapter *adapter)
                        ret = qlcnic_sriov_set_guest_vlan_mode(adapter, &cmd);
                        break;
                case QLC_PVID_MODE:
-                       ret = qlcnic_sriov_set_pvid_mode(adapter, &cmd);
+                       ret = qlcnic_sriov_set_pvid_mode(adapter, &cmd, cap);
                        break;
                }
        }
@@ -522,8 +470,8 @@ static int qlcnic_sriov_get_vf_acl(struct qlcnic_adapter *adapter)
 
 static int qlcnic_sriov_vf_init_driver(struct qlcnic_adapter *adapter)
 {
-       struct qlcnic_info nic_info;
        struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_info nic_info;
        int err;
 
        err = qlcnic_sriov_get_vf_vport_info(adapter, &nic_info, 0);
@@ -534,7 +482,7 @@ static int qlcnic_sriov_vf_init_driver(struct qlcnic_adapter *adapter)
        if (err)
                return -EIO;
 
-       err = qlcnic_sriov_get_vf_acl(adapter);
+       err = qlcnic_sriov_get_vf_acl(adapter, &nic_info);
        if (err)
                return err;
 
@@ -562,9 +510,9 @@ static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter,
        INIT_LIST_HEAD(&adapter->vf_mc_list);
        if (!qlcnic_use_msi_x && !!qlcnic_use_msi)
                dev_warn(&adapter->pdev->dev,
-                        "83xx adapter do not support MSI interrupts\n");
+                        "Device does not support MSI interrupts\n");
 
-       err = qlcnic_setup_intr(adapter, 1);
+       err = qlcnic_setup_intr(adapter, 1, 0);
        if (err) {
                dev_err(&adapter->pdev->dev, "Failed to setup interrupt\n");
                goto err_out_disable_msi;
@@ -590,6 +538,9 @@ static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter,
        if (err)
                goto err_out_send_channel_term;
 
+       if (adapter->dcb && qlcnic_dcb_attach(adapter))
+               qlcnic_clear_dcb_ops(adapter);
+
        err = qlcnic_setup_netdev(adapter, adapter->netdev, pci_using_dac);
        if (err)
                goto err_out_send_channel_term;
@@ -597,6 +548,7 @@ static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter,
        pci_set_drvdata(adapter->pdev, adapter);
        dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n",
                 adapter->netdev->name);
+
        qlcnic_schedule_work(adapter, qlcnic_sriov_vf_poll_dev_state,
                             adapter->ahw->idc.delay);
        return 0;
@@ -637,8 +589,6 @@ int qlcnic_sriov_vf_init(struct qlcnic_adapter *adapter, int pci_using_dac)
        struct qlcnic_hardware_context *ahw = adapter->ahw;
        int err;
 
-       spin_lock_init(&ahw->mbx_lock);
-       set_bit(QLC_83XX_MBX_READY, &ahw->idc.status);
        set_bit(QLC_83XX_MODULE_LOADED, &ahw->idc.status);
        ahw->idc.delay = QLC_83XX_IDC_FW_POLL_DELAY;
        ahw->reset_context = 0;
@@ -762,6 +712,7 @@ static int qlcnic_sriov_alloc_bc_mbx_args(struct qlcnic_cmd_args *mbx, u32 type)
                        memset(mbx->rsp.arg, 0, sizeof(u32) * mbx->rsp.num);
                        mbx->req.arg[0] = (type | (mbx->req.num << 16) |
                                           (3 << 29));
+                       mbx->rsp.arg[0] = (type & 0xffff) | mbx->rsp.num << 16;
                        return 0;
                }
        }
@@ -813,6 +764,7 @@ static int qlcnic_sriov_prepare_bc_hdr(struct qlcnic_bc_trans *trans,
                cmd->req.num = trans->req_pay_size / 4;
                cmd->rsp.num = trans->rsp_pay_size / 4;
                hdr = trans->rsp_hdr;
+               cmd->op_type = trans->req_hdr->op_type;
        }
 
        trans->trans_id = seq;
@@ -1083,6 +1035,7 @@ static void qlcnic_sriov_process_bc_cmd(struct work_struct *work)
        if (test_bit(QLC_BC_VF_FLR, &vf->state))
                return;
 
+       memset(&cmd, 0, sizeof(struct qlcnic_cmd_args));
        trans = list_first_entry(&vf->rcv_act.wait_list,
                                 struct qlcnic_bc_trans, list);
        adapter = vf->adapter;
@@ -1232,6 +1185,7 @@ static void qlcnic_sriov_handle_bc_cmd(struct qlcnic_sriov *sriov,
                return;
        }
 
+       memset(&cmd, 0, sizeof(struct qlcnic_cmd_args));
        cmd_op = hdr->cmd_op;
        if (qlcnic_sriov_alloc_bc_trans(&trans))
                return;
@@ -1357,7 +1311,7 @@ int qlcnic_sriov_cfg_bc_intr(struct qlcnic_adapter *adapter, u8 enable)
        if (enable)
                cmd.req.arg[1] = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7);
 
-       err = qlcnic_83xx_mbx_op(adapter, &cmd);
+       err = qlcnic_83xx_issue_cmd(adapter, &cmd);
 
        if (err != QLCNIC_RCODE_SUCCESS) {
                dev_err(&adapter->pdev->dev,
@@ -1389,10 +1343,11 @@ static int qlcnic_sriov_retry_bc_cmd(struct qlcnic_adapter *adapter,
        return -EIO;
 }
 
-static int qlcnic_sriov_vf_mbx_op(struct qlcnic_adapter *adapter,
+static int qlcnic_sriov_issue_cmd(struct qlcnic_adapter *adapter,
                                  struct qlcnic_cmd_args *cmd)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_mailbox *mbx = ahw->mailbox;
        struct device *dev = &adapter->pdev->dev;
        struct qlcnic_bc_trans *trans;
        int err;
@@ -1409,7 +1364,7 @@ static int qlcnic_sriov_vf_mbx_op(struct qlcnic_adapter *adapter,
                goto cleanup_transaction;
 
 retry:
-       if (!test_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status)) {
+       if (!test_bit(QLC_83XX_MBX_READY, &mbx->status)) {
                rsp = -EIO;
                QLCDB(adapter, DRV, "MBX not Ready!(cmd 0x%x) for VF 0x%x\n",
                      QLCNIC_MBX_RSP(cmd->req.arg[0]), func);
@@ -1452,7 +1407,7 @@ err_out:
        if (rsp == QLCNIC_RCODE_TIMEOUT) {
                ahw->reset_context = 1;
                adapter->need_fw_reset = 1;
-               clear_bit(QLC_83XX_MBX_READY, &ahw->idc.status);
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
        }
 
 cleanup_transaction:
@@ -1611,8 +1566,8 @@ static int qlcnic_sriov_vf_reinit_driver(struct qlcnic_adapter *adapter)
 {
        int err;
 
-       set_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status);
-       qlcnic_83xx_enable_mbx_intrpt(adapter);
+       qlcnic_83xx_reinit_mbx_work(adapter->ahw->mailbox);
+       qlcnic_83xx_enable_mbx_interrupt(adapter);
 
        err = qlcnic_sriov_cfg_bc_intr(adapter, 1);
        if (err)
@@ -1626,6 +1581,8 @@ static int qlcnic_sriov_vf_reinit_driver(struct qlcnic_adapter *adapter)
        if (err)
                goto err_out_term_channel;
 
+       qlcnic_dcb_get_info(adapter);
+
        return 0;
 
 err_out_term_channel:
@@ -1655,8 +1612,10 @@ static void qlcnic_sriov_vf_detach(struct qlcnic_adapter *adapter)
        struct net_device *netdev = adapter->netdev;
        u8 i, max_ints = ahw->num_msix - 1;
 
-       qlcnic_83xx_disable_mbx_intr(adapter);
        netif_device_detach(netdev);
+       qlcnic_83xx_detach_mailbox_work(adapter);
+       qlcnic_83xx_disable_mbx_intr(adapter);
+
        if (netif_running(netdev))
                qlcnic_down(adapter, netdev);
 
@@ -1700,6 +1659,7 @@ static int qlcnic_sriov_vf_handle_dev_ready(struct qlcnic_adapter *adapter)
 static int qlcnic_sriov_vf_handle_context_reset(struct qlcnic_adapter *adapter)
 {
        struct qlcnic_hardware_context *ahw = adapter->ahw;
+       struct qlcnic_mailbox *mbx = ahw->mailbox;
        struct device *dev = &adapter->pdev->dev;
        struct qlc_83xx_idc *idc = &ahw->idc;
        u8 func = ahw->pci_func;
@@ -1710,7 +1670,7 @@ static int qlcnic_sriov_vf_handle_context_reset(struct qlcnic_adapter *adapter)
        /* Skip the context reset and check if FW is hung */
        if (adapter->reset_ctx_cnt < 3) {
                adapter->need_fw_reset = 1;
-               clear_bit(QLC_83XX_MBX_READY, &idc->status);
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
                dev_info(dev,
                         "Resetting context, wait here to check if FW is in failed state\n");
                return 0;
@@ -1735,7 +1695,7 @@ static int qlcnic_sriov_vf_handle_context_reset(struct qlcnic_adapter *adapter)
                 __func__, adapter->reset_ctx_cnt, func);
        set_bit(__QLCNIC_RESETTING, &adapter->state);
        adapter->need_fw_reset = 1;
-       clear_bit(QLC_83XX_MBX_READY, &idc->status);
+       clear_bit(QLC_83XX_MBX_READY, &mbx->status);
        qlcnic_sriov_vf_detach(adapter);
        adapter->need_fw_reset = 0;
 
@@ -1785,6 +1745,7 @@ static int qlcnic_sriov_vf_idc_failed_state(struct qlcnic_adapter *adapter)
 static int
 qlcnic_sriov_vf_idc_need_quiescent_state(struct qlcnic_adapter *adapter)
 {
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
        struct qlc_83xx_idc *idc = &adapter->ahw->idc;
 
        dev_info(&adapter->pdev->dev, "Device is in quiescent state\n");
@@ -1792,7 +1753,7 @@ qlcnic_sriov_vf_idc_need_quiescent_state(struct qlcnic_adapter *adapter)
                set_bit(__QLCNIC_RESETTING, &adapter->state);
                adapter->tx_timeo_cnt = 0;
                adapter->reset_ctx_cnt = 0;
-               clear_bit(QLC_83XX_MBX_READY, &idc->status);
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
                qlcnic_sriov_vf_detach(adapter);
        }
 
@@ -1801,6 +1762,7 @@ qlcnic_sriov_vf_idc_need_quiescent_state(struct qlcnic_adapter *adapter)
 
 static int qlcnic_sriov_vf_idc_init_reset_state(struct qlcnic_adapter *adapter)
 {
+       struct qlcnic_mailbox *mbx = adapter->ahw->mailbox;
        struct qlc_83xx_idc *idc = &adapter->ahw->idc;
        u8 func = adapter->ahw->pci_func;
 
@@ -1810,7 +1772,7 @@ static int qlcnic_sriov_vf_idc_init_reset_state(struct qlcnic_adapter *adapter)
                set_bit(__QLCNIC_RESETTING, &adapter->state);
                adapter->tx_timeo_cnt = 0;
                adapter->reset_ctx_cnt = 0;
-               clear_bit(QLC_83XX_MBX_READY, &idc->status);
+               clear_bit(QLC_83XX_MBX_READY, &mbx->status);
                qlcnic_sriov_vf_detach(adapter);
        }
        return 0;
@@ -1988,7 +1950,7 @@ int qlcnic_sriov_vf_resume(struct qlcnic_adapter *adapter)
        int err;
 
        set_bit(QLC_83XX_MODULE_LOADED, &idc->status);
-       qlcnic_83xx_enable_mbx_intrpt(adapter);
+       qlcnic_83xx_enable_mbx_interrupt(adapter);
        err = qlcnic_sriov_cfg_bc_intr(adapter, 1);
        if (err)
                return err;
index ee0c1d307966d842d824c3ed64449690946b7d76..2d6faf0fcc10764091df908562be65da82994200 100644 (file)
@@ -635,12 +635,12 @@ static int qlcnic_sriov_pf_channel_cfg_cmd(struct qlcnic_bc_trans *trans,
                                           struct qlcnic_cmd_args *cmd)
 {
        struct qlcnic_vf_info *vf = trans->vf;
-       struct qlcnic_adapter *adapter = vf->adapter;
-       int err;
+       struct qlcnic_vport *vp = vf->vp;
+       struct qlcnic_adapter *adapter;
        u16 func = vf->pci_func;
+       int err;
 
-       cmd->rsp.arg[0] = trans->req_hdr->cmd_op;
-       cmd->rsp.arg[0] |= (1 << 16);
+       adapter = vf->adapter;
 
        if (trans->req_hdr->cmd_op == QLCNIC_BC_CMD_CHANNEL_INIT) {
                err = qlcnic_sriov_pf_config_vport(adapter, 1, func);
@@ -650,6 +650,8 @@ static int qlcnic_sriov_pf_channel_cfg_cmd(struct qlcnic_bc_trans *trans,
                                qlcnic_sriov_pf_config_vport(adapter, 0, func);
                }
        } else {
+               if (vp->vlan_mode == QLC_GUEST_VLAN_MODE)
+                       vp->vlan = 0;
                err = qlcnic_sriov_pf_config_vport(adapter, 0, func);
        }
 
@@ -1183,7 +1185,7 @@ static int qlcnic_sriov_pf_get_acl_cmd(struct qlcnic_bc_trans *trans,
        u8 cmd_op, mode = vp->vlan_mode;
 
        cmd_op = trans->req_hdr->cmd_op;
-       cmd->rsp.arg[0] = (cmd_op & 0xffff) | 14 << 16 | 1 << 25;
+       cmd->rsp.arg[0] |= 1 << 25;
 
        switch (mode) {
        case QLC_GUEST_VLAN_MODE:
@@ -1282,6 +1284,10 @@ static const int qlcnic_pf_passthru_supp_cmds[] = {
        QLCNIC_CMD_GET_STATISTICS,
        QLCNIC_CMD_GET_PORT_CONFIG,
        QLCNIC_CMD_GET_LINK_STATUS,
+       QLCNIC_CMD_DCB_QUERY_CAP,
+       QLCNIC_CMD_DCB_QUERY_PARAM,
+       QLCNIC_CMD_INIT_NIC_FUNC,
+       QLCNIC_CMD_STOP_NIC_FUNC,
 };
 
 static const struct qlcnic_sriov_cmd_handler qlcnic_pf_bc_cmd_hdlr[] = {
@@ -1561,6 +1567,7 @@ void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *sriov,
                                struct qlcnic_vf_info *vf)
 {
        struct net_device *dev = vf->adapter->netdev;
+       struct qlcnic_vport *vp = vf->vp;
 
        if (!test_and_clear_bit(QLC_BC_VF_STATE, &vf->state)) {
                clear_bit(QLC_BC_VF_FLR, &vf->state);
@@ -1573,6 +1580,9 @@ void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *sriov,
                return;
        }
 
+       if (vp->vlan_mode == QLC_GUEST_VLAN_MODE)
+               vp->vlan = 0;
+
        qlcnic_sriov_schedule_flr(sriov, vf, qlcnic_sriov_pf_process_flr);
        netdev_info(dev, "FLR received for PCI func %d\n", vf->pci_func);
 }
@@ -1621,13 +1631,15 @@ int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
        struct qlcnic_sriov *sriov = adapter->ahw->sriov;
-       int i, num_vfs = sriov->num_vfs;
+       int i, num_vfs;
        struct qlcnic_vf_info *vf_info;
        u8 *curr_mac;
 
        if (!qlcnic_sriov_pf_check(adapter))
                return -EOPNOTSUPP;
 
+       num_vfs = sriov->num_vfs;
+
        if (!is_valid_ether_addr(mac) || vf >= num_vfs)
                return -EINVAL;
 
@@ -1741,6 +1753,7 @@ int qlcnic_sriov_set_vf_vlan(struct net_device *netdev, int vf,
 
        switch (vlan) {
        case 4095:
+               vp->vlan = 0;
                vp->vlan_mode = QLC_GUEST_VLAN_MODE;
                break;
        case 0:
@@ -1759,6 +1772,29 @@ int qlcnic_sriov_set_vf_vlan(struct net_device *netdev, int vf,
        return 0;
 }
 
+static inline __u32 qlcnic_sriov_get_vf_vlan(struct qlcnic_adapter *adapter,
+                                            struct qlcnic_vport *vp, int vf)
+{
+       __u32 vlan = 0;
+
+       switch (vp->vlan_mode) {
+       case QLC_PVID_MODE:
+               vlan = vp->vlan;
+               break;
+       case QLC_GUEST_VLAN_MODE:
+               vlan = MAX_VLAN_ID;
+               break;
+       case QLC_NO_VLAN_MODE:
+               vlan = 0;
+               break;
+       default:
+               netdev_info(adapter->netdev, "Invalid VLAN mode = %d for VF %d\n",
+                           vp->vlan_mode, vf);
+       }
+
+       return vlan;
+}
+
 int qlcnic_sriov_get_vf_config(struct net_device *netdev,
                               int vf, struct ifla_vf_info *ivi)
 {
@@ -1774,7 +1810,7 @@ int qlcnic_sriov_get_vf_config(struct net_device *netdev,
 
        vp = sriov->vf_info[vf].vp;
        memcpy(&ivi->mac, vp->mac, ETH_ALEN);
-       ivi->vlan = vp->vlan;
+       ivi->vlan = qlcnic_sriov_get_vf_vlan(adapter, vp, vf);
        ivi->qos = vp->qos;
        ivi->spoofchk = vp->spoofchk;
        if (vp->max_tx_bw == MAX_BW)
index 10ed82b3baca0970f65ce9797a18fc35cf76b1e3..660c3f5b22377a956c0caed68e59e6761d282239 100644 (file)
@@ -170,9 +170,9 @@ static int qlcnic_82xx_store_beacon(struct qlcnic_adapter *adapter,
 
        if (ahw->extra_capability[0] & QLCNIC_FW_CAPABILITY_2_BEACON) {
                err = qlcnic_get_beacon_state(adapter, &h_beacon_state);
-               if (!err) {
-                       dev_info(&adapter->pdev->dev,
-                                "Failed to get current beacon state\n");
+               if (err) {
+                       netdev_err(adapter->netdev,
+                                  "Failed to get current beacon state\n");
                } else {
                        if (h_beacon_state == QLCNIC_BEACON_DISABLE)
                                ahw->beacon_state = 0;
index 7e8d68263963aa5928f5ef1f145ad27624c14ce2..89943377846699e1e2719be8b2da16b07b144d09 100644 (file)
@@ -2149,7 +2149,7 @@ struct ql_adapter {
        struct timer_list timer;
        atomic_t lb_count;
        /* Keep local copy of current mac address. */
-       char current_mac_addr[6];
+       char current_mac_addr[ETH_ALEN];
 };
 
 /*
index e6acb9fa5767687d8565596adc11328f55e2a12b..d2e591955bdde3fd03b40dac1c9c22e3d013c23d 100644 (file)
@@ -478,7 +478,7 @@ rx_status_loop:
 
        while (1) {
                u32 status, len;
-               dma_addr_t mapping;
+               dma_addr_t mapping, new_mapping;
                struct sk_buff *skb, *new_skb;
                struct cp_desc *desc;
                const unsigned buflen = cp->rx_buf_sz;
@@ -520,6 +520,14 @@ rx_status_loop:
                        goto rx_next;
                }
 
+               new_mapping = dma_map_single(&cp->pdev->dev, new_skb->data, buflen,
+                                        PCI_DMA_FROMDEVICE);
+               if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
+                       dev->stats.rx_dropped++;
+                       kfree_skb(new_skb);
+                       goto rx_next;
+               }
+
                dma_unmap_single(&cp->pdev->dev, mapping,
                                 buflen, PCI_DMA_FROMDEVICE);
 
@@ -531,12 +539,11 @@ rx_status_loop:
 
                skb_put(skb, len);
 
-               mapping = dma_map_single(&cp->pdev->dev, new_skb->data, buflen,
-                                        PCI_DMA_FROMDEVICE);
                cp->rx_skb[rx_tail] = new_skb;
 
                cp_rx_skb(cp, skb, desc);
                rx++;
+               mapping = new_mapping;
 
 rx_next:
                cp->rx_ring[rx_tail].opts2 = 0;
@@ -716,6 +723,22 @@ static inline u32 cp_tx_vlan_tag(struct sk_buff *skb)
                TxVlanTag | swab16(vlan_tx_tag_get(skb)) : 0x00;
 }
 
+static void unwind_tx_frag_mapping(struct cp_private *cp, struct sk_buff *skb,
+                                  int first, int entry_last)
+{
+       int frag, index;
+       struct cp_desc *txd;
+       skb_frag_t *this_frag;
+       for (frag = 0; frag+first < entry_last; frag++) {
+               index = first+frag;
+               cp->tx_skb[index] = NULL;
+               txd = &cp->tx_ring[index];
+               this_frag = &skb_shinfo(skb)->frags[frag];
+               dma_unmap_single(&cp->pdev->dev, le64_to_cpu(txd->addr),
+                                skb_frag_size(this_frag), PCI_DMA_TODEVICE);
+       }
+}
+
 static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
                                        struct net_device *dev)
 {
@@ -749,6 +772,9 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
 
                len = skb->len;
                mapping = dma_map_single(&cp->pdev->dev, skb->data, len, PCI_DMA_TODEVICE);
+               if (dma_mapping_error(&cp->pdev->dev, mapping))
+                       goto out_dma_error;
+
                txd->opts2 = opts2;
                txd->addr = cpu_to_le64(mapping);
                wmb();
@@ -786,6 +812,9 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
                first_len = skb_headlen(skb);
                first_mapping = dma_map_single(&cp->pdev->dev, skb->data,
                                               first_len, PCI_DMA_TODEVICE);
+               if (dma_mapping_error(&cp->pdev->dev, first_mapping))
+                       goto out_dma_error;
+
                cp->tx_skb[entry] = skb;
                entry = NEXT_TX(entry);
 
@@ -799,6 +828,11 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
                        mapping = dma_map_single(&cp->pdev->dev,
                                                 skb_frag_address(this_frag),
                                                 len, PCI_DMA_TODEVICE);
+                       if (dma_mapping_error(&cp->pdev->dev, mapping)) {
+                               unwind_tx_frag_mapping(cp, skb, first_entry, entry);
+                               goto out_dma_error;
+                       }
+
                        eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
 
                        ctrl = eor | len | DescOwn;
@@ -859,11 +893,16 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
        if (TX_BUFFS_AVAIL(cp) <= (MAX_SKB_FRAGS + 1))
                netif_stop_queue(dev);
 
+out_unlock:
        spin_unlock_irqrestore(&cp->lock, intr_flags);
 
        cpw8(TxPoll, NormalTxPoll);
 
        return NETDEV_TX_OK;
+out_dma_error:
+       kfree_skb(skb);
+       cp->dev->stats.tx_dropped++;
+       goto out_unlock;
 }
 
 /* Set or clear the multicast filter for this adaptor.
@@ -1054,6 +1093,10 @@ static int cp_refill_rx(struct cp_private *cp)
 
                mapping = dma_map_single(&cp->pdev->dev, skb->data,
                                         cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
+               if (dma_mapping_error(&cp->pdev->dev, mapping)) {
+                       kfree_skb(skb);
+                       goto err_out;
+               }
                cp->rx_skb[i] = skb;
 
                cp->rx_ring[i].opts2 = 0;
index 4106a743ca74c16e0dcf02b1d9b9bc10b76e79a9..6f87f2cde647fba98bed02cc599afff911125ded 100644 (file)
@@ -1897,12 +1897,13 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
                             void *p)
 {
        struct rtl8169_private *tp = netdev_priv(dev);
-
-       if (regs->len > R8169_REGS_SIZE)
-               regs->len = R8169_REGS_SIZE;
+       u32 __iomem *data = tp->mmio_addr;
+       u32 *dw = p;
+       int i;
 
        rtl_lock_work(tp);
-       memcpy_fromio(p, tp->mmio_addr, regs->len);
+       for (i = 0; i < R8169_REGS_SIZE; i += 4)
+               memcpy_fromio(dw++, data++, 4);
        rtl_unlock_work(tp);
 }
 
@@ -3689,7 +3690,7 @@ static void rtl_phy_work(struct rtl8169_private *tp)
        if (tp->link_ok(ioaddr))
                return;
 
-       netif_warn(tp, link, tp->dev, "PHY reset until link up\n");
+       netif_dbg(tp, link, tp->dev, "PHY reset until link up\n");
 
        tp->phy_reset_enable(tp);
 
@@ -6468,6 +6469,8 @@ static int rtl8169_close(struct net_device *dev)
        rtl8169_down(dev);
        rtl_unlock_work(tp);
 
+       cancel_work_sync(&tp->wk.work);
+
        free_irq(pdev->irq, dev);
 
        dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
@@ -6793,8 +6796,6 @@ static void rtl_remove_one(struct pci_dev *pdev)
                rtl8168_driver_stop(tp);
        }
 
-       cancel_work_sync(&tp->wk.work);
-
        netif_napi_del(&tp->napi);
 
        unregister_netdev(dev);
@@ -7088,7 +7089,7 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        RTL_W8(Cfg9346, Cfg9346_Unlock);
        RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
-       RTL_W8(Config5, RTL_R8(Config5) & PMEStatus);
+       RTL_W8(Config5, RTL_R8(Config5) & (BWF | MWF | UWF | LanWake | PMEStatus));
        if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0)
                tp->features |= RTL_FEATURE_WOL;
        if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
index 19a8a045e07728868cbe3a6e08b841865068e3e3..a30c4395b23220902d4b785333b31b53abfb24c7 100644 (file)
@@ -13,4 +13,4 @@ config SH_ETH
          Renesas SuperH Ethernet device driver.
          This driver supporting CPUs are:
                - SH7619, SH7710, SH7712, SH7724, SH7734, SH7763, SH7757,
-                 R8A7740 and R8A7779.
+                 R8A7740, R8A777x and R8A7790.
index a753928bab9c683d54036f92350e6db466eaa7b9..c3570764f58f9dcfb774a8534fdde38403701e62 100644 (file)
@@ -189,6 +189,7 @@ static const u16 sh_eth_offset_fast_rcar[SH_ETH_MAX_REGISTER_OFFSET] = {
        [RMCR]          = 0x0258,
        [TFUCR]         = 0x0264,
        [RFOCR]         = 0x0268,
+       [RMIIMODE]      = 0x026c,
        [FCFTR]         = 0x0270,
        [TRIMD]         = 0x027c,
 };
@@ -377,6 +378,8 @@ static struct sh_eth_cpu_data r8a777x_data = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_r8a777x,
 
+       .register_type  = SH_ETH_REG_FAST_RCAR,
+
        .ecsr_value     = ECSR_PSRTO | ECSR_LCHNG | ECSR_ICD,
        .ecsipr_value   = ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | ECSIPR_ICDIP,
        .eesipr_value   = 0x01ff009f,
@@ -392,6 +395,29 @@ static struct sh_eth_cpu_data r8a777x_data = {
        .hw_swap        = 1,
 };
 
+/* R8A7790 */
+static struct sh_eth_cpu_data r8a7790_data = {
+       .set_duplex     = sh_eth_set_duplex,
+       .set_rate       = sh_eth_set_rate_r8a777x,
+
+       .register_type  = SH_ETH_REG_FAST_RCAR,
+
+       .ecsr_value     = ECSR_PSRTO | ECSR_LCHNG | ECSR_ICD,
+       .ecsipr_value   = ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | ECSIPR_ICDIP,
+       .eesipr_value   = 0x01ff009f,
+
+       .tx_check       = EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO,
+       .eesr_err_check = EESR_TWB | EESR_TABT | EESR_RABT | EESR_RFE |
+                         EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE |
+                         EESR_ECI,
+
+       .apr            = 1,
+       .mpr            = 1,
+       .tpauser        = 1,
+       .hw_swap        = 1,
+       .rmiimode       = 1,
+};
+
 static void sh_eth_set_rate_sh7724(struct net_device *ndev)
 {
        struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -413,6 +439,8 @@ static struct sh_eth_cpu_data sh7724_data = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_sh7724,
 
+       .register_type  = SH_ETH_REG_FAST_SH4,
+
        .ecsr_value     = ECSR_PSRTO | ECSR_LCHNG | ECSR_ICD,
        .ecsipr_value   = ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | ECSIPR_ICDIP,
        .eesipr_value   = 0x01ff009f,
@@ -451,6 +479,8 @@ static struct sh_eth_cpu_data sh7757_data = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_sh7757,
 
+       .register_type  = SH_ETH_REG_FAST_SH4,
+
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
        .rmcr_value     = 0x00000001,
 
@@ -519,6 +549,8 @@ static struct sh_eth_cpu_data sh7757_data_giga = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_giga,
 
+       .register_type  = SH_ETH_REG_GIGABIT,
+
        .ecsr_value     = ECSR_ICD | ECSR_MPD,
        .ecsipr_value   = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
@@ -577,6 +609,8 @@ static struct sh_eth_cpu_data sh7734_data = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_gether,
 
+       .register_type  = SH_ETH_REG_GIGABIT,
+
        .ecsr_value     = ECSR_ICD | ECSR_MPD,
        .ecsipr_value   = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
@@ -604,6 +638,8 @@ static struct sh_eth_cpu_data sh7763_data = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_gether,
 
+       .register_type  = SH_ETH_REG_GIGABIT,
+
        .ecsr_value     = ECSR_ICD | ECSR_MPD,
        .ecsipr_value   = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
@@ -641,6 +677,8 @@ static struct sh_eth_cpu_data r8a7740_data = {
        .set_duplex     = sh_eth_set_duplex,
        .set_rate       = sh_eth_set_rate_gether,
 
+       .register_type  = SH_ETH_REG_GIGABIT,
+
        .ecsr_value     = ECSR_ICD | ECSR_MPD,
        .ecsipr_value   = ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP,
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
@@ -663,6 +701,8 @@ static struct sh_eth_cpu_data r8a7740_data = {
 };
 
 static struct sh_eth_cpu_data sh7619_data = {
+       .register_type  = SH_ETH_REG_FAST_SH3_SH2,
+
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
 
        .apr            = 1,
@@ -672,6 +712,8 @@ static struct sh_eth_cpu_data sh7619_data = {
 };
 
 static struct sh_eth_cpu_data sh771x_data = {
+       .register_type  = SH_ETH_REG_FAST_SH3_SH2,
+
        .eesipr_value   = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
        .tsu            = 1,
 };
@@ -1124,6 +1166,9 @@ static int sh_eth_dev_init(struct net_device *ndev, bool start)
        if (ret)
                goto out;
 
+       if (mdp->cd->rmiimode)
+               sh_eth_write(ndev, 0x1, RMIIMODE);
+
        /* Descriptor format */
        sh_eth_ring_format(ndev);
        if (mdp->cd->rpadir)
@@ -2618,10 +2663,10 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
        mdp->edmac_endian = pd->edmac_endian;
        mdp->no_ether_link = pd->no_ether_link;
        mdp->ether_link_active_low = pd->ether_link_active_low;
-       mdp->reg_offset = sh_eth_get_register_offset(pd->register_type);
 
        /* set cpu data */
        mdp->cd = (struct sh_eth_cpu_data *)id->driver_data;
+       mdp->reg_offset = sh_eth_get_register_offset(mdp->cd->register_type);
        sh_eth_set_default_cpu_data(mdp->cd);
 
        /* set function */
@@ -2749,6 +2794,7 @@ static struct platform_device_id sh_eth_id_table[] = {
        { "sh7763-gether", (kernel_ulong_t)&sh7763_data },
        { "r8a7740-gether", (kernel_ulong_t)&r8a7740_data },
        { "r8a777x-ether", (kernel_ulong_t)&r8a777x_data },
+       { "r8a7790-ether", (kernel_ulong_t)&r8a7790_data },
        { }
 };
 MODULE_DEVICE_TABLE(platform, sh_eth_id_table);
index 99995bf38c403a3eb641a9d1f79fe5fc54aa6b8b..a0db02c63b1157930ca0fca070dd733aa39b7c54 100644 (file)
@@ -60,6 +60,7 @@ enum {
        EDOCR,
        TFUCR,
        RFOCR,
+       RMIIMODE,
        FCFTR,
        RPADIR,
        TRIMD,
@@ -156,6 +157,13 @@ enum {
        SH_ETH_MAX_REGISTER_OFFSET,
 };
 
+enum {
+       SH_ETH_REG_GIGABIT,
+       SH_ETH_REG_FAST_RCAR,
+       SH_ETH_REG_FAST_SH4,
+       SH_ETH_REG_FAST_SH3_SH2
+};
+
 /* Driver's parameters */
 #if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
 #define SH4_SKB_RX_ALIGN       32
@@ -453,6 +461,7 @@ struct sh_eth_cpu_data {
        void (*set_rate)(struct net_device *ndev);
 
        /* mandatory initialize value */
+       int register_type;
        unsigned long eesipr_value;
 
        /* optional initialize value */
@@ -482,6 +491,7 @@ struct sh_eth_cpu_data {
        unsigned hw_crc:1;      /* E-DMAC have CSMR */
        unsigned select_mii:1;  /* EtherC have RMII_MII (MII select register) */
        unsigned shift_rd0:1;   /* shift Rx descriptor word 0 right by 16 */
+       unsigned rmiimode:1;    /* EtherC has RMIIMODE register */
 };
 
 struct sh_eth_private {
index 945bf06e69ef11c636849ed1f20263868a6b0947..a61272661a732ec04864a1f2cc13598bb6c308f9 100644 (file)
@@ -1,8 +1,7 @@
-sfc-y                  += efx.o nic.o falcon.o siena.o tx.o rx.o filter.o \
-                          falcon_xmac.o mcdi_mac.o \
+sfc-y                  += efx.o nic.o farch.o falcon.o siena.o tx.o rx.o \
                           selftest.o ethtool.o qt202x_phy.o mdio_10g.o \
                           tenxpress.o txc43128_phy.o falcon_boards.o \
-                          mcdi.o mcdi_phy.o mcdi_mon.o ptp.o
+                          mcdi.o mcdi_port.o mcdi_mon.o ptp.o
 sfc-$(CONFIG_SFC_MTD)  += mtd.o
 sfc-$(CONFIG_SFC_SRIOV)        += siena_sriov.o
 
index c72968840f1a6784413e46e53e1fcd31923bf389..db2f119d7fec202d8b6e6f9174ebd253e7b0eef8 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/in.h>
-#include <linux/crc32.h>
 #include <linux/ethtool.h>
 #include <linux/topology.h>
 #include <linux/gfp.h>
@@ -81,8 +80,7 @@ const char *const efx_reset_type_names[] = {
        [RESET_TYPE_TX_WATCHDOG]        = "TX_WATCHDOG",
        [RESET_TYPE_INT_ERROR]          = "INT_ERROR",
        [RESET_TYPE_RX_RECOVERY]        = "RX_RECOVERY",
-       [RESET_TYPE_RX_DESC_FETCH]      = "RX_DESC_FETCH",
-       [RESET_TYPE_TX_DESC_FETCH]      = "TX_DESC_FETCH",
+       [RESET_TYPE_DMA_ERROR]          = "DMA_ERROR",
        [RESET_TYPE_TX_SKIP]            = "TX_SKIP",
        [RESET_TYPE_MC_FAILURE]         = "MC_FAILURE",
 };
@@ -191,8 +189,8 @@ MODULE_PARM_DESC(debug, "Bitmapped debugging message enable value");
  *
  *************************************************************************/
 
-static void efx_start_interrupts(struct efx_nic *efx, bool may_keep_eventq);
-static void efx_stop_interrupts(struct efx_nic *efx, bool may_keep_eventq);
+static void efx_soft_enable_interrupts(struct efx_nic *efx);
+static void efx_soft_disable_interrupts(struct efx_nic *efx);
 static void efx_remove_channel(struct efx_channel *channel);
 static void efx_remove_channels(struct efx_nic *efx);
 static const struct efx_channel_type efx_default_channel_type;
@@ -248,30 +246,12 @@ static int efx_process_channel(struct efx_channel *channel, int budget)
                        efx_channel_get_rx_queue(channel);
 
                efx_rx_flush_packet(channel);
-               if (rx_queue->enabled)
-                       efx_fast_push_rx_descriptors(rx_queue);
+               efx_fast_push_rx_descriptors(rx_queue);
        }
 
        return spent;
 }
 
-/* Mark channel as finished processing
- *
- * Note that since we will not receive further interrupts for this
- * channel before we finish processing and call the eventq_read_ack()
- * method, there is no need to use the interrupt hold-off timers.
- */
-static inline void efx_channel_processed(struct efx_channel *channel)
-{
-       /* The interrupt handler for this channel may set work_pending
-        * as soon as we acknowledge the events we've seen.  Make sure
-        * it's cleared before then. */
-       channel->work_pending = false;
-       smp_wmb();
-
-       efx_nic_eventq_read_ack(channel);
-}
-
 /* NAPI poll handler
  *
  * NAPI guarantees serialisation of polls of the same device, which
@@ -316,58 +296,16 @@ static int efx_poll(struct napi_struct *napi, int budget)
 
                /* There is no race here; although napi_disable() will
                 * only wait for napi_complete(), this isn't a problem
-                * since efx_channel_processed() will have no effect if
+                * since efx_nic_eventq_read_ack() will have no effect if
                 * interrupts have already been disabled.
                 */
                napi_complete(napi);
-               efx_channel_processed(channel);
+               efx_nic_eventq_read_ack(channel);
        }
 
        return spent;
 }
 
-/* Process the eventq of the specified channel immediately on this CPU
- *
- * Disable hardware generated interrupts, wait for any existing
- * processing to finish, then directly poll (and ack ) the eventq.
- * Finally reenable NAPI and interrupts.
- *
- * This is for use only during a loopback self-test.  It must not
- * deliver any packets up the stack as this can result in deadlock.
- */
-void efx_process_channel_now(struct efx_channel *channel)
-{
-       struct efx_nic *efx = channel->efx;
-
-       BUG_ON(channel->channel >= efx->n_channels);
-       BUG_ON(!channel->enabled);
-       BUG_ON(!efx->loopback_selftest);
-
-       /* Disable interrupts and wait for ISRs to complete */
-       efx_nic_disable_interrupts(efx);
-       if (efx->legacy_irq) {
-               synchronize_irq(efx->legacy_irq);
-               efx->legacy_irq_enabled = false;
-       }
-       if (channel->irq)
-               synchronize_irq(channel->irq);
-
-       /* Wait for any NAPI processing to complete */
-       napi_disable(&channel->napi_str);
-
-       /* Poll the channel */
-       efx_process_channel(channel, channel->eventq_mask + 1);
-
-       /* Ack the eventq. This may cause an interrupt to be generated
-        * when they are reenabled */
-       efx_channel_processed(channel);
-
-       napi_enable(&channel->napi_str);
-       if (efx->legacy_irq)
-               efx->legacy_irq_enabled = true;
-       efx_nic_enable_interrupts(efx);
-}
-
 /* Create event queue
  * Event queue memory allocations are done only once.  If the channel
  * is reset, the memory buffer will be reused; this guards against
@@ -399,6 +337,7 @@ static void efx_init_eventq(struct efx_channel *channel)
        channel->eventq_read_ptr = 0;
 
        efx_nic_init_eventq(channel);
+       channel->eventq_init = true;
 }
 
 /* Enable event queue processing and NAPI */
@@ -407,11 +346,7 @@ static void efx_start_eventq(struct efx_channel *channel)
        netif_dbg(channel->efx, ifup, channel->efx->net_dev,
                  "chan %d start event queue\n", channel->channel);
 
-       /* The interrupt handler for this channel may set work_pending
-        * as soon as we enable it.  Make sure it's cleared before
-        * then.  Similarly, make sure it sees the enabled flag set.
-        */
-       channel->work_pending = false;
+       /* Make sure the NAPI handler sees the enabled flag set */
        channel->enabled = true;
        smp_wmb();
 
@@ -431,10 +366,14 @@ static void efx_stop_eventq(struct efx_channel *channel)
 
 static void efx_fini_eventq(struct efx_channel *channel)
 {
+       if (!channel->eventq_init)
+               return;
+
        netif_dbg(channel->efx, drv, channel->efx->net_dev,
                  "chan %d fini event queue\n", channel->channel);
 
        efx_nic_fini_eventq(channel);
+       channel->eventq_init = false;
 }
 
 static void efx_remove_eventq(struct efx_channel *channel)
@@ -583,8 +522,8 @@ static void efx_set_channel_names(struct efx_nic *efx)
 
        efx_for_each_channel(channel, efx)
                channel->type->get_name(channel,
-                                       efx->channel_name[channel->channel],
-                                       sizeof(efx->channel_name[0]));
+                                       efx->msi_context[channel->channel].name,
+                                       sizeof(efx->msi_context[0].name));
 }
 
 static int efx_probe_channels(struct efx_nic *efx)
@@ -634,7 +573,7 @@ static void efx_start_datapath(struct efx_nic *efx)
         * support the current MTU, including padding for header
         * alignment and overruns.
         */
-       efx->rx_dma_len = (efx->type->rx_buffer_hash_size +
+       efx->rx_dma_len = (efx->rx_prefix_size +
                           EFX_MAX_FRAME_LEN(efx->net_dev->mtu) +
                           efx->type->rx_buffer_padding);
        rx_buf_len = (sizeof(struct efx_rx_page_state) +
@@ -670,7 +609,7 @@ static void efx_start_datapath(struct efx_nic *efx)
 
        /* RX filters also have scatter-enabled flags */
        if (efx->rx_scatter != old_rx_scatter)
-               efx_filter_update_rx_scatter(efx);
+               efx->type->filter_update_rx_scatter(efx);
 
        /* We must keep at least one descriptor in a TX ring empty.
         * We could avoid this when the queue size does not exactly
@@ -704,30 +643,15 @@ static void efx_stop_datapath(struct efx_nic *efx)
        struct efx_channel *channel;
        struct efx_tx_queue *tx_queue;
        struct efx_rx_queue *rx_queue;
-       struct pci_dev *dev = efx->pci_dev;
        int rc;
 
        EFX_ASSERT_RESET_SERIALISED(efx);
        BUG_ON(efx->port_enabled);
 
-       /* Only perform flush if dma is enabled */
-       if (dev->is_busmaster && efx->state != STATE_RECOVERY) {
-               rc = efx_nic_flush_queues(efx);
-
-               if (rc && EFX_WORKAROUND_7803(efx)) {
-                       /* Schedule a reset to recover from the flush failure. The
-                        * descriptor caches reference memory we're about to free,
-                        * but falcon_reconfigure_mac_wrapper() won't reconnect
-                        * the MACs because of the pending reset. */
-                       netif_err(efx, drv, efx->net_dev,
-                                 "Resetting to recover from flush failure\n");
-                       efx_schedule_reset(efx, RESET_TYPE_ALL);
-               } else if (rc) {
-                       netif_err(efx, drv, efx->net_dev, "failed to flush queues\n");
-               } else {
-                       netif_dbg(efx, drv, efx->net_dev,
-                                 "successfully flushed all queues\n");
-               }
+       /* Stop RX refill */
+       efx_for_each_channel(channel, efx) {
+               efx_for_each_channel_rx_queue(rx_queue, channel)
+                       rx_queue->refill_enabled = false;
        }
 
        efx_for_each_channel(channel, efx) {
@@ -741,7 +665,26 @@ static void efx_stop_datapath(struct efx_nic *efx)
                        efx_stop_eventq(channel);
                        efx_start_eventq(channel);
                }
+       }
+
+       rc = efx->type->fini_dmaq(efx);
+       if (rc && EFX_WORKAROUND_7803(efx)) {
+               /* Schedule a reset to recover from the flush failure. The
+                * descriptor caches reference memory we're about to free,
+                * but falcon_reconfigure_mac_wrapper() won't reconnect
+                * the MACs because of the pending reset.
+                */
+               netif_err(efx, drv, efx->net_dev,
+                         "Resetting to recover from flush failure\n");
+               efx_schedule_reset(efx, RESET_TYPE_ALL);
+       } else if (rc) {
+               netif_err(efx, drv, efx->net_dev, "failed to flush queues\n");
+       } else {
+               netif_dbg(efx, drv, efx->net_dev,
+                         "successfully flushed all queues\n");
+       }
 
+       efx_for_each_channel(channel, efx) {
                efx_for_each_channel_rx_queue(rx_queue, channel)
                        efx_fini_rx_queue(rx_queue);
                efx_for_each_possible_channel_tx_queue(tx_queue, channel)
@@ -809,7 +752,7 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)
 
        efx_device_detach_sync(efx);
        efx_stop_all(efx);
-       efx_stop_interrupts(efx, true);
+       efx_soft_disable_interrupts(efx);
 
        /* Clone channels (where possible) */
        memset(other_channel, 0, sizeof(other_channel));
@@ -859,7 +802,7 @@ out:
                }
        }
 
-       efx_start_interrupts(efx, true);
+       efx_soft_enable_interrupts(efx);
        efx_start_all(efx);
        netif_device_attach(efx->net_dev);
        return rc;
@@ -931,10 +874,9 @@ void efx_link_status_changed(struct efx_nic *efx)
        /* Status message for kernel log */
        if (link_state->up)
                netif_info(efx, link, efx->net_dev,
-                          "link up at %uMbps %s-duplex (MTU %d)%s\n",
+                          "link up at %uMbps %s-duplex (MTU %d)\n",
                           link_state->speed, link_state->fd ? "full" : "half",
-                          efx->net_dev->mtu,
-                          (efx->promiscuous ? " [PROMISC]" : ""));
+                          efx->net_dev->mtu);
        else
                netif_info(efx, link, efx->net_dev, "link down\n");
 }
@@ -983,10 +925,6 @@ int __efx_reconfigure_port(struct efx_nic *efx)
 
        WARN_ON(!mutex_is_locked(&efx->mac_lock));
 
-       /* Serialise the promiscuous flag with efx_set_rx_mode. */
-       netif_addr_lock_bh(efx->net_dev);
-       netif_addr_unlock_bh(efx->net_dev);
-
        /* Disable PHY transmit in mac level loopbacks */
        phy_mode = efx->phy_mode;
        if (LOOPBACK_INTERNAL(efx))
@@ -1144,6 +1082,7 @@ static int efx_init_io(struct efx_nic *efx)
 {
        struct pci_dev *pci_dev = efx->pci_dev;
        dma_addr_t dma_mask = efx->type->max_dma_mask;
+       unsigned int mem_map_size = efx->type->mem_map_size(efx);
        int rc;
 
        netif_dbg(efx, probe, efx->net_dev, "initialising I/O\n");
@@ -1196,20 +1135,18 @@ static int efx_init_io(struct efx_nic *efx)
                rc = -EIO;
                goto fail3;
        }
-       efx->membase = ioremap_nocache(efx->membase_phys,
-                                      efx->type->mem_map_size);
+       efx->membase = ioremap_nocache(efx->membase_phys, mem_map_size);
        if (!efx->membase) {
                netif_err(efx, probe, efx->net_dev,
                          "could not map memory BAR at %llx+%x\n",
-                         (unsigned long long)efx->membase_phys,
-                         efx->type->mem_map_size);
+                         (unsigned long long)efx->membase_phys, mem_map_size);
                rc = -ENOMEM;
                goto fail4;
        }
        netif_dbg(efx, probe, efx->net_dev,
                  "memory BAR at %llx+%x (virtual %p)\n",
-                 (unsigned long long)efx->membase_phys,
-                 efx->type->mem_map_size, efx->membase);
+                 (unsigned long long)efx->membase_phys, mem_map_size,
+                 efx->membase);
 
        return 0;
 
@@ -1288,8 +1225,6 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx)
  */
 static int efx_probe_interrupts(struct efx_nic *efx)
 {
-       unsigned int max_channels =
-               min(efx->type->phys_addr_channels, EFX_MAX_CHANNELS);
        unsigned int extra_channels = 0;
        unsigned int i, j;
        int rc;
@@ -1306,7 +1241,7 @@ static int efx_probe_interrupts(struct efx_nic *efx)
                if (separate_tx_channels)
                        n_channels *= 2;
                n_channels += extra_channels;
-               n_channels = min(n_channels, max_channels);
+               n_channels = min(n_channels, efx->max_channels);
 
                for (i = 0; i < n_channels; i++)
                        xentries[i].entry = i;
@@ -1392,23 +1327,17 @@ static int efx_probe_interrupts(struct efx_nic *efx)
        return 0;
 }
 
-/* Enable interrupts, then probe and start the event queues */
-static void efx_start_interrupts(struct efx_nic *efx, bool may_keep_eventq)
+static void efx_soft_enable_interrupts(struct efx_nic *efx)
 {
        struct efx_channel *channel;
 
        BUG_ON(efx->state == STATE_DISABLED);
 
-       if (efx->eeh_disabled_legacy_irq) {
-               enable_irq(efx->legacy_irq);
-               efx->eeh_disabled_legacy_irq = false;
-       }
-       if (efx->legacy_irq)
-               efx->legacy_irq_enabled = true;
-       efx_nic_enable_interrupts(efx);
+       efx->irq_soft_enabled = true;
+       smp_wmb();
 
        efx_for_each_channel(channel, efx) {
-               if (!channel->type->keep_eventq || !may_keep_eventq)
+               if (!channel->type->keep_eventq)
                        efx_init_eventq(channel);
                efx_start_eventq(channel);
        }
@@ -1416,7 +1345,7 @@ static void efx_start_interrupts(struct efx_nic *efx, bool may_keep_eventq)
        efx_mcdi_mode_event(efx);
 }
 
-static void efx_stop_interrupts(struct efx_nic *efx, bool may_keep_eventq)
+static void efx_soft_disable_interrupts(struct efx_nic *efx)
 {
        struct efx_channel *channel;
 
@@ -1425,20 +1354,55 @@ static void efx_stop_interrupts(struct efx_nic *efx, bool may_keep_eventq)
 
        efx_mcdi_mode_poll(efx);
 
-       efx_nic_disable_interrupts(efx);
-       if (efx->legacy_irq) {
+       efx->irq_soft_enabled = false;
+       smp_wmb();
+
+       if (efx->legacy_irq)
                synchronize_irq(efx->legacy_irq);
-               efx->legacy_irq_enabled = false;
-       }
 
        efx_for_each_channel(channel, efx) {
                if (channel->irq)
                        synchronize_irq(channel->irq);
 
                efx_stop_eventq(channel);
-               if (!channel->type->keep_eventq || !may_keep_eventq)
+               if (!channel->type->keep_eventq)
+                       efx_fini_eventq(channel);
+       }
+}
+
+static void efx_enable_interrupts(struct efx_nic *efx)
+{
+       struct efx_channel *channel;
+
+       BUG_ON(efx->state == STATE_DISABLED);
+
+       if (efx->eeh_disabled_legacy_irq) {
+               enable_irq(efx->legacy_irq);
+               efx->eeh_disabled_legacy_irq = false;
+       }
+
+       efx->type->irq_enable_master(efx);
+
+       efx_for_each_channel(channel, efx) {
+               if (channel->type->keep_eventq)
+                       efx_init_eventq(channel);
+       }
+
+       efx_soft_enable_interrupts(efx);
+}
+
+static void efx_disable_interrupts(struct efx_nic *efx)
+{
+       struct efx_channel *channel;
+
+       efx_soft_disable_interrupts(efx);
+
+       efx_for_each_channel(channel, efx) {
+               if (channel->type->keep_eventq)
                        efx_fini_eventq(channel);
        }
+
+       efx->type->irq_disable_non_ev(efx);
 }
 
 static void efx_remove_interrupts(struct efx_nic *efx)
@@ -1528,6 +1492,44 @@ static void efx_remove_nic(struct efx_nic *efx)
        efx->type->remove(efx);
 }
 
+static int efx_probe_filters(struct efx_nic *efx)
+{
+       int rc;
+
+       spin_lock_init(&efx->filter_lock);
+
+       rc = efx->type->filter_table_probe(efx);
+       if (rc)
+               return rc;
+
+#ifdef CONFIG_RFS_ACCEL
+       if (efx->type->offload_features & NETIF_F_NTUPLE) {
+               efx->rps_flow_id = kcalloc(efx->type->max_rx_ip_filters,
+                                          sizeof(*efx->rps_flow_id),
+                                          GFP_KERNEL);
+               if (!efx->rps_flow_id) {
+                       efx->type->filter_table_remove(efx);
+                       return -ENOMEM;
+               }
+       }
+#endif
+
+       return 0;
+}
+
+static void efx_remove_filters(struct efx_nic *efx)
+{
+#ifdef CONFIG_RFS_ACCEL
+       kfree(efx->rps_flow_id);
+#endif
+       efx->type->filter_table_remove(efx);
+}
+
+static void efx_restore_filters(struct efx_nic *efx)
+{
+       efx->type->filter_table_restore(efx);
+}
+
 /**************************************************************************
  *
  * NIC startup/shutdown
@@ -1917,34 +1919,9 @@ static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev,
                                               struct rtnl_link_stats64 *stats)
 {
        struct efx_nic *efx = netdev_priv(net_dev);
-       struct efx_mac_stats *mac_stats = &efx->mac_stats;
 
        spin_lock_bh(&efx->stats_lock);
-
-       efx->type->update_stats(efx);
-
-       stats->rx_packets = mac_stats->rx_packets;
-       stats->tx_packets = mac_stats->tx_packets;
-       stats->rx_bytes = mac_stats->rx_bytes;
-       stats->tx_bytes = mac_stats->tx_bytes;
-       stats->rx_dropped = efx->n_rx_nodesc_drop_cnt;
-       stats->multicast = mac_stats->rx_multicast;
-       stats->collisions = mac_stats->tx_collision;
-       stats->rx_length_errors = (mac_stats->rx_gtjumbo +
-                                  mac_stats->rx_length_error);
-       stats->rx_crc_errors = mac_stats->rx_bad;
-       stats->rx_frame_errors = mac_stats->rx_align_error;
-       stats->rx_fifo_errors = mac_stats->rx_overflow;
-       stats->rx_missed_errors = mac_stats->rx_missed;
-       stats->tx_window_errors = mac_stats->tx_late_collision;
-
-       stats->rx_errors = (stats->rx_length_errors +
-                           stats->rx_crc_errors +
-                           stats->rx_frame_errors +
-                           mac_stats->rx_symbol_error);
-       stats->tx_errors = (stats->tx_window_errors +
-                           mac_stats->tx_bad);
-
+       efx->type->update_stats(efx, NULL, stats);
        spin_unlock_bh(&efx->stats_lock);
 
        return stats;
@@ -2018,30 +1995,6 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
 static void efx_set_rx_mode(struct net_device *net_dev)
 {
        struct efx_nic *efx = netdev_priv(net_dev);
-       struct netdev_hw_addr *ha;
-       union efx_multicast_hash *mc_hash = &efx->multicast_hash;
-       u32 crc;
-       int bit;
-
-       efx->promiscuous = !!(net_dev->flags & IFF_PROMISC);
-
-       /* Build multicast hash table */
-       if (efx->promiscuous || (net_dev->flags & IFF_ALLMULTI)) {
-               memset(mc_hash, 0xff, sizeof(*mc_hash));
-       } else {
-               memset(mc_hash, 0x00, sizeof(*mc_hash));
-               netdev_for_each_mc_addr(ha, net_dev) {
-                       crc = ether_crc_le(ETH_ALEN, ha->addr);
-                       bit = crc & (EFX_MCAST_HASH_ENTRIES - 1);
-                       __set_bit_le(bit, mc_hash);
-               }
-
-               /* Broadcast packets go through the multicast hash filter.
-                * ether_crc_le() of the broadcast address is 0xbe2612ff
-                * so we always add bit 0xff to the mask.
-                */
-               __set_bit_le(0xff, mc_hash);
-       }
 
        if (efx->port_enabled)
                queue_work(efx->workqueue, &efx->mac_work);
@@ -2185,22 +2138,11 @@ fail_locked:
 
 static void efx_unregister_netdev(struct efx_nic *efx)
 {
-       struct efx_channel *channel;
-       struct efx_tx_queue *tx_queue;
-
        if (!efx->net_dev)
                return;
 
        BUG_ON(netdev_priv(efx->net_dev) != efx);
 
-       /* Free up any skbs still remaining. This has to happen before
-        * we try to unregister the netdev as running their destructors
-        * may be needed to get the device ref. count to 0. */
-       efx_for_each_channel(channel, efx) {
-               efx_for_each_channel_tx_queue(tx_queue, channel)
-                       efx_release_tx_buffers(tx_queue);
-       }
-
        strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
        device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
 
@@ -2223,7 +2165,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method)
        EFX_ASSERT_RESET_SERIALISED(efx);
 
        efx_stop_all(efx);
-       efx_stop_interrupts(efx, false);
+       efx_disable_interrupts(efx);
 
        mutex_lock(&efx->mac_lock);
        if (efx->port_initialized && method != RESET_TYPE_INVISIBLE)
@@ -2260,9 +2202,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
                                  "could not restore PHY settings\n");
        }
 
-       efx->type->reconfigure_mac(efx);
-
-       efx_start_interrupts(efx, false);
+       efx_enable_interrupts(efx);
        efx_restore_filters(efx);
        efx_sriov_reset(efx);
 
@@ -2516,6 +2456,9 @@ static int efx_init_struct(struct efx_nic *efx,
        strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name));
 
        efx->net_dev = net_dev;
+       efx->rx_prefix_size = efx->type->rx_prefix_size;
+       efx->rx_packet_hash_offset =
+               efx->type->rx_hash_offset - efx->type->rx_prefix_size;
        spin_lock_init(&efx->stats_lock);
        mutex_init(&efx->mac_lock);
        efx->phy_op = &efx_dummy_phy_operations;
@@ -2527,10 +2470,10 @@ static int efx_init_struct(struct efx_nic *efx,
                efx->channel[i] = efx_alloc_channel(efx, i, NULL);
                if (!efx->channel[i])
                        goto fail;
+               efx->msi_context[i].efx = efx;
+               efx->msi_context[i].index = i;
        }
 
-       EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS);
-
        /* Higher numbered interrupt modes are less capable! */
        efx->interrupt_mode = max(efx->type->max_interrupt_mode,
                                  interrupt_mode);
@@ -2579,7 +2522,7 @@ static void efx_pci_remove_main(struct efx_nic *efx)
        BUG_ON(efx->state == STATE_READY);
        cancel_work_sync(&efx->reset_work);
 
-       efx_stop_interrupts(efx, false);
+       efx_disable_interrupts(efx);
        efx_nic_fini_interrupt(efx);
        efx_fini_port(efx);
        efx->type->fini(efx);
@@ -2601,7 +2544,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
        /* Mark the NIC as fini, then stop the interface */
        rtnl_lock();
        dev_close(efx->net_dev);
-       efx_stop_interrupts(efx, false);
+       efx_disable_interrupts(efx);
        rtnl_unlock();
 
        efx_sriov_fini(efx);
@@ -2703,7 +2646,7 @@ static int efx_pci_probe_main(struct efx_nic *efx)
        rc = efx_nic_init_interrupt(efx);
        if (rc)
                goto fail5;
-       efx_start_interrupts(efx, false);
+       efx_enable_interrupts(efx);
 
        return 0;
 
@@ -2824,7 +2767,7 @@ static int efx_pm_freeze(struct device *dev)
                efx_device_detach_sync(efx);
 
                efx_stop_all(efx);
-               efx_stop_interrupts(efx, false);
+               efx_disable_interrupts(efx);
        }
 
        rtnl_unlock();
@@ -2839,7 +2782,7 @@ static int efx_pm_thaw(struct device *dev)
        rtnl_lock();
 
        if (efx->state != STATE_DISABLED) {
-               efx_start_interrupts(efx, false);
+               efx_enable_interrupts(efx);
 
                mutex_lock(&efx->mac_lock);
                efx->phy_op->reconfigure(efx);
@@ -2942,7 +2885,7 @@ static pci_ers_result_t efx_io_error_detected(struct pci_dev *pdev,
                efx_device_detach_sync(efx);
 
                efx_stop_all(efx);
-               efx_stop_interrupts(efx, false);
+               efx_disable_interrupts(efx);
 
                status = PCI_ERS_RESULT_NEED_RESET;
        } else {
index bdb30bbb0c973f13d05e86491b20f9a1e5470111..3bbc047baea24b69ca45614f29261a01b0e8121d 100644 (file)
@@ -23,7 +23,6 @@ extern void efx_remove_tx_queue(struct efx_tx_queue *tx_queue);
 extern void efx_init_tx_queue(struct efx_tx_queue *tx_queue);
 extern void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue);
 extern void efx_fini_tx_queue(struct efx_tx_queue *tx_queue);
-extern void efx_release_tx_buffers(struct efx_tx_queue *tx_queue);
 extern netdev_tx_t
 efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev);
 extern netdev_tx_t
@@ -69,27 +68,92 @@ extern void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue);
 #define EFX_TXQ_MIN_ENT(efx)   (2 * efx_tx_max_skb_descs(efx))
 
 /* Filters */
-extern int efx_probe_filters(struct efx_nic *efx);
-extern void efx_restore_filters(struct efx_nic *efx);
-extern void efx_remove_filters(struct efx_nic *efx);
-extern void efx_filter_update_rx_scatter(struct efx_nic *efx);
-extern s32 efx_filter_insert_filter(struct efx_nic *efx,
-                                   struct efx_filter_spec *spec,
-                                   bool replace);
-extern int efx_filter_remove_id_safe(struct efx_nic *efx,
-                                    enum efx_filter_priority priority,
-                                    u32 filter_id);
-extern int efx_filter_get_filter_safe(struct efx_nic *efx,
-                                     enum efx_filter_priority priority,
-                                     u32 filter_id, struct efx_filter_spec *);
-extern void efx_filter_clear_rx(struct efx_nic *efx,
-                               enum efx_filter_priority priority);
-extern u32 efx_filter_count_rx_used(struct efx_nic *efx,
-                                   enum efx_filter_priority priority);
-extern u32 efx_filter_get_rx_id_limit(struct efx_nic *efx);
-extern s32 efx_filter_get_rx_ids(struct efx_nic *efx,
-                                enum efx_filter_priority priority,
-                                u32 *buf, u32 size);
+
+/**
+ * efx_filter_insert_filter - add or replace a filter
+ * @efx: NIC in which to insert the filter
+ * @spec: Specification for the filter
+ * @replace_equal: Flag for whether the specified filter may replace an
+ *     existing filter with equal priority
+ *
+ * On success, return the filter ID.
+ * On failure, return a negative error code.
+ *
+ * If an existing filter has equal match values to the new filter
+ * spec, then the new filter might replace it, depending on the
+ * relative priorities.  If the existing filter has lower priority, or
+ * if @replace_equal is set and it has equal priority, then it is
+ * replaced.  Otherwise the function fails, returning -%EPERM if
+ * the existing filter has higher priority or -%EEXIST if it has
+ * equal priority.
+ */
+static inline s32 efx_filter_insert_filter(struct efx_nic *efx,
+                                          struct efx_filter_spec *spec,
+                                          bool replace_equal)
+{
+       return efx->type->filter_insert(efx, spec, replace_equal);
+}
+
+/**
+ * efx_filter_remove_id_safe - remove a filter by ID, carefully
+ * @efx: NIC from which to remove the filter
+ * @priority: Priority of filter, as passed to @efx_filter_insert_filter
+ * @filter_id: ID of filter, as returned by @efx_filter_insert_filter
+ *
+ * This function will range-check @filter_id, so it is safe to call
+ * with a value passed from userland.
+ */
+static inline int efx_filter_remove_id_safe(struct efx_nic *efx,
+                                           enum efx_filter_priority priority,
+                                           u32 filter_id)
+{
+       return efx->type->filter_remove_safe(efx, priority, filter_id);
+}
+
+/**
+ * efx_filter_get_filter_safe - retrieve a filter by ID, carefully
+ * @efx: NIC from which to remove the filter
+ * @priority: Priority of filter, as passed to @efx_filter_insert_filter
+ * @filter_id: ID of filter, as returned by @efx_filter_insert_filter
+ * @spec: Buffer in which to store filter specification
+ *
+ * This function will range-check @filter_id, so it is safe to call
+ * with a value passed from userland.
+ */
+static inline int
+efx_filter_get_filter_safe(struct efx_nic *efx,
+                          enum efx_filter_priority priority,
+                          u32 filter_id, struct efx_filter_spec *spec)
+{
+       return efx->type->filter_get_safe(efx, priority, filter_id, spec);
+}
+
+/**
+ * efx_farch_filter_clear_rx - remove RX filters by priority
+ * @efx: NIC from which to remove the filters
+ * @priority: Maximum priority to remove
+ */
+static inline void efx_filter_clear_rx(struct efx_nic *efx,
+                                      enum efx_filter_priority priority)
+{
+       return efx->type->filter_clear_rx(efx, priority);
+}
+
+static inline u32 efx_filter_count_rx_used(struct efx_nic *efx,
+                                          enum efx_filter_priority priority)
+{
+       return efx->type->filter_count_rx_used(efx, priority);
+}
+static inline u32 efx_filter_get_rx_id_limit(struct efx_nic *efx)
+{
+       return efx->type->filter_get_rx_id_limit(efx);
+}
+static inline s32 efx_filter_get_rx_ids(struct efx_nic *efx,
+                                       enum efx_filter_priority priority,
+                                       u32 *buf, u32 size)
+{
+       return efx->type->filter_get_rx_ids(efx, priority, buf, size);
+}
 #ifdef CONFIG_RFS_ACCEL
 extern int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
                          u16 rxq_index, u32 flow_id);
@@ -109,7 +173,6 @@ static inline void efx_filter_rfs_expire(struct efx_channel *channel) {}
 /* Channels */
 extern int efx_channel_dummy_op_int(struct efx_channel *channel);
 extern void efx_channel_dummy_op_void(struct efx_channel *channel);
-extern void efx_process_channel_now(struct efx_channel *channel);
 extern int
 efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries);
 
@@ -141,7 +204,12 @@ extern void efx_port_dummy_op_void(struct efx_nic *efx);
 
 /* MTD */
 #ifdef CONFIG_SFC_MTD
-extern int efx_mtd_probe(struct efx_nic *efx);
+extern int efx_mtd_add(struct efx_nic *efx, struct efx_mtd_partition *parts,
+                      size_t n_parts, size_t sizeof_part);
+static inline int efx_mtd_probe(struct efx_nic *efx)
+{
+       return efx->type->mtd_probe(efx);
+}
 extern void efx_mtd_rename(struct efx_nic *efx);
 extern void efx_mtd_remove(struct efx_nic *efx);
 #else
@@ -155,7 +223,6 @@ static inline void efx_schedule_channel(struct efx_channel *channel)
        netif_vdbg(channel->efx, intr, channel->efx->net_dev,
                   "channel %d scheduling NAPI poll on CPU%d\n",
                   channel->channel, raw_smp_processor_id());
-       channel->work_pending = true;
 
        napi_schedule(&channel->napi_str);
 }
index ab8fb5889e55829df9bedbb39cbcc0104bd48242..8665921d7170bf147524f7e79289d8da45c36613 100644 (file)
@@ -147,8 +147,7 @@ enum efx_loopback_mode {
  * @RESET_TYPE_TX_WATCHDOG: reset due to TX watchdog
  * @RESET_TYPE_INT_ERROR: reset due to internal error
  * @RESET_TYPE_RX_RECOVERY: reset to recover from RX datapath errors
- * @RESET_TYPE_RX_DESC_FETCH: pcie error during rx descriptor fetch
- * @RESET_TYPE_TX_DESC_FETCH: pcie error during tx descriptor fetch
+ * @RESET_TYPE_DMA_ERROR: DMA error
  * @RESET_TYPE_TX_SKIP: hardware completed empty tx descriptors
  * @RESET_TYPE_MC_FAILURE: MC reboot/assertion
  */
@@ -163,8 +162,7 @@ enum reset_type {
        RESET_TYPE_TX_WATCHDOG,
        RESET_TYPE_INT_ERROR,
        RESET_TYPE_RX_RECOVERY,
-       RESET_TYPE_RX_DESC_FETCH,
-       RESET_TYPE_TX_DESC_FETCH,
+       RESET_TYPE_DMA_ERROR,
        RESET_TYPE_TX_SKIP,
        RESET_TYPE_MC_FAILURE,
        RESET_TYPE_MAX,
index 1fc21458413d50ade70be1ff1ee9481aca7cf987..63546930f954367af2fb6563f45de618f1cbae90 100644 (file)
 #include "filter.h"
 #include "nic.h"
 
-struct ethtool_string {
-       char name[ETH_GSTRING_LEN];
-};
-
-struct efx_ethtool_stat {
+struct efx_sw_stat_desc {
        const char *name;
        enum {
-               EFX_ETHTOOL_STAT_SOURCE_mac_stats,
                EFX_ETHTOOL_STAT_SOURCE_nic,
                EFX_ETHTOOL_STAT_SOURCE_channel,
                EFX_ETHTOOL_STAT_SOURCE_tx_queue
@@ -35,7 +30,7 @@ struct efx_ethtool_stat {
        u64(*get_stat) (void *field); /* Reader function */
 };
 
-/* Initialiser for a struct #efx_ethtool_stat with type-checking */
+/* Initialiser for a struct efx_sw_stat_desc with type-checking */
 #define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
                                get_stat_function) {                    \
        .name = #stat_name,                                             \
@@ -52,24 +47,11 @@ static u64 efx_get_uint_stat(void *field)
        return *(unsigned int *)field;
 }
 
-static u64 efx_get_u64_stat(void *field)
-{
-       return *(u64 *) field;
-}
-
 static u64 efx_get_atomic_stat(void *field)
 {
        return atomic_read((atomic_t *) field);
 }
 
-#define EFX_ETHTOOL_U64_MAC_STAT(field)                                \
-       EFX_ETHTOOL_STAT(field, mac_stats, field,               \
-                         u64, efx_get_u64_stat)
-
-#define EFX_ETHTOOL_UINT_NIC_STAT(name)                                \
-       EFX_ETHTOOL_STAT(name, nic, n_##name,                   \
-                        unsigned int, efx_get_uint_stat)
-
 #define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field)               \
        EFX_ETHTOOL_STAT(field, nic, field,                     \
                         atomic_t, efx_get_atomic_stat)
@@ -82,72 +64,12 @@ static u64 efx_get_atomic_stat(void *field)
        EFX_ETHTOOL_STAT(tx_##field, tx_queue, field,           \
                         unsigned int, efx_get_uint_stat)
 
-static const struct efx_ethtool_stat efx_ethtool_stats[] = {
-       EFX_ETHTOOL_U64_MAC_STAT(tx_bytes),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_packets),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_bad),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_pause),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_control),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_unicast),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_multicast),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_broadcast),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_lt64),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_64),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_65_to_127),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_128_to_255),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_256_to_511),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_512_to_1023),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_1024_to_15xx),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_15xx_to_jumbo),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_gtjumbo),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_collision),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_single_collision),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_multiple_collision),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_excessive_collision),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_deferred),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_late_collision),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_excessive_deferred),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_non_tcpudp),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_mac_src_error),
-       EFX_ETHTOOL_U64_MAC_STAT(tx_ip_src_error),
+static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
+       EFX_ETHTOOL_UINT_TXQ_STAT(merge_events),
        EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
        EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
        EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
        EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bytes),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_packets),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_good),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bad),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_pause),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_control),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_unicast),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_multicast),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_broadcast),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_lt64),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_64),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_65_to_127),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_128_to_255),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_256_to_511),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_512_to_1023),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_1024_to_15xx),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_15xx_to_jumbo),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_gtjumbo),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bad_lt64),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bad_64_to_15xx),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bad_15xx_to_jumbo),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_bad_gtjumbo),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_overflow),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_missed),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_false_carrier),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_symbol_error),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_align_error),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_length_error),
-       EFX_ETHTOOL_U64_MAC_STAT(rx_internal_error),
-       EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt),
        EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
        EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
        EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
@@ -157,8 +79,7 @@ static const struct efx_ethtool_stat efx_ethtool_stats[] = {
        EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_nodesc_trunc),
 };
 
-/* Number of ethtool statistics */
-#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
+#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
 
 #define EFX_ETHTOOL_EEPROM_MAGIC 0xEFAB
 
@@ -205,8 +126,6 @@ static int efx_ethtool_get_settings(struct net_device *net_dev,
        efx->phy_op->get_settings(efx, ecmd);
        mutex_unlock(&efx->mac_lock);
 
-       /* GMAC does not support 1000Mbps HD */
-       ecmd->supported &= ~SUPPORTED_1000baseT_Half;
        /* Both MACs support pause frames (bidirectional and respond-only) */
        ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
 
@@ -291,12 +210,11 @@ static void efx_ethtool_set_msglevel(struct net_device *net_dev, u32 msg_enable)
  *
  * Fill in an individual self-test entry.
  */
-static void efx_fill_test(unsigned int test_index,
-                         struct ethtool_string *strings, u64 *data,
+static void efx_fill_test(unsigned int test_index, u8 *strings, u64 *data,
                          int *test, const char *unit_format, int unit_id,
                          const char *test_format, const char *test_id)
 {
-       struct ethtool_string unit_str, test_str;
+       char unit_str[ETH_GSTRING_LEN], test_str[ETH_GSTRING_LEN];
 
        /* Fill data value, if applicable */
        if (data)
@@ -305,15 +223,14 @@ static void efx_fill_test(unsigned int test_index,
        /* Fill string, if applicable */
        if (strings) {
                if (strchr(unit_format, '%'))
-                       snprintf(unit_str.name, sizeof(unit_str.name),
+                       snprintf(unit_str, sizeof(unit_str),
                                 unit_format, unit_id);
                else
-                       strcpy(unit_str.name, unit_format);
-               snprintf(test_str.name, sizeof(test_str.name),
-                        test_format, test_id);
-               snprintf(strings[test_index].name,
-                        sizeof(strings[test_index].name),
-                        "%-6s %-24s", unit_str.name, test_str.name);
+                       strcpy(unit_str, unit_format);
+               snprintf(test_str, sizeof(test_str), test_format, test_id);
+               snprintf(strings + test_index * ETH_GSTRING_LEN,
+                        ETH_GSTRING_LEN,
+                        "%-6s %-24s", unit_str, test_str);
        }
 }
 
@@ -336,7 +253,7 @@ static int efx_fill_loopback_test(struct efx_nic *efx,
                                  struct efx_loopback_self_tests *lb_tests,
                                  enum efx_loopback_mode mode,
                                  unsigned int test_index,
-                                 struct ethtool_string *strings, u64 *data)
+                                 u8 *strings, u64 *data)
 {
        struct efx_channel *channel =
                efx_get_channel(efx, efx->tx_channel_offset);
@@ -373,8 +290,7 @@ static int efx_fill_loopback_test(struct efx_nic *efx,
  */
 static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
                                       struct efx_self_tests *tests,
-                                      struct ethtool_string *strings,
-                                      u64 *data)
+                                      u8 *strings, u64 *data)
 {
        struct efx_channel *channel;
        unsigned int n = 0, i;
@@ -433,12 +349,14 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
 static int efx_ethtool_get_sset_count(struct net_device *net_dev,
                                      int string_set)
 {
+       struct efx_nic *efx = netdev_priv(net_dev);
+
        switch (string_set) {
        case ETH_SS_STATS:
-               return EFX_ETHTOOL_NUM_STATS;
+               return efx->type->describe_stats(efx, NULL) +
+                       EFX_ETHTOOL_SW_STAT_COUNT;
        case ETH_SS_TEST:
-               return efx_ethtool_fill_self_tests(netdev_priv(net_dev),
-                                                  NULL, NULL, NULL);
+               return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
        default:
                return -EINVAL;
        }
@@ -448,20 +366,18 @@ static void efx_ethtool_get_strings(struct net_device *net_dev,
                                    u32 string_set, u8 *strings)
 {
        struct efx_nic *efx = netdev_priv(net_dev);
-       struct ethtool_string *ethtool_strings =
-               (struct ethtool_string *)strings;
        int i;
 
        switch (string_set) {
        case ETH_SS_STATS:
-               for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
-                       strlcpy(ethtool_strings[i].name,
-                               efx_ethtool_stats[i].name,
-                               sizeof(ethtool_strings[i].name));
+               strings += (efx->type->describe_stats(efx, strings) *
+                           ETH_GSTRING_LEN);
+               for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++)
+                       strlcpy(strings + i * ETH_GSTRING_LEN,
+                               efx_sw_stat_desc[i].name, ETH_GSTRING_LEN);
                break;
        case ETH_SS_TEST:
-               efx_ethtool_fill_self_tests(efx, NULL,
-                                           ethtool_strings, NULL);
+               efx_ethtool_fill_self_tests(efx, NULL, strings, NULL);
                break;
        default:
                /* No other string sets */
@@ -474,27 +390,20 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
                                  u64 *data)
 {
        struct efx_nic *efx = netdev_priv(net_dev);
-       struct efx_mac_stats *mac_stats = &efx->mac_stats;
-       const struct efx_ethtool_stat *stat;
+       const struct efx_sw_stat_desc *stat;
        struct efx_channel *channel;
        struct efx_tx_queue *tx_queue;
        int i;
 
-       EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
-
        spin_lock_bh(&efx->stats_lock);
 
-       /* Update MAC and NIC statistics */
-       efx->type->update_stats(efx);
+       /* Get NIC statistics */
+       data += efx->type->update_stats(efx, data, NULL);
 
-       /* Fill detailed statistics buffer */
-       for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
-               stat = &efx_ethtool_stats[i];
+       /* Get software statistics */
+       for (i = 0; i < EFX_ETHTOOL_SW_STAT_COUNT; i++) {
+               stat = &efx_sw_stat_desc[i];
                switch (stat->source) {
-               case EFX_ETHTOOL_STAT_SOURCE_mac_stats:
-                       data[i] = stat->get_stat((void *)mac_stats +
-                                                stat->offset);
-                       break;
                case EFX_ETHTOOL_STAT_SOURCE_nic:
                        data[i] = stat->get_stat((void *)efx + stat->offset);
                        break;
@@ -709,7 +618,6 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
        struct efx_nic *efx = netdev_priv(net_dev);
        u8 wanted_fc, old_fc;
        u32 old_adv;
-       bool reset;
        int rc = 0;
 
        mutex_lock(&efx->mac_lock);
@@ -732,24 +640,10 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
                goto out;
        }
 
-       /* TX flow control may automatically turn itself off if the
-        * link partner (intermittently) stops responding to pause
-        * frames. There isn't any indication that this has happened,
-        * so the best we do is leave it up to the user to spot this
-        * and fix it be cycling transmit flow control on this end. */
-       reset = (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX);
-       if (EFX_WORKAROUND_11482(efx) && reset) {
-               if (efx_nic_rev(efx) == EFX_REV_FALCON_B0) {
-                       /* Recover by resetting the EM block */
-                       falcon_stop_nic_stats(efx);
-                       falcon_drain_tx_fifo(efx);
-                       falcon_reconfigure_xmac(efx);
-                       falcon_start_nic_stats(efx);
-               } else {
-                       /* Schedule a reset to recover */
-                       efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);
-               }
-       }
+       /* Hook for Falcon bug 11482 workaround */
+       if (efx->type->prepare_enable_fc_tx &&
+           (wanted_fc & EFX_FC_TX) && !(efx->wanted_fc & EFX_FC_TX))
+               efx->type->prepare_enable_fc_tx(efx);
 
        old_adv = efx->link_advertising;
        old_fc = efx->wanted_fc;
@@ -814,11 +708,12 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
        return efx_reset(efx, rc);
 }
 
-/* MAC address mask including only MC flag */
-static const u8 mac_addr_mc_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
+/* MAC address mask including only I/G bit */
+static const u8 mac_addr_ig_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
 
 #define IP4_ADDR_FULL_MASK     ((__force __be32)~0)
 #define PORT_FULL_MASK         ((__force __be16)~0)
+#define ETHER_TYPE_FULL_MASK   ((__force __be16)~0)
 
 static int efx_ethtool_get_class_rule(struct efx_nic *efx,
                                      struct ethtool_rx_flow_spec *rule)
@@ -828,8 +723,6 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx,
        struct ethhdr *mac_entry = &rule->h_u.ether_spec;
        struct ethhdr *mac_mask = &rule->m_u.ether_spec;
        struct efx_filter_spec spec;
-       u16 vid;
-       u8 proto;
        int rc;
 
        rc = efx_filter_get_filter_safe(efx, EFX_FILTER_PRI_MANUAL,
@@ -837,44 +730,72 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx,
        if (rc)
                return rc;
 
-       if (spec.dmaq_id == 0xfff)
+       if (spec.dmaq_id == EFX_FILTER_RX_DMAQ_ID_DROP)
                rule->ring_cookie = RX_CLS_FLOW_DISC;
        else
                rule->ring_cookie = spec.dmaq_id;
 
-       if (spec.type == EFX_FILTER_MC_DEF || spec.type == EFX_FILTER_UC_DEF) {
-               rule->flow_type = ETHER_FLOW;
-               memcpy(mac_mask->h_dest, mac_addr_mc_mask, ETH_ALEN);
-               if (spec.type == EFX_FILTER_MC_DEF)
-                       memcpy(mac_entry->h_dest, mac_addr_mc_mask, ETH_ALEN);
-               return 0;
-       }
-
-       rc = efx_filter_get_eth_local(&spec, &vid, mac_entry->h_dest);
-       if (rc == 0) {
+       if ((spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) &&
+           spec.ether_type == htons(ETH_P_IP) &&
+           (spec.match_flags & EFX_FILTER_MATCH_IP_PROTO) &&
+           (spec.ip_proto == IPPROTO_TCP || spec.ip_proto == IPPROTO_UDP) &&
+           !(spec.match_flags &
+             ~(EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_OUTER_VID |
+               EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_REM_HOST |
+               EFX_FILTER_MATCH_IP_PROTO |
+               EFX_FILTER_MATCH_LOC_PORT | EFX_FILTER_MATCH_REM_PORT))) {
+               rule->flow_type = ((spec.ip_proto == IPPROTO_TCP) ?
+                                  TCP_V4_FLOW : UDP_V4_FLOW);
+               if (spec.match_flags & EFX_FILTER_MATCH_LOC_HOST) {
+                       ip_entry->ip4dst = spec.loc_host[0];
+                       ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
+               }
+               if (spec.match_flags & EFX_FILTER_MATCH_REM_HOST) {
+                       ip_entry->ip4src = spec.rem_host[0];
+                       ip_mask->ip4src = IP4_ADDR_FULL_MASK;
+               }
+               if (spec.match_flags & EFX_FILTER_MATCH_LOC_PORT) {
+                       ip_entry->pdst = spec.loc_port;
+                       ip_mask->pdst = PORT_FULL_MASK;
+               }
+               if (spec.match_flags & EFX_FILTER_MATCH_REM_PORT) {
+                       ip_entry->psrc = spec.rem_port;
+                       ip_mask->psrc = PORT_FULL_MASK;
+               }
+       } else if (!(spec.match_flags &
+                    ~(EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG |
+                      EFX_FILTER_MATCH_REM_MAC | EFX_FILTER_MATCH_ETHER_TYPE |
+                      EFX_FILTER_MATCH_OUTER_VID))) {
                rule->flow_type = ETHER_FLOW;
-               memset(mac_mask->h_dest, ~0, ETH_ALEN);
-               if (vid != EFX_FILTER_VID_UNSPEC) {
-                       rule->flow_type |= FLOW_EXT;
-                       rule->h_ext.vlan_tci = htons(vid);
-                       rule->m_ext.vlan_tci = htons(0xfff);
+               if (spec.match_flags &
+                   (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
+                       memcpy(mac_entry->h_dest, spec.loc_mac, ETH_ALEN);
+                       if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
+                               memset(mac_mask->h_dest, ~0, ETH_ALEN);
+                       else
+                               memcpy(mac_mask->h_dest, mac_addr_ig_mask,
+                                      ETH_ALEN);
                }
-               return 0;
+               if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
+                       memcpy(mac_entry->h_source, spec.rem_mac, ETH_ALEN);
+                       memset(mac_mask->h_source, ~0, ETH_ALEN);
+               }
+               if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
+                       mac_entry->h_proto = spec.ether_type;
+                       mac_mask->h_proto = ETHER_TYPE_FULL_MASK;
+               }
+       } else {
+               /* The above should handle all filters that we insert */
+               WARN_ON(1);
+               return -EINVAL;
        }
 
-       rc = efx_filter_get_ipv4_local(&spec, &proto,
-                                      &ip_entry->ip4dst, &ip_entry->pdst);
-       if (rc != 0) {
-               rc = efx_filter_get_ipv4_full(
-                       &spec, &proto, &ip_entry->ip4dst, &ip_entry->pdst,
-                       &ip_entry->ip4src, &ip_entry->psrc);
-               EFX_WARN_ON_PARANOID(rc);
-               ip_mask->ip4src = IP4_ADDR_FULL_MASK;
-               ip_mask->psrc = PORT_FULL_MASK;
+       if (spec.match_flags & EFX_FILTER_MATCH_OUTER_VID) {
+               rule->flow_type |= FLOW_EXT;
+               rule->h_ext.vlan_tci = spec.outer_vid;
+               rule->m_ext.vlan_tci = htons(0xfff);
        }
-       rule->flow_type = (proto == IPPROTO_TCP) ? TCP_V4_FLOW : UDP_V4_FLOW;
-       ip_mask->ip4dst = IP4_ADDR_FULL_MASK;
-       ip_mask->pdst = PORT_FULL_MASK;
+
        return rc;
 }
 
@@ -982,82 +903,80 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
        efx_filter_init_rx(&spec, EFX_FILTER_PRI_MANUAL,
                           efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0,
                           (rule->ring_cookie == RX_CLS_FLOW_DISC) ?
-                          0xfff : rule->ring_cookie);
+                          EFX_FILTER_RX_DMAQ_ID_DROP : rule->ring_cookie);
 
-       switch (rule->flow_type) {
+       switch (rule->flow_type & ~FLOW_EXT) {
        case TCP_V4_FLOW:
-       case UDP_V4_FLOW: {
-               u8 proto = (rule->flow_type == TCP_V4_FLOW ?
-                           IPPROTO_TCP : IPPROTO_UDP);
-
-               /* Must match all of destination, */
-               if (!(ip_mask->ip4dst == IP4_ADDR_FULL_MASK &&
-                     ip_mask->pdst == PORT_FULL_MASK))
-                       return -EINVAL;
-               /* all or none of source, */
-               if ((ip_mask->ip4src || ip_mask->psrc) &&
-                   !(ip_mask->ip4src == IP4_ADDR_FULL_MASK &&
-                     ip_mask->psrc == PORT_FULL_MASK))
-                       return -EINVAL;
-               /* and nothing else */
-               if (ip_mask->tos || rule->m_ext.vlan_tci)
+       case UDP_V4_FLOW:
+               spec.match_flags = (EFX_FILTER_MATCH_ETHER_TYPE |
+                                   EFX_FILTER_MATCH_IP_PROTO);
+               spec.ether_type = htons(ETH_P_IP);
+               spec.ip_proto = ((rule->flow_type & ~FLOW_EXT) == TCP_V4_FLOW ?
+                                IPPROTO_TCP : IPPROTO_UDP);
+               if (ip_mask->ip4dst) {
+                       if (ip_mask->ip4dst != IP4_ADDR_FULL_MASK)
+                               return -EINVAL;
+                       spec.match_flags |= EFX_FILTER_MATCH_LOC_HOST;
+                       spec.loc_host[0] = ip_entry->ip4dst;
+               }
+               if (ip_mask->ip4src) {
+                       if (ip_mask->ip4src != IP4_ADDR_FULL_MASK)
+                               return -EINVAL;
+                       spec.match_flags |= EFX_FILTER_MATCH_REM_HOST;
+                       spec.rem_host[0] = ip_entry->ip4src;
+               }
+               if (ip_mask->pdst) {
+                       if (ip_mask->pdst != PORT_FULL_MASK)
+                               return -EINVAL;
+                       spec.match_flags |= EFX_FILTER_MATCH_LOC_PORT;
+                       spec.loc_port = ip_entry->pdst;
+               }
+               if (ip_mask->psrc) {
+                       if (ip_mask->psrc != PORT_FULL_MASK)
+                               return -EINVAL;
+                       spec.match_flags |= EFX_FILTER_MATCH_REM_PORT;
+                       spec.rem_port = ip_entry->psrc;
+               }
+               if (ip_mask->tos)
                        return -EINVAL;
-
-               if (ip_mask->ip4src)
-                       rc = efx_filter_set_ipv4_full(&spec, proto,
-                                                     ip_entry->ip4dst,
-                                                     ip_entry->pdst,
-                                                     ip_entry->ip4src,
-                                                     ip_entry->psrc);
-               else
-                       rc = efx_filter_set_ipv4_local(&spec, proto,
-                                                      ip_entry->ip4dst,
-                                                      ip_entry->pdst);
-               if (rc)
-                       return rc;
                break;
-       }
-
-       case ETHER_FLOW | FLOW_EXT:
-       case ETHER_FLOW: {
-               u16 vlan_tag_mask = (rule->flow_type & FLOW_EXT ?
-                                    ntohs(rule->m_ext.vlan_tci) : 0);
-
-               /* Must not match on source address or Ethertype */
-               if (!is_zero_ether_addr(mac_mask->h_source) ||
-                   mac_mask->h_proto)
-                       return -EINVAL;
 
-               /* Is it a default UC or MC filter? */
-               if (ether_addr_equal(mac_mask->h_dest, mac_addr_mc_mask) &&
-                   vlan_tag_mask == 0) {
-                       if (is_multicast_ether_addr(mac_entry->h_dest))
-                               rc = efx_filter_set_mc_def(&spec);
+       case ETHER_FLOW:
+               if (!is_zero_ether_addr(mac_mask->h_dest)) {
+                       if (ether_addr_equal(mac_mask->h_dest,
+                                            mac_addr_ig_mask))
+                               spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
+                       else if (is_broadcast_ether_addr(mac_mask->h_dest))
+                               spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
                        else
-                               rc = efx_filter_set_uc_def(&spec);
+                               return -EINVAL;
+                       memcpy(spec.loc_mac, mac_entry->h_dest, ETH_ALEN);
                }
-               /* Otherwise, it must match all of destination and all
-                * or none of VID.
-                */
-               else if (is_broadcast_ether_addr(mac_mask->h_dest) &&
-                        (vlan_tag_mask == 0xfff || vlan_tag_mask == 0)) {
-                       rc = efx_filter_set_eth_local(
-                               &spec,
-                               vlan_tag_mask ?
-                               ntohs(rule->h_ext.vlan_tci) : EFX_FILTER_VID_UNSPEC,
-                               mac_entry->h_dest);
-               } else {
-                       rc = -EINVAL;
+               if (!is_zero_ether_addr(mac_mask->h_source)) {
+                       if (!is_broadcast_ether_addr(mac_mask->h_source))
+                               return -EINVAL;
+                       spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
+                       memcpy(spec.rem_mac, mac_entry->h_source, ETH_ALEN);
+               }
+               if (mac_mask->h_proto) {
+                       if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
+                               return -EINVAL;
+                       spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
+                       spec.ether_type = mac_entry->h_proto;
                }
-               if (rc)
-                       return rc;
                break;
-       }
 
        default:
                return -EINVAL;
        }
 
+       if ((rule->flow_type & FLOW_EXT) && rule->m_ext.vlan_tci) {
+               if (rule->m_ext.vlan_tci != htons(0xfff))
+                       return -EINVAL;
+               spec.match_flags |= EFX_FILTER_MATCH_OUTER_VID;
+               spec.outer_vid = rule->h_ext.vlan_tci;
+       }
+
        rc = efx_filter_insert_filter(efx, &spec, true);
        if (rc < 0)
                return rc;
index 71998e7995d9b3af015653eee2a80f1ec097c3ab..ec77611a52e453cc50d839a3331c6622578ef5c3 100644 (file)
 #include "net_driver.h"
 #include "bitfield.h"
 #include "efx.h"
-#include "spi.h"
 #include "nic.h"
-#include "regs.h"
+#include "farch_regs.h"
 #include "io.h"
 #include "phy.h"
 #include "workarounds.h"
 #include "selftest.h"
+#include "mdio_10g.h"
 
 /* Hardware control for SFC4000 (aka Falcon). */
 
+/**************************************************************************
+ *
+ * NIC stats
+ *
+ **************************************************************************
+ */
+
+#define FALCON_MAC_STATS_SIZE 0x100
+
+#define XgRxOctets_offset 0x0
+#define XgRxOctets_WIDTH 48
+#define XgRxOctetsOK_offset 0x8
+#define XgRxOctetsOK_WIDTH 48
+#define XgRxPkts_offset 0x10
+#define XgRxPkts_WIDTH 32
+#define XgRxPktsOK_offset 0x14
+#define XgRxPktsOK_WIDTH 32
+#define XgRxBroadcastPkts_offset 0x18
+#define XgRxBroadcastPkts_WIDTH 32
+#define XgRxMulticastPkts_offset 0x1C
+#define XgRxMulticastPkts_WIDTH 32
+#define XgRxUnicastPkts_offset 0x20
+#define XgRxUnicastPkts_WIDTH 32
+#define XgRxUndersizePkts_offset 0x24
+#define XgRxUndersizePkts_WIDTH 32
+#define XgRxOversizePkts_offset 0x28
+#define XgRxOversizePkts_WIDTH 32
+#define XgRxJabberPkts_offset 0x2C
+#define XgRxJabberPkts_WIDTH 32
+#define XgRxUndersizeFCSerrorPkts_offset 0x30
+#define XgRxUndersizeFCSerrorPkts_WIDTH 32
+#define XgRxDropEvents_offset 0x34
+#define XgRxDropEvents_WIDTH 32
+#define XgRxFCSerrorPkts_offset 0x38
+#define XgRxFCSerrorPkts_WIDTH 32
+#define XgRxAlignError_offset 0x3C
+#define XgRxAlignError_WIDTH 32
+#define XgRxSymbolError_offset 0x40
+#define XgRxSymbolError_WIDTH 32
+#define XgRxInternalMACError_offset 0x44
+#define XgRxInternalMACError_WIDTH 32
+#define XgRxControlPkts_offset 0x48
+#define XgRxControlPkts_WIDTH 32
+#define XgRxPausePkts_offset 0x4C
+#define XgRxPausePkts_WIDTH 32
+#define XgRxPkts64Octets_offset 0x50
+#define XgRxPkts64Octets_WIDTH 32
+#define XgRxPkts65to127Octets_offset 0x54
+#define XgRxPkts65to127Octets_WIDTH 32
+#define XgRxPkts128to255Octets_offset 0x58
+#define XgRxPkts128to255Octets_WIDTH 32
+#define XgRxPkts256to511Octets_offset 0x5C
+#define XgRxPkts256to511Octets_WIDTH 32
+#define XgRxPkts512to1023Octets_offset 0x60
+#define XgRxPkts512to1023Octets_WIDTH 32
+#define XgRxPkts1024to15xxOctets_offset 0x64
+#define XgRxPkts1024to15xxOctets_WIDTH 32
+#define XgRxPkts15xxtoMaxOctets_offset 0x68
+#define XgRxPkts15xxtoMaxOctets_WIDTH 32
+#define XgRxLengthError_offset 0x6C
+#define XgRxLengthError_WIDTH 32
+#define XgTxPkts_offset 0x80
+#define XgTxPkts_WIDTH 32
+#define XgTxOctets_offset 0x88
+#define XgTxOctets_WIDTH 48
+#define XgTxMulticastPkts_offset 0x90
+#define XgTxMulticastPkts_WIDTH 32
+#define XgTxBroadcastPkts_offset 0x94
+#define XgTxBroadcastPkts_WIDTH 32
+#define XgTxUnicastPkts_offset 0x98
+#define XgTxUnicastPkts_WIDTH 32
+#define XgTxControlPkts_offset 0x9C
+#define XgTxControlPkts_WIDTH 32
+#define XgTxPausePkts_offset 0xA0
+#define XgTxPausePkts_WIDTH 32
+#define XgTxPkts64Octets_offset 0xA4
+#define XgTxPkts64Octets_WIDTH 32
+#define XgTxPkts65to127Octets_offset 0xA8
+#define XgTxPkts65to127Octets_WIDTH 32
+#define XgTxPkts128to255Octets_offset 0xAC
+#define XgTxPkts128to255Octets_WIDTH 32
+#define XgTxPkts256to511Octets_offset 0xB0
+#define XgTxPkts256to511Octets_WIDTH 32
+#define XgTxPkts512to1023Octets_offset 0xB4
+#define XgTxPkts512to1023Octets_WIDTH 32
+#define XgTxPkts1024to15xxOctets_offset 0xB8
+#define XgTxPkts1024to15xxOctets_WIDTH 32
+#define XgTxPkts1519toMaxOctets_offset 0xBC
+#define XgTxPkts1519toMaxOctets_WIDTH 32
+#define XgTxUndersizePkts_offset 0xC0
+#define XgTxUndersizePkts_WIDTH 32
+#define XgTxOversizePkts_offset 0xC4
+#define XgTxOversizePkts_WIDTH 32
+#define XgTxNonTcpUdpPkt_offset 0xC8
+#define XgTxNonTcpUdpPkt_WIDTH 16
+#define XgTxMacSrcErrPkt_offset 0xCC
+#define XgTxMacSrcErrPkt_WIDTH 16
+#define XgTxIpSrcErrPkt_offset 0xD0
+#define XgTxIpSrcErrPkt_WIDTH 16
+#define XgDmaDone_offset 0xD4
+#define XgDmaDone_WIDTH 32
+
+#define FALCON_XMAC_STATS_DMA_FLAG(efx)                                \
+       (*(u32 *)((efx)->stats_buffer.addr + XgDmaDone_offset))
+
+#define FALCON_DMA_STAT(ext_name, hw_name)                             \
+       [FALCON_STAT_ ## ext_name] =                                    \
+       { #ext_name,                                                    \
+         /* 48-bit stats are zero-padded to 64 on DMA */               \
+         hw_name ## _ ## WIDTH == 48 ? 64 : hw_name ## _ ## WIDTH,     \
+         hw_name ## _ ## offset }
+#define FALCON_OTHER_STAT(ext_name)                                    \
+       [FALCON_STAT_ ## ext_name] = { #ext_name, 0, 0 }
+
+static const struct efx_hw_stat_desc falcon_stat_desc[FALCON_STAT_COUNT] = {
+       FALCON_DMA_STAT(tx_bytes, XgTxOctets),
+       FALCON_DMA_STAT(tx_packets, XgTxPkts),
+       FALCON_DMA_STAT(tx_pause, XgTxPausePkts),
+       FALCON_DMA_STAT(tx_control, XgTxControlPkts),
+       FALCON_DMA_STAT(tx_unicast, XgTxUnicastPkts),
+       FALCON_DMA_STAT(tx_multicast, XgTxMulticastPkts),
+       FALCON_DMA_STAT(tx_broadcast, XgTxBroadcastPkts),
+       FALCON_DMA_STAT(tx_lt64, XgTxUndersizePkts),
+       FALCON_DMA_STAT(tx_64, XgTxPkts64Octets),
+       FALCON_DMA_STAT(tx_65_to_127, XgTxPkts65to127Octets),
+       FALCON_DMA_STAT(tx_128_to_255, XgTxPkts128to255Octets),
+       FALCON_DMA_STAT(tx_256_to_511, XgTxPkts256to511Octets),
+       FALCON_DMA_STAT(tx_512_to_1023, XgTxPkts512to1023Octets),
+       FALCON_DMA_STAT(tx_1024_to_15xx, XgTxPkts1024to15xxOctets),
+       FALCON_DMA_STAT(tx_15xx_to_jumbo, XgTxPkts1519toMaxOctets),
+       FALCON_DMA_STAT(tx_gtjumbo, XgTxOversizePkts),
+       FALCON_DMA_STAT(tx_non_tcpudp, XgTxNonTcpUdpPkt),
+       FALCON_DMA_STAT(tx_mac_src_error, XgTxMacSrcErrPkt),
+       FALCON_DMA_STAT(tx_ip_src_error, XgTxIpSrcErrPkt),
+       FALCON_DMA_STAT(rx_bytes, XgRxOctets),
+       FALCON_DMA_STAT(rx_good_bytes, XgRxOctetsOK),
+       FALCON_OTHER_STAT(rx_bad_bytes),
+       FALCON_DMA_STAT(rx_packets, XgRxPkts),
+       FALCON_DMA_STAT(rx_good, XgRxPktsOK),
+       FALCON_DMA_STAT(rx_bad, XgRxFCSerrorPkts),
+       FALCON_DMA_STAT(rx_pause, XgRxPausePkts),
+       FALCON_DMA_STAT(rx_control, XgRxControlPkts),
+       FALCON_DMA_STAT(rx_unicast, XgRxUnicastPkts),
+       FALCON_DMA_STAT(rx_multicast, XgRxMulticastPkts),
+       FALCON_DMA_STAT(rx_broadcast, XgRxBroadcastPkts),
+       FALCON_DMA_STAT(rx_lt64, XgRxUndersizePkts),
+       FALCON_DMA_STAT(rx_64, XgRxPkts64Octets),
+       FALCON_DMA_STAT(rx_65_to_127, XgRxPkts65to127Octets),
+       FALCON_DMA_STAT(rx_128_to_255, XgRxPkts128to255Octets),
+       FALCON_DMA_STAT(rx_256_to_511, XgRxPkts256to511Octets),
+       FALCON_DMA_STAT(rx_512_to_1023, XgRxPkts512to1023Octets),
+       FALCON_DMA_STAT(rx_1024_to_15xx, XgRxPkts1024to15xxOctets),
+       FALCON_DMA_STAT(rx_15xx_to_jumbo, XgRxPkts15xxtoMaxOctets),
+       FALCON_DMA_STAT(rx_gtjumbo, XgRxOversizePkts),
+       FALCON_DMA_STAT(rx_bad_lt64, XgRxUndersizeFCSerrorPkts),
+       FALCON_DMA_STAT(rx_bad_gtjumbo, XgRxJabberPkts),
+       FALCON_DMA_STAT(rx_overflow, XgRxDropEvents),
+       FALCON_DMA_STAT(rx_symbol_error, XgRxSymbolError),
+       FALCON_DMA_STAT(rx_align_error, XgRxAlignError),
+       FALCON_DMA_STAT(rx_length_error, XgRxLengthError),
+       FALCON_DMA_STAT(rx_internal_error, XgRxInternalMACError),
+       FALCON_OTHER_STAT(rx_nodesc_drop_cnt),
+};
+static const unsigned long falcon_stat_mask[] = {
+       [0 ... BITS_TO_LONGS(FALCON_STAT_COUNT) - 1] = ~0UL,
+};
+
+/**************************************************************************
+ *
+ * Basic SPI command set and bit definitions
+ *
+ *************************************************************************/
+
+#define SPI_WRSR 0x01          /* Write status register */
+#define SPI_WRITE 0x02         /* Write data to memory array */
+#define SPI_READ 0x03          /* Read data from memory array */
+#define SPI_WRDI 0x04          /* Reset write enable latch */
+#define SPI_RDSR 0x05          /* Read status register */
+#define SPI_WREN 0x06          /* Set write enable latch */
+#define SPI_SST_EWSR 0x50      /* SST: Enable write to status register */
+
+#define SPI_STATUS_WPEN 0x80   /* Write-protect pin enabled */
+#define SPI_STATUS_BP2 0x10    /* Block protection bit 2 */
+#define SPI_STATUS_BP1 0x08    /* Block protection bit 1 */
+#define SPI_STATUS_BP0 0x04    /* Block protection bit 0 */
+#define SPI_STATUS_WEN 0x02    /* State of the write enable latch */
+#define SPI_STATUS_NRDY 0x01   /* Device busy flag */
+
+/**************************************************************************
+ *
+ * Non-volatile memory layout
+ *
+ **************************************************************************
+ */
+
+/* SFC4000 flash is partitioned into:
+ *     0-0x400       chip and board config (see struct falcon_nvconfig)
+ *     0x400-0x8000  unused (or may contain VPD if EEPROM not present)
+ *     0x8000-end    boot code (mapped to PCI expansion ROM)
+ * SFC4000 small EEPROM (size < 0x400) is used for VPD only.
+ * SFC4000 large EEPROM (size >= 0x400) is partitioned into:
+ *     0-0x400       chip and board config
+ *     configurable  VPD
+ *     0x800-0x1800  boot config
+ * Aside from the chip and board config, all of these are optional and may
+ * be absent or truncated depending on the devices used.
+ */
+#define FALCON_NVCONFIG_END 0x400U
+#define FALCON_FLASH_BOOTCODE_START 0x8000U
+#define FALCON_EEPROM_BOOTCONFIG_START 0x800U
+#define FALCON_EEPROM_BOOTCONFIG_END 0x1800U
+
+/* Board configuration v2 (v1 is obsolete; later versions are compatible) */
+struct falcon_nvconfig_board_v2 {
+       __le16 nports;
+       u8 port0_phy_addr;
+       u8 port0_phy_type;
+       u8 port1_phy_addr;
+       u8 port1_phy_type;
+       __le16 asic_sub_revision;
+       __le16 board_revision;
+} __packed;
+
+/* Board configuration v3 extra information */
+struct falcon_nvconfig_board_v3 {
+       __le32 spi_device_type[2];
+} __packed;
+
+/* Bit numbers for spi_device_type */
+#define SPI_DEV_TYPE_SIZE_LBN 0
+#define SPI_DEV_TYPE_SIZE_WIDTH 5
+#define SPI_DEV_TYPE_ADDR_LEN_LBN 6
+#define SPI_DEV_TYPE_ADDR_LEN_WIDTH 2
+#define SPI_DEV_TYPE_ERASE_CMD_LBN 8
+#define SPI_DEV_TYPE_ERASE_CMD_WIDTH 8
+#define SPI_DEV_TYPE_ERASE_SIZE_LBN 16
+#define SPI_DEV_TYPE_ERASE_SIZE_WIDTH 5
+#define SPI_DEV_TYPE_BLOCK_SIZE_LBN 24
+#define SPI_DEV_TYPE_BLOCK_SIZE_WIDTH 5
+#define SPI_DEV_TYPE_FIELD(type, field)                                        \
+       (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field)))
+
+#define FALCON_NVCONFIG_OFFSET 0x300
+
+#define FALCON_NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
+struct falcon_nvconfig {
+       efx_oword_t ee_vpd_cfg_reg;                     /* 0x300 */
+       u8 mac_address[2][8];                   /* 0x310 */
+       efx_oword_t pcie_sd_ctl0123_reg;                /* 0x320 */
+       efx_oword_t pcie_sd_ctl45_reg;                  /* 0x330 */
+       efx_oword_t pcie_pcs_ctl_stat_reg;              /* 0x340 */
+       efx_oword_t hw_init_reg;                        /* 0x350 */
+       efx_oword_t nic_stat_reg;                       /* 0x360 */
+       efx_oword_t glb_ctl_reg;                        /* 0x370 */
+       efx_oword_t srm_cfg_reg;                        /* 0x380 */
+       efx_oword_t spare_reg;                          /* 0x390 */
+       __le16 board_magic_num;                 /* 0x3A0 */
+       __le16 board_struct_ver;
+       __le16 board_checksum;
+       struct falcon_nvconfig_board_v2 board_v2;
+       efx_oword_t ee_base_page_reg;                   /* 0x3B0 */
+       struct falcon_nvconfig_board_v3 board_v3;       /* 0x3C0 */
+} __packed;
+
+/*************************************************************************/
+
 static int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
+static void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
 
 static const unsigned int
 /* "Large" EEPROM device: Atmel AT25640 or similar
@@ -146,7 +413,7 @@ static void falcon_prepare_flush(struct efx_nic *efx)
  *
  * NB most hardware supports MSI interrupts
  */
-inline void falcon_irq_ack_a1(struct efx_nic *efx)
+static inline void falcon_irq_ack_a1(struct efx_nic *efx)
 {
        efx_dword_t reg;
 
@@ -156,7 +423,7 @@ inline void falcon_irq_ack_a1(struct efx_nic *efx)
 }
 
 
-irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id)
+static irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id)
 {
        struct efx_nic *efx = dev_id;
        efx_oword_t *int_ker = efx->irq_status.addr;
@@ -177,10 +444,13 @@ irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id)
                   "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
                   irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
 
+       if (!likely(ACCESS_ONCE(efx->irq_soft_enabled)))
+               return IRQ_HANDLED;
+
        /* Check to see if we have a serious error condition */
        syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
        if (unlikely(syserr))
-               return efx_nic_fatal_interrupt(efx);
+               return efx_farch_fatal_interrupt(efx);
 
        /* Determine interrupting queues, clear interrupt status
         * register and acknowledge the device interrupt.
@@ -241,9 +511,10 @@ static int falcon_spi_wait(struct efx_nic *efx)
        }
 }
 
-int falcon_spi_cmd(struct efx_nic *efx, const struct efx_spi_device *spi,
-                  unsigned int command, int address,
-                  const void *in, void *out, size_t len)
+static int
+falcon_spi_cmd(struct efx_nic *efx, const struct falcon_spi_device *spi,
+              unsigned int command, int address,
+              const void *in, void *out, size_t len)
 {
        bool addressed = (address >= 0);
        bool reading = (out != NULL);
@@ -297,48 +568,16 @@ int falcon_spi_cmd(struct efx_nic *efx, const struct efx_spi_device *spi,
        return 0;
 }
 
-static size_t
-falcon_spi_write_limit(const struct efx_spi_device *spi, size_t start)
-{
-       return min(FALCON_SPI_MAX_LEN,
-                  (spi->block_size - (start & (spi->block_size - 1))));
-}
-
 static inline u8
-efx_spi_munge_command(const struct efx_spi_device *spi,
-                     const u8 command, const unsigned int address)
+falcon_spi_munge_command(const struct falcon_spi_device *spi,
+                        const u8 command, const unsigned int address)
 {
        return command | (((address >> 8) & spi->munge_address) << 3);
 }
 
-/* Wait up to 10 ms for buffered write completion */
-int
-falcon_spi_wait_write(struct efx_nic *efx, const struct efx_spi_device *spi)
-{
-       unsigned long timeout = jiffies + 1 + DIV_ROUND_UP(HZ, 100);
-       u8 status;
-       int rc;
-
-       for (;;) {
-               rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
-                                   &status, sizeof(status));
-               if (rc)
-                       return rc;
-               if (!(status & SPI_STATUS_NRDY))
-                       return 0;
-               if (time_after_eq(jiffies, timeout)) {
-                       netif_err(efx, hw, efx->net_dev,
-                                 "SPI write timeout on device %d"
-                                 " last status=0x%02x\n",
-                                 spi->device_id, status);
-                       return -ETIMEDOUT;
-               }
-               schedule_timeout_uninterruptible(1);
-       }
-}
-
-int falcon_spi_read(struct efx_nic *efx, const struct efx_spi_device *spi,
-                   loff_t start, size_t len, size_t *retlen, u8 *buffer)
+static int
+falcon_spi_read(struct efx_nic *efx, const struct falcon_spi_device *spi,
+               loff_t start, size_t len, size_t *retlen, u8 *buffer)
 {
        size_t block_len, pos = 0;
        unsigned int command;
@@ -347,7 +586,7 @@ int falcon_spi_read(struct efx_nic *efx, const struct efx_spi_device *spi,
        while (pos < len) {
                block_len = min(len - pos, FALCON_SPI_MAX_LEN);
 
-               command = efx_spi_munge_command(spi, SPI_READ, start + pos);
+               command = falcon_spi_munge_command(spi, SPI_READ, start + pos);
                rc = falcon_spi_cmd(efx, spi, command, start + pos, NULL,
                                    buffer + pos, block_len);
                if (rc)
@@ -367,8 +606,52 @@ int falcon_spi_read(struct efx_nic *efx, const struct efx_spi_device *spi,
        return rc;
 }
 
-int
-falcon_spi_write(struct efx_nic *efx, const struct efx_spi_device *spi,
+#ifdef CONFIG_SFC_MTD
+
+struct falcon_mtd_partition {
+       struct efx_mtd_partition common;
+       const struct falcon_spi_device *spi;
+       size_t offset;
+};
+
+#define to_falcon_mtd_partition(mtd)                           \
+       container_of(mtd, struct falcon_mtd_partition, common.mtd)
+
+static size_t
+falcon_spi_write_limit(const struct falcon_spi_device *spi, size_t start)
+{
+       return min(FALCON_SPI_MAX_LEN,
+                  (spi->block_size - (start & (spi->block_size - 1))));
+}
+
+/* Wait up to 10 ms for buffered write completion */
+static int
+falcon_spi_wait_write(struct efx_nic *efx, const struct falcon_spi_device *spi)
+{
+       unsigned long timeout = jiffies + 1 + DIV_ROUND_UP(HZ, 100);
+       u8 status;
+       int rc;
+
+       for (;;) {
+               rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
+                                   &status, sizeof(status));
+               if (rc)
+                       return rc;
+               if (!(status & SPI_STATUS_NRDY))
+                       return 0;
+               if (time_after_eq(jiffies, timeout)) {
+                       netif_err(efx, hw, efx->net_dev,
+                                 "SPI write timeout on device %d"
+                                 " last status=0x%02x\n",
+                                 spi->device_id, status);
+                       return -ETIMEDOUT;
+               }
+               schedule_timeout_uninterruptible(1);
+       }
+}
+
+static int
+falcon_spi_write(struct efx_nic *efx, const struct falcon_spi_device *spi,
                 loff_t start, size_t len, size_t *retlen, const u8 *buffer)
 {
        u8 verify_buffer[FALCON_SPI_MAX_LEN];
@@ -383,7 +666,7 @@ falcon_spi_write(struct efx_nic *efx, const struct efx_spi_device *spi,
 
                block_len = min(len - pos,
                                falcon_spi_write_limit(spi, start + pos));
-               command = efx_spi_munge_command(spi, SPI_WRITE, start + pos);
+               command = falcon_spi_munge_command(spi, SPI_WRITE, start + pos);
                rc = falcon_spi_cmd(efx, spi, command, start + pos,
                                    buffer + pos, NULL, block_len);
                if (rc)
@@ -393,7 +676,7 @@ falcon_spi_write(struct efx_nic *efx, const struct efx_spi_device *spi,
                if (rc)
                        break;
 
-               command = efx_spi_munge_command(spi, SPI_READ, start + pos);
+               command = falcon_spi_munge_command(spi, SPI_READ, start + pos);
                rc = falcon_spi_cmd(efx, spi, command, start + pos,
                                    NULL, verify_buffer, block_len);
                if (memcmp(verify_buffer, buffer + pos, block_len)) {
@@ -416,6 +699,518 @@ falcon_spi_write(struct efx_nic *efx, const struct efx_spi_device *spi,
        return rc;
 }
 
+static int
+falcon_spi_slow_wait(struct falcon_mtd_partition *part, bool uninterruptible)
+{
+       const struct falcon_spi_device *spi = part->spi;
+       struct efx_nic *efx = part->common.mtd.priv;
+       u8 status;
+       int rc, i;
+
+       /* Wait up to 4s for flash/EEPROM to finish a slow operation. */
+       for (i = 0; i < 40; i++) {
+               __set_current_state(uninterruptible ?
+                                   TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
+               schedule_timeout(HZ / 10);
+               rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
+                                   &status, sizeof(status));
+               if (rc)
+                       return rc;
+               if (!(status & SPI_STATUS_NRDY))
+                       return 0;
+               if (signal_pending(current))
+                       return -EINTR;
+       }
+       pr_err("%s: timed out waiting for %s\n",
+              part->common.name, part->common.dev_type_name);
+       return -ETIMEDOUT;
+}
+
+static int
+falcon_spi_unlock(struct efx_nic *efx, const struct falcon_spi_device *spi)
+{
+       const u8 unlock_mask = (SPI_STATUS_BP2 | SPI_STATUS_BP1 |
+                               SPI_STATUS_BP0);
+       u8 status;
+       int rc;
+
+       rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
+                           &status, sizeof(status));
+       if (rc)
+               return rc;
+
+       if (!(status & unlock_mask))
+               return 0; /* already unlocked */
+
+       rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0);
+       if (rc)
+               return rc;
+       rc = falcon_spi_cmd(efx, spi, SPI_SST_EWSR, -1, NULL, NULL, 0);
+       if (rc)
+               return rc;
+
+       status &= ~unlock_mask;
+       rc = falcon_spi_cmd(efx, spi, SPI_WRSR, -1, &status,
+                           NULL, sizeof(status));
+       if (rc)
+               return rc;
+       rc = falcon_spi_wait_write(efx, spi);
+       if (rc)
+               return rc;
+
+       return 0;
+}
+
+#define FALCON_SPI_VERIFY_BUF_LEN 16
+
+static int
+falcon_spi_erase(struct falcon_mtd_partition *part, loff_t start, size_t len)
+{
+       const struct falcon_spi_device *spi = part->spi;
+       struct efx_nic *efx = part->common.mtd.priv;
+       unsigned pos, block_len;
+       u8 empty[FALCON_SPI_VERIFY_BUF_LEN];
+       u8 buffer[FALCON_SPI_VERIFY_BUF_LEN];
+       int rc;
+
+       if (len != spi->erase_size)
+               return -EINVAL;
+
+       if (spi->erase_command == 0)
+               return -EOPNOTSUPP;
+
+       rc = falcon_spi_unlock(efx, spi);
+       if (rc)
+               return rc;
+       rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0);
+       if (rc)
+               return rc;
+       rc = falcon_spi_cmd(efx, spi, spi->erase_command, start, NULL,
+                           NULL, 0);
+       if (rc)
+               return rc;
+       rc = falcon_spi_slow_wait(part, false);
+
+       /* Verify the entire region has been wiped */
+       memset(empty, 0xff, sizeof(empty));
+       for (pos = 0; pos < len; pos += block_len) {
+               block_len = min(len - pos, sizeof(buffer));
+               rc = falcon_spi_read(efx, spi, start + pos, block_len,
+                                    NULL, buffer);
+               if (rc)
+                       return rc;
+               if (memcmp(empty, buffer, block_len))
+                       return -EIO;
+
+               /* Avoid locking up the system */
+               cond_resched();
+               if (signal_pending(current))
+                       return -EINTR;
+       }
+
+       return rc;
+}
+
+static void falcon_mtd_rename(struct efx_mtd_partition *part)
+{
+       struct efx_nic *efx = part->mtd.priv;
+
+       snprintf(part->name, sizeof(part->name), "%s %s",
+                efx->name, part->type_name);
+}
+
+static int falcon_mtd_read(struct mtd_info *mtd, loff_t start,
+                          size_t len, size_t *retlen, u8 *buffer)
+{
+       struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       int rc;
+
+       rc = mutex_lock_interruptible(&nic_data->spi_lock);
+       if (rc)
+               return rc;
+       rc = falcon_spi_read(efx, part->spi, part->offset + start,
+                            len, retlen, buffer);
+       mutex_unlock(&nic_data->spi_lock);
+       return rc;
+}
+
+static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len)
+{
+       struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       int rc;
+
+       rc = mutex_lock_interruptible(&nic_data->spi_lock);
+       if (rc)
+               return rc;
+       rc = falcon_spi_erase(part, part->offset + start, len);
+       mutex_unlock(&nic_data->spi_lock);
+       return rc;
+}
+
+static int falcon_mtd_write(struct mtd_info *mtd, loff_t start,
+                           size_t len, size_t *retlen, const u8 *buffer)
+{
+       struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       int rc;
+
+       rc = mutex_lock_interruptible(&nic_data->spi_lock);
+       if (rc)
+               return rc;
+       rc = falcon_spi_write(efx, part->spi, part->offset + start,
+                             len, retlen, buffer);
+       mutex_unlock(&nic_data->spi_lock);
+       return rc;
+}
+
+static int falcon_mtd_sync(struct mtd_info *mtd)
+{
+       struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       int rc;
+
+       mutex_lock(&nic_data->spi_lock);
+       rc = falcon_spi_slow_wait(part, true);
+       mutex_unlock(&nic_data->spi_lock);
+       return rc;
+}
+
+static int falcon_mtd_probe(struct efx_nic *efx)
+{
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       struct falcon_mtd_partition *parts;
+       struct falcon_spi_device *spi;
+       size_t n_parts;
+       int rc = -ENODEV;
+
+       ASSERT_RTNL();
+
+       /* Allocate space for maximum number of partitions */
+       parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
+       n_parts = 0;
+
+       spi = &nic_data->spi_flash;
+       if (falcon_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) {
+               parts[n_parts].spi = spi;
+               parts[n_parts].offset = FALCON_FLASH_BOOTCODE_START;
+               parts[n_parts].common.dev_type_name = "flash";
+               parts[n_parts].common.type_name = "sfc_flash_bootrom";
+               parts[n_parts].common.mtd.type = MTD_NORFLASH;
+               parts[n_parts].common.mtd.flags = MTD_CAP_NORFLASH;
+               parts[n_parts].common.mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
+               parts[n_parts].common.mtd.erasesize = spi->erase_size;
+               n_parts++;
+       }
+
+       spi = &nic_data->spi_eeprom;
+       if (falcon_spi_present(spi) && spi->size > FALCON_EEPROM_BOOTCONFIG_START) {
+               parts[n_parts].spi = spi;
+               parts[n_parts].offset = FALCON_EEPROM_BOOTCONFIG_START;
+               parts[n_parts].common.dev_type_name = "EEPROM";
+               parts[n_parts].common.type_name = "sfc_bootconfig";
+               parts[n_parts].common.mtd.type = MTD_RAM;
+               parts[n_parts].common.mtd.flags = MTD_CAP_RAM;
+               parts[n_parts].common.mtd.size =
+                       min(spi->size, FALCON_EEPROM_BOOTCONFIG_END) -
+                       FALCON_EEPROM_BOOTCONFIG_START;
+               parts[n_parts].common.mtd.erasesize = spi->erase_size;
+               n_parts++;
+       }
+
+       rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
+       if (rc)
+               kfree(parts);
+       return rc;
+}
+
+#endif /* CONFIG_SFC_MTD */
+
+/**************************************************************************
+ *
+ * XMAC operations
+ *
+ **************************************************************************
+ */
+
+/* Configure the XAUI driver that is an output from Falcon */
+static void falcon_setup_xaui(struct efx_nic *efx)
+{
+       efx_oword_t sdctl, txdrv;
+
+       /* Move the XAUI into low power, unless there is no PHY, in
+        * which case the XAUI will have to drive a cable. */
+       if (efx->phy_type == PHY_TYPE_NONE)
+               return;
+
+       efx_reado(efx, &sdctl, FR_AB_XX_SD_CTL);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVD, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVD, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVC, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVC, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVB, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVB, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVA, FFE_AB_XX_SD_CTL_DRV_DEF);
+       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVA, FFE_AB_XX_SD_CTL_DRV_DEF);
+       efx_writeo(efx, &sdctl, FR_AB_XX_SD_CTL);
+
+       EFX_POPULATE_OWORD_8(txdrv,
+                            FRF_AB_XX_DEQD, FFE_AB_XX_TXDRV_DEQ_DEF,
+                            FRF_AB_XX_DEQC, FFE_AB_XX_TXDRV_DEQ_DEF,
+                            FRF_AB_XX_DEQB, FFE_AB_XX_TXDRV_DEQ_DEF,
+                            FRF_AB_XX_DEQA, FFE_AB_XX_TXDRV_DEQ_DEF,
+                            FRF_AB_XX_DTXD, FFE_AB_XX_TXDRV_DTX_DEF,
+                            FRF_AB_XX_DTXC, FFE_AB_XX_TXDRV_DTX_DEF,
+                            FRF_AB_XX_DTXB, FFE_AB_XX_TXDRV_DTX_DEF,
+                            FRF_AB_XX_DTXA, FFE_AB_XX_TXDRV_DTX_DEF);
+       efx_writeo(efx, &txdrv, FR_AB_XX_TXDRV_CTL);
+}
+
+int falcon_reset_xaui(struct efx_nic *efx)
+{
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       efx_oword_t reg;
+       int count;
+
+       /* Don't fetch MAC statistics over an XMAC reset */
+       WARN_ON(nic_data->stats_disable_count == 0);
+
+       /* Start reset sequence */
+       EFX_POPULATE_OWORD_1(reg, FRF_AB_XX_RST_XX_EN, 1);
+       efx_writeo(efx, &reg, FR_AB_XX_PWR_RST);
+
+       /* Wait up to 10 ms for completion, then reinitialise */
+       for (count = 0; count < 1000; count++) {
+               efx_reado(efx, &reg, FR_AB_XX_PWR_RST);
+               if (EFX_OWORD_FIELD(reg, FRF_AB_XX_RST_XX_EN) == 0 &&
+                   EFX_OWORD_FIELD(reg, FRF_AB_XX_SD_RST_ACT) == 0) {
+                       falcon_setup_xaui(efx);
+                       return 0;
+               }
+               udelay(10);
+       }
+       netif_err(efx, hw, efx->net_dev,
+                 "timed out waiting for XAUI/XGXS reset\n");
+       return -ETIMEDOUT;
+}
+
+static void falcon_ack_status_intr(struct efx_nic *efx)
+{
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       efx_oword_t reg;
+
+       if ((efx_nic_rev(efx) != EFX_REV_FALCON_B0) || LOOPBACK_INTERNAL(efx))
+               return;
+
+       /* We expect xgmii faults if the wireside link is down */
+       if (!efx->link_state.up)
+               return;
+
+       /* We can only use this interrupt to signal the negative edge of
+        * xaui_align [we have to poll the positive edge]. */
+       if (nic_data->xmac_poll_required)
+               return;
+
+       efx_reado(efx, &reg, FR_AB_XM_MGT_INT_MSK);
+}
+
+static bool falcon_xgxs_link_ok(struct efx_nic *efx)
+{
+       efx_oword_t reg;
+       bool align_done, link_ok = false;
+       int sync_status;
+
+       /* Read link status */
+       efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
+
+       align_done = EFX_OWORD_FIELD(reg, FRF_AB_XX_ALIGN_DONE);
+       sync_status = EFX_OWORD_FIELD(reg, FRF_AB_XX_SYNC_STAT);
+       if (align_done && (sync_status == FFE_AB_XX_STAT_ALL_LANES))
+               link_ok = true;
+
+       /* Clear link status ready for next read */
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_COMMA_DET, FFE_AB_XX_STAT_ALL_LANES);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_CHAR_ERR, FFE_AB_XX_STAT_ALL_LANES);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_DISPERR, FFE_AB_XX_STAT_ALL_LANES);
+       efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT);
+
+       return link_ok;
+}
+
+static bool falcon_xmac_link_ok(struct efx_nic *efx)
+{
+       /*
+        * Check MAC's XGXS link status except when using XGMII loopback
+        * which bypasses the XGXS block.
+        * If possible, check PHY's XGXS link status except when using
+        * MAC loopback.
+        */
+       return (efx->loopback_mode == LOOPBACK_XGMII ||
+               falcon_xgxs_link_ok(efx)) &&
+               (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) ||
+                LOOPBACK_INTERNAL(efx) ||
+                efx_mdio_phyxgxs_lane_sync(efx));
+}
+
+static void falcon_reconfigure_xmac_core(struct efx_nic *efx)
+{
+       unsigned int max_frame_len;
+       efx_oword_t reg;
+       bool rx_fc = !!(efx->link_state.fc & EFX_FC_RX);
+       bool tx_fc = !!(efx->link_state.fc & EFX_FC_TX);
+
+       /* Configure MAC  - cut-thru mode is hard wired on */
+       EFX_POPULATE_OWORD_3(reg,
+                            FRF_AB_XM_RX_JUMBO_MODE, 1,
+                            FRF_AB_XM_TX_STAT_EN, 1,
+                            FRF_AB_XM_RX_STAT_EN, 1);
+       efx_writeo(efx, &reg, FR_AB_XM_GLB_CFG);
+
+       /* Configure TX */
+       EFX_POPULATE_OWORD_6(reg,
+                            FRF_AB_XM_TXEN, 1,
+                            FRF_AB_XM_TX_PRMBL, 1,
+                            FRF_AB_XM_AUTO_PAD, 1,
+                            FRF_AB_XM_TXCRC, 1,
+                            FRF_AB_XM_FCNTL, tx_fc,
+                            FRF_AB_XM_IPG, 0x3);
+       efx_writeo(efx, &reg, FR_AB_XM_TX_CFG);
+
+       /* Configure RX */
+       EFX_POPULATE_OWORD_5(reg,
+                            FRF_AB_XM_RXEN, 1,
+                            FRF_AB_XM_AUTO_DEPAD, 0,
+                            FRF_AB_XM_ACPT_ALL_MCAST, 1,
+                            FRF_AB_XM_ACPT_ALL_UCAST, !efx->unicast_filter,
+                            FRF_AB_XM_PASS_CRC_ERR, 1);
+       efx_writeo(efx, &reg, FR_AB_XM_RX_CFG);
+
+       /* Set frame length */
+       max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu);
+       EFX_POPULATE_OWORD_1(reg, FRF_AB_XM_MAX_RX_FRM_SIZE, max_frame_len);
+       efx_writeo(efx, &reg, FR_AB_XM_RX_PARAM);
+       EFX_POPULATE_OWORD_2(reg,
+                            FRF_AB_XM_MAX_TX_FRM_SIZE, max_frame_len,
+                            FRF_AB_XM_TX_JUMBO_MODE, 1);
+       efx_writeo(efx, &reg, FR_AB_XM_TX_PARAM);
+
+       EFX_POPULATE_OWORD_2(reg,
+                            FRF_AB_XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */
+                            FRF_AB_XM_DIS_FCNTL, !rx_fc);
+       efx_writeo(efx, &reg, FR_AB_XM_FC);
+
+       /* Set MAC address */
+       memcpy(&reg, &efx->net_dev->dev_addr[0], 4);
+       efx_writeo(efx, &reg, FR_AB_XM_ADR_LO);
+       memcpy(&reg, &efx->net_dev->dev_addr[4], 2);
+       efx_writeo(efx, &reg, FR_AB_XM_ADR_HI);
+}
+
+static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
+{
+       efx_oword_t reg;
+       bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS);
+       bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI);
+       bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII);
+       bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback;
+
+       /* XGXS block is flaky and will need to be reset if moving
+        * into our out of XGMII, XGXS or XAUI loopbacks. */
+       efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
+       old_xgxs_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_XGXS_LB_EN);
+       old_xgmii_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_XGMII_LB_EN);
+
+       efx_reado(efx, &reg, FR_AB_XX_SD_CTL);
+       old_xaui_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_LPBKA);
+
+       /* The PHY driver may have turned XAUI off */
+       if ((xgxs_loopback != old_xgxs_loopback) ||
+           (xaui_loopback != old_xaui_loopback) ||
+           (xgmii_loopback != old_xgmii_loopback))
+               falcon_reset_xaui(efx);
+
+       efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_FORCE_SIG,
+                           (xgxs_loopback || xaui_loopback) ?
+                           FFE_AB_XX_FORCE_SIG_ALL_LANES : 0);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_XGXS_LB_EN, xgxs_loopback);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_XGMII_LB_EN, xgmii_loopback);
+       efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT);
+
+       efx_reado(efx, &reg, FR_AB_XX_SD_CTL);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKD, xaui_loopback);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKC, xaui_loopback);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKB, xaui_loopback);
+       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKA, xaui_loopback);
+       efx_writeo(efx, &reg, FR_AB_XX_SD_CTL);
+}
+
+
+/* Try to bring up the Falcon side of the Falcon-Phy XAUI link */
+static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries)
+{
+       bool mac_up = falcon_xmac_link_ok(efx);
+
+       if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS ||
+           efx_phy_mode_disabled(efx->phy_mode))
+               /* XAUI link is expected to be down */
+               return mac_up;
+
+       falcon_stop_nic_stats(efx);
+
+       while (!mac_up && tries) {
+               netif_dbg(efx, hw, efx->net_dev, "bashing xaui\n");
+               falcon_reset_xaui(efx);
+               udelay(200);
+
+               mac_up = falcon_xmac_link_ok(efx);
+               --tries;
+       }
+
+       falcon_start_nic_stats(efx);
+
+       return mac_up;
+}
+
+static bool falcon_xmac_check_fault(struct efx_nic *efx)
+{
+       return !falcon_xmac_link_ok_retry(efx, 5);
+}
+
+static int falcon_reconfigure_xmac(struct efx_nic *efx)
+{
+       struct falcon_nic_data *nic_data = efx->nic_data;
+
+       efx_farch_filter_sync_rx_mode(efx);
+
+       falcon_reconfigure_xgxs_core(efx);
+       falcon_reconfigure_xmac_core(efx);
+
+       falcon_reconfigure_mac_wrapper(efx);
+
+       nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 5);
+       falcon_ack_status_intr(efx);
+
+       return 0;
+}
+
+static void falcon_poll_xmac(struct efx_nic *efx)
+{
+       struct falcon_nic_data *nic_data = efx->nic_data;
+
+       /* We expect xgmii faults if the wireside link is down */
+       if (!efx->link_state.up || !nic_data->xmac_poll_required)
+               return;
+
+       nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
+       falcon_ack_status_intr(efx);
+}
+
 /**************************************************************************
  *
  * MAC wrapper
@@ -497,7 +1292,7 @@ static void falcon_reset_macs(struct efx_nic *efx)
        falcon_setup_xaui(efx);
 }
 
-void falcon_drain_tx_fifo(struct efx_nic *efx)
+static void falcon_drain_tx_fifo(struct efx_nic *efx)
 {
        efx_oword_t reg;
 
@@ -529,7 +1324,7 @@ static void falcon_deconfigure_mac_wrapper(struct efx_nic *efx)
        falcon_drain_tx_fifo(efx);
 }
 
-void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
+static void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
 {
        struct efx_link_state *link_state = &efx->link_state;
        efx_oword_t reg;
@@ -550,7 +1345,7 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
        EFX_POPULATE_OWORD_5(reg,
                             FRF_AB_MAC_XOFF_VAL, 0xffff /* max pause time */,
                             FRF_AB_MAC_BCAD_ACPT, 1,
-                            FRF_AB_MAC_UC_PROM, efx->promiscuous,
+                            FRF_AB_MAC_UC_PROM, !efx->unicast_filter,
                             FRF_AB_MAC_LINK_STATUS, 1, /* always set */
                             FRF_AB_MAC_SPEED, link_speed);
        /* On B0, MAC backpressure can be disabled and packets get
@@ -583,10 +1378,7 @@ static void falcon_stats_request(struct efx_nic *efx)
        WARN_ON(nic_data->stats_pending);
        WARN_ON(nic_data->stats_disable_count);
 
-       if (nic_data->stats_dma_done == NULL)
-               return; /* no mac selected */
-
-       *nic_data->stats_dma_done = FALCON_STATS_NOT_DONE;
+       FALCON_XMAC_STATS_DMA_FLAG(efx) = 0;
        nic_data->stats_pending = true;
        wmb(); /* ensure done flag is clear */
 
@@ -608,9 +1400,11 @@ static void falcon_stats_complete(struct efx_nic *efx)
                return;
 
        nic_data->stats_pending = false;
-       if (*nic_data->stats_dma_done == FALCON_STATS_DONE) {
+       if (FALCON_XMAC_STATS_DMA_FLAG(efx)) {
                rmb(); /* read the done flag before the stats */
-               falcon_update_stats_xmac(efx);
+               efx_nic_update_stats(falcon_stat_desc, FALCON_STAT_COUNT,
+                                    falcon_stat_mask, nic_data->stats,
+                                    efx->stats_buffer.addr, true);
        } else {
                netif_err(efx, hw, efx->net_dev,
                          "timed out waiting for statistics\n");
@@ -678,6 +1472,28 @@ static int falcon_reconfigure_port(struct efx_nic *efx)
        return 0;
 }
 
+/* TX flow control may automatically turn itself off if the link
+ * partner (intermittently) stops responding to pause frames. There
+ * isn't any indication that this has happened, so the best we do is
+ * leave it up to the user to spot this and fix it by cycling transmit
+ * flow control on this end.
+ */
+
+static void falcon_a1_prepare_enable_fc_tx(struct efx_nic *efx)
+{
+       /* Schedule a reset to recover */
+       efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);
+}
+
+static void falcon_b0_prepare_enable_fc_tx(struct efx_nic *efx)
+{
+       /* Recover by resetting the EM block */
+       falcon_stop_nic_stats(efx);
+       falcon_drain_tx_fifo(efx);
+       falcon_reconfigure_xmac(efx);
+       falcon_start_nic_stats(efx);
+}
+
 /**************************************************************************
  *
  * PHY access via GMII
@@ -861,7 +1677,7 @@ static int falcon_probe_port(struct efx_nic *efx)
 
        /* Allocate buffer for stats */
        rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
-                                 FALCON_MAC_STATS_SIZE);
+                                 FALCON_MAC_STATS_SIZE, GFP_KERNEL);
        if (rc)
                return rc;
        netif_dbg(efx, probe, efx->net_dev,
@@ -869,7 +1685,6 @@ static int falcon_probe_port(struct efx_nic *efx)
                  (u64)efx->stats_buffer.dma_addr,
                  efx->stats_buffer.addr,
                  (u64)virt_to_phys(efx->stats_buffer.addr));
-       nic_data->stats_dma_done = efx->stats_buffer.addr + XgDmaDone_offset;
 
        return 0;
 }
@@ -926,15 +1741,15 @@ falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
 {
        struct falcon_nic_data *nic_data = efx->nic_data;
        struct falcon_nvconfig *nvconfig;
-       struct efx_spi_device *spi;
+       struct falcon_spi_device *spi;
        void *region;
        int rc, magic_num, struct_ver;
        __le16 *word, *limit;
        u32 csum;
 
-       if (efx_spi_present(&nic_data->spi_flash))
+       if (falcon_spi_present(&nic_data->spi_flash))
                spi = &nic_data->spi_flash;
-       else if (efx_spi_present(&nic_data->spi_eeprom))
+       else if (falcon_spi_present(&nic_data->spi_eeprom))
                spi = &nic_data->spi_eeprom;
        else
                return -EINVAL;
@@ -949,7 +1764,7 @@ falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out)
        mutex_unlock(&nic_data->spi_lock);
        if (rc) {
                netif_err(efx, hw, efx->net_dev, "Failed to read %s\n",
-                         efx_spi_present(&nic_data->spi_flash) ?
+                         falcon_spi_present(&nic_data->spi_flash) ?
                          "flash" : "EEPROM");
                rc = -EIO;
                goto out;
@@ -998,7 +1813,7 @@ static int falcon_test_nvram(struct efx_nic *efx)
        return falcon_read_nvram(efx, NULL);
 }
 
-static const struct efx_nic_register_test falcon_b0_register_tests[] = {
+static const struct efx_farch_register_test falcon_b0_register_tests[] = {
        { FR_AZ_ADR_REGION,
          EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) },
        { FR_AZ_RX_CFG,
@@ -1058,8 +1873,8 @@ falcon_b0_test_chip(struct efx_nic *efx, struct efx_self_tests *tests)
        efx_reset_down(efx, reset_method);
 
        tests->registers =
-               efx_nic_test_registers(efx, falcon_b0_register_tests,
-                                      ARRAY_SIZE(falcon_b0_register_tests))
+               efx_farch_test_registers(efx, falcon_b0_register_tests,
+                                        ARRAY_SIZE(falcon_b0_register_tests))
                ? -1 : 1;
 
        rc = falcon_reset_hw(efx, reset_method);
@@ -1078,8 +1893,7 @@ static enum reset_type falcon_map_reset_reason(enum reset_type reason)
 {
        switch (reason) {
        case RESET_TYPE_RX_RECOVERY:
-       case RESET_TYPE_RX_DESC_FETCH:
-       case RESET_TYPE_TX_DESC_FETCH:
+       case RESET_TYPE_DMA_ERROR:
        case RESET_TYPE_TX_SKIP:
                /* These can occasionally occur due to hardware bugs.
                 * We try to reset without disrupting the link.
@@ -1294,7 +2108,7 @@ static int falcon_reset_sram(struct efx_nic *efx)
 }
 
 static void falcon_spi_device_init(struct efx_nic *efx,
-                                 struct efx_spi_device *spi_device,
+                                 struct falcon_spi_device *spi_device,
                                  unsigned int device_id, u32 device_type)
 {
        if (device_type != 0) {
@@ -1410,6 +2224,20 @@ static void falcon_probe_spi_devices(struct efx_nic *efx)
                                       large_eeprom_type);
 }
 
+static unsigned int falcon_a1_mem_map_size(struct efx_nic *efx)
+{
+       return 0x20000;
+}
+
+static unsigned int falcon_b0_mem_map_size(struct efx_nic *efx)
+{
+       /* Map everything up to and including the RSS indirection table.
+        * The PCI core takes care of mapping the MSI-X tables.
+        */
+       return FR_BZ_RX_INDIRECTION_TBL +
+               FR_BZ_RX_INDIRECTION_TBL_STEP * FR_BZ_RX_INDIRECTION_TBL_ROWS;
+}
+
 static int falcon_probe_nic(struct efx_nic *efx)
 {
        struct falcon_nic_data *nic_data;
@@ -1424,7 +2252,7 @@ static int falcon_probe_nic(struct efx_nic *efx)
 
        rc = -ENODEV;
 
-       if (efx_nic_fpga_ver(efx) != 0) {
+       if (efx_farch_fpga_ver(efx) != 0) {
                netif_err(efx, probe, efx->net_dev,
                          "Falcon FPGA not supported\n");
                goto fail1;
@@ -1478,7 +2306,8 @@ static int falcon_probe_nic(struct efx_nic *efx)
        }
 
        /* Allocate memory for INT_KER */
-       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t));
+       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t),
+                                 GFP_KERNEL);
        if (rc)
                goto fail4;
        BUG_ON(efx->irq_status.dma_addr & 0x0f);
@@ -1499,6 +2328,8 @@ static int falcon_probe_nic(struct efx_nic *efx)
                goto fail5;
        }
 
+       efx->max_channels = (efx_nic_rev(efx) <= EFX_REV_FALCON_A1 ? 4 :
+                            EFX_MAX_CHANNELS);
        efx->timer_quantum_ns = 4968; /* 621 cycles */
 
        /* Initialise I2C adapter */
@@ -1657,7 +2488,7 @@ static int falcon_init_nic(struct efx_nic *efx)
                efx_writeo(efx, &temp, FR_BZ_DP_CTRL);
        }
 
-       efx_nic_init_common(efx);
+       efx_farch_init_common(efx);
 
        return 0;
 }
@@ -1688,24 +2519,65 @@ static void falcon_remove_nic(struct efx_nic *efx)
        efx->nic_data = NULL;
 }
 
-static void falcon_update_nic_stats(struct efx_nic *efx)
+static size_t falcon_describe_nic_stats(struct efx_nic *efx, u8 *names)
+{
+       return efx_nic_describe_stats(falcon_stat_desc, FALCON_STAT_COUNT,
+                                     falcon_stat_mask, names);
+}
+
+static size_t falcon_update_nic_stats(struct efx_nic *efx, u64 *full_stats,
+                                     struct rtnl_link_stats64 *core_stats)
 {
        struct falcon_nic_data *nic_data = efx->nic_data;
+       u64 *stats = nic_data->stats;
        efx_oword_t cnt;
 
-       if (nic_data->stats_disable_count)
-               return;
+       if (!nic_data->stats_disable_count) {
+               efx_reado(efx, &cnt, FR_AZ_RX_NODESC_DROP);
+               stats[FALCON_STAT_rx_nodesc_drop_cnt] +=
+                       EFX_OWORD_FIELD(cnt, FRF_AB_RX_NODESC_DROP_CNT);
+
+               if (nic_data->stats_pending &&
+                   FALCON_XMAC_STATS_DMA_FLAG(efx)) {
+                       nic_data->stats_pending = false;
+                       rmb(); /* read the done flag before the stats */
+                       efx_nic_update_stats(
+                               falcon_stat_desc, FALCON_STAT_COUNT,
+                               falcon_stat_mask,
+                               stats, efx->stats_buffer.addr, true);
+               }
 
-       efx_reado(efx, &cnt, FR_AZ_RX_NODESC_DROP);
-       efx->n_rx_nodesc_drop_cnt +=
-               EFX_OWORD_FIELD(cnt, FRF_AB_RX_NODESC_DROP_CNT);
+               /* Update derived statistic */
+               efx_update_diff_stat(&stats[FALCON_STAT_rx_bad_bytes],
+                                    stats[FALCON_STAT_rx_bytes] -
+                                    stats[FALCON_STAT_rx_good_bytes] -
+                                    stats[FALCON_STAT_rx_control] * 64);
+       }
 
-       if (nic_data->stats_pending &&
-           *nic_data->stats_dma_done == FALCON_STATS_DONE) {
-               nic_data->stats_pending = false;
-               rmb(); /* read the done flag before the stats */
-               falcon_update_stats_xmac(efx);
+       if (full_stats)
+               memcpy(full_stats, stats, sizeof(u64) * FALCON_STAT_COUNT);
+
+       if (core_stats) {
+               core_stats->rx_packets = stats[FALCON_STAT_rx_packets];
+               core_stats->tx_packets = stats[FALCON_STAT_tx_packets];
+               core_stats->rx_bytes = stats[FALCON_STAT_rx_bytes];
+               core_stats->tx_bytes = stats[FALCON_STAT_tx_bytes];
+               core_stats->rx_dropped = stats[FALCON_STAT_rx_nodesc_drop_cnt];
+               core_stats->multicast = stats[FALCON_STAT_rx_multicast];
+               core_stats->rx_length_errors =
+                       stats[FALCON_STAT_rx_gtjumbo] +
+                       stats[FALCON_STAT_rx_length_error];
+               core_stats->rx_crc_errors = stats[FALCON_STAT_rx_bad];
+               core_stats->rx_frame_errors = stats[FALCON_STAT_rx_align_error];
+               core_stats->rx_fifo_errors = stats[FALCON_STAT_rx_overflow];
+
+               core_stats->rx_errors = (core_stats->rx_length_errors +
+                                        core_stats->rx_crc_errors +
+                                        core_stats->rx_frame_errors +
+                                        stats[FALCON_STAT_rx_symbol_error]);
        }
+
+       return FALCON_STAT_COUNT;
 }
 
 void falcon_start_nic_stats(struct efx_nic *efx)
@@ -1734,7 +2606,7 @@ void falcon_stop_nic_stats(struct efx_nic *efx)
        /* Wait enough time for the most recent transfer to
         * complete. */
        for (i = 0; i < 4 && nic_data->stats_pending; i++) {
-               if (*nic_data->stats_dma_done == FALCON_STATS_DONE)
+               if (FALCON_XMAC_STATS_DMA_FLAG(efx))
                        break;
                msleep(1);
        }
@@ -1778,11 +2650,12 @@ static int falcon_set_wol(struct efx_nic *efx, u32 type)
  */
 
 const struct efx_nic_type falcon_a1_nic_type = {
+       .mem_map_size = falcon_a1_mem_map_size,
        .probe = falcon_probe_nic,
        .remove = falcon_remove_nic,
        .init = falcon_init_nic,
        .dimension_resources = falcon_dimension_resources,
-       .fini = efx_port_dummy_op_void,
+       .fini = falcon_irq_ack_a1,
        .monitor = falcon_monitor,
        .map_reset_reason = falcon_map_reset_reason,
        .map_reset_flags = falcon_map_reset_flags,
@@ -1790,23 +2663,71 @@ const struct efx_nic_type falcon_a1_nic_type = {
        .probe_port = falcon_probe_port,
        .remove_port = falcon_remove_port,
        .handle_global_event = falcon_handle_global_event,
+       .fini_dmaq = efx_farch_fini_dmaq,
        .prepare_flush = falcon_prepare_flush,
        .finish_flush = efx_port_dummy_op_void,
+       .describe_stats = falcon_describe_nic_stats,
        .update_stats = falcon_update_nic_stats,
        .start_stats = falcon_start_nic_stats,
        .stop_stats = falcon_stop_nic_stats,
        .set_id_led = falcon_set_id_led,
        .push_irq_moderation = falcon_push_irq_moderation,
        .reconfigure_port = falcon_reconfigure_port,
+       .prepare_enable_fc_tx = falcon_a1_prepare_enable_fc_tx,
        .reconfigure_mac = falcon_reconfigure_xmac,
        .check_mac_fault = falcon_xmac_check_fault,
        .get_wol = falcon_get_wol,
        .set_wol = falcon_set_wol,
        .resume_wol = efx_port_dummy_op_void,
        .test_nvram = falcon_test_nvram,
+       .irq_enable_master = efx_farch_irq_enable_master,
+       .irq_test_generate = efx_farch_irq_test_generate,
+       .irq_disable_non_ev = efx_farch_irq_disable_master,
+       .irq_handle_msi = efx_farch_msi_interrupt,
+       .irq_handle_legacy = falcon_legacy_interrupt_a1,
+       .tx_probe = efx_farch_tx_probe,
+       .tx_init = efx_farch_tx_init,
+       .tx_remove = efx_farch_tx_remove,
+       .tx_write = efx_farch_tx_write,
+       .rx_push_indir_table = efx_farch_rx_push_indir_table,
+       .rx_probe = efx_farch_rx_probe,
+       .rx_init = efx_farch_rx_init,
+       .rx_remove = efx_farch_rx_remove,
+       .rx_write = efx_farch_rx_write,
+       .rx_defer_refill = efx_farch_rx_defer_refill,
+       .ev_probe = efx_farch_ev_probe,
+       .ev_init = efx_farch_ev_init,
+       .ev_fini = efx_farch_ev_fini,
+       .ev_remove = efx_farch_ev_remove,
+       .ev_process = efx_farch_ev_process,
+       .ev_read_ack = efx_farch_ev_read_ack,
+       .ev_test_generate = efx_farch_ev_test_generate,
+
+       /* We don't expose the filter table on Falcon A1 as it is not
+        * mapped into function 0, but these implementations still
+        * work with a degenerate case of all tables set to size 0.
+        */
+       .filter_table_probe = efx_farch_filter_table_probe,
+       .filter_table_restore = efx_farch_filter_table_restore,
+       .filter_table_remove = efx_farch_filter_table_remove,
+       .filter_insert = efx_farch_filter_insert,
+       .filter_remove_safe = efx_farch_filter_remove_safe,
+       .filter_get_safe = efx_farch_filter_get_safe,
+       .filter_clear_rx = efx_farch_filter_clear_rx,
+       .filter_count_rx_used = efx_farch_filter_count_rx_used,
+       .filter_get_rx_id_limit = efx_farch_filter_get_rx_id_limit,
+       .filter_get_rx_ids = efx_farch_filter_get_rx_ids,
+
+#ifdef CONFIG_SFC_MTD
+       .mtd_probe = falcon_mtd_probe,
+       .mtd_rename = falcon_mtd_rename,
+       .mtd_read = falcon_mtd_read,
+       .mtd_erase = falcon_mtd_erase,
+       .mtd_write = falcon_mtd_write,
+       .mtd_sync = falcon_mtd_sync,
+#endif
 
        .revision = EFX_REV_FALCON_A1,
-       .mem_map_size = 0x20000,
        .txd_ptr_tbl_base = FR_AA_TX_DESC_PTR_TBL_KER,
        .rxd_ptr_tbl_base = FR_AA_RX_DESC_PTR_TBL_KER,
        .buf_tbl_base = FR_AA_BUF_FULL_TBL_KER,
@@ -1816,12 +2737,13 @@ const struct efx_nic_type falcon_a1_nic_type = {
        .rx_buffer_padding = 0x24,
        .can_rx_scatter = false,
        .max_interrupt_mode = EFX_INT_MODE_MSI,
-       .phys_addr_channels = 4,
        .timer_period_max =  1 << FRF_AB_TC_TIMER_VAL_WIDTH,
        .offload_features = NETIF_F_IP_CSUM,
+       .mcdi_max_ver = -1,
 };
 
 const struct efx_nic_type falcon_b0_nic_type = {
+       .mem_map_size = falcon_b0_mem_map_size,
        .probe = falcon_probe_nic,
        .remove = falcon_remove_nic,
        .init = falcon_init_nic,
@@ -1834,14 +2756,17 @@ const struct efx_nic_type falcon_b0_nic_type = {
        .probe_port = falcon_probe_port,
        .remove_port = falcon_remove_port,
        .handle_global_event = falcon_handle_global_event,
+       .fini_dmaq = efx_farch_fini_dmaq,
        .prepare_flush = falcon_prepare_flush,
        .finish_flush = efx_port_dummy_op_void,
+       .describe_stats = falcon_describe_nic_stats,
        .update_stats = falcon_update_nic_stats,
        .start_stats = falcon_start_nic_stats,
        .stop_stats = falcon_stop_nic_stats,
        .set_id_led = falcon_set_id_led,
        .push_irq_moderation = falcon_push_irq_moderation,
        .reconfigure_port = falcon_reconfigure_port,
+       .prepare_enable_fc_tx = falcon_b0_prepare_enable_fc_tx,
        .reconfigure_mac = falcon_reconfigure_xmac,
        .check_mac_fault = falcon_xmac_check_fault,
        .get_wol = falcon_get_wol,
@@ -1849,28 +2774,67 @@ const struct efx_nic_type falcon_b0_nic_type = {
        .resume_wol = efx_port_dummy_op_void,
        .test_chip = falcon_b0_test_chip,
        .test_nvram = falcon_test_nvram,
+       .irq_enable_master = efx_farch_irq_enable_master,
+       .irq_test_generate = efx_farch_irq_test_generate,
+       .irq_disable_non_ev = efx_farch_irq_disable_master,
+       .irq_handle_msi = efx_farch_msi_interrupt,
+       .irq_handle_legacy = efx_farch_legacy_interrupt,
+       .tx_probe = efx_farch_tx_probe,
+       .tx_init = efx_farch_tx_init,
+       .tx_remove = efx_farch_tx_remove,
+       .tx_write = efx_farch_tx_write,
+       .rx_push_indir_table = efx_farch_rx_push_indir_table,
+       .rx_probe = efx_farch_rx_probe,
+       .rx_init = efx_farch_rx_init,
+       .rx_remove = efx_farch_rx_remove,
+       .rx_write = efx_farch_rx_write,
+       .rx_defer_refill = efx_farch_rx_defer_refill,
+       .ev_probe = efx_farch_ev_probe,
+       .ev_init = efx_farch_ev_init,
+       .ev_fini = efx_farch_ev_fini,
+       .ev_remove = efx_farch_ev_remove,
+       .ev_process = efx_farch_ev_process,
+       .ev_read_ack = efx_farch_ev_read_ack,
+       .ev_test_generate = efx_farch_ev_test_generate,
+       .filter_table_probe = efx_farch_filter_table_probe,
+       .filter_table_restore = efx_farch_filter_table_restore,
+       .filter_table_remove = efx_farch_filter_table_remove,
+       .filter_update_rx_scatter = efx_farch_filter_update_rx_scatter,
+       .filter_insert = efx_farch_filter_insert,
+       .filter_remove_safe = efx_farch_filter_remove_safe,
+       .filter_get_safe = efx_farch_filter_get_safe,
+       .filter_clear_rx = efx_farch_filter_clear_rx,
+       .filter_count_rx_used = efx_farch_filter_count_rx_used,
+       .filter_get_rx_id_limit = efx_farch_filter_get_rx_id_limit,
+       .filter_get_rx_ids = efx_farch_filter_get_rx_ids,
+#ifdef CONFIG_RFS_ACCEL
+       .filter_rfs_insert = efx_farch_filter_rfs_insert,
+       .filter_rfs_expire_one = efx_farch_filter_rfs_expire_one,
+#endif
+#ifdef CONFIG_SFC_MTD
+       .mtd_probe = falcon_mtd_probe,
+       .mtd_rename = falcon_mtd_rename,
+       .mtd_read = falcon_mtd_read,
+       .mtd_erase = falcon_mtd_erase,
+       .mtd_write = falcon_mtd_write,
+       .mtd_sync = falcon_mtd_sync,
+#endif
 
        .revision = EFX_REV_FALCON_B0,
-       /* Map everything up to and including the RSS indirection
-        * table.  Don't map MSI-X table, MSI-X PBA since Linux
-        * requires that they not be mapped.  */
-       .mem_map_size = (FR_BZ_RX_INDIRECTION_TBL +
-                        FR_BZ_RX_INDIRECTION_TBL_STEP *
-                        FR_BZ_RX_INDIRECTION_TBL_ROWS),
        .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
        .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL,
        .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
        .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL,
        .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR,
        .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH),
-       .rx_buffer_hash_size = 0x10,
+       .rx_prefix_size = FS_BZ_RX_PREFIX_SIZE,
+       .rx_hash_offset = FS_BZ_RX_PREFIX_HASH_OFST,
        .rx_buffer_padding = 0,
        .can_rx_scatter = true,
        .max_interrupt_mode = EFX_INT_MODE_MSIX,
-       .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy
-                                  * interrupt handler only supports 32
-                                  * channels */
        .timer_period_max =  1 << FRF_AB_TC_TIMER_VAL_WIDTH,
        .offload_features = NETIF_F_IP_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE,
+       .mcdi_max_ver = -1,
+       .max_rx_ip_filters = FR_BZ_RX_FILTER_TBL0_ROWS,
 };
 
diff --git a/drivers/net/ethernet/sfc/falcon_xmac.c b/drivers/net/ethernet/sfc/falcon_xmac.c
deleted file mode 100644 (file)
index 8333865..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2005-2006 Fen Systems Ltd.
- * Copyright 2006-2010 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-#include <linux/delay.h>
-#include "net_driver.h"
-#include "efx.h"
-#include "nic.h"
-#include "regs.h"
-#include "io.h"
-#include "mdio_10g.h"
-#include "workarounds.h"
-
-/**************************************************************************
- *
- * MAC operations
- *
- *************************************************************************/
-
-/* Configure the XAUI driver that is an output from Falcon */
-void falcon_setup_xaui(struct efx_nic *efx)
-{
-       efx_oword_t sdctl, txdrv;
-
-       /* Move the XAUI into low power, unless there is no PHY, in
-        * which case the XAUI will have to drive a cable. */
-       if (efx->phy_type == PHY_TYPE_NONE)
-               return;
-
-       efx_reado(efx, &sdctl, FR_AB_XX_SD_CTL);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVD, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVD, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVC, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVC, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVB, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVB, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_HIDRVA, FFE_AB_XX_SD_CTL_DRV_DEF);
-       EFX_SET_OWORD_FIELD(sdctl, FRF_AB_XX_LODRVA, FFE_AB_XX_SD_CTL_DRV_DEF);
-       efx_writeo(efx, &sdctl, FR_AB_XX_SD_CTL);
-
-       EFX_POPULATE_OWORD_8(txdrv,
-                            FRF_AB_XX_DEQD, FFE_AB_XX_TXDRV_DEQ_DEF,
-                            FRF_AB_XX_DEQC, FFE_AB_XX_TXDRV_DEQ_DEF,
-                            FRF_AB_XX_DEQB, FFE_AB_XX_TXDRV_DEQ_DEF,
-                            FRF_AB_XX_DEQA, FFE_AB_XX_TXDRV_DEQ_DEF,
-                            FRF_AB_XX_DTXD, FFE_AB_XX_TXDRV_DTX_DEF,
-                            FRF_AB_XX_DTXC, FFE_AB_XX_TXDRV_DTX_DEF,
-                            FRF_AB_XX_DTXB, FFE_AB_XX_TXDRV_DTX_DEF,
-                            FRF_AB_XX_DTXA, FFE_AB_XX_TXDRV_DTX_DEF);
-       efx_writeo(efx, &txdrv, FR_AB_XX_TXDRV_CTL);
-}
-
-int falcon_reset_xaui(struct efx_nic *efx)
-{
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       efx_oword_t reg;
-       int count;
-
-       /* Don't fetch MAC statistics over an XMAC reset */
-       WARN_ON(nic_data->stats_disable_count == 0);
-
-       /* Start reset sequence */
-       EFX_POPULATE_OWORD_1(reg, FRF_AB_XX_RST_XX_EN, 1);
-       efx_writeo(efx, &reg, FR_AB_XX_PWR_RST);
-
-       /* Wait up to 10 ms for completion, then reinitialise */
-       for (count = 0; count < 1000; count++) {
-               efx_reado(efx, &reg, FR_AB_XX_PWR_RST);
-               if (EFX_OWORD_FIELD(reg, FRF_AB_XX_RST_XX_EN) == 0 &&
-                   EFX_OWORD_FIELD(reg, FRF_AB_XX_SD_RST_ACT) == 0) {
-                       falcon_setup_xaui(efx);
-                       return 0;
-               }
-               udelay(10);
-       }
-       netif_err(efx, hw, efx->net_dev,
-                 "timed out waiting for XAUI/XGXS reset\n");
-       return -ETIMEDOUT;
-}
-
-static void falcon_ack_status_intr(struct efx_nic *efx)
-{
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       efx_oword_t reg;
-
-       if ((efx_nic_rev(efx) != EFX_REV_FALCON_B0) || LOOPBACK_INTERNAL(efx))
-               return;
-
-       /* We expect xgmii faults if the wireside link is down */
-       if (!EFX_WORKAROUND_5147(efx) || !efx->link_state.up)
-               return;
-
-       /* We can only use this interrupt to signal the negative edge of
-        * xaui_align [we have to poll the positive edge]. */
-       if (nic_data->xmac_poll_required)
-               return;
-
-       efx_reado(efx, &reg, FR_AB_XM_MGT_INT_MSK);
-}
-
-static bool falcon_xgxs_link_ok(struct efx_nic *efx)
-{
-       efx_oword_t reg;
-       bool align_done, link_ok = false;
-       int sync_status;
-
-       /* Read link status */
-       efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
-
-       align_done = EFX_OWORD_FIELD(reg, FRF_AB_XX_ALIGN_DONE);
-       sync_status = EFX_OWORD_FIELD(reg, FRF_AB_XX_SYNC_STAT);
-       if (align_done && (sync_status == FFE_AB_XX_STAT_ALL_LANES))
-               link_ok = true;
-
-       /* Clear link status ready for next read */
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_COMMA_DET, FFE_AB_XX_STAT_ALL_LANES);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_CHAR_ERR, FFE_AB_XX_STAT_ALL_LANES);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_DISPERR, FFE_AB_XX_STAT_ALL_LANES);
-       efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT);
-
-       return link_ok;
-}
-
-static bool falcon_xmac_link_ok(struct efx_nic *efx)
-{
-       /*
-        * Check MAC's XGXS link status except when using XGMII loopback
-        * which bypasses the XGXS block.
-        * If possible, check PHY's XGXS link status except when using
-        * MAC loopback.
-        */
-       return (efx->loopback_mode == LOOPBACK_XGMII ||
-               falcon_xgxs_link_ok(efx)) &&
-               (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) ||
-                LOOPBACK_INTERNAL(efx) ||
-                efx_mdio_phyxgxs_lane_sync(efx));
-}
-
-static void falcon_reconfigure_xmac_core(struct efx_nic *efx)
-{
-       unsigned int max_frame_len;
-       efx_oword_t reg;
-       bool rx_fc = !!(efx->link_state.fc & EFX_FC_RX);
-       bool tx_fc = !!(efx->link_state.fc & EFX_FC_TX);
-
-       /* Configure MAC  - cut-thru mode is hard wired on */
-       EFX_POPULATE_OWORD_3(reg,
-                            FRF_AB_XM_RX_JUMBO_MODE, 1,
-                            FRF_AB_XM_TX_STAT_EN, 1,
-                            FRF_AB_XM_RX_STAT_EN, 1);
-       efx_writeo(efx, &reg, FR_AB_XM_GLB_CFG);
-
-       /* Configure TX */
-       EFX_POPULATE_OWORD_6(reg,
-                            FRF_AB_XM_TXEN, 1,
-                            FRF_AB_XM_TX_PRMBL, 1,
-                            FRF_AB_XM_AUTO_PAD, 1,
-                            FRF_AB_XM_TXCRC, 1,
-                            FRF_AB_XM_FCNTL, tx_fc,
-                            FRF_AB_XM_IPG, 0x3);
-       efx_writeo(efx, &reg, FR_AB_XM_TX_CFG);
-
-       /* Configure RX */
-       EFX_POPULATE_OWORD_5(reg,
-                            FRF_AB_XM_RXEN, 1,
-                            FRF_AB_XM_AUTO_DEPAD, 0,
-                            FRF_AB_XM_ACPT_ALL_MCAST, 1,
-                            FRF_AB_XM_ACPT_ALL_UCAST, efx->promiscuous,
-                            FRF_AB_XM_PASS_CRC_ERR, 1);
-       efx_writeo(efx, &reg, FR_AB_XM_RX_CFG);
-
-       /* Set frame length */
-       max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu);
-       EFX_POPULATE_OWORD_1(reg, FRF_AB_XM_MAX_RX_FRM_SIZE, max_frame_len);
-       efx_writeo(efx, &reg, FR_AB_XM_RX_PARAM);
-       EFX_POPULATE_OWORD_2(reg,
-                            FRF_AB_XM_MAX_TX_FRM_SIZE, max_frame_len,
-                            FRF_AB_XM_TX_JUMBO_MODE, 1);
-       efx_writeo(efx, &reg, FR_AB_XM_TX_PARAM);
-
-       EFX_POPULATE_OWORD_2(reg,
-                            FRF_AB_XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */
-                            FRF_AB_XM_DIS_FCNTL, !rx_fc);
-       efx_writeo(efx, &reg, FR_AB_XM_FC);
-
-       /* Set MAC address */
-       memcpy(&reg, &efx->net_dev->dev_addr[0], 4);
-       efx_writeo(efx, &reg, FR_AB_XM_ADR_LO);
-       memcpy(&reg, &efx->net_dev->dev_addr[4], 2);
-       efx_writeo(efx, &reg, FR_AB_XM_ADR_HI);
-}
-
-static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
-{
-       efx_oword_t reg;
-       bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS);
-       bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI);
-       bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII);
-
-       /* XGXS block is flaky and will need to be reset if moving
-        * into our out of XGMII, XGXS or XAUI loopbacks. */
-       if (EFX_WORKAROUND_5147(efx)) {
-               bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback;
-               bool reset_xgxs;
-
-               efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
-               old_xgxs_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_XGXS_LB_EN);
-               old_xgmii_loopback =
-                       EFX_OWORD_FIELD(reg, FRF_AB_XX_XGMII_LB_EN);
-
-               efx_reado(efx, &reg, FR_AB_XX_SD_CTL);
-               old_xaui_loopback = EFX_OWORD_FIELD(reg, FRF_AB_XX_LPBKA);
-
-               /* The PHY driver may have turned XAUI off */
-               reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) ||
-                             (xaui_loopback != old_xaui_loopback) ||
-                             (xgmii_loopback != old_xgmii_loopback));
-
-               if (reset_xgxs)
-                       falcon_reset_xaui(efx);
-       }
-
-       efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_FORCE_SIG,
-                           (xgxs_loopback || xaui_loopback) ?
-                           FFE_AB_XX_FORCE_SIG_ALL_LANES : 0);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_XGXS_LB_EN, xgxs_loopback);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_XGMII_LB_EN, xgmii_loopback);
-       efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT);
-
-       efx_reado(efx, &reg, FR_AB_XX_SD_CTL);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKD, xaui_loopback);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKC, xaui_loopback);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKB, xaui_loopback);
-       EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_LPBKA, xaui_loopback);
-       efx_writeo(efx, &reg, FR_AB_XX_SD_CTL);
-}
-
-
-/* Try to bring up the Falcon side of the Falcon-Phy XAUI link */
-static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries)
-{
-       bool mac_up = falcon_xmac_link_ok(efx);
-
-       if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS ||
-           efx_phy_mode_disabled(efx->phy_mode))
-               /* XAUI link is expected to be down */
-               return mac_up;
-
-       falcon_stop_nic_stats(efx);
-
-       while (!mac_up && tries) {
-               netif_dbg(efx, hw, efx->net_dev, "bashing xaui\n");
-               falcon_reset_xaui(efx);
-               udelay(200);
-
-               mac_up = falcon_xmac_link_ok(efx);
-               --tries;
-       }
-
-       falcon_start_nic_stats(efx);
-
-       return mac_up;
-}
-
-bool falcon_xmac_check_fault(struct efx_nic *efx)
-{
-       return !falcon_xmac_link_ok_retry(efx, 5);
-}
-
-int falcon_reconfigure_xmac(struct efx_nic *efx)
-{
-       struct falcon_nic_data *nic_data = efx->nic_data;
-
-       falcon_reconfigure_xgxs_core(efx);
-       falcon_reconfigure_xmac_core(efx);
-
-       falcon_reconfigure_mac_wrapper(efx);
-
-       nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 5);
-       falcon_ack_status_intr(efx);
-
-       return 0;
-}
-
-void falcon_update_stats_xmac(struct efx_nic *efx)
-{
-       struct efx_mac_stats *mac_stats = &efx->mac_stats;
-
-       /* Update MAC stats from DMAed values */
-       FALCON_STAT(efx, XgRxOctets, rx_bytes);
-       FALCON_STAT(efx, XgRxOctetsOK, rx_good_bytes);
-       FALCON_STAT(efx, XgRxPkts, rx_packets);
-       FALCON_STAT(efx, XgRxPktsOK, rx_good);
-       FALCON_STAT(efx, XgRxBroadcastPkts, rx_broadcast);
-       FALCON_STAT(efx, XgRxMulticastPkts, rx_multicast);
-       FALCON_STAT(efx, XgRxUnicastPkts, rx_unicast);
-       FALCON_STAT(efx, XgRxUndersizePkts, rx_lt64);
-       FALCON_STAT(efx, XgRxOversizePkts, rx_gtjumbo);
-       FALCON_STAT(efx, XgRxJabberPkts, rx_bad_gtjumbo);
-       FALCON_STAT(efx, XgRxUndersizeFCSerrorPkts, rx_bad_lt64);
-       FALCON_STAT(efx, XgRxDropEvents, rx_overflow);
-       FALCON_STAT(efx, XgRxFCSerrorPkts, rx_bad);
-       FALCON_STAT(efx, XgRxAlignError, rx_align_error);
-       FALCON_STAT(efx, XgRxSymbolError, rx_symbol_error);
-       FALCON_STAT(efx, XgRxInternalMACError, rx_internal_error);
-       FALCON_STAT(efx, XgRxControlPkts, rx_control);
-       FALCON_STAT(efx, XgRxPausePkts, rx_pause);
-       FALCON_STAT(efx, XgRxPkts64Octets, rx_64);
-       FALCON_STAT(efx, XgRxPkts65to127Octets, rx_65_to_127);
-       FALCON_STAT(efx, XgRxPkts128to255Octets, rx_128_to_255);
-       FALCON_STAT(efx, XgRxPkts256to511Octets, rx_256_to_511);
-       FALCON_STAT(efx, XgRxPkts512to1023Octets, rx_512_to_1023);
-       FALCON_STAT(efx, XgRxPkts1024to15xxOctets, rx_1024_to_15xx);
-       FALCON_STAT(efx, XgRxPkts15xxtoMaxOctets, rx_15xx_to_jumbo);
-       FALCON_STAT(efx, XgRxLengthError, rx_length_error);
-       FALCON_STAT(efx, XgTxPkts, tx_packets);
-       FALCON_STAT(efx, XgTxOctets, tx_bytes);
-       FALCON_STAT(efx, XgTxMulticastPkts, tx_multicast);
-       FALCON_STAT(efx, XgTxBroadcastPkts, tx_broadcast);
-       FALCON_STAT(efx, XgTxUnicastPkts, tx_unicast);
-       FALCON_STAT(efx, XgTxControlPkts, tx_control);
-       FALCON_STAT(efx, XgTxPausePkts, tx_pause);
-       FALCON_STAT(efx, XgTxPkts64Octets, tx_64);
-       FALCON_STAT(efx, XgTxPkts65to127Octets, tx_65_to_127);
-       FALCON_STAT(efx, XgTxPkts128to255Octets, tx_128_to_255);
-       FALCON_STAT(efx, XgTxPkts256to511Octets, tx_256_to_511);
-       FALCON_STAT(efx, XgTxPkts512to1023Octets, tx_512_to_1023);
-       FALCON_STAT(efx, XgTxPkts1024to15xxOctets, tx_1024_to_15xx);
-       FALCON_STAT(efx, XgTxPkts1519toMaxOctets, tx_15xx_to_jumbo);
-       FALCON_STAT(efx, XgTxUndersizePkts, tx_lt64);
-       FALCON_STAT(efx, XgTxOversizePkts, tx_gtjumbo);
-       FALCON_STAT(efx, XgTxNonTcpUdpPkt, tx_non_tcpudp);
-       FALCON_STAT(efx, XgTxMacSrcErrPkt, tx_mac_src_error);
-       FALCON_STAT(efx, XgTxIpSrcErrPkt, tx_ip_src_error);
-
-       /* Update derived statistics */
-       efx_update_diff_stat(&mac_stats->tx_good_bytes,
-                            mac_stats->tx_bytes - mac_stats->tx_bad_bytes -
-                            mac_stats->tx_control * 64);
-       efx_update_diff_stat(&mac_stats->rx_bad_bytes,
-                            mac_stats->rx_bytes - mac_stats->rx_good_bytes -
-                            mac_stats->rx_control * 64);
-}
-
-void falcon_poll_xmac(struct efx_nic *efx)
-{
-       struct falcon_nic_data *nic_data = efx->nic_data;
-
-       if (!EFX_WORKAROUND_5147(efx) || !efx->link_state.up ||
-           !nic_data->xmac_poll_required)
-               return;
-
-       nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
-       falcon_ack_status_intr(efx);
-}
diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c
new file mode 100644 (file)
index 0000000..d21483d
--- /dev/null
@@ -0,0 +1,2942 @@
+/****************************************************************************
+ * Driver for Solarflare Solarstorm network controllers and boards
+ * Copyright 2005-2006 Fen Systems Ltd.
+ * Copyright 2006-2011 Solarflare Communications Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation, incorporated herein by reference.
+ */
+
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <linux/seq_file.h>
+#include <linux/crc32.h>
+#include "net_driver.h"
+#include "bitfield.h"
+#include "efx.h"
+#include "nic.h"
+#include "farch_regs.h"
+#include "io.h"
+#include "workarounds.h"
+
+/* Falcon-architecture (SFC4000 and SFC9000-family) support */
+
+/**************************************************************************
+ *
+ * Configurable values
+ *
+ **************************************************************************
+ */
+
+/* This is set to 16 for a good reason.  In summary, if larger than
+ * 16, the descriptor cache holds more than a default socket
+ * buffer's worth of packets (for UDP we can only have at most one
+ * socket buffer's worth outstanding).  This combined with the fact
+ * that we only get 1 TX event per descriptor cache means the NIC
+ * goes idle.
+ */
+#define TX_DC_ENTRIES 16
+#define TX_DC_ENTRIES_ORDER 1
+
+#define RX_DC_ENTRIES 64
+#define RX_DC_ENTRIES_ORDER 3
+
+/* If EFX_MAX_INT_ERRORS internal errors occur within
+ * EFX_INT_ERROR_EXPIRE seconds, we consider the NIC broken and
+ * disable it.
+ */
+#define EFX_INT_ERROR_EXPIRE 3600
+#define EFX_MAX_INT_ERRORS 5
+
+/* Depth of RX flush request fifo */
+#define EFX_RX_FLUSH_COUNT 4
+
+/* Driver generated events */
+#define _EFX_CHANNEL_MAGIC_TEST                0x000101
+#define _EFX_CHANNEL_MAGIC_FILL                0x000102
+#define _EFX_CHANNEL_MAGIC_RX_DRAIN    0x000103
+#define _EFX_CHANNEL_MAGIC_TX_DRAIN    0x000104
+
+#define _EFX_CHANNEL_MAGIC(_code, _data)       ((_code) << 8 | (_data))
+#define _EFX_CHANNEL_MAGIC_CODE(_magic)                ((_magic) >> 8)
+
+#define EFX_CHANNEL_MAGIC_TEST(_channel)                               \
+       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TEST, (_channel)->channel)
+#define EFX_CHANNEL_MAGIC_FILL(_rx_queue)                              \
+       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_FILL,                     \
+                          efx_rx_queue_index(_rx_queue))
+#define EFX_CHANNEL_MAGIC_RX_DRAIN(_rx_queue)                          \
+       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_RX_DRAIN,                 \
+                          efx_rx_queue_index(_rx_queue))
+#define EFX_CHANNEL_MAGIC_TX_DRAIN(_tx_queue)                          \
+       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TX_DRAIN,                 \
+                          (_tx_queue)->queue)
+
+static void efx_farch_magic_event(struct efx_channel *channel, u32 magic);
+
+/**************************************************************************
+ *
+ * Hardware access
+ *
+ **************************************************************************/
+
+static inline void efx_write_buf_tbl(struct efx_nic *efx, efx_qword_t *value,
+                                    unsigned int index)
+{
+       efx_sram_writeq(efx, efx->membase + efx->type->buf_tbl_base,
+                       value, index);
+}
+
+static bool efx_masked_compare_oword(const efx_oword_t *a, const efx_oword_t *b,
+                                    const efx_oword_t *mask)
+{
+       return ((a->u64[0] ^ b->u64[0]) & mask->u64[0]) ||
+               ((a->u64[1] ^ b->u64[1]) & mask->u64[1]);
+}
+
+int efx_farch_test_registers(struct efx_nic *efx,
+                            const struct efx_farch_register_test *regs,
+                            size_t n_regs)
+{
+       unsigned address = 0, i, j;
+       efx_oword_t mask, imask, original, reg, buf;
+
+       for (i = 0; i < n_regs; ++i) {
+               address = regs[i].address;
+               mask = imask = regs[i].mask;
+               EFX_INVERT_OWORD(imask);
+
+               efx_reado(efx, &original, address);
+
+               /* bit sweep on and off */
+               for (j = 0; j < 128; j++) {
+                       if (!EFX_EXTRACT_OWORD32(mask, j, j))
+                               continue;
+
+                       /* Test this testable bit can be set in isolation */
+                       EFX_AND_OWORD(reg, original, mask);
+                       EFX_SET_OWORD32(reg, j, j, 1);
+
+                       efx_writeo(efx, &reg, address);
+                       efx_reado(efx, &buf, address);
+
+                       if (efx_masked_compare_oword(&reg, &buf, &mask))
+                               goto fail;
+
+                       /* Test this testable bit can be cleared in isolation */
+                       EFX_OR_OWORD(reg, original, mask);
+                       EFX_SET_OWORD32(reg, j, j, 0);
+
+                       efx_writeo(efx, &reg, address);
+                       efx_reado(efx, &buf, address);
+
+                       if (efx_masked_compare_oword(&reg, &buf, &mask))
+                               goto fail;
+               }
+
+               efx_writeo(efx, &original, address);
+       }
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev,
+                 "wrote "EFX_OWORD_FMT" read "EFX_OWORD_FMT
+                 " at address 0x%x mask "EFX_OWORD_FMT"\n", EFX_OWORD_VAL(reg),
+                 EFX_OWORD_VAL(buf), address, EFX_OWORD_VAL(mask));
+       return -EIO;
+}
+
+/**************************************************************************
+ *
+ * Special buffer handling
+ * Special buffers are used for event queues and the TX and RX
+ * descriptor rings.
+ *
+ *************************************************************************/
+
+/*
+ * Initialise a special buffer
+ *
+ * This will define a buffer (previously allocated via
+ * efx_alloc_special_buffer()) in the buffer table, allowing
+ * it to be used for event queues, descriptor rings etc.
+ */
+static void
+efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
+{
+       efx_qword_t buf_desc;
+       unsigned int index;
+       dma_addr_t dma_addr;
+       int i;
+
+       EFX_BUG_ON_PARANOID(!buffer->buf.addr);
+
+       /* Write buffer descriptors to NIC */
+       for (i = 0; i < buffer->entries; i++) {
+               index = buffer->index + i;
+               dma_addr = buffer->buf.dma_addr + (i * EFX_BUF_SIZE);
+               netif_dbg(efx, probe, efx->net_dev,
+                         "mapping special buffer %d at %llx\n",
+                         index, (unsigned long long)dma_addr);
+               EFX_POPULATE_QWORD_3(buf_desc,
+                                    FRF_AZ_BUF_ADR_REGION, 0,
+                                    FRF_AZ_BUF_ADR_FBUF, dma_addr >> 12,
+                                    FRF_AZ_BUF_OWNER_ID_FBUF, 0);
+               efx_write_buf_tbl(efx, &buf_desc, index);
+       }
+}
+
+/* Unmaps a buffer and clears the buffer table entries */
+static void
+efx_fini_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
+{
+       efx_oword_t buf_tbl_upd;
+       unsigned int start = buffer->index;
+       unsigned int end = (buffer->index + buffer->entries - 1);
+
+       if (!buffer->entries)
+               return;
+
+       netif_dbg(efx, hw, efx->net_dev, "unmapping special buffers %d-%d\n",
+                 buffer->index, buffer->index + buffer->entries - 1);
+
+       EFX_POPULATE_OWORD_4(buf_tbl_upd,
+                            FRF_AZ_BUF_UPD_CMD, 0,
+                            FRF_AZ_BUF_CLR_CMD, 1,
+                            FRF_AZ_BUF_CLR_END_ID, end,
+                            FRF_AZ_BUF_CLR_START_ID, start);
+       efx_writeo(efx, &buf_tbl_upd, FR_AZ_BUF_TBL_UPD);
+}
+
+/*
+ * Allocate a new special buffer
+ *
+ * This allocates memory for a new buffer, clears it and allocates a
+ * new buffer ID range.  It does not write into the buffer table.
+ *
+ * This call will allocate 4KB buffers, since 8KB buffers can't be
+ * used for event queues and descriptor rings.
+ */
+static int efx_alloc_special_buffer(struct efx_nic *efx,
+                                   struct efx_special_buffer *buffer,
+                                   unsigned int len)
+{
+       len = ALIGN(len, EFX_BUF_SIZE);
+
+       if (efx_nic_alloc_buffer(efx, &buffer->buf, len, GFP_KERNEL))
+               return -ENOMEM;
+       buffer->entries = len / EFX_BUF_SIZE;
+       BUG_ON(buffer->buf.dma_addr & (EFX_BUF_SIZE - 1));
+
+       /* Select new buffer ID */
+       buffer->index = efx->next_buffer_table;
+       efx->next_buffer_table += buffer->entries;
+#ifdef CONFIG_SFC_SRIOV
+       BUG_ON(efx_sriov_enabled(efx) &&
+              efx->vf_buftbl_base < efx->next_buffer_table);
+#endif
+
+       netif_dbg(efx, probe, efx->net_dev,
+                 "allocating special buffers %d-%d at %llx+%x "
+                 "(virt %p phys %llx)\n", buffer->index,
+                 buffer->index + buffer->entries - 1,
+                 (u64)buffer->buf.dma_addr, len,
+                 buffer->buf.addr, (u64)virt_to_phys(buffer->buf.addr));
+
+       return 0;
+}
+
+static void
+efx_free_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
+{
+       if (!buffer->buf.addr)
+               return;
+
+       netif_dbg(efx, hw, efx->net_dev,
+                 "deallocating special buffers %d-%d at %llx+%x "
+                 "(virt %p phys %llx)\n", buffer->index,
+                 buffer->index + buffer->entries - 1,
+                 (u64)buffer->buf.dma_addr, buffer->buf.len,
+                 buffer->buf.addr, (u64)virt_to_phys(buffer->buf.addr));
+
+       efx_nic_free_buffer(efx, &buffer->buf);
+       buffer->entries = 0;
+}
+
+/**************************************************************************
+ *
+ * TX path
+ *
+ **************************************************************************/
+
+/* This writes to the TX_DESC_WPTR; write pointer for TX descriptor ring */
+static inline void efx_farch_notify_tx_desc(struct efx_tx_queue *tx_queue)
+{
+       unsigned write_ptr;
+       efx_dword_t reg;
+
+       write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
+       EFX_POPULATE_DWORD_1(reg, FRF_AZ_TX_DESC_WPTR_DWORD, write_ptr);
+       efx_writed_page(tx_queue->efx, &reg,
+                       FR_AZ_TX_DESC_UPD_DWORD_P0, tx_queue->queue);
+}
+
+/* Write pointer and first descriptor for TX descriptor ring */
+static inline void efx_farch_push_tx_desc(struct efx_tx_queue *tx_queue,
+                                         const efx_qword_t *txd)
+{
+       unsigned write_ptr;
+       efx_oword_t reg;
+
+       BUILD_BUG_ON(FRF_AZ_TX_DESC_LBN != 0);
+       BUILD_BUG_ON(FR_AA_TX_DESC_UPD_KER != FR_BZ_TX_DESC_UPD_P0);
+
+       write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
+       EFX_POPULATE_OWORD_2(reg, FRF_AZ_TX_DESC_PUSH_CMD, true,
+                            FRF_AZ_TX_DESC_WPTR, write_ptr);
+       reg.qword[0] = *txd;
+       efx_writeo_page(tx_queue->efx, &reg,
+                       FR_BZ_TX_DESC_UPD_P0, tx_queue->queue);
+}
+
+
+/* For each entry inserted into the software descriptor ring, create a
+ * descriptor in the hardware TX descriptor ring (in host memory), and
+ * write a doorbell.
+ */
+void efx_farch_tx_write(struct efx_tx_queue *tx_queue)
+{
+
+       struct efx_tx_buffer *buffer;
+       efx_qword_t *txd;
+       unsigned write_ptr;
+       unsigned old_write_count = tx_queue->write_count;
+
+       BUG_ON(tx_queue->write_count == tx_queue->insert_count);
+
+       do {
+               write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
+               buffer = &tx_queue->buffer[write_ptr];
+               txd = efx_tx_desc(tx_queue, write_ptr);
+               ++tx_queue->write_count;
+
+               /* Create TX descriptor ring entry */
+               BUILD_BUG_ON(EFX_TX_BUF_CONT != 1);
+               EFX_POPULATE_QWORD_4(*txd,
+                                    FSF_AZ_TX_KER_CONT,
+                                    buffer->flags & EFX_TX_BUF_CONT,
+                                    FSF_AZ_TX_KER_BYTE_COUNT, buffer->len,
+                                    FSF_AZ_TX_KER_BUF_REGION, 0,
+                                    FSF_AZ_TX_KER_BUF_ADDR, buffer->dma_addr);
+       } while (tx_queue->write_count != tx_queue->insert_count);
+
+       wmb(); /* Ensure descriptors are written before they are fetched */
+
+       if (efx_nic_may_push_tx_desc(tx_queue, old_write_count)) {
+               txd = efx_tx_desc(tx_queue,
+                                 old_write_count & tx_queue->ptr_mask);
+               efx_farch_push_tx_desc(tx_queue, txd);
+               ++tx_queue->pushes;
+       } else {
+               efx_farch_notify_tx_desc(tx_queue);
+       }
+}
+
+/* Allocate hardware resources for a TX queue */
+int efx_farch_tx_probe(struct efx_tx_queue *tx_queue)
+{
+       struct efx_nic *efx = tx_queue->efx;
+       unsigned entries;
+
+       entries = tx_queue->ptr_mask + 1;
+       return efx_alloc_special_buffer(efx, &tx_queue->txd,
+                                       entries * sizeof(efx_qword_t));
+}
+
+void efx_farch_tx_init(struct efx_tx_queue *tx_queue)
+{
+       struct efx_nic *efx = tx_queue->efx;
+       efx_oword_t reg;
+
+       /* Pin TX descriptor ring */
+       efx_init_special_buffer(efx, &tx_queue->txd);
+
+       /* Push TX descriptor ring to card */
+       EFX_POPULATE_OWORD_10(reg,
+                             FRF_AZ_TX_DESCQ_EN, 1,
+                             FRF_AZ_TX_ISCSI_DDIG_EN, 0,
+                             FRF_AZ_TX_ISCSI_HDIG_EN, 0,
+                             FRF_AZ_TX_DESCQ_BUF_BASE_ID, tx_queue->txd.index,
+                             FRF_AZ_TX_DESCQ_EVQ_ID,
+                             tx_queue->channel->channel,
+                             FRF_AZ_TX_DESCQ_OWNER_ID, 0,
+                             FRF_AZ_TX_DESCQ_LABEL, tx_queue->queue,
+                             FRF_AZ_TX_DESCQ_SIZE,
+                             __ffs(tx_queue->txd.entries),
+                             FRF_AZ_TX_DESCQ_TYPE, 0,
+                             FRF_BZ_TX_NON_IP_DROP_DIS, 1);
+
+       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+               int csum = tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD;
+               EFX_SET_OWORD_FIELD(reg, FRF_BZ_TX_IP_CHKSM_DIS, !csum);
+               EFX_SET_OWORD_FIELD(reg, FRF_BZ_TX_TCP_CHKSM_DIS,
+                                   !csum);
+       }
+
+       efx_writeo_table(efx, &reg, efx->type->txd_ptr_tbl_base,
+                        tx_queue->queue);
+
+       if (efx_nic_rev(efx) < EFX_REV_FALCON_B0) {
+               /* Only 128 bits in this register */
+               BUILD_BUG_ON(EFX_MAX_TX_QUEUES > 128);
+
+               efx_reado(efx, &reg, FR_AA_TX_CHKSM_CFG);
+               if (tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD)
+                       __clear_bit_le(tx_queue->queue, &reg);
+               else
+                       __set_bit_le(tx_queue->queue, &reg);
+               efx_writeo(efx, &reg, FR_AA_TX_CHKSM_CFG);
+       }
+
+       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+               EFX_POPULATE_OWORD_1(reg,
+                                    FRF_BZ_TX_PACE,
+                                    (tx_queue->queue & EFX_TXQ_TYPE_HIGHPRI) ?
+                                    FFE_BZ_TX_PACE_OFF :
+                                    FFE_BZ_TX_PACE_RESERVED);
+               efx_writeo_table(efx, &reg, FR_BZ_TX_PACE_TBL,
+                                tx_queue->queue);
+       }
+}
+
+static void efx_farch_flush_tx_queue(struct efx_tx_queue *tx_queue)
+{
+       struct efx_nic *efx = tx_queue->efx;
+       efx_oword_t tx_flush_descq;
+
+       WARN_ON(atomic_read(&tx_queue->flush_outstanding));
+       atomic_set(&tx_queue->flush_outstanding, 1);
+
+       EFX_POPULATE_OWORD_2(tx_flush_descq,
+                            FRF_AZ_TX_FLUSH_DESCQ_CMD, 1,
+                            FRF_AZ_TX_FLUSH_DESCQ, tx_queue->queue);
+       efx_writeo(efx, &tx_flush_descq, FR_AZ_TX_FLUSH_DESCQ);
+}
+
+void efx_farch_tx_fini(struct efx_tx_queue *tx_queue)
+{
+       struct efx_nic *efx = tx_queue->efx;
+       efx_oword_t tx_desc_ptr;
+
+       /* Remove TX descriptor ring from card */
+       EFX_ZERO_OWORD(tx_desc_ptr);
+       efx_writeo_table(efx, &tx_desc_ptr, efx->type->txd_ptr_tbl_base,
+                        tx_queue->queue);
+
+       /* Unpin TX descriptor ring */
+       efx_fini_special_buffer(efx, &tx_queue->txd);
+}
+
+/* Free buffers backing TX queue */
+void efx_farch_tx_remove(struct efx_tx_queue *tx_queue)
+{
+       efx_free_special_buffer(tx_queue->efx, &tx_queue->txd);
+}
+
+/**************************************************************************
+ *
+ * RX path
+ *
+ **************************************************************************/
+
+/* This creates an entry in the RX descriptor queue */
+static inline void
+efx_farch_build_rx_desc(struct efx_rx_queue *rx_queue, unsigned index)
+{
+       struct efx_rx_buffer *rx_buf;
+       efx_qword_t *rxd;
+
+       rxd = efx_rx_desc(rx_queue, index);
+       rx_buf = efx_rx_buffer(rx_queue, index);
+       EFX_POPULATE_QWORD_3(*rxd,
+                            FSF_AZ_RX_KER_BUF_SIZE,
+                            rx_buf->len -
+                            rx_queue->efx->type->rx_buffer_padding,
+                            FSF_AZ_RX_KER_BUF_REGION, 0,
+                            FSF_AZ_RX_KER_BUF_ADDR, rx_buf->dma_addr);
+}
+
+/* This writes to the RX_DESC_WPTR register for the specified receive
+ * descriptor ring.
+ */
+void efx_farch_rx_write(struct efx_rx_queue *rx_queue)
+{
+       struct efx_nic *efx = rx_queue->efx;
+       efx_dword_t reg;
+       unsigned write_ptr;
+
+       while (rx_queue->notified_count != rx_queue->added_count) {
+               efx_farch_build_rx_desc(
+                       rx_queue,
+                       rx_queue->notified_count & rx_queue->ptr_mask);
+               ++rx_queue->notified_count;
+       }
+
+       wmb();
+       write_ptr = rx_queue->added_count & rx_queue->ptr_mask;
+       EFX_POPULATE_DWORD_1(reg, FRF_AZ_RX_DESC_WPTR_DWORD, write_ptr);
+       efx_writed_page(efx, &reg, FR_AZ_RX_DESC_UPD_DWORD_P0,
+                       efx_rx_queue_index(rx_queue));
+}
+
+int efx_farch_rx_probe(struct efx_rx_queue *rx_queue)
+{
+       struct efx_nic *efx = rx_queue->efx;
+       unsigned entries;
+
+       entries = rx_queue->ptr_mask + 1;
+       return efx_alloc_special_buffer(efx, &rx_queue->rxd,
+                                       entries * sizeof(efx_qword_t));
+}
+
+void efx_farch_rx_init(struct efx_rx_queue *rx_queue)
+{
+       efx_oword_t rx_desc_ptr;
+       struct efx_nic *efx = rx_queue->efx;
+       bool is_b0 = efx_nic_rev(efx) >= EFX_REV_FALCON_B0;
+       bool iscsi_digest_en = is_b0;
+       bool jumbo_en;
+
+       /* For kernel-mode queues in Falcon A1, the JUMBO flag enables
+        * DMA to continue after a PCIe page boundary (and scattering
+        * is not possible).  In Falcon B0 and Siena, it enables
+        * scatter.
+        */
+       jumbo_en = !is_b0 || efx->rx_scatter;
+
+       netif_dbg(efx, hw, efx->net_dev,
+                 "RX queue %d ring in special buffers %d-%d\n",
+                 efx_rx_queue_index(rx_queue), rx_queue->rxd.index,
+                 rx_queue->rxd.index + rx_queue->rxd.entries - 1);
+
+       rx_queue->scatter_n = 0;
+
+       /* Pin RX descriptor ring */
+       efx_init_special_buffer(efx, &rx_queue->rxd);
+
+       /* Push RX descriptor ring to card */
+       EFX_POPULATE_OWORD_10(rx_desc_ptr,
+                             FRF_AZ_RX_ISCSI_DDIG_EN, iscsi_digest_en,
+                             FRF_AZ_RX_ISCSI_HDIG_EN, iscsi_digest_en,
+                             FRF_AZ_RX_DESCQ_BUF_BASE_ID, rx_queue->rxd.index,
+                             FRF_AZ_RX_DESCQ_EVQ_ID,
+                             efx_rx_queue_channel(rx_queue)->channel,
+                             FRF_AZ_RX_DESCQ_OWNER_ID, 0,
+                             FRF_AZ_RX_DESCQ_LABEL,
+                             efx_rx_queue_index(rx_queue),
+                             FRF_AZ_RX_DESCQ_SIZE,
+                             __ffs(rx_queue->rxd.entries),
+                             FRF_AZ_RX_DESCQ_TYPE, 0 /* kernel queue */ ,
+                             FRF_AZ_RX_DESCQ_JUMBO, jumbo_en,
+                             FRF_AZ_RX_DESCQ_EN, 1);
+       efx_writeo_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base,
+                        efx_rx_queue_index(rx_queue));
+}
+
+static void efx_farch_flush_rx_queue(struct efx_rx_queue *rx_queue)
+{
+       struct efx_nic *efx = rx_queue->efx;
+       efx_oword_t rx_flush_descq;
+
+       EFX_POPULATE_OWORD_2(rx_flush_descq,
+                            FRF_AZ_RX_FLUSH_DESCQ_CMD, 1,
+                            FRF_AZ_RX_FLUSH_DESCQ,
+                            efx_rx_queue_index(rx_queue));
+       efx_writeo(efx, &rx_flush_descq, FR_AZ_RX_FLUSH_DESCQ);
+}
+
+void efx_farch_rx_fini(struct efx_rx_queue *rx_queue)
+{
+       efx_oword_t rx_desc_ptr;
+       struct efx_nic *efx = rx_queue->efx;
+
+       /* Remove RX descriptor ring from card */
+       EFX_ZERO_OWORD(rx_desc_ptr);
+       efx_writeo_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base,
+                        efx_rx_queue_index(rx_queue));
+
+       /* Unpin RX descriptor ring */
+       efx_fini_special_buffer(efx, &rx_queue->rxd);
+}
+
+/* Free buffers backing RX queue */
+void efx_farch_rx_remove(struct efx_rx_queue *rx_queue)
+{
+       efx_free_special_buffer(rx_queue->efx, &rx_queue->rxd);
+}
+
+/**************************************************************************
+ *
+ * Flush handling
+ *
+ **************************************************************************/
+
+/* efx_farch_flush_queues() must be woken up when all flushes are completed,
+ * or more RX flushes can be kicked off.
+ */
+static bool efx_farch_flush_wake(struct efx_nic *efx)
+{
+       /* Ensure that all updates are visible to efx_farch_flush_queues() */
+       smp_mb();
+
+       return (atomic_read(&efx->drain_pending) == 0 ||
+               (atomic_read(&efx->rxq_flush_outstanding) < EFX_RX_FLUSH_COUNT
+                && atomic_read(&efx->rxq_flush_pending) > 0));
+}
+
+static bool efx_check_tx_flush_complete(struct efx_nic *efx)
+{
+       bool i = true;
+       efx_oword_t txd_ptr_tbl;
+       struct efx_channel *channel;
+       struct efx_tx_queue *tx_queue;
+
+       efx_for_each_channel(channel, efx) {
+               efx_for_each_channel_tx_queue(tx_queue, channel) {
+                       efx_reado_table(efx, &txd_ptr_tbl,
+                                       FR_BZ_TX_DESC_PTR_TBL, tx_queue->queue);
+                       if (EFX_OWORD_FIELD(txd_ptr_tbl,
+                                           FRF_AZ_TX_DESCQ_FLUSH) ||
+                           EFX_OWORD_FIELD(txd_ptr_tbl,
+                                           FRF_AZ_TX_DESCQ_EN)) {
+                               netif_dbg(efx, hw, efx->net_dev,
+                                         "flush did not complete on TXQ %d\n",
+                                         tx_queue->queue);
+                               i = false;
+                       } else if (atomic_cmpxchg(&tx_queue->flush_outstanding,
+                                                 1, 0)) {
+                               /* The flush is complete, but we didn't
+                                * receive a flush completion event
+                                */
+                               netif_dbg(efx, hw, efx->net_dev,
+                                         "flush complete on TXQ %d, so drain "
+                                         "the queue\n", tx_queue->queue);
+                               /* Don't need to increment drain_pending as it
+                                * has already been incremented for the queues
+                                * which did not drain
+                                */
+                               efx_farch_magic_event(channel,
+                                                     EFX_CHANNEL_MAGIC_TX_DRAIN(
+                                                             tx_queue));
+                       }
+               }
+       }
+
+       return i;
+}
+
+/* Flush all the transmit queues, and continue flushing receive queues until
+ * they're all flushed. Wait for the DRAIN events to be recieved so that there
+ * are no more RX and TX events left on any channel. */
+static int efx_farch_do_flush(struct efx_nic *efx)
+{
+       unsigned timeout = msecs_to_jiffies(5000); /* 5s for all flushes and drains */
+       struct efx_channel *channel;
+       struct efx_rx_queue *rx_queue;
+       struct efx_tx_queue *tx_queue;
+       int rc = 0;
+
+       efx_for_each_channel(channel, efx) {
+               efx_for_each_channel_tx_queue(tx_queue, channel) {
+                       atomic_inc(&efx->drain_pending);
+                       efx_farch_flush_tx_queue(tx_queue);
+               }
+               efx_for_each_channel_rx_queue(rx_queue, channel) {
+                       atomic_inc(&efx->drain_pending);
+                       rx_queue->flush_pending = true;
+                       atomic_inc(&efx->rxq_flush_pending);
+               }
+       }
+
+       while (timeout && atomic_read(&efx->drain_pending) > 0) {
+               /* If SRIOV is enabled, then offload receive queue flushing to
+                * the firmware (though we will still have to poll for
+                * completion). If that fails, fall back to the old scheme.
+                */
+               if (efx_sriov_enabled(efx)) {
+                       rc = efx_mcdi_flush_rxqs(efx);
+                       if (!rc)
+                               goto wait;
+               }
+
+               /* The hardware supports four concurrent rx flushes, each of
+                * which may need to be retried if there is an outstanding
+                * descriptor fetch
+                */
+               efx_for_each_channel(channel, efx) {
+                       efx_for_each_channel_rx_queue(rx_queue, channel) {
+                               if (atomic_read(&efx->rxq_flush_outstanding) >=
+                                   EFX_RX_FLUSH_COUNT)
+                                       break;
+
+                               if (rx_queue->flush_pending) {
+                                       rx_queue->flush_pending = false;
+                                       atomic_dec(&efx->rxq_flush_pending);
+                                       atomic_inc(&efx->rxq_flush_outstanding);
+                                       efx_farch_flush_rx_queue(rx_queue);
+                               }
+                       }
+               }
+
+       wait:
+               timeout = wait_event_timeout(efx->flush_wq,
+                                            efx_farch_flush_wake(efx),
+                                            timeout);
+       }
+
+       if (atomic_read(&efx->drain_pending) &&
+           !efx_check_tx_flush_complete(efx)) {
+               netif_err(efx, hw, efx->net_dev, "failed to flush %d queues "
+                         "(rx %d+%d)\n", atomic_read(&efx->drain_pending),
+                         atomic_read(&efx->rxq_flush_outstanding),
+                         atomic_read(&efx->rxq_flush_pending));
+               rc = -ETIMEDOUT;
+
+               atomic_set(&efx->drain_pending, 0);
+               atomic_set(&efx->rxq_flush_pending, 0);
+               atomic_set(&efx->rxq_flush_outstanding, 0);
+       }
+
+       return rc;
+}
+
+int efx_farch_fini_dmaq(struct efx_nic *efx)
+{
+       struct efx_channel *channel;
+       struct efx_tx_queue *tx_queue;
+       struct efx_rx_queue *rx_queue;
+       int rc = 0;
+
+       /* Do not attempt to write to the NIC during EEH recovery */
+       if (efx->state != STATE_RECOVERY) {
+               /* Only perform flush if DMA is enabled */
+               if (efx->pci_dev->is_busmaster) {
+                       efx->type->prepare_flush(efx);
+                       rc = efx_farch_do_flush(efx);
+                       efx->type->finish_flush(efx);
+               }
+
+               efx_for_each_channel(channel, efx) {
+                       efx_for_each_channel_rx_queue(rx_queue, channel)
+                               efx_farch_rx_fini(rx_queue);
+                       efx_for_each_channel_tx_queue(tx_queue, channel)
+                               efx_farch_tx_fini(tx_queue);
+               }
+       }
+
+       return rc;
+}
+
+/**************************************************************************
+ *
+ * Event queue processing
+ * Event queues are processed by per-channel tasklets.
+ *
+ **************************************************************************/
+
+/* Update a channel's event queue's read pointer (RPTR) register
+ *
+ * This writes the EVQ_RPTR_REG register for the specified channel's
+ * event queue.
+ */
+void efx_farch_ev_read_ack(struct efx_channel *channel)
+{
+       efx_dword_t reg;
+       struct efx_nic *efx = channel->efx;
+
+       EFX_POPULATE_DWORD_1(reg, FRF_AZ_EVQ_RPTR,
+                            channel->eventq_read_ptr & channel->eventq_mask);
+
+       /* For Falcon A1, EVQ_RPTR_KER is documented as having a step size
+        * of 4 bytes, but it is really 16 bytes just like later revisions.
+        */
+       efx_writed(efx, &reg,
+                  efx->type->evq_rptr_tbl_base +
+                  FR_BZ_EVQ_RPTR_STEP * channel->channel);
+}
+
+/* Use HW to insert a SW defined event */
+void efx_farch_generate_event(struct efx_nic *efx, unsigned int evq,
+                             efx_qword_t *event)
+{
+       efx_oword_t drv_ev_reg;
+
+       BUILD_BUG_ON(FRF_AZ_DRV_EV_DATA_LBN != 0 ||
+                    FRF_AZ_DRV_EV_DATA_WIDTH != 64);
+       drv_ev_reg.u32[0] = event->u32[0];
+       drv_ev_reg.u32[1] = event->u32[1];
+       drv_ev_reg.u32[2] = 0;
+       drv_ev_reg.u32[3] = 0;
+       EFX_SET_OWORD_FIELD(drv_ev_reg, FRF_AZ_DRV_EV_QID, evq);
+       efx_writeo(efx, &drv_ev_reg, FR_AZ_DRV_EV);
+}
+
+static void efx_farch_magic_event(struct efx_channel *channel, u32 magic)
+{
+       efx_qword_t event;
+
+       EFX_POPULATE_QWORD_2(event, FSF_AZ_EV_CODE,
+                            FSE_AZ_EV_CODE_DRV_GEN_EV,
+                            FSF_AZ_DRV_GEN_EV_MAGIC, magic);
+       efx_farch_generate_event(channel->efx, channel->channel, &event);
+}
+
+/* Handle a transmit completion event
+ *
+ * The NIC batches TX completion events; the message we receive is of
+ * the form "complete all TX events up to this index".
+ */
+static int
+efx_farch_handle_tx_event(struct efx_channel *channel, efx_qword_t *event)
+{
+       unsigned int tx_ev_desc_ptr;
+       unsigned int tx_ev_q_label;
+       struct efx_tx_queue *tx_queue;
+       struct efx_nic *efx = channel->efx;
+       int tx_packets = 0;
+
+       if (unlikely(ACCESS_ONCE(efx->reset_pending)))
+               return 0;
+
+       if (likely(EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_COMP))) {
+               /* Transmit completion */
+               tx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_DESC_PTR);
+               tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL);
+               tx_queue = efx_channel_get_tx_queue(
+                       channel, tx_ev_q_label % EFX_TXQ_TYPES);
+               tx_packets = ((tx_ev_desc_ptr - tx_queue->read_count) &
+                             tx_queue->ptr_mask);
+               efx_xmit_done(tx_queue, tx_ev_desc_ptr);
+       } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) {
+               /* Rewrite the FIFO write pointer */
+               tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL);
+               tx_queue = efx_channel_get_tx_queue(
+                       channel, tx_ev_q_label % EFX_TXQ_TYPES);
+
+               netif_tx_lock(efx->net_dev);
+               efx_farch_notify_tx_desc(tx_queue);
+               netif_tx_unlock(efx->net_dev);
+       } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_PKT_ERR)) {
+               efx_schedule_reset(efx, RESET_TYPE_DMA_ERROR);
+       } else {
+               netif_err(efx, tx_err, efx->net_dev,
+                         "channel %d unexpected TX event "
+                         EFX_QWORD_FMT"\n", channel->channel,
+                         EFX_QWORD_VAL(*event));
+       }
+
+       return tx_packets;
+}
+
+/* Detect errors included in the rx_evt_pkt_ok bit. */
+static u16 efx_farch_handle_rx_not_ok(struct efx_rx_queue *rx_queue,
+                                     const efx_qword_t *event)
+{
+       struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
+       struct efx_nic *efx = rx_queue->efx;
+       bool rx_ev_buf_owner_id_err, rx_ev_ip_hdr_chksum_err;
+       bool rx_ev_tcp_udp_chksum_err, rx_ev_eth_crc_err;
+       bool rx_ev_frm_trunc, rx_ev_drib_nib, rx_ev_tobe_disc;
+       bool rx_ev_other_err, rx_ev_pause_frm;
+       bool rx_ev_hdr_type, rx_ev_mcast_pkt;
+       unsigned rx_ev_pkt_type;
+
+       rx_ev_hdr_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_HDR_TYPE);
+       rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_PKT);
+       rx_ev_tobe_disc = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_TOBE_DISC);
+       rx_ev_pkt_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PKT_TYPE);
+       rx_ev_buf_owner_id_err = EFX_QWORD_FIELD(*event,
+                                                FSF_AZ_RX_EV_BUF_OWNER_ID_ERR);
+       rx_ev_ip_hdr_chksum_err = EFX_QWORD_FIELD(*event,
+                                                 FSF_AZ_RX_EV_IP_HDR_CHKSUM_ERR);
+       rx_ev_tcp_udp_chksum_err = EFX_QWORD_FIELD(*event,
+                                                  FSF_AZ_RX_EV_TCP_UDP_CHKSUM_ERR);
+       rx_ev_eth_crc_err = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_ETH_CRC_ERR);
+       rx_ev_frm_trunc = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_FRM_TRUNC);
+       rx_ev_drib_nib = ((efx_nic_rev(efx) >= EFX_REV_FALCON_B0) ?
+                         0 : EFX_QWORD_FIELD(*event, FSF_AA_RX_EV_DRIB_NIB));
+       rx_ev_pause_frm = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PAUSE_FRM_ERR);
+
+       /* Every error apart from tobe_disc and pause_frm */
+       rx_ev_other_err = (rx_ev_drib_nib | rx_ev_tcp_udp_chksum_err |
+                          rx_ev_buf_owner_id_err | rx_ev_eth_crc_err |
+                          rx_ev_frm_trunc | rx_ev_ip_hdr_chksum_err);
+
+       /* Count errors that are not in MAC stats.  Ignore expected
+        * checksum errors during self-test. */
+       if (rx_ev_frm_trunc)
+               ++channel->n_rx_frm_trunc;
+       else if (rx_ev_tobe_disc)
+               ++channel->n_rx_tobe_disc;
+       else if (!efx->loopback_selftest) {
+               if (rx_ev_ip_hdr_chksum_err)
+                       ++channel->n_rx_ip_hdr_chksum_err;
+               else if (rx_ev_tcp_udp_chksum_err)
+                       ++channel->n_rx_tcp_udp_chksum_err;
+       }
+
+       /* TOBE_DISC is expected on unicast mismatches; don't print out an
+        * error message.  FRM_TRUNC indicates RXDP dropped the packet due
+        * to a FIFO overflow.
+        */
+#ifdef DEBUG
+       if (rx_ev_other_err && net_ratelimit()) {
+               netif_dbg(efx, rx_err, efx->net_dev,
+                         " RX queue %d unexpected RX event "
+                         EFX_QWORD_FMT "%s%s%s%s%s%s%s%s\n",
+                         efx_rx_queue_index(rx_queue), EFX_QWORD_VAL(*event),
+                         rx_ev_buf_owner_id_err ? " [OWNER_ID_ERR]" : "",
+                         rx_ev_ip_hdr_chksum_err ?
+                         " [IP_HDR_CHKSUM_ERR]" : "",
+                         rx_ev_tcp_udp_chksum_err ?
+                         " [TCP_UDP_CHKSUM_ERR]" : "",
+                         rx_ev_eth_crc_err ? " [ETH_CRC_ERR]" : "",
+                         rx_ev_frm_trunc ? " [FRM_TRUNC]" : "",
+                         rx_ev_drib_nib ? " [DRIB_NIB]" : "",
+                         rx_ev_tobe_disc ? " [TOBE_DISC]" : "",
+                         rx_ev_pause_frm ? " [PAUSE]" : "");
+       }
+#endif
+
+       /* The frame must be discarded if any of these are true. */
+       return (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib |
+               rx_ev_tobe_disc | rx_ev_pause_frm) ?
+               EFX_RX_PKT_DISCARD : 0;
+}
+
+/* Handle receive events that are not in-order. Return true if this
+ * can be handled as a partial packet discard, false if it's more
+ * serious.
+ */
+static bool
+efx_farch_handle_rx_bad_index(struct efx_rx_queue *rx_queue, unsigned index)
+{
+       struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
+       struct efx_nic *efx = rx_queue->efx;
+       unsigned expected, dropped;
+
+       if (rx_queue->scatter_n &&
+           index == ((rx_queue->removed_count + rx_queue->scatter_n - 1) &
+                     rx_queue->ptr_mask)) {
+               ++channel->n_rx_nodesc_trunc;
+               return true;
+       }
+
+       expected = rx_queue->removed_count & rx_queue->ptr_mask;
+       dropped = (index - expected) & rx_queue->ptr_mask;
+       netif_info(efx, rx_err, efx->net_dev,
+                  "dropped %d events (index=%d expected=%d)\n",
+                  dropped, index, expected);
+
+       efx_schedule_reset(efx, EFX_WORKAROUND_5676(efx) ?
+                          RESET_TYPE_RX_RECOVERY : RESET_TYPE_DISABLE);
+       return false;
+}
+
+/* Handle a packet received event
+ *
+ * The NIC gives a "discard" flag if it's a unicast packet with the
+ * wrong destination address
+ * Also "is multicast" and "matches multicast filter" flags can be used to
+ * discard non-matching multicast packets.
+ */
+static void
+efx_farch_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event)
+{
+       unsigned int rx_ev_desc_ptr, rx_ev_byte_cnt;
+       unsigned int rx_ev_hdr_type, rx_ev_mcast_pkt;
+       unsigned expected_ptr;
+       bool rx_ev_pkt_ok, rx_ev_sop, rx_ev_cont;
+       u16 flags;
+       struct efx_rx_queue *rx_queue;
+       struct efx_nic *efx = channel->efx;
+
+       if (unlikely(ACCESS_ONCE(efx->reset_pending)))
+               return;
+
+       rx_ev_cont = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_JUMBO_CONT);
+       rx_ev_sop = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_SOP);
+       WARN_ON(EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_Q_LABEL) !=
+               channel->channel);
+
+       rx_queue = efx_channel_get_rx_queue(channel);
+
+       rx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_DESC_PTR);
+       expected_ptr = ((rx_queue->removed_count + rx_queue->scatter_n) &
+                       rx_queue->ptr_mask);
+
+       /* Check for partial drops and other errors */
+       if (unlikely(rx_ev_desc_ptr != expected_ptr) ||
+           unlikely(rx_ev_sop != (rx_queue->scatter_n == 0))) {
+               if (rx_ev_desc_ptr != expected_ptr &&
+                   !efx_farch_handle_rx_bad_index(rx_queue, rx_ev_desc_ptr))
+                       return;
+
+               /* Discard all pending fragments */
+               if (rx_queue->scatter_n) {
+                       efx_rx_packet(
+                               rx_queue,
+                               rx_queue->removed_count & rx_queue->ptr_mask,
+                               rx_queue->scatter_n, 0, EFX_RX_PKT_DISCARD);
+                       rx_queue->removed_count += rx_queue->scatter_n;
+                       rx_queue->scatter_n = 0;
+               }
+
+               /* Return if there is no new fragment */
+               if (rx_ev_desc_ptr != expected_ptr)
+                       return;
+
+               /* Discard new fragment if not SOP */
+               if (!rx_ev_sop) {
+                       efx_rx_packet(
+                               rx_queue,
+                               rx_queue->removed_count & rx_queue->ptr_mask,
+                               1, 0, EFX_RX_PKT_DISCARD);
+                       ++rx_queue->removed_count;
+                       return;
+               }
+       }
+
+       ++rx_queue->scatter_n;
+       if (rx_ev_cont)
+               return;
+
+       rx_ev_byte_cnt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_BYTE_CNT);
+       rx_ev_pkt_ok = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PKT_OK);
+       rx_ev_hdr_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_HDR_TYPE);
+
+       if (likely(rx_ev_pkt_ok)) {
+               /* If packet is marked as OK then we can rely on the
+                * hardware checksum and classification.
+                */
+               flags = 0;
+               switch (rx_ev_hdr_type) {
+               case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP:
+                       flags |= EFX_RX_PKT_TCP;
+                       /* fall through */
+               case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP:
+                       flags |= EFX_RX_PKT_CSUMMED;
+                       /* fall through */
+               case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER:
+               case FSE_AZ_RX_EV_HDR_TYPE_OTHER:
+                       break;
+               }
+       } else {
+               flags = efx_farch_handle_rx_not_ok(rx_queue, event);
+       }
+
+       /* Detect multicast packets that didn't match the filter */
+       rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_PKT);
+       if (rx_ev_mcast_pkt) {
+               unsigned int rx_ev_mcast_hash_match =
+                       EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_HASH_MATCH);
+
+               if (unlikely(!rx_ev_mcast_hash_match)) {
+                       ++channel->n_rx_mcast_mismatch;
+                       flags |= EFX_RX_PKT_DISCARD;
+               }
+       }
+
+       channel->irq_mod_score += 2;
+
+       /* Handle received packet */
+       efx_rx_packet(rx_queue,
+                     rx_queue->removed_count & rx_queue->ptr_mask,
+                     rx_queue->scatter_n, rx_ev_byte_cnt, flags);
+       rx_queue->removed_count += rx_queue->scatter_n;
+       rx_queue->scatter_n = 0;
+}
+
+/* If this flush done event corresponds to a &struct efx_tx_queue, then
+ * send an %EFX_CHANNEL_MAGIC_TX_DRAIN event to drain the event queue
+ * of all transmit completions.
+ */
+static void
+efx_farch_handle_tx_flush_done(struct efx_nic *efx, efx_qword_t *event)
+{
+       struct efx_tx_queue *tx_queue;
+       int qid;
+
+       qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA);
+       if (qid < EFX_TXQ_TYPES * efx->n_tx_channels) {
+               tx_queue = efx_get_tx_queue(efx, qid / EFX_TXQ_TYPES,
+                                           qid % EFX_TXQ_TYPES);
+               if (atomic_cmpxchg(&tx_queue->flush_outstanding, 1, 0)) {
+                       efx_farch_magic_event(tx_queue->channel,
+                                             EFX_CHANNEL_MAGIC_TX_DRAIN(tx_queue));
+               }
+       }
+}
+
+/* If this flush done event corresponds to a &struct efx_rx_queue: If the flush
+ * was succesful then send an %EFX_CHANNEL_MAGIC_RX_DRAIN, otherwise add
+ * the RX queue back to the mask of RX queues in need of flushing.
+ */
+static void
+efx_farch_handle_rx_flush_done(struct efx_nic *efx, efx_qword_t *event)
+{
+       struct efx_channel *channel;
+       struct efx_rx_queue *rx_queue;
+       int qid;
+       bool failed;
+
+       qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_DESCQ_ID);
+       failed = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL);
+       if (qid >= efx->n_channels)
+               return;
+       channel = efx_get_channel(efx, qid);
+       if (!efx_channel_has_rx_queue(channel))
+               return;
+       rx_queue = efx_channel_get_rx_queue(channel);
+
+       if (failed) {
+               netif_info(efx, hw, efx->net_dev,
+                          "RXQ %d flush retry\n", qid);
+               rx_queue->flush_pending = true;
+               atomic_inc(&efx->rxq_flush_pending);
+       } else {
+               efx_farch_magic_event(efx_rx_queue_channel(rx_queue),
+                                     EFX_CHANNEL_MAGIC_RX_DRAIN(rx_queue));
+       }
+       atomic_dec(&efx->rxq_flush_outstanding);
+       if (efx_farch_flush_wake(efx))
+               wake_up(&efx->flush_wq);
+}
+
+static void
+efx_farch_handle_drain_event(struct efx_channel *channel)
+{
+       struct efx_nic *efx = channel->efx;
+
+       WARN_ON(atomic_read(&efx->drain_pending) == 0);
+       atomic_dec(&efx->drain_pending);
+       if (efx_farch_flush_wake(efx))
+               wake_up(&efx->flush_wq);
+}
+
+static void efx_farch_handle_generated_event(struct efx_channel *channel,
+                                            efx_qword_t *event)
+{
+       struct efx_nic *efx = channel->efx;
+       struct efx_rx_queue *rx_queue =
+               efx_channel_has_rx_queue(channel) ?
+               efx_channel_get_rx_queue(channel) : NULL;
+       unsigned magic, code;
+
+       magic = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC);
+       code = _EFX_CHANNEL_MAGIC_CODE(magic);
+
+       if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) {
+               channel->event_test_cpu = raw_smp_processor_id();
+       } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_FILL(rx_queue)) {
+               /* The queue must be empty, so we won't receive any rx
+                * events, so efx_process_channel() won't refill the
+                * queue. Refill it here */
+               efx_fast_push_rx_descriptors(rx_queue);
+       } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_RX_DRAIN(rx_queue)) {
+               efx_farch_handle_drain_event(channel);
+       } else if (code == _EFX_CHANNEL_MAGIC_TX_DRAIN) {
+               efx_farch_handle_drain_event(channel);
+       } else {
+               netif_dbg(efx, hw, efx->net_dev, "channel %d received "
+                         "generated event "EFX_QWORD_FMT"\n",
+                         channel->channel, EFX_QWORD_VAL(*event));
+       }
+}
+
+static void
+efx_farch_handle_driver_event(struct efx_channel *channel, efx_qword_t *event)
+{
+       struct efx_nic *efx = channel->efx;
+       unsigned int ev_sub_code;
+       unsigned int ev_sub_data;
+
+       ev_sub_code = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBCODE);
+       ev_sub_data = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA);
+
+       switch (ev_sub_code) {
+       case FSE_AZ_TX_DESCQ_FLS_DONE_EV:
+               netif_vdbg(efx, hw, efx->net_dev, "channel %d TXQ %d flushed\n",
+                          channel->channel, ev_sub_data);
+               efx_farch_handle_tx_flush_done(efx, event);
+               efx_sriov_tx_flush_done(efx, event);
+               break;
+       case FSE_AZ_RX_DESCQ_FLS_DONE_EV:
+               netif_vdbg(efx, hw, efx->net_dev, "channel %d RXQ %d flushed\n",
+                          channel->channel, ev_sub_data);
+               efx_farch_handle_rx_flush_done(efx, event);
+               efx_sriov_rx_flush_done(efx, event);
+               break;
+       case FSE_AZ_EVQ_INIT_DONE_EV:
+               netif_dbg(efx, hw, efx->net_dev,
+                         "channel %d EVQ %d initialised\n",
+                         channel->channel, ev_sub_data);
+               break;
+       case FSE_AZ_SRM_UPD_DONE_EV:
+               netif_vdbg(efx, hw, efx->net_dev,
+                          "channel %d SRAM update done\n", channel->channel);
+               break;
+       case FSE_AZ_WAKE_UP_EV:
+               netif_vdbg(efx, hw, efx->net_dev,
+                          "channel %d RXQ %d wakeup event\n",
+                          channel->channel, ev_sub_data);
+               break;
+       case FSE_AZ_TIMER_EV:
+               netif_vdbg(efx, hw, efx->net_dev,
+                          "channel %d RX queue %d timer expired\n",
+                          channel->channel, ev_sub_data);
+               break;
+       case FSE_AA_RX_RECOVER_EV:
+               netif_err(efx, rx_err, efx->net_dev,
+                         "channel %d seen DRIVER RX_RESET event. "
+                       "Resetting.\n", channel->channel);
+               atomic_inc(&efx->rx_reset);
+               efx_schedule_reset(efx,
+                                  EFX_WORKAROUND_6555(efx) ?
+                                  RESET_TYPE_RX_RECOVERY :
+                                  RESET_TYPE_DISABLE);
+               break;
+       case FSE_BZ_RX_DSC_ERROR_EV:
+               if (ev_sub_data < EFX_VI_BASE) {
+                       netif_err(efx, rx_err, efx->net_dev,
+                                 "RX DMA Q %d reports descriptor fetch error."
+                                 " RX Q %d is disabled.\n", ev_sub_data,
+                                 ev_sub_data);
+                       efx_schedule_reset(efx, RESET_TYPE_DMA_ERROR);
+               } else
+                       efx_sriov_desc_fetch_err(efx, ev_sub_data);
+               break;
+       case FSE_BZ_TX_DSC_ERROR_EV:
+               if (ev_sub_data < EFX_VI_BASE) {
+                       netif_err(efx, tx_err, efx->net_dev,
+                                 "TX DMA Q %d reports descriptor fetch error."
+                                 " TX Q %d is disabled.\n", ev_sub_data,
+                                 ev_sub_data);
+                       efx_schedule_reset(efx, RESET_TYPE_DMA_ERROR);
+               } else
+                       efx_sriov_desc_fetch_err(efx, ev_sub_data);
+               break;
+       default:
+               netif_vdbg(efx, hw, efx->net_dev,
+                          "channel %d unknown driver event code %d "
+                          "data %04x\n", channel->channel, ev_sub_code,
+                          ev_sub_data);
+               break;
+       }
+}
+
+int efx_farch_ev_process(struct efx_channel *channel, int budget)
+{
+       struct efx_nic *efx = channel->efx;
+       unsigned int read_ptr;
+       efx_qword_t event, *p_event;
+       int ev_code;
+       int tx_packets = 0;
+       int spent = 0;
+
+       read_ptr = channel->eventq_read_ptr;
+
+       for (;;) {
+               p_event = efx_event(channel, read_ptr);
+               event = *p_event;
+
+               if (!efx_event_present(&event))
+                       /* End of events */
+                       break;
+
+               netif_vdbg(channel->efx, intr, channel->efx->net_dev,
+                          "channel %d event is "EFX_QWORD_FMT"\n",
+                          channel->channel, EFX_QWORD_VAL(event));
+
+               /* Clear this event by marking it all ones */
+               EFX_SET_QWORD(*p_event);
+
+               ++read_ptr;
+
+               ev_code = EFX_QWORD_FIELD(event, FSF_AZ_EV_CODE);
+
+               switch (ev_code) {
+               case FSE_AZ_EV_CODE_RX_EV:
+                       efx_farch_handle_rx_event(channel, &event);
+                       if (++spent == budget)
+                               goto out;
+                       break;
+               case FSE_AZ_EV_CODE_TX_EV:
+                       tx_packets += efx_farch_handle_tx_event(channel,
+                                                               &event);
+                       if (tx_packets > efx->txq_entries) {
+                               spent = budget;
+                               goto out;
+                       }
+                       break;
+               case FSE_AZ_EV_CODE_DRV_GEN_EV:
+                       efx_farch_handle_generated_event(channel, &event);
+                       break;
+               case FSE_AZ_EV_CODE_DRIVER_EV:
+                       efx_farch_handle_driver_event(channel, &event);
+                       break;
+               case FSE_CZ_EV_CODE_USER_EV:
+                       efx_sriov_event(channel, &event);
+                       break;
+               case FSE_CZ_EV_CODE_MCDI_EV:
+                       efx_mcdi_process_event(channel, &event);
+                       break;
+               case FSE_AZ_EV_CODE_GLOBAL_EV:
+                       if (efx->type->handle_global_event &&
+                           efx->type->handle_global_event(channel, &event))
+                               break;
+                       /* else fall through */
+               default:
+                       netif_err(channel->efx, hw, channel->efx->net_dev,
+                                 "channel %d unknown event type %d (data "
+                                 EFX_QWORD_FMT ")\n", channel->channel,
+                                 ev_code, EFX_QWORD_VAL(event));
+               }
+       }
+
+out:
+       channel->eventq_read_ptr = read_ptr;
+       return spent;
+}
+
+/* Allocate buffer table entries for event queue */
+int efx_farch_ev_probe(struct efx_channel *channel)
+{
+       struct efx_nic *efx = channel->efx;
+       unsigned entries;
+
+       entries = channel->eventq_mask + 1;
+       return efx_alloc_special_buffer(efx, &channel->eventq,
+                                       entries * sizeof(efx_qword_t));
+}
+
+void efx_farch_ev_init(struct efx_channel *channel)
+{
+       efx_oword_t reg;
+       struct efx_nic *efx = channel->efx;
+
+       netif_dbg(efx, hw, efx->net_dev,
+                 "channel %d event queue in special buffers %d-%d\n",
+                 channel->channel, channel->eventq.index,
+                 channel->eventq.index + channel->eventq.entries - 1);
+
+       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) {
+               EFX_POPULATE_OWORD_3(reg,
+                                    FRF_CZ_TIMER_Q_EN, 1,
+                                    FRF_CZ_HOST_NOTIFY_MODE, 0,
+                                    FRF_CZ_TIMER_MODE, FFE_CZ_TIMER_MODE_DIS);
+               efx_writeo_table(efx, &reg, FR_BZ_TIMER_TBL, channel->channel);
+       }
+
+       /* Pin event queue buffer */
+       efx_init_special_buffer(efx, &channel->eventq);
+
+       /* Fill event queue with all ones (i.e. empty events) */
+       memset(channel->eventq.buf.addr, 0xff, channel->eventq.buf.len);
+
+       /* Push event queue to card */
+       EFX_POPULATE_OWORD_3(reg,
+                            FRF_AZ_EVQ_EN, 1,
+                            FRF_AZ_EVQ_SIZE, __ffs(channel->eventq.entries),
+                            FRF_AZ_EVQ_BUF_BASE_ID, channel->eventq.index);
+       efx_writeo_table(efx, &reg, efx->type->evq_ptr_tbl_base,
+                        channel->channel);
+
+       efx->type->push_irq_moderation(channel);
+}
+
+void efx_farch_ev_fini(struct efx_channel *channel)
+{
+       efx_oword_t reg;
+       struct efx_nic *efx = channel->efx;
+
+       /* Remove event queue from card */
+       EFX_ZERO_OWORD(reg);
+       efx_writeo_table(efx, &reg, efx->type->evq_ptr_tbl_base,
+                        channel->channel);
+       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
+               efx_writeo_table(efx, &reg, FR_BZ_TIMER_TBL, channel->channel);
+
+       /* Unpin event queue */
+       efx_fini_special_buffer(efx, &channel->eventq);
+}
+
+/* Free buffers backing event queue */
+void efx_farch_ev_remove(struct efx_channel *channel)
+{
+       efx_free_special_buffer(channel->efx, &channel->eventq);
+}
+
+
+void efx_farch_ev_test_generate(struct efx_channel *channel)
+{
+       efx_farch_magic_event(channel, EFX_CHANNEL_MAGIC_TEST(channel));
+}
+
+void efx_farch_rx_defer_refill(struct efx_rx_queue *rx_queue)
+{
+       efx_farch_magic_event(efx_rx_queue_channel(rx_queue),
+                             EFX_CHANNEL_MAGIC_FILL(rx_queue));
+}
+
+/**************************************************************************
+ *
+ * Hardware interrupts
+ * The hardware interrupt handler does very little work; all the event
+ * queue processing is carried out by per-channel tasklets.
+ *
+ **************************************************************************/
+
+/* Enable/disable/generate interrupts */
+static inline void efx_farch_interrupts(struct efx_nic *efx,
+                                     bool enabled, bool force)
+{
+       efx_oword_t int_en_reg_ker;
+
+       EFX_POPULATE_OWORD_3(int_en_reg_ker,
+                            FRF_AZ_KER_INT_LEVE_SEL, efx->irq_level,
+                            FRF_AZ_KER_INT_KER, force,
+                            FRF_AZ_DRV_INT_EN_KER, enabled);
+       efx_writeo(efx, &int_en_reg_ker, FR_AZ_INT_EN_KER);
+}
+
+void efx_farch_irq_enable_master(struct efx_nic *efx)
+{
+       EFX_ZERO_OWORD(*((efx_oword_t *) efx->irq_status.addr));
+       wmb(); /* Ensure interrupt vector is clear before interrupts enabled */
+
+       efx_farch_interrupts(efx, true, false);
+}
+
+void efx_farch_irq_disable_master(struct efx_nic *efx)
+{
+       /* Disable interrupts */
+       efx_farch_interrupts(efx, false, false);
+}
+
+/* Generate a test interrupt
+ * Interrupt must already have been enabled, otherwise nasty things
+ * may happen.
+ */
+void efx_farch_irq_test_generate(struct efx_nic *efx)
+{
+       efx_farch_interrupts(efx, true, true);
+}
+
+/* Process a fatal interrupt
+ * Disable bus mastering ASAP and schedule a reset
+ */
+irqreturn_t efx_farch_fatal_interrupt(struct efx_nic *efx)
+{
+       struct falcon_nic_data *nic_data = efx->nic_data;
+       efx_oword_t *int_ker = efx->irq_status.addr;
+       efx_oword_t fatal_intr;
+       int error, mem_perr;
+
+       efx_reado(efx, &fatal_intr, FR_AZ_FATAL_INTR_KER);
+       error = EFX_OWORD_FIELD(fatal_intr, FRF_AZ_FATAL_INTR);
+
+       netif_err(efx, hw, efx->net_dev, "SYSTEM ERROR "EFX_OWORD_FMT" status "
+                 EFX_OWORD_FMT ": %s\n", EFX_OWORD_VAL(*int_ker),
+                 EFX_OWORD_VAL(fatal_intr),
+                 error ? "disabling bus mastering" : "no recognised error");
+
+       /* If this is a memory parity error dump which blocks are offending */
+       mem_perr = (EFX_OWORD_FIELD(fatal_intr, FRF_AZ_MEM_PERR_INT_KER) ||
+                   EFX_OWORD_FIELD(fatal_intr, FRF_AZ_SRM_PERR_INT_KER));
+       if (mem_perr) {
+               efx_oword_t reg;
+               efx_reado(efx, &reg, FR_AZ_MEM_STAT);
+               netif_err(efx, hw, efx->net_dev,
+                         "SYSTEM ERROR: memory parity error "EFX_OWORD_FMT"\n",
+                         EFX_OWORD_VAL(reg));
+       }
+
+       /* Disable both devices */
+       pci_clear_master(efx->pci_dev);
+       if (efx_nic_is_dual_func(efx))
+               pci_clear_master(nic_data->pci_dev2);
+       efx_farch_irq_disable_master(efx);
+
+       /* Count errors and reset or disable the NIC accordingly */
+       if (efx->int_error_count == 0 ||
+           time_after(jiffies, efx->int_error_expire)) {
+               efx->int_error_count = 0;
+               efx->int_error_expire =
+                       jiffies + EFX_INT_ERROR_EXPIRE * HZ;
+       }
+       if (++efx->int_error_count < EFX_MAX_INT_ERRORS) {
+               netif_err(efx, hw, efx->net_dev,
+                         "SYSTEM ERROR - reset scheduled\n");
+               efx_schedule_reset(efx, RESET_TYPE_INT_ERROR);
+       } else {
+               netif_err(efx, hw, efx->net_dev,
+                         "SYSTEM ERROR - max number of errors seen."
+                         "NIC will be disabled\n");
+               efx_schedule_reset(efx, RESET_TYPE_DISABLE);
+       }
+
+       return IRQ_HANDLED;
+}
+
+/* Handle a legacy interrupt
+ * Acknowledges the interrupt and schedule event queue processing.
+ */
+irqreturn_t efx_farch_legacy_interrupt(int irq, void *dev_id)
+{
+       struct efx_nic *efx = dev_id;
+       bool soft_enabled = ACCESS_ONCE(efx->irq_soft_enabled);
+       efx_oword_t *int_ker = efx->irq_status.addr;
+       irqreturn_t result = IRQ_NONE;
+       struct efx_channel *channel;
+       efx_dword_t reg;
+       u32 queues;
+       int syserr;
+
+       /* Read the ISR which also ACKs the interrupts */
+       efx_readd(efx, &reg, FR_BZ_INT_ISR0);
+       queues = EFX_EXTRACT_DWORD(reg, 0, 31);
+
+       /* Legacy interrupts are disabled too late by the EEH kernel
+        * code. Disable them earlier.
+        * If an EEH error occurred, the read will have returned all ones.
+        */
+       if (EFX_DWORD_IS_ALL_ONES(reg) && efx_try_recovery(efx) &&
+           !efx->eeh_disabled_legacy_irq) {
+               disable_irq_nosync(efx->legacy_irq);
+               efx->eeh_disabled_legacy_irq = true;
+       }
+
+       /* Handle non-event-queue sources */
+       if (queues & (1U << efx->irq_level) && soft_enabled) {
+               syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
+               if (unlikely(syserr))
+                       return efx_farch_fatal_interrupt(efx);
+               efx->last_irq_cpu = raw_smp_processor_id();
+       }
+
+       if (queues != 0) {
+               efx->irq_zero_count = 0;
+
+               /* Schedule processing of any interrupting queues */
+               if (likely(soft_enabled)) {
+                       efx_for_each_channel(channel, efx) {
+                               if (queues & 1)
+                                       efx_schedule_channel_irq(channel);
+                               queues >>= 1;
+                       }
+               }
+               result = IRQ_HANDLED;
+
+       } else {
+               efx_qword_t *event;
+
+               /* Legacy ISR read can return zero once (SF bug 15783) */
+
+               /* We can't return IRQ_HANDLED more than once on seeing ISR=0
+                * because this might be a shared interrupt. */
+               if (efx->irq_zero_count++ == 0)
+                       result = IRQ_HANDLED;
+
+               /* Ensure we schedule or rearm all event queues */
+               if (likely(soft_enabled)) {
+                       efx_for_each_channel(channel, efx) {
+                               event = efx_event(channel,
+                                                 channel->eventq_read_ptr);
+                               if (efx_event_present(event))
+                                       efx_schedule_channel_irq(channel);
+                               else
+                                       efx_farch_ev_read_ack(channel);
+                       }
+               }
+       }
+
+       if (result == IRQ_HANDLED)
+               netif_vdbg(efx, intr, efx->net_dev,
+                          "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n",
+                          irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg));
+
+       return result;
+}
+
+/* Handle an MSI interrupt
+ *
+ * Handle an MSI hardware interrupt.  This routine schedules event
+ * queue processing.  No interrupt acknowledgement cycle is necessary.
+ * Also, we never need to check that the interrupt is for us, since
+ * MSI interrupts cannot be shared.
+ */
+irqreturn_t efx_farch_msi_interrupt(int irq, void *dev_id)
+{
+       struct efx_msi_context *context = dev_id;
+       struct efx_nic *efx = context->efx;
+       efx_oword_t *int_ker = efx->irq_status.addr;
+       int syserr;
+
+       netif_vdbg(efx, intr, efx->net_dev,
+                  "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
+                  irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
+
+       if (!likely(ACCESS_ONCE(efx->irq_soft_enabled)))
+               return IRQ_HANDLED;
+
+       /* Handle non-event-queue sources */
+       if (context->index == efx->irq_level) {
+               syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
+               if (unlikely(syserr))
+                       return efx_farch_fatal_interrupt(efx);
+               efx->last_irq_cpu = raw_smp_processor_id();
+       }
+
+       /* Schedule processing of the channel */
+       efx_schedule_channel_irq(efx->channel[context->index]);
+
+       return IRQ_HANDLED;
+}
+
+
+/* Setup RSS indirection table.
+ * This maps from the hash value of the packet to RXQ
+ */
+void efx_farch_rx_push_indir_table(struct efx_nic *efx)
+{
+       size_t i = 0;
+       efx_dword_t dword;
+
+       if (efx_nic_rev(efx) < EFX_REV_FALCON_B0)
+               return;
+
+       BUILD_BUG_ON(ARRAY_SIZE(efx->rx_indir_table) !=
+                    FR_BZ_RX_INDIRECTION_TBL_ROWS);
+
+       for (i = 0; i < FR_BZ_RX_INDIRECTION_TBL_ROWS; i++) {
+               EFX_POPULATE_DWORD_1(dword, FRF_BZ_IT_QUEUE,
+                                    efx->rx_indir_table[i]);
+               efx_writed(efx, &dword,
+                          FR_BZ_RX_INDIRECTION_TBL +
+                          FR_BZ_RX_INDIRECTION_TBL_STEP * i);
+       }
+}
+
+/* Looks at available SRAM resources and works out how many queues we
+ * can support, and where things like descriptor caches should live.
+ *
+ * SRAM is split up as follows:
+ * 0                          buftbl entries for channels
+ * efx->vf_buftbl_base        buftbl entries for SR-IOV
+ * efx->rx_dc_base            RX descriptor caches
+ * efx->tx_dc_base            TX descriptor caches
+ */
+void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw)
+{
+       unsigned vi_count, buftbl_min;
+
+       /* Account for the buffer table entries backing the datapath channels
+        * and the descriptor caches for those channels.
+        */
+       buftbl_min = ((efx->n_rx_channels * EFX_MAX_DMAQ_SIZE +
+                      efx->n_tx_channels * EFX_TXQ_TYPES * EFX_MAX_DMAQ_SIZE +
+                      efx->n_channels * EFX_MAX_EVQ_SIZE)
+                     * sizeof(efx_qword_t) / EFX_BUF_SIZE);
+       vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES);
+
+#ifdef CONFIG_SFC_SRIOV
+       if (efx_sriov_wanted(efx)) {
+               unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit;
+
+               efx->vf_buftbl_base = buftbl_min;
+
+               vi_dc_entries = RX_DC_ENTRIES + TX_DC_ENTRIES;
+               vi_count = max(vi_count, EFX_VI_BASE);
+               buftbl_free = (sram_lim_qw - buftbl_min -
+                              vi_count * vi_dc_entries);
+
+               entries_per_vf = ((vi_dc_entries + EFX_VF_BUFTBL_PER_VI) *
+                                 efx_vf_size(efx));
+               vf_limit = min(buftbl_free / entries_per_vf,
+                              (1024U - EFX_VI_BASE) >> efx->vi_scale);
+
+               if (efx->vf_count > vf_limit) {
+                       netif_err(efx, probe, efx->net_dev,
+                                 "Reducing VF count from from %d to %d\n",
+                                 efx->vf_count, vf_limit);
+                       efx->vf_count = vf_limit;
+               }
+               vi_count += efx->vf_count * efx_vf_size(efx);
+       }
+#endif
+
+       efx->tx_dc_base = sram_lim_qw - vi_count * TX_DC_ENTRIES;
+       efx->rx_dc_base = efx->tx_dc_base - vi_count * RX_DC_ENTRIES;
+}
+
+u32 efx_farch_fpga_ver(struct efx_nic *efx)
+{
+       efx_oword_t altera_build;
+       efx_reado(efx, &altera_build, FR_AZ_ALTERA_BUILD);
+       return EFX_OWORD_FIELD(altera_build, FRF_AZ_ALTERA_BUILD_VER);
+}
+
+void efx_farch_init_common(struct efx_nic *efx)
+{
+       efx_oword_t temp;
+
+       /* Set positions of descriptor caches in SRAM. */
+       EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_TX_DC_BASE_ADR, efx->tx_dc_base);
+       efx_writeo(efx, &temp, FR_AZ_SRM_TX_DC_CFG);
+       EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_RX_DC_BASE_ADR, efx->rx_dc_base);
+       efx_writeo(efx, &temp, FR_AZ_SRM_RX_DC_CFG);
+
+       /* Set TX descriptor cache size. */
+       BUILD_BUG_ON(TX_DC_ENTRIES != (8 << TX_DC_ENTRIES_ORDER));
+       EFX_POPULATE_OWORD_1(temp, FRF_AZ_TX_DC_SIZE, TX_DC_ENTRIES_ORDER);
+       efx_writeo(efx, &temp, FR_AZ_TX_DC_CFG);
+
+       /* Set RX descriptor cache size.  Set low watermark to size-8, as
+        * this allows most efficient prefetching.
+        */
+       BUILD_BUG_ON(RX_DC_ENTRIES != (8 << RX_DC_ENTRIES_ORDER));
+       EFX_POPULATE_OWORD_1(temp, FRF_AZ_RX_DC_SIZE, RX_DC_ENTRIES_ORDER);
+       efx_writeo(efx, &temp, FR_AZ_RX_DC_CFG);
+       EFX_POPULATE_OWORD_1(temp, FRF_AZ_RX_DC_PF_LWM, RX_DC_ENTRIES - 8);
+       efx_writeo(efx, &temp, FR_AZ_RX_DC_PF_WM);
+
+       /* Program INT_KER address */
+       EFX_POPULATE_OWORD_2(temp,
+                            FRF_AZ_NORM_INT_VEC_DIS_KER,
+                            EFX_INT_MODE_USE_MSI(efx),
+                            FRF_AZ_INT_ADR_KER, efx->irq_status.dma_addr);
+       efx_writeo(efx, &temp, FR_AZ_INT_ADR_KER);
+
+       if (EFX_WORKAROUND_17213(efx) && !EFX_INT_MODE_USE_MSI(efx))
+               /* Use an interrupt level unused by event queues */
+               efx->irq_level = 0x1f;
+       else
+               /* Use a valid MSI-X vector */
+               efx->irq_level = 0;
+
+       /* Enable all the genuinely fatal interrupts.  (They are still
+        * masked by the overall interrupt mask, controlled by
+        * falcon_interrupts()).
+        *
+        * Note: All other fatal interrupts are enabled
+        */
+       EFX_POPULATE_OWORD_3(temp,
+                            FRF_AZ_ILL_ADR_INT_KER_EN, 1,
+                            FRF_AZ_RBUF_OWN_INT_KER_EN, 1,
+                            FRF_AZ_TBUF_OWN_INT_KER_EN, 1);
+       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
+               EFX_SET_OWORD_FIELD(temp, FRF_CZ_SRAM_PERR_INT_P_KER_EN, 1);
+       EFX_INVERT_OWORD(temp);
+       efx_writeo(efx, &temp, FR_AZ_FATAL_INTR_KER);
+
+       efx_farch_rx_push_indir_table(efx);
+
+       /* Disable the ugly timer-based TX DMA backoff and allow TX DMA to be
+        * controlled by the RX FIFO fill level. Set arbitration to one pkt/Q.
+        */
+       efx_reado(efx, &temp, FR_AZ_TX_RESERVED);
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_RX_SPACER, 0xfe);
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_RX_SPACER_EN, 1);
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_ONE_PKT_PER_Q, 1);
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PUSH_EN, 1);
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_DIS_NON_IP_EV, 1);
+       /* Enable SW_EV to inherit in char driver - assume harmless here */
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_SOFT_EVT_EN, 1);
+       /* Prefetch threshold 2 => fetch when descriptor cache half empty */
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PREF_THRESHOLD, 2);
+       /* Disable hardware watchdog which can misfire */
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PREF_WD_TMR, 0x3fffff);
+       /* Squash TX of packets of 16 bytes or less */
+       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0)
+               EFX_SET_OWORD_FIELD(temp, FRF_BZ_TX_FLUSH_MIN_LEN_EN, 1);
+       efx_writeo(efx, &temp, FR_AZ_TX_RESERVED);
+
+       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+               EFX_POPULATE_OWORD_4(temp,
+                                    /* Default values */
+                                    FRF_BZ_TX_PACE_SB_NOT_AF, 0x15,
+                                    FRF_BZ_TX_PACE_SB_AF, 0xb,
+                                    FRF_BZ_TX_PACE_FB_BASE, 0,
+                                    /* Allow large pace values in the
+                                     * fast bin. */
+                                    FRF_BZ_TX_PACE_BIN_TH,
+                                    FFE_BZ_TX_PACE_RESERVED);
+               efx_writeo(efx, &temp, FR_BZ_TX_PACE);
+       }
+}
+
+/**************************************************************************
+ *
+ * Filter tables
+ *
+ **************************************************************************
+ */
+
+/* "Fudge factors" - difference between programmed value and actual depth.
+ * Due to pipelined implementation we need to program H/W with a value that
+ * is larger than the hop limit we want.
+ */
+#define EFX_FARCH_FILTER_CTL_SRCH_FUDGE_WILD 3
+#define EFX_FARCH_FILTER_CTL_SRCH_FUDGE_FULL 1
+
+/* Hard maximum search limit.  Hardware will time-out beyond 200-something.
+ * We also need to avoid infinite loops in efx_farch_filter_search() when the
+ * table is full.
+ */
+#define EFX_FARCH_FILTER_CTL_SRCH_MAX 200
+
+/* Don't try very hard to find space for performance hints, as this is
+ * counter-productive. */
+#define EFX_FARCH_FILTER_CTL_SRCH_HINT_MAX 5
+
+enum efx_farch_filter_type {
+       EFX_FARCH_FILTER_TCP_FULL = 0,
+       EFX_FARCH_FILTER_TCP_WILD,
+       EFX_FARCH_FILTER_UDP_FULL,
+       EFX_FARCH_FILTER_UDP_WILD,
+       EFX_FARCH_FILTER_MAC_FULL = 4,
+       EFX_FARCH_FILTER_MAC_WILD,
+       EFX_FARCH_FILTER_UC_DEF = 8,
+       EFX_FARCH_FILTER_MC_DEF,
+       EFX_FARCH_FILTER_TYPE_COUNT,            /* number of specific types */
+};
+
+enum efx_farch_filter_table_id {
+       EFX_FARCH_FILTER_TABLE_RX_IP = 0,
+       EFX_FARCH_FILTER_TABLE_RX_MAC,
+       EFX_FARCH_FILTER_TABLE_RX_DEF,
+       EFX_FARCH_FILTER_TABLE_TX_MAC,
+       EFX_FARCH_FILTER_TABLE_COUNT,
+};
+
+enum efx_farch_filter_index {
+       EFX_FARCH_FILTER_INDEX_UC_DEF,
+       EFX_FARCH_FILTER_INDEX_MC_DEF,
+       EFX_FARCH_FILTER_SIZE_RX_DEF,
+};
+
+struct efx_farch_filter_spec {
+       u8      type:4;
+       u8      priority:4;
+       u8      flags;
+       u16     dmaq_id;
+       u32     data[3];
+};
+
+struct efx_farch_filter_table {
+       enum efx_farch_filter_table_id id;
+       u32             offset;         /* address of table relative to BAR */
+       unsigned        size;           /* number of entries */
+       unsigned        step;           /* step between entries */
+       unsigned        used;           /* number currently used */
+       unsigned long   *used_bitmap;
+       struct efx_farch_filter_spec *spec;
+       unsigned        search_limit[EFX_FARCH_FILTER_TYPE_COUNT];
+};
+
+struct efx_farch_filter_state {
+       struct efx_farch_filter_table table[EFX_FARCH_FILTER_TABLE_COUNT];
+};
+
+static void
+efx_farch_filter_table_clear_entry(struct efx_nic *efx,
+                                  struct efx_farch_filter_table *table,
+                                  unsigned int filter_idx);
+
+/* The filter hash function is LFSR polynomial x^16 + x^3 + 1 of a 32-bit
+ * key derived from the n-tuple.  The initial LFSR state is 0xffff. */
+static u16 efx_farch_filter_hash(u32 key)
+{
+       u16 tmp;
+
+       /* First 16 rounds */
+       tmp = 0x1fff ^ key >> 16;
+       tmp = tmp ^ tmp >> 3 ^ tmp >> 6;
+       tmp = tmp ^ tmp >> 9;
+       /* Last 16 rounds */
+       tmp = tmp ^ tmp << 13 ^ key;
+       tmp = tmp ^ tmp >> 3 ^ tmp >> 6;
+       return tmp ^ tmp >> 9;
+}
+
+/* To allow for hash collisions, filter search continues at these
+ * increments from the first possible entry selected by the hash. */
+static u16 efx_farch_filter_increment(u32 key)
+{
+       return key * 2 - 1;
+}
+
+static enum efx_farch_filter_table_id
+efx_farch_filter_spec_table_id(const struct efx_farch_filter_spec *spec)
+{
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_RX_IP !=
+                    (EFX_FARCH_FILTER_TCP_FULL >> 2));
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_RX_IP !=
+                    (EFX_FARCH_FILTER_TCP_WILD >> 2));
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_RX_IP !=
+                    (EFX_FARCH_FILTER_UDP_FULL >> 2));
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_RX_IP !=
+                    (EFX_FARCH_FILTER_UDP_WILD >> 2));
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_RX_MAC !=
+                    (EFX_FARCH_FILTER_MAC_FULL >> 2));
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_RX_MAC !=
+                    (EFX_FARCH_FILTER_MAC_WILD >> 2));
+       BUILD_BUG_ON(EFX_FARCH_FILTER_TABLE_TX_MAC !=
+                    EFX_FARCH_FILTER_TABLE_RX_MAC + 2);
+       return (spec->type >> 2) + ((spec->flags & EFX_FILTER_FLAG_TX) ? 2 : 0);
+}
+
+static void efx_farch_filter_push_rx_config(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       struct efx_farch_filter_table *table;
+       efx_oword_t filter_ctl;
+
+       efx_reado(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL);
+
+       table = &state->table[EFX_FARCH_FILTER_TABLE_RX_IP];
+       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_TCP_FULL_SRCH_LIMIT,
+                           table->search_limit[EFX_FARCH_FILTER_TCP_FULL] +
+                           EFX_FARCH_FILTER_CTL_SRCH_FUDGE_FULL);
+       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_TCP_WILD_SRCH_LIMIT,
+                           table->search_limit[EFX_FARCH_FILTER_TCP_WILD] +
+                           EFX_FARCH_FILTER_CTL_SRCH_FUDGE_WILD);
+       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_UDP_FULL_SRCH_LIMIT,
+                           table->search_limit[EFX_FARCH_FILTER_UDP_FULL] +
+                           EFX_FARCH_FILTER_CTL_SRCH_FUDGE_FULL);
+       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_UDP_WILD_SRCH_LIMIT,
+                           table->search_limit[EFX_FARCH_FILTER_UDP_WILD] +
+                           EFX_FARCH_FILTER_CTL_SRCH_FUDGE_WILD);
+
+       table = &state->table[EFX_FARCH_FILTER_TABLE_RX_MAC];
+       if (table->size) {
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_CZ_ETHERNET_FULL_SEARCH_LIMIT,
+                       table->search_limit[EFX_FARCH_FILTER_MAC_FULL] +
+                       EFX_FARCH_FILTER_CTL_SRCH_FUDGE_FULL);
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_CZ_ETHERNET_WILDCARD_SEARCH_LIMIT,
+                       table->search_limit[EFX_FARCH_FILTER_MAC_WILD] +
+                       EFX_FARCH_FILTER_CTL_SRCH_FUDGE_WILD);
+       }
+
+       table = &state->table[EFX_FARCH_FILTER_TABLE_RX_DEF];
+       if (table->size) {
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_CZ_UNICAST_NOMATCH_Q_ID,
+                       table->spec[EFX_FARCH_FILTER_INDEX_UC_DEF].dmaq_id);
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED,
+                       !!(table->spec[EFX_FARCH_FILTER_INDEX_UC_DEF].flags &
+                          EFX_FILTER_FLAG_RX_RSS));
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_CZ_MULTICAST_NOMATCH_Q_ID,
+                       table->spec[EFX_FARCH_FILTER_INDEX_MC_DEF].dmaq_id);
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED,
+                       !!(table->spec[EFX_FARCH_FILTER_INDEX_MC_DEF].flags &
+                          EFX_FILTER_FLAG_RX_RSS));
+
+               /* There is a single bit to enable RX scatter for all
+                * unmatched packets.  Only set it if scatter is
+                * enabled in both filter specs.
+                */
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_BZ_SCATTER_ENBL_NO_MATCH_Q,
+                       !!(table->spec[EFX_FARCH_FILTER_INDEX_UC_DEF].flags &
+                          table->spec[EFX_FARCH_FILTER_INDEX_MC_DEF].flags &
+                          EFX_FILTER_FLAG_RX_SCATTER));
+       } else if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+               /* We don't expose 'default' filters because unmatched
+                * packets always go to the queue number found in the
+                * RSS table.  But we still need to set the RX scatter
+                * bit here.
+                */
+               EFX_SET_OWORD_FIELD(
+                       filter_ctl, FRF_BZ_SCATTER_ENBL_NO_MATCH_Q,
+                       efx->rx_scatter);
+       }
+
+       efx_writeo(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL);
+}
+
+static void efx_farch_filter_push_tx_limits(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       struct efx_farch_filter_table *table;
+       efx_oword_t tx_cfg;
+
+       efx_reado(efx, &tx_cfg, FR_AZ_TX_CFG);
+
+       table = &state->table[EFX_FARCH_FILTER_TABLE_TX_MAC];
+       if (table->size) {
+               EFX_SET_OWORD_FIELD(
+                       tx_cfg, FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE,
+                       table->search_limit[EFX_FARCH_FILTER_MAC_FULL] +
+                       EFX_FARCH_FILTER_CTL_SRCH_FUDGE_FULL);
+               EFX_SET_OWORD_FIELD(
+                       tx_cfg, FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE,
+                       table->search_limit[EFX_FARCH_FILTER_MAC_WILD] +
+                       EFX_FARCH_FILTER_CTL_SRCH_FUDGE_WILD);
+       }
+
+       efx_writeo(efx, &tx_cfg, FR_AZ_TX_CFG);
+}
+
+static int
+efx_farch_filter_from_gen_spec(struct efx_farch_filter_spec *spec,
+                              const struct efx_filter_spec *gen_spec)
+{
+       bool is_full = false;
+
+       if ((gen_spec->flags & EFX_FILTER_FLAG_RX_RSS) &&
+           gen_spec->rss_context != EFX_FILTER_RSS_CONTEXT_DEFAULT)
+               return -EINVAL;
+
+       spec->priority = gen_spec->priority;
+       spec->flags = gen_spec->flags;
+       spec->dmaq_id = gen_spec->dmaq_id;
+
+       switch (gen_spec->match_flags) {
+       case (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
+             EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT |
+             EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_REM_PORT):
+               is_full = true;
+               /* fall through */
+       case (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
+             EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT): {
+               __be32 rhost, host1, host2;
+               __be16 rport, port1, port2;
+
+               EFX_BUG_ON_PARANOID(!(gen_spec->flags & EFX_FILTER_FLAG_RX));
+
+               if (gen_spec->ether_type != htons(ETH_P_IP))
+                       return -EPROTONOSUPPORT;
+               if (gen_spec->loc_port == 0 ||
+                   (is_full && gen_spec->rem_port == 0))
+                       return -EADDRNOTAVAIL;
+               switch (gen_spec->ip_proto) {
+               case IPPROTO_TCP:
+                       spec->type = (is_full ? EFX_FARCH_FILTER_TCP_FULL :
+                                     EFX_FARCH_FILTER_TCP_WILD);
+                       break;
+               case IPPROTO_UDP:
+                       spec->type = (is_full ? EFX_FARCH_FILTER_UDP_FULL :
+                                     EFX_FARCH_FILTER_UDP_WILD);
+                       break;
+               default:
+                       return -EPROTONOSUPPORT;
+               }
+
+               /* Filter is constructed in terms of source and destination,
+                * with the odd wrinkle that the ports are swapped in a UDP
+                * wildcard filter.  We need to convert from local and remote
+                * (= zero for wildcard) addresses.
+                */
+               rhost = is_full ? gen_spec->rem_host[0] : 0;
+               rport = is_full ? gen_spec->rem_port : 0;
+               host1 = rhost;
+               host2 = gen_spec->loc_host[0];
+               if (!is_full && gen_spec->ip_proto == IPPROTO_UDP) {
+                       port1 = gen_spec->loc_port;
+                       port2 = rport;
+               } else {
+                       port1 = rport;
+                       port2 = gen_spec->loc_port;
+               }
+               spec->data[0] = ntohl(host1) << 16 | ntohs(port1);
+               spec->data[1] = ntohs(port2) << 16 | ntohl(host1) >> 16;
+               spec->data[2] = ntohl(host2);
+
+               break;
+       }
+
+       case EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_OUTER_VID:
+               is_full = true;
+               /* fall through */
+       case EFX_FILTER_MATCH_LOC_MAC:
+               spec->type = (is_full ? EFX_FARCH_FILTER_MAC_FULL :
+                             EFX_FARCH_FILTER_MAC_WILD);
+               spec->data[0] = is_full ? ntohs(gen_spec->outer_vid) : 0;
+               spec->data[1] = (gen_spec->loc_mac[2] << 24 |
+                                gen_spec->loc_mac[3] << 16 |
+                                gen_spec->loc_mac[4] << 8 |
+                                gen_spec->loc_mac[5]);
+               spec->data[2] = (gen_spec->loc_mac[0] << 8 |
+                                gen_spec->loc_mac[1]);
+               break;
+
+       case EFX_FILTER_MATCH_LOC_MAC_IG:
+               spec->type = (is_multicast_ether_addr(gen_spec->loc_mac) ?
+                             EFX_FARCH_FILTER_MC_DEF :
+                             EFX_FARCH_FILTER_UC_DEF);
+               memset(spec->data, 0, sizeof(spec->data)); /* ensure equality */
+               break;
+
+       default:
+               return -EPROTONOSUPPORT;
+       }
+
+       return 0;
+}
+
+static void
+efx_farch_filter_to_gen_spec(struct efx_filter_spec *gen_spec,
+                            const struct efx_farch_filter_spec *spec)
+{
+       bool is_full = false;
+
+       /* *gen_spec should be completely initialised, to be consistent
+        * with efx_filter_init_{rx,tx}() and in case we want to copy
+        * it back to userland.
+        */
+       memset(gen_spec, 0, sizeof(*gen_spec));
+
+       gen_spec->priority = spec->priority;
+       gen_spec->flags = spec->flags;
+       gen_spec->dmaq_id = spec->dmaq_id;
+
+       switch (spec->type) {
+       case EFX_FARCH_FILTER_TCP_FULL:
+       case EFX_FARCH_FILTER_UDP_FULL:
+               is_full = true;
+               /* fall through */
+       case EFX_FARCH_FILTER_TCP_WILD:
+       case EFX_FARCH_FILTER_UDP_WILD: {
+               __be32 host1, host2;
+               __be16 port1, port2;
+
+               gen_spec->match_flags =
+                       EFX_FILTER_MATCH_ETHER_TYPE |
+                       EFX_FILTER_MATCH_IP_PROTO |
+                       EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT;
+               if (is_full)
+                       gen_spec->match_flags |= (EFX_FILTER_MATCH_REM_HOST |
+                                                 EFX_FILTER_MATCH_REM_PORT);
+               gen_spec->ether_type = htons(ETH_P_IP);
+               gen_spec->ip_proto =
+                       (spec->type == EFX_FARCH_FILTER_TCP_FULL ||
+                        spec->type == EFX_FARCH_FILTER_TCP_WILD) ?
+                       IPPROTO_TCP : IPPROTO_UDP;
+
+               host1 = htonl(spec->data[0] >> 16 | spec->data[1] << 16);
+               port1 = htons(spec->data[0]);
+               host2 = htonl(spec->data[2]);
+               port2 = htons(spec->data[1] >> 16);
+               if (spec->flags & EFX_FILTER_FLAG_TX) {
+                       gen_spec->loc_host[0] = host1;
+                       gen_spec->rem_host[0] = host2;
+               } else {
+                       gen_spec->loc_host[0] = host2;
+                       gen_spec->rem_host[0] = host1;
+               }
+               if (!!(gen_spec->flags & EFX_FILTER_FLAG_TX) ^
+                   (!is_full && gen_spec->ip_proto == IPPROTO_UDP)) {
+                       gen_spec->loc_port = port1;
+                       gen_spec->rem_port = port2;
+               } else {
+                       gen_spec->loc_port = port2;
+                       gen_spec->rem_port = port1;
+               }
+
+               break;
+       }
+
+       case EFX_FARCH_FILTER_MAC_FULL:
+               is_full = true;
+               /* fall through */
+       case EFX_FARCH_FILTER_MAC_WILD:
+               gen_spec->match_flags = EFX_FILTER_MATCH_LOC_MAC;
+               if (is_full)
+                       gen_spec->match_flags |= EFX_FILTER_MATCH_OUTER_VID;
+               gen_spec->loc_mac[0] = spec->data[2] >> 8;
+               gen_spec->loc_mac[1] = spec->data[2];
+               gen_spec->loc_mac[2] = spec->data[1] >> 24;
+               gen_spec->loc_mac[3] = spec->data[1] >> 16;
+               gen_spec->loc_mac[4] = spec->data[1] >> 8;
+               gen_spec->loc_mac[5] = spec->data[1];
+               gen_spec->outer_vid = htons(spec->data[0]);
+               break;
+
+       case EFX_FARCH_FILTER_UC_DEF:
+       case EFX_FARCH_FILTER_MC_DEF:
+               gen_spec->match_flags = EFX_FILTER_MATCH_LOC_MAC_IG;
+               gen_spec->loc_mac[0] = spec->type == EFX_FARCH_FILTER_MC_DEF;
+               break;
+
+       default:
+               WARN_ON(1);
+               break;
+       }
+}
+
+static void
+efx_farch_filter_init_rx_for_stack(struct efx_nic *efx,
+                                  struct efx_farch_filter_spec *spec)
+{
+       /* If there's only one channel then disable RSS for non VF
+        * traffic, thereby allowing VFs to use RSS when the PF can't.
+        */
+       spec->priority = EFX_FILTER_PRI_REQUIRED;
+       spec->flags = (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_RX_STACK |
+                      (efx->n_rx_channels > 1 ? EFX_FILTER_FLAG_RX_RSS : 0) |
+                      (efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0));
+       spec->dmaq_id = 0;
+}
+
+/* Build a filter entry and return its n-tuple key. */
+static u32 efx_farch_filter_build(efx_oword_t *filter,
+                                 struct efx_farch_filter_spec *spec)
+{
+       u32 data3;
+
+       switch (efx_farch_filter_spec_table_id(spec)) {
+       case EFX_FARCH_FILTER_TABLE_RX_IP: {
+               bool is_udp = (spec->type == EFX_FARCH_FILTER_UDP_FULL ||
+                              spec->type == EFX_FARCH_FILTER_UDP_WILD);
+               EFX_POPULATE_OWORD_7(
+                       *filter,
+                       FRF_BZ_RSS_EN,
+                       !!(spec->flags & EFX_FILTER_FLAG_RX_RSS),
+                       FRF_BZ_SCATTER_EN,
+                       !!(spec->flags & EFX_FILTER_FLAG_RX_SCATTER),
+                       FRF_BZ_TCP_UDP, is_udp,
+                       FRF_BZ_RXQ_ID, spec->dmaq_id,
+                       EFX_DWORD_2, spec->data[2],
+                       EFX_DWORD_1, spec->data[1],
+                       EFX_DWORD_0, spec->data[0]);
+               data3 = is_udp;
+               break;
+       }
+
+       case EFX_FARCH_FILTER_TABLE_RX_MAC: {
+               bool is_wild = spec->type == EFX_FARCH_FILTER_MAC_WILD;
+               EFX_POPULATE_OWORD_7(
+                       *filter,
+                       FRF_CZ_RMFT_RSS_EN,
+                       !!(spec->flags & EFX_FILTER_FLAG_RX_RSS),
+                       FRF_CZ_RMFT_SCATTER_EN,
+                       !!(spec->flags & EFX_FILTER_FLAG_RX_SCATTER),
+                       FRF_CZ_RMFT_RXQ_ID, spec->dmaq_id,
+                       FRF_CZ_RMFT_WILDCARD_MATCH, is_wild,
+                       FRF_CZ_RMFT_DEST_MAC_HI, spec->data[2],
+                       FRF_CZ_RMFT_DEST_MAC_LO, spec->data[1],
+                       FRF_CZ_RMFT_VLAN_ID, spec->data[0]);
+               data3 = is_wild;
+               break;
+       }
+
+       case EFX_FARCH_FILTER_TABLE_TX_MAC: {
+               bool is_wild = spec->type == EFX_FARCH_FILTER_MAC_WILD;
+               EFX_POPULATE_OWORD_5(*filter,
+                                    FRF_CZ_TMFT_TXQ_ID, spec->dmaq_id,
+                                    FRF_CZ_TMFT_WILDCARD_MATCH, is_wild,
+                                    FRF_CZ_TMFT_SRC_MAC_HI, spec->data[2],
+                                    FRF_CZ_TMFT_SRC_MAC_LO, spec->data[1],
+                                    FRF_CZ_TMFT_VLAN_ID, spec->data[0]);
+               data3 = is_wild | spec->dmaq_id << 1;
+               break;
+       }
+
+       default:
+               BUG();
+       }
+
+       return spec->data[0] ^ spec->data[1] ^ spec->data[2] ^ data3;
+}
+
+static bool efx_farch_filter_equal(const struct efx_farch_filter_spec *left,
+                                  const struct efx_farch_filter_spec *right)
+{
+       if (left->type != right->type ||
+           memcmp(left->data, right->data, sizeof(left->data)))
+               return false;
+
+       if (left->flags & EFX_FILTER_FLAG_TX &&
+           left->dmaq_id != right->dmaq_id)
+               return false;
+
+       return true;
+}
+
+/*
+ * Construct/deconstruct external filter IDs.  At least the RX filter
+ * IDs must be ordered by matching priority, for RX NFC semantics.
+ *
+ * Deconstruction needs to be robust against invalid IDs so that
+ * efx_filter_remove_id_safe() and efx_filter_get_filter_safe() can
+ * accept user-provided IDs.
+ */
+
+#define EFX_FARCH_FILTER_MATCH_PRI_COUNT       5
+
+static const u8 efx_farch_filter_type_match_pri[EFX_FARCH_FILTER_TYPE_COUNT] = {
+       [EFX_FARCH_FILTER_TCP_FULL]     = 0,
+       [EFX_FARCH_FILTER_UDP_FULL]     = 0,
+       [EFX_FARCH_FILTER_TCP_WILD]     = 1,
+       [EFX_FARCH_FILTER_UDP_WILD]     = 1,
+       [EFX_FARCH_FILTER_MAC_FULL]     = 2,
+       [EFX_FARCH_FILTER_MAC_WILD]     = 3,
+       [EFX_FARCH_FILTER_UC_DEF]       = 4,
+       [EFX_FARCH_FILTER_MC_DEF]       = 4,
+};
+
+static const enum efx_farch_filter_table_id efx_farch_filter_range_table[] = {
+       EFX_FARCH_FILTER_TABLE_RX_IP,   /* RX match pri 0 */
+       EFX_FARCH_FILTER_TABLE_RX_IP,
+       EFX_FARCH_FILTER_TABLE_RX_MAC,
+       EFX_FARCH_FILTER_TABLE_RX_MAC,
+       EFX_FARCH_FILTER_TABLE_RX_DEF,  /* RX match pri 4 */
+       EFX_FARCH_FILTER_TABLE_TX_MAC,  /* TX match pri 0 */
+       EFX_FARCH_FILTER_TABLE_TX_MAC,  /* TX match pri 1 */
+};
+
+#define EFX_FARCH_FILTER_INDEX_WIDTH 13
+#define EFX_FARCH_FILTER_INDEX_MASK ((1 << EFX_FARCH_FILTER_INDEX_WIDTH) - 1)
+
+static inline u32
+efx_farch_filter_make_id(const struct efx_farch_filter_spec *spec,
+                        unsigned int index)
+{
+       unsigned int range;
+
+       range = efx_farch_filter_type_match_pri[spec->type];
+       if (!(spec->flags & EFX_FILTER_FLAG_RX))
+               range += EFX_FARCH_FILTER_MATCH_PRI_COUNT;
+
+       return range << EFX_FARCH_FILTER_INDEX_WIDTH | index;
+}
+
+static inline enum efx_farch_filter_table_id
+efx_farch_filter_id_table_id(u32 id)
+{
+       unsigned int range = id >> EFX_FARCH_FILTER_INDEX_WIDTH;
+
+       if (range < ARRAY_SIZE(efx_farch_filter_range_table))
+               return efx_farch_filter_range_table[range];
+       else
+               return EFX_FARCH_FILTER_TABLE_COUNT; /* invalid */
+}
+
+static inline unsigned int efx_farch_filter_id_index(u32 id)
+{
+       return id & EFX_FARCH_FILTER_INDEX_MASK;
+}
+
+u32 efx_farch_filter_get_rx_id_limit(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       unsigned int range = EFX_FARCH_FILTER_MATCH_PRI_COUNT - 1;
+       enum efx_farch_filter_table_id table_id;
+
+       do {
+               table_id = efx_farch_filter_range_table[range];
+               if (state->table[table_id].size != 0)
+                       return range << EFX_FARCH_FILTER_INDEX_WIDTH |
+                               state->table[table_id].size;
+       } while (range--);
+
+       return 0;
+}
+
+s32 efx_farch_filter_insert(struct efx_nic *efx,
+                           struct efx_filter_spec *gen_spec,
+                           bool replace_equal)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       struct efx_farch_filter_table *table;
+       struct efx_farch_filter_spec spec;
+       efx_oword_t filter;
+       int rep_index, ins_index;
+       unsigned int depth = 0;
+       int rc;
+
+       rc = efx_farch_filter_from_gen_spec(&spec, gen_spec);
+       if (rc)
+               return rc;
+
+       table = &state->table[efx_farch_filter_spec_table_id(&spec)];
+       if (table->size == 0)
+               return -EINVAL;
+
+       netif_vdbg(efx, hw, efx->net_dev,
+                  "%s: type %d search_limit=%d", __func__, spec.type,
+                  table->search_limit[spec.type]);
+
+       if (table->id == EFX_FARCH_FILTER_TABLE_RX_DEF) {
+               /* One filter spec per type */
+               BUILD_BUG_ON(EFX_FARCH_FILTER_INDEX_UC_DEF != 0);
+               BUILD_BUG_ON(EFX_FARCH_FILTER_INDEX_MC_DEF !=
+                            EFX_FARCH_FILTER_MC_DEF - EFX_FARCH_FILTER_UC_DEF);
+               rep_index = spec.type - EFX_FARCH_FILTER_UC_DEF;
+               ins_index = rep_index;
+
+               spin_lock_bh(&efx->filter_lock);
+       } else {
+               /* Search concurrently for
+                * (1) a filter to be replaced (rep_index): any filter
+                *     with the same match values, up to the current
+                *     search depth for this type, and
+                * (2) the insertion point (ins_index): (1) or any
+                *     free slot before it or up to the maximum search
+                *     depth for this priority
+                * We fail if we cannot find (2).
+                *
+                * We can stop once either
+                * (a) we find (1), in which case we have definitely
+                *     found (2) as well; or
+                * (b) we have searched exhaustively for (1), and have
+                *     either found (2) or searched exhaustively for it
+                */
+               u32 key = efx_farch_filter_build(&filter, &spec);
+               unsigned int hash = efx_farch_filter_hash(key);
+               unsigned int incr = efx_farch_filter_increment(key);
+               unsigned int max_rep_depth = table->search_limit[spec.type];
+               unsigned int max_ins_depth =
+                       spec.priority <= EFX_FILTER_PRI_HINT ?
+                       EFX_FARCH_FILTER_CTL_SRCH_HINT_MAX :
+                       EFX_FARCH_FILTER_CTL_SRCH_MAX;
+               unsigned int i = hash & (table->size - 1);
+
+               ins_index = -1;
+               depth = 1;
+
+               spin_lock_bh(&efx->filter_lock);
+
+               for (;;) {
+                       if (!test_bit(i, table->used_bitmap)) {
+                               if (ins_index < 0)
+                                       ins_index = i;
+                       } else if (efx_farch_filter_equal(&spec,
+                                                         &table->spec[i])) {
+                               /* Case (a) */
+                               if (ins_index < 0)
+                                       ins_index = i;
+                               rep_index = i;
+                               break;
+                       }
+
+                       if (depth >= max_rep_depth &&
+                           (ins_index >= 0 || depth >= max_ins_depth)) {
+                               /* Case (b) */
+                               if (ins_index < 0) {
+                                       rc = -EBUSY;
+                                       goto out;
+                               }
+                               rep_index = -1;
+                               break;
+                       }
+
+                       i = (i + incr) & (table->size - 1);
+                       ++depth;
+               }
+       }
+
+       /* If we found a filter to be replaced, check whether we
+        * should do so
+        */
+       if (rep_index >= 0) {
+               struct efx_farch_filter_spec *saved_spec =
+                       &table->spec[rep_index];
+
+               if (spec.priority == saved_spec->priority && !replace_equal) {
+                       rc = -EEXIST;
+                       goto out;
+               }
+               if (spec.priority < saved_spec->priority &&
+                   !(saved_spec->priority == EFX_FILTER_PRI_REQUIRED &&
+                     saved_spec->flags & EFX_FILTER_FLAG_RX_STACK)) {
+                       rc = -EPERM;
+                       goto out;
+               }
+               if (spec.flags & EFX_FILTER_FLAG_RX_STACK) {
+                       /* Just make sure it won't be removed */
+                       saved_spec->flags |= EFX_FILTER_FLAG_RX_STACK;
+                       rc = 0;
+                       goto out;
+               }
+               /* Retain the RX_STACK flag */
+               spec.flags |= saved_spec->flags & EFX_FILTER_FLAG_RX_STACK;
+       }
+
+       /* Insert the filter */
+       if (ins_index != rep_index) {
+               __set_bit(ins_index, table->used_bitmap);
+               ++table->used;
+       }
+       table->spec[ins_index] = spec;
+
+       if (table->id == EFX_FARCH_FILTER_TABLE_RX_DEF) {
+               efx_farch_filter_push_rx_config(efx);
+       } else {
+               if (table->search_limit[spec.type] < depth) {
+                       table->search_limit[spec.type] = depth;
+                       if (spec.flags & EFX_FILTER_FLAG_TX)
+                               efx_farch_filter_push_tx_limits(efx);
+                       else
+                               efx_farch_filter_push_rx_config(efx);
+               }
+
+               efx_writeo(efx, &filter,
+                          table->offset + table->step * ins_index);
+
+               /* If we were able to replace a filter by inserting
+                * at a lower depth, clear the replaced filter
+                */
+               if (ins_index != rep_index && rep_index >= 0)
+                       efx_farch_filter_table_clear_entry(efx, table,
+                                                          rep_index);
+       }
+
+       netif_vdbg(efx, hw, efx->net_dev,
+                  "%s: filter type %d index %d rxq %u set",
+                  __func__, spec.type, ins_index, spec.dmaq_id);
+       rc = efx_farch_filter_make_id(&spec, ins_index);
+
+out:
+       spin_unlock_bh(&efx->filter_lock);
+       return rc;
+}
+
+static void
+efx_farch_filter_table_clear_entry(struct efx_nic *efx,
+                                  struct efx_farch_filter_table *table,
+                                  unsigned int filter_idx)
+{
+       static efx_oword_t filter;
+
+       EFX_WARN_ON_PARANOID(!test_bit(filter_idx, table->used_bitmap));
+       BUG_ON(table->offset == 0); /* can't clear MAC default filters */
+
+       __clear_bit(filter_idx, table->used_bitmap);
+       --table->used;
+       memset(&table->spec[filter_idx], 0, sizeof(table->spec[0]));
+
+       efx_writeo(efx, &filter, table->offset + table->step * filter_idx);
+
+       /* If this filter required a greater search depth than
+        * any other, the search limit for its type can now be
+        * decreased.  However, it is hard to determine that
+        * unless the table has become completely empty - in
+        * which case, all its search limits can be set to 0.
+        */
+       if (unlikely(table->used == 0)) {
+               memset(table->search_limit, 0, sizeof(table->search_limit));
+               if (table->id == EFX_FARCH_FILTER_TABLE_TX_MAC)
+                       efx_farch_filter_push_tx_limits(efx);
+               else
+                       efx_farch_filter_push_rx_config(efx);
+       }
+}
+
+static int efx_farch_filter_remove(struct efx_nic *efx,
+                                  struct efx_farch_filter_table *table,
+                                  unsigned int filter_idx,
+                                  enum efx_filter_priority priority)
+{
+       struct efx_farch_filter_spec *spec = &table->spec[filter_idx];
+
+       if (!test_bit(filter_idx, table->used_bitmap) ||
+           spec->priority > priority)
+               return -ENOENT;
+
+       if (spec->flags & EFX_FILTER_FLAG_RX_STACK) {
+               efx_farch_filter_init_rx_for_stack(efx, spec);
+               efx_farch_filter_push_rx_config(efx);
+       } else {
+               efx_farch_filter_table_clear_entry(efx, table, filter_idx);
+       }
+
+       return 0;
+}
+
+int efx_farch_filter_remove_safe(struct efx_nic *efx,
+                                enum efx_filter_priority priority,
+                                u32 filter_id)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+       struct efx_farch_filter_table *table;
+       unsigned int filter_idx;
+       struct efx_farch_filter_spec *spec;
+       int rc;
+
+       table_id = efx_farch_filter_id_table_id(filter_id);
+       if ((unsigned int)table_id >= EFX_FARCH_FILTER_TABLE_COUNT)
+               return -ENOENT;
+       table = &state->table[table_id];
+
+       filter_idx = efx_farch_filter_id_index(filter_id);
+       if (filter_idx >= table->size)
+               return -ENOENT;
+       spec = &table->spec[filter_idx];
+
+       spin_lock_bh(&efx->filter_lock);
+       rc = efx_farch_filter_remove(efx, table, filter_idx, priority);
+       spin_unlock_bh(&efx->filter_lock);
+
+       return rc;
+}
+
+int efx_farch_filter_get_safe(struct efx_nic *efx,
+                             enum efx_filter_priority priority,
+                             u32 filter_id, struct efx_filter_spec *spec_buf)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+       struct efx_farch_filter_table *table;
+       struct efx_farch_filter_spec *spec;
+       unsigned int filter_idx;
+       int rc;
+
+       table_id = efx_farch_filter_id_table_id(filter_id);
+       if ((unsigned int)table_id >= EFX_FARCH_FILTER_TABLE_COUNT)
+               return -ENOENT;
+       table = &state->table[table_id];
+
+       filter_idx = efx_farch_filter_id_index(filter_id);
+       if (filter_idx >= table->size)
+               return -ENOENT;
+       spec = &table->spec[filter_idx];
+
+       spin_lock_bh(&efx->filter_lock);
+
+       if (test_bit(filter_idx, table->used_bitmap) &&
+           spec->priority == priority) {
+               efx_farch_filter_to_gen_spec(spec_buf, spec);
+               rc = 0;
+       } else {
+               rc = -ENOENT;
+       }
+
+       spin_unlock_bh(&efx->filter_lock);
+
+       return rc;
+}
+
+static void
+efx_farch_filter_table_clear(struct efx_nic *efx,
+                            enum efx_farch_filter_table_id table_id,
+                            enum efx_filter_priority priority)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       struct efx_farch_filter_table *table = &state->table[table_id];
+       unsigned int filter_idx;
+
+       spin_lock_bh(&efx->filter_lock);
+       for (filter_idx = 0; filter_idx < table->size; ++filter_idx)
+               efx_farch_filter_remove(efx, table, filter_idx, priority);
+       spin_unlock_bh(&efx->filter_lock);
+}
+
+void efx_farch_filter_clear_rx(struct efx_nic *efx,
+                              enum efx_filter_priority priority)
+{
+       efx_farch_filter_table_clear(efx, EFX_FARCH_FILTER_TABLE_RX_IP,
+                                    priority);
+       efx_farch_filter_table_clear(efx, EFX_FARCH_FILTER_TABLE_RX_MAC,
+                                    priority);
+       efx_farch_filter_table_clear(efx, EFX_FARCH_FILTER_TABLE_RX_DEF,
+                                    priority);
+}
+
+u32 efx_farch_filter_count_rx_used(struct efx_nic *efx,
+                                  enum efx_filter_priority priority)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+       struct efx_farch_filter_table *table;
+       unsigned int filter_idx;
+       u32 count = 0;
+
+       spin_lock_bh(&efx->filter_lock);
+
+       for (table_id = EFX_FARCH_FILTER_TABLE_RX_IP;
+            table_id <= EFX_FARCH_FILTER_TABLE_RX_DEF;
+            table_id++) {
+               table = &state->table[table_id];
+               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
+                       if (test_bit(filter_idx, table->used_bitmap) &&
+                           table->spec[filter_idx].priority == priority)
+                               ++count;
+               }
+       }
+
+       spin_unlock_bh(&efx->filter_lock);
+
+       return count;
+}
+
+s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx,
+                               enum efx_filter_priority priority,
+                               u32 *buf, u32 size)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+       struct efx_farch_filter_table *table;
+       unsigned int filter_idx;
+       s32 count = 0;
+
+       spin_lock_bh(&efx->filter_lock);
+
+       for (table_id = EFX_FARCH_FILTER_TABLE_RX_IP;
+            table_id <= EFX_FARCH_FILTER_TABLE_RX_DEF;
+            table_id++) {
+               table = &state->table[table_id];
+               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
+                       if (test_bit(filter_idx, table->used_bitmap) &&
+                           table->spec[filter_idx].priority == priority) {
+                               if (count == size) {
+                                       count = -EMSGSIZE;
+                                       goto out;
+                               }
+                               buf[count++] = efx_farch_filter_make_id(
+                                       &table->spec[filter_idx], filter_idx);
+                       }
+               }
+       }
+out:
+       spin_unlock_bh(&efx->filter_lock);
+
+       return count;
+}
+
+/* Restore filter stater after reset */
+void efx_farch_filter_table_restore(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+       struct efx_farch_filter_table *table;
+       efx_oword_t filter;
+       unsigned int filter_idx;
+
+       spin_lock_bh(&efx->filter_lock);
+
+       for (table_id = 0; table_id < EFX_FARCH_FILTER_TABLE_COUNT; table_id++) {
+               table = &state->table[table_id];
+
+               /* Check whether this is a regular register table */
+               if (table->step == 0)
+                       continue;
+
+               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
+                       if (!test_bit(filter_idx, table->used_bitmap))
+                               continue;
+                       efx_farch_filter_build(&filter, &table->spec[filter_idx]);
+                       efx_writeo(efx, &filter,
+                                  table->offset + table->step * filter_idx);
+               }
+       }
+
+       efx_farch_filter_push_rx_config(efx);
+       efx_farch_filter_push_tx_limits(efx);
+
+       spin_unlock_bh(&efx->filter_lock);
+}
+
+void efx_farch_filter_table_remove(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+
+       for (table_id = 0; table_id < EFX_FARCH_FILTER_TABLE_COUNT; table_id++) {
+               kfree(state->table[table_id].used_bitmap);
+               vfree(state->table[table_id].spec);
+       }
+       kfree(state);
+}
+
+int efx_farch_filter_table_probe(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state;
+       struct efx_farch_filter_table *table;
+       unsigned table_id;
+
+       state = kzalloc(sizeof(struct efx_farch_filter_state), GFP_KERNEL);
+       if (!state)
+               return -ENOMEM;
+       efx->filter_state = state;
+
+       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
+               table = &state->table[EFX_FARCH_FILTER_TABLE_RX_IP];
+               table->id = EFX_FARCH_FILTER_TABLE_RX_IP;
+               table->offset = FR_BZ_RX_FILTER_TBL0;
+               table->size = FR_BZ_RX_FILTER_TBL0_ROWS;
+               table->step = FR_BZ_RX_FILTER_TBL0_STEP;
+       }
+
+       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) {
+               table = &state->table[EFX_FARCH_FILTER_TABLE_RX_MAC];
+               table->id = EFX_FARCH_FILTER_TABLE_RX_MAC;
+               table->offset = FR_CZ_RX_MAC_FILTER_TBL0;
+               table->size = FR_CZ_RX_MAC_FILTER_TBL0_ROWS;
+               table->step = FR_CZ_RX_MAC_FILTER_TBL0_STEP;
+
+               table = &state->table[EFX_FARCH_FILTER_TABLE_RX_DEF];
+               table->id = EFX_FARCH_FILTER_TABLE_RX_DEF;
+               table->size = EFX_FARCH_FILTER_SIZE_RX_DEF;
+
+               table = &state->table[EFX_FARCH_FILTER_TABLE_TX_MAC];
+               table->id = EFX_FARCH_FILTER_TABLE_TX_MAC;
+               table->offset = FR_CZ_TX_MAC_FILTER_TBL0;
+               table->size = FR_CZ_TX_MAC_FILTER_TBL0_ROWS;
+               table->step = FR_CZ_TX_MAC_FILTER_TBL0_STEP;
+       }
+
+       for (table_id = 0; table_id < EFX_FARCH_FILTER_TABLE_COUNT; table_id++) {
+               table = &state->table[table_id];
+               if (table->size == 0)
+                       continue;
+               table->used_bitmap = kcalloc(BITS_TO_LONGS(table->size),
+                                            sizeof(unsigned long),
+                                            GFP_KERNEL);
+               if (!table->used_bitmap)
+                       goto fail;
+               table->spec = vzalloc(table->size * sizeof(*table->spec));
+               if (!table->spec)
+                       goto fail;
+       }
+
+       table = &state->table[EFX_FARCH_FILTER_TABLE_RX_DEF];
+       if (table->size) {
+               /* RX default filters must always exist */
+               struct efx_farch_filter_spec *spec;
+               unsigned i;
+
+               for (i = 0; i < EFX_FARCH_FILTER_SIZE_RX_DEF; i++) {
+                       spec = &table->spec[i];
+                       spec->type = EFX_FARCH_FILTER_UC_DEF + i;
+                       efx_farch_filter_init_rx_for_stack(efx, spec);
+                       __set_bit(i, table->used_bitmap);
+               }
+       }
+
+       efx_farch_filter_push_rx_config(efx);
+
+       return 0;
+
+fail:
+       efx_farch_filter_table_remove(efx);
+       return -ENOMEM;
+}
+
+/* Update scatter enable flags for filters pointing to our own RX queues */
+void efx_farch_filter_update_rx_scatter(struct efx_nic *efx)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       enum efx_farch_filter_table_id table_id;
+       struct efx_farch_filter_table *table;
+       efx_oword_t filter;
+       unsigned int filter_idx;
+
+       spin_lock_bh(&efx->filter_lock);
+
+       for (table_id = EFX_FARCH_FILTER_TABLE_RX_IP;
+            table_id <= EFX_FARCH_FILTER_TABLE_RX_DEF;
+            table_id++) {
+               table = &state->table[table_id];
+
+               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
+                       if (!test_bit(filter_idx, table->used_bitmap) ||
+                           table->spec[filter_idx].dmaq_id >=
+                           efx->n_rx_channels)
+                               continue;
+
+                       if (efx->rx_scatter)
+                               table->spec[filter_idx].flags |=
+                                       EFX_FILTER_FLAG_RX_SCATTER;
+                       else
+                               table->spec[filter_idx].flags &=
+                                       ~EFX_FILTER_FLAG_RX_SCATTER;
+
+                       if (table_id == EFX_FARCH_FILTER_TABLE_RX_DEF)
+                               /* Pushed by efx_farch_filter_push_rx_config() */
+                               continue;
+
+                       efx_farch_filter_build(&filter, &table->spec[filter_idx]);
+                       efx_writeo(efx, &filter,
+                                  table->offset + table->step * filter_idx);
+               }
+       }
+
+       efx_farch_filter_push_rx_config(efx);
+
+       spin_unlock_bh(&efx->filter_lock);
+}
+
+#ifdef CONFIG_RFS_ACCEL
+
+s32 efx_farch_filter_rfs_insert(struct efx_nic *efx,
+                               struct efx_filter_spec *gen_spec)
+{
+       return efx_farch_filter_insert(efx, gen_spec, true);
+}
+
+bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id,
+                                    unsigned int index)
+{
+       struct efx_farch_filter_state *state = efx->filter_state;
+       struct efx_farch_filter_table *table =
+               &state->table[EFX_FARCH_FILTER_TABLE_RX_IP];
+
+       if (test_bit(index, table->used_bitmap) &&
+           table->spec[index].priority == EFX_FILTER_PRI_HINT &&
+           rps_may_expire_flow(efx->net_dev, table->spec[index].dmaq_id,
+                               flow_id, index)) {
+               efx_farch_filter_table_clear_entry(efx, table, index);
+               return true;
+       }
+
+       return false;
+}
+
+#endif /* CONFIG_RFS_ACCEL */
+
+void efx_farch_filter_sync_rx_mode(struct efx_nic *efx)
+{
+       struct net_device *net_dev = efx->net_dev;
+       struct netdev_hw_addr *ha;
+       union efx_multicast_hash *mc_hash = &efx->multicast_hash;
+       u32 crc;
+       int bit;
+
+       netif_addr_lock_bh(net_dev);
+
+       efx->unicast_filter = !(net_dev->flags & IFF_PROMISC);
+
+       /* Build multicast hash table */
+       if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
+               memset(mc_hash, 0xff, sizeof(*mc_hash));
+       } else {
+               memset(mc_hash, 0x00, sizeof(*mc_hash));
+               netdev_for_each_mc_addr(ha, net_dev) {
+                       crc = ether_crc_le(ETH_ALEN, ha->addr);
+                       bit = crc & (EFX_MCAST_HASH_ENTRIES - 1);
+                       __set_bit_le(bit, mc_hash);
+               }
+
+               /* Broadcast packets go through the multicast hash filter.
+                * ether_crc_le() of the broadcast address is 0xbe2612ff
+                * so we always add bit 0xff to the mask.
+                */
+               __set_bit_le(0xff, mc_hash);
+       }
+
+       netif_addr_unlock_bh(net_dev);
+}
diff --git a/drivers/net/ethernet/sfc/farch_regs.h b/drivers/net/ethernet/sfc/farch_regs.h
new file mode 100644 (file)
index 0000000..491b103
--- /dev/null
@@ -0,0 +1,2932 @@
+/****************************************************************************
+ * Driver for Solarflare Solarstorm network controllers and boards
+ * Copyright 2005-2006 Fen Systems Ltd.
+ * Copyright 2006-2010 Solarflare Communications Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation, incorporated herein by reference.
+ */
+
+#ifndef EFX_FARCH_REGS_H
+#define EFX_FARCH_REGS_H
+
+/*
+ * Falcon hardware architecture definitions have a name prefix following
+ * the format:
+ *
+ *     F<type>_<min-rev><max-rev>_
+ *
+ * The following <type> strings are used:
+ *
+ *             MMIO register  MC register  Host memory structure
+ * -------------------------------------------------------------
+ * Address     R              MCR
+ * Bitfield    RF             MCRF         SF
+ * Enumerator  FE             MCFE         SE
+ *
+ * <min-rev> is the first revision to which the definition applies:
+ *
+ *     A: Falcon A1 (SFC4000AB)
+ *     B: Falcon B0 (SFC4000BA)
+ *     C: Siena A0 (SFL9021AA)
+ *
+ * If the definition has been changed or removed in later revisions
+ * then <max-rev> is the last revision to which the definition applies;
+ * otherwise it is "Z".
+ */
+
+/**************************************************************************
+ *
+ * Falcon/Siena registers and descriptors
+ *
+ **************************************************************************
+ */
+
+/* ADR_REGION_REG: Address region register */
+#define        FR_AZ_ADR_REGION 0x00000000
+#define        FRF_AZ_ADR_REGION3_LBN 96
+#define        FRF_AZ_ADR_REGION3_WIDTH 18
+#define        FRF_AZ_ADR_REGION2_LBN 64
+#define        FRF_AZ_ADR_REGION2_WIDTH 18
+#define        FRF_AZ_ADR_REGION1_LBN 32
+#define        FRF_AZ_ADR_REGION1_WIDTH 18
+#define        FRF_AZ_ADR_REGION0_LBN 0
+#define        FRF_AZ_ADR_REGION0_WIDTH 18
+
+/* INT_EN_REG_KER: Kernel driver Interrupt enable register */
+#define        FR_AZ_INT_EN_KER 0x00000010
+#define        FRF_AZ_KER_INT_LEVE_SEL_LBN 8
+#define        FRF_AZ_KER_INT_LEVE_SEL_WIDTH 6
+#define        FRF_AZ_KER_INT_CHAR_LBN 4
+#define        FRF_AZ_KER_INT_CHAR_WIDTH 1
+#define        FRF_AZ_KER_INT_KER_LBN 3
+#define        FRF_AZ_KER_INT_KER_WIDTH 1
+#define        FRF_AZ_DRV_INT_EN_KER_LBN 0
+#define        FRF_AZ_DRV_INT_EN_KER_WIDTH 1
+
+/* INT_EN_REG_CHAR: Char Driver interrupt enable register */
+#define        FR_BZ_INT_EN_CHAR 0x00000020
+#define        FRF_BZ_CHAR_INT_LEVE_SEL_LBN 8
+#define        FRF_BZ_CHAR_INT_LEVE_SEL_WIDTH 6
+#define        FRF_BZ_CHAR_INT_CHAR_LBN 4
+#define        FRF_BZ_CHAR_INT_CHAR_WIDTH 1
+#define        FRF_BZ_CHAR_INT_KER_LBN 3
+#define        FRF_BZ_CHAR_INT_KER_WIDTH 1
+#define        FRF_BZ_DRV_INT_EN_CHAR_LBN 0
+#define        FRF_BZ_DRV_INT_EN_CHAR_WIDTH 1
+
+/* INT_ADR_REG_KER: Interrupt host address for Kernel driver */
+#define        FR_AZ_INT_ADR_KER 0x00000030
+#define        FRF_AZ_NORM_INT_VEC_DIS_KER_LBN 64
+#define        FRF_AZ_NORM_INT_VEC_DIS_KER_WIDTH 1
+#define        FRF_AZ_INT_ADR_KER_LBN 0
+#define        FRF_AZ_INT_ADR_KER_WIDTH 64
+
+/* INT_ADR_REG_CHAR: Interrupt host address for Char driver */
+#define        FR_BZ_INT_ADR_CHAR 0x00000040
+#define        FRF_BZ_NORM_INT_VEC_DIS_CHAR_LBN 64
+#define        FRF_BZ_NORM_INT_VEC_DIS_CHAR_WIDTH 1
+#define        FRF_BZ_INT_ADR_CHAR_LBN 0
+#define        FRF_BZ_INT_ADR_CHAR_WIDTH 64
+
+/* INT_ACK_KER: Kernel interrupt acknowledge register */
+#define        FR_AA_INT_ACK_KER 0x00000050
+#define        FRF_AA_INT_ACK_KER_FIELD_LBN 0
+#define        FRF_AA_INT_ACK_KER_FIELD_WIDTH 32
+
+/* INT_ISR0_REG: Function 0 Interrupt Acknowledge Status register */
+#define        FR_BZ_INT_ISR0 0x00000090
+#define        FRF_BZ_INT_ISR_REG_LBN 0
+#define        FRF_BZ_INT_ISR_REG_WIDTH 64
+
+/* HW_INIT_REG: Hardware initialization register */
+#define        FR_AZ_HW_INIT 0x000000c0
+#define        FRF_BB_BDMRD_CPLF_FULL_LBN 124
+#define        FRF_BB_BDMRD_CPLF_FULL_WIDTH 1
+#define        FRF_BB_PCIE_CPL_TIMEOUT_CTRL_LBN 121
+#define        FRF_BB_PCIE_CPL_TIMEOUT_CTRL_WIDTH 3
+#define        FRF_CZ_TX_MRG_TAGS_LBN 120
+#define        FRF_CZ_TX_MRG_TAGS_WIDTH 1
+#define        FRF_AB_TRGT_MASK_ALL_LBN 100
+#define        FRF_AB_TRGT_MASK_ALL_WIDTH 1
+#define        FRF_AZ_DOORBELL_DROP_LBN 92
+#define        FRF_AZ_DOORBELL_DROP_WIDTH 8
+#define        FRF_AB_TX_RREQ_MASK_EN_LBN 76
+#define        FRF_AB_TX_RREQ_MASK_EN_WIDTH 1
+#define        FRF_AB_PE_EIDLE_DIS_LBN 75
+#define        FRF_AB_PE_EIDLE_DIS_WIDTH 1
+#define        FRF_AA_FC_BLOCKING_EN_LBN 45
+#define        FRF_AA_FC_BLOCKING_EN_WIDTH 1
+#define        FRF_BZ_B2B_REQ_EN_LBN 45
+#define        FRF_BZ_B2B_REQ_EN_WIDTH 1
+#define        FRF_AA_B2B_REQ_EN_LBN 44
+#define        FRF_AA_B2B_REQ_EN_WIDTH 1
+#define        FRF_BB_FC_BLOCKING_EN_LBN 44
+#define        FRF_BB_FC_BLOCKING_EN_WIDTH 1
+#define        FRF_AZ_POST_WR_MASK_LBN 40
+#define        FRF_AZ_POST_WR_MASK_WIDTH 4
+#define        FRF_AZ_TLP_TC_LBN 34
+#define        FRF_AZ_TLP_TC_WIDTH 3
+#define        FRF_AZ_TLP_ATTR_LBN 32
+#define        FRF_AZ_TLP_ATTR_WIDTH 2
+#define        FRF_AB_INTB_VEC_LBN 24
+#define        FRF_AB_INTB_VEC_WIDTH 5
+#define        FRF_AB_INTA_VEC_LBN 16
+#define        FRF_AB_INTA_VEC_WIDTH 5
+#define        FRF_AZ_WD_TIMER_LBN 8
+#define        FRF_AZ_WD_TIMER_WIDTH 8
+#define        FRF_AZ_US_DISABLE_LBN 5
+#define        FRF_AZ_US_DISABLE_WIDTH 1
+#define        FRF_AZ_TLP_EP_LBN 4
+#define        FRF_AZ_TLP_EP_WIDTH 1
+#define        FRF_AZ_ATTR_SEL_LBN 3
+#define        FRF_AZ_ATTR_SEL_WIDTH 1
+#define        FRF_AZ_TD_SEL_LBN 1
+#define        FRF_AZ_TD_SEL_WIDTH 1
+#define        FRF_AZ_TLP_TD_LBN 0
+#define        FRF_AZ_TLP_TD_WIDTH 1
+
+/* EE_SPI_HCMD_REG: SPI host command register */
+#define        FR_AB_EE_SPI_HCMD 0x00000100
+#define        FRF_AB_EE_SPI_HCMD_CMD_EN_LBN 31
+#define        FRF_AB_EE_SPI_HCMD_CMD_EN_WIDTH 1
+#define        FRF_AB_EE_WR_TIMER_ACTIVE_LBN 28
+#define        FRF_AB_EE_WR_TIMER_ACTIVE_WIDTH 1
+#define        FRF_AB_EE_SPI_HCMD_SF_SEL_LBN 24
+#define        FRF_AB_EE_SPI_HCMD_SF_SEL_WIDTH 1
+#define        FRF_AB_EE_SPI_HCMD_DABCNT_LBN 16
+#define        FRF_AB_EE_SPI_HCMD_DABCNT_WIDTH 5
+#define        FRF_AB_EE_SPI_HCMD_READ_LBN 15
+#define        FRF_AB_EE_SPI_HCMD_READ_WIDTH 1
+#define        FRF_AB_EE_SPI_HCMD_DUBCNT_LBN 12
+#define        FRF_AB_EE_SPI_HCMD_DUBCNT_WIDTH 2
+#define        FRF_AB_EE_SPI_HCMD_ADBCNT_LBN 8
+#define        FRF_AB_EE_SPI_HCMD_ADBCNT_WIDTH 2
+#define        FRF_AB_EE_SPI_HCMD_ENC_LBN 0
+#define        FRF_AB_EE_SPI_HCMD_ENC_WIDTH 8
+
+/* USR_EV_CFG: User Level Event Configuration register */
+#define        FR_CZ_USR_EV_CFG 0x00000100
+#define        FRF_CZ_USREV_DIS_LBN 16
+#define        FRF_CZ_USREV_DIS_WIDTH 1
+#define        FRF_CZ_DFLT_EVQ_LBN 0
+#define        FRF_CZ_DFLT_EVQ_WIDTH 10
+
+/* EE_SPI_HADR_REG: SPI host address register */
+#define        FR_AB_EE_SPI_HADR 0x00000110
+#define        FRF_AB_EE_SPI_HADR_DUBYTE_LBN 24
+#define        FRF_AB_EE_SPI_HADR_DUBYTE_WIDTH 8
+#define        FRF_AB_EE_SPI_HADR_ADR_LBN 0
+#define        FRF_AB_EE_SPI_HADR_ADR_WIDTH 24
+
+/* EE_SPI_HDATA_REG: SPI host data register */
+#define        FR_AB_EE_SPI_HDATA 0x00000120
+#define        FRF_AB_EE_SPI_HDATA3_LBN 96
+#define        FRF_AB_EE_SPI_HDATA3_WIDTH 32
+#define        FRF_AB_EE_SPI_HDATA2_LBN 64
+#define        FRF_AB_EE_SPI_HDATA2_WIDTH 32
+#define        FRF_AB_EE_SPI_HDATA1_LBN 32
+#define        FRF_AB_EE_SPI_HDATA1_WIDTH 32
+#define        FRF_AB_EE_SPI_HDATA0_LBN 0
+#define        FRF_AB_EE_SPI_HDATA0_WIDTH 32
+
+/* EE_BASE_PAGE_REG: Expansion ROM base mirror register */
+#define        FR_AB_EE_BASE_PAGE 0x00000130
+#define        FRF_AB_EE_EXPROM_MASK_LBN 16
+#define        FRF_AB_EE_EXPROM_MASK_WIDTH 13
+#define        FRF_AB_EE_EXP_ROM_WINDOW_BASE_LBN 0
+#define        FRF_AB_EE_EXP_ROM_WINDOW_BASE_WIDTH 13
+
+/* EE_VPD_CFG0_REG: SPI/VPD configuration register 0 */
+#define        FR_AB_EE_VPD_CFG0 0x00000140
+#define        FRF_AB_EE_SF_FASTRD_EN_LBN 127
+#define        FRF_AB_EE_SF_FASTRD_EN_WIDTH 1
+#define        FRF_AB_EE_SF_CLOCK_DIV_LBN 120
+#define        FRF_AB_EE_SF_CLOCK_DIV_WIDTH 7
+#define        FRF_AB_EE_VPD_WIP_POLL_LBN 119
+#define        FRF_AB_EE_VPD_WIP_POLL_WIDTH 1
+#define        FRF_AB_EE_EE_CLOCK_DIV_LBN 112
+#define        FRF_AB_EE_EE_CLOCK_DIV_WIDTH 7
+#define        FRF_AB_EE_EE_WR_TMR_VALUE_LBN 96
+#define        FRF_AB_EE_EE_WR_TMR_VALUE_WIDTH 16
+#define        FRF_AB_EE_VPDW_LENGTH_LBN 80
+#define        FRF_AB_EE_VPDW_LENGTH_WIDTH 15
+#define        FRF_AB_EE_VPDW_BASE_LBN 64
+#define        FRF_AB_EE_VPDW_BASE_WIDTH 15
+#define        FRF_AB_EE_VPD_WR_CMD_EN_LBN 56
+#define        FRF_AB_EE_VPD_WR_CMD_EN_WIDTH 8
+#define        FRF_AB_EE_VPD_BASE_LBN 32
+#define        FRF_AB_EE_VPD_BASE_WIDTH 24
+#define        FRF_AB_EE_VPD_LENGTH_LBN 16
+#define        FRF_AB_EE_VPD_LENGTH_WIDTH 15
+#define        FRF_AB_EE_VPD_AD_SIZE_LBN 8
+#define        FRF_AB_EE_VPD_AD_SIZE_WIDTH 5
+#define        FRF_AB_EE_VPD_ACCESS_ON_LBN 5
+#define        FRF_AB_EE_VPD_ACCESS_ON_WIDTH 1
+#define        FRF_AB_EE_VPD_ACCESS_BLOCK_LBN 4
+#define        FRF_AB_EE_VPD_ACCESS_BLOCK_WIDTH 1
+#define        FRF_AB_EE_VPD_DEV_SF_SEL_LBN 2
+#define        FRF_AB_EE_VPD_DEV_SF_SEL_WIDTH 1
+#define        FRF_AB_EE_VPD_EN_AD9_MODE_LBN 1
+#define        FRF_AB_EE_VPD_EN_AD9_MODE_WIDTH 1
+#define        FRF_AB_EE_VPD_EN_LBN 0
+#define        FRF_AB_EE_VPD_EN_WIDTH 1
+
+/* EE_VPD_SW_CNTL_REG: VPD access SW control register */
+#define        FR_AB_EE_VPD_SW_CNTL 0x00000150
+#define        FRF_AB_EE_VPD_CYCLE_PENDING_LBN 31
+#define        FRF_AB_EE_VPD_CYCLE_PENDING_WIDTH 1
+#define        FRF_AB_EE_VPD_CYC_WRITE_LBN 28
+#define        FRF_AB_EE_VPD_CYC_WRITE_WIDTH 1
+#define        FRF_AB_EE_VPD_CYC_ADR_LBN 0
+#define        FRF_AB_EE_VPD_CYC_ADR_WIDTH 15
+
+/* EE_VPD_SW_DATA_REG: VPD access SW data register */
+#define        FR_AB_EE_VPD_SW_DATA 0x00000160
+#define        FRF_AB_EE_VPD_CYC_DAT_LBN 0
+#define        FRF_AB_EE_VPD_CYC_DAT_WIDTH 32
+
+/* PBMX_DBG_IADDR_REG: Capture Module address register */
+#define        FR_CZ_PBMX_DBG_IADDR 0x000001f0
+#define        FRF_CZ_PBMX_DBG_IADDR_LBN 0
+#define        FRF_CZ_PBMX_DBG_IADDR_WIDTH 32
+
+/* PCIE_CORE_INDIRECT_REG: Indirect Access to PCIE Core registers */
+#define        FR_BB_PCIE_CORE_INDIRECT 0x000001f0
+#define        FRF_BB_PCIE_CORE_TARGET_DATA_LBN 32
+#define        FRF_BB_PCIE_CORE_TARGET_DATA_WIDTH 32
+#define        FRF_BB_PCIE_CORE_INDIRECT_ACCESS_DIR_LBN 15
+#define        FRF_BB_PCIE_CORE_INDIRECT_ACCESS_DIR_WIDTH 1
+#define        FRF_BB_PCIE_CORE_TARGET_REG_ADRS_LBN 0
+#define        FRF_BB_PCIE_CORE_TARGET_REG_ADRS_WIDTH 12
+
+/* PBMX_DBG_IDATA_REG: Capture Module data register */
+#define        FR_CZ_PBMX_DBG_IDATA 0x000001f8
+#define        FRF_CZ_PBMX_DBG_IDATA_LBN 0
+#define        FRF_CZ_PBMX_DBG_IDATA_WIDTH 64
+
+/* NIC_STAT_REG: NIC status register */
+#define        FR_AB_NIC_STAT 0x00000200
+#define        FRF_BB_AER_DIS_LBN 34
+#define        FRF_BB_AER_DIS_WIDTH 1
+#define        FRF_BB_EE_STRAP_EN_LBN 31
+#define        FRF_BB_EE_STRAP_EN_WIDTH 1
+#define        FRF_BB_EE_STRAP_LBN 24
+#define        FRF_BB_EE_STRAP_WIDTH 4
+#define        FRF_BB_REVISION_ID_LBN 17
+#define        FRF_BB_REVISION_ID_WIDTH 7
+#define        FRF_AB_ONCHIP_SRAM_LBN 16
+#define        FRF_AB_ONCHIP_SRAM_WIDTH 1
+#define        FRF_AB_SF_PRST_LBN 9
+#define        FRF_AB_SF_PRST_WIDTH 1
+#define        FRF_AB_EE_PRST_LBN 8
+#define        FRF_AB_EE_PRST_WIDTH 1
+#define        FRF_AB_ATE_MODE_LBN 3
+#define        FRF_AB_ATE_MODE_WIDTH 1
+#define        FRF_AB_STRAP_PINS_LBN 0
+#define        FRF_AB_STRAP_PINS_WIDTH 3
+
+/* GPIO_CTL_REG: GPIO control register */
+#define        FR_AB_GPIO_CTL 0x00000210
+#define        FRF_AB_GPIO_OUT3_LBN 112
+#define        FRF_AB_GPIO_OUT3_WIDTH 16
+#define        FRF_AB_GPIO_IN3_LBN 104
+#define        FRF_AB_GPIO_IN3_WIDTH 8
+#define        FRF_AB_GPIO_PWRUP_VALUE3_LBN 96
+#define        FRF_AB_GPIO_PWRUP_VALUE3_WIDTH 8
+#define        FRF_AB_GPIO_OUT2_LBN 80
+#define        FRF_AB_GPIO_OUT2_WIDTH 16
+#define        FRF_AB_GPIO_IN2_LBN 72
+#define        FRF_AB_GPIO_IN2_WIDTH 8
+#define        FRF_AB_GPIO_PWRUP_VALUE2_LBN 64
+#define        FRF_AB_GPIO_PWRUP_VALUE2_WIDTH 8
+#define        FRF_AB_GPIO15_OEN_LBN 63
+#define        FRF_AB_GPIO15_OEN_WIDTH 1
+#define        FRF_AB_GPIO14_OEN_LBN 62
+#define        FRF_AB_GPIO14_OEN_WIDTH 1
+#define        FRF_AB_GPIO13_OEN_LBN 61
+#define        FRF_AB_GPIO13_OEN_WIDTH 1
+#define        FRF_AB_GPIO12_OEN_LBN 60
+#define        FRF_AB_GPIO12_OEN_WIDTH 1
+#define        FRF_AB_GPIO11_OEN_LBN 59
+#define        FRF_AB_GPIO11_OEN_WIDTH 1
+#define        FRF_AB_GPIO10_OEN_LBN 58
+#define        FRF_AB_GPIO10_OEN_WIDTH 1
+#define        FRF_AB_GPIO9_OEN_LBN 57
+#define        FRF_AB_GPIO9_OEN_WIDTH 1
+#define        FRF_AB_GPIO8_OEN_LBN 56
+#define        FRF_AB_GPIO8_OEN_WIDTH 1
+#define        FRF_AB_GPIO15_OUT_LBN 55
+#define        FRF_AB_GPIO15_OUT_WIDTH 1
+#define        FRF_AB_GPIO14_OUT_LBN 54
+#define        FRF_AB_GPIO14_OUT_WIDTH 1
+#define        FRF_AB_GPIO13_OUT_LBN 53
+#define        FRF_AB_GPIO13_OUT_WIDTH 1
+#define        FRF_AB_GPIO12_OUT_LBN 52
+#define        FRF_AB_GPIO12_OUT_WIDTH 1
+#define        FRF_AB_GPIO11_OUT_LBN 51
+#define        FRF_AB_GPIO11_OUT_WIDTH 1
+#define        FRF_AB_GPIO10_OUT_LBN 50
+#define        FRF_AB_GPIO10_OUT_WIDTH 1
+#define        FRF_AB_GPIO9_OUT_LBN 49
+#define        FRF_AB_GPIO9_OUT_WIDTH 1
+#define        FRF_AB_GPIO8_OUT_LBN 48
+#define        FRF_AB_GPIO8_OUT_WIDTH 1
+#define        FRF_AB_GPIO15_IN_LBN 47
+#define        FRF_AB_GPIO15_IN_WIDTH 1
+#define        FRF_AB_GPIO14_IN_LBN 46
+#define        FRF_AB_GPIO14_IN_WIDTH 1
+#define        FRF_AB_GPIO13_IN_LBN 45
+#define        FRF_AB_GPIO13_IN_WIDTH 1
+#define        FRF_AB_GPIO12_IN_LBN 44
+#define        FRF_AB_GPIO12_IN_WIDTH 1
+#define        FRF_AB_GPIO11_IN_LBN 43
+#define        FRF_AB_GPIO11_IN_WIDTH 1
+#define        FRF_AB_GPIO10_IN_LBN 42
+#define        FRF_AB_GPIO10_IN_WIDTH 1
+#define        FRF_AB_GPIO9_IN_LBN 41
+#define        FRF_AB_GPIO9_IN_WIDTH 1
+#define        FRF_AB_GPIO8_IN_LBN 40
+#define        FRF_AB_GPIO8_IN_WIDTH 1
+#define        FRF_AB_GPIO15_PWRUP_VALUE_LBN 39
+#define        FRF_AB_GPIO15_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO14_PWRUP_VALUE_LBN 38
+#define        FRF_AB_GPIO14_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO13_PWRUP_VALUE_LBN 37
+#define        FRF_AB_GPIO13_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO12_PWRUP_VALUE_LBN 36
+#define        FRF_AB_GPIO12_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO11_PWRUP_VALUE_LBN 35
+#define        FRF_AB_GPIO11_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO10_PWRUP_VALUE_LBN 34
+#define        FRF_AB_GPIO10_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO9_PWRUP_VALUE_LBN 33
+#define        FRF_AB_GPIO9_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO8_PWRUP_VALUE_LBN 32
+#define        FRF_AB_GPIO8_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_CLK156_OUT_EN_LBN 31
+#define        FRF_AB_CLK156_OUT_EN_WIDTH 1
+#define        FRF_AB_USE_NIC_CLK_LBN 30
+#define        FRF_AB_USE_NIC_CLK_WIDTH 1
+#define        FRF_AB_GPIO5_OEN_LBN 29
+#define        FRF_AB_GPIO5_OEN_WIDTH 1
+#define        FRF_AB_GPIO4_OEN_LBN 28
+#define        FRF_AB_GPIO4_OEN_WIDTH 1
+#define        FRF_AB_GPIO3_OEN_LBN 27
+#define        FRF_AB_GPIO3_OEN_WIDTH 1
+#define        FRF_AB_GPIO2_OEN_LBN 26
+#define        FRF_AB_GPIO2_OEN_WIDTH 1
+#define        FRF_AB_GPIO1_OEN_LBN 25
+#define        FRF_AB_GPIO1_OEN_WIDTH 1
+#define        FRF_AB_GPIO0_OEN_LBN 24
+#define        FRF_AB_GPIO0_OEN_WIDTH 1
+#define        FRF_AB_GPIO7_OUT_LBN 23
+#define        FRF_AB_GPIO7_OUT_WIDTH 1
+#define        FRF_AB_GPIO6_OUT_LBN 22
+#define        FRF_AB_GPIO6_OUT_WIDTH 1
+#define        FRF_AB_GPIO5_OUT_LBN 21
+#define        FRF_AB_GPIO5_OUT_WIDTH 1
+#define        FRF_AB_GPIO4_OUT_LBN 20
+#define        FRF_AB_GPIO4_OUT_WIDTH 1
+#define        FRF_AB_GPIO3_OUT_LBN 19
+#define        FRF_AB_GPIO3_OUT_WIDTH 1
+#define        FRF_AB_GPIO2_OUT_LBN 18
+#define        FRF_AB_GPIO2_OUT_WIDTH 1
+#define        FRF_AB_GPIO1_OUT_LBN 17
+#define        FRF_AB_GPIO1_OUT_WIDTH 1
+#define        FRF_AB_GPIO0_OUT_LBN 16
+#define        FRF_AB_GPIO0_OUT_WIDTH 1
+#define        FRF_AB_GPIO7_IN_LBN 15
+#define        FRF_AB_GPIO7_IN_WIDTH 1
+#define        FRF_AB_GPIO6_IN_LBN 14
+#define        FRF_AB_GPIO6_IN_WIDTH 1
+#define        FRF_AB_GPIO5_IN_LBN 13
+#define        FRF_AB_GPIO5_IN_WIDTH 1
+#define        FRF_AB_GPIO4_IN_LBN 12
+#define        FRF_AB_GPIO4_IN_WIDTH 1
+#define        FRF_AB_GPIO3_IN_LBN 11
+#define        FRF_AB_GPIO3_IN_WIDTH 1
+#define        FRF_AB_GPIO2_IN_LBN 10
+#define        FRF_AB_GPIO2_IN_WIDTH 1
+#define        FRF_AB_GPIO1_IN_LBN 9
+#define        FRF_AB_GPIO1_IN_WIDTH 1
+#define        FRF_AB_GPIO0_IN_LBN 8
+#define        FRF_AB_GPIO0_IN_WIDTH 1
+#define        FRF_AB_GPIO7_PWRUP_VALUE_LBN 7
+#define        FRF_AB_GPIO7_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO6_PWRUP_VALUE_LBN 6
+#define        FRF_AB_GPIO6_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO5_PWRUP_VALUE_LBN 5
+#define        FRF_AB_GPIO5_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO4_PWRUP_VALUE_LBN 4
+#define        FRF_AB_GPIO4_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO3_PWRUP_VALUE_LBN 3
+#define        FRF_AB_GPIO3_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO2_PWRUP_VALUE_LBN 2
+#define        FRF_AB_GPIO2_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO1_PWRUP_VALUE_LBN 1
+#define        FRF_AB_GPIO1_PWRUP_VALUE_WIDTH 1
+#define        FRF_AB_GPIO0_PWRUP_VALUE_LBN 0
+#define        FRF_AB_GPIO0_PWRUP_VALUE_WIDTH 1
+
+/* GLB_CTL_REG: Global control register */
+#define        FR_AB_GLB_CTL 0x00000220
+#define        FRF_AB_EXT_PHY_RST_CTL_LBN 63
+#define        FRF_AB_EXT_PHY_RST_CTL_WIDTH 1
+#define        FRF_AB_XAUI_SD_RST_CTL_LBN 62
+#define        FRF_AB_XAUI_SD_RST_CTL_WIDTH 1
+#define        FRF_AB_PCIE_SD_RST_CTL_LBN 61
+#define        FRF_AB_PCIE_SD_RST_CTL_WIDTH 1
+#define        FRF_AA_PCIX_RST_CTL_LBN 60
+#define        FRF_AA_PCIX_RST_CTL_WIDTH 1
+#define        FRF_BB_BIU_RST_CTL_LBN 60
+#define        FRF_BB_BIU_RST_CTL_WIDTH 1
+#define        FRF_AB_PCIE_STKY_RST_CTL_LBN 59
+#define        FRF_AB_PCIE_STKY_RST_CTL_WIDTH 1
+#define        FRF_AB_PCIE_NSTKY_RST_CTL_LBN 58
+#define        FRF_AB_PCIE_NSTKY_RST_CTL_WIDTH 1
+#define        FRF_AB_PCIE_CORE_RST_CTL_LBN 57
+#define        FRF_AB_PCIE_CORE_RST_CTL_WIDTH 1
+#define        FRF_AB_XGRX_RST_CTL_LBN 56
+#define        FRF_AB_XGRX_RST_CTL_WIDTH 1
+#define        FRF_AB_XGTX_RST_CTL_LBN 55
+#define        FRF_AB_XGTX_RST_CTL_WIDTH 1
+#define        FRF_AB_EM_RST_CTL_LBN 54
+#define        FRF_AB_EM_RST_CTL_WIDTH 1
+#define        FRF_AB_EV_RST_CTL_LBN 53
+#define        FRF_AB_EV_RST_CTL_WIDTH 1
+#define        FRF_AB_SR_RST_CTL_LBN 52
+#define        FRF_AB_SR_RST_CTL_WIDTH 1
+#define        FRF_AB_RX_RST_CTL_LBN 51
+#define        FRF_AB_RX_RST_CTL_WIDTH 1
+#define        FRF_AB_TX_RST_CTL_LBN 50
+#define        FRF_AB_TX_RST_CTL_WIDTH 1
+#define        FRF_AB_EE_RST_CTL_LBN 49
+#define        FRF_AB_EE_RST_CTL_WIDTH 1
+#define        FRF_AB_CS_RST_CTL_LBN 48
+#define        FRF_AB_CS_RST_CTL_WIDTH 1
+#define        FRF_AB_HOT_RST_CTL_LBN 40
+#define        FRF_AB_HOT_RST_CTL_WIDTH 2
+#define        FRF_AB_RST_EXT_PHY_LBN 31
+#define        FRF_AB_RST_EXT_PHY_WIDTH 1
+#define        FRF_AB_RST_XAUI_SD_LBN 30
+#define        FRF_AB_RST_XAUI_SD_WIDTH 1
+#define        FRF_AB_RST_PCIE_SD_LBN 29
+#define        FRF_AB_RST_PCIE_SD_WIDTH 1
+#define        FRF_AA_RST_PCIX_LBN 28
+#define        FRF_AA_RST_PCIX_WIDTH 1
+#define        FRF_BB_RST_BIU_LBN 28
+#define        FRF_BB_RST_BIU_WIDTH 1
+#define        FRF_AB_RST_PCIE_STKY_LBN 27
+#define        FRF_AB_RST_PCIE_STKY_WIDTH 1
+#define        FRF_AB_RST_PCIE_NSTKY_LBN 26
+#define        FRF_AB_RST_PCIE_NSTKY_WIDTH 1
+#define        FRF_AB_RST_PCIE_CORE_LBN 25
+#define        FRF_AB_RST_PCIE_CORE_WIDTH 1
+#define        FRF_AB_RST_XGRX_LBN 24
+#define        FRF_AB_RST_XGRX_WIDTH 1
+#define        FRF_AB_RST_XGTX_LBN 23
+#define        FRF_AB_RST_XGTX_WIDTH 1
+#define        FRF_AB_RST_EM_LBN 22
+#define        FRF_AB_RST_EM_WIDTH 1
+#define        FRF_AB_RST_EV_LBN 21
+#define        FRF_AB_RST_EV_WIDTH 1
+#define        FRF_AB_RST_SR_LBN 20
+#define        FRF_AB_RST_SR_WIDTH 1
+#define        FRF_AB_RST_RX_LBN 19
+#define        FRF_AB_RST_RX_WIDTH 1
+#define        FRF_AB_RST_TX_LBN 18
+#define        FRF_AB_RST_TX_WIDTH 1
+#define        FRF_AB_RST_SF_LBN 17
+#define        FRF_AB_RST_SF_WIDTH 1
+#define        FRF_AB_RST_CS_LBN 16
+#define        FRF_AB_RST_CS_WIDTH 1
+#define        FRF_AB_INT_RST_DUR_LBN 4
+#define        FRF_AB_INT_RST_DUR_WIDTH 3
+#define        FRF_AB_EXT_PHY_RST_DUR_LBN 1
+#define        FRF_AB_EXT_PHY_RST_DUR_WIDTH 3
+#define        FFE_AB_EXT_PHY_RST_DUR_10240US 7
+#define        FFE_AB_EXT_PHY_RST_DUR_5120US 6
+#define        FFE_AB_EXT_PHY_RST_DUR_2560US 5
+#define        FFE_AB_EXT_PHY_RST_DUR_1280US 4
+#define        FFE_AB_EXT_PHY_RST_DUR_640US 3
+#define        FFE_AB_EXT_PHY_RST_DUR_320US 2
+#define        FFE_AB_EXT_PHY_RST_DUR_160US 1
+#define        FFE_AB_EXT_PHY_RST_DUR_80US 0
+#define        FRF_AB_SWRST_LBN 0
+#define        FRF_AB_SWRST_WIDTH 1
+
+/* FATAL_INTR_REG_KER: Fatal interrupt register for Kernel */
+#define        FR_AZ_FATAL_INTR_KER 0x00000230
+#define        FRF_CZ_SRAM_PERR_INT_P_KER_EN_LBN 44
+#define        FRF_CZ_SRAM_PERR_INT_P_KER_EN_WIDTH 1
+#define        FRF_AB_PCI_BUSERR_INT_KER_EN_LBN 43
+#define        FRF_AB_PCI_BUSERR_INT_KER_EN_WIDTH 1
+#define        FRF_CZ_MBU_PERR_INT_KER_EN_LBN 43
+#define        FRF_CZ_MBU_PERR_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_SRAM_OOB_INT_KER_EN_LBN 42
+#define        FRF_AZ_SRAM_OOB_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_BUFID_OOB_INT_KER_EN_LBN 41
+#define        FRF_AZ_BUFID_OOB_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_MEM_PERR_INT_KER_EN_LBN 40
+#define        FRF_AZ_MEM_PERR_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_RBUF_OWN_INT_KER_EN_LBN 39
+#define        FRF_AZ_RBUF_OWN_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_TBUF_OWN_INT_KER_EN_LBN 38
+#define        FRF_AZ_TBUF_OWN_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_RDESCQ_OWN_INT_KER_EN_LBN 37
+#define        FRF_AZ_RDESCQ_OWN_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_TDESCQ_OWN_INT_KER_EN_LBN 36
+#define        FRF_AZ_TDESCQ_OWN_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_EVQ_OWN_INT_KER_EN_LBN 35
+#define        FRF_AZ_EVQ_OWN_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_EVF_OFLO_INT_KER_EN_LBN 34
+#define        FRF_AZ_EVF_OFLO_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_ILL_ADR_INT_KER_EN_LBN 33
+#define        FRF_AZ_ILL_ADR_INT_KER_EN_WIDTH 1
+#define        FRF_AZ_SRM_PERR_INT_KER_EN_LBN 32
+#define        FRF_AZ_SRM_PERR_INT_KER_EN_WIDTH 1
+#define        FRF_CZ_SRAM_PERR_INT_P_KER_LBN 12
+#define        FRF_CZ_SRAM_PERR_INT_P_KER_WIDTH 1
+#define        FRF_AB_PCI_BUSERR_INT_KER_LBN 11
+#define        FRF_AB_PCI_BUSERR_INT_KER_WIDTH 1
+#define        FRF_CZ_MBU_PERR_INT_KER_LBN 11
+#define        FRF_CZ_MBU_PERR_INT_KER_WIDTH 1
+#define        FRF_AZ_SRAM_OOB_INT_KER_LBN 10
+#define        FRF_AZ_SRAM_OOB_INT_KER_WIDTH 1
+#define        FRF_AZ_BUFID_DC_OOB_INT_KER_LBN 9
+#define        FRF_AZ_BUFID_DC_OOB_INT_KER_WIDTH 1
+#define        FRF_AZ_MEM_PERR_INT_KER_LBN 8
+#define        FRF_AZ_MEM_PERR_INT_KER_WIDTH 1
+#define        FRF_AZ_RBUF_OWN_INT_KER_LBN 7
+#define        FRF_AZ_RBUF_OWN_INT_KER_WIDTH 1
+#define        FRF_AZ_TBUF_OWN_INT_KER_LBN 6
+#define        FRF_AZ_TBUF_OWN_INT_KER_WIDTH 1
+#define        FRF_AZ_RDESCQ_OWN_INT_KER_LBN 5
+#define        FRF_AZ_RDESCQ_OWN_INT_KER_WIDTH 1
+#define        FRF_AZ_TDESCQ_OWN_INT_KER_LBN 4
+#define        FRF_AZ_TDESCQ_OWN_INT_KER_WIDTH 1
+#define        FRF_AZ_EVQ_OWN_INT_KER_LBN 3
+#define        FRF_AZ_EVQ_OWN_INT_KER_WIDTH 1
+#define        FRF_AZ_EVF_OFLO_INT_KER_LBN 2
+#define        FRF_AZ_EVF_OFLO_INT_KER_WIDTH 1
+#define        FRF_AZ_ILL_ADR_INT_KER_LBN 1
+#define        FRF_AZ_ILL_ADR_INT_KER_WIDTH 1
+#define        FRF_AZ_SRM_PERR_INT_KER_LBN 0
+#define        FRF_AZ_SRM_PERR_INT_KER_WIDTH 1
+
+/* FATAL_INTR_REG_CHAR: Fatal interrupt register for Char */
+#define        FR_BZ_FATAL_INTR_CHAR 0x00000240
+#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_EN_LBN 44
+#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_EN_WIDTH 1
+#define        FRF_BB_PCI_BUSERR_INT_CHAR_EN_LBN 43
+#define        FRF_BB_PCI_BUSERR_INT_CHAR_EN_WIDTH 1
+#define        FRF_CZ_MBU_PERR_INT_CHAR_EN_LBN 43
+#define        FRF_CZ_MBU_PERR_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_SRAM_OOB_INT_CHAR_EN_LBN 42
+#define        FRF_BZ_SRAM_OOB_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_BUFID_OOB_INT_CHAR_EN_LBN 41
+#define        FRF_BZ_BUFID_OOB_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_MEM_PERR_INT_CHAR_EN_LBN 40
+#define        FRF_BZ_MEM_PERR_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_RBUF_OWN_INT_CHAR_EN_LBN 39
+#define        FRF_BZ_RBUF_OWN_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_TBUF_OWN_INT_CHAR_EN_LBN 38
+#define        FRF_BZ_TBUF_OWN_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_EN_LBN 37
+#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_EN_LBN 36
+#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_EVQ_OWN_INT_CHAR_EN_LBN 35
+#define        FRF_BZ_EVQ_OWN_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_EVF_OFLO_INT_CHAR_EN_LBN 34
+#define        FRF_BZ_EVF_OFLO_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_ILL_ADR_INT_CHAR_EN_LBN 33
+#define        FRF_BZ_ILL_ADR_INT_CHAR_EN_WIDTH 1
+#define        FRF_BZ_SRM_PERR_INT_CHAR_EN_LBN 32
+#define        FRF_BZ_SRM_PERR_INT_CHAR_EN_WIDTH 1
+#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_LBN 12
+#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_WIDTH 1
+#define        FRF_BB_PCI_BUSERR_INT_CHAR_LBN 11
+#define        FRF_BB_PCI_BUSERR_INT_CHAR_WIDTH 1
+#define        FRF_CZ_MBU_PERR_INT_CHAR_LBN 11
+#define        FRF_CZ_MBU_PERR_INT_CHAR_WIDTH 1
+#define        FRF_BZ_SRAM_OOB_INT_CHAR_LBN 10
+#define        FRF_BZ_SRAM_OOB_INT_CHAR_WIDTH 1
+#define        FRF_BZ_BUFID_DC_OOB_INT_CHAR_LBN 9
+#define        FRF_BZ_BUFID_DC_OOB_INT_CHAR_WIDTH 1
+#define        FRF_BZ_MEM_PERR_INT_CHAR_LBN 8
+#define        FRF_BZ_MEM_PERR_INT_CHAR_WIDTH 1
+#define        FRF_BZ_RBUF_OWN_INT_CHAR_LBN 7
+#define        FRF_BZ_RBUF_OWN_INT_CHAR_WIDTH 1
+#define        FRF_BZ_TBUF_OWN_INT_CHAR_LBN 6
+#define        FRF_BZ_TBUF_OWN_INT_CHAR_WIDTH 1
+#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_LBN 5
+#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_WIDTH 1
+#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_LBN 4
+#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_WIDTH 1
+#define        FRF_BZ_EVQ_OWN_INT_CHAR_LBN 3
+#define        FRF_BZ_EVQ_OWN_INT_CHAR_WIDTH 1
+#define        FRF_BZ_EVF_OFLO_INT_CHAR_LBN 2
+#define        FRF_BZ_EVF_OFLO_INT_CHAR_WIDTH 1
+#define        FRF_BZ_ILL_ADR_INT_CHAR_LBN 1
+#define        FRF_BZ_ILL_ADR_INT_CHAR_WIDTH 1
+#define        FRF_BZ_SRM_PERR_INT_CHAR_LBN 0
+#define        FRF_BZ_SRM_PERR_INT_CHAR_WIDTH 1
+
+/* DP_CTRL_REG: Datapath control register */
+#define        FR_BZ_DP_CTRL 0x00000250
+#define        FRF_BZ_FLS_EVQ_ID_LBN 0
+#define        FRF_BZ_FLS_EVQ_ID_WIDTH 12
+
+/* MEM_STAT_REG: Memory status register */
+#define        FR_AZ_MEM_STAT 0x00000260
+#define        FRF_AB_MEM_PERR_VEC_LBN 53
+#define        FRF_AB_MEM_PERR_VEC_WIDTH 38
+#define        FRF_AB_MBIST_CORR_LBN 38
+#define        FRF_AB_MBIST_CORR_WIDTH 15
+#define        FRF_AB_MBIST_ERR_LBN 0
+#define        FRF_AB_MBIST_ERR_WIDTH 40
+#define        FRF_CZ_MEM_PERR_VEC_LBN 0
+#define        FRF_CZ_MEM_PERR_VEC_WIDTH 35
+
+/* CS_DEBUG_REG: Debug register */
+#define        FR_AZ_CS_DEBUG 0x00000270
+#define        FRF_AB_GLB_DEBUG2_SEL_LBN 50
+#define        FRF_AB_GLB_DEBUG2_SEL_WIDTH 3
+#define        FRF_AB_DEBUG_BLK_SEL2_LBN 47
+#define        FRF_AB_DEBUG_BLK_SEL2_WIDTH 3
+#define        FRF_AB_DEBUG_BLK_SEL1_LBN 44
+#define        FRF_AB_DEBUG_BLK_SEL1_WIDTH 3
+#define        FRF_AB_DEBUG_BLK_SEL0_LBN 41
+#define        FRF_AB_DEBUG_BLK_SEL0_WIDTH 3
+#define        FRF_CZ_CS_PORT_NUM_LBN 40
+#define        FRF_CZ_CS_PORT_NUM_WIDTH 2
+#define        FRF_AB_MISC_DEBUG_ADDR_LBN 36
+#define        FRF_AB_MISC_DEBUG_ADDR_WIDTH 5
+#define        FRF_AB_SERDES_DEBUG_ADDR_LBN 31
+#define        FRF_AB_SERDES_DEBUG_ADDR_WIDTH 5
+#define        FRF_CZ_CS_PORT_FPE_LBN 1
+#define        FRF_CZ_CS_PORT_FPE_WIDTH 35
+#define        FRF_AB_EM_DEBUG_ADDR_LBN 26
+#define        FRF_AB_EM_DEBUG_ADDR_WIDTH 5
+#define        FRF_AB_SR_DEBUG_ADDR_LBN 21
+#define        FRF_AB_SR_DEBUG_ADDR_WIDTH 5
+#define        FRF_AB_EV_DEBUG_ADDR_LBN 16
+#define        FRF_AB_EV_DEBUG_ADDR_WIDTH 5
+#define        FRF_AB_RX_DEBUG_ADDR_LBN 11
+#define        FRF_AB_RX_DEBUG_ADDR_WIDTH 5
+#define        FRF_AB_TX_DEBUG_ADDR_LBN 6
+#define        FRF_AB_TX_DEBUG_ADDR_WIDTH 5
+#define        FRF_AB_CS_BIU_DEBUG_ADDR_LBN 1
+#define        FRF_AB_CS_BIU_DEBUG_ADDR_WIDTH 5
+#define        FRF_AZ_CS_DEBUG_EN_LBN 0
+#define        FRF_AZ_CS_DEBUG_EN_WIDTH 1
+
+/* DRIVER_REG: Driver scratch register [0-7] */
+#define        FR_AZ_DRIVER 0x00000280
+#define        FR_AZ_DRIVER_STEP 16
+#define        FR_AZ_DRIVER_ROWS 8
+#define        FRF_AZ_DRIVER_DW0_LBN 0
+#define        FRF_AZ_DRIVER_DW0_WIDTH 32
+
+/* ALTERA_BUILD_REG: Altera build register */
+#define        FR_AZ_ALTERA_BUILD 0x00000300
+#define        FRF_AZ_ALTERA_BUILD_VER_LBN 0
+#define        FRF_AZ_ALTERA_BUILD_VER_WIDTH 32
+
+/* CSR_SPARE_REG: Spare register */
+#define        FR_AZ_CSR_SPARE 0x00000310
+#define        FRF_AB_MEM_PERR_EN_LBN 64
+#define        FRF_AB_MEM_PERR_EN_WIDTH 38
+#define        FRF_CZ_MEM_PERR_EN_LBN 64
+#define        FRF_CZ_MEM_PERR_EN_WIDTH 35
+#define        FRF_AB_MEM_PERR_EN_TX_DATA_LBN 72
+#define        FRF_AB_MEM_PERR_EN_TX_DATA_WIDTH 2
+#define        FRF_AZ_CSR_SPARE_BITS_LBN 0
+#define        FRF_AZ_CSR_SPARE_BITS_WIDTH 32
+
+/* PCIE_SD_CTL0123_REG: PCIE SerDes control register 0 to 3 */
+#define        FR_AB_PCIE_SD_CTL0123 0x00000320
+#define        FRF_AB_PCIE_TESTSIG_H_LBN 96
+#define        FRF_AB_PCIE_TESTSIG_H_WIDTH 19
+#define        FRF_AB_PCIE_TESTSIG_L_LBN 64
+#define        FRF_AB_PCIE_TESTSIG_L_WIDTH 19
+#define        FRF_AB_PCIE_OFFSET_LBN 56
+#define        FRF_AB_PCIE_OFFSET_WIDTH 8
+#define        FRF_AB_PCIE_OFFSETEN_H_LBN 55
+#define        FRF_AB_PCIE_OFFSETEN_H_WIDTH 1
+#define        FRF_AB_PCIE_OFFSETEN_L_LBN 54
+#define        FRF_AB_PCIE_OFFSETEN_L_WIDTH 1
+#define        FRF_AB_PCIE_HIVMODE_H_LBN 53
+#define        FRF_AB_PCIE_HIVMODE_H_WIDTH 1
+#define        FRF_AB_PCIE_HIVMODE_L_LBN 52
+#define        FRF_AB_PCIE_HIVMODE_L_WIDTH 1
+#define        FRF_AB_PCIE_PARRESET_H_LBN 51
+#define        FRF_AB_PCIE_PARRESET_H_WIDTH 1
+#define        FRF_AB_PCIE_PARRESET_L_LBN 50
+#define        FRF_AB_PCIE_PARRESET_L_WIDTH 1
+#define        FRF_AB_PCIE_LPBKWDRV_H_LBN 49
+#define        FRF_AB_PCIE_LPBKWDRV_H_WIDTH 1
+#define        FRF_AB_PCIE_LPBKWDRV_L_LBN 48
+#define        FRF_AB_PCIE_LPBKWDRV_L_WIDTH 1
+#define        FRF_AB_PCIE_LPBK_LBN 40
+#define        FRF_AB_PCIE_LPBK_WIDTH 8
+#define        FRF_AB_PCIE_PARLPBK_LBN 32
+#define        FRF_AB_PCIE_PARLPBK_WIDTH 8
+#define        FRF_AB_PCIE_RXTERMADJ_H_LBN 30
+#define        FRF_AB_PCIE_RXTERMADJ_H_WIDTH 2
+#define        FRF_AB_PCIE_RXTERMADJ_L_LBN 28
+#define        FRF_AB_PCIE_RXTERMADJ_L_WIDTH 2
+#define        FFE_AB_PCIE_RXTERMADJ_MIN15PCNT 3
+#define        FFE_AB_PCIE_RXTERMADJ_PL10PCNT 2
+#define        FFE_AB_PCIE_RXTERMADJ_MIN17PCNT 1
+#define        FFE_AB_PCIE_RXTERMADJ_NOMNL 0
+#define        FRF_AB_PCIE_TXTERMADJ_H_LBN 26
+#define        FRF_AB_PCIE_TXTERMADJ_H_WIDTH 2
+#define        FRF_AB_PCIE_TXTERMADJ_L_LBN 24
+#define        FRF_AB_PCIE_TXTERMADJ_L_WIDTH 2
+#define        FFE_AB_PCIE_TXTERMADJ_MIN15PCNT 3
+#define        FFE_AB_PCIE_TXTERMADJ_PL10PCNT 2
+#define        FFE_AB_PCIE_TXTERMADJ_MIN17PCNT 1
+#define        FFE_AB_PCIE_TXTERMADJ_NOMNL 0
+#define        FRF_AB_PCIE_RXEQCTL_H_LBN 18
+#define        FRF_AB_PCIE_RXEQCTL_H_WIDTH 2
+#define        FRF_AB_PCIE_RXEQCTL_L_LBN 16
+#define        FRF_AB_PCIE_RXEQCTL_L_WIDTH 2
+#define        FFE_AB_PCIE_RXEQCTL_OFF_ALT 3
+#define        FFE_AB_PCIE_RXEQCTL_OFF 2
+#define        FFE_AB_PCIE_RXEQCTL_MIN 1
+#define        FFE_AB_PCIE_RXEQCTL_MAX 0
+#define        FRF_AB_PCIE_HIDRV_LBN 8
+#define        FRF_AB_PCIE_HIDRV_WIDTH 8
+#define        FRF_AB_PCIE_LODRV_LBN 0
+#define        FRF_AB_PCIE_LODRV_WIDTH 8
+
+/* PCIE_SD_CTL45_REG: PCIE SerDes control register 4 and 5 */
+#define        FR_AB_PCIE_SD_CTL45 0x00000330
+#define        FRF_AB_PCIE_DTX7_LBN 60
+#define        FRF_AB_PCIE_DTX7_WIDTH 4
+#define        FRF_AB_PCIE_DTX6_LBN 56
+#define        FRF_AB_PCIE_DTX6_WIDTH 4
+#define        FRF_AB_PCIE_DTX5_LBN 52
+#define        FRF_AB_PCIE_DTX5_WIDTH 4
+#define        FRF_AB_PCIE_DTX4_LBN 48
+#define        FRF_AB_PCIE_DTX4_WIDTH 4
+#define        FRF_AB_PCIE_DTX3_LBN 44
+#define        FRF_AB_PCIE_DTX3_WIDTH 4
+#define        FRF_AB_PCIE_DTX2_LBN 40
+#define        FRF_AB_PCIE_DTX2_WIDTH 4
+#define        FRF_AB_PCIE_DTX1_LBN 36
+#define        FRF_AB_PCIE_DTX1_WIDTH 4
+#define        FRF_AB_PCIE_DTX0_LBN 32
+#define        FRF_AB_PCIE_DTX0_WIDTH 4
+#define        FRF_AB_PCIE_DEQ7_LBN 28
+#define        FRF_AB_PCIE_DEQ7_WIDTH 4
+#define        FRF_AB_PCIE_DEQ6_LBN 24
+#define        FRF_AB_PCIE_DEQ6_WIDTH 4
+#define        FRF_AB_PCIE_DEQ5_LBN 20
+#define        FRF_AB_PCIE_DEQ5_WIDTH 4
+#define        FRF_AB_PCIE_DEQ4_LBN 16
+#define        FRF_AB_PCIE_DEQ4_WIDTH 4
+#define        FRF_AB_PCIE_DEQ3_LBN 12
+#define        FRF_AB_PCIE_DEQ3_WIDTH 4
+#define        FRF_AB_PCIE_DEQ2_LBN 8
+#define        FRF_AB_PCIE_DEQ2_WIDTH 4
+#define        FRF_AB_PCIE_DEQ1_LBN 4
+#define        FRF_AB_PCIE_DEQ1_WIDTH 4
+#define        FRF_AB_PCIE_DEQ0_LBN 0
+#define        FRF_AB_PCIE_DEQ0_WIDTH 4
+
+/* PCIE_PCS_CTL_STAT_REG: PCIE PCS control and status register */
+#define        FR_AB_PCIE_PCS_CTL_STAT 0x00000340
+#define        FRF_AB_PCIE_PRBSERRCOUNT0_H_LBN 52
+#define        FRF_AB_PCIE_PRBSERRCOUNT0_H_WIDTH 4
+#define        FRF_AB_PCIE_PRBSERRCOUNT0_L_LBN 48
+#define        FRF_AB_PCIE_PRBSERRCOUNT0_L_WIDTH 4
+#define        FRF_AB_PCIE_PRBSERR_LBN 40
+#define        FRF_AB_PCIE_PRBSERR_WIDTH 8
+#define        FRF_AB_PCIE_PRBSERRH0_LBN 32
+#define        FRF_AB_PCIE_PRBSERRH0_WIDTH 8
+#define        FRF_AB_PCIE_FASTINIT_H_LBN 15
+#define        FRF_AB_PCIE_FASTINIT_H_WIDTH 1
+#define        FRF_AB_PCIE_FASTINIT_L_LBN 14
+#define        FRF_AB_PCIE_FASTINIT_L_WIDTH 1
+#define        FRF_AB_PCIE_CTCDISABLE_H_LBN 13
+#define        FRF_AB_PCIE_CTCDISABLE_H_WIDTH 1
+#define        FRF_AB_PCIE_CTCDISABLE_L_LBN 12
+#define        FRF_AB_PCIE_CTCDISABLE_L_WIDTH 1
+#define        FRF_AB_PCIE_PRBSSYNC_H_LBN 11
+#define        FRF_AB_PCIE_PRBSSYNC_H_WIDTH 1
+#define        FRF_AB_PCIE_PRBSSYNC_L_LBN 10
+#define        FRF_AB_PCIE_PRBSSYNC_L_WIDTH 1
+#define        FRF_AB_PCIE_PRBSERRACK_H_LBN 9
+#define        FRF_AB_PCIE_PRBSERRACK_H_WIDTH 1
+#define        FRF_AB_PCIE_PRBSERRACK_L_LBN 8
+#define        FRF_AB_PCIE_PRBSERRACK_L_WIDTH 1
+#define        FRF_AB_PCIE_PRBSSEL_LBN 0
+#define        FRF_AB_PCIE_PRBSSEL_WIDTH 8
+
+/* DEBUG_DATA_OUT_REG: Live Debug and Debug 2 out ports */
+#define        FR_BB_DEBUG_DATA_OUT 0x00000350
+#define        FRF_BB_DEBUG2_PORT_LBN 25
+#define        FRF_BB_DEBUG2_PORT_WIDTH 15
+#define        FRF_BB_DEBUG1_PORT_LBN 0
+#define        FRF_BB_DEBUG1_PORT_WIDTH 25
+
+/* EVQ_RPTR_REGP0: Event queue read pointer register */
+#define        FR_BZ_EVQ_RPTR_P0 0x00000400
+#define        FR_BZ_EVQ_RPTR_P0_STEP 8192
+#define        FR_BZ_EVQ_RPTR_P0_ROWS 1024
+/* EVQ_RPTR_REG_KER: Event queue read pointer register */
+#define        FR_AA_EVQ_RPTR_KER 0x00011b00
+#define        FR_AA_EVQ_RPTR_KER_STEP 4
+#define        FR_AA_EVQ_RPTR_KER_ROWS 4
+/* EVQ_RPTR_REG: Event queue read pointer register */
+#define        FR_BZ_EVQ_RPTR 0x00fa0000
+#define        FR_BZ_EVQ_RPTR_STEP 16
+#define        FR_BB_EVQ_RPTR_ROWS 4096
+#define        FR_CZ_EVQ_RPTR_ROWS 1024
+/* EVQ_RPTR_REGP123: Event queue read pointer register */
+#define        FR_BB_EVQ_RPTR_P123 0x01000400
+#define        FR_BB_EVQ_RPTR_P123_STEP 8192
+#define        FR_BB_EVQ_RPTR_P123_ROWS 3072
+#define        FRF_AZ_EVQ_RPTR_VLD_LBN 15
+#define        FRF_AZ_EVQ_RPTR_VLD_WIDTH 1
+#define        FRF_AZ_EVQ_RPTR_LBN 0
+#define        FRF_AZ_EVQ_RPTR_WIDTH 15
+
+/* TIMER_COMMAND_REGP0: Timer Command Registers */
+#define        FR_BZ_TIMER_COMMAND_P0 0x00000420
+#define        FR_BZ_TIMER_COMMAND_P0_STEP 8192
+#define        FR_BZ_TIMER_COMMAND_P0_ROWS 1024
+/* TIMER_COMMAND_REG_KER: Timer Command Registers */
+#define        FR_AA_TIMER_COMMAND_KER 0x00000420
+#define        FR_AA_TIMER_COMMAND_KER_STEP 8192
+#define        FR_AA_TIMER_COMMAND_KER_ROWS 4
+/* TIMER_COMMAND_REGP123: Timer Command Registers */
+#define        FR_BB_TIMER_COMMAND_P123 0x01000420
+#define        FR_BB_TIMER_COMMAND_P123_STEP 8192
+#define        FR_BB_TIMER_COMMAND_P123_ROWS 3072
+#define        FRF_CZ_TC_TIMER_MODE_LBN 14
+#define        FRF_CZ_TC_TIMER_MODE_WIDTH 2
+#define        FRF_AB_TC_TIMER_MODE_LBN 12
+#define        FRF_AB_TC_TIMER_MODE_WIDTH 2
+#define        FRF_CZ_TC_TIMER_VAL_LBN 0
+#define        FRF_CZ_TC_TIMER_VAL_WIDTH 14
+#define        FRF_AB_TC_TIMER_VAL_LBN 0
+#define        FRF_AB_TC_TIMER_VAL_WIDTH 12
+
+/* DRV_EV_REG: Driver generated event register */
+#define        FR_AZ_DRV_EV 0x00000440
+#define        FRF_AZ_DRV_EV_QID_LBN 64
+#define        FRF_AZ_DRV_EV_QID_WIDTH 12
+#define        FRF_AZ_DRV_EV_DATA_LBN 0
+#define        FRF_AZ_DRV_EV_DATA_WIDTH 64
+
+/* EVQ_CTL_REG: Event queue control register */
+#define        FR_AZ_EVQ_CTL 0x00000450
+#define        FRF_CZ_RX_EVQ_WAKEUP_MASK_LBN 15
+#define        FRF_CZ_RX_EVQ_WAKEUP_MASK_WIDTH 10
+#define        FRF_BB_RX_EVQ_WAKEUP_MASK_LBN 15
+#define        FRF_BB_RX_EVQ_WAKEUP_MASK_WIDTH 6
+#define        FRF_AZ_EVQ_OWNERR_CTL_LBN 14
+#define        FRF_AZ_EVQ_OWNERR_CTL_WIDTH 1
+#define        FRF_AZ_EVQ_FIFO_AF_TH_LBN 7
+#define        FRF_AZ_EVQ_FIFO_AF_TH_WIDTH 7
+#define        FRF_AZ_EVQ_FIFO_NOTAF_TH_LBN 0
+#define        FRF_AZ_EVQ_FIFO_NOTAF_TH_WIDTH 7
+
+/* EVQ_CNT1_REG: Event counter 1 register */
+#define        FR_AZ_EVQ_CNT1 0x00000460
+#define        FRF_AZ_EVQ_CNT_PRE_FIFO_LBN 120
+#define        FRF_AZ_EVQ_CNT_PRE_FIFO_WIDTH 7
+#define        FRF_AZ_EVQ_CNT_TOBIU_LBN 100
+#define        FRF_AZ_EVQ_CNT_TOBIU_WIDTH 20
+#define        FRF_AZ_EVQ_TX_REQ_CNT_LBN 80
+#define        FRF_AZ_EVQ_TX_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_RX_REQ_CNT_LBN 60
+#define        FRF_AZ_EVQ_RX_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_EM_REQ_CNT_LBN 40
+#define        FRF_AZ_EVQ_EM_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_CSR_REQ_CNT_LBN 20
+#define        FRF_AZ_EVQ_CSR_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_ERR_REQ_CNT_LBN 0
+#define        FRF_AZ_EVQ_ERR_REQ_CNT_WIDTH 20
+
+/* EVQ_CNT2_REG: Event counter 2 register */
+#define        FR_AZ_EVQ_CNT2 0x00000470
+#define        FRF_AZ_EVQ_UPD_REQ_CNT_LBN 104
+#define        FRF_AZ_EVQ_UPD_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_CLR_REQ_CNT_LBN 84
+#define        FRF_AZ_EVQ_CLR_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_RDY_CNT_LBN 80
+#define        FRF_AZ_EVQ_RDY_CNT_WIDTH 4
+#define        FRF_AZ_EVQ_WU_REQ_CNT_LBN 60
+#define        FRF_AZ_EVQ_WU_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_WET_REQ_CNT_LBN 40
+#define        FRF_AZ_EVQ_WET_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_INIT_REQ_CNT_LBN 20
+#define        FRF_AZ_EVQ_INIT_REQ_CNT_WIDTH 20
+#define        FRF_AZ_EVQ_TM_REQ_CNT_LBN 0
+#define        FRF_AZ_EVQ_TM_REQ_CNT_WIDTH 20
+
+/* USR_EV_REG: Event mailbox register */
+#define        FR_CZ_USR_EV 0x00000540
+#define        FR_CZ_USR_EV_STEP 8192
+#define        FR_CZ_USR_EV_ROWS 1024
+#define        FRF_CZ_USR_EV_DATA_LBN 0
+#define        FRF_CZ_USR_EV_DATA_WIDTH 32
+
+/* BUF_TBL_CFG_REG: Buffer table configuration register */
+#define        FR_AZ_BUF_TBL_CFG 0x00000600
+#define        FRF_AZ_BUF_TBL_MODE_LBN 3
+#define        FRF_AZ_BUF_TBL_MODE_WIDTH 1
+
+/* SRM_RX_DC_CFG_REG: SRAM receive descriptor cache configuration register */
+#define        FR_AZ_SRM_RX_DC_CFG 0x00000610
+#define        FRF_AZ_SRM_CLK_TMP_EN_LBN 21
+#define        FRF_AZ_SRM_CLK_TMP_EN_WIDTH 1
+#define        FRF_AZ_SRM_RX_DC_BASE_ADR_LBN 0
+#define        FRF_AZ_SRM_RX_DC_BASE_ADR_WIDTH 21
+
+/* SRM_TX_DC_CFG_REG: SRAM transmit descriptor cache configuration register */
+#define        FR_AZ_SRM_TX_DC_CFG 0x00000620
+#define        FRF_AZ_SRM_TX_DC_BASE_ADR_LBN 0
+#define        FRF_AZ_SRM_TX_DC_BASE_ADR_WIDTH 21
+
+/* SRM_CFG_REG: SRAM configuration register */
+#define        FR_AZ_SRM_CFG 0x00000630
+#define        FRF_AZ_SRM_OOB_ADR_INTEN_LBN 5
+#define        FRF_AZ_SRM_OOB_ADR_INTEN_WIDTH 1
+#define        FRF_AZ_SRM_OOB_BUF_INTEN_LBN 4
+#define        FRF_AZ_SRM_OOB_BUF_INTEN_WIDTH 1
+#define        FRF_AZ_SRM_INIT_EN_LBN 3
+#define        FRF_AZ_SRM_INIT_EN_WIDTH 1
+#define        FRF_AZ_SRM_NUM_BANK_LBN 2
+#define        FRF_AZ_SRM_NUM_BANK_WIDTH 1
+#define        FRF_AZ_SRM_BANK_SIZE_LBN 0
+#define        FRF_AZ_SRM_BANK_SIZE_WIDTH 2
+
+/* BUF_TBL_UPD_REG: Buffer table update register */
+#define        FR_AZ_BUF_TBL_UPD 0x00000650
+#define        FRF_AZ_BUF_UPD_CMD_LBN 63
+#define        FRF_AZ_BUF_UPD_CMD_WIDTH 1
+#define        FRF_AZ_BUF_CLR_CMD_LBN 62
+#define        FRF_AZ_BUF_CLR_CMD_WIDTH 1
+#define        FRF_AZ_BUF_CLR_END_ID_LBN 32
+#define        FRF_AZ_BUF_CLR_END_ID_WIDTH 20
+#define        FRF_AZ_BUF_CLR_START_ID_LBN 0
+#define        FRF_AZ_BUF_CLR_START_ID_WIDTH 20
+
+/* SRM_UPD_EVQ_REG: Buffer table update register */
+#define        FR_AZ_SRM_UPD_EVQ 0x00000660
+#define        FRF_AZ_SRM_UPD_EVQ_ID_LBN 0
+#define        FRF_AZ_SRM_UPD_EVQ_ID_WIDTH 12
+
+/* SRAM_PARITY_REG: SRAM parity register. */
+#define        FR_AZ_SRAM_PARITY 0x00000670
+#define        FRF_CZ_BYPASS_ECC_LBN 3
+#define        FRF_CZ_BYPASS_ECC_WIDTH 1
+#define        FRF_CZ_SEC_INT_LBN 2
+#define        FRF_CZ_SEC_INT_WIDTH 1
+#define        FRF_CZ_FORCE_SRAM_DOUBLE_ERR_LBN 1
+#define        FRF_CZ_FORCE_SRAM_DOUBLE_ERR_WIDTH 1
+#define        FRF_AB_FORCE_SRAM_PERR_LBN 0
+#define        FRF_AB_FORCE_SRAM_PERR_WIDTH 1
+#define        FRF_CZ_FORCE_SRAM_SINGLE_ERR_LBN 0
+#define        FRF_CZ_FORCE_SRAM_SINGLE_ERR_WIDTH 1
+
+/* RX_CFG_REG: Receive configuration register */
+#define        FR_AZ_RX_CFG 0x00000800
+#define        FRF_CZ_RX_MIN_KBUF_SIZE_LBN 72
+#define        FRF_CZ_RX_MIN_KBUF_SIZE_WIDTH 14
+#define        FRF_CZ_RX_HDR_SPLIT_EN_LBN 71
+#define        FRF_CZ_RX_HDR_SPLIT_EN_WIDTH 1
+#define        FRF_CZ_RX_HDR_SPLIT_PLD_BUF_SIZE_LBN 62
+#define        FRF_CZ_RX_HDR_SPLIT_PLD_BUF_SIZE_WIDTH 9
+#define        FRF_CZ_RX_HDR_SPLIT_HDR_BUF_SIZE_LBN 53
+#define        FRF_CZ_RX_HDR_SPLIT_HDR_BUF_SIZE_WIDTH 9
+#define        FRF_CZ_RX_PRE_RFF_IPG_LBN 49
+#define        FRF_CZ_RX_PRE_RFF_IPG_WIDTH 4
+#define        FRF_BZ_RX_TCP_SUP_LBN 48
+#define        FRF_BZ_RX_TCP_SUP_WIDTH 1
+#define        FRF_BZ_RX_INGR_EN_LBN 47
+#define        FRF_BZ_RX_INGR_EN_WIDTH 1
+#define        FRF_BZ_RX_IP_HASH_LBN 46
+#define        FRF_BZ_RX_IP_HASH_WIDTH 1
+#define        FRF_BZ_RX_HASH_ALG_LBN 45
+#define        FRF_BZ_RX_HASH_ALG_WIDTH 1
+#define        FRF_BZ_RX_HASH_INSRT_HDR_LBN 44
+#define        FRF_BZ_RX_HASH_INSRT_HDR_WIDTH 1
+#define        FRF_BZ_RX_DESC_PUSH_EN_LBN 43
+#define        FRF_BZ_RX_DESC_PUSH_EN_WIDTH 1
+#define        FRF_BZ_RX_RDW_PATCH_EN_LBN 42
+#define        FRF_BZ_RX_RDW_PATCH_EN_WIDTH 1
+#define        FRF_BB_RX_PCI_BURST_SIZE_LBN 39
+#define        FRF_BB_RX_PCI_BURST_SIZE_WIDTH 3
+#define        FRF_BZ_RX_OWNERR_CTL_LBN 38
+#define        FRF_BZ_RX_OWNERR_CTL_WIDTH 1
+#define        FRF_BZ_RX_XON_TX_TH_LBN 33
+#define        FRF_BZ_RX_XON_TX_TH_WIDTH 5
+#define        FRF_AA_RX_DESC_PUSH_EN_LBN 35
+#define        FRF_AA_RX_DESC_PUSH_EN_WIDTH 1
+#define        FRF_AA_RX_RDW_PATCH_EN_LBN 34
+#define        FRF_AA_RX_RDW_PATCH_EN_WIDTH 1
+#define        FRF_AA_RX_PCI_BURST_SIZE_LBN 31
+#define        FRF_AA_RX_PCI_BURST_SIZE_WIDTH 3
+#define        FRF_BZ_RX_XOFF_TX_TH_LBN 28
+#define        FRF_BZ_RX_XOFF_TX_TH_WIDTH 5
+#define        FRF_AA_RX_OWNERR_CTL_LBN 30
+#define        FRF_AA_RX_OWNERR_CTL_WIDTH 1
+#define        FRF_AA_RX_XON_TX_TH_LBN 25
+#define        FRF_AA_RX_XON_TX_TH_WIDTH 5
+#define        FRF_BZ_RX_USR_BUF_SIZE_LBN 19
+#define        FRF_BZ_RX_USR_BUF_SIZE_WIDTH 9
+#define        FRF_AA_RX_XOFF_TX_TH_LBN 20
+#define        FRF_AA_RX_XOFF_TX_TH_WIDTH 5
+#define        FRF_AA_RX_USR_BUF_SIZE_LBN 11
+#define        FRF_AA_RX_USR_BUF_SIZE_WIDTH 9
+#define        FRF_BZ_RX_XON_MAC_TH_LBN 10
+#define        FRF_BZ_RX_XON_MAC_TH_WIDTH 9
+#define        FRF_AA_RX_XON_MAC_TH_LBN 6
+#define        FRF_AA_RX_XON_MAC_TH_WIDTH 5
+#define        FRF_BZ_RX_XOFF_MAC_TH_LBN 1
+#define        FRF_BZ_RX_XOFF_MAC_TH_WIDTH 9
+#define        FRF_AA_RX_XOFF_MAC_TH_LBN 1
+#define        FRF_AA_RX_XOFF_MAC_TH_WIDTH 5
+#define        FRF_AZ_RX_XOFF_MAC_EN_LBN 0
+#define        FRF_AZ_RX_XOFF_MAC_EN_WIDTH 1
+
+/* RX_FILTER_CTL_REG: Receive filter control registers */
+#define        FR_BZ_RX_FILTER_CTL 0x00000810
+#define        FRF_CZ_ETHERNET_WILDCARD_SEARCH_LIMIT_LBN 94
+#define        FRF_CZ_ETHERNET_WILDCARD_SEARCH_LIMIT_WIDTH 8
+#define        FRF_CZ_ETHERNET_FULL_SEARCH_LIMIT_LBN 86
+#define        FRF_CZ_ETHERNET_FULL_SEARCH_LIMIT_WIDTH 8
+#define        FRF_CZ_RX_FILTER_ALL_VLAN_ETHERTYPES_LBN 85
+#define        FRF_CZ_RX_FILTER_ALL_VLAN_ETHERTYPES_WIDTH 1
+#define        FRF_CZ_RX_VLAN_MATCH_ETHERTYPE_LBN 69
+#define        FRF_CZ_RX_VLAN_MATCH_ETHERTYPE_WIDTH 16
+#define        FRF_CZ_MULTICAST_NOMATCH_Q_ID_LBN 57
+#define        FRF_CZ_MULTICAST_NOMATCH_Q_ID_WIDTH 12
+#define        FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED_LBN 56
+#define        FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED_WIDTH 1
+#define        FRF_CZ_MULTICAST_NOMATCH_IP_OVERRIDE_LBN 55
+#define        FRF_CZ_MULTICAST_NOMATCH_IP_OVERRIDE_WIDTH 1
+#define        FRF_CZ_UNICAST_NOMATCH_Q_ID_LBN 43
+#define        FRF_CZ_UNICAST_NOMATCH_Q_ID_WIDTH 12
+#define        FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED_LBN 42
+#define        FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED_WIDTH 1
+#define        FRF_CZ_UNICAST_NOMATCH_IP_OVERRIDE_LBN 41
+#define        FRF_CZ_UNICAST_NOMATCH_IP_OVERRIDE_WIDTH 1
+#define        FRF_BZ_SCATTER_ENBL_NO_MATCH_Q_LBN 40
+#define        FRF_BZ_SCATTER_ENBL_NO_MATCH_Q_WIDTH 1
+#define        FRF_BZ_UDP_FULL_SRCH_LIMIT_LBN 32
+#define        FRF_BZ_UDP_FULL_SRCH_LIMIT_WIDTH 8
+#define        FRF_BZ_NUM_KER_LBN 24
+#define        FRF_BZ_NUM_KER_WIDTH 2
+#define        FRF_BZ_UDP_WILD_SRCH_LIMIT_LBN 16
+#define        FRF_BZ_UDP_WILD_SRCH_LIMIT_WIDTH 8
+#define        FRF_BZ_TCP_WILD_SRCH_LIMIT_LBN 8
+#define        FRF_BZ_TCP_WILD_SRCH_LIMIT_WIDTH 8
+#define        FRF_BZ_TCP_FULL_SRCH_LIMIT_LBN 0
+#define        FRF_BZ_TCP_FULL_SRCH_LIMIT_WIDTH 8
+
+/* RX_FLUSH_DESCQ_REG: Receive flush descriptor queue register */
+#define        FR_AZ_RX_FLUSH_DESCQ 0x00000820
+#define        FRF_AZ_RX_FLUSH_DESCQ_CMD_LBN 24
+#define        FRF_AZ_RX_FLUSH_DESCQ_CMD_WIDTH 1
+#define        FRF_AZ_RX_FLUSH_DESCQ_LBN 0
+#define        FRF_AZ_RX_FLUSH_DESCQ_WIDTH 12
+
+/* RX_DESC_UPD_REGP0: Receive descriptor update register. */
+#define        FR_BZ_RX_DESC_UPD_P0 0x00000830
+#define        FR_BZ_RX_DESC_UPD_P0_STEP 8192
+#define        FR_BZ_RX_DESC_UPD_P0_ROWS 1024
+/* RX_DESC_UPD_REG_KER: Receive descriptor update register. */
+#define        FR_AA_RX_DESC_UPD_KER 0x00000830
+#define        FR_AA_RX_DESC_UPD_KER_STEP 8192
+#define        FR_AA_RX_DESC_UPD_KER_ROWS 4
+/* RX_DESC_UPD_REGP123: Receive descriptor update register. */
+#define        FR_BB_RX_DESC_UPD_P123 0x01000830
+#define        FR_BB_RX_DESC_UPD_P123_STEP 8192
+#define        FR_BB_RX_DESC_UPD_P123_ROWS 3072
+#define        FRF_AZ_RX_DESC_WPTR_LBN 96
+#define        FRF_AZ_RX_DESC_WPTR_WIDTH 12
+#define        FRF_AZ_RX_DESC_PUSH_CMD_LBN 95
+#define        FRF_AZ_RX_DESC_PUSH_CMD_WIDTH 1
+#define        FRF_AZ_RX_DESC_LBN 0
+#define        FRF_AZ_RX_DESC_WIDTH 64
+
+/* RX_DC_CFG_REG: Receive descriptor cache configuration register */
+#define        FR_AZ_RX_DC_CFG 0x00000840
+#define        FRF_AB_RX_MAX_PF_LBN 2
+#define        FRF_AB_RX_MAX_PF_WIDTH 2
+#define        FRF_AZ_RX_DC_SIZE_LBN 0
+#define        FRF_AZ_RX_DC_SIZE_WIDTH 2
+#define        FFE_AZ_RX_DC_SIZE_64 3
+#define        FFE_AZ_RX_DC_SIZE_32 2
+#define        FFE_AZ_RX_DC_SIZE_16 1
+#define        FFE_AZ_RX_DC_SIZE_8 0
+
+/* RX_DC_PF_WM_REG: Receive descriptor cache pre-fetch watermark register */
+#define        FR_AZ_RX_DC_PF_WM 0x00000850
+#define        FRF_AZ_RX_DC_PF_HWM_LBN 6
+#define        FRF_AZ_RX_DC_PF_HWM_WIDTH 6
+#define        FRF_AZ_RX_DC_PF_LWM_LBN 0
+#define        FRF_AZ_RX_DC_PF_LWM_WIDTH 6
+
+/* RX_RSS_TKEY_REG: RSS Toeplitz hash key */
+#define        FR_BZ_RX_RSS_TKEY 0x00000860
+#define        FRF_BZ_RX_RSS_TKEY_HI_LBN 64
+#define        FRF_BZ_RX_RSS_TKEY_HI_WIDTH 64
+#define        FRF_BZ_RX_RSS_TKEY_LO_LBN 0
+#define        FRF_BZ_RX_RSS_TKEY_LO_WIDTH 64
+
+/* RX_NODESC_DROP_REG: Receive dropped packet counter register */
+#define        FR_AZ_RX_NODESC_DROP 0x00000880
+#define        FRF_CZ_RX_NODESC_DROP_CNT_LBN 0
+#define        FRF_CZ_RX_NODESC_DROP_CNT_WIDTH 32
+#define        FRF_AB_RX_NODESC_DROP_CNT_LBN 0
+#define        FRF_AB_RX_NODESC_DROP_CNT_WIDTH 16
+
+/* RX_SELF_RST_REG: Receive self reset register */
+#define        FR_AA_RX_SELF_RST 0x00000890
+#define        FRF_AA_RX_ISCSI_DIS_LBN 17
+#define        FRF_AA_RX_ISCSI_DIS_WIDTH 1
+#define        FRF_AA_RX_SW_RST_REG_LBN 16
+#define        FRF_AA_RX_SW_RST_REG_WIDTH 1
+#define FRF_AA_RX_NODESC_WAIT_DIS_LBN 9
+#define FRF_AA_RX_NODESC_WAIT_DIS_WIDTH 1
+#define        FRF_AA_RX_SELF_RST_EN_LBN 8
+#define        FRF_AA_RX_SELF_RST_EN_WIDTH 1
+#define        FRF_AA_RX_MAX_PF_LAT_LBN 4
+#define        FRF_AA_RX_MAX_PF_LAT_WIDTH 4
+#define        FRF_AA_RX_MAX_LU_LAT_LBN 0
+#define        FRF_AA_RX_MAX_LU_LAT_WIDTH 4
+
+/* RX_DEBUG_REG: undocumented register */
+#define        FR_AZ_RX_DEBUG 0x000008a0
+#define        FRF_AZ_RX_DEBUG_LBN 0
+#define        FRF_AZ_RX_DEBUG_WIDTH 64
+
+/* RX_PUSH_DROP_REG: Receive descriptor push dropped counter register */
+#define        FR_AZ_RX_PUSH_DROP 0x000008b0
+#define        FRF_AZ_RX_PUSH_DROP_CNT_LBN 0
+#define        FRF_AZ_RX_PUSH_DROP_CNT_WIDTH 32
+
+/* RX_RSS_IPV6_REG1: IPv6 RSS Toeplitz hash key low bytes */
+#define        FR_CZ_RX_RSS_IPV6_REG1 0x000008d0
+#define        FRF_CZ_RX_RSS_IPV6_TKEY_LO_LBN 0
+#define        FRF_CZ_RX_RSS_IPV6_TKEY_LO_WIDTH 128
+
+/* RX_RSS_IPV6_REG2: IPv6 RSS Toeplitz hash key middle bytes */
+#define        FR_CZ_RX_RSS_IPV6_REG2 0x000008e0
+#define        FRF_CZ_RX_RSS_IPV6_TKEY_MID_LBN 0
+#define        FRF_CZ_RX_RSS_IPV6_TKEY_MID_WIDTH 128
+
+/* RX_RSS_IPV6_REG3: IPv6 RSS Toeplitz hash key upper bytes and IPv6 RSS settings */
+#define        FR_CZ_RX_RSS_IPV6_REG3 0x000008f0
+#define        FRF_CZ_RX_RSS_IPV6_THASH_ENABLE_LBN 66
+#define        FRF_CZ_RX_RSS_IPV6_THASH_ENABLE_WIDTH 1
+#define        FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE_LBN 65
+#define        FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE_WIDTH 1
+#define        FRF_CZ_RX_RSS_IPV6_TCP_SUPPRESS_LBN 64
+#define        FRF_CZ_RX_RSS_IPV6_TCP_SUPPRESS_WIDTH 1
+#define        FRF_CZ_RX_RSS_IPV6_TKEY_HI_LBN 0
+#define        FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH 64
+
+/* TX_FLUSH_DESCQ_REG: Transmit flush descriptor queue register */
+#define        FR_AZ_TX_FLUSH_DESCQ 0x00000a00
+#define        FRF_AZ_TX_FLUSH_DESCQ_CMD_LBN 12
+#define        FRF_AZ_TX_FLUSH_DESCQ_CMD_WIDTH 1
+#define        FRF_AZ_TX_FLUSH_DESCQ_LBN 0
+#define        FRF_AZ_TX_FLUSH_DESCQ_WIDTH 12
+
+/* TX_DESC_UPD_REGP0: Transmit descriptor update register. */
+#define        FR_BZ_TX_DESC_UPD_P0 0x00000a10
+#define        FR_BZ_TX_DESC_UPD_P0_STEP 8192
+#define        FR_BZ_TX_DESC_UPD_P0_ROWS 1024
+/* TX_DESC_UPD_REG_KER: Transmit descriptor update register. */
+#define        FR_AA_TX_DESC_UPD_KER 0x00000a10
+#define        FR_AA_TX_DESC_UPD_KER_STEP 8192
+#define        FR_AA_TX_DESC_UPD_KER_ROWS 8
+/* TX_DESC_UPD_REGP123: Transmit descriptor update register. */
+#define        FR_BB_TX_DESC_UPD_P123 0x01000a10
+#define        FR_BB_TX_DESC_UPD_P123_STEP 8192
+#define        FR_BB_TX_DESC_UPD_P123_ROWS 3072
+#define        FRF_AZ_TX_DESC_WPTR_LBN 96
+#define        FRF_AZ_TX_DESC_WPTR_WIDTH 12
+#define        FRF_AZ_TX_DESC_PUSH_CMD_LBN 95
+#define        FRF_AZ_TX_DESC_PUSH_CMD_WIDTH 1
+#define        FRF_AZ_TX_DESC_LBN 0
+#define        FRF_AZ_TX_DESC_WIDTH 95
+
+/* TX_DC_CFG_REG: Transmit descriptor cache configuration register */
+#define        FR_AZ_TX_DC_CFG 0x00000a20
+#define        FRF_AZ_TX_DC_SIZE_LBN 0
+#define        FRF_AZ_TX_DC_SIZE_WIDTH 2
+#define        FFE_AZ_TX_DC_SIZE_32 2
+#define        FFE_AZ_TX_DC_SIZE_16 1
+#define        FFE_AZ_TX_DC_SIZE_8 0
+
+/* TX_CHKSM_CFG_REG: Transmit checksum configuration register */
+#define        FR_AA_TX_CHKSM_CFG 0x00000a30
+#define        FRF_AA_TX_Q_CHKSM_DIS_96_127_LBN 96
+#define        FRF_AA_TX_Q_CHKSM_DIS_96_127_WIDTH 32
+#define        FRF_AA_TX_Q_CHKSM_DIS_64_95_LBN 64
+#define        FRF_AA_TX_Q_CHKSM_DIS_64_95_WIDTH 32
+#define        FRF_AA_TX_Q_CHKSM_DIS_32_63_LBN 32
+#define        FRF_AA_TX_Q_CHKSM_DIS_32_63_WIDTH 32
+#define        FRF_AA_TX_Q_CHKSM_DIS_0_31_LBN 0
+#define        FRF_AA_TX_Q_CHKSM_DIS_0_31_WIDTH 32
+
+/* TX_CFG_REG: Transmit configuration register */
+#define        FR_AZ_TX_CFG 0x00000a50
+#define        FRF_CZ_TX_CONT_LOOKUP_THRESH_RANGE_LBN 114
+#define        FRF_CZ_TX_CONT_LOOKUP_THRESH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_FILTER_TEST_MODE_BIT_LBN 113
+#define        FRF_CZ_TX_FILTER_TEST_MODE_BIT_WIDTH 1
+#define        FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE_LBN 105
+#define        FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE_LBN 97
+#define        FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_UDPIP_FILTER_WILD_SEARCH_RANGE_LBN 89
+#define        FRF_CZ_TX_UDPIP_FILTER_WILD_SEARCH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_UDPIP_FILTER_FULL_SEARCH_RANGE_LBN 81
+#define        FRF_CZ_TX_UDPIP_FILTER_FULL_SEARCH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_TCPIP_FILTER_WILD_SEARCH_RANGE_LBN 73
+#define        FRF_CZ_TX_TCPIP_FILTER_WILD_SEARCH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_TCPIP_FILTER_FULL_SEARCH_RANGE_LBN 65
+#define        FRF_CZ_TX_TCPIP_FILTER_FULL_SEARCH_RANGE_WIDTH 8
+#define        FRF_CZ_TX_FILTER_ALL_VLAN_ETHERTYPES_BIT_LBN 64
+#define        FRF_CZ_TX_FILTER_ALL_VLAN_ETHERTYPES_BIT_WIDTH 1
+#define        FRF_CZ_TX_VLAN_MATCH_ETHERTYPE_RANGE_LBN 48
+#define        FRF_CZ_TX_VLAN_MATCH_ETHERTYPE_RANGE_WIDTH 16
+#define        FRF_CZ_TX_FILTER_EN_BIT_LBN 47
+#define        FRF_CZ_TX_FILTER_EN_BIT_WIDTH 1
+#define        FRF_AZ_TX_IP_ID_P0_OFS_LBN 16
+#define        FRF_AZ_TX_IP_ID_P0_OFS_WIDTH 15
+#define        FRF_AZ_TX_NO_EOP_DISC_EN_LBN 5
+#define        FRF_AZ_TX_NO_EOP_DISC_EN_WIDTH 1
+#define        FRF_AZ_TX_P1_PRI_EN_LBN 4
+#define        FRF_AZ_TX_P1_PRI_EN_WIDTH 1
+#define        FRF_AZ_TX_OWNERR_CTL_LBN 2
+#define        FRF_AZ_TX_OWNERR_CTL_WIDTH 1
+#define        FRF_AA_TX_NON_IP_DROP_DIS_LBN 1
+#define        FRF_AA_TX_NON_IP_DROP_DIS_WIDTH 1
+#define        FRF_AZ_TX_IP_ID_REP_EN_LBN 0
+#define        FRF_AZ_TX_IP_ID_REP_EN_WIDTH 1
+
+/* TX_PUSH_DROP_REG: Transmit push dropped register */
+#define        FR_AZ_TX_PUSH_DROP 0x00000a60
+#define        FRF_AZ_TX_PUSH_DROP_CNT_LBN 0
+#define        FRF_AZ_TX_PUSH_DROP_CNT_WIDTH 32
+
+/* TX_RESERVED_REG: Transmit configuration register */
+#define        FR_AZ_TX_RESERVED 0x00000a80
+#define        FRF_AZ_TX_EVT_CNT_LBN 121
+#define        FRF_AZ_TX_EVT_CNT_WIDTH 7
+#define        FRF_AZ_TX_PREF_AGE_CNT_LBN 119
+#define        FRF_AZ_TX_PREF_AGE_CNT_WIDTH 2
+#define        FRF_AZ_TX_RD_COMP_TMR_LBN 96
+#define        FRF_AZ_TX_RD_COMP_TMR_WIDTH 23
+#define        FRF_AZ_TX_PUSH_EN_LBN 89
+#define        FRF_AZ_TX_PUSH_EN_WIDTH 1
+#define        FRF_AZ_TX_PUSH_CHK_DIS_LBN 88
+#define        FRF_AZ_TX_PUSH_CHK_DIS_WIDTH 1
+#define        FRF_AZ_TX_D_FF_FULL_P0_LBN 85
+#define        FRF_AZ_TX_D_FF_FULL_P0_WIDTH 1
+#define        FRF_AZ_TX_DMAR_ST_P0_LBN 81
+#define        FRF_AZ_TX_DMAR_ST_P0_WIDTH 1
+#define        FRF_AZ_TX_DMAQ_ST_LBN 78
+#define        FRF_AZ_TX_DMAQ_ST_WIDTH 1
+#define        FRF_AZ_TX_RX_SPACER_LBN 64
+#define        FRF_AZ_TX_RX_SPACER_WIDTH 8
+#define        FRF_AZ_TX_DROP_ABORT_EN_LBN 60
+#define        FRF_AZ_TX_DROP_ABORT_EN_WIDTH 1
+#define        FRF_AZ_TX_SOFT_EVT_EN_LBN 59
+#define        FRF_AZ_TX_SOFT_EVT_EN_WIDTH 1
+#define        FRF_AZ_TX_PS_EVT_DIS_LBN 58
+#define        FRF_AZ_TX_PS_EVT_DIS_WIDTH 1
+#define        FRF_AZ_TX_RX_SPACER_EN_LBN 57
+#define        FRF_AZ_TX_RX_SPACER_EN_WIDTH 1
+#define        FRF_AZ_TX_XP_TIMER_LBN 52
+#define        FRF_AZ_TX_XP_TIMER_WIDTH 5
+#define        FRF_AZ_TX_PREF_SPACER_LBN 44
+#define        FRF_AZ_TX_PREF_SPACER_WIDTH 8
+#define        FRF_AZ_TX_PREF_WD_TMR_LBN 22
+#define        FRF_AZ_TX_PREF_WD_TMR_WIDTH 22
+#define        FRF_AZ_TX_ONLY1TAG_LBN 21
+#define        FRF_AZ_TX_ONLY1TAG_WIDTH 1
+#define        FRF_AZ_TX_PREF_THRESHOLD_LBN 19
+#define        FRF_AZ_TX_PREF_THRESHOLD_WIDTH 2
+#define        FRF_AZ_TX_ONE_PKT_PER_Q_LBN 18
+#define        FRF_AZ_TX_ONE_PKT_PER_Q_WIDTH 1
+#define        FRF_AZ_TX_DIS_NON_IP_EV_LBN 17
+#define        FRF_AZ_TX_DIS_NON_IP_EV_WIDTH 1
+#define        FRF_AA_TX_DMA_FF_THR_LBN 16
+#define        FRF_AA_TX_DMA_FF_THR_WIDTH 1
+#define        FRF_AZ_TX_DMA_SPACER_LBN 8
+#define        FRF_AZ_TX_DMA_SPACER_WIDTH 8
+#define        FRF_AA_TX_TCP_DIS_LBN 7
+#define        FRF_AA_TX_TCP_DIS_WIDTH 1
+#define        FRF_BZ_TX_FLUSH_MIN_LEN_EN_LBN 7
+#define        FRF_BZ_TX_FLUSH_MIN_LEN_EN_WIDTH 1
+#define        FRF_AA_TX_IP_DIS_LBN 6
+#define        FRF_AA_TX_IP_DIS_WIDTH 1
+#define        FRF_AZ_TX_MAX_CPL_LBN 2
+#define        FRF_AZ_TX_MAX_CPL_WIDTH 2
+#define        FFE_AZ_TX_MAX_CPL_16 3
+#define        FFE_AZ_TX_MAX_CPL_8 2
+#define        FFE_AZ_TX_MAX_CPL_4 1
+#define        FFE_AZ_TX_MAX_CPL_NOLIMIT 0
+#define        FRF_AZ_TX_MAX_PREF_LBN 0
+#define        FRF_AZ_TX_MAX_PREF_WIDTH 2
+#define        FFE_AZ_TX_MAX_PREF_32 3
+#define        FFE_AZ_TX_MAX_PREF_16 2
+#define        FFE_AZ_TX_MAX_PREF_8 1
+#define        FFE_AZ_TX_MAX_PREF_OFF 0
+
+/* TX_PACE_REG: Transmit pace control register */
+#define        FR_BZ_TX_PACE 0x00000a90
+#define        FRF_BZ_TX_PACE_SB_NOT_AF_LBN 19
+#define        FRF_BZ_TX_PACE_SB_NOT_AF_WIDTH 10
+#define        FRF_BZ_TX_PACE_SB_AF_LBN 9
+#define        FRF_BZ_TX_PACE_SB_AF_WIDTH 10
+#define        FRF_BZ_TX_PACE_FB_BASE_LBN 5
+#define        FRF_BZ_TX_PACE_FB_BASE_WIDTH 4
+#define        FRF_BZ_TX_PACE_BIN_TH_LBN 0
+#define        FRF_BZ_TX_PACE_BIN_TH_WIDTH 5
+
+/* TX_PACE_DROP_QID_REG: PACE Drop QID Counter */
+#define        FR_BZ_TX_PACE_DROP_QID 0x00000aa0
+#define        FRF_BZ_TX_PACE_QID_DRP_CNT_LBN 0
+#define        FRF_BZ_TX_PACE_QID_DRP_CNT_WIDTH 16
+
+/* TX_VLAN_REG: Transmit VLAN tag register */
+#define        FR_BB_TX_VLAN 0x00000ae0
+#define        FRF_BB_TX_VLAN_EN_LBN 127
+#define        FRF_BB_TX_VLAN_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN7_PORT1_EN_LBN 125
+#define        FRF_BB_TX_VLAN7_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN7_PORT0_EN_LBN 124
+#define        FRF_BB_TX_VLAN7_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN7_LBN 112
+#define        FRF_BB_TX_VLAN7_WIDTH 12
+#define        FRF_BB_TX_VLAN6_PORT1_EN_LBN 109
+#define        FRF_BB_TX_VLAN6_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN6_PORT0_EN_LBN 108
+#define        FRF_BB_TX_VLAN6_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN6_LBN 96
+#define        FRF_BB_TX_VLAN6_WIDTH 12
+#define        FRF_BB_TX_VLAN5_PORT1_EN_LBN 93
+#define        FRF_BB_TX_VLAN5_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN5_PORT0_EN_LBN 92
+#define        FRF_BB_TX_VLAN5_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN5_LBN 80
+#define        FRF_BB_TX_VLAN5_WIDTH 12
+#define        FRF_BB_TX_VLAN4_PORT1_EN_LBN 77
+#define        FRF_BB_TX_VLAN4_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN4_PORT0_EN_LBN 76
+#define        FRF_BB_TX_VLAN4_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN4_LBN 64
+#define        FRF_BB_TX_VLAN4_WIDTH 12
+#define        FRF_BB_TX_VLAN3_PORT1_EN_LBN 61
+#define        FRF_BB_TX_VLAN3_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN3_PORT0_EN_LBN 60
+#define        FRF_BB_TX_VLAN3_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN3_LBN 48
+#define        FRF_BB_TX_VLAN3_WIDTH 12
+#define        FRF_BB_TX_VLAN2_PORT1_EN_LBN 45
+#define        FRF_BB_TX_VLAN2_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN2_PORT0_EN_LBN 44
+#define        FRF_BB_TX_VLAN2_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN2_LBN 32
+#define        FRF_BB_TX_VLAN2_WIDTH 12
+#define        FRF_BB_TX_VLAN1_PORT1_EN_LBN 29
+#define        FRF_BB_TX_VLAN1_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN1_PORT0_EN_LBN 28
+#define        FRF_BB_TX_VLAN1_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN1_LBN 16
+#define        FRF_BB_TX_VLAN1_WIDTH 12
+#define        FRF_BB_TX_VLAN0_PORT1_EN_LBN 13
+#define        FRF_BB_TX_VLAN0_PORT1_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN0_PORT0_EN_LBN 12
+#define        FRF_BB_TX_VLAN0_PORT0_EN_WIDTH 1
+#define        FRF_BB_TX_VLAN0_LBN 0
+#define        FRF_BB_TX_VLAN0_WIDTH 12
+
+/* TX_IPFIL_PORTEN_REG: Transmit filter control register */
+#define        FR_BZ_TX_IPFIL_PORTEN 0x00000af0
+#define        FRF_BZ_TX_MADR0_FIL_EN_LBN 64
+#define        FRF_BZ_TX_MADR0_FIL_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL31_PORT_EN_LBN 62
+#define        FRF_BB_TX_IPFIL31_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL30_PORT_EN_LBN 60
+#define        FRF_BB_TX_IPFIL30_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL29_PORT_EN_LBN 58
+#define        FRF_BB_TX_IPFIL29_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL28_PORT_EN_LBN 56
+#define        FRF_BB_TX_IPFIL28_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL27_PORT_EN_LBN 54
+#define        FRF_BB_TX_IPFIL27_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL26_PORT_EN_LBN 52
+#define        FRF_BB_TX_IPFIL26_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL25_PORT_EN_LBN 50
+#define        FRF_BB_TX_IPFIL25_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL24_PORT_EN_LBN 48
+#define        FRF_BB_TX_IPFIL24_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL23_PORT_EN_LBN 46
+#define        FRF_BB_TX_IPFIL23_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL22_PORT_EN_LBN 44
+#define        FRF_BB_TX_IPFIL22_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL21_PORT_EN_LBN 42
+#define        FRF_BB_TX_IPFIL21_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL20_PORT_EN_LBN 40
+#define        FRF_BB_TX_IPFIL20_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL19_PORT_EN_LBN 38
+#define        FRF_BB_TX_IPFIL19_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL18_PORT_EN_LBN 36
+#define        FRF_BB_TX_IPFIL18_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL17_PORT_EN_LBN 34
+#define        FRF_BB_TX_IPFIL17_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL16_PORT_EN_LBN 32
+#define        FRF_BB_TX_IPFIL16_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL15_PORT_EN_LBN 30
+#define        FRF_BB_TX_IPFIL15_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL14_PORT_EN_LBN 28
+#define        FRF_BB_TX_IPFIL14_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL13_PORT_EN_LBN 26
+#define        FRF_BB_TX_IPFIL13_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL12_PORT_EN_LBN 24
+#define        FRF_BB_TX_IPFIL12_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL11_PORT_EN_LBN 22
+#define        FRF_BB_TX_IPFIL11_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL10_PORT_EN_LBN 20
+#define        FRF_BB_TX_IPFIL10_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL9_PORT_EN_LBN 18
+#define        FRF_BB_TX_IPFIL9_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL8_PORT_EN_LBN 16
+#define        FRF_BB_TX_IPFIL8_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL7_PORT_EN_LBN 14
+#define        FRF_BB_TX_IPFIL7_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL6_PORT_EN_LBN 12
+#define        FRF_BB_TX_IPFIL6_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL5_PORT_EN_LBN 10
+#define        FRF_BB_TX_IPFIL5_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL4_PORT_EN_LBN 8
+#define        FRF_BB_TX_IPFIL4_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL3_PORT_EN_LBN 6
+#define        FRF_BB_TX_IPFIL3_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL2_PORT_EN_LBN 4
+#define        FRF_BB_TX_IPFIL2_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL1_PORT_EN_LBN 2
+#define        FRF_BB_TX_IPFIL1_PORT_EN_WIDTH 1
+#define        FRF_BB_TX_IPFIL0_PORT_EN_LBN 0
+#define        FRF_BB_TX_IPFIL0_PORT_EN_WIDTH 1
+
+/* TX_IPFIL_TBL: Transmit IP source address filter table */
+#define        FR_BB_TX_IPFIL_TBL 0x00000b00
+#define        FR_BB_TX_IPFIL_TBL_STEP 16
+#define        FR_BB_TX_IPFIL_TBL_ROWS 16
+#define        FRF_BB_TX_IPFIL_MASK_1_LBN 96
+#define        FRF_BB_TX_IPFIL_MASK_1_WIDTH 32
+#define        FRF_BB_TX_IP_SRC_ADR_1_LBN 64
+#define        FRF_BB_TX_IP_SRC_ADR_1_WIDTH 32
+#define        FRF_BB_TX_IPFIL_MASK_0_LBN 32
+#define        FRF_BB_TX_IPFIL_MASK_0_WIDTH 32
+#define        FRF_BB_TX_IP_SRC_ADR_0_LBN 0
+#define        FRF_BB_TX_IP_SRC_ADR_0_WIDTH 32
+
+/* MD_TXD_REG: PHY management transmit data register */
+#define        FR_AB_MD_TXD 0x00000c00
+#define        FRF_AB_MD_TXD_LBN 0
+#define        FRF_AB_MD_TXD_WIDTH 16
+
+/* MD_RXD_REG: PHY management receive data register */
+#define        FR_AB_MD_RXD 0x00000c10
+#define        FRF_AB_MD_RXD_LBN 0
+#define        FRF_AB_MD_RXD_WIDTH 16
+
+/* MD_CS_REG: PHY management configuration & status register */
+#define        FR_AB_MD_CS 0x00000c20
+#define        FRF_AB_MD_RD_EN_CMD_LBN 15
+#define        FRF_AB_MD_RD_EN_CMD_WIDTH 1
+#define        FRF_AB_MD_WR_EN_CMD_LBN 14
+#define        FRF_AB_MD_WR_EN_CMD_WIDTH 1
+#define        FRF_AB_MD_ADDR_CMD_LBN 13
+#define        FRF_AB_MD_ADDR_CMD_WIDTH 1
+#define        FRF_AB_MD_PT_LBN 7
+#define        FRF_AB_MD_PT_WIDTH 3
+#define        FRF_AB_MD_PL_LBN 6
+#define        FRF_AB_MD_PL_WIDTH 1
+#define        FRF_AB_MD_INT_CLR_LBN 5
+#define        FRF_AB_MD_INT_CLR_WIDTH 1
+#define        FRF_AB_MD_GC_LBN 4
+#define        FRF_AB_MD_GC_WIDTH 1
+#define        FRF_AB_MD_PRSP_LBN 3
+#define        FRF_AB_MD_PRSP_WIDTH 1
+#define        FRF_AB_MD_RIC_LBN 2
+#define        FRF_AB_MD_RIC_WIDTH 1
+#define        FRF_AB_MD_RDC_LBN 1
+#define        FRF_AB_MD_RDC_WIDTH 1
+#define        FRF_AB_MD_WRC_LBN 0
+#define        FRF_AB_MD_WRC_WIDTH 1
+
+/* MD_PHY_ADR_REG: PHY management PHY address register */
+#define        FR_AB_MD_PHY_ADR 0x00000c30
+#define        FRF_AB_MD_PHY_ADR_LBN 0
+#define        FRF_AB_MD_PHY_ADR_WIDTH 16
+
+/* MD_ID_REG: PHY management ID register */
+#define        FR_AB_MD_ID 0x00000c40
+#define        FRF_AB_MD_PRT_ADR_LBN 11
+#define        FRF_AB_MD_PRT_ADR_WIDTH 5
+#define        FRF_AB_MD_DEV_ADR_LBN 6
+#define        FRF_AB_MD_DEV_ADR_WIDTH 5
+
+/* MD_STAT_REG: PHY management status & mask register */
+#define        FR_AB_MD_STAT 0x00000c50
+#define        FRF_AB_MD_PINT_LBN 4
+#define        FRF_AB_MD_PINT_WIDTH 1
+#define        FRF_AB_MD_DONE_LBN 3
+#define        FRF_AB_MD_DONE_WIDTH 1
+#define        FRF_AB_MD_BSERR_LBN 2
+#define        FRF_AB_MD_BSERR_WIDTH 1
+#define        FRF_AB_MD_LNFL_LBN 1
+#define        FRF_AB_MD_LNFL_WIDTH 1
+#define        FRF_AB_MD_BSY_LBN 0
+#define        FRF_AB_MD_BSY_WIDTH 1
+
+/* MAC_STAT_DMA_REG: Port MAC statistical counter DMA register */
+#define        FR_AB_MAC_STAT_DMA 0x00000c60
+#define        FRF_AB_MAC_STAT_DMA_CMD_LBN 48
+#define        FRF_AB_MAC_STAT_DMA_CMD_WIDTH 1
+#define        FRF_AB_MAC_STAT_DMA_ADR_LBN 0
+#define        FRF_AB_MAC_STAT_DMA_ADR_WIDTH 48
+
+/* MAC_CTRL_REG: Port MAC control register */
+#define        FR_AB_MAC_CTRL 0x00000c80
+#define        FRF_AB_MAC_XOFF_VAL_LBN 16
+#define        FRF_AB_MAC_XOFF_VAL_WIDTH 16
+#define        FRF_BB_TXFIFO_DRAIN_EN_LBN 7
+#define        FRF_BB_TXFIFO_DRAIN_EN_WIDTH 1
+#define        FRF_AB_MAC_XG_DISTXCRC_LBN 5
+#define        FRF_AB_MAC_XG_DISTXCRC_WIDTH 1
+#define        FRF_AB_MAC_BCAD_ACPT_LBN 4
+#define        FRF_AB_MAC_BCAD_ACPT_WIDTH 1
+#define        FRF_AB_MAC_UC_PROM_LBN 3
+#define        FRF_AB_MAC_UC_PROM_WIDTH 1
+#define        FRF_AB_MAC_LINK_STATUS_LBN 2
+#define        FRF_AB_MAC_LINK_STATUS_WIDTH 1
+#define        FRF_AB_MAC_SPEED_LBN 0
+#define        FRF_AB_MAC_SPEED_WIDTH 2
+#define        FFE_AB_MAC_SPEED_10G 3
+#define        FFE_AB_MAC_SPEED_1G 2
+#define        FFE_AB_MAC_SPEED_100M 1
+#define        FFE_AB_MAC_SPEED_10M 0
+
+/* GEN_MODE_REG: General Purpose mode register (external interrupt mask) */
+#define        FR_BB_GEN_MODE 0x00000c90
+#define        FRF_BB_XFP_PHY_INT_POL_SEL_LBN 3
+#define        FRF_BB_XFP_PHY_INT_POL_SEL_WIDTH 1
+#define        FRF_BB_XG_PHY_INT_POL_SEL_LBN 2
+#define        FRF_BB_XG_PHY_INT_POL_SEL_WIDTH 1
+#define        FRF_BB_XFP_PHY_INT_MASK_LBN 1
+#define        FRF_BB_XFP_PHY_INT_MASK_WIDTH 1
+#define        FRF_BB_XG_PHY_INT_MASK_LBN 0
+#define        FRF_BB_XG_PHY_INT_MASK_WIDTH 1
+
+/* MAC_MC_HASH_REG0: Multicast address hash table */
+#define        FR_AB_MAC_MC_HASH_REG0 0x00000ca0
+#define        FRF_AB_MAC_MCAST_HASH0_LBN 0
+#define        FRF_AB_MAC_MCAST_HASH0_WIDTH 128
+
+/* MAC_MC_HASH_REG1: Multicast address hash table */
+#define        FR_AB_MAC_MC_HASH_REG1 0x00000cb0
+#define        FRF_AB_MAC_MCAST_HASH1_LBN 0
+#define        FRF_AB_MAC_MCAST_HASH1_WIDTH 128
+
+/* GM_CFG1_REG: GMAC configuration register 1 */
+#define        FR_AB_GM_CFG1 0x00000e00
+#define        FRF_AB_GM_SW_RST_LBN 31
+#define        FRF_AB_GM_SW_RST_WIDTH 1
+#define        FRF_AB_GM_SIM_RST_LBN 30
+#define        FRF_AB_GM_SIM_RST_WIDTH 1
+#define        FRF_AB_GM_RST_RX_MAC_CTL_LBN 19
+#define        FRF_AB_GM_RST_RX_MAC_CTL_WIDTH 1
+#define        FRF_AB_GM_RST_TX_MAC_CTL_LBN 18
+#define        FRF_AB_GM_RST_TX_MAC_CTL_WIDTH 1
+#define        FRF_AB_GM_RST_RX_FUNC_LBN 17
+#define        FRF_AB_GM_RST_RX_FUNC_WIDTH 1
+#define        FRF_AB_GM_RST_TX_FUNC_LBN 16
+#define        FRF_AB_GM_RST_TX_FUNC_WIDTH 1
+#define        FRF_AB_GM_LOOP_LBN 8
+#define        FRF_AB_GM_LOOP_WIDTH 1
+#define        FRF_AB_GM_RX_FC_EN_LBN 5
+#define        FRF_AB_GM_RX_FC_EN_WIDTH 1
+#define        FRF_AB_GM_TX_FC_EN_LBN 4
+#define        FRF_AB_GM_TX_FC_EN_WIDTH 1
+#define        FRF_AB_GM_SYNC_RXEN_LBN 3
+#define        FRF_AB_GM_SYNC_RXEN_WIDTH 1
+#define        FRF_AB_GM_RX_EN_LBN 2
+#define        FRF_AB_GM_RX_EN_WIDTH 1
+#define        FRF_AB_GM_SYNC_TXEN_LBN 1
+#define        FRF_AB_GM_SYNC_TXEN_WIDTH 1
+#define        FRF_AB_GM_TX_EN_LBN 0
+#define        FRF_AB_GM_TX_EN_WIDTH 1
+
+/* GM_CFG2_REG: GMAC configuration register 2 */
+#define        FR_AB_GM_CFG2 0x00000e10
+#define        FRF_AB_GM_PAMBL_LEN_LBN 12
+#define        FRF_AB_GM_PAMBL_LEN_WIDTH 4
+#define        FRF_AB_GM_IF_MODE_LBN 8
+#define        FRF_AB_GM_IF_MODE_WIDTH 2
+#define        FFE_AB_IF_MODE_BYTE_MODE 2
+#define        FFE_AB_IF_MODE_NIBBLE_MODE 1
+#define        FRF_AB_GM_HUGE_FRM_EN_LBN 5
+#define        FRF_AB_GM_HUGE_FRM_EN_WIDTH 1
+#define        FRF_AB_GM_LEN_CHK_LBN 4
+#define        FRF_AB_GM_LEN_CHK_WIDTH 1
+#define        FRF_AB_GM_PAD_CRC_EN_LBN 2
+#define        FRF_AB_GM_PAD_CRC_EN_WIDTH 1
+#define        FRF_AB_GM_CRC_EN_LBN 1
+#define        FRF_AB_GM_CRC_EN_WIDTH 1
+#define        FRF_AB_GM_FD_LBN 0
+#define        FRF_AB_GM_FD_WIDTH 1
+
+/* GM_IPG_REG: GMAC IPG register */
+#define        FR_AB_GM_IPG 0x00000e20
+#define        FRF_AB_GM_NONB2B_IPG1_LBN 24
+#define        FRF_AB_GM_NONB2B_IPG1_WIDTH 7
+#define        FRF_AB_GM_NONB2B_IPG2_LBN 16
+#define        FRF_AB_GM_NONB2B_IPG2_WIDTH 7
+#define        FRF_AB_GM_MIN_IPG_ENF_LBN 8
+#define        FRF_AB_GM_MIN_IPG_ENF_WIDTH 8
+#define        FRF_AB_GM_B2B_IPG_LBN 0
+#define        FRF_AB_GM_B2B_IPG_WIDTH 7
+
+/* GM_HD_REG: GMAC half duplex register */
+#define        FR_AB_GM_HD 0x00000e30
+#define        FRF_AB_GM_ALT_BOFF_VAL_LBN 20
+#define        FRF_AB_GM_ALT_BOFF_VAL_WIDTH 4
+#define        FRF_AB_GM_ALT_BOFF_EN_LBN 19
+#define        FRF_AB_GM_ALT_BOFF_EN_WIDTH 1
+#define        FRF_AB_GM_BP_NO_BOFF_LBN 18
+#define        FRF_AB_GM_BP_NO_BOFF_WIDTH 1
+#define        FRF_AB_GM_DIS_BOFF_LBN 17
+#define        FRF_AB_GM_DIS_BOFF_WIDTH 1
+#define        FRF_AB_GM_EXDEF_TX_EN_LBN 16
+#define        FRF_AB_GM_EXDEF_TX_EN_WIDTH 1
+#define        FRF_AB_GM_RTRY_LIMIT_LBN 12
+#define        FRF_AB_GM_RTRY_LIMIT_WIDTH 4
+#define        FRF_AB_GM_COL_WIN_LBN 0
+#define        FRF_AB_GM_COL_WIN_WIDTH 10
+
+/* GM_MAX_FLEN_REG: GMAC maximum frame length register */
+#define        FR_AB_GM_MAX_FLEN 0x00000e40
+#define        FRF_AB_GM_MAX_FLEN_LBN 0
+#define        FRF_AB_GM_MAX_FLEN_WIDTH 16
+
+/* GM_TEST_REG: GMAC test register */
+#define        FR_AB_GM_TEST 0x00000e70
+#define        FRF_AB_GM_MAX_BOFF_LBN 3
+#define        FRF_AB_GM_MAX_BOFF_WIDTH 1
+#define        FRF_AB_GM_REG_TX_FLOW_EN_LBN 2
+#define        FRF_AB_GM_REG_TX_FLOW_EN_WIDTH 1
+#define        FRF_AB_GM_TEST_PAUSE_LBN 1
+#define        FRF_AB_GM_TEST_PAUSE_WIDTH 1
+#define        FRF_AB_GM_SHORT_SLOT_LBN 0
+#define        FRF_AB_GM_SHORT_SLOT_WIDTH 1
+
+/* GM_ADR1_REG: GMAC station address register 1 */
+#define        FR_AB_GM_ADR1 0x00000f00
+#define        FRF_AB_GM_ADR_B0_LBN 24
+#define        FRF_AB_GM_ADR_B0_WIDTH 8
+#define        FRF_AB_GM_ADR_B1_LBN 16
+#define        FRF_AB_GM_ADR_B1_WIDTH 8
+#define        FRF_AB_GM_ADR_B2_LBN 8
+#define        FRF_AB_GM_ADR_B2_WIDTH 8
+#define        FRF_AB_GM_ADR_B3_LBN 0
+#define        FRF_AB_GM_ADR_B3_WIDTH 8
+
+/* GM_ADR2_REG: GMAC station address register 2 */
+#define        FR_AB_GM_ADR2 0x00000f10
+#define        FRF_AB_GM_ADR_B4_LBN 24
+#define        FRF_AB_GM_ADR_B4_WIDTH 8
+#define        FRF_AB_GM_ADR_B5_LBN 16
+#define        FRF_AB_GM_ADR_B5_WIDTH 8
+
+/* GMF_CFG0_REG: GMAC FIFO configuration register 0 */
+#define        FR_AB_GMF_CFG0 0x00000f20
+#define        FRF_AB_GMF_FTFENRPLY_LBN 20
+#define        FRF_AB_GMF_FTFENRPLY_WIDTH 1
+#define        FRF_AB_GMF_STFENRPLY_LBN 19
+#define        FRF_AB_GMF_STFENRPLY_WIDTH 1
+#define        FRF_AB_GMF_FRFENRPLY_LBN 18
+#define        FRF_AB_GMF_FRFENRPLY_WIDTH 1
+#define        FRF_AB_GMF_SRFENRPLY_LBN 17
+#define        FRF_AB_GMF_SRFENRPLY_WIDTH 1
+#define        FRF_AB_GMF_WTMENRPLY_LBN 16
+#define        FRF_AB_GMF_WTMENRPLY_WIDTH 1
+#define        FRF_AB_GMF_FTFENREQ_LBN 12
+#define        FRF_AB_GMF_FTFENREQ_WIDTH 1
+#define        FRF_AB_GMF_STFENREQ_LBN 11
+#define        FRF_AB_GMF_STFENREQ_WIDTH 1
+#define        FRF_AB_GMF_FRFENREQ_LBN 10
+#define        FRF_AB_GMF_FRFENREQ_WIDTH 1
+#define        FRF_AB_GMF_SRFENREQ_LBN 9
+#define        FRF_AB_GMF_SRFENREQ_WIDTH 1
+#define        FRF_AB_GMF_WTMENREQ_LBN 8
+#define        FRF_AB_GMF_WTMENREQ_WIDTH 1
+#define        FRF_AB_GMF_HSTRSTFT_LBN 4
+#define        FRF_AB_GMF_HSTRSTFT_WIDTH 1
+#define        FRF_AB_GMF_HSTRSTST_LBN 3
+#define        FRF_AB_GMF_HSTRSTST_WIDTH 1
+#define        FRF_AB_GMF_HSTRSTFR_LBN 2
+#define        FRF_AB_GMF_HSTRSTFR_WIDTH 1
+#define        FRF_AB_GMF_HSTRSTSR_LBN 1
+#define        FRF_AB_GMF_HSTRSTSR_WIDTH 1
+#define        FRF_AB_GMF_HSTRSTWT_LBN 0
+#define        FRF_AB_GMF_HSTRSTWT_WIDTH 1
+
+/* GMF_CFG1_REG: GMAC FIFO configuration register 1 */
+#define        FR_AB_GMF_CFG1 0x00000f30
+#define        FRF_AB_GMF_CFGFRTH_LBN 16
+#define        FRF_AB_GMF_CFGFRTH_WIDTH 5
+#define        FRF_AB_GMF_CFGXOFFRTX_LBN 0
+#define        FRF_AB_GMF_CFGXOFFRTX_WIDTH 16
+
+/* GMF_CFG2_REG: GMAC FIFO configuration register 2 */
+#define        FR_AB_GMF_CFG2 0x00000f40
+#define        FRF_AB_GMF_CFGHWM_LBN 16
+#define        FRF_AB_GMF_CFGHWM_WIDTH 6
+#define        FRF_AB_GMF_CFGLWM_LBN 0
+#define        FRF_AB_GMF_CFGLWM_WIDTH 6
+
+/* GMF_CFG3_REG: GMAC FIFO configuration register 3 */
+#define        FR_AB_GMF_CFG3 0x00000f50
+#define        FRF_AB_GMF_CFGHWMFT_LBN 16
+#define        FRF_AB_GMF_CFGHWMFT_WIDTH 6
+#define        FRF_AB_GMF_CFGFTTH_LBN 0
+#define        FRF_AB_GMF_CFGFTTH_WIDTH 6
+
+/* GMF_CFG4_REG: GMAC FIFO configuration register 4 */
+#define        FR_AB_GMF_CFG4 0x00000f60
+#define        FRF_AB_GMF_HSTFLTRFRM_LBN 0
+#define        FRF_AB_GMF_HSTFLTRFRM_WIDTH 18
+
+/* GMF_CFG5_REG: GMAC FIFO configuration register 5 */
+#define        FR_AB_GMF_CFG5 0x00000f70
+#define        FRF_AB_GMF_CFGHDPLX_LBN 22
+#define        FRF_AB_GMF_CFGHDPLX_WIDTH 1
+#define        FRF_AB_GMF_SRFULL_LBN 21
+#define        FRF_AB_GMF_SRFULL_WIDTH 1
+#define        FRF_AB_GMF_HSTSRFULLCLR_LBN 20
+#define        FRF_AB_GMF_HSTSRFULLCLR_WIDTH 1
+#define        FRF_AB_GMF_CFGBYTMODE_LBN 19
+#define        FRF_AB_GMF_CFGBYTMODE_WIDTH 1
+#define        FRF_AB_GMF_HSTDRPLT64_LBN 18
+#define        FRF_AB_GMF_HSTDRPLT64_WIDTH 1
+#define        FRF_AB_GMF_HSTFLTRFRMDC_LBN 0
+#define        FRF_AB_GMF_HSTFLTRFRMDC_WIDTH 18
+
+/* TX_SRC_MAC_TBL: Transmit IP source address filter table */
+#define        FR_BB_TX_SRC_MAC_TBL 0x00001000
+#define        FR_BB_TX_SRC_MAC_TBL_STEP 16
+#define        FR_BB_TX_SRC_MAC_TBL_ROWS 16
+#define        FRF_BB_TX_SRC_MAC_ADR_1_LBN 64
+#define        FRF_BB_TX_SRC_MAC_ADR_1_WIDTH 48
+#define        FRF_BB_TX_SRC_MAC_ADR_0_LBN 0
+#define        FRF_BB_TX_SRC_MAC_ADR_0_WIDTH 48
+
+/* TX_SRC_MAC_CTL_REG: Transmit MAC source address filter control */
+#define        FR_BB_TX_SRC_MAC_CTL 0x00001100
+#define        FRF_BB_TX_SRC_DROP_CTR_LBN 16
+#define        FRF_BB_TX_SRC_DROP_CTR_WIDTH 16
+#define        FRF_BB_TX_SRC_FLTR_EN_LBN 15
+#define        FRF_BB_TX_SRC_FLTR_EN_WIDTH 1
+#define        FRF_BB_TX_DROP_CTR_CLR_LBN 12
+#define        FRF_BB_TX_DROP_CTR_CLR_WIDTH 1
+#define        FRF_BB_TX_MAC_QID_SEL_LBN 0
+#define        FRF_BB_TX_MAC_QID_SEL_WIDTH 3
+
+/* XM_ADR_LO_REG: XGMAC address register low */
+#define        FR_AB_XM_ADR_LO 0x00001200
+#define        FRF_AB_XM_ADR_LO_LBN 0
+#define        FRF_AB_XM_ADR_LO_WIDTH 32
+
+/* XM_ADR_HI_REG: XGMAC address register high */
+#define        FR_AB_XM_ADR_HI 0x00001210
+#define        FRF_AB_XM_ADR_HI_LBN 0
+#define        FRF_AB_XM_ADR_HI_WIDTH 16
+
+/* XM_GLB_CFG_REG: XGMAC global configuration */
+#define        FR_AB_XM_GLB_CFG 0x00001220
+#define        FRF_AB_XM_RMTFLT_GEN_LBN 17
+#define        FRF_AB_XM_RMTFLT_GEN_WIDTH 1
+#define        FRF_AB_XM_DEBUG_MODE_LBN 16
+#define        FRF_AB_XM_DEBUG_MODE_WIDTH 1
+#define        FRF_AB_XM_RX_STAT_EN_LBN 11
+#define        FRF_AB_XM_RX_STAT_EN_WIDTH 1
+#define        FRF_AB_XM_TX_STAT_EN_LBN 10
+#define        FRF_AB_XM_TX_STAT_EN_WIDTH 1
+#define        FRF_AB_XM_RX_JUMBO_MODE_LBN 6
+#define        FRF_AB_XM_RX_JUMBO_MODE_WIDTH 1
+#define        FRF_AB_XM_WAN_MODE_LBN 5
+#define        FRF_AB_XM_WAN_MODE_WIDTH 1
+#define        FRF_AB_XM_INTCLR_MODE_LBN 3
+#define        FRF_AB_XM_INTCLR_MODE_WIDTH 1
+#define        FRF_AB_XM_CORE_RST_LBN 0
+#define        FRF_AB_XM_CORE_RST_WIDTH 1
+
+/* XM_TX_CFG_REG: XGMAC transmit configuration */
+#define        FR_AB_XM_TX_CFG 0x00001230
+#define        FRF_AB_XM_TX_PROG_LBN 24
+#define        FRF_AB_XM_TX_PROG_WIDTH 1
+#define        FRF_AB_XM_IPG_LBN 16
+#define        FRF_AB_XM_IPG_WIDTH 4
+#define        FRF_AB_XM_FCNTL_LBN 10
+#define        FRF_AB_XM_FCNTL_WIDTH 1
+#define        FRF_AB_XM_TXCRC_LBN 8
+#define        FRF_AB_XM_TXCRC_WIDTH 1
+#define        FRF_AB_XM_EDRC_LBN 6
+#define        FRF_AB_XM_EDRC_WIDTH 1
+#define        FRF_AB_XM_AUTO_PAD_LBN 5
+#define        FRF_AB_XM_AUTO_PAD_WIDTH 1
+#define        FRF_AB_XM_TX_PRMBL_LBN 2
+#define        FRF_AB_XM_TX_PRMBL_WIDTH 1
+#define        FRF_AB_XM_TXEN_LBN 1
+#define        FRF_AB_XM_TXEN_WIDTH 1
+#define        FRF_AB_XM_TX_RST_LBN 0
+#define        FRF_AB_XM_TX_RST_WIDTH 1
+
+/* XM_RX_CFG_REG: XGMAC receive configuration */
+#define        FR_AB_XM_RX_CFG 0x00001240
+#define        FRF_AB_XM_PASS_LENERR_LBN 26
+#define        FRF_AB_XM_PASS_LENERR_WIDTH 1
+#define        FRF_AB_XM_PASS_CRC_ERR_LBN 25
+#define        FRF_AB_XM_PASS_CRC_ERR_WIDTH 1
+#define        FRF_AB_XM_PASS_PRMBLE_ERR_LBN 24
+#define        FRF_AB_XM_PASS_PRMBLE_ERR_WIDTH 1
+#define        FRF_AB_XM_REJ_BCAST_LBN 20
+#define        FRF_AB_XM_REJ_BCAST_WIDTH 1
+#define        FRF_AB_XM_ACPT_ALL_MCAST_LBN 11
+#define        FRF_AB_XM_ACPT_ALL_MCAST_WIDTH 1
+#define        FRF_AB_XM_ACPT_ALL_UCAST_LBN 9
+#define        FRF_AB_XM_ACPT_ALL_UCAST_WIDTH 1
+#define        FRF_AB_XM_AUTO_DEPAD_LBN 8
+#define        FRF_AB_XM_AUTO_DEPAD_WIDTH 1
+#define        FRF_AB_XM_RXCRC_LBN 3
+#define        FRF_AB_XM_RXCRC_WIDTH 1
+#define        FRF_AB_XM_RX_PRMBL_LBN 2
+#define        FRF_AB_XM_RX_PRMBL_WIDTH 1
+#define        FRF_AB_XM_RXEN_LBN 1
+#define        FRF_AB_XM_RXEN_WIDTH 1
+#define        FRF_AB_XM_RX_RST_LBN 0
+#define        FRF_AB_XM_RX_RST_WIDTH 1
+
+/* XM_MGT_INT_MASK: documentation to be written for sum_XM_MGT_INT_MASK */
+#define        FR_AB_XM_MGT_INT_MASK 0x00001250
+#define        FRF_AB_XM_MSK_STA_INTR_LBN 16
+#define        FRF_AB_XM_MSK_STA_INTR_WIDTH 1
+#define        FRF_AB_XM_MSK_STAT_CNTR_HF_LBN 9
+#define        FRF_AB_XM_MSK_STAT_CNTR_HF_WIDTH 1
+#define        FRF_AB_XM_MSK_STAT_CNTR_OF_LBN 8
+#define        FRF_AB_XM_MSK_STAT_CNTR_OF_WIDTH 1
+#define        FRF_AB_XM_MSK_PRMBLE_ERR_LBN 2
+#define        FRF_AB_XM_MSK_PRMBLE_ERR_WIDTH 1
+#define        FRF_AB_XM_MSK_RMTFLT_LBN 1
+#define        FRF_AB_XM_MSK_RMTFLT_WIDTH 1
+#define        FRF_AB_XM_MSK_LCLFLT_LBN 0
+#define        FRF_AB_XM_MSK_LCLFLT_WIDTH 1
+
+/* XM_FC_REG: XGMAC flow control register */
+#define        FR_AB_XM_FC 0x00001270
+#define        FRF_AB_XM_PAUSE_TIME_LBN 16
+#define        FRF_AB_XM_PAUSE_TIME_WIDTH 16
+#define        FRF_AB_XM_RX_MAC_STAT_LBN 11
+#define        FRF_AB_XM_RX_MAC_STAT_WIDTH 1
+#define        FRF_AB_XM_TX_MAC_STAT_LBN 10
+#define        FRF_AB_XM_TX_MAC_STAT_WIDTH 1
+#define        FRF_AB_XM_MCNTL_PASS_LBN 8
+#define        FRF_AB_XM_MCNTL_PASS_WIDTH 2
+#define        FRF_AB_XM_REJ_CNTL_UCAST_LBN 6
+#define        FRF_AB_XM_REJ_CNTL_UCAST_WIDTH 1
+#define        FRF_AB_XM_REJ_CNTL_MCAST_LBN 5
+#define        FRF_AB_XM_REJ_CNTL_MCAST_WIDTH 1
+#define        FRF_AB_XM_ZPAUSE_LBN 2
+#define        FRF_AB_XM_ZPAUSE_WIDTH 1
+#define        FRF_AB_XM_XMIT_PAUSE_LBN 1
+#define        FRF_AB_XM_XMIT_PAUSE_WIDTH 1
+#define        FRF_AB_XM_DIS_FCNTL_LBN 0
+#define        FRF_AB_XM_DIS_FCNTL_WIDTH 1
+
+/* XM_PAUSE_TIME_REG: XGMAC pause time register */
+#define        FR_AB_XM_PAUSE_TIME 0x00001290
+#define        FRF_AB_XM_TX_PAUSE_CNT_LBN 16
+#define        FRF_AB_XM_TX_PAUSE_CNT_WIDTH 16
+#define        FRF_AB_XM_RX_PAUSE_CNT_LBN 0
+#define        FRF_AB_XM_RX_PAUSE_CNT_WIDTH 16
+
+/* XM_TX_PARAM_REG: XGMAC transmit parameter register */
+#define        FR_AB_XM_TX_PARAM 0x000012d0
+#define        FRF_AB_XM_TX_JUMBO_MODE_LBN 31
+#define        FRF_AB_XM_TX_JUMBO_MODE_WIDTH 1
+#define        FRF_AB_XM_MAX_TX_FRM_SIZE_HI_LBN 19
+#define        FRF_AB_XM_MAX_TX_FRM_SIZE_HI_WIDTH 11
+#define        FRF_AB_XM_MAX_TX_FRM_SIZE_LO_LBN 16
+#define        FRF_AB_XM_MAX_TX_FRM_SIZE_LO_WIDTH 3
+#define        FRF_AB_XM_PAD_CHAR_LBN 0
+#define        FRF_AB_XM_PAD_CHAR_WIDTH 8
+
+/* XM_RX_PARAM_REG: XGMAC receive parameter register */
+#define        FR_AB_XM_RX_PARAM 0x000012e0
+#define        FRF_AB_XM_MAX_RX_FRM_SIZE_HI_LBN 3
+#define        FRF_AB_XM_MAX_RX_FRM_SIZE_HI_WIDTH 11
+#define        FRF_AB_XM_MAX_RX_FRM_SIZE_LO_LBN 0
+#define        FRF_AB_XM_MAX_RX_FRM_SIZE_LO_WIDTH 3
+
+/* XM_MGT_INT_MSK_REG: XGMAC management interrupt mask register */
+#define        FR_AB_XM_MGT_INT_MSK 0x000012f0
+#define        FRF_AB_XM_STAT_CNTR_OF_LBN 9
+#define        FRF_AB_XM_STAT_CNTR_OF_WIDTH 1
+#define        FRF_AB_XM_STAT_CNTR_HF_LBN 8
+#define        FRF_AB_XM_STAT_CNTR_HF_WIDTH 1
+#define        FRF_AB_XM_PRMBLE_ERR_LBN 2
+#define        FRF_AB_XM_PRMBLE_ERR_WIDTH 1
+#define        FRF_AB_XM_RMTFLT_LBN 1
+#define        FRF_AB_XM_RMTFLT_WIDTH 1
+#define        FRF_AB_XM_LCLFLT_LBN 0
+#define        FRF_AB_XM_LCLFLT_WIDTH 1
+
+/* XX_PWR_RST_REG: XGXS/XAUI powerdown/reset register */
+#define        FR_AB_XX_PWR_RST 0x00001300
+#define        FRF_AB_XX_PWRDND_SIG_LBN 31
+#define        FRF_AB_XX_PWRDND_SIG_WIDTH 1
+#define        FRF_AB_XX_PWRDNC_SIG_LBN 30
+#define        FRF_AB_XX_PWRDNC_SIG_WIDTH 1
+#define        FRF_AB_XX_PWRDNB_SIG_LBN 29
+#define        FRF_AB_XX_PWRDNB_SIG_WIDTH 1
+#define        FRF_AB_XX_PWRDNA_SIG_LBN 28
+#define        FRF_AB_XX_PWRDNA_SIG_WIDTH 1
+#define        FRF_AB_XX_SIM_MODE_LBN 27
+#define        FRF_AB_XX_SIM_MODE_WIDTH 1
+#define        FRF_AB_XX_RSTPLLCD_SIG_LBN 25
+#define        FRF_AB_XX_RSTPLLCD_SIG_WIDTH 1
+#define        FRF_AB_XX_RSTPLLAB_SIG_LBN 24
+#define        FRF_AB_XX_RSTPLLAB_SIG_WIDTH 1
+#define        FRF_AB_XX_RESETD_SIG_LBN 23
+#define        FRF_AB_XX_RESETD_SIG_WIDTH 1
+#define        FRF_AB_XX_RESETC_SIG_LBN 22
+#define        FRF_AB_XX_RESETC_SIG_WIDTH 1
+#define        FRF_AB_XX_RESETB_SIG_LBN 21
+#define        FRF_AB_XX_RESETB_SIG_WIDTH 1
+#define        FRF_AB_XX_RESETA_SIG_LBN 20
+#define        FRF_AB_XX_RESETA_SIG_WIDTH 1
+#define        FRF_AB_XX_RSTXGXSRX_SIG_LBN 18
+#define        FRF_AB_XX_RSTXGXSRX_SIG_WIDTH 1
+#define        FRF_AB_XX_RSTXGXSTX_SIG_LBN 17
+#define        FRF_AB_XX_RSTXGXSTX_SIG_WIDTH 1
+#define        FRF_AB_XX_SD_RST_ACT_LBN 16
+#define        FRF_AB_XX_SD_RST_ACT_WIDTH 1
+#define        FRF_AB_XX_PWRDND_EN_LBN 15
+#define        FRF_AB_XX_PWRDND_EN_WIDTH 1
+#define        FRF_AB_XX_PWRDNC_EN_LBN 14
+#define        FRF_AB_XX_PWRDNC_EN_WIDTH 1
+#define        FRF_AB_XX_PWRDNB_EN_LBN 13
+#define        FRF_AB_XX_PWRDNB_EN_WIDTH 1
+#define        FRF_AB_XX_PWRDNA_EN_LBN 12
+#define        FRF_AB_XX_PWRDNA_EN_WIDTH 1
+#define        FRF_AB_XX_RSTPLLCD_EN_LBN 9
+#define        FRF_AB_XX_RSTPLLCD_EN_WIDTH 1
+#define        FRF_AB_XX_RSTPLLAB_EN_LBN 8
+#define        FRF_AB_XX_RSTPLLAB_EN_WIDTH 1
+#define        FRF_AB_XX_RESETD_EN_LBN 7
+#define        FRF_AB_XX_RESETD_EN_WIDTH 1
+#define        FRF_AB_XX_RESETC_EN_LBN 6
+#define        FRF_AB_XX_RESETC_EN_WIDTH 1
+#define        FRF_AB_XX_RESETB_EN_LBN 5
+#define        FRF_AB_XX_RESETB_EN_WIDTH 1
+#define        FRF_AB_XX_RESETA_EN_LBN 4
+#define        FRF_AB_XX_RESETA_EN_WIDTH 1
+#define        FRF_AB_XX_RSTXGXSRX_EN_LBN 2
+#define        FRF_AB_XX_RSTXGXSRX_EN_WIDTH 1
+#define        FRF_AB_XX_RSTXGXSTX_EN_LBN 1
+#define        FRF_AB_XX_RSTXGXSTX_EN_WIDTH 1
+#define        FRF_AB_XX_RST_XX_EN_LBN 0
+#define        FRF_AB_XX_RST_XX_EN_WIDTH 1
+
+/* XX_SD_CTL_REG: XGXS/XAUI powerdown/reset control register */
+#define        FR_AB_XX_SD_CTL 0x00001310
+#define        FRF_AB_XX_TERMADJ1_LBN 17
+#define        FRF_AB_XX_TERMADJ1_WIDTH 1
+#define        FRF_AB_XX_TERMADJ0_LBN 16
+#define        FRF_AB_XX_TERMADJ0_WIDTH 1
+#define        FRF_AB_XX_HIDRVD_LBN 15
+#define        FRF_AB_XX_HIDRVD_WIDTH 1
+#define        FRF_AB_XX_LODRVD_LBN 14
+#define        FRF_AB_XX_LODRVD_WIDTH 1
+#define        FRF_AB_XX_HIDRVC_LBN 13
+#define        FRF_AB_XX_HIDRVC_WIDTH 1
+#define        FRF_AB_XX_LODRVC_LBN 12
+#define        FRF_AB_XX_LODRVC_WIDTH 1
+#define        FRF_AB_XX_HIDRVB_LBN 11
+#define        FRF_AB_XX_HIDRVB_WIDTH 1
+#define        FRF_AB_XX_LODRVB_LBN 10
+#define        FRF_AB_XX_LODRVB_WIDTH 1
+#define        FRF_AB_XX_HIDRVA_LBN 9
+#define        FRF_AB_XX_HIDRVA_WIDTH 1
+#define        FRF_AB_XX_LODRVA_LBN 8
+#define        FRF_AB_XX_LODRVA_WIDTH 1
+#define        FRF_AB_XX_LPBKD_LBN 3
+#define        FRF_AB_XX_LPBKD_WIDTH 1
+#define        FRF_AB_XX_LPBKC_LBN 2
+#define        FRF_AB_XX_LPBKC_WIDTH 1
+#define        FRF_AB_XX_LPBKB_LBN 1
+#define        FRF_AB_XX_LPBKB_WIDTH 1
+#define        FRF_AB_XX_LPBKA_LBN 0
+#define        FRF_AB_XX_LPBKA_WIDTH 1
+
+/* XX_TXDRV_CTL_REG: XAUI SerDes transmit drive control register */
+#define        FR_AB_XX_TXDRV_CTL 0x00001320
+#define        FRF_AB_XX_DEQD_LBN 28
+#define        FRF_AB_XX_DEQD_WIDTH 4
+#define        FRF_AB_XX_DEQC_LBN 24
+#define        FRF_AB_XX_DEQC_WIDTH 4
+#define        FRF_AB_XX_DEQB_LBN 20
+#define        FRF_AB_XX_DEQB_WIDTH 4
+#define        FRF_AB_XX_DEQA_LBN 16
+#define        FRF_AB_XX_DEQA_WIDTH 4
+#define        FRF_AB_XX_DTXD_LBN 12
+#define        FRF_AB_XX_DTXD_WIDTH 4
+#define        FRF_AB_XX_DTXC_LBN 8
+#define        FRF_AB_XX_DTXC_WIDTH 4
+#define        FRF_AB_XX_DTXB_LBN 4
+#define        FRF_AB_XX_DTXB_WIDTH 4
+#define        FRF_AB_XX_DTXA_LBN 0
+#define        FRF_AB_XX_DTXA_WIDTH 4
+
+/* XX_PRBS_CTL_REG: documentation to be written for sum_XX_PRBS_CTL_REG */
+#define        FR_AB_XX_PRBS_CTL 0x00001330
+#define        FRF_AB_XX_CH3_RX_PRBS_SEL_LBN 30
+#define        FRF_AB_XX_CH3_RX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH3_RX_PRBS_INV_LBN 29
+#define        FRF_AB_XX_CH3_RX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH3_RX_PRBS_CHKEN_LBN 28
+#define        FRF_AB_XX_CH3_RX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH2_RX_PRBS_SEL_LBN 26
+#define        FRF_AB_XX_CH2_RX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH2_RX_PRBS_INV_LBN 25
+#define        FRF_AB_XX_CH2_RX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH2_RX_PRBS_CHKEN_LBN 24
+#define        FRF_AB_XX_CH2_RX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH1_RX_PRBS_SEL_LBN 22
+#define        FRF_AB_XX_CH1_RX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH1_RX_PRBS_INV_LBN 21
+#define        FRF_AB_XX_CH1_RX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH1_RX_PRBS_CHKEN_LBN 20
+#define        FRF_AB_XX_CH1_RX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH0_RX_PRBS_SEL_LBN 18
+#define        FRF_AB_XX_CH0_RX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH0_RX_PRBS_INV_LBN 17
+#define        FRF_AB_XX_CH0_RX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH0_RX_PRBS_CHKEN_LBN 16
+#define        FRF_AB_XX_CH0_RX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH3_TX_PRBS_SEL_LBN 14
+#define        FRF_AB_XX_CH3_TX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH3_TX_PRBS_INV_LBN 13
+#define        FRF_AB_XX_CH3_TX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH3_TX_PRBS_CHKEN_LBN 12
+#define        FRF_AB_XX_CH3_TX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH2_TX_PRBS_SEL_LBN 10
+#define        FRF_AB_XX_CH2_TX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH2_TX_PRBS_INV_LBN 9
+#define        FRF_AB_XX_CH2_TX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH2_TX_PRBS_CHKEN_LBN 8
+#define        FRF_AB_XX_CH2_TX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH1_TX_PRBS_SEL_LBN 6
+#define        FRF_AB_XX_CH1_TX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH1_TX_PRBS_INV_LBN 5
+#define        FRF_AB_XX_CH1_TX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH1_TX_PRBS_CHKEN_LBN 4
+#define        FRF_AB_XX_CH1_TX_PRBS_CHKEN_WIDTH 1
+#define        FRF_AB_XX_CH0_TX_PRBS_SEL_LBN 2
+#define        FRF_AB_XX_CH0_TX_PRBS_SEL_WIDTH 2
+#define        FRF_AB_XX_CH0_TX_PRBS_INV_LBN 1
+#define        FRF_AB_XX_CH0_TX_PRBS_INV_WIDTH 1
+#define        FRF_AB_XX_CH0_TX_PRBS_CHKEN_LBN 0
+#define        FRF_AB_XX_CH0_TX_PRBS_CHKEN_WIDTH 1
+
+/* XX_PRBS_CHK_REG: documentation to be written for sum_XX_PRBS_CHK_REG */
+#define        FR_AB_XX_PRBS_CHK 0x00001340
+#define        FRF_AB_XX_REV_LB_EN_LBN 16
+#define        FRF_AB_XX_REV_LB_EN_WIDTH 1
+#define        FRF_AB_XX_CH3_DEG_DET_LBN 15
+#define        FRF_AB_XX_CH3_DEG_DET_WIDTH 1
+#define        FRF_AB_XX_CH3_LFSR_LOCK_IND_LBN 14
+#define        FRF_AB_XX_CH3_LFSR_LOCK_IND_WIDTH 1
+#define        FRF_AB_XX_CH3_PRBS_FRUN_LBN 13
+#define        FRF_AB_XX_CH3_PRBS_FRUN_WIDTH 1
+#define        FRF_AB_XX_CH3_ERR_CHK_LBN 12
+#define        FRF_AB_XX_CH3_ERR_CHK_WIDTH 1
+#define        FRF_AB_XX_CH2_DEG_DET_LBN 11
+#define        FRF_AB_XX_CH2_DEG_DET_WIDTH 1
+#define        FRF_AB_XX_CH2_LFSR_LOCK_IND_LBN 10
+#define        FRF_AB_XX_CH2_LFSR_LOCK_IND_WIDTH 1
+#define        FRF_AB_XX_CH2_PRBS_FRUN_LBN 9
+#define        FRF_AB_XX_CH2_PRBS_FRUN_WIDTH 1
+#define        FRF_AB_XX_CH2_ERR_CHK_LBN 8
+#define        FRF_AB_XX_CH2_ERR_CHK_WIDTH 1
+#define        FRF_AB_XX_CH1_DEG_DET_LBN 7
+#define        FRF_AB_XX_CH1_DEG_DET_WIDTH 1
+#define        FRF_AB_XX_CH1_LFSR_LOCK_IND_LBN 6
+#define        FRF_AB_XX_CH1_LFSR_LOCK_IND_WIDTH 1
+#define        FRF_AB_XX_CH1_PRBS_FRUN_LBN 5
+#define        FRF_AB_XX_CH1_PRBS_FRUN_WIDTH 1
+#define        FRF_AB_XX_CH1_ERR_CHK_LBN 4
+#define        FRF_AB_XX_CH1_ERR_CHK_WIDTH 1
+#define        FRF_AB_XX_CH0_DEG_DET_LBN 3
+#define        FRF_AB_XX_CH0_DEG_DET_WIDTH 1
+#define        FRF_AB_XX_CH0_LFSR_LOCK_IND_LBN 2
+#define        FRF_AB_XX_CH0_LFSR_LOCK_IND_WIDTH 1
+#define        FRF_AB_XX_CH0_PRBS_FRUN_LBN 1
+#define        FRF_AB_XX_CH0_PRBS_FRUN_WIDTH 1
+#define        FRF_AB_XX_CH0_ERR_CHK_LBN 0
+#define        FRF_AB_XX_CH0_ERR_CHK_WIDTH 1
+
+/* XX_PRBS_ERR_REG: documentation to be written for sum_XX_PRBS_ERR_REG */
+#define        FR_AB_XX_PRBS_ERR 0x00001350
+#define        FRF_AB_XX_CH3_PRBS_ERR_CNT_LBN 24
+#define        FRF_AB_XX_CH3_PRBS_ERR_CNT_WIDTH 8
+#define        FRF_AB_XX_CH2_PRBS_ERR_CNT_LBN 16
+#define        FRF_AB_XX_CH2_PRBS_ERR_CNT_WIDTH 8
+#define        FRF_AB_XX_CH1_PRBS_ERR_CNT_LBN 8
+#define        FRF_AB_XX_CH1_PRBS_ERR_CNT_WIDTH 8
+#define        FRF_AB_XX_CH0_PRBS_ERR_CNT_LBN 0
+#define        FRF_AB_XX_CH0_PRBS_ERR_CNT_WIDTH 8
+
+/* XX_CORE_STAT_REG: XAUI XGXS core status register */
+#define        FR_AB_XX_CORE_STAT 0x00001360
+#define        FRF_AB_XX_FORCE_SIG3_LBN 31
+#define        FRF_AB_XX_FORCE_SIG3_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG3_VAL_LBN 30
+#define        FRF_AB_XX_FORCE_SIG3_VAL_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG2_LBN 29
+#define        FRF_AB_XX_FORCE_SIG2_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG2_VAL_LBN 28
+#define        FRF_AB_XX_FORCE_SIG2_VAL_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG1_LBN 27
+#define        FRF_AB_XX_FORCE_SIG1_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG1_VAL_LBN 26
+#define        FRF_AB_XX_FORCE_SIG1_VAL_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG0_LBN 25
+#define        FRF_AB_XX_FORCE_SIG0_WIDTH 1
+#define        FRF_AB_XX_FORCE_SIG0_VAL_LBN 24
+#define        FRF_AB_XX_FORCE_SIG0_VAL_WIDTH 1
+#define        FRF_AB_XX_XGXS_LB_EN_LBN 23
+#define        FRF_AB_XX_XGXS_LB_EN_WIDTH 1
+#define        FRF_AB_XX_XGMII_LB_EN_LBN 22
+#define        FRF_AB_XX_XGMII_LB_EN_WIDTH 1
+#define        FRF_AB_XX_MATCH_FAULT_LBN 21
+#define        FRF_AB_XX_MATCH_FAULT_WIDTH 1
+#define        FRF_AB_XX_ALIGN_DONE_LBN 20
+#define        FRF_AB_XX_ALIGN_DONE_WIDTH 1
+#define        FRF_AB_XX_SYNC_STAT3_LBN 19
+#define        FRF_AB_XX_SYNC_STAT3_WIDTH 1
+#define        FRF_AB_XX_SYNC_STAT2_LBN 18
+#define        FRF_AB_XX_SYNC_STAT2_WIDTH 1
+#define        FRF_AB_XX_SYNC_STAT1_LBN 17
+#define        FRF_AB_XX_SYNC_STAT1_WIDTH 1
+#define        FRF_AB_XX_SYNC_STAT0_LBN 16
+#define        FRF_AB_XX_SYNC_STAT0_WIDTH 1
+#define        FRF_AB_XX_COMMA_DET_CH3_LBN 15
+#define        FRF_AB_XX_COMMA_DET_CH3_WIDTH 1
+#define        FRF_AB_XX_COMMA_DET_CH2_LBN 14
+#define        FRF_AB_XX_COMMA_DET_CH2_WIDTH 1
+#define        FRF_AB_XX_COMMA_DET_CH1_LBN 13
+#define        FRF_AB_XX_COMMA_DET_CH1_WIDTH 1
+#define        FRF_AB_XX_COMMA_DET_CH0_LBN 12
+#define        FRF_AB_XX_COMMA_DET_CH0_WIDTH 1
+#define        FRF_AB_XX_CGRP_ALIGN_CH3_LBN 11
+#define        FRF_AB_XX_CGRP_ALIGN_CH3_WIDTH 1
+#define        FRF_AB_XX_CGRP_ALIGN_CH2_LBN 10
+#define        FRF_AB_XX_CGRP_ALIGN_CH2_WIDTH 1
+#define        FRF_AB_XX_CGRP_ALIGN_CH1_LBN 9
+#define        FRF_AB_XX_CGRP_ALIGN_CH1_WIDTH 1
+#define        FRF_AB_XX_CGRP_ALIGN_CH0_LBN 8
+#define        FRF_AB_XX_CGRP_ALIGN_CH0_WIDTH 1
+#define        FRF_AB_XX_CHAR_ERR_CH3_LBN 7
+#define        FRF_AB_XX_CHAR_ERR_CH3_WIDTH 1
+#define        FRF_AB_XX_CHAR_ERR_CH2_LBN 6
+#define        FRF_AB_XX_CHAR_ERR_CH2_WIDTH 1
+#define        FRF_AB_XX_CHAR_ERR_CH1_LBN 5
+#define        FRF_AB_XX_CHAR_ERR_CH1_WIDTH 1
+#define        FRF_AB_XX_CHAR_ERR_CH0_LBN 4
+#define        FRF_AB_XX_CHAR_ERR_CH0_WIDTH 1
+#define        FRF_AB_XX_DISPERR_CH3_LBN 3
+#define        FRF_AB_XX_DISPERR_CH3_WIDTH 1
+#define        FRF_AB_XX_DISPERR_CH2_LBN 2
+#define        FRF_AB_XX_DISPERR_CH2_WIDTH 1
+#define        FRF_AB_XX_DISPERR_CH1_LBN 1
+#define        FRF_AB_XX_DISPERR_CH1_WIDTH 1
+#define        FRF_AB_XX_DISPERR_CH0_LBN 0
+#define        FRF_AB_XX_DISPERR_CH0_WIDTH 1
+
+/* RX_DESC_PTR_TBL_KER: Receive descriptor pointer table */
+#define        FR_AA_RX_DESC_PTR_TBL_KER 0x00011800
+#define        FR_AA_RX_DESC_PTR_TBL_KER_STEP 16
+#define        FR_AA_RX_DESC_PTR_TBL_KER_ROWS 4
+/* RX_DESC_PTR_TBL: Receive descriptor pointer table */
+#define        FR_BZ_RX_DESC_PTR_TBL 0x00f40000
+#define        FR_BZ_RX_DESC_PTR_TBL_STEP 16
+#define        FR_BB_RX_DESC_PTR_TBL_ROWS 4096
+#define        FR_CZ_RX_DESC_PTR_TBL_ROWS 1024
+#define        FRF_CZ_RX_HDR_SPLIT_LBN 90
+#define        FRF_CZ_RX_HDR_SPLIT_WIDTH 1
+#define        FRF_AA_RX_RESET_LBN 89
+#define        FRF_AA_RX_RESET_WIDTH 1
+#define        FRF_AZ_RX_ISCSI_DDIG_EN_LBN 88
+#define        FRF_AZ_RX_ISCSI_DDIG_EN_WIDTH 1
+#define        FRF_AZ_RX_ISCSI_HDIG_EN_LBN 87
+#define        FRF_AZ_RX_ISCSI_HDIG_EN_WIDTH 1
+#define        FRF_AZ_RX_DESC_PREF_ACT_LBN 86
+#define        FRF_AZ_RX_DESC_PREF_ACT_WIDTH 1
+#define        FRF_AZ_RX_DC_HW_RPTR_LBN 80
+#define        FRF_AZ_RX_DC_HW_RPTR_WIDTH 6
+#define        FRF_AZ_RX_DESCQ_HW_RPTR_LBN 68
+#define        FRF_AZ_RX_DESCQ_HW_RPTR_WIDTH 12
+#define        FRF_AZ_RX_DESCQ_SW_WPTR_LBN 56
+#define        FRF_AZ_RX_DESCQ_SW_WPTR_WIDTH 12
+#define        FRF_AZ_RX_DESCQ_BUF_BASE_ID_LBN 36
+#define        FRF_AZ_RX_DESCQ_BUF_BASE_ID_WIDTH 20
+#define        FRF_AZ_RX_DESCQ_EVQ_ID_LBN 24
+#define        FRF_AZ_RX_DESCQ_EVQ_ID_WIDTH 12
+#define        FRF_AZ_RX_DESCQ_OWNER_ID_LBN 10
+#define        FRF_AZ_RX_DESCQ_OWNER_ID_WIDTH 14
+#define        FRF_AZ_RX_DESCQ_LABEL_LBN 5
+#define        FRF_AZ_RX_DESCQ_LABEL_WIDTH 5
+#define        FRF_AZ_RX_DESCQ_SIZE_LBN 3
+#define        FRF_AZ_RX_DESCQ_SIZE_WIDTH 2
+#define        FFE_AZ_RX_DESCQ_SIZE_4K 3
+#define        FFE_AZ_RX_DESCQ_SIZE_2K 2
+#define        FFE_AZ_RX_DESCQ_SIZE_1K 1
+#define        FFE_AZ_RX_DESCQ_SIZE_512 0
+#define        FRF_AZ_RX_DESCQ_TYPE_LBN 2
+#define        FRF_AZ_RX_DESCQ_TYPE_WIDTH 1
+#define        FRF_AZ_RX_DESCQ_JUMBO_LBN 1
+#define        FRF_AZ_RX_DESCQ_JUMBO_WIDTH 1
+#define        FRF_AZ_RX_DESCQ_EN_LBN 0
+#define        FRF_AZ_RX_DESCQ_EN_WIDTH 1
+
+/* TX_DESC_PTR_TBL_KER: Transmit descriptor pointer */
+#define        FR_AA_TX_DESC_PTR_TBL_KER 0x00011900
+#define        FR_AA_TX_DESC_PTR_TBL_KER_STEP 16
+#define        FR_AA_TX_DESC_PTR_TBL_KER_ROWS 8
+/* TX_DESC_PTR_TBL: Transmit descriptor pointer */
+#define        FR_BZ_TX_DESC_PTR_TBL 0x00f50000
+#define        FR_BZ_TX_DESC_PTR_TBL_STEP 16
+#define        FR_BB_TX_DESC_PTR_TBL_ROWS 4096
+#define        FR_CZ_TX_DESC_PTR_TBL_ROWS 1024
+#define        FRF_CZ_TX_DPT_Q_MASK_WIDTH_LBN 94
+#define        FRF_CZ_TX_DPT_Q_MASK_WIDTH_WIDTH 2
+#define        FRF_CZ_TX_DPT_ETH_FILT_EN_LBN 93
+#define        FRF_CZ_TX_DPT_ETH_FILT_EN_WIDTH 1
+#define        FRF_CZ_TX_DPT_IP_FILT_EN_LBN 92
+#define        FRF_CZ_TX_DPT_IP_FILT_EN_WIDTH 1
+#define        FRF_BZ_TX_NON_IP_DROP_DIS_LBN 91
+#define        FRF_BZ_TX_NON_IP_DROP_DIS_WIDTH 1
+#define        FRF_BZ_TX_IP_CHKSM_DIS_LBN 90
+#define        FRF_BZ_TX_IP_CHKSM_DIS_WIDTH 1
+#define        FRF_BZ_TX_TCP_CHKSM_DIS_LBN 89
+#define        FRF_BZ_TX_TCP_CHKSM_DIS_WIDTH 1
+#define        FRF_AZ_TX_DESCQ_EN_LBN 88
+#define        FRF_AZ_TX_DESCQ_EN_WIDTH 1
+#define        FRF_AZ_TX_ISCSI_DDIG_EN_LBN 87
+#define        FRF_AZ_TX_ISCSI_DDIG_EN_WIDTH 1
+#define        FRF_AZ_TX_ISCSI_HDIG_EN_LBN 86
+#define        FRF_AZ_TX_ISCSI_HDIG_EN_WIDTH 1
+#define        FRF_AZ_TX_DC_HW_RPTR_LBN 80
+#define        FRF_AZ_TX_DC_HW_RPTR_WIDTH 6
+#define        FRF_AZ_TX_DESCQ_HW_RPTR_LBN 68
+#define        FRF_AZ_TX_DESCQ_HW_RPTR_WIDTH 12
+#define        FRF_AZ_TX_DESCQ_SW_WPTR_LBN 56
+#define        FRF_AZ_TX_DESCQ_SW_WPTR_WIDTH 12
+#define        FRF_AZ_TX_DESCQ_BUF_BASE_ID_LBN 36
+#define        FRF_AZ_TX_DESCQ_BUF_BASE_ID_WIDTH 20
+#define        FRF_AZ_TX_DESCQ_EVQ_ID_LBN 24
+#define        FRF_AZ_TX_DESCQ_EVQ_ID_WIDTH 12
+#define        FRF_AZ_TX_DESCQ_OWNER_ID_LBN 10
+#define        FRF_AZ_TX_DESCQ_OWNER_ID_WIDTH 14
+#define        FRF_AZ_TX_DESCQ_LABEL_LBN 5
+#define        FRF_AZ_TX_DESCQ_LABEL_WIDTH 5
+#define        FRF_AZ_TX_DESCQ_SIZE_LBN 3
+#define        FRF_AZ_TX_DESCQ_SIZE_WIDTH 2
+#define        FFE_AZ_TX_DESCQ_SIZE_4K 3
+#define        FFE_AZ_TX_DESCQ_SIZE_2K 2
+#define        FFE_AZ_TX_DESCQ_SIZE_1K 1
+#define        FFE_AZ_TX_DESCQ_SIZE_512 0
+#define        FRF_AZ_TX_DESCQ_TYPE_LBN 1
+#define        FRF_AZ_TX_DESCQ_TYPE_WIDTH 2
+#define        FRF_AZ_TX_DESCQ_FLUSH_LBN 0
+#define        FRF_AZ_TX_DESCQ_FLUSH_WIDTH 1
+
+/* EVQ_PTR_TBL_KER: Event queue pointer table */
+#define        FR_AA_EVQ_PTR_TBL_KER 0x00011a00
+#define        FR_AA_EVQ_PTR_TBL_KER_STEP 16
+#define        FR_AA_EVQ_PTR_TBL_KER_ROWS 4
+/* EVQ_PTR_TBL: Event queue pointer table */
+#define        FR_BZ_EVQ_PTR_TBL 0x00f60000
+#define        FR_BZ_EVQ_PTR_TBL_STEP 16
+#define        FR_CZ_EVQ_PTR_TBL_ROWS 1024
+#define        FR_BB_EVQ_PTR_TBL_ROWS 4096
+#define        FRF_BZ_EVQ_RPTR_IGN_LBN 40
+#define        FRF_BZ_EVQ_RPTR_IGN_WIDTH 1
+#define        FRF_AB_EVQ_WKUP_OR_INT_EN_LBN 39
+#define        FRF_AB_EVQ_WKUP_OR_INT_EN_WIDTH 1
+#define        FRF_CZ_EVQ_DOS_PROTECT_EN_LBN 39
+#define        FRF_CZ_EVQ_DOS_PROTECT_EN_WIDTH 1
+#define        FRF_AZ_EVQ_NXT_WPTR_LBN 24
+#define        FRF_AZ_EVQ_NXT_WPTR_WIDTH 15
+#define        FRF_AZ_EVQ_EN_LBN 23
+#define        FRF_AZ_EVQ_EN_WIDTH 1
+#define        FRF_AZ_EVQ_SIZE_LBN 20
+#define        FRF_AZ_EVQ_SIZE_WIDTH 3
+#define        FFE_AZ_EVQ_SIZE_32K 6
+#define        FFE_AZ_EVQ_SIZE_16K 5
+#define        FFE_AZ_EVQ_SIZE_8K 4
+#define        FFE_AZ_EVQ_SIZE_4K 3
+#define        FFE_AZ_EVQ_SIZE_2K 2
+#define        FFE_AZ_EVQ_SIZE_1K 1
+#define        FFE_AZ_EVQ_SIZE_512 0
+#define        FRF_AZ_EVQ_BUF_BASE_ID_LBN 0
+#define        FRF_AZ_EVQ_BUF_BASE_ID_WIDTH 20
+
+/* BUF_HALF_TBL_KER: Buffer table in half buffer table mode direct access by driver */
+#define        FR_AA_BUF_HALF_TBL_KER 0x00018000
+#define        FR_AA_BUF_HALF_TBL_KER_STEP 8
+#define        FR_AA_BUF_HALF_TBL_KER_ROWS 4096
+/* BUF_HALF_TBL: Buffer table in half buffer table mode direct access by driver */
+#define        FR_BZ_BUF_HALF_TBL 0x00800000
+#define        FR_BZ_BUF_HALF_TBL_STEP 8
+#define        FR_CZ_BUF_HALF_TBL_ROWS 147456
+#define        FR_BB_BUF_HALF_TBL_ROWS 524288
+#define        FRF_AZ_BUF_ADR_HBUF_ODD_LBN 44
+#define        FRF_AZ_BUF_ADR_HBUF_ODD_WIDTH 20
+#define        FRF_AZ_BUF_OWNER_ID_HBUF_ODD_LBN 32
+#define        FRF_AZ_BUF_OWNER_ID_HBUF_ODD_WIDTH 12
+#define        FRF_AZ_BUF_ADR_HBUF_EVEN_LBN 12
+#define        FRF_AZ_BUF_ADR_HBUF_EVEN_WIDTH 20
+#define        FRF_AZ_BUF_OWNER_ID_HBUF_EVEN_LBN 0
+#define        FRF_AZ_BUF_OWNER_ID_HBUF_EVEN_WIDTH 12
+
+/* BUF_FULL_TBL_KER: Buffer table in full buffer table mode direct access by driver */
+#define        FR_AA_BUF_FULL_TBL_KER 0x00018000
+#define        FR_AA_BUF_FULL_TBL_KER_STEP 8
+#define        FR_AA_BUF_FULL_TBL_KER_ROWS 4096
+/* BUF_FULL_TBL: Buffer table in full buffer table mode direct access by driver */
+#define        FR_BZ_BUF_FULL_TBL 0x00800000
+#define        FR_BZ_BUF_FULL_TBL_STEP 8
+#define        FR_CZ_BUF_FULL_TBL_ROWS 147456
+#define        FR_BB_BUF_FULL_TBL_ROWS 917504
+#define        FRF_AZ_BUF_FULL_UNUSED_LBN 51
+#define        FRF_AZ_BUF_FULL_UNUSED_WIDTH 13
+#define        FRF_AZ_IP_DAT_BUF_SIZE_LBN 50
+#define        FRF_AZ_IP_DAT_BUF_SIZE_WIDTH 1
+#define        FRF_AZ_BUF_ADR_REGION_LBN 48
+#define        FRF_AZ_BUF_ADR_REGION_WIDTH 2
+#define        FFE_AZ_BUF_ADR_REGN3 3
+#define        FFE_AZ_BUF_ADR_REGN2 2
+#define        FFE_AZ_BUF_ADR_REGN1 1
+#define        FFE_AZ_BUF_ADR_REGN0 0
+#define        FRF_AZ_BUF_ADR_FBUF_LBN 14
+#define        FRF_AZ_BUF_ADR_FBUF_WIDTH 34
+#define        FRF_AZ_BUF_OWNER_ID_FBUF_LBN 0
+#define        FRF_AZ_BUF_OWNER_ID_FBUF_WIDTH 14
+
+/* RX_FILTER_TBL0: TCP/IPv4 Receive filter table */
+#define        FR_BZ_RX_FILTER_TBL0 0x00f00000
+#define        FR_BZ_RX_FILTER_TBL0_STEP 32
+#define        FR_BZ_RX_FILTER_TBL0_ROWS 8192
+/* RX_FILTER_TBL1: TCP/IPv4 Receive filter table */
+#define        FR_BB_RX_FILTER_TBL1 0x00f00010
+#define        FR_BB_RX_FILTER_TBL1_STEP 32
+#define        FR_BB_RX_FILTER_TBL1_ROWS 8192
+#define        FRF_BZ_RSS_EN_LBN 110
+#define        FRF_BZ_RSS_EN_WIDTH 1
+#define        FRF_BZ_SCATTER_EN_LBN 109
+#define        FRF_BZ_SCATTER_EN_WIDTH 1
+#define        FRF_BZ_TCP_UDP_LBN 108
+#define        FRF_BZ_TCP_UDP_WIDTH 1
+#define        FRF_BZ_RXQ_ID_LBN 96
+#define        FRF_BZ_RXQ_ID_WIDTH 12
+#define        FRF_BZ_DEST_IP_LBN 64
+#define        FRF_BZ_DEST_IP_WIDTH 32
+#define        FRF_BZ_DEST_PORT_TCP_LBN 48
+#define        FRF_BZ_DEST_PORT_TCP_WIDTH 16
+#define        FRF_BZ_SRC_IP_LBN 16
+#define        FRF_BZ_SRC_IP_WIDTH 32
+#define        FRF_BZ_SRC_TCP_DEST_UDP_LBN 0
+#define        FRF_BZ_SRC_TCP_DEST_UDP_WIDTH 16
+
+/* RX_MAC_FILTER_TBL0: Receive Ethernet filter table */
+#define        FR_CZ_RX_MAC_FILTER_TBL0 0x00f00010
+#define        FR_CZ_RX_MAC_FILTER_TBL0_STEP 32
+#define        FR_CZ_RX_MAC_FILTER_TBL0_ROWS 512
+#define        FRF_CZ_RMFT_RSS_EN_LBN 75
+#define        FRF_CZ_RMFT_RSS_EN_WIDTH 1
+#define        FRF_CZ_RMFT_SCATTER_EN_LBN 74
+#define        FRF_CZ_RMFT_SCATTER_EN_WIDTH 1
+#define        FRF_CZ_RMFT_IP_OVERRIDE_LBN 73
+#define        FRF_CZ_RMFT_IP_OVERRIDE_WIDTH 1
+#define        FRF_CZ_RMFT_RXQ_ID_LBN 61
+#define        FRF_CZ_RMFT_RXQ_ID_WIDTH 12
+#define        FRF_CZ_RMFT_WILDCARD_MATCH_LBN 60
+#define        FRF_CZ_RMFT_WILDCARD_MATCH_WIDTH 1
+#define        FRF_CZ_RMFT_DEST_MAC_LBN 12
+#define        FRF_CZ_RMFT_DEST_MAC_WIDTH 48
+#define        FRF_CZ_RMFT_VLAN_ID_LBN 0
+#define        FRF_CZ_RMFT_VLAN_ID_WIDTH 12
+
+/* TIMER_TBL: Timer table */
+#define        FR_BZ_TIMER_TBL 0x00f70000
+#define        FR_BZ_TIMER_TBL_STEP 16
+#define        FR_CZ_TIMER_TBL_ROWS 1024
+#define        FR_BB_TIMER_TBL_ROWS 4096
+#define        FRF_CZ_TIMER_Q_EN_LBN 33
+#define        FRF_CZ_TIMER_Q_EN_WIDTH 1
+#define        FRF_CZ_INT_ARMD_LBN 32
+#define        FRF_CZ_INT_ARMD_WIDTH 1
+#define        FRF_CZ_INT_PEND_LBN 31
+#define        FRF_CZ_INT_PEND_WIDTH 1
+#define        FRF_CZ_HOST_NOTIFY_MODE_LBN 30
+#define        FRF_CZ_HOST_NOTIFY_MODE_WIDTH 1
+#define        FRF_CZ_RELOAD_TIMER_VAL_LBN 16
+#define        FRF_CZ_RELOAD_TIMER_VAL_WIDTH 14
+#define        FRF_CZ_TIMER_MODE_LBN 14
+#define        FRF_CZ_TIMER_MODE_WIDTH 2
+#define        FFE_CZ_TIMER_MODE_INT_HLDOFF 3
+#define        FFE_CZ_TIMER_MODE_TRIG_START 2
+#define        FFE_CZ_TIMER_MODE_IMMED_START 1
+#define        FFE_CZ_TIMER_MODE_DIS 0
+#define        FRF_BB_TIMER_MODE_LBN 12
+#define        FRF_BB_TIMER_MODE_WIDTH 2
+#define        FFE_BB_TIMER_MODE_INT_HLDOFF 2
+#define        FFE_BB_TIMER_MODE_TRIG_START 2
+#define        FFE_BB_TIMER_MODE_IMMED_START 1
+#define        FFE_BB_TIMER_MODE_DIS 0
+#define        FRF_CZ_TIMER_VAL_LBN 0
+#define        FRF_CZ_TIMER_VAL_WIDTH 14
+#define        FRF_BB_TIMER_VAL_LBN 0
+#define        FRF_BB_TIMER_VAL_WIDTH 12
+
+/* TX_PACE_TBL: Transmit pacing table */
+#define        FR_BZ_TX_PACE_TBL 0x00f80000
+#define        FR_BZ_TX_PACE_TBL_STEP 16
+#define        FR_CZ_TX_PACE_TBL_ROWS 1024
+#define        FR_BB_TX_PACE_TBL_ROWS 4096
+#define        FRF_BZ_TX_PACE_LBN 0
+#define        FRF_BZ_TX_PACE_WIDTH 5
+
+/* RX_INDIRECTION_TBL: RX Indirection Table */
+#define        FR_BZ_RX_INDIRECTION_TBL 0x00fb0000
+#define        FR_BZ_RX_INDIRECTION_TBL_STEP 16
+#define        FR_BZ_RX_INDIRECTION_TBL_ROWS 128
+#define        FRF_BZ_IT_QUEUE_LBN 0
+#define        FRF_BZ_IT_QUEUE_WIDTH 6
+
+/* TX_FILTER_TBL0: TCP/IPv4 Transmit filter table */
+#define        FR_CZ_TX_FILTER_TBL0 0x00fc0000
+#define        FR_CZ_TX_FILTER_TBL0_STEP 16
+#define        FR_CZ_TX_FILTER_TBL0_ROWS 8192
+#define        FRF_CZ_TIFT_TCP_UDP_LBN 108
+#define        FRF_CZ_TIFT_TCP_UDP_WIDTH 1
+#define        FRF_CZ_TIFT_TXQ_ID_LBN 96
+#define        FRF_CZ_TIFT_TXQ_ID_WIDTH 12
+#define        FRF_CZ_TIFT_DEST_IP_LBN 64
+#define        FRF_CZ_TIFT_DEST_IP_WIDTH 32
+#define        FRF_CZ_TIFT_DEST_PORT_TCP_LBN 48
+#define        FRF_CZ_TIFT_DEST_PORT_TCP_WIDTH 16
+#define        FRF_CZ_TIFT_SRC_IP_LBN 16
+#define        FRF_CZ_TIFT_SRC_IP_WIDTH 32
+#define        FRF_CZ_TIFT_SRC_TCP_DEST_UDP_LBN 0
+#define        FRF_CZ_TIFT_SRC_TCP_DEST_UDP_WIDTH 16
+
+/* TX_MAC_FILTER_TBL0: Transmit Ethernet filter table */
+#define        FR_CZ_TX_MAC_FILTER_TBL0 0x00fe0000
+#define        FR_CZ_TX_MAC_FILTER_TBL0_STEP 16
+#define        FR_CZ_TX_MAC_FILTER_TBL0_ROWS 512
+#define        FRF_CZ_TMFT_TXQ_ID_LBN 61
+#define        FRF_CZ_TMFT_TXQ_ID_WIDTH 12
+#define        FRF_CZ_TMFT_WILDCARD_MATCH_LBN 60
+#define        FRF_CZ_TMFT_WILDCARD_MATCH_WIDTH 1
+#define        FRF_CZ_TMFT_SRC_MAC_LBN 12
+#define        FRF_CZ_TMFT_SRC_MAC_WIDTH 48
+#define        FRF_CZ_TMFT_VLAN_ID_LBN 0
+#define        FRF_CZ_TMFT_VLAN_ID_WIDTH 12
+
+/* MC_TREG_SMEM: MC Shared Memory */
+#define        FR_CZ_MC_TREG_SMEM 0x00ff0000
+#define        FR_CZ_MC_TREG_SMEM_STEP 4
+#define        FR_CZ_MC_TREG_SMEM_ROWS 512
+#define        FRF_CZ_MC_TREG_SMEM_ROW_LBN 0
+#define        FRF_CZ_MC_TREG_SMEM_ROW_WIDTH 32
+
+/* MSIX_VECTOR_TABLE: MSIX Vector Table */
+#define        FR_BB_MSIX_VECTOR_TABLE 0x00ff0000
+#define        FR_BZ_MSIX_VECTOR_TABLE_STEP 16
+#define        FR_BB_MSIX_VECTOR_TABLE_ROWS 64
+/* MSIX_VECTOR_TABLE: MSIX Vector Table */
+#define        FR_CZ_MSIX_VECTOR_TABLE 0x00000000
+/* FR_BZ_MSIX_VECTOR_TABLE_STEP 16 */
+#define        FR_CZ_MSIX_VECTOR_TABLE_ROWS 1024
+#define        FRF_BZ_MSIX_VECTOR_RESERVED_LBN 97
+#define        FRF_BZ_MSIX_VECTOR_RESERVED_WIDTH 31
+#define        FRF_BZ_MSIX_VECTOR_MASK_LBN 96
+#define        FRF_BZ_MSIX_VECTOR_MASK_WIDTH 1
+#define        FRF_BZ_MSIX_MESSAGE_DATA_LBN 64
+#define        FRF_BZ_MSIX_MESSAGE_DATA_WIDTH 32
+#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_HI_LBN 32
+#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_HI_WIDTH 32
+#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_LO_LBN 0
+#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_LO_WIDTH 32
+
+/* MSIX_PBA_TABLE: MSIX Pending Bit Array */
+#define        FR_BB_MSIX_PBA_TABLE 0x00ff2000
+#define        FR_BZ_MSIX_PBA_TABLE_STEP 4
+#define        FR_BB_MSIX_PBA_TABLE_ROWS 2
+/* MSIX_PBA_TABLE: MSIX Pending Bit Array */
+#define        FR_CZ_MSIX_PBA_TABLE 0x00008000
+/* FR_BZ_MSIX_PBA_TABLE_STEP 4 */
+#define        FR_CZ_MSIX_PBA_TABLE_ROWS 32
+#define        FRF_BZ_MSIX_PBA_PEND_DWORD_LBN 0
+#define        FRF_BZ_MSIX_PBA_PEND_DWORD_WIDTH 32
+
+/* SRM_DBG_REG: SRAM debug access */
+#define        FR_BZ_SRM_DBG 0x03000000
+#define        FR_BZ_SRM_DBG_STEP 8
+#define        FR_CZ_SRM_DBG_ROWS 262144
+#define        FR_BB_SRM_DBG_ROWS 2097152
+#define        FRF_BZ_SRM_DBG_LBN 0
+#define        FRF_BZ_SRM_DBG_WIDTH 64
+
+/* TB_MSIX_PBA_TABLE: MSIX Pending Bit Array */
+#define        FR_CZ_TB_MSIX_PBA_TABLE 0x00008000
+#define        FR_CZ_TB_MSIX_PBA_TABLE_STEP 4
+#define        FR_CZ_TB_MSIX_PBA_TABLE_ROWS 1024
+#define        FRF_CZ_TB_MSIX_PBA_PEND_DWORD_LBN 0
+#define        FRF_CZ_TB_MSIX_PBA_PEND_DWORD_WIDTH 32
+
+/* DRIVER_EV */
+#define        FSF_AZ_DRIVER_EV_SUBCODE_LBN 56
+#define        FSF_AZ_DRIVER_EV_SUBCODE_WIDTH 4
+#define        FSE_BZ_TX_DSC_ERROR_EV 15
+#define        FSE_BZ_RX_DSC_ERROR_EV 14
+#define        FSE_AA_RX_RECOVER_EV 11
+#define        FSE_AZ_TIMER_EV 10
+#define        FSE_AZ_TX_PKT_NON_TCP_UDP 9
+#define        FSE_AZ_WAKE_UP_EV 6
+#define        FSE_AZ_SRM_UPD_DONE_EV 5
+#define        FSE_AB_EVQ_NOT_EN_EV 3
+#define        FSE_AZ_EVQ_INIT_DONE_EV 2
+#define        FSE_AZ_RX_DESCQ_FLS_DONE_EV 1
+#define        FSE_AZ_TX_DESCQ_FLS_DONE_EV 0
+#define        FSF_AZ_DRIVER_EV_SUBDATA_LBN 0
+#define        FSF_AZ_DRIVER_EV_SUBDATA_WIDTH 14
+
+/* EVENT_ENTRY */
+#define        FSF_AZ_EV_CODE_LBN 60
+#define        FSF_AZ_EV_CODE_WIDTH 4
+#define        FSE_CZ_EV_CODE_MCDI_EV 12
+#define        FSE_CZ_EV_CODE_USER_EV 8
+#define        FSE_AZ_EV_CODE_DRV_GEN_EV 7
+#define        FSE_AZ_EV_CODE_GLOBAL_EV 6
+#define        FSE_AZ_EV_CODE_DRIVER_EV 5
+#define        FSE_AZ_EV_CODE_TX_EV 2
+#define        FSE_AZ_EV_CODE_RX_EV 0
+#define        FSF_AZ_EV_DATA_LBN 0
+#define        FSF_AZ_EV_DATA_WIDTH 60
+
+/* GLOBAL_EV */
+#define        FSF_BB_GLB_EV_RX_RECOVERY_LBN 12
+#define        FSF_BB_GLB_EV_RX_RECOVERY_WIDTH 1
+#define        FSF_AA_GLB_EV_RX_RECOVERY_LBN 11
+#define        FSF_AA_GLB_EV_RX_RECOVERY_WIDTH 1
+#define        FSF_BB_GLB_EV_XG_MGT_INTR_LBN 11
+#define        FSF_BB_GLB_EV_XG_MGT_INTR_WIDTH 1
+#define        FSF_AB_GLB_EV_XFP_PHY0_INTR_LBN 10
+#define        FSF_AB_GLB_EV_XFP_PHY0_INTR_WIDTH 1
+#define        FSF_AB_GLB_EV_XG_PHY0_INTR_LBN 9
+#define        FSF_AB_GLB_EV_XG_PHY0_INTR_WIDTH 1
+#define        FSF_AB_GLB_EV_G_PHY0_INTR_LBN 7
+#define        FSF_AB_GLB_EV_G_PHY0_INTR_WIDTH 1
+
+/* LEGACY_INT_VEC */
+#define        FSF_AZ_NET_IVEC_FATAL_INT_LBN 64
+#define        FSF_AZ_NET_IVEC_FATAL_INT_WIDTH 1
+#define        FSF_AZ_NET_IVEC_INT_Q_LBN 40
+#define        FSF_AZ_NET_IVEC_INT_Q_WIDTH 4
+#define        FSF_AZ_NET_IVEC_INT_FLAG_LBN 32
+#define        FSF_AZ_NET_IVEC_INT_FLAG_WIDTH 1
+#define        FSF_AZ_NET_IVEC_EVQ_FIFO_HF_LBN 1
+#define        FSF_AZ_NET_IVEC_EVQ_FIFO_HF_WIDTH 1
+#define        FSF_AZ_NET_IVEC_EVQ_FIFO_AF_LBN 0
+#define        FSF_AZ_NET_IVEC_EVQ_FIFO_AF_WIDTH 1
+
+/* MC_XGMAC_FLTR_RULE_DEF */
+#define        FSF_CZ_MC_XFRC_MODE_LBN 416
+#define        FSF_CZ_MC_XFRC_MODE_WIDTH 1
+#define        FSE_CZ_MC_XFRC_MODE_LAYERED 1
+#define        FSE_CZ_MC_XFRC_MODE_SIMPLE 0
+#define        FSF_CZ_MC_XFRC_HASH_LBN 384
+#define        FSF_CZ_MC_XFRC_HASH_WIDTH 32
+#define        FSF_CZ_MC_XFRC_LAYER4_BYTE_MASK_LBN 256
+#define        FSF_CZ_MC_XFRC_LAYER4_BYTE_MASK_WIDTH 128
+#define        FSF_CZ_MC_XFRC_LAYER3_BYTE_MASK_LBN 128
+#define        FSF_CZ_MC_XFRC_LAYER3_BYTE_MASK_WIDTH 128
+#define        FSF_CZ_MC_XFRC_LAYER2_OR_SIMPLE_BYTE_MASK_LBN 0
+#define        FSF_CZ_MC_XFRC_LAYER2_OR_SIMPLE_BYTE_MASK_WIDTH 128
+
+/* RX_EV */
+#define        FSF_CZ_RX_EV_PKT_NOT_PARSED_LBN 58
+#define        FSF_CZ_RX_EV_PKT_NOT_PARSED_WIDTH 1
+#define        FSF_CZ_RX_EV_IPV6_PKT_LBN 57
+#define        FSF_CZ_RX_EV_IPV6_PKT_WIDTH 1
+#define        FSF_AZ_RX_EV_PKT_OK_LBN 56
+#define        FSF_AZ_RX_EV_PKT_OK_WIDTH 1
+#define        FSF_AZ_RX_EV_PAUSE_FRM_ERR_LBN 55
+#define        FSF_AZ_RX_EV_PAUSE_FRM_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_BUF_OWNER_ID_ERR_LBN 54
+#define        FSF_AZ_RX_EV_BUF_OWNER_ID_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_IP_FRAG_ERR_LBN 53
+#define        FSF_AZ_RX_EV_IP_FRAG_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_IP_HDR_CHKSUM_ERR_LBN 52
+#define        FSF_AZ_RX_EV_IP_HDR_CHKSUM_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_TCP_UDP_CHKSUM_ERR_LBN 51
+#define        FSF_AZ_RX_EV_TCP_UDP_CHKSUM_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_ETH_CRC_ERR_LBN 50
+#define        FSF_AZ_RX_EV_ETH_CRC_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_FRM_TRUNC_LBN 49
+#define        FSF_AZ_RX_EV_FRM_TRUNC_WIDTH 1
+#define        FSF_AA_RX_EV_DRIB_NIB_LBN 49
+#define        FSF_AA_RX_EV_DRIB_NIB_WIDTH 1
+#define        FSF_AZ_RX_EV_TOBE_DISC_LBN 47
+#define        FSF_AZ_RX_EV_TOBE_DISC_WIDTH 1
+#define        FSF_AZ_RX_EV_PKT_TYPE_LBN 44
+#define        FSF_AZ_RX_EV_PKT_TYPE_WIDTH 3
+#define        FSE_AZ_RX_EV_PKT_TYPE_VLAN_JUMBO 5
+#define        FSE_AZ_RX_EV_PKT_TYPE_VLAN_LLC 4
+#define        FSE_AZ_RX_EV_PKT_TYPE_VLAN 3
+#define        FSE_AZ_RX_EV_PKT_TYPE_JUMBO 2
+#define        FSE_AZ_RX_EV_PKT_TYPE_LLC 1
+#define        FSE_AZ_RX_EV_PKT_TYPE_ETH 0
+#define        FSF_AZ_RX_EV_HDR_TYPE_LBN 42
+#define        FSF_AZ_RX_EV_HDR_TYPE_WIDTH 2
+#define        FSE_AZ_RX_EV_HDR_TYPE_OTHER 3
+#define        FSE_AB_RX_EV_HDR_TYPE_IPV4_OTHER 2
+#define        FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER 2
+#define        FSE_AB_RX_EV_HDR_TYPE_IPV4_UDP 1
+#define        FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP 1
+#define        FSE_AB_RX_EV_HDR_TYPE_IPV4_TCP 0
+#define        FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP 0
+#define        FSF_AZ_RX_EV_DESC_Q_EMPTY_LBN 41
+#define        FSF_AZ_RX_EV_DESC_Q_EMPTY_WIDTH 1
+#define        FSF_AZ_RX_EV_MCAST_HASH_MATCH_LBN 40
+#define        FSF_AZ_RX_EV_MCAST_HASH_MATCH_WIDTH 1
+#define        FSF_AZ_RX_EV_MCAST_PKT_LBN 39
+#define        FSF_AZ_RX_EV_MCAST_PKT_WIDTH 1
+#define        FSF_AA_RX_EV_RECOVERY_FLAG_LBN 37
+#define        FSF_AA_RX_EV_RECOVERY_FLAG_WIDTH 1
+#define        FSF_AZ_RX_EV_Q_LABEL_LBN 32
+#define        FSF_AZ_RX_EV_Q_LABEL_WIDTH 5
+#define        FSF_AZ_RX_EV_JUMBO_CONT_LBN 31
+#define        FSF_AZ_RX_EV_JUMBO_CONT_WIDTH 1
+#define        FSF_AZ_RX_EV_PORT_LBN 30
+#define        FSF_AZ_RX_EV_PORT_WIDTH 1
+#define        FSF_AZ_RX_EV_BYTE_CNT_LBN 16
+#define        FSF_AZ_RX_EV_BYTE_CNT_WIDTH 14
+#define        FSF_AZ_RX_EV_SOP_LBN 15
+#define        FSF_AZ_RX_EV_SOP_WIDTH 1
+#define        FSF_AZ_RX_EV_ISCSI_PKT_OK_LBN 14
+#define        FSF_AZ_RX_EV_ISCSI_PKT_OK_WIDTH 1
+#define        FSF_AZ_RX_EV_ISCSI_DDIG_ERR_LBN 13
+#define        FSF_AZ_RX_EV_ISCSI_DDIG_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_ISCSI_HDIG_ERR_LBN 12
+#define        FSF_AZ_RX_EV_ISCSI_HDIG_ERR_WIDTH 1
+#define        FSF_AZ_RX_EV_DESC_PTR_LBN 0
+#define        FSF_AZ_RX_EV_DESC_PTR_WIDTH 12
+
+/* RX_KER_DESC */
+#define        FSF_AZ_RX_KER_BUF_SIZE_LBN 48
+#define        FSF_AZ_RX_KER_BUF_SIZE_WIDTH 14
+#define        FSF_AZ_RX_KER_BUF_REGION_LBN 46
+#define        FSF_AZ_RX_KER_BUF_REGION_WIDTH 2
+#define        FSF_AZ_RX_KER_BUF_ADDR_LBN 0
+#define        FSF_AZ_RX_KER_BUF_ADDR_WIDTH 46
+
+/* RX_USER_DESC */
+#define        FSF_AZ_RX_USER_2BYTE_OFFSET_LBN 20
+#define        FSF_AZ_RX_USER_2BYTE_OFFSET_WIDTH 12
+#define        FSF_AZ_RX_USER_BUF_ID_LBN 0
+#define        FSF_AZ_RX_USER_BUF_ID_WIDTH 20
+
+/* TX_EV */
+#define        FSF_AZ_TX_EV_PKT_ERR_LBN 38
+#define        FSF_AZ_TX_EV_PKT_ERR_WIDTH 1
+#define        FSF_AZ_TX_EV_PKT_TOO_BIG_LBN 37
+#define        FSF_AZ_TX_EV_PKT_TOO_BIG_WIDTH 1
+#define        FSF_AZ_TX_EV_Q_LABEL_LBN 32
+#define        FSF_AZ_TX_EV_Q_LABEL_WIDTH 5
+#define        FSF_AZ_TX_EV_PORT_LBN 16
+#define        FSF_AZ_TX_EV_PORT_WIDTH 1
+#define        FSF_AZ_TX_EV_WQ_FF_FULL_LBN 15
+#define        FSF_AZ_TX_EV_WQ_FF_FULL_WIDTH 1
+#define        FSF_AZ_TX_EV_BUF_OWNER_ID_ERR_LBN 14
+#define        FSF_AZ_TX_EV_BUF_OWNER_ID_ERR_WIDTH 1
+#define        FSF_AZ_TX_EV_COMP_LBN 12
+#define        FSF_AZ_TX_EV_COMP_WIDTH 1
+#define        FSF_AZ_TX_EV_DESC_PTR_LBN 0
+#define        FSF_AZ_TX_EV_DESC_PTR_WIDTH 12
+
+/* TX_KER_DESC */
+#define        FSF_AZ_TX_KER_CONT_LBN 62
+#define        FSF_AZ_TX_KER_CONT_WIDTH 1
+#define        FSF_AZ_TX_KER_BYTE_COUNT_LBN 48
+#define        FSF_AZ_TX_KER_BYTE_COUNT_WIDTH 14
+#define        FSF_AZ_TX_KER_BUF_REGION_LBN 46
+#define        FSF_AZ_TX_KER_BUF_REGION_WIDTH 2
+#define        FSF_AZ_TX_KER_BUF_ADDR_LBN 0
+#define        FSF_AZ_TX_KER_BUF_ADDR_WIDTH 46
+
+/* TX_USER_DESC */
+#define        FSF_AZ_TX_USER_SW_EV_EN_LBN 48
+#define        FSF_AZ_TX_USER_SW_EV_EN_WIDTH 1
+#define        FSF_AZ_TX_USER_CONT_LBN 46
+#define        FSF_AZ_TX_USER_CONT_WIDTH 1
+#define        FSF_AZ_TX_USER_BYTE_CNT_LBN 33
+#define        FSF_AZ_TX_USER_BYTE_CNT_WIDTH 13
+#define        FSF_AZ_TX_USER_BUF_ID_LBN 13
+#define        FSF_AZ_TX_USER_BUF_ID_WIDTH 20
+#define        FSF_AZ_TX_USER_BYTE_OFS_LBN 0
+#define        FSF_AZ_TX_USER_BYTE_OFS_WIDTH 13
+
+/* USER_EV */
+#define        FSF_CZ_USER_QID_LBN 32
+#define        FSF_CZ_USER_QID_WIDTH 10
+#define        FSF_CZ_USER_EV_REG_VALUE_LBN 0
+#define        FSF_CZ_USER_EV_REG_VALUE_WIDTH 32
+
+/**************************************************************************
+ *
+ * Falcon B0 PCIe core indirect registers
+ *
+ **************************************************************************
+ */
+
+#define FPCR_BB_PCIE_DEVICE_CTRL_STAT 0x68
+
+#define FPCR_BB_PCIE_LINK_CTRL_STAT 0x70
+
+#define FPCR_BB_ACK_RPL_TIMER 0x700
+#define FPCRF_BB_ACK_TL_LBN 0
+#define FPCRF_BB_ACK_TL_WIDTH 16
+#define FPCRF_BB_RPL_TL_LBN 16
+#define FPCRF_BB_RPL_TL_WIDTH 16
+
+#define FPCR_BB_ACK_FREQ 0x70C
+#define FPCRF_BB_ACK_FREQ_LBN 0
+#define FPCRF_BB_ACK_FREQ_WIDTH 7
+
+/**************************************************************************
+ *
+ * Pseudo-registers and fields
+ *
+ **************************************************************************
+ */
+
+/* Interrupt acknowledge work-around register (A0/A1 only) */
+#define FR_AA_WORK_AROUND_BROKEN_PCI_READS 0x0070
+
+/* EE_SPI_HCMD_REG: SPI host command register */
+/* Values for the EE_SPI_HCMD_SF_SEL register field */
+#define FFE_AB_SPI_DEVICE_EEPROM 0
+#define FFE_AB_SPI_DEVICE_FLASH 1
+
+/* NIC_STAT_REG: NIC status register */
+#define FRF_AB_STRAP_10G_LBN 2
+#define FRF_AB_STRAP_10G_WIDTH 1
+#define FRF_AA_STRAP_PCIE_LBN 0
+#define FRF_AA_STRAP_PCIE_WIDTH 1
+
+/* FATAL_INTR_REG_KER: Fatal interrupt register for Kernel */
+#define FRF_AZ_FATAL_INTR_LBN 0
+#define FRF_AZ_FATAL_INTR_WIDTH 12
+
+/* SRM_CFG_REG: SRAM configuration register */
+/* We treat the number of SRAM banks and bank size as a single field */
+#define        FRF_AZ_SRM_NB_SZ_LBN FRF_AZ_SRM_BANK_SIZE_LBN
+#define        FRF_AZ_SRM_NB_SZ_WIDTH \
+       (FRF_AZ_SRM_BANK_SIZE_WIDTH + FRF_AZ_SRM_NUM_BANK_WIDTH)
+#define FFE_AB_SRM_NB1_SZ2M 0
+#define FFE_AB_SRM_NB1_SZ4M 1
+#define FFE_AB_SRM_NB1_SZ8M 2
+#define FFE_AB_SRM_NB_SZ_DEF 3
+#define FFE_AB_SRM_NB2_SZ4M 4
+#define FFE_AB_SRM_NB2_SZ8M 5
+#define FFE_AB_SRM_NB2_SZ16M 6
+#define FFE_AB_SRM_NB_SZ_RES 7
+
+/* RX_DESC_UPD_REGP0: Receive descriptor update register. */
+/* We write just the last dword of these registers */
+#define        FR_AZ_RX_DESC_UPD_DWORD_P0 \
+       (BUILD_BUG_ON_ZERO(FR_AA_RX_DESC_UPD_KER != FR_BZ_RX_DESC_UPD_P0) + \
+        FR_BZ_RX_DESC_UPD_P0 + 3 * 4)
+#define        FRF_AZ_RX_DESC_WPTR_DWORD_LBN (FRF_AZ_RX_DESC_WPTR_LBN - 3 * 32)
+#define        FRF_AZ_RX_DESC_WPTR_DWORD_WIDTH FRF_AZ_RX_DESC_WPTR_WIDTH
+
+/* TX_DESC_UPD_REGP0: Transmit descriptor update register. */
+#define FR_AZ_TX_DESC_UPD_DWORD_P0 \
+       (BUILD_BUG_ON_ZERO(FR_AA_TX_DESC_UPD_KER != FR_BZ_TX_DESC_UPD_P0) + \
+        FR_BZ_TX_DESC_UPD_P0 + 3 * 4)
+#define        FRF_AZ_TX_DESC_WPTR_DWORD_LBN (FRF_AZ_TX_DESC_WPTR_LBN - 3 * 32)
+#define        FRF_AZ_TX_DESC_WPTR_DWORD_WIDTH FRF_AZ_TX_DESC_WPTR_WIDTH
+
+/* GMF_CFG4_REG: GMAC FIFO configuration register 4 */
+#define FRF_AB_GMF_HSTFLTRFRM_PAUSE_LBN 12
+#define FRF_AB_GMF_HSTFLTRFRM_PAUSE_WIDTH 1
+
+/* GMF_CFG5_REG: GMAC FIFO configuration register 5 */
+#define FRF_AB_GMF_HSTFLTRFRMDC_PAUSE_LBN 12
+#define FRF_AB_GMF_HSTFLTRFRMDC_PAUSE_WIDTH 1
+
+/* XM_TX_PARAM_REG: XGMAC transmit parameter register */
+#define        FRF_AB_XM_MAX_TX_FRM_SIZE_LBN FRF_AB_XM_MAX_TX_FRM_SIZE_LO_LBN
+#define        FRF_AB_XM_MAX_TX_FRM_SIZE_WIDTH (FRF_AB_XM_MAX_TX_FRM_SIZE_HI_WIDTH + \
+                                        FRF_AB_XM_MAX_TX_FRM_SIZE_LO_WIDTH)
+
+/* XM_RX_PARAM_REG: XGMAC receive parameter register */
+#define        FRF_AB_XM_MAX_RX_FRM_SIZE_LBN FRF_AB_XM_MAX_RX_FRM_SIZE_LO_LBN
+#define        FRF_AB_XM_MAX_RX_FRM_SIZE_WIDTH (FRF_AB_XM_MAX_RX_FRM_SIZE_HI_WIDTH + \
+                                        FRF_AB_XM_MAX_RX_FRM_SIZE_LO_WIDTH)
+
+/* XX_TXDRV_CTL_REG: XAUI SerDes transmit drive control register */
+/* Default values */
+#define FFE_AB_XX_TXDRV_DEQ_DEF 0xe /* deq=.6 */
+#define FFE_AB_XX_TXDRV_DTX_DEF 0x5 /* 1.25 */
+#define FFE_AB_XX_SD_CTL_DRV_DEF 0  /* 20mA */
+
+/* XX_CORE_STAT_REG: XAUI XGXS core status register */
+/* XGXS all-lanes status fields */
+#define        FRF_AB_XX_SYNC_STAT_LBN FRF_AB_XX_SYNC_STAT0_LBN
+#define        FRF_AB_XX_SYNC_STAT_WIDTH 4
+#define        FRF_AB_XX_COMMA_DET_LBN FRF_AB_XX_COMMA_DET_CH0_LBN
+#define        FRF_AB_XX_COMMA_DET_WIDTH 4
+#define        FRF_AB_XX_CHAR_ERR_LBN FRF_AB_XX_CHAR_ERR_CH0_LBN
+#define        FRF_AB_XX_CHAR_ERR_WIDTH 4
+#define        FRF_AB_XX_DISPERR_LBN FRF_AB_XX_DISPERR_CH0_LBN
+#define        FRF_AB_XX_DISPERR_WIDTH 4
+#define        FFE_AB_XX_STAT_ALL_LANES 0xf
+#define        FRF_AB_XX_FORCE_SIG_LBN FRF_AB_XX_FORCE_SIG0_VAL_LBN
+#define        FRF_AB_XX_FORCE_SIG_WIDTH 8
+#define        FFE_AB_XX_FORCE_SIG_ALL_LANES 0xff
+
+/* RX_MAC_FILTER_TBL0 */
+/* RMFT_DEST_MAC is wider than 32 bits */
+#define FRF_CZ_RMFT_DEST_MAC_LO_LBN FRF_CZ_RMFT_DEST_MAC_LBN
+#define FRF_CZ_RMFT_DEST_MAC_LO_WIDTH 32
+#define FRF_CZ_RMFT_DEST_MAC_HI_LBN (FRF_CZ_RMFT_DEST_MAC_LBN + 32)
+#define FRF_CZ_RMFT_DEST_MAC_HI_WIDTH (FRF_CZ_RMFT_DEST_MAC_WIDTH - 32)
+
+/* TX_MAC_FILTER_TBL0 */
+/* TMFT_SRC_MAC is wider than 32 bits */
+#define FRF_CZ_TMFT_SRC_MAC_LO_LBN FRF_CZ_TMFT_SRC_MAC_LBN
+#define FRF_CZ_TMFT_SRC_MAC_LO_WIDTH 32
+#define FRF_CZ_TMFT_SRC_MAC_HI_LBN (FRF_CZ_TMFT_SRC_MAC_LBN + 32)
+#define FRF_CZ_TMFT_SRC_MAC_HI_WIDTH (FRF_CZ_TMFT_SRC_MAC_WIDTH - 32)
+
+/* TX_PACE_TBL */
+/* Values >20 are documented as reserved, but will result in a queue going
+ * into the fast bin with a pace value of zero. */
+#define FFE_BZ_TX_PACE_OFF 0
+#define FFE_BZ_TX_PACE_RESERVED 21
+
+/* DRIVER_EV */
+/* Sub-fields of an RX flush completion event */
+#define FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL_LBN 12
+#define FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL_WIDTH 1
+#define FSF_AZ_DRIVER_EV_RX_DESCQ_ID_LBN 0
+#define FSF_AZ_DRIVER_EV_RX_DESCQ_ID_WIDTH 12
+
+/* EVENT_ENTRY */
+/* Magic number field for event test */
+#define FSF_AZ_DRV_GEN_EV_MAGIC_LBN 0
+#define FSF_AZ_DRV_GEN_EV_MAGIC_WIDTH 32
+
+/* RX packet prefix */
+#define FS_BZ_RX_PREFIX_HASH_OFST 12
+#define FS_BZ_RX_PREFIX_SIZE 16
+
+#endif /* EFX_FARCH_REGS_H */
diff --git a/drivers/net/ethernet/sfc/filter.c b/drivers/net/ethernet/sfc/filter.c
deleted file mode 100644 (file)
index b74a60a..0000000
+++ /dev/null
@@ -1,1272 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2005-2010 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-#include <linux/in.h>
-#include <net/ip.h>
-#include "efx.h"
-#include "filter.h"
-#include "io.h"
-#include "nic.h"
-#include "regs.h"
-
-/* "Fudge factors" - difference between programmed value and actual depth.
- * Due to pipelined implementation we need to program H/W with a value that
- * is larger than the hop limit we want.
- */
-#define FILTER_CTL_SRCH_FUDGE_WILD 3
-#define FILTER_CTL_SRCH_FUDGE_FULL 1
-
-/* Hard maximum hop limit.  Hardware will time-out beyond 200-something.
- * We also need to avoid infinite loops in efx_filter_search() when the
- * table is full.
- */
-#define FILTER_CTL_SRCH_MAX 200
-
-/* Don't try very hard to find space for performance hints, as this is
- * counter-productive. */
-#define FILTER_CTL_SRCH_HINT_MAX 5
-
-enum efx_filter_table_id {
-       EFX_FILTER_TABLE_RX_IP = 0,
-       EFX_FILTER_TABLE_RX_MAC,
-       EFX_FILTER_TABLE_RX_DEF,
-       EFX_FILTER_TABLE_TX_MAC,
-       EFX_FILTER_TABLE_COUNT,
-};
-
-enum efx_filter_index {
-       EFX_FILTER_INDEX_UC_DEF,
-       EFX_FILTER_INDEX_MC_DEF,
-       EFX_FILTER_SIZE_RX_DEF,
-};
-
-struct efx_filter_table {
-       enum efx_filter_table_id id;
-       u32             offset;         /* address of table relative to BAR */
-       unsigned        size;           /* number of entries */
-       unsigned        step;           /* step between entries */
-       unsigned        used;           /* number currently used */
-       unsigned long   *used_bitmap;
-       struct efx_filter_spec *spec;
-       unsigned        search_depth[EFX_FILTER_TYPE_COUNT];
-};
-
-struct efx_filter_state {
-       spinlock_t      lock;
-       struct efx_filter_table table[EFX_FILTER_TABLE_COUNT];
-#ifdef CONFIG_RFS_ACCEL
-       u32             *rps_flow_id;
-       unsigned        rps_expire_index;
-#endif
-};
-
-static void efx_filter_table_clear_entry(struct efx_nic *efx,
-                                        struct efx_filter_table *table,
-                                        unsigned int filter_idx);
-
-/* The filter hash function is LFSR polynomial x^16 + x^3 + 1 of a 32-bit
- * key derived from the n-tuple.  The initial LFSR state is 0xffff. */
-static u16 efx_filter_hash(u32 key)
-{
-       u16 tmp;
-
-       /* First 16 rounds */
-       tmp = 0x1fff ^ key >> 16;
-       tmp = tmp ^ tmp >> 3 ^ tmp >> 6;
-       tmp = tmp ^ tmp >> 9;
-       /* Last 16 rounds */
-       tmp = tmp ^ tmp << 13 ^ key;
-       tmp = tmp ^ tmp >> 3 ^ tmp >> 6;
-       return tmp ^ tmp >> 9;
-}
-
-/* To allow for hash collisions, filter search continues at these
- * increments from the first possible entry selected by the hash. */
-static u16 efx_filter_increment(u32 key)
-{
-       return key * 2 - 1;
-}
-
-static enum efx_filter_table_id
-efx_filter_spec_table_id(const struct efx_filter_spec *spec)
-{
-       BUILD_BUG_ON(EFX_FILTER_TABLE_RX_IP != (EFX_FILTER_TCP_FULL >> 2));
-       BUILD_BUG_ON(EFX_FILTER_TABLE_RX_IP != (EFX_FILTER_TCP_WILD >> 2));
-       BUILD_BUG_ON(EFX_FILTER_TABLE_RX_IP != (EFX_FILTER_UDP_FULL >> 2));
-       BUILD_BUG_ON(EFX_FILTER_TABLE_RX_IP != (EFX_FILTER_UDP_WILD >> 2));
-       BUILD_BUG_ON(EFX_FILTER_TABLE_RX_MAC != (EFX_FILTER_MAC_FULL >> 2));
-       BUILD_BUG_ON(EFX_FILTER_TABLE_RX_MAC != (EFX_FILTER_MAC_WILD >> 2));
-       BUILD_BUG_ON(EFX_FILTER_TABLE_TX_MAC != EFX_FILTER_TABLE_RX_MAC + 2);
-       EFX_BUG_ON_PARANOID(spec->type == EFX_FILTER_UNSPEC);
-       return (spec->type >> 2) + ((spec->flags & EFX_FILTER_FLAG_TX) ? 2 : 0);
-}
-
-static struct efx_filter_table *
-efx_filter_spec_table(struct efx_filter_state *state,
-                     const struct efx_filter_spec *spec)
-{
-       if (spec->type == EFX_FILTER_UNSPEC)
-               return NULL;
-       else
-               return &state->table[efx_filter_spec_table_id(spec)];
-}
-
-static void efx_filter_table_reset_search_depth(struct efx_filter_table *table)
-{
-       memset(table->search_depth, 0, sizeof(table->search_depth));
-}
-
-static void efx_filter_push_rx_config(struct efx_nic *efx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_table *table;
-       efx_oword_t filter_ctl;
-
-       efx_reado(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL);
-
-       table = &state->table[EFX_FILTER_TABLE_RX_IP];
-       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_TCP_FULL_SRCH_LIMIT,
-                           table->search_depth[EFX_FILTER_TCP_FULL] +
-                           FILTER_CTL_SRCH_FUDGE_FULL);
-       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_TCP_WILD_SRCH_LIMIT,
-                           table->search_depth[EFX_FILTER_TCP_WILD] +
-                           FILTER_CTL_SRCH_FUDGE_WILD);
-       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_UDP_FULL_SRCH_LIMIT,
-                           table->search_depth[EFX_FILTER_UDP_FULL] +
-                           FILTER_CTL_SRCH_FUDGE_FULL);
-       EFX_SET_OWORD_FIELD(filter_ctl, FRF_BZ_UDP_WILD_SRCH_LIMIT,
-                           table->search_depth[EFX_FILTER_UDP_WILD] +
-                           FILTER_CTL_SRCH_FUDGE_WILD);
-
-       table = &state->table[EFX_FILTER_TABLE_RX_MAC];
-       if (table->size) {
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_CZ_ETHERNET_FULL_SEARCH_LIMIT,
-                       table->search_depth[EFX_FILTER_MAC_FULL] +
-                       FILTER_CTL_SRCH_FUDGE_FULL);
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_CZ_ETHERNET_WILDCARD_SEARCH_LIMIT,
-                       table->search_depth[EFX_FILTER_MAC_WILD] +
-                       FILTER_CTL_SRCH_FUDGE_WILD);
-       }
-
-       table = &state->table[EFX_FILTER_TABLE_RX_DEF];
-       if (table->size) {
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_CZ_UNICAST_NOMATCH_Q_ID,
-                       table->spec[EFX_FILTER_INDEX_UC_DEF].dmaq_id);
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED,
-                       !!(table->spec[EFX_FILTER_INDEX_UC_DEF].flags &
-                          EFX_FILTER_FLAG_RX_RSS));
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_CZ_MULTICAST_NOMATCH_Q_ID,
-                       table->spec[EFX_FILTER_INDEX_MC_DEF].dmaq_id);
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED,
-                       !!(table->spec[EFX_FILTER_INDEX_MC_DEF].flags &
-                          EFX_FILTER_FLAG_RX_RSS));
-
-               /* There is a single bit to enable RX scatter for all
-                * unmatched packets.  Only set it if scatter is
-                * enabled in both filter specs.
-                */
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_BZ_SCATTER_ENBL_NO_MATCH_Q,
-                       !!(table->spec[EFX_FILTER_INDEX_UC_DEF].flags &
-                          table->spec[EFX_FILTER_INDEX_MC_DEF].flags &
-                          EFX_FILTER_FLAG_RX_SCATTER));
-       } else if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
-               /* We don't expose 'default' filters because unmatched
-                * packets always go to the queue number found in the
-                * RSS table.  But we still need to set the RX scatter
-                * bit here.
-                */
-               EFX_SET_OWORD_FIELD(
-                       filter_ctl, FRF_BZ_SCATTER_ENBL_NO_MATCH_Q,
-                       efx->rx_scatter);
-       }
-
-       efx_writeo(efx, &filter_ctl, FR_BZ_RX_FILTER_CTL);
-}
-
-static void efx_filter_push_tx_limits(struct efx_nic *efx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_table *table;
-       efx_oword_t tx_cfg;
-
-       efx_reado(efx, &tx_cfg, FR_AZ_TX_CFG);
-
-       table = &state->table[EFX_FILTER_TABLE_TX_MAC];
-       if (table->size) {
-               EFX_SET_OWORD_FIELD(
-                       tx_cfg, FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE,
-                       table->search_depth[EFX_FILTER_MAC_FULL] +
-                       FILTER_CTL_SRCH_FUDGE_FULL);
-               EFX_SET_OWORD_FIELD(
-                       tx_cfg, FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE,
-                       table->search_depth[EFX_FILTER_MAC_WILD] +
-                       FILTER_CTL_SRCH_FUDGE_WILD);
-       }
-
-       efx_writeo(efx, &tx_cfg, FR_AZ_TX_CFG);
-}
-
-static inline void __efx_filter_set_ipv4(struct efx_filter_spec *spec,
-                                        __be32 host1, __be16 port1,
-                                        __be32 host2, __be16 port2)
-{
-       spec->data[0] = ntohl(host1) << 16 | ntohs(port1);
-       spec->data[1] = ntohs(port2) << 16 | ntohl(host1) >> 16;
-       spec->data[2] = ntohl(host2);
-}
-
-static inline void __efx_filter_get_ipv4(const struct efx_filter_spec *spec,
-                                        __be32 *host1, __be16 *port1,
-                                        __be32 *host2, __be16 *port2)
-{
-       *host1 = htonl(spec->data[0] >> 16 | spec->data[1] << 16);
-       *port1 = htons(spec->data[0]);
-       *host2 = htonl(spec->data[2]);
-       *port2 = htons(spec->data[1] >> 16);
-}
-
-/**
- * efx_filter_set_ipv4_local - specify IPv4 host, transport protocol and port
- * @spec: Specification to initialise
- * @proto: Transport layer protocol number
- * @host: Local host address (network byte order)
- * @port: Local port (network byte order)
- */
-int efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto,
-                             __be32 host, __be16 port)
-{
-       __be32 host1;
-       __be16 port1;
-
-       EFX_BUG_ON_PARANOID(!(spec->flags & EFX_FILTER_FLAG_RX));
-
-       /* This cannot currently be combined with other filtering */
-       if (spec->type != EFX_FILTER_UNSPEC)
-               return -EPROTONOSUPPORT;
-
-       if (port == 0)
-               return -EINVAL;
-
-       switch (proto) {
-       case IPPROTO_TCP:
-               spec->type = EFX_FILTER_TCP_WILD;
-               break;
-       case IPPROTO_UDP:
-               spec->type = EFX_FILTER_UDP_WILD;
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       /* Filter is constructed in terms of source and destination,
-        * with the odd wrinkle that the ports are swapped in a UDP
-        * wildcard filter.  We need to convert from local and remote
-        * (= zero for wildcard) addresses.
-        */
-       host1 = 0;
-       if (proto != IPPROTO_UDP) {
-               port1 = 0;
-       } else {
-               port1 = port;
-               port = 0;
-       }
-
-       __efx_filter_set_ipv4(spec, host1, port1, host, port);
-       return 0;
-}
-
-int efx_filter_get_ipv4_local(const struct efx_filter_spec *spec,
-                             u8 *proto, __be32 *host, __be16 *port)
-{
-       __be32 host1;
-       __be16 port1;
-
-       switch (spec->type) {
-       case EFX_FILTER_TCP_WILD:
-               *proto = IPPROTO_TCP;
-               __efx_filter_get_ipv4(spec, &host1, &port1, host, port);
-               return 0;
-       case EFX_FILTER_UDP_WILD:
-               *proto = IPPROTO_UDP;
-               __efx_filter_get_ipv4(spec, &host1, port, host, &port1);
-               return 0;
-       default:
-               return -EINVAL;
-       }
-}
-
-/**
- * efx_filter_set_ipv4_full - specify IPv4 hosts, transport protocol and ports
- * @spec: Specification to initialise
- * @proto: Transport layer protocol number
- * @host: Local host address (network byte order)
- * @port: Local port (network byte order)
- * @rhost: Remote host address (network byte order)
- * @rport: Remote port (network byte order)
- */
-int efx_filter_set_ipv4_full(struct efx_filter_spec *spec, u8 proto,
-                            __be32 host, __be16 port,
-                            __be32 rhost, __be16 rport)
-{
-       EFX_BUG_ON_PARANOID(!(spec->flags & EFX_FILTER_FLAG_RX));
-
-       /* This cannot currently be combined with other filtering */
-       if (spec->type != EFX_FILTER_UNSPEC)
-               return -EPROTONOSUPPORT;
-
-       if (port == 0 || rport == 0)
-               return -EINVAL;
-
-       switch (proto) {
-       case IPPROTO_TCP:
-               spec->type = EFX_FILTER_TCP_FULL;
-               break;
-       case IPPROTO_UDP:
-               spec->type = EFX_FILTER_UDP_FULL;
-               break;
-       default:
-               return -EPROTONOSUPPORT;
-       }
-
-       __efx_filter_set_ipv4(spec, rhost, rport, host, port);
-       return 0;
-}
-
-int efx_filter_get_ipv4_full(const struct efx_filter_spec *spec,
-                            u8 *proto, __be32 *host, __be16 *port,
-                            __be32 *rhost, __be16 *rport)
-{
-       switch (spec->type) {
-       case EFX_FILTER_TCP_FULL:
-               *proto = IPPROTO_TCP;
-               break;
-       case EFX_FILTER_UDP_FULL:
-               *proto = IPPROTO_UDP;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       __efx_filter_get_ipv4(spec, rhost, rport, host, port);
-       return 0;
-}
-
-/**
- * efx_filter_set_eth_local - specify local Ethernet address and optional VID
- * @spec: Specification to initialise
- * @vid: VLAN ID to match, or %EFX_FILTER_VID_UNSPEC
- * @addr: Local Ethernet MAC address
- */
-int efx_filter_set_eth_local(struct efx_filter_spec *spec,
-                            u16 vid, const u8 *addr)
-{
-       EFX_BUG_ON_PARANOID(!(spec->flags &
-                             (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX)));
-
-       /* This cannot currently be combined with other filtering */
-       if (spec->type != EFX_FILTER_UNSPEC)
-               return -EPROTONOSUPPORT;
-
-       if (vid == EFX_FILTER_VID_UNSPEC) {
-               spec->type = EFX_FILTER_MAC_WILD;
-               spec->data[0] = 0;
-       } else {
-               spec->type = EFX_FILTER_MAC_FULL;
-               spec->data[0] = vid;
-       }
-
-       spec->data[1] = addr[2] << 24 | addr[3] << 16 | addr[4] << 8 | addr[5];
-       spec->data[2] = addr[0] << 8 | addr[1];
-       return 0;
-}
-
-/**
- * efx_filter_set_uc_def - specify matching otherwise-unmatched unicast
- * @spec: Specification to initialise
- */
-int efx_filter_set_uc_def(struct efx_filter_spec *spec)
-{
-       EFX_BUG_ON_PARANOID(!(spec->flags &
-                             (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX)));
-
-       if (spec->type != EFX_FILTER_UNSPEC)
-               return -EINVAL;
-
-       spec->type = EFX_FILTER_UC_DEF;
-       memset(spec->data, 0, sizeof(spec->data)); /* ensure equality */
-       return 0;
-}
-
-/**
- * efx_filter_set_mc_def - specify matching otherwise-unmatched multicast
- * @spec: Specification to initialise
- */
-int efx_filter_set_mc_def(struct efx_filter_spec *spec)
-{
-       EFX_BUG_ON_PARANOID(!(spec->flags &
-                             (EFX_FILTER_FLAG_RX | EFX_FILTER_FLAG_TX)));
-
-       if (spec->type != EFX_FILTER_UNSPEC)
-               return -EINVAL;
-
-       spec->type = EFX_FILTER_MC_DEF;
-       memset(spec->data, 0, sizeof(spec->data)); /* ensure equality */
-       return 0;
-}
-
-static void efx_filter_reset_rx_def(struct efx_nic *efx, unsigned filter_idx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_table *table = &state->table[EFX_FILTER_TABLE_RX_DEF];
-       struct efx_filter_spec *spec = &table->spec[filter_idx];
-       enum efx_filter_flags flags = 0;
-
-       /* If there's only one channel then disable RSS for non VF
-        * traffic, thereby allowing VFs to use RSS when the PF can't.
-        */
-       if (efx->n_rx_channels > 1)
-               flags |= EFX_FILTER_FLAG_RX_RSS;
-
-       if (efx->rx_scatter)
-               flags |= EFX_FILTER_FLAG_RX_SCATTER;
-
-       efx_filter_init_rx(spec, EFX_FILTER_PRI_MANUAL, flags, 0);
-       spec->type = EFX_FILTER_UC_DEF + filter_idx;
-       table->used_bitmap[0] |= 1 << filter_idx;
-}
-
-int efx_filter_get_eth_local(const struct efx_filter_spec *spec,
-                            u16 *vid, u8 *addr)
-{
-       switch (spec->type) {
-       case EFX_FILTER_MAC_WILD:
-               *vid = EFX_FILTER_VID_UNSPEC;
-               break;
-       case EFX_FILTER_MAC_FULL:
-               *vid = spec->data[0];
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       addr[0] = spec->data[2] >> 8;
-       addr[1] = spec->data[2];
-       addr[2] = spec->data[1] >> 24;
-       addr[3] = spec->data[1] >> 16;
-       addr[4] = spec->data[1] >> 8;
-       addr[5] = spec->data[1];
-       return 0;
-}
-
-/* Build a filter entry and return its n-tuple key. */
-static u32 efx_filter_build(efx_oword_t *filter, struct efx_filter_spec *spec)
-{
-       u32 data3;
-
-       switch (efx_filter_spec_table_id(spec)) {
-       case EFX_FILTER_TABLE_RX_IP: {
-               bool is_udp = (spec->type == EFX_FILTER_UDP_FULL ||
-                              spec->type == EFX_FILTER_UDP_WILD);
-               EFX_POPULATE_OWORD_7(
-                       *filter,
-                       FRF_BZ_RSS_EN,
-                       !!(spec->flags & EFX_FILTER_FLAG_RX_RSS),
-                       FRF_BZ_SCATTER_EN,
-                       !!(spec->flags & EFX_FILTER_FLAG_RX_SCATTER),
-                       FRF_BZ_TCP_UDP, is_udp,
-                       FRF_BZ_RXQ_ID, spec->dmaq_id,
-                       EFX_DWORD_2, spec->data[2],
-                       EFX_DWORD_1, spec->data[1],
-                       EFX_DWORD_0, spec->data[0]);
-               data3 = is_udp;
-               break;
-       }
-
-       case EFX_FILTER_TABLE_RX_MAC: {
-               bool is_wild = spec->type == EFX_FILTER_MAC_WILD;
-               EFX_POPULATE_OWORD_7(
-                       *filter,
-                       FRF_CZ_RMFT_RSS_EN,
-                       !!(spec->flags & EFX_FILTER_FLAG_RX_RSS),
-                       FRF_CZ_RMFT_SCATTER_EN,
-                       !!(spec->flags & EFX_FILTER_FLAG_RX_SCATTER),
-                       FRF_CZ_RMFT_RXQ_ID, spec->dmaq_id,
-                       FRF_CZ_RMFT_WILDCARD_MATCH, is_wild,
-                       FRF_CZ_RMFT_DEST_MAC_HI, spec->data[2],
-                       FRF_CZ_RMFT_DEST_MAC_LO, spec->data[1],
-                       FRF_CZ_RMFT_VLAN_ID, spec->data[0]);
-               data3 = is_wild;
-               break;
-       }
-
-       case EFX_FILTER_TABLE_TX_MAC: {
-               bool is_wild = spec->type == EFX_FILTER_MAC_WILD;
-               EFX_POPULATE_OWORD_5(*filter,
-                                    FRF_CZ_TMFT_TXQ_ID, spec->dmaq_id,
-                                    FRF_CZ_TMFT_WILDCARD_MATCH, is_wild,
-                                    FRF_CZ_TMFT_SRC_MAC_HI, spec->data[2],
-                                    FRF_CZ_TMFT_SRC_MAC_LO, spec->data[1],
-                                    FRF_CZ_TMFT_VLAN_ID, spec->data[0]);
-               data3 = is_wild | spec->dmaq_id << 1;
-               break;
-       }
-
-       default:
-               BUG();
-       }
-
-       return spec->data[0] ^ spec->data[1] ^ spec->data[2] ^ data3;
-}
-
-static bool efx_filter_equal(const struct efx_filter_spec *left,
-                            const struct efx_filter_spec *right)
-{
-       if (left->type != right->type ||
-           memcmp(left->data, right->data, sizeof(left->data)))
-               return false;
-
-       if (left->flags & EFX_FILTER_FLAG_TX &&
-           left->dmaq_id != right->dmaq_id)
-               return false;
-
-       return true;
-}
-
-/*
- * Construct/deconstruct external filter IDs.  At least the RX filter
- * IDs must be ordered by matching priority, for RX NFC semantics.
- *
- * Deconstruction needs to be robust against invalid IDs so that
- * efx_filter_remove_id_safe() and efx_filter_get_filter_safe() can
- * accept user-provided IDs.
- */
-
-#define EFX_FILTER_MATCH_PRI_COUNT     5
-
-static const u8 efx_filter_type_match_pri[EFX_FILTER_TYPE_COUNT] = {
-       [EFX_FILTER_TCP_FULL]   = 0,
-       [EFX_FILTER_UDP_FULL]   = 0,
-       [EFX_FILTER_TCP_WILD]   = 1,
-       [EFX_FILTER_UDP_WILD]   = 1,
-       [EFX_FILTER_MAC_FULL]   = 2,
-       [EFX_FILTER_MAC_WILD]   = 3,
-       [EFX_FILTER_UC_DEF]     = 4,
-       [EFX_FILTER_MC_DEF]     = 4,
-};
-
-static const enum efx_filter_table_id efx_filter_range_table[] = {
-       EFX_FILTER_TABLE_RX_IP,         /* RX match pri 0 */
-       EFX_FILTER_TABLE_RX_IP,
-       EFX_FILTER_TABLE_RX_MAC,
-       EFX_FILTER_TABLE_RX_MAC,
-       EFX_FILTER_TABLE_RX_DEF,        /* RX match pri 4 */
-       EFX_FILTER_TABLE_COUNT,         /* TX match pri 0; invalid */
-       EFX_FILTER_TABLE_COUNT,         /* invalid */
-       EFX_FILTER_TABLE_TX_MAC,
-       EFX_FILTER_TABLE_TX_MAC,        /* TX match pri 3 */
-};
-
-#define EFX_FILTER_INDEX_WIDTH 13
-#define EFX_FILTER_INDEX_MASK  ((1 << EFX_FILTER_INDEX_WIDTH) - 1)
-
-static inline u32
-efx_filter_make_id(const struct efx_filter_spec *spec, unsigned int index)
-{
-       unsigned int range;
-
-       range = efx_filter_type_match_pri[spec->type];
-       if (!(spec->flags & EFX_FILTER_FLAG_RX))
-               range += EFX_FILTER_MATCH_PRI_COUNT;
-
-       return range << EFX_FILTER_INDEX_WIDTH | index;
-}
-
-static inline enum efx_filter_table_id efx_filter_id_table_id(u32 id)
-{
-       unsigned int range = id >> EFX_FILTER_INDEX_WIDTH;
-
-       if (range < ARRAY_SIZE(efx_filter_range_table))
-               return efx_filter_range_table[range];
-       else
-               return EFX_FILTER_TABLE_COUNT; /* invalid */
-}
-
-static inline unsigned int efx_filter_id_index(u32 id)
-{
-       return id & EFX_FILTER_INDEX_MASK;
-}
-
-static inline u8 efx_filter_id_flags(u32 id)
-{
-       unsigned int range = id >> EFX_FILTER_INDEX_WIDTH;
-
-       if (range < EFX_FILTER_MATCH_PRI_COUNT)
-               return EFX_FILTER_FLAG_RX;
-       else
-               return EFX_FILTER_FLAG_TX;
-}
-
-u32 efx_filter_get_rx_id_limit(struct efx_nic *efx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       unsigned int range = EFX_FILTER_MATCH_PRI_COUNT - 1;
-       enum efx_filter_table_id table_id;
-
-       do {
-               table_id = efx_filter_range_table[range];
-               if (state->table[table_id].size != 0)
-                       return range << EFX_FILTER_INDEX_WIDTH |
-                               state->table[table_id].size;
-       } while (range--);
-
-       return 0;
-}
-
-/**
- * efx_filter_insert_filter - add or replace a filter
- * @efx: NIC in which to insert the filter
- * @spec: Specification for the filter
- * @replace_equal: Flag for whether the specified filter may replace an
- *     existing filter with equal priority
- *
- * On success, return the filter ID.
- * On failure, return a negative error code.
- *
- * If an existing filter has equal match values to the new filter
- * spec, then the new filter might replace it, depending on the
- * relative priorities.  If the existing filter has lower priority, or
- * if @replace_equal is set and it has equal priority, then it is
- * replaced.  Otherwise the function fails, returning -%EPERM if
- * the existing filter has higher priority or -%EEXIST if it has
- * equal priority.
- */
-s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec,
-                            bool replace_equal)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_table *table = efx_filter_spec_table(state, spec);
-       efx_oword_t filter;
-       int rep_index, ins_index;
-       unsigned int depth = 0;
-       int rc;
-
-       if (!table || table->size == 0)
-               return -EINVAL;
-
-       netif_vdbg(efx, hw, efx->net_dev,
-                  "%s: type %d search_depth=%d", __func__, spec->type,
-                  table->search_depth[spec->type]);
-
-       if (table->id == EFX_FILTER_TABLE_RX_DEF) {
-               /* One filter spec per type */
-               BUILD_BUG_ON(EFX_FILTER_INDEX_UC_DEF != 0);
-               BUILD_BUG_ON(EFX_FILTER_INDEX_MC_DEF !=
-                            EFX_FILTER_MC_DEF - EFX_FILTER_UC_DEF);
-               rep_index = spec->type - EFX_FILTER_INDEX_UC_DEF;
-               ins_index = rep_index;
-
-               spin_lock_bh(&state->lock);
-       } else {
-               /* Search concurrently for
-                * (1) a filter to be replaced (rep_index): any filter
-                *     with the same match values, up to the current
-                *     search depth for this type, and
-                * (2) the insertion point (ins_index): (1) or any
-                *     free slot before it or up to the maximum search
-                *     depth for this priority
-                * We fail if we cannot find (2).
-                *
-                * We can stop once either
-                * (a) we find (1), in which case we have definitely
-                *     found (2) as well; or
-                * (b) we have searched exhaustively for (1), and have
-                *     either found (2) or searched exhaustively for it
-                */
-               u32 key = efx_filter_build(&filter, spec);
-               unsigned int hash = efx_filter_hash(key);
-               unsigned int incr = efx_filter_increment(key);
-               unsigned int max_rep_depth = table->search_depth[spec->type];
-               unsigned int max_ins_depth =
-                       spec->priority <= EFX_FILTER_PRI_HINT ?
-                       FILTER_CTL_SRCH_HINT_MAX : FILTER_CTL_SRCH_MAX;
-               unsigned int i = hash & (table->size - 1);
-
-               ins_index = -1;
-               depth = 1;
-
-               spin_lock_bh(&state->lock);
-
-               for (;;) {
-                       if (!test_bit(i, table->used_bitmap)) {
-                               if (ins_index < 0)
-                                       ins_index = i;
-                       } else if (efx_filter_equal(spec, &table->spec[i])) {
-                               /* Case (a) */
-                               if (ins_index < 0)
-                                       ins_index = i;
-                               rep_index = i;
-                               break;
-                       }
-
-                       if (depth >= max_rep_depth &&
-                           (ins_index >= 0 || depth >= max_ins_depth)) {
-                               /* Case (b) */
-                               if (ins_index < 0) {
-                                       rc = -EBUSY;
-                                       goto out;
-                               }
-                               rep_index = -1;
-                               break;
-                       }
-
-                       i = (i + incr) & (table->size - 1);
-                       ++depth;
-               }
-       }
-
-       /* If we found a filter to be replaced, check whether we
-        * should do so
-        */
-       if (rep_index >= 0) {
-               struct efx_filter_spec *saved_spec = &table->spec[rep_index];
-
-               if (spec->priority == saved_spec->priority && !replace_equal) {
-                       rc = -EEXIST;
-                       goto out;
-               }
-               if (spec->priority < saved_spec->priority) {
-                       rc = -EPERM;
-                       goto out;
-               }
-       }
-
-       /* Insert the filter */
-       if (ins_index != rep_index) {
-               __set_bit(ins_index, table->used_bitmap);
-               ++table->used;
-       }
-       table->spec[ins_index] = *spec;
-
-       if (table->id == EFX_FILTER_TABLE_RX_DEF) {
-               efx_filter_push_rx_config(efx);
-       } else {
-               if (table->search_depth[spec->type] < depth) {
-                       table->search_depth[spec->type] = depth;
-                       if (spec->flags & EFX_FILTER_FLAG_TX)
-                               efx_filter_push_tx_limits(efx);
-                       else
-                               efx_filter_push_rx_config(efx);
-               }
-
-               efx_writeo(efx, &filter,
-                          table->offset + table->step * ins_index);
-
-               /* If we were able to replace a filter by inserting
-                * at a lower depth, clear the replaced filter
-                */
-               if (ins_index != rep_index && rep_index >= 0)
-                       efx_filter_table_clear_entry(efx, table, rep_index);
-       }
-
-       netif_vdbg(efx, hw, efx->net_dev,
-                  "%s: filter type %d index %d rxq %u set",
-                  __func__, spec->type, ins_index, spec->dmaq_id);
-       rc = efx_filter_make_id(spec, ins_index);
-
-out:
-       spin_unlock_bh(&state->lock);
-       return rc;
-}
-
-static void efx_filter_table_clear_entry(struct efx_nic *efx,
-                                        struct efx_filter_table *table,
-                                        unsigned int filter_idx)
-{
-       static efx_oword_t filter;
-
-       if (table->id == EFX_FILTER_TABLE_RX_DEF) {
-               /* RX default filters must always exist */
-               efx_filter_reset_rx_def(efx, filter_idx);
-               efx_filter_push_rx_config(efx);
-       } else if (test_bit(filter_idx, table->used_bitmap)) {
-               __clear_bit(filter_idx, table->used_bitmap);
-               --table->used;
-               memset(&table->spec[filter_idx], 0, sizeof(table->spec[0]));
-
-               efx_writeo(efx, &filter,
-                          table->offset + table->step * filter_idx);
-       }
-}
-
-/**
- * efx_filter_remove_id_safe - remove a filter by ID, carefully
- * @efx: NIC from which to remove the filter
- * @priority: Priority of filter, as passed to @efx_filter_insert_filter
- * @filter_id: ID of filter, as returned by @efx_filter_insert_filter
- *
- * This function will range-check @filter_id, so it is safe to call
- * with a value passed from userland.
- */
-int efx_filter_remove_id_safe(struct efx_nic *efx,
-                             enum efx_filter_priority priority,
-                             u32 filter_id)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-       struct efx_filter_table *table;
-       unsigned int filter_idx;
-       struct efx_filter_spec *spec;
-       u8 filter_flags;
-       int rc;
-
-       table_id = efx_filter_id_table_id(filter_id);
-       if ((unsigned int)table_id >= EFX_FILTER_TABLE_COUNT)
-               return -ENOENT;
-       table = &state->table[table_id];
-
-       filter_idx = efx_filter_id_index(filter_id);
-       if (filter_idx >= table->size)
-               return -ENOENT;
-       spec = &table->spec[filter_idx];
-
-       filter_flags = efx_filter_id_flags(filter_id);
-
-       spin_lock_bh(&state->lock);
-
-       if (test_bit(filter_idx, table->used_bitmap) &&
-           spec->priority == priority) {
-               efx_filter_table_clear_entry(efx, table, filter_idx);
-               if (table->used == 0)
-                       efx_filter_table_reset_search_depth(table);
-               rc = 0;
-       } else {
-               rc = -ENOENT;
-       }
-
-       spin_unlock_bh(&state->lock);
-
-       return rc;
-}
-
-/**
- * efx_filter_get_filter_safe - retrieve a filter by ID, carefully
- * @efx: NIC from which to remove the filter
- * @priority: Priority of filter, as passed to @efx_filter_insert_filter
- * @filter_id: ID of filter, as returned by @efx_filter_insert_filter
- * @spec: Buffer in which to store filter specification
- *
- * This function will range-check @filter_id, so it is safe to call
- * with a value passed from userland.
- */
-int efx_filter_get_filter_safe(struct efx_nic *efx,
-                              enum efx_filter_priority priority,
-                              u32 filter_id, struct efx_filter_spec *spec_buf)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-       struct efx_filter_table *table;
-       struct efx_filter_spec *spec;
-       unsigned int filter_idx;
-       u8 filter_flags;
-       int rc;
-
-       table_id = efx_filter_id_table_id(filter_id);
-       if ((unsigned int)table_id >= EFX_FILTER_TABLE_COUNT)
-               return -ENOENT;
-       table = &state->table[table_id];
-
-       filter_idx = efx_filter_id_index(filter_id);
-       if (filter_idx >= table->size)
-               return -ENOENT;
-       spec = &table->spec[filter_idx];
-
-       filter_flags = efx_filter_id_flags(filter_id);
-
-       spin_lock_bh(&state->lock);
-
-       if (test_bit(filter_idx, table->used_bitmap) &&
-           spec->priority == priority) {
-               *spec_buf = *spec;
-               rc = 0;
-       } else {
-               rc = -ENOENT;
-       }
-
-       spin_unlock_bh(&state->lock);
-
-       return rc;
-}
-
-static void efx_filter_table_clear(struct efx_nic *efx,
-                                  enum efx_filter_table_id table_id,
-                                  enum efx_filter_priority priority)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_table *table = &state->table[table_id];
-       unsigned int filter_idx;
-
-       spin_lock_bh(&state->lock);
-
-       for (filter_idx = 0; filter_idx < table->size; ++filter_idx)
-               if (table->spec[filter_idx].priority <= priority)
-                       efx_filter_table_clear_entry(efx, table, filter_idx);
-       if (table->used == 0)
-               efx_filter_table_reset_search_depth(table);
-
-       spin_unlock_bh(&state->lock);
-}
-
-/**
- * efx_filter_clear_rx - remove RX filters by priority
- * @efx: NIC from which to remove the filters
- * @priority: Maximum priority to remove
- */
-void efx_filter_clear_rx(struct efx_nic *efx, enum efx_filter_priority priority)
-{
-       efx_filter_table_clear(efx, EFX_FILTER_TABLE_RX_IP, priority);
-       efx_filter_table_clear(efx, EFX_FILTER_TABLE_RX_MAC, priority);
-}
-
-u32 efx_filter_count_rx_used(struct efx_nic *efx,
-                            enum efx_filter_priority priority)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-       struct efx_filter_table *table;
-       unsigned int filter_idx;
-       u32 count = 0;
-
-       spin_lock_bh(&state->lock);
-
-       for (table_id = EFX_FILTER_TABLE_RX_IP;
-            table_id <= EFX_FILTER_TABLE_RX_DEF;
-            table_id++) {
-               table = &state->table[table_id];
-               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
-                       if (test_bit(filter_idx, table->used_bitmap) &&
-                           table->spec[filter_idx].priority == priority)
-                               ++count;
-               }
-       }
-
-       spin_unlock_bh(&state->lock);
-
-       return count;
-}
-
-s32 efx_filter_get_rx_ids(struct efx_nic *efx,
-                         enum efx_filter_priority priority,
-                         u32 *buf, u32 size)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-       struct efx_filter_table *table;
-       unsigned int filter_idx;
-       s32 count = 0;
-
-       spin_lock_bh(&state->lock);
-
-       for (table_id = EFX_FILTER_TABLE_RX_IP;
-            table_id <= EFX_FILTER_TABLE_RX_DEF;
-            table_id++) {
-               table = &state->table[table_id];
-               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
-                       if (test_bit(filter_idx, table->used_bitmap) &&
-                           table->spec[filter_idx].priority == priority) {
-                               if (count == size) {
-                                       count = -EMSGSIZE;
-                                       goto out;
-                               }
-                               buf[count++] = efx_filter_make_id(
-                                       &table->spec[filter_idx], filter_idx);
-                       }
-               }
-       }
-out:
-       spin_unlock_bh(&state->lock);
-
-       return count;
-}
-
-/* Restore filter stater after reset */
-void efx_restore_filters(struct efx_nic *efx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-       struct efx_filter_table *table;
-       efx_oword_t filter;
-       unsigned int filter_idx;
-
-       spin_lock_bh(&state->lock);
-
-       for (table_id = 0; table_id < EFX_FILTER_TABLE_COUNT; table_id++) {
-               table = &state->table[table_id];
-
-               /* Check whether this is a regular register table */
-               if (table->step == 0)
-                       continue;
-
-               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
-                       if (!test_bit(filter_idx, table->used_bitmap))
-                               continue;
-                       efx_filter_build(&filter, &table->spec[filter_idx]);
-                       efx_writeo(efx, &filter,
-                                  table->offset + table->step * filter_idx);
-               }
-       }
-
-       efx_filter_push_rx_config(efx);
-       efx_filter_push_tx_limits(efx);
-
-       spin_unlock_bh(&state->lock);
-}
-
-int efx_probe_filters(struct efx_nic *efx)
-{
-       struct efx_filter_state *state;
-       struct efx_filter_table *table;
-       unsigned table_id;
-
-       state = kzalloc(sizeof(*efx->filter_state), GFP_KERNEL);
-       if (!state)
-               return -ENOMEM;
-       efx->filter_state = state;
-
-       spin_lock_init(&state->lock);
-
-       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
-#ifdef CONFIG_RFS_ACCEL
-               state->rps_flow_id = kcalloc(FR_BZ_RX_FILTER_TBL0_ROWS,
-                                            sizeof(*state->rps_flow_id),
-                                            GFP_KERNEL);
-               if (!state->rps_flow_id)
-                       goto fail;
-#endif
-               table = &state->table[EFX_FILTER_TABLE_RX_IP];
-               table->id = EFX_FILTER_TABLE_RX_IP;
-               table->offset = FR_BZ_RX_FILTER_TBL0;
-               table->size = FR_BZ_RX_FILTER_TBL0_ROWS;
-               table->step = FR_BZ_RX_FILTER_TBL0_STEP;
-       }
-
-       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) {
-               table = &state->table[EFX_FILTER_TABLE_RX_MAC];
-               table->id = EFX_FILTER_TABLE_RX_MAC;
-               table->offset = FR_CZ_RX_MAC_FILTER_TBL0;
-               table->size = FR_CZ_RX_MAC_FILTER_TBL0_ROWS;
-               table->step = FR_CZ_RX_MAC_FILTER_TBL0_STEP;
-
-               table = &state->table[EFX_FILTER_TABLE_RX_DEF];
-               table->id = EFX_FILTER_TABLE_RX_DEF;
-               table->size = EFX_FILTER_SIZE_RX_DEF;
-
-               table = &state->table[EFX_FILTER_TABLE_TX_MAC];
-               table->id = EFX_FILTER_TABLE_TX_MAC;
-               table->offset = FR_CZ_TX_MAC_FILTER_TBL0;
-               table->size = FR_CZ_TX_MAC_FILTER_TBL0_ROWS;
-               table->step = FR_CZ_TX_MAC_FILTER_TBL0_STEP;
-       }
-
-       for (table_id = 0; table_id < EFX_FILTER_TABLE_COUNT; table_id++) {
-               table = &state->table[table_id];
-               if (table->size == 0)
-                       continue;
-               table->used_bitmap = kcalloc(BITS_TO_LONGS(table->size),
-                                            sizeof(unsigned long),
-                                            GFP_KERNEL);
-               if (!table->used_bitmap)
-                       goto fail;
-               table->spec = vzalloc(table->size * sizeof(*table->spec));
-               if (!table->spec)
-                       goto fail;
-       }
-
-       if (state->table[EFX_FILTER_TABLE_RX_DEF].size) {
-               /* RX default filters must always exist */
-               unsigned i;
-               for (i = 0; i < EFX_FILTER_SIZE_RX_DEF; i++)
-                       efx_filter_reset_rx_def(efx, i);
-       }
-
-       efx_filter_push_rx_config(efx);
-
-       return 0;
-
-fail:
-       efx_remove_filters(efx);
-       return -ENOMEM;
-}
-
-void efx_remove_filters(struct efx_nic *efx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-
-       for (table_id = 0; table_id < EFX_FILTER_TABLE_COUNT; table_id++) {
-               kfree(state->table[table_id].used_bitmap);
-               vfree(state->table[table_id].spec);
-       }
-#ifdef CONFIG_RFS_ACCEL
-       kfree(state->rps_flow_id);
-#endif
-       kfree(state);
-}
-
-/* Update scatter enable flags for filters pointing to our own RX queues */
-void efx_filter_update_rx_scatter(struct efx_nic *efx)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       enum efx_filter_table_id table_id;
-       struct efx_filter_table *table;
-       efx_oword_t filter;
-       unsigned int filter_idx;
-
-       spin_lock_bh(&state->lock);
-
-       for (table_id = EFX_FILTER_TABLE_RX_IP;
-            table_id <= EFX_FILTER_TABLE_RX_DEF;
-            table_id++) {
-               table = &state->table[table_id];
-
-               for (filter_idx = 0; filter_idx < table->size; filter_idx++) {
-                       if (!test_bit(filter_idx, table->used_bitmap) ||
-                           table->spec[filter_idx].dmaq_id >=
-                           efx->n_rx_channels)
-                               continue;
-
-                       if (efx->rx_scatter)
-                               table->spec[filter_idx].flags |=
-                                       EFX_FILTER_FLAG_RX_SCATTER;
-                       else
-                               table->spec[filter_idx].flags &=
-                                       ~EFX_FILTER_FLAG_RX_SCATTER;
-
-                       if (table_id == EFX_FILTER_TABLE_RX_DEF)
-                               /* Pushed by efx_filter_push_rx_config() */
-                               continue;
-
-                       efx_filter_build(&filter, &table->spec[filter_idx]);
-                       efx_writeo(efx, &filter,
-                                  table->offset + table->step * filter_idx);
-               }
-       }
-
-       efx_filter_push_rx_config(efx);
-
-       spin_unlock_bh(&state->lock);
-}
-
-#ifdef CONFIG_RFS_ACCEL
-
-int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
-                  u16 rxq_index, u32 flow_id)
-{
-       struct efx_nic *efx = netdev_priv(net_dev);
-       struct efx_channel *channel;
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_spec spec;
-       const struct iphdr *ip;
-       const __be16 *ports;
-       int nhoff;
-       int rc;
-
-       nhoff = skb_network_offset(skb);
-
-       if (skb->protocol == htons(ETH_P_8021Q)) {
-               EFX_BUG_ON_PARANOID(skb_headlen(skb) <
-                                   nhoff + sizeof(struct vlan_hdr));
-               if (((const struct vlan_hdr *)skb->data + nhoff)->
-                   h_vlan_encapsulated_proto != htons(ETH_P_IP))
-                       return -EPROTONOSUPPORT;
-
-               /* This is IP over 802.1q VLAN.  We can't filter on the
-                * IP 5-tuple and the vlan together, so just strip the
-                * vlan header and filter on the IP part.
-                */
-               nhoff += sizeof(struct vlan_hdr);
-       } else if (skb->protocol != htons(ETH_P_IP)) {
-               return -EPROTONOSUPPORT;
-       }
-
-       /* RFS must validate the IP header length before calling us */
-       EFX_BUG_ON_PARANOID(skb_headlen(skb) < nhoff + sizeof(*ip));
-       ip = (const struct iphdr *)(skb->data + nhoff);
-       if (ip_is_fragment(ip))
-               return -EPROTONOSUPPORT;
-       EFX_BUG_ON_PARANOID(skb_headlen(skb) < nhoff + 4 * ip->ihl + 4);
-       ports = (const __be16 *)(skb->data + nhoff + 4 * ip->ihl);
-
-       efx_filter_init_rx(&spec, EFX_FILTER_PRI_HINT, 0, rxq_index);
-       rc = efx_filter_set_ipv4_full(&spec, ip->protocol,
-                                     ip->daddr, ports[1], ip->saddr, ports[0]);
-       if (rc)
-               return rc;
-
-       rc = efx_filter_insert_filter(efx, &spec, true);
-       if (rc < 0)
-               return rc;
-
-       /* Remember this so we can check whether to expire the filter later */
-       state->rps_flow_id[rc] = flow_id;
-       channel = efx_get_channel(efx, skb_get_rx_queue(skb));
-       ++channel->rfs_filters_added;
-
-       netif_info(efx, rx_status, efx->net_dev,
-                  "steering %s %pI4:%u:%pI4:%u to queue %u [flow %u filter %d]\n",
-                  (ip->protocol == IPPROTO_TCP) ? "TCP" : "UDP",
-                  &ip->saddr, ntohs(ports[0]), &ip->daddr, ntohs(ports[1]),
-                  rxq_index, flow_id, rc);
-
-       return rc;
-}
-
-bool __efx_filter_rfs_expire(struct efx_nic *efx, unsigned quota)
-{
-       struct efx_filter_state *state = efx->filter_state;
-       struct efx_filter_table *table = &state->table[EFX_FILTER_TABLE_RX_IP];
-       unsigned mask = table->size - 1;
-       unsigned index;
-       unsigned stop;
-
-       if (!spin_trylock_bh(&state->lock))
-               return false;
-
-       index = state->rps_expire_index;
-       stop = (index + quota) & mask;
-
-       while (index != stop) {
-               if (test_bit(index, table->used_bitmap) &&
-                   table->spec[index].priority == EFX_FILTER_PRI_HINT &&
-                   rps_may_expire_flow(efx->net_dev,
-                                       table->spec[index].dmaq_id,
-                                       state->rps_flow_id[index], index)) {
-                       netif_info(efx, rx_status, efx->net_dev,
-                                  "expiring filter %d [flow %u]\n",
-                                  index, state->rps_flow_id[index]);
-                       efx_filter_table_clear_entry(efx, table, index);
-               }
-               index = (index + 1) & mask;
-       }
-
-       state->rps_expire_index = stop;
-       if (table->used == 0)
-               efx_filter_table_reset_search_depth(table);
-
-       spin_unlock_bh(&state->lock);
-       return true;
-}
-
-#endif /* CONFIG_RFS_ACCEL */
index 5cb54723b8244bf5b4c8b21e8c655f8e9f9b0916..e459e43a279898e923788c568373ac84d9af987a 100644 (file)
 #define EFX_FILTER_H
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
+#include <asm/byteorder.h>
 
 /**
- * enum efx_filter_type - type of hardware filter
- * @EFX_FILTER_TCP_FULL: Matching TCP/IPv4 4-tuple
- * @EFX_FILTER_TCP_WILD: Matching TCP/IPv4 destination (host, port)
- * @EFX_FILTER_UDP_FULL: Matching UDP/IPv4 4-tuple
- * @EFX_FILTER_UDP_WILD: Matching UDP/IPv4 destination (host, port)
- * @EFX_FILTER_MAC_FULL: Matching Ethernet destination MAC address, VID
- * @EFX_FILTER_MAC_WILD: Matching Ethernet destination MAC address
- * @EFX_FILTER_UC_DEF: Matching all otherwise unmatched unicast
- * @EFX_FILTER_MC_DEF: Matching all otherwise unmatched multicast
- * @EFX_FILTER_UNSPEC: Match type is unspecified
+ * enum efx_filter_match_flags - Flags for hardware filter match type
+ * @EFX_FILTER_MATCH_REM_HOST: Match by remote IP host address
+ * @EFX_FILTER_MATCH_LOC_HOST: Match by local IP host address
+ * @EFX_FILTER_MATCH_REM_MAC: Match by remote MAC address
+ * @EFX_FILTER_MATCH_REM_PORT: Match by remote TCP/UDP port
+ * @EFX_FILTER_MATCH_LOC_MAC: Match by local MAC address
+ * @EFX_FILTER_MATCH_LOC_PORT: Match by local TCP/UDP port
+ * @EFX_FILTER_MATCH_ETHER_TYPE: Match by Ether-type
+ * @EFX_FILTER_MATCH_INNER_VID: Match by inner VLAN ID
+ * @EFX_FILTER_MATCH_OUTER_VID: Match by outer VLAN ID
+ * @EFX_FILTER_MATCH_IP_PROTO: Match by IP transport protocol
+ * @EFX_FILTER_MATCH_LOC_MAC_IG: Match by local MAC address I/G bit.
+ *     Used for RX default unicast and multicast/broadcast filters.
  *
- * Falcon NICs only support the TCP/IPv4 and UDP/IPv4 filter types.
+ * Only some combinations are supported, depending on NIC type:
+ *
+ * - Falcon supports RX filters matching by {TCP,UDP}/IPv4 4-tuple or
+ *   local 2-tuple (only implemented for Falcon B0)
+ *
+ * - Siena supports RX and TX filters matching by {TCP,UDP}/IPv4 4-tuple
+ *   or local 2-tuple, or local MAC with or without outer VID, and RX
+ *   default filters
+ *
+ * - Huntington supports filter matching controlled by firmware, potentially
+ *   using {TCP,UDP}/IPv{4,6} 4-tuple or local 2-tuple, local MAC or I/G bit,
+ *   with or without outer and inner VID
  */
-enum efx_filter_type {
-       EFX_FILTER_TCP_FULL = 0,
-       EFX_FILTER_TCP_WILD,
-       EFX_FILTER_UDP_FULL,
-       EFX_FILTER_UDP_WILD,
-       EFX_FILTER_MAC_FULL = 4,
-       EFX_FILTER_MAC_WILD,
-       EFX_FILTER_UC_DEF = 8,
-       EFX_FILTER_MC_DEF,
-       EFX_FILTER_TYPE_COUNT,          /* number of specific types */
-       EFX_FILTER_UNSPEC = 0xf,
+enum efx_filter_match_flags {
+       EFX_FILTER_MATCH_REM_HOST =     0x0001,
+       EFX_FILTER_MATCH_LOC_HOST =     0x0002,
+       EFX_FILTER_MATCH_REM_MAC =      0x0004,
+       EFX_FILTER_MATCH_REM_PORT =     0x0008,
+       EFX_FILTER_MATCH_LOC_MAC =      0x0010,
+       EFX_FILTER_MATCH_LOC_PORT =     0x0020,
+       EFX_FILTER_MATCH_ETHER_TYPE =   0x0040,
+       EFX_FILTER_MATCH_INNER_VID =    0x0080,
+       EFX_FILTER_MATCH_OUTER_VID =    0x0100,
+       EFX_FILTER_MATCH_IP_PROTO =     0x0200,
+       EFX_FILTER_MATCH_LOC_MAC_IG =   0x0400,
 };
 
 /**
@@ -61,37 +78,75 @@ enum efx_filter_priority {
  *     according to the indirection table.
  * @EFX_FILTER_FLAG_RX_SCATTER: Enable DMA scatter on the receiving
  *     queue.
+ * @EFX_FILTER_FLAG_RX_STACK: Indicates a filter inserted for the
+ *     network stack.  The filter must have a priority of
+ *     %EFX_FILTER_PRI_REQUIRED.  It can be steered by a replacement
+ *     request with priority %EFX_FILTER_PRI_MANUAL, and a removal
+ *     request with priority %EFX_FILTER_PRI_MANUAL will reset the
+ *     steering (but not remove the filter).
  * @EFX_FILTER_FLAG_RX: Filter is for RX
  * @EFX_FILTER_FLAG_TX: Filter is for TX
  */
 enum efx_filter_flags {
        EFX_FILTER_FLAG_RX_RSS = 0x01,
        EFX_FILTER_FLAG_RX_SCATTER = 0x02,
+       EFX_FILTER_FLAG_RX_STACK = 0x04,
        EFX_FILTER_FLAG_RX = 0x08,
        EFX_FILTER_FLAG_TX = 0x10,
 };
 
 /**
  * struct efx_filter_spec - specification for a hardware filter
- * @type: Type of match to be performed, from &enum efx_filter_type
+ * @match_flags: Match type flags, from &enum efx_filter_match_flags
  * @priority: Priority of the filter, from &enum efx_filter_priority
  * @flags: Miscellaneous flags, from &enum efx_filter_flags
- * @dmaq_id: Source/target queue index
- * @data: Match data (type-dependent)
+ * @rss_context: RSS context to use, if %EFX_FILTER_FLAG_RX_RSS is set
+ * @dmaq_id: Source/target queue index, or %EFX_FILTER_RX_DMAQ_ID_DROP for
+ *     an RX drop filter
+ * @outer_vid: Outer VLAN ID to match, if %EFX_FILTER_MATCH_OUTER_VID is set
+ * @inner_vid: Inner VLAN ID to match, if %EFX_FILTER_MATCH_INNER_VID is set
+ * @loc_mac: Local MAC address to match, if %EFX_FILTER_MATCH_LOC_MAC or
+ *     %EFX_FILTER_MATCH_LOC_MAC_IG is set
+ * @rem_mac: Remote MAC address to match, if %EFX_FILTER_MATCH_REM_MAC is set
+ * @ether_type: Ether-type to match, if %EFX_FILTER_MATCH_ETHER_TYPE is set
+ * @ip_proto: IP transport protocol to match, if %EFX_FILTER_MATCH_IP_PROTO
+ *     is set
+ * @loc_host: Local IP host to match, if %EFX_FILTER_MATCH_LOC_HOST is set
+ * @rem_host: Remote IP host to match, if %EFX_FILTER_MATCH_REM_HOST is set
+ * @loc_port: Local TCP/UDP port to match, if %EFX_FILTER_MATCH_LOC_PORT is set
+ * @rem_port: Remote TCP/UDP port to match, if %EFX_FILTER_MATCH_REM_PORT is set
  *
- * Use the efx_filter_set_*() functions to initialise the @type and
- * @data fields.
+ * The efx_filter_init_rx() or efx_filter_init_tx() function *must* be
+ * used to initialise the structure.  The efx_filter_set_*() functions
+ * may then be used to set @rss_context, @match_flags and related
+ * fields.
  *
  * The @priority field is used by software to determine whether a new
  * filter may replace an old one.  The hardware priority of a filter
- * depends on the filter type.
+ * depends on which fields are matched.
  */
 struct efx_filter_spec {
-       u8      type:4;
-       u8      priority:4;
-       u8      flags;
-       u16     dmaq_id;
-       u32     data[3];
+       u32     match_flags:12;
+       u32     priority:2;
+       u32     flags:6;
+       u32     dmaq_id:12;
+       u32     rss_context;
+       __be16  outer_vid __aligned(4); /* allow jhash2() of match values */
+       __be16  inner_vid;
+       u8      loc_mac[ETH_ALEN];
+       u8      rem_mac[ETH_ALEN];
+       __be16  ether_type;
+       u8      ip_proto;
+       __be32  loc_host[4];
+       __be32  rem_host[4];
+       __be16  loc_port;
+       __be16  rem_port;
+       /* total 64 bytes */
+};
+
+enum {
+       EFX_FILTER_RSS_CONTEXT_DEFAULT = 0xffffffff,
+       EFX_FILTER_RX_DMAQ_ID_DROP = 0xfff
 };
 
 static inline void efx_filter_init_rx(struct efx_filter_spec *spec,
@@ -99,39 +154,116 @@ static inline void efx_filter_init_rx(struct efx_filter_spec *spec,
                                      enum efx_filter_flags flags,
                                      unsigned rxq_id)
 {
-       spec->type = EFX_FILTER_UNSPEC;
+       memset(spec, 0, sizeof(*spec));
        spec->priority = priority;
        spec->flags = EFX_FILTER_FLAG_RX | flags;
+       spec->rss_context = EFX_FILTER_RSS_CONTEXT_DEFAULT;
        spec->dmaq_id = rxq_id;
 }
 
 static inline void efx_filter_init_tx(struct efx_filter_spec *spec,
                                      unsigned txq_id)
 {
-       spec->type = EFX_FILTER_UNSPEC;
+       memset(spec, 0, sizeof(*spec));
        spec->priority = EFX_FILTER_PRI_REQUIRED;
        spec->flags = EFX_FILTER_FLAG_TX;
        spec->dmaq_id = txq_id;
 }
 
-extern int efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto,
-                                    __be32 host, __be16 port);
-extern int efx_filter_get_ipv4_local(const struct efx_filter_spec *spec,
-                                    u8 *proto, __be32 *host, __be16 *port);
-extern int efx_filter_set_ipv4_full(struct efx_filter_spec *spec, u8 proto,
-                                   __be32 host, __be16 port,
-                                   __be32 rhost, __be16 rport);
-extern int efx_filter_get_ipv4_full(const struct efx_filter_spec *spec,
-                                   u8 *proto, __be32 *host, __be16 *port,
-                                   __be32 *rhost, __be16 *rport);
-extern int efx_filter_set_eth_local(struct efx_filter_spec *spec,
-                                   u16 vid, const u8 *addr);
-extern int efx_filter_get_eth_local(const struct efx_filter_spec *spec,
-                                   u16 *vid, u8 *addr);
-extern int efx_filter_set_uc_def(struct efx_filter_spec *spec);
-extern int efx_filter_set_mc_def(struct efx_filter_spec *spec);
+/**
+ * efx_filter_set_ipv4_local - specify IPv4 host, transport protocol and port
+ * @spec: Specification to initialise
+ * @proto: Transport layer protocol number
+ * @host: Local host address (network byte order)
+ * @port: Local port (network byte order)
+ */
+static inline int
+efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto,
+                         __be32 host, __be16 port)
+{
+       spec->match_flags |=
+               EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
+               EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT;
+       spec->ether_type = htons(ETH_P_IP);
+       spec->ip_proto = proto;
+       spec->loc_host[0] = host;
+       spec->loc_port = port;
+       return 0;
+}
+
+/**
+ * efx_filter_set_ipv4_full - specify IPv4 hosts, transport protocol and ports
+ * @spec: Specification to initialise
+ * @proto: Transport layer protocol number
+ * @lhost: Local host address (network byte order)
+ * @lport: Local port (network byte order)
+ * @rhost: Remote host address (network byte order)
+ * @rport: Remote port (network byte order)
+ */
+static inline int
+efx_filter_set_ipv4_full(struct efx_filter_spec *spec, u8 proto,
+                        __be32 lhost, __be16 lport,
+                        __be32 rhost, __be16 rport)
+{
+       spec->match_flags |=
+               EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
+               EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT |
+               EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_REM_PORT;
+       spec->ether_type = htons(ETH_P_IP);
+       spec->ip_proto = proto;
+       spec->loc_host[0] = lhost;
+       spec->loc_port = lport;
+       spec->rem_host[0] = rhost;
+       spec->rem_port = rport;
+       return 0;
+}
+
 enum {
        EFX_FILTER_VID_UNSPEC = 0xffff,
 };
 
+/**
+ * efx_filter_set_eth_local - specify local Ethernet address and/or VID
+ * @spec: Specification to initialise
+ * @vid: Outer VLAN ID to match, or %EFX_FILTER_VID_UNSPEC
+ * @addr: Local Ethernet MAC address, or %NULL
+ */
+static inline int efx_filter_set_eth_local(struct efx_filter_spec *spec,
+                                          u16 vid, const u8 *addr)
+{
+       if (vid == EFX_FILTER_VID_UNSPEC && addr == NULL)
+               return -EINVAL;
+
+       if (vid != EFX_FILTER_VID_UNSPEC) {
+               spec->match_flags |= EFX_FILTER_MATCH_OUTER_VID;
+               spec->outer_vid = htons(vid);
+       }
+       if (addr != NULL) {
+               spec->match_flags |= EFX_FILTER_MATCH_LOC_MAC;
+               memcpy(spec->loc_mac, addr, ETH_ALEN);
+       }
+       return 0;
+}
+
+/**
+ * efx_filter_set_uc_def - specify matching otherwise-unmatched unicast
+ * @spec: Specification to initialise
+ */
+static inline int efx_filter_set_uc_def(struct efx_filter_spec *spec)
+{
+       spec->match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
+       return 0;
+}
+
+/**
+ * efx_filter_set_mc_def - specify matching otherwise-unmatched multicast
+ * @spec: Specification to initialise
+ */
+static inline int efx_filter_set_mc_def(struct efx_filter_spec *spec)
+{
+       spec->match_flags |= EFX_FILTER_MATCH_LOC_MAC_IG;
+       spec->loc_mac[0] = 1;
+       return 0;
+}
+
 #endif /* EFX_FILTER_H */
index 96759aee1c6c2fcb372f83a3f3dd844d39489e97..19e8b95b7af60963478807910b4f5d6e9a362d0e 100644 (file)
@@ -83,7 +83,7 @@ static inline __le32 _efx_readd(struct efx_nic *efx, unsigned int reg)
 }
 
 /* Write a normal 128-bit CSR, locking as appropriate. */
-static inline void efx_writeo(struct efx_nic *efx, efx_oword_t *value,
+static inline void efx_writeo(struct efx_nic *efx, const efx_oword_t *value,
                              unsigned int reg)
 {
        unsigned long flags __attribute__ ((unused));
@@ -108,7 +108,7 @@ static inline void efx_writeo(struct efx_nic *efx, efx_oword_t *value,
 
 /* Write 64-bit SRAM through the supplied mapping, locking as appropriate. */
 static inline void efx_sram_writeq(struct efx_nic *efx, void __iomem *membase,
-                                  efx_qword_t *value, unsigned int index)
+                                  const efx_qword_t *value, unsigned int index)
 {
        unsigned int addr = index * sizeof(*value);
        unsigned long flags __attribute__ ((unused));
@@ -129,7 +129,7 @@ static inline void efx_sram_writeq(struct efx_nic *efx, void __iomem *membase,
 }
 
 /* Write a 32-bit CSR or the last dword of a special 128-bit CSR */
-static inline void efx_writed(struct efx_nic *efx, efx_dword_t *value,
+static inline void efx_writed(struct efx_nic *efx, const efx_dword_t *value,
                              unsigned int reg)
 {
        netif_vdbg(efx, hw, efx->net_dev,
@@ -190,8 +190,9 @@ static inline void efx_readd(struct efx_nic *efx, efx_dword_t *value,
 }
 
 /* Write a 128-bit CSR forming part of a table */
-static inline void efx_writeo_table(struct efx_nic *efx, efx_oword_t *value,
-                                     unsigned int reg, unsigned int index)
+static inline void
+efx_writeo_table(struct efx_nic *efx, const efx_oword_t *value,
+                unsigned int reg, unsigned int index)
 {
        efx_writeo(efx, value, reg + index * sizeof(efx_oword_t));
 }
@@ -203,12 +204,12 @@ static inline void efx_reado_table(struct efx_nic *efx, efx_oword_t *value,
        efx_reado(efx, value, reg + index * sizeof(efx_oword_t));
 }
 
-/* Page-mapped register block size */
-#define EFX_PAGE_BLOCK_SIZE 0x2000
+/* Page size used as step between per-VI registers */
+#define EFX_VI_PAGE_SIZE 0x2000
 
-/* Calculate offset to page-mapped register block */
+/* Calculate offset to page-mapped register */
 #define EFX_PAGED_REG(page, reg) \
-       ((page) * EFX_PAGE_BLOCK_SIZE + (reg))
+       ((page) * EFX_VI_PAGE_SIZE + (reg))
 
 /* Write the whole of RX_DESC_UPD or TX_DESC_UPD */
 static inline void _efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
@@ -239,8 +240,9 @@ static inline void _efx_writeo_page(struct efx_nic *efx, efx_oword_t *value,
 /* Write a page-mapped 32-bit CSR (EVQ_RPTR or the high bits of
  * RX_DESC_UPD or TX_DESC_UPD)
  */
-static inline void _efx_writed_page(struct efx_nic *efx, efx_dword_t *value,
-                                   unsigned int reg, unsigned int page)
+static inline void
+_efx_writed_page(struct efx_nic *efx, const efx_dword_t *value,
+                unsigned int reg, unsigned int page)
 {
        efx_writed(efx, value, EFX_PAGED_REG(page, reg));
 }
@@ -256,7 +258,7 @@ static inline void _efx_writed_page(struct efx_nic *efx, efx_dword_t *value,
  * collector register.
  */
 static inline void _efx_writed_page_locked(struct efx_nic *efx,
-                                          efx_dword_t *value,
+                                          const efx_dword_t *value,
                                           unsigned int reg,
                                           unsigned int page)
 {
index 97dd8f18c001af4669307c0553ad1aca1e990970..63121adbc3bbfdcf777e851bac98d111d5136e48 100644 (file)
@@ -11,7 +11,7 @@
 #include "net_driver.h"
 #include "nic.h"
 #include "io.h"
-#include "regs.h"
+#include "farch_regs.h"
 #include "mcdi_pcol.h"
 #include "phy.h"
 
 
 #define MCDI_RPC_TIMEOUT       (10 * HZ)
 
-#define MCDI_PDU(efx)                                                  \
-       (efx_port_num(efx) ? MC_SMEM_P1_PDU_OFST : MC_SMEM_P0_PDU_OFST)
-#define MCDI_DOORBELL(efx)                                             \
-       (efx_port_num(efx) ? MC_SMEM_P1_DOORBELL_OFST : MC_SMEM_P0_DOORBELL_OFST)
-#define MCDI_STATUS(efx)                                               \
-       (efx_port_num(efx) ? MC_SMEM_P1_STATUS_OFST : MC_SMEM_P0_STATUS_OFST)
-
 /* A reboot/assertion causes the MCDI status word to be set after the
  * command word is set or a REBOOT event is sent. If we notice a reboot
- * via these mechanisms then wait 10ms for the status word to be set. */
+ * via these mechanisms then wait 20ms for the status word to be set.
+ */
 #define MCDI_STATUS_DELAY_US           100
-#define MCDI_STATUS_DELAY_COUNT                100
+#define MCDI_STATUS_DELAY_COUNT                200
 #define MCDI_STATUS_SLEEP_MS                                           \
        (MCDI_STATUS_DELAY_US * MCDI_STATUS_DELAY_COUNT / 1000)
 
 
 static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
 {
-       struct siena_nic_data *nic_data;
-       EFX_BUG_ON_PARANOID(efx_nic_rev(efx) < EFX_REV_SIENA_A0);
-       nic_data = efx->nic_data;
-       return &nic_data->mcdi;
+       EFX_BUG_ON_PARANOID(!efx->mcdi);
+       return &efx->mcdi->iface;
 }
 
-void efx_mcdi_init(struct efx_nic *efx)
+int efx_mcdi_init(struct efx_nic *efx)
 {
        struct efx_mcdi_iface *mcdi;
 
-       if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
-               return;
+       efx->mcdi = kzalloc(sizeof(*efx->mcdi), GFP_KERNEL);
+       if (!efx->mcdi)
+               return -ENOMEM;
 
        mcdi = efx_mcdi(efx);
        init_waitqueue_head(&mcdi->wq);
@@ -64,72 +57,150 @@ void efx_mcdi_init(struct efx_nic *efx)
        mcdi->mode = MCDI_MODE_POLL;
 
        (void) efx_mcdi_poll_reboot(efx);
+       mcdi->new_epoch = true;
+
+       /* Recover from a failed assertion before probing */
+       return efx_mcdi_handle_assertion(efx);
+}
+
+void efx_mcdi_fini(struct efx_nic *efx)
+{
+       BUG_ON(efx->mcdi &&
+              atomic_read(&efx->mcdi->iface.state) != MCDI_STATE_QUIESCENT);
+       kfree(efx->mcdi);
 }
 
 static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
-                           const u8 *inbuf, size_t inlen)
+                           const efx_dword_t *inbuf, size_t inlen)
 {
        struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
-       unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
-       unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL(efx);
-       unsigned int i;
-       efx_dword_t hdr;
+       efx_dword_t hdr[2];
+       size_t hdr_len;
        u32 xflags, seqno;
 
        BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
-       BUG_ON(inlen & 3 || inlen >= MC_SMEM_PDU_LEN);
 
        seqno = mcdi->seqno & SEQ_MASK;
        xflags = 0;
        if (mcdi->mode == MCDI_MODE_EVENTS)
                xflags |= MCDI_HEADER_XFLAGS_EVREQ;
 
-       EFX_POPULATE_DWORD_6(hdr,
-                            MCDI_HEADER_RESPONSE, 0,
-                            MCDI_HEADER_RESYNC, 1,
-                            MCDI_HEADER_CODE, cmd,
-                            MCDI_HEADER_DATALEN, inlen,
-                            MCDI_HEADER_SEQ, seqno,
-                            MCDI_HEADER_XFLAGS, xflags);
-
-       efx_writed(efx, &hdr, pdu);
-
-       for (i = 0; i < inlen; i += 4)
-               _efx_writed(efx, *((__le32 *)(inbuf + i)), pdu + 4 + i);
+       if (efx->type->mcdi_max_ver == 1) {
+               /* MCDI v1 */
+               EFX_POPULATE_DWORD_7(hdr[0],
+                                    MCDI_HEADER_RESPONSE, 0,
+                                    MCDI_HEADER_RESYNC, 1,
+                                    MCDI_HEADER_CODE, cmd,
+                                    MCDI_HEADER_DATALEN, inlen,
+                                    MCDI_HEADER_SEQ, seqno,
+                                    MCDI_HEADER_XFLAGS, xflags,
+                                    MCDI_HEADER_NOT_EPOCH, !mcdi->new_epoch);
+               hdr_len = 4;
+       } else {
+               /* MCDI v2 */
+               BUG_ON(inlen > MCDI_CTL_SDU_LEN_MAX_V2);
+               EFX_POPULATE_DWORD_7(hdr[0],
+                                    MCDI_HEADER_RESPONSE, 0,
+                                    MCDI_HEADER_RESYNC, 1,
+                                    MCDI_HEADER_CODE, MC_CMD_V2_EXTN,
+                                    MCDI_HEADER_DATALEN, 0,
+                                    MCDI_HEADER_SEQ, seqno,
+                                    MCDI_HEADER_XFLAGS, xflags,
+                                    MCDI_HEADER_NOT_EPOCH, !mcdi->new_epoch);
+               EFX_POPULATE_DWORD_2(hdr[1],
+                                    MC_CMD_V2_EXTN_IN_EXTENDED_CMD, cmd,
+                                    MC_CMD_V2_EXTN_IN_ACTUAL_LEN, inlen);
+               hdr_len = 8;
+       }
 
-       /* Ensure the payload is written out before the header */
-       wmb();
+       efx->type->mcdi_request(efx, hdr, hdr_len, inbuf, inlen);
+}
 
-       /* ring the doorbell with a distinctive value */
-       _efx_writed(efx, (__force __le32) 0x45789abc, doorbell);
+static int efx_mcdi_errno(unsigned int mcdi_err)
+{
+       switch (mcdi_err) {
+       case 0:
+               return 0;
+#define TRANSLATE_ERROR(name)                                  \
+       case MC_CMD_ERR_ ## name:                               \
+               return -name;
+       TRANSLATE_ERROR(EPERM);
+       TRANSLATE_ERROR(ENOENT);
+       TRANSLATE_ERROR(EINTR);
+       TRANSLATE_ERROR(EAGAIN);
+       TRANSLATE_ERROR(EACCES);
+       TRANSLATE_ERROR(EBUSY);
+       TRANSLATE_ERROR(EINVAL);
+       TRANSLATE_ERROR(EDEADLK);
+       TRANSLATE_ERROR(ENOSYS);
+       TRANSLATE_ERROR(ETIME);
+       TRANSLATE_ERROR(EALREADY);
+       TRANSLATE_ERROR(ENOSPC);
+#undef TRANSLATE_ERROR
+       case MC_CMD_ERR_ALLOC_FAIL:
+               return -ENOBUFS;
+       case MC_CMD_ERR_MAC_EXIST:
+               return -EADDRINUSE;
+       default:
+               return -EPROTO;
+       }
 }
 
-static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen)
+static void efx_mcdi_read_response_header(struct efx_nic *efx)
 {
        struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
-       unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
-       int i;
+       unsigned int respseq, respcmd, error;
+       efx_dword_t hdr;
 
-       BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
-       BUG_ON(outlen & 3 || outlen >= MC_SMEM_PDU_LEN);
+       efx->type->mcdi_read_response(efx, &hdr, 0, 4);
+       respseq = EFX_DWORD_FIELD(hdr, MCDI_HEADER_SEQ);
+       respcmd = EFX_DWORD_FIELD(hdr, MCDI_HEADER_CODE);
+       error = EFX_DWORD_FIELD(hdr, MCDI_HEADER_ERROR);
+
+       if (respcmd != MC_CMD_V2_EXTN) {
+               mcdi->resp_hdr_len = 4;
+               mcdi->resp_data_len = EFX_DWORD_FIELD(hdr, MCDI_HEADER_DATALEN);
+       } else {
+               efx->type->mcdi_read_response(efx, &hdr, 4, 4);
+               mcdi->resp_hdr_len = 8;
+               mcdi->resp_data_len =
+                       EFX_DWORD_FIELD(hdr, MC_CMD_V2_EXTN_IN_ACTUAL_LEN);
+       }
 
-       for (i = 0; i < outlen; i += 4)
-               *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i);
+       if (error && mcdi->resp_data_len == 0) {
+               netif_err(efx, hw, efx->net_dev, "MC rebooted\n");
+               mcdi->resprc = -EIO;
+       } else if ((respseq ^ mcdi->seqno) & SEQ_MASK) {
+               netif_err(efx, hw, efx->net_dev,
+                         "MC response mismatch tx seq 0x%x rx seq 0x%x\n",
+                         respseq, mcdi->seqno);
+               mcdi->resprc = -EIO;
+       } else if (error) {
+               efx->type->mcdi_read_response(efx, &hdr, mcdi->resp_hdr_len, 4);
+               mcdi->resprc =
+                       efx_mcdi_errno(EFX_DWORD_FIELD(hdr, EFX_DWORD_0));
+       } else {
+               mcdi->resprc = 0;
+       }
 }
 
 static int efx_mcdi_poll(struct efx_nic *efx)
 {
        struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
        unsigned long time, finish;
-       unsigned int respseq, respcmd, error;
-       unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
-       unsigned int rc, spins;
-       efx_dword_t reg;
+       unsigned int spins;
+       int rc;
 
        /* Check for a reboot atomically with respect to efx_mcdi_copyout() */
-       rc = -efx_mcdi_poll_reboot(efx);
-       if (rc)
-               goto out;
+       rc = efx_mcdi_poll_reboot(efx);
+       if (rc) {
+               spin_lock_bh(&mcdi->iface_lock);
+               mcdi->resprc = rc;
+               mcdi->resp_hdr_len = 0;
+               mcdi->resp_data_len = 0;
+               spin_unlock_bh(&mcdi->iface_lock);
+               return 0;
+       }
 
        /* Poll for completion. Poll quickly (once a us) for the 1st jiffy,
         * because generally mcdi responses are fast. After that, back off
@@ -149,59 +220,16 @@ static int efx_mcdi_poll(struct efx_nic *efx)
                time = jiffies;
 
                rmb();
-               efx_readd(efx, &reg, pdu);
-
-               /* All 1's indicates that shared memory is in reset (and is
-                * not a valid header). Wait for it to come out reset before
-                * completing the command */
-               if (EFX_DWORD_FIELD(reg, EFX_DWORD_0) != 0xffffffff &&
-                   EFX_DWORD_FIELD(reg, MCDI_HEADER_RESPONSE))
+               if (efx->type->mcdi_poll_response(efx))
                        break;
 
                if (time_after(time, finish))
                        return -ETIMEDOUT;
        }
 
-       mcdi->resplen = EFX_DWORD_FIELD(reg, MCDI_HEADER_DATALEN);
-       respseq = EFX_DWORD_FIELD(reg, MCDI_HEADER_SEQ);
-       respcmd = EFX_DWORD_FIELD(reg, MCDI_HEADER_CODE);
-       error = EFX_DWORD_FIELD(reg, MCDI_HEADER_ERROR);
-
-       if (error && mcdi->resplen == 0) {
-               netif_err(efx, hw, efx->net_dev, "MC rebooted\n");
-               rc = EIO;
-       } else if ((respseq ^ mcdi->seqno) & SEQ_MASK) {
-               netif_err(efx, hw, efx->net_dev,
-                         "MC response mismatch tx seq 0x%x rx seq 0x%x\n",
-                         respseq, mcdi->seqno);
-               rc = EIO;
-       } else if (error) {
-               efx_readd(efx, &reg, pdu + 4);
-               switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) {
-#define TRANSLATE_ERROR(name)                                  \
-               case MC_CMD_ERR_ ## name:                       \
-                       rc = name;                              \
-                       break
-                       TRANSLATE_ERROR(ENOENT);
-                       TRANSLATE_ERROR(EINTR);
-                       TRANSLATE_ERROR(EACCES);
-                       TRANSLATE_ERROR(EBUSY);
-                       TRANSLATE_ERROR(EINVAL);
-                       TRANSLATE_ERROR(EDEADLK);
-                       TRANSLATE_ERROR(ENOSYS);
-                       TRANSLATE_ERROR(ETIME);
-#undef TRANSLATE_ERROR
-               default:
-                       rc = EIO;
-                       break;
-               }
-       } else
-               rc = 0;
-
-out:
-       mcdi->resprc = rc;
-       if (rc)
-               mcdi->resplen = 0;
+       spin_lock_bh(&mcdi->iface_lock);
+       efx_mcdi_read_response_header(efx);
+       spin_unlock_bh(&mcdi->iface_lock);
 
        /* Return rc=0 like wait_event_timeout() */
        return 0;
@@ -212,31 +240,10 @@ out:
  */
 int efx_mcdi_poll_reboot(struct efx_nic *efx)
 {
-       unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_STATUS(efx);
-       efx_dword_t reg;
-       uint32_t value;
-
-       if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
-               return false;
-
-       efx_readd(efx, &reg, addr);
-       value = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
-
-       if (value == 0)
+       if (!efx->mcdi)
                return 0;
 
-       /* MAC statistics have been cleared on the NIC; clear our copy
-        * so that efx_update_diff_stat() can continue to work.
-        */
-       memset(&efx->mac_stats, 0, sizeof(efx->mac_stats));
-
-       EFX_ZERO_DWORD(reg);
-       efx_writed(efx, &reg, addr);
-
-       if (value == MC_STATUS_DWORD_ASSERT)
-               return -EINTR;
-       else
-               return -EIO;
+       return efx->type->mcdi_poll_reboot(efx);
 }
 
 static void efx_mcdi_acquire(struct efx_mcdi_iface *mcdi)
@@ -299,7 +306,7 @@ static void efx_mcdi_release(struct efx_mcdi_iface *mcdi)
 }
 
 static void efx_mcdi_ev_cpl(struct efx_nic *efx, unsigned int seqno,
-                           unsigned int datalen, unsigned int errno)
+                           unsigned int datalen, unsigned int mcdi_err)
 {
        struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
        bool wake = false;
@@ -315,8 +322,14 @@ static void efx_mcdi_ev_cpl(struct efx_nic *efx, unsigned int seqno,
                                  "MC response mismatch tx seq 0x%x rx "
                                  "seq 0x%x\n", seqno, mcdi->seqno);
        } else {
-               mcdi->resprc = errno;
-               mcdi->resplen = datalen;
+               if (efx->type->mcdi_max_ver >= 2) {
+                       /* MCDI v2 responses don't fit in an event */
+                       efx_mcdi_read_response_header(efx);
+               } else {
+                       mcdi->resprc = efx_mcdi_errno(mcdi_err);
+                       mcdi->resp_hdr_len = 4;
+                       mcdi->resp_data_len = datalen;
+               }
 
                wake = true;
        }
@@ -328,20 +341,33 @@ static void efx_mcdi_ev_cpl(struct efx_nic *efx, unsigned int seqno,
 }
 
 int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd,
-                const u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen,
+                const efx_dword_t *inbuf, size_t inlen,
+                efx_dword_t *outbuf, size_t outlen,
                 size_t *outlen_actual)
 {
-       efx_mcdi_rpc_start(efx, cmd, inbuf, inlen);
+       int rc;
+
+       rc = efx_mcdi_rpc_start(efx, cmd, inbuf, inlen);
+       if (rc)
+               return rc;
        return efx_mcdi_rpc_finish(efx, cmd, inlen,
                                   outbuf, outlen, outlen_actual);
 }
 
-void efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd, const u8 *inbuf,
-                       size_t inlen)
+int efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd,
+                      const efx_dword_t *inbuf, size_t inlen)
 {
        struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
 
-       BUG_ON(efx_nic_rev(efx) < EFX_REV_SIENA_A0);
+       if (efx->type->mcdi_max_ver < 0 ||
+            (efx->type->mcdi_max_ver < 2 &&
+             cmd > MC_CMD_CMD_SPACE_ESCAPE_7))
+               return -EINVAL;
+
+       if (inlen > MCDI_CTL_SDU_LEN_MAX_V2 ||
+           (efx->type->mcdi_max_ver < 2 &&
+            inlen > MCDI_CTL_SDU_LEN_MAX_V1))
+               return -EMSGSIZE;
 
        efx_mcdi_acquire(mcdi);
 
@@ -351,16 +377,17 @@ void efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd, const u8 *inbuf,
        spin_unlock_bh(&mcdi->iface_lock);
 
        efx_mcdi_copyin(efx, cmd, inbuf, inlen);
+       mcdi->new_epoch = false;
+       return 0;
 }
 
 int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
-                       u8 *outbuf, size_t outlen, size_t *outlen_actual)
+                       efx_dword_t *outbuf, size_t outlen,
+                       size_t *outlen_actual)
 {
        struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
        int rc;
 
-       BUG_ON(efx_nic_rev(efx) < EFX_REV_SIENA_A0);
-
        if (mcdi->mode == MCDI_MODE_POLL)
                rc = efx_mcdi_poll(efx);
        else
@@ -380,22 +407,25 @@ int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
                          "MC command 0x%x inlen %d mode %d timed out\n",
                          cmd, (int)inlen, mcdi->mode);
        } else {
-               size_t resplen;
+               size_t hdr_len, data_len;
 
                /* At the very least we need a memory barrier here to ensure
                 * we pick up changes from efx_mcdi_ev_cpl(). Protect against
                 * a spurious efx_mcdi_ev_cpl() running concurrently by
                 * acquiring the iface_lock. */
                spin_lock_bh(&mcdi->iface_lock);
-               rc = -mcdi->resprc;
-               resplen = mcdi->resplen;
+               rc = mcdi->resprc;
+               hdr_len = mcdi->resp_hdr_len;
+               data_len = mcdi->resp_data_len;
                spin_unlock_bh(&mcdi->iface_lock);
 
+               BUG_ON(rc > 0);
+
                if (rc == 0) {
-                       efx_mcdi_copyout(efx, outbuf,
-                                        min(outlen, mcdi->resplen + 3) & ~0x3);
+                       efx->type->mcdi_read_response(efx, outbuf, hdr_len,
+                                                     min(outlen, data_len));
                        if (outlen_actual != NULL)
-                               *outlen_actual = resplen;
+                               *outlen_actual = data_len;
                } else if (cmd == MC_CMD_REBOOT && rc == -EIO)
                        ; /* Don't reset if MC_CMD_REBOOT returns EIO */
                else if (rc == -EIO || rc == -EINTR) {
@@ -410,6 +440,7 @@ int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
                if (rc == -EIO || rc == -EINTR) {
                        msleep(MCDI_STATUS_SLEEP_MS);
                        efx_mcdi_poll_reboot(efx);
+                       mcdi->new_epoch = true;
                }
        }
 
@@ -421,7 +452,7 @@ void efx_mcdi_mode_poll(struct efx_nic *efx)
 {
        struct efx_mcdi_iface *mcdi;
 
-       if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
+       if (!efx->mcdi)
                return;
 
        mcdi = efx_mcdi(efx);
@@ -445,7 +476,7 @@ void efx_mcdi_mode_event(struct efx_nic *efx)
 {
        struct efx_mcdi_iface *mcdi;
 
-       if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
+       if (!efx->mcdi)
                return;
 
        mcdi = efx_mcdi(efx);
@@ -489,7 +520,8 @@ static void efx_mcdi_ev_death(struct efx_nic *efx, int rc)
        if (efx_mcdi_complete(mcdi)) {
                if (mcdi->mode == MCDI_MODE_EVENTS) {
                        mcdi->resprc = rc;
-                       mcdi->resplen = 0;
+                       mcdi->resp_hdr_len = 0;
+                       mcdi->resp_data_len = 0;
                        ++mcdi->credits;
                }
        } else {
@@ -504,41 +536,12 @@ static void efx_mcdi_ev_death(struct efx_nic *efx, int rc)
                                break;
                        udelay(MCDI_STATUS_DELAY_US);
                }
+               mcdi->new_epoch = true;
        }
 
        spin_unlock(&mcdi->iface_lock);
 }
 
-static unsigned int efx_mcdi_event_link_speed[] = {
-       [MCDI_EVENT_LINKCHANGE_SPEED_100M] = 100,
-       [MCDI_EVENT_LINKCHANGE_SPEED_1G] = 1000,
-       [MCDI_EVENT_LINKCHANGE_SPEED_10G] = 10000,
-};
-
-
-static void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev)
-{
-       u32 flags, fcntl, speed, lpa;
-
-       speed = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_SPEED);
-       EFX_BUG_ON_PARANOID(speed >= ARRAY_SIZE(efx_mcdi_event_link_speed));
-       speed = efx_mcdi_event_link_speed[speed];
-
-       flags = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_LINK_FLAGS);
-       fcntl = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_FCNTL);
-       lpa = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_LP_CAP);
-
-       /* efx->link_state is only modified by efx_mcdi_phy_get_link(),
-        * which is only run after flushing the event queues. Therefore, it
-        * is safe to modify the link state outside of the mac_lock here.
-        */
-       efx_mcdi_phy_decode_link(efx, &efx->link_state, speed, flags, fcntl);
-
-       efx_mcdi_phy_check_fcntl(efx, lpa);
-
-       efx_link_status_changed(efx);
-}
-
 /* Called from  falcon_process_eventq for MCDI events */
 void efx_mcdi_process_event(struct efx_channel *channel,
                            efx_qword_t *event)
@@ -551,7 +554,7 @@ void efx_mcdi_process_event(struct efx_channel *channel,
        case MCDI_EVENT_CODE_BADSSERT:
                netif_err(efx, hw, efx->net_dev,
                          "MC watchdog or assertion failure at 0x%x\n", data);
-               efx_mcdi_ev_death(efx, EINTR);
+               efx_mcdi_ev_death(efx, -EINTR);
                break;
 
        case MCDI_EVENT_CODE_PMNOTICE:
@@ -577,7 +580,7 @@ void efx_mcdi_process_event(struct efx_channel *channel,
                break;
        case MCDI_EVENT_CODE_REBOOT:
                netif_info(efx, hw, efx->net_dev, "MC Reboot\n");
-               efx_mcdi_ev_death(efx, EIO);
+               efx_mcdi_ev_death(efx, -EIO);
                break;
        case MCDI_EVENT_CODE_MAC_STATS_DMA:
                /* MAC stats are gather lazily.  We can ignore this. */
@@ -591,6 +594,14 @@ void efx_mcdi_process_event(struct efx_channel *channel,
                efx_ptp_event(efx, event);
                break;
 
+       case MCDI_EVENT_CODE_TX_ERR:
+       case MCDI_EVENT_CODE_RX_ERR:
+               netif_err(efx, hw, efx->net_dev,
+                         "%s DMA error (event: "EFX_QWORD_FMT")\n",
+                         code == MCDI_EVENT_CODE_TX_ERR ? "TX" : "RX",
+                         EFX_QWORD_VAL(*event));
+               efx_schedule_reset(efx, RESET_TYPE_DMA_ERROR);
+               break;
        default:
                netif_err(efx, hw, efx->net_dev, "Unknown MCDI event 0x%x\n",
                          code);
@@ -606,7 +617,7 @@ void efx_mcdi_process_event(struct efx_channel *channel,
 
 void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len)
 {
-       u8 outbuf[ALIGN(MC_CMD_GET_VERSION_OUT_LEN, 4)];
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_VERSION_OUT_LEN);
        size_t outlength;
        const __le16 *ver_words;
        int rc;
@@ -637,14 +648,15 @@ fail:
 int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
                        bool *was_attached)
 {
-       u8 inbuf[MC_CMD_DRV_ATTACH_IN_LEN];
-       u8 outbuf[MC_CMD_DRV_ATTACH_OUT_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_OUT_LEN);
        size_t outlen;
        int rc;
 
        MCDI_SET_DWORD(inbuf, DRV_ATTACH_IN_NEW_STATE,
                       driver_operating ? 1 : 0);
        MCDI_SET_DWORD(inbuf, DRV_ATTACH_IN_UPDATE, 1);
+       MCDI_SET_DWORD(inbuf, DRV_ATTACH_IN_FIRMWARE_ID, MC_CMD_FW_LOW_LATENCY);
 
        rc = efx_mcdi_rpc(efx, MC_CMD_DRV_ATTACH, inbuf, sizeof(inbuf),
                          outbuf, sizeof(outbuf), &outlen);
@@ -667,8 +679,8 @@ fail:
 int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
                           u16 *fw_subtype_list, u32 *capabilities)
 {
-       uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMAX];
-       size_t outlen, offset, i;
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_BOARD_CFG_OUT_LENMAX);
+       size_t outlen, i;
        int port_num = efx_port_num(efx);
        int rc;
 
@@ -684,22 +696,21 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
                goto fail;
        }
 
-       offset = (port_num)
-               ? MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_OFST
-               : MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST;
        if (mac_address)
-               memcpy(mac_address, outbuf + offset, ETH_ALEN);
+               memcpy(mac_address,
+                      port_num ?
+                      MCDI_PTR(outbuf, GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1) :
+                      MCDI_PTR(outbuf, GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0),
+                      ETH_ALEN);
        if (fw_subtype_list) {
-               /* Byte-swap and truncate or zero-pad as necessary */
-               offset = MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST;
                for (i = 0;
-                    i < MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM;
-                    i++) {
-                       fw_subtype_list[i] =
-                               (offset + 2 <= outlen) ?
-                               le16_to_cpup((__le16 *)(outbuf + offset)) : 0;
-                       offset += 2;
-               }
+                    i < MCDI_VAR_ARRAY_LEN(outlen,
+                                           GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST);
+                    i++)
+                       fw_subtype_list[i] = MCDI_ARRAY_WORD(
+                               outbuf, GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST, i);
+               for (; i < MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM; i++)
+                       fw_subtype_list[i] = 0;
        }
        if (capabilities) {
                if (port_num)
@@ -721,7 +732,7 @@ fail:
 
 int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, u32 dest_evq)
 {
-       u8 inbuf[MC_CMD_LOG_CTRL_IN_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_LOG_CTRL_IN_LEN);
        u32 dest = 0;
        int rc;
 
@@ -749,7 +760,7 @@ fail:
 
 int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out)
 {
-       u8 outbuf[MC_CMD_NVRAM_TYPES_OUT_LEN];
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_TYPES_OUT_LEN);
        size_t outlen;
        int rc;
 
@@ -777,8 +788,8 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type,
                        size_t *size_out, size_t *erase_size_out,
                        bool *protected_out)
 {
-       u8 inbuf[MC_CMD_NVRAM_INFO_IN_LEN];
-       u8 outbuf[MC_CMD_NVRAM_INFO_OUT_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_INFO_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_INFO_OUT_LEN);
        size_t outlen;
        int rc;
 
@@ -804,127 +815,10 @@ fail:
        return rc;
 }
 
-int efx_mcdi_nvram_update_start(struct efx_nic *efx, unsigned int type)
-{
-       u8 inbuf[MC_CMD_NVRAM_UPDATE_START_IN_LEN];
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_START_IN_TYPE, type);
-
-       BUILD_BUG_ON(MC_CMD_NVRAM_UPDATE_START_OUT_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_UPDATE_START, inbuf, sizeof(inbuf),
-                         NULL, 0, NULL);
-       if (rc)
-               goto fail;
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-int efx_mcdi_nvram_read(struct efx_nic *efx, unsigned int type,
-                       loff_t offset, u8 *buffer, size_t length)
-{
-       u8 inbuf[MC_CMD_NVRAM_READ_IN_LEN];
-       u8 outbuf[MC_CMD_NVRAM_READ_OUT_LEN(EFX_MCDI_NVRAM_LEN_MAX)];
-       size_t outlen;
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_TYPE, type);
-       MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_OFFSET, offset);
-       MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_LENGTH, length);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_READ, inbuf, sizeof(inbuf),
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               goto fail;
-
-       memcpy(buffer, MCDI_PTR(outbuf, NVRAM_READ_OUT_READ_BUFFER), length);
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-int efx_mcdi_nvram_write(struct efx_nic *efx, unsigned int type,
-                          loff_t offset, const u8 *buffer, size_t length)
-{
-       u8 inbuf[MC_CMD_NVRAM_WRITE_IN_LEN(EFX_MCDI_NVRAM_LEN_MAX)];
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_TYPE, type);
-       MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_OFFSET, offset);
-       MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_LENGTH, length);
-       memcpy(MCDI_PTR(inbuf, NVRAM_WRITE_IN_WRITE_BUFFER), buffer, length);
-
-       BUILD_BUG_ON(MC_CMD_NVRAM_WRITE_OUT_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_WRITE, inbuf,
-                         ALIGN(MC_CMD_NVRAM_WRITE_IN_LEN(length), 4),
-                         NULL, 0, NULL);
-       if (rc)
-               goto fail;
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type,
-                        loff_t offset, size_t length)
-{
-       u8 inbuf[MC_CMD_NVRAM_ERASE_IN_LEN];
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_TYPE, type);
-       MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_OFFSET, offset);
-       MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_LENGTH, length);
-
-       BUILD_BUG_ON(MC_CMD_NVRAM_ERASE_OUT_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_ERASE, inbuf, sizeof(inbuf),
-                         NULL, 0, NULL);
-       if (rc)
-               goto fail;
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-int efx_mcdi_nvram_update_finish(struct efx_nic *efx, unsigned int type)
-{
-       u8 inbuf[MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN];
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_FINISH_IN_TYPE, type);
-
-       BUILD_BUG_ON(MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_UPDATE_FINISH, inbuf, sizeof(inbuf),
-                         NULL, 0, NULL);
-       if (rc)
-               goto fail;
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
 static int efx_mcdi_nvram_test(struct efx_nic *efx, unsigned int type)
 {
-       u8 inbuf[MC_CMD_NVRAM_TEST_IN_LEN];
-       u8 outbuf[MC_CMD_NVRAM_TEST_OUT_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_TEST_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_TEST_OUT_LEN);
        int rc;
 
        MCDI_SET_DWORD(inbuf, NVRAM_TEST_IN_TYPE, type);
@@ -976,9 +870,9 @@ fail1:
 
 static int efx_mcdi_read_assertion(struct efx_nic *efx)
 {
-       u8 inbuf[MC_CMD_GET_ASSERTS_IN_LEN];
-       u8 outbuf[MC_CMD_GET_ASSERTS_OUT_LEN];
-       unsigned int flags, index, ofst;
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_ASSERTS_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_ASSERTS_OUT_LEN);
+       unsigned int flags, index;
        const char *reason;
        size_t outlen;
        int retry;
@@ -1020,19 +914,20 @@ static int efx_mcdi_read_assertion(struct efx_nic *efx)
                  MCDI_DWORD(outbuf, GET_ASSERTS_OUT_THREAD_OFFS));
 
        /* Print out the registers */
-       ofst = MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST;
-       for (index = 1; index < 32; index++) {
-               netif_err(efx, hw, efx->net_dev, "R%.2d (?): 0x%.8x\n", index,
-                       MCDI_DWORD2(outbuf, ofst));
-               ofst += sizeof(efx_dword_t);
-       }
+       for (index = 0;
+            index < MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_NUM;
+            index++)
+               netif_err(efx, hw, efx->net_dev, "R%.2d (?): 0x%.8x\n",
+                         1 + index,
+                         MCDI_ARRAY_DWORD(outbuf, GET_ASSERTS_OUT_GP_REGS_OFFS,
+                                          index));
 
        return 0;
 }
 
 static void efx_mcdi_exit_assertion(struct efx_nic *efx)
 {
-       u8 inbuf[MC_CMD_REBOOT_IN_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_REBOOT_IN_LEN);
 
        /* If the MC is running debug firmware, it might now be
         * waiting for a debugger to attach, but we just want it to
@@ -1062,7 +957,7 @@ int efx_mcdi_handle_assertion(struct efx_nic *efx)
 
 void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
 {
-       u8 inbuf[MC_CMD_SET_ID_LED_IN_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_SET_ID_LED_IN_LEN);
        int rc;
 
        BUILD_BUG_ON(EFX_LED_OFF != MC_CMD_LED_OFF);
@@ -1080,7 +975,7 @@ void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
                          __func__, rc);
 }
 
-int efx_mcdi_reset_port(struct efx_nic *efx)
+static int efx_mcdi_reset_port(struct efx_nic *efx)
 {
        int rc = efx_mcdi_rpc(efx, MC_CMD_ENTITY_RESET, NULL, 0, NULL, 0, NULL);
        if (rc)
@@ -1089,9 +984,9 @@ int efx_mcdi_reset_port(struct efx_nic *efx)
        return rc;
 }
 
-int efx_mcdi_reset_mc(struct efx_nic *efx)
+static int efx_mcdi_reset_mc(struct efx_nic *efx)
 {
-       u8 inbuf[MC_CMD_REBOOT_IN_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_REBOOT_IN_LEN);
        int rc;
 
        BUILD_BUG_ON(MC_CMD_REBOOT_OUT_LEN != 0);
@@ -1107,11 +1002,31 @@ int efx_mcdi_reset_mc(struct efx_nic *efx)
        return rc;
 }
 
+enum reset_type efx_mcdi_map_reset_reason(enum reset_type reason)
+{
+       return RESET_TYPE_RECOVER_OR_ALL;
+}
+
+int efx_mcdi_reset(struct efx_nic *efx, enum reset_type method)
+{
+       int rc;
+
+       /* Recover from a failed assertion pre-reset */
+       rc = efx_mcdi_handle_assertion(efx);
+       if (rc)
+               return rc;
+
+       if (method == RESET_TYPE_WORLD)
+               return efx_mcdi_reset_mc(efx);
+       else
+               return efx_mcdi_reset_port(efx);
+}
+
 static int efx_mcdi_wol_filter_set(struct efx_nic *efx, u32 type,
                                   const u8 *mac, int *id_out)
 {
-       u8 inbuf[MC_CMD_WOL_FILTER_SET_IN_LEN];
-       u8 outbuf[MC_CMD_WOL_FILTER_SET_OUT_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_WOL_FILTER_SET_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_WOL_FILTER_SET_OUT_LEN);
        size_t outlen;
        int rc;
 
@@ -1151,7 +1066,7 @@ efx_mcdi_wol_filter_set_magic(struct efx_nic *efx,  const u8 *mac, int *id_out)
 
 int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out)
 {
-       u8 outbuf[MC_CMD_WOL_FILTER_GET_OUT_LEN];
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_WOL_FILTER_GET_OUT_LEN);
        size_t outlen;
        int rc;
 
@@ -1178,7 +1093,7 @@ fail:
 
 int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id)
 {
-       u8 inbuf[MC_CMD_WOL_FILTER_REMOVE_IN_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_WOL_FILTER_REMOVE_IN_LEN);
        int rc;
 
        MCDI_SET_DWORD(inbuf, WOL_FILTER_REMOVE_IN_FILTER_ID, (u32)id);
@@ -1199,34 +1114,31 @@ int efx_mcdi_flush_rxqs(struct efx_nic *efx)
 {
        struct efx_channel *channel;
        struct efx_rx_queue *rx_queue;
-       __le32 *qid;
+       MCDI_DECLARE_BUF(inbuf,
+                        MC_CMD_FLUSH_RX_QUEUES_IN_LEN(EFX_MAX_CHANNELS));
        int rc, count;
 
        BUILD_BUG_ON(EFX_MAX_CHANNELS >
                     MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MAXNUM);
 
-       qid = kmalloc(EFX_MAX_CHANNELS * sizeof(*qid), GFP_KERNEL);
-       if (qid == NULL)
-               return -ENOMEM;
-
        count = 0;
        efx_for_each_channel(channel, efx) {
                efx_for_each_channel_rx_queue(rx_queue, channel) {
                        if (rx_queue->flush_pending) {
                                rx_queue->flush_pending = false;
                                atomic_dec(&efx->rxq_flush_pending);
-                               qid[count++] = cpu_to_le32(
-                                       efx_rx_queue_index(rx_queue));
+                               MCDI_SET_ARRAY_DWORD(
+                                       inbuf, FLUSH_RX_QUEUES_IN_QID_OFST,
+                                       count, efx_rx_queue_index(rx_queue));
+                               count++;
                        }
                }
        }
 
-       rc = efx_mcdi_rpc(efx, MC_CMD_FLUSH_RX_QUEUES, (u8 *)qid,
-                         count * sizeof(*qid), NULL, 0, NULL);
+       rc = efx_mcdi_rpc(efx, MC_CMD_FLUSH_RX_QUEUES, inbuf,
+                         MC_CMD_FLUSH_RX_QUEUES_IN_LEN(count), NULL, 0, NULL);
        WARN_ON(rc < 0);
 
-       kfree(qid);
-
        return rc;
 }
 
@@ -1245,3 +1157,236 @@ fail:
        return rc;
 }
 
+#ifdef CONFIG_SFC_MTD
+
+#define EFX_MCDI_NVRAM_LEN_MAX 128
+
+static int efx_mcdi_nvram_update_start(struct efx_nic *efx, unsigned int type)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_UPDATE_START_IN_LEN);
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_START_IN_TYPE, type);
+
+       BUILD_BUG_ON(MC_CMD_NVRAM_UPDATE_START_OUT_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_UPDATE_START, inbuf, sizeof(inbuf),
+                         NULL, 0, NULL);
+       if (rc)
+               goto fail;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_nvram_read(struct efx_nic *efx, unsigned int type,
+                              loff_t offset, u8 *buffer, size_t length)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_READ_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf,
+                        MC_CMD_NVRAM_READ_OUT_LEN(EFX_MCDI_NVRAM_LEN_MAX));
+       size_t outlen;
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_TYPE, type);
+       MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_OFFSET, offset);
+       MCDI_SET_DWORD(inbuf, NVRAM_READ_IN_LENGTH, length);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_READ, inbuf, sizeof(inbuf),
+                         outbuf, sizeof(outbuf), &outlen);
+       if (rc)
+               goto fail;
+
+       memcpy(buffer, MCDI_PTR(outbuf, NVRAM_READ_OUT_READ_BUFFER), length);
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_nvram_write(struct efx_nic *efx, unsigned int type,
+                               loff_t offset, const u8 *buffer, size_t length)
+{
+       MCDI_DECLARE_BUF(inbuf,
+                        MC_CMD_NVRAM_WRITE_IN_LEN(EFX_MCDI_NVRAM_LEN_MAX));
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_TYPE, type);
+       MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_OFFSET, offset);
+       MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_LENGTH, length);
+       memcpy(MCDI_PTR(inbuf, NVRAM_WRITE_IN_WRITE_BUFFER), buffer, length);
+
+       BUILD_BUG_ON(MC_CMD_NVRAM_WRITE_OUT_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_WRITE, inbuf,
+                         ALIGN(MC_CMD_NVRAM_WRITE_IN_LEN(length), 4),
+                         NULL, 0, NULL);
+       if (rc)
+               goto fail;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type,
+                               loff_t offset, size_t length)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_ERASE_IN_LEN);
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_TYPE, type);
+       MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_OFFSET, offset);
+       MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_LENGTH, length);
+
+       BUILD_BUG_ON(MC_CMD_NVRAM_ERASE_OUT_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_ERASE, inbuf, sizeof(inbuf),
+                         NULL, 0, NULL);
+       if (rc)
+               goto fail;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_nvram_update_finish(struct efx_nic *efx, unsigned int type)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN);
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_FINISH_IN_TYPE, type);
+
+       BUILD_BUG_ON(MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_UPDATE_FINISH, inbuf, sizeof(inbuf),
+                         NULL, 0, NULL);
+       if (rc)
+               goto fail;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+int efx_mcdi_mtd_read(struct mtd_info *mtd, loff_t start,
+                     size_t len, size_t *retlen, u8 *buffer)
+{
+       struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       loff_t offset = start;
+       loff_t end = min_t(loff_t, start + len, mtd->size);
+       size_t chunk;
+       int rc = 0;
+
+       while (offset < end) {
+               chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX);
+               rc = efx_mcdi_nvram_read(efx, part->nvram_type, offset,
+                                        buffer, chunk);
+               if (rc)
+                       goto out;
+               offset += chunk;
+               buffer += chunk;
+       }
+out:
+       *retlen = offset - start;
+       return rc;
+}
+
+int efx_mcdi_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len)
+{
+       struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       loff_t offset = start & ~((loff_t)(mtd->erasesize - 1));
+       loff_t end = min_t(loff_t, start + len, mtd->size);
+       size_t chunk = part->common.mtd.erasesize;
+       int rc = 0;
+
+       if (!part->updating) {
+               rc = efx_mcdi_nvram_update_start(efx, part->nvram_type);
+               if (rc)
+                       goto out;
+               part->updating = true;
+       }
+
+       /* The MCDI interface can in fact do multiple erase blocks at once;
+        * but erasing may be slow, so we make multiple calls here to avoid
+        * tripping the MCDI RPC timeout. */
+       while (offset < end) {
+               rc = efx_mcdi_nvram_erase(efx, part->nvram_type, offset,
+                                         chunk);
+               if (rc)
+                       goto out;
+               offset += chunk;
+       }
+out:
+       return rc;
+}
+
+int efx_mcdi_mtd_write(struct mtd_info *mtd, loff_t start,
+                      size_t len, size_t *retlen, const u8 *buffer)
+{
+       struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       loff_t offset = start;
+       loff_t end = min_t(loff_t, start + len, mtd->size);
+       size_t chunk;
+       int rc = 0;
+
+       if (!part->updating) {
+               rc = efx_mcdi_nvram_update_start(efx, part->nvram_type);
+               if (rc)
+                       goto out;
+               part->updating = true;
+       }
+
+       while (offset < end) {
+               chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX);
+               rc = efx_mcdi_nvram_write(efx, part->nvram_type, offset,
+                                         buffer, chunk);
+               if (rc)
+                       goto out;
+               offset += chunk;
+               buffer += chunk;
+       }
+out:
+       *retlen = offset - start;
+       return rc;
+}
+
+int efx_mcdi_mtd_sync(struct mtd_info *mtd)
+{
+       struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
+       struct efx_nic *efx = mtd->priv;
+       int rc = 0;
+
+       if (part->updating) {
+               part->updating = false;
+               rc = efx_mcdi_nvram_update_finish(efx, part->nvram_type);
+       }
+
+       return rc;
+}
+
+void efx_mcdi_mtd_rename(struct efx_mtd_partition *part)
+{
+       struct efx_mcdi_mtd_partition *mcdi_part =
+               container_of(part, struct efx_mcdi_mtd_partition, common);
+       struct efx_nic *efx = part->mtd.priv;
+
+       snprintf(part->name, sizeof(part->name), "%s %s:%02x",
+                efx->name, part->type_name, mcdi_part->fw_subtype);
+}
+
+#endif /* CONFIG_SFC_MTD */
index 3ba2e5b5a9cc98eac81a90c9b3d2e0e650b63af0..303d9e88a27f28e2bc04a9b9de19c909238c08f4 100644 (file)
 #define EFX_MCDI_H
 
 /**
- * enum efx_mcdi_state
+ * enum efx_mcdi_state - MCDI request handling state
  * @MCDI_STATE_QUIESCENT: No pending MCDI requests. If the caller holds the
- *     mcdi_lock then they are able to move to MCDI_STATE_RUNNING
+ *     mcdi @iface_lock then they are able to move to %MCDI_STATE_RUNNING
  * @MCDI_STATE_RUNNING: There is an MCDI request pending. Only the thread that
  *     moved into this state is allowed to move out of it.
  * @MCDI_STATE_COMPLETED: An MCDI request has completed, but the owning thread
  *     has not yet consumed the result. For all other threads, equivalent to
- *     MCDI_STATE_RUNNING.
+ *     %MCDI_STATE_RUNNING.
  */
 enum efx_mcdi_state {
        MCDI_STATE_QUIESCENT,
@@ -32,28 +32,30 @@ enum efx_mcdi_mode {
 };
 
 /**
- * struct efx_mcdi_iface
- * @state: Interface state. Waited for by mcdi_wq.
- * @wq: Wait queue for threads waiting for state != STATE_RUNNING
- * @iface_lock: Protects @credits, @seqno, @resprc, @resplen
+ * struct efx_mcdi_iface - MCDI protocol context
+ * @state: Request handling state. Waited for by @wq.
  * @mode: Poll for mcdi completion, or wait for an mcdi_event.
- *     Serialised by @lock
+ * @wq: Wait queue for threads waiting for @state != %MCDI_STATE_RUNNING
+ * @new_epoch: Indicates start of day or start of MC reboot recovery
+ * @iface_lock: Serialises access to all the following fields
  * @seqno: The next sequence number to use for mcdi requests.
- *     Serialised by @lock
  * @credits: Number of spurious MCDI completion events allowed before we
- *     trigger a fatal error. Protected by @lock
- * @resprc: Returned MCDI completion
- * @resplen: Returned payload length
+ *     trigger a fatal error
+ * @resprc: Response error/success code (Linux numbering)
+ * @resp_hdr_len: Response header length
+ * @resp_data_len: Response data (SDU or error) length
  */
 struct efx_mcdi_iface {
        atomic_t state;
+       enum efx_mcdi_mode mode;
        wait_queue_head_t wq;
        spinlock_t iface_lock;
-       enum efx_mcdi_mode mode;
+       bool new_epoch;
        unsigned int credits;
        unsigned int seqno;
-       unsigned int resprc;
-       size_t resplen;
+       int resprc;
+       size_t resp_hdr_len;
+       size_t resp_data_len;
 };
 
 struct efx_mcdi_mon {
@@ -65,18 +67,51 @@ struct efx_mcdi_mon {
        unsigned int n_attrs;
 };
 
-extern void efx_mcdi_init(struct efx_nic *efx);
+struct efx_mcdi_mtd_partition {
+       struct efx_mtd_partition common;
+       bool updating;
+       u8 nvram_type;
+       u16 fw_subtype;
+};
+
+#define to_efx_mcdi_mtd_partition(mtd)                         \
+       container_of(mtd, struct efx_mcdi_mtd_partition, common.mtd)
+
+/**
+ * struct efx_mcdi_data - extra state for NICs that implement MCDI
+ * @iface: Interface/protocol state
+ * @hwmon: Hardware monitor state
+ */
+struct efx_mcdi_data {
+       struct efx_mcdi_iface iface;
+#ifdef CONFIG_SFC_MCDI_MON
+       struct efx_mcdi_mon hwmon;
+#endif
+};
+
+#ifdef CONFIG_SFC_MCDI_MON
+static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx)
+{
+       EFX_BUG_ON_PARANOID(!efx->mcdi);
+       return &efx->mcdi->hwmon;
+}
+#endif
+
+extern int efx_mcdi_init(struct efx_nic *efx);
+extern void efx_mcdi_fini(struct efx_nic *efx);
 
-extern int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, const u8 *inbuf,
-                       size_t inlen, u8 *outbuf, size_t outlen,
+extern int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd,
+                       const efx_dword_t *inbuf, size_t inlen,
+                       efx_dword_t *outbuf, size_t outlen,
                        size_t *outlen_actual);
 
-extern void efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd,
-                              const u8 *inbuf, size_t inlen);
+extern int efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd,
+                             const efx_dword_t *inbuf, size_t inlen);
 extern int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
-                              u8 *outbuf, size_t outlen,
+                              efx_dword_t *outbuf, size_t outlen,
                               size_t *outlen_actual);
 
+
 extern int efx_mcdi_poll_reboot(struct efx_nic *efx);
 extern void efx_mcdi_mode_poll(struct efx_nic *efx);
 extern void efx_mcdi_mode_event(struct efx_nic *efx);
@@ -85,41 +120,136 @@ extern void efx_mcdi_process_event(struct efx_channel *channel,
                                   efx_qword_t *event);
 extern void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
 
-#define MCDI_PTR2(_buf, _ofst)                                         \
-       (((u8 *)_buf) + _ofst)
-#define MCDI_SET_DWORD2(_buf, _ofst, _value)                           \
-       EFX_POPULATE_DWORD_1(*((efx_dword_t *)MCDI_PTR2(_buf, _ofst)),  \
-                            EFX_DWORD_0, _value)
-#define MCDI_DWORD2(_buf, _ofst)                                       \
-       EFX_DWORD_FIELD(*((efx_dword_t *)MCDI_PTR2(_buf, _ofst)),       \
-                       EFX_DWORD_0)
-#define MCDI_QWORD2(_buf, _ofst)                                       \
-       EFX_QWORD_FIELD64(*((efx_qword_t *)MCDI_PTR2(_buf, _ofst)),     \
-                         EFX_QWORD_0)
-
-#define MCDI_PTR(_buf, _ofst)                                          \
-       MCDI_PTR2(_buf, MC_CMD_ ## _ofst ## _OFST)
-#define MCDI_ARRAY_PTR(_buf, _field, _type, _index)                    \
-       MCDI_PTR2(_buf,                                                 \
-                 MC_CMD_ ## _field ## _OFST +                          \
-                 (_index) * MC_CMD_ ## _type ## _TYPEDEF_LEN)
-#define MCDI_SET_DWORD(_buf, _ofst, _value)                            \
-       MCDI_SET_DWORD2(_buf, MC_CMD_ ## _ofst ## _OFST, _value)
-#define MCDI_DWORD(_buf, _ofst)                                                \
-       MCDI_DWORD2(_buf, MC_CMD_ ## _ofst ## _OFST)
-#define MCDI_QWORD(_buf, _ofst)                                                \
-       MCDI_QWORD2(_buf, MC_CMD_ ## _ofst ## _OFST)
+/* We expect that 16- and 32-bit fields in MCDI requests and responses
+ * are appropriately aligned, but 64-bit fields are only
+ * 32-bit-aligned.  Also, on Siena we must copy to the MC shared
+ * memory strictly 32 bits at a time, so add any necessary padding.
+ */
+#define MCDI_DECLARE_BUF(_name, _len)                                  \
+       efx_dword_t _name[DIV_ROUND_UP(_len, 4)]
+#define _MCDI_PTR(_buf, _offset)                                       \
+       ((u8 *)(_buf) + (_offset))
+#define MCDI_PTR(_buf, _field)                                         \
+       _MCDI_PTR(_buf, MC_CMD_ ## _field ## _OFST)
+#define _MCDI_CHECK_ALIGN(_ofst, _align)                               \
+       ((_ofst) + BUILD_BUG_ON_ZERO((_ofst) & (_align - 1)))
+#define _MCDI_DWORD(_buf, _field)                                      \
+       ((_buf) + (_MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, 4) >> 2))
+
+#define MCDI_SET_DWORD(_buf, _field, _value)                           \
+       EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0, _value)
+#define MCDI_DWORD(_buf, _field)                                       \
+       EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0)
+#define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1)           \
+       EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1)
+#define MCDI_POPULATE_DWORD_2(_buf, _field, _name1, _value1,           \
+                             _name2, _value2)                          \
+       EFX_POPULATE_DWORD_2(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1,                \
+                            MC_CMD_ ## _name2, _value2)
+#define MCDI_POPULATE_DWORD_3(_buf, _field, _name1, _value1,           \
+                             _name2, _value2, _name3, _value3)         \
+       EFX_POPULATE_DWORD_3(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1,                \
+                            MC_CMD_ ## _name2, _value2,                \
+                            MC_CMD_ ## _name3, _value3)
+#define MCDI_POPULATE_DWORD_4(_buf, _field, _name1, _value1,           \
+                             _name2, _value2, _name3, _value3,         \
+                             _name4, _value4)                          \
+       EFX_POPULATE_DWORD_4(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1,                \
+                            MC_CMD_ ## _name2, _value2,                \
+                            MC_CMD_ ## _name3, _value3,                \
+                            MC_CMD_ ## _name4, _value4)
+#define MCDI_POPULATE_DWORD_5(_buf, _field, _name1, _value1,           \
+                             _name2, _value2, _name3, _value3,         \
+                             _name4, _value4, _name5, _value5)         \
+       EFX_POPULATE_DWORD_5(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1,                \
+                            MC_CMD_ ## _name2, _value2,                \
+                            MC_CMD_ ## _name3, _value3,                \
+                            MC_CMD_ ## _name4, _value4,                \
+                            MC_CMD_ ## _name5, _value5)
+#define MCDI_POPULATE_DWORD_6(_buf, _field, _name1, _value1,           \
+                             _name2, _value2, _name3, _value3,         \
+                             _name4, _value4, _name5, _value5,         \
+                             _name6, _value6)                          \
+       EFX_POPULATE_DWORD_6(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1,                \
+                            MC_CMD_ ## _name2, _value2,                \
+                            MC_CMD_ ## _name3, _value3,                \
+                            MC_CMD_ ## _name4, _value4,                \
+                            MC_CMD_ ## _name5, _value5,                \
+                            MC_CMD_ ## _name6, _value6)
+#define MCDI_POPULATE_DWORD_7(_buf, _field, _name1, _value1,           \
+                             _name2, _value2, _name3, _value3,         \
+                             _name4, _value4, _name5, _value5,         \
+                             _name6, _value6, _name7, _value7)         \
+       EFX_POPULATE_DWORD_7(*_MCDI_DWORD(_buf, _field),                \
+                            MC_CMD_ ## _name1, _value1,                \
+                            MC_CMD_ ## _name2, _value2,                \
+                            MC_CMD_ ## _name3, _value3,                \
+                            MC_CMD_ ## _name4, _value4,                \
+                            MC_CMD_ ## _name5, _value5,                \
+                            MC_CMD_ ## _name6, _value6,                \
+                            MC_CMD_ ## _name7, _value7)
+#define MCDI_SET_QWORD(_buf, _field, _value)                           \
+       do {                                                            \
+               EFX_POPULATE_DWORD_1(_MCDI_DWORD(_buf, _field)[0],      \
+                                    EFX_DWORD_0, (u32)(_value));       \
+               EFX_POPULATE_DWORD_1(_MCDI_DWORD(_buf, _field)[1],      \
+                                    EFX_DWORD_0, (u64)(_value) >> 32); \
+       } while (0)
+#define MCDI_QWORD(_buf, _field)                                       \
+       (EFX_DWORD_FIELD(_MCDI_DWORD(_buf, _field)[0], EFX_DWORD_0) |   \
+       (u64)EFX_DWORD_FIELD(_MCDI_DWORD(_buf, _field)[1], EFX_DWORD_0) << 32)
+#define MCDI_FIELD(_ptr, _type, _field)                                        \
+       EFX_EXTRACT_DWORD(                                              \
+               *(efx_dword_t *)                                        \
+               _MCDI_PTR(_ptr, MC_CMD_ ## _type ## _ ## _field ## _OFST & ~3),\
+               MC_CMD_ ## _type ## _ ## _field ## _LBN & 0x1f, \
+               (MC_CMD_ ## _type ## _ ## _field ## _LBN & 0x1f) +      \
+               MC_CMD_ ## _type ## _ ## _field ## _WIDTH - 1)
+
+#define _MCDI_ARRAY_PTR(_buf, _field, _index, _align)                  \
+       (_MCDI_PTR(_buf, _MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, _align))\
+        + (_index) * _MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _LEN, _align))
+#define MCDI_DECLARE_STRUCT_PTR(_name)                                 \
+       efx_dword_t *_name
+#define MCDI_ARRAY_STRUCT_PTR(_buf, _field, _index)                    \
+       ((efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4))
+#define MCDI_VAR_ARRAY_LEN(_len, _field)                               \
+       min_t(size_t, MC_CMD_ ## _field ## _MAXNUM,                     \
+             ((_len) - MC_CMD_ ## _field ## _OFST) / MC_CMD_ ## _field ## _LEN)
+#define MCDI_ARRAY_WORD(_buf, _field, _index)                          \
+       (BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) +            \
+        le16_to_cpu(*(__force const __le16 *)                          \
+                    _MCDI_ARRAY_PTR(_buf, _field, _index, 2)))
+#define _MCDI_ARRAY_DWORD(_buf, _field, _index)                                \
+       (BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 4) +            \
+        (efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4))
+#define MCDI_SET_ARRAY_DWORD(_buf, _field, _index, _value)             \
+       EFX_SET_DWORD_FIELD(*_MCDI_ARRAY_DWORD(_buf, _field, _index),   \
+                           EFX_DWORD_0, _value)
+#define MCDI_ARRAY_DWORD(_buf, _field, _index)                         \
+       EFX_DWORD_FIELD(*_MCDI_ARRAY_DWORD(_buf, _field, _index), EFX_DWORD_0)
+#define _MCDI_ARRAY_QWORD(_buf, _field, _index)                                \
+       (BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 8) +            \
+        (efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4))
+#define MCDI_SET_ARRAY_QWORD(_buf, _field, _index, _value)             \
+       do {                                                            \
+               EFX_SET_DWORD_FIELD(_MCDI_ARRAY_QWORD(_buf, _field, _index)[0],\
+                                   EFX_DWORD_0, (u32)(_value));        \
+               EFX_SET_DWORD_FIELD(_MCDI_ARRAY_QWORD(_buf, _field, _index)[1],\
+                                   EFX_DWORD_0, (u64)(_value) >> 32);  \
+       } while (0)
+#define MCDI_ARRAY_FIELD(_buf, _field1, _type, _index, _field2)                \
+       MCDI_FIELD(MCDI_ARRAY_STRUCT_PTR(_buf, _field1, _index),        \
+                  _type ## _TYPEDEF, _field2)
 
 #define MCDI_EVENT_FIELD(_ev, _field)                  \
        EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
-#define MCDI_ARRAY_FIELD(_buf, _field1, _type, _index, _field2)                \
-       EFX_EXTRACT_DWORD(                                              \
-               *((efx_dword_t *)                                       \
-                 (MCDI_ARRAY_PTR(_buf, _field1, _type, _index) +       \
-                  (MC_CMD_ ## _type ## _TYPEDEF_ ## _field2 ## _OFST & ~3))), \
-               MC_CMD_ ## _type ## _TYPEDEF_ ## _field2 ## _LBN & 0x1f, \
-               (MC_CMD_ ## _type ## _TYPEDEF_ ## _field2 ## _LBN & 0x1f) + \
-               MC_CMD_ ## _type ## _TYPEDEF_ ## _field2 ## _WIDTH - 1)
 
 extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
 extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
@@ -132,34 +262,26 @@ extern int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out);
 extern int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type,
                               size_t *size_out, size_t *erase_size_out,
                               bool *protected_out);
-extern int efx_mcdi_nvram_update_start(struct efx_nic *efx,
-                                      unsigned int type);
-extern int efx_mcdi_nvram_read(struct efx_nic *efx, unsigned int type,
-                              loff_t offset, u8 *buffer, size_t length);
-extern int efx_mcdi_nvram_write(struct efx_nic *efx, unsigned int type,
-                               loff_t offset, const u8 *buffer,
-                               size_t length);
-#define EFX_MCDI_NVRAM_LEN_MAX 128
-extern int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type,
-                               loff_t offset, size_t length);
-extern int efx_mcdi_nvram_update_finish(struct efx_nic *efx,
-                                       unsigned int type);
 extern int efx_mcdi_nvram_test_all(struct efx_nic *efx);
 extern int efx_mcdi_handle_assertion(struct efx_nic *efx);
 extern void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode);
-extern int efx_mcdi_reset_port(struct efx_nic *efx);
-extern int efx_mcdi_reset_mc(struct efx_nic *efx);
 extern int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx,
                                         const u8 *mac, int *id_out);
 extern int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out);
 extern int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id);
 extern int efx_mcdi_wol_filter_reset(struct efx_nic *efx);
 extern int efx_mcdi_flush_rxqs(struct efx_nic *efx);
+extern int efx_mcdi_port_probe(struct efx_nic *efx);
+extern void efx_mcdi_port_remove(struct efx_nic *efx);
+extern int efx_mcdi_port_reconfigure(struct efx_nic *efx);
+extern void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev);
 extern int efx_mcdi_set_mac(struct efx_nic *efx);
-extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
-                             u32 dma_len, int enable, int clear);
-extern int efx_mcdi_mac_reconfigure(struct efx_nic *efx);
+#define EFX_MC_STATS_GENERATION_INVALID ((__force __le64)(-1))
+extern void efx_mcdi_mac_start_stats(struct efx_nic *efx);
+extern void efx_mcdi_mac_stop_stats(struct efx_nic *efx);
 extern bool efx_mcdi_mac_check_fault(struct efx_nic *efx);
+extern enum reset_type efx_mcdi_map_reset_reason(enum reset_type reason);
+extern int efx_mcdi_reset(struct efx_nic *efx, enum reset_type method);
 
 #ifdef CONFIG_SFC_MCDI_MON
 extern int efx_mcdi_mon_probe(struct efx_nic *efx);
@@ -169,4 +291,14 @@ static inline int efx_mcdi_mon_probe(struct efx_nic *efx) { return 0; }
 static inline void efx_mcdi_mon_remove(struct efx_nic *efx) {}
 #endif
 
+#ifdef CONFIG_SFC_MTD
+extern int efx_mcdi_mtd_read(struct mtd_info *mtd, loff_t start,
+                            size_t len, size_t *retlen, u8 *buffer);
+extern int efx_mcdi_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len);
+extern int efx_mcdi_mtd_write(struct mtd_info *mtd, loff_t start,
+                             size_t len, size_t *retlen, const u8 *buffer);
+extern int efx_mcdi_mtd_sync(struct mtd_info *mtd);
+extern void efx_mcdi_mtd_rename(struct efx_mtd_partition *part);
+#endif
+
 #endif /* EFX_MCDI_H */
diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c
deleted file mode 100644 (file)
index 1003f30..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2009-2010 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-#include "net_driver.h"
-#include "efx.h"
-#include "mcdi.h"
-#include "mcdi_pcol.h"
-
-int efx_mcdi_set_mac(struct efx_nic *efx)
-{
-       u32 reject, fcntl;
-       u8 cmdbytes[MC_CMD_SET_MAC_IN_LEN];
-
-       memcpy(cmdbytes + MC_CMD_SET_MAC_IN_ADDR_OFST,
-              efx->net_dev->dev_addr, ETH_ALEN);
-
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU,
-                       EFX_MAX_FRAME_LEN(efx->net_dev->mtu));
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_DRAIN, 0);
-
-       /* The MCDI command provides for controlling accept/reject
-        * of broadcast packets too, but the driver doesn't currently
-        * expose this. */
-       reject = (efx->promiscuous) ? 0 :
-               (1 << MC_CMD_SET_MAC_IN_REJECT_UNCST_LBN);
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_REJECT, reject);
-
-       switch (efx->wanted_fc) {
-       case EFX_FC_RX | EFX_FC_TX:
-               fcntl = MC_CMD_FCNTL_BIDIR;
-               break;
-       case EFX_FC_RX:
-               fcntl = MC_CMD_FCNTL_RESPOND;
-               break;
-       default:
-               fcntl = MC_CMD_FCNTL_OFF;
-               break;
-       }
-       if (efx->wanted_fc & EFX_FC_AUTO)
-               fcntl = MC_CMD_FCNTL_AUTO;
-       if (efx->fc_disable)
-               fcntl = MC_CMD_FCNTL_OFF;
-
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl);
-
-       return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes),
-                           NULL, 0, NULL);
-}
-
-bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
-{
-       u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
-       size_t outlength;
-       int rc;
-
-       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
-                         outbuf, sizeof(outbuf), &outlength);
-       if (rc) {
-               netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
-                         __func__, rc);
-               return true;
-       }
-
-       return MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT) != 0;
-}
-
-int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
-                      u32 dma_len, int enable, int clear)
-{
-       u8 inbuf[MC_CMD_MAC_STATS_IN_LEN];
-       int rc;
-       efx_dword_t *cmd_ptr;
-       int period = enable ? 1000 : 0;
-       u32 addr_hi;
-       u32 addr_lo;
-
-       BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_DMA_LEN != 0);
-
-       addr_lo = ((u64)dma_addr) >> 0;
-       addr_hi = ((u64)dma_addr) >> 32;
-
-       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_LO, addr_lo);
-       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_HI, addr_hi);
-       cmd_ptr = (efx_dword_t *)MCDI_PTR(inbuf, MAC_STATS_IN_CMD);
-       EFX_POPULATE_DWORD_7(*cmd_ptr,
-                            MC_CMD_MAC_STATS_IN_DMA, !!enable,
-                            MC_CMD_MAC_STATS_IN_CLEAR, clear,
-                            MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE, 1,
-                            MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE, !!enable,
-                            MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR, 0,
-                            MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT, 1,
-                            MC_CMD_MAC_STATS_IN_PERIOD_MS, period);
-       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
-                         NULL, 0, NULL);
-       if (rc)
-               goto fail;
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: %s failed rc=%d\n",
-                 __func__, enable ? "enable" : "disable", rc);
-       return rc;
-}
-
-int efx_mcdi_mac_reconfigure(struct efx_nic *efx)
-{
-       int rc;
-
-       WARN_ON(!mutex_is_locked(&efx->mac_lock));
-
-       rc = efx_mcdi_set_mac(efx);
-       if (rc != 0)
-               return rc;
-
-       return efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH,
-                           efx->multicast_hash.byte,
-                           sizeof(efx->multicast_hash),
-                           NULL, 0, NULL);
-}
index 1d552f0664d71268d9f57cb6953519f550c4de75..d7d45662d684100d903d0a109e2cd0f302b75936 100644 (file)
@@ -28,7 +28,7 @@ static const struct {
        const char *label;
        enum efx_hwmon_type hwmon_type;
        int port;
-} efx_mcdi_sensor_type[MC_CMD_SENSOR_ENTRY_MAXNUM] = {
+} efx_mcdi_sensor_type[] = {
 #define SENSOR(name, label, hwmon_type, port)                  \
        [MC_CMD_SENSOR_##name] = { label, hwmon_type, port }
        SENSOR(CONTROLLER_TEMP,    "Controller temp.",     EFX_HWMON_TEMP, -1),
@@ -54,6 +54,7 @@ static const char *const sensor_status_names[] = {
        [MC_CMD_SENSOR_STATE_WARNING] = "Warning",
        [MC_CMD_SENSOR_STATE_FATAL] = "Fatal",
        [MC_CMD_SENSOR_STATE_BROKEN] = "Device failure",
+       [MC_CMD_SENSOR_STATE_NO_READING] = "No reading",
 };
 
 void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
@@ -85,6 +86,7 @@ struct efx_mcdi_mon_attribute {
        struct device_attribute dev_attr;
        unsigned int index;
        unsigned int type;
+       enum efx_hwmon_type hwmon_type;
        unsigned int limit_value;
        char name[12];
 };
@@ -92,13 +94,12 @@ struct efx_mcdi_mon_attribute {
 static int efx_mcdi_mon_update(struct efx_nic *efx)
 {
        struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
-       u8 inbuf[MC_CMD_READ_SENSORS_IN_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_READ_SENSORS_EXT_IN_LEN);
        int rc;
 
-       MCDI_SET_DWORD(inbuf, READ_SENSORS_IN_DMA_ADDR_LO,
-                      hwmon->dma_buf.dma_addr & 0xffffffff);
-       MCDI_SET_DWORD(inbuf, READ_SENSORS_IN_DMA_ADDR_HI,
-                      (u64)hwmon->dma_buf.dma_addr >> 32);
+       MCDI_SET_QWORD(inbuf, READ_SENSORS_EXT_IN_DMA_ADDR,
+                      hwmon->dma_buf.dma_addr);
+       MCDI_SET_DWORD(inbuf, READ_SENSORS_EXT_IN_LENGTH, hwmon->dma_buf.len);
 
        rc = efx_mcdi_rpc(efx, MC_CMD_READ_SENSORS,
                          inbuf, sizeof(inbuf), NULL, 0, NULL);
@@ -146,17 +147,21 @@ static ssize_t efx_mcdi_mon_show_value(struct device *dev,
        struct efx_mcdi_mon_attribute *mon_attr =
                container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
        efx_dword_t entry;
-       unsigned int value;
+       unsigned int value, state;
        int rc;
 
        rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry);
        if (rc)
                return rc;
 
+       state = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE);
+       if (state == MC_CMD_SENSOR_STATE_NO_READING)
+               return -EBUSY;
+
        value = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE);
 
        /* Convert temperature from degrees to milli-degrees Celsius */
-       if (efx_mcdi_sensor_type[mon_attr->type].hwmon_type == EFX_HWMON_TEMP)
+       if (mon_attr->hwmon_type == EFX_HWMON_TEMP)
                value *= 1000;
 
        return sprintf(buf, "%u\n", value);
@@ -173,7 +178,7 @@ static ssize_t efx_mcdi_mon_show_limit(struct device *dev,
        value = mon_attr->limit_value;
 
        /* Convert temperature from degrees to milli-degrees Celsius */
-       if (efx_mcdi_sensor_type[mon_attr->type].hwmon_type == EFX_HWMON_TEMP)
+       if (mon_attr->hwmon_type == EFX_HWMON_TEMP)
                value *= 1000;
 
        return sprintf(buf, "%u\n", value);
@@ -221,6 +226,10 @@ efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name,
        strlcpy(attr->name, name, sizeof(attr->name));
        attr->index = index;
        attr->type = type;
+       if (type < ARRAY_SIZE(efx_mcdi_sensor_type))
+               attr->hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
+       else
+               attr->hwmon_type = EFX_HWMON_UNKNOWN;
        attr->limit_value = limit_value;
        sysfs_attr_init(&attr->dev_attr.attr);
        attr->dev_attr.attr.name = attr->name;
@@ -235,35 +244,42 @@ efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name,
 int efx_mcdi_mon_probe(struct efx_nic *efx)
 {
        struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
-       unsigned int n_attrs, n_temp = 0, n_cool = 0, n_in = 0;
-       u8 outbuf[MC_CMD_SENSOR_INFO_OUT_LENMAX];
+       unsigned int n_temp = 0, n_cool = 0, n_in = 0;
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_SENSOR_INFO_EXT_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_SENSOR_INFO_OUT_LENMAX);
+       unsigned int n_pages, n_sensors, n_attrs, page;
        size_t outlen;
        char name[12];
        u32 mask;
-       int rc, i, type;
+       int rc, i, j, type;
 
-       BUILD_BUG_ON(MC_CMD_SENSOR_INFO_IN_LEN != 0);
+       /* Find out how many sensors are present */
+       n_sensors = 0;
+       page = 0;
+       do {
+               MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE, page);
 
-       rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO, NULL, 0,
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               return rc;
-       if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN)
-               return -EIO;
-
-       /* Find out which sensors are present.  Don't create a device
-        * if there are none.
-        */
-       mask = MCDI_DWORD(outbuf, SENSOR_INFO_OUT_MASK);
-       if (mask == 0)
+               rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO, inbuf, sizeof(inbuf),
+                                 outbuf, sizeof(outbuf), &outlen);
+               if (rc)
+                       return rc;
+               if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN)
+                       return -EIO;
+
+               mask = MCDI_DWORD(outbuf, SENSOR_INFO_OUT_MASK);
+               n_sensors += hweight32(mask & ~(1 << MC_CMD_SENSOR_PAGE0_NEXT));
+               ++page;
+       } while (mask & (1 << MC_CMD_SENSOR_PAGE0_NEXT));
+       n_pages = page;
+
+       /* Don't create a device if there are none */
+       if (n_sensors == 0)
                return 0;
 
-       /* Check again for short response */
-       if (outlen < MC_CMD_SENSOR_INFO_OUT_LEN(hweight32(mask)))
-               return -EIO;
-
-       rc = efx_nic_alloc_buffer(efx, &hwmon->dma_buf,
-                                 4 * MC_CMD_SENSOR_ENTRY_MAXNUM);
+       rc = efx_nic_alloc_buffer(
+               efx, &hwmon->dma_buf,
+               n_sensors * MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN,
+               GFP_KERNEL);
        if (rc)
                return rc;
 
@@ -274,7 +290,7 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
         * attributes for this set of sensors: name of the driver plus
         * value, min, max, crit, alarm and label for each sensor.
         */
-       n_attrs = 1 + 6 * hweight32(mask);
+       n_attrs = 1 + 6 * n_sensors;
        hwmon->attrs = kcalloc(n_attrs, sizeof(*hwmon->attrs), GFP_KERNEL);
        if (!hwmon->attrs) {
                rc = -ENOMEM;
@@ -291,26 +307,63 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
        if (rc)
                goto fail;
 
-       for (i = 0, type = -1; ; i++) {
+       for (i = 0, j = -1, type = -1; ; i++) {
+               enum efx_hwmon_type hwmon_type;
                const char *hwmon_prefix;
                unsigned hwmon_index;
                u16 min1, max1, min2, max2;
 
                /* Find next sensor type or exit if there is none */
-               type++;
-               while (!(mask & (1 << type))) {
+               do {
                        type++;
-                       if (type == 32)
-                               return 0;
-               }
 
-               /* Skip sensors specific to a different port */
-               if (efx_mcdi_sensor_type[type].hwmon_type != EFX_HWMON_UNKNOWN &&
-                   efx_mcdi_sensor_type[type].port >= 0 &&
-                   efx_mcdi_sensor_type[type].port != efx_port_num(efx))
-                       continue;
+                       if ((type % 32) == 0) {
+                               page = type / 32;
+                               j = -1;
+                               if (page == n_pages)
+                                       return 0;
+
+                               MCDI_SET_DWORD(inbuf, SENSOR_INFO_EXT_IN_PAGE,
+                                              page);
+                               rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO,
+                                                 inbuf, sizeof(inbuf),
+                                                 outbuf, sizeof(outbuf),
+                                                 &outlen);
+                               if (rc)
+                                       goto fail;
+                               if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN) {
+                                       rc = -EIO;
+                                       goto fail;
+                               }
+
+                               mask = (MCDI_DWORD(outbuf,
+                                                  SENSOR_INFO_OUT_MASK) &
+                                       ~(1 << MC_CMD_SENSOR_PAGE0_NEXT));
 
-               switch (efx_mcdi_sensor_type[type].hwmon_type) {
+                               /* Check again for short response */
+                               if (outlen <
+                                   MC_CMD_SENSOR_INFO_OUT_LEN(hweight32(mask))) {
+                                       rc = -EIO;
+                                       goto fail;
+                               }
+                       }
+               } while (!(mask & (1 << type % 32)));
+               j++;
+
+               if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) {
+                       hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
+
+                       /* Skip sensors specific to a different port */
+                       if (hwmon_type != EFX_HWMON_UNKNOWN &&
+                           efx_mcdi_sensor_type[type].port >= 0 &&
+                           efx_mcdi_sensor_type[type].port !=
+                           efx_port_num(efx))
+                               continue;
+               } else {
+                       hwmon_type = EFX_HWMON_UNKNOWN;
+               }
+
+               switch (hwmon_type) {
                case EFX_HWMON_TEMP:
                        hwmon_prefix = "temp";
                        hwmon_index = ++n_temp; /* 1-based */
@@ -330,13 +383,13 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
                }
 
                min1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
-                                       SENSOR_INFO_ENTRY, i, MIN1);
+                                       SENSOR_INFO_ENTRY, j, MIN1);
                max1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
-                                       SENSOR_INFO_ENTRY, i, MAX1);
+                                       SENSOR_INFO_ENTRY, j, MAX1);
                min2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
-                                       SENSOR_INFO_ENTRY, i, MIN2);
+                                       SENSOR_INFO_ENTRY, j, MIN2);
                max2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
-                                       SENSOR_INFO_ENTRY, i, MAX2);
+                                       SENSOR_INFO_ENTRY, j, MAX2);
 
                if (min1 != max1) {
                        snprintf(name, sizeof(name), "%s%u_input",
@@ -383,7 +436,8 @@ int efx_mcdi_mon_probe(struct efx_nic *efx)
                if (rc)
                        goto fail;
 
-               if (efx_mcdi_sensor_type[type].label) {
+               if (type < ARRAY_SIZE(efx_mcdi_sensor_type) &&
+                   efx_mcdi_sensor_type[type].label) {
                        snprintf(name, sizeof(name), "%s%u_label",
                                 hwmon_prefix, hwmon_index);
                        rc = efx_mcdi_mon_add_attr(
@@ -400,8 +454,7 @@ fail:
 
 void efx_mcdi_mon_remove(struct efx_nic *efx)
 {
-       struct siena_nic_data *nic_data = efx->nic_data;
-       struct efx_mcdi_mon *hwmon = &nic_data->hwmon;
+       struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
        unsigned int i;
 
        for (i = 0; i < hwmon->n_attrs; i++)
index c5c9747861bac39e73b8b2a576078746403af2a7..9e824f74e8a1f6402f10d4c36d835e19f4c4e0bb 100644 (file)
@@ -1,6 +1,6 @@
 /****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2009-2011 Solarflare Communications Inc.
+ * Driver for Solarflare network controllers and boards
+ * Copyright 2009-2013 Solarflare Communications Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
 #define MC_FW_STATE_BOOTING (4)
 /* The Scheduler has started. */
 #define MC_FW_STATE_SCHED (8)
+/* If this is set in MC_RESET_STATE_REG then it should be
+ * possible to jump into IMEM without loading code from flash.
+ * Unlike a warm boot, assume DMEM has been reloaded, so that
+ * the MC persistent data must be reinitialised. */
+#define MC_FW_TEPID_BOOT_OK (16)
+/* BIST state has been initialized */
+#define MC_FW_BIST_INIT_OK (128)
 
 /* Siena MC shared memmory offsets */
 /* The 'doorbell' addresses are hard-wired to alert the MC when written */
 #define MC_STATUS_DWORD_REBOOT (0xb007b007)
 #define MC_STATUS_DWORD_ASSERT (0xdeaddead)
 
+/* Check whether an mcfw version (in host order) belongs to a bootloader */
+#define MC_FW_VERSION_IS_BOOTLOADER(_v) (((_v) >> 16) == 0xb007)
+
 /* The current version of the MCDI protocol.
  *
  * Note that the ROM burnt into the card only talks V0, so at the very
  * least every driver must support version 0 and MCDI_PCOL_VERSION
  */
-#define MCDI_PCOL_VERSION 1
+#define MCDI_PCOL_VERSION 2
 
 /* Unused commands: 0x23, 0x27, 0x30, 0x31 */
 
 /* MCDI version 1
  *
- * Each MCDI request starts with an MCDI_HEADER, which is a 32byte
+ * Each MCDI request starts with an MCDI_HEADER, which is a 32bit
  * structure, filled in by the client.
  *
  *       0       7  8     16    20     22  23  24    31
 #define MCDI_HEADER_DATALEN_LBN 8
 #define MCDI_HEADER_DATALEN_WIDTH 8
 #define MCDI_HEADER_SEQ_LBN 16
-#define MCDI_HEADER_RSVD_LBN 20
-#define MCDI_HEADER_RSVD_WIDTH 2
 #define MCDI_HEADER_SEQ_WIDTH 4
+#define MCDI_HEADER_RSVD_LBN 20
+#define MCDI_HEADER_RSVD_WIDTH 1
+#define MCDI_HEADER_NOT_EPOCH_LBN 21
+#define MCDI_HEADER_NOT_EPOCH_WIDTH 1
 #define MCDI_HEADER_ERROR_LBN 22
 #define MCDI_HEADER_ERROR_WIDTH 1
 #define MCDI_HEADER_RESPONSE_LBN 23
 #define MCDI_HEADER_XFLAGS_EVREQ 0x01
 
 /* Maximum number of payload bytes */
-#define MCDI_CTL_SDU_LEN_MAX 0xfc
+#define MCDI_CTL_SDU_LEN_MAX_V1 0xfc
+#define MCDI_CTL_SDU_LEN_MAX_V2 0x400
+
+#define MCDI_CTL_SDU_LEN_MAX MCDI_CTL_SDU_LEN_MAX_V2
+
 
 /* The MC can generate events for two reasons:
  *   - To complete a shared memory request if XFLAGS_EVREQ was set
 #define FSE_AZ_EV_CODE_MCDI_EVRESPONSE 0xc
 
 
+/* Operation not permitted. */
+#define MC_CMD_ERR_EPERM 1
 /* Non-existent command target */
 #define MC_CMD_ERR_ENOENT 2
 /* assert() has killed the MC */
 #define MC_CMD_ERR_EINTR 4
+/* I/O failure */
+#define MC_CMD_ERR_EIO 5
+/* Try again */
+#define MC_CMD_ERR_EAGAIN 11
+/* Out of memory */
+#define MC_CMD_ERR_ENOMEM 12
 /* Caller does not hold required locks */
 #define MC_CMD_ERR_EACCES 13
 /* Resource is currently unavailable (e.g. lock contention) */
 #define MC_CMD_ERR_EBUSY 16
+/* No such device */
+#define MC_CMD_ERR_ENODEV 19
 /* Invalid argument to target */
 #define MC_CMD_ERR_EINVAL 22
+/* Out of range */
+#define MC_CMD_ERR_ERANGE 34
 /* Non-recursive resource is already acquired */
 #define MC_CMD_ERR_EDEADLK 35
 /* Operation not implemented */
 #define MC_CMD_ERR_ENOSYS 38
 /* Operation timed out */
 #define MC_CMD_ERR_ETIME 62
+/* Link has been severed */
+#define MC_CMD_ERR_ENOLINK 67
+/* Protocol error */
+#define MC_CMD_ERR_EPROTO 71
+/* Operation not supported */
+#define MC_CMD_ERR_ENOTSUP 95
+/* Address not available */
+#define MC_CMD_ERR_EADDRNOTAVAIL 99
+/* Not connected */
+#define MC_CMD_ERR_ENOTCONN 107
+/* Operation already in progress */
+#define MC_CMD_ERR_EALREADY 114
+
+/* Resource allocation failed. */
+#define MC_CMD_ERR_ALLOC_FAIL  0x1000
+/* V-adaptor not found. */
+#define MC_CMD_ERR_NO_VADAPTOR 0x1001
+/* EVB port not found. */
+#define MC_CMD_ERR_NO_EVB_PORT 0x1002
+/* V-switch not found. */
+#define MC_CMD_ERR_NO_VSWITCH  0x1003
+/* Too many VLAN tags. */
+#define MC_CMD_ERR_VLAN_LIMIT  0x1004
+/* Bad PCI function number. */
+#define MC_CMD_ERR_BAD_PCI_FUNC 0x1005
+/* Invalid VLAN mode. */
+#define MC_CMD_ERR_BAD_VLAN_MODE 0x1006
+/* Invalid v-switch type. */
+#define MC_CMD_ERR_BAD_VSWITCH_TYPE 0x1007
+/* Invalid v-port type. */
+#define MC_CMD_ERR_BAD_VPORT_TYPE 0x1008
+/* MAC address exists. */
+#define MC_CMD_ERR_MAC_EXIST 0x1009
+/* Slave core not present */
+#define MC_CMD_ERR_SLAVE_NOT_PRESENT 0x100a
 
 #define MC_CMD_ERR_CODE_OFST 0
 
 
 /* Vectors in the boot ROM */
 /* Point to the copycode entry point. */
-#define MC_BOOTROM_COPYCODE_VEC (0x7f4)
+#define SIENA_MC_BOOTROM_COPYCODE_VEC (0x800 - 3 * 0x4)
+#define HUNT_MC_BOOTROM_COPYCODE_VEC (0x8000 - 3 * 0x4)
 /* Points to the recovery mode entry point. */
-#define MC_BOOTROM_NOFLASH_VEC (0x7f8)
+#define SIENA_MC_BOOTROM_NOFLASH_VEC (0x800 - 2 * 0x4)
+#define HUNT_MC_BOOTROM_NOFLASH_VEC (0x8000 - 2 * 0x4)
 
 /* The command set exported by the boot ROM (MCDI v0) */
 #define MC_CMD_GET_VERSION_V0_SUPPORTED_FUNCS {                \
         (n) * MC_CMD_DBIWROP_TYPEDEF_LEN)
 
 
+/* Version 2 adds an optional argument to error returns: the errno value
+ * may be followed by the (0-based) number of the first argument that
+ * could not be processed.
+ */
+#define MC_CMD_ERR_ARG_OFST 4
+
+/* No space */
+#define MC_CMD_ERR_ENOSPC 28
+
 /* MCDI_EVENT structuredef */
 #define    MCDI_EVENT_LEN 8
 #define       MCDI_EVENT_CONT_LBN 32
 #define       MCDI_EVENT_CONT_WIDTH 1
 #define       MCDI_EVENT_LEVEL_LBN 33
 #define       MCDI_EVENT_LEVEL_WIDTH 3
-#define          MCDI_EVENT_LEVEL_INFO  0x0 /* enum */
-#define          MCDI_EVENT_LEVEL_WARN 0x1 /* enum */
-#define          MCDI_EVENT_LEVEL_ERR 0x2 /* enum */
-#define          MCDI_EVENT_LEVEL_FATAL 0x3 /* enum */
+/* enum: Info. */
+#define          MCDI_EVENT_LEVEL_INFO  0x0
+/* enum: Warning. */
+#define          MCDI_EVENT_LEVEL_WARN 0x1
+/* enum: Error. */
+#define          MCDI_EVENT_LEVEL_ERR 0x2
+/* enum: Fatal. */
+#define          MCDI_EVENT_LEVEL_FATAL 0x3
 #define       MCDI_EVENT_DATA_OFST 0
 #define        MCDI_EVENT_CMDDONE_SEQ_LBN 0
 #define        MCDI_EVENT_CMDDONE_SEQ_WIDTH 8
 #define        MCDI_EVENT_LINKCHANGE_LP_CAP_WIDTH 16
 #define        MCDI_EVENT_LINKCHANGE_SPEED_LBN 16
 #define        MCDI_EVENT_LINKCHANGE_SPEED_WIDTH 4
-#define          MCDI_EVENT_LINKCHANGE_SPEED_100M  0x1 /* enum */
-#define          MCDI_EVENT_LINKCHANGE_SPEED_1G  0x2 /* enum */
-#define          MCDI_EVENT_LINKCHANGE_SPEED_10G  0x3 /* enum */
+/* enum: 100Mbs */
+#define          MCDI_EVENT_LINKCHANGE_SPEED_100M  0x1
+/* enum: 1Gbs */
+#define          MCDI_EVENT_LINKCHANGE_SPEED_1G  0x2
+/* enum: 10Gbs */
+#define          MCDI_EVENT_LINKCHANGE_SPEED_10G  0x3
+/* enum: 40Gbs */
+#define          MCDI_EVENT_LINKCHANGE_SPEED_40G  0x4
 #define        MCDI_EVENT_LINKCHANGE_FCNTL_LBN 20
 #define        MCDI_EVENT_LINKCHANGE_FCNTL_WIDTH 4
 #define        MCDI_EVENT_LINKCHANGE_LINK_FLAGS_LBN 24
 #define        MCDI_EVENT_FWALERT_DATA_WIDTH 24
 #define        MCDI_EVENT_FWALERT_REASON_LBN 0
 #define        MCDI_EVENT_FWALERT_REASON_WIDTH 8
-#define          MCDI_EVENT_FWALERT_REASON_SRAM_ACCESS 0x1 /* enum */
+/* enum: SRAM Access. */
+#define          MCDI_EVENT_FWALERT_REASON_SRAM_ACCESS 0x1
 #define        MCDI_EVENT_FLR_VF_LBN 0
 #define        MCDI_EVENT_FLR_VF_WIDTH 8
 #define        MCDI_EVENT_TX_ERR_TXQ_LBN 0
 #define        MCDI_EVENT_TX_ERR_TXQ_WIDTH 12
 #define        MCDI_EVENT_TX_ERR_TYPE_LBN 12
 #define        MCDI_EVENT_TX_ERR_TYPE_WIDTH 4
-#define          MCDI_EVENT_TX_ERR_DL_FAIL 0x1 /* enum */
-#define          MCDI_EVENT_TX_ERR_NO_EOP 0x2 /* enum */
-#define          MCDI_EVENT_TX_ERR_2BIG 0x3 /* enum */
+/* enum: Descriptor loader reported failure */
+#define          MCDI_EVENT_TX_ERR_DL_FAIL 0x1
+/* enum: Descriptor ring empty and no EOP seen for packet */
+#define          MCDI_EVENT_TX_ERR_NO_EOP 0x2
+/* enum: Overlength packet */
+#define          MCDI_EVENT_TX_ERR_2BIG 0x3
+/* enum: Malformed option descriptor */
+#define          MCDI_EVENT_TX_BAD_OPTDESC 0x5
+/* enum: Option descriptor part way through a packet */
+#define          MCDI_EVENT_TX_OPT_IN_PKT 0x8
+/* enum: DMA or PIO data access error */
+#define          MCDI_EVENT_TX_ERR_BAD_DMA_OR_PIO 0x9
 #define        MCDI_EVENT_TX_ERR_INFO_LBN 16
 #define        MCDI_EVENT_TX_ERR_INFO_WIDTH 16
+#define        MCDI_EVENT_TX_FLUSH_TO_DRIVER_LBN 12
+#define        MCDI_EVENT_TX_FLUSH_TO_DRIVER_WIDTH 1
 #define        MCDI_EVENT_TX_FLUSH_TXQ_LBN 0
 #define        MCDI_EVENT_TX_FLUSH_TXQ_WIDTH 12
 #define        MCDI_EVENT_PTP_ERR_TYPE_LBN 0
 #define        MCDI_EVENT_PTP_ERR_TYPE_WIDTH 8
-#define          MCDI_EVENT_PTP_ERR_PLL_LOST 0x1 /* enum */
-#define          MCDI_EVENT_PTP_ERR_FILTER 0x2 /* enum */
-#define          MCDI_EVENT_PTP_ERR_FIFO 0x3 /* enum */
-#define          MCDI_EVENT_PTP_ERR_QUEUE 0x4 /* enum */
+/* enum: PLL lost lock */
+#define          MCDI_EVENT_PTP_ERR_PLL_LOST 0x1
+/* enum: Filter overflow (PDMA) */
+#define          MCDI_EVENT_PTP_ERR_FILTER 0x2
+/* enum: FIFO overflow (FPGA) */
+#define          MCDI_EVENT_PTP_ERR_FIFO 0x3
+/* enum: Merge queue overflow */
+#define          MCDI_EVENT_PTP_ERR_QUEUE 0x4
+#define        MCDI_EVENT_AOE_ERR_TYPE_LBN 0
+#define        MCDI_EVENT_AOE_ERR_TYPE_WIDTH 8
+/* enum: AOE failed to load - no valid image? */
+#define          MCDI_EVENT_AOE_NO_LOAD 0x1
+/* enum: AOE FC reported an exception */
+#define          MCDI_EVENT_AOE_FC_ASSERT 0x2
+/* enum: AOE FC watchdogged */
+#define          MCDI_EVENT_AOE_FC_WATCHDOG 0x3
+/* enum: AOE FC failed to start */
+#define          MCDI_EVENT_AOE_FC_NO_START 0x4
+/* enum: Generic AOE fault - likely to have been reported via other means too
+ * but intended for use by aoex driver.
+ */
+#define          MCDI_EVENT_AOE_FAULT 0x5
+/* enum: Results of reprogramming the CPLD (status in AOE_ERR_DATA) */
+#define          MCDI_EVENT_AOE_CPLD_REPROGRAMMED 0x6
+/* enum: AOE loaded successfully */
+#define          MCDI_EVENT_AOE_LOAD 0x7
+/* enum: AOE DMA operation completed (LSB of HOST_HANDLE in AOE_ERR_DATA) */
+#define          MCDI_EVENT_AOE_DMA 0x8
+/* enum: AOE byteblaster connected/disconnected (Connection status in
+ * AOE_ERR_DATA)
+ */
+#define          MCDI_EVENT_AOE_BYTEBLASTER 0x9
+#define        MCDI_EVENT_AOE_ERR_DATA_LBN 8
+#define        MCDI_EVENT_AOE_ERR_DATA_WIDTH 8
+#define        MCDI_EVENT_RX_ERR_RXQ_LBN 0
+#define        MCDI_EVENT_RX_ERR_RXQ_WIDTH 12
+#define        MCDI_EVENT_RX_ERR_TYPE_LBN 12
+#define        MCDI_EVENT_RX_ERR_TYPE_WIDTH 4
+#define        MCDI_EVENT_RX_ERR_INFO_LBN 16
+#define        MCDI_EVENT_RX_ERR_INFO_WIDTH 16
+#define        MCDI_EVENT_RX_FLUSH_TO_DRIVER_LBN 12
+#define        MCDI_EVENT_RX_FLUSH_TO_DRIVER_WIDTH 1
+#define        MCDI_EVENT_RX_FLUSH_RXQ_LBN 0
+#define        MCDI_EVENT_RX_FLUSH_RXQ_WIDTH 12
+#define        MCDI_EVENT_MC_REBOOT_COUNT_LBN 0
+#define        MCDI_EVENT_MC_REBOOT_COUNT_WIDTH 16
 #define       MCDI_EVENT_DATA_LBN 0
 #define       MCDI_EVENT_DATA_WIDTH 32
 #define       MCDI_EVENT_SRC_LBN 36
 #define       MCDI_EVENT_EV_CODE_WIDTH 4
 #define       MCDI_EVENT_CODE_LBN 44
 #define       MCDI_EVENT_CODE_WIDTH 8
-#define          MCDI_EVENT_CODE_BADSSERT 0x1 /* enum */
-#define          MCDI_EVENT_CODE_PMNOTICE 0x2 /* enum */
-#define          MCDI_EVENT_CODE_CMDDONE 0x3 /* enum */
-#define          MCDI_EVENT_CODE_LINKCHANGE 0x4 /* enum */
-#define          MCDI_EVENT_CODE_SENSOREVT 0x5 /* enum */
-#define          MCDI_EVENT_CODE_SCHEDERR 0x6 /* enum */
-#define          MCDI_EVENT_CODE_REBOOT 0x7 /* enum */
-#define          MCDI_EVENT_CODE_MAC_STATS_DMA 0x8 /* enum */
-#define          MCDI_EVENT_CODE_FWALERT 0x9 /* enum */
-#define          MCDI_EVENT_CODE_FLR 0xa /* enum */
-#define          MCDI_EVENT_CODE_TX_ERR 0xb /* enum */
-#define          MCDI_EVENT_CODE_TX_FLUSH  0xc /* enum */
-#define          MCDI_EVENT_CODE_PTP_RX  0xd /* enum */
-#define          MCDI_EVENT_CODE_PTP_FAULT  0xe /* enum */
-#define          MCDI_EVENT_CODE_PTP_PPS  0xf /* enum */
+/* enum: Bad assert. */
+#define          MCDI_EVENT_CODE_BADSSERT 0x1
+/* enum: PM Notice. */
+#define          MCDI_EVENT_CODE_PMNOTICE 0x2
+/* enum: Command done. */
+#define          MCDI_EVENT_CODE_CMDDONE 0x3
+/* enum: Link change. */
+#define          MCDI_EVENT_CODE_LINKCHANGE 0x4
+/* enum: Sensor Event. */
+#define          MCDI_EVENT_CODE_SENSOREVT 0x5
+/* enum: Schedule error. */
+#define          MCDI_EVENT_CODE_SCHEDERR 0x6
+/* enum: Reboot. */
+#define          MCDI_EVENT_CODE_REBOOT 0x7
+/* enum: Mac stats DMA. */
+#define          MCDI_EVENT_CODE_MAC_STATS_DMA 0x8
+/* enum: Firmware alert. */
+#define          MCDI_EVENT_CODE_FWALERT 0x9
+/* enum: Function level reset. */
+#define          MCDI_EVENT_CODE_FLR 0xa
+/* enum: Transmit error */
+#define          MCDI_EVENT_CODE_TX_ERR 0xb
+/* enum: Tx flush has completed */
+#define          MCDI_EVENT_CODE_TX_FLUSH  0xc
+/* enum: PTP packet received timestamp */
+#define          MCDI_EVENT_CODE_PTP_RX  0xd
+/* enum: PTP NIC failure */
+#define          MCDI_EVENT_CODE_PTP_FAULT  0xe
+/* enum: PTP PPS event */
+#define          MCDI_EVENT_CODE_PTP_PPS  0xf
+/* enum: Rx flush has completed */
+#define          MCDI_EVENT_CODE_RX_FLUSH  0x10
+/* enum: Receive error */
+#define          MCDI_EVENT_CODE_RX_ERR 0x11
+/* enum: AOE fault */
+#define          MCDI_EVENT_CODE_AOE  0x12
+/* enum: Network port calibration failed (VCAL). */
+#define          MCDI_EVENT_CODE_VCAL_FAIL  0x13
+/* enum: HW PPS event */
+#define          MCDI_EVENT_CODE_HW_PPS  0x14
+/* enum: The MC has rebooted (huntington and later, siena uses CODE_REBOOT and
+ * a different format)
+ */
+#define          MCDI_EVENT_CODE_MC_REBOOT 0x15
+/* enum: the MC has detected a parity error */
+#define          MCDI_EVENT_CODE_PAR_ERR 0x16
+/* enum: the MC has detected a correctable error */
+#define          MCDI_EVENT_CODE_ECC_CORR_ERR 0x17
+/* enum: the MC has detected an uncorrectable error */
+#define          MCDI_EVENT_CODE_ECC_FATAL_ERR 0x18
+/* enum: Artificial event generated by host and posted via MC for test
+ * purposes.
+ */
+#define          MCDI_EVENT_CODE_TESTGEN  0xfa
 #define       MCDI_EVENT_CMDDONE_DATA_OFST 0
 #define       MCDI_EVENT_CMDDONE_DATA_LBN 0
 #define       MCDI_EVENT_CMDDONE_DATA_WIDTH 32
 #define       MCDI_EVENT_TX_ERR_DATA_OFST 0
 #define       MCDI_EVENT_TX_ERR_DATA_LBN 0
 #define       MCDI_EVENT_TX_ERR_DATA_WIDTH 32
+/* Seconds field of timestamp */
 #define       MCDI_EVENT_PTP_SECONDS_OFST 0
 #define       MCDI_EVENT_PTP_SECONDS_LBN 0
 #define       MCDI_EVENT_PTP_SECONDS_WIDTH 32
+/* Nanoseconds field of timestamp */
 #define       MCDI_EVENT_PTP_NANOSECONDS_OFST 0
 #define       MCDI_EVENT_PTP_NANOSECONDS_LBN 0
 #define       MCDI_EVENT_PTP_NANOSECONDS_WIDTH 32
+/* Lowest four bytes of sourceUUID from PTP packet */
 #define       MCDI_EVENT_PTP_UUID_OFST 0
 #define       MCDI_EVENT_PTP_UUID_LBN 0
 #define       MCDI_EVENT_PTP_UUID_WIDTH 32
+#define       MCDI_EVENT_RX_ERR_DATA_OFST 0
+#define       MCDI_EVENT_RX_ERR_DATA_LBN 0
+#define       MCDI_EVENT_RX_ERR_DATA_WIDTH 32
+#define       MCDI_EVENT_PAR_ERR_DATA_OFST 0
+#define       MCDI_EVENT_PAR_ERR_DATA_LBN 0
+#define       MCDI_EVENT_PAR_ERR_DATA_WIDTH 32
+#define       MCDI_EVENT_ECC_CORR_ERR_DATA_OFST 0
+#define       MCDI_EVENT_ECC_CORR_ERR_DATA_LBN 0
+#define       MCDI_EVENT_ECC_CORR_ERR_DATA_WIDTH 32
+#define       MCDI_EVENT_ECC_FATAL_ERR_DATA_OFST 0
+#define       MCDI_EVENT_ECC_FATAL_ERR_DATA_LBN 0
+#define       MCDI_EVENT_ECC_FATAL_ERR_DATA_WIDTH 32
+
+/* FCDI_EVENT structuredef */
+#define    FCDI_EVENT_LEN 8
+#define       FCDI_EVENT_CONT_LBN 32
+#define       FCDI_EVENT_CONT_WIDTH 1
+#define       FCDI_EVENT_LEVEL_LBN 33
+#define       FCDI_EVENT_LEVEL_WIDTH 3
+/* enum: Info. */
+#define          FCDI_EVENT_LEVEL_INFO  0x0
+/* enum: Warning. */
+#define          FCDI_EVENT_LEVEL_WARN 0x1
+/* enum: Error. */
+#define          FCDI_EVENT_LEVEL_ERR 0x2
+/* enum: Fatal. */
+#define          FCDI_EVENT_LEVEL_FATAL 0x3
+#define       FCDI_EVENT_DATA_OFST 0
+#define        FCDI_EVENT_LINK_STATE_STATUS_LBN 0
+#define        FCDI_EVENT_LINK_STATE_STATUS_WIDTH 1
+#define          FCDI_EVENT_LINK_DOWN 0x0 /* enum */
+#define          FCDI_EVENT_LINK_UP 0x1 /* enum */
+#define       FCDI_EVENT_DATA_LBN 0
+#define       FCDI_EVENT_DATA_WIDTH 32
+#define       FCDI_EVENT_SRC_LBN 36
+#define       FCDI_EVENT_SRC_WIDTH 8
+#define       FCDI_EVENT_EV_CODE_LBN 60
+#define       FCDI_EVENT_EV_CODE_WIDTH 4
+#define       FCDI_EVENT_CODE_LBN 44
+#define       FCDI_EVENT_CODE_WIDTH 8
+/* enum: The FC was rebooted. */
+#define          FCDI_EVENT_CODE_REBOOT 0x1
+/* enum: Bad assert. */
+#define          FCDI_EVENT_CODE_ASSERT 0x2
+/* enum: DDR3 test result. */
+#define          FCDI_EVENT_CODE_DDR_TEST_RESULT 0x3
+/* enum: Link status. */
+#define          FCDI_EVENT_CODE_LINK_STATE 0x4
+/* enum: A timed read is ready to be serviced. */
+#define          FCDI_EVENT_CODE_TIMED_READ 0x5
+/* enum: One or more PPS IN events */
+#define          FCDI_EVENT_CODE_PPS_IN 0x6
+/* enum: One or more PPS OUT events */
+#define          FCDI_EVENT_CODE_PPS_OUT 0x7
+#define       FCDI_EVENT_ASSERT_INSTR_ADDRESS_OFST 0
+#define       FCDI_EVENT_ASSERT_INSTR_ADDRESS_LBN 0
+#define       FCDI_EVENT_ASSERT_INSTR_ADDRESS_WIDTH 32
+#define       FCDI_EVENT_ASSERT_TYPE_LBN 36
+#define       FCDI_EVENT_ASSERT_TYPE_WIDTH 8
+#define       FCDI_EVENT_DDR_TEST_RESULT_STATUS_CODE_LBN 36
+#define       FCDI_EVENT_DDR_TEST_RESULT_STATUS_CODE_WIDTH 8
+#define       FCDI_EVENT_DDR_TEST_RESULT_RESULT_OFST 0
+#define       FCDI_EVENT_DDR_TEST_RESULT_RESULT_LBN 0
+#define       FCDI_EVENT_DDR_TEST_RESULT_RESULT_WIDTH 32
+#define       FCDI_EVENT_LINK_STATE_DATA_OFST 0
+#define       FCDI_EVENT_LINK_STATE_DATA_LBN 0
+#define       FCDI_EVENT_LINK_STATE_DATA_WIDTH 32
+#define       FCDI_EVENT_PPS_COUNT_OFST 0
+#define       FCDI_EVENT_PPS_COUNT_LBN 0
+#define       FCDI_EVENT_PPS_COUNT_WIDTH 32
+
+/* FCDI_EXTENDED_EVENT structuredef */
+#define    FCDI_EXTENDED_EVENT_LENMIN 16
+#define    FCDI_EXTENDED_EVENT_LENMAX 248
+#define    FCDI_EXTENDED_EVENT_LEN(num) (8+8*(num))
+/* Number of timestamps following */
+#define       FCDI_EXTENDED_EVENT_PPS_COUNT_OFST 0
+#define       FCDI_EXTENDED_EVENT_PPS_COUNT_LBN 0
+#define       FCDI_EXTENDED_EVENT_PPS_COUNT_WIDTH 32
+/* Seconds field of a timestamp record */
+#define       FCDI_EXTENDED_EVENT_PPS_SECONDS_OFST 8
+#define       FCDI_EXTENDED_EVENT_PPS_SECONDS_LBN 64
+#define       FCDI_EXTENDED_EVENT_PPS_SECONDS_WIDTH 32
+/* Nanoseconds field of a timestamp record */
+#define       FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_OFST 12
+#define       FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_LBN 96
+#define       FCDI_EXTENDED_EVENT_PPS_NANOSECONDS_WIDTH 32
+/* Timestamp records comprising the event */
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_OFST 8
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_LEN 8
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_LO_OFST 8
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_HI_OFST 12
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_MINNUM 1
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_MAXNUM 30
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_LBN 64
+#define       FCDI_EXTENDED_EVENT_PPS_TIME_WIDTH 64
 
 
 /***********************************/
 
 /* MC_CMD_COPYCODE_IN msgrequest */
 #define    MC_CMD_COPYCODE_IN_LEN 16
+/* Source address */
 #define       MC_CMD_COPYCODE_IN_SRC_ADDR_OFST 0
+/* enum: Entering the main image via a copy of a single word from and to this
+ * address indicates that it should not attempt to start the datapath CPUs.
+ * This is useful for certain soft rebooting scenarios. (Huntington only)
+ */
+#define          MC_CMD_COPYCODE_HUNT_NO_DATAPATH_MAGIC_ADDR 0x1d0d0
+/* enum: Entering the main image via a copy of a single word from and to this
+ * address indicates that it should not attempt to parse any configuration from
+ * flash. (In addition, the datapath CPUs will not be started, as for
+ * MC_CMD_COPYCODE_HUNT_NO_DATAPATH_MAGIC_ADDR above.) This is useful for
+ * certain soft rebooting scenarios. (Huntington only)
+ */
+#define          MC_CMD_COPYCODE_HUNT_IGNORE_CONFIG_MAGIC_ADDR 0x1badc
+/* Destination address */
 #define       MC_CMD_COPYCODE_IN_DEST_ADDR_OFST 4
 #define       MC_CMD_COPYCODE_IN_NUMWORDS_OFST 8
+/* Address of where to jump after copy. */
 #define       MC_CMD_COPYCODE_IN_JUMP_OFST 12
-#define          MC_CMD_COPYCODE_JUMP_NONE 0x1 /* enum */
+/* enum: Control should return to the caller rather than jumping */
+#define          MC_CMD_COPYCODE_JUMP_NONE 0x1
 
 /* MC_CMD_COPYCODE_OUT msgresponse */
 #define    MC_CMD_COPYCODE_OUT_LEN 0
 
 /***********************************/
 /* MC_CMD_SET_FUNC
+ * Select function for function-specific commands.
  */
 #define MC_CMD_SET_FUNC 0x4
 
 /* MC_CMD_SET_FUNC_IN msgrequest */
 #define    MC_CMD_SET_FUNC_IN_LEN 4
+/* Set function */
 #define       MC_CMD_SET_FUNC_IN_FUNC_OFST 0
 
 /* MC_CMD_SET_FUNC_OUT msgresponse */
 
 /***********************************/
 /* MC_CMD_GET_BOOT_STATUS
+ * Get the instruction address from which the MC booted.
  */
 #define MC_CMD_GET_BOOT_STATUS 0x5
 
 
 /* MC_CMD_GET_BOOT_STATUS_OUT msgresponse */
 #define    MC_CMD_GET_BOOT_STATUS_OUT_LEN 8
+/* ?? */
 #define       MC_CMD_GET_BOOT_STATUS_OUT_BOOT_OFFSET_OFST 0
+/* enum: indicates that the MC wasn't flash booted */
+#define          MC_CMD_GET_BOOT_STATUS_OUT_BOOT_OFFSET_NULL  0xdeadbeef
 #define       MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_OFST 4
 #define        MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_WATCHDOG_LBN 0
 #define        MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_WATCHDOG_WIDTH 1
 
 /***********************************/
 /* MC_CMD_GET_ASSERTS
- * Get and clear any assertion status.
+ * Get (and optionally clear) the current assertion status. Only
+ * OUT.GLOBAL_FLAGS is guaranteed to exist in the completion payload. The other
+ * fields will only be present if OUT.GLOBAL_FLAGS != NO_FAILS
  */
 #define MC_CMD_GET_ASSERTS 0x6
 
 /* MC_CMD_GET_ASSERTS_IN msgrequest */
 #define    MC_CMD_GET_ASSERTS_IN_LEN 4
+/* Set to clear assertion */
 #define       MC_CMD_GET_ASSERTS_IN_CLEAR_OFST 0
 
 /* MC_CMD_GET_ASSERTS_OUT msgresponse */
 #define    MC_CMD_GET_ASSERTS_OUT_LEN 140
+/* Assertion status flag. */
 #define       MC_CMD_GET_ASSERTS_OUT_GLOBAL_FLAGS_OFST 0
-#define          MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS 0x1 /* enum */
-#define          MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL 0x2 /* enum */
-#define          MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL 0x3 /* enum */
-#define          MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED 0x4 /* enum */
+/* enum: No assertions have failed. */
+#define          MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS 0x1
+/* enum: A system-level assertion has failed. */
+#define          MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL 0x2
+/* enum: A thread-level assertion has failed. */
+#define          MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL 0x3
+/* enum: The system was reset by the watchdog. */
+#define          MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED 0x4
+/* enum: An illegal address trap stopped the system (huntington and later) */
+#define          MC_CMD_GET_ASSERTS_FLAGS_ADDR_TRAP 0x5
+/* Failing PC value */
 #define       MC_CMD_GET_ASSERTS_OUT_SAVED_PC_OFFS_OFST 4
+/* Saved GP regs */
 #define       MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST 8
 #define       MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_LEN 4
 #define       MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_NUM 31
+/* Failing thread address */
 #define       MC_CMD_GET_ASSERTS_OUT_THREAD_OFFS_OFST 132
 #define       MC_CMD_GET_ASSERTS_OUT_RESERVED_OFST 136
 
 
 /* MC_CMD_LOG_CTRL_IN msgrequest */
 #define    MC_CMD_LOG_CTRL_IN_LEN 8
+/* Log destination */
 #define       MC_CMD_LOG_CTRL_IN_LOG_DEST_OFST 0
-#define          MC_CMD_LOG_CTRL_IN_LOG_DEST_UART 0x1 /* enum */
-#define          MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ 0x2 /* enum */
+/* enum: UART. */
+#define          MC_CMD_LOG_CTRL_IN_LOG_DEST_UART 0x1
+/* enum: Event queue. */
+#define          MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ 0x2
 #define       MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ_OFST 4
 
 /* MC_CMD_LOG_CTRL_OUT msgresponse */
 /* MC_CMD_GET_VERSION_IN msgrequest */
 #define    MC_CMD_GET_VERSION_IN_LEN 0
 
-/* MC_CMD_GET_VERSION_V0_OUT msgresponse */
+/* MC_CMD_GET_VERSION_EXT_IN msgrequest: Asks for the extended version */
+#define    MC_CMD_GET_VERSION_EXT_IN_LEN 4
+/* placeholder, set to 0 */
+#define       MC_CMD_GET_VERSION_EXT_IN_EXT_FLAGS_OFST 0
+
+/* MC_CMD_GET_VERSION_V0_OUT msgresponse: deprecated version format */
 #define    MC_CMD_GET_VERSION_V0_OUT_LEN 4
 #define       MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0
-#define          MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff /* enum */
-#define          MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM 0xb0070000 /* enum */
+/* enum: Reserved version number to indicate "any" version. */
+#define          MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff
+/* enum: Bootrom version value for Siena. */
+#define          MC_CMD_GET_VERSION_OUT_FIRMWARE_SIENA_BOOTROM 0xb0070000
+/* enum: Bootrom version value for Huntington. */
+#define          MC_CMD_GET_VERSION_OUT_FIRMWARE_HUNT_BOOTROM 0xb0070001
 
 /* MC_CMD_GET_VERSION_OUT msgresponse */
 #define    MC_CMD_GET_VERSION_OUT_LEN 32
 /*            Enum values, see field(s): */
 /*               MC_CMD_GET_VERSION_V0_OUT/MC_CMD_GET_VERSION_OUT_FIRMWARE */
 #define       MC_CMD_GET_VERSION_OUT_PCOL_OFST 4
+/* 128bit mask of functions supported by the current firmware */
 #define       MC_CMD_GET_VERSION_OUT_SUPPORTED_FUNCS_OFST 8
 #define       MC_CMD_GET_VERSION_OUT_SUPPORTED_FUNCS_LEN 16
 #define       MC_CMD_GET_VERSION_OUT_VERSION_OFST 24
 #define       MC_CMD_GET_VERSION_OUT_VERSION_LO_OFST 24
 #define       MC_CMD_GET_VERSION_OUT_VERSION_HI_OFST 28
 
-
-/***********************************/
-/* MC_CMD_GET_FPGAREG
- * Read multiple bytes from PTP FPGA.
- */
-#define MC_CMD_GET_FPGAREG 0x9
-
-/* MC_CMD_GET_FPGAREG_IN msgrequest */
-#define    MC_CMD_GET_FPGAREG_IN_LEN 8
-#define       MC_CMD_GET_FPGAREG_IN_ADDR_OFST 0
-#define       MC_CMD_GET_FPGAREG_IN_NUMBYTES_OFST 4
-
-/* MC_CMD_GET_FPGAREG_OUT msgresponse */
-#define    MC_CMD_GET_FPGAREG_OUT_LENMIN 1
-#define    MC_CMD_GET_FPGAREG_OUT_LENMAX 252
-#define    MC_CMD_GET_FPGAREG_OUT_LEN(num) (0+1*(num))
-#define       MC_CMD_GET_FPGAREG_OUT_BUFFER_OFST 0
-#define       MC_CMD_GET_FPGAREG_OUT_BUFFER_LEN 1
-#define       MC_CMD_GET_FPGAREG_OUT_BUFFER_MINNUM 1
-#define       MC_CMD_GET_FPGAREG_OUT_BUFFER_MAXNUM 252
-
-
-/***********************************/
-/* MC_CMD_PUT_FPGAREG
- * Write multiple bytes to PTP FPGA.
- */
-#define MC_CMD_PUT_FPGAREG 0xa
-
-/* MC_CMD_PUT_FPGAREG_IN msgrequest */
-#define    MC_CMD_PUT_FPGAREG_IN_LENMIN 5
-#define    MC_CMD_PUT_FPGAREG_IN_LENMAX 252
-#define    MC_CMD_PUT_FPGAREG_IN_LEN(num) (4+1*(num))
-#define       MC_CMD_PUT_FPGAREG_IN_ADDR_OFST 0
-#define       MC_CMD_PUT_FPGAREG_IN_BUFFER_OFST 4
-#define       MC_CMD_PUT_FPGAREG_IN_BUFFER_LEN 1
-#define       MC_CMD_PUT_FPGAREG_IN_BUFFER_MINNUM 1
-#define       MC_CMD_PUT_FPGAREG_IN_BUFFER_MAXNUM 248
-
-/* MC_CMD_PUT_FPGAREG_OUT msgresponse */
-#define    MC_CMD_PUT_FPGAREG_OUT_LEN 0
+/* MC_CMD_GET_VERSION_EXT_OUT msgresponse */
+#define    MC_CMD_GET_VERSION_EXT_OUT_LEN 48
+/*            MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */
+/*            Enum values, see field(s): */
+/*               MC_CMD_GET_VERSION_V0_OUT/MC_CMD_GET_VERSION_OUT_FIRMWARE */
+#define       MC_CMD_GET_VERSION_EXT_OUT_PCOL_OFST 4
+/* 128bit mask of functions supported by the current firmware */
+#define       MC_CMD_GET_VERSION_EXT_OUT_SUPPORTED_FUNCS_OFST 8
+#define       MC_CMD_GET_VERSION_EXT_OUT_SUPPORTED_FUNCS_LEN 16
+#define       MC_CMD_GET_VERSION_EXT_OUT_VERSION_OFST 24
+#define       MC_CMD_GET_VERSION_EXT_OUT_VERSION_LEN 8
+#define       MC_CMD_GET_VERSION_EXT_OUT_VERSION_LO_OFST 24
+#define       MC_CMD_GET_VERSION_EXT_OUT_VERSION_HI_OFST 28
+/* extra info */
+#define       MC_CMD_GET_VERSION_EXT_OUT_EXTRA_OFST 32
+#define       MC_CMD_GET_VERSION_EXT_OUT_EXTRA_LEN 16
 
 
 /***********************************/
 
 /* MC_CMD_PTP_IN msgrequest */
 #define    MC_CMD_PTP_IN_LEN 1
+/* PTP operation code */
 #define       MC_CMD_PTP_IN_OP_OFST 0
 #define       MC_CMD_PTP_IN_OP_LEN 1
-#define          MC_CMD_PTP_OP_ENABLE 0x1 /* enum */
-#define          MC_CMD_PTP_OP_DISABLE 0x2 /* enum */
-#define          MC_CMD_PTP_OP_TRANSMIT 0x3 /* enum */
-#define          MC_CMD_PTP_OP_READ_NIC_TIME 0x4 /* enum */
-#define          MC_CMD_PTP_OP_STATUS 0x5 /* enum */
-#define          MC_CMD_PTP_OP_ADJUST 0x6 /* enum */
-#define          MC_CMD_PTP_OP_SYNCHRONIZE 0x7 /* enum */
-#define          MC_CMD_PTP_OP_MANFTEST_BASIC 0x8 /* enum */
-#define          MC_CMD_PTP_OP_MANFTEST_PACKET 0x9 /* enum */
-#define          MC_CMD_PTP_OP_RESET_STATS 0xa /* enum */
-#define          MC_CMD_PTP_OP_DEBUG 0xb /* enum */
-#define          MC_CMD_PTP_OP_MAX 0xc /* enum */
+/* enum: Enable PTP packet timestamping operation. */
+#define          MC_CMD_PTP_OP_ENABLE 0x1
+/* enum: Disable PTP packet timestamping operation. */
+#define          MC_CMD_PTP_OP_DISABLE 0x2
+/* enum: Send a PTP packet. */
+#define          MC_CMD_PTP_OP_TRANSMIT 0x3
+/* enum: Read the current NIC time. */
+#define          MC_CMD_PTP_OP_READ_NIC_TIME 0x4
+/* enum: Get the current PTP status. */
+#define          MC_CMD_PTP_OP_STATUS 0x5
+/* enum: Adjust the PTP NIC's time. */
+#define          MC_CMD_PTP_OP_ADJUST 0x6
+/* enum: Synchronize host and NIC time. */
+#define          MC_CMD_PTP_OP_SYNCHRONIZE 0x7
+/* enum: Basic manufacturing tests. */
+#define          MC_CMD_PTP_OP_MANFTEST_BASIC 0x8
+/* enum: Packet based manufacturing tests. */
+#define          MC_CMD_PTP_OP_MANFTEST_PACKET 0x9
+/* enum: Reset some of the PTP related statistics */
+#define          MC_CMD_PTP_OP_RESET_STATS 0xa
+/* enum: Debug operations to MC. */
+#define          MC_CMD_PTP_OP_DEBUG 0xb
+/* enum: Read an FPGA register */
+#define          MC_CMD_PTP_OP_FPGAREAD 0xc
+/* enum: Write an FPGA register */
+#define          MC_CMD_PTP_OP_FPGAWRITE 0xd
+/* enum: Apply an offset to the NIC clock */
+#define          MC_CMD_PTP_OP_CLOCK_OFFSET_ADJUST 0xe
+/* enum: Change Apply an offset to the NIC clock */
+#define          MC_CMD_PTP_OP_CLOCK_FREQ_ADJUST 0xf
+/* enum: Set the MC packet filter VLAN tags for received PTP packets */
+#define          MC_CMD_PTP_OP_RX_SET_VLAN_FILTER 0x10
+/* enum: Set the MC packet filter UUID for received PTP packets */
+#define          MC_CMD_PTP_OP_RX_SET_UUID_FILTER 0x11
+/* enum: Set the MC packet filter Domain for received PTP packets */
+#define          MC_CMD_PTP_OP_RX_SET_DOMAIN_FILTER 0x12
+/* enum: Set the clock source */
+#define          MC_CMD_PTP_OP_SET_CLK_SRC 0x13
+/* enum: Reset value of Timer Reg. */
+#define          MC_CMD_PTP_OP_RST_CLK 0x14
+/* enum: Enable the forwarding of PPS events to the host */
+#define          MC_CMD_PTP_OP_PPS_ENABLE 0x15
+/* enum: Above this for future use. */
+#define          MC_CMD_PTP_OP_MAX 0x16
 
 /* MC_CMD_PTP_IN_ENABLE msgrequest */
 #define    MC_CMD_PTP_IN_ENABLE_LEN 16
 #define       MC_CMD_PTP_IN_CMD_OFST 0
 #define       MC_CMD_PTP_IN_PERIPH_ID_OFST 4
+/* Event queue for PTP events */
 #define       MC_CMD_PTP_IN_ENABLE_QUEUE_OFST 8
+/* PTP timestamping mode */
 #define       MC_CMD_PTP_IN_ENABLE_MODE_OFST 12
-#define          MC_CMD_PTP_MODE_V1 0x0 /* enum */
-#define          MC_CMD_PTP_MODE_V1_VLAN 0x1 /* enum */
-#define          MC_CMD_PTP_MODE_V2 0x2 /* enum */
-#define          MC_CMD_PTP_MODE_V2_VLAN 0x3 /* enum */
-#define          MC_CMD_PTP_MODE_V2_ENHANCED 0x4 /* enum */
+/* enum: PTP, version 1 */
+#define          MC_CMD_PTP_MODE_V1 0x0
+/* enum: PTP, version 1, with VLAN headers - deprecated */
+#define          MC_CMD_PTP_MODE_V1_VLAN 0x1
+/* enum: PTP, version 2 */
+#define          MC_CMD_PTP_MODE_V2 0x2
+/* enum: PTP, version 2, with VLAN headers - deprecated */
+#define          MC_CMD_PTP_MODE_V2_VLAN 0x3
+/* enum: PTP, version 2, with improved UUID filtering */
+#define          MC_CMD_PTP_MODE_V2_ENHANCED 0x4
+/* enum: FCoE (seconds and microseconds) */
+#define          MC_CMD_PTP_MODE_FCOE 0x5
 
 /* MC_CMD_PTP_IN_DISABLE msgrequest */
 #define    MC_CMD_PTP_IN_DISABLE_LEN 8
 #define    MC_CMD_PTP_IN_TRANSMIT_LEN(num) (12+1*(num))
 /*            MC_CMD_PTP_IN_CMD_OFST 0 */
 /*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Transmit packet length */
 #define       MC_CMD_PTP_IN_TRANSMIT_LENGTH_OFST 8
+/* Transmit packet data */
 #define       MC_CMD_PTP_IN_TRANSMIT_PACKET_OFST 12
 #define       MC_CMD_PTP_IN_TRANSMIT_PACKET_LEN 1
 #define       MC_CMD_PTP_IN_TRANSMIT_PACKET_MINNUM 1
 #define    MC_CMD_PTP_IN_ADJUST_LEN 24
 /*            MC_CMD_PTP_IN_CMD_OFST 0 */
 /*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Frequency adjustment 40 bit fixed point ns */
 #define       MC_CMD_PTP_IN_ADJUST_FREQ_OFST 8
 #define       MC_CMD_PTP_IN_ADJUST_FREQ_LEN 8
 #define       MC_CMD_PTP_IN_ADJUST_FREQ_LO_OFST 8
 #define       MC_CMD_PTP_IN_ADJUST_FREQ_HI_OFST 12
-#define          MC_CMD_PTP_IN_ADJUST_BITS 0x28 /* enum */
+/* enum: Number of fractional bits in frequency adjustment */
+#define          MC_CMD_PTP_IN_ADJUST_BITS 0x28
+/* Time adjustment in seconds */
 #define       MC_CMD_PTP_IN_ADJUST_SECONDS_OFST 16
+/* Time adjustment in nanoseconds */
 #define       MC_CMD_PTP_IN_ADJUST_NANOSECONDS_OFST 20
 
 /* MC_CMD_PTP_IN_SYNCHRONIZE msgrequest */
 #define    MC_CMD_PTP_IN_SYNCHRONIZE_LEN 20
 /*            MC_CMD_PTP_IN_CMD_OFST 0 */
 /*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Number of time readings to capture */
 #define       MC_CMD_PTP_IN_SYNCHRONIZE_NUMTIMESETS_OFST 8
+/* Host address in which to write "synchronization started" indication (64
+ * bits)
+ */
 #define       MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_OFST 12
 #define       MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LEN 8
 #define       MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LO_OFST 12
 #define    MC_CMD_PTP_IN_MANFTEST_PACKET_LEN 12
 /*            MC_CMD_PTP_IN_CMD_OFST 0 */
 /*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Enable or disable packet testing */
 #define       MC_CMD_PTP_IN_MANFTEST_PACKET_TEST_ENABLE_OFST 8
 
 /* MC_CMD_PTP_IN_RESET_STATS msgrequest */
 #define    MC_CMD_PTP_IN_RESET_STATS_LEN 8
 /*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/* Reset PTP statistics */
 /*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
 
 /* MC_CMD_PTP_IN_DEBUG msgrequest */
 #define    MC_CMD_PTP_IN_DEBUG_LEN 12
 /*            MC_CMD_PTP_IN_CMD_OFST 0 */
 /*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Debug operations */
 #define       MC_CMD_PTP_IN_DEBUG_DEBUG_PARAM_OFST 8
 
+/* MC_CMD_PTP_IN_FPGAREAD msgrequest */
+#define    MC_CMD_PTP_IN_FPGAREAD_LEN 16
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define       MC_CMD_PTP_IN_FPGAREAD_ADDR_OFST 8
+#define       MC_CMD_PTP_IN_FPGAREAD_NUMBYTES_OFST 12
+
+/* MC_CMD_PTP_IN_FPGAWRITE msgrequest */
+#define    MC_CMD_PTP_IN_FPGAWRITE_LENMIN 13
+#define    MC_CMD_PTP_IN_FPGAWRITE_LENMAX 252
+#define    MC_CMD_PTP_IN_FPGAWRITE_LEN(num) (12+1*(num))
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+#define       MC_CMD_PTP_IN_FPGAWRITE_ADDR_OFST 8
+#define       MC_CMD_PTP_IN_FPGAWRITE_BUFFER_OFST 12
+#define       MC_CMD_PTP_IN_FPGAWRITE_BUFFER_LEN 1
+#define       MC_CMD_PTP_IN_FPGAWRITE_BUFFER_MINNUM 1
+#define       MC_CMD_PTP_IN_FPGAWRITE_BUFFER_MAXNUM 240
+
+/* MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST msgrequest */
+#define    MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST_LEN 16
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Time adjustment in seconds */
+#define       MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST_SECONDS_OFST 8
+/* Time adjustment in nanoseconds */
+#define       MC_CMD_PTP_IN_CLOCK_OFFSET_ADJUST_NANOSECONDS_OFST 12
+
+/* MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST msgrequest */
+#define    MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_LEN 16
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Frequency adjustment 40 bit fixed point ns */
+#define       MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_OFST 8
+#define       MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_LEN 8
+#define       MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_LO_OFST 8
+#define       MC_CMD_PTP_IN_CLOCK_FREQ_ADJUST_FREQ_HI_OFST 12
+/* enum: Number of fractional bits in frequency adjustment */
+/*               MC_CMD_PTP_IN_ADJUST_BITS 0x28 */
+
+/* MC_CMD_PTP_IN_RX_SET_VLAN_FILTER msgrequest */
+#define    MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_LEN 24
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Number of VLAN tags, 0 if not VLAN */
+#define       MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_NUM_VLAN_TAGS_OFST 8
+/* Set of VLAN tags to filter against */
+#define       MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_VLAN_TAG_OFST 12
+#define       MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_VLAN_TAG_LEN 4
+#define       MC_CMD_PTP_IN_RX_SET_VLAN_FILTER_VLAN_TAG_NUM 3
+
+/* MC_CMD_PTP_IN_RX_SET_UUID_FILTER msgrequest */
+#define    MC_CMD_PTP_IN_RX_SET_UUID_FILTER_LEN 20
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* 1 to enable UUID filtering, 0 to disable */
+#define       MC_CMD_PTP_IN_RX_SET_UUID_FILTER_ENABLE_OFST 8
+/* UUID to filter against */
+#define       MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_OFST 12
+#define       MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_LEN 8
+#define       MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_LO_OFST 12
+#define       MC_CMD_PTP_IN_RX_SET_UUID_FILTER_UUID_HI_OFST 16
+
+/* MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER msgrequest */
+#define    MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER_LEN 16
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* 1 to enable Domain filtering, 0 to disable */
+#define       MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER_ENABLE_OFST 8
+/* Domain number to filter against */
+#define       MC_CMD_PTP_IN_RX_SET_DOMAIN_FILTER_DOMAIN_OFST 12
+
+/* MC_CMD_PTP_IN_SET_CLK_SRC msgrequest */
+#define    MC_CMD_PTP_IN_SET_CLK_SRC_LEN 12
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+/* Set the clock source. */
+#define       MC_CMD_PTP_IN_SET_CLK_SRC_CLK_OFST 8
+/* enum: Internal. */
+#define          MC_CMD_PTP_CLK_SRC_INTERNAL 0x0
+/* enum: External. */
+#define          MC_CMD_PTP_CLK_SRC_EXTERNAL 0x1
+
+/* MC_CMD_PTP_IN_RST_CLK msgrequest */
+#define    MC_CMD_PTP_IN_RST_CLK_LEN 8
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/* Reset value of Timer Reg. */
+/*            MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
+
+/* MC_CMD_PTP_IN_PPS_ENABLE msgrequest */
+#define    MC_CMD_PTP_IN_PPS_ENABLE_LEN 12
+/*            MC_CMD_PTP_IN_CMD_OFST 0 */
+/* Enable or disable */
+#define       MC_CMD_PTP_IN_PPS_ENABLE_OP_OFST 4
+/* enum: Enable */
+#define          MC_CMD_PTP_ENABLE_PPS 0x0
+/* enum: Disable */
+#define          MC_CMD_PTP_DISABLE_PPS 0x1
+/* Queueid to send events back */
+#define       MC_CMD_PTP_IN_PPS_ENABLE_QUEUE_ID_OFST 8
+
 /* MC_CMD_PTP_OUT msgresponse */
 #define    MC_CMD_PTP_OUT_LEN 0
 
 /* MC_CMD_PTP_OUT_TRANSMIT msgresponse */
 #define    MC_CMD_PTP_OUT_TRANSMIT_LEN 8
+/* Value of seconds timestamp */
 #define       MC_CMD_PTP_OUT_TRANSMIT_SECONDS_OFST 0
+/* Value of nanoseconds timestamp */
 #define       MC_CMD_PTP_OUT_TRANSMIT_NANOSECONDS_OFST 4
 
 /* MC_CMD_PTP_OUT_READ_NIC_TIME msgresponse */
 #define    MC_CMD_PTP_OUT_READ_NIC_TIME_LEN 8
+/* Value of seconds timestamp */
 #define       MC_CMD_PTP_OUT_READ_NIC_TIME_SECONDS_OFST 0
+/* Value of nanoseconds timestamp */
 #define       MC_CMD_PTP_OUT_READ_NIC_TIME_NANOSECONDS_OFST 4
 
 /* MC_CMD_PTP_OUT_STATUS msgresponse */
 #define    MC_CMD_PTP_OUT_STATUS_LEN 64
+/* Frequency of NIC's hardware clock */
 #define       MC_CMD_PTP_OUT_STATUS_CLOCK_FREQ_OFST 0
+/* Number of packets transmitted and timestamped */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_TX_OFST 4
+/* Number of packets received and timestamped */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_RX_OFST 8
+/* Number of packets timestamped by the FPGA */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_TS_OFST 12
+/* Number of packets filter matched */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_FM_OFST 16
+/* Number of packets not filter matched */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_NFM_OFST 20
+/* Number of PPS overflows (noise on input?) */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFLOW_OFST 24
+/* Number of PPS bad periods */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_BAD_OFST 28
+/* Minimum period of PPS pulse */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MIN_OFST 32
+/* Maximum period of PPS pulse */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MAX_OFST 36
+/* Last period of PPS pulse */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_LAST_OFST 40
+/* Mean period of PPS pulse */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MEAN_OFST 44
+/* Minimum offset of PPS pulse (signed) */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MIN_OFST 48
+/* Maximum offset of PPS pulse (signed) */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MAX_OFST 52
+/* Last offset of PPS pulse (signed) */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_LAST_OFST 56
+/* Mean offset of PPS pulse (signed) */
 #define       MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MEAN_OFST 60
 
 /* MC_CMD_PTP_OUT_SYNCHRONIZE msgresponse */
 #define    MC_CMD_PTP_OUT_SYNCHRONIZE_LENMIN 20
 #define    MC_CMD_PTP_OUT_SYNCHRONIZE_LENMAX 240
 #define    MC_CMD_PTP_OUT_SYNCHRONIZE_LEN(num) (0+20*(num))
+/* A set of host and NIC times */
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_OFST 0
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN 20
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MINNUM 1
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM 12
+/* Host time immediately before NIC's hardware clock read */
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTSTART_OFST 0
+/* Value of seconds timestamp */
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_SECONDS_OFST 4
+/* Value of nanoseconds timestamp */
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_NANOSECONDS_OFST 8
+/* Host time immediately after NIC's hardware clock read */
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTEND_OFST 12
+/* Number of nanoseconds waited after reading NIC's hardware clock */
 #define       MC_CMD_PTP_OUT_SYNCHRONIZE_WAITNS_OFST 16
 
 /* MC_CMD_PTP_OUT_MANFTEST_BASIC msgresponse */
 #define    MC_CMD_PTP_OUT_MANFTEST_BASIC_LEN 8
+/* Results of testing */
 #define       MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_RESULT_OFST 0
-#define          MC_CMD_PTP_MANF_SUCCESS 0x0 /* enum */
-#define          MC_CMD_PTP_MANF_FPGA_LOAD 0x1 /* enum */
-#define          MC_CMD_PTP_MANF_FPGA_VERSION 0x2 /* enum */
-#define          MC_CMD_PTP_MANF_FPGA_REGISTERS 0x3 /* enum */
-#define          MC_CMD_PTP_MANF_OSCILLATOR 0x4 /* enum */
-#define          MC_CMD_PTP_MANF_TIMESTAMPS 0x5 /* enum */
-#define          MC_CMD_PTP_MANF_PACKET_COUNT 0x6 /* enum */
-#define          MC_CMD_PTP_MANF_FILTER_COUNT 0x7 /* enum */
-#define          MC_CMD_PTP_MANF_PACKET_ENOUGH 0x8 /* enum */
-#define          MC_CMD_PTP_MANF_GPIO_TRIGGER 0x9 /* enum */
+/* enum: Successful test */
+#define          MC_CMD_PTP_MANF_SUCCESS 0x0
+/* enum: FPGA load failed */
+#define          MC_CMD_PTP_MANF_FPGA_LOAD 0x1
+/* enum: FPGA version invalid */
+#define          MC_CMD_PTP_MANF_FPGA_VERSION 0x2
+/* enum: FPGA registers incorrect */
+#define          MC_CMD_PTP_MANF_FPGA_REGISTERS 0x3
+/* enum: Oscillator possibly not working? */
+#define          MC_CMD_PTP_MANF_OSCILLATOR 0x4
+/* enum: Timestamps not increasing */
+#define          MC_CMD_PTP_MANF_TIMESTAMPS 0x5
+/* enum: Mismatched packet count */
+#define          MC_CMD_PTP_MANF_PACKET_COUNT 0x6
+/* enum: Mismatched packet count (Siena filter and FPGA) */
+#define          MC_CMD_PTP_MANF_FILTER_COUNT 0x7
+/* enum: Not enough packets to perform timestamp check */
+#define          MC_CMD_PTP_MANF_PACKET_ENOUGH 0x8
+/* enum: Timestamp trigger GPIO not working */
+#define          MC_CMD_PTP_MANF_GPIO_TRIGGER 0x9
+/* Presence of external oscillator */
 #define       MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_EXTOSC_OFST 4
 
 /* MC_CMD_PTP_OUT_MANFTEST_PACKET msgresponse */
 #define    MC_CMD_PTP_OUT_MANFTEST_PACKET_LEN 12
+/* Results of testing */
 #define       MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_RESULT_OFST 0
+/* Number of packets received by FPGA */
 #define       MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FPGACOUNT_OFST 4
+/* Number of packets received by Siena filters */
 #define       MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FILTERCOUNT_OFST 8
 
+/* MC_CMD_PTP_OUT_FPGAREAD msgresponse */
+#define    MC_CMD_PTP_OUT_FPGAREAD_LENMIN 1
+#define    MC_CMD_PTP_OUT_FPGAREAD_LENMAX 252
+#define    MC_CMD_PTP_OUT_FPGAREAD_LEN(num) (0+1*(num))
+#define       MC_CMD_PTP_OUT_FPGAREAD_BUFFER_OFST 0
+#define       MC_CMD_PTP_OUT_FPGAREAD_BUFFER_LEN 1
+#define       MC_CMD_PTP_OUT_FPGAREAD_BUFFER_MINNUM 1
+#define       MC_CMD_PTP_OUT_FPGAREAD_BUFFER_MAXNUM 252
+
 
 /***********************************/
 /* MC_CMD_CSR_READ32
 
 /* MC_CMD_CSR_READ32_IN msgrequest */
 #define    MC_CMD_CSR_READ32_IN_LEN 12
+/* Address */
 #define       MC_CMD_CSR_READ32_IN_ADDR_OFST 0
 #define       MC_CMD_CSR_READ32_IN_STEP_OFST 4
 #define       MC_CMD_CSR_READ32_IN_NUMWORDS_OFST 8
 #define    MC_CMD_CSR_READ32_OUT_LENMIN 4
 #define    MC_CMD_CSR_READ32_OUT_LENMAX 252
 #define    MC_CMD_CSR_READ32_OUT_LEN(num) (0+4*(num))
+/* The last dword is the status, not a value read */
 #define       MC_CMD_CSR_READ32_OUT_BUFFER_OFST 0
 #define       MC_CMD_CSR_READ32_OUT_BUFFER_LEN 4
 #define       MC_CMD_CSR_READ32_OUT_BUFFER_MINNUM 1
 #define    MC_CMD_CSR_WRITE32_IN_LENMIN 12
 #define    MC_CMD_CSR_WRITE32_IN_LENMAX 252
 #define    MC_CMD_CSR_WRITE32_IN_LEN(num) (8+4*(num))
+/* Address */
 #define       MC_CMD_CSR_WRITE32_IN_ADDR_OFST 0
 #define       MC_CMD_CSR_WRITE32_IN_STEP_OFST 4
 #define       MC_CMD_CSR_WRITE32_IN_BUFFER_OFST 8
 #define       MC_CMD_CSR_WRITE32_OUT_STATUS_OFST 0
 
 
+/***********************************/
+/* MC_CMD_HP
+ * These commands are used for HP related features. They are grouped under one
+ * MCDI command to avoid creating too many MCDI commands.
+ */
+#define MC_CMD_HP 0x54
+
+/* MC_CMD_HP_IN msgrequest */
+#define    MC_CMD_HP_IN_LEN 16
+/* HP OCSD sub-command. When address is not NULL, request activation of OCSD at
+ * the specified address with the specified interval.When address is NULL,
+ * INTERVAL is interpreted as a command: 0: stop OCSD / 1: Report OCSD current
+ * state / 2: (debug) Show temperature reported by one of the supported
+ * sensors.
+ */
+#define       MC_CMD_HP_IN_SUBCMD_OFST 0
+/* enum: OCSD (Option Card Sensor Data) sub-command. */
+#define          MC_CMD_HP_IN_OCSD_SUBCMD 0x0
+/* enum: Last known valid HP sub-command. */
+#define          MC_CMD_HP_IN_LAST_SUBCMD 0x0
+/* The address to the array of sensor fields. (Or NULL to use a sub-command.)
+ */
+#define       MC_CMD_HP_IN_OCSD_ADDR_OFST 4
+#define       MC_CMD_HP_IN_OCSD_ADDR_LEN 8
+#define       MC_CMD_HP_IN_OCSD_ADDR_LO_OFST 4
+#define       MC_CMD_HP_IN_OCSD_ADDR_HI_OFST 8
+/* The requested update interval, in seconds. (Or the sub-command if ADDR is
+ * NULL.)
+ */
+#define       MC_CMD_HP_IN_OCSD_INTERVAL_OFST 12
+
+/* MC_CMD_HP_OUT msgresponse */
+#define    MC_CMD_HP_OUT_LEN 4
+#define       MC_CMD_HP_OUT_OCSD_STATUS_OFST 0
+/* enum: OCSD stopped for this card. */
+#define          MC_CMD_HP_OUT_OCSD_STOPPED 0x1
+/* enum: OCSD was successfully started with the address provided. */
+#define          MC_CMD_HP_OUT_OCSD_STARTED 0x2
+/* enum: OCSD was already started for this card. */
+#define          MC_CMD_HP_OUT_OCSD_ALREADY_STARTED 0x3
+
+
 /***********************************/
 /* MC_CMD_STACKINFO
  * Get stack information.
 #define    MC_CMD_STACKINFO_OUT_LENMIN 12
 #define    MC_CMD_STACKINFO_OUT_LENMAX 252
 #define    MC_CMD_STACKINFO_OUT_LEN(num) (0+12*(num))
+/* (thread ptr, stack size, free space) for each thread in system */
 #define       MC_CMD_STACKINFO_OUT_THREAD_INFO_OFST 0
 #define       MC_CMD_STACKINFO_OUT_THREAD_INFO_LEN 12
 #define       MC_CMD_STACKINFO_OUT_THREAD_INFO_MINNUM 1
 
 /* MC_CMD_MDIO_READ_IN msgrequest */
 #define    MC_CMD_MDIO_READ_IN_LEN 16
+/* Bus number; there are two MDIO buses: one for the internal PHY, and one for
+ * external devices.
+ */
 #define       MC_CMD_MDIO_READ_IN_BUS_OFST 0
-#define          MC_CMD_MDIO_BUS_INTERNAL 0x0 /* enum */
-#define          MC_CMD_MDIO_BUS_EXTERNAL 0x1 /* enum */
+/* enum: Internal. */
+#define          MC_CMD_MDIO_BUS_INTERNAL 0x0
+/* enum: External. */
+#define          MC_CMD_MDIO_BUS_EXTERNAL 0x1
+/* Port address */
 #define       MC_CMD_MDIO_READ_IN_PRTAD_OFST 4
+/* Device Address or clause 22. */
 #define       MC_CMD_MDIO_READ_IN_DEVAD_OFST 8
-#define          MC_CMD_MDIO_CLAUSE22 0x20 /* enum */
+/* enum: By default all the MCDI MDIO operations perform clause45 mode. If you
+ * want to use clause22 then set DEVAD = MC_CMD_MDIO_CLAUSE22.
+ */
+#define          MC_CMD_MDIO_CLAUSE22 0x20
+/* Address */
 #define       MC_CMD_MDIO_READ_IN_ADDR_OFST 12
 
 /* MC_CMD_MDIO_READ_OUT msgresponse */
 #define    MC_CMD_MDIO_READ_OUT_LEN 8
+/* Value */
 #define       MC_CMD_MDIO_READ_OUT_VALUE_OFST 0
+/* Status the MDIO commands return the raw status bits from the MDIO block. A
+ * "good" transaction should have the DONE bit set and all other bits clear.
+ */
 #define       MC_CMD_MDIO_READ_OUT_STATUS_OFST 4
-#define          MC_CMD_MDIO_STATUS_GOOD 0x8 /* enum */
+/* enum: Good. */
+#define          MC_CMD_MDIO_STATUS_GOOD 0x8
 
 
 /***********************************/
 
 /* MC_CMD_MDIO_WRITE_IN msgrequest */
 #define    MC_CMD_MDIO_WRITE_IN_LEN 20
+/* Bus number; there are two MDIO buses: one for the internal PHY, and one for
+ * external devices.
+ */
 #define       MC_CMD_MDIO_WRITE_IN_BUS_OFST 0
+/* enum: Internal. */
 /*               MC_CMD_MDIO_BUS_INTERNAL 0x0 */
+/* enum: External. */
 /*               MC_CMD_MDIO_BUS_EXTERNAL 0x1 */
+/* Port address */
 #define       MC_CMD_MDIO_WRITE_IN_PRTAD_OFST 4
+/* Device Address or clause 22. */
 #define       MC_CMD_MDIO_WRITE_IN_DEVAD_OFST 8
+/* enum: By default all the MCDI MDIO operations perform clause45 mode. If you
+ * want to use clause22 then set DEVAD = MC_CMD_MDIO_CLAUSE22.
+ */
 /*               MC_CMD_MDIO_CLAUSE22 0x20 */
+/* Address */
 #define       MC_CMD_MDIO_WRITE_IN_ADDR_OFST 12
+/* Value */
 #define       MC_CMD_MDIO_WRITE_IN_VALUE_OFST 16
 
 /* MC_CMD_MDIO_WRITE_OUT msgresponse */
 #define    MC_CMD_MDIO_WRITE_OUT_LEN 4
+/* Status; the MDIO commands return the raw status bits from the MDIO block. A
+ * "good" transaction should have the DONE bit set and all other bits clear.
+ */
 #define       MC_CMD_MDIO_WRITE_OUT_STATUS_OFST 0
+/* enum: Good. */
 /*               MC_CMD_MDIO_STATUS_GOOD 0x8 */
 
 
 #define    MC_CMD_DBI_WRITE_IN_LENMIN 12
 #define    MC_CMD_DBI_WRITE_IN_LENMAX 252
 #define    MC_CMD_DBI_WRITE_IN_LEN(num) (0+12*(num))
+/* Each write op consists of an address (offset 0), byte enable/VF/CS2 (offset
+ * 32) and value (offset 64). See MC_CMD_DBIWROP_TYPEDEF.
+ */
 #define       MC_CMD_DBI_WRITE_IN_DBIWROP_OFST 0
 #define       MC_CMD_DBI_WRITE_IN_DBIWROP_LEN 12
 #define       MC_CMD_DBI_WRITE_IN_DBIWROP_MINNUM 1
 #define       MC_CMD_DBIWROP_TYPEDEF_ADDRESS_OFST 0
 #define       MC_CMD_DBIWROP_TYPEDEF_ADDRESS_LBN 0
 #define       MC_CMD_DBIWROP_TYPEDEF_ADDRESS_WIDTH 32
-#define       MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_OFST 4
-#define       MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_LBN 32
-#define       MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_WIDTH 32
+#define       MC_CMD_DBIWROP_TYPEDEF_PARMS_OFST 4
+#define        MC_CMD_DBIWROP_TYPEDEF_VF_NUM_LBN 16
+#define        MC_CMD_DBIWROP_TYPEDEF_VF_NUM_WIDTH 16
+#define        MC_CMD_DBIWROP_TYPEDEF_VF_ACTIVE_LBN 15
+#define        MC_CMD_DBIWROP_TYPEDEF_VF_ACTIVE_WIDTH 1
+#define        MC_CMD_DBIWROP_TYPEDEF_CS2_LBN 14
+#define        MC_CMD_DBIWROP_TYPEDEF_CS2_WIDTH 1
+#define       MC_CMD_DBIWROP_TYPEDEF_PARMS_LBN 32
+#define       MC_CMD_DBIWROP_TYPEDEF_PARMS_WIDTH 32
 #define       MC_CMD_DBIWROP_TYPEDEF_VALUE_OFST 8
 #define       MC_CMD_DBIWROP_TYPEDEF_VALUE_LBN 64
 #define       MC_CMD_DBIWROP_TYPEDEF_VALUE_WIDTH 32
 
 /***********************************/
 /* MC_CMD_PORT_READ32
- * Read a 32-bit register from the indirect port register map.
+ * Read a 32-bit register from the indirect port register map. The port to
+ * access is implied by the Shared memory channel used.
  */
 #define MC_CMD_PORT_READ32 0x14
 
 /* MC_CMD_PORT_READ32_IN msgrequest */
 #define    MC_CMD_PORT_READ32_IN_LEN 4
+/* Address */
 #define       MC_CMD_PORT_READ32_IN_ADDR_OFST 0
 
 /* MC_CMD_PORT_READ32_OUT msgresponse */
 #define    MC_CMD_PORT_READ32_OUT_LEN 8
+/* Value */
 #define       MC_CMD_PORT_READ32_OUT_VALUE_OFST 0
+/* Status */
 #define       MC_CMD_PORT_READ32_OUT_STATUS_OFST 4
 
 
 /***********************************/
 /* MC_CMD_PORT_WRITE32
- * Write a 32-bit register to the indirect port register map.
+ * Write a 32-bit register to the indirect port register map. The port to
+ * access is implied by the Shared memory channel used.
  */
 #define MC_CMD_PORT_WRITE32 0x15
 
 /* MC_CMD_PORT_WRITE32_IN msgrequest */
 #define    MC_CMD_PORT_WRITE32_IN_LEN 8
+/* Address */
 #define       MC_CMD_PORT_WRITE32_IN_ADDR_OFST 0
+/* Value */
 #define       MC_CMD_PORT_WRITE32_IN_VALUE_OFST 4
 
 /* MC_CMD_PORT_WRITE32_OUT msgresponse */
 #define    MC_CMD_PORT_WRITE32_OUT_LEN 4
+/* Status */
 #define       MC_CMD_PORT_WRITE32_OUT_STATUS_OFST 0
 
 
 /***********************************/
 /* MC_CMD_PORT_READ128
- * Read a 128-bit register from the indirect port register map.
+ * Read a 128-bit register from the indirect port register map. The port to
+ * access is implied by the Shared memory channel used.
  */
 #define MC_CMD_PORT_READ128 0x16
 
 /* MC_CMD_PORT_READ128_IN msgrequest */
 #define    MC_CMD_PORT_READ128_IN_LEN 4
+/* Address */
 #define       MC_CMD_PORT_READ128_IN_ADDR_OFST 0
 
 /* MC_CMD_PORT_READ128_OUT msgresponse */
 #define    MC_CMD_PORT_READ128_OUT_LEN 20
+/* Value */
 #define       MC_CMD_PORT_READ128_OUT_VALUE_OFST 0
 #define       MC_CMD_PORT_READ128_OUT_VALUE_LEN 16
+/* Status */
 #define       MC_CMD_PORT_READ128_OUT_STATUS_OFST 16
 
 
 /***********************************/
 /* MC_CMD_PORT_WRITE128
- * Write a 128-bit register to the indirect port register map.
+ * Write a 128-bit register to the indirect port register map. The port to
+ * access is implied by the Shared memory channel used.
  */
 #define MC_CMD_PORT_WRITE128 0x17
 
 /* MC_CMD_PORT_WRITE128_IN msgrequest */
 #define    MC_CMD_PORT_WRITE128_IN_LEN 20
+/* Address */
 #define       MC_CMD_PORT_WRITE128_IN_ADDR_OFST 0
+/* Value */
 #define       MC_CMD_PORT_WRITE128_IN_VALUE_OFST 4
 #define       MC_CMD_PORT_WRITE128_IN_VALUE_LEN 16
 
 /* MC_CMD_PORT_WRITE128_OUT msgresponse */
 #define    MC_CMD_PORT_WRITE128_OUT_LEN 4
+/* Status */
 #define       MC_CMD_PORT_WRITE128_OUT_STATUS_OFST 0
 
+/* MC_CMD_CAPABILITIES structuredef */
+#define    MC_CMD_CAPABILITIES_LEN 4
+/* Small buf table. */
+#define       MC_CMD_CAPABILITIES_SMALL_BUF_TBL_LBN 0
+#define       MC_CMD_CAPABILITIES_SMALL_BUF_TBL_WIDTH 1
+/* Turbo mode (for Maranello). */
+#define       MC_CMD_CAPABILITIES_TURBO_LBN 1
+#define       MC_CMD_CAPABILITIES_TURBO_WIDTH 1
+/* Turbo mode active (for Maranello). */
+#define       MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN 2
+#define       MC_CMD_CAPABILITIES_TURBO_ACTIVE_WIDTH 1
+/* PTP offload. */
+#define       MC_CMD_CAPABILITIES_PTP_LBN 3
+#define       MC_CMD_CAPABILITIES_PTP_WIDTH 1
+/* AOE mode. */
+#define       MC_CMD_CAPABILITIES_AOE_LBN 4
+#define       MC_CMD_CAPABILITIES_AOE_WIDTH 1
+/* AOE mode active. */
+#define       MC_CMD_CAPABILITIES_AOE_ACTIVE_LBN 5
+#define       MC_CMD_CAPABILITIES_AOE_ACTIVE_WIDTH 1
+/* AOE mode active. */
+#define       MC_CMD_CAPABILITIES_FC_ACTIVE_LBN 6
+#define       MC_CMD_CAPABILITIES_FC_ACTIVE_WIDTH 1
+#define       MC_CMD_CAPABILITIES_RESERVED_LBN 7
+#define       MC_CMD_CAPABILITIES_RESERVED_WIDTH 25
+
 
 /***********************************/
 /* MC_CMD_GET_BOARD_CFG
 #define       MC_CMD_GET_BOARD_CFG_OUT_BOARD_TYPE_OFST 0
 #define       MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_OFST 4
 #define       MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_LEN 32
+/* See MC_CMD_CAPABILITIES */
 #define       MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT0_OFST 36
-#define          MC_CMD_CAPABILITIES_SMALL_BUF_TBL_LBN 0x0 /* enum */
-#define          MC_CMD_CAPABILITIES_SMALL_BUF_TBL_WIDTH 0x1 /* enum */
-#define          MC_CMD_CAPABILITIES_TURBO_LBN 0x1 /* enum */
-#define          MC_CMD_CAPABILITIES_TURBO_WIDTH 0x1 /* enum */
-#define          MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN 0x2 /* enum */
-#define          MC_CMD_CAPABILITIES_TURBO_ACTIVE_WIDTH 0x1 /* enum */
-#define          MC_CMD_CAPABILITIES_PTP_LBN 0x3 /* enum */
-#define          MC_CMD_CAPABILITIES_PTP_WIDTH 0x1 /* enum */
+/* See MC_CMD_CAPABILITIES */
 #define       MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT1_OFST 40
-/*            Enum values, see field(s): */
-/*               CAPABILITIES_PORT0 */
 #define       MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST 44
 #define       MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_LEN 6
 #define       MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_OFST 50
 #define       MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT1_OFST 60
 #define       MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT0_OFST 64
 #define       MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT1_OFST 68
+/* This field contains a 16-bit value for each of the types of NVRAM area. The
+ * values are defined in the firmware/mc/platform/.c file for a specific board
+ * type, but otherwise have no meaning to the MC; they are used by the driver
+ * to manage selection of appropriate firmware updates.
+ */
 #define       MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST 72
 #define       MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN 2
 #define       MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM 12
 
 /***********************************/
 /* MC_CMD_DBI_READX
- * Read DBI register(s).
+ * Read DBI register(s) -- extended functionality
  */
 #define MC_CMD_DBI_READX 0x19
 
 #define    MC_CMD_DBI_READX_IN_LENMIN 8
 #define    MC_CMD_DBI_READX_IN_LENMAX 248
 #define    MC_CMD_DBI_READX_IN_LEN(num) (0+8*(num))
+/* Each Read op consists of an address (offset 0), VF/CS2) */
 #define       MC_CMD_DBI_READX_IN_DBIRDOP_OFST 0
 #define       MC_CMD_DBI_READX_IN_DBIRDOP_LEN 8
 #define       MC_CMD_DBI_READX_IN_DBIRDOP_LO_OFST 0
 #define    MC_CMD_DBI_READX_OUT_LENMIN 4
 #define    MC_CMD_DBI_READX_OUT_LENMAX 252
 #define    MC_CMD_DBI_READX_OUT_LEN(num) (0+4*(num))
+/* Value */
 #define       MC_CMD_DBI_READX_OUT_VALUE_OFST 0
 #define       MC_CMD_DBI_READX_OUT_VALUE_LEN 4
 #define       MC_CMD_DBI_READX_OUT_VALUE_MINNUM 1
 #define       MC_CMD_DBI_READX_OUT_VALUE_MAXNUM 63
 
+/* MC_CMD_DBIRDOP_TYPEDEF structuredef */
+#define    MC_CMD_DBIRDOP_TYPEDEF_LEN 8
+#define       MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_OFST 0
+#define       MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_LBN 0
+#define       MC_CMD_DBIRDOP_TYPEDEF_ADDRESS_WIDTH 32
+#define       MC_CMD_DBIRDOP_TYPEDEF_PARMS_OFST 4
+#define        MC_CMD_DBIRDOP_TYPEDEF_VF_NUM_LBN 16
+#define        MC_CMD_DBIRDOP_TYPEDEF_VF_NUM_WIDTH 16
+#define        MC_CMD_DBIRDOP_TYPEDEF_VF_ACTIVE_LBN 15
+#define        MC_CMD_DBIRDOP_TYPEDEF_VF_ACTIVE_WIDTH 1
+#define        MC_CMD_DBIRDOP_TYPEDEF_CS2_LBN 14
+#define        MC_CMD_DBIRDOP_TYPEDEF_CS2_WIDTH 1
+#define       MC_CMD_DBIRDOP_TYPEDEF_PARMS_LBN 32
+#define       MC_CMD_DBIRDOP_TYPEDEF_PARMS_WIDTH 32
+
 
 /***********************************/
 /* MC_CMD_SET_RAND_SEED
 
 /* MC_CMD_SET_RAND_SEED_IN msgrequest */
 #define    MC_CMD_SET_RAND_SEED_IN_LEN 16
+/* Seed value. */
 #define       MC_CMD_SET_RAND_SEED_IN_SEED_OFST 0
 #define       MC_CMD_SET_RAND_SEED_IN_SEED_LEN 16
 
 
 /***********************************/
 /* MC_CMD_LTSSM_HIST
- * Retrieve the history of the PCIE LTSSM.
+ * Retrieve the history of the LTSSM, if the build supports it.
  */
 #define MC_CMD_LTSSM_HIST 0x1b
 
 #define    MC_CMD_LTSSM_HIST_OUT_LENMIN 0
 #define    MC_CMD_LTSSM_HIST_OUT_LENMAX 252
 #define    MC_CMD_LTSSM_HIST_OUT_LEN(num) (0+4*(num))
+/* variable number of LTSSM values, as bytes. The history is read-to-clear. */
 #define       MC_CMD_LTSSM_HIST_OUT_DATA_OFST 0
 #define       MC_CMD_LTSSM_HIST_OUT_DATA_LEN 4
 #define       MC_CMD_LTSSM_HIST_OUT_DATA_MINNUM 0
 
 /***********************************/
 /* MC_CMD_DRV_ATTACH
- * Inform MCPU that this port is managed on the host.
+ * Inform MCPU that this port is managed on the host (i.e. driver active). For
+ * Huntington, also request the preferred datapath firmware to use if possible
+ * (it may not be possible for this request to be fulfilled; the driver must
+ * issue a subsequent MC_CMD_GET_CAPABILITIES command to determine which
+ * features are actually available). The FIRMWARE_ID field is ignored by older
+ * platforms.
  */
 #define MC_CMD_DRV_ATTACH 0x1c
 
 /* MC_CMD_DRV_ATTACH_IN msgrequest */
-#define    MC_CMD_DRV_ATTACH_IN_LEN 8
+#define    MC_CMD_DRV_ATTACH_IN_LEN 12
+/* new state (0=detached, 1=attached) to set if UPDATE=1 */
 #define       MC_CMD_DRV_ATTACH_IN_NEW_STATE_OFST 0
+/* 1 to set new state, or 0 to just report the existing state */
 #define       MC_CMD_DRV_ATTACH_IN_UPDATE_OFST 4
+/* preferred datapath firmware (for Huntington; ignored for Siena) */
+#define       MC_CMD_DRV_ATTACH_IN_FIRMWARE_ID_OFST 8
+/* enum: Prefer to use full featured firmware */
+#define          MC_CMD_FW_FULL_FEATURED 0x0
+/* enum: Prefer to use firmware with fewer features but lower latency */
+#define          MC_CMD_FW_LOW_LATENCY 0x1
 
 /* MC_CMD_DRV_ATTACH_OUT msgresponse */
 #define    MC_CMD_DRV_ATTACH_OUT_LEN 4
+/* previous or existing state (0=detached, 1=attached) */
 #define       MC_CMD_DRV_ATTACH_OUT_OLD_STATE_OFST 0
 
-
-/***********************************/
-/* MC_CMD_NCSI_PROD
- * Trigger an NC-SI event.
+/* MC_CMD_DRV_ATTACH_EXT_OUT msgresponse */
+#define    MC_CMD_DRV_ATTACH_EXT_OUT_LEN 8
+/* previous or existing state (0=detached, 1=attached) */
+#define       MC_CMD_DRV_ATTACH_EXT_OUT_OLD_STATE_OFST 0
+/* Flags associated with this function */
+#define       MC_CMD_DRV_ATTACH_EXT_OUT_FUNC_FLAGS_OFST 4
+/* enum: Labels the lowest-numbered function visible to the OS */
+#define          MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY 0x0
+/* enum: The function can control the link state of the physical port it is
+ * bound to.
  */
-#define MC_CMD_NCSI_PROD 0x1d
-
-/* MC_CMD_NCSI_PROD_IN msgrequest */
-#define    MC_CMD_NCSI_PROD_IN_LEN 4
-#define       MC_CMD_NCSI_PROD_IN_EVENTS_OFST 0
-#define          MC_CMD_NCSI_PROD_LINKCHANGE 0x0 /* enum */
-#define          MC_CMD_NCSI_PROD_RESET 0x1 /* enum */
-#define          MC_CMD_NCSI_PROD_DRVATTACH 0x2 /* enum */
-#define        MC_CMD_NCSI_PROD_IN_LINKCHANGE_LBN 0
-#define        MC_CMD_NCSI_PROD_IN_LINKCHANGE_WIDTH 1
-#define        MC_CMD_NCSI_PROD_IN_RESET_LBN 1
-#define        MC_CMD_NCSI_PROD_IN_RESET_WIDTH 1
-#define        MC_CMD_NCSI_PROD_IN_DRVATTACH_LBN 2
-#define        MC_CMD_NCSI_PROD_IN_DRVATTACH_WIDTH 1
-
-/* MC_CMD_NCSI_PROD_OUT msgresponse */
-#define    MC_CMD_NCSI_PROD_OUT_LEN 0
+#define          MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_LINKCTRL 0x1
+/* enum: The function can perform privileged operations */
+#define          MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_TRUSTED 0x2
 
 
 /***********************************/
 
 /* MC_CMD_SHMUART_IN msgrequest */
 #define    MC_CMD_SHMUART_IN_LEN 4
+/* ??? */
 #define       MC_CMD_SHMUART_IN_FLAG_OFST 0
 
 /* MC_CMD_SHMUART_OUT msgresponse */
 #define    MC_CMD_SHMUART_OUT_LEN 0
 
 
+/***********************************/
+/* MC_CMD_PORT_RESET
+ * Generic per-port reset. There is no equivalent for per-board reset. Locks
+ * required: None; Return code: 0, ETIME. NOTE: This command is deprecated -
+ * use MC_CMD_ENTITY_RESET instead.
+ */
+#define MC_CMD_PORT_RESET 0x20
+
+/* MC_CMD_PORT_RESET_IN msgrequest */
+#define    MC_CMD_PORT_RESET_IN_LEN 0
+
+/* MC_CMD_PORT_RESET_OUT msgresponse */
+#define    MC_CMD_PORT_RESET_OUT_LEN 0
+
+
 /***********************************/
 /* MC_CMD_ENTITY_RESET
- * Generic per-port reset.
+ * Generic per-resource reset. There is no equivalent for per-board reset.
+ * Locks required: None; Return code: 0, ETIME. NOTE: This command is an
+ * extended version of the deprecated MC_CMD_PORT_RESET with added fields.
  */
 #define MC_CMD_ENTITY_RESET 0x20
 
 /* MC_CMD_ENTITY_RESET_IN msgrequest */
 #define    MC_CMD_ENTITY_RESET_IN_LEN 4
+/* Optional flags field. Omitting this will perform a "legacy" reset action
+ * (TBD).
+ */
 #define       MC_CMD_ENTITY_RESET_IN_FLAG_OFST 0
 #define        MC_CMD_ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET_LBN 0
 #define        MC_CMD_ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET_WIDTH 1
 
 /* MC_CMD_PCIE_CREDITS_IN msgrequest */
 #define    MC_CMD_PCIE_CREDITS_IN_LEN 8
+/* poll period. 0 is disabled */
 #define       MC_CMD_PCIE_CREDITS_IN_POLL_PERIOD_OFST 0
+/* wipe statistics */
 #define       MC_CMD_PCIE_CREDITS_IN_WIPE_OFST 4
 
 /* MC_CMD_PCIE_CREDITS_OUT msgresponse */
 
 /***********************************/
 /* MC_CMD_PUTS
- * puts(3) implementation over MCDI
+ * Copy the given ASCII string out onto UART and/or out of the network port.
  */
 #define MC_CMD_PUTS 0x23
 
 
 /***********************************/
 /* MC_CMD_GET_PHY_CFG
- * Report PHY configuration.
+ * Report PHY configuration. This guarantees to succeed even if the PHY is in a
+ * 'zombie' state. Locks required: None
  */
 #define MC_CMD_GET_PHY_CFG 0x24
 
 
 /* MC_CMD_GET_PHY_CFG_OUT msgresponse */
 #define    MC_CMD_GET_PHY_CFG_OUT_LEN 72
+/* flags */
 #define       MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0
 #define        MC_CMD_GET_PHY_CFG_OUT_PRESENT_LBN 0
 #define        MC_CMD_GET_PHY_CFG_OUT_PRESENT_WIDTH 1
 #define        MC_CMD_GET_PHY_CFG_OUT_TXDIS_WIDTH 1
 #define        MC_CMD_GET_PHY_CFG_OUT_BIST_LBN 6
 #define        MC_CMD_GET_PHY_CFG_OUT_BIST_WIDTH 1
+/* ?? */
 #define       MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4
+/* Bitmask of supported capabilities */
 #define       MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8
 #define        MC_CMD_PHY_CAP_10HDX_LBN 1
 #define        MC_CMD_PHY_CAP_10HDX_WIDTH 1
 #define        MC_CMD_PHY_CAP_ASYM_WIDTH 1
 #define        MC_CMD_PHY_CAP_AN_LBN 10
 #define        MC_CMD_PHY_CAP_AN_WIDTH 1
+#define        MC_CMD_PHY_CAP_40000FDX_LBN 11
+#define        MC_CMD_PHY_CAP_40000FDX_WIDTH 1
+#define        MC_CMD_PHY_CAP_DDM_LBN 12
+#define        MC_CMD_PHY_CAP_DDM_WIDTH 1
+/* ?? */
 #define       MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12
+/* ?? */
 #define       MC_CMD_GET_PHY_CFG_OUT_PRT_OFST 16
+/* ?? */
 #define       MC_CMD_GET_PHY_CFG_OUT_STATS_MASK_OFST 20
+/* ?? */
 #define       MC_CMD_GET_PHY_CFG_OUT_NAME_OFST 24
 #define       MC_CMD_GET_PHY_CFG_OUT_NAME_LEN 20
+/* ?? */
 #define       MC_CMD_GET_PHY_CFG_OUT_MEDIA_TYPE_OFST 44
-#define          MC_CMD_MEDIA_XAUI 0x1 /* enum */
-#define          MC_CMD_MEDIA_CX4 0x2 /* enum */
-#define          MC_CMD_MEDIA_KX4 0x3 /* enum */
-#define          MC_CMD_MEDIA_XFP 0x4 /* enum */
-#define          MC_CMD_MEDIA_SFP_PLUS 0x5 /* enum */
-#define          MC_CMD_MEDIA_BASE_T 0x6 /* enum */
+/* enum: Xaui. */
+#define          MC_CMD_MEDIA_XAUI 0x1
+/* enum: CX4. */
+#define          MC_CMD_MEDIA_CX4 0x2
+/* enum: KX4. */
+#define          MC_CMD_MEDIA_KX4 0x3
+/* enum: XFP Far. */
+#define          MC_CMD_MEDIA_XFP 0x4
+/* enum: SFP+. */
+#define          MC_CMD_MEDIA_SFP_PLUS 0x5
+/* enum: 10GBaseT. */
+#define          MC_CMD_MEDIA_BASE_T 0x6
 #define       MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_OFST 48
-#define          MC_CMD_MMD_CLAUSE22 0x0 /* enum */
+/* enum: Native clause 22 */
+#define          MC_CMD_MMD_CLAUSE22 0x0
 #define          MC_CMD_MMD_CLAUSE45_PMAPMD 0x1 /* enum */
 #define          MC_CMD_MMD_CLAUSE45_WIS 0x2 /* enum */
 #define          MC_CMD_MMD_CLAUSE45_PCS 0x3 /* enum */
 #define          MC_CMD_MMD_CLAUSE45_DTEXS 0x5 /* enum */
 #define          MC_CMD_MMD_CLAUSE45_TC 0x6 /* enum */
 #define          MC_CMD_MMD_CLAUSE45_AN 0x7 /* enum */
-#define          MC_CMD_MMD_CLAUSE45_C22EXT 0x1d /* enum */
+/* enum: Clause22 proxied over clause45 by PHY. */
+#define          MC_CMD_MMD_CLAUSE45_C22EXT 0x1d
 #define          MC_CMD_MMD_CLAUSE45_VEND1 0x1e /* enum */
 #define          MC_CMD_MMD_CLAUSE45_VEND2 0x1f /* enum */
 #define       MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52
 
 /***********************************/
 /* MC_CMD_START_BIST
- * Start a BIST test on the PHY.
+ * Start a BIST test on the PHY. Locks required: PHY_LOCK if doing a PHY BIST
+ * Return code: 0, EINVAL, EACCES (if PHY_LOCK is not held)
  */
 #define MC_CMD_START_BIST 0x25
 
 /* MC_CMD_START_BIST_IN msgrequest */
 #define    MC_CMD_START_BIST_IN_LEN 4
+/* Type of test. */
 #define       MC_CMD_START_BIST_IN_TYPE_OFST 0
-#define          MC_CMD_PHY_BIST_CABLE_SHORT 0x1 /* enum */
-#define          MC_CMD_PHY_BIST_CABLE_LONG 0x2 /* enum */
-#define          MC_CMD_BPX_SERDES_BIST 0x3 /* enum */
-#define          MC_CMD_MC_LOOPBACK_BIST 0x4 /* enum */
-#define          MC_CMD_PHY_BIST 0x5 /* enum */
+/* enum: Run the PHY's short cable BIST. */
+#define          MC_CMD_PHY_BIST_CABLE_SHORT 0x1
+/* enum: Run the PHY's long cable BIST. */
+#define          MC_CMD_PHY_BIST_CABLE_LONG 0x2
+/* enum: Run BIST on the currently selected BPX Serdes (XAUI or XFI) . */
+#define          MC_CMD_BPX_SERDES_BIST 0x3
+/* enum: Run the MC loopback tests. */
+#define          MC_CMD_MC_LOOPBACK_BIST 0x4
+/* enum: Run the PHY's standard BIST. */
+#define          MC_CMD_PHY_BIST 0x5
+/* enum: Run MC RAM test. */
+#define          MC_CMD_MC_MEM_BIST 0x6
+/* enum: Run Port RAM test. */
+#define          MC_CMD_PORT_MEM_BIST 0x7
+/* enum: Run register test. */
+#define          MC_CMD_REG_BIST 0x8
 
 /* MC_CMD_START_BIST_OUT msgresponse */
 #define    MC_CMD_START_BIST_OUT_LEN 0
 
 /***********************************/
 /* MC_CMD_POLL_BIST
- * Poll for BIST completion.
+ * Poll for BIST completion. Returns a single status code, and optionally some
+ * PHY specific bist output. The driver should only consume the BIST output
+ * after validating OUTLEN and MC_CMD_GET_PHY_CFG.TYPE. If a driver can't
+ * successfully parse the BIST output, it should still respect the pass/Fail in
+ * OUT.RESULT. Locks required: PHY_LOCK if doing a PHY BIST. Return code: 0,
+ * EACCES (if PHY_LOCK is not held).
  */
 #define MC_CMD_POLL_BIST 0x26
 
 
 /* MC_CMD_POLL_BIST_OUT msgresponse */
 #define    MC_CMD_POLL_BIST_OUT_LEN 8
+/* result */
 #define       MC_CMD_POLL_BIST_OUT_RESULT_OFST 0
-#define          MC_CMD_POLL_BIST_RUNNING 0x1 /* enum */
-#define          MC_CMD_POLL_BIST_PASSED 0x2 /* enum */
-#define          MC_CMD_POLL_BIST_FAILED 0x3 /* enum */
-#define          MC_CMD_POLL_BIST_TIMEOUT 0x4 /* enum */
+/* enum: Running. */
+#define          MC_CMD_POLL_BIST_RUNNING 0x1
+/* enum: Passed. */
+#define          MC_CMD_POLL_BIST_PASSED 0x2
+/* enum: Failed. */
+#define          MC_CMD_POLL_BIST_FAILED 0x3
+/* enum: Timed-out. */
+#define          MC_CMD_POLL_BIST_TIMEOUT 0x4
 #define       MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4
 
 /* MC_CMD_POLL_BIST_OUT_SFT9001 msgresponse */
 #define    MC_CMD_POLL_BIST_OUT_SFT9001_LEN 36
+/* result */
 /*            MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */
 /*            Enum values, see field(s): */
 /*               MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_B_OFST 8
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_C_OFST 12
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_D_OFST 16
+/* Status of each channel A */
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_A_OFST 20
-#define          MC_CMD_POLL_BIST_SFT9001_PAIR_OK 0x1 /* enum */
-#define          MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 0x2 /* enum */
-#define          MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 0x3 /* enum */
-#define          MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 0x4 /* enum */
-#define          MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 0x9 /* enum */
+/* enum: Ok. */
+#define          MC_CMD_POLL_BIST_SFT9001_PAIR_OK 0x1
+/* enum: Open. */
+#define          MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 0x2
+/* enum: Intra-pair short. */
+#define          MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 0x3
+/* enum: Inter-pair short. */
+#define          MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 0x4
+/* enum: Busy. */
+#define          MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 0x9
+/* Status of each channel B */
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_B_OFST 24
 /*            Enum values, see field(s): */
 /*               CABLE_STATUS_A */
+/* Status of each channel C */
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_C_OFST 28
 /*            Enum values, see field(s): */
 /*               CABLE_STATUS_A */
+/* Status of each channel D */
 #define       MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_D_OFST 32
 /*            Enum values, see field(s): */
 /*               CABLE_STATUS_A */
 
 /* MC_CMD_POLL_BIST_OUT_MRSFP msgresponse */
 #define    MC_CMD_POLL_BIST_OUT_MRSFP_LEN 8
+/* result */
 /*            MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */
 /*            Enum values, see field(s): */
 /*               MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */
 #define       MC_CMD_POLL_BIST_OUT_MRSFP_TEST_OFST 4
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0x0 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 0x1 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 0x2 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 0x3 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 0x4 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 0x5 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 0x6 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 0x7 /* enum */
-#define          MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 0x8 /* enum */
+/* enum: Complete. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0x0
+/* enum: Bus switch off I2C write. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 0x1
+/* enum: Bus switch off I2C no access IO exp. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 0x2
+/* enum: Bus switch off I2C no access module. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 0x3
+/* enum: IO exp I2C configure. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 0x4
+/* enum: Bus switch I2C no cross talk. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 0x5
+/* enum: Module presence. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 0x6
+/* enum: Module ID I2C access. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 0x7
+/* enum: Module ID sane value. */
+#define          MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 0x8
+
+/* MC_CMD_POLL_BIST_OUT_MEM msgresponse */
+#define    MC_CMD_POLL_BIST_OUT_MEM_LEN 36
+/* result */
+/*            MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */
+/*            Enum values, see field(s): */
+/*               MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */
+#define       MC_CMD_POLL_BIST_OUT_MEM_TEST_OFST 4
+/* enum: Test has completed. */
+#define          MC_CMD_POLL_BIST_MEM_COMPLETE 0x0
+/* enum: RAM test - walk ones. */
+#define          MC_CMD_POLL_BIST_MEM_MEM_WALK_ONES 0x1
+/* enum: RAM test - walk zeros. */
+#define          MC_CMD_POLL_BIST_MEM_MEM_WALK_ZEROS 0x2
+/* enum: RAM test - walking inversions zeros/ones. */
+#define          MC_CMD_POLL_BIST_MEM_MEM_INV_ZERO_ONE 0x3
+/* enum: RAM test - walking inversions checkerboard. */
+#define          MC_CMD_POLL_BIST_MEM_MEM_INV_CHKBOARD 0x4
+/* enum: Register test - set / clear individual bits. */
+#define          MC_CMD_POLL_BIST_MEM_REG 0x5
+/* enum: ECC error detected. */
+#define          MC_CMD_POLL_BIST_MEM_ECC 0x6
+/* Failure address, only valid if result is POLL_BIST_FAILED */
+#define       MC_CMD_POLL_BIST_OUT_MEM_ADDR_OFST 8
+/* Bus or address space to which the failure address corresponds */
+#define       MC_CMD_POLL_BIST_OUT_MEM_BUS_OFST 12
+/* enum: MC MIPS bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_MC 0x0
+/* enum: CSR IREG bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_CSR 0x1
+/* enum: RX DPCPU bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_DPCPU_RX 0x2
+/* enum: TX0 DPCPU bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_DPCPU_TX0 0x3
+/* enum: TX1 DPCPU bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_DPCPU_TX1 0x4
+/* enum: RX DICPU bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_DICPU_RX 0x5
+/* enum: TX DICPU bus. */
+#define          MC_CMD_POLL_BIST_MEM_BUS_DICPU_TX 0x6
+/* Pattern written to RAM / register */
+#define       MC_CMD_POLL_BIST_OUT_MEM_EXPECT_OFST 16
+/* Actual value read from RAM / register */
+#define       MC_CMD_POLL_BIST_OUT_MEM_ACTUAL_OFST 20
+/* ECC error mask */
+#define       MC_CMD_POLL_BIST_OUT_MEM_ECC_OFST 24
+/* ECC parity error mask */
+#define       MC_CMD_POLL_BIST_OUT_MEM_ECC_PARITY_OFST 28
+/* ECC fatal error mask */
+#define       MC_CMD_POLL_BIST_OUT_MEM_ECC_FATAL_OFST 32
 
 
 /***********************************/
 /* MC_CMD_FLUSH_RX_QUEUES
- * Flush receive queue(s).
+ * Flush receive queue(s). If SRIOV is enabled (via MC_CMD_SRIOV), then RXQ
+ * flushes should be initiated via this MCDI operation, rather than via
+ * directly writing FLUSH_CMD.
+ *
+ * The flush is completed (either done/fail) asynchronously (after this command
+ * returns). The driver must still wait for flush done/failure events as usual.
  */
 #define MC_CMD_FLUSH_RX_QUEUES 0x27
 
 
 /***********************************/
 /* MC_CMD_GET_LOOPBACK_MODES
- * Get port's loopback modes.
+ * Returns a bitmask of loopback modes available at each speed.
  */
 #define MC_CMD_GET_LOOPBACK_MODES 0x28
 
 #define    MC_CMD_GET_LOOPBACK_MODES_IN_LEN 0
 
 /* MC_CMD_GET_LOOPBACK_MODES_OUT msgresponse */
-#define    MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 32
+#define    MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 40
+/* Supported loopbacks. */
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_100M_OFST 0
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_100M_LEN 8
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_100M_LO_OFST 0
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_100M_HI_OFST 4
-#define          MC_CMD_LOOPBACK_NONE  0x0 /* enum */
-#define          MC_CMD_LOOPBACK_DATA  0x1 /* enum */
-#define          MC_CMD_LOOPBACK_GMAC  0x2 /* enum */
-#define          MC_CMD_LOOPBACK_XGMII 0x3 /* enum */
-#define          MC_CMD_LOOPBACK_XGXS  0x4 /* enum */
-#define          MC_CMD_LOOPBACK_XAUI  0x5 /* enum */
-#define          MC_CMD_LOOPBACK_GMII  0x6 /* enum */
-#define          MC_CMD_LOOPBACK_SGMII  0x7 /* enum */
-#define          MC_CMD_LOOPBACK_XGBR  0x8 /* enum */
-#define          MC_CMD_LOOPBACK_XFI  0x9 /* enum */
-#define          MC_CMD_LOOPBACK_XAUI_FAR  0xa /* enum */
-#define          MC_CMD_LOOPBACK_GMII_FAR  0xb /* enum */
-#define          MC_CMD_LOOPBACK_SGMII_FAR  0xc /* enum */
-#define          MC_CMD_LOOPBACK_XFI_FAR  0xd /* enum */
-#define          MC_CMD_LOOPBACK_GPHY  0xe /* enum */
-#define          MC_CMD_LOOPBACK_PHYXS  0xf /* enum */
-#define          MC_CMD_LOOPBACK_PCS  0x10 /* enum */
-#define          MC_CMD_LOOPBACK_PMAPMD  0x11 /* enum */
-#define          MC_CMD_LOOPBACK_XPORT  0x12 /* enum */
-#define          MC_CMD_LOOPBACK_XGMII_WS  0x13 /* enum */
-#define          MC_CMD_LOOPBACK_XAUI_WS  0x14 /* enum */
-#define          MC_CMD_LOOPBACK_XAUI_WS_FAR  0x15 /* enum */
-#define          MC_CMD_LOOPBACK_XAUI_WS_NEAR  0x16 /* enum */
-#define          MC_CMD_LOOPBACK_GMII_WS  0x17 /* enum */
-#define          MC_CMD_LOOPBACK_XFI_WS  0x18 /* enum */
-#define          MC_CMD_LOOPBACK_XFI_WS_FAR  0x19 /* enum */
-#define          MC_CMD_LOOPBACK_PHYXS_WS  0x1a /* enum */
+/* enum: None. */
+#define          MC_CMD_LOOPBACK_NONE  0x0
+/* enum: Data. */
+#define          MC_CMD_LOOPBACK_DATA  0x1
+/* enum: GMAC. */
+#define          MC_CMD_LOOPBACK_GMAC  0x2
+/* enum: XGMII. */
+#define          MC_CMD_LOOPBACK_XGMII 0x3
+/* enum: XGXS. */
+#define          MC_CMD_LOOPBACK_XGXS  0x4
+/* enum: XAUI. */
+#define          MC_CMD_LOOPBACK_XAUI  0x5
+/* enum: GMII. */
+#define          MC_CMD_LOOPBACK_GMII  0x6
+/* enum: SGMII. */
+#define          MC_CMD_LOOPBACK_SGMII  0x7
+/* enum: XGBR. */
+#define          MC_CMD_LOOPBACK_XGBR  0x8
+/* enum: XFI. */
+#define          MC_CMD_LOOPBACK_XFI  0x9
+/* enum: XAUI Far. */
+#define          MC_CMD_LOOPBACK_XAUI_FAR  0xa
+/* enum: GMII Far. */
+#define          MC_CMD_LOOPBACK_GMII_FAR  0xb
+/* enum: SGMII Far. */
+#define          MC_CMD_LOOPBACK_SGMII_FAR  0xc
+/* enum: XFI Far. */
+#define          MC_CMD_LOOPBACK_XFI_FAR  0xd
+/* enum: GPhy. */
+#define          MC_CMD_LOOPBACK_GPHY  0xe
+/* enum: PhyXS. */
+#define          MC_CMD_LOOPBACK_PHYXS  0xf
+/* enum: PCS. */
+#define          MC_CMD_LOOPBACK_PCS  0x10
+/* enum: PMA-PMD. */
+#define          MC_CMD_LOOPBACK_PMAPMD  0x11
+/* enum: Cross-Port. */
+#define          MC_CMD_LOOPBACK_XPORT  0x12
+/* enum: XGMII-Wireside. */
+#define          MC_CMD_LOOPBACK_XGMII_WS  0x13
+/* enum: XAUI Wireside. */
+#define          MC_CMD_LOOPBACK_XAUI_WS  0x14
+/* enum: XAUI Wireside Far. */
+#define          MC_CMD_LOOPBACK_XAUI_WS_FAR  0x15
+/* enum: XAUI Wireside near. */
+#define          MC_CMD_LOOPBACK_XAUI_WS_NEAR  0x16
+/* enum: GMII Wireside. */
+#define          MC_CMD_LOOPBACK_GMII_WS  0x17
+/* enum: XFI Wireside. */
+#define          MC_CMD_LOOPBACK_XFI_WS  0x18
+/* enum: XFI Wireside Far. */
+#define          MC_CMD_LOOPBACK_XFI_WS_FAR  0x19
+/* enum: PhyXS Wireside. */
+#define          MC_CMD_LOOPBACK_PHYXS_WS  0x1a
+/* enum: PMA lanes MAC-Serdes. */
+#define          MC_CMD_LOOPBACK_PMA_INT  0x1b
+/* enum: KR Serdes Parallel (Encoder). */
+#define          MC_CMD_LOOPBACK_SD_NEAR  0x1c
+/* enum: KR Serdes Serial. */
+#define          MC_CMD_LOOPBACK_SD_FAR  0x1d
+/* enum: PMA lanes MAC-Serdes Wireside. */
+#define          MC_CMD_LOOPBACK_PMA_INT_WS  0x1e
+/* enum: KR Serdes Parallel Wireside (Full PCS). */
+#define          MC_CMD_LOOPBACK_SD_FEP2_WS  0x1f
+/* enum: KR Serdes Parallel Wireside (Sym Aligner to TX). */
+#define          MC_CMD_LOOPBACK_SD_FEP1_5_WS  0x20
+/* enum: KR Serdes Parallel Wireside (Deserializer to Serializer). */
+#define          MC_CMD_LOOPBACK_SD_FEP_WS  0x21
+/* enum: KR Serdes Serial Wireside. */
+#define          MC_CMD_LOOPBACK_SD_FES_WS  0x22
+/* Supported loopbacks. */
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_1G_OFST 8
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LEN 8
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LO_OFST 8
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_1G_HI_OFST 12
 /*            Enum values, see field(s): */
 /*               100M */
+/* Supported loopbacks. */
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_10G_OFST 16
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_10G_LEN 8
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_10G_LO_OFST 16
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_10G_HI_OFST 20
 /*            Enum values, see field(s): */
 /*               100M */
+/* Supported loopbacks. */
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_OFST 24
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LEN 8
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LO_OFST 24
 #define       MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_HI_OFST 28
 /*            Enum values, see field(s): */
 /*               100M */
+/* Supported loopbacks. */
+#define       MC_CMD_GET_LOOPBACK_MODES_OUT_40G_OFST 32
+#define       MC_CMD_GET_LOOPBACK_MODES_OUT_40G_LEN 8
+#define       MC_CMD_GET_LOOPBACK_MODES_OUT_40G_LO_OFST 32
+#define       MC_CMD_GET_LOOPBACK_MODES_OUT_40G_HI_OFST 36
+/*            Enum values, see field(s): */
+/*               100M */
 
 
 /***********************************/
 /* MC_CMD_GET_LINK
- * Read the unified MAC/PHY link state.
+ * Read the unified MAC/PHY link state. Locks required: None Return code: 0,
+ * ETIME.
  */
 #define MC_CMD_GET_LINK 0x29
 
 
 /* MC_CMD_GET_LINK_OUT msgresponse */
 #define    MC_CMD_GET_LINK_OUT_LEN 28
+/* near-side advertised capabilities */
 #define       MC_CMD_GET_LINK_OUT_CAP_OFST 0
+/* link-partner advertised capabilities */
 #define       MC_CMD_GET_LINK_OUT_LP_CAP_OFST 4
+/* Autonegotiated speed in mbit/s. The link may still be down even if this
+ * reads non-zero.
+ */
 #define       MC_CMD_GET_LINK_OUT_LINK_SPEED_OFST 8
+/* Current loopback setting. */
 #define       MC_CMD_GET_LINK_OUT_LOOPBACK_MODE_OFST 12
 /*            Enum values, see field(s): */
 /*               MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */
 #define        MC_CMD_GET_LINK_OUT_BPX_LINK_WIDTH 1
 #define        MC_CMD_GET_LINK_OUT_PHY_LINK_LBN 3
 #define        MC_CMD_GET_LINK_OUT_PHY_LINK_WIDTH 1
+/* This returns the negotiated flow control value. */
 #define       MC_CMD_GET_LINK_OUT_FCNTL_OFST 20
-#define          MC_CMD_FCNTL_OFF 0x0 /* enum */
-#define          MC_CMD_FCNTL_RESPOND 0x1 /* enum */
-#define          MC_CMD_FCNTL_BIDIR 0x2 /* enum */
+/* enum: Flow control is off. */
+#define          MC_CMD_FCNTL_OFF 0x0
+/* enum: Respond to flow control. */
+#define          MC_CMD_FCNTL_RESPOND 0x1
+/* enum: Respond to and Issue flow control. */
+#define          MC_CMD_FCNTL_BIDIR 0x2
 #define       MC_CMD_GET_LINK_OUT_MAC_FAULT_OFST 24
 #define        MC_CMD_MAC_FAULT_XGMII_LOCAL_LBN 0
 #define        MC_CMD_MAC_FAULT_XGMII_LOCAL_WIDTH 1
 
 /***********************************/
 /* MC_CMD_SET_LINK
- * Write the unified MAC/PHY link configuration.
+ * Write the unified MAC/PHY link configuration. Locks required: None. Return
+ * code: 0, EINVAL, ETIME
  */
 #define MC_CMD_SET_LINK 0x2a
 
 /* MC_CMD_SET_LINK_IN msgrequest */
 #define    MC_CMD_SET_LINK_IN_LEN 16
+/* ??? */
 #define       MC_CMD_SET_LINK_IN_CAP_OFST 0
+/* Flags */
 #define       MC_CMD_SET_LINK_IN_FLAGS_OFST 4
 #define        MC_CMD_SET_LINK_IN_LOWPOWER_LBN 0
 #define        MC_CMD_SET_LINK_IN_LOWPOWER_WIDTH 1
 #define        MC_CMD_SET_LINK_IN_POWEROFF_WIDTH 1
 #define        MC_CMD_SET_LINK_IN_TXDIS_LBN 2
 #define        MC_CMD_SET_LINK_IN_TXDIS_WIDTH 1
+/* Loopback mode. */
 #define       MC_CMD_SET_LINK_IN_LOOPBACK_MODE_OFST 8
 /*            Enum values, see field(s): */
 /*               MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */
+/* A loopback speed of "0" is supported, and means (choose any available
+ * speed).
+ */
 #define       MC_CMD_SET_LINK_IN_LOOPBACK_SPEED_OFST 12
 
 /* MC_CMD_SET_LINK_OUT msgresponse */
 
 /***********************************/
 /* MC_CMD_SET_ID_LED
- * Set indentification LED state.
+ * Set identification LED state. Locks required: None. Return code: 0, EINVAL
  */
 #define MC_CMD_SET_ID_LED 0x2b
 
 /* MC_CMD_SET_ID_LED_IN msgrequest */
 #define    MC_CMD_SET_ID_LED_IN_LEN 4
+/* Set LED state. */
 #define       MC_CMD_SET_ID_LED_IN_STATE_OFST 0
 #define          MC_CMD_LED_OFF  0x0 /* enum */
 #define          MC_CMD_LED_ON  0x1 /* enum */
 
 /***********************************/
 /* MC_CMD_SET_MAC
- * Set MAC configuration.
+ * Set MAC configuration. Locks required: None. Return code: 0, EINVAL
  */
 #define MC_CMD_SET_MAC 0x2c
 
 /* MC_CMD_SET_MAC_IN msgrequest */
 #define    MC_CMD_SET_MAC_IN_LEN 24
+/* The MTU is the MTU programmed directly into the XMAC/GMAC (inclusive of
+ * EtherII, VLAN, bug16011 padding).
+ */
 #define       MC_CMD_SET_MAC_IN_MTU_OFST 0
 #define       MC_CMD_SET_MAC_IN_DRAIN_OFST 4
 #define       MC_CMD_SET_MAC_IN_ADDR_OFST 8
 #define        MC_CMD_SET_MAC_IN_REJECT_BRDCST_LBN 1
 #define        MC_CMD_SET_MAC_IN_REJECT_BRDCST_WIDTH 1
 #define       MC_CMD_SET_MAC_IN_FCNTL_OFST 20
+/* enum: Flow control is off. */
 /*               MC_CMD_FCNTL_OFF 0x0 */
+/* enum: Respond to flow control. */
 /*               MC_CMD_FCNTL_RESPOND 0x1 */
+/* enum: Respond to and Issue flow control. */
 /*               MC_CMD_FCNTL_BIDIR 0x2 */
-#define          MC_CMD_FCNTL_AUTO 0x3 /* enum */
+/* enum: Auto neg flow control. */
+#define          MC_CMD_FCNTL_AUTO 0x3
 
 /* MC_CMD_SET_MAC_OUT msgresponse */
 #define    MC_CMD_SET_MAC_OUT_LEN 0
 
 /***********************************/
 /* MC_CMD_PHY_STATS
- * Get generic PHY statistics.
+ * Get generic PHY statistics. This call returns the statistics for a generic
+ * PHY in a sparse array (indexed by the enumerate). Each value is represented
+ * by a 32bit number. If the DMA_ADDR is 0, then no DMA is performed, and the
+ * statistics may be read from the message response. If DMA_ADDR != 0, then the
+ * statistics are dmad to that (page-aligned location). Locks required: None.
+ * Returns: 0, ETIME
  */
 #define MC_CMD_PHY_STATS 0x2d
 
 /* MC_CMD_PHY_STATS_IN msgrequest */
 #define    MC_CMD_PHY_STATS_IN_LEN 8
+/* ??? */
 #define       MC_CMD_PHY_STATS_IN_DMA_ADDR_OFST 0
 #define       MC_CMD_PHY_STATS_IN_DMA_ADDR_LEN 8
 #define       MC_CMD_PHY_STATS_IN_DMA_ADDR_LO_OFST 0
 #define       MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_OFST 0
 #define       MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_LEN 4
 #define       MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_NUM MC_CMD_PHY_NSTATS
-#define          MC_CMD_OUI  0x0 /* enum */
-#define          MC_CMD_PMA_PMD_LINK_UP  0x1 /* enum */
-#define          MC_CMD_PMA_PMD_RX_FAULT  0x2 /* enum */
-#define          MC_CMD_PMA_PMD_TX_FAULT  0x3 /* enum */
-#define          MC_CMD_PMA_PMD_SIGNAL  0x4 /* enum */
-#define          MC_CMD_PMA_PMD_SNR_A  0x5 /* enum */
-#define          MC_CMD_PMA_PMD_SNR_B  0x6 /* enum */
-#define          MC_CMD_PMA_PMD_SNR_C  0x7 /* enum */
-#define          MC_CMD_PMA_PMD_SNR_D  0x8 /* enum */
-#define          MC_CMD_PCS_LINK_UP  0x9 /* enum */
-#define          MC_CMD_PCS_RX_FAULT  0xa /* enum */
-#define          MC_CMD_PCS_TX_FAULT  0xb /* enum */
-#define          MC_CMD_PCS_BER  0xc /* enum */
-#define          MC_CMD_PCS_BLOCK_ERRORS  0xd /* enum */
-#define          MC_CMD_PHYXS_LINK_UP  0xe /* enum */
-#define          MC_CMD_PHYXS_RX_FAULT  0xf /* enum */
-#define          MC_CMD_PHYXS_TX_FAULT  0x10 /* enum */
-#define          MC_CMD_PHYXS_ALIGN  0x11 /* enum */
-#define          MC_CMD_PHYXS_SYNC  0x12 /* enum */
-#define          MC_CMD_AN_LINK_UP  0x13 /* enum */
-#define          MC_CMD_AN_COMPLETE  0x14 /* enum */
-#define          MC_CMD_AN_10GBT_STATUS  0x15 /* enum */
-#define          MC_CMD_CL22_LINK_UP  0x16 /* enum */
-#define          MC_CMD_PHY_NSTATS  0x17 /* enum */
+/* enum: OUI. */
+#define          MC_CMD_OUI  0x0
+/* enum: PMA-PMD Link Up. */
+#define          MC_CMD_PMA_PMD_LINK_UP  0x1
+/* enum: PMA-PMD RX Fault. */
+#define          MC_CMD_PMA_PMD_RX_FAULT  0x2
+/* enum: PMA-PMD TX Fault. */
+#define          MC_CMD_PMA_PMD_TX_FAULT  0x3
+/* enum: PMA-PMD Signal */
+#define          MC_CMD_PMA_PMD_SIGNAL  0x4
+/* enum: PMA-PMD SNR A. */
+#define          MC_CMD_PMA_PMD_SNR_A  0x5
+/* enum: PMA-PMD SNR B. */
+#define          MC_CMD_PMA_PMD_SNR_B  0x6
+/* enum: PMA-PMD SNR C. */
+#define          MC_CMD_PMA_PMD_SNR_C  0x7
+/* enum: PMA-PMD SNR D. */
+#define          MC_CMD_PMA_PMD_SNR_D  0x8
+/* enum: PCS Link Up. */
+#define          MC_CMD_PCS_LINK_UP  0x9
+/* enum: PCS RX Fault. */
+#define          MC_CMD_PCS_RX_FAULT  0xa
+/* enum: PCS TX Fault. */
+#define          MC_CMD_PCS_TX_FAULT  0xb
+/* enum: PCS BER. */
+#define          MC_CMD_PCS_BER  0xc
+/* enum: PCS Block Errors. */
+#define          MC_CMD_PCS_BLOCK_ERRORS  0xd
+/* enum: PhyXS Link Up. */
+#define          MC_CMD_PHYXS_LINK_UP  0xe
+/* enum: PhyXS RX Fault. */
+#define          MC_CMD_PHYXS_RX_FAULT  0xf
+/* enum: PhyXS TX Fault. */
+#define          MC_CMD_PHYXS_TX_FAULT  0x10
+/* enum: PhyXS Align. */
+#define          MC_CMD_PHYXS_ALIGN  0x11
+/* enum: PhyXS Sync. */
+#define          MC_CMD_PHYXS_SYNC  0x12
+/* enum: AN link-up. */
+#define          MC_CMD_AN_LINK_UP  0x13
+/* enum: AN Complete. */
+#define          MC_CMD_AN_COMPLETE  0x14
+/* enum: AN 10GBaseT Status. */
+#define          MC_CMD_AN_10GBT_STATUS  0x15
+/* enum: Clause 22 Link-Up. */
+#define          MC_CMD_CL22_LINK_UP  0x16
+/* enum: (Last entry) */
+#define          MC_CMD_PHY_NSTATS  0x17
 
 
 /***********************************/
 /* MC_CMD_MAC_STATS
- * Get generic MAC statistics.
+ * Get generic MAC statistics. This call returns unified statistics maintained
+ * by the MC as it switches between the GMAC and XMAC. The MC will write out
+ * all supported stats. The driver should zero initialise the buffer to
+ * guarantee consistent results. If the DMA_ADDR is 0, then no DMA is
+ * performed, and the statistics may be read from the message response. If
+ * DMA_ADDR != 0, then the statistics are dmad to that (page-aligned location).
+ * Locks required: None. Returns: 0, ETIME
  */
 #define MC_CMD_MAC_STATS 0x2e
 
 /* MC_CMD_MAC_STATS_IN msgrequest */
 #define    MC_CMD_MAC_STATS_IN_LEN 16
+/* ??? */
 #define       MC_CMD_MAC_STATS_IN_DMA_ADDR_OFST 0
 #define       MC_CMD_MAC_STATS_IN_DMA_ADDR_LEN 8
 #define       MC_CMD_MAC_STATS_IN_DMA_ADDR_LO_OFST 0
 
 /* MC_CMD_MEMCPY_RECORD_TYPEDEF structuredef */
 #define    MC_CMD_MEMCPY_RECORD_TYPEDEF_LEN 32
+/* this is only used for the first record */
 #define       MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_OFST 0
 #define       MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_LBN 0
 #define       MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_WIDTH 32
 
 /***********************************/
 /* MC_CMD_MEMCPY
- * Perform memory copy operation.
+ * DMA write data into (Rid,Addr), either by dma reading (Rid,Addr), or by data
+ * embedded directly in the command.
+ *
+ * A common pattern is for a client to use generation counts to signal a dma
+ * update of a datastructure. To facilitate this, this MCDI operation can
+ * contain multiple requests which are executed in strict order. Requests take
+ * the form of duplicating the entire MCDI request continuously (including the
+ * requests record, which is ignored in all but the first structure)
+ *
+ * The source data can either come from a DMA from the host, or it can be
+ * embedded within the request directly, thereby eliminating a DMA read. To
+ * indicate this, the client sets FROM_RID=%RID_INLINE, ADDR_HI=0, and
+ * ADDR_LO=offset, and inserts the data at %offset from the start of the
+ * payload. It's the callers responsibility to ensure that the embedded data
+ * doesn't overlap the records.
+ *
+ * Returns: 0, EINVAL (invalid RID)
  */
 #define MC_CMD_MEMCPY 0x31
 
 #define    MC_CMD_MEMCPY_IN_LENMIN 32
 #define    MC_CMD_MEMCPY_IN_LENMAX 224
 #define    MC_CMD_MEMCPY_IN_LEN(num) (0+32*(num))
+/* see MC_CMD_MEMCPY_RECORD_TYPEDEF */
 #define       MC_CMD_MEMCPY_IN_RECORD_OFST 0
 #define       MC_CMD_MEMCPY_IN_RECORD_LEN 32
 #define       MC_CMD_MEMCPY_IN_RECORD_MINNUM 1
 #define       MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0
 #define          MC_CMD_FILTER_MODE_SIMPLE    0x0 /* enum */
 #define          MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff /* enum */
+/* A type value of 1 is unused. */
 #define       MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4
-#define          MC_CMD_WOL_TYPE_MAGIC      0x0 /* enum */
-#define          MC_CMD_WOL_TYPE_WIN_MAGIC 0x2 /* enum */
-#define          MC_CMD_WOL_TYPE_IPV4_SYN   0x3 /* enum */
-#define          MC_CMD_WOL_TYPE_IPV6_SYN   0x4 /* enum */
-#define          MC_CMD_WOL_TYPE_BITMAP     0x5 /* enum */
-#define          MC_CMD_WOL_TYPE_LINK       0x6 /* enum */
-#define          MC_CMD_WOL_TYPE_MAX        0x7 /* enum */
+/* enum: Magic */
+#define          MC_CMD_WOL_TYPE_MAGIC      0x0
+/* enum: MS Windows Magic */
+#define          MC_CMD_WOL_TYPE_WIN_MAGIC 0x2
+/* enum: IPv4 Syn */
+#define          MC_CMD_WOL_TYPE_IPV4_SYN   0x3
+/* enum: IPv6 Syn */
+#define          MC_CMD_WOL_TYPE_IPV6_SYN   0x4
+/* enum: Bitmap */
+#define          MC_CMD_WOL_TYPE_BITMAP     0x5
+/* enum: Link */
+#define          MC_CMD_WOL_TYPE_LINK       0x6
+/* enum: (Above this for future use) */
+#define          MC_CMD_WOL_TYPE_MAX        0x7
 #define       MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 8
 #define       MC_CMD_WOL_FILTER_SET_IN_DATA_LEN 4
 #define       MC_CMD_WOL_FILTER_SET_IN_DATA_NUM 46
 
 /***********************************/
 /* MC_CMD_WOL_FILTER_REMOVE
- * Remove a WoL filter.
+ * Remove a WoL filter. Locks required: None. Returns: 0, EINVAL, ENOSYS
  */
 #define MC_CMD_WOL_FILTER_REMOVE 0x33
 
 
 /***********************************/
 /* MC_CMD_WOL_FILTER_RESET
- * Reset (i.e. remove all) WoL filters.
+ * Reset (i.e. remove all) WoL filters. Locks required: None. Returns: 0,
+ * ENOSYS
  */
 #define MC_CMD_WOL_FILTER_RESET 0x34
 
 
 /***********************************/
 /* MC_CMD_SET_MCAST_HASH
- * Set the MCASH hash value.
+ * Set the MCAST hash value without otherwise reconfiguring the MAC
  */
 #define MC_CMD_SET_MCAST_HASH 0x35
 
 
 /***********************************/
 /* MC_CMD_NVRAM_TYPES
- * Get virtual NVRAM partitions information.
+ * Return bitfield indicating available types of virtual NVRAM partitions.
+ * Locks required: none. Returns: 0
  */
 #define MC_CMD_NVRAM_TYPES 0x36
 
 
 /* MC_CMD_NVRAM_TYPES_OUT msgresponse */
 #define    MC_CMD_NVRAM_TYPES_OUT_LEN 4
+/* Bit mask of supported types. */
 #define       MC_CMD_NVRAM_TYPES_OUT_TYPES_OFST 0
-#define          MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO 0x0 /* enum */
-#define          MC_CMD_NVRAM_TYPE_MC_FW 0x1 /* enum */
-#define          MC_CMD_NVRAM_TYPE_MC_FW_BACKUP 0x2 /* enum */
-#define          MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 0x3 /* enum */
-#define          MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1 0x4 /* enum */
-#define          MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 0x5 /* enum */
-#define          MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1 0x6 /* enum */
-#define          MC_CMD_NVRAM_TYPE_EXP_ROM 0x7 /* enum */
-#define          MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0 0x8 /* enum */
-#define          MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1 0x9 /* enum */
-#define          MC_CMD_NVRAM_TYPE_PHY_PORT0 0xa /* enum */
-#define          MC_CMD_NVRAM_TYPE_PHY_PORT1 0xb /* enum */
-#define          MC_CMD_NVRAM_TYPE_LOG 0xc /* enum */
-#define          MC_CMD_NVRAM_TYPE_FPGA 0xd /* enum */
+/* enum: Disabled callisto. */
+#define          MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO 0x0
+/* enum: MC firmware. */
+#define          MC_CMD_NVRAM_TYPE_MC_FW 0x1
+/* enum: MC backup firmware. */
+#define          MC_CMD_NVRAM_TYPE_MC_FW_BACKUP 0x2
+/* enum: Static configuration Port0. */
+#define          MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 0x3
+/* enum: Static configuration Port1. */
+#define          MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1 0x4
+/* enum: Dynamic configuration Port0. */
+#define          MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 0x5
+/* enum: Dynamic configuration Port1. */
+#define          MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1 0x6
+/* enum: Expansion Rom. */
+#define          MC_CMD_NVRAM_TYPE_EXP_ROM 0x7
+/* enum: Expansion Rom Configuration Port0. */
+#define          MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0 0x8
+/* enum: Expansion Rom Configuration Port1. */
+#define          MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1 0x9
+/* enum: Phy Configuration Port0. */
+#define          MC_CMD_NVRAM_TYPE_PHY_PORT0 0xa
+/* enum: Phy Configuration Port1. */
+#define          MC_CMD_NVRAM_TYPE_PHY_PORT1 0xb
+/* enum: Log. */
+#define          MC_CMD_NVRAM_TYPE_LOG 0xc
+/* enum: FPGA image. */
+#define          MC_CMD_NVRAM_TYPE_FPGA 0xd
+/* enum: FPGA backup image */
+#define          MC_CMD_NVRAM_TYPE_FPGA_BACKUP 0xe
+/* enum: FC firmware. */
+#define          MC_CMD_NVRAM_TYPE_FC_FW 0xf
+/* enum: FC backup firmware. */
+#define          MC_CMD_NVRAM_TYPE_FC_FW_BACKUP 0x10
+/* enum: CPLD image. */
+#define          MC_CMD_NVRAM_TYPE_CPLD 0x11
+/* enum: Licensing information. */
+#define          MC_CMD_NVRAM_TYPE_LICENSE 0x12
+/* enum: FC Log. */
+#define          MC_CMD_NVRAM_TYPE_FC_LOG 0x13
 
 
 /***********************************/
 /* MC_CMD_NVRAM_INFO
- * Read info about a virtual NVRAM partition.
+ * Read info about a virtual NVRAM partition. Locks required: none. Returns: 0,
+ * EINVAL (bad type).
  */
 #define MC_CMD_NVRAM_INFO 0x37
 
 #define       MC_CMD_NVRAM_INFO_OUT_FLAGS_OFST 12
 #define        MC_CMD_NVRAM_INFO_OUT_PROTECTED_LBN 0
 #define        MC_CMD_NVRAM_INFO_OUT_PROTECTED_WIDTH 1
+#define        MC_CMD_NVRAM_INFO_OUT_TLV_LBN 1
+#define        MC_CMD_NVRAM_INFO_OUT_TLV_WIDTH 1
+#define        MC_CMD_NVRAM_INFO_OUT_A_B_LBN 7
+#define        MC_CMD_NVRAM_INFO_OUT_A_B_WIDTH 1
 #define       MC_CMD_NVRAM_INFO_OUT_PHYSDEV_OFST 16
 #define       MC_CMD_NVRAM_INFO_OUT_PHYSADDR_OFST 20
 
 
 /***********************************/
 /* MC_CMD_NVRAM_UPDATE_START
- * Start a group of update operations on a virtual NVRAM partition.
+ * Start a group of update operations on a virtual NVRAM partition. Locks
+ * required: PHY_LOCK if type==*PHY*. Returns: 0, EINVAL (bad type), EACCES (if
+ * PHY_LOCK required and not held).
  */
 #define MC_CMD_NVRAM_UPDATE_START 0x38
 
 
 /***********************************/
 /* MC_CMD_NVRAM_READ
- * Read data from a virtual NVRAM partition.
+ * Read data from a virtual NVRAM partition. Locks required: PHY_LOCK if
+ * type==*PHY*. Returns: 0, EINVAL (bad type/offset/length), EACCES (if
+ * PHY_LOCK required and not held)
  */
 #define MC_CMD_NVRAM_READ 0x39
 
 /*            Enum values, see field(s): */
 /*               MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
 #define       MC_CMD_NVRAM_READ_IN_OFFSET_OFST 4
+/* amount to read in bytes */
 #define       MC_CMD_NVRAM_READ_IN_LENGTH_OFST 8
 
 /* MC_CMD_NVRAM_READ_OUT msgresponse */
 
 /***********************************/
 /* MC_CMD_NVRAM_WRITE
- * Write data to a virtual NVRAM partition.
+ * Write data to a virtual NVRAM partition. Locks required: PHY_LOCK if
+ * type==*PHY*. Returns: 0, EINVAL (bad type/offset/length), EACCES (if
+ * PHY_LOCK required and not held)
  */
 #define MC_CMD_NVRAM_WRITE 0x3a
 
 
 /***********************************/
 /* MC_CMD_NVRAM_ERASE
- * Erase sector(s) from a virtual NVRAM partition.
+ * Erase sector(s) from a virtual NVRAM partition. Locks required: PHY_LOCK if
+ * type==*PHY*. Returns: 0, EINVAL (bad type/offset/length), EACCES (if
+ * PHY_LOCK required and not held)
  */
 #define MC_CMD_NVRAM_ERASE 0x3b
 
 
 /***********************************/
 /* MC_CMD_NVRAM_UPDATE_FINISH
- * Finish a group of update operations on a virtual NVRAM partition.
+ * Finish a group of update operations on a virtual NVRAM partition. Locks
+ * required: PHY_LOCK if type==*PHY*. Returns: 0, EINVAL (bad
+ * type/offset/length), EACCES (if PHY_LOCK required and not held)
  */
 #define MC_CMD_NVRAM_UPDATE_FINISH 0x3c
 
 /***********************************/
 /* MC_CMD_REBOOT
  * Reboot the MC.
+ *
+ * The AFTER_ASSERTION flag is intended to be used when the driver notices an
+ * assertion failure (at which point it is expected to perform a complete tear
+ * down and reinitialise), to allow both ports to reset the MC once in an
+ * atomic fashion.
+ *
+ * Production mc firmwares are generally compiled with REBOOT_ON_ASSERT=1,
+ * which means that they will automatically reboot out of the assertion
+ * handler, so this is in practise an optional operation. It is still
+ * recommended that drivers execute this to support custom firmwares with
+ * REBOOT_ON_ASSERT=0.
+ *
+ * Locks required: NONE Returns: Nothing. You get back a response with ERR=1,
+ * DATALEN=0
  */
 #define MC_CMD_REBOOT 0x3d
 
 
 /***********************************/
 /* MC_CMD_SCHEDINFO
- * Request scheduler info.
+ * Request scheduler info. Locks required: NONE. Returns: An array of
+ * (timeslice,maximum overrun), one for each thread, in ascending order of
+ * thread address.
  */
 #define MC_CMD_SCHEDINFO 0x3e
 
 
 /***********************************/
 /* MC_CMD_REBOOT_MODE
+ * Set the mode for the next MC reboot. Locks required: NONE. Sets the reboot
+ * mode to the specified value. Returns the old mode.
  */
 #define MC_CMD_REBOOT_MODE 0x3f
 
 /* MC_CMD_REBOOT_MODE_IN msgrequest */
 #define    MC_CMD_REBOOT_MODE_IN_LEN 4
 #define       MC_CMD_REBOOT_MODE_IN_VALUE_OFST 0
-#define          MC_CMD_REBOOT_MODE_NORMAL 0x0 /* enum */
-#define          MC_CMD_REBOOT_MODE_SNAPPER 0x3 /* enum */
+/* enum: Normal. */
+#define          MC_CMD_REBOOT_MODE_NORMAL 0x0
+/* enum: Power-on Reset. */
+#define          MC_CMD_REBOOT_MODE_POR 0x2
+/* enum: Snapper. */
+#define          MC_CMD_REBOOT_MODE_SNAPPER 0x3
+/* enum: snapper fake POR */
+#define          MC_CMD_REBOOT_MODE_SNAPPER_POR 0x4
+#define        MC_CMD_REBOOT_MODE_IN_FAKE_LBN 7
+#define        MC_CMD_REBOOT_MODE_IN_FAKE_WIDTH 1
 
 /* MC_CMD_REBOOT_MODE_OUT msgresponse */
 #define    MC_CMD_REBOOT_MODE_OUT_LEN 4
 /***********************************/
 /* MC_CMD_SENSOR_INFO
  * Returns information about every available sensor.
+ *
+ * Each sensor has a single (16bit) value, and a corresponding state. The
+ * mapping between value and state is nominally determined by the MC, but may
+ * be implemented using up to 2 ranges per sensor.
+ *
+ * This call returns a mask (32bit) of the sensors that are supported by this
+ * platform, then an array of sensor information structures, in order of sensor
+ * type (but without gaps for unimplemented sensors). Each structure defines
+ * the ranges for the corresponding sensor. An unused range is indicated by
+ * equal limit values. If one range is used, a value outside that range results
+ * in STATE_FATAL. If two ranges are used, a value outside the second range
+ * results in STATE_FATAL while a value outside the first and inside the second
+ * range results in STATE_WARNING.
+ *
+ * Sensor masks and sensor information arrays are organised into pages. For
+ * backward compatibility, older host software can only use sensors in page 0.
+ * Bit 32 in the sensor mask was previously unused, and is no reserved for use
+ * as the next page flag.
+ *
+ * If the request does not contain a PAGE value then firmware will only return
+ * page 0 of sensor information, with bit 31 in the sensor mask cleared.
+ *
+ * If the request contains a PAGE value then firmware responds with the sensor
+ * mask and sensor information array for that page of sensors. In this case bit
+ * 31 in the mask is set if another page exists.
+ *
+ * Locks required: None Returns: 0
  */
 #define MC_CMD_SENSOR_INFO 0x41
 
 /* MC_CMD_SENSOR_INFO_IN msgrequest */
 #define    MC_CMD_SENSOR_INFO_IN_LEN 0
 
+/* MC_CMD_SENSOR_INFO_EXT_IN msgrequest */
+#define    MC_CMD_SENSOR_INFO_EXT_IN_LEN 4
+/* Which page of sensors to report.
+ *
+ * Page 0 contains sensors 0 to 30 (sensor 31 is the next page bit).
+ *
+ * Page 1 contains sensors 32 to 62 (sensor 63 is the next page bit). etc.
+ */
+#define       MC_CMD_SENSOR_INFO_EXT_IN_PAGE_OFST 0
+
 /* MC_CMD_SENSOR_INFO_OUT msgresponse */
 #define    MC_CMD_SENSOR_INFO_OUT_LENMIN 12
 #define    MC_CMD_SENSOR_INFO_OUT_LENMAX 252
 #define    MC_CMD_SENSOR_INFO_OUT_LEN(num) (4+8*(num))
 #define       MC_CMD_SENSOR_INFO_OUT_MASK_OFST 0
-#define          MC_CMD_SENSOR_CONTROLLER_TEMP  0x0 /* enum */
-#define          MC_CMD_SENSOR_PHY_COMMON_TEMP  0x1 /* enum */
-#define          MC_CMD_SENSOR_CONTROLLER_COOLING  0x2 /* enum */
-#define          MC_CMD_SENSOR_PHY0_TEMP  0x3 /* enum */
-#define          MC_CMD_SENSOR_PHY0_COOLING  0x4 /* enum */
-#define          MC_CMD_SENSOR_PHY1_TEMP  0x5 /* enum */
-#define          MC_CMD_SENSOR_PHY1_COOLING  0x6 /* enum */
-#define          MC_CMD_SENSOR_IN_1V0  0x7 /* enum */
-#define          MC_CMD_SENSOR_IN_1V2  0x8 /* enum */
-#define          MC_CMD_SENSOR_IN_1V8  0x9 /* enum */
-#define          MC_CMD_SENSOR_IN_2V5  0xa /* enum */
-#define          MC_CMD_SENSOR_IN_3V3  0xb /* enum */
-#define          MC_CMD_SENSOR_IN_12V0  0xc /* enum */
-#define          MC_CMD_SENSOR_IN_1V2A  0xd /* enum */
-#define          MC_CMD_SENSOR_IN_VREF  0xe /* enum */
+/* enum: Controller temperature: degC */
+#define          MC_CMD_SENSOR_CONTROLLER_TEMP  0x0
+/* enum: Phy common temperature: degC */
+#define          MC_CMD_SENSOR_PHY_COMMON_TEMP  0x1
+/* enum: Controller cooling: bool */
+#define          MC_CMD_SENSOR_CONTROLLER_COOLING  0x2
+/* enum: Phy 0 temperature: degC */
+#define          MC_CMD_SENSOR_PHY0_TEMP  0x3
+/* enum: Phy 0 cooling: bool */
+#define          MC_CMD_SENSOR_PHY0_COOLING  0x4
+/* enum: Phy 1 temperature: degC */
+#define          MC_CMD_SENSOR_PHY1_TEMP  0x5
+/* enum: Phy 1 cooling: bool */
+#define          MC_CMD_SENSOR_PHY1_COOLING  0x6
+/* enum: 1.0v power: mV */
+#define          MC_CMD_SENSOR_IN_1V0  0x7
+/* enum: 1.2v power: mV */
+#define          MC_CMD_SENSOR_IN_1V2  0x8
+/* enum: 1.8v power: mV */
+#define          MC_CMD_SENSOR_IN_1V8  0x9
+/* enum: 2.5v power: mV */
+#define          MC_CMD_SENSOR_IN_2V5  0xa
+/* enum: 3.3v power: mV */
+#define          MC_CMD_SENSOR_IN_3V3  0xb
+/* enum: 12v power: mV */
+#define          MC_CMD_SENSOR_IN_12V0  0xc
+/* enum: 1.2v analogue power: mV */
+#define          MC_CMD_SENSOR_IN_1V2A  0xd
+/* enum: reference voltage: mV */
+#define          MC_CMD_SENSOR_IN_VREF  0xe
+/* enum: AOE FPGA power: mV */
+#define          MC_CMD_SENSOR_OUT_VAOE  0xf
+/* enum: AOE FPGA temperature: degC */
+#define          MC_CMD_SENSOR_AOE_TEMP  0x10
+/* enum: AOE FPGA PSU temperature: degC */
+#define          MC_CMD_SENSOR_PSU_AOE_TEMP  0x11
+/* enum: AOE PSU temperature: degC */
+#define          MC_CMD_SENSOR_PSU_TEMP  0x12
+/* enum: Fan 0 speed: RPM */
+#define          MC_CMD_SENSOR_FAN_0  0x13
+/* enum: Fan 1 speed: RPM */
+#define          MC_CMD_SENSOR_FAN_1  0x14
+/* enum: Fan 2 speed: RPM */
+#define          MC_CMD_SENSOR_FAN_2  0x15
+/* enum: Fan 3 speed: RPM */
+#define          MC_CMD_SENSOR_FAN_3  0x16
+/* enum: Fan 4 speed: RPM */
+#define          MC_CMD_SENSOR_FAN_4  0x17
+/* enum: AOE FPGA input power: mV */
+#define          MC_CMD_SENSOR_IN_VAOE  0x18
+/* enum: AOE FPGA current: mA */
+#define          MC_CMD_SENSOR_OUT_IAOE  0x19
+/* enum: AOE FPGA input current: mA */
+#define          MC_CMD_SENSOR_IN_IAOE  0x1a
+/* enum: NIC power consumption: W */
+#define          MC_CMD_SENSOR_NIC_POWER  0x1b
+/* enum: 0.9v power voltage: mV */
+#define          MC_CMD_SENSOR_IN_0V9  0x1c
+/* enum: 0.9v power current: mA */
+#define          MC_CMD_SENSOR_IN_I0V9  0x1d
+/* enum: 1.2v power current: mA */
+#define          MC_CMD_SENSOR_IN_I1V2  0x1e
+/* enum: Not a sensor: reserved for the next page flag */
+#define          MC_CMD_SENSOR_PAGE0_NEXT  0x1f
+/* enum: 0.9v power voltage (at ADC): mV */
+#define          MC_CMD_SENSOR_IN_0V9_ADC  0x20
+/* enum: Controller temperature 2: degC */
+#define          MC_CMD_SENSOR_CONTROLLER_2_TEMP  0x21
+/* enum: Voltage regulator internal temperature: degC */
+#define          MC_CMD_SENSOR_VREG_INTERNAL_TEMP  0x22
+/* enum: 0.9V voltage regulator temperature: degC */
+#define          MC_CMD_SENSOR_VREG_0V9_TEMP  0x23
+/* enum: 1.2V voltage regulator temperature: degC */
+#define          MC_CMD_SENSOR_VREG_1V2_TEMP  0x24
+/* enum: controller internal temperature sensor voltage (internal ADC): mV */
+#define          MC_CMD_SENSOR_CONTROLLER_VPTAT  0x25
+/* enum: controller internal temperature (internal ADC): degC */
+#define          MC_CMD_SENSOR_CONTROLLER_INTERNAL_TEMP  0x26
+/* enum: controller internal temperature sensor voltage (external ADC): mV */
+#define          MC_CMD_SENSOR_CONTROLLER_VPTAT_EXTADC  0x27
+/* enum: controller internal temperature (external ADC): degC */
+#define          MC_CMD_SENSOR_CONTROLLER_INTERNAL_TEMP_EXTADC  0x28
+/* enum: ambient temperature: degC */
+#define          MC_CMD_SENSOR_AMBIENT_TEMP  0x29
+/* enum: air flow: bool */
+#define          MC_CMD_SENSOR_AIRFLOW  0x2a
+/* enum: voltage between VSS08D and VSS08D at CSR: mV */
+#define          MC_CMD_SENSOR_VDD08D_VSS08D_CSR  0x2b
+/* enum: voltage between VSS08D and VSS08D at CSR (external ADC): mV */
+#define          MC_CMD_SENSOR_VDD08D_VSS08D_CSR_EXTADC  0x2c
+/* MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF */
 #define       MC_CMD_SENSOR_ENTRY_OFST 4
 #define       MC_CMD_SENSOR_ENTRY_LEN 8
 #define       MC_CMD_SENSOR_ENTRY_LO_OFST 4
 #define       MC_CMD_SENSOR_ENTRY_MINNUM 1
 #define       MC_CMD_SENSOR_ENTRY_MAXNUM 31
 
+/* MC_CMD_SENSOR_INFO_EXT_OUT msgresponse */
+#define    MC_CMD_SENSOR_INFO_EXT_OUT_LENMIN 12
+#define    MC_CMD_SENSOR_INFO_EXT_OUT_LENMAX 252
+#define    MC_CMD_SENSOR_INFO_EXT_OUT_LEN(num) (4+8*(num))
+#define       MC_CMD_SENSOR_INFO_EXT_OUT_MASK_OFST 0
+/*            Enum values, see field(s): */
+/*               MC_CMD_SENSOR_INFO_OUT */
+#define        MC_CMD_SENSOR_INFO_EXT_OUT_NEXT_PAGE_LBN 31
+#define        MC_CMD_SENSOR_INFO_EXT_OUT_NEXT_PAGE_WIDTH 1
+/* MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF */
+/*            MC_CMD_SENSOR_ENTRY_OFST 4 */
+/*            MC_CMD_SENSOR_ENTRY_LEN 8 */
+/*            MC_CMD_SENSOR_ENTRY_LO_OFST 4 */
+/*            MC_CMD_SENSOR_ENTRY_HI_OFST 8 */
+/*            MC_CMD_SENSOR_ENTRY_MINNUM 1 */
+/*            MC_CMD_SENSOR_ENTRY_MAXNUM 31 */
+
 /* MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF structuredef */
 #define    MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_LEN 8
 #define       MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_OFST 0
 
 /***********************************/
 /* MC_CMD_READ_SENSORS
- * Returns the current reading from each sensor.
+ * Returns the current reading from each sensor. DMAs an array of sensor
+ * readings, in order of sensor type (but without gaps for unimplemented
+ * sensors), into host memory. Each array element is a
+ * MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF dword.
+ *
+ * If the request does not contain the LENGTH field then only sensors 0 to 30
+ * are reported, to avoid DMA buffer overflow in older host software. If the
+ * sensor reading require more space than the LENGTH allows, then return
+ * EINVAL.
+ *
+ * The MC will send a SENSOREVT event every time any sensor changes state. The
+ * driver is responsible for ensuring that it doesn't miss any events. The
+ * board will function normally if all sensors are in STATE_OK or
+ * STATE_WARNING. Otherwise the board should not be expected to function.
  */
 #define MC_CMD_READ_SENSORS 0x42
 
 /* MC_CMD_READ_SENSORS_IN msgrequest */
 #define    MC_CMD_READ_SENSORS_IN_LEN 8
+/* DMA address of host buffer for sensor readings (must be 4Kbyte aligned). */
 #define       MC_CMD_READ_SENSORS_IN_DMA_ADDR_OFST 0
 #define       MC_CMD_READ_SENSORS_IN_DMA_ADDR_LEN 8
 #define       MC_CMD_READ_SENSORS_IN_DMA_ADDR_LO_OFST 0
 #define       MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4
 
+/* MC_CMD_READ_SENSORS_EXT_IN msgrequest */
+#define    MC_CMD_READ_SENSORS_EXT_IN_LEN 12
+/* DMA address of host buffer for sensor readings */
+#define       MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_OFST 0
+#define       MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_LEN 8
+#define       MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_LO_OFST 0
+#define       MC_CMD_READ_SENSORS_EXT_IN_DMA_ADDR_HI_OFST 4
+/* Size in bytes of host buffer. */
+#define       MC_CMD_READ_SENSORS_EXT_IN_LENGTH_OFST 8
+
 /* MC_CMD_READ_SENSORS_OUT msgresponse */
 #define    MC_CMD_READ_SENSORS_OUT_LEN 0
 
+/* MC_CMD_READ_SENSORS_EXT_OUT msgresponse */
+#define    MC_CMD_READ_SENSORS_EXT_OUT_LEN 0
+
 /* MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF structuredef */
-#define    MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN 3
+#define    MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN 4
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_OFST 0
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_LEN 2
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_LBN 0
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_WIDTH 16
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_OFST 2
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_LEN 1
-#define          MC_CMD_SENSOR_STATE_OK  0x0 /* enum */
-#define          MC_CMD_SENSOR_STATE_WARNING  0x1 /* enum */
-#define          MC_CMD_SENSOR_STATE_FATAL  0x2 /* enum */
-#define          MC_CMD_SENSOR_STATE_BROKEN  0x3 /* enum */
+/* enum: Ok. */
+#define          MC_CMD_SENSOR_STATE_OK  0x0
+/* enum: Breached warning threshold. */
+#define          MC_CMD_SENSOR_STATE_WARNING  0x1
+/* enum: Breached fatal threshold. */
+#define          MC_CMD_SENSOR_STATE_FATAL  0x2
+/* enum: Fault with sensor. */
+#define          MC_CMD_SENSOR_STATE_BROKEN  0x3
+/* enum: Sensor is working but does not currently have a reading. */
+#define          MC_CMD_SENSOR_STATE_NO_READING  0x4
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_LBN 16
 #define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_WIDTH 8
+#define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_TYPE_OFST 3
+#define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_TYPE_LEN 1
+/*            Enum values, see field(s): */
+/*               MC_CMD_SENSOR_INFO/MC_CMD_SENSOR_INFO_OUT/MASK */
+#define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_TYPE_LBN 24
+#define       MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_TYPE_WIDTH 8
 
 
 /***********************************/
 /* MC_CMD_GET_PHY_STATE
- * Report current state of PHY.
+ * Report current state of PHY. A 'zombie' PHY is a PHY that has failed to boot
+ * (e.g. due to missing or corrupted firmware). Locks required: None. Return
+ * code: 0
  */
 #define MC_CMD_GET_PHY_STATE 0x43
 
 /* MC_CMD_GET_PHY_STATE_OUT msgresponse */
 #define    MC_CMD_GET_PHY_STATE_OUT_LEN 4
 #define       MC_CMD_GET_PHY_STATE_OUT_STATE_OFST 0
-#define          MC_CMD_PHY_STATE_OK 0x1 /* enum */
-#define          MC_CMD_PHY_STATE_ZOMBIE 0x2 /* enum */
+/* enum: Ok. */
+#define          MC_CMD_PHY_STATE_OK 0x1
+/* enum: Faulty. */
+#define          MC_CMD_PHY_STATE_ZOMBIE 0x2
 
 
 /***********************************/
 /* MC_CMD_SETUP_8021QBB
- * 802.1Qbb control.
+ * 802.1Qbb control. 8 Tx queues that map to priorities 0 - 7. Use all 1s to
+ * disable 802.Qbb for a given priority.
  */
 #define MC_CMD_SETUP_8021QBB 0x44
 
 
 /***********************************/
 /* MC_CMD_WOL_FILTER_GET
- * Retrieve ID of any WoL filters.
+ * Retrieve ID of any WoL filters. Locks required: None. Returns: 0, ENOSYS
  */
 #define MC_CMD_WOL_FILTER_GET 0x45
 
 
 /***********************************/
 /* MC_CMD_ADD_LIGHTSOUT_OFFLOAD
- * Add a protocol offload to NIC for lights-out state.
+ * Add a protocol offload to NIC for lights-out state. Locks required: None.
+ * Returns: 0, ENOSYS
  */
 #define MC_CMD_ADD_LIGHTSOUT_OFFLOAD 0x46
 
 
 /***********************************/
 /* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD
- * Remove a protocol offload from NIC for lights-out state.
+ * Remove a protocol offload from NIC for lights-out state. Locks required:
+ * None. Returns: 0, ENOSYS
  */
 #define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD 0x47
 
 
 /***********************************/
 /* MC_CMD_MAC_RESET_RESTORE
- * Restore MAC after block reset.
+ * Restore MAC after block reset. Locks required: None. Returns: 0.
  */
 #define MC_CMD_MAC_RESET_RESTORE 0x48
 
 
 /***********************************/
 /* MC_CMD_TESTASSERT
+ * Deliberately trigger an assert-detonation in the firmware for testing
+ * purposes (i.e. to allow tests that the driver copes gracefully). Locks
+ * required: None Returns: 0
  */
 #define MC_CMD_TESTASSERT 0x49
 
 
 /***********************************/
 /* MC_CMD_WORKAROUND
- * Enable/Disable a given workaround.
+ * Enable/Disable a given workaround. The mcfw will return EINVAL if it doesn't
+ * understand the given workaround number - which should not be treated as a
+ * hard error by client code. This op does not imply any semantics about each
+ * workaround, that's between the driver and the mcfw on a per-workaround
+ * basis. Locks required: None. Returns: 0, EINVAL .
  */
 #define MC_CMD_WORKAROUND 0x4a
 
 /* MC_CMD_WORKAROUND_IN msgrequest */
 #define    MC_CMD_WORKAROUND_IN_LEN 8
 #define       MC_CMD_WORKAROUND_IN_TYPE_OFST 0
-#define          MC_CMD_WORKAROUND_BUG17230 0x1 /* enum */
+/* enum: Bug 17230 work around. */
+#define          MC_CMD_WORKAROUND_BUG17230 0x1
+/* enum: Bug 35388 work around (unsafe EVQ writes). */
+#define          MC_CMD_WORKAROUND_BUG35388 0x2
+/* enum: Bug35017 workaround (A64 tables must be identity map) */
+#define          MC_CMD_WORKAROUND_BUG35017 0x3
 #define       MC_CMD_WORKAROUND_IN_ENABLED_OFST 4
 
 /* MC_CMD_WORKAROUND_OUT msgresponse */
 
 /***********************************/
 /* MC_CMD_GET_PHY_MEDIA_INFO
- * Read media-specific data from PHY.
+ * Read media-specific data from PHY (e.g. SFP/SFP+ module ID information for
+ * SFP+ PHYs). The 'media type' can be found via GET_PHY_CFG
+ * (GET_PHY_CFG_OUT_MEDIA_TYPE); the valid 'page number' input values, and the
+ * output data, are interpreted on a per-type basis. For SFP+: PAGE=0 or 1
+ * returns a 128-byte block read from module I2C address 0xA0 offset 0 or 0x80.
+ * Anything else: currently undefined. Locks required: None. Return code: 0.
  */
 #define MC_CMD_GET_PHY_MEDIA_INFO 0x4b
 
 #define    MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMIN 5
 #define    MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX 252
 #define    MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(num) (4+1*(num))
+/* in bytes */
 #define       MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0
 #define       MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4
 #define       MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_LEN 1
 
 /***********************************/
 /* MC_CMD_NVRAM_TEST
- * Test a particular NVRAM partition.
+ * Test a particular NVRAM partition for valid contents (where "valid" depends
+ * on the type of partition).
  */
 #define MC_CMD_NVRAM_TEST 0x4c
 
 /* MC_CMD_NVRAM_TEST_OUT msgresponse */
 #define    MC_CMD_NVRAM_TEST_OUT_LEN 4
 #define       MC_CMD_NVRAM_TEST_OUT_RESULT_OFST 0
-#define          MC_CMD_NVRAM_TEST_PASS 0x0 /* enum */
-#define          MC_CMD_NVRAM_TEST_FAIL 0x1 /* enum */
-#define          MC_CMD_NVRAM_TEST_NOTSUPP 0x2 /* enum */
+/* enum: Passed. */
+#define          MC_CMD_NVRAM_TEST_PASS 0x0
+/* enum: Failed. */
+#define          MC_CMD_NVRAM_TEST_FAIL 0x1
+/* enum: Not supported. */
+#define          MC_CMD_NVRAM_TEST_NOTSUPP 0x2
 
 
 /***********************************/
 /* MC_CMD_MRSFP_TWEAK
- * Read status and/or set parameters for the 'mrsfp' driver.
+ * Read status and/or set parameters for the 'mrsfp' driver in mr_rusty builds.
+ * I2C I/O expander bits are always read; if equaliser parameters are supplied,
+ * they are configured first. Locks required: None. Return code: 0, EINVAL.
  */
 #define MC_CMD_MRSFP_TWEAK 0x4d
 
 /* MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG msgrequest */
 #define    MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_LEN 16
+/* 0-6 low->high de-emph. */
 #define       MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_TXEQ_LEVEL_OFST 0
+/* 0-8 low->high ref.V */
 #define       MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_TXEQ_DT_CFG_OFST 4
+/* 0-8 0-8 low->high boost */
 #define       MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_RXEQ_BOOST_OFST 8
+/* 0-8 low->high ref.V */
 #define       MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_RXEQ_DT_CFG_OFST 12
 
 /* MC_CMD_MRSFP_TWEAK_IN_READ_ONLY msgrequest */
 
 /* MC_CMD_MRSFP_TWEAK_OUT msgresponse */
 #define    MC_CMD_MRSFP_TWEAK_OUT_LEN 12
+/* input bits */
 #define       MC_CMD_MRSFP_TWEAK_OUT_IOEXP_INPUTS_OFST 0
+/* output bits */
 #define       MC_CMD_MRSFP_TWEAK_OUT_IOEXP_OUTPUTS_OFST 4
+/* direction */
 #define       MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OFST 8
-#define          MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OUT 0x0 /* enum */
-#define          MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_IN 0x1 /* enum */
+/* enum: Out. */
+#define          MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OUT 0x0
+/* enum: In. */
+#define          MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_IN 0x1
 
 
 /***********************************/
 /* MC_CMD_SENSOR_SET_LIMS
- * Adjusts the sensor limits.
+ * Adjusts the sensor limits. This is a warranty-voiding operation. Returns:
+ * ENOENT if the sensor specified does not exist, EINVAL if the limits are out
+ * of range.
  */
 #define MC_CMD_SENSOR_SET_LIMS 0x4e
 
 #define       MC_CMD_SENSOR_SET_LIMS_IN_SENSOR_OFST 0
 /*            Enum values, see field(s): */
 /*               MC_CMD_SENSOR_INFO/MC_CMD_SENSOR_INFO_OUT/MASK */
+/* interpretation is is sensor-specific. */
 #define       MC_CMD_SENSOR_SET_LIMS_IN_LOW0_OFST 4
+/* interpretation is is sensor-specific. */
 #define       MC_CMD_SENSOR_SET_LIMS_IN_HI0_OFST 8
+/* interpretation is is sensor-specific. */
 #define       MC_CMD_SENSOR_SET_LIMS_IN_LOW1_OFST 12
+/* interpretation is is sensor-specific. */
 #define       MC_CMD_SENSOR_SET_LIMS_IN_HI1_OFST 16
 
 /* MC_CMD_SENSOR_SET_LIMS_OUT msgresponse */
 #define       MC_CMD_GET_RESOURCE_LIMITS_OUT_RXQ_OFST 8
 #define       MC_CMD_GET_RESOURCE_LIMITS_OUT_TXQ_OFST 12
 
+
+/***********************************/
+/* MC_CMD_NVRAM_PARTITIONS
+ * Reads the list of available virtual NVRAM partition types. Locks required:
+ * none. Returns: 0, EINVAL (bad type).
+ */
+#define MC_CMD_NVRAM_PARTITIONS 0x51
+
+/* MC_CMD_NVRAM_PARTITIONS_IN msgrequest */
+#define    MC_CMD_NVRAM_PARTITIONS_IN_LEN 0
+
+/* MC_CMD_NVRAM_PARTITIONS_OUT msgresponse */
+#define    MC_CMD_NVRAM_PARTITIONS_OUT_LENMIN 4
+#define    MC_CMD_NVRAM_PARTITIONS_OUT_LENMAX 252
+#define    MC_CMD_NVRAM_PARTITIONS_OUT_LEN(num) (4+4*(num))
+/* total number of partitions */
+#define       MC_CMD_NVRAM_PARTITIONS_OUT_NUM_PARTITIONS_OFST 0
+/* type ID code for each of NUM_PARTITIONS partitions */
+#define       MC_CMD_NVRAM_PARTITIONS_OUT_TYPE_ID_OFST 4
+#define       MC_CMD_NVRAM_PARTITIONS_OUT_TYPE_ID_LEN 4
+#define       MC_CMD_NVRAM_PARTITIONS_OUT_TYPE_ID_MINNUM 0
+#define       MC_CMD_NVRAM_PARTITIONS_OUT_TYPE_ID_MAXNUM 62
+
+
+/***********************************/
+/* MC_CMD_NVRAM_METADATA
+ * Reads soft metadata for a virtual NVRAM partition type. Locks required:
+ * none. Returns: 0, EINVAL (bad type).
+ */
+#define MC_CMD_NVRAM_METADATA 0x52
+
+/* MC_CMD_NVRAM_METADATA_IN msgrequest */
+#define    MC_CMD_NVRAM_METADATA_IN_LEN 4
+/* Partition type ID code */
+#define       MC_CMD_NVRAM_METADATA_IN_TYPE_OFST 0
+
+/* MC_CMD_NVRAM_METADATA_OUT msgresponse */
+#define    MC_CMD_NVRAM_METADATA_OUT_LENMIN 20
+#define    MC_CMD_NVRAM_METADATA_OUT_LENMAX 252
+#define    MC_CMD_NVRAM_METADATA_OUT_LEN(num) (20+1*(num))
+/* Partition type ID code */
+#define       MC_CMD_NVRAM_METADATA_OUT_TYPE_OFST 0
+#define       MC_CMD_NVRAM_METADATA_OUT_FLAGS_OFST 4
+#define        MC_CMD_NVRAM_METADATA_OUT_SUBTYPE_VALID_LBN 0
+#define        MC_CMD_NVRAM_METADATA_OUT_SUBTYPE_VALID_WIDTH 1
+#define        MC_CMD_NVRAM_METADATA_OUT_VERSION_VALID_LBN 1
+#define        MC_CMD_NVRAM_METADATA_OUT_VERSION_VALID_WIDTH 1
+#define        MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_VALID_LBN 2
+#define        MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_VALID_WIDTH 1
+/* Subtype ID code for content of this partition */
+#define       MC_CMD_NVRAM_METADATA_OUT_SUBTYPE_OFST 8
+/* 1st component of W.X.Y.Z version number for content of this partition */
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_W_OFST 12
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_W_LEN 2
+/* 2nd component of W.X.Y.Z version number for content of this partition */
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_X_OFST 14
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_X_LEN 2
+/* 3rd component of W.X.Y.Z version number for content of this partition */
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_Y_OFST 16
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_Y_LEN 2
+/* 4th component of W.X.Y.Z version number for content of this partition */
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_Z_OFST 18
+#define       MC_CMD_NVRAM_METADATA_OUT_VERSION_Z_LEN 2
+/* Zero-terminated string describing the content of this partition */
+#define       MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_OFST 20
+#define       MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_LEN 1
+#define       MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MINNUM 0
+#define       MC_CMD_NVRAM_METADATA_OUT_DESCRIPTION_MAXNUM 232
+
+
+/***********************************/
+/* MC_CMD_GET_MAC_ADDRESSES
+ * Returns the base MAC, count and stride for the requestiong function
+ */
+#define MC_CMD_GET_MAC_ADDRESSES 0x55
+
+/* MC_CMD_GET_MAC_ADDRESSES_IN msgrequest */
+#define    MC_CMD_GET_MAC_ADDRESSES_IN_LEN 0
+
+/* MC_CMD_GET_MAC_ADDRESSES_OUT msgresponse */
+#define    MC_CMD_GET_MAC_ADDRESSES_OUT_LEN 16
+/* Base MAC address */
+#define       MC_CMD_GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE_OFST 0
+#define       MC_CMD_GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE_LEN 6
+/* Padding */
+#define       MC_CMD_GET_MAC_ADDRESSES_OUT_RESERVED_OFST 6
+#define       MC_CMD_GET_MAC_ADDRESSES_OUT_RESERVED_LEN 2
+/* Number of allocated MAC addresses */
+#define       MC_CMD_GET_MAC_ADDRESSES_OUT_MAC_COUNT_OFST 8
+/* Spacing of allocated MAC addresses */
+#define       MC_CMD_GET_MAC_ADDRESSES_OUT_MAC_STRIDE_OFST 12
+
 /* MC_CMD_RESOURCE_SPECIFIER enum */
-#define          MC_CMD_RESOURCE_INSTANCE_ANY 0xffffffff /* enum */
-#define          MC_CMD_RESOURCE_INSTANCE_NONE 0xfffffffe /* enum */
+/* enum: Any */
+#define          MC_CMD_RESOURCE_INSTANCE_ANY 0xffffffff
+/* enum: None */
+#define          MC_CMD_RESOURCE_INSTANCE_NONE 0xfffffffe
+
+/* EVB_PORT_ID structuredef */
+#define    EVB_PORT_ID_LEN 4
+#define       EVB_PORT_ID_PORT_ID_OFST 0
+/* enum: An invalid port handle. */
+#define          EVB_PORT_ID_NULL  0x0
+/* enum: The port assigned to this function.. */
+#define          EVB_PORT_ID_ASSIGNED  0x1000000
+/* enum: External network port 0 */
+#define          EVB_PORT_ID_MAC0  0x2000000
+/* enum: External network port 1 */
+#define          EVB_PORT_ID_MAC1  0x2000001
+/* enum: External network port 2 */
+#define          EVB_PORT_ID_MAC2  0x2000002
+/* enum: External network port 3 */
+#define          EVB_PORT_ID_MAC3  0x2000003
+#define       EVB_PORT_ID_PORT_ID_LBN 0
+#define       EVB_PORT_ID_PORT_ID_WIDTH 32
+
+/* EVB_VLAN_TAG structuredef */
+#define    EVB_VLAN_TAG_LEN 2
+/* The VLAN tag value */
+#define       EVB_VLAN_TAG_VLAN_ID_LBN 0
+#define       EVB_VLAN_TAG_VLAN_ID_WIDTH 12
+#define       EVB_VLAN_TAG_MODE_LBN 12
+#define       EVB_VLAN_TAG_MODE_WIDTH 4
+/* enum: Insert the VLAN. */
+#define          EVB_VLAN_TAG_INSERT  0x0
+/* enum: Replace the VLAN if already present. */
+#define          EVB_VLAN_TAG_REPLACE 0x1
+
+/* BUFTBL_ENTRY structuredef */
+#define    BUFTBL_ENTRY_LEN 12
+/* the owner ID */
+#define       BUFTBL_ENTRY_OID_OFST 0
+#define       BUFTBL_ENTRY_OID_LEN 2
+#define       BUFTBL_ENTRY_OID_LBN 0
+#define       BUFTBL_ENTRY_OID_WIDTH 16
+/* the page parameter as one of ESE_DZ_SMC_PAGE_SIZE_ */
+#define       BUFTBL_ENTRY_PGSZ_OFST 2
+#define       BUFTBL_ENTRY_PGSZ_LEN 2
+#define       BUFTBL_ENTRY_PGSZ_LBN 16
+#define       BUFTBL_ENTRY_PGSZ_WIDTH 16
+/* the raw 64-bit address field from the SMC, not adjusted for page size */
+#define       BUFTBL_ENTRY_RAWADDR_OFST 4
+#define       BUFTBL_ENTRY_RAWADDR_LEN 8
+#define       BUFTBL_ENTRY_RAWADDR_LO_OFST 4
+#define       BUFTBL_ENTRY_RAWADDR_HI_OFST 8
+#define       BUFTBL_ENTRY_RAWADDR_LBN 32
+#define       BUFTBL_ENTRY_RAWADDR_WIDTH 64
+
+/* NVRAM_PARTITION_TYPE structuredef */
+#define    NVRAM_PARTITION_TYPE_LEN 2
+#define       NVRAM_PARTITION_TYPE_ID_OFST 0
+#define       NVRAM_PARTITION_TYPE_ID_LEN 2
+/* enum: Primary MC firmware partition */
+#define          NVRAM_PARTITION_TYPE_MC_FIRMWARE          0x100
+/* enum: Secondary MC firmware partition */
+#define          NVRAM_PARTITION_TYPE_MC_FIRMWARE_BACKUP   0x200
+/* enum: Expansion ROM partition */
+#define          NVRAM_PARTITION_TYPE_EXPANSION_ROM        0x300
+/* enum: Static configuration TLV partition */
+#define          NVRAM_PARTITION_TYPE_STATIC_CONFIG        0x400
+/* enum: Dynamic configuration TLV partition */
+#define          NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG       0x500
+/* enum: Expansion ROM configuration data for port 0 */
+#define          NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT0  0x600
+/* enum: Expansion ROM configuration data for port 1 */
+#define          NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT1  0x601
+/* enum: Expansion ROM configuration data for port 2 */
+#define          NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT2  0x602
+/* enum: Expansion ROM configuration data for port 3 */
+#define          NVRAM_PARTITION_TYPE_EXPROM_CONFIG_PORT3  0x603
+/* enum: Non-volatile log output partition */
+#define          NVRAM_PARTITION_TYPE_LOG                  0x700
+/* enum: Device state dump output partition */
+#define          NVRAM_PARTITION_TYPE_DUMP                 0x800
+/* enum: Application license key storage partition */
+#define          NVRAM_PARTITION_TYPE_LICENSE              0x900
+/* enum: Start of reserved value range (firmware may use for any purpose) */
+#define          NVRAM_PARTITION_TYPE_RESERVED_VALUES_MIN  0xff00
+/* enum: End of reserved value range (firmware may use for any purpose) */
+#define          NVRAM_PARTITION_TYPE_RESERVED_VALUES_MAX  0xfffd
+/* enum: Recovery partition map (provided if real map is missing or corrupt) */
+#define          NVRAM_PARTITION_TYPE_RECOVERY_MAP         0xfffe
+/* enum: Partition map (real map as stored in flash) */
+#define          NVRAM_PARTITION_TYPE_PARTITION_MAP        0xffff
+#define       NVRAM_PARTITION_TYPE_ID_LBN 0
+#define       NVRAM_PARTITION_TYPE_ID_WIDTH 16
+
+
+/***********************************/
+/* MC_CMD_READ_REGS
+ * Get a dump of the MCPU registers
+ */
+#define MC_CMD_READ_REGS 0x50
+
+/* MC_CMD_READ_REGS_IN msgrequest */
+#define    MC_CMD_READ_REGS_IN_LEN 0
+
+/* MC_CMD_READ_REGS_OUT msgresponse */
+#define    MC_CMD_READ_REGS_OUT_LEN 308
+/* Whether the corresponding register entry contains a valid value */
+#define       MC_CMD_READ_REGS_OUT_MASK_OFST 0
+#define       MC_CMD_READ_REGS_OUT_MASK_LEN 16
+/* Same order as MIPS GDB (r0-r31, sr, lo, hi, bad, cause, 32 x float, fsr,
+ * fir, fp)
+ */
+#define       MC_CMD_READ_REGS_OUT_REGS_OFST 16
+#define       MC_CMD_READ_REGS_OUT_REGS_LEN 4
+#define       MC_CMD_READ_REGS_OUT_REGS_NUM 73
+
+
+/***********************************/
+/* MC_CMD_INIT_EVQ
+ * Set up an event queue according to the supplied parameters. The IN arguments
+ * end with an address for each 4k of host memory required to back the EVQ.
+ */
+#define MC_CMD_INIT_EVQ 0x80
+
+/* MC_CMD_INIT_EVQ_IN msgrequest */
+#define    MC_CMD_INIT_EVQ_IN_LENMIN 44
+#define    MC_CMD_INIT_EVQ_IN_LENMAX 548
+#define    MC_CMD_INIT_EVQ_IN_LEN(num) (36+8*(num))
+/* Size, in entries */
+#define       MC_CMD_INIT_EVQ_IN_SIZE_OFST 0
+/* Desired instance. Must be set to a specific instance, which is a function
+ * local queue index.
+ */
+#define       MC_CMD_INIT_EVQ_IN_INSTANCE_OFST 4
+/* The initial timer value. The load value is ignored if the timer mode is DIS.
+ */
+#define       MC_CMD_INIT_EVQ_IN_TMR_LOAD_OFST 8
+/* The reload value is ignored in one-shot modes */
+#define       MC_CMD_INIT_EVQ_IN_TMR_RELOAD_OFST 12
+/* tbd */
+#define       MC_CMD_INIT_EVQ_IN_FLAGS_OFST 16
+#define        MC_CMD_INIT_EVQ_IN_FLAG_INTERRUPTING_LBN 0
+#define        MC_CMD_INIT_EVQ_IN_FLAG_INTERRUPTING_WIDTH 1
+#define        MC_CMD_INIT_EVQ_IN_FLAG_RPTR_DOS_LBN 1
+#define        MC_CMD_INIT_EVQ_IN_FLAG_RPTR_DOS_WIDTH 1
+#define        MC_CMD_INIT_EVQ_IN_FLAG_INT_ARMD_LBN 2
+#define        MC_CMD_INIT_EVQ_IN_FLAG_INT_ARMD_WIDTH 1
+#define        MC_CMD_INIT_EVQ_IN_FLAG_CUT_THRU_LBN 3
+#define        MC_CMD_INIT_EVQ_IN_FLAG_CUT_THRU_WIDTH 1
+#define        MC_CMD_INIT_EVQ_IN_FLAG_RX_MERGE_LBN 4
+#define        MC_CMD_INIT_EVQ_IN_FLAG_RX_MERGE_WIDTH 1
+#define        MC_CMD_INIT_EVQ_IN_FLAG_TX_MERGE_LBN 5
+#define        MC_CMD_INIT_EVQ_IN_FLAG_TX_MERGE_WIDTH 1
+#define       MC_CMD_INIT_EVQ_IN_TMR_MODE_OFST 20
+/* enum: Disabled */
+#define          MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS 0x0
+/* enum: Immediate */
+#define          MC_CMD_INIT_EVQ_IN_TMR_IMMED_START 0x1
+/* enum: Triggered */
+#define          MC_CMD_INIT_EVQ_IN_TMR_TRIG_START 0x2
+/* enum: Hold-off */
+#define          MC_CMD_INIT_EVQ_IN_TMR_INT_HLDOFF 0x3
+/* Target EVQ for wakeups if in wakeup mode. */
+#define       MC_CMD_INIT_EVQ_IN_TARGET_EVQ_OFST 24
+/* Target interrupt if in interrupting mode (note union with target EVQ). Use
+ * MC_CMD_RESOURCE_INSTANCE_ANY unless a specific one required for test
+ * purposes.
+ */
+#define       MC_CMD_INIT_EVQ_IN_IRQ_NUM_OFST 24
+/* Event Counter Mode. */
+#define       MC_CMD_INIT_EVQ_IN_COUNT_MODE_OFST 28
+/* enum: Disabled */
+#define          MC_CMD_INIT_EVQ_IN_COUNT_MODE_DIS 0x0
+/* enum: Disabled */
+#define          MC_CMD_INIT_EVQ_IN_COUNT_MODE_RX 0x1
+/* enum: Disabled */
+#define          MC_CMD_INIT_EVQ_IN_COUNT_MODE_TX 0x2
+/* enum: Disabled */
+#define          MC_CMD_INIT_EVQ_IN_COUNT_MODE_RXTX 0x3
+/* Event queue packet count threshold. */
+#define       MC_CMD_INIT_EVQ_IN_COUNT_THRSHLD_OFST 32
+/* 64-bit address of 4k of 4k-aligned host memory buffer */
+#define       MC_CMD_INIT_EVQ_IN_DMA_ADDR_OFST 36
+#define       MC_CMD_INIT_EVQ_IN_DMA_ADDR_LEN 8
+#define       MC_CMD_INIT_EVQ_IN_DMA_ADDR_LO_OFST 36
+#define       MC_CMD_INIT_EVQ_IN_DMA_ADDR_HI_OFST 40
+#define       MC_CMD_INIT_EVQ_IN_DMA_ADDR_MINNUM 1
+#define       MC_CMD_INIT_EVQ_IN_DMA_ADDR_MAXNUM 64
+
+/* MC_CMD_INIT_EVQ_OUT msgresponse */
+#define    MC_CMD_INIT_EVQ_OUT_LEN 4
+/* Only valid if INTRFLAG was true */
+#define       MC_CMD_INIT_EVQ_OUT_IRQ_OFST 0
+
+/* QUEUE_CRC_MODE structuredef */
+#define    QUEUE_CRC_MODE_LEN 1
+#define       QUEUE_CRC_MODE_MODE_LBN 0
+#define       QUEUE_CRC_MODE_MODE_WIDTH 4
+/* enum: No CRC. */
+#define          QUEUE_CRC_MODE_NONE  0x0
+/* enum: CRC Fiber channel over ethernet. */
+#define          QUEUE_CRC_MODE_FCOE  0x1
+/* enum: CRC (digest) iSCSI header only. */
+#define          QUEUE_CRC_MODE_ISCSI_HDR  0x2
+/* enum: CRC (digest) iSCSI header and payload. */
+#define          QUEUE_CRC_MODE_ISCSI  0x3
+/* enum: CRC Fiber channel over IP over ethernet. */
+#define          QUEUE_CRC_MODE_FCOIPOE  0x4
+/* enum: CRC MPA. */
+#define          QUEUE_CRC_MODE_MPA  0x5
+#define       QUEUE_CRC_MODE_SPARE_LBN 4
+#define       QUEUE_CRC_MODE_SPARE_WIDTH 4
+
+
+/***********************************/
+/* MC_CMD_INIT_RXQ
+ * set up a receive queue according to the supplied parameters. The IN
+ * arguments end with an address for each 4k of host memory required to back
+ * the RXQ.
+ */
+#define MC_CMD_INIT_RXQ 0x81
+
+/* MC_CMD_INIT_RXQ_IN msgrequest */
+#define    MC_CMD_INIT_RXQ_IN_LENMIN 36
+#define    MC_CMD_INIT_RXQ_IN_LENMAX 252
+#define    MC_CMD_INIT_RXQ_IN_LEN(num) (28+8*(num))
+/* Size, in entries */
+#define       MC_CMD_INIT_RXQ_IN_SIZE_OFST 0
+/* The EVQ to send events to. This is an index originally specified to INIT_EVQ
+ */
+#define       MC_CMD_INIT_RXQ_IN_TARGET_EVQ_OFST 4
+/* The value to put in the event data. Check hardware spec. for valid range. */
+#define       MC_CMD_INIT_RXQ_IN_LABEL_OFST 8
+/* Desired instance. Must be set to a specific instance, which is a function
+ * local queue index.
+ */
+#define       MC_CMD_INIT_RXQ_IN_INSTANCE_OFST 12
+/* There will be more flags here. */
+#define       MC_CMD_INIT_RXQ_IN_FLAGS_OFST 16
+#define        MC_CMD_INIT_RXQ_IN_FLAG_BUFF_MODE_LBN 0
+#define        MC_CMD_INIT_RXQ_IN_FLAG_BUFF_MODE_WIDTH 1
+#define        MC_CMD_INIT_RXQ_IN_FLAG_HDR_SPLIT_LBN 1
+#define        MC_CMD_INIT_RXQ_IN_FLAG_HDR_SPLIT_WIDTH 1
+#define        MC_CMD_INIT_RXQ_IN_FLAG_TIMESTAMP_LBN 2
+#define        MC_CMD_INIT_RXQ_IN_FLAG_TIMESTAMP_WIDTH 1
+#define        MC_CMD_INIT_RXQ_IN_CRC_MODE_LBN 3
+#define        MC_CMD_INIT_RXQ_IN_CRC_MODE_WIDTH 4
+#define        MC_CMD_INIT_RXQ_IN_FLAG_CHAIN_LBN 7
+#define        MC_CMD_INIT_RXQ_IN_FLAG_CHAIN_WIDTH 1
+#define        MC_CMD_INIT_RXQ_IN_FLAG_PREFIX_LBN 8
+#define        MC_CMD_INIT_RXQ_IN_FLAG_PREFIX_WIDTH 1
+/* Owner ID to use if in buffer mode (zero if physical) */
+#define       MC_CMD_INIT_RXQ_IN_OWNER_ID_OFST 20
+/* The port ID associated with the v-adaptor which should contain this DMAQ. */
+#define       MC_CMD_INIT_RXQ_IN_PORT_ID_OFST 24
+/* 64-bit address of 4k of 4k-aligned host memory buffer */
+#define       MC_CMD_INIT_RXQ_IN_DMA_ADDR_OFST 28
+#define       MC_CMD_INIT_RXQ_IN_DMA_ADDR_LEN 8
+#define       MC_CMD_INIT_RXQ_IN_DMA_ADDR_LO_OFST 28
+#define       MC_CMD_INIT_RXQ_IN_DMA_ADDR_HI_OFST 32
+#define       MC_CMD_INIT_RXQ_IN_DMA_ADDR_MINNUM 1
+#define       MC_CMD_INIT_RXQ_IN_DMA_ADDR_MAXNUM 28
+
+/* MC_CMD_INIT_RXQ_OUT msgresponse */
+#define    MC_CMD_INIT_RXQ_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_INIT_TXQ
+ */
+#define MC_CMD_INIT_TXQ 0x82
+
+/* MC_CMD_INIT_TXQ_IN msgrequest */
+#define    MC_CMD_INIT_TXQ_IN_LENMIN 36
+#define    MC_CMD_INIT_TXQ_IN_LENMAX 252
+#define    MC_CMD_INIT_TXQ_IN_LEN(num) (28+8*(num))
+/* Size, in entries */
+#define       MC_CMD_INIT_TXQ_IN_SIZE_OFST 0
+/* The EVQ to send events to. This is an index originally specified to
+ * INIT_EVQ.
+ */
+#define       MC_CMD_INIT_TXQ_IN_TARGET_EVQ_OFST 4
+/* The value to put in the event data. Check hardware spec. for valid range. */
+#define       MC_CMD_INIT_TXQ_IN_LABEL_OFST 8
+/* Desired instance. Must be set to a specific instance, which is a function
+ * local queue index.
+ */
+#define       MC_CMD_INIT_TXQ_IN_INSTANCE_OFST 12
+/* There will be more flags here. */
+#define       MC_CMD_INIT_TXQ_IN_FLAGS_OFST 16
+#define        MC_CMD_INIT_TXQ_IN_FLAG_BUFF_MODE_LBN 0
+#define        MC_CMD_INIT_TXQ_IN_FLAG_BUFF_MODE_WIDTH 1
+#define        MC_CMD_INIT_TXQ_IN_FLAG_IP_CSUM_DIS_LBN 1
+#define        MC_CMD_INIT_TXQ_IN_FLAG_IP_CSUM_DIS_WIDTH 1
+#define        MC_CMD_INIT_TXQ_IN_FLAG_TCP_CSUM_DIS_LBN 2
+#define        MC_CMD_INIT_TXQ_IN_FLAG_TCP_CSUM_DIS_WIDTH 1
+#define        MC_CMD_INIT_TXQ_IN_FLAG_TCP_UDP_ONLY_LBN 3
+#define        MC_CMD_INIT_TXQ_IN_FLAG_TCP_UDP_ONLY_WIDTH 1
+#define        MC_CMD_INIT_TXQ_IN_CRC_MODE_LBN 4
+#define        MC_CMD_INIT_TXQ_IN_CRC_MODE_WIDTH 4
+#define        MC_CMD_INIT_TXQ_IN_FLAG_TIMESTAMP_LBN 8
+#define        MC_CMD_INIT_TXQ_IN_FLAG_TIMESTAMP_WIDTH 1
+#define        MC_CMD_INIT_TXQ_IN_FLAG_PACER_BYPASS_LBN 9
+#define        MC_CMD_INIT_TXQ_IN_FLAG_PACER_BYPASS_WIDTH 1
+/* Owner ID to use if in buffer mode (zero if physical) */
+#define       MC_CMD_INIT_TXQ_IN_OWNER_ID_OFST 20
+/* The port ID associated with the v-adaptor which should contain this DMAQ. */
+#define       MC_CMD_INIT_TXQ_IN_PORT_ID_OFST 24
+/* 64-bit address of 4k of 4k-aligned host memory buffer */
+#define       MC_CMD_INIT_TXQ_IN_DMA_ADDR_OFST 28
+#define       MC_CMD_INIT_TXQ_IN_DMA_ADDR_LEN 8
+#define       MC_CMD_INIT_TXQ_IN_DMA_ADDR_LO_OFST 28
+#define       MC_CMD_INIT_TXQ_IN_DMA_ADDR_HI_OFST 32
+#define       MC_CMD_INIT_TXQ_IN_DMA_ADDR_MINNUM 1
+#define       MC_CMD_INIT_TXQ_IN_DMA_ADDR_MAXNUM 28
+
+/* MC_CMD_INIT_TXQ_OUT msgresponse */
+#define    MC_CMD_INIT_TXQ_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_FINI_EVQ
+ * Teardown an EVQ.
+ *
+ * All DMAQs or EVQs that point to the EVQ to tear down must be torn down first
+ * or the operation will fail with EBUSY
+ */
+#define MC_CMD_FINI_EVQ 0x83
+
+/* MC_CMD_FINI_EVQ_IN msgrequest */
+#define    MC_CMD_FINI_EVQ_IN_LEN 4
+/* Instance of EVQ to destroy. Should be the same instance as that previously
+ * passed to INIT_EVQ
+ */
+#define       MC_CMD_FINI_EVQ_IN_INSTANCE_OFST 0
+
+/* MC_CMD_FINI_EVQ_OUT msgresponse */
+#define    MC_CMD_FINI_EVQ_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_FINI_RXQ
+ * Teardown a RXQ.
+ */
+#define MC_CMD_FINI_RXQ 0x84
+
+/* MC_CMD_FINI_RXQ_IN msgrequest */
+#define    MC_CMD_FINI_RXQ_IN_LEN 4
+/* Instance of RXQ to destroy */
+#define       MC_CMD_FINI_RXQ_IN_INSTANCE_OFST 0
+
+/* MC_CMD_FINI_RXQ_OUT msgresponse */
+#define    MC_CMD_FINI_RXQ_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_FINI_TXQ
+ * Teardown a TXQ.
+ */
+#define MC_CMD_FINI_TXQ 0x85
+
+/* MC_CMD_FINI_TXQ_IN msgrequest */
+#define    MC_CMD_FINI_TXQ_IN_LEN 4
+/* Instance of TXQ to destroy */
+#define       MC_CMD_FINI_TXQ_IN_INSTANCE_OFST 0
+
+/* MC_CMD_FINI_TXQ_OUT msgresponse */
+#define    MC_CMD_FINI_TXQ_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_DRIVER_EVENT
+ * Generate an event on an EVQ belonging to the function issuing the command.
+ */
+#define MC_CMD_DRIVER_EVENT 0x86
+
+/* MC_CMD_DRIVER_EVENT_IN msgrequest */
+#define    MC_CMD_DRIVER_EVENT_IN_LEN 12
+/* Handle of target EVQ */
+#define       MC_CMD_DRIVER_EVENT_IN_EVQ_OFST 0
+/* Bits 0 - 63 of event */
+#define       MC_CMD_DRIVER_EVENT_IN_DATA_OFST 4
+#define       MC_CMD_DRIVER_EVENT_IN_DATA_LEN 8
+#define       MC_CMD_DRIVER_EVENT_IN_DATA_LO_OFST 4
+#define       MC_CMD_DRIVER_EVENT_IN_DATA_HI_OFST 8
+
+/* MC_CMD_DRIVER_EVENT_OUT msgresponse */
+#define    MC_CMD_DRIVER_EVENT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_PROXY_CMD
+ * Execute an arbitrary MCDI command on behalf of a different function, subject
+ * to security restrictions. The command to be proxied follows immediately
+ * afterward in the host buffer (or on the UART). This command supercedes
+ * MC_CMD_SET_FUNC, which remains available for Siena but now deprecated.
+ */
+#define MC_CMD_PROXY_CMD 0x5b
+
+/* MC_CMD_PROXY_CMD_IN msgrequest */
+#define    MC_CMD_PROXY_CMD_IN_LEN 4
+/* The handle of the target function. */
+#define       MC_CMD_PROXY_CMD_IN_TARGET_OFST 0
+#define        MC_CMD_PROXY_CMD_IN_TARGET_PF_LBN 0
+#define        MC_CMD_PROXY_CMD_IN_TARGET_PF_WIDTH 16
+#define        MC_CMD_PROXY_CMD_IN_TARGET_VF_LBN 16
+#define        MC_CMD_PROXY_CMD_IN_TARGET_VF_WIDTH 16
+#define          MC_CMD_PROXY_CMD_IN_VF_NULL  0xffff /* enum */
+
+
+/***********************************/
+/* MC_CMD_ALLOC_BUFTBL_CHUNK
+ * Allocate a set of buffer table entries using the specified owner ID. This
+ * operation allocates the required buffer table entries (and fails if it
+ * cannot do so). The buffer table entries will initially be zeroed.
+ */
+#define MC_CMD_ALLOC_BUFTBL_CHUNK 0x87
+
+/* MC_CMD_ALLOC_BUFTBL_CHUNK_IN msgrequest */
+#define    MC_CMD_ALLOC_BUFTBL_CHUNK_IN_LEN 8
+/* Owner ID to use */
+#define       MC_CMD_ALLOC_BUFTBL_CHUNK_IN_OWNER_OFST 0
+/* Size of buffer table pages to use, in bytes (note that only a few values are
+ * legal on any specific hardware).
+ */
+#define       MC_CMD_ALLOC_BUFTBL_CHUNK_IN_PAGE_SIZE_OFST 4
+
+/* MC_CMD_ALLOC_BUFTBL_CHUNK_OUT msgresponse */
+#define    MC_CMD_ALLOC_BUFTBL_CHUNK_OUT_LEN 12
+#define       MC_CMD_ALLOC_BUFTBL_CHUNK_OUT_HANDLE_OFST 0
+#define       MC_CMD_ALLOC_BUFTBL_CHUNK_OUT_NUMENTRIES_OFST 4
+/* Buffer table IDs for use in DMA descriptors. */
+#define       MC_CMD_ALLOC_BUFTBL_CHUNK_OUT_ID_OFST 8
+
+
+/***********************************/
+/* MC_CMD_PROGRAM_BUFTBL_ENTRIES
+ * Reprogram a set of buffer table entries in the specified chunk.
+ */
+#define MC_CMD_PROGRAM_BUFTBL_ENTRIES 0x88
+
+/* MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN msgrequest */
+#define    MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_LENMIN 20
+#define    MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_LENMAX 252
+#define    MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_LEN(num) (12+8*(num))
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_HANDLE_OFST 0
+/* ID */
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_FIRSTID_OFST 4
+/* Num entries */
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_NUMENTRIES_OFST 8
+/* Buffer table entry address */
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_ENTRY_OFST 12
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_ENTRY_LEN 8
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_ENTRY_LO_OFST 12
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_ENTRY_HI_OFST 16
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_ENTRY_MINNUM 1
+#define       MC_CMD_PROGRAM_BUFTBL_ENTRIES_IN_ENTRY_MAXNUM 30
+
+/* MC_CMD_PROGRAM_BUFTBL_ENTRIES_OUT msgresponse */
+#define    MC_CMD_PROGRAM_BUFTBL_ENTRIES_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_FREE_BUFTBL_CHUNK
+ */
+#define MC_CMD_FREE_BUFTBL_CHUNK 0x89
+
+/* MC_CMD_FREE_BUFTBL_CHUNK_IN msgrequest */
+#define    MC_CMD_FREE_BUFTBL_CHUNK_IN_LEN 4
+#define       MC_CMD_FREE_BUFTBL_CHUNK_IN_HANDLE_OFST 0
+
+/* MC_CMD_FREE_BUFTBL_CHUNK_OUT msgresponse */
+#define    MC_CMD_FREE_BUFTBL_CHUNK_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_FILTER_OP
+ * Multiplexed MCDI call for filter operations
+ */
+#define MC_CMD_FILTER_OP 0x8a
+
+/* MC_CMD_FILTER_OP_IN msgrequest */
+#define    MC_CMD_FILTER_OP_IN_LEN 108
+/* identifies the type of operation requested */
+#define       MC_CMD_FILTER_OP_IN_OP_OFST 0
+/* enum: single-recipient filter insert */
+#define          MC_CMD_FILTER_OP_IN_OP_INSERT  0x0
+/* enum: single-recipient filter remove */
+#define          MC_CMD_FILTER_OP_IN_OP_REMOVE  0x1
+/* enum: multi-recipient filter subscribe */
+#define          MC_CMD_FILTER_OP_IN_OP_SUBSCRIBE  0x2
+/* enum: multi-recipient filter unsubscribe */
+#define          MC_CMD_FILTER_OP_IN_OP_UNSUBSCRIBE  0x3
+/* enum: replace one recipient with another (warning - the filter handle may
+ * change)
+ */
+#define          MC_CMD_FILTER_OP_IN_OP_REPLACE  0x4
+/* filter handle (for remove / unsubscribe operations) */
+#define       MC_CMD_FILTER_OP_IN_HANDLE_OFST 4
+#define       MC_CMD_FILTER_OP_IN_HANDLE_LEN 8
+#define       MC_CMD_FILTER_OP_IN_HANDLE_LO_OFST 4
+#define       MC_CMD_FILTER_OP_IN_HANDLE_HI_OFST 8
+/* The port ID associated with the v-adaptor which should contain this filter.
+ */
+#define       MC_CMD_FILTER_OP_IN_PORT_ID_OFST 12
+/* fields to include in match criteria */
+#define       MC_CMD_FILTER_OP_IN_MATCH_FIELDS_OFST 16
+#define        MC_CMD_FILTER_OP_IN_MATCH_SRC_IP_LBN 0
+#define        MC_CMD_FILTER_OP_IN_MATCH_SRC_IP_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_DST_IP_LBN 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_DST_IP_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_SRC_MAC_LBN 2
+#define        MC_CMD_FILTER_OP_IN_MATCH_SRC_MAC_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_SRC_PORT_LBN 3
+#define        MC_CMD_FILTER_OP_IN_MATCH_SRC_PORT_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_DST_MAC_LBN 4
+#define        MC_CMD_FILTER_OP_IN_MATCH_DST_MAC_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_DST_PORT_LBN 5
+#define        MC_CMD_FILTER_OP_IN_MATCH_DST_PORT_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_ETHER_TYPE_LBN 6
+#define        MC_CMD_FILTER_OP_IN_MATCH_ETHER_TYPE_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_INNER_VLAN_LBN 7
+#define        MC_CMD_FILTER_OP_IN_MATCH_INNER_VLAN_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_OUTER_VLAN_LBN 8
+#define        MC_CMD_FILTER_OP_IN_MATCH_OUTER_VLAN_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_IP_PROTO_LBN 9
+#define        MC_CMD_FILTER_OP_IN_MATCH_IP_PROTO_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_FWDEF0_LBN 10
+#define        MC_CMD_FILTER_OP_IN_MATCH_FWDEF0_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_FWDEF1_LBN 11
+#define        MC_CMD_FILTER_OP_IN_MATCH_FWDEF1_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST_LBN 30
+#define        MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_MCAST_DST_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST_LBN 31
+#define        MC_CMD_FILTER_OP_IN_MATCH_UNKNOWN_UCAST_DST_WIDTH 1
+/* receive destination */
+#define       MC_CMD_FILTER_OP_IN_RX_DEST_OFST 20
+/* enum: drop packets */
+#define          MC_CMD_FILTER_OP_IN_RX_DEST_DROP  0x0
+/* enum: receive to host */
+#define          MC_CMD_FILTER_OP_IN_RX_DEST_HOST  0x1
+/* enum: receive to MC */
+#define          MC_CMD_FILTER_OP_IN_RX_DEST_MC  0x2
+/* enum: loop back to port 0 TX MAC */
+#define          MC_CMD_FILTER_OP_IN_RX_DEST_TX0  0x3
+/* enum: loop back to port 1 TX MAC */
+#define          MC_CMD_FILTER_OP_IN_RX_DEST_TX1  0x4
+/* receive queue handle (for multiple queue modes, this is the base queue) */
+#define       MC_CMD_FILTER_OP_IN_RX_QUEUE_OFST 24
+/* receive mode */
+#define       MC_CMD_FILTER_OP_IN_RX_MODE_OFST 28
+/* enum: receive to just the specified queue */
+#define          MC_CMD_FILTER_OP_IN_RX_MODE_SIMPLE  0x0
+/* enum: receive to multiple queues using RSS context */
+#define          MC_CMD_FILTER_OP_IN_RX_MODE_RSS  0x1
+/* enum: receive to multiple queues using .1p mapping */
+#define          MC_CMD_FILTER_OP_IN_RX_MODE_DOT1P_MAPPING  0x2
+/* enum: install a filter entry that will never match; for test purposes only
+ */
+#define          MC_CMD_FILTER_OP_IN_RX_MODE_TEST_NEVER_MATCH  0x80000000
+/* RSS context (for RX_MODE_RSS) or .1p mapping handle (for
+ * RX_MODE_DOT1P_MAPPING), as returned by MC_CMD_RSS_CONTEXT_ALLOC or
+ * MC_CMD_DOT1P_MAPPING_ALLOC. Note that these handles should be considered
+ * opaque to the host, although a value of 0xFFFFFFFF is guaranteed never to be
+ * a valid handle.
+ */
+#define       MC_CMD_FILTER_OP_IN_RX_CONTEXT_OFST 32
+/* transmit domain (reserved; set to 0) */
+#define       MC_CMD_FILTER_OP_IN_TX_DOMAIN_OFST 36
+/* transmit destination (either set the MAC and/or PM bits for explicit
+ * control, or set this field to TX_DEST_DEFAULT for sensible default
+ * behaviour)
+ */
+#define       MC_CMD_FILTER_OP_IN_TX_DEST_OFST 40
+/* enum: request default behaviour (based on filter type) */
+#define          MC_CMD_FILTER_OP_IN_TX_DEST_DEFAULT  0xffffffff
+#define        MC_CMD_FILTER_OP_IN_TX_DEST_MAC_LBN 0
+#define        MC_CMD_FILTER_OP_IN_TX_DEST_MAC_WIDTH 1
+#define        MC_CMD_FILTER_OP_IN_TX_DEST_PM_LBN 1
+#define        MC_CMD_FILTER_OP_IN_TX_DEST_PM_WIDTH 1
+/* source MAC address to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_SRC_MAC_OFST 44
+#define       MC_CMD_FILTER_OP_IN_SRC_MAC_LEN 6
+/* source port to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_SRC_PORT_OFST 50
+#define       MC_CMD_FILTER_OP_IN_SRC_PORT_LEN 2
+/* destination MAC address to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_DST_MAC_OFST 52
+#define       MC_CMD_FILTER_OP_IN_DST_MAC_LEN 6
+/* destination port to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_DST_PORT_OFST 58
+#define       MC_CMD_FILTER_OP_IN_DST_PORT_LEN 2
+/* Ethernet type to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_ETHER_TYPE_OFST 60
+#define       MC_CMD_FILTER_OP_IN_ETHER_TYPE_LEN 2
+/* Inner VLAN tag to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_INNER_VLAN_OFST 62
+#define       MC_CMD_FILTER_OP_IN_INNER_VLAN_LEN 2
+/* Outer VLAN tag to match (as bytes in network order) */
+#define       MC_CMD_FILTER_OP_IN_OUTER_VLAN_OFST 64
+#define       MC_CMD_FILTER_OP_IN_OUTER_VLAN_LEN 2
+/* IP protocol to match (in low byte; set high byte to 0) */
+#define       MC_CMD_FILTER_OP_IN_IP_PROTO_OFST 66
+#define       MC_CMD_FILTER_OP_IN_IP_PROTO_LEN 2
+/* Firmware defined register 0 to match (reserved; set to 0) */
+#define       MC_CMD_FILTER_OP_IN_FWDEF0_OFST 68
+/* Firmware defined register 1 to match (reserved; set to 0) */
+#define       MC_CMD_FILTER_OP_IN_FWDEF1_OFST 72
+/* source IP address to match (as bytes in network order; set last 12 bytes to
+ * 0 for IPv4 address)
+ */
+#define       MC_CMD_FILTER_OP_IN_SRC_IP_OFST 76
+#define       MC_CMD_FILTER_OP_IN_SRC_IP_LEN 16
+/* destination IP address to match (as bytes in network order; set last 12
+ * bytes to 0 for IPv4 address)
+ */
+#define       MC_CMD_FILTER_OP_IN_DST_IP_OFST 92
+#define       MC_CMD_FILTER_OP_IN_DST_IP_LEN 16
+
+/* MC_CMD_FILTER_OP_OUT msgresponse */
+#define    MC_CMD_FILTER_OP_OUT_LEN 12
+/* identifies the type of operation requested */
+#define       MC_CMD_FILTER_OP_OUT_OP_OFST 0
+/*            Enum values, see field(s): */
+/*               MC_CMD_FILTER_OP_IN/OP */
+/* Returned filter handle (for insert / subscribe operations). Note that these
+ * handles should be considered opaque to the host, although a value of
+ * 0xFFFFFFFF_FFFFFFFF is guaranteed never to be a valid handle.
+ */
+#define       MC_CMD_FILTER_OP_OUT_HANDLE_OFST 4
+#define       MC_CMD_FILTER_OP_OUT_HANDLE_LEN 8
+#define       MC_CMD_FILTER_OP_OUT_HANDLE_LO_OFST 4
+#define       MC_CMD_FILTER_OP_OUT_HANDLE_HI_OFST 8
+
+
+/***********************************/
+/* MC_CMD_GET_PARSER_DISP_INFO
+ * Get information related to the parser-dispatcher subsystem
+ */
+#define MC_CMD_GET_PARSER_DISP_INFO 0xe4
+
+/* MC_CMD_GET_PARSER_DISP_INFO_IN msgrequest */
+#define    MC_CMD_GET_PARSER_DISP_INFO_IN_LEN 4
+/* identifies the type of operation requested */
+#define       MC_CMD_GET_PARSER_DISP_INFO_IN_OP_OFST 0
+/* enum: read the list of supported RX filter matches */
+#define          MC_CMD_GET_PARSER_DISP_INFO_IN_OP_GET_SUPPORTED_RX_MATCHES  0x1
+
+/* MC_CMD_GET_PARSER_DISP_INFO_OUT msgresponse */
+#define    MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMIN 8
+#define    MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX 252
+#define    MC_CMD_GET_PARSER_DISP_INFO_OUT_LEN(num) (8+4*(num))
+/* identifies the type of operation requested */
+#define       MC_CMD_GET_PARSER_DISP_INFO_OUT_OP_OFST 0
+/*            Enum values, see field(s): */
+/*               MC_CMD_GET_PARSER_DISP_INFO_IN/OP */
+/* number of supported match types */
+#define       MC_CMD_GET_PARSER_DISP_INFO_OUT_NUM_SUPPORTED_MATCHES_OFST 4
+/* array of supported match types (valid MATCH_FIELDS values for
+ * MC_CMD_FILTER_OP) sorted in decreasing priority order
+ */
+#define       MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_OFST 8
+#define       MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_LEN 4
+#define       MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_MINNUM 0
+#define       MC_CMD_GET_PARSER_DISP_INFO_OUT_SUPPORTED_MATCHES_MAXNUM 61
+
+
+/***********************************/
+/* MC_CMD_PARSER_DISP_RW
+ * Direct read/write of parser-dispatcher state (DICPUs and LUE) for debugging
+ */
+#define MC_CMD_PARSER_DISP_RW 0xe5
+
+/* MC_CMD_PARSER_DISP_RW_IN msgrequest */
+#define    MC_CMD_PARSER_DISP_RW_IN_LEN 32
+/* identifies the target of the operation */
+#define       MC_CMD_PARSER_DISP_RW_IN_TARGET_OFST 0
+/* enum: RX dispatcher CPU */
+#define          MC_CMD_PARSER_DISP_RW_IN_RX_DICPU  0x0
+/* enum: TX dispatcher CPU */
+#define          MC_CMD_PARSER_DISP_RW_IN_TX_DICPU  0x1
+/* enum: Lookup engine */
+#define          MC_CMD_PARSER_DISP_RW_IN_LUE  0x2
+/* identifies the type of operation requested */
+#define       MC_CMD_PARSER_DISP_RW_IN_OP_OFST 4
+/* enum: read a word of DICPU DMEM or a LUE entry */
+#define          MC_CMD_PARSER_DISP_RW_IN_READ  0x0
+/* enum: write a word of DICPU DMEM or a LUE entry */
+#define          MC_CMD_PARSER_DISP_RW_IN_WRITE  0x1
+/* enum: read-modify-write a word of DICPU DMEM (not valid for LUE) */
+#define          MC_CMD_PARSER_DISP_RW_IN_RMW  0x2
+/* data memory address or LUE index */
+#define       MC_CMD_PARSER_DISP_RW_IN_ADDRESS_OFST 8
+/* value to write (for DMEM writes) */
+#define       MC_CMD_PARSER_DISP_RW_IN_DMEM_WRITE_VALUE_OFST 12
+/* XOR value (for DMEM read-modify-writes: new = (old & mask) ^ value) */
+#define       MC_CMD_PARSER_DISP_RW_IN_DMEM_RMW_XOR_VALUE_OFST 12
+/* AND mask (for DMEM read-modify-writes: new = (old & mask) ^ value) */
+#define       MC_CMD_PARSER_DISP_RW_IN_DMEM_RMW_AND_MASK_OFST 16
+/* value to write (for LUE writes) */
+#define       MC_CMD_PARSER_DISP_RW_IN_LUE_WRITE_VALUE_OFST 12
+#define       MC_CMD_PARSER_DISP_RW_IN_LUE_WRITE_VALUE_LEN 20
+
+/* MC_CMD_PARSER_DISP_RW_OUT msgresponse */
+#define    MC_CMD_PARSER_DISP_RW_OUT_LEN 52
+/* value read (for DMEM reads) */
+#define       MC_CMD_PARSER_DISP_RW_OUT_DMEM_READ_VALUE_OFST 0
+/* value read (for LUE reads) */
+#define       MC_CMD_PARSER_DISP_RW_OUT_LUE_READ_VALUE_OFST 0
+#define       MC_CMD_PARSER_DISP_RW_OUT_LUE_READ_VALUE_LEN 20
+/* up to 8 32-bit words of additional soft state from the LUE manager (the
+ * exact content is firmware-dependent and intended only for debug use)
+ */
+#define       MC_CMD_PARSER_DISP_RW_OUT_LUE_MGR_STATE_OFST 20
+#define       MC_CMD_PARSER_DISP_RW_OUT_LUE_MGR_STATE_LEN 32
+
+
+/***********************************/
+/* MC_CMD_GET_PF_COUNT
+ * Get number of PFs on the device.
+ */
+#define MC_CMD_GET_PF_COUNT 0xb6
+
+/* MC_CMD_GET_PF_COUNT_IN msgrequest */
+#define    MC_CMD_GET_PF_COUNT_IN_LEN 0
+
+/* MC_CMD_GET_PF_COUNT_OUT msgresponse */
+#define    MC_CMD_GET_PF_COUNT_OUT_LEN 1
+/* Identifies the number of PFs on the device. */
+#define       MC_CMD_GET_PF_COUNT_OUT_PF_COUNT_OFST 0
+#define       MC_CMD_GET_PF_COUNT_OUT_PF_COUNT_LEN 1
+
+
+/***********************************/
+/* MC_CMD_SET_PF_COUNT
+ * Set number of PFs on the device.
+ */
+#define MC_CMD_SET_PF_COUNT 0xb7
+
+/* MC_CMD_SET_PF_COUNT_IN msgrequest */
+#define    MC_CMD_SET_PF_COUNT_IN_LEN 4
+/* New number of PFs on the device. */
+#define       MC_CMD_SET_PF_COUNT_IN_PF_COUNT_OFST 0
+
+/* MC_CMD_SET_PF_COUNT_OUT msgresponse */
+#define    MC_CMD_SET_PF_COUNT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_PORT_ASSIGNMENT
+ * Get port assignment for current PCI function.
+ */
+#define MC_CMD_GET_PORT_ASSIGNMENT 0xb8
+
+/* MC_CMD_GET_PORT_ASSIGNMENT_IN msgrequest */
+#define    MC_CMD_GET_PORT_ASSIGNMENT_IN_LEN 0
+
+/* MC_CMD_GET_PORT_ASSIGNMENT_OUT msgresponse */
+#define    MC_CMD_GET_PORT_ASSIGNMENT_OUT_LEN 4
+/* Identifies the port assignment for this function. */
+#define       MC_CMD_GET_PORT_ASSIGNMENT_OUT_PORT_OFST 0
+
+
+/***********************************/
+/* MC_CMD_SET_PORT_ASSIGNMENT
+ * Set port assignment for current PCI function.
+ */
+#define MC_CMD_SET_PORT_ASSIGNMENT 0xb9
+
+/* MC_CMD_SET_PORT_ASSIGNMENT_IN msgrequest */
+#define    MC_CMD_SET_PORT_ASSIGNMENT_IN_LEN 4
+/* Identifies the port assignment for this function. */
+#define       MC_CMD_SET_PORT_ASSIGNMENT_IN_PORT_OFST 0
+
+/* MC_CMD_SET_PORT_ASSIGNMENT_OUT msgresponse */
+#define    MC_CMD_SET_PORT_ASSIGNMENT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_ALLOC_VIS
+ * Allocate VIs for current PCI function.
+ */
+#define MC_CMD_ALLOC_VIS 0x8b
+
+/* MC_CMD_ALLOC_VIS_IN msgrequest */
+#define    MC_CMD_ALLOC_VIS_IN_LEN 8
+/* The minimum number of VIs that is acceptable */
+#define       MC_CMD_ALLOC_VIS_IN_MIN_VI_COUNT_OFST 0
+/* The maximum number of VIs that would be useful */
+#define       MC_CMD_ALLOC_VIS_IN_MAX_VI_COUNT_OFST 4
+
+/* MC_CMD_ALLOC_VIS_OUT msgresponse */
+#define    MC_CMD_ALLOC_VIS_OUT_LEN 8
+/* The number of VIs allocated on this function */
+#define       MC_CMD_ALLOC_VIS_OUT_VI_COUNT_OFST 0
+/* The base absolute VI number allocated to this function. Required to
+ * correctly interpret wakeup events.
+ */
+#define       MC_CMD_ALLOC_VIS_OUT_VI_BASE_OFST 4
+
+
+/***********************************/
+/* MC_CMD_FREE_VIS
+ * Free VIs for current PCI function. Any linked PIO buffers will be unlinked,
+ * but not freed.
+ */
+#define MC_CMD_FREE_VIS 0x8c
+
+/* MC_CMD_FREE_VIS_IN msgrequest */
+#define    MC_CMD_FREE_VIS_IN_LEN 0
+
+/* MC_CMD_FREE_VIS_OUT msgresponse */
+#define    MC_CMD_FREE_VIS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_SRIOV_CFG
+ * Get SRIOV config for this PF.
+ */
+#define MC_CMD_GET_SRIOV_CFG 0xba
+
+/* MC_CMD_GET_SRIOV_CFG_IN msgrequest */
+#define    MC_CMD_GET_SRIOV_CFG_IN_LEN 0
+
+/* MC_CMD_GET_SRIOV_CFG_OUT msgresponse */
+#define    MC_CMD_GET_SRIOV_CFG_OUT_LEN 20
+/* Number of VFs currently enabled. */
+#define       MC_CMD_GET_SRIOV_CFG_OUT_VF_CURRENT_OFST 0
+/* Max number of VFs before sriov stride and offset may need to be changed. */
+#define       MC_CMD_GET_SRIOV_CFG_OUT_VF_MAX_OFST 4
+#define       MC_CMD_GET_SRIOV_CFG_OUT_FLAGS_OFST 8
+#define        MC_CMD_GET_SRIOV_CFG_OUT_VF_ENABLED_LBN 0
+#define        MC_CMD_GET_SRIOV_CFG_OUT_VF_ENABLED_WIDTH 1
+/* RID offset of first VF from PF. */
+#define       MC_CMD_GET_SRIOV_CFG_OUT_VF_OFFSET_OFST 12
+/* RID offset of each subsequent VF from the previous. */
+#define       MC_CMD_GET_SRIOV_CFG_OUT_VF_STRIDE_OFST 16
+
+
+/***********************************/
+/* MC_CMD_SET_SRIOV_CFG
+ * Set SRIOV config for this PF.
+ */
+#define MC_CMD_SET_SRIOV_CFG 0xbb
+
+/* MC_CMD_SET_SRIOV_CFG_IN msgrequest */
+#define    MC_CMD_SET_SRIOV_CFG_IN_LEN 20
+/* Number of VFs currently enabled. */
+#define       MC_CMD_SET_SRIOV_CFG_IN_VF_CURRENT_OFST 0
+/* Max number of VFs before sriov stride and offset may need to be changed. */
+#define       MC_CMD_SET_SRIOV_CFG_IN_VF_MAX_OFST 4
+#define       MC_CMD_SET_SRIOV_CFG_IN_FLAGS_OFST 8
+#define        MC_CMD_SET_SRIOV_CFG_IN_VF_ENABLED_LBN 0
+#define        MC_CMD_SET_SRIOV_CFG_IN_VF_ENABLED_WIDTH 1
+/* RID offset of first VF from PF, or 0 for no change, or
+ * MC_CMD_RESOURCE_INSTANCE_ANY to allow the system to allocate an offset.
+ */
+#define       MC_CMD_SET_SRIOV_CFG_IN_VF_OFFSET_OFST 12
+/* RID offset of each subsequent VF from the previous, 0 for no change, or
+ * MC_CMD_RESOURCE_INSTANCE_ANY to allow the system to allocate a stride.
+ */
+#define       MC_CMD_SET_SRIOV_CFG_IN_VF_STRIDE_OFST 16
+
+/* MC_CMD_SET_SRIOV_CFG_OUT msgresponse */
+#define    MC_CMD_SET_SRIOV_CFG_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_VI_ALLOC_INFO
+ * Get information about number of VI's and base VI number allocated to this
+ * function.
+ */
+#define MC_CMD_GET_VI_ALLOC_INFO 0x8d
+
+/* MC_CMD_GET_VI_ALLOC_INFO_IN msgrequest */
+#define    MC_CMD_GET_VI_ALLOC_INFO_IN_LEN 0
+
+/* MC_CMD_GET_VI_ALLOC_INFO_OUT msgresponse */
+#define    MC_CMD_GET_VI_ALLOC_INFO_OUT_LEN 8
+/* The number of VIs allocated on this function */
+#define       MC_CMD_GET_VI_ALLOC_INFO_OUT_VI_COUNT_OFST 0
+/* The base absolute VI number allocated to this function. Required to
+ * correctly interpret wakeup events.
+ */
+#define       MC_CMD_GET_VI_ALLOC_INFO_OUT_VI_BASE_OFST 4
+
+
+/***********************************/
+/* MC_CMD_DUMP_VI_STATE
+ * For CmdClient use. Dump pertinent information on a specific absolute VI.
+ */
+#define MC_CMD_DUMP_VI_STATE 0x8e
+
+/* MC_CMD_DUMP_VI_STATE_IN msgrequest */
+#define    MC_CMD_DUMP_VI_STATE_IN_LEN 4
+/* The VI number to query. */
+#define       MC_CMD_DUMP_VI_STATE_IN_VI_NUMBER_OFST 0
+
+/* MC_CMD_DUMP_VI_STATE_OUT msgresponse */
+#define    MC_CMD_DUMP_VI_STATE_OUT_LEN 96
+/* The PF part of the function owning this VI. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_OWNER_PF_OFST 0
+#define       MC_CMD_DUMP_VI_STATE_OUT_OWNER_PF_LEN 2
+/* The VF part of the function owning this VI. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_OWNER_VF_OFST 2
+#define       MC_CMD_DUMP_VI_STATE_OUT_OWNER_VF_LEN 2
+/* Base of VIs allocated to this function. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VI_BASE_OFST 4
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VI_BASE_LEN 2
+/* Count of VIs allocated to the owner function. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VI_COUNT_OFST 6
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VI_COUNT_LEN 2
+/* Base interrupt vector allocated to this function. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VECTOR_BASE_OFST 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VECTOR_BASE_LEN 2
+/* Number of interrupt vectors allocated to this function. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VECTOR_COUNT_OFST 10
+#define       MC_CMD_DUMP_VI_STATE_OUT_FUNC_VECTOR_COUNT_LEN 2
+/* Raw evq ptr table data. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EVQ_PTR_RAW_OFST 12
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EVQ_PTR_RAW_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EVQ_PTR_RAW_LO_OFST 12
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EVQ_PTR_RAW_HI_OFST 16
+/* Raw evq timer table data. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EV_TIMER_RAW_OFST 20
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EV_TIMER_RAW_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EV_TIMER_RAW_LO_OFST 20
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EV_TIMER_RAW_HI_OFST 24
+/* Combined metadata field. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_OFST 28
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_BUFS_BASE_LBN 0
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_BUFS_BASE_WIDTH 16
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_BUFS_NPAGES_LBN 16
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_BUFS_NPAGES_WIDTH 8
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_WKUP_REF_LBN 24
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_EV_META_WKUP_REF_WIDTH 8
+/* TXDPCPU raw table data for queue. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_0_OFST 32
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_0_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_0_LO_OFST 32
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_0_HI_OFST 36
+/* TXDPCPU raw table data for queue. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_1_OFST 40
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_1_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_1_LO_OFST 40
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_1_HI_OFST 44
+/* TXDPCPU raw table data for queue. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_2_OFST 48
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_2_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_2_LO_OFST 48
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_RAW_TBL_2_HI_OFST 52
+/* Combined metadata field. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_OFST 56
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_LO_OFST 56
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_HI_OFST 60
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_BUFS_BASE_LBN 0
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_BUFS_BASE_WIDTH 16
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_BUFS_NPAGES_LBN 16
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_BUFS_NPAGES_WIDTH 8
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_QSTATE_LBN 24
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_QSTATE_WIDTH 8
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_WAITCOUNT_LBN 32
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_TX_META_WAITCOUNT_WIDTH 8
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_PADDING_LBN 40
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_PADDING_WIDTH 24
+/* RXDPCPU raw table data for queue. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_0_OFST 64
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_0_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_0_LO_OFST 64
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_0_HI_OFST 68
+/* RXDPCPU raw table data for queue. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_1_OFST 72
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_1_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_1_LO_OFST 72
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_1_HI_OFST 76
+/* Reserved, currently 0. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_2_OFST 80
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_2_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_2_LO_OFST 80
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_RAW_TBL_2_HI_OFST 84
+/* Combined metadata field. */
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_OFST 88
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_LEN 8
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_LO_OFST 88
+#define       MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_HI_OFST 92
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_BUFS_BASE_LBN 0
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_BUFS_BASE_WIDTH 16
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_BUFS_NPAGES_LBN 16
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_BUFS_NPAGES_WIDTH 8
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_QSTATE_LBN 24
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_QSTATE_WIDTH 8
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_WAITCOUNT_LBN 32
+#define        MC_CMD_DUMP_VI_STATE_OUT_VI_RX_META_WAITCOUNT_WIDTH 8
+
+
+/***********************************/
+/* MC_CMD_ALLOC_PIOBUF
+ * Allocate a push I/O buffer for later use with a tx queue.
+ */
+#define MC_CMD_ALLOC_PIOBUF 0x8f
+
+/* MC_CMD_ALLOC_PIOBUF_IN msgrequest */
+#define    MC_CMD_ALLOC_PIOBUF_IN_LEN 0
+
+/* MC_CMD_ALLOC_PIOBUF_OUT msgresponse */
+#define    MC_CMD_ALLOC_PIOBUF_OUT_LEN 4
+/* Handle for allocated push I/O buffer. */
+#define       MC_CMD_ALLOC_PIOBUF_OUT_PIOBUF_HANDLE_OFST 0
+
+
+/***********************************/
+/* MC_CMD_FREE_PIOBUF
+ * Free a push I/O buffer.
+ */
+#define MC_CMD_FREE_PIOBUF 0x90
+
+/* MC_CMD_FREE_PIOBUF_IN msgrequest */
+#define    MC_CMD_FREE_PIOBUF_IN_LEN 4
+/* Handle for allocated push I/O buffer. */
+#define       MC_CMD_FREE_PIOBUF_IN_PIOBUF_HANDLE_OFST 0
+
+/* MC_CMD_FREE_PIOBUF_OUT msgresponse */
+#define    MC_CMD_FREE_PIOBUF_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_VI_TLP_PROCESSING
+ * Get TLP steering and ordering information for a VI.
+ */
+#define MC_CMD_GET_VI_TLP_PROCESSING 0xb0
+
+/* MC_CMD_GET_VI_TLP_PROCESSING_IN msgrequest */
+#define    MC_CMD_GET_VI_TLP_PROCESSING_IN_LEN 4
+/* VI number to get information for. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_IN_INSTANCE_OFST 0
+
+/* MC_CMD_GET_VI_TLP_PROCESSING_OUT msgresponse */
+#define    MC_CMD_GET_VI_TLP_PROCESSING_OUT_LEN 4
+/* Transaction processing steering hint 1 for use with the Rx Queue. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_TPH_TAG1_RX_OFST 0
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_TPH_TAG1_RX_LEN 1
+/* Transaction processing steering hint 2 for use with the Ev Queue. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_TPH_TAG2_EV_OFST 1
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_TPH_TAG2_EV_LEN 1
+/* Use Relaxed ordering model for TLPs on this VI. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_RELAXED_ORDERING_LBN 16
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_RELAXED_ORDERING_WIDTH 1
+/* Use ID based ordering for TLPs on this VI. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_ID_BASED_ORDERING_LBN 17
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_ID_BASED_ORDERING_WIDTH 1
+/* Set no snoop bit for TLPs on this VI. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_NO_SNOOP_LBN 18
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_NO_SNOOP_WIDTH 1
+/* Enable TPH for TLPs on this VI. */
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_TPH_ON_LBN 19
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_TPH_ON_WIDTH 1
+#define       MC_CMD_GET_VI_TLP_PROCESSING_OUT_DATA_OFST 0
+
+
+/***********************************/
+/* MC_CMD_SET_VI_TLP_PROCESSING
+ * Set TLP steering and ordering information for a VI.
+ */
+#define MC_CMD_SET_VI_TLP_PROCESSING 0xb1
+
+/* MC_CMD_SET_VI_TLP_PROCESSING_IN msgrequest */
+#define    MC_CMD_SET_VI_TLP_PROCESSING_IN_LEN 8
+/* VI number to set information for. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_INSTANCE_OFST 0
+/* Transaction processing steering hint 1 for use with the Rx Queue. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_TPH_TAG1_RX_OFST 4
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_TPH_TAG1_RX_LEN 1
+/* Transaction processing steering hint 2 for use with the Ev Queue. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_TPH_TAG2_EV_OFST 5
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_TPH_TAG2_EV_LEN 1
+/* Use Relaxed ordering model for TLPs on this VI. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_RELAXED_ORDERING_LBN 48
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_RELAXED_ORDERING_WIDTH 1
+/* Use ID based ordering for TLPs on this VI. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_ID_BASED_ORDERING_LBN 49
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_ID_BASED_ORDERING_WIDTH 1
+/* Set the no snoop bit for TLPs on this VI. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_NO_SNOOP_LBN 50
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_NO_SNOOP_WIDTH 1
+/* Enable TPH for TLPs on this VI. */
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_TPH_ON_LBN 51
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_TPH_ON_WIDTH 1
+#define       MC_CMD_SET_VI_TLP_PROCESSING_IN_DATA_OFST 4
+
+/* MC_CMD_SET_VI_TLP_PROCESSING_OUT msgresponse */
+#define    MC_CMD_SET_VI_TLP_PROCESSING_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_TLP_PROCESSING_GLOBALS
+ * Get global PCIe steering and transaction processing configuration.
+ */
+#define MC_CMD_GET_TLP_PROCESSING_GLOBALS 0xbc
+
+/* MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN msgrequest */
+#define    MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN_LEN 4
+#define       MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN_TLP_GLOBAL_CATEGORY_OFST 0
+/* enum: MISC. */
+#define          MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN_TLP_GLOBAL_CATEGORY_MISC  0x0
+/* enum: IDO. */
+#define          MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN_TLP_GLOBAL_CATEGORY_IDO  0x1
+/* enum: RO. */
+#define          MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN_TLP_GLOBAL_CATEGORY_RO  0x2
+/* enum: TPH Type. */
+#define          MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN_TLP_GLOBAL_CATEGORY_TPH_TYPE  0x3
+
+/* MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT msgresponse */
+#define    MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_LEN 8
+#define       MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_GLOBAL_CATEGORY_OFST 0
+/*            Enum values, see field(s): */
+/*               MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN/TLP_GLOBAL_CATEGORY */
+/* Amalgamated TLP info word. */
+#define       MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_WORD_OFST 4
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_MISC_WTAG_EN_LBN 0
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_MISC_WTAG_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_MISC_SPARE_LBN 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_MISC_SPARE_WIDTH 31
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_DL_EN_LBN 0
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_DL_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_TX_EN_LBN 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_TX_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_EV_EN_LBN 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_EV_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_RX_EN_LBN 3
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_RX_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_SPARE_LBN 4
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_IDO_SPARE_WIDTH 28
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_RXDMA_EN_LBN 0
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_RXDMA_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_TXDMA_EN_LBN 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_TXDMA_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_DL_EN_LBN 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_DL_EN_WIDTH 1
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_SPARE_LBN 3
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_RO_SPARE_WIDTH 29
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_MSIX_LBN 0
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_MSIX_WIDTH 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_DL_LBN 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_DL_WIDTH 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_TX_LBN 4
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_TX_WIDTH 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_EV_LBN 6
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_EV_WIDTH 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_RX_LBN 8
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TPH_TYPE_RX_WIDTH 2
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TLP_TYPE_SPARE_LBN 9
+#define        MC_CMD_GET_TLP_PROCESSING_GLOBALS_OUT_TLP_INFO_TLP_TYPE_SPARE_WIDTH 23
+
+
+/***********************************/
+/* MC_CMD_SET_TLP_PROCESSING_GLOBALS
+ * Set global PCIe steering and transaction processing configuration.
+ */
+#define MC_CMD_SET_TLP_PROCESSING_GLOBALS 0xbd
+
+/* MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN msgrequest */
+#define    MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_LEN 8
+#define       MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_GLOBAL_CATEGORY_OFST 0
+/*            Enum values, see field(s): */
+/*               MC_CMD_GET_TLP_PROCESSING_GLOBALS/MC_CMD_GET_TLP_PROCESSING_GLOBALS_IN/TLP_GLOBAL_CATEGORY */
+/* Amalgamated TLP info word. */
+#define       MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_WORD_OFST 4
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_MISC_WTAG_EN_LBN 0
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_MISC_WTAG_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_DL_EN_LBN 0
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_DL_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_TX_EN_LBN 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_TX_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_EV_EN_LBN 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_EV_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_RX_EN_LBN 3
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_IDO_RX_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_RO_RXDMA_EN_LBN 0
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_RO_RXDMA_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_RO_TXDMA_EN_LBN 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_RO_TXDMA_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_RO_DL_EN_LBN 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_RO_DL_EN_WIDTH 1
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_MSIX_LBN 0
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_MSIX_WIDTH 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_DL_LBN 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_DL_WIDTH 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_TX_LBN 4
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_TX_WIDTH 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_EV_LBN 6
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_EV_WIDTH 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_RX_LBN 8
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_TPH_TYPE_RX_WIDTH 2
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_SPARE_LBN 10
+#define        MC_CMD_SET_TLP_PROCESSING_GLOBALS_IN_TLP_INFO_SPARE_WIDTH 22
+
+/* MC_CMD_SET_TLP_PROCESSING_GLOBALS_OUT msgresponse */
+#define    MC_CMD_SET_TLP_PROCESSING_GLOBALS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_SATELLITE_DOWNLOAD
+ * Download a new set of images to the satellite CPUs from the host.
+ */
+#define MC_CMD_SATELLITE_DOWNLOAD 0x91
+
+/* MC_CMD_SATELLITE_DOWNLOAD_IN msgrequest: The reset requirements for the CPUs
+ * are subtle, and so downloads must proceed in a number of phases.
+ *
+ * 1) PHASE_RESET with a target of TARGET_ALL and chunk ID/length of 0.
+ *
+ * 2) PHASE_IMEMS for each of the IMEM targets (target IDs 0-11). Each download
+ * may consist of multiple chunks. The final chunk (with CHUNK_ID_LAST) should
+ * be a checksum (a simple 32-bit sum) of the transferred data. An individual
+ * download may be aborted using CHUNK_ID_ABORT.
+ *
+ * 3) PHASE_VECTORS for each of the vector table targets (target IDs 12-15),
+ * similar to PHASE_IMEMS.
+ *
+ * 4) PHASE_READY with a target of TARGET_ALL and chunk ID/length of 0.
+ *
+ * After any error (a requested abort is not considered to be an error) the
+ * sequence must be restarted from PHASE_RESET.
+ */
+#define    MC_CMD_SATELLITE_DOWNLOAD_IN_LENMIN 20
+#define    MC_CMD_SATELLITE_DOWNLOAD_IN_LENMAX 252
+#define    MC_CMD_SATELLITE_DOWNLOAD_IN_LEN(num) (16+4*(num))
+/* Download phase. (Note: the IDLE phase is used internally and is never valid
+ * in a command from the host.)
+ */
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_PHASE_OFST 0
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_PHASE_IDLE     0x0 /* enum */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_PHASE_RESET    0x1 /* enum */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_PHASE_IMEMS    0x2 /* enum */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_PHASE_VECTORS  0x3 /* enum */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_PHASE_READY    0x4 /* enum */
+/* Target for download. (These match the blob numbers defined in
+ * mc_flash_layout.h.)
+ */
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_OFST 4
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXDI_TEXT  0x0
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXDI_TEXT  0x1
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXDP_TEXT  0x2
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXDP_TEXT  0x3
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXHRSL_HR_LUT  0x4
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXHRSL_HR_LUT_CFG  0x5
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXHRSL_HR_LUT  0x6
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXHRSL_HR_LUT_CFG  0x7
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXHRSL_HR_PGM  0x8
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXHRSL_SL_PGM  0x9
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXHRSL_HR_PGM  0xa
+/* enum: Valid in phase 2 (PHASE_IMEMS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXHRSL_SL_PGM  0xb
+/* enum: Valid in phase 3 (PHASE_VECTORS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXDI_VTBL0  0xc
+/* enum: Valid in phase 3 (PHASE_VECTORS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXDI_VTBL0  0xd
+/* enum: Valid in phase 3 (PHASE_VECTORS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_RXDI_VTBL1  0xe
+/* enum: Valid in phase 3 (PHASE_VECTORS) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_TXDI_VTBL1  0xf
+/* enum: Valid in phases 1 (PHASE_RESET) and 4 (PHASE_READY) only */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_TARGET_ALL  0xffffffff
+/* Chunk ID, or CHUNK_ID_LAST or CHUNK_ID_ABORT */
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_ID_OFST 8
+/* enum: Last chunk, containing checksum rather than data */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_ID_LAST  0xffffffff
+/* enum: Abort download of this item */
+#define          MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_ID_ABORT  0xfffffffe
+/* Length of this chunk in bytes */
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_LEN_OFST 12
+/* Data for this chunk */
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_DATA_OFST 16
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_DATA_LEN 4
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_DATA_MINNUM 1
+#define       MC_CMD_SATELLITE_DOWNLOAD_IN_CHUNK_DATA_MAXNUM 59
+
+/* MC_CMD_SATELLITE_DOWNLOAD_OUT msgresponse */
+#define    MC_CMD_SATELLITE_DOWNLOAD_OUT_LEN 8
+/* Same as MC_CMD_ERR field, but included as 0 in success cases */
+#define       MC_CMD_SATELLITE_DOWNLOAD_OUT_RESULT_OFST 0
+/* Extra status information */
+#define       MC_CMD_SATELLITE_DOWNLOAD_OUT_INFO_OFST 4
+/* enum: Code download OK, completed. */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_OK_COMPLETE  0x0
+/* enum: Code download aborted as requested. */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_OK_ABORTED  0x1
+/* enum: Code download OK so far, send next chunk. */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_OK_NEXT_CHUNK  0x2
+/* enum: Download phases out of sequence */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_ERR_BAD_PHASE  0x100
+/* enum: Bad target for this phase */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_ERR_BAD_TARGET  0x101
+/* enum: Chunk ID out of sequence */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_ERR_BAD_CHUNK_ID  0x200
+/* enum: Chunk length zero or too large */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_ERR_BAD_CHUNK_LEN  0x201
+/* enum: Checksum was incorrect */
+#define          MC_CMD_SATELLITE_DOWNLOAD_OUT_ERR_BAD_CHECKSUM  0x300
+
+
+/***********************************/
+/* MC_CMD_GET_CAPABILITIES
+ * Get device capabilities.
+ *
+ * This is supplementary to the MC_CMD_GET_BOARD_CFG command, and intended to
+ * reference inherent device capabilities as opposed to current NVRAM config.
+ */
+#define MC_CMD_GET_CAPABILITIES 0xbe
+
+/* MC_CMD_GET_CAPABILITIES_IN msgrequest */
+#define    MC_CMD_GET_CAPABILITIES_IN_LEN 0
+
+/* MC_CMD_GET_CAPABILITIES_OUT msgresponse */
+#define    MC_CMD_GET_CAPABILITIES_OUT_LEN 20
+/* First word of flags. */
+#define       MC_CMD_GET_CAPABILITIES_OUT_FLAGS1_OFST 0
+#define        MC_CMD_GET_CAPABILITIES_OUT_TX_VLAN_INSERTION_LBN 19
+#define        MC_CMD_GET_CAPABILITIES_OUT_TX_VLAN_INSERTION_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_VLAN_STRIPPING_LBN 20
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_VLAN_STRIPPING_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_LBN 21
+#define        MC_CMD_GET_CAPABILITIES_OUT_TX_TSO_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_PREFIX_LEN_0_LBN 22
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_PREFIX_LEN_0_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_PREFIX_LEN_14_LBN 23
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_PREFIX_LEN_14_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_TIMESTAMP_LBN 24
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_TIMESTAMP_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_BATCHING_LBN 25
+#define        MC_CMD_GET_CAPABILITIES_OUT_RX_BATCHING_WIDTH 1
+#define        MC_CMD_GET_CAPABILITIES_OUT_MCAST_FILTER_CHAINING_LBN 26
+#define        MC_CMD_GET_CAPABILITIES_OUT_MCAST_FILTER_CHAINING_WIDTH 1
+/* RxDPCPU firmware id. */
+#define       MC_CMD_GET_CAPABILITIES_OUT_RX_DPCPU_FW_ID_OFST 4
+#define       MC_CMD_GET_CAPABILITIES_OUT_RX_DPCPU_FW_ID_LEN 2
+/* enum: Standard RXDP firmware */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP  0x0
+/* enum: Low latency RXDP firmware */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_LOW_LATENCY  0x1
+/* enum: RXDP Test firmware image 1 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_FW_TO_MC_CUT_THROUGH  0x101
+/* enum: RXDP Test firmware image 2 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_FW_TO_MC_STORE_FORWARD  0x102
+/* enum: RXDP Test firmware image 3 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_FW_TO_MC_STORE_FORWARD_FIRST  0x103
+/* enum: RXDP Test firmware image 4 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_EVERY_EVENT_BATCHABLE  0x104
+/* enum: RXDP Test firmware image 5 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_BACKPRESSURE  0x105
+/* enum: RXDP Test firmware image 6 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_FW_PACKET_EDITS  0x106
+/* enum: RXDP Test firmware image 7 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_FW_RX_HDR_SPLIT  0x107
+/* enum: RXDP Test firmware image 8 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXDP_TEST_FW_DISABLE_DL  0x108
+/* TxDPCPU firmware id. */
+#define       MC_CMD_GET_CAPABILITIES_OUT_TX_DPCPU_FW_ID_OFST 6
+#define       MC_CMD_GET_CAPABILITIES_OUT_TX_DPCPU_FW_ID_LEN 2
+/* enum: Standard TXDP firmware */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXDP  0x0
+/* enum: Low latency TXDP firmware */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXDP_LOW_LATENCY  0x1
+/* enum: TXDP Test firmware image 1 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXDP_TEST_FW_TSO_EDIT  0x101
+/* enum: TXDP Test firmware image 2 */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXDP_TEST_FW_PACKET_EDITS  0x102
+#define       MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_VERSION_OFST 8
+#define       MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_VERSION_LEN 2
+#define        MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_VERSION_REV_LBN 0
+#define        MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_VERSION_REV_WIDTH 12
+#define        MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_VERSION_TYPE_LBN 12
+#define        MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_VERSION_TYPE_WIDTH 4
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_TYPE_FIRST_PKT  0x1 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_TYPE_SIENA_COMPAT  0x2 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_TYPE_VSWITCH  0x3 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_TYPE_SIENA_COMPAT_PM  0x4 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_RXPD_FW_TYPE_LOW_LATENCY  0x5 /* enum */
+#define       MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_VERSION_OFST 10
+#define       MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_VERSION_LEN 2
+#define        MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_VERSION_REV_LBN 0
+#define        MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_VERSION_REV_WIDTH 12
+#define        MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_VERSION_TYPE_LBN 12
+#define        MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_VERSION_TYPE_WIDTH 4
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_TYPE_FIRST_PKT  0x1 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_TYPE_SIENA_COMPAT  0x2 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_TYPE_VSWITCH  0x3 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_TYPE_SIENA_COMPAT_PM  0x4 /* enum */
+#define          MC_CMD_GET_CAPABILITIES_OUT_TXPD_FW_TYPE_LOW_LATENCY  0x5 /* enum */
+/* Hardware capabilities of NIC */
+#define       MC_CMD_GET_CAPABILITIES_OUT_HW_CAPABILITIES_OFST 12
+/* Licensed capabilities */
+#define       MC_CMD_GET_CAPABILITIES_OUT_LICENSE_CAPABILITIES_OFST 16
+
+
+/***********************************/
+/* MC_CMD_V2_EXTN
+ * Encapsulation for a v2 extended command
+ */
+#define MC_CMD_V2_EXTN 0x7f
+
+/* MC_CMD_V2_EXTN_IN msgrequest */
+#define    MC_CMD_V2_EXTN_IN_LEN 4
+/* the extended command number */
+#define       MC_CMD_V2_EXTN_IN_EXTENDED_CMD_LBN 0
+#define       MC_CMD_V2_EXTN_IN_EXTENDED_CMD_WIDTH 15
+#define       MC_CMD_V2_EXTN_IN_UNUSED_LBN 15
+#define       MC_CMD_V2_EXTN_IN_UNUSED_WIDTH 1
+/* the actual length of the encapsulated command (which is not in the v1
+ * header)
+ */
+#define       MC_CMD_V2_EXTN_IN_ACTUAL_LEN_LBN 16
+#define       MC_CMD_V2_EXTN_IN_ACTUAL_LEN_WIDTH 10
+#define       MC_CMD_V2_EXTN_IN_UNUSED2_LBN 26
+#define       MC_CMD_V2_EXTN_IN_UNUSED2_WIDTH 6
+
+
+/***********************************/
+/* MC_CMD_TCM_BUCKET_ALLOC
+ * Allocate a pacer bucket (for qau rp or a snapper test)
+ */
+#define MC_CMD_TCM_BUCKET_ALLOC 0xb2
+
+/* MC_CMD_TCM_BUCKET_ALLOC_IN msgrequest */
+#define    MC_CMD_TCM_BUCKET_ALLOC_IN_LEN 0
+
+/* MC_CMD_TCM_BUCKET_ALLOC_OUT msgresponse */
+#define    MC_CMD_TCM_BUCKET_ALLOC_OUT_LEN 4
+/* the bucket id */
+#define       MC_CMD_TCM_BUCKET_ALLOC_OUT_BUCKET_OFST 0
+
+
+/***********************************/
+/* MC_CMD_TCM_BUCKET_FREE
+ * Free a pacer bucket
+ */
+#define MC_CMD_TCM_BUCKET_FREE 0xb3
+
+/* MC_CMD_TCM_BUCKET_FREE_IN msgrequest */
+#define    MC_CMD_TCM_BUCKET_FREE_IN_LEN 4
+/* the bucket id */
+#define       MC_CMD_TCM_BUCKET_FREE_IN_BUCKET_OFST 0
+
+/* MC_CMD_TCM_BUCKET_FREE_OUT msgresponse */
+#define    MC_CMD_TCM_BUCKET_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_TCM_BUCKET_INIT
+ * Initialise pacer bucket with a given rate
+ */
+#define MC_CMD_TCM_BUCKET_INIT 0xb4
+
+/* MC_CMD_TCM_BUCKET_INIT_IN msgrequest */
+#define    MC_CMD_TCM_BUCKET_INIT_IN_LEN 8
+/* the bucket id */
+#define       MC_CMD_TCM_BUCKET_INIT_IN_BUCKET_OFST 0
+/* the rate in mbps */
+#define       MC_CMD_TCM_BUCKET_INIT_IN_RATE_OFST 4
+
+/* MC_CMD_TCM_BUCKET_INIT_OUT msgresponse */
+#define    MC_CMD_TCM_BUCKET_INIT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_TCM_TXQ_INIT
+ * Initialise txq in pacer with given options or set options
+ */
+#define MC_CMD_TCM_TXQ_INIT 0xb5
+
+/* MC_CMD_TCM_TXQ_INIT_IN msgrequest */
+#define    MC_CMD_TCM_TXQ_INIT_IN_LEN 28
+/* the txq id */
+#define       MC_CMD_TCM_TXQ_INIT_IN_QID_OFST 0
+/* the static priority associated with the txq */
+#define       MC_CMD_TCM_TXQ_INIT_IN_LABEL_OFST 4
+/* bitmask of the priority queues this txq is inserted into */
+#define       MC_CMD_TCM_TXQ_INIT_IN_PQ_FLAGS_OFST 8
+/* the reaction point (RP) bucket */
+#define       MC_CMD_TCM_TXQ_INIT_IN_RP_BKT_OFST 12
+/* an already reserved bucket (typically set to bucket associated with outer
+ * vswitch)
+ */
+#define       MC_CMD_TCM_TXQ_INIT_IN_MAX_BKT1_OFST 16
+/* an already reserved bucket (typically set to bucket associated with inner
+ * vswitch)
+ */
+#define       MC_CMD_TCM_TXQ_INIT_IN_MAX_BKT2_OFST 20
+/* the min bucket (typically for ETS/minimum bandwidth) */
+#define       MC_CMD_TCM_TXQ_INIT_IN_MIN_BKT_OFST 24
+
+/* MC_CMD_TCM_TXQ_INIT_OUT msgresponse */
+#define    MC_CMD_TCM_TXQ_INIT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_LINK_PIOBUF
+ * Link a push I/O buffer to a TxQ
+ */
+#define MC_CMD_LINK_PIOBUF 0x92
+
+/* MC_CMD_LINK_PIOBUF_IN msgrequest */
+#define    MC_CMD_LINK_PIOBUF_IN_LEN 8
+/* Handle for allocated push I/O buffer. */
+#define       MC_CMD_LINK_PIOBUF_IN_PIOBUF_HANDLE_OFST 0
+/* Function Local Instance (VI) number. */
+#define       MC_CMD_LINK_PIOBUF_IN_TXQ_INSTANCE_OFST 4
+
+/* MC_CMD_LINK_PIOBUF_OUT msgresponse */
+#define    MC_CMD_LINK_PIOBUF_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_UNLINK_PIOBUF
+ * Unlink a push I/O buffer from a TxQ
+ */
+#define MC_CMD_UNLINK_PIOBUF 0x93
+
+/* MC_CMD_UNLINK_PIOBUF_IN msgrequest */
+#define    MC_CMD_UNLINK_PIOBUF_IN_LEN 4
+/* Function Local Instance (VI) number. */
+#define       MC_CMD_UNLINK_PIOBUF_IN_TXQ_INSTANCE_OFST 0
+
+/* MC_CMD_UNLINK_PIOBUF_OUT msgresponse */
+#define    MC_CMD_UNLINK_PIOBUF_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VSWITCH_ALLOC
+ * allocate and initialise a v-switch.
+ */
+#define MC_CMD_VSWITCH_ALLOC 0x94
+
+/* MC_CMD_VSWITCH_ALLOC_IN msgrequest */
+#define    MC_CMD_VSWITCH_ALLOC_IN_LEN 16
+/* The port to connect to the v-switch's upstream port. */
+#define       MC_CMD_VSWITCH_ALLOC_IN_UPSTREAM_PORT_ID_OFST 0
+/* The type of v-switch to create. */
+#define       MC_CMD_VSWITCH_ALLOC_IN_TYPE_OFST 4
+/* enum: VLAN */
+#define          MC_CMD_VSWITCH_ALLOC_IN_VSWITCH_TYPE_VLAN  0x1
+/* enum: VEB */
+#define          MC_CMD_VSWITCH_ALLOC_IN_VSWITCH_TYPE_VEB  0x2
+/* enum: VEPA */
+#define          MC_CMD_VSWITCH_ALLOC_IN_VSWITCH_TYPE_VEPA  0x3
+/* Flags controlling v-port creation */
+#define       MC_CMD_VSWITCH_ALLOC_IN_FLAGS_OFST 8
+#define        MC_CMD_VSWITCH_ALLOC_IN_FLAG_AUTO_PORT_LBN 0
+#define        MC_CMD_VSWITCH_ALLOC_IN_FLAG_AUTO_PORT_WIDTH 1
+/* The number of VLAN tags to support. */
+#define       MC_CMD_VSWITCH_ALLOC_IN_NUM_VLAN_TAGS_OFST 12
+
+/* MC_CMD_VSWITCH_ALLOC_OUT msgresponse */
+#define    MC_CMD_VSWITCH_ALLOC_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VSWITCH_FREE
+ * de-allocate a v-switch.
+ */
+#define MC_CMD_VSWITCH_FREE 0x95
+
+/* MC_CMD_VSWITCH_FREE_IN msgrequest */
+#define    MC_CMD_VSWITCH_FREE_IN_LEN 4
+/* The port to which the v-switch is connected. */
+#define       MC_CMD_VSWITCH_FREE_IN_UPSTREAM_PORT_ID_OFST 0
+
+/* MC_CMD_VSWITCH_FREE_OUT msgresponse */
+#define    MC_CMD_VSWITCH_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VPORT_ALLOC
+ * allocate a v-port.
+ */
+#define MC_CMD_VPORT_ALLOC 0x96
+
+/* MC_CMD_VPORT_ALLOC_IN msgrequest */
+#define    MC_CMD_VPORT_ALLOC_IN_LEN 20
+/* The port to which the v-switch is connected. */
+#define       MC_CMD_VPORT_ALLOC_IN_UPSTREAM_PORT_ID_OFST 0
+/* The type of the new v-port. */
+#define       MC_CMD_VPORT_ALLOC_IN_TYPE_OFST 4
+/* enum: VLAN (obsolete) */
+#define          MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_VLAN  0x1
+/* enum: VEB (obsolete) */
+#define          MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_VEB  0x2
+/* enum: VEPA (obsolete) */
+#define          MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_VEPA  0x3
+/* enum: A normal v-port receives packets which match a specified MAC and/or
+ * VLAN.
+ */
+#define          MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL  0x4
+/* enum: An expansion v-port packets traffic which don't match any other
+ * v-port.
+ */
+#define          MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_EXPANSION  0x5
+/* enum: An test v-port receives packets which match any filters installed by
+ * its downstream components.
+ */
+#define          MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_TEST  0x6
+/* Flags controlling v-port creation */
+#define       MC_CMD_VPORT_ALLOC_IN_FLAGS_OFST 8
+#define        MC_CMD_VPORT_ALLOC_IN_FLAG_AUTO_PORT_LBN 0
+#define        MC_CMD_VPORT_ALLOC_IN_FLAG_AUTO_PORT_WIDTH 1
+/* The number of VLAN tags to insert/remove. */
+#define       MC_CMD_VPORT_ALLOC_IN_NUM_VLAN_TAGS_OFST 12
+/* The actual VLAN tags to insert/remove */
+#define       MC_CMD_VPORT_ALLOC_IN_VLAN_TAGS_OFST 16
+#define        MC_CMD_VPORT_ALLOC_IN_VLAN_TAG_0_LBN 0
+#define        MC_CMD_VPORT_ALLOC_IN_VLAN_TAG_0_WIDTH 16
+#define        MC_CMD_VPORT_ALLOC_IN_VLAN_TAG_1_LBN 16
+#define        MC_CMD_VPORT_ALLOC_IN_VLAN_TAG_1_WIDTH 16
+
+/* MC_CMD_VPORT_ALLOC_OUT msgresponse */
+#define    MC_CMD_VPORT_ALLOC_OUT_LEN 4
+/* The handle of the new v-port */
+#define       MC_CMD_VPORT_ALLOC_OUT_VPORT_ID_OFST 0
+
+
+/***********************************/
+/* MC_CMD_VPORT_FREE
+ * de-allocate a v-port.
+ */
+#define MC_CMD_VPORT_FREE 0x97
+
+/* MC_CMD_VPORT_FREE_IN msgrequest */
+#define    MC_CMD_VPORT_FREE_IN_LEN 4
+/* The handle of the v-port */
+#define       MC_CMD_VPORT_FREE_IN_VPORT_ID_OFST 0
+
+/* MC_CMD_VPORT_FREE_OUT msgresponse */
+#define    MC_CMD_VPORT_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VADAPTOR_ALLOC
+ * allocate a v-adaptor.
+ */
+#define MC_CMD_VADAPTOR_ALLOC 0x98
+
+/* MC_CMD_VADAPTOR_ALLOC_IN msgrequest */
+#define    MC_CMD_VADAPTOR_ALLOC_IN_LEN 16
+/* The port to connect to the v-adaptor's port. */
+#define       MC_CMD_VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID_OFST 0
+/* Flags controlling v-adaptor creation */
+#define       MC_CMD_VADAPTOR_ALLOC_IN_FLAGS_OFST 8
+#define        MC_CMD_VADAPTOR_ALLOC_IN_FLAG_AUTO_VADAPTOR_LBN 0
+#define        MC_CMD_VADAPTOR_ALLOC_IN_FLAG_AUTO_VADAPTOR_WIDTH 1
+/* The number of VLAN tags to strip on receive */
+#define       MC_CMD_VADAPTOR_ALLOC_IN_NUM_VLANS_OFST 12
+
+/* MC_CMD_VADAPTOR_ALLOC_OUT msgresponse */
+#define    MC_CMD_VADAPTOR_ALLOC_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VADAPTOR_FREE
+ * de-allocate a v-adaptor.
+ */
+#define MC_CMD_VADAPTOR_FREE 0x99
+
+/* MC_CMD_VADAPTOR_FREE_IN msgrequest */
+#define    MC_CMD_VADAPTOR_FREE_IN_LEN 4
+/* The port to which the v-adaptor is connected. */
+#define       MC_CMD_VADAPTOR_FREE_IN_UPSTREAM_PORT_ID_OFST 0
+
+/* MC_CMD_VADAPTOR_FREE_OUT msgresponse */
+#define    MC_CMD_VADAPTOR_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_EVB_PORT_ASSIGN
+ * assign a port to a PCI function.
+ */
+#define MC_CMD_EVB_PORT_ASSIGN 0x9a
+
+/* MC_CMD_EVB_PORT_ASSIGN_IN msgrequest */
+#define    MC_CMD_EVB_PORT_ASSIGN_IN_LEN 8
+/* The port to assign. */
+#define       MC_CMD_EVB_PORT_ASSIGN_IN_PORT_ID_OFST 0
+/* The target function to modify. */
+#define       MC_CMD_EVB_PORT_ASSIGN_IN_FUNCTION_OFST 4
+#define        MC_CMD_EVB_PORT_ASSIGN_IN_PF_LBN 0
+#define        MC_CMD_EVB_PORT_ASSIGN_IN_PF_WIDTH 16
+#define        MC_CMD_EVB_PORT_ASSIGN_IN_VF_LBN 16
+#define        MC_CMD_EVB_PORT_ASSIGN_IN_VF_WIDTH 16
+
+/* MC_CMD_EVB_PORT_ASSIGN_OUT msgresponse */
+#define    MC_CMD_EVB_PORT_ASSIGN_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RDWR_A64_REGIONS
+ * Assign the 64 bit region addresses.
+ */
+#define MC_CMD_RDWR_A64_REGIONS 0x9b
+
+/* MC_CMD_RDWR_A64_REGIONS_IN msgrequest */
+#define    MC_CMD_RDWR_A64_REGIONS_IN_LEN 17
+#define       MC_CMD_RDWR_A64_REGIONS_IN_REGION0_OFST 0
+#define       MC_CMD_RDWR_A64_REGIONS_IN_REGION1_OFST 4
+#define       MC_CMD_RDWR_A64_REGIONS_IN_REGION2_OFST 8
+#define       MC_CMD_RDWR_A64_REGIONS_IN_REGION3_OFST 12
+/* Write enable bits 0-3, set to write, clear to read. */
+#define       MC_CMD_RDWR_A64_REGIONS_IN_WRITE_MASK_LBN 128
+#define       MC_CMD_RDWR_A64_REGIONS_IN_WRITE_MASK_WIDTH 4
+#define       MC_CMD_RDWR_A64_REGIONS_IN_WRITE_MASK_BYTE_OFST 16
+#define       MC_CMD_RDWR_A64_REGIONS_IN_WRITE_MASK_BYTE_LEN 1
+
+/* MC_CMD_RDWR_A64_REGIONS_OUT msgresponse: This data always included
+ * regardless of state of write bits in the request.
+ */
+#define    MC_CMD_RDWR_A64_REGIONS_OUT_LEN 16
+#define       MC_CMD_RDWR_A64_REGIONS_OUT_REGION0_OFST 0
+#define       MC_CMD_RDWR_A64_REGIONS_OUT_REGION1_OFST 4
+#define       MC_CMD_RDWR_A64_REGIONS_OUT_REGION2_OFST 8
+#define       MC_CMD_RDWR_A64_REGIONS_OUT_REGION3_OFST 12
+
+
+/***********************************/
+/* MC_CMD_ONLOAD_STACK_ALLOC
+ * Allocate an Onload stack ID.
+ */
+#define MC_CMD_ONLOAD_STACK_ALLOC 0x9c
+
+/* MC_CMD_ONLOAD_STACK_ALLOC_IN msgrequest */
+#define    MC_CMD_ONLOAD_STACK_ALLOC_IN_LEN 4
+/* The handle of the owning upstream port */
+#define       MC_CMD_ONLOAD_STACK_ALLOC_IN_UPSTREAM_PORT_ID_OFST 0
+
+/* MC_CMD_ONLOAD_STACK_ALLOC_OUT msgresponse */
+#define    MC_CMD_ONLOAD_STACK_ALLOC_OUT_LEN 4
+/* The handle of the new Onload stack */
+#define       MC_CMD_ONLOAD_STACK_ALLOC_OUT_ONLOAD_STACK_ID_OFST 0
+
+
+/***********************************/
+/* MC_CMD_ONLOAD_STACK_FREE
+ * Free an Onload stack ID.
+ */
+#define MC_CMD_ONLOAD_STACK_FREE 0x9d
+
+/* MC_CMD_ONLOAD_STACK_FREE_IN msgrequest */
+#define    MC_CMD_ONLOAD_STACK_FREE_IN_LEN 4
+/* The handle of the Onload stack */
+#define       MC_CMD_ONLOAD_STACK_FREE_IN_ONLOAD_STACK_ID_OFST 0
+
+/* MC_CMD_ONLOAD_STACK_FREE_OUT msgresponse */
+#define    MC_CMD_ONLOAD_STACK_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_ALLOC
+ * Allocate an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_ALLOC 0x9e
+
+/* MC_CMD_RSS_CONTEXT_ALLOC_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN 12
+/* The handle of the owning upstream port */
+#define       MC_CMD_RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID_OFST 0
+/* The type of context to allocate */
+#define       MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_OFST 4
+/* enum: Allocate a context for exclusive use. The key and indirection table
+ * must be explicitly configured.
+ */
+#define          MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE  0x0
+/* enum: Allocate a context for shared use; this will spread across a range of
+ * queues, but the key and indirection table are pre-configured and may not be
+ * changed. For this mode, NUM_QUEUES must 2, 4, 8, 16, 32 or 64.
+ */
+#define          MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_SHARED  0x1
+/* Number of queues spanned by this context, in the range 1-64; valid offsets
+ * in the indirection table will be in the range 0 to NUM_QUEUES-1.
+ */
+#define       MC_CMD_RSS_CONTEXT_ALLOC_IN_NUM_QUEUES_OFST 8
+
+/* MC_CMD_RSS_CONTEXT_ALLOC_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN 4
+/* The handle of the new RSS context */
+#define       MC_CMD_RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID_OFST 0
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_FREE
+ * Free an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_FREE 0x9f
+
+/* MC_CMD_RSS_CONTEXT_FREE_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_FREE_IN_LEN 4
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_FREE_IN_RSS_CONTEXT_ID_OFST 0
+
+/* MC_CMD_RSS_CONTEXT_FREE_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_SET_KEY
+ * Set the Toeplitz hash key for an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_SET_KEY 0xa0
+
+/* MC_CMD_RSS_CONTEXT_SET_KEY_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_SET_KEY_IN_LEN 44
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_SET_KEY_IN_RSS_CONTEXT_ID_OFST 0
+/* The 40-byte Toeplitz hash key (TBD endianness issues?) */
+#define       MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_OFST 4
+#define       MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN 40
+
+/* MC_CMD_RSS_CONTEXT_SET_KEY_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_SET_KEY_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_GET_KEY
+ * Get the Toeplitz hash key for an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_GET_KEY 0xa1
+
+/* MC_CMD_RSS_CONTEXT_GET_KEY_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_GET_KEY_IN_LEN 4
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_GET_KEY_IN_RSS_CONTEXT_ID_OFST 0
+
+/* MC_CMD_RSS_CONTEXT_GET_KEY_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_GET_KEY_OUT_LEN 44
+/* The 40-byte Toeplitz hash key (TBD endianness issues?) */
+#define       MC_CMD_RSS_CONTEXT_GET_KEY_OUT_TOEPLITZ_KEY_OFST 4
+#define       MC_CMD_RSS_CONTEXT_GET_KEY_OUT_TOEPLITZ_KEY_LEN 40
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_SET_TABLE
+ * Set the indirection table for an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_SET_TABLE 0xa2
+
+/* MC_CMD_RSS_CONTEXT_SET_TABLE_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_SET_TABLE_IN_LEN 132
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_SET_TABLE_IN_RSS_CONTEXT_ID_OFST 0
+/* The 128-byte indirection table (1 byte per entry) */
+#define       MC_CMD_RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE_OFST 4
+#define       MC_CMD_RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE_LEN 128
+
+/* MC_CMD_RSS_CONTEXT_SET_TABLE_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_SET_TABLE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_GET_TABLE
+ * Get the indirection table for an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_GET_TABLE 0xa3
+
+/* MC_CMD_RSS_CONTEXT_GET_TABLE_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_GET_TABLE_IN_LEN 4
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_GET_TABLE_IN_RSS_CONTEXT_ID_OFST 0
+
+/* MC_CMD_RSS_CONTEXT_GET_TABLE_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_GET_TABLE_OUT_LEN 132
+/* The 128-byte indirection table (1 byte per entry) */
+#define       MC_CMD_RSS_CONTEXT_GET_TABLE_OUT_INDIRECTION_TABLE_OFST 4
+#define       MC_CMD_RSS_CONTEXT_GET_TABLE_OUT_INDIRECTION_TABLE_LEN 128
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_SET_FLAGS
+ * Set various control flags for an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_SET_FLAGS 0xe1
+
+/* MC_CMD_RSS_CONTEXT_SET_FLAGS_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN 8
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_RSS_CONTEXT_ID_OFST 0
+/* Hash control flags */
+#define       MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_FLAGS_OFST 4
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV4_EN_LBN 0
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV4_EN_WIDTH 1
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV4_EN_LBN 1
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV4_EN_WIDTH 1
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV6_EN_LBN 2
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV6_EN_WIDTH 1
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV6_EN_LBN 3
+#define        MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV6_EN_WIDTH 1
+
+/* MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RSS_CONTEXT_GET_FLAGS
+ * Get various control flags for an RSS context.
+ */
+#define MC_CMD_RSS_CONTEXT_GET_FLAGS 0xe2
+
+/* MC_CMD_RSS_CONTEXT_GET_FLAGS_IN msgrequest */
+#define    MC_CMD_RSS_CONTEXT_GET_FLAGS_IN_LEN 4
+/* The handle of the RSS context */
+#define       MC_CMD_RSS_CONTEXT_GET_FLAGS_IN_RSS_CONTEXT_ID_OFST 0
+
+/* MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT msgresponse */
+#define    MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_LEN 8
+/* Hash control flags */
+#define       MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_FLAGS_OFST 4
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_IPV4_EN_LBN 0
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_IPV4_EN_WIDTH 1
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_TCPV4_EN_LBN 1
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_TCPV4_EN_WIDTH 1
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_IPV6_EN_LBN 2
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_IPV6_EN_WIDTH 1
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_TCPV6_EN_LBN 3
+#define        MC_CMD_RSS_CONTEXT_GET_FLAGS_OUT_TOEPLITZ_TCPV6_EN_WIDTH 1
+
+
+/***********************************/
+/* MC_CMD_DOT1P_MAPPING_ALLOC
+ * Allocate a .1p mapping.
+ */
+#define MC_CMD_DOT1P_MAPPING_ALLOC 0xa4
+
+/* MC_CMD_DOT1P_MAPPING_ALLOC_IN msgrequest */
+#define    MC_CMD_DOT1P_MAPPING_ALLOC_IN_LEN 8
+/* The handle of the owning upstream port */
+#define       MC_CMD_DOT1P_MAPPING_ALLOC_IN_UPSTREAM_PORT_ID_OFST 0
+/* Number of queues spanned by this mapping, in the range 1-64; valid fixed
+ * offsets in the mapping table will be in the range 0 to NUM_QUEUES-1, and
+ * referenced RSS contexts must span no more than this number.
+ */
+#define       MC_CMD_DOT1P_MAPPING_ALLOC_IN_NUM_QUEUES_OFST 4
+
+/* MC_CMD_DOT1P_MAPPING_ALLOC_OUT msgresponse */
+#define    MC_CMD_DOT1P_MAPPING_ALLOC_OUT_LEN 4
+/* The handle of the new .1p mapping */
+#define       MC_CMD_DOT1P_MAPPING_ALLOC_OUT_DOT1P_MAPPING_ID_OFST 0
+
+
+/***********************************/
+/* MC_CMD_DOT1P_MAPPING_FREE
+ * Free a .1p mapping.
+ */
+#define MC_CMD_DOT1P_MAPPING_FREE 0xa5
+
+/* MC_CMD_DOT1P_MAPPING_FREE_IN msgrequest */
+#define    MC_CMD_DOT1P_MAPPING_FREE_IN_LEN 4
+/* The handle of the .1p mapping */
+#define       MC_CMD_DOT1P_MAPPING_FREE_IN_DOT1P_MAPPING_ID_OFST 0
+
+/* MC_CMD_DOT1P_MAPPING_FREE_OUT msgresponse */
+#define    MC_CMD_DOT1P_MAPPING_FREE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_DOT1P_MAPPING_SET_TABLE
+ * Set the mapping table for a .1p mapping.
+ */
+#define MC_CMD_DOT1P_MAPPING_SET_TABLE 0xa6
+
+/* MC_CMD_DOT1P_MAPPING_SET_TABLE_IN msgrequest */
+#define    MC_CMD_DOT1P_MAPPING_SET_TABLE_IN_LEN 36
+/* The handle of the .1p mapping */
+#define       MC_CMD_DOT1P_MAPPING_SET_TABLE_IN_DOT1P_MAPPING_ID_OFST 0
+/* Per-priority mappings (1 32-bit word per entry - an offset or RSS context
+ * handle)
+ */
+#define       MC_CMD_DOT1P_MAPPING_SET_TABLE_IN_MAPPING_TABLE_OFST 4
+#define       MC_CMD_DOT1P_MAPPING_SET_TABLE_IN_MAPPING_TABLE_LEN 32
+
+/* MC_CMD_DOT1P_MAPPING_SET_TABLE_OUT msgresponse */
+#define    MC_CMD_DOT1P_MAPPING_SET_TABLE_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_DOT1P_MAPPING_GET_TABLE
+ * Get the mapping table for a .1p mapping.
+ */
+#define MC_CMD_DOT1P_MAPPING_GET_TABLE 0xa7
+
+/* MC_CMD_DOT1P_MAPPING_GET_TABLE_IN msgrequest */
+#define    MC_CMD_DOT1P_MAPPING_GET_TABLE_IN_LEN 4
+/* The handle of the .1p mapping */
+#define       MC_CMD_DOT1P_MAPPING_GET_TABLE_IN_DOT1P_MAPPING_ID_OFST 0
+
+/* MC_CMD_DOT1P_MAPPING_GET_TABLE_OUT msgresponse */
+#define    MC_CMD_DOT1P_MAPPING_GET_TABLE_OUT_LEN 36
+/* Per-priority mappings (1 32-bit word per entry - an offset or RSS context
+ * handle)
+ */
+#define       MC_CMD_DOT1P_MAPPING_GET_TABLE_OUT_MAPPING_TABLE_OFST 4
+#define       MC_CMD_DOT1P_MAPPING_GET_TABLE_OUT_MAPPING_TABLE_LEN 32
+
+
+/***********************************/
+/* MC_CMD_GET_VECTOR_CFG
+ * Get Interrupt Vector config for this PF.
+ */
+#define MC_CMD_GET_VECTOR_CFG 0xbf
+
+/* MC_CMD_GET_VECTOR_CFG_IN msgrequest */
+#define    MC_CMD_GET_VECTOR_CFG_IN_LEN 0
+
+/* MC_CMD_GET_VECTOR_CFG_OUT msgresponse */
+#define    MC_CMD_GET_VECTOR_CFG_OUT_LEN 12
+/* Base absolute interrupt vector number. */
+#define       MC_CMD_GET_VECTOR_CFG_OUT_VEC_BASE_OFST 0
+/* Number of interrupt vectors allocate to this PF. */
+#define       MC_CMD_GET_VECTOR_CFG_OUT_VECS_PER_PF_OFST 4
+/* Number of interrupt vectors to allocate per VF. */
+#define       MC_CMD_GET_VECTOR_CFG_OUT_VECS_PER_VF_OFST 8
+
+
+/***********************************/
+/* MC_CMD_SET_VECTOR_CFG
+ * Set Interrupt Vector config for this PF.
+ */
+#define MC_CMD_SET_VECTOR_CFG 0xc0
+
+/* MC_CMD_SET_VECTOR_CFG_IN msgrequest */
+#define    MC_CMD_SET_VECTOR_CFG_IN_LEN 12
+/* Base absolute interrupt vector number, or MC_CMD_RESOURCE_INSTANCE_ANY to
+ * let the system find a suitable base.
+ */
+#define       MC_CMD_SET_VECTOR_CFG_IN_VEC_BASE_OFST 0
+/* Number of interrupt vectors allocate to this PF. */
+#define       MC_CMD_SET_VECTOR_CFG_IN_VECS_PER_PF_OFST 4
+/* Number of interrupt vectors to allocate per VF. */
+#define       MC_CMD_SET_VECTOR_CFG_IN_VECS_PER_VF_OFST 8
+
+/* MC_CMD_SET_VECTOR_CFG_OUT msgresponse */
+#define    MC_CMD_SET_VECTOR_CFG_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_CLASS_STATS
+ * Retrieve rmon rx class statistics
+ */
+#define MC_CMD_RMON_RX_CLASS_STATS 0xc3
+
+/* MC_CMD_RMON_RX_CLASS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_CLASS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_CLASS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_CLASS_STATS_IN_CLASS_LBN 0
+#define        MC_CMD_RMON_RX_CLASS_STATS_IN_CLASS_WIDTH 8
+#define        MC_CMD_RMON_RX_CLASS_STATS_IN_RST_LBN 8
+#define        MC_CMD_RMON_RX_CLASS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_CLASS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_CLASS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_CLASS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_CLASS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_CLASS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_CLASS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_CLASS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_CLASS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_CLASS_STATS
+ * Retrieve rmon tx class statistics
+ */
+#define MC_CMD_RMON_TX_CLASS_STATS 0xc4
+
+/* MC_CMD_RMON_TX_CLASS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_CLASS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_CLASS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_CLASS_STATS_IN_CLASS_LBN 0
+#define        MC_CMD_RMON_TX_CLASS_STATS_IN_CLASS_WIDTH 8
+#define        MC_CMD_RMON_TX_CLASS_STATS_IN_RST_LBN 8
+#define        MC_CMD_RMON_TX_CLASS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_CLASS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_CLASS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_CLASS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_CLASS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_CLASS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_CLASS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_CLASS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_CLASS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_SUPER_CLASS_STATS
+ * Retrieve rmon rx super_class statistics
+ */
+#define MC_CMD_RMON_RX_SUPER_CLASS_STATS 0xc5
+
+/* MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN_SUPER_CLASS_LBN 0
+#define        MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN_SUPER_CLASS_WIDTH 4
+#define        MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN_RST_LBN 4
+#define        MC_CMD_RMON_RX_SUPER_CLASS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_SUPER_CLASS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_SUPER_CLASS_STATS
+ * Retrieve rmon tx super_class statistics
+ */
+#define MC_CMD_RMON_TX_SUPER_CLASS_STATS 0xc6
+
+/* MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN_SUPER_CLASS_LBN 0
+#define        MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN_SUPER_CLASS_WIDTH 4
+#define        MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN_RST_LBN 4
+#define        MC_CMD_RMON_TX_SUPER_CLASS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_SUPER_CLASS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_ADD_QID_TO_CLASS
+ * Add qid to class for statistics collection
+ */
+#define MC_CMD_RMON_RX_ADD_QID_TO_CLASS 0xc7
+
+/* MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_LEN 12
+/* class */
+#define       MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_CLASS_OFST 0
+/* qid */
+#define       MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_QID_OFST 4
+/* flags */
+#define       MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_FLAGS_OFST 8
+#define        MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_SUPER_CLASS_LBN 0
+#define        MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_SUPER_CLASS_WIDTH 4
+#define        MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_PE_DELTA_LBN 4
+#define        MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_PE_DELTA_WIDTH 4
+#define        MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_MTU_LBN 8
+#define        MC_CMD_RMON_RX_ADD_QID_TO_CLASS_IN_MTU_WIDTH 14
+
+/* MC_CMD_RMON_RX_ADD_QID_TO_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_ADD_QID_TO_CLASS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_ADD_QID_TO_CLASS
+ * Add qid to class for statistics collection
+ */
+#define MC_CMD_RMON_TX_ADD_QID_TO_CLASS 0xc8
+
+/* MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_LEN 12
+/* class */
+#define       MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_CLASS_OFST 0
+/* qid */
+#define       MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_QID_OFST 4
+/* flags */
+#define       MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_FLAGS_OFST 8
+#define        MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_SUPER_CLASS_LBN 0
+#define        MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_SUPER_CLASS_WIDTH 4
+#define        MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_PE_DELTA_LBN 4
+#define        MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_PE_DELTA_WIDTH 4
+#define        MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_MTU_LBN 8
+#define        MC_CMD_RMON_TX_ADD_QID_TO_CLASS_IN_MTU_WIDTH 14
+
+/* MC_CMD_RMON_TX_ADD_QID_TO_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_ADD_QID_TO_CLASS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RMON_MC_ADD_QID_TO_CLASS
+ * Add qid to class for statistics collection
+ */
+#define MC_CMD_RMON_MC_ADD_QID_TO_CLASS 0xc9
+
+/* MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_LEN 12
+/* class */
+#define       MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_CLASS_OFST 0
+/* qid */
+#define       MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_QID_OFST 4
+/* flags */
+#define       MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_FLAGS_OFST 8
+#define        MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_SUPER_CLASS_LBN 0
+#define        MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_SUPER_CLASS_WIDTH 4
+#define        MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_PE_DELTA_LBN 4
+#define        MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_PE_DELTA_WIDTH 4
+#define        MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_MTU_LBN 8
+#define        MC_CMD_RMON_MC_ADD_QID_TO_CLASS_IN_MTU_WIDTH 14
+
+/* MC_CMD_RMON_MC_ADD_QID_TO_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_MC_ADD_QID_TO_CLASS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RMON_ALLOC_CLASS
+ * Allocate an rmon class
+ */
+#define MC_CMD_RMON_ALLOC_CLASS 0xca
+
+/* MC_CMD_RMON_ALLOC_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_ALLOC_CLASS_IN_LEN 0
+
+/* MC_CMD_RMON_ALLOC_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_ALLOC_CLASS_OUT_LEN 4
+/* class */
+#define       MC_CMD_RMON_ALLOC_CLASS_OUT_CLASS_OFST 0
+
+
+/***********************************/
+/* MC_CMD_RMON_DEALLOC_CLASS
+ * Deallocate an rmon class
+ */
+#define MC_CMD_RMON_DEALLOC_CLASS 0xcb
+
+/* MC_CMD_RMON_DEALLOC_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_DEALLOC_CLASS_IN_LEN 4
+/* class */
+#define       MC_CMD_RMON_DEALLOC_CLASS_IN_CLASS_OFST 0
+
+/* MC_CMD_RMON_DEALLOC_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_DEALLOC_CLASS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RMON_ALLOC_SUPER_CLASS
+ * Allocate an rmon super_class
+ */
+#define MC_CMD_RMON_ALLOC_SUPER_CLASS 0xcc
+
+/* MC_CMD_RMON_ALLOC_SUPER_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_ALLOC_SUPER_CLASS_IN_LEN 0
+
+/* MC_CMD_RMON_ALLOC_SUPER_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_ALLOC_SUPER_CLASS_OUT_LEN 4
+/* super_class */
+#define       MC_CMD_RMON_ALLOC_SUPER_CLASS_OUT_SUPER_CLASS_OFST 0
+
+
+/***********************************/
+/* MC_CMD_RMON_DEALLOC_SUPER_CLASS
+ * Deallocate an rmon tx super_class
+ */
+#define MC_CMD_RMON_DEALLOC_SUPER_CLASS 0xcd
+
+/* MC_CMD_RMON_DEALLOC_SUPER_CLASS_IN msgrequest */
+#define    MC_CMD_RMON_DEALLOC_SUPER_CLASS_IN_LEN 4
+/* super_class */
+#define       MC_CMD_RMON_DEALLOC_SUPER_CLASS_IN_SUPER_CLASS_OFST 0
+
+/* MC_CMD_RMON_DEALLOC_SUPER_CLASS_OUT msgresponse */
+#define    MC_CMD_RMON_DEALLOC_SUPER_CLASS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_UP_CONV_STATS
+ * Retrieve up converter statistics
+ */
+#define MC_CMD_RMON_RX_UP_CONV_STATS 0xce
+
+/* MC_CMD_RMON_RX_UP_CONV_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_UP_CONV_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_UP_CONV_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_UP_CONV_STATS_IN_PORT_LBN 0
+#define        MC_CMD_RMON_RX_UP_CONV_STATS_IN_PORT_WIDTH 2
+#define        MC_CMD_RMON_RX_UP_CONV_STATS_IN_RST_LBN 2
+#define        MC_CMD_RMON_RX_UP_CONV_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_UP_CONV_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_UP_CONV_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_UP_CONV_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_UP_CONV_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_UP_CONV_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_UP_CONV_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_UP_CONV_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_UP_CONV_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_IPI_STATS
+ * Retrieve rx ipi stats
+ */
+#define MC_CMD_RMON_RX_IPI_STATS 0xcf
+
+/* MC_CMD_RMON_RX_IPI_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_IPI_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_IPI_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_IPI_STATS_IN_VFIFO_LBN 0
+#define        MC_CMD_RMON_RX_IPI_STATS_IN_VFIFO_WIDTH 5
+#define        MC_CMD_RMON_RX_IPI_STATS_IN_RST_LBN 5
+#define        MC_CMD_RMON_RX_IPI_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_IPI_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_IPI_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_IPI_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_IPI_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_IPI_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_IPI_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_IPI_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_IPI_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS
+ * Retrieve rx ipsec cntxt_ptr indexed stats
+ */
+#define MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS 0xd0
+
+/* MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN_CNTXT_PTR_LBN 0
+#define        MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN_CNTXT_PTR_WIDTH 9
+#define        MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN_RST_LBN 9
+#define        MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_IPSEC_PORT_STATS
+ * Retrieve rx ipsec port indexed stats
+ */
+#define MC_CMD_RMON_RX_IPSEC_PORT_STATS 0xd1
+
+/* MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN_PORT_LBN 0
+#define        MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN_PORT_WIDTH 2
+#define        MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN_RST_LBN 2
+#define        MC_CMD_RMON_RX_IPSEC_PORT_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_IPSEC_PORT_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_IPSEC_OFLOW_STATS
+ * Retrieve tx ipsec overflow
+ */
+#define MC_CMD_RMON_RX_IPSEC_OFLOW_STATS 0xd2
+
+/* MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN_PORT_LBN 0
+#define        MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN_PORT_WIDTH 2
+#define        MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN_RST_LBN 2
+#define        MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_IPSEC_OFLOW_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_VPORT_ADD_MAC_ADDRESS
+ * Add a MAC address to a v-port
+ */
+#define MC_CMD_VPORT_ADD_MAC_ADDRESS 0xa8
+
+/* MC_CMD_VPORT_ADD_MAC_ADDRESS_IN msgrequest */
+#define    MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_LEN 10
+/* The handle of the v-port */
+#define       MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_VPORT_ID_OFST 0
+/* MAC address to add */
+#define       MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_MACADDR_OFST 4
+#define       MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_MACADDR_LEN 6
+
+/* MC_CMD_VPORT_ADD_MAC_ADDRESS_OUT msgresponse */
+#define    MC_CMD_VPORT_ADD_MAC_ADDRESS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VPORT_DEL_MAC_ADDRESS
+ * Delete a MAC address from a v-port
+ */
+#define MC_CMD_VPORT_DEL_MAC_ADDRESS 0xa9
+
+/* MC_CMD_VPORT_DEL_MAC_ADDRESS_IN msgrequest */
+#define    MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN 10
+/* The handle of the v-port */
+#define       MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID_OFST 0
+/* MAC address to add */
+#define       MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_MACADDR_OFST 4
+#define       MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_MACADDR_LEN 6
+
+/* MC_CMD_VPORT_DEL_MAC_ADDRESS_OUT msgresponse */
+#define    MC_CMD_VPORT_DEL_MAC_ADDRESS_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_VPORT_GET_MAC_ADDRESSES
+ * Delete a MAC address from a v-port
+ */
+#define MC_CMD_VPORT_GET_MAC_ADDRESSES 0xaa
+
+/* MC_CMD_VPORT_GET_MAC_ADDRESSES_IN msgrequest */
+#define    MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_LEN 4
+/* The handle of the v-port */
+#define       MC_CMD_VPORT_GET_MAC_ADDRESSES_IN_VPORT_ID_OFST 0
+
+/* MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT msgresponse */
+#define    MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMIN 4
+#define    MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LENMAX 250
+#define    MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_LEN(num) (4+6*(num))
+/* The number of MAC addresses returned */
+#define       MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_COUNT_OFST 0
+/* Array of MAC addresses */
+#define       MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_OFST 4
+#define       MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_LEN 6
+#define       MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_MINNUM 0
+#define       MC_CMD_VPORT_GET_MAC_ADDRESSES_OUT_MACADDR_MAXNUM 41
+
+
+/***********************************/
+/* MC_CMD_DUMP_BUFTBL_ENTRIES
+ * Dump buffer table entries, mainly for command client debug use. Dumps
+ * absolute entries, and does not use chunk handles. All entries must be in
+ * range, and used for q page mapping, Although the latter restriction may be
+ * lifted in future.
+ */
+#define MC_CMD_DUMP_BUFTBL_ENTRIES 0xab
+
+/* MC_CMD_DUMP_BUFTBL_ENTRIES_IN msgrequest */
+#define    MC_CMD_DUMP_BUFTBL_ENTRIES_IN_LEN 8
+/* Index of the first buffer table entry. */
+#define       MC_CMD_DUMP_BUFTBL_ENTRIES_IN_FIRSTID_OFST 0
+/* Number of buffer table entries to dump. */
+#define       MC_CMD_DUMP_BUFTBL_ENTRIES_IN_NUMENTRIES_OFST 4
+
+/* MC_CMD_DUMP_BUFTBL_ENTRIES_OUT msgresponse */
+#define    MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_LENMIN 12
+#define    MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_LENMAX 252
+#define    MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_LEN(num) (0+12*(num))
+/* Raw buffer table entries, layed out as BUFTBL_ENTRY. */
+#define       MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_ENTRY_OFST 0
+#define       MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_ENTRY_LEN 12
+#define       MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_ENTRY_MINNUM 1
+#define       MC_CMD_DUMP_BUFTBL_ENTRIES_OUT_ENTRY_MAXNUM 21
+
+
+/***********************************/
+/* MC_CMD_SET_RXDP_CONFIG
+ * Set global RXDP configuration settings
+ */
+#define MC_CMD_SET_RXDP_CONFIG 0xc1
+
+/* MC_CMD_SET_RXDP_CONFIG_IN msgrequest */
+#define    MC_CMD_SET_RXDP_CONFIG_IN_LEN 4
+#define       MC_CMD_SET_RXDP_CONFIG_IN_DATA_OFST 0
+#define        MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_DMA_LBN 0
+#define        MC_CMD_SET_RXDP_CONFIG_IN_PAD_HOST_DMA_WIDTH 1
+
+/* MC_CMD_SET_RXDP_CONFIG_OUT msgresponse */
+#define    MC_CMD_SET_RXDP_CONFIG_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_RXDP_CONFIG
+ * Get global RXDP configuration settings
+ */
+#define MC_CMD_GET_RXDP_CONFIG 0xc2
+
+/* MC_CMD_GET_RXDP_CONFIG_IN msgrequest */
+#define    MC_CMD_GET_RXDP_CONFIG_IN_LEN 0
+
+/* MC_CMD_GET_RXDP_CONFIG_OUT msgresponse */
+#define    MC_CMD_GET_RXDP_CONFIG_OUT_LEN 4
+#define       MC_CMD_GET_RXDP_CONFIG_OUT_DATA_OFST 0
+#define        MC_CMD_GET_RXDP_CONFIG_OUT_PAD_HOST_DMA_LBN 0
+#define        MC_CMD_GET_RXDP_CONFIG_OUT_PAD_HOST_DMA_WIDTH 1
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_CLASS_DROPS_STATS
+ * Retrieve rx class drop stats
+ */
+#define MC_CMD_RMON_RX_CLASS_DROPS_STATS 0xd3
+
+/* MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN_CLASS_LBN 0
+#define        MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN_CLASS_WIDTH 8
+#define        MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN_RST_LBN 8
+#define        MC_CMD_RMON_RX_CLASS_DROPS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_CLASS_DROPS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS
+ * Retrieve rx super class drop stats
+ */
+#define MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS 0xd4
+
+/* MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN_SUPER_CLASS_LBN 0
+#define        MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN_SUPER_CLASS_WIDTH 4
+#define        MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN_RST_LBN 4
+#define        MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_SUPER_CLASS_DROPS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_ERRORS_STATS
+ * Retrieve rxdp errors
+ */
+#define MC_CMD_RMON_RX_ERRORS_STATS 0xd5
+
+/* MC_CMD_RMON_RX_ERRORS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_ERRORS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_ERRORS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_ERRORS_STATS_IN_QID_LBN 0
+#define        MC_CMD_RMON_RX_ERRORS_STATS_IN_QID_WIDTH 11
+#define        MC_CMD_RMON_RX_ERRORS_STATS_IN_RST_LBN 11
+#define        MC_CMD_RMON_RX_ERRORS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_ERRORS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_ERRORS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_ERRORS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_ERRORS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_ERRORS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_ERRORS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_ERRORS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_ERRORS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_RX_OVERFLOW_STATS
+ * Retrieve rxdp overflow
+ */
+#define MC_CMD_RMON_RX_OVERFLOW_STATS 0xd6
+
+/* MC_CMD_RMON_RX_OVERFLOW_STATS_IN msgrequest */
+#define    MC_CMD_RMON_RX_OVERFLOW_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_RX_OVERFLOW_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_RX_OVERFLOW_STATS_IN_CLASS_LBN 0
+#define        MC_CMD_RMON_RX_OVERFLOW_STATS_IN_CLASS_WIDTH 8
+#define        MC_CMD_RMON_RX_OVERFLOW_STATS_IN_RST_LBN 8
+#define        MC_CMD_RMON_RX_OVERFLOW_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_RX_OVERFLOW_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_RX_OVERFLOW_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_IPI_STATS
+ * Retrieve tx ipi stats
+ */
+#define MC_CMD_RMON_TX_IPI_STATS 0xd7
+
+/* MC_CMD_RMON_TX_IPI_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_IPI_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_IPI_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_IPI_STATS_IN_VFIFO_LBN 0
+#define        MC_CMD_RMON_TX_IPI_STATS_IN_VFIFO_WIDTH 5
+#define        MC_CMD_RMON_TX_IPI_STATS_IN_RST_LBN 5
+#define        MC_CMD_RMON_TX_IPI_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_IPI_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_IPI_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_IPI_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_IPI_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_IPI_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_IPI_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_IPI_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_IPI_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS
+ * Retrieve tx ipsec counters by cntxt_ptr
+ */
+#define MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS 0xd8
+
+/* MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN_CNTXT_PTR_LBN 0
+#define        MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN_CNTXT_PTR_WIDTH 9
+#define        MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN_RST_LBN 9
+#define        MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_IPSEC_CNTXT_PTR_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_IPSEC_PORT_STATS
+ * Retrieve tx ipsec counters by port
+ */
+#define MC_CMD_RMON_TX_IPSEC_PORT_STATS 0xd9
+
+/* MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN_PORT_LBN 0
+#define        MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN_PORT_WIDTH 2
+#define        MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN_RST_LBN 2
+#define        MC_CMD_RMON_TX_IPSEC_PORT_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_IPSEC_PORT_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_IPSEC_OFLOW_STATS
+ * Retrieve tx ipsec overflow
+ */
+#define MC_CMD_RMON_TX_IPSEC_OFLOW_STATS 0xda
+
+/* MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN_PORT_LBN 0
+#define        MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN_PORT_WIDTH 2
+#define        MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN_RST_LBN 2
+#define        MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_IPSEC_OFLOW_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_NOWHERE_STATS
+ * Retrieve tx nowhere stats
+ */
+#define MC_CMD_RMON_TX_NOWHERE_STATS 0xdb
+
+/* MC_CMD_RMON_TX_NOWHERE_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_NOWHERE_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_NOWHERE_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_NOWHERE_STATS_IN_CLASS_LBN 0
+#define        MC_CMD_RMON_TX_NOWHERE_STATS_IN_CLASS_WIDTH 8
+#define        MC_CMD_RMON_TX_NOWHERE_STATS_IN_RST_LBN 8
+#define        MC_CMD_RMON_TX_NOWHERE_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_NOWHERE_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_NOWHERE_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_NOWHERE_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_NOWHERE_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_NOWHERE_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_NOWHERE_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_NOWHERE_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_NOWHERE_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_NOWHERE_QBB_STATS
+ * Retrieve tx nowhere qbb stats
+ */
+#define MC_CMD_RMON_TX_NOWHERE_QBB_STATS 0xdc
+
+/* MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN_PRIORITY_LBN 0
+#define        MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN_PRIORITY_WIDTH 3
+#define        MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN_RST_LBN 3
+#define        MC_CMD_RMON_TX_NOWHERE_QBB_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_NOWHERE_QBB_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_ERRORS_STATS
+ * Retrieve rxdp errors
+ */
+#define MC_CMD_RMON_TX_ERRORS_STATS 0xdd
+
+/* MC_CMD_RMON_TX_ERRORS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_ERRORS_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_ERRORS_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_ERRORS_STATS_IN_QID_LBN 0
+#define        MC_CMD_RMON_TX_ERRORS_STATS_IN_QID_WIDTH 11
+#define        MC_CMD_RMON_TX_ERRORS_STATS_IN_RST_LBN 11
+#define        MC_CMD_RMON_TX_ERRORS_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_ERRORS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_ERRORS_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_ERRORS_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_ERRORS_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_ERRORS_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_ERRORS_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_ERRORS_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_ERRORS_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_TX_OVERFLOW_STATS
+ * Retrieve rxdp overflow
+ */
+#define MC_CMD_RMON_TX_OVERFLOW_STATS 0xde
+
+/* MC_CMD_RMON_TX_OVERFLOW_STATS_IN msgrequest */
+#define    MC_CMD_RMON_TX_OVERFLOW_STATS_IN_LEN 4
+/* flags */
+#define       MC_CMD_RMON_TX_OVERFLOW_STATS_IN_FLAGS_OFST 0
+#define        MC_CMD_RMON_TX_OVERFLOW_STATS_IN_CLASS_LBN 0
+#define        MC_CMD_RMON_TX_OVERFLOW_STATS_IN_CLASS_WIDTH 8
+#define        MC_CMD_RMON_TX_OVERFLOW_STATS_IN_RST_LBN 8
+#define        MC_CMD_RMON_TX_OVERFLOW_STATS_IN_RST_WIDTH 1
+
+/* MC_CMD_RMON_TX_OVERFLOW_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_LENMIN 4
+#define    MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_LENMAX 252
+#define    MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_LEN(num) (0+4*(num))
+/* Array of stats */
+#define       MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_BUFFER_OFST 0
+#define       MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_BUFFER_LEN 4
+#define       MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_BUFFER_MINNUM 1
+#define       MC_CMD_RMON_TX_OVERFLOW_STATS_OUT_BUFFER_MAXNUM 63
+
+
+/***********************************/
+/* MC_CMD_RMON_COLLECT_CLASS_STATS
+ * Explicitly collect class stats at the specified evb port
+ */
+#define MC_CMD_RMON_COLLECT_CLASS_STATS 0xdf
+
+/* MC_CMD_RMON_COLLECT_CLASS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_COLLECT_CLASS_STATS_IN_LEN 4
+/* The port id associated with the vport/pport at which to collect class stats
+ */
+#define       MC_CMD_RMON_COLLECT_CLASS_STATS_IN_PORT_ID_OFST 0
+
+/* MC_CMD_RMON_COLLECT_CLASS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_COLLECT_CLASS_STATS_OUT_LEN 4
+/* class */
+#define       MC_CMD_RMON_COLLECT_CLASS_STATS_OUT_CLASS_OFST 0
+
+
+/***********************************/
+/* MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS
+ * Explicitly collect class stats at the specified evb port
+ */
+#define MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS 0xe0
+
+/* MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS_IN msgrequest */
+#define    MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS_IN_LEN 4
+/* The port id associated with the vport/pport at which to collect class stats
+ */
+#define       MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS_IN_PORT_ID_OFST 0
+
+/* MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS_OUT msgresponse */
+#define    MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS_OUT_LEN 4
+/* super_class */
+#define       MC_CMD_RMON_COLLECT_SUPER_CLASS_STATS_OUT_SUPER_CLASS_OFST 0
+
+
+/***********************************/
+/* MC_CMD_GET_CLOCK
+ * Return the system and PDCPU clock frequencies.
+ */
+#define MC_CMD_GET_CLOCK 0xac
+
+/* MC_CMD_GET_CLOCK_IN msgrequest */
+#define    MC_CMD_GET_CLOCK_IN_LEN 0
+
+/* MC_CMD_GET_CLOCK_OUT msgresponse */
+#define    MC_CMD_GET_CLOCK_OUT_LEN 8
+/* System frequency, MHz */
+#define       MC_CMD_GET_CLOCK_OUT_SYS_FREQ_OFST 0
+/* DPCPU frequency, MHz */
+#define       MC_CMD_GET_CLOCK_OUT_DPCPU_FREQ_OFST 4
+
+
+/***********************************/
+/* MC_CMD_SET_CLOCK
+ * Control the system and DPCPU clock frequencies. Changes are lost reboot.
+ */
+#define MC_CMD_SET_CLOCK 0xad
+
+/* MC_CMD_SET_CLOCK_IN msgrequest */
+#define    MC_CMD_SET_CLOCK_IN_LEN 12
+/* Requested system frequency in MHz; 0 leaves unchanged. */
+#define       MC_CMD_SET_CLOCK_IN_SYS_FREQ_OFST 0
+/* Requested inter-core frequency in MHz; 0 leaves unchanged. */
+#define       MC_CMD_SET_CLOCK_IN_ICORE_FREQ_OFST 4
+/* Request DPCPU frequency in MHz; 0 leaves unchanged. */
+#define       MC_CMD_SET_CLOCK_IN_DPCPU_FREQ_OFST 8
+
+/* MC_CMD_SET_CLOCK_OUT msgresponse */
+#define    MC_CMD_SET_CLOCK_OUT_LEN 12
+/* Resulting system frequency in MHz */
+#define       MC_CMD_SET_CLOCK_OUT_SYS_FREQ_OFST 0
+/* Resulting inter-core frequency in MHz */
+#define       MC_CMD_SET_CLOCK_OUT_ICORE_FREQ_OFST 4
+/* Resulting DPCPU frequency in MHz */
+#define       MC_CMD_SET_CLOCK_OUT_DPCPU_FREQ_OFST 8
+
+
+/***********************************/
+/* MC_CMD_DPCPU_RPC
+ * Send an arbitrary DPCPU message.
+ */
+#define MC_CMD_DPCPU_RPC 0xae
+
+/* MC_CMD_DPCPU_RPC_IN msgrequest */
+#define    MC_CMD_DPCPU_RPC_IN_LEN 36
+#define       MC_CMD_DPCPU_RPC_IN_CPU_OFST 0
+/* enum: RxDPCPU */
+#define          MC_CMD_DPCPU_RPC_IN_DPCPU_RX   0x0
+/* enum: TxDPCPU0 */
+#define          MC_CMD_DPCPU_RPC_IN_DPCPU_TX0  0x1
+/* enum: TxDPCPU1 */
+#define          MC_CMD_DPCPU_RPC_IN_DPCPU_TX1  0x2
+/* First 8 bits [39:32] of DATA are consumed by MC-DPCPU protocol and must be
+ * initialised to zero
+ */
+#define       MC_CMD_DPCPU_RPC_IN_DATA_OFST 4
+#define       MC_CMD_DPCPU_RPC_IN_DATA_LEN 32
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_CMDNUM_LBN 8
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_CMDNUM_WIDTH 8
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_TXDPCPU_READ  0x6 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_TXDPCPU_WRITE  0x7 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_TXDPCPU_SELF_TEST  0xc /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_TXDPCPU_CSR_ACCESS  0xe /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_RXDPCPU_READ  0x46 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_RXDPCPU_WRITE  0x47 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_RXDPCPU_SELF_TEST  0x4a /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_RXDPCPU_CSR_ACCESS  0x4c /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CMDNUM_RXDPCPU_SET_MC_REPLAY_CNTXT  0x4d /* enum */
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_REQ_OBJID_LBN 16
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_REQ_OBJID_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_REQ_ADDR_LBN 16
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_REQ_ADDR_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_REQ_COUNT_LBN 48
+#define        MC_CMD_DPCPU_RPC_IN_HDR_CMD_REQ_COUNT_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_INFO_LBN 16
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_INFO_WIDTH 240
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_LBN 16
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_WIDTH 16
+#define          MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_STOP_RETURN_RESULT  0x0 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_START_READ  0x1 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_START_WRITE  0x2 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_START_WRITE_READ  0x3 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_CMD_START_PIPELINED_READ  0x4 /* enum */
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_START_DELAY_LBN 48
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_START_DELAY_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_RPT_COUNT_LBN 64
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_RPT_COUNT_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_GAP_DELAY_LBN 80
+#define        MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_GAP_DELAY_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_IN_MC_REPLAY_MODE_LBN 16
+#define        MC_CMD_DPCPU_RPC_IN_MC_REPLAY_MODE_WIDTH 16
+#define          MC_CMD_DPCPU_RPC_IN_MC_REPLAY_MODE_CUT_THROUGH  0x1 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_MC_REPLAY_MODE_STORE_FORWARD  0x2 /* enum */
+#define          MC_CMD_DPCPU_RPC_IN_MC_REPLAY_MODE_STORE_FORWARD_FIRST  0x3 /* enum */
+#define        MC_CMD_DPCPU_RPC_IN_MC_REPLAY_CNTXT_LBN 64
+#define        MC_CMD_DPCPU_RPC_IN_MC_REPLAY_CNTXT_WIDTH 16
+#define       MC_CMD_DPCPU_RPC_IN_WDATA_OFST 12
+#define       MC_CMD_DPCPU_RPC_IN_WDATA_LEN 24
+/* Register data to write. Only valid in write/write-read. */
+#define       MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_DATA_OFST 16
+/* Register address. */
+#define       MC_CMD_DPCPU_RPC_IN_CSR_ACCESS_ADDRESS_OFST 20
+
+/* MC_CMD_DPCPU_RPC_OUT msgresponse */
+#define    MC_CMD_DPCPU_RPC_OUT_LEN 36
+#define       MC_CMD_DPCPU_RPC_OUT_RC_OFST 0
+/* DATA */
+#define       MC_CMD_DPCPU_RPC_OUT_DATA_OFST 4
+#define       MC_CMD_DPCPU_RPC_OUT_DATA_LEN 32
+#define        MC_CMD_DPCPU_RPC_OUT_HDR_CMD_RESP_ERRCODE_LBN 32
+#define        MC_CMD_DPCPU_RPC_OUT_HDR_CMD_RESP_ERRCODE_WIDTH 16
+#define        MC_CMD_DPCPU_RPC_OUT_CSR_ACCESS_READ_COUNT_LBN 48
+#define        MC_CMD_DPCPU_RPC_OUT_CSR_ACCESS_READ_COUNT_WIDTH 16
+#define       MC_CMD_DPCPU_RPC_OUT_RDATA_OFST 12
+#define       MC_CMD_DPCPU_RPC_OUT_RDATA_LEN 24
+#define       MC_CMD_DPCPU_RPC_OUT_CSR_ACCESS_READ_VAL_1_OFST 12
+#define       MC_CMD_DPCPU_RPC_OUT_CSR_ACCESS_READ_VAL_2_OFST 16
+#define       MC_CMD_DPCPU_RPC_OUT_CSR_ACCESS_READ_VAL_3_OFST 20
+#define       MC_CMD_DPCPU_RPC_OUT_CSR_ACCESS_READ_VAL_4_OFST 24
+
+
+/***********************************/
+/* MC_CMD_TRIGGER_INTERRUPT
+ * Trigger an interrupt by prodding the BIU.
+ */
+#define MC_CMD_TRIGGER_INTERRUPT 0xe3
+
+/* MC_CMD_TRIGGER_INTERRUPT_IN msgrequest */
+#define    MC_CMD_TRIGGER_INTERRUPT_IN_LEN 4
+/* Interrupt level relative to base for function. */
+#define       MC_CMD_TRIGGER_INTERRUPT_IN_INTR_LEVEL_OFST 0
+
+/* MC_CMD_TRIGGER_INTERRUPT_OUT msgresponse */
+#define    MC_CMD_TRIGGER_INTERRUPT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_DUMP_DO
+ * Take a dump of the DUT state
+ */
+#define MC_CMD_DUMP_DO 0xe8
+
+/* MC_CMD_DUMP_DO_IN msgrequest */
+#define    MC_CMD_DUMP_DO_IN_LEN 52
+#define       MC_CMD_DUMP_DO_IN_PADDING_OFST 0
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_OFST 4
+#define          MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM  0x0 /* enum */
+#define          MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_DEFAULT  0x1 /* enum */
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_TYPE_OFST 8
+#define          MC_CMD_DUMP_DO_IN_DUMP_LOCATION_NVRAM  0x1 /* enum */
+#define          MC_CMD_DUMP_DO_IN_DUMP_LOCATION_HOST_MEMORY  0x2 /* enum */
+#define          MC_CMD_DUMP_DO_IN_DUMP_LOCATION_HOST_MEMORY_MLI  0x3 /* enum */
+#define          MC_CMD_DUMP_DO_IN_DUMP_LOCATION_UART  0x4 /* enum */
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_NVRAM_PARTITION_TYPE_ID_OFST 12
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_NVRAM_OFFSET_OFST 16
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_ADDR_LO_OFST 12
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_ADDR_HI_OFST 16
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_LO_OFST 12
+#define          MC_CMD_DUMP_DO_IN_HOST_MEMORY_MLI_PAGE_SIZE  0x1000 /* enum */
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_HI_OFST 16
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_MLI_DEPTH_OFST 20
+#define          MC_CMD_DUMP_DO_IN_HOST_MEMORY_MLI_MAX_DEPTH  0x2 /* enum */
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_UART_PORT_OFST 12
+#define       MC_CMD_DUMP_DO_IN_DUMPSPEC_SRC_CUSTOM_SIZE_OFST 24
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_OFST 28
+#define          MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM  0x0 /* enum */
+#define          MC_CMD_DUMP_DO_IN_DUMPFILE_DST_NVRAM_DUMP_PARTITION  0x1 /* enum */
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_TYPE_OFST 32
+/*            Enum values, see field(s): */
+/*               MC_CMD_DUMP_DO_IN/DUMPSPEC_SRC_CUSTOM_TYPE */
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_NVRAM_PARTITION_TYPE_ID_OFST 36
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_NVRAM_OFFSET_OFST 40
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_ADDR_LO_OFST 36
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_ADDR_HI_OFST 40
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_LO_OFST 36
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_HI_OFST 40
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_MLI_DEPTH_OFST 44
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_UART_PORT_OFST 36
+#define       MC_CMD_DUMP_DO_IN_DUMPFILE_DST_CUSTOM_SIZE_OFST 48
+
+/* MC_CMD_DUMP_DO_OUT msgresponse */
+#define    MC_CMD_DUMP_DO_OUT_LEN 4
+#define       MC_CMD_DUMP_DO_OUT_DUMPFILE_SIZE_OFST 0
+
+
+/***********************************/
+/* MC_CMD_DUMP_CONFIGURE_UNSOLICITED
+ * Configure unsolicited dumps
+ */
+#define MC_CMD_DUMP_CONFIGURE_UNSOLICITED 0xe9
+
+/* MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN msgrequest */
+#define    MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_LEN 52
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_ENABLE_OFST 0
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_OFST 4
+/*            Enum values, see field(s): */
+/*               MC_CMD_DUMP_DO/MC_CMD_DUMP_DO_IN/DUMPSPEC_SRC */
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_TYPE_OFST 8
+/*            Enum values, see field(s): */
+/*               MC_CMD_DUMP_DO/MC_CMD_DUMP_DO_IN/DUMPSPEC_SRC_CUSTOM_TYPE */
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_NVRAM_PARTITION_TYPE_ID_OFST 12
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_NVRAM_OFFSET_OFST 16
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_ADDR_LO_OFST 12
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_ADDR_HI_OFST 16
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_LO_OFST 12
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_HI_OFST 16
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_HOST_MEMORY_MLI_DEPTH_OFST 20
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_UART_PORT_OFST 12
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPSPEC_SRC_CUSTOM_SIZE_OFST 24
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_OFST 28
+/*            Enum values, see field(s): */
+/*               MC_CMD_DUMP_DO/MC_CMD_DUMP_DO_IN/DUMPFILE_DST */
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_TYPE_OFST 32
+/*            Enum values, see field(s): */
+/*               MC_CMD_DUMP_DO/MC_CMD_DUMP_DO_IN/DUMPSPEC_SRC_CUSTOM_TYPE */
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_NVRAM_PARTITION_TYPE_ID_OFST 36
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_NVRAM_OFFSET_OFST 40
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_ADDR_LO_OFST 36
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_ADDR_HI_OFST 40
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_LO_OFST 36
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_MLI_ROOT_ADDR_HI_OFST 40
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_HOST_MEMORY_MLI_DEPTH_OFST 44
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_UART_PORT_OFST 36
+#define       MC_CMD_DUMP_CONFIGURE_UNSOLICITED_IN_DUMPFILE_DST_CUSTOM_SIZE_OFST 48
+
+
+/***********************************/
+/* MC_CMD_SET_PSU
+ * Adjusts power supply parameters. This is a warranty-voiding operation.
+ * Returns: ENOENT if the parameter or rail specified does not exist, EINVAL if
+ * the parameter is out of range.
+ */
+#define MC_CMD_SET_PSU 0xea
+
+/* MC_CMD_SET_PSU_IN msgrequest */
+#define    MC_CMD_SET_PSU_IN_LEN 12
+#define       MC_CMD_SET_PSU_IN_PARAM_OFST 0
+#define          MC_CMD_SET_PSU_IN_PARAM_SUPPLY_VOLTAGE  0x0 /* enum */
+#define       MC_CMD_SET_PSU_IN_RAIL_OFST 4
+#define          MC_CMD_SET_PSU_IN_RAIL_0V9  0x0 /* enum */
+#define          MC_CMD_SET_PSU_IN_RAIL_1V2  0x1 /* enum */
+/* desired value, eg voltage in mV */
+#define       MC_CMD_SET_PSU_IN_VALUE_OFST 8
+
+/* MC_CMD_SET_PSU_OUT msgresponse */
+#define    MC_CMD_SET_PSU_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_GET_FUNCTION_INFO
+ * Get function information. PF and VF number.
+ */
+#define MC_CMD_GET_FUNCTION_INFO 0xec
+
+/* MC_CMD_GET_FUNCTION_INFO_IN msgrequest */
+#define    MC_CMD_GET_FUNCTION_INFO_IN_LEN 0
+
+/* MC_CMD_GET_FUNCTION_INFO_OUT msgresponse */
+#define    MC_CMD_GET_FUNCTION_INFO_OUT_LEN 8
+#define       MC_CMD_GET_FUNCTION_INFO_OUT_PF_OFST 0
+#define       MC_CMD_GET_FUNCTION_INFO_OUT_VF_OFST 4
+
+
+/***********************************/
+/* MC_CMD_ENABLE_OFFLINE_BIST
+ * Enters offline BIST mode. All queues are torn down, chip enters quiescent
+ * mode, calling function gets exclusive MCDI ownership. The only way out is
+ * reboot.
+ */
+#define MC_CMD_ENABLE_OFFLINE_BIST 0xed
+
+/* MC_CMD_ENABLE_OFFLINE_BIST_IN msgrequest */
+#define    MC_CMD_ENABLE_OFFLINE_BIST_IN_LEN 0
+
+/* MC_CMD_ENABLE_OFFLINE_BIST_OUT msgresponse */
+#define    MC_CMD_ENABLE_OFFLINE_BIST_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_START_KR_EYE_PLOT
+ * Start KR Serdes Eye diagram plot on a given lane. Lane must have valid
+ * signal.
+ */
+#define MC_CMD_START_KR_EYE_PLOT 0xee
+
+/* MC_CMD_START_KR_EYE_PLOT_IN msgrequest */
+#define    MC_CMD_START_KR_EYE_PLOT_IN_LEN 4
+#define       MC_CMD_START_KR_EYE_PLOT_IN_LANE_OFST 0
+
+/* MC_CMD_START_KR_EYE_PLOT_OUT msgresponse */
+#define    MC_CMD_START_KR_EYE_PLOT_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_POLL_KR_EYE_PLOT
+ * Poll KR Serdes Eye diagram plot. Returns one row of BER data. The caller
+ * should call this command repeatedly after starting eye plot, until no more
+ * data is returned.
+ */
+#define MC_CMD_POLL_KR_EYE_PLOT 0xef
+
+/* MC_CMD_POLL_KR_EYE_PLOT_IN msgrequest */
+#define    MC_CMD_POLL_KR_EYE_PLOT_IN_LEN 0
+
+/* MC_CMD_POLL_KR_EYE_PLOT_OUT msgresponse */
+#define    MC_CMD_POLL_KR_EYE_PLOT_OUT_LENMIN 0
+#define    MC_CMD_POLL_KR_EYE_PLOT_OUT_LENMAX 252
+#define    MC_CMD_POLL_KR_EYE_PLOT_OUT_LEN(num) (0+2*(num))
+#define       MC_CMD_POLL_KR_EYE_PLOT_OUT_SAMPLES_OFST 0
+#define       MC_CMD_POLL_KR_EYE_PLOT_OUT_SAMPLES_LEN 2
+#define       MC_CMD_POLL_KR_EYE_PLOT_OUT_SAMPLES_MINNUM 0
+#define       MC_CMD_POLL_KR_EYE_PLOT_OUT_SAMPLES_MAXNUM 126
+
+
+/***********************************/
+/* MC_CMD_READ_FUSES
+ * Read data programmed into the device One-Time-Programmable (OTP) Fuses
+ */
+#define MC_CMD_READ_FUSES 0xf0
+
+/* MC_CMD_READ_FUSES_IN msgrequest */
+#define    MC_CMD_READ_FUSES_IN_LEN 8
+/* Offset in OTP to read */
+#define       MC_CMD_READ_FUSES_IN_OFFSET_OFST 0
+/* Length of data to read in bytes */
+#define       MC_CMD_READ_FUSES_IN_LENGTH_OFST 4
+
+/* MC_CMD_READ_FUSES_OUT msgresponse */
+#define    MC_CMD_READ_FUSES_OUT_LENMIN 4
+#define    MC_CMD_READ_FUSES_OUT_LENMAX 252
+#define    MC_CMD_READ_FUSES_OUT_LEN(num) (4+1*(num))
+/* Length of returned OTP data in bytes */
+#define       MC_CMD_READ_FUSES_OUT_LENGTH_OFST 0
+/* Returned data */
+#define       MC_CMD_READ_FUSES_OUT_DATA_OFST 4
+#define       MC_CMD_READ_FUSES_OUT_DATA_LEN 1
+#define       MC_CMD_READ_FUSES_OUT_DATA_MINNUM 0
+#define       MC_CMD_READ_FUSES_OUT_DATA_MAXNUM 248
+
+
+/***********************************/
+/* MC_CMD_KR_TUNE
+ * Get or set KR Serdes RXEQ and TX Driver settings
+ */
+#define MC_CMD_KR_TUNE 0xf1
+
+/* MC_CMD_KR_TUNE_IN msgrequest */
+#define    MC_CMD_KR_TUNE_IN_LENMIN 4
+#define    MC_CMD_KR_TUNE_IN_LENMAX 252
+#define    MC_CMD_KR_TUNE_IN_LEN(num) (4+4*(num))
+/* Requested operation */
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_OP_OFST 0
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_OP_LEN 1
+/* enum: Get current RXEQ settings */
+#define          MC_CMD_KR_TUNE_IN_RXEQ_GET  0x0
+/* enum: Override RXEQ settings */
+#define          MC_CMD_KR_TUNE_IN_RXEQ_SET  0x1
+/* enum: Get current TX Driver settings */
+#define          MC_CMD_KR_TUNE_IN_TXEQ_GET  0x2
+/* enum: Override TX Driver settings */
+#define          MC_CMD_KR_TUNE_IN_TXEQ_SET  0x3
+/* enum: Force KR Serdes reset / recalibration */
+#define          MC_CMD_KR_TUNE_IN_RECAL  0x4
+/* Align the arguments to 32 bits */
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_RSVD_OFST 1
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_RSVD_LEN 3
+/* Arguments specific to the operation */
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_ARGS_OFST 4
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_ARGS_LEN 4
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_ARGS_MINNUM 0
+#define       MC_CMD_KR_TUNE_IN_KR_TUNE_ARGS_MAXNUM 62
+
+/* MC_CMD_KR_TUNE_OUT msgresponse */
+#define    MC_CMD_KR_TUNE_OUT_LEN 0
+
+/* MC_CMD_KR_TUNE_RXEQ_GET_IN msgrequest */
+#define    MC_CMD_KR_TUNE_RXEQ_GET_IN_LEN 4
+/* Requested operation */
+#define       MC_CMD_KR_TUNE_RXEQ_GET_IN_KR_TUNE_OP_OFST 0
+#define       MC_CMD_KR_TUNE_RXEQ_GET_IN_KR_TUNE_OP_LEN 1
+/* Align the arguments to 32 bits */
+#define       MC_CMD_KR_TUNE_RXEQ_GET_IN_KR_TUNE_RSVD_OFST 1
+#define       MC_CMD_KR_TUNE_RXEQ_GET_IN_KR_TUNE_RSVD_LEN 3
+
+/* MC_CMD_KR_TUNE_RXEQ_GET_OUT msgresponse */
+#define    MC_CMD_KR_TUNE_RXEQ_GET_OUT_LENMIN 4
+#define    MC_CMD_KR_TUNE_RXEQ_GET_OUT_LENMAX 252
+#define    MC_CMD_KR_TUNE_RXEQ_GET_OUT_LEN(num) (0+4*(num))
+/* RXEQ Parameter */
+#define       MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_OFST 0
+#define       MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_LEN 4
+#define       MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_MINNUM 1
+#define       MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_MAXNUM 63
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_ID_LBN 0
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_ID_WIDTH 8
+/* enum: Attenuation (0-15) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_ATT  0x0
+/* enum: CTLE Boost (0-15) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_BOOST  0x1
+/* enum: Edge DFE Tap1 (0 - max negative, 64 - zero, 127 - max positive) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP1  0x2
+/* enum: Edge DFE Tap2 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP2  0x3
+/* enum: Edge DFE Tap3 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP3  0x4
+/* enum: Edge DFE Tap4 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP4  0x5
+/* enum: Edge DFE Tap5 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_EDFE_TAP5  0x6
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_LANE_LBN 8
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_LANE_WIDTH 3
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_LANE_0  0x0 /* enum */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_LANE_1  0x1 /* enum */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_LANE_2  0x2 /* enum */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_LANE_3  0x3 /* enum */
+#define          MC_CMD_KR_TUNE_RXEQ_GET_OUT_LANE_ALL  0x4 /* enum */
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_AUTOCAL_LBN 11
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_AUTOCAL_WIDTH 1
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_RESERVED_LBN 12
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_RESERVED_WIDTH 4
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_INITIAL_LBN 16
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_INITIAL_WIDTH 8
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_CURRENT_LBN 24
+#define        MC_CMD_KR_TUNE_RXEQ_GET_OUT_PARAM_CURRENT_WIDTH 8
+
+/* MC_CMD_KR_TUNE_RXEQ_SET_IN msgrequest */
+#define    MC_CMD_KR_TUNE_RXEQ_SET_IN_LENMIN 8
+#define    MC_CMD_KR_TUNE_RXEQ_SET_IN_LENMAX 252
+#define    MC_CMD_KR_TUNE_RXEQ_SET_IN_LEN(num) (4+4*(num))
+/* Requested operation */
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_KR_TUNE_OP_OFST 0
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_KR_TUNE_OP_LEN 1
+/* Align the arguments to 32 bits */
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_KR_TUNE_RSVD_OFST 1
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_KR_TUNE_RSVD_LEN 3
+/* RXEQ Parameter */
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_OFST 4
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_LEN 4
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_MINNUM 1
+#define       MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_MAXNUM 62
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_ID_LBN 0
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_ID_WIDTH 8
+/*             Enum values, see field(s): */
+/*                MC_CMD_KR_TUNE_RXEQ_GET_OUT/PARAM_ID */
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_LANE_LBN 8
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_LANE_WIDTH 3
+/*             Enum values, see field(s): */
+/*                MC_CMD_KR_TUNE_RXEQ_GET_OUT/PARAM_LANE */
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_AUTOCAL_LBN 11
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_AUTOCAL_WIDTH 1
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_RESERVED_LBN 12
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_RESERVED_WIDTH 4
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_INITIAL_LBN 16
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_PARAM_INITIAL_WIDTH 8
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_RESERVED2_LBN 24
+#define        MC_CMD_KR_TUNE_RXEQ_SET_IN_RESERVED2_WIDTH 8
+
+/* MC_CMD_KR_TUNE_RXEQ_SET_OUT msgresponse */
+#define    MC_CMD_KR_TUNE_RXEQ_SET_OUT_LEN 0
+
+/* MC_CMD_KR_TUNE_RECAL_IN msgrequest */
+#define    MC_CMD_KR_TUNE_RECAL_IN_LEN 4
+/* Requested operation */
+#define       MC_CMD_KR_TUNE_RECAL_IN_KR_TUNE_OP_OFST 0
+#define       MC_CMD_KR_TUNE_RECAL_IN_KR_TUNE_OP_LEN 1
+/* Align the arguments to 32 bits */
+#define       MC_CMD_KR_TUNE_RECAL_IN_KR_TUNE_RSVD_OFST 1
+#define       MC_CMD_KR_TUNE_RECAL_IN_KR_TUNE_RSVD_LEN 3
+
+/* MC_CMD_KR_TUNE_RECAL_OUT msgresponse */
+#define    MC_CMD_KR_TUNE_RECAL_OUT_LEN 0
+
+
+/***********************************/
+/* MC_CMD_PCIE_TUNE
+ * Get or set PCIE Serdes RXEQ and TX Driver settings
+ */
+#define MC_CMD_PCIE_TUNE 0xf2
+
+/* MC_CMD_PCIE_TUNE_IN msgrequest */
+#define    MC_CMD_PCIE_TUNE_IN_LENMIN 4
+#define    MC_CMD_PCIE_TUNE_IN_LENMAX 252
+#define    MC_CMD_PCIE_TUNE_IN_LEN(num) (4+4*(num))
+/* Requested operation */
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_OP_OFST 0
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_OP_LEN 1
+/* enum: Get current RXEQ settings */
+#define          MC_CMD_PCIE_TUNE_IN_RXEQ_GET  0x0
+/* enum: Override RXEQ settings */
+#define          MC_CMD_PCIE_TUNE_IN_RXEQ_SET  0x1
+/* enum: Get current TX Driver settings */
+#define          MC_CMD_PCIE_TUNE_IN_TXEQ_GET  0x2
+/* enum: Override TX Driver settings */
+#define          MC_CMD_PCIE_TUNE_IN_TXEQ_SET  0x3
+/* Align the arguments to 32 bits */
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_RSVD_OFST 1
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_RSVD_LEN 3
+/* Arguments specific to the operation */
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_ARGS_OFST 4
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_ARGS_LEN 4
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_ARGS_MINNUM 0
+#define       MC_CMD_PCIE_TUNE_IN_PCIE_TUNE_ARGS_MAXNUM 62
+
+/* MC_CMD_PCIE_TUNE_OUT msgresponse */
+#define    MC_CMD_PCIE_TUNE_OUT_LEN 0
+
+/* MC_CMD_PCIE_TUNE_RXEQ_GET_IN msgrequest */
+#define    MC_CMD_PCIE_TUNE_RXEQ_GET_IN_LEN 4
+/* Requested operation */
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_IN_PCIE_TUNE_OP_OFST 0
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_IN_PCIE_TUNE_OP_LEN 1
+/* Align the arguments to 32 bits */
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_IN_PCIE_TUNE_RSVD_OFST 1
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_IN_PCIE_TUNE_RSVD_LEN 3
+
+/* MC_CMD_PCIE_TUNE_RXEQ_GET_OUT msgresponse */
+#define    MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LENMIN 4
+#define    MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LENMAX 252
+#define    MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LEN(num) (0+4*(num))
+/* RXEQ Parameter */
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_OFST 0
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_LEN 4
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_MINNUM 1
+#define       MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_MAXNUM 63
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_ID_LBN 0
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_ID_WIDTH 8
+/* enum: Attenuation (0-15) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_ATT  0x0
+/* enum: CTLE Boost (0-15) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_BOOST  0x1
+/* enum: DFE Tap1 (0 - max negative, 64 - zero, 127 - max positive) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_DFE_TAP1  0x2
+/* enum: DFE Tap2 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_DFE_TAP2  0x3
+/* enum: DFE Tap3 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_DFE_TAP3  0x4
+/* enum: DFE Tap4 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_DFE_TAP4  0x5
+/* enum: DFE Tap5 (0 - max negative, 32 - zero, 63 - max positive) */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_DFE_TAP5  0x6
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_LANE_LBN 8
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_LANE_WIDTH 4
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_0  0x0 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_1  0x1 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_2  0x2 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_3  0x3 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_4  0x4 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_5  0x5 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_6  0x6 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_7  0x7 /* enum */
+#define          MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_LANE_ALL  0x8 /* enum */
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_RESERVED_LBN 12
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_RESERVED_WIDTH 12
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_CURRENT_LBN 24
+#define        MC_CMD_PCIE_TUNE_RXEQ_GET_OUT_PARAM_CURRENT_WIDTH 8
+
+/* MC_CMD_PCIE_TUNE_TXEQ_GET_IN msgrequest */
+#define    MC_CMD_PCIE_TUNE_TXEQ_GET_IN_LEN 4
+/* Requested operation */
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_IN_PCIE_TUNE_OP_OFST 0
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_IN_PCIE_TUNE_OP_LEN 1
+/* Align the arguments to 32 bits */
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_IN_PCIE_TUNE_RSVD_OFST 1
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_IN_PCIE_TUNE_RSVD_LEN 3
+
+/* MC_CMD_PCIE_TUNE_TXEQ_GET_OUT msgresponse */
+#define    MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_LENMIN 4
+#define    MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_LENMAX 252
+#define    MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_LEN(num) (0+4*(num))
+/* RXEQ Parameter */
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_OFST 0
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_LEN 4
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_MINNUM 1
+#define       MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_MAXNUM 63
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_ID_LBN 0
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_ID_WIDTH 8
+/* enum: TxMargin (PIPE) */
+#define          MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_TXMARGIN  0x0
+/* enum: TxSwing (PIPE) */
+#define          MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_TXSWING  0x1
+/* enum: De-emphasis coefficient C(-1) (PIPE) */
+#define          MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_CM1  0x2
+/* enum: De-emphasis coefficient C(0) (PIPE) */
+#define          MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_C0  0x3
+/* enum: De-emphasis coefficient C(+1) (PIPE) */
+#define          MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_CP1  0x4
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_LANE_LBN 8
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_LANE_WIDTH 4
+/*             Enum values, see field(s): */
+/*                MC_CMD_PCIE_TUNE_RXEQ_GET_OUT/PARAM_LANE */
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_RESERVED_LBN 12
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_RESERVED_WIDTH 12
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_CURRENT_LBN 24
+#define        MC_CMD_PCIE_TUNE_TXEQ_GET_OUT_PARAM_CURRENT_WIDTH 8
+
+
+/***********************************/
+/* MC_CMD_LICENSING
+ * Operations on the NVRAM_PARTITION_TYPE_LICENSE application license partition
+ */
+#define MC_CMD_LICENSING 0xf3
+
+/* MC_CMD_LICENSING_IN msgrequest */
+#define    MC_CMD_LICENSING_IN_LEN 4
+/* identifies the type of operation requested */
+#define       MC_CMD_LICENSING_IN_OP_OFST 0
+/* enum: re-read and apply licenses after a license key partition update; note
+ * that this operation returns a zero-length response
+ */
+#define          MC_CMD_LICENSING_IN_OP_UPDATE_LICENSE  0x0
+/* enum: report counts of installed licenses */
+#define          MC_CMD_LICENSING_IN_OP_GET_KEY_STATS  0x1
+
+/* MC_CMD_LICENSING_OUT msgresponse */
+#define    MC_CMD_LICENSING_OUT_LEN 28
+/* count of application keys which are valid */
+#define       MC_CMD_LICENSING_OUT_VALID_APP_KEYS_OFST 0
+/* sum of UNVERIFIABLE_APP_KEYS + WRONG_NODE_APP_KEYS (for compatibility with
+ * MC_CMD_FC_OP_LICENSE)
+ */
+#define       MC_CMD_LICENSING_OUT_INVALID_APP_KEYS_OFST 4
+/* count of application keys which are invalid due to being blacklisted */
+#define       MC_CMD_LICENSING_OUT_BLACKLISTED_APP_KEYS_OFST 8
+/* count of application keys which are invalid due to being unverifiable */
+#define       MC_CMD_LICENSING_OUT_UNVERIFIABLE_APP_KEYS_OFST 12
+/* count of application keys which are invalid due to being for the wrong node
+ */
+#define       MC_CMD_LICENSING_OUT_WRONG_NODE_APP_KEYS_OFST 16
+/* licensing state (for diagnostics; the exact meaning of the bits in this
+ * field are private to the firmware)
+ */
+#define       MC_CMD_LICENSING_OUT_LICENSING_STATE_OFST 20
+/* licensing subsystem self-test report (for manftest) */
+#define       MC_CMD_LICENSING_OUT_LICENSING_SELF_TEST_OFST 24
+/* enum: licensing subsystem self-test failed */
+#define          MC_CMD_LICENSING_OUT_SELF_TEST_FAIL  0x0
+/* enum: licensing subsystem self-test passed */
+#define          MC_CMD_LICENSING_OUT_SELF_TEST_PASS  0x1
+
+
+/***********************************/
+/* MC_CMD_MC2MC_PROXY
+ * Execute an arbitrary MCDI command on the slave MC of a dual-core device.
+ * This will fail on a single-core system.
+ */
+#define MC_CMD_MC2MC_PROXY 0xf4
 
 
 #endif /* MCDI_PCOL_H */
diff --git a/drivers/net/ethernet/sfc/mcdi_phy.c b/drivers/net/ethernet/sfc/mcdi_phy.c
deleted file mode 100644 (file)
index 13cb40f..0000000
+++ /dev/null
@@ -1,830 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2009-2010 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-/*
- * Driver for PHY related operations via MCDI.
- */
-
-#include <linux/slab.h>
-#include "efx.h"
-#include "phy.h"
-#include "mcdi.h"
-#include "mcdi_pcol.h"
-#include "nic.h"
-#include "selftest.h"
-
-struct efx_mcdi_phy_data {
-       u32 flags;
-       u32 type;
-       u32 supported_cap;
-       u32 channel;
-       u32 port;
-       u32 stats_mask;
-       u8 name[20];
-       u32 media;
-       u32 mmd_mask;
-       u8 revision[20];
-       u32 forced_cap;
-};
-
-static int
-efx_mcdi_get_phy_cfg(struct efx_nic *efx, struct efx_mcdi_phy_data *cfg)
-{
-       u8 outbuf[MC_CMD_GET_PHY_CFG_OUT_LEN];
-       size_t outlen;
-       int rc;
-
-       BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_IN_LEN != 0);
-       BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_OUT_NAME_LEN != sizeof(cfg->name));
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_CFG, NULL, 0,
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               goto fail;
-
-       if (outlen < MC_CMD_GET_PHY_CFG_OUT_LEN) {
-               rc = -EIO;
-               goto fail;
-       }
-
-       cfg->flags = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_FLAGS);
-       cfg->type = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_TYPE);
-       cfg->supported_cap =
-               MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_SUPPORTED_CAP);
-       cfg->channel = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_CHANNEL);
-       cfg->port = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_PRT);
-       cfg->stats_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_STATS_MASK);
-       memcpy(cfg->name, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_NAME),
-              sizeof(cfg->name));
-       cfg->media = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MEDIA_TYPE);
-       cfg->mmd_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MMD_MASK);
-       memcpy(cfg->revision, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_REVISION),
-              sizeof(cfg->revision));
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-static int efx_mcdi_set_link(struct efx_nic *efx, u32 capabilities,
-                            u32 flags, u32 loopback_mode,
-                            u32 loopback_speed)
-{
-       u8 inbuf[MC_CMD_SET_LINK_IN_LEN];
-       int rc;
-
-       BUILD_BUG_ON(MC_CMD_SET_LINK_OUT_LEN != 0);
-
-       MCDI_SET_DWORD(inbuf, SET_LINK_IN_CAP, capabilities);
-       MCDI_SET_DWORD(inbuf, SET_LINK_IN_FLAGS, flags);
-       MCDI_SET_DWORD(inbuf, SET_LINK_IN_LOOPBACK_MODE, loopback_mode);
-       MCDI_SET_DWORD(inbuf, SET_LINK_IN_LOOPBACK_SPEED, loopback_speed);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_SET_LINK, inbuf, sizeof(inbuf),
-                         NULL, 0, NULL);
-       if (rc)
-               goto fail;
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-static int efx_mcdi_loopback_modes(struct efx_nic *efx, u64 *loopback_modes)
-{
-       u8 outbuf[MC_CMD_GET_LOOPBACK_MODES_OUT_LEN];
-       size_t outlen;
-       int rc;
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LOOPBACK_MODES, NULL, 0,
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               goto fail;
-
-       if (outlen < MC_CMD_GET_LOOPBACK_MODES_OUT_LEN) {
-               rc = -EIO;
-               goto fail;
-       }
-
-       *loopback_modes = MCDI_QWORD(outbuf, GET_LOOPBACK_MODES_OUT_SUGGESTED);
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-int efx_mcdi_mdio_read(struct efx_nic *efx, unsigned int bus,
-                        unsigned int prtad, unsigned int devad, u16 addr,
-                        u16 *value_out, u32 *status_out)
-{
-       u8 inbuf[MC_CMD_MDIO_READ_IN_LEN];
-       u8 outbuf[MC_CMD_MDIO_READ_OUT_LEN];
-       size_t outlen;
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_BUS, bus);
-       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_PRTAD, prtad);
-       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_DEVAD, devad);
-       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_ADDR, addr);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_READ, inbuf, sizeof(inbuf),
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               goto fail;
-
-       *value_out = (u16)MCDI_DWORD(outbuf, MDIO_READ_OUT_VALUE);
-       *status_out = MCDI_DWORD(outbuf, MDIO_READ_OUT_STATUS);
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-int efx_mcdi_mdio_write(struct efx_nic *efx, unsigned int bus,
-                         unsigned int prtad, unsigned int devad, u16 addr,
-                         u16 value, u32 *status_out)
-{
-       u8 inbuf[MC_CMD_MDIO_WRITE_IN_LEN];
-       u8 outbuf[MC_CMD_MDIO_WRITE_OUT_LEN];
-       size_t outlen;
-       int rc;
-
-       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_BUS, bus);
-       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_PRTAD, prtad);
-       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_DEVAD, devad);
-       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_ADDR, addr);
-       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_VALUE, value);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_WRITE, inbuf, sizeof(inbuf),
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               goto fail;
-
-       *status_out = MCDI_DWORD(outbuf, MDIO_WRITE_OUT_STATUS);
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
-       return rc;
-}
-
-static u32 mcdi_to_ethtool_cap(u32 media, u32 cap)
-{
-       u32 result = 0;
-
-       switch (media) {
-       case MC_CMD_MEDIA_KX4:
-               result |= SUPPORTED_Backplane;
-               if (cap & (1 << MC_CMD_PHY_CAP_1000FDX_LBN))
-                       result |= SUPPORTED_1000baseKX_Full;
-               if (cap & (1 << MC_CMD_PHY_CAP_10000FDX_LBN))
-                       result |= SUPPORTED_10000baseKX4_Full;
-               break;
-
-       case MC_CMD_MEDIA_XFP:
-       case MC_CMD_MEDIA_SFP_PLUS:
-               result |= SUPPORTED_FIBRE;
-               break;
-
-       case MC_CMD_MEDIA_BASE_T:
-               result |= SUPPORTED_TP;
-               if (cap & (1 << MC_CMD_PHY_CAP_10HDX_LBN))
-                       result |= SUPPORTED_10baseT_Half;
-               if (cap & (1 << MC_CMD_PHY_CAP_10FDX_LBN))
-                       result |= SUPPORTED_10baseT_Full;
-               if (cap & (1 << MC_CMD_PHY_CAP_100HDX_LBN))
-                       result |= SUPPORTED_100baseT_Half;
-               if (cap & (1 << MC_CMD_PHY_CAP_100FDX_LBN))
-                       result |= SUPPORTED_100baseT_Full;
-               if (cap & (1 << MC_CMD_PHY_CAP_1000HDX_LBN))
-                       result |= SUPPORTED_1000baseT_Half;
-               if (cap & (1 << MC_CMD_PHY_CAP_1000FDX_LBN))
-                       result |= SUPPORTED_1000baseT_Full;
-               if (cap & (1 << MC_CMD_PHY_CAP_10000FDX_LBN))
-                       result |= SUPPORTED_10000baseT_Full;
-               break;
-       }
-
-       if (cap & (1 << MC_CMD_PHY_CAP_PAUSE_LBN))
-               result |= SUPPORTED_Pause;
-       if (cap & (1 << MC_CMD_PHY_CAP_ASYM_LBN))
-               result |= SUPPORTED_Asym_Pause;
-       if (cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
-               result |= SUPPORTED_Autoneg;
-
-       return result;
-}
-
-static u32 ethtool_to_mcdi_cap(u32 cap)
-{
-       u32 result = 0;
-
-       if (cap & SUPPORTED_10baseT_Half)
-               result |= (1 << MC_CMD_PHY_CAP_10HDX_LBN);
-       if (cap & SUPPORTED_10baseT_Full)
-               result |= (1 << MC_CMD_PHY_CAP_10FDX_LBN);
-       if (cap & SUPPORTED_100baseT_Half)
-               result |= (1 << MC_CMD_PHY_CAP_100HDX_LBN);
-       if (cap & SUPPORTED_100baseT_Full)
-               result |= (1 << MC_CMD_PHY_CAP_100FDX_LBN);
-       if (cap & SUPPORTED_1000baseT_Half)
-               result |= (1 << MC_CMD_PHY_CAP_1000HDX_LBN);
-       if (cap & (SUPPORTED_1000baseT_Full | SUPPORTED_1000baseKX_Full))
-               result |= (1 << MC_CMD_PHY_CAP_1000FDX_LBN);
-       if (cap & (SUPPORTED_10000baseT_Full | SUPPORTED_10000baseKX4_Full))
-               result |= (1 << MC_CMD_PHY_CAP_10000FDX_LBN);
-       if (cap & SUPPORTED_Pause)
-               result |= (1 << MC_CMD_PHY_CAP_PAUSE_LBN);
-       if (cap & SUPPORTED_Asym_Pause)
-               result |= (1 << MC_CMD_PHY_CAP_ASYM_LBN);
-       if (cap & SUPPORTED_Autoneg)
-               result |= (1 << MC_CMD_PHY_CAP_AN_LBN);
-
-       return result;
-}
-
-static u32 efx_get_mcdi_phy_flags(struct efx_nic *efx)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-       enum efx_phy_mode mode, supported;
-       u32 flags;
-
-       /* TODO: Advertise the capabilities supported by this PHY */
-       supported = 0;
-       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN))
-               supported |= PHY_MODE_TX_DISABLED;
-       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN))
-               supported |= PHY_MODE_LOW_POWER;
-       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN))
-               supported |= PHY_MODE_OFF;
-
-       mode = efx->phy_mode & supported;
-
-       flags = 0;
-       if (mode & PHY_MODE_TX_DISABLED)
-               flags |= (1 << MC_CMD_SET_LINK_IN_TXDIS_LBN);
-       if (mode & PHY_MODE_LOW_POWER)
-               flags |= (1 << MC_CMD_SET_LINK_IN_LOWPOWER_LBN);
-       if (mode & PHY_MODE_OFF)
-               flags |= (1 << MC_CMD_SET_LINK_IN_POWEROFF_LBN);
-
-       return flags;
-}
-
-static u32 mcdi_to_ethtool_media(u32 media)
-{
-       switch (media) {
-       case MC_CMD_MEDIA_XAUI:
-       case MC_CMD_MEDIA_CX4:
-       case MC_CMD_MEDIA_KX4:
-               return PORT_OTHER;
-
-       case MC_CMD_MEDIA_XFP:
-       case MC_CMD_MEDIA_SFP_PLUS:
-               return PORT_FIBRE;
-
-       case MC_CMD_MEDIA_BASE_T:
-               return PORT_TP;
-
-       default:
-               return PORT_OTHER;
-       }
-}
-
-static int efx_mcdi_phy_probe(struct efx_nic *efx)
-{
-       struct efx_mcdi_phy_data *phy_data;
-       u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
-       u32 caps;
-       int rc;
-
-       /* Initialise and populate phy_data */
-       phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
-       if (phy_data == NULL)
-               return -ENOMEM;
-
-       rc = efx_mcdi_get_phy_cfg(efx, phy_data);
-       if (rc != 0)
-               goto fail;
-
-       /* Read initial link advertisement */
-       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
-                         outbuf, sizeof(outbuf), NULL);
-       if (rc)
-               goto fail;
-
-       /* Fill out nic state */
-       efx->phy_data = phy_data;
-       efx->phy_type = phy_data->type;
-
-       efx->mdio_bus = phy_data->channel;
-       efx->mdio.prtad = phy_data->port;
-       efx->mdio.mmds = phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22);
-       efx->mdio.mode_support = 0;
-       if (phy_data->mmd_mask & (1 << MC_CMD_MMD_CLAUSE22))
-               efx->mdio.mode_support |= MDIO_SUPPORTS_C22;
-       if (phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22))
-               efx->mdio.mode_support |= MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
-
-       caps = MCDI_DWORD(outbuf, GET_LINK_OUT_CAP);
-       if (caps & (1 << MC_CMD_PHY_CAP_AN_LBN))
-               efx->link_advertising =
-                       mcdi_to_ethtool_cap(phy_data->media, caps);
-       else
-               phy_data->forced_cap = caps;
-
-       /* Assert that we can map efx -> mcdi loopback modes */
-       BUILD_BUG_ON(LOOPBACK_NONE != MC_CMD_LOOPBACK_NONE);
-       BUILD_BUG_ON(LOOPBACK_DATA != MC_CMD_LOOPBACK_DATA);
-       BUILD_BUG_ON(LOOPBACK_GMAC != MC_CMD_LOOPBACK_GMAC);
-       BUILD_BUG_ON(LOOPBACK_XGMII != MC_CMD_LOOPBACK_XGMII);
-       BUILD_BUG_ON(LOOPBACK_XGXS != MC_CMD_LOOPBACK_XGXS);
-       BUILD_BUG_ON(LOOPBACK_XAUI != MC_CMD_LOOPBACK_XAUI);
-       BUILD_BUG_ON(LOOPBACK_GMII != MC_CMD_LOOPBACK_GMII);
-       BUILD_BUG_ON(LOOPBACK_SGMII != MC_CMD_LOOPBACK_SGMII);
-       BUILD_BUG_ON(LOOPBACK_XGBR != MC_CMD_LOOPBACK_XGBR);
-       BUILD_BUG_ON(LOOPBACK_XFI != MC_CMD_LOOPBACK_XFI);
-       BUILD_BUG_ON(LOOPBACK_XAUI_FAR != MC_CMD_LOOPBACK_XAUI_FAR);
-       BUILD_BUG_ON(LOOPBACK_GMII_FAR != MC_CMD_LOOPBACK_GMII_FAR);
-       BUILD_BUG_ON(LOOPBACK_SGMII_FAR != MC_CMD_LOOPBACK_SGMII_FAR);
-       BUILD_BUG_ON(LOOPBACK_XFI_FAR != MC_CMD_LOOPBACK_XFI_FAR);
-       BUILD_BUG_ON(LOOPBACK_GPHY != MC_CMD_LOOPBACK_GPHY);
-       BUILD_BUG_ON(LOOPBACK_PHYXS != MC_CMD_LOOPBACK_PHYXS);
-       BUILD_BUG_ON(LOOPBACK_PCS != MC_CMD_LOOPBACK_PCS);
-       BUILD_BUG_ON(LOOPBACK_PMAPMD != MC_CMD_LOOPBACK_PMAPMD);
-       BUILD_BUG_ON(LOOPBACK_XPORT != MC_CMD_LOOPBACK_XPORT);
-       BUILD_BUG_ON(LOOPBACK_XGMII_WS != MC_CMD_LOOPBACK_XGMII_WS);
-       BUILD_BUG_ON(LOOPBACK_XAUI_WS != MC_CMD_LOOPBACK_XAUI_WS);
-       BUILD_BUG_ON(LOOPBACK_XAUI_WS_FAR != MC_CMD_LOOPBACK_XAUI_WS_FAR);
-       BUILD_BUG_ON(LOOPBACK_XAUI_WS_NEAR != MC_CMD_LOOPBACK_XAUI_WS_NEAR);
-       BUILD_BUG_ON(LOOPBACK_GMII_WS != MC_CMD_LOOPBACK_GMII_WS);
-       BUILD_BUG_ON(LOOPBACK_XFI_WS != MC_CMD_LOOPBACK_XFI_WS);
-       BUILD_BUG_ON(LOOPBACK_XFI_WS_FAR != MC_CMD_LOOPBACK_XFI_WS_FAR);
-       BUILD_BUG_ON(LOOPBACK_PHYXS_WS != MC_CMD_LOOPBACK_PHYXS_WS);
-
-       rc = efx_mcdi_loopback_modes(efx, &efx->loopback_modes);
-       if (rc != 0)
-               goto fail;
-       /* The MC indicates that LOOPBACK_NONE is a valid loopback mode,
-        * but by convention we don't */
-       efx->loopback_modes &= ~(1 << LOOPBACK_NONE);
-
-       /* Set the initial link mode */
-       efx_mcdi_phy_decode_link(
-               efx, &efx->link_state,
-               MCDI_DWORD(outbuf, GET_LINK_OUT_LINK_SPEED),
-               MCDI_DWORD(outbuf, GET_LINK_OUT_FLAGS),
-               MCDI_DWORD(outbuf, GET_LINK_OUT_FCNTL));
-
-       /* Default to Autonegotiated flow control if the PHY supports it */
-       efx->wanted_fc = EFX_FC_RX | EFX_FC_TX;
-       if (phy_data->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
-               efx->wanted_fc |= EFX_FC_AUTO;
-       efx_link_set_wanted_fc(efx, efx->wanted_fc);
-
-       return 0;
-
-fail:
-       kfree(phy_data);
-       return rc;
-}
-
-int efx_mcdi_phy_reconfigure(struct efx_nic *efx)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-       u32 caps = (efx->link_advertising ?
-                   ethtool_to_mcdi_cap(efx->link_advertising) :
-                   phy_cfg->forced_cap);
-
-       return efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx),
-                                efx->loopback_mode, 0);
-}
-
-void efx_mcdi_phy_decode_link(struct efx_nic *efx,
-                             struct efx_link_state *link_state,
-                             u32 speed, u32 flags, u32 fcntl)
-{
-       switch (fcntl) {
-       case MC_CMD_FCNTL_AUTO:
-               WARN_ON(1);     /* This is not a link mode */
-               link_state->fc = EFX_FC_AUTO | EFX_FC_TX | EFX_FC_RX;
-               break;
-       case MC_CMD_FCNTL_BIDIR:
-               link_state->fc = EFX_FC_TX | EFX_FC_RX;
-               break;
-       case MC_CMD_FCNTL_RESPOND:
-               link_state->fc = EFX_FC_RX;
-               break;
-       default:
-               WARN_ON(1);
-       case MC_CMD_FCNTL_OFF:
-               link_state->fc = 0;
-               break;
-       }
-
-       link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN));
-       link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN));
-       link_state->speed = speed;
-}
-
-/* Verify that the forced flow control settings (!EFX_FC_AUTO) are
- * supported by the link partner. Warn the user if this isn't the case
- */
-void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-       u32 rmtadv;
-
-       /* The link partner capabilities are only relevant if the
-        * link supports flow control autonegotiation */
-       if (~phy_cfg->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
-               return;
-
-       /* If flow control autoneg is supported and enabled, then fine */
-       if (efx->wanted_fc & EFX_FC_AUTO)
-               return;
-
-       rmtadv = 0;
-       if (lpa & (1 << MC_CMD_PHY_CAP_PAUSE_LBN))
-               rmtadv |= ADVERTISED_Pause;
-       if (lpa & (1 << MC_CMD_PHY_CAP_ASYM_LBN))
-               rmtadv |=  ADVERTISED_Asym_Pause;
-
-       if ((efx->wanted_fc & EFX_FC_TX) && rmtadv == ADVERTISED_Asym_Pause)
-               netif_err(efx, link, efx->net_dev,
-                         "warning: link partner doesn't support pause frames");
-}
-
-static bool efx_mcdi_phy_poll(struct efx_nic *efx)
-{
-       struct efx_link_state old_state = efx->link_state;
-       u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
-       int rc;
-
-       WARN_ON(!mutex_is_locked(&efx->mac_lock));
-
-       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
-                         outbuf, sizeof(outbuf), NULL);
-       if (rc) {
-               netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
-                         __func__, rc);
-               efx->link_state.up = false;
-       } else {
-               efx_mcdi_phy_decode_link(
-                       efx, &efx->link_state,
-                       MCDI_DWORD(outbuf, GET_LINK_OUT_LINK_SPEED),
-                       MCDI_DWORD(outbuf, GET_LINK_OUT_FLAGS),
-                       MCDI_DWORD(outbuf, GET_LINK_OUT_FCNTL));
-       }
-
-       return !efx_link_state_equal(&efx->link_state, &old_state);
-}
-
-static void efx_mcdi_phy_remove(struct efx_nic *efx)
-{
-       struct efx_mcdi_phy_data *phy_data = efx->phy_data;
-
-       efx->phy_data = NULL;
-       kfree(phy_data);
-}
-
-static void efx_mcdi_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-       u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
-       int rc;
-
-       ecmd->supported =
-               mcdi_to_ethtool_cap(phy_cfg->media, phy_cfg->supported_cap);
-       ecmd->advertising = efx->link_advertising;
-       ethtool_cmd_speed_set(ecmd, efx->link_state.speed);
-       ecmd->duplex = efx->link_state.fd;
-       ecmd->port = mcdi_to_ethtool_media(phy_cfg->media);
-       ecmd->phy_address = phy_cfg->port;
-       ecmd->transceiver = XCVR_INTERNAL;
-       ecmd->autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg);
-       ecmd->mdio_support = (efx->mdio.mode_support &
-                             (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22));
-
-       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
-                         outbuf, sizeof(outbuf), NULL);
-       if (rc) {
-               netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
-                         __func__, rc);
-               return;
-       }
-       ecmd->lp_advertising =
-               mcdi_to_ethtool_cap(phy_cfg->media,
-                                   MCDI_DWORD(outbuf, GET_LINK_OUT_LP_CAP));
-}
-
-static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-       u32 caps;
-       int rc;
-
-       if (ecmd->autoneg) {
-               caps = (ethtool_to_mcdi_cap(ecmd->advertising) |
-                        1 << MC_CMD_PHY_CAP_AN_LBN);
-       } else if (ecmd->duplex) {
-               switch (ethtool_cmd_speed(ecmd)) {
-               case 10:    caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN;    break;
-               case 100:   caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN;   break;
-               case 1000:  caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN;  break;
-               case 10000: caps = 1 << MC_CMD_PHY_CAP_10000FDX_LBN; break;
-               default:    return -EINVAL;
-               }
-       } else {
-               switch (ethtool_cmd_speed(ecmd)) {
-               case 10:    caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN;    break;
-               case 100:   caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN;   break;
-               case 1000:  caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN;  break;
-               default:    return -EINVAL;
-               }
-       }
-
-       rc = efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx),
-                              efx->loopback_mode, 0);
-       if (rc)
-               return rc;
-
-       if (ecmd->autoneg) {
-               efx_link_set_advertising(
-                       efx, ecmd->advertising | ADVERTISED_Autoneg);
-               phy_cfg->forced_cap = 0;
-       } else {
-               efx_link_set_advertising(efx, 0);
-               phy_cfg->forced_cap = caps;
-       }
-       return 0;
-}
-
-static int efx_mcdi_phy_test_alive(struct efx_nic *efx)
-{
-       u8 outbuf[MC_CMD_GET_PHY_STATE_OUT_LEN];
-       size_t outlen;
-       int rc;
-
-       BUILD_BUG_ON(MC_CMD_GET_PHY_STATE_IN_LEN != 0);
-
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_STATE, NULL, 0,
-                         outbuf, sizeof(outbuf), &outlen);
-       if (rc)
-               return rc;
-
-       if (outlen < MC_CMD_GET_PHY_STATE_OUT_LEN)
-               return -EIO;
-       if (MCDI_DWORD(outbuf, GET_PHY_STATE_OUT_STATE) != MC_CMD_PHY_STATE_OK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static const char *const mcdi_sft9001_cable_diag_names[] = {
-       "cable.pairA.length",
-       "cable.pairB.length",
-       "cable.pairC.length",
-       "cable.pairD.length",
-       "cable.pairA.status",
-       "cable.pairB.status",
-       "cable.pairC.status",
-       "cable.pairD.status",
-};
-
-static int efx_mcdi_bist(struct efx_nic *efx, unsigned int bist_mode,
-                        int *results)
-{
-       unsigned int retry, i, count = 0;
-       size_t outlen;
-       u32 status;
-       u8 *buf, *ptr;
-       int rc;
-
-       buf = kzalloc(0x100, GFP_KERNEL);
-       if (buf == NULL)
-               return -ENOMEM;
-
-       BUILD_BUG_ON(MC_CMD_START_BIST_OUT_LEN != 0);
-       MCDI_SET_DWORD(buf, START_BIST_IN_TYPE, bist_mode);
-       rc = efx_mcdi_rpc(efx, MC_CMD_START_BIST, buf, MC_CMD_START_BIST_IN_LEN,
-                         NULL, 0, NULL);
-       if (rc)
-               goto out;
-
-       /* Wait up to 10s for BIST to finish */
-       for (retry = 0; retry < 100; ++retry) {
-               BUILD_BUG_ON(MC_CMD_POLL_BIST_IN_LEN != 0);
-               rc = efx_mcdi_rpc(efx, MC_CMD_POLL_BIST, NULL, 0,
-                                 buf, 0x100, &outlen);
-               if (rc)
-                       goto out;
-
-               status = MCDI_DWORD(buf, POLL_BIST_OUT_RESULT);
-               if (status != MC_CMD_POLL_BIST_RUNNING)
-                       goto finished;
-
-               msleep(100);
-       }
-
-       rc = -ETIMEDOUT;
-       goto out;
-
-finished:
-       results[count++] = (status == MC_CMD_POLL_BIST_PASSED) ? 1 : -1;
-
-       /* SFT9001 specific cable diagnostics output */
-       if (efx->phy_type == PHY_TYPE_SFT9001B &&
-           (bist_mode == MC_CMD_PHY_BIST_CABLE_SHORT ||
-            bist_mode == MC_CMD_PHY_BIST_CABLE_LONG)) {
-               ptr = MCDI_PTR(buf, POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A);
-               if (status == MC_CMD_POLL_BIST_PASSED &&
-                   outlen >= MC_CMD_POLL_BIST_OUT_SFT9001_LEN) {
-                       for (i = 0; i < 8; i++) {
-                               results[count + i] =
-                                       EFX_DWORD_FIELD(((efx_dword_t *)ptr)[i],
-                                                       EFX_DWORD_0);
-                       }
-               }
-               count += 8;
-       }
-       rc = count;
-
-out:
-       kfree(buf);
-
-       return rc;
-}
-
-static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results,
-                                 unsigned flags)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-       u32 mode;
-       int rc;
-
-       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) {
-               rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results);
-               if (rc < 0)
-                       return rc;
-
-               results += rc;
-       }
-
-       /* If we support both LONG and SHORT, then run each in response to
-        * break or not. Otherwise, run the one we support */
-       mode = 0;
-       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN)) {
-               if ((flags & ETH_TEST_FL_OFFLINE) &&
-                   (phy_cfg->flags &
-                    (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN)))
-                       mode = MC_CMD_PHY_BIST_CABLE_LONG;
-               else
-                       mode = MC_CMD_PHY_BIST_CABLE_SHORT;
-       } else if (phy_cfg->flags &
-                  (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))
-               mode = MC_CMD_PHY_BIST_CABLE_LONG;
-
-       if (mode != 0) {
-               rc = efx_mcdi_bist(efx, mode, results);
-               if (rc < 0)
-                       return rc;
-               results += rc;
-       }
-
-       return 0;
-}
-
-static const char *efx_mcdi_phy_test_name(struct efx_nic *efx,
-                                         unsigned int index)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-
-       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) {
-               if (index == 0)
-                       return "bist";
-               --index;
-       }
-
-       if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN) |
-                             (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))) {
-               if (index == 0)
-                       return "cable";
-               --index;
-
-               if (efx->phy_type == PHY_TYPE_SFT9001B) {
-                       if (index < ARRAY_SIZE(mcdi_sft9001_cable_diag_names))
-                               return mcdi_sft9001_cable_diag_names[index];
-                       index -= ARRAY_SIZE(mcdi_sft9001_cable_diag_names);
-               }
-       }
-
-       return NULL;
-}
-
-#define SFP_PAGE_SIZE  128
-#define SFP_NUM_PAGES  2
-static int efx_mcdi_phy_get_module_eeprom(struct efx_nic *efx,
-                                         struct ethtool_eeprom *ee, u8 *data)
-{
-       u8 outbuf[MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX];
-       u8 inbuf[MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN];
-       size_t outlen;
-       int rc;
-       unsigned int payload_len;
-       unsigned int space_remaining = ee->len;
-       unsigned int page;
-       unsigned int page_off;
-       unsigned int to_copy;
-       u8 *user_data = data;
-
-       BUILD_BUG_ON(SFP_PAGE_SIZE * SFP_NUM_PAGES != ETH_MODULE_SFF_8079_LEN);
-
-       page_off = ee->offset % SFP_PAGE_SIZE;
-       page = ee->offset / SFP_PAGE_SIZE;
-
-       while (space_remaining && (page < SFP_NUM_PAGES)) {
-               MCDI_SET_DWORD(inbuf, GET_PHY_MEDIA_INFO_IN_PAGE, page);
-
-               rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_MEDIA_INFO,
-                                 inbuf, sizeof(inbuf),
-                                 outbuf, sizeof(outbuf),
-                                 &outlen);
-               if (rc)
-                       return rc;
-
-               if (outlen < (MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST +
-                             SFP_PAGE_SIZE))
-                       return -EIO;
-
-               payload_len = MCDI_DWORD(outbuf,
-                                        GET_PHY_MEDIA_INFO_OUT_DATALEN);
-               if (payload_len != SFP_PAGE_SIZE)
-                       return -EIO;
-
-               /* Copy as much as we can into data */
-               payload_len -= page_off;
-               to_copy = (space_remaining < payload_len) ?
-                       space_remaining : payload_len;
-
-               memcpy(user_data,
-                      outbuf + page_off +
-                      MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST,
-                      to_copy);
-
-               space_remaining -= to_copy;
-               user_data += to_copy;
-               page_off = 0;
-               page++;
-       }
-
-       return 0;
-}
-
-static int efx_mcdi_phy_get_module_info(struct efx_nic *efx,
-                                       struct ethtool_modinfo *modinfo)
-{
-       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
-
-       switch (phy_cfg->media) {
-       case MC_CMD_MEDIA_SFP_PLUS:
-               modinfo->type = ETH_MODULE_SFF_8079;
-               modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
-               return 0;
-       default:
-               return -EOPNOTSUPP;
-       }
-}
-
-const struct efx_phy_operations efx_mcdi_phy_ops = {
-       .probe          = efx_mcdi_phy_probe,
-       .init           = efx_port_dummy_op_int,
-       .reconfigure    = efx_mcdi_phy_reconfigure,
-       .poll           = efx_mcdi_phy_poll,
-       .fini           = efx_port_dummy_op_void,
-       .remove         = efx_mcdi_phy_remove,
-       .get_settings   = efx_mcdi_phy_get_settings,
-       .set_settings   = efx_mcdi_phy_set_settings,
-       .test_alive     = efx_mcdi_phy_test_alive,
-       .run_tests      = efx_mcdi_phy_run_tests,
-       .test_name      = efx_mcdi_phy_test_name,
-       .get_module_eeprom = efx_mcdi_phy_get_module_eeprom,
-       .get_module_info = efx_mcdi_phy_get_module_info,
-};
diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c
new file mode 100644 (file)
index 0000000..42d52f3
--- /dev/null
@@ -0,0 +1,1006 @@
+/****************************************************************************
+ * Driver for Solarflare Solarstorm network controllers and boards
+ * Copyright 2009-2010 Solarflare Communications Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation, incorporated herein by reference.
+ */
+
+/*
+ * Driver for PHY related operations via MCDI.
+ */
+
+#include <linux/slab.h>
+#include "efx.h"
+#include "phy.h"
+#include "mcdi.h"
+#include "mcdi_pcol.h"
+#include "nic.h"
+#include "selftest.h"
+
+struct efx_mcdi_phy_data {
+       u32 flags;
+       u32 type;
+       u32 supported_cap;
+       u32 channel;
+       u32 port;
+       u32 stats_mask;
+       u8 name[20];
+       u32 media;
+       u32 mmd_mask;
+       u8 revision[20];
+       u32 forced_cap;
+};
+
+static int
+efx_mcdi_get_phy_cfg(struct efx_nic *efx, struct efx_mcdi_phy_data *cfg)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_PHY_CFG_OUT_LEN);
+       size_t outlen;
+       int rc;
+
+       BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_IN_LEN != 0);
+       BUILD_BUG_ON(MC_CMD_GET_PHY_CFG_OUT_NAME_LEN != sizeof(cfg->name));
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_CFG, NULL, 0,
+                         outbuf, sizeof(outbuf), &outlen);
+       if (rc)
+               goto fail;
+
+       if (outlen < MC_CMD_GET_PHY_CFG_OUT_LEN) {
+               rc = -EIO;
+               goto fail;
+       }
+
+       cfg->flags = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_FLAGS);
+       cfg->type = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_TYPE);
+       cfg->supported_cap =
+               MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_SUPPORTED_CAP);
+       cfg->channel = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_CHANNEL);
+       cfg->port = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_PRT);
+       cfg->stats_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_STATS_MASK);
+       memcpy(cfg->name, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_NAME),
+              sizeof(cfg->name));
+       cfg->media = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MEDIA_TYPE);
+       cfg->mmd_mask = MCDI_DWORD(outbuf, GET_PHY_CFG_OUT_MMD_MASK);
+       memcpy(cfg->revision, MCDI_PTR(outbuf, GET_PHY_CFG_OUT_REVISION),
+              sizeof(cfg->revision));
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_set_link(struct efx_nic *efx, u32 capabilities,
+                            u32 flags, u32 loopback_mode,
+                            u32 loopback_speed)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_SET_LINK_IN_LEN);
+       int rc;
+
+       BUILD_BUG_ON(MC_CMD_SET_LINK_OUT_LEN != 0);
+
+       MCDI_SET_DWORD(inbuf, SET_LINK_IN_CAP, capabilities);
+       MCDI_SET_DWORD(inbuf, SET_LINK_IN_FLAGS, flags);
+       MCDI_SET_DWORD(inbuf, SET_LINK_IN_LOOPBACK_MODE, loopback_mode);
+       MCDI_SET_DWORD(inbuf, SET_LINK_IN_LOOPBACK_SPEED, loopback_speed);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_SET_LINK, inbuf, sizeof(inbuf),
+                         NULL, 0, NULL);
+       if (rc)
+               goto fail;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_loopback_modes(struct efx_nic *efx, u64 *loopback_modes)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LOOPBACK_MODES_OUT_LEN);
+       size_t outlen;
+       int rc;
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LOOPBACK_MODES, NULL, 0,
+                         outbuf, sizeof(outbuf), &outlen);
+       if (rc)
+               goto fail;
+
+       if (outlen < (MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_OFST +
+                     MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LEN)) {
+               rc = -EIO;
+               goto fail;
+       }
+
+       *loopback_modes = MCDI_QWORD(outbuf, GET_LOOPBACK_MODES_OUT_SUGGESTED);
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_mdio_read(struct net_device *net_dev,
+                             int prtad, int devad, u16 addr)
+{
+       struct efx_nic *efx = netdev_priv(net_dev);
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_MDIO_READ_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_MDIO_READ_OUT_LEN);
+       size_t outlen;
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_BUS, efx->mdio_bus);
+       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_PRTAD, prtad);
+       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_DEVAD, devad);
+       MCDI_SET_DWORD(inbuf, MDIO_READ_IN_ADDR, addr);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_READ, inbuf, sizeof(inbuf),
+                         outbuf, sizeof(outbuf), &outlen);
+       if (rc)
+               goto fail;
+
+       if (MCDI_DWORD(outbuf, MDIO_READ_OUT_STATUS) !=
+           MC_CMD_MDIO_STATUS_GOOD)
+               return -EIO;
+
+       return (u16)MCDI_DWORD(outbuf, MDIO_READ_OUT_VALUE);
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static int efx_mcdi_mdio_write(struct net_device *net_dev,
+                              int prtad, int devad, u16 addr, u16 value)
+{
+       struct efx_nic *efx = netdev_priv(net_dev);
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_MDIO_WRITE_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_MDIO_WRITE_OUT_LEN);
+       size_t outlen;
+       int rc;
+
+       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_BUS, efx->mdio_bus);
+       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_PRTAD, prtad);
+       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_DEVAD, devad);
+       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_ADDR, addr);
+       MCDI_SET_DWORD(inbuf, MDIO_WRITE_IN_VALUE, value);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_MDIO_WRITE, inbuf, sizeof(inbuf),
+                         outbuf, sizeof(outbuf), &outlen);
+       if (rc)
+               goto fail;
+
+       if (MCDI_DWORD(outbuf, MDIO_WRITE_OUT_STATUS) !=
+           MC_CMD_MDIO_STATUS_GOOD)
+               return -EIO;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
+       return rc;
+}
+
+static u32 mcdi_to_ethtool_cap(u32 media, u32 cap)
+{
+       u32 result = 0;
+
+       switch (media) {
+       case MC_CMD_MEDIA_KX4:
+               result |= SUPPORTED_Backplane;
+               if (cap & (1 << MC_CMD_PHY_CAP_1000FDX_LBN))
+                       result |= SUPPORTED_1000baseKX_Full;
+               if (cap & (1 << MC_CMD_PHY_CAP_10000FDX_LBN))
+                       result |= SUPPORTED_10000baseKX4_Full;
+               break;
+
+       case MC_CMD_MEDIA_XFP:
+       case MC_CMD_MEDIA_SFP_PLUS:
+               result |= SUPPORTED_FIBRE;
+               break;
+
+       case MC_CMD_MEDIA_BASE_T:
+               result |= SUPPORTED_TP;
+               if (cap & (1 << MC_CMD_PHY_CAP_10HDX_LBN))
+                       result |= SUPPORTED_10baseT_Half;
+               if (cap & (1 << MC_CMD_PHY_CAP_10FDX_LBN))
+                       result |= SUPPORTED_10baseT_Full;
+               if (cap & (1 << MC_CMD_PHY_CAP_100HDX_LBN))
+                       result |= SUPPORTED_100baseT_Half;
+               if (cap & (1 << MC_CMD_PHY_CAP_100FDX_LBN))
+                       result |= SUPPORTED_100baseT_Full;
+               if (cap & (1 << MC_CMD_PHY_CAP_1000HDX_LBN))
+                       result |= SUPPORTED_1000baseT_Half;
+               if (cap & (1 << MC_CMD_PHY_CAP_1000FDX_LBN))
+                       result |= SUPPORTED_1000baseT_Full;
+               if (cap & (1 << MC_CMD_PHY_CAP_10000FDX_LBN))
+                       result |= SUPPORTED_10000baseT_Full;
+               break;
+       }
+
+       if (cap & (1 << MC_CMD_PHY_CAP_PAUSE_LBN))
+               result |= SUPPORTED_Pause;
+       if (cap & (1 << MC_CMD_PHY_CAP_ASYM_LBN))
+               result |= SUPPORTED_Asym_Pause;
+       if (cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
+               result |= SUPPORTED_Autoneg;
+
+       return result;
+}
+
+static u32 ethtool_to_mcdi_cap(u32 cap)
+{
+       u32 result = 0;
+
+       if (cap & SUPPORTED_10baseT_Half)
+               result |= (1 << MC_CMD_PHY_CAP_10HDX_LBN);
+       if (cap & SUPPORTED_10baseT_Full)
+               result |= (1 << MC_CMD_PHY_CAP_10FDX_LBN);
+       if (cap & SUPPORTED_100baseT_Half)
+               result |= (1 << MC_CMD_PHY_CAP_100HDX_LBN);
+       if (cap & SUPPORTED_100baseT_Full)
+               result |= (1 << MC_CMD_PHY_CAP_100FDX_LBN);
+       if (cap & SUPPORTED_1000baseT_Half)
+               result |= (1 << MC_CMD_PHY_CAP_1000HDX_LBN);
+       if (cap & (SUPPORTED_1000baseT_Full | SUPPORTED_1000baseKX_Full))
+               result |= (1 << MC_CMD_PHY_CAP_1000FDX_LBN);
+       if (cap & (SUPPORTED_10000baseT_Full | SUPPORTED_10000baseKX4_Full))
+               result |= (1 << MC_CMD_PHY_CAP_10000FDX_LBN);
+       if (cap & SUPPORTED_Pause)
+               result |= (1 << MC_CMD_PHY_CAP_PAUSE_LBN);
+       if (cap & SUPPORTED_Asym_Pause)
+               result |= (1 << MC_CMD_PHY_CAP_ASYM_LBN);
+       if (cap & SUPPORTED_Autoneg)
+               result |= (1 << MC_CMD_PHY_CAP_AN_LBN);
+
+       return result;
+}
+
+static u32 efx_get_mcdi_phy_flags(struct efx_nic *efx)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+       enum efx_phy_mode mode, supported;
+       u32 flags;
+
+       /* TODO: Advertise the capabilities supported by this PHY */
+       supported = 0;
+       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN))
+               supported |= PHY_MODE_TX_DISABLED;
+       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN))
+               supported |= PHY_MODE_LOW_POWER;
+       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN))
+               supported |= PHY_MODE_OFF;
+
+       mode = efx->phy_mode & supported;
+
+       flags = 0;
+       if (mode & PHY_MODE_TX_DISABLED)
+               flags |= (1 << MC_CMD_SET_LINK_IN_TXDIS_LBN);
+       if (mode & PHY_MODE_LOW_POWER)
+               flags |= (1 << MC_CMD_SET_LINK_IN_LOWPOWER_LBN);
+       if (mode & PHY_MODE_OFF)
+               flags |= (1 << MC_CMD_SET_LINK_IN_POWEROFF_LBN);
+
+       return flags;
+}
+
+static u32 mcdi_to_ethtool_media(u32 media)
+{
+       switch (media) {
+       case MC_CMD_MEDIA_XAUI:
+       case MC_CMD_MEDIA_CX4:
+       case MC_CMD_MEDIA_KX4:
+               return PORT_OTHER;
+
+       case MC_CMD_MEDIA_XFP:
+       case MC_CMD_MEDIA_SFP_PLUS:
+               return PORT_FIBRE;
+
+       case MC_CMD_MEDIA_BASE_T:
+               return PORT_TP;
+
+       default:
+               return PORT_OTHER;
+       }
+}
+
+static void efx_mcdi_phy_decode_link(struct efx_nic *efx,
+                             struct efx_link_state *link_state,
+                             u32 speed, u32 flags, u32 fcntl)
+{
+       switch (fcntl) {
+       case MC_CMD_FCNTL_AUTO:
+               WARN_ON(1);     /* This is not a link mode */
+               link_state->fc = EFX_FC_AUTO | EFX_FC_TX | EFX_FC_RX;
+               break;
+       case MC_CMD_FCNTL_BIDIR:
+               link_state->fc = EFX_FC_TX | EFX_FC_RX;
+               break;
+       case MC_CMD_FCNTL_RESPOND:
+               link_state->fc = EFX_FC_RX;
+               break;
+       default:
+               WARN_ON(1);
+       case MC_CMD_FCNTL_OFF:
+               link_state->fc = 0;
+               break;
+       }
+
+       link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN));
+       link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN));
+       link_state->speed = speed;
+}
+
+static int efx_mcdi_phy_probe(struct efx_nic *efx)
+{
+       struct efx_mcdi_phy_data *phy_data;
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN);
+       u32 caps;
+       int rc;
+
+       /* Initialise and populate phy_data */
+       phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
+       if (phy_data == NULL)
+               return -ENOMEM;
+
+       rc = efx_mcdi_get_phy_cfg(efx, phy_data);
+       if (rc != 0)
+               goto fail;
+
+       /* Read initial link advertisement */
+       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
+                         outbuf, sizeof(outbuf), NULL);
+       if (rc)
+               goto fail;
+
+       /* Fill out nic state */
+       efx->phy_data = phy_data;
+       efx->phy_type = phy_data->type;
+
+       efx->mdio_bus = phy_data->channel;
+       efx->mdio.prtad = phy_data->port;
+       efx->mdio.mmds = phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22);
+       efx->mdio.mode_support = 0;
+       if (phy_data->mmd_mask & (1 << MC_CMD_MMD_CLAUSE22))
+               efx->mdio.mode_support |= MDIO_SUPPORTS_C22;
+       if (phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22))
+               efx->mdio.mode_support |= MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
+
+       caps = MCDI_DWORD(outbuf, GET_LINK_OUT_CAP);
+       if (caps & (1 << MC_CMD_PHY_CAP_AN_LBN))
+               efx->link_advertising =
+                       mcdi_to_ethtool_cap(phy_data->media, caps);
+       else
+               phy_data->forced_cap = caps;
+
+       /* Assert that we can map efx -> mcdi loopback modes */
+       BUILD_BUG_ON(LOOPBACK_NONE != MC_CMD_LOOPBACK_NONE);
+       BUILD_BUG_ON(LOOPBACK_DATA != MC_CMD_LOOPBACK_DATA);
+       BUILD_BUG_ON(LOOPBACK_GMAC != MC_CMD_LOOPBACK_GMAC);
+       BUILD_BUG_ON(LOOPBACK_XGMII != MC_CMD_LOOPBACK_XGMII);
+       BUILD_BUG_ON(LOOPBACK_XGXS != MC_CMD_LOOPBACK_XGXS);
+       BUILD_BUG_ON(LOOPBACK_XAUI != MC_CMD_LOOPBACK_XAUI);
+       BUILD_BUG_ON(LOOPBACK_GMII != MC_CMD_LOOPBACK_GMII);
+       BUILD_BUG_ON(LOOPBACK_SGMII != MC_CMD_LOOPBACK_SGMII);
+       BUILD_BUG_ON(LOOPBACK_XGBR != MC_CMD_LOOPBACK_XGBR);
+       BUILD_BUG_ON(LOOPBACK_XFI != MC_CMD_LOOPBACK_XFI);
+       BUILD_BUG_ON(LOOPBACK_XAUI_FAR != MC_CMD_LOOPBACK_XAUI_FAR);
+       BUILD_BUG_ON(LOOPBACK_GMII_FAR != MC_CMD_LOOPBACK_GMII_FAR);
+       BUILD_BUG_ON(LOOPBACK_SGMII_FAR != MC_CMD_LOOPBACK_SGMII_FAR);
+       BUILD_BUG_ON(LOOPBACK_XFI_FAR != MC_CMD_LOOPBACK_XFI_FAR);
+       BUILD_BUG_ON(LOOPBACK_GPHY != MC_CMD_LOOPBACK_GPHY);
+       BUILD_BUG_ON(LOOPBACK_PHYXS != MC_CMD_LOOPBACK_PHYXS);
+       BUILD_BUG_ON(LOOPBACK_PCS != MC_CMD_LOOPBACK_PCS);
+       BUILD_BUG_ON(LOOPBACK_PMAPMD != MC_CMD_LOOPBACK_PMAPMD);
+       BUILD_BUG_ON(LOOPBACK_XPORT != MC_CMD_LOOPBACK_XPORT);
+       BUILD_BUG_ON(LOOPBACK_XGMII_WS != MC_CMD_LOOPBACK_XGMII_WS);
+       BUILD_BUG_ON(LOOPBACK_XAUI_WS != MC_CMD_LOOPBACK_XAUI_WS);
+       BUILD_BUG_ON(LOOPBACK_XAUI_WS_FAR != MC_CMD_LOOPBACK_XAUI_WS_FAR);
+       BUILD_BUG_ON(LOOPBACK_XAUI_WS_NEAR != MC_CMD_LOOPBACK_XAUI_WS_NEAR);
+       BUILD_BUG_ON(LOOPBACK_GMII_WS != MC_CMD_LOOPBACK_GMII_WS);
+       BUILD_BUG_ON(LOOPBACK_XFI_WS != MC_CMD_LOOPBACK_XFI_WS);
+       BUILD_BUG_ON(LOOPBACK_XFI_WS_FAR != MC_CMD_LOOPBACK_XFI_WS_FAR);
+       BUILD_BUG_ON(LOOPBACK_PHYXS_WS != MC_CMD_LOOPBACK_PHYXS_WS);
+
+       rc = efx_mcdi_loopback_modes(efx, &efx->loopback_modes);
+       if (rc != 0)
+               goto fail;
+       /* The MC indicates that LOOPBACK_NONE is a valid loopback mode,
+        * but by convention we don't */
+       efx->loopback_modes &= ~(1 << LOOPBACK_NONE);
+
+       /* Set the initial link mode */
+       efx_mcdi_phy_decode_link(
+               efx, &efx->link_state,
+               MCDI_DWORD(outbuf, GET_LINK_OUT_LINK_SPEED),
+               MCDI_DWORD(outbuf, GET_LINK_OUT_FLAGS),
+               MCDI_DWORD(outbuf, GET_LINK_OUT_FCNTL));
+
+       /* Default to Autonegotiated flow control if the PHY supports it */
+       efx->wanted_fc = EFX_FC_RX | EFX_FC_TX;
+       if (phy_data->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
+               efx->wanted_fc |= EFX_FC_AUTO;
+       efx_link_set_wanted_fc(efx, efx->wanted_fc);
+
+       return 0;
+
+fail:
+       kfree(phy_data);
+       return rc;
+}
+
+int efx_mcdi_port_reconfigure(struct efx_nic *efx)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+       u32 caps = (efx->link_advertising ?
+                   ethtool_to_mcdi_cap(efx->link_advertising) :
+                   phy_cfg->forced_cap);
+
+       return efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx),
+                                efx->loopback_mode, 0);
+}
+
+/* Verify that the forced flow control settings (!EFX_FC_AUTO) are
+ * supported by the link partner. Warn the user if this isn't the case
+ */
+static void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+       u32 rmtadv;
+
+       /* The link partner capabilities are only relevant if the
+        * link supports flow control autonegotiation */
+       if (~phy_cfg->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
+               return;
+
+       /* If flow control autoneg is supported and enabled, then fine */
+       if (efx->wanted_fc & EFX_FC_AUTO)
+               return;
+
+       rmtadv = 0;
+       if (lpa & (1 << MC_CMD_PHY_CAP_PAUSE_LBN))
+               rmtadv |= ADVERTISED_Pause;
+       if (lpa & (1 << MC_CMD_PHY_CAP_ASYM_LBN))
+               rmtadv |=  ADVERTISED_Asym_Pause;
+
+       if ((efx->wanted_fc & EFX_FC_TX) && rmtadv == ADVERTISED_Asym_Pause)
+               netif_err(efx, link, efx->net_dev,
+                         "warning: link partner doesn't support pause frames");
+}
+
+static bool efx_mcdi_phy_poll(struct efx_nic *efx)
+{
+       struct efx_link_state old_state = efx->link_state;
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN);
+       int rc;
+
+       WARN_ON(!mutex_is_locked(&efx->mac_lock));
+
+       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
+                         outbuf, sizeof(outbuf), NULL);
+       if (rc) {
+               netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
+                         __func__, rc);
+               efx->link_state.up = false;
+       } else {
+               efx_mcdi_phy_decode_link(
+                       efx, &efx->link_state,
+                       MCDI_DWORD(outbuf, GET_LINK_OUT_LINK_SPEED),
+                       MCDI_DWORD(outbuf, GET_LINK_OUT_FLAGS),
+                       MCDI_DWORD(outbuf, GET_LINK_OUT_FCNTL));
+       }
+
+       return !efx_link_state_equal(&efx->link_state, &old_state);
+}
+
+static void efx_mcdi_phy_remove(struct efx_nic *efx)
+{
+       struct efx_mcdi_phy_data *phy_data = efx->phy_data;
+
+       efx->phy_data = NULL;
+       kfree(phy_data);
+}
+
+static void efx_mcdi_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN);
+       int rc;
+
+       ecmd->supported =
+               mcdi_to_ethtool_cap(phy_cfg->media, phy_cfg->supported_cap);
+       ecmd->advertising = efx->link_advertising;
+       ethtool_cmd_speed_set(ecmd, efx->link_state.speed);
+       ecmd->duplex = efx->link_state.fd;
+       ecmd->port = mcdi_to_ethtool_media(phy_cfg->media);
+       ecmd->phy_address = phy_cfg->port;
+       ecmd->transceiver = XCVR_INTERNAL;
+       ecmd->autoneg = !!(efx->link_advertising & ADVERTISED_Autoneg);
+       ecmd->mdio_support = (efx->mdio.mode_support &
+                             (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22));
+
+       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
+                         outbuf, sizeof(outbuf), NULL);
+       if (rc) {
+               netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
+                         __func__, rc);
+               return;
+       }
+       ecmd->lp_advertising =
+               mcdi_to_ethtool_cap(phy_cfg->media,
+                                   MCDI_DWORD(outbuf, GET_LINK_OUT_LP_CAP));
+}
+
+static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+       u32 caps;
+       int rc;
+
+       if (ecmd->autoneg) {
+               caps = (ethtool_to_mcdi_cap(ecmd->advertising) |
+                        1 << MC_CMD_PHY_CAP_AN_LBN);
+       } else if (ecmd->duplex) {
+               switch (ethtool_cmd_speed(ecmd)) {
+               case 10:    caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN;    break;
+               case 100:   caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN;   break;
+               case 1000:  caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN;  break;
+               case 10000: caps = 1 << MC_CMD_PHY_CAP_10000FDX_LBN; break;
+               default:    return -EINVAL;
+               }
+       } else {
+               switch (ethtool_cmd_speed(ecmd)) {
+               case 10:    caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN;    break;
+               case 100:   caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN;   break;
+               case 1000:  caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN;  break;
+               default:    return -EINVAL;
+               }
+       }
+
+       rc = efx_mcdi_set_link(efx, caps, efx_get_mcdi_phy_flags(efx),
+                              efx->loopback_mode, 0);
+       if (rc)
+               return rc;
+
+       if (ecmd->autoneg) {
+               efx_link_set_advertising(
+                       efx, ecmd->advertising | ADVERTISED_Autoneg);
+               phy_cfg->forced_cap = 0;
+       } else {
+               efx_link_set_advertising(efx, 0);
+               phy_cfg->forced_cap = caps;
+       }
+       return 0;
+}
+
+static int efx_mcdi_phy_test_alive(struct efx_nic *efx)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_PHY_STATE_OUT_LEN);
+       size_t outlen;
+       int rc;
+
+       BUILD_BUG_ON(MC_CMD_GET_PHY_STATE_IN_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_STATE, NULL, 0,
+                         outbuf, sizeof(outbuf), &outlen);
+       if (rc)
+               return rc;
+
+       if (outlen < MC_CMD_GET_PHY_STATE_OUT_LEN)
+               return -EIO;
+       if (MCDI_DWORD(outbuf, GET_PHY_STATE_OUT_STATE) != MC_CMD_PHY_STATE_OK)
+               return -EINVAL;
+
+       return 0;
+}
+
+static const char *const mcdi_sft9001_cable_diag_names[] = {
+       "cable.pairA.length",
+       "cable.pairB.length",
+       "cable.pairC.length",
+       "cable.pairD.length",
+       "cable.pairA.status",
+       "cable.pairB.status",
+       "cable.pairC.status",
+       "cable.pairD.status",
+};
+
+static int efx_mcdi_bist(struct efx_nic *efx, unsigned int bist_mode,
+                        int *results)
+{
+       unsigned int retry, i, count = 0;
+       size_t outlen;
+       u32 status;
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_START_BIST_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_POLL_BIST_OUT_SFT9001_LEN);
+       u8 *ptr;
+       int rc;
+
+       BUILD_BUG_ON(MC_CMD_START_BIST_OUT_LEN != 0);
+       MCDI_SET_DWORD(inbuf, START_BIST_IN_TYPE, bist_mode);
+       rc = efx_mcdi_rpc(efx, MC_CMD_START_BIST,
+                         inbuf, MC_CMD_START_BIST_IN_LEN, NULL, 0, NULL);
+       if (rc)
+               goto out;
+
+       /* Wait up to 10s for BIST to finish */
+       for (retry = 0; retry < 100; ++retry) {
+               BUILD_BUG_ON(MC_CMD_POLL_BIST_IN_LEN != 0);
+               rc = efx_mcdi_rpc(efx, MC_CMD_POLL_BIST, NULL, 0,
+                                 outbuf, sizeof(outbuf), &outlen);
+               if (rc)
+                       goto out;
+
+               status = MCDI_DWORD(outbuf, POLL_BIST_OUT_RESULT);
+               if (status != MC_CMD_POLL_BIST_RUNNING)
+                       goto finished;
+
+               msleep(100);
+       }
+
+       rc = -ETIMEDOUT;
+       goto out;
+
+finished:
+       results[count++] = (status == MC_CMD_POLL_BIST_PASSED) ? 1 : -1;
+
+       /* SFT9001 specific cable diagnostics output */
+       if (efx->phy_type == PHY_TYPE_SFT9001B &&
+           (bist_mode == MC_CMD_PHY_BIST_CABLE_SHORT ||
+            bist_mode == MC_CMD_PHY_BIST_CABLE_LONG)) {
+               ptr = MCDI_PTR(outbuf, POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A);
+               if (status == MC_CMD_POLL_BIST_PASSED &&
+                   outlen >= MC_CMD_POLL_BIST_OUT_SFT9001_LEN) {
+                       for (i = 0; i < 8; i++) {
+                               results[count + i] =
+                                       EFX_DWORD_FIELD(((efx_dword_t *)ptr)[i],
+                                                       EFX_DWORD_0);
+                       }
+               }
+               count += 8;
+       }
+       rc = count;
+
+out:
+       return rc;
+}
+
+static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results,
+                                 unsigned flags)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+       u32 mode;
+       int rc;
+
+       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) {
+               rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results);
+               if (rc < 0)
+                       return rc;
+
+               results += rc;
+       }
+
+       /* If we support both LONG and SHORT, then run each in response to
+        * break or not. Otherwise, run the one we support */
+       mode = 0;
+       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN)) {
+               if ((flags & ETH_TEST_FL_OFFLINE) &&
+                   (phy_cfg->flags &
+                    (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN)))
+                       mode = MC_CMD_PHY_BIST_CABLE_LONG;
+               else
+                       mode = MC_CMD_PHY_BIST_CABLE_SHORT;
+       } else if (phy_cfg->flags &
+                  (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))
+               mode = MC_CMD_PHY_BIST_CABLE_LONG;
+
+       if (mode != 0) {
+               rc = efx_mcdi_bist(efx, mode, results);
+               if (rc < 0)
+                       return rc;
+               results += rc;
+       }
+
+       return 0;
+}
+
+static const char *efx_mcdi_phy_test_name(struct efx_nic *efx,
+                                         unsigned int index)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+
+       if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) {
+               if (index == 0)
+                       return "bist";
+               --index;
+       }
+
+       if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN) |
+                             (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))) {
+               if (index == 0)
+                       return "cable";
+               --index;
+
+               if (efx->phy_type == PHY_TYPE_SFT9001B) {
+                       if (index < ARRAY_SIZE(mcdi_sft9001_cable_diag_names))
+                               return mcdi_sft9001_cable_diag_names[index];
+                       index -= ARRAY_SIZE(mcdi_sft9001_cable_diag_names);
+               }
+       }
+
+       return NULL;
+}
+
+#define SFP_PAGE_SIZE  128
+#define SFP_NUM_PAGES  2
+static int efx_mcdi_phy_get_module_eeprom(struct efx_nic *efx,
+                                         struct ethtool_eeprom *ee, u8 *data)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX);
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN);
+       size_t outlen;
+       int rc;
+       unsigned int payload_len;
+       unsigned int space_remaining = ee->len;
+       unsigned int page;
+       unsigned int page_off;
+       unsigned int to_copy;
+       u8 *user_data = data;
+
+       BUILD_BUG_ON(SFP_PAGE_SIZE * SFP_NUM_PAGES != ETH_MODULE_SFF_8079_LEN);
+
+       page_off = ee->offset % SFP_PAGE_SIZE;
+       page = ee->offset / SFP_PAGE_SIZE;
+
+       while (space_remaining && (page < SFP_NUM_PAGES)) {
+               MCDI_SET_DWORD(inbuf, GET_PHY_MEDIA_INFO_IN_PAGE, page);
+
+               rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_MEDIA_INFO,
+                                 inbuf, sizeof(inbuf),
+                                 outbuf, sizeof(outbuf),
+                                 &outlen);
+               if (rc)
+                       return rc;
+
+               if (outlen < (MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST +
+                             SFP_PAGE_SIZE))
+                       return -EIO;
+
+               payload_len = MCDI_DWORD(outbuf,
+                                        GET_PHY_MEDIA_INFO_OUT_DATALEN);
+               if (payload_len != SFP_PAGE_SIZE)
+                       return -EIO;
+
+               /* Copy as much as we can into data */
+               payload_len -= page_off;
+               to_copy = (space_remaining < payload_len) ?
+                       space_remaining : payload_len;
+
+               memcpy(user_data,
+                      MCDI_PTR(outbuf, GET_PHY_MEDIA_INFO_OUT_DATA) + page_off,
+                      to_copy);
+
+               space_remaining -= to_copy;
+               user_data += to_copy;
+               page_off = 0;
+               page++;
+       }
+
+       return 0;
+}
+
+static int efx_mcdi_phy_get_module_info(struct efx_nic *efx,
+                                       struct ethtool_modinfo *modinfo)
+{
+       struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
+
+       switch (phy_cfg->media) {
+       case MC_CMD_MEDIA_SFP_PLUS:
+               modinfo->type = ETH_MODULE_SFF_8079;
+               modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
+               return 0;
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+static const struct efx_phy_operations efx_mcdi_phy_ops = {
+       .probe          = efx_mcdi_phy_probe,
+       .init           = efx_port_dummy_op_int,
+       .reconfigure    = efx_mcdi_port_reconfigure,
+       .poll           = efx_mcdi_phy_poll,
+       .fini           = efx_port_dummy_op_void,
+       .remove         = efx_mcdi_phy_remove,
+       .get_settings   = efx_mcdi_phy_get_settings,
+       .set_settings   = efx_mcdi_phy_set_settings,
+       .test_alive     = efx_mcdi_phy_test_alive,
+       .run_tests      = efx_mcdi_phy_run_tests,
+       .test_name      = efx_mcdi_phy_test_name,
+       .get_module_eeprom = efx_mcdi_phy_get_module_eeprom,
+       .get_module_info = efx_mcdi_phy_get_module_info,
+};
+
+static unsigned int efx_mcdi_event_link_speed[] = {
+       [MCDI_EVENT_LINKCHANGE_SPEED_100M] = 100,
+       [MCDI_EVENT_LINKCHANGE_SPEED_1G] = 1000,
+       [MCDI_EVENT_LINKCHANGE_SPEED_10G] = 10000,
+};
+
+void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev)
+{
+       u32 flags, fcntl, speed, lpa;
+
+       speed = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_SPEED);
+       EFX_BUG_ON_PARANOID(speed >= ARRAY_SIZE(efx_mcdi_event_link_speed));
+       speed = efx_mcdi_event_link_speed[speed];
+
+       flags = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_LINK_FLAGS);
+       fcntl = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_FCNTL);
+       lpa = EFX_QWORD_FIELD(*ev, MCDI_EVENT_LINKCHANGE_LP_CAP);
+
+       /* efx->link_state is only modified by efx_mcdi_phy_get_link(),
+        * which is only run after flushing the event queues. Therefore, it
+        * is safe to modify the link state outside of the mac_lock here.
+        */
+       efx_mcdi_phy_decode_link(efx, &efx->link_state, speed, flags, fcntl);
+
+       efx_mcdi_phy_check_fcntl(efx, lpa);
+
+       efx_link_status_changed(efx);
+}
+
+int efx_mcdi_set_mac(struct efx_nic *efx)
+{
+       u32 fcntl;
+       MCDI_DECLARE_BUF(cmdbytes, MC_CMD_SET_MAC_IN_LEN);
+
+       BUILD_BUG_ON(MC_CMD_SET_MAC_OUT_LEN != 0);
+
+       memcpy(MCDI_PTR(cmdbytes, SET_MAC_IN_ADDR),
+              efx->net_dev->dev_addr, ETH_ALEN);
+
+       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU,
+                       EFX_MAX_FRAME_LEN(efx->net_dev->mtu));
+       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_DRAIN, 0);
+
+       /* Set simple MAC filter for Siena */
+       MCDI_POPULATE_DWORD_1(cmdbytes, SET_MAC_IN_REJECT,
+                             SET_MAC_IN_REJECT_UNCST, efx->unicast_filter);
+
+       switch (efx->wanted_fc) {
+       case EFX_FC_RX | EFX_FC_TX:
+               fcntl = MC_CMD_FCNTL_BIDIR;
+               break;
+       case EFX_FC_RX:
+               fcntl = MC_CMD_FCNTL_RESPOND;
+               break;
+       default:
+               fcntl = MC_CMD_FCNTL_OFF;
+               break;
+       }
+       if (efx->wanted_fc & EFX_FC_AUTO)
+               fcntl = MC_CMD_FCNTL_AUTO;
+       if (efx->fc_disable)
+               fcntl = MC_CMD_FCNTL_OFF;
+
+       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl);
+
+       return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes),
+                           NULL, 0, NULL);
+}
+
+bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
+{
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN);
+       size_t outlength;
+       int rc;
+
+       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
+                         outbuf, sizeof(outbuf), &outlength);
+       if (rc) {
+               netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
+                         __func__, rc);
+               return true;
+       }
+
+       return MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT) != 0;
+}
+
+static int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
+                             u32 dma_len, int enable, int clear)
+{
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
+       int rc;
+       int period = enable ? 1000 : 0;
+
+       BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_DMA_LEN != 0);
+
+       MCDI_SET_QWORD(inbuf, MAC_STATS_IN_DMA_ADDR, dma_addr);
+       MCDI_POPULATE_DWORD_7(inbuf, MAC_STATS_IN_CMD,
+                             MAC_STATS_IN_DMA, !!enable,
+                             MAC_STATS_IN_CLEAR, clear,
+                             MAC_STATS_IN_PERIODIC_CHANGE, 1,
+                             MAC_STATS_IN_PERIODIC_ENABLE, !!enable,
+                             MAC_STATS_IN_PERIODIC_CLEAR, 0,
+                             MAC_STATS_IN_PERIODIC_NOEVENT, 1,
+                             MAC_STATS_IN_PERIOD_MS, period);
+       MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
+
+       rc = efx_mcdi_rpc(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
+                         NULL, 0, NULL);
+       if (rc)
+               goto fail;
+
+       return 0;
+
+fail:
+       netif_err(efx, hw, efx->net_dev, "%s: %s failed rc=%d\n",
+                 __func__, enable ? "enable" : "disable", rc);
+       return rc;
+}
+
+void efx_mcdi_mac_start_stats(struct efx_nic *efx)
+{
+       __le64 *dma_stats = efx->stats_buffer.addr;
+
+       dma_stats[MC_CMD_MAC_GENERATION_END] = EFX_MC_STATS_GENERATION_INVALID;
+
+       efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr,
+                          MC_CMD_MAC_NSTATS * sizeof(u64), 1, 0);
+}
+
+void efx_mcdi_mac_stop_stats(struct efx_nic *efx)
+{
+       efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 0);
+}
+
+int efx_mcdi_port_probe(struct efx_nic *efx)
+{
+       int rc;
+
+       /* Hook in PHY operations table */
+       efx->phy_op = &efx_mcdi_phy_ops;
+
+       /* Set up MDIO structure for PHY */
+       efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
+       efx->mdio.mdio_read = efx_mcdi_mdio_read;
+       efx->mdio.mdio_write = efx_mcdi_mdio_write;
+
+       /* Fill out MDIO structure, loopback modes, and initial link state */
+       rc = efx->phy_op->probe(efx);
+       if (rc != 0)
+               return rc;
+
+       /* Allocate buffer for stats */
+       rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
+                                 MC_CMD_MAC_NSTATS * sizeof(u64), GFP_KERNEL);
+       if (rc)
+               return rc;
+       netif_dbg(efx, probe, efx->net_dev,
+                 "stats buffer at %llx (virt %p phys %llx)\n",
+                 (u64)efx->stats_buffer.dma_addr,
+                 efx->stats_buffer.addr,
+                 (u64)virt_to_phys(efx->stats_buffer.addr));
+
+       efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 1);
+
+       return 0;
+}
+
+void efx_mcdi_port_remove(struct efx_nic *efx)
+{
+       efx->phy_op->remove(efx);
+       efx_nic_free_buffer(efx, &efx->stats_buffer);
+}
index 08f825b71ac8c5a69db6995fda028626e702adae..8be9a69a61e1f6e774f81948e898f0f9cf9a9c2b 100644 (file)
  * by the Free Software Foundation, incorporated herein by reference.
  */
 
-#include <linux/bitops.h>
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
-#include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/rtnetlink.h>
 
 #include "net_driver.h"
-#include "spi.h"
 #include "efx.h"
-#include "nic.h"
-#include "mcdi.h"
-#include "mcdi_pcol.h"
-
-#define EFX_SPI_VERIFY_BUF_LEN 16
-
-struct efx_mtd_partition {
-       struct mtd_info mtd;
-       union {
-               struct {
-                       bool updating;
-                       u8 nvram_type;
-                       u16 fw_subtype;
-               } mcdi;
-               size_t offset;
-       };
-       const char *type_name;
-       char name[IFNAMSIZ + 20];
-};
-
-struct efx_mtd_ops {
-       int (*read)(struct mtd_info *mtd, loff_t start, size_t len,
-                   size_t *retlen, u8 *buffer);
-       int (*erase)(struct mtd_info *mtd, loff_t start, size_t len);
-       int (*write)(struct mtd_info *mtd, loff_t start, size_t len,
-                    size_t *retlen, const u8 *buffer);
-       int (*sync)(struct mtd_info *mtd);
-};
-
-struct efx_mtd {
-       struct list_head node;
-       struct efx_nic *efx;
-       const struct efx_spi_device *spi;
-       const char *name;
-       const struct efx_mtd_ops *ops;
-       size_t n_parts;
-       struct efx_mtd_partition part[0];
-};
-
-#define efx_for_each_partition(part, efx_mtd)                  \
-       for ((part) = &(efx_mtd)->part[0];                      \
-            (part) != &(efx_mtd)->part[(efx_mtd)->n_parts];    \
-            (part)++)
 
 #define to_efx_mtd_partition(mtd)                              \
        container_of(mtd, struct efx_mtd_partition, mtd)
 
-static int falcon_mtd_probe(struct efx_nic *efx);
-static int siena_mtd_probe(struct efx_nic *efx);
-
-/* SPI utilities */
-
-static int
-efx_spi_slow_wait(struct efx_mtd_partition *part, bool uninterruptible)
-{
-       struct efx_mtd *efx_mtd = part->mtd.priv;
-       const struct efx_spi_device *spi = efx_mtd->spi;
-       struct efx_nic *efx = efx_mtd->efx;
-       u8 status;
-       int rc, i;
-
-       /* Wait up to 4s for flash/EEPROM to finish a slow operation. */
-       for (i = 0; i < 40; i++) {
-               __set_current_state(uninterruptible ?
-                                   TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
-               schedule_timeout(HZ / 10);
-               rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
-                                   &status, sizeof(status));
-               if (rc)
-                       return rc;
-               if (!(status & SPI_STATUS_NRDY))
-                       return 0;
-               if (signal_pending(current))
-                       return -EINTR;
-       }
-       pr_err("%s: timed out waiting for %s\n", part->name, efx_mtd->name);
-       return -ETIMEDOUT;
-}
-
-static int
-efx_spi_unlock(struct efx_nic *efx, const struct efx_spi_device *spi)
-{
-       const u8 unlock_mask = (SPI_STATUS_BP2 | SPI_STATUS_BP1 |
-                               SPI_STATUS_BP0);
-       u8 status;
-       int rc;
-
-       rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
-                           &status, sizeof(status));
-       if (rc)
-               return rc;
-
-       if (!(status & unlock_mask))
-               return 0; /* already unlocked */
-
-       rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0);
-       if (rc)
-               return rc;
-       rc = falcon_spi_cmd(efx, spi, SPI_SST_EWSR, -1, NULL, NULL, 0);
-       if (rc)
-               return rc;
-
-       status &= ~unlock_mask;
-       rc = falcon_spi_cmd(efx, spi, SPI_WRSR, -1, &status,
-                           NULL, sizeof(status));
-       if (rc)
-               return rc;
-       rc = falcon_spi_wait_write(efx, spi);
-       if (rc)
-               return rc;
-
-       return 0;
-}
-
-static int
-efx_spi_erase(struct efx_mtd_partition *part, loff_t start, size_t len)
-{
-       struct efx_mtd *efx_mtd = part->mtd.priv;
-       const struct efx_spi_device *spi = efx_mtd->spi;
-       struct efx_nic *efx = efx_mtd->efx;
-       unsigned pos, block_len;
-       u8 empty[EFX_SPI_VERIFY_BUF_LEN];
-       u8 buffer[EFX_SPI_VERIFY_BUF_LEN];
-       int rc;
-
-       if (len != spi->erase_size)
-               return -EINVAL;
-
-       if (spi->erase_command == 0)
-               return -EOPNOTSUPP;
-
-       rc = efx_spi_unlock(efx, spi);
-       if (rc)
-               return rc;
-       rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0);
-       if (rc)
-               return rc;
-       rc = falcon_spi_cmd(efx, spi, spi->erase_command, start, NULL,
-                           NULL, 0);
-       if (rc)
-               return rc;
-       rc = efx_spi_slow_wait(part, false);
-
-       /* Verify the entire region has been wiped */
-       memset(empty, 0xff, sizeof(empty));
-       for (pos = 0; pos < len; pos += block_len) {
-               block_len = min(len - pos, sizeof(buffer));
-               rc = falcon_spi_read(efx, spi, start + pos, block_len,
-                                    NULL, buffer);
-               if (rc)
-                       return rc;
-               if (memcmp(empty, buffer, block_len))
-                       return -EIO;
-
-               /* Avoid locking up the system */
-               cond_resched();
-               if (signal_pending(current))
-                       return -EINTR;
-       }
-
-       return rc;
-}
-
 /* MTD interface */
 
 static int efx_mtd_erase(struct mtd_info *mtd, struct erase_info *erase)
 {
-       struct efx_mtd *efx_mtd = mtd->priv;
+       struct efx_nic *efx = mtd->priv;
        int rc;
 
-       rc = efx_mtd->ops->erase(mtd, erase->addr, erase->len);
+       rc = efx->type->mtd_erase(mtd, erase->addr, erase->len);
        if (rc == 0) {
                erase->state = MTD_ERASE_DONE;
        } else {
@@ -202,13 +40,13 @@ static int efx_mtd_erase(struct mtd_info *mtd, struct erase_info *erase)
 static void efx_mtd_sync(struct mtd_info *mtd)
 {
        struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
+       struct efx_nic *efx = mtd->priv;
        int rc;
 
-       rc = efx_mtd->ops->sync(mtd);
+       rc = efx->type->mtd_sync(mtd);
        if (rc)
                pr_err("%s: %s sync failed (%d)\n",
-                      part->name, efx_mtd->name, rc);
+                      part->name, part->dev_type_name, rc);
 }
 
 static void efx_mtd_remove_partition(struct efx_mtd_partition *part)
@@ -222,62 +60,44 @@ static void efx_mtd_remove_partition(struct efx_mtd_partition *part)
                ssleep(1);
        }
        WARN_ON(rc);
+       list_del(&part->node);
 }
 
-static void efx_mtd_remove_device(struct efx_mtd *efx_mtd)
-{
-       struct efx_mtd_partition *part;
-
-       efx_for_each_partition(part, efx_mtd)
-               efx_mtd_remove_partition(part);
-       list_del(&efx_mtd->node);
-       kfree(efx_mtd);
-}
-
-static void efx_mtd_rename_device(struct efx_mtd *efx_mtd)
-{
-       struct efx_mtd_partition *part;
-
-       efx_for_each_partition(part, efx_mtd)
-               if (efx_nic_rev(efx_mtd->efx) >= EFX_REV_SIENA_A0)
-                       snprintf(part->name, sizeof(part->name),
-                                "%s %s:%02x", efx_mtd->efx->name,
-                                part->type_name, part->mcdi.fw_subtype);
-               else
-                       snprintf(part->name, sizeof(part->name),
-                                "%s %s", efx_mtd->efx->name,
-                                part->type_name);
-}
-
-static int efx_mtd_probe_device(struct efx_nic *efx, struct efx_mtd *efx_mtd)
+int efx_mtd_add(struct efx_nic *efx, struct efx_mtd_partition *parts,
+               size_t n_parts, size_t sizeof_part)
 {
        struct efx_mtd_partition *part;
+       size_t i;
 
-       efx_mtd->efx = efx;
+       for (i = 0; i < n_parts; i++) {
+               part = (struct efx_mtd_partition *)((char *)parts +
+                                                   i * sizeof_part);
 
-       efx_mtd_rename_device(efx_mtd);
-
-       efx_for_each_partition(part, efx_mtd) {
                part->mtd.writesize = 1;
 
                part->mtd.owner = THIS_MODULE;
-               part->mtd.priv = efx_mtd;
+               part->mtd.priv = efx;
                part->mtd.name = part->name;
                part->mtd._erase = efx_mtd_erase;
-               part->mtd._read = efx_mtd->ops->read;
-               part->mtd._write = efx_mtd->ops->write;
+               part->mtd._read = efx->type->mtd_read;
+               part->mtd._write = efx->type->mtd_write;
                part->mtd._sync = efx_mtd_sync;
 
+               efx->type->mtd_rename(part);
+
                if (mtd_device_register(&part->mtd, NULL, 0))
                        goto fail;
+
+               /* Add to list in order - efx_mtd_remove() depends on this */
+               list_add_tail(&part->node, &efx->mtd_list);
        }
 
-       list_add(&efx_mtd->node, &efx->mtd_list);
        return 0;
 
 fail:
-       while (part != &efx_mtd->part[0]) {
-               --part;
+       while (i--) {
+               part = (struct efx_mtd_partition *)((char *)parts +
+                                                   i * sizeof_part);
                efx_mtd_remove_partition(part);
        }
        /* Failure is unlikely here, but probably means we're out of memory */
@@ -286,410 +106,28 @@ fail:
 
 void efx_mtd_remove(struct efx_nic *efx)
 {
-       struct efx_mtd *efx_mtd, *next;
+       struct efx_mtd_partition *parts, *part, *next;
 
        WARN_ON(efx_dev_registered(efx));
 
-       list_for_each_entry_safe(efx_mtd, next, &efx->mtd_list, node)
-               efx_mtd_remove_device(efx_mtd);
-}
-
-void efx_mtd_rename(struct efx_nic *efx)
-{
-       struct efx_mtd *efx_mtd;
-
-       ASSERT_RTNL();
-
-       list_for_each_entry(efx_mtd, &efx->mtd_list, node)
-               efx_mtd_rename_device(efx_mtd);
-}
-
-int efx_mtd_probe(struct efx_nic *efx)
-{
-       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
-               return siena_mtd_probe(efx);
-       else
-               return falcon_mtd_probe(efx);
-}
-
-/* Implementation of MTD operations for Falcon */
-
-static int falcon_mtd_read(struct mtd_info *mtd, loff_t start,
-                          size_t len, size_t *retlen, u8 *buffer)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       const struct efx_spi_device *spi = efx_mtd->spi;
-       struct efx_nic *efx = efx_mtd->efx;
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       int rc;
-
-       rc = mutex_lock_interruptible(&nic_data->spi_lock);
-       if (rc)
-               return rc;
-       rc = falcon_spi_read(efx, spi, part->offset + start, len,
-                            retlen, buffer);
-       mutex_unlock(&nic_data->spi_lock);
-       return rc;
-}
-
-static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       struct efx_nic *efx = efx_mtd->efx;
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       int rc;
-
-       rc = mutex_lock_interruptible(&nic_data->spi_lock);
-       if (rc)
-               return rc;
-       rc = efx_spi_erase(part, part->offset + start, len);
-       mutex_unlock(&nic_data->spi_lock);
-       return rc;
-}
-
-static int falcon_mtd_write(struct mtd_info *mtd, loff_t start,
-                           size_t len, size_t *retlen, const u8 *buffer)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       const struct efx_spi_device *spi = efx_mtd->spi;
-       struct efx_nic *efx = efx_mtd->efx;
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       int rc;
-
-       rc = mutex_lock_interruptible(&nic_data->spi_lock);
-       if (rc)
-               return rc;
-       rc = falcon_spi_write(efx, spi, part->offset + start, len,
-                             retlen, buffer);
-       mutex_unlock(&nic_data->spi_lock);
-       return rc;
-}
-
-static int falcon_mtd_sync(struct mtd_info *mtd)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       struct efx_nic *efx = efx_mtd->efx;
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       int rc;
-
-       mutex_lock(&nic_data->spi_lock);
-       rc = efx_spi_slow_wait(part, true);
-       mutex_unlock(&nic_data->spi_lock);
-       return rc;
-}
-
-static const struct efx_mtd_ops falcon_mtd_ops = {
-       .read   = falcon_mtd_read,
-       .erase  = falcon_mtd_erase,
-       .write  = falcon_mtd_write,
-       .sync   = falcon_mtd_sync,
-};
-
-static int falcon_mtd_probe(struct efx_nic *efx)
-{
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       struct efx_spi_device *spi;
-       struct efx_mtd *efx_mtd;
-       int rc = -ENODEV;
-
-       ASSERT_RTNL();
-
-       spi = &nic_data->spi_flash;
-       if (efx_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) {
-               efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
-                                 GFP_KERNEL);
-               if (!efx_mtd)
-                       return -ENOMEM;
-
-               efx_mtd->spi = spi;
-               efx_mtd->name = "flash";
-               efx_mtd->ops = &falcon_mtd_ops;
-
-               efx_mtd->n_parts = 1;
-               efx_mtd->part[0].mtd.type = MTD_NORFLASH;
-               efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH;
-               efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
-               efx_mtd->part[0].mtd.erasesize = spi->erase_size;
-               efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START;
-               efx_mtd->part[0].type_name = "sfc_flash_bootrom";
-
-               rc = efx_mtd_probe_device(efx, efx_mtd);
-               if (rc) {
-                       kfree(efx_mtd);
-                       return rc;
-               }
-       }
-
-       spi = &nic_data->spi_eeprom;
-       if (efx_spi_present(spi) && spi->size > EFX_EEPROM_BOOTCONFIG_START) {
-               efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
-                                 GFP_KERNEL);
-               if (!efx_mtd)
-                       return -ENOMEM;
-
-               efx_mtd->spi = spi;
-               efx_mtd->name = "EEPROM";
-               efx_mtd->ops = &falcon_mtd_ops;
-
-               efx_mtd->n_parts = 1;
-               efx_mtd->part[0].mtd.type = MTD_RAM;
-               efx_mtd->part[0].mtd.flags = MTD_CAP_RAM;
-               efx_mtd->part[0].mtd.size =
-                       min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
-                       EFX_EEPROM_BOOTCONFIG_START;
-               efx_mtd->part[0].mtd.erasesize = spi->erase_size;
-               efx_mtd->part[0].offset = EFX_EEPROM_BOOTCONFIG_START;
-               efx_mtd->part[0].type_name = "sfc_bootconfig";
-
-               rc = efx_mtd_probe_device(efx, efx_mtd);
-               if (rc) {
-                       kfree(efx_mtd);
-                       return rc;
-               }
-       }
-
-       return rc;
-}
-
-/* Implementation of MTD operations for Siena */
-
-static int siena_mtd_read(struct mtd_info *mtd, loff_t start,
-                         size_t len, size_t *retlen, u8 *buffer)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       struct efx_nic *efx = efx_mtd->efx;
-       loff_t offset = start;
-       loff_t end = min_t(loff_t, start + len, mtd->size);
-       size_t chunk;
-       int rc = 0;
-
-       while (offset < end) {
-               chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX);
-               rc = efx_mcdi_nvram_read(efx, part->mcdi.nvram_type, offset,
-                                        buffer, chunk);
-               if (rc)
-                       goto out;
-               offset += chunk;
-               buffer += chunk;
-       }
-out:
-       *retlen = offset - start;
-       return rc;
-}
-
-static int siena_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       struct efx_nic *efx = efx_mtd->efx;
-       loff_t offset = start & ~((loff_t)(mtd->erasesize - 1));
-       loff_t end = min_t(loff_t, start + len, mtd->size);
-       size_t chunk = part->mtd.erasesize;
-       int rc = 0;
-
-       if (!part->mcdi.updating) {
-               rc = efx_mcdi_nvram_update_start(efx, part->mcdi.nvram_type);
-               if (rc)
-                       goto out;
-               part->mcdi.updating = true;
-       }
-
-       /* The MCDI interface can in fact do multiple erase blocks at once;
-        * but erasing may be slow, so we make multiple calls here to avoid
-        * tripping the MCDI RPC timeout. */
-       while (offset < end) {
-               rc = efx_mcdi_nvram_erase(efx, part->mcdi.nvram_type, offset,
-                                         chunk);
-               if (rc)
-                       goto out;
-               offset += chunk;
-       }
-out:
-       return rc;
-}
-
-static int siena_mtd_write(struct mtd_info *mtd, loff_t start,
-                          size_t len, size_t *retlen, const u8 *buffer)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       struct efx_nic *efx = efx_mtd->efx;
-       loff_t offset = start;
-       loff_t end = min_t(loff_t, start + len, mtd->size);
-       size_t chunk;
-       int rc = 0;
-
-       if (!part->mcdi.updating) {
-               rc = efx_mcdi_nvram_update_start(efx, part->mcdi.nvram_type);
-               if (rc)
-                       goto out;
-               part->mcdi.updating = true;
-       }
-
-       while (offset < end) {
-               chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX);
-               rc = efx_mcdi_nvram_write(efx, part->mcdi.nvram_type, offset,
-                                         buffer, chunk);
-               if (rc)
-                       goto out;
-               offset += chunk;
-               buffer += chunk;
-       }
-out:
-       *retlen = offset - start;
-       return rc;
-}
-
-static int siena_mtd_sync(struct mtd_info *mtd)
-{
-       struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
-       struct efx_mtd *efx_mtd = mtd->priv;
-       struct efx_nic *efx = efx_mtd->efx;
-       int rc = 0;
-
-       if (part->mcdi.updating) {
-               part->mcdi.updating = false;
-               rc = efx_mcdi_nvram_update_finish(efx, part->mcdi.nvram_type);
-       }
-
-       return rc;
-}
-
-static const struct efx_mtd_ops siena_mtd_ops = {
-       .read   = siena_mtd_read,
-       .erase  = siena_mtd_erase,
-       .write  = siena_mtd_write,
-       .sync   = siena_mtd_sync,
-};
-
-struct siena_nvram_type_info {
-       int port;
-       const char *name;
-};
+       if (list_empty(&efx->mtd_list))
+               return;
 
-static const struct siena_nvram_type_info siena_nvram_types[] = {
-       [MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO]   = { 0, "sfc_dummy_phy" },
-       [MC_CMD_NVRAM_TYPE_MC_FW]               = { 0, "sfc_mcfw" },
-       [MC_CMD_NVRAM_TYPE_MC_FW_BACKUP]        = { 0, "sfc_mcfw_backup" },
-       [MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0]    = { 0, "sfc_static_cfg" },
-       [MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1]    = { 1, "sfc_static_cfg" },
-       [MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0]   = { 0, "sfc_dynamic_cfg" },
-       [MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1]   = { 1, "sfc_dynamic_cfg" },
-       [MC_CMD_NVRAM_TYPE_EXP_ROM]             = { 0, "sfc_exp_rom" },
-       [MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0]   = { 0, "sfc_exp_rom_cfg" },
-       [MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1]   = { 1, "sfc_exp_rom_cfg" },
-       [MC_CMD_NVRAM_TYPE_PHY_PORT0]           = { 0, "sfc_phy_fw" },
-       [MC_CMD_NVRAM_TYPE_PHY_PORT1]           = { 1, "sfc_phy_fw" },
-       [MC_CMD_NVRAM_TYPE_FPGA]                = { 0, "sfc_fpga" },
-};
+       parts = list_first_entry(&efx->mtd_list, struct efx_mtd_partition,
+                                node);
 
-static int siena_mtd_probe_partition(struct efx_nic *efx,
-                                    struct efx_mtd *efx_mtd,
-                                    unsigned int part_id,
-                                    unsigned int type)
-{
-       struct efx_mtd_partition *part = &efx_mtd->part[part_id];
-       const struct siena_nvram_type_info *info;
-       size_t size, erase_size;
-       bool protected;
-       int rc;
-
-       if (type >= ARRAY_SIZE(siena_nvram_types) ||
-           siena_nvram_types[type].name == NULL)
-               return -ENODEV;
-
-       info = &siena_nvram_types[type];
-
-       if (info->port != efx_port_num(efx))
-               return -ENODEV;
-
-       rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &protected);
-       if (rc)
-               return rc;
-       if (protected)
-               return -ENODEV; /* hide it */
-
-       part->mcdi.nvram_type = type;
-       part->type_name = info->name;
-
-       part->mtd.type = MTD_NORFLASH;
-       part->mtd.flags = MTD_CAP_NORFLASH;
-       part->mtd.size = size;
-       part->mtd.erasesize = erase_size;
+       list_for_each_entry_safe(part, next, &efx->mtd_list, node)
+               efx_mtd_remove_partition(part);
 
-       return 0;
+       kfree(parts);
 }
 
-static int siena_mtd_get_fw_subtypes(struct efx_nic *efx,
-                                    struct efx_mtd *efx_mtd)
+void efx_mtd_rename(struct efx_nic *efx)
 {
        struct efx_mtd_partition *part;
-       uint16_t fw_subtype_list[
-               MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM];
-       int rc;
-
-       rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list, NULL);
-       if (rc)
-               return rc;
-
-       efx_for_each_partition(part, efx_mtd)
-               part->mcdi.fw_subtype = fw_subtype_list[part->mcdi.nvram_type];
-
-       return 0;
-}
-
-static int siena_mtd_probe(struct efx_nic *efx)
-{
-       struct efx_mtd *efx_mtd;
-       int rc = -ENODEV;
-       u32 nvram_types;
-       unsigned int type;
 
        ASSERT_RTNL();
 
-       rc = efx_mcdi_nvram_types(efx, &nvram_types);
-       if (rc)
-               return rc;
-
-       efx_mtd = kzalloc(sizeof(*efx_mtd) +
-                         hweight32(nvram_types) * sizeof(efx_mtd->part[0]),
-                         GFP_KERNEL);
-       if (!efx_mtd)
-               return -ENOMEM;
-
-       efx_mtd->name = "Siena NVRAM manager";
-
-       efx_mtd->ops = &siena_mtd_ops;
-
-       type = 0;
-       efx_mtd->n_parts = 0;
-
-       while (nvram_types != 0) {
-               if (nvram_types & 1) {
-                       rc = siena_mtd_probe_partition(efx, efx_mtd,
-                                                      efx_mtd->n_parts, type);
-                       if (rc == 0)
-                               efx_mtd->n_parts++;
-                       else if (rc != -ENODEV)
-                               goto fail;
-               }
-               type++;
-               nvram_types >>= 1;
-       }
-
-       rc = siena_mtd_get_fw_subtypes(efx, efx_mtd);
-       if (rc)
-               goto fail;
-
-       rc = efx_mtd_probe_device(efx, efx_mtd);
-fail:
-       if (rc)
-               kfree(efx_mtd);
-       return rc;
+       list_for_each_entry(part, &efx->mtd_list, node)
+               efx->type->mtd_rename(part);
 }
-
index f4c7e6b67743b93eaa8d2c318705a05dd3302f8b..e85bed09b5e92ecc443acbacb7cd78b99e11d9e8 100644 (file)
 #include <linux/mutex.h>
 #include <linux/vmalloc.h>
 #include <linux/i2c.h>
+#include <linux/mtd/mtd.h>
 
 #include "enum.h"
 #include "bitfield.h"
+#include "filter.h"
 
 /**************************************************************************
  *
@@ -93,21 +95,36 @@ struct efx_ptp_data;
 struct efx_self_tests;
 
 /**
- * struct efx_special_buffer - An Efx special buffer
- * @addr: CPU base address of the buffer
+ * struct efx_buffer - A general-purpose DMA buffer
+ * @addr: host base address of the buffer
  * @dma_addr: DMA base address of the buffer
  * @len: Buffer length, in bytes
- * @index: Buffer index within controller;s buffer table
- * @entries: Number of buffer table entries
  *
- * Special buffers are used for the event queues and the TX and RX
- * descriptor queues for each channel.  They are *not* used for the
- * actual transmit and receive buffers.
+ * The NIC uses these buffers for its interrupt status registers and
+ * MAC stats dumps.
  */
-struct efx_special_buffer {
+struct efx_buffer {
        void *addr;
        dma_addr_t dma_addr;
        unsigned int len;
+};
+
+/**
+ * struct efx_special_buffer - DMA buffer entered into buffer table
+ * @buf: Standard &struct efx_buffer
+ * @index: Buffer index within controller;s buffer table
+ * @entries: Number of buffer table entries
+ *
+ * The NIC has a buffer table that maps buffers of size %EFX_BUF_SIZE.
+ * Event and descriptor rings are addressed via one or more buffer
+ * table entries (and so can be physically non-contiguous, although we
+ * currently do not take advantage of that).  On Falcon and Siena we
+ * have to take care of allocating and initialising the entries
+ * ourselves.  On later hardware this is managed by the firmware and
+ * @index and @entries are left as 0.
+ */
+struct efx_special_buffer {
+       struct efx_buffer buf;
        unsigned int index;
        unsigned int entries;
 };
@@ -169,6 +186,7 @@ struct efx_tx_buffer {
  *     variable indicates that the queue is empty.  This is to
  *     avoid cache-line ping-pong between the xmit path and the
  *     completion path.
+ * @merge_events: Number of TX merged completion events
  * @insert_count: Current insert pointer
  *     This is the number of buffers that have been added to the
  *     software ring.
@@ -205,6 +223,7 @@ struct efx_tx_queue {
        /* Members used mainly on the completion path */
        unsigned int read_count ____cacheline_aligned_in_smp;
        unsigned int old_write_count;
+       unsigned int merge_events;
 
        /* Members used only on the xmit path */
        unsigned int insert_count ____cacheline_aligned_in_smp;
@@ -244,6 +263,7 @@ struct efx_rx_buffer {
 #define EFX_RX_PKT_CSUMMED     0x0002
 #define EFX_RX_PKT_DISCARD     0x0004
 #define EFX_RX_PKT_TCP         0x0040
+#define EFX_RX_PKT_PREFIX_LEN  0x0080  /* length is in prefix only */
 
 /**
  * struct efx_rx_page_state - Page-based rx buffer state
@@ -271,7 +291,7 @@ struct efx_rx_page_state {
  * @buffer: The software buffer ring
  * @rxd: The hardware descriptor ring
  * @ptr_mask: The size of the ring minus 1.
- * @enabled: Receive queue enabled indicator.
+ * @refill_enabled: Enable refill whenever fill level is low
  * @flush_pending: Set when a RX flush is pending. Has the same lifetime as
  *     @rxq_flush_pending.
  * @added_count: Number of buffers added to the receive queue.
@@ -302,7 +322,7 @@ struct efx_rx_queue {
        struct efx_rx_buffer *buffer;
        struct efx_special_buffer rxd;
        unsigned int ptr_mask;
-       bool enabled;
+       bool refill_enabled;
        bool flush_pending;
 
        unsigned int added_count;
@@ -325,22 +345,6 @@ struct efx_rx_queue {
        unsigned int slow_fill_count;
 };
 
-/**
- * struct efx_buffer - An Efx general-purpose buffer
- * @addr: host base address of the buffer
- * @dma_addr: DMA base address of the buffer
- * @len: Buffer length, in bytes
- *
- * The NIC uses these buffers for its interrupt status registers and
- * MAC stats dumps.
- */
-struct efx_buffer {
-       void *addr;
-       dma_addr_t dma_addr;
-       unsigned int len;
-};
-
-
 enum efx_rx_alloc_method {
        RX_ALLOC_METHOD_AUTO = 0,
        RX_ALLOC_METHOD_SKB = 1,
@@ -357,12 +361,12 @@ enum efx_rx_alloc_method {
  * @efx: Associated Efx NIC
  * @channel: Channel instance number
  * @type: Channel type definition
+ * @eventq_init: Event queue initialised flag
  * @enabled: Channel enabled indicator
  * @irq: IRQ number (MSI and MSI-X only)
  * @irq_moderation: IRQ moderation value (in hardware ticks)
  * @napi_dev: Net device used with NAPI
  * @napi_str: NAPI control structure
- * @work_pending: Is work pending via NAPI?
  * @eventq: Event queue buffer
  * @eventq_mask: Event queue pointer mask
  * @eventq_read_ptr: Event queue read pointer
@@ -389,12 +393,12 @@ struct efx_channel {
        struct efx_nic *efx;
        int channel;
        const struct efx_channel_type *type;
+       bool eventq_init;
        bool enabled;
        int irq;
        unsigned int irq_moderation;
        struct net_device *napi_dev;
        struct napi_struct napi_str;
-       bool work_pending;
        struct efx_special_buffer eventq;
        unsigned int eventq_mask;
        unsigned int eventq_read_ptr;
@@ -422,6 +426,21 @@ struct efx_channel {
        struct efx_tx_queue tx_queue[EFX_TXQ_TYPES];
 };
 
+/**
+ * struct efx_msi_context - Context for each MSI
+ * @efx: The associated NIC
+ * @index: Index of the channel/IRQ
+ * @name: Name of the channel/IRQ
+ *
+ * Unlike &struct efx_channel, this is never reallocated and is always
+ * safe for the IRQ handler to access.
+ */
+struct efx_msi_context {
+       struct efx_nic *efx;
+       unsigned int index;
+       char name[IFNAMSIZ + 6];
+};
+
 /**
  * struct efx_channel_type - distinguishes traffic and extra channels
  * @handle_no_channel: Handle failure to allocate an extra channel
@@ -579,75 +598,17 @@ static inline bool efx_phy_mode_disabled(enum efx_phy_mode mode)
        return !!(mode & ~PHY_MODE_TX_DISABLED);
 }
 
-/*
- * Efx extended statistics
- *
- * Not all statistics are provided by all supported MACs.  The purpose
- * is this structure is to contain the raw statistics provided by each
- * MAC.
+/**
+ * struct efx_hw_stat_desc - Description of a hardware statistic
+ * @name: Name of the statistic as visible through ethtool, or %NULL if
+ *     it should not be exposed
+ * @dma_width: Width in bits (0 for non-DMA statistics)
+ * @offset: Offset within stats (ignored for non-DMA statistics)
  */
-struct efx_mac_stats {
-       u64 tx_bytes;
-       u64 tx_good_bytes;
-       u64 tx_bad_bytes;
-       u64 tx_packets;
-       u64 tx_bad;
-       u64 tx_pause;
-       u64 tx_control;
-       u64 tx_unicast;
-       u64 tx_multicast;
-       u64 tx_broadcast;
-       u64 tx_lt64;
-       u64 tx_64;
-       u64 tx_65_to_127;
-       u64 tx_128_to_255;
-       u64 tx_256_to_511;
-       u64 tx_512_to_1023;
-       u64 tx_1024_to_15xx;
-       u64 tx_15xx_to_jumbo;
-       u64 tx_gtjumbo;
-       u64 tx_collision;
-       u64 tx_single_collision;
-       u64 tx_multiple_collision;
-       u64 tx_excessive_collision;
-       u64 tx_deferred;
-       u64 tx_late_collision;
-       u64 tx_excessive_deferred;
-       u64 tx_non_tcpudp;
-       u64 tx_mac_src_error;
-       u64 tx_ip_src_error;
-       u64 rx_bytes;
-       u64 rx_good_bytes;
-       u64 rx_bad_bytes;
-       u64 rx_packets;
-       u64 rx_good;
-       u64 rx_bad;
-       u64 rx_pause;
-       u64 rx_control;
-       u64 rx_unicast;
-       u64 rx_multicast;
-       u64 rx_broadcast;
-       u64 rx_lt64;
-       u64 rx_64;
-       u64 rx_65_to_127;
-       u64 rx_128_to_255;
-       u64 rx_256_to_511;
-       u64 rx_512_to_1023;
-       u64 rx_1024_to_15xx;
-       u64 rx_15xx_to_jumbo;
-       u64 rx_gtjumbo;
-       u64 rx_bad_lt64;
-       u64 rx_bad_64_to_15xx;
-       u64 rx_bad_15xx_to_jumbo;
-       u64 rx_bad_gtjumbo;
-       u64 rx_overflow;
-       u64 rx_missed;
-       u64 rx_false_carrier;
-       u64 rx_symbol_error;
-       u64 rx_align_error;
-       u64 rx_length_error;
-       u64 rx_internal_error;
-       u64 rx_good_lt64;
+struct efx_hw_stat_desc {
+       const char *name;
+       u16 dma_width;
+       u16 offset;
 };
 
 /* Number of bits used in a multicast filter hash address */
@@ -662,7 +623,6 @@ union efx_multicast_hash {
        efx_oword_t oword[EFX_MCAST_HASH_ENTRIES / sizeof(efx_oword_t) / 8];
 };
 
-struct efx_filter_state;
 struct efx_vf;
 struct vfdi_status;
 
@@ -672,7 +632,6 @@ struct vfdi_status;
  * @pci_dev: The PCI device
  * @type: Controller type attributes
  * @legacy_irq: IRQ number
- * @legacy_irq_enabled: Are IRQs enabled on NIC (INT_EN_KER register)?
  * @workqueue: Workqueue for port reconfigures and the HW monitor.
  *     Work items do not hold and must not acquire RTNL.
  * @workqueue_name: Name of workqueue
@@ -689,7 +648,7 @@ struct vfdi_status;
  * @tx_queue: TX DMA queues
  * @rx_queue: RX DMA queues
  * @channel: Channels
- * @channel_name: Names for channels and their IRQs
+ * @msi_context: Context for each MSI
  * @extra_channel_types: Types of extra (non-traffic) channels that
  *     should be allocated for this NIC
  * @rxq_entries: Size of receive queues requested by user.
@@ -707,17 +666,25 @@ struct vfdi_status;
  * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
  * @rx_buffer_truesize: Amortised allocation size of an RX buffer,
  *     for use in sk_buff::truesize
+ * @rx_prefix_size: Size of RX prefix before packet data
+ * @rx_packet_hash_offset: Offset of RX flow hash from start of packet data
+ *     (valid only if @rx_prefix_size != 0; always negative)
+ * @rx_packet_len_offset: Offset of RX packet length from start of packet data
+ *     (valid only for NICs that set %EFX_RX_PKT_PREFIX_LEN; always negative)
  * @rx_hash_key: Toeplitz hash key for RSS
  * @rx_indir_table: Indirection table for RSS
  * @rx_scatter: Scatter mode enabled for receives
  * @int_error_count: Number of internal errors seen recently
  * @int_error_expire: Time at which error count will be expired
+ * @irq_soft_enabled: Are IRQs soft-enabled? If not, IRQ handler will
+ *     acknowledge but do nothing else.
  * @irq_status: Interrupt status buffer
  * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0
  * @irq_level: IRQ level/index for IRQs not triggered by an event queue
  * @selftest_work: Work item for asynchronous self-test
  * @mtd_list: List of MTDs attached to the NIC
  * @nic_data: Hardware dependent state
+ * @mcdi: Management-Controller-to-Driver Interface state
  * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode,
  *     efx_monitor() and efx_reconfigure_port()
  * @port_enabled: Port enabled indicator.
@@ -737,8 +704,10 @@ struct vfdi_status;
  * @link_advertising: Autonegotiation advertising flags
  * @link_state: Current state of the link
  * @n_link_state_changes: Number of times the link has changed state
- * @promiscuous: Promiscuous flag. Protected by netif_tx_lock.
- * @multicast_hash: Multicast hash table
+ * @unicast_filter: Flag for Falcon-arch simple unicast filter.
+ *     Protected by @mac_lock.
+ * @multicast_hash: Multicast hash table for Falcon-arch.
+ *     Protected by @mac_lock.
  * @wanted_fc: Wanted flow control flags
  * @fc_disable: When non-zero flow control is disabled. Typically used to
  *     ensure that network back pressure doesn't delay dma queue flushes.
@@ -747,6 +716,11 @@ struct vfdi_status;
  * @loopback_mode: Loopback status
  * @loopback_modes: Supported loopback mode bitmask
  * @loopback_selftest: Offline self-test private state
+ * @filter_lock: Filter table lock
+ * @filter_state: Architecture-dependent filter table state
+ * @rps_flow_id: Flow IDs of filters allocated for accelerated RFS,
+ *     indexed by filter ID
+ * @rps_expire_index: Next index to check for expiry in @rps_flow_id
  * @drain_pending: Count of RX and TX queues that haven't been flushed and drained.
  * @rxq_flush_pending: Count of number of receive queues that need to be flushed.
  *     Decremented when the efx_flush_rx_queue() is called.
@@ -771,12 +745,8 @@ struct vfdi_status;
  * @last_irq_cpu: Last CPU to handle a possible test interrupt.  This
  *     field is used by efx_test_interrupts() to verify that an
  *     interrupt has occurred.
- * @n_rx_nodesc_drop_cnt: RX no descriptor drop count
- * @mac_stats: MAC statistics. These include all statistics the MACs
- *     can provide.  Generic code converts these into a standard
- *     &struct net_device_stats.
- * @stats_lock: Statistics update lock. Serialises statistics fetches
- *     and access to @mac_stats.
+ * @stats_lock: Statistics update lock. Must be held when calling
+ *     efx_nic_type::{update,start,stop}_stats.
  *
  * This is stored in the private area of the &struct net_device.
  */
@@ -788,7 +758,6 @@ struct efx_nic {
        unsigned int port_num;
        const struct efx_nic_type *type;
        int legacy_irq;
-       bool legacy_irq_enabled;
        bool eeh_disabled_legacy_irq;
        struct workqueue_struct *workqueue;
        char workqueue_name[16];
@@ -806,7 +775,7 @@ struct efx_nic {
        unsigned long reset_pending;
 
        struct efx_channel *channel[EFX_MAX_CHANNELS];
-       char channel_name[EFX_MAX_CHANNELS][IFNAMSIZ + 6];
+       struct efx_msi_context msi_context[EFX_MAX_CHANNELS];
        const struct efx_channel_type *
        extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
 
@@ -819,6 +788,8 @@ struct efx_nic {
        unsigned rx_dc_base;
        unsigned sram_lim_qw;
        unsigned next_buffer_table;
+
+       unsigned int max_channels;
        unsigned n_channels;
        unsigned n_rx_channels;
        unsigned rss_spread;
@@ -830,6 +801,9 @@ struct efx_nic {
        unsigned int rx_page_buf_step;
        unsigned int rx_bufs_per_page;
        unsigned int rx_pages_per_batch;
+       unsigned int rx_prefix_size;
+       int rx_packet_hash_offset;
+       int rx_packet_len_offset;
        u8 rx_hash_key[40];
        u32 rx_indir_table[128];
        bool rx_scatter;
@@ -837,6 +811,7 @@ struct efx_nic {
        unsigned int_error_count;
        unsigned long int_error_expire;
 
+       bool irq_soft_enabled;
        struct efx_buffer irq_status;
        unsigned irq_zero_count;
        unsigned irq_level;
@@ -847,6 +822,7 @@ struct efx_nic {
 #endif
 
        void *nic_data;
+       struct efx_mcdi_data *mcdi;
 
        struct mutex mac_lock;
        struct work_struct mac_work;
@@ -868,7 +844,7 @@ struct efx_nic {
        struct efx_link_state link_state;
        unsigned int n_link_state_changes;
 
-       bool promiscuous;
+       bool unicast_filter;
        union efx_multicast_hash multicast_hash;
        u8 wanted_fc;
        unsigned fc_disable;
@@ -879,7 +855,12 @@ struct efx_nic {
 
        void *loopback_selftest;
 
-       struct efx_filter_state *filter_state;
+       spinlock_t filter_lock;
+       void *filter_state;
+#ifdef CONFIG_RFS_ACCEL
+       u32 *rps_flow_id;
+       unsigned int rps_expire_index;
+#endif
 
        atomic_t drain_pending;
        atomic_t rxq_flush_pending;
@@ -907,8 +888,6 @@ struct efx_nic {
        struct delayed_work monitor_work ____cacheline_aligned_in_smp;
        spinlock_t biu_lock;
        int last_irq_cpu;
-       unsigned n_rx_nodesc_drop_cnt;
-       struct efx_mac_stats mac_stats;
        spinlock_t stats_lock;
 };
 
@@ -922,8 +901,17 @@ static inline unsigned int efx_port_num(struct efx_nic *efx)
        return efx->port_num;
 }
 
+struct efx_mtd_partition {
+       struct list_head node;
+       struct mtd_info mtd;
+       const char *dev_type_name;
+       const char *type_name;
+       char name[IFNAMSIZ + 20];
+};
+
 /**
  * struct efx_nic_type - Efx device type definition
+ * @mem_map_size: Get memory BAR mapped size
  * @probe: Probe the controller
  * @remove: Free resources allocated by probe()
  * @init: Initialise the controller
@@ -938,43 +926,113 @@ static inline unsigned int efx_port_num(struct efx_nic *efx)
  * @probe_port: Probe the MAC and PHY
  * @remove_port: Free resources allocated by probe_port()
  * @handle_global_event: Handle a "global" event (may be %NULL)
+ * @fini_dmaq: Flush and finalise DMA queues (RX and TX queues)
  * @prepare_flush: Prepare the hardware for flushing the DMA queues
- * @finish_flush: Clean up after flushing the DMA queues
- * @update_stats: Update statistics not provided by event handling
+ *     (for Falcon architecture)
+ * @finish_flush: Clean up after flushing the DMA queues (for Falcon
+ *     architecture)
+ * @describe_stats: Describe statistics for ethtool
+ * @update_stats: Update statistics not provided by event handling.
+ *     Either argument may be %NULL.
  * @start_stats: Start the regular fetching of statistics
  * @stop_stats: Stop the regular fetching of statistics
  * @set_id_led: Set state of identifying LED or revert to automatic function
  * @push_irq_moderation: Apply interrupt moderation value
  * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY
+ * @prepare_enable_fc_tx: Prepare MAC to enable pause frame TX (may be %NULL)
  * @reconfigure_mac: Push MAC address, MTU, flow control and filter settings
  *     to the hardware.  Serialised by the mac_lock.
  * @check_mac_fault: Check MAC fault state. True if fault present.
  * @get_wol: Get WoL configuration from driver state
  * @set_wol: Push WoL configuration to the NIC
  * @resume_wol: Synchronise WoL state between driver and MC (e.g. after resume)
- * @test_chip: Test registers.  Should use efx_nic_test_registers(), and is
+ * @test_chip: Test registers.  May use efx_farch_test_registers(), and is
  *     expected to reset the NIC.
  * @test_nvram: Test validity of NVRAM contents
+ * @mcdi_request: Send an MCDI request with the given header and SDU.
+ *     The SDU length may be any value from 0 up to the protocol-
+ *     defined maximum, but its buffer will be padded to a multiple
+ *     of 4 bytes.
+ * @mcdi_poll_response: Test whether an MCDI response is available.
+ * @mcdi_read_response: Read the MCDI response PDU.  The offset will
+ *     be a multiple of 4.  The length may not be, but the buffer
+ *     will be padded so it is safe to round up.
+ * @mcdi_poll_reboot: Test whether the MCDI has rebooted.  If so,
+ *     return an appropriate error code for aborting any current
+ *     request; otherwise return 0.
+ * @irq_enable_master: Enable IRQs on the NIC.  Each event queue must
+ *     be separately enabled after this.
+ * @irq_test_generate: Generate a test IRQ
+ * @irq_disable_non_ev: Disable non-event IRQs on the NIC.  Each event
+ *     queue must be separately disabled before this.
+ * @irq_handle_msi: Handle MSI for a channel.  The @dev_id argument is
+ *     a pointer to the &struct efx_msi_context for the channel.
+ * @irq_handle_legacy: Handle legacy interrupt.  The @dev_id argument
+ *     is a pointer to the &struct efx_nic.
+ * @tx_probe: Allocate resources for TX queue
+ * @tx_init: Initialise TX queue on the NIC
+ * @tx_remove: Free resources for TX queue
+ * @tx_write: Write TX descriptors and doorbell
+ * @rx_push_indir_table: Write RSS indirection table to the NIC
+ * @rx_probe: Allocate resources for RX queue
+ * @rx_init: Initialise RX queue on the NIC
+ * @rx_remove: Free resources for RX queue
+ * @rx_write: Write RX descriptors and doorbell
+ * @rx_defer_refill: Generate a refill reminder event
+ * @ev_probe: Allocate resources for event queue
+ * @ev_init: Initialise event queue on the NIC
+ * @ev_fini: Deinitialise event queue on the NIC
+ * @ev_remove: Free resources for event queue
+ * @ev_process: Process events for a queue, up to the given NAPI quota
+ * @ev_read_ack: Acknowledge read events on a queue, rearming its IRQ
+ * @ev_test_generate: Generate a test event
+ * @filter_table_probe: Probe filter capabilities and set up filter software state
+ * @filter_table_restore: Restore filters removed from hardware
+ * @filter_table_remove: Remove filters from hardware and tear down software state
+ * @filter_update_rx_scatter: Update filters after change to rx scatter setting
+ * @filter_insert: add or replace a filter
+ * @filter_remove_safe: remove a filter by ID, carefully
+ * @filter_get_safe: retrieve a filter by ID, carefully
+ * @filter_clear_rx: remove RX filters by priority
+ * @filter_count_rx_used: Get the number of filters in use at a given priority
+ * @filter_get_rx_id_limit: Get maximum value of a filter id, plus 1
+ * @filter_get_rx_ids: Get list of RX filters at a given priority
+ * @filter_rfs_insert: Add or replace a filter for RFS.  This must be
+ *     atomic.  The hardware change may be asynchronous but should
+ *     not be delayed for long.  It may fail if this can't be done
+ *     atomically.
+ * @filter_rfs_expire_one: Consider expiring a filter inserted for RFS.
+ *     This must check whether the specified table entry is used by RFS
+ *     and that rps_may_expire_flow() returns true for it.
+ * @mtd_probe: Probe and add MTD partitions associated with this net device,
+ *      using efx_mtd_add()
+ * @mtd_rename: Set an MTD partition name using the net device name
+ * @mtd_read: Read from an MTD partition
+ * @mtd_erase: Erase part of an MTD partition
+ * @mtd_write: Write to an MTD partition
+ * @mtd_sync: Wait for write-back to complete on MTD partition.  This
+ *     also notifies the driver that a writer has finished using this
+ *     partition.
  * @revision: Hardware architecture revision
- * @mem_map_size: Memory BAR mapped size
  * @txd_ptr_tbl_base: TX descriptor ring base address
  * @rxd_ptr_tbl_base: RX descriptor ring base address
  * @buf_tbl_base: Buffer table base address
  * @evq_ptr_tbl_base: Event queue pointer table base address
  * @evq_rptr_tbl_base: Event queue read-pointer table base address
  * @max_dma_mask: Maximum possible DMA mask
- * @rx_buffer_hash_size: Size of hash at start of RX packet
+ * @rx_prefix_size: Size of RX prefix before packet data
+ * @rx_hash_offset: Offset of RX flow hash within prefix
  * @rx_buffer_padding: Size of padding at end of RX packet
  * @can_rx_scatter: NIC is able to scatter packet to multiple buffers
  * @max_interrupt_mode: Highest capability interrupt mode supported
  *     from &enum efx_init_mode.
- * @phys_addr_channels: Number of channels with physically addressed
- *     descriptors
  * @timer_period_max: Maximum period of interrupt timer (in ticks)
  * @offload_features: net_device feature flags for protocol offload
  *     features implemented in hardware
+ * @mcdi_max_ver: Maximum MCDI version supported
  */
 struct efx_nic_type {
+       unsigned int (*mem_map_size)(struct efx_nic *efx);
        int (*probe)(struct efx_nic *efx);
        void (*remove)(struct efx_nic *efx);
        int (*init)(struct efx_nic *efx);
@@ -987,14 +1045,18 @@ struct efx_nic_type {
        int (*probe_port)(struct efx_nic *efx);
        void (*remove_port)(struct efx_nic *efx);
        bool (*handle_global_event)(struct efx_channel *channel, efx_qword_t *);
+       int (*fini_dmaq)(struct efx_nic *efx);
        void (*prepare_flush)(struct efx_nic *efx);
        void (*finish_flush)(struct efx_nic *efx);
-       void (*update_stats)(struct efx_nic *efx);
+       size_t (*describe_stats)(struct efx_nic *efx, u8 *names);
+       size_t (*update_stats)(struct efx_nic *efx, u64 *full_stats,
+                              struct rtnl_link_stats64 *core_stats);
        void (*start_stats)(struct efx_nic *efx);
        void (*stop_stats)(struct efx_nic *efx);
        void (*set_id_led)(struct efx_nic *efx, enum efx_led_mode mode);
        void (*push_irq_moderation)(struct efx_channel *channel);
        int (*reconfigure_port)(struct efx_nic *efx);
+       void (*prepare_enable_fc_tx)(struct efx_nic *efx);
        int (*reconfigure_mac)(struct efx_nic *efx);
        bool (*check_mac_fault)(struct efx_nic *efx);
        void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol);
@@ -1002,22 +1064,89 @@ struct efx_nic_type {
        void (*resume_wol)(struct efx_nic *efx);
        int (*test_chip)(struct efx_nic *efx, struct efx_self_tests *tests);
        int (*test_nvram)(struct efx_nic *efx);
+       void (*mcdi_request)(struct efx_nic *efx,
+                            const efx_dword_t *hdr, size_t hdr_len,
+                            const efx_dword_t *sdu, size_t sdu_len);
+       bool (*mcdi_poll_response)(struct efx_nic *efx);
+       void (*mcdi_read_response)(struct efx_nic *efx, efx_dword_t *pdu,
+                                  size_t pdu_offset, size_t pdu_len);
+       int (*mcdi_poll_reboot)(struct efx_nic *efx);
+       void (*irq_enable_master)(struct efx_nic *efx);
+       void (*irq_test_generate)(struct efx_nic *efx);
+       void (*irq_disable_non_ev)(struct efx_nic *efx);
+       irqreturn_t (*irq_handle_msi)(int irq, void *dev_id);
+       irqreturn_t (*irq_handle_legacy)(int irq, void *dev_id);
+       int (*tx_probe)(struct efx_tx_queue *tx_queue);
+       void (*tx_init)(struct efx_tx_queue *tx_queue);
+       void (*tx_remove)(struct efx_tx_queue *tx_queue);
+       void (*tx_write)(struct efx_tx_queue *tx_queue);
+       void (*rx_push_indir_table)(struct efx_nic *efx);
+       int (*rx_probe)(struct efx_rx_queue *rx_queue);
+       void (*rx_init)(struct efx_rx_queue *rx_queue);
+       void (*rx_remove)(struct efx_rx_queue *rx_queue);
+       void (*rx_write)(struct efx_rx_queue *rx_queue);
+       void (*rx_defer_refill)(struct efx_rx_queue *rx_queue);
+       int (*ev_probe)(struct efx_channel *channel);
+       void (*ev_init)(struct efx_channel *channel);
+       void (*ev_fini)(struct efx_channel *channel);
+       void (*ev_remove)(struct efx_channel *channel);
+       int (*ev_process)(struct efx_channel *channel, int quota);
+       void (*ev_read_ack)(struct efx_channel *channel);
+       void (*ev_test_generate)(struct efx_channel *channel);
+       int (*filter_table_probe)(struct efx_nic *efx);
+       void (*filter_table_restore)(struct efx_nic *efx);
+       void (*filter_table_remove)(struct efx_nic *efx);
+       void (*filter_update_rx_scatter)(struct efx_nic *efx);
+       s32 (*filter_insert)(struct efx_nic *efx,
+                            struct efx_filter_spec *spec, bool replace);
+       int (*filter_remove_safe)(struct efx_nic *efx,
+                                 enum efx_filter_priority priority,
+                                 u32 filter_id);
+       int (*filter_get_safe)(struct efx_nic *efx,
+                              enum efx_filter_priority priority,
+                              u32 filter_id, struct efx_filter_spec *);
+       void (*filter_clear_rx)(struct efx_nic *efx,
+                               enum efx_filter_priority priority);
+       u32 (*filter_count_rx_used)(struct efx_nic *efx,
+                                   enum efx_filter_priority priority);
+       u32 (*filter_get_rx_id_limit)(struct efx_nic *efx);
+       s32 (*filter_get_rx_ids)(struct efx_nic *efx,
+                                enum efx_filter_priority priority,
+                                u32 *buf, u32 size);
+#ifdef CONFIG_RFS_ACCEL
+       s32 (*filter_rfs_insert)(struct efx_nic *efx,
+                                struct efx_filter_spec *spec);
+       bool (*filter_rfs_expire_one)(struct efx_nic *efx, u32 flow_id,
+                                     unsigned int index);
+#endif
+#ifdef CONFIG_SFC_MTD
+       int (*mtd_probe)(struct efx_nic *efx);
+       void (*mtd_rename)(struct efx_mtd_partition *part);
+       int (*mtd_read)(struct mtd_info *mtd, loff_t start, size_t len,
+                       size_t *retlen, u8 *buffer);
+       int (*mtd_erase)(struct mtd_info *mtd, loff_t start, size_t len);
+       int (*mtd_write)(struct mtd_info *mtd, loff_t start, size_t len,
+                        size_t *retlen, const u8 *buffer);
+       int (*mtd_sync)(struct mtd_info *mtd);
+#endif
+       void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
 
        int revision;
-       unsigned int mem_map_size;
        unsigned int txd_ptr_tbl_base;
        unsigned int rxd_ptr_tbl_base;
        unsigned int buf_tbl_base;
        unsigned int evq_ptr_tbl_base;
        unsigned int evq_rptr_tbl_base;
        u64 max_dma_mask;
-       unsigned int rx_buffer_hash_size;
+       unsigned int rx_prefix_size;
+       unsigned int rx_hash_offset;
        unsigned int rx_buffer_padding;
        bool can_rx_scatter;
        unsigned int max_interrupt_mode;
-       unsigned int phys_addr_channels;
        unsigned int timer_period_max;
        netdev_features_t offload_features;
+       int mcdi_max_ver;
+       unsigned int max_rx_ip_filters;
 };
 
 /**************************************************************************
index 56ed3bc71e00e0a4a24717e40d18918e4fd22fd6..b9b127743a077d6e725cb9042e2d0a0b470ac1ca 100644 (file)
 #include "bitfield.h"
 #include "efx.h"
 #include "nic.h"
-#include "regs.h"
+#include "farch_regs.h"
 #include "io.h"
 #include "workarounds.h"
 
 /**************************************************************************
  *
- * Configurable values
- *
- **************************************************************************
- */
-
-/* This is set to 16 for a good reason.  In summary, if larger than
- * 16, the descriptor cache holds more than a default socket
- * buffer's worth of packets (for UDP we can only have at most one
- * socket buffer's worth outstanding).  This combined with the fact
- * that we only get 1 TX event per descriptor cache means the NIC
- * goes idle.
- */
-#define TX_DC_ENTRIES 16
-#define TX_DC_ENTRIES_ORDER 1
-
-#define RX_DC_ENTRIES 64
-#define RX_DC_ENTRIES_ORDER 3
-
-/* If EFX_MAX_INT_ERRORS internal errors occur within
- * EFX_INT_ERROR_EXPIRE seconds, we consider the NIC broken and
- * disable it.
- */
-#define EFX_INT_ERROR_EXPIRE 3600
-#define EFX_MAX_INT_ERRORS 5
-
-/* Depth of RX flush request fifo */
-#define EFX_RX_FLUSH_COUNT 4
-
-/* Driver generated events */
-#define _EFX_CHANNEL_MAGIC_TEST                0x000101
-#define _EFX_CHANNEL_MAGIC_FILL                0x000102
-#define _EFX_CHANNEL_MAGIC_RX_DRAIN    0x000103
-#define _EFX_CHANNEL_MAGIC_TX_DRAIN    0x000104
-
-#define _EFX_CHANNEL_MAGIC(_code, _data)       ((_code) << 8 | (_data))
-#define _EFX_CHANNEL_MAGIC_CODE(_magic)                ((_magic) >> 8)
-
-#define EFX_CHANNEL_MAGIC_TEST(_channel)                               \
-       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TEST, (_channel)->channel)
-#define EFX_CHANNEL_MAGIC_FILL(_rx_queue)                              \
-       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_FILL,                     \
-                          efx_rx_queue_index(_rx_queue))
-#define EFX_CHANNEL_MAGIC_RX_DRAIN(_rx_queue)                          \
-       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_RX_DRAIN,                 \
-                          efx_rx_queue_index(_rx_queue))
-#define EFX_CHANNEL_MAGIC_TX_DRAIN(_tx_queue)                          \
-       _EFX_CHANNEL_MAGIC(_EFX_CHANNEL_MAGIC_TX_DRAIN,                 \
-                          (_tx_queue)->queue)
-
-static void efx_magic_event(struct efx_channel *channel, u32 magic);
-
-/**************************************************************************
- *
- * Solarstorm hardware access
- *
- **************************************************************************/
-
-static inline void efx_write_buf_tbl(struct efx_nic *efx, efx_qword_t *value,
-                                    unsigned int index)
-{
-       efx_sram_writeq(efx, efx->membase + efx->type->buf_tbl_base,
-                       value, index);
-}
-
-/* Read the current event from the event queue */
-static inline efx_qword_t *efx_event(struct efx_channel *channel,
-                                    unsigned int index)
-{
-       return ((efx_qword_t *) (channel->eventq.addr)) +
-               (index & channel->eventq_mask);
-}
-
-/* See if an event is present
- *
- * We check both the high and low dword of the event for all ones.  We
- * wrote all ones when we cleared the event, and no valid event can
- * have all ones in either its high or low dwords.  This approach is
- * robust against reordering.
- *
- * Note that using a single 64-bit comparison is incorrect; even
- * though the CPU read will be atomic, the DMA write may not be.
- */
-static inline int efx_event_present(efx_qword_t *event)
-{
-       return !(EFX_DWORD_IS_ALL_ONES(event->dword[0]) |
-                 EFX_DWORD_IS_ALL_ONES(event->dword[1]));
-}
-
-static bool efx_masked_compare_oword(const efx_oword_t *a, const efx_oword_t *b,
-                                    const efx_oword_t *mask)
-{
-       return ((a->u64[0] ^ b->u64[0]) & mask->u64[0]) ||
-               ((a->u64[1] ^ b->u64[1]) & mask->u64[1]);
-}
-
-int efx_nic_test_registers(struct efx_nic *efx,
-                          const struct efx_nic_register_test *regs,
-                          size_t n_regs)
-{
-       unsigned address = 0, i, j;
-       efx_oword_t mask, imask, original, reg, buf;
-
-       for (i = 0; i < n_regs; ++i) {
-               address = regs[i].address;
-               mask = imask = regs[i].mask;
-               EFX_INVERT_OWORD(imask);
-
-               efx_reado(efx, &original, address);
-
-               /* bit sweep on and off */
-               for (j = 0; j < 128; j++) {
-                       if (!EFX_EXTRACT_OWORD32(mask, j, j))
-                               continue;
-
-                       /* Test this testable bit can be set in isolation */
-                       EFX_AND_OWORD(reg, original, mask);
-                       EFX_SET_OWORD32(reg, j, j, 1);
-
-                       efx_writeo(efx, &reg, address);
-                       efx_reado(efx, &buf, address);
-
-                       if (efx_masked_compare_oword(&reg, &buf, &mask))
-                               goto fail;
-
-                       /* Test this testable bit can be cleared in isolation */
-                       EFX_OR_OWORD(reg, original, mask);
-                       EFX_SET_OWORD32(reg, j, j, 0);
-
-                       efx_writeo(efx, &reg, address);
-                       efx_reado(efx, &buf, address);
-
-                       if (efx_masked_compare_oword(&reg, &buf, &mask))
-                               goto fail;
-               }
-
-               efx_writeo(efx, &original, address);
-       }
-
-       return 0;
-
-fail:
-       netif_err(efx, hw, efx->net_dev,
-                 "wrote "EFX_OWORD_FMT" read "EFX_OWORD_FMT
-                 " at address 0x%x mask "EFX_OWORD_FMT"\n", EFX_OWORD_VAL(reg),
-                 EFX_OWORD_VAL(buf), address, EFX_OWORD_VAL(mask));
-       return -EIO;
-}
-
-/**************************************************************************
- *
- * Special buffer handling
- * Special buffers are used for event queues and the TX and RX
- * descriptor rings.
- *
- *************************************************************************/
-
-/*
- * Initialise a special buffer
- *
- * This will define a buffer (previously allocated via
- * efx_alloc_special_buffer()) in the buffer table, allowing
- * it to be used for event queues, descriptor rings etc.
- */
-static void
-efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
-{
-       efx_qword_t buf_desc;
-       unsigned int index;
-       dma_addr_t dma_addr;
-       int i;
-
-       EFX_BUG_ON_PARANOID(!buffer->addr);
-
-       /* Write buffer descriptors to NIC */
-       for (i = 0; i < buffer->entries; i++) {
-               index = buffer->index + i;
-               dma_addr = buffer->dma_addr + (i * EFX_BUF_SIZE);
-               netif_dbg(efx, probe, efx->net_dev,
-                         "mapping special buffer %d at %llx\n",
-                         index, (unsigned long long)dma_addr);
-               EFX_POPULATE_QWORD_3(buf_desc,
-                                    FRF_AZ_BUF_ADR_REGION, 0,
-                                    FRF_AZ_BUF_ADR_FBUF, dma_addr >> 12,
-                                    FRF_AZ_BUF_OWNER_ID_FBUF, 0);
-               efx_write_buf_tbl(efx, &buf_desc, index);
-       }
-}
-
-/* Unmaps a buffer and clears the buffer table entries */
-static void
-efx_fini_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
-{
-       efx_oword_t buf_tbl_upd;
-       unsigned int start = buffer->index;
-       unsigned int end = (buffer->index + buffer->entries - 1);
-
-       if (!buffer->entries)
-               return;
-
-       netif_dbg(efx, hw, efx->net_dev, "unmapping special buffers %d-%d\n",
-                 buffer->index, buffer->index + buffer->entries - 1);
-
-       EFX_POPULATE_OWORD_4(buf_tbl_upd,
-                            FRF_AZ_BUF_UPD_CMD, 0,
-                            FRF_AZ_BUF_CLR_CMD, 1,
-                            FRF_AZ_BUF_CLR_END_ID, end,
-                            FRF_AZ_BUF_CLR_START_ID, start);
-       efx_writeo(efx, &buf_tbl_upd, FR_AZ_BUF_TBL_UPD);
-}
-
-/*
- * Allocate a new special buffer
- *
- * This allocates memory for a new buffer, clears it and allocates a
- * new buffer ID range.  It does not write into the buffer table.
- *
- * This call will allocate 4KB buffers, since 8KB buffers can't be
- * used for event queues and descriptor rings.
- */
-static int efx_alloc_special_buffer(struct efx_nic *efx,
-                                   struct efx_special_buffer *buffer,
-                                   unsigned int len)
-{
-       len = ALIGN(len, EFX_BUF_SIZE);
-
-       buffer->addr = dma_alloc_coherent(&efx->pci_dev->dev, len,
-                                         &buffer->dma_addr, GFP_KERNEL);
-       if (!buffer->addr)
-               return -ENOMEM;
-       buffer->len = len;
-       buffer->entries = len / EFX_BUF_SIZE;
-       BUG_ON(buffer->dma_addr & (EFX_BUF_SIZE - 1));
-
-       /* Select new buffer ID */
-       buffer->index = efx->next_buffer_table;
-       efx->next_buffer_table += buffer->entries;
-#ifdef CONFIG_SFC_SRIOV
-       BUG_ON(efx_sriov_enabled(efx) &&
-              efx->vf_buftbl_base < efx->next_buffer_table);
-#endif
-
-       netif_dbg(efx, probe, efx->net_dev,
-                 "allocating special buffers %d-%d at %llx+%x "
-                 "(virt %p phys %llx)\n", buffer->index,
-                 buffer->index + buffer->entries - 1,
-                 (u64)buffer->dma_addr, len,
-                 buffer->addr, (u64)virt_to_phys(buffer->addr));
-
-       return 0;
-}
-
-static void
-efx_free_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
-{
-       if (!buffer->addr)
-               return;
-
-       netif_dbg(efx, hw, efx->net_dev,
-                 "deallocating special buffers %d-%d at %llx+%x "
-                 "(virt %p phys %llx)\n", buffer->index,
-                 buffer->index + buffer->entries - 1,
-                 (u64)buffer->dma_addr, buffer->len,
-                 buffer->addr, (u64)virt_to_phys(buffer->addr));
-
-       dma_free_coherent(&efx->pci_dev->dev, buffer->len, buffer->addr,
-                         buffer->dma_addr);
-       buffer->addr = NULL;
-       buffer->entries = 0;
-}
-
-/**************************************************************************
- *
- * Generic buffer handling
- * These buffers are used for interrupt status, MAC stats, etc.
- *
- **************************************************************************/
-
-int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
-                        unsigned int len)
-{
-       buffer->addr = dma_alloc_coherent(&efx->pci_dev->dev, len,
-                                         &buffer->dma_addr,
-                                         GFP_ATOMIC | __GFP_ZERO);
-       if (!buffer->addr)
-               return -ENOMEM;
-       buffer->len = len;
-       return 0;
-}
-
-void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
-{
-       if (buffer->addr) {
-               dma_free_coherent(&efx->pci_dev->dev, buffer->len,
-                                 buffer->addr, buffer->dma_addr);
-               buffer->addr = NULL;
-       }
-}
-
-/**************************************************************************
- *
- * TX path
- *
- **************************************************************************/
-
-/* Returns a pointer to the specified transmit descriptor in the TX
- * descriptor queue belonging to the specified channel.
- */
-static inline efx_qword_t *
-efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)
-{
-       return ((efx_qword_t *) (tx_queue->txd.addr)) + index;
-}
-
-/* This writes to the TX_DESC_WPTR; write pointer for TX descriptor ring */
-static inline void efx_notify_tx_desc(struct efx_tx_queue *tx_queue)
-{
-       unsigned write_ptr;
-       efx_dword_t reg;
-
-       write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
-       EFX_POPULATE_DWORD_1(reg, FRF_AZ_TX_DESC_WPTR_DWORD, write_ptr);
-       efx_writed_page(tx_queue->efx, &reg,
-                       FR_AZ_TX_DESC_UPD_DWORD_P0, tx_queue->queue);
-}
-
-/* Write pointer and first descriptor for TX descriptor ring */
-static inline void efx_push_tx_desc(struct efx_tx_queue *tx_queue,
-                                   const efx_qword_t *txd)
-{
-       unsigned write_ptr;
-       efx_oword_t reg;
-
-       BUILD_BUG_ON(FRF_AZ_TX_DESC_LBN != 0);
-       BUILD_BUG_ON(FR_AA_TX_DESC_UPD_KER != FR_BZ_TX_DESC_UPD_P0);
-
-       write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
-       EFX_POPULATE_OWORD_2(reg, FRF_AZ_TX_DESC_PUSH_CMD, true,
-                            FRF_AZ_TX_DESC_WPTR, write_ptr);
-       reg.qword[0] = *txd;
-       efx_writeo_page(tx_queue->efx, &reg,
-                       FR_BZ_TX_DESC_UPD_P0, tx_queue->queue);
-}
-
-static inline bool
-efx_may_push_tx_desc(struct efx_tx_queue *tx_queue, unsigned int write_count)
-{
-       unsigned empty_read_count = ACCESS_ONCE(tx_queue->empty_read_count);
-
-       if (empty_read_count == 0)
-               return false;
-
-       tx_queue->empty_read_count = 0;
-       return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID) == 0
-               && tx_queue->write_count - write_count == 1;
-}
-
-/* For each entry inserted into the software descriptor ring, create a
- * descriptor in the hardware TX descriptor ring (in host memory), and
- * write a doorbell.
- */
-void efx_nic_push_buffers(struct efx_tx_queue *tx_queue)
-{
-
-       struct efx_tx_buffer *buffer;
-       efx_qword_t *txd;
-       unsigned write_ptr;
-       unsigned old_write_count = tx_queue->write_count;
-
-       BUG_ON(tx_queue->write_count == tx_queue->insert_count);
-
-       do {
-               write_ptr = tx_queue->write_count & tx_queue->ptr_mask;
-               buffer = &tx_queue->buffer[write_ptr];
-               txd = efx_tx_desc(tx_queue, write_ptr);
-               ++tx_queue->write_count;
-
-               /* Create TX descriptor ring entry */
-               BUILD_BUG_ON(EFX_TX_BUF_CONT != 1);
-               EFX_POPULATE_QWORD_4(*txd,
-                                    FSF_AZ_TX_KER_CONT,
-                                    buffer->flags & EFX_TX_BUF_CONT,
-                                    FSF_AZ_TX_KER_BYTE_COUNT, buffer->len,
-                                    FSF_AZ_TX_KER_BUF_REGION, 0,
-                                    FSF_AZ_TX_KER_BUF_ADDR, buffer->dma_addr);
-       } while (tx_queue->write_count != tx_queue->insert_count);
-
-       wmb(); /* Ensure descriptors are written before they are fetched */
-
-       if (efx_may_push_tx_desc(tx_queue, old_write_count)) {
-               txd = efx_tx_desc(tx_queue,
-                                 old_write_count & tx_queue->ptr_mask);
-               efx_push_tx_desc(tx_queue, txd);
-               ++tx_queue->pushes;
-       } else {
-               efx_notify_tx_desc(tx_queue);
-       }
-}
-
-/* Allocate hardware resources for a TX queue */
-int efx_nic_probe_tx(struct efx_tx_queue *tx_queue)
-{
-       struct efx_nic *efx = tx_queue->efx;
-       unsigned entries;
-
-       entries = tx_queue->ptr_mask + 1;
-       return efx_alloc_special_buffer(efx, &tx_queue->txd,
-                                       entries * sizeof(efx_qword_t));
-}
-
-void efx_nic_init_tx(struct efx_tx_queue *tx_queue)
-{
-       struct efx_nic *efx = tx_queue->efx;
-       efx_oword_t reg;
-
-       /* Pin TX descriptor ring */
-       efx_init_special_buffer(efx, &tx_queue->txd);
-
-       /* Push TX descriptor ring to card */
-       EFX_POPULATE_OWORD_10(reg,
-                             FRF_AZ_TX_DESCQ_EN, 1,
-                             FRF_AZ_TX_ISCSI_DDIG_EN, 0,
-                             FRF_AZ_TX_ISCSI_HDIG_EN, 0,
-                             FRF_AZ_TX_DESCQ_BUF_BASE_ID, tx_queue->txd.index,
-                             FRF_AZ_TX_DESCQ_EVQ_ID,
-                             tx_queue->channel->channel,
-                             FRF_AZ_TX_DESCQ_OWNER_ID, 0,
-                             FRF_AZ_TX_DESCQ_LABEL, tx_queue->queue,
-                             FRF_AZ_TX_DESCQ_SIZE,
-                             __ffs(tx_queue->txd.entries),
-                             FRF_AZ_TX_DESCQ_TYPE, 0,
-                             FRF_BZ_TX_NON_IP_DROP_DIS, 1);
-
-       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
-               int csum = tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD;
-               EFX_SET_OWORD_FIELD(reg, FRF_BZ_TX_IP_CHKSM_DIS, !csum);
-               EFX_SET_OWORD_FIELD(reg, FRF_BZ_TX_TCP_CHKSM_DIS,
-                                   !csum);
-       }
-
-       efx_writeo_table(efx, &reg, efx->type->txd_ptr_tbl_base,
-                        tx_queue->queue);
-
-       if (efx_nic_rev(efx) < EFX_REV_FALCON_B0) {
-               /* Only 128 bits in this register */
-               BUILD_BUG_ON(EFX_MAX_TX_QUEUES > 128);
-
-               efx_reado(efx, &reg, FR_AA_TX_CHKSM_CFG);
-               if (tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD)
-                       __clear_bit_le(tx_queue->queue, &reg);
-               else
-                       __set_bit_le(tx_queue->queue, &reg);
-               efx_writeo(efx, &reg, FR_AA_TX_CHKSM_CFG);
-       }
-
-       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
-               EFX_POPULATE_OWORD_1(reg,
-                                    FRF_BZ_TX_PACE,
-                                    (tx_queue->queue & EFX_TXQ_TYPE_HIGHPRI) ?
-                                    FFE_BZ_TX_PACE_OFF :
-                                    FFE_BZ_TX_PACE_RESERVED);
-               efx_writeo_table(efx, &reg, FR_BZ_TX_PACE_TBL,
-                                tx_queue->queue);
-       }
-}
-
-static void efx_flush_tx_queue(struct efx_tx_queue *tx_queue)
-{
-       struct efx_nic *efx = tx_queue->efx;
-       efx_oword_t tx_flush_descq;
-
-       WARN_ON(atomic_read(&tx_queue->flush_outstanding));
-       atomic_set(&tx_queue->flush_outstanding, 1);
-
-       EFX_POPULATE_OWORD_2(tx_flush_descq,
-                            FRF_AZ_TX_FLUSH_DESCQ_CMD, 1,
-                            FRF_AZ_TX_FLUSH_DESCQ, tx_queue->queue);
-       efx_writeo(efx, &tx_flush_descq, FR_AZ_TX_FLUSH_DESCQ);
-}
-
-void efx_nic_fini_tx(struct efx_tx_queue *tx_queue)
-{
-       struct efx_nic *efx = tx_queue->efx;
-       efx_oword_t tx_desc_ptr;
-
-       /* Remove TX descriptor ring from card */
-       EFX_ZERO_OWORD(tx_desc_ptr);
-       efx_writeo_table(efx, &tx_desc_ptr, efx->type->txd_ptr_tbl_base,
-                        tx_queue->queue);
-
-       /* Unpin TX descriptor ring */
-       efx_fini_special_buffer(efx, &tx_queue->txd);
-}
-
-/* Free buffers backing TX queue */
-void efx_nic_remove_tx(struct efx_tx_queue *tx_queue)
-{
-       efx_free_special_buffer(tx_queue->efx, &tx_queue->txd);
-}
-
-/**************************************************************************
- *
- * RX path
- *
- **************************************************************************/
-
-/* Returns a pointer to the specified descriptor in the RX descriptor queue */
-static inline efx_qword_t *
-efx_rx_desc(struct efx_rx_queue *rx_queue, unsigned int index)
-{
-       return ((efx_qword_t *) (rx_queue->rxd.addr)) + index;
-}
-
-/* This creates an entry in the RX descriptor queue */
-static inline void
-efx_build_rx_desc(struct efx_rx_queue *rx_queue, unsigned index)
-{
-       struct efx_rx_buffer *rx_buf;
-       efx_qword_t *rxd;
-
-       rxd = efx_rx_desc(rx_queue, index);
-       rx_buf = efx_rx_buffer(rx_queue, index);
-       EFX_POPULATE_QWORD_3(*rxd,
-                            FSF_AZ_RX_KER_BUF_SIZE,
-                            rx_buf->len -
-                            rx_queue->efx->type->rx_buffer_padding,
-                            FSF_AZ_RX_KER_BUF_REGION, 0,
-                            FSF_AZ_RX_KER_BUF_ADDR, rx_buf->dma_addr);
-}
-
-/* This writes to the RX_DESC_WPTR register for the specified receive
- * descriptor ring.
- */
-void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue)
-{
-       struct efx_nic *efx = rx_queue->efx;
-       efx_dword_t reg;
-       unsigned write_ptr;
-
-       while (rx_queue->notified_count != rx_queue->added_count) {
-               efx_build_rx_desc(
-                       rx_queue,
-                       rx_queue->notified_count & rx_queue->ptr_mask);
-               ++rx_queue->notified_count;
-       }
-
-       wmb();
-       write_ptr = rx_queue->added_count & rx_queue->ptr_mask;
-       EFX_POPULATE_DWORD_1(reg, FRF_AZ_RX_DESC_WPTR_DWORD, write_ptr);
-       efx_writed_page(efx, &reg, FR_AZ_RX_DESC_UPD_DWORD_P0,
-                       efx_rx_queue_index(rx_queue));
-}
-
-int efx_nic_probe_rx(struct efx_rx_queue *rx_queue)
-{
-       struct efx_nic *efx = rx_queue->efx;
-       unsigned entries;
-
-       entries = rx_queue->ptr_mask + 1;
-       return efx_alloc_special_buffer(efx, &rx_queue->rxd,
-                                       entries * sizeof(efx_qword_t));
-}
-
-void efx_nic_init_rx(struct efx_rx_queue *rx_queue)
-{
-       efx_oword_t rx_desc_ptr;
-       struct efx_nic *efx = rx_queue->efx;
-       bool is_b0 = efx_nic_rev(efx) >= EFX_REV_FALCON_B0;
-       bool iscsi_digest_en = is_b0;
-       bool jumbo_en;
-
-       /* For kernel-mode queues in Falcon A1, the JUMBO flag enables
-        * DMA to continue after a PCIe page boundary (and scattering
-        * is not possible).  In Falcon B0 and Siena, it enables
-        * scatter.
-        */
-       jumbo_en = !is_b0 || efx->rx_scatter;
-
-       netif_dbg(efx, hw, efx->net_dev,
-                 "RX queue %d ring in special buffers %d-%d\n",
-                 efx_rx_queue_index(rx_queue), rx_queue->rxd.index,
-                 rx_queue->rxd.index + rx_queue->rxd.entries - 1);
-
-       rx_queue->scatter_n = 0;
-
-       /* Pin RX descriptor ring */
-       efx_init_special_buffer(efx, &rx_queue->rxd);
-
-       /* Push RX descriptor ring to card */
-       EFX_POPULATE_OWORD_10(rx_desc_ptr,
-                             FRF_AZ_RX_ISCSI_DDIG_EN, iscsi_digest_en,
-                             FRF_AZ_RX_ISCSI_HDIG_EN, iscsi_digest_en,
-                             FRF_AZ_RX_DESCQ_BUF_BASE_ID, rx_queue->rxd.index,
-                             FRF_AZ_RX_DESCQ_EVQ_ID,
-                             efx_rx_queue_channel(rx_queue)->channel,
-                             FRF_AZ_RX_DESCQ_OWNER_ID, 0,
-                             FRF_AZ_RX_DESCQ_LABEL,
-                             efx_rx_queue_index(rx_queue),
-                             FRF_AZ_RX_DESCQ_SIZE,
-                             __ffs(rx_queue->rxd.entries),
-                             FRF_AZ_RX_DESCQ_TYPE, 0 /* kernel queue */ ,
-                             FRF_AZ_RX_DESCQ_JUMBO, jumbo_en,
-                             FRF_AZ_RX_DESCQ_EN, 1);
-       efx_writeo_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base,
-                        efx_rx_queue_index(rx_queue));
-}
-
-static void efx_flush_rx_queue(struct efx_rx_queue *rx_queue)
-{
-       struct efx_nic *efx = rx_queue->efx;
-       efx_oword_t rx_flush_descq;
-
-       EFX_POPULATE_OWORD_2(rx_flush_descq,
-                            FRF_AZ_RX_FLUSH_DESCQ_CMD, 1,
-                            FRF_AZ_RX_FLUSH_DESCQ,
-                            efx_rx_queue_index(rx_queue));
-       efx_writeo(efx, &rx_flush_descq, FR_AZ_RX_FLUSH_DESCQ);
-}
-
-void efx_nic_fini_rx(struct efx_rx_queue *rx_queue)
-{
-       efx_oword_t rx_desc_ptr;
-       struct efx_nic *efx = rx_queue->efx;
-
-       /* Remove RX descriptor ring from card */
-       EFX_ZERO_OWORD(rx_desc_ptr);
-       efx_writeo_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base,
-                        efx_rx_queue_index(rx_queue));
-
-       /* Unpin RX descriptor ring */
-       efx_fini_special_buffer(efx, &rx_queue->rxd);
-}
-
-/* Free buffers backing RX queue */
-void efx_nic_remove_rx(struct efx_rx_queue *rx_queue)
-{
-       efx_free_special_buffer(rx_queue->efx, &rx_queue->rxd);
-}
-
-/**************************************************************************
- *
- * Flush handling
- *
- **************************************************************************/
-
-/* efx_nic_flush_queues() must be woken up when all flushes are completed,
- * or more RX flushes can be kicked off.
- */
-static bool efx_flush_wake(struct efx_nic *efx)
-{
-       /* Ensure that all updates are visible to efx_nic_flush_queues() */
-       smp_mb();
-
-       return (atomic_read(&efx->drain_pending) == 0 ||
-               (atomic_read(&efx->rxq_flush_outstanding) < EFX_RX_FLUSH_COUNT
-                && atomic_read(&efx->rxq_flush_pending) > 0));
-}
-
-static bool efx_check_tx_flush_complete(struct efx_nic *efx)
-{
-       bool i = true;
-       efx_oword_t txd_ptr_tbl;
-       struct efx_channel *channel;
-       struct efx_tx_queue *tx_queue;
-
-       efx_for_each_channel(channel, efx) {
-               efx_for_each_channel_tx_queue(tx_queue, channel) {
-                       efx_reado_table(efx, &txd_ptr_tbl,
-                                       FR_BZ_TX_DESC_PTR_TBL, tx_queue->queue);
-                       if (EFX_OWORD_FIELD(txd_ptr_tbl,
-                                           FRF_AZ_TX_DESCQ_FLUSH) ||
-                           EFX_OWORD_FIELD(txd_ptr_tbl,
-                                           FRF_AZ_TX_DESCQ_EN)) {
-                               netif_dbg(efx, hw, efx->net_dev,
-                                         "flush did not complete on TXQ %d\n",
-                                         tx_queue->queue);
-                               i = false;
-                       } else if (atomic_cmpxchg(&tx_queue->flush_outstanding,
-                                                 1, 0)) {
-                               /* The flush is complete, but we didn't
-                                * receive a flush completion event
-                                */
-                               netif_dbg(efx, hw, efx->net_dev,
-                                         "flush complete on TXQ %d, so drain "
-                                         "the queue\n", tx_queue->queue);
-                               /* Don't need to increment drain_pending as it
-                                * has already been incremented for the queues
-                                * which did not drain
-                                */
-                               efx_magic_event(channel,
-                                               EFX_CHANNEL_MAGIC_TX_DRAIN(
-                                                       tx_queue));
-                       }
-               }
-       }
-
-       return i;
-}
-
-/* Flush all the transmit queues, and continue flushing receive queues until
- * they're all flushed. Wait for the DRAIN events to be recieved so that there
- * are no more RX and TX events left on any channel. */
-int efx_nic_flush_queues(struct efx_nic *efx)
-{
-       unsigned timeout = msecs_to_jiffies(5000); /* 5s for all flushes and drains */
-       struct efx_channel *channel;
-       struct efx_rx_queue *rx_queue;
-       struct efx_tx_queue *tx_queue;
-       int rc = 0;
-
-       efx->type->prepare_flush(efx);
-
-       efx_for_each_channel(channel, efx) {
-               efx_for_each_channel_tx_queue(tx_queue, channel) {
-                       atomic_inc(&efx->drain_pending);
-                       efx_flush_tx_queue(tx_queue);
-               }
-               efx_for_each_channel_rx_queue(rx_queue, channel) {
-                       atomic_inc(&efx->drain_pending);
-                       rx_queue->flush_pending = true;
-                       atomic_inc(&efx->rxq_flush_pending);
-               }
-       }
-
-       while (timeout && atomic_read(&efx->drain_pending) > 0) {
-               /* If SRIOV is enabled, then offload receive queue flushing to
-                * the firmware (though we will still have to poll for
-                * completion). If that fails, fall back to the old scheme.
-                */
-               if (efx_sriov_enabled(efx)) {
-                       rc = efx_mcdi_flush_rxqs(efx);
-                       if (!rc)
-                               goto wait;
-               }
-
-               /* The hardware supports four concurrent rx flushes, each of
-                * which may need to be retried if there is an outstanding
-                * descriptor fetch
-                */
-               efx_for_each_channel(channel, efx) {
-                       efx_for_each_channel_rx_queue(rx_queue, channel) {
-                               if (atomic_read(&efx->rxq_flush_outstanding) >=
-                                   EFX_RX_FLUSH_COUNT)
-                                       break;
-
-                               if (rx_queue->flush_pending) {
-                                       rx_queue->flush_pending = false;
-                                       atomic_dec(&efx->rxq_flush_pending);
-                                       atomic_inc(&efx->rxq_flush_outstanding);
-                                       efx_flush_rx_queue(rx_queue);
-                               }
-                       }
-               }
-
-       wait:
-               timeout = wait_event_timeout(efx->flush_wq, efx_flush_wake(efx),
-                                            timeout);
-       }
-
-       if (atomic_read(&efx->drain_pending) &&
-           !efx_check_tx_flush_complete(efx)) {
-               netif_err(efx, hw, efx->net_dev, "failed to flush %d queues "
-                         "(rx %d+%d)\n", atomic_read(&efx->drain_pending),
-                         atomic_read(&efx->rxq_flush_outstanding),
-                         atomic_read(&efx->rxq_flush_pending));
-               rc = -ETIMEDOUT;
-
-               atomic_set(&efx->drain_pending, 0);
-               atomic_set(&efx->rxq_flush_pending, 0);
-               atomic_set(&efx->rxq_flush_outstanding, 0);
-       }
-
-       efx->type->finish_flush(efx);
-
-       return rc;
-}
-
-/**************************************************************************
- *
- * Event queue processing
- * Event queues are processed by per-channel tasklets.
- *
- **************************************************************************/
-
-/* Update a channel's event queue's read pointer (RPTR) register
- *
- * This writes the EVQ_RPTR_REG register for the specified channel's
- * event queue.
- */
-void efx_nic_eventq_read_ack(struct efx_channel *channel)
-{
-       efx_dword_t reg;
-       struct efx_nic *efx = channel->efx;
-
-       EFX_POPULATE_DWORD_1(reg, FRF_AZ_EVQ_RPTR,
-                            channel->eventq_read_ptr & channel->eventq_mask);
-
-       /* For Falcon A1, EVQ_RPTR_KER is documented as having a step size
-        * of 4 bytes, but it is really 16 bytes just like later revisions.
-        */
-       efx_writed(efx, &reg,
-                  efx->type->evq_rptr_tbl_base +
-                  FR_BZ_EVQ_RPTR_STEP * channel->channel);
-}
-
-/* Use HW to insert a SW defined event */
-void efx_generate_event(struct efx_nic *efx, unsigned int evq,
-                       efx_qword_t *event)
-{
-       efx_oword_t drv_ev_reg;
-
-       BUILD_BUG_ON(FRF_AZ_DRV_EV_DATA_LBN != 0 ||
-                    FRF_AZ_DRV_EV_DATA_WIDTH != 64);
-       drv_ev_reg.u32[0] = event->u32[0];
-       drv_ev_reg.u32[1] = event->u32[1];
-       drv_ev_reg.u32[2] = 0;
-       drv_ev_reg.u32[3] = 0;
-       EFX_SET_OWORD_FIELD(drv_ev_reg, FRF_AZ_DRV_EV_QID, evq);
-       efx_writeo(efx, &drv_ev_reg, FR_AZ_DRV_EV);
-}
-
-static void efx_magic_event(struct efx_channel *channel, u32 magic)
-{
-       efx_qword_t event;
-
-       EFX_POPULATE_QWORD_2(event, FSF_AZ_EV_CODE,
-                            FSE_AZ_EV_CODE_DRV_GEN_EV,
-                            FSF_AZ_DRV_GEN_EV_MAGIC, magic);
-       efx_generate_event(channel->efx, channel->channel, &event);
-}
-
-/* Handle a transmit completion event
- *
- * The NIC batches TX completion events; the message we receive is of
- * the form "complete all TX events up to this index".
- */
-static int
-efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event)
-{
-       unsigned int tx_ev_desc_ptr;
-       unsigned int tx_ev_q_label;
-       struct efx_tx_queue *tx_queue;
-       struct efx_nic *efx = channel->efx;
-       int tx_packets = 0;
-
-       if (unlikely(ACCESS_ONCE(efx->reset_pending)))
-               return 0;
-
-       if (likely(EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_COMP))) {
-               /* Transmit completion */
-               tx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_DESC_PTR);
-               tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL);
-               tx_queue = efx_channel_get_tx_queue(
-                       channel, tx_ev_q_label % EFX_TXQ_TYPES);
-               tx_packets = ((tx_ev_desc_ptr - tx_queue->read_count) &
-                             tx_queue->ptr_mask);
-               efx_xmit_done(tx_queue, tx_ev_desc_ptr);
-       } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_WQ_FF_FULL)) {
-               /* Rewrite the FIFO write pointer */
-               tx_ev_q_label = EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_Q_LABEL);
-               tx_queue = efx_channel_get_tx_queue(
-                       channel, tx_ev_q_label % EFX_TXQ_TYPES);
-
-               netif_tx_lock(efx->net_dev);
-               efx_notify_tx_desc(tx_queue);
-               netif_tx_unlock(efx->net_dev);
-       } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_PKT_ERR) &&
-                  EFX_WORKAROUND_10727(efx)) {
-               efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH);
-       } else {
-               netif_err(efx, tx_err, efx->net_dev,
-                         "channel %d unexpected TX event "
-                         EFX_QWORD_FMT"\n", channel->channel,
-                         EFX_QWORD_VAL(*event));
-       }
-
-       return tx_packets;
-}
-
-/* Detect errors included in the rx_evt_pkt_ok bit. */
-static u16 efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue,
-                               const efx_qword_t *event)
-{
-       struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
-       struct efx_nic *efx = rx_queue->efx;
-       bool rx_ev_buf_owner_id_err, rx_ev_ip_hdr_chksum_err;
-       bool rx_ev_tcp_udp_chksum_err, rx_ev_eth_crc_err;
-       bool rx_ev_frm_trunc, rx_ev_drib_nib, rx_ev_tobe_disc;
-       bool rx_ev_other_err, rx_ev_pause_frm;
-       bool rx_ev_hdr_type, rx_ev_mcast_pkt;
-       unsigned rx_ev_pkt_type;
-
-       rx_ev_hdr_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_HDR_TYPE);
-       rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_PKT);
-       rx_ev_tobe_disc = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_TOBE_DISC);
-       rx_ev_pkt_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PKT_TYPE);
-       rx_ev_buf_owner_id_err = EFX_QWORD_FIELD(*event,
-                                                FSF_AZ_RX_EV_BUF_OWNER_ID_ERR);
-       rx_ev_ip_hdr_chksum_err = EFX_QWORD_FIELD(*event,
-                                                 FSF_AZ_RX_EV_IP_HDR_CHKSUM_ERR);
-       rx_ev_tcp_udp_chksum_err = EFX_QWORD_FIELD(*event,
-                                                  FSF_AZ_RX_EV_TCP_UDP_CHKSUM_ERR);
-       rx_ev_eth_crc_err = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_ETH_CRC_ERR);
-       rx_ev_frm_trunc = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_FRM_TRUNC);
-       rx_ev_drib_nib = ((efx_nic_rev(efx) >= EFX_REV_FALCON_B0) ?
-                         0 : EFX_QWORD_FIELD(*event, FSF_AA_RX_EV_DRIB_NIB));
-       rx_ev_pause_frm = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PAUSE_FRM_ERR);
-
-       /* Every error apart from tobe_disc and pause_frm */
-       rx_ev_other_err = (rx_ev_drib_nib | rx_ev_tcp_udp_chksum_err |
-                          rx_ev_buf_owner_id_err | rx_ev_eth_crc_err |
-                          rx_ev_frm_trunc | rx_ev_ip_hdr_chksum_err);
-
-       /* Count errors that are not in MAC stats.  Ignore expected
-        * checksum errors during self-test. */
-       if (rx_ev_frm_trunc)
-               ++channel->n_rx_frm_trunc;
-       else if (rx_ev_tobe_disc)
-               ++channel->n_rx_tobe_disc;
-       else if (!efx->loopback_selftest) {
-               if (rx_ev_ip_hdr_chksum_err)
-                       ++channel->n_rx_ip_hdr_chksum_err;
-               else if (rx_ev_tcp_udp_chksum_err)
-                       ++channel->n_rx_tcp_udp_chksum_err;
-       }
-
-       /* TOBE_DISC is expected on unicast mismatches; don't print out an
-        * error message.  FRM_TRUNC indicates RXDP dropped the packet due
-        * to a FIFO overflow.
-        */
-#ifdef DEBUG
-       if (rx_ev_other_err && net_ratelimit()) {
-               netif_dbg(efx, rx_err, efx->net_dev,
-                         " RX queue %d unexpected RX event "
-                         EFX_QWORD_FMT "%s%s%s%s%s%s%s%s\n",
-                         efx_rx_queue_index(rx_queue), EFX_QWORD_VAL(*event),
-                         rx_ev_buf_owner_id_err ? " [OWNER_ID_ERR]" : "",
-                         rx_ev_ip_hdr_chksum_err ?
-                         " [IP_HDR_CHKSUM_ERR]" : "",
-                         rx_ev_tcp_udp_chksum_err ?
-                         " [TCP_UDP_CHKSUM_ERR]" : "",
-                         rx_ev_eth_crc_err ? " [ETH_CRC_ERR]" : "",
-                         rx_ev_frm_trunc ? " [FRM_TRUNC]" : "",
-                         rx_ev_drib_nib ? " [DRIB_NIB]" : "",
-                         rx_ev_tobe_disc ? " [TOBE_DISC]" : "",
-                         rx_ev_pause_frm ? " [PAUSE]" : "");
-       }
-#endif
-
-       /* The frame must be discarded if any of these are true. */
-       return (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib |
-               rx_ev_tobe_disc | rx_ev_pause_frm) ?
-               EFX_RX_PKT_DISCARD : 0;
-}
-
-/* Handle receive events that are not in-order. Return true if this
- * can be handled as a partial packet discard, false if it's more
- * serious.
- */
-static bool
-efx_handle_rx_bad_index(struct efx_rx_queue *rx_queue, unsigned index)
-{
-       struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
-       struct efx_nic *efx = rx_queue->efx;
-       unsigned expected, dropped;
-
-       if (rx_queue->scatter_n &&
-           index == ((rx_queue->removed_count + rx_queue->scatter_n - 1) &
-                     rx_queue->ptr_mask)) {
-               ++channel->n_rx_nodesc_trunc;
-               return true;
-       }
-
-       expected = rx_queue->removed_count & rx_queue->ptr_mask;
-       dropped = (index - expected) & rx_queue->ptr_mask;
-       netif_info(efx, rx_err, efx->net_dev,
-                  "dropped %d events (index=%d expected=%d)\n",
-                  dropped, index, expected);
-
-       efx_schedule_reset(efx, EFX_WORKAROUND_5676(efx) ?
-                          RESET_TYPE_RX_RECOVERY : RESET_TYPE_DISABLE);
-       return false;
-}
-
-/* Handle a packet received event
+ * Generic buffer handling
+ * These buffers are used for interrupt status, MAC stats, etc.
  *
- * The NIC gives a "discard" flag if it's a unicast packet with the
- * wrong destination address
- * Also "is multicast" and "matches multicast filter" flags can be used to
- * discard non-matching multicast packets.
- */
-static void
-efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event)
-{
-       unsigned int rx_ev_desc_ptr, rx_ev_byte_cnt;
-       unsigned int rx_ev_hdr_type, rx_ev_mcast_pkt;
-       unsigned expected_ptr;
-       bool rx_ev_pkt_ok, rx_ev_sop, rx_ev_cont;
-       u16 flags;
-       struct efx_rx_queue *rx_queue;
-       struct efx_nic *efx = channel->efx;
-
-       if (unlikely(ACCESS_ONCE(efx->reset_pending)))
-               return;
-
-       rx_ev_cont = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_JUMBO_CONT);
-       rx_ev_sop = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_SOP);
-       WARN_ON(EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_Q_LABEL) !=
-               channel->channel);
-
-       rx_queue = efx_channel_get_rx_queue(channel);
-
-       rx_ev_desc_ptr = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_DESC_PTR);
-       expected_ptr = ((rx_queue->removed_count + rx_queue->scatter_n) &
-                       rx_queue->ptr_mask);
-
-       /* Check for partial drops and other errors */
-       if (unlikely(rx_ev_desc_ptr != expected_ptr) ||
-           unlikely(rx_ev_sop != (rx_queue->scatter_n == 0))) {
-               if (rx_ev_desc_ptr != expected_ptr &&
-                   !efx_handle_rx_bad_index(rx_queue, rx_ev_desc_ptr))
-                       return;
-
-               /* Discard all pending fragments */
-               if (rx_queue->scatter_n) {
-                       efx_rx_packet(
-                               rx_queue,
-                               rx_queue->removed_count & rx_queue->ptr_mask,
-                               rx_queue->scatter_n, 0, EFX_RX_PKT_DISCARD);
-                       rx_queue->removed_count += rx_queue->scatter_n;
-                       rx_queue->scatter_n = 0;
-               }
-
-               /* Return if there is no new fragment */
-               if (rx_ev_desc_ptr != expected_ptr)
-                       return;
-
-               /* Discard new fragment if not SOP */
-               if (!rx_ev_sop) {
-                       efx_rx_packet(
-                               rx_queue,
-                               rx_queue->removed_count & rx_queue->ptr_mask,
-                               1, 0, EFX_RX_PKT_DISCARD);
-                       ++rx_queue->removed_count;
-                       return;
-               }
-       }
-
-       ++rx_queue->scatter_n;
-       if (rx_ev_cont)
-               return;
-
-       rx_ev_byte_cnt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_BYTE_CNT);
-       rx_ev_pkt_ok = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_PKT_OK);
-       rx_ev_hdr_type = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_HDR_TYPE);
-
-       if (likely(rx_ev_pkt_ok)) {
-               /* If packet is marked as OK then we can rely on the
-                * hardware checksum and classification.
-                */
-               flags = 0;
-               switch (rx_ev_hdr_type) {
-               case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP:
-                       flags |= EFX_RX_PKT_TCP;
-                       /* fall through */
-               case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP:
-                       flags |= EFX_RX_PKT_CSUMMED;
-                       /* fall through */
-               case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER:
-               case FSE_AZ_RX_EV_HDR_TYPE_OTHER:
-                       break;
-               }
-       } else {
-               flags = efx_handle_rx_not_ok(rx_queue, event);
-       }
-
-       /* Detect multicast packets that didn't match the filter */
-       rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_PKT);
-       if (rx_ev_mcast_pkt) {
-               unsigned int rx_ev_mcast_hash_match =
-                       EFX_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_HASH_MATCH);
-
-               if (unlikely(!rx_ev_mcast_hash_match)) {
-                       ++channel->n_rx_mcast_mismatch;
-                       flags |= EFX_RX_PKT_DISCARD;
-               }
-       }
-
-       channel->irq_mod_score += 2;
-
-       /* Handle received packet */
-       efx_rx_packet(rx_queue,
-                     rx_queue->removed_count & rx_queue->ptr_mask,
-                     rx_queue->scatter_n, rx_ev_byte_cnt, flags);
-       rx_queue->removed_count += rx_queue->scatter_n;
-       rx_queue->scatter_n = 0;
-}
-
-/* If this flush done event corresponds to a &struct efx_tx_queue, then
- * send an %EFX_CHANNEL_MAGIC_TX_DRAIN event to drain the event queue
- * of all transmit completions.
- */
-static void
-efx_handle_tx_flush_done(struct efx_nic *efx, efx_qword_t *event)
-{
-       struct efx_tx_queue *tx_queue;
-       int qid;
-
-       qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA);
-       if (qid < EFX_TXQ_TYPES * efx->n_tx_channels) {
-               tx_queue = efx_get_tx_queue(efx, qid / EFX_TXQ_TYPES,
-                                           qid % EFX_TXQ_TYPES);
-               if (atomic_cmpxchg(&tx_queue->flush_outstanding, 1, 0)) {
-                       efx_magic_event(tx_queue->channel,
-                                       EFX_CHANNEL_MAGIC_TX_DRAIN(tx_queue));
-               }
-       }
-}
-
-/* If this flush done event corresponds to a &struct efx_rx_queue: If the flush
- * was succesful then send an %EFX_CHANNEL_MAGIC_RX_DRAIN, otherwise add
- * the RX queue back to the mask of RX queues in need of flushing.
- */
-static void
-efx_handle_rx_flush_done(struct efx_nic *efx, efx_qword_t *event)
-{
-       struct efx_channel *channel;
-       struct efx_rx_queue *rx_queue;
-       int qid;
-       bool failed;
-
-       qid = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_DESCQ_ID);
-       failed = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL);
-       if (qid >= efx->n_channels)
-               return;
-       channel = efx_get_channel(efx, qid);
-       if (!efx_channel_has_rx_queue(channel))
-               return;
-       rx_queue = efx_channel_get_rx_queue(channel);
-
-       if (failed) {
-               netif_info(efx, hw, efx->net_dev,
-                          "RXQ %d flush retry\n", qid);
-               rx_queue->flush_pending = true;
-               atomic_inc(&efx->rxq_flush_pending);
-       } else {
-               efx_magic_event(efx_rx_queue_channel(rx_queue),
-                               EFX_CHANNEL_MAGIC_RX_DRAIN(rx_queue));
-       }
-       atomic_dec(&efx->rxq_flush_outstanding);
-       if (efx_flush_wake(efx))
-               wake_up(&efx->flush_wq);
-}
-
-static void
-efx_handle_drain_event(struct efx_channel *channel)
-{
-       struct efx_nic *efx = channel->efx;
-
-       WARN_ON(atomic_read(&efx->drain_pending) == 0);
-       atomic_dec(&efx->drain_pending);
-       if (efx_flush_wake(efx))
-               wake_up(&efx->flush_wq);
-}
-
-static void
-efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event)
-{
-       struct efx_nic *efx = channel->efx;
-       struct efx_rx_queue *rx_queue =
-               efx_channel_has_rx_queue(channel) ?
-               efx_channel_get_rx_queue(channel) : NULL;
-       unsigned magic, code;
-
-       magic = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC);
-       code = _EFX_CHANNEL_MAGIC_CODE(magic);
-
-       if (magic == EFX_CHANNEL_MAGIC_TEST(channel)) {
-               channel->event_test_cpu = raw_smp_processor_id();
-       } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_FILL(rx_queue)) {
-               /* The queue must be empty, so we won't receive any rx
-                * events, so efx_process_channel() won't refill the
-                * queue. Refill it here */
-               efx_fast_push_rx_descriptors(rx_queue);
-       } else if (rx_queue && magic == EFX_CHANNEL_MAGIC_RX_DRAIN(rx_queue)) {
-               rx_queue->enabled = false;
-               efx_handle_drain_event(channel);
-       } else if (code == _EFX_CHANNEL_MAGIC_TX_DRAIN) {
-               efx_handle_drain_event(channel);
-       } else {
-               netif_dbg(efx, hw, efx->net_dev, "channel %d received "
-                         "generated event "EFX_QWORD_FMT"\n",
-                         channel->channel, EFX_QWORD_VAL(*event));
-       }
-}
+ **************************************************************************/
 
-static void
-efx_handle_driver_event(struct efx_channel *channel, efx_qword_t *event)
+int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
+                        unsigned int len, gfp_t gfp_flags)
 {
-       struct efx_nic *efx = channel->efx;
-       unsigned int ev_sub_code;
-       unsigned int ev_sub_data;
-
-       ev_sub_code = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBCODE);
-       ev_sub_data = EFX_QWORD_FIELD(*event, FSF_AZ_DRIVER_EV_SUBDATA);
-
-       switch (ev_sub_code) {
-       case FSE_AZ_TX_DESCQ_FLS_DONE_EV:
-               netif_vdbg(efx, hw, efx->net_dev, "channel %d TXQ %d flushed\n",
-                          channel->channel, ev_sub_data);
-               efx_handle_tx_flush_done(efx, event);
-               efx_sriov_tx_flush_done(efx, event);
-               break;
-       case FSE_AZ_RX_DESCQ_FLS_DONE_EV:
-               netif_vdbg(efx, hw, efx->net_dev, "channel %d RXQ %d flushed\n",
-                          channel->channel, ev_sub_data);
-               efx_handle_rx_flush_done(efx, event);
-               efx_sriov_rx_flush_done(efx, event);
-               break;
-       case FSE_AZ_EVQ_INIT_DONE_EV:
-               netif_dbg(efx, hw, efx->net_dev,
-                         "channel %d EVQ %d initialised\n",
-                         channel->channel, ev_sub_data);
-               break;
-       case FSE_AZ_SRM_UPD_DONE_EV:
-               netif_vdbg(efx, hw, efx->net_dev,
-                          "channel %d SRAM update done\n", channel->channel);
-               break;
-       case FSE_AZ_WAKE_UP_EV:
-               netif_vdbg(efx, hw, efx->net_dev,
-                          "channel %d RXQ %d wakeup event\n",
-                          channel->channel, ev_sub_data);
-               break;
-       case FSE_AZ_TIMER_EV:
-               netif_vdbg(efx, hw, efx->net_dev,
-                          "channel %d RX queue %d timer expired\n",
-                          channel->channel, ev_sub_data);
-               break;
-       case FSE_AA_RX_RECOVER_EV:
-               netif_err(efx, rx_err, efx->net_dev,
-                         "channel %d seen DRIVER RX_RESET event. "
-                       "Resetting.\n", channel->channel);
-               atomic_inc(&efx->rx_reset);
-               efx_schedule_reset(efx,
-                                  EFX_WORKAROUND_6555(efx) ?
-                                  RESET_TYPE_RX_RECOVERY :
-                                  RESET_TYPE_DISABLE);
-               break;
-       case FSE_BZ_RX_DSC_ERROR_EV:
-               if (ev_sub_data < EFX_VI_BASE) {
-                       netif_err(efx, rx_err, efx->net_dev,
-                                 "RX DMA Q %d reports descriptor fetch error."
-                                 " RX Q %d is disabled.\n", ev_sub_data,
-                                 ev_sub_data);
-                       efx_schedule_reset(efx, RESET_TYPE_RX_DESC_FETCH);
-               } else
-                       efx_sriov_desc_fetch_err(efx, ev_sub_data);
-               break;
-       case FSE_BZ_TX_DSC_ERROR_EV:
-               if (ev_sub_data < EFX_VI_BASE) {
-                       netif_err(efx, tx_err, efx->net_dev,
-                                 "TX DMA Q %d reports descriptor fetch error."
-                                 " TX Q %d is disabled.\n", ev_sub_data,
-                                 ev_sub_data);
-                       efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH);
-               } else
-                       efx_sriov_desc_fetch_err(efx, ev_sub_data);
-               break;
-       default:
-               netif_vdbg(efx, hw, efx->net_dev,
-                          "channel %d unknown driver event code %d "
-                          "data %04x\n", channel->channel, ev_sub_code,
-                          ev_sub_data);
-               break;
-       }
+       buffer->addr = dma_alloc_coherent(&efx->pci_dev->dev, len,
+                                         &buffer->dma_addr,
+                                         gfp_flags | __GFP_ZERO);
+       if (!buffer->addr)
+               return -ENOMEM;
+       buffer->len = len;
+       return 0;
 }
 
-int efx_nic_process_eventq(struct efx_channel *channel, int budget)
+void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
 {
-       struct efx_nic *efx = channel->efx;
-       unsigned int read_ptr;
-       efx_qword_t event, *p_event;
-       int ev_code;
-       int tx_packets = 0;
-       int spent = 0;
-
-       read_ptr = channel->eventq_read_ptr;
-
-       for (;;) {
-               p_event = efx_event(channel, read_ptr);
-               event = *p_event;
-
-               if (!efx_event_present(&event))
-                       /* End of events */
-                       break;
-
-               netif_vdbg(channel->efx, intr, channel->efx->net_dev,
-                          "channel %d event is "EFX_QWORD_FMT"\n",
-                          channel->channel, EFX_QWORD_VAL(event));
-
-               /* Clear this event by marking it all ones */
-               EFX_SET_QWORD(*p_event);
-
-               ++read_ptr;
-
-               ev_code = EFX_QWORD_FIELD(event, FSF_AZ_EV_CODE);
-
-               switch (ev_code) {
-               case FSE_AZ_EV_CODE_RX_EV:
-                       efx_handle_rx_event(channel, &event);
-                       if (++spent == budget)
-                               goto out;
-                       break;
-               case FSE_AZ_EV_CODE_TX_EV:
-                       tx_packets += efx_handle_tx_event(channel, &event);
-                       if (tx_packets > efx->txq_entries) {
-                               spent = budget;
-                               goto out;
-                       }
-                       break;
-               case FSE_AZ_EV_CODE_DRV_GEN_EV:
-                       efx_handle_generated_event(channel, &event);
-                       break;
-               case FSE_AZ_EV_CODE_DRIVER_EV:
-                       efx_handle_driver_event(channel, &event);
-                       break;
-               case FSE_CZ_EV_CODE_USER_EV:
-                       efx_sriov_event(channel, &event);
-                       break;
-               case FSE_CZ_EV_CODE_MCDI_EV:
-                       efx_mcdi_process_event(channel, &event);
-                       break;
-               case FSE_AZ_EV_CODE_GLOBAL_EV:
-                       if (efx->type->handle_global_event &&
-                           efx->type->handle_global_event(channel, &event))
-                               break;
-                       /* else fall through */
-               default:
-                       netif_err(channel->efx, hw, channel->efx->net_dev,
-                                 "channel %d unknown event type %d (data "
-                                 EFX_QWORD_FMT ")\n", channel->channel,
-                                 ev_code, EFX_QWORD_VAL(event));
-               }
+       if (buffer->addr) {
+               dma_free_coherent(&efx->pci_dev->dev, buffer->len,
+                                 buffer->addr, buffer->dma_addr);
+               buffer->addr = NULL;
        }
-
-out:
-       channel->eventq_read_ptr = read_ptr;
-       return spent;
 }
 
 /* Check whether an event is present in the eventq at the current
@@ -1382,323 +59,18 @@ bool efx_nic_event_present(struct efx_channel *channel)
        return efx_event_present(efx_event(channel, channel->eventq_read_ptr));
 }
 
-/* Allocate buffer table entries for event queue */
-int efx_nic_probe_eventq(struct efx_channel *channel)
-{
-       struct efx_nic *efx = channel->efx;
-       unsigned entries;
-
-       entries = channel->eventq_mask + 1;
-       return efx_alloc_special_buffer(efx, &channel->eventq,
-                                       entries * sizeof(efx_qword_t));
-}
-
-void efx_nic_init_eventq(struct efx_channel *channel)
-{
-       efx_oword_t reg;
-       struct efx_nic *efx = channel->efx;
-
-       netif_dbg(efx, hw, efx->net_dev,
-                 "channel %d event queue in special buffers %d-%d\n",
-                 channel->channel, channel->eventq.index,
-                 channel->eventq.index + channel->eventq.entries - 1);
-
-       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0) {
-               EFX_POPULATE_OWORD_3(reg,
-                                    FRF_CZ_TIMER_Q_EN, 1,
-                                    FRF_CZ_HOST_NOTIFY_MODE, 0,
-                                    FRF_CZ_TIMER_MODE, FFE_CZ_TIMER_MODE_DIS);
-               efx_writeo_table(efx, &reg, FR_BZ_TIMER_TBL, channel->channel);
-       }
-
-       /* Pin event queue buffer */
-       efx_init_special_buffer(efx, &channel->eventq);
-
-       /* Fill event queue with all ones (i.e. empty events) */
-       memset(channel->eventq.addr, 0xff, channel->eventq.len);
-
-       /* Push event queue to card */
-       EFX_POPULATE_OWORD_3(reg,
-                            FRF_AZ_EVQ_EN, 1,
-                            FRF_AZ_EVQ_SIZE, __ffs(channel->eventq.entries),
-                            FRF_AZ_EVQ_BUF_BASE_ID, channel->eventq.index);
-       efx_writeo_table(efx, &reg, efx->type->evq_ptr_tbl_base,
-                        channel->channel);
-
-       efx->type->push_irq_moderation(channel);
-}
-
-void efx_nic_fini_eventq(struct efx_channel *channel)
-{
-       efx_oword_t reg;
-       struct efx_nic *efx = channel->efx;
-
-       /* Remove event queue from card */
-       EFX_ZERO_OWORD(reg);
-       efx_writeo_table(efx, &reg, efx->type->evq_ptr_tbl_base,
-                        channel->channel);
-       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
-               efx_writeo_table(efx, &reg, FR_BZ_TIMER_TBL, channel->channel);
-
-       /* Unpin event queue */
-       efx_fini_special_buffer(efx, &channel->eventq);
-}
-
-/* Free buffers backing event queue */
-void efx_nic_remove_eventq(struct efx_channel *channel)
-{
-       efx_free_special_buffer(channel->efx, &channel->eventq);
-}
-
-
 void efx_nic_event_test_start(struct efx_channel *channel)
 {
        channel->event_test_cpu = -1;
        smp_wmb();
-       efx_magic_event(channel, EFX_CHANNEL_MAGIC_TEST(channel));
-}
-
-void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue)
-{
-       efx_magic_event(efx_rx_queue_channel(rx_queue),
-                       EFX_CHANNEL_MAGIC_FILL(rx_queue));
-}
-
-/**************************************************************************
- *
- * Hardware interrupts
- * The hardware interrupt handler does very little work; all the event
- * queue processing is carried out by per-channel tasklets.
- *
- **************************************************************************/
-
-/* Enable/disable/generate interrupts */
-static inline void efx_nic_interrupts(struct efx_nic *efx,
-                                     bool enabled, bool force)
-{
-       efx_oword_t int_en_reg_ker;
-
-       EFX_POPULATE_OWORD_3(int_en_reg_ker,
-                            FRF_AZ_KER_INT_LEVE_SEL, efx->irq_level,
-                            FRF_AZ_KER_INT_KER, force,
-                            FRF_AZ_DRV_INT_EN_KER, enabled);
-       efx_writeo(efx, &int_en_reg_ker, FR_AZ_INT_EN_KER);
-}
-
-void efx_nic_enable_interrupts(struct efx_nic *efx)
-{
-       EFX_ZERO_OWORD(*((efx_oword_t *) efx->irq_status.addr));
-       wmb(); /* Ensure interrupt vector is clear before interrupts enabled */
-
-       efx_nic_interrupts(efx, true, false);
-}
-
-void efx_nic_disable_interrupts(struct efx_nic *efx)
-{
-       /* Disable interrupts */
-       efx_nic_interrupts(efx, false, false);
+       channel->efx->type->ev_test_generate(channel);
 }
 
-/* Generate a test interrupt
- * Interrupt must already have been enabled, otherwise nasty things
- * may happen.
- */
 void efx_nic_irq_test_start(struct efx_nic *efx)
 {
        efx->last_irq_cpu = -1;
        smp_wmb();
-       efx_nic_interrupts(efx, true, true);
-}
-
-/* Process a fatal interrupt
- * Disable bus mastering ASAP and schedule a reset
- */
-irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx)
-{
-       struct falcon_nic_data *nic_data = efx->nic_data;
-       efx_oword_t *int_ker = efx->irq_status.addr;
-       efx_oword_t fatal_intr;
-       int error, mem_perr;
-
-       efx_reado(efx, &fatal_intr, FR_AZ_FATAL_INTR_KER);
-       error = EFX_OWORD_FIELD(fatal_intr, FRF_AZ_FATAL_INTR);
-
-       netif_err(efx, hw, efx->net_dev, "SYSTEM ERROR "EFX_OWORD_FMT" status "
-                 EFX_OWORD_FMT ": %s\n", EFX_OWORD_VAL(*int_ker),
-                 EFX_OWORD_VAL(fatal_intr),
-                 error ? "disabling bus mastering" : "no recognised error");
-
-       /* If this is a memory parity error dump which blocks are offending */
-       mem_perr = (EFX_OWORD_FIELD(fatal_intr, FRF_AZ_MEM_PERR_INT_KER) ||
-                   EFX_OWORD_FIELD(fatal_intr, FRF_AZ_SRM_PERR_INT_KER));
-       if (mem_perr) {
-               efx_oword_t reg;
-               efx_reado(efx, &reg, FR_AZ_MEM_STAT);
-               netif_err(efx, hw, efx->net_dev,
-                         "SYSTEM ERROR: memory parity error "EFX_OWORD_FMT"\n",
-                         EFX_OWORD_VAL(reg));
-       }
-
-       /* Disable both devices */
-       pci_clear_master(efx->pci_dev);
-       if (efx_nic_is_dual_func(efx))
-               pci_clear_master(nic_data->pci_dev2);
-       efx_nic_disable_interrupts(efx);
-
-       /* Count errors and reset or disable the NIC accordingly */
-       if (efx->int_error_count == 0 ||
-           time_after(jiffies, efx->int_error_expire)) {
-               efx->int_error_count = 0;
-               efx->int_error_expire =
-                       jiffies + EFX_INT_ERROR_EXPIRE * HZ;
-       }
-       if (++efx->int_error_count < EFX_MAX_INT_ERRORS) {
-               netif_err(efx, hw, efx->net_dev,
-                         "SYSTEM ERROR - reset scheduled\n");
-               efx_schedule_reset(efx, RESET_TYPE_INT_ERROR);
-       } else {
-               netif_err(efx, hw, efx->net_dev,
-                         "SYSTEM ERROR - max number of errors seen."
-                         "NIC will be disabled\n");
-               efx_schedule_reset(efx, RESET_TYPE_DISABLE);
-       }
-
-       return IRQ_HANDLED;
-}
-
-/* Handle a legacy interrupt
- * Acknowledges the interrupt and schedule event queue processing.
- */
-static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id)
-{
-       struct efx_nic *efx = dev_id;
-       efx_oword_t *int_ker = efx->irq_status.addr;
-       irqreturn_t result = IRQ_NONE;
-       struct efx_channel *channel;
-       efx_dword_t reg;
-       u32 queues;
-       int syserr;
-
-       /* Could this be ours?  If interrupts are disabled then the
-        * channel state may not be valid.
-        */
-       if (!efx->legacy_irq_enabled)
-               return result;
-
-       /* Read the ISR which also ACKs the interrupts */
-       efx_readd(efx, &reg, FR_BZ_INT_ISR0);
-       queues = EFX_EXTRACT_DWORD(reg, 0, 31);
-
-       /* Legacy interrupts are disabled too late by the EEH kernel
-        * code. Disable them earlier.
-        * If an EEH error occurred, the read will have returned all ones.
-        */
-       if (EFX_DWORD_IS_ALL_ONES(reg) && efx_try_recovery(efx) &&
-           !efx->eeh_disabled_legacy_irq) {
-               disable_irq_nosync(efx->legacy_irq);
-               efx->eeh_disabled_legacy_irq = true;
-       }
-
-       /* Handle non-event-queue sources */
-       if (queues & (1U << efx->irq_level)) {
-               syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
-               if (unlikely(syserr))
-                       return efx_nic_fatal_interrupt(efx);
-               efx->last_irq_cpu = raw_smp_processor_id();
-       }
-
-       if (queues != 0) {
-               if (EFX_WORKAROUND_15783(efx))
-                       efx->irq_zero_count = 0;
-
-               /* Schedule processing of any interrupting queues */
-               efx_for_each_channel(channel, efx) {
-                       if (queues & 1)
-                               efx_schedule_channel_irq(channel);
-                       queues >>= 1;
-               }
-               result = IRQ_HANDLED;
-
-       } else if (EFX_WORKAROUND_15783(efx)) {
-               efx_qword_t *event;
-
-               /* We can't return IRQ_HANDLED more than once on seeing ISR=0
-                * because this might be a shared interrupt. */
-               if (efx->irq_zero_count++ == 0)
-                       result = IRQ_HANDLED;
-
-               /* Ensure we schedule or rearm all event queues */
-               efx_for_each_channel(channel, efx) {
-                       event = efx_event(channel, channel->eventq_read_ptr);
-                       if (efx_event_present(event))
-                               efx_schedule_channel_irq(channel);
-                       else
-                               efx_nic_eventq_read_ack(channel);
-               }
-       }
-
-       if (result == IRQ_HANDLED)
-               netif_vdbg(efx, intr, efx->net_dev,
-                          "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n",
-                          irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg));
-
-       return result;
-}
-
-/* Handle an MSI interrupt
- *
- * Handle an MSI hardware interrupt.  This routine schedules event
- * queue processing.  No interrupt acknowledgement cycle is necessary.
- * Also, we never need to check that the interrupt is for us, since
- * MSI interrupts cannot be shared.
- */
-static irqreturn_t efx_msi_interrupt(int irq, void *dev_id)
-{
-       struct efx_channel *channel = *(struct efx_channel **)dev_id;
-       struct efx_nic *efx = channel->efx;
-       efx_oword_t *int_ker = efx->irq_status.addr;
-       int syserr;
-
-       netif_vdbg(efx, intr, efx->net_dev,
-                  "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
-                  irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
-
-       /* Handle non-event-queue sources */
-       if (channel->channel == efx->irq_level) {
-               syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
-               if (unlikely(syserr))
-                       return efx_nic_fatal_interrupt(efx);
-               efx->last_irq_cpu = raw_smp_processor_id();
-       }
-
-       /* Schedule processing of the channel */
-       efx_schedule_channel_irq(channel);
-
-       return IRQ_HANDLED;
-}
-
-
-/* Setup RSS indirection table.
- * This maps from the hash value of the packet to RXQ
- */
-void efx_nic_push_rx_indir_table(struct efx_nic *efx)
-{
-       size_t i = 0;
-       efx_dword_t dword;
-
-       if (efx_nic_rev(efx) < EFX_REV_FALCON_B0)
-               return;
-
-       BUILD_BUG_ON(ARRAY_SIZE(efx->rx_indir_table) !=
-                    FR_BZ_RX_INDIRECTION_TBL_ROWS);
-
-       for (i = 0; i < FR_BZ_RX_INDIRECTION_TBL_ROWS; i++) {
-               EFX_POPULATE_DWORD_1(dword, FRF_BZ_IT_QUEUE,
-                                    efx->rx_indir_table[i]);
-               efx_writed(efx, &dword,
-                          FR_BZ_RX_INDIRECTION_TBL +
-                          FR_BZ_RX_INDIRECTION_TBL_STEP * i);
-       }
+       efx->type->irq_test_generate(efx);
 }
 
 /* Hook interrupt handler(s)
@@ -1711,13 +83,8 @@ int efx_nic_init_interrupt(struct efx_nic *efx)
        int rc;
 
        if (!EFX_INT_MODE_USE_MSI(efx)) {
-               irq_handler_t handler;
-               if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0)
-                       handler = efx_legacy_interrupt;
-               else
-                       handler = falcon_legacy_interrupt_a1;
-
-               rc = request_irq(efx->legacy_irq, handler, IRQF_SHARED,
+               rc = request_irq(efx->legacy_irq,
+                                efx->type->irq_handle_legacy, IRQF_SHARED,
                                 efx->name, efx);
                if (rc) {
                        netif_err(efx, drv, efx->net_dev,
@@ -1742,10 +109,10 @@ int efx_nic_init_interrupt(struct efx_nic *efx)
        /* Hook MSI or MSI-X interrupt */
        n_irqs = 0;
        efx_for_each_channel(channel, efx) {
-               rc = request_irq(channel->irq, efx_msi_interrupt,
+               rc = request_irq(channel->irq, efx->type->irq_handle_msi,
                                 IRQF_PROBE_SHARED, /* Not shared */
-                                efx->channel_name[channel->channel],
-                                &efx->channel[channel->channel]);
+                                efx->msi_context[channel->channel].name,
+                                &efx->msi_context[channel->channel]);
                if (rc) {
                        netif_err(efx, drv, efx->net_dev,
                                  "failed to hook IRQ %d\n", channel->irq);
@@ -1774,7 +141,7 @@ int efx_nic_init_interrupt(struct efx_nic *efx)
        efx_for_each_channel(channel, efx) {
                if (n_irqs-- == 0)
                        break;
-               free_irq(channel->irq, &efx->channel[channel->channel]);
+               free_irq(channel->irq, &efx->msi_context[channel->channel]);
        }
  fail1:
        return rc;
@@ -1783,7 +150,6 @@ int efx_nic_init_interrupt(struct efx_nic *efx)
 void efx_nic_fini_interrupt(struct efx_nic *efx)
 {
        struct efx_channel *channel;
-       efx_oword_t reg;
 
 #ifdef CONFIG_RFS_ACCEL
        free_irq_cpu_rmap(efx->net_dev->rx_cpu_rmap);
@@ -1792,167 +158,13 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
 
        /* Disable MSI/MSI-X interrupts */
        efx_for_each_channel(channel, efx)
-               free_irq(channel->irq, &efx->channel[channel->channel]);
-
-       /* ACK legacy interrupt */
-       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0)
-               efx_reado(efx, &reg, FR_BZ_INT_ISR0);
-       else
-               falcon_irq_ack_a1(efx);
+               free_irq(channel->irq, &efx->msi_context[channel->channel]);
 
        /* Disable legacy interrupt */
        if (efx->legacy_irq)
                free_irq(efx->legacy_irq, efx);
 }
 
-/* Looks at available SRAM resources and works out how many queues we
- * can support, and where things like descriptor caches should live.
- *
- * SRAM is split up as follows:
- * 0                          buftbl entries for channels
- * efx->vf_buftbl_base        buftbl entries for SR-IOV
- * efx->rx_dc_base            RX descriptor caches
- * efx->tx_dc_base            TX descriptor caches
- */
-void efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw)
-{
-       unsigned vi_count, buftbl_min;
-
-       /* Account for the buffer table entries backing the datapath channels
-        * and the descriptor caches for those channels.
-        */
-       buftbl_min = ((efx->n_rx_channels * EFX_MAX_DMAQ_SIZE +
-                      efx->n_tx_channels * EFX_TXQ_TYPES * EFX_MAX_DMAQ_SIZE +
-                      efx->n_channels * EFX_MAX_EVQ_SIZE)
-                     * sizeof(efx_qword_t) / EFX_BUF_SIZE);
-       vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES);
-
-#ifdef CONFIG_SFC_SRIOV
-       if (efx_sriov_wanted(efx)) {
-               unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit;
-
-               efx->vf_buftbl_base = buftbl_min;
-
-               vi_dc_entries = RX_DC_ENTRIES + TX_DC_ENTRIES;
-               vi_count = max(vi_count, EFX_VI_BASE);
-               buftbl_free = (sram_lim_qw - buftbl_min -
-                              vi_count * vi_dc_entries);
-
-               entries_per_vf = ((vi_dc_entries + EFX_VF_BUFTBL_PER_VI) *
-                                 efx_vf_size(efx));
-               vf_limit = min(buftbl_free / entries_per_vf,
-                              (1024U - EFX_VI_BASE) >> efx->vi_scale);
-
-               if (efx->vf_count > vf_limit) {
-                       netif_err(efx, probe, efx->net_dev,
-                                 "Reducing VF count from from %d to %d\n",
-                                 efx->vf_count, vf_limit);
-                       efx->vf_count = vf_limit;
-               }
-               vi_count += efx->vf_count * efx_vf_size(efx);
-       }
-#endif
-
-       efx->tx_dc_base = sram_lim_qw - vi_count * TX_DC_ENTRIES;
-       efx->rx_dc_base = efx->tx_dc_base - vi_count * RX_DC_ENTRIES;
-}
-
-u32 efx_nic_fpga_ver(struct efx_nic *efx)
-{
-       efx_oword_t altera_build;
-       efx_reado(efx, &altera_build, FR_AZ_ALTERA_BUILD);
-       return EFX_OWORD_FIELD(altera_build, FRF_AZ_ALTERA_BUILD_VER);
-}
-
-void efx_nic_init_common(struct efx_nic *efx)
-{
-       efx_oword_t temp;
-
-       /* Set positions of descriptor caches in SRAM. */
-       EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_TX_DC_BASE_ADR, efx->tx_dc_base);
-       efx_writeo(efx, &temp, FR_AZ_SRM_TX_DC_CFG);
-       EFX_POPULATE_OWORD_1(temp, FRF_AZ_SRM_RX_DC_BASE_ADR, efx->rx_dc_base);
-       efx_writeo(efx, &temp, FR_AZ_SRM_RX_DC_CFG);
-
-       /* Set TX descriptor cache size. */
-       BUILD_BUG_ON(TX_DC_ENTRIES != (8 << TX_DC_ENTRIES_ORDER));
-       EFX_POPULATE_OWORD_1(temp, FRF_AZ_TX_DC_SIZE, TX_DC_ENTRIES_ORDER);
-       efx_writeo(efx, &temp, FR_AZ_TX_DC_CFG);
-
-       /* Set RX descriptor cache size.  Set low watermark to size-8, as
-        * this allows most efficient prefetching.
-        */
-       BUILD_BUG_ON(RX_DC_ENTRIES != (8 << RX_DC_ENTRIES_ORDER));
-       EFX_POPULATE_OWORD_1(temp, FRF_AZ_RX_DC_SIZE, RX_DC_ENTRIES_ORDER);
-       efx_writeo(efx, &temp, FR_AZ_RX_DC_CFG);
-       EFX_POPULATE_OWORD_1(temp, FRF_AZ_RX_DC_PF_LWM, RX_DC_ENTRIES - 8);
-       efx_writeo(efx, &temp, FR_AZ_RX_DC_PF_WM);
-
-       /* Program INT_KER address */
-       EFX_POPULATE_OWORD_2(temp,
-                            FRF_AZ_NORM_INT_VEC_DIS_KER,
-                            EFX_INT_MODE_USE_MSI(efx),
-                            FRF_AZ_INT_ADR_KER, efx->irq_status.dma_addr);
-       efx_writeo(efx, &temp, FR_AZ_INT_ADR_KER);
-
-       if (EFX_WORKAROUND_17213(efx) && !EFX_INT_MODE_USE_MSI(efx))
-               /* Use an interrupt level unused by event queues */
-               efx->irq_level = 0x1f;
-       else
-               /* Use a valid MSI-X vector */
-               efx->irq_level = 0;
-
-       /* Enable all the genuinely fatal interrupts.  (They are still
-        * masked by the overall interrupt mask, controlled by
-        * falcon_interrupts()).
-        *
-        * Note: All other fatal interrupts are enabled
-        */
-       EFX_POPULATE_OWORD_3(temp,
-                            FRF_AZ_ILL_ADR_INT_KER_EN, 1,
-                            FRF_AZ_RBUF_OWN_INT_KER_EN, 1,
-                            FRF_AZ_TBUF_OWN_INT_KER_EN, 1);
-       if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
-               EFX_SET_OWORD_FIELD(temp, FRF_CZ_SRAM_PERR_INT_P_KER_EN, 1);
-       EFX_INVERT_OWORD(temp);
-       efx_writeo(efx, &temp, FR_AZ_FATAL_INTR_KER);
-
-       efx_nic_push_rx_indir_table(efx);
-
-       /* Disable the ugly timer-based TX DMA backoff and allow TX DMA to be
-        * controlled by the RX FIFO fill level. Set arbitration to one pkt/Q.
-        */
-       efx_reado(efx, &temp, FR_AZ_TX_RESERVED);
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_RX_SPACER, 0xfe);
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_RX_SPACER_EN, 1);
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_ONE_PKT_PER_Q, 1);
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PUSH_EN, 1);
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_DIS_NON_IP_EV, 1);
-       /* Enable SW_EV to inherit in char driver - assume harmless here */
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_SOFT_EVT_EN, 1);
-       /* Prefetch threshold 2 => fetch when descriptor cache half empty */
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PREF_THRESHOLD, 2);
-       /* Disable hardware watchdog which can misfire */
-       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PREF_WD_TMR, 0x3fffff);
-       /* Squash TX of packets of 16 bytes or less */
-       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0)
-               EFX_SET_OWORD_FIELD(temp, FRF_BZ_TX_FLUSH_MIN_LEN_EN, 1);
-       efx_writeo(efx, &temp, FR_AZ_TX_RESERVED);
-
-       if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0) {
-               EFX_POPULATE_OWORD_4(temp,
-                                    /* Default values */
-                                    FRF_BZ_TX_PACE_SB_NOT_AF, 0x15,
-                                    FRF_BZ_TX_PACE_SB_AF, 0xb,
-                                    FRF_BZ_TX_PACE_FB_BASE, 0,
-                                    /* Allow large pace values in the
-                                     * fast bin. */
-                                    FRF_BZ_TX_PACE_BIN_TH,
-                                    FFE_BZ_TX_PACE_RESERVED);
-               efx_writeo(efx, &temp, FR_BZ_TX_PACE);
-       }
-}
-
 /* Register dump */
 
 #define REGISTER_REVISION_A    1
@@ -2217,3 +429,86 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf)
                }
        }
 }
+
+/**
+ * efx_nic_describe_stats - Describe supported statistics for ethtool
+ * @desc: Array of &struct efx_hw_stat_desc describing the statistics
+ * @count: Length of the @desc array
+ * @mask: Bitmask of which elements of @desc are enabled
+ * @names: Buffer to copy names to, or %NULL.  The names are copied
+ *     starting at intervals of %ETH_GSTRING_LEN bytes.
+ *
+ * Returns the number of visible statistics, i.e. the number of set
+ * bits in the first @count bits of @mask for which a name is defined.
+ */
+size_t efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
+                             const unsigned long *mask, u8 *names)
+{
+       size_t visible = 0;
+       size_t index;
+
+       for_each_set_bit(index, mask, count) {
+               if (desc[index].name) {
+                       if (names) {
+                               strlcpy(names, desc[index].name,
+                                       ETH_GSTRING_LEN);
+                               names += ETH_GSTRING_LEN;
+                       }
+                       ++visible;
+               }
+       }
+
+       return visible;
+}
+
+/**
+ * efx_nic_update_stats - Convert statistics DMA buffer to array of u64
+ * @desc: Array of &struct efx_hw_stat_desc describing the DMA buffer
+ *     layout.  DMA widths of 0, 16, 32 and 64 are supported; where
+ *     the width is specified as 0 the corresponding element of
+ *     @stats is not updated.
+ * @count: Length of the @desc array
+ * @mask: Bitmask of which elements of @desc are enabled
+ * @stats: Buffer to update with the converted statistics.  The length
+ *     of this array must be at least the number of set bits in the
+ *     first @count bits of @mask.
+ * @dma_buf: DMA buffer containing hardware statistics
+ * @accumulate: If set, the converted values will be added rather than
+ *     directly stored to the corresponding elements of @stats
+ */
+void efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
+                         const unsigned long *mask,
+                         u64 *stats, const void *dma_buf, bool accumulate)
+{
+       size_t index;
+
+       for_each_set_bit(index, mask, count) {
+               if (desc[index].dma_width) {
+                       const void *addr = dma_buf + desc[index].offset;
+                       u64 val;
+
+                       switch (desc[index].dma_width) {
+                       case 16:
+                               val = le16_to_cpup((__le16 *)addr);
+                               break;
+                       case 32:
+                               val = le32_to_cpup((__le32 *)addr);
+                               break;
+                       case 64:
+                               val = le64_to_cpup((__le64 *)addr);
+                               break;
+                       default:
+                               WARN_ON(1);
+                               val = 0;
+                               break;
+                       }
+
+                       if (accumulate)
+                               *stats += val;
+                       else
+                               *stats = val;
+               }
+
+               ++stats;
+       }
+}
index d63c2991a75105767487aa66ae1cbe284fc6abc1..9afbf3616b4bc28015cc01d863274c7c87b700df 100644 (file)
@@ -16,7 +16,6 @@
 #include "net_driver.h"
 #include "efx.h"
 #include "mcdi.h"
-#include "spi.h"
 
 /*
  * Falcon hardware control
@@ -34,7 +33,7 @@ static inline int efx_nic_rev(struct efx_nic *efx)
        return efx->type->revision;
 }
 
-extern u32 efx_nic_fpga_ver(struct efx_nic *efx);
+extern u32 efx_farch_fpga_ver(struct efx_nic *efx);
 
 /* NIC has two interlinked PCI functions for the same port. */
 static inline bool efx_nic_is_dual_func(struct efx_nic *efx)
@@ -42,6 +41,65 @@ static inline bool efx_nic_is_dual_func(struct efx_nic *efx)
        return efx_nic_rev(efx) < EFX_REV_FALCON_B0;
 }
 
+/* Read the current event from the event queue */
+static inline efx_qword_t *efx_event(struct efx_channel *channel,
+                                    unsigned int index)
+{
+       return ((efx_qword_t *) (channel->eventq.buf.addr)) +
+               (index & channel->eventq_mask);
+}
+
+/* See if an event is present
+ *
+ * We check both the high and low dword of the event for all ones.  We
+ * wrote all ones when we cleared the event, and no valid event can
+ * have all ones in either its high or low dwords.  This approach is
+ * robust against reordering.
+ *
+ * Note that using a single 64-bit comparison is incorrect; even
+ * though the CPU read will be atomic, the DMA write may not be.
+ */
+static inline int efx_event_present(efx_qword_t *event)
+{
+       return !(EFX_DWORD_IS_ALL_ONES(event->dword[0]) |
+                 EFX_DWORD_IS_ALL_ONES(event->dword[1]));
+}
+
+/* Returns a pointer to the specified transmit descriptor in the TX
+ * descriptor queue belonging to the specified channel.
+ */
+static inline efx_qword_t *
+efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)
+{
+       return ((efx_qword_t *) (tx_queue->txd.buf.addr)) + index;
+}
+
+/* Decide whether to push a TX descriptor to the NIC vs merely writing
+ * the doorbell.  This can reduce latency when we are adding a single
+ * descriptor to an empty queue, but is otherwise pointless.  Further,
+ * Falcon and Siena have hardware bugs (SF bug 33851) that may be
+ * triggered if we don't check this.
+ */
+static inline bool efx_nic_may_push_tx_desc(struct efx_tx_queue *tx_queue,
+                                           unsigned int write_count)
+{
+       unsigned empty_read_count = ACCESS_ONCE(tx_queue->empty_read_count);
+
+       if (empty_read_count == 0)
+               return false;
+
+       tx_queue->empty_read_count = 0;
+       return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID) == 0
+               && tx_queue->write_count - write_count == 1;
+}
+
+/* Returns a pointer to the specified descriptor in the RX descriptor queue */
+static inline efx_qword_t *
+efx_rx_desc(struct efx_rx_queue *rx_queue, unsigned int index)
+{
+       return ((efx_qword_t *) (rx_queue->rxd.buf.addr)) + index;
+}
+
 enum {
        PHY_TYPE_NONE = 0,
        PHY_TYPE_TXC43128 = 1,
@@ -59,9 +117,6 @@ enum {
         (1 << LOOPBACK_XGXS) |                 \
         (1 << LOOPBACK_XAUI))
 
-#define FALCON_GMAC_LOOPBACKS                  \
-       (1 << LOOPBACK_GMAC)
-
 /* Alignment of PCIe DMA boundaries (4KB) */
 #define EFX_PAGE_SIZE  4096
 /* Size and alignment of buffer table entries (same) */
@@ -104,14 +159,97 @@ struct falcon_board {
        struct i2c_client *hwmon_client, *ioexp_client;
 };
 
+/**
+ * struct falcon_spi_device - a Falcon SPI (Serial Peripheral Interface) device
+ * @device_id:         Controller's id for the device
+ * @size:              Size (in bytes)
+ * @addr_len:          Number of address bytes in read/write commands
+ * @munge_address:     Flag whether addresses should be munged.
+ *     Some devices with 9-bit addresses (e.g. AT25040A EEPROM)
+ *     use bit 3 of the command byte as address bit A8, rather
+ *     than having a two-byte address.  If this flag is set, then
+ *     commands should be munged in this way.
+ * @erase_command:     Erase command (or 0 if sector erase not needed).
+ * @erase_size:                Erase sector size (in bytes)
+ *     Erase commands affect sectors with this size and alignment.
+ *     This must be a power of two.
+ * @block_size:                Write block size (in bytes).
+ *     Write commands are limited to blocks with this size and alignment.
+ */
+struct falcon_spi_device {
+       int device_id;
+       unsigned int size;
+       unsigned int addr_len;
+       unsigned int munge_address:1;
+       u8 erase_command;
+       unsigned int erase_size;
+       unsigned int block_size;
+};
+
+static inline bool falcon_spi_present(const struct falcon_spi_device *spi)
+{
+       return spi->size != 0;
+}
+
+enum {
+       FALCON_STAT_tx_bytes,
+       FALCON_STAT_tx_packets,
+       FALCON_STAT_tx_pause,
+       FALCON_STAT_tx_control,
+       FALCON_STAT_tx_unicast,
+       FALCON_STAT_tx_multicast,
+       FALCON_STAT_tx_broadcast,
+       FALCON_STAT_tx_lt64,
+       FALCON_STAT_tx_64,
+       FALCON_STAT_tx_65_to_127,
+       FALCON_STAT_tx_128_to_255,
+       FALCON_STAT_tx_256_to_511,
+       FALCON_STAT_tx_512_to_1023,
+       FALCON_STAT_tx_1024_to_15xx,
+       FALCON_STAT_tx_15xx_to_jumbo,
+       FALCON_STAT_tx_gtjumbo,
+       FALCON_STAT_tx_non_tcpudp,
+       FALCON_STAT_tx_mac_src_error,
+       FALCON_STAT_tx_ip_src_error,
+       FALCON_STAT_rx_bytes,
+       FALCON_STAT_rx_good_bytes,
+       FALCON_STAT_rx_bad_bytes,
+       FALCON_STAT_rx_packets,
+       FALCON_STAT_rx_good,
+       FALCON_STAT_rx_bad,
+       FALCON_STAT_rx_pause,
+       FALCON_STAT_rx_control,
+       FALCON_STAT_rx_unicast,
+       FALCON_STAT_rx_multicast,
+       FALCON_STAT_rx_broadcast,
+       FALCON_STAT_rx_lt64,
+       FALCON_STAT_rx_64,
+       FALCON_STAT_rx_65_to_127,
+       FALCON_STAT_rx_128_to_255,
+       FALCON_STAT_rx_256_to_511,
+       FALCON_STAT_rx_512_to_1023,
+       FALCON_STAT_rx_1024_to_15xx,
+       FALCON_STAT_rx_15xx_to_jumbo,
+       FALCON_STAT_rx_gtjumbo,
+       FALCON_STAT_rx_bad_lt64,
+       FALCON_STAT_rx_bad_gtjumbo,
+       FALCON_STAT_rx_overflow,
+       FALCON_STAT_rx_symbol_error,
+       FALCON_STAT_rx_align_error,
+       FALCON_STAT_rx_length_error,
+       FALCON_STAT_rx_internal_error,
+       FALCON_STAT_rx_nodesc_drop_cnt,
+       FALCON_STAT_COUNT
+};
+
 /**
  * struct falcon_nic_data - Falcon NIC state
  * @pci_dev2: Secondary function of Falcon A
  * @board: Board state and functions
+ * @stats: Hardware statistics
  * @stats_disable_count: Nest count for disabling statistics fetches
  * @stats_pending: Is there a pending DMA of MAC statistics.
  * @stats_timer: A timer for regularly fetching MAC statistics.
- * @stats_dma_done: Pointer to the flag which indicates DMA completion.
  * @spi_flash: SPI flash device
  * @spi_eeprom: SPI EEPROM device
  * @spi_lock: SPI bus lock
@@ -121,12 +259,12 @@ struct falcon_board {
 struct falcon_nic_data {
        struct pci_dev *pci_dev2;
        struct falcon_board board;
+       u64 stats[FALCON_STAT_COUNT];
        unsigned int stats_disable_count;
        bool stats_pending;
        struct timer_list stats_timer;
-       u32 *stats_dma_done;
-       struct efx_spi_device spi_flash;
-       struct efx_spi_device spi_eeprom;
+       struct falcon_spi_device spi_flash;
+       struct falcon_spi_device spi_eeprom;
        struct mutex spi_lock;
        struct mutex mdio_lock;
        bool xmac_poll_required;
@@ -138,30 +276,77 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
        return &data->board;
 }
 
+enum {
+       SIENA_STAT_tx_bytes,
+       SIENA_STAT_tx_good_bytes,
+       SIENA_STAT_tx_bad_bytes,
+       SIENA_STAT_tx_packets,
+       SIENA_STAT_tx_bad,
+       SIENA_STAT_tx_pause,
+       SIENA_STAT_tx_control,
+       SIENA_STAT_tx_unicast,
+       SIENA_STAT_tx_multicast,
+       SIENA_STAT_tx_broadcast,
+       SIENA_STAT_tx_lt64,
+       SIENA_STAT_tx_64,
+       SIENA_STAT_tx_65_to_127,
+       SIENA_STAT_tx_128_to_255,
+       SIENA_STAT_tx_256_to_511,
+       SIENA_STAT_tx_512_to_1023,
+       SIENA_STAT_tx_1024_to_15xx,
+       SIENA_STAT_tx_15xx_to_jumbo,
+       SIENA_STAT_tx_gtjumbo,
+       SIENA_STAT_tx_collision,
+       SIENA_STAT_tx_single_collision,
+       SIENA_STAT_tx_multiple_collision,
+       SIENA_STAT_tx_excessive_collision,
+       SIENA_STAT_tx_deferred,
+       SIENA_STAT_tx_late_collision,
+       SIENA_STAT_tx_excessive_deferred,
+       SIENA_STAT_tx_non_tcpudp,
+       SIENA_STAT_tx_mac_src_error,
+       SIENA_STAT_tx_ip_src_error,
+       SIENA_STAT_rx_bytes,
+       SIENA_STAT_rx_good_bytes,
+       SIENA_STAT_rx_bad_bytes,
+       SIENA_STAT_rx_packets,
+       SIENA_STAT_rx_good,
+       SIENA_STAT_rx_bad,
+       SIENA_STAT_rx_pause,
+       SIENA_STAT_rx_control,
+       SIENA_STAT_rx_unicast,
+       SIENA_STAT_rx_multicast,
+       SIENA_STAT_rx_broadcast,
+       SIENA_STAT_rx_lt64,
+       SIENA_STAT_rx_64,
+       SIENA_STAT_rx_65_to_127,
+       SIENA_STAT_rx_128_to_255,
+       SIENA_STAT_rx_256_to_511,
+       SIENA_STAT_rx_512_to_1023,
+       SIENA_STAT_rx_1024_to_15xx,
+       SIENA_STAT_rx_15xx_to_jumbo,
+       SIENA_STAT_rx_gtjumbo,
+       SIENA_STAT_rx_bad_gtjumbo,
+       SIENA_STAT_rx_overflow,
+       SIENA_STAT_rx_false_carrier,
+       SIENA_STAT_rx_symbol_error,
+       SIENA_STAT_rx_align_error,
+       SIENA_STAT_rx_length_error,
+       SIENA_STAT_rx_internal_error,
+       SIENA_STAT_rx_nodesc_drop_cnt,
+       SIENA_STAT_COUNT
+};
+
 /**
  * struct siena_nic_data - Siena NIC state
- * @mcdi: Management-Controller-to-Driver Interface
  * @wol_filter_id: Wake-on-LAN packet filter id
- * @hwmon: Hardware monitor state
+ * @stats: Hardware statistics
  */
 struct siena_nic_data {
-       struct efx_mcdi_iface mcdi;
        int wol_filter_id;
-#ifdef CONFIG_SFC_MCDI_MON
-       struct efx_mcdi_mon hwmon;
-#endif
+       u64 stats[SIENA_STAT_COUNT];
 };
 
-#ifdef CONFIG_SFC_MCDI_MON
-static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx)
-{
-       struct siena_nic_data *nic_data;
-       EFX_BUG_ON_PARANOID(efx_nic_rev(efx) < EFX_REV_SIENA_A0);
-       nic_data = efx->nic_data;
-       return &nic_data->hwmon;
-}
-#endif
-
 /*
  * On the SFC9000 family each port is associated with 1 PCI physical
  * function (PF) handled by sfc and a configurable number of virtual
@@ -274,35 +459,123 @@ extern const struct efx_nic_type siena_a0_nic_type;
 extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info);
 
 /* TX data path */
-extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue);
-extern void efx_nic_init_tx(struct efx_tx_queue *tx_queue);
-extern void efx_nic_fini_tx(struct efx_tx_queue *tx_queue);
-extern void efx_nic_remove_tx(struct efx_tx_queue *tx_queue);
-extern void efx_nic_push_buffers(struct efx_tx_queue *tx_queue);
+static inline int efx_nic_probe_tx(struct efx_tx_queue *tx_queue)
+{
+       return tx_queue->efx->type->tx_probe(tx_queue);
+}
+static inline void efx_nic_init_tx(struct efx_tx_queue *tx_queue)
+{
+       tx_queue->efx->type->tx_init(tx_queue);
+}
+static inline void efx_nic_remove_tx(struct efx_tx_queue *tx_queue)
+{
+       tx_queue->efx->type->tx_remove(tx_queue);
+}
+static inline void efx_nic_push_buffers(struct efx_tx_queue *tx_queue)
+{
+       tx_queue->efx->type->tx_write(tx_queue);
+}
 
 /* RX data path */
-extern int efx_nic_probe_rx(struct efx_rx_queue *rx_queue);
-extern void efx_nic_init_rx(struct efx_rx_queue *rx_queue);
-extern void efx_nic_fini_rx(struct efx_rx_queue *rx_queue);
-extern void efx_nic_remove_rx(struct efx_rx_queue *rx_queue);
-extern void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue);
-extern void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue);
+static inline int efx_nic_probe_rx(struct efx_rx_queue *rx_queue)
+{
+       return rx_queue->efx->type->rx_probe(rx_queue);
+}
+static inline void efx_nic_init_rx(struct efx_rx_queue *rx_queue)
+{
+       rx_queue->efx->type->rx_init(rx_queue);
+}
+static inline void efx_nic_remove_rx(struct efx_rx_queue *rx_queue)
+{
+       rx_queue->efx->type->rx_remove(rx_queue);
+}
+static inline void efx_nic_notify_rx_desc(struct efx_rx_queue *rx_queue)
+{
+       rx_queue->efx->type->rx_write(rx_queue);
+}
+static inline void efx_nic_generate_fill_event(struct efx_rx_queue *rx_queue)
+{
+       rx_queue->efx->type->rx_defer_refill(rx_queue);
+}
 
 /* Event data path */
-extern int efx_nic_probe_eventq(struct efx_channel *channel);
-extern void efx_nic_init_eventq(struct efx_channel *channel);
-extern void efx_nic_fini_eventq(struct efx_channel *channel);
-extern void efx_nic_remove_eventq(struct efx_channel *channel);
-extern int efx_nic_process_eventq(struct efx_channel *channel, int rx_quota);
-extern void efx_nic_eventq_read_ack(struct efx_channel *channel);
-extern bool efx_nic_event_present(struct efx_channel *channel);
+static inline int efx_nic_probe_eventq(struct efx_channel *channel)
+{
+       return channel->efx->type->ev_probe(channel);
+}
+static inline void efx_nic_init_eventq(struct efx_channel *channel)
+{
+       channel->efx->type->ev_init(channel);
+}
+static inline void efx_nic_fini_eventq(struct efx_channel *channel)
+{
+       channel->efx->type->ev_fini(channel);
+}
+static inline void efx_nic_remove_eventq(struct efx_channel *channel)
+{
+       channel->efx->type->ev_remove(channel);
+}
+static inline int
+efx_nic_process_eventq(struct efx_channel *channel, int quota)
+{
+       return channel->efx->type->ev_process(channel, quota);
+}
+static inline void efx_nic_eventq_read_ack(struct efx_channel *channel)
+{
+       channel->efx->type->ev_read_ack(channel);
+}
+extern void efx_nic_event_test_start(struct efx_channel *channel);
 
-/* MAC/PHY */
-extern void falcon_drain_tx_fifo(struct efx_nic *efx);
-extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
-extern bool falcon_xmac_check_fault(struct efx_nic *efx);
-extern int falcon_reconfigure_xmac(struct efx_nic *efx);
-extern void falcon_update_stats_xmac(struct efx_nic *efx);
+/* Falcon/Siena queue operations */
+extern int efx_farch_tx_probe(struct efx_tx_queue *tx_queue);
+extern void efx_farch_tx_init(struct efx_tx_queue *tx_queue);
+extern void efx_farch_tx_fini(struct efx_tx_queue *tx_queue);
+extern void efx_farch_tx_remove(struct efx_tx_queue *tx_queue);
+extern void efx_farch_tx_write(struct efx_tx_queue *tx_queue);
+extern int efx_farch_rx_probe(struct efx_rx_queue *rx_queue);
+extern void efx_farch_rx_init(struct efx_rx_queue *rx_queue);
+extern void efx_farch_rx_fini(struct efx_rx_queue *rx_queue);
+extern void efx_farch_rx_remove(struct efx_rx_queue *rx_queue);
+extern void efx_farch_rx_write(struct efx_rx_queue *rx_queue);
+extern void efx_farch_rx_defer_refill(struct efx_rx_queue *rx_queue);
+extern int efx_farch_ev_probe(struct efx_channel *channel);
+extern void efx_farch_ev_init(struct efx_channel *channel);
+extern void efx_farch_ev_fini(struct efx_channel *channel);
+extern void efx_farch_ev_remove(struct efx_channel *channel);
+extern int efx_farch_ev_process(struct efx_channel *channel, int quota);
+extern void efx_farch_ev_read_ack(struct efx_channel *channel);
+extern void efx_farch_ev_test_generate(struct efx_channel *channel);
+
+/* Falcon/Siena filter operations */
+extern int efx_farch_filter_table_probe(struct efx_nic *efx);
+extern void efx_farch_filter_table_restore(struct efx_nic *efx);
+extern void efx_farch_filter_table_remove(struct efx_nic *efx);
+extern void efx_farch_filter_update_rx_scatter(struct efx_nic *efx);
+extern s32 efx_farch_filter_insert(struct efx_nic *efx,
+                                  struct efx_filter_spec *spec, bool replace);
+extern int efx_farch_filter_remove_safe(struct efx_nic *efx,
+                                       enum efx_filter_priority priority,
+                                       u32 filter_id);
+extern int efx_farch_filter_get_safe(struct efx_nic *efx,
+                                    enum efx_filter_priority priority,
+                                    u32 filter_id, struct efx_filter_spec *);
+extern void efx_farch_filter_clear_rx(struct efx_nic *efx,
+                                     enum efx_filter_priority priority);
+extern u32 efx_farch_filter_count_rx_used(struct efx_nic *efx,
+                                         enum efx_filter_priority priority);
+extern u32 efx_farch_filter_get_rx_id_limit(struct efx_nic *efx);
+extern s32 efx_farch_filter_get_rx_ids(struct efx_nic *efx,
+                                      enum efx_filter_priority priority,
+                                      u32 *buf, u32 size);
+#ifdef CONFIG_RFS_ACCEL
+extern s32 efx_farch_filter_rfs_insert(struct efx_nic *efx,
+                                      struct efx_filter_spec *spec);
+extern bool efx_farch_filter_rfs_expire_one(struct efx_nic *efx, u32 flow_id,
+                                           unsigned int index);
+#endif
+extern void efx_farch_filter_sync_rx_mode(struct efx_nic *efx);
+
+extern bool efx_nic_event_present(struct efx_channel *channel);
 
 /* Some statistics are computed as A - B where A and B each increase
  * linearly with some hardware counter(s) and the counters are read
@@ -322,16 +595,18 @@ static inline void efx_update_diff_stat(u64 *stat, u64 diff)
                *stat = diff;
 }
 
-/* Interrupts and test events */
+/* Interrupts */
 extern int efx_nic_init_interrupt(struct efx_nic *efx);
-extern void efx_nic_enable_interrupts(struct efx_nic *efx);
-extern void efx_nic_event_test_start(struct efx_channel *channel);
 extern void efx_nic_irq_test_start(struct efx_nic *efx);
-extern void efx_nic_disable_interrupts(struct efx_nic *efx);
 extern void efx_nic_fini_interrupt(struct efx_nic *efx);
-extern irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx);
-extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id);
-extern void falcon_irq_ack_a1(struct efx_nic *efx);
+
+/* Falcon/Siena interrupts */
+extern void efx_farch_irq_enable_master(struct efx_nic *efx);
+extern void efx_farch_irq_test_generate(struct efx_nic *efx);
+extern void efx_farch_irq_disable_master(struct efx_nic *efx);
+extern irqreturn_t efx_farch_msi_interrupt(int irq, void *dev_id);
+extern irqreturn_t efx_farch_legacy_interrupt(int irq, void *dev_id);
+extern irqreturn_t efx_farch_fatal_interrupt(struct efx_nic *efx);
 
 static inline int efx_nic_event_test_irq_cpu(struct efx_channel *channel)
 {
@@ -345,69 +620,46 @@ static inline int efx_nic_irq_test_irq_cpu(struct efx_nic *efx)
 /* Global Resources */
 extern int efx_nic_flush_queues(struct efx_nic *efx);
 extern void siena_prepare_flush(struct efx_nic *efx);
+extern int efx_farch_fini_dmaq(struct efx_nic *efx);
 extern void siena_finish_flush(struct efx_nic *efx);
 extern void falcon_start_nic_stats(struct efx_nic *efx);
 extern void falcon_stop_nic_stats(struct efx_nic *efx);
-extern void falcon_setup_xaui(struct efx_nic *efx);
 extern int falcon_reset_xaui(struct efx_nic *efx);
-extern void
-efx_nic_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw);
-extern void efx_nic_init_common(struct efx_nic *efx);
-extern void efx_nic_push_rx_indir_table(struct efx_nic *efx);
+extern void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw);
+extern void efx_farch_init_common(struct efx_nic *efx);
+static inline void efx_nic_push_rx_indir_table(struct efx_nic *efx)
+{
+       efx->type->rx_push_indir_table(efx);
+}
+extern void efx_farch_rx_push_indir_table(struct efx_nic *efx);
 
 int efx_nic_alloc_buffer(struct efx_nic *efx, struct efx_buffer *buffer,
-                        unsigned int len);
+                        unsigned int len, gfp_t gfp_flags);
 void efx_nic_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer);
 
 /* Tests */
-struct efx_nic_register_test {
+struct efx_farch_register_test {
        unsigned address;
        efx_oword_t mask;
 };
-extern int efx_nic_test_registers(struct efx_nic *efx,
-                                 const struct efx_nic_register_test *regs,
-                                 size_t n_regs);
+extern int efx_farch_test_registers(struct efx_nic *efx,
+                                   const struct efx_farch_register_test *regs,
+                                   size_t n_regs);
 
 extern size_t efx_nic_get_regs_len(struct efx_nic *efx);
 extern void efx_nic_get_regs(struct efx_nic *efx, void *buf);
 
-/**************************************************************************
- *
- * Falcon MAC stats
- *
- **************************************************************************
- */
+extern size_t
+efx_nic_describe_stats(const struct efx_hw_stat_desc *desc, size_t count,
+                      const unsigned long *mask, u8 *names);
+extern void
+efx_nic_update_stats(const struct efx_hw_stat_desc *desc, size_t count,
+                    const unsigned long *mask,
+                    u64 *stats, const void *dma_buf, bool accumulate);
+
+#define EFX_MAX_FLUSH_TIME 5000
 
-#define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
-#define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
-
-/* Retrieve statistic from statistics block */
-#define FALCON_STAT(efx, falcon_stat, efx_stat) do {           \
-       if (FALCON_STAT_WIDTH(falcon_stat) == 16)               \
-               (efx)->mac_stats.efx_stat += le16_to_cpu(       \
-                       *((__force __le16 *)                            \
-                         (efx->stats_buffer.addr +             \
-                          FALCON_STAT_OFFSET(falcon_stat))));  \
-       else if (FALCON_STAT_WIDTH(falcon_stat) == 32)          \
-               (efx)->mac_stats.efx_stat += le32_to_cpu(       \
-                       *((__force __le32 *)                            \
-                         (efx->stats_buffer.addr +             \
-                          FALCON_STAT_OFFSET(falcon_stat))));  \
-       else                                                    \
-               (efx)->mac_stats.efx_stat += le64_to_cpu(       \
-                       *((__force __le64 *)                            \
-                         (efx->stats_buffer.addr +             \
-                          FALCON_STAT_OFFSET(falcon_stat))));  \
-       } while (0)
-
-#define FALCON_MAC_STATS_SIZE 0x100
-
-#define MAC_DATA_LBN 0
-#define MAC_DATA_WIDTH 32
-
-extern void efx_generate_event(struct efx_nic *efx, unsigned int evq,
-                              efx_qword_t *event);
-
-extern void falcon_poll_xmac(struct efx_nic *efx);
+extern void efx_farch_generate_event(struct efx_nic *efx, unsigned int evq,
+                                    efx_qword_t *event);
 
 #endif /* EFX_NIC_H */
index 11d148cd8441e2c3ca84c7f765a5b929a7de31ce..4f6eb8177a6dc3f1af15193c38a51d458ce2a46b 100644 (file)
@@ -47,21 +47,4 @@ extern const struct efx_phy_operations falcon_txc_phy_ops;
 extern void falcon_txc_set_gpio_dir(struct efx_nic *efx, int pin, int dir);
 extern void falcon_txc_set_gpio_val(struct efx_nic *efx, int pin, int val);
 
-/****************************************************************************
- * Siena managed PHYs
- */
-extern const struct efx_phy_operations efx_mcdi_phy_ops;
-
-extern int efx_mcdi_mdio_read(struct efx_nic *efx, unsigned int bus,
-                             unsigned int prtad, unsigned int devad,
-                             u16 addr, u16 *value_out, u32 *status_out);
-extern int efx_mcdi_mdio_write(struct efx_nic *efx, unsigned int bus,
-                              unsigned int prtad, unsigned int devad,
-                              u16 addr, u16 value, u32 *status_out);
-extern void efx_mcdi_phy_decode_link(struct efx_nic *efx,
-                                    struct efx_link_state *link_state,
-                                    u32 speed, u32 flags, u32 fcntl);
-extern int efx_mcdi_phy_reconfigure(struct efx_nic *efx);
-extern void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa);
-
 #endif
index b495394a6dfa7f7f64353caf5929c4a76825e34e..c60cabb6ff05ca4baed25f48dbe6ef7098b9ede9 100644 (file)
@@ -46,7 +46,7 @@
 #include "mcdi.h"
 #include "mcdi_pcol.h"
 #include "io.h"
-#include "regs.h"
+#include "farch_regs.h"
 #include "nic.h"
 
 /* Maximum number of events expected to make up a PTP event */
@@ -294,8 +294,7 @@ struct efx_ptp_data {
        struct work_struct pps_work;
        struct workqueue_struct *pps_workwq;
        bool nic_ts_enabled;
-       u8 txbuf[ALIGN(MC_CMD_PTP_IN_TRANSMIT_LEN(
-                              MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM), 4)];
+       MCDI_DECLARE_BUF(txbuf, MC_CMD_PTP_IN_TRANSMIT_LENMAX);
        struct efx_ptp_timeset
        timeset[MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM];
 };
@@ -311,9 +310,10 @@ static int efx_phc_enable(struct ptp_clock_info *ptp,
 /* Enable MCDI PTP support. */
 static int efx_ptp_enable(struct efx_nic *efx)
 {
-       u8 inbuf[MC_CMD_PTP_IN_ENABLE_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_PTP_IN_ENABLE_LEN);
 
        MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_ENABLE);
+       MCDI_SET_DWORD(inbuf, PTP_IN_PERIPH_ID, 0);
        MCDI_SET_DWORD(inbuf, PTP_IN_ENABLE_QUEUE,
                       efx->ptp_data->channel->channel);
        MCDI_SET_DWORD(inbuf, PTP_IN_ENABLE_MODE, efx->ptp_data->mode);
@@ -329,9 +329,10 @@ static int efx_ptp_enable(struct efx_nic *efx)
  */
 static int efx_ptp_disable(struct efx_nic *efx)
 {
-       u8 inbuf[MC_CMD_PTP_IN_DISABLE_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_PTP_IN_DISABLE_LEN);
 
        MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_DISABLE);
+       MCDI_SET_DWORD(inbuf, PTP_IN_PERIPH_ID, 0);
        return efx_mcdi_rpc(efx, MC_CMD_PTP, inbuf, sizeof(inbuf),
                            NULL, 0, NULL);
 }
@@ -389,14 +390,14 @@ static void efx_ptp_send_times(struct efx_nic *efx,
                host_time = (now.ts_real.tv_sec << MC_NANOSECOND_BITS |
                             now.ts_real.tv_nsec);
                /* Update host time in NIC memory */
-               _efx_writed(efx, cpu_to_le32(host_time),
-                           FR_CZ_MC_TREG_SMEM + MC_SMEM_P0_PTP_TIME_OFST);
+               efx->type->ptp_write_host_time(efx, host_time);
        }
        *last_time = now;
 }
 
 /* Read a timeset from the MC's results and partial process. */
-static void efx_ptp_read_timeset(u8 *data, struct efx_ptp_timeset *timeset)
+static void efx_ptp_read_timeset(MCDI_DECLARE_STRUCT_PTR(data),
+                                struct efx_ptp_timeset *timeset)
 {
        unsigned start_ns, end_ns;
 
@@ -425,12 +426,14 @@ static void efx_ptp_read_timeset(u8 *data, struct efx_ptp_timeset *timeset)
  * busy. A number of readings are taken so that, hopefully, at least one good
  * synchronisation will be seen in the results.
  */
-static int efx_ptp_process_times(struct efx_nic *efx, u8 *synch_buf,
-                                size_t response_length,
-                                const struct pps_event_time *last_time)
+static int
+efx_ptp_process_times(struct efx_nic *efx, MCDI_DECLARE_STRUCT_PTR(synch_buf),
+                     size_t response_length,
+                     const struct pps_event_time *last_time)
 {
-       unsigned number_readings = (response_length /
-                              MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN);
+       unsigned number_readings =
+               MCDI_VAR_ARRAY_LEN(response_length,
+                                  PTP_OUT_SYNCHRONIZE_TIMESET);
        unsigned i;
        unsigned total;
        unsigned ngood = 0;
@@ -447,8 +450,10 @@ static int efx_ptp_process_times(struct efx_nic *efx, u8 *synch_buf,
         * appera to be erroneous.
         */
        for (i = 0; i < number_readings; i++) {
-               efx_ptp_read_timeset(synch_buf, &ptp->timeset[i]);
-               synch_buf += MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN;
+               efx_ptp_read_timeset(
+                       MCDI_ARRAY_STRUCT_PTR(synch_buf,
+                                             PTP_OUT_SYNCHRONIZE_TIMESET, i),
+                       &ptp->timeset[i]);
        }
 
        /* Find the last good host-MC synchronization result. The MC times
@@ -518,7 +523,7 @@ static int efx_ptp_process_times(struct efx_nic *efx, u8 *synch_buf,
 static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
 {
        struct efx_ptp_data *ptp = efx->ptp_data;
-       u8 synch_buf[MC_CMD_PTP_OUT_SYNCHRONIZE_LENMAX];
+       MCDI_DECLARE_BUF(synch_buf, MC_CMD_PTP_OUT_SYNCHRONIZE_LENMAX);
        size_t response_length;
        int rc;
        unsigned long timeout;
@@ -527,17 +532,17 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
        int *start = ptp->start.addr;
 
        MCDI_SET_DWORD(synch_buf, PTP_IN_OP, MC_CMD_PTP_OP_SYNCHRONIZE);
+       MCDI_SET_DWORD(synch_buf, PTP_IN_PERIPH_ID, 0);
        MCDI_SET_DWORD(synch_buf, PTP_IN_SYNCHRONIZE_NUMTIMESETS,
                       num_readings);
-       MCDI_SET_DWORD(synch_buf, PTP_IN_SYNCHRONIZE_START_ADDR_LO,
-                      (u32)ptp->start.dma_addr);
-       MCDI_SET_DWORD(synch_buf, PTP_IN_SYNCHRONIZE_START_ADDR_HI,
-                      (u32)((u64)ptp->start.dma_addr >> 32));
+       MCDI_SET_QWORD(synch_buf, PTP_IN_SYNCHRONIZE_START_ADDR,
+                      ptp->start.dma_addr);
 
        /* Clear flag that signals MC ready */
        ACCESS_ONCE(*start) = 0;
-       efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
-                          MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
+       rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
+                               MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
+       EFX_BUG_ON_PARANOID(rc);
 
        /* Wait for start from MCDI (or timeout) */
        timeout = jiffies + msecs_to_jiffies(MAX_SYNCHRONISE_WAIT_MS);
@@ -564,15 +569,15 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
 /* Transmit a PTP packet, via the MCDI interface, to the wire. */
 static int efx_ptp_xmit_skb(struct efx_nic *efx, struct sk_buff *skb)
 {
-       u8 *txbuf = efx->ptp_data->txbuf;
+       struct efx_ptp_data *ptp_data = efx->ptp_data;
        struct skb_shared_hwtstamps timestamps;
        int rc = -EIO;
-       /* MCDI driver requires word aligned lengths */
-       size_t len = ALIGN(MC_CMD_PTP_IN_TRANSMIT_LEN(skb->len), 4);
-       u8 txtime[MC_CMD_PTP_OUT_TRANSMIT_LEN];
+       MCDI_DECLARE_BUF(txtime, MC_CMD_PTP_OUT_TRANSMIT_LEN);
+       size_t len;
 
-       MCDI_SET_DWORD(txbuf, PTP_IN_OP, MC_CMD_PTP_OP_TRANSMIT);
-       MCDI_SET_DWORD(txbuf, PTP_IN_TRANSMIT_LENGTH, skb->len);
+       MCDI_SET_DWORD(ptp_data->txbuf, PTP_IN_OP, MC_CMD_PTP_OP_TRANSMIT);
+       MCDI_SET_DWORD(ptp_data->txbuf, PTP_IN_PERIPH_ID, 0);
+       MCDI_SET_DWORD(ptp_data->txbuf, PTP_IN_TRANSMIT_LENGTH, skb->len);
        if (skb_shinfo(skb)->nr_frags != 0) {
                rc = skb_linearize(skb);
                if (rc != 0)
@@ -585,10 +590,12 @@ static int efx_ptp_xmit_skb(struct efx_nic *efx, struct sk_buff *skb)
                        goto fail;
        }
        skb_copy_from_linear_data(skb,
-                                 &txbuf[MC_CMD_PTP_IN_TRANSMIT_PACKET_OFST],
-                                 len);
-       rc = efx_mcdi_rpc(efx, MC_CMD_PTP, txbuf, len, txtime,
-                         sizeof(txtime), &len);
+                                 MCDI_PTR(ptp_data->txbuf,
+                                          PTP_IN_TRANSMIT_PACKET),
+                                 skb->len);
+       rc = efx_mcdi_rpc(efx, MC_CMD_PTP,
+                         ptp_data->txbuf, MC_CMD_PTP_IN_TRANSMIT_LEN(skb->len),
+                         txtime, sizeof(txtime), &len);
        if (rc != 0)
                goto fail;
 
@@ -872,7 +879,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel)
        if (!efx->ptp_data)
                return -ENOMEM;
 
-       rc = efx_nic_alloc_buffer(efx, &ptp->start, sizeof(int));
+       rc = efx_nic_alloc_buffer(efx, &ptp->start, sizeof(int), GFP_KERNEL);
        if (rc != 0)
                goto fail1;
 
@@ -1359,7 +1366,7 @@ static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
                                                     struct efx_ptp_data,
                                                     phc_clock_info);
        struct efx_nic *efx = ptp_data->channel->efx;
-       u8 inadj[MC_CMD_PTP_IN_ADJUST_LEN];
+       MCDI_DECLARE_BUF(inadj, MC_CMD_PTP_IN_ADJUST_LEN);
        s64 adjustment_ns;
        int rc;
 
@@ -1373,9 +1380,8 @@ static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
                         (PPB_EXTRA_BITS + MAX_PPB_BITS));
 
        MCDI_SET_DWORD(inadj, PTP_IN_OP, MC_CMD_PTP_OP_ADJUST);
-       MCDI_SET_DWORD(inadj, PTP_IN_ADJUST_FREQ_LO, (u32)adjustment_ns);
-       MCDI_SET_DWORD(inadj, PTP_IN_ADJUST_FREQ_HI,
-                      (u32)(adjustment_ns >> 32));
+       MCDI_SET_DWORD(inadj, PTP_IN_PERIPH_ID, 0);
+       MCDI_SET_QWORD(inadj, PTP_IN_ADJUST_FREQ, adjustment_ns);
        MCDI_SET_DWORD(inadj, PTP_IN_ADJUST_SECONDS, 0);
        MCDI_SET_DWORD(inadj, PTP_IN_ADJUST_NANOSECONDS, 0);
        rc = efx_mcdi_rpc(efx, MC_CMD_PTP, inadj, sizeof(inadj),
@@ -1394,11 +1400,11 @@ static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)
                                                     phc_clock_info);
        struct efx_nic *efx = ptp_data->channel->efx;
        struct timespec delta_ts = ns_to_timespec(delta);
-       u8 inbuf[MC_CMD_PTP_IN_ADJUST_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_PTP_IN_ADJUST_LEN);
 
        MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_ADJUST);
-       MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_FREQ_LO, 0);
-       MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_FREQ_HI, 0);
+       MCDI_SET_DWORD(inbuf, PTP_IN_PERIPH_ID, 0);
+       MCDI_SET_QWORD(inbuf, PTP_IN_ADJUST_FREQ, 0);
        MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_SECONDS, (u32)delta_ts.tv_sec);
        MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_NANOSECONDS, (u32)delta_ts.tv_nsec);
        return efx_mcdi_rpc(efx, MC_CMD_PTP, inbuf, sizeof(inbuf),
@@ -1411,11 +1417,12 @@ static int efx_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
                                                     struct efx_ptp_data,
                                                     phc_clock_info);
        struct efx_nic *efx = ptp_data->channel->efx;
-       u8 inbuf[MC_CMD_PTP_IN_READ_NIC_TIME_LEN];
-       u8 outbuf[MC_CMD_PTP_OUT_READ_NIC_TIME_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_PTP_IN_READ_NIC_TIME_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_PTP_OUT_READ_NIC_TIME_LEN);
        int rc;
 
        MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_READ_NIC_TIME);
+       MCDI_SET_DWORD(inbuf, PTP_IN_PERIPH_ID, 0);
 
        rc = efx_mcdi_rpc(efx, MC_CMD_PTP, inbuf, sizeof(inbuf),
                          outbuf, sizeof(outbuf), NULL);
diff --git a/drivers/net/ethernet/sfc/regs.h b/drivers/net/ethernet/sfc/regs.h
deleted file mode 100644 (file)
index ade4c4d..0000000
+++ /dev/null
@@ -1,3188 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2005-2006 Fen Systems Ltd.
- * Copyright 2006-2010 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-#ifndef EFX_REGS_H
-#define EFX_REGS_H
-
-/*
- * Falcon hardware architecture definitions have a name prefix following
- * the format:
- *
- *     F<type>_<min-rev><max-rev>_
- *
- * The following <type> strings are used:
- *
- *             MMIO register  MC register  Host memory structure
- * -------------------------------------------------------------
- * Address     R              MCR
- * Bitfield    RF             MCRF         SF
- * Enumerator  FE             MCFE         SE
- *
- * <min-rev> is the first revision to which the definition applies:
- *
- *     A: Falcon A1 (SFC4000AB)
- *     B: Falcon B0 (SFC4000BA)
- *     C: Siena A0 (SFL9021AA)
- *
- * If the definition has been changed or removed in later revisions
- * then <max-rev> is the last revision to which the definition applies;
- * otherwise it is "Z".
- */
-
-/**************************************************************************
- *
- * Falcon/Siena registers and descriptors
- *
- **************************************************************************
- */
-
-/* ADR_REGION_REG: Address region register */
-#define        FR_AZ_ADR_REGION 0x00000000
-#define        FRF_AZ_ADR_REGION3_LBN 96
-#define        FRF_AZ_ADR_REGION3_WIDTH 18
-#define        FRF_AZ_ADR_REGION2_LBN 64
-#define        FRF_AZ_ADR_REGION2_WIDTH 18
-#define        FRF_AZ_ADR_REGION1_LBN 32
-#define        FRF_AZ_ADR_REGION1_WIDTH 18
-#define        FRF_AZ_ADR_REGION0_LBN 0
-#define        FRF_AZ_ADR_REGION0_WIDTH 18
-
-/* INT_EN_REG_KER: Kernel driver Interrupt enable register */
-#define        FR_AZ_INT_EN_KER 0x00000010
-#define        FRF_AZ_KER_INT_LEVE_SEL_LBN 8
-#define        FRF_AZ_KER_INT_LEVE_SEL_WIDTH 6
-#define        FRF_AZ_KER_INT_CHAR_LBN 4
-#define        FRF_AZ_KER_INT_CHAR_WIDTH 1
-#define        FRF_AZ_KER_INT_KER_LBN 3
-#define        FRF_AZ_KER_INT_KER_WIDTH 1
-#define        FRF_AZ_DRV_INT_EN_KER_LBN 0
-#define        FRF_AZ_DRV_INT_EN_KER_WIDTH 1
-
-/* INT_EN_REG_CHAR: Char Driver interrupt enable register */
-#define        FR_BZ_INT_EN_CHAR 0x00000020
-#define        FRF_BZ_CHAR_INT_LEVE_SEL_LBN 8
-#define        FRF_BZ_CHAR_INT_LEVE_SEL_WIDTH 6
-#define        FRF_BZ_CHAR_INT_CHAR_LBN 4
-#define        FRF_BZ_CHAR_INT_CHAR_WIDTH 1
-#define        FRF_BZ_CHAR_INT_KER_LBN 3
-#define        FRF_BZ_CHAR_INT_KER_WIDTH 1
-#define        FRF_BZ_DRV_INT_EN_CHAR_LBN 0
-#define        FRF_BZ_DRV_INT_EN_CHAR_WIDTH 1
-
-/* INT_ADR_REG_KER: Interrupt host address for Kernel driver */
-#define        FR_AZ_INT_ADR_KER 0x00000030
-#define        FRF_AZ_NORM_INT_VEC_DIS_KER_LBN 64
-#define        FRF_AZ_NORM_INT_VEC_DIS_KER_WIDTH 1
-#define        FRF_AZ_INT_ADR_KER_LBN 0
-#define        FRF_AZ_INT_ADR_KER_WIDTH 64
-
-/* INT_ADR_REG_CHAR: Interrupt host address for Char driver */
-#define        FR_BZ_INT_ADR_CHAR 0x00000040
-#define        FRF_BZ_NORM_INT_VEC_DIS_CHAR_LBN 64
-#define        FRF_BZ_NORM_INT_VEC_DIS_CHAR_WIDTH 1
-#define        FRF_BZ_INT_ADR_CHAR_LBN 0
-#define        FRF_BZ_INT_ADR_CHAR_WIDTH 64
-
-/* INT_ACK_KER: Kernel interrupt acknowledge register */
-#define        FR_AA_INT_ACK_KER 0x00000050
-#define        FRF_AA_INT_ACK_KER_FIELD_LBN 0
-#define        FRF_AA_INT_ACK_KER_FIELD_WIDTH 32
-
-/* INT_ISR0_REG: Function 0 Interrupt Acknowledge Status register */
-#define        FR_BZ_INT_ISR0 0x00000090
-#define        FRF_BZ_INT_ISR_REG_LBN 0
-#define        FRF_BZ_INT_ISR_REG_WIDTH 64
-
-/* HW_INIT_REG: Hardware initialization register */
-#define        FR_AZ_HW_INIT 0x000000c0
-#define        FRF_BB_BDMRD_CPLF_FULL_LBN 124
-#define        FRF_BB_BDMRD_CPLF_FULL_WIDTH 1
-#define        FRF_BB_PCIE_CPL_TIMEOUT_CTRL_LBN 121
-#define        FRF_BB_PCIE_CPL_TIMEOUT_CTRL_WIDTH 3
-#define        FRF_CZ_TX_MRG_TAGS_LBN 120
-#define        FRF_CZ_TX_MRG_TAGS_WIDTH 1
-#define        FRF_AB_TRGT_MASK_ALL_LBN 100
-#define        FRF_AB_TRGT_MASK_ALL_WIDTH 1
-#define        FRF_AZ_DOORBELL_DROP_LBN 92
-#define        FRF_AZ_DOORBELL_DROP_WIDTH 8
-#define        FRF_AB_TX_RREQ_MASK_EN_LBN 76
-#define        FRF_AB_TX_RREQ_MASK_EN_WIDTH 1
-#define        FRF_AB_PE_EIDLE_DIS_LBN 75
-#define        FRF_AB_PE_EIDLE_DIS_WIDTH 1
-#define        FRF_AA_FC_BLOCKING_EN_LBN 45
-#define        FRF_AA_FC_BLOCKING_EN_WIDTH 1
-#define        FRF_BZ_B2B_REQ_EN_LBN 45
-#define        FRF_BZ_B2B_REQ_EN_WIDTH 1
-#define        FRF_AA_B2B_REQ_EN_LBN 44
-#define        FRF_AA_B2B_REQ_EN_WIDTH 1
-#define        FRF_BB_FC_BLOCKING_EN_LBN 44
-#define        FRF_BB_FC_BLOCKING_EN_WIDTH 1
-#define        FRF_AZ_POST_WR_MASK_LBN 40
-#define        FRF_AZ_POST_WR_MASK_WIDTH 4
-#define        FRF_AZ_TLP_TC_LBN 34
-#define        FRF_AZ_TLP_TC_WIDTH 3
-#define        FRF_AZ_TLP_ATTR_LBN 32
-#define        FRF_AZ_TLP_ATTR_WIDTH 2
-#define        FRF_AB_INTB_VEC_LBN 24
-#define        FRF_AB_INTB_VEC_WIDTH 5
-#define        FRF_AB_INTA_VEC_LBN 16
-#define        FRF_AB_INTA_VEC_WIDTH 5
-#define        FRF_AZ_WD_TIMER_LBN 8
-#define        FRF_AZ_WD_TIMER_WIDTH 8
-#define        FRF_AZ_US_DISABLE_LBN 5
-#define        FRF_AZ_US_DISABLE_WIDTH 1
-#define        FRF_AZ_TLP_EP_LBN 4
-#define        FRF_AZ_TLP_EP_WIDTH 1
-#define        FRF_AZ_ATTR_SEL_LBN 3
-#define        FRF_AZ_ATTR_SEL_WIDTH 1
-#define        FRF_AZ_TD_SEL_LBN 1
-#define        FRF_AZ_TD_SEL_WIDTH 1
-#define        FRF_AZ_TLP_TD_LBN 0
-#define        FRF_AZ_TLP_TD_WIDTH 1
-
-/* EE_SPI_HCMD_REG: SPI host command register */
-#define        FR_AB_EE_SPI_HCMD 0x00000100
-#define        FRF_AB_EE_SPI_HCMD_CMD_EN_LBN 31
-#define        FRF_AB_EE_SPI_HCMD_CMD_EN_WIDTH 1
-#define        FRF_AB_EE_WR_TIMER_ACTIVE_LBN 28
-#define        FRF_AB_EE_WR_TIMER_ACTIVE_WIDTH 1
-#define        FRF_AB_EE_SPI_HCMD_SF_SEL_LBN 24
-#define        FRF_AB_EE_SPI_HCMD_SF_SEL_WIDTH 1
-#define        FRF_AB_EE_SPI_HCMD_DABCNT_LBN 16
-#define        FRF_AB_EE_SPI_HCMD_DABCNT_WIDTH 5
-#define        FRF_AB_EE_SPI_HCMD_READ_LBN 15
-#define        FRF_AB_EE_SPI_HCMD_READ_WIDTH 1
-#define        FRF_AB_EE_SPI_HCMD_DUBCNT_LBN 12
-#define        FRF_AB_EE_SPI_HCMD_DUBCNT_WIDTH 2
-#define        FRF_AB_EE_SPI_HCMD_ADBCNT_LBN 8
-#define        FRF_AB_EE_SPI_HCMD_ADBCNT_WIDTH 2
-#define        FRF_AB_EE_SPI_HCMD_ENC_LBN 0
-#define        FRF_AB_EE_SPI_HCMD_ENC_WIDTH 8
-
-/* USR_EV_CFG: User Level Event Configuration register */
-#define        FR_CZ_USR_EV_CFG 0x00000100
-#define        FRF_CZ_USREV_DIS_LBN 16
-#define        FRF_CZ_USREV_DIS_WIDTH 1
-#define        FRF_CZ_DFLT_EVQ_LBN 0
-#define        FRF_CZ_DFLT_EVQ_WIDTH 10
-
-/* EE_SPI_HADR_REG: SPI host address register */
-#define        FR_AB_EE_SPI_HADR 0x00000110
-#define        FRF_AB_EE_SPI_HADR_DUBYTE_LBN 24
-#define        FRF_AB_EE_SPI_HADR_DUBYTE_WIDTH 8
-#define        FRF_AB_EE_SPI_HADR_ADR_LBN 0
-#define        FRF_AB_EE_SPI_HADR_ADR_WIDTH 24
-
-/* EE_SPI_HDATA_REG: SPI host data register */
-#define        FR_AB_EE_SPI_HDATA 0x00000120
-#define        FRF_AB_EE_SPI_HDATA3_LBN 96
-#define        FRF_AB_EE_SPI_HDATA3_WIDTH 32
-#define        FRF_AB_EE_SPI_HDATA2_LBN 64
-#define        FRF_AB_EE_SPI_HDATA2_WIDTH 32
-#define        FRF_AB_EE_SPI_HDATA1_LBN 32
-#define        FRF_AB_EE_SPI_HDATA1_WIDTH 32
-#define        FRF_AB_EE_SPI_HDATA0_LBN 0
-#define        FRF_AB_EE_SPI_HDATA0_WIDTH 32
-
-/* EE_BASE_PAGE_REG: Expansion ROM base mirror register */
-#define        FR_AB_EE_BASE_PAGE 0x00000130
-#define        FRF_AB_EE_EXPROM_MASK_LBN 16
-#define        FRF_AB_EE_EXPROM_MASK_WIDTH 13
-#define        FRF_AB_EE_EXP_ROM_WINDOW_BASE_LBN 0
-#define        FRF_AB_EE_EXP_ROM_WINDOW_BASE_WIDTH 13
-
-/* EE_VPD_CFG0_REG: SPI/VPD configuration register 0 */
-#define        FR_AB_EE_VPD_CFG0 0x00000140
-#define        FRF_AB_EE_SF_FASTRD_EN_LBN 127
-#define        FRF_AB_EE_SF_FASTRD_EN_WIDTH 1
-#define        FRF_AB_EE_SF_CLOCK_DIV_LBN 120
-#define        FRF_AB_EE_SF_CLOCK_DIV_WIDTH 7
-#define        FRF_AB_EE_VPD_WIP_POLL_LBN 119
-#define        FRF_AB_EE_VPD_WIP_POLL_WIDTH 1
-#define        FRF_AB_EE_EE_CLOCK_DIV_LBN 112
-#define        FRF_AB_EE_EE_CLOCK_DIV_WIDTH 7
-#define        FRF_AB_EE_EE_WR_TMR_VALUE_LBN 96
-#define        FRF_AB_EE_EE_WR_TMR_VALUE_WIDTH 16
-#define        FRF_AB_EE_VPDW_LENGTH_LBN 80
-#define        FRF_AB_EE_VPDW_LENGTH_WIDTH 15
-#define        FRF_AB_EE_VPDW_BASE_LBN 64
-#define        FRF_AB_EE_VPDW_BASE_WIDTH 15
-#define        FRF_AB_EE_VPD_WR_CMD_EN_LBN 56
-#define        FRF_AB_EE_VPD_WR_CMD_EN_WIDTH 8
-#define        FRF_AB_EE_VPD_BASE_LBN 32
-#define        FRF_AB_EE_VPD_BASE_WIDTH 24
-#define        FRF_AB_EE_VPD_LENGTH_LBN 16
-#define        FRF_AB_EE_VPD_LENGTH_WIDTH 15
-#define        FRF_AB_EE_VPD_AD_SIZE_LBN 8
-#define        FRF_AB_EE_VPD_AD_SIZE_WIDTH 5
-#define        FRF_AB_EE_VPD_ACCESS_ON_LBN 5
-#define        FRF_AB_EE_VPD_ACCESS_ON_WIDTH 1
-#define        FRF_AB_EE_VPD_ACCESS_BLOCK_LBN 4
-#define        FRF_AB_EE_VPD_ACCESS_BLOCK_WIDTH 1
-#define        FRF_AB_EE_VPD_DEV_SF_SEL_LBN 2
-#define        FRF_AB_EE_VPD_DEV_SF_SEL_WIDTH 1
-#define        FRF_AB_EE_VPD_EN_AD9_MODE_LBN 1
-#define        FRF_AB_EE_VPD_EN_AD9_MODE_WIDTH 1
-#define        FRF_AB_EE_VPD_EN_LBN 0
-#define        FRF_AB_EE_VPD_EN_WIDTH 1
-
-/* EE_VPD_SW_CNTL_REG: VPD access SW control register */
-#define        FR_AB_EE_VPD_SW_CNTL 0x00000150
-#define        FRF_AB_EE_VPD_CYCLE_PENDING_LBN 31
-#define        FRF_AB_EE_VPD_CYCLE_PENDING_WIDTH 1
-#define        FRF_AB_EE_VPD_CYC_WRITE_LBN 28
-#define        FRF_AB_EE_VPD_CYC_WRITE_WIDTH 1
-#define        FRF_AB_EE_VPD_CYC_ADR_LBN 0
-#define        FRF_AB_EE_VPD_CYC_ADR_WIDTH 15
-
-/* EE_VPD_SW_DATA_REG: VPD access SW data register */
-#define        FR_AB_EE_VPD_SW_DATA 0x00000160
-#define        FRF_AB_EE_VPD_CYC_DAT_LBN 0
-#define        FRF_AB_EE_VPD_CYC_DAT_WIDTH 32
-
-/* PBMX_DBG_IADDR_REG: Capture Module address register */
-#define        FR_CZ_PBMX_DBG_IADDR 0x000001f0
-#define        FRF_CZ_PBMX_DBG_IADDR_LBN 0
-#define        FRF_CZ_PBMX_DBG_IADDR_WIDTH 32
-
-/* PCIE_CORE_INDIRECT_REG: Indirect Access to PCIE Core registers */
-#define        FR_BB_PCIE_CORE_INDIRECT 0x000001f0
-#define        FRF_BB_PCIE_CORE_TARGET_DATA_LBN 32
-#define        FRF_BB_PCIE_CORE_TARGET_DATA_WIDTH 32
-#define        FRF_BB_PCIE_CORE_INDIRECT_ACCESS_DIR_LBN 15
-#define        FRF_BB_PCIE_CORE_INDIRECT_ACCESS_DIR_WIDTH 1
-#define        FRF_BB_PCIE_CORE_TARGET_REG_ADRS_LBN 0
-#define        FRF_BB_PCIE_CORE_TARGET_REG_ADRS_WIDTH 12
-
-/* PBMX_DBG_IDATA_REG: Capture Module data register */
-#define        FR_CZ_PBMX_DBG_IDATA 0x000001f8
-#define        FRF_CZ_PBMX_DBG_IDATA_LBN 0
-#define        FRF_CZ_PBMX_DBG_IDATA_WIDTH 64
-
-/* NIC_STAT_REG: NIC status register */
-#define        FR_AB_NIC_STAT 0x00000200
-#define        FRF_BB_AER_DIS_LBN 34
-#define        FRF_BB_AER_DIS_WIDTH 1
-#define        FRF_BB_EE_STRAP_EN_LBN 31
-#define        FRF_BB_EE_STRAP_EN_WIDTH 1
-#define        FRF_BB_EE_STRAP_LBN 24
-#define        FRF_BB_EE_STRAP_WIDTH 4
-#define        FRF_BB_REVISION_ID_LBN 17
-#define        FRF_BB_REVISION_ID_WIDTH 7
-#define        FRF_AB_ONCHIP_SRAM_LBN 16
-#define        FRF_AB_ONCHIP_SRAM_WIDTH 1
-#define        FRF_AB_SF_PRST_LBN 9
-#define        FRF_AB_SF_PRST_WIDTH 1
-#define        FRF_AB_EE_PRST_LBN 8
-#define        FRF_AB_EE_PRST_WIDTH 1
-#define        FRF_AB_ATE_MODE_LBN 3
-#define        FRF_AB_ATE_MODE_WIDTH 1
-#define        FRF_AB_STRAP_PINS_LBN 0
-#define        FRF_AB_STRAP_PINS_WIDTH 3
-
-/* GPIO_CTL_REG: GPIO control register */
-#define        FR_AB_GPIO_CTL 0x00000210
-#define        FRF_AB_GPIO_OUT3_LBN 112
-#define        FRF_AB_GPIO_OUT3_WIDTH 16
-#define        FRF_AB_GPIO_IN3_LBN 104
-#define        FRF_AB_GPIO_IN3_WIDTH 8
-#define        FRF_AB_GPIO_PWRUP_VALUE3_LBN 96
-#define        FRF_AB_GPIO_PWRUP_VALUE3_WIDTH 8
-#define        FRF_AB_GPIO_OUT2_LBN 80
-#define        FRF_AB_GPIO_OUT2_WIDTH 16
-#define        FRF_AB_GPIO_IN2_LBN 72
-#define        FRF_AB_GPIO_IN2_WIDTH 8
-#define        FRF_AB_GPIO_PWRUP_VALUE2_LBN 64
-#define        FRF_AB_GPIO_PWRUP_VALUE2_WIDTH 8
-#define        FRF_AB_GPIO15_OEN_LBN 63
-#define        FRF_AB_GPIO15_OEN_WIDTH 1
-#define        FRF_AB_GPIO14_OEN_LBN 62
-#define        FRF_AB_GPIO14_OEN_WIDTH 1
-#define        FRF_AB_GPIO13_OEN_LBN 61
-#define        FRF_AB_GPIO13_OEN_WIDTH 1
-#define        FRF_AB_GPIO12_OEN_LBN 60
-#define        FRF_AB_GPIO12_OEN_WIDTH 1
-#define        FRF_AB_GPIO11_OEN_LBN 59
-#define        FRF_AB_GPIO11_OEN_WIDTH 1
-#define        FRF_AB_GPIO10_OEN_LBN 58
-#define        FRF_AB_GPIO10_OEN_WIDTH 1
-#define        FRF_AB_GPIO9_OEN_LBN 57
-#define        FRF_AB_GPIO9_OEN_WIDTH 1
-#define        FRF_AB_GPIO8_OEN_LBN 56
-#define        FRF_AB_GPIO8_OEN_WIDTH 1
-#define        FRF_AB_GPIO15_OUT_LBN 55
-#define        FRF_AB_GPIO15_OUT_WIDTH 1
-#define        FRF_AB_GPIO14_OUT_LBN 54
-#define        FRF_AB_GPIO14_OUT_WIDTH 1
-#define        FRF_AB_GPIO13_OUT_LBN 53
-#define        FRF_AB_GPIO13_OUT_WIDTH 1
-#define        FRF_AB_GPIO12_OUT_LBN 52
-#define        FRF_AB_GPIO12_OUT_WIDTH 1
-#define        FRF_AB_GPIO11_OUT_LBN 51
-#define        FRF_AB_GPIO11_OUT_WIDTH 1
-#define        FRF_AB_GPIO10_OUT_LBN 50
-#define        FRF_AB_GPIO10_OUT_WIDTH 1
-#define        FRF_AB_GPIO9_OUT_LBN 49
-#define        FRF_AB_GPIO9_OUT_WIDTH 1
-#define        FRF_AB_GPIO8_OUT_LBN 48
-#define        FRF_AB_GPIO8_OUT_WIDTH 1
-#define        FRF_AB_GPIO15_IN_LBN 47
-#define        FRF_AB_GPIO15_IN_WIDTH 1
-#define        FRF_AB_GPIO14_IN_LBN 46
-#define        FRF_AB_GPIO14_IN_WIDTH 1
-#define        FRF_AB_GPIO13_IN_LBN 45
-#define        FRF_AB_GPIO13_IN_WIDTH 1
-#define        FRF_AB_GPIO12_IN_LBN 44
-#define        FRF_AB_GPIO12_IN_WIDTH 1
-#define        FRF_AB_GPIO11_IN_LBN 43
-#define        FRF_AB_GPIO11_IN_WIDTH 1
-#define        FRF_AB_GPIO10_IN_LBN 42
-#define        FRF_AB_GPIO10_IN_WIDTH 1
-#define        FRF_AB_GPIO9_IN_LBN 41
-#define        FRF_AB_GPIO9_IN_WIDTH 1
-#define        FRF_AB_GPIO8_IN_LBN 40
-#define        FRF_AB_GPIO8_IN_WIDTH 1
-#define        FRF_AB_GPIO15_PWRUP_VALUE_LBN 39
-#define        FRF_AB_GPIO15_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO14_PWRUP_VALUE_LBN 38
-#define        FRF_AB_GPIO14_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO13_PWRUP_VALUE_LBN 37
-#define        FRF_AB_GPIO13_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO12_PWRUP_VALUE_LBN 36
-#define        FRF_AB_GPIO12_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO11_PWRUP_VALUE_LBN 35
-#define        FRF_AB_GPIO11_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO10_PWRUP_VALUE_LBN 34
-#define        FRF_AB_GPIO10_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO9_PWRUP_VALUE_LBN 33
-#define        FRF_AB_GPIO9_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO8_PWRUP_VALUE_LBN 32
-#define        FRF_AB_GPIO8_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_CLK156_OUT_EN_LBN 31
-#define        FRF_AB_CLK156_OUT_EN_WIDTH 1
-#define        FRF_AB_USE_NIC_CLK_LBN 30
-#define        FRF_AB_USE_NIC_CLK_WIDTH 1
-#define        FRF_AB_GPIO5_OEN_LBN 29
-#define        FRF_AB_GPIO5_OEN_WIDTH 1
-#define        FRF_AB_GPIO4_OEN_LBN 28
-#define        FRF_AB_GPIO4_OEN_WIDTH 1
-#define        FRF_AB_GPIO3_OEN_LBN 27
-#define        FRF_AB_GPIO3_OEN_WIDTH 1
-#define        FRF_AB_GPIO2_OEN_LBN 26
-#define        FRF_AB_GPIO2_OEN_WIDTH 1
-#define        FRF_AB_GPIO1_OEN_LBN 25
-#define        FRF_AB_GPIO1_OEN_WIDTH 1
-#define        FRF_AB_GPIO0_OEN_LBN 24
-#define        FRF_AB_GPIO0_OEN_WIDTH 1
-#define        FRF_AB_GPIO7_OUT_LBN 23
-#define        FRF_AB_GPIO7_OUT_WIDTH 1
-#define        FRF_AB_GPIO6_OUT_LBN 22
-#define        FRF_AB_GPIO6_OUT_WIDTH 1
-#define        FRF_AB_GPIO5_OUT_LBN 21
-#define        FRF_AB_GPIO5_OUT_WIDTH 1
-#define        FRF_AB_GPIO4_OUT_LBN 20
-#define        FRF_AB_GPIO4_OUT_WIDTH 1
-#define        FRF_AB_GPIO3_OUT_LBN 19
-#define        FRF_AB_GPIO3_OUT_WIDTH 1
-#define        FRF_AB_GPIO2_OUT_LBN 18
-#define        FRF_AB_GPIO2_OUT_WIDTH 1
-#define        FRF_AB_GPIO1_OUT_LBN 17
-#define        FRF_AB_GPIO1_OUT_WIDTH 1
-#define        FRF_AB_GPIO0_OUT_LBN 16
-#define        FRF_AB_GPIO0_OUT_WIDTH 1
-#define        FRF_AB_GPIO7_IN_LBN 15
-#define        FRF_AB_GPIO7_IN_WIDTH 1
-#define        FRF_AB_GPIO6_IN_LBN 14
-#define        FRF_AB_GPIO6_IN_WIDTH 1
-#define        FRF_AB_GPIO5_IN_LBN 13
-#define        FRF_AB_GPIO5_IN_WIDTH 1
-#define        FRF_AB_GPIO4_IN_LBN 12
-#define        FRF_AB_GPIO4_IN_WIDTH 1
-#define        FRF_AB_GPIO3_IN_LBN 11
-#define        FRF_AB_GPIO3_IN_WIDTH 1
-#define        FRF_AB_GPIO2_IN_LBN 10
-#define        FRF_AB_GPIO2_IN_WIDTH 1
-#define        FRF_AB_GPIO1_IN_LBN 9
-#define        FRF_AB_GPIO1_IN_WIDTH 1
-#define        FRF_AB_GPIO0_IN_LBN 8
-#define        FRF_AB_GPIO0_IN_WIDTH 1
-#define        FRF_AB_GPIO7_PWRUP_VALUE_LBN 7
-#define        FRF_AB_GPIO7_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO6_PWRUP_VALUE_LBN 6
-#define        FRF_AB_GPIO6_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO5_PWRUP_VALUE_LBN 5
-#define        FRF_AB_GPIO5_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO4_PWRUP_VALUE_LBN 4
-#define        FRF_AB_GPIO4_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO3_PWRUP_VALUE_LBN 3
-#define        FRF_AB_GPIO3_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO2_PWRUP_VALUE_LBN 2
-#define        FRF_AB_GPIO2_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO1_PWRUP_VALUE_LBN 1
-#define        FRF_AB_GPIO1_PWRUP_VALUE_WIDTH 1
-#define        FRF_AB_GPIO0_PWRUP_VALUE_LBN 0
-#define        FRF_AB_GPIO0_PWRUP_VALUE_WIDTH 1
-
-/* GLB_CTL_REG: Global control register */
-#define        FR_AB_GLB_CTL 0x00000220
-#define        FRF_AB_EXT_PHY_RST_CTL_LBN 63
-#define        FRF_AB_EXT_PHY_RST_CTL_WIDTH 1
-#define        FRF_AB_XAUI_SD_RST_CTL_LBN 62
-#define        FRF_AB_XAUI_SD_RST_CTL_WIDTH 1
-#define        FRF_AB_PCIE_SD_RST_CTL_LBN 61
-#define        FRF_AB_PCIE_SD_RST_CTL_WIDTH 1
-#define        FRF_AA_PCIX_RST_CTL_LBN 60
-#define        FRF_AA_PCIX_RST_CTL_WIDTH 1
-#define        FRF_BB_BIU_RST_CTL_LBN 60
-#define        FRF_BB_BIU_RST_CTL_WIDTH 1
-#define        FRF_AB_PCIE_STKY_RST_CTL_LBN 59
-#define        FRF_AB_PCIE_STKY_RST_CTL_WIDTH 1
-#define        FRF_AB_PCIE_NSTKY_RST_CTL_LBN 58
-#define        FRF_AB_PCIE_NSTKY_RST_CTL_WIDTH 1
-#define        FRF_AB_PCIE_CORE_RST_CTL_LBN 57
-#define        FRF_AB_PCIE_CORE_RST_CTL_WIDTH 1
-#define        FRF_AB_XGRX_RST_CTL_LBN 56
-#define        FRF_AB_XGRX_RST_CTL_WIDTH 1
-#define        FRF_AB_XGTX_RST_CTL_LBN 55
-#define        FRF_AB_XGTX_RST_CTL_WIDTH 1
-#define        FRF_AB_EM_RST_CTL_LBN 54
-#define        FRF_AB_EM_RST_CTL_WIDTH 1
-#define        FRF_AB_EV_RST_CTL_LBN 53
-#define        FRF_AB_EV_RST_CTL_WIDTH 1
-#define        FRF_AB_SR_RST_CTL_LBN 52
-#define        FRF_AB_SR_RST_CTL_WIDTH 1
-#define        FRF_AB_RX_RST_CTL_LBN 51
-#define        FRF_AB_RX_RST_CTL_WIDTH 1
-#define        FRF_AB_TX_RST_CTL_LBN 50
-#define        FRF_AB_TX_RST_CTL_WIDTH 1
-#define        FRF_AB_EE_RST_CTL_LBN 49
-#define        FRF_AB_EE_RST_CTL_WIDTH 1
-#define        FRF_AB_CS_RST_CTL_LBN 48
-#define        FRF_AB_CS_RST_CTL_WIDTH 1
-#define        FRF_AB_HOT_RST_CTL_LBN 40
-#define        FRF_AB_HOT_RST_CTL_WIDTH 2
-#define        FRF_AB_RST_EXT_PHY_LBN 31
-#define        FRF_AB_RST_EXT_PHY_WIDTH 1
-#define        FRF_AB_RST_XAUI_SD_LBN 30
-#define        FRF_AB_RST_XAUI_SD_WIDTH 1
-#define        FRF_AB_RST_PCIE_SD_LBN 29
-#define        FRF_AB_RST_PCIE_SD_WIDTH 1
-#define        FRF_AA_RST_PCIX_LBN 28
-#define        FRF_AA_RST_PCIX_WIDTH 1
-#define        FRF_BB_RST_BIU_LBN 28
-#define        FRF_BB_RST_BIU_WIDTH 1
-#define        FRF_AB_RST_PCIE_STKY_LBN 27
-#define        FRF_AB_RST_PCIE_STKY_WIDTH 1
-#define        FRF_AB_RST_PCIE_NSTKY_LBN 26
-#define        FRF_AB_RST_PCIE_NSTKY_WIDTH 1
-#define        FRF_AB_RST_PCIE_CORE_LBN 25
-#define        FRF_AB_RST_PCIE_CORE_WIDTH 1
-#define        FRF_AB_RST_XGRX_LBN 24
-#define        FRF_AB_RST_XGRX_WIDTH 1
-#define        FRF_AB_RST_XGTX_LBN 23
-#define        FRF_AB_RST_XGTX_WIDTH 1
-#define        FRF_AB_RST_EM_LBN 22
-#define        FRF_AB_RST_EM_WIDTH 1
-#define        FRF_AB_RST_EV_LBN 21
-#define        FRF_AB_RST_EV_WIDTH 1
-#define        FRF_AB_RST_SR_LBN 20
-#define        FRF_AB_RST_SR_WIDTH 1
-#define        FRF_AB_RST_RX_LBN 19
-#define        FRF_AB_RST_RX_WIDTH 1
-#define        FRF_AB_RST_TX_LBN 18
-#define        FRF_AB_RST_TX_WIDTH 1
-#define        FRF_AB_RST_SF_LBN 17
-#define        FRF_AB_RST_SF_WIDTH 1
-#define        FRF_AB_RST_CS_LBN 16
-#define        FRF_AB_RST_CS_WIDTH 1
-#define        FRF_AB_INT_RST_DUR_LBN 4
-#define        FRF_AB_INT_RST_DUR_WIDTH 3
-#define        FRF_AB_EXT_PHY_RST_DUR_LBN 1
-#define        FRF_AB_EXT_PHY_RST_DUR_WIDTH 3
-#define        FFE_AB_EXT_PHY_RST_DUR_10240US 7
-#define        FFE_AB_EXT_PHY_RST_DUR_5120US 6
-#define        FFE_AB_EXT_PHY_RST_DUR_2560US 5
-#define        FFE_AB_EXT_PHY_RST_DUR_1280US 4
-#define        FFE_AB_EXT_PHY_RST_DUR_640US 3
-#define        FFE_AB_EXT_PHY_RST_DUR_320US 2
-#define        FFE_AB_EXT_PHY_RST_DUR_160US 1
-#define        FFE_AB_EXT_PHY_RST_DUR_80US 0
-#define        FRF_AB_SWRST_LBN 0
-#define        FRF_AB_SWRST_WIDTH 1
-
-/* FATAL_INTR_REG_KER: Fatal interrupt register for Kernel */
-#define        FR_AZ_FATAL_INTR_KER 0x00000230
-#define        FRF_CZ_SRAM_PERR_INT_P_KER_EN_LBN 44
-#define        FRF_CZ_SRAM_PERR_INT_P_KER_EN_WIDTH 1
-#define        FRF_AB_PCI_BUSERR_INT_KER_EN_LBN 43
-#define        FRF_AB_PCI_BUSERR_INT_KER_EN_WIDTH 1
-#define        FRF_CZ_MBU_PERR_INT_KER_EN_LBN 43
-#define        FRF_CZ_MBU_PERR_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_SRAM_OOB_INT_KER_EN_LBN 42
-#define        FRF_AZ_SRAM_OOB_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_BUFID_OOB_INT_KER_EN_LBN 41
-#define        FRF_AZ_BUFID_OOB_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_MEM_PERR_INT_KER_EN_LBN 40
-#define        FRF_AZ_MEM_PERR_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_RBUF_OWN_INT_KER_EN_LBN 39
-#define        FRF_AZ_RBUF_OWN_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_TBUF_OWN_INT_KER_EN_LBN 38
-#define        FRF_AZ_TBUF_OWN_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_RDESCQ_OWN_INT_KER_EN_LBN 37
-#define        FRF_AZ_RDESCQ_OWN_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_TDESCQ_OWN_INT_KER_EN_LBN 36
-#define        FRF_AZ_TDESCQ_OWN_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_EVQ_OWN_INT_KER_EN_LBN 35
-#define        FRF_AZ_EVQ_OWN_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_EVF_OFLO_INT_KER_EN_LBN 34
-#define        FRF_AZ_EVF_OFLO_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_ILL_ADR_INT_KER_EN_LBN 33
-#define        FRF_AZ_ILL_ADR_INT_KER_EN_WIDTH 1
-#define        FRF_AZ_SRM_PERR_INT_KER_EN_LBN 32
-#define        FRF_AZ_SRM_PERR_INT_KER_EN_WIDTH 1
-#define        FRF_CZ_SRAM_PERR_INT_P_KER_LBN 12
-#define        FRF_CZ_SRAM_PERR_INT_P_KER_WIDTH 1
-#define        FRF_AB_PCI_BUSERR_INT_KER_LBN 11
-#define        FRF_AB_PCI_BUSERR_INT_KER_WIDTH 1
-#define        FRF_CZ_MBU_PERR_INT_KER_LBN 11
-#define        FRF_CZ_MBU_PERR_INT_KER_WIDTH 1
-#define        FRF_AZ_SRAM_OOB_INT_KER_LBN 10
-#define        FRF_AZ_SRAM_OOB_INT_KER_WIDTH 1
-#define        FRF_AZ_BUFID_DC_OOB_INT_KER_LBN 9
-#define        FRF_AZ_BUFID_DC_OOB_INT_KER_WIDTH 1
-#define        FRF_AZ_MEM_PERR_INT_KER_LBN 8
-#define        FRF_AZ_MEM_PERR_INT_KER_WIDTH 1
-#define        FRF_AZ_RBUF_OWN_INT_KER_LBN 7
-#define        FRF_AZ_RBUF_OWN_INT_KER_WIDTH 1
-#define        FRF_AZ_TBUF_OWN_INT_KER_LBN 6
-#define        FRF_AZ_TBUF_OWN_INT_KER_WIDTH 1
-#define        FRF_AZ_RDESCQ_OWN_INT_KER_LBN 5
-#define        FRF_AZ_RDESCQ_OWN_INT_KER_WIDTH 1
-#define        FRF_AZ_TDESCQ_OWN_INT_KER_LBN 4
-#define        FRF_AZ_TDESCQ_OWN_INT_KER_WIDTH 1
-#define        FRF_AZ_EVQ_OWN_INT_KER_LBN 3
-#define        FRF_AZ_EVQ_OWN_INT_KER_WIDTH 1
-#define        FRF_AZ_EVF_OFLO_INT_KER_LBN 2
-#define        FRF_AZ_EVF_OFLO_INT_KER_WIDTH 1
-#define        FRF_AZ_ILL_ADR_INT_KER_LBN 1
-#define        FRF_AZ_ILL_ADR_INT_KER_WIDTH 1
-#define        FRF_AZ_SRM_PERR_INT_KER_LBN 0
-#define        FRF_AZ_SRM_PERR_INT_KER_WIDTH 1
-
-/* FATAL_INTR_REG_CHAR: Fatal interrupt register for Char */
-#define        FR_BZ_FATAL_INTR_CHAR 0x00000240
-#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_EN_LBN 44
-#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_EN_WIDTH 1
-#define        FRF_BB_PCI_BUSERR_INT_CHAR_EN_LBN 43
-#define        FRF_BB_PCI_BUSERR_INT_CHAR_EN_WIDTH 1
-#define        FRF_CZ_MBU_PERR_INT_CHAR_EN_LBN 43
-#define        FRF_CZ_MBU_PERR_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_SRAM_OOB_INT_CHAR_EN_LBN 42
-#define        FRF_BZ_SRAM_OOB_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_BUFID_OOB_INT_CHAR_EN_LBN 41
-#define        FRF_BZ_BUFID_OOB_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_MEM_PERR_INT_CHAR_EN_LBN 40
-#define        FRF_BZ_MEM_PERR_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_RBUF_OWN_INT_CHAR_EN_LBN 39
-#define        FRF_BZ_RBUF_OWN_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_TBUF_OWN_INT_CHAR_EN_LBN 38
-#define        FRF_BZ_TBUF_OWN_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_EN_LBN 37
-#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_EN_LBN 36
-#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_EVQ_OWN_INT_CHAR_EN_LBN 35
-#define        FRF_BZ_EVQ_OWN_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_EVF_OFLO_INT_CHAR_EN_LBN 34
-#define        FRF_BZ_EVF_OFLO_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_ILL_ADR_INT_CHAR_EN_LBN 33
-#define        FRF_BZ_ILL_ADR_INT_CHAR_EN_WIDTH 1
-#define        FRF_BZ_SRM_PERR_INT_CHAR_EN_LBN 32
-#define        FRF_BZ_SRM_PERR_INT_CHAR_EN_WIDTH 1
-#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_LBN 12
-#define        FRF_CZ_SRAM_PERR_INT_P_CHAR_WIDTH 1
-#define        FRF_BB_PCI_BUSERR_INT_CHAR_LBN 11
-#define        FRF_BB_PCI_BUSERR_INT_CHAR_WIDTH 1
-#define        FRF_CZ_MBU_PERR_INT_CHAR_LBN 11
-#define        FRF_CZ_MBU_PERR_INT_CHAR_WIDTH 1
-#define        FRF_BZ_SRAM_OOB_INT_CHAR_LBN 10
-#define        FRF_BZ_SRAM_OOB_INT_CHAR_WIDTH 1
-#define        FRF_BZ_BUFID_DC_OOB_INT_CHAR_LBN 9
-#define        FRF_BZ_BUFID_DC_OOB_INT_CHAR_WIDTH 1
-#define        FRF_BZ_MEM_PERR_INT_CHAR_LBN 8
-#define        FRF_BZ_MEM_PERR_INT_CHAR_WIDTH 1
-#define        FRF_BZ_RBUF_OWN_INT_CHAR_LBN 7
-#define        FRF_BZ_RBUF_OWN_INT_CHAR_WIDTH 1
-#define        FRF_BZ_TBUF_OWN_INT_CHAR_LBN 6
-#define        FRF_BZ_TBUF_OWN_INT_CHAR_WIDTH 1
-#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_LBN 5
-#define        FRF_BZ_RDESCQ_OWN_INT_CHAR_WIDTH 1
-#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_LBN 4
-#define        FRF_BZ_TDESCQ_OWN_INT_CHAR_WIDTH 1
-#define        FRF_BZ_EVQ_OWN_INT_CHAR_LBN 3
-#define        FRF_BZ_EVQ_OWN_INT_CHAR_WIDTH 1
-#define        FRF_BZ_EVF_OFLO_INT_CHAR_LBN 2
-#define        FRF_BZ_EVF_OFLO_INT_CHAR_WIDTH 1
-#define        FRF_BZ_ILL_ADR_INT_CHAR_LBN 1
-#define        FRF_BZ_ILL_ADR_INT_CHAR_WIDTH 1
-#define        FRF_BZ_SRM_PERR_INT_CHAR_LBN 0
-#define        FRF_BZ_SRM_PERR_INT_CHAR_WIDTH 1
-
-/* DP_CTRL_REG: Datapath control register */
-#define        FR_BZ_DP_CTRL 0x00000250
-#define        FRF_BZ_FLS_EVQ_ID_LBN 0
-#define        FRF_BZ_FLS_EVQ_ID_WIDTH 12
-
-/* MEM_STAT_REG: Memory status register */
-#define        FR_AZ_MEM_STAT 0x00000260
-#define        FRF_AB_MEM_PERR_VEC_LBN 53
-#define        FRF_AB_MEM_PERR_VEC_WIDTH 38
-#define        FRF_AB_MBIST_CORR_LBN 38
-#define        FRF_AB_MBIST_CORR_WIDTH 15
-#define        FRF_AB_MBIST_ERR_LBN 0
-#define        FRF_AB_MBIST_ERR_WIDTH 40
-#define        FRF_CZ_MEM_PERR_VEC_LBN 0
-#define        FRF_CZ_MEM_PERR_VEC_WIDTH 35
-
-/* CS_DEBUG_REG: Debug register */
-#define        FR_AZ_CS_DEBUG 0x00000270
-#define        FRF_AB_GLB_DEBUG2_SEL_LBN 50
-#define        FRF_AB_GLB_DEBUG2_SEL_WIDTH 3
-#define        FRF_AB_DEBUG_BLK_SEL2_LBN 47
-#define        FRF_AB_DEBUG_BLK_SEL2_WIDTH 3
-#define        FRF_AB_DEBUG_BLK_SEL1_LBN 44
-#define        FRF_AB_DEBUG_BLK_SEL1_WIDTH 3
-#define        FRF_AB_DEBUG_BLK_SEL0_LBN 41
-#define        FRF_AB_DEBUG_BLK_SEL0_WIDTH 3
-#define        FRF_CZ_CS_PORT_NUM_LBN 40
-#define        FRF_CZ_CS_PORT_NUM_WIDTH 2
-#define        FRF_AB_MISC_DEBUG_ADDR_LBN 36
-#define        FRF_AB_MISC_DEBUG_ADDR_WIDTH 5
-#define        FRF_AB_SERDES_DEBUG_ADDR_LBN 31
-#define        FRF_AB_SERDES_DEBUG_ADDR_WIDTH 5
-#define        FRF_CZ_CS_PORT_FPE_LBN 1
-#define        FRF_CZ_CS_PORT_FPE_WIDTH 35
-#define        FRF_AB_EM_DEBUG_ADDR_LBN 26
-#define        FRF_AB_EM_DEBUG_ADDR_WIDTH 5
-#define        FRF_AB_SR_DEBUG_ADDR_LBN 21
-#define        FRF_AB_SR_DEBUG_ADDR_WIDTH 5
-#define        FRF_AB_EV_DEBUG_ADDR_LBN 16
-#define        FRF_AB_EV_DEBUG_ADDR_WIDTH 5
-#define        FRF_AB_RX_DEBUG_ADDR_LBN 11
-#define        FRF_AB_RX_DEBUG_ADDR_WIDTH 5
-#define        FRF_AB_TX_DEBUG_ADDR_LBN 6
-#define        FRF_AB_TX_DEBUG_ADDR_WIDTH 5
-#define        FRF_AB_CS_BIU_DEBUG_ADDR_LBN 1
-#define        FRF_AB_CS_BIU_DEBUG_ADDR_WIDTH 5
-#define        FRF_AZ_CS_DEBUG_EN_LBN 0
-#define        FRF_AZ_CS_DEBUG_EN_WIDTH 1
-
-/* DRIVER_REG: Driver scratch register [0-7] */
-#define        FR_AZ_DRIVER 0x00000280
-#define        FR_AZ_DRIVER_STEP 16
-#define        FR_AZ_DRIVER_ROWS 8
-#define        FRF_AZ_DRIVER_DW0_LBN 0
-#define        FRF_AZ_DRIVER_DW0_WIDTH 32
-
-/* ALTERA_BUILD_REG: Altera build register */
-#define        FR_AZ_ALTERA_BUILD 0x00000300
-#define        FRF_AZ_ALTERA_BUILD_VER_LBN 0
-#define        FRF_AZ_ALTERA_BUILD_VER_WIDTH 32
-
-/* CSR_SPARE_REG: Spare register */
-#define        FR_AZ_CSR_SPARE 0x00000310
-#define        FRF_AB_MEM_PERR_EN_LBN 64
-#define        FRF_AB_MEM_PERR_EN_WIDTH 38
-#define        FRF_CZ_MEM_PERR_EN_LBN 64
-#define        FRF_CZ_MEM_PERR_EN_WIDTH 35
-#define        FRF_AB_MEM_PERR_EN_TX_DATA_LBN 72
-#define        FRF_AB_MEM_PERR_EN_TX_DATA_WIDTH 2
-#define        FRF_AZ_CSR_SPARE_BITS_LBN 0
-#define        FRF_AZ_CSR_SPARE_BITS_WIDTH 32
-
-/* PCIE_SD_CTL0123_REG: PCIE SerDes control register 0 to 3 */
-#define        FR_AB_PCIE_SD_CTL0123 0x00000320
-#define        FRF_AB_PCIE_TESTSIG_H_LBN 96
-#define        FRF_AB_PCIE_TESTSIG_H_WIDTH 19
-#define        FRF_AB_PCIE_TESTSIG_L_LBN 64
-#define        FRF_AB_PCIE_TESTSIG_L_WIDTH 19
-#define        FRF_AB_PCIE_OFFSET_LBN 56
-#define        FRF_AB_PCIE_OFFSET_WIDTH 8
-#define        FRF_AB_PCIE_OFFSETEN_H_LBN 55
-#define        FRF_AB_PCIE_OFFSETEN_H_WIDTH 1
-#define        FRF_AB_PCIE_OFFSETEN_L_LBN 54
-#define        FRF_AB_PCIE_OFFSETEN_L_WIDTH 1
-#define        FRF_AB_PCIE_HIVMODE_H_LBN 53
-#define        FRF_AB_PCIE_HIVMODE_H_WIDTH 1
-#define        FRF_AB_PCIE_HIVMODE_L_LBN 52
-#define        FRF_AB_PCIE_HIVMODE_L_WIDTH 1
-#define        FRF_AB_PCIE_PARRESET_H_LBN 51
-#define        FRF_AB_PCIE_PARRESET_H_WIDTH 1
-#define        FRF_AB_PCIE_PARRESET_L_LBN 50
-#define        FRF_AB_PCIE_PARRESET_L_WIDTH 1
-#define        FRF_AB_PCIE_LPBKWDRV_H_LBN 49
-#define        FRF_AB_PCIE_LPBKWDRV_H_WIDTH 1
-#define        FRF_AB_PCIE_LPBKWDRV_L_LBN 48
-#define        FRF_AB_PCIE_LPBKWDRV_L_WIDTH 1
-#define        FRF_AB_PCIE_LPBK_LBN 40
-#define        FRF_AB_PCIE_LPBK_WIDTH 8
-#define        FRF_AB_PCIE_PARLPBK_LBN 32
-#define        FRF_AB_PCIE_PARLPBK_WIDTH 8
-#define        FRF_AB_PCIE_RXTERMADJ_H_LBN 30
-#define        FRF_AB_PCIE_RXTERMADJ_H_WIDTH 2
-#define        FRF_AB_PCIE_RXTERMADJ_L_LBN 28
-#define        FRF_AB_PCIE_RXTERMADJ_L_WIDTH 2
-#define        FFE_AB_PCIE_RXTERMADJ_MIN15PCNT 3
-#define        FFE_AB_PCIE_RXTERMADJ_PL10PCNT 2
-#define        FFE_AB_PCIE_RXTERMADJ_MIN17PCNT 1
-#define        FFE_AB_PCIE_RXTERMADJ_NOMNL 0
-#define        FRF_AB_PCIE_TXTERMADJ_H_LBN 26
-#define        FRF_AB_PCIE_TXTERMADJ_H_WIDTH 2
-#define        FRF_AB_PCIE_TXTERMADJ_L_LBN 24
-#define        FRF_AB_PCIE_TXTERMADJ_L_WIDTH 2
-#define        FFE_AB_PCIE_TXTERMADJ_MIN15PCNT 3
-#define        FFE_AB_PCIE_TXTERMADJ_PL10PCNT 2
-#define        FFE_AB_PCIE_TXTERMADJ_MIN17PCNT 1
-#define        FFE_AB_PCIE_TXTERMADJ_NOMNL 0
-#define        FRF_AB_PCIE_RXEQCTL_H_LBN 18
-#define        FRF_AB_PCIE_RXEQCTL_H_WIDTH 2
-#define        FRF_AB_PCIE_RXEQCTL_L_LBN 16
-#define        FRF_AB_PCIE_RXEQCTL_L_WIDTH 2
-#define        FFE_AB_PCIE_RXEQCTL_OFF_ALT 3
-#define        FFE_AB_PCIE_RXEQCTL_OFF 2
-#define        FFE_AB_PCIE_RXEQCTL_MIN 1
-#define        FFE_AB_PCIE_RXEQCTL_MAX 0
-#define        FRF_AB_PCIE_HIDRV_LBN 8
-#define        FRF_AB_PCIE_HIDRV_WIDTH 8
-#define        FRF_AB_PCIE_LODRV_LBN 0
-#define        FRF_AB_PCIE_LODRV_WIDTH 8
-
-/* PCIE_SD_CTL45_REG: PCIE SerDes control register 4 and 5 */
-#define        FR_AB_PCIE_SD_CTL45 0x00000330
-#define        FRF_AB_PCIE_DTX7_LBN 60
-#define        FRF_AB_PCIE_DTX7_WIDTH 4
-#define        FRF_AB_PCIE_DTX6_LBN 56
-#define        FRF_AB_PCIE_DTX6_WIDTH 4
-#define        FRF_AB_PCIE_DTX5_LBN 52
-#define        FRF_AB_PCIE_DTX5_WIDTH 4
-#define        FRF_AB_PCIE_DTX4_LBN 48
-#define        FRF_AB_PCIE_DTX4_WIDTH 4
-#define        FRF_AB_PCIE_DTX3_LBN 44
-#define        FRF_AB_PCIE_DTX3_WIDTH 4
-#define        FRF_AB_PCIE_DTX2_LBN 40
-#define        FRF_AB_PCIE_DTX2_WIDTH 4
-#define        FRF_AB_PCIE_DTX1_LBN 36
-#define        FRF_AB_PCIE_DTX1_WIDTH 4
-#define        FRF_AB_PCIE_DTX0_LBN 32
-#define        FRF_AB_PCIE_DTX0_WIDTH 4
-#define        FRF_AB_PCIE_DEQ7_LBN 28
-#define        FRF_AB_PCIE_DEQ7_WIDTH 4
-#define        FRF_AB_PCIE_DEQ6_LBN 24
-#define        FRF_AB_PCIE_DEQ6_WIDTH 4
-#define        FRF_AB_PCIE_DEQ5_LBN 20
-#define        FRF_AB_PCIE_DEQ5_WIDTH 4
-#define        FRF_AB_PCIE_DEQ4_LBN 16
-#define        FRF_AB_PCIE_DEQ4_WIDTH 4
-#define        FRF_AB_PCIE_DEQ3_LBN 12
-#define        FRF_AB_PCIE_DEQ3_WIDTH 4
-#define        FRF_AB_PCIE_DEQ2_LBN 8
-#define        FRF_AB_PCIE_DEQ2_WIDTH 4
-#define        FRF_AB_PCIE_DEQ1_LBN 4
-#define        FRF_AB_PCIE_DEQ1_WIDTH 4
-#define        FRF_AB_PCIE_DEQ0_LBN 0
-#define        FRF_AB_PCIE_DEQ0_WIDTH 4
-
-/* PCIE_PCS_CTL_STAT_REG: PCIE PCS control and status register */
-#define        FR_AB_PCIE_PCS_CTL_STAT 0x00000340
-#define        FRF_AB_PCIE_PRBSERRCOUNT0_H_LBN 52
-#define        FRF_AB_PCIE_PRBSERRCOUNT0_H_WIDTH 4
-#define        FRF_AB_PCIE_PRBSERRCOUNT0_L_LBN 48
-#define        FRF_AB_PCIE_PRBSERRCOUNT0_L_WIDTH 4
-#define        FRF_AB_PCIE_PRBSERR_LBN 40
-#define        FRF_AB_PCIE_PRBSERR_WIDTH 8
-#define        FRF_AB_PCIE_PRBSERRH0_LBN 32
-#define        FRF_AB_PCIE_PRBSERRH0_WIDTH 8
-#define        FRF_AB_PCIE_FASTINIT_H_LBN 15
-#define        FRF_AB_PCIE_FASTINIT_H_WIDTH 1
-#define        FRF_AB_PCIE_FASTINIT_L_LBN 14
-#define        FRF_AB_PCIE_FASTINIT_L_WIDTH 1
-#define        FRF_AB_PCIE_CTCDISABLE_H_LBN 13
-#define        FRF_AB_PCIE_CTCDISABLE_H_WIDTH 1
-#define        FRF_AB_PCIE_CTCDISABLE_L_LBN 12
-#define        FRF_AB_PCIE_CTCDISABLE_L_WIDTH 1
-#define        FRF_AB_PCIE_PRBSSYNC_H_LBN 11
-#define        FRF_AB_PCIE_PRBSSYNC_H_WIDTH 1
-#define        FRF_AB_PCIE_PRBSSYNC_L_LBN 10
-#define        FRF_AB_PCIE_PRBSSYNC_L_WIDTH 1
-#define        FRF_AB_PCIE_PRBSERRACK_H_LBN 9
-#define        FRF_AB_PCIE_PRBSERRACK_H_WIDTH 1
-#define        FRF_AB_PCIE_PRBSERRACK_L_LBN 8
-#define        FRF_AB_PCIE_PRBSERRACK_L_WIDTH 1
-#define        FRF_AB_PCIE_PRBSSEL_LBN 0
-#define        FRF_AB_PCIE_PRBSSEL_WIDTH 8
-
-/* DEBUG_DATA_OUT_REG: Live Debug and Debug 2 out ports */
-#define        FR_BB_DEBUG_DATA_OUT 0x00000350
-#define        FRF_BB_DEBUG2_PORT_LBN 25
-#define        FRF_BB_DEBUG2_PORT_WIDTH 15
-#define        FRF_BB_DEBUG1_PORT_LBN 0
-#define        FRF_BB_DEBUG1_PORT_WIDTH 25
-
-/* EVQ_RPTR_REGP0: Event queue read pointer register */
-#define        FR_BZ_EVQ_RPTR_P0 0x00000400
-#define        FR_BZ_EVQ_RPTR_P0_STEP 8192
-#define        FR_BZ_EVQ_RPTR_P0_ROWS 1024
-/* EVQ_RPTR_REG_KER: Event queue read pointer register */
-#define        FR_AA_EVQ_RPTR_KER 0x00011b00
-#define        FR_AA_EVQ_RPTR_KER_STEP 4
-#define        FR_AA_EVQ_RPTR_KER_ROWS 4
-/* EVQ_RPTR_REG: Event queue read pointer register */
-#define        FR_BZ_EVQ_RPTR 0x00fa0000
-#define        FR_BZ_EVQ_RPTR_STEP 16
-#define        FR_BB_EVQ_RPTR_ROWS 4096
-#define        FR_CZ_EVQ_RPTR_ROWS 1024
-/* EVQ_RPTR_REGP123: Event queue read pointer register */
-#define        FR_BB_EVQ_RPTR_P123 0x01000400
-#define        FR_BB_EVQ_RPTR_P123_STEP 8192
-#define        FR_BB_EVQ_RPTR_P123_ROWS 3072
-#define        FRF_AZ_EVQ_RPTR_VLD_LBN 15
-#define        FRF_AZ_EVQ_RPTR_VLD_WIDTH 1
-#define        FRF_AZ_EVQ_RPTR_LBN 0
-#define        FRF_AZ_EVQ_RPTR_WIDTH 15
-
-/* TIMER_COMMAND_REGP0: Timer Command Registers */
-#define        FR_BZ_TIMER_COMMAND_P0 0x00000420
-#define        FR_BZ_TIMER_COMMAND_P0_STEP 8192
-#define        FR_BZ_TIMER_COMMAND_P0_ROWS 1024
-/* TIMER_COMMAND_REG_KER: Timer Command Registers */
-#define        FR_AA_TIMER_COMMAND_KER 0x00000420
-#define        FR_AA_TIMER_COMMAND_KER_STEP 8192
-#define        FR_AA_TIMER_COMMAND_KER_ROWS 4
-/* TIMER_COMMAND_REGP123: Timer Command Registers */
-#define        FR_BB_TIMER_COMMAND_P123 0x01000420
-#define        FR_BB_TIMER_COMMAND_P123_STEP 8192
-#define        FR_BB_TIMER_COMMAND_P123_ROWS 3072
-#define        FRF_CZ_TC_TIMER_MODE_LBN 14
-#define        FRF_CZ_TC_TIMER_MODE_WIDTH 2
-#define        FRF_AB_TC_TIMER_MODE_LBN 12
-#define        FRF_AB_TC_TIMER_MODE_WIDTH 2
-#define        FRF_CZ_TC_TIMER_VAL_LBN 0
-#define        FRF_CZ_TC_TIMER_VAL_WIDTH 14
-#define        FRF_AB_TC_TIMER_VAL_LBN 0
-#define        FRF_AB_TC_TIMER_VAL_WIDTH 12
-
-/* DRV_EV_REG: Driver generated event register */
-#define        FR_AZ_DRV_EV 0x00000440
-#define        FRF_AZ_DRV_EV_QID_LBN 64
-#define        FRF_AZ_DRV_EV_QID_WIDTH 12
-#define        FRF_AZ_DRV_EV_DATA_LBN 0
-#define        FRF_AZ_DRV_EV_DATA_WIDTH 64
-
-/* EVQ_CTL_REG: Event queue control register */
-#define        FR_AZ_EVQ_CTL 0x00000450
-#define        FRF_CZ_RX_EVQ_WAKEUP_MASK_LBN 15
-#define        FRF_CZ_RX_EVQ_WAKEUP_MASK_WIDTH 10
-#define        FRF_BB_RX_EVQ_WAKEUP_MASK_LBN 15
-#define        FRF_BB_RX_EVQ_WAKEUP_MASK_WIDTH 6
-#define        FRF_AZ_EVQ_OWNERR_CTL_LBN 14
-#define        FRF_AZ_EVQ_OWNERR_CTL_WIDTH 1
-#define        FRF_AZ_EVQ_FIFO_AF_TH_LBN 7
-#define        FRF_AZ_EVQ_FIFO_AF_TH_WIDTH 7
-#define        FRF_AZ_EVQ_FIFO_NOTAF_TH_LBN 0
-#define        FRF_AZ_EVQ_FIFO_NOTAF_TH_WIDTH 7
-
-/* EVQ_CNT1_REG: Event counter 1 register */
-#define        FR_AZ_EVQ_CNT1 0x00000460
-#define        FRF_AZ_EVQ_CNT_PRE_FIFO_LBN 120
-#define        FRF_AZ_EVQ_CNT_PRE_FIFO_WIDTH 7
-#define        FRF_AZ_EVQ_CNT_TOBIU_LBN 100
-#define        FRF_AZ_EVQ_CNT_TOBIU_WIDTH 20
-#define        FRF_AZ_EVQ_TX_REQ_CNT_LBN 80
-#define        FRF_AZ_EVQ_TX_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_RX_REQ_CNT_LBN 60
-#define        FRF_AZ_EVQ_RX_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_EM_REQ_CNT_LBN 40
-#define        FRF_AZ_EVQ_EM_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_CSR_REQ_CNT_LBN 20
-#define        FRF_AZ_EVQ_CSR_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_ERR_REQ_CNT_LBN 0
-#define        FRF_AZ_EVQ_ERR_REQ_CNT_WIDTH 20
-
-/* EVQ_CNT2_REG: Event counter 2 register */
-#define        FR_AZ_EVQ_CNT2 0x00000470
-#define        FRF_AZ_EVQ_UPD_REQ_CNT_LBN 104
-#define        FRF_AZ_EVQ_UPD_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_CLR_REQ_CNT_LBN 84
-#define        FRF_AZ_EVQ_CLR_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_RDY_CNT_LBN 80
-#define        FRF_AZ_EVQ_RDY_CNT_WIDTH 4
-#define        FRF_AZ_EVQ_WU_REQ_CNT_LBN 60
-#define        FRF_AZ_EVQ_WU_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_WET_REQ_CNT_LBN 40
-#define        FRF_AZ_EVQ_WET_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_INIT_REQ_CNT_LBN 20
-#define        FRF_AZ_EVQ_INIT_REQ_CNT_WIDTH 20
-#define        FRF_AZ_EVQ_TM_REQ_CNT_LBN 0
-#define        FRF_AZ_EVQ_TM_REQ_CNT_WIDTH 20
-
-/* USR_EV_REG: Event mailbox register */
-#define        FR_CZ_USR_EV 0x00000540
-#define        FR_CZ_USR_EV_STEP 8192
-#define        FR_CZ_USR_EV_ROWS 1024
-#define        FRF_CZ_USR_EV_DATA_LBN 0
-#define        FRF_CZ_USR_EV_DATA_WIDTH 32
-
-/* BUF_TBL_CFG_REG: Buffer table configuration register */
-#define        FR_AZ_BUF_TBL_CFG 0x00000600
-#define        FRF_AZ_BUF_TBL_MODE_LBN 3
-#define        FRF_AZ_BUF_TBL_MODE_WIDTH 1
-
-/* SRM_RX_DC_CFG_REG: SRAM receive descriptor cache configuration register */
-#define        FR_AZ_SRM_RX_DC_CFG 0x00000610
-#define        FRF_AZ_SRM_CLK_TMP_EN_LBN 21
-#define        FRF_AZ_SRM_CLK_TMP_EN_WIDTH 1
-#define        FRF_AZ_SRM_RX_DC_BASE_ADR_LBN 0
-#define        FRF_AZ_SRM_RX_DC_BASE_ADR_WIDTH 21
-
-/* SRM_TX_DC_CFG_REG: SRAM transmit descriptor cache configuration register */
-#define        FR_AZ_SRM_TX_DC_CFG 0x00000620
-#define        FRF_AZ_SRM_TX_DC_BASE_ADR_LBN 0
-#define        FRF_AZ_SRM_TX_DC_BASE_ADR_WIDTH 21
-
-/* SRM_CFG_REG: SRAM configuration register */
-#define        FR_AZ_SRM_CFG 0x00000630
-#define        FRF_AZ_SRM_OOB_ADR_INTEN_LBN 5
-#define        FRF_AZ_SRM_OOB_ADR_INTEN_WIDTH 1
-#define        FRF_AZ_SRM_OOB_BUF_INTEN_LBN 4
-#define        FRF_AZ_SRM_OOB_BUF_INTEN_WIDTH 1
-#define        FRF_AZ_SRM_INIT_EN_LBN 3
-#define        FRF_AZ_SRM_INIT_EN_WIDTH 1
-#define        FRF_AZ_SRM_NUM_BANK_LBN 2
-#define        FRF_AZ_SRM_NUM_BANK_WIDTH 1
-#define        FRF_AZ_SRM_BANK_SIZE_LBN 0
-#define        FRF_AZ_SRM_BANK_SIZE_WIDTH 2
-
-/* BUF_TBL_UPD_REG: Buffer table update register */
-#define        FR_AZ_BUF_TBL_UPD 0x00000650
-#define        FRF_AZ_BUF_UPD_CMD_LBN 63
-#define        FRF_AZ_BUF_UPD_CMD_WIDTH 1
-#define        FRF_AZ_BUF_CLR_CMD_LBN 62
-#define        FRF_AZ_BUF_CLR_CMD_WIDTH 1
-#define        FRF_AZ_BUF_CLR_END_ID_LBN 32
-#define        FRF_AZ_BUF_CLR_END_ID_WIDTH 20
-#define        FRF_AZ_BUF_CLR_START_ID_LBN 0
-#define        FRF_AZ_BUF_CLR_START_ID_WIDTH 20
-
-/* SRM_UPD_EVQ_REG: Buffer table update register */
-#define        FR_AZ_SRM_UPD_EVQ 0x00000660
-#define        FRF_AZ_SRM_UPD_EVQ_ID_LBN 0
-#define        FRF_AZ_SRM_UPD_EVQ_ID_WIDTH 12
-
-/* SRAM_PARITY_REG: SRAM parity register. */
-#define        FR_AZ_SRAM_PARITY 0x00000670
-#define        FRF_CZ_BYPASS_ECC_LBN 3
-#define        FRF_CZ_BYPASS_ECC_WIDTH 1
-#define        FRF_CZ_SEC_INT_LBN 2
-#define        FRF_CZ_SEC_INT_WIDTH 1
-#define        FRF_CZ_FORCE_SRAM_DOUBLE_ERR_LBN 1
-#define        FRF_CZ_FORCE_SRAM_DOUBLE_ERR_WIDTH 1
-#define        FRF_AB_FORCE_SRAM_PERR_LBN 0
-#define        FRF_AB_FORCE_SRAM_PERR_WIDTH 1
-#define        FRF_CZ_FORCE_SRAM_SINGLE_ERR_LBN 0
-#define        FRF_CZ_FORCE_SRAM_SINGLE_ERR_WIDTH 1
-
-/* RX_CFG_REG: Receive configuration register */
-#define        FR_AZ_RX_CFG 0x00000800
-#define        FRF_CZ_RX_MIN_KBUF_SIZE_LBN 72
-#define        FRF_CZ_RX_MIN_KBUF_SIZE_WIDTH 14
-#define        FRF_CZ_RX_HDR_SPLIT_EN_LBN 71
-#define        FRF_CZ_RX_HDR_SPLIT_EN_WIDTH 1
-#define        FRF_CZ_RX_HDR_SPLIT_PLD_BUF_SIZE_LBN 62
-#define        FRF_CZ_RX_HDR_SPLIT_PLD_BUF_SIZE_WIDTH 9
-#define        FRF_CZ_RX_HDR_SPLIT_HDR_BUF_SIZE_LBN 53
-#define        FRF_CZ_RX_HDR_SPLIT_HDR_BUF_SIZE_WIDTH 9
-#define        FRF_CZ_RX_PRE_RFF_IPG_LBN 49
-#define        FRF_CZ_RX_PRE_RFF_IPG_WIDTH 4
-#define        FRF_BZ_RX_TCP_SUP_LBN 48
-#define        FRF_BZ_RX_TCP_SUP_WIDTH 1
-#define        FRF_BZ_RX_INGR_EN_LBN 47
-#define        FRF_BZ_RX_INGR_EN_WIDTH 1
-#define        FRF_BZ_RX_IP_HASH_LBN 46
-#define        FRF_BZ_RX_IP_HASH_WIDTH 1
-#define        FRF_BZ_RX_HASH_ALG_LBN 45
-#define        FRF_BZ_RX_HASH_ALG_WIDTH 1
-#define        FRF_BZ_RX_HASH_INSRT_HDR_LBN 44
-#define        FRF_BZ_RX_HASH_INSRT_HDR_WIDTH 1
-#define        FRF_BZ_RX_DESC_PUSH_EN_LBN 43
-#define        FRF_BZ_RX_DESC_PUSH_EN_WIDTH 1
-#define        FRF_BZ_RX_RDW_PATCH_EN_LBN 42
-#define        FRF_BZ_RX_RDW_PATCH_EN_WIDTH 1
-#define        FRF_BB_RX_PCI_BURST_SIZE_LBN 39
-#define        FRF_BB_RX_PCI_BURST_SIZE_WIDTH 3
-#define        FRF_BZ_RX_OWNERR_CTL_LBN 38
-#define        FRF_BZ_RX_OWNERR_CTL_WIDTH 1
-#define        FRF_BZ_RX_XON_TX_TH_LBN 33
-#define        FRF_BZ_RX_XON_TX_TH_WIDTH 5
-#define        FRF_AA_RX_DESC_PUSH_EN_LBN 35
-#define        FRF_AA_RX_DESC_PUSH_EN_WIDTH 1
-#define        FRF_AA_RX_RDW_PATCH_EN_LBN 34
-#define        FRF_AA_RX_RDW_PATCH_EN_WIDTH 1
-#define        FRF_AA_RX_PCI_BURST_SIZE_LBN 31
-#define        FRF_AA_RX_PCI_BURST_SIZE_WIDTH 3
-#define        FRF_BZ_RX_XOFF_TX_TH_LBN 28
-#define        FRF_BZ_RX_XOFF_TX_TH_WIDTH 5
-#define        FRF_AA_RX_OWNERR_CTL_LBN 30
-#define        FRF_AA_RX_OWNERR_CTL_WIDTH 1
-#define        FRF_AA_RX_XON_TX_TH_LBN 25
-#define        FRF_AA_RX_XON_TX_TH_WIDTH 5
-#define        FRF_BZ_RX_USR_BUF_SIZE_LBN 19
-#define        FRF_BZ_RX_USR_BUF_SIZE_WIDTH 9
-#define        FRF_AA_RX_XOFF_TX_TH_LBN 20
-#define        FRF_AA_RX_XOFF_TX_TH_WIDTH 5
-#define        FRF_AA_RX_USR_BUF_SIZE_LBN 11
-#define        FRF_AA_RX_USR_BUF_SIZE_WIDTH 9
-#define        FRF_BZ_RX_XON_MAC_TH_LBN 10
-#define        FRF_BZ_RX_XON_MAC_TH_WIDTH 9
-#define        FRF_AA_RX_XON_MAC_TH_LBN 6
-#define        FRF_AA_RX_XON_MAC_TH_WIDTH 5
-#define        FRF_BZ_RX_XOFF_MAC_TH_LBN 1
-#define        FRF_BZ_RX_XOFF_MAC_TH_WIDTH 9
-#define        FRF_AA_RX_XOFF_MAC_TH_LBN 1
-#define        FRF_AA_RX_XOFF_MAC_TH_WIDTH 5
-#define        FRF_AZ_RX_XOFF_MAC_EN_LBN 0
-#define        FRF_AZ_RX_XOFF_MAC_EN_WIDTH 1
-
-/* RX_FILTER_CTL_REG: Receive filter control registers */
-#define        FR_BZ_RX_FILTER_CTL 0x00000810
-#define        FRF_CZ_ETHERNET_WILDCARD_SEARCH_LIMIT_LBN 94
-#define        FRF_CZ_ETHERNET_WILDCARD_SEARCH_LIMIT_WIDTH 8
-#define        FRF_CZ_ETHERNET_FULL_SEARCH_LIMIT_LBN 86
-#define        FRF_CZ_ETHERNET_FULL_SEARCH_LIMIT_WIDTH 8
-#define        FRF_CZ_RX_FILTER_ALL_VLAN_ETHERTYPES_LBN 85
-#define        FRF_CZ_RX_FILTER_ALL_VLAN_ETHERTYPES_WIDTH 1
-#define        FRF_CZ_RX_VLAN_MATCH_ETHERTYPE_LBN 69
-#define        FRF_CZ_RX_VLAN_MATCH_ETHERTYPE_WIDTH 16
-#define        FRF_CZ_MULTICAST_NOMATCH_Q_ID_LBN 57
-#define        FRF_CZ_MULTICAST_NOMATCH_Q_ID_WIDTH 12
-#define        FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED_LBN 56
-#define        FRF_CZ_MULTICAST_NOMATCH_RSS_ENABLED_WIDTH 1
-#define        FRF_CZ_MULTICAST_NOMATCH_IP_OVERRIDE_LBN 55
-#define        FRF_CZ_MULTICAST_NOMATCH_IP_OVERRIDE_WIDTH 1
-#define        FRF_CZ_UNICAST_NOMATCH_Q_ID_LBN 43
-#define        FRF_CZ_UNICAST_NOMATCH_Q_ID_WIDTH 12
-#define        FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED_LBN 42
-#define        FRF_CZ_UNICAST_NOMATCH_RSS_ENABLED_WIDTH 1
-#define        FRF_CZ_UNICAST_NOMATCH_IP_OVERRIDE_LBN 41
-#define        FRF_CZ_UNICAST_NOMATCH_IP_OVERRIDE_WIDTH 1
-#define        FRF_BZ_SCATTER_ENBL_NO_MATCH_Q_LBN 40
-#define        FRF_BZ_SCATTER_ENBL_NO_MATCH_Q_WIDTH 1
-#define        FRF_BZ_UDP_FULL_SRCH_LIMIT_LBN 32
-#define        FRF_BZ_UDP_FULL_SRCH_LIMIT_WIDTH 8
-#define        FRF_BZ_NUM_KER_LBN 24
-#define        FRF_BZ_NUM_KER_WIDTH 2
-#define        FRF_BZ_UDP_WILD_SRCH_LIMIT_LBN 16
-#define        FRF_BZ_UDP_WILD_SRCH_LIMIT_WIDTH 8
-#define        FRF_BZ_TCP_WILD_SRCH_LIMIT_LBN 8
-#define        FRF_BZ_TCP_WILD_SRCH_LIMIT_WIDTH 8
-#define        FRF_BZ_TCP_FULL_SRCH_LIMIT_LBN 0
-#define        FRF_BZ_TCP_FULL_SRCH_LIMIT_WIDTH 8
-
-/* RX_FLUSH_DESCQ_REG: Receive flush descriptor queue register */
-#define        FR_AZ_RX_FLUSH_DESCQ 0x00000820
-#define        FRF_AZ_RX_FLUSH_DESCQ_CMD_LBN 24
-#define        FRF_AZ_RX_FLUSH_DESCQ_CMD_WIDTH 1
-#define        FRF_AZ_RX_FLUSH_DESCQ_LBN 0
-#define        FRF_AZ_RX_FLUSH_DESCQ_WIDTH 12
-
-/* RX_DESC_UPD_REGP0: Receive descriptor update register. */
-#define        FR_BZ_RX_DESC_UPD_P0 0x00000830
-#define        FR_BZ_RX_DESC_UPD_P0_STEP 8192
-#define        FR_BZ_RX_DESC_UPD_P0_ROWS 1024
-/* RX_DESC_UPD_REG_KER: Receive descriptor update register. */
-#define        FR_AA_RX_DESC_UPD_KER 0x00000830
-#define        FR_AA_RX_DESC_UPD_KER_STEP 8192
-#define        FR_AA_RX_DESC_UPD_KER_ROWS 4
-/* RX_DESC_UPD_REGP123: Receive descriptor update register. */
-#define        FR_BB_RX_DESC_UPD_P123 0x01000830
-#define        FR_BB_RX_DESC_UPD_P123_STEP 8192
-#define        FR_BB_RX_DESC_UPD_P123_ROWS 3072
-#define        FRF_AZ_RX_DESC_WPTR_LBN 96
-#define        FRF_AZ_RX_DESC_WPTR_WIDTH 12
-#define        FRF_AZ_RX_DESC_PUSH_CMD_LBN 95
-#define        FRF_AZ_RX_DESC_PUSH_CMD_WIDTH 1
-#define        FRF_AZ_RX_DESC_LBN 0
-#define        FRF_AZ_RX_DESC_WIDTH 64
-
-/* RX_DC_CFG_REG: Receive descriptor cache configuration register */
-#define        FR_AZ_RX_DC_CFG 0x00000840
-#define        FRF_AB_RX_MAX_PF_LBN 2
-#define        FRF_AB_RX_MAX_PF_WIDTH 2
-#define        FRF_AZ_RX_DC_SIZE_LBN 0
-#define        FRF_AZ_RX_DC_SIZE_WIDTH 2
-#define        FFE_AZ_RX_DC_SIZE_64 3
-#define        FFE_AZ_RX_DC_SIZE_32 2
-#define        FFE_AZ_RX_DC_SIZE_16 1
-#define        FFE_AZ_RX_DC_SIZE_8 0
-
-/* RX_DC_PF_WM_REG: Receive descriptor cache pre-fetch watermark register */
-#define        FR_AZ_RX_DC_PF_WM 0x00000850
-#define        FRF_AZ_RX_DC_PF_HWM_LBN 6
-#define        FRF_AZ_RX_DC_PF_HWM_WIDTH 6
-#define        FRF_AZ_RX_DC_PF_LWM_LBN 0
-#define        FRF_AZ_RX_DC_PF_LWM_WIDTH 6
-
-/* RX_RSS_TKEY_REG: RSS Toeplitz hash key */
-#define        FR_BZ_RX_RSS_TKEY 0x00000860
-#define        FRF_BZ_RX_RSS_TKEY_HI_LBN 64
-#define        FRF_BZ_RX_RSS_TKEY_HI_WIDTH 64
-#define        FRF_BZ_RX_RSS_TKEY_LO_LBN 0
-#define        FRF_BZ_RX_RSS_TKEY_LO_WIDTH 64
-
-/* RX_NODESC_DROP_REG: Receive dropped packet counter register */
-#define        FR_AZ_RX_NODESC_DROP 0x00000880
-#define        FRF_CZ_RX_NODESC_DROP_CNT_LBN 0
-#define        FRF_CZ_RX_NODESC_DROP_CNT_WIDTH 32
-#define        FRF_AB_RX_NODESC_DROP_CNT_LBN 0
-#define        FRF_AB_RX_NODESC_DROP_CNT_WIDTH 16
-
-/* RX_SELF_RST_REG: Receive self reset register */
-#define        FR_AA_RX_SELF_RST 0x00000890
-#define        FRF_AA_RX_ISCSI_DIS_LBN 17
-#define        FRF_AA_RX_ISCSI_DIS_WIDTH 1
-#define        FRF_AA_RX_SW_RST_REG_LBN 16
-#define        FRF_AA_RX_SW_RST_REG_WIDTH 1
-#define FRF_AA_RX_NODESC_WAIT_DIS_LBN 9
-#define FRF_AA_RX_NODESC_WAIT_DIS_WIDTH 1
-#define        FRF_AA_RX_SELF_RST_EN_LBN 8
-#define        FRF_AA_RX_SELF_RST_EN_WIDTH 1
-#define        FRF_AA_RX_MAX_PF_LAT_LBN 4
-#define        FRF_AA_RX_MAX_PF_LAT_WIDTH 4
-#define        FRF_AA_RX_MAX_LU_LAT_LBN 0
-#define        FRF_AA_RX_MAX_LU_LAT_WIDTH 4
-
-/* RX_DEBUG_REG: undocumented register */
-#define        FR_AZ_RX_DEBUG 0x000008a0
-#define        FRF_AZ_RX_DEBUG_LBN 0
-#define        FRF_AZ_RX_DEBUG_WIDTH 64
-
-/* RX_PUSH_DROP_REG: Receive descriptor push dropped counter register */
-#define        FR_AZ_RX_PUSH_DROP 0x000008b0
-#define        FRF_AZ_RX_PUSH_DROP_CNT_LBN 0
-#define        FRF_AZ_RX_PUSH_DROP_CNT_WIDTH 32
-
-/* RX_RSS_IPV6_REG1: IPv6 RSS Toeplitz hash key low bytes */
-#define        FR_CZ_RX_RSS_IPV6_REG1 0x000008d0
-#define        FRF_CZ_RX_RSS_IPV6_TKEY_LO_LBN 0
-#define        FRF_CZ_RX_RSS_IPV6_TKEY_LO_WIDTH 128
-
-/* RX_RSS_IPV6_REG2: IPv6 RSS Toeplitz hash key middle bytes */
-#define        FR_CZ_RX_RSS_IPV6_REG2 0x000008e0
-#define        FRF_CZ_RX_RSS_IPV6_TKEY_MID_LBN 0
-#define        FRF_CZ_RX_RSS_IPV6_TKEY_MID_WIDTH 128
-
-/* RX_RSS_IPV6_REG3: IPv6 RSS Toeplitz hash key upper bytes and IPv6 RSS settings */
-#define        FR_CZ_RX_RSS_IPV6_REG3 0x000008f0
-#define        FRF_CZ_RX_RSS_IPV6_THASH_ENABLE_LBN 66
-#define        FRF_CZ_RX_RSS_IPV6_THASH_ENABLE_WIDTH 1
-#define        FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE_LBN 65
-#define        FRF_CZ_RX_RSS_IPV6_IP_THASH_ENABLE_WIDTH 1
-#define        FRF_CZ_RX_RSS_IPV6_TCP_SUPPRESS_LBN 64
-#define        FRF_CZ_RX_RSS_IPV6_TCP_SUPPRESS_WIDTH 1
-#define        FRF_CZ_RX_RSS_IPV6_TKEY_HI_LBN 0
-#define        FRF_CZ_RX_RSS_IPV6_TKEY_HI_WIDTH 64
-
-/* TX_FLUSH_DESCQ_REG: Transmit flush descriptor queue register */
-#define        FR_AZ_TX_FLUSH_DESCQ 0x00000a00
-#define        FRF_AZ_TX_FLUSH_DESCQ_CMD_LBN 12
-#define        FRF_AZ_TX_FLUSH_DESCQ_CMD_WIDTH 1
-#define        FRF_AZ_TX_FLUSH_DESCQ_LBN 0
-#define        FRF_AZ_TX_FLUSH_DESCQ_WIDTH 12
-
-/* TX_DESC_UPD_REGP0: Transmit descriptor update register. */
-#define        FR_BZ_TX_DESC_UPD_P0 0x00000a10
-#define        FR_BZ_TX_DESC_UPD_P0_STEP 8192
-#define        FR_BZ_TX_DESC_UPD_P0_ROWS 1024
-/* TX_DESC_UPD_REG_KER: Transmit descriptor update register. */
-#define        FR_AA_TX_DESC_UPD_KER 0x00000a10
-#define        FR_AA_TX_DESC_UPD_KER_STEP 8192
-#define        FR_AA_TX_DESC_UPD_KER_ROWS 8
-/* TX_DESC_UPD_REGP123: Transmit descriptor update register. */
-#define        FR_BB_TX_DESC_UPD_P123 0x01000a10
-#define        FR_BB_TX_DESC_UPD_P123_STEP 8192
-#define        FR_BB_TX_DESC_UPD_P123_ROWS 3072
-#define        FRF_AZ_TX_DESC_WPTR_LBN 96
-#define        FRF_AZ_TX_DESC_WPTR_WIDTH 12
-#define        FRF_AZ_TX_DESC_PUSH_CMD_LBN 95
-#define        FRF_AZ_TX_DESC_PUSH_CMD_WIDTH 1
-#define        FRF_AZ_TX_DESC_LBN 0
-#define        FRF_AZ_TX_DESC_WIDTH 95
-
-/* TX_DC_CFG_REG: Transmit descriptor cache configuration register */
-#define        FR_AZ_TX_DC_CFG 0x00000a20
-#define        FRF_AZ_TX_DC_SIZE_LBN 0
-#define        FRF_AZ_TX_DC_SIZE_WIDTH 2
-#define        FFE_AZ_TX_DC_SIZE_32 2
-#define        FFE_AZ_TX_DC_SIZE_16 1
-#define        FFE_AZ_TX_DC_SIZE_8 0
-
-/* TX_CHKSM_CFG_REG: Transmit checksum configuration register */
-#define        FR_AA_TX_CHKSM_CFG 0x00000a30
-#define        FRF_AA_TX_Q_CHKSM_DIS_96_127_LBN 96
-#define        FRF_AA_TX_Q_CHKSM_DIS_96_127_WIDTH 32
-#define        FRF_AA_TX_Q_CHKSM_DIS_64_95_LBN 64
-#define        FRF_AA_TX_Q_CHKSM_DIS_64_95_WIDTH 32
-#define        FRF_AA_TX_Q_CHKSM_DIS_32_63_LBN 32
-#define        FRF_AA_TX_Q_CHKSM_DIS_32_63_WIDTH 32
-#define        FRF_AA_TX_Q_CHKSM_DIS_0_31_LBN 0
-#define        FRF_AA_TX_Q_CHKSM_DIS_0_31_WIDTH 32
-
-/* TX_CFG_REG: Transmit configuration register */
-#define        FR_AZ_TX_CFG 0x00000a50
-#define        FRF_CZ_TX_CONT_LOOKUP_THRESH_RANGE_LBN 114
-#define        FRF_CZ_TX_CONT_LOOKUP_THRESH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_FILTER_TEST_MODE_BIT_LBN 113
-#define        FRF_CZ_TX_FILTER_TEST_MODE_BIT_WIDTH 1
-#define        FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE_LBN 105
-#define        FRF_CZ_TX_ETH_FILTER_WILD_SEARCH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE_LBN 97
-#define        FRF_CZ_TX_ETH_FILTER_FULL_SEARCH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_UDPIP_FILTER_WILD_SEARCH_RANGE_LBN 89
-#define        FRF_CZ_TX_UDPIP_FILTER_WILD_SEARCH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_UDPIP_FILTER_FULL_SEARCH_RANGE_LBN 81
-#define        FRF_CZ_TX_UDPIP_FILTER_FULL_SEARCH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_TCPIP_FILTER_WILD_SEARCH_RANGE_LBN 73
-#define        FRF_CZ_TX_TCPIP_FILTER_WILD_SEARCH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_TCPIP_FILTER_FULL_SEARCH_RANGE_LBN 65
-#define        FRF_CZ_TX_TCPIP_FILTER_FULL_SEARCH_RANGE_WIDTH 8
-#define        FRF_CZ_TX_FILTER_ALL_VLAN_ETHERTYPES_BIT_LBN 64
-#define        FRF_CZ_TX_FILTER_ALL_VLAN_ETHERTYPES_BIT_WIDTH 1
-#define        FRF_CZ_TX_VLAN_MATCH_ETHERTYPE_RANGE_LBN 48
-#define        FRF_CZ_TX_VLAN_MATCH_ETHERTYPE_RANGE_WIDTH 16
-#define        FRF_CZ_TX_FILTER_EN_BIT_LBN 47
-#define        FRF_CZ_TX_FILTER_EN_BIT_WIDTH 1
-#define        FRF_AZ_TX_IP_ID_P0_OFS_LBN 16
-#define        FRF_AZ_TX_IP_ID_P0_OFS_WIDTH 15
-#define        FRF_AZ_TX_NO_EOP_DISC_EN_LBN 5
-#define        FRF_AZ_TX_NO_EOP_DISC_EN_WIDTH 1
-#define        FRF_AZ_TX_P1_PRI_EN_LBN 4
-#define        FRF_AZ_TX_P1_PRI_EN_WIDTH 1
-#define        FRF_AZ_TX_OWNERR_CTL_LBN 2
-#define        FRF_AZ_TX_OWNERR_CTL_WIDTH 1
-#define        FRF_AA_TX_NON_IP_DROP_DIS_LBN 1
-#define        FRF_AA_TX_NON_IP_DROP_DIS_WIDTH 1
-#define        FRF_AZ_TX_IP_ID_REP_EN_LBN 0
-#define        FRF_AZ_TX_IP_ID_REP_EN_WIDTH 1
-
-/* TX_PUSH_DROP_REG: Transmit push dropped register */
-#define        FR_AZ_TX_PUSH_DROP 0x00000a60
-#define        FRF_AZ_TX_PUSH_DROP_CNT_LBN 0
-#define        FRF_AZ_TX_PUSH_DROP_CNT_WIDTH 32
-
-/* TX_RESERVED_REG: Transmit configuration register */
-#define        FR_AZ_TX_RESERVED 0x00000a80
-#define        FRF_AZ_TX_EVT_CNT_LBN 121
-#define        FRF_AZ_TX_EVT_CNT_WIDTH 7
-#define        FRF_AZ_TX_PREF_AGE_CNT_LBN 119
-#define        FRF_AZ_TX_PREF_AGE_CNT_WIDTH 2
-#define        FRF_AZ_TX_RD_COMP_TMR_LBN 96
-#define        FRF_AZ_TX_RD_COMP_TMR_WIDTH 23
-#define        FRF_AZ_TX_PUSH_EN_LBN 89
-#define        FRF_AZ_TX_PUSH_EN_WIDTH 1
-#define        FRF_AZ_TX_PUSH_CHK_DIS_LBN 88
-#define        FRF_AZ_TX_PUSH_CHK_DIS_WIDTH 1
-#define        FRF_AZ_TX_D_FF_FULL_P0_LBN 85
-#define        FRF_AZ_TX_D_FF_FULL_P0_WIDTH 1
-#define        FRF_AZ_TX_DMAR_ST_P0_LBN 81
-#define        FRF_AZ_TX_DMAR_ST_P0_WIDTH 1
-#define        FRF_AZ_TX_DMAQ_ST_LBN 78
-#define        FRF_AZ_TX_DMAQ_ST_WIDTH 1
-#define        FRF_AZ_TX_RX_SPACER_LBN 64
-#define        FRF_AZ_TX_RX_SPACER_WIDTH 8
-#define        FRF_AZ_TX_DROP_ABORT_EN_LBN 60
-#define        FRF_AZ_TX_DROP_ABORT_EN_WIDTH 1
-#define        FRF_AZ_TX_SOFT_EVT_EN_LBN 59
-#define        FRF_AZ_TX_SOFT_EVT_EN_WIDTH 1
-#define        FRF_AZ_TX_PS_EVT_DIS_LBN 58
-#define        FRF_AZ_TX_PS_EVT_DIS_WIDTH 1
-#define        FRF_AZ_TX_RX_SPACER_EN_LBN 57
-#define        FRF_AZ_TX_RX_SPACER_EN_WIDTH 1
-#define        FRF_AZ_TX_XP_TIMER_LBN 52
-#define        FRF_AZ_TX_XP_TIMER_WIDTH 5
-#define        FRF_AZ_TX_PREF_SPACER_LBN 44
-#define        FRF_AZ_TX_PREF_SPACER_WIDTH 8
-#define        FRF_AZ_TX_PREF_WD_TMR_LBN 22
-#define        FRF_AZ_TX_PREF_WD_TMR_WIDTH 22
-#define        FRF_AZ_TX_ONLY1TAG_LBN 21
-#define        FRF_AZ_TX_ONLY1TAG_WIDTH 1
-#define        FRF_AZ_TX_PREF_THRESHOLD_LBN 19
-#define        FRF_AZ_TX_PREF_THRESHOLD_WIDTH 2
-#define        FRF_AZ_TX_ONE_PKT_PER_Q_LBN 18
-#define        FRF_AZ_TX_ONE_PKT_PER_Q_WIDTH 1
-#define        FRF_AZ_TX_DIS_NON_IP_EV_LBN 17
-#define        FRF_AZ_TX_DIS_NON_IP_EV_WIDTH 1
-#define        FRF_AA_TX_DMA_FF_THR_LBN 16
-#define        FRF_AA_TX_DMA_FF_THR_WIDTH 1
-#define        FRF_AZ_TX_DMA_SPACER_LBN 8
-#define        FRF_AZ_TX_DMA_SPACER_WIDTH 8
-#define        FRF_AA_TX_TCP_DIS_LBN 7
-#define        FRF_AA_TX_TCP_DIS_WIDTH 1
-#define        FRF_BZ_TX_FLUSH_MIN_LEN_EN_LBN 7
-#define        FRF_BZ_TX_FLUSH_MIN_LEN_EN_WIDTH 1
-#define        FRF_AA_TX_IP_DIS_LBN 6
-#define        FRF_AA_TX_IP_DIS_WIDTH 1
-#define        FRF_AZ_TX_MAX_CPL_LBN 2
-#define        FRF_AZ_TX_MAX_CPL_WIDTH 2
-#define        FFE_AZ_TX_MAX_CPL_16 3
-#define        FFE_AZ_TX_MAX_CPL_8 2
-#define        FFE_AZ_TX_MAX_CPL_4 1
-#define        FFE_AZ_TX_MAX_CPL_NOLIMIT 0
-#define        FRF_AZ_TX_MAX_PREF_LBN 0
-#define        FRF_AZ_TX_MAX_PREF_WIDTH 2
-#define        FFE_AZ_TX_MAX_PREF_32 3
-#define        FFE_AZ_TX_MAX_PREF_16 2
-#define        FFE_AZ_TX_MAX_PREF_8 1
-#define        FFE_AZ_TX_MAX_PREF_OFF 0
-
-/* TX_PACE_REG: Transmit pace control register */
-#define        FR_BZ_TX_PACE 0x00000a90
-#define        FRF_BZ_TX_PACE_SB_NOT_AF_LBN 19
-#define        FRF_BZ_TX_PACE_SB_NOT_AF_WIDTH 10
-#define        FRF_BZ_TX_PACE_SB_AF_LBN 9
-#define        FRF_BZ_TX_PACE_SB_AF_WIDTH 10
-#define        FRF_BZ_TX_PACE_FB_BASE_LBN 5
-#define        FRF_BZ_TX_PACE_FB_BASE_WIDTH 4
-#define        FRF_BZ_TX_PACE_BIN_TH_LBN 0
-#define        FRF_BZ_TX_PACE_BIN_TH_WIDTH 5
-
-/* TX_PACE_DROP_QID_REG: PACE Drop QID Counter */
-#define        FR_BZ_TX_PACE_DROP_QID 0x00000aa0
-#define        FRF_BZ_TX_PACE_QID_DRP_CNT_LBN 0
-#define        FRF_BZ_TX_PACE_QID_DRP_CNT_WIDTH 16
-
-/* TX_VLAN_REG: Transmit VLAN tag register */
-#define        FR_BB_TX_VLAN 0x00000ae0
-#define        FRF_BB_TX_VLAN_EN_LBN 127
-#define        FRF_BB_TX_VLAN_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN7_PORT1_EN_LBN 125
-#define        FRF_BB_TX_VLAN7_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN7_PORT0_EN_LBN 124
-#define        FRF_BB_TX_VLAN7_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN7_LBN 112
-#define        FRF_BB_TX_VLAN7_WIDTH 12
-#define        FRF_BB_TX_VLAN6_PORT1_EN_LBN 109
-#define        FRF_BB_TX_VLAN6_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN6_PORT0_EN_LBN 108
-#define        FRF_BB_TX_VLAN6_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN6_LBN 96
-#define        FRF_BB_TX_VLAN6_WIDTH 12
-#define        FRF_BB_TX_VLAN5_PORT1_EN_LBN 93
-#define        FRF_BB_TX_VLAN5_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN5_PORT0_EN_LBN 92
-#define        FRF_BB_TX_VLAN5_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN5_LBN 80
-#define        FRF_BB_TX_VLAN5_WIDTH 12
-#define        FRF_BB_TX_VLAN4_PORT1_EN_LBN 77
-#define        FRF_BB_TX_VLAN4_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN4_PORT0_EN_LBN 76
-#define        FRF_BB_TX_VLAN4_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN4_LBN 64
-#define        FRF_BB_TX_VLAN4_WIDTH 12
-#define        FRF_BB_TX_VLAN3_PORT1_EN_LBN 61
-#define        FRF_BB_TX_VLAN3_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN3_PORT0_EN_LBN 60
-#define        FRF_BB_TX_VLAN3_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN3_LBN 48
-#define        FRF_BB_TX_VLAN3_WIDTH 12
-#define        FRF_BB_TX_VLAN2_PORT1_EN_LBN 45
-#define        FRF_BB_TX_VLAN2_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN2_PORT0_EN_LBN 44
-#define        FRF_BB_TX_VLAN2_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN2_LBN 32
-#define        FRF_BB_TX_VLAN2_WIDTH 12
-#define        FRF_BB_TX_VLAN1_PORT1_EN_LBN 29
-#define        FRF_BB_TX_VLAN1_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN1_PORT0_EN_LBN 28
-#define        FRF_BB_TX_VLAN1_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN1_LBN 16
-#define        FRF_BB_TX_VLAN1_WIDTH 12
-#define        FRF_BB_TX_VLAN0_PORT1_EN_LBN 13
-#define        FRF_BB_TX_VLAN0_PORT1_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN0_PORT0_EN_LBN 12
-#define        FRF_BB_TX_VLAN0_PORT0_EN_WIDTH 1
-#define        FRF_BB_TX_VLAN0_LBN 0
-#define        FRF_BB_TX_VLAN0_WIDTH 12
-
-/* TX_IPFIL_PORTEN_REG: Transmit filter control register */
-#define        FR_BZ_TX_IPFIL_PORTEN 0x00000af0
-#define        FRF_BZ_TX_MADR0_FIL_EN_LBN 64
-#define        FRF_BZ_TX_MADR0_FIL_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL31_PORT_EN_LBN 62
-#define        FRF_BB_TX_IPFIL31_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL30_PORT_EN_LBN 60
-#define        FRF_BB_TX_IPFIL30_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL29_PORT_EN_LBN 58
-#define        FRF_BB_TX_IPFIL29_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL28_PORT_EN_LBN 56
-#define        FRF_BB_TX_IPFIL28_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL27_PORT_EN_LBN 54
-#define        FRF_BB_TX_IPFIL27_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL26_PORT_EN_LBN 52
-#define        FRF_BB_TX_IPFIL26_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL25_PORT_EN_LBN 50
-#define        FRF_BB_TX_IPFIL25_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL24_PORT_EN_LBN 48
-#define        FRF_BB_TX_IPFIL24_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL23_PORT_EN_LBN 46
-#define        FRF_BB_TX_IPFIL23_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL22_PORT_EN_LBN 44
-#define        FRF_BB_TX_IPFIL22_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL21_PORT_EN_LBN 42
-#define        FRF_BB_TX_IPFIL21_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL20_PORT_EN_LBN 40
-#define        FRF_BB_TX_IPFIL20_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL19_PORT_EN_LBN 38
-#define        FRF_BB_TX_IPFIL19_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL18_PORT_EN_LBN 36
-#define        FRF_BB_TX_IPFIL18_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL17_PORT_EN_LBN 34
-#define        FRF_BB_TX_IPFIL17_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL16_PORT_EN_LBN 32
-#define        FRF_BB_TX_IPFIL16_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL15_PORT_EN_LBN 30
-#define        FRF_BB_TX_IPFIL15_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL14_PORT_EN_LBN 28
-#define        FRF_BB_TX_IPFIL14_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL13_PORT_EN_LBN 26
-#define        FRF_BB_TX_IPFIL13_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL12_PORT_EN_LBN 24
-#define        FRF_BB_TX_IPFIL12_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL11_PORT_EN_LBN 22
-#define        FRF_BB_TX_IPFIL11_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL10_PORT_EN_LBN 20
-#define        FRF_BB_TX_IPFIL10_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL9_PORT_EN_LBN 18
-#define        FRF_BB_TX_IPFIL9_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL8_PORT_EN_LBN 16
-#define        FRF_BB_TX_IPFIL8_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL7_PORT_EN_LBN 14
-#define        FRF_BB_TX_IPFIL7_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL6_PORT_EN_LBN 12
-#define        FRF_BB_TX_IPFIL6_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL5_PORT_EN_LBN 10
-#define        FRF_BB_TX_IPFIL5_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL4_PORT_EN_LBN 8
-#define        FRF_BB_TX_IPFIL4_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL3_PORT_EN_LBN 6
-#define        FRF_BB_TX_IPFIL3_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL2_PORT_EN_LBN 4
-#define        FRF_BB_TX_IPFIL2_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL1_PORT_EN_LBN 2
-#define        FRF_BB_TX_IPFIL1_PORT_EN_WIDTH 1
-#define        FRF_BB_TX_IPFIL0_PORT_EN_LBN 0
-#define        FRF_BB_TX_IPFIL0_PORT_EN_WIDTH 1
-
-/* TX_IPFIL_TBL: Transmit IP source address filter table */
-#define        FR_BB_TX_IPFIL_TBL 0x00000b00
-#define        FR_BB_TX_IPFIL_TBL_STEP 16
-#define        FR_BB_TX_IPFIL_TBL_ROWS 16
-#define        FRF_BB_TX_IPFIL_MASK_1_LBN 96
-#define        FRF_BB_TX_IPFIL_MASK_1_WIDTH 32
-#define        FRF_BB_TX_IP_SRC_ADR_1_LBN 64
-#define        FRF_BB_TX_IP_SRC_ADR_1_WIDTH 32
-#define        FRF_BB_TX_IPFIL_MASK_0_LBN 32
-#define        FRF_BB_TX_IPFIL_MASK_0_WIDTH 32
-#define        FRF_BB_TX_IP_SRC_ADR_0_LBN 0
-#define        FRF_BB_TX_IP_SRC_ADR_0_WIDTH 32
-
-/* MD_TXD_REG: PHY management transmit data register */
-#define        FR_AB_MD_TXD 0x00000c00
-#define        FRF_AB_MD_TXD_LBN 0
-#define        FRF_AB_MD_TXD_WIDTH 16
-
-/* MD_RXD_REG: PHY management receive data register */
-#define        FR_AB_MD_RXD 0x00000c10
-#define        FRF_AB_MD_RXD_LBN 0
-#define        FRF_AB_MD_RXD_WIDTH 16
-
-/* MD_CS_REG: PHY management configuration & status register */
-#define        FR_AB_MD_CS 0x00000c20
-#define        FRF_AB_MD_RD_EN_CMD_LBN 15
-#define        FRF_AB_MD_RD_EN_CMD_WIDTH 1
-#define        FRF_AB_MD_WR_EN_CMD_LBN 14
-#define        FRF_AB_MD_WR_EN_CMD_WIDTH 1
-#define        FRF_AB_MD_ADDR_CMD_LBN 13
-#define        FRF_AB_MD_ADDR_CMD_WIDTH 1
-#define        FRF_AB_MD_PT_LBN 7
-#define        FRF_AB_MD_PT_WIDTH 3
-#define        FRF_AB_MD_PL_LBN 6
-#define        FRF_AB_MD_PL_WIDTH 1
-#define        FRF_AB_MD_INT_CLR_LBN 5
-#define        FRF_AB_MD_INT_CLR_WIDTH 1
-#define        FRF_AB_MD_GC_LBN 4
-#define        FRF_AB_MD_GC_WIDTH 1
-#define        FRF_AB_MD_PRSP_LBN 3
-#define        FRF_AB_MD_PRSP_WIDTH 1
-#define        FRF_AB_MD_RIC_LBN 2
-#define        FRF_AB_MD_RIC_WIDTH 1
-#define        FRF_AB_MD_RDC_LBN 1
-#define        FRF_AB_MD_RDC_WIDTH 1
-#define        FRF_AB_MD_WRC_LBN 0
-#define        FRF_AB_MD_WRC_WIDTH 1
-
-/* MD_PHY_ADR_REG: PHY management PHY address register */
-#define        FR_AB_MD_PHY_ADR 0x00000c30
-#define        FRF_AB_MD_PHY_ADR_LBN 0
-#define        FRF_AB_MD_PHY_ADR_WIDTH 16
-
-/* MD_ID_REG: PHY management ID register */
-#define        FR_AB_MD_ID 0x00000c40
-#define        FRF_AB_MD_PRT_ADR_LBN 11
-#define        FRF_AB_MD_PRT_ADR_WIDTH 5
-#define        FRF_AB_MD_DEV_ADR_LBN 6
-#define        FRF_AB_MD_DEV_ADR_WIDTH 5
-
-/* MD_STAT_REG: PHY management status & mask register */
-#define        FR_AB_MD_STAT 0x00000c50
-#define        FRF_AB_MD_PINT_LBN 4
-#define        FRF_AB_MD_PINT_WIDTH 1
-#define        FRF_AB_MD_DONE_LBN 3
-#define        FRF_AB_MD_DONE_WIDTH 1
-#define        FRF_AB_MD_BSERR_LBN 2
-#define        FRF_AB_MD_BSERR_WIDTH 1
-#define        FRF_AB_MD_LNFL_LBN 1
-#define        FRF_AB_MD_LNFL_WIDTH 1
-#define        FRF_AB_MD_BSY_LBN 0
-#define        FRF_AB_MD_BSY_WIDTH 1
-
-/* MAC_STAT_DMA_REG: Port MAC statistical counter DMA register */
-#define        FR_AB_MAC_STAT_DMA 0x00000c60
-#define        FRF_AB_MAC_STAT_DMA_CMD_LBN 48
-#define        FRF_AB_MAC_STAT_DMA_CMD_WIDTH 1
-#define        FRF_AB_MAC_STAT_DMA_ADR_LBN 0
-#define        FRF_AB_MAC_STAT_DMA_ADR_WIDTH 48
-
-/* MAC_CTRL_REG: Port MAC control register */
-#define        FR_AB_MAC_CTRL 0x00000c80
-#define        FRF_AB_MAC_XOFF_VAL_LBN 16
-#define        FRF_AB_MAC_XOFF_VAL_WIDTH 16
-#define        FRF_BB_TXFIFO_DRAIN_EN_LBN 7
-#define        FRF_BB_TXFIFO_DRAIN_EN_WIDTH 1
-#define        FRF_AB_MAC_XG_DISTXCRC_LBN 5
-#define        FRF_AB_MAC_XG_DISTXCRC_WIDTH 1
-#define        FRF_AB_MAC_BCAD_ACPT_LBN 4
-#define        FRF_AB_MAC_BCAD_ACPT_WIDTH 1
-#define        FRF_AB_MAC_UC_PROM_LBN 3
-#define        FRF_AB_MAC_UC_PROM_WIDTH 1
-#define        FRF_AB_MAC_LINK_STATUS_LBN 2
-#define        FRF_AB_MAC_LINK_STATUS_WIDTH 1
-#define        FRF_AB_MAC_SPEED_LBN 0
-#define        FRF_AB_MAC_SPEED_WIDTH 2
-#define        FFE_AB_MAC_SPEED_10G 3
-#define        FFE_AB_MAC_SPEED_1G 2
-#define        FFE_AB_MAC_SPEED_100M 1
-#define        FFE_AB_MAC_SPEED_10M 0
-
-/* GEN_MODE_REG: General Purpose mode register (external interrupt mask) */
-#define        FR_BB_GEN_MODE 0x00000c90
-#define        FRF_BB_XFP_PHY_INT_POL_SEL_LBN 3
-#define        FRF_BB_XFP_PHY_INT_POL_SEL_WIDTH 1
-#define        FRF_BB_XG_PHY_INT_POL_SEL_LBN 2
-#define        FRF_BB_XG_PHY_INT_POL_SEL_WIDTH 1
-#define        FRF_BB_XFP_PHY_INT_MASK_LBN 1
-#define        FRF_BB_XFP_PHY_INT_MASK_WIDTH 1
-#define        FRF_BB_XG_PHY_INT_MASK_LBN 0
-#define        FRF_BB_XG_PHY_INT_MASK_WIDTH 1
-
-/* MAC_MC_HASH_REG0: Multicast address hash table */
-#define        FR_AB_MAC_MC_HASH_REG0 0x00000ca0
-#define        FRF_AB_MAC_MCAST_HASH0_LBN 0
-#define        FRF_AB_MAC_MCAST_HASH0_WIDTH 128
-
-/* MAC_MC_HASH_REG1: Multicast address hash table */
-#define        FR_AB_MAC_MC_HASH_REG1 0x00000cb0
-#define        FRF_AB_MAC_MCAST_HASH1_LBN 0
-#define        FRF_AB_MAC_MCAST_HASH1_WIDTH 128
-
-/* GM_CFG1_REG: GMAC configuration register 1 */
-#define        FR_AB_GM_CFG1 0x00000e00
-#define        FRF_AB_GM_SW_RST_LBN 31
-#define        FRF_AB_GM_SW_RST_WIDTH 1
-#define        FRF_AB_GM_SIM_RST_LBN 30
-#define        FRF_AB_GM_SIM_RST_WIDTH 1
-#define        FRF_AB_GM_RST_RX_MAC_CTL_LBN 19
-#define        FRF_AB_GM_RST_RX_MAC_CTL_WIDTH 1
-#define        FRF_AB_GM_RST_TX_MAC_CTL_LBN 18
-#define        FRF_AB_GM_RST_TX_MAC_CTL_WIDTH 1
-#define        FRF_AB_GM_RST_RX_FUNC_LBN 17
-#define        FRF_AB_GM_RST_RX_FUNC_WIDTH 1
-#define        FRF_AB_GM_RST_TX_FUNC_LBN 16
-#define        FRF_AB_GM_RST_TX_FUNC_WIDTH 1
-#define        FRF_AB_GM_LOOP_LBN 8
-#define        FRF_AB_GM_LOOP_WIDTH 1
-#define        FRF_AB_GM_RX_FC_EN_LBN 5
-#define        FRF_AB_GM_RX_FC_EN_WIDTH 1
-#define        FRF_AB_GM_TX_FC_EN_LBN 4
-#define        FRF_AB_GM_TX_FC_EN_WIDTH 1
-#define        FRF_AB_GM_SYNC_RXEN_LBN 3
-#define        FRF_AB_GM_SYNC_RXEN_WIDTH 1
-#define        FRF_AB_GM_RX_EN_LBN 2
-#define        FRF_AB_GM_RX_EN_WIDTH 1
-#define        FRF_AB_GM_SYNC_TXEN_LBN 1
-#define        FRF_AB_GM_SYNC_TXEN_WIDTH 1
-#define        FRF_AB_GM_TX_EN_LBN 0
-#define        FRF_AB_GM_TX_EN_WIDTH 1
-
-/* GM_CFG2_REG: GMAC configuration register 2 */
-#define        FR_AB_GM_CFG2 0x00000e10
-#define        FRF_AB_GM_PAMBL_LEN_LBN 12
-#define        FRF_AB_GM_PAMBL_LEN_WIDTH 4
-#define        FRF_AB_GM_IF_MODE_LBN 8
-#define        FRF_AB_GM_IF_MODE_WIDTH 2
-#define        FFE_AB_IF_MODE_BYTE_MODE 2
-#define        FFE_AB_IF_MODE_NIBBLE_MODE 1
-#define        FRF_AB_GM_HUGE_FRM_EN_LBN 5
-#define        FRF_AB_GM_HUGE_FRM_EN_WIDTH 1
-#define        FRF_AB_GM_LEN_CHK_LBN 4
-#define        FRF_AB_GM_LEN_CHK_WIDTH 1
-#define        FRF_AB_GM_PAD_CRC_EN_LBN 2
-#define        FRF_AB_GM_PAD_CRC_EN_WIDTH 1
-#define        FRF_AB_GM_CRC_EN_LBN 1
-#define        FRF_AB_GM_CRC_EN_WIDTH 1
-#define        FRF_AB_GM_FD_LBN 0
-#define        FRF_AB_GM_FD_WIDTH 1
-
-/* GM_IPG_REG: GMAC IPG register */
-#define        FR_AB_GM_IPG 0x00000e20
-#define        FRF_AB_GM_NONB2B_IPG1_LBN 24
-#define        FRF_AB_GM_NONB2B_IPG1_WIDTH 7
-#define        FRF_AB_GM_NONB2B_IPG2_LBN 16
-#define        FRF_AB_GM_NONB2B_IPG2_WIDTH 7
-#define        FRF_AB_GM_MIN_IPG_ENF_LBN 8
-#define        FRF_AB_GM_MIN_IPG_ENF_WIDTH 8
-#define        FRF_AB_GM_B2B_IPG_LBN 0
-#define        FRF_AB_GM_B2B_IPG_WIDTH 7
-
-/* GM_HD_REG: GMAC half duplex register */
-#define        FR_AB_GM_HD 0x00000e30
-#define        FRF_AB_GM_ALT_BOFF_VAL_LBN 20
-#define        FRF_AB_GM_ALT_BOFF_VAL_WIDTH 4
-#define        FRF_AB_GM_ALT_BOFF_EN_LBN 19
-#define        FRF_AB_GM_ALT_BOFF_EN_WIDTH 1
-#define        FRF_AB_GM_BP_NO_BOFF_LBN 18
-#define        FRF_AB_GM_BP_NO_BOFF_WIDTH 1
-#define        FRF_AB_GM_DIS_BOFF_LBN 17
-#define        FRF_AB_GM_DIS_BOFF_WIDTH 1
-#define        FRF_AB_GM_EXDEF_TX_EN_LBN 16
-#define        FRF_AB_GM_EXDEF_TX_EN_WIDTH 1
-#define        FRF_AB_GM_RTRY_LIMIT_LBN 12
-#define        FRF_AB_GM_RTRY_LIMIT_WIDTH 4
-#define        FRF_AB_GM_COL_WIN_LBN 0
-#define        FRF_AB_GM_COL_WIN_WIDTH 10
-
-/* GM_MAX_FLEN_REG: GMAC maximum frame length register */
-#define        FR_AB_GM_MAX_FLEN 0x00000e40
-#define        FRF_AB_GM_MAX_FLEN_LBN 0
-#define        FRF_AB_GM_MAX_FLEN_WIDTH 16
-
-/* GM_TEST_REG: GMAC test register */
-#define        FR_AB_GM_TEST 0x00000e70
-#define        FRF_AB_GM_MAX_BOFF_LBN 3
-#define        FRF_AB_GM_MAX_BOFF_WIDTH 1
-#define        FRF_AB_GM_REG_TX_FLOW_EN_LBN 2
-#define        FRF_AB_GM_REG_TX_FLOW_EN_WIDTH 1
-#define        FRF_AB_GM_TEST_PAUSE_LBN 1
-#define        FRF_AB_GM_TEST_PAUSE_WIDTH 1
-#define        FRF_AB_GM_SHORT_SLOT_LBN 0
-#define        FRF_AB_GM_SHORT_SLOT_WIDTH 1
-
-/* GM_ADR1_REG: GMAC station address register 1 */
-#define        FR_AB_GM_ADR1 0x00000f00
-#define        FRF_AB_GM_ADR_B0_LBN 24
-#define        FRF_AB_GM_ADR_B0_WIDTH 8
-#define        FRF_AB_GM_ADR_B1_LBN 16
-#define        FRF_AB_GM_ADR_B1_WIDTH 8
-#define        FRF_AB_GM_ADR_B2_LBN 8
-#define        FRF_AB_GM_ADR_B2_WIDTH 8
-#define        FRF_AB_GM_ADR_B3_LBN 0
-#define        FRF_AB_GM_ADR_B3_WIDTH 8
-
-/* GM_ADR2_REG: GMAC station address register 2 */
-#define        FR_AB_GM_ADR2 0x00000f10
-#define        FRF_AB_GM_ADR_B4_LBN 24
-#define        FRF_AB_GM_ADR_B4_WIDTH 8
-#define        FRF_AB_GM_ADR_B5_LBN 16
-#define        FRF_AB_GM_ADR_B5_WIDTH 8
-
-/* GMF_CFG0_REG: GMAC FIFO configuration register 0 */
-#define        FR_AB_GMF_CFG0 0x00000f20
-#define        FRF_AB_GMF_FTFENRPLY_LBN 20
-#define        FRF_AB_GMF_FTFENRPLY_WIDTH 1
-#define        FRF_AB_GMF_STFENRPLY_LBN 19
-#define        FRF_AB_GMF_STFENRPLY_WIDTH 1
-#define        FRF_AB_GMF_FRFENRPLY_LBN 18
-#define        FRF_AB_GMF_FRFENRPLY_WIDTH 1
-#define        FRF_AB_GMF_SRFENRPLY_LBN 17
-#define        FRF_AB_GMF_SRFENRPLY_WIDTH 1
-#define        FRF_AB_GMF_WTMENRPLY_LBN 16
-#define        FRF_AB_GMF_WTMENRPLY_WIDTH 1
-#define        FRF_AB_GMF_FTFENREQ_LBN 12
-#define        FRF_AB_GMF_FTFENREQ_WIDTH 1
-#define        FRF_AB_GMF_STFENREQ_LBN 11
-#define        FRF_AB_GMF_STFENREQ_WIDTH 1
-#define        FRF_AB_GMF_FRFENREQ_LBN 10
-#define        FRF_AB_GMF_FRFENREQ_WIDTH 1
-#define        FRF_AB_GMF_SRFENREQ_LBN 9
-#define        FRF_AB_GMF_SRFENREQ_WIDTH 1
-#define        FRF_AB_GMF_WTMENREQ_LBN 8
-#define        FRF_AB_GMF_WTMENREQ_WIDTH 1
-#define        FRF_AB_GMF_HSTRSTFT_LBN 4
-#define        FRF_AB_GMF_HSTRSTFT_WIDTH 1
-#define        FRF_AB_GMF_HSTRSTST_LBN 3
-#define        FRF_AB_GMF_HSTRSTST_WIDTH 1
-#define        FRF_AB_GMF_HSTRSTFR_LBN 2
-#define        FRF_AB_GMF_HSTRSTFR_WIDTH 1
-#define        FRF_AB_GMF_HSTRSTSR_LBN 1
-#define        FRF_AB_GMF_HSTRSTSR_WIDTH 1
-#define        FRF_AB_GMF_HSTRSTWT_LBN 0
-#define        FRF_AB_GMF_HSTRSTWT_WIDTH 1
-
-/* GMF_CFG1_REG: GMAC FIFO configuration register 1 */
-#define        FR_AB_GMF_CFG1 0x00000f30
-#define        FRF_AB_GMF_CFGFRTH_LBN 16
-#define        FRF_AB_GMF_CFGFRTH_WIDTH 5
-#define        FRF_AB_GMF_CFGXOFFRTX_LBN 0
-#define        FRF_AB_GMF_CFGXOFFRTX_WIDTH 16
-
-/* GMF_CFG2_REG: GMAC FIFO configuration register 2 */
-#define        FR_AB_GMF_CFG2 0x00000f40
-#define        FRF_AB_GMF_CFGHWM_LBN 16
-#define        FRF_AB_GMF_CFGHWM_WIDTH 6
-#define        FRF_AB_GMF_CFGLWM_LBN 0
-#define        FRF_AB_GMF_CFGLWM_WIDTH 6
-
-/* GMF_CFG3_REG: GMAC FIFO configuration register 3 */
-#define        FR_AB_GMF_CFG3 0x00000f50
-#define        FRF_AB_GMF_CFGHWMFT_LBN 16
-#define        FRF_AB_GMF_CFGHWMFT_WIDTH 6
-#define        FRF_AB_GMF_CFGFTTH_LBN 0
-#define        FRF_AB_GMF_CFGFTTH_WIDTH 6
-
-/* GMF_CFG4_REG: GMAC FIFO configuration register 4 */
-#define        FR_AB_GMF_CFG4 0x00000f60
-#define        FRF_AB_GMF_HSTFLTRFRM_LBN 0
-#define        FRF_AB_GMF_HSTFLTRFRM_WIDTH 18
-
-/* GMF_CFG5_REG: GMAC FIFO configuration register 5 */
-#define        FR_AB_GMF_CFG5 0x00000f70
-#define        FRF_AB_GMF_CFGHDPLX_LBN 22
-#define        FRF_AB_GMF_CFGHDPLX_WIDTH 1
-#define        FRF_AB_GMF_SRFULL_LBN 21
-#define        FRF_AB_GMF_SRFULL_WIDTH 1
-#define        FRF_AB_GMF_HSTSRFULLCLR_LBN 20
-#define        FRF_AB_GMF_HSTSRFULLCLR_WIDTH 1
-#define        FRF_AB_GMF_CFGBYTMODE_LBN 19
-#define        FRF_AB_GMF_CFGBYTMODE_WIDTH 1
-#define        FRF_AB_GMF_HSTDRPLT64_LBN 18
-#define        FRF_AB_GMF_HSTDRPLT64_WIDTH 1
-#define        FRF_AB_GMF_HSTFLTRFRMDC_LBN 0
-#define        FRF_AB_GMF_HSTFLTRFRMDC_WIDTH 18
-
-/* TX_SRC_MAC_TBL: Transmit IP source address filter table */
-#define        FR_BB_TX_SRC_MAC_TBL 0x00001000
-#define        FR_BB_TX_SRC_MAC_TBL_STEP 16
-#define        FR_BB_TX_SRC_MAC_TBL_ROWS 16
-#define        FRF_BB_TX_SRC_MAC_ADR_1_LBN 64
-#define        FRF_BB_TX_SRC_MAC_ADR_1_WIDTH 48
-#define        FRF_BB_TX_SRC_MAC_ADR_0_LBN 0
-#define        FRF_BB_TX_SRC_MAC_ADR_0_WIDTH 48
-
-/* TX_SRC_MAC_CTL_REG: Transmit MAC source address filter control */
-#define        FR_BB_TX_SRC_MAC_CTL 0x00001100
-#define        FRF_BB_TX_SRC_DROP_CTR_LBN 16
-#define        FRF_BB_TX_SRC_DROP_CTR_WIDTH 16
-#define        FRF_BB_TX_SRC_FLTR_EN_LBN 15
-#define        FRF_BB_TX_SRC_FLTR_EN_WIDTH 1
-#define        FRF_BB_TX_DROP_CTR_CLR_LBN 12
-#define        FRF_BB_TX_DROP_CTR_CLR_WIDTH 1
-#define        FRF_BB_TX_MAC_QID_SEL_LBN 0
-#define        FRF_BB_TX_MAC_QID_SEL_WIDTH 3
-
-/* XM_ADR_LO_REG: XGMAC address register low */
-#define        FR_AB_XM_ADR_LO 0x00001200
-#define        FRF_AB_XM_ADR_LO_LBN 0
-#define        FRF_AB_XM_ADR_LO_WIDTH 32
-
-/* XM_ADR_HI_REG: XGMAC address register high */
-#define        FR_AB_XM_ADR_HI 0x00001210
-#define        FRF_AB_XM_ADR_HI_LBN 0
-#define        FRF_AB_XM_ADR_HI_WIDTH 16
-
-/* XM_GLB_CFG_REG: XGMAC global configuration */
-#define        FR_AB_XM_GLB_CFG 0x00001220
-#define        FRF_AB_XM_RMTFLT_GEN_LBN 17
-#define        FRF_AB_XM_RMTFLT_GEN_WIDTH 1
-#define        FRF_AB_XM_DEBUG_MODE_LBN 16
-#define        FRF_AB_XM_DEBUG_MODE_WIDTH 1
-#define        FRF_AB_XM_RX_STAT_EN_LBN 11
-#define        FRF_AB_XM_RX_STAT_EN_WIDTH 1
-#define        FRF_AB_XM_TX_STAT_EN_LBN 10
-#define        FRF_AB_XM_TX_STAT_EN_WIDTH 1
-#define        FRF_AB_XM_RX_JUMBO_MODE_LBN 6
-#define        FRF_AB_XM_RX_JUMBO_MODE_WIDTH 1
-#define        FRF_AB_XM_WAN_MODE_LBN 5
-#define        FRF_AB_XM_WAN_MODE_WIDTH 1
-#define        FRF_AB_XM_INTCLR_MODE_LBN 3
-#define        FRF_AB_XM_INTCLR_MODE_WIDTH 1
-#define        FRF_AB_XM_CORE_RST_LBN 0
-#define        FRF_AB_XM_CORE_RST_WIDTH 1
-
-/* XM_TX_CFG_REG: XGMAC transmit configuration */
-#define        FR_AB_XM_TX_CFG 0x00001230
-#define        FRF_AB_XM_TX_PROG_LBN 24
-#define        FRF_AB_XM_TX_PROG_WIDTH 1
-#define        FRF_AB_XM_IPG_LBN 16
-#define        FRF_AB_XM_IPG_WIDTH 4
-#define        FRF_AB_XM_FCNTL_LBN 10
-#define        FRF_AB_XM_FCNTL_WIDTH 1
-#define        FRF_AB_XM_TXCRC_LBN 8
-#define        FRF_AB_XM_TXCRC_WIDTH 1
-#define        FRF_AB_XM_EDRC_LBN 6
-#define        FRF_AB_XM_EDRC_WIDTH 1
-#define        FRF_AB_XM_AUTO_PAD_LBN 5
-#define        FRF_AB_XM_AUTO_PAD_WIDTH 1
-#define        FRF_AB_XM_TX_PRMBL_LBN 2
-#define        FRF_AB_XM_TX_PRMBL_WIDTH 1
-#define        FRF_AB_XM_TXEN_LBN 1
-#define        FRF_AB_XM_TXEN_WIDTH 1
-#define        FRF_AB_XM_TX_RST_LBN 0
-#define        FRF_AB_XM_TX_RST_WIDTH 1
-
-/* XM_RX_CFG_REG: XGMAC receive configuration */
-#define        FR_AB_XM_RX_CFG 0x00001240
-#define        FRF_AB_XM_PASS_LENERR_LBN 26
-#define        FRF_AB_XM_PASS_LENERR_WIDTH 1
-#define        FRF_AB_XM_PASS_CRC_ERR_LBN 25
-#define        FRF_AB_XM_PASS_CRC_ERR_WIDTH 1
-#define        FRF_AB_XM_PASS_PRMBLE_ERR_LBN 24
-#define        FRF_AB_XM_PASS_PRMBLE_ERR_WIDTH 1
-#define        FRF_AB_XM_REJ_BCAST_LBN 20
-#define        FRF_AB_XM_REJ_BCAST_WIDTH 1
-#define        FRF_AB_XM_ACPT_ALL_MCAST_LBN 11
-#define        FRF_AB_XM_ACPT_ALL_MCAST_WIDTH 1
-#define        FRF_AB_XM_ACPT_ALL_UCAST_LBN 9
-#define        FRF_AB_XM_ACPT_ALL_UCAST_WIDTH 1
-#define        FRF_AB_XM_AUTO_DEPAD_LBN 8
-#define        FRF_AB_XM_AUTO_DEPAD_WIDTH 1
-#define        FRF_AB_XM_RXCRC_LBN 3
-#define        FRF_AB_XM_RXCRC_WIDTH 1
-#define        FRF_AB_XM_RX_PRMBL_LBN 2
-#define        FRF_AB_XM_RX_PRMBL_WIDTH 1
-#define        FRF_AB_XM_RXEN_LBN 1
-#define        FRF_AB_XM_RXEN_WIDTH 1
-#define        FRF_AB_XM_RX_RST_LBN 0
-#define        FRF_AB_XM_RX_RST_WIDTH 1
-
-/* XM_MGT_INT_MASK: documentation to be written for sum_XM_MGT_INT_MASK */
-#define        FR_AB_XM_MGT_INT_MASK 0x00001250
-#define        FRF_AB_XM_MSK_STA_INTR_LBN 16
-#define        FRF_AB_XM_MSK_STA_INTR_WIDTH 1
-#define        FRF_AB_XM_MSK_STAT_CNTR_HF_LBN 9
-#define        FRF_AB_XM_MSK_STAT_CNTR_HF_WIDTH 1
-#define        FRF_AB_XM_MSK_STAT_CNTR_OF_LBN 8
-#define        FRF_AB_XM_MSK_STAT_CNTR_OF_WIDTH 1
-#define        FRF_AB_XM_MSK_PRMBLE_ERR_LBN 2
-#define        FRF_AB_XM_MSK_PRMBLE_ERR_WIDTH 1
-#define        FRF_AB_XM_MSK_RMTFLT_LBN 1
-#define        FRF_AB_XM_MSK_RMTFLT_WIDTH 1
-#define        FRF_AB_XM_MSK_LCLFLT_LBN 0
-#define        FRF_AB_XM_MSK_LCLFLT_WIDTH 1
-
-/* XM_FC_REG: XGMAC flow control register */
-#define        FR_AB_XM_FC 0x00001270
-#define        FRF_AB_XM_PAUSE_TIME_LBN 16
-#define        FRF_AB_XM_PAUSE_TIME_WIDTH 16
-#define        FRF_AB_XM_RX_MAC_STAT_LBN 11
-#define        FRF_AB_XM_RX_MAC_STAT_WIDTH 1
-#define        FRF_AB_XM_TX_MAC_STAT_LBN 10
-#define        FRF_AB_XM_TX_MAC_STAT_WIDTH 1
-#define        FRF_AB_XM_MCNTL_PASS_LBN 8
-#define        FRF_AB_XM_MCNTL_PASS_WIDTH 2
-#define        FRF_AB_XM_REJ_CNTL_UCAST_LBN 6
-#define        FRF_AB_XM_REJ_CNTL_UCAST_WIDTH 1
-#define        FRF_AB_XM_REJ_CNTL_MCAST_LBN 5
-#define        FRF_AB_XM_REJ_CNTL_MCAST_WIDTH 1
-#define        FRF_AB_XM_ZPAUSE_LBN 2
-#define        FRF_AB_XM_ZPAUSE_WIDTH 1
-#define        FRF_AB_XM_XMIT_PAUSE_LBN 1
-#define        FRF_AB_XM_XMIT_PAUSE_WIDTH 1
-#define        FRF_AB_XM_DIS_FCNTL_LBN 0
-#define        FRF_AB_XM_DIS_FCNTL_WIDTH 1
-
-/* XM_PAUSE_TIME_REG: XGMAC pause time register */
-#define        FR_AB_XM_PAUSE_TIME 0x00001290
-#define        FRF_AB_XM_TX_PAUSE_CNT_LBN 16
-#define        FRF_AB_XM_TX_PAUSE_CNT_WIDTH 16
-#define        FRF_AB_XM_RX_PAUSE_CNT_LBN 0
-#define        FRF_AB_XM_RX_PAUSE_CNT_WIDTH 16
-
-/* XM_TX_PARAM_REG: XGMAC transmit parameter register */
-#define        FR_AB_XM_TX_PARAM 0x000012d0
-#define        FRF_AB_XM_TX_JUMBO_MODE_LBN 31
-#define        FRF_AB_XM_TX_JUMBO_MODE_WIDTH 1
-#define        FRF_AB_XM_MAX_TX_FRM_SIZE_HI_LBN 19
-#define        FRF_AB_XM_MAX_TX_FRM_SIZE_HI_WIDTH 11
-#define        FRF_AB_XM_MAX_TX_FRM_SIZE_LO_LBN 16
-#define        FRF_AB_XM_MAX_TX_FRM_SIZE_LO_WIDTH 3
-#define        FRF_AB_XM_PAD_CHAR_LBN 0
-#define        FRF_AB_XM_PAD_CHAR_WIDTH 8
-
-/* XM_RX_PARAM_REG: XGMAC receive parameter register */
-#define        FR_AB_XM_RX_PARAM 0x000012e0
-#define        FRF_AB_XM_MAX_RX_FRM_SIZE_HI_LBN 3
-#define        FRF_AB_XM_MAX_RX_FRM_SIZE_HI_WIDTH 11
-#define        FRF_AB_XM_MAX_RX_FRM_SIZE_LO_LBN 0
-#define        FRF_AB_XM_MAX_RX_FRM_SIZE_LO_WIDTH 3
-
-/* XM_MGT_INT_MSK_REG: XGMAC management interrupt mask register */
-#define        FR_AB_XM_MGT_INT_MSK 0x000012f0
-#define        FRF_AB_XM_STAT_CNTR_OF_LBN 9
-#define        FRF_AB_XM_STAT_CNTR_OF_WIDTH 1
-#define        FRF_AB_XM_STAT_CNTR_HF_LBN 8
-#define        FRF_AB_XM_STAT_CNTR_HF_WIDTH 1
-#define        FRF_AB_XM_PRMBLE_ERR_LBN 2
-#define        FRF_AB_XM_PRMBLE_ERR_WIDTH 1
-#define        FRF_AB_XM_RMTFLT_LBN 1
-#define        FRF_AB_XM_RMTFLT_WIDTH 1
-#define        FRF_AB_XM_LCLFLT_LBN 0
-#define        FRF_AB_XM_LCLFLT_WIDTH 1
-
-/* XX_PWR_RST_REG: XGXS/XAUI powerdown/reset register */
-#define        FR_AB_XX_PWR_RST 0x00001300
-#define        FRF_AB_XX_PWRDND_SIG_LBN 31
-#define        FRF_AB_XX_PWRDND_SIG_WIDTH 1
-#define        FRF_AB_XX_PWRDNC_SIG_LBN 30
-#define        FRF_AB_XX_PWRDNC_SIG_WIDTH 1
-#define        FRF_AB_XX_PWRDNB_SIG_LBN 29
-#define        FRF_AB_XX_PWRDNB_SIG_WIDTH 1
-#define        FRF_AB_XX_PWRDNA_SIG_LBN 28
-#define        FRF_AB_XX_PWRDNA_SIG_WIDTH 1
-#define        FRF_AB_XX_SIM_MODE_LBN 27
-#define        FRF_AB_XX_SIM_MODE_WIDTH 1
-#define        FRF_AB_XX_RSTPLLCD_SIG_LBN 25
-#define        FRF_AB_XX_RSTPLLCD_SIG_WIDTH 1
-#define        FRF_AB_XX_RSTPLLAB_SIG_LBN 24
-#define        FRF_AB_XX_RSTPLLAB_SIG_WIDTH 1
-#define        FRF_AB_XX_RESETD_SIG_LBN 23
-#define        FRF_AB_XX_RESETD_SIG_WIDTH 1
-#define        FRF_AB_XX_RESETC_SIG_LBN 22
-#define        FRF_AB_XX_RESETC_SIG_WIDTH 1
-#define        FRF_AB_XX_RESETB_SIG_LBN 21
-#define        FRF_AB_XX_RESETB_SIG_WIDTH 1
-#define        FRF_AB_XX_RESETA_SIG_LBN 20
-#define        FRF_AB_XX_RESETA_SIG_WIDTH 1
-#define        FRF_AB_XX_RSTXGXSRX_SIG_LBN 18
-#define        FRF_AB_XX_RSTXGXSRX_SIG_WIDTH 1
-#define        FRF_AB_XX_RSTXGXSTX_SIG_LBN 17
-#define        FRF_AB_XX_RSTXGXSTX_SIG_WIDTH 1
-#define        FRF_AB_XX_SD_RST_ACT_LBN 16
-#define        FRF_AB_XX_SD_RST_ACT_WIDTH 1
-#define        FRF_AB_XX_PWRDND_EN_LBN 15
-#define        FRF_AB_XX_PWRDND_EN_WIDTH 1
-#define        FRF_AB_XX_PWRDNC_EN_LBN 14
-#define        FRF_AB_XX_PWRDNC_EN_WIDTH 1
-#define        FRF_AB_XX_PWRDNB_EN_LBN 13
-#define        FRF_AB_XX_PWRDNB_EN_WIDTH 1
-#define        FRF_AB_XX_PWRDNA_EN_LBN 12
-#define        FRF_AB_XX_PWRDNA_EN_WIDTH 1
-#define        FRF_AB_XX_RSTPLLCD_EN_LBN 9
-#define        FRF_AB_XX_RSTPLLCD_EN_WIDTH 1
-#define        FRF_AB_XX_RSTPLLAB_EN_LBN 8
-#define        FRF_AB_XX_RSTPLLAB_EN_WIDTH 1
-#define        FRF_AB_XX_RESETD_EN_LBN 7
-#define        FRF_AB_XX_RESETD_EN_WIDTH 1
-#define        FRF_AB_XX_RESETC_EN_LBN 6
-#define        FRF_AB_XX_RESETC_EN_WIDTH 1
-#define        FRF_AB_XX_RESETB_EN_LBN 5
-#define        FRF_AB_XX_RESETB_EN_WIDTH 1
-#define        FRF_AB_XX_RESETA_EN_LBN 4
-#define        FRF_AB_XX_RESETA_EN_WIDTH 1
-#define        FRF_AB_XX_RSTXGXSRX_EN_LBN 2
-#define        FRF_AB_XX_RSTXGXSRX_EN_WIDTH 1
-#define        FRF_AB_XX_RSTXGXSTX_EN_LBN 1
-#define        FRF_AB_XX_RSTXGXSTX_EN_WIDTH 1
-#define        FRF_AB_XX_RST_XX_EN_LBN 0
-#define        FRF_AB_XX_RST_XX_EN_WIDTH 1
-
-/* XX_SD_CTL_REG: XGXS/XAUI powerdown/reset control register */
-#define        FR_AB_XX_SD_CTL 0x00001310
-#define        FRF_AB_XX_TERMADJ1_LBN 17
-#define        FRF_AB_XX_TERMADJ1_WIDTH 1
-#define        FRF_AB_XX_TERMADJ0_LBN 16
-#define        FRF_AB_XX_TERMADJ0_WIDTH 1
-#define        FRF_AB_XX_HIDRVD_LBN 15
-#define        FRF_AB_XX_HIDRVD_WIDTH 1
-#define        FRF_AB_XX_LODRVD_LBN 14
-#define        FRF_AB_XX_LODRVD_WIDTH 1
-#define        FRF_AB_XX_HIDRVC_LBN 13
-#define        FRF_AB_XX_HIDRVC_WIDTH 1
-#define        FRF_AB_XX_LODRVC_LBN 12
-#define        FRF_AB_XX_LODRVC_WIDTH 1
-#define        FRF_AB_XX_HIDRVB_LBN 11
-#define        FRF_AB_XX_HIDRVB_WIDTH 1
-#define        FRF_AB_XX_LODRVB_LBN 10
-#define        FRF_AB_XX_LODRVB_WIDTH 1
-#define        FRF_AB_XX_HIDRVA_LBN 9
-#define        FRF_AB_XX_HIDRVA_WIDTH 1
-#define        FRF_AB_XX_LODRVA_LBN 8
-#define        FRF_AB_XX_LODRVA_WIDTH 1
-#define        FRF_AB_XX_LPBKD_LBN 3
-#define        FRF_AB_XX_LPBKD_WIDTH 1
-#define        FRF_AB_XX_LPBKC_LBN 2
-#define        FRF_AB_XX_LPBKC_WIDTH 1
-#define        FRF_AB_XX_LPBKB_LBN 1
-#define        FRF_AB_XX_LPBKB_WIDTH 1
-#define        FRF_AB_XX_LPBKA_LBN 0
-#define        FRF_AB_XX_LPBKA_WIDTH 1
-
-/* XX_TXDRV_CTL_REG: XAUI SerDes transmit drive control register */
-#define        FR_AB_XX_TXDRV_CTL 0x00001320
-#define        FRF_AB_XX_DEQD_LBN 28
-#define        FRF_AB_XX_DEQD_WIDTH 4
-#define        FRF_AB_XX_DEQC_LBN 24
-#define        FRF_AB_XX_DEQC_WIDTH 4
-#define        FRF_AB_XX_DEQB_LBN 20
-#define        FRF_AB_XX_DEQB_WIDTH 4
-#define        FRF_AB_XX_DEQA_LBN 16
-#define        FRF_AB_XX_DEQA_WIDTH 4
-#define        FRF_AB_XX_DTXD_LBN 12
-#define        FRF_AB_XX_DTXD_WIDTH 4
-#define        FRF_AB_XX_DTXC_LBN 8
-#define        FRF_AB_XX_DTXC_WIDTH 4
-#define        FRF_AB_XX_DTXB_LBN 4
-#define        FRF_AB_XX_DTXB_WIDTH 4
-#define        FRF_AB_XX_DTXA_LBN 0
-#define        FRF_AB_XX_DTXA_WIDTH 4
-
-/* XX_PRBS_CTL_REG: documentation to be written for sum_XX_PRBS_CTL_REG */
-#define        FR_AB_XX_PRBS_CTL 0x00001330
-#define        FRF_AB_XX_CH3_RX_PRBS_SEL_LBN 30
-#define        FRF_AB_XX_CH3_RX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH3_RX_PRBS_INV_LBN 29
-#define        FRF_AB_XX_CH3_RX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH3_RX_PRBS_CHKEN_LBN 28
-#define        FRF_AB_XX_CH3_RX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH2_RX_PRBS_SEL_LBN 26
-#define        FRF_AB_XX_CH2_RX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH2_RX_PRBS_INV_LBN 25
-#define        FRF_AB_XX_CH2_RX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH2_RX_PRBS_CHKEN_LBN 24
-#define        FRF_AB_XX_CH2_RX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH1_RX_PRBS_SEL_LBN 22
-#define        FRF_AB_XX_CH1_RX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH1_RX_PRBS_INV_LBN 21
-#define        FRF_AB_XX_CH1_RX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH1_RX_PRBS_CHKEN_LBN 20
-#define        FRF_AB_XX_CH1_RX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH0_RX_PRBS_SEL_LBN 18
-#define        FRF_AB_XX_CH0_RX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH0_RX_PRBS_INV_LBN 17
-#define        FRF_AB_XX_CH0_RX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH0_RX_PRBS_CHKEN_LBN 16
-#define        FRF_AB_XX_CH0_RX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH3_TX_PRBS_SEL_LBN 14
-#define        FRF_AB_XX_CH3_TX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH3_TX_PRBS_INV_LBN 13
-#define        FRF_AB_XX_CH3_TX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH3_TX_PRBS_CHKEN_LBN 12
-#define        FRF_AB_XX_CH3_TX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH2_TX_PRBS_SEL_LBN 10
-#define        FRF_AB_XX_CH2_TX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH2_TX_PRBS_INV_LBN 9
-#define        FRF_AB_XX_CH2_TX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH2_TX_PRBS_CHKEN_LBN 8
-#define        FRF_AB_XX_CH2_TX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH1_TX_PRBS_SEL_LBN 6
-#define        FRF_AB_XX_CH1_TX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH1_TX_PRBS_INV_LBN 5
-#define        FRF_AB_XX_CH1_TX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH1_TX_PRBS_CHKEN_LBN 4
-#define        FRF_AB_XX_CH1_TX_PRBS_CHKEN_WIDTH 1
-#define        FRF_AB_XX_CH0_TX_PRBS_SEL_LBN 2
-#define        FRF_AB_XX_CH0_TX_PRBS_SEL_WIDTH 2
-#define        FRF_AB_XX_CH0_TX_PRBS_INV_LBN 1
-#define        FRF_AB_XX_CH0_TX_PRBS_INV_WIDTH 1
-#define        FRF_AB_XX_CH0_TX_PRBS_CHKEN_LBN 0
-#define        FRF_AB_XX_CH0_TX_PRBS_CHKEN_WIDTH 1
-
-/* XX_PRBS_CHK_REG: documentation to be written for sum_XX_PRBS_CHK_REG */
-#define        FR_AB_XX_PRBS_CHK 0x00001340
-#define        FRF_AB_XX_REV_LB_EN_LBN 16
-#define        FRF_AB_XX_REV_LB_EN_WIDTH 1
-#define        FRF_AB_XX_CH3_DEG_DET_LBN 15
-#define        FRF_AB_XX_CH3_DEG_DET_WIDTH 1
-#define        FRF_AB_XX_CH3_LFSR_LOCK_IND_LBN 14
-#define        FRF_AB_XX_CH3_LFSR_LOCK_IND_WIDTH 1
-#define        FRF_AB_XX_CH3_PRBS_FRUN_LBN 13
-#define        FRF_AB_XX_CH3_PRBS_FRUN_WIDTH 1
-#define        FRF_AB_XX_CH3_ERR_CHK_LBN 12
-#define        FRF_AB_XX_CH3_ERR_CHK_WIDTH 1
-#define        FRF_AB_XX_CH2_DEG_DET_LBN 11
-#define        FRF_AB_XX_CH2_DEG_DET_WIDTH 1
-#define        FRF_AB_XX_CH2_LFSR_LOCK_IND_LBN 10
-#define        FRF_AB_XX_CH2_LFSR_LOCK_IND_WIDTH 1
-#define        FRF_AB_XX_CH2_PRBS_FRUN_LBN 9
-#define        FRF_AB_XX_CH2_PRBS_FRUN_WIDTH 1
-#define        FRF_AB_XX_CH2_ERR_CHK_LBN 8
-#define        FRF_AB_XX_CH2_ERR_CHK_WIDTH 1
-#define        FRF_AB_XX_CH1_DEG_DET_LBN 7
-#define        FRF_AB_XX_CH1_DEG_DET_WIDTH 1
-#define        FRF_AB_XX_CH1_LFSR_LOCK_IND_LBN 6
-#define        FRF_AB_XX_CH1_LFSR_LOCK_IND_WIDTH 1
-#define        FRF_AB_XX_CH1_PRBS_FRUN_LBN 5
-#define        FRF_AB_XX_CH1_PRBS_FRUN_WIDTH 1
-#define        FRF_AB_XX_CH1_ERR_CHK_LBN 4
-#define        FRF_AB_XX_CH1_ERR_CHK_WIDTH 1
-#define        FRF_AB_XX_CH0_DEG_DET_LBN 3
-#define        FRF_AB_XX_CH0_DEG_DET_WIDTH 1
-#define        FRF_AB_XX_CH0_LFSR_LOCK_IND_LBN 2
-#define        FRF_AB_XX_CH0_LFSR_LOCK_IND_WIDTH 1
-#define        FRF_AB_XX_CH0_PRBS_FRUN_LBN 1
-#define        FRF_AB_XX_CH0_PRBS_FRUN_WIDTH 1
-#define        FRF_AB_XX_CH0_ERR_CHK_LBN 0
-#define        FRF_AB_XX_CH0_ERR_CHK_WIDTH 1
-
-/* XX_PRBS_ERR_REG: documentation to be written for sum_XX_PRBS_ERR_REG */
-#define        FR_AB_XX_PRBS_ERR 0x00001350
-#define        FRF_AB_XX_CH3_PRBS_ERR_CNT_LBN 24
-#define        FRF_AB_XX_CH3_PRBS_ERR_CNT_WIDTH 8
-#define        FRF_AB_XX_CH2_PRBS_ERR_CNT_LBN 16
-#define        FRF_AB_XX_CH2_PRBS_ERR_CNT_WIDTH 8
-#define        FRF_AB_XX_CH1_PRBS_ERR_CNT_LBN 8
-#define        FRF_AB_XX_CH1_PRBS_ERR_CNT_WIDTH 8
-#define        FRF_AB_XX_CH0_PRBS_ERR_CNT_LBN 0
-#define        FRF_AB_XX_CH0_PRBS_ERR_CNT_WIDTH 8
-
-/* XX_CORE_STAT_REG: XAUI XGXS core status register */
-#define        FR_AB_XX_CORE_STAT 0x00001360
-#define        FRF_AB_XX_FORCE_SIG3_LBN 31
-#define        FRF_AB_XX_FORCE_SIG3_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG3_VAL_LBN 30
-#define        FRF_AB_XX_FORCE_SIG3_VAL_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG2_LBN 29
-#define        FRF_AB_XX_FORCE_SIG2_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG2_VAL_LBN 28
-#define        FRF_AB_XX_FORCE_SIG2_VAL_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG1_LBN 27
-#define        FRF_AB_XX_FORCE_SIG1_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG1_VAL_LBN 26
-#define        FRF_AB_XX_FORCE_SIG1_VAL_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG0_LBN 25
-#define        FRF_AB_XX_FORCE_SIG0_WIDTH 1
-#define        FRF_AB_XX_FORCE_SIG0_VAL_LBN 24
-#define        FRF_AB_XX_FORCE_SIG0_VAL_WIDTH 1
-#define        FRF_AB_XX_XGXS_LB_EN_LBN 23
-#define        FRF_AB_XX_XGXS_LB_EN_WIDTH 1
-#define        FRF_AB_XX_XGMII_LB_EN_LBN 22
-#define        FRF_AB_XX_XGMII_LB_EN_WIDTH 1
-#define        FRF_AB_XX_MATCH_FAULT_LBN 21
-#define        FRF_AB_XX_MATCH_FAULT_WIDTH 1
-#define        FRF_AB_XX_ALIGN_DONE_LBN 20
-#define        FRF_AB_XX_ALIGN_DONE_WIDTH 1
-#define        FRF_AB_XX_SYNC_STAT3_LBN 19
-#define        FRF_AB_XX_SYNC_STAT3_WIDTH 1
-#define        FRF_AB_XX_SYNC_STAT2_LBN 18
-#define        FRF_AB_XX_SYNC_STAT2_WIDTH 1
-#define        FRF_AB_XX_SYNC_STAT1_LBN 17
-#define        FRF_AB_XX_SYNC_STAT1_WIDTH 1
-#define        FRF_AB_XX_SYNC_STAT0_LBN 16
-#define        FRF_AB_XX_SYNC_STAT0_WIDTH 1
-#define        FRF_AB_XX_COMMA_DET_CH3_LBN 15
-#define        FRF_AB_XX_COMMA_DET_CH3_WIDTH 1
-#define        FRF_AB_XX_COMMA_DET_CH2_LBN 14
-#define        FRF_AB_XX_COMMA_DET_CH2_WIDTH 1
-#define        FRF_AB_XX_COMMA_DET_CH1_LBN 13
-#define        FRF_AB_XX_COMMA_DET_CH1_WIDTH 1
-#define        FRF_AB_XX_COMMA_DET_CH0_LBN 12
-#define        FRF_AB_XX_COMMA_DET_CH0_WIDTH 1
-#define        FRF_AB_XX_CGRP_ALIGN_CH3_LBN 11
-#define        FRF_AB_XX_CGRP_ALIGN_CH3_WIDTH 1
-#define        FRF_AB_XX_CGRP_ALIGN_CH2_LBN 10
-#define        FRF_AB_XX_CGRP_ALIGN_CH2_WIDTH 1
-#define        FRF_AB_XX_CGRP_ALIGN_CH1_LBN 9
-#define        FRF_AB_XX_CGRP_ALIGN_CH1_WIDTH 1
-#define        FRF_AB_XX_CGRP_ALIGN_CH0_LBN 8
-#define        FRF_AB_XX_CGRP_ALIGN_CH0_WIDTH 1
-#define        FRF_AB_XX_CHAR_ERR_CH3_LBN 7
-#define        FRF_AB_XX_CHAR_ERR_CH3_WIDTH 1
-#define        FRF_AB_XX_CHAR_ERR_CH2_LBN 6
-#define        FRF_AB_XX_CHAR_ERR_CH2_WIDTH 1
-#define        FRF_AB_XX_CHAR_ERR_CH1_LBN 5
-#define        FRF_AB_XX_CHAR_ERR_CH1_WIDTH 1
-#define        FRF_AB_XX_CHAR_ERR_CH0_LBN 4
-#define        FRF_AB_XX_CHAR_ERR_CH0_WIDTH 1
-#define        FRF_AB_XX_DISPERR_CH3_LBN 3
-#define        FRF_AB_XX_DISPERR_CH3_WIDTH 1
-#define        FRF_AB_XX_DISPERR_CH2_LBN 2
-#define        FRF_AB_XX_DISPERR_CH2_WIDTH 1
-#define        FRF_AB_XX_DISPERR_CH1_LBN 1
-#define        FRF_AB_XX_DISPERR_CH1_WIDTH 1
-#define        FRF_AB_XX_DISPERR_CH0_LBN 0
-#define        FRF_AB_XX_DISPERR_CH0_WIDTH 1
-
-/* RX_DESC_PTR_TBL_KER: Receive descriptor pointer table */
-#define        FR_AA_RX_DESC_PTR_TBL_KER 0x00011800
-#define        FR_AA_RX_DESC_PTR_TBL_KER_STEP 16
-#define        FR_AA_RX_DESC_PTR_TBL_KER_ROWS 4
-/* RX_DESC_PTR_TBL: Receive descriptor pointer table */
-#define        FR_BZ_RX_DESC_PTR_TBL 0x00f40000
-#define        FR_BZ_RX_DESC_PTR_TBL_STEP 16
-#define        FR_BB_RX_DESC_PTR_TBL_ROWS 4096
-#define        FR_CZ_RX_DESC_PTR_TBL_ROWS 1024
-#define        FRF_CZ_RX_HDR_SPLIT_LBN 90
-#define        FRF_CZ_RX_HDR_SPLIT_WIDTH 1
-#define        FRF_AA_RX_RESET_LBN 89
-#define        FRF_AA_RX_RESET_WIDTH 1
-#define        FRF_AZ_RX_ISCSI_DDIG_EN_LBN 88
-#define        FRF_AZ_RX_ISCSI_DDIG_EN_WIDTH 1
-#define        FRF_AZ_RX_ISCSI_HDIG_EN_LBN 87
-#define        FRF_AZ_RX_ISCSI_HDIG_EN_WIDTH 1
-#define        FRF_AZ_RX_DESC_PREF_ACT_LBN 86
-#define        FRF_AZ_RX_DESC_PREF_ACT_WIDTH 1
-#define        FRF_AZ_RX_DC_HW_RPTR_LBN 80
-#define        FRF_AZ_RX_DC_HW_RPTR_WIDTH 6
-#define        FRF_AZ_RX_DESCQ_HW_RPTR_LBN 68
-#define        FRF_AZ_RX_DESCQ_HW_RPTR_WIDTH 12
-#define        FRF_AZ_RX_DESCQ_SW_WPTR_LBN 56
-#define        FRF_AZ_RX_DESCQ_SW_WPTR_WIDTH 12
-#define        FRF_AZ_RX_DESCQ_BUF_BASE_ID_LBN 36
-#define        FRF_AZ_RX_DESCQ_BUF_BASE_ID_WIDTH 20
-#define        FRF_AZ_RX_DESCQ_EVQ_ID_LBN 24
-#define        FRF_AZ_RX_DESCQ_EVQ_ID_WIDTH 12
-#define        FRF_AZ_RX_DESCQ_OWNER_ID_LBN 10
-#define        FRF_AZ_RX_DESCQ_OWNER_ID_WIDTH 14
-#define        FRF_AZ_RX_DESCQ_LABEL_LBN 5
-#define        FRF_AZ_RX_DESCQ_LABEL_WIDTH 5
-#define        FRF_AZ_RX_DESCQ_SIZE_LBN 3
-#define        FRF_AZ_RX_DESCQ_SIZE_WIDTH 2
-#define        FFE_AZ_RX_DESCQ_SIZE_4K 3
-#define        FFE_AZ_RX_DESCQ_SIZE_2K 2
-#define        FFE_AZ_RX_DESCQ_SIZE_1K 1
-#define        FFE_AZ_RX_DESCQ_SIZE_512 0
-#define        FRF_AZ_RX_DESCQ_TYPE_LBN 2
-#define        FRF_AZ_RX_DESCQ_TYPE_WIDTH 1
-#define        FRF_AZ_RX_DESCQ_JUMBO_LBN 1
-#define        FRF_AZ_RX_DESCQ_JUMBO_WIDTH 1
-#define        FRF_AZ_RX_DESCQ_EN_LBN 0
-#define        FRF_AZ_RX_DESCQ_EN_WIDTH 1
-
-/* TX_DESC_PTR_TBL_KER: Transmit descriptor pointer */
-#define        FR_AA_TX_DESC_PTR_TBL_KER 0x00011900
-#define        FR_AA_TX_DESC_PTR_TBL_KER_STEP 16
-#define        FR_AA_TX_DESC_PTR_TBL_KER_ROWS 8
-/* TX_DESC_PTR_TBL: Transmit descriptor pointer */
-#define        FR_BZ_TX_DESC_PTR_TBL 0x00f50000
-#define        FR_BZ_TX_DESC_PTR_TBL_STEP 16
-#define        FR_BB_TX_DESC_PTR_TBL_ROWS 4096
-#define        FR_CZ_TX_DESC_PTR_TBL_ROWS 1024
-#define        FRF_CZ_TX_DPT_Q_MASK_WIDTH_LBN 94
-#define        FRF_CZ_TX_DPT_Q_MASK_WIDTH_WIDTH 2
-#define        FRF_CZ_TX_DPT_ETH_FILT_EN_LBN 93
-#define        FRF_CZ_TX_DPT_ETH_FILT_EN_WIDTH 1
-#define        FRF_CZ_TX_DPT_IP_FILT_EN_LBN 92
-#define        FRF_CZ_TX_DPT_IP_FILT_EN_WIDTH 1
-#define        FRF_BZ_TX_NON_IP_DROP_DIS_LBN 91
-#define        FRF_BZ_TX_NON_IP_DROP_DIS_WIDTH 1
-#define        FRF_BZ_TX_IP_CHKSM_DIS_LBN 90
-#define        FRF_BZ_TX_IP_CHKSM_DIS_WIDTH 1
-#define        FRF_BZ_TX_TCP_CHKSM_DIS_LBN 89
-#define        FRF_BZ_TX_TCP_CHKSM_DIS_WIDTH 1
-#define        FRF_AZ_TX_DESCQ_EN_LBN 88
-#define        FRF_AZ_TX_DESCQ_EN_WIDTH 1
-#define        FRF_AZ_TX_ISCSI_DDIG_EN_LBN 87
-#define        FRF_AZ_TX_ISCSI_DDIG_EN_WIDTH 1
-#define        FRF_AZ_TX_ISCSI_HDIG_EN_LBN 86
-#define        FRF_AZ_TX_ISCSI_HDIG_EN_WIDTH 1
-#define        FRF_AZ_TX_DC_HW_RPTR_LBN 80
-#define        FRF_AZ_TX_DC_HW_RPTR_WIDTH 6
-#define        FRF_AZ_TX_DESCQ_HW_RPTR_LBN 68
-#define        FRF_AZ_TX_DESCQ_HW_RPTR_WIDTH 12
-#define        FRF_AZ_TX_DESCQ_SW_WPTR_LBN 56
-#define        FRF_AZ_TX_DESCQ_SW_WPTR_WIDTH 12
-#define        FRF_AZ_TX_DESCQ_BUF_BASE_ID_LBN 36
-#define        FRF_AZ_TX_DESCQ_BUF_BASE_ID_WIDTH 20
-#define        FRF_AZ_TX_DESCQ_EVQ_ID_LBN 24
-#define        FRF_AZ_TX_DESCQ_EVQ_ID_WIDTH 12
-#define        FRF_AZ_TX_DESCQ_OWNER_ID_LBN 10
-#define        FRF_AZ_TX_DESCQ_OWNER_ID_WIDTH 14
-#define        FRF_AZ_TX_DESCQ_LABEL_LBN 5
-#define        FRF_AZ_TX_DESCQ_LABEL_WIDTH 5
-#define        FRF_AZ_TX_DESCQ_SIZE_LBN 3
-#define        FRF_AZ_TX_DESCQ_SIZE_WIDTH 2
-#define        FFE_AZ_TX_DESCQ_SIZE_4K 3
-#define        FFE_AZ_TX_DESCQ_SIZE_2K 2
-#define        FFE_AZ_TX_DESCQ_SIZE_1K 1
-#define        FFE_AZ_TX_DESCQ_SIZE_512 0
-#define        FRF_AZ_TX_DESCQ_TYPE_LBN 1
-#define        FRF_AZ_TX_DESCQ_TYPE_WIDTH 2
-#define        FRF_AZ_TX_DESCQ_FLUSH_LBN 0
-#define        FRF_AZ_TX_DESCQ_FLUSH_WIDTH 1
-
-/* EVQ_PTR_TBL_KER: Event queue pointer table */
-#define        FR_AA_EVQ_PTR_TBL_KER 0x00011a00
-#define        FR_AA_EVQ_PTR_TBL_KER_STEP 16
-#define        FR_AA_EVQ_PTR_TBL_KER_ROWS 4
-/* EVQ_PTR_TBL: Event queue pointer table */
-#define        FR_BZ_EVQ_PTR_TBL 0x00f60000
-#define        FR_BZ_EVQ_PTR_TBL_STEP 16
-#define        FR_CZ_EVQ_PTR_TBL_ROWS 1024
-#define        FR_BB_EVQ_PTR_TBL_ROWS 4096
-#define        FRF_BZ_EVQ_RPTR_IGN_LBN 40
-#define        FRF_BZ_EVQ_RPTR_IGN_WIDTH 1
-#define        FRF_AB_EVQ_WKUP_OR_INT_EN_LBN 39
-#define        FRF_AB_EVQ_WKUP_OR_INT_EN_WIDTH 1
-#define        FRF_CZ_EVQ_DOS_PROTECT_EN_LBN 39
-#define        FRF_CZ_EVQ_DOS_PROTECT_EN_WIDTH 1
-#define        FRF_AZ_EVQ_NXT_WPTR_LBN 24
-#define        FRF_AZ_EVQ_NXT_WPTR_WIDTH 15
-#define        FRF_AZ_EVQ_EN_LBN 23
-#define        FRF_AZ_EVQ_EN_WIDTH 1
-#define        FRF_AZ_EVQ_SIZE_LBN 20
-#define        FRF_AZ_EVQ_SIZE_WIDTH 3
-#define        FFE_AZ_EVQ_SIZE_32K 6
-#define        FFE_AZ_EVQ_SIZE_16K 5
-#define        FFE_AZ_EVQ_SIZE_8K 4
-#define        FFE_AZ_EVQ_SIZE_4K 3
-#define        FFE_AZ_EVQ_SIZE_2K 2
-#define        FFE_AZ_EVQ_SIZE_1K 1
-#define        FFE_AZ_EVQ_SIZE_512 0
-#define        FRF_AZ_EVQ_BUF_BASE_ID_LBN 0
-#define        FRF_AZ_EVQ_BUF_BASE_ID_WIDTH 20
-
-/* BUF_HALF_TBL_KER: Buffer table in half buffer table mode direct access by driver */
-#define        FR_AA_BUF_HALF_TBL_KER 0x00018000
-#define        FR_AA_BUF_HALF_TBL_KER_STEP 8
-#define        FR_AA_BUF_HALF_TBL_KER_ROWS 4096
-/* BUF_HALF_TBL: Buffer table in half buffer table mode direct access by driver */
-#define        FR_BZ_BUF_HALF_TBL 0x00800000
-#define        FR_BZ_BUF_HALF_TBL_STEP 8
-#define        FR_CZ_BUF_HALF_TBL_ROWS 147456
-#define        FR_BB_BUF_HALF_TBL_ROWS 524288
-#define        FRF_AZ_BUF_ADR_HBUF_ODD_LBN 44
-#define        FRF_AZ_BUF_ADR_HBUF_ODD_WIDTH 20
-#define        FRF_AZ_BUF_OWNER_ID_HBUF_ODD_LBN 32
-#define        FRF_AZ_BUF_OWNER_ID_HBUF_ODD_WIDTH 12
-#define        FRF_AZ_BUF_ADR_HBUF_EVEN_LBN 12
-#define        FRF_AZ_BUF_ADR_HBUF_EVEN_WIDTH 20
-#define        FRF_AZ_BUF_OWNER_ID_HBUF_EVEN_LBN 0
-#define        FRF_AZ_BUF_OWNER_ID_HBUF_EVEN_WIDTH 12
-
-/* BUF_FULL_TBL_KER: Buffer table in full buffer table mode direct access by driver */
-#define        FR_AA_BUF_FULL_TBL_KER 0x00018000
-#define        FR_AA_BUF_FULL_TBL_KER_STEP 8
-#define        FR_AA_BUF_FULL_TBL_KER_ROWS 4096
-/* BUF_FULL_TBL: Buffer table in full buffer table mode direct access by driver */
-#define        FR_BZ_BUF_FULL_TBL 0x00800000
-#define        FR_BZ_BUF_FULL_TBL_STEP 8
-#define        FR_CZ_BUF_FULL_TBL_ROWS 147456
-#define        FR_BB_BUF_FULL_TBL_ROWS 917504
-#define        FRF_AZ_BUF_FULL_UNUSED_LBN 51
-#define        FRF_AZ_BUF_FULL_UNUSED_WIDTH 13
-#define        FRF_AZ_IP_DAT_BUF_SIZE_LBN 50
-#define        FRF_AZ_IP_DAT_BUF_SIZE_WIDTH 1
-#define        FRF_AZ_BUF_ADR_REGION_LBN 48
-#define        FRF_AZ_BUF_ADR_REGION_WIDTH 2
-#define        FFE_AZ_BUF_ADR_REGN3 3
-#define        FFE_AZ_BUF_ADR_REGN2 2
-#define        FFE_AZ_BUF_ADR_REGN1 1
-#define        FFE_AZ_BUF_ADR_REGN0 0
-#define        FRF_AZ_BUF_ADR_FBUF_LBN 14
-#define        FRF_AZ_BUF_ADR_FBUF_WIDTH 34
-#define        FRF_AZ_BUF_OWNER_ID_FBUF_LBN 0
-#define        FRF_AZ_BUF_OWNER_ID_FBUF_WIDTH 14
-
-/* RX_FILTER_TBL0: TCP/IPv4 Receive filter table */
-#define        FR_BZ_RX_FILTER_TBL0 0x00f00000
-#define        FR_BZ_RX_FILTER_TBL0_STEP 32
-#define        FR_BZ_RX_FILTER_TBL0_ROWS 8192
-/* RX_FILTER_TBL1: TCP/IPv4 Receive filter table */
-#define        FR_BB_RX_FILTER_TBL1 0x00f00010
-#define        FR_BB_RX_FILTER_TBL1_STEP 32
-#define        FR_BB_RX_FILTER_TBL1_ROWS 8192
-#define        FRF_BZ_RSS_EN_LBN 110
-#define        FRF_BZ_RSS_EN_WIDTH 1
-#define        FRF_BZ_SCATTER_EN_LBN 109
-#define        FRF_BZ_SCATTER_EN_WIDTH 1
-#define        FRF_BZ_TCP_UDP_LBN 108
-#define        FRF_BZ_TCP_UDP_WIDTH 1
-#define        FRF_BZ_RXQ_ID_LBN 96
-#define        FRF_BZ_RXQ_ID_WIDTH 12
-#define        FRF_BZ_DEST_IP_LBN 64
-#define        FRF_BZ_DEST_IP_WIDTH 32
-#define        FRF_BZ_DEST_PORT_TCP_LBN 48
-#define        FRF_BZ_DEST_PORT_TCP_WIDTH 16
-#define        FRF_BZ_SRC_IP_LBN 16
-#define        FRF_BZ_SRC_IP_WIDTH 32
-#define        FRF_BZ_SRC_TCP_DEST_UDP_LBN 0
-#define        FRF_BZ_SRC_TCP_DEST_UDP_WIDTH 16
-
-/* RX_MAC_FILTER_TBL0: Receive Ethernet filter table */
-#define        FR_CZ_RX_MAC_FILTER_TBL0 0x00f00010
-#define        FR_CZ_RX_MAC_FILTER_TBL0_STEP 32
-#define        FR_CZ_RX_MAC_FILTER_TBL0_ROWS 512
-#define        FRF_CZ_RMFT_RSS_EN_LBN 75
-#define        FRF_CZ_RMFT_RSS_EN_WIDTH 1
-#define        FRF_CZ_RMFT_SCATTER_EN_LBN 74
-#define        FRF_CZ_RMFT_SCATTER_EN_WIDTH 1
-#define        FRF_CZ_RMFT_IP_OVERRIDE_LBN 73
-#define        FRF_CZ_RMFT_IP_OVERRIDE_WIDTH 1
-#define        FRF_CZ_RMFT_RXQ_ID_LBN 61
-#define        FRF_CZ_RMFT_RXQ_ID_WIDTH 12
-#define        FRF_CZ_RMFT_WILDCARD_MATCH_LBN 60
-#define        FRF_CZ_RMFT_WILDCARD_MATCH_WIDTH 1
-#define        FRF_CZ_RMFT_DEST_MAC_LBN 12
-#define        FRF_CZ_RMFT_DEST_MAC_WIDTH 48
-#define        FRF_CZ_RMFT_VLAN_ID_LBN 0
-#define        FRF_CZ_RMFT_VLAN_ID_WIDTH 12
-
-/* TIMER_TBL: Timer table */
-#define        FR_BZ_TIMER_TBL 0x00f70000
-#define        FR_BZ_TIMER_TBL_STEP 16
-#define        FR_CZ_TIMER_TBL_ROWS 1024
-#define        FR_BB_TIMER_TBL_ROWS 4096
-#define        FRF_CZ_TIMER_Q_EN_LBN 33
-#define        FRF_CZ_TIMER_Q_EN_WIDTH 1
-#define        FRF_CZ_INT_ARMD_LBN 32
-#define        FRF_CZ_INT_ARMD_WIDTH 1
-#define        FRF_CZ_INT_PEND_LBN 31
-#define        FRF_CZ_INT_PEND_WIDTH 1
-#define        FRF_CZ_HOST_NOTIFY_MODE_LBN 30
-#define        FRF_CZ_HOST_NOTIFY_MODE_WIDTH 1
-#define        FRF_CZ_RELOAD_TIMER_VAL_LBN 16
-#define        FRF_CZ_RELOAD_TIMER_VAL_WIDTH 14
-#define        FRF_CZ_TIMER_MODE_LBN 14
-#define        FRF_CZ_TIMER_MODE_WIDTH 2
-#define        FFE_CZ_TIMER_MODE_INT_HLDOFF 3
-#define        FFE_CZ_TIMER_MODE_TRIG_START 2
-#define        FFE_CZ_TIMER_MODE_IMMED_START 1
-#define        FFE_CZ_TIMER_MODE_DIS 0
-#define        FRF_BB_TIMER_MODE_LBN 12
-#define        FRF_BB_TIMER_MODE_WIDTH 2
-#define        FFE_BB_TIMER_MODE_INT_HLDOFF 2
-#define        FFE_BB_TIMER_MODE_TRIG_START 2
-#define        FFE_BB_TIMER_MODE_IMMED_START 1
-#define        FFE_BB_TIMER_MODE_DIS 0
-#define        FRF_CZ_TIMER_VAL_LBN 0
-#define        FRF_CZ_TIMER_VAL_WIDTH 14
-#define        FRF_BB_TIMER_VAL_LBN 0
-#define        FRF_BB_TIMER_VAL_WIDTH 12
-
-/* TX_PACE_TBL: Transmit pacing table */
-#define        FR_BZ_TX_PACE_TBL 0x00f80000
-#define        FR_BZ_TX_PACE_TBL_STEP 16
-#define        FR_CZ_TX_PACE_TBL_ROWS 1024
-#define        FR_BB_TX_PACE_TBL_ROWS 4096
-#define        FRF_BZ_TX_PACE_LBN 0
-#define        FRF_BZ_TX_PACE_WIDTH 5
-
-/* RX_INDIRECTION_TBL: RX Indirection Table */
-#define        FR_BZ_RX_INDIRECTION_TBL 0x00fb0000
-#define        FR_BZ_RX_INDIRECTION_TBL_STEP 16
-#define        FR_BZ_RX_INDIRECTION_TBL_ROWS 128
-#define        FRF_BZ_IT_QUEUE_LBN 0
-#define        FRF_BZ_IT_QUEUE_WIDTH 6
-
-/* TX_FILTER_TBL0: TCP/IPv4 Transmit filter table */
-#define        FR_CZ_TX_FILTER_TBL0 0x00fc0000
-#define        FR_CZ_TX_FILTER_TBL0_STEP 16
-#define        FR_CZ_TX_FILTER_TBL0_ROWS 8192
-#define        FRF_CZ_TIFT_TCP_UDP_LBN 108
-#define        FRF_CZ_TIFT_TCP_UDP_WIDTH 1
-#define        FRF_CZ_TIFT_TXQ_ID_LBN 96
-#define        FRF_CZ_TIFT_TXQ_ID_WIDTH 12
-#define        FRF_CZ_TIFT_DEST_IP_LBN 64
-#define        FRF_CZ_TIFT_DEST_IP_WIDTH 32
-#define        FRF_CZ_TIFT_DEST_PORT_TCP_LBN 48
-#define        FRF_CZ_TIFT_DEST_PORT_TCP_WIDTH 16
-#define        FRF_CZ_TIFT_SRC_IP_LBN 16
-#define        FRF_CZ_TIFT_SRC_IP_WIDTH 32
-#define        FRF_CZ_TIFT_SRC_TCP_DEST_UDP_LBN 0
-#define        FRF_CZ_TIFT_SRC_TCP_DEST_UDP_WIDTH 16
-
-/* TX_MAC_FILTER_TBL0: Transmit Ethernet filter table */
-#define        FR_CZ_TX_MAC_FILTER_TBL0 0x00fe0000
-#define        FR_CZ_TX_MAC_FILTER_TBL0_STEP 16
-#define        FR_CZ_TX_MAC_FILTER_TBL0_ROWS 512
-#define        FRF_CZ_TMFT_TXQ_ID_LBN 61
-#define        FRF_CZ_TMFT_TXQ_ID_WIDTH 12
-#define        FRF_CZ_TMFT_WILDCARD_MATCH_LBN 60
-#define        FRF_CZ_TMFT_WILDCARD_MATCH_WIDTH 1
-#define        FRF_CZ_TMFT_SRC_MAC_LBN 12
-#define        FRF_CZ_TMFT_SRC_MAC_WIDTH 48
-#define        FRF_CZ_TMFT_VLAN_ID_LBN 0
-#define        FRF_CZ_TMFT_VLAN_ID_WIDTH 12
-
-/* MC_TREG_SMEM: MC Shared Memory */
-#define        FR_CZ_MC_TREG_SMEM 0x00ff0000
-#define        FR_CZ_MC_TREG_SMEM_STEP 4
-#define        FR_CZ_MC_TREG_SMEM_ROWS 512
-#define        FRF_CZ_MC_TREG_SMEM_ROW_LBN 0
-#define        FRF_CZ_MC_TREG_SMEM_ROW_WIDTH 32
-
-/* MSIX_VECTOR_TABLE: MSIX Vector Table */
-#define        FR_BB_MSIX_VECTOR_TABLE 0x00ff0000
-#define        FR_BZ_MSIX_VECTOR_TABLE_STEP 16
-#define        FR_BB_MSIX_VECTOR_TABLE_ROWS 64
-/* MSIX_VECTOR_TABLE: MSIX Vector Table */
-#define        FR_CZ_MSIX_VECTOR_TABLE 0x00000000
-/* FR_BZ_MSIX_VECTOR_TABLE_STEP 16 */
-#define        FR_CZ_MSIX_VECTOR_TABLE_ROWS 1024
-#define        FRF_BZ_MSIX_VECTOR_RESERVED_LBN 97
-#define        FRF_BZ_MSIX_VECTOR_RESERVED_WIDTH 31
-#define        FRF_BZ_MSIX_VECTOR_MASK_LBN 96
-#define        FRF_BZ_MSIX_VECTOR_MASK_WIDTH 1
-#define        FRF_BZ_MSIX_MESSAGE_DATA_LBN 64
-#define        FRF_BZ_MSIX_MESSAGE_DATA_WIDTH 32
-#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_HI_LBN 32
-#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_HI_WIDTH 32
-#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_LO_LBN 0
-#define        FRF_BZ_MSIX_MESSAGE_ADDRESS_LO_WIDTH 32
-
-/* MSIX_PBA_TABLE: MSIX Pending Bit Array */
-#define        FR_BB_MSIX_PBA_TABLE 0x00ff2000
-#define        FR_BZ_MSIX_PBA_TABLE_STEP 4
-#define        FR_BB_MSIX_PBA_TABLE_ROWS 2
-/* MSIX_PBA_TABLE: MSIX Pending Bit Array */
-#define        FR_CZ_MSIX_PBA_TABLE 0x00008000
-/* FR_BZ_MSIX_PBA_TABLE_STEP 4 */
-#define        FR_CZ_MSIX_PBA_TABLE_ROWS 32
-#define        FRF_BZ_MSIX_PBA_PEND_DWORD_LBN 0
-#define        FRF_BZ_MSIX_PBA_PEND_DWORD_WIDTH 32
-
-/* SRM_DBG_REG: SRAM debug access */
-#define        FR_BZ_SRM_DBG 0x03000000
-#define        FR_BZ_SRM_DBG_STEP 8
-#define        FR_CZ_SRM_DBG_ROWS 262144
-#define        FR_BB_SRM_DBG_ROWS 2097152
-#define        FRF_BZ_SRM_DBG_LBN 0
-#define        FRF_BZ_SRM_DBG_WIDTH 64
-
-/* TB_MSIX_PBA_TABLE: MSIX Pending Bit Array */
-#define        FR_CZ_TB_MSIX_PBA_TABLE 0x00008000
-#define        FR_CZ_TB_MSIX_PBA_TABLE_STEP 4
-#define        FR_CZ_TB_MSIX_PBA_TABLE_ROWS 1024
-#define        FRF_CZ_TB_MSIX_PBA_PEND_DWORD_LBN 0
-#define        FRF_CZ_TB_MSIX_PBA_PEND_DWORD_WIDTH 32
-
-/* DRIVER_EV */
-#define        FSF_AZ_DRIVER_EV_SUBCODE_LBN 56
-#define        FSF_AZ_DRIVER_EV_SUBCODE_WIDTH 4
-#define        FSE_BZ_TX_DSC_ERROR_EV 15
-#define        FSE_BZ_RX_DSC_ERROR_EV 14
-#define        FSE_AA_RX_RECOVER_EV 11
-#define        FSE_AZ_TIMER_EV 10
-#define        FSE_AZ_TX_PKT_NON_TCP_UDP 9
-#define        FSE_AZ_WAKE_UP_EV 6
-#define        FSE_AZ_SRM_UPD_DONE_EV 5
-#define        FSE_AB_EVQ_NOT_EN_EV 3
-#define        FSE_AZ_EVQ_INIT_DONE_EV 2
-#define        FSE_AZ_RX_DESCQ_FLS_DONE_EV 1
-#define        FSE_AZ_TX_DESCQ_FLS_DONE_EV 0
-#define        FSF_AZ_DRIVER_EV_SUBDATA_LBN 0
-#define        FSF_AZ_DRIVER_EV_SUBDATA_WIDTH 14
-
-/* EVENT_ENTRY */
-#define        FSF_AZ_EV_CODE_LBN 60
-#define        FSF_AZ_EV_CODE_WIDTH 4
-#define        FSE_CZ_EV_CODE_MCDI_EV 12
-#define        FSE_CZ_EV_CODE_USER_EV 8
-#define        FSE_AZ_EV_CODE_DRV_GEN_EV 7
-#define        FSE_AZ_EV_CODE_GLOBAL_EV 6
-#define        FSE_AZ_EV_CODE_DRIVER_EV 5
-#define        FSE_AZ_EV_CODE_TX_EV 2
-#define        FSE_AZ_EV_CODE_RX_EV 0
-#define        FSF_AZ_EV_DATA_LBN 0
-#define        FSF_AZ_EV_DATA_WIDTH 60
-
-/* GLOBAL_EV */
-#define        FSF_BB_GLB_EV_RX_RECOVERY_LBN 12
-#define        FSF_BB_GLB_EV_RX_RECOVERY_WIDTH 1
-#define        FSF_AA_GLB_EV_RX_RECOVERY_LBN 11
-#define        FSF_AA_GLB_EV_RX_RECOVERY_WIDTH 1
-#define        FSF_BB_GLB_EV_XG_MGT_INTR_LBN 11
-#define        FSF_BB_GLB_EV_XG_MGT_INTR_WIDTH 1
-#define        FSF_AB_GLB_EV_XFP_PHY0_INTR_LBN 10
-#define        FSF_AB_GLB_EV_XFP_PHY0_INTR_WIDTH 1
-#define        FSF_AB_GLB_EV_XG_PHY0_INTR_LBN 9
-#define        FSF_AB_GLB_EV_XG_PHY0_INTR_WIDTH 1
-#define        FSF_AB_GLB_EV_G_PHY0_INTR_LBN 7
-#define        FSF_AB_GLB_EV_G_PHY0_INTR_WIDTH 1
-
-/* LEGACY_INT_VEC */
-#define        FSF_AZ_NET_IVEC_FATAL_INT_LBN 64
-#define        FSF_AZ_NET_IVEC_FATAL_INT_WIDTH 1
-#define        FSF_AZ_NET_IVEC_INT_Q_LBN 40
-#define        FSF_AZ_NET_IVEC_INT_Q_WIDTH 4
-#define        FSF_AZ_NET_IVEC_INT_FLAG_LBN 32
-#define        FSF_AZ_NET_IVEC_INT_FLAG_WIDTH 1
-#define        FSF_AZ_NET_IVEC_EVQ_FIFO_HF_LBN 1
-#define        FSF_AZ_NET_IVEC_EVQ_FIFO_HF_WIDTH 1
-#define        FSF_AZ_NET_IVEC_EVQ_FIFO_AF_LBN 0
-#define        FSF_AZ_NET_IVEC_EVQ_FIFO_AF_WIDTH 1
-
-/* MC_XGMAC_FLTR_RULE_DEF */
-#define        FSF_CZ_MC_XFRC_MODE_LBN 416
-#define        FSF_CZ_MC_XFRC_MODE_WIDTH 1
-#define        FSE_CZ_MC_XFRC_MODE_LAYERED 1
-#define        FSE_CZ_MC_XFRC_MODE_SIMPLE 0
-#define        FSF_CZ_MC_XFRC_HASH_LBN 384
-#define        FSF_CZ_MC_XFRC_HASH_WIDTH 32
-#define        FSF_CZ_MC_XFRC_LAYER4_BYTE_MASK_LBN 256
-#define        FSF_CZ_MC_XFRC_LAYER4_BYTE_MASK_WIDTH 128
-#define        FSF_CZ_MC_XFRC_LAYER3_BYTE_MASK_LBN 128
-#define        FSF_CZ_MC_XFRC_LAYER3_BYTE_MASK_WIDTH 128
-#define        FSF_CZ_MC_XFRC_LAYER2_OR_SIMPLE_BYTE_MASK_LBN 0
-#define        FSF_CZ_MC_XFRC_LAYER2_OR_SIMPLE_BYTE_MASK_WIDTH 128
-
-/* RX_EV */
-#define        FSF_CZ_RX_EV_PKT_NOT_PARSED_LBN 58
-#define        FSF_CZ_RX_EV_PKT_NOT_PARSED_WIDTH 1
-#define        FSF_CZ_RX_EV_IPV6_PKT_LBN 57
-#define        FSF_CZ_RX_EV_IPV6_PKT_WIDTH 1
-#define        FSF_AZ_RX_EV_PKT_OK_LBN 56
-#define        FSF_AZ_RX_EV_PKT_OK_WIDTH 1
-#define        FSF_AZ_RX_EV_PAUSE_FRM_ERR_LBN 55
-#define        FSF_AZ_RX_EV_PAUSE_FRM_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_BUF_OWNER_ID_ERR_LBN 54
-#define        FSF_AZ_RX_EV_BUF_OWNER_ID_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_IP_FRAG_ERR_LBN 53
-#define        FSF_AZ_RX_EV_IP_FRAG_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_IP_HDR_CHKSUM_ERR_LBN 52
-#define        FSF_AZ_RX_EV_IP_HDR_CHKSUM_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_TCP_UDP_CHKSUM_ERR_LBN 51
-#define        FSF_AZ_RX_EV_TCP_UDP_CHKSUM_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_ETH_CRC_ERR_LBN 50
-#define        FSF_AZ_RX_EV_ETH_CRC_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_FRM_TRUNC_LBN 49
-#define        FSF_AZ_RX_EV_FRM_TRUNC_WIDTH 1
-#define        FSF_AA_RX_EV_DRIB_NIB_LBN 49
-#define        FSF_AA_RX_EV_DRIB_NIB_WIDTH 1
-#define        FSF_AZ_RX_EV_TOBE_DISC_LBN 47
-#define        FSF_AZ_RX_EV_TOBE_DISC_WIDTH 1
-#define        FSF_AZ_RX_EV_PKT_TYPE_LBN 44
-#define        FSF_AZ_RX_EV_PKT_TYPE_WIDTH 3
-#define        FSE_AZ_RX_EV_PKT_TYPE_VLAN_JUMBO 5
-#define        FSE_AZ_RX_EV_PKT_TYPE_VLAN_LLC 4
-#define        FSE_AZ_RX_EV_PKT_TYPE_VLAN 3
-#define        FSE_AZ_RX_EV_PKT_TYPE_JUMBO 2
-#define        FSE_AZ_RX_EV_PKT_TYPE_LLC 1
-#define        FSE_AZ_RX_EV_PKT_TYPE_ETH 0
-#define        FSF_AZ_RX_EV_HDR_TYPE_LBN 42
-#define        FSF_AZ_RX_EV_HDR_TYPE_WIDTH 2
-#define        FSE_AZ_RX_EV_HDR_TYPE_OTHER 3
-#define        FSE_AB_RX_EV_HDR_TYPE_IPV4_OTHER 2
-#define        FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER 2
-#define        FSE_AB_RX_EV_HDR_TYPE_IPV4_UDP 1
-#define        FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP 1
-#define        FSE_AB_RX_EV_HDR_TYPE_IPV4_TCP 0
-#define        FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP 0
-#define        FSF_AZ_RX_EV_DESC_Q_EMPTY_LBN 41
-#define        FSF_AZ_RX_EV_DESC_Q_EMPTY_WIDTH 1
-#define        FSF_AZ_RX_EV_MCAST_HASH_MATCH_LBN 40
-#define        FSF_AZ_RX_EV_MCAST_HASH_MATCH_WIDTH 1
-#define        FSF_AZ_RX_EV_MCAST_PKT_LBN 39
-#define        FSF_AZ_RX_EV_MCAST_PKT_WIDTH 1
-#define        FSF_AA_RX_EV_RECOVERY_FLAG_LBN 37
-#define        FSF_AA_RX_EV_RECOVERY_FLAG_WIDTH 1
-#define        FSF_AZ_RX_EV_Q_LABEL_LBN 32
-#define        FSF_AZ_RX_EV_Q_LABEL_WIDTH 5
-#define        FSF_AZ_RX_EV_JUMBO_CONT_LBN 31
-#define        FSF_AZ_RX_EV_JUMBO_CONT_WIDTH 1
-#define        FSF_AZ_RX_EV_PORT_LBN 30
-#define        FSF_AZ_RX_EV_PORT_WIDTH 1
-#define        FSF_AZ_RX_EV_BYTE_CNT_LBN 16
-#define        FSF_AZ_RX_EV_BYTE_CNT_WIDTH 14
-#define        FSF_AZ_RX_EV_SOP_LBN 15
-#define        FSF_AZ_RX_EV_SOP_WIDTH 1
-#define        FSF_AZ_RX_EV_ISCSI_PKT_OK_LBN 14
-#define        FSF_AZ_RX_EV_ISCSI_PKT_OK_WIDTH 1
-#define        FSF_AZ_RX_EV_ISCSI_DDIG_ERR_LBN 13
-#define        FSF_AZ_RX_EV_ISCSI_DDIG_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_ISCSI_HDIG_ERR_LBN 12
-#define        FSF_AZ_RX_EV_ISCSI_HDIG_ERR_WIDTH 1
-#define        FSF_AZ_RX_EV_DESC_PTR_LBN 0
-#define        FSF_AZ_RX_EV_DESC_PTR_WIDTH 12
-
-/* RX_KER_DESC */
-#define        FSF_AZ_RX_KER_BUF_SIZE_LBN 48
-#define        FSF_AZ_RX_KER_BUF_SIZE_WIDTH 14
-#define        FSF_AZ_RX_KER_BUF_REGION_LBN 46
-#define        FSF_AZ_RX_KER_BUF_REGION_WIDTH 2
-#define        FSF_AZ_RX_KER_BUF_ADDR_LBN 0
-#define        FSF_AZ_RX_KER_BUF_ADDR_WIDTH 46
-
-/* RX_USER_DESC */
-#define        FSF_AZ_RX_USER_2BYTE_OFFSET_LBN 20
-#define        FSF_AZ_RX_USER_2BYTE_OFFSET_WIDTH 12
-#define        FSF_AZ_RX_USER_BUF_ID_LBN 0
-#define        FSF_AZ_RX_USER_BUF_ID_WIDTH 20
-
-/* TX_EV */
-#define        FSF_AZ_TX_EV_PKT_ERR_LBN 38
-#define        FSF_AZ_TX_EV_PKT_ERR_WIDTH 1
-#define        FSF_AZ_TX_EV_PKT_TOO_BIG_LBN 37
-#define        FSF_AZ_TX_EV_PKT_TOO_BIG_WIDTH 1
-#define        FSF_AZ_TX_EV_Q_LABEL_LBN 32
-#define        FSF_AZ_TX_EV_Q_LABEL_WIDTH 5
-#define        FSF_AZ_TX_EV_PORT_LBN 16
-#define        FSF_AZ_TX_EV_PORT_WIDTH 1
-#define        FSF_AZ_TX_EV_WQ_FF_FULL_LBN 15
-#define        FSF_AZ_TX_EV_WQ_FF_FULL_WIDTH 1
-#define        FSF_AZ_TX_EV_BUF_OWNER_ID_ERR_LBN 14
-#define        FSF_AZ_TX_EV_BUF_OWNER_ID_ERR_WIDTH 1
-#define        FSF_AZ_TX_EV_COMP_LBN 12
-#define        FSF_AZ_TX_EV_COMP_WIDTH 1
-#define        FSF_AZ_TX_EV_DESC_PTR_LBN 0
-#define        FSF_AZ_TX_EV_DESC_PTR_WIDTH 12
-
-/* TX_KER_DESC */
-#define        FSF_AZ_TX_KER_CONT_LBN 62
-#define        FSF_AZ_TX_KER_CONT_WIDTH 1
-#define        FSF_AZ_TX_KER_BYTE_COUNT_LBN 48
-#define        FSF_AZ_TX_KER_BYTE_COUNT_WIDTH 14
-#define        FSF_AZ_TX_KER_BUF_REGION_LBN 46
-#define        FSF_AZ_TX_KER_BUF_REGION_WIDTH 2
-#define        FSF_AZ_TX_KER_BUF_ADDR_LBN 0
-#define        FSF_AZ_TX_KER_BUF_ADDR_WIDTH 46
-
-/* TX_USER_DESC */
-#define        FSF_AZ_TX_USER_SW_EV_EN_LBN 48
-#define        FSF_AZ_TX_USER_SW_EV_EN_WIDTH 1
-#define        FSF_AZ_TX_USER_CONT_LBN 46
-#define        FSF_AZ_TX_USER_CONT_WIDTH 1
-#define        FSF_AZ_TX_USER_BYTE_CNT_LBN 33
-#define        FSF_AZ_TX_USER_BYTE_CNT_WIDTH 13
-#define        FSF_AZ_TX_USER_BUF_ID_LBN 13
-#define        FSF_AZ_TX_USER_BUF_ID_WIDTH 20
-#define        FSF_AZ_TX_USER_BYTE_OFS_LBN 0
-#define        FSF_AZ_TX_USER_BYTE_OFS_WIDTH 13
-
-/* USER_EV */
-#define        FSF_CZ_USER_QID_LBN 32
-#define        FSF_CZ_USER_QID_WIDTH 10
-#define        FSF_CZ_USER_EV_REG_VALUE_LBN 0
-#define        FSF_CZ_USER_EV_REG_VALUE_WIDTH 32
-
-/**************************************************************************
- *
- * Falcon B0 PCIe core indirect registers
- *
- **************************************************************************
- */
-
-#define FPCR_BB_PCIE_DEVICE_CTRL_STAT 0x68
-
-#define FPCR_BB_PCIE_LINK_CTRL_STAT 0x70
-
-#define FPCR_BB_ACK_RPL_TIMER 0x700
-#define FPCRF_BB_ACK_TL_LBN 0
-#define FPCRF_BB_ACK_TL_WIDTH 16
-#define FPCRF_BB_RPL_TL_LBN 16
-#define FPCRF_BB_RPL_TL_WIDTH 16
-
-#define FPCR_BB_ACK_FREQ 0x70C
-#define FPCRF_BB_ACK_FREQ_LBN 0
-#define FPCRF_BB_ACK_FREQ_WIDTH 7
-
-/**************************************************************************
- *
- * Pseudo-registers and fields
- *
- **************************************************************************
- */
-
-/* Interrupt acknowledge work-around register (A0/A1 only) */
-#define FR_AA_WORK_AROUND_BROKEN_PCI_READS 0x0070
-
-/* EE_SPI_HCMD_REG: SPI host command register */
-/* Values for the EE_SPI_HCMD_SF_SEL register field */
-#define FFE_AB_SPI_DEVICE_EEPROM 0
-#define FFE_AB_SPI_DEVICE_FLASH 1
-
-/* NIC_STAT_REG: NIC status register */
-#define FRF_AB_STRAP_10G_LBN 2
-#define FRF_AB_STRAP_10G_WIDTH 1
-#define FRF_AA_STRAP_PCIE_LBN 0
-#define FRF_AA_STRAP_PCIE_WIDTH 1
-
-/* FATAL_INTR_REG_KER: Fatal interrupt register for Kernel */
-#define FRF_AZ_FATAL_INTR_LBN 0
-#define FRF_AZ_FATAL_INTR_WIDTH 12
-
-/* SRM_CFG_REG: SRAM configuration register */
-/* We treat the number of SRAM banks and bank size as a single field */
-#define        FRF_AZ_SRM_NB_SZ_LBN FRF_AZ_SRM_BANK_SIZE_LBN
-#define        FRF_AZ_SRM_NB_SZ_WIDTH \
-       (FRF_AZ_SRM_BANK_SIZE_WIDTH + FRF_AZ_SRM_NUM_BANK_WIDTH)
-#define FFE_AB_SRM_NB1_SZ2M 0
-#define FFE_AB_SRM_NB1_SZ4M 1
-#define FFE_AB_SRM_NB1_SZ8M 2
-#define FFE_AB_SRM_NB_SZ_DEF 3
-#define FFE_AB_SRM_NB2_SZ4M 4
-#define FFE_AB_SRM_NB2_SZ8M 5
-#define FFE_AB_SRM_NB2_SZ16M 6
-#define FFE_AB_SRM_NB_SZ_RES 7
-
-/* RX_DESC_UPD_REGP0: Receive descriptor update register. */
-/* We write just the last dword of these registers */
-#define        FR_AZ_RX_DESC_UPD_DWORD_P0 \
-       (BUILD_BUG_ON_ZERO(FR_AA_RX_DESC_UPD_KER != FR_BZ_RX_DESC_UPD_P0) + \
-        FR_BZ_RX_DESC_UPD_P0 + 3 * 4)
-#define        FRF_AZ_RX_DESC_WPTR_DWORD_LBN (FRF_AZ_RX_DESC_WPTR_LBN - 3 * 32)
-#define        FRF_AZ_RX_DESC_WPTR_DWORD_WIDTH FRF_AZ_RX_DESC_WPTR_WIDTH
-
-/* TX_DESC_UPD_REGP0: Transmit descriptor update register. */
-#define FR_AZ_TX_DESC_UPD_DWORD_P0 \
-       (BUILD_BUG_ON_ZERO(FR_AA_TX_DESC_UPD_KER != FR_BZ_TX_DESC_UPD_P0) + \
-        FR_BZ_TX_DESC_UPD_P0 + 3 * 4)
-#define        FRF_AZ_TX_DESC_WPTR_DWORD_LBN (FRF_AZ_TX_DESC_WPTR_LBN - 3 * 32)
-#define        FRF_AZ_TX_DESC_WPTR_DWORD_WIDTH FRF_AZ_TX_DESC_WPTR_WIDTH
-
-/* GMF_CFG4_REG: GMAC FIFO configuration register 4 */
-#define FRF_AB_GMF_HSTFLTRFRM_PAUSE_LBN 12
-#define FRF_AB_GMF_HSTFLTRFRM_PAUSE_WIDTH 1
-
-/* GMF_CFG5_REG: GMAC FIFO configuration register 5 */
-#define FRF_AB_GMF_HSTFLTRFRMDC_PAUSE_LBN 12
-#define FRF_AB_GMF_HSTFLTRFRMDC_PAUSE_WIDTH 1
-
-/* XM_TX_PARAM_REG: XGMAC transmit parameter register */
-#define        FRF_AB_XM_MAX_TX_FRM_SIZE_LBN FRF_AB_XM_MAX_TX_FRM_SIZE_LO_LBN
-#define        FRF_AB_XM_MAX_TX_FRM_SIZE_WIDTH (FRF_AB_XM_MAX_TX_FRM_SIZE_HI_WIDTH + \
-                                        FRF_AB_XM_MAX_TX_FRM_SIZE_LO_WIDTH)
-
-/* XM_RX_PARAM_REG: XGMAC receive parameter register */
-#define        FRF_AB_XM_MAX_RX_FRM_SIZE_LBN FRF_AB_XM_MAX_RX_FRM_SIZE_LO_LBN
-#define        FRF_AB_XM_MAX_RX_FRM_SIZE_WIDTH (FRF_AB_XM_MAX_RX_FRM_SIZE_HI_WIDTH + \
-                                        FRF_AB_XM_MAX_RX_FRM_SIZE_LO_WIDTH)
-
-/* XX_TXDRV_CTL_REG: XAUI SerDes transmit drive control register */
-/* Default values */
-#define FFE_AB_XX_TXDRV_DEQ_DEF 0xe /* deq=.6 */
-#define FFE_AB_XX_TXDRV_DTX_DEF 0x5 /* 1.25 */
-#define FFE_AB_XX_SD_CTL_DRV_DEF 0  /* 20mA */
-
-/* XX_CORE_STAT_REG: XAUI XGXS core status register */
-/* XGXS all-lanes status fields */
-#define        FRF_AB_XX_SYNC_STAT_LBN FRF_AB_XX_SYNC_STAT0_LBN
-#define        FRF_AB_XX_SYNC_STAT_WIDTH 4
-#define        FRF_AB_XX_COMMA_DET_LBN FRF_AB_XX_COMMA_DET_CH0_LBN
-#define        FRF_AB_XX_COMMA_DET_WIDTH 4
-#define        FRF_AB_XX_CHAR_ERR_LBN FRF_AB_XX_CHAR_ERR_CH0_LBN
-#define        FRF_AB_XX_CHAR_ERR_WIDTH 4
-#define        FRF_AB_XX_DISPERR_LBN FRF_AB_XX_DISPERR_CH0_LBN
-#define        FRF_AB_XX_DISPERR_WIDTH 4
-#define        FFE_AB_XX_STAT_ALL_LANES 0xf
-#define        FRF_AB_XX_FORCE_SIG_LBN FRF_AB_XX_FORCE_SIG0_VAL_LBN
-#define        FRF_AB_XX_FORCE_SIG_WIDTH 8
-#define        FFE_AB_XX_FORCE_SIG_ALL_LANES 0xff
-
-/* RX_MAC_FILTER_TBL0 */
-/* RMFT_DEST_MAC is wider than 32 bits */
-#define FRF_CZ_RMFT_DEST_MAC_LO_LBN FRF_CZ_RMFT_DEST_MAC_LBN
-#define FRF_CZ_RMFT_DEST_MAC_LO_WIDTH 32
-#define FRF_CZ_RMFT_DEST_MAC_HI_LBN (FRF_CZ_RMFT_DEST_MAC_LBN + 32)
-#define FRF_CZ_RMFT_DEST_MAC_HI_WIDTH (FRF_CZ_RMFT_DEST_MAC_WIDTH - 32)
-
-/* TX_MAC_FILTER_TBL0 */
-/* TMFT_SRC_MAC is wider than 32 bits */
-#define FRF_CZ_TMFT_SRC_MAC_LO_LBN FRF_CZ_TMFT_SRC_MAC_LBN
-#define FRF_CZ_TMFT_SRC_MAC_LO_WIDTH 32
-#define FRF_CZ_TMFT_SRC_MAC_HI_LBN (FRF_CZ_TMFT_SRC_MAC_LBN + 32)
-#define FRF_CZ_TMFT_SRC_MAC_HI_WIDTH (FRF_CZ_TMFT_SRC_MAC_WIDTH - 32)
-
-/* TX_PACE_TBL */
-/* Values >20 are documented as reserved, but will result in a queue going
- * into the fast bin with a pace value of zero. */
-#define FFE_BZ_TX_PACE_OFF 0
-#define FFE_BZ_TX_PACE_RESERVED 21
-
-/* DRIVER_EV */
-/* Sub-fields of an RX flush completion event */
-#define FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL_LBN 12
-#define FSF_AZ_DRIVER_EV_RX_FLUSH_FAIL_WIDTH 1
-#define FSF_AZ_DRIVER_EV_RX_DESCQ_ID_LBN 0
-#define FSF_AZ_DRIVER_EV_RX_DESCQ_ID_WIDTH 12
-
-/* EVENT_ENTRY */
-/* Magic number field for event test */
-#define FSF_AZ_DRV_GEN_EV_MAGIC_LBN 0
-#define FSF_AZ_DRV_GEN_EV_MAGIC_WIDTH 32
-
-/**************************************************************************
- *
- * Falcon MAC stats
- *
- **************************************************************************
- *
- */
-
-#define GRxGoodOct_offset 0x0
-#define GRxGoodOct_WIDTH 48
-#define GRxBadOct_offset 0x8
-#define GRxBadOct_WIDTH 48
-#define GRxMissPkt_offset 0x10
-#define GRxMissPkt_WIDTH 32
-#define GRxFalseCRS_offset 0x14
-#define GRxFalseCRS_WIDTH 32
-#define GRxPausePkt_offset 0x18
-#define GRxPausePkt_WIDTH 32
-#define GRxBadPkt_offset 0x1C
-#define GRxBadPkt_WIDTH 32
-#define GRxUcastPkt_offset 0x20
-#define GRxUcastPkt_WIDTH 32
-#define GRxMcastPkt_offset 0x24
-#define GRxMcastPkt_WIDTH 32
-#define GRxBcastPkt_offset 0x28
-#define GRxBcastPkt_WIDTH 32
-#define GRxGoodLt64Pkt_offset 0x2C
-#define GRxGoodLt64Pkt_WIDTH 32
-#define GRxBadLt64Pkt_offset 0x30
-#define GRxBadLt64Pkt_WIDTH 32
-#define GRx64Pkt_offset 0x34
-#define GRx64Pkt_WIDTH 32
-#define GRx65to127Pkt_offset 0x38
-#define GRx65to127Pkt_WIDTH 32
-#define GRx128to255Pkt_offset 0x3C
-#define GRx128to255Pkt_WIDTH 32
-#define GRx256to511Pkt_offset 0x40
-#define GRx256to511Pkt_WIDTH 32
-#define GRx512to1023Pkt_offset 0x44
-#define GRx512to1023Pkt_WIDTH 32
-#define GRx1024to15xxPkt_offset 0x48
-#define GRx1024to15xxPkt_WIDTH 32
-#define GRx15xxtoJumboPkt_offset 0x4C
-#define GRx15xxtoJumboPkt_WIDTH 32
-#define GRxGtJumboPkt_offset 0x50
-#define GRxGtJumboPkt_WIDTH 32
-#define GRxFcsErr64to15xxPkt_offset 0x54
-#define GRxFcsErr64to15xxPkt_WIDTH 32
-#define GRxFcsErr15xxtoJumboPkt_offset 0x58
-#define GRxFcsErr15xxtoJumboPkt_WIDTH 32
-#define GRxFcsErrGtJumboPkt_offset 0x5C
-#define GRxFcsErrGtJumboPkt_WIDTH 32
-#define GTxGoodBadOct_offset 0x80
-#define GTxGoodBadOct_WIDTH 48
-#define GTxGoodOct_offset 0x88
-#define GTxGoodOct_WIDTH 48
-#define GTxSglColPkt_offset 0x90
-#define GTxSglColPkt_WIDTH 32
-#define GTxMultColPkt_offset 0x94
-#define GTxMultColPkt_WIDTH 32
-#define GTxExColPkt_offset 0x98
-#define GTxExColPkt_WIDTH 32
-#define GTxDefPkt_offset 0x9C
-#define GTxDefPkt_WIDTH 32
-#define GTxLateCol_offset 0xA0
-#define GTxLateCol_WIDTH 32
-#define GTxExDefPkt_offset 0xA4
-#define GTxExDefPkt_WIDTH 32
-#define GTxPausePkt_offset 0xA8
-#define GTxPausePkt_WIDTH 32
-#define GTxBadPkt_offset 0xAC
-#define GTxBadPkt_WIDTH 32
-#define GTxUcastPkt_offset 0xB0
-#define GTxUcastPkt_WIDTH 32
-#define GTxMcastPkt_offset 0xB4
-#define GTxMcastPkt_WIDTH 32
-#define GTxBcastPkt_offset 0xB8
-#define GTxBcastPkt_WIDTH 32
-#define GTxLt64Pkt_offset 0xBC
-#define GTxLt64Pkt_WIDTH 32
-#define GTx64Pkt_offset 0xC0
-#define GTx64Pkt_WIDTH 32
-#define GTx65to127Pkt_offset 0xC4
-#define GTx65to127Pkt_WIDTH 32
-#define GTx128to255Pkt_offset 0xC8
-#define GTx128to255Pkt_WIDTH 32
-#define GTx256to511Pkt_offset 0xCC
-#define GTx256to511Pkt_WIDTH 32
-#define GTx512to1023Pkt_offset 0xD0
-#define GTx512to1023Pkt_WIDTH 32
-#define GTx1024to15xxPkt_offset 0xD4
-#define GTx1024to15xxPkt_WIDTH 32
-#define GTx15xxtoJumboPkt_offset 0xD8
-#define GTx15xxtoJumboPkt_WIDTH 32
-#define GTxGtJumboPkt_offset 0xDC
-#define GTxGtJumboPkt_WIDTH 32
-#define GTxNonTcpUdpPkt_offset 0xE0
-#define GTxNonTcpUdpPkt_WIDTH 16
-#define GTxMacSrcErrPkt_offset 0xE4
-#define GTxMacSrcErrPkt_WIDTH 16
-#define GTxIpSrcErrPkt_offset 0xE8
-#define GTxIpSrcErrPkt_WIDTH 16
-#define GDmaDone_offset 0xEC
-#define GDmaDone_WIDTH 32
-
-#define XgRxOctets_offset 0x0
-#define XgRxOctets_WIDTH 48
-#define XgRxOctetsOK_offset 0x8
-#define XgRxOctetsOK_WIDTH 48
-#define XgRxPkts_offset 0x10
-#define XgRxPkts_WIDTH 32
-#define XgRxPktsOK_offset 0x14
-#define XgRxPktsOK_WIDTH 32
-#define XgRxBroadcastPkts_offset 0x18
-#define XgRxBroadcastPkts_WIDTH 32
-#define XgRxMulticastPkts_offset 0x1C
-#define XgRxMulticastPkts_WIDTH 32
-#define XgRxUnicastPkts_offset 0x20
-#define XgRxUnicastPkts_WIDTH 32
-#define XgRxUndersizePkts_offset 0x24
-#define XgRxUndersizePkts_WIDTH 32
-#define XgRxOversizePkts_offset 0x28
-#define XgRxOversizePkts_WIDTH 32
-#define XgRxJabberPkts_offset 0x2C
-#define XgRxJabberPkts_WIDTH 32
-#define XgRxUndersizeFCSerrorPkts_offset 0x30
-#define XgRxUndersizeFCSerrorPkts_WIDTH 32
-#define XgRxDropEvents_offset 0x34
-#define XgRxDropEvents_WIDTH 32
-#define XgRxFCSerrorPkts_offset 0x38
-#define XgRxFCSerrorPkts_WIDTH 32
-#define XgRxAlignError_offset 0x3C
-#define XgRxAlignError_WIDTH 32
-#define XgRxSymbolError_offset 0x40
-#define XgRxSymbolError_WIDTH 32
-#define XgRxInternalMACError_offset 0x44
-#define XgRxInternalMACError_WIDTH 32
-#define XgRxControlPkts_offset 0x48
-#define XgRxControlPkts_WIDTH 32
-#define XgRxPausePkts_offset 0x4C
-#define XgRxPausePkts_WIDTH 32
-#define XgRxPkts64Octets_offset 0x50
-#define XgRxPkts64Octets_WIDTH 32
-#define XgRxPkts65to127Octets_offset 0x54
-#define XgRxPkts65to127Octets_WIDTH 32
-#define XgRxPkts128to255Octets_offset 0x58
-#define XgRxPkts128to255Octets_WIDTH 32
-#define XgRxPkts256to511Octets_offset 0x5C
-#define XgRxPkts256to511Octets_WIDTH 32
-#define XgRxPkts512to1023Octets_offset 0x60
-#define XgRxPkts512to1023Octets_WIDTH 32
-#define XgRxPkts1024to15xxOctets_offset 0x64
-#define XgRxPkts1024to15xxOctets_WIDTH 32
-#define XgRxPkts15xxtoMaxOctets_offset 0x68
-#define XgRxPkts15xxtoMaxOctets_WIDTH 32
-#define XgRxLengthError_offset 0x6C
-#define XgRxLengthError_WIDTH 32
-#define XgTxPkts_offset 0x80
-#define XgTxPkts_WIDTH 32
-#define XgTxOctets_offset 0x88
-#define XgTxOctets_WIDTH 48
-#define XgTxMulticastPkts_offset 0x90
-#define XgTxMulticastPkts_WIDTH 32
-#define XgTxBroadcastPkts_offset 0x94
-#define XgTxBroadcastPkts_WIDTH 32
-#define XgTxUnicastPkts_offset 0x98
-#define XgTxUnicastPkts_WIDTH 32
-#define XgTxControlPkts_offset 0x9C
-#define XgTxControlPkts_WIDTH 32
-#define XgTxPausePkts_offset 0xA0
-#define XgTxPausePkts_WIDTH 32
-#define XgTxPkts64Octets_offset 0xA4
-#define XgTxPkts64Octets_WIDTH 32
-#define XgTxPkts65to127Octets_offset 0xA8
-#define XgTxPkts65to127Octets_WIDTH 32
-#define XgTxPkts128to255Octets_offset 0xAC
-#define XgTxPkts128to255Octets_WIDTH 32
-#define XgTxPkts256to511Octets_offset 0xB0
-#define XgTxPkts256to511Octets_WIDTH 32
-#define XgTxPkts512to1023Octets_offset 0xB4
-#define XgTxPkts512to1023Octets_WIDTH 32
-#define XgTxPkts1024to15xxOctets_offset 0xB8
-#define XgTxPkts1024to15xxOctets_WIDTH 32
-#define XgTxPkts1519toMaxOctets_offset 0xBC
-#define XgTxPkts1519toMaxOctets_WIDTH 32
-#define XgTxUndersizePkts_offset 0xC0
-#define XgTxUndersizePkts_WIDTH 32
-#define XgTxOversizePkts_offset 0xC4
-#define XgTxOversizePkts_WIDTH 32
-#define XgTxNonTcpUdpPkt_offset 0xC8
-#define XgTxNonTcpUdpPkt_WIDTH 16
-#define XgTxMacSrcErrPkt_offset 0xCC
-#define XgTxMacSrcErrPkt_WIDTH 16
-#define XgTxIpSrcErrPkt_offset 0xD0
-#define XgTxIpSrcErrPkt_WIDTH 16
-#define XgDmaDone_offset 0xD4
-#define XgDmaDone_WIDTH 32
-
-#define FALCON_STATS_NOT_DONE 0x00000000
-#define FALCON_STATS_DONE 0xffffffff
-
-/**************************************************************************
- *
- * Falcon non-volatile configuration
- *
- **************************************************************************
- */
-
-/* Board configuration v2 (v1 is obsolete; later versions are compatible) */
-struct falcon_nvconfig_board_v2 {
-       __le16 nports;
-       u8 port0_phy_addr;
-       u8 port0_phy_type;
-       u8 port1_phy_addr;
-       u8 port1_phy_type;
-       __le16 asic_sub_revision;
-       __le16 board_revision;
-} __packed;
-
-/* Board configuration v3 extra information */
-struct falcon_nvconfig_board_v3 {
-       __le32 spi_device_type[2];
-} __packed;
-
-/* Bit numbers for spi_device_type */
-#define SPI_DEV_TYPE_SIZE_LBN 0
-#define SPI_DEV_TYPE_SIZE_WIDTH 5
-#define SPI_DEV_TYPE_ADDR_LEN_LBN 6
-#define SPI_DEV_TYPE_ADDR_LEN_WIDTH 2
-#define SPI_DEV_TYPE_ERASE_CMD_LBN 8
-#define SPI_DEV_TYPE_ERASE_CMD_WIDTH 8
-#define SPI_DEV_TYPE_ERASE_SIZE_LBN 16
-#define SPI_DEV_TYPE_ERASE_SIZE_WIDTH 5
-#define SPI_DEV_TYPE_BLOCK_SIZE_LBN 24
-#define SPI_DEV_TYPE_BLOCK_SIZE_WIDTH 5
-#define SPI_DEV_TYPE_FIELD(type, field)                                        \
-       (((type) >> EFX_LOW_BIT(field)) & EFX_MASK32(EFX_WIDTH(field)))
-
-#define FALCON_NVCONFIG_OFFSET 0x300
-
-#define FALCON_NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
-struct falcon_nvconfig {
-       efx_oword_t ee_vpd_cfg_reg;                     /* 0x300 */
-       u8 mac_address[2][8];                   /* 0x310 */
-       efx_oword_t pcie_sd_ctl0123_reg;                /* 0x320 */
-       efx_oword_t pcie_sd_ctl45_reg;                  /* 0x330 */
-       efx_oword_t pcie_pcs_ctl_stat_reg;              /* 0x340 */
-       efx_oword_t hw_init_reg;                        /* 0x350 */
-       efx_oword_t nic_stat_reg;                       /* 0x360 */
-       efx_oword_t glb_ctl_reg;                        /* 0x370 */
-       efx_oword_t srm_cfg_reg;                        /* 0x380 */
-       efx_oword_t spare_reg;                          /* 0x390 */
-       __le16 board_magic_num;                 /* 0x3A0 */
-       __le16 board_struct_ver;
-       __le16 board_checksum;
-       struct falcon_nvconfig_board_v2 board_v2;
-       efx_oword_t ee_base_page_reg;                   /* 0x3B0 */
-       struct falcon_nvconfig_board_v3 board_v3;       /* 0x3C0 */
-} __packed;
-
-#endif /* EFX_REGS_H */
index 6af9cfda50fb650742dc435fb95992a3ff0f3f0d..864b6ffc9cb22f51e6271dfd0775bba327fe2c00 100644 (file)
@@ -21,6 +21,7 @@
 #include <net/checksum.h>
 #include "net_driver.h"
 #include "efx.h"
+#include "filter.h"
 #include "nic.h"
 #include "selftest.h"
 #include "workarounds.h"
@@ -60,13 +61,12 @@ static inline u8 *efx_rx_buf_va(struct efx_rx_buffer *buf)
        return page_address(buf->page) + buf->page_offset;
 }
 
-static inline u32 efx_rx_buf_hash(const u8 *eh)
+static inline u32 efx_rx_buf_hash(struct efx_nic *efx, const u8 *eh)
 {
-       /* The ethernet header is always directly after any hash. */
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || NET_IP_ALIGN % 4 == 0
-       return __le32_to_cpup((const __le32 *)(eh - 4));
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+       return __le32_to_cpup((const __le32 *)(eh + efx->rx_packet_hash_offset));
 #else
-       const u8 *data = eh - 4;
+       const u8 *data = eh + efx->rx_packet_hash_offset;
        return (u32)data[0]       |
               (u32)data[1] << 8  |
               (u32)data[2] << 16 |
@@ -326,6 +326,9 @@ void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue)
        unsigned int fill_level, batch_size;
        int space, rc = 0;
 
+       if (!rx_queue->refill_enabled)
+               return;
+
        /* Calculate current fill level, and exit if we don't need to fill */
        fill_level = (rx_queue->added_count - rx_queue->removed_count);
        EFX_BUG_ON_PARANOID(fill_level > rx_queue->efx->rxq_entries);
@@ -435,7 +438,7 @@ efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf,
        }
 
        if (efx->net_dev->features & NETIF_F_RXHASH)
-               skb->rxhash = efx_rx_buf_hash(eh);
+               skb->rxhash = efx_rx_buf_hash(efx, eh);
        skb->ip_summed = ((rx_buf->flags & EFX_RX_PKT_CSUMMED) ?
                          CHECKSUM_UNNECESSARY : CHECKSUM_NONE);
 
@@ -523,7 +526,8 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
 
        /* Validate the number of fragments and completed length */
        if (n_frags == 1) {
-               efx_rx_packet__check_len(rx_queue, rx_buf, len);
+               if (!(flags & EFX_RX_PKT_PREFIX_LEN))
+                       efx_rx_packet__check_len(rx_queue, rx_buf, len);
        } else if (unlikely(n_frags > EFX_RX_MAX_FRAGS) ||
                   unlikely(len <= (n_frags - 1) * EFX_RX_USR_BUF_SIZE) ||
                   unlikely(len > n_frags * EFX_RX_USR_BUF_SIZE) ||
@@ -551,7 +555,7 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
                return;
        }
 
-       if (n_frags == 1)
+       if (n_frags == 1 && !(flags & EFX_RX_PKT_PREFIX_LEN))
                rx_buf->len = len;
 
        /* Release and/or sync the DMA mapping - assumes all RX buffers
@@ -564,8 +568,8 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
         */
        prefetch(efx_rx_buf_va(rx_buf));
 
-       rx_buf->page_offset += efx->type->rx_buffer_hash_size;
-       rx_buf->len -= efx->type->rx_buffer_hash_size;
+       rx_buf->page_offset += efx->rx_prefix_size;
+       rx_buf->len -= efx->rx_prefix_size;
 
        if (n_frags > 1) {
                /* Release/sync DMA mapping for additional fragments.
@@ -630,6 +634,13 @@ void __efx_rx_packet(struct efx_channel *channel)
                efx_rx_buffer(&channel->rx_queue, channel->rx_pkt_index);
        u8 *eh = efx_rx_buf_va(rx_buf);
 
+       /* Read length from the prefix if necessary.  This already
+        * excludes the length of the prefix itself.
+        */
+       if (rx_buf->flags & EFX_RX_PKT_PREFIX_LEN)
+               rx_buf->len = le16_to_cpup((__le16 *)
+                                          (eh + efx->rx_packet_len_offset));
+
        /* If we're in loopback test, then pass the packet directly to the
         * loopback layer, and free the rx_buf here
         */
@@ -738,9 +749,9 @@ void efx_init_rx_queue(struct efx_rx_queue *rx_queue)
 
        rx_queue->max_fill = max_fill;
        rx_queue->fast_fill_trigger = trigger;
+       rx_queue->refill_enabled = true;
 
        /* Set up RX descriptor ring */
-       rx_queue->enabled = true;
        efx_nic_init_rx(rx_queue);
 }
 
@@ -753,11 +764,7 @@ void efx_fini_rx_queue(struct efx_rx_queue *rx_queue)
        netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev,
                  "shutting down RX queue %d\n", efx_rx_queue_index(rx_queue));
 
-       /* A flush failure might have left rx_queue->enabled */
-       rx_queue->enabled = false;
-
        del_timer_sync(&rx_queue->slow_fill);
-       efx_nic_fini_rx(rx_queue);
 
        /* Release RX buffers from the current read ptr to the write ptr */
        if (rx_queue->buffer) {
@@ -803,3 +810,96 @@ module_param(rx_refill_threshold, uint, 0444);
 MODULE_PARM_DESC(rx_refill_threshold,
                 "RX descriptor ring refill threshold (%)");
 
+#ifdef CONFIG_RFS_ACCEL
+
+int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
+                  u16 rxq_index, u32 flow_id)
+{
+       struct efx_nic *efx = netdev_priv(net_dev);
+       struct efx_channel *channel;
+       struct efx_filter_spec spec;
+       const struct iphdr *ip;
+       const __be16 *ports;
+       int nhoff;
+       int rc;
+
+       nhoff = skb_network_offset(skb);
+
+       if (skb->protocol == htons(ETH_P_8021Q)) {
+               EFX_BUG_ON_PARANOID(skb_headlen(skb) <
+                                   nhoff + sizeof(struct vlan_hdr));
+               if (((const struct vlan_hdr *)skb->data + nhoff)->
+                   h_vlan_encapsulated_proto != htons(ETH_P_IP))
+                       return -EPROTONOSUPPORT;
+
+               /* This is IP over 802.1q VLAN.  We can't filter on the
+                * IP 5-tuple and the vlan together, so just strip the
+                * vlan header and filter on the IP part.
+                */
+               nhoff += sizeof(struct vlan_hdr);
+       } else if (skb->protocol != htons(ETH_P_IP)) {
+               return -EPROTONOSUPPORT;
+       }
+
+       /* RFS must validate the IP header length before calling us */
+       EFX_BUG_ON_PARANOID(skb_headlen(skb) < nhoff + sizeof(*ip));
+       ip = (const struct iphdr *)(skb->data + nhoff);
+       if (ip_is_fragment(ip))
+               return -EPROTONOSUPPORT;
+       EFX_BUG_ON_PARANOID(skb_headlen(skb) < nhoff + 4 * ip->ihl + 4);
+       ports = (const __be16 *)(skb->data + nhoff + 4 * ip->ihl);
+
+       efx_filter_init_rx(&spec, EFX_FILTER_PRI_HINT,
+                          efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0,
+                          rxq_index);
+       rc = efx_filter_set_ipv4_full(&spec, ip->protocol,
+                                     ip->daddr, ports[1], ip->saddr, ports[0]);
+       if (rc)
+               return rc;
+
+       rc = efx->type->filter_rfs_insert(efx, &spec);
+       if (rc < 0)
+               return rc;
+
+       /* Remember this so we can check whether to expire the filter later */
+       efx->rps_flow_id[rc] = flow_id;
+       channel = efx_get_channel(efx, skb_get_rx_queue(skb));
+       ++channel->rfs_filters_added;
+
+       netif_info(efx, rx_status, efx->net_dev,
+                  "steering %s %pI4:%u:%pI4:%u to queue %u [flow %u filter %d]\n",
+                  (ip->protocol == IPPROTO_TCP) ? "TCP" : "UDP",
+                  &ip->saddr, ntohs(ports[0]), &ip->daddr, ntohs(ports[1]),
+                  rxq_index, flow_id, rc);
+
+       return rc;
+}
+
+bool __efx_filter_rfs_expire(struct efx_nic *efx, unsigned int quota)
+{
+       bool (*expire_one)(struct efx_nic *efx, u32 flow_id, unsigned int index);
+       unsigned int index, size;
+       u32 flow_id;
+
+       if (!spin_trylock_bh(&efx->filter_lock))
+               return false;
+
+       expire_one = efx->type->filter_rfs_expire_one;
+       index = efx->rps_expire_index;
+       size = efx->type->max_rx_ip_filters;
+       while (quota--) {
+               flow_id = efx->rps_flow_id[index];
+               if (expire_one(efx, flow_id, index))
+                       netif_info(efx, rx_status, efx->net_dev,
+                                  "expired filter %d [flow %u]\n",
+                                  index, flow_id);
+               if (++index == size)
+                       index = 0;
+       }
+       efx->rps_expire_index = index;
+
+       spin_unlock_bh(&efx->filter_lock);
+       return true;
+}
+
+#endif /* CONFIG_RFS_ACCEL */
index 2069f51b2aa9a1412f342b7654a6fb21ae17d9ee..716cff9d0160fef12b95dd1cd738ec9b6199c9d9 100644 (file)
@@ -447,14 +447,7 @@ static int efx_begin_loopback(struct efx_tx_queue *tx_queue)
 static int efx_poll_loopback(struct efx_nic *efx)
 {
        struct efx_loopback_state *state = efx->loopback_selftest;
-       struct efx_channel *channel;
 
-       /* NAPI polling is not enabled, so process channels
-        * synchronously */
-       efx_for_each_channel(channel, efx) {
-               if (channel->work_pending)
-                       efx_process_channel_now(channel);
-       }
        return atomic_read(&state->rx_good) == state->packet_count;
 }
 
@@ -586,10 +579,6 @@ static int efx_wait_for_link(struct efx_nic *efx)
                        mutex_lock(&efx->mac_lock);
                        efx->type->monitor(efx);
                        mutex_unlock(&efx->mac_lock);
-               } else {
-                       struct efx_channel *channel = efx_get_channel(efx, 0);
-                       if (channel->work_pending)
-                               efx_process_channel_now(channel);
                }
 
                mutex_lock(&efx->mac_lock);
index 8c91775e3c5f19bcd51f409b8e6fca21133d84cf..89180d47536788267e6e2631597d9fd1771b3f85 100644 (file)
@@ -18,8 +18,7 @@
 #include "bitfield.h"
 #include "efx.h"
 #include "nic.h"
-#include "spi.h"
-#include "regs.h"
+#include "farch_regs.h"
 #include "io.h"
 #include "phy.h"
 #include "workarounds.h"
@@ -30,7 +29,6 @@
 /* Hardware control for SFC9000 family including SFL9021 (aka Siena). */
 
 static void siena_init_wol(struct efx_nic *efx);
-static int siena_reset_hw(struct efx_nic *efx, enum reset_type method);
 
 
 static void siena_push_irq_moderation(struct efx_channel *channel)
@@ -52,81 +50,6 @@ static void siena_push_irq_moderation(struct efx_channel *channel)
                               channel->channel);
 }
 
-static int siena_mdio_write(struct net_device *net_dev,
-                           int prtad, int devad, u16 addr, u16 value)
-{
-       struct efx_nic *efx = netdev_priv(net_dev);
-       uint32_t status;
-       int rc;
-
-       rc = efx_mcdi_mdio_write(efx, efx->mdio_bus, prtad, devad,
-                                addr, value, &status);
-       if (rc)
-               return rc;
-       if (status != MC_CMD_MDIO_STATUS_GOOD)
-               return -EIO;
-
-       return 0;
-}
-
-static int siena_mdio_read(struct net_device *net_dev,
-                          int prtad, int devad, u16 addr)
-{
-       struct efx_nic *efx = netdev_priv(net_dev);
-       uint16_t value;
-       uint32_t status;
-       int rc;
-
-       rc = efx_mcdi_mdio_read(efx, efx->mdio_bus, prtad, devad,
-                               addr, &value, &status);
-       if (rc)
-               return rc;
-       if (status != MC_CMD_MDIO_STATUS_GOOD)
-               return -EIO;
-
-       return (int)value;
-}
-
-/* This call is responsible for hooking in the MAC and PHY operations */
-static int siena_probe_port(struct efx_nic *efx)
-{
-       int rc;
-
-       /* Hook in PHY operations table */
-       efx->phy_op = &efx_mcdi_phy_ops;
-
-       /* Set up MDIO structure for PHY */
-       efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
-       efx->mdio.mdio_read = siena_mdio_read;
-       efx->mdio.mdio_write = siena_mdio_write;
-
-       /* Fill out MDIO structure, loopback modes, and initial link state */
-       rc = efx->phy_op->probe(efx);
-       if (rc != 0)
-               return rc;
-
-       /* Allocate buffer for stats */
-       rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
-                                 MC_CMD_MAC_NSTATS * sizeof(u64));
-       if (rc)
-               return rc;
-       netif_dbg(efx, probe, efx->net_dev,
-                 "stats buffer at %llx (virt %p phys %llx)\n",
-                 (u64)efx->stats_buffer.dma_addr,
-                 efx->stats_buffer.addr,
-                 (u64)virt_to_phys(efx->stats_buffer.addr));
-
-       efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 1);
-
-       return 0;
-}
-
-static void siena_remove_port(struct efx_nic *efx)
-{
-       efx->phy_op->remove(efx);
-       efx_nic_free_buffer(efx, &efx->stats_buffer);
-}
-
 void siena_prepare_flush(struct efx_nic *efx)
 {
        if (efx->fc_disable++ == 0)
@@ -139,7 +62,7 @@ void siena_finish_flush(struct efx_nic *efx)
                efx_mcdi_set_mac(efx);
 }
 
-static const struct efx_nic_register_test siena_register_tests[] = {
+static const struct efx_farch_register_test siena_register_tests[] = {
        { FR_AZ_ADR_REGION,
          EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) },
        { FR_CZ_USR_EV_CFG,
@@ -178,16 +101,16 @@ static int siena_test_chip(struct efx_nic *efx, struct efx_self_tests *tests)
        /* Reset the chip immediately so that it is completely
         * quiescent regardless of what any VF driver does.
         */
-       rc = siena_reset_hw(efx, reset_method);
+       rc = efx_mcdi_reset(efx, reset_method);
        if (rc)
                goto out;
 
        tests->registers =
-               efx_nic_test_registers(efx, siena_register_tests,
-                                      ARRAY_SIZE(siena_register_tests))
+               efx_farch_test_registers(efx, siena_register_tests,
+                                        ARRAY_SIZE(siena_register_tests))
                ? -1 : 1;
 
-       rc = siena_reset_hw(efx, reset_method);
+       rc = efx_mcdi_reset(efx, reset_method);
 out:
        rc2 = efx_reset_up(efx, reset_method, rc == 0);
        return rc ? rc : rc2;
@@ -200,11 +123,6 @@ out:
  **************************************************************************
  */
 
-static enum reset_type siena_map_reset_reason(enum reset_type reason)
-{
-       return RESET_TYPE_RECOVER_OR_ALL;
-}
-
 static int siena_map_reset_flags(u32 *flags)
 {
        enum {
@@ -230,21 +148,6 @@ static int siena_map_reset_flags(u32 *flags)
        return -EINVAL;
 }
 
-static int siena_reset_hw(struct efx_nic *efx, enum reset_type method)
-{
-       int rc;
-
-       /* Recover from a failed assertion pre-reset */
-       rc = efx_mcdi_handle_assertion(efx);
-       if (rc)
-               return rc;
-
-       if (method == RESET_TYPE_WORLD)
-               return efx_mcdi_reset_mc(efx);
-       else
-               return efx_mcdi_reset_port(efx);
-}
-
 #ifdef CONFIG_EEH
 /* When a PCI device is isolated from the bus, a subsequent MMIO read is
  * required for the kernel EEH mechanisms to notice. As the Solarflare driver
@@ -280,7 +183,13 @@ static void siena_dimension_resources(struct efx_nic *efx)
         * the buffer table and descriptor caches.  In theory we can
         * map both blocks to one port, but we don't.
         */
-       efx_nic_dimension_resources(efx, FR_CZ_BUF_FULL_TBL_ROWS / 2);
+       efx_farch_dimension_resources(efx, FR_CZ_BUF_FULL_TBL_ROWS / 2);
+}
+
+static unsigned int siena_mem_map_size(struct efx_nic *efx)
+{
+       return FR_CZ_MC_TREG_SMEM +
+               FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS;
 }
 
 static int siena_probe_nic(struct efx_nic *efx)
@@ -296,20 +205,19 @@ static int siena_probe_nic(struct efx_nic *efx)
                return -ENOMEM;
        efx->nic_data = nic_data;
 
-       if (efx_nic_fpga_ver(efx) != 0) {
+       if (efx_farch_fpga_ver(efx) != 0) {
                netif_err(efx, probe, efx->net_dev,
                          "Siena FPGA not supported\n");
                rc = -ENODEV;
                goto fail1;
        }
 
+       efx->max_channels = EFX_MAX_CHANNELS;
+
        efx_reado(efx, &reg, FR_AZ_CS_DEBUG);
        efx->port_num = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;
 
-       efx_mcdi_init(efx);
-
-       /* Recover from a failed assertion before probing */
-       rc = efx_mcdi_handle_assertion(efx);
+       rc = efx_mcdi_init(efx);
        if (rc)
                goto fail1;
 
@@ -327,7 +235,7 @@ static int siena_probe_nic(struct efx_nic *efx)
                          "Host already registered with MCPU\n");
 
        /* Now we can reset the NIC */
-       rc = siena_reset_hw(efx, RESET_TYPE_ALL);
+       rc = efx_mcdi_reset(efx, RESET_TYPE_ALL);
        if (rc) {
                netif_err(efx, probe, efx->net_dev, "failed to reset NIC\n");
                goto fail3;
@@ -336,7 +244,8 @@ static int siena_probe_nic(struct efx_nic *efx)
        siena_init_wol(efx);
 
        /* Allocate memory for INT_KER */
-       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t));
+       rc = efx_nic_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t),
+                                 GFP_KERNEL);
        if (rc)
                goto fail4;
        BUG_ON(efx->irq_status.dma_addr & 0x0f);
@@ -373,6 +282,7 @@ fail4:
 fail3:
        efx_mcdi_drv_attach(efx, false, NULL);
 fail2:
+       efx_mcdi_fini(efx);
 fail1:
        kfree(efx->nic_data);
        return rc;
@@ -448,7 +358,7 @@ static int siena_init_nic(struct efx_nic *efx)
        EFX_POPULATE_OWORD_1(temp, FRF_CZ_USREV_DIS, 1);
        efx_writeo(efx, &temp, FR_CZ_USR_EV_CFG);
 
-       efx_nic_init_common(efx);
+       efx_farch_init_common(efx);
        return 0;
 }
 
@@ -458,7 +368,7 @@ static void siena_remove_nic(struct efx_nic *efx)
 
        efx_nic_free_buffer(efx, &efx->irq_status);
 
-       siena_reset_hw(efx, RESET_TYPE_ALL);
+       efx_mcdi_reset(efx, RESET_TYPE_ALL);
 
        /* Relinquish the device back to the BMC */
        efx_mcdi_drv_attach(efx, false, NULL);
@@ -466,136 +376,187 @@ static void siena_remove_nic(struct efx_nic *efx)
        /* Tear down the private nic state */
        kfree(efx->nic_data);
        efx->nic_data = NULL;
+
+       efx_mcdi_fini(efx);
 }
 
-#define STATS_GENERATION_INVALID ((__force __le64)(-1))
+#define SIENA_DMA_STAT(ext_name, mcdi_name)                    \
+       [SIENA_STAT_ ## ext_name] =                             \
+       { #ext_name, 64, 8 * MC_CMD_MAC_ ## mcdi_name }
+#define SIENA_OTHER_STAT(ext_name)                             \
+       [SIENA_STAT_ ## ext_name] = { #ext_name, 0, 0 }
+
+static const struct efx_hw_stat_desc siena_stat_desc[SIENA_STAT_COUNT] = {
+       SIENA_DMA_STAT(tx_bytes, TX_BYTES),
+       SIENA_OTHER_STAT(tx_good_bytes),
+       SIENA_DMA_STAT(tx_bad_bytes, TX_BAD_BYTES),
+       SIENA_DMA_STAT(tx_packets, TX_PKTS),
+       SIENA_DMA_STAT(tx_bad, TX_BAD_FCS_PKTS),
+       SIENA_DMA_STAT(tx_pause, TX_PAUSE_PKTS),
+       SIENA_DMA_STAT(tx_control, TX_CONTROL_PKTS),
+       SIENA_DMA_STAT(tx_unicast, TX_UNICAST_PKTS),
+       SIENA_DMA_STAT(tx_multicast, TX_MULTICAST_PKTS),
+       SIENA_DMA_STAT(tx_broadcast, TX_BROADCAST_PKTS),
+       SIENA_DMA_STAT(tx_lt64, TX_LT64_PKTS),
+       SIENA_DMA_STAT(tx_64, TX_64_PKTS),
+       SIENA_DMA_STAT(tx_65_to_127, TX_65_TO_127_PKTS),
+       SIENA_DMA_STAT(tx_128_to_255, TX_128_TO_255_PKTS),
+       SIENA_DMA_STAT(tx_256_to_511, TX_256_TO_511_PKTS),
+       SIENA_DMA_STAT(tx_512_to_1023, TX_512_TO_1023_PKTS),
+       SIENA_DMA_STAT(tx_1024_to_15xx, TX_1024_TO_15XX_PKTS),
+       SIENA_DMA_STAT(tx_15xx_to_jumbo, TX_15XX_TO_JUMBO_PKTS),
+       SIENA_DMA_STAT(tx_gtjumbo, TX_GTJUMBO_PKTS),
+       SIENA_OTHER_STAT(tx_collision),
+       SIENA_DMA_STAT(tx_single_collision, TX_SINGLE_COLLISION_PKTS),
+       SIENA_DMA_STAT(tx_multiple_collision, TX_MULTIPLE_COLLISION_PKTS),
+       SIENA_DMA_STAT(tx_excessive_collision, TX_EXCESSIVE_COLLISION_PKTS),
+       SIENA_DMA_STAT(tx_deferred, TX_DEFERRED_PKTS),
+       SIENA_DMA_STAT(tx_late_collision, TX_LATE_COLLISION_PKTS),
+       SIENA_DMA_STAT(tx_excessive_deferred, TX_EXCESSIVE_DEFERRED_PKTS),
+       SIENA_DMA_STAT(tx_non_tcpudp, TX_NON_TCPUDP_PKTS),
+       SIENA_DMA_STAT(tx_mac_src_error, TX_MAC_SRC_ERR_PKTS),
+       SIENA_DMA_STAT(tx_ip_src_error, TX_IP_SRC_ERR_PKTS),
+       SIENA_DMA_STAT(rx_bytes, RX_BYTES),
+       SIENA_OTHER_STAT(rx_good_bytes),
+       SIENA_DMA_STAT(rx_bad_bytes, RX_BAD_BYTES),
+       SIENA_DMA_STAT(rx_packets, RX_PKTS),
+       SIENA_DMA_STAT(rx_good, RX_GOOD_PKTS),
+       SIENA_DMA_STAT(rx_bad, RX_BAD_FCS_PKTS),
+       SIENA_DMA_STAT(rx_pause, RX_PAUSE_PKTS),
+       SIENA_DMA_STAT(rx_control, RX_CONTROL_PKTS),
+       SIENA_DMA_STAT(rx_unicast, RX_UNICAST_PKTS),
+       SIENA_DMA_STAT(rx_multicast, RX_MULTICAST_PKTS),
+       SIENA_DMA_STAT(rx_broadcast, RX_BROADCAST_PKTS),
+       SIENA_DMA_STAT(rx_lt64, RX_UNDERSIZE_PKTS),
+       SIENA_DMA_STAT(rx_64, RX_64_PKTS),
+       SIENA_DMA_STAT(rx_65_to_127, RX_65_TO_127_PKTS),
+       SIENA_DMA_STAT(rx_128_to_255, RX_128_TO_255_PKTS),
+       SIENA_DMA_STAT(rx_256_to_511, RX_256_TO_511_PKTS),
+       SIENA_DMA_STAT(rx_512_to_1023, RX_512_TO_1023_PKTS),
+       SIENA_DMA_STAT(rx_1024_to_15xx, RX_1024_TO_15XX_PKTS),
+       SIENA_DMA_STAT(rx_15xx_to_jumbo, RX_15XX_TO_JUMBO_PKTS),
+       SIENA_DMA_STAT(rx_gtjumbo, RX_GTJUMBO_PKTS),
+       SIENA_DMA_STAT(rx_bad_gtjumbo, RX_JABBER_PKTS),
+       SIENA_DMA_STAT(rx_overflow, RX_OVERFLOW_PKTS),
+       SIENA_DMA_STAT(rx_false_carrier, RX_FALSE_CARRIER_PKTS),
+       SIENA_DMA_STAT(rx_symbol_error, RX_SYMBOL_ERROR_PKTS),
+       SIENA_DMA_STAT(rx_align_error, RX_ALIGN_ERROR_PKTS),
+       SIENA_DMA_STAT(rx_length_error, RX_LENGTH_ERROR_PKTS),
+       SIENA_DMA_STAT(rx_internal_error, RX_INTERNAL_ERROR_PKTS),
+       SIENA_DMA_STAT(rx_nodesc_drop_cnt, RX_NODESC_DROPS),
+};
+static const unsigned long siena_stat_mask[] = {
+       [0 ... BITS_TO_LONGS(SIENA_STAT_COUNT) - 1] = ~0UL,
+};
+
+static size_t siena_describe_nic_stats(struct efx_nic *efx, u8 *names)
+{
+       return efx_nic_describe_stats(siena_stat_desc, SIENA_STAT_COUNT,
+                                     siena_stat_mask, names);
+}
 
 static int siena_try_update_nic_stats(struct efx_nic *efx)
 {
+       struct siena_nic_data *nic_data = efx->nic_data;
+       u64 *stats = nic_data->stats;
        __le64 *dma_stats;
-       struct efx_mac_stats *mac_stats;
        __le64 generation_start, generation_end;
 
-       mac_stats = &efx->mac_stats;
        dma_stats = efx->stats_buffer.addr;
 
        generation_end = dma_stats[MC_CMD_MAC_GENERATION_END];
-       if (generation_end == STATS_GENERATION_INVALID)
+       if (generation_end == EFX_MC_STATS_GENERATION_INVALID)
                return 0;
        rmb();
-
-#define MAC_STAT(M, D) \
-       mac_stats->M = le64_to_cpu(dma_stats[MC_CMD_MAC_ ## D])
-
-       MAC_STAT(tx_bytes, TX_BYTES);
-       MAC_STAT(tx_bad_bytes, TX_BAD_BYTES);
-       efx_update_diff_stat(&mac_stats->tx_good_bytes,
-                            mac_stats->tx_bytes - mac_stats->tx_bad_bytes);
-       MAC_STAT(tx_packets, TX_PKTS);
-       MAC_STAT(tx_bad, TX_BAD_FCS_PKTS);
-       MAC_STAT(tx_pause, TX_PAUSE_PKTS);
-       MAC_STAT(tx_control, TX_CONTROL_PKTS);
-       MAC_STAT(tx_unicast, TX_UNICAST_PKTS);
-       MAC_STAT(tx_multicast, TX_MULTICAST_PKTS);
-       MAC_STAT(tx_broadcast, TX_BROADCAST_PKTS);
-       MAC_STAT(tx_lt64, TX_LT64_PKTS);
-       MAC_STAT(tx_64, TX_64_PKTS);
-       MAC_STAT(tx_65_to_127, TX_65_TO_127_PKTS);
-       MAC_STAT(tx_128_to_255, TX_128_TO_255_PKTS);
-       MAC_STAT(tx_256_to_511, TX_256_TO_511_PKTS);
-       MAC_STAT(tx_512_to_1023, TX_512_TO_1023_PKTS);
-       MAC_STAT(tx_1024_to_15xx, TX_1024_TO_15XX_PKTS);
-       MAC_STAT(tx_15xx_to_jumbo, TX_15XX_TO_JUMBO_PKTS);
-       MAC_STAT(tx_gtjumbo, TX_GTJUMBO_PKTS);
-       mac_stats->tx_collision = 0;
-       MAC_STAT(tx_single_collision, TX_SINGLE_COLLISION_PKTS);
-       MAC_STAT(tx_multiple_collision, TX_MULTIPLE_COLLISION_PKTS);
-       MAC_STAT(tx_excessive_collision, TX_EXCESSIVE_COLLISION_PKTS);
-       MAC_STAT(tx_deferred, TX_DEFERRED_PKTS);
-       MAC_STAT(tx_late_collision, TX_LATE_COLLISION_PKTS);
-       mac_stats->tx_collision = (mac_stats->tx_single_collision +
-                                  mac_stats->tx_multiple_collision +
-                                  mac_stats->tx_excessive_collision +
-                                  mac_stats->tx_late_collision);
-       MAC_STAT(tx_excessive_deferred, TX_EXCESSIVE_DEFERRED_PKTS);
-       MAC_STAT(tx_non_tcpudp, TX_NON_TCPUDP_PKTS);
-       MAC_STAT(tx_mac_src_error, TX_MAC_SRC_ERR_PKTS);
-       MAC_STAT(tx_ip_src_error, TX_IP_SRC_ERR_PKTS);
-       MAC_STAT(rx_bytes, RX_BYTES);
-       MAC_STAT(rx_bad_bytes, RX_BAD_BYTES);
-       efx_update_diff_stat(&mac_stats->rx_good_bytes,
-                            mac_stats->rx_bytes - mac_stats->rx_bad_bytes);
-       MAC_STAT(rx_packets, RX_PKTS);
-       MAC_STAT(rx_good, RX_GOOD_PKTS);
-       MAC_STAT(rx_bad, RX_BAD_FCS_PKTS);
-       MAC_STAT(rx_pause, RX_PAUSE_PKTS);
-       MAC_STAT(rx_control, RX_CONTROL_PKTS);
-       MAC_STAT(rx_unicast, RX_UNICAST_PKTS);
-       MAC_STAT(rx_multicast, RX_MULTICAST_PKTS);
-       MAC_STAT(rx_broadcast, RX_BROADCAST_PKTS);
-       MAC_STAT(rx_lt64, RX_UNDERSIZE_PKTS);
-       MAC_STAT(rx_64, RX_64_PKTS);
-       MAC_STAT(rx_65_to_127, RX_65_TO_127_PKTS);
-       MAC_STAT(rx_128_to_255, RX_128_TO_255_PKTS);
-       MAC_STAT(rx_256_to_511, RX_256_TO_511_PKTS);
-       MAC_STAT(rx_512_to_1023, RX_512_TO_1023_PKTS);
-       MAC_STAT(rx_1024_to_15xx, RX_1024_TO_15XX_PKTS);
-       MAC_STAT(rx_15xx_to_jumbo, RX_15XX_TO_JUMBO_PKTS);
-       MAC_STAT(rx_gtjumbo, RX_GTJUMBO_PKTS);
-       mac_stats->rx_bad_lt64 = 0;
-       mac_stats->rx_bad_64_to_15xx = 0;
-       mac_stats->rx_bad_15xx_to_jumbo = 0;
-       MAC_STAT(rx_bad_gtjumbo, RX_JABBER_PKTS);
-       MAC_STAT(rx_overflow, RX_OVERFLOW_PKTS);
-       mac_stats->rx_missed = 0;
-       MAC_STAT(rx_false_carrier, RX_FALSE_CARRIER_PKTS);
-       MAC_STAT(rx_symbol_error, RX_SYMBOL_ERROR_PKTS);
-       MAC_STAT(rx_align_error, RX_ALIGN_ERROR_PKTS);
-       MAC_STAT(rx_length_error, RX_LENGTH_ERROR_PKTS);
-       MAC_STAT(rx_internal_error, RX_INTERNAL_ERROR_PKTS);
-       mac_stats->rx_good_lt64 = 0;
-
-       efx->n_rx_nodesc_drop_cnt =
-               le64_to_cpu(dma_stats[MC_CMD_MAC_RX_NODESC_DROPS]);
-
-#undef MAC_STAT
-
+       efx_nic_update_stats(siena_stat_desc, SIENA_STAT_COUNT, siena_stat_mask,
+                            stats, efx->stats_buffer.addr, false);
        rmb();
        generation_start = dma_stats[MC_CMD_MAC_GENERATION_START];
        if (generation_end != generation_start)
                return -EAGAIN;
 
+       /* Update derived statistics */
+       efx_update_diff_stat(&stats[SIENA_STAT_tx_good_bytes],
+                            stats[SIENA_STAT_tx_bytes] -
+                            stats[SIENA_STAT_tx_bad_bytes]);
+       stats[SIENA_STAT_tx_collision] =
+               stats[SIENA_STAT_tx_single_collision] +
+               stats[SIENA_STAT_tx_multiple_collision] +
+               stats[SIENA_STAT_tx_excessive_collision] +
+               stats[SIENA_STAT_tx_late_collision];
+       efx_update_diff_stat(&stats[SIENA_STAT_rx_good_bytes],
+                            stats[SIENA_STAT_rx_bytes] -
+                            stats[SIENA_STAT_rx_bad_bytes]);
        return 0;
 }
 
-static void siena_update_nic_stats(struct efx_nic *efx)
+static size_t siena_update_nic_stats(struct efx_nic *efx, u64 *full_stats,
+                                    struct rtnl_link_stats64 *core_stats)
 {
+       struct siena_nic_data *nic_data = efx->nic_data;
+       u64 *stats = nic_data->stats;
        int retry;
 
        /* If we're unlucky enough to read statistics wduring the DMA, wait
         * up to 10ms for it to finish (typically takes <500us) */
        for (retry = 0; retry < 100; ++retry) {
                if (siena_try_update_nic_stats(efx) == 0)
-                       return;
+                       break;
                udelay(100);
        }
 
-       /* Use the old values instead */
+       if (full_stats)
+               memcpy(full_stats, stats, sizeof(u64) * SIENA_STAT_COUNT);
+
+       if (core_stats) {
+               core_stats->rx_packets = stats[SIENA_STAT_rx_packets];
+               core_stats->tx_packets = stats[SIENA_STAT_tx_packets];
+               core_stats->rx_bytes = stats[SIENA_STAT_rx_bytes];
+               core_stats->tx_bytes = stats[SIENA_STAT_tx_bytes];
+               core_stats->rx_dropped = stats[SIENA_STAT_rx_nodesc_drop_cnt];
+               core_stats->multicast = stats[SIENA_STAT_rx_multicast];
+               core_stats->collisions = stats[SIENA_STAT_tx_collision];
+               core_stats->rx_length_errors =
+                       stats[SIENA_STAT_rx_gtjumbo] +
+                       stats[SIENA_STAT_rx_length_error];
+               core_stats->rx_crc_errors = stats[SIENA_STAT_rx_bad];
+               core_stats->rx_frame_errors = stats[SIENA_STAT_rx_align_error];
+               core_stats->rx_fifo_errors = stats[SIENA_STAT_rx_overflow];
+               core_stats->tx_window_errors =
+                       stats[SIENA_STAT_tx_late_collision];
+
+               core_stats->rx_errors = (core_stats->rx_length_errors +
+                                        core_stats->rx_crc_errors +
+                                        core_stats->rx_frame_errors +
+                                        stats[SIENA_STAT_rx_symbol_error]);
+               core_stats->tx_errors = (core_stats->tx_window_errors +
+                                        stats[SIENA_STAT_tx_bad]);
+       }
+
+       return SIENA_STAT_COUNT;
 }
 
-static void siena_start_nic_stats(struct efx_nic *efx)
+static int siena_mac_reconfigure(struct efx_nic *efx)
 {
-       __le64 *dma_stats = efx->stats_buffer.addr;
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_SET_MCAST_HASH_IN_LEN);
+       int rc;
 
-       dma_stats[MC_CMD_MAC_GENERATION_END] = STATS_GENERATION_INVALID;
+       BUILD_BUG_ON(MC_CMD_SET_MCAST_HASH_IN_LEN !=
+                    MC_CMD_SET_MCAST_HASH_IN_HASH0_OFST +
+                    sizeof(efx->multicast_hash));
 
-       efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr,
-                          MC_CMD_MAC_NSTATS * sizeof(u64), 1, 0);
-}
+       efx_farch_filter_sync_rx_mode(efx);
 
-static void siena_stop_nic_stats(struct efx_nic *efx)
-{
-       efx_mcdi_mac_stats(efx, efx->stats_buffer.dma_addr, 0, 0, 0);
+       WARN_ON(!mutex_is_locked(&efx->mac_lock));
+
+       rc = efx_mcdi_set_mac(efx);
+       if (rc != 0)
+               return rc;
+
+       memcpy(MCDI_PTR(inbuf, SET_MCAST_HASH_IN_HASH0),
+              efx->multicast_hash.byte, sizeof(efx->multicast_hash));
+       return efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH,
+                           inbuf, sizeof(inbuf), NULL, 0, NULL);
 }
 
 /**************************************************************************
@@ -669,6 +630,241 @@ static void siena_init_wol(struct efx_nic *efx)
        }
 }
 
+/**************************************************************************
+ *
+ * MCDI
+ *
+ **************************************************************************
+ */
+
+#define MCDI_PDU(efx)                                                  \
+       (efx_port_num(efx) ? MC_SMEM_P1_PDU_OFST : MC_SMEM_P0_PDU_OFST)
+#define MCDI_DOORBELL(efx)                                             \
+       (efx_port_num(efx) ? MC_SMEM_P1_DOORBELL_OFST : MC_SMEM_P0_DOORBELL_OFST)
+#define MCDI_STATUS(efx)                                               \
+       (efx_port_num(efx) ? MC_SMEM_P1_STATUS_OFST : MC_SMEM_P0_STATUS_OFST)
+
+static void siena_mcdi_request(struct efx_nic *efx,
+                              const efx_dword_t *hdr, size_t hdr_len,
+                              const efx_dword_t *sdu, size_t sdu_len)
+{
+       unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
+       unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL(efx);
+       unsigned int i;
+       unsigned int inlen_dw = DIV_ROUND_UP(sdu_len, 4);
+
+       EFX_BUG_ON_PARANOID(hdr_len != 4);
+
+       efx_writed(efx, hdr, pdu);
+
+       for (i = 0; i < inlen_dw; i++)
+               efx_writed(efx, &sdu[i], pdu + hdr_len + 4 * i);
+
+       /* Ensure the request is written out before the doorbell */
+       wmb();
+
+       /* ring the doorbell with a distinctive value */
+       _efx_writed(efx, (__force __le32) 0x45789abc, doorbell);
+}
+
+static bool siena_mcdi_poll_response(struct efx_nic *efx)
+{
+       unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
+       efx_dword_t hdr;
+
+       efx_readd(efx, &hdr, pdu);
+
+       /* All 1's indicates that shared memory is in reset (and is
+        * not a valid hdr). Wait for it to come out reset before
+        * completing the command
+        */
+       return EFX_DWORD_FIELD(hdr, EFX_DWORD_0) != 0xffffffff &&
+               EFX_DWORD_FIELD(hdr, MCDI_HEADER_RESPONSE);
+}
+
+static void siena_mcdi_read_response(struct efx_nic *efx, efx_dword_t *outbuf,
+                                    size_t offset, size_t outlen)
+{
+       unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx);
+       unsigned int outlen_dw = DIV_ROUND_UP(outlen, 4);
+       int i;
+
+       for (i = 0; i < outlen_dw; i++)
+               efx_readd(efx, &outbuf[i], pdu + offset + 4 * i);
+}
+
+static int siena_mcdi_poll_reboot(struct efx_nic *efx)
+{
+       struct siena_nic_data *nic_data = efx->nic_data;
+       unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_STATUS(efx);
+       efx_dword_t reg;
+       u32 value;
+
+       efx_readd(efx, &reg, addr);
+       value = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
+
+       if (value == 0)
+               return 0;
+
+       EFX_ZERO_DWORD(reg);
+       efx_writed(efx, &reg, addr);
+
+       /* MAC statistics have been cleared on the NIC; clear the local
+        * copies that we update with efx_update_diff_stat().
+        */
+       nic_data->stats[SIENA_STAT_tx_good_bytes] = 0;
+       nic_data->stats[SIENA_STAT_rx_good_bytes] = 0;
+
+       if (value == MC_STATUS_DWORD_ASSERT)
+               return -EINTR;
+       else
+               return -EIO;
+}
+
+/**************************************************************************
+ *
+ * MTD
+ *
+ **************************************************************************
+ */
+
+#ifdef CONFIG_SFC_MTD
+
+struct siena_nvram_type_info {
+       int port;
+       const char *name;
+};
+
+static const struct siena_nvram_type_info siena_nvram_types[] = {
+       [MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO]   = { 0, "sfc_dummy_phy" },
+       [MC_CMD_NVRAM_TYPE_MC_FW]               = { 0, "sfc_mcfw" },
+       [MC_CMD_NVRAM_TYPE_MC_FW_BACKUP]        = { 0, "sfc_mcfw_backup" },
+       [MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0]    = { 0, "sfc_static_cfg" },
+       [MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1]    = { 1, "sfc_static_cfg" },
+       [MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0]   = { 0, "sfc_dynamic_cfg" },
+       [MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1]   = { 1, "sfc_dynamic_cfg" },
+       [MC_CMD_NVRAM_TYPE_EXP_ROM]             = { 0, "sfc_exp_rom" },
+       [MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0]   = { 0, "sfc_exp_rom_cfg" },
+       [MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1]   = { 1, "sfc_exp_rom_cfg" },
+       [MC_CMD_NVRAM_TYPE_PHY_PORT0]           = { 0, "sfc_phy_fw" },
+       [MC_CMD_NVRAM_TYPE_PHY_PORT1]           = { 1, "sfc_phy_fw" },
+       [MC_CMD_NVRAM_TYPE_FPGA]                = { 0, "sfc_fpga" },
+};
+
+static int siena_mtd_probe_partition(struct efx_nic *efx,
+                                    struct efx_mcdi_mtd_partition *part,
+                                    unsigned int type)
+{
+       const struct siena_nvram_type_info *info;
+       size_t size, erase_size;
+       bool protected;
+       int rc;
+
+       if (type >= ARRAY_SIZE(siena_nvram_types) ||
+           siena_nvram_types[type].name == NULL)
+               return -ENODEV;
+
+       info = &siena_nvram_types[type];
+
+       if (info->port != efx_port_num(efx))
+               return -ENODEV;
+
+       rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &protected);
+       if (rc)
+               return rc;
+       if (protected)
+               return -ENODEV; /* hide it */
+
+       part->nvram_type = type;
+       part->common.dev_type_name = "Siena NVRAM manager";
+       part->common.type_name = info->name;
+
+       part->common.mtd.type = MTD_NORFLASH;
+       part->common.mtd.flags = MTD_CAP_NORFLASH;
+       part->common.mtd.size = size;
+       part->common.mtd.erasesize = erase_size;
+
+       return 0;
+}
+
+static int siena_mtd_get_fw_subtypes(struct efx_nic *efx,
+                                    struct efx_mcdi_mtd_partition *parts,
+                                    size_t n_parts)
+{
+       uint16_t fw_subtype_list[
+               MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM];
+       size_t i;
+       int rc;
+
+       rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list, NULL);
+       if (rc)
+               return rc;
+
+       for (i = 0; i < n_parts; i++)
+               parts[i].fw_subtype = fw_subtype_list[parts[i].nvram_type];
+
+       return 0;
+}
+
+static int siena_mtd_probe(struct efx_nic *efx)
+{
+       struct efx_mcdi_mtd_partition *parts;
+       u32 nvram_types;
+       unsigned int type;
+       size_t n_parts;
+       int rc;
+
+       ASSERT_RTNL();
+
+       rc = efx_mcdi_nvram_types(efx, &nvram_types);
+       if (rc)
+               return rc;
+
+       parts = kcalloc(hweight32(nvram_types), sizeof(*parts), GFP_KERNEL);
+       if (!parts)
+               return -ENOMEM;
+
+       type = 0;
+       n_parts = 0;
+
+       while (nvram_types != 0) {
+               if (nvram_types & 1) {
+                       rc = siena_mtd_probe_partition(efx, &parts[n_parts],
+                                                      type);
+                       if (rc == 0)
+                               n_parts++;
+                       else if (rc != -ENODEV)
+                               goto fail;
+               }
+               type++;
+               nvram_types >>= 1;
+       }
+
+       rc = siena_mtd_get_fw_subtypes(efx, parts, n_parts);
+       if (rc)
+               goto fail;
+
+       rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
+fail:
+       if (rc)
+               kfree(parts);
+       return rc;
+}
+
+#endif /* CONFIG_SFC_MTD */
+
+/**************************************************************************
+ *
+ * PTP
+ *
+ **************************************************************************
+ */
+
+static void siena_ptp_write_host_time(struct efx_nic *efx, u32 host_time)
+{
+       _efx_writed(efx, cpu_to_le32(host_time),
+                   FR_CZ_MC_TREG_SMEM + MC_SMEM_P0_PTP_TIME_OFST);
+}
 
 /**************************************************************************
  *
@@ -678,6 +874,7 @@ static void siena_init_wol(struct efx_nic *efx)
  */
 
 const struct efx_nic_type siena_a0_nic_type = {
+       .mem_map_size = siena_mem_map_size,
        .probe = siena_probe_nic,
        .remove = siena_remove_nic,
        .init = siena_init_nic,
@@ -688,44 +885,94 @@ const struct efx_nic_type siena_a0_nic_type = {
 #else
        .monitor = NULL,
 #endif
-       .map_reset_reason = siena_map_reset_reason,
+       .map_reset_reason = efx_mcdi_map_reset_reason,
        .map_reset_flags = siena_map_reset_flags,
-       .reset = siena_reset_hw,
-       .probe_port = siena_probe_port,
-       .remove_port = siena_remove_port,
+       .reset = efx_mcdi_reset,
+       .probe_port = efx_mcdi_port_probe,
+       .remove_port = efx_mcdi_port_remove,
+       .fini_dmaq = efx_farch_fini_dmaq,
        .prepare_flush = siena_prepare_flush,
        .finish_flush = siena_finish_flush,
+       .describe_stats = siena_describe_nic_stats,
        .update_stats = siena_update_nic_stats,
-       .start_stats = siena_start_nic_stats,
-       .stop_stats = siena_stop_nic_stats,
+       .start_stats = efx_mcdi_mac_start_stats,
+       .stop_stats = efx_mcdi_mac_stop_stats,
        .set_id_led = efx_mcdi_set_id_led,
        .push_irq_moderation = siena_push_irq_moderation,
-       .reconfigure_mac = efx_mcdi_mac_reconfigure,
+       .reconfigure_mac = siena_mac_reconfigure,
        .check_mac_fault = efx_mcdi_mac_check_fault,
-       .reconfigure_port = efx_mcdi_phy_reconfigure,
+       .reconfigure_port = efx_mcdi_port_reconfigure,
        .get_wol = siena_get_wol,
        .set_wol = siena_set_wol,
        .resume_wol = siena_init_wol,
        .test_chip = siena_test_chip,
        .test_nvram = efx_mcdi_nvram_test_all,
+       .mcdi_request = siena_mcdi_request,
+       .mcdi_poll_response = siena_mcdi_poll_response,
+       .mcdi_read_response = siena_mcdi_read_response,
+       .mcdi_poll_reboot = siena_mcdi_poll_reboot,
+       .irq_enable_master = efx_farch_irq_enable_master,
+       .irq_test_generate = efx_farch_irq_test_generate,
+       .irq_disable_non_ev = efx_farch_irq_disable_master,
+       .irq_handle_msi = efx_farch_msi_interrupt,
+       .irq_handle_legacy = efx_farch_legacy_interrupt,
+       .tx_probe = efx_farch_tx_probe,
+       .tx_init = efx_farch_tx_init,
+       .tx_remove = efx_farch_tx_remove,
+       .tx_write = efx_farch_tx_write,
+       .rx_push_indir_table = efx_farch_rx_push_indir_table,
+       .rx_probe = efx_farch_rx_probe,
+       .rx_init = efx_farch_rx_init,
+       .rx_remove = efx_farch_rx_remove,
+       .rx_write = efx_farch_rx_write,
+       .rx_defer_refill = efx_farch_rx_defer_refill,
+       .ev_probe = efx_farch_ev_probe,
+       .ev_init = efx_farch_ev_init,
+       .ev_fini = efx_farch_ev_fini,
+       .ev_remove = efx_farch_ev_remove,
+       .ev_process = efx_farch_ev_process,
+       .ev_read_ack = efx_farch_ev_read_ack,
+       .ev_test_generate = efx_farch_ev_test_generate,
+       .filter_table_probe = efx_farch_filter_table_probe,
+       .filter_table_restore = efx_farch_filter_table_restore,
+       .filter_table_remove = efx_farch_filter_table_remove,
+       .filter_update_rx_scatter = efx_farch_filter_update_rx_scatter,
+       .filter_insert = efx_farch_filter_insert,
+       .filter_remove_safe = efx_farch_filter_remove_safe,
+       .filter_get_safe = efx_farch_filter_get_safe,
+       .filter_clear_rx = efx_farch_filter_clear_rx,
+       .filter_count_rx_used = efx_farch_filter_count_rx_used,
+       .filter_get_rx_id_limit = efx_farch_filter_get_rx_id_limit,
+       .filter_get_rx_ids = efx_farch_filter_get_rx_ids,
+#ifdef CONFIG_RFS_ACCEL
+       .filter_rfs_insert = efx_farch_filter_rfs_insert,
+       .filter_rfs_expire_one = efx_farch_filter_rfs_expire_one,
+#endif
+#ifdef CONFIG_SFC_MTD
+       .mtd_probe = siena_mtd_probe,
+       .mtd_rename = efx_mcdi_mtd_rename,
+       .mtd_read = efx_mcdi_mtd_read,
+       .mtd_erase = efx_mcdi_mtd_erase,
+       .mtd_write = efx_mcdi_mtd_write,
+       .mtd_sync = efx_mcdi_mtd_sync,
+#endif
+       .ptp_write_host_time = siena_ptp_write_host_time,
 
        .revision = EFX_REV_SIENA_A0,
-       .mem_map_size = (FR_CZ_MC_TREG_SMEM +
-                        FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS),
        .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
        .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL,
        .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
        .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL,
        .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR,
        .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH),
-       .rx_buffer_hash_size = 0x10,
+       .rx_prefix_size = FS_BZ_RX_PREFIX_SIZE,
+       .rx_hash_offset = FS_BZ_RX_PREFIX_HASH_OFST,
        .rx_buffer_padding = 0,
        .can_rx_scatter = true,
        .max_interrupt_mode = EFX_INT_MODE_MSIX,
-       .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy
-                                  * interrupt handler only supports 32
-                                  * channels */
        .timer_period_max = 1 << FRF_CZ_TC_TIMER_VAL_WIDTH,
        .offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
                             NETIF_F_RXHASH | NETIF_F_NTUPLE),
+       .mcdi_max_ver = 1,
+       .max_rx_ip_filters = FR_BZ_RX_FILTER_TBL0_ROWS,
 };
index 90f8d1604f5fbc8c6e7d1153169b99e97388e901..4b8eef962faa03ca65420fc2d7cf7f17dd5234f1 100644 (file)
@@ -15,7 +15,7 @@
 #include "mcdi.h"
 #include "filter.h"
 #include "mcdi_pcol.h"
-#include "regs.h"
+#include "farch_regs.h"
 #include "vfdi.h"
 
 /* Number of longs required to track all the VIs in a VF */
@@ -197,8 +197,8 @@ static unsigned abs_index(struct efx_vf *vf, unsigned index)
 static int efx_sriov_cmd(struct efx_nic *efx, bool enable,
                         unsigned *vi_scale_out, unsigned *vf_total_out)
 {
-       u8 inbuf[MC_CMD_SRIOV_IN_LEN];
-       u8 outbuf[MC_CMD_SRIOV_OUT_LEN];
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_SRIOV_IN_LEN);
+       MCDI_DECLARE_BUF(outbuf, MC_CMD_SRIOV_OUT_LEN);
        unsigned vi_scale, vf_total;
        size_t outlen;
        int rc;
@@ -240,64 +240,55 @@ static void efx_sriov_usrev(struct efx_nic *efx, bool enabled)
 static int efx_sriov_memcpy(struct efx_nic *efx, struct efx_memcpy_req *req,
                            unsigned int count)
 {
-       u8 *inbuf, *record;
-       unsigned int used;
-       u32 from_rid, from_hi, from_lo;
+       MCDI_DECLARE_BUF(inbuf, MCDI_CTL_SDU_LEN_MAX_V1);
+       MCDI_DECLARE_STRUCT_PTR(record);
+       unsigned int index, used;
+       u64 from_addr;
+       u32 from_rid;
        int rc;
 
        mb();   /* Finish writing source/reading dest before DMA starts */
 
-       used = MC_CMD_MEMCPY_IN_LEN(count);
-       if (WARN_ON(used > MCDI_CTL_SDU_LEN_MAX))
+       if (WARN_ON(count > MC_CMD_MEMCPY_IN_RECORD_MAXNUM))
                return -ENOBUFS;
+       used = MC_CMD_MEMCPY_IN_LEN(count);
 
-       /* Allocate room for the largest request */
-       inbuf = kzalloc(MCDI_CTL_SDU_LEN_MAX, GFP_KERNEL);
-       if (inbuf == NULL)
-               return -ENOMEM;
-
-       record = inbuf;
-       MCDI_SET_DWORD(record, MEMCPY_IN_RECORD, count);
-       while (count-- > 0) {
+       for (index = 0; index < count; index++) {
+               record = MCDI_ARRAY_STRUCT_PTR(inbuf, MEMCPY_IN_RECORD, index);
+               MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_NUM_RECORDS,
+                              count);
                MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_TO_RID,
                               req->to_rid);
-               MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_TO_ADDR_LO,
-                              (u32)req->to_addr);
-               MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_TO_ADDR_HI,
-                              (u32)(req->to_addr >> 32));
+               MCDI_SET_QWORD(record, MEMCPY_RECORD_TYPEDEF_TO_ADDR,
+                              req->to_addr);
                if (req->from_buf == NULL) {
                        from_rid = req->from_rid;
-                       from_lo = (u32)req->from_addr;
-                       from_hi = (u32)(req->from_addr >> 32);
+                       from_addr = req->from_addr;
                } else {
-                       if (WARN_ON(used + req->length > MCDI_CTL_SDU_LEN_MAX)) {
+                       if (WARN_ON(used + req->length >
+                                   MCDI_CTL_SDU_LEN_MAX_V1)) {
                                rc = -ENOBUFS;
                                goto out;
                        }
 
                        from_rid = MC_CMD_MEMCPY_RECORD_TYPEDEF_RID_INLINE;
-                       from_lo = used;
-                       from_hi = 0;
-                       memcpy(inbuf + used, req->from_buf, req->length);
+                       from_addr = used;
+                       memcpy(_MCDI_PTR(inbuf, used), req->from_buf,
+                              req->length);
                        used += req->length;
                }
 
                MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_RID, from_rid);
-               MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LO,
-                              from_lo);
-               MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_ADDR_HI,
-                              from_hi);
+               MCDI_SET_QWORD(record, MEMCPY_RECORD_TYPEDEF_FROM_ADDR,
+                              from_addr);
                MCDI_SET_DWORD(record, MEMCPY_RECORD_TYPEDEF_LENGTH,
                               req->length);
 
                ++req;
-               record += MC_CMD_MEMCPY_IN_RECORD_LEN;
        }
 
        rc = efx_mcdi_rpc(efx, MC_CMD_MEMCPY, inbuf, used, NULL, 0, NULL);
 out:
-       kfree(inbuf);
-
        mb();   /* Don't write source/read dest before DMA is complete */
 
        return rc;
@@ -473,8 +464,9 @@ static void __efx_sriov_push_vf_status(struct efx_vf *vf)
                             VFDI_EV_SEQ, (vf->msg_seqno & 0xff),
                             VFDI_EV_TYPE, VFDI_EV_TYPE_STATUS);
        ++vf->msg_seqno;
-       efx_generate_event(efx, EFX_VI_BASE + vf->index * efx_vf_size(efx),
-                             &event);
+       efx_farch_generate_event(efx,
+                                EFX_VI_BASE + vf->index * efx_vf_size(efx),
+                                &event);
 }
 
 static void efx_sriov_bufs(struct efx_nic *efx, unsigned offset,
@@ -684,16 +676,12 @@ static int efx_vfdi_fini_all_queues(struct efx_vf *vf)
        unsigned vf_offset = EFX_VI_BASE + vf->index * efx_vf_size(efx);
        unsigned timeout = HZ;
        unsigned index, rxqs_count;
-       __le32 *rxqs;
+       MCDI_DECLARE_BUF(inbuf, MC_CMD_FLUSH_RX_QUEUES_IN_LENMAX);
        int rc;
 
        BUILD_BUG_ON(VF_MAX_RX_QUEUES >
                     MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MAXNUM);
 
-       rxqs = kmalloc(count * sizeof(*rxqs), GFP_KERNEL);
-       if (rxqs == NULL)
-               return VFDI_RC_ENOMEM;
-
        rtnl_lock();
        siena_prepare_flush(efx);
        rtnl_unlock();
@@ -708,14 +696,19 @@ static int efx_vfdi_fini_all_queues(struct efx_vf *vf)
                                             vf_offset + index);
                        efx_writeo(efx, &reg, FR_AZ_TX_FLUSH_DESCQ);
                }
-               if (test_bit(index, vf->rxq_mask))
-                       rxqs[rxqs_count++] = cpu_to_le32(vf_offset + index);
+               if (test_bit(index, vf->rxq_mask)) {
+                       MCDI_SET_ARRAY_DWORD(
+                               inbuf, FLUSH_RX_QUEUES_IN_QID_OFST,
+                               rxqs_count, vf_offset + index);
+                       rxqs_count++;
+               }
        }
 
        atomic_set(&vf->rxq_retry_count, 0);
        while (timeout && (vf->rxq_count || vf->txq_count)) {
-               rc = efx_mcdi_rpc(efx, MC_CMD_FLUSH_RX_QUEUES, (u8 *)rxqs,
-                                 rxqs_count * sizeof(*rxqs), NULL, 0, NULL);
+               rc = efx_mcdi_rpc(efx, MC_CMD_FLUSH_RX_QUEUES, inbuf,
+                                 MC_CMD_FLUSH_RX_QUEUES_IN_LEN(rxqs_count),
+                                 NULL, 0, NULL);
                WARN_ON(rc < 0);
 
                timeout = wait_event_timeout(vf->flush_waitq,
@@ -725,8 +718,10 @@ static int efx_vfdi_fini_all_queues(struct efx_vf *vf)
                for (index = 0; index < count; ++index) {
                        if (test_and_clear_bit(index, vf->rxq_retry_mask)) {
                                atomic_dec(&vf->rxq_retry_count);
-                               rxqs[rxqs_count++] =
-                                       cpu_to_le32(vf_offset + index);
+                               MCDI_SET_ARRAY_DWORD(
+                                       inbuf, FLUSH_RX_QUEUES_IN_QID_OFST,
+                                       rxqs_count, vf_offset + index);
+                               rxqs_count++;
                        }
                }
        }
@@ -749,7 +744,6 @@ static int efx_vfdi_fini_all_queues(struct efx_vf *vf)
        }
        efx_sriov_bufs(efx, vf->buftbl_base, NULL,
                       EFX_VF_BUFTBL_PER_VI * efx_vf_size(efx));
-       kfree(rxqs);
        efx_vfdi_flush_clear(vf);
 
        vf->evq0_count = 0;
@@ -1004,7 +998,7 @@ static void efx_sriov_reset_vf_work(struct work_struct *work)
        struct efx_nic *efx = vf->efx;
        struct efx_buffer buf;
 
-       if (!efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE)) {
+       if (!efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE, GFP_NOIO)) {
                efx_sriov_reset_vf(vf, &buf);
                efx_nic_free_buffer(efx, &buf);
        }
@@ -1248,7 +1242,8 @@ static int efx_sriov_vfs_init(struct efx_nic *efx)
                         pci_domain_nr(pci_dev->bus), pci_dev->bus->number,
                         PCI_SLOT(devfn), PCI_FUNC(devfn));
 
-               rc = efx_nic_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE);
+               rc = efx_nic_alloc_buffer(efx, &vf->buf, EFX_PAGE_SIZE,
+                                         GFP_KERNEL);
                if (rc)
                        goto fail;
 
@@ -1280,7 +1275,8 @@ int efx_sriov_init(struct efx_nic *efx)
        if (rc)
                goto fail_cmd;
 
-       rc = efx_nic_alloc_buffer(efx, &efx->vfdi_status, sizeof(*vfdi_status));
+       rc = efx_nic_alloc_buffer(efx, &efx->vfdi_status, sizeof(*vfdi_status),
+                                 GFP_KERNEL);
        if (rc)
                goto fail_status;
        vfdi_status = efx->vfdi_status.addr;
@@ -1535,7 +1531,7 @@ void efx_sriov_reset(struct efx_nic *efx)
        efx_sriov_usrev(efx, true);
        (void)efx_sriov_cmd(efx, true, NULL, NULL);
 
-       if (efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE))
+       if (efx_nic_alloc_buffer(efx, &buf, EFX_PAGE_SIZE, GFP_NOIO))
                return;
 
        for (vf_i = 0; vf_i < efx->vf_init_count; ++vf_i) {
diff --git a/drivers/net/ethernet/sfc/spi.h b/drivers/net/ethernet/sfc/spi.h
deleted file mode 100644 (file)
index 5431a1b..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
- * Driver for Solarflare Solarstorm network controllers and boards
- * Copyright 2005 Fen Systems Ltd.
- * Copyright 2006-2010 Solarflare Communications Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, incorporated herein by reference.
- */
-
-#ifndef EFX_SPI_H
-#define EFX_SPI_H
-
-#include "net_driver.h"
-
-/**************************************************************************
- *
- * Basic SPI command set and bit definitions
- *
- *************************************************************************/
-
-#define SPI_WRSR 0x01          /* Write status register */
-#define SPI_WRITE 0x02         /* Write data to memory array */
-#define SPI_READ 0x03          /* Read data from memory array */
-#define SPI_WRDI 0x04          /* Reset write enable latch */
-#define SPI_RDSR 0x05          /* Read status register */
-#define SPI_WREN 0x06          /* Set write enable latch */
-#define SPI_SST_EWSR 0x50      /* SST: Enable write to status register */
-
-#define SPI_STATUS_WPEN 0x80   /* Write-protect pin enabled */
-#define SPI_STATUS_BP2 0x10    /* Block protection bit 2 */
-#define SPI_STATUS_BP1 0x08    /* Block protection bit 1 */
-#define SPI_STATUS_BP0 0x04    /* Block protection bit 0 */
-#define SPI_STATUS_WEN 0x02    /* State of the write enable latch */
-#define SPI_STATUS_NRDY 0x01   /* Device busy flag */
-
-/**
- * struct efx_spi_device - an Efx SPI (Serial Peripheral Interface) device
- * @device_id:         Controller's id for the device
- * @size:              Size (in bytes)
- * @addr_len:          Number of address bytes in read/write commands
- * @munge_address:     Flag whether addresses should be munged.
- *     Some devices with 9-bit addresses (e.g. AT25040A EEPROM)
- *     use bit 3 of the command byte as address bit A8, rather
- *     than having a two-byte address.  If this flag is set, then
- *     commands should be munged in this way.
- * @erase_command:     Erase command (or 0 if sector erase not needed).
- * @erase_size:                Erase sector size (in bytes)
- *     Erase commands affect sectors with this size and alignment.
- *     This must be a power of two.
- * @block_size:                Write block size (in bytes).
- *     Write commands are limited to blocks with this size and alignment.
- */
-struct efx_spi_device {
-       int device_id;
-       unsigned int size;
-       unsigned int addr_len;
-       unsigned int munge_address:1;
-       u8 erase_command;
-       unsigned int erase_size;
-       unsigned int block_size;
-};
-
-static inline bool efx_spi_present(const struct efx_spi_device *spi)
-{
-       return spi->size != 0;
-}
-
-int falcon_spi_cmd(struct efx_nic *efx,
-                  const struct efx_spi_device *spi, unsigned int command,
-                  int address, const void *in, void *out, size_t len);
-int falcon_spi_wait_write(struct efx_nic *efx,
-                         const struct efx_spi_device *spi);
-int falcon_spi_read(struct efx_nic *efx,
-                   const struct efx_spi_device *spi, loff_t start,
-                   size_t len, size_t *retlen, u8 *buffer);
-int falcon_spi_write(struct efx_nic *efx,
-                    const struct efx_spi_device *spi, loff_t start,
-                    size_t len, size_t *retlen, const u8 *buffer);
-
-/*
- * SFC4000 flash is partitioned into:
- *     0-0x400       chip and board config (see falcon_hwdefs.h)
- *     0x400-0x8000  unused (or may contain VPD if EEPROM not present)
- *     0x8000-end    boot code (mapped to PCI expansion ROM)
- * SFC4000 small EEPROM (size < 0x400) is used for VPD only.
- * SFC4000 large EEPROM (size >= 0x400) is partitioned into:
- *     0-0x400       chip and board config
- *     configurable  VPD
- *     0x800-0x1800  boot config
- * Aside from the chip and board config, all of these are optional and may
- * be absent or truncated depending on the devices used.
- */
-#define FALCON_NVCONFIG_END 0x400U
-#define FALCON_FLASH_BOOTCODE_START 0x8000U
-#define EFX_EEPROM_BOOTCONFIG_START 0x800U
-#define EFX_EEPROM_BOOTCONFIG_END 0x1800U
-
-#endif /* EFX_SPI_H */
index 5e090e54298e667a732c53ece789bb03e40aef5e..85ee647b28ad7b2e9864a25874d909ce39843f1a 100644 (file)
@@ -437,6 +437,9 @@ void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index)
        efx_dequeue_buffers(tx_queue, index, &pkts_compl, &bytes_compl);
        netdev_tx_completed_queue(tx_queue->core_txq, pkts_compl, bytes_compl);
 
+       if (pkts_compl > 1)
+               ++tx_queue->merge_events;
+
        /* See if we need to restart the netif queue.  This memory
         * barrier ensures that we write read_count (inside
         * efx_dequeue_buffers()) before reading the queue status.
@@ -543,10 +546,13 @@ void efx_init_tx_queue(struct efx_tx_queue *tx_queue)
        tx_queue->initialised = true;
 }
 
-void efx_release_tx_buffers(struct efx_tx_queue *tx_queue)
+void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)
 {
        struct efx_tx_buffer *buffer;
 
+       netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev,
+                 "shutting down TX queue %d\n", tx_queue->queue);
+
        if (!tx_queue->buffer)
                return;
 
@@ -561,22 +567,6 @@ void efx_release_tx_buffers(struct efx_tx_queue *tx_queue)
        netdev_tx_reset_queue(tx_queue->core_txq);
 }
 
-void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)
-{
-       if (!tx_queue->initialised)
-               return;
-
-       netif_dbg(tx_queue->efx, drv, tx_queue->efx->net_dev,
-                 "shutting down TX queue %d\n", tx_queue->queue);
-
-       tx_queue->initialised = false;
-
-       /* Flush TX queue, remove descriptor ring */
-       efx_nic_fini_tx(tx_queue);
-
-       efx_release_tx_buffers(tx_queue);
-}
-
 void efx_remove_tx_queue(struct efx_tx_queue *tx_queue)
 {
        int i;
@@ -708,7 +698,8 @@ static u8 *efx_tsoh_get_buffer(struct efx_tx_queue *tx_queue,
                        TSOH_STD_SIZE * (index % TSOH_PER_PAGE) + TSOH_OFFSET;
 
                if (unlikely(!page_buf->addr) &&
-                   efx_nic_alloc_buffer(tx_queue->efx, page_buf, PAGE_SIZE))
+                   efx_nic_alloc_buffer(tx_queue->efx, page_buf, PAGE_SIZE,
+                                        GFP_ATOMIC))
                        return NULL;
 
                result = (u8 *)page_buf->addr + offset;
index e4dd3a7f304b5b70e874530fda18d251cc4515b1..7e5be1d873a7c77f8796a9d9da2a7ec574583875 100644 (file)
  * Bug numbers are from Solarflare's Bugzilla.
  */
 
-#define EFX_WORKAROUND_ALWAYS(efx) 1
 #define EFX_WORKAROUND_FALCON_A(efx) (efx_nic_rev(efx) <= EFX_REV_FALCON_A1)
 #define EFX_WORKAROUND_FALCON_AB(efx) (efx_nic_rev(efx) <= EFX_REV_FALCON_B0)
 #define EFX_WORKAROUND_SIENA(efx) (efx_nic_rev(efx) == EFX_REV_SIENA_A0)
 #define EFX_WORKAROUND_10G(efx) 1
 
-/* XAUI resets if link not detected */
-#define EFX_WORKAROUND_5147 EFX_WORKAROUND_ALWAYS
-/* RX PCIe double split performance issue */
-#define EFX_WORKAROUND_7575 EFX_WORKAROUND_ALWAYS
 /* Bit-bashed I2C reads cause performance drop */
 #define EFX_WORKAROUND_7884 EFX_WORKAROUND_10G
-/* TX_EV_PKT_ERR can be caused by a dangling TX descriptor
- * or a PCIe error (bug 11028) */
-#define EFX_WORKAROUND_10727 EFX_WORKAROUND_ALWAYS
-/* Transmit flow control may get disabled */
-#define EFX_WORKAROUND_11482 EFX_WORKAROUND_FALCON_AB
 /* Truncated IPv4 packets can confuse the TX packet parser */
 #define EFX_WORKAROUND_15592 EFX_WORKAROUND_FALCON_AB
-/* Legacy ISR read can return zero once */
-#define EFX_WORKAROUND_15783 EFX_WORKAROUND_ALWAYS
 /* Legacy interrupt storm when interrupt fifo fills */
 #define EFX_WORKAROUND_17213 EFX_WORKAROUND_SIENA
 
index 02df0894690d698c7234e8057a58714ad65a2915..ee18e6f7b4fe19d9b8e3bbec69fd5e2cd098cb81 100644 (file)
@@ -1770,9 +1770,6 @@ static void sis190_get_regs(struct net_device *dev, struct ethtool_regs *regs,
        struct sis190_private *tp = netdev_priv(dev);
        unsigned long flags;
 
-       if (regs->len > SIS190_REGS_SIZE)
-               regs->len = SIS190_REGS_SIZE;
-
        spin_lock_irqsave(&tp->lock, flags);
        memcpy_fromio(p, tp->mmio_addr, regs->len);
        spin_unlock_irqrestore(&tp->lock, flags);
index eb4aea3fe793a8372292023877eecae57c5b5acd..b7a39305472b156c05b21d0af850fd56fc3945dd 100644 (file)
@@ -1309,23 +1309,9 @@ static void sis900_timer(unsigned long data)
        struct sis900_private *sis_priv = netdev_priv(net_dev);
        struct mii_phy *mii_phy = sis_priv->mii;
        static const int next_tick = 5*HZ;
+       int speed = 0, duplex = 0;
        u16 status;
 
-       if (!sis_priv->autong_complete){
-               int uninitialized_var(speed), duplex = 0;
-
-               sis900_read_mode(net_dev, &speed, &duplex);
-               if (duplex){
-                       sis900_set_mode(sis_priv, speed, duplex);
-                       sis630_set_eq(net_dev, sis_priv->chipset_rev);
-                       netif_start_queue(net_dev);
-               }
-
-               sis_priv->timer.expires = jiffies + HZ;
-               add_timer(&sis_priv->timer);
-               return;
-       }
-
        status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS);
        status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS);
 
@@ -1336,9 +1322,15 @@ static void sis900_timer(unsigned long data)
                status = sis900_default_phy(net_dev);
                mii_phy = sis_priv->mii;
 
-               if (status & MII_STAT_LINK){
-                       sis900_check_mode(net_dev, mii_phy);
-                       netif_carrier_on(net_dev);
+               if (status & MII_STAT_LINK) {
+                       WARN_ON(!(status & MII_STAT_AUTO_DONE));
+
+                       sis900_read_mode(net_dev, &speed, &duplex);
+                       if (duplex) {
+                               sis900_set_mode(sis_priv, speed, duplex);
+                               sis630_set_eq(net_dev, sis_priv->chipset_rev);
+                               netif_carrier_on(net_dev);
+                       }
                }
        } else {
        /* Link ON -> OFF */
@@ -1612,12 +1604,6 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
        unsigned int  index_cur_tx, index_dirty_tx;
        unsigned int  count_dirty_tx;
 
-       /* Don't transmit data before the complete of auto-negotiation */
-       if(!sis_priv->autong_complete){
-               netif_stop_queue(net_dev);
-               return NETDEV_TX_BUSY;
-       }
-
        spin_lock_irqsave(&sis_priv->lock, flags);
 
        /* Calculate the next Tx descriptor entry. */
index c9d942a5c335d022a3eb8bd59ebe5345d655d557..1ef9d8a555aa33100d2103fd0d8e3a48f403a735 100644 (file)
@@ -33,10 +33,15 @@ static unsigned int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
        struct stmmac_priv *priv = (struct stmmac_priv *)p;
        unsigned int txsize = priv->dma_tx_size;
        unsigned int entry = priv->cur_tx % txsize;
-       struct dma_desc *desc = priv->dma_tx + entry;
+       struct dma_desc *desc;
        unsigned int nopaged_len = skb_headlen(skb);
        unsigned int bmax, len;
 
+       if (priv->extend_desc)
+               desc = (struct dma_desc *)(priv->dma_etx + entry);
+       else
+               desc = priv->dma_tx + entry;
+
        if (priv->plat->enh_desc)
                bmax = BUF_SIZE_8KiB;
        else
@@ -54,7 +59,11 @@ static unsigned int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                                                STMMAC_RING_MODE);
                wmb();
                entry = (++priv->cur_tx) % txsize;
-               desc = priv->dma_tx + entry;
+
+               if (priv->extend_desc)
+                       desc = (struct dma_desc *)(priv->dma_etx + entry);
+               else
+                       desc = priv->dma_tx + entry;
 
                desc->des2 = dma_map_single(priv->device, skb->data + bmax,
                                            len, DMA_TO_DEVICE);
index c922fde929a14a29cedc2fe03f3031e84fd13024..f16a9bdf45bb6738c7fca4063cf96307d6303462 100644 (file)
@@ -70,7 +70,6 @@ struct stmmac_priv {
        struct net_device *dev;
        struct device *device;
        struct mac_device_info *hw;
-       int no_csum_insertion;
        spinlock_t lock;
 
        struct phy_device *phydev ____cacheline_aligned_in_smp;
index f2ccb36e868590917a4cea295eb93dc20cb9ea8c..be406911fd01e13668c2e8408cc25a61bc4e7da8 100644 (file)
@@ -939,15 +939,20 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
 
        skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN,
                                 GFP_KERNEL);
-       if (unlikely(skb == NULL)) {
+       if (!skb) {
                pr_err("%s: Rx init fails; skb is NULL\n", __func__);
-               return 1;
+               return -ENOMEM;
        }
        skb_reserve(skb, NET_IP_ALIGN);
        priv->rx_skbuff[i] = skb;
        priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data,
                                                priv->dma_buf_sz,
                                                DMA_FROM_DEVICE);
+       if (dma_mapping_error(priv->device, priv->rx_skbuff_dma[i])) {
+               pr_err("%s: DMA mapping error\n", __func__);
+               dev_kfree_skb_any(skb);
+               return -EINVAL;
+       }
 
        p->des2 = priv->rx_skbuff_dma[i];
 
@@ -958,6 +963,16 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
        return 0;
 }
 
+static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i)
+{
+       if (priv->rx_skbuff[i]) {
+               dma_unmap_single(priv->device, priv->rx_skbuff_dma[i],
+                                priv->dma_buf_sz, DMA_FROM_DEVICE);
+               dev_kfree_skb_any(priv->rx_skbuff[i]);
+       }
+       priv->rx_skbuff[i] = NULL;
+}
+
 /**
  * init_dma_desc_rings - init the RX/TX descriptor rings
  * @dev: net device structure
@@ -965,13 +980,14 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
  * and allocates the socket buffers. It suppors the chained and ring
  * modes.
  */
-static void init_dma_desc_rings(struct net_device *dev)
+static int init_dma_desc_rings(struct net_device *dev)
 {
        int i;
        struct stmmac_priv *priv = netdev_priv(dev);
        unsigned int txsize = priv->dma_tx_size;
        unsigned int rxsize = priv->dma_rx_size;
        unsigned int bfsize = 0;
+       int ret = -ENOMEM;
 
        /* Set the max buffer size according to the DESC mode
         * and the MTU. Note that RING mode allows 16KiB bsize.
@@ -992,34 +1008,60 @@ static void init_dma_desc_rings(struct net_device *dev)
                                                          dma_extended_desc),
                                                   &priv->dma_rx_phy,
                                                   GFP_KERNEL);
+               if (!priv->dma_erx)
+                       goto err_dma;
+
                priv->dma_etx = dma_alloc_coherent(priv->device, txsize *
                                                   sizeof(struct
                                                          dma_extended_desc),
                                                   &priv->dma_tx_phy,
                                                   GFP_KERNEL);
-               if ((!priv->dma_erx) || (!priv->dma_etx))
-                       return;
+               if (!priv->dma_etx) {
+                       dma_free_coherent(priv->device, priv->dma_rx_size *
+                                       sizeof(struct dma_extended_desc),
+                                       priv->dma_erx, priv->dma_rx_phy);
+                       goto err_dma;
+               }
        } else {
                priv->dma_rx = dma_alloc_coherent(priv->device, rxsize *
                                                  sizeof(struct dma_desc),
                                                  &priv->dma_rx_phy,
                                                  GFP_KERNEL);
+               if (!priv->dma_rx)
+                       goto err_dma;
+
                priv->dma_tx = dma_alloc_coherent(priv->device, txsize *
                                                  sizeof(struct dma_desc),
                                                  &priv->dma_tx_phy,
                                                  GFP_KERNEL);
-               if ((!priv->dma_rx) || (!priv->dma_tx))
-                       return;
+               if (!priv->dma_tx) {
+                       dma_free_coherent(priv->device, priv->dma_rx_size *
+                                       sizeof(struct dma_desc),
+                                       priv->dma_rx, priv->dma_rx_phy);
+                       goto err_dma;
+               }
        }
 
        priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t),
                                            GFP_KERNEL);
+       if (!priv->rx_skbuff_dma)
+               goto err_rx_skbuff_dma;
+
        priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *),
                                        GFP_KERNEL);
+       if (!priv->rx_skbuff)
+               goto err_rx_skbuff;
+
        priv->tx_skbuff_dma = kmalloc_array(txsize, sizeof(dma_addr_t),
                                            GFP_KERNEL);
+       if (!priv->tx_skbuff_dma)
+               goto err_tx_skbuff_dma;
+
        priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *),
                                        GFP_KERNEL);
+       if (!priv->tx_skbuff)
+               goto err_tx_skbuff;
+
        if (netif_msg_probe(priv)) {
                pr_debug("(%s) dma_rx_phy=0x%08x dma_tx_phy=0x%08x\n", __func__,
                         (u32) priv->dma_rx_phy, (u32) priv->dma_tx_phy);
@@ -1034,8 +1076,9 @@ static void init_dma_desc_rings(struct net_device *dev)
                else
                        p = priv->dma_rx + i;
 
-               if (stmmac_init_rx_buffers(priv, p, i))
-                       break;
+               ret = stmmac_init_rx_buffers(priv, p, i);
+               if (ret)
+                       goto err_init_rx_buffers;
 
                if (netif_msg_probe(priv))
                        pr_debug("[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i],
@@ -1081,20 +1124,44 @@ static void init_dma_desc_rings(struct net_device *dev)
 
        if (netif_msg_hw(priv))
                stmmac_display_rings(priv);
+
+       return 0;
+err_init_rx_buffers:
+       while (--i >= 0)
+               stmmac_free_rx_buffers(priv, i);
+       kfree(priv->tx_skbuff);
+err_tx_skbuff:
+       kfree(priv->tx_skbuff_dma);
+err_tx_skbuff_dma:
+       kfree(priv->rx_skbuff);
+err_rx_skbuff:
+       kfree(priv->rx_skbuff_dma);
+err_rx_skbuff_dma:
+       if (priv->extend_desc) {
+               dma_free_coherent(priv->device, priv->dma_tx_size *
+                                 sizeof(struct dma_extended_desc),
+                                 priv->dma_etx, priv->dma_tx_phy);
+               dma_free_coherent(priv->device, priv->dma_rx_size *
+                                 sizeof(struct dma_extended_desc),
+                                 priv->dma_erx, priv->dma_rx_phy);
+       } else {
+               dma_free_coherent(priv->device,
+                               priv->dma_tx_size * sizeof(struct dma_desc),
+                               priv->dma_tx, priv->dma_tx_phy);
+               dma_free_coherent(priv->device,
+                               priv->dma_rx_size * sizeof(struct dma_desc),
+                               priv->dma_rx, priv->dma_rx_phy);
+       }
+err_dma:
+       return ret;
 }
 
 static void dma_free_rx_skbufs(struct stmmac_priv *priv)
 {
        int i;
 
-       for (i = 0; i < priv->dma_rx_size; i++) {
-               if (priv->rx_skbuff[i]) {
-                       dma_unmap_single(priv->device, priv->rx_skbuff_dma[i],
-                                        priv->dma_buf_sz, DMA_FROM_DEVICE);
-                       dev_kfree_skb_any(priv->rx_skbuff[i]);
-               }
-               priv->rx_skbuff[i] = NULL;
-       }
+       for (i = 0; i < priv->dma_rx_size; i++)
+               stmmac_free_rx_buffers(priv, i);
 }
 
 static void dma_free_tx_skbufs(struct stmmac_priv *priv)
@@ -1157,8 +1224,7 @@ static void free_dma_desc_resources(struct stmmac_priv *priv)
  */
 static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
 {
-       if (likely(priv->plat->force_sf_dma_mode ||
-                  ((priv->plat->tx_coe) && (!priv->no_csum_insertion)))) {
+       if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) {
                /*
                 * In case of GMAC, SF mode can be enabled
                 * to perform the TX COE in HW. This depends on:
@@ -1560,12 +1626,17 @@ static int stmmac_open(struct net_device *dev)
        priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
        priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize);
        priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
-       init_dma_desc_rings(dev);
+
+       ret = init_dma_desc_rings(dev);
+       if (ret < 0) {
+               pr_err("%s: DMA descriptors initialization failed\n", __func__);
+               goto dma_desc_error;
+       }
 
        /* DMA initialization and SW reset */
        ret = stmmac_init_dma_engine(priv);
        if (ret < 0) {
-               pr_err("%s: DMA initialization failed\n", __func__);
+               pr_err("%s: DMA engine initialization failed\n", __func__);
                goto init_error;
        }
 
@@ -1672,6 +1743,7 @@ wolirq_error:
 
 init_error:
        free_dma_desc_resources(priv);
+dma_desc_error:
        if (priv->phydev)
                phy_disconnect(priv->phydev);
 phy_error:
index 03de76c7a177b6c9b54d571370e92d697c9a9ef6..da8be6e630961bac8478565741afe03b7b36a046 100644 (file)
@@ -109,9 +109,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
        const char *mac = NULL;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res)
-               return -ENODEV;
-
        addr = devm_ioremap_resource(dev, res);
        if (IS_ERR(addr))
                return PTR_ERR(addr);
index 0d43fa9ff9801ccbc19a74510f9aef952e22a3f8..7217ee5d62730acbc43de559abc2fe555e043155 100644 (file)
@@ -1239,7 +1239,7 @@ static int bigmac_sbus_probe(struct platform_device *op)
 
 static int bigmac_sbus_remove(struct platform_device *op)
 {
-       struct bigmac *bp = dev_get_drvdata(&op->dev);
+       struct bigmac *bp = platform_get_drvdata(op);
        struct device *parent = op->dev.parent;
        struct net_device *net_dev = bp->dev;
        struct platform_device *qec_op;
@@ -1259,8 +1259,6 @@ static int bigmac_sbus_remove(struct platform_device *op)
 
        free_netdev(net_dev);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 171f5b0809c4d1659cd26d8ba7255a915c1d8f70..c67e683a36e1e8edeac343e5b7fa56fa7547a926 100644 (file)
@@ -3231,7 +3231,7 @@ static int hme_sbus_probe(struct platform_device *op)
 
 static int hme_sbus_remove(struct platform_device *op)
 {
-       struct happy_meal *hp = dev_get_drvdata(&op->dev);
+       struct happy_meal *hp = platform_get_drvdata(op);
        struct net_device *net_dev = hp->dev;
 
        unregister_netdev(net_dev);
@@ -3250,8 +3250,6 @@ static int hme_sbus_remove(struct platform_device *op)
 
        free_netdev(net_dev);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 05a1674e204f772f84eb3d4ff70633942ba7c256..79974e31187ac19af63452a3a0c421a5ff2b7cf7 100644 (file)
@@ -34,9 +34,9 @@
 #include <linux/of_device.h>
 #include <linux/if_vlan.h>
 
-#include <linux/platform_data/cpsw.h>
 #include <linux/pinctrl/consumer.h>
 
+#include "cpsw.h"
 #include "cpsw_ale.h"
 #include "cpts.h"
 #include "davinci_cpdma.h"
@@ -82,6 +82,8 @@ do {                                                          \
 
 #define CPSW_VERSION_1         0x19010a
 #define CPSW_VERSION_2         0x19010c
+#define CPSW_VERSION_3         0x19010f
+#define CPSW_VERSION_4         0x190112
 
 #define HOST_PORT_NUM          0
 #define SLIVER_SIZE            0x40
@@ -91,6 +93,7 @@ do {                                                          \
 #define CPSW1_SLAVE_SIZE       0x040
 #define CPSW1_CPDMA_OFFSET     0x100
 #define CPSW1_STATERAM_OFFSET  0x200
+#define CPSW1_HW_STATS         0x400
 #define CPSW1_CPTS_OFFSET      0x500
 #define CPSW1_ALE_OFFSET       0x600
 #define CPSW1_SLIVER_OFFSET    0x700
@@ -99,6 +102,7 @@ do {                                                         \
 #define CPSW2_SLAVE_OFFSET     0x200
 #define CPSW2_SLAVE_SIZE       0x100
 #define CPSW2_CPDMA_OFFSET     0x800
+#define CPSW2_HW_STATS         0x900
 #define CPSW2_STATERAM_OFFSET  0xa00
 #define CPSW2_CPTS_OFFSET      0xc00
 #define CPSW2_ALE_OFFSET       0xd00
@@ -299,6 +303,44 @@ struct cpsw_sliver_regs {
        u32     rx_pri_map;
 };
 
+struct cpsw_hw_stats {
+       u32     rxgoodframes;
+       u32     rxbroadcastframes;
+       u32     rxmulticastframes;
+       u32     rxpauseframes;
+       u32     rxcrcerrors;
+       u32     rxaligncodeerrors;
+       u32     rxoversizedframes;
+       u32     rxjabberframes;
+       u32     rxundersizedframes;
+       u32     rxfragments;
+       u32     __pad_0[2];
+       u32     rxoctets;
+       u32     txgoodframes;
+       u32     txbroadcastframes;
+       u32     txmulticastframes;
+       u32     txpauseframes;
+       u32     txdeferredframes;
+       u32     txcollisionframes;
+       u32     txsinglecollframes;
+       u32     txmultcollframes;
+       u32     txexcessivecollisions;
+       u32     txlatecollisions;
+       u32     txunderrun;
+       u32     txcarriersenseerrors;
+       u32     txoctets;
+       u32     octetframes64;
+       u32     octetframes65t127;
+       u32     octetframes128t255;
+       u32     octetframes256t511;
+       u32     octetframes512t1023;
+       u32     octetframes1024tup;
+       u32     netoctets;
+       u32     rxsofoverruns;
+       u32     rxmofoverruns;
+       u32     rxdmaoverruns;
+};
+
 struct cpsw_slave {
        void __iomem                    *regs;
        struct cpsw_sliver_regs __iomem *sliver;
@@ -332,6 +374,7 @@ struct cpsw_priv {
        struct cpsw_platform_data       data;
        struct cpsw_ss_regs __iomem     *regs;
        struct cpsw_wr_regs __iomem     *wr_regs;
+       u8 __iomem                      *hw_stats;
        struct cpsw_host_regs __iomem   *host_port_regs;
        u32                             msg_enable;
        u32                             version;
@@ -354,6 +397,94 @@ struct cpsw_priv {
        u32 emac_port;
 };
 
+struct cpsw_stats {
+       char stat_string[ETH_GSTRING_LEN];
+       int type;
+       int sizeof_stat;
+       int stat_offset;
+};
+
+enum {
+       CPSW_STATS,
+       CPDMA_RX_STATS,
+       CPDMA_TX_STATS,
+};
+
+#define CPSW_STAT(m)           CPSW_STATS,                             \
+                               sizeof(((struct cpsw_hw_stats *)0)->m), \
+                               offsetof(struct cpsw_hw_stats, m)
+#define CPDMA_RX_STAT(m)       CPDMA_RX_STATS,                            \
+                               sizeof(((struct cpdma_chan_stats *)0)->m), \
+                               offsetof(struct cpdma_chan_stats, m)
+#define CPDMA_TX_STAT(m)       CPDMA_TX_STATS,                            \
+                               sizeof(((struct cpdma_chan_stats *)0)->m), \
+                               offsetof(struct cpdma_chan_stats, m)
+
+static const struct cpsw_stats cpsw_gstrings_stats[] = {
+       { "Good Rx Frames", CPSW_STAT(rxgoodframes) },
+       { "Broadcast Rx Frames", CPSW_STAT(rxbroadcastframes) },
+       { "Multicast Rx Frames", CPSW_STAT(rxmulticastframes) },
+       { "Pause Rx Frames", CPSW_STAT(rxpauseframes) },
+       { "Rx CRC Errors", CPSW_STAT(rxcrcerrors) },
+       { "Rx Align/Code Errors", CPSW_STAT(rxaligncodeerrors) },
+       { "Oversize Rx Frames", CPSW_STAT(rxoversizedframes) },
+       { "Rx Jabbers", CPSW_STAT(rxjabberframes) },
+       { "Undersize (Short) Rx Frames", CPSW_STAT(rxundersizedframes) },
+       { "Rx Fragments", CPSW_STAT(rxfragments) },
+       { "Rx Octets", CPSW_STAT(rxoctets) },
+       { "Good Tx Frames", CPSW_STAT(txgoodframes) },
+       { "Broadcast Tx Frames", CPSW_STAT(txbroadcastframes) },
+       { "Multicast Tx Frames", CPSW_STAT(txmulticastframes) },
+       { "Pause Tx Frames", CPSW_STAT(txpauseframes) },
+       { "Deferred Tx Frames", CPSW_STAT(txdeferredframes) },
+       { "Collisions", CPSW_STAT(txcollisionframes) },
+       { "Single Collision Tx Frames", CPSW_STAT(txsinglecollframes) },
+       { "Multiple Collision Tx Frames", CPSW_STAT(txmultcollframes) },
+       { "Excessive Collisions", CPSW_STAT(txexcessivecollisions) },
+       { "Late Collisions", CPSW_STAT(txlatecollisions) },
+       { "Tx Underrun", CPSW_STAT(txunderrun) },
+       { "Carrier Sense Errors", CPSW_STAT(txcarriersenseerrors) },
+       { "Tx Octets", CPSW_STAT(txoctets) },
+       { "Rx + Tx 64 Octet Frames", CPSW_STAT(octetframes64) },
+       { "Rx + Tx 65-127 Octet Frames", CPSW_STAT(octetframes65t127) },
+       { "Rx + Tx 128-255 Octet Frames", CPSW_STAT(octetframes128t255) },
+       { "Rx + Tx 256-511 Octet Frames", CPSW_STAT(octetframes256t511) },
+       { "Rx + Tx 512-1023 Octet Frames", CPSW_STAT(octetframes512t1023) },
+       { "Rx + Tx 1024-Up Octet Frames", CPSW_STAT(octetframes1024tup) },
+       { "Net Octets", CPSW_STAT(netoctets) },
+       { "Rx Start of Frame Overruns", CPSW_STAT(rxsofoverruns) },
+       { "Rx Middle of Frame Overruns", CPSW_STAT(rxmofoverruns) },
+       { "Rx DMA Overruns", CPSW_STAT(rxdmaoverruns) },
+       { "Rx DMA chan: head_enqueue", CPDMA_RX_STAT(head_enqueue) },
+       { "Rx DMA chan: tail_enqueue", CPDMA_RX_STAT(tail_enqueue) },
+       { "Rx DMA chan: pad_enqueue", CPDMA_RX_STAT(pad_enqueue) },
+       { "Rx DMA chan: misqueued", CPDMA_RX_STAT(misqueued) },
+       { "Rx DMA chan: desc_alloc_fail", CPDMA_RX_STAT(desc_alloc_fail) },
+       { "Rx DMA chan: pad_alloc_fail", CPDMA_RX_STAT(pad_alloc_fail) },
+       { "Rx DMA chan: runt_receive_buf", CPDMA_RX_STAT(runt_receive_buff) },
+       { "Rx DMA chan: runt_transmit_buf", CPDMA_RX_STAT(runt_transmit_buff) },
+       { "Rx DMA chan: empty_dequeue", CPDMA_RX_STAT(empty_dequeue) },
+       { "Rx DMA chan: busy_dequeue", CPDMA_RX_STAT(busy_dequeue) },
+       { "Rx DMA chan: good_dequeue", CPDMA_RX_STAT(good_dequeue) },
+       { "Rx DMA chan: requeue", CPDMA_RX_STAT(requeue) },
+       { "Rx DMA chan: teardown_dequeue", CPDMA_RX_STAT(teardown_dequeue) },
+       { "Tx DMA chan: head_enqueue", CPDMA_TX_STAT(head_enqueue) },
+       { "Tx DMA chan: tail_enqueue", CPDMA_TX_STAT(tail_enqueue) },
+       { "Tx DMA chan: pad_enqueue", CPDMA_TX_STAT(pad_enqueue) },
+       { "Tx DMA chan: misqueued", CPDMA_TX_STAT(misqueued) },
+       { "Tx DMA chan: desc_alloc_fail", CPDMA_TX_STAT(desc_alloc_fail) },
+       { "Tx DMA chan: pad_alloc_fail", CPDMA_TX_STAT(pad_alloc_fail) },
+       { "Tx DMA chan: runt_receive_buf", CPDMA_TX_STAT(runt_receive_buff) },
+       { "Tx DMA chan: runt_transmit_buf", CPDMA_TX_STAT(runt_transmit_buff) },
+       { "Tx DMA chan: empty_dequeue", CPDMA_TX_STAT(empty_dequeue) },
+       { "Tx DMA chan: busy_dequeue", CPDMA_TX_STAT(busy_dequeue) },
+       { "Tx DMA chan: good_dequeue", CPDMA_TX_STAT(good_dequeue) },
+       { "Tx DMA chan: requeue", CPDMA_TX_STAT(requeue) },
+       { "Tx DMA chan: teardown_dequeue", CPDMA_TX_STAT(teardown_dequeue) },
+};
+
+#define CPSW_STATS_LEN ARRAY_SIZE(cpsw_gstrings_stats)
+
 #define napi_to_priv(napi)     container_of(napi, struct cpsw_priv, napi)
 #define for_each_slave(priv, func, arg...)                             \
        do {                                                            \
@@ -723,6 +854,69 @@ static int cpsw_set_coalesce(struct net_device *ndev,
        return 0;
 }
 
+static int cpsw_get_sset_count(struct net_device *ndev, int sset)
+{
+       switch (sset) {
+       case ETH_SS_STATS:
+               return CPSW_STATS_LEN;
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+static void cpsw_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
+{
+       u8 *p = data;
+       int i;
+
+       switch (stringset) {
+       case ETH_SS_STATS:
+               for (i = 0; i < CPSW_STATS_LEN; i++) {
+                       memcpy(p, cpsw_gstrings_stats[i].stat_string,
+                              ETH_GSTRING_LEN);
+                       p += ETH_GSTRING_LEN;
+               }
+               break;
+       }
+}
+
+static void cpsw_get_ethtool_stats(struct net_device *ndev,
+                                   struct ethtool_stats *stats, u64 *data)
+{
+       struct cpsw_priv *priv = netdev_priv(ndev);
+       struct cpdma_chan_stats rx_stats;
+       struct cpdma_chan_stats tx_stats;
+       u32 val;
+       u8 *p;
+       int i;
+
+       /* Collect Davinci CPDMA stats for Rx and Tx Channel */
+       cpdma_chan_get_stats(priv->rxch, &rx_stats);
+       cpdma_chan_get_stats(priv->txch, &tx_stats);
+
+       for (i = 0; i < CPSW_STATS_LEN; i++) {
+               switch (cpsw_gstrings_stats[i].type) {
+               case CPSW_STATS:
+                       val = readl(priv->hw_stats +
+                                   cpsw_gstrings_stats[i].stat_offset);
+                       data[i] = val;
+                       break;
+
+               case CPDMA_RX_STATS:
+                       p = (u8 *)&rx_stats +
+                               cpsw_gstrings_stats[i].stat_offset;
+                       data[i] = *(u32 *)p;
+                       break;
+
+               case CPDMA_TX_STATS:
+                       p = (u8 *)&tx_stats +
+                               cpsw_gstrings_stats[i].stat_offset;
+                       data[i] = *(u32 *)p;
+                       break;
+               }
+       }
+}
+
 static inline int __show_stat(char *buf, int maxlen, const char *name, u32 val)
 {
        static char *leader = "........................................";
@@ -799,6 +993,8 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
                slave_write(slave, TX_PRIORITY_MAPPING, CPSW1_TX_PRI_MAP);
                break;
        case CPSW_VERSION_2:
+       case CPSW_VERSION_3:
+       case CPSW_VERSION_4:
                slave_write(slave, TX_PRIORITY_MAPPING, CPSW2_TX_PRI_MAP);
                break;
        }
@@ -1232,6 +1428,33 @@ static void cpsw_ndo_tx_timeout(struct net_device *ndev)
 
 }
 
+static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)
+{
+       struct cpsw_priv *priv = netdev_priv(ndev);
+       struct sockaddr *addr = (struct sockaddr *)p;
+       int flags = 0;
+       u16 vid = 0;
+
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+
+       if (priv->data.dual_emac) {
+               vid = priv->slaves[priv->emac_port].port_vlan;
+               flags = ALE_VLAN;
+       }
+
+       cpsw_ale_del_ucast(priv->ale, priv->mac_addr, priv->host_port,
+                          flags, vid);
+       cpsw_ale_add_ucast(priv->ale, addr->sa_data, priv->host_port,
+                          flags, vid);
+
+       memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN);
+       memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
+       for_each_slave(priv, cpsw_set_slave_mac, priv);
+
+       return 0;
+}
+
 static struct net_device_stats *cpsw_ndo_get_stats(struct net_device *ndev)
 {
        struct cpsw_priv *priv = netdev_priv(ndev);
@@ -1326,6 +1549,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
        .ndo_stop               = cpsw_ndo_stop,
        .ndo_start_xmit         = cpsw_ndo_start_xmit,
        .ndo_change_rx_flags    = cpsw_ndo_change_rx_flags,
+       .ndo_set_mac_address    = cpsw_ndo_set_mac_address,
        .ndo_do_ioctl           = cpsw_ndo_ioctl,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_change_mtu         = eth_change_mtu,
@@ -1416,6 +1640,29 @@ static int cpsw_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
                return -EOPNOTSUPP;
 }
 
+static void cpsw_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
+{
+       struct cpsw_priv *priv = netdev_priv(ndev);
+       int slave_no = cpsw_slave_index(priv);
+
+       wol->supported = 0;
+       wol->wolopts = 0;
+
+       if (priv->slaves[slave_no].phy)
+               phy_ethtool_get_wol(priv->slaves[slave_no].phy, wol);
+}
+
+static int cpsw_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
+{
+       struct cpsw_priv *priv = netdev_priv(ndev);
+       int slave_no = cpsw_slave_index(priv);
+
+       if (priv->slaves[slave_no].phy)
+               return phy_ethtool_set_wol(priv->slaves[slave_no].phy, wol);
+       else
+               return -EOPNOTSUPP;
+}
+
 static const struct ethtool_ops cpsw_ethtool_ops = {
        .get_drvinfo    = cpsw_get_drvinfo,
        .get_msglevel   = cpsw_get_msglevel,
@@ -1426,6 +1673,11 @@ static const struct ethtool_ops cpsw_ethtool_ops = {
        .set_settings   = cpsw_set_settings,
        .get_coalesce   = cpsw_get_coalesce,
        .set_coalesce   = cpsw_set_coalesce,
+       .get_sset_count         = cpsw_get_sset_count,
+       .get_strings            = cpsw_get_strings,
+       .get_ethtool_stats      = cpsw_get_ethtool_stats,
+       .get_wol        = cpsw_get_wol,
+       .set_wol        = cpsw_set_wol,
 };
 
 static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv,
@@ -1623,6 +1875,7 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
        priv_sl2->host_port = priv->host_port;
        priv_sl2->host_port_regs = priv->host_port_regs;
        priv_sl2->wr_regs = priv->wr_regs;
+       priv_sl2->hw_stats = priv->hw_stats;
        priv_sl2->dma = priv->dma;
        priv_sl2->txch = priv->txch;
        priv_sl2->rxch = priv->rxch;
@@ -1780,7 +2033,8 @@ static int cpsw_probe(struct platform_device *pdev)
        switch (priv->version) {
        case CPSW_VERSION_1:
                priv->host_port_regs = ss_regs + CPSW1_HOST_PORT_OFFSET;
-               priv->cpts->reg       = ss_regs + CPSW1_CPTS_OFFSET;
+               priv->cpts->reg      = ss_regs + CPSW1_CPTS_OFFSET;
+               priv->hw_stats       = ss_regs + CPSW1_HW_STATS;
                dma_params.dmaregs   = ss_regs + CPSW1_CPDMA_OFFSET;
                dma_params.txhdp     = ss_regs + CPSW1_STATERAM_OFFSET;
                ale_params.ale_regs  = ss_regs + CPSW1_ALE_OFFSET;
@@ -1790,8 +2044,11 @@ static int cpsw_probe(struct platform_device *pdev)
                dma_params.desc_mem_phys = 0;
                break;
        case CPSW_VERSION_2:
+       case CPSW_VERSION_3:
+       case CPSW_VERSION_4:
                priv->host_port_regs = ss_regs + CPSW2_HOST_PORT_OFFSET;
-               priv->cpts->reg       = ss_regs + CPSW2_CPTS_OFFSET;
+               priv->cpts->reg      = ss_regs + CPSW2_CPTS_OFFSET;
+               priv->hw_stats       = ss_regs + CPSW2_HW_STATS;
                dma_params.dmaregs   = ss_regs + CPSW2_CPDMA_OFFSET;
                dma_params.txhdp     = ss_regs + CPSW2_STATERAM_OFFSET;
                ale_params.ale_regs  = ss_regs + CPSW2_ALE_OFFSET;
@@ -1867,7 +2124,7 @@ static int cpsw_probe(struct platform_device *pdev)
 
        while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
                for (i = res->start; i <= res->end; i++) {
-                       if (request_irq(i, cpsw_interrupt, IRQF_DISABLED,
+                       if (request_irq(i, cpsw_interrupt, 0,
                                        dev_name(&pdev->dev), priv)) {
                                dev_err(priv->dev, "error attaching irq\n");
                                goto clean_ale_ret;
diff --git a/drivers/net/ethernet/ti/cpsw.h b/drivers/net/ethernet/ti/cpsw.h
new file mode 100644 (file)
index 0000000..eb3e101
--- /dev/null
@@ -0,0 +1,42 @@
+/* Texas Instruments Ethernet Switch Driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef __CPSW_H__
+#define __CPSW_H__
+
+#include <linux/if_ether.h>
+
+struct cpsw_slave_data {
+       char            phy_id[MII_BUS_ID_SIZE];
+       int             phy_if;
+       u8              mac_addr[ETH_ALEN];
+       u16             dual_emac_res_vlan;     /* Reserved VLAN for DualEMAC */
+};
+
+struct cpsw_platform_data {
+       struct cpsw_slave_data  *slave_data;
+       u32     ss_reg_ofs;     /* Subsystem control register offset */
+       u32     channels;       /* number of cpdma channels (symmetric) */
+       u32     slaves;         /* number of slave cpgmac ports */
+       u32     active_slave; /* time stamping, ethtool and SIOCGMIIPHY slave */
+       u32     cpts_clock_mult;  /* convert input clock ticks to nanoseconds */
+       u32     cpts_clock_shift; /* convert input clock ticks to nanoseconds */
+       u32     ale_entries;    /* ale table size */
+       u32     bd_ram_size;  /*buffer descriptor ram size */
+       u32     rx_descs;       /* Number of Rx Descriptios */
+       u32     mac_control;    /* Mac control register */
+       u16     default_vlan;   /* Def VLAN for ALE lookup in VLAN aware mode*/
+       bool    dual_emac;      /* Enable Dual EMAC mode */
+};
+
+#endif /* __CPSW_H__ */
index 031ebc81b50cda491b72029cd4b8b33699c1573e..90a79462c869a075c1f95c68d2a30c18e9e31283 100644 (file)
@@ -591,6 +591,7 @@ int cpdma_chan_get_stats(struct cpdma_chan *chan,
        spin_unlock_irqrestore(&chan->lock, flags);
        return 0;
 }
+EXPORT_SYMBOL_GPL(cpdma_chan_get_stats);
 
 int cpdma_chan_dump(struct cpdma_chan *chan)
 {
index 07b176bcf929706a7f3c3974e49becd346a2dc27..1a222bce4bd7bb4e84ce8a845a81c27440b4f863 100644 (file)
@@ -1568,8 +1568,7 @@ static int emac_dev_open(struct net_device *ndev)
        while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
                for (i = res->start; i <= res->end; i++) {
                        if (devm_request_irq(&priv->pdev->dev, i, emac_irq,
-                                            IRQF_DISABLED,
-                                            ndev->name, ndev))
+                                            0, ndev->name, ndev))
                                goto rollback;
                }
                k++;
index 16ddfc348062c4b3cf3b14d0aac1b7e2a2f70e6f..7f851438486379de0558e4dc5693d08fd2e1f0a9 100644 (file)
@@ -421,8 +421,7 @@ bail_out:
 
 static int davinci_mdio_remove(struct platform_device *pdev)
 {
-       struct device *dev = &pdev->dev;
-       struct davinci_mdio_data *data = dev_get_drvdata(dev);
+       struct davinci_mdio_data *data = platform_get_drvdata(pdev);
 
        if (data->bus) {
                mdiobus_unregister(data->bus);
@@ -434,8 +433,6 @@ static int davinci_mdio_remove(struct platform_device *pdev)
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
 
-       dev_set_drvdata(dev, NULL);
-
        kfree(data);
 
        return 0;
index 098b1c42b39368faef868e50fdbb3174a6ccf8d9..4083ba8839e1f2e73d1a1b872c4e4149a6db419e 100644 (file)
@@ -15,3 +15,14 @@ config TILE_NET
 
          To compile this driver as a module, choose M here: the module
          will be called tile_net.
+
+config PTP_1588_CLOCK_TILEGX
+        tristate "Tilera TILE-Gx mPIPE as PTP clock"
+        select PTP_1588_CLOCK
+        depends on TILE_NET
+        depends on TILEGX
+        ---help---
+          This driver adds support for using the mPIPE as a PTP
+          clock. This clock is only useful if your PTP programs are
+          getting hardware time stamps on the PTP Ethernet packets
+          using the SO_TIMESTAMPING API.
index f3c2d034b32c817530f3767de710de41c1d71b90..5d2a719fc68824c3b77ee5519406f4f9df31d42f 100644 (file)
 #include <linux/io.h>
 #include <linux/ctype.h>
 #include <linux/ip.h>
+#include <linux/ipv6.h>
 #include <linux/tcp.h>
+#include <linux/net_tstamp.h>
+#include <linux/ptp_clock_kernel.h>
 
 #include <asm/checksum.h>
 #include <asm/homecache.h>
@@ -76,6 +79,9 @@
 
 #define MAX_FRAGS (MAX_SKB_FRAGS + 1)
 
+/* The "kinds" of buffer stacks (small/large/jumbo). */
+#define MAX_KINDS 3
+
 /* Size of completions data to allocate.
  * ISSUE: Probably more than needed since we don't use all the channels.
  */
@@ -130,29 +136,31 @@ struct tile_net_tx_wake {
 
 /* Info for a specific cpu. */
 struct tile_net_info {
-       /* The NAPI struct. */
-       struct napi_struct napi;
-       /* Packet queue. */
-       gxio_mpipe_iqueue_t iqueue;
        /* Our cpu. */
        int my_cpu;
-       /* True if iqueue is valid. */
-       bool has_iqueue;
-       /* NAPI flags. */
-       bool napi_added;
-       bool napi_enabled;
-       /* Number of small sk_buffs which must still be provided. */
-       unsigned int num_needed_small_buffers;
-       /* Number of large sk_buffs which must still be provided. */
-       unsigned int num_needed_large_buffers;
        /* A timer for handling egress completions. */
        struct hrtimer egress_timer;
        /* True if "egress_timer" is scheduled. */
        bool egress_timer_scheduled;
-       /* Comps for each egress channel. */
-       struct tile_net_comps *comps_for_echannel[TILE_NET_CHANNELS];
-       /* Transmit wake timer for each egress channel. */
-       struct tile_net_tx_wake tx_wake[TILE_NET_CHANNELS];
+       struct info_mpipe {
+               /* Packet queue. */
+               gxio_mpipe_iqueue_t iqueue;
+               /* The NAPI struct. */
+               struct napi_struct napi;
+               /* Number of buffers (by kind) which must still be provided. */
+               unsigned int num_needed_buffers[MAX_KINDS];
+               /* instance id. */
+               int instance;
+               /* True if iqueue is valid. */
+               bool has_iqueue;
+               /* NAPI flags. */
+               bool napi_added;
+               bool napi_enabled;
+               /* Comps for each egress channel. */
+               struct tile_net_comps *comps_for_echannel[TILE_NET_CHANNELS];
+               /* Transmit wake timer for each egress channel. */
+               struct tile_net_tx_wake tx_wake[TILE_NET_CHANNELS];
+       } mpipe[NR_MPIPE_MAX];
 };
 
 /* Info for egress on a particular egress channel. */
@@ -177,19 +185,67 @@ struct tile_net_priv {
        int loopify_channel;
        /* The egress channel (channel or loopify_channel). */
        int echannel;
-       /* Total stats. */
-       struct net_device_stats stats;
+       /* mPIPE instance, 0 or 1. */
+       int instance;
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       /* The timestamp config. */
+       struct hwtstamp_config stamp_cfg;
+#endif
 };
 
-/* Egress info, indexed by "priv->echannel" (lazily created as needed). */
-static struct tile_net_egress egress_for_echannel[TILE_NET_CHANNELS];
+static struct mpipe_data {
+       /* The ingress irq. */
+       int ingress_irq;
 
-/* Devices currently associated with each channel.
- * NOTE: The array entry can become NULL after ifconfig down, but
- * we do not free the underlying net_device structures, so it is
- * safe to use a pointer after reading it from this array.
- */
-static struct net_device *tile_net_devs_for_channel[TILE_NET_CHANNELS];
+       /* The "context" for all devices. */
+       gxio_mpipe_context_t context;
+
+       /* Egress info, indexed by "priv->echannel"
+        * (lazily created as needed).
+        */
+       struct tile_net_egress
+       egress_for_echannel[TILE_NET_CHANNELS];
+
+       /* Devices currently associated with each channel.
+        * NOTE: The array entry can become NULL after ifconfig down, but
+        * we do not free the underlying net_device structures, so it is
+        * safe to use a pointer after reading it from this array.
+        */
+       struct net_device
+       *tile_net_devs_for_channel[TILE_NET_CHANNELS];
+
+       /* The actual memory allocated for the buffer stacks. */
+       void *buffer_stack_vas[MAX_KINDS];
+
+       /* The amount of memory allocated for each buffer stack. */
+       size_t buffer_stack_bytes[MAX_KINDS];
+
+       /* The first buffer stack index
+        * (small = +0, large = +1, jumbo = +2).
+        */
+       int first_buffer_stack;
+
+       /* The buckets. */
+       int first_bucket;
+       int num_buckets;
+
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       /* PTP-specific data. */
+       struct ptp_clock *ptp_clock;
+       struct ptp_clock_info caps;
+
+       /* Lock for ptp accessors. */
+       struct mutex ptp_lock;
+#endif
+
+} mpipe_data[NR_MPIPE_MAX] = {
+       [0 ... (NR_MPIPE_MAX - 1)] {
+               .ingress_irq = -1,
+               .first_buffer_stack = -1,
+               .first_bucket = -1,
+               .num_buckets = 1
+       }
+};
 
 /* A mutex for "tile_net_devs_for_channel". */
 static DEFINE_MUTEX(tile_net_devs_for_channel_mutex);
@@ -197,34 +253,17 @@ static DEFINE_MUTEX(tile_net_devs_for_channel_mutex);
 /* The per-cpu info. */
 static DEFINE_PER_CPU(struct tile_net_info, per_cpu_info);
 
-/* The "context" for all devices. */
-static gxio_mpipe_context_t context;
 
-/* Buffer sizes and mpipe enum codes for buffer stacks.
+/* The buffer size enums for each buffer stack.
  * See arch/tile/include/gxio/mpipe.h for the set of possible values.
+ * We avoid the "10384" size because it can induce "false chaining"
+ * on "cut-through" jumbo packets.
  */
-#define BUFFER_SIZE_SMALL_ENUM GXIO_MPIPE_BUFFER_SIZE_128
-#define BUFFER_SIZE_SMALL 128
-#define BUFFER_SIZE_LARGE_ENUM GXIO_MPIPE_BUFFER_SIZE_1664
-#define BUFFER_SIZE_LARGE 1664
-
-/* The small/large "buffer stacks". */
-static int small_buffer_stack = -1;
-static int large_buffer_stack = -1;
-
-/* Amount of memory allocated for each buffer stack. */
-static size_t buffer_stack_size;
-
-/* The actual memory allocated for the buffer stacks. */
-static void *small_buffer_stack_va;
-static void *large_buffer_stack_va;
-
-/* The buckets. */
-static int first_bucket = -1;
-static int num_buckets = 1;
-
-/* The ingress irq. */
-static int ingress_irq = -1;
+static gxio_mpipe_buffer_size_enum_t buffer_size_enums[MAX_KINDS] = {
+       GXIO_MPIPE_BUFFER_SIZE_128,
+       GXIO_MPIPE_BUFFER_SIZE_1664,
+       GXIO_MPIPE_BUFFER_SIZE_16384
+};
 
 /* Text value of tile_net.cpus if passed as a module parameter. */
 static char *network_cpus_string;
@@ -232,11 +271,21 @@ static char *network_cpus_string;
 /* The actual cpus in "network_cpus". */
 static struct cpumask network_cpus_map;
 
-/* If "loopify=LINK" was specified, this is "LINK". */
+/* If "tile_net.loopify=LINK" was specified, this is "LINK". */
 static char *loopify_link_name;
 
-/* If "tile_net.custom" was specified, this is non-NULL. */
-static char *custom_str;
+/* If "tile_net.custom" was specified, this is true. */
+static bool custom_flag;
+
+/* If "tile_net.jumbo=NUM" was specified, this is "NUM". */
+static uint jumbo_num;
+
+/* Obtain mpipe instance from struct tile_net_priv given struct net_device. */
+static inline int mpipe_instance(struct net_device *dev)
+{
+       struct tile_net_priv *priv = netdev_priv(dev);
+       return priv->instance;
+}
 
 /* The "tile_net.cpus" argument specifies the cpus that are dedicated
  * to handle ingress packets.
@@ -289,9 +338,15 @@ MODULE_PARM_DESC(loopify, "name the device to use loop0/1 for ingress/egress");
 /* The "tile_net.custom" argument causes us to ignore the "conventional"
  * classifier metadata, in particular, the "l2_offset".
  */
-module_param_named(custom, custom_str, charp, 0444);
+module_param_named(custom, custom_flag, bool, 0444);
 MODULE_PARM_DESC(custom, "indicates a (heavily) customized classifier");
 
+/* The "tile_net.jumbo" argument causes us to support "jumbo" packets,
+ * and to allocate the given number of "jumbo" buffers.
+ */
+module_param_named(jumbo, jumbo_num, uint, 0444);
+MODULE_PARM_DESC(jumbo, "the number of buffers to support jumbo packets");
+
 /* Atomically update a statistics field.
  * Note that on TILE-Gx, this operation is fire-and-forget on the
  * issuing core (single-cycle dispatch) and takes only a few cycles
@@ -305,15 +360,16 @@ static void tile_net_stats_add(unsigned long value, unsigned long *field)
 }
 
 /* Allocate and push a buffer. */
-static bool tile_net_provide_buffer(bool small)
+static bool tile_net_provide_buffer(int instance, int kind)
 {
-       int stack = small ? small_buffer_stack : large_buffer_stack;
+       struct mpipe_data *md = &mpipe_data[instance];
+       gxio_mpipe_buffer_size_enum_t bse = buffer_size_enums[kind];
+       size_t bs = gxio_mpipe_buffer_size_enum_to_buffer_size(bse);
        const unsigned long buffer_alignment = 128;
        struct sk_buff *skb;
        int len;
 
-       len = sizeof(struct sk_buff **) + buffer_alignment;
-       len += (small ? BUFFER_SIZE_SMALL : BUFFER_SIZE_LARGE);
+       len = sizeof(struct sk_buff **) + buffer_alignment + bs;
        skb = dev_alloc_skb(len);
        if (skb == NULL)
                return false;
@@ -328,7 +384,7 @@ static bool tile_net_provide_buffer(bool small)
        /* Make sure "skb" and the back-pointer have been flushed. */
        wmb();
 
-       gxio_mpipe_push_buffer(&context, stack,
+       gxio_mpipe_push_buffer(&md->context, md->first_buffer_stack + kind,
                               (void *)va_to_tile_io_addr(skb->data));
 
        return true;
@@ -354,11 +410,14 @@ static struct sk_buff *mpipe_buf_to_skb(void *va)
        return skb;
 }
 
-static void tile_net_pop_all_buffers(int stack)
+static void tile_net_pop_all_buffers(int instance, int stack)
 {
+       struct mpipe_data *md = &mpipe_data[instance];
+
        for (;;) {
                tile_io_addr_t addr =
-                       (tile_io_addr_t)gxio_mpipe_pop_buffer(&context, stack);
+                       (tile_io_addr_t)gxio_mpipe_pop_buffer(&md->context,
+                                                             stack);
                if (addr == 0)
                        break;
                dev_kfree_skb_irq(mpipe_buf_to_skb(tile_io_addr_to_va(addr)));
@@ -369,24 +428,111 @@ static void tile_net_pop_all_buffers(int stack)
 static void tile_net_provide_needed_buffers(void)
 {
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
+       int instance, kind;
+       for (instance = 0; instance < NR_MPIPE_MAX &&
+                    info->mpipe[instance].has_iqueue; instance++)      {
+               for (kind = 0; kind < MAX_KINDS; kind++) {
+                       while (info->mpipe[instance].num_needed_buffers[kind]
+                              != 0) {
+                               if (!tile_net_provide_buffer(instance, kind)) {
+                                       pr_notice("Tile %d still needs"
+                                                 " some buffers\n",
+                                                 info->my_cpu);
+                                       return;
+                               }
+                               info->mpipe[instance].
+                                       num_needed_buffers[kind]--;
+                       }
+               }
+       }
+}
 
-       while (info->num_needed_small_buffers != 0) {
-               if (!tile_net_provide_buffer(true))
-                       goto oops;
-               info->num_needed_small_buffers--;
+/* Get RX timestamp, and store it in the skb. */
+static void tile_rx_timestamp(struct tile_net_priv *priv, struct sk_buff *skb,
+                             gxio_mpipe_idesc_t *idesc)
+{
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       if (unlikely(priv->stamp_cfg.rx_filter != HWTSTAMP_FILTER_NONE)) {
+               struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
+               memset(shhwtstamps, 0, sizeof(*shhwtstamps));
+               shhwtstamps->hwtstamp = ktime_set(idesc->time_stamp_sec,
+                                                 idesc->time_stamp_ns);
        }
+#endif
+}
 
-       while (info->num_needed_large_buffers != 0) {
-               if (!tile_net_provide_buffer(false))
-                       goto oops;
-               info->num_needed_large_buffers--;
+/* Get TX timestamp, and store it in the skb. */
+static void tile_tx_timestamp(struct sk_buff *skb, int instance)
+{
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       struct skb_shared_info *shtx = skb_shinfo(skb);
+       if (unlikely((shtx->tx_flags & SKBTX_HW_TSTAMP) != 0)) {
+               struct mpipe_data *md = &mpipe_data[instance];
+               struct skb_shared_hwtstamps shhwtstamps;
+               struct timespec ts;
+
+               shtx->tx_flags |= SKBTX_IN_PROGRESS;
+               gxio_mpipe_get_timestamp(&md->context, &ts);
+               memset(&shhwtstamps, 0, sizeof(shhwtstamps));
+               shhwtstamps.hwtstamp = ktime_set(ts.tv_sec, ts.tv_nsec);
+               skb_tstamp_tx(skb, &shhwtstamps);
        }
+#endif
+}
 
-       return;
+/* Use ioctl() to enable or disable TX or RX timestamping. */
+static int tile_hwtstamp_ioctl(struct net_device *dev, struct ifreq *rq,
+                              int cmd)
+{
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       struct hwtstamp_config config;
+       struct tile_net_priv *priv = netdev_priv(dev);
 
-oops:
-       /* Add a description to the page allocation failure dump. */
-       pr_notice("Tile %d still needs some buffers\n", info->my_cpu);
+       if (copy_from_user(&config, rq->ifr_data, sizeof(config)))
+               return -EFAULT;
+
+       if (config.flags)  /* reserved for future extensions */
+               return -EINVAL;
+
+       switch (config.tx_type) {
+       case HWTSTAMP_TX_OFF:
+       case HWTSTAMP_TX_ON:
+               break;
+       default:
+               return -ERANGE;
+       }
+
+       switch (config.rx_filter) {
+       case HWTSTAMP_FILTER_NONE:
+               break;
+       case HWTSTAMP_FILTER_ALL:
+       case HWTSTAMP_FILTER_SOME:
+       case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
+       case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
+       case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+       case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
+       case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
+       case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
+       case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
+       case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
+       case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
+       case HWTSTAMP_FILTER_PTP_V2_EVENT:
+       case HWTSTAMP_FILTER_PTP_V2_SYNC:
+       case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
+               config.rx_filter = HWTSTAMP_FILTER_ALL;
+               break;
+       default:
+               return -ERANGE;
+       }
+
+       if (copy_to_user(rq->ifr_data, &config, sizeof(config)))
+               return -EFAULT;
+
+       priv->stamp_cfg = config;
+       return 0;
+#else
+       return -EOPNOTSUPP;
+#endif
 }
 
 static inline bool filter_packet(struct net_device *dev, void *buf)
@@ -409,6 +555,7 @@ static void tile_net_receive_skb(struct net_device *dev, struct sk_buff *skb,
 {
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
        struct tile_net_priv *priv = netdev_priv(dev);
+       int instance = priv->instance;
 
        /* Encode the actual packet length. */
        skb_put(skb, len);
@@ -419,47 +566,52 @@ static void tile_net_receive_skb(struct net_device *dev, struct sk_buff *skb,
        if (idesc->cs && idesc->csum_seed_val == 0xFFFF)
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-       netif_receive_skb(skb);
+       /* Get RX timestamp from idesc. */
+       tile_rx_timestamp(priv, skb, idesc);
+
+       napi_gro_receive(&info->mpipe[instance].napi, skb);
 
        /* Update stats. */
-       tile_net_stats_add(1, &priv->stats.rx_packets);
-       tile_net_stats_add(len, &priv->stats.rx_bytes);
+       tile_net_stats_add(1, &dev->stats.rx_packets);
+       tile_net_stats_add(len, &dev->stats.rx_bytes);
 
        /* Need a new buffer. */
-       if (idesc->size == BUFFER_SIZE_SMALL_ENUM)
-               info->num_needed_small_buffers++;
+       if (idesc->size == buffer_size_enums[0])
+               info->mpipe[instance].num_needed_buffers[0]++;
+       else if (idesc->size == buffer_size_enums[1])
+               info->mpipe[instance].num_needed_buffers[1]++;
        else
-               info->num_needed_large_buffers++;
+               info->mpipe[instance].num_needed_buffers[2]++;
 }
 
 /* Handle a packet.  Return true if "processed", false if "filtered". */
-static bool tile_net_handle_packet(gxio_mpipe_idesc_t *idesc)
+static bool tile_net_handle_packet(int instance, gxio_mpipe_idesc_t *idesc)
 {
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
-       struct net_device *dev = tile_net_devs_for_channel[idesc->channel];
+       struct mpipe_data *md = &mpipe_data[instance];
+       struct net_device *dev = md->tile_net_devs_for_channel[idesc->channel];
        uint8_t l2_offset;
        void *va;
        void *buf;
        unsigned long len;
        bool filter;
 
-       /* Drop packets for which no buffer was available.
-        * NOTE: This happens under heavy load.
+       /* Drop packets for which no buffer was available (which can
+        * happen under heavy load), or for which the me/tr/ce flags
+        * are set (which can happen for jumbo cut-through packets,
+        * or with a customized classifier).
         */
-       if (idesc->be) {
-               struct tile_net_priv *priv = netdev_priv(dev);
-               tile_net_stats_add(1, &priv->stats.rx_dropped);
-               gxio_mpipe_iqueue_consume(&info->iqueue, idesc);
-               if (net_ratelimit())
-                       pr_info("Dropping packet (insufficient buffers).\n");
-               return false;
+       if (idesc->be || idesc->me || idesc->tr || idesc->ce) {
+               if (dev)
+                       tile_net_stats_add(1, &dev->stats.rx_errors);
+               goto drop;
        }
 
        /* Get the "l2_offset", if allowed. */
-       l2_offset = custom_str ? 0 : gxio_mpipe_idesc_get_l2_offset(idesc);
+       l2_offset = custom_flag ? 0 : gxio_mpipe_idesc_get_l2_offset(idesc);
 
-       /* Get the raw buffer VA (includes "headroom"). */
-       va = tile_io_addr_to_va((unsigned long)(long)idesc->va);
+       /* Get the VA (including NET_IP_ALIGN bytes of "headroom"). */
+       va = tile_io_addr_to_va((unsigned long)idesc->va);
 
        /* Get the actual packet start/length. */
        buf = va + l2_offset;
@@ -470,7 +622,10 @@ static bool tile_net_handle_packet(gxio_mpipe_idesc_t *idesc)
 
        filter = filter_packet(dev, buf);
        if (filter) {
-               gxio_mpipe_iqueue_drop(&info->iqueue, idesc);
+               if (dev)
+                       tile_net_stats_add(1, &dev->stats.rx_dropped);
+drop:
+               gxio_mpipe_iqueue_drop(&info->mpipe[instance].iqueue, idesc);
        } else {
                struct sk_buff *skb = mpipe_buf_to_skb(va);
 
@@ -480,7 +635,7 @@ static bool tile_net_handle_packet(gxio_mpipe_idesc_t *idesc)
                tile_net_receive_skb(dev, skb, idesc, len);
        }
 
-       gxio_mpipe_iqueue_consume(&info->iqueue, idesc);
+       gxio_mpipe_iqueue_consume(&info->mpipe[instance].iqueue, idesc);
        return !filter;
 }
 
@@ -501,14 +656,20 @@ static int tile_net_poll(struct napi_struct *napi, int budget)
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
        unsigned int work = 0;
        gxio_mpipe_idesc_t *idesc;
-       int i, n;
-
-       /* Process packets. */
-       while ((n = gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc)) > 0) {
+       int instance, i, n;
+       struct mpipe_data *md;
+       struct info_mpipe *info_mpipe =
+               container_of(napi, struct info_mpipe, napi);
+
+       instance = info_mpipe->instance;
+       while ((n = gxio_mpipe_iqueue_try_peek(
+                       &info_mpipe->iqueue,
+                       &idesc)) > 0) {
                for (i = 0; i < n; i++) {
                        if (i == TILE_NET_BATCH)
                                goto done;
-                       if (tile_net_handle_packet(idesc + i)) {
+                       if (tile_net_handle_packet(instance,
+                                                  idesc + i)) {
                                if (++work >= budget)
                                        goto done;
                        }
@@ -516,14 +677,16 @@ static int tile_net_poll(struct napi_struct *napi, int budget)
        }
 
        /* There are no packets left. */
-       napi_complete(&info->napi);
+       napi_complete(&info_mpipe->napi);
 
+       md = &mpipe_data[instance];
        /* Re-enable hypervisor interrupts. */
-       gxio_mpipe_enable_notif_ring_interrupt(&context, info->iqueue.ring);
+       gxio_mpipe_enable_notif_ring_interrupt(
+               &md->context, info->mpipe[instance].iqueue.ring);
 
        /* HACK: Avoid the "rotting packet" problem. */
-       if (gxio_mpipe_iqueue_try_peek(&info->iqueue, &idesc) > 0)
-               napi_schedule(&info->napi);
+       if (gxio_mpipe_iqueue_try_peek(&info_mpipe->iqueue, &idesc) > 0)
+               napi_schedule(&info_mpipe->napi);
 
        /* ISSUE: Handle completions? */
 
@@ -533,11 +696,11 @@ done:
        return work;
 }
 
-/* Handle an ingress interrupt on the current cpu. */
-static irqreturn_t tile_net_handle_ingress_irq(int irq, void *unused)
+/* Handle an ingress interrupt from an instance on the current cpu. */
+static irqreturn_t tile_net_handle_ingress_irq(int irq, void *id)
 {
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
-       napi_schedule(&info->napi);
+       napi_schedule(&info->mpipe[(uint64_t)id].napi);
        return IRQ_HANDLED;
 }
 
@@ -579,7 +742,9 @@ static void tile_net_schedule_tx_wake_timer(struct net_device *dev,
 {
        struct tile_net_info *info = &per_cpu(per_cpu_info, tx_queue_idx);
        struct tile_net_priv *priv = netdev_priv(dev);
-       struct tile_net_tx_wake *tx_wake = &info->tx_wake[priv->echannel];
+       int instance = priv->instance;
+       struct tile_net_tx_wake *tx_wake =
+               &info->mpipe[instance].tx_wake[priv->echannel];
 
        hrtimer_start(&tx_wake->timer,
                      ktime_set(0, TX_TIMER_DELAY_USEC * 1000UL),
@@ -617,7 +782,7 @@ static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t)
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
        unsigned long irqflags;
        bool pending = false;
-       int i;
+       int i, instance;
 
        local_irq_save(irqflags);
 
@@ -625,13 +790,19 @@ static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t)
        info->egress_timer_scheduled = false;
 
        /* Free all possible comps for this tile. */
-       for (i = 0; i < TILE_NET_CHANNELS; i++) {
-               struct tile_net_egress *egress = &egress_for_echannel[i];
-               struct tile_net_comps *comps = info->comps_for_echannel[i];
-               if (comps->comp_last >= comps->comp_next)
-                       continue;
-               tile_net_free_comps(egress->equeue, comps, -1, true);
-               pending = pending || (comps->comp_last < comps->comp_next);
+       for (instance = 0; instance < NR_MPIPE_MAX &&
+                    info->mpipe[instance].has_iqueue; instance++) {
+               for (i = 0; i < TILE_NET_CHANNELS; i++) {
+                       struct tile_net_egress *egress =
+                               &mpipe_data[instance].egress_for_echannel[i];
+                       struct tile_net_comps *comps =
+                               info->mpipe[instance].comps_for_echannel[i];
+                       if (!egress || comps->comp_last >= comps->comp_next)
+                               continue;
+                       tile_net_free_comps(egress->equeue, comps, -1, true);
+                       pending = pending ||
+                               (comps->comp_last < comps->comp_next);
+               }
        }
 
        /* Reschedule timer if needed. */
@@ -643,37 +814,112 @@ static enum hrtimer_restart tile_net_handle_egress_timer(struct hrtimer *t)
        return HRTIMER_NORESTART;
 }
 
-/* Helper function for "tile_net_update()".
- * "dev" (i.e. arg) is the device being brought up or down,
- * or NULL if all devices are now down.
- */
-static void tile_net_update_cpu(void *arg)
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+
+/* PTP clock operations. */
+
+static int ptp_mpipe_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 {
-       struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
-       struct net_device *dev = arg;
+       int ret = 0;
+       struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);
+       mutex_lock(&md->ptp_lock);
+       if (gxio_mpipe_adjust_timestamp_freq(&md->context, ppb))
+               ret = -EINVAL;
+       mutex_unlock(&md->ptp_lock);
+       return ret;
+}
 
-       if (!info->has_iqueue)
-               return;
+static int ptp_mpipe_adjtime(struct ptp_clock_info *ptp, s64 delta)
+{
+       int ret = 0;
+       struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);
+       mutex_lock(&md->ptp_lock);
+       if (gxio_mpipe_adjust_timestamp(&md->context, delta))
+               ret = -EBUSY;
+       mutex_unlock(&md->ptp_lock);
+       return ret;
+}
 
-       if (dev != NULL) {
-               if (!info->napi_added) {
-                       netif_napi_add(dev, &info->napi,
-                                      tile_net_poll, TILE_NET_WEIGHT);
-                       info->napi_added = true;
-               }
-               if (!info->napi_enabled) {
-                       napi_enable(&info->napi);
-                       info->napi_enabled = true;
-               }
-               enable_percpu_irq(ingress_irq, 0);
-       } else {
-               disable_percpu_irq(ingress_irq);
-               if (info->napi_enabled) {
-                       napi_disable(&info->napi);
-                       info->napi_enabled = false;
-               }
-               /* FIXME: Drain the iqueue. */
-       }
+static int ptp_mpipe_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
+{
+       int ret = 0;
+       struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);
+       mutex_lock(&md->ptp_lock);
+       if (gxio_mpipe_get_timestamp(&md->context, ts))
+               ret = -EBUSY;
+       mutex_unlock(&md->ptp_lock);
+       return ret;
+}
+
+static int ptp_mpipe_settime(struct ptp_clock_info *ptp,
+                            const struct timespec *ts)
+{
+       int ret = 0;
+       struct mpipe_data *md = container_of(ptp, struct mpipe_data, caps);
+       mutex_lock(&md->ptp_lock);
+       if (gxio_mpipe_set_timestamp(&md->context, ts))
+               ret = -EBUSY;
+       mutex_unlock(&md->ptp_lock);
+       return ret;
+}
+
+static int ptp_mpipe_enable(struct ptp_clock_info *ptp,
+                           struct ptp_clock_request *request, int on)
+{
+       return -EOPNOTSUPP;
+}
+
+static struct ptp_clock_info ptp_mpipe_caps = {
+       .owner          = THIS_MODULE,
+       .name           = "mPIPE clock",
+       .max_adj        = 999999999,
+       .n_ext_ts       = 0,
+       .pps            = 0,
+       .adjfreq        = ptp_mpipe_adjfreq,
+       .adjtime        = ptp_mpipe_adjtime,
+       .gettime        = ptp_mpipe_gettime,
+       .settime        = ptp_mpipe_settime,
+       .enable         = ptp_mpipe_enable,
+};
+
+#endif /* CONFIG_PTP_1588_CLOCK_TILEGX */
+
+/* Sync mPIPE's timestamp up with Linux system time and register PTP clock. */
+static void register_ptp_clock(struct net_device *dev, struct mpipe_data *md)
+{
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       struct timespec ts;
+
+       getnstimeofday(&ts);
+       gxio_mpipe_set_timestamp(&md->context, &ts);
+
+       mutex_init(&md->ptp_lock);
+       md->caps = ptp_mpipe_caps;
+       md->ptp_clock = ptp_clock_register(&md->caps, NULL);
+       if (IS_ERR(md->ptp_clock))
+               netdev_err(dev, "ptp_clock_register failed %ld\n",
+                          PTR_ERR(md->ptp_clock));
+#endif
+}
+
+/* Initialize PTP fields in a new device. */
+static void init_ptp_dev(struct tile_net_priv *priv)
+{
+#ifdef CONFIG_PTP_1588_CLOCK_TILEGX
+       priv->stamp_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
+       priv->stamp_cfg.tx_type = HWTSTAMP_TX_OFF;
+#endif
+}
+
+/* Helper functions for "tile_net_update()". */
+static void enable_ingress_irq(void *irq)
+{
+       enable_percpu_irq((long)irq, 0);
+}
+
+static void disable_ingress_irq(void *irq)
+{
+       disable_percpu_irq((long)irq);
 }
 
 /* Helper function for tile_net_open() and tile_net_stop().
@@ -683,19 +929,22 @@ static int tile_net_update(struct net_device *dev)
 {
        static gxio_mpipe_rules_t rules;  /* too big to fit on the stack */
        bool saw_channel = false;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
        int channel;
        int rc;
        int cpu;
 
-       gxio_mpipe_rules_init(&rules, &context);
+       saw_channel = false;
+       gxio_mpipe_rules_init(&rules, &md->context);
 
        for (channel = 0; channel < TILE_NET_CHANNELS; channel++) {
-               if (tile_net_devs_for_channel[channel] == NULL)
+               if (md->tile_net_devs_for_channel[channel] == NULL)
                        continue;
                if (!saw_channel) {
                        saw_channel = true;
-                       gxio_mpipe_rules_begin(&rules, first_bucket,
-                                              num_buckets, NULL);
+                       gxio_mpipe_rules_begin(&rules, md->first_bucket,
+                                              md->num_buckets, NULL);
                        gxio_mpipe_rules_set_headroom(&rules, NET_IP_ALIGN);
                }
                gxio_mpipe_rules_add_channel(&rules, channel);
@@ -706,102 +955,150 @@ static int tile_net_update(struct net_device *dev)
         */
        rc = gxio_mpipe_rules_commit(&rules);
        if (rc != 0) {
-               netdev_warn(dev, "gxio_mpipe_rules_commit failed: %d\n", rc);
+               netdev_warn(dev, "gxio_mpipe_rules_commit: mpipe[%d] %d\n",
+                           instance, rc);
                return -EIO;
        }
 
-       /* Update all cpus, sequentially (to protect "netif_napi_add()"). */
-       for_each_online_cpu(cpu)
-               smp_call_function_single(cpu, tile_net_update_cpu,
-                                        (saw_channel ? dev : NULL), 1);
+       /* Update all cpus, sequentially (to protect "netif_napi_add()").
+        * We use on_each_cpu to handle the IPI mask or unmask.
+        */
+       if (!saw_channel)
+               on_each_cpu(disable_ingress_irq,
+                           (void *)(long)(md->ingress_irq), 1);
+       for_each_online_cpu(cpu) {
+               struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
+
+               if (!info->mpipe[instance].has_iqueue)
+                       continue;
+               if (saw_channel) {
+                       if (!info->mpipe[instance].napi_added) {
+                               netif_napi_add(dev, &info->mpipe[instance].napi,
+                                              tile_net_poll, TILE_NET_WEIGHT);
+                               info->mpipe[instance].napi_added = true;
+                       }
+                       if (!info->mpipe[instance].napi_enabled) {
+                               napi_enable(&info->mpipe[instance].napi);
+                               info->mpipe[instance].napi_enabled = true;
+                       }
+               } else {
+                       if (info->mpipe[instance].napi_enabled) {
+                               napi_disable(&info->mpipe[instance].napi);
+                               info->mpipe[instance].napi_enabled = false;
+                       }
+                       /* FIXME: Drain the iqueue. */
+               }
+       }
+       if (saw_channel)
+               on_each_cpu(enable_ingress_irq,
+                           (void *)(long)(md->ingress_irq), 1);
 
        /* HACK: Allow packets to flow in the simulator. */
        if (saw_channel)
-               sim_enable_mpipe_links(0, -1);
+               sim_enable_mpipe_links(instance, -1);
 
        return 0;
 }
 
-/* Allocate and initialize mpipe buffer stacks, and register them in
- * the mPIPE TLBs, for both small and large packet sizes.
- * This routine supports tile_net_init_mpipe(), below.
- */
-static int init_buffer_stacks(struct net_device *dev, int num_buffers)
+/* Initialize a buffer stack. */
+static int create_buffer_stack(struct net_device *dev,
+                              int kind, size_t num_buffers)
 {
        pte_t hash_pte = pte_set_home((pte_t) { 0 }, PAGE_HOME_HASH);
-       int rc;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
+       size_t needed = gxio_mpipe_calc_buffer_stack_bytes(num_buffers);
+       int stack_idx = md->first_buffer_stack + kind;
+       void *va;
+       int i, rc;
 
-       /* Compute stack bytes; we round up to 64KB and then use
-        * alloc_pages() so we get the required 64KB alignment as well.
+       /* Round up to 64KB and then use alloc_pages() so we get the
+        * required 64KB alignment.
         */
-       buffer_stack_size =
-               ALIGN(gxio_mpipe_calc_buffer_stack_bytes(num_buffers),
-                     64 * 1024);
+       md->buffer_stack_bytes[kind] =
+               ALIGN(needed, 64 * 1024);
 
-       /* Allocate two buffer stack indices. */
-       rc = gxio_mpipe_alloc_buffer_stacks(&context, 2, 0, 0);
-       if (rc < 0) {
-               netdev_err(dev, "gxio_mpipe_alloc_buffer_stacks failed: %d\n",
-                          rc);
-               return rc;
-       }
-       small_buffer_stack = rc;
-       large_buffer_stack = rc + 1;
-
-       /* Allocate the small memory stack. */
-       small_buffer_stack_va =
-               alloc_pages_exact(buffer_stack_size, GFP_KERNEL);
-       if (small_buffer_stack_va == NULL) {
+       va = alloc_pages_exact(md->buffer_stack_bytes[kind], GFP_KERNEL);
+       if (va == NULL) {
                netdev_err(dev,
-                          "Could not alloc %zd bytes for buffer stacks\n",
-                          buffer_stack_size);
+                          "Could not alloc %zd bytes for buffer stack %d\n",
+                          md->buffer_stack_bytes[kind], kind);
                return -ENOMEM;
        }
-       rc = gxio_mpipe_init_buffer_stack(&context, small_buffer_stack,
-                                         BUFFER_SIZE_SMALL_ENUM,
-                                         small_buffer_stack_va,
-                                         buffer_stack_size, 0);
+
+       /* Initialize the buffer stack. */
+       rc = gxio_mpipe_init_buffer_stack(&md->context, stack_idx,
+                                         buffer_size_enums[kind],  va,
+                                         md->buffer_stack_bytes[kind], 0);
        if (rc != 0) {
-               netdev_err(dev, "gxio_mpipe_init_buffer_stack: %d\n", rc);
+               netdev_err(dev, "gxio_mpipe_init_buffer_stack: mpipe[%d] %d\n",
+                          instance, rc);
+               free_pages_exact(va, md->buffer_stack_bytes[kind]);
                return rc;
        }
-       rc = gxio_mpipe_register_client_memory(&context, small_buffer_stack,
+
+       md->buffer_stack_vas[kind] = va;
+
+       rc = gxio_mpipe_register_client_memory(&md->context, stack_idx,
                                               hash_pte, 0);
        if (rc != 0) {
                netdev_err(dev,
-                          "gxio_mpipe_register_buffer_memory failed: %d\n",
-                          rc);
+                          "gxio_mpipe_register_client_memory: mpipe[%d] %d\n",
+                          instance, rc);
                return rc;
        }
 
-       /* Allocate the large buffer stack. */
-       large_buffer_stack_va =
-               alloc_pages_exact(buffer_stack_size, GFP_KERNEL);
-       if (large_buffer_stack_va == NULL) {
-               netdev_err(dev,
-                          "Could not alloc %zd bytes for buffer stacks\n",
-                          buffer_stack_size);
-               return -ENOMEM;
-       }
-       rc = gxio_mpipe_init_buffer_stack(&context, large_buffer_stack,
-                                         BUFFER_SIZE_LARGE_ENUM,
-                                         large_buffer_stack_va,
-                                         buffer_stack_size, 0);
-       if (rc != 0) {
-               netdev_err(dev, "gxio_mpipe_init_buffer_stack failed: %d\n",
-                          rc);
-               return rc;
+       /* Provide initial buffers. */
+       for (i = 0; i < num_buffers; i++) {
+               if (!tile_net_provide_buffer(instance, kind)) {
+                       netdev_err(dev, "Cannot allocate initial sk_bufs!\n");
+                       return -ENOMEM;
+               }
        }
-       rc = gxio_mpipe_register_client_memory(&context, large_buffer_stack,
-                                              hash_pte, 0);
-       if (rc != 0) {
+
+       return 0;
+}
+
+/* Allocate and initialize mpipe buffer stacks, and register them in
+ * the mPIPE TLBs, for small, large, and (possibly) jumbo packet sizes.
+ * This routine supports tile_net_init_mpipe(), below.
+ */
+static int init_buffer_stacks(struct net_device *dev,
+                             int network_cpus_count)
+{
+       int num_kinds = MAX_KINDS - (jumbo_num == 0);
+       size_t num_buffers;
+       int rc;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
+
+       /* Allocate the buffer stacks. */
+       rc = gxio_mpipe_alloc_buffer_stacks(&md->context, num_kinds, 0, 0);
+       if (rc < 0) {
                netdev_err(dev,
-                          "gxio_mpipe_register_buffer_memory failed: %d\n",
-                          rc);
+                          "gxio_mpipe_alloc_buffer_stacks: mpipe[%d] %d\n",
+                          instance, rc);
                return rc;
        }
+       md->first_buffer_stack = rc;
 
-       return 0;
+       /* Enough small/large buffers to (normally) avoid buffer errors. */
+       num_buffers =
+               network_cpus_count * (IQUEUE_ENTRIES + TILE_NET_BATCH);
+
+       /* Allocate the small memory stack. */
+       if (rc >= 0)
+               rc = create_buffer_stack(dev, 0, num_buffers);
+
+       /* Allocate the large buffer stack. */
+       if (rc >= 0)
+               rc = create_buffer_stack(dev, 1, num_buffers);
+
+       /* Allocate the jumbo buffer stack if needed. */
+       if (rc >= 0 && jumbo_num != 0)
+               rc = create_buffer_stack(dev, 2, jumbo_num);
+
+       return rc;
 }
 
 /* Allocate per-cpu resources (memory for completions and idescs).
@@ -812,6 +1109,8 @@ static int alloc_percpu_mpipe_resources(struct net_device *dev,
 {
        struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
        int order, i, rc;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
        struct page *page;
        void *addr;
 
@@ -826,7 +1125,7 @@ static int alloc_percpu_mpipe_resources(struct net_device *dev,
        addr = pfn_to_kaddr(page_to_pfn(page));
        memset(addr, 0, COMPS_SIZE);
        for (i = 0; i < TILE_NET_CHANNELS; i++)
-               info->comps_for_echannel[i] =
+               info->mpipe[instance].comps_for_echannel[i] =
                        addr + i * sizeof(struct tile_net_comps);
 
        /* If this is a network cpu, create an iqueue. */
@@ -840,14 +1139,15 @@ static int alloc_percpu_mpipe_resources(struct net_device *dev,
                        return -ENOMEM;
                }
                addr = pfn_to_kaddr(page_to_pfn(page));
-               rc = gxio_mpipe_iqueue_init(&info->iqueue, &context, ring++,
-                                           addr, NOTIF_RING_SIZE, 0);
+               rc = gxio_mpipe_iqueue_init(&info->mpipe[instance].iqueue,
+                                           &md->context, ring++, addr,
+                                           NOTIF_RING_SIZE, 0);
                if (rc < 0) {
                        netdev_err(dev,
                                   "gxio_mpipe_iqueue_init failed: %d\n", rc);
                        return rc;
                }
-               info->has_iqueue = true;
+               info->mpipe[instance].has_iqueue = true;
        }
 
        return ring;
@@ -860,40 +1160,41 @@ static int init_notif_group_and_buckets(struct net_device *dev,
                                        int ring, int network_cpus_count)
 {
        int group, rc;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
 
        /* Allocate one NotifGroup. */
-       rc = gxio_mpipe_alloc_notif_groups(&context, 1, 0, 0);
+       rc = gxio_mpipe_alloc_notif_groups(&md->context, 1, 0, 0);
        if (rc < 0) {
-               netdev_err(dev, "gxio_mpipe_alloc_notif_groups failed: %d\n",
-                          rc);
+               netdev_err(dev, "gxio_mpipe_alloc_notif_groups: mpipe[%d] %d\n",
+                          instance, rc);
                return rc;
        }
        group = rc;
 
        /* Initialize global num_buckets value. */
        if (network_cpus_count > 4)
-               num_buckets = 256;
+               md->num_buckets = 256;
        else if (network_cpus_count > 1)
-               num_buckets = 16;
+               md->num_buckets = 16;
 
        /* Allocate some buckets, and set global first_bucket value. */
-       rc = gxio_mpipe_alloc_buckets(&context, num_buckets, 0, 0);
+       rc = gxio_mpipe_alloc_buckets(&md->context, md->num_buckets, 0, 0);
        if (rc < 0) {
-               netdev_err(dev, "gxio_mpipe_alloc_buckets failed: %d\n", rc);
+               netdev_err(dev, "gxio_mpipe_alloc_buckets: mpipe[%d] %d\n",
+                          instance, rc);
                return rc;
        }
-       first_bucket = rc;
+       md->first_bucket = rc;
 
        /* Init group and buckets. */
        rc = gxio_mpipe_init_notif_group_and_buckets(
-               &context, group, ring, network_cpus_count,
-               first_bucket, num_buckets,
+               &md->context, group, ring, network_cpus_count,
+               md->first_bucket, md->num_buckets,
                GXIO_MPIPE_BUCKET_STICKY_FLOW_LOCALITY);
        if (rc != 0) {
-               netdev_err(
-                       dev,
-                       "gxio_mpipe_init_notif_group_and_buckets failed: %d\n",
-                       rc);
+               netdev_err(dev, "gxio_mpipe_init_notif_group_and_buckets: "
+                          "mpipe[%d] %d\n", instance, rc);
                return rc;
        }
 
@@ -907,30 +1208,39 @@ static int init_notif_group_and_buckets(struct net_device *dev,
  */
 static int tile_net_setup_interrupts(struct net_device *dev)
 {
-       int cpu, rc;
+       int cpu, rc, irq;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
+
+       irq = md->ingress_irq;
+       if (irq < 0) {
+               irq = create_irq();
+               if (irq < 0) {
+                       netdev_err(dev,
+                                  "create_irq failed: mpipe[%d] %d\n",
+                                  instance, irq);
+                       return irq;
+               }
+               tile_irq_activate(irq, TILE_IRQ_PERCPU);
 
-       rc = create_irq();
-       if (rc < 0) {
-               netdev_err(dev, "create_irq failed: %d\n", rc);
-               return rc;
-       }
-       ingress_irq = rc;
-       tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU);
-       rc = request_irq(ingress_irq, tile_net_handle_ingress_irq,
-                        0, "tile_net", NULL);
-       if (rc != 0) {
-               netdev_err(dev, "request_irq failed: %d\n", rc);
-               destroy_irq(ingress_irq);
-               ingress_irq = -1;
-               return rc;
+               rc = request_irq(irq, tile_net_handle_ingress_irq,
+                                0, "tile_net", (void *)((uint64_t)instance));
+
+               if (rc != 0) {
+                       netdev_err(dev, "request_irq failed: mpipe[%d] %d\n",
+                                  instance, rc);
+                       destroy_irq(irq);
+                       return rc;
+               }
+               md->ingress_irq = irq;
        }
 
        for_each_online_cpu(cpu) {
                struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
-               if (info->has_iqueue) {
-                       gxio_mpipe_request_notif_ring_interrupt(
-                               &context, cpu_x(cpu), cpu_y(cpu),
-                               KERNEL_PL, ingress_irq, info->iqueue.ring);
+               if (info->mpipe[instance].has_iqueue) {
+                       gxio_mpipe_request_notif_ring_interrupt(&md->context,
+                               cpu_x(cpu), cpu_y(cpu), KERNEL_PL, irq,
+                               info->mpipe[instance].iqueue.ring);
                }
        }
 
@@ -938,39 +1248,45 @@ static int tile_net_setup_interrupts(struct net_device *dev)
 }
 
 /* Undo any state set up partially by a failed call to tile_net_init_mpipe. */
-static void tile_net_init_mpipe_fail(void)
+static void tile_net_init_mpipe_fail(int instance)
 {
-       int cpu;
+       int kind, cpu;
+       struct mpipe_data *md = &mpipe_data[instance];
 
        /* Do cleanups that require the mpipe context first. */
-       if (small_buffer_stack >= 0)
-               tile_net_pop_all_buffers(small_buffer_stack);
-       if (large_buffer_stack >= 0)
-               tile_net_pop_all_buffers(large_buffer_stack);
+       for (kind = 0; kind < MAX_KINDS; kind++) {
+               if (md->buffer_stack_vas[kind] != NULL) {
+                       tile_net_pop_all_buffers(instance,
+                                                md->first_buffer_stack +
+                                                kind);
+               }
+       }
 
        /* Destroy mpipe context so the hardware no longer owns any memory. */
-       gxio_mpipe_destroy(&context);
+       gxio_mpipe_destroy(&md->context);
 
        for_each_online_cpu(cpu) {
                struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
-               free_pages((unsigned long)(info->comps_for_echannel[0]),
-                          get_order(COMPS_SIZE));
-               info->comps_for_echannel[0] = NULL;
-               free_pages((unsigned long)(info->iqueue.idescs),
+               free_pages(
+                       (unsigned long)(
+                               info->mpipe[instance].comps_for_echannel[0]),
+                       get_order(COMPS_SIZE));
+               info->mpipe[instance].comps_for_echannel[0] = NULL;
+               free_pages((unsigned long)(info->mpipe[instance].iqueue.idescs),
                           get_order(NOTIF_RING_SIZE));
-               info->iqueue.idescs = NULL;
+               info->mpipe[instance].iqueue.idescs = NULL;
        }
 
-       if (small_buffer_stack_va)
-               free_pages_exact(small_buffer_stack_va, buffer_stack_size);
-       if (large_buffer_stack_va)
-               free_pages_exact(large_buffer_stack_va, buffer_stack_size);
+       for (kind = 0; kind < MAX_KINDS; kind++) {
+               if (md->buffer_stack_vas[kind] != NULL) {
+                       free_pages_exact(md->buffer_stack_vas[kind],
+                                        md->buffer_stack_bytes[kind]);
+                       md->buffer_stack_vas[kind] = NULL;
+               }
+       }
 
-       small_buffer_stack_va = NULL;
-       large_buffer_stack_va = NULL;
-       large_buffer_stack = -1;
-       small_buffer_stack = -1;
-       first_bucket = -1;
+       md->first_buffer_stack = -1;
+       md->first_bucket = -1;
 }
 
 /* The first time any tilegx network device is opened, we initialize
@@ -984,9 +1300,11 @@ static void tile_net_init_mpipe_fail(void)
  */
 static int tile_net_init_mpipe(struct net_device *dev)
 {
-       int i, num_buffers, rc;
+       int rc;
        int cpu;
        int first_ring, ring;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
        int network_cpus_count = cpus_weight(network_cpus_map);
 
        if (!hash_default) {
@@ -994,36 +1312,21 @@ static int tile_net_init_mpipe(struct net_device *dev)
                return -EIO;
        }
 
-       rc = gxio_mpipe_init(&context, 0);
+       rc = gxio_mpipe_init(&md->context, instance);
        if (rc != 0) {
-               netdev_err(dev, "gxio_mpipe_init failed: %d\n", rc);
+               netdev_err(dev, "gxio_mpipe_init: mpipe[%d] %d\n",
+                          instance, rc);
                return -EIO;
        }
 
        /* Set up the buffer stacks. */
-       num_buffers =
-               network_cpus_count * (IQUEUE_ENTRIES + TILE_NET_BATCH);
-       rc = init_buffer_stacks(dev, num_buffers);
+       rc = init_buffer_stacks(dev, network_cpus_count);
        if (rc != 0)
                goto fail;
 
-       /* Provide initial buffers. */
-       rc = -ENOMEM;
-       for (i = 0; i < num_buffers; i++) {
-               if (!tile_net_provide_buffer(true)) {
-                       netdev_err(dev, "Cannot allocate initial sk_bufs!\n");
-                       goto fail;
-               }
-       }
-       for (i = 0; i < num_buffers; i++) {
-               if (!tile_net_provide_buffer(false)) {
-                       netdev_err(dev, "Cannot allocate initial sk_bufs!\n");
-                       goto fail;
-               }
-       }
-
        /* Allocate one NotifRing for each network cpu. */
-       rc = gxio_mpipe_alloc_notif_rings(&context, network_cpus_count, 0, 0);
+       rc = gxio_mpipe_alloc_notif_rings(&md->context,
+                                         network_cpus_count, 0, 0);
        if (rc < 0) {
                netdev_err(dev, "gxio_mpipe_alloc_notif_rings failed %d\n",
                           rc);
@@ -1050,10 +1353,13 @@ static int tile_net_init_mpipe(struct net_device *dev)
        if (rc != 0)
                goto fail;
 
+       /* Register PTP clock and set mPIPE timestamp, if configured. */
+       register_ptp_clock(dev, md);
+
        return 0;
 
 fail:
-       tile_net_init_mpipe_fail();
+       tile_net_init_mpipe_fail(instance);
        return rc;
 }
 
@@ -1063,17 +1369,19 @@ fail:
  */
 static int tile_net_init_egress(struct net_device *dev, int echannel)
 {
+       static int ering = -1;
        struct page *headers_page, *edescs_page, *equeue_page;
        gxio_mpipe_edesc_t *edescs;
        gxio_mpipe_equeue_t *equeue;
        unsigned char *headers;
        int headers_order, edescs_order, equeue_order;
        size_t edescs_size;
-       int edma;
        int rc = -ENOMEM;
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
 
        /* Only initialize once. */
-       if (egress_for_echannel[echannel].equeue != NULL)
+       if (md->egress_for_echannel[echannel].equeue != NULL)
                return 0;
 
        /* Allocate memory for the "headers". */
@@ -1110,28 +1418,41 @@ static int tile_net_init_egress(struct net_device *dev, int echannel)
        }
        equeue = pfn_to_kaddr(page_to_pfn(equeue_page));
 
-       /* Allocate an edma ring.  Note that in practice this can't
-        * fail, which is good, because we will leak an edma ring if so.
-        */
-       rc = gxio_mpipe_alloc_edma_rings(&context, 1, 0, 0);
-       if (rc < 0) {
-               netdev_warn(dev, "gxio_mpipe_alloc_edma_rings failed: %d\n",
-                           rc);
-               goto fail_equeue;
+       /* Allocate an edma ring (using a one entry "free list"). */
+       if (ering < 0) {
+               rc = gxio_mpipe_alloc_edma_rings(&md->context, 1, 0, 0);
+               if (rc < 0) {
+                       netdev_warn(dev, "gxio_mpipe_alloc_edma_rings: "
+                                   "mpipe[%d] %d\n", instance, rc);
+                       goto fail_equeue;
+               }
+               ering = rc;
        }
-       edma = rc;
 
        /* Initialize the equeue. */
-       rc = gxio_mpipe_equeue_init(equeue, &context, edma, echannel,
+       rc = gxio_mpipe_equeue_init(equeue, &md->context, ering, echannel,
                                    edescs, edescs_size, 0);
        if (rc != 0) {
-               netdev_err(dev, "gxio_mpipe_equeue_init failed: %d\n", rc);
+               netdev_err(dev, "gxio_mpipe_equeue_init: mpipe[%d] %d\n",
+                          instance, rc);
                goto fail_equeue;
        }
 
+       /* Don't reuse the ering later. */
+       ering = -1;
+
+       if (jumbo_num != 0) {
+               /* Make sure "jumbo" packets can be egressed safely. */
+               if (gxio_mpipe_equeue_set_snf_size(equeue, 10368) < 0) {
+                       /* ISSUE: There is no "gxio_mpipe_equeue_destroy()". */
+                       netdev_warn(dev, "Jumbo packets may not be egressed"
+                                   " properly on channel %d\n", echannel);
+               }
+       }
+
        /* Done. */
-       egress_for_echannel[echannel].equeue = equeue;
-       egress_for_echannel[echannel].headers = headers;
+       md->egress_for_echannel[echannel].equeue = equeue;
+       md->egress_for_echannel[echannel].headers = headers;
        return 0;
 
 fail_equeue:
@@ -1151,11 +1472,25 @@ fail:
 static int tile_net_link_open(struct net_device *dev, gxio_mpipe_link_t *link,
                              const char *link_name)
 {
-       int rc = gxio_mpipe_link_open(link, &context, link_name, 0);
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
+       int rc = gxio_mpipe_link_open(link, &md->context, link_name, 0);
        if (rc < 0) {
-               netdev_err(dev, "Failed to open '%s'\n", link_name);
+               netdev_err(dev, "Failed to open '%s', mpipe[%d], %d\n",
+                          link_name, instance, rc);
                return rc;
        }
+       if (jumbo_num != 0) {
+               u32 attr = GXIO_MPIPE_LINK_RECEIVE_JUMBO;
+               rc = gxio_mpipe_link_set_attr(link, attr, 1);
+               if (rc != 0) {
+                       netdev_err(dev,
+                                  "Cannot receive jumbo packets on '%s'\n",
+                                  link_name);
+                       gxio_mpipe_link_close(link);
+                       return rc;
+               }
+       }
        rc = gxio_mpipe_link_channel(link);
        if (rc < 0 || rc >= TILE_NET_CHANNELS) {
                netdev_err(dev, "gxio_mpipe_link_channel bad value: %d\n", rc);
@@ -1169,12 +1504,23 @@ static int tile_net_link_open(struct net_device *dev, gxio_mpipe_link_t *link,
 static int tile_net_open(struct net_device *dev)
 {
        struct tile_net_priv *priv = netdev_priv(dev);
-       int cpu, rc;
+       int cpu, rc, instance;
 
        mutex_lock(&tile_net_devs_for_channel_mutex);
 
-       /* Do one-time initialization the first time any device is opened. */
-       if (ingress_irq < 0) {
+       /* Get the instance info. */
+       rc = gxio_mpipe_link_instance(dev->name);
+       if (rc < 0 || rc >= NR_MPIPE_MAX) {
+               mutex_unlock(&tile_net_devs_for_channel_mutex);
+               return -EIO;
+       }
+
+       priv->instance = rc;
+       instance = rc;
+       if (!mpipe_data[rc].context.mmio_fast_base) {
+               /* Do one-time initialization per instance the first time
+                * any device is opened.
+                */
                rc = tile_net_init_mpipe(dev);
                if (rc != 0)
                        goto fail;
@@ -1205,7 +1551,7 @@ static int tile_net_open(struct net_device *dev)
        if (rc != 0)
                goto fail;
 
-       tile_net_devs_for_channel[priv->channel] = dev;
+       mpipe_data[instance].tile_net_devs_for_channel[priv->channel] = dev;
 
        rc = tile_net_update(dev);
        if (rc != 0)
@@ -1217,7 +1563,7 @@ static int tile_net_open(struct net_device *dev)
        for_each_online_cpu(cpu) {
                struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
                struct tile_net_tx_wake *tx_wake =
-                       &info->tx_wake[priv->echannel];
+                       &info->mpipe[instance].tx_wake[priv->echannel];
 
                hrtimer_init(&tx_wake->timer, CLOCK_MONOTONIC,
                             HRTIMER_MODE_REL);
@@ -1243,7 +1589,7 @@ fail:
                priv->channel = -1;
        }
        priv->echannel = -1;
-       tile_net_devs_for_channel[priv->channel] = NULL;
+       mpipe_data[instance].tile_net_devs_for_channel[priv->channel] = NULL;
        mutex_unlock(&tile_net_devs_for_channel_mutex);
 
        /* Don't return raw gxio error codes to generic Linux. */
@@ -1255,18 +1601,20 @@ static int tile_net_stop(struct net_device *dev)
 {
        struct tile_net_priv *priv = netdev_priv(dev);
        int cpu;
+       int instance = priv->instance;
+       struct mpipe_data *md = &mpipe_data[instance];
 
        for_each_online_cpu(cpu) {
                struct tile_net_info *info = &per_cpu(per_cpu_info, cpu);
                struct tile_net_tx_wake *tx_wake =
-                       &info->tx_wake[priv->echannel];
+                       &info->mpipe[instance].tx_wake[priv->echannel];
 
                hrtimer_cancel(&tx_wake->timer);
                netif_stop_subqueue(dev, cpu);
        }
 
        mutex_lock(&tile_net_devs_for_channel_mutex);
-       tile_net_devs_for_channel[priv->channel] = NULL;
+       md->tile_net_devs_for_channel[priv->channel] = NULL;
        (void)tile_net_update(dev);
        if (priv->loopify_channel >= 0) {
                if (gxio_mpipe_link_close(&priv->loopify_link) != 0)
@@ -1374,20 +1722,20 @@ static int tso_count_edescs(struct sk_buff *skb)
        return num_edescs;
 }
 
-/* Prepare modified copies of the skbuff headers.
- * FIXME: add support for IPv6.
- */
+/* Prepare modified copies of the skbuff headers. */
 static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
                                s64 slot)
 {
        struct skb_shared_info *sh = skb_shinfo(skb);
        struct iphdr *ih;
+       struct ipv6hdr *ih6;
        struct tcphdr *th;
        unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
        unsigned int data_len = skb->len - sh_len;
        unsigned char *data = skb->data;
        unsigned int ih_off, th_off, p_len;
        unsigned int isum_seed, tsum_seed, id, seq;
+       int is_ipv6;
        long f_id = -1;    /* id of the current fragment */
        long f_size = skb_headlen(skb) - sh_len;  /* current fragment size */
        long f_used = 0;  /* bytes used from the current fragment */
@@ -1395,18 +1743,24 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
        int segment;
 
        /* Locate original headers and compute various lengths. */
-       ih = ip_hdr(skb);
+       is_ipv6 = skb_is_gso_v6(skb);
+       if (is_ipv6) {
+               ih6 = ipv6_hdr(skb);
+               ih_off = skb_network_offset(skb);
+       } else {
+               ih = ip_hdr(skb);
+               ih_off = skb_network_offset(skb);
+               isum_seed = ((0xFFFF - ih->check) +
+                            (0xFFFF - ih->tot_len) +
+                            (0xFFFF - ih->id));
+               id = ntohs(ih->id);
+       }
+
        th = tcp_hdr(skb);
-       ih_off = skb_network_offset(skb);
        th_off = skb_transport_offset(skb);
        p_len = sh->gso_size;
 
-       /* Set up seed values for IP and TCP csum and initialize id and seq. */
-       isum_seed = ((0xFFFF - ih->check) +
-                    (0xFFFF - ih->tot_len) +
-                    (0xFFFF - ih->id));
        tsum_seed = th->check + (0xFFFF ^ htons(skb->len));
-       id = ntohs(ih->id);
        seq = ntohl(th->seq);
 
        /* Prepare all the headers. */
@@ -1420,11 +1774,17 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
                memcpy(buf, data, sh_len);
 
                /* Update copied ip header. */
-               ih = (struct iphdr *)(buf + ih_off);
-               ih->tot_len = htons(sh_len + p_len - ih_off);
-               ih->id = htons(id);
-               ih->check = csum_long(isum_seed + ih->tot_len +
-                                     ih->id) ^ 0xffff;
+               if (is_ipv6) {
+                       ih6 = (struct ipv6hdr *)(buf + ih_off);
+                       ih6->payload_len = htons(sh_len + p_len - ih_off -
+                                                sizeof(*ih6));
+               } else {
+                       ih = (struct iphdr *)(buf + ih_off);
+                       ih->tot_len = htons(sh_len + p_len - ih_off);
+                       ih->id = htons(id);
+                       ih->check = csum_long(isum_seed + ih->tot_len +
+                                             ih->id) ^ 0xffff;
+               }
 
                /* Update copied tcp header. */
                th = (struct tcphdr *)(buf + th_off);
@@ -1475,8 +1835,9 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
 static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue,
                       struct sk_buff *skb, unsigned char *headers, s64 slot)
 {
-       struct tile_net_priv *priv = netdev_priv(dev);
        struct skb_shared_info *sh = skb_shinfo(skb);
+       int instance = mpipe_instance(dev);
+       struct mpipe_data *md = &mpipe_data[instance];
        unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
        unsigned int data_len = skb->len - sh_len;
        unsigned int p_len = sh->gso_size;
@@ -1499,8 +1860,8 @@ static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue,
        edesc_head.xfer_size = sh_len;
 
        /* This is only used to specify the TLB. */
-       edesc_head.stack_idx = large_buffer_stack;
-       edesc_body.stack_idx = large_buffer_stack;
+       edesc_head.stack_idx = md->first_buffer_stack;
+       edesc_body.stack_idx = md->first_buffer_stack;
 
        /* Egress all the edescs. */
        for (segment = 0; segment < sh->gso_segs; segment++) {
@@ -1553,8 +1914,8 @@ static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue,
        }
 
        /* Update stats. */
-       tile_net_stats_add(tx_packets, &priv->stats.tx_packets);
-       tile_net_stats_add(tx_bytes, &priv->stats.tx_bytes);
+       tile_net_stats_add(tx_packets, &dev->stats.tx_packets);
+       tile_net_stats_add(tx_bytes, &dev->stats.tx_bytes);
 }
 
 /* Do "TSO" handling for egress.
@@ -1575,8 +1936,11 @@ static int tile_net_tx_tso(struct sk_buff *skb, struct net_device *dev)
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
        struct tile_net_priv *priv = netdev_priv(dev);
        int channel = priv->echannel;
-       struct tile_net_egress *egress = &egress_for_echannel[channel];
-       struct tile_net_comps *comps = info->comps_for_echannel[channel];
+       int instance = priv->instance;
+       struct mpipe_data *md = &mpipe_data[instance];
+       struct tile_net_egress *egress = &md->egress_for_echannel[channel];
+       struct tile_net_comps *comps =
+               info->mpipe[instance].comps_for_echannel[channel];
        gxio_mpipe_equeue_t *equeue = egress->equeue;
        unsigned long irqflags;
        int num_edescs;
@@ -1640,10 +2004,13 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
        struct tile_net_priv *priv = netdev_priv(dev);
-       struct tile_net_egress *egress = &egress_for_echannel[priv->echannel];
+       int instance = priv->instance;
+       struct mpipe_data *md = &mpipe_data[instance];
+       struct tile_net_egress *egress =
+               &md->egress_for_echannel[priv->echannel];
        gxio_mpipe_equeue_t *equeue = egress->equeue;
        struct tile_net_comps *comps =
-               info->comps_for_echannel[priv->echannel];
+               info->mpipe[instance].comps_for_echannel[priv->echannel];
        unsigned int len = skb->len;
        unsigned char *data = skb->data;
        unsigned int num_edescs;
@@ -1660,7 +2027,7 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
        num_edescs = tile_net_tx_frags(frags, skb, data, skb_headlen(skb));
 
        /* This is only used to specify the TLB. */
-       edesc.stack_idx = large_buffer_stack;
+       edesc.stack_idx = md->first_buffer_stack;
 
        /* Prepare the edescs. */
        for (i = 0; i < num_edescs; i++) {
@@ -1693,13 +2060,16 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
        for (i = 0; i < num_edescs; i++)
                gxio_mpipe_equeue_put_at(equeue, edescs[i], slot++);
 
+       /* Store TX timestamp if needed. */
+       tile_tx_timestamp(skb, instance);
+
        /* Add a completion record. */
        add_comp(equeue, comps, slot - 1, skb);
 
        /* NOTE: Use ETH_ZLEN for short packets (e.g. 42 < 60). */
-       tile_net_stats_add(1, &priv->stats.tx_packets);
+       tile_net_stats_add(1, &dev->stats.tx_packets);
        tile_net_stats_add(max_t(unsigned int, len, ETH_ZLEN),
-                          &priv->stats.tx_bytes);
+                          &dev->stats.tx_bytes);
 
        local_irq_restore(irqflags);
 
@@ -1727,20 +2097,18 @@ static void tile_net_tx_timeout(struct net_device *dev)
 /* Ioctl commands. */
 static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-       return -EOPNOTSUPP;
-}
+       if (cmd == SIOCSHWTSTAMP)
+               return tile_hwtstamp_ioctl(dev, rq, cmd);
 
-/* Get system network statistics for device. */
-static struct net_device_stats *tile_net_get_stats(struct net_device *dev)
-{
-       struct tile_net_priv *priv = netdev_priv(dev);
-       return &priv->stats;
+       return -EOPNOTSUPP;
 }
 
 /* Change the MTU. */
 static int tile_net_change_mtu(struct net_device *dev, int new_mtu)
 {
-       if ((new_mtu < 68) || (new_mtu > 1500))
+       if (new_mtu < 68)
+               return -EINVAL;
+       if (new_mtu > ((jumbo_num != 0) ? 9000 : 1500))
                return -EINVAL;
        dev->mtu = new_mtu;
        return 0;
@@ -1772,9 +2140,13 @@ static int tile_net_set_mac_address(struct net_device *dev, void *p)
  */
 static void tile_net_netpoll(struct net_device *dev)
 {
-       disable_percpu_irq(ingress_irq);
-       tile_net_handle_ingress_irq(ingress_irq, NULL);
-       enable_percpu_irq(ingress_irq, 0);
+       int instance = mpipe_instance(dev);
+       struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
+       struct mpipe_data *md = &mpipe_data[instance];
+
+       disable_percpu_irq(md->ingress_irq);
+       napi_schedule(&info->mpipe[instance].napi);
+       enable_percpu_irq(md->ingress_irq, 0);
 }
 #endif
 
@@ -1784,7 +2156,6 @@ static const struct net_device_ops tile_net_ops = {
        .ndo_start_xmit = tile_net_tx,
        .ndo_select_queue = tile_net_select_queue,
        .ndo_do_ioctl = tile_net_ioctl,
-       .ndo_get_stats = tile_net_get_stats,
        .ndo_change_mtu = tile_net_change_mtu,
        .ndo_tx_timeout = tile_net_tx_timeout,
        .ndo_set_mac_address = tile_net_set_mac_address,
@@ -1800,14 +2171,21 @@ static const struct net_device_ops tile_net_ops = {
  */
 static void tile_net_setup(struct net_device *dev)
 {
+       netdev_features_t features = 0;
+
        ether_setup(dev);
        dev->netdev_ops = &tile_net_ops;
        dev->watchdog_timeo = TILE_NET_TIMEOUT;
-       dev->features |= NETIF_F_LLTX;
-       dev->features |= NETIF_F_HW_CSUM;
-       dev->features |= NETIF_F_SG;
-       dev->features |= NETIF_F_TSO;
        dev->mtu = 1500;
+
+       features |= NETIF_F_HW_CSUM;
+       features |= NETIF_F_SG;
+       features |= NETIF_F_TSO;
+       features |= NETIF_F_TSO6;
+
+       dev->hw_features   |= features;
+       dev->vlan_features |= features;
+       dev->features      |= features;
 }
 
 /* Allocate the device structure, register the device, and obtain the
@@ -1842,6 +2220,7 @@ static void tile_net_dev_init(const char *name, const uint8_t *mac)
        priv->channel = -1;
        priv->loopify_channel = -1;
        priv->echannel = -1;
+       init_ptp_dev(priv);
 
        /* Get the MAC address and set it in the device struct; this must
         * be done before the device is opened.  If the MAC is all zeroes,
@@ -1871,9 +2250,12 @@ static void tile_net_init_module_percpu(void *unused)
 {
        struct tile_net_info *info = &__get_cpu_var(per_cpu_info);
        int my_cpu = smp_processor_id();
+       int instance;
 
-       info->has_iqueue = false;
-
+       for (instance = 0; instance < NR_MPIPE_MAX; instance++) {
+               info->mpipe[instance].has_iqueue = false;
+               info->mpipe[instance].instance = instance;
+       }
        info->my_cpu = my_cpu;
 
        /* Initialize the egress timer. */
@@ -1890,6 +2272,8 @@ static int __init tile_net_init_module(void)
 
        pr_info("Tilera Network Driver\n");
 
+       BUILD_BUG_ON(NR_MPIPE_MAX != 2);
+
        mutex_init(&tile_net_devs_for_channel_mutex);
 
        /* Initialize each CPU. */
index 36435499814b78d34020503caa41fdb00d2cd57f..106be47716e796105012efd7b8d644929faaccef 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/in6.h>
 #include <linux/timer.h>
 #include <linux/io.h>
+#include <linux/u64_stats_sync.h>
 #include <asm/checksum.h>
 #include <asm/homecache.h>
 
 /* ISSUE: This has not been thoroughly tested (except at 1500). */
 #define TILE_NET_MTU 1500
 
-/* HACK: Define to support GSO. */
-/* ISSUE: This may actually hurt performance of the TCP blaster. */
-/* #define TILE_NET_GSO */
-
-/* Define this to collapse "duplicate" acks. */
-/* #define IGNORE_DUP_ACKS */
-
 /* HACK: Define this to verify incoming packets. */
 /* #define TILE_NET_VERIFY_INGRESS */
 
@@ -156,10 +150,13 @@ struct tile_netio_queue {
  * Statistics counters for a specific cpu and device.
  */
 struct tile_net_stats_t {
-       u32 rx_packets;
-       u32 rx_bytes;
-       u32 tx_packets;
-       u32 tx_bytes;
+       struct u64_stats_sync syncp;
+       u64 rx_packets;         /* total packets received       */
+       u64 tx_packets;         /* total packets transmitted    */
+       u64 rx_bytes;           /* total bytes received         */
+       u64 tx_bytes;           /* total bytes transmitted      */
+       u64 rx_errors;          /* packets truncated or marked bad by hw */
+       u64 rx_dropped;         /* packets not for us or intf not up */
 };
 
 
@@ -218,8 +215,6 @@ struct tile_net_priv {
        int network_cpus_count;
        /* Credits per network cpu. */
        int network_cpus_credits;
-       /* Network stats. */
-       struct net_device_stats stats;
        /* For NetIO bringup retries. */
        struct delayed_work retry_work;
        /* Quick access to per cpu data. */
@@ -627,79 +622,6 @@ static void tile_net_handle_egress_timer(unsigned long arg)
 }
 
 
-#ifdef IGNORE_DUP_ACKS
-
-/*
- * Help detect "duplicate" ACKs.  These are sequential packets (for a
- * given flow) which are exactly 66 bytes long, sharing everything but
- * ID=2@0x12, Hsum=2@0x18, Ack=4@0x2a, WinSize=2@0x30, Csum=2@0x32,
- * Tstamps=10@0x38.  The ID's are +1, the Hsum's are -1, the Ack's are
- * +N, and the Tstamps are usually identical.
- *
- * NOTE: Apparently truly duplicate acks (with identical "ack" values),
- * should not be collapsed, as they are used for some kind of flow control.
- */
-static bool is_dup_ack(char *s1, char *s2, unsigned int len)
-{
-       int i;
-
-       unsigned long long ignorable = 0;
-
-       /* Identification. */
-       ignorable |= (1ULL << 0x12);
-       ignorable |= (1ULL << 0x13);
-
-       /* Header checksum. */
-       ignorable |= (1ULL << 0x18);
-       ignorable |= (1ULL << 0x19);
-
-       /* ACK. */
-       ignorable |= (1ULL << 0x2a);
-       ignorable |= (1ULL << 0x2b);
-       ignorable |= (1ULL << 0x2c);
-       ignorable |= (1ULL << 0x2d);
-
-       /* WinSize. */
-       ignorable |= (1ULL << 0x30);
-       ignorable |= (1ULL << 0x31);
-
-       /* Checksum. */
-       ignorable |= (1ULL << 0x32);
-       ignorable |= (1ULL << 0x33);
-
-       for (i = 0; i < len; i++, ignorable >>= 1) {
-
-               if ((ignorable & 1) || (s1[i] == s2[i]))
-                       continue;
-
-#ifdef TILE_NET_DEBUG
-               /* HACK: Mention non-timestamp diffs. */
-               if (i < 0x38 && i != 0x2f &&
-                   net_ratelimit())
-                       pr_info("Diff at 0x%x\n", i);
-#endif
-
-               return false;
-       }
-
-#ifdef TILE_NET_NO_SUPPRESS_DUP_ACKS
-       /* HACK: Do not suppress truly duplicate ACKs. */
-       /* ISSUE: Is this actually necessary or helpful? */
-       if (s1[0x2a] == s2[0x2a] &&
-           s1[0x2b] == s2[0x2b] &&
-           s1[0x2c] == s2[0x2c] &&
-           s1[0x2d] == s2[0x2d]) {
-               return false;
-       }
-#endif
-
-       return true;
-}
-
-#endif
-
-
-
 static void tile_net_discard_aux(struct tile_net_cpu *info, int index)
 {
        struct tile_netio_queue *queue = &info->queue;
@@ -774,6 +696,7 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
        netio_pkt_t *pkt = (netio_pkt_t *)((unsigned long) &qsp[1] + index);
 
        netio_pkt_metadata_t *metadata = NETIO_PKT_METADATA(pkt);
+       netio_pkt_status_t pkt_status = NETIO_PKT_STATUS_M(metadata, pkt);
 
        /* Extract the packet size.  FIXME: Shouldn't the second line */
        /* get subtracted?  Mostly moot, since it should be "zero". */
@@ -806,40 +729,25 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
 #endif /* TILE_NET_DUMP_PACKETS */
 
 #ifdef TILE_NET_VERIFY_INGRESS
-       if (!NETIO_PKT_L4_CSUM_CORRECT_M(metadata, pkt) &&
-           NETIO_PKT_L4_CSUM_CALCULATED_M(metadata, pkt)) {
-               /* Bug 6624: Includes UDP packets with a "zero" checksum. */
-               pr_warning("Bad L4 checksum on %d byte packet.\n", len);
-       }
-       if (!NETIO_PKT_L3_CSUM_CORRECT_M(metadata, pkt) &&
-           NETIO_PKT_L3_CSUM_CALCULATED_M(metadata, pkt)) {
+       if (pkt_status == NETIO_PKT_STATUS_OVERSIZE && len >= 64) {
                dump_packet(buf, len, "rx");
-               panic("Bad L3 checksum.");
-       }
-       switch (NETIO_PKT_STATUS_M(metadata, pkt)) {
-       case NETIO_PKT_STATUS_OVERSIZE:
-               if (len >= 64) {
-                       dump_packet(buf, len, "rx");
-                       panic("Unexpected OVERSIZE.");
-               }
-               break;
-       case NETIO_PKT_STATUS_BAD:
-               pr_warning("Unexpected BAD %ld byte packet.\n", len);
+               panic("Unexpected OVERSIZE.");
        }
 #endif
 
        filter = 0;
 
-       /* ISSUE: Filter TCP packets with "bad" checksums? */
-
-       if (!(dev->flags & IFF_UP)) {
+       if (pkt_status == NETIO_PKT_STATUS_BAD) {
+               /* Handle CRC error and hardware truncation. */
+               filter = 2;
+       } else if (!(dev->flags & IFF_UP)) {
                /* Filter packets received before we're up. */
                filter = 1;
-       } else if (NETIO_PKT_STATUS_M(metadata, pkt) == NETIO_PKT_STATUS_BAD) {
+       } else if (NETIO_PKT_ETHERTYPE_RECOGNIZED_M(metadata, pkt) &&
+                  pkt_status == NETIO_PKT_STATUS_UNDERSIZE) {
                /* Filter "truncated" packets. */
-               filter = 1;
+               filter = 2;
        } else if (!(dev->flags & IFF_PROMISC)) {
-               /* FIXME: Implement HW multicast filter. */
                if (!is_multicast_ether_addr(buf)) {
                        /* Filter packets not for our address. */
                        const u8 *mine = dev->dev_addr;
@@ -847,9 +755,14 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
                }
        }
 
-       if (filter) {
+       u64_stats_update_begin(&stats->syncp);
 
-               /* ISSUE: Update "drop" statistics? */
+       if (filter != 0) {
+
+               if (filter == 1)
+                       stats->rx_dropped++;
+               else
+                       stats->rx_errors++;
 
                tile_net_provide_linux_buffer(info, va, small);
 
@@ -881,6 +794,8 @@ static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
                stats->rx_bytes += len;
        }
 
+       u64_stats_update_end(&stats->syncp);
+
        /* ISSUE: It would be nice to defer this until the packet has */
        /* actually been processed. */
        tile_net_return_credit(info);
@@ -1907,8 +1822,10 @@ busy:
                kfree_skb(olds[i]);
 
        /* Update stats. */
+       u64_stats_update_begin(&stats->syncp);
        stats->tx_packets += num_segs;
        stats->tx_bytes += (num_segs * sh_len) + d_len;
+       u64_stats_update_end(&stats->syncp);
 
        /* Make sure the egress timer is scheduled. */
        tile_net_schedule_egress_timer(info);
@@ -1936,7 +1853,7 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
 
        unsigned int csum_start = skb_checksum_start_offset(skb);
 
-       lepp_frag_t frags[LEPP_MAX_FRAGS];
+       lepp_frag_t frags[1 + MAX_SKB_FRAGS];
 
        unsigned int num_frags;
 
@@ -1951,7 +1868,7 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
        unsigned int cmd_head, cmd_tail, cmd_next;
        unsigned int comp_tail;
 
-       lepp_cmd_t cmds[LEPP_MAX_FRAGS];
+       lepp_cmd_t cmds[1 + MAX_SKB_FRAGS];
 
 
        /*
@@ -2089,8 +2006,10 @@ busy:
                kfree_skb(olds[i]);
 
        /* HACK: Track "expanded" size for short packets (e.g. 42 < 60). */
+       u64_stats_update_begin(&stats->syncp);
        stats->tx_packets++;
        stats->tx_bytes += ((len >= ETH_ZLEN) ? len : ETH_ZLEN);
+       u64_stats_update_end(&stats->syncp);
 
        /* Make sure the egress timer is scheduled. */
        tile_net_schedule_egress_timer(info);
@@ -2127,30 +2046,51 @@ static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  *
  * Returns the address of the device statistics structure.
  */
-static struct net_device_stats *tile_net_get_stats(struct net_device *dev)
+static struct rtnl_link_stats64 *tile_net_get_stats64(struct net_device *dev,
+               struct rtnl_link_stats64 *stats)
 {
        struct tile_net_priv *priv = netdev_priv(dev);
-       u32 rx_packets = 0;
-       u32 tx_packets = 0;
-       u32 rx_bytes = 0;
-       u32 tx_bytes = 0;
+       u64 rx_packets = 0, tx_packets = 0;
+       u64 rx_bytes = 0, tx_bytes = 0;
+       u64 rx_errors = 0, rx_dropped = 0;
        int i;
 
        for_each_online_cpu(i) {
-               if (priv->cpu[i]) {
-                       rx_packets += priv->cpu[i]->stats.rx_packets;
-                       rx_bytes += priv->cpu[i]->stats.rx_bytes;
-                       tx_packets += priv->cpu[i]->stats.tx_packets;
-                       tx_bytes += priv->cpu[i]->stats.tx_bytes;
-               }
+               struct tile_net_stats_t *cpu_stats;
+               u64 trx_packets, ttx_packets, trx_bytes, ttx_bytes;
+               u64 trx_errors, trx_dropped;
+               unsigned int start;
+
+               if (priv->cpu[i] == NULL)
+                       continue;
+               cpu_stats = &priv->cpu[i]->stats;
+
+               do {
+                       start = u64_stats_fetch_begin_bh(&cpu_stats->syncp);
+                       trx_packets = cpu_stats->rx_packets;
+                       ttx_packets = cpu_stats->tx_packets;
+                       trx_bytes   = cpu_stats->rx_bytes;
+                       ttx_bytes   = cpu_stats->tx_bytes;
+                       trx_errors  = cpu_stats->rx_errors;
+                       trx_dropped = cpu_stats->rx_dropped;
+               } while (u64_stats_fetch_retry_bh(&cpu_stats->syncp, start));
+
+               rx_packets += trx_packets;
+               tx_packets += ttx_packets;
+               rx_bytes   += trx_bytes;
+               tx_bytes   += ttx_bytes;
+               rx_errors  += trx_errors;
+               rx_dropped += trx_dropped;
        }
 
-       priv->stats.rx_packets = rx_packets;
-       priv->stats.rx_bytes = rx_bytes;
-       priv->stats.tx_packets = tx_packets;
-       priv->stats.tx_bytes = tx_bytes;
+       stats->rx_packets = rx_packets;
+       stats->tx_packets = tx_packets;
+       stats->rx_bytes   = rx_bytes;
+       stats->tx_bytes   = tx_bytes;
+       stats->rx_errors  = rx_errors;
+       stats->rx_dropped = rx_dropped;
 
-       return &priv->stats;
+       return stats;
 }
 
 
@@ -2287,7 +2227,7 @@ static const struct net_device_ops tile_net_ops = {
        .ndo_stop = tile_net_stop,
        .ndo_start_xmit = tile_net_tx,
        .ndo_do_ioctl = tile_net_ioctl,
-       .ndo_get_stats = tile_net_get_stats,
+       .ndo_get_stats64 = tile_net_get_stats64,
        .ndo_change_mtu = tile_net_change_mtu,
        .ndo_tx_timeout = tile_net_tx_timeout,
        .ndo_set_mac_address = tile_net_set_mac_address,
@@ -2305,39 +2245,30 @@ static const struct net_device_ops tile_net_ops = {
  */
 static void tile_net_setup(struct net_device *dev)
 {
-       PDEBUG("tile_net_setup()\n");
+       netdev_features_t features = 0;
 
        ether_setup(dev);
-
        dev->netdev_ops = &tile_net_ops;
-
        dev->watchdog_timeo = TILE_NET_TIMEOUT;
+       dev->tx_queue_len = TILE_NET_TX_QUEUE_LEN;
+       dev->mtu = TILE_NET_MTU;
 
-       /* We want lockless xmit. */
-       dev->features |= NETIF_F_LLTX;
-
-       /* We support hardware tx checksums. */
-       dev->features |= NETIF_F_HW_CSUM;
-
-       /* We support scatter/gather. */
-       dev->features |= NETIF_F_SG;
-
-       /* We support TSO. */
-       dev->features |= NETIF_F_TSO;
+       features |= NETIF_F_HW_CSUM;
+       features |= NETIF_F_SG;
 
-#ifdef TILE_NET_GSO
-       /* We support GSO. */
-       dev->features |= NETIF_F_GSO;
-#endif
+       /* We support TSO iff the HV supports sufficient frags. */
+       if (LEPP_MAX_FRAGS >= 1 + MAX_SKB_FRAGS)
+               features |= NETIF_F_TSO;
 
+       /* We can't support HIGHDMA without hash_default, since we need
+        * to be able to finv() with a VA if we don't have hash_default.
+        */
        if (hash_default)
-               dev->features |= NETIF_F_HIGHDMA;
-
-       /* ISSUE: We should support NETIF_F_UFO. */
+               features |= NETIF_F_HIGHDMA;
 
-       dev->tx_queue_len = TILE_NET_TX_QUEUE_LEN;
-
-       dev->mtu = TILE_NET_MTU;
+       dev->hw_features   |= features;
+       dev->vlan_features |= features;
+       dev->features      |= features;
 }
 
 
index b75eb9e0e867a88ac6531c2cd35f419d8553e88a..c8f088ab5fdfdbb6c9c757f5defd9c9b70588163 100644 (file)
@@ -2407,7 +2407,7 @@ static struct pci_driver rhine_driver = {
        .driver.pm      = RHINE_PM_OPS,
 };
 
-static struct dmi_system_id __initdata rhine_dmi_table[] = {
+static struct dmi_system_id rhine_dmi_table[] __initdata = {
        {
                .ident = "EPIA-M",
                .matches = {
index 1d6dc41f755dba00edfbc83d07c1d898c05020cf..d022bf936572ea857cbcb9f0fded1899077d5a95 100644 (file)
@@ -2100,7 +2100,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
 
                __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
        }
-       netif_rx(skb);
+       netif_receive_skb(skb);
 
        stats->rx_bytes += pkt_len;
        stats->rx_packets++;
@@ -2376,6 +2376,23 @@ out_0:
        return ret;
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/**
+ *  velocity_poll_controller           -       Velocity Poll controller function
+ *  @dev: network device
+ *
+ *
+ *  Used by NETCONSOLE and other diagnostic tools to allow network I/P
+ *  with interrupts disabled.
+ */
+static void velocity_poll_controller(struct net_device *dev)
+{
+       disable_irq(dev->irq);
+       velocity_intr(dev->irq, dev);
+       enable_irq(dev->irq);
+}
+#endif
+
 /**
  *     velocity_mii_ioctl              -       MII ioctl handler
  *     @dev: network device
@@ -2641,6 +2658,9 @@ static const struct net_device_ops velocity_netdev_ops = {
        .ndo_do_ioctl           = velocity_ioctl,
        .ndo_vlan_rx_add_vid    = velocity_vlan_rx_add_vid,
        .ndo_vlan_rx_kill_vid   = velocity_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller = velocity_poll_controller,
+#endif
 };
 
 /**
@@ -2884,6 +2904,7 @@ out:
        return ret;
 
 err_iounmap:
+       netif_napi_del(&vptr->napi);
        iounmap(regs);
 err_free_dev:
        free_netdev(netdev);
@@ -2904,6 +2925,7 @@ static int velocity_remove(struct device *dev)
        struct velocity_info *vptr = netdev_priv(netdev);
 
        unregister_netdev(netdev);
+       netif_napi_del(&vptr->napi);
        iounmap(vptr->mac_regs);
        free_netdev(netdev);
        velocity_nics--;
index fd4dbdae5331a3cf31732d9691a1356b7d1abf1c..4c619ea5189fc22308b8fe36851824e72eaad0ab 100644 (file)
@@ -1230,8 +1230,7 @@ error:
  */
 static int xemaclite_of_remove(struct platform_device *of_dev)
 {
-       struct device *dev = &of_dev->dev;
-       struct net_device *ndev = dev_get_drvdata(dev);
+       struct net_device *ndev = platform_get_drvdata(of_dev);
 
        struct net_local *lp = netdev_priv(ndev);
 
@@ -1250,7 +1249,6 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
        lp->phy_node = NULL;
 
        xemaclite_remove_ndev(ndev, of_dev);
-       dev_set_drvdata(dev, NULL);
 
        return 0;
 }
index 4dccead586bee57a076be015478809ea82e7157e..23a0fff0df52eaf6cc3a9992e9ec45350a1c9084 100644 (file)
@@ -431,8 +431,8 @@ static int netvsc_probe(struct hv_device *dev,
        net->netdev_ops = &device_ops;
 
        /* TODO: Add GSO and Checksum offload */
-       net->hw_features = NETIF_F_SG;
-       net->features = NETIF_F_SG | NETIF_F_HW_VLAN_CTAG_TX;
+       net->hw_features = 0;
+       net->features = NETIF_F_HW_VLAN_CTAG_TX;
 
        SET_ETHTOOL_OPS(net, &ethtool_ops);
        SET_NETDEV_DEV(net, &dev->device);
index 964b116a0ab79ad79120c4d537cdb5701e000152..3eeaaf8004949f28f5a1aead38665a56bedc557e 100644 (file)
@@ -915,7 +915,7 @@ static int pxa_irda_probe(struct platform_device *pdev)
        err = register_netdev(dev);
 
        if (err == 0)
-               dev_set_drvdata(&pdev->dev, dev);
+               platform_set_drvdata(pdev, dev);
 
        if (err) {
                if (si->pdata->shutdown)
index 51f2bc37610188b44de5b8546062d16142571505..2dcc60fb37f1dee50beea82b878e98248c1688a0 100644 (file)
@@ -210,8 +210,7 @@ static int via_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
                        pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0));
                        pci_write_config_byte(pcidev,0x5a,0xc0);
                        WriteLPCReg(0x28, 0x70 );
-                       if (via_ircc_open(pcidev, &info, 0x3076) == 0)
-                               rc=0;
+                       rc = via_ircc_open(pcidev, &info, 0x3076);
                } else
                        rc = -ENODEV; //IR not turn on   
        } else { //Not VT1211
@@ -249,8 +248,7 @@ static int via_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
                        info.irq=FirIRQ;
                        info.dma=FirDRQ1;
                        info.dma2=FirDRQ0;
-                       if (via_ircc_open(pcidev, &info, 0x3096) == 0)
-                               rc=0;
+                       rc = via_ircc_open(pcidev, &info, 0x3096);
                } else
                        rc = -ENODEV; //IR not turn on !!!!!
        }//Not VT1211
index 18373b6ae37d78543cf925e2d86efab1578f3019..510a9b60fde1d2881d322a3278cc1613210bd54a 100644 (file)
@@ -337,8 +337,11 @@ static int macvlan_open(struct net_device *dev)
        int err;
 
        if (vlan->port->passthru) {
-               if (!(vlan->flags & MACVLAN_FLAG_NOPROMISC))
-                       dev_set_promiscuity(lowerdev, 1);
+               if (!(vlan->flags & MACVLAN_FLAG_NOPROMISC)) {
+                       err = dev_set_promiscuity(lowerdev, 1);
+                       if (err < 0)
+                               goto out;
+               }
                goto hash_add;
        }
 
@@ -597,6 +600,9 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
        if (!vlan->port->passthru)
                return -EOPNOTSUPP;
 
+       if (flags & NLM_F_REPLACE)
+               return -EOPNOTSUPP;
+
        if (is_unicast_ether_addr(addr))
                err = dev_uc_add_excl(dev, addr);
        else if (is_multicast_ether_addr(addr))
@@ -736,6 +742,10 @@ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[])
                        return -EADDRNOTAVAIL;
        }
 
+       if (data && data[IFLA_MACVLAN_FLAGS] &&
+           nla_get_u16(data[IFLA_MACVLAN_FLAGS]) & ~MACVLAN_FLAG_NOPROMISC)
+               return -EINVAL;
+
        if (data && data[IFLA_MACVLAN_MODE]) {
                switch (nla_get_u32(data[IFLA_MACVLAN_MODE])) {
                case MACVLAN_MODE_PRIVATE:
@@ -863,6 +873,18 @@ static int macvlan_changelink(struct net_device *dev,
                struct nlattr *tb[], struct nlattr *data[])
 {
        struct macvlan_dev *vlan = netdev_priv(dev);
+       enum macvlan_mode mode;
+       bool set_mode = false;
+
+       /* Validate mode, but don't set yet: setting flags may fail. */
+       if (data && data[IFLA_MACVLAN_MODE]) {
+               set_mode = true;
+               mode = nla_get_u32(data[IFLA_MACVLAN_MODE]);
+               /* Passthrough mode can't be set or cleared dynamically */
+               if ((mode == MACVLAN_MODE_PASSTHRU) !=
+                   (vlan->mode == MACVLAN_MODE_PASSTHRU))
+                       return -EINVAL;
+       }
 
        if (data && data[IFLA_MACVLAN_FLAGS]) {
                __u16 flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
@@ -879,8 +901,8 @@ static int macvlan_changelink(struct net_device *dev,
                }
                vlan->flags = flags;
        }
-       if (data && data[IFLA_MACVLAN_MODE])
-               vlan->mode = nla_get_u32(data[IFLA_MACVLAN_MODE]);
+       if (set_mode)
+               vlan->mode = mode;
        return 0;
 }
 
index 876c72246ae92aa30efe1291bf90a17ed042555a..9dccb1edfd2aba2070023f4ae874bac0cc432293 100644 (file)
@@ -68,6 +68,8 @@ static const struct proto_ops macvtap_socket_ops;
 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
                      NETIF_F_TSO6 | NETIF_F_UFO)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
+#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
+
 /*
  * RCU usage:
  * The macvtap_queue and the macvlan_dev are loosely coupled, the
@@ -278,7 +280,8 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
 {
        struct macvlan_dev *vlan = netdev_priv(dev);
        struct macvtap_queue *q = macvtap_get_queue(dev, skb);
-       netdev_features_t features;
+       netdev_features_t features = TAP_FEATURES;
+
        if (!q)
                goto drop;
 
@@ -287,9 +290,11 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
 
        skb->dev = dev;
        /* Apply the forward feature mask so that we perform segmentation
-        * according to users wishes.
+        * according to users wishes.  This only works if VNET_HDR is
+        * enabled.
         */
-       features = netif_skb_features(skb) & vlan->tap_features;
+       if (q->flags & IFF_VNET_HDR)
+               features |= vlan->tap_features;
        if (netif_needs_gso(skb, features)) {
                struct sk_buff *segs = __skb_gso_segment(skb, features, false);
 
@@ -524,7 +529,7 @@ static inline struct sk_buff *macvtap_alloc_skb(struct sock *sk, size_t prepad,
                linear = len;
 
        skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
-                                  err);
+                                  err, 0);
        if (!skb)
                return NULL;
 
@@ -536,86 +541,6 @@ static inline struct sk_buff *macvtap_alloc_skb(struct sock *sk, size_t prepad,
        return skb;
 }
 
-/* set skb frags from iovec, this can move to core network code for reuse */
-static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
-                                 int offset, size_t count)
-{
-       int len = iov_length(from, count) - offset;
-       int copy = skb_headlen(skb);
-       int size, offset1 = 0;
-       int i = 0;
-
-       /* Skip over from offset */
-       while (count && (offset >= from->iov_len)) {
-               offset -= from->iov_len;
-               ++from;
-               --count;
-       }
-
-       /* copy up to skb headlen */
-       while (count && (copy > 0)) {
-               size = min_t(unsigned int, copy, from->iov_len - offset);
-               if (copy_from_user(skb->data + offset1, from->iov_base + offset,
-                                  size))
-                       return -EFAULT;
-               if (copy > size) {
-                       ++from;
-                       --count;
-                       offset = 0;
-               } else
-                       offset += size;
-               copy -= size;
-               offset1 += size;
-       }
-
-       if (len == offset1)
-               return 0;
-
-       while (count--) {
-               struct page *page[MAX_SKB_FRAGS];
-               int num_pages;
-               unsigned long base;
-               unsigned long truesize;
-
-               len = from->iov_len - offset;
-               if (!len) {
-                       offset = 0;
-                       ++from;
-                       continue;
-               }
-               base = (unsigned long)from->iov_base + offset;
-               size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
-               if (i + size > MAX_SKB_FRAGS)
-                       return -EMSGSIZE;
-               num_pages = get_user_pages_fast(base, size, 0, &page[i]);
-               if (num_pages != size) {
-                       int j;
-
-                       for (j = 0; j < num_pages; j++)
-                               put_page(page[i + j]);
-                       return -EFAULT;
-               }
-               truesize = size * PAGE_SIZE;
-               skb->data_len += len;
-               skb->len += len;
-               skb->truesize += truesize;
-               atomic_add(truesize, &skb->sk->sk_wmem_alloc);
-               while (len) {
-                       int off = base & ~PAGE_MASK;
-                       int size = min_t(int, len, PAGE_SIZE - off);
-                       __skb_fill_page_desc(skb, i, page[i], off, size);
-                       skb_shinfo(skb)->nr_frags++;
-                       /* increase sk_wmem_alloc */
-                       base += size;
-                       len -= size;
-                       i++;
-               }
-               offset = 0;
-               ++from;
-       }
-       return 0;
-}
-
 /*
  * macvtap_skb_from_vnet_hdr and macvtap_skb_to_vnet_hdr should
  * be shared with the tun/tap driver.
@@ -698,7 +623,6 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
        return 0;
 }
 
-
 /* Get packet from user space buffer */
 static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
                                const struct iovec *iv, unsigned long total_len,
@@ -744,31 +668,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
        if (unlikely(count > UIO_MAXIOV))
                goto err;
 
-       if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY))
-               zerocopy = true;
-
-       if (zerocopy) {
-               /* Userspace may produce vectors with count greater than
-                * MAX_SKB_FRAGS, so we need to linearize parts of the skb
-                * to let the rest of data to be fit in the frags.
-                */
-               if (count > MAX_SKB_FRAGS) {
-                       copylen = iov_length(iv, count - MAX_SKB_FRAGS);
-                       if (copylen < vnet_hdr_len)
-                               copylen = 0;
-                       else
-                               copylen -= vnet_hdr_len;
-               }
-               /* There are 256 bytes to be copied in skb, so there is enough
-                * room for skb expand head in case it is used.
-                * The rest buffer is mapped from userspace.
-                */
-               if (copylen < vnet_hdr.hdr_len)
-                       copylen = vnet_hdr.hdr_len;
-               if (!copylen)
-                       copylen = GOODCOPY_LEN;
+       if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) {
+               copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN;
                linear = copylen;
-       } else {
+               if (iov_pages(iv, vnet_hdr_len + copylen, count)
+                   <= MAX_SKB_FRAGS)
+                       zerocopy = true;
+       }
+
+       if (!zerocopy) {
                copylen = len;
                linear = vnet_hdr.hdr_len;
        }
@@ -780,9 +688,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
 
        if (zerocopy)
                err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count);
-       else
+       else {
                err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len,
                                                   len);
+               if (!err && m && m->msg_control) {
+                       struct ubuf_info *uarg = m->msg_control;
+                       uarg->callback(uarg, false);
+               }
+       }
+
        if (err)
                goto err_kfree;
 
@@ -806,10 +720,13 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
                skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
                skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
        }
-       if (vlan)
+       if (vlan) {
+               local_bh_disable();
                macvlan_start_xmit(skb, vlan->dev);
-       else
+               local_bh_enable();
+       } else {
                kfree_skb(skb);
+       }
        rcu_read_unlock();
 
        return total_len;
@@ -873,7 +790,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
                        __be16 h_vlan_proto;
                        __be16 h_vlan_TCI;
                } veth;
-               veth.h_vlan_proto = htons(ETH_P_8021Q);
+               veth.h_vlan_proto = skb->vlan_proto;
                veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb));
 
                vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
@@ -900,8 +817,11 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 done:
        rcu_read_lock();
        vlan = rcu_dereference(q->vlan);
-       if (vlan)
+       if (vlan) {
+               preempt_disable();
                macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
+               preempt_enable();
+       }
        rcu_read_unlock();
 
        return ret ? ret : copied;
@@ -1046,8 +966,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
        /* tap_features are the same as features on tun/tap and
         * reflect user expectations.
         */
-       vlan->tap_features = vlan->dev->features &
-                           (feature_mask | ~TUN_OFFLOADS);
+       vlan->tap_features = feature_mask;
        vlan->set_features = features;
        netdev_update_features(vlan->dev);
 
@@ -1107,6 +1026,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
                rtnl_lock();
                ret = macvtap_ioctl_set_queue(file, u);
                rtnl_unlock();
+               return ret;
 
        case TUNGETFEATURES:
                if (put_user(IFF_TAP | IFF_NO_PI | IFF_VNET_HDR |
@@ -1142,10 +1062,6 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
                            TUN_F_TSO_ECN | TUN_F_UFO))
                        return -EINVAL;
 
-               /* TODO: only accept frames with the features that
-                        got enabled for forwarded frames */
-               if (!(q->flags & IFF_VNET_HDR))
-                       return  -EINVAL;
                rtnl_lock();
                ret = set_offload(q, arg);
                rtnl_unlock();
index 9733bd239a866d4a38552c8c41fb9b9864b6e50f..f8e305d8da761cfc3ffd2ba36ae4a19f53ff1e01 100644 (file)
@@ -48,7 +48,7 @@ static int mdio_mux_mmioreg_switch_fn(int current_child, int desired_child,
        struct mdio_mux_mmioreg_state *s = data;
 
        if (current_child ^ desired_child) {
-               void *p = ioremap(s->phys, 1);
+               void __iomem *p = ioremap(s->phys, 1);
                uint8_t x, y;
 
                if (!p)
index b51fa1f469b0ad7a664b0f39b575464a6b9ccf3b..7f18f80e87c9c059c3eb53d1382bb522315ce7cb 100644 (file)
@@ -222,7 +222,7 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
        bus->mii_bus->read = octeon_mdiobus_read;
        bus->mii_bus->write = octeon_mdiobus_write;
 
-       dev_set_drvdata(&pdev->dev, bus);
+       platform_set_drvdata(pdev, bus);
 
        err = of_mdiobus_register(bus->mii_bus, pdev->dev.of_node);
        if (err)
index 61d3f4ebf52e5590f41b260aa7a354e2ac4b862a..7f25e49ae37f21167bebda2f8051dc4da6c6ba0c 100644 (file)
@@ -40,7 +40,7 @@ struct sun4i_mdio_data {
 static int sun4i_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 {
        struct sun4i_mdio_data *data = bus->priv;
-       unsigned long start_jiffies;
+       unsigned long timeout_jiffies;
        int value;
 
        /* issue the phy address and reg */
@@ -49,10 +49,9 @@ static int sun4i_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
        writel(0x1, data->membase + EMAC_MAC_MCMD_REG);
 
        /* Wait read complete */
-       start_jiffies = jiffies;
+       timeout_jiffies = jiffies + MDIO_TIMEOUT;
        while (readl(data->membase + EMAC_MAC_MIND_REG) & 0x1) {
-               if (time_after(start_jiffies,
-                              start_jiffies + MDIO_TIMEOUT))
+               if (time_is_before_jiffies(timeout_jiffies))
                        return -ETIMEDOUT;
                msleep(1);
        }
@@ -69,7 +68,7 @@ static int sun4i_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
                            u16 value)
 {
        struct sun4i_mdio_data *data = bus->priv;
-       unsigned long start_jiffies;
+       unsigned long timeout_jiffies;
 
        /* issue the phy address and reg */
        writel((mii_id << 8) | regnum, data->membase + EMAC_MAC_MADR_REG);
@@ -77,10 +76,9 @@ static int sun4i_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
        writel(0x1, data->membase + EMAC_MAC_MCMD_REG);
 
        /* Wait read complete */
-       start_jiffies = jiffies;
+       timeout_jiffies = jiffies + MDIO_TIMEOUT;
        while (readl(data->membase + EMAC_MAC_MIND_REG) & 0x1) {
-               if (time_after(start_jiffies,
-                              start_jiffies + MDIO_TIMEOUT))
+               if (time_is_before_jiffies(timeout_jiffies))
                        return -ETIMEDOUT;
                msleep(1);
        }
index 2510435f34edfd5e10cc4252c6e7dcfa35e95e62..c31aad0004cb5ed93453089114e9f7dc31894ab2 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/phy.h>
 #include <linux/micrel_phy.h>
+#include <linux/of.h>
 
 /* Operation Mode Strap Override */
 #define MII_KSZPHY_OMSO                                0x16
 #define KS8737_CTRL_INT_ACTIVE_HIGH            (1 << 14)
 #define KSZ8051_RMII_50MHZ_CLK                 (1 << 7)
 
+/* Write/read to/from extended registers */
+#define MII_KSZPHY_EXTREG                       0x0b
+#define KSZPHY_EXTREG_WRITE                     0x8000
+
+#define MII_KSZPHY_EXTREG_WRITE                 0x0c
+#define MII_KSZPHY_EXTREG_READ                  0x0d
+
+/* Extended registers */
+#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW         0x104
+#define MII_KSZPHY_RX_DATA_PAD_SKEW             0x105
+#define MII_KSZPHY_TX_DATA_PAD_SKEW             0x106
+
+#define PS_TO_REG                              200
+
 static int ksz_config_flags(struct phy_device *phydev)
 {
        int regval;
@@ -65,6 +80,20 @@ static int ksz_config_flags(struct phy_device *phydev)
        return 0;
 }
 
+static int kszphy_extended_write(struct phy_device *phydev,
+                                 u32 regnum, u16 val)
+{
+       phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
+       return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
+}
+
+static int kszphy_extended_read(struct phy_device *phydev,
+                                 u32 regnum)
+{
+       phy_write(phydev, MII_KSZPHY_EXTREG, regnum);
+       return phy_read(phydev, MII_KSZPHY_EXTREG_READ);
+}
+
 static int kszphy_ack_interrupt(struct phy_device *phydev)
 {
        /* bit[7..0] int status, which is a read and clear register. */
@@ -141,10 +170,82 @@ static int ks8051_config_init(struct phy_device *phydev)
        return rc < 0 ? rc : 0;
 }
 
+static int ksz9021_load_values_from_of(struct phy_device *phydev,
+                                      struct device_node *of_node, u16 reg,
+                                      char *field1, char *field2,
+                                      char *field3, char *field4)
+{
+       int val1 = -1;
+       int val2 = -2;
+       int val3 = -3;
+       int val4 = -4;
+       int newval;
+       int matches = 0;
+
+       if (!of_property_read_u32(of_node, field1, &val1))
+               matches++;
+
+       if (!of_property_read_u32(of_node, field2, &val2))
+               matches++;
+
+       if (!of_property_read_u32(of_node, field3, &val3))
+               matches++;
+
+       if (!of_property_read_u32(of_node, field4, &val4))
+               matches++;
+
+       if (!matches)
+               return 0;
+
+       if (matches < 4)
+               newval = kszphy_extended_read(phydev, reg);
+       else
+               newval = 0;
+
+       if (val1 != -1)
+               newval = ((newval & 0xfff0) | ((val1 / PS_TO_REG) & 0xf) << 0);
+
+       if (val2 != -1)
+               newval = ((newval & 0xff0f) | ((val2 / PS_TO_REG) & 0xf) << 4);
+
+       if (val3 != -1)
+               newval = ((newval & 0xf0ff) | ((val3 / PS_TO_REG) & 0xf) << 8);
+
+       if (val4 != -1)
+               newval = ((newval & 0x0fff) | ((val4 / PS_TO_REG) & 0xf) << 12);
+
+       return kszphy_extended_write(phydev, reg, newval);
+}
+
+static int ksz9021_config_init(struct phy_device *phydev)
+{
+       struct device *dev = &phydev->dev;
+       struct device_node *of_node = dev->of_node;
+
+       if (!of_node && dev->parent->of_node)
+               of_node = dev->parent->of_node;
+
+       if (of_node) {
+               ksz9021_load_values_from_of(phydev, of_node,
+                                   MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
+                                   "txen-skew-ps", "txc-skew-ps",
+                                   "rxdv-skew-ps", "rxc-skew-ps");
+               ksz9021_load_values_from_of(phydev, of_node,
+                                   MII_KSZPHY_RX_DATA_PAD_SKEW,
+                                   "rxd0-skew-ps", "rxd1-skew-ps",
+                                   "rxd2-skew-ps", "rxd3-skew-ps");
+               ksz9021_load_values_from_of(phydev, of_node,
+                                   MII_KSZPHY_TX_DATA_PAD_SKEW,
+                                   "txd0-skew-ps", "txd1-skew-ps",
+                                   "txd2-skew-ps", "txd3-skew-ps");
+       }
+       return 0;
+}
+
 #define KSZ8873MLL_GLOBAL_CONTROL_4    0x06
 #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX     (1 << 6)
 #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED      (1 << 4)
-int ksz8873mll_read_status(struct phy_device *phydev)
+static int ksz8873mll_read_status(struct phy_device *phydev)
 {
        int regval;
 
@@ -281,7 +382,7 @@ static struct phy_driver ksphy_driver[] = {
        .name           = "Micrel KSZ9021 Gigabit PHY",
        .features       = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
        .flags          = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
-       .config_init    = kszphy_config_init,
+       .config_init    = ksz9021_config_init,
        .config_aneg    = genphy_config_aneg,
        .read_status    = genphy_read_status,
        .ack_interrupt  = kszphy_ack_interrupt,
index 8e7af8354342c9ce6440e3131aad536fbe385c87..138de837977f1e5762ecb8ae6fecac59ade8c181 100644 (file)
@@ -23,7 +23,7 @@
 #define RTL821x_INER_INIT      0x6400
 #define RTL821x_INSR           0x13
 
-#define        RTL8211E_INER_LINK_STAT 0x10
+#define        RTL8211E_INER_LINK_STATUS       0x400
 
 MODULE_DESCRIPTION("Realtek PHY driver");
 MODULE_AUTHOR("Johnson Leung");
@@ -57,7 +57,7 @@ static int rtl8211e_config_intr(struct phy_device *phydev)
 
        if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
                err = phy_write(phydev, RTL821x_INER,
-                               RTL8211E_INER_LINK_STAT);
+                               RTL8211E_INER_LINK_STATUS);
        else
                err = phy_write(phydev, RTL821x_INER, 0);
 
index 162464fe86bf7634fb9ac6c21ecd76e25beb10b6..6fa5ae00039fd65b2c634d0d22241d9c7a9d13e2 100644 (file)
@@ -47,7 +47,7 @@
 #define MAX_CALLID 65535
 
 static DECLARE_BITMAP(callid_bitmap, MAX_CALLID + 1);
-static struct pppox_sock **callid_sock;
+static struct pppox_sock __rcu **callid_sock;
 
 static DEFINE_SPINLOCK(chan_lock);
 
@@ -83,11 +83,11 @@ static const struct proto_ops pptp_ops;
 struct pptp_gre_header {
        u8  flags;
        u8  ver;
-       u16 protocol;
-       u16 payload_len;
-       u16 call_id;
-       u32 seq;
-       u32 ack;
+       __be16 protocol;
+       __be16 payload_len;
+       __be16 call_id;
+       __be32 seq;
+       __be32 ack;
 } __packed;
 
 static struct pppox_sock *lookup_chan(u16 call_id, __be32 s_addr)
index bff7e0b0b4e70d10ccdf9a6de11cdbae056a64f0..9ccccd40c4101b07c0f5ecbaec7c25484b67ceeb 100644 (file)
@@ -622,6 +622,86 @@ static int team_change_mode(struct team *team, const char *kind)
 }
 
 
+/*********************
+ * Peers notification
+ *********************/
+
+static void team_notify_peers_work(struct work_struct *work)
+{
+       struct team *team;
+
+       team = container_of(work, struct team, notify_peers.dw.work);
+
+       if (!rtnl_trylock()) {
+               schedule_delayed_work(&team->notify_peers.dw, 0);
+               return;
+       }
+       call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, team->dev);
+       rtnl_unlock();
+       if (!atomic_dec_and_test(&team->notify_peers.count_pending))
+               schedule_delayed_work(&team->notify_peers.dw,
+                                     msecs_to_jiffies(team->notify_peers.interval));
+}
+
+static void team_notify_peers(struct team *team)
+{
+       if (!team->notify_peers.count || !netif_running(team->dev))
+               return;
+       atomic_set(&team->notify_peers.count_pending, team->notify_peers.count);
+       schedule_delayed_work(&team->notify_peers.dw, 0);
+}
+
+static void team_notify_peers_init(struct team *team)
+{
+       INIT_DELAYED_WORK(&team->notify_peers.dw, team_notify_peers_work);
+}
+
+static void team_notify_peers_fini(struct team *team)
+{
+       cancel_delayed_work_sync(&team->notify_peers.dw);
+}
+
+
+/*******************************
+ * Send multicast group rejoins
+ *******************************/
+
+static void team_mcast_rejoin_work(struct work_struct *work)
+{
+       struct team *team;
+
+       team = container_of(work, struct team, mcast_rejoin.dw.work);
+
+       if (!rtnl_trylock()) {
+               schedule_delayed_work(&team->mcast_rejoin.dw, 0);
+               return;
+       }
+       call_netdevice_notifiers(NETDEV_RESEND_IGMP, team->dev);
+       rtnl_unlock();
+       if (!atomic_dec_and_test(&team->mcast_rejoin.count_pending))
+               schedule_delayed_work(&team->mcast_rejoin.dw,
+                                     msecs_to_jiffies(team->mcast_rejoin.interval));
+}
+
+static void team_mcast_rejoin(struct team *team)
+{
+       if (!team->mcast_rejoin.count || !netif_running(team->dev))
+               return;
+       atomic_set(&team->mcast_rejoin.count_pending, team->mcast_rejoin.count);
+       schedule_delayed_work(&team->mcast_rejoin.dw, 0);
+}
+
+static void team_mcast_rejoin_init(struct team *team)
+{
+       INIT_DELAYED_WORK(&team->mcast_rejoin.dw, team_mcast_rejoin_work);
+}
+
+static void team_mcast_rejoin_fini(struct team *team)
+{
+       cancel_delayed_work_sync(&team->mcast_rejoin.dw);
+}
+
+
 /************************
  * Rx path frame handler
  ************************/
@@ -846,6 +926,8 @@ static void team_port_enable(struct team *team,
        team_queue_override_port_add(team, port);
        if (team->ops.port_enabled)
                team->ops.port_enabled(team, port);
+       team_notify_peers(team);
+       team_mcast_rejoin(team);
 }
 
 static void __reconstruct_port_hlist(struct team *team, int rm_index)
@@ -875,6 +957,8 @@ static void team_port_disable(struct team *team,
        team->en_port_count--;
        team_queue_override_port_del(team, port);
        team_adjust_ops(team);
+       team_notify_peers(team);
+       team_mcast_rejoin(team);
 }
 
 #define TEAM_VLAN_FEATURES (NETIF_F_ALL_CSUM | NETIF_F_SG | \
@@ -953,6 +1037,9 @@ static int team_port_enable_netpoll(struct team *team, struct team_port *port,
        struct netpoll *np;
        int err;
 
+       if (!team->dev->npinfo)
+               return 0;
+
        np = kzalloc(sizeof(*np), gfp);
        if (!np)
                return -ENOMEM;
@@ -979,12 +1066,6 @@ static void team_port_disable_netpoll(struct team_port *port)
        __netpoll_cleanup(np);
        kfree(np);
 }
-
-static struct netpoll_info *team_netpoll_info(struct team *team)
-{
-       return team->dev->npinfo;
-}
-
 #else
 static int team_port_enable_netpoll(struct team *team, struct team_port *port,
                                    gfp_t gfp)
@@ -994,10 +1075,6 @@ static int team_port_enable_netpoll(struct team *team, struct team_port *port,
 static void team_port_disable_netpoll(struct team_port *port)
 {
 }
-static struct netpoll_info *team_netpoll_info(struct team *team)
-{
-       return NULL;
-}
 #endif
 
 static void __team_port_change_port_added(struct team_port *port, bool linkup);
@@ -1079,13 +1156,11 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
                goto err_vids_add;
        }
 
-       if (team_netpoll_info(team)) {
-               err = team_port_enable_netpoll(team, port, GFP_KERNEL);
-               if (err) {
-                       netdev_err(dev, "Failed to enable netpoll on device %s\n",
-                                  portname);
-                       goto err_enable_netpoll;
-               }
+       err = team_port_enable_netpoll(team, port, GFP_KERNEL);
+       if (err) {
+               netdev_err(dev, "Failed to enable netpoll on device %s\n",
+                          portname);
+               goto err_enable_netpoll;
        }
 
        err = netdev_master_upper_dev_link(port_dev, dev);
@@ -1205,6 +1280,62 @@ static int team_mode_option_set(struct team *team, struct team_gsetter_ctx *ctx)
        return team_change_mode(team, ctx->data.str_val);
 }
 
+static int team_notify_peers_count_get(struct team *team,
+                                      struct team_gsetter_ctx *ctx)
+{
+       ctx->data.u32_val = team->notify_peers.count;
+       return 0;
+}
+
+static int team_notify_peers_count_set(struct team *team,
+                                      struct team_gsetter_ctx *ctx)
+{
+       team->notify_peers.count = ctx->data.u32_val;
+       return 0;
+}
+
+static int team_notify_peers_interval_get(struct team *team,
+                                         struct team_gsetter_ctx *ctx)
+{
+       ctx->data.u32_val = team->notify_peers.interval;
+       return 0;
+}
+
+static int team_notify_peers_interval_set(struct team *team,
+                                         struct team_gsetter_ctx *ctx)
+{
+       team->notify_peers.interval = ctx->data.u32_val;
+       return 0;
+}
+
+static int team_mcast_rejoin_count_get(struct team *team,
+                                      struct team_gsetter_ctx *ctx)
+{
+       ctx->data.u32_val = team->mcast_rejoin.count;
+       return 0;
+}
+
+static int team_mcast_rejoin_count_set(struct team *team,
+                                      struct team_gsetter_ctx *ctx)
+{
+       team->mcast_rejoin.count = ctx->data.u32_val;
+       return 0;
+}
+
+static int team_mcast_rejoin_interval_get(struct team *team,
+                                         struct team_gsetter_ctx *ctx)
+{
+       ctx->data.u32_val = team->mcast_rejoin.interval;
+       return 0;
+}
+
+static int team_mcast_rejoin_interval_set(struct team *team,
+                                         struct team_gsetter_ctx *ctx)
+{
+       team->mcast_rejoin.interval = ctx->data.u32_val;
+       return 0;
+}
+
 static int team_port_en_option_get(struct team *team,
                                   struct team_gsetter_ctx *ctx)
 {
@@ -1316,6 +1447,30 @@ static const struct team_option team_options[] = {
                .getter = team_mode_option_get,
                .setter = team_mode_option_set,
        },
+       {
+               .name = "notify_peers_count",
+               .type = TEAM_OPTION_TYPE_U32,
+               .getter = team_notify_peers_count_get,
+               .setter = team_notify_peers_count_set,
+       },
+       {
+               .name = "notify_peers_interval",
+               .type = TEAM_OPTION_TYPE_U32,
+               .getter = team_notify_peers_interval_get,
+               .setter = team_notify_peers_interval_set,
+       },
+       {
+               .name = "mcast_rejoin_count",
+               .type = TEAM_OPTION_TYPE_U32,
+               .getter = team_mcast_rejoin_count_get,
+               .setter = team_mcast_rejoin_count_set,
+       },
+       {
+               .name = "mcast_rejoin_interval",
+               .type = TEAM_OPTION_TYPE_U32,
+               .getter = team_mcast_rejoin_interval_get,
+               .setter = team_mcast_rejoin_interval_set,
+       },
        {
                .name = "enabled",
                .type = TEAM_OPTION_TYPE_BOOL,
@@ -1396,6 +1551,10 @@ static int team_init(struct net_device *dev)
 
        INIT_LIST_HEAD(&team->option_list);
        INIT_LIST_HEAD(&team->option_inst_list);
+
+       team_notify_peers_init(team);
+       team_mcast_rejoin_init(team);
+
        err = team_options_register(team, team_options, ARRAY_SIZE(team_options));
        if (err)
                goto err_options_register;
@@ -1406,6 +1565,8 @@ static int team_init(struct net_device *dev)
        return 0;
 
 err_options_register:
+       team_mcast_rejoin_fini(team);
+       team_notify_peers_fini(team);
        team_queue_override_fini(team);
 err_team_queue_override_init:
        free_percpu(team->pcpu_stats);
@@ -1425,6 +1586,8 @@ static void team_uninit(struct net_device *dev)
 
        __team_change_mode(team, NULL); /* cleanup */
        __team_options_unregister(team, team_options, ARRAY_SIZE(team_options));
+       team_mcast_rejoin_fini(team);
+       team_notify_peers_fini(team);
        team_queue_override_fini(team);
        mutex_unlock(&team->lock);
 }
@@ -2698,6 +2861,10 @@ static int team_device_event(struct notifier_block *unused,
        case NETDEV_PRE_TYPE_CHANGE:
                /* Forbid to change type of underlaying device */
                return NOTIFY_BAD;
+       case NETDEV_RESEND_IGMP:
+               /* Propagate to master device */
+               call_netdevice_notifiers(event, port->team->dev);
+               break;
        }
        return NOTIFY_DONE;
 }
index 5cdcf92eb310391c1684374d0c41a3147a55f762..60a1e93e9d351a3a9f6e49ac3db1f4da7a25ada8 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/if_arp.h>
 #include <linux/if_ether.h>
 #include <linux/if_tun.h>
+#include <linux/if_vlan.h>
 #include <linux/crc32.h>
 #include <linux/nsproxy.h>
 #include <linux/virtio_net.h>
@@ -137,7 +138,10 @@ struct tun_file {
        struct fasync_struct *fasync;
        /* only used for fasnyc */
        unsigned int flags;
-       u16 queue_index;
+       union {
+               u16 queue_index;
+               unsigned int ifindex;
+       };
        struct list_head next;
        struct tun_struct *detached;
 };
@@ -497,7 +501,7 @@ static void tun_detach_all(struct net_device *dev)
                module_put(THIS_MODULE);
 }
 
-static int tun_attach(struct tun_struct *tun, struct file *file)
+static int tun_attach(struct tun_struct *tun, struct file *file, bool skip_filter)
 {
        struct tun_file *tfile = file->private_data;
        int err;
@@ -522,7 +526,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
        err = 0;
 
        /* Re-attach the filter to presist device */
-       if (tun->filter_attached == true) {
+       if (!skip_filter && (tun->filter_attached == true)) {
                err = sk_attach_filter(&tun->fprog, tfile->socket.sk);
                if (!err)
                        goto out;
@@ -739,6 +743,11 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
                          >= dev->tx_queue_len / tun->numqueues)
                goto drop;
 
+       if (skb->sk) {
+               sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags);
+               sw_tx_timestamp(skb);
+       }
+
        /* Orphan the skb - required as we might hang on to it
         * for indefinite time. */
        if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
@@ -943,7 +952,7 @@ static struct sk_buff *tun_alloc_skb(struct tun_file *tfile,
                linear = len;
 
        skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
-                                  &err);
+                                  &err, 0);
        if (!skb)
                return ERR_PTR(err);
 
@@ -955,86 +964,6 @@ static struct sk_buff *tun_alloc_skb(struct tun_file *tfile,
        return skb;
 }
 
-/* set skb frags from iovec, this can move to core network code for reuse */
-static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
-                                 int offset, size_t count)
-{
-       int len = iov_length(from, count) - offset;
-       int copy = skb_headlen(skb);
-       int size, offset1 = 0;
-       int i = 0;
-
-       /* Skip over from offset */
-       while (count && (offset >= from->iov_len)) {
-               offset -= from->iov_len;
-               ++from;
-               --count;
-       }
-
-       /* copy up to skb headlen */
-       while (count && (copy > 0)) {
-               size = min_t(unsigned int, copy, from->iov_len - offset);
-               if (copy_from_user(skb->data + offset1, from->iov_base + offset,
-                                  size))
-                       return -EFAULT;
-               if (copy > size) {
-                       ++from;
-                       --count;
-                       offset = 0;
-               } else
-                       offset += size;
-               copy -= size;
-               offset1 += size;
-       }
-
-       if (len == offset1)
-               return 0;
-
-       while (count--) {
-               struct page *page[MAX_SKB_FRAGS];
-               int num_pages;
-               unsigned long base;
-               unsigned long truesize;
-
-               len = from->iov_len - offset;
-               if (!len) {
-                       offset = 0;
-                       ++from;
-                       continue;
-               }
-               base = (unsigned long)from->iov_base + offset;
-               size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
-               if (i + size > MAX_SKB_FRAGS)
-                       return -EMSGSIZE;
-               num_pages = get_user_pages_fast(base, size, 0, &page[i]);
-               if (num_pages != size) {
-                       int j;
-
-                       for (j = 0; j < num_pages; j++)
-                               put_page(page[i + j]);
-                       return -EFAULT;
-               }
-               truesize = size * PAGE_SIZE;
-               skb->data_len += len;
-               skb->len += len;
-               skb->truesize += truesize;
-               atomic_add(truesize, &skb->sk->sk_wmem_alloc);
-               while (len) {
-                       int off = base & ~PAGE_MASK;
-                       int size = min_t(int, len, PAGE_SIZE - off);
-                       __skb_fill_page_desc(skb, i, page[i], off, size);
-                       skb_shinfo(skb)->nr_frags++;
-                       /* increase sk_wmem_alloc */
-                       base += size;
-                       len -= size;
-                       i++;
-               }
-               offset = 0;
-               ++from;
-       }
-       return 0;
-}
-
 /* Get packet from user space buffer */
 static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
                            void *msg_control, const struct iovec *iv,
@@ -1051,8 +980,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
        u32 rxhash;
 
        if (!(tun->flags & TUN_NO_PI)) {
-               if ((len -= sizeof(pi)) > total_len)
+               if (len < sizeof(pi))
                        return -EINVAL;
+               len -= sizeof(pi);
 
                if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
                        return -EFAULT;
@@ -1060,8 +990,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
        }
 
        if (tun->flags & TUN_VNET_HDR) {
-               if ((len -= tun->vnet_hdr_sz) > total_len)
+               if (len < tun->vnet_hdr_sz)
                        return -EINVAL;
+               len -= tun->vnet_hdr_sz;
 
                if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
                        return -EFAULT;
@@ -1082,32 +1013,18 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
                        return -EINVAL;
        }
 
-       if (msg_control)
-               zerocopy = true;
-
-       if (zerocopy) {
-               /* Userspace may produce vectors with count greater than
-                * MAX_SKB_FRAGS, so we need to linearize parts of the skb
-                * to let the rest of data to be fit in the frags.
-                */
-               if (count > MAX_SKB_FRAGS) {
-                       copylen = iov_length(iv, count - MAX_SKB_FRAGS);
-                       if (copylen < offset)
-                               copylen = 0;
-                       else
-                               copylen -= offset;
-               } else
-                               copylen = 0;
-               /* There are 256 bytes to be copied in skb, so there is enough
-                * room for skb expand head in case it is used.
+       if (msg_control) {
+               /* There are 256 bytes to be copied in skb, so there is
+                * enough room for skb expand head in case it is used.
                 * The rest of the buffer is mapped from userspace.
                 */
-               if (copylen < gso.hdr_len)
-                       copylen = gso.hdr_len;
-               if (!copylen)
-                       copylen = GOODCOPY_LEN;
+               copylen = gso.hdr_len ? gso.hdr_len : GOODCOPY_LEN;
                linear = copylen;
-       } else {
+               if (iov_pages(iv, offset + copylen, count) <= MAX_SKB_FRAGS)
+                       zerocopy = true;
+       }
+
+       if (!zerocopy) {
                copylen = len;
                linear = gso.hdr_len;
        }
@@ -1121,8 +1038,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 
        if (zerocopy)
                err = zerocopy_sg_from_iovec(skb, iv, offset, count);
-       else
+       else {
                err = skb_copy_datagram_from_iovec(skb, 0, iv, offset, len);
+               if (!err && msg_control) {
+                       struct ubuf_info *uarg = msg_control;
+                       uarg->callback(uarg, false);
+               }
+       }
 
        if (err) {
                tun->dev->stats.rx_dropped++;
@@ -1246,6 +1168,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 {
        struct tun_pi pi = { 0, skb->protocol };
        ssize_t total = 0;
+       int vlan_offset = 0;
 
        if (!(tun->flags & TUN_NO_PI)) {
                if ((len -= sizeof(pi)) < 0)
@@ -1309,11 +1232,40 @@ static ssize_t tun_put_user(struct tun_struct *tun,
                total += tun->vnet_hdr_sz;
        }
 
-       len = min_t(int, skb->len, len);
+       if (!vlan_tx_tag_present(skb)) {
+               len = min_t(int, skb->len, len);
+       } else {
+               int copy, ret;
+               struct {
+                       __be16 h_vlan_proto;
+                       __be16 h_vlan_TCI;
+               } veth;
+
+               veth.h_vlan_proto = skb->vlan_proto;
+               veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb));
+
+               vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
+               len = min_t(int, skb->len + VLAN_HLEN, len);
+
+               copy = min_t(int, vlan_offset, len);
+               ret = skb_copy_datagram_const_iovec(skb, 0, iv, total, copy);
+               len -= copy;
+               total += copy;
+               if (ret || !len)
+                       goto done;
+
+               copy = min_t(int, sizeof(veth), len);
+               ret = memcpy_toiovecend(iv, (void *)&veth, total, copy);
+               len -= copy;
+               total += copy;
+               if (ret || !len)
+                       goto done;
+       }
 
-       skb_copy_datagram_const_iovec(skb, 0, iv, total, len);
-       total += skb->len;
+       skb_copy_datagram_const_iovec(skb, vlan_offset, iv, total, len);
+       total += len;
 
+done:
        tun->dev->stats.tx_packets++;
        tun->dev->stats.tx_bytes += len;
 
@@ -1462,7 +1414,6 @@ static int tun_sendmsg(struct kiocb *iocb, struct socket *sock,
        return ret;
 }
 
-
 static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
                       struct msghdr *m, size_t total_len,
                       int flags)
@@ -1474,10 +1425,15 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
        if (!tun)
                return -EBADFD;
 
-       if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
+       if (flags & ~(MSG_DONTWAIT|MSG_TRUNC|MSG_ERRQUEUE)) {
                ret = -EINVAL;
                goto out;
        }
+       if (flags & MSG_ERRQUEUE) {
+               ret = sock_recv_errqueue(sock->sk, m, total_len,
+                                        SOL_PACKET, TUN_TX_TIMESTAMP);
+               goto out;
+       }
        ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len,
                          flags & MSG_DONTWAIT);
        if (ret > total_len) {
@@ -1601,7 +1557,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
                if (err < 0)
                        return err;
 
-               err = tun_attach(tun, file);
+               err = tun_attach(tun, file, ifr->ifr_flags & IFF_NOFILTER);
                if (err < 0)
                        return err;
 
@@ -1648,6 +1604,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 
                dev_net_set(dev, net);
                dev->rtnl_link_ops = &tun_link_ops;
+               dev->ifindex = tfile->ifindex;
 
                tun = netdev_priv(dev);
                tun->dev = dev;
@@ -1668,12 +1625,13 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
                tun_flow_init(tun);
 
                dev->hw_features = NETIF_F_SG | NETIF_F_FRAGLIST |
-                       TUN_USER_FEATURES;
+                                  TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
+                                  NETIF_F_HW_VLAN_STAG_TX;
                dev->features = dev->hw_features;
                dev->vlan_features = dev->features;
 
                INIT_LIST_HEAD(&tun->disabled);
-               err = tun_attach(tun, file);
+               err = tun_attach(tun, file, false);
                if (err < 0)
                        goto err_free_dev;
 
@@ -1837,7 +1795,7 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
                ret = security_tun_dev_attach_queue(tun->security);
                if (ret < 0)
                        goto unlock;
-               ret = tun_attach(tun, file);
+               ret = tun_attach(tun, file, false);
        } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {
                tun = rtnl_dereference(tfile->tun);
                if (!tun || !(tun->flags & TUN_TAP_MQ) || tfile->detached)
@@ -1863,6 +1821,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
        kgid_t group;
        int sndbuf;
        int vnet_hdr_sz;
+       unsigned int ifindex;
        int ret;
 
        if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
@@ -1897,6 +1856,19 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
                        ret = -EFAULT;
                goto unlock;
        }
+       if (cmd == TUNSETIFINDEX) {
+               ret = -EPERM;
+               if (tun)
+                       goto unlock;
+
+               ret = -EFAULT;
+               if (copy_from_user(&ifindex, argp, sizeof(ifindex)))
+                       goto unlock;
+
+               ret = 0;
+               tfile->ifindex = ifindex;
+               goto unlock;
+       }
 
        ret = -EBADFD;
        if (!tun)
@@ -1909,6 +1881,11 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
        case TUNGETIFF:
                tun_get_iff(current->nsproxy->net_ns, tun, &ifr);
 
+               if (tfile->detached)
+                       ifr.ifr_flags |= IFF_DETACH_QUEUE;
+               if (!tfile->socket.sk->sk_filter)
+                       ifr.ifr_flags |= IFF_NOFILTER;
+
                if (copy_to_user(argp, &ifr, ifreq_len))
                        ret = -EFAULT;
                break;
@@ -2065,6 +2042,16 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
                tun_detach_filter(tun, tun->numqueues);
                break;
 
+       case TUNGETFILTER:
+               ret = -EINVAL;
+               if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV)
+                       break;
+               ret = -EFAULT;
+               if (copy_to_user(argp, &tun->fprog, sizeof(tun->fprog)))
+                       break;
+               ret = 0;
+               break;
+
        default:
                ret = -EINVAL;
                break;
@@ -2145,6 +2132,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
        rcu_assign_pointer(tfile->tun, NULL);
        tfile->net = get_net(current->nsproxy->net_ns);
        tfile->flags = 0;
+       tfile->ifindex = 0;
 
        rcu_assign_pointer(tfile->socket.wq, &tfile->wq);
        init_waitqueue_head(&tfile->wq.wait);
@@ -2260,6 +2248,7 @@ static const struct ethtool_ops tun_ethtool_ops = {
        .get_msglevel   = tun_get_msglevel,
        .set_msglevel   = tun_set_msglevel,
        .get_link       = ethtool_op_get_link,
+       .get_ts_info    = ethtool_op_get_ts_info,
 };
 
 
index 346c032aa7955ba7ff09ca2a698cc1374e2ae630..bdaa12d07a127fae11a6209986d0473c32644f27 100644 (file)
@@ -178,6 +178,8 @@ struct asix_common_private {
        struct asix_rx_fixup_info rx_fixup_info;
 };
 
+extern const struct driver_info ax88172a_info;
+
 /* ASIX specific flags */
 #define FLAG_EEPROM_MAC                (1UL << 0)  /* init device MAC from eeprom */
 
index ad5d1e4384db7b3b6c3ab6f2406b5cd8075cd2d0..386a3df53678a23761308938221f4aa79b520538 100644 (file)
@@ -778,6 +778,9 @@ static int ax88178_change_mtu(struct net_device *net, int new_mtu)
        dev->hard_mtu = net->mtu + net->hard_header_len;
        ax88178_set_mfb(dev);
 
+       /* max qlen depend on hard_mtu and rx_urb_size */
+       usbnet_update_max_qlen(dev);
+
        return 0;
 }
 
@@ -943,8 +946,6 @@ static const struct driver_info hg20f9_info = {
        .data = FLAG_EEPROM_MAC,
 };
 
-extern const struct driver_info ax88172a_info;
-
 static const struct usb_device_id      products [] = {
 {
        // Linksys USB200M
index d012203b0f298dd1e1fc1a69192cda3d0c82c523..723b3879ecc2e195515037404f1bb4eae8a6f3f4 100644 (file)
@@ -161,7 +161,8 @@ static const struct net_device_ops ax88172a_netdev_ops = {
        .ndo_set_rx_mode        = asix_set_multicast,
 };
 
-int ax88172a_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
+static int ax88172a_get_settings(struct net_device *net,
+                                struct ethtool_cmd *cmd)
 {
        if (!net->phydev)
                return -ENODEV;
@@ -169,7 +170,8 @@ int ax88172a_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
        return phy_ethtool_gset(net->phydev, cmd);
 }
 
-int ax88172a_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
+static int ax88172a_set_settings(struct net_device *net,
+                                struct ethtool_cmd *cmd)
 {
        if (!net->phydev)
                return -ENODEV;
@@ -177,7 +179,7 @@ int ax88172a_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
        return phy_ethtool_sset(net->phydev, cmd);
 }
 
-int ax88172a_nway_reset(struct net_device *net)
+static int ax88172a_nway_reset(struct net_device *net)
 {
        if (!net->phydev)
                return -ENODEV;
index 1e3c302d94fe338dec36ba934fc90a79bfb00e0d..fb0caa289d0bfe53e8632305379afbc86abf2502 100644 (file)
@@ -688,6 +688,9 @@ static int ax88179_change_mtu(struct net_device *net, int new_mtu)
                                  2, 2, &tmp16);
        }
 
+       /* max qlen depend on hard_mtu and rx_urb_size */
+       usbnet_update_max_qlen(dev);
+
        return 0;
 }
 
@@ -1029,10 +1032,10 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf)
        dev->mii.supports_gmii = 1;
 
        dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-                             NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
+                             NETIF_F_RXCSUM;
 
        dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-                                NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
+                                NETIF_F_RXCSUM;
 
        /* Enable checksum offload */
        *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
@@ -1166,32 +1169,18 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
        int frame_size = dev->maxpacket;
        int mss = skb_shinfo(skb)->gso_size;
        int headroom;
-       int tailroom;
 
        tx_hdr1 = skb->len;
        tx_hdr2 = mss;
        if (((skb->len + 8) % frame_size) == 0)
                tx_hdr2 |= 0x80008000;  /* Enable padding */
 
-       skb_linearize(skb);
-       headroom = skb_headroom(skb);
-       tailroom = skb_tailroom(skb);
-
-       if (!skb_header_cloned(skb) &&
-           !skb_cloned(skb) &&
-           (headroom + tailroom) >= 8) {
-               if (headroom < 8) {
-                       skb->data = memmove(skb->head + 8, skb->data, skb->len);
-                       skb_set_tail_pointer(skb, skb->len);
-               }
-       } else {
-               struct sk_buff *skb2;
+       headroom = skb_headroom(skb) - 8;
 
-               skb2 = skb_copy_expand(skb, 8, 0, flags);
+       if ((skb_header_cloned(skb) || headroom < 0) &&
+           pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) {
                dev_kfree_skb_any(skb);
-               skb = skb2;
-               if (!skb)
-                       return NULL;
+               return NULL;
        }
 
        skb_push(skb, 4);
@@ -1317,10 +1306,10 @@ static int ax88179_reset(struct usbnet *dev)
                          1, 1, tmp);
 
        dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-                             NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
+                             NETIF_F_RXCSUM;
 
        dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-                                NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_TSO;
+                                NETIF_F_RXCSUM;
 
        /* Enable checksum offload */
        *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP |
index cba1d46e672e4cde205fbbd36fb79275cd1ecc53..86292e6aaf4955c4412ead6579f74e6848bcd089 100644 (file)
@@ -2816,13 +2816,16 @@ exit:
 static int hso_get_config_data(struct usb_interface *interface)
 {
        struct usb_device *usbdev = interface_to_usbdev(interface);
-       u8 config_data[17];
+       u8 *config_data = kmalloc(17, GFP_KERNEL);
        u32 if_num = interface->altsetting->desc.bInterfaceNumber;
        s32 result;
 
+       if (!config_data)
+               return -ENOMEM;
        if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
                            0x86, 0xC0, 0, 0, config_data, 17,
                            USB_CTRL_SET_TIMEOUT) != 0x11) {
+               kfree(config_data);
                return -EIO;
        }
 
@@ -2873,6 +2876,7 @@ static int hso_get_config_data(struct usb_interface *interface)
        if (config_data[16] & 0x1)
                result |= HSO_INFO_CRC_BUG;
 
+       kfree(config_data);
        return result;
 }
 
@@ -2886,6 +2890,11 @@ static int hso_probe(struct usb_interface *interface,
        struct hso_shared_int *shared_int;
        struct hso_device *tmp_dev = NULL;
 
+       if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
+               dev_err(&interface->dev, "Not our interface\n");
+               return -ENODEV;
+       }
+
        if_num = interface->altsetting->desc.bInterfaceNumber;
 
        /* Get the interface/port specification from either driver_info or from
@@ -2895,10 +2904,6 @@ static int hso_probe(struct usb_interface *interface,
        else
                port_spec = hso_get_config_data(interface);
 
-       if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
-               dev_err(&interface->dev, "Not our interface\n");
-               return -ENODEV;
-       }
        /* Check if we need to switch to alt interfaces prior to port
         * configuration */
        if (interface->num_altsetting > 1)
index ee13f9eb740c0bf18b793b308194675e9967a317..f3fce412c0c1a38bb7a5522ebf0d2dd2139bbff5 100644 (file)
 #include <linux/crc32.h>
 #include <linux/if_vlan.h>
 #include <linux/uaccess.h>
+#include <linux/list.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
 
 /* Version Information */
-#define DRIVER_VERSION "v1.0.0 (2013/05/03)"
+#define DRIVER_VERSION "v1.01.0 (2013/08/12)"
 #define DRIVER_AUTHOR "Realtek linux nic maintainers <nic_swsd@realtek.com>"
 #define DRIVER_DESC "Realtek RTL8152 Based USB 2.0 Ethernet Adapters"
 #define MODULENAME "r8152"
@@ -267,6 +270,12 @@ enum rtl_register_content {
        FULL_DUP        = 0x01,
 };
 
+#define RTL8152_MAX_TX         10
+#define RTL8152_MAX_RX         10
+#define INTBUFSIZE             2
+
+#define INTR_LINK              0x0004
+
 #define RTL8152_REQT_READ      0xc0
 #define RTL8152_REQT_WRITE     0x40
 #define RTL8152_REQ_GET_REGS   0x05
@@ -285,9 +294,9 @@ enum rtl_register_content {
 /* rtl8152 flags */
 enum rtl8152_flags {
        RTL8152_UNPLUG = 0,
-       RX_URB_FAIL,
        RTL8152_SET_RX_MODE,
-       WORK_ENABLE
+       WORK_ENABLE,
+       RTL8152_LINK_CHG,
 };
 
 /* Define these values to match your device */
@@ -311,21 +320,53 @@ struct tx_desc {
        u32 opts1;
 #define TX_FS                  (1 << 31) /* First segment of a packet */
 #define TX_LS                  (1 << 30) /* Final segment of a packet */
-#define TX_LEN_MASK            0xffff
+#define TX_LEN_MASK            0x3ffff
+
        u32 opts2;
+#define UDP_CS                 (1 << 31) /* Calculate UDP/IP checksum */
+#define TCP_CS                 (1 << 30) /* Calculate TCP/IP checksum */
+#define IPV4_CS                        (1 << 29) /* Calculate IPv4 checksum */
+#define IPV6_CS                        (1 << 28) /* Calculate IPv6 checksum */
+};
+
+struct r8152;
+
+struct rx_agg {
+       struct list_head list;
+       struct urb *urb;
+       struct r8152 *context;
+       void *buffer;
+       void *head;
+};
+
+struct tx_agg {
+       struct list_head list;
+       struct urb *urb;
+       struct r8152 *context;
+       void *buffer;
+       void *head;
+       u32 skb_num;
+       u32 skb_len;
 };
 
 struct r8152 {
        unsigned long flags;
        struct usb_device *udev;
        struct tasklet_struct tl;
+       struct usb_interface *intf;
        struct net_device *netdev;
-       struct urb *rx_urb, *tx_urb;
-       struct sk_buff *tx_skb, *rx_skb;
+       struct urb *intr_urb;
+       struct tx_agg tx_info[RTL8152_MAX_TX];
+       struct rx_agg rx_info[RTL8152_MAX_RX];
+       struct list_head rx_done, tx_free;
+       struct sk_buff_head tx_queue;
+       spinlock_t rx_lock, tx_lock;
        struct delayed_work schedule;
        struct mii_if_info mii;
+       int intr_interval;
        u32 msg_enable;
        u16 ocp_base;
+       u8 *intr_buff;
        u8 version;
        u8 speed;
 };
@@ -340,21 +381,46 @@ enum rtl_version {
  * The RTL chips use a 64 element hash table based on the Ethernet CRC.
  */
 static const int multicast_filter_limit = 32;
+static unsigned int rx_buf_sz = 16384;
 
 static
 int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
 {
-       return usb_control_msg(tp->udev, usb_rcvctrlpipe(tp->udev, 0),
+       int ret;
+       void *tmp;
+
+       tmp = kmalloc(size, GFP_KERNEL);
+       if (!tmp)
+               return -ENOMEM;
+
+       ret = usb_control_msg(tp->udev, usb_rcvctrlpipe(tp->udev, 0),
                               RTL8152_REQ_GET_REGS, RTL8152_REQT_READ,
-                              value, index, data, size, 500);
+                              value, index, tmp, size, 500);
+
+       memcpy(data, tmp, size);
+       kfree(tmp);
+
+       return ret;
 }
 
 static
 int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
 {
-       return usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0),
+       int ret;
+       void *tmp;
+
+       tmp = kmalloc(size, GFP_KERNEL);
+       if (!tmp)
+               return -ENOMEM;
+
+       memcpy(tmp, data, size);
+
+       ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0),
                               RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE,
-                              value, index, data, size, 500);
+                              value, index, tmp, size, 500);
+
+       kfree(tmp);
+       return ret;
 }
 
 static int generic_ocp_read(struct r8152 *tp, u16 index, u16 size,
@@ -490,37 +556,31 @@ int usb_ocp_write(struct r8152 *tp, u16 index, u16 byteen, u16 size, void *data)
 
 static u32 ocp_read_dword(struct r8152 *tp, u16 type, u16 index)
 {
-       u32 data;
+       __le32 data;
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_read(tp, index, sizeof(data), &data);
-       else
-               usb_ocp_read(tp, index, sizeof(data), &data);
+       generic_ocp_read(tp, index, sizeof(data), &data, type);
 
        return __le32_to_cpu(data);
 }
 
 static void ocp_write_dword(struct r8152 *tp, u16 type, u16 index, u32 data)
 {
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(data), &data);
-       else
-               usb_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(data), &data);
+       __le32 tmp = __cpu_to_le32(data);
+
+       generic_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(tmp), &tmp, type);
 }
 
 static u16 ocp_read_word(struct r8152 *tp, u16 type, u16 index)
 {
        u32 data;
+       __le32 tmp;
        u8 shift = index & 2;
 
        index &= ~3;
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_read(tp, index, sizeof(data), &data);
-       else
-               usb_ocp_read(tp, index, sizeof(data), &data);
+       generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
 
-       data = __le32_to_cpu(data);
+       data = __le32_to_cpu(tmp);
        data >>= (shift * 8);
        data &= 0xffff;
 
@@ -529,7 +589,8 @@ static u16 ocp_read_word(struct r8152 *tp, u16 type, u16 index)
 
 static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data)
 {
-       u32 tmp, mask = 0xffff;
+       u32 mask = 0xffff;
+       __le32 tmp;
        u16 byen = BYTE_EN_WORD;
        u8 shift = index & 2;
 
@@ -542,34 +603,25 @@ static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data)
                index &= ~3;
        }
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_read(tp, index, sizeof(tmp), &tmp);
-       else
-               usb_ocp_read(tp, index, sizeof(tmp), &tmp);
+       generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
 
-       tmp = __le32_to_cpu(tmp) & ~mask;
-       tmp |= data;
-       tmp = __cpu_to_le32(tmp);
+       data |= __le32_to_cpu(tmp) & ~mask;
+       tmp = __cpu_to_le32(data);
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_write(tp, index, byen, sizeof(tmp), &tmp);
-       else
-               usb_ocp_write(tp, index, byen, sizeof(tmp), &tmp);
+       generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
 }
 
 static u8 ocp_read_byte(struct r8152 *tp, u16 type, u16 index)
 {
        u32 data;
+       __le32 tmp;
        u8 shift = index & 3;
 
        index &= ~3;
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_read(tp, index, sizeof(data), &data);
-       else
-               usb_ocp_read(tp, index, sizeof(data), &data);
+       generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
 
-       data = __le32_to_cpu(data);
+       data = __le32_to_cpu(tmp);
        data >>= (shift * 8);
        data &= 0xff;
 
@@ -578,7 +630,8 @@ static u8 ocp_read_byte(struct r8152 *tp, u16 type, u16 index)
 
 static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data)
 {
-       u32 tmp, mask = 0xff;
+       u32 mask = 0xff;
+       __le32 tmp;
        u16 byen = BYTE_EN_BYTE;
        u8 shift = index & 3;
 
@@ -591,19 +644,12 @@ static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data)
                index &= ~3;
        }
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_read(tp, index, sizeof(tmp), &tmp);
-       else
-               usb_ocp_read(tp, index, sizeof(tmp), &tmp);
+       generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
 
-       tmp = __le32_to_cpu(tmp) & ~mask;
-       tmp |= data;
-       tmp = __cpu_to_le32(tmp);
+       data |= __le32_to_cpu(tmp) & ~mask;
+       tmp = __cpu_to_le32(data);
 
-       if (type == MCU_TYPE_PLA)
-               pla_ocp_write(tp, index, byen, sizeof(tmp), &tmp);
-       else
-               usb_ocp_write(tp, index, byen, sizeof(tmp), &tmp);
+       generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
 }
 
 static void r8152_mdio_write(struct r8152 *tp, u32 reg_addr, u32 value)
@@ -682,24 +728,20 @@ static void ocp_reg_write(struct r8152 *tp, u16 addr, u16 data)
        ocp_write_word(tp, MCU_TYPE_PLA, ocp_index, data);
 }
 
+static
+int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags);
+
 static inline void set_ethernet_addr(struct r8152 *tp)
 {
        struct net_device *dev = tp->netdev;
-       u8 *node_id;
-
-       node_id = kmalloc(sizeof(u8) * 8, GFP_KERNEL);
-       if (!node_id) {
-               netif_err(tp, probe, dev, "out of memory");
-               return;
-       }
+       u8 node_id[8] = {0};
 
-       if (pla_ocp_read(tp, PLA_IDR, sizeof(u8) * 8, node_id) < 0)
+       if (pla_ocp_read(tp, PLA_IDR, sizeof(node_id), node_id) < 0)
                netif_notice(tp, probe, dev, "inet addr fail\n");
        else {
                memcpy(dev->dev_addr, node_id, dev->addr_len);
                memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
        }
-       kfree(node_id);
 }
 
 static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
@@ -719,26 +761,6 @@ static int rtl8152_set_mac_address(struct net_device *netdev, void *p)
        return 0;
 }
 
-static int alloc_all_urbs(struct r8152 *tp)
-{
-       tp->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!tp->rx_urb)
-               return 0;
-       tp->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!tp->tx_urb) {
-               usb_free_urb(tp->rx_urb);
-               return 0;
-       }
-
-       return 1;
-}
-
-static void free_all_urbs(struct r8152 *tp)
-{
-       usb_free_urb(tp->rx_urb);
-       usb_free_urb(tp->tx_urb);
-}
-
 static struct net_device_stats *rtl8152_get_stats(struct net_device *dev)
 {
        return &dev->stats;
@@ -746,151 +768,583 @@ static struct net_device_stats *rtl8152_get_stats(struct net_device *dev)
 
 static void read_bulk_callback(struct urb *urb)
 {
-       struct r8152 *tp;
-       unsigned pkt_len;
-       struct sk_buff *skb;
        struct net_device *netdev;
-       struct net_device_stats *stats;
+       unsigned long flags;
        int status = urb->status;
+       struct rx_agg *agg;
+       struct r8152 *tp;
        int result;
-       struct rx_desc *rx_desc;
 
-       tp = urb->context;
+       agg = urb->context;
+       if (!agg)
+               return;
+
+       tp = agg->context;
        if (!tp)
                return;
+
        if (test_bit(RTL8152_UNPLUG, &tp->flags))
                return;
+
+       if (!test_bit(WORK_ENABLE, &tp->flags))
+               return;
+
        netdev = tp->netdev;
-       if (!netif_device_present(netdev))
+
+       /* When link down, the driver would cancel all bulks. */
+       /* This avoid the re-submitting bulk */
+       if (!netif_carrier_ok(netdev))
                return;
 
-       stats = rtl8152_get_stats(netdev);
        switch (status) {
        case 0:
-               break;
+               if (urb->actual_length < ETH_ZLEN)
+                       break;
+
+               spin_lock_irqsave(&tp->rx_lock, flags);
+               list_add_tail(&agg->list, &tp->rx_done);
+               spin_unlock_irqrestore(&tp->rx_lock, flags);
+               tasklet_schedule(&tp->tl);
+               return;
        case -ESHUTDOWN:
                set_bit(RTL8152_UNPLUG, &tp->flags);
                netif_device_detach(tp->netdev);
+               return;
        case -ENOENT:
                return; /* the urb is in unlink state */
        case -ETIME:
                pr_warn_ratelimited("may be reset is needed?..\n");
-               goto goon;
+               break;
        default:
                pr_warn_ratelimited("Rx status %d\n", status);
-               goto goon;
+               break;
        }
 
-       /* protect against short packets (tell me why we got some?!?) */
-       if (urb->actual_length < sizeof(*rx_desc))
-               goto goon;
-
-
-       rx_desc = (struct rx_desc *)urb->transfer_buffer;
-       pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK;
-       if (urb->actual_length < sizeof(struct rx_desc) + pkt_len)
-               goto goon;
-
-       skb = netdev_alloc_skb_ip_align(netdev, pkt_len);
-       if (!skb)
-               goto goon;
-
-       memcpy(skb->data, tp->rx_skb->data + sizeof(struct rx_desc), pkt_len);
-       skb_put(skb, pkt_len);
-       skb->protocol = eth_type_trans(skb, netdev);
-       netif_rx(skb);
-       stats->rx_packets++;
-       stats->rx_bytes += pkt_len;
-goon:
-       usb_fill_bulk_urb(tp->rx_urb, tp->udev, usb_rcvbulkpipe(tp->udev, 1),
-                     tp->rx_skb->data, RTL8152_RMS + sizeof(struct rx_desc),
-                     (usb_complete_t)read_bulk_callback, tp);
-       result = usb_submit_urb(tp->rx_urb, GFP_ATOMIC);
+       result = r8152_submit_rx(tp, agg, GFP_ATOMIC);
        if (result == -ENODEV) {
                netif_device_detach(tp->netdev);
        } else if (result) {
-               set_bit(RX_URB_FAIL, &tp->flags);
-               goto resched;
+               spin_lock_irqsave(&tp->rx_lock, flags);
+               list_add_tail(&agg->list, &tp->rx_done);
+               spin_unlock_irqrestore(&tp->rx_lock, flags);
+               tasklet_schedule(&tp->tl);
+       }
+}
+
+static void write_bulk_callback(struct urb *urb)
+{
+       struct net_device_stats *stats;
+       unsigned long flags;
+       struct tx_agg *agg;
+       struct r8152 *tp;
+       int status = urb->status;
+
+       agg = urb->context;
+       if (!agg)
+               return;
+
+       tp = agg->context;
+       if (!tp)
+               return;
+
+       stats = rtl8152_get_stats(tp->netdev);
+       if (status) {
+               pr_warn_ratelimited("Tx status %d\n", status);
+               stats->tx_errors += agg->skb_num;
        } else {
-               clear_bit(RX_URB_FAIL, &tp->flags);
+               stats->tx_packets += agg->skb_num;
+               stats->tx_bytes += agg->skb_len;
        }
 
-       return;
-resched:
-       tasklet_schedule(&tp->tl);
+       spin_lock_irqsave(&tp->tx_lock, flags);
+       list_add_tail(&agg->list, &tp->tx_free);
+       spin_unlock_irqrestore(&tp->tx_lock, flags);
+
+       if (!netif_carrier_ok(tp->netdev))
+               return;
+
+       if (!test_bit(WORK_ENABLE, &tp->flags))
+               return;
+
+       if (test_bit(RTL8152_UNPLUG, &tp->flags))
+               return;
+
+       if (!skb_queue_empty(&tp->tx_queue))
+               tasklet_schedule(&tp->tl);
 }
 
-static void rx_fixup(unsigned long data)
+static void intr_callback(struct urb *urb)
 {
        struct r8152 *tp;
-       int status;
+       __u16 *d;
+       int status = urb->status;
+       int res;
+
+       tp = urb->context;
+       if (!tp)
+               return;
 
-       tp = (struct r8152 *)data;
        if (!test_bit(WORK_ENABLE, &tp->flags))
                return;
 
-       status = usb_submit_urb(tp->rx_urb, GFP_ATOMIC);
-       if (status == -ENODEV) {
+       if (test_bit(RTL8152_UNPLUG, &tp->flags))
+               return;
+
+       switch (status) {
+       case 0:                 /* success */
+               break;
+       case -ECONNRESET:       /* unlink */
+       case -ESHUTDOWN:
                netif_device_detach(tp->netdev);
-       } else if (status) {
-               set_bit(RX_URB_FAIL, &tp->flags);
-               goto tlsched;
+       case -ENOENT:
+               return;
+       case -EOVERFLOW:
+               netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n");
+               goto resubmit;
+       /* -EPIPE:  should clear the halt */
+       default:
+               netif_info(tp, intr, tp->netdev, "intr status %d\n", status);
+               goto resubmit;
+       }
+
+       d = urb->transfer_buffer;
+       if (INTR_LINK & __le16_to_cpu(d[0])) {
+               if (!(tp->speed & LINK_STATUS)) {
+                       set_bit(RTL8152_LINK_CHG, &tp->flags);
+                       schedule_delayed_work(&tp->schedule, 0);
+               }
        } else {
-               clear_bit(RX_URB_FAIL, &tp->flags);
+               if (tp->speed & LINK_STATUS) {
+                       set_bit(RTL8152_LINK_CHG, &tp->flags);
+                       schedule_delayed_work(&tp->schedule, 0);
+               }
        }
 
-       return;
-tlsched:
-       tasklet_schedule(&tp->tl);
+resubmit:
+       res = usb_submit_urb(urb, GFP_ATOMIC);
+       if (res == -ENODEV)
+               netif_device_detach(tp->netdev);
+       else if (res)
+               netif_err(tp, intr, tp->netdev,
+                       "can't resubmit intr, status %d\n", res);
 }
 
-static void write_bulk_callback(struct urb *urb)
+static inline void *rx_agg_align(void *data)
+{
+       return (void *)ALIGN((uintptr_t)data, 8);
+}
+
+static inline void *tx_agg_align(void *data)
+{
+       return (void *)ALIGN((uintptr_t)data, 4);
+}
+
+static void free_all_mem(struct r8152 *tp)
+{
+       int i;
+
+       for (i = 0; i < RTL8152_MAX_RX; i++) {
+               if (tp->rx_info[i].urb) {
+                       usb_free_urb(tp->rx_info[i].urb);
+                       tp->rx_info[i].urb = NULL;
+               }
+
+               if (tp->rx_info[i].buffer) {
+                       kfree(tp->rx_info[i].buffer);
+                       tp->rx_info[i].buffer = NULL;
+                       tp->rx_info[i].head = NULL;
+               }
+       }
+
+       for (i = 0; i < RTL8152_MAX_TX; i++) {
+               if (tp->tx_info[i].urb) {
+                       usb_free_urb(tp->tx_info[i].urb);
+                       tp->tx_info[i].urb = NULL;
+               }
+
+               if (tp->tx_info[i].buffer) {
+                       kfree(tp->tx_info[i].buffer);
+                       tp->tx_info[i].buffer = NULL;
+                       tp->tx_info[i].head = NULL;
+               }
+       }
+
+       if (tp->intr_urb) {
+               usb_free_urb(tp->intr_urb);
+               tp->intr_urb = NULL;
+       }
+
+       if (tp->intr_buff) {
+               kfree(tp->intr_buff);
+               tp->intr_buff = NULL;
+       }
+}
+
+static int alloc_all_mem(struct r8152 *tp)
+{
+       struct net_device *netdev = tp->netdev;
+       struct usb_interface *intf = tp->intf;
+       struct usb_host_interface *alt = intf->cur_altsetting;
+       struct usb_host_endpoint *ep_intr = alt->endpoint + 2;
+       struct urb *urb;
+       int node, i;
+       u8 *buf;
+
+       node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1;
+
+       spin_lock_init(&tp->rx_lock);
+       spin_lock_init(&tp->tx_lock);
+       INIT_LIST_HEAD(&tp->rx_done);
+       INIT_LIST_HEAD(&tp->tx_free);
+       skb_queue_head_init(&tp->tx_queue);
+
+       for (i = 0; i < RTL8152_MAX_RX; i++) {
+               buf = kmalloc_node(rx_buf_sz, GFP_KERNEL, node);
+               if (!buf)
+                       goto err1;
+
+               if (buf != rx_agg_align(buf)) {
+                       kfree(buf);
+                       buf = kmalloc_node(rx_buf_sz + 8, GFP_KERNEL, node);
+                       if (!buf)
+                               goto err1;
+               }
+
+               urb = usb_alloc_urb(0, GFP_KERNEL);
+               if (!urb) {
+                       kfree(buf);
+                       goto err1;
+               }
+
+               INIT_LIST_HEAD(&tp->rx_info[i].list);
+               tp->rx_info[i].context = tp;
+               tp->rx_info[i].urb = urb;
+               tp->rx_info[i].buffer = buf;
+               tp->rx_info[i].head = rx_agg_align(buf);
+       }
+
+       for (i = 0; i < RTL8152_MAX_TX; i++) {
+               buf = kmalloc_node(rx_buf_sz, GFP_KERNEL, node);
+               if (!buf)
+                       goto err1;
+
+               if (buf != tx_agg_align(buf)) {
+                       kfree(buf);
+                       buf = kmalloc_node(rx_buf_sz + 4, GFP_KERNEL, node);
+                       if (!buf)
+                               goto err1;
+               }
+
+               urb = usb_alloc_urb(0, GFP_KERNEL);
+               if (!urb) {
+                       kfree(buf);
+                       goto err1;
+               }
+
+               INIT_LIST_HEAD(&tp->tx_info[i].list);
+               tp->tx_info[i].context = tp;
+               tp->tx_info[i].urb = urb;
+               tp->tx_info[i].buffer = buf;
+               tp->tx_info[i].head = tx_agg_align(buf);
+
+               list_add_tail(&tp->tx_info[i].list, &tp->tx_free);
+       }
+
+       tp->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
+       if (!tp->intr_urb)
+               goto err1;
+
+       tp->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL);
+       if (!tp->intr_buff)
+               goto err1;
+
+       tp->intr_interval = (int)ep_intr->desc.bInterval;
+       usb_fill_int_urb(tp->intr_urb, tp->udev, usb_rcvintpipe(tp->udev, 3),
+                    tp->intr_buff, INTBUFSIZE, intr_callback,
+                    tp, tp->intr_interval);
+
+       return 0;
+
+err1:
+       free_all_mem(tp);
+       return -ENOMEM;
+}
+
+static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp)
+{
+       struct tx_agg *agg = NULL;
+       unsigned long flags;
+
+       spin_lock_irqsave(&tp->tx_lock, flags);
+       if (!list_empty(&tp->tx_free)) {
+               struct list_head *cursor;
+
+               cursor = tp->tx_free.next;
+               list_del_init(cursor);
+               agg = list_entry(cursor, struct tx_agg, list);
+       }
+       spin_unlock_irqrestore(&tp->tx_lock, flags);
+
+       return agg;
+}
+
+static void
+r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb)
+{
+       memset(desc, 0, sizeof(*desc));
+
+       desc->opts1 = cpu_to_le32((skb->len & TX_LEN_MASK) | TX_FS | TX_LS);
+
+       if (skb->ip_summed == CHECKSUM_PARTIAL) {
+               __be16 protocol;
+               u8 ip_protocol;
+               u32 opts2 = 0;
+
+               if (skb->protocol == htons(ETH_P_8021Q))
+                       protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
+               else
+                       protocol = skb->protocol;
+
+               switch (protocol) {
+               case htons(ETH_P_IP):
+                       opts2 |= IPV4_CS;
+                       ip_protocol = ip_hdr(skb)->protocol;
+                       break;
+
+               case htons(ETH_P_IPV6):
+                       opts2 |= IPV6_CS;
+                       ip_protocol = ipv6_hdr(skb)->nexthdr;
+                       break;
+
+               default:
+                       ip_protocol = IPPROTO_RAW;
+                       break;
+               }
+
+               if (ip_protocol == IPPROTO_TCP) {
+                       opts2 |= TCP_CS;
+                       opts2 |= (skb_transport_offset(skb) & 0x7fff) << 17;
+               } else if (ip_protocol == IPPROTO_UDP) {
+                       opts2 |= UDP_CS;
+               } else {
+                       WARN_ON_ONCE(1);
+               }
+
+               desc->opts2 = cpu_to_le32(opts2);
+       }
+}
+
+static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg)
+{
+       u32 remain;
+       u8 *tx_data;
+
+       tx_data = agg->head;
+       agg->skb_num = agg->skb_len = 0;
+       remain = rx_buf_sz - sizeof(struct tx_desc);
+
+       while (remain >= ETH_ZLEN) {
+               struct tx_desc *tx_desc;
+               struct sk_buff *skb;
+               unsigned int len;
+
+               skb = skb_dequeue(&tp->tx_queue);
+               if (!skb)
+                       break;
+
+               len = skb->len;
+               if (remain < len) {
+                       skb_queue_head(&tp->tx_queue, skb);
+                       break;
+               }
+
+               tx_desc = (struct tx_desc *)tx_data;
+               tx_data += sizeof(*tx_desc);
+
+               r8152_tx_csum(tp, tx_desc, skb);
+               memcpy(tx_data, skb->data, len);
+               agg->skb_num++;
+               agg->skb_len += len;
+               dev_kfree_skb_any(skb);
+
+               tx_data = tx_agg_align(tx_data + len);
+               remain = rx_buf_sz - sizeof(*tx_desc) -
+                        (u32)((void *)tx_data - agg->head);
+       }
+
+       usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2),
+                         agg->head, (int)(tx_data - (u8 *)agg->head),
+                         (usb_complete_t)write_bulk_callback, agg);
+
+       return usb_submit_urb(agg->urb, GFP_ATOMIC);
+}
+
+static void rx_bottom(struct r8152 *tp)
+{
+       unsigned long flags;
+       struct list_head *cursor, *next;
+
+       spin_lock_irqsave(&tp->rx_lock, flags);
+       list_for_each_safe(cursor, next, &tp->rx_done) {
+               struct rx_desc *rx_desc;
+               struct rx_agg *agg;
+               unsigned pkt_len;
+               int len_used = 0;
+               struct urb *urb;
+               u8 *rx_data;
+               int ret;
+
+               list_del_init(cursor);
+               spin_unlock_irqrestore(&tp->rx_lock, flags);
+
+               agg = list_entry(cursor, struct rx_agg, list);
+               urb = agg->urb;
+               if (urb->actual_length < ETH_ZLEN)
+                       goto submit;
+
+               rx_desc = agg->head;
+               rx_data = agg->head;
+               pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK;
+               len_used += sizeof(struct rx_desc) + pkt_len;
+
+               while (urb->actual_length >= len_used) {
+                       struct net_device *netdev = tp->netdev;
+                       struct net_device_stats *stats;
+                       struct sk_buff *skb;
+
+                       if (pkt_len < ETH_ZLEN)
+                               break;
+
+                       stats = rtl8152_get_stats(netdev);
+
+                       pkt_len -= 4; /* CRC */
+                       rx_data += sizeof(struct rx_desc);
+
+                       skb = netdev_alloc_skb_ip_align(netdev, pkt_len);
+                       if (!skb) {
+                               stats->rx_dropped++;
+                               break;
+                       }
+                       memcpy(skb->data, rx_data, pkt_len);
+                       skb_put(skb, pkt_len);
+                       skb->protocol = eth_type_trans(skb, netdev);
+                       netif_rx(skb);
+                       stats->rx_packets++;
+                       stats->rx_bytes += pkt_len;
+
+                       rx_data = rx_agg_align(rx_data + pkt_len + 4);
+                       rx_desc = (struct rx_desc *)rx_data;
+                       pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK;
+                       len_used = (int)(rx_data - (u8 *)agg->head);
+                       len_used += sizeof(struct rx_desc) + pkt_len;
+               }
+
+submit:
+               ret = r8152_submit_rx(tp, agg, GFP_ATOMIC);
+               spin_lock_irqsave(&tp->rx_lock, flags);
+               if (ret && ret != -ENODEV) {
+                       list_add_tail(&agg->list, next);
+                       tasklet_schedule(&tp->tl);
+               }
+       }
+       spin_unlock_irqrestore(&tp->rx_lock, flags);
+}
+
+static void tx_bottom(struct r8152 *tp)
+{
+       int res;
+
+       do {
+               struct tx_agg *agg;
+
+               if (skb_queue_empty(&tp->tx_queue))
+                       break;
+
+               agg = r8152_get_tx_agg(tp);
+               if (!agg)
+                       break;
+
+               res = r8152_tx_agg_fill(tp, agg);
+               if (res) {
+                       struct net_device_stats *stats;
+                       struct net_device *netdev;
+                       unsigned long flags;
+
+                       netdev = tp->netdev;
+                       stats = rtl8152_get_stats(netdev);
+
+                       if (res == -ENODEV) {
+                               netif_device_detach(netdev);
+                       } else {
+                               netif_warn(tp, tx_err, netdev,
+                                          "failed tx_urb %d\n", res);
+                               stats->tx_dropped += agg->skb_num;
+                               spin_lock_irqsave(&tp->tx_lock, flags);
+                               list_add_tail(&agg->list, &tp->tx_free);
+                               spin_unlock_irqrestore(&tp->tx_lock, flags);
+                       }
+               }
+       } while (res == 0);
+}
+
+static void bottom_half(unsigned long data)
 {
        struct r8152 *tp;
-       int status = urb->status;
 
-       tp = urb->context;
-       if (!tp)
+       tp = (struct r8152 *)data;
+
+       if (test_bit(RTL8152_UNPLUG, &tp->flags))
                return;
-       dev_kfree_skb_irq(tp->tx_skb);
-       if (!netif_device_present(tp->netdev))
+
+       if (!test_bit(WORK_ENABLE, &tp->flags))
+               return;
+
+       /* When link down, the driver would cancel all bulks. */
+       /* This avoid the re-submitting bulk */
+       if (!netif_carrier_ok(tp->netdev))
                return;
-       if (status)
-               dev_info(&urb->dev->dev, "%s: Tx status %d\n",
-                        tp->netdev->name, status);
-       tp->netdev->trans_start = jiffies;
-       netif_wake_queue(tp->netdev);
+
+       rx_bottom(tp);
+       tx_bottom(tp);
+}
+
+static
+int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags)
+{
+       usb_fill_bulk_urb(agg->urb, tp->udev, usb_rcvbulkpipe(tp->udev, 1),
+                     agg->head, rx_buf_sz,
+                     (usb_complete_t)read_bulk_callback, agg);
+
+       return usb_submit_urb(agg->urb, mem_flags);
 }
 
 static void rtl8152_tx_timeout(struct net_device *netdev)
 {
        struct r8152 *tp = netdev_priv(netdev);
-       struct net_device_stats *stats = rtl8152_get_stats(netdev);
+       int i;
+
        netif_warn(tp, tx_err, netdev, "Tx timeout.\n");
-       usb_unlink_urb(tp->tx_urb);
-       stats->tx_errors++;
+       for (i = 0; i < RTL8152_MAX_TX; i++)
+               usb_unlink_urb(tp->tx_info[i].urb);
 }
 
 static void rtl8152_set_rx_mode(struct net_device *netdev)
 {
        struct r8152 *tp = netdev_priv(netdev);
 
-       if (tp->speed & LINK_STATUS)
+       if (tp->speed & LINK_STATUS) {
                set_bit(RTL8152_SET_RX_MODE, &tp->flags);
+               schedule_delayed_work(&tp->schedule, 0);
+       }
 }
 
 static void _rtl8152_set_rx_mode(struct net_device *netdev)
 {
        struct r8152 *tp = netdev_priv(netdev);
-       u32 tmp, *mc_filter;    /* Multicast hash filter */
+       u32 mc_filter[2];       /* Multicast hash filter */
+       __le32 tmp[2];
        u32 ocp_data;
 
-       mc_filter = kmalloc(sizeof(u32) * 2, GFP_KERNEL);
-       if (!mc_filter) {
-               netif_err(tp, link, netdev, "out of memory");
-               return;
-       }
-
        clear_bit(RTL8152_SET_RX_MODE, &tp->flags);
        netif_stop_queue(netdev);
        ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
@@ -918,14 +1372,12 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev)
                }
        }
 
-       tmp = mc_filter[0];
-       mc_filter[0] = __cpu_to_le32(swab32(mc_filter[1]));
-       mc_filter[1] = __cpu_to_le32(swab32(tmp));
+       tmp[0] = __cpu_to_le32(swab32(mc_filter[1]));
+       tmp[1] = __cpu_to_le32(swab32(mc_filter[0]));
 
-       pla_ocp_write(tp, PLA_MAR, BYTE_EN_DWORD, sizeof(u32) * 2, mc_filter);
+       pla_ocp_write(tp, PLA_MAR, BYTE_EN_DWORD, sizeof(tmp), tmp);
        ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
        netif_wake_queue(netdev);
-       kfree(mc_filter);
 }
 
 static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
@@ -933,33 +1385,39 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
 {
        struct r8152 *tp = netdev_priv(netdev);
        struct net_device_stats *stats = rtl8152_get_stats(netdev);
+       unsigned long flags;
+       struct tx_agg *agg = NULL;
        struct tx_desc *tx_desc;
        unsigned int len;
+       u8 *tx_data;
        int res;
 
-       netif_stop_queue(netdev);
-       len = skb->len;
-       if (skb_header_cloned(skb) || skb_headroom(skb) < sizeof(*tx_desc)) {
-               struct sk_buff *tx_skb;
+       skb_tx_timestamp(skb);
 
-               tx_skb = skb_copy_expand(skb, sizeof(*tx_desc), 0, GFP_ATOMIC);
-               dev_kfree_skb_any(skb);
-               if (!tx_skb) {
-                       stats->tx_dropped++;
-                       netif_wake_queue(netdev);
-                       return NETDEV_TX_OK;
-               }
-               skb = tx_skb;
+       /* If tx_queue is not empty, it means at least one previous packt */
+       /* is waiting for sending. Don't send current one before it.      */
+       if (skb_queue_empty(&tp->tx_queue))
+               agg = r8152_get_tx_agg(tp);
+
+       if (!agg) {
+               skb_queue_tail(&tp->tx_queue, skb);
+               return NETDEV_TX_OK;
        }
-       tx_desc = (struct tx_desc *)skb_push(skb, sizeof(*tx_desc));
-       memset(tx_desc, 0, sizeof(*tx_desc));
-       tx_desc->opts1 = cpu_to_le32((len & TX_LEN_MASK) | TX_FS | TX_LS);
-       tp->tx_skb = skb;
-       skb_tx_timestamp(skb);
-       usb_fill_bulk_urb(tp->tx_urb, tp->udev, usb_sndbulkpipe(tp->udev, 2),
-                         skb->data, skb->len,
-                         (usb_complete_t)write_bulk_callback, tp);
-       res = usb_submit_urb(tp->tx_urb, GFP_ATOMIC);
+
+       tx_desc = (struct tx_desc *)agg->head;
+       tx_data = agg->head + sizeof(*tx_desc);
+       agg->skb_num = agg->skb_len = 0;
+
+       len = skb->len;
+       r8152_tx_csum(tp, tx_desc, skb);
+       memcpy(tx_data, skb->data, len);
+       dev_kfree_skb_any(skb);
+       agg->skb_num++;
+       agg->skb_len += len;
+       usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2),
+                         agg->head, len + sizeof(*tx_desc),
+                         (usb_complete_t)write_bulk_callback, agg);
+       res = usb_submit_urb(agg->urb, GFP_ATOMIC);
        if (res) {
                /* Can we get/handle EPIPE here? */
                if (res == -ENODEV) {
@@ -967,12 +1425,11 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
                } else {
                        netif_warn(tp, tx_err, netdev,
                                   "failed tx_urb %d\n", res);
-                       stats->tx_errors++;
-                       netif_start_queue(netdev);
+                       stats->tx_dropped++;
+                       spin_lock_irqsave(&tp->tx_lock, flags);
+                       list_add_tail(&agg->list, &tp->tx_free);
+                       spin_unlock_irqrestore(&tp->tx_lock, flags);
                }
-       } else {
-               stats->tx_packets++;
-               stats->tx_bytes += skb->len;
        }
 
        return NETDEV_TX_OK;
@@ -1009,17 +1466,18 @@ static inline u8 rtl8152_get_speed(struct r8152 *tp)
 
 static int rtl8152_enable(struct r8152 *tp)
 {
-       u32     ocp_data;
+       u32 ocp_data;
+       int i, ret;
        u8 speed;
 
        speed = rtl8152_get_speed(tp);
-       if (speed & _100bps) {
+       if (speed & _10bps) {
                ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
-               ocp_data &= ~EEEP_CR_EEEP_TX;
+               ocp_data |= EEEP_CR_EEEP_TX;
                ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
        } else {
                ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
-               ocp_data |= EEEP_CR_EEEP_TX;
+               ocp_data &= ~EEEP_CR_EEEP_TX;
                ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
        }
 
@@ -1033,23 +1491,34 @@ static int rtl8152_enable(struct r8152 *tp)
        ocp_data &= ~RXDY_GATED_EN;
        ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data);
 
-       usb_fill_bulk_urb(tp->rx_urb, tp->udev, usb_rcvbulkpipe(tp->udev, 1),
-                     tp->rx_skb->data, RTL8152_RMS + sizeof(struct rx_desc),
-                     (usb_complete_t)read_bulk_callback, tp);
+       INIT_LIST_HEAD(&tp->rx_done);
+       ret = 0;
+       for (i = 0; i < RTL8152_MAX_RX; i++) {
+               INIT_LIST_HEAD(&tp->rx_info[i].list);
+               ret |= r8152_submit_rx(tp, &tp->rx_info[i], GFP_KERNEL);
+       }
 
-       return usb_submit_urb(tp->rx_urb, GFP_KERNEL);
+       return ret;
 }
 
 static void rtl8152_disable(struct r8152 *tp)
 {
-       u32     ocp_data;
-       int     i;
+       struct net_device_stats *stats = rtl8152_get_stats(tp->netdev);
+       struct sk_buff *skb;
+       u32 ocp_data;
+       int i;
 
        ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
        ocp_data &= ~RCR_ACPT_ALL;
        ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
 
-       usb_kill_urb(tp->tx_urb);
+       while ((skb = skb_dequeue(&tp->tx_queue))) {
+               dev_kfree_skb(skb);
+               stats->tx_dropped++;
+       }
+
+       for (i = 0; i < RTL8152_MAX_TX; i++)
+               usb_kill_urb(tp->tx_info[i].urb);
 
        ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1);
        ocp_data |= RXDY_GATED_EN;
@@ -1068,7 +1537,8 @@ static void rtl8152_disable(struct r8152 *tp)
                mdelay(1);
        }
 
-       usb_kill_urb(tp->rx_urb);
+       for (i = 0; i < RTL8152_MAX_RX; i++)
+               usb_kill_urb(tp->rx_info[i].urb);
 
        rtl8152_nic_reset(tp);
 }
@@ -1279,7 +1749,6 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex)
        r8152_mdio_write(tp, MII_BMCR, bmcr);
 
 out:
-       schedule_delayed_work(&tp->schedule, 5 * HZ);
 
        return ret;
 }
@@ -1302,6 +1771,7 @@ static void set_carrier(struct r8152 *tp)
        struct net_device *netdev = tp->netdev;
        u8 speed;
 
+       clear_bit(RTL8152_LINK_CHG, &tp->flags);
        speed = rtl8152_get_speed(tp);
 
        if (speed & LINK_STATUS) {
@@ -1313,7 +1783,9 @@ static void set_carrier(struct r8152 *tp)
        } else {
                if (tp->speed & LINK_STATUS) {
                        netif_carrier_off(netdev);
+                       tasklet_disable(&tp->tl);
                        rtl8152_disable(tp);
+                       tasklet_enable(&tp->tl);
                }
        }
        tp->speed = speed;
@@ -1329,13 +1801,12 @@ static void rtl_work_func_t(struct work_struct *work)
        if (test_bit(RTL8152_UNPLUG, &tp->flags))
                goto out1;
 
-       set_carrier(tp);
+       if (test_bit(RTL8152_LINK_CHG, &tp->flags))
+               set_carrier(tp);
 
        if (test_bit(RTL8152_SET_RX_MODE, &tp->flags))
                _rtl8152_set_rx_mode(tp->netdev);
 
-       schedule_delayed_work(&tp->schedule, HZ);
-
 out1:
        return;
 }
@@ -1345,28 +1816,20 @@ static int rtl8152_open(struct net_device *netdev)
        struct r8152 *tp = netdev_priv(netdev);
        int res = 0;
 
-       tp->speed = rtl8152_get_speed(tp);
-       if (tp->speed & LINK_STATUS) {
-               res = rtl8152_enable(tp);
-               if (res) {
-                       if (res == -ENODEV)
-                               netif_device_detach(tp->netdev);
-
-                       netif_err(tp, ifup, netdev,
-                                 "rtl8152_open failed: %d\n", res);
-                       return res;
-               }
-
-               netif_carrier_on(netdev);
-       } else {
-               netif_stop_queue(netdev);
-               netif_carrier_off(netdev);
+       res = usb_submit_urb(tp->intr_urb, GFP_KERNEL);
+       if (res) {
+               if (res == -ENODEV)
+                       netif_device_detach(tp->netdev);
+               netif_warn(tp, ifup, netdev,
+                       "intr_urb submit failed: %d\n", res);
+               return res;
        }
 
        rtl8152_set_speed(tp, AUTONEG_ENABLE, SPEED_100, DUPLEX_FULL);
+       tp->speed = 0;
+       netif_carrier_off(netdev);
        netif_start_queue(netdev);
        set_bit(WORK_ENABLE, &tp->flags);
-       schedule_delayed_work(&tp->schedule, 0);
 
        return res;
 }
@@ -1376,10 +1839,13 @@ static int rtl8152_close(struct net_device *netdev)
        struct r8152 *tp = netdev_priv(netdev);
        int res = 0;
 
+       usb_kill_urb(tp->intr_urb);
        clear_bit(WORK_ENABLE, &tp->flags);
        cancel_delayed_work_sync(&tp->schedule);
        netif_stop_queue(netdev);
+       tasklet_disable(&tp->tl);
        rtl8152_disable(tp);
+       tasklet_enable(&tp->tl);
 
        return res;
 }
@@ -1439,8 +1905,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp)
 
 static void r8152b_init(struct r8152 *tp)
 {
-       u32     ocp_data;
-       int     i;
+       u32 ocp_data;
+       int i;
 
        rtl_clear_bp(tp);
 
@@ -1485,9 +1951,9 @@ static void r8152b_init(struct r8152 *tp)
                        break;
        }
 
-       /* disable rx aggregation */
+       /* enable rx aggregation */
        ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
-       ocp_data |= RX_AGG_DISABLE;
+       ocp_data &= ~RX_AGG_DISABLE;
        ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 }
 
@@ -1499,7 +1965,9 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
 
        if (netif_running(tp->netdev)) {
                clear_bit(WORK_ENABLE, &tp->flags);
+               usb_kill_urb(tp->intr_urb);
                cancel_delayed_work_sync(&tp->schedule);
+               tasklet_disable(&tp->tl);
        }
 
        rtl8152_down(tp);
@@ -1514,10 +1982,12 @@ static int rtl8152_resume(struct usb_interface *intf)
        r8152b_init(tp);
        netif_device_attach(tp->netdev);
        if (netif_running(tp->netdev)) {
-               rtl8152_enable(tp);
+               rtl8152_set_speed(tp, AUTONEG_ENABLE, SPEED_100, DUPLEX_FULL);
+               tp->speed = 0;
+               netif_carrier_off(tp->netdev);
                set_bit(WORK_ENABLE, &tp->flags);
-               set_bit(RTL8152_SET_RX_MODE, &tp->flags);
-               schedule_delayed_work(&tp->schedule, 0);
+               usb_submit_urb(tp->intr_urb, GFP_KERNEL);
+               tasklet_enable(&tp->tl);
        }
 
        return 0;
@@ -1629,6 +2099,7 @@ static int rtl8152_probe(struct usb_interface *intf,
        struct usb_device *udev = interface_to_usbdev(intf);
        struct r8152 *tp;
        struct net_device *netdev;
+       int ret;
 
        if (udev->actconfig->desc.bConfigurationValue != 1) {
                usb_driver_set_configuration(udev, 1);
@@ -1641,19 +2112,22 @@ static int rtl8152_probe(struct usb_interface *intf,
                return -ENOMEM;
        }
 
+       SET_NETDEV_DEV(netdev, &intf->dev);
        tp = netdev_priv(netdev);
        tp->msg_enable = 0x7FFF;
 
-       tasklet_init(&tp->tl, rx_fixup, (unsigned long)tp);
+       tasklet_init(&tp->tl, bottom_half, (unsigned long)tp);
        INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t);
 
        tp->udev = udev;
        tp->netdev = netdev;
+       tp->intf = intf;
        netdev->netdev_ops = &rtl8152_netdev_ops;
        netdev->watchdog_timeo = RTL8152_TX_TIMEOUT;
-       netdev->features &= ~NETIF_F_IP_CSUM;
+
+       netdev->features |= NETIF_F_IP_CSUM;
+       netdev->hw_features = NETIF_F_IP_CSUM;
        SET_ETHTOOL_OPS(netdev, &ops);
-       tp->speed = 0;
 
        tp->mii.dev = netdev;
        tp->mii.mdio_read = read_mii_word;
@@ -1667,37 +2141,27 @@ static int rtl8152_probe(struct usb_interface *intf,
        r8152b_init(tp);
        set_ethernet_addr(tp);
 
-       if (!alloc_all_urbs(tp)) {
-               netif_err(tp, probe, netdev, "out of memory");
+       ret = alloc_all_mem(tp);
+       if (ret)
                goto out;
-       }
-
-       tp->rx_skb = netdev_alloc_skb(netdev,
-                       RTL8152_RMS + sizeof(struct rx_desc));
-       if (!tp->rx_skb)
-               goto out1;
 
        usb_set_intfdata(intf, tp);
-       SET_NETDEV_DEV(netdev, &intf->dev);
-
 
-       if (register_netdev(netdev) != 0) {
+       ret = register_netdev(netdev);
+       if (ret != 0) {
                netif_err(tp, probe, netdev, "couldn't register the device");
-               goto out2;
+               goto out1;
        }
 
        netif_info(tp, probe, netdev, "%s", DRIVER_VERSION);
 
        return 0;
 
-out2:
-       usb_set_intfdata(intf, NULL);
-       dev_kfree_skb(tp->rx_skb);
 out1:
-       free_all_urbs(tp);
+       usb_set_intfdata(intf, NULL);
 out:
        free_netdev(netdev);
-       return -EIO;
+       return ret;
 }
 
 static void rtl8152_unload(struct r8152 *tp)
@@ -1725,9 +2189,7 @@ static void rtl8152_disconnect(struct usb_interface *intf)
                tasklet_kill(&tp->tl);
                unregister_netdev(tp->netdev);
                rtl8152_unload(tp);
-               free_all_urbs(tp);
-               if (tp->rx_skb)
-                       dev_kfree_skb(tp->rx_skb);
+               free_all_mem(tp);
                free_netdev(tp->netdev);
        }
 }
@@ -1742,11 +2204,12 @@ MODULE_DEVICE_TABLE(usb, rtl8152_table);
 
 static struct usb_driver rtl8152_driver = {
        .name =         MODULENAME,
+       .id_table =     rtl8152_table,
        .probe =        rtl8152_probe,
        .disconnect =   rtl8152_disconnect,
-       .id_table =     rtl8152_table,
        .suspend =      rtl8152_suspend,
-       .resume =       rtl8152_resume
+       .resume =       rtl8152_resume,
+       .reset_resume = rtl8152_resume,
 };
 
 module_usb_driver(rtl8152_driver);
index 852392269718e1892119a3c42d45c635f768a77f..2df2f4fb42a7c381fb68275bfab10052b7a71363 100644 (file)
 
 static int pla_read_word(struct usb_device *udev, u16 index)
 {
-       int data, ret;
+       int ret;
        u8 shift = index & 2;
-       __le32 ocp_data;
+       __le32 *tmp;
+
+       tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
+       if (!tmp)
+               return -ENOMEM;
 
        index &= ~3;
 
        ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
                              RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
-                             index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data),
-                             500);
+                             index, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
        if (ret < 0)
-               return ret;
+               goto out2;
 
-       data = __le32_to_cpu(ocp_data);
-       data >>= (shift * 8);
-       data &= 0xffff;
+       ret = __le32_to_cpu(*tmp);
+       ret >>= (shift * 8);
+       ret &= 0xffff;
 
-       return data;
+out2:
+       kfree(tmp);
+       return ret;
 }
 
 static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
 {
-       __le32 ocp_data;
+       __le32 *tmp;
        u32 mask = 0xffff;
        u16 byen = BYTE_EN_WORD;
        u8 shift = index & 2;
        int ret;
 
+       tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
+       if (!tmp)
+               return -ENOMEM;
+
        data &= mask;
 
        if (shift) {
@@ -63,19 +72,20 @@ static int pla_write_word(struct usb_device *udev, u16 index, u32 data)
 
        ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
                              RTL815x_REQ_GET_REGS, RTL815x_REQT_READ,
-                             index, MCU_TYPE_PLA, &ocp_data, sizeof(ocp_data),
-                             500);
+                             index, MCU_TYPE_PLA, tmp, sizeof(*tmp), 500);
        if (ret < 0)
-               return ret;
+               goto out3;
 
-       data |= __le32_to_cpu(ocp_data) & ~mask;
-       ocp_data = __cpu_to_le32(data);
+       data |= __le32_to_cpu(*tmp) & ~mask;
+       *tmp = __cpu_to_le32(data);
 
        ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
                              RTL815x_REQ_SET_REGS, RTL815x_REQT_WRITE,
-                             index, MCU_TYPE_PLA | byen, &ocp_data,
-                             sizeof(ocp_data), 500);
+                             index, MCU_TYPE_PLA | byen, tmp, sizeof(*tmp),
+                             500);
 
+out3:
+       kfree(tmp);
        return ret;
 }
 
@@ -116,11 +126,18 @@ out1:
 static int r815x_mdio_read(struct net_device *netdev, int phy_id, int reg)
 {
        struct usbnet *dev = netdev_priv(netdev);
+       int ret;
 
        if (phy_id != R815x_PHY_ID)
                return -EINVAL;
 
-       return ocp_reg_read(dev, BASE_MII + reg * 2);
+       if (usb_autopm_get_interface(dev->intf) < 0)
+               return -ENODEV;
+
+       ret = ocp_reg_read(dev, BASE_MII + reg * 2);
+
+       usb_autopm_put_interface(dev->intf);
+       return ret;
 }
 
 static
@@ -131,7 +148,12 @@ void r815x_mdio_write(struct net_device *netdev, int phy_id, int reg, int val)
        if (phy_id != R815x_PHY_ID)
                return;
 
+       if (usb_autopm_get_interface(dev->intf) < 0)
+               return;
+
        ocp_reg_write(dev, BASE_MII + reg * 2, val);
+
+       usb_autopm_put_interface(dev->intf);
 }
 
 static int r8153_bind(struct usbnet *dev, struct usb_interface *intf)
@@ -150,7 +172,7 @@ static int r8153_bind(struct usbnet *dev, struct usb_interface *intf)
        dev->mii.phy_id = R815x_PHY_ID;
        dev->mii.supports_gmii = 1;
 
-       return 0;
+       return status;
 }
 
 static int r8152_bind(struct usbnet *dev, struct usb_interface *intf)
@@ -169,7 +191,7 @@ static int r8152_bind(struct usbnet *dev, struct usb_interface *intf)
        dev->mii.phy_id = R815x_PHY_ID;
        dev->mii.supports_gmii = 0;
 
-       return 0;
+       return status;
 }
 
 static const struct driver_info r8152_info = {
index 75409748c77470da8cc5bcc7390e9f4c5a94ea6a..66ebbacf066f6692ba21d2fa07538535827074b9 100644 (file)
@@ -45,7 +45,6 @@
 #define EEPROM_MAC_OFFSET              (0x01)
 #define DEFAULT_TX_CSUM_ENABLE         (true)
 #define DEFAULT_RX_CSUM_ENABLE         (true)
-#define DEFAULT_TSO_ENABLE             (true)
 #define SMSC75XX_INTERNAL_PHY_ID       (1)
 #define SMSC75XX_TX_OVERHEAD           (8)
 #define MAX_RX_FIFO_SIZE               (20 * 1024)
@@ -1410,17 +1409,14 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
 
        INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write);
 
-       if (DEFAULT_TX_CSUM_ENABLE) {
+       if (DEFAULT_TX_CSUM_ENABLE)
                dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
-               if (DEFAULT_TSO_ENABLE)
-                       dev->net->features |= NETIF_F_SG |
-                               NETIF_F_TSO | NETIF_F_TSO6;
-       }
+
        if (DEFAULT_RX_CSUM_ENABLE)
                dev->net->features |= NETIF_F_RXCSUM;
 
        dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-               NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_RXCSUM;
+                               NETIF_F_RXCSUM;
 
        ret = smsc75xx_wait_ready(dev, 0);
        if (ret < 0) {
@@ -2200,8 +2196,6 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev,
 {
        u32 tx_cmd_a, tx_cmd_b;
 
-       skb_linearize(skb);
-
        if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) {
                struct sk_buff *skb2 =
                        skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags);
index 06ee82f557d45ba31b4847c187f57771ae2c73d2..e4811d7b5af1cb19aad389f231781cede61c3f81 100644 (file)
  * For high speed, each frame comfortably fits almost 36 max size
  * Ethernet packets (so queues should be bigger).
  *
- * REVISIT qlens should be members of 'struct usbnet'; the goal is to
- * let the USB host controller be busy for 5msec or more before an irq
- * is required, under load.  Jumbograms change the equation.
+ * The goal is to let the USB host controller be busy for 5msec or
+ * more before an irq is required, under load.  Jumbograms change
+ * the equation.
  */
-#define RX_MAX_QUEUE_MEMORY (60 * 1518)
-#define        RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
-                       (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
-#define        TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
-                       (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
+#define        MAX_QUEUE_MEMORY        (60 * 1518)
+#define        RX_QLEN(dev)            ((dev)->rx_qlen)
+#define        TX_QLEN(dev)            ((dev)->tx_qlen)
 
 // reawaken network queue this soon after stopping; else watchdog barks
 #define TX_TIMEOUT_JIFFIES     (5*HZ)
@@ -347,6 +345,31 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
 }
 EXPORT_SYMBOL_GPL(usbnet_skb_return);
 
+/* must be called if hard_mtu or rx_urb_size changed */
+void usbnet_update_max_qlen(struct usbnet *dev)
+{
+       enum usb_device_speed speed = dev->udev->speed;
+
+       switch (speed) {
+       case USB_SPEED_HIGH:
+               dev->rx_qlen = MAX_QUEUE_MEMORY / dev->rx_urb_size;
+               dev->tx_qlen = MAX_QUEUE_MEMORY / dev->hard_mtu;
+               break;
+       case USB_SPEED_SUPER:
+               /*
+                * Not take default 5ms qlen for super speed HC to
+                * save memory, and iperf tests show 2.5ms qlen can
+                * work well
+                */
+               dev->rx_qlen = 5 * MAX_QUEUE_MEMORY / dev->rx_urb_size;
+               dev->tx_qlen = 5 * MAX_QUEUE_MEMORY / dev->hard_mtu;
+               break;
+       default:
+               dev->rx_qlen = dev->tx_qlen = 4;
+       }
+}
+EXPORT_SYMBOL_GPL(usbnet_update_max_qlen);
+
 \f
 /*-------------------------------------------------------------------------
  *
@@ -375,6 +398,9 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu)
                        usbnet_unlink_rx_urbs(dev);
        }
 
+       /* max qlen depend on hard_mtu and rx_urb_size */
+       usbnet_update_max_qlen(dev);
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(usbnet_change_mtu);
@@ -843,6 +869,9 @@ int usbnet_open (struct net_device *net)
                goto done;
        }
 
+       /* hard_mtu or rx_urb_size may change in reset() */
+       usbnet_update_max_qlen(dev);
+
        // insist peer be connected
        if (info->check_connect && (retval = info->check_connect (dev)) < 0) {
                netif_dbg(dev, ifup, dev->net, "can't open; %d\n", retval);
@@ -927,6 +956,9 @@ int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
        if (dev->driver_info->link_reset)
                dev->driver_info->link_reset(dev);
 
+       /* hard_mtu or rx_urb_size may change in link_reset() */
+       usbnet_update_max_qlen(dev);
+
        return retval;
 
 }
@@ -1020,6 +1052,9 @@ static void __handle_link_change(struct usbnet *dev)
                tasklet_schedule(&dev->bh);
        }
 
+       /* hard_mtu or rx_urb_size may change during link change */
+       usbnet_update_max_qlen(dev);
+
        clear_bit(EVENT_LINK_CHANGE, &dev->flags);
 }
 
@@ -1599,6 +1634,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
        if ((dev->driver_info->flags & FLAG_WWAN) != 0)
                SET_NETDEV_DEVTYPE(net, &wwan_type);
 
+       /* initialize max rx_qlen and tx_qlen */
+       usbnet_update_max_qlen(dev);
+
        status = register_netdev (net);
        if (status)
                goto out4;
index da866523cf20097d57550c7357020e937782fd37..eee1f19ef1e9397469e343133490ec6972b4bbdc 100644 (file)
@@ -269,6 +269,7 @@ static void veth_setup(struct net_device *dev)
        dev->ethtool_ops = &veth_ethtool_ops;
        dev->features |= NETIF_F_LLTX;
        dev->features |= VETH_FEATURES;
+       dev->vlan_features = dev->features;
        dev->destructor = veth_dev_free;
 
        dev->hw_features = VETH_FEATURES;
index 3d2a90a626498d20c96ba7729beacec16b9b5040..f21600277583fac0b9e1a78065ccf588d8bc2f6d 100644 (file)
@@ -106,6 +106,9 @@ struct virtnet_info {
        /* Has control virtqueue */
        bool has_cvq;
 
+       /* Host can handle any s/g split between our header and packet data */
+       bool any_header_sg;
+
        /* enable config space updates */
        bool config_enable;
 
@@ -669,12 +672,28 @@ static void free_old_xmit_skbs(struct send_queue *sq)
 
 static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 {
-       struct skb_vnet_hdr *hdr = skb_vnet_hdr(skb);
+       struct skb_vnet_hdr *hdr;
        const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
        struct virtnet_info *vi = sq->vq->vdev->priv;
        unsigned num_sg;
+       unsigned hdr_len;
+       bool can_push;
 
        pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
+       if (vi->mergeable_rx_bufs)
+               hdr_len = sizeof hdr->mhdr;
+       else
+               hdr_len = sizeof hdr->hdr;
+
+       can_push = vi->any_header_sg &&
+               !((unsigned long)skb->data & (__alignof__(*hdr) - 1)) &&
+               !skb_header_cloned(skb) && skb_headroom(skb) >= hdr_len;
+       /* Even if we can, don't push here yet as this would skew
+        * csum_start offset below. */
+       if (can_push)
+               hdr = (struct skb_vnet_hdr *)(skb->data - hdr_len);
+       else
+               hdr = skb_vnet_hdr(skb);
 
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                hdr->hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
@@ -703,15 +722,18 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
                hdr->hdr.gso_size = hdr->hdr.hdr_len = 0;
        }
 
-       hdr->mhdr.num_buffers = 0;
-
-       /* Encode metadata header at front. */
        if (vi->mergeable_rx_bufs)
-               sg_set_buf(sq->sg, &hdr->mhdr, sizeof hdr->mhdr);
-       else
-               sg_set_buf(sq->sg, &hdr->hdr, sizeof hdr->hdr);
+               hdr->mhdr.num_buffers = 0;
 
-       num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;
+       if (can_push) {
+               __skb_push(skb, hdr_len);
+               num_sg = skb_to_sgvec(skb, sq->sg, 0, skb->len);
+               /* Pull header back to avoid skew in tx bytes calculations. */
+               __skb_pull(skb, hdr_len);
+       } else {
+               sg_set_buf(sq->sg, hdr, hdr_len);
+               num_sg = skb_to_sgvec(skb, sq->sg + 1, 0, skb->len) + 1;
+       }
        return virtqueue_add_outbuf(sq->vq, sq->sg, num_sg, skb, GFP_ATOMIC);
 }
 
@@ -1552,6 +1574,9 @@ static int virtnet_probe(struct virtio_device *vdev)
        if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
                vi->mergeable_rx_bufs = true;
 
+       if (virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT))
+               vi->any_header_sg = true;
+
        if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
                vi->has_cvq = true;
 
@@ -1727,6 +1752,7 @@ static unsigned int features[] = {
        VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
        VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
        VIRTIO_NET_F_CTRL_MAC_ADDR,
+       VIRTIO_F_ANY_LAYOUT,
 };
 
 static struct virtio_driver virtio_net_driver = {
index 55a62cae2cb4c976388a9b67dc20ad5c15832604..7e2788c488edce4536fa0039337b5b267d2dc270 100644 (file)
@@ -313,10 +313,10 @@ vmxnet3_unmap_tx_buf(struct vmxnet3_tx_buf_info *tbi,
                     struct pci_dev *pdev)
 {
        if (tbi->map_type == VMXNET3_MAP_SINGLE)
-               pci_unmap_single(pdev, tbi->dma_addr, tbi->len,
+               dma_unmap_single(&pdev->dev, tbi->dma_addr, tbi->len,
                                 PCI_DMA_TODEVICE);
        else if (tbi->map_type == VMXNET3_MAP_PAGE)
-               pci_unmap_page(pdev, tbi->dma_addr, tbi->len,
+               dma_unmap_page(&pdev->dev, tbi->dma_addr, tbi->len,
                               PCI_DMA_TODEVICE);
        else
                BUG_ON(tbi->map_type != VMXNET3_MAP_NONE);
@@ -429,25 +429,29 @@ vmxnet3_tq_destroy(struct vmxnet3_tx_queue *tq,
                   struct vmxnet3_adapter *adapter)
 {
        if (tq->tx_ring.base) {
-               pci_free_consistent(adapter->pdev, tq->tx_ring.size *
-                                   sizeof(struct Vmxnet3_TxDesc),
-                                   tq->tx_ring.base, tq->tx_ring.basePA);
+               dma_free_coherent(&adapter->pdev->dev, tq->tx_ring.size *
+                                 sizeof(struct Vmxnet3_TxDesc),
+                                 tq->tx_ring.base, tq->tx_ring.basePA);
                tq->tx_ring.base = NULL;
        }
        if (tq->data_ring.base) {
-               pci_free_consistent(adapter->pdev, tq->data_ring.size *
-                                   sizeof(struct Vmxnet3_TxDataDesc),
-                                   tq->data_ring.base, tq->data_ring.basePA);
+               dma_free_coherent(&adapter->pdev->dev, tq->data_ring.size *
+                                 sizeof(struct Vmxnet3_TxDataDesc),
+                                 tq->data_ring.base, tq->data_ring.basePA);
                tq->data_ring.base = NULL;
        }
        if (tq->comp_ring.base) {
-               pci_free_consistent(adapter->pdev, tq->comp_ring.size *
-                                   sizeof(struct Vmxnet3_TxCompDesc),
-                                   tq->comp_ring.base, tq->comp_ring.basePA);
+               dma_free_coherent(&adapter->pdev->dev, tq->comp_ring.size *
+                                 sizeof(struct Vmxnet3_TxCompDesc),
+                                 tq->comp_ring.base, tq->comp_ring.basePA);
                tq->comp_ring.base = NULL;
        }
-       kfree(tq->buf_info);
-       tq->buf_info = NULL;
+       if (tq->buf_info) {
+               dma_free_coherent(&adapter->pdev->dev,
+                                 tq->tx_ring.size * sizeof(tq->buf_info[0]),
+                                 tq->buf_info, tq->buf_info_pa);
+               tq->buf_info = NULL;
+       }
 }
 
 
@@ -496,37 +500,38 @@ static int
 vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
                  struct vmxnet3_adapter *adapter)
 {
+       size_t sz;
+
        BUG_ON(tq->tx_ring.base || tq->data_ring.base ||
               tq->comp_ring.base || tq->buf_info);
 
-       tq->tx_ring.base = pci_alloc_consistent(adapter->pdev, tq->tx_ring.size
-                          * sizeof(struct Vmxnet3_TxDesc),
-                          &tq->tx_ring.basePA);
+       tq->tx_ring.base = dma_alloc_coherent(&adapter->pdev->dev,
+                       tq->tx_ring.size * sizeof(struct Vmxnet3_TxDesc),
+                       &tq->tx_ring.basePA, GFP_KERNEL);
        if (!tq->tx_ring.base) {
                netdev_err(adapter->netdev, "failed to allocate tx ring\n");
                goto err;
        }
 
-       tq->data_ring.base = pci_alloc_consistent(adapter->pdev,
-                            tq->data_ring.size *
-                            sizeof(struct Vmxnet3_TxDataDesc),
-                            &tq->data_ring.basePA);
+       tq->data_ring.base = dma_alloc_coherent(&adapter->pdev->dev,
+                       tq->data_ring.size * sizeof(struct Vmxnet3_TxDataDesc),
+                       &tq->data_ring.basePA, GFP_KERNEL);
        if (!tq->data_ring.base) {
                netdev_err(adapter->netdev, "failed to allocate data ring\n");
                goto err;
        }
 
-       tq->comp_ring.base = pci_alloc_consistent(adapter->pdev,
-                            tq->comp_ring.size *
-                            sizeof(struct Vmxnet3_TxCompDesc),
-                            &tq->comp_ring.basePA);
+       tq->comp_ring.base = dma_alloc_coherent(&adapter->pdev->dev,
+                       tq->comp_ring.size * sizeof(struct Vmxnet3_TxCompDesc),
+                       &tq->comp_ring.basePA, GFP_KERNEL);
        if (!tq->comp_ring.base) {
                netdev_err(adapter->netdev, "failed to allocate tx comp ring\n");
                goto err;
        }
 
-       tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]),
-                              GFP_KERNEL);
+       sz = tq->tx_ring.size * sizeof(tq->buf_info[0]);
+       tq->buf_info = dma_zalloc_coherent(&adapter->pdev->dev, sz,
+                                          &tq->buf_info_pa, GFP_KERNEL);
        if (!tq->buf_info)
                goto err;
 
@@ -578,7 +583,8 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx,
                                        break;
                                }
 
-                               rbi->dma_addr = pci_map_single(adapter->pdev,
+                               rbi->dma_addr = dma_map_single(
+                                               &adapter->pdev->dev,
                                                rbi->skb->data, rbi->len,
                                                PCI_DMA_FROMDEVICE);
                        } else {
@@ -595,7 +601,8 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx,
                                        rq->stats.rx_buf_alloc_failure++;
                                        break;
                                }
-                               rbi->dma_addr = pci_map_page(adapter->pdev,
+                               rbi->dma_addr = dma_map_page(
+                                               &adapter->pdev->dev,
                                                rbi->page, 0, PAGE_SIZE,
                                                PCI_DMA_FROMDEVICE);
                        } else {
@@ -705,7 +712,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx,
 
                tbi = tq->buf_info + tq->tx_ring.next2fill;
                tbi->map_type = VMXNET3_MAP_SINGLE;
-               tbi->dma_addr = pci_map_single(adapter->pdev,
+               tbi->dma_addr = dma_map_single(&adapter->pdev->dev,
                                skb->data + buf_offset, buf_size,
                                PCI_DMA_TODEVICE);
 
@@ -1221,7 +1228,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
                                goto rcd_done;
                        }
 
-                       pci_unmap_single(adapter->pdev, rbi->dma_addr, rbi->len,
+                       dma_unmap_single(&adapter->pdev->dev, rbi->dma_addr,
+                                        rbi->len,
                                         PCI_DMA_FROMDEVICE);
 
 #ifdef VMXNET3_RSS
@@ -1233,7 +1241,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
                        /* Immediate refill */
                        rbi->skb = new_skb;
-                       rbi->dma_addr = pci_map_single(adapter->pdev,
+                       rbi->dma_addr = dma_map_single(&adapter->pdev->dev,
                                                       rbi->skb->data, rbi->len,
                                                       PCI_DMA_FROMDEVICE);
                        rxd->addr = cpu_to_le64(rbi->dma_addr);
@@ -1267,7 +1275,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
                        }
 
                        if (rcd->len) {
-                               pci_unmap_page(adapter->pdev,
+                               dma_unmap_page(&adapter->pdev->dev,
                                               rbi->dma_addr, rbi->len,
                                               PCI_DMA_FROMDEVICE);
 
@@ -1276,7 +1284,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
 
                        /* Immediate refill */
                        rbi->page = new_page;
-                       rbi->dma_addr = pci_map_page(adapter->pdev, rbi->page,
+                       rbi->dma_addr = dma_map_page(&adapter->pdev->dev,
+                                                    rbi->page,
                                                     0, PAGE_SIZE,
                                                     PCI_DMA_FROMDEVICE);
                        rxd->addr = cpu_to_le64(rbi->dma_addr);
@@ -1352,13 +1361,13 @@ vmxnet3_rq_cleanup(struct vmxnet3_rx_queue *rq,
 
                        if (rxd->btype == VMXNET3_RXD_BTYPE_HEAD &&
                                        rq->buf_info[ring_idx][i].skb) {
-                               pci_unmap_single(adapter->pdev, rxd->addr,
+                               dma_unmap_single(&adapter->pdev->dev, rxd->addr,
                                                 rxd->len, PCI_DMA_FROMDEVICE);
                                dev_kfree_skb(rq->buf_info[ring_idx][i].skb);
                                rq->buf_info[ring_idx][i].skb = NULL;
                        } else if (rxd->btype == VMXNET3_RXD_BTYPE_BODY &&
                                        rq->buf_info[ring_idx][i].page) {
-                               pci_unmap_page(adapter->pdev, rxd->addr,
+                               dma_unmap_page(&adapter->pdev->dev, rxd->addr,
                                               rxd->len, PCI_DMA_FROMDEVICE);
                                put_page(rq->buf_info[ring_idx][i].page);
                                rq->buf_info[ring_idx][i].page = NULL;
@@ -1400,25 +1409,31 @@ static void vmxnet3_rq_destroy(struct vmxnet3_rx_queue *rq,
        }
 
 
-       kfree(rq->buf_info[0]);
-
        for (i = 0; i < 2; i++) {
                if (rq->rx_ring[i].base) {
-                       pci_free_consistent(adapter->pdev, rq->rx_ring[i].size
-                                           * sizeof(struct Vmxnet3_RxDesc),
-                                           rq->rx_ring[i].base,
-                                           rq->rx_ring[i].basePA);
+                       dma_free_coherent(&adapter->pdev->dev,
+                                         rq->rx_ring[i].size
+                                         * sizeof(struct Vmxnet3_RxDesc),
+                                         rq->rx_ring[i].base,
+                                         rq->rx_ring[i].basePA);
                        rq->rx_ring[i].base = NULL;
                }
                rq->buf_info[i] = NULL;
        }
 
        if (rq->comp_ring.base) {
-               pci_free_consistent(adapter->pdev, rq->comp_ring.size *
-                                   sizeof(struct Vmxnet3_RxCompDesc),
-                                   rq->comp_ring.base, rq->comp_ring.basePA);
+               dma_free_coherent(&adapter->pdev->dev, rq->comp_ring.size
+                                 * sizeof(struct Vmxnet3_RxCompDesc),
+                                 rq->comp_ring.base, rq->comp_ring.basePA);
                rq->comp_ring.base = NULL;
        }
+
+       if (rq->buf_info[0]) {
+               size_t sz = sizeof(struct vmxnet3_rx_buf_info) *
+                       (rq->rx_ring[0].size + rq->rx_ring[1].size);
+               dma_free_coherent(&adapter->pdev->dev, sz, rq->buf_info[0],
+                                 rq->buf_info_pa);
+       }
 }
 
 
@@ -1503,8 +1518,10 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter)
        for (i = 0; i < 2; i++) {
 
                sz = rq->rx_ring[i].size * sizeof(struct Vmxnet3_RxDesc);
-               rq->rx_ring[i].base = pci_alloc_consistent(adapter->pdev, sz,
-                                                       &rq->rx_ring[i].basePA);
+               rq->rx_ring[i].base = dma_alloc_coherent(
+                                               &adapter->pdev->dev, sz,
+                                               &rq->rx_ring[i].basePA,
+                                               GFP_KERNEL);
                if (!rq->rx_ring[i].base) {
                        netdev_err(adapter->netdev,
                                   "failed to allocate rx ring %d\n", i);
@@ -1513,8 +1530,9 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter)
        }
 
        sz = rq->comp_ring.size * sizeof(struct Vmxnet3_RxCompDesc);
-       rq->comp_ring.base = pci_alloc_consistent(adapter->pdev, sz,
-                                                 &rq->comp_ring.basePA);
+       rq->comp_ring.base = dma_alloc_coherent(&adapter->pdev->dev, sz,
+                                               &rq->comp_ring.basePA,
+                                               GFP_KERNEL);
        if (!rq->comp_ring.base) {
                netdev_err(adapter->netdev, "failed to allocate rx comp ring\n");
                goto err;
@@ -1522,7 +1540,8 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter)
 
        sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size +
                                                   rq->rx_ring[1].size);
-       bi = kzalloc(sz, GFP_KERNEL);
+       bi = dma_zalloc_coherent(&adapter->pdev->dev, sz, &rq->buf_info_pa,
+                                GFP_KERNEL);
        if (!bi)
                goto err;
 
@@ -2005,6 +2024,7 @@ vmxnet3_set_mc(struct net_device *netdev)
        struct Vmxnet3_RxFilterConf *rxConf =
                                        &adapter->shared->devRead.rxFilterConf;
        u8 *new_table = NULL;
+       dma_addr_t new_table_pa = 0;
        u32 new_mode = VMXNET3_RXM_UCAST;
 
        if (netdev->flags & IFF_PROMISC) {
@@ -2028,8 +2048,12 @@ vmxnet3_set_mc(struct net_device *netdev)
                                new_mode |= VMXNET3_RXM_MCAST;
                                rxConf->mfTableLen = cpu_to_le16(
                                        netdev_mc_count(netdev) * ETH_ALEN);
-                               rxConf->mfTablePA = cpu_to_le64(virt_to_phys(
-                                                   new_table));
+                               new_table_pa = dma_map_single(
+                                                       &adapter->pdev->dev,
+                                                       new_table,
+                                                       rxConf->mfTableLen,
+                                                       PCI_DMA_TODEVICE);
+                               rxConf->mfTablePA = cpu_to_le64(new_table_pa);
                        } else {
                                netdev_info(netdev, "failed to copy mcast list"
                                            ", setting ALL_MULTI\n");
@@ -2056,7 +2080,11 @@ vmxnet3_set_mc(struct net_device *netdev)
                               VMXNET3_CMD_UPDATE_MAC_FILTERS);
        spin_unlock_irqrestore(&adapter->cmd_lock, flags);
 
-       kfree(new_table);
+       if (new_table) {
+               dma_unmap_single(&adapter->pdev->dev, new_table_pa,
+                                rxConf->mfTableLen, PCI_DMA_TODEVICE);
+               kfree(new_table);
+       }
 }
 
 void
@@ -2096,7 +2124,7 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
        devRead->misc.driverInfo.vmxnet3RevSpt = cpu_to_le32(1);
        devRead->misc.driverInfo.uptVerSpt = cpu_to_le32(1);
 
-       devRead->misc.ddPA = cpu_to_le64(virt_to_phys(adapter));
+       devRead->misc.ddPA = cpu_to_le64(adapter->adapter_pa);
        devRead->misc.ddLen = cpu_to_le32(sizeof(struct vmxnet3_adapter));
 
        /* set up feature flags */
@@ -2125,7 +2153,7 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
                tqc->txRingBasePA   = cpu_to_le64(tq->tx_ring.basePA);
                tqc->dataRingBasePA = cpu_to_le64(tq->data_ring.basePA);
                tqc->compRingBasePA = cpu_to_le64(tq->comp_ring.basePA);
-               tqc->ddPA           = cpu_to_le64(virt_to_phys(tq->buf_info));
+               tqc->ddPA           = cpu_to_le64(tq->buf_info_pa);
                tqc->txRingSize     = cpu_to_le32(tq->tx_ring.size);
                tqc->dataRingSize   = cpu_to_le32(tq->data_ring.size);
                tqc->compRingSize   = cpu_to_le32(tq->comp_ring.size);
@@ -2143,8 +2171,7 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
                rqc->rxRingBasePA[0] = cpu_to_le64(rq->rx_ring[0].basePA);
                rqc->rxRingBasePA[1] = cpu_to_le64(rq->rx_ring[1].basePA);
                rqc->compRingBasePA  = cpu_to_le64(rq->comp_ring.basePA);
-               rqc->ddPA            = cpu_to_le64(virt_to_phys(
-                                                       rq->buf_info));
+               rqc->ddPA            = cpu_to_le64(rq->buf_info_pa);
                rqc->rxRingSize[0]   = cpu_to_le32(rq->rx_ring[0].size);
                rqc->rxRingSize[1]   = cpu_to_le32(rq->rx_ring[1].size);
                rqc->compRingSize    = cpu_to_le32(rq->comp_ring.size);
@@ -2184,8 +2211,9 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
                                i, adapter->num_rx_queues);
 
                devRead->rssConfDesc.confVer = 1;
-               devRead->rssConfDesc.confLen = sizeof(*rssConf);
-               devRead->rssConfDesc.confPA  = virt_to_phys(rssConf);
+               devRead->rssConfDesc.confLen = cpu_to_le32(sizeof(*rssConf));
+               devRead->rssConfDesc.confPA =
+                       cpu_to_le64(adapter->rss_conf_pa);
        }
 
 #endif /* VMXNET3_RSS */
@@ -2948,9 +2976,13 @@ vmxnet3_probe_device(struct pci_dev *pdev,
        adapter->pdev = pdev;
 
        spin_lock_init(&adapter->cmd_lock);
-       adapter->shared = pci_alloc_consistent(adapter->pdev,
-                                              sizeof(struct Vmxnet3_DriverShared),
-                                              &adapter->shared_pa);
+       adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter,
+                                            sizeof(struct vmxnet3_adapter),
+                                            PCI_DMA_TODEVICE);
+       adapter->shared = dma_alloc_coherent(
+                               &adapter->pdev->dev,
+                               sizeof(struct Vmxnet3_DriverShared),
+                               &adapter->shared_pa, GFP_KERNEL);
        if (!adapter->shared) {
                dev_err(&pdev->dev, "Failed to allocate memory\n");
                err = -ENOMEM;
@@ -2963,8 +2995,9 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 
        size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
        size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues;
-       adapter->tqd_start = pci_alloc_consistent(adapter->pdev, size,
-                                                 &adapter->queue_desc_pa);
+       adapter->tqd_start = dma_alloc_coherent(&adapter->pdev->dev, size,
+                                               &adapter->queue_desc_pa,
+                                               GFP_KERNEL);
 
        if (!adapter->tqd_start) {
                dev_err(&pdev->dev, "Failed to allocate memory\n");
@@ -2974,7 +3007,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,
        adapter->rqd_start = (struct Vmxnet3_RxQueueDesc *)(adapter->tqd_start +
                                                            adapter->num_tx_queues);
 
-       adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL);
+       adapter->pm_conf = dma_alloc_coherent(&adapter->pdev->dev,
+                                             sizeof(struct Vmxnet3_PMConf),
+                                             &adapter->pm_conf_pa,
+                                             GFP_KERNEL);
        if (adapter->pm_conf == NULL) {
                err = -ENOMEM;
                goto err_alloc_pm;
@@ -2982,7 +3018,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 
 #ifdef VMXNET3_RSS
 
-       adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL);
+       adapter->rss_conf = dma_alloc_coherent(&adapter->pdev->dev,
+                                              sizeof(struct UPT1_RSSConf),
+                                              &adapter->rss_conf_pa,
+                                              GFP_KERNEL);
        if (adapter->rss_conf == NULL) {
                err = -ENOMEM;
                goto err_alloc_rss;
@@ -3077,17 +3116,22 @@ err_ver:
        vmxnet3_free_pci_resources(adapter);
 err_alloc_pci:
 #ifdef VMXNET3_RSS
-       kfree(adapter->rss_conf);
+       dma_free_coherent(&adapter->pdev->dev, sizeof(struct UPT1_RSSConf),
+                         adapter->rss_conf, adapter->rss_conf_pa);
 err_alloc_rss:
 #endif
-       kfree(adapter->pm_conf);
+       dma_free_coherent(&adapter->pdev->dev, sizeof(struct Vmxnet3_PMConf),
+                         adapter->pm_conf, adapter->pm_conf_pa);
 err_alloc_pm:
-       pci_free_consistent(adapter->pdev, size, adapter->tqd_start,
-                           adapter->queue_desc_pa);
+       dma_free_coherent(&adapter->pdev->dev, size, adapter->tqd_start,
+                         adapter->queue_desc_pa);
 err_alloc_queue_desc:
-       pci_free_consistent(adapter->pdev, sizeof(struct Vmxnet3_DriverShared),
-                           adapter->shared, adapter->shared_pa);
+       dma_free_coherent(&adapter->pdev->dev,
+                         sizeof(struct Vmxnet3_DriverShared),
+                         adapter->shared, adapter->shared_pa);
 err_alloc_shared:
+       dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa,
+                        sizeof(struct vmxnet3_adapter), PCI_DMA_TODEVICE);
        pci_set_drvdata(pdev, NULL);
        free_netdev(netdev);
        return err;
@@ -3118,16 +3162,21 @@ vmxnet3_remove_device(struct pci_dev *pdev)
        vmxnet3_free_intr_resources(adapter);
        vmxnet3_free_pci_resources(adapter);
 #ifdef VMXNET3_RSS
-       kfree(adapter->rss_conf);
+       dma_free_coherent(&adapter->pdev->dev, sizeof(struct UPT1_RSSConf),
+                         adapter->rss_conf, adapter->rss_conf_pa);
 #endif
-       kfree(adapter->pm_conf);
+       dma_free_coherent(&adapter->pdev->dev, sizeof(struct Vmxnet3_PMConf),
+                         adapter->pm_conf, adapter->pm_conf_pa);
 
        size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
        size += sizeof(struct Vmxnet3_RxQueueDesc) * num_rx_queues;
-       pci_free_consistent(adapter->pdev, size, adapter->tqd_start,
-                           adapter->queue_desc_pa);
-       pci_free_consistent(adapter->pdev, sizeof(struct Vmxnet3_DriverShared),
-                           adapter->shared, adapter->shared_pa);
+       dma_free_coherent(&adapter->pdev->dev, size, adapter->tqd_start,
+                         adapter->queue_desc_pa);
+       dma_free_coherent(&adapter->pdev->dev,
+                         sizeof(struct Vmxnet3_DriverShared),
+                         adapter->shared, adapter->shared_pa);
+       dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa,
+                        sizeof(struct vmxnet3_adapter), PCI_DMA_TODEVICE);
        free_netdev(netdev);
 }
 
@@ -3227,8 +3276,8 @@ skip_arp:
        adapter->shared->devRead.pmConfDesc.confVer = cpu_to_le32(1);
        adapter->shared->devRead.pmConfDesc.confLen = cpu_to_le32(sizeof(
                                                                  *pmConf));
-       adapter->shared->devRead.pmConfDesc.confPA = cpu_to_le64(virt_to_phys(
-                                                                pmConf));
+       adapter->shared->devRead.pmConfDesc.confPA =
+               cpu_to_le64(adapter->pm_conf_pa);
 
        spin_lock_irqsave(&adapter->cmd_lock, flags);
        VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
@@ -3265,8 +3314,8 @@ vmxnet3_resume(struct device *device)
        adapter->shared->devRead.pmConfDesc.confVer = cpu_to_le32(1);
        adapter->shared->devRead.pmConfDesc.confLen = cpu_to_le32(sizeof(
                                                                  *pmConf));
-       adapter->shared->devRead.pmConfDesc.confPA = cpu_to_le64(virt_to_phys(
-                                                                pmConf));
+       adapter->shared->devRead.pmConfDesc.confPA =
+               cpu_to_le64(adapter->pm_conf_pa);
 
        netif_device_attach(netdev);
        pci_set_power_state(pdev, PCI_D0);
index 35418146fa170100ec1f8aef59c123e6a5b908df..a03f358fd58b9a44fc480ea33c67adf28e3cf0ef 100644 (file)
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.1.30.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.2.0.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM      0x01011E00
+#define VMXNET3_DRIVER_VERSION_NUM      0x01020000
 
 #if defined(CONFIG_PCI_MSI)
        /* RSS only makes sense if MSI-X is supported. */
@@ -229,6 +229,7 @@ struct vmxnet3_tx_queue {
        spinlock_t                      tx_lock;
        struct vmxnet3_cmd_ring         tx_ring;
        struct vmxnet3_tx_buf_info      *buf_info;
+       dma_addr_t                       buf_info_pa;
        struct vmxnet3_tx_data_ring     data_ring;
        struct vmxnet3_comp_ring        comp_ring;
        struct Vmxnet3_TxQueueCtrl      *shared;
@@ -277,6 +278,7 @@ struct vmxnet3_rx_queue {
        u32 qid;            /* rqID in RCD for buffer from 1st ring */
        u32 qid2;           /* rqID in RCD for buffer from 2nd ring */
        struct vmxnet3_rx_buf_info     *buf_info[2];
+       dma_addr_t                      buf_info_pa;
        struct Vmxnet3_RxQueueCtrl            *shared;
        struct vmxnet3_rq_driver_stats  stats;
 } __attribute__((__aligned__(SMP_CACHE_BYTES)));
@@ -353,6 +355,10 @@ struct vmxnet3_adapter {
        unsigned long  state;    /* VMXNET3_STATE_BIT_xxx */
 
        int share_intr;
+
+       dma_addr_t adapter_pa;
+       dma_addr_t pm_conf_pa;
+       dma_addr_t rss_conf_pa;
 };
 
 #define VMXNET3_WRITE_BAR0_REG(adapter, reg, val)  \
index 0ba1e7edbb1b443d8fe34a685baf4fe934c91175..3b21aca0c0c249c6a6e3392d78b47e03fd7d9006 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/igmp.h>
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h>
+#include <linux/if_vlan.h>
 #include <linux/hash.h>
 #include <linux/ethtool.h>
 #include <net/arp.h>
@@ -41,6 +42,7 @@
 #include <net/inet_ecn.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
+#include <net/vxlan.h>
 
 #define VXLAN_VERSION  "0.1"
 
@@ -57,6 +59,7 @@
 #define VXLAN_VID_MASK (VXLAN_N_VID - 1)
 /* IP header + UDP + VXLAN + Ethernet header */
 #define VXLAN_HEADROOM (20 + 8 + 8 + 14)
+#define VXLAN_HLEN (sizeof(struct udphdr) + sizeof(struct vxlanhdr))
 
 #define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
 
@@ -82,16 +85,6 @@ static int vxlan_net_id;
 
 static const u8 all_zeros_mac[ETH_ALEN];
 
-/* per UDP socket information */
-struct vxlan_sock {
-       struct hlist_node hlist;
-       struct rcu_head   rcu;
-       struct work_struct del_work;
-       atomic_t          refcnt;
-       struct socket     *sock;
-       struct hlist_head vni_list[VNI_HASH_SIZE];
-};
-
 /* per-network namespace private data for this module */
 struct vxlan_net {
        struct list_head  vxlan_list;
@@ -136,7 +129,8 @@ struct vxlan_dev {
        u32               flags;        /* VXLAN_F_* below */
 
        struct work_struct sock_work;
-       struct work_struct igmp_work;
+       struct work_struct igmp_join;
+       struct work_struct igmp_leave;
 
        unsigned long     age_interval;
        struct timer_list age_timer;
@@ -176,13 +170,18 @@ static inline struct hlist_head *vs_head(struct net *net, __be16 port)
 /* First remote destination for a forwarding entry.
  * Guaranteed to be non-NULL because remotes are never deleted.
  */
-static inline struct vxlan_rdst *first_remote(struct vxlan_fdb *fdb)
+static inline struct vxlan_rdst *first_remote_rcu(struct vxlan_fdb *fdb)
 {
-       return list_first_or_null_rcu(&fdb->remotes, struct vxlan_rdst, list);
+       return list_entry_rcu(fdb->remotes.next, struct vxlan_rdst, list);
+}
+
+static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb)
+{
+       return list_first_entry(&fdb->remotes, struct vxlan_rdst, list);
 }
 
 /* Find VXLAN socket based on network namespace and UDP port */
-static struct vxlan_sock *vxlan_find_port(struct net *net, __be16 port)
+static struct vxlan_sock *vxlan_find_sock(struct net *net, __be16 port)
 {
        struct vxlan_sock *vs;
 
@@ -193,16 +192,10 @@ static struct vxlan_sock *vxlan_find_port(struct net *net, __be16 port)
        return NULL;
 }
 
-/* Look up VNI in a per net namespace table */
-static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, __be16 port)
+static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, u32 id)
 {
-       struct vxlan_sock *vs;
        struct vxlan_dev *vxlan;
 
-       vs = vxlan_find_port(net, port);
-       if (!vs)
-               return NULL;
-
        hlist_for_each_entry_rcu(vxlan, vni_head(vs, id), hlist) {
                if (vxlan->default_dst.remote_vni == id)
                        return vxlan;
@@ -211,6 +204,18 @@ static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, __be16 port)
        return NULL;
 }
 
+/* Look up VNI in a per net namespace table */
+static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, __be16 port)
+{
+       struct vxlan_sock *vs;
+
+       vs = vxlan_find_sock(net, port);
+       if (!vs)
+               return NULL;
+
+       return vxlan_vs_find_vni(vs, id);
+}
+
 /* Fill in neighbour message in skbuff. */
 static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
                          const struct vxlan_fdb *fdb,
@@ -296,7 +301,8 @@ static void vxlan_fdb_notify(struct vxlan_dev *vxlan,
        if (skb == NULL)
                goto errout;
 
-       err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0, first_remote(fdb));
+       err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0,
+                            first_remote_rtnl(fdb));
        if (err < 0) {
                /* -EMSGSIZE implies BUG in vxlan_nlmsg_size() */
                WARN_ON(err == -EMSGSIZE);
@@ -407,6 +413,26 @@ static struct vxlan_rdst *vxlan_fdb_find_rdst(struct vxlan_fdb *f,
        return NULL;
 }
 
+/* Replace destination of unicast mac */
+static int vxlan_fdb_replace(struct vxlan_fdb *f,
+                           __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
+{
+       struct vxlan_rdst *rd;
+
+       rd = vxlan_fdb_find_rdst(f, ip, port, vni, ifindex);
+       if (rd)
+               return 0;
+
+       rd = list_first_entry_or_null(&f->remotes, struct vxlan_rdst, list);
+       if (!rd)
+               return 0;
+       rd->remote_ip = ip;
+       rd->remote_port = port;
+       rd->remote_vni = vni;
+       rd->remote_ifindex = ifindex;
+       return 1;
+}
+
 /* Add/update destinations for multicast */
 static int vxlan_fdb_append(struct vxlan_fdb *f,
                            __be32 ip, __be16 port, __u32 vni, __u32 ifindex)
@@ -457,6 +483,19 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
                        f->updated = jiffies;
                        notify = 1;
                }
+               if ((flags & NLM_F_REPLACE)) {
+                       /* Only change unicasts */
+                       if (!(is_multicast_ether_addr(f->eth_addr) ||
+                            is_zero_ether_addr(f->eth_addr))) {
+                               int rc = vxlan_fdb_replace(f, ip, port, vni,
+                                                          ifindex);
+
+                               if (rc < 0)
+                                       return rc;
+                               notify |= rc;
+                       } else
+                               return -EOPNOTSUPP;
+               }
                if ((flags & NLM_F_APPEND) &&
                    (is_multicast_ether_addr(f->eth_addr) ||
                     is_zero_ether_addr(f->eth_addr))) {
@@ -473,6 +512,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
                if (vxlan->addrmax && vxlan->addrcnt >= vxlan->addrmax)
                        return -ENOSPC;
 
+               /* Disallow replace to add a multicast entry */
+               if ((flags & NLM_F_REPLACE) &&
+                   (is_multicast_ether_addr(mac) || is_zero_ether_addr(mac)))
+                       return -EOPNOTSUPP;
+
                netdev_dbg(vxlan->dev, "add %pM -> %pI4\n", mac, &ip);
                f = kmalloc(sizeof(*f), GFP_ATOMIC);
                if (!f)
@@ -498,12 +542,6 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
        return 0;
 }
 
-static void vxlan_fdb_free_rdst(struct rcu_head *head)
-{
-       struct vxlan_rdst *rd = container_of(head, struct vxlan_rdst, rcu);
-       kfree(rd);
-}
-
 static void vxlan_fdb_free(struct rcu_head *head)
 {
        struct vxlan_fdb *f = container_of(head, struct vxlan_fdb, rcu);
@@ -643,7 +681,7 @@ static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
         */
        if (rd && !list_is_singular(&f->remotes)) {
                list_del_rcu(&rd->list);
-               call_rcu(&rd->rcu, vxlan_fdb_free_rdst);
+               kfree_rcu(rd, rcu);
                goto out;
        }
 
@@ -701,7 +739,7 @@ static bool vxlan_snoop(struct net_device *dev,
 
        f = vxlan_find_mac(vxlan, src_mac);
        if (likely(f)) {
-               struct vxlan_rdst *rdst = first_remote(f);
+               struct vxlan_rdst *rdst = first_remote_rcu(f);
 
                if (likely(rdst->remote_ip == src_ip))
                        return false;
@@ -736,7 +774,6 @@ static bool vxlan_snoop(struct net_device *dev,
        return false;
 }
 
-
 /* See if multicast group is already in use by other ID */
 static bool vxlan_group_used(struct vxlan_net *vn, __be32 remote_ip)
 {
@@ -758,8 +795,10 @@ static void vxlan_sock_hold(struct vxlan_sock *vs)
        atomic_inc(&vs->refcnt);
 }
 
-static void vxlan_sock_release(struct vxlan_net *vn, struct vxlan_sock *vs)
+void vxlan_sock_release(struct vxlan_sock *vs)
 {
+       struct vxlan_net *vn = net_generic(sock_net(vs->sock->sk), vxlan_net_id);
+
        if (!atomic_dec_and_test(&vs->refcnt))
                return;
 
@@ -769,14 +808,15 @@ static void vxlan_sock_release(struct vxlan_net *vn, struct vxlan_sock *vs)
 
        queue_work(vxlan_wq, &vs->del_work);
 }
+EXPORT_SYMBOL_GPL(vxlan_sock_release);
 
-/* Callback to update multicast group membership.
- * Scheduled when vxlan goes up/down.
+/* Callback to update multicast group membership when first VNI on
+ * multicast asddress is brought up
+ * Done as workqueue because ip_mc_join_group acquires RTNL.
  */
-static void vxlan_igmp_work(struct work_struct *work)
+static void vxlan_igmp_join(struct work_struct *work)
 {
-       struct vxlan_dev *vxlan = container_of(work, struct vxlan_dev, igmp_work);
-       struct vxlan_net *vn = net_generic(dev_net(vxlan->dev), vxlan_net_id);
+       struct vxlan_dev *vxlan = container_of(work, struct vxlan_dev, igmp_join);
        struct vxlan_sock *vs = vxlan->vn_sock;
        struct sock *sk = vs->sock->sk;
        struct ip_mreqn mreq = {
@@ -785,36 +825,45 @@ static void vxlan_igmp_work(struct work_struct *work)
        };
 
        lock_sock(sk);
-       if (vxlan_group_used(vn, vxlan->default_dst.remote_ip))
-               ip_mc_join_group(sk, &mreq);
-       else
-               ip_mc_leave_group(sk, &mreq);
+       ip_mc_join_group(sk, &mreq);
+       release_sock(sk);
+
+       vxlan_sock_release(vs);
+       dev_put(vxlan->dev);
+}
+
+/* Inverse of vxlan_igmp_join when last VNI is brought down */
+static void vxlan_igmp_leave(struct work_struct *work)
+{
+       struct vxlan_dev *vxlan = container_of(work, struct vxlan_dev, igmp_leave);
+       struct vxlan_sock *vs = vxlan->vn_sock;
+       struct sock *sk = vs->sock->sk;
+       struct ip_mreqn mreq = {
+               .imr_multiaddr.s_addr   = vxlan->default_dst.remote_ip,
+               .imr_ifindex            = vxlan->default_dst.remote_ifindex,
+       };
+
+       lock_sock(sk);
+       ip_mc_leave_group(sk, &mreq);
        release_sock(sk);
 
-       vxlan_sock_release(vn, vs);
+       vxlan_sock_release(vs);
        dev_put(vxlan->dev);
 }
 
 /* Callback from net/ipv4/udp.c to receive packets */
 static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
 {
-       struct iphdr *oip;
+       struct vxlan_sock *vs;
        struct vxlanhdr *vxh;
-       struct vxlan_dev *vxlan;
-       struct pcpu_tstats *stats;
        __be16 port;
-       __u32 vni;
-       int err;
-
-       /* pop off outer UDP header */
-       __skb_pull(skb, sizeof(struct udphdr));
 
        /* Need Vxlan and inner Ethernet header to be present */
-       if (!pskb_may_pull(skb, sizeof(struct vxlanhdr)))
+       if (!pskb_may_pull(skb, VXLAN_HLEN))
                goto error;
 
-       /* Drop packets with reserved bits set */
-       vxh = (struct vxlanhdr *) skb->data;
+       /* Return packets with reserved bits set */
+       vxh = (struct vxlanhdr *)(udp_hdr(skb) + 1);
        if (vxh->vx_flags != htonl(VXLAN_FLAGS) ||
            (vxh->vx_vni & htonl(0xff))) {
                netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
@@ -822,28 +871,44 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
                goto error;
        }
 
-       __skb_pull(skb, sizeof(struct vxlanhdr));
+       if (iptunnel_pull_header(skb, VXLAN_HLEN, htons(ETH_P_TEB)))
+               goto drop;
 
-       /* Is this VNI defined? */
-       vni = ntohl(vxh->vx_vni) >> 8;
        port = inet_sk(sk)->inet_sport;
-       vxlan = vxlan_find_vni(sock_net(sk), vni, port);
-       if (!vxlan) {
-               netdev_dbg(skb->dev, "unknown vni %d port %u\n",
-                          vni, ntohs(port));
+
+       vs = vxlan_find_sock(sock_net(sk), port);
+       if (!vs)
                goto drop;
-       }
 
-       if (!pskb_may_pull(skb, ETH_HLEN)) {
-               vxlan->dev->stats.rx_length_errors++;
-               vxlan->dev->stats.rx_errors++;
+       vs->rcv(vs, skb, vxh->vx_vni);
+       return 0;
+
+drop:
+       /* Consume bad packet */
+       kfree_skb(skb);
+       return 0;
+
+error:
+       /* Return non vxlan pkt */
+       return 1;
+}
+
+static void vxlan_rcv(struct vxlan_sock *vs,
+                     struct sk_buff *skb, __be32 vx_vni)
+{
+       struct iphdr *oip;
+       struct vxlan_dev *vxlan;
+       struct pcpu_tstats *stats;
+       __u32 vni;
+       int err;
+
+       vni = ntohl(vx_vni) >> 8;
+       /* Is this VNI defined? */
+       vxlan = vxlan_vs_find_vni(vs, vni);
+       if (!vxlan)
                goto drop;
-       }
 
        skb_reset_mac_header(skb);
-
-       /* Re-examine inner Ethernet packet */
-       oip = ip_hdr(skb);
        skb->protocol = eth_type_trans(skb, vxlan->dev);
 
        /* Ignore packet loops (and multicast echo) */
@@ -851,11 +916,12 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
                               vxlan->dev->dev_addr) == 0)
                goto drop;
 
+       /* Re-examine inner Ethernet packet */
+       oip = ip_hdr(skb);
        if ((vxlan->flags & VXLAN_F_LEARN) &&
            vxlan_snoop(skb->dev, oip->saddr, eth_hdr(skb)->h_source))
                goto drop;
 
-       __skb_tunnel_rx(skb, vxlan->dev);
        skb_reset_network_header(skb);
 
        /* If the NIC driver gave us an encapsulated packet with
@@ -889,16 +955,10 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
 
        netif_rx(skb);
 
-       return 0;
-error:
-       /* Put UDP header back */
-       __skb_push(skb, sizeof(struct udphdr));
-
-       return 1;
+       return;
 drop:
        /* Consume bad packet */
        kfree_skb(skb);
-       return 0;
 }
 
 static int arp_reduce(struct net_device *dev, struct sk_buff *skb)
@@ -949,7 +1009,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb)
                }
 
                f = vxlan_find_mac(vxlan, n->ha);
-               if (f && first_remote(f)->remote_ip == htonl(INADDR_ANY)) {
+               if (f && first_remote_rcu(f)->remote_ip == htonl(INADDR_ANY)) {
                        /* bridge-local neighbor */
                        neigh_release(n);
                        goto out;
@@ -1017,11 +1077,8 @@ static void vxlan_sock_put(struct sk_buff *skb)
 }
 
 /* On transmit, associate with the tunnel socket */
-static void vxlan_set_owner(struct net_device *dev, struct sk_buff *skb)
+static void vxlan_set_owner(struct sock *sk, struct sk_buff *skb)
 {
-       struct vxlan_dev *vxlan = netdev_priv(dev);
-       struct sock *sk = vxlan->vn_sock->sock->sk;
-
        skb_orphan(skb);
        sock_hold(sk);
        skb->sk = sk;
@@ -1033,9 +1090,9 @@ static void vxlan_set_owner(struct net_device *dev, struct sk_buff *skb)
  *     better and maybe available from hardware
  *   secondary choice is to use jhash on the Ethernet header
  */
-static __be16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb)
+__be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb)
 {
-       unsigned int range = (vxlan->port_max - vxlan->port_min) + 1;
+       unsigned int range = (port_max - port_min) + 1;
        u32 hash;
 
        hash = skb_get_rxhash(skb);
@@ -1043,8 +1100,9 @@ static __be16 vxlan_src_port(const struct vxlan_dev *vxlan, struct sk_buff *skb)
                hash = jhash(skb->data, 2 * ETH_ALEN,
                             (__force u32) skb->protocol);
 
-       return htons((((u64) hash * range) >> 32) + vxlan->port_min);
+       return htons((((u64) hash * range) >> 32) + port_min);
 }
+EXPORT_SYMBOL_GPL(vxlan_src_port);
 
 static int handle_offloads(struct sk_buff *skb)
 {
@@ -1060,6 +1118,64 @@ static int handle_offloads(struct sk_buff *skb)
        return 0;
 }
 
+int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,
+                  struct rtable *rt, struct sk_buff *skb,
+                  __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
+                  __be16 src_port, __be16 dst_port, __be32 vni)
+{
+       struct vxlanhdr *vxh;
+       struct udphdr *uh;
+       int min_headroom;
+       int err;
+
+       if (!skb->encapsulation) {
+               skb_reset_inner_headers(skb);
+               skb->encapsulation = 1;
+       }
+
+       min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len
+                       + VXLAN_HLEN + sizeof(struct iphdr)
+                       + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
+
+       /* Need space for new headers (invalidates iph ptr) */
+       err = skb_cow_head(skb, min_headroom);
+       if (unlikely(err))
+               return err;
+
+       if (vlan_tx_tag_present(skb)) {
+               if (WARN_ON(!__vlan_put_tag(skb,
+                                           skb->vlan_proto,
+                                           vlan_tx_tag_get(skb))))
+                       return -ENOMEM;
+
+               skb->vlan_tci = 0;
+       }
+
+       vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
+       vxh->vx_flags = htonl(VXLAN_FLAGS);
+       vxh->vx_vni = vni;
+
+       __skb_push(skb, sizeof(*uh));
+       skb_reset_transport_header(skb);
+       uh = udp_hdr(skb);
+
+       uh->dest = dst_port;
+       uh->source = src_port;
+
+       uh->len = htons(skb->len);
+       uh->check = 0;
+
+       vxlan_set_owner(vs->sock->sk, skb);
+
+       err = handle_offloads(skb);
+       if (err)
+               return err;
+
+       return iptunnel_xmit(net, rt, skb, src, dst,
+                       IPPROTO_UDP, tos, ttl, df);
+}
+EXPORT_SYMBOL_GPL(vxlan_xmit_skb);
+
 /* Bypass encapsulation if the destination is local */
 static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
                               struct vxlan_dev *dst_vxlan)
@@ -1097,8 +1213,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
        struct vxlan_dev *vxlan = netdev_priv(dev);
        struct rtable *rt;
        const struct iphdr *old_iph;
-       struct vxlanhdr *vxh;
-       struct udphdr *uh;
        struct flowi4 fl4;
        __be32 dst;
        __be16 src_port, dst_port;
@@ -1120,15 +1234,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
                goto drop;
        }
 
-       if (!skb->encapsulation) {
-               skb_reset_inner_headers(skb);
-               skb->encapsulation = 1;
-       }
-
-       /* Need space for new headers (invalidates iph ptr) */
-       if (skb_cow_head(skb, VXLAN_HEADROOM))
-               goto drop;
-
        old_iph = ip_hdr(skb);
 
        ttl = vxlan->ttl;
@@ -1139,7 +1244,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
        if (tos == 1)
                tos = ip_tunnel_get_dsfield(old_iph, skb);
 
-       src_port = vxlan_src_port(vxlan, skb);
+       src_port = vxlan_src_port(vxlan->port_min, vxlan->port_max, skb);
 
        memset(&fl4, 0, sizeof(fl4));
        fl4.flowi4_oif = rdst->remote_ifindex;
@@ -1156,9 +1261,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
 
        if (rt->dst.dev == dev) {
                netdev_dbg(dev, "circular route to %pI4\n", &dst);
-               ip_rt_put(rt);
                dev->stats.collisions++;
-               goto tx_error;
+               goto rt_tx_error;
        }
 
        /* Bypass encapsulation if the destination is local */
@@ -1173,30 +1277,16 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
                vxlan_encap_bypass(skb, vxlan, dst_vxlan);
                return;
        }
-       vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
-       vxh->vx_flags = htonl(VXLAN_FLAGS);
-       vxh->vx_vni = htonl(vni << 8);
-
-       __skb_push(skb, sizeof(*uh));
-       skb_reset_transport_header(skb);
-       uh = udp_hdr(skb);
-
-       uh->dest = dst_port;
-       uh->source = src_port;
-
-       uh->len = htons(skb->len);
-       uh->check = 0;
-
-       vxlan_set_owner(dev, skb);
-
-       if (handle_offloads(skb))
-               goto drop;
 
        tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
        ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
 
-       err = iptunnel_xmit(dev_net(dev), rt, skb, fl4.saddr, dst,
-                           IPPROTO_UDP, tos, ttl, df);
+       err = vxlan_xmit_skb(dev_net(dev), vxlan->vn_sock, rt, skb,
+                            fl4.saddr, dst, tos, ttl, df,
+                            src_port, dst_port, htonl(vni << 8));
+
+       if (err < 0)
+               goto rt_tx_error;
        iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
 
        return;
@@ -1205,6 +1295,8 @@ drop:
        dev->stats.tx_dropped++;
        goto tx_free;
 
+rt_tx_error:
+       ip_rt_put(rt);
 tx_error:
        dev->stats.tx_errors++;
 tx_free:
@@ -1303,25 +1395,31 @@ static void vxlan_cleanup(unsigned long arg)
        mod_timer(&vxlan->age_timer, next_timer);
 }
 
+static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan)
+{
+       __u32 vni = vxlan->default_dst.remote_vni;
+
+       vxlan->vn_sock = vs;
+       hlist_add_head_rcu(&vxlan->hlist, vni_head(vs, vni));
+}
+
 /* Setup stats when device is created */
 static int vxlan_init(struct net_device *dev)
 {
        struct vxlan_dev *vxlan = netdev_priv(dev);
        struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
        struct vxlan_sock *vs;
-       __u32 vni = vxlan->default_dst.remote_vni;
 
        dev->tstats = alloc_percpu(struct pcpu_tstats);
        if (!dev->tstats)
                return -ENOMEM;
 
        spin_lock(&vn->sock_lock);
-       vs = vxlan_find_port(dev_net(dev), vxlan->dst_port);
+       vs = vxlan_find_sock(dev_net(dev), vxlan->dst_port);
        if (vs) {
                /* If we have a socket with same port already, reuse it */
                atomic_inc(&vs->refcnt);
-               vxlan->vn_sock = vs;
-               hlist_add_head_rcu(&vxlan->hlist, vni_head(vs, vni));
+               vxlan_vs_add_dev(vs, vxlan);
        } else {
                /* otherwise make new socket outside of RTNL */
                dev_hold(dev);
@@ -1346,19 +1444,19 @@ static void vxlan_fdb_delete_default(struct vxlan_dev *vxlan)
 static void vxlan_uninit(struct net_device *dev)
 {
        struct vxlan_dev *vxlan = netdev_priv(dev);
-       struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
        struct vxlan_sock *vs = vxlan->vn_sock;
 
        vxlan_fdb_delete_default(vxlan);
 
        if (vs)
-               vxlan_sock_release(vn, vs);
+               vxlan_sock_release(vs);
        free_percpu(dev->tstats);
 }
 
 /* Start ageing timer and join group when device is brought up */
 static int vxlan_open(struct net_device *dev)
 {
+       struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
        struct vxlan_dev *vxlan = netdev_priv(dev);
        struct vxlan_sock *vs = vxlan->vn_sock;
 
@@ -1366,10 +1464,11 @@ static int vxlan_open(struct net_device *dev)
        if (!vs)
                return -ENOTCONN;
 
-       if (IN_MULTICAST(ntohl(vxlan->default_dst.remote_ip))) {
+       if (IN_MULTICAST(ntohl(vxlan->default_dst.remote_ip)) &&
+           vxlan_group_used(vn, vxlan->default_dst.remote_ip)) {
                vxlan_sock_hold(vs);
                dev_hold(dev);
-               queue_work(vxlan_wq, &vxlan->igmp_work);
+               queue_work(vxlan_wq, &vxlan->igmp_join);
        }
 
        if (vxlan->age_interval)
@@ -1400,13 +1499,15 @@ static void vxlan_flush(struct vxlan_dev *vxlan)
 /* Cleanup timer and forwarding table on shutdown */
 static int vxlan_stop(struct net_device *dev)
 {
+       struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
        struct vxlan_dev *vxlan = netdev_priv(dev);
        struct vxlan_sock *vs = vxlan->vn_sock;
 
-       if (vs && IN_MULTICAST(ntohl(vxlan->default_dst.remote_ip))) {
+       if (vs && IN_MULTICAST(ntohl(vxlan->default_dst.remote_ip)) &&
+           ! vxlan_group_used(vn, vxlan->default_dst.remote_ip)) {
                vxlan_sock_hold(vs);
                dev_hold(dev);
-               queue_work(vxlan_wq, &vxlan->igmp_work);
+               queue_work(vxlan_wq, &vxlan->igmp_leave);
        }
 
        del_timer_sync(&vxlan->age_timer);
@@ -1464,14 +1565,18 @@ static void vxlan_setup(struct net_device *dev)
        dev->features   |= NETIF_F_RXCSUM;
        dev->features   |= NETIF_F_GSO_SOFTWARE;
 
+       dev->vlan_features = dev->features;
+       dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
        dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
        dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+       dev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
        dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
        dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
 
        INIT_LIST_HEAD(&vxlan->next);
        spin_lock_init(&vxlan->hash_lock);
-       INIT_WORK(&vxlan->igmp_work, vxlan_igmp_work);
+       INIT_WORK(&vxlan->igmp_join, vxlan_igmp_join);
+       INIT_WORK(&vxlan->igmp_leave, vxlan_igmp_leave);
        INIT_WORK(&vxlan->sock_work, vxlan_sock_work);
 
        init_timer_deferrable(&vxlan->age_timer);
@@ -1564,8 +1669,10 @@ static void vxlan_del_work(struct work_struct *work)
        kfree_rcu(vs, rcu);
 }
 
-static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port)
+static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
+                                             vxlan_rcv_t *rcv, void *data)
 {
+       struct vxlan_net *vn = net_generic(net, vxlan_net_id);
        struct vxlan_sock *vs;
        struct sock *sk;
        struct sockaddr_in vxlan_addr = {
@@ -1577,8 +1684,10 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port)
        unsigned int h;
 
        vs = kmalloc(sizeof(*vs), GFP_KERNEL);
-       if (!vs)
+       if (!vs) {
+               pr_debug("memory alocation failure\n");
                return ERR_PTR(-ENOMEM);
+       }
 
        for (h = 0; h < VNI_HASH_SIZE; ++h)
                INIT_HLIST_HEAD(&vs->vni_list[h]);
@@ -1606,57 +1715,70 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port)
                kfree(vs);
                return ERR_PTR(rc);
        }
+       atomic_set(&vs->refcnt, 1);
+       vs->rcv = rcv;
+       vs->data = data;
 
        /* Disable multicast loopback */
        inet_sk(sk)->mc_loop = 0;
+       spin_lock(&vn->sock_lock);
+       hlist_add_head_rcu(&vs->hlist, vs_head(net, port));
+       spin_unlock(&vn->sock_lock);
 
        /* Mark socket as an encapsulation socket. */
        udp_sk(sk)->encap_type = 1;
        udp_sk(sk)->encap_rcv = vxlan_udp_encap_recv;
        udp_encap_enable();
-       atomic_set(&vs->refcnt, 1);
+       return vs;
+}
+
+struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
+                                 vxlan_rcv_t *rcv, void *data,
+                                 bool no_share)
+{
+       struct vxlan_net *vn = net_generic(net, vxlan_net_id);
+       struct vxlan_sock *vs;
+
+       vs = vxlan_socket_create(net, port, rcv, data);
+       if (!IS_ERR(vs))
+               return vs;
+
+       if (no_share)   /* Return error if sharing is not allowed. */
+               return vs;
+
+       spin_lock(&vn->sock_lock);
+       vs = vxlan_find_sock(net, port);
+       if (vs) {
+               if (vs->rcv == rcv)
+                       atomic_inc(&vs->refcnt);
+               else
+                       vs = ERR_PTR(-EBUSY);
+       }
+       spin_unlock(&vn->sock_lock);
+
+       if (!vs)
+               vs = ERR_PTR(-EINVAL);
 
        return vs;
 }
+EXPORT_SYMBOL_GPL(vxlan_sock_add);
 
 /* Scheduled at device creation to bind to a socket */
 static void vxlan_sock_work(struct work_struct *work)
 {
-       struct vxlan_dev *vxlan
-               = container_of(work, struct vxlan_dev, sock_work);
-       struct net_device *dev = vxlan->dev;
-       struct net *net = dev_net(dev);
-       __u32 vni = vxlan->default_dst.remote_vni;
-       __be16 port = vxlan->dst_port;
+       struct vxlan_dev *vxlan = container_of(work, struct vxlan_dev, sock_work);
+       struct net *net = dev_net(vxlan->dev);
        struct vxlan_net *vn = net_generic(net, vxlan_net_id);
-       struct vxlan_sock *nvs, *ovs;
-
-       nvs = vxlan_socket_create(net, port);
-       if (IS_ERR(nvs)) {
-               netdev_err(vxlan->dev, "Can not create UDP socket, %ld\n",
-                          PTR_ERR(nvs));
-               goto out;
-       }
+       __be16 port = vxlan->dst_port;
+       struct vxlan_sock *nvs;
 
+       nvs = vxlan_sock_add(net, port, vxlan_rcv, NULL, false);
        spin_lock(&vn->sock_lock);
-       /* Look again to see if can reuse socket */
-       ovs = vxlan_find_port(net, port);
-       if (ovs) {
-               atomic_inc(&ovs->refcnt);
-               vxlan->vn_sock = ovs;
-               hlist_add_head_rcu(&vxlan->hlist, vni_head(ovs, vni));
-               spin_unlock(&vn->sock_lock);
-
-               sk_release_kernel(nvs->sock->sk);
-               kfree(nvs);
-       } else {
-               vxlan->vn_sock = nvs;
-               hlist_add_head_rcu(&nvs->hlist, vs_head(net, port));
-               hlist_add_head_rcu(&vxlan->hlist, vni_head(nvs, vni));
-               spin_unlock(&vn->sock_lock);
-       }
-out:
-       dev_put(dev);
+       if (!IS_ERR(nvs))
+               vxlan_vs_add_dev(nvs, vxlan);
+       spin_unlock(&vn->sock_lock);
+
+       dev_put(vxlan->dev);
 }
 
 static int vxlan_newlink(struct net *net, struct net_device *dev,
@@ -1767,9 +1889,14 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
 
 static void vxlan_dellink(struct net_device *dev, struct list_head *head)
 {
+       struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
        struct vxlan_dev *vxlan = netdev_priv(dev);
 
-       hlist_del_rcu(&vxlan->hlist);
+       spin_lock(&vn->sock_lock);
+       if (!hlist_unhashed(&vxlan->hlist))
+               hlist_del_rcu(&vxlan->hlist);
+       spin_unlock(&vn->sock_lock);
+
        list_del(&vxlan->next);
        unregister_netdevice_queue(dev, head);
 }
@@ -1872,10 +1999,12 @@ static __net_exit void vxlan_exit_net(struct net *net)
 {
        struct vxlan_net *vn = net_generic(net, vxlan_net_id);
        struct vxlan_dev *vxlan;
+       LIST_HEAD(list);
 
        rtnl_lock();
        list_for_each_entry(vxlan, &vn->vxlan_list, next)
-               dev_close(vxlan->dev);
+               unregister_netdevice_queue(vxlan->dev, &list);
+       unregister_netdevice_many(&list);
        rtnl_unlock();
 }
 
index d43f4efd3e07abc6d62fff0343cfd46cec609097..5bbcb5e3ee0c0cf5e9fefff42fb6892541e14548 100644 (file)
@@ -176,7 +176,7 @@ static u32  mac[  SBNI_MAX_NUM_CARDS ] __initdata;
 
 #ifndef MODULE
 typedef u32  iarr[];
-static iarr __initdata *dest[5] = { &io, &irq, &baud, &rxl, &mac };
+static iarr *dest[5] __initdata = { &io, &irq, &baud, &rxl, &mac };
 #endif
 
 /* A zero-terminated list of I/O addresses to be probed on ISA bus */
index 8a4d77ee9c5b61a312c3f2142ffa42fc0671e122..a1977430ddfb9be616a6e97c7cfb4951da2cdd09 100644 (file)
 #include <xen/grant_table.h>
 #include <xen/xenbus.h>
 
-struct xen_netbk;
+typedef unsigned int pending_ring_idx_t;
+#define INVALID_PENDING_RING_IDX (~0U)
+
+/* For the head field in pending_tx_info: it is used to indicate
+ * whether this tx info is the head of one or more coalesced requests.
+ *
+ * When head != INVALID_PENDING_RING_IDX, it means the start of a new
+ * tx requests queue and the end of previous queue.
+ *
+ * An example sequence of head fields (I = INVALID_PENDING_RING_IDX):
+ *
+ * ...|0 I I I|5 I|9 I I I|...
+ * -->|<-INUSE----------------
+ *
+ * After consuming the first slot(s) we have:
+ *
+ * ...|V V V V|5 I|9 I I I|...
+ * -----FREE->|<-INUSE--------
+ *
+ * where V stands for "valid pending ring index". Any number other
+ * than INVALID_PENDING_RING_IDX is OK. These entries are considered
+ * free and can contain any number other than
+ * INVALID_PENDING_RING_IDX. In practice we use 0.
+ *
+ * The in use non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the
+ * above example) number is the index into pending_tx_info and
+ * mmap_pages arrays.
+ */
+struct pending_tx_info {
+       struct xen_netif_tx_request req; /* coalesced tx request */
+       pending_ring_idx_t head; /* head != INVALID_PENDING_RING_IDX
+                                 * if it is head of one or more tx
+                                 * reqs
+                                 */
+};
+
+#define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
+#define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
+
+struct xenvif_rx_meta {
+       int id;
+       int size;
+       int gso_size;
+};
+
+/* Discriminate from any valid pending_idx value. */
+#define INVALID_PENDING_IDX 0xFFFF
+
+#define MAX_BUFFER_OFFSET PAGE_SIZE
+
+#define MAX_PENDING_REQS 256
 
 struct xenvif {
        /* Unique identifier for this interface. */
        domid_t          domid;
        unsigned int     handle;
 
-       /* Reference to netback processing backend. */
-       struct xen_netbk *netbk;
+       /* Use NAPI for guest TX */
+       struct napi_struct napi;
+       /* When feature-split-event-channels = 0, tx_irq = rx_irq. */
+       unsigned int tx_irq;
+       /* Only used when feature-split-event-channels = 1 */
+       char tx_irq_name[IFNAMSIZ+4]; /* DEVNAME-tx */
+       struct xen_netif_tx_back_ring tx;
+       struct sk_buff_head tx_queue;
+       struct page *mmap_pages[MAX_PENDING_REQS];
+       pending_ring_idx_t pending_prod;
+       pending_ring_idx_t pending_cons;
+       u16 pending_ring[MAX_PENDING_REQS];
+       struct pending_tx_info pending_tx_info[MAX_PENDING_REQS];
+
+       /* Coalescing tx requests before copying makes number of grant
+        * copy ops greater or equal to number of slots required. In
+        * worst case a tx request consumes 2 gnttab_copy.
+        */
+       struct gnttab_copy tx_copy_ops[2*MAX_PENDING_REQS];
 
-       u8               fe_dev_addr[6];
 
+       /* Use kthread for guest RX */
+       struct task_struct *task;
+       wait_queue_head_t wq;
        /* When feature-split-event-channels = 0, tx_irq = rx_irq. */
-       unsigned int tx_irq;
        unsigned int rx_irq;
        /* Only used when feature-split-event-channels = 1 */
-       char tx_irq_name[IFNAMSIZ+4]; /* DEVNAME-tx */
        char rx_irq_name[IFNAMSIZ+4]; /* DEVNAME-rx */
+       struct xen_netif_rx_back_ring rx;
+       struct sk_buff_head rx_queue;
 
-       /* List of frontends to notify after a batch of frames sent. */
-       struct list_head notify_list;
+       /* Allow xenvif_start_xmit() to peek ahead in the rx request
+        * ring.  This is a prediction of what rx_req_cons will be
+        * once all queued skbs are put on the ring.
+        */
+       RING_IDX rx_req_cons_peek;
+
+       /* Given MAX_BUFFER_OFFSET of 4096 the worst case is that each
+        * head/fragment page uses 2 copy operations because it
+        * straddles two buffers in the frontend.
+        */
+       struct gnttab_copy grant_copy_op[2*XEN_NETIF_RX_RING_SIZE];
+       struct xenvif_rx_meta meta[2*XEN_NETIF_RX_RING_SIZE];
 
-       /* The shared rings and indexes. */
-       struct xen_netif_tx_back_ring tx;
-       struct xen_netif_rx_back_ring rx;
+
+       u8               fe_dev_addr[6];
 
        /* Frontend feature information. */
        u8 can_sg:1;
@@ -80,13 +158,6 @@ struct xenvif {
        /* Internal feature information. */
        u8 can_queue:1;     /* can queue packets for receiver? */
 
-       /*
-        * Allow xenvif_start_xmit() to peek ahead in the rx request
-        * ring.  This is a prediction of what rx_req_cons will be
-        * once all queued skbs are put on the ring.
-        */
-       RING_IDX rx_req_cons_peek;
-
        /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
        unsigned long   credit_bytes;
        unsigned long   credit_usec;
@@ -97,11 +168,7 @@ struct xenvif {
        unsigned long rx_gso_checksum_fixup;
 
        /* Miscellaneous private stuff. */
-       struct list_head schedule_list;
-       atomic_t         refcnt;
        struct net_device *dev;
-
-       wait_queue_head_t waiting_to_free;
 };
 
 static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)
@@ -109,9 +176,6 @@ static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)
        return to_xenbus_device(vif->dev->dev.parent);
 }
 
-#define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
-#define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
-
 struct xenvif *xenvif_alloc(struct device *parent,
                            domid_t domid,
                            unsigned int handle);
@@ -121,39 +185,26 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
                   unsigned int rx_evtchn);
 void xenvif_disconnect(struct xenvif *vif);
 
-void xenvif_get(struct xenvif *vif);
-void xenvif_put(struct xenvif *vif);
-
 int xenvif_xenbus_init(void);
 void xenvif_xenbus_fini(void);
 
 int xenvif_schedulable(struct xenvif *vif);
 
-int xen_netbk_rx_ring_full(struct xenvif *vif);
+int xenvif_rx_ring_full(struct xenvif *vif);
 
-int xen_netbk_must_stop_queue(struct xenvif *vif);
+int xenvif_must_stop_queue(struct xenvif *vif);
 
 /* (Un)Map communication rings. */
-void xen_netbk_unmap_frontend_rings(struct xenvif *vif);
-int xen_netbk_map_frontend_rings(struct xenvif *vif,
-                                grant_ref_t tx_ring_ref,
-                                grant_ref_t rx_ring_ref);
-
-/* (De)Register a xenvif with the netback backend. */
-void xen_netbk_add_xenvif(struct xenvif *vif);
-void xen_netbk_remove_xenvif(struct xenvif *vif);
-
-/* (De)Schedule backend processing for a xenvif */
-void xen_netbk_schedule_xenvif(struct xenvif *vif);
-void xen_netbk_deschedule_xenvif(struct xenvif *vif);
+void xenvif_unmap_frontend_rings(struct xenvif *vif);
+int xenvif_map_frontend_rings(struct xenvif *vif,
+                             grant_ref_t tx_ring_ref,
+                             grant_ref_t rx_ring_ref);
 
 /* Check for SKBs from frontend and schedule backend processing */
-void xen_netbk_check_rx_xenvif(struct xenvif *vif);
-/* Receive an SKB from the frontend */
-void xenvif_receive_skb(struct xenvif *vif, struct sk_buff *skb);
+void xenvif_check_rx_xenvif(struct xenvif *vif);
 
 /* Queue an SKB for transmission to the frontend */
-void xen_netbk_queue_tx_skb(struct xenvif *vif, struct sk_buff *skb);
+void xenvif_queue_tx_skb(struct xenvif *vif, struct sk_buff *skb);
 /* Notify xenvif that ring now has space to send an skb to the frontend */
 void xenvif_notify_tx_completion(struct xenvif *vif);
 
@@ -161,7 +212,12 @@ void xenvif_notify_tx_completion(struct xenvif *vif);
 void xenvif_carrier_off(struct xenvif *vif);
 
 /* Returns number of ring slots required to send an skb to the frontend */
-unsigned int xen_netbk_count_skb_slots(struct xenvif *vif, struct sk_buff *skb);
+unsigned int xenvif_count_skb_slots(struct xenvif *vif, struct sk_buff *skb);
+
+int xenvif_tx_action(struct xenvif *vif, int budget);
+void xenvif_rx_action(struct xenvif *vif);
+
+int xenvif_kthread(void *data);
 
 extern bool separate_tx_rx_irq;
 
index 087d2db0389d04efc3368a0ba48a925a3b070124..625c6f49cfba9923e80dc0834d49a6a6b870f1b3 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "common.h"
 
+#include <linux/kthread.h>
 #include <linux/ethtool.h>
 #include <linux/rtnetlink.h>
 #include <linux/if_vlan.h>
 #include <asm/xen/hypercall.h>
 
 #define XENVIF_QUEUE_LENGTH 32
-
-void xenvif_get(struct xenvif *vif)
-{
-       atomic_inc(&vif->refcnt);
-}
-
-void xenvif_put(struct xenvif *vif)
-{
-       if (atomic_dec_and_test(&vif->refcnt))
-               wake_up(&vif->waiting_to_free);
-}
+#define XENVIF_NAPI_WEIGHT  64
 
 int xenvif_schedulable(struct xenvif *vif)
 {
@@ -57,28 +48,62 @@ int xenvif_schedulable(struct xenvif *vif)
 
 static int xenvif_rx_schedulable(struct xenvif *vif)
 {
-       return xenvif_schedulable(vif) && !xen_netbk_rx_ring_full(vif);
+       return xenvif_schedulable(vif) && !xenvif_rx_ring_full(vif);
 }
 
 static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id)
 {
        struct xenvif *vif = dev_id;
 
-       if (vif->netbk == NULL)
-               return IRQ_HANDLED;
-
-       xen_netbk_schedule_xenvif(vif);
+       if (RING_HAS_UNCONSUMED_REQUESTS(&vif->tx))
+               napi_schedule(&vif->napi);
 
        return IRQ_HANDLED;
 }
 
+static int xenvif_poll(struct napi_struct *napi, int budget)
+{
+       struct xenvif *vif = container_of(napi, struct xenvif, napi);
+       int work_done;
+
+       work_done = xenvif_tx_action(vif, budget);
+
+       if (work_done < budget) {
+               int more_to_do = 0;
+               unsigned long flags;
+
+               /* It is necessary to disable IRQ before calling
+                * RING_HAS_UNCONSUMED_REQUESTS. Otherwise we might
+                * lose event from the frontend.
+                *
+                * Consider:
+                *   RING_HAS_UNCONSUMED_REQUESTS
+                *   <frontend generates event to trigger napi_schedule>
+                *   __napi_complete
+                *
+                * This handler is still in scheduled state so the
+                * event has no effect at all. After __napi_complete
+                * this handler is descheduled and cannot get
+                * scheduled again. We lose event in this case and the ring
+                * will be completely stalled.
+                */
+
+               local_irq_save(flags);
+
+               RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, more_to_do);
+               if (!more_to_do)
+                       __napi_complete(napi);
+
+               local_irq_restore(flags);
+       }
+
+       return work_done;
+}
+
 static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id)
 {
        struct xenvif *vif = dev_id;
 
-       if (vif->netbk == NULL)
-               return IRQ_HANDLED;
-
        if (xenvif_rx_schedulable(vif))
                netif_wake_queue(vif->dev);
 
@@ -99,7 +124,8 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        BUG_ON(skb->dev != dev);
 
-       if (vif->netbk == NULL)
+       /* Drop the packet if vif is not ready */
+       if (vif->task == NULL)
                goto drop;
 
        /* Drop the packet if the target domain has no receive buffers. */
@@ -107,13 +133,12 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
                goto drop;
 
        /* Reserve ring slots for the worst-case number of fragments. */
-       vif->rx_req_cons_peek += xen_netbk_count_skb_slots(vif, skb);
-       xenvif_get(vif);
+       vif->rx_req_cons_peek += xenvif_count_skb_slots(vif, skb);
 
-       if (vif->can_queue && xen_netbk_must_stop_queue(vif))
+       if (vif->can_queue && xenvif_must_stop_queue(vif))
                netif_stop_queue(dev);
 
-       xen_netbk_queue_tx_skb(vif, skb);
+       xenvif_queue_tx_skb(vif, skb);
 
        return NETDEV_TX_OK;
 
@@ -123,11 +148,6 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
        return NETDEV_TX_OK;
 }
 
-void xenvif_receive_skb(struct xenvif *vif, struct sk_buff *skb)
-{
-       netif_rx_ni(skb);
-}
-
 void xenvif_notify_tx_completion(struct xenvif *vif)
 {
        if (netif_queue_stopped(vif->dev) && xenvif_rx_schedulable(vif))
@@ -142,21 +162,20 @@ static struct net_device_stats *xenvif_get_stats(struct net_device *dev)
 
 static void xenvif_up(struct xenvif *vif)
 {
-       xen_netbk_add_xenvif(vif);
+       napi_enable(&vif->napi);
        enable_irq(vif->tx_irq);
        if (vif->tx_irq != vif->rx_irq)
                enable_irq(vif->rx_irq);
-       xen_netbk_check_rx_xenvif(vif);
+       xenvif_check_rx_xenvif(vif);
 }
 
 static void xenvif_down(struct xenvif *vif)
 {
+       napi_disable(&vif->napi);
        disable_irq(vif->tx_irq);
        if (vif->tx_irq != vif->rx_irq)
                disable_irq(vif->rx_irq);
        del_timer_sync(&vif->credit_timeout);
-       xen_netbk_deschedule_xenvif(vif);
-       xen_netbk_remove_xenvif(vif);
 }
 
 static int xenvif_open(struct net_device *dev)
@@ -272,11 +291,12 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
        struct net_device *dev;
        struct xenvif *vif;
        char name[IFNAMSIZ] = {};
+       int i;
 
        snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
        dev = alloc_netdev(sizeof(struct xenvif), name, ether_setup);
        if (dev == NULL) {
-               pr_warn("Could not allocate netdev\n");
+               pr_warn("Could not allocate netdev for %s\n", name);
                return ERR_PTR(-ENOMEM);
        }
 
@@ -285,14 +305,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
        vif = netdev_priv(dev);
        vif->domid  = domid;
        vif->handle = handle;
-       vif->netbk  = NULL;
        vif->can_sg = 1;
        vif->csum = 1;
-       atomic_set(&vif->refcnt, 1);
-       init_waitqueue_head(&vif->waiting_to_free);
        vif->dev = dev;
-       INIT_LIST_HEAD(&vif->schedule_list);
-       INIT_LIST_HEAD(&vif->notify_list);
 
        vif->credit_bytes = vif->remaining_credit = ~0UL;
        vif->credit_usec  = 0UL;
@@ -307,6 +322,16 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
 
        dev->tx_queue_len = XENVIF_QUEUE_LENGTH;
 
+       skb_queue_head_init(&vif->rx_queue);
+       skb_queue_head_init(&vif->tx_queue);
+
+       vif->pending_cons = 0;
+       vif->pending_prod = MAX_PENDING_REQS;
+       for (i = 0; i < MAX_PENDING_REQS; i++)
+               vif->pending_ring[i] = i;
+       for (i = 0; i < MAX_PENDING_REQS; i++)
+               vif->mmap_pages[i] = NULL;
+
        /*
         * Initialise a dummy MAC address. We choose the numerically
         * largest non-broadcast address to prevent the address getting
@@ -316,6 +341,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
        memset(dev->dev_addr, 0xFF, ETH_ALEN);
        dev->dev_addr[0] &= ~0x01;
 
+       netif_napi_add(dev, &vif->napi, xenvif_poll, XENVIF_NAPI_WEIGHT);
+
        netif_carrier_off(dev);
 
        err = register_netdev(dev);
@@ -341,7 +368,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
 
        __module_get(THIS_MODULE);
 
-       err = xen_netbk_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref);
+       err = xenvif_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref);
        if (err < 0)
                goto err;
 
@@ -377,7 +404,14 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
                disable_irq(vif->rx_irq);
        }
 
-       xenvif_get(vif);
+       init_waitqueue_head(&vif->wq);
+       vif->task = kthread_create(xenvif_kthread,
+                                  (void *)vif, vif->dev->name);
+       if (IS_ERR(vif->task)) {
+               pr_warn("Could not allocate kthread for %s\n", vif->dev->name);
+               err = PTR_ERR(vif->task);
+               goto err_rx_unbind;
+       }
 
        rtnl_lock();
        if (!vif->can_sg && vif->dev->mtu > ETH_DATA_LEN)
@@ -388,12 +422,18 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
                xenvif_up(vif);
        rtnl_unlock();
 
+       wake_up_process(vif->task);
+
        return 0;
+
+err_rx_unbind:
+       unbind_from_irqhandler(vif->rx_irq, vif);
+       vif->rx_irq = 0;
 err_tx_unbind:
        unbind_from_irqhandler(vif->tx_irq, vif);
        vif->tx_irq = 0;
 err_unmap:
-       xen_netbk_unmap_frontend_rings(vif);
+       xenvif_unmap_frontend_rings(vif);
 err:
        module_put(THIS_MODULE);
        return err;
@@ -408,7 +448,6 @@ void xenvif_carrier_off(struct xenvif *vif)
        if (netif_running(dev))
                xenvif_down(vif);
        rtnl_unlock();
-       xenvif_put(vif);
 }
 
 void xenvif_disconnect(struct xenvif *vif)
@@ -422,9 +461,6 @@ void xenvif_disconnect(struct xenvif *vif)
        if (netif_carrier_ok(vif->dev))
                xenvif_carrier_off(vif);
 
-       atomic_dec(&vif->refcnt);
-       wait_event(vif->waiting_to_free, atomic_read(&vif->refcnt) == 0);
-
        if (vif->tx_irq) {
                if (vif->tx_irq == vif->rx_irq)
                        unbind_from_irqhandler(vif->tx_irq, vif);
@@ -438,9 +474,14 @@ void xenvif_disconnect(struct xenvif *vif)
                need_module_put = 1;
        }
 
+       if (vif->task)
+               kthread_stop(vif->task);
+
+       netif_napi_del(&vif->napi);
+
        unregister_netdev(vif->dev);
 
-       xen_netbk_unmap_frontend_rings(vif);
+       xenvif_unmap_frontend_rings(vif);
 
        free_netdev(vif->dev);
 
index 64828de25d9a252119a16bb805bfe4fb3ed4b809..956130c70036d2d3d297e8d101bc68017f19c9d6 100644 (file)
@@ -70,131 +70,26 @@ module_param(fatal_skb_slots, uint, 0444);
  */
 #define XEN_NETBK_LEGACY_SLOTS_MAX XEN_NETIF_NR_SLOTS_MIN
 
-typedef unsigned int pending_ring_idx_t;
-#define INVALID_PENDING_RING_IDX (~0U)
-
-struct pending_tx_info {
-       struct xen_netif_tx_request req; /* coalesced tx request */
-       struct xenvif *vif;
-       pending_ring_idx_t head; /* head != INVALID_PENDING_RING_IDX
-                                 * if it is head of one or more tx
-                                 * reqs
-                                 */
-};
-
-struct netbk_rx_meta {
-       int id;
-       int size;
-       int gso_size;
-};
-
-#define MAX_PENDING_REQS 256
-
-/* Discriminate from any valid pending_idx value. */
-#define INVALID_PENDING_IDX 0xFFFF
-
-#define MAX_BUFFER_OFFSET PAGE_SIZE
-
-/* extra field used in struct page */
-union page_ext {
-       struct {
-#if BITS_PER_LONG < 64
-#define IDX_WIDTH   8
-#define GROUP_WIDTH (BITS_PER_LONG - IDX_WIDTH)
-               unsigned int group:GROUP_WIDTH;
-               unsigned int idx:IDX_WIDTH;
-#else
-               unsigned int group, idx;
-#endif
-       } e;
-       void *mapping;
-};
-
-struct xen_netbk {
-       wait_queue_head_t wq;
-       struct task_struct *task;
-
-       struct sk_buff_head rx_queue;
-       struct sk_buff_head tx_queue;
-
-       struct timer_list net_timer;
-
-       struct page *mmap_pages[MAX_PENDING_REQS];
-
-       pending_ring_idx_t pending_prod;
-       pending_ring_idx_t pending_cons;
-       struct list_head net_schedule_list;
-
-       /* Protect the net_schedule_list in netif. */
-       spinlock_t net_schedule_list_lock;
-
-       atomic_t netfront_count;
-
-       struct pending_tx_info pending_tx_info[MAX_PENDING_REQS];
-       /* Coalescing tx requests before copying makes number of grant
-        * copy ops greater or equal to number of slots required. In
-        * worst case a tx request consumes 2 gnttab_copy.
-        */
-       struct gnttab_copy tx_copy_ops[2*MAX_PENDING_REQS];
-
-       u16 pending_ring[MAX_PENDING_REQS];
-
-       /*
-        * Given MAX_BUFFER_OFFSET of 4096 the worst case is that each
-        * head/fragment page uses 2 copy operations because it
-        * straddles two buffers in the frontend.
-        */
-       struct gnttab_copy grant_copy_op[2*XEN_NETIF_RX_RING_SIZE];
-       struct netbk_rx_meta meta[2*XEN_NETIF_RX_RING_SIZE];
-};
-
-static struct xen_netbk *xen_netbk;
-static int xen_netbk_group_nr;
-
 /*
  * If head != INVALID_PENDING_RING_IDX, it means this tx request is head of
  * one or more merged tx requests, otherwise it is the continuation of
  * previous tx request.
  */
-static inline int pending_tx_is_head(struct xen_netbk *netbk, RING_IDX idx)
-{
-       return netbk->pending_tx_info[idx].head != INVALID_PENDING_RING_IDX;
-}
-
-void xen_netbk_add_xenvif(struct xenvif *vif)
+static inline int pending_tx_is_head(struct xenvif *vif, RING_IDX idx)
 {
-       int i;
-       int min_netfront_count;
-       int min_group = 0;
-       struct xen_netbk *netbk;
-
-       min_netfront_count = atomic_read(&xen_netbk[0].netfront_count);
-       for (i = 0; i < xen_netbk_group_nr; i++) {
-               int netfront_count = atomic_read(&xen_netbk[i].netfront_count);
-               if (netfront_count < min_netfront_count) {
-                       min_group = i;
-                       min_netfront_count = netfront_count;
-               }
-       }
-
-       netbk = &xen_netbk[min_group];
-
-       vif->netbk = netbk;
-       atomic_inc(&netbk->netfront_count);
+       return vif->pending_tx_info[idx].head != INVALID_PENDING_RING_IDX;
 }
 
-void xen_netbk_remove_xenvif(struct xenvif *vif)
-{
-       struct xen_netbk *netbk = vif->netbk;
-       vif->netbk = NULL;
-       atomic_dec(&netbk->netfront_count);
-}
+static void xenvif_idx_release(struct xenvif *vif, u16 pending_idx,
+                              u8 status);
 
-static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx,
-                                 u8 status);
 static void make_tx_response(struct xenvif *vif,
                             struct xen_netif_tx_request *txp,
                             s8       st);
+
+static inline int tx_work_todo(struct xenvif *vif);
+static inline int rx_work_todo(struct xenvif *vif);
+
 static struct xen_netif_rx_response *make_rx_response(struct xenvif *vif,
                                             u16      id,
                                             s8       st,
@@ -202,55 +97,16 @@ static struct xen_netif_rx_response *make_rx_response(struct xenvif *vif,
                                             u16      size,
                                             u16      flags);
 
-static inline unsigned long idx_to_pfn(struct xen_netbk *netbk,
+static inline unsigned long idx_to_pfn(struct xenvif *vif,
                                       u16 idx)
 {
-       return page_to_pfn(netbk->mmap_pages[idx]);
+       return page_to_pfn(vif->mmap_pages[idx]);
 }
 
-static inline unsigned long idx_to_kaddr(struct xen_netbk *netbk,
+static inline unsigned long idx_to_kaddr(struct xenvif *vif,
                                         u16 idx)
 {
-       return (unsigned long)pfn_to_kaddr(idx_to_pfn(netbk, idx));
-}
-
-/* extra field used in struct page */
-static inline void set_page_ext(struct page *pg, struct xen_netbk *netbk,
-                               unsigned int idx)
-{
-       unsigned int group = netbk - xen_netbk;
-       union page_ext ext = { .e = { .group = group + 1, .idx = idx } };
-
-       BUILD_BUG_ON(sizeof(ext) > sizeof(ext.mapping));
-       pg->mapping = ext.mapping;
-}
-
-static int get_page_ext(struct page *pg,
-                       unsigned int *pgroup, unsigned int *pidx)
-{
-       union page_ext ext = { .mapping = pg->mapping };
-       struct xen_netbk *netbk;
-       unsigned int group, idx;
-
-       group = ext.e.group - 1;
-
-       if (group < 0 || group >= xen_netbk_group_nr)
-               return 0;
-
-       netbk = &xen_netbk[group];
-
-       idx = ext.e.idx;
-
-       if ((idx < 0) || (idx >= MAX_PENDING_REQS))
-               return 0;
-
-       if (netbk->mmap_pages[idx] != pg)
-               return 0;
-
-       *pgroup = group;
-       *pidx = idx;
-
-       return 1;
+       return (unsigned long)pfn_to_kaddr(idx_to_pfn(vif, idx));
 }
 
 /*
@@ -278,15 +134,10 @@ static inline pending_ring_idx_t pending_index(unsigned i)
        return i & (MAX_PENDING_REQS-1);
 }
 
-static inline pending_ring_idx_t nr_pending_reqs(struct xen_netbk *netbk)
+static inline pending_ring_idx_t nr_pending_reqs(struct xenvif *vif)
 {
        return MAX_PENDING_REQS -
-               netbk->pending_prod + netbk->pending_cons;
-}
-
-static void xen_netbk_kick_thread(struct xen_netbk *netbk)
-{
-       wake_up(&netbk->wq);
+               vif->pending_prod + vif->pending_cons;
 }
 
 static int max_required_rx_slots(struct xenvif *vif)
@@ -300,7 +151,7 @@ static int max_required_rx_slots(struct xenvif *vif)
        return max;
 }
 
-int xen_netbk_rx_ring_full(struct xenvif *vif)
+int xenvif_rx_ring_full(struct xenvif *vif)
 {
        RING_IDX peek   = vif->rx_req_cons_peek;
        RING_IDX needed = max_required_rx_slots(vif);
@@ -309,16 +160,16 @@ int xen_netbk_rx_ring_full(struct xenvif *vif)
               ((vif->rx.rsp_prod_pvt + XEN_NETIF_RX_RING_SIZE - peek) < needed);
 }
 
-int xen_netbk_must_stop_queue(struct xenvif *vif)
+int xenvif_must_stop_queue(struct xenvif *vif)
 {
-       if (!xen_netbk_rx_ring_full(vif))
+       if (!xenvif_rx_ring_full(vif))
                return 0;
 
        vif->rx.sring->req_event = vif->rx_req_cons_peek +
                max_required_rx_slots(vif);
        mb(); /* request notification /then/ check the queue */
 
-       return xen_netbk_rx_ring_full(vif);
+       return xenvif_rx_ring_full(vif);
 }
 
 /*
@@ -364,9 +215,9 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head)
 /*
  * Figure out how many ring slots we're going to need to send @skb to
  * the guest. This function is essentially a dry run of
- * netbk_gop_frag_copy.
+ * xenvif_gop_frag_copy.
  */
-unsigned int xen_netbk_count_skb_slots(struct xenvif *vif, struct sk_buff *skb)
+unsigned int xenvif_count_skb_slots(struct xenvif *vif, struct sk_buff *skb)
 {
        unsigned int count;
        int i, copy_off;
@@ -418,15 +269,15 @@ struct netrx_pending_operations {
        unsigned copy_prod, copy_cons;
        unsigned meta_prod, meta_cons;
        struct gnttab_copy *copy;
-       struct netbk_rx_meta *meta;
+       struct xenvif_rx_meta *meta;
        int copy_off;
        grant_ref_t copy_gref;
 };
 
-static struct netbk_rx_meta *get_next_rx_buffer(struct xenvif *vif,
-                                               struct netrx_pending_operations *npo)
+static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif *vif,
+                                                struct netrx_pending_operations *npo)
 {
-       struct netbk_rx_meta *meta;
+       struct xenvif_rx_meta *meta;
        struct xen_netif_rx_request *req;
 
        req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
@@ -446,19 +297,13 @@ static struct netbk_rx_meta *get_next_rx_buffer(struct xenvif *vif,
  * Set up the grant operations for this fragment. If it's a flipping
  * interface, we also set up the unmap request from here.
  */
-static void netbk_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
-                               struct netrx_pending_operations *npo,
-                               struct page *page, unsigned long size,
-                               unsigned long offset, int *head)
+static void xenvif_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
+                                struct netrx_pending_operations *npo,
+                                struct page *page, unsigned long size,
+                                unsigned long offset, int *head)
 {
        struct gnttab_copy *copy_gop;
-       struct netbk_rx_meta *meta;
-       /*
-        * These variables are used iff get_page_ext returns true,
-        * in which case they are guaranteed to be initialized.
-        */
-       unsigned int uninitialized_var(group), uninitialized_var(idx);
-       int foreign = get_page_ext(page, &group, &idx);
+       struct xenvif_rx_meta *meta;
        unsigned long bytes;
 
        /* Data must not cross a page boundary. */
@@ -494,26 +339,15 @@ static void netbk_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
 
                copy_gop = npo->copy + npo->copy_prod++;
                copy_gop->flags = GNTCOPY_dest_gref;
-               if (foreign) {
-                       struct xen_netbk *netbk = &xen_netbk[group];
-                       struct pending_tx_info *src_pend;
-
-                       src_pend = &netbk->pending_tx_info[idx];
+               copy_gop->len = bytes;
 
-                       copy_gop->source.domid = src_pend->vif->domid;
-                       copy_gop->source.u.ref = src_pend->req.gref;
-                       copy_gop->flags |= GNTCOPY_source_gref;
-               } else {
-                       void *vaddr = page_address(page);
-                       copy_gop->source.domid = DOMID_SELF;
-                       copy_gop->source.u.gmfn = virt_to_mfn(vaddr);
-               }
+               copy_gop->source.domid = DOMID_SELF;
+               copy_gop->source.u.gmfn = virt_to_mfn(page_address(page));
                copy_gop->source.offset = offset;
-               copy_gop->dest.domid = vif->domid;
 
+               copy_gop->dest.domid = vif->domid;
                copy_gop->dest.offset = npo->copy_off;
                copy_gop->dest.u.ref = npo->copy_gref;
-               copy_gop->len = bytes;
 
                npo->copy_off += bytes;
                meta->size += bytes;
@@ -549,14 +383,14 @@ static void netbk_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
  * zero GSO descriptors (for non-GSO packets) or one descriptor (for
  * frontend-side LRO).
  */
-static int netbk_gop_skb(struct sk_buff *skb,
-                        struct netrx_pending_operations *npo)
+static int xenvif_gop_skb(struct sk_buff *skb,
+                         struct netrx_pending_operations *npo)
 {
        struct xenvif *vif = netdev_priv(skb->dev);
        int nr_frags = skb_shinfo(skb)->nr_frags;
        int i;
        struct xen_netif_rx_request *req;
-       struct netbk_rx_meta *meta;
+       struct xenvif_rx_meta *meta;
        unsigned char *data;
        int head = 1;
        int old_meta_prod;
@@ -593,30 +427,30 @@ static int netbk_gop_skb(struct sk_buff *skb,
                if (data + len > skb_tail_pointer(skb))
                        len = skb_tail_pointer(skb) - data;
 
-               netbk_gop_frag_copy(vif, skb, npo,
-                                   virt_to_page(data), len, offset, &head);
+               xenvif_gop_frag_copy(vif, skb, npo,
+                                    virt_to_page(data), len, offset, &head);
                data += len;
        }
 
        for (i = 0; i < nr_frags; i++) {
-               netbk_gop_frag_copy(vif, skb, npo,
-                                   skb_frag_page(&skb_shinfo(skb)->frags[i]),
-                                   skb_frag_size(&skb_shinfo(skb)->frags[i]),
-                                   skb_shinfo(skb)->frags[i].page_offset,
-                                   &head);
+               xenvif_gop_frag_copy(vif, skb, npo,
+                                    skb_frag_page(&skb_shinfo(skb)->frags[i]),
+                                    skb_frag_size(&skb_shinfo(skb)->frags[i]),
+                                    skb_shinfo(skb)->frags[i].page_offset,
+                                    &head);
        }
 
        return npo->meta_prod - old_meta_prod;
 }
 
 /*
- * This is a twin to netbk_gop_skb.  Assume that netbk_gop_skb was
+ * This is a twin to xenvif_gop_skb.  Assume that xenvif_gop_skb was
  * used to set up the operations on the top of
  * netrx_pending_operations, which have since been done.  Check that
  * they didn't give any errors and advance over them.
  */
-static int netbk_check_gop(struct xenvif *vif, int nr_meta_slots,
-                          struct netrx_pending_operations *npo)
+static int xenvif_check_gop(struct xenvif *vif, int nr_meta_slots,
+                           struct netrx_pending_operations *npo)
 {
        struct gnttab_copy     *copy_op;
        int status = XEN_NETIF_RSP_OKAY;
@@ -635,9 +469,9 @@ static int netbk_check_gop(struct xenvif *vif, int nr_meta_slots,
        return status;
 }
 
-static void netbk_add_frag_responses(struct xenvif *vif, int status,
-                                    struct netbk_rx_meta *meta,
-                                    int nr_meta_slots)
+static void xenvif_add_frag_responses(struct xenvif *vif, int status,
+                                     struct xenvif_rx_meta *meta,
+                                     int nr_meta_slots)
 {
        int i;
        unsigned long offset;
@@ -665,9 +499,13 @@ struct skb_cb_overlay {
        int meta_slots_used;
 };
 
-static void xen_netbk_rx_action(struct xen_netbk *netbk)
+static void xenvif_kick_thread(struct xenvif *vif)
+{
+       wake_up(&vif->wq);
+}
+
+void xenvif_rx_action(struct xenvif *vif)
 {
-       struct xenvif *vif = NULL, *tmp;
        s8 status;
        u16 flags;
        struct xen_netif_rx_response *resp;
@@ -679,22 +517,23 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
        int count;
        unsigned long offset;
        struct skb_cb_overlay *sco;
+       int need_to_notify = 0;
 
        struct netrx_pending_operations npo = {
-               .copy  = netbk->grant_copy_op,
-               .meta  = netbk->meta,
+               .copy  = vif->grant_copy_op,
+               .meta  = vif->meta,
        };
 
        skb_queue_head_init(&rxq);
 
        count = 0;
 
-       while ((skb = skb_dequeue(&netbk->rx_queue)) != NULL) {
+       while ((skb = skb_dequeue(&vif->rx_queue)) != NULL) {
                vif = netdev_priv(skb->dev);
                nr_frags = skb_shinfo(skb)->nr_frags;
 
                sco = (struct skb_cb_overlay *)skb->cb;
-               sco->meta_slots_used = netbk_gop_skb(skb, &npo);
+               sco->meta_slots_used = xenvif_gop_skb(skb, &npo);
 
                count += nr_frags + 1;
 
@@ -706,27 +545,27 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
                        break;
        }
 
-       BUG_ON(npo.meta_prod > ARRAY_SIZE(netbk->meta));
+       BUG_ON(npo.meta_prod > ARRAY_SIZE(vif->meta));
 
        if (!npo.copy_prod)
                return;
 
-       BUG_ON(npo.copy_prod > ARRAY_SIZE(netbk->grant_copy_op));
-       gnttab_batch_copy(netbk->grant_copy_op, npo.copy_prod);
+       BUG_ON(npo.copy_prod > ARRAY_SIZE(vif->grant_copy_op));
+       gnttab_batch_copy(vif->grant_copy_op, npo.copy_prod);
 
        while ((skb = __skb_dequeue(&rxq)) != NULL) {
                sco = (struct skb_cb_overlay *)skb->cb;
 
                vif = netdev_priv(skb->dev);
 
-               if (netbk->meta[npo.meta_cons].gso_size && vif->gso_prefix) {
+               if (vif->meta[npo.meta_cons].gso_size && vif->gso_prefix) {
                        resp = RING_GET_RESPONSE(&vif->rx,
-                                               vif->rx.rsp_prod_pvt++);
+                                                vif->rx.rsp_prod_pvt++);
 
                        resp->flags = XEN_NETRXF_gso_prefix | XEN_NETRXF_more_data;
 
-                       resp->offset = netbk->meta[npo.meta_cons].gso_size;
-                       resp->id = netbk->meta[npo.meta_cons].id;
+                       resp->offset = vif->meta[npo.meta_cons].gso_size;
+                       resp->id = vif->meta[npo.meta_cons].id;
                        resp->status = sco->meta_slots_used;
 
                        npo.meta_cons++;
@@ -737,7 +576,7 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
                vif->dev->stats.tx_bytes += skb->len;
                vif->dev->stats.tx_packets++;
 
-               status = netbk_check_gop(vif, sco->meta_slots_used, &npo);
+               status = xenvif_check_gop(vif, sco->meta_slots_used, &npo);
 
                if (sco->meta_slots_used == 1)
                        flags = 0;
@@ -751,12 +590,12 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
                        flags |= XEN_NETRXF_data_validated;
 
                offset = 0;
-               resp = make_rx_response(vif, netbk->meta[npo.meta_cons].id,
+               resp = make_rx_response(vif, vif->meta[npo.meta_cons].id,
                                        status, offset,
-                                       netbk->meta[npo.meta_cons].size,
+                                       vif->meta[npo.meta_cons].size,
                                        flags);
 
-               if (netbk->meta[npo.meta_cons].gso_size && !vif->gso_prefix) {
+               if (vif->meta[npo.meta_cons].gso_size && !vif->gso_prefix) {
                        struct xen_netif_extra_info *gso =
                                (struct xen_netif_extra_info *)
                                RING_GET_RESPONSE(&vif->rx,
@@ -764,7 +603,7 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
 
                        resp->flags |= XEN_NETRXF_extra_info;
 
-                       gso->u.gso.size = netbk->meta[npo.meta_cons].gso_size;
+                       gso->u.gso.size = vif->meta[npo.meta_cons].gso_size;
                        gso->u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4;
                        gso->u.gso.pad = 0;
                        gso->u.gso.features = 0;
@@ -773,123 +612,44 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
                        gso->flags = 0;
                }
 
-               netbk_add_frag_responses(vif, status,
-                                        netbk->meta + npo.meta_cons + 1,
-                                        sco->meta_slots_used);
+               xenvif_add_frag_responses(vif, status,
+                                         vif->meta + npo.meta_cons + 1,
+                                         sco->meta_slots_used);
 
                RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret);
 
+               if (ret)
+                       need_to_notify = 1;
+
                xenvif_notify_tx_completion(vif);
 
-               if (ret && list_empty(&vif->notify_list))
-                       list_add_tail(&vif->notify_list, &notify);
-               else
-                       xenvif_put(vif);
                npo.meta_cons += sco->meta_slots_used;
                dev_kfree_skb(skb);
        }
 
-       list_for_each_entry_safe(vif, tmp, &notify, notify_list) {
+       if (need_to_notify)
                notify_remote_via_irq(vif->rx_irq);
-               list_del_init(&vif->notify_list);
-               xenvif_put(vif);
-       }
 
        /* More work to do? */
-       if (!skb_queue_empty(&netbk->rx_queue) &&
-                       !timer_pending(&netbk->net_timer))
-               xen_netbk_kick_thread(netbk);
-}
-
-void xen_netbk_queue_tx_skb(struct xenvif *vif, struct sk_buff *skb)
-{
-       struct xen_netbk *netbk = vif->netbk;
-
-       skb_queue_tail(&netbk->rx_queue, skb);
-
-       xen_netbk_kick_thread(netbk);
-}
-
-static void xen_netbk_alarm(unsigned long data)
-{
-       struct xen_netbk *netbk = (struct xen_netbk *)data;
-       xen_netbk_kick_thread(netbk);
-}
-
-static int __on_net_schedule_list(struct xenvif *vif)
-{
-       return !list_empty(&vif->schedule_list);
-}
-
-/* Must be called with net_schedule_list_lock held */
-static void remove_from_net_schedule_list(struct xenvif *vif)
-{
-       if (likely(__on_net_schedule_list(vif))) {
-               list_del_init(&vif->schedule_list);
-               xenvif_put(vif);
-       }
-}
-
-static struct xenvif *poll_net_schedule_list(struct xen_netbk *netbk)
-{
-       struct xenvif *vif = NULL;
-
-       spin_lock_irq(&netbk->net_schedule_list_lock);
-       if (list_empty(&netbk->net_schedule_list))
-               goto out;
-
-       vif = list_first_entry(&netbk->net_schedule_list,
-                              struct xenvif, schedule_list);
-       if (!vif)
-               goto out;
-
-       xenvif_get(vif);
-
-       remove_from_net_schedule_list(vif);
-out:
-       spin_unlock_irq(&netbk->net_schedule_list_lock);
-       return vif;
+       if (!skb_queue_empty(&vif->rx_queue))
+               xenvif_kick_thread(vif);
 }
 
-void xen_netbk_schedule_xenvif(struct xenvif *vif)
+void xenvif_queue_tx_skb(struct xenvif *vif, struct sk_buff *skb)
 {
-       unsigned long flags;
-       struct xen_netbk *netbk = vif->netbk;
-
-       if (__on_net_schedule_list(vif))
-               goto kick;
-
-       spin_lock_irqsave(&netbk->net_schedule_list_lock, flags);
-       if (!__on_net_schedule_list(vif) &&
-           likely(xenvif_schedulable(vif))) {
-               list_add_tail(&vif->schedule_list, &netbk->net_schedule_list);
-               xenvif_get(vif);
-       }
-       spin_unlock_irqrestore(&netbk->net_schedule_list_lock, flags);
-
-kick:
-       smp_mb();
-       if ((nr_pending_reqs(netbk) < (MAX_PENDING_REQS/2)) &&
-           !list_empty(&netbk->net_schedule_list))
-               xen_netbk_kick_thread(netbk);
-}
+       skb_queue_tail(&vif->rx_queue, skb);
 
-void xen_netbk_deschedule_xenvif(struct xenvif *vif)
-{
-       struct xen_netbk *netbk = vif->netbk;
-       spin_lock_irq(&netbk->net_schedule_list_lock);
-       remove_from_net_schedule_list(vif);
-       spin_unlock_irq(&netbk->net_schedule_list_lock);
+       xenvif_kick_thread(vif);
 }
 
-void xen_netbk_check_rx_xenvif(struct xenvif *vif)
+void xenvif_check_rx_xenvif(struct xenvif *vif)
 {
        int more_to_do;
 
        RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, more_to_do);
 
        if (more_to_do)
-               xen_netbk_schedule_xenvif(vif);
+               napi_schedule(&vif->napi);
 }
 
 static void tx_add_credit(struct xenvif *vif)
@@ -916,11 +676,11 @@ static void tx_credit_callback(unsigned long data)
 {
        struct xenvif *vif = (struct xenvif *)data;
        tx_add_credit(vif);
-       xen_netbk_check_rx_xenvif(vif);
+       xenvif_check_rx_xenvif(vif);
 }
 
-static void netbk_tx_err(struct xenvif *vif,
-                        struct xen_netif_tx_request *txp, RING_IDX end)
+static void xenvif_tx_err(struct xenvif *vif,
+                         struct xen_netif_tx_request *txp, RING_IDX end)
 {
        RING_IDX cons = vif->tx.req_cons;
 
@@ -931,21 +691,18 @@ static void netbk_tx_err(struct xenvif *vif,
                txp = RING_GET_REQUEST(&vif->tx, cons++);
        } while (1);
        vif->tx.req_cons = cons;
-       xen_netbk_check_rx_xenvif(vif);
-       xenvif_put(vif);
 }
 
-static void netbk_fatal_tx_err(struct xenvif *vif)
+static void xenvif_fatal_tx_err(struct xenvif *vif)
 {
        netdev_err(vif->dev, "fatal error; disabling device\n");
        xenvif_carrier_off(vif);
-       xenvif_put(vif);
 }
 
-static int netbk_count_requests(struct xenvif *vif,
-                               struct xen_netif_tx_request *first,
-                               struct xen_netif_tx_request *txp,
-                               int work_to_do)
+static int xenvif_count_requests(struct xenvif *vif,
+                                struct xen_netif_tx_request *first,
+                                struct xen_netif_tx_request *txp,
+                                int work_to_do)
 {
        RING_IDX cons = vif->tx.req_cons;
        int slots = 0;
@@ -962,7 +719,7 @@ static int netbk_count_requests(struct xenvif *vif,
                        netdev_err(vif->dev,
                                   "Asked for %d slots but exceeds this limit\n",
                                   work_to_do);
-                       netbk_fatal_tx_err(vif);
+                       xenvif_fatal_tx_err(vif);
                        return -ENODATA;
                }
 
@@ -973,7 +730,7 @@ static int netbk_count_requests(struct xenvif *vif,
                        netdev_err(vif->dev,
                                   "Malicious frontend using %d slots, threshold %u\n",
                                   slots, fatal_skb_slots);
-                       netbk_fatal_tx_err(vif);
+                       xenvif_fatal_tx_err(vif);
                        return -E2BIG;
                }
 
@@ -1021,7 +778,7 @@ static int netbk_count_requests(struct xenvif *vif,
                if (unlikely((txp->offset + txp->size) > PAGE_SIZE)) {
                        netdev_err(vif->dev, "Cross page boundary, txp->offset: %x, size: %u\n",
                                 txp->offset, txp->size);
-                       netbk_fatal_tx_err(vif);
+                       xenvif_fatal_tx_err(vif);
                        return -EINVAL;
                }
 
@@ -1033,30 +790,30 @@ static int netbk_count_requests(struct xenvif *vif,
        } while (more_data);
 
        if (drop_err) {
-               netbk_tx_err(vif, first, cons + slots);
+               xenvif_tx_err(vif, first, cons + slots);
                return drop_err;
        }
 
        return slots;
 }
 
-static struct page *xen_netbk_alloc_page(struct xen_netbk *netbk,
-                                        u16 pending_idx)
+static struct page *xenvif_alloc_page(struct xenvif *vif,
+                                     u16 pending_idx)
 {
        struct page *page;
-       page = alloc_page(GFP_KERNEL|__GFP_COLD);
+
+       page = alloc_page(GFP_ATOMIC|__GFP_COLD);
        if (!page)
                return NULL;
-       set_page_ext(page, netbk, pending_idx);
-       netbk->mmap_pages[pending_idx] = page;
+       vif->mmap_pages[pending_idx] = page;
+
        return page;
 }
 
-static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
-                                                 struct xenvif *vif,
-                                                 struct sk_buff *skb,
-                                                 struct xen_netif_tx_request *txp,
-                                                 struct gnttab_copy *gop)
+static struct gnttab_copy *xenvif_get_requests(struct xenvif *vif,
+                                              struct sk_buff *skb,
+                                              struct xen_netif_tx_request *txp,
+                                              struct gnttab_copy *gop)
 {
        struct skb_shared_info *shinfo = skb_shinfo(skb);
        skb_frag_t *frags = shinfo->frags;
@@ -1079,14 +836,14 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
 
        /* Coalesce tx requests, at this point the packet passed in
         * should be <= 64K. Any packets larger than 64K have been
-        * handled in netbk_count_requests().
+        * handled in xenvif_count_requests().
         */
        for (shinfo->nr_frags = slot = start; slot < nr_slots;
             shinfo->nr_frags++) {
                struct pending_tx_info *pending_tx_info =
-                       netbk->pending_tx_info;
+                       vif->pending_tx_info;
 
-               page = alloc_page(GFP_KERNEL|__GFP_COLD);
+               page = alloc_page(GFP_ATOMIC|__GFP_COLD);
                if (!page)
                        goto err;
 
@@ -1121,21 +878,18 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
                                gop->len = txp->size;
                                dst_offset += gop->len;
 
-                               index = pending_index(netbk->pending_cons++);
+                               index = pending_index(vif->pending_cons++);
 
-                               pending_idx = netbk->pending_ring[index];
+                               pending_idx = vif->pending_ring[index];
 
                                memcpy(&pending_tx_info[pending_idx].req, txp,
                                       sizeof(*txp));
-                               xenvif_get(vif);
-
-                               pending_tx_info[pending_idx].vif = vif;
 
                                /* Poison these fields, corresponding
                                 * fields for head tx req will be set
                                 * to correct values after the loop.
                                 */
-                               netbk->mmap_pages[pending_idx] = (void *)(~0UL);
+                               vif->mmap_pages[pending_idx] = (void *)(~0UL);
                                pending_tx_info[pending_idx].head =
                                        INVALID_PENDING_RING_IDX;
 
@@ -1155,8 +909,7 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
                first->req.offset = 0;
                first->req.size = dst_offset;
                first->head = start_idx;
-               set_page_ext(page, netbk, head_idx);
-               netbk->mmap_pages[head_idx] = page;
+               vif->mmap_pages[head_idx] = page;
                frag_set_pending_idx(&frags[shinfo->nr_frags], head_idx);
        }
 
@@ -1166,20 +919,20 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
 err:
        /* Unwind, freeing all pages and sending error responses. */
        while (shinfo->nr_frags-- > start) {
-               xen_netbk_idx_release(netbk,
+               xenvif_idx_release(vif,
                                frag_get_pending_idx(&frags[shinfo->nr_frags]),
                                XEN_NETIF_RSP_ERROR);
        }
        /* The head too, if necessary. */
        if (start)
-               xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_ERROR);
+               xenvif_idx_release(vif, pending_idx, XEN_NETIF_RSP_ERROR);
 
        return NULL;
 }
 
-static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
-                                 struct sk_buff *skb,
-                                 struct gnttab_copy **gopp)
+static int xenvif_tx_check_gop(struct xenvif *vif,
+                              struct sk_buff *skb,
+                              struct gnttab_copy **gopp)
 {
        struct gnttab_copy *gop = *gopp;
        u16 pending_idx = *((u16 *)skb->data);
@@ -1192,7 +945,7 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
        /* Check status of header. */
        err = gop->status;
        if (unlikely(err))
-               xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_ERROR);
+               xenvif_idx_release(vif, pending_idx, XEN_NETIF_RSP_ERROR);
 
        /* Skip first skb fragment if it is on same page as header fragment. */
        start = (frag_get_pending_idx(&shinfo->frags[0]) == pending_idx);
@@ -1202,7 +955,7 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
                pending_ring_idx_t head;
 
                pending_idx = frag_get_pending_idx(&shinfo->frags[i]);
-               tx_info = &netbk->pending_tx_info[pending_idx];
+               tx_info = &vif->pending_tx_info[pending_idx];
                head = tx_info->head;
 
                /* Check error status: if okay then remember grant handle. */
@@ -1210,18 +963,19 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
                        newerr = (++gop)->status;
                        if (newerr)
                                break;
-                       peek = netbk->pending_ring[pending_index(++head)];
-               } while (!pending_tx_is_head(netbk, peek));
+                       peek = vif->pending_ring[pending_index(++head)];
+               } while (!pending_tx_is_head(vif, peek));
 
                if (likely(!newerr)) {
                        /* Had a previous error? Invalidate this fragment. */
                        if (unlikely(err))
-                               xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
+                               xenvif_idx_release(vif, pending_idx,
+                                                  XEN_NETIF_RSP_OKAY);
                        continue;
                }
 
                /* Error on this fragment: respond to client with an error. */
-               xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_ERROR);
+               xenvif_idx_release(vif, pending_idx, XEN_NETIF_RSP_ERROR);
 
                /* Not the first error? Preceding frags already invalidated. */
                if (err)
@@ -1229,10 +983,11 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
 
                /* First error: invalidate header and preceding fragments. */
                pending_idx = *((u16 *)skb->data);
-               xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
+               xenvif_idx_release(vif, pending_idx, XEN_NETIF_RSP_OKAY);
                for (j = start; j < i; j++) {
                        pending_idx = frag_get_pending_idx(&shinfo->frags[j]);
-                       xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
+                       xenvif_idx_release(vif, pending_idx,
+                                          XEN_NETIF_RSP_OKAY);
                }
 
                /* Remember the error: invalidate all subsequent fragments. */
@@ -1243,7 +998,7 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
        return err;
 }
 
-static void xen_netbk_fill_frags(struct xen_netbk *netbk, struct sk_buff *skb)
+static void xenvif_fill_frags(struct xenvif *vif, struct sk_buff *skb)
 {
        struct skb_shared_info *shinfo = skb_shinfo(skb);
        int nr_frags = shinfo->nr_frags;
@@ -1257,20 +1012,20 @@ static void xen_netbk_fill_frags(struct xen_netbk *netbk, struct sk_buff *skb)
 
                pending_idx = frag_get_pending_idx(frag);
 
-               txp = &netbk->pending_tx_info[pending_idx].req;
-               page = virt_to_page(idx_to_kaddr(netbk, pending_idx));
+               txp = &vif->pending_tx_info[pending_idx].req;
+               page = virt_to_page(idx_to_kaddr(vif, pending_idx));
                __skb_fill_page_desc(skb, i, page, txp->offset, txp->size);
                skb->len += txp->size;
                skb->data_len += txp->size;
                skb->truesize += txp->size;
 
-               /* Take an extra reference to offset xen_netbk_idx_release */
-               get_page(netbk->mmap_pages[pending_idx]);
-               xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
+               /* Take an extra reference to offset xenvif_idx_release */
+               get_page(vif->mmap_pages[pending_idx]);
+               xenvif_idx_release(vif, pending_idx, XEN_NETIF_RSP_OKAY);
        }
 }
 
-static int xen_netbk_get_extras(struct xenvif *vif,
+static int xenvif_get_extras(struct xenvif *vif,
                                struct xen_netif_extra_info *extras,
                                int work_to_do)
 {
@@ -1280,7 +1035,7 @@ static int xen_netbk_get_extras(struct xenvif *vif,
        do {
                if (unlikely(work_to_do-- <= 0)) {
                        netdev_err(vif->dev, "Missing extra info\n");
-                       netbk_fatal_tx_err(vif);
+                       xenvif_fatal_tx_err(vif);
                        return -EBADR;
                }
 
@@ -1291,7 +1046,7 @@ static int xen_netbk_get_extras(struct xenvif *vif,
                        vif->tx.req_cons = ++cons;
                        netdev_err(vif->dev,
                                   "Invalid extra type: %d\n", extra.type);
-                       netbk_fatal_tx_err(vif);
+                       xenvif_fatal_tx_err(vif);
                        return -EINVAL;
                }
 
@@ -1302,20 +1057,20 @@ static int xen_netbk_get_extras(struct xenvif *vif,
        return work_to_do;
 }
 
-static int netbk_set_skb_gso(struct xenvif *vif,
-                            struct sk_buff *skb,
-                            struct xen_netif_extra_info *gso)
+static int xenvif_set_skb_gso(struct xenvif *vif,
+                             struct sk_buff *skb,
+                             struct xen_netif_extra_info *gso)
 {
        if (!gso->u.gso.size) {
                netdev_err(vif->dev, "GSO size must not be zero.\n");
-               netbk_fatal_tx_err(vif);
+               xenvif_fatal_tx_err(vif);
                return -EINVAL;
        }
 
        /* Currently only TCPv4 S.O. is supported. */
        if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) {
                netdev_err(vif->dev, "Bad GSO type %d.\n", gso->u.gso.type);
-               netbk_fatal_tx_err(vif);
+               xenvif_fatal_tx_err(vif);
                return -EINVAL;
        }
 
@@ -1426,16 +1181,14 @@ static bool tx_credit_exceeded(struct xenvif *vif, unsigned size)
        return false;
 }
 
-static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
+static unsigned xenvif_tx_build_gops(struct xenvif *vif)
 {
-       struct gnttab_copy *gop = netbk->tx_copy_ops, *request_gop;
+       struct gnttab_copy *gop = vif->tx_copy_ops, *request_gop;
        struct sk_buff *skb;
        int ret;
 
-       while ((nr_pending_reqs(netbk) + XEN_NETBK_LEGACY_SLOTS_MAX
-               < MAX_PENDING_REQS) &&
-               !list_empty(&netbk->net_schedule_list)) {
-               struct xenvif *vif;
+       while ((nr_pending_reqs(vif) + XEN_NETBK_LEGACY_SLOTS_MAX
+               < MAX_PENDING_REQS)) {
                struct xen_netif_tx_request txreq;
                struct xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX];
                struct page *page;
@@ -1446,16 +1199,6 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                unsigned int data_len;
                pending_ring_idx_t index;
 
-               /* Get a netif from the list with work to do. */
-               vif = poll_net_schedule_list(netbk);
-               /* This can sometimes happen because the test of
-                * list_empty(net_schedule_list) at the top of the
-                * loop is unlocked.  Just go back and have another
-                * look.
-                */
-               if (!vif)
-                       continue;
-
                if (vif->tx.sring->req_prod - vif->tx.req_cons >
                    XEN_NETIF_TX_RING_SIZE) {
                        netdev_err(vif->dev,
@@ -1463,15 +1206,13 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                                   "req_prod %d, req_cons %d, size %ld\n",
                                   vif->tx.sring->req_prod, vif->tx.req_cons,
                                   XEN_NETIF_TX_RING_SIZE);
-                       netbk_fatal_tx_err(vif);
+                       xenvif_fatal_tx_err(vif);
                        continue;
                }
 
                RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, work_to_do);
-               if (!work_to_do) {
-                       xenvif_put(vif);
-                       continue;
-               }
+               if (!work_to_do)
+                       break;
 
                idx = vif->tx.req_cons;
                rmb(); /* Ensure that we see the request before we copy it. */
@@ -1479,10 +1220,8 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
 
                /* Credit-based scheduling. */
                if (txreq.size > vif->remaining_credit &&
-                   tx_credit_exceeded(vif, txreq.size)) {
-                       xenvif_put(vif);
-                       continue;
-               }
+                   tx_credit_exceeded(vif, txreq.size))
+                       break;
 
                vif->remaining_credit -= txreq.size;
 
@@ -1491,24 +1230,24 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
 
                memset(extras, 0, sizeof(extras));
                if (txreq.flags & XEN_NETTXF_extra_info) {
-                       work_to_do = xen_netbk_get_extras(vif, extras,
-                                                         work_to_do);
+                       work_to_do = xenvif_get_extras(vif, extras,
+                                                      work_to_do);
                        idx = vif->tx.req_cons;
                        if (unlikely(work_to_do < 0))
-                               continue;
+                               break;
                }
 
-               ret = netbk_count_requests(vif, &txreq, txfrags, work_to_do);
+               ret = xenvif_count_requests(vif, &txreq, txfrags, work_to_do);
                if (unlikely(ret < 0))
-                       continue;
+                       break;
 
                idx += ret;
 
                if (unlikely(txreq.size < ETH_HLEN)) {
                        netdev_dbg(vif->dev,
                                   "Bad packet size: %d\n", txreq.size);
-                       netbk_tx_err(vif, &txreq, idx);
-                       continue;
+                       xenvif_tx_err(vif, &txreq, idx);
+                       break;
                }
 
                /* No crossing a page as the payload mustn't fragment. */
@@ -1517,12 +1256,12 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                                   "txreq.offset: %x, size: %u, end: %lu\n",
                                   txreq.offset, txreq.size,
                                   (txreq.offset&~PAGE_MASK) + txreq.size);
-                       netbk_fatal_tx_err(vif);
-                       continue;
+                       xenvif_fatal_tx_err(vif);
+                       break;
                }
 
-               index = pending_index(netbk->pending_cons);
-               pending_idx = netbk->pending_ring[index];
+               index = pending_index(vif->pending_cons);
+               pending_idx = vif->pending_ring[index];
 
                data_len = (txreq.size > PKT_PROT_LEN &&
                            ret < XEN_NETBK_LEGACY_SLOTS_MAX) ?
@@ -1533,7 +1272,7 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                if (unlikely(skb == NULL)) {
                        netdev_dbg(vif->dev,
                                   "Can't allocate a skb in start_xmit.\n");
-                       netbk_tx_err(vif, &txreq, idx);
+                       xenvif_tx_err(vif, &txreq, idx);
                        break;
                }
 
@@ -1544,19 +1283,19 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                        struct xen_netif_extra_info *gso;
                        gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1];
 
-                       if (netbk_set_skb_gso(vif, skb, gso)) {
-                               /* Failure in netbk_set_skb_gso is fatal. */
+                       if (xenvif_set_skb_gso(vif, skb, gso)) {
+                               /* Failure in xenvif_set_skb_gso is fatal. */
                                kfree_skb(skb);
-                               continue;
+                               break;
                        }
                }
 
                /* XXX could copy straight to head */
-               page = xen_netbk_alloc_page(netbk, pending_idx);
+               page = xenvif_alloc_page(vif, pending_idx);
                if (!page) {
                        kfree_skb(skb);
-                       netbk_tx_err(vif, &txreq, idx);
-                       continue;
+                       xenvif_tx_err(vif, &txreq, idx);
+                       break;
                }
 
                gop->source.u.ref = txreq.gref;
@@ -1572,10 +1311,9 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
 
                gop++;
 
-               memcpy(&netbk->pending_tx_info[pending_idx].req,
+               memcpy(&vif->pending_tx_info[pending_idx].req,
                       &txreq, sizeof(txreq));
-               netbk->pending_tx_info[pending_idx].vif = vif;
-               netbk->pending_tx_info[pending_idx].head = index;
+               vif->pending_tx_info[pending_idx].head = index;
                *((u16 *)skb->data) = pending_idx;
 
                __skb_put(skb, data_len);
@@ -1590,46 +1328,45 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
                                             INVALID_PENDING_IDX);
                }
 
-               netbk->pending_cons++;
+               vif->pending_cons++;
 
-               request_gop = xen_netbk_get_requests(netbk, vif,
-                                                    skb, txfrags, gop);
+               request_gop = xenvif_get_requests(vif, skb, txfrags, gop);
                if (request_gop == NULL) {
                        kfree_skb(skb);
-                       netbk_tx_err(vif, &txreq, idx);
-                       continue;
+                       xenvif_tx_err(vif, &txreq, idx);
+                       break;
                }
                gop = request_gop;
 
-               __skb_queue_tail(&netbk->tx_queue, skb);
+               __skb_queue_tail(&vif->tx_queue, skb);
 
                vif->tx.req_cons = idx;
-               xen_netbk_check_rx_xenvif(vif);
 
-               if ((gop-netbk->tx_copy_ops) >= ARRAY_SIZE(netbk->tx_copy_ops))
+               if ((gop-vif->tx_copy_ops) >= ARRAY_SIZE(vif->tx_copy_ops))
                        break;
        }
 
-       return gop - netbk->tx_copy_ops;
+       return gop - vif->tx_copy_ops;
 }
 
-static void xen_netbk_tx_submit(struct xen_netbk *netbk)
+
+static int xenvif_tx_submit(struct xenvif *vif, int budget)
 {
-       struct gnttab_copy *gop = netbk->tx_copy_ops;
+       struct gnttab_copy *gop = vif->tx_copy_ops;
        struct sk_buff *skb;
+       int work_done = 0;
 
-       while ((skb = __skb_dequeue(&netbk->tx_queue)) != NULL) {
+       while (work_done < budget &&
+              (skb = __skb_dequeue(&vif->tx_queue)) != NULL) {
                struct xen_netif_tx_request *txp;
-               struct xenvif *vif;
                u16 pending_idx;
                unsigned data_len;
 
                pending_idx = *((u16 *)skb->data);
-               vif = netbk->pending_tx_info[pending_idx].vif;
-               txp = &netbk->pending_tx_info[pending_idx].req;
+               txp = &vif->pending_tx_info[pending_idx].req;
 
                /* Check the remap error code. */
-               if (unlikely(xen_netbk_tx_check_gop(netbk, skb, &gop))) {
+               if (unlikely(xenvif_tx_check_gop(vif, skb, &gop))) {
                        netdev_dbg(vif->dev, "netback grant failed.\n");
                        skb_shinfo(skb)->nr_frags = 0;
                        kfree_skb(skb);
@@ -1638,7 +1375,7 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
 
                data_len = skb->len;
                memcpy(skb->data,
-                      (void *)(idx_to_kaddr(netbk, pending_idx)|txp->offset),
+                      (void *)(idx_to_kaddr(vif, pending_idx)|txp->offset),
                       data_len);
                if (data_len < txp->size) {
                        /* Append the packet payload as a fragment. */
@@ -1646,7 +1383,8 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
                        txp->size -= data_len;
                } else {
                        /* Schedule a response immediately. */
-                       xen_netbk_idx_release(netbk, pending_idx, XEN_NETIF_RSP_OKAY);
+                       xenvif_idx_release(vif, pending_idx,
+                                          XEN_NETIF_RSP_OKAY);
                }
 
                if (txp->flags & XEN_NETTXF_csum_blank)
@@ -1654,7 +1392,7 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
                else if (txp->flags & XEN_NETTXF_data_validated)
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-               xen_netbk_fill_frags(netbk, skb);
+               xenvif_fill_frags(vif, skb);
 
                /*
                 * If the initial fragment was < PKT_PROT_LEN then
@@ -1682,53 +1420,61 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
                vif->dev->stats.rx_bytes += skb->len;
                vif->dev->stats.rx_packets++;
 
-               xenvif_receive_skb(vif, skb);
+               work_done++;
+
+               netif_receive_skb(skb);
        }
+
+       return work_done;
 }
 
 /* Called after netfront has transmitted */
-static void xen_netbk_tx_action(struct xen_netbk *netbk)
+int xenvif_tx_action(struct xenvif *vif, int budget)
 {
        unsigned nr_gops;
+       int work_done;
+
+       if (unlikely(!tx_work_todo(vif)))
+               return 0;
 
-       nr_gops = xen_netbk_tx_build_gops(netbk);
+       nr_gops = xenvif_tx_build_gops(vif);
 
        if (nr_gops == 0)
-               return;
+               return 0;
 
-       gnttab_batch_copy(netbk->tx_copy_ops, nr_gops);
+       gnttab_batch_copy(vif->tx_copy_ops, nr_gops);
 
-       xen_netbk_tx_submit(netbk);
+       work_done = xenvif_tx_submit(vif, nr_gops);
+
+       return work_done;
 }
 
-static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx,
-                                 u8 status)
+static void xenvif_idx_release(struct xenvif *vif, u16 pending_idx,
+                              u8 status)
 {
-       struct xenvif *vif;
        struct pending_tx_info *pending_tx_info;
        pending_ring_idx_t head;
        u16 peek; /* peek into next tx request */
 
-       BUG_ON(netbk->mmap_pages[pending_idx] == (void *)(~0UL));
+       BUG_ON(vif->mmap_pages[pending_idx] == (void *)(~0UL));
 
        /* Already complete? */
-       if (netbk->mmap_pages[pending_idx] == NULL)
+       if (vif->mmap_pages[pending_idx] == NULL)
                return;
 
-       pending_tx_info = &netbk->pending_tx_info[pending_idx];
+       pending_tx_info = &vif->pending_tx_info[pending_idx];
 
-       vif = pending_tx_info->vif;
        head = pending_tx_info->head;
 
-       BUG_ON(!pending_tx_is_head(netbk, head));
-       BUG_ON(netbk->pending_ring[pending_index(head)] != pending_idx);
+       BUG_ON(!pending_tx_is_head(vif, head));
+       BUG_ON(vif->pending_ring[pending_index(head)] != pending_idx);
 
        do {
                pending_ring_idx_t index;
                pending_ring_idx_t idx = pending_index(head);
-               u16 info_idx = netbk->pending_ring[idx];
+               u16 info_idx = vif->pending_ring[idx];
 
-               pending_tx_info = &netbk->pending_tx_info[info_idx];
+               pending_tx_info = &vif->pending_tx_info[info_idx];
                make_tx_response(vif, &pending_tx_info->req, status);
 
                /* Setting any number other than
@@ -1737,18 +1483,15 @@ static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx,
                 */
                pending_tx_info->head = 0;
 
-               index = pending_index(netbk->pending_prod++);
-               netbk->pending_ring[index] = netbk->pending_ring[info_idx];
-
-               xenvif_put(vif);
+               index = pending_index(vif->pending_prod++);
+               vif->pending_ring[index] = vif->pending_ring[info_idx];
 
-               peek = netbk->pending_ring[pending_index(++head)];
+               peek = vif->pending_ring[pending_index(++head)];
 
-       } while (!pending_tx_is_head(netbk, peek));
+       } while (!pending_tx_is_head(vif, peek));
 
-       netbk->mmap_pages[pending_idx]->mapping = 0;
-       put_page(netbk->mmap_pages[pending_idx]);
-       netbk->mmap_pages[pending_idx] = NULL;
+       put_page(vif->mmap_pages[pending_idx]);
+       vif->mmap_pages[pending_idx] = NULL;
 }
 
 
@@ -1796,46 +1539,23 @@ static struct xen_netif_rx_response *make_rx_response(struct xenvif *vif,
        return resp;
 }
 
-static inline int rx_work_todo(struct xen_netbk *netbk)
+static inline int rx_work_todo(struct xenvif *vif)
 {
-       return !skb_queue_empty(&netbk->rx_queue);
+       return !skb_queue_empty(&vif->rx_queue);
 }
 
-static inline int tx_work_todo(struct xen_netbk *netbk)
+static inline int tx_work_todo(struct xenvif *vif)
 {
 
-       if ((nr_pending_reqs(netbk) + XEN_NETBK_LEGACY_SLOTS_MAX
-            < MAX_PENDING_REQS) &&
-            !list_empty(&netbk->net_schedule_list))
+       if (likely(RING_HAS_UNCONSUMED_REQUESTS(&vif->tx)) &&
+           (nr_pending_reqs(vif) + XEN_NETBK_LEGACY_SLOTS_MAX
+            < MAX_PENDING_REQS))
                return 1;
 
        return 0;
 }
 
-static int xen_netbk_kthread(void *data)
-{
-       struct xen_netbk *netbk = data;
-       while (!kthread_should_stop()) {
-               wait_event_interruptible(netbk->wq,
-                               rx_work_todo(netbk) ||
-                               tx_work_todo(netbk) ||
-                               kthread_should_stop());
-               cond_resched();
-
-               if (kthread_should_stop())
-                       break;
-
-               if (rx_work_todo(netbk))
-                       xen_netbk_rx_action(netbk);
-
-               if (tx_work_todo(netbk))
-                       xen_netbk_tx_action(netbk);
-       }
-
-       return 0;
-}
-
-void xen_netbk_unmap_frontend_rings(struct xenvif *vif)
+void xenvif_unmap_frontend_rings(struct xenvif *vif)
 {
        if (vif->tx.sring)
                xenbus_unmap_ring_vfree(xenvif_to_xenbus_device(vif),
@@ -1845,9 +1565,9 @@ void xen_netbk_unmap_frontend_rings(struct xenvif *vif)
                                        vif->rx.sring);
 }
 
-int xen_netbk_map_frontend_rings(struct xenvif *vif,
-                                grant_ref_t tx_ring_ref,
-                                grant_ref_t rx_ring_ref)
+int xenvif_map_frontend_rings(struct xenvif *vif,
+                             grant_ref_t tx_ring_ref,
+                             grant_ref_t rx_ring_ref)
 {
        void *addr;
        struct xen_netif_tx_sring *txs;
@@ -1876,15 +1596,33 @@ int xen_netbk_map_frontend_rings(struct xenvif *vif,
        return 0;
 
 err:
-       xen_netbk_unmap_frontend_rings(vif);
+       xenvif_unmap_frontend_rings(vif);
        return err;
 }
 
+int xenvif_kthread(void *data)
+{
+       struct xenvif *vif = data;
+
+       while (!kthread_should_stop()) {
+               wait_event_interruptible(vif->wq,
+                                        rx_work_todo(vif) ||
+                                        kthread_should_stop());
+               if (kthread_should_stop())
+                       break;
+
+               if (rx_work_todo(vif))
+                       xenvif_rx_action(vif);
+
+               cond_resched();
+       }
+
+       return 0;
+}
+
 static int __init netback_init(void)
 {
-       int i;
        int rc = 0;
-       int group;
 
        if (!xen_domain())
                return -ENODEV;
@@ -1895,48 +1633,6 @@ static int __init netback_init(void)
                fatal_skb_slots = XEN_NETBK_LEGACY_SLOTS_MAX;
        }
 
-       xen_netbk_group_nr = num_online_cpus();
-       xen_netbk = vzalloc(sizeof(struct xen_netbk) * xen_netbk_group_nr);
-       if (!xen_netbk)
-               return -ENOMEM;
-
-       for (group = 0; group < xen_netbk_group_nr; group++) {
-               struct xen_netbk *netbk = &xen_netbk[group];
-               skb_queue_head_init(&netbk->rx_queue);
-               skb_queue_head_init(&netbk->tx_queue);
-
-               init_timer(&netbk->net_timer);
-               netbk->net_timer.data = (unsigned long)netbk;
-               netbk->net_timer.function = xen_netbk_alarm;
-
-               netbk->pending_cons = 0;
-               netbk->pending_prod = MAX_PENDING_REQS;
-               for (i = 0; i < MAX_PENDING_REQS; i++)
-                       netbk->pending_ring[i] = i;
-
-               init_waitqueue_head(&netbk->wq);
-               netbk->task = kthread_create(xen_netbk_kthread,
-                                            (void *)netbk,
-                                            "netback/%u", group);
-
-               if (IS_ERR(netbk->task)) {
-                       pr_alert("kthread_create() fails at netback\n");
-                       del_timer(&netbk->net_timer);
-                       rc = PTR_ERR(netbk->task);
-                       goto failed_init;
-               }
-
-               kthread_bind(netbk->task, group);
-
-               INIT_LIST_HEAD(&netbk->net_schedule_list);
-
-               spin_lock_init(&netbk->net_schedule_list_lock);
-
-               atomic_set(&netbk->netfront_count, 0);
-
-               wake_up_process(netbk->task);
-       }
-
        rc = xenvif_xenbus_init();
        if (rc)
                goto failed_init;
@@ -1944,35 +1640,14 @@ static int __init netback_init(void)
        return 0;
 
 failed_init:
-       while (--group >= 0) {
-               struct xen_netbk *netbk = &xen_netbk[group];
-               del_timer(&netbk->net_timer);
-               kthread_stop(netbk->task);
-       }
-       vfree(xen_netbk);
        return rc;
-
 }
 
 module_init(netback_init);
 
 static void __exit netback_fini(void)
 {
-       int i, j;
-
        xenvif_xenbus_fini();
-
-       for (i = 0; i < xen_netbk_group_nr; i++) {
-               struct xen_netbk *netbk = &xen_netbk[i];
-               del_timer_sync(&netbk->net_timer);
-               kthread_stop(netbk->task);
-               for (j = 0; j < MAX_PENDING_REQS; j++) {
-                       if (netbk->mmap_pages[j])
-                               __free_page(netbk->mmap_pages[j]);
-               }
-       }
-
-       vfree(xen_netbk);
 }
 module_exit(netback_fini);
 
index ff7f111fffeed780b1c5581c10561dbe237866ce..36808bf256770a5e02e7674002ed389c7fd8ac19 100644 (file)
@@ -286,8 +286,7 @@ no_skb:
                        break;
                }
 
-               __skb_fill_page_desc(skb, 0, page, 0, 0);
-               skb_shinfo(skb)->nr_frags = 1;
+               skb_add_rx_frag(skb, 0, page, 0, 0, PAGE_SIZE);
                __skb_queue_tail(&np->rx_batch, skb);
        }
 
@@ -831,7 +830,6 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,
                                  struct sk_buff_head *list)
 {
        struct skb_shared_info *shinfo = skb_shinfo(skb);
-       int nr_frags = shinfo->nr_frags;
        RING_IDX cons = np->rx.rsp_cons;
        struct sk_buff *nskb;
 
@@ -840,19 +838,21 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,
                        RING_GET_RESPONSE(&np->rx, ++cons);
                skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0];
 
-               __skb_fill_page_desc(skb, nr_frags,
-                                    skb_frag_page(nfrag),
-                                    rx->offset, rx->status);
+               if (shinfo->nr_frags == MAX_SKB_FRAGS) {
+                       unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
 
-               skb->data_len += rx->status;
+                       BUG_ON(pull_to <= skb_headlen(skb));
+                       __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
+               }
+               BUG_ON(shinfo->nr_frags >= MAX_SKB_FRAGS);
+
+               skb_add_rx_frag(skb, shinfo->nr_frags, skb_frag_page(nfrag),
+                               rx->offset, rx->status, PAGE_SIZE);
 
                skb_shinfo(nskb)->nr_frags = 0;
                kfree_skb(nskb);
-
-               nr_frags++;
        }
 
-       shinfo->nr_frags = nr_frags;
        return cons;
 }
 
@@ -933,7 +933,8 @@ static int handle_incoming_queue(struct net_device *dev,
        while ((skb = __skb_dequeue(rxq)) != NULL) {
                int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
 
-               __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
+               if (pull_to > skb_headlen(skb))
+                       __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
 
                /* Ethernet work: Delayed to here as it peeks the header. */
                skb->protocol = eth_type_trans(skb, dev);
@@ -1019,16 +1020,10 @@ err:
                skb_shinfo(skb)->frags[0].page_offset = rx->offset;
                skb_frag_size_set(&skb_shinfo(skb)->frags[0], rx->status);
                skb->data_len = rx->status;
+               skb->len += rx->status;
 
                i = xennet_fill_frags(np, skb, &tmpq);
 
-               /*
-                 * Truesize is the actual allocation size, even if the
-                 * allocation is only partially used.
-                 */
-               skb->truesize += PAGE_SIZE * skb_shinfo(skb)->nr_frags;
-               skb->len += skb->data_len;
-
                if (rx->flags & XEN_NETRXF_csum_blank)
                        skb->ip_summed = CHECKSUM_PARTIAL;
                else if (rx->flags & XEN_NETRXF_data_validated)
index 6bb7cf2de556b559d1f54f9d1c7c3ff297138a3a..b10ba00cc3e6d00f476fc99e1f35daa26f5ae2e6 100644 (file)
@@ -392,6 +392,8 @@ static void __unflatten_device_tree(struct boot_param_header *blob,
        mem = (unsigned long)
                dt_alloc(size + 4, __alignof__(struct device_node));
 
+       memset((void *)mem, 0, size);
+
        ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
 
        pr_debug("  unflattening %lx...\n", mem);
index a3c1c5aae6a9eaa5de0ecd0dd0335771ac8f7fab..1264923ade0f2c7973528080d3fa75167b6be0b4 100644 (file)
@@ -345,6 +345,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
        if (r && irq) {
                const char *name = NULL;
 
+               memset(r, 0, sizeof(*r));
                /*
                 * Get optional "interrupts-names" property to add a name
                 * to the resource.
@@ -482,8 +483,9 @@ void __init of_irq_init(const struct of_device_id *matches)
                }
 
                /* Get the next pending parent that might have children */
-               desc = list_first_entry(&intc_parent_list, typeof(*desc), list);
-               if (list_empty(&intc_parent_list) || !desc) {
+               desc = list_first_entry_or_null(&intc_parent_list,
+                                               typeof(*desc), list);
+               if (!desc) {
                        pr_err("of_irq_init: children remain, but no parents\n");
                        break;
                }
index 93404f72dfa8197a9f2292c70e5988424614a9f0..61be1d9c16c85f6da3243b74b6b5c63ec3cef774 100644 (file)
@@ -74,8 +74,8 @@ static void oprofile_hrtimer_stop(void)
        put_online_cpus();
 }
 
-static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
-                                        unsigned long action, void *hcpu)
+static int oprofile_cpu_notify(struct notifier_block *self,
+                              unsigned long action, void *hcpu)
 {
        long cpu = (long) hcpu;
 
index e79e006eb9abc4eab4722aa483d2c6fb38a8c455..9ee04b4b68bf39569acd6dd360c62a6cb4e4b76e 100644 (file)
@@ -811,18 +811,28 @@ int iosapic_fixup_irq(void *isi_obj, struct pci_dev *pcidev)
        return pcidev->irq;
 }
 
-static struct iosapic_info *first_isi = NULL;
+static struct iosapic_info *iosapic_list;
 
 #ifdef CONFIG_64BIT
-int iosapic_serial_irq(int num)
+int iosapic_serial_irq(struct parisc_device *dev)
 {
-       struct iosapic_info *isi = first_isi;
-       struct irt_entry *irte = NULL;  /* only used if PAT PDC */
+       struct iosapic_info *isi;
+       struct irt_entry *irte;
        struct vector_info *vi;
-       int isi_line;   /* line used by device */
+       int cnt;
+       int intin;
+
+       intin = (dev->mod_info >> 24) & 15;
 
        /* lookup IRT entry for isi/slot/pin set */
-       irte = &irt_cell[num];
+       for (cnt = 0; cnt < irt_num_entry; cnt++) {
+               irte = &irt_cell[cnt];
+               if (COMPARE_IRTE_ADDR(irte, dev->mod0) &&
+                   irte->dest_iosapic_intin == intin)
+                       break;
+       }
+       if (cnt >= irt_num_entry)
+               return 0; /* no irq found, force polling */
 
        DBG_IRT("iosapic_serial_irq(): irte %p %x %x %x %x %x %x %x %x\n",
                irte,
@@ -834,11 +844,17 @@ int iosapic_serial_irq(int num)
                irte->src_seg_id,
                irte->dest_iosapic_intin,
                (u32) irte->dest_iosapic_addr);
-       isi_line = irte->dest_iosapic_intin;
+
+       /* search for iosapic */
+       for (isi = iosapic_list; isi; isi = isi->isi_next)
+               if (isi->isi_hpa == dev->mod0)
+                       break;
+       if (!isi)
+               return 0; /* no iosapic found, force polling */
 
        /* get vector info for this input line */
-       vi = isi->isi_vector + isi_line;
-       DBG_IRT("iosapic_serial_irq:  line %d vi 0x%p\n", isi_line, vi);
+       vi = isi->isi_vector + intin;
+       DBG_IRT("iosapic_serial_irq:  line %d vi 0x%p\n", iosapic_intin, vi);
 
        /* If this IRQ line has already been setup, skip it */
        if (vi->irte)
@@ -941,8 +957,8 @@ void *iosapic_register(unsigned long hpa)
                vip->irqline = (unsigned char) cnt;
                vip->iosapic = isi;
        }
-       if (!first_isi)
-               first_isi = isi;
+       isi->isi_next = iosapic_list;
+       iosapic_list = isi;
        return isi;
 }
 
index 13a633b1612e1786b9cdcb7f2eebece8b0a70dde..7bf3926aecc0d765af64f166cbeb871ea66ac127 100644 (file)
@@ -86,10 +86,6 @@ struct mvebu_sw_pci_bridge {
        u16 secondary_status;
        u16 membase;
        u16 memlimit;
-       u16 prefmembase;
-       u16 prefmemlimit;
-       u32 prefbaseupper;
-       u32 preflimitupper;
        u16 iobaseupper;
        u16 iolimitupper;
        u8 cappointer;
@@ -419,15 +415,7 @@ static int mvebu_sw_pci_bridge_read(struct mvebu_pcie_port *port,
                break;
 
        case PCI_PREF_MEMORY_BASE:
-               *value = (bridge->prefmemlimit << 16 | bridge->prefmembase);
-               break;
-
-       case PCI_PREF_BASE_UPPER32:
-               *value = bridge->prefbaseupper;
-               break;
-
-       case PCI_PREF_LIMIT_UPPER32:
-               *value = bridge->preflimitupper;
+               *value = 0;
                break;
 
        case PCI_IO_BASE_UPPER16:
@@ -501,19 +489,6 @@ static int mvebu_sw_pci_bridge_write(struct mvebu_pcie_port *port,
                mvebu_pcie_handle_membase_change(port);
                break;
 
-       case PCI_PREF_MEMORY_BASE:
-               bridge->prefmembase = value & 0xffff;
-               bridge->prefmemlimit = value >> 16;
-               break;
-
-       case PCI_PREF_BASE_UPPER32:
-               bridge->prefbaseupper = value;
-               break;
-
-       case PCI_PREF_LIMIT_UPPER32:
-               bridge->preflimitupper = value;
-               break;
-
        case PCI_IO_BASE_UPPER16:
                bridge->iobaseupper = value & 0xffff;
                bridge->iolimitupper = value >> 16;
index bb7ebb22db01e39a66840ba4684f811e7d89e075..d85009de713d647b9e3a81024776b6bdaf312754 100644 (file)
@@ -3,16 +3,13 @@
 #
 
 menuconfig HOTPLUG_PCI
-       tristate "Support for PCI Hotplug"
+       bool "Support for PCI Hotplug"
        depends on PCI && SYSFS
        ---help---
          Say Y here if you have a motherboard with a PCI Hotplug controller.
          This allows you to add and remove PCI cards while the machine is
          powered up and running.
 
-         To compile this driver as a module, choose M here: the
-         module will be called pci_hotplug.
-
          When in doubt, say N.
 
 if HOTPLUG_PCI
index aac7a40e4a4ac9205441d9c6918a080531117571..0e0d0f7f63fdd83aa551549d38b174cdca8d034d 100644 (file)
@@ -92,7 +92,14 @@ int pciehp_unconfigure_device(struct slot *p_slot)
        if (ret)
                presence = 0;
 
-       list_for_each_entry_safe(dev, temp, &parent->devices, bus_list) {
+       /*
+        * Stopping an SR-IOV PF device removes all the associated VFs,
+        * which will update the bus->devices list and confuse the
+        * iterator.  Therefore, iterate in reverse so we remove the VFs
+        * first, then the PF.  We do the same in pci_stop_bus_device().
+        */
+       list_for_each_entry_safe_reverse(dev, temp, &parent->devices,
+                                        bus_list) {
                pci_dev_get(dev);
                if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) {
                        pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl);
index b29e20b7862f168673b3ad980200dd3c80fff175..bb7af78e4eedd359a08db0fab40682a82abac5e1 100644 (file)
@@ -388,7 +388,6 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
        /* Remove the EADS bridge device itself */
        BUG_ON(!bus->self);
        pr_debug("PCI: Now removing bridge device %s\n", pci_name(bus->self));
-       eeh_remove_bus_device(bus->self, true);
        pci_stop_and_remove_bus_device(bus->self);
 
        return 0;
index dbdc5f7e2b294fad4adfe3ae676e258c5af6abbe..01e264fb50e0ebf09a1c4b9b49e1e5e0da3bc7ff 100644 (file)
@@ -317,13 +317,20 @@ void acpi_pci_remove_bus(struct pci_bus *bus)
 /* ACPI bus type */
 static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
 {
-       struct pci_dev * pci_dev;
-       u64     addr;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       bool is_bridge;
+       u64 addr;
 
-       pci_dev = to_pci_dev(dev);
+       /*
+        * pci_is_bridge() is not suitable here, because pci_dev->subordinate
+        * is set only after acpi_pci_find_device() has been called for the
+        * given device.
+        */
+       is_bridge = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
+                       || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
        /* Please ref to ACPI spec for the syntax of _ADR */
        addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
-       *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
+       *handle = acpi_find_child(ACPI_HANDLE(dev->parent), addr, is_bridge);
        if (!*handle)
                return -ENODEV;
        return 0;
index e37fea6e178d2dab00d3334848d231117d525013..c71e78c46705e5f202bda5bd56f39bbfaaa8c46c 100644 (file)
@@ -3578,6 +3578,49 @@ int pcie_set_mps(struct pci_dev *dev, int mps)
                                                  PCI_EXP_DEVCTL_PAYLOAD, v);
 }
 
+/**
+ * pcie_get_minimum_link - determine minimum link settings of a PCI device
+ * @dev: PCI device to query
+ * @speed: storage for minimum speed
+ * @width: storage for minimum width
+ *
+ * This function will walk up the PCI device chain and determine the minimum
+ * link width and speed of the device.
+ */
+int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
+                         enum pcie_link_width *width)
+{
+       int ret;
+
+       *speed = PCI_SPEED_UNKNOWN;
+       *width = PCIE_LNK_WIDTH_UNKNOWN;
+
+       while (dev) {
+               u16 lnksta;
+               enum pci_bus_speed next_speed;
+               enum pcie_link_width next_width;
+
+               ret = pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta);
+               if (ret)
+                       return ret;
+
+               next_speed = pcie_link_speed[lnksta & PCI_EXP_LNKSTA_CLS];
+               next_width = (lnksta & PCI_EXP_LNKSTA_NLW) >>
+                       PCI_EXP_LNKSTA_NLW_SHIFT;
+
+               if (next_speed < *speed)
+                       *speed = next_speed;
+
+               if (next_width < *width)
+                       *width = next_width;
+
+               dev = dev->bus->self;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(pcie_get_minimum_link);
+
 /**
  * pci_select_bars - Make BAR mask from the type of resource
  * @dev: the PCI device for which BAR mask is made
index d1182c4a754e235b25fb2914d658010d05157756..948d1a033a22410319089043a104e31fcd519097 100644 (file)
@@ -6,6 +6,9 @@
 #define PCI_CFG_SPACE_SIZE     256
 #define PCI_CFG_SPACE_EXP_SIZE 4096
 
+extern const unsigned char pcix_bus_speed[];
+extern const unsigned char pcie_link_speed[];
+
 /* Functions internal to the PCI core code */
 
 int pci_create_sysfs_dev_files(struct pci_dev *pdev);
index 569f82fc9e22bb826fbfca36ba74b891cc15b0d8..3b94cfcfa03bee1dd1a1d319f9d038a46b07b834 100644 (file)
@@ -14,15 +14,12 @@ config PCIEPORTBUS
 # Include service Kconfig here
 #
 config HOTPLUG_PCI_PCIE
-       tristate "PCI Express Hotplug driver"
+       bool "PCI Express Hotplug driver"
        depends on HOTPLUG_PCI && PCIEPORTBUS
        help
          Say Y here if you have a motherboard that supports PCI Express Native
          Hotplug
 
-         To compile this driver as a module, choose M here: the
-         module will be called pciehp.
-
          When in doubt, say N.
 
 source "drivers/pci/pcie/aer/Kconfig"
index 46ada5c098ebed710f24a7deb426720149b219fd..496c5b082d4247082ef0450a9b379817ac1efaf9 100644 (file)
@@ -513,7 +513,7 @@ static struct pci_host_bridge *pci_alloc_host_bridge(struct pci_bus *b)
        return bridge;
 }
 
-static unsigned char pcix_bus_speed[] = {
+const unsigned char pcix_bus_speed[] = {
        PCI_SPEED_UNKNOWN,              /* 0 */
        PCI_SPEED_66MHz_PCIX,           /* 1 */
        PCI_SPEED_100MHz_PCIX,          /* 2 */
@@ -532,7 +532,7 @@ static unsigned char pcix_bus_speed[] = {
        PCI_SPEED_133MHz_PCIX_533       /* F */
 };
 
-static unsigned char pcie_link_speed[] = {
+const unsigned char pcie_link_speed[] = {
        PCI_SPEED_UNKNOWN,              /* 0 */
        PCIE_SPEED_2_5GT,               /* 1 */
        PCIE_SPEED_5_0GT,               /* 2 */
index d254e237953382bb99768c7cca79b65c3b9aded8..64a7de22d9afe0edb548b3b20f96d7c288e53273 100644 (file)
@@ -300,6 +300,47 @@ static void assign_requested_resources_sorted(struct list_head *head,
        }
 }
 
+static unsigned long pci_fail_res_type_mask(struct list_head *fail_head)
+{
+       struct pci_dev_resource *fail_res;
+       unsigned long mask = 0;
+
+       /* check failed type */
+       list_for_each_entry(fail_res, fail_head, list)
+               mask |= fail_res->flags;
+
+       /*
+        * one pref failed resource will set IORESOURCE_MEM,
+        * as we can allocate pref in non-pref range.
+        * Will release all assigned non-pref sibling resources
+        * according to that bit.
+        */
+       return mask & (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH);
+}
+
+static bool pci_need_to_release(unsigned long mask, struct resource *res)
+{
+       if (res->flags & IORESOURCE_IO)
+               return !!(mask & IORESOURCE_IO);
+
+       /* check pref at first */
+       if (res->flags & IORESOURCE_PREFETCH) {
+               if (mask & IORESOURCE_PREFETCH)
+                       return true;
+               /* count pref if its parent is non-pref */
+               else if ((mask & IORESOURCE_MEM) &&
+                        !(res->parent->flags & IORESOURCE_PREFETCH))
+                       return true;
+               else
+                       return false;
+       }
+
+       if (res->flags & IORESOURCE_MEM)
+               return !!(mask & IORESOURCE_MEM);
+
+       return false;   /* should not get here */
+}
+
 static void __assign_resources_sorted(struct list_head *head,
                                 struct list_head *realloc_head,
                                 struct list_head *fail_head)
@@ -312,11 +353,24 @@ static void __assign_resources_sorted(struct list_head *head,
         *  if could do that, could get out early.
         *  if could not do that, we still try to assign requested at first,
         *    then try to reassign add_size for some resources.
+        *
+        * Separate three resource type checking if we need to release
+        * assigned resource after requested + add_size try.
+        *      1. if there is io port assign fail, will release assigned
+        *         io port.
+        *      2. if there is pref mmio assign fail, release assigned
+        *         pref mmio.
+        *         if assigned pref mmio's parent is non-pref mmio and there
+        *         is non-pref mmio assign fail, will release that assigned
+        *         pref mmio.
+        *      3. if there is non-pref mmio assign fail or pref mmio
+        *         assigned fail, will release assigned non-pref mmio.
         */
        LIST_HEAD(save_head);
        LIST_HEAD(local_fail_head);
        struct pci_dev_resource *save_res;
-       struct pci_dev_resource *dev_res;
+       struct pci_dev_resource *dev_res, *tmp_res;
+       unsigned long fail_type;
 
        /* Check if optional add_size is there */
        if (!realloc_head || list_empty(realloc_head))
@@ -348,6 +402,19 @@ static void __assign_resources_sorted(struct list_head *head,
                return;
        }
 
+       /* check failed type */
+       fail_type = pci_fail_res_type_mask(&local_fail_head);
+       /* remove not need to be released assigned res from head list etc */
+       list_for_each_entry_safe(dev_res, tmp_res, head, list)
+               if (dev_res->res->parent &&
+                   !pci_need_to_release(fail_type, dev_res->res)) {
+                       /* remove it from realloc_head list */
+                       remove_from_list(realloc_head, dev_res->res);
+                       remove_from_list(&save_head, dev_res->res);
+                       list_del(&dev_res->list);
+                       kfree(dev_res);
+               }
+
        free_list(&local_fail_head);
        /* Release assigned resource */
        list_for_each_entry(dev_res, head, list)
index 5b272bfd261d6803fad6eaac61a3fa28dab4e767..2a00239661b3c27ec979802a3f040f92f2276060 100644 (file)
@@ -1193,6 +1193,7 @@ void pinctrl_unregister_map(struct pinctrl_map const *map)
        list_for_each_entry(maps_node, &pinctrl_maps, node) {
                if (maps_node->maps == map) {
                        list_del(&maps_node->node);
+                       kfree(maps_node);
                        mutex_unlock(&pinctrl_maps_mutex);
                        return;
                }
index 6866548fab31669d5141a7c8af21c10e0caa895d..7323cca440b5929ef7248d6d73662d200c01109b 100644 (file)
@@ -1483,6 +1483,7 @@ static int pcs_add_gpio_func(struct device_node *node, struct pcs_device *pcs)
        return ret;
 }
 
+#ifdef CONFIG_PM
 static int pinctrl_single_suspend(struct platform_device *pdev,
                                        pm_message_t state)
 {
@@ -1505,6 +1506,7 @@ static int pinctrl_single_resume(struct platform_device *pdev)
 
        return pinctrl_force_default(pcs->pctl);
 }
+#endif
 
 static int pcs_probe(struct platform_device *pdev)
 {
index c47fd1e5450ba6f26ba8e70f2ad207efc1959a82..94716c779800ea099bfd580c627a93345af7d1db 100644 (file)
@@ -278,6 +278,7 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
 {
        struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
        struct sunxi_pinctrl_group *g = &pctl->groups[group];
+       unsigned long flags;
        u32 val, mask;
        u16 strength;
        u8 dlevel;
@@ -295,22 +296,35 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
                 *   3: 40mA
                 */
                dlevel = strength / 10 - 1;
+
+               spin_lock_irqsave(&pctl->lock, flags);
+
                val = readl(pctl->membase + sunxi_dlevel_reg(g->pin));
                mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin);
                writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin),
                        pctl->membase + sunxi_dlevel_reg(g->pin));
+
+               spin_unlock_irqrestore(&pctl->lock, flags);
                break;
        case PIN_CONFIG_BIAS_PULL_UP:
+               spin_lock_irqsave(&pctl->lock, flags);
+
                val = readl(pctl->membase + sunxi_pull_reg(g->pin));
                mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
                writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin),
                        pctl->membase + sunxi_pull_reg(g->pin));
+
+               spin_unlock_irqrestore(&pctl->lock, flags);
                break;
        case PIN_CONFIG_BIAS_PULL_DOWN:
+               spin_lock_irqsave(&pctl->lock, flags);
+
                val = readl(pctl->membase + sunxi_pull_reg(g->pin));
                mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
                writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin),
                        pctl->membase + sunxi_pull_reg(g->pin));
+
+               spin_unlock_irqrestore(&pctl->lock, flags);
                break;
        default:
                break;
@@ -360,11 +374,17 @@ static void sunxi_pmx_set(struct pinctrl_dev *pctldev,
                                 u8 config)
 {
        struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
+       unsigned long flags;
+       u32 val, mask;
+
+       spin_lock_irqsave(&pctl->lock, flags);
 
-       u32 val = readl(pctl->membase + sunxi_mux_reg(pin));
-       u32 mask = MUX_PINS_MASK << sunxi_mux_offset(pin);
+       val = readl(pctl->membase + sunxi_mux_reg(pin));
+       mask = MUX_PINS_MASK << sunxi_mux_offset(pin);
        writel((val & ~mask) | config << sunxi_mux_offset(pin),
                pctl->membase + sunxi_mux_reg(pin));
+
+       spin_unlock_irqrestore(&pctl->lock, flags);
 }
 
 static int sunxi_pmx_enable(struct pinctrl_dev *pctldev,
@@ -464,8 +484,21 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
        struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
        u32 reg = sunxi_data_reg(offset);
        u8 index = sunxi_data_offset(offset);
+       unsigned long flags;
+       u32 regval;
+
+       spin_lock_irqsave(&pctl->lock, flags);
+
+       regval = readl(pctl->membase + reg);
 
-       writel((value & DATA_PINS_MASK) << index, pctl->membase + reg);
+       if (value)
+               regval |= BIT(index);
+       else
+               regval &= ~(BIT(index));
+
+       writel(regval, pctl->membase + reg);
+
+       spin_unlock_irqrestore(&pctl->lock, flags);
 }
 
 static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
@@ -526,6 +559,8 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
        struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
        u32 reg = sunxi_irq_cfg_reg(d->hwirq);
        u8 index = sunxi_irq_cfg_offset(d->hwirq);
+       unsigned long flags;
+       u32 regval;
        u8 mode;
 
        switch (type) {
@@ -548,7 +583,13 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
                return -EINVAL;
        }
 
-       writel((mode & IRQ_CFG_IRQ_MASK) << index, pctl->membase + reg);
+       spin_lock_irqsave(&pctl->lock, flags);
+
+       regval = readl(pctl->membase + reg);
+       regval &= ~IRQ_CFG_IRQ_MASK;
+       writel(regval | (mode << index), pctl->membase + reg);
+
+       spin_unlock_irqrestore(&pctl->lock, flags);
 
        return 0;
 }
@@ -560,14 +601,19 @@ static void sunxi_pinctrl_irq_mask_ack(struct irq_data *d)
        u8 ctrl_idx = sunxi_irq_ctrl_offset(d->hwirq);
        u32 status_reg = sunxi_irq_status_reg(d->hwirq);
        u8 status_idx = sunxi_irq_status_offset(d->hwirq);
+       unsigned long flags;
        u32 val;
 
+       spin_lock_irqsave(&pctl->lock, flags);
+
        /* Mask the IRQ */
        val = readl(pctl->membase + ctrl_reg);
        writel(val & ~(1 << ctrl_idx), pctl->membase + ctrl_reg);
 
        /* Clear the IRQ */
        writel(1 << status_idx, pctl->membase + status_reg);
+
+       spin_unlock_irqrestore(&pctl->lock, flags);
 }
 
 static void sunxi_pinctrl_irq_mask(struct irq_data *d)
@@ -575,11 +621,16 @@ static void sunxi_pinctrl_irq_mask(struct irq_data *d)
        struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
        u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
        u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
+       unsigned long flags;
        u32 val;
 
+       spin_lock_irqsave(&pctl->lock, flags);
+
        /* Mask the IRQ */
        val = readl(pctl->membase + reg);
        writel(val & ~(1 << idx), pctl->membase + reg);
+
+       spin_unlock_irqrestore(&pctl->lock, flags);
 }
 
 static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
@@ -588,6 +639,7 @@ static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
        struct sunxi_desc_function *func;
        u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
        u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
+       unsigned long flags;
        u32 val;
 
        func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
@@ -597,9 +649,13 @@ static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
        /* Change muxing to INT mode */
        sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval);
 
+       spin_lock_irqsave(&pctl->lock, flags);
+
        /* Unmask the IRQ */
        val = readl(pctl->membase + reg);
        writel(val | (1 << idx), pctl->membase + reg);
+
+       spin_unlock_irqrestore(&pctl->lock, flags);
 }
 
 static struct irq_chip sunxi_pinctrl_irq_chip = {
@@ -752,6 +808,8 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
                return -ENOMEM;
        platform_set_drvdata(pdev, pctl);
 
+       spin_lock_init(&pctl->lock);
+
        pctl->membase = of_iomap(node, 0);
        if (!pctl->membase)
                return -ENOMEM;
index d68047d8f6992e709c250d39dab4cf1497102eea..01c494f8a14f0119493d783624b86831549ccdb0 100644 (file)
@@ -14,6 +14,7 @@
 #define __PINCTRL_SUNXI_H
 
 #include <linux/kernel.h>
+#include <linux/spinlock.h>
 
 #define PA_BASE        0
 #define PB_BASE        32
@@ -407,6 +408,7 @@ struct sunxi_pinctrl {
        unsigned                        ngroups;
        int                             irq;
        int                             irq_array[SUNXI_IRQ_NUMBER];
+       spinlock_t                      lock;
        struct pinctrl_dev              *pctl_dev;
 };
 
index 7956df58d751a3231db71b2c4f8c00f0cb231b7d..31f7d0e04aaaaa6f335342ee99b5df269e792beb 100644 (file)
@@ -3785,6 +3785,7 @@ static const struct regulator_desc sh73a0_vccq_mc0_desc = {
 
 static struct regulator_consumer_supply sh73a0_vccq_mc0_consumers[] = {
        REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
+       REGULATOR_SUPPLY("vqmmc", "ee100000.sdhi"),
 };
 
 static const struct regulator_init_data sh73a0_vccq_mc0_init_data = {
index 1fa39a4441717e233c8844c0a7e72357356ece0d..867c9681763cab5ad42790dd98eb6137745c0d87 100644 (file)
@@ -496,7 +496,7 @@ static const unsigned sdmmc5_pins[] = { 24, 25, 26 };
 static const struct sirfsoc_muxmask usp0_muxmask[] = {
        {
                .group = 1,
-               .mask = BIT(19) | BIT(20) | BIT(21) | BIT(22),
+               .mask = BIT(19) | BIT(20) | BIT(21) | BIT(22) | BIT(23),
        },
 };
 
@@ -507,8 +507,21 @@ static const struct sirfsoc_padmux usp0_padmux = {
        .funcval = 0,
 };
 
-static const unsigned usp0_pins[] = { 51, 52, 53, 54 };
+static const unsigned usp0_pins[] = { 51, 52, 53, 54, 55 };
 
+static const struct sirfsoc_muxmask usp0_uart_nostreamctrl_muxmask[] = {
+       {
+               .group = 1,
+               .mask = BIT(20) | BIT(21),
+       },
+};
+
+static const struct sirfsoc_padmux usp0_uart_nostreamctrl_padmux = {
+       .muxmask_counts = ARRAY_SIZE(usp0_uart_nostreamctrl_muxmask),
+       .muxmask = usp0_uart_nostreamctrl_muxmask,
+};
+
+static const unsigned usp0_uart_nostreamctrl_pins[] = { 52, 53 };
 static const struct sirfsoc_muxmask usp1_muxmask[] = {
        {
                .group = 0,
@@ -822,6 +835,8 @@ static const struct sirfsoc_pin_group sirfsoc_pin_groups[] = {
        SIRFSOC_PIN_GROUP("uart2grp", uart2_pins),
        SIRFSOC_PIN_GROUP("uart2_nostreamctrlgrp", uart2_nostreamctrl_pins),
        SIRFSOC_PIN_GROUP("usp0grp", usp0_pins),
+       SIRFSOC_PIN_GROUP("usp0_uart_nostreamctrl_grp",
+                                       usp0_uart_nostreamctrl_pins),
        SIRFSOC_PIN_GROUP("usp1grp", usp1_pins),
        SIRFSOC_PIN_GROUP("i2c0grp", i2c0_pins),
        SIRFSOC_PIN_GROUP("i2c1grp", i2c1_pins),
@@ -862,6 +877,8 @@ static const char * const uart0grp[] = { "uart0grp" };
 static const char * const uart1grp[] = { "uart1grp" };
 static const char * const uart2grp[] = { "uart2grp" };
 static const char * const uart2_nostreamctrlgrp[] = { "uart2_nostreamctrlgrp" };
+static const char * const usp0_uart_nostreamctrl_grp[] = {
+                                       "usp0_uart_nostreamctrl_grp" };
 static const char * const usp0grp[] = { "usp0grp" };
 static const char * const usp1grp[] = { "usp1grp" };
 static const char * const i2c0grp[] = { "i2c0grp" };
@@ -904,6 +921,9 @@ static const struct sirfsoc_pmx_func sirfsoc_pmx_functions[] = {
        SIRFSOC_PMX_FUNCTION("uart2", uart2grp, uart2_padmux),
        SIRFSOC_PMX_FUNCTION("uart2_nostreamctrl", uart2_nostreamctrlgrp, uart2_nostreamctrl_padmux),
        SIRFSOC_PMX_FUNCTION("usp0", usp0grp, usp0_padmux),
+       SIRFSOC_PMX_FUNCTION("usp0_uart_nostreamctrl",
+                                               usp0_uart_nostreamctrl_grp,
+                                               usp0_uart_nostreamctrl_padmux),
        SIRFSOC_PMX_FUNCTION("usp1", usp1grp, usp1_padmux),
        SIRFSOC_PMX_FUNCTION("i2c0", i2c0grp, i2c0_padmux),
        SIRFSOC_PMX_FUNCTION("i2c1", i2c1grp, i2c1_padmux),
index 0f9f8596b300a0d06d525547159bf4d038ba1505..f9119525f5570c2d041d563c0eefbc9a01e32c20 100644 (file)
@@ -330,7 +330,7 @@ static int __init olpc_ec_init_module(void)
        return platform_driver_register(&olpc_ec_plat_driver);
 }
 
-module_init(olpc_ec_init_module);
+arch_initcall(olpc_ec_init_module);
 
 MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
 MODULE_LICENSE("GPL");
index 97bb05edcb5a806d85e9930022a77530735b2336..d6970f47ae72f639d648c924a27bea8b97cbdfb6 100644 (file)
@@ -53,7 +53,6 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_ALS_QUERY 0x3
 #define HPWMI_HARDWARE_QUERY 0x4
 #define HPWMI_WIRELESS_QUERY 0x5
-#define HPWMI_BIOS_QUERY 0x9
 #define HPWMI_HOTKEY_QUERY 0xc
 #define HPWMI_WIRELESS2_QUERY 0x1b
 #define HPWMI_POSTCODEERROR_QUERY 0x2a
@@ -293,19 +292,6 @@ static int hp_wmi_tablet_state(void)
        return (state & 0x4) ? 1 : 0;
 }
 
-static int hp_wmi_enable_hotkeys(void)
-{
-       int ret;
-       int query = 0x6e;
-
-       ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query, sizeof(query),
-                                  0);
-
-       if (ret)
-               return -EINVAL;
-       return 0;
-}
-
 static int hp_wmi_set_block(void *data, bool blocked)
 {
        enum hp_wmi_radio r = (enum hp_wmi_radio) data;
@@ -1009,8 +995,6 @@ static int __init hp_wmi_init(void)
                err = hp_wmi_input_setup();
                if (err)
                        return err;
-
-               hp_wmi_enable_hotkeys();
        }
 
        if (bios_capable) {
index 2ac045f27f10112aa467b867a9b97a9a1790c189..3a1b6bf326a814d8453a1cdb2e3d699834f7e87a 100644 (file)
@@ -2440,7 +2440,10 @@ static ssize_t sony_nc_gfx_switch_status_show(struct device *dev,
        if (pos < 0)
                return pos;
 
-       return snprintf(buffer, PAGE_SIZE, "%s\n", pos ? "speed" : "stamina");
+       return snprintf(buffer, PAGE_SIZE, "%s\n",
+                                       pos == SPEED ? "speed" :
+                                       pos == STAMINA ? "stamina" :
+                                       pos == AUTO ? "auto" : "unknown");
 }
 
 static int sony_nc_gfx_switch_setup(struct platform_device *pd,
@@ -4320,7 +4323,8 @@ static int sony_pic_add(struct acpi_device *device)
                goto err_free_resources;
        }
 
-       if (sonypi_compat_init())
+       result = sonypi_compat_init();
+       if (result)
                goto err_remove_input;
 
        /* request io port */
index 9847ab163829f60d7311c83f3c57a0eb32d767f1..167f3d00c916d2e30a63dcc31d260a45d1e5cada 100644 (file)
@@ -180,7 +180,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
        struct pnp_dev *dev = data;
        struct acpi_resource_dma *dma;
        struct acpi_resource_vendor_typed *vendor_typed;
-       struct resource r;
+       struct resource r = {0};
        int i, flags;
 
        if (acpi_dev_resource_memory(res, &r)
index 3e6db1c1dc295386f01c37bf23679eba86e1cbd7..d95e101ffb439ebec5cc11772305d99578db772d 100644 (file)
@@ -515,6 +515,7 @@ struct pnp_resource *pnp_add_resource(struct pnp_dev *dev,
        }
 
        pnp_res->res = *res;
+       pnp_res->res.name = dev->name;
        dev_dbg(&dev->dev, "%pR\n", res);
        return pnp_res;
 }
index f4f30af2df68c682744cc125ede61da5f87eb4d1..2e8a20cac58848cdd0e2afa6201f3f82f4a88e84 100644 (file)
@@ -1715,11 +1715,13 @@ int rio_unregister_scan(int mport_id, struct rio_scan *scan_ops)
                    (mport_id == RIO_MPORT_ANY && port->nscan == scan_ops))
                        port->nscan = NULL;
 
-       list_for_each_entry(scan, &rio_scans, node)
+       list_for_each_entry(scan, &rio_scans, node) {
                if (scan->mport_id == mport_id) {
                        list_del(&scan->node);
                        kfree(scan);
+                       break;
                }
+       }
 
        mutex_unlock(&rio_mport_list_lock);
 
index 767fee2ab340efb2d5ce647637053028c38b4aec..26019531db15a2f481dc87da6e6c76e085e1a06c 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 #include <linux/rtc.h>
 #include <linux/slab.h>
 #include <linux/of_device.h>
@@ -119,24 +120,39 @@ static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
 }
 #endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */
 
-static void stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data)
+static int stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data)
 {
+       int timeout = 5000; /* 3ms according to i.MX28 Ref Manual */
        /*
-        * The datasheet doesn't say which way round the
-        * NEW_REGS/STALE_REGS bitfields go. In fact it's 0x1=P0,
-        * 0x2=P1, .., 0x20=P5, 0x40=ALARM, 0x80=SECONDS
+        * The i.MX28 Applications Processor Reference Manual, Rev. 1, 2010
+        * states:
+        * | The order in which registers are updated is
+        * | Persistent 0, 1, 2, 3, 4, 5, Alarm, Seconds.
+        * | (This list is in bitfield order, from LSB to MSB, as they would
+        * | appear in the STALE_REGS and NEW_REGS bitfields of the HW_RTC_STAT
+        * | register. For example, the Seconds register corresponds to
+        * | STALE_REGS or NEW_REGS containing 0x80.)
         */
-       while (readl(rtc_data->io + STMP3XXX_RTC_STAT) &
-                       (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT))
-               cpu_relax();
+       do {
+               if (!(readl(rtc_data->io + STMP3XXX_RTC_STAT) &
+                               (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)))
+                       return 0;
+               udelay(1);
+       } while (--timeout > 0);
+       return (readl(rtc_data->io + STMP3XXX_RTC_STAT) &
+               (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)) ? -ETIME : 0;
 }
 
 /* Time read/write */
 static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
 {
+       int ret;
        struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
 
-       stmp3xxx_wait_time(rtc_data);
+       ret = stmp3xxx_wait_time(rtc_data);
+       if (ret)
+               return ret;
+
        rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
        return 0;
 }
@@ -146,8 +162,7 @@ static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t)
        struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
 
        writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS);
-       stmp3xxx_wait_time(rtc_data);
-       return 0;
+       return stmp3xxx_wait_time(rtc_data);
 }
 
 /* interrupt(s) handler */
index 02faf3c4e0d51d13cd6fd7c55b2de4f09776f08f..c2e80d7ca5e26b618a19bfc5aac45e8497651082 100644 (file)
@@ -524,6 +524,8 @@ static int twl_rtc_probe(struct platform_device *pdev)
        if (ret < 0)
                goto out1;
 
+       device_init_wakeup(&pdev->dev, 1);
+
        rtc = rtc_device_register(pdev->name,
                                  &pdev->dev, &twl_rtc_ops, THIS_MODULE);
        if (IS_ERR(rtc)) {
@@ -542,7 +544,6 @@ static int twl_rtc_probe(struct platform_device *pdev)
        }
 
        platform_set_drvdata(pdev, rtc);
-       device_init_wakeup(&pdev->dev, 1);
        return 0;
 
 out2:
index 17150a77898433c27e58b2a8ac9ccb81bd228ddb..451bf99582ff09948c04e6634ca2d381c0d6a45a 100644 (file)
@@ -2392,6 +2392,12 @@ int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
                rc = cqr->intrc;
        else
                rc = -EIO;
+
+       /* kick tasklets */
+       dasd_schedule_device_bh(device);
+       if (device->block)
+               dasd_schedule_block_bh(device->block);
+
        return rc;
 }
 
index fb1c1e0483ed30213343620da6542ba5ca6b43bb..8ed52aa4912269405158e300f1c983577b29caec 100644 (file)
@@ -1497,7 +1497,7 @@ static inline int buf_in_between(int bufnr, int start, int count)
 static int handle_inbound(struct qdio_q *q, unsigned int callflags,
                          int bufnr, int count)
 {
-       int used, diff;
+       int diff;
 
        qperf_inc(q, inbound_call);
 
@@ -1530,7 +1530,7 @@ static int handle_inbound(struct qdio_q *q, unsigned int callflags,
 
 set:
        count = set_buf_states(q, bufnr, SLSB_CU_INPUT_EMPTY, count);
-       used = atomic_add_return(count, &q->nr_buf_used) - count;
+       atomic_add(count, &q->nr_buf_used);
 
        if (need_siga_in(q))
                return qdio_siga_input(q);
index f446a7705c3b9fb9a2856b8fc79b82730e897f2b..d4174b82a1a953e98277f5215dba5a4e20f36b38 100644 (file)
@@ -71,6 +71,7 @@ MODULE_AUTHOR("IBM Corporation");
 MODULE_DESCRIPTION("Adjunct Processor Bus driver, " \
                   "Copyright IBM Corp. 2006, 2012");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("z90crypt");
 
 /*
  * Module parameter
index f2db5fe7bdc2ba8f8a9c0cbb8458593494eef98a..62f00da09ad1b42f29f812f3ff8dc583ff850130 100644 (file)
@@ -581,8 +581,10 @@ struct iscsi_kwqe_init1 {
 #define ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE_SHIFT 4
 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE (0x1<<5)
 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE_SHIFT 5
-#define ISCSI_KWQE_INIT1_RESERVED1 (0x3<<6)
-#define ISCSI_KWQE_INIT1_RESERVED1_SHIFT 6
+#define ISCSI_KWQE_INIT1_TIME_STAMPS_ENABLE (0x1<<6)
+#define ISCSI_KWQE_INIT1_TIME_STAMPS_ENABLE_SHIFT 6
+#define ISCSI_KWQE_INIT1_RESERVED1 (0x1<<7)
+#define ISCSI_KWQE_INIT1_RESERVED1_SHIFT 7
        u16 cq_num_wqes;
 #elif defined(__LITTLE_ENDIAN)
        u16 cq_num_wqes;
@@ -593,8 +595,10 @@ struct iscsi_kwqe_init1 {
 #define ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE_SHIFT 4
 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE (0x1<<5)
 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE_SHIFT 5
-#define ISCSI_KWQE_INIT1_RESERVED1 (0x3<<6)
-#define ISCSI_KWQE_INIT1_RESERVED1_SHIFT 6
+#define ISCSI_KWQE_INIT1_TIME_STAMPS_ENABLE (0x1<<6)
+#define ISCSI_KWQE_INIT1_TIME_STAMPS_ENABLE_SHIFT 6
+#define ISCSI_KWQE_INIT1_RESERVED1 (0x1<<7)
+#define ISCSI_KWQE_INIT1_RESERVED1_SHIFT 7
        u8 cq_log_wqes_per_page;
 #endif
 #if defined(__BIG_ENDIAN)
index 50fef6963a811baa61b1fbec94e250a4e7457179..3104202902edb319ff02b92168226d4162fb9674 100644 (file)
@@ -172,16 +172,14 @@ void bnx2i_start(void *handle)
        struct bnx2i_hba *hba = handle;
        int i = HZ;
 
-       /*
-        * We should never register devices that don't support iSCSI
-        * (see bnx2i_init_one), so something is wrong if we try to
-        * start a iSCSI adapter on hardware with 0 supported iSCSI
-        * connections
+       /* On some bnx2x devices, it is possible that iSCSI is no
+        * longer supported after firmware is downloaded.  In that
+        * case, the iscsi_init_msg will return failure.
         */
-       BUG_ON(!hba->cnic->max_iscsi_conn);
 
        bnx2i_send_fw_iscsi_init_msg(hba);
-       while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--)
+       while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) &&
+              !test_bit(ADAPTER_STATE_INIT_FAILED, &hba->adapter_state) && i--)
                msleep(BNX2I_INIT_POLL_TIME);
 }
 
index b6d1f92ed33cc17e67ff4cbe1b3c424f5f75bd0e..c18c68150e9f17c8965b80159ecb2c2ddf1b0060 100644 (file)
@@ -38,7 +38,7 @@
 
 #define DRV_NAME               "fnic"
 #define DRV_DESCRIPTION                "Cisco FCoE HBA Driver"
-#define DRV_VERSION            "1.5.0.22"
+#define DRV_VERSION            "1.5.0.23"
 #define PFX                    DRV_NAME ": "
 #define DFX                     DRV_NAME "%d: "
 
index 5f09d1814d2685e86b06d9c6d697659d06cade07..42e15ee6e1bb73fceac4bd8aaf8ded5ad06ecf1e 100644 (file)
@@ -642,19 +642,6 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
                INIT_WORK(&fnic->event_work, fnic_handle_event);
                skb_queue_head_init(&fnic->fip_frame_queue);
-               spin_lock_irqsave(&fnic_list_lock, flags);
-               if (!fnic_fip_queue) {
-                       fnic_fip_queue =
-                               create_singlethread_workqueue("fnic_fip_q");
-                       if (!fnic_fip_queue) {
-                               spin_unlock_irqrestore(&fnic_list_lock, flags);
-                               printk(KERN_ERR PFX "fnic FIP work queue "
-                                                "create failed\n");
-                               err = -ENOMEM;
-                               goto err_out_free_max_pool;
-                       }
-               }
-               spin_unlock_irqrestore(&fnic_list_lock, flags);
                INIT_LIST_HEAD(&fnic->evlist);
                INIT_LIST_HEAD(&fnic->vlans);
        } else {
@@ -960,6 +947,13 @@ static int __init fnic_init_module(void)
        spin_lock_init(&fnic_list_lock);
        INIT_LIST_HEAD(&fnic_list);
 
+       fnic_fip_queue = create_singlethread_workqueue("fnic_fip_q");
+       if (!fnic_fip_queue) {
+               printk(KERN_ERR PFX "fnic FIP work queue create failed\n");
+               err = -ENOMEM;
+               goto err_create_fip_workq;
+       }
+
        fnic_fc_transport = fc_attach_transport(&fnic_fc_functions);
        if (!fnic_fc_transport) {
                printk(KERN_ERR PFX "fc_attach_transport error\n");
@@ -978,6 +972,8 @@ static int __init fnic_init_module(void)
 err_pci_register:
        fc_release_transport(fnic_fc_transport);
 err_fc_transport:
+       destroy_workqueue(fnic_fip_queue);
+err_create_fip_workq:
        destroy_workqueue(fnic_event_queue);
 err_create_fnic_workq:
        kmem_cache_destroy(fnic_io_req_cache);
index 7b082157eb79668b5fa6bcda0b16d6df25cd6acb..99d2930b18c80e319d3c506244c80b6205bab17e 100644 (file)
@@ -185,7 +185,7 @@ static void sci_io_request_build_ssp_command_iu(struct isci_request *ireq)
        cmd_iu->_r_c = 0;
 
        sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cmd->cmnd,
-                      task->ssp_task.cmd->cmd_len / sizeof(u32));
+                      (task->ssp_task.cmd->cmd_len+3) / sizeof(u32));
 }
 
 static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq)
index 9bb020ac089cddf6b665e8a52f728c95621ece34..0d30ca849e8f71502c9ecddfa9aa539e4e59af0f 100644 (file)
@@ -491,6 +491,7 @@ int isci_task_abort_task(struct sas_task *task)
        struct isci_tmf           tmf;
        int                       ret = TMF_RESP_FUNC_FAILED;
        unsigned long             flags;
+       int                       target_done_already = 0;
 
        /* Get the isci_request reference from the task.  Note that
         * this check does not depend on the pending request list
@@ -505,9 +506,11 @@ int isci_task_abort_task(struct sas_task *task)
        /* If task is already done, the request isn't valid */
        if (!(task->task_state_flags & SAS_TASK_STATE_DONE) &&
            (task->task_state_flags & SAS_TASK_AT_INITIATOR) &&
-           old_request)
+           old_request) {
                idev = isci_get_device(task->dev->lldd_dev);
-
+               target_done_already = test_bit(IREQ_COMPLETE_IN_TARGET,
+                                              &old_request->flags);
+       }
        spin_unlock(&task->task_state_lock);
        spin_unlock_irqrestore(&ihost->scic_lock, flags);
 
@@ -561,7 +564,7 @@ int isci_task_abort_task(struct sas_task *task)
 
        if (task->task_proto == SAS_PROTOCOL_SMP ||
            sas_protocol_ata(task->task_proto) ||
-           test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags) ||
+           target_done_already ||
            test_bit(IDEV_GONE, &idev->flags)) {
 
                spin_unlock_irqrestore(&ihost->scic_lock, flags);
index 0177295599e0cd976e14982b5991fef567cbe52a..1f0ca68409d43a09ae24bd98a1703d34ec2ba2cc 100644 (file)
@@ -3547,11 +3547,21 @@ static int megasas_init_fw(struct megasas_instance *instance)
                break;
        }
 
-       /*
-        * We expect the FW state to be READY
-        */
-       if (megasas_transition_to_ready(instance, 0))
-               goto fail_ready_state;
+       if (megasas_transition_to_ready(instance, 0)) {
+               atomic_set(&instance->fw_reset_no_pci_access, 1);
+               instance->instancet->adp_reset
+                       (instance, instance->reg_set);
+               atomic_set(&instance->fw_reset_no_pci_access, 0);
+               dev_info(&instance->pdev->dev,
+                       "megasas: FW restarted successfully from %s!\n",
+                       __func__);
+
+               /*waitting for about 30 second before retry*/
+               ssleep(30);
+
+               if (megasas_transition_to_ready(instance, 0))
+                       goto fail_ready_state;
+       }
 
        /*
         * MSI-X host index 0 is common for all adapter.
index f14665a6293dbb702d9c7c4a98fc135fc6f489eb..6b1b4e91e53f655128edf0235589bd02081963fb 100644 (file)
@@ -1857,11 +1857,16 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
                goto out;
        }
 
-       /* error info record present */
-       if (unlikely((rx_desc & RXQ_ERR) && (*(u64 *) slot->response))) {
+       /*
+        * error info record present; slot->response is 32 bit aligned but may
+        * not be 64 bit aligned, so check for zero in two 32 bit reads
+        */
+       if (unlikely((rx_desc & RXQ_ERR)
+                    && (*((u32 *)slot->response)
+                        || *(((u32 *)slot->response) + 1)))) {
                mv_dprintk("port %d slot %d rx_desc %X has error info"
                        "%016llX.\n", slot->port->sas_port.id, slot_idx,
-                        rx_desc, (u64)(*(u64 *)slot->response));
+                        rx_desc, get_unaligned_le64(slot->response));
                tstat->stat = mvs_slot_err(mvi, task, slot_idx);
                tstat->resp = SAS_TASK_COMPLETE;
                goto out;
index 60e2fb7f2dca7e37512b128bea9b59fd1c9cd579..d6b19dc80bee522a934bb1bb64dd56c1ecad0c51 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/irq.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
+#include <asm/unaligned.h>
 #include <scsi/libsas.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_tcq.h>
index 42ef481db942a79685900c136e7140a199cd8dc4..ef0a5481b9dd46ce0efbad796fa9a6cf04744296 100644 (file)
@@ -419,6 +419,8 @@ qla2x00_start_scsi(srb_t *sp)
                            __constant_cpu_to_le16(CF_SIMPLE_TAG);
                        break;
                }
+       } else {
+               cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
        }
 
        /* Load SCSI command packet. */
@@ -1307,11 +1309,11 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
                    fcp_cmnd->task_attribute = TSK_ORDERED;
                    break;
                default:
-                   fcp_cmnd->task_attribute = 0;
+                   fcp_cmnd->task_attribute = TSK_SIMPLE;
                    break;
                }
        } else {
-               fcp_cmnd->task_attribute = 0;
+               fcp_cmnd->task_attribute = TSK_SIMPLE;
        }
 
        cmd_pkt->fcp_rsp_dseg_len = 0; /* Let response come in status iocb */
@@ -1525,7 +1527,12 @@ qla24xx_start_scsi(srb_t *sp)
                case ORDERED_QUEUE_TAG:
                        cmd_pkt->task = TSK_ORDERED;
                        break;
+               default:
+                   cmd_pkt->task = TSK_SIMPLE;
+                   break;
                }
+       } else {
+               cmd_pkt->task = TSK_SIMPLE;
        }
 
        /* Load SCSI command packet. */
index 3b1ea34e1f5a8ea5812a7feecd6ad7c40cd9fe04..eaa808e6ba91c78f13748a6ab3977c9c174c20f9 100644 (file)
@@ -1031,6 +1031,9 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
 {
        int i, result;
 
+       if (sdev->skip_vpd_pages)
+               goto fail;
+
        /* Ask for all the pages supported by this device */
        result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
        if (result)
index 80f39b8b02239ad325143fb3e5e38c9753729ab4..86fcf2c313ad2ef9c5539149bb0006a06bd5c25b 100644 (file)
@@ -838,10 +838,17 @@ static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq)
 
 static void sd_unprep_fn(struct request_queue *q, struct request *rq)
 {
+       struct scsi_cmnd *SCpnt = rq->special;
+
        if (rq->cmd_flags & REQ_DISCARD) {
                free_page((unsigned long)rq->buffer);
                rq->buffer = NULL;
        }
+       if (SCpnt->cmnd != rq->cmd) {
+               mempool_free(SCpnt->cmnd, sd_cdb_pool);
+               SCpnt->cmnd = NULL;
+               SCpnt->cmd_len = 0;
+       }
 }
 
 /**
@@ -1720,21 +1727,6 @@ static int sd_done(struct scsi_cmnd *SCpnt)
        if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt))
                sd_dif_complete(SCpnt, good_bytes);
 
-       if (scsi_host_dif_capable(sdkp->device->host, sdkp->protection_type)
-           == SD_DIF_TYPE2_PROTECTION && SCpnt->cmnd != SCpnt->request->cmd) {
-
-               /* We have to print a failed command here as the
-                * extended CDB gets freed before scsi_io_completion()
-                * is called.
-                */
-               if (result)
-                       scsi_print_command(SCpnt);
-
-               mempool_free(SCpnt->cmnd, sd_cdb_pool);
-               SCpnt->cmnd = NULL;
-               SCpnt->cmd_len = 0;
-       }
-
        return good_bytes;
 }
 
index 2168258fb2c3a2cf5374a3592a302062d75bb305..74b88efde6ad408123de6a9b96ec37460195fe82 100644 (file)
@@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
 
                vscsi->affinity_hint_set = true;
        } else {
-               for (i = 0; i < vscsi->num_queues - VIRTIO_SCSI_VQ_BASE; i++)
+               for (i = 0; i < vscsi->num_queues; i++)
                        virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1);
 
                vscsi->affinity_hint_set = false;
index 8a6bb37910dabeb018c4fab0bcd68d3936456aa8..81b9adb6e766bdae0b0f6c9de4836ecfaffc490a 100644 (file)
@@ -103,6 +103,16 @@ static void altera_spi_chipsel(struct spi_device *spi, int value)
        }
 }
 
+static int altera_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
+{
+       return 0;
+}
+
+static int altera_spi_setup(struct spi_device *spi)
+{
+       return 0;
+}
+
 static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
 {
        if (hw->tx) {
@@ -221,6 +231,7 @@ static int altera_spi_probe(struct platform_device *pdev)
        master->bus_num = pdev->id;
        master->num_chipselect = 16;
        master->mode_bits = SPI_CS_HIGH;
+       master->setup = altera_spi_setup;
 
        hw = spi_master_get_devdata(master);
        platform_set_drvdata(pdev, hw);
@@ -229,6 +240,7 @@ static int altera_spi_probe(struct platform_device *pdev)
        hw->bitbang.master = spi_master_get(master);
        if (!hw->bitbang.master)
                return err;
+       hw->bitbang.setup_transfer = altera_spi_setupxfer;
        hw->bitbang.chipselect = altera_spi_chipsel;
        hw->bitbang.txrx_bufs = altera_spi_txrx;
 
index 222d3e37fc283b95dc5932570c1dec874cec78e2..707966bd56103181d31887b53cca01c1d9bd9776 100644 (file)
@@ -609,7 +609,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
                else
                        buf = (void *)t->tx_buf;
                t->tx_dma = dma_map_single(&spi->dev, buf,
-                               t->len, DMA_FROM_DEVICE);
+                               t->len, DMA_TO_DEVICE);
                if (!t->tx_dma) {
                        ret = -EFAULT;
                        goto err_tx_map;
index 2ad3d74ac0217061b1942eda99dc0bc4d758a74b..150d85453c27d2c2d5347402113cc52547180db4 100644 (file)
@@ -174,6 +174,17 @@ static void nuc900_spi_gobusy(struct nuc900_spi *hw)
        spin_unlock_irqrestore(&hw->lock, flags);
 }
 
+static int nuc900_spi_setupxfer(struct spi_device *spi,
+                                struct spi_transfer *t)
+{
+       return 0;
+}
+
+static int nuc900_spi_setup(struct spi_device *spi)
+{
+       return 0;
+}
+
 static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count)
 {
        return hw->tx ? hw->tx[count] : 0;
@@ -366,8 +377,10 @@ static int nuc900_spi_probe(struct platform_device *pdev)
        master->num_chipselect     = hw->pdata->num_cs;
        master->bus_num            = hw->pdata->bus_num;
        hw->bitbang.master         = hw->master;
+       hw->bitbang.setup_transfer = nuc900_spi_setupxfer;
        hw->bitbang.chipselect     = nuc900_spi_chipsel;
        hw->bitbang.txrx_bufs      = nuc900_spi_txrx;
+       hw->bitbang.master->setup  = nuc900_spi_setup;
 
        hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (hw->res == NULL) {
index eb53df27e7ea81af4eefa2912da48565724d6aaa..63e2070c6c14aa8e39a64a850248e07a38546708 100644 (file)
@@ -434,6 +434,9 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi)
        dma_cap_mask_t mask;
        int ret;
 
+       if (is_polling(sdd))
+               return 0;
+
        dma_cap_zero(mask);
        dma_cap_set(DMA_SLAVE, mask);
 
index fb56fcfdf65e76b3110ea75bdbb6d9f61141cb93..09a9428525934e2e56732e89202680102295dd9b 100644 (file)
@@ -233,6 +233,21 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
        return 0;
 }
 
+static int xilinx_spi_setup(struct spi_device *spi)
+{
+       /* always return 0, we can not check the number of bits.
+        * There are cases when SPI setup is called before any driver is
+        * there, in that case the SPI core defaults to 8 bits, which we
+        * do not support in some cases. But if we return an error, the
+        * SPI device would not be registered and no driver can get hold of it
+        * When the driver is there, it will call SPI setup again with the
+        * correct number of bits per transfer.
+        * If a driver setups with the wrong bit number, it will fail when
+        * it tries to do a transfer
+        */
+       return 0;
+}
+
 static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
 {
        u8 sr;
@@ -360,6 +375,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
        xspi->bitbang.chipselect = xilinx_spi_chipselect;
        xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer;
        xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs;
+       xspi->bitbang.master->setup = xilinx_spi_setup;
        init_completion(&xspi->done);
 
        if (!request_mem_region(mem->start, resource_size(mem),
index 3227ebeae3f1c88a5260a672e090a31cc18fc8b4..57d8b3444600c3577aaed381fce02be990fe912a 100644 (file)
@@ -118,8 +118,6 @@ source "drivers/staging/ozwpan/Kconfig"
 
 source "drivers/staging/gdm72xx/Kconfig"
 
-source "drivers/staging/csr/Kconfig"
-
 source "drivers/staging/silicom/Kconfig"
 
 source "drivers/staging/ced1401/Kconfig"
index 4d79ebe2de06d9b335333aee5baa060032454619..429321f15105f7159dea275fbb70219e491bf027 100644 (file)
@@ -52,7 +52,6 @@ obj-$(CONFIG_MFD_NVEC)                += nvec/
 obj-$(CONFIG_ANDROID)          += android/
 obj-$(CONFIG_USB_WPAN_HCD)     += ozwpan/
 obj-$(CONFIG_WIMAX_GDM72XX)    += gdm72xx/
-obj-$(CONFIG_CSR_WIFI)         += csr/
 obj-$(CONFIG_NET_VENDOR_SILICOM)       += silicom/
 obj-$(CONFIG_CED1401)          += ced1401/
 obj-$(CONFIG_DRM_IMX)          += imx-drm/
index 080abf2faf972ab3b999ac58f923c03dbec7e9b8..a8c344422a77d5cce6c34fcadfd7d61781d660bc 100644 (file)
@@ -469,7 +469,7 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
                         unsigned long nr_segs, loff_t ppos)
 {
        struct logger_log *log = file_get_log(iocb->ki_filp);
-       size_t orig = log->w_off;
+       size_t orig;
        struct logger_entry header;
        struct timespec now;
        ssize_t ret = 0;
@@ -490,6 +490,8 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
 
        mutex_lock(&log->mutex);
 
+       orig = log->w_off;
+
        /*
         * Fix up any readers, pulling them forward to the first readable
         * entry after (what will be) the new write offset. We do this now
index b10f739b7e3e1fcbe16acaf7d66705b59e534441..fa8da9aada3079b6a18fc0189d4fdca36af753c6 100644 (file)
@@ -9,4 +9,4 @@ TODO:
 Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
 copy:
        Ian Abbott <abbotti@mev.co.uk>
-       Frank Mori Hess <fmhess@users.sourceforge.net>
+       H Hartley Sweeten <hsweeten@visionengravers.com>
index 8647518259f6dd5ab3379babc218d5ef6cf24831..f4a197b2d1fd951f8879b78cd96e6a2cce1f24d3 100644 (file)
@@ -1413,22 +1413,19 @@ static int do_cmd_ioctl(struct comedi_device *dev,
                DPRINTK("subdevice busy\n");
                return -EBUSY;
        }
-       s->busy = file;
 
        /* make sure channel/gain list isn't too long */
        if (cmd.chanlist_len > s->len_chanlist) {
                DPRINTK("channel/gain list too long %u > %d\n",
                        cmd.chanlist_len, s->len_chanlist);
-               ret = -EINVAL;
-               goto cleanup;
+               return -EINVAL;
        }
 
        /* make sure channel/gain list isn't too short */
        if (cmd.chanlist_len < 1) {
                DPRINTK("channel/gain list too short %u < 1\n",
                        cmd.chanlist_len);
-               ret = -EINVAL;
-               goto cleanup;
+               return -EINVAL;
        }
 
        async->cmd = cmd;
@@ -1438,8 +1435,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
            kmalloc(async->cmd.chanlist_len * sizeof(int), GFP_KERNEL);
        if (!async->cmd.chanlist) {
                DPRINTK("allocation failed\n");
-               ret = -ENOMEM;
-               goto cleanup;
+               return -ENOMEM;
        }
 
        if (copy_from_user(async->cmd.chanlist, user_chanlist,
@@ -1491,6 +1487,9 @@ static int do_cmd_ioctl(struct comedi_device *dev,
 
        comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING);
 
+       /* set s->busy _after_ setting SRF_RUNNING flag to avoid race with
+        * comedi_read() or comedi_write() */
+       s->busy = file;
        ret = s->do_cmd(dev, s);
        if (ret == 0)
                return 0;
@@ -1705,6 +1704,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
                           void *file)
 {
        struct comedi_subdevice *s;
+       int ret;
 
        if (arg >= dev->n_subdevices)
                return -EINVAL;
@@ -1721,7 +1721,11 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
        if (s->busy != file)
                return -EBUSY;
 
-       return do_cancel(dev, s);
+       ret = do_cancel(dev, s);
+       if (comedi_get_subdevice_runflags(s) & SRF_USER)
+               wake_up_interruptible(&s->async->wait_head);
+
+       return ret;
 }
 
 /*
@@ -2053,11 +2057,13 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
 
                if (!comedi_is_subdevice_running(s)) {
                        if (count == 0) {
+                               mutex_lock(&dev->mutex);
                                if (comedi_is_subdevice_in_error(s))
                                        retval = -EPIPE;
                                else
                                        retval = 0;
                                do_become_nonbusy(dev, s);
+                               mutex_unlock(&dev->mutex);
                        }
                        break;
                }
@@ -2156,11 +2162,13 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
 
                if (n == 0) {
                        if (!comedi_is_subdevice_running(s)) {
+                               mutex_lock(&dev->mutex);
                                do_become_nonbusy(dev, s);
                                if (comedi_is_subdevice_in_error(s))
                                        retval = -EPIPE;
                                else
                                        retval = 0;
+                               mutex_unlock(&dev->mutex);
                                break;
                        }
                        if (file->f_flags & O_NONBLOCK) {
@@ -2198,9 +2206,11 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
                buf += n;
                break;          /* makes device work like a pipe */
        }
-       if (comedi_is_subdevice_idle(s) &&
-           async->buf_read_count - async->buf_write_count == 0) {
-               do_become_nonbusy(dev, s);
+       if (comedi_is_subdevice_idle(s)) {
+               mutex_lock(&dev->mutex);
+               if (async->buf_read_count - async->buf_write_count == 0)
+                       do_become_nonbusy(dev, s);
+               mutex_unlock(&dev->mutex);
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&async->wait_head, &wait);
diff --git a/drivers/staging/csr/Kconfig b/drivers/staging/csr/Kconfig
deleted file mode 100644 (file)
index ad2a109..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-config CSR_WIFI
-       tristate "CSR wireless driver"
-       depends on MMC && CFG80211_WEXT && INET
-       select WIRELESS_EXT
-       select WEXT_PRIV
-       help
-         Driver for the CSR wireless SDIO device.
-
-         If unsure, select N.
diff --git a/drivers/staging/csr/LICENSE.txt b/drivers/staging/csr/LICENSE.txt
deleted file mode 100644 (file)
index 364853e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-Except as contained in this notice, the names of above-listed
-copyright holders and the names of any contributors shall not be used
-in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
-OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-Alternatively, this software may be distributed under the terms of the
-GNU General Public License ("GPL") version 2 as published
-by the Free Software Foundation.
-
-As a special exception, if other files instantiate templates or use
-macros or inline functions from this file, or you compile this file
-and link it with other works to produce a work based on this file,
-this file does not by itself cause the resulting work to be covered by
-the GNU General Public License. However the source code for this file
-must still be made available in accordance with section (3) of the GNU
-General Public License.
-
-This exception does not invalidate any other reasons why a work based
-on this file might be covered by the GNU General Public License.
diff --git a/drivers/staging/csr/Makefile b/drivers/staging/csr/Makefile
deleted file mode 100644 (file)
index dbd135a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-ccflags-y      := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG
-ccflags-y      += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH
-ccflags-y      += -DCSR_SUPPORT_WEXT -DREMOTE_SYS_SAP  -DREMOTE_MGT_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DCSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND -DENABLE_SHUTDOWN -DCSR_WIFI_NME_ENABLE -DCSR_WIFI_AP_ENABLE -DCSR_SUPPORT_WEXT_AP -DCSR_WIFI_REQUEUE_PACKET_TO_HAL
-
-obj-$(CONFIG_CSR_WIFI) += csr_wifi.o
-obj-$(CONFIG_CSR_WIFI) += csr_helper.o
-
-csr_wifi-y :=  bh.o                            \
-               data_tx.o                       \
-               drv.o                           \
-               firmware.o                      \
-               inet.o                          \
-               init_hw.o                       \
-               io.o                            \
-               monitor.o                       \
-               netdev.o                        \
-               os.o                            \
-               putest.o                        \
-               sdio_events.o                   \
-               sdio_mmc.o                      \
-               sdio_stubs.o                    \
-               sme_blocking.o                  \
-               ul_int.o                        \
-               unifi_dbg.o                     \
-               unifi_event.o                   \
-               unifi_pdu_processing.o          \
-               unifi_sme.o                     \
-               csr_wifi_hip_card_sdio.o        \
-               csr_wifi_hip_card_sdio_intr.o   \
-               csr_wifi_hip_card_sdio_mem.o    \
-               csr_wifi_hip_chiphelper.o       \
-               csr_wifi_hip_download.o         \
-               csr_wifi_hip_dump.o             \
-               csr_wifi_hip_packing.o          \
-               csr_wifi_hip_send.o             \
-               csr_wifi_hip_signals.o          \
-               csr_wifi_hip_ta_sampling.o      \
-               csr_wifi_hip_udi.o              \
-               csr_wifi_hip_unifi_signal_names.o       \
-               csr_wifi_hip_xbv.o              \
-               csr_wifi_nme_ap_converter_init.o                \
-               csr_wifi_nme_ap_free_downstream_contents.o      \
-               csr_wifi_nme_ap_free_upstream_contents.o        \
-               csr_wifi_nme_ap_serialize.o     \
-               csr_wifi_nme_ap_sef.o           \
-               csr_wifi_router_ctrl_sef.o      \
-               csr_wifi_router_sef.o           \
-               csr_wifi_router_transport.o     \
-               csr_wifi_sme_sef.o              \
-               csr_wifi_sme_converter_init.o   \
-               csr_wifi_sme_free_downstream_contents.o         \
-               csr_wifi_sme_free_upstream_contents.o           \
-               csr_wifi_sme_serialize.o                        \
-               csr_wifi_router_ctrl_converter_init.o           \
-               csr_wifi_router_ctrl_free_downstream_contents.o \
-               csr_wifi_router_ctrl_free_upstream_contents.o   \
-               csr_wifi_router_ctrl_serialize.o                \
-               csr_wifi_router_converter_init.o                \
-               csr_wifi_router_free_downstream_contents.o      \
-               csr_wifi_router_free_upstream_contents.o        \
-               csr_wifi_router_serialize.o                     \
-               sme_mgt.o                       \
-               sme_sys.o                       \
-               sme_userspace.o                 \
-               sme_wext.o                      \
-               wext_events.o
-
-csr_helper-y :=        csr_time.o                      \
-               csr_util.o                      \
-               csr_framework_ext.o             \
-               csr_wifi_serialize_primitive_types.o    \
-               csr_serialize_primitive_types.o \
-               csr_msgconv.o
diff --git a/drivers/staging/csr/bh.c b/drivers/staging/csr/bh.c
deleted file mode 100644 (file)
index d795852..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     bh.c
- *
- * PURPOSE:
- *      Provides an implementation for the driver bottom-half.
- *      It is part of the porting exercise in Linux.
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include "csr_wifi_hip_unifi.h"
-#include "unifi_priv.h"
-#include <linux/sched/rt.h>
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_start_thread
- *
- *      Helper function to start a new thread.
- *
- *  Arguments:
- *      priv            Pointer to OS driver structure for the device.
- *      thread          Pointer to the thread object
- *      func            The thread function
- *
- *  Returns:
- *      0 on success or else a Linux error code.
- * ---------------------------------------------------------------------------
- */
-int uf_start_thread(unifi_priv_t *priv,
-                   struct uf_thread *thread, int (*func)(void *))
-{
-       if (thread->thread_task != NULL) {
-               unifi_error(priv, "%s thread already started\n", thread->name);
-               return 0;
-       }
-
-       /* Start the kernel thread that handles all h/w accesses. */
-       thread->thread_task = kthread_run(func, priv, "%s", thread->name);
-       if (IS_ERR(thread->thread_task))
-               return PTR_ERR(thread->thread_task);
-
-       /* Module parameter overides the thread priority */
-       if (bh_priority != -1) {
-               if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) {
-                       struct sched_param param;
-                       priv->bh_thread.prio = bh_priority;
-                       unifi_trace(priv, UDBG1,
-                               "%s thread (RT) priority = %d\n",
-                               thread->name, bh_priority);
-                       param.sched_priority = bh_priority;
-                       sched_setscheduler(thread->thread_task,
-                                          SCHED_FIFO, &param);
-               } else if (bh_priority > MAX_RT_PRIO &&
-                          bh_priority <= MAX_PRIO) {
-                       priv->bh_thread.prio = bh_priority;
-                       unifi_trace(priv, UDBG1, "%s thread priority = %d\n",
-                                       thread->name,
-                                       PRIO_TO_NICE(bh_priority));
-                       set_user_nice(thread->thread_task,
-                                     PRIO_TO_NICE(bh_priority));
-               } else {
-                       priv->bh_thread.prio = DEFAULT_PRIO;
-                       unifi_warning(priv,
-                                     "%s thread unsupported (%d) priority\n",
-                                     thread->name, bh_priority);
-               }
-       } else
-               priv->bh_thread.prio = DEFAULT_PRIO;
-       unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name);
-
-       return 0;
-} /* uf_start_thread() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_stop_thread
- *
- *      Helper function to stop a thread.
- *
- *  Arguments:
- *      priv            Pointer to OS driver structure for the device.
- *      thread          Pointer to the thread object
- *
- *  Returns:
- *
- * ---------------------------------------------------------------------------
- */
-void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread)
-{
-       if (!thread->thread_task) {
-               unifi_notice(priv, "%s thread is already stopped\n",
-                                                       thread->name);
-               return;
-       }
-
-       unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name);
-
-       kthread_stop(thread->thread_task);
-       thread->thread_task = NULL;
-
-} /* uf_stop_thread() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_wait_for_thread_to_stop
- *
- *      Helper function to wait until a thread is stopped.
- *
- *  Arguments:
- *      priv    Pointer to OS driver structure for the device.
- *
- *  Returns:
- *
- * ---------------------------------------------------------------------------
- */
-void
-uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread)
-{
-       /*
-        * kthread_stop() cannot handle the thread exiting while
-        * kthread_should_stop() is false, so sleep until kthread_stop()
-        * wakes us up
-        */
-       unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n",
-                                                       thread->name);
-       set_current_state(TASK_INTERRUPTIBLE);
-       if (!kthread_should_stop()) {
-               unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name);
-               schedule();
-       }
-
-       thread->thread_task = NULL;
-       unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name);
-} /* uf_wait_for_thread_to_stop() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  handle_bh_error
- *
- *      This function reports an error returned from the HIP core bottom-half.
- *      Normally, implemented during the porting exercise, passing the error
- *      to the SME using unifi_sys_wifi_off_ind().
- *      The SME will try to reset the device and go through
- *      the initialisation of the UniFi.
- *
- *  Arguments:
- *      priv            Pointer to OS driver structure for the device.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-handle_bh_error(unifi_priv_t *priv)
-{
-       netInterface_priv_t *interfacePriv;
-       u8 conf_param = CONFIG_IND_ERROR;
-       u8 interfaceTag;
-
-
-       /* Block unifi_run_bh() until the error has been handled. */
-       priv->bh_thread.block_thread = 1;
-
-       /* Consider UniFi to be uninitialised */
-       priv->init_progress = UNIFI_INIT_NONE;
-
-       /* Stop the network traffic */
-       for (interfaceTag = 0;
-            interfaceTag < CSR_WIFI_NUM_INTERFACES; interfaceTag++) {
-               interfacePriv = priv->interfacePriv[interfaceTag];
-               if (interfacePriv->netdev_registered)
-                       netif_carrier_off(priv->netdev[interfaceTag]);
-       }
-
-#ifdef CSR_NATIVE_LINUX
-       /* Force any client waiting on an mlme_wait_for_reply() to abort. */
-       uf_abort_mlme(priv);
-
-       /* Cancel any pending workqueue tasks */
-       flush_workqueue(priv->unifi_workqueue);
-
-#endif /* CSR_NATIVE_LINUX */
-
-       unifi_error(priv,
-               "handle_bh_error: fatal error is reported to the SME.\n");
-       /* Notify the clients (SME or unifi_manager) for the error. */
-       ul_log_config_ind(priv, &conf_param, sizeof(u8));
-
-} /* handle_bh_error() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  bh_thread_function
- *
- *      All hardware access happens in this thread.
- *      This means there is no need for locks on the hardware and we don't need
- *      to worry about reentrancy with the SDIO library.
- *      Provides and example implementation on how to call unifi_bh(), which
- *      is part of the HIP core API.
- *
- *      It processes the events generated by unifi_run_bh() to serialise calls
- *      to unifi_bh(). It also demonstrates how the timeout parameter passed in
- *      and returned from unifi_bh() needs to be handled.
- *
- *  Arguments:
- *      arg             Pointer to OS driver structure for the device.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      When the bottom half of the driver needs to process signals, events,
- *      or simply the host status (i.e sleep mode), it invokes unifi_run_bh().
- *      Since we need all SDIO transaction to be in a single thread, the
- *      unifi_run_bh() will wake up this thread to process it.
- *
- * ---------------------------------------------------------------------------
- */
-static int bh_thread_function(void *arg)
-{
-       unifi_priv_t *priv = (unifi_priv_t *)arg;
-       CsrResult csrResult;
-       long ret;
-       u32 timeout, t;
-       struct uf_thread *this_thread;
-
-       unifi_trace(priv, UDBG2, "bh_thread_function starting\n");
-
-       this_thread = &priv->bh_thread;
-
-       t = timeout = 0;
-       while (!kthread_should_stop()) {
-               /*
-               * wait until an error occurs,
-               * or we need to process something.
-               */
-               unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n");
-
-               if (timeout > 0) {
-                       /* Convert t in ms to jiffies */
-                       t = msecs_to_jiffies(timeout);
-                       ret = wait_event_interruptible_timeout(
-                               this_thread->wakeup_q,
-                               (this_thread->wakeup_flag && !this_thread->block_thread) ||
-                               kthread_should_stop(),
-                               t);
-                       timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0;
-               } else {
-                       ret = wait_event_interruptible(this_thread->wakeup_q,
-                               (this_thread->wakeup_flag && !this_thread->block_thread) ||
-                               kthread_should_stop());
-               }
-
-               if (kthread_should_stop()) {
-                       unifi_trace(priv, UDBG2,
-                               "bh_thread: signalled to exit\n");
-                       break;
-               }
-
-               if (ret < 0) {
-                       unifi_notice(priv,
-                               "bh_thread: wait_event returned %d, thread will exit\n",
-                               ret);
-                       uf_wait_for_thread_to_stop(priv, this_thread);
-                       break;
-               }
-
-               this_thread->wakeup_flag = 0;
-
-               unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n");
-
-               CsrSdioClaim(priv->sdio);
-               csrResult = unifi_bh(priv->card, &timeout);
-               if (csrResult != CSR_RESULT_SUCCESS) {
-                       if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
-                               CsrSdioRelease(priv->sdio);
-                               uf_wait_for_thread_to_stop(priv, this_thread);
-                               break;
-                       }
-                       /* Errors must be delivered to the error task */
-                       handle_bh_error(priv);
-               }
-               CsrSdioRelease(priv->sdio);
-       }
-
-       /*
-        * I would normally try to call csr_sdio_remove_irq() here to make sure
-       * that we do not get any interrupts while this thread is not running.
-       * However, the MMC/SDIO driver tries to kill its' interrupt thread.
-       * The kernel threads implementation does not allow to kill threads
-       * from a signalled to stop thread.
-       * So, instead call csr_sdio_linux_remove_irq() always after calling
-       * uf_stop_thread() to kill this thread.
-       */
-
-       unifi_trace(priv, UDBG2, "bh_thread exiting....\n");
-       return 0;
-} /* bh_thread_function() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_init_bh
- *
- *      Helper function to start the bottom half of the driver.
- *      All we need to do here is start the I/O bh thread.
- *
- *  Arguments:
- *      priv            Pointer to OS driver structure for the device.
- *
- *  Returns:
- *      0 on success or else a Linux error code.
- * ---------------------------------------------------------------------------
- */
-int
-uf_init_bh(unifi_priv_t *priv)
-{
-       int r;
-
-       /* Enable mlme interface. */
-       priv->io_aborted = 0;
-
-
-       /* Start the BH thread */
-       r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function);
-       if (r) {
-               unifi_error(priv,
-                       "uf_init_bh: failed to start the BH thread.\n");
-               return r;
-       }
-
-       /* Allow interrupts */
-       r = csr_sdio_linux_install_irq(priv->sdio);
-       if (r) {
-               unifi_error(priv,
-                       "uf_init_bh: failed to install the IRQ.\n");
-
-               uf_stop_thread(priv, &priv->bh_thread);
-       }
-
-       return r;
-} /* uf_init_bh() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_run_bh
- *
- *      Part of the HIP core lib API, implemented in the porting exercise.
- *      The bottom half of the driver calls this function when
- *      it wants to process anything that requires access to unifi.
- *      We need to call unifi_bh() which in this implementation is done
- *      by waking up the I/O thread.
- *
- *  Arguments:
- *      ospriv          Pointer to OS driver structure for the device.
- *
- *  Returns:
- *      0 on success or else a Linux error code.
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_run_bh(void *ospriv)
-{
-       unifi_priv_t *priv = ospriv;
-
-       /*
-       * If an error has occurred, we discard silently all messages from the bh
-       * until the error has been processed and the unifi has been
-       * reinitialised.
-       */
-       if (priv->bh_thread.block_thread == 1) {
-               unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n");
-               /*
-               * Do not try to acknowledge a pending interrupt here.
-               * This function is called by unifi_send_signal()
-               * which in turn can be running in an atomic or 'disabled irq'
-               * level if a signal is sent from a workqueue task
-               * (i.e multicass addresses set). We can not hold the SDIO lock
-               * because it might sleep.
-               */
-               return CSR_RESULT_FAILURE;
-       }
-
-       priv->bh_thread.wakeup_flag = 1;
-       /* wake up I/O thread */
-       wake_up_interruptible(&priv->bh_thread.wakeup_q);
-
-       return CSR_RESULT_SUCCESS;
-} /* unifi_run_bh() */
-
diff --git a/drivers/staging/csr/csr_framework_ext.c b/drivers/staging/csr/csr_framework_ext.c
deleted file mode 100644 (file)
index 98122bc..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*****************************************************************************
-
-               (c) Cambridge Silicon Radio Limited 2010
-               All rights reserved and confidential information of CSR
-
-               Refer to LICENSE.txt included with this source for details
-               on the license terms.
-
-*****************************************************************************/
-
-#include <linux/kernel.h>
-#include <linux/kthread.h>
-#include <linux/module.h>
-#include <linux/freezer.h>
-#include <linux/semaphore.h>
-#include <linux/slab.h>
-#include <linux/bitops.h>
-
-#include "csr_framework_ext.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrThreadSleep
- *
- *  DESCRIPTION
- *      Sleep for a given period.
- *
- *  RETURNS
- *      void
- *
- *----------------------------------------------------------------------------*/
-void CsrThreadSleep(u16 sleepTimeInMs)
-{
-       unsigned long t;
-
-       /* Convert t in ms to jiffies and round up */
-       t = ((sleepTimeInMs * HZ) + 999) / 1000;
-       schedule_timeout_uninterruptible(t);
-}
-EXPORT_SYMBOL_GPL(CsrThreadSleep);
diff --git a/drivers/staging/csr/csr_framework_ext.h b/drivers/staging/csr/csr_framework_ext.h
deleted file mode 100644 (file)
index 6d26ac6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef CSR_FRAMEWORK_EXT_H__
-#define CSR_FRAMEWORK_EXT_H__
-/*****************************************************************************
-
-               (c) Cambridge Silicon Radio Limited 2010
-       All rights reserved and confidential information of CSR
-
-               Refer to LICENSE.txt included with this source for details
-               on the license terms.
-
-*****************************************************************************/
-
-#include "csr_result.h"
-#include "csr_framework_ext_types.h"
-
-/* Result codes */
-#define CSR_FE_RESULT_NO_MORE_EVENTS    ((CsrResult) 0x0001)
-#define CSR_FE_RESULT_INVALID_POINTER   ((CsrResult) 0x0002)
-#define CSR_FE_RESULT_INVALID_HANDLE    ((CsrResult) 0x0003)
-#define CSR_FE_RESULT_NO_MORE_MUTEXES   ((CsrResult) 0x0004)
-#define CSR_FE_RESULT_TIMEOUT           ((CsrResult) 0x0005)
-#define CSR_FE_RESULT_NO_MORE_THREADS   ((CsrResult) 0x0006)
-
-/* Thread priorities */
-#define CSR_THREAD_PRIORITY_HIGHEST     ((u16) 0)
-#define CSR_THREAD_PRIORITY_HIGH        ((u16) 1)
-#define CSR_THREAD_PRIORITY_NORMAL      ((u16) 2)
-#define CSR_THREAD_PRIORITY_LOW         ((u16) 3)
-#define CSR_THREAD_PRIORITY_LOWEST      ((u16) 4)
-
-#define CSR_EVENT_WAIT_INFINITE         ((u16) 0xFFFF)
-
-void CsrThreadSleep(u16 sleepTimeInMs);
-
-#endif
diff --git a/drivers/staging/csr/csr_framework_ext_types.h b/drivers/staging/csr/csr_framework_ext_types.h
deleted file mode 100644 (file)
index 575598c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef CSR_FRAMEWORK_EXT_TYPES_H__
-#define CSR_FRAMEWORK_EXT_TYPES_H__
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2010
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-#ifdef __KERNEL__
-#include <linux/kthread.h>
-#include <linux/semaphore.h>
-#else
-#include <pthread.h>
-#endif
-
-#ifdef __KERNEL__
-
-typedef struct semaphore CsrMutexHandle;
-
-#else /* __KERNEL __ */
-
-typedef pthread_mutex_t CsrMutexHandle;
-
-#endif /* __KERNEL__ */
-
-#endif
diff --git a/drivers/staging/csr/csr_log.h b/drivers/staging/csr/csr_log.h
deleted file mode 100644 (file)
index 9829410..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef CSR_LOG_H__
-#define CSR_LOG_H__
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2010
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-#include "csr_sched.h"
-#include "csr_prim_defs.h"
-#include "csr_msgconv.h"
-
-/*
- * Log filtering
- */
-
-/*----------------------------------------------------*/
-/*  Filtering on environment specific log levels      */
-/*----------------------------------------------------*/
-typedef u32 CsrLogLevelEnvironment;
-#define CSR_LOG_LEVEL_ENVIRONMENT_OFF          ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL      ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI      ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO      ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR   ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
-#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS   ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG    ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG  ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET    ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START  ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE   ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO        ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
-#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC    ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occurred are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */
-/* The bit masks between here are reserved for future usage */
-#define CSR_LOG_LEVEL_ENVIRONMENT_ALL          ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */
-
-/*----------------------------------------------------*/
-/*  Filtering on task specific log levels             */
-/*----------------------------------------------------*/
-typedef u32 CsrLogLevelTask;
-#define CSR_LOG_LEVEL_TASK_OFF                 ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
-#define CSR_LOG_LEVEL_TASK_TEXT                ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */
-#define CSR_LOG_LEVEL_TASK_TEXT_LOC            ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */
-#define CSR_LOG_LEVEL_TASK_STATE               ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
-#define CSR_LOG_LEVEL_TASK_STATE_NAME          ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
-#define CSR_LOG_LEVEL_TASK_STATE_LOC           ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
-#define CSR_LOG_LEVEL_TASK_TASK_SWITCH         ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
-#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT         ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
-#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC     ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */
-#define CSR_LOG_LEVEL_TASK_MESSAGE_GET         ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
-#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH  ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
-#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP   ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
-#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE      ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */
-#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT    ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */
-#define CSR_LOG_LEVEL_TASK_TIMER_IN            ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
-#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC        ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */
-#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL        ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
-#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC    ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */
-#define CSR_LOG_LEVEL_TASK_TIMER_FIRE          ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
-#define CSR_LOG_LEVEL_TASK_TIMER_DONE          ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
-/* The bit masks between here are reserved for future usage */
-#define CSR_LOG_LEVEL_TASK_ALL                 ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */
-
-u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
-CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
-u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
-
-/*
- * Logging stuff
- */
-#define CSR_LOG_STRINGIFY_REAL(a) (#a)
-#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
-
-typedef struct {
-       u16            primitiveType;
-       const char *primitiveName;
-       CsrMsgConvMsgEntry  *messageConv; /* Private - do not use */
-} CsrLogPrimitiveInformation;
-
-typedef struct {
-       const char        *techVer;
-       u32                   primitiveInfoCount;
-       CsrLogPrimitiveInformation *primitiveInfo;
-} CsrLogTechInformation;
-
-/*---------------------------------*/
-/*  Tech logging */
-/*---------------------------------*/
-typedef u8 bitmask8_t;
-typedef u16 bitmask16_t;
-typedef u32 bitmask32_t;
-
-#ifdef CSR_LOG_ENABLE
-#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
-/* DEPRECATED - replaced by csr_log_text.h */
-#define CSR_LOG_TEXT(text) \
-       do { \
-               if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
-                       CsrLogTaskText(text, __LINE__, __FILE__); \
-               } \
-       } while (0)
-#else
-/* DEPRECATED - replaced by csr_log_text.h */
-#define CSR_LOG_TEXT(text) \
-       do { \
-               if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
-                       CsrLogTaskText(text, 0, NULL); \
-               } \
-       } while (0)
-#endif
-#else
-#define CSR_LOG_TEXT(text)
-#endif
-
-/* DEPRECATED - replaced by csr_log_text.h */
-void CsrLogTaskText(const char *text,
-       u32 line,
-       const char *file);
-
-#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME          (0x001)
-#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE        (0x002)
-#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR    (0x004)
-#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE        (0x008)
-#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR    (0x010)
-#define CSR_LOG_STATE_TRANSITION_MASK_EVENT             (0x020)
-#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR         (0x040)
-
-/* DEPRECATED - replaced by csr_log_text.h */
-void CsrLogStateTransition(bitmask16_t mask,
-       u32 identifier,
-       const char *fsm_name,
-       u32 prev_state,
-       const char *prev_state_str,
-       u32 in_event,
-       const char *in_event_str,
-       u32 next_state,
-       const char *next_state_str,
-       u32 line,
-       const char *file);
-
-/*---------------------------------*/
-/*  BSP logging */
-/*---------------------------------*/
-void CsrLogSchedInit(u8 thread_id);
-void CsrLogSchedDeinit(u8 thread_id);
-
-void CsrLogSchedStart(u8 thread_id);
-void CsrLogSchedStop(u8 thread_id);
-
-void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
-void CsrLogDeinitTask(u16 task_id);
-
-void CsrLogActivate(CsrSchedQid tskid);
-void CsrLogDeactivate(CsrSchedQid tskid);
-
-#define SYNERGY_SERIALIZER_TYPE_DUMP    (0x000)
-#define SYNERGY_SERIALIZER_TYPE_SER     (0x001)
-
-void CsrLogMessagePut(u32 line,
-       const char *file,
-       CsrSchedQid src_task_id,
-       CsrSchedQid dst_taskid,
-       CsrSchedMsgId msg_id,
-       u16 prim_type,
-       const void *msg);
-
-void CsrLogMessageGet(CsrSchedQid src_task_id,
-       CsrSchedQid dst_taskid,
-       u8 get_res,
-       CsrSchedMsgId msg_id,
-       u16 prim_type,
-       const void *msg);
-
-void CsrLogTimedEventIn(u32 line,
-       const char *file,
-       CsrSchedQid task_id,
-       CsrSchedTid tid,
-       u32 requested_delay,
-       u16 fniarg,
-       const void *fnvarg);
-
-void CsrLogTimedEventFire(CsrSchedQid task_id,
-       CsrSchedTid tid);
-
-void CsrLogTimedEventDone(CsrSchedQid task_id,
-       CsrSchedTid tid);
-
-void CsrLogTimedEventCancel(u32 line,
-       const char *file,
-       CsrSchedQid task_id,
-       CsrSchedTid tid,
-       u8 cancel_res);
-
-void CsrLogBgintRegister(u8 thread_id,
-       CsrSchedBgint irq,
-       const char *callback,
-       const void *ptr);
-void CsrLogBgintUnregister(CsrSchedBgint irq);
-void CsrLogBgintSet(CsrSchedBgint irq);
-void CsrLogBgintServiceStart(CsrSchedBgint irq);
-void CsrLogBgintServiceDone(CsrSchedBgint irq);
-
-void CsrLogExceptionStateEvent(u16 prim_type,
-       CsrPrim msg_type,
-       u16 state,
-       u32 line,
-       const char *file);
-void CsrLogExceptionGeneral(u16 prim_type,
-       u16 state,
-       const char *text,
-       u32 line,
-       const char *file);
-void CsrLogExceptionWarning(u16 prim_type,
-       u16 state,
-       const char *text,
-       u32 line,
-       const char *file);
-
-#endif
diff --git a/drivers/staging/csr/csr_log_configure.h b/drivers/staging/csr/csr_log_configure.h
deleted file mode 100644 (file)
index 283647c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CSR_LOG_CONFIGURE_H__
-#define CSR_LOG_CONFIGURE_H__
-/*****************************************************************************
-
-  (c) Cambridge Silicon Radio Limited 2010
-  All rights reserved and confidential information of CSR
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-
-#include "csr_log.h"
-
-/*--------------------------------------------*/
-/*  Filtering on log text warning levels      */
-/*--------------------------------------------*/
-typedef u32 CsrLogLevelText;
-#define CSR_LOG_LEVEL_TEXT_OFF       ((CsrLogLevelText) 0x0000)
-
-#define CSR_LOG_LEVEL_TEXT_CRITICAL  ((CsrLogLevelText) 0x0001)
-#define CSR_LOG_LEVEL_TEXT_ERROR     ((CsrLogLevelText) 0x0002)
-#define CSR_LOG_LEVEL_TEXT_WARNING   ((CsrLogLevelText) 0x0004)
-#define CSR_LOG_LEVEL_TEXT_INFO      ((CsrLogLevelText) 0x0008)
-#define CSR_LOG_LEVEL_TEXT_DEBUG     ((CsrLogLevelText) 0x0010)
-
-#define CSR_LOG_LEVEL_TEXT_ALL       ((CsrLogLevelText) 0xFFFF)
-
-/* The log text interface is used by both scheduler tasks and components outside the scheduler context.
- * Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two u16's. The lower
- * 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used
- * by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the
- * scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid
- * clashes the technologies are only allowed to assign values within the same restrictive range as allies to
- * primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign
- * taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */
-typedef u32 CsrLogTextTaskId;
-
-#endif
diff --git a/drivers/staging/csr/csr_log_text.h b/drivers/staging/csr/csr_log_text.h
deleted file mode 100644 (file)
index cfcf64a..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef CSR_LOG_TEXT_H__
-#define CSR_LOG_TEXT_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include "csr_log_configure.h"
-
-typedef struct CsrLogSubOrigin
-{
-    u16            subOriginNumber;  /* Id of the given SubOrigin */
-    const char *subOriginName;    /* Prefix Text for this SubOrigin */
-} CsrLogSubOrigin;
-
-/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
-#ifdef CSR_LOG_ENABLE
-void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
-#else
-#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins)
-#endif
-
-/* CRITICAL: Conditions that are threatening to the integrity/stability of the
-   system as a whole. */
-#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE)
-void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
-void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
-#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs
-#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}}
-#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}}
-#else
-#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs)
-#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs)
-#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs)
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs)
-#endif
-
-/* ERROR: Malfunction of a component rendering it unable to operate correctly,
-   causing lack of functionality but not loss of system integrity/stability. */
-#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE)
-void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
-void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
-#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs
-#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}}
-#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}}
-#else
-#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs)
-#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs)
-#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs)
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs)
-#endif
-
-/* WARNING: Conditions that are unexpected and indicative of possible problems
-   or violations of specifications, where the result of such deviations does not
-   lead to malfunction of the component. */
-#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE)
-void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
-void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
-#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs
-#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}}
-#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}}
-#else
-#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs)
-#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs)
-#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs)
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs)
-#endif
-
-/* INFO: Important events that may aid in determining the conditions under which
-   the more severe conditions are encountered. */
-#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE)
-void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
-void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
-#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs
-#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}}
-#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}}
-#else
-#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs)
-#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs)
-#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs)
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs)
-#endif
-
-/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */
-#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE)
-void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
-void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
-#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs
-#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}}
-#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}}
-#else
-#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs)
-#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs)
-#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs)
-#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs)
-#endif
-
-/* CSR_LOG_TEXT_ASSERT (CRITICAL) */
-#ifdef CSR_LOG_ENABLE
-#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \
-    {if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}}
-#else
-#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition)
-#endif
-
-/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */
-#ifdef CSR_LOG_ENABLE
-#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \
-    CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__))
-#else
-#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType)
-#endif
-
-#endif
diff --git a/drivers/staging/csr/csr_macro.h b/drivers/staging/csr/csr_macro.h
deleted file mode 100644 (file)
index c47f1d9..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CSR_MACRO_H__
-#define CSR_MACRO_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include <linux/types.h>
-
-#define FALSE  (0)
-#define TRUE   (1)
-
-/*------------------------------------------------------------------*/
-/* Endian conversion */
-/*------------------------------------------------------------------*/
-#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr)        (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8)
-#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr)        (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \
-                                                       ((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24)
-#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr)    ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \
-    ((u8 *) (ptr))[1] = ((u8) ((uint) >> 8))
-#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr)    ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \
-    ((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
-    ((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \
-    ((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF))
-
-/*------------------------------------------------------------------*/
-/* Misc */
-/*------------------------------------------------------------------*/
-/* Use this macro on unused local variables that cannot be removed (such as
-   unused function parameters). This will quell warnings from certain compilers
-   and static code analysis tools like Lint and Valgrind. */
-#define CSR_UNUSED(x) ((void) (x))
-
-#endif
diff --git a/drivers/staging/csr/csr_msg_transport.h b/drivers/staging/csr/csr_msg_transport.h
deleted file mode 100644 (file)
index 8d88e78..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef CSR_MSG_TRANSPORT_H__
-#define CSR_MSG_TRANSPORT_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CsrMsgTransport
-#define CsrMsgTransport CsrSchedMessagePut
-#endif
-
-#endif /* CSR_MSG_TRANSPORT */
diff --git a/drivers/staging/csr/csr_msgconv.c b/drivers/staging/csr/csr_msgconv.c
deleted file mode 100644 (file)
index db5e845..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include "csr_sched.h"
-#include "csr_msgconv.h"
-#include "csr_macro.h"
-
-static CsrMsgConvEntry *converter;
-
-CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType)
-{
-    CsrMsgConvPrimEntry *ptr = NULL;
-
-    if (converter)
-    {
-        ptr = converter->profile_converters;
-        while (ptr)
-        {
-            if (ptr->primType == primType)
-            {
-                break;
-            }
-            else
-            {
-                ptr = ptr->next;
-            }
-        }
-    }
-
-    return ptr;
-}
-
-static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, u16 msgType)
-{
-    const CsrMsgConvMsgEntry *cv = ptr->conv;
-    if (ptr->lookupFunc)
-    {
-        return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType);
-    }
-
-    while (cv)
-    {
-        if (cv->serFunc == NULL)
-        {
-            /* We've reached the end of the chain */
-            cv = NULL;
-            break;
-        }
-
-        if (cv->msgType == msgType)
-        {
-            break;
-        }
-        else
-        {
-            cv++;
-        }
-    }
-
-    return cv;
-}
-
-static void *deserialize_data(u16 primType,
-    size_t length,
-    u8 *data)
-{
-    CsrMsgConvPrimEntry *ptr;
-    u8 *ret;
-
-    ptr = CsrMsgConvFind(primType);
-
-    if (ptr)
-    {
-        const CsrMsgConvMsgEntry *cv;
-        u16 msgId = 0;
-        size_t offset = 0;
-        CsrUint16Des(&msgId, data, &offset);
-
-        cv = find_msg_converter(ptr, msgId);
-        if (cv)
-        {
-            ret = cv->deserFunc(data, length);
-        }
-        else
-        {
-            ret = NULL;
-        }
-    }
-    else
-    {
-        ret = NULL;
-    }
-
-    return ret;
-}
-
-static size_t sizeof_message(u16 primType, void *msg)
-{
-    CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
-    size_t ret;
-
-    if (ptr)
-    {
-        const CsrMsgConvMsgEntry *cv;
-        u16 msgId = *(u16 *) msg;
-
-        cv = find_msg_converter(ptr, msgId);
-        if (cv)
-        {
-            ret = cv->sizeofFunc(msg);
-        }
-        else
-        {
-            ret = 0;
-        }
-    }
-    else
-    {
-        ret = 0;
-    }
-
-    return ret;
-}
-
-static u8 free_message(u16 primType, u8 *data)
-{
-    CsrMsgConvPrimEntry *ptr;
-    u8 ret;
-
-    ptr = CsrMsgConvFind(primType);
-
-    if (ptr)
-    {
-        const CsrMsgConvMsgEntry *cv;
-        u16 msgId = *(u16 *) data;
-
-        cv = find_msg_converter(ptr, msgId);
-        if (cv)
-        {
-            cv->freeFunc(data);
-            ret = TRUE;
-        }
-        else
-        {
-            ret = FALSE;
-        }
-    }
-    else
-    {
-        ret = FALSE;
-    }
-
-    return ret;
-}
-
-static u8 *serialize_message(u16 primType,
-    void *msg,
-    size_t *length,
-    u8 *buffer)
-{
-    CsrMsgConvPrimEntry *ptr;
-    u8 *ret;
-
-    ptr = CsrMsgConvFind(primType);
-
-    *length = 0;
-
-    if (ptr)
-    {
-        const CsrMsgConvMsgEntry *cv;
-
-        cv = find_msg_converter(ptr, *(u16 *) msg);
-        if (cv)
-        {
-            ret = cv->serFunc(buffer, length, msg);
-        }
-        else
-        {
-            ret = NULL;
-        }
-    }
-    else
-    {
-        ret = NULL;
-    }
-
-    return ret;
-}
-
-size_t CsrMsgConvSizeof(u16 primType, void *msg)
-{
-    return sizeof_message(primType, msg);
-}
-
-u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg)
-{
-    if (converter)
-    {
-        size_t serializedLength;
-        u8 *bufSerialized;
-        u8 *bufOffset = &buffer[*offset];
-        bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset);
-        *offset += serializedLength;
-        return bufSerialized;
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-/* Insert profile converter at head of converter list. */
-void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce)
-{
-    CsrMsgConvPrimEntry *pc;
-    pc = CsrMsgConvFind(primType);
-
-    if (pc)
-    {
-        /* Already registered. Do nothing */
-    }
-    else
-    {
-        pc = kmalloc(sizeof(*pc), GFP_KERNEL);
-        pc->primType = primType;
-        pc->conv = ce;
-        pc->lookupFunc = NULL;
-        pc->next = converter->profile_converters;
-        converter->profile_converters = pc;
-    }
-}
-EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
-
-CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType)
-{
-    CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
-    if (ptr)
-    {
-        return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
-    }
-    return NULL;
-}
-EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
-
-CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg)
-{
-    CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
-    if (ptr && msg)
-    {
-        u16 msgType = *((u16 *) msg);
-        return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
-    }
-    return NULL;
-}
-
-void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc)
-{
-    CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
-    if (ptr)
-    {
-        ptr->lookupFunc = lookupFunc;
-    }
-}
-EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
-
-CsrMsgConvEntry *CsrMsgConvInit(void)
-{
-    if (!converter)
-    {
-        converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);
-
-        converter->profile_converters = NULL;
-        converter->free_message = free_message;
-        converter->sizeof_message = sizeof_message;
-        converter->serialize_message = serialize_message;
-        converter->deserialize_data = deserialize_data;
-    }
-
-    return converter;
-}
-EXPORT_SYMBOL_GPL(CsrMsgConvInit);
diff --git a/drivers/staging/csr/csr_msgconv.h b/drivers/staging/csr/csr_msgconv.h
deleted file mode 100644 (file)
index 7e4dd38..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef CSR_MSGCONV_H__
-#define CSR_MSGCONV_H__
-
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include <linux/types.h>
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-
-typedef size_t (CsrMsgSizeofFunc)(void *msg);
-typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
-typedef void (CsrMsgFreeFunc)(void *msg);
-typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
-
-/* Converter entry for one message type */
-typedef struct CsrMsgConvMsgEntry
-{
-    u16              msgType;
-    CsrMsgSizeofFunc      *sizeofFunc;
-    CsrMsgSerializeFunc   *serFunc;
-    CsrMsgDeserializeFunc *deserFunc;
-    CsrMsgFreeFunc        *freeFunc;
-} CsrMsgConvMsgEntry;
-
-/* Optional lookup function */
-typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
-
-/* All converter entries for one specific primitive */
-typedef struct CsrMsgConvPrimEntry
-{
-    u16                   primType;
-    const CsrMsgConvMsgEntry   *conv;
-    CsrMsgCustomLookupFunc     *lookupFunc;
-    struct CsrMsgConvPrimEntry *next;
-} CsrMsgConvPrimEntry;
-
-typedef struct
-{
-    CsrMsgConvPrimEntry *profile_converters;
-    void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
-    u8 (*free_message)(u16 primType, u8 *data);
-    size_t (*sizeof_message)(u16 primType, void *msg);
-    u8 *(*serialize_message)(u16 primType, void *msg,
-                                   size_t * length,
-                                   u8 * buffer);
-} CsrMsgConvEntry;
-
-size_t CsrMsgConvSizeof(u16 primType, void *msg);
-u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
-void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
-void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
-CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
-CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
-CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
-CsrMsgConvEntry *CsrMsgConvInit(void);
-
-/* Prototypes for primitive type serializers */
-void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
-void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
-void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
-void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
-void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
-
-void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
-void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
-void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
-void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
-void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
-
-#endif
diff --git a/drivers/staging/csr/csr_prim_defs.h b/drivers/staging/csr/csr_prim_defs.h
deleted file mode 100644 (file)
index 81a1eaa..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef CSR_PRIM_DEFS_H__
-#define CSR_PRIM_DEFS_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/************************************************************************************
- * Segmentation of primitives in upstream and downstream segment
- ************************************************************************************/
-typedef u16 CsrPrim;
-#define CSR_PRIM_UPSTREAM                   ((CsrPrim) (0x8000))
-
-/************************************************************************************
- * Primitive definitions for Synergy framework
- ************************************************************************************/
-#define CSR_SYNERGY_EVENT_CLASS_BASE        ((u16) (0x0600))
-
-#define CSR_HCI_PRIM                        ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_BCCMD_PRIM                      ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_HQ_PRIM                         ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_VM_PRIM                         ((u16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_TM_BLUECORE_PRIM                ((u16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_FP_PRIM                         ((u16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_IP_SOCKET_PRIM                  ((u16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_IP_ETHER_PRIM                   ((u16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_IP_IFCONFIG_PRIM                ((u16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_IP_INTERNAL_PRIM                ((u16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_FSAL_PRIM                       ((u16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_DATA_STORE_PRIM                 ((u16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_AM_PRIM                         ((u16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_TLS_PRIM                        ((u16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_DHCP_SERVER_PRIM                ((u16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_TFTP_PRIM                       ((u16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_DSPM_PRIM                       ((u16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE))
-#define CSR_TLS_INTERNAL_PRIM               ((u16) (0x0011 | CSR_SYNERGY_EVENT_CLASS_BASE))
-
-#define NUMBER_OF_CSR_FW_EVENTS             (CSR_DSPM_PRIM - CSR_SYNERGY_EVENT_CLASS_BASE + 1)
-
-#define CSR_SYNERGY_EVENT_CLASS_MISC_BASE   ((u16) (0x06A0))
-
-#define CSR_UI_PRIM                         ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
-#define CSR_APP_PRIM                        ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
-#define CSR_SDIO_PROBE_PRIM                 ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
-
-#define NUMBER_OF_CSR_FW_MISC_EVENTS        (CSR_SDIO_PROBE_PRIM - CSR_SYNERGY_EVENT_CLASS_MISC_BASE + 1)
-
-#define CSR_ENV_PRIM                        ((u16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
-
-#endif /* CSR_PRIM_DEFS_H__ */
diff --git a/drivers/staging/csr/csr_result.h b/drivers/staging/csr/csr_result.h
deleted file mode 100644 (file)
index cbb607d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef CSR_RESULT_H__
-#define CSR_RESULT_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-typedef u16 CsrResult;
-#define CSR_RESULT_SUCCESS  ((CsrResult) 0x0000)
-#define CSR_RESULT_FAILURE  ((CsrResult) 0xFFFF)
-
-#endif
diff --git a/drivers/staging/csr/csr_sched.h b/drivers/staging/csr/csr_sched.h
deleted file mode 100644 (file)
index c7d672c..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef CSR_SCHED_H__
-#define CSR_SCHED_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-#include <linux/types.h>
-#include "csr_time.h"
-
-/* An identifier issued by the scheduler. */
-typedef u32 CsrSchedIdentifier;
-
-/* A task identifier */
-typedef u16 CsrSchedTaskId;
-
-/* A queue identifier */
-typedef u16 CsrSchedQid;
-
-/* A message identifier */
-typedef CsrSchedIdentifier CsrSchedMsgId;
-
-/* A timer event identifier */
-typedef CsrSchedIdentifier CsrSchedTid;
-#define CSR_SCHED_TID_INVALID     ((CsrSchedTid) 0)
-
-/* Time constants. */
-#define CSR_SCHED_TIME_MAX                (0xFFFFFFFF)
-#define CSR_SCHED_MILLISECOND             (1000)
-#define CSR_SCHED_SECOND                  (1000 * CSR_SCHED_MILLISECOND)
-#define CSR_SCHED_MINUTE                  (60 * CSR_SCHED_SECOND)
-
-/* Queue and primitive that identifies the environment */
-#define CSR_SCHED_TASK_ID        0xFFFF
-#define CSR_SCHED_PRIM                   (CSR_SCHED_TASK_ID)
-#define CSR_SCHED_EXCLUDED_MODULE_QUEUE      0xFFFF
-
-/*
- * Background interrupt definitions
- */
-typedef u16 CsrSchedBgint;
-#define CSR_SCHED_BGINT_INVALID ((CsrSchedBgint) 0xFFFF)
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSchedMessagePut
- *
- *  DESCRIPTION
- *      Sends a message consisting of the integer "mi" and the void * pointer
- *      "mv" to the message queue "q".
- *
- *      "mi" and "mv" are neither inspected nor changed by the scheduler - the
- *      task that owns "q" is expected to make sense of the values. "mv" may
- *      be null.
- *
- *  NOTE
- *      If "mv" is not null then it will typically be a chunk of kmalloc()ed
- *      memory, though there is no need for it to be so. Tasks should normally
- *      obey the convention that when a message built with kmalloc()ed memory
- *      is given to CsrSchedMessagePut() then ownership of the memory is ceded to the
- *      scheduler - and eventually to the recipient task. I.e., the receiver of
- *      the message will be expected to kfree() the message storage.
- *
- *  RETURNS
- *      void.
- *
- *----------------------------------------------------------------------------*/
-#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
-void CsrSchedMessagePutStringLog(CsrSchedQid q,
-    u16 mi,
-    void *mv,
-    u32 line,
-    const char *file);
-#define CsrSchedMessagePut(q, mi, mv) CsrSchedMessagePutStringLog((q), (mi), (mv), __LINE__, __FILE__)
-#else
-void CsrSchedMessagePut(CsrSchedQid q,
-    u16 mi,
-    void *mv);
-#endif
-
-#endif
diff --git a/drivers/staging/csr/csr_sdio.h b/drivers/staging/csr/csr_sdio.h
deleted file mode 100644 (file)
index 0971d13..0000000
+++ /dev/null
@@ -1,723 +0,0 @@
-#ifndef CSR_SDIO_H__
-#define CSR_SDIO_H__
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include "csr_result.h"
-
-/* Result Codes */
-#define CSR_SDIO_RESULT_INVALID_VALUE   ((CsrResult) 1) /* Invalid argument value */
-#define CSR_SDIO_RESULT_NO_DEVICE       ((CsrResult) 2) /* The specified device is no longer present */
-#define CSR_SDIO_RESULT_CRC_ERROR       ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
-#define CSR_SDIO_RESULT_TIMEOUT         ((CsrResult) 4) /* No command response or data received from device, or function enable/disable did not succeed within timeout period */
-#define CSR_SDIO_RESULT_NOT_RESET       ((CsrResult) 5) /* The device was not reset */
-
-/* Features (for use in features member of CsrSdioFunction) */
-#define CSR_SDIO_FEATURE_BYTE_MODE                   0x00000001 /* Transfer sizes do not have to be a multiple of block size */
-#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED    0x00000002 /* Bulk operations require DMA friendly memory */
-
-/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
-#define CSR_SDIO_ANY_MANF_ID        0xFFFF
-#define CSR_SDIO_ANY_CARD_ID        0xFFFF
-#define CSR_SDIO_ANY_SDIO_FUNCTION  0xFF
-#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunctionId
- *
- *  DESCRIPTION
- *      This structure describes one or more functions of a device, based on
- *      four qualitative measures. The CsrSdioFunctionId wildcard defines can be
- *      used for making the CsrSdioFunctionId match more than one function.
- *
- *  MEMBERS
- *      manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
- *      cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
- *      sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
- *      sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
- *
- *----------------------------------------------------------------------------*/
-typedef struct
-{
-    u16 manfId;       /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
-    u16 cardId;       /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
-    u8  sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
-    u8  sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
-} CsrSdioFunctionId;
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunction
- *
- *  DESCRIPTION
- *      This structure represents a single function on a device.
- *
- *  MEMBERS
- *      sdioId - A CsrSdioFunctionId describing this particular function. The
- *               subfield shall not contain any CsrSdioFunctionId wildcards. The
- *               subfields shall describe the specific single function
- *               represented by this structure.
- *      blockSize - Actual configured block size, or 0 if unconfigured.
- *      features - Bit mask with any of CSR_SDIO_FEATURE_* set.
- *      device - Handle of device containing the function. If two functions have
- *               the same device handle, they reside on the same device.
- *      driverData - For use by the Function Driver. The SDIO Driver shall not
- *                   attempt to dereference the pointer.
- *      priv - For use by the SDIO Driver. The Function Driver shall not attempt
- *             to dereference the pointer.
- *
- *
- *----------------------------------------------------------------------------*/
-typedef struct
-{
-    CsrSdioFunctionId sdioId;
-    u16         blockSize; /* Actual configured block size, or 0 if unconfigured */
-    u32         features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
-    void             *device; /* Handle of device containing the function */
-    void             *driverData; /* For use by the Function Driver */
-    void             *priv; /* For use by the SDIO Driver */
-} CsrSdioFunction;
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioInsertedCallback, CsrSdioRemovedCallback
- *
- *  DESCRIPTION
- *      CsrSdioInsertedCallback is called when a function becomes available to
- *      a registered Function Driver that supports the function.
- *      CsrSdioRemovedCallback is called when a function is no longer available
- *      to a Function Driver, either because the device has been removed, or the
- *      Function Driver has been unregistered.
- *
- *      NOTE: These functions are implemented by the Function Driver, and are
- *            passed as function pointers in the CsrSdioFunctionDriver struct.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *
- *----------------------------------------------------------------------------*/
-typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
-typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
- *
- *  DESCRIPTION
- *      CsrSdioInterruptCallback is called when an interrupt occurs on the
- *      the device associated with the specified function.
- *
- *      NOTE: These functions are implemented by the Function Driver, and are
- *            passed as function pointers in the CsrSdioFunctionDriver struct.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *
- *  RETURNS (only CsrSdioInterruptCallback)
- *      A pointer to a CsrSdioInterruptDsrCallback function.
- *
- *----------------------------------------------------------------------------*/
-typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
-typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioSuspendCallback, CsrSdioResumeCallback
- *
- *  DESCRIPTION
- *      CsrSdioSuspendCallback is called when the system is preparing to go
- *      into a suspended state. CsrSdioResumeCallback is called when the system
- *      has entered an active state again.
- *
- *      NOTE: These functions are implemented by the Function Driver, and are
- *            passed as function pointers in the CsrSdioFunctionDriver struct.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *
- *----------------------------------------------------------------------------*/
-typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
-typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
- *
- *  DESCRIPTION
- *      CsrSdioAsyncCallback is called when an asynchronous operation completes.
- *
- *      NOTE: These functions are implemented by the Function Driver, and are
- *            passed as function pointers in the function calls that initiate
- *            the operation.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      result - The result of the operation that completed. See the description
- *               of the initiating function for possible result values.
- *
- *  RETURNS (only CsrSdioAsyncCallback)
- *      A pointer to a CsrSdioAsyncDsrCallback function.
- *
- *----------------------------------------------------------------------------*/
-typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
-typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunctionDriver
- *
- *  DESCRIPTION
- *      Structure representing a Function Driver.
- *
- *  MEMBERS
- *      inserted - Callback, see description of CsrSdioInsertedCallback.
- *      removed - Callback, see description of CsrSdioRemovedCallback.
- *      intr - Callback, see description of CsrSdioInterruptCallback.
- *      suspend - Callback, see description of CsrSdioSuspendCallback.
- *      resume - Callback, see description of CsrSdioResumeCallback.
- *      ids - Array of CsrSdioFunctionId describing one or more functions that
- *            are supported by the Function Driver.
- *      idsCount - Length of the ids array.
- *      priv - For use by the SDIO Driver. The Function Driver may initialise
- *             it to NULL, but shall otherwise not access the pointer or attempt
- *             to dereference it.
- *
- *----------------------------------------------------------------------------*/
-typedef struct
-{
-    CsrSdioInsertedCallback  inserted;
-    CsrSdioRemovedCallback   removed;
-    CsrSdioInterruptCallback intr;
-    CsrSdioSuspendCallback   suspend;
-    CsrSdioResumeCallback    resume;
-    CsrSdioFunctionId       *ids;
-    u8                 idsCount;
-    void                    *priv;          /* For use by the SDIO Driver */
-} CsrSdioFunctionDriver;
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunctionDriverRegister
- *
- *  DESCRIPTION
- *      Register a Function Driver.
- *
- *  PARAMETERS
- *      functionDriver - Pointer to struct describing the Function Driver.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The Function Driver was successfully
- *                           registered.
- *      CSR_RESULT_FAILURE - Unable to register the function driver,
- *                                because of an unspecified/unknown error. The
- *                                Function Driver has not been registered.
- *      CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
- *                                      does not point at a valid Function
- *                                      Driver structure, or some of the members
- *                                      contain invalid entries.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunctionDriverUnregister
- *
- *  DESCRIPTION
- *      Unregister a previously registered Function Driver.
- *
- *  PARAMETERS
- *      functionDriver - pointer to struct describing the Function Driver.
- *
- *----------------------------------------------------------------------------*/
-void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunctionEnable, CsrSdioFunctionDisable
- *
- *  DESCRIPTION
- *      Enable/disable the specified function by setting/clearing the
- *      corresponding bit in the I/O Enable register in function 0, and then
- *      periodically reading the related bit in the I/O Ready register until it
- *      is set/clear, limited by an implementation defined timeout.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
- *                                  related bit in the I/O Enable register is
- *                                  undefined.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
- *                                bit in the I/O ready register was not
- *                                set/cleared within the timeout period.
- *
- *      NOTE: If the SDIO R5 response is available, and either of the
- *            FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
- *            is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
-CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioInterruptEnable, CsrSdioInterruptDisable
- *
- *  DESCRIPTION
- *      Enable/disable the interrupt for the specified function by
- *      setting/clearing the corresponding bit in the INT Enable register in
- *      function 0.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
- *                                  related bit in the INT Enable register is
- *                                  unchanged.
- *      CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
- *                                      enabled/disabled, because it either
- *                                      does not exist or it is not possible to
- *                                      individually enable/disable functions.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device.
- *
- *      NOTE: If the SDIO R5 response is available, and either of the
- *            FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
- *            is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
-CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioInterruptAcknowledge
- *
- *  DESCRIPTION
- *      Acknowledge that a signalled interrupt has been handled. Shall only
- *      be called once, and exactly once for each signalled interrupt to the
- *      corresponding function.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function to which the
- *                 event was signalled.
- *
- *----------------------------------------------------------------------------*/
-void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
- *
- *  DESCRIPTION
- *      Acknowledge that a signalled inserted/removed event has been handled.
- *      Shall only be called once, and exactly once for each signalled event to
- *      the corresponding function.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function to which the
- *                 inserted was signalled.
- *      result (CsrSdioInsertedAcknowledge only)
- *          CSR_RESULT_SUCCESS - The Function Driver has accepted the
- *                                    function, and the function is attached to
- *                                    the Function Driver until the
- *                                    CsrSdioRemovedCallback is called and
- *                                    acknowledged.
- *          CSR_RESULT_FAILURE - Unable to accept the function. The
- *                                    function is not attached to the Function
- *                                    Driver, and it may be passed to another
- *                                    Function Driver which supports the
- *                                    function.
- *
- *----------------------------------------------------------------------------*/
-void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
-void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
- *
- *  DESCRIPTION
- *      Acknowledge that a signalled suspend event has been handled. Shall only
- *      be called once, and exactly once for each signalled event to the
- *      corresponding function.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function to which the
- *                 event was signalled.
- *      result
- *          CSR_RESULT_SUCCESS - Successfully suspended/resumed.
- *          CSR_RESULT_FAILURE - Unspecified/unknown error.
- *
- *----------------------------------------------------------------------------*/
-void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
-void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioBlockSizeSet
- *
- *  DESCRIPTION
- *      Set the block size to use for the function. The actual configured block
- *      size shall be the minimum of:
- *          1) Maximum block size supported by the function.
- *          2) Maximum block size supported by the host controller.
- *          3) The block size specified by the blockSize argument.
- *
- *      When this function returns, the actual configured block size is
- *      available in the blockSize member of the function struct.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      blockSize - Block size to use for the function. Valid range is 1 to
- *                  2048.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The block size register on the chip
- *                                was updated.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The configured block
- *                                  size is undefined.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device.
- *
- *      NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
- *            bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
- *            If the ERROR bit is set (but not FUNCTION_NUMBER),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *      NOTE: Setting the block size requires two individual operations. The
- *            implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
- *            response for the first operation, as the partially configured
- *            block size may be out of range, even if the final block size
- *            (after the second operation) is in the valid range.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioMaxBusClockFrequencySet
- *
- *  DESCRIPTION
- *      Set the maximum clock frequency to use for the device associated with
- *      the specified function. The actual configured clock frequency for the
- *      device shall be the minimum of:
- *          1) Maximum clock frequency supported by the device.
- *          2) Maximum clock frequency supported by the host controller.
- *          3) Maximum clock frequency specified for any function on the same
- *             device.
- *
- *      If the clock frequency exceeds 25MHz, it is the responsibility of the
- *      SDIO driver to enable high speed mode on the device, using the standard
- *      defined procedure, before increasing the frequency beyond the limit.
- *
- *      Note that the clock frequency configured affects all functions on the
- *      same device.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      maxFrequency - The maximum clock frequency for the function in Hertz.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The maximum clock frequency was successfully
- *                                set for the function.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *
- *      NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
- *            bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
- *            If the ERROR bit is set (but not FUNCTION_NUMBER),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
- *
- *  DESCRIPTION
- *      Read/write an 8bit value from/to the specified register address.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      address - Register address within the function.
- *      data - The data to read/write.
- *      callback - The function to call on operation completion.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The data was successfully read/written.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device.
- *
- *      NOTE: If the SDIO R5 response is available, and either of the
- *            FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
- *            is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *      NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
- *            immediately, and the supplied callback function is called when the
- *            operation is complete. The result value is given as an argument to
- *            the callback function.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
-CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
-void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
-void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
- *
- *  DESCRIPTION
- *      Read/write a 16bit value from/to the specified register address.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      address - Register address within the function.
- *      data - The data to read/write.
- *      callback - The function to call on operation completion.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The data was successfully read/written.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
- *                                  partially read/written.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device.
- *
- *      NOTE: If the SDIO R5 response is available, and either of the
- *            FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
- *            is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *      NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
- *            immediately, and the supplied callback function is called when the
- *            operation is complete. The result value is given as an argument to
- *            the callback function.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
-CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
-void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
-void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
- *      CsrSdioF0Write8Async
- *
- *  DESCRIPTION
- *      Read/write an 8bit value from/to the specified register address in
- *      function 0.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      address - Register address within the function.
- *      data - The data to read/write.
- *      callback - The function to call on operation completion.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The data was successfully read/written.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device.
- *
- *      NOTE: If the SDIO R5 response is available, and either of the
- *            FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
- *            is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *      NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
- *            immediately, and the supplied callback function is called when the
- *            operation is complete. The result value is given as an argument to
- *            the callback function.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
-CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
-void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
-void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
- *
- *  DESCRIPTION
- *      Read/write a specified number of bytes from/to the specified register
- *      address.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *      address - Register address within the function.
- *      data - The data to read/write.
- *      length - Number of byte to read/write.
- *      callback - The function to call on operation completion.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - The data was successfully read/written.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
- *                                  partially read/written.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device.
- *
- *      NOTE: If the SDIO R5 response is available, and either of the
- *            FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
- *            is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
- *            CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
- *            COM_CRC_ERROR bits shall be ignored.
- *
- *            If the CSPI response is available, and any of the
- *            FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
- *            CSR_SDIO_RESULT_INVALID_VALUE will be returned.
- *
- *      NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
- *            immediately, and the supplied callback function is called when the
- *            operation is complete. The result value is given as an argument to
- *            the callback function.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
-CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
-void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
-void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioPowerOn, CsrSdioPowerOff
- *
- *  DESCRIPTION
- *      Power on/off the device.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function that resides on
- *                 the device to power on/off.
- *
- *  RETURNS (only CsrSdioPowerOn)
- *      CSR_RESULT_SUCCESS - Power was successfully reapplied and the device
- *                                has been reinitialised.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device during
- *                                reinitialisation.
- *      CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
- *                                  CsrSdioPowerOff call. The state of the
- *                                  device is unchanged.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
-void CsrSdioPowerOff(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioHardReset
- *
- *  DESCRIPTION
- *      Perform a hardware reset of the device.
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function that resides on
- *                 the device to hard reset.
- *
- *  RETURNS
- *      CSR_RESULT_SUCCESS - Reset was successfully performed and the device
- *                                has been reinitialised.
- *      CSR_RESULT_FAILURE - Unspecified/unknown error.
- *      CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
- *      CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
- *      CSR_SDIO_RESULT_TIMEOUT - No response from the device during
- *                                reinitialisation.
- *      CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
- *                                  supported. The state of the device is
- *                                  unchanged.
- *
- *----------------------------------------------------------------------------*/
-CsrResult CsrSdioHardReset(CsrSdioFunction *function);
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrSdioFunctionActive, CsrSdioFunctionIdle
- *
- *  DESCRIPTION
- *
- *  PARAMETERS
- *      function - Pointer to struct representing the function.
- *
- *----------------------------------------------------------------------------*/
-void CsrSdioFunctionActive(CsrSdioFunction *function);
-void CsrSdioFunctionIdle(CsrSdioFunction *function);
-
-#endif
diff --git a/drivers/staging/csr/csr_serialize_primitive_types.c b/drivers/staging/csr/csr_serialize_primitive_types.c
deleted file mode 100644 (file)
index 9713b9a..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include "csr_prim_defs.h"
-#include "csr_msgconv.h"
-#include "csr_macro.h"
-
-void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset)
-{
-    *value = buffer[*offset];
-    *offset += sizeof(*value);
-}
-EXPORT_SYMBOL_GPL(CsrUint8Des);
-
-void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset)
-{
-    *value = (buffer[*offset + 0] << 0) |
-             (buffer[*offset + 1] << 8);
-    *offset += sizeof(*value);
-}
-EXPORT_SYMBOL_GPL(CsrUint16Des);
-
-void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset)
-{
-    *value = (buffer[*offset + 0] << 0) |
-             (buffer[*offset + 1] << 8) |
-             (buffer[*offset + 2] << 16) |
-             (buffer[*offset + 3] << 24);
-    *offset += sizeof(*value);
-}
-EXPORT_SYMBOL_GPL(CsrUint32Des);
-
-void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length)
-{
-    memcpy(value, &buffer[*offset], length);
-    *offset += length;
-}
-EXPORT_SYMBOL_GPL(CsrMemCpyDes);
-
-void CsrCharStringDes(char **value, u8 *buffer, size_t *offset)
-{
-    *value = kstrdup((char *) &buffer[*offset], GFP_KERNEL);
-    *offset += strlen(*value) + 1;
-}
-EXPORT_SYMBOL_GPL(CsrCharStringDes);
-
-void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value)
-{
-    buffer[*offset] = value;
-    *offset += sizeof(value);
-}
-EXPORT_SYMBOL_GPL(CsrUint8Ser);
-
-void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value)
-{
-    buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
-    buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
-    *offset += sizeof(value);
-}
-EXPORT_SYMBOL_GPL(CsrUint16Ser);
-
-void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value)
-{
-    buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
-    buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
-    buffer[*offset + 2] = (u8) ((value >> 16) & 0xFF);
-    buffer[*offset + 3] = (u8) ((value >> 24) & 0xFF);
-    *offset += sizeof(value);
-}
-EXPORT_SYMBOL_GPL(CsrUint32Ser);
-
-void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length)
-{
-    memcpy(&buffer[*offset], value, length);
-    *offset += length;
-}
-EXPORT_SYMBOL_GPL(CsrMemCpySer);
-
-void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value)
-{
-    if (value)
-    {
-        strcpy(((char *) &buffer[*offset]), value);
-        *offset += strlen(value) + 1;
-    }
-    else
-    {
-        CsrUint8Ser(buffer, offset, 0);
-    }
-}
-EXPORT_SYMBOL_GPL(CsrCharStringSer);
diff --git a/drivers/staging/csr/csr_time.c b/drivers/staging/csr/csr_time.c
deleted file mode 100644 (file)
index 01179e4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2010
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <linux/module.h>
-
-#include "csr_time.h"
-
-u32 CsrTimeGet(u32 *high)
-{
-       struct timespec ts;
-       u64 time;
-       u32 low;
-
-       ts = current_kernel_time();
-       time = (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
-
-       if (high != NULL)
-               *high = (u32) ((time >> 32) & 0xFFFFFFFF);
-
-       low = (u32) (time & 0xFFFFFFFF);
-
-       return low;
-}
-EXPORT_SYMBOL_GPL(CsrTimeGet);
diff --git a/drivers/staging/csr/csr_time.h b/drivers/staging/csr/csr_time.h
deleted file mode 100644 (file)
index fc29e8e..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef CSR_TIME_H__
-#define CSR_TIME_H__
-/*****************************************************************************
-
-(c) Cambridge Silicon Radio Limited 2010
-All rights reserved and confidential information of CSR
-
-Refer to LICENSE.txt included with this source for details
-on the license terms.
-
-*****************************************************************************/
-
-#include <linux/types.h>
-
-/*******************************************************************************
-
-NAME
-       CsrTimeGet
-
-DESCRIPTION
-       Returns the current system time in a low and a high part. The low part
-       is expressed in microseconds. The high part is incremented when the low
-       part wraps to provide an extended range.
-
-       The caller may provide a NULL pointer as the high parameter.
-       In this case the function just returns the low part and ignores the
-       high parameter.
-
-       Although the time is expressed in microseconds the actual resolution is
-       platform dependent and can be less. It is recommended that the
-       resolution is at least 10 milliseconds.
-
-PARAMETERS
-       high - Pointer to variable that will receive the high part of the
-              current system time. Passing NULL is valid.
-
-RETURNS
-       Low part of current system time in microseconds.
-
-*******************************************************************************/
-u32 CsrTimeGet(u32 *high);
-
-
-/*------------------------------------------------------------------*/
-/* CsrTime Macros */
-/*------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrTimeAdd
- *
- *  DESCRIPTION
- *      Add two time values. Adding the numbers can overflow the range of a
- *      CsrTime, so the user must be cautious.
- *
- *  RETURNS
- *      CsrTime - the sum of "t1" and "t2".
- *
- *----------------------------------------------------------------------------*/
-#define CsrTimeAdd(t1, t2) ((t1) + (t2))
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrTimeSub
- *
- *  DESCRIPTION
- *      Subtract two time values. Subtracting the numbers can provoke an
- *      underflow, so the user must be cautious.
- *
- *  RETURNS
- *      CsrTime - "t1" - "t2".
- *
- *----------------------------------------------------------------------------*/
-#define CsrTimeSub(t1, t2)    ((s32) (t1) - (s32) (t2))
-
-#endif
diff --git a/drivers/staging/csr/csr_util.c b/drivers/staging/csr/csr_util.c
deleted file mode 100644 (file)
index c3aa9d5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2010
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include <linux/module.h>
-
-MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction");
-MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
-MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/staging/csr/csr_wifi_common.h b/drivers/staging/csr/csr_wifi_common.h
deleted file mode 100644 (file)
index efc43a5..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_COMMON_H__
-#define CSR_WIFI_COMMON_H__
-
-#include <linux/types.h>
-#include "csr_result.h"
-
-/* MAC address */
-typedef struct
-{
-    u8 a[6];
-} CsrWifiMacAddress;
-
-/* IPv4 address */
-typedef struct
-{
-    u8 a[4];
-} CsrWifiIp4Address;
-
-/* IPv6 address */
-typedef struct
-{
-    u8 a[16];
-} CsrWifiIp6Address;
-
-typedef struct
-{
-    u8 ssid[32];
-    u8 length;
-} CsrWifiSsid;
-
-/*******************************************************************************
-
-  DESCRIPTION
-    Result values used on the Wifi Interfaces
-
- VALUES
-    CSR_RESULT_SUCCESS
-                   - The request/procedure succeeded
-    CSR_RESULT_FAILURE
-                   - The request/procedure did not succeed because of an error
-    CSR_WIFI_RESULT_NOT_FOUND
-                   - The request did not succeed because some resource was not
-                     found.
-    CSR_WIFI_RESULT_TIMED_OUT
-                   - The request/procedure did not succeed because of a time out
-    CSR_WIFI_RESULT_CANCELLED
-                   - The request was canceled due to another conflicting
-                     request that was issued before this one was completed
-    CSR_WIFI_RESULT_INVALID_PARAMETER
-                   - The request/procedure did not succeed because it had an
-                     invalid parameter
-    CSR_WIFI_RESULT_NO_ROOM
-                   - The request did not succeed due to a lack of resources,
-                     e.g. out of memory problem.
-    CSR_WIFI_RESULT_UNSUPPORTED
-                   - The request/procedure did not succeed because the feature
-                     is not supported yet
-    CSR_WIFI_RESULT_UNAVAILABLE
-                   - The request cannot be processed at this time
-    CSR_WIFI_RESULT_WIFI_OFF
-                   - The requested action is not available because Wi-Fi is
-                     currently off
-    CSR_WIFI_RESULT_SECURITY_ERROR
-                   - The request/procedure did not succeed because of a security
-                     error
-    CSR_WIFI_RESULT_MIB_SET_FAILURE
-                   - MIB Set Failure: either the MIB OID to be written to does
-                     not exist or the MIB Value is invalid.
-    CSR_WIFI_RESULT_INVALID_INTERFACE_TAG
-                   - The supplied Interface Tag is not valid.
-    CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT
-                   - The new NOA configuration conflicts with the existing NOA configuration
-                     hence not accepted"
-*******************************************************************************/
-#define CSR_WIFI_RESULT_NOT_FOUND                 ((CsrResult) 0x0001)
-#define CSR_WIFI_RESULT_TIMED_OUT                 ((CsrResult) 0x0002)
-#define CSR_WIFI_RESULT_CANCELLED                 ((CsrResult) 0x0003)
-#define CSR_WIFI_RESULT_INVALID_PARAMETER         ((CsrResult) 0x0004)
-#define CSR_WIFI_RESULT_NO_ROOM                   ((CsrResult) 0x0005)
-#define CSR_WIFI_RESULT_UNSUPPORTED               ((CsrResult) 0x0006)
-#define CSR_WIFI_RESULT_UNAVAILABLE               ((CsrResult) 0x0007)
-#define CSR_WIFI_RESULT_WIFI_OFF                  ((CsrResult) 0x0008)
-#define CSR_WIFI_RESULT_SECURITY_ERROR            ((CsrResult) 0x0009)
-#define CSR_WIFI_RESULT_MIB_SET_FAILURE           ((CsrResult) 0x000A)
-#define CSR_WIFI_RESULT_INVALID_INTERFACE_TAG     ((CsrResult) 0x000B)
-#define CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT   ((CsrResult) 0x000C)
-
-#define CSR_WIFI_VERSION       "5.1.0.0"
-
-#endif
-
diff --git a/drivers/staging/csr/csr_wifi_fsm.h b/drivers/staging/csr/csr_wifi_fsm.h
deleted file mode 100644 (file)
index fc5c5aa..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_FSM_H
-#define CSR_WIFI_FSM_H
-
-#include "csr_prim_defs.h"
-#include "csr_log_text.h"
-#include "csr_wifi_fsm_event.h"
-
-/* including this file for CsrWifiInterfaceMode*/
-#include "csr_wifi_common.h"
-
-#define CSR_WIFI_FSM_ENV       (0xFFFF)
-
-/**
- * @brief
- *   Toplevel FSM context data
- *
- * @par Description
- *   Holds ALL FSM static and dynamic data for a FSM
- */
-typedef struct CsrWifiFsmContext CsrWifiFsmContext;
-
-/**
- * @brief
- *   FSM External Wakeup CallbackFunction Pointer
- *
- * @par Description
- *   Defines the external wakeup function for the FSM
- *   to call when an external event is injected into the systen
- *
- * @param[in]    context : External context
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmExternalWakupCallbackPtr)(void *context);
-
-/**
- * @brief
- *   Initialises a top level FSM context
- *
- * @par Description
- *   Initialises the FSM Context to an initial state and allocates
- *   space for "maxProcesses" number of instances
- *
- * @param[in]    osaContext         : OSA context
- * @param[in]    applicationContext : Internal fsm application context
- * @param[in]    externalContext    : External context
- * @param[in]    maxProcesses       : Max processes to allocate room for
- *
- * @return
- *   CsrWifiFsmContext* fsm context
- */
-extern CsrWifiFsmContext* CsrWifiFsmInit(void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId);
-
-/**
- * @brief
- *   Resets the FSM's back to first conditions
- *
- * @par Description
- *   This function is used to free any dynamic resources allocated for the
- *   given context by CsrWifiFsmInit().
- *   The FSM's reset function is called to cleanup any fsm specific memory
- *   The reset function does NOT need to free the fsm data pointer as
- *   CsrWifiFsmShutdown() will do it.
- *   the FSM's init function is call again to reinitialise the FSM context.
- *   CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running.
- *
- * @param[in]    context    : FSM context
- *
- * @return
- *   void
- */
-extern void CsrWifiFsmReset(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   Frees resources allocated by CsrWifiFsmInit
- *
- * @par Description
- *   This function is used to free any dynamic resources allocated for the
- *   given context by CsrWifiFsmInit(), prior to complete termination of
- *   the program.
- *   The FSM's reset function is called to cleanup any fsm specific memory.
- *   The reset function does NOT need to free the fsm data pointer as
- *   CsrWifiFsmShutdown() will do it.
- *   CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running.
- *
- * @param[in]    context       : FSM context
- *
- * @return
- *   void
- */
-extern void CsrWifiFsmShutdown(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   Executes the fsm context
- *
- * @par Description
- *   Executes the FSM context and runs until ALL events in the context are processed.
- *   When no more events are left to process then CsrWifiFsmExecute() returns to a time
- *   specifying when to next call the CsrWifiFsmExecute()
- *   Scheduling, threading, blocking and external event notification are outside
- *   the scope of the FSM and CsrWifiFsmExecute().
- *
- * @param[in]    context  : FSM context
- *
- * @return
- *   u32    Time in ms until next timeout or 0xFFFFFFFF for no timer set
- */
-extern u32 CsrWifiFsmExecute(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   Adds an event to the FSM context's external event queue for processing
- *
- * @par Description
- *   Adds an event to the contexts external queue
- *   This is thread safe and adds an event to the fsm's external event queue.
- *
- * @param[in]    context      : FSM context
- * @param[in]    event        : event to add to the event queue
- * @param[in]    source       : source of the event (this can be a synergy task queue or an fsm instance id)
- * @param[in]    destination  : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
- * @param[in]    id           : event id
- *
- * @return
- *   void
- */
-extern void CsrWifiFsmSendEventExternal(CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id);
-
-/**
- * @brief
- *   Adds an Alien event to the FSM context's external event queue for processing
- *
- * @par Description
- *   Adds an event to the contexts external queue
- *   This is thread safe and adds an event to the fsm's external event queue.
- *
- * @param[in]    context      : FSM context
- * @param[in]    event        : event to add to the event queue
- * @param[in]    source       : source of the event (this can be a synergy task queue or an fsm instance id)
- * @param[in]    destination  : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
- * @param[in]    id           : event id
- */
-#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id) \
-    { \
-        CsrWifiFsmAlienEvent *_evt = kmalloc(sizeof(CsrWifiFsmAlienEvent), GFP_KERNEL); \
-        _evt->alienEvent = _alienEvent; \
-        CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \
-    }
-
-
-/**
- * @brief
- *   Current time of day in ms
- *
- * @param[in]    context   : FSM context
- *
- * @return
- *   u32 32 bit ms tick
- */
-extern u32 CsrWifiFsmGetTimeOfDayMs(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   Gets the time until the next FSM timer expiry
- *
- * @par Description
- *   Returns the next timeout time or 0 if no timers are set.
- *
- * @param[in]    context    : FSM context
- *
- * @return
- *   u32    Time in ms until next timeout or 0xFFFFFFFF for no timer set
- */
-extern u32 CsrWifiFsmGetNextTimeout(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   Fast forwards the fsm timers by ms Milliseconds
- *
- * @param[in]  context : FSM context
- * @param[in]  ms      : Milliseconds to fast forward by
- *
- * @return
- *   void
- */
-extern void CsrWifiFsmFastForward(CsrWifiFsmContext *context, u16 ms);
-
-/**
- * @brief
- *   shift the current time of day by ms amount
- *
- * @par Description
- *   useful to speed up tests where time needs to pass
- *
- * @param[in]    context  : FSM context
- * @param[in]    ms       : ms to adjust time by
- *
- * @return
- *   void
- */
-extern void CsrWifiFsmTestAdvanceTime(CsrWifiFsmContext *context, u32 ms);
-
-/**
- * @brief
- *    Check if the fsm has events to process
- *
- * @param[in]    context    : FSM context
- *
- * @return
- *   u8 returns TRUE if there are events for the FSM to process
- */
-extern u8 CsrWifiFsmHasEvents(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   function that installs the contexts wakeup function
- *
- * @param[in]    context    : FSM context
- * @param[in]    callback   : Callback function pointer
- *
- * @return
- *   void
- */
-extern void CsrWifiFsmInstallWakeupCallback(CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback);
-
-#endif /* CSR_WIFI_FSM_H */
-
diff --git a/drivers/staging/csr/csr_wifi_fsm_event.h b/drivers/staging/csr/csr_wifi_fsm_event.h
deleted file mode 100644 (file)
index 0690ca9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_FSM_EVENT_H
-#define CSR_WIFI_FSM_EVENT_H
-
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-
-/**
- * @brief
- *   FSM event header.
- *
- * @par Description
- *   All events MUST have this struct as the FIRST member.
- *   The next member is used internally for linked lists
- */
-typedef struct CsrWifiFsmEvent
-{
-    CsrPrim     type;
-    u16   primtype;
-    CsrSchedQid destination;
-    CsrSchedQid source;
-
-    /* Private pointer to allow an optimal Event list */
-    /* NOTE: Ignore this pointer.
-     *       Do not waste code initializing OR freeing it.
-     *       The pointer is used internally in the CsrWifiFsm code
-     *       to avoid a second malloc when queuing events.
-     */
-    struct CsrWifiFsmEvent *next;
-} CsrWifiFsmEvent;
-
-#endif /* CSR_WIFI_FSM_EVENT_H */
-
diff --git a/drivers/staging/csr/csr_wifi_fsm_types.h b/drivers/staging/csr/csr_wifi_fsm_types.h
deleted file mode 100644 (file)
index d21c60a..0000000
+++ /dev/null
@@ -1,430 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_FSM_TYPES_H
-#define CSR_WIFI_FSM_TYPES_H
-
-#include <linux/types.h>
-#include "csr_macro.h"
-#include "csr_sched.h"
-
-#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
-#include "csr_framework_ext.h"
-#endif
-
-#include "csr_wifi_fsm.h"
-
-#define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10
-
-/**
- * @brief
- *   FSM event list header.
- *
- * @par Description
- *   Singly linked list of events.
- */
-typedef struct CsrWifiFsmEventList
-{
-    CsrWifiFsmEvent *first;
-    CsrWifiFsmEvent *last;
-} CsrWifiFsmEventList;
-
-
-/**
- * @brief
- *   FSM timer id.
- *
- * @par Description
- *   Composite Id made up of the type, dest and a unique id so
- *   CsrWifiFsmRemoveTimer knows where to look when removing the timer
- */
-typedef struct CsrWifiFsmTimerId
-{
-    CsrPrim     type;
-    u16   primtype;
-    CsrSchedQid destination;
-    u16   uniqueid;
-} CsrWifiFsmTimerId;
-
-/**
- * @brief
- *   FSM timer header.
- *
- * @par Description
- *   All timer MUST have this struct as the FIRST member.
- *   The first members of the structure MUST remain compatable
- *   with the CsrWifiFsmEvent so that timers are just specialised events
- */
-typedef struct CsrWifiFsmTimer
-{
-    CsrPrim     type;
-    u16   primtype;
-    CsrSchedQid destination;
-    CsrSchedQid source;
-
-    /* Private pointer to allow an optimal Event list */
-    struct CsrWifiFsmTimer *next;
-
-    CsrWifiFsmTimerId timerid;
-    u32         timeoutTimeMs;
-} CsrWifiFsmTimer;
-
-
-/**
- * @brief
- *   Fsm Alien Event
- *
- * @par Description
- *   Allows the wrapping of alien events that do not use CsrWifiFsmEvent
- *   as the first member of the Event struct
- */
-typedef struct
-{
-    CsrWifiFsmEvent event;
-    void           *alienEvent;
-} CsrWifiFsmAlienEvent;
-
-
-/**
- * @brief
- *   FSM timer list header.
- *
- * @par Description
- *   Singly linked list of timers.
- */
-typedef struct CsrWifiFsmTimerList
-{
-    CsrWifiFsmTimer *first;
-    CsrWifiFsmTimer *last;
-    u16        nexttimerid;
-} CsrWifiFsmTimerList;
-
-/**
- * @brief
- *   Process Entry Function Pointer
- *
- * @par Description
- *   Defines the entry function for a processes.
- *   Called at process initialisation.
- *
- * @param[in]    context : FSM context
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmProcEntryFnPtr)(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   Process Transition Function Pointer
- *
- * @par Description
- *   Defines a transition function for a processes.
- *   Called when an event causes a transition on a process
- *
- * @param[in]    CsrWifiFsmContext* : FSM context
- * @param[in]    void* : FSM data (can be NULL)
- * @param[in]    const CsrWifiFsmEvent*  : event to process
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmTransitionFnPtr)(CsrWifiFsmContext *context, void *fsmData, const CsrWifiFsmEvent *event);
-
-/**
- * @brief
- *   Process reset/shutdown Function Pointer
- *
- * @par Description
- *   Defines the reset/shutdown function for a processes.
- *   Called to reset or shutdown an fsm.
- *
- * @param[in]    context      : FSM context
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmProcResetFnPtr)(CsrWifiFsmContext *context);
-
-/**
- * @brief
- *   FSM Default Destination CallbackFunction Pointer
- *
- * @par Description
- *   Defines the default destination function for the FSM
- *   to call when an event does not have a valid destination.
- *   This
- *
- * @param[in]    context : External context
- *
- * @return
- *   u16 a valid destination OR CSR_WIFI_FSM_ENV
- */
-typedef u16 (*CsrWifiFsmDestLookupCallbackPtr)(void *context, const CsrWifiFsmEvent *event);
-
-
-#ifdef CSR_WIFI_FSM_DUMP_ENABLE
-/**
- * @brief
- *   Trace Dump Function Pointer
- *
- * @par Description
- *   Called when we want to trace the FSM
- *
- * @param[in]    context : FSM context
- * @param[in]    id      : fsm id
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData);
-#endif
-
-/**
- * @brief
- *   Event ID to transition function entry
- *
- * @par Description
- *   Event ID to Transition Entry in a state table.
- */
-typedef struct
-{
-    u32                 eventid;
-    CsrWifiFsmTransitionFnPtr transition;
-#ifdef CSR_LOG_ENABLE
-    const char *transitionName;
-#endif
-} CsrWifiFsmEventEntry;
-
-/**
- * @brief
- *   Single State's Transition Table
- *
- * @par Description
- *   Stores Data for a single State's event to
- *   transition functions mapping
- */
-typedef struct
-{
-    const u8              numEntries;
-    const u8               saveAll;
-    const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */
-#ifdef CSR_LOG_ENABLE
-    u16            stateNumber;
-    const char *stateName;
-#endif
-} CsrWifiFsmTableEntry;
-
-/**
- * @brief
- *   Process State Transtion table
- *
- * @par Description
- *   Stores Data for a processes State to transition table
- */
-typedef struct
-{
-    u16                   numStates;         /* number of states    */
-    const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix  */
-} CsrWifiFsmTransitionFunctionTable;
-
-/**
- * @brief
- *   Const Process definition
- *
- * @par Description
- *   Constant process specification.
- *   This is ALL the non dynamic data that defines
- *   a process.
- */
-typedef struct
-{
-    const char                    *processName;
-    const u32                         processId;
-    const CsrWifiFsmTransitionFunctionTable transitionTable;
-    const CsrWifiFsmTableEntry              unhandledTransitions;
-    const CsrWifiFsmTableEntry              ignoreFunctions;
-    const CsrWifiFsmProcEntryFnPtr          entryFn;
-    const CsrWifiFsmProcResetFnPtr          resetFn;
-#ifdef CSR_WIFI_FSM_DUMP_ENABLE
-    const CsrWifiFsmDumpFnPtr dumpFn;               /* Called to dump fsm specific trace if not NULL */
-#endif
-} CsrWifiFsmProcessStateMachine;
-
-#ifdef CSR_WIFI_FSM_DUMP_ENABLE
-/**
- * @brief
- *   Storage for state transition info
- */
-typedef struct
-{
-    u16                 transitionNumber;
-    CsrWifiFsmEvent           event;
-    u16                 fromState;
-    u16                 toState;
-    CsrWifiFsmTransitionFnPtr transitionFn;
-    u16                 transitionCount; /* number consecutive of times this transition was seen */
-#ifdef CSR_LOG_ENABLE
-    const char *transitionName;
-#endif
-} CsrWifiFsmTransitionRecord;
-
-/**
- * @brief
- *   Storage for the last state X transitions
- */
-typedef struct
-{
-    u16                  numTransitions;
-    CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY];
-} CsrWifiFsmTransitionRecords;
-#endif
-
-/**
- * @brief
- *   Dynamic Process data
- *
- * @par Description
- *   Dynamic process data that is used to keep track of the
- *   state and data for a process instance
- */
-typedef struct
-{
-    const CsrWifiFsmProcessStateMachine *fsmInfo;         /* state machine info that is constant regardless of context */
-    u16                            instanceId;      /* Runtime process id */
-    u16                            state;           /* Current state */
-    void                                *params;          /* Instance user data */
-    CsrWifiFsmEventList                  savedEventQueue; /* The saved event queue */
-    struct CsrWifiFsmInstanceEntry      *subFsm;          /* Sub Fsm instance data */
-    struct CsrWifiFsmInstanceEntry      *subFsmCaller;    /* The Fsm instance that created the SubFsm and should be used for callbacks*/
-#ifdef CSR_WIFI_FSM_DUMP_ENABLE
-    CsrWifiFsmTransitionRecords transitionRecords;        /* Last X transitions in the FSM */
-#endif
-} CsrWifiFsmInstanceEntry;
-
-/**
- * @brief
- *   OnCreate Callback Function Pointer
- *
- * @par Description
- *   Called when an fsm is created.
- *
- * @param[in]    extContext : External context
- * @param[in]    instance : FSM instance
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance);
-
-/**
- * @brief
- *   OnTransition Callback Function Pointer
- *
- * @par Description
- *   Called when an event is processed by a fsm
- *
- * @param[in]    extContext : External context
- * @param[in]    eventEntryArray : Entry data
- * @param[in]    event : Event
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event);
-
-/**
- * @brief
- *   OnStateChange Callback Function Pointer
- *
- * @par Description
- *   Called when CsrWifiFsmNextState is called
- *
- * @param[in]    extContext : External context
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate);
-
-/**
- * @brief
- *   OnIgnore,OnError or OnInvalid Callback Function Pointer
- *
- * @par Description
- *   Called when an event is processed by a fsm
- *
- * @param[in]    extContext : External context
- * @param[in]    event : Event
- *
- * @return
- *   void
- */
-typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event);
-
-/**
- * @brief
- *   Toplevel FSM context data
- *
- * @par Description
- *   Holds ALL FSM static and dynamic data for a FSM
- */
-struct CsrWifiFsmContext
-{
-    CsrWifiFsmEventList eventQueue;                           /* The internal event queue                     */
-    CsrWifiFsmEventList externalEventQueue;                   /* The external event queue                     */
-#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
-    CsrMutexHandle externalEventQueueLock;                    /* The external event queue mutex               */
-#endif
-    u32                          timeOffset;            /* Amount to adjust the TimeOfDayMs by          */
-    CsrWifiFsmTimerList                timerQueue;            /* The internal timer queue                     */
-    u8                            useTempSaveList;       /* Should the temp save list be used            */
-    CsrWifiFsmEventList                tempSaveList;          /* The temp save event queue                    */
-    CsrWifiFsmEvent                   *eventForwardedOrSaved; /* The event that was forwarded or Saved        */
-    u16                          maxProcesses;          /* Size of instanceArray                        */
-    u16                          numProcesses;          /* Current number allocated in instanceArray    */
-    CsrWifiFsmInstanceEntry           *instanceArray;         /* Array of processes for this component        */
-    CsrWifiFsmInstanceEntry           *ownerInstance;         /* The Process that owns currentInstance (SubFsm support) */
-    CsrWifiFsmInstanceEntry           *currentInstance;       /* Current Process that is executing            */
-    CsrWifiFsmExternalWakupCallbackPtr externalEventFn;       /* External event Callback                      */
-    CsrWifiFsmOnEventFnPtr             appIgnoreCallback;     /* Application Ignore event Callback            */
-    CsrWifiFsmDestLookupCallbackPtr    appEvtDstCallback;     /* Application Lookup event Destination Function*/
-
-    void            *applicationContext;                      /* Internal fsm application context             */
-    void            *externalContext;                         /* External context (set by the user of the fsm)*/
-    CsrLogTextTaskId loggingTaskId;                           /* Task Id to use in any logging output         */
-
-#ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED
-    CsrSchedTid schedTimerId;                                 /* Scheduler TimerId for use in Scheduler Tasks */
-    u32   schedTimerNexttimeoutMs;                      /* Next timeout time for the current timer      */
-#endif
-
-#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
-#ifdef CSR_WIFI_FSM_TRANSITION_LOCK
-    CsrMutexHandle transitionLock;                     /* Lock when calling transition functions        */
-#endif
-#endif
-
-#ifdef CSR_LOG_ENABLE
-    CsrWifiFsmOnCreateFnPtr      onCreate;             /* Debug Transition Callback                    */
-    CsrWifiFsmOnTransitionFnPtr  onTransition;         /* Debug Transition Callback                    */
-    CsrWifiFsmOnTransitionFnPtr  onUnhandedCallback;   /* Unhanded event Callback                      */
-    CsrWifiFsmOnStateChangeFnPtr onStateChange;        /* Debug State Change Callback                  */
-    CsrWifiFsmOnEventFnPtr       onIgnoreCallback;     /* Ignore event Callback                        */
-    CsrWifiFsmOnEventFnPtr       onSaveCallback;       /* Save event Callback                          */
-    CsrWifiFsmOnEventFnPtr       onErrorCallback;      /* Error event Callback                         */
-    CsrWifiFsmOnEventFnPtr       onInvalidCallback;    /* Invalid event Callback                       */
-#endif
-#ifdef CSR_WIFI_FSM_DUMP_ENABLE
-    u16 masterTransitionNumber;                  /* Increments on every transition              */
-#endif
-};
-
-#endif /* CSR_WIFI_FSM_TYPES_H */
diff --git a/drivers/staging/csr/csr_wifi_hip_card.h b/drivers/staging/csr/csr_wifi_hip_card.h
deleted file mode 100644 (file)
index bd47f60..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- ******************************************************************************
- * FILE : csr_wifi_hip_card.h
- *
- * PURPOSE : Defines abstract interface for hardware specific functions.
- *           Note, this is a different file from one of the same name in the
- *           Windows driver.
- *
- *****************************************************************************
- */
-#ifndef __CARD_H__
-#define __CARD_H__
-
-#include "csr_wifi_hip_card_sdio.h"
-#include "csr_wifi_hip_signals.h"
-#include "csr_wifi_hip_unifi_udi.h"
-
-
-/*****************************************************************************
- * CardEnableInt -
- */
-CsrResult CardEnableInt(card_t *card);
-
-/*****************************************************************************
- * CardGenInt -
- */
-CsrResult CardGenInt(card_t *card);
-
-/*****************************************************************************
- * CardPendingInt -
- */
-CsrResult CardPendingInt(card_t *card, u8 *pintr);
-
-/*****************************************************************************
- * CardDisableInt -
- */
-CsrResult CardDisableInt(card_t *card);
-
-/*****************************************************************************
- * CardClearInt -
- */
-CsrResult CardClearInt(card_t *card);
-
-/*****************************************************************************
- * CardDisable -
- */
-void CardDisable(card_t *card);
-
-/*****************************************************************************
- * CardIntEnabled -
- */
-CsrResult CardIntEnabled(card_t *card, u8 *enabled);
-
-/*****************************************************************************
- * CardGetDataSlotSize
- */
-u16 CardGetDataSlotSize(card_t *card);
-
-/*****************************************************************************
- * CardWriteBulkData -
- */
-CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue);
-
-
-/*****************************************************************************
- * CardClearFromHostDataSlot -
- */
-void CardClearFromHostDataSlot(card_t *card, const s16 aSlotNum);
-
-#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
-/*****************************************************************************
- * CardClearFromHostDataSlotWithoutFreeingBulkData - Clear the data stot
- * without freeing the bulk data
- */
-
-void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 aSlotNum);
-#endif
-
-/*****************************************************************************
- * CardGetFreeFromHostDataSlots -
- */
-u16 CardGetFreeFromHostDataSlots(card_t *card);
-
-u16 CardAreAllFromHostDataSlotsEmpty(card_t *card);
-
-CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which);
-
-CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr);
-
-CsrResult unifi_dl_firmware(card_t *card, void *arg);
-CsrResult unifi_dl_patch(card_t *card, void *arg, u32 boot_ctrl);
-CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode);
-void* unifi_dl_fw_read_start(card_t *card, s8 is_fw);
-
-CsrResult unifi_coredump_handle_request(card_t *card);
-
-CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult);
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-void unifi_debug_log_to_buf(const char *fmt, ...);
-void unifi_debug_string_to_buf(const char *str);
-void unifi_debug_hex_to_buf(const char *buff, u16 length);
-#endif
-
-#endif /* __CARD_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.c b/drivers/staging/csr/csr_wifi_hip_card_sdio.c
deleted file mode 100644 (file)
index d542532..0000000
+++ /dev/null
@@ -1,4001 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- * FILE: csr_wifi_hip_card_sdio.c
- *
- * PURPOSE: Implementation of the Card API for SDIO.
- *
- * NOTES:
- *      CardInit() is called from the SDIO probe callback when a card is
- *      inserted. This performs the basic SDIO initialisation, enabling i/o
- *      etc.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/slab.h>
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "csr_wifi_hip_unifiversion.h"
-#include "csr_wifi_hip_card.h"
-#include "csr_wifi_hip_card_sdio.h"
-#include "csr_wifi_hip_chiphelper.h"
-
-
-/* Time to wait between attempts to read MAILBOX0 */
-#define MAILBOX1_TIMEOUT                10  /* in millisecs */
-#define MAILBOX1_ATTEMPTS               200 /* 2 seconds */
-
-#define MAILBOX2_TIMEOUT                5   /* in millisecs */
-#define MAILBOX2_ATTEMPTS               10  /* 50ms */
-
-#define RESET_SETTLE_DELAY              25  /* in millisecs */
-
-static CsrResult card_init_slots(card_t *card);
-static CsrResult card_hw_init(card_t *card);
-static CsrResult firmware_present_in_flash(card_t *card);
-static void bootstrap_chip_hw(card_t *card);
-static CsrResult unifi_reset_hardware(card_t *card);
-static CsrResult unifi_hip_init(card_t *card);
-static CsrResult card_access_panic(card_t *card);
-static CsrResult unifi_read_chip_version(card_t *card);
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_alloc_card
- *
- *      Allocate and initialise the card context structure.
- *
- *  Arguments:
- *      sdio            Pointer to SDIO context pointer to pass to low
- *                      level i/o functions.
- *      ospriv          Pointer to O/S private struct to pass when calling
- *                      callbacks to the higher level system.
- *
- *  Returns:
- *      Pointer to card struct, which represents the driver context or
- *      NULL if the allocation failed.
- * ---------------------------------------------------------------------------
- */
-card_t* unifi_alloc_card(CsrSdioFunction *sdio, void *ospriv)
-{
-    card_t *card;
-    u32 i;
-
-
-    card = kzalloc(sizeof(card_t), GFP_KERNEL);
-    if (card == NULL)
-    {
-        return NULL;
-    }
-
-    card->sdio_if = sdio;
-    card->ospriv  = ospriv;
-
-    card->unifi_interrupt_seq = 1;
-
-    /* Make these invalid. */
-    card->proc_select = (u32)(-1);
-    card->dmem_page = (u32)(-1);
-    card->pmem_page = (u32)(-1);
-
-    card->bh_reason_host = 0;
-    card->bh_reason_unifi = 0;
-
-    for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
-    {
-        card->tx_q_paused_flag[i] = 0;
-    }
-    card->memory_resources_allocated = 0;
-
-    card->low_power_mode = UNIFI_LOW_POWER_DISABLED;
-    card->periodic_wake_mode = UNIFI_PERIODIC_WAKE_HOST_DISABLED;
-
-    card->host_state = UNIFI_HOST_STATE_AWAKE;
-    card->intmode = CSR_WIFI_INTMODE_DEFAULT;
-
-    /*
-     * Memory resources for buffers are allocated when the chip is initialised
-     * because we need configuration information from the firmware.
-     */
-
-    /*
-     * Initialise wait queues and lists
-     */
-    card->fh_command_queue.q_body = card->fh_command_q_body;
-    card->fh_command_queue.q_length = UNIFI_SOFT_COMMAND_Q_LENGTH;
-
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        card->fh_traffic_queue[i].q_body = card->fh_traffic_q_body[i];
-        card->fh_traffic_queue[i].q_length = UNIFI_SOFT_TRAFFIC_Q_LENGTH;
-    }
-
-
-    /* Initialise mini-coredump pointers in case no coredump buffers
-     * are requested by the OS layer.
-     */
-    card->request_coredump_on_reset = 0;
-    card->dump_next_write = NULL;
-    card->dump_cur_read = NULL;
-    card->dump_buf = NULL;
-
-#ifdef UNIFI_DEBUG
-    /* Determine offset of LSB in pointer for later alignment sanity check.
-     * Synergy integer types have specific widths, which cause compiler
-     * warnings when casting pointer types, e.g. on 64-bit systems.
-     */
-    {
-        u32 val = 0x01234567;
-
-        if (*((u8 *)&val) == 0x01)
-        {
-            card->lsb = sizeof(void *) - 1;     /* BE */
-        }
-        else
-        {
-            card->lsb = 0;                      /* LE */
-        }
-    }
-#endif
-    return card;
-} /* unifi_alloc_card() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_init_card
- *
- *      Reset the hardware and perform HIP initialization
- *
- *  Arguments:
- *      card        Pointer to card struct
- *
- *  Returns:
- *      CsrResult code
- *      CSR_RESULT_SUCCESS if successful
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_init_card(card_t *card, s32 led_mask)
-{
-    CsrResult r;
-
-
-    if (card == NULL)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    r = unifi_init(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    r = unifi_hip_init(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to start host protocol.\n");
-        return r;
-    }
-
-    return CSR_RESULT_SUCCESS;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_init
- *
- *      Init the hardware.
- *
- *  Arguments:
- *      card        Pointer to card struct
- *
- *  Returns:
- *      CsrResult code
- *      CSR_RESULT_SUCCESS if successful
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_init(card_t *card)
-{
-    CsrResult r;
-    CsrResult csrResult;
-
-    if (card == NULL)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    /*
-     * Disable the SDIO interrupts while initialising UniFi.
-     * Re-enable them when f/w is running.
-     */
-    csrResult = CsrSdioInterruptDisable(card->sdio_if);
-    if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-    }
-
-    /*
-     * UniFi's PLL may start with a slow clock (~ 1 MHz) so initially
-     * set the SDIO bus clock to a similar value or SDIO accesses may
-     * fail.
-     */
-    csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-        return r;
-    }
-    card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
-
-    /*
-     * Reset UniFi. Note, this only resets the WLAN function part of the chip,
-     * the SDIO interface is not reset.
-     */
-    unifi_trace(card->ospriv, UDBG1, "Resetting UniFi\n");
-    r = unifi_reset_hardware(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to reset UniFi\n");
-        return r;
-    }
-
-    /* Reset the power save mode, to be active until the MLME-reset is complete */
-    r = unifi_configure_low_power_mode(card,
-                                       UNIFI_LOW_POWER_DISABLED, UNIFI_PERIODIC_WAKE_HOST_DISABLED);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to set power save mode\n");
-        return r;
-    }
-
-    /*
-     * Set initial value of page registers.
-     * The page registers will be maintained by unifi_read...() and
-     * unifi_write...().
-     */
-    card->proc_select = (u32)(-1);
-    card->dmem_page = (u32)(-1);
-    card->pmem_page = (u32)(-1);
-    r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, 0);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
-        return r;
-    }
-    r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, 0);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write PROG_MEM2_PAGE\n");
-        return r;
-    }
-
-    /*
-     * If the driver has reset UniFi due to previous SDIO failure, this may
-     * have been due to a chip watchdog reset. In this case, the driver may
-     * have requested a mini-coredump which needs to be captured now the
-     * SDIO interface is alive.
-     */
-    (void)unifi_coredump_handle_request(card);
-
-    /*
-     * Probe to see if the UniFi has ROM/flash to boot from. CSR6xxx should do.
-     */
-    r = firmware_present_in_flash(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r == CSR_WIFI_HIP_RESULT_NOT_FOUND)
-    {
-        unifi_error(card->ospriv, "No firmware found\n");
-    }
-    else if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Probe for Flash failed\n");
-    }
-
-    return r;
-} /* unifi_init() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_download
- *
- *      Load the firmware.
- *
- *  Arguments:
- *      card        Pointer to card struct
- *      led_mask    Loader LED mask
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success
- *      CsrResult error code on failure.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_download(card_t *card, s32 led_mask)
-{
-    CsrResult r;
-    void *dlpriv;
-
-    if (card == NULL)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    /* Set the loader led mask */
-    card->loader_led_mask = led_mask;
-
-    /* Get the firmware file information */
-    unifi_trace(card->ospriv, UDBG1, "downloading firmware...\n");
-
-    dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
-    if (dlpriv == NULL)
-    {
-        return CSR_WIFI_HIP_RESULT_NOT_FOUND;
-    }
-
-    /* Download the firmware. */
-    r = unifi_dl_firmware(card, dlpriv);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to download firmware\n");
-        return r;
-    }
-
-    /* Free the firmware file information. */
-    unifi_fw_read_stop(card->ospriv, dlpriv);
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_download() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_hip_init
- *
- *      This function performs the f/w initialisation sequence as described
- *      in the Unifi Host Interface Protocol Specification.
- *      It allocates memory for host-side slot data and signal queues.
- *
- *  Arguments:
- *      card        Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or else a CSR error code
- *
- *  Notes:
- *      The firmware must have been downloaded.
- * ---------------------------------------------------------------------------
- */
-static CsrResult unifi_hip_init(card_t *card)
-{
-    CsrResult r;
-    CsrResult csrResult;
-
-    r = card_hw_init(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to establish communication with UniFi\n");
-        return r;
-    }
-#ifdef CSR_PRE_ALLOC_NET_DATA
-    /* if there is any preallocated netdata left from the prev session free it now */
-    prealloc_netdata_free(card);
-#endif
-    /*
-     * Allocate memory for host-side slot data and signal queues.
-     * We need the config info read from the firmware to know how much
-     * memory to allocate.
-     */
-    r = card_init_slots(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Init slots failed: %d\n", r);
-        return r;
-    }
-
-    unifi_trace(card->ospriv, UDBG2, "Sending first UniFi interrupt\n");
-
-    r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    /* Enable the SDIO interrupts now that the f/w is running. */
-    csrResult = CsrSdioInterruptEnable(card->sdio_if);
-    if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-    }
-
-    /* Signal the UniFi to start handling messages */
-    r = CardGenInt(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_hip_init() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  _build_sdio_config_data
- *
- *      Unpack the SDIO configuration information from a buffer read from
- *      UniFi into a host structure.
- *      The data is byte-swapped for a big-endian host if necessary by the
- *      UNPACK... macros.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      cfg_data        Destination structure to unpack into.
- *      cfg_data_buf    Source buffer to read from. This should be the raw
- *                      data read from UniFi.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void _build_sdio_config_data(sdio_config_data_t *cfg_data,
-                                    const u8     *cfg_data_buf)
-{
-    s16 offset = 0;
-
-    cfg_data->version = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->sdio_ctrl_offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->fromhost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->tohost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->num_fromhost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->num_tohost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->num_fromhost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->num_tohost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->data_slot_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->initialised = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->overlay_size = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT32;
-
-    cfg_data->data_slot_round = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->sig_frag_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-    offset += SIZEOF_UINT16;
-
-    cfg_data->tohost_signal_padding = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
-} /* _build_sdio_config_data() */
-
-
-/*
- * - Function ----------------------------------------------------------------
- * card_hw_init()
- *
- *      Perform the initialisation procedure described in the UniFi Host
- *      Interface Protocol document (section 3.3.8) and read the run-time
- *      configuration information from the UniFi. This is stuff like number
- *      of bulk data slots etc.
- *
- *      The card enumeration and SD initialisation has already been done by
- *      the SDIO library, see card_sdio_init().
- *
- *      The initialisation is done when firmware is ready, i.e. this may need
- *      to be called after a f/w download operation.
- *
- *      The initialisation procedure goes like this:
- *       - Wait for UniFi to start-up by polling SHARED_MAILBOX1
- *       - Find the symbol table and look up SLT_SDIO_SLOT_CONFIG
- *       - Read the config structure
- *       - Check the "SDIO initialised" flag, if not zero do a h/w reset and
- *         start again
- *       - Decide the number of bulk data slots to allocate, allocate them and
- *         set "SDIO initialised" flag (and generate an interrupt) to say so.
- *
- * Arguments:
- *      card        Pointer to card struct
- *
- * Returns:
- *      CSR_RESULT_SUCEESS on success,
- *      a CSR error code on failure
- *
- * Notes:
- *      All data in the f/w is stored in a little endian format, without any
- *      padding bytes. Every read from this memory has to be transformed in
- *      host (cpu specific) format, before it is stored in driver's parameters
- *      or/and structures. Athough unifi_card_read16() and unifi_read32() do perform
- *      the conversion internally, unifi_readn() does not.
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_hw_init(card_t *card)
-{
-    u32 slut_address;
-    u16 initialised;
-    u16 finger_print;
-    symbol_t slut;
-    sdio_config_data_t *cfg_data;
-    u8 cfg_data_buf[SDIO_CONFIG_DATA_SIZE];
-    CsrResult r;
-    void *dlpriv;
-    s16 major, minor;
-    s16 search_4slut_again;
-    CsrResult csrResult;
-
-    /*
-     * The device revision from the TPLMID_MANF and TPLMID_CARD fields
-     * of the CIS are available as
-     *   card->sdio_if->pDevice->ManfID
-     *   card->sdio_if->pDevice->AppID
-     */
-
-    /*
-     * Run in a loop so we can patch.
-     */
-    do
-    {
-        /* Reset these each time around the loop. */
-        search_4slut_again = 0;
-        cfg_data = NULL;
-
-        r = card_wait_for_firmware_to_start(card, &slut_address);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Firmware hasn't started\n");
-            return r;
-        }
-        unifi_trace(card->ospriv, UDBG4, "SLUT addr 0x%lX\n", slut_address);
-
-        /*
-         * Firmware has started, but doesn't know full clock configuration yet
-         * as some of the information may be in the MIB. Therefore we set an
-         * initial SDIO clock speed, faster than UNIFI_SDIO_CLOCK_SAFE_HZ, for
-         * the patch download and subsequent firmware initialisation, and
-         * full speed UNIFI_SDIO_CLOCK_MAX_HZ will be set once the f/w tells us
-         * that it is ready.
-         */
-        csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            return r;
-        }
-        card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
-
-        /*
-         * Check the SLUT fingerprint.
-         * The slut_address is a generic pointer so we must use unifi_card_read16().
-         */
-        unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
-        finger_print = 0;
-        r = unifi_card_read16(card, slut_address, &finger_print);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
-            return r;
-        }
-
-        if (finger_print != SLUT_FINGERPRINT)
-        {
-            unifi_error(card->ospriv, "Failed to find Symbol lookup table fingerprint\n");
-            return CSR_RESULT_FAILURE;
-        }
-
-        /* Symbol table starts imedately after the fingerprint */
-        slut_address += 2;
-
-        /* Search the table until either the end marker is found, or the
-         * loading of patch firmware invalidates the current table.
-         */
-        while (!search_4slut_again)
-        {
-            u16 s;
-            u32 l;
-
-            r = unifi_card_read16(card, slut_address, &s);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            slut_address += 2;
-
-            if (s == CSR_SLT_END)
-            {
-                unifi_trace(card->ospriv, UDBG3, "  found CSR_SLT_END\n");
-                break;
-            }
-
-            r = unifi_read32(card, slut_address, &l);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            slut_address += 4;
-
-            slut.id = s;
-            slut.obj = l;
-
-            unifi_trace(card->ospriv, UDBG3, "  found SLUT id %02d.%08lx\n", slut.id, slut.obj);
-            switch (slut.id)
-            {
-                case CSR_SLT_SDIO_SLOT_CONFIG:
-                    cfg_data = &card->config_data;
-                    /*
-                     * unifi_card_readn reads n bytes from the card, where data is stored
-                     * in a little endian format, without any padding bytes. So, we
-                     * can not just pass the cfg_data pointer or use the
-                     * sizeof(sdio_config_data_t) since the structure in the host can
-                     * be big endian formatted or have padding bytes for alignment.
-                     * We use a char buffer to read the data from the card.
-                     */
-                    r = unifi_card_readn(card, slut.obj, cfg_data_buf, SDIO_CONFIG_DATA_SIZE);
-                    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-                    {
-                        return r;
-                    }
-                    if (r != CSR_RESULT_SUCCESS)
-                    {
-                        unifi_error(card->ospriv, "Failed to read config data\n");
-                        return r;
-                    }
-                    /* .. and then we copy the data to the host structure */
-                    _build_sdio_config_data(cfg_data, cfg_data_buf);
-
-                    /* Make sure the from host data slots are what we expect
-                        we reserve 2 for commands and there should be at least
-                        1 left for each access category */
-                    if ((cfg_data->num_fromhost_data_slots < UNIFI_RESERVED_COMMAND_SLOTS)
-                        || (cfg_data->num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS) / UNIFI_NO_OF_TX_QS == 0)
-                    {
-                        unifi_error(card->ospriv, "From host data slots %d\n", cfg_data->num_fromhost_data_slots);
-                        unifi_error(card->ospriv, "need to be (queues * x + 2) (UNIFI_RESERVED_COMMAND_SLOTS for commands)\n");
-                        return CSR_RESULT_FAILURE;
-                    }
-
-                    /* Configure SDIO to-block-size padding */
-                    if (card->sdio_io_block_pad)
-                    {
-                    /*
-                     * Firmware limits the maximum padding size via data_slot_round.
-                     * Therefore when padding to whole block sizes, the block size
-                     * must be configured correctly by adjusting CSR_WIFI_HIP_SDIO_BLOCK_SIZE.
-                     */
-                        if (cfg_data->data_slot_round < card->sdio_io_block_size)
-                        {
-                            unifi_error(card->ospriv,
-                                        "Configuration error: Block size of %d exceeds f/w data_slot_round of %d\n",
-                                        card->sdio_io_block_size, cfg_data->data_slot_round);
-                            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-                        }
-
-                        /*
-                         * To force the To-Host signals to be rounded up to the SDIO block
-                         * size, we need to write the To-Host Signal Padding Fragments
-                         * field of the SDIO configuration in UniFi.
-                         */
-                        if ((card->sdio_io_block_size % cfg_data->sig_frag_size) != 0)
-                        {
-                            unifi_error(card->ospriv, "Configuration error: Can not pad to-host signals.\n");
-                            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-                        }
-                        cfg_data->tohost_signal_padding = (u16) (card->sdio_io_block_size / cfg_data->sig_frag_size);
-                        unifi_info(card->ospriv, "SDIO block size %d requires %d padding chunks\n",
-                                   card->sdio_io_block_size, cfg_data->tohost_signal_padding);
-                        r = unifi_card_write16(card, slut.obj + SDIO_TO_HOST_SIG_PADDING_OFFSET, cfg_data->tohost_signal_padding);
-                        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-                        {
-                            return r;
-                        }
-                        if (r != CSR_RESULT_SUCCESS)
-                        {
-                            unifi_error(card->ospriv, "Failed to write To-Host Signal Padding Fragments\n");
-                            return r;
-                        }
-                    }
-
-                    /* Reconstruct the Generic Pointer address of the
-                     * SDIO Control Data Struct.
-                     */
-                    card->sdio_ctrl_addr = cfg_data->sdio_ctrl_offset | (UNIFI_SH_DMEM << 24);
-                    card->init_flag_addr = slut.obj + SDIO_INIT_FLAG_OFFSET;
-                    break;
-
-                case CSR_SLT_BUILD_ID_NUMBER:
-                {
-                    u32 n;
-                    r = unifi_read32(card, slut.obj, &n);
-                    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-                    {
-                        return r;
-                    }
-                    if (r != CSR_RESULT_SUCCESS)
-                    {
-                        unifi_error(card->ospriv, "Failed to read build id\n");
-                        return r;
-                    }
-                    card->build_id = n;
-                }
-                break;
-
-                case CSR_SLT_BUILD_ID_STRING:
-                    r = unifi_readnz(card, slut.obj, card->build_id_string,
-                                     sizeof(card->build_id_string));
-                    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-                    {
-                        return r;
-                    }
-                    if (r != CSR_RESULT_SUCCESS)
-                    {
-                        unifi_error(card->ospriv, "Failed to read build string\n");
-                        return r;
-                    }
-                    break;
-
-                case CSR_SLT_PERSISTENT_STORE_DB:
-                    break;
-
-                case CSR_SLT_BOOT_LOADER_CONTROL:
-
-                    /* This command copies most of the station firmware
-                     * image from ROM into program RAM.  It also clears
-                     * out the zerod data and sets up the initialised
-                     * data. */
-                    r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_LOAD_STA);
-                    if (r != CSR_RESULT_SUCCESS)
-                    {
-                        unifi_error(card->ospriv, "Failed to write loader load image command\n");
-                        return r;
-                    }
-
-                    dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
-
-                    /* dlpriv might be NULL, we still need to do the do_loader_op step. */
-                    if (dlpriv != NULL)
-                    {
-                    /* Download the firmware. */
-                        r = unifi_dl_patch(card, dlpriv, slut.obj);
-
-                    /* Free the firmware file information. */
-                        unifi_fw_read_stop(card->ospriv, dlpriv);
-
-                        if (r != CSR_RESULT_SUCCESS)
-                        {
-                            unifi_error(card->ospriv, "Failed to patch firmware\n");
-                            return r;
-                        }
-                    }
-
-                    /* This command starts the firmware image that we want (the
-                    * station by default) with any patches required applied. */
-                    r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_RESTART);
-                    if (r != CSR_RESULT_SUCCESS)
-                    {
-                        unifi_error(card->ospriv, "Failed to write loader restart command\n");
-                        return r;
-                    }
-
-                    /* The now running patch f/w defines a new SLUT data structure -
-                     * the current one is no longer valid. We must drop out of the
-                     * processing loop and enumerate the new SLUT (which may appear
-                     * at a different offset).
-                     */
-                    search_4slut_again = 1;
-                    break;
-
-                case CSR_SLT_PANIC_DATA_PHY:
-                    card->panic_data_phy_addr = slut.obj;
-                    break;
-
-                case CSR_SLT_PANIC_DATA_MAC:
-                    card->panic_data_mac_addr = slut.obj;
-                    break;
-
-                default:
-                    /* do nothing */
-                    break;
-            }
-        } /* while */
-    } while (search_4slut_again);
-
-    /* Did we find the Config Data ? */
-    if (cfg_data == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to find SDIO_SLOT_CONFIG Symbol\n");
-        return CSR_RESULT_FAILURE;
-    }
-
-    /*
-     * Has ths card already been initialised?
-     * If so, return an error so we do a h/w reset and start again.
-     */
-    r = unifi_card_read16(card, card->init_flag_addr, &initialised);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read init flag at %08lx\n",
-                    card->init_flag_addr);
-        return r;
-    }
-    if (initialised != 0)
-    {
-        return CSR_RESULT_FAILURE;
-    }
-
-
-    /*
-     * Now check the UniFi firmware version
-     */
-    major = (cfg_data->version >> 8) & 0xFF;
-    minor = cfg_data->version & 0xFF;
-    unifi_info(card->ospriv, "UniFi f/w protocol version %d.%d (driver %d.%d)\n",
-               major, minor,
-               UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
-
-    unifi_info(card->ospriv, "Firmware build %u: %s\n",
-               card->build_id, card->build_id_string);
-
-    if (major != UNIFI_HIP_MAJOR_VERSION)
-    {
-        unifi_error(card->ospriv, "UniFi f/w protocol major version (%d) is different from driver (v%d.%d)\n",
-                    major, UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
-#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
-        return CSR_RESULT_FAILURE;
-#endif
-    }
-    if (minor < UNIFI_HIP_MINOR_VERSION)
-    {
-        unifi_error(card->ospriv, "UniFi f/w protocol version (v%d.%d) is older than minimum required by driver (v%d.%d).\n",
-                    major, minor,
-                    UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
-#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
-        return CSR_RESULT_FAILURE;
-#endif
-    }
-
-    /* Read panic codes from a previous firmware panic. If the firmware has
-     * not panicked since power was applied (e.g. power-off hard reset)
-     * the stored panic codes will not be updated.
-     */
-    unifi_read_panic(card);
-
-    return CSR_RESULT_SUCCESS;
-} /* card_hw_init() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_wait_for_unifi_to_reset
- *
- *      Waits for a reset to complete by polling the WLAN function enable
- *      bit (which is cleared on reset).
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on failure.
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_wait_for_unifi_to_reset(card_t *card)
-{
-    s16 i;
-    CsrResult r;
-    u8 io_enable;
-    CsrResult csrResult;
-
-    r = CSR_RESULT_SUCCESS;
-    for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
-    {
-        unifi_trace(card->ospriv, UDBG1, "waiting for reset to complete, attempt %d\n", i);
-        if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-        {
-            /* It's quite likely that this read will timeout for the
-             * first few tries - especially if we have reset via
-             * DBG_RESET.
-             */
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-            unifi_debug_log_to_buf("m0@%02X=", SDIO_IO_READY);
-#endif
-            csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-            if (csrResult != CSR_RESULT_SUCCESS)
-            {
-                unifi_debug_log_to_buf("error=%X\n", csrResult);
-            }
-            else
-            {
-                unifi_debug_log_to_buf("%X\n", io_enable);
-            }
-#endif
-            if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-            {
-                return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-            }
-            r = CSR_RESULT_SUCCESS;
-            if (csrResult != CSR_RESULT_SUCCESS)
-            {
-                r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            }
-        }
-        else
-        {
-            r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_enable);
-        }
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r == CSR_RESULT_SUCCESS)
-        {
-            u16 mbox2;
-            s16 enabled = io_enable & (1 << card->function);
-
-            if (!enabled)
-            {
-                unifi_trace(card->ospriv, UDBG1,
-                            "Reset complete (function %d is disabled) in ~ %u msecs\n",
-                            card->function, i * MAILBOX2_TIMEOUT);
-
-                /* Enable WLAN function and verify MAILBOX2 is zero'd */
-                csrResult = CsrSdioFunctionEnable(card->sdio_if);
-                if (csrResult != CSR_RESULT_SUCCESS)
-                {
-                    r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-                    unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d\n", r);
-                    break;
-                }
-            }
-
-            r = unifi_read_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, &mbox2);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "read HIP_HANDSHAKE failed %d\n", r);
-                break;
-            }
-            if (mbox2 != 0)
-            {
-                unifi_error(card->ospriv, "MAILBOX2 non-zero after reset (mbox2 = %04x)\n", mbox2);
-                r = CSR_RESULT_FAILURE;
-            }
-            break;
-        }
-        else
-        {
-            if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-            {
-                /* We ignore read failures for the first few reads,
-                 * they are probably benign. */
-                if (i > MAILBOX2_ATTEMPTS / 4)
-                {
-                    unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Ready register while polling for reset\n");
-                }
-            }
-            else
-            {
-                unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Enable register while polling for reset\n");
-            }
-        }
-        CsrThreadSleep(MAILBOX2_TIMEOUT);
-    }
-
-    if (r == CSR_RESULT_SUCCESS && i == MAILBOX2_ATTEMPTS)
-    {
-        unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete reset\n");
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* card_wait_for_unifi_to_reset() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_wait_for_unifi_to_disable
- *
- *      Waits for the function to become disabled by polling the
- *      IO_READY bit.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on failure.
- *
- *  Notes: This function can only be used with
- *         card->chip_id > SDIO_CARD_ID_UNIFI_2
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_wait_for_unifi_to_disable(card_t *card)
-{
-    s16 i;
-    CsrResult r;
-    u8 io_enable;
-    CsrResult csrResult;
-
-    if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
-    {
-        unifi_error(card->ospriv,
-                    "Function reset method not supported for chip_id=%d\n",
-                    card->chip_id);
-        return CSR_RESULT_FAILURE;
-    }
-
-    r = CSR_RESULT_SUCCESS;
-    for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
-    {
-        unifi_trace(card->ospriv, UDBG1, "waiting for disable to complete, attempt %d\n", i);
-
-        /*
-         * It's quite likely that this read will timeout for the
-         * first few tries - especially if we have reset via
-         * DBG_RESET.
-         */
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        unifi_debug_log_to_buf("r0@%02X=", SDIO_IO_READY);
-#endif
-        csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            unifi_debug_log_to_buf("error=%X\n", csrResult);
-        }
-        else
-        {
-            unifi_debug_log_to_buf("%X\n", io_enable);
-        }
-#endif
-        if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-        {
-            return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        }
-        if (csrResult == CSR_RESULT_SUCCESS)
-        {
-            s16 enabled = io_enable & (1 << card->function);
-            r = CSR_RESULT_SUCCESS;
-            if (!enabled)
-            {
-                unifi_trace(card->ospriv, UDBG1,
-                            "Disable complete (function %d is disabled) in ~ %u msecs\n",
-                            card->function, i * MAILBOX2_TIMEOUT);
-
-                break;
-            }
-        }
-        else
-        {
-            /*
-             * We ignore read failures for the first few reads,
-             * they are probably benign.
-             */
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            if (i > (MAILBOX2_ATTEMPTS / 4))
-            {
-                unifi_trace(card->ospriv, UDBG1,
-                            "Failed to read CCCR IO Ready register while polling for disable\n");
-            }
-        }
-        CsrThreadSleep(MAILBOX2_TIMEOUT);
-    }
-
-    if ((r == CSR_RESULT_SUCCESS) && (i == MAILBOX2_ATTEMPTS))
-    {
-        unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete disable\n");
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* card_wait_for_unifi_to_reset() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_wait_for_firmware_to_start
- *
- *      Polls the MAILBOX1 register for a non-zero value.
- *      Then reads MAILBOX0 and forms the two values into a 32-bit address
- *      which is returned to the caller.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      paddr           Pointer to receive the UniFi address formed
- *                      by concatenating MAILBOX1 and MAILBOX0.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on failure.
- * ---------------------------------------------------------------------------
- */
-CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr)
-{
-    s32 i;
-    u16 mbox0, mbox1;
-    CsrResult r;
-
-    /*
-     * Wait for UniFi to initialise its data structures by polling
-     * the SHARED_MAILBOX1 register.
-     * Experience shows this is typically 120ms.
-     */
-    CsrThreadSleep(MAILBOX1_TIMEOUT);
-
-    mbox1 = 0;
-    unifi_trace(card->ospriv, UDBG1, "waiting for MAILBOX1 to be non-zero...\n");
-    for (i = 0; i < MAILBOX1_ATTEMPTS; i++)
-    {
-        r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            /* These reads can fail if UniFi isn't up yet, so try again */
-            unifi_warning(card->ospriv, "Failed to read UniFi Mailbox1 register\n");
-        }
-
-        if ((r == CSR_RESULT_SUCCESS) && (mbox1 != 0))
-        {
-            unifi_trace(card->ospriv, UDBG1, "MAILBOX1 ready (0x%04X) in %u millisecs\n",
-                        mbox1, i * MAILBOX1_TIMEOUT);
-
-            /* Read the MAILBOX1 again in case we caught the value as it
-             * changed. */
-            r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
-            if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                return r;
-            }
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "Failed to read UniFi Mailbox1 register for second time\n");
-                return r;
-            }
-            unifi_trace(card->ospriv, UDBG1, "MAILBOX1 value=0x%04X\n", mbox1);
-
-            break;
-        }
-
-        CsrThreadSleep(MAILBOX1_TIMEOUT);
-        if ((i % 100) == 99)
-        {
-            unifi_trace(card->ospriv, UDBG2, "MAILBOX1 not ready (0x%X), still trying...\n", mbox1);
-        }
-    }
-
-    if ((r == CSR_RESULT_SUCCESS) && (mbox1 == 0))
-    {
-        unifi_trace(card->ospriv, UDBG1, "Timeout waiting for firmware to start, Mailbox1 still 0 after %d ms\n",
-                    MAILBOX1_ATTEMPTS * MAILBOX1_TIMEOUT);
-        return CSR_RESULT_FAILURE;
-    }
-
-
-    /*
-     * Complete the reset handshake by setting MAILBOX2 to 0xFFFF
-     */
-    r = unifi_write_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, 0xFFFF);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write f/w startup handshake to MAILBOX2\n");
-        return r;
-    }
-
-
-    /*
-     * Read the Symbol Look Up Table (SLUT) offset.
-     * Top 16 bits are in mbox1, read the lower 16 bits from mbox0.
-     */
-    mbox0 = 0;
-    r = unifi_read_direct16(card, ChipHelper_MAILBOX0(card->helper) * 2, &mbox0);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read UniFi Mailbox0 register\n");
-        return r;
-    }
-
-    *paddr = (((u32)mbox1 << 16) | mbox0);
-
-    return CSR_RESULT_SUCCESS;
-} /* card_wait_for_firmware_to_start() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_capture_panic
- *
- *      Attempt to capture panic codes from the firmware. This may involve
- *      warm reset of the chip to regain access following a watchdog reset.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS if panic codes were captured, or none available
- *      CSR_RESULT_FAILURE if the driver could not access function 1
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_capture_panic(card_t *card)
-{
-
-    /* The firmware must have previously initialised to read the panic addresses
-     * from the SLUT
-     */
-    if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
-    {
-        return CSR_RESULT_SUCCESS;
-    }
-
-    /* Ensure we can access function 1 following a panic/watchdog reset */
-    if (card_access_panic(card) == CSR_RESULT_SUCCESS)
-    {
-        /* Read the panic codes */
-        unifi_read_panic(card);
-    }
-    else
-    {
-        unifi_info(card->ospriv, "Unable to read panic codes");
-    }
-
-    return CSR_RESULT_SUCCESS;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_access_panic
- *      Attempt to read the WLAN SDIO function in order to read panic codes
- *      and perform various reset steps to regain access if the read fails.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS if panic codes can be read
- *      CSR error code if panic codes can not be read
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_access_panic(card_t *card)
-{
-    u16 data_u16 = 0;
-    s32 i;
-    CsrResult r, sr;
-
-    /* A chip version of zero means that the version never got successfully read
-     * during reset. In this case give up because it will not be possible to
-     * verify the chip version.
-     */
-    if (!card->chip_version)
-    {
-        unifi_info(card->ospriv, "Unknown chip version\n");
-        return CSR_RESULT_FAILURE;
-    }
-
-    /* Ensure chip is awake or access to function 1 will fail */
-    r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "unifi_set_host_state() failed %d\n", r);
-        return CSR_RESULT_FAILURE; /* Card is probably unpowered */
-    }
-    CsrThreadSleep(20);
-
-    for (i = 0; i < 3; i++)
-    {
-        sr = CsrSdioRead16(card->sdio_if, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION * 2, &data_u16);
-        if (sr != CSR_RESULT_SUCCESS || data_u16 != card->chip_version)
-        {
-            unifi_info(card->ospriv, "Failed to read valid chip version sr=%d (0x%04x want 0x%04x) try %d\n",
-                       sr, data_u16, card->chip_version, i);
-
-            /* Set clock speed low */
-            sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
-            if (sr != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed1 %d\n", sr);
-                r = ConvertCsrSdioToCsrHipResult(card, sr);
-            }
-            card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
-
-            /* First try re-enabling function in case a f/w watchdog reset disabled it */
-            if (i == 0)
-            {
-                unifi_info(card->ospriv, "Try function enable\n");
-                sr = CsrSdioFunctionEnable(card->sdio_if);
-                if (sr != CSR_RESULT_SUCCESS)
-                {
-                    r = ConvertCsrSdioToCsrHipResult(card, sr);
-                    unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d (HIP %d)\n", sr, r);
-                }
-                continue;
-            }
-
-            /* Second try, set awake */
-            unifi_info(card->ospriv, "Try set awake\n");
-
-            /* Ensure chip is awake */
-            r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-            if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                return r;
-            }
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "unifi_set_host_state() failed2 %d\n", r);
-            }
-
-            /* Set clock speed low in case setting the host state raised it, which
-             * would only happen if host state was previously TORPID
-             */
-            sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
-            if (sr != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed2 %d\n", sr);
-            }
-            card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
-
-            if (i == 1)
-            {
-                continue;
-            }
-
-            /* Perform a s/w reset to preserve as much as the card state as possible,
-             * (mainly the preserve RAM). The context will be lost for coredump - but as we
-             * were unable to access the WLAN function for panic, the coredump would have
-             * also failed without a reset.
-             */
-            unifi_info(card->ospriv, "Try s/w reset\n");
-
-            r = unifi_card_hard_reset(card);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "unifi_card_hard_reset() failed %d\n", r);
-            }
-        }
-        else
-        {
-            if (i > 0)
-            {
-                unifi_info(card->ospriv, "Read chip version 0x%x after %d retries\n", data_u16, i);
-            }
-            break;
-        }
-    }
-
-    r = ConvertCsrSdioToCsrHipResult(card, sr);
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read_panic
- *      Reads, saves and prints panic codes stored by the firmware in UniFi's
- *      preserve RAM by the last panic that occurred since chip was powered.
- *      Nothing is saved if the panic codes are read as zero.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- * ---------------------------------------------------------------------------
- */
-void unifi_read_panic(card_t *card)
-{
-    CsrResult r;
-    u16 p_code, p_arg;
-
-    /* The firmware must have previously initialised to read the panic addresses
-     * from the SLUT
-     */
-    if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
-    {
-        return;
-    }
-
-    /* Get the panic data from PHY */
-    r = unifi_card_read16(card, card->panic_data_phy_addr, &p_code);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr, r);
-        p_code = 0;
-    }
-    if (p_code)
-    {
-        r = unifi_card_read16(card, card->panic_data_phy_addr + 2, &p_arg);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr + 2, r);
-        }
-        unifi_error(card->ospriv, "Last UniFi PHY PANIC %04x arg %04x\n", p_code, p_arg);
-        card->last_phy_panic_code = p_code;
-        card->last_phy_panic_arg = p_arg;
-    }
-
-    /* Get the panic data from MAC */
-    r = unifi_card_read16(card, card->panic_data_mac_addr, &p_code);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr, r);
-        p_code = 0;
-    }
-    if (p_code)
-    {
-        r = unifi_card_read16(card, card->panic_data_mac_addr + 2, &p_arg);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr + 2, r);
-        }
-        unifi_error(card->ospriv, "Last UniFi MAC PANIC %04x arg %04x\n", p_code, p_arg);
-        card->last_mac_panic_code = p_code;
-        card->last_mac_panic_arg = p_arg;
-    }
-
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_allocate_memory_resources
- *
- *      Allocates memory for the from-host, to-host bulk data slots,
- *      soft queue buffers and bulk data buffers.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on failure.
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_allocate_memory_resources(card_t *card)
-{
-    s16 n, i, k, r;
-    sdio_config_data_t *cfg_data;
-
-    /* Reset any state carried forward from a previous life */
-    card->fh_command_queue.q_rd_ptr = 0;
-    card->fh_command_queue.q_wr_ptr = 0;
-    (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
-                      "fh_cmd_q");
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        card->fh_traffic_queue[i].q_rd_ptr = 0;
-        card->fh_traffic_queue[i].q_wr_ptr = 0;
-        (void)scnprintf(card->fh_traffic_queue[i].name,
-                          UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
-    }
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-    unifi_ta_sampling_init(card);
-#endif
-    /* Convenience short-cut */
-    cfg_data = &card->config_data;
-
-    /*
-     * Allocate memory for the from-host and to-host signal buffers.
-     */
-    card->fh_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
-    if (card->fh_buffer.buf == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for F-H signals\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-    card->fh_buffer.bufsize = UNIFI_FH_BUF_SIZE;
-    card->fh_buffer.ptr = card->fh_buffer.buf;
-    card->fh_buffer.count = 0;
-
-    card->th_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
-    if (card->th_buffer.buf == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for T-H signals\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-    card->th_buffer.bufsize = UNIFI_FH_BUF_SIZE;
-    card->th_buffer.ptr = card->th_buffer.buf;
-    card->th_buffer.count = 0;
-
-
-    /*
-     * Allocate memory for the from-host and to-host bulk data slots.
-     * This is done as separate kmallocs because lots of smaller
-     * allocations are more likely to succeed than one huge one.
-     */
-
-    /* Allocate memory for the array of pointers */
-    n = cfg_data->num_fromhost_data_slots;
-
-    unifi_trace(card->ospriv, UDBG3, "Alloc from-host resources, %d slots.\n", n);
-    card->from_host_data = kmalloc(n * sizeof(slot_desc_t), GFP_KERNEL);
-    if (card->from_host_data == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for F-H bulk data array\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-
-    /* Initialise from-host bulk data slots */
-    for (i = 0; i < n; i++)
-    {
-        UNIFI_INIT_BULK_DATA(&card->from_host_data[i].bd);
-    }
-
-    /* Allocate memory for the array used for slot host tag mapping */
-    card->fh_slot_host_tag_record = kmalloc(n * sizeof(u32), GFP_KERNEL);
-
-    if (card->fh_slot_host_tag_record == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for F-H slot host tag mapping array\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-
-    /* Initialise host tag entries for from-host bulk data slots */
-    for (i = 0; i < n; i++)
-    {
-        card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
-    }
-
-
-    /* Allocate memory for the array of pointers */
-    n = cfg_data->num_tohost_data_slots;
-
-    unifi_trace(card->ospriv, UDBG3, "Alloc to-host resources, %d slots.\n", n);
-    card->to_host_data = kmalloc(n * sizeof(bulk_data_desc_t), GFP_KERNEL);
-    if (card->to_host_data == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for T-H bulk data array\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-
-    /* Initialise to-host bulk data slots */
-    for (i = 0; i < n; i++)
-    {
-        UNIFI_INIT_BULK_DATA(&card->to_host_data[i]);
-    }
-
-    /*
-     * Initialise buffers for soft Q
-     */
-    for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
-    {
-        for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
-        {
-            UNIFI_INIT_BULK_DATA(&card->fh_command_q_body[i].bulkdata[r]);
-        }
-    }
-
-    for (k = 0; k < UNIFI_NO_OF_TX_QS; k++)
-    {
-        for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
-        {
-            for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
-            {
-                UNIFI_INIT_BULK_DATA(&card->fh_traffic_q_body[k][i].bulkdata[r]);
-            }
-        }
-    }
-
-    card->memory_resources_allocated = 1;
-
-    return CSR_RESULT_SUCCESS;
-} /* card_allocate_memory_resources() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_free_bulk_data
- *
- *      Free the data associated to a bulk data structure.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      bulk_data_slot  Pointer to bulk data structure
- *
- *  Returns:
- *      None.
- *
- * ---------------------------------------------------------------------------
- */
-static void unifi_free_bulk_data(card_t *card, bulk_data_desc_t *bulk_data_slot)
-{
-    if (bulk_data_slot->data_length != 0)
-    {
-        unifi_net_data_free(card->ospriv, bulk_data_slot);
-    }
-} /* unifi_free_bulk_data() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_free_memory_resources
- *
- *      Frees memory allocated for the from-host, to-host bulk data slots,
- *      soft queue buffers and bulk data buffers.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void card_free_memory_resources(card_t *card)
-{
-
-    unifi_trace(card->ospriv, UDBG1, "Freeing card memory resources.\n");
-
-    /* Clear our internal queues */
-    unifi_cancel_pending_signals(card);
-
-
-    kfree(card->to_host_data);
-    card->to_host_data = NULL;
-
-    kfree(card->from_host_data);
-    card->from_host_data = NULL;
-
-    /* free the memory for slot host tag mapping array */
-    kfree(card->fh_slot_host_tag_record);
-    card->fh_slot_host_tag_record = NULL;
-
-    kfree(card->fh_buffer.buf);
-    card->fh_buffer.ptr = card->fh_buffer.buf = NULL;
-    card->fh_buffer.bufsize = 0;
-    card->fh_buffer.count = 0;
-
-    kfree(card->th_buffer.buf);
-    card->th_buffer.ptr = card->th_buffer.buf = NULL;
-    card->th_buffer.bufsize = 0;
-    card->th_buffer.count = 0;
-
-
-    card->memory_resources_allocated = 0;
-
-} /* card_free_memory_resources() */
-
-
-static void card_init_soft_queues(card_t *card)
-{
-    s16 i;
-
-    unifi_trace(card->ospriv, UDBG1, "Initialising internal signal queues.\n");
-    /* Reset any state carried forward from a previous life */
-    card->fh_command_queue.q_rd_ptr = 0;
-    card->fh_command_queue.q_wr_ptr = 0;
-    (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
-                      "fh_cmd_q");
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        card->fh_traffic_queue[i].q_rd_ptr = 0;
-        card->fh_traffic_queue[i].q_wr_ptr = 0;
-        (void)scnprintf(card->fh_traffic_queue[i].name,
-                          UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
-    }
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-    unifi_ta_sampling_init(card);
-#endif
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_cancel_pending_signals
- *
- *      Free the signals and associated bulk data, pending in the core.
- *
- *  Arguments:
- *      card        Pointer to card struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void unifi_cancel_pending_signals(card_t *card)
-{
-    s16 i, n, r;
-
-    unifi_trace(card->ospriv, UDBG1, "Canceling pending signals.\n");
-
-    if (card->to_host_data)
-    {
-        /*
-         * Free any bulk data buffers allocated for the t-h slots
-         * This will clear all buffers that did not make it to
-         * unifi_receive_event() before cancel was request.
-         */
-        n = card->config_data.num_tohost_data_slots;
-        unifi_trace(card->ospriv, UDBG3, "Freeing to-host resources, %d slots.\n", n);
-        for (i = 0; i < n; i++)
-        {
-            unifi_free_bulk_data(card, &card->to_host_data[i]);
-        }
-    }
-
-    /*
-     * If any of the from-host bulk data has reached the card->from_host_data
-     * but not UniFi, we need to free the buffers here.
-     */
-    if (card->from_host_data)
-    {
-        /* Free any bulk data buffers allocated for the f-h slots */
-        n = card->config_data.num_fromhost_data_slots;
-        unifi_trace(card->ospriv, UDBG3, "Freeing from-host resources, %d slots.\n", n);
-        for (i = 0; i < n; i++)
-        {
-            unifi_free_bulk_data(card, &card->from_host_data[i].bd);
-        }
-
-        for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-        {
-            card->dynamic_slot_data.from_host_used_slots[i] = 0;
-            card->dynamic_slot_data.from_host_max_slots[i] = 0;
-            card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
-        }
-    }
-
-    /*
-     * Free any bulk data buffers allocated in the soft queues.
-     * This covers the case where a bulk data pointer has reached the soft queue
-     * but not the card->from_host_data.
-     */
-    unifi_trace(card->ospriv, UDBG3, "Freeing cmd q resources.\n");
-    for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
-    {
-        for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
-        {
-            unifi_free_bulk_data(card, &card->fh_command_q_body[i].bulkdata[r]);
-        }
-    }
-
-    unifi_trace(card->ospriv, UDBG3, "Freeing traffic q resources.\n");
-    for (n = 0; n < UNIFI_NO_OF_TX_QS; n++)
-    {
-        for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
-        {
-            for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
-            {
-                unifi_free_bulk_data(card, &card->fh_traffic_q_body[n][i].bulkdata[r]);
-            }
-        }
-    }
-
-    card_init_soft_queues(card);
-
-} /* unifi_cancel_pending_signals() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_free_card
- *
- *      Free the memory allocated for the card structure and buffers.
- *
- *  Notes:
- *      The porting layer is responsible for freeing any mini-coredump buffers
- *      allocated when it called unifi_coredump_init(), by calling
- *      unifi_coredump_free() before calling this function.
- *
- *  Arguments:
- *      card        Pointer to card struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void unifi_free_card(card_t *card)
-{
-#ifdef CSR_PRE_ALLOC_NET_DATA
-    prealloc_netdata_free(card);
-#endif
-    /* Free any memory allocated. */
-    card_free_memory_resources(card);
-
-    /* Warn if caller didn't free coredump buffers */
-    if (card->dump_buf)
-    {
-        unifi_error(card->ospriv, "Caller should call unifi_coredump_free()\n");
-        unifi_coredump_free(card); /* free anyway to prevent memory leak */
-    }
-
-    kfree(card);
-
-} /* unifi_free_card() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_init_slots
- *
- *      Allocate memory for host-side slot data and signal queues.
- *
- * Arguments:
- *      card            Pointer to card object
- *
- * Returns:
- *      CSR error code.
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_init_slots(card_t *card)
-{
-    CsrResult r;
-    u8 i;
-
-    /* Allocate the buffers we need, only once. */
-    if (card->memory_resources_allocated == 1)
-    {
-        card_free_memory_resources(card);
-    }
-    else
-    {
-        /* Initialise our internal command and traffic queues */
-        card_init_soft_queues(card);
-    }
-
-    r = card_allocate_memory_resources(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to allocate card memory resources.\n");
-        card_free_memory_resources(card);
-        return r;
-    }
-
-    if (card->sdio_ctrl_addr == 0)
-    {
-        unifi_error(card->ospriv, "Failed to find config struct!\n");
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    /*
-     * Set initial counts.
-     */
-
-    card->from_host_data_head = 0;
-
-    /* Get initial signal counts from UniFi, in case it has not been reset. */
-    {
-        u16 s;
-
-        /* Get the from-host-signals-written count */
-        r = unifi_card_read16(card, card->sdio_ctrl_addr + 0, &s);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to read from-host sig written count\n");
-            return r;
-        }
-        card->from_host_signals_w = (s16)s;
-
-        /* Get the to-host-signals-written count */
-        r = unifi_card_read16(card, card->sdio_ctrl_addr + 6, &s);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to read to-host sig read count\n");
-            return r;
-        }
-        card->to_host_signals_r = (s16)s;
-    }
-
-    /* Set Initialised flag. */
-    r = unifi_card_write16(card, card->init_flag_addr, 0x0001);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write initialised flag\n");
-        return r;
-    }
-
-    /* Dynamic queue reservation */
-    memset(&card->dynamic_slot_data, 0, sizeof(card_dynamic_slot_t));
-
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
-                                                         UNIFI_RESERVED_COMMAND_SLOTS;
-        card->dynamic_slot_data.queue_stable[i] = FALSE;
-    }
-
-    card->dynamic_slot_data.packets_interval = UNIFI_PACKETS_INTERVAL;
-
-    return CSR_RESULT_SUCCESS;
-} /* card_init_slots() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_set_udi_hook
- *
- *      Registers the udi hook that reports the sent signals to the core.
- *
- *  Arguments:
- *      card            Pointer to the card context struct
- *      udi_fn          Pointer to the callback function.
- *
- *  Returns:
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
- *      CSR_RESULT_SUCCESS on success.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn)
-{
-    if (card == NULL)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    if (card->udi_hook == NULL)
-    {
-        card->udi_hook = udi_fn;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_set_udi_hook() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_remove_udi_hook
- *
- *      Removes the udi hook that reports the sent signals from the core.
- *
- *  Arguments:
- *      card            Pointer to the card context struct
- *      udi_fn          Pointer to the callback function.
- *
- *  Returns:
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
- *      CSR_RESULT_SUCCESS on success.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn)
-{
-    if (card == NULL)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    if (card->udi_hook == udi_fn)
-    {
-        card->udi_hook = NULL;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_remove_udi_hook() */
-
-
-static void CardReassignDynamicReservation(card_t *card)
-{
-    u8 i;
-
-    unifi_trace(card->ospriv, UDBG5, "Packets Txed %d %d %d %d\n",
-                card->dynamic_slot_data.packets_txed[0],
-                card->dynamic_slot_data.packets_txed[1],
-                card->dynamic_slot_data.packets_txed[2],
-                card->dynamic_slot_data.packets_txed[3]);
-
-    /* Clear reservation and recalculate max slots */
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        card->dynamic_slot_data.queue_stable[i] = FALSE;
-        card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
-        card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
-                                                         UNIFI_RESERVED_COMMAND_SLOTS;
-        card->dynamic_slot_data.packets_txed[i] = 0;
-
-        unifi_trace(card->ospriv, UDBG5, "CardReassignDynamicReservation: queue %d reserved %d Max %d\n", i,
-                    card->dynamic_slot_data.from_host_reserved_slots[i],
-                    card->dynamic_slot_data.from_host_max_slots[i]);
-    }
-
-    card->dynamic_slot_data.total_packets_txed = 0;
-}
-
-
-/* Algorithm to dynamically reserve slots. The logic is based mainly on the outstanding queue
- * length. Slots are reserved for particular queues during an interval and cleared after the interval.
- * Each queue has three associated variables.. a) used slots - the number of slots currently occupied
- * by the queue b) reserved slots - number of slots reserved specifically for the queue c) max slots - total
- * slots that this queue can actually use (may be higher than reserved slots and is dependent on reserved slots
- * for other queues).
- * This function is called when there are no slots available for a queue. It checks to see if there are enough
- * unreserved slots sufficient for this request. If available these slots are reserved for the queue.
- * If there are not enough unreserved slots, a fair share for each queue is calculated based on the total slots
- * and the number of active queues (any queue with existing reservation is considered active). Queues needing
- * less than their fair share are allowed to have the previously reserved slots. The remaining slots are
- * distributed evenly among queues that need more than the fair share
- *
- * A better scheme would take current bandwidth per AC into consideration when reserving slots. An
- * implementation scheme could consider the relative time/service period for slots in an AC. If the firmware
- * services other ACs faster than a particular AC (packets wait in the slots longer) then it is fair to reserve
- * less slots for the AC
- */
-static void CardCheckDynamicReservation(card_t *card, unifi_TrafficQueue queue)
-{
-    u16 q_len, active_queues = 0, excess_queue_slots, div_extra_slots,
-              queue_fair_share, reserved_slots = 0, q, excess_need_queues = 0, unmovable_slots = 0;
-    s32 i;
-    q_t *sigq;
-    u16 num_data_slots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
-
-    /* Calculate the pending queue length */
-    sigq = &card->fh_traffic_queue[queue];
-    q_len = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
-
-    if (q_len <= card->dynamic_slot_data.from_host_reserved_slots[queue])
-    {
-        unifi_trace(card->ospriv, UDBG5, "queue %d q_len %d already has that many reserved slots, exiting\n", queue, q_len);
-        return;
-    }
-
-    /* Upper limit */
-    if (q_len > num_data_slots)
-    {
-        q_len = num_data_slots;
-    }
-
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        if (i != (s32)queue)
-        {
-            reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
-        }
-        if ((i == (s32)queue) || (card->dynamic_slot_data.from_host_reserved_slots[i] > 0))
-        {
-            active_queues++;
-        }
-    }
-
-    unifi_trace(card->ospriv, UDBG5, "CardCheckDynamicReservation: queue %d q_len %d\n", queue, q_len);
-    unifi_trace(card->ospriv, UDBG5, "Active queues %d reserved slots on other queues %d\n",
-                active_queues, reserved_slots);
-
-    if (reserved_slots + q_len <= num_data_slots)
-    {
-        card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
-        if (q_len == num_data_slots)
-        {
-            /* This is the common case when just 1 stream is going */
-            card->dynamic_slot_data.queue_stable[queue] = TRUE;
-        }
-    }
-    else
-    {
-        queue_fair_share = num_data_slots / active_queues;
-        unifi_trace(card->ospriv, UDBG5, "queue fair share %d\n", queue_fair_share);
-
-        /* Evenly distribute slots among active queues */
-        /* Find out the queues that need excess of fair share. Also find slots allocated
-         * to queues less than their fair share, these slots cannot be reallocated (unmovable slots) */
-
-        card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
-
-        for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-        {
-            if (card->dynamic_slot_data.from_host_reserved_slots[i] > queue_fair_share)
-            {
-                excess_need_queues++;
-            }
-            else
-            {
-                unmovable_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
-            }
-        }
-
-        unifi_trace(card->ospriv, UDBG5, "Excess need queues %d\n", excess_need_queues);
-
-        /* Now find the slots per excess demand queue */
-        excess_queue_slots = (num_data_slots - unmovable_slots) / excess_need_queues;
-        div_extra_slots = (num_data_slots - unmovable_slots) - excess_queue_slots * excess_need_queues;
-        for (i = UNIFI_NO_OF_TX_QS - 1; i >= 0; i--)
-        {
-            if (card->dynamic_slot_data.from_host_reserved_slots[i] > excess_queue_slots)
-            {
-                card->dynamic_slot_data.from_host_reserved_slots[i] = excess_queue_slots;
-                if (div_extra_slots > 0)
-                {
-                    card->dynamic_slot_data.from_host_reserved_slots[i]++;
-                    div_extra_slots--;
-                }
-                /* No more slots will be allocated to this queue during the current interval */
-                card->dynamic_slot_data.queue_stable[i] = TRUE;
-                unifi_trace(card->ospriv, UDBG5, "queue stable %d\n", i);
-            }
-        }
-    }
-
-    /* Redistribute max slots */
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        reserved_slots = 0;
-        for (q = 0; q < UNIFI_NO_OF_TX_QS; q++)
-        {
-            if (i != q)
-            {
-                reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[q];
-            }
-        }
-
-        card->dynamic_slot_data.from_host_max_slots[i] = num_data_slots - reserved_slots;
-        unifi_trace(card->ospriv, UDBG5, "queue %d reserved %d Max %d\n", i,
-                    card->dynamic_slot_data.from_host_reserved_slots[i],
-                    card->dynamic_slot_data.from_host_max_slots[i]);
-    }
-
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardClearFromHostDataSlot
- *
- *      Clear a the given data slot, making it available again.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *      slot            Index of the signal slot to clear.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void CardClearFromHostDataSlot(card_t *card, const s16 slot)
-{
-    u8 queue = card->from_host_data[slot].queue;
-    const void *os_data_ptr = card->from_host_data[slot].bd.os_data_ptr;
-
-    if (card->from_host_data[slot].bd.data_length == 0)
-    {
-        unifi_warning(card->ospriv,
-                      "Surprise: request to clear an already free FH data slot: %d\n",
-                      slot);
-        return;
-    }
-
-    if (os_data_ptr == NULL)
-    {
-        unifi_warning(card->ospriv,
-                      "Clearing FH data slot %d: has null payload, len=%d\n",
-                      slot, card->from_host_data[slot].bd.data_length);
-    }
-
-    /* Free card->from_host_data[slot].bd.os_net_ptr here. */
-    /* Mark slot as free by setting length to 0. */
-    unifi_free_bulk_data(card, &card->from_host_data[slot].bd);
-    if (queue < UNIFI_NO_OF_TX_QS)
-    {
-        if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
-        {
-            unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
-                        queue,
-                        card->dynamic_slot_data.from_host_used_slots[queue]);
-        }
-        else
-        {
-            card->dynamic_slot_data.from_host_used_slots[queue]--;
-        }
-        card->dynamic_slot_data.packets_txed[queue]++;
-        card->dynamic_slot_data.total_packets_txed++;
-        if (card->dynamic_slot_data.total_packets_txed >= card->dynamic_slot_data.packets_interval)
-        {
-            CardReassignDynamicReservation(card);
-        }
-    }
-
-    unifi_trace(card->ospriv, UDBG4, "CardClearFromHostDataSlot: slot %d recycled %p\n", slot, os_data_ptr);
-
-} /* CardClearFromHostDataSlot() */
-
-
-#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
-/*
- * ---------------------------------------------------------------------------
- *  CardClearFromHostDataSlotWithoutFreeingBulkData
- *
- *      Clear the given data slot with out freeing the bulk data.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *      slot            Index of the signal slot to clear.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 slot)
-{
-    u8 queue = card->from_host_data[slot].queue;
-
-    /* Initialise the from_host data slot so it can be re-used,
-     * Set length field in from_host_data array to 0.
-     */
-    UNIFI_INIT_BULK_DATA(&card->from_host_data[slot].bd);
-
-    queue = card->from_host_data[slot].queue;
-
-    if (queue < UNIFI_NO_OF_TX_QS)
-    {
-        if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
-        {
-            unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
-                        queue,
-                        card->dynamic_slot_data.from_host_used_slots[queue]);
-        }
-        else
-        {
-            card->dynamic_slot_data.from_host_used_slots[queue]--;
-        }
-        card->dynamic_slot_data.packets_txed[queue]++;
-        card->dynamic_slot_data.total_packets_txed++;
-        if (card->dynamic_slot_data.total_packets_txed >=
-            card->dynamic_slot_data.packets_interval)
-        {
-            CardReassignDynamicReservation(card);
-        }
-    }
-} /* CardClearFromHostDataSlotWithoutFreeingBulkData() */
-
-
-#endif
-
-u16 CardGetDataSlotSize(card_t *card)
-{
-    return card->config_data.data_slot_size;
-} /* CardGetDataSlotSize() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardGetFreeFromHostDataSlots
- *
- *      Retrieve the number of from-host bulk data slots available.
- *
- *  Arguments:
- *      card            Pointer to the card context struct
- *
- *  Returns:
- *      Number of free from-host bulk data slots.
- * ---------------------------------------------------------------------------
- */
-u16 CardGetFreeFromHostDataSlots(card_t *card)
-{
-    u16 i, n = 0;
-
-    /* First two slots reserved for MLME */
-    for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
-    {
-        if (card->from_host_data[i].bd.data_length == 0)
-        {
-            /* Free slot */
-            n++;
-        }
-    }
-
-    return n;
-} /* CardGetFreeFromHostDataSlots() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardAreAllFromHostDataSlotsEmpty
- *
- *      Returns the state of from-host bulk data slots.
- *
- *  Arguments:
- *      card            Pointer to the card context struct
- *
- *  Returns:
- *      1       The from-host bulk data slots are all empty (available).
- *      0       Some or all the from-host bulk data slots are in use.
- * ---------------------------------------------------------------------------
- */
-u16 CardAreAllFromHostDataSlotsEmpty(card_t *card)
-{
-    u16 i;
-
-    for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
-    {
-        if (card->from_host_data[i].bd.data_length != 0)
-        {
-            return 0;
-        }
-    }
-
-    return 1;
-} /* CardGetFreeFromHostDataSlots() */
-
-
-static CsrResult unifi_identify_hw(card_t *card)
-{
-
-    card->chip_id = card->sdio_if->sdioId.cardId;
-    card->function = card->sdio_if->sdioId.sdioFunction;
-    card->sdio_io_block_size = card->sdio_if->blockSize;
-
-    /* If SDIO controller doesn't support byte mode CMD53, pad transfers to block sizes */
-    card->sdio_io_block_pad = (card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE)?FALSE : TRUE;
-
-    /*
-     * Setup the chip helper so that we can access the registers (and
-     * also tell what sub-type of HIP we should use).
-     */
-    card->helper = ChipHelper_GetVersionSdio((u8)card->chip_id);
-    if (!card->helper)
-    {
-        unifi_error(card->ospriv, "Null ChipHelper\n");
-    }
-
-    unifi_info(card->ospriv, "Chip ID 0x%02X  Function %u  Block Size %u  Name %s(%s)\n",
-               card->chip_id, card->function, card->sdio_io_block_size,
-               ChipHelper_MarketingName(card->helper),
-               ChipHelper_FriendlyName(card->helper));
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_identify_hw() */
-
-
-static CsrResult unifi_prepare_hw(card_t *card)
-{
-    CsrResult r;
-    CsrResult csrResult;
-    enum unifi_host_state old_state = card->host_state;
-
-    r = unifi_identify_hw(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to identify hw\n");
-        return r;
-    }
-
-    unifi_trace(card->ospriv, UDBG1,
-                "%s mode SDIO\n", card->sdio_io_block_pad?"Block" : "Byte");
-    /*
-     * Chip must be a awake or blocks that are asleep may not get
-     * reset.  We can only do this after we have read the chip_id.
-     */
-    r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-
-    if (old_state == UNIFI_HOST_STATE_TORPID)
-    {
-        /* Ensure the initial clock rate is set; if a reset occurred when the chip was
-         * TORPID, unifi_set_host_state() may have raised it to MAX.
-         */
-        csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            return r;
-        }
-        card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
-    }
-
-    /*
-     * The WLAN function must be enabled to access MAILBOX2 and DEBUG_RST
-     * registers.
-     */
-    csrResult = CsrSdioFunctionEnable(card->sdio_if);
-    if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-    }
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-        /* Can't enable WLAN function. Try resetting the SDIO block. */
-        unifi_error(card->ospriv, "Failed to re-enable function %d.\n", card->function);
-        return r;
-    }
-
-    /*
-     * Poke some registers to make sure the PLL has started,
-     * otherwise memory accesses are likely to fail.
-     */
-    bootstrap_chip_hw(card);
-
-    /* Try to read the chip version from register. */
-    r = unifi_read_chip_version(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_prepare_hw() */
-
-
-static CsrResult unifi_read_chip_version(card_t *card)
-{
-    u32 gbl_chip_version;
-    CsrResult r;
-    u16 ver;
-
-    gbl_chip_version = ChipHelper_GBL_CHIP_VERSION(card->helper);
-
-    /* Try to read the chip version from register. */
-    if (gbl_chip_version != 0)
-    {
-        r = unifi_read_direct16(card, gbl_chip_version * 2, &ver);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to read GBL_CHIP_VERSION\n");
-            return r;
-        }
-        card->chip_version = ver;
-    }
-    else
-    {
-        unifi_info(card->ospriv, "Unknown Chip ID, cannot locate GBL_CHIP_VERSION\n");
-        r = CSR_RESULT_FAILURE;
-    }
-
-    unifi_info(card->ospriv, "Chip Version 0x%04X\n", card->chip_version);
-
-    return r;
-} /* unifi_read_chip_version() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_reset_hardware
- *
- *      Execute the UniFi reset sequence.
- *
- *      Note: This may fail if the chip is going TORPID so retry at
- *      least once.
- *
- *  Arguments:
- *      card - pointer to card context structure
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error otherwise.
- *
- *  Notes:
- *      Some platforms (e.g. Windows Vista) do not allow access to registers
- *      that are necessary for a software soft reset.
- * ---------------------------------------------------------------------------
- */
-static CsrResult unifi_reset_hardware(card_t *card)
-{
-    CsrResult r;
-    u16 new_block_size = UNIFI_IO_BLOCK_SIZE;
-    CsrResult csrResult;
-
-    /* Errors returned by unifi_prepare_hw() are not critical at this point */
-    r = unifi_prepare_hw(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-
-    /* First try SDIO controller reset, which may power cycle the UniFi, assert
-     * its reset line, or not be implemented depending on the platform.
-     */
-    unifi_info(card->ospriv, "Calling CsrSdioHardReset\n");
-    csrResult = CsrSdioHardReset(card->sdio_if);
-    if (csrResult == CSR_RESULT_SUCCESS)
-    {
-        unifi_info(card->ospriv, "CsrSdioHardReset succeeded on resetting UniFi\n");
-        r = unifi_prepare_hw(card);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "unifi_prepare_hw failed after hard reset\n");
-            return r;
-        }
-    }
-    else if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-    }
-    else
-    {
-        /* Falling back to software hard reset methods */
-        unifi_info(card->ospriv, "Falling back to software hard reset\n");
-        r = unifi_card_hard_reset(card);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "software hard reset failed\n");
-            return r;
-        }
-
-        /* If we fell back to unifi_card_hard_reset() methods, chip version may
-         * not have been read. (Note in the unlikely event that it is zero,
-         * it will be harmlessly read again)
-         */
-        if (card->chip_version == 0)
-        {
-            r = unifi_read_chip_version(card);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-        }
-    }
-
-#ifdef CSR_WIFI_HIP_SDIO_BLOCK_SIZE
-    new_block_size = CSR_WIFI_HIP_SDIO_BLOCK_SIZE;
-#endif
-
-    /* After hard reset, we need to restore the SDIO block size */
-    csrResult = CsrSdioBlockSizeSet(card->sdio_if, new_block_size);
-    r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-
-    /* Warn if a different block size was achieved by the transport */
-    if (card->sdio_if->blockSize != new_block_size)
-    {
-        unifi_info(card->ospriv,
-                   "Actually got block size %d\n", card->sdio_if->blockSize);
-    }
-
-    /* sdio_io_block_size always needs be updated from the achieved block size,
-     * as it is used by the OS layer to allocate memory in unifi_net_malloc().
-     * Controllers which don't support block mode (e.g. CSPI) will report a
-     * block size of zero.
-     */
-    if (card->sdio_if->blockSize == 0)
-    {
-        unifi_info(card->ospriv, "Block size 0, block mode not available\n");
-
-        /* Set sdio_io_block_size to 1 so that unifi_net_data_malloc() has a
-         * sensible rounding value. Elsewhere padding will already be
-         * disabled because the controller supports byte mode.
-         */
-        card->sdio_io_block_size = 1;
-
-        /* Controller features must declare support for byte mode */
-        if (!(card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE))
-        {
-            unifi_error(card->ospriv, "Requires byte mode\n");
-            r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-        }
-    }
-    else
-    {
-        /* Padding will be enabled if CSR_SDIO_FEATURE_BYTE_MODE isn't set */
-        card->sdio_io_block_size = card->sdio_if->blockSize;
-    }
-
-
-    return r;
-} /* unifi_reset_hardware() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_reset_method_io_enable
- *
- *      Issue a hard reset to the hw writing the IO_ENABLE.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      0 on success,
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE   if the card was ejected
- *      CSR_RESULT_FAILURE         if an SDIO error occurred or if a response
- *                                 was not seen in the expected time
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_reset_method_io_enable(card_t *card)
-{
-    CsrResult r;
-    CsrResult csrResult;
-
-    /*
-     * This resets only function 1, so should be used in
-     * preference to the method below (CSR_FUNC_EN)
-     */
-    unifi_trace(card->ospriv, UDBG1, "Hard reset (IO_ENABLE)\n");
-
-    csrResult = CsrSdioFunctionDisable(card->sdio_if);
-    if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-    }
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-        unifi_warning(card->ospriv, "SDIO error writing IO_ENABLE: %d\n", r);
-    }
-    else
-    {
-        /* Delay here to let the reset take affect. */
-        CsrThreadSleep(RESET_SETTLE_DELAY);
-
-        r = card_wait_for_unifi_to_disable(card);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-
-        if (r == CSR_RESULT_SUCCESS)
-        {
-            r = card_wait_for_unifi_to_reset(card);
-            if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                return r;
-            }
-        }
-    }
-
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_trace(card->ospriv, UDBG1, "Hard reset (CSR_FUNC_EN)\n");
-
-        r = sdio_write_f0(card, SDIO_CSR_FUNC_EN, 0);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_warning(card->ospriv, "SDIO error writing SDIO_CSR_FUNC_EN: %d\n", r);
-            return r;
-        }
-        else
-        {
-            /* Delay here to let the reset take affect. */
-            CsrThreadSleep(RESET_SETTLE_DELAY);
-
-            r = card_wait_for_unifi_to_reset(card);
-            if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                return r;
-            }
-        }
-    }
-
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_warning(card->ospriv, "card_reset_method_io_enable failed to reset UniFi\n");
-    }
-
-    return r;
-} /* card_reset_method_io_enable() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_reset_method_dbg_reset
- *
- *      Issue a hard reset to the hw writing the DBG_RESET.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS         on success,
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE   if the card was ejected
- *      CSR_RESULT_FAILURE         if an SDIO error occurred or if a response
- *                                 was not seen in the expected time
- * ---------------------------------------------------------------------------
- */
-static CsrResult card_reset_method_dbg_reset(card_t *card)
-{
-    CsrResult r;
-
-    /*
-     * Prepare UniFi for h/w reset
-     */
-    if (card->host_state == UNIFI_HOST_STATE_TORPID)
-    {
-        r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to set UNIFI_HOST_STATE_DROWSY\n");
-            return r;
-        }
-        CsrThreadSleep(5);
-    }
-
-    r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Can't stop processors\n");
-        return r;
-    }
-
-    unifi_trace(card->ospriv, UDBG1, "Hard reset (DBG_RESET)\n");
-
-    /*
-     * This register write may fail. The debug reset resets
-     * parts of the Function 0 sections of the chip, and
-     * therefore the response cannot be sent back to the host.
-     */
-    r = unifi_write_direct_8_or_16(card, ChipHelper_DBG_RESET(card->helper) * 2, 1);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_warning(card->ospriv, "SDIO error writing DBG_RESET: %d\n", r);
-        return r;
-    }
-
-    /* Delay here to let the reset take affect. */
-    CsrThreadSleep(RESET_SETTLE_DELAY);
-
-    r = card_wait_for_unifi_to_reset(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_warning(card->ospriv, "card_reset_method_dbg_reset failed to reset UniFi\n");
-    }
-
-    return r;
-} /* card_reset_method_dbg_reset() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_card_hard_reset
- *
- *      Issue reset to hardware, by writing to registers on the card.
- *      Power to the card is preserved.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS         on success,
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE   if the card was ejected
- *      CSR_RESULT_FAILURE         if an SDIO error occurred or if a response
- *                                 was not seen in the expected time
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_card_hard_reset(card_t *card)
-{
-    CsrResult r;
-    const struct chip_helper_reset_values *init_data;
-    u32 chunks;
-
-    /* Clear cache of page registers */
-    card->proc_select = (u32)(-1);
-    card->dmem_page = (u32)(-1);
-    card->pmem_page = (u32)(-1);
-
-    /*
-     * We need to have a valid card->helper before we use software hard reset.
-     * If unifi_identify_hw() fails to get the card ID, it probably means
-     * that there is no way to talk to the h/w.
-     */
-    r = unifi_identify_hw(card);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "unifi_card_hard_reset failed to identify h/w\n");
-        return r;
-    }
-
-    /* Search for some reset code. */
-    chunks = ChipHelper_HostResetSequence(card->helper, &init_data);
-    if (chunks != 0)
-    {
-        unifi_error(card->ospriv,
-                    "Hard reset (Code download) is unsupported\n");
-
-        return CSR_RESULT_FAILURE;
-    }
-
-    if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-    {
-        /* The HIP spec considers this a bus-specific reset.
-         * This resets only function 1, so should be used in
-         * preference to the method below (CSR_FUNC_EN)
-         * If this method fails, it means that the f/w is probably
-         * not running. In this case, try the DBG_RESET method.
-         */
-        r = card_reset_method_io_enable(card);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r == CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-    }
-
-    /* Software hard reset */
-    r = card_reset_method_dbg_reset(card);
-
-    return r;
-} /* unifi_card_hard_reset() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *
- *  CardGenInt
- *
- *      Prod the card.
- *      This function causes an internal interrupt to be raised in the
- *      UniFi chip. It is used to signal the firmware that some action has
- *      been completed.
- *      The UniFi Host Interface asks that the value used increments for
- *      debugging purposes.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS         on success,
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE   if the card was ejected
- *      CSR_RESULT_FAILURE         if an SDIO error occurred or if a response
- *                                 was not seen in the expected time
- * ---------------------------------------------------------------------------
- */
-CsrResult CardGenInt(card_t *card)
-{
-    CsrResult r;
-
-    if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-    {
-        r = sdio_write_f0(card, SDIO_CSR_FROM_HOST_SCRATCH0,
-                          (u8)card->unifi_interrupt_seq);
-    }
-    else
-    {
-        r = unifi_write_direct_8_or_16(card,
-                                       ChipHelper_SHARED_IO_INTERRUPT(card->helper) * 2,
-                                       (u8)card->unifi_interrupt_seq);
-    }
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error writing UNIFI_SHARED_IO_INTERRUPT: %d\n", r);
-        return r;
-    }
-
-    card->unifi_interrupt_seq++;
-
-    return CSR_RESULT_SUCCESS;
-} /* CardGenInt() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardEnableInt
- *
- *      Enable the outgoing SDIO interrupt from UniFi to the host.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS            on success,
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE      if the card was ejected
- *      CSR_RESULT_FAILURE            if an SDIO error occurred,
- * ---------------------------------------------------------------------------
- */
-CsrResult CardEnableInt(card_t *card)
-{
-    CsrResult r;
-    u8 int_enable;
-
-    r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
-        return r;
-    }
-
-    int_enable |= (1 << card->function) | UNIFI_SD_INT_ENABLE_IENM;
-
-    r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
-        return r;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CardEnableInt() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardDisableInt
- *
- *      Disable the outgoing SDIO interrupt from UniFi to the host.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS            on success,
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE      if the card was ejected
- *      CSR_RESULT_FAILURE            if an SDIO error occurred,
- * ---------------------------------------------------------------------------
- */
-CsrResult CardDisableInt(card_t *card)
-{
-    CsrResult r;
-    u8 int_enable;
-
-    r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
-        return r;
-    }
-
-    int_enable &= ~(1 << card->function);
-
-    r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
-        return r;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CardDisableInt() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardPendingInt
- *
- *      Determine whether UniFi is currently asserting the SDIO interrupt
- *      request.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *      pintr           Pointer to location to write interrupt status,
- *                          TRUE if interrupt pending,
- *                          FALSE if no interrupt pending.
- *  Returns:
- *      CSR_RESULT_SUCCESS            interrupt status read successfully
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE      if the card was ejected
- *      CSR_RESULT_FAILURE            if an SDIO error occurred,
- * ---------------------------------------------------------------------------
- */
-CsrResult CardPendingInt(card_t *card, u8 *pintr)
-{
-    CsrResult r;
-    u8 pending;
-
-    *pintr = FALSE;
-
-    r = sdio_read_f0(card, SDIO_INT_PENDING, &pending);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error reading SDIO_INT_PENDING\n");
-        return r;
-    }
-
-    *pintr = (pending & (1 << card->function))?TRUE : FALSE;
-
-    return CSR_RESULT_SUCCESS;
-} /* CardPendingInt() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardClearInt
- *
- *      Clear the UniFi SDIO interrupt request.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS          if pending interrupt was cleared, or no pending interrupt.
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE    if the card was ejected
- *      CSR_RESULT_FAILURE          if an SDIO error occurred,
- * ---------------------------------------------------------------------------
- */
-CsrResult CardClearInt(card_t *card)
-{
-    CsrResult r;
-    u8 intr;
-
-    if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-    {
-        /* CardPendingInt() sets intr, if there is a pending interrupt */
-        r = CardPendingInt(card, &intr);
-        if (intr == FALSE)
-        {
-            return r;
-        }
-
-        r = sdio_write_f0(card, SDIO_CSR_HOST_INT_CLEAR, 1);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "SDIO error writing SDIO_CSR_HOST_INT_CLEAR\n");
-        }
-    }
-    else
-    {
-        r = unifi_write_direct_8_or_16(card,
-                                       ChipHelper_SDIO_HOST_INT(card->helper) * 2,
-                                       0);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "SDIO error writing UNIFI_SDIO_HOST_INT\n");
-        }
-    }
-
-    return r;
-} /* CardClearInt() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardIntEnabled
- *
- *      Determine whether UniFi is currently asserting the SDIO interrupt
- *      request.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *      enabled         Pointer to location to write interrupt enable status,
- *                          TRUE if interrupts enabled,
- *                          FALSE if interupts disabled.
- *
- *  Returns:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE      if the card was ejected
- *      CSR_RESULT_FAILURE            if an SDIO error occurred,
- * ---------------------------------------------------------------------------
- */
-CsrResult CardIntEnabled(card_t *card, u8 *enabled)
-{
-    CsrResult r;
-    u8 int_enable;
-
-    r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
-        return r;
-    }
-
-    *enabled = (int_enable & (1 << card->function))?TRUE : FALSE;
-
-    return CSR_RESULT_SUCCESS;
-} /* CardIntEnabled() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CardWriteBulkData
- *      Allocate slot in the pending bulkdata arrays and assign it to a signal's
- *      bulkdata reference. The slot is then ready for UniFi's bulkdata commands
- *      to transfer the data to/from the host.
- *
- *  Arguments:
- *      card            Pointer to Card object
- *      csptr           Pending signal pointer, including bulkdata ref
- *      queue           Traffic queue that this signal is using
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS if a free slot was assigned
- *      CSR_RESULT_FAILURE if no slot was available
- * ---------------------------------------------------------------------------
- */
-CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue)
-{
-    u16 i, slots[UNIFI_MAX_DATA_REFERENCES], j = 0;
-    u8 *packed_sigptr, num_slots_required = 0;
-    bulk_data_desc_t *bulkdata = csptr->bulkdata;
-    s16 h, nslots;
-
-    /* Count the number of slots required */
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
-    {
-        if (bulkdata[i].data_length != 0)
-        {
-            num_slots_required++;
-        }
-    }
-
-    /* Get the slot numbers */
-    if (num_slots_required != 0)
-    {
-        /* Last 2 slots for MLME */
-        if (queue == UNIFI_TRAFFIC_Q_MLME)
-        {
-            h = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
-            for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
-            {
-                if (card->from_host_data[h].bd.data_length == 0)
-                {
-                    /* Free data slot, claim it */
-                    slots[j++] = h;
-                    if (j == num_slots_required)
-                    {
-                        break;
-                    }
-                }
-
-                if (++h >= card->config_data.num_fromhost_data_slots)
-                {
-                    h = 0;
-                }
-            }
-        }
-        else
-        {
-            if (card->dynamic_slot_data.from_host_used_slots[queue]
-                < card->dynamic_slot_data.from_host_max_slots[queue])
-            {
-                /* Data commands get a free slot only after a few checks */
-                nslots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
-
-                h = card->from_host_data_head;
-
-                for (i = 0; i < nslots; i++)
-                {
-                    if (card->from_host_data[h].bd.data_length == 0)
-                    {
-                        /* Free data slot, claim it */
-                        slots[j++] = h;
-                        if (j == num_slots_required)
-                        {
-                            break;
-                        }
-                    }
-
-                    if (++h >= nslots)
-                    {
-                        h = 0;
-                    }
-                }
-                card->from_host_data_head = h;
-            }
-        }
-
-        /* Required number of slots are not available, bail out */
-        if (j != num_slots_required)
-        {
-            unifi_trace(card->ospriv, UDBG5, "CardWriteBulkData: didn't find free slot/s\n");
-
-            /* If we haven't already reached the stable state we can ask for reservation */
-            if ((queue != UNIFI_TRAFFIC_Q_MLME) && (card->dynamic_slot_data.queue_stable[queue] == FALSE))
-            {
-                CardCheckDynamicReservation(card, queue);
-            }
-
-            for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
-            {
-                unifi_trace(card->ospriv, UDBG5, "fh data slot %d: %d\n", i, card->from_host_data[i].bd.data_length);
-            }
-            return CSR_RESULT_FAILURE;
-        }
-    }
-
-    packed_sigptr = csptr->sigbuf;
-
-    /* Fill in the slots with data */
-    j = 0;
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
-    {
-        if (bulkdata[i].data_length == 0)
-        {
-            /* Zero-out the DATAREF in the signal */
-            SET_PACKED_DATAREF_SLOT(packed_sigptr, i, 0);
-            SET_PACKED_DATAREF_LEN(packed_sigptr, i, 0);
-        }
-        else
-        {
-            /*
-             * Fill in the slot number in the SIGNAL structure but
-             * preserve the offset already in there
-             */
-            SET_PACKED_DATAREF_SLOT(packed_sigptr, i, slots[j] | (((u16)packed_sigptr[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1]) << 8));
-            SET_PACKED_DATAREF_LEN(packed_sigptr, i, bulkdata[i].data_length);
-
-            /* Do not copy the data, just store the information to them */
-            card->from_host_data[slots[j]].bd.os_data_ptr = bulkdata[i].os_data_ptr;
-            card->from_host_data[slots[j]].bd.os_net_buf_ptr = bulkdata[i].os_net_buf_ptr;
-            card->from_host_data[slots[j]].bd.data_length = bulkdata[i].data_length;
-            card->from_host_data[slots[j]].bd.net_buf_length = bulkdata[i].net_buf_length;
-            card->from_host_data[slots[j]].queue = queue;
-
-            unifi_trace(card->ospriv, UDBG4, "CardWriteBulkData sig=0x%x, fh slot %d = %p\n",
-                        GET_SIGNAL_ID(packed_sigptr), i, bulkdata[i].os_data_ptr);
-
-            /* Sanity-check that the bulk data desc being assigned to the slot
-             * actually has a payload.
-             */
-            if (!bulkdata[i].os_data_ptr)
-            {
-                unifi_error(card->ospriv, "Assign null os_data_ptr (len=%d) fh slot %d, i=%d, q=%d, sig=0x%x",
-                            bulkdata[i].data_length, slots[j], i, queue, GET_SIGNAL_ID(packed_sigptr));
-            }
-
-            j++;
-            if (queue < UNIFI_NO_OF_TX_QS)
-            {
-                card->dynamic_slot_data.from_host_used_slots[queue]++;
-            }
-        }
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /*  CardWriteBulkData() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_find_data_slot
- *
- *      Dereference references to bulk data slots into pointers to real data.
- *
- *  Arguments:
- *      card            Pointer to the card struct.
- *      slot            Slot number from a signal structure
- *
- *  Returns:
- *      Pointer to entry in bulk_data_slot array.
- * ---------------------------------------------------------------------------
- */
-bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot)
-{
-    s16 sn;
-    bulk_data_desc_t *bd;
-
-    sn = slot & 0x7FFF;
-
-    /* ?? check sanity of slot number ?? */
-
-    if (slot & SLOT_DIR_TO_HOST)
-    {
-        bd = &card->to_host_data[sn];
-    }
-    else
-    {
-        bd = &card->from_host_data[sn].bd;
-    }
-
-    return bd;
-} /* card_find_data_slot() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  firmware_present_in_flash
- *
- *      Probe for external Flash that looks like it might contain firmware.
- *
- *      If Flash is not present, reads always return 0x0008.
- *      If Flash is present, but empty, reads return 0xFFFF.
- *      Anything else is considered to be firmware.
- *
- *  Arguments:
- *      card        Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS                 firmware is present in ROM or flash
- *      CSR_WIFI_HIP_RESULT_NOT_FOUND      firmware is not present in ROM or flash
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE      if the card was ejected
- *      CSR_RESULT_FAILURE                 if an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-static CsrResult firmware_present_in_flash(card_t *card)
-{
-    CsrResult r;
-    u16 m1, m5;
-
-    if (ChipHelper_HasRom(card->helper))
-    {
-        return CSR_RESULT_SUCCESS;
-    }
-    if (!ChipHelper_HasFlash(card->helper))
-    {
-        return CSR_WIFI_HIP_RESULT_NOT_FOUND;
-    }
-
-    /*
-     * Examine the Flash locations that are the power-on default reset
-     * vectors of the XAP processors.
-     * These are words 1 and 5 in Flash.
-     */
-    r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 2), &m1);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 10), &m5);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    /* Check for uninitialised/missing flash */
-    if ((m1 == 0x0008) || (m1 == 0xFFFF) ||
-        (m1 == 0x0004) || (m5 == 0x0004) ||
-        (m5 == 0x0008) || (m5 == 0xFFFF))
-    {
-        return CSR_WIFI_HIP_RESULT_NOT_FOUND;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* firmware_present_in_flash() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  bootstrap_chip_hw
- *
- *      Perform chip specific magic to "Get It Working" TM.  This will
- *      increase speed of PLLs in analogue and maybe enable some
- *      on-chip regulators.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void bootstrap_chip_hw(card_t *card)
-{
-    const struct chip_helper_init_values *vals;
-    u32 i, len;
-    void *sdio = card->sdio_if;
-    CsrResult csrResult;
-
-    len = ChipHelper_ClockStartupSequence(card->helper, &vals);
-    if (len != 0)
-    {
-        for (i = 0; i < len; i++)
-        {
-            csrResult = CsrSdioWrite16(sdio, vals[i].addr * 2, vals[i].value);
-            if (csrResult != CSR_RESULT_SUCCESS)
-            {
-                unifi_warning(card->ospriv, "Failed to write bootstrap value %d\n", i);
-                /* Might not be fatal */
-            }
-
-            CsrThreadSleep(1);
-        }
-    }
-} /* bootstrap_chip_hw() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_card_stop_processor
- *
- *      Stop the UniFi XAP processors.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      which           One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS if successful, or CSR error code
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which)
-{
-    CsrResult r = CSR_RESULT_SUCCESS;
-    u8 status;
-    s16 retry = 100;
-
-    while (retry--)
-    {
-        /* Select both XAPs */
-        r = unifi_set_proc_select(card, which);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            break;
-        }
-
-        /* Stop processors */
-        r = unifi_write_direct16(card, ChipHelper_DBG_EMU_CMD(card->helper) * 2, 2);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            break;
-        }
-
-        /* Read status */
-        r = unifi_read_direct_8_or_16(card,
-                                      ChipHelper_DBG_HOST_STOP_STATUS(card->helper) * 2,
-                                      &status);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            break;
-        }
-
-        if ((status & 1) == 1)
-        {
-            /* Success! */
-            return CSR_RESULT_SUCCESS;
-        }
-
-        /* Processors didn't stop, try again */
-    }
-
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        /* An SDIO error occurred */
-        unifi_error(card->ospriv, "Failed to stop processors: SDIO error\n");
-    }
-    else
-    {
-        /* If we reach here, we didn't the status in time. */
-        unifi_error(card->ospriv, "Failed to stop processors: timeout waiting for stopped status\n");
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* unifi_card_stop_processor() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  card_start_processor
- *
- *      Start the UniFi XAP processors.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      which           One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS or CSR error code
- * ---------------------------------------------------------------------------
- */
-CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which)
-{
-    CsrResult r;
-
-    /* Select both XAPs */
-    r = unifi_set_proc_select(card, which);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "unifi_set_proc_select failed: %d.\n", r);
-        return r;
-    }
-
-
-    r = unifi_write_direct_8_or_16(card,
-                                   ChipHelper_DBG_EMU_CMD(card->helper) * 2, 8);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    r = unifi_write_direct_8_or_16(card,
-                                   ChipHelper_DBG_EMU_CMD(card->helper) * 2, 0);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* card_start_processor() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_set_interrupt_mode
- *
- *      Configure the interrupt processing mode used by the HIP
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      mode            Interrupt mode to apply
- *
- *  Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-void unifi_set_interrupt_mode(card_t *card, u32 mode)
-{
-    if (mode == CSR_WIFI_INTMODE_RUN_BH_ONCE)
-    {
-        unifi_info(card->ospriv, "Scheduled interrupt mode");
-    }
-    card->intmode = mode;
-} /* unifi_set_interrupt_mode() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_start_processors
- *
- *      Start all UniFi XAP processors.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on error
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_start_processors(card_t *card)
-{
-    return card_start_processor(card, UNIFI_PROC_BOTH);
-} /* unifi_start_processors() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_request_max_sdio_clock
- *
- *      Requests that the maximum SDIO clock rate is set at the next suitable
- *      opportunity (e.g. when the BH next runs, so as not to interfere with
- *      any current operation).
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-void unifi_request_max_sdio_clock(card_t *card)
-{
-    card->request_max_clock = 1;
-} /* unifi_request_max_sdio_clock() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_set_host_state
- *
- *      Set the host deep-sleep state.
- *
- *      If transitioning to TORPID, the SDIO driver will be notified
- *      that the SD bus will be unused (idle) and conversely, when
- *      transitioning from TORPID that the bus will be used (active).
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      state           New deep-sleep state.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS            on success
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE      if the card was ejected
- *      CSR_RESULT_FAILURE            if an SDIO error occurred
- *
- *  Notes:
- *      We need to reduce the SDIO clock speed before trying to wake up the
- *      chip. Actually, in the implementation below we reduce the clock speed
- *      not just before we try to wake up the chip, but when we put the chip to
- *      deep sleep. This means that if the f/w wakes up on its' own, we waste
- *      a reduce/increace cycle. However, trying to eliminate this overhead is
- *      proved difficult, as the current state machine in the HIP lib does at
- *      least a CMD52 to disable the interrupts before we configure the host
- *      state.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state)
-{
-    CsrResult r = CSR_RESULT_SUCCESS;
-    CsrResult csrResult;
-    static const char *const states[] = {
-        "AWAKE", "DROWSY", "TORPID"
-    };
-    static const u8 state_csr_host_wakeup[] = {
-        1, 3, 0
-    };
-    static const u8 state_io_abort[] = {
-        0, 2, 3
-    };
-
-    unifi_trace(card->ospriv, UDBG4, "State %s to %s\n",
-                states[card->host_state], states[state]);
-
-    if (card->host_state == UNIFI_HOST_STATE_TORPID)
-    {
-        CsrSdioFunctionActive(card->sdio_if);
-    }
-
-    /* Write the new state to UniFi. */
-    if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-    {
-        r = sdio_write_f0(card, SDIO_CSR_HOST_WAKEUP,
-                          (u8)((card->function << 4) | state_csr_host_wakeup[state]));
-    }
-    else
-    {
-        r = sdio_write_f0(card, SDIO_IO_ABORT, state_io_abort[state]);
-    }
-
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write UniFi deep sleep state\n");
-    }
-    else
-    {
-        /*
-         * If the chip was in state TORPID then we can now increase
-         * the maximum bus clock speed.
-         */
-        if (card->host_state == UNIFI_HOST_STATE_TORPID)
-        {
-            csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
-                                                       UNIFI_SDIO_CLOCK_MAX_HZ);
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            /* Non-fatal error */
-            if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                unifi_warning(card->ospriv,
-                              "Failed to increase the SDIO clock speed\n");
-            }
-            else
-            {
-                card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ;
-            }
-        }
-
-        /*
-         * Cache the current state in the card structure to avoid
-         * unnecessary SDIO reads.
-         */
-        card->host_state = state;
-
-        if (state == UNIFI_HOST_STATE_TORPID)
-        {
-            /*
-             * If the chip is now in state TORPID then we must now decrease
-             * the maximum bus clock speed.
-             */
-            csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
-                                                       UNIFI_SDIO_CLOCK_SAFE_HZ);
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                unifi_warning(card->ospriv,
-                              "Failed to decrease the SDIO clock speed\n");
-            }
-            else
-            {
-                card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
-            }
-            CsrSdioFunctionIdle(card->sdio_if);
-        }
-    }
-
-    return r;
-} /* unifi_set_host_state() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_card_info
- *
- *      Update the card information data structure
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      card_info       Pointer to info structure to update
- *
- *  Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-void unifi_card_info(card_t *card, card_info_t *card_info)
-{
-    card_info->chip_id = card->chip_id;
-    card_info->chip_version = card->chip_version;
-    card_info->fw_build = card->build_id;
-    card_info->fw_hip_version = card->config_data.version;
-    card_info->sdio_block_size = card->sdio_io_block_size;
-} /* unifi_card_info() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_check_io_status
- *
- *      Check UniFi for spontaneous reset and pending interrupt.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      status          Pointer to location to write chip status:
- *                        0 if UniFi is running, and no interrupt pending
- *                        1 if UniFi has spontaneously reset
- *                        2 if there is a pending interrupt
- *  Returns:
- *      CSR_RESULT_SUCCESS if OK, or CSR error
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_check_io_status(card_t *card, s32 *status)
-{
-    u8 io_en;
-    CsrResult r;
-    u8 pending;
-
-    *status = 0;
-
-    r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_en);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read SDIO_IO_ENABLE to check for spontaneous reset\n");
-        return r;
-    }
-
-    if ((io_en & (1 << card->function)) == 0)
-    {
-        s32 fw_count;
-        *status = 1;
-        unifi_error(card->ospriv, "UniFi has spontaneously reset.\n");
-
-        /*
-         * These reads are very likely to fail. We want to know if the function is really
-         * disabled or the SDIO driver just returns rubbish.
-         */
-        fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
-        if (fw_count < 0)
-        {
-            unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
-        }
-        else
-        {
-            unifi_error(card->ospriv, "thsw: %u (driver thinks is %u)\n",
-                        fw_count, card->to_host_signals_w);
-        }
-        fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
-        if (fw_count < 0)
-        {
-            unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
-        }
-        else
-        {
-            unifi_error(card->ospriv, "fhsr: %u (driver thinks is %u)\n",
-                        fw_count, card->from_host_signals_r);
-        }
-
-        return r;
-    }
-
-    unifi_info(card->ospriv, "UniFi function %d is enabled.\n", card->function);
-
-    /* See if we missed an SDIO interrupt */
-    r = CardPendingInt(card, &pending);
-    if (pending)
-    {
-        unifi_error(card->ospriv, "There is an unhandled pending interrupt.\n");
-        *status = 2;
-        return r;
-    }
-
-    return r;
-} /* unifi_check_io_status() */
-
-
-void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo)
-{
-    s32 count_fhr;
-    s16 t;
-    u32 occupied_fh;
-
-    q_t *sigq;
-    u16 nslots, i;
-
-    memset(hipqosinfo, 0, sizeof(unifi_HipQosInfo));
-
-    nslots = card->config_data.num_fromhost_data_slots;
-
-    for (i = 0; i < nslots; i++)
-    {
-        if (card->from_host_data[i].bd.data_length == 0)
-        {
-            hipqosinfo->free_fh_bulkdata_slots++;
-        }
-    }
-
-    for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-    {
-        sigq = &card->fh_traffic_queue[i];
-        t = sigq->q_wr_ptr - sigq->q_rd_ptr;
-        if (t < 0)
-        {
-            t += sigq->q_length;
-        }
-        hipqosinfo->free_fh_sig_queue_slots[i] = (sigq->q_length - t) - 1;
-    }
-
-    count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
-    if (count_fhr < 0)
-    {
-        unifi_error(card->ospriv, "Failed to read from-host sig read count - %d\n", count_fhr);
-        hipqosinfo->free_fh_fw_slots = 0xfa;
-        return;
-    }
-
-    occupied_fh = (card->from_host_signals_w - count_fhr) % 128;
-
-    hipqosinfo->free_fh_fw_slots = (u16)(card->config_data.num_fromhost_sig_frags - occupied_fh);
-}
-
-
-
-CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult)
-{
-    CsrResult r = CSR_RESULT_FAILURE;
-
-    switch (csrResult)
-    {
-        case CSR_RESULT_SUCCESS:
-            r = CSR_RESULT_SUCCESS;
-            break;
-        /* Timeout errors */
-        case CSR_SDIO_RESULT_TIMEOUT:
-        /* Integrity errors */
-        case CSR_SDIO_RESULT_CRC_ERROR:
-            r = CSR_RESULT_FAILURE;
-            break;
-        case CSR_SDIO_RESULT_NO_DEVICE:
-            r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
-            break;
-        case CSR_SDIO_RESULT_INVALID_VALUE:
-            r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            break;
-        case CSR_RESULT_FAILURE:
-            r = CSR_RESULT_FAILURE;
-            break;
-        default:
-            unifi_warning(card->ospriv, "Unrecognised csrResult error code: %d\n", csrResult);
-            break;
-    }
-
-    return r;
-} /* ConvertCsrSdioToCsrHipResult() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.h b/drivers/staging/csr/csr_wifi_hip_card_sdio.h
deleted file mode 100644 (file)
index a9b9ec4..0000000
+++ /dev/null
@@ -1,694 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *
- *  FILE:     csr_wifi_hip_card_sdio.h
- *
- *  PURPOSE:
- *      Internal header for Card API for SDIO.
- * ---------------------------------------------------------------------------
- */
-#ifndef __CARD_SDIO_H__
-#define __CARD_SDIO_H__
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_unifi_udi.h"
-#include "csr_wifi_hip_unifihw.h"
-#include "csr_wifi_hip_unifiversion.h"
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-#include "csr_wifi_hip_ta_sampling.h"
-#endif
-#include "csr_wifi_hip_xbv.h"
-#include "csr_wifi_hip_chiphelper.h"
-
-
-/*
- *
- * Configuration items.
- * Which of these should go in a platform unifi_config.h file?
- *
- */
-
-/*
- * When the traffic queues contain more signals than there is space for on
- * UniFi, a limiting algorithm comes into play.
- * If a traffic queue has enough slots free to buffer more traffic from the
- * network stack, then the following check is applied. The number of free
- * slots is RESUME_XMIT_THRESHOLD.
- */
-#define RESUME_XMIT_THRESHOLD           4
-
-
-/*
- * When reading signals from UniFi, the host processes pending all signals
- * and then acknowledges them together in a single write to update the
- * to-host-chunks-read location.
- * When there is more than one bulk data transfer (e.g. one received data
- * packet and a request for the payload data of a transmitted packet), the
- * update can be delayed significantly. This ties up resources on chip.
- *
- * To remedy this problem, to-host-chunks-read is updated after processing
- * a signal if TO_HOST_FLUSH_THRESHOLD bytes of bulk data have been
- * transferred since the last update.
- */
-#define TO_HOST_FLUSH_THRESHOLD (500 * 5)
-
-
-/* SDIO Card Common Control Registers */
-#define SDIO_CCCR_SDIO_REVISION     (0x00)
-#define SDIO_SD_SPEC_REVISION       (0x01)
-#define SDIO_IO_ENABLE              (0x02)
-#define SDIO_IO_READY               (0x03)
-#define SDIO_INT_ENABLE             (0x04)
-#define SDIO_INT_PENDING            (0x05)
-#define SDIO_IO_ABORT               (0x06)
-#define SDIO_BUS_IFACE_CONTROL      (0x07)
-#define SDIO_CARD_CAPABILOTY        (0x08)
-#define SDIO_COMMON_CIS_POINTER     (0x09)
-#define SDIO_BUS_SUSPEND            (0x0C)
-#define SDIO_FUNCTION_SELECT        (0x0D)
-#define SDIO_EXEC_FLAGS             (0x0E)
-#define SDIO_READY_FLAGS            (0x0F)
-#define SDIO_FN0_BLOCK_SIZE         (0x10)
-#define SDIO_POWER_CONTROL          (0x12)
-#define SDIO_VENDOR_START           (0xF0)
-
-#define SDIO_CSR_HOST_WAKEUP        (0xf0)
-#define SDIO_CSR_HOST_INT_CLEAR     (0xf1)
-#define SDIO_CSR_FROM_HOST_SCRATCH0 (0xf2)
-#define SDIO_CSR_FROM_HOST_SCRATCH1 (0xf3)
-#define SDIO_CSR_TO_HOST_SCRATCH0   (0xf4)
-#define SDIO_CSR_TO_HOST_SCRATCH1   (0xf5)
-#define SDIO_CSR_FUNC_EN            (0xf6)
-#define SDIO_CSR_CSPI_MODE          (0xf7)
-#define SDIO_CSR_CSPI_STATUS        (0xf8)
-#define SDIO_CSR_CSPI_PADDING       (0xf9)
-
-
-#define UNIFI_SD_INT_ENABLE_IENM 0x0001    /* Master INT Enable */
-
-#ifdef CSR_PRE_ALLOC_NET_DATA
-#define BULK_DATA_PRE_ALLOC_NUM 16
-#endif
-
-/*
- * Structure to hold configuration information read from UniFi.
- */
-typedef struct
-{
-    /*
-     * The version of the SDIO signal queues and bulk data pools
-     * configuration structure. The MSB is the major version number, used to
-     * indicate incompatible changes. The LSB gives the minor revision number,
-     * used to indicate changes that maintain backwards compatibility.
-     */
-    u16 version;
-
-    /*
-     * offset from the start of the shared data memory to the SD IO
-     * control structure.
-     */
-    u16 sdio_ctrl_offset;
-
-    /* Buffer handle of the from-host signal queue */
-    u16 fromhost_sigbuf_handle;
-
-    /* Buffer handle of the to-host signal queue */
-    u16 tohost_sigbuf_handle;
-
-    /*
-     * Maximum number of signal primitive or bulk data command fragments that may be
-     * pending in the to-hw signal queue.
-     */
-    u16 num_fromhost_sig_frags;
-
-    /*
-     * Number of signal primitive or bulk data command fragments that must be pending
-     * in the to-host signal queue before the host will generate an interrupt
-     * to indicate that it has read a signal. This will usually be the total
-     * capacity of the to-host signal buffer less the size of the largest signal
-     * primitive divided by the signal primitive fragment size, but may be set
-     * to 1 to request interrupts every time that the host read a signal.
-     * Note that the hw may place more signals in the to-host signal queue
-     * than indicated by this field.
-     */
-    u16 num_tohost_sig_frags;
-
-    /*
-     * Number of to-hw bulk data slots. Slots are numbered from 0 (zero) to
-     * one less than the value in this field
-     */
-    u16 num_fromhost_data_slots;
-
-    /*
-     * Number of frm-hw bulk data slots. Slots are numbered from 0 (zero) to
-     * one less than the value in this field
-     */
-    u16 num_tohost_data_slots;
-
-    /*
-     * Size of the bulk data slots (2 octets)
-     * The size of the bulk data slots in octets. This will usually be
-     * the size of the largest MSDU. The value should always be even.
-     */
-    u16 data_slot_size;
-
-    /*
-     * Indicates that the host has finished the initialisation sequence.
-     * Initialised to 0x0000 by the firmware, and set to 0x0001 by us.
-     */
-    u16 initialised;
-
-    /* Added by protocol version 0x0001 */
-    u32 overlay_size;
-
-    /* Added by protocol version 0x0300 */
-    u16 data_slot_round;
-    u16 sig_frag_size;
-
-    /* Added by protocol version 0x0500 */
-    u16 tohost_signal_padding;
-} sdio_config_data_t;
-
-/*
- * These values may change with versions of the Host Interface Protocol.
- */
-/*
- * Size of config info block pointed to by the CSR_SLT_SDIO_SLOT_CONFIG
- * entry in the f/w symbol table
- */
-#define SDIO_CONFIG_DATA_SIZE 30
-
-/* Offset of the INIT flag in the config info block. */
-#define SDIO_INIT_FLAG_OFFSET 0x12
-#define SDIO_TO_HOST_SIG_PADDING_OFFSET 0x1C
-
-
-/* Structure for a bulk data transfer command */
-typedef struct
-{
-    u16 cmd_and_len;   /* bits 12-15 cmd, bits 0-11 len */
-    u16 data_slot;     /* slot number, perhaps OR'd with SLOT_DIR_TO_HOST */
-    u16 offset;
-    u16 buffer_handle;
-} bulk_data_cmd_t;
-
-
-/* Bulk Data signal command values */
-#define SDIO_CMD_SIGNAL                 0x00
-#define SDIO_CMD_TO_HOST_TRANSFER       0x01
-#define SDIO_CMD_TO_HOST_TRANSFER_ACK   0x02 /*deprecated*/
-#define SDIO_CMD_FROM_HOST_TRANSFER     0x03
-#define SDIO_CMD_FROM_HOST_TRANSFER_ACK 0x04 /*deprecated*/
-#define SDIO_CMD_CLEAR_SLOT             0x05
-#define SDIO_CMD_OVERLAY_TRANSFER       0x06
-#define SDIO_CMD_OVERLAY_TRANSFER_ACK   0x07 /*deprecated*/
-#define SDIO_CMD_FROM_HOST_AND_CLEAR    0x08
-#define SDIO_CMD_PADDING                0x0f
-
-#define SLOT_DIR_TO_HOST 0x8000
-
-
-/* Initialise bulkdata slot
- *  params:
- *      bulk_data_desc_t *bulk_data_slot
- */
-#define UNIFI_INIT_BULK_DATA(bulk_data_slot)        \
-    {                                               \
-        (bulk_data_slot)->os_data_ptr = NULL;       \
-        (bulk_data_slot)->data_length = 0;          \
-        (bulk_data_slot)->os_net_buf_ptr = NULL;    \
-        (bulk_data_slot)->net_buf_length = 0;       \
-    }
-
-/*
- * Structure to contain a SIGNAL datagram.
- * This is used to build signal queues between the main driver and the
- * i/o thread.
- * The fields are:
- *      sigbuf          Contains the HIP signal is wire-format (i.e. packed,
- *                      little-endian)
- *      bulkdata        Contains a copy of any associated bulk data
- *      signal_length   The size of the signal in the sigbuf
- */
-typedef struct card_signal
-{
-    u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
-
-    /* Length of the SIGNAL inside sigbuf */
-    u16 signal_length;
-
-    bulk_data_desc_t bulkdata[UNIFI_MAX_DATA_REFERENCES];
-} card_signal_t;
-
-
-/*
- * Control structure for a generic ring buffer.
- */
-#define UNIFI_QUEUE_NAME_MAX_LENGTH     16
-typedef struct
-{
-    card_signal_t *q_body;
-
-    /* Num elements in queue (capacity is one less than this!) */
-    u16 q_length;
-
-    u16 q_wr_ptr;
-    u16 q_rd_ptr;
-
-    char name[UNIFI_QUEUE_NAME_MAX_LENGTH];
-} q_t;
-
-
-#define UNIFI_RESERVED_COMMAND_SLOTS   2
-
-/* Considering approx 500 us per packet giving 0.5 secs */
-#define UNIFI_PACKETS_INTERVAL         1000
-
-/*
- * Dynamic slot reservation for QoS
- */
-typedef struct
-{
-    u16 from_host_used_slots[UNIFI_NO_OF_TX_QS];
-    u16 from_host_max_slots[UNIFI_NO_OF_TX_QS];
-    u16 from_host_reserved_slots[UNIFI_NO_OF_TX_QS];
-
-    /* Parameters to determine if a queue was active.
-       If number of packets sent is greater than the threshold
-       for the queue, the queue is considered active and no
-       re reservation is done, it is important not to keep this
-       value too low */
-    /* Packets sent during this interval */
-    u16 packets_txed[UNIFI_NO_OF_TX_QS];
-    u16 total_packets_txed;
-
-    /* Number of packets to see if slots need to be reassigned */
-    u16 packets_interval;
-
-    /* Once a queue reaches a stable state, avoid processing */
-    u8 queue_stable[UNIFI_NO_OF_TX_QS];
-} card_dynamic_slot_t;
-
-
-/* These are type-safe and don't write incorrect values to the
- * structure. */
-
-/* Return queue slots used count
- *  params:
- *      const q_t *q
- *  returns:
- *      u16
- */
-#define CSR_WIFI_HIP_Q_SLOTS_USED(q)     \
-    (((q)->q_wr_ptr - (q)->q_rd_ptr < 0)? \
-     ((q)->q_wr_ptr - (q)->q_rd_ptr + (q)->q_length) : ((q)->q_wr_ptr - (q)->q_rd_ptr))
-
-/* Return queue slots free count
- *  params:
- *      const q_t *q
- *  returns:
- *      u16
- */
-#define CSR_WIFI_HIP_Q_SLOTS_FREE(q)     \
-    ((q)->q_length - CSR_WIFI_HIP_Q_SLOTS_USED((q)) - 1)
-
-/* Return slot signal data pointer
- *  params:
- *      const q_t *q
- *      u16 slot
- *  returns:
- *      card_signal_t *
- */
-#define CSR_WIFI_HIP_Q_SLOT_DATA(q, slot)    \
-    ((q)->q_body + slot)
-
-/* Return queue next read slot
- *  params:
- *      const q_t *q
- *  returns:
- *      u16 slot offset
- */
-#define CSR_WIFI_HIP_Q_NEXT_R_SLOT(q)    \
-    ((q)->q_rd_ptr)
-
-/* Return queue next write slot
- *  params:
- *      const q_t *q
- *  returns:
- *      u16 slot offset
- */
-#define CSR_WIFI_HIP_Q_NEXT_W_SLOT(q)    \
-    ((q)->q_wr_ptr)
-
-/* Return updated queue pointer wrapped around its length
- *  params:
- *      const q_t *q
- *      u16 x     amount to add to queue pointer
- *  returns:
- *      u16 wrapped queue pointer
- */
-#define CSR_WIFI_HIP_Q_WRAP(q, x)    \
-    ((((x) >= (q)->q_length)?((x) % (q)->q_length) : (x)))
-
-/* Advance queue read pointer
- *  params:
- *      const q_t *q
- */
-#define CSR_WIFI_HIP_Q_INC_R(q)  \
-    ((q)->q_rd_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_rd_ptr + 1))
-
-/* Advance queue write pointer
- *  params:
- *      const q_t *q
- */
-#define CSR_WIFI_HIP_Q_INC_W(q)  \
-    ((q)->q_wr_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_wr_ptr + 1))
-
-enum unifi_host_state
-{
-    UNIFI_HOST_STATE_AWAKE   = 0,
-    UNIFI_HOST_STATE_DROWSY  = 1,
-    UNIFI_HOST_STATE_TORPID  = 2
-};
-
-typedef struct
-{
-    bulk_data_desc_t   bd;
-    unifi_TrafficQueue queue; /* Used for dynamic slot reservation */
-} slot_desc_t;
-
-/*
- * Structure describing a UniFi SDIO card.
- */
-struct card
-{
-    /*
-     * Back pointer for the higher level OS code. This is passed as
-     * an argument to callbacks (e.g. for received data and indications).
-     */
-    void *ospriv;
-
-    /*
-     * mapping of HIP slot to MA-PACKET.req host tag, the
-     * array is indexed by slot numbers and each index stores
-     * information of the last host tag it was used for
-     */
-    u32 *fh_slot_host_tag_record;
-
-
-    /* Info read from Symbol Table during probe */
-    u32     build_id;
-    char build_id_string[128];
-
-    /* Retrieve from SDIO driver. */
-    u16 chip_id;
-
-    /* Read from GBL_CHIP_VERSION. */
-    u16 chip_version;
-
-    /* From the SDIO driver (probably 1) */
-    u8 function;
-
-    /* This is sused to get the register addresses and things. */
-    ChipDescript *helper;
-
-    /*
-     * Bit mask of PIOs for the loader to waggle during download.
-     * We assume these are connected to LEDs. The main firmware gets
-     * the mask from a MIB entry.
-     */
-    s32 loader_led_mask;
-
-    /*
-     * Support for flow control. When the from-host queue of signals
-     * is full, we ask the host upper layer to stop sending packets. When
-     * the queue drains we tell it that it can send packets again.
-     * We use this flag to remember the current state.
-     */
-#define card_is_tx_q_paused(card, q)   (card->tx_q_paused_flag[q])
-#define card_tx_q_unpause(card, q)   (card->tx_q_paused_flag[q] = 0)
-#define card_tx_q_pause(card, q)   (card->tx_q_paused_flag[q] = 1)
-
-    u16 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX + 1 + UNIFI_NO_OF_TX_QS]; /* defensive more than big enough */
-
-    /* UDI callback for logging UniFi interactions */
-    udi_func_t udi_hook;
-
-    u8 bh_reason_host;
-    u8 bh_reason_unifi;
-
-    /* SDIO clock speed request from OS layer */
-    u8 request_max_clock;
-
-    /* Last SDIO clock frequency set */
-    u32 sdio_clock_speed;
-
-    /*
-     * Current host state (copy of value in IOABORT register and
-     * spinlock to protect it.
-     */
-    enum unifi_host_state host_state;
-
-    enum unifi_low_power_mode     low_power_mode;
-    enum unifi_periodic_wake_mode periodic_wake_mode;
-
-    /*
-     * Ring buffer of signal structs for a queue of data packets from
-     * the host.
-     * The queue is empty when fh_data_q_num_rd == fh_data_q_num_wr.
-     * To add a packet to the queue, copy it to index given by
-     * (fh_data_q_num_wr%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_wr.
-     * To take a packet from the queue, copy data from index given by
-     * (fh_data_q_num_rd%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_rd.
-     * fh_data_q_num_rd and fh_data_q_num_rd are both modulo 256.
-     */
-    card_signal_t fh_command_q_body[UNIFI_SOFT_COMMAND_Q_LENGTH];
-    q_t           fh_command_queue;
-
-    card_signal_t fh_traffic_q_body[UNIFI_NO_OF_TX_QS][UNIFI_SOFT_TRAFFIC_Q_LENGTH];
-    q_t           fh_traffic_queue[UNIFI_NO_OF_TX_QS];
-
-    /*
-     * Signal counts from UniFi SDIO Control Data Structure.
-     * These are cached and synchronised with the UniFi before and after
-     * a batch of operations.
-     *
-     * These are the modulo-256 count of signals written to or read from UniFi
-     * The value is incremented for every signal.
-     */
-    s32 from_host_signals_w;
-    s32 from_host_signals_r;
-    s32 to_host_signals_r;
-    s32 to_host_signals_w;
-
-
-    /* Should specify buffer size as a number of signals */
-    /*
-     * Enough for 10 th and 10 fh data slots:
-     *   1 * 10 * 8 =  80
-     *   2 * 10 * 8 = 160
-     */
-#define UNIFI_FH_BUF_SIZE 1024
-    struct sigbuf
-    {
-        u8 *buf;     /* buffer area */
-        u8 *ptr;     /* current pos */
-        u16 count;   /* signal count */
-        u16 bufsize;
-    } fh_buffer;
-    struct sigbuf th_buffer;
-
-
-    /*
-     * Field to use for the incrementing value to write to the UniFi
-     * SHARED_IO_INTERRUPT register.
-     * Flag to say we need to generate an interrupt at end of processing.
-     */
-    u32 unifi_interrupt_seq;
-    u8  generate_interrupt;
-
-
-    /* Pointers to the bulk data slots */
-    slot_desc_t      *from_host_data;
-    bulk_data_desc_t *to_host_data;
-
-
-    /*
-     * Index of the next (hopefully) free data slot.
-     * This is an optimisation that starts searching at a more likely point
-     * than the beginning.
-     */
-    s16 from_host_data_head;
-
-    /* Dynamic slot allocation for queues */
-    card_dynamic_slot_t dynamic_slot_data;
-
-    /*
-     * SDIO specific fields
-     */
-
-    /* Interface pointer for the SDIO library */
-    CsrSdioFunction *sdio_if;
-
-    /* Copy of config_data struct from the card */
-    sdio_config_data_t config_data;
-
-    /* SDIO address of the Initialised flag and Control Data struct */
-    u32 init_flag_addr;
-    u32 sdio_ctrl_addr;
-
-    /* The last value written to the Shared Data Memory Page register */
-    u32 proc_select;
-    u32 dmem_page;
-    u32 pmem_page;
-
-    /* SDIO traffic counters limited to 32 bits for Synergy compatibility */
-    u32 sdio_bytes_read;
-    u32 sdio_bytes_written;
-
-    u8 memory_resources_allocated;
-
-    /* UniFi SDIO I/O Block size. */
-    u16 sdio_io_block_size;
-
-    /* Pad transfer sizes to SDIO block boundaries */
-    u8 sdio_io_block_pad;
-
-    /* Read from the XBV */
-    struct FWOV fwov;
-
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-    /* TA sampling */
-    ta_data_t ta_sampling;
-#endif
-
-    /* Auto-coredump */
-    s16             request_coredump_on_reset; /* request coredump on next reset */
-    struct coredump_buf *dump_buf;                  /* root node */
-    struct coredump_buf *dump_next_write;           /* node to fill at next dump */
-    struct coredump_buf *dump_cur_read;             /* valid node to read, or NULL */
-
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-    struct cmd_profile
-    {
-        u32 cmd52_count;
-        u32 cmd53_count;
-        u32 tx_count;
-        u32 tx_cfm_count;
-        u32 rx_count;
-        u32 bh_count;
-        u32 process_count;
-        u32 protocol_count;
-
-        u32 cmd52_f0_r_count;
-        u32 cmd52_f0_w_count;
-        u32 cmd52_r8or16_count;
-        u32 cmd52_w8or16_count;
-        u32 cmd52_r16_count;
-        u32 cmd52_w16_count;
-        u32 cmd52_r32_count;
-
-        u32 sdio_cmd_signal;
-        u32 sdio_cmd_clear_slot;
-        u32 sdio_cmd_to_host;
-        u32 sdio_cmd_from_host;
-        u32 sdio_cmd_from_host_and_clear;
-    } hip_prof;
-    struct cmd_profile cmd_prof;
-#endif
-
-    /* Interrupt processing mode flags */
-    u32 intmode;
-
-#ifdef UNIFI_DEBUG
-    u8 lsb;
-#endif
-
-    /* Historic firmware panic codes */
-    u32 panic_data_phy_addr;
-    u32 panic_data_mac_addr;
-    u16 last_phy_panic_code;
-    u16 last_phy_panic_arg;
-    u16 last_mac_panic_code;
-    u16 last_mac_panic_arg;
-#ifdef CSR_PRE_ALLOC_NET_DATA
-    bulk_data_desc_t bulk_data_desc_list[BULK_DATA_PRE_ALLOC_NUM];
-    u16        prealloc_netdata_r;
-    u16        prealloc_netdata_w;
-#endif
-}; /* struct card */
-
-
-/* Reset types */
-enum unifi_reset_type
-{
-    UNIFI_COLD_RESET = 1,
-    UNIFI_WARM_RESET = 2
-};
-
-/*
- * unifi_set_host_state() implements signalling for waking UniFi from
- * deep sleep. The host indicates to UniFi that it is in one of three states:
- *   Torpid - host has nothing to send, UniFi can go to sleep.
- *   Drowsy - host has data to send to UniFi. UniFi will respond with an
- *            SDIO interrupt. When hosts responds it moves to Awake.
- *   Awake  - host has data to transfer, UniFi must stay awake.
- *            When host has finished, it moves to Torpid.
- */
-CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state);
-
-
-CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select);
-s32 card_read_signal_counts(card_t *card);
-bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot);
-
-
-CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata);
-CsrResult unifi_readnz(card_t *card, u32 unifi_addr,
-                       void *pdata, u16 len);
-s32 unifi_read_shared_count(card_t *card, u32 addr);
-
-CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len);
-
-CsrResult unifi_bulk_rw(card_t *card, u32 handle,
-                        void *pdata, u32 len, s16 direction);
-CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle,
-                                void *pdata, u32 len, s16 direction);
-#define UNIFI_SDIO_READ       0
-#define UNIFI_SDIO_WRITE      1
-
-CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata);
-CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data);
-CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata);
-CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data);
-
-CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata);
-CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata);
-CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len);
-
-CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data);
-CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len);
-
-CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata);
-CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data);
-
-void unifi_read_panic(card_t *card);
-#ifdef CSR_PRE_ALLOC_NET_DATA
-void prealloc_netdata_free(card_t *card);
-CsrResult prealloc_netdata_alloc(card_t *card);
-#endif
-/* For diagnostic use */
-void dump(void *mem, u16 len);
-void dump16(void *mem, u16 len);
-
-#endif /* __CARD_SDIO_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c b/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c
deleted file mode 100644 (file)
index cfe186e..0000000
+++ /dev/null
@@ -1,2595 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     csr_wifi_hip_card_sdio_intr.c
- *
- *  PURPOSE:
- *      Interrupt processing for the UniFi SDIO driver.
- *
- *      We may need another signal queue of responses to UniFi to hold
- *      bulk data commands generated by read_to_host_signals().
- *
- * ---------------------------------------------------------------------------
- */
-#undef CSR_WIFI_HIP_NOISY
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "csr_wifi_hip_card.h"
-#include "csr_wifi_hip_xbv.h"
-
-
-/*
- * If the SDIO link is idle for this time (in milliseconds),
- * signal UniFi to go into Deep Sleep.
- * Valid return value of unifi_bh().
- */
-#define UNIFI_DEFAULT_HOST_IDLE_TIMEOUT 5
-/*
- * If the UniFi has not woken up for this time (in milliseconds),
- * signal the bottom half to take action.
- * Valid return value of unifi_bh().
- */
-#define UNIFI_DEFAULT_WAKE_TIMEOUT      1000
-
-
-static CsrResult process_bh(card_t *card);
-static CsrResult handle_host_protocol(card_t *card, u8 *processed_something);
-
-static CsrResult flush_fh_buffer(card_t *card);
-
-static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space);
-
-static CsrResult read_to_host_signals(card_t *card, s32 *processed);
-static CsrResult process_to_host_signals(card_t *card, s32 *processed);
-
-static CsrResult process_bulk_data_command(card_t *card,
-                                           const u8 *cmdptr,
-                                           s16 cmd, u16 len);
-static CsrResult process_clear_slot_command(card_t         *card,
-                                            const u8 *cmdptr);
-static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed);
-static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed);
-static void restart_packet_flow(card_t *card);
-static CsrResult process_clock_request(card_t *card);
-
-#ifdef CSR_WIFI_HIP_NOISY
-s16 dump_fh_buf = 0;
-#endif /* CSR_WIFI_HIP_NOISY */
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-
-/*
- * The unifi_debug_output buffer can be used to debug the HIP behaviour offline
- * i.e. without using the tracing functions that change the timing.
- *
- * Call unifi_debug_log_to_buf() with printf arguments to store a string into
- * unifi_debug_output. When unifi_debug_buf_dump() is called, the contents of the
- * buffer are dumped with dump_str() which has to be implemented in the
- * OS layer, during the porting exercise. The offset printed, holds the
- * offset where the last character is (always a zero).
- *
- */
-
-#define UNIFI_DEBUG_GBUFFER_SIZE       8192
-static char unifi_debug_output[UNIFI_DEBUG_GBUFFER_SIZE];
-static char *unifi_dbgbuf_ptr = unifi_debug_output;
-static char *unifi_dbgbuf_start = unifi_debug_output;
-
-static void append_char(char c)
-{
-    /* write char and advance pointer */
-    *unifi_dbgbuf_ptr++ = c;
-    /* wrap pointer at end of buffer */
-    if ((unifi_dbgbuf_ptr - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
-    {
-        unifi_dbgbuf_ptr = unifi_debug_output;
-    }
-} /* append_char() */
-
-
-void unifi_debug_string_to_buf(const char *str)
-{
-    const char *p = str;
-    while (*p)
-    {
-        append_char(*p);
-        p++;
-    }
-    /* Update start-of-buffer pointer */
-    unifi_dbgbuf_start = unifi_dbgbuf_ptr + 1;
-    if ((unifi_dbgbuf_start - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
-    {
-        unifi_dbgbuf_start = unifi_debug_output;
-    }
-}
-
-
-void unifi_debug_log_to_buf(const char *fmt, ...)
-{
-#define DEBUG_BUFFER_SIZE       80
-    static char s[DEBUG_BUFFER_SIZE];
-    va_list args;
-
-    va_start(args, fmt);
-    vsnprintf(s, DEBUG_BUFFER_SIZE, fmt, args);
-    va_end(args);
-
-    unifi_debug_string_to_buf(s);
-} /* unifi_debug_log_to_buf() */
-
-
-/* Convert signed 32 bit (or less) integer to string */
-static void CsrUInt16ToHex(u16 number, char *str)
-{
-    u16 index;
-    u16 currentValue;
-
-    for (index = 0; index < 4; index++)
-    {
-        currentValue = (u16) (number & 0x000F);
-        number >>= 4;
-        str[3 - index] = (char) (currentValue > 9 ? currentValue + 55 : currentValue + '0');
-    }
-    str[4] = '\0';
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_debug_hex_to_buf
- *
- *  puts the contents of the passed buffer into the debug buffer as a hex string
- *
- *  Arguments:
- *      buff         buffer to print as hex
- *      length       number of chars to print
- *
- *  Returns:
- *      None.
- *
- * ---------------------------------------------------------------------------
- */
-void unifi_debug_hex_to_buf(const char *buff, u16 length)
-{
-    char s[5];
-    u16 i;
-
-    for (i = 0; i < length; i = i + 2)
-    {
-        CsrUInt16ToHex(*((u16 *)(buff + i)), s);
-        unifi_debug_string_to_buf(s);
-    }
-}
-
-
-void unifi_debug_buf_dump(void)
-{
-    s32 offset = unifi_dbgbuf_ptr - unifi_debug_output;
-
-    unifi_error(NULL, "HIP debug buffer offset=%d\n", offset);
-    dump_str(unifi_debug_output + offset, UNIFI_DEBUG_GBUFFER_SIZE - offset);
-    dump_str(unifi_debug_output, offset);
-} /* unifi_debug_buf_dump() */
-
-
-#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
-
-#ifdef CSR_PRE_ALLOC_NET_DATA
-#define NETDATA_PRE_ALLOC_BUF_SIZE 8000
-
-void prealloc_netdata_free(card_t *card)
-{
-    unifi_warning(card->ospriv, "prealloc_netdata_free: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
-
-    while (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length != 0)
-    {
-        unifi_warning(card->ospriv, "prealloc_netdata_free: r=%d\n", card->prealloc_netdata_r);
-
-        unifi_net_data_free(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_r]);
-        card->prealloc_netdata_r++;
-        card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
-    }
-    card->prealloc_netdata_r = card->prealloc_netdata_w = 0;
-
-    unifi_warning(card->ospriv, "prealloc_netdata_free: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
-}
-
-
-CsrResult prealloc_netdata_alloc(card_t *card)
-{
-    CsrResult r;
-
-    unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
-
-    while (card->bulk_data_desc_list[card->prealloc_netdata_w].data_length == 0)
-    {
-        r = unifi_net_data_malloc(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_w], NETDATA_PRE_ALLOC_BUF_SIZE);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "prealloc_netdata_alloc: Failed to allocate t-h bulk data\n");
-            return CSR_RESULT_FAILURE;
-        }
-        card->prealloc_netdata_w++;
-        card->prealloc_netdata_w %= BULK_DATA_PRE_ALLOC_NUM;
-    }
-    unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
-
-    return CSR_RESULT_SUCCESS;
-}
-
-
-static CsrResult prealloc_netdata_get(card_t *card, bulk_data_desc_t *bulk_data_slot, u32 size)
-{
-    CsrResult r;
-
-    unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
-
-    if (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0)
-    {
-        unifi_error(card->ospriv, "prealloc_netdata_get: data_length = 0\n");
-    }
-
-    if ((size > NETDATA_PRE_ALLOC_BUF_SIZE) || (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0))
-    {
-        unifi_warning(card->ospriv, "prealloc_netdata_get: Calling net_data_malloc\n");
-
-        r = unifi_net_data_malloc(card->ospriv, bulk_data_slot, size);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "prealloc_netdata_get: Failed to allocate t-h bulk data\n");
-            return CSR_RESULT_FAILURE;
-        }
-        return CSR_RESULT_SUCCESS;
-    }
-
-    *bulk_data_slot = card->bulk_data_desc_list[card->prealloc_netdata_r];
-    card->bulk_data_desc_list[card->prealloc_netdata_r].os_data_ptr = NULL;
-    card->bulk_data_desc_list[card->prealloc_netdata_r].os_net_buf_ptr = NULL;
-    card->bulk_data_desc_list[card->prealloc_netdata_r].net_buf_length = 0;
-    card->bulk_data_desc_list[card->prealloc_netdata_r].data_length = 0;
-
-    card->prealloc_netdata_r++;
-    card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
-
-    unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
-
-    return CSR_RESULT_SUCCESS;
-}
-
-
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_sdio_interrupt_handler
- *
- *      This function should be called by the OS-dependent code to handle
- *      an SDIO interrupt from the UniFi.
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *
- *  Returns:
- *      None.
- *
- *  Notes: This function may be called in DRS context. In this case,
- *         tracing with the unifi_trace(), etc, is not allowed.
- * ---------------------------------------------------------------------------
- */
-void unifi_sdio_interrupt_handler(card_t *card)
-{
-    /*
-     * Set the flag to say reason for waking was SDIO interrupt.
-     * Then ask the OS layer to run the unifi_bh to give attention to the UniFi.
-     */
-    card->bh_reason_unifi = 1;
-    (void)unifi_run_bh(card->ospriv);
-} /*  sdio_interrupt_handler() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_configure_low_power_mode
- *
- *      This function should be called by the OS-dependent when
- *      the deep sleep signaling needs to be enabled or disabled.
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *      low_power_mode  Disable/Enable the deep sleep signaling
- *      periodic_wake_mode UniFi wakes host periodically.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or a CSR error code.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_configure_low_power_mode(card_t                       *card,
-                                         enum unifi_low_power_mode     low_power_mode,
-                                         enum unifi_periodic_wake_mode periodic_wake_mode)
-{
-    card->low_power_mode = low_power_mode;
-    card->periodic_wake_mode = periodic_wake_mode;
-
-    unifi_trace(card->ospriv, UDBG1,
-                "unifi_configure_low_power_mode: new mode = %s, wake_host = %s\n",
-                (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled",
-                (periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_DISABLED)?"FALSE" : "TRUE");
-
-    (void)unifi_run_bh(card->ospriv);
-    return CSR_RESULT_SUCCESS;
-} /* unifi_configure_low_power_mode() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_force_low_power_mode
- *
- *      This function should be called by the OS-dependent when
- *      UniFi needs to be set to the low power mode (e.g. on suspend)
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or a CSR error code.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_force_low_power_mode(card_t *card)
-{
-    if (card->low_power_mode == UNIFI_LOW_POWER_DISABLED)
-    {
-        unifi_error(card->ospriv, "Attempt to set mode to TORPID when lower power mode is disabled\n");
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    return unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
-} /* unifi_force_low_power_mode() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_bh
- *
- *      This function should be called by the OS-dependent code when
- *      host and/or UniFi has requested an exchange of messages.
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or a CSR error code.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_bh(card_t *card, u32 *remaining)
-{
-    CsrResult r;
-    CsrResult csrResult;
-    u8 pending;
-    s32 iostate, j;
-    const enum unifi_low_power_mode low_power_mode = card->low_power_mode;
-    u16 data_slots_used = 0;
-
-
-    /* Process request to raise the maximum SDIO clock */
-    r = process_clock_request(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Error setting maximum SDIO clock\n");
-        goto exit;
-    }
-
-    /*
-     * Why was the BH thread woken?
-     * If it was an SDIO interrupt, UniFi is awake and we need to process it.
-     * If it was a host process queueing data, then we need to awaken UniFi.
-     *
-     * Priority of flags is top down.
-     *
-     * ----------------------------------------------------------+
-     *    \state|   AWAKE      |    DROWSY      |    TORPID      |
-     * flag\    |              |                |                |
-     * ---------+--------------+----------------+----------------|
-     *          | do the host  | go to AWAKE and| go to AWAKE and|
-     *   unifi  | protocol     | do the host    | do the host    |
-     *          |              | protocol       | protocol       |
-     * ---------+--------------+----------------+----------------|
-     *          | do the host  |                |                |
-     *   host   | protocol     |  do nothing    | go to DROWSY   |
-     *          |              |                |                |
-     * ---------+--------------+----------------+----------------|
-     *          |              |                | should not     |
-     *  timeout | go to TORPID | error, unifi   | occur          |
-     *          |              | didn't wake up | do nothing     |
-     * ----------------------------------------------------------+
-     *
-     * Note that if we end up in the AWAKE state we always do the host protocol.
-     */
-
-    do
-    {
-        /*
-         * When the host state is set to DROWSY, then we can not disable the
-         * interrupts as UniFi can generate an interrupt even when the INT_ENABLE
-         * register has the interrupts disabled. This interrupt will be lost.
-         */
-        if (card->host_state == UNIFI_HOST_STATE_DROWSY || card->host_state == UNIFI_HOST_STATE_TORPID)
-        {
-            u8 reason_unifi;
-
-            /*
-             * An interrupt may occur while or after we cache the reason.
-             * This interrupt will cause the unifi_bh() to be scheduled again.
-             * Any interrupt that has happened before the register is read
-             * and is considered spurious has to acknowledged.
-             */
-            reason_unifi = card->bh_reason_unifi;
-
-            /*
-             * If an interrupt is received, check if it was a real one,
-             * set the host state to AWAKE and run the BH.
-             */
-            r = CardPendingInt(card, &pending);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                goto exit;
-            }
-
-            if (pending)
-            {
-                unifi_trace(card->ospriv, UDBG5,
-                            "UNIFI_HOST_STATE_%s: Set state to AWAKE.\n",
-                            (card->host_state == UNIFI_HOST_STATE_TORPID)?"TORPID" : "DROWSY");
-
-                r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-                if (r == CSR_RESULT_SUCCESS)
-                {
-                    (*remaining) = 0;
-                    break;
-                }
-            }
-            else if (reason_unifi)
-            {
-                CsrSdioInterruptAcknowledge(card->sdio_if);
-            }
-
-            /*
-             * If an chip is in TORPID, and the host wants to wake it up,
-             * set the host state to DROWSY and wait for the wake-up interrupt.
-             */
-            if ((card->host_state == UNIFI_HOST_STATE_TORPID) && card->bh_reason_host)
-            {
-                r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
-                if (r == CSR_RESULT_SUCCESS)
-                {
-                    /*
-                     * set the timeout value to UNIFI_DEFAULT_WAKE_TIMEOUT
-                     * to capture a wake error.
-                     */
-                    card->bh_reason_host = 0;
-                    (*remaining) = UNIFI_DEFAULT_WAKE_TIMEOUT;
-                    return CSR_RESULT_SUCCESS;
-                }
-
-                goto exit;
-            }
-
-            /*
-             * If the chip is in DROWSY, and the timeout expires,
-             * we need to reset the chip. This should never occur.
-             * (If it does, check that the calling thread set "remaining"
-             * according to the time remaining when unifi_bh() was called).
-             */
-            if ((card->host_state == UNIFI_HOST_STATE_DROWSY) && ((*remaining) == 0))
-            {
-                unifi_error(card->ospriv, "UniFi did not wake up on time...\n");
-
-                /*
-                 * Check if Function1 has gone away or
-                 * if we missed an SDIO interrupt.
-                 */
-                r = unifi_check_io_status(card, &iostate);
-                if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-                {
-                    goto exit;
-                }
-                /* Need to reset and reboot */
-                return CSR_RESULT_FAILURE;
-            }
-        }
-        else
-        {
-            if (card->bh_reason_unifi || card->bh_reason_host)
-            {
-                break;
-            }
-
-            if (((*remaining) == 0) && (low_power_mode == UNIFI_LOW_POWER_ENABLED))
-            {
-                r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
-                if (r == CSR_RESULT_SUCCESS)
-                {
-                    (*remaining) = 0;
-                    return CSR_RESULT_SUCCESS;
-                }
-
-                goto exit;
-            }
-        }
-
-        /* No need to run the host protocol */
-        return CSR_RESULT_SUCCESS;
-    } while (0);
-
-
-    /* Disable the SDIO interrupts while doing SDIO ops */
-    csrResult = CsrSdioInterruptDisable(card->sdio_if);
-    if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        goto exit;
-    }
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-        unifi_error(card->ospriv, "Failed to disable SDIO interrupts. unifi_bh queues error.\n");
-        goto exit;
-    }
-
-    /* Now that the interrupts are disabled, ack the interrupt */
-    CsrSdioInterruptAcknowledge(card->sdio_if);
-
-    /* Run the HIP */
-    r = process_bh(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        goto exit;
-    }
-
-    /*
-     * If host is now idle, schedule a timer for the delay before we
-     * let UniFi go into deep sleep.
-     * If the timer goes off, we will move to TORPID state.
-     * If UniFi raises an interrupt in the meantime, we will cancel
-     * the timer and start a new one when we become idle.
-     */
-    for (j = 0; j < UNIFI_NO_OF_TX_QS; j++)
-    {
-        data_slots_used += CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[j]);
-    }
-
-    if ((low_power_mode == UNIFI_LOW_POWER_ENABLED) && (data_slots_used == 0))
-    {
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-        if (card->ta_sampling.traffic_type != CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC)
-        {
-#endif
-        /* return the UNIFI_DEFAULT_HOST_IDLE_TIMEOUT, so we can go to sleep. */
-        unifi_trace(card->ospriv, UDBG5,
-                    "Traffic is not periodic, set timer for TORPID.\n");
-        (*remaining) = UNIFI_DEFAULT_HOST_IDLE_TIMEOUT;
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-    }
-    else
-    {
-        unifi_trace(card->ospriv, UDBG5,
-                    "Traffic is periodic, set unifi to TORPID immediately.\n");
-        if (CardAreAllFromHostDataSlotsEmpty(card) == 1)
-        {
-            r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                goto exit;
-            }
-        }
-    }
-#endif
-    }
-
-    csrResult = CsrSdioInterruptEnable(card->sdio_if);
-    if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-    {
-        r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
-    }
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-        unifi_error(card->ospriv, "Failed to enable SDIO interrupt\n");
-    }
-
-exit:
-
-    unifi_trace(card->ospriv, UDBG4, "New state=%d\n", card->host_state);
-
-    if (r != CSR_RESULT_SUCCESS)
-    {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        unifi_debug_buf_dump();
-#endif
-        /* If an interrupt has been raised, ack it here */
-        if (card->bh_reason_unifi)
-        {
-            CsrSdioInterruptAcknowledge(card->sdio_if);
-        }
-
-        unifi_error(card->ospriv,
-                    "unifi_bh: state=%d %c, clock=%dkHz, interrupt=%d host=%d, power_save=%s\n",
-                    card->host_state,
-                    (card->host_state == UNIFI_HOST_STATE_AWAKE)?'A' : (card->host_state == UNIFI_HOST_STATE_DROWSY)?'D' : 'T',
-                    card->sdio_clock_speed / 1000,
-                    card->bh_reason_unifi, card->bh_reason_host,
-                    (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled");
-
-        /* Try to capture firmware panic codes */
-        (void)unifi_capture_panic(card);
-
-        /* Ask for a mini-coredump when the driver has reset UniFi */
-        (void)unifi_coredump_request_at_next_reset(card, 1);
-    }
-
-    return r;
-} /* unifi_bh() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_clock_request
- *
- *      Handle request from the OS layer to increase the SDIO clock speed.
- *      The fast clock is limited until the firmware has indicated that it has
- *      completed initialisation to the OS layer.
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or CSR error code.
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_clock_request(card_t *card)
-{
-    CsrResult r = CSR_RESULT_SUCCESS;
-    CsrResult csrResult;
-
-    if (!card->request_max_clock)
-    {
-        return CSR_RESULT_SUCCESS;   /* No pending request */
-    }
-
-    /*
-     * The SDIO clock speed request from the OS layer is only acted upon if
-     * the UniFi is awake. If it was in any other state, the clock speed will
-     * transition through SAFE to MAX while the host wakes it up, and the
-     * final speed reached will be UNIFI_SDIO_CLOCK_MAX_HZ.
-     * This assumes that the SME never requests low power mode while the f/w
-     * initialisation takes place.
-     */
-    if (card->host_state == UNIFI_HOST_STATE_AWAKE)
-    {
-        unifi_trace(card->ospriv, UDBG1, "Set SDIO max clock\n");
-        csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_MAX_HZ);
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-        }
-        else
-        {
-            card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ;  /* log the new freq */
-        }
-    }
-    else
-    {
-        unifi_trace(card->ospriv, UDBG1, "Will set SDIO max clock after wakeup\n");
-    }
-
-    /* Cancel the request now that it has been acted upon, or is about to be
-     * by the wakeup mechanism
-     */
-    card->request_max_clock = 0;
-
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_bh
- *
- *      Exchange messages with UniFi
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or CSR error code.
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_bh(card_t *card)
-{
-    CsrResult r;
-    u8 more;
-    more = FALSE;
-
-    /* Process the reasons (interrupt, signals) */
-    do
-    {
-        /*
-         * Run in a while loop, to save clearing the interrupts
-         * every time around the outside loop.
-         */
-        do
-        {
-            /* If configured to run the HIP just once, skip first loop */
-            if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
-            {
-                break;
-            }
-
-            r = handle_host_protocol(card, &more);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-            unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
-                                   card->cmd_prof.cmd52_count,
-                                   card->cmd_prof.cmd53_count,
-                                   card->cmd_prof.tx_count,
-                                   card->cmd_prof.tx_cfm_count,
-                                   card->cmd_prof.rx_count,
-                                   card->cmd_prof.sdio_cmd_signal,
-                                   card->cmd_prof.sdio_cmd_to_host,
-                                   card->cmd_prof.sdio_cmd_from_host_and_clear
-                                   );
-
-            card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
-            card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
-
-            card->cmd_prof.cmd52_f0_r_count = 0;
-            card->cmd_prof.cmd52_f0_w_count = 0;
-            card->cmd_prof.cmd52_r8or16_count = 0;
-            card->cmd_prof.cmd52_w8or16_count = 0;
-            card->cmd_prof.cmd52_r16_count = 0;
-            card->cmd_prof.cmd52_w16_count = 0;
-            card->cmd_prof.cmd52_r32_count = 0;
-
-            card->cmd_prof.sdio_cmd_signal = 0;
-            card->cmd_prof.sdio_cmd_clear_slot = 0;
-            card->cmd_prof.sdio_cmd_to_host = 0;
-            card->cmd_prof.sdio_cmd_from_host = 0;
-            card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
-#endif
-
-
-        } while (more || card->bh_reason_unifi || card->bh_reason_host);
-
-        /* Acknowledge the h/w interrupt */
-        r = CardClearInt(card);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to acknowledge interrupt.\n");
-            return r;
-        }
-
-        /*
-         * UniFi may have tried to generate an interrupt during the
-         * CardClearInt() was running. So, we need to run the host
-         * protocol again, to check if there are any pending requests.
-         */
-        r = handle_host_protocol(card, &more);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-        unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
-                               card->cmd_prof.cmd52_count,
-                               card->cmd_prof.cmd53_count,
-                               card->cmd_prof.tx_count,
-                               card->cmd_prof.tx_cfm_count,
-                               card->cmd_prof.rx_count,
-                               card->cmd_prof.sdio_cmd_signal,
-                               card->cmd_prof.sdio_cmd_to_host,
-                               card->cmd_prof.sdio_cmd_from_host_and_clear
-                               );
-
-        card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
-        card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
-
-        card->cmd_prof.cmd52_f0_r_count = 0;
-        card->cmd_prof.cmd52_f0_w_count = 0;
-        card->cmd_prof.cmd52_r8or16_count = 0;
-        card->cmd_prof.cmd52_w8or16_count = 0;
-        card->cmd_prof.cmd52_r16_count = 0;
-        card->cmd_prof.cmd52_w16_count = 0;
-        card->cmd_prof.cmd52_r32_count = 0;
-
-        card->cmd_prof.sdio_cmd_signal = 0;
-        card->cmd_prof.sdio_cmd_clear_slot = 0;
-        card->cmd_prof.sdio_cmd_to_host = 0;
-        card->cmd_prof.sdio_cmd_from_host = 0;
-        card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
-#endif
-        /* If configured to run the HIP just once, work is now done */
-        if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
-        {
-            break;
-        }
-
-    } while (more || card->bh_reason_unifi || card->bh_reason_host);
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    if ((card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) == 0)
-    {
-        unifi_debug_log_to_buf("proc=%d\n",
-                               card->cmd_prof.process_count);
-    }
-#endif
-
-    return CSR_RESULT_SUCCESS;
-} /* process_bh() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  handle_host_protocol
- *
- *      This function implements the Host Interface Protocol (HIP) as
- *      described in the Host Interface Protocol Specification.
- *
- *  Arguments:
- *      card                 Pointer to card context structure.
- *      processed_something  Pointer to location to update processing status:
- *                              TRUE when data was transferred
- *                              FALSE when no data was transferred (queues empty)
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or CSR error code.
- * ---------------------------------------------------------------------------
- */
-static CsrResult handle_host_protocol(card_t *card, u8 *processed_something)
-{
-    CsrResult r;
-    s32 done;
-
-    *processed_something = FALSE;
-
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv, "   ========================     \n");
-#endif /* CSR_WIFI_HIP_NOISY */
-
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-    card->cmd_prof.process_count++;
-#endif
-
-    card->bh_reason_unifi = card->bh_reason_host = 0;
-    card->generate_interrupt = 0;
-
-
-    /*
-     * (Re)fill the T-H signal buffer
-     */
-    r = read_to_host_signals(card, &done);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Error occurred reading to-host signals\n");
-        return r;
-    }
-    if (done > 0)
-    {
-        *processed_something = TRUE;
-    }
-
-    /*
-     * Process any to-host signals.
-     * Perform any requested CMD53 transfers here, but just queue any
-     * bulk data command responses.
-     */
-    r = process_to_host_signals(card, &done);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Error occurred processing to-host signals\n");
-        return r;
-    }
-
-    /* Now send any signals in the F-H queues */
-    /* Give precedence to the command queue */
-    r = process_fh_cmd_queue(card, &done);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Error occurred processing from-host signals\n");
-        return r;
-    }
-    if (done > 0)
-    {
-        *processed_something = TRUE;
-    }
-
-    r = process_fh_traffic_queue(card, &done);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Error occurred processing from-host data signals\n");
-        return r;
-    }
-    if (done > 0)
-    {
-        *processed_something = TRUE;
-    }
-
-    /* Flush out the batch of signals to the UniFi. */
-    r = flush_fh_buffer(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to copy from-host signals to UniFi\n");
-        return r;
-    }
-
-
-    /*
-     * Send the host interrupt to say the queues have been modified.
-     */
-    if (card->generate_interrupt)
-    {
-        r = CardGenInt(card);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to notify UniFi that queues have been modified.\n");
-            return r;
-        }
-    }
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-#ifdef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
-    unifi_rx_queue_flush(card->ospriv);
-#endif
-#endif
-
-    /* See if we can re-enable transmission now */
-    restart_packet_flow(card);
-
-#ifdef CSR_PRE_ALLOC_NET_DATA
-    r = prealloc_netdata_alloc(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "prealloc_netdata failed\n");
-        return r;
-    }
-#endif
-
-    /*
-     * Don't put the thread sleep if we just interacted with the chip,
-     * there might be more to do if we look again.
-     */
-    return r;
-} /* handle_host_protocol() */
-
-
-/*
- *      Rounds the given signal length in bytes to a whole number
- *      of sig_frag_size.
- */
-#define GET_CHUNKS_FOR(SIG_FRAG_SIZE, LENGTH) (((LENGTH) + ((SIG_FRAG_SIZE)-1)) / (SIG_FRAG_SIZE))
-
-
-/*
- * ---------------------------------------------------------------------------
- *  read_to_host_signals
- *
- *      Read everything pending in the UniFi TH signal buffer.
- *      Only do it if the local buffer is empty.
- *
- *  Arguments:
- *      card        Pointer to card context struct
- *      processed   Number of signals read:
- *                      0 if there were no signals pending,
- *                      1 if we read at least one signal
- *  Returns:
- *      CSR error code if an error occurred.
- * ---------------------------------------------------------------------------
- */
-static CsrResult read_to_host_signals(card_t *card, s32 *processed)
-{
-    s32 count_thw, count_thr;
-    s32 unread_chunks, unread_bytes;
-    CsrResult r;
-
-    *processed = 0;
-
-    /* Read any pending signals or bulk data commands */
-    count_thw = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
-    if (count_thw < 0)
-    {
-        unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
-        return CSR_RESULT_FAILURE;
-    }
-    card->to_host_signals_w = count_thw; /* diag */
-
-    count_thr = card->to_host_signals_r;
-
-    if (count_thw == count_thr)
-    {
-        return CSR_RESULT_SUCCESS;
-    }
-
-    unread_chunks =
-        (((count_thw - count_thr) + 128) % 128) - card->th_buffer.count;
-
-    if (unread_chunks == 0)
-    {
-        return CSR_RESULT_SUCCESS;
-    }
-
-    unread_bytes = card->config_data.sig_frag_size * unread_chunks;
-
-
-    r = unifi_bulk_rw(card,
-                      card->config_data.tohost_sigbuf_handle,
-                      card->th_buffer.ptr,
-                      unread_bytes,
-                      UNIFI_SDIO_READ);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read ToHost signal\n");
-        return r;
-    }
-
-    card->th_buffer.ptr += unread_bytes;
-    card->th_buffer.count += (u16)unread_chunks;
-
-    *processed = 1;
-
-    return CSR_RESULT_SUCCESS;
-} /* read_to_host_signals() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  update_to_host_signals_r
- *
- *      Advance the shared-memory count of chunks read from the to-host
- *      signal buffer.
- *      Raise a UniFi internal interrupt to tell the firmware that the
- *      count has changed.
- *
- *  Arguments:
- *      card            Pointer to card context struct
- *      pending         Number of chunks remaining
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success or CSR error code
- * ---------------------------------------------------------------------------
- */
-static CsrResult update_to_host_signals_r(card_t *card, s16 pending)
-{
-    CsrResult r;
-
-    card->to_host_signals_r =
-        (card->to_host_signals_r + (card->th_buffer.count - pending)) % 128;
-    card->th_buffer.count = pending;
-
-    /* Update the count of signals read */
-    r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 6,
-                            (u8)card->to_host_signals_r);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to update to-host signals read\n");
-        return r;
-    }
-
-    r = CardGenInt(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to notify UniFi that we processed to-host signals.\n");
-        return r;
-    }
-
-    card->generate_interrupt = 0;
-
-    return CSR_RESULT_SUCCESS;
-} /* update_to_host_signals_r() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  read_unpack_cmd
- *
- *      Converts a wire-formatted command to the host bulk_data_cmd_t structure.
- *
- *  Arguments:
- *      ptr             Pointer to the command
- *      bulk_data_cmd   Pointer to the host structure
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void read_unpack_cmd(const u8 *ptr, bulk_data_cmd_t *bulk_data_cmd)
-{
-    s16 index = 0;
-    bulk_data_cmd->cmd_and_len = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-    bulk_data_cmd->data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-    bulk_data_cmd->offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-    bulk_data_cmd->buffer_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-} /* read_unpack_cmd */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_to_host_signals
- *
- *      Read and dispatch signals from the UniFi
- *
- *  Arguments:
- *      card        Pointer to card context struct
- *      processed   Pointer to location to write processing result:
- *                      0 if there were no signals pending,
- *                      1 if we read at least one signal
- *
- *  Returns:
- *      CSR error code if there was an error
- *
- *  Notes:
- *      Since bulk data transfers can take a long time, if we wait until
- *      all are done before we acknowledge the signals, the UniFi runs out
- *      of buffer space. Therefore we keep a count of the bytes transferred
- *      in bulk data commands, and update the to-host-signals-read count
- *      if we've done a large transfer.
- *
- *      All data in the f/w is stored in a little endian format, without any
- *      padding bytes. Every read from the memory has to be transformed in
- *      host (cpu specific) format, before we can process it. Therefore we
- *      use read_unpack_cmd() and read_unpack_signal() to convert the raw data
- *      contained in the card->th_buffer.buf to host structures.
- *      Important: UDI clients use wire-formatted structures, so we need to
- *      indicate all data, as we have read it from the device.
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_to_host_signals(card_t *card, s32 *processed)
-{
-    s16 pending;
-    s16 remaining;
-    u8 *bufptr;
-    bulk_data_param_t data_ptrs;
-    s16 cmd;
-    u16 sig_len;
-    s16 i;
-    u16 chunks_in_buf;
-    u16 bytes_transferred = 0;
-    CsrResult r = CSR_RESULT_SUCCESS;
-
-    *processed = 0;
-
-    pending = card->th_buffer.count;
-
-    /* Are there new to-host signals? */
-    unifi_trace(card->ospriv, UDBG4, "handling %d to-host chunks\n", pending);
-
-    if (!pending)
-    {
-        return CSR_RESULT_SUCCESS;
-    }
-
-    /*
-     * This is a pointer to the raw data we have read from the f/w.
-     * Can be a signal or a command. Note that we need to convert
-     * it to a host structure before we process it.
-     */
-    bufptr = card->th_buffer.buf;
-
-    while (pending > 0)
-    {
-        s16 f_flush_count = 0;
-
-        /*
-         * Command and length are common to signal and bulk data msgs.
-         * If command == 0 (i.e. a signal), len is number of bytes
-         * *following* the 2-byte header.
-         */
-        cmd = bufptr[1] >> 4;
-        sig_len = bufptr[0] + ((bufptr[1] & 0x0F) << 8);
-
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "Received UniFi msg cmd=%d, len=%d\n",
-                    cmd, sig_len);
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-        if ((sig_len == 0) &&
-            ((cmd != SDIO_CMD_CLEAR_SLOT) && (cmd != SDIO_CMD_PADDING)))
-        {
-            unifi_error(card->ospriv, "incomplete signal or command: has size zero\n");
-            return CSR_RESULT_FAILURE;
-        }
-        /*
-         * Make sure the buffer contains a complete message.
-         * Signals may occupy multiple chunks, bulk-data commands occupy
-         * one chunk.
-         */
-        if (cmd == SDIO_CMD_SIGNAL)
-        {
-            chunks_in_buf = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(sig_len + 2));
-        }
-        else
-        {
-            chunks_in_buf = 1;
-        }
-
-        if (chunks_in_buf > (u16)pending)
-        {
-            unifi_error(card->ospriv, "incomplete signal (0x%x?): need %d chunks, got %d\n",
-                        GET_SIGNAL_ID(bufptr + 2),
-                        chunks_in_buf, pending);
-            unifi_error(card->ospriv, " thsw=%d, thsr=%d\n",
-                        card->to_host_signals_w,
-                        card->to_host_signals_r);
-            return CSR_RESULT_FAILURE;
-        }
-
-
-        switch (cmd)
-        {
-            case SDIO_CMD_SIGNAL:
-                /* This is a signal. Read the rest of it and then handle it. */
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-                card->cmd_prof.sdio_cmd_signal++;
-#endif
-
-                for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
-                {
-                    /* Retrieve dataRefs[i].DataLength */
-                    u16 data_len = GET_PACKED_DATAREF_LEN(bufptr + 2, i);
-
-                    /*
-                     * The bulk data length in the signal can not be greater than
-                     * the maximun length allowed by the SDIO config structure.
-                     */
-                    if (data_len > card->config_data.data_slot_size)
-                    {
-                        unifi_error(card->ospriv,
-                                    "Bulk Data length (%d) exceeds Maximum Bulk Data length (%d)\n",
-                                    data_len, card->config_data.data_slot_size);
-                        return CSR_RESULT_FAILURE;
-                    }
-
-                    /*
-                     * Len here might not be the same as the length in the
-                     * bulk data slot.  The slot length will always be even,
-                     * but len could be odd.
-                     */
-                    if (data_len != 0)
-                    {
-                    /* Retrieve dataRefs[i].SlotNumber */
-                        s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
-
-                        if (slot >= card->config_data.num_tohost_data_slots)
-                        {
-                            unifi_error(card->ospriv, "!!!bad slot number in to-host signal: %d, sig 0x%X\n",
-                                        slot, cmd);
-                            return CSR_RESULT_FAILURE;
-                        }
-
-                        data_ptrs.d[i].os_data_ptr = card->to_host_data[slot].os_data_ptr;
-                        data_ptrs.d[i].os_net_buf_ptr = card->to_host_data[slot].os_net_buf_ptr;
-                        data_ptrs.d[i].net_buf_length = card->to_host_data[slot].net_buf_length;
-                        data_ptrs.d[i].data_length = data_len;
-                    }
-                    else
-                    {
-                        UNIFI_INIT_BULK_DATA(&data_ptrs.d[i]);
-                    }
-                }
-
-            /*
-             * Log the signal to the UDI, before call unifi_receive_event() as
-             * it can modify the bulk data.
-             */
-                if (card->udi_hook)
-                {
-                    (*card->udi_hook)(card->ospriv, bufptr + 2, sig_len,
-                                      &data_ptrs, UDI_LOG_TO_HOST);
-                }
-
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-                if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
-                {
-                    card->cmd_prof.tx_cfm_count++;
-                }
-                else if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_INDICATION_ID)
-                {
-                    if (data_ptrs.d[0].os_data_ptr)
-                    {
-                        if ((*data_ptrs.d[0].os_data_ptr) & 0x08)
-                        {
-                            card->cmd_prof.rx_count++;
-                        }
-                    }
-                }
-#endif
-                /*
-                 * Check if the signal is MA-PACKET.cfm and if so check the status.
-                 * If the status is failure, search through the slot records to find
-                 * if any slots are occupied for this host tag. This can happen if
-                 * f/w has not downloaded the bulkdata and before that itself it has
-                 * signalled the confirm with failure. If it finds a slot with that
-                 * host tag then, it clears the corresponding slot
-                 */
-
-                if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
-                {
-                    /* Get host tag and transmission status */
-                    u32 host_tag = GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(bufptr + 2);
-                    u16 status = GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(bufptr + 2);
-
-                    unifi_trace(card->ospriv, UDBG4, "process_to_host_signals signal ID=%x host Tag=%x status=%x\n",
-                                GET_SIGNAL_ID(bufptr + 2), host_tag, status);
-
-                    /* If transmission status is failure then search through the slot records
-                     * and if for any slot records the clear slot is not done then do it now
-                     */
-
-                    if (status && (card->fh_slot_host_tag_record))
-                    {
-                        u16 num_fh_slots = card->config_data.num_fromhost_data_slots;
-
-                        /* search through the list of slot records and match with host tag
-                         * If a slot is not yet cleared then clear the slot from here
-                         */
-                        for (i = 0; i < num_fh_slots; i++)
-                        {
-                            if (card->fh_slot_host_tag_record[i] == host_tag)
-                            {
-#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
-                                /* Invoke the HAL module function to requeue it back to HAL Queues */
-                                r = unifi_reque_ma_packet_request(card->ospriv, host_tag, status, &card->from_host_data[i].bd);
-                                card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
-                                if (CSR_RESULT_SUCCESS != r)
-                                {
-                                    unifi_trace(card->ospriv, UDBG5, "process_to_host_signals: Failed to requeue Packet(hTag:%x) back to HAL \n", host_tag);
-                                    CardClearFromHostDataSlot(card, i);
-                                }
-                                else
-                                {
-                                    CardClearFromHostDataSlotWithoutFreeingBulkData(card, i);
-                                }
-
-#else
-                                unifi_trace(card->ospriv, UDBG4, "process_to_host_signals Clear slot=%x host tag=%x\n", i, host_tag);
-                                card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
-
-                                /* Set length field in from_host_data array to 0 */
-                                CardClearFromHostDataSlot(card, i);
-#endif
-                                break;
-                            }
-                        }
-                    }
-                }
-
-                /* Pass event to OS layer */
-                unifi_receive_event(card->ospriv, bufptr + 2, sig_len, &data_ptrs);
-
-                /* Initialise the to_host data, so it can be re-used. */
-                for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
-                {
-                /* The slot is only valid if the length is non-zero. */
-                    if (GET_PACKED_DATAREF_LEN(bufptr + 2, i) != 0)
-                    {
-                        s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
-                        if (slot < card->config_data.num_tohost_data_slots)
-                        {
-                            UNIFI_INIT_BULK_DATA(&card->to_host_data[slot]);
-                        }
-                    }
-                }
-
-#ifndef CSR_WIFI_DEFER_TH_FLUSH
-                /*
-                 * If we have previously transferred a lot of data, ack
-                 * the signals read so far, so f/w can reclaim the buffer
-                 * memory sooner.
-                 */
-                if (bytes_transferred >= TO_HOST_FLUSH_THRESHOLD)
-                {
-                    f_flush_count = 1;
-                }
-#endif
-                break;
-
-
-            case SDIO_CMD_CLEAR_SLOT:
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-                card->cmd_prof.sdio_cmd_clear_slot++;
-#endif
-                /* This is a clear slot command. */
-                if (sig_len != 0)
-                {
-                    unifi_error(card->ospriv, "process_to_host_signals: clear slot, bad data len: 0x%X at offset %d\n",
-                                sig_len, bufptr - card->th_buffer.buf);
-                    return CSR_RESULT_FAILURE;
-                }
-
-                r = process_clear_slot_command(card, bufptr);
-                if (r != CSR_RESULT_SUCCESS)
-                {
-                    unifi_error(card->ospriv, "Failed to process clear slot\n");
-                    return r;
-                }
-                break;
-
-            case SDIO_CMD_TO_HOST_TRANSFER:
-            case SDIO_CMD_FROM_HOST_TRANSFER:
-            case SDIO_CMD_FROM_HOST_AND_CLEAR:
-            case SDIO_CMD_OVERLAY_TRANSFER:
-                /* This is a bulk data command. */
-                if (sig_len & 1)
-                {
-                    unifi_error(card->ospriv, "process_to_host_signals: bulk data, bad data len: 0x%X at offset %d\n",
-                                sig_len, bufptr - card->th_buffer.buf);
-                    return CSR_RESULT_FAILURE;
-                }
-
-                r = process_bulk_data_command(card, bufptr, cmd, sig_len);
-                if (r != CSR_RESULT_SUCCESS)
-                {
-                    unifi_error(card->ospriv, "Failed to process bulk cmd\n");
-                    return r;
-                }
-                /* Count the bytes transferred */
-                bytes_transferred += sig_len;
-
-                if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
-                {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-                    card->cmd_prof.sdio_cmd_from_host_and_clear++;
-#endif
-#ifndef CSR_WIFI_DEFER_TH_FLUSH
-                    f_flush_count = 1;
-#endif
-                }
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-                else if (cmd == SDIO_CMD_FROM_HOST_TRANSFER)
-                {
-                    card->cmd_prof.sdio_cmd_from_host++;
-                }
-                else if (cmd == SDIO_CMD_TO_HOST_TRANSFER)
-                {
-                    card->cmd_prof.sdio_cmd_to_host++;
-                }
-#endif
-                break;
-
-            case SDIO_CMD_PADDING:
-                break;
-
-            default:
-                unifi_error(card->ospriv, "Unrecognised to-host command: %d\n", cmd);
-                break;
-        }
-
-        bufptr += chunks_in_buf * card->config_data.sig_frag_size;
-        pending -= chunks_in_buf;
-
-        /*
-         * Write out the host signal count when a significant
-         * number of bytes of bulk data have been transferred or
-         * when we have performed a CopyFromHostAndClear.
-         */
-        if (f_flush_count)
-        {
-            r = update_to_host_signals_r(card, pending);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            bytes_transferred = 0;
-        }
-    }
-
-    if (pending)
-    {
-        unifi_warning(card->ospriv, "proc_th_sigs: %d unprocessed\n", pending);
-    }
-
-    /* If we processed any signals, write the updated count to UniFi */
-    if (card->th_buffer.count != pending)
-    {
-        r = update_to_host_signals_r(card, pending);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-    }
-
-    /*
-     * Reset the buffer pointer, copying down any un-processed signals.
-     * This can happen if we enable the optimisation in read_to_host_signals()
-     * that limits the length to whole blocks.
-     */
-    remaining = card->th_buffer.ptr - bufptr;
-    if (remaining < 0)
-    {
-        unifi_error(card->ospriv, "Processing TH signals overran the buffer\n");
-        return CSR_RESULT_FAILURE;
-    }
-    if (remaining > 0)
-    {
-        /* Use a safe copy because source and destination may overlap */
-        u8 *d = card->th_buffer.buf;
-        u8 *s = bufptr;
-        s32 n = remaining;
-        while (n--)
-        {
-            *d++ = *s++;
-        }
-    }
-    card->th_buffer.ptr = card->th_buffer.buf + remaining;
-
-
-    /* If we reach here then we processed something */
-    *processed = 1;
-    return CSR_RESULT_SUCCESS;
-} /* process_to_host_signals() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_clear_slot_command
- *
- *      Process a clear slot command fom the UniFi.
- *
- *  Arguments:
- *   card       Pointer to card context struct
- *   bdcmd      Pointer to bulk-data command msg from UniFi
- *
- *  Returns:
- *      0 on success, CSR error code on error
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_clear_slot_command(card_t *card, const u8 *cmdptr)
-{
-    u16 data_slot;
-    s16 slot;
-
-    data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cmdptr + SIZEOF_UINT16);
-
-    unifi_trace(card->ospriv, UDBG4, "Processing clear slot cmd, slot=0x%X\n",
-                data_slot);
-
-    slot = data_slot & 0x7FFF;
-
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv, "CMD clear data slot 0x%04x\n", data_slot);
-#endif /* CSR_WIFI_HIP_NOISY */
-
-    if (data_slot & SLOT_DIR_TO_HOST)
-    {
-        if (slot >= card->config_data.num_tohost_data_slots)
-        {
-            unifi_error(card->ospriv,
-                        "Invalid to-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
-                        slot);
-            return CSR_RESULT_FAILURE;
-        }
-        /* clear to-host data slot */
-        unifi_warning(card->ospriv, "Unexpected clear to-host data slot cmd: 0x%04x\n",
-                      data_slot);
-    }
-    else
-    {
-        if (slot >= card->config_data.num_fromhost_data_slots)
-        {
-            unifi_error(card->ospriv,
-                        "Invalid from-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
-                        slot);
-            return CSR_RESULT_FAILURE;
-        }
-
-        /*
-         * The driver is the owner to clear all slots now
-         * Ref - comment in process_fh_traffic_queue
-         * so it will just ignore the clear slot command from firmware
-         * and return success
-         */
-        return CSR_RESULT_SUCCESS;
-
-        /* Set length field in from_host_data array to 0 */
-        /* CardClearFromHostDataSlot(card, slot); */
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* process_clear_slot_command() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_bulk_data_command
- *
- *      Process a bulk data request from the UniFi.
- *
- *  Arguments:
- *   card       Pointer to card context struct
- *   bdcmd      Pointer to bulk-data command msg from UniFi
- *   cmd, len   Decoded values of command and length from the msg header
- *              Cmd will only be one of:
- *                      SDIO_CMD_TO_HOST_TRANSFER
- *                      SDIO_CMD_FROM_HOST_TRANSFER
- *                      SDIO_CMD_FROM_HOST_AND_CLEAR
- *                      SDIO_CMD_OVERLAY_TRANSFER
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on error
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_bulk_data_command(card_t *card, const u8 *cmdptr,
-                                           s16 cmd, u16 len)
-{
-    bulk_data_desc_t *bdslot;
-#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
-    u8 *host_bulk_data_slot;
-#endif
-    bulk_data_cmd_t bdcmd;
-    s16 offset;
-    s16 slot;
-    s16 dir;
-    CsrResult r;
-
-    read_unpack_cmd(cmdptr, &bdcmd);
-
-    unifi_trace(card->ospriv, UDBG4, "Processing bulk data cmd %d %s, len=%d, slot=0x%X\n",
-                cmd, lookup_bulkcmd_name(cmd), len, bdcmd.data_slot);
-
-    /*
-     * Round up the transfer length if required.
-     * This is useful to force all transfers to be a multiple of the SDIO block
-     * size, so the SDIO driver won't try to use a byte-mode CMD53. These are
-     * broken on some hardware platforms.
-     */
-    if (card->sdio_io_block_pad)
-    {
-        len = (len + card->sdio_io_block_size - 1) & ~(card->sdio_io_block_size - 1);
-        unifi_trace(card->ospriv, UDBG4, "Rounded bulk data length up to %d\n", len);
-    }
-
-    slot = bdcmd.data_slot & 0x7FFF;
-
-    if (cmd == SDIO_CMD_OVERLAY_TRANSFER)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;     /* Not used on CSR6xxx */
-    }
-    else
-    {
-        if (bdcmd.data_slot & SLOT_DIR_TO_HOST)
-        {
-            /* Request is for to-host bulk data */
-
-            /* Check sanity of slot number */
-            if (slot >= card->config_data.num_tohost_data_slots)
-            {
-                unifi_error(card->ospriv,
-                            "Invalid to-host data slot in SDIO bulk xfr req: %d\n",
-                            slot);
-                return CSR_RESULT_FAILURE;
-            }
-
-            /* Allocate memory for card->to_host_data[slot] bulk data here. */
-#ifdef CSR_PRE_ALLOC_NET_DATA
-            r = prealloc_netdata_get(card, &card->to_host_data[slot], len);
-#else
-            r = unifi_net_data_malloc(card->ospriv, &card->to_host_data[slot], len);
-#endif
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "Failed to allocate t-h bulk data\n");
-                return CSR_RESULT_FAILURE;
-            }
-
-            bdslot = &card->to_host_data[slot];
-
-            /* Make sure that the buffer is 4-bytes aligned */
-            r = unifi_net_dma_align(card->ospriv, bdslot);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "Failed to align t-h bulk data buffer for DMA\n");
-                return CSR_RESULT_FAILURE;
-            }
-        }
-        else
-        {
-            /* Request is for from-host bulk data */
-
-            if (slot >= card->config_data.num_fromhost_data_slots)
-            {
-                unifi_error(card->ospriv,
-                            "Invalid from-host data slot in SDIO bulk xfr req: %d\n",
-                            slot);
-                return CSR_RESULT_FAILURE;
-            }
-            bdslot = &card->from_host_data[slot].bd;
-        }
-        offset = bdcmd.offset;
-    }
-    /* Do the transfer */
-    dir = (cmd == SDIO_CMD_TO_HOST_TRANSFER)?
-          UNIFI_SDIO_READ : UNIFI_SDIO_WRITE;
-
-    unifi_trace(card->ospriv, UDBG4,
-                "Bulk %c %s len=%d, handle %d - slot=%d %p+(%d)\n",
-                (dir == UNIFI_SDIO_READ)?'R' : 'W',
-                lookup_bulkcmd_name(cmd),
-                len,
-                bdcmd.buffer_handle,
-                slot, bdslot->os_data_ptr, offset);
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv, "Bulk %s len=%d, handle %d - slot=%d %p+(%d)\n",
-                lookup_bulkcmd_name(cmd),
-                len,
-                bdcmd.buffer_handle,
-                slot, bdslot->os_data_ptr, offset);
-#endif /* CSR_WIFI_HIP_NOISY */
-
-
-    if (bdslot->os_data_ptr == NULL)
-    {
-        unifi_error(card->ospriv, "Null os_data_ptr - Bulk %s handle %d - slot=%d o=(%d)\n",
-                    lookup_bulkcmd_name(cmd),
-                    bdcmd.buffer_handle,
-                    slot,
-                    offset);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
-    /* if os_data_ptr is not 4-byte aligned, then allocate a new buffer and copy data
-    to new buffer to ensure the address passed to unifi_bulk_rw is 4-byte aligned */
-
-    if (len != 0 && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
-    {
-        host_bulk_data_slot = kmalloc(len, GFP_KERNEL);
-
-        if (!host_bulk_data_slot)
-        {
-            unifi_error(card->ospriv, " failed to allocate request_data before unifi_bulk_rw\n");
-            return -1;
-        }
-
-        memcpy((void *)host_bulk_data_slot,
-                  (void *)(bdslot->os_data_ptr + offset), len);
-
-        r = unifi_bulk_rw(card,
-                          bdcmd.buffer_handle,
-                          (void *)host_bulk_data_slot,
-                          len,
-                          dir);
-    }
-    else
-#endif
-    {
-        r = unifi_bulk_rw(card,
-                          bdcmd.buffer_handle,
-                          (void *)(bdslot->os_data_ptr + offset),
-                          len,
-                          dir);
-    }
-
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv,
-                    "Failed: %s hlen=%d, slen=%d, handle %d - slot=%d %p+0x%X\n",
-                    lookup_bulkcmd_name(cmd),
-                    len,                    /* Header length */
-                    bdslot->data_length,    /* Length stored in slot */
-                    bdcmd.buffer_handle,
-                    slot, bdslot->os_data_ptr, offset);
-        return r;
-    }
-
-    bdslot->data_length = len;
-
-    if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
-    {
-        if (slot >= card->config_data.num_fromhost_data_slots)
-        {
-            unifi_error(card->ospriv,
-                        "Invalid from-host data slot in SDIO_CMD_FROM_HOST_AND_CLEAR: %d\n",
-                        slot);
-            return CSR_RESULT_FAILURE;
-        }
-
-#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
-        /* moving this check before we clear host data slot */
-        if ((len != 0) && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
-        {
-            kfree(host_bulk_data_slot);
-        }
-#endif
-
-        if (card->fh_slot_host_tag_record)
-        {
-            unifi_trace(card->ospriv, UDBG5, "CopyFromHostAndClearSlot Reset entry for slot=%d\n", slot);
-
-            /* reset the host tag entry for the corresponding slot */
-            card->fh_slot_host_tag_record[slot] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
-        }
-
-
-        /* Set length field in from_host_data array to 0 */
-        CardClearFromHostDataSlot(card, slot);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* process_bulk_data_command() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  check_fh_sig_slots
- *
- *      Check whether there are <n> free signal slots available on UniFi.
- *      This takes into account the signals already batched since the
- *      from_host_signal counts were last read.
- *      If the from_host_signal counts indicate not enough space, we read
- *      the latest count from UniFi to see if some more have been freed.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS, otherwise CSR error code on error.
- * ---------------------------------------------------------------------------
- */
-static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space_fh)
-{
-    u32 count_fhw;
-    u32 occupied_fh, slots_fh;
-    s32 count_fhr;
-
-    count_fhw = card->from_host_signals_w;
-    count_fhr = card->from_host_signals_r;
-    slots_fh = card->config_data.num_fromhost_sig_frags;
-
-    /* Only read the space in from-host queue if necessary */
-    occupied_fh = (count_fhw - count_fhr) % 128;
-
-    if (slots_fh < occupied_fh)
-    {
-        *space_fh = 0;
-    }
-    else
-    {
-        *space_fh = slots_fh - occupied_fh;
-    }
-
-    if ((occupied_fh != 0) && (*space_fh < needed))
-    {
-        count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
-        if (count_fhr < 0)
-        {
-            unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
-            return CSR_RESULT_FAILURE;
-        }
-        card->from_host_signals_r = count_fhr; /* diag */
-
-        occupied_fh = (count_fhw - count_fhr) % 128;
-        *space_fh = slots_fh - occupied_fh;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* check_fh_sig_slots() */
-
-
-/*
-* If we are padding the From-Host signals to the SDIO block size,
-* we need to round up the needed_chunks to the SDIO block size.
-*/
-#define ROUND_UP_NEEDED_CHUNKS(_card, _needed_chunks) \
-    { \
-        u16 _chunks_per_block; \
-        u16 _chunks_in_last_block; \
- \
-        if (_card->sdio_io_block_pad) \
-        { \
-            _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
-            _chunks_in_last_block = _needed_chunks % _chunks_per_block; \
-            if (_chunks_in_last_block != 0) \
-            { \
-                _needed_chunks = _needed_chunks + (_chunks_per_block - _chunks_in_last_block); \
-            } \
-        } \
-    }
-
-
-#define ROUND_UP_SPACE_CHUNKS(_card, _space_chunks) \
-    { \
-        u16 _chunks_per_block; \
- \
-        if (_card->sdio_io_block_pad) \
-        { \
-            _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
-            _space_chunks = ((_space_chunks / _chunks_per_block) * _chunks_per_block); \
-        } \
-    }
-
-
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_fh_cmd_queue
- *
- *      Take one signal off the from-host queue and copy it to the UniFi.
- *      Does nothing if the UniFi has no slots free.
- *
- *  Arguments:
- *      card       Pointer to card context struct
- *      processed  Location to write:
- *                      0 if there is nothing on the queue to process
- *                      1 if a signal was successfully processed
- *
- *  Returns:
- *      CSR error code if an error occurred.
- *
- *  Notes:
- *      The from-host queue contains signal requests from the network driver
- *      and any UDI clients interspersed. UDI clients' requests have been stored
- *      in the from-host queue using the wire-format structures, as they arrive.
- *      All other requests are stored in the from-host queue using the host
- *      (cpu specific) structures. We use the is_packed member of the card_signal_t
- *      structure that describes the queue to make the distinction.
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed)
-{
-    q_t *sigq = &card->fh_command_queue;
-
-    CsrResult r;
-    u16 pending_sigs;
-    u16 pending_chunks;
-    u16 needed_chunks;
-    s32 space_chunks;
-    u16 q_index;
-
-    *processed = 0;
-
-    /* Get the number of pending signals. */
-    pending_sigs = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
-    unifi_trace(card->ospriv, UDBG5, "proc_fh: %d pending\n", pending_sigs);
-    if (pending_sigs == 0)
-    {
-        /* Nothing to do */
-        return CSR_RESULT_SUCCESS;
-    }
-
-    /* Work out how many chunks we have waiting to send */
-    for (pending_chunks = 0, q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
-         q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
-         q_index = CSR_WIFI_HIP_Q_WRAP(sigq, q_index + 1))
-    {
-        card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
-
-        /*
-         * Note that GET_CHUNKS_FOR() needs the size of the packed
-         * (wire-formatted) structure
-         */
-        pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
-    }
-
-    /*
-     * Check whether UniFi has space for all the buffered bulk-data
-     * commands and signals as well.
-     */
-    needed_chunks = pending_chunks + card->fh_buffer.count;
-
-    /* Round up to the block size if necessary */
-    ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
-
-    r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        /* Error */
-        unifi_error(card->ospriv, "Failed to read fh sig count\n");
-        return r;
-    }
-
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv, "proc_fh: %d chunks free, need %d\n",
-                space_chunks, needed_chunks);
-#endif /* CSR_WIFI_HIP_NOISY */
-
-
-    /*
-     * Coalesce as many from-host signals as possible
-     * into a single block and write using a single CMD53
-     */
-    if (needed_chunks > (u16)space_chunks)
-    {
-        /* Round up to the block size if necessary */
-        ROUND_UP_SPACE_CHUNKS(card, space_chunks);
-
-        /*
-         * If the f/w has less free chunks than those already pending
-         * return immediately.
-         */
-        if ((u16)space_chunks <= card->fh_buffer.count)
-        {
-            /*
-             * No room in UniFi for any signals after the buffered bulk
-             * data commands have been sent.
-             */
-            unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
-                        card->fh_buffer.count, space_chunks);
-            card->generate_interrupt = 1;
-            return CSR_RESULT_SUCCESS;
-        }
-        pending_chunks = (u16)(space_chunks - card->fh_buffer.count);
-    }
-
-    while (pending_sigs-- && pending_chunks > 0)
-    {
-        card_signal_t *csptr;
-        s16 i;
-        u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
-        bulk_data_param_t bulkdata;
-        u8 *packed_sigptr;
-        u16 signal_length = 0;
-
-        /* Retrieve the entry at the head of the queue */
-        q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
-
-        /* Get a pointer to the containing card_signal_t struct */
-        csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
-
-        /* Get the new length of the packed signal */
-        signal_length = csptr->signal_length;
-
-        if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
-        {
-            unifi_error(card->ospriv, "process_fh_queue: Bad len: %d\n", signal_length);
-            return CSR_RESULT_FAILURE;
-        }
-
-        /* Need space for 2-byte SDIO protocol header + signal */
-        sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
-
-        free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
-                                                  (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
-        if (free_chunks_in_fh_buffer < sig_chunks)
-        {
-            /* No more room */
-            unifi_notice(card->ospriv, "proc_fh_cmd_q: no room in fh buffer for 0x%.4X, deferring\n",
-                         (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
-            break;
-        }
-
-        packed_sigptr = csptr->sigbuf;
-
-        /* Claim and set up a from-host data slot */
-        if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, UNIFI_TRAFFIC_Q_MLME))
-        {
-            unifi_notice(card->ospriv, "proc_fh_cmd_q: no fh data slots for 0x%.4X, deferring\n",
-                         (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
-            break;
-        }
-
-        for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
-        {
-            if (csptr->bulkdata[i].data_length == 0)
-            {
-                UNIFI_INIT_BULK_DATA(&bulkdata.d[i]);
-            }
-            else
-            {
-                bulkdata.d[i].os_data_ptr = csptr->bulkdata[i].os_data_ptr;
-                bulkdata.d[i].data_length = csptr->bulkdata[i].data_length;
-            }
-
-            /* Pass the free responsibility to the lower layer. */
-            UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
-        }
-
-        unifi_trace(card->ospriv, UDBG2, "Sending signal 0x%.4X\n",
-                    GET_SIGNAL_ID(packed_sigptr));
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
-                    GET_SIGNAL_ID(packed_sigptr));
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-
-        /* Append packed signal to F-H buffer */
-        total_length = sig_chunks * card->config_data.sig_frag_size;
-
-        card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
-        card->fh_buffer.ptr[1] =
-            (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
-
-        memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
-        memset(card->fh_buffer.ptr + 2 + signal_length, 0,
-                  total_length - (2 + signal_length));
-
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
-                    signal_length + 2);
-        dump(card->fh_buffer.ptr, signal_length + 2);
-        unifi_trace(card->ospriv, UDBG1, " \n");
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-        card->fh_buffer.ptr += total_length;
-        card->fh_buffer.count += sig_chunks;
-
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
-                    signal_length,
-                    card->fh_buffer.ptr - card->fh_buffer.buf,
-                    card->fh_buffer.count);
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-        (*processed)++;
-        pending_chunks -= sig_chunks;
-
-        /* Log the signal to the UDI. */
-        /* UDI will get the packed structure */
-        /* Can not log the unpacked signal, unless we reconstruct it! */
-        if (card->udi_hook)
-        {
-            (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
-                              &bulkdata, UDI_LOG_FROM_HOST);
-        }
-
-        /* Remove entry from q */
-        csptr->signal_length = 0;
-        CSR_WIFI_HIP_Q_INC_R(sigq);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* process_fh_cmd_queue() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  process_fh_traffic_queue
- *
- *      Take signals off the from-host queue and copy them to the UniFi.
- *      Does nothing if the UniFi has no slots free.
- *
- *  Arguments:
- *      card       Pointer to card context struct
- *      sigq       Pointer to the traffic queue
- *      processed  Pointer to location to write:
- *                      0 if there is nothing on the queue to process
- *                      1 if a signal was successfully processed
- *
- *  Returns:
- *      CSR error code if an error occurred.
- *
- *  Notes:
- *      The from-host queue contains signal requests from the network driver
- *      and any UDI clients interspersed.
- * ---------------------------------------------------------------------------
- */
-static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed)
-{
-    q_t *sigq = card->fh_traffic_queue;
-
-    CsrResult r;
-    s16 n = 0;
-    s32 q_no;
-    u16 pending_sigs = 0;
-    u16 pending_chunks = 0;
-    u16 needed_chunks;
-    s32 space_chunks;
-    u16 q_index;
-    u32 host_tag = 0;
-    u16 slot_num = 0;
-
-    *processed = 0;
-
-    /* calculate how many signals are in queues and how many chunks are needed. */
-    for (n = UNIFI_NO_OF_TX_QS - 1; n >= 0; n--)
-    {
-        /* Get the number of pending signals. */
-        pending_sigs += CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[n]);
-        unifi_trace(card->ospriv, UDBG5, "proc_fh%d: %d pending\n", n, pending_sigs);
-
-        /* Work out how many chunks we have waiting to send */
-        for (q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[n]);
-             q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(&sigq[n]);
-             q_index = CSR_WIFI_HIP_Q_WRAP(&sigq[n], q_index + 1))
-        {
-            card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[n], q_index);
-
-            /*
-             * Note that GET_CHUNKS_FOR() needs the size of the packed
-             * (wire-formatted) structure
-             */
-            pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
-        }
-    }
-
-    /* If there are no pending signals, just return */
-    if (pending_sigs == 0)
-    {
-        /* Nothing to do */
-        return CSR_RESULT_SUCCESS;
-    }
-
-    /*
-     * Check whether UniFi has space for all the buffered bulk-data
-     * commands and signals as well.
-     */
-    needed_chunks = pending_chunks + card->fh_buffer.count;
-
-    /* Round up to the block size if necessary */
-    ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
-
-    r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        /* Error */
-        unifi_error(card->ospriv, "Failed to read fh sig count\n");
-        return r;
-    }
-
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv,
-                "process_fh_traffic_queue: %d chunks free, need %d\n",
-                space_chunks, needed_chunks);
-    read_fhsr(card);            /* debugging only */
-#endif /* CSR_WIFI_HIP_NOISY */
-
-    /* Coalesce as many from-host signals as possible
-       into a single block and write using a single CMD53 */
-    if (needed_chunks > (u16)space_chunks)
-    {
-        /* Round up to the block size if necessary */
-        ROUND_UP_SPACE_CHUNKS(card, space_chunks);
-
-        if ((u16)space_chunks <= card->fh_buffer.count)
-        {
-            /*
-             * No room in UniFi for any signals after the buffered bulk
-             * data commands have been sent.
-             */
-            unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
-                        card->fh_buffer.count, space_chunks);
-            card->generate_interrupt = 1;
-            return 0;
-        }
-
-        pending_chunks = (u16)space_chunks - card->fh_buffer.count;
-    }
-
-    q_no = UNIFI_NO_OF_TX_QS - 1;
-
-    /*
-     * pending_sigs will be exhausted if there are is no restriction to the pending
-     * signals per queue. pending_chunks may be exhausted if there is a restriction.
-     * q_no check will be exhausted if there is a restriction and our round-robin
-     * algorith fails to fill all chunks.
-     */
-    do
-    {
-        card_signal_t *csptr;
-        u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
-        bulk_data_param_t bulkdata;
-        u8 *packed_sigptr;
-        u16 signal_length = 0;
-
-        /* if this queue is empty go to next one. */
-        if (CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[q_no]) == 0)
-        {
-            q_no--;
-            continue;
-        }
-
-        /* Retrieve the entry at the head of the queue */
-        q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[q_no]);
-
-        /* Get a pointer to the containing card_signal_t struct */
-        csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[q_no], q_index);
-
-        /* Get the new length of the packed signal */
-        signal_length = csptr->signal_length;
-
-        if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
-        {
-            unifi_error(card->ospriv, "process_fh_traffic_queue: Bad len: %d\n", signal_length);
-            return CSR_RESULT_FAILURE;
-        }
-
-        /* Need space for 2-byte SDIO protocol header + signal */
-        sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
-        free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
-                                                  (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
-        if (free_chunks_in_fh_buffer < sig_chunks)
-        {
-            /* No more room */
-            unifi_notice(card->ospriv, "process_fh_traffic_queue: no more chunks.\n");
-            break;
-        }
-
-        packed_sigptr = csptr->sigbuf;
-        /* Claim and set up a from-host data slot */
-        if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, (unifi_TrafficQueue)q_no))
-        {
-            q_no--;
-            continue;
-        }
-
-        /* Sanity check: MA-PACKET.req must have a valid bulk data */
-        if ((csptr->bulkdata[0].data_length == 0) || (csptr->bulkdata[0].os_data_ptr == NULL))
-        {
-            unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
-                        csptr->bulkdata[0].data_length, csptr->bulkdata[0].os_data_ptr);
-            dump(packed_sigptr, signal_length);
-            return CSR_RESULT_FAILURE;
-        }
-
-        bulkdata.d[0].os_data_ptr = csptr->bulkdata[0].os_data_ptr;
-        bulkdata.d[0].data_length = csptr->bulkdata[0].data_length;
-        bulkdata.d[0].os_net_buf_ptr = csptr->bulkdata[0].os_net_buf_ptr;
-        bulkdata.d[0].net_buf_length = csptr->bulkdata[0].net_buf_length;
-
-        /* The driver owns clearing of HIP slots for following scenario
-         * - driver has requested a MA-PACKET.req signal
-         * - The f/w after receiving the signal decides it can't send it out due to various reasons
-         * - So the f/w without downloading the bulk data decides to just send a confirmation with fail
-         * - and then sends a clear slot signal to HIP
-         *
-         * But in some cases the clear slot signal never comes and the slot remains --NOT-- freed for ever
-         *
-         * To handle this, HIP will keep the record of host tag for each occupied slot
-         * and then based on status of that Host tag and slot the driver will decide if the slot is
-         * cleared by f/w signal or the slot has to be freed by driver
-         */
-
-        if (card->fh_slot_host_tag_record)
-        {
-            /* Update the f-h slot record for the corresponding host tag */
-            host_tag = GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(packed_sigptr);
-            slot_num = GET_PACKED_DATAREF_SLOT(packed_sigptr, 0) & 0x00FF;
-
-            unifi_trace(card->ospriv, UDBG5,
-                        "process_fh_traffic_queue signal ID =%x fh slot=%x Host tag =%x\n",
-                        GET_SIGNAL_ID(packed_sigptr), slot_num, host_tag);
-            card->fh_slot_host_tag_record[slot_num] = host_tag;
-        }
-        UNIFI_INIT_BULK_DATA(&bulkdata.d[1]);
-        UNIFI_INIT_BULK_DATA(&csptr->bulkdata[0]);
-        UNIFI_INIT_BULK_DATA(&csptr->bulkdata[1]);
-
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-        if (bulkdata.d[0].os_data_ptr)
-        {
-            if ((*bulkdata.d[0].os_data_ptr) & 0x08)
-            {
-                card->cmd_prof.tx_count++;
-            }
-        }
-#endif
-        unifi_trace(card->ospriv, UDBG3, "Sending signal 0x%.4X\n",
-                    GET_SIGNAL_ID(packed_sigptr));
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
-                    GET_SIGNAL_ID(packed_sigptr));
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-        /* Append packed signal to F-H buffer */
-        total_length = sig_chunks * card->config_data.sig_frag_size;
-
-        card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
-        card->fh_buffer.ptr[1] =
-            (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
-
-        memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
-        memset(card->fh_buffer.ptr + 2 + signal_length, 0,
-                  total_length - (2 + signal_length));
-
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
-                    signal_length + 2);
-        dump(card->fh_buffer.ptr, signal_length + 2);
-        unifi_trace(card->ospriv, UDBG1, " \n");
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-        card->fh_buffer.ptr += total_length;
-        card->fh_buffer.count += sig_chunks;
-
-#ifdef CSR_WIFI_HIP_NOISY
-        unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
-                    signal_length,
-                    card->fh_buffer.ptr - card->fh_buffer.buf,
-                    card->fh_buffer.count);
-#endif  /* CSR_WIFI_HIP_NOISY */
-
-        (*processed)++;
-        pending_sigs--;
-        pending_chunks -= sig_chunks;
-
-        /* Log the signal to the UDI. */
-        /* UDI will get the packed structure */
-        /* Can not log the unpacked signal, unless we reconstruct it! */
-        if (card->udi_hook)
-        {
-            (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
-                              &bulkdata, UDI_LOG_FROM_HOST);
-        }
-
-        /* Remove entry from q */
-        csptr->signal_length = 0;
-        /* Note that the traffic queue has only one valid bulk data buffer. */
-        csptr->bulkdata[0].data_length = 0;
-
-        CSR_WIFI_HIP_Q_INC_R(&sigq[q_no]);
-    } while ((pending_sigs > 0) && (pending_chunks > 0) && (q_no >= 0));
-
-    return CSR_RESULT_SUCCESS;
-} /* process_fh_traffic_queue() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  flush_fh_buffer
- *
- *      Write out the cache from-hosts signals to the UniFi.
- *
- *  Arguments:
- *      card       Pointer to card context struct
- *
- *  Returns:
- *      CSR error code if an SDIO error occurred.
- * ---------------------------------------------------------------------------
- */
-static CsrResult flush_fh_buffer(card_t *card)
-{
-    CsrResult r;
-    u16 len;
-    u16 sig_units;
-    u16 data_round;
-    u16 chunks_in_last_block;
-    u16 padding_chunks;
-    u16 i;
-
-    len = card->fh_buffer.ptr - card->fh_buffer.buf;
-
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv, "fh_buffer is at %p, ptr= %p\n",
-                card->fh_buffer.buf, card->fh_buffer.ptr);
-#endif /* CSR_WIFI_HIP_NOISY */
-
-    if (len == 0)
-    {
-        return CSR_RESULT_SUCCESS;
-    }
-
-#ifdef CSR_WIFI_HIP_NOISY
-    if (dump_fh_buf)
-    {
-        dump(card->fh_buffer.buf, len);
-        dump_fh_buf = 0;
-    }
-#endif /* CSR_WIFI_HIP_NOISY */
-
-    if (card->sdio_io_block_pad)
-    {
-        /* Both of these are powers of 2 */
-        sig_units = card->config_data.sig_frag_size;
-        data_round = card->sdio_io_block_size;
-
-        if (data_round > sig_units)
-        {
-            chunks_in_last_block = (len % data_round) / sig_units;
-
-            if (chunks_in_last_block != 0)
-            {
-                padding_chunks = (data_round / sig_units) - chunks_in_last_block;
-
-                memset(card->fh_buffer.ptr, 0, padding_chunks * sig_units);
-                for (i = 0; i < padding_chunks; i++)
-                {
-                    card->fh_buffer.ptr[1] = SDIO_CMD_PADDING << 4;
-                    card->fh_buffer.ptr += sig_units;
-                }
-
-                card->fh_buffer.count += padding_chunks;
-                len += padding_chunks * sig_units;
-            }
-        }
-    }
-
-    r = unifi_bulk_rw(card,
-                      card->config_data.fromhost_sigbuf_handle,
-                      card->fh_buffer.buf,
-                      len, UNIFI_SDIO_WRITE);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write fh signals: %u bytes, error %d\n", len, r);
-        return r;
-    }
-
-    /* Update from-host-signals-written signal count */
-    card->from_host_signals_w =
-        (card->from_host_signals_w + card->fh_buffer.count) % 128u;
-    r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 0,
-                            (u8)card->from_host_signals_w);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write fh signal count %u with error %d\n",
-                    card->from_host_signals_w, r);
-        return r;
-    }
-    card->generate_interrupt = 1;
-
-    /* Reset the fh buffer pointer */
-    card->fh_buffer.ptr = card->fh_buffer.buf;
-    card->fh_buffer.count = 0;
-
-#ifdef CSR_WIFI_HIP_NOISY
-    unifi_error(card->ospriv, "END flush: fh len %d, count %d\n",
-                card->fh_buffer.ptr - card->fh_buffer.buf,
-                card->fh_buffer.count);
-#endif /* CSR_WIFI_HIP_NOISY */
-
-    return CSR_RESULT_SUCCESS;
-} /* flush_fh_buffer() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  restart_packet_flow
- *
- *      This function is called before the bottom-half thread sleeps.
- *      It checks whether both data and signal resources are available and
- *      then calls the OS-layer function to re-enable packet transmission.
- *
- *  Arguments:
- *      card       Pointer to card context struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void restart_packet_flow(card_t *card)
-{
-    u8 q;
-
-    /*
-     * We only look at the fh_traffic_queue, because that is where packets from
-     * the network stack are placed.
-     */
-    for (q = 0; q <= UNIFI_TRAFFIC_Q_VO; q++)
-    {
-        if (card_is_tx_q_paused(card, q) &&
-            CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[q]) >= RESUME_XMIT_THRESHOLD)
-        {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-            unifi_debug_log_to_buf("U");
-#endif
-            card_tx_q_unpause(card, q);
-            unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue)q);
-        }
-    }
-} /* restart_packet_flow() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c b/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c
deleted file mode 100644 (file)
index 17867f6..0000000
+++ /dev/null
@@ -1,1713 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- * FILE: csr_wifi_hip_card_sdio_mem.c
- *
- * PURPOSE: Implementation of the Card API for SDIO.
- *
- * ---------------------------------------------------------------------------
- */
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_card.h"
-
-#define SDIO_RETRIES    3
-#define CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH 16
-
-
-#define retryable_sdio_error(_csrResult) (((_csrResult) == CSR_SDIO_RESULT_CRC_ERROR) || ((_csrResult) == CSR_SDIO_RESULT_TIMEOUT))
-
-
-/*
- * ---------------------------------------------------------------------------
- *  retrying_read8
- *  retrying_write8
- *
- *      These functions provide the first level of retry for SDIO operations.
- *      If an SDIO command fails for reason of a response timeout or CRC
- *      error, it is retried immediately. If three attempts fail we report a
- *      failure.
- *      If the command failed for any other reason, the failure is reported
- *      immediately.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      funcnum         The SDIO function to access.
- *                      Function 0 is the Card Configuration Register space,
- *                      function 1/2 is the UniFi register space.
- *      addr            Address to access
- *      pdata           Pointer in which to return the value read.
- *      data            Value to write.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS  on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-static CsrResult retrying_read8(card_t *card, s16 funcnum, u32 addr, u8 *pdata)
-{
-    CsrSdioFunction *sdio = card->sdio_if;
-    CsrResult r = CSR_RESULT_SUCCESS;
-    s16 retries;
-    CsrResult csrResult = CSR_RESULT_SUCCESS;
-
-    retries = 0;
-    while (retries++ < SDIO_RETRIES)
-    {
-        if (funcnum == 0)
-        {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-            unifi_debug_log_to_buf("r0@%02X", addr);
-#endif
-            csrResult = CsrSdioF0Read8(sdio, addr, pdata);
-        }
-        else
-        {
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-            unifi_error(card->ospriv,
-                        "retrying_read_f0_8: F1 8-bit reads are not allowed.\n");
-            return CSR_RESULT_FAILURE;
-#else
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-            unifi_debug_log_to_buf("r@%02X", addr);
-#endif
-            csrResult = CsrSdioRead8(sdio, addr, pdata);
-#endif
-        }
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            unifi_debug_log_to_buf("error=%X\n", csrResult);
-        }
-        else
-        {
-            unifi_debug_log_to_buf("=%X\n", *pdata);
-        }
-#endif
-        if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-        {
-            return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        }
-        /*
-         * Try again for retryable (CRC or TIMEOUT) errors,
-         * break on success or fatal error
-         */
-        if (!retryable_sdio_error(csrResult))
-        {
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-            card->cmd_prof.cmd52_count++;
-#endif
-            break;
-        }
-        unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
-    }
-
-    if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
-    {
-        unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
-    }
-
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
-                    addr, retries - 1);
-        /* Report any SDIO error as a general i/o error */
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* retrying_read8() */
-
-
-static CsrResult retrying_write8(card_t *card, s16 funcnum, u32 addr, u8 data)
-{
-    CsrSdioFunction *sdio = card->sdio_if;
-    CsrResult r = CSR_RESULT_SUCCESS;
-    s16 retries;
-    CsrResult csrResult = CSR_RESULT_SUCCESS;
-
-    retries = 0;
-    while (retries++ < SDIO_RETRIES)
-    {
-        if (funcnum == 0)
-        {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-            unifi_debug_log_to_buf("w0@%02X=%X", addr, data);
-#endif
-            csrResult = CsrSdioF0Write8(sdio, addr, data);
-        }
-        else
-        {
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-            unifi_error(card->ospriv,
-                        "retrying_write_f0_8: F1 8-bit writes are not allowed.\n");
-            return CSR_RESULT_FAILURE;
-#else
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-            unifi_debug_log_to_buf("w@%02X=%X", addr, data);
-#endif
-            csrResult = CsrSdioWrite8(sdio, addr, data);
-#endif
-        }
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            unifi_debug_log_to_buf(",error=%X", csrResult);
-        }
-        unifi_debug_string_to_buf("\n");
-#endif
-        if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-        {
-            return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        }
-        /*
-         * Try again for retryable (CRC or TIMEOUT) errors,
-         * break on success or fatal error
-         */
-        if (!retryable_sdio_error(csrResult))
-        {
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-            card->cmd_prof.cmd52_count++;
-#endif
-            break;
-        }
-        unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
-                    data, funcnum, addr);
-    }
-
-    if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
-    {
-        unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
-    }
-
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
-                    addr, retries - 1);
-        /* Report any SDIO error as a general i/o error */
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* retrying_write8() */
-
-
-static CsrResult retrying_read16(card_t *card, s16 funcnum,
-                                 u32 addr, u16 *pdata)
-{
-    CsrSdioFunction *sdio = card->sdio_if;
-    CsrResult r = CSR_RESULT_SUCCESS;
-    s16 retries;
-    CsrResult csrResult = CSR_RESULT_SUCCESS;
-
-    retries = 0;
-    while (retries++ < SDIO_RETRIES)
-    {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        unifi_debug_log_to_buf("r@%02X", addr);
-#endif
-        csrResult = CsrSdioRead16(sdio, addr, pdata);
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            unifi_debug_log_to_buf("error=%X\n", csrResult);
-        }
-        else
-        {
-            unifi_debug_log_to_buf("=%X\n", *pdata);
-        }
-#endif
-        if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-        {
-            return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        }
-
-        /*
-         * Try again for retryable (CRC or TIMEOUT) errors,
-         * break on success or fatal error
-         */
-        if (!retryable_sdio_error(csrResult))
-        {
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-            card->cmd_prof.cmd52_count++;
-#endif
-            break;
-        }
-        unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
-    }
-
-    if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
-    {
-        unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
-    }
-
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
-                    addr, retries - 1);
-        /* Report any SDIO error as a general i/o error */
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* retrying_read16() */
-
-
-static CsrResult retrying_write16(card_t *card, s16 funcnum,
-                                  u32 addr, u16 data)
-{
-    CsrSdioFunction *sdio = card->sdio_if;
-    CsrResult r = CSR_RESULT_SUCCESS;
-    s16 retries;
-    CsrResult csrResult = CSR_RESULT_SUCCESS;
-
-    retries = 0;
-    while (retries++ < SDIO_RETRIES)
-    {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        unifi_debug_log_to_buf("w@%02X=%X", addr, data);
-#endif
-        csrResult = CsrSdioWrite16(sdio, addr, data);
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            unifi_debug_log_to_buf(",error=%X", csrResult);
-        }
-        unifi_debug_string_to_buf("\n");
-#endif
-        if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-        {
-            return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        }
-
-        /*
-         * Try again for retryable (CRC or TIMEOUT) errors,
-         * break on success or fatal error
-         */
-        if (!retryable_sdio_error(csrResult))
-        {
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-            card->cmd_prof.cmd52_count++;
-#endif
-            break;
-        }
-        unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
-                    data, funcnum, addr);
-    }
-
-    if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
-    {
-        unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
-    }
-
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
-                    addr, retries - 1);
-        /* Report any SDIO error as a general i/o error */
-        r = CSR_RESULT_FAILURE;
-    }
-
-    return r;
-} /* retrying_write16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  sdio_read_f0
- *
- *      Reads a byte value from the CCCR (func 0) area of UniFi.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to read from
- *      pdata   Pointer in which to store the read value.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata)
-{
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_f0_r_count++;
-#endif
-    return retrying_read8(card, 0, addr, pdata);
-} /* sdio_read_f0() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  sdio_write_f0
- *
- *      Writes a byte value to the CCCR (func 0) area of UniFi.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to read from
- *      data    Data value to write.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data)
-{
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_f0_w_count++;
-#endif
-    return retrying_write8(card, 0, addr, data);
-} /* sdio_write_f0() */
-
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_read_direct_8_or_16
- *
- *      Read a 8-bit value from the UniFi SDIO interface.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to read from
- *      pdata   Pointer in which to return data.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata)
-{
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-    u16 w;
-    CsrResult r;
-
-    r = retrying_read16(card, card->function, addr, &w);
-    *pdata = (u8)(w & 0xFF);
-    return r;
-#else
-    return retrying_read8(card, card->function, addr, pdata);
-#endif
-} /* unifi_read_direct_8_or_16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_write_direct_8_or_16
- *
- *      Write a byte value to the UniFi SDIO interface.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to write to
- *      data    Value to write.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error
- *
- *  Notes:
- *      If 8-bit write is used, the even address *must* be written second.
- *      This is because writes to odd bytes are cached and not committed
- *      to memory until the preceding even address is written.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data)
-{
-    if (addr & 1)
-    {
-        unifi_warning(card->ospriv,
-                      "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
-                      addr);
-    }
-
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-    return retrying_write16(card, card->function, addr, (u16)data);
-#else
-    return retrying_write8(card, card->function, addr, data);
-#endif
-} /* unifi_write_direct_8_or_16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read_direct16
- *
- *      Read a 16-bit value from the UniFi SDIO interface.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to read from
- *      pdata   Pointer in which to return data.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      The even address *must* be read first. This is because reads from
- *      odd bytes are cached and read from memory when the preceding
- *      even address is read.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata)
-{
-    return retrying_read16(card, card->function, addr, pdata);
-} /* unifi_read_direct16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_write_direct16
- *
- *      Write a 16-bit value to the UniFi SDIO interface.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to write to
- *      data    Value to write.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      The even address *must* be written second. This is because writes to
- *      odd bytes are cached and not committed to memory until the preceding
- *      even address is written.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data)
-{
-    return retrying_write16(card, card->function, addr, data);
-} /* unifi_write_direct16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read_direct32
- *
- *      Read a 32-bit value from the UniFi SDIO interface.
- *
- *  Arguments:
- *      card    Pointer to card structure.
- *      addr    Address to read from
- *      pdata   Pointer in which to return data.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata)
-{
-    CsrResult r;
-    u16 w0, w1;
-
-    r = retrying_read16(card, card->function, addr, &w0);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    r = retrying_read16(card, card->function, addr + 2, &w1);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    *pdata = ((u32)w1 << 16) | (u32)w0;
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_read_direct32() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read_directn_match
- *
- *      Read multiple 8-bit values from the UniFi SDIO interface,
- *      stopping when either we have read 'len' bytes or we have read
- *      a octet equal to 'match'.  If 'match' is not a valid octet
- *      then this function is the same as 'unifi_read_directn'.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      addr            Start address to read from.
- *      pdata           Pointer to which to write data.
- *      len             Maximum umber of bytes to read
- *      match           The value to stop reading at.
- *      num             Pointer to buffer to write number of bytes read
- *
- *  Returns:
- *      number of octets read on success, negative error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      The even address *must* be read first. This is because reads from
- *      odd bytes are cached and read from memory when the preceding
- *      even address is read.
- * ---------------------------------------------------------------------------
- */
-static CsrResult unifi_read_directn_match(card_t *card, u32 addr, void *pdata, u16 len, s8 m, u32 *num)
-{
-    CsrResult r;
-    u32 i;
-    u8 *cptr;
-    u16 w;
-
-    *num = 0;
-
-    cptr = (u8 *)pdata;
-    for (i = 0; i < len; i += 2)
-    {
-        r = retrying_read16(card, card->function, addr, &w);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-
-        *cptr++ = ((u8)w & 0xFF);
-        if ((m >= 0) && (((s8)w & 0xFF) == m))
-        {
-            break;
-        }
-
-        if (i + 1 == len)
-        {
-            /* The len is odd. Ignore the last high byte */
-            break;
-        }
-
-        *cptr++ = ((u8)(w >> 8) & 0xFF);
-        if ((m >= 0) && (((s8)(w >> 8) & 0xFF) == m))
-        {
-            break;
-        }
-
-        addr += 2;
-    }
-
-    *num = (s32)(cptr - (u8 *)pdata);
-    return CSR_RESULT_SUCCESS;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read_directn
- *
- *      Read multiple 8-bit values from the UniFi SDIO interface.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      addr            Start address to read from.
- *      pdata           Pointer to which to write data.
- *      len             Number of bytes to read
- *
- *  Returns:
- *      0 on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      The even address *must* be read first. This is because reads from
- *      odd bytes are cached and read from memory when the preceding
- *      even address is read.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len)
-{
-    u32 num;
-
-    return unifi_read_directn_match(card, addr, pdata, len, -1, &num);
-} /* unifi_read_directn() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_write_directn
- *
- *      Write multiple 8-bit values to the UniFi SDIO interface.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      addr            Start address to write to.
- *      pdata           Source data pointer.
- *      len             Number of bytes to write, must be even.
- *
- *  Returns:
- *      0 on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      The UniFi has a peculiar 16-bit bus architecture. Writes are only
- *      committed to memory when an even address is accessed. Writes to
- *      odd addresses are cached and only committed if the next write is
- *      to the preceding address.
- *      This means we must write data as pairs of bytes in reverse order.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len)
-{
-    CsrResult r;
-    u8 *cptr;
-    s16 signed_len;
-
-    cptr = (u8 *)pdata;
-    signed_len = (s16)len;
-    while (signed_len > 0)
-    {
-        /* This is UniFi-1 specific code. CSPI not supported so 8-bit write allowed */
-        r = retrying_write16(card, card->function, addr, *cptr);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-
-        cptr += 2;
-        addr += 2;
-        signed_len -= 2;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_write_directn() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  set_dmem_page
- *  set_pmem_page
- *
- *      Set up the page register for the shared data memory window or program
- *      memory window.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      dmem_addr       UniFi shared-data-memory address to access.
- *      pmem_addr       UniFi program memory address to access. This includes
- *                        External FLASH memory at    0x000000
- *                        Processor program memory at 0x200000
- *                        External SRAM at memory     0x400000
- *      paddr           Location to write an SDIO address (24-bit) for
- *                       use in a unifi_read_direct or unifi_write_direct call.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
- *      CSR_RESULT_FAILURE an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-static CsrResult set_dmem_page(card_t *card, u32 dmem_addr, u32 *paddr)
-{
-    u16 page, addr;
-    u32 len;
-    CsrResult r;
-
-    *paddr = 0;
-
-    if (!ChipHelper_DecodeWindow(card->helper,
-                                 CHIP_HELPER_WINDOW_3,
-                                 CHIP_HELPER_WT_SHARED,
-                                 dmem_addr / 2,
-                                 &page, &addr, &len))
-    {
-        unifi_error(card->ospriv, "Failed to decode SHARED_DMEM_PAGE %08lx\n", dmem_addr);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    if (page != card->dmem_page)
-    {
-        unifi_trace(card->ospriv, UDBG6, "setting dmem page=0x%X, addr=0x%lX\n", page, addr);
-
-        /* change page register */
-        r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, page);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
-            return r;
-        }
-
-        card->dmem_page = page;
-    }
-
-    *paddr = ((s32)addr * 2) + (dmem_addr & 1);
-
-    return CSR_RESULT_SUCCESS;
-} /* set_dmem_page() */
-
-
-static CsrResult set_pmem_page(card_t *card, u32 pmem_addr,
-                               enum chip_helper_window_type mem_type, u32 *paddr)
-{
-    u16 page, addr;
-    u32 len;
-    CsrResult r;
-
-    *paddr = 0;
-
-    if (!ChipHelper_DecodeWindow(card->helper,
-                                 CHIP_HELPER_WINDOW_2,
-                                 mem_type,
-                                 pmem_addr / 2,
-                                 &page, &addr, &len))
-    {
-        unifi_error(card->ospriv, "Failed to decode PROG MEM PAGE %08lx %d\n", pmem_addr, mem_type);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    if (page != card->pmem_page)
-    {
-        unifi_trace(card->ospriv, UDBG6, "setting pmem page=0x%X, addr=0x%lX\n", page, addr);
-
-        /* change page register */
-        r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, page);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to write PROG MEM PAGE\n");
-            return r;
-        }
-
-        card->pmem_page = page;
-    }
-
-    *paddr = ((s32)addr * 2) + (pmem_addr & 1);
-
-    return CSR_RESULT_SUCCESS;
-} /* set_pmem_page() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  set_page
- *
- *      Sets up the appropriate page register to access the given address.
- *      Returns the sdio address at which the unifi address can be accessed.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      generic_addr    UniFi internal address to access, in Generic Pointer
- *                      format, i.e. top byte is space indicator.
- *      paddr           Location to write page address
- *                          SDIO address (24-bit) for use in a unifi_read_direct or
- *                          unifi_write_direct call
- *
- *  Returns:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE  the address is invalid
- * ---------------------------------------------------------------------------
- */
-static CsrResult set_page(card_t *card, u32 generic_addr, u32 *paddr)
-{
-    s32 space;
-    u32 addr;
-    CsrResult r = CSR_RESULT_SUCCESS;
-
-    if (!paddr)
-    {
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-    *paddr = 0;
-    space = UNIFI_GP_SPACE(generic_addr);
-    addr = UNIFI_GP_OFFSET(generic_addr);
-    switch (space)
-    {
-        case UNIFI_SH_DMEM:
-            /* Shared Data Memory is accessed via the Shared Data Memory window */
-            r = set_dmem_page(card, addr, paddr);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            break;
-
-        case UNIFI_EXT_FLASH:
-            if (!ChipHelper_HasFlash(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            /* External FLASH is accessed via the Program Memory window */
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_FLASH, paddr);
-            break;
-
-        case UNIFI_EXT_SRAM:
-            if (!ChipHelper_HasExtSram(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08l (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            /* External SRAM is accessed via the Program Memory window */
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_EXT_SRAM, paddr);
-            break;
-
-        case UNIFI_REGISTERS:
-            /* Registers are accessed directly */
-            *paddr = addr;
-            break;
-
-        case UNIFI_PHY_DMEM:
-            r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
-            break;
-
-        case UNIFI_MAC_DMEM:
-            r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
-            break;
-
-        case UNIFI_BT_DMEM:
-            if (!ChipHelper_HasBt(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            r = unifi_set_proc_select(card, UNIFI_PROC_BT);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
-            break;
-
-        case UNIFI_PHY_PMEM:
-            r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
-            break;
-
-        case UNIFI_MAC_PMEM:
-            r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
-            break;
-
-        case UNIFI_BT_PMEM:
-            if (!ChipHelper_HasBt(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            r = unifi_set_proc_select(card, UNIFI_PROC_BT);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
-            break;
-
-        case UNIFI_PHY_ROM:
-            if (!ChipHelper_HasRom(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
-            break;
-
-        case UNIFI_MAC_ROM:
-            if (!ChipHelper_HasRom(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
-            break;
-
-        case UNIFI_BT_ROM:
-            if (!ChipHelper_HasRom(card->helper) || !ChipHelper_HasBt(card->helper))
-            {
-                unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
-                            generic_addr, card->helper);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            r = unifi_set_proc_select(card, UNIFI_PROC_BT);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                return r;
-            }
-            r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
-            break;
-
-        default:
-            unifi_error(card->ospriv, "Bad address space %d in generic pointer 0x%08lX (helper=0x%x)\n",
-                        space, generic_addr, card->helper);
-            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    return r;
-} /* set_page() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_set_proc_select
- *
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      select          Which XAP core to select
- *
- *  Returns:
- *      0 on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select)
-{
-    CsrResult r;
-
-    /* Verify the the select value is allowed. */
-    switch (select)
-    {
-        case UNIFI_PROC_MAC:
-        case UNIFI_PROC_PHY:
-        case UNIFI_PROC_BOTH:
-            break;
-
-
-        default:
-            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    if (card->proc_select != (u32)select)
-    {
-        r = unifi_write_direct16(card,
-                                 ChipHelper_DBG_HOST_PROC_SELECT(card->helper) * 2,
-                                 (u8)select);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to write to Proc Select register\n");
-            return r;
-        }
-
-        card->proc_select = (u32)select;
-    }
-
-    return CSR_RESULT_SUCCESS;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_read_8_or_16
- *
- * Performs a byte read of the given address in shared data memory.
- * Set up the shared data memory page register as required.
- *
- * Arguments:
- * card Pointer to card structure.
- * unifi_addr UniFi shared-data-memory address to access.
- * pdata Pointer to a byte variable for the value read.
- *
- * Returns:
- * CSR_RESULT_SUCCESS on success, non-zero error code on error:
- * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
- * CSR_RESULT_FAILURE an SDIO error occurred
- * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata)
-{
-    u32 sdio_addr;
-    CsrResult r;
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-    u16 w;
-#endif
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_r8or16_count++;
-#endif
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-    r = retrying_read16(card, card->function, sdio_addr, &w);
-    *pdata = (u8)(w & 0xFF);
-    return r;
-#else
-    return retrying_read8(card, card->function, sdio_addr, pdata);
-#endif
-} /* unifi_read_8_or_16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_write_8_or_16
- *
- * Performs a byte write of the given address in shared data memory.
- * Set up the shared data memory page register as required.
- *
- * Arguments:
- * card Pointer to card context struct.
- * unifi_addr UniFi shared-data-memory address to access.
- * data Value to write.
- *
- * Returns:
- * CSR_RESULT_SUCCESS on success, non-zero error code on error:
- * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
- * CSR_RESULT_FAILURE an SDIO error occurred
- * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
- *
- * Notes:
- * Beware using unifi_write8() because byte writes are not safe on UniFi.
- * Writes to odd bytes are cached, writes to even bytes perform a 16-bit
- * write with the previously cached odd byte.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data)
-{
-    u32 sdio_addr;
-    CsrResult r;
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-    u16 w;
-#endif
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    if (sdio_addr & 1)
-    {
-        unifi_warning(card->ospriv,
-                      "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
-                      sdio_addr);
-    }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_w8or16_count++;
-#endif
-#ifdef CSR_WIFI_TRANSPORT_CSPI
-    w = data;
-    return retrying_write16(card, card->function, sdio_addr, w);
-#else
-    return retrying_write8(card, card->function, sdio_addr, data);
-#endif
-} /* unifi_write_8_or_16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_card_read16
- *
- *      Performs a 16-bit read of the given address in shared data memory.
- *      Set up the shared data memory page register as required.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      unifi_addr      UniFi shared-data-memory address to access.
- *      pdata           Pointer to a 16-bit int variable for the value read.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE  a bad generic pointer was specified
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata)
-{
-    u32 sdio_addr;
-    CsrResult r;
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_r16_count++;
-#endif
-    return unifi_read_direct16(card, sdio_addr, pdata);
-} /* unifi_card_read16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_card_write16
- *
- *      Performs a 16-bit write of the given address in shared data memory.
- *      Set up the shared data memory page register as required.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      unifi_addr      UniFi shared-data-memory address to access.
- *      pdata           Pointer to a byte variable for the value write.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE  a bad generic pointer was specified
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data)
-{
-    u32 sdio_addr;
-    CsrResult r;
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_w16_count++;
-#endif
-    return unifi_write_direct16(card, sdio_addr, data);
-} /* unifi_card_write16() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read32
- *
- *      Performs a 32-bit read of the given address in shared data memory.
- *      Set up the shared data memory page register as required.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      unifi_addr      UniFi shared-data-memory address to access.
- *      pdata           Pointer to a int variable for the value read.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE  a bad generic pointer was specified
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata)
-{
-    u32 sdio_addr;
-    CsrResult r;
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-    card->cmd_prof.cmd52_r32_count++;
-#endif
-    return unifi_read_direct32(card, sdio_addr, pdata);
-} /* unifi_read32() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_card_readn
- *  unifi_readnz
- *
- *      Read multiple 8-bit values from the UniFi SDIO interface.
- *      This function interprets the address as a GenericPointer as
- *      defined in the UniFi Host Interface Protocol Specification.
- *      The readnz version of this function will stop when it reads a
- *      zero octet.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      unifi_addr      UniFi shared-data-memory address to access.
- *      pdata           Pointer to which to write data.
- *      len             Number of bytes to read
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE  a bad generic pointer was specified
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_readn_match(card_t *card, u32 unifi_addr, void *pdata, u16 len, s8 match)
-{
-    u32 sdio_addr;
-    CsrResult r;
-    u32 num;
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    r = unifi_read_directn_match(card, sdio_addr, pdata, len, match, &num);
-    return r;
-} /* unifi_readn_match() */
-
-
-CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len)
-{
-    return unifi_readn_match(card, unifi_addr, pdata, len, -1);
-} /* unifi_card_readn() */
-
-
-CsrResult unifi_readnz(card_t *card, u32 unifi_addr, void *pdata, u16 len)
-{
-    return unifi_readn_match(card, unifi_addr, pdata, len, 0);
-} /* unifi_readnz() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read_shared_count
- *
- *      Read signal count locations, checking for an SDIO error.  The
- *      signal count locations only contain a valid number if the
- *      highest bit isn't set.
- *
- *  Arguments:
- *      card            Pointer to card context structure.
- *      addr            Shared-memory address to read.
- *
- *  Returns:
- *      Value read from memory (0-127) or -1 on error
- * ---------------------------------------------------------------------------
- */
-s32 unifi_read_shared_count(card_t *card, u32 addr)
-{
-    u8 b;
-    /* I've increased this count, because I have seen cases where
-     * there were three reads in a row with the top bit set.  I'm not
-     * sure why this might have happened, but I can't see a problem
-     * with increasing this limit.  It's better to take a while to
-     * recover than to fail. */
-#define SHARED_READ_RETRY_LIMIT 10
-    s32 i;
-
-    /*
-     * Get the to-host-signals-written count.
-     * The top-bit will be set if the firmware was in the process of
-     * changing the value, in which case we read again.
-     */
-    /* Limit the number of repeats so we don't freeze */
-    for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
-    {
-        CsrResult r;
-        r = unifi_read_8_or_16(card, addr, &b);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return -1;
-        }
-        if (!(b & 0x80))
-        {
-            /* There is a chance that the MSB may have contained invalid data
-             * (overflow) at the time it was read. Therefore mask off the MSB.
-             * This avoids a race between driver read and firmware write of the
-             * word, the value we need is in the lower 8 bits anway.
-             */
-            return (s32)(b & 0xff);
-        }
-    }
-
-    return -1;                  /* this function has changed in WMM mods */
-} /* unifi_read_shared_count() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_writen
- *
- *      Write multiple 8-bit values to the UniFi SDIO interface using CMD52
- *      This function interprets the address as a GenericPointer as
- *      defined in the UniFi Host Interface Protocol Specification.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      unifi_addr      UniFi shared-data-memory address to access.
- *      pdata           Pointer to which to write data.
- *      len             Number of bytes to write
- *
- *  Returns:
- *      0 on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE    an odd length or length too big.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len)
-{
-    u32 sdio_addr;
-    CsrResult r;
-
-    r = set_page(card, unifi_addr, &sdio_addr);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    return unifi_write_directn(card, sdio_addr, pdata, len);
-} /* unifi_writen() */
-
-
-static CsrResult csr_sdio_block_rw(card_t *card, s16 funcnum,
-                                   u32 addr, u8 *pdata,
-                                   u16 count, s16 dir_is_write)
-{
-    CsrResult csrResult;
-
-    if (dir_is_write == UNIFI_SDIO_READ)
-    {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        unifi_debug_log_to_buf("r@%02X#%X=", addr, count);
-#endif
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-        unifi_debug_log_to_buf("R");
-#endif
-        csrResult = CsrSdioRead(card->sdio_if, addr, pdata, count);
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-        unifi_debug_log_to_buf("<");
-#endif
-    }
-    else
-    {
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-        unifi_debug_log_to_buf("w@%02X#%X=", addr, count);
-        unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
-#endif
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-        unifi_debug_log_to_buf("W");
-#endif
-        csrResult = CsrSdioWrite(card->sdio_if, addr, pdata, count);
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-        unifi_debug_log_to_buf(">");
-#endif
-    }
-#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
-    card->cmd_prof.cmd53_count++;
-#endif
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_debug_log_to_buf("error=%X", csrResult);
-    }
-    else if (dir_is_write == UNIFI_SDIO_READ)
-    {
-        unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
-    }
-    unifi_debug_string_to_buf("\n");
-#endif
-    return csrResult;  /* CSR SDIO (not HIP) error code */
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_bulk_rw
- *
- *      Transfer bulk data to or from the UniFi SDIO interface.
- *      This function is used to read or write signals and bulk data.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      handle          Value to put in the Register Address field of the CMD53 req.
- *      data            Pointer to data to write.
- *      direction       One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      This function uses SDIO CMD53, which is the block transfer mode.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_bulk_rw(card_t *card, u32 handle, void *pdata,
-                        u32 len, s16 direction)
-{
-#define CMD53_RETRIES 3
-    /*
-     * Ideally instead of sleeping, we want to busy wait.
-     * Currently there is no framework API to do this. When it becomes available,
-     * we can use it to busy wait using usecs
-     */
-#define REWIND_RETRIES          15    /* when REWIND_DELAY==1msec, or 250 when REWIND_DELAY==50usecs */
-#define REWIND_POLLING_RETRIES  5
-#define REWIND_DELAY            1     /* msec or 50usecs */
-    CsrResult csrResult;              /* SDIO error code */
-    CsrResult r = CSR_RESULT_SUCCESS; /* HIP error code */
-    s16 retries = CMD53_RETRIES;
-    s16 stat_retries;
-    u8 stat;
-    s16 dump_read;
-#ifdef UNIFI_DEBUG
-    u8 *pdata_lsb = ((u8 *)&pdata) + card->lsb;
-#endif
-#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
-    static s16 fake_error;
-#endif
-
-    dump_read = 0;
-#ifdef UNIFI_DEBUG
-    if (*pdata_lsb & 1)
-    {
-        unifi_notice(card->ospriv, "CD53 request on a unaligned buffer (addr: 0x%X) dir %s-Host\n",
-                     pdata, (direction == UNIFI_SDIO_READ)?"To" : "From");
-        if (direction == UNIFI_SDIO_WRITE)
-        {
-            dump(pdata, (u16)len);
-        }
-        else
-        {
-            dump_read = 1;
-        }
-    }
-#endif
-
-    /* Defensive checks */
-    if (!pdata)
-    {
-        unifi_error(card->ospriv, "Null pdata for unifi_bulk_rw() len: %d\n", len);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-    if ((len & 1) || (len > 0xffff))
-    {
-        unifi_error(card->ospriv, "Impossible CMD53 length requested: %d\n", len);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    while (1)
-    {
-        csrResult = csr_sdio_block_rw(card, card->function, handle,
-                                      (u8 *)pdata, (u16)len,
-                                      direction);
-        if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
-        {
-            return CSR_WIFI_HIP_RESULT_NO_DEVICE;
-        }
-#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
-        if (++fake_error > 100)
-        {
-            fake_error = 90;
-            unifi_warning(card->ospriv, "Faking a CMD53 error,\n");
-            if (csrResult == CSR_RESULT_SUCCESS)
-            {
-                csrResult = CSR_RESULT_FAILURE;
-            }
-        }
-#endif
-        if (csrResult == CSR_RESULT_SUCCESS)
-        {
-            if (dump_read)
-            {
-                dump(pdata, (u16)len);
-            }
-            break;
-        }
-
-        /*
-         * At this point the SDIO driver should have written the I/O Abort
-         * register to notify UniFi that the command has failed.
-         * UniFi-1 and UniFi-2 (not UF6xxx) use the same register to store the
-         * Deep Sleep State. This means we have to restore the Deep Sleep
-         * State (AWAKE in any case since we can not perform a CD53 in any other
-         * state) by rewriting the I/O Abort register to its previous value.
-         */
-        if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
-        {
-            (void)unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-        }
-
-        /* If csr_sdio_block_rw() failed in a non-retryable way, or retries exhausted
-         * then stop retrying
-         */
-        if (!retryable_sdio_error(csrResult))
-        {
-            unifi_error(card->ospriv, "Fatal error in a CMD53 transfer\n");
-            break;
-        }
-
-        /*
-         * These happen from time to time, try again
-         */
-        if (--retries == 0)
-        {
-            break;
-        }
-
-        unifi_trace(card->ospriv, UDBG4,
-                    "Error in a CMD53 transfer, retrying (h:%d,l:%u)...\n",
-                    (s16)handle & 0xff, len);
-
-        /* The transfer failed, rewind and try again */
-        r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 8,
-                                (u8)(handle & 0xff));
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            /*
-             * If we can't even do CMD52 (register read/write) then
-             * stop here.
-             */
-            unifi_error(card->ospriv, "Failed to write REWIND cmd\n");
-            return r;
-        }
-
-        /* Signal the UniFi to look for the rewind request. */
-        r = CardGenInt(card);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-
-        /* Wait for UniFi to acknowledge the rewind */
-        stat_retries = REWIND_RETRIES;
-        while (1)
-        {
-            r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 8, &stat);
-            if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-            {
-                return r;
-            }
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "Failed to read REWIND status\n");
-                return CSR_RESULT_FAILURE;
-            }
-
-            if (stat == 0)
-            {
-                break;
-            }
-            if (--stat_retries == 0)
-            {
-                unifi_error(card->ospriv, "Timeout waiting for REWIND ready\n");
-                return CSR_RESULT_FAILURE;
-            }
-
-            /* Poll for the ack a few times */
-            if (stat_retries < REWIND_RETRIES - REWIND_POLLING_RETRIES)
-            {
-                CsrThreadSleep(REWIND_DELAY);
-            }
-        }
-    }
-
-    /* The call to csr_sdio_block_rw() still failed after retrying */
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Block %s failed after %d retries\n",
-                    (direction == UNIFI_SDIO_READ)?"read" : "write",
-                    CMD53_RETRIES - retries);
-        /* Report any SDIO error as a general i/o error */
-        return CSR_RESULT_FAILURE;
-    }
-
-    /* Collect some stats */
-    if (direction == UNIFI_SDIO_READ)
-    {
-        card->sdio_bytes_read += len;
-    }
-    else
-    {
-        card->sdio_bytes_written += len;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_bulk_rw() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_bulk_rw_noretry
- *
- *      Transfer bulk data to or from the UniFi SDIO interface.
- *      This function is used to read or write signals and bulk data.
- *
- *  Arguments:
- *      card            Pointer to card structure.
- *      handle          Value to put in the Register Address field of
- *                      the CMD53 req.
- *      data            Pointer to data to write.
- *      direction       One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
- *
- *  Returns:
- *      0 on success, non-zero error code on error:
- *      CSR_WIFI_HIP_RESULT_NO_DEVICE  card was ejected
- *      CSR_RESULT_FAILURE     an SDIO error occurred
- *
- *  Notes:
- *      This function uses SDIO CMD53, which is the block transfer mode.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle, void *pdata,
-                                u32 len, s16 direction)
-{
-    CsrResult csrResult;
-
-    csrResult = csr_sdio_block_rw(card, card->function, handle,
-                                  (u8 *)pdata, (u16)len, direction);
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Block %s failed\n",
-                    (direction == UNIFI_SDIO_READ)?"read" : "write");
-        return csrResult;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_bulk_rw_noretry() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.c b/drivers/staging/csr/csr_wifi_hip_chiphelper.c
deleted file mode 100644 (file)
index 5cf5b8a..0000000
+++ /dev/null
@@ -1,793 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include "csr_macro.h"
-#include "csr_wifi_hip_chiphelper_private.h"
-
-#ifndef nelem
-#define nelem(a) (sizeof(a) / sizeof(a[0]))
-#endif
-
-#define counted(foo) { nelem(foo), foo }
-#define null_counted()  { 0, NULL }
-
-/* The init values are a set of register writes that we must
-   perform when we first connect to the chip to get it working.
-   They swicth on the correct clocks and possibly set the host
-   interface as a wkaeup source.  They should not be used if
-   proper HIP opperation is required, but are useful before we
-   do a code download. */
-static const struct chip_helper_init_values init_vals_v1[] = {
-    { 0xFDBB, 0xFFFF },
-    { 0xFDB6, 0x03FF },
-    { 0xFDB1, 0x01E3 },
-    { 0xFDB3, 0x0FFF },
-    { 0xFEE3, 0x08F0 },
-    { 0xFEE7, 0x3C3F },
-    { 0xFEE6, 0x0050 },
-    { 0xFDBA, 0x0000 }
-};
-
-static const struct chip_helper_init_values init_vals_v2[] = {
-    { 0xFDB6, 0x0FFF },
-    { 0xF023, 0x3F3F },
-    { 0xFDB1, 0x01E3 },
-    { 0xFDB3, 0x0FFF },
-    { 0xF003, 0x08F0 },
-    { 0xF007, 0x3C3F },
-    { 0xF006, 0x0050 }
-};
-
-
-static const struct chip_helper_init_values init_vals_v22_v23[] = {
-    { 0xF81C, 0x00FF },
-    /*{ 0x????, 0x???? }, */
-    { 0xF80C, 0x1FFF },
-    { 0xFA25, 0x001F },
-    { 0xF804, 0x00FF },
-    { 0xF802, 0x0FFF },
-    /*{ 0x????, 0x???? },
-      { 0x????, 0x???? },
-      { 0x????, 0x???? }*/
-};
-
-static const u16 reset_program_a_v1_or_v2[] = {
-    0x0000
-};
-static const u16 reset_program_b_v1_or_v2[] = {
-    0x0010, 0xFE00, 0xA021, 0xFF00, 0x8111, 0x0009, 0x0CA4, 0x0114,
-    0x0280, 0x04F8, 0xFE00, 0x6F25, 0x06E0, 0x0010, 0xFC00, 0x0121,
-    0xFC00, 0x0225, 0xFE00, 0x7125, 0xFE00, 0x6D11, 0x03F0, 0xFE00,
-    0x6E25, 0x0008, 0x00E0
-};
-
-static const struct chip_helper_reset_values reset_program_v1_or_v2[] =
-{
-    {
-        MAKE_GP(REGISTERS, 0x000C),
-        nelem(reset_program_a_v1_or_v2),
-        reset_program_a_v1_or_v2
-    },
-    {
-        MAKE_GP(MAC_PMEM, 0x000000),
-        nelem(reset_program_b_v1_or_v2),
-        reset_program_b_v1_or_v2
-    }
-};
-
-static const struct chip_map_address_t unifi_map_address_v1_v2[] =
-{
-    { 0xFE9F, 0xFE7B },     /* PM1_BANK_SELECT */
-    { 0xFE9E, 0xFE78 },     /* PM2_BANK_SELECT */
-    { 0xFE9D, 0xFE7E },     /* SHARED_DMEM_PAGE */
-    { 0xFE91, 0xFE90 },     /* PROC_SELECT */
-    { 0xFE8D, 0xFE8C },     /* STOP_STATUS */
-};
-
-static const struct chip_map_address_t unifi_map_address_v22_v23[] =
-{
-    { 0xF8F9, 0xF8AC },     /* GW1_CONFIG */
-    { 0xF8FA, 0xF8AD },     /* GW2_CONFIG */
-    { 0xF8FB, 0xF8AE },     /* GW3_CONFIG */
-    { 0xF830, 0xF81E },     /* PROC_SELECT */
-    { 0xF831, 0xF81F },     /* STOP_STATUS */
-    { 0xF8FC, 0xF8AF },     /* IO_LOG_ADDRESS */
-};
-
-static const struct chip_device_regs_t unifi_device_regs_null =
-{
-    0xFE81,                     /* GBL_CHIP_VERSION */
-    0x0000,                     /* GBL_MISC_ENABLES */
-    0x0000,                     /* DBG_EMU_CMD */
-    {
-        0x0000,                 /* HOST.DBG_PROC_SELECT */
-        0x0000,                 /* HOST.DBG_STOP_STATUS */
-        0x0000,                 /* HOST.WINDOW1_PAGE */
-        0x0000,                 /* HOST.WINDOW2_PAGE */
-        0x0000,                 /* HOST.WINDOW3_PAGE */
-        0x0000                  /* HOST.IO_LOG_ADDR */
-    },
-    {
-        0x0000,                 /* SPI.DBG_PROC_SELECT */
-        0x0000,                 /* SPI.DBG_STOP_STATUS */
-        0x0000,                 /* SPI.WINDOW1_PAGE */
-        0x0000,                 /* SPI.WINDOW2_PAGE */
-        0x0000,                 /* SPI.WINDOW3_PAGE */
-        0x0000                  /* SPI.IO_LOG_ADDR */
-    },
-    0x0000,                     /* DBG_RESET */
-    0x0000,                     /* > DBG_RESET_VALUE */
-    0x0000,                     /* DBG_RESET_WARN */
-    0x0000,                     /* DBG_RESET_WARN_VALUE */
-    0x0000,                     /* DBG_RESET_RESULT */
-    0xFFE9,                     /* XAP_PCH */
-    0xFFEA,                     /* XAP_PCL */
-    0x0000,                     /* PROC_PC_SNOOP */
-    0x0000,                     /* WATCHDOG_DISABLE */
-    0x0000,                     /* MAILBOX0 */
-    0x0000,                     /* MAILBOX1 */
-    0x0000,                     /* MAILBOX2 */
-    0x0000,                     /* MAILBOX3 */
-    0x0000,                     /* SDIO_HOST_INT */
-    0x0000,                     /* SHARED_IO_INTERRUPT */
-    0x0000,                     /* SDIO HIP HANDSHAKE */
-    0x0000                      /* COEX_STATUS */
-};
-
-/* UF105x */
-static const struct chip_device_regs_t unifi_device_regs_v1 =
-{
-    0xFE81,                     /* GBL_CHIP_VERSION */
-    0xFE87,                     /* GBL_MISC_ENABLES */
-    0xFE9C,                     /* DBG_EMU_CMD */
-    {
-        0xFE90,                 /* HOST.DBG_PROC_SELECT */
-        0xFE8C,                 /* HOST.DBG_STOP_STATUS */
-        0xFE7B,                 /* HOST.WINDOW1_PAGE */
-        0xFE78,                 /* HOST.WINDOW2_PAGE */
-        0xFE7E,                 /* HOST.WINDOW3_PAGE */
-        0x0000                  /* HOST.IO_LOG_ADDR */
-    },
-    {
-        0xFE91,                 /* SPI.DBG_PROC_SELECT */
-        0xFE8D,                 /* SPI.DBG_STOP_STATUS */
-        0xFE9F,                 /* SPI.WINDOW1_PAGE */
-        0xFE9E,                 /* SPI.WINDOW2_PAGE */
-        0xFE9D,                 /* SPI.WINDOW3_PAGE */
-        0x0000                  /* SPI.IO_LOG_ADDR */
-    },
-    0xFE92,                     /* DBG_RESET */
-    0x0001,                     /* > DBG_RESET_VALUE */
-    0xFDA0,                     /* DBG_RESET_WARN (HOST_SELECT) */
-    0x0000,                     /* DBG_RESET_WARN_VALUE */
-    0xFE92,                     /* DBG_RESET_RESULT */
-    0xFFE9,                     /* XAP_PCH */
-    0xFFEA,                     /* XAP_PCL */
-    0x0051,                     /* PROC_PC_SNOOP */
-    0xFE70,                     /* WATCHDOG_DISABLE */
-    0xFE6B,                     /* MAILBOX0 */
-    0xFE6A,                     /* MAILBOX1 */
-    0xFE69,                     /* MAILBOX2 */
-    0xFE68,                     /* MAILBOX3 */
-    0xFE67,                     /* SDIO_HOST_INT */
-    0xFE65,                     /* SHARED_IO_INTERRUPT */
-    0xFDE9,                     /* SDIO HIP HANDSHAKE */
-    0x0000                      /* COEX_STATUS */
-};
-
-/* UF2... */
-static const struct chip_device_regs_t unifi_device_regs_v2 =
-{
-    0xFE81,                     /* GBL_CHIP_VERSION */
-    0xFE87,                     /* GBL_MISC_ENABLES */
-    0xFE9C,                     /* DBG_EMU_CMD */
-    {
-        0xFE90,                 /* HOST.DBG_PROC_SELECT */
-        0xFE8C,                 /* HOST.DBG_STOP_STATUS */
-        0xFE7B,                 /* HOST.WINDOW1_PAGE */
-        0xFE78,                 /* HOST.WINDOW2_PAGE */
-        0xFE7E,                 /* HOST.WINDOW3_PAGE */
-        0x0000                  /* HOST.IO_LOG_ADDR */
-    },
-    {
-        0xFE91,                 /* SPI.DBG_PROC_SELECT */
-        0xFE8D,                 /* SPI.DBG_STOP_STATUS */
-        0xFE9F,                 /* SPI.WINDOW1_PAGE */
-        0xFE9E,                 /* SPI.WINDOW2_PAGE */
-        0xFE9D,                 /* SPI.WINDOW3_PAGE */
-        0x0000                  /* SPI.IO_LOG_ADDR */
-    },
-    0xFE92,                     /* DBG_RESET */
-    0x0000,                     /* > DBG_RESET_VALUE */
-    0xFDE9,                     /* DBG_RESET_WARN (TEST_FLASH_DATA - SHARED_MAILBOX2B) */
-    0xFFFF,                     /* DBG_RESET_WARN_VALUE */
-    0xFDE9,                     /* DBG_RESET_RESULT (TEST_FLASH_DATA) */
-    0xFFE9,                     /* XAP_PCH */
-    0xFFEA,                     /* XAP_PCL */
-    0x0051,                     /* PROC_PC_SNOOP */
-    0xFE70,                     /* WATCHDOG_DISABLE */
-    0xFE6B,                     /* MAILBOX0 */
-    0xFE6A,                     /* MAILBOX1 */
-    0xFE69,                     /* MAILBOX2 */
-    0xFE68,                     /* MAILBOX3 */
-    0xFE67,                     /* SDIO_HOST_INT */
-    0xFE65,                     /* SHARED_IO_INTERRUPT */
-    0xFE69,                     /* SDIO HIP HANDSHAKE */
-    0x0000                      /* COEX_STATUS */
-};
-
-/* UF60xx */
-static const struct chip_device_regs_t unifi_device_regs_v22_v23 =
-{
-    0xFE81,                     /* GBL_CHIP_VERSION */
-    0xF84F,                     /* GBL_MISC_ENABLES */
-    0xF81D,                     /* DBG_EMU_CMD */
-    {
-        0xF81E,                 /* HOST.DBG_PROC_SELECT */
-        0xF81F,                 /* HOST.DBG_STOP_STATUS */
-        0xF8AC,                 /* HOST.WINDOW1_PAGE */
-        0xF8AD,                 /* HOST.WINDOW2_PAGE */
-        0xF8AE,                 /* HOST.WINDOW3_PAGE */
-        0xF8AF                  /* HOST.IO_LOG_ADDR */
-    },
-    {
-        0xF830,                 /* SPI.DBG_PROC_SELECT */
-        0xF831,                 /* SPI.DBG_STOP_STATUS */
-        0xF8F9,                 /* SPI.WINDOW1_PAGE */
-        0xF8FA,                 /* SPI.WINDOW2_PAGE */
-        0xF8FB,                 /* SPI.WINDOW3_PAGE */
-        0xF8FC                  /* SPI.IO_LOG_ADDR */
-    },
-    0xF82F,                     /* DBG_RESET */
-    0x0001,                     /* > DBG_RESET_VALUE */
-    0x0000,                     /* DBG_RESET_WARN */
-    0x0000,                     /* DBG_RESET_WARN_VALUE */
-    0xF82F,                     /* DBG_RESET_RESULT */
-    0xFFE9,                     /* XAP_PCH */
-    0xFFEA,                     /* XAP_PCL */
-    0x001B,                     /* PROC_PC_SNOOP */
-    0x0055,                     /* WATCHDOG_DISABLE */
-    0xF84B,                     /* MAILBOX0 */
-    0xF84C,                     /* MAILBOX1 */
-    0xF84D,                     /* MAILBOX2 */
-    0xF84E,                     /* MAILBOX3 */
-    0xF92F,                     /* SDIO_HOST_INT */
-    0xF92B,                     /* SDIO_FROMHOST_SCRTACH0 / SHARED_IO_INTERRUPT */
-    0xF84D,                     /* SDIO HIP HANDSHAKE (MAILBOX2) */
-    0xF9FB                      /* COEX_STATUS */
-};
-
-/* Program memory window on UF105x. */
-static const struct window_shift_info_t prog_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
-{
-    { TRUE, 11, 0x0200 }, /* CODE RAM */
-    { TRUE, 11, 0x0000 }, /* FLASH */
-    { TRUE, 11, 0x0400 }, /* External SRAM */
-    { FALSE, 0, 0 },      /* ROM */
-    { FALSE, 0, 0 }       /* SHARED */
-};
-
-/* Shared memory window on UF105x. */
-static const struct window_shift_info_t shared_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
-{
-    { FALSE, 0, 0 },      /* CODE RAM */
-    { FALSE, 0, 0 },      /* FLASH */
-    { FALSE, 0, 0 },      /* External SRAM */
-    { FALSE, 0, 0 },      /* ROM */
-    { TRUE, 11, 0x0000 }  /* SHARED */
-};
-
-/* One of the Generic Windows on UF60xx and later. */
-static const struct window_shift_info_t generic_window_array_unifi_v22_v23[CHIP_HELPER_WT_COUNT] =
-{
-    { TRUE, 11, 0x3800 }, /* CODE RAM */
-    { FALSE, 0, 0 },      /* FLASH */
-    { FALSE, 0, 0 },      /* External SRAM */
-    { TRUE, 11, 0x2000 }, /* ROM */
-    { TRUE, 11, 0x0000 }  /* SHARED */
-};
-
-/* The three windows on UF105x. */
-static const struct window_info_t prog1_window_unifi_v1_v2  = { 0x0000, 0x2000, 0x0080, prog_window_array_unifi_v1_v2 };
-static const struct window_info_t prog2_window_unifi_v1_v2  = { 0x2000, 0x2000, 0x0000, prog_window_array_unifi_v1_v2 };
-static const struct window_info_t shared_window_unifi_v1_v2 = { 0x4000, 0x2000, 0x0000, shared_window_array_unifi_v1_v2 };
-
-/* The three windows on UF60xx and later. */
-static const struct window_info_t generic1_window_unifi_v22_v23 = { 0x0000, 0x2000, 0x0080, generic_window_array_unifi_v22_v23 };
-static const struct window_info_t generic2_window_unifi_v22_v23 = { 0x2000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
-static const struct window_info_t generic3_window_unifi_v22_v23 = { 0x4000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
-
-static const struct chip_device_desc_t chip_device_desc_null =
-{
-    { FALSE, 0x0000, 0x0000, 0x00 },
-    "",
-    "",
-    null_counted(),                         /* init */
-    null_counted(),                         /* reset_prog */
-    &unifi_device_regs_null,                /* regs */
-    {
-        FALSE,                              /* has_flash */
-        FALSE,                              /* has_ext_sram */
-        FALSE,                              /* has_rom */
-        FALSE,                              /* has_bt */
-        FALSE,                              /* has_wlan */
-    },
-    null_counted(),
-    /* prog_offset */
-    {
-        0x00000000,
-        0x00000000,
-        0x00000000,
-        0x00000000
-    },
-    /* data_offset */
-    {
-        0x0000                              /* ram */
-    },
-    /* windows */
-    {
-        NULL,
-        NULL,
-        NULL
-    }
-};
-
-static const struct chip_device_desc_t unifi_device_desc_v1 =
-{
-    { FALSE, 0xf0ff, 0x1001, 0x01 },        /* UF105x R01 */
-    "UF105x",
-    "UniFi-1",
-    counted(init_vals_v1),                  /* init */
-    counted(reset_program_v1_or_v2),        /* reset_prog */
-    &unifi_device_regs_v1,                  /* regs */
-    {
-        TRUE,                               /* has_flash    */
-        TRUE,                               /* has_ext_sram */
-        FALSE,                              /* has_rom      */
-        FALSE,                              /* has_bt       */
-        TRUE,                               /* has_wlan */
-    },
-    counted(unifi_map_address_v1_v2),       /* map */
-    /* prog_offset */
-    {
-        0x00100000,                         /* ram */
-        0x00000000,                         /* rom (invalid) */
-        0x00000000,                         /* flash */
-        0x00200000,                         /* ext_ram */
-    },
-    /* data_offset */
-    {
-        0x8000                              /* ram */
-    },
-    /* windows */
-    {
-        &prog1_window_unifi_v1_v2,
-        &prog2_window_unifi_v1_v2,
-        &shared_window_unifi_v1_v2
-    }
-};
-
-static const struct chip_device_desc_t unifi_device_desc_v2 =
-{
-    { FALSE, 0xf0ff, 0x2001, 0x02 },        /* UF2... R02 */
-    "UF2...",
-    "UniFi-2",
-    counted(init_vals_v2),                  /* init */
-    counted(reset_program_v1_or_v2),        /* reset_prog */
-    &unifi_device_regs_v2,                  /* regs */
-    {
-        TRUE,                               /* has_flash    */
-        TRUE,                               /* has_ext_sram */
-        FALSE,                              /* has_rom      */
-        FALSE,                              /* has_bt      */
-        TRUE,                               /* has_wlan */
-    },
-    counted(unifi_map_address_v1_v2),       /* map */
-    /* prog_offset */
-    {
-        0x00100000,                         /* ram */
-        0x00000000,                         /* rom (invalid) */
-        0x00000000,                         /* flash */
-        0x00200000,                         /* ext_ram */
-    },
-    /* data_offset */
-    {
-        0x8000                              /* ram */
-    },
-    /* windows */
-    {
-        &prog1_window_unifi_v1_v2,
-        &prog2_window_unifi_v1_v2,
-        &shared_window_unifi_v1_v2
-    }
-};
-
-static const struct chip_device_desc_t unifi_device_desc_v3 =
-{
-    { FALSE, 0xf0ff, 0x3001, 0x02 },        /* UF2... R03 */
-    "UF2...",
-    "UniFi-3",
-    counted(init_vals_v2),                  /* init */
-    counted(reset_program_v1_or_v2),        /* reset_prog */
-    &unifi_device_regs_v2,                  /* regs */
-    {
-        TRUE,                               /* has_flash    */
-        TRUE,                               /* has_ext_sram */
-        FALSE,                              /* has_rom      */
-        FALSE,                              /* has_bt      */
-        TRUE,                               /* has_wlan */
-    },
-    counted(unifi_map_address_v1_v2),       /* map */
-    /* prog_offset */
-    {
-        0x00100000,                         /* ram */
-        0x00000000,                         /* rom (invalid) */
-        0x00000000,                         /* flash */
-        0x00200000,                         /* ext_ram */
-    },
-    /* data_offset */
-    {
-        0x8000                              /* ram */
-    },
-    /* windows */
-    {
-        &prog1_window_unifi_v1_v2,
-        &prog2_window_unifi_v1_v2,
-        &shared_window_unifi_v1_v2
-    }
-};
-
-static const struct chip_device_desc_t unifi_device_desc_v22 =
-{
-    { FALSE, 0x00ff, 0x0022, 0x07 },        /* UF60xx */
-    "UF60xx",
-    "UniFi-4",
-    counted(init_vals_v22_v23),             /* init */
-    null_counted(),                         /* reset_prog */
-    &unifi_device_regs_v22_v23,             /* regs */
-    {
-        FALSE,                              /* has_flash    */
-        FALSE,                              /* has_ext_sram */
-        TRUE,                               /* has_rom      */
-        FALSE,                              /* has_bt       */
-        TRUE,                               /* has_wlan */
-    },
-    counted(unifi_map_address_v22_v23),     /* map */
-    /* prog_offset */
-    {
-        0x00C00000,                         /* ram */
-        0x00000000,                         /* rom */
-        0x00000000,                         /* flash (invalid) */
-        0x00000000,                         /* ext_ram (invalid) */
-    },
-    /* data_offset */
-    {
-        0x8000                              /* ram */
-    },
-    /* windows */
-    {
-        &generic1_window_unifi_v22_v23,
-        &generic2_window_unifi_v22_v23,
-        &generic3_window_unifi_v22_v23
-    }
-};
-
-static const struct chip_device_desc_t unifi_device_desc_v23 =
-{
-    { FALSE, 0x00ff, 0x0023, 0x08 },        /* UF.... */
-    "UF....",
-    "UF.... (5)",
-    counted(init_vals_v22_v23),             /* init */
-    null_counted(),                         /* reset_prog */
-    &unifi_device_regs_v22_v23,             /* regs */
-    {
-        FALSE,                              /* has_flash    */
-        FALSE,                              /* has_ext_sram */
-        TRUE,                               /* has_rom      */
-        TRUE,                               /* has_bt       */
-        TRUE,                               /* has_wlan */
-    },
-    counted(unifi_map_address_v22_v23),
-    /* prog_offset */
-    {
-        0x00C00000,                         /* ram */
-        0x00000000,                         /* rom */
-        0x00000000,                         /* flash (invalid) */
-        0x00000000,                         /* ext_sram (invalid) */
-    },
-    /* data_offset */
-    {
-        0x8000                              /* ram */
-    },
-    /* windows */
-    {
-        &generic1_window_unifi_v22_v23,
-        &generic2_window_unifi_v22_v23,
-        &generic3_window_unifi_v22_v23
-    }
-};
-
-static const struct chip_device_desc_t hyd_wlan_subsys_desc_v1 =
-{
-    { FALSE, 0x00ff, 0x0044, 0x00 },        /* UF.... */
-    "HYD...",
-    "HYD...    ",
-    counted(init_vals_v22_v23),             /* init */
-    null_counted(),                         /* reset_prog */
-    &unifi_device_regs_v22_v23,             /* regs */
-    {
-        FALSE,                              /* has_flash    */
-        FALSE,                              /* has_ext_sram */
-        TRUE,                               /* has_rom      */
-        FALSE,                              /* has_bt       */
-        TRUE,                               /* has_wlan */
-    },
-    counted(unifi_map_address_v22_v23),
-    /* prog_offset */
-    {
-        0x00C00000,                         /* ram */
-        0x00000000,                         /* rom */
-        0x00000000,                         /* flash (invalid) */
-        0x00000000,                         /* ext_sram (invalid) */
-    },
-    /* data_offset */
-    {
-        0x8000                              /* ram */
-    },
-    /* windows */
-    {
-        &generic1_window_unifi_v22_v23,
-        &generic2_window_unifi_v22_v23,
-        &generic3_window_unifi_v22_v23
-    }
-};
-
-
-/* This is the list of all chips that we know about.  I'm
-   assuming that the order here will be important - we
-   might have multiple entries witrh the same SDIO id for
-   instance.  The first one in this list will be the one
-   that is returned if a search is done on only that id.
-   The client will then have to call GetVersionXXX again
-   but with more detailed info.
-
-   I don't know if we need to signal this up to the client
-   in some way?
-
-   (We get the SDIO id before we know anything else about
-   the chip.  We might not be able to read any of the other
-   registers at first, but we still need to know about the
-   chip). */
-static const struct chip_device_desc_t *chip_ver_to_desc[] =
-{
-    &unifi_device_desc_v1,      /* UF105x R01 */
-    &unifi_device_desc_v2,      /* UF2... R02 */
-    &unifi_device_desc_v3,      /* UF2... R03 */
-    &unifi_device_desc_v22,     /* UF60xx */
-    &unifi_device_desc_v23,     /* UF.... */
-    &hyd_wlan_subsys_desc_v1
-};
-
-ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_ver)
-{
-    u32 i;
-
-    for (i = 0; i < nelem(chip_ver_to_desc); i++)
-    {
-        if (chip_ver_to_desc[i]->chip_version.sdio == sdio_ver)
-        {
-            return chip_ver_to_desc[i];
-        }
-    }
-
-    return &chip_device_desc_null;
-}
-
-
-ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81)
-{
-    u32 i;
-
-    if ((from_FF9A & 0xFF00) != 0)
-    {
-        for (i = 0; i < nelem(chip_ver_to_desc); i++)
-        {
-            if (chip_ver_to_desc[i]->chip_version.pre_bc7 &&
-                ((from_FF9A & chip_ver_to_desc[i]->chip_version.mask) ==
-                 chip_ver_to_desc[i]->chip_version.result))
-            {
-                return chip_ver_to_desc[i];
-            }
-        }
-    }
-    else
-    {
-        for (i = 0; i < nelem(chip_ver_to_desc); i++)
-        {
-            if (!chip_ver_to_desc[i]->chip_version.pre_bc7 &&
-                ((from_FE81 & chip_ver_to_desc[i]->chip_version.mask) ==
-                 chip_ver_to_desc[i]->chip_version.result))
-            {
-                return chip_ver_to_desc[i];
-            }
-        }
-    }
-
-    return &chip_device_desc_null;
-}
-
-
-ChipDescript* ChipHelper_GetVersionUniFi(u16 ver)
-{
-    return ChipHelper_GetVersionAny(0x0000, ver);
-}
-
-
-ChipDescript *ChipHelper_Null(void)
-{
-    return &chip_device_desc_null;
-}
-
-
-ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age bc_age, u16 version)
-{
-    if (bc_age == chip_helper_bluecore_pre_bc7)
-    {
-        return ChipHelper_GetVersionAny(version, 0x0000);
-    }
-    else
-    {
-        return ChipHelper_GetVersionAny(0x0000, version);
-    }
-}
-
-
-/* Expand the DEF0 functions into simple code to return the
-   correct thing.  The DEF1 functions expand to nothing in
-   this X macro expansion. */
-#define CHIP_HELPER_DEF0_C_DEF(ret_type, name, info)            \
-    ret_type ChipHelper_ ## name(ChipDescript * chip_help)           \
-    {                                                               \
-        return chip_help->info;                                     \
-    }
-#define CHIP_HELPER_DEF1_C_DEF(ret_type, name, type1, name1)
-
-CHIP_HELPER_LIST(C_DEF)
-
-/*
- * Map register addresses between HOST and SPI access.
- */
-u16 ChipHelper_MapAddress_SPI2HOST(ChipDescript *chip_help, u16 addr)
-{
-    u32 i;
-    for (i = 0; i < chip_help->map.len; i++)
-    {
-        if (chip_help->map.vals[i].spi == addr)
-        {
-            return chip_help->map.vals[i].host;
-        }
-    }
-    return addr;
-}
-
-
-u16 ChipHelper_MapAddress_HOST2SPI(ChipDescript *chip_help, u16 addr)
-{
-    u32 i;
-    for (i = 0; i < chip_help->map.len; i++)
-    {
-        if (chip_help->map.vals[i].host == addr)
-        {
-            return chip_help->map.vals[i].spi;
-        }
-    }
-    return addr;
-}
-
-
-/* The address returned by this function is the start of the
-   window in the address space, that is where we can start
-   accessing data from.  If a section of the window at the
-   start is unusable because something else is cluttering up
-   the address map then that is taken into account and this
-   function returns that address justt past that. */
-u16 ChipHelper_WINDOW_ADDRESS(ChipDescript                 *chip_help,
-                                    enum chip_helper_window_index window)
-{
-    if (window < CHIP_HELPER_WINDOW_COUNT &&
-        chip_help->windows[window] != NULL)
-    {
-        return chip_help->windows[window]->address + chip_help->windows[window]->blocked;
-    }
-    return 0;
-}
-
-
-/* This returns the size of the window minus any blocked section */
-u16 ChipHelper_WINDOW_SIZE(ChipDescript                 *chip_help,
-                                 enum chip_helper_window_index window)
-{
-    if (window < CHIP_HELPER_WINDOW_COUNT &&
-        chip_help->windows[window] != NULL)
-    {
-        return chip_help->windows[window]->size - chip_help->windows[window]->blocked;
-    }
-    return 0;
-}
-
-
-/* Get the register writes we should do to make sure that
-   the chip is running with most clocks on. */
-u32 ChipHelper_ClockStartupSequence(ChipDescript                          *chip_help,
-                                          const struct chip_helper_init_values **val)
-{
-    *val = chip_help->init.vals;
-    return chip_help->init.len;
-}
-
-
-/* Get the set of values tat we should write to the chip to perform a reset. */
-u32 ChipHelper_HostResetSequence(ChipDescript                           *chip_help,
-                                       const struct chip_helper_reset_values **val)
-{
-    *val = chip_help->reset_prog.vals;
-    return chip_help->reset_prog.len;
-}
-
-
-/* Decode a windowed access to the chip. */
-s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
-                                 enum chip_helper_window_index window,
-                                 enum chip_helper_window_type type,
-                                 u32 offset,
-                                 u16 *page, u16 *addr, u32 *len)
-{
-    const struct window_info_t *win;
-    const struct window_shift_info_t *mode;
-    u16 of, pg;
-
-    if (window >= CHIP_HELPER_WINDOW_COUNT)
-    {
-        return FALSE;
-    }
-    if ((win = chip_help->windows[window]) == NULL)
-    {
-        return FALSE;
-    }
-    if (type >= CHIP_HELPER_WT_COUNT)
-    {
-        return FALSE;
-    }
-    if ((mode = &win->mode[type]) == NULL)
-    {
-        return FALSE;
-    }
-    if (!mode->allowed)
-    {
-        return FALSE;
-    }
-
-    pg = (u16)(offset >> mode->page_shift) + mode->page_offset;
-    of = (u16)(offset & ((1 << mode->page_shift) - 1));
-    /* If 'blocked' is zero this does nothing, else decrease
-       the page register and increase the offset until we aren't
-       in the blocked region of the window. */
-    while (of < win->blocked)
-    {
-        of += 1 << mode->page_shift;
-        pg--;
-    }
-    *page = pg;
-    *addr = win->address + of;
-    *len = win->size - of;
-    return TRUE;
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.h b/drivers/staging/csr/csr_wifi_hip_chiphelper.h
deleted file mode 100644 (file)
index 09b3aef..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_HIP_CHIPHELPER_H__
-#define CSR_WIFI_HIP_CHIPHELPER_H__
-
-
-#include <linux/types.h>
-
-/* The age of the BlueCore chip.  This is probably not useful, if
-   you know the age then you can probably work out the version directly. */
-enum chip_helper_bluecore_age
-{
-    chip_helper_bluecore_pre_bc7,
-    chip_helper_bluecore_bc7_or_later
-};
-
-/* We support up to three windowed regions at the moment.
-   Don't reorder these - they're used to index into an array. */
-enum chip_helper_window_index
-{
-    CHIP_HELPER_WINDOW_1        = 0,
-    CHIP_HELPER_WINDOW_2        = 1,
-    CHIP_HELPER_WINDOW_3        = 2,
-    CHIP_HELPER_WINDOW_COUNT    = 3
-};
-
-/* These are the things that we can access through a window.
-   Don't reorder these - they're used to index into an array. */
-enum chip_helper_window_type
-{
-    CHIP_HELPER_WT_CODE_RAM = 0,
-    CHIP_HELPER_WT_FLASH    = 1,
-    CHIP_HELPER_WT_EXT_SRAM = 2,
-    CHIP_HELPER_WT_ROM      = 3,
-    CHIP_HELPER_WT_SHARED   = 4,
-    CHIP_HELPER_WT_COUNT    = 5
-};
-
-/* Commands to stop and start the XAP */
-enum chip_helper_dbg_emu_cmd_enum
-{
-    CHIP_HELPER_DBG_EMU_CMD_XAP_STEP_MASK   = 0x0001,
-    CHIP_HELPER_DBG_EMU_CMD_XAP_RUN_B_MASK  = 0x0002,
-    CHIP_HELPER_DBG_EMU_CMD_XAP_BRK_MASK    = 0x0004,
-    CHIP_HELPER_DBG_EMU_CMD_XAP_WAKEUP_MASK = 0x0008
-};
-
-/* Bitmasks for Stop and sleep status: DBG_SPI_STOP_STATUS & DBG_HOST_STOP_STATUS */
-enum chip_helper_dbg_stop_status_enum
-{
-    CHIP_HELPER_DBG_STOP_STATUS_NONE_MASK               = 0x0000,
-    CHIP_HELPER_DBG_STOP_STATUS_P0_MASK                 = 0x0001,
-    CHIP_HELPER_DBG_STOP_STATUS_P1_MASK                 = 0x0002,
-    CHIP_HELPER_DBG_STOP_STATUS_P2_MASK                 = 0x0004,
-    CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P0_MASK    = 0x0008,
-    CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P1_MASK    = 0x0010,
-    CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P2_MASK    = 0x0020,
-    /* Legacy names/alias */
-    CHIP_HELPER_DBG_STOP_STATUS_MAC_MASK                = 0x0001,
-    CHIP_HELPER_DBG_STOP_STATUS_PHY_MASK                = 0x0002,
-    CHIP_HELPER_DBG_STOP_STATUS_BT_MASK                 = 0x0004,
-    CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_MAC_MASK   = 0x0008,
-    CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_PHY_MASK   = 0x0010,
-    CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_BT_MASK    = 0x0020
-};
-
-/* Codes to disable the watchdog */
-enum chip_helper_watchdog_disable_enum
-{
-    CHIP_HELPER_WATCHDOG_DISABLE_CODE1 = 0x6734,
-    CHIP_HELPER_WATCHDOG_DISABLE_CODE2 = 0xD6BF,
-    CHIP_HELPER_WATCHDOG_DISABLE_CODE3 = 0xC31E
-};
-
-/* Other bits have changed between versions */
-enum chip_helper_gbl_misc_enum
-{
-    CHIP_HELPER_GBL_MISC_SPI_STOP_OUT_EN_MASK  = 0x0001,
-    CHIP_HELPER_GBL_MISC_MMU_INIT_DONE_MASK    = 0x0004
-};
-
-/* Coex status register, contains interrupt status and reset pullup status.
- * CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK can be used to check
- * for WAPI on R03 chips and later. */
-enum chip_helper_coex_status_mask_enum
-{
-    CHIP_HELPER_COEX_STATUS_RST_PULLS_LSB_MASK   = 0x0001,
-    CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK   = 0x0008,
-    CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_LSB_MASK = 0x0010,
-    CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_MSB_MASK = 0x0080,
-    CHIP_HELPER_COEX_STATUS_INT_UART_MASK        = 0x0100,
-    CHIP_HELPER_COEX_STATUS_INT_BT_LEG_MASK      = 0x0200
-};
-
-/* How to select the different CPUs */
-enum chip_helper_dbg_proc_sel_enum
-{
-    CHIP_HELPER_DBG_PROC_SEL_MAC  = 0,
-    CHIP_HELPER_DBG_PROC_SEL_PHY  = 1,
-    CHIP_HELPER_DBG_PROC_SEL_BT   = 2,
-    CHIP_HELPER_DBG_PROC_SEL_NONE = 2,
-    CHIP_HELPER_DBG_PROC_SEL_BOTH = 3
-};
-
-/* These are the only registers that we have to know the
-   address of before we know the chip version. */
-enum chip_helper_fixed_registers
-{
-    /* This is the address of GBL_CHIP_VERISON on BC7,
-       UF105x, UF60xx and
-       anything later than that. */
-    CHIP_HELPER_UNIFI_GBL_CHIP_VERSION  = 0xFE81,
-
-    CHIP_HELPER_OLD_BLUECORE_GBL_CHIP_VERSION = 0xFF9A
-
-                                                /* This isn't used at the moment (but might be needed
-                                                to distinguish the BlueCore sub version?) */
-                                                /* CHIP_HELPER_OLD_BLUECORE_ANA_VERSION_ID = 0xFF7D */
-};
-
-/* Address-value pairs for defining initialisation values */
-struct chip_helper_init_values
-{
-    u16 addr;
-    u16 value;
-};
-
-/* A block of data that should be written to the device */
-struct chip_helper_reset_values
-{
-    u32        gp_address;
-    u32        len;
-    const u16 *data;
-};
-
-/*
- * This is the C API.
- */
-
-/* opaque type */
-typedef const struct chip_device_desc_t ChipDescript;
-
-/* Return a NULL descriptor */
-ChipDescript* ChipHelper_Null(void);
-
-/* This should get the correct version for any CSR chip.
-   The two parameters are what is read from addresses
-   0xFF9A and 0xFE81 (OLD_BLUECORE_GBL_CHIP_VERSION and
-   UNIFI_GBL_CHIP_VERSION).  These should give a unique identity
-   for most (all?) chips.
-
-   FF9A is the old GBL_CHIP_VERSION register.  If the high
-   eight bits are zero then the chip is a new (BC7 +) one
-   and FE81 is the _new_ GBL_CHIP_VERSION register. */
-ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81);
-
-/* The chip is a UniFi, but we don't know which type
-   The parameter is the value of UNIFI_GBL_CHIP_VERSION (0xFE81) */
-ChipDescript* ChipHelper_GetVersionUniFi(u16 version);
-
-/* This gets the version from the SDIO device id.  This only
-   gives quite a coarse grained version, so we should update once
-   we hav access to the function N registers. */
-ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_version);
-
-/* The chip is some sort of BlueCore.  If "age" is "pre_bc7" then
-   "version" is what was read from FF9A.  If "age" is bc7_or_later
-   then "version" is read from FE81.  If we don't know if we're pre
-   or post BC7 then we should use "GetVersionAny". */
-ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age age,
-                                            u16                     version);
-
-/* The main functions of this class are built with an X macro.  This
-   means we can generate the C and C++ versions from the same source
-   without the two diverging.
-
-   The DEF0 functions are simple and take no parameters.  The first
-   parameter to the macro is the return type.  The second parameter
-   is the function name and the third parameter is where to get the
-   info from (this is hidden from the user).
-
-   The DEF1 functions take one parameter. This time the third macro
-   parameter is the type of this parameter, and the fourth macro
-   parameter is the name of the parameter. The bodies of these
-   functions are hand written. */
-#define CHIP_HELPER_LIST(m)                                             \
-    CHIP_HELPER_DEF0(m, (const char *, FriendlyName, friendly_name))     \
-    CHIP_HELPER_DEF0(m, (const char *, MarketingName, marketing_name))  \
-    CHIP_HELPER_DEF0(m, (u16, DBG_EMU_CMD, regs->dbg_emu_cmd))       \
-    CHIP_HELPER_DEF0(m, (u16, DBG_HOST_PROC_SELECT, regs->host.dbg_proc_select)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_HOST_STOP_STATUS, regs->host.dbg_stop_status)) \
-    CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW1_PAGE, regs->host.window1_page)) \
-    CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW2_PAGE, regs->host.window2_page)) \
-    CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW3_PAGE, regs->host.window3_page)) \
-    CHIP_HELPER_DEF0(m, (u16, HOST_IO_LOG_ADDR, regs->host.io_log_addr)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_SPI_PROC_SELECT, regs->spi.dbg_proc_select)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_SPI_STOP_STATUS, regs->spi.dbg_stop_status)) \
-    CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW1_PAGE, regs->spi.window1_page)) \
-    CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW2_PAGE, regs->spi.window2_page)) \
-    CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW3_PAGE, regs->spi.window3_page)) \
-    CHIP_HELPER_DEF0(m, (u16, SPI_IO_LOG_ADDR, regs->spi.io_log_addr)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_RESET, regs->dbg_reset))           \
-    CHIP_HELPER_DEF0(m, (u16, DBG_RESET_VALUE, regs->dbg_reset_value)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN, regs->dbg_reset_warn)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN_VALUE, regs->dbg_reset_warn_value)) \
-    CHIP_HELPER_DEF0(m, (u16, DBG_RESET_RESULT, regs->dbg_reset_result)) \
-    CHIP_HELPER_DEF0(m, (u16, WATCHDOG_DISABLE, regs->watchdog_disable)) \
-    CHIP_HELPER_DEF0(m, (u16, PROC_PC_SNOOP, regs->proc_pc_snoop))   \
-    CHIP_HELPER_DEF0(m, (u16, GBL_CHIP_VERSION, regs->gbl_chip_version)) \
-    CHIP_HELPER_DEF0(m, (u16, GBL_MISC_ENABLES, regs->gbl_misc_enables)) \
-    CHIP_HELPER_DEF0(m, (u16, XAP_PCH, regs->xap_pch))               \
-    CHIP_HELPER_DEF0(m, (u16, XAP_PCL, regs->xap_pcl))               \
-    CHIP_HELPER_DEF0(m, (u16, MAILBOX0, regs->mailbox0))             \
-    CHIP_HELPER_DEF0(m, (u16, MAILBOX1, regs->mailbox1))             \
-    CHIP_HELPER_DEF0(m, (u16, MAILBOX2, regs->mailbox2))             \
-    CHIP_HELPER_DEF0(m, (u16, MAILBOX3, regs->mailbox3))             \
-    CHIP_HELPER_DEF0(m, (u16, SDIO_HIP_HANDSHAKE, regs->sdio_hip_handshake))   \
-    CHIP_HELPER_DEF0(m, (u16, SDIO_HOST_INT, regs->sdio_host_int))   \
-    CHIP_HELPER_DEF0(m, (u16, COEX_STATUS, regs->coex_status))       \
-    CHIP_HELPER_DEF0(m, (u16, SHARED_IO_INTERRUPT, regs->shared_io_interrupt)) \
-    CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_RAM_OFFSET, prog_offset.ram)) \
-    CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_ROM_OFFSET, prog_offset.rom)) \
-    CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_FLASH_OFFSET, prog_offset.flash)) \
-    CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_EXT_SRAM_OFFSET, prog_offset.ext_sram)) \
-    CHIP_HELPER_DEF0(m, (u16, DATA_MEMORY_RAM_OFFSET, data_offset.ram)) \
-    CHIP_HELPER_DEF0(m, (s32, HasFlash, bools.has_flash))              \
-    CHIP_HELPER_DEF0(m, (s32, HasExtSram, bools.has_ext_sram))         \
-    CHIP_HELPER_DEF0(m, (s32, HasRom, bools.has_rom))                  \
-    CHIP_HELPER_DEF0(m, (s32, HasBt, bools.has_bt))                    \
-    CHIP_HELPER_DEF0(m, (s32, HasWLan, bools.has_wlan))                \
-    CHIP_HELPER_DEF1(m, (u16, WINDOW_ADDRESS, enum chip_helper_window_index, window)) \
-    CHIP_HELPER_DEF1(m, (u16, WINDOW_SIZE, enum chip_helper_window_index, window)) \
-    CHIP_HELPER_DEF1(m, (u16, MapAddress_SPI2HOST, u16, addr))          \
-    CHIP_HELPER_DEF1(m, (u16, MapAddress_HOST2SPI, u16, addr))          \
-    CHIP_HELPER_DEF1(m, (u32, ClockStartupSequence, const struct chip_helper_init_values **, val)) \
-    CHIP_HELPER_DEF1(m, (u32, HostResetSequence, const struct chip_helper_reset_values **, val))
-
-/* Some magic to help the expansion */
-#define CHIP_HELPER_DEF0(a, b) \
-    CHIP_HELPER_DEF0_ ## a b
-#define CHIP_HELPER_DEF1(a, b) \
-    CHIP_HELPER_DEF1_ ## a b
-
-/* Macros so that when we expand the list we get "C" function prototypes. */
-#define CHIP_HELPER_DEF0_C_DEC(ret_type, name, info)    \
-    ret_type ChipHelper_ ## name(ChipDescript * chip_help);
-#define CHIP_HELPER_DEF1_C_DEC(ret_type, name, type1, name1)   \
-    ret_type ChipHelper_ ## name(ChipDescript * chip_help, type1 name1);
-
-CHIP_HELPER_LIST(C_DEC)
-
-/* FriendlyName
-   MarketingName
-
-   These two functions return human readable strings that describe
-   the chip.  FriendlyName returns something that a software engineer
-   at CSR might understand.  MarketingName returns something more like
-   an external name for a CSR chip.
-*/
-/* DBG_EMU_CMD
-   WATCHDOG_DISABLE
-   PROC_PC_SNOOP
-   GBL_CHIP_VERSION
-   XAP_PCH
-   XAP_PCL
-
-   These registers are used to control the XAPs.
-*/
-/* DBG_HOST_PROC_SELECT  DBG_HOST_STOP_STATUS
-   HOST_WINDOW1_PAGE HOST_WINDOW2_PAGE HOST_WINDOW3_PAGE
-   HOST_IO_LOG_ADDR
-   DBG_SPI_PROC_SELECT  DBG_SPI_STOP_STATUS
-   SPI_WINDOW1_PAGE SPI_WINDOW2_PAGE SPI_WINDOW3_PAGE
-   SPI_IO_LOG_ADDR
-
-   These register are used to control the XAPs and the memory
-   windows, normally while debugging the code on chip.  There
-   are two versons of these registers, one for access via SPI
-   and another for access via the host interface.
-*/
-/*  DBG_RESET
-    DBG_RESET_VALUE
-    DBG_RESET_WARN
-    DBG_RESET_WARN_VALUE
-    DBG_RESET_RESULT
-
-    These registers are used to reset the XAP.  This can be
-    quite complex for some chips.  If DBG_RESET_WARN is non
-    zero the DBG_RESET_WARN_VALUE should be written to address
-    DBG_RESET_WARN before the reset is perfeormed.  DBG_RESET_VALUE
-    should then be written to DBG_RESET to make the reset happen.
-    The DBG_RESET_RESULT register should contain 0 if the reset
-    was successful.
-*/
-/*  GBL_MISC_ENABLES
-
-    This register controls some special chip features.  It
-    should be used with care is it changes quite a lot between
-    chip versions.
-*/
-/*  MAILBOX0
-    MAILBOX1
-    MAILBOX2
-    MAILBOX3
-
-    The mailbox registers are for communication between the host
-    and the firmware.  There use is described in part by the host
-    interface protcol specifcation.
-*/
-/*  SDIO_HIP_HANDSHAKE
-
-    This is one of the more important SDIO HIP registers.  On some
-    chips it has the same value as one of the mailbox registers
-    and on other chips it is different.
-*/
-/*  SDIO_HOST_INT
-    SHARED_IO_INTERRUPT
-
-    These registers are used by some versions of the host interface
-    protocol specification.  Their names should probably be changed
-    to hide the registers and to expose the functions more.
-*/
-/*  COEX_STATUS
-
-    Coex status register, contains interrupt status and reset
-    pullup status.  The latter is used to detect WAPI.
-*/
-/*  PROGRAM_MEMORY_RAM_OFFSET
-    PROGRAM_MEMORY_ROM_OFFSET
-    PROGRAM_MEMORY_FLASH_OFFSET
-    PROGRAM_MEMORY_EXT_SRAM_OFFSET
-    DATA_MEMORY_RAM_OFFSET
-
-    These are constants that describe the offset of the different
-    memory types in the two different address spaces.
-*/
-/*  HasFlash HasExtSram HasRom
-    HasBt HasWLan
-
-    These are a set of bools describing the chip.
-*/
-/*  WINDOW_ADDRESS WINDOW_SIZE
-
-    These two functions return the size and address of the windows.
-    The address is the address of the lowest value in the address
-    map that is part of the window and the size is the number of
-    visible words.
-
-    Some of the windows have their lowest portion covered by
-    registers.  For these windows address is the first address
-    after the registers and size is the siave excluding the part
-    covered by registers.
-*/
-/*  MapAddress_SPI2HOST
-    MapAddress_HOST2SPI
-
-    The debugging interface is duplicated on UniFi and later chips
-    so that there are two versions - one over the SPI interaface and
-    the other over the SDIO interface.  These functions map the
-    registers between these two interfaces.
-*/
-/*  ClockStartupSequence
-
-    This function returns the list of register value pairs that
-    should be forced into UniFi to enable SPI communication.  This
-    set of registers is not needed if the firmware is running, but
-    will be needed if the device is being booted from cold.  These
-    register writes enable the clocks and setup the PLL to a basic
-    working state.  SPI access might be unreliable until these writes
-    have occurred (And they may take mulitple goes).
-*/
-/*  HostResetSequence
-
-    This returns a number of chunks of data and generic pointers.
-    All of the XAPs should be stopped.  The data should be written
-    to the generic pointers.  The instruction pointer for the MAC
-    should then be set to the start of program memory and then the
-    MAC should be "go"d.  This will reset the chip in a reliable
-    and orderly manner without resetting the SDIO interface.  It
-    is therefore not needed if the chip is being accessed by the
-    SPI interface (the DBG_RESET_ mechanism can be used instead).
-*/
-
-/* The Decode Window function is more complex.  For the window
-   'window' it tries to return the address and page register
-   value needed to see offset 'offset' of memory type 'type'.
-
-   It return 1 on success and 0 on failure.  'page' is what
-   should be written to the page register.  'addr' is the
-   address in the XAPs 16 address map to read from.  'len'
-   is the length that we can read without having to change
-   the page registers. */
-s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
-                                 enum chip_helper_window_index window,
-                                 enum chip_helper_window_type type,
-                                 u32 offset,
-                                 u16 *page, u16 *addr, u32 *len);
-
-#endif
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h b/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h
deleted file mode 100644 (file)
index e5e5799..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
-#define CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
-
-
-#include "csr_wifi_hip_chiphelper.h"
-
-/* This GP stuff should be somewhere else? */
-
-/* Memory spaces encoded in top byte of Generic Pointer type */
-#define UNIFI_SH_DMEM   0x01    /* Shared Data Memory */
-#define UNIFI_EXT_FLASH 0x02    /* External FLASH */
-#define UNIFI_EXT_SRAM  0x03    /* External SRAM */
-#define UNIFI_REGISTERS 0x04    /* Registers */
-#define UNIFI_PHY_DMEM  0x10    /* PHY Data Memory */
-#define UNIFI_PHY_PMEM  0x11    /* PHY Program Memory */
-#define UNIFI_PHY_ROM   0x12    /* PHY ROM */
-#define UNIFI_MAC_DMEM  0x20    /* MAC Data Memory */
-#define UNIFI_MAC_PMEM  0x21    /* MAC Program Memory */
-#define UNIFI_MAC_ROM   0x22    /* MAC ROM */
-#define UNIFI_BT_DMEM   0x30    /* BT Data Memory */
-#define UNIFI_BT_PMEM   0x31    /* BT Program Memory */
-#define UNIFI_BT_ROM    0x32    /* BT ROM */
-
-#define MAKE_GP(R, O)  (((UNIFI_ ## R) << 24) | (O))
-#define GP_OFFSET(GP)  ((GP) & 0xFFFFFF)
-#define GP_SPACE(GP)   (((GP) >> 24) & 0xFF)
-
-
-/* Address value pairs */
-struct val_array_t
-{
-    u32                             len;
-    const struct chip_helper_init_values *vals;
-};
-
-/* Just a (counted) u16 array */
-struct data_array_t
-{
-    u32        len;
-    const u16 *vals;
-};
-
-struct reset_prog_t
-{
-    u32                              len;
-    const struct chip_helper_reset_values *vals;
-};
-
-/* The addresses of registers that are equivalent but on
-   different host transports. */
-struct chip_map_address_t
-{
-    u16 spi, host;
-};
-
-struct map_array_t
-{
-    u32                        len;
-    const struct chip_map_address_t *vals;
-};
-
-struct chip_device_regs_per_transport_t
-{
-    u16 dbg_proc_select;
-    u16 dbg_stop_status;
-    u16 window1_page;    /* PROG_PMEM1 or GW1 */
-    u16 window2_page;    /* PROG_PMEM2 or GW2 */
-    u16 window3_page;    /* SHARED or GW3 */
-    u16 io_log_addr;
-};
-
-struct chip_device_regs_t
-{
-    u16                               gbl_chip_version;
-    u16                               gbl_misc_enables;
-    u16                               dbg_emu_cmd;
-    struct chip_device_regs_per_transport_t host;
-    struct chip_device_regs_per_transport_t spi;
-    u16                               dbg_reset;
-    u16                               dbg_reset_value;
-    u16                               dbg_reset_warn;
-    u16                               dbg_reset_warn_value;
-    u16                               dbg_reset_result;
-    u16                               xap_pch;
-    u16                               xap_pcl;
-    u16                               proc_pc_snoop;
-    u16                               watchdog_disable;
-    u16                               mailbox0;
-    u16                               mailbox1;
-    u16                               mailbox2;
-    u16                               mailbox3;
-    u16                               sdio_host_int;
-    u16                               shared_io_interrupt;
-    u16                               sdio_hip_handshake;
-    u16                               coex_status; /* Allows WAPI detection */
-};
-
-/* If allowed is false then this window does not provide this
-   type of access.
-   This describes how addresses should be shifted to make the
-   "page" address.  The address is shifted left by 'page_shift'
-   and then has 'page_offset' added.  This value should then be
-   written to the page register. */
-struct window_shift_info_t
-{
-    s32  allowed;
-    u32 page_shift;
-    u16 page_offset;
-};
-
-/* Each window has an address and size.  These are obvious.  It then
-   has a description for each type of memory that might be accessed
-   through it.  There might also be a start to the offset of the window.
-   This means that that number of addresses at the start of the window
-   are unusable. */
-struct window_info_t
-{
-    u16                         address;
-    u16                         size;
-    u16                         blocked;
-    const struct window_shift_info_t *mode;
-};
-
-/* If GBL_CHIP_VERSION and'ed with 'mask' and is equal to 'result'
-   then this is the correct set of info.  If pre_bc7 is true then the
-   address of GBL_CHIP_VERSION is FF9A, else its FE81. */
-struct chip_version_t
-{
-    s32  pre_bc7;
-    u16 mask;
-    u16 result;
-    u8  sdio;
-};
-
-struct chip_device_desc_t
-{
-    struct chip_version_t chip_version;
-
-    /* This is a text string that a human might find useful (BC02, UF105x) */
-    const char *friendly_name;
-    /* This is what we show to customers */
-    const char *marketing_name;
-
-    /* Initialisation values to write following a reset */
-    struct val_array_t init;
-
-    /* Binary sequence for hard reset */
-    struct reset_prog_t reset_prog;
-
-    /* The register map */
-    const struct chip_device_regs_t *regs;
-
-    /* Some misc. info on the chip */
-    struct
-    {
-        u32 has_flash     : 1;
-        u32 has_ext_sram  : 1;
-        u32 has_rom       : 1;
-        u32 has_bt        : 1;
-        u32 has_wlan      : 1;
-    } bools;
-
-    /* This table is used to remap register addresses depending on what
-       host interface is used.  On the BC7 and later chips there are
-       multiple sets of memory window registers, on for each host
-       interafce (SDIO / SPI).  The correct one is needed. */
-    struct map_array_t map;
-
-    /* The offsets into the program address space of the different types of memory.
-       The RAM offset is probably the most useful. */
-    struct
-    {
-        u32 ram;
-        u32 rom;
-        u32 flash;
-        u32 ext_sram;
-    } prog_offset;
-
-    /* The offsets into the data address space of interesting things. */
-    struct
-    {
-        u16 ram;
-        /* maybe add shared / page tables? */
-    } data_offset;
-
-    /* Information on the different windows */
-    const struct window_info_t *windows[CHIP_HELPER_WINDOW_COUNT];
-};
-
-#endif /* CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_conversions.h b/drivers/staging/csr/csr_wifi_hip_conversions.h
deleted file mode 100644 (file)
index bf7a52e..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *
- * FILE: csr_wifi_hip_conversions.h
- *
- * PURPOSE:
- *      This header file provides the macros for converting to and from
- *      wire format.
- *      These macros *MUST* work for little-endian AND big-endian hosts.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __CSR_WIFI_HIP_CONVERSIONS_H__
-#define __CSR_WIFI_HIP_CONVERSIONS_H__
-
-#define SIZEOF_UINT16           2
-#define SIZEOF_UINT32           4
-#define SIZEOF_UINT64           8
-
-#define SIZEOF_SIGNAL_HEADER    6
-#define SIZEOF_DATAREF          4
-
-
-/*
- * Macro to retrieve the signal ID from a wire-format signal.
- */
-#define GET_SIGNAL_ID(_buf)     CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf))
-
-/*
- * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format)
- * HIP signal.
- */
-#define GET_PACKED_DATAREF_SLOT(_buf, _ref)                             \
-    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
-
-#define GET_PACKED_DATAREF_LEN(_buf, _ref)                              \
-    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
-
-#define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot)                      \
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
-
-#define SET_PACKED_DATAREF_LEN(_buf, _ref, _len)                        \
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
-
-#define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf)              \
-    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
-
-#define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf)                     \
-    CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4))
-
-#define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf)                     \
-    CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
-
-#define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf)                     \
-    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2))
-
-
-s32 get_packed_struct_size(const u8 *buf);
-CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig);
-CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len);
-
-#endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_hip_download.c b/drivers/staging/csr/csr_wifi_hip_download.c
deleted file mode 100644 (file)
index 2f44a38..0000000
+++ /dev/null
@@ -1,819 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- * FILE: csr_wifi_hip_download.c
- *
- * PURPOSE:
- *      Routines for downloading firmware to UniFi.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/slab.h>
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_unifiversion.h"
-#include "csr_wifi_hip_card.h"
-#include "csr_wifi_hip_xbv.h"
-
-#undef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
-
-static CsrResult do_patch_download(card_t *card, void *dlpriv,
-                                   xbv1_t *pfwinfo, u32 boot_ctrl_addr);
-
-static CsrResult do_patch_convert_download(card_t *card,
-                                           void *dlpriv, xbv1_t *pfwinfo);
-
-/*
- * ---------------------------------------------------------------------------
- *  _find_in_slut
- *
- *      Find the offset of the appropriate object in the SLUT of a card
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      psym            Pointer to symbol object.
- *                         id set up by caller
- *                         obj will be set up by this function
- *      pslut           Pointer to SLUT address, if 0xffffffff then it must be
- *                         read from the chip.
- *  Returns:
- *      CSR_RESULT_SUCCESS on success
- *      Non-zero on error,
- *      CSR_WIFI_HIP_RESULT_NOT_FOUND if not found
- * ---------------------------------------------------------------------------
- */
-static CsrResult _find_in_slut(card_t *card, symbol_t *psym, u32 *pslut)
-{
-    u32 slut_address;
-    u16 finger_print;
-    CsrResult r;
-    CsrResult csrResult;
-
-    /* Get SLUT address */
-    if (*pslut == 0xffffffff)
-    {
-        r = card_wait_for_firmware_to_start(card, &slut_address);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Firmware hasn't started\n");
-            return r;
-        }
-        *pslut = slut_address;
-
-        /*
-         * Firmware has started so set the SDIO bus clock to the initial speed,
-         * faster than UNIFI_SDIO_CLOCK_SAFE_HZ, to speed up the f/w download.
-         */
-        csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
-        if (csrResult != CSR_RESULT_SUCCESS)
-        {
-            r = ConvertCsrSdioToCsrHipResult(card, csrResult);
-            return r;
-        }
-        card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
-    }
-    else
-    {
-        slut_address = *pslut;  /* Use previously discovered address */
-    }
-    unifi_trace(card->ospriv, UDBG4, "SLUT addr: 0x%lX\n", slut_address);
-
-    /*
-     * Check the SLUT fingerprint.
-     * The slut_address is a generic pointer so we must use unifi_card_read16().
-     */
-    unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
-    finger_print = 0;
-    r = unifi_card_read16(card, slut_address, &finger_print);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        return r;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
-        return r;
-    }
-
-    if (finger_print != SLUT_FINGERPRINT)
-    {
-        unifi_error(card->ospriv, "Failed to find SLUT fingerprint\n");
-        return CSR_RESULT_FAILURE;
-    }
-
-    /* Symbol table starts imedately after the fingerprint */
-    slut_address += 2;
-
-    while (1)
-    {
-        u16 id;
-        u32 obj;
-
-        r = unifi_card_read16(card, slut_address, &id);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-        slut_address += 2;
-
-        if (id == CSR_SLT_END)
-        {
-            /* End of table reached: not found */
-            r = CSR_WIFI_HIP_RESULT_RANGE;
-            break;
-        }
-
-        r = unifi_read32(card, slut_address, &obj);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-        slut_address += 4;
-
-        unifi_trace(card->ospriv, UDBG3, "  found SLUT id %02d.%08lx\n", id, obj);
-
-        r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
-        /* Found search term? */
-        if (id == psym->id)
-        {
-            unifi_trace(card->ospriv, UDBG1, " matched SLUT id %02d.%08lx\n", id, obj);
-            psym->obj = obj;
-            r = CSR_RESULT_SUCCESS;
-            break;
-        }
-    }
-
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  do_patch_convert_download
- *
- *      Download the given firmware image to the UniFi, converting from FWDL
- *      to PTDL XBV format.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      dlpriv          Pointer to source firmware image
- *      fwinfo          Pointer to source firmware info struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on error
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-static CsrResult do_patch_convert_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo)
-{
-    CsrResult r;
-    u32 slut_base = 0xffffffff;
-    void *pfw;
-    u32 psize;
-    symbol_t sym;
-
-    /* Reset the chip to guarantee that the ROM loader is running */
-    r = unifi_init(card);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv,
-                    "do_patch_convert_download: failed to re-init UniFi\n");
-        return r;
-    }
-
-    /* If no unifi_helper is running, the firmware version must be read */
-    if (card->build_id == 0)
-    {
-        u32 ver = 0;
-        sym.id = CSR_SLT_BUILD_ID_NUMBER;
-        sym.obj = 0; /* To be updated by _find_in_slut() */
-
-        unifi_trace(card->ospriv, UDBG1, "Need f/w version\n");
-
-        /* Find chip build id entry in SLUT */
-        r = _find_in_slut(card, &sym, &slut_base);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to find CSR_SLT_BUILD_ID_NUMBER\n");
-            return CSR_RESULT_FAILURE;
-        }
-
-        /* Read running f/w version */
-        r = unifi_read32(card, sym.obj, &ver);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to read f/w id\n");
-            return CSR_RESULT_FAILURE;
-        }
-        card->build_id = ver;
-    }
-
-    /* Convert the ptest firmware to a patch against the running firmware */
-    pfw = xbv_to_patch(card, unifi_fw_read, dlpriv, pfwinfo, &psize);
-    if (!pfw)
-    {
-        unifi_error(card->ospriv, "Failed to convert f/w to patch");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-    else
-    {
-        void *desc;
-        sym.id = CSR_SLT_BOOT_LOADER_CONTROL;
-        sym.obj = 0; /* To be updated by _find_in_slut() */
-
-        /* Find boot loader control entry in SLUT */
-        r = _find_in_slut(card, &sym, &slut_base);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to find BOOT_LOADER_CONTROL\n");
-            kfree(pfw);
-            return CSR_RESULT_FAILURE;
-        }
-
-        r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to wake UniFi\n");
-        }
-
-        /* Get a dlpriv for the patch buffer so that unifi_fw_read() can
-         * access it.
-         */
-        desc = unifi_fw_open_buffer(card->ospriv, pfw, psize);
-        if (!desc)
-        {
-            kfree(pfw);
-            return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-        }
-
-        /* Download the patch */
-        unifi_info(card->ospriv, "Downloading converted f/w as patch\n");
-        r = unifi_dl_patch(card, desc, sym.obj);
-        kfree(pfw);
-        unifi_fw_close_buffer(card->ospriv, desc);
-
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Converted patch download failed\n");
-            return r;
-        }
-        else
-        {
-            unifi_trace(card->ospriv, UDBG1, "Converted patch downloaded\n");
-        }
-
-        /* This command starts the firmware */
-        r = unifi_do_loader_op(card, sym.obj + 6, UNIFI_BOOT_LOADER_RESTART);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to write loader restart cmd\n");
-        }
-
-        return r;
-    }
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_dl_firmware
- *
- *      Download the given firmware image to the UniFi.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      dlpriv          A context pointer from the calling function to be
- *                      passed when calling unifi_fw_read().
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success,
- *      CSR_WIFI_HIP_RESULT_NO_MEMORY         memory allocation failed
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         error in XBV file
- *      CSR_RESULT_FAILURE            SDIO error
- *
- *  Notes:
- *      Stops and resets the chip, does the download and runs the new
- *      firmware.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_dl_firmware(card_t *card, void *dlpriv)
-{
-    xbv1_t *fwinfo;
-    CsrResult r;
-
-    fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
-    if (fwinfo == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for firmware\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-
-    /*
-     * Scan the firmware file to find the TLVs we are interested in.
-     * These are:
-     *   - check we support the file format version in VERF
-     *   - SLTP Symbol Lookup Table Pointer
-     *   - FWDL firmware download segments
-     *   - FWOV firmware overlay segment
-     *   - VMEQ Register probe tests to verify matching h/w
-     */
-    r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
-    if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_firmware)
-    {
-        unifi_error(card->ospriv, "File type is %s, expected firmware.\n",
-                    fwinfo->mode == xbv_patch?"patch" : "unknown");
-        kfree(fwinfo);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    /* UF6xxx doesn't accept firmware, only patches. Therefore we convert
-     * the file to patch format with version numbers matching the current
-     * running firmware, and then download via the patch mechanism.
-     * The sole purpose of this is to support production test firmware across
-     * different ROM releases, the test firmware being provided in non-patch
-     * format.
-     */
-    if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
-    {
-        unifi_info(card->ospriv, "Must convert f/w to patch format\n");
-        r = do_patch_convert_download(card, dlpriv, fwinfo);
-    }
-    else
-    {
-        /* Older UniFi chips allowed firmware to be directly loaded onto the
-         * chip, which is no longer supported.
-         */
-        unifi_error(card->ospriv, "Only patch downloading supported\n");
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    kfree(fwinfo);
-    return r;
-} /* unifi_dl_firmware() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_dl_patch
- *
- *      Load the given patch set into UniFi.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      dlpriv          The os specific handle to the firmware file.
- *      boot_ctrl       The address of the boot loader control structure.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success,
- *      CSR_WIFI_HIP_RESULT_NO_MEMORY         memory allocation failed
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         error in XBV file
- *      CSR_RESULT_FAILURE            SDIO error
- *
- *  Notes:
- *      This ends up telling UniFi to restart.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_dl_patch(card_t *card, void *dlpriv, u32 boot_ctrl)
-{
-    xbv1_t *fwinfo;
-    CsrResult r;
-
-    unifi_info(card->ospriv, "unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl);
-
-    fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
-    if (fwinfo == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate memory for patches\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-
-    /*
-     * Scan the firmware file to find the TLVs we are interested in.
-     * These are:
-     *   - check we support the file format version in VERF
-     *   - FWID The build ID of the ROM that we can patch
-     *   - PTDL patch download segments
-     */
-    r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
-    if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_patch)
-    {
-        kfree(fwinfo);
-        unifi_error(card->ospriv, "Failed to read in patch file\n");
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    /*
-     * We have to check the build id read from the SLUT against that
-     * for the patch file.  They have to match exactly.
-     *    "card->build_id" == XBV1.PTCH.FWID
-     */
-    if (card->build_id != fwinfo->build_id)
-    {
-        unifi_error(card->ospriv, "Wrong patch file for chip (chip = %lu, file = %lu)\n",
-                    card->build_id, fwinfo->build_id);
-        kfree(fwinfo);
-#ifndef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-#else
-        fwinfo = NULL;
-        dlpriv = NULL;
-        return CSR_RESULT_SUCCESS;
-#endif
-    }
-
-    r = do_patch_download(card, dlpriv, fwinfo, boot_ctrl);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to patch image\n");
-    }
-
-    kfree(fwinfo);
-
-    return r;
-} /* unifi_dl_patch() */
-
-
-void* unifi_dl_fw_read_start(card_t *card, s8 is_fw)
-{
-    card_info_t card_info;
-
-    unifi_card_info(card, &card_info);
-    unifi_trace(card->ospriv, UDBG5,
-                "id=%d, ver=0x%x, fw_build=%u, fw_hip=0x%x, block_size=%d\n",
-                card_info.chip_id, card_info.chip_version,
-                card_info.fw_build, card_info.fw_hip_version,
-                card_info.sdio_block_size);
-
-    return unifi_fw_read_start(card->ospriv, is_fw, &card_info);
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  safe_read_shared_location
- *
- *      Read a shared memory location repeatedly until we get two readings
- *      the same.
- *
- *  Arguments:
- *      card            Pointer to card context struct.
- *      unifi_addr      UniFi shared-data-memory address to access.
- *      pdata           Pointer to a byte variable for the value read.
- *
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on failure
- * ---------------------------------------------------------------------------
- */
-static CsrResult safe_read_shared_location(card_t *card, u32 address, u8 *pdata)
-{
-    CsrResult r;
-    u16 limit = 1000;
-    u8 b, b2;
-
-    *pdata = 0;
-
-    r = unifi_read_8_or_16(card, address, &b);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        return r;
-    }
-
-    while (limit--)
-    {
-        r = unifi_read_8_or_16(card, address, &b2);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            return r;
-        }
-
-        /* When we have a stable value, return it */
-        if (b == b2)
-        {
-            *pdata = b;
-            return CSR_RESULT_SUCCESS;
-        }
-
-        b = b2;
-    }
-
-    return CSR_RESULT_FAILURE;
-} /* safe_read_shared_location() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_do_loader_op
- *
- *      Send a loader / boot_loader command to the UniFi and wait for
- *      it to complete.
- *
- *  Arguments:
- *      card            Pointer to card context struct.
- *      op_addr         The address of the loader operation control word.
- *      opcode          The operation to perform.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS    on success
- *      CSR_RESULT_FAILURE    SDIO error or SDIO/XAP timeout
- * ---------------------------------------------------------------------------
- */
-
-/*
- * Ideally instead of sleeping, we want to busy wait.
- * Currently there is no framework API to do this. When it becomes available,
- * we can use it to busy wait using usecs
- */
-#define OPERATION_TIMEOUT_LOOPS (100)  /* when OPERATION_TIMEOUT_DELAY==1, (500) otherwise */
-#define OPERATION_TIMEOUT_DELAY 1      /* msec, or 200usecs */
-
-CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode)
-{
-    CsrResult r;
-    s16 op_retries;
-
-    unifi_trace(card->ospriv, UDBG4, "Loader cmd 0x%0x -> 0x%08x\n", opcode, op_addr);
-
-    /* Set the Operation command byte to the opcode */
-    r = unifi_write_8_or_16(card, op_addr, opcode);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to write loader copy command\n");
-        return r;
-    }
-
-    /* Wait for Operation command byte to be Idle */
-    /* Typically takes ~100us */
-    op_retries = 0;
-    r = CSR_RESULT_SUCCESS;
-    while (1)
-    {
-        u8 op;
-
-        /*
-         * Read the memory location until two successive reads give
-         * the same value.
-         * Then handle it.
-         */
-        r = safe_read_shared_location(card, op_addr, &op);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Failed to read loader status\n");
-            break;
-        }
-
-        if (op == UNIFI_LOADER_IDLE)
-        {
-            /* Success */
-            break;
-        }
-
-        if (op != opcode)
-        {
-            unifi_error(card->ospriv, "Error reported by loader: 0x%X\n", op);
-            r = CSR_RESULT_FAILURE;
-            break;
-        }
-
-        /* Allow 500us timeout */
-        if (++op_retries >= OPERATION_TIMEOUT_LOOPS)
-        {
-            unifi_error(card->ospriv, "Timeout waiting for loader to ack transfer\n");
-            /* Stop XAPs to aid post-mortem */
-            r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
-            if (r != CSR_RESULT_SUCCESS)
-            {
-                unifi_error(card->ospriv, "Failed to stop UniFi processors\n");
-            }
-            else
-            {
-                r = CSR_RESULT_FAILURE;
-            }
-            break;
-        }
-        CsrThreadSleep(OPERATION_TIMEOUT_DELAY);
-    } /* Loop exits with r != CSR_RESULT_SUCCESS on error */
-
-    return r;
-}     /* unifi_do_loader_op() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  send_ptdl_to_unifi
- *
- *      Copy a patch block from userland to the UniFi.
- *      This function reads data, 2K at a time, from userland and writes
- *      it to the UniFi.
- *
- *  Arguments:
- *      card            A pointer to the card structure
- *      dlpriv          The os specific handle for the firmware file
- *      ptdl            A pointer ot the PTDL block
- *      handle          The buffer handle to use for the xfer
- *      op_addr         The address of the loader operation control word
- *
- *  Returns:
- *      Number of bytes sent (Positive) or negative value indicating
- *      error code:
- *      CSR_WIFI_HIP_RESULT_NO_MEMORY         memory allocation failed
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         error in XBV file
- *      CSR_RESULT_FAILURE            SDIO error
- * ---------------------------------------------------------------------------
- */
-static CsrResult send_ptdl_to_unifi(card_t *card, void *dlpriv,
-                                    const struct PTDL *ptdl, u32 handle,
-                                    u32 op_addr)
-{
-    u32 offset;
-    u8 *buf;
-    s32 data_len;
-    u32 write_len;
-    CsrResult r;
-    const u16 buf_size = 2 * 1024;
-
-    offset = ptdl->dl_offset;
-    data_len = ptdl->dl_size;
-
-    if (data_len > buf_size)
-    {
-        unifi_error(card->ospriv, "PTDL block is too large (%u)\n",
-                    ptdl->dl_size);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    buf = kmalloc(buf_size, GFP_KERNEL);
-    if (buf == NULL)
-    {
-        unifi_error(card->ospriv, "Failed to allocate transfer buffer for firmware download\n");
-        return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-    }
-
-    r = CSR_RESULT_SUCCESS;
-
-    if (unifi_fw_read(card->ospriv, dlpriv, offset, buf, data_len) != data_len)
-    {
-        unifi_error(card->ospriv, "Failed to read from file\n");
-    }
-    else
-    {
-        /* We can always round these if the host wants to */
-        if (card->sdio_io_block_pad)
-        {
-            write_len = (data_len + (card->sdio_io_block_size - 1)) &
-                        ~(card->sdio_io_block_size - 1);
-
-            /* Zero out the rest of the buffer (This isn't needed, but it
-             * makes debugging things later much easier). */
-            memset(buf + data_len, 0, write_len - data_len);
-        }
-        else
-        {
-            write_len = data_len;
-        }
-
-        r = unifi_bulk_rw_noretry(card, handle, buf, write_len, UNIFI_SDIO_WRITE);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "CMD53 failed writing %d bytes to handle %ld\n",
-                        data_len, handle);
-        }
-        else
-        {
-            /*
-             * Can change the order of things to overlap read from file
-             * with copy to unifi
-             */
-            r = unifi_do_loader_op(card, op_addr, UNIFI_BOOT_LOADER_PATCH);
-        }
-    }
-
-    kfree(buf);
-
-    if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        unifi_error(card->ospriv, "Failed to copy block of %u bytes to UniFi\n",
-                    ptdl->dl_size);
-    }
-
-    return r;
-} /* send_ptdl_to_unifi() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  do_patch_download
- *
- *      This function downloads a set of patches to UniFi and then
- *      causes it to restart.
- *
- *  Arguments:
- *      card            Pointer to card struct.
- *      dlpriv          A context pointer from the calling function to be
- *                      used when reading the XBV file.  This can be NULL
- *                      in which case not patches are applied.
- *      pfwinfo         Pointer to a fwinfo struct describing the f/w
- *                      XBV file.
- *      boot_ctrl_addr  The address of the boot loader control structure.
- *
- *  Returns:
- *      0 on success, or an error code
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE for a bad laoader version number
- * ---------------------------------------------------------------------------
- */
-static CsrResult do_patch_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo, u32 boot_ctrl_addr)
-{
-    CsrResult r;
-    s32 i;
-    u16 loader_version;
-    u16 handle;
-    u32 total_bytes;
-
-    /*
-     * Read info from the SDIO Loader Control Data Structure
-     */
-    /* Check the loader version */
-    r = unifi_card_read16(card, boot_ctrl_addr, &loader_version);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Patch download: Failed to read loader version\n");
-        return r;
-    }
-    unifi_trace(card->ospriv, UDBG2, "Patch download: boot loader version 0x%04X\n", loader_version);
-    switch (loader_version)
-    {
-        case 0x0000:
-            break;
-
-        default:
-            unifi_error(card->ospriv, "Patch loader version (0x%04X) is not supported by this driver\n",
-                        loader_version);
-            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    /* Retrieve the handle to use with CMD53 */
-    r = unifi_card_read16(card, boot_ctrl_addr + 4, &handle);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Patch download: Failed to read loader handle\n");
-        return r;
-    }
-
-    /* Set the mask of LEDs to flash */
-    if (card->loader_led_mask)
-    {
-        r = unifi_card_write16(card, boot_ctrl_addr + 2,
-                               (u16)card->loader_led_mask);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Patch download: Failed to write LED mask\n");
-            return r;
-        }
-    }
-
-    total_bytes = 0;
-
-    /* Copy download data to UniFi memory */
-    for (i = 0; i < pfwinfo->num_ptdl; i++)
-    {
-        unifi_trace(card->ospriv, UDBG3, "Patch download: %d Downloading for %d from offset %d\n",
-                    i,
-                    pfwinfo->ptdl[i].dl_size,
-                    pfwinfo->ptdl[i].dl_offset);
-
-        r = send_ptdl_to_unifi(card, dlpriv, &pfwinfo->ptdl[i],
-                               handle, boot_ctrl_addr + 6);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            return r;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Patch failed after %u bytes\n",
-                        total_bytes);
-            return r;
-        }
-        total_bytes += pfwinfo->ptdl[i].dl_size;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* do_patch_download() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_dump.c b/drivers/staging/csr/csr_wifi_hip_dump.c
deleted file mode 100644 (file)
index 7b7eec4..0000000
+++ /dev/null
@@ -1,837 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- * FILE: csr_wifi_hip_dump.c
- *
- * PURPOSE:
- *      Routines for retrieving and buffering core status from the UniFi
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/slab.h>
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_unifiversion.h"
-#include "csr_wifi_hip_card.h"
-
-/* Locations to capture in dump (XAP words) */
-#define HIP_CDUMP_FIRST_CPUREG      (0xFFE0) /* First CPU register */
-#define HIP_CDUMP_FIRST_LO          (0)      /* Start of low address range */
-#define HIP_CDUMP_FIRST_HI_MAC      (0x3C00) /* Start of MAC high area */
-#define HIP_CDUMP_FIRST_HI_PHY      (0x1C00) /* Start of PHY high area */
-#define HIP_CDUMP_FIRST_SH          (0)      /* Start of shared memory area */
-
-#define HIP_CDUMP_NCPUREGS    (10)           /* No. of 16-bit XAP registers */
-#define HIP_CDUMP_NWORDS_LO   (0x0100)       /* Low area size in 16-bit words */
-#define HIP_CDUMP_NWORDS_HI   (0x0400)       /* High area size in 16-bit words */
-#define HIP_CDUMP_NWORDS_SH   (0x0500)       /* Shared memory area size, 16-bit words */
-
-#define HIP_CDUMP_NUM_ZONES 7                /* Number of UniFi memory areas to capture */
-
-/* Mini-coredump state */
-typedef struct coredump_buf
-{
-    u16  count;                       /* serial number of dump */
-    u32  timestamp;                   /* host's system time at capture */
-    s16   requestor;                   /* request: 0=auto dump, 1=manual */
-    u16  chip_ver;
-    u32  fw_ver;
-    u16 *zone[HIP_CDUMP_NUM_ZONES];
-
-    struct coredump_buf *next;              /* circular list */
-    struct coredump_buf *prev;              /* circular list */
-} coredump_buffer;
-
-/* Structure used to describe a zone of chip memory captured by mini-coredump */
-struct coredump_zone
-{
-    unifi_coredump_space_t           space;  /* XAP memory space this zone covers */
-    enum unifi_dbg_processors_select cpu;    /* XAP CPU core selector */
-    u32                        gp;     /* Generic Pointer to memory zone on XAP */
-    u16                        offset; /* 16-bit XAP word offset of zone in memory space */
-    u16                        length; /* Length of zone in XAP words */
-};
-
-static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf);
-static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf);
-static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zone,
-                                          const struct coredump_zone *def);
-static s32 get_value_from_coredump(const coredump_buffer *dump,
-                                        const unifi_coredump_space_t space, const u16 offset);
-
-/* Table of chip memory zones we capture on mini-coredump */
-static const struct coredump_zone zonedef_table[HIP_CDUMP_NUM_ZONES] = {
-    { UNIFI_COREDUMP_MAC_REG,  UNIFI_PROC_MAC, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
-    { UNIFI_COREDUMP_PHY_REG,  UNIFI_PROC_PHY, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
-    { UNIFI_COREDUMP_SH_DMEM,  UNIFI_PROC_INVALID, UNIFI_MAKE_GP(SH_DMEM, HIP_CDUMP_FIRST_SH * 2),   HIP_CDUMP_FIRST_SH,     HIP_CDUMP_NWORDS_SH },
-    { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_LO * 2),      HIP_CDUMP_FIRST_LO,     HIP_CDUMP_NWORDS_LO },
-    { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_HI_MAC * 2),  HIP_CDUMP_FIRST_HI_MAC, HIP_CDUMP_NWORDS_HI },
-    { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_LO * 2),      HIP_CDUMP_FIRST_LO,     HIP_CDUMP_NWORDS_LO },
-    { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_HI_PHY * 2),  HIP_CDUMP_FIRST_HI_PHY, HIP_CDUMP_NWORDS_HI },
-};
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_request_at_next_reset
- *
- *      Request that a mini-coredump is performed when the driver has
- *      completed resetting the UniFi device.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      enable          If non-zero, sets the request.
- *                      If zero, cancels any pending request.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS or CSR HIP error code
- *
- *  Notes:
- *      This function is typically called once the driver has detected that
- *      the UniFi device has become unresponsive due to crash, or internal
- *      watchdog reset. The driver must reset it to regain communication and,
- *      immediately after that, the mini-coredump can be captured.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable)
-{
-    CsrResult r;
-
-    if (enable)
-    {
-        unifi_trace(card->ospriv, UDBG2, "Mini-coredump requested after reset\n");
-    }
-
-    if (card == NULL)
-    {
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-    else
-    {
-        card->request_coredump_on_reset = enable?1 : 0;
-        r = CSR_RESULT_SUCCESS;
-    }
-
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_handle_request
- *
- *      Performs a coredump now, if one was requested, and clears the request.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS or CSR HIP error code
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_coredump_handle_request(card_t *card)
-{
-    CsrResult r = CSR_RESULT_SUCCESS;
-
-    if (card == NULL)
-    {
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-    else
-    {
-        if (card->request_coredump_on_reset == 1)
-        {
-            card->request_coredump_on_reset = 0;
-            r = unifi_coredump_capture(card, NULL);
-        }
-    }
-
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_capture
- *
- *      Capture the current status of the UniFi device.
- *      Various registers are buffered for future offline inspection.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      req             Pointer to request struct, or NULL:
- *                          A coredump requested manually by the user app
- *                          will have a request struct pointer, an automatic
- *                          coredump will have a NULL pointer.
- *  Returns:
- *      CSR_RESULT_SUCCESS  on success,
- *      CSR_RESULT_FAILURE  SDIO error
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE  Initialisation not complete
- *
- *  Notes:
- *      The result is a filled entry in the circular buffer of core dumps,
- *      values from which can be extracted to userland via an ioctl.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req)
-{
-    CsrResult r = CSR_RESULT_SUCCESS;
-    static u16 dump_seq_no = 1;
-    u32 time_of_capture;
-
-    if (card->dump_next_write == NULL)
-    {
-        r = CSR_RESULT_SUCCESS;
-        goto done;
-    }
-
-    /* Reject forced capture before initialisation has happened */
-    if (card->helper == NULL)
-    {
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-        goto done;
-    }
-
-
-    /*
-     * Force a mini-coredump capture right now
-     */
-    time_of_capture = CsrTimeGet(NULL);
-    unifi_info(card->ospriv, "Mini-coredump capture at t=%u\n", time_of_capture);
-
-    /* Wake up the processors so we can talk to them */
-    r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to wake UniFi\n");
-        goto done;
-    }
-    CsrThreadSleep(20);
-
-    /* Stop both XAPs */
-    unifi_trace(card->ospriv, UDBG4, "Stopping XAPs for coredump capture\n");
-    r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to stop UniFi XAPs\n");
-        goto done;
-    }
-
-    /* Dump core into the next available slot in the circular list */
-    r = unifi_coredump_from_sdio(card, card->dump_next_write);
-    if (r == CSR_RESULT_SUCCESS)
-    {
-        /* Record whether the dump was manual or automatic */
-        card->dump_next_write->requestor = (req?1 : 0);
-        card->dump_next_write->timestamp = time_of_capture;
-        /* Advance to the next buffer */
-        card->dump_next_write->count = dump_seq_no++;
-        card->dump_cur_read = card->dump_next_write;
-        card->dump_next_write = card->dump_next_write->next;
-
-        /* Sequence no. of zero indicates slot not in use, so handle wrap */
-        if (dump_seq_no == 0)
-        {
-            dump_seq_no = 1;
-        }
-
-        unifi_trace(card->ospriv, UDBG3,
-                    "Coredump (%p), SeqNo=%d, cur_read=%p, next_write=%p\n",
-                    req,
-                    card->dump_cur_read->count,
-                    card->dump_cur_read, card->dump_next_write);
-    }
-
-    /* Start both XAPs */
-    unifi_trace(card->ospriv, UDBG4, "Restart XAPs after coredump\n");
-    r = card_start_processor(card, UNIFI_PROC_BOTH);
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Failed to start UniFi XAPs\n");
-        goto done;
-    }
-
-done:
-    return r;
-} /* unifi_coredump_capture() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  get_value_from_coredump
- *
- *
- *
- *  Arguments:
- *      dump                Pointer to buffered coredump data
- *      offset_in_space     XAP memory space to retrieve from the buffer (there
- *                          may be more than one zone covering the same memory
- *                          space, but starting from different offsets).
- *      offset              Offset within the XAP memory space to be retrieved
- *
- *  Returns:
- *      >=0                  Register value on success
- *      <0                   Register out of range of any captured zones
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-static s32 get_value_from_coredump(const coredump_buffer       *coreDump,
-                                        const unifi_coredump_space_t space,
-                                        const u16              offset_in_space)
-{
-    s32 r = -1;
-    u16 offset_in_zone;
-    u32 zone_end_offset;
-    s32 i;
-    const struct coredump_zone *def = &zonedef_table[0];
-
-    /* Search zone def table for a match with the requested memory space */
-    for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++, def++)
-    {
-        if (space == def->space)
-        {
-            zone_end_offset = def->offset + def->length;
-
-            /* Is the space offset contained in this zone? */
-            if (offset_in_space < zone_end_offset &&
-                offset_in_space >= def->offset)
-            {
-                /* Calculate the offset of data within the zone buffer */
-                offset_in_zone = offset_in_space - def->offset;
-                r = (s32) * (coreDump->zone[i] + offset_in_zone);
-
-                unifi_trace(NULL, UDBG6,
-                            "sp %d, offs 0x%04x = 0x%04x (in z%d 0x%04x->0x%04x)\n",
-                            space, offset_in_space, r,
-                            i, def->offset, zone_end_offset - 1);
-                break;
-            }
-        }
-    }
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_get_value
- *
- *      Retrieve the value of a register buffered from a previous core dump,
- *      so that it may be reported back to application code.
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      req_reg         Pointer to request parameter partially filled. This
- *                      function puts in the values retrieved from the dump.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, or:
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         Null parameter error
- *      CSR_WIFI_HIP_RESULT_RANGE                 Register out of range
- *      CSR_WIFI_HIP_RESULT_NOT_FOUND             Dump index not (yet) captured
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req)
-{
-    CsrResult r;
-    s32 i = 0;
-    coredump_buffer *find_dump = NULL;
-
-    if (req == NULL || card == NULL)
-    {
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-        goto done;
-    }
-    req->value = -1;
-    if (card->dump_buf == NULL)
-    {
-        unifi_trace(card->ospriv, UDBG2, "No coredump buffers\n");
-        r = CSR_WIFI_HIP_RESULT_NOT_FOUND;     /* Coredumping disabled */
-        goto done;
-    }
-    if (card->dump_cur_read == NULL)
-    {
-        unifi_trace(card->ospriv, UDBG4, "No coredumps captured\n");
-        r = CSR_WIFI_HIP_RESULT_NOT_FOUND;     /* No coredump yet captured */
-        goto done;
-    }
-
-    /* Find the requested dump buffer */
-    switch (req->index)
-    {
-        case 0:     /* Newest */
-            find_dump = card->dump_cur_read;
-            break;
-        case -1:    /* Oldest: The next used slot forward */
-            for (find_dump = card->dump_cur_read->next;
-                 (find_dump->count == 0) && (find_dump != card->dump_cur_read);
-                 find_dump = card->dump_cur_read->next)
-            {
-            }
-            break;
-        default:    /* Number of steps back from current read position */
-            for (i = 0, find_dump = card->dump_cur_read;
-                 i < req->index;
-                 i++, find_dump = find_dump->prev)
-            {
-                /* Walk the list for the index'th entry, but
-                 * stop when about to wrap. */
-                unifi_trace(card->ospriv, UDBG6,
-                            "%d: %d, @%p, p=%p, n=%p, cr=%p, h=%p\n",
-                            i, find_dump->count, find_dump, find_dump->prev,
-                            find_dump->next, card->dump_cur_read, card->dump_buf);
-                if (find_dump->prev == card->dump_cur_read)
-                {
-                    /* Wrapped but still not found, index out of range */
-                    if (i != req->index)
-                    {
-                        unifi_trace(card->ospriv, UDBG6,
-                                    "Dump index %d not found %d\n", req->index, i);
-                        r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
-                        goto done;
-                    }
-                    break;
-                }
-            }
-            break;
-    }
-
-    /* Check if the slot is actually filled with a core dump */
-    if (find_dump->count == 0)
-    {
-        unifi_trace(card->ospriv, UDBG4, "Not captured %d\n", req->index);
-        r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
-        goto done;
-    }
-
-    unifi_trace(card->ospriv, UDBG6, "Req index %d, found seq %d at step %d\n",
-                req->index, find_dump->count, i);
-
-    /* Find the appropriate entry in the buffer */
-    req->value = get_value_from_coredump(find_dump, req->space, (u16)req->offset);
-    if (req->value < 0)
-    {
-        r = CSR_WIFI_HIP_RESULT_RANGE;     /* Un-captured register */
-        unifi_trace(card->ospriv, UDBG4,
-                    "Can't read space %d, reg 0x%x from coredump buffer %d\n",
-                    req->space, req->offset, req->index);
-    }
-    else
-    {
-        r = CSR_RESULT_SUCCESS;
-    }
-
-    /* Update the private request structure with the found values */
-    req->chip_ver = find_dump->chip_ver;
-    req->fw_ver = find_dump->fw_ver;
-    req->timestamp = find_dump->timestamp;
-    req->requestor = find_dump->requestor;
-    req->serial = find_dump->count;
-
-done:
-    return r;
-} /* unifi_coredump_get_value() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_read_zone
- *
- *      Captures a UniFi memory zone into a buffer on the host
- *
- *  Arguments:
- *      card          Pointer to card struct
- *      zonebuf       Pointer to on-host buffer to dump the memory zone into
- *      def           Pointer to description of the memory zone to read from UniFi.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS                   on success, or:
- *      CSR_RESULT_FAILURE                   SDIO error
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         Parameter error
- *
- *  Notes:
- *      It is assumed that the caller has already stopped the XAPs
- * ---------------------------------------------------------------------------
- */
-static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zonebuf, const struct coredump_zone *def)
-{
-    CsrResult r;
-
-    if (zonebuf == NULL || def == NULL)
-    {
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-        goto done;
-    }
-
-    /* Select XAP CPU if necessary */
-    if (def->cpu != UNIFI_PROC_INVALID)
-    {
-        if (def->cpu != UNIFI_PROC_MAC && def->cpu != UNIFI_PROC_PHY)
-        {
-            r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            goto done;
-        }
-        r = unifi_set_proc_select(card, def->cpu);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            goto done;
-        }
-    }
-
-    unifi_trace(card->ospriv, UDBG4,
-                "Dump sp %d, offs 0x%04x, 0x%04x words @GP=%08x CPU %d\n",
-                def->space, def->offset, def->length, def->gp, def->cpu);
-
-    /* Read on-chip RAM (byte-wise) */
-    r = unifi_card_readn(card, def->gp, zonebuf, (u16)(def->length * 2));
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        goto done;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Can't read UniFi shared data area\n");
-        goto done;
-    }
-
-done:
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_read_zones
- *
- *      Walks through the table of on-chip memory zones defined in zonedef_table,
- *      and reads each of them from the UniFi chip
- *
- *  Arguments:
- *      card          Pointer to card struct
- *      dump_buf      Buffer into which register values will be dumped
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS                   on success, or:
- *      CSR_RESULT_FAILURE                   SDIO error
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         Parameter error
- *
- *  Notes:
- *      It is assumed that the caller has already stopped the XAPs
- * ---------------------------------------------------------------------------
- */
-static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf)
-{
-    CsrResult r = CSR_RESULT_SUCCESS;
-    s32 i;
-
-    /* Walk the table of coredump zone definitions and read them from the chip */
-    for (i = 0;
-         (i < HIP_CDUMP_NUM_ZONES) && (r == 0);
-         i++)
-    {
-        r = unifi_coredump_read_zone(card, dump_buf->zone[i], &zonedef_table[i]);
-    }
-
-    return r;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_from_sdio
- *
- *      Capture the status of the UniFi processors, over SDIO
- *
- *  Arguments:
- *      card            Pointer to card struct
- *      reg_buffer      Buffer into which register values will be dumped
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS                   on success, or:
- *      CSR_RESULT_FAILURE                   SDIO error
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE         Parameter error
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf)
-{
-    u16 val;
-    CsrResult r;
-    u32 sdio_addr;
-
-    if (dump_buf == NULL)
-    {
-        r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-        goto done;
-    }
-
-
-    /* Chip and firmware version */
-    unifi_trace(card->ospriv, UDBG4, "Get chip version\n");
-    sdio_addr = 2 * ChipHelper_GBL_CHIP_VERSION(card->helper);
-    if (sdio_addr != 0)
-    {
-        r = unifi_read_direct16(card, sdio_addr, &val);
-        if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-        {
-            goto done;
-        }
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "Can't read GBL_CHIP_VERSION\n");
-            goto done;
-        }
-    }
-    dump_buf->chip_ver = val;
-    dump_buf->fw_ver = card->build_id;
-
-    unifi_trace(card->ospriv, UDBG4, "chip_ver 0x%04x, fw_ver %u\n",
-                dump_buf->chip_ver, dump_buf->fw_ver);
-
-    /* Capture the memory zones required from UniFi */
-    r = unifi_coredump_read_zones(card, dump_buf);
-    if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
-    {
-        goto done;
-    }
-    if (r != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(card->ospriv, "Can't read UniFi memory areas\n");
-        goto done;
-    }
-
-done:
-    return r;
-} /* unifi_coredump_from_sdio() */
-
-
-#ifndef UNIFI_DISABLE_COREDUMP
-/*
- * ---------------------------------------------------------------------------
- *  new_coredump_node
- *
- *      Allocates a coredump linked-list node, and links it to the previous.
- *
- *  Arguments:
- *      ospriv          OS context
- *      prevnode        Previous node to link into
- *
- *  Returns:
- *      Pointer to valid coredump_buffer on success
- *      NULL on memory allocation failure
- *
- *  Notes:
- *      Allocates "all or nothing"
- * ---------------------------------------------------------------------------
- */
-static
-coredump_buffer* new_coredump_node(void *ospriv, coredump_buffer *prevnode)
-{
-    coredump_buffer *newnode = NULL;
-    u16 *newzone = NULL;
-    s32 i;
-    u32 zone_size;
-
-    /* Allocate node header */
-    newnode = kzalloc(sizeof(coredump_buffer), GFP_KERNEL);
-    if (newnode == NULL)
-    {
-        return NULL;
-    }
-
-    /* Allocate chip memory zone capture buffers */
-    for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++)
-    {
-        zone_size = sizeof(u16) * zonedef_table[i].length;
-        newzone = kzalloc(zone_size, GFP_KERNEL);
-        newnode->zone[i] = newzone;
-        if (newzone == NULL)
-        {
-            unifi_error(ospriv, "Out of memory on coredump zone %d (%d words)\n",
-                        i, zonedef_table[i].length);
-            break;
-        }
-    }
-
-    /* Clean up if any zone alloc failed */
-    if (newzone == NULL)
-    {
-        for (i = 0; newnode->zone[i] != NULL; i++)
-        {
-            kfree(newnode->zone[i]);
-            newnode->zone[i] = NULL;
-        }
-    }
-
-    /* Link to previous node */
-    newnode->prev = prevnode;
-    if (prevnode)
-    {
-        prevnode->next = newnode;
-    }
-    newnode->next = NULL;
-
-    return newnode;
-}
-
-
-#endif /* UNIFI_DISABLE_COREDUMP */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_init
- *
- *      Allocates buffers for the automatic SDIO core dump
- *
- *  Arguments:
- *      card                Pointer to card struct
- *      num_dump_buffers    Number of buffers to reserve for coredumps
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS               on success, or:
- *      CSR_WIFI_HIP_RESULT_NO_MEMORY         memory allocation failed
- *
- *  Notes:
- *      Allocates space in advance, to be used for the last n coredump buffers
- *      the intention being that the size is sufficient for at least one dump,
- *      probably several.
- *      It's probably advisable to have at least 2 coredump buffers to allow
- *      one to be enquired with the unifi_coredump tool, while leaving another
- *      free for capturing.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers)
-{
-#ifndef UNIFI_DISABLE_COREDUMP
-    void *ospriv = card->ospriv;
-    coredump_buffer *prev = NULL;
-    coredump_buffer *newnode = NULL;
-    u32 i = 0;
-#endif
-
-    card->request_coredump_on_reset = 0;
-    card->dump_next_write = NULL;
-    card->dump_cur_read = NULL;
-    card->dump_buf = NULL;
-
-#ifndef UNIFI_DISABLE_COREDUMP
-    unifi_trace(ospriv, UDBG1,
-                "Allocate buffers for %d core dumps\n", num_dump_buffers);
-    if (num_dump_buffers == 0)
-    {
-        goto done;
-    }
-
-    /* Root node */
-    card->dump_buf = new_coredump_node(ospriv, NULL);
-    if (card->dump_buf == NULL)
-    {
-        goto fail;
-    }
-    prev = card->dump_buf;
-    newnode = card->dump_buf;
-
-    /* Add each subsequent node at tail */
-    for (i = 1; i < num_dump_buffers; i++)
-    {
-        newnode = new_coredump_node(ospriv, prev);
-        if (newnode == NULL)
-        {
-            goto fail;
-        }
-        prev = newnode;
-    }
-
-    /* Link the first and last nodes to make the list circular */
-    card->dump_buf->prev = newnode;
-    newnode->next = card->dump_buf;
-
-    /* Set initial r/w access pointers */
-    card->dump_next_write = card->dump_buf;
-    card->dump_cur_read = NULL;
-
-    unifi_trace(ospriv, UDBG2, "Core dump configured (%d dumps max)\n", i);
-
-done:
-#endif
-    return CSR_RESULT_SUCCESS;
-
-#ifndef UNIFI_DISABLE_COREDUMP
-fail:
-    /* Unwind what we allocated so far */
-    unifi_error(ospriv, "Out of memory allocating core dump node %d\n", i);
-    unifi_coredump_free(card);
-    return CSR_WIFI_HIP_RESULT_NO_MEMORY;
-#endif
-} /* unifi_coreump_init() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_coredump_free
- *
- *      Free all memory dynamically allocated for core dump
- *
- *  Arguments:
- *      card            Pointer to card struct
- *
- *  Returns:
- *      None
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-void unifi_coredump_free(card_t *card)
-{
-    void *ospriv = card->ospriv;
-    coredump_buffer *node, *del_node;
-    s16 i = 0;
-    s16 j;
-
-    unifi_trace(ospriv, UDBG2, "Core dump de-configured\n");
-
-    if (card->dump_buf == NULL)
-    {
-        return;
-    }
-
-    node = card->dump_buf;
-    do
-    {
-        /* Free payload zones */
-        for (j = 0; j < HIP_CDUMP_NUM_ZONES; j++)
-        {
-            kfree(node->zone[j]);
-            node->zone[j] = NULL;
-        }
-
-        /* Detach */
-        del_node = node;
-        node = node->next;
-
-        /* Free header */
-        kfree(del_node);
-        i++;
-    } while ((node != NULL) && (node != card->dump_buf));
-
-    unifi_trace(ospriv, UDBG3, "Freed %d coredump buffers\n", i);
-
-    card->dump_buf = NULL;
-    card->dump_next_write = NULL;
-    card->dump_cur_read = NULL;
-} /* unifi_coredump_free() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_packing.c b/drivers/staging/csr/csr_wifi_hip_packing.c
deleted file mode 100644 (file)
index 0768aef..0000000
+++ /dev/null
@@ -1,4804 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#include "csr_wifi_hip_signals.h"
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-
-
-/*
- * ---------------------------------------------------------------------------
- *  get_packed_struct_size
- *
- *      Examine a buffer containing a UniFi signal in wire-format.
- *      The first two bytes contain the signal ID, decode the signal ID and
- *      return the size, in  bytes, of the signal, not including any bulk
- *      data.
- *
- *      WARNING: This function is auto-generated, DO NOT EDIT!
- *
- *  Arguments:
- *      buf     Pointer to buffer to decode.
- *
- *  Returns:
- *      0 if the signal ID is not recognised (i.e. zero length),
- *      otherwise the number of bytes occupied by the signal in the buffer.
- *      This is useful for stepping past the signal to the object in the buffer.
- * ---------------------------------------------------------------------------
- */
-s32 get_packed_struct_size(const u8 *buf)
-{
-    s32 size = 0;
-    u16 sig_id;
-
-    sig_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(buf);
-
-    size += SIZEOF_UINT16;
-    size += SIZEOF_UINT16;
-    size += SIZEOF_UINT16;
-    switch (sig_id)
-    {
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-        case CSR_MA_PACKET_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT64;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-        case CSR_MLME_SET_TIM_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-        case CSR_DEBUG_GENERIC_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-        case CSR_MA_PACKET_CANCEL_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-        case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT32;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 32 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT32;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += 48 / 8;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT32;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_REQUEST_ID:
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            size += SIZEOF_UINT16;
-            break;
-#endif
-        default:
-            size = 0;
-    }
-    return size;
-} /* get_packed_struct_size() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  read_unpack_signal
- *
- *      Unpack a wire-format signal into a host-native structure.
- *      This function handles any necessary conversions for endianness and
- *      places no restrictions on packing or alignment for the structure
- *      definition.
- *
- *      WARNING: This function is auto-generated, DO NOT EDIT!
- *
- *  Arguments:
- *      ptr             Signal buffer to unpack.
- *      sig             Pointer to destination structure to populate.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success,
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
- * ---------------------------------------------------------------------------
- */
-CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig)
-{
-    s32 index = 0;
-
-    sig->SignalPrimitiveHeader.SignalId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-
-    sig->SignalPrimitiveHeader.ReceiverProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-
-    sig->SignalPrimitiveHeader.SenderProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-    index += SIZEOF_UINT16;
-
-    switch (sig->SignalPrimitiveHeader.SignalId)
-    {
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-            sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-            sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-            sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-            sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-            sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
-            sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-            sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_CONFIRM_ID:
-            sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-            sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeStopAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_REQUEST_ID:
-            sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            sig->u.DebugWord16Indication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[8] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[9] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[10] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[11] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[12] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[13] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[14] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugWord16Indication.DebugWords[15] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            sig->u.DebugGenericConfirm.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericConfirm.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_MA_PACKET_INDICATION_ID:
-            sig->u.MaPacketIndication.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MaPacketIndication.LocalTime.x, &ptr[index], 64 / 8);
-            index += 64 / 8;
-            sig->u.MaPacketIndication.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.ReceptionStatus = (CSR_RECEPTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.Rssi = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.Snr = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketIndication.ReceivedRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_MLME_SET_TIM_REQUEST_ID:
-            sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimRequest.TimValue = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectedIndication.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeConnectedIndication.PeerMacAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
-            sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
-            sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeTriggeredGetIndication.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_REQUEST_ID:
-            sig->u.MlmeScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-            sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_REQUEST_ID:
-            sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-            sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_REQUEST_ID:
-            sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeStartAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.StartingSequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.BufferSize = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationRequest.BlockAckTimeout = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_REQUEST_ID:
-            sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeHlSyncRequest.GroupAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-        case CSR_DEBUG_GENERIC_REQUEST_ID:
-            sig->u.DebugGenericRequest.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericRequest.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-            sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
-            sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
-            sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_REQUEST_ID:
-            sig->u.MlmeResetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeResetRequest.StaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeResetRequest.SetDefaultMib = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
-            sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-            sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
-            sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterRequest.PacketFilterMode = (CSR_PACKET_FILTER_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-            sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
-            sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusRequest.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeConnectStatusRequest.StaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeConnectStatusRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_REQUEST_ID:
-            sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
-            sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.QueueIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.Aifs = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.Cwmin = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.Cwmax = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConfigQueueRequest.TxopLimit = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-            sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetTimConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_INDICATION_ID:
-            sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureIndication.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-            sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-            sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            sig->u.DebugGenericIndication.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugGenericIndication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_MA_PACKET_CANCEL_REQUEST_ID:
-            sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketCancelRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-            sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-            sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_REQUEST_ID:
-            sig->u.MaPacketRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketRequest.TransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MaPacketRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MaPacketRequest.Ra.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MaPacketRequest.TransmissionControl = (CSR_TRANSMISSION_CONTROL) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
-            sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeModifyBssParameterRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeModifyBssParameterRequest.Bssid.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeModifyBssParameterRequest.RtsThreshold = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
-            sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
-            sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityIndication.Multicast = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
-            sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
-            sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
-            sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlackoutEndedIndication.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
-            sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanDoneIndication.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
-            sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetKeySequenceRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeGetKeySequenceRequest.Address.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_REQUEST_ID:
-            sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeSetChannelRequest.Address.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeSetChannelRequest.AvailabilityDuration = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetChannelRequest.AvailabilityInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-            sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
-            sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
-            sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeAutonomousScanLossIndication.Bssid.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-        case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
-            sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaVifAvailabilityResponse.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
-            sig->u.MlmeAddTemplateRequest.Data1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateRequest.Data1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateRequest.Data2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateRequest.Data2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateRequest.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateRequest.MinTransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-            sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-            sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_CONFIRM_ID:
-            sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-            sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetNextConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
-            sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeStopAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-            sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
-            sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.BlackoutType = (CSR_BLACKOUT_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.BlackoutSource = (CSR_BLACKOUT_SOURCE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddBlackoutRequest.BlackoutStartReference = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeAddBlackoutRequest.BlackoutPeriod = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeAddBlackoutRequest.BlackoutDuration = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            memcpy(sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeAddBlackoutRequest.BlackoutCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_REQUEST_ID:
-            sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDeletekeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeDeletekeysRequest.Address.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_CONFIRM_ID:
-            sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeResetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-            sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeHlSyncConfirm.GroupAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeHlSyncConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
-            sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeAddAutonomousScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_REQUEST_ID:
-            sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetRequest.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_REQUEST_ID:
-            sig->u.MlmeSmStartRequest.Beacon.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.Beacon.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.BssParameters.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.BssParameters.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeSmStartRequest.InterfaceAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            memcpy(sig->u.MlmeSmStartRequest.Bssid.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeSmStartRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSmStartRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-            sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeConnectStatusConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-            sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
-            sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_REQUEST_ID:
-            sig->u.MlmeSetkeysRequest.Key.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.Key.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.Length = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeSetkeysRequest.Address.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetkeysRequest.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(&sig->u.MlmeSetkeysRequest.CipherSuiteSelector, &ptr[index], 32 / 8);
-            index += 32 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
-            sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePauseAutonomousScanRequest.Pause = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_REQUEST_ID:
-            sig->u.MlmeGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_REQUEST_ID:
-            sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.PowerManagementMode = (CSR_POWER_MANAGEMENT_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.ReceiveDtims = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.ListenInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmePowermgtRequest.TrafficWindow = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MaPacketErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MaPacketErrorIndication.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketErrorIndication.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
-            sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.MaximumLatency = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode = (CSR_PERIODIC_SCHEDULING_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.WakeHost = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddPeriodicRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_REQUEST_ID:
-            sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.PsScheme = (CSR_PS_SCHEME) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.MediumTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecRequest.ServiceStartTime = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeAddTspecRequest.ServiceInterval = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            sig->u.MlmeAddTspecRequest.MinimumDataRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-            sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddMulticastAddressConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-            sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-            sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeHlSyncCancelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CONFIRM_ID:
-            sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            sig->u.DebugStringIndication.DebugMessage.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugStringIndication.DebugMessage.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugStringIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.DebugStringIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-            sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateConfirm.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeAddTemplateConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
-            sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeBlockackErrorIndication.ResultCode = (CSR_REASON_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CONFIRM_ID:
-            sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeSetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_REQUEST_ID:
-            sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-            sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
-            index += 48 / 8;
-            sig->u.MlmeStartAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStartAggregationConfirm.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-            sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_CONFIRM_ID:
-            sig->u.MaPacketConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.TransmissionStatus = (CSR_TRANSMISSION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.RetryCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.Rate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MaPacketConfirm.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT32;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-            sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeDelPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_REQUEST_ID:
-            sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            sig->u.MlmeStopMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-
-        default:
-            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-    return CSR_RESULT_SUCCESS;
-} /* read_unpack_signal() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  write_pack
- *
- *      Convert a signal structure, in host-native format, to the
- *      little-endian wire format specified in the UniFi Host Interface
- *      Protocol Specification.
- *
- *      WARNING: This function is auto-generated, DO NOT EDIT!
- *
- *  Arguments:
- *      sig             Pointer to signal structure to pack.
- *      ptr             Destination buffer to pack into.
- *      sig_len         Returns the length of the packed signal, i.e. the
- *                      number of bytes written to ptr.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success,
- *      CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
- * ---------------------------------------------------------------------------
- */
-CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len)
-{
-    s16 index = 0;
-
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SignalId, ptr + index);
-    index += SIZEOF_UINT16;
-
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.ReceiverProcessId, ptr + index);
-    index += SIZEOF_UINT16;
-
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SenderProcessId, ptr + index);
-    index += SIZEOF_UINT16;
-
-    switch (sig->SignalPrimitiveHeader.SignalId)
-    {
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.BlackoutId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.BlackoutId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7], ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Direction, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Direction, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[0], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[1], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[2], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[3], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[4], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[5], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[6], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[7], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[8], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[9], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[10], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[11], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[12], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[13], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[14], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[15], ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[0], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[1], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[2], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[3], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[4], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[5], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[6], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[7], ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_MA_PACKET_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MaPacketIndication.LocalTime.x, 64 / 8);
-            index += 64 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Ifindex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Channel, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceptionStatus, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Rssi, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Snr, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceivedRate, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_MLME_SET_TIM_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.AssociationId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.TimValue, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.ConnectionStatus, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeConnectedIndication.PeerMacAddress.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.TriggerId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Status, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.ErrorIndex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.TriggeredId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.Ifindex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ScanType, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ProbeDelay, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MinChannelTime, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MaxChannelTime, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Direction, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.StartingSequenceNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BufferSize, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BlockAckTimeout, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeHlSyncRequest.GroupAddress.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-        case CSR_DEBUG_GENERIC_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[0], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[1], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[2], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[3], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[4], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[5], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[6], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[7], ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.TriggeredId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeResetRequest.StaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.SetDefaultMib, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.TriggeredId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.PacketFilterMode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress, ptr + index);
-            index += SIZEOF_UINT32;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.TriggerId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.ConnectionStatus, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeConnectStatusRequest.StaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.QueueIndex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Aifs, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmin, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmax, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.TxopLimit, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.DialogToken, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.BlackoutId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.TriggeredId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[0], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[1], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[2], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[3], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[4], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[5], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[6], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[7], ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-        case CSR_MA_PACKET_CANCEL_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.HostTag, ptr + index);
-            index += SIZEOF_UINT32;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmitRate, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.HostTag, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Priority, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MaPacketRequest.Ra.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmissionControl, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.BeaconPeriod, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.DtimPeriod, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.CapabilityInformation, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeModifyBssParameterRequest.Bssid.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.RtsThreshold, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.TriggerId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Priority, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Multicast, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.BlackoutId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyType, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeGetKeySequenceRequest.Address.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Ifindex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Channel, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeSetChannelRequest.Address.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityDuration, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityInterval, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.DialogToken, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.TriggeredId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeAutonomousScanLossIndication.Bssid.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-        case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.FrameType, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.MinTransmitRate, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.PeriodicId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Status, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.ErrorIndex, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Status, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.ErrorIndex, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Direction, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.TriggerId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutType, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutSource, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutStartReference, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutPeriod, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutDuration, ptr + index);
-            index += SIZEOF_UINT32;
-            memcpy(ptr + index, sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutCount, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyType, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeDeletekeysRequest.Address.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeHlSyncConfirm.GroupAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.Ifindex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ScanType, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ProbeDelay, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MinChannelTime, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Ifindex, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Channel, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeSmStartRequest.InterfaceAddress.x, 48 / 8);
-            index += 48 / 8;
-            memcpy(ptr + index, sig->u.MlmeSmStartRequest.Bssid.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BeaconPeriod, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.DtimPeriod, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.CapabilityInformation, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.PeriodicId, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Length, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyType, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeSetkeysRequest.Address.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[0], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[1], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[2], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[3], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[4], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[5], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[6], ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[7], ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, &sig->u.MlmeSetkeysRequest.CipherSuiteSelector, 32 / 8);
-            index += 32 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Pause, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.PowerManagementMode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ReceiveDtims, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ListenInterval, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.TrafficWindow, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MaPacketErrorIndication.PeerQstaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.SequenceNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.MaximumLatency, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.WakeHost, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Direction, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.PsScheme, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MediumTime, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceStartTime, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceInterval, ptr + index);
-            index += SIZEOF_UINT32;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MinimumDataRate, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.FrameType, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, 48 / 8);
-            index += 48 / 8;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Status, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.ErrorIndex, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.DialogToken, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            memcpy(ptr + index, sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, 48 / 8);
-            index += 48 / 8;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.UserPriority, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Direction, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.SequenceNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.DialogToken, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-        case CSR_MA_PACKET_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.TransmissionStatus, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.RetryCount, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Rate, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.HostTag, ptr + index);
-            index += SIZEOF_UINT32;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.PeriodicId, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.ResultCode, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_REQUEST_ID:
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength, ptr + index);
-            index += SIZEOF_UINT16;
-            CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.DialogToken, ptr + index);
-            index += SIZEOF_UINT16;
-            break;
-#endif
-
-        default:
-            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    *sig_len = index;
-
-    return CSR_RESULT_SUCCESS;
-} /* write_pack() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_send.c b/drivers/staging/csr/csr_wifi_hip_send.c
deleted file mode 100644 (file)
index 76429e5..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ***************************************************************************
- *
- *  FILE:     csr_wifi_hip_send.c
- *
- *  PURPOSE:
- *      Code for adding a signal request to the from-host queue.
- *      When the driver bottom-half is run, it will take requests from the
- *      queue and pass them to the UniFi.
- *
- * ***************************************************************************
- */
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "csr_wifi_hip_sigs.h"
-#include "csr_wifi_hip_card.h"
-
-unifi_TrafficQueue unifi_frame_priority_to_queue(CSR_PRIORITY priority)
-{
-    switch (priority)
-    {
-        case CSR_QOS_UP0:
-        case CSR_QOS_UP3:
-            return UNIFI_TRAFFIC_Q_BE;
-        case CSR_QOS_UP1:
-        case CSR_QOS_UP2:
-            return UNIFI_TRAFFIC_Q_BK;
-        case CSR_QOS_UP4:
-        case CSR_QOS_UP5:
-            return UNIFI_TRAFFIC_Q_VI;
-        case CSR_QOS_UP6:
-        case CSR_QOS_UP7:
-        case CSR_MANAGEMENT:
-            return UNIFI_TRAFFIC_Q_VO;
-        default:
-            return UNIFI_TRAFFIC_Q_BE;
-    }
-}
-
-
-CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue)
-{
-    switch (queue)
-    {
-        case UNIFI_TRAFFIC_Q_BE:
-            return CSR_QOS_UP0;
-        case UNIFI_TRAFFIC_Q_BK:
-            return CSR_QOS_UP1;
-        case UNIFI_TRAFFIC_Q_VI:
-            return CSR_QOS_UP5;
-        case UNIFI_TRAFFIC_Q_VO:
-            return CSR_QOS_UP6;
-        default:
-            return CSR_QOS_UP0;
-    }
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  send_signal
- *
- *      This function queues a signal for sending to UniFi.  It first checks
- *      that there is space on the fh_signal_queue for another entry, then
- *      claims any bulk data slots required and copies data into them. Then
- *      increments the fh_signal_queue write count.
- *
- *      The fh_signal_queue is later processed by the driver bottom half
- *      (in unifi_bh()).
- *
- *      This function call unifi_pause_xmit() to pause the flow of data plane
- *      packets when:
- *        - the fh_signal_queue ring buffer is full
- *        - there are less than UNIFI_MAX_DATA_REFERENCES (2) bulk data
- *          slots available.
- *
- *  Arguments:
- *      card            Pointer to card context structure
- *      sigptr          Pointer to the signal to write to UniFi.
- *      siglen          Number of bytes pointer to by sigptr.
- *      bulkdata        Array of pointers to an associated bulk data.
- *      sigq            To which from-host queue to add the signal.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success
- *      CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or
- *                              no free signal queue entry
- *
- * Notes:
- *      Calls unifi_pause_xmit() when the last slots are used.
- * ---------------------------------------------------------------------------
- */
-static CsrResult send_signal(card_t *card, const u8 *sigptr, u32 siglen,
-                             const bulk_data_param_t *bulkdata,
-                             q_t *sigq, u32 priority_q, u32 run_bh)
-{
-    u16 i, data_slot_size;
-    card_signal_t *csptr;
-    s16 qe;
-    CsrResult r;
-    s16 debug_print = 0;
-
-    data_slot_size = CardGetDataSlotSize(card);
-
-    /* Check that the fh_data_queue has a free slot */
-    if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sigq))
-    {
-        unifi_trace(card->ospriv, UDBG3, "send_signal: %s full\n", sigq->name);
-
-        return CSR_WIFI_HIP_RESULT_NO_SPACE;
-    }
-
-    /*
-     * Now add the signal to the From Host signal queue
-     */
-    /* Get next slot on queue */
-    qe = CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
-    csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, qe);
-
-    /* Make up the card_signal struct */
-    csptr->signal_length = (u16)siglen;
-    memcpy((void *)csptr->sigbuf, (void *)sigptr, siglen);
-
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
-    {
-        if ((bulkdata != NULL) && (bulkdata->d[i].data_length != 0))
-        {
-            u32 datalen = bulkdata->d[i].data_length;
-
-            /* Make sure data will fit in a bulk data slot */
-            if (bulkdata->d[i].os_data_ptr == NULL)
-            {
-                unifi_error(card->ospriv, "send_signal - NULL bulkdata[%d]\n", i);
-                debug_print++;
-                csptr->bulkdata[i].data_length = 0;
-            }
-            else
-            {
-                if (datalen > data_slot_size)
-                {
-                    unifi_error(card->ospriv,
-                                "send_signal - Invalid data length %u (@%p), "
-                                "truncating\n",
-                                datalen, bulkdata->d[i].os_data_ptr);
-                    datalen = data_slot_size;
-                    debug_print++;
-                }
-                /* Store the bulk data info in the soft queue. */
-                csptr->bulkdata[i].os_data_ptr = (u8 *)bulkdata->d[i].os_data_ptr;
-                csptr->bulkdata[i].os_net_buf_ptr = (u8 *)bulkdata->d[i].os_net_buf_ptr;
-                csptr->bulkdata[i].net_buf_length = bulkdata->d[i].net_buf_length;
-                csptr->bulkdata[i].data_length = datalen;
-            }
-        }
-        else
-        {
-            UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
-        }
-    }
-
-    if (debug_print)
-    {
-        const u8 *sig = sigptr;
-
-               unifi_error(card->ospriv, "Signal(%d): %*ph\n", siglen,
-                                         16, sig);
-        unifi_error(card->ospriv, "Bulkdata pointer %p(%d), %p(%d)\n",
-                    bulkdata != NULL?bulkdata->d[0].os_data_ptr : NULL,
-                    bulkdata != NULL?bulkdata->d[0].data_length : 0,
-                    bulkdata != NULL?bulkdata->d[1].os_data_ptr : NULL,
-                    bulkdata != NULL?bulkdata->d[1].data_length : 0);
-    }
-
-    /* Advance the written count to say there is a new entry */
-    CSR_WIFI_HIP_Q_INC_W(sigq);
-
-    /*
-     * Set the flag to say reason for waking was a host request.
-     * Then ask the OS layer to run the unifi_bh.
-     */
-    if (run_bh == 1)
-    {
-        card->bh_reason_host = 1;
-        r = unifi_run_bh(card->ospriv);
-        if (r != CSR_RESULT_SUCCESS)
-        {
-            unifi_error(card->ospriv, "failed to run bh.\n");
-            card->bh_reason_host = 0;
-
-            /*
-             * The bulk data buffer will be freed by the caller.
-             * We need to invalidate the description of the bulk data in our
-             * soft queue, to prevent the core freeing the bulk data again later.
-             */
-            for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
-            {
-                if (csptr->bulkdata[i].data_length != 0)
-                {
-                    csptr->bulkdata[i].os_data_ptr = csptr->bulkdata[i].os_net_buf_ptr = NULL;
-                    csptr->bulkdata[i].net_buf_length = csptr->bulkdata[i].data_length = 0;
-                }
-            }
-            return r;
-        }
-    }
-    else
-    {
-        unifi_error(card->ospriv, "run_bh=%d, bh not called.\n", run_bh);
-    }
-
-    /*
-     * Have we used up all the fh signal list entries?
-     */
-    if (CSR_WIFI_HIP_Q_SLOTS_FREE(sigq) == 0)
-    {
-        /* We have filled the queue, so stop the upper layer. The command queue
-         * is an exception, as suspending due to that being full could delay
-         * resume/retry until new commands or data are received.
-         */
-        if (sigq != &card->fh_command_queue)
-        {
-            /*
-             * Must call unifi_pause_xmit() *before* setting the paused flag.
-             * (the unifi_pause_xmit call should not be after setting the flag because of the possibility of being interrupted
-             * by the bh thread between our setting the flag and the call to unifi_pause_xmit()
-             * If bh thread then cleared the flag, we would end up paused, but without the flag set)
-             * Instead, setting it afterwards means that if this thread is interrupted by the bh thread
-             * the pause flag is still guaranteed to end up set
-             * However the potential deadlock now is that if bh thread emptied the queue and cleared the flag before this thread's
-             * call to unifi_pause_xmit(), then bh thread may not run again because it will be waiting for
-             * a packet to appear in the queue but nothing ever will because xmit is paused.
-             * So we will end up with the queue paused, and the flag set to say it is paused, but bh never runs to unpause it.
-             * (Note even this bad situation would not persist long in practice, because something else (eg rx, or tx in different queue)
-             * is likely to wake bh thread quite soon)
-             * But to avoid this deadlock completely, after setting the flag we check that there is something left in the queue.
-             * If there is, we know that bh thread has not emptied the queue yet.
-             * Since bh thread checks to unpause the queue *after* taking packets from the queue, we know that it is still going to make at
-             * least one more check to see whether it needs to unpause the queue.  So all is well.
-             * If there are no packets in the queue, then the deadlock described above might happen.  To make sure it does not, we
-             * unpause the queue here. A possible side effect is that unifi_restart_xmit() may (rarely) be called for second time
-             *  unnecessarily, which is harmless
-             */
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-            unifi_debug_log_to_buf("P");
-#endif
-            unifi_pause_xmit(card->ospriv, (unifi_TrafficQueue)priority_q);
-            card_tx_q_pause(card, priority_q);
-            if (CSR_WIFI_HIP_Q_SLOTS_USED(sigq) == 0)
-            {
-                card_tx_q_unpause(card, priority_q);
-                unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue) priority_q);
-            }
-        }
-        else
-        {
-            unifi_warning(card->ospriv,
-                          "send_signal: fh_cmd_q full, not pausing (run_bh=%d)\n",
-                          run_bh);
-        }
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /*  send_signal() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_send_signal
- *
- *    Invokes send_signal() to queue a signal in the command or traffic queue
- *    If sigptr pointer is NULL, it pokes the bh to check if UniFi is responsive.
- *
- *  Arguments:
- *      card        Pointer to card context struct
- *      sigptr      Pointer to signal from card.
- *      siglen      Size of the signal
- *      bulkdata    Pointer to the bulk data of the signal
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success
- *      CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or no free signal queue entry
- *
- *  Notes:
- *      unifi_send_signal() is used to queue signals, created by the driver,
- *      to the device. Signals are constructed using the UniFi packed structures.
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_send_signal(card_t *card, const u8 *sigptr, u32 siglen,
-                            const bulk_data_param_t *bulkdata)
-{
-    q_t *sig_soft_q;
-    u16 signal_id;
-    CsrResult r;
-    u32 run_bh;
-    u32 priority_q;
-
-    /* A NULL signal pointer is a request to check if UniFi is responsive */
-    if (sigptr == NULL)
-    {
-        card->bh_reason_host = 1;
-        return unifi_run_bh(card->ospriv);
-    }
-
-    priority_q = 0;
-    run_bh = 1;
-    signal_id = GET_SIGNAL_ID(sigptr);
-    /*
-     * If the signal is a CSR_MA_PACKET_REQUEST ,
-     * we send it using the traffic soft queue. Else we use the command soft queue.
-     */
-    if (signal_id == CSR_MA_PACKET_REQUEST_ID)
-    {
-        u16 frame_priority;
-
-        if (card->periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_ENABLED)
-        {
-            run_bh = 0;
-        }
-
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
-        unifi_debug_log_to_buf("D");
-#endif
-        /* Sanity check: MA-PACKET.req must have a valid bulk data */
-        if ((bulkdata->d[0].data_length == 0) || (bulkdata->d[0].os_data_ptr == NULL))
-        {
-            unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
-                        bulkdata->d[0].data_length, bulkdata->d[0].os_data_ptr);
-            dump((void *)sigptr, siglen);
-            return CSR_RESULT_FAILURE;
-        }
-
-        /* Map the frame priority to a traffic queue index. */
-        frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr);
-        priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority);
-
-        sig_soft_q = &card->fh_traffic_queue[priority_q];
-    }
-    else
-    {
-        sig_soft_q = &card->fh_command_queue;
-    }
-
-    r = send_signal(card, sigptr, siglen, bulkdata, sig_soft_q, priority_q, run_bh);
-    /* On error, the caller must free or requeue bulkdata buffers */
-
-    return r;
-} /* unifi_send_signal() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_send_resources_available
- *
- *      Examines whether there is available space to queue
- *      a signal in the command or traffic queue
- *
- *  Arguments:
- *      card        Pointer to card context struct
- *      sigptr      Pointer to signal.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS if resources available
- *      CSR_WIFI_HIP_RESULT_NO_SPACE if there was no free signal queue entry
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr)
-{
-    q_t *sig_soft_q;
-    u16 signal_id = GET_SIGNAL_ID(sigptr);
-
-    /*
-     * If the signal is a CSR_MA_PACKET_REQUEST ,
-     * we send it using the traffic soft queue. Else we use the command soft queue.
-     */
-    if (signal_id == CSR_MA_PACKET_REQUEST_ID)
-    {
-        u16 frame_priority;
-        u32 priority_q;
-
-        /* Map the frame priority to a traffic queue index. */
-        frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr);
-        priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority);
-
-        sig_soft_q = &card->fh_traffic_queue[priority_q];
-    }
-    else
-    {
-        sig_soft_q = &card->fh_command_queue;
-    }
-
-    /* Check that the fh_data_queue has a free slot */
-    if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sig_soft_q))
-    {
-        unifi_notice(card->ospriv, "unifi_send_resources_available: %s full\n",
-                     sig_soft_q->name);
-        return CSR_WIFI_HIP_RESULT_NO_SPACE;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_send_resources_available() */
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_signals.c b/drivers/staging/csr/csr_wifi_hip_signals.c
deleted file mode 100644 (file)
index 3c82132..0000000
+++ /dev/null
@@ -1,1313 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-
-/* Generated by hip_dd_l_c_gen.pl */
-
-#include "csr_wifi_hip_signals.h"
-
-#include "csr_wifi_hip_unifi.h"
-
-s32 SigGetSize(const CSR_SIGNAL *aSignal)
-{
-    switch (aSignal->SignalPrimitiveHeader.SignalId)
-    {
-        case CSR_MA_PACKET_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_REQUEST);
-        case CSR_MA_PACKET_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CONFIRM);
-        case CSR_MA_PACKET_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_INDICATION);
-        case CSR_MA_PACKET_CANCEL_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CANCEL_REQUEST);
-        case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_RESPONSE);
-        case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_INDICATION);
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_ERROR_INDICATION);
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECTED_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CANCEL_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_TRIGGERED_GET_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLACKOUT_ENDED_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLOCKACK_ERROR_INDICATION);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_CONFIRM);
-#endif
-        case CSR_MLME_SET_TIM_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_REQUEST);
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_CONFIRM);
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_CONFIRM);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST);
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM);
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_STRING_INDICATION);
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_WORD16_INDICATION);
-        case CSR_DEBUG_GENERIC_REQUEST_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_REQUEST);
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_CONFIRM);
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_INDICATION);
-        default:
-            return 0;
-    }
-}
-
-
-s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef)
-{
-    s32 numRefs = 0;
-
-    switch (aSignal->SignalPrimitiveHeader.SignalId)
-    {
-        case CSR_MA_PACKET_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Data;
-            aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Dummydataref2;
-            break;
-        case CSR_MA_PACKET_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref2;
-            break;
-        case CSR_MA_PACKET_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Data;
-            aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Dummydataref2;
-            break;
-        case CSR_MA_PACKET_CANCEL_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref2;
-            break;
-        case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref2;
-            break;
-        case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref2;
-            break;
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref2;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.MibAttribute;
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.MibAttributeValue;
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.MibAttributeValue;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.MibAttributeValue;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.MibAttribute;
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.MibAttributeValue;
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.ChannelList;
-            aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.InformationElements;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.MeasurementRequestSet;
-            aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.MeasurementReportSet;
-            aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Key;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.ChannelList;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.InformationElements;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.InformationElements;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.MibAttribute;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.MibAttributeValue;
-            aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.InformationElements;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.InformationElements;
-            aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Data;
-            aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.Beacon;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.BssParameters;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref2;
-            break;
-#endif
-        case CSR_MLME_SET_TIM_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref2;
-            break;
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref2;
-            break;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Data;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Dummydataref2;
-            break;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref2;
-            break;
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.DebugMessage;
-            aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.Dummydataref2;
-            break;
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref1;
-            aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref2;
-            break;
-        case CSR_DEBUG_GENERIC_REQUEST_ID:
-            aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.DebugVariable;
-            aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.Dummydataref2;
-            break;
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.DebugVariable;
-            aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.Dummydataref2;
-            break;
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.DebugVariable;
-            aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.Dummydataref2;
-            break;
-        default:
-            return 0;
-    }
-    return numRefs;
-}
-
-
-u32 SigGetFilterPos(u16 aSigID)
-{
-    switch (aSigID)
-    {
-        case CSR_MA_PACKET_REQUEST_ID:
-            return 0x00000001;
-        case CSR_MA_PACKET_CONFIRM_ID:
-            return 0x00000002;
-        case CSR_MA_PACKET_INDICATION_ID:
-            return 0x00000004;
-        case CSR_MA_PACKET_CANCEL_REQUEST_ID:
-            return 0x00000008;
-        case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
-            return 0x00000010;
-        case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
-            return 0x00000020;
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            return 0x00000040;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_REQUEST_ID:
-            return 0x00000080;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_RESET_CONFIRM_ID:
-            return 0x00000100;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_REQUEST_ID:
-            return 0x00000200;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_CONFIRM_ID:
-            return 0x00000400;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_REQUEST_ID:
-            return 0x00000800;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CONFIRM_ID:
-            return 0x00001000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_REQUEST_ID:
-            return 0x00002000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-            return 0x00004000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_REQUEST_ID:
-            return 0x00008000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-            return 0x00010001;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_REQUEST_ID:
-            return 0x00010002;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CONFIRM_ID:
-            return 0x00010004;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_REQUEST_ID:
-            return 0x00010008;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-            return 0x00010010;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_REQUEST_ID:
-            return 0x00010020;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-            return 0x00010040;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MEASURE_INDICATION_ID:
-            return 0x00010080;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_REQUEST_ID:
-            return 0x00010100;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-            return 0x00010200;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_REQUEST_ID:
-            return 0x00010400;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-            return 0x00010800;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
-            return 0x00011000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            return 0x00012000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
-            return 0x00014000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
-            return 0x00018000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-            return 0x00020001;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
-            return 0x00020002;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-            return 0x00020004;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
-            return 0x00020008;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-            return 0x00020010;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
-            return 0x00020020;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-            return 0x00020040;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
-            return 0x00020080;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-            return 0x00020100;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
-            return 0x00020200;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-            return 0x00020400;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_REQUEST_ID:
-            return 0x00020800;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-            return 0x00021000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
-            return 0x00022000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-            return 0x00024000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
-            return 0x00028000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
-            return 0x00030001;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-            return 0x00030002;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
-            return 0x00030004;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-            return 0x00030008;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
-            return 0x00030010;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
-            return 0x00030020;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-            return 0x00030040;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
-            return 0x00030080;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
-            return 0x00030100;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-            return 0x00030200;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
-            return 0x00030400;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-            return 0x00030800;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
-            return 0x00031000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-            return 0x00032000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
-            return 0x00034000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-            return 0x00038000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
-            return 0x00040001;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-            return 0x00040002;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
-            return 0x00040004;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-            return 0x00040008;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
-            return 0x00040010;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-            return 0x00040020;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_REQUEST_ID:
-            return 0x00040040;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-            return 0x00040080;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_REQUEST_ID:
-            return 0x00040100;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-            return 0x00040200;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_REQUEST_ID:
-            return 0x00040400;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-            return 0x00040800;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
-            return 0x00041000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
-            return 0x00042000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-            return 0x00044000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_REQUEST_ID:
-            return 0x00048000;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SM_START_CONFIRM_ID:
-            return 0x00050001;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_REQUEST_ID:
-            return 0x00050002;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-            return 0x00050004;
-#endif
-        case CSR_MLME_SET_TIM_REQUEST_ID:
-            return 0x00050008;
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            return 0x00050010;
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
-            return 0x00050020;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-            return 0x00050040;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_REQUEST_ID:
-            return 0x00050080;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-            return 0x00050100;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
-            return 0x00050200;
-#endif
-#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-            return 0x00050400;
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            return 0x00050800;
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            return 0x00051000;
-        case CSR_DEBUG_GENERIC_REQUEST_ID:
-            return 0x00052000;
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            return 0x00054000;
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            return 0x00058000;
-        default:
-            break;
-    }
-    return 0xffffffff;
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_signals.h b/drivers/staging/csr/csr_wifi_hip_signals.h
deleted file mode 100644 (file)
index ca4d077..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2011
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-/*
- *****************************************************************************
- *
- * FILE: csr_wifi_hip_signals.h
- *
- * PURPOSE:
- *      Header file wrapping the auto-generated code in csr_wifi_hip_sigs.h
- *      and csr_wifi_hip_signals.c -
- *      csr_wifi_hip_sigs.h provides structures defining UniFi signals and
- *      csr_wifi_hip_signals.c provides SigGetSize() and SigGetDataRefs().
- *
- *****************************************************************************
- */
-#ifndef __CSR_WIFI_HIP_SIGNALS_H__
-#define __CSR_WIFI_HIP_SIGNALS_H__
-
-#include <linux/types.h>
-#include "csr_wifi_hip_sigs.h"
-
-
-/****************************************************************************/
-/* INFORMATION ELEMENTS */
-/****************************************************************************/
-
-/* Information Element ID's - shouldn't be in here, but nowhere better yet */
-#define IE_SSID_ID                       0
-#define IE_SUPPORTED_RATES_ID            1
-#define IE_FH_PARAM_SET_ID               2
-#define IE_DS_PARAM_SET_ID               3
-#define IE_CF_PARAM_SET_ID               4
-#define IE_TIM_ID                        5
-#define IE_IBSS_PARAM_SET_ID             6
-#define IE_COUNTRY_ID                    7
-#define IE_HOPPING_PATTERN_PARAMS_ID     8
-#define IE_HOPPING_PATTERN_TABLE_ID      9
-#define IE_REQUEST_ID                    10
-#define IE_QBSS_LOAD_ID                  11
-#define IE_EDCA_PARAM_SET_ID             12
-#define IE_TRAFFIC_SPEC_ID               13
-#define IE_TRAFFIC_CLASS_ID              14
-#define IE_SCHEDULE_ID                   15
-#define IE_CHALLENGE_TEXT_ID             16
-#define IE_POWER_CONSTRAINT_ID           32
-#define IE_POWER_CAPABILITY_ID           33
-#define IE_TPC_REQUEST_ID                34
-#define IE_TPC_REPORT_ID                 35
-#define IE_SUPPORTED_CHANNELS_ID         36
-#define IE_CHANNEL_SWITCH_ANNOUNCE_ID    37
-#define IE_MEASUREMENT_REQUEST_ID        38
-#define IE_MEASUREMENT_REPORT_ID         39
-#define IE_QUIET_ID                      40
-#define IE_IBSS_DFS_ID                   41
-#define IE_ERP_INFO_ID                   42
-#define IE_TS_DELAY_ID                   43
-#define IE_TCLAS_PROCESSING_ID           44
-#define IE_QOS_CAPABILITY_ID             46
-#define IE_RSN_ID                        48
-#define IE_EXTENDED_SUPPORTED_RATES_ID   50
-#define IE_AP_CHANNEL_REPORT_ID          52
-#define IE_RCPI_ID                       53
-#define IE_WPA_ID                       221
-
-
-/* The maximum number of data references in a signal structure */
-#define UNIFI_MAX_DATA_REFERENCES 2
-
-/* The space to allow for a wire-format signal structure */
-#define UNIFI_PACKED_SIGBUF_SIZE   64
-
-
-/******************************************************************************/
-/* SIGNAL PARAMETER VALUES */
-/******************************************************************************/
-
-/* ifIndex */
-#define UNIFI_IF_2G4 1
-#define UNIFI_IF_5G  2
-
-/* SendProcessId */
-#define HOST_PROC_ID 0xc000
-
-#define SIG_CAP_ESS             0x0001
-#define SIG_CAP_IBSS            0x0002
-#define SIG_CAP_CF_POLLABLE     0x0004
-#define SIG_CAP_CF_POLL_REQUEST 0x0008
-#define SIG_CAP_PRIVACY         0x0010
-#define SIG_CAP_SHORT_PREAMBLE  0x0020
-#define SIG_CAP_DSSSOFDM        0x2000
-
-/******************************************************************************/
-/* FUNCTION DECLARATIONS */
-/******************************************************************************/
-
-/******************************************************************************
- * SigGetNumDataRefs - Retrieve pointers to data-refs from a signal.
- *
- * PARAMETERS:
- *   aSignal  - Pointer to signal to retrieve the data refs of.
- *   aDataRef - Address of a pointer to the structure that the data refs
- *              pointers will be stored.
- *
- * RETURNS:
- *   The number of data-refs in the signal.
- */
-s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef);
-
-/******************************************************************************
- * SigGetSize - Retrieve the size (in bytes) of a given signal.
- *
- * PARAMETERS:
- *   aSignal  - Pointer to signal to retrieve size of.
- *
- * RETURNS:
- *   The size (in bytes) of the given signal.
- */
-s32 SigGetSize(const CSR_SIGNAL *aSignal);
-
-#endif /* __CSR_WIFI_HIP_SIGNALS_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_sigs.h b/drivers/staging/csr/csr_wifi_hip_sigs.h
deleted file mode 100644 (file)
index 6112cc3..0000000
+++ /dev/null
@@ -1,1417 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-
-/* Generated by hip_dd_l_h_gen.pl */
-
-#ifndef CSR_WIFI_HIP_SIGS_H
-#define CSR_WIFI_HIP_SIGS_H
-
-typedef s16 csr_place_holding_type;
-
-typedef u16 CSR_ASSOCIATION_ID;
-
-typedef u16 CSR_AUTONOMOUS_SCAN_ID;
-
-typedef u16 CSR_BEACON_PERIODS;
-
-typedef u16 CSR_BLACKOUT_ID;
-
-typedef enum CSR_BLACKOUT_SOURCE
-{
-    CSR_DOT11_LOCAL                               = 0x0000,
-    CSR_DOT11_REMOTE                              = 0x0001,
-    CSR_OTHER_RADIO                               = 0x0002,
-    CSR_NOT_LINKED                                = 0x0004
-} CSR_BLACKOUT_SOURCE;
-
-typedef enum CSR_BLACKOUT_TYPE
-{
-    CSR_LOCAL_DEVICE_ONLY                         = 0x0001,
-    CSR_SPECIFIED_PEER                            = 0x0002,
-    CSR_CURRENT_CHANNEL                           = 0x0004,
-    CSR_P2P                                       = 0x0008
-} CSR_BLACKOUT_TYPE;
-
-typedef enum CSR_BOOT_LOADER_OPERATION
-{
-    CSR_BOOT_LOADER_IDLE                          = 0x00,
-    CSR_BOOT_LOADER_RESTART                       = 0x01,
-    CSR_BOOT_LOADER_PATCH                         = 0x02,
-    CSR_BOOT_LOADER_IMAGE_0                       = 0x10,
-    CSR_BOOT_LOADER_IMAGE_1                       = 0x11,
-    CSR_BOOT_LOADER_IMAGE_2                       = 0x12,
-    CSR_BOOT_LOADER_IMAGE_3                       = 0x13
-} CSR_BOOT_LOADER_OPERATION;
-
-typedef u16 CSR_CAPABILITY_INFORMATION;
-
-typedef u16 CSR_CHANNEL_STARTING_FACTOR;
-
-typedef u32 CSR_CIPHER_SUITE_SELECTOR;
-
-typedef u32 CSR_CLIENT_TAG;
-
-typedef enum CSR_CONNECTION_STATUS
-{
-    CSR_DISCONNECTED                              = 0x0000,
-    CSR_CONNECTED_AWAKE                           = 0x0001
-} CSR_CONNECTION_STATUS;
-
-typedef s16 CSR_DECIBELS;
-
-typedef enum CSR_DIRECTION
-{
-    CSR_TRANSMIT                                  = 0x0000,
-    CSR_RECEIVE                                   = 0x0001,
-    CSR_BIDIRECTIONAL                             = 0x0003
-} CSR_DIRECTION;
-
-typedef enum CSR_FRAME_TYPE
-{
-    CSR_RESERVED                                  = 0x0000,
-    CSR_BEACON                                    = 0x0001,
-    CSR_PROBE_RESPONSE                            = 0x0002,
-    CSR_BEACON_AND_PROBE_RESPONSE                 = 0x0003,
-    CSR_PROBE_REQUEST                             = 0x0004
-} CSR_FRAME_TYPE;
-
-typedef u32 CSR_IPV4_ADDRESS;
-
-typedef enum CSR_IFINTERFACE
-{
-    CSR_INDEX_2G4                                 = 0x0001,
-    CSR_INDEX_5G                                  = 0x0002
-} CSR_IFINTERFACE;
-
-typedef enum CSR_KEY_TYPE
-{
-    CSR_GROUP                                     = 0x0000,
-    CSR_PAIRWISE                                  = 0x0001,
-    CSR_PEER_KEY                                  = 0x0002,
-    CSR_IGTK                                      = 0x0003
-} CSR_KEY_TYPE;
-
-typedef enum CSR_LOADER_OPERATION
-{
-    CSR_LOADER_IDLE                               = 0x0000,
-    CSR_LOADER_COPY                               = 0x0001
-} CSR_LOADER_OPERATION;
-
-typedef struct CSR_MAC_ADDRESS
-{
-    u8 x[6];
-} CSR_MACADDRESS;
-
-typedef enum CSR_MIB_STATUS
-{
-    CSR_MIB_SUCCESSFUL                            = 0x0000,
-    CSR_MIB_INVALID_PARAMETERS                    = 0x0001,
-    CSR_MIB_WRITE_ONLY                            = 0x0002,
-    CSR_MIB_READ_ONLY                             = 0x0003
-} CSR_MIB_STATUS;
-
-typedef enum CSR_MEMORY_SPACE
-{
-    CSR_NONE                                      = 0x00,
-    CSR_SHARED_DATA_MEMORY                        = 0x01,
-    CSR_EXTERNAL_FLASH_MEMORY                     = 0x02,
-    CSR_EXTERNAL_SRAM                             = 0x03,
-    CSR_REGISTERS                                 = 0x04,
-    CSR_PHY_PROCESSOR_DATA_MEMORY                 = 0x10,
-    CSR_PHY_PROCESSOR_PROGRAM_MEMORY              = 0x11,
-    CSR_PHY_PROCESSOR_ROM                         = 0x12,
-    CSR_MAC_PROCESSOR_DATA_MEMORY                 = 0x20,
-    CSR_MAC_PROCESSOR_PROGRAM_MEMORY              = 0x21,
-    CSR_MAC_PROCESSOR_ROM                         = 0x22,
-    CSR_BT_PROCESSOR_DATA_MEMORY                  = 0x30,
-    CSR_BT_PROCESSOR_PROGRAM_MEMORY               = 0x31,
-    CSR_BT_PROCESSOR_ROM                          = 0x32
-} CSR_MEMORY_SPACE;
-
-typedef u16 CSR_MICROSECONDS16;
-
-typedef u32 CSR_MICROSECONDS32;
-
-typedef u16 CSR_NATURAL16;
-
-typedef enum CSR_PS_SCHEME
-{
-    CSR_LEGACY_PS                                 = 0x0001,
-    CSR_U_APSD                                    = 0x0002,
-    CSR_S_APSD                                    = 0x0004
-} CSR_PS_SCHEME;
-
-typedef enum CSR_PACKET_FILTER_MODE
-{
-    CSR_PFM_OPT_OUT                               = 0x0000,
-    CSR_PFM_OPT_IN                                = 0x0003
-} CSR_PACKET_FILTER_MODE;
-
-typedef u16 CSR_PERIODIC_ID;
-
-typedef enum CSR_PERIODIC_SCHEDULING_MODE
-{
-    CSR_PSM_PERIODIC_SCHEDULE_PS_POLL             = 0x0001,
-    CSR_PSM_PERIODIC_SCHEDULE_PM_BIT              = 0x0002,
-    CSR_PSM_PERIODIC_SCHEDULE_UAPSD               = 0x0004,
-    CSR_PSM_PERIODIC_SCHEDULE_SAPSD               = 0x0008
-} CSR_PERIODIC_SCHEDULING_MODE;
-
-typedef enum CSR_POWER_MANAGEMENT_MODE
-{
-    CSR_PMM_ACTIVE_MODE                           = 0x0000,
-    CSR_PMM_POWER_SAVE                            = 0x0001,
-    CSR_PMM_FAST_POWER_SAVE                       = 0x0002
-} CSR_POWER_MANAGEMENT_MODE;
-
-typedef enum CSR_PRIORITY
-{
-    CSR_QOS_UP0                                   = 0x0000,
-    CSR_QOS_UP1                                   = 0x0001,
-    CSR_QOS_UP2                                   = 0x0002,
-    CSR_QOS_UP3                                   = 0x0003,
-    CSR_QOS_UP4                                   = 0x0004,
-    CSR_QOS_UP5                                   = 0x0005,
-    CSR_QOS_UP6                                   = 0x0006,
-    CSR_QOS_UP7                                   = 0x0007,
-    CSR_CONTENTION                                = 0x8000,
-    CSR_MANAGEMENT                                = 0x8010
-} CSR_PRIORITY;
-
-typedef enum CSR_REASON_CODE
-{
-    CSR_UNSPECIFIED_REASON                        = 0x0001,
-    CSR_INVALID_INFORMATION_ELEMENT               = 0x000d,
-    CSR_QOS_UNSPECIFIED_REASON                    = 0x0020,
-    CSR_QOS_EXCESSIVE_NOT_ACK                     = 0x0022,
-    CSR_QOS_TXOP_LIMIT_EXCEEDED                   = 0x0023,
-    CSR_QSTA_LEAVING                              = 0x0024,
-    CSR_UNKNOWN_BA                                = 0x0026,
-    CSR_UNKNOWN_TS                                = 0x0026,
-    CSR_TIMEOUT                                   = 0x0027
-} CSR_REASON_CODE;
-
-typedef enum CSR_RECEPTION_STATUS
-{
-    CSR_RX_SUCCESS                                = 0x0000,
-    CSR_RX_FAILURE_UNSPECIFIED                    = 0x0001,
-    CSR_MICHAEL_MIC_ERROR                         = 0x0002,
-    CSR_DECRYPTION_ERROR                          = 0x0003,
-    CSR_NO_TEMPORAL_KEY_AVAILABLE                 = 0x0004,
-    CSR_UNSUPPORTED_MODULATION                    = 0x0011,
-    CSR_BAD_FCS                                   = 0x0012,
-    CSR_BAD_SIGNAL                                = 0x0013
-} CSR_RECEPTION_STATUS;
-
-typedef enum CSR_RESULT_CODE
-{
-    CSR_RC_SUCCESS                                = 0x0000,
-    CSR_RC_UNSPECIFIED_FAILURE                    = 0x0001,
-    CSR_RC_REFUSED                                = 0x0003,
-    CSR_RC_INVALID_PARAMETERS                     = 0x0026,
-    CSR_RC_REJECTED_INVALID_IE                    = 0x0028,
-    CSR_RC_REJECTED_INVALID_GROUP_CIPHER          = 0x0029,
-    CSR_RC_REJECTED_INVALID_PAIRWISE_CIPHER       = 0x002a,
-    CSR_RC_TIMEOUT                                = 0x8000,
-    CSR_RC_TOO_MANY_SIMULTANEOUS_REQUESTS         = 0x8001,
-    CSR_RC_BSS_ALREADY_STARTED_OR_JOINED          = 0x8002,
-    CSR_RC_NOT_SUPPORTED                          = 0x8003,
-    CSR_RC_TRANSMISSION_FAILURE                   = 0x8004,
-    CSR_RC_RESET_REQUIRED_BEFORE_START            = 0x8006,
-    CSR_RC_INSUFFICIENT_RESOURCE                  = 0x8007,
-    CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES = 0x8008,
-    CSR_RC_INVALID_UNICAST_CIPHER                 = 0xf02f,
-    CSR_RC_INVALID_MULTICAST_CIPHER               = 0xf030
-} CSR_RESULT_CODE;
-
-typedef enum CSR_SCAN_TYPE
-{
-    CSR_SC_ACTIVE_SCAN                            = 0x0000,
-    CSR_SC_PASSIVE_SCAN                           = 0x0001
-} CSR_SCAN_TYPE;
-
-typedef enum CSR_SIGNAL_ID
-{
-    CSR_MA_PACKET_REQUEST_ID                      = 0x0110,
-    CSR_MA_PACKET_CONFIRM_ID                      = 0x0111,
-    CSR_MA_PACKET_INDICATION_ID                   = 0x0113,
-    CSR_MA_PACKET_CANCEL_REQUEST_ID               = 0x0114,
-    CSR_MA_VIF_AVAILABILITY_RESPONSE_ID           = 0x0116,
-    CSR_MA_VIF_AVAILABILITY_INDICATION_ID         = 0x0117,
-    CSR_MA_PACKET_ERROR_INDICATION_ID             = 0x011b,
-    CSR_MLME_RESET_REQUEST_ID                     = 0x0200,
-    CSR_MLME_RESET_CONFIRM_ID                     = 0x0201,
-    CSR_MLME_GET_REQUEST_ID                       = 0x0204,
-    CSR_MLME_GET_CONFIRM_ID                       = 0x0205,
-    CSR_MLME_SET_REQUEST_ID                       = 0x0208,
-    CSR_MLME_SET_CONFIRM_ID                       = 0x0209,
-    CSR_MLME_GET_NEXT_REQUEST_ID                  = 0x020c,
-    CSR_MLME_GET_NEXT_CONFIRM_ID                  = 0x020d,
-    CSR_MLME_POWERMGT_REQUEST_ID                  = 0x0210,
-    CSR_MLME_POWERMGT_CONFIRM_ID                  = 0x0211,
-    CSR_MLME_SCAN_REQUEST_ID                      = 0x0214,
-    CSR_MLME_SCAN_CONFIRM_ID                      = 0x0215,
-    CSR_MLME_HL_SYNC_REQUEST_ID                   = 0x0244,
-    CSR_MLME_HL_SYNC_CONFIRM_ID                   = 0x0245,
-    CSR_MLME_MEASURE_REQUEST_ID                   = 0x0258,
-    CSR_MLME_MEASURE_CONFIRM_ID                   = 0x0259,
-    CSR_MLME_MEASURE_INDICATION_ID                = 0x025b,
-    CSR_MLME_SETKEYS_REQUEST_ID                   = 0x0268,
-    CSR_MLME_SETKEYS_CONFIRM_ID                   = 0x0269,
-    CSR_MLME_DELETEKEYS_REQUEST_ID                = 0x026c,
-    CSR_MLME_DELETEKEYS_CONFIRM_ID                = 0x026d,
-    CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID   = 0x0287,
-    CSR_MLME_CONNECTED_INDICATION_ID              = 0x028b,
-    CSR_MLME_SCAN_CANCEL_REQUEST_ID               = 0x028c,
-    CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID            = 0x0298,
-    CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID            = 0x0299,
-    CSR_MLME_ADD_PERIODIC_REQUEST_ID              = 0x02a0,
-    CSR_MLME_ADD_PERIODIC_CONFIRM_ID              = 0x02a1,
-    CSR_MLME_DEL_PERIODIC_REQUEST_ID              = 0x02a4,
-    CSR_MLME_DEL_PERIODIC_CONFIRM_ID              = 0x02a5,
-    CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID       = 0x02a8,
-    CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID       = 0x02a9,
-    CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID       = 0x02ac,
-    CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID       = 0x02ad,
-    CSR_MLME_SET_PACKET_FILTER_REQUEST_ID         = 0x02b8,
-    CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID         = 0x02b9,
-    CSR_MLME_STOP_MEASURE_REQUEST_ID              = 0x02bc,
-    CSR_MLME_STOP_MEASURE_CONFIRM_ID              = 0x02bd,
-    CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID     = 0x02cc,
-    CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID     = 0x02cd,
-    CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID   = 0x02db,
-    CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID         = 0x02dc,
-    CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID         = 0x02dd,
-    CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID         = 0x02e0,
-    CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID         = 0x02e1,
-    CSR_MLME_TRIGGERED_GET_INDICATION_ID          = 0x02e7,
-    CSR_MLME_ADD_BLACKOUT_REQUEST_ID              = 0x02f8,
-    CSR_MLME_ADD_BLACKOUT_CONFIRM_ID              = 0x02f9,
-    CSR_MLME_BLACKOUT_ENDED_INDICATION_ID         = 0x02fb,
-    CSR_MLME_DEL_BLACKOUT_REQUEST_ID              = 0x02fc,
-    CSR_MLME_DEL_BLACKOUT_CONFIRM_ID              = 0x02fd,
-    CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID            = 0x0304,
-    CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID            = 0x0305,
-    CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID            = 0x0308,
-    CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID            = 0x0309,
-    CSR_MLME_CONNECT_STATUS_REQUEST_ID            = 0x0310,
-    CSR_MLME_CONNECT_STATUS_CONFIRM_ID            = 0x0311,
-    CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID      = 0x0314,
-    CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID      = 0x0315,
-    CSR_MLME_ADD_TEMPLATE_REQUEST_ID              = 0x0318,
-    CSR_MLME_ADD_TEMPLATE_CONFIRM_ID              = 0x0319,
-    CSR_MLME_CONFIG_QUEUE_REQUEST_ID              = 0x031c,
-    CSR_MLME_CONFIG_QUEUE_CONFIRM_ID              = 0x031d,
-    CSR_MLME_ADD_TSPEC_REQUEST_ID                 = 0x0320,
-    CSR_MLME_ADD_TSPEC_CONFIRM_ID                 = 0x0321,
-    CSR_MLME_DEL_TSPEC_REQUEST_ID                 = 0x0324,
-    CSR_MLME_DEL_TSPEC_CONFIRM_ID                 = 0x0325,
-    CSR_MLME_START_AGGREGATION_REQUEST_ID         = 0x0328,
-    CSR_MLME_START_AGGREGATION_CONFIRM_ID         = 0x0329,
-    CSR_MLME_BLOCKACK_ERROR_INDICATION_ID         = 0x032b,
-    CSR_MLME_STOP_AGGREGATION_REQUEST_ID          = 0x032c,
-    CSR_MLME_STOP_AGGREGATION_CONFIRM_ID          = 0x032d,
-    CSR_MLME_SM_START_REQUEST_ID                  = 0x0334,
-    CSR_MLME_SM_START_CONFIRM_ID                  = 0x0335,
-    CSR_MLME_LEAVE_REQUEST_ID                     = 0x0338,
-    CSR_MLME_LEAVE_CONFIRM_ID                     = 0x0339,
-    CSR_MLME_SET_TIM_REQUEST_ID                   = 0x033c,
-    CSR_MLME_SET_TIM_CONFIRM_ID                   = 0x033d,
-    CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID          = 0x0340,
-    CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID          = 0x0341,
-    CSR_MLME_SET_CHANNEL_REQUEST_ID               = 0x034c,
-    CSR_MLME_SET_CHANNEL_CONFIRM_ID               = 0x034d,
-    CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID     = 0x040c,
-    CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID     = 0x040d,
-    CSR_DEBUG_STRING_INDICATION_ID                = 0x0803,
-    CSR_DEBUG_WORD16_INDICATION_ID                = 0x0807,
-    CSR_DEBUG_GENERIC_REQUEST_ID                  = 0x0808,
-    CSR_DEBUG_GENERIC_CONFIRM_ID                  = 0x0809,
-    CSR_DEBUG_GENERIC_INDICATION_ID               = 0x080b
-} CSR_SIGNAL_ID;
-
-typedef u16 CSR_SIMPLE_POINTER;
-
-typedef u16 CSR_STARTING_SEQUENCE_NUMBER;
-
-typedef enum CSR_SYMBOL_ID
-{
-    CSR_SLT_END                                   = 0x0000,
-    CSR_SLT_PCI_SLOT_CONFIG                       = 0x0001,
-    CSR_SLT_SDIO_SLOT_CONFIG                      = 0x0002,
-    CSR_SLT_BUILD_ID_NUMBER                       = 0x0003,
-    CSR_SLT_BUILD_ID_STRING                       = 0x0004,
-    CSR_SLT_PERSISTENT_STORE_DB                   = 0x0005,
-    CSR_SLT_RESET_VECTOR_PHY                      = 0x0006,
-    CSR_SLT_RESET_VECTOR_MAC                      = 0x0007,
-    CSR_SLT_SDIO_LOADER_CONTROL                   = 0x0008,
-    CSR_SLT_TEST_CMD                              = 0x0009,
-    CSR_SLT_TEST_ALIVE_COUNTER                    = 0x000a,
-    CSR_SLT_TEST_PARAMETERS                       = 0x000b,
-    CSR_SLT_TEST_RESULTS                          = 0x000c,
-    CSR_SLT_TEST_VERSION                          = 0x000d,
-    CSR_SLT_MIB_PSID_RANGES                       = 0x000e,
-    CSR_SLT_KIP_TABLE                             = 0x000f,
-    CSR_SLT_PANIC_DATA_PHY                        = 0x0010,
-    CSR_SLT_PANIC_DATA_MAC                        = 0x0011,
-    CSR_SLT_BOOT_LOADER_CONTROL                   = 0x0012,
-    CSR_SLT_SOFT_MAC                              = 0x0013
-} CSR_SYMBOL_ID;
-
-typedef struct CSR_TSF_TIME
-{
-    u8 x[8];
-} CSR_TSF_TIME;
-
-typedef u16 CSR_TIME_UNITS;
-
-typedef enum CSR_TRANSMISSION_CONTROL
-{
-    CSR_TRIGGERED                                 = 0x0001,
-    CSR_END_OF_SERVICE                            = 0x0002,
-    CSR_NO_CONFIRM_REQUIRED                       = 0x0004,
-    CSR_ALLOW_BA                                  = 0x0008
-} CSR_TRANSMISSION_CONTROL;
-
-typedef enum CSR_TRANSMISSION_STATUS
-{
-    CSR_TX_SUCCESSFUL                             = 0x0000,
-    CSR_TX_RETRY_LIMIT                            = 0x0001,
-    CSR_TX_LIFETIME                               = 0x0002,
-    CSR_TX_NO_BSS                                 = 0x0003,
-    CSR_TX_EXCESSIVE_DATA_LENGTH                  = 0x0004,
-    CSR_TX_UNSUPPORTED_PRIORITY                   = 0x0006,
-    CSR_TX_UNAVAILABLE_PRIORITY                   = 0x0007,
-    CSR_TX_UNAVAILABLE_KEY_MAPPING                = 0x000a,
-    CSR_TX_EDCA_TIMEOUT                           = 0x000b,
-    CSR_TX_BLOCK_ACK_TIMEOUT                      = 0x000c,
-    CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED      = 0x000d,
-    CSR_TX_REJECTED_PEER_STATION_SLEEPING         = 0x000e,
-    CSR_TX_REJECTED_DTIM_ENDED                    = 0x000f,
-    CSR_TX_REJECTED_DTIM_STARTED                  = 0x0010
-} CSR_TRANSMISSION_STATUS;
-
-typedef u16 CSR_TRIGGER_ID;
-
-typedef u16 CSR_TRIGGERED_ID;
-
-typedef enum CSR_HIP_VERSIONS
-{
-    CSR_HIP_ENG_VERSION                           = 0x0001,
-    CSR_HIP_VERSION                               = 0x0900
-} CSR_HIP_VERSIONS;
-
-typedef u16 CSR_BUFFER_HANDLE;
-
-typedef u16 CSR_CHANNEL_NUMBER;
-
-typedef struct CSR_DATA_REFERENCE
-{
-    u16 SlotNumber;
-    u16 DataLength;
-} CSR_DATAREF;
-
-typedef u16 CSR_DIALOG_TOKEN;
-
-typedef struct CSR_GENERIC_POINTER
-{
-    u32        MemoryOffset;
-    CSR_MEMORY_SPACE MemorySpace;
-} CSR_GENERIC_POINTER;
-
-typedef struct CSR_MLME_CONFIG_QUEUE_CONFIRM
-{
-    CSR_DATAREF     Dummydataref1;
-    CSR_DATAREF     Dummydataref2;
-    CSR_RESULT_CODE ResultCode;
-} CSR_MLME_CONFIG_QUEUE_CONFIRM;
-
-typedef struct CSR_MLME_CONFIG_QUEUE_REQUEST
-{
-    CSR_DATAREF   Dummydataref1;
-    CSR_DATAREF   Dummydataref2;
-    CSR_NATURAL16 QueueIndex;
-    CSR_NATURAL16 Aifs;
-    CSR_NATURAL16 Cwmin;
-    CSR_NATURAL16 Cwmax;
-    CSR_NATURAL16 TxopLimit;
-} CSR_MLME_CONFIG_QUEUE_REQUEST;
-
-typedef struct CSR_MLME_GET_CONFIRM
-{
-    CSR_DATAREF    MibAttributeValue;
-    CSR_DATAREF    Dummydataref2;
-    CSR_MIB_STATUS Status;
-    CSR_NATURAL16  ErrorIndex;
-} CSR_MLME_GET_CONFIRM;
-
-typedef struct CSR_MLME_GET_REQUEST
-{
-    CSR_DATAREF MibAttribute;
-    CSR_DATAREF Dummydataref2;
-} CSR_MLME_GET_REQUEST;
-
-typedef struct CSR_MLME_GET_NEXT_CONFIRM
-{
-    CSR_DATAREF    MibAttributeValue;
-    CSR_DATAREF    Dummydataref2;
-    CSR_MIB_STATUS Status;
-    CSR_NATURAL16  ErrorIndex;
-} CSR_MLME_GET_NEXT_CONFIRM;
-
-typedef struct CSR_MLME_GET_NEXT_REQUEST
-{
-    CSR_DATAREF MibAttribute;
-    CSR_DATAREF Dummydataref2;
-} CSR_MLME_GET_NEXT_REQUEST;
-
-typedef struct CSR_MLME_HL_SYNC_CONFIRM
-{
-    CSR_DATAREF     Dummydataref1;
-    CSR_DATAREF     Dummydataref2;
-    CSR_MACADDRESS  GroupAddress;
-    CSR_RESULT_CODE ResultCode;
-} CSR_MLME_HL_SYNC_CONFIRM;
-
-typedef struct CSR_MLME_HL_SYNC_REQUEST
-{
-    CSR_DATAREF    Dummydataref1;
-    CSR_DATAREF    Dummydataref2;
-    CSR_MACADDRESS GroupAddress;
-} CSR_MLME_HL_SYNC_REQUEST;
-
-typedef struct CSR_MLME_HL_SYNC_CANCEL_CONFIRM
-{
-    CSR_DATAREF     Dummydataref1;
-    CSR_DATAREF     Dummydataref2;
-    CSR_RESULT_CODE ResultCode;
-} CSR_MLME_HL_SYNC_CANCEL_CONFIRM;
-
-typedef struct CSR_MLME_HL_SYNC_CANCEL_REQUEST
-{
-    CSR_DATAREF    Dummydataref1;
-    CSR_DATAREF    Dummydataref2;
-    CSR_MACADDRESS GroupAddress;
-} CSR_MLME_HL_SYNC_CANCEL_REQUEST;
-
-typedef struct CSR_MLME_MEASURE_CONFIRM
-{
-    CSR_DATAREF      Dummydataref1;
-    CSR_DATAREF      Dummydataref2;
-    CSR_RESULT_CODE  ResultCode;
-    CSR_DIALOG_TOKEN DialogToken;
-} CSR_MLME_MEASURE_CONFIRM;
-
-typedef struct CSR_MLME_MEASURE_INDICATION
-{
-    CSR_DATAREF      MeasurementReportSet;
-    CSR_DATAREF      Dummydataref2;
-    CSR_DIALOG_TOKEN DialogToken;
-} CSR_MLME_MEASURE_INDICATION;
-
-typedef struct CSR_MLME_MEASURE_REQUEST
-{
-    CSR_DATAREF      MeasurementRequestSet;
-    CSR_DATAREF      Dummydataref2;
-    CSR_DIALOG_TOKEN DialogToken;
-} CSR_MLME_MEASURE_REQUEST;
-
-typedef struct CSR_MLME_RESET_CONFIRM
-{
-    CSR_DATAREF     Dummydataref1;
-    CSR_DATAREF     Dummydataref2;
-    CSR_RESULT_CODE ResultCode;
-} CSR_MLME_RESET_CONFIRM;
-
-typedef struct CSR_MLME_RESET_REQUEST
-{
-    CSR_DATAREF    Dummydataref1;
-    CSR_DATAREF    Dummydataref2;
-    CSR_MACADDRESS StaAddress;
-    s16       SetDefaultMib;
-} CSR_MLME_RESET_REQUEST;
-
-typedef struct CSR_MLME_SET_CONFIRM
-{
-    CSR_DATAREF    MibAttributeValue;
-    CSR_DATAREF    Dummydataref2;
-    CSR_MIB_STATUS Status;
-    CSR_NATURAL16  ErrorIndex;
-} CSR_MLME_SET_CONFIRM;
-
-typedef struct CSR_MLME_SET_REQUEST
-{
-    CSR_DATAREF MibAttributeValue;
-    CSR_DATAREF Dummydataref2;
-} CSR_MLME_SET_REQUEST;
-
-typedef struct CSR_MLME_STOP_MEASURE_CONFIRM
-{
-    CSR_DATAREF      Dummydataref1;
-    CSR_DATAREF      Dummydataref2;
-    CSR_RESULT_CODE  ResultCode;
-    CSR_DIALOG_TOKEN DialogToken;
-} CSR_MLME_STOP_MEASURE_CONFIRM;
-
-typedef struct CSR_MLME_STOP_MEASURE_REQUEST
-{
-    CSR_DATAREF      Dummydataref1;
-    CSR_DATAREF      Dummydataref2;
-    CSR_DIALOG_TOKEN DialogToken;
-} CSR_MLME_STOP_MEASURE_REQUEST;
-
-typedef u16 CSR_PROCESS_ID;
-
-typedef u16 CSR_RATE;
-
-typedef u16 CSR_SEQUENCE_NUMBER;
-
-typedef struct CSR_SIGNAL_PRIMITIVE_HEADER
-{
-    s16       SignalId;
-    CSR_PROCESS_ID ReceiverProcessId;
-    CSR_PROCESS_ID SenderProcessId;
-} CSR_SIGNAL_PRIMITIVE_HEADER;
-
-typedef u16 CSR_TRAFFIC_WINDOW;
-
-typedef u16 CSR_VIF_IDENTIFIER;
-
-typedef struct CSR_DEBUG_GENERIC_CONFIRM
-{
-    CSR_DATAREF   DebugVariable;
-    CSR_DATAREF   Dummydataref2;
-    CSR_NATURAL16 DebugWords[8];
-} CSR_DEBUG_GENERIC_CONFIRM;
-
-typedef struct CSR_DEBUG_GENERIC_INDICATION
-{
-    CSR_DATAREF   DebugVariable;
-    CSR_DATAREF   Dummydataref2;
-    CSR_NATURAL16 DebugWords[8];
-} CSR_DEBUG_GENERIC_INDICATION;
-
-typedef struct CSR_DEBUG_GENERIC_REQUEST
-{
-    CSR_DATAREF   DebugVariable;
-    CSR_DATAREF   Dummydataref2;
-    CSR_NATURAL16 DebugWords[8];
-} CSR_DEBUG_GENERIC_REQUEST;
-
-typedef struct CSR_DEBUG_STRING_INDICATION
-{
-    CSR_DATAREF DebugMessage;
-    CSR_DATAREF Dummydataref2;
-} CSR_DEBUG_STRING_INDICATION;
-
-typedef struct CSR_DEBUG_WORD16_INDICATION
-{
-    CSR_DATAREF   Dummydataref1;
-    CSR_DATAREF   Dummydataref2;
-    CSR_NATURAL16 DebugWords[16];
-} CSR_DEBUG_WORD16_INDICATION;
-
-typedef struct CSR_MA_PACKET_CONFIRM
-{
-    CSR_DATAREF             Dummydataref1;
-    CSR_DATAREF             Dummydataref2;
-    CSR_VIF_IDENTIFIER      VirtualInterfaceIdentifier;
-    CSR_TRANSMISSION_STATUS TransmissionStatus;
-    CSR_NATURAL16           RetryCount;
-    CSR_RATE                Rate;
-    CSR_CLIENT_TAG          HostTag;
-} CSR_MA_PACKET_CONFIRM;
-
-typedef struct CSR_MA_PACKET_INDICATION
-{
-    CSR_DATAREF          Data;
-    CSR_DATAREF          Dummydataref2;
-    CSR_VIF_IDENTIFIER   VirtualInterfaceIdentifier;
-    CSR_TSF_TIME         LocalTime;
-    CSR_IFINTERFACE      Ifindex;
-    CSR_CHANNEL_NUMBER   Channel;
-    CSR_RECEPTION_STATUS ReceptionStatus;
-    CSR_DECIBELS         Rssi;
-    CSR_DECIBELS         Snr;
-    CSR_RATE             ReceivedRate;
-} CSR_MA_PACKET_INDICATION;
-
-typedef struct CSR_MA_PACKET_REQUEST
-{
-    CSR_DATAREF              Data;
-    CSR_DATAREF              Dummydataref2;
-    CSR_VIF_IDENTIFIER       VirtualInterfaceIdentifier;
-    CSR_RATE                 TransmitRate;
-    CSR_CLIENT_TAG           HostTag;
-    CSR_PRIORITY             Priority;
-    CSR_MACADDRESS           Ra;
-    CSR_TRANSMISSION_CONTROL TransmissionControl;
-} CSR_MA_PACKET_REQUEST;
-
-typedef struct CSR_MA_PACKET_CANCEL_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_CLIENT_TAG     HostTag;
-} CSR_MA_PACKET_CANCEL_REQUEST;
-
-typedef struct CSR_MA_PACKET_ERROR_INDICATION
-{
-    CSR_DATAREF         Dummydataref1;
-    CSR_DATAREF         Dummydataref2;
-    CSR_VIF_IDENTIFIER  VirtualInterfaceIdentifier;
-    CSR_MACADDRESS      PeerQstaAddress;
-    CSR_PRIORITY        UserPriority;
-    CSR_SEQUENCE_NUMBER SequenceNumber;
-} CSR_MA_PACKET_ERROR_INDICATION;
-
-typedef struct CSR_MA_VIF_AVAILABILITY_INDICATION
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    s16           Multicast;
-} CSR_MA_VIF_AVAILABILITY_INDICATION;
-
-typedef struct CSR_MA_VIF_AVAILABILITY_RESPONSE
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MA_VIF_AVAILABILITY_RESPONSE;
-
-typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM
-{
-    CSR_DATAREF            Dummydataref1;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE        ResultCode;
-    CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
-} CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM;
-
-typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST
-{
-    CSR_DATAREF                 ChannelList;
-    CSR_DATAREF                 InformationElements;
-    CSR_VIF_IDENTIFIER          VirtualInterfaceIdentifier;
-    CSR_AUTONOMOUS_SCAN_ID      AutonomousScanId;
-    CSR_IFINTERFACE             Ifindex;
-    CSR_CHANNEL_STARTING_FACTOR ChannelStartingFactor;
-    CSR_SCAN_TYPE               ScanType;
-    CSR_MICROSECONDS32          ProbeDelay;
-    CSR_TIME_UNITS              MinChannelTime;
-    CSR_TIME_UNITS              MaxChannelTime;
-} CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST;
-
-typedef struct CSR_MLME_ADD_BLACKOUT_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_BLACKOUT_ID    BlackoutId;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_ADD_BLACKOUT_CONFIRM;
-
-typedef struct CSR_MLME_ADD_BLACKOUT_REQUEST
-{
-    CSR_DATAREF         Dummydataref1;
-    CSR_DATAREF         Dummydataref2;
-    CSR_VIF_IDENTIFIER  VirtualInterfaceIdentifier;
-    CSR_BLACKOUT_ID     BlackoutId;
-    CSR_BLACKOUT_TYPE   BlackoutType;
-    CSR_BLACKOUT_SOURCE BlackoutSource;
-    CSR_MICROSECONDS32  BlackoutStartReference;
-    CSR_MICROSECONDS32  BlackoutPeriod;
-    CSR_MICROSECONDS32  BlackoutDuration;
-    CSR_MACADDRESS      PeerStaAddress;
-    CSR_NATURAL16       BlackoutCount;
-} CSR_MLME_ADD_BLACKOUT_REQUEST;
-
-typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM;
-
-typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST
-{
-    CSR_DATAREF        Data;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_NATURAL16      NumberOfMulticastGroupAddresses;
-} CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST;
-
-typedef struct CSR_MLME_ADD_PERIODIC_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PERIODIC_ID    PeriodicId;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_ADD_PERIODIC_CONFIRM;
-
-typedef struct CSR_MLME_ADD_PERIODIC_REQUEST
-{
-    CSR_DATAREF                  Dummydataref1;
-    CSR_DATAREF                  Dummydataref2;
-    CSR_VIF_IDENTIFIER           VirtualInterfaceIdentifier;
-    CSR_PERIODIC_ID              PeriodicId;
-    CSR_MICROSECONDS32           MaximumLatency;
-    CSR_PERIODIC_SCHEDULING_MODE PeriodicSchedulingMode;
-    s16                     WakeHost;
-    CSR_PRIORITY                 UserPriority;
-} CSR_MLME_ADD_PERIODIC_REQUEST;
-
-typedef struct CSR_MLME_ADD_RX_TRIGGER_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_TRIGGER_ID     TriggerId;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_ADD_RX_TRIGGER_CONFIRM;
-
-typedef struct CSR_MLME_ADD_RX_TRIGGER_REQUEST
-{
-    CSR_DATAREF        InformationElements;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_TRIGGER_ID     TriggerId;
-    CSR_PRIORITY       Priority;
-} CSR_MLME_ADD_RX_TRIGGER_REQUEST;
-
-typedef struct CSR_MLME_ADD_TEMPLATE_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_FRAME_TYPE     FrameType;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_ADD_TEMPLATE_CONFIRM;
-
-typedef struct CSR_MLME_ADD_TEMPLATE_REQUEST
-{
-    CSR_DATAREF        Data1;
-    CSR_DATAREF        Data2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_FRAME_TYPE     FrameType;
-    CSR_RATE           MinTransmitRate;
-} CSR_MLME_ADD_TEMPLATE_REQUEST;
-
-typedef struct CSR_MLME_ADD_TRIGGERED_GET_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-    CSR_TRIGGERED_ID   TriggeredId;
-} CSR_MLME_ADD_TRIGGERED_GET_CONFIRM;
-
-typedef struct CSR_MLME_ADD_TRIGGERED_GET_REQUEST
-{
-    CSR_DATAREF        MibAttribute;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_TRIGGERED_ID   TriggeredId;
-} CSR_MLME_ADD_TRIGGERED_GET_REQUEST;
-
-typedef struct CSR_MLME_ADD_TSPEC_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PRIORITY       UserPriority;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_ADD_TSPEC_CONFIRM;
-
-typedef struct CSR_MLME_ADD_TSPEC_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PRIORITY       UserPriority;
-    CSR_DIRECTION      Direction;
-    CSR_PS_SCHEME      PsScheme;
-    CSR_NATURAL16      MediumTime;
-    CSR_MICROSECONDS32 ServiceStartTime;
-    CSR_MICROSECONDS32 ServiceInterval;
-    CSR_RATE           MinimumDataRate;
-} CSR_MLME_ADD_TSPEC_REQUEST;
-
-typedef struct CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION
-{
-    CSR_DATAREF            Dummydataref1;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE        ResultCode;
-    CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
-} CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION;
-
-typedef struct CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_MACADDRESS     Bssid;
-} CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION;
-
-typedef struct CSR_MLME_BLACKOUT_ENDED_INDICATION
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_BLACKOUT_ID    BlackoutId;
-} CSR_MLME_BLACKOUT_ENDED_INDICATION;
-
-typedef struct CSR_MLME_BLOCKACK_ERROR_INDICATION
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_REASON_CODE    ResultCode;
-    CSR_MACADDRESS     PeerQstaAddress;
-} CSR_MLME_BLOCKACK_ERROR_INDICATION;
-
-typedef struct CSR_MLME_CONNECTED_INDICATION
-{
-    CSR_DATAREF           Dummydataref1;
-    CSR_DATAREF           Dummydataref2;
-    CSR_VIF_IDENTIFIER    VirtualInterfaceIdentifier;
-    CSR_CONNECTION_STATUS ConnectionStatus;
-    CSR_MACADDRESS        PeerMacAddress;
-} CSR_MLME_CONNECTED_INDICATION;
-
-typedef struct CSR_MLME_CONNECT_STATUS_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_CONNECT_STATUS_CONFIRM;
-
-typedef struct CSR_MLME_CONNECT_STATUS_REQUEST
-{
-    CSR_DATAREF                InformationElements;
-    CSR_DATAREF                Dummydataref2;
-    CSR_VIF_IDENTIFIER         VirtualInterfaceIdentifier;
-    CSR_CONNECTION_STATUS      ConnectionStatus;
-    CSR_MACADDRESS             StaAddress;
-    CSR_ASSOCIATION_ID         AssociationId;
-    CSR_CAPABILITY_INFORMATION AssociationCapabilityInformation;
-} CSR_MLME_CONNECT_STATUS_REQUEST;
-
-typedef struct CSR_MLME_DELETEKEYS_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_DELETEKEYS_CONFIRM;
-
-typedef struct CSR_MLME_DELETEKEYS_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_NATURAL16      KeyId;
-    CSR_KEY_TYPE       KeyType;
-    CSR_MACADDRESS     Address;
-} CSR_MLME_DELETEKEYS_REQUEST;
-
-typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM
-{
-    CSR_DATAREF            Dummydataref1;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE        ResultCode;
-    CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
-} CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM;
-
-typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST
-{
-    CSR_DATAREF            Dummydataref1;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
-} CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST;
-
-typedef struct CSR_MLME_DEL_BLACKOUT_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_BLACKOUT_ID    BlackoutId;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_DEL_BLACKOUT_CONFIRM;
-
-typedef struct CSR_MLME_DEL_BLACKOUT_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_BLACKOUT_ID    BlackoutId;
-} CSR_MLME_DEL_BLACKOUT_REQUEST;
-
-typedef struct CSR_MLME_DEL_PERIODIC_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PERIODIC_ID    PeriodicId;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_DEL_PERIODIC_CONFIRM;
-
-typedef struct CSR_MLME_DEL_PERIODIC_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PERIODIC_ID    PeriodicId;
-} CSR_MLME_DEL_PERIODIC_REQUEST;
-
-typedef struct CSR_MLME_DEL_RX_TRIGGER_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_TRIGGER_ID     TriggerId;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_DEL_RX_TRIGGER_CONFIRM;
-
-typedef struct CSR_MLME_DEL_RX_TRIGGER_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_TRIGGER_ID     TriggerId;
-} CSR_MLME_DEL_RX_TRIGGER_REQUEST;
-
-typedef struct CSR_MLME_DEL_TRIGGERED_GET_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-    CSR_TRIGGERED_ID   TriggeredId;
-} CSR_MLME_DEL_TRIGGERED_GET_CONFIRM;
-
-typedef struct CSR_MLME_DEL_TRIGGERED_GET_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_TRIGGERED_ID   TriggeredId;
-} CSR_MLME_DEL_TRIGGERED_GET_REQUEST;
-
-typedef struct CSR_MLME_DEL_TSPEC_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PRIORITY       UserPriority;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_DEL_TSPEC_CONFIRM;
-
-typedef struct CSR_MLME_DEL_TSPEC_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_PRIORITY       UserPriority;
-    CSR_DIRECTION      Direction;
-} CSR_MLME_DEL_TSPEC_REQUEST;
-
-typedef struct CSR_MLME_GET_KEY_SEQUENCE_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-    CSR_NATURAL16      SequenceNumber[8];
-} CSR_MLME_GET_KEY_SEQUENCE_CONFIRM;
-
-typedef struct CSR_MLME_GET_KEY_SEQUENCE_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_NATURAL16      KeyId;
-    CSR_KEY_TYPE       KeyType;
-    CSR_MACADDRESS     Address;
-} CSR_MLME_GET_KEY_SEQUENCE_REQUEST;
-
-typedef struct CSR_MLME_LEAVE_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_LEAVE_CONFIRM;
-
-typedef struct CSR_MLME_LEAVE_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-} CSR_MLME_LEAVE_REQUEST;
-
-typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM;
-
-typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST
-{
-    CSR_DATAREF                Data;
-    CSR_DATAREF                Dummydataref2;
-    CSR_VIF_IDENTIFIER         VirtualInterfaceIdentifier;
-    CSR_TIME_UNITS             BeaconPeriod;
-    CSR_BEACON_PERIODS         DtimPeriod;
-    CSR_CAPABILITY_INFORMATION CapabilityInformation;
-    CSR_MACADDRESS             Bssid;
-    CSR_NATURAL16              RtsThreshold;
-} CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST;
-
-typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM
-{
-    CSR_DATAREF            Dummydataref1;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE        ResultCode;
-    CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
-} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM;
-
-typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST
-{
-    CSR_DATAREF            Dummydataref1;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
-    s16               Pause;
-} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST;
-
-typedef struct CSR_MLME_POWERMGT_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_POWERMGT_CONFIRM;
-
-typedef struct CSR_MLME_POWERMGT_REQUEST
-{
-    CSR_DATAREF               Dummydataref1;
-    CSR_DATAREF               Dummydataref2;
-    CSR_VIF_IDENTIFIER        VirtualInterfaceIdentifier;
-    CSR_POWER_MANAGEMENT_MODE PowerManagementMode;
-    s16                  ReceiveDtims;
-    CSR_BEACON_PERIODS        ListenInterval;
-    CSR_TRAFFIC_WINDOW        TrafficWindow;
-} CSR_MLME_POWERMGT_REQUEST;
-
-typedef struct CSR_MLME_SCAN_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_SCAN_CONFIRM;
-
-typedef struct CSR_MLME_SCAN_REQUEST
-{
-    CSR_DATAREF        ChannelList;
-    CSR_DATAREF        InformationElements;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_IFINTERFACE    Ifindex;
-    CSR_SCAN_TYPE      ScanType;
-    CSR_MICROSECONDS32 ProbeDelay;
-    CSR_TIME_UNITS     MinChannelTime;
-    CSR_TIME_UNITS     MaxChannelTime;
-} CSR_MLME_SCAN_REQUEST;
-
-typedef struct CSR_MLME_SCAN_CANCEL_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-} CSR_MLME_SCAN_CANCEL_REQUEST;
-
-typedef struct CSR_MLME_SETKEYS_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_SETKEYS_CONFIRM;
-
-typedef struct CSR_MLME_SETKEYS_REQUEST
-{
-    CSR_DATAREF               Key;
-    CSR_DATAREF               Dummydataref2;
-    CSR_VIF_IDENTIFIER        VirtualInterfaceIdentifier;
-    CSR_NATURAL16             Length;
-    CSR_NATURAL16             KeyId;
-    CSR_KEY_TYPE              KeyType;
-    CSR_MACADDRESS            Address;
-    CSR_NATURAL16             SequenceNumber[8];
-    CSR_CIPHER_SUITE_SELECTOR CipherSuiteSelector;
-} CSR_MLME_SETKEYS_REQUEST;
-
-typedef struct CSR_MLME_SET_CHANNEL_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_SET_CHANNEL_CONFIRM;
-
-typedef struct CSR_MLME_SET_CHANNEL_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_IFINTERFACE    Ifindex;
-    CSR_CHANNEL_NUMBER Channel;
-    CSR_MACADDRESS     Address;
-    CSR_TIME_UNITS     AvailabilityDuration;
-    CSR_TIME_UNITS     AvailabilityInterval;
-} CSR_MLME_SET_CHANNEL_REQUEST;
-
-typedef struct CSR_MLME_SET_PACKET_FILTER_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_SET_PACKET_FILTER_CONFIRM;
-
-typedef struct CSR_MLME_SET_PACKET_FILTER_REQUEST
-{
-    CSR_DATAREF            InformationElements;
-    CSR_DATAREF            Dummydataref2;
-    CSR_VIF_IDENTIFIER     VirtualInterfaceIdentifier;
-    CSR_PACKET_FILTER_MODE PacketFilterMode;
-    CSR_IPV4_ADDRESS       ArpFilterAddress;
-} CSR_MLME_SET_PACKET_FILTER_REQUEST;
-
-typedef struct CSR_MLME_SET_TIM_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_SET_TIM_CONFIRM;
-
-typedef struct CSR_MLME_SET_TIM_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_ASSOCIATION_ID AssociationId;
-    s16           TimValue;
-} CSR_MLME_SET_TIM_REQUEST;
-
-typedef struct CSR_MLME_SM_START_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_SM_START_CONFIRM;
-
-typedef struct CSR_MLME_SM_START_REQUEST
-{
-    CSR_DATAREF                Beacon;
-    CSR_DATAREF                BssParameters;
-    CSR_VIF_IDENTIFIER         VirtualInterfaceIdentifier;
-    CSR_IFINTERFACE            Ifindex;
-    CSR_CHANNEL_NUMBER         Channel;
-    CSR_MACADDRESS             InterfaceAddress;
-    CSR_MACADDRESS             Bssid;
-    CSR_TIME_UNITS             BeaconPeriod;
-    CSR_BEACON_PERIODS         DtimPeriod;
-    CSR_CAPABILITY_INFORMATION CapabilityInformation;
-} CSR_MLME_SM_START_REQUEST;
-
-typedef struct CSR_MLME_START_AGGREGATION_CONFIRM
-{
-    CSR_DATAREF         Dummydataref1;
-    CSR_DATAREF         Dummydataref2;
-    CSR_VIF_IDENTIFIER  VirtualInterfaceIdentifier;
-    CSR_MACADDRESS      PeerQstaAddress;
-    CSR_PRIORITY        UserPriority;
-    CSR_DIRECTION       Direction;
-    CSR_RESULT_CODE     ResultCode;
-    CSR_SEQUENCE_NUMBER SequenceNumber;
-} CSR_MLME_START_AGGREGATION_CONFIRM;
-
-typedef struct CSR_MLME_START_AGGREGATION_REQUEST
-{
-    CSR_DATAREF                  Dummydataref1;
-    CSR_DATAREF                  Dummydataref2;
-    CSR_VIF_IDENTIFIER           VirtualInterfaceIdentifier;
-    CSR_MACADDRESS               PeerQstaAddress;
-    CSR_PRIORITY                 UserPriority;
-    CSR_DIRECTION                Direction;
-    CSR_STARTING_SEQUENCE_NUMBER StartingSequenceNumber;
-    CSR_NATURAL16                BufferSize;
-    CSR_TIME_UNITS               BlockAckTimeout;
-} CSR_MLME_START_AGGREGATION_REQUEST;
-
-typedef struct CSR_MLME_STOP_AGGREGATION_CONFIRM
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_MACADDRESS     PeerQstaAddress;
-    CSR_PRIORITY       UserPriority;
-    CSR_DIRECTION      Direction;
-    CSR_RESULT_CODE    ResultCode;
-} CSR_MLME_STOP_AGGREGATION_CONFIRM;
-
-typedef struct CSR_MLME_STOP_AGGREGATION_REQUEST
-{
-    CSR_DATAREF        Dummydataref1;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_MACADDRESS     PeerQstaAddress;
-    CSR_PRIORITY       UserPriority;
-    CSR_DIRECTION      Direction;
-} CSR_MLME_STOP_AGGREGATION_REQUEST;
-
-typedef struct CSR_MLME_TRIGGERED_GET_INDICATION
-{
-    CSR_DATAREF        MibAttributeValue;
-    CSR_DATAREF        Dummydataref2;
-    CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
-    CSR_MIB_STATUS     Status;
-    CSR_NATURAL16      ErrorIndex;
-    CSR_TRIGGERED_ID   TriggeredId;
-} CSR_MLME_TRIGGERED_GET_INDICATION;
-
-typedef struct CSR_SIGNAL_PRIMITIVE
-{
-    CSR_SIGNAL_PRIMITIVE_HEADER SignalPrimitiveHeader;
-    union
-    {
-        CSR_MA_PACKET_REQUEST                    MaPacketRequest;
-        CSR_MA_PACKET_CONFIRM                    MaPacketConfirm;
-        CSR_MA_PACKET_INDICATION                 MaPacketIndication;
-        CSR_MA_PACKET_CANCEL_REQUEST             MaPacketCancelRequest;
-        CSR_MA_VIF_AVAILABILITY_RESPONSE         MaVifAvailabilityResponse;
-        CSR_MA_VIF_AVAILABILITY_INDICATION       MaVifAvailabilityIndication;
-        CSR_MA_PACKET_ERROR_INDICATION           MaPacketErrorIndication;
-        CSR_MLME_RESET_REQUEST                   MlmeResetRequest;
-        CSR_MLME_RESET_CONFIRM                   MlmeResetConfirm;
-        CSR_MLME_GET_REQUEST                     MlmeGetRequest;
-        CSR_MLME_GET_CONFIRM                     MlmeGetConfirm;
-        CSR_MLME_SET_REQUEST                     MlmeSetRequest;
-        CSR_MLME_SET_CONFIRM                     MlmeSetConfirm;
-        CSR_MLME_GET_NEXT_REQUEST                MlmeGetNextRequest;
-        CSR_MLME_GET_NEXT_CONFIRM                MlmeGetNextConfirm;
-        CSR_MLME_POWERMGT_REQUEST                MlmePowermgtRequest;
-        CSR_MLME_POWERMGT_CONFIRM                MlmePowermgtConfirm;
-        CSR_MLME_SCAN_REQUEST                    MlmeScanRequest;
-        CSR_MLME_SCAN_CONFIRM                    MlmeScanConfirm;
-        CSR_MLME_HL_SYNC_REQUEST                 MlmeHlSyncRequest;
-        CSR_MLME_HL_SYNC_CONFIRM                 MlmeHlSyncConfirm;
-        CSR_MLME_MEASURE_REQUEST                 MlmeMeasureRequest;
-        CSR_MLME_MEASURE_CONFIRM                 MlmeMeasureConfirm;
-        CSR_MLME_MEASURE_INDICATION              MlmeMeasureIndication;
-        CSR_MLME_SETKEYS_REQUEST                 MlmeSetkeysRequest;
-        CSR_MLME_SETKEYS_CONFIRM                 MlmeSetkeysConfirm;
-        CSR_MLME_DELETEKEYS_REQUEST              MlmeDeletekeysRequest;
-        CSR_MLME_DELETEKEYS_CONFIRM              MlmeDeletekeysConfirm;
-        CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION MlmeAutonomousScanLossIndication;
-        CSR_MLME_CONNECTED_INDICATION            MlmeConnectedIndication;
-        CSR_MLME_SCAN_CANCEL_REQUEST             MlmeScanCancelRequest;
-        CSR_MLME_HL_SYNC_CANCEL_REQUEST          MlmeHlSyncCancelRequest;
-        CSR_MLME_HL_SYNC_CANCEL_CONFIRM          MlmeHlSyncCancelConfirm;
-        CSR_MLME_ADD_PERIODIC_REQUEST            MlmeAddPeriodicRequest;
-        CSR_MLME_ADD_PERIODIC_CONFIRM            MlmeAddPeriodicConfirm;
-        CSR_MLME_DEL_PERIODIC_REQUEST            MlmeDelPeriodicRequest;
-        CSR_MLME_DEL_PERIODIC_CONFIRM            MlmeDelPeriodicConfirm;
-        CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST     MlmeAddAutonomousScanRequest;
-        CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM     MlmeAddAutonomousScanConfirm;
-        CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST     MlmeDelAutonomousScanRequest;
-        CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM     MlmeDelAutonomousScanConfirm;
-        CSR_MLME_SET_PACKET_FILTER_REQUEST       MlmeSetPacketFilterRequest;
-        CSR_MLME_SET_PACKET_FILTER_CONFIRM       MlmeSetPacketFilterConfirm;
-        CSR_MLME_STOP_MEASURE_REQUEST            MlmeStopMeasureRequest;
-        CSR_MLME_STOP_MEASURE_CONFIRM            MlmeStopMeasureConfirm;
-        CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST   MlmePauseAutonomousScanRequest;
-        CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM   MlmePauseAutonomousScanConfirm;
-        CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION MlmeAutonomousScanDoneIndication;
-        CSR_MLME_ADD_TRIGGERED_GET_REQUEST       MlmeAddTriggeredGetRequest;
-        CSR_MLME_ADD_TRIGGERED_GET_CONFIRM       MlmeAddTriggeredGetConfirm;
-        CSR_MLME_DEL_TRIGGERED_GET_REQUEST       MlmeDelTriggeredGetRequest;
-        CSR_MLME_DEL_TRIGGERED_GET_CONFIRM       MlmeDelTriggeredGetConfirm;
-        CSR_MLME_TRIGGERED_GET_INDICATION        MlmeTriggeredGetIndication;
-        CSR_MLME_ADD_BLACKOUT_REQUEST            MlmeAddBlackoutRequest;
-        CSR_MLME_ADD_BLACKOUT_CONFIRM            MlmeAddBlackoutConfirm;
-        CSR_MLME_BLACKOUT_ENDED_INDICATION       MlmeBlackoutEndedIndication;
-        CSR_MLME_DEL_BLACKOUT_REQUEST            MlmeDelBlackoutRequest;
-        CSR_MLME_DEL_BLACKOUT_CONFIRM            MlmeDelBlackoutConfirm;
-        CSR_MLME_ADD_RX_TRIGGER_REQUEST          MlmeAddRxTriggerRequest;
-        CSR_MLME_ADD_RX_TRIGGER_CONFIRM          MlmeAddRxTriggerConfirm;
-        CSR_MLME_DEL_RX_TRIGGER_REQUEST          MlmeDelRxTriggerRequest;
-        CSR_MLME_DEL_RX_TRIGGER_CONFIRM          MlmeDelRxTriggerConfirm;
-        CSR_MLME_CONNECT_STATUS_REQUEST          MlmeConnectStatusRequest;
-        CSR_MLME_CONNECT_STATUS_CONFIRM          MlmeConnectStatusConfirm;
-        CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST    MlmeModifyBssParameterRequest;
-        CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM    MlmeModifyBssParameterConfirm;
-        CSR_MLME_ADD_TEMPLATE_REQUEST            MlmeAddTemplateRequest;
-        CSR_MLME_ADD_TEMPLATE_CONFIRM            MlmeAddTemplateConfirm;
-        CSR_MLME_CONFIG_QUEUE_REQUEST            MlmeConfigQueueRequest;
-        CSR_MLME_CONFIG_QUEUE_CONFIRM            MlmeConfigQueueConfirm;
-        CSR_MLME_ADD_TSPEC_REQUEST               MlmeAddTspecRequest;
-        CSR_MLME_ADD_TSPEC_CONFIRM               MlmeAddTspecConfirm;
-        CSR_MLME_DEL_TSPEC_REQUEST               MlmeDelTspecRequest;
-        CSR_MLME_DEL_TSPEC_CONFIRM               MlmeDelTspecConfirm;
-        CSR_MLME_START_AGGREGATION_REQUEST       MlmeStartAggregationRequest;
-        CSR_MLME_START_AGGREGATION_CONFIRM       MlmeStartAggregationConfirm;
-        CSR_MLME_BLOCKACK_ERROR_INDICATION       MlmeBlockackErrorIndication;
-        CSR_MLME_STOP_AGGREGATION_REQUEST        MlmeStopAggregationRequest;
-        CSR_MLME_STOP_AGGREGATION_CONFIRM        MlmeStopAggregationConfirm;
-        CSR_MLME_SM_START_REQUEST                MlmeSmStartRequest;
-        CSR_MLME_SM_START_CONFIRM                MlmeSmStartConfirm;
-        CSR_MLME_LEAVE_REQUEST                   MlmeLeaveRequest;
-        CSR_MLME_LEAVE_CONFIRM                   MlmeLeaveConfirm;
-        CSR_MLME_SET_TIM_REQUEST                 MlmeSetTimRequest;
-        CSR_MLME_SET_TIM_CONFIRM                 MlmeSetTimConfirm;
-        CSR_MLME_GET_KEY_SEQUENCE_REQUEST        MlmeGetKeySequenceRequest;
-        CSR_MLME_GET_KEY_SEQUENCE_CONFIRM        MlmeGetKeySequenceConfirm;
-        CSR_MLME_SET_CHANNEL_REQUEST             MlmeSetChannelRequest;
-        CSR_MLME_SET_CHANNEL_CONFIRM             MlmeSetChannelConfirm;
-        CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST   MlmeAddMulticastAddressRequest;
-        CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM   MlmeAddMulticastAddressConfirm;
-        CSR_DEBUG_STRING_INDICATION              DebugStringIndication;
-        CSR_DEBUG_WORD16_INDICATION              DebugWord16Indication;
-        CSR_DEBUG_GENERIC_REQUEST                DebugGenericRequest;
-        CSR_DEBUG_GENERIC_CONFIRM                DebugGenericConfirm;
-        CSR_DEBUG_GENERIC_INDICATION             DebugGenericIndication;
-    } u;
-} CSR_SIGNAL;
-
-#define SIG_FILTER_SIZE 6
-
-u32 SigGetFilterPos(u16 aSigID);
-
-#endif
diff --git a/drivers/staging/csr/csr_wifi_hip_ta_sampling.c b/drivers/staging/csr/csr_wifi_hip_ta_sampling.c
deleted file mode 100644 (file)
index f1df36a..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     csr_wifi_hip_ta_sampling.c
- *
- *  PURPOSE:
- *      The traffic analysis sampling module.
- *      This gathers data which is sent to the SME and used to analyse
- *      the traffic behaviour.
- *
- * Provides:
- *      unifi_ta_sampling_init - Initialise the internal state
- *      unifi_ta_sample        - Sampling function, call this for every data packet
- *
- * Calls these external functions which must be provided:
- *      unifi_ta_indicate_sampling - Pass sample data to the SME.
- *      unifi_ta_indicate_protocol - Report certain data packet types to the SME.
- * ---------------------------------------------------------------------------
- */
-
-#include "csr_wifi_hip_card_sdio.h"
-
-/* Maximum number of Tx frames we store each CYCLE_1, for detecting period */
-#define TA_MAX_INTERVALS_IN_C1          100
-
-/* Number of intervals in CYCLE_1 (one second), for detecting periodic */
-/* Must match size of unifi_TrafficStats.intervals - 1 */
-#define TA_INTERVALS_NUM               10
-
-/* Step (in msecs) between intervals, for detecting periodic */
-/* We are only interested in periods up to 100ms, i.e. between beacons */
-/* This is correct for TA_INTERVALS_NUM=10 */
-#define TA_INTERVALS_STEP               10
-
-
-enum ta_frame_identity
-{
-    TA_FRAME_UNKNOWN,
-    TA_FRAME_ETHERNET_UNINTERESTING,
-    TA_FRAME_ETHERNET_INTERESTING
-};
-
-
-#define TA_ETHERNET_TYPE_OFFSET     6
-#define TA_LLC_HEADER_SIZE          8
-#define TA_IP_TYPE_OFFSET           17
-#define TA_UDP_SOURCE_PORT_OFFSET   28
-#define TA_UDP_DEST_PORT_OFFSET     (TA_UDP_SOURCE_PORT_OFFSET + 2)
-#define TA_BOOTP_CLIENT_MAC_ADDR_OFFSET 64
-#define TA_DHCP_MESSAGE_TYPE_OFFSET 278
-#define TA_DHCP_MESSAGE_TYPE_ACK    0x05
-#define TA_PROTO_TYPE_IP            0x0800
-#define TA_PROTO_TYPE_EAP           0x888E
-#define TA_PROTO_TYPE_WAI           0x8864
-#define TA_PROTO_TYPE_ARP           0x0806
-#define TA_IP_TYPE_TCP              0x06
-#define TA_IP_TYPE_UDP              0x11
-#define TA_UDP_PORT_BOOTPC          0x0044
-#define TA_UDP_PORT_BOOTPS          0x0043
-#define TA_EAPOL_TYPE_OFFSET        9
-#define TA_EAPOL_TYPE_START         0x01
-
-#define snap_802_2                  0xAAAA0300
-#define oui_rfc1042                 0x00000000
-#define oui_8021h                   0x0000f800
-static const u8 aironet_snap[5] = { 0x00, 0x40, 0x96, 0x00, 0x00 };
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ta_detect_protocol
- *
- *      Internal only.
- *      Detects a specific protocol in a frame and indicates a TA event.
- *
- *  Arguments:
- *      ta              The pointer to the TA module.
- *      direction       The direction of the frame (tx or rx).
- *      data            Pointer to the structure that contains the data.
- *
- *  Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-static enum ta_frame_identity ta_detect_protocol(card_t *card, CsrWifiRouterCtrlProtocolDirection direction,
-                                                 const bulk_data_desc_t *data,
-                                                 const u8 *saddr,
-                                                 const u8 *sta_macaddr)
-{
-    ta_data_t *tad = &card->ta_sampling;
-    u16 proto;
-    u16 source_port, dest_port;
-    CsrWifiMacAddress srcAddress;
-    u32 snap_hdr, oui_hdr;
-
-    if (data->data_length < TA_LLC_HEADER_SIZE)
-    {
-        return TA_FRAME_UNKNOWN;
-    }
-
-    snap_hdr = (((u32)data->os_data_ptr[0]) << 24) |
-               (((u32)data->os_data_ptr[1]) << 16) |
-               (((u32)data->os_data_ptr[2]) << 8);
-    if (snap_hdr != snap_802_2)
-    {
-        return TA_FRAME_UNKNOWN;
-    }
-
-    if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
-    {
-        /*
-         * Here we would use the custom filter to detect interesting frames.
-         */
-    }
-
-    oui_hdr = (((u32)data->os_data_ptr[3]) << 24) |
-              (((u32)data->os_data_ptr[4]) << 16) |
-              (((u32)data->os_data_ptr[5]) << 8);
-    if ((oui_hdr == oui_rfc1042) || (oui_hdr == oui_8021h))
-    {
-        proto = (data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET] * 256) +
-                data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET + 1];
-
-        /* The only interesting IP frames are the DHCP */
-        if (proto == TA_PROTO_TYPE_IP)
-        {
-            if (data->data_length > TA_IP_TYPE_OFFSET)
-            {
-                if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
-                {
-                    ta_l4stats_t *ta_l4stats = &tad->ta_l4stats;
-                    u8 l4proto = data->os_data_ptr[TA_IP_TYPE_OFFSET];
-
-                    if (l4proto == TA_IP_TYPE_TCP)
-                    {
-                        if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
-                        {
-                            ta_l4stats->txTcpBytesCount += data->data_length;
-                        }
-                        else
-                        {
-                            ta_l4stats->rxTcpBytesCount += data->data_length;
-                        }
-                    }
-                    else if (l4proto == TA_IP_TYPE_UDP)
-                    {
-                        if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
-                        {
-                            ta_l4stats->txUdpBytesCount += data->data_length;
-                        }
-                        else
-                        {
-                            ta_l4stats->rxUdpBytesCount += data->data_length;
-                        }
-                    }
-                }
-
-                /* detect DHCP frames */
-                if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP)
-                {
-                    /* DHCP frames are UDP frames with BOOTP ports */
-                    if (data->os_data_ptr[TA_IP_TYPE_OFFSET] == TA_IP_TYPE_UDP)
-                    {
-                        if (data->data_length > TA_UDP_DEST_PORT_OFFSET)
-                        {
-                            source_port = (data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET] * 256) +
-                                          data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET + 1];
-                            dest_port = (data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET] * 256) +
-                                        data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET + 1];
-
-                            if (((source_port == TA_UDP_PORT_BOOTPC) && (dest_port == TA_UDP_PORT_BOOTPS)) ||
-                                ((source_port == TA_UDP_PORT_BOOTPS) && (dest_port == TA_UDP_PORT_BOOTPC)))
-                            {
-                                /* The DHCP should have at least a message type (request, ack, nack, etc) */
-                                if (data->data_length > TA_DHCP_MESSAGE_TYPE_OFFSET + 6)
-                                {
-                                    UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
-
-                                    if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
-                                    {
-                                        unifi_ta_indicate_protocol(card->ospriv,
-                                                                   CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP,
-                                                                   direction,
-                                                                   &srcAddress);
-                                        return TA_FRAME_ETHERNET_UNINTERESTING;
-                                    }
-
-                                    /* DHCPACK is a special indication */
-                                    if (UNIFI_MAC_ADDRESS_CMP(data->os_data_ptr + TA_BOOTP_CLIENT_MAC_ADDR_OFFSET, sta_macaddr) == TRUE)
-                                    {
-                                        if (data->os_data_ptr[TA_DHCP_MESSAGE_TYPE_OFFSET] == TA_DHCP_MESSAGE_TYPE_ACK)
-                                        {
-                                            unifi_ta_indicate_protocol(card->ospriv,
-                                                                       CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK,
-                                                                       direction,
-                                                                       &srcAddress);
-                                        }
-                                        else
-                                        {
-                                            unifi_ta_indicate_protocol(card->ospriv,
-                                                                       CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP,
-                                                                       direction,
-                                                                       &srcAddress);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            return TA_FRAME_ETHERNET_INTERESTING;
-        }
-
-        /* detect protocol type EAPOL or WAI (treated as equivalent here) */
-        if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL)
-        {
-            if (TA_PROTO_TYPE_EAP == proto || TA_PROTO_TYPE_WAI == proto)
-            {
-                if ((TA_PROTO_TYPE_WAI == proto) || (direction != CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) ||
-                    (data->os_data_ptr[TA_EAPOL_TYPE_OFFSET] == TA_EAPOL_TYPE_START))
-                {
-                    UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
-                    unifi_ta_indicate_protocol(card->ospriv,
-                                               CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL,
-                                               direction, &srcAddress);
-                }
-                return TA_FRAME_ETHERNET_UNINTERESTING;
-            }
-        }
-
-        /* detect protocol type 0x0806 (ARP) */
-        if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP)
-        {
-            if (proto == TA_PROTO_TYPE_ARP)
-            {
-                UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
-                unifi_ta_indicate_protocol(card->ospriv,
-                                           CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP,
-                                           direction, &srcAddress);
-                return TA_FRAME_ETHERNET_UNINTERESTING;
-            }
-        }
-
-        return TA_FRAME_ETHERNET_INTERESTING;
-    }
-    else if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET)
-    {
-        /* detect Aironet frames */
-        if (!memcmp(data->os_data_ptr + 3, aironet_snap, 5))
-        {
-            UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
-            unifi_ta_indicate_protocol(card->ospriv, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET,
-                                       direction, &srcAddress);
-        }
-    }
-
-    return TA_FRAME_ETHERNET_UNINTERESTING;
-} /* ta_detect_protocol() */
-
-
-static void tas_reset_data(ta_data_t *tad)
-{
-    s16 i;
-
-    for (i = 0; i < (TA_INTERVALS_NUM + 1); i++)
-    {
-        tad->stats.intervals[i] = 0;
-    }
-
-    tad->stats.rxFramesNum = 0;
-    tad->stats.txFramesNum = 0;
-    tad->stats.rxBytesCount = 0;
-    tad->stats.txBytesCount = 0;
-    tad->stats.rxMeanRate = 0;
-
-    tad->rx_sum_rate = 0;
-
-    tad->ta_l4stats.rxTcpBytesCount = 0;
-    tad->ta_l4stats.txTcpBytesCount = 0;
-    tad->ta_l4stats.rxUdpBytesCount = 0;
-    tad->ta_l4stats.txUdpBytesCount = 0;
-} /* tas_reset_data() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  API.
- *  unifi_ta_sampling_init
- *
- *      (Re)Initialise the Traffic Analysis sampling module.
- *      Resets the counters and timestamps.
- *
- *  Arguments:
- *      tad             Pointer to a ta_data_t structure containing the
- *                      context for this device instance.
- *      drv_priv        An opaque pointer that the TA sampling module will
- *                      pass in call-outs.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void unifi_ta_sampling_init(card_t *card)
-{
-    (void)unifi_ta_configure(card, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET, NULL);
-
-    card->ta_sampling.packet_filter = CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE;
-    card->ta_sampling.traffic_type = CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL;
-} /* unifi_ta_sampling_init() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  API.
- *  unifi_ta_sample
- *
- *      Sample a data frame for the TA module.
- *      This function stores all the useful information it can extract from
- *      the frame and detects any specific protocols.
- *
- *  Arguments:
- *      tad             The pointer to the TA sampling context struct.
- *      direction       The direction of the frame (rx, tx)
- *      data            Pointer to the frame data
- *      saddr           Source MAC address of frame.
- *      timestamp       Time (in msecs) that the frame was received.
- *      rate            Reported data rate for the rx frame (0 for tx frames)
- *
- *  Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-void unifi_ta_sample(card_t                            *card,
-                     CsrWifiRouterCtrlProtocolDirection direction,
-                     const bulk_data_desc_t            *data,
-                     const u8                    *saddr,
-                     const u8                    *sta_macaddr,
-                     u32                          timestamp,
-                     u16                          rate)
-{
-    ta_data_t *tad = &card->ta_sampling;
-    enum ta_frame_identity identity;
-    u32 time_delta;
-
-
-
-    /* Step1: Check for specific frames */
-    if (tad->packet_filter != CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE)
-    {
-        identity = ta_detect_protocol(card, direction, data, saddr, sta_macaddr);
-    }
-    else
-    {
-        identity = TA_FRAME_ETHERNET_INTERESTING;
-    }
-
-
-    /* Step2: Update the information in the current record */
-    if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX)
-    {
-        /* Update the Rx packet count and the throughput count */
-        tad->stats.rxFramesNum++;
-        tad->stats.rxBytesCount += data->data_length;
-
-        /* Accumulate packet Rx rates for later averaging */
-        tad->rx_sum_rate += rate;
-    }
-    else
-    {
-        if (identity == TA_FRAME_ETHERNET_INTERESTING)
-        {
-            /*
-             * Store the period between the last and the current frame.
-             * There is not point storing more than TA_MAX_INTERVALS_IN_C1 periods,
-             * the traffic will be bursty or continuous.
-             */
-            if (tad->stats.txFramesNum < TA_MAX_INTERVALS_IN_C1)
-            {
-                u32 interval;
-                u32 index_in_intervals;
-
-                interval = timestamp - tad->tx_last_ts;
-                tad->tx_last_ts = timestamp;
-                index_in_intervals = (interval + TA_INTERVALS_STEP / 2 - 1) / TA_INTERVALS_STEP;
-
-                /* If the interval is interesting, update the t1_intervals count */
-                if (index_in_intervals <= TA_INTERVALS_NUM)
-                {
-                    unifi_trace(card->ospriv, UDBG5,
-                                "unifi_ta_sample: TX interval=%d index=%d\n",
-                                interval, index_in_intervals);
-                    tad->stats.intervals[index_in_intervals]++;
-                }
-            }
-        }
-
-        /* Update the Tx packet count... */
-        tad->stats.txFramesNum++;
-        /* ... and the number of bytes for throughput. */
-        tad->stats.txBytesCount += data->data_length;
-    }
-
-    /*
-     * If more than one second has elapsed since the last report, send
-     * another one.
-     */
-    /* Unsigned subtraction handles wrap-around from 0xFFFFFFFF to 0 */
-    time_delta = timestamp - tad->last_indication_time;
-    if (time_delta >= 1000)
-    {
-        /*
-         * rxFramesNum can be flashed in tas_reset_data() by another thread.
-         * Use a temp to avoid division by zero.
-         */
-        u32 temp_rxFramesNum;
-        temp_rxFramesNum = tad->stats.rxFramesNum;
-
-        /* Calculate this interval's mean frame Rx rate from the sum */
-        if (temp_rxFramesNum)
-        {
-            tad->stats.rxMeanRate = tad->rx_sum_rate / temp_rxFramesNum;
-        }
-        unifi_trace(card->ospriv, UDBG5,
-                    "unifi_ta_sample: RX fr=%lu, r=%u, sum=%lu, av=%lu\n",
-                    tad->stats.rxFramesNum, rate,
-                    tad->rx_sum_rate, tad->stats.rxMeanRate);
-
-        /*
-         * Send the information collected in the stats struct
-         * to the SME and reset the counters.
-         */
-        if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
-        {
-            u32 rxTcpThroughput = tad->ta_l4stats.rxTcpBytesCount / time_delta;
-            u32 txTcpThroughput = tad->ta_l4stats.txTcpBytesCount / time_delta;
-            u32 rxUdpThroughput = tad->ta_l4stats.rxUdpBytesCount / time_delta;
-            u32 txUdpThroughput = tad->ta_l4stats.txUdpBytesCount / time_delta;
-
-            unifi_ta_indicate_l4stats(card->ospriv,
-                                      rxTcpThroughput,
-                                      txTcpThroughput,
-                                      rxUdpThroughput,
-                                      txUdpThroughput
-                                      );
-        }
-        unifi_ta_indicate_sampling(card->ospriv, &tad->stats);
-        tas_reset_data(tad);
-        tad->last_indication_time = timestamp;
-    }
-} /* unifi_ta_sample() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  External API.
- *  unifi_ta_configure
- *
- *      Configures the TA module parameters.
- *
- *  Arguments:
- *      ta              The pointer to the TA module.
- *      config_type     The type of the configuration request
- *      config          Pointer to the configuration parameters.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code otherwise
- * ---------------------------------------------------------------------------
- */
-CsrResult unifi_ta_configure(card_t                               *card,
-                             CsrWifiRouterCtrlTrafficConfigType    config_type,
-                             const CsrWifiRouterCtrlTrafficConfig *config)
-{
-    ta_data_t *tad = &card->ta_sampling;
-
-    /* Reinitialise our data when we are reset */
-    if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET)
-    {
-        /* Reset the stats to zero */
-        tas_reset_data(tad);
-
-        /* Reset the timer variables */
-        tad->tx_last_ts = 0;
-        tad->last_indication_time = 0;
-
-        return CSR_RESULT_SUCCESS;
-    }
-
-    if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER)
-    {
-        tad->packet_filter = config->packetFilter;
-
-        if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
-        {
-            tad->custom_filter = config->customFilter;
-        }
-
-        return CSR_RESULT_SUCCESS;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_ta_configure() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  External API.
- *  unifi_ta_classification
- *
- *      Configures the current TA classification.
- *
- *  Arguments:
- *      ta              The pointer to the TA module.
- *      traffic_type    The classification type
- *      period          The traffic period if the type is periodic
- *
- *  Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-void unifi_ta_classification(card_t                      *card,
-                             CsrWifiRouterCtrlTrafficType traffic_type,
-                             u16                    period)
-{
-    unifi_trace(card->ospriv, UDBG3,
-                "Changed current ta classification to: %d\n", traffic_type);
-
-    card->ta_sampling.traffic_type = traffic_type;
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_ta_sampling.h b/drivers/staging/csr/csr_wifi_hip_ta_sampling.h
deleted file mode 100644 (file)
index aa684c6..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     csr_wifi_hip_ta_sampling.h
- *
- *  PURPOSE:
- *      This file contains Traffic Analysis definitions common to the
- *      sampling and analysis modules.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __TA_SAMPLING_H__
-#define __TA_SAMPLING_H__
-
-#include "csr_wifi_hip_unifi.h"
-
-typedef struct ta_l4stats
-{
-    u32 rxTcpBytesCount;
-    u32 txTcpBytesCount;
-    u32 rxUdpBytesCount;
-    u32 txUdpBytesCount;
-} ta_l4stats_t;
-
-/*
- * Context structure to preserve state between calls.
- */
-
-typedef struct ta_data
-{
-    /* Current packet filter configuration */
-    u16 packet_filter;
-
-    /* Current packet custom filter configuration */
-    CsrWifiRouterCtrlTrafficFilter custom_filter;
-
-    /* The timestamp of the last tx packet processed. */
-    u32 tx_last_ts;
-
-    /* The timestamp of the last packet processed. */
-    u32 last_indication_time;
-
-    /* Statistics */
-    CsrWifiRouterCtrlTrafficStats stats;
-
-    /* Current traffic classification */
-    CsrWifiRouterCtrlTrafficType traffic_type;
-
-    /* Sum of packet rx rates for this interval used to calculate mean */
-    u32    rx_sum_rate;
-    ta_l4stats_t ta_l4stats;
-} ta_data_t;
-
-
-void unifi_ta_sampling_init(card_t *card);
-
-#endif /* __TA_SAMPLING_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_udi.c b/drivers/staging/csr/csr_wifi_hip_udi.c
deleted file mode 100644 (file)
index a6b006b..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     csr_wifi_hip_card_udi.c
- *
- *  PURPOSE:
- *      Maintain a list of callbacks to log UniFi exchanges to one or more
- *      debug/monitoring client applications.
- *
- * NOTES:
- *      Just call the UDI driver log fn directly for now.
- *      When done properly, each open() on the UDI device will install
- *      a log function. We will call all log fns whenever a signal is written
- *      to or read form the UniFi.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/seq_file.h>
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_card.h"
-
-
-static void unifi_print_unsafe_sdio_status(card_t *card, struct seq_file *m)
-{
-#ifdef CSR_UNSAFE_SDIO_ACCESS
-       s32 iostate;
-       CsrResult r;
-       static const char *const states[] = {
-               "AWAKE", "DROWSY", "TORPID"
-       };
-#define SHARED_READ_RETRY_LIMIT 10
-       u8 b;
-
-       seq_printf(m, "Host State: %s\n", states[card->host_state]);
-
-       r = unifi_check_io_status(card, &iostate);
-       if (iostate == 1) {
-               seq_puts(m, remaining, "I/O Check: F1 disabled\n");
-        } else {
-               if (iostate == 1) {
-                       seq_puts(m, "I/O Check: pending interrupt\n");
-
-               seq_printf(m, "BH reason interrupt = %d\n", card->bh_reason_unifi);
-               seq_printf(m, "BH reason host      = %d\n", card->bh_reason_host);
-
-               for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++) {
-                       r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b);
-                       if (r == CSR_RESULT_SUCCESS && !(b & 0x80)) {
-                               seq_printf(m, "fhsr: %u (driver thinks is %u)\n",
-                                          b, card->from_host_signals_r);
-                               break;
-                       }
-               }
-
-               iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
-               seq_printf(m, "thsw: %u (driver thinks is %u)\n",
-                          iostate, card->to_host_signals_w);
-        }
-#endif
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_print_status
- *
- *      Print status info to given character buffer.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-s32 unifi_print_status(card_t *card, struct seq_file *m)
-{
-       sdio_config_data_t *cfg;
-       u16 i, n;
-
-       i = n = 0;
-       seq_printf(m, "Chip ID %u\n", card->chip_id);
-       seq_printf(m, "Chip Version %04X\n", card->chip_version);
-       seq_printf(m, "HIP v%u.%u\n",
-                  (card->config_data.version >> 8) & 0xFF,
-                  card->config_data.version & 0xFF);
-       seq_printf(m, "Build %u: %s\n", card->build_id, card->build_id_string);
-
-       cfg = &card->config_data;
-
-       seq_printf(m, "sdio ctrl offset          %u\n", cfg->sdio_ctrl_offset);
-       seq_printf(m, "fromhost sigbuf handle    %u\n", cfg->fromhost_sigbuf_handle);
-       seq_printf(m, "tohost_sigbuf_handle      %u\n", cfg->tohost_sigbuf_handle);
-       seq_printf(m, "num_fromhost_sig_frags    %u\n", cfg->num_fromhost_sig_frags);
-       seq_printf(m, "num_tohost_sig_frags      %u\n", cfg->num_tohost_sig_frags);
-       seq_printf(m, "num_fromhost_data_slots   %u\n", cfg->num_fromhost_data_slots);
-       seq_printf(m, "num_tohost_data_slots     %u\n", cfg->num_tohost_data_slots);
-       seq_printf(m, "data_slot_size            %u\n", cfg->data_slot_size);
-
-       /* Added by protocol version 0x0001 */
-       seq_printf(m, "overlay_size              %u\n", cfg->overlay_size);
-
-       /* Added by protocol version 0x0300 */
-       seq_printf(m, "data_slot_round           %u\n", cfg->data_slot_round);
-       seq_printf(m, "sig_frag_size             %u\n", cfg->sig_frag_size);
-
-       /* Added by protocol version 0x0300 */
-       seq_printf(m, "tohost_sig_pad            %u\n", cfg->tohost_signal_padding);
-
-       seq_puts(m, "\nInternal state:\n");
-
-       seq_printf(m, "Last PHY PANIC: %04x:%04x\n",
-                  card->last_phy_panic_code, card->last_phy_panic_arg);
-       seq_printf(m, "Last MAC PANIC: %04x:%04x\n",
-                  card->last_mac_panic_code, card->last_mac_panic_arg);
-
-       seq_printf(m, "fhsr: %hu\n", (u16)card->from_host_signals_r);
-       seq_printf(m, "fhsw: %hu\n", (u16)card->from_host_signals_w);
-       seq_printf(m, "thsr: %hu\n", (u16)card->to_host_signals_r);
-       seq_printf(m, "thsw: %hu\n", (u16)card->to_host_signals_w);
-       seq_printf(m, "fh buffer contains: %d signals, %td bytes\n",
-                  card->fh_buffer.count,
-                  card->fh_buffer.ptr - card->fh_buffer.buf);
-
-       seq_puts(m, "paused: ");
-       for (i = 0; i < ARRAY_SIZE(card->tx_q_paused_flag); i++)
-               seq_printf(m, card->tx_q_paused_flag[i] ? "1" : "0");
-       seq_putc(m, '\n');
-
-       seq_printf(m, "fh command q: %u waiting, %u free of %u:\n",
-                  CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue),
-                  CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue),
-                  UNIFI_SOFT_COMMAND_Q_LENGTH);
-
-       for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
-               seq_printf(m, "fh traffic q[%u]: %u waiting, %u free of %u:\n",
-                          i,
-                          CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]),
-                          CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]),
-                          UNIFI_SOFT_TRAFFIC_Q_LENGTH);
-
-       seq_printf(m, "fh data slots free: %u\n",
-                  card->from_host_data ? CardGetFreeFromHostDataSlots(card) : 0);
-
-       seq_puts(m, "From host data slots:");
-       n = card->config_data.num_fromhost_data_slots;
-       for (i = 0; i < n && card->from_host_data; i++)
-               seq_printf(m, " %hu", (u16)card->from_host_data[i].bd.data_length);
-       seq_putc(m, '\n');
-
-       seq_puts(m, "To host data slots:");
-       n = card->config_data.num_tohost_data_slots;
-       for (i = 0; i < n && card->to_host_data; i++)
-               seq_printf(m, " %hu", (u16)card->to_host_data[i].data_length);
-       seq_putc(m, '\n');
-
-       unifi_print_unsafe_sdio_status(card, m);
-
-       seq_puts(m, "\nStats:\n");
-       seq_printf(m, "Total SDIO bytes: R=%u W=%u\n",
-                  card->sdio_bytes_read, card->sdio_bytes_written);
-
-       seq_printf(m, "Interrupts generated on card: %u\n", card->unifi_interrupt_seq);
-       return 0;
-}
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi.h b/drivers/staging/csr/csr_wifi_hip_unifi.h
deleted file mode 100644 (file)
index 1160a0e..0000000
+++ /dev/null
@@ -1,871 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *
- * FILE : csr_wifi_hip_unifi.h
- *
- * PURPOSE : Public API for the UniFi HIP core library.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __CSR_WIFI_HIP_UNIFI_H__
-#define __CSR_WIFI_HIP_UNIFI_H__ 1
-
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-#include "csr_wifi_router_ctrl_prim.h"
-#include "csr_wifi_router_prim.h"
-#else
-#include "csr_time.h"
-#endif
-
-/* SDIO chip ID numbers */
-
-/* Manufacturer id */
-#define SDIO_MANF_ID_CSR              0x032a
-
-/* Device id */
-#define SDIO_CARD_ID_UNIFI_1          0x0001
-#define SDIO_CARD_ID_UNIFI_2          0x0002
-#define SDIO_CARD_ID_UNIFI_3          0x0007
-#define SDIO_CARD_ID_UNIFI_4          0x0008
-
-/* Function number for WLAN */
-#define SDIO_WLAN_FUNC_ID_UNIFI_1          0x0001
-#define SDIO_WLAN_FUNC_ID_UNIFI_2          0x0001
-#define SDIO_WLAN_FUNC_ID_UNIFI_3          0x0001
-#define SDIO_WLAN_FUNC_ID_UNIFI_4          0x0002
-
-/* Maximum SDIO bus clock supported. */
-#define UNIFI_SDIO_CLOCK_MAX_HZ    50000000  /* Hz */
-
-/*
- * Initialisation SDIO bus clock.
- *
- * The initialisation clock speed should be used from when the chip has been
- * reset until the first MLME-reset has been received (i.e. during firmware
- * initialisation), unless UNIFI_SDIO_CLOCK_SAFE_HZ applies.
- */
-#define UNIFI_SDIO_CLOCK_INIT_HZ    12500000 /* Hz */
-
-/*
- * Safe SDIO bus clock.
- *
- * The safe speed should be used when the chip is in deep sleep or
- * it's state is unknown (just after reset / power on).
- */
-#define UNIFI_SDIO_CLOCK_SAFE_HZ    1000000  /* Hz */
-
-/* I/O default block size to use for UniFi. */
-#define UNIFI_IO_BLOCK_SIZE     64
-
-#define UNIFI_WOL_OFF   0
-#define UNIFI_WOL_SDIO  1
-#define UNIFI_WOL_PIO   2
-
-/* The number of Tx traffic queues */
-#define UNIFI_NO_OF_TX_QS              4
-
-#define CSR_WIFI_HIP_RESERVED_HOST_TAG 0xFFFFFFFF
-
-/*
- * The number of slots in the from-host queues.
- *
- * UNIFI_SOFT_TRAFFIC_Q_LENGTH is the number of slots in the traffic queues
- * and there will be UNIFI_NO_OF_TX_QS of them.
- * Traffic queues are used for data packets.
- *
- * UNIFI_SOFT_COMMAND_Q_LENGTH is the number of slots in the command queue.
- * The command queue is used for MLME management requests.
- *
- * Queues are ring buffers and so must always have 1 unused slot.
- */
-#define UNIFI_SOFT_TRAFFIC_Q_LENGTH (20 + 1)
-#define UNIFI_SOFT_COMMAND_Q_LENGTH (16 + 1)
-
-#include "csr_framework_ext.h"  /* from the synergy porting folder */
-#include "csr_sdio.h"           /* from the synergy porting folder */
-#include "csr_macro.h"          /* from the synergy porting folder */
-#include "csr_wifi_result.h"
-
-/* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */
-#define UNIFI_MAC_ADDRESS_COPY(dst, src) \
-    do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; \
-         (dst)[2] = (src)[2]; (dst)[3] = (src)[3]; \
-         (dst)[4] = (src)[4]; (dst)[5] = (src)[5]; \
-    } while (0)
-
-#define UNIFI_MAC_ADDRESS_CMP(addr1, addr2) \
-    (((addr1)[0] == (addr2)[0]) && ((addr1)[1] == (addr2)[1]) && \
-     ((addr1)[2] == (addr2)[2]) && ((addr1)[3] == (addr2)[3]) && \
-     ((addr1)[4] == (addr2)[4]) && ((addr1)[5] == (addr2)[5]))
-
-/* Traffic queue ordered according to priority
- * EAPOL/Uncontrolled port Queue should be the last
- */
-typedef enum
-{
-    UNIFI_TRAFFIC_Q_BK = 0,
-    UNIFI_TRAFFIC_Q_BE,
-    UNIFI_TRAFFIC_Q_VI,
-    UNIFI_TRAFFIC_Q_VO,
-    UNIFI_TRAFFIC_Q_EAPOL,    /* Non existent in HIP */
-    UNIFI_TRAFFIC_Q_MAX,      /* Non existent */
-    UNIFI_TRAFFIC_Q_MLME      /* Non existent */
-} unifi_TrafficQueue;
-
-/*
- * Structure describing a bulk data slot.
- * This structure is shared between the HIP core library and the OS
- * layer. See the definition of unifi_net_data_malloc() for more details.
- *
- * The data_length field is used to indicate empty/occupied state.
- * Needs to be defined before #include "unifi_os.h".
- */
-typedef struct _bulk_data_desc
-{
-    const u8 *os_data_ptr;
-    u32       data_length;
-    const void     *os_net_buf_ptr;
-    u32       net_buf_length;
-} bulk_data_desc_t;
-
-/* Structure of an entry in the Symbol Look Up Table (SLUT). */
-typedef struct _symbol
-{
-    u16 id;
-    u32 obj;
-} symbol_t;
-
-/*
- * Header files need to be included from the current directory,
- * the SME library, the synergy framework and the OS layer.
- * A thin OS layer needs to be implemented in the porting exercise.
- *
- * Note that unifi_os.h should be included only in unifi.h
- */
-
-#include "unifi_os.h"
-
-/*
- * Contains the HIP core definitions selected in the porting exercise, such as
- * UNIFI_PAD_BULK_DATA_TO_BLOCK_SIZE and UNIFI_PAD_SIGNALS_TO_BLOCK_SIZE.
- * Implemented in the OS layer, as part of the porting exersice.
- */
-#include "unifi_config.h"
-
-#include "csr_wifi_hip_signals.h" /* from this dir */
-
-/*
- * The card structure is an opaque pointer that is used to pass context
- * to the upper-edge API functions.
- */
-typedef struct card card_t;
-
-
-/*
- * This structure describes all of the bulk data that 'might' be
- * associated with a signal.
- */
-typedef struct _bulk_data_param
-{
-    bulk_data_desc_t d[UNIFI_MAX_DATA_REFERENCES];
-} bulk_data_param_t;
-
-
-/*
- * This structure describes the chip and HIP core lib
- * information that exposed to the OS layer.
- */
-typedef struct _card_info
-{
-    u16 chip_id;
-    u16 chip_version;
-    u32 fw_build;
-    u16 fw_hip_version;
-    u32 sdio_block_size;
-} card_info_t;
-
-
-/*
- * Mini-coredump definitions
- */
-/* Definition of XAP memory ranges used by the mini-coredump system.
- * Note that, these values are NOT the same as UNIFI_REGISTERS, etc
- * in unifihw.h which don't allow selection of register areas for each XAP.
- */
-typedef enum unifi_coredump_space
-{
-    UNIFI_COREDUMP_MAC_REG,
-    UNIFI_COREDUMP_PHY_REG,
-    UNIFI_COREDUMP_SH_DMEM,
-    UNIFI_COREDUMP_MAC_DMEM,
-    UNIFI_COREDUMP_PHY_DMEM,
-    UNIFI_COREDUMP_TRIGGER_MAGIC = 0xFEED
-} unifi_coredump_space_t;
-
-/* Structure used to request a register value from a mini-coredump buffer */
-typedef struct unifi_coredump_req
-{
-    /* From user */
-    s32               index;       /* 0=newest, -1=oldest */
-    unifi_coredump_space_t space;       /* memory space */
-    u32              offset;      /* register offset in space */
-    /* From driver */
-    u32 drv_build;                /* Driver build id */
-    u32 chip_ver;                 /* Chip version */
-    u32 fw_ver;                   /* Firmware version */
-    s32  requestor;                /* Requestor: 0=auto dump, 1=manual */
-    u32 timestamp;                /* time of capture by driver */
-    u32 serial;                   /* capture serial number */
-    s32  value;                    /* register value */
-} unifi_coredump_req_t;                 /* mini-coredumped reg value request */
-
-
-/**
- * @defgroup upperedge Upper edge API
- *
- * The following functions are implemented in the HIP core lib.
- */
-
-/**
- *
- * Initialise the HIP core lib.
- * Note that the OS layer must initialise the SDIO glue layer and obtain
- * an SDIO function context, prior to this call.
- *
- * @param sdiopriv the SDIO function context.
- *
- * @param ospriv the OS layer context.
- *
- * @return \p card_t the HIP core lib API context.
- *
- * @ingroup upperedge
- */
-card_t* unifi_alloc_card(CsrSdioFunction *sdiopriv, void *ospriv);
-
-
-/**
- *
- * Initialise the UniFi chip.
- *
- * @param card the HIP core lib API context.
- *
- * @param led_mask the led mask to apply to UniFi.
- *
- * @return \b 0 if UniFi is initialized.
- *
- * @return \b -CSR_EIO if an I/O error occurred while initializing UniFi
- *
- * @return \b -CSR_ENODEV if the card is no longer present.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_init_card(card_t *card, s32 led_mask);
-
-/**
- *
- * De-Initialise the HIP core lib.
- *
- * @param card the HIP core lib API context.
- *
- * @ingroup upperedge
- */
-void unifi_free_card(card_t *card);
-
-/**
- *
- * Cancel all the signals pending in the HIP core lib.
- * Normally used during a system suspend when the power is retained on UniFi.
- *
- * @param card the HIP core lib API context.
- *
- * @ingroup upperedge
- */
-void unifi_cancel_pending_signals(card_t *card);
-
-/**
- *
- * Send a signal to UniFi.
- * Normally it is called from unifi_sys_hip_req() and the OS layer
- * Tx data plane.
- *
- * Note that the bulkdata buffers ownership is passed to the HIP core lib.
- * These buffers must be allocated using unifi_net_data_malloc().
- *
- * @param card the HIP core lib API context.
- *
- * @param sigptr pointer to the signal.
- *
- * @param siglen size of the signal.
- *
- * @param bulkdata pointer to the bulk data associated with the signal.
- *
- * @return \b 0 signal is sent.
- *
- * @return \b -CSR_EIO if an error occurred while sending the signal
- *
- * @return \b -CSR_ENODEV if the card is no longer present.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_send_signal(card_t *card, const u8 *sigptr,
-                            u32 siglen,
-                            const bulk_data_param_t *bulkdata);
-
-/**
- *
- * Check if the HIP core lib has resources to send a signal.
- * Normally there no need to use this function.
- *
- * @param card the HIP core lib API context.
- *
- * @param sigptr pointer to the signal.
- *
- * @return \b 0 if there are resources for the signal.
- *
- * @return \b -CSR_ENOSPC if there are not enough resources
- *
- * @ingroup upperedge
- */
-CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr);
-
-/**
- *
- * Read the UniFi chip and the HIP core lib information.
- *
- * @param card the HIP core lib API context.
- *
- * @param card_info pointer to save the information.
- *
- * @ingroup upperedge
- */
-void unifi_card_info(card_t *card, card_info_t *card_info);
-
-/**
- *
- * Print the UniFi I/O and Interrupt status.
- * Normally it is used for debug purposes only.
- *
- * @param card the HIP core lib API context.
-
- * @param status buffer for the chip status
- *
- * @return \b 0 if the check was performed.
- *
- * @return \b -CSR_EIO if an error occurred while checking the status.
- *
- * @return \b -CSR_ENODEV if the card is no longer present.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_check_io_status(card_t *card, s32 *status);
-
-
-/**
- *
- * Run the HIP core lib Botton-Half.
- * Whenever the HIP core lib want this function to be called
- * by the OS layer, it calls unifi_run_bh().
- *
- * @param card the HIP core lib API context.
- *
- * @param remaining pointer to return the time (in msecs) that this function
- * should be re-scheduled. A return value of 0 means that no re-scheduling
- * is required. If unifi_bh() is called before the timeout expires,
- * the caller must pass in the remaining time.
- *
- * @return \b 0 if no error occurred.
- *
- * @return \b -CSR_ENODEV if the card is no longer present.
- *
- * @return \b -CSR_E* if an error occurred while running the bottom half.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_bh(card_t *card, u32 *remaining);
-
-
-/**
- * UniFi Low Power Mode (Deep Sleep Signaling)
- *
- * unifi_low_power_mode defines the UniFi Deep Sleep Signaling status.
- * Use with unifi_configure_low_power_mode() to enable/disable
- * the Deep Sleep Signaling.
- */
-enum unifi_low_power_mode
-{
-    UNIFI_LOW_POWER_DISABLED,
-    UNIFI_LOW_POWER_ENABLED
-};
-
-/**
- * Periodic Wake Host Mode
- *
- * unifi_periodic_wake_mode defines the Periodic Wake Host Mode.
- * It can only be set to UNIFI_PERIODIC_WAKE_HOST_ENABLED if
- * low_power_mode == UNIFI_LOW_POWER_ENABLED.
- */
-enum unifi_periodic_wake_mode
-{
-    UNIFI_PERIODIC_WAKE_HOST_DISABLED,
-    UNIFI_PERIODIC_WAKE_HOST_ENABLED
-};
-
-/**
- *
- * Run the HIP core lib Botton-Half.
- * Whenever the HIP core lib want this function to be called
- * by the OS layer, it calls unifi_run_bh().
- *
- * Typically, the SME is responsible for configuring these parameters,
- * so unifi_sys_configure_power_mode_req() is usually implemented
- * as a direct call to unifi_configure_low_power_mode().
- *
- * Note: When polling mode is used instead of interrupts,
- * low_power_mode must never be set to UNIFI_LOW_POWER_ENABLED.
- *
- * @param card the HIP core lib API context.
- *
- * @param low_power_mode the Low Power Mode.
- *
- * @param periodic_wake_mode the Periodic Wake Mode.
- *
- * @return \b 0 if no error occurred.
- *
- * @return \b -CSR_E* if the request failed.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_configure_low_power_mode(card_t                       *card,
-                                         enum unifi_low_power_mode     low_power_mode,
-                                         enum unifi_periodic_wake_mode periodic_wake_mode);
-
-/**
- *
- * Forces the UniFi chip to enter a Deep Sleep state.
- * This is normally called by the OS layer when the platform suspends.
- *
- * Note that if the UniFi Low Power Mode is disabled this call fails.
- *
- * @param card the HIP core lib API context.
- *
- * @return \b 0 if no error occurred.
- *
- * @return \b -CSR_ENODEV if the card is no longer present.
- *
- * @return \b -CSR_E* if the request failed.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_force_low_power_mode(card_t *card);
-
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-/**
- * Configure the Traffic Analysis sampling
- *
- * Enable or disable statistics gathering.
- * Enable or disable particular packet detection.
- *
- * @param card the HIP core context
- * @param config_type the item to configure
- * @param config pointer to struct containing config info
- *
- * @return \b 0 if configuration was successful
- *
- * @return \b -CSR_EINVAL if a parameter had an invalid value
- *
- * @ingroup upperedge
- */
-CsrResult unifi_ta_configure(card_t                               *card,
-                             CsrWifiRouterCtrlTrafficConfigType    config_type,
-                             const CsrWifiRouterCtrlTrafficConfig *config);
-
-/**
- * Pass a packet for Traffic Analysis sampling
- *
- * @param card the HIP core context
- * @param direction the direction (Rx or Tx) of the frame.
- * @param data pointer to bulkdata struct containing the packet
- * @param saddr the source address of the packet
- * @param sta_macaddr the MAC address of the UniFi chip
- * @param timestamp the current time in msecs
- *
- * @ingroup upperedge
- */
-void unifi_ta_sample(card_t                            *card,
-                     CsrWifiRouterCtrlProtocolDirection direction,
-                     const bulk_data_desc_t            *data,
-                     const u8                    *saddr,
-                     const u8                    *sta_macaddr,
-                     u32                          timestamp,
-                     u16                          rate);
-
-/**
- * Notify the HIP core lib for a detected Traffic Classification.
- * Typically, the SME is responsible for configuring these parameters,
- * so unifi_sys_traffic_classification_req() is usually implemented
- * as a direct call to unifi_ta_classification().
- *
- * @param card the HIP core context.
- * @param traffic_type the detected traffic type.
- * @param period The detected period of the traffic.
- *
- * @ingroup upperedge
- */
-void unifi_ta_classification(card_t                      *card,
-                             CsrWifiRouterCtrlTrafficType traffic_type,
-                             u16                    period);
-
-#endif
-/**
- * Use software to hard reset the chip.
- * This is a subset of the unifi_init_card() functionality and should
- * only be used only to reset a paniced chip before a coredump is taken.
- *
- * @param card the HIP core context.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_card_hard_reset(card_t *card);
-
-
-CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len);
-CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata);
-CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data);
-
-
-enum unifi_dbg_processors_select
-{
-    UNIFI_PROC_MAC,
-    UNIFI_PROC_PHY,
-    UNIFI_PROC_BT,
-    UNIFI_PROC_BOTH,
-    UNIFI_PROC_INVALID
-};
-
-CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which);
-
-/**
- * Call-outs from the HIP core lib to the OS layer.
- * The following functions need to be implemented during the porting exercise.
- */
-
-/**
- * Selects appropriate queue according to priority
- * Helps maintain uniformity in queue selection between the HIP
- * and the OS layers.
- *
- * @param priority priority of the packet
- *
- * @return \b Traffic queue to which a packet of this priority belongs
- *
- * @ingroup upperedge
- */
-unifi_TrafficQueue
-unifi_frame_priority_to_queue(CSR_PRIORITY priority);
-
-/**
- * Returns the priority corresponding to a particular Queue when that is used
- * when downgrading a packet to a lower AC.
- * Helps maintain uniformity in queue - priority mapping between the HIP
- * and the OS layers.
- *
- * @param queue
- *
- * @return \b Highest priority corresponding to this queue
- *
- * @ingroup upperedge
- */
-CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue);
-
-/**
- *
- * Flow control callbacks.
- * unifi_pause_xmit() is called when the HIP core lib does not have any
- * resources to store data packets. The OS layer needs to pause
- * the Tx data plane until unifi_restart_xmit() is called.
- *
- * @param ospriv the OS layer context.
- *
- * @ingroup upperedge
- */
-void unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue);
-void unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue);
-
-/**
- *
- * Request to run the Bottom-Half.
- * The HIP core lib calls this function to request that unifi_bh()
- * needs to be run by the OS layer. It can be called anytime, i.e.
- * when the unifi_bh() is running.
- * Since unifi_bh() is not re-entrant, usually unifi_run_bh() sets
- * an event to a thread that schedules a call to unifi_bh().
- *
- * @param ospriv the OS layer context.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_run_bh(void *ospriv);
-
-/**
- *
- * Delivers a signal received from UniFi to the OS layer.
- * Normally, the data signals should be delivered to the data plane
- * and all the rest to the SME (unifi_sys_hip_ind()).
- *
- * Note that the OS layer is responsible for freeing the bulkdata
- * buffers, using unifi_net_data_free().
- *
- * @param ospriv the OS layer context.
- *
- * @param sigptr pointer to the signal.
- *
- * @param siglen size of the signal.
- *
- * @param bulkdata pointer to the bulk data associated with the signal.
- *
- * @ingroup upperedge
- */
-void unifi_receive_event(void *ospriv,
-                         u8 *sigdata, u32 siglen,
-                         const bulk_data_param_t *bulkdata);
-
-#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
-/**
- *
- * Used to reque the failed ma packet request back to hal queues
- *
- * @param ospriv the OS layer context.
- *
- * @param host_tag host tag for the packet to requeue.
- *
- * @param bulkDataDesc pointer to the bulk data.
- *
- * @ingroup upperedge
- */
-CsrResult unifi_reque_ma_packet_request(void *ospriv, u32 host_tag,
-                                        u16 status,
-                                        bulk_data_desc_t *bulkDataDesc);
-
-#endif
-typedef struct
-{
-    u16 free_fh_sig_queue_slots[UNIFI_NO_OF_TX_QS];
-    u16 free_fh_bulkdata_slots;
-    u16 free_fh_fw_slots;
-} unifi_HipQosInfo;
-
-void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo);
-
-
-/**
- * Functions that read a portion of a firmware file.
- *
- * Note: If the UniFi chip runs the f/w from ROM, the HIP core may never
- * call these functions. Also, the HIP core may call these functions even if
- * a f/w file is not available. In this case, it is safe to fail the request.
- */
-#define UNIFI_FW_STA    1   /* Identify STA firmware file */
-
-/**
- *
- * Ask the OS layer to initialise a read from a f/w file.
- *
- * @param ospriv the OS layer context.
- *
- * @param is_fw if 0 the request if for the loader file, if 1 the request
- * is for a f/w file.
- *
- * @param info a card_info_t structure containing versions information.
- * Note that some members of the structure may not be initialised.
- *
- * @return \p NULL if the file is not available, or a pointer which contains
- * OS specific information for the file (typically the contents of the file)
- * that the HIP core uses when calling unifi_fw_read() and unifi_fw_read_stop()
- *
- * @ingroup upperedge
- */
-void* unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info);
-
-/**
- *
- * Ask the OS layer to return a portion from a f/w file.
- *
- * @param ospriv the OS layer context.
- *
- * @param arg the OS pointer returned by unifi_fw_read_start().
- *
- * @param offset the offset in the f/w file to read the read from.
- *
- * @param buf the buffer to store the returned data.
- *
- * @param len the size in bytes of the requested read.
- *
- * @ingroup upperedge
- */
-s32 unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len);
-
-/**
- *
- * Ask the OS layer to finish reading from a f/w file.
- *
- * @param ospriv the OS layer context.
- *
- * @param dlpriv the OS pointer returned by unifi_fw_read_start().
- *
- * @ingroup upperedge
- */
-void unifi_fw_read_stop(void *ospriv, void *dlpriv);
-
-/**
- *
- * Ask OS layer for a handle to a dynamically allocated firmware buffer
- * (primarily intended for production test images which may need conversion)
- *
- * @param ospriv the OS layer context.
- *
- * @param fwbuf pointer to dynamically allocated buffer
- *
- * @param len length of provided buffer in bytes
- *
- * @ingroup upperedge
- */
-void* unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len);
-
-/**
- *
- * Release a handle to a dynamically allocated firmware buffer
- * (primarily intended for production test images which may need conversion)
- *
- * @param ospriv the OS layer context.
- *
- * @param fwbuf pointer to dynamically allocated buffer
- *
- * @ingroup upperedge
- */
-void unifi_fw_close_buffer(void *ospriv, void *fwbuf);
-
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-/*
- * Driver must provide these.
- *
- * A simple implementation will just call
- * unifi_sys_traffic_protocol_ind() or unifi_sys_traffic_classification_ind()
- * respectively. See sme_csr_userspace/sme_userspace.c.
- */
-/**
- *
- * Indicates a detected packet of type packet_type.
- * Typically, this information is processed by the SME so
- * unifi_ta_indicate_protocol() needs to schedule a call to
- * unifi_sys_traffic_protocol_ind().
- *
- * @param ospriv the OS layer context.
- *
- * @param packet_type the detected packet type.
- *
- * @param direction the direction of the packet (Rx, Tx).
- *
- * @param src_addr the source address of the packet.
- *
- * @ingroup upperedge
- */
-void unifi_ta_indicate_protocol(void                              *ospriv,
-                                CsrWifiRouterCtrlTrafficPacketType packet_type,
-                                CsrWifiRouterCtrlProtocolDirection direction,
-                                const CsrWifiMacAddress           *src_addr);
-
-/**
- *
- * Indicates statistics for the sample data over a period.
- * Typically, this information is processed by the SME so
- * unifi_ta_indicate_sampling() needs to schedule a call to
- * unifi_sys_traffic_sample_ind().
- *
- * @param ospriv the OS layer context.
- *
- * @param stats the pointer to the structure that contains the statistics.
- *
- * @ingroup upperedge
- */
-void unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats);
-void unifi_ta_indicate_l4stats(void     *ospriv,
-                               u32 rxTcpThroughput,
-                               u32 txTcpThroughput,
-                               u32 rxUdpThroughput,
-                               u32 txUdpThroughput);
-#endif
-
-void unifi_rx_queue_flush(void *ospriv);
-
-/**
- * Call-out from the SDIO glue layer.
- *
- * The glue layer needs to call unifi_sdio_interrupt_handler() every time
- * an interrupts occurs.
- *
- * @param card the HIP core context.
- *
- * @ingroup bottomedge
- */
-void unifi_sdio_interrupt_handler(card_t *card);
-
-
-/* HELPER FUNCTIONS */
-
-/*
- * unifi_init() and unifi_download() implement a subset of unifi_init_card functionality
- * that excludes HIP initialization.
- */
-CsrResult unifi_init(card_t *card);
-CsrResult unifi_download(card_t *card, s32 led_mask);
-
-/*
- * unifi_start_processors() ensures both on-chip processors are running
- */
-CsrResult unifi_start_processors(card_t *card);
-
-CsrResult unifi_capture_panic(card_t *card);
-
-/*
- * Configure HIP interrupt processing mode
- */
-#define CSR_WIFI_INTMODE_DEFAULT        0
-#define CSR_WIFI_INTMODE_RUN_BH_ONCE    1       /* Run BH once per interrupt */
-
-void unifi_set_interrupt_mode(card_t *card, u32 mode);
-
-/*
- * unifi_request_max_clock() requests that max SDIO clock speed is set at the
- * next suitable opportunity.
- */
-void unifi_request_max_sdio_clock(card_t *card);
-
-
-/* Functions to lookup bulk data command names. */
-const char* lookup_bulkcmd_name(u16 id);
-
-/* Function to log HIP's global debug buffer */
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-void unifi_debug_buf_dump(void);
-void unifi_debug_log_to_buf(const char *fmt, ...);
-void unifi_debug_hex_to_buf(const char *buff, u16 length);
-#endif
-
-/* Mini-coredump utility functions */
-CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req);
-CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req);
-CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable);
-CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers);
-void unifi_coredump_free(card_t *card);
-
-#endif /* __CSR_WIFI_HIP_UNIFI_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c b/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c
deleted file mode 100644 (file)
index 9a35285..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include "csr_wifi_hip_unifi.h"
-
-struct sig_name {
-       s16 id;
-       const char *name;
-};
-
-static const struct sig_name Unifi_bulkcmd_names[] = {
-       { 0, "SignalCmd" },
-       { 1, "CopyToHost" },
-       { 2, "CopyToHostAck" },
-       { 3, "CopyFromHost" },
-       { 4, "CopyFromHostAck" },
-       { 5, "ClearSlot" },
-       { 6, "CopyOverlay" },
-       { 7, "CopyOverlayAck" },
-       { 8, "CopyFromHostAndClearSlot" },
-       { 15, "Padding" }
-};
-
-const char *lookup_bulkcmd_name(u16 id)
-{
-       if (id < 9)
-               return Unifi_bulkcmd_names[id].name;
-       if (id == 15)
-               return "Padding";
-
-       return "UNKNOWN";
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
deleted file mode 100644 (file)
index 4126e85..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     csr_wifi_hip_unifi_udi.h
- *
- *  PURPOSE:
- *      Declarations and definitions for the UniFi Debug Interface.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __CSR_WIFI_HIP_UNIFI_UDI_H__
-#define __CSR_WIFI_HIP_UNIFI_UDI_H__
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_signals.h"
-
-
-/*
- * Support for tracing the wire protocol.
- */
-enum udi_log_direction
-{
-    UDI_LOG_FROM_HOST   = 0x0000,
-    UDI_LOG_TO_HOST     = 0x0001
-};
-
-typedef void (*udi_func_t)(void *ospriv, u8 *sigdata,
-                           u32 signal_len,
-                           const bulk_data_param_t *bulkdata,
-                           enum udi_log_direction dir);
-
-CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn);
-CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn);
-
-
-/*
- * Function to print current status info to a string.
- * This is used in the linux /proc interface and might be useful
- * in other systems.
- */
-s32 unifi_print_status(card_t *card, struct seq_file *m);
-
-#endif /* __CSR_WIFI_HIP_UNIFI_UDI_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_unifihw.h b/drivers/staging/csr/csr_wifi_hip_unifihw.h
deleted file mode 100644 (file)
index 3f9fcbd..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *
- * File: csr_wifi_hip_unifihw.h
- *
- *      Definitions of various chip registers, addresses, values etc.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __UNIFIHW_H__
-#define __UNIFIHW_H__ 1
-
-/* Symbol Look Up Table fingerprint. IDs are in sigs.h */
-#define SLUT_FINGERPRINT        0xD397
-
-
-/* Values of LoaderOperation */
-#define UNIFI_LOADER_IDLE       0x00
-#define UNIFI_LOADER_COPY       0x01
-#define UNIFI_LOADER_ERROR_MASK 0xF0
-
-/* Values of BootLoaderOperation */
-#define UNIFI_BOOT_LOADER_IDLE       0x00
-#define UNIFI_BOOT_LOADER_RESTART    0x01
-#define UNIFI_BOOT_LOADER_PATCH      0x02
-#define UNIFI_BOOT_LOADER_LOAD_STA   0x10
-#define UNIFI_BOOT_LOADER_LOAD_PTEST 0x11
-
-
-/* Memory spaces encoded in top byte of Generic Pointer type */
-#define UNIFI_SH_DMEM   0x01    /* Shared Data Memory */
-#define UNIFI_EXT_FLASH 0x02    /* External FLASH */
-#define UNIFI_EXT_SRAM  0x03    /* External SRAM */
-#define UNIFI_REGISTERS 0x04    /* Registers */
-#define UNIFI_PHY_DMEM  0x10    /* PHY Data Memory */
-#define UNIFI_PHY_PMEM  0x11    /* PHY Program Memory */
-#define UNIFI_PHY_ROM   0x12    /* PHY ROM */
-#define UNIFI_MAC_DMEM  0x20    /* MAC Data Memory */
-#define UNIFI_MAC_PMEM  0x21    /* MAC Program Memory */
-#define UNIFI_MAC_ROM   0x22    /* MAC ROM */
-#define UNIFI_BT_DMEM   0x30    /* BT Data Memory */
-#define UNIFI_BT_PMEM   0x31    /* BT Program Memory */
-#define UNIFI_BT_ROM    0x32    /* BT ROM */
-
-#define UNIFI_MAKE_GP(R, O)  (((UNIFI_ ## R) << 24) | (O))
-#define UNIFI_GP_OFFSET(GP)  ((GP) & 0xFFFFFF)
-#define UNIFI_GP_SPACE(GP)   (((GP) >> 24) & 0xFF)
-
-#endif /* __UNIFIHW_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_unifiversion.h b/drivers/staging/csr/csr_wifi_hip_unifiversion.h
deleted file mode 100644 (file)
index d1c6678..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     unifiversion.h
- *
- *  PURPOSE:
- *      Version information for the portable UniFi driver.
- *
- * ---------------------------------------------------------------------------
- */
-
-#ifndef __UNIFIVERSION_H__
-#define __UNIFIVERSION_H__
-
-/*
- * The minimum version of Host Interface Protocol required by the driver.
- */
-#define UNIFI_HIP_MAJOR_VERSION 9
-#define UNIFI_HIP_MINOR_VERSION 1
-
-#endif /* __UNIFIVERSION_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.c b/drivers/staging/csr/csr_wifi_hip_xbv.c
deleted file mode 100644 (file)
index 050a15f..0000000
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- * FILE: csr_wifi_hip_xbv.c
- *
- * PURPOSE:
- *      Routines for downloading firmware to UniFi.
- *
- *      UniFi firmware files use a nested TLV (Tag-Length-Value) format.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/slab.h>
-
-#ifdef CSR_WIFI_XBV_TEST
-/* Standalone test harness */
-#include "unifi_xbv.h"
-#include "csr_wifi_hip_unifihw.h"
-#else
-/* Normal driver build */
-#include "csr_wifi_hip_unifiversion.h"
-#include "csr_wifi_hip_card.h"
-#define DBG_TAG(t)
-#endif
-
-#include "csr_wifi_hip_xbv.h"
-
-#define STREAM_CHECKSUM 0x6d34        /* Sum of uint16s in each patch stream */
-
-/* XBV sizes used in patch conversion
- */
-#define PTDL_MAX_SIZE 2048            /* Max bytes allowed per PTDL */
-#define PTDL_HDR_SIZE (4 + 2 + 6 + 2) /* sizeof(fw_id, sec_len, patch_cmd, csum) */
-
-/* Struct to represent a buffer for reading firmware file */
-
-typedef struct
-{
-    void      *dlpriv;
-    s32   ioffset;
-    fwreadfn_t iread;
-} ct_t;
-
-/* Struct to represent a TLV field */
-typedef struct
-{
-    char t_name[4];
-    u32     t_len;
-} tag_t;
-
-
-#define TAG_EQ(i, v)    (((i)[0] == (v)[0]) &&  \
-                         ((i)[1] == (v)[1]) &&  \
-                         ((i)[2] == (v)[2]) &&  \
-                         ((i)[3] == (v)[3]))
-
-/* We create a small stack on the stack that contains an enum
- * indicating the containing list segments, and the offset at which
- * those lists end.  This enables a lot more error checking. */
-typedef enum
-{
-    xbv_xbv1,
-    /*xbv_info,*/
-    xbv_fw,
-    xbv_vers,
-    xbv_vand,
-    xbv_ptch,
-    xbv_other
-} xbv_container;
-
-#define XBV_STACK_SIZE 6
-#define XBV_MAX_OFFS   0x7fffffff
-
-typedef struct
-{
-    struct
-    {
-        xbv_container container;
-        s32      ioffset_end;
-    } s[XBV_STACK_SIZE];
-    u32 ptr;
-} xbv_stack_t;
-
-static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag);
-static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len);
-static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len);
-static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
-                          xbv_mode new_mode, xbv_container old_cont);
-static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack,
-                         xbv_mode new_mode, xbv_container old_cont,
-                         xbv_container new_cont, u32 ioff);
-
-static u32 write_uint16(void *buf, const u32 offset,
-                              const u16 val);
-static u32 write_uint32(void *buf, const u32 offset,
-                              const u32 val);
-static u32 write_bytes(void *buf, const u32 offset,
-                             const u8 *data, const u32 len);
-static u32 write_tag(void *buf, const u32 offset,
-                           const char *tag_str);
-static u32 write_chunk(void *buf, const u32 offset,
-                             const char *tag_str,
-                             const u32 payload_len);
-static u16 calc_checksum(void *buf, const u32 offset,
-                               const u32 bytes_len);
-static u32 calc_patch_size(const xbv1_t *fwinfo);
-
-static u32 write_xbv_header(void *buf, const u32 offset,
-                                  const u32 file_payload_length);
-static u32 write_ptch_header(void *buf, const u32 offset,
-                                   const u32 fw_id);
-static u32 write_patchcmd(void *buf, const u32 offset,
-                                const u32 dst_genaddr, const u16 len);
-static u32 write_reset_ptdl(void *buf, const u32 offset,
-                                  const xbv1_t *fwinfo, u32 fw_id);
-static u32 write_fwdl_to_ptdl(void *buf, const u32 offset,
-                                    fwreadfn_t readfn, const struct FWDL *fwdl,
-                                    const void *fw_buf, const u32 fw_id,
-                                    void *rdbuf);
-
-/*
- * ---------------------------------------------------------------------------
- *  parse_xbv1
- *
- *      Scan the firmware file to find the TLVs we are interested in.
- *      Actions performed:
- *        - check we support the file format version in VERF
- *      Store these TLVs if we have a firmware image:
- *        - SLTP Symbol Lookup Table Pointer
- *        - FWDL firmware download segments
- *        - FWOL firmware overlay segment
- *        - VMEQ Register probe tests to verify matching h/w
- *      Store these TLVs if we have a patch file:
- *        - FWID the firmware build ID that this file patches
- *        - PTDL The actual patches
- *
- *      The structure pointed to by fwinfo is cleared and
- *      'fwinfo->mode' is set to 'unknown'.  The 'fwinfo->mode'
- *      variable is set to 'firmware' or 'patch' once we know which
- *      sort of XBV file we have.
- *
- *  Arguments:
- *      readfn          Pointer to function to call to read from the file.
- *      dlpriv          Opaque pointer arg to pass to readfn.
- *      fwinfo          Pointer to fwinfo struct to fill in.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR error code on failure
- * ---------------------------------------------------------------------------
- */
-CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo)
-{
-    ct_t ct;
-    tag_t tag;
-    xbv_stack_t stack;
-
-    ct.dlpriv = dlpriv;
-    ct.ioffset = 0;
-    ct.iread = readfn;
-
-    memset(fwinfo, 0, sizeof(xbv1_t));
-    fwinfo->mode = xbv_unknown;
-
-    /* File must start with XBV1 triplet */
-    if (read_tag(card, &ct, &tag) <= 0)
-    {
-        unifi_error(NULL, "File is not UniFi firmware\n");
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    DBG_TAG(tag.t_name);
-
-    if (!TAG_EQ(tag.t_name, "XBV1"))
-    {
-        unifi_error(NULL, "File is not UniFi firmware (%s)\n", tag.t_name);
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    stack.ptr = 0;
-    stack.s[stack.ptr].container = xbv_xbv1;
-    stack.s[stack.ptr].ioffset_end = XBV_MAX_OFFS;
-
-    /* Now scan the file */
-    while (1)
-    {
-        s32 n;
-
-        n = read_tag(card, &ct, &tag);
-        if (n < 0)
-        {
-            unifi_error(NULL, "No tag\n");
-            return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-        }
-        if (n == 0)
-        {
-            /* End of file */
-            break;
-        }
-
-        DBG_TAG(tag.t_name);
-
-        /* File format version */
-        if (TAG_EQ(tag.t_name, "VERF"))
-        {
-            u32 version;
-
-            if (xbv_check(fwinfo, &stack, xbv_unknown, xbv_xbv1) ||
-                (tag.t_len != 2) ||
-                read_uint(card, &ct, &version, 2))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            if (version != 0)
-            {
-                unifi_error(NULL, "Unsupported firmware file version: %d.%d\n",
-                            version >> 8, version & 0xFF);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-        }
-        else if (TAG_EQ(tag.t_name, "LIST"))
-        {
-            char name[4];
-            u32 list_end;
-
-            list_end = ct.ioffset + tag.t_len;
-
-            if (read_bytes(card, &ct, name, 4))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            DBG_TAG(name);
-            if (TAG_EQ(name, "FW  "))
-            {
-                if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_xbv1, xbv_fw, list_end))
-                {
-                    return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-                }
-            }
-            else if (TAG_EQ(name, "VERS"))
-            {
-                if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_fw, xbv_vers, list_end) ||
-                    (fwinfo->vers.num_vand != 0))
-                {
-                    return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-                }
-            }
-            else if (TAG_EQ(name, "VAND"))
-            {
-                struct VAND *vand;
-
-                if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_vers, xbv_vand, list_end) ||
-                    (fwinfo->vers.num_vand >= MAX_VAND))
-                {
-                    return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-                }
-
-                /* Get a new VAND */
-                vand = fwinfo->vand + fwinfo->vers.num_vand++;
-
-                /* Fill it in */
-                vand->first = fwinfo->num_vmeq;
-                vand->count = 0;
-            }
-            else if (TAG_EQ(name, "PTCH"))
-            {
-                if (xbv_push(fwinfo, &stack, xbv_patch, xbv_xbv1, xbv_ptch, list_end))
-                {
-                    return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-                }
-            }
-            else
-            {
-                /* Skip over any other lists.  We dont bother to push
-                 * the new list type now as we would only pop it at
-                 * the end of the outer loop. */
-                ct.ioffset += tag.t_len - 4;
-            }
-        }
-        else if (TAG_EQ(tag.t_name, "SLTP"))
-        {
-            u32 addr;
-
-            if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
-                (tag.t_len != 4) ||
-                (fwinfo->slut_addr != 0) ||
-                read_uint(card, &ct, &addr, 4))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            fwinfo->slut_addr = addr;
-        }
-        else if (TAG_EQ(tag.t_name, "FWDL"))
-        {
-            u32 addr;
-            struct FWDL *fwdl;
-
-            if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
-                (fwinfo->num_fwdl >= MAX_FWDL) ||
-                (read_uint(card, &ct, &addr, 4)))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            fwdl = fwinfo->fwdl + fwinfo->num_fwdl++;
-
-            fwdl->dl_size = tag.t_len - 4;
-            fwdl->dl_addr = addr;
-            fwdl->dl_offset = ct.ioffset;
-
-            ct.ioffset += tag.t_len - 4;
-        }
-        else if (TAG_EQ(tag.t_name, "FWOV"))
-        {
-            if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
-                (fwinfo->fwov.dl_size != 0) ||
-                (fwinfo->fwov.dl_offset != 0))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            fwinfo->fwov.dl_size = tag.t_len;
-            fwinfo->fwov.dl_offset = ct.ioffset;
-
-            ct.ioffset += tag.t_len;
-        }
-        else if (TAG_EQ(tag.t_name, "VMEQ"))
-        {
-            u32 temp[3];
-            struct VAND *vand;
-            struct VMEQ *vmeq;
-
-            if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_vand) ||
-                (fwinfo->num_vmeq >= MAX_VMEQ) ||
-                (fwinfo->vers.num_vand == 0) ||
-                (tag.t_len != 8) ||
-                read_uint(card, &ct, &temp[0], 4) ||
-                read_uint(card, &ct, &temp[1], 2) ||
-                read_uint(card, &ct, &temp[2], 2))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            /* Get the last VAND */
-            vand = fwinfo->vand + (fwinfo->vers.num_vand - 1);
-
-            /* Get a new VMEQ */
-            vmeq = fwinfo->vmeq + fwinfo->num_vmeq++;
-
-            /* Note that this VAND contains another VMEQ */
-            vand->count++;
-
-            /* Fill in the VMEQ */
-            vmeq->addr = temp[0];
-            vmeq->mask = (u16)temp[1];
-            vmeq->value = (u16)temp[2];
-        }
-        else if (TAG_EQ(tag.t_name, "FWID"))
-        {
-            u32 build_id;
-
-            if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) ||
-                (tag.t_len != 4) ||
-                (fwinfo->build_id != 0) ||
-                read_uint(card, &ct, &build_id, 4))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            fwinfo->build_id = build_id;
-        }
-        else if (TAG_EQ(tag.t_name, "PTDL"))
-        {
-            struct PTDL *ptdl;
-
-            if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) ||
-                (fwinfo->num_ptdl >= MAX_PTDL))
-            {
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-
-            /* Allocate a new PTDL */
-            ptdl = fwinfo->ptdl + fwinfo->num_ptdl++;
-
-            ptdl->dl_size = tag.t_len;
-            ptdl->dl_offset = ct.ioffset;
-
-            ct.ioffset += tag.t_len;
-        }
-        else
-        {
-            /*
-             * If we get here it is a tag we are not interested in,
-             * just skip over it.
-             */
-            ct.ioffset += tag.t_len;
-        }
-
-        /* Check to see if we are at the end of the currently stacked
-         * segment.  We could finish more than one list at a time. */
-        while (ct.ioffset >= stack.s[stack.ptr].ioffset_end)
-        {
-            if (ct.ioffset > stack.s[stack.ptr].ioffset_end)
-            {
-                unifi_error(NULL,
-                            "XBV file has overrun stack'd segment %d (%d > %d)\n",
-                            stack.ptr, ct.ioffset, stack.s[stack.ptr].ioffset_end);
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            if (stack.ptr <= 0)
-            {
-                unifi_error(NULL, "XBV file has underrun stack pointer\n");
-                return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-            }
-            stack.ptr--;
-        }
-    }
-
-    if (stack.ptr != 0)
-    {
-        unifi_error(NULL, "Last list of XBV is not complete.\n");
-        return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* xbv1_parse() */
-
-
-/* Check the the XBV file is of a consistant sort (either firmware or
- * patch) and that we are in the correct containing list type. */
-static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
-                          xbv_mode new_mode, xbv_container old_cont)
-{
-    /* If the new file mode is unknown the current packet could be in
-     * either (any) type of XBV file, and we cant make a decission at
-     * this time. */
-    if (new_mode != xbv_unknown)
-    {
-        if (fwinfo->mode == xbv_unknown)
-        {
-            fwinfo->mode = new_mode;
-        }
-        else if (fwinfo->mode != new_mode)
-        {
-            return -1;
-        }
-    }
-    /* If the current stack top doesn't match what we expect then the
-     * file is corrupt. */
-    if (stack->s[stack->ptr].container != old_cont)
-    {
-        return -1;
-    }
-    return 0;
-}
-
-
-/* Make checks as above and then enter a new list */
-static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack,
-                         xbv_mode new_mode, xbv_container old_cont,
-                         xbv_container new_cont, u32 new_ioff)
-{
-    if (xbv_check(fwinfo, stack, new_mode, old_cont))
-    {
-        return -1;
-    }
-
-    /* Check that our stack won't overflow. */
-    if (stack->ptr >= (XBV_STACK_SIZE - 1))
-    {
-        return -1;
-    }
-
-    /* Add the new list element to the top of the stack. */
-    stack->ptr++;
-    stack->s[stack->ptr].container = new_cont;
-    stack->s[stack->ptr].ioffset_end = new_ioff;
-
-    return 0;
-}
-
-
-static u32 xbv2uint(u8 *ptr, s32 len)
-{
-    u32 u = 0;
-    s16 i;
-
-    for (i = 0; i < len; i++)
-    {
-        u32 b;
-        b = ptr[i];
-        u += b << (i * 8);
-    }
-    return u;
-}
-
-
-static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag)
-{
-    u8 buf[8];
-    s32 n;
-
-    n = (*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, 8);
-    if (n <= 0)
-    {
-        return n;
-    }
-
-    /* read the tag and length */
-    if (n != 8)
-    {
-        return -1;
-    }
-
-    /* get section tag */
-    memcpy(tag->t_name, buf, 4);
-
-    /* get section length */
-    tag->t_len = xbv2uint(buf + 4, 4);
-
-    ct->ioffset += 8;
-
-    return 8;
-} /* read_tag() */
-
-
-static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len)
-{
-    /* read the tag value */
-    if ((*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, len) != (s32)len)
-    {
-        return -1;
-    }
-
-    ct->ioffset += len;
-
-    return 0;
-} /* read_bytes() */
-
-
-static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len)
-{
-    u8 buf[4];
-
-    /* Integer cannot be more than 4 bytes */
-    if (len > 4)
-    {
-        return -1;
-    }
-
-    if (read_bytes(card, ct, buf, len))
-    {
-        return -1;
-    }
-
-    *u = xbv2uint(buf, len);
-
-    return 0;
-} /* read_uint() */
-
-
-static u32 write_uint16(void *buf, const u32 offset, const u16 val)
-{
-    u8 *dst = (u8 *)buf + offset;
-    *dst++ = (u8)(val & 0xff); /* LSB first */
-    *dst = (u8)(val >> 8);
-    return sizeof(u16);
-}
-
-
-static u32 write_uint32(void *buf, const u32 offset, const u32 val)
-{
-    (void)write_uint16(buf, offset + 0, (u16)(val & 0xffff));
-    (void)write_uint16(buf, offset + 2, (u16)(val >> 16));
-    return sizeof(u32);
-}
-
-
-static u32 write_bytes(void *buf, const u32 offset, const u8 *data, const u32 len)
-{
-    u32 i;
-    u8 *dst = (u8 *)buf + offset;
-
-    for (i = 0; i < len; i++)
-    {
-        *dst++ = *((u8 *)data + i);
-    }
-    return len;
-}
-
-
-static u32 write_tag(void *buf, const u32 offset, const char *tag_str)
-{
-    u8 *dst = (u8 *)buf + offset;
-    memcpy(dst, tag_str, 4);
-    return 4;
-}
-
-
-static u32 write_chunk(void *buf, const u32 offset, const char *tag_str, const u32 payload_len)
-{
-    u32 written = 0;
-    written += write_tag(buf, offset, tag_str);
-    written += write_uint32(buf, written + offset, (u32)payload_len);
-
-    return written;
-}
-
-
-static u16 calc_checksum(void *buf, const u32 offset, const u32 bytes_len)
-{
-    u32 i;
-    u8 *src = (u8 *)buf + offset;
-    u16 sum = 0;
-    u16 val;
-
-    for (i = 0; i < bytes_len / 2; i++)
-    {
-        /* Contents copied to file is LE, host might not be */
-        val = (u16) * src++;         /* LSB */
-        val += (u16)(*src++) << 8;   /* MSB */
-        sum += val;
-    }
-
-    /* Total of uint16s in the stream plus the stored check value
-     * should equal STREAM_CHECKSUM when decoded.
-     */
-    return (STREAM_CHECKSUM - sum);
-}
-
-
-#define PTDL_RESET_DATA_SIZE  20  /* Size of reset vectors PTDL */
-
-static u32 calc_patch_size(const xbv1_t *fwinfo)
-{
-    s16 i;
-    u32 size = 0;
-
-    /*
-     * Work out how big an equivalent patch format file must be for this image.
-     * This only needs to be approximate, so long as it's large enough.
-     */
-    if (fwinfo->mode != xbv_firmware)
-    {
-        return 0;
-    }
-
-    /* Payload (which will get put into a series of PTDLs) */
-    for (i = 0; i < fwinfo->num_fwdl; i++)
-    {
-        size += fwinfo->fwdl[i].dl_size;
-    }
-
-    /* Another PTDL at the end containing reset vectors */
-    size += PTDL_RESET_DATA_SIZE;
-
-    /* PTDL headers. Add one for remainder, one for reset vectors */
-    size += ((fwinfo->num_fwdl / PTDL_MAX_SIZE) + 2) * PTDL_HDR_SIZE;
-
-    /* Another 1K sufficient to cover miscellaneous headers */
-    size += 1024;
-
-    return size;
-}
-
-
-static u32 write_xbv_header(void *buf, const u32 offset, const u32 file_payload_length)
-{
-    u32 written = 0;
-
-    /* The length value given to the XBV chunk is the length of all subsequent
-     * contents of the file, excluding the 8 byte size of the XBV1 header itself
-     * (The added 6 bytes thus accounts for the size of the VERF)
-     */
-    written += write_chunk(buf, offset + written, (char *)"XBV1", file_payload_length + 6);
-
-    written += write_chunk(buf, offset + written, (char *)"VERF", 2);
-    written += write_uint16(buf,  offset + written, 0);      /* File version */
-
-    return written;
-}
-
-
-static u32 write_ptch_header(void *buf, const u32 offset, const u32 fw_id)
-{
-    u32 written = 0;
-
-    /* LIST is written with a zero length, to be updated later */
-    written += write_chunk(buf, offset + written, (char *)"LIST", 0);
-    written += write_tag(buf, offset + written, (char *)"PTCH");        /* List type */
-
-    written += write_chunk(buf, offset + written, (char *)"FWID", 4);
-    written += write_uint32(buf, offset + written, fw_id);
-
-
-    return written;
-}
-
-
-#define UF_REGION_PHY  1
-#define UF_REGION_MAC  2
-#define UF_MEMPUT_MAC  0x0000
-#define UF_MEMPUT_PHY  0x1000
-
-static u32 write_patchcmd(void *buf, const u32 offset, const u32 dst_genaddr, const u16 len)
-{
-    u32 written = 0;
-    u32 region = (dst_genaddr >> 28);
-    u16 cmd_and_len = UF_MEMPUT_MAC;
-
-    if (region == UF_REGION_PHY)
-    {
-        cmd_and_len = UF_MEMPUT_PHY;
-    }
-    else if (region != UF_REGION_MAC)
-    {
-        return 0; /* invalid */
-    }
-
-    /* Write the command and data length */
-    cmd_and_len |= len;
-    written += write_uint16(buf, offset + written, cmd_and_len);
-
-    /* Write the destination generic address */
-    written += write_uint16(buf, offset + written, (u16)(dst_genaddr >> 16));
-    written += write_uint16(buf, offset + written, (u16)(dst_genaddr & 0xffff));
-
-    /* The data payload should be appended to the command */
-    return written;
-}
-
-
-static u32 write_fwdl_to_ptdl(void *buf, const u32 offset, fwreadfn_t readfn,
-                                    const struct FWDL *fwdl, const void *dlpriv,
-                                    const u32 fw_id, void *fw_buf)
-{
-    u32 written = 0;
-    s16 chunks = 0;
-    u32 left = fwdl->dl_size;      /* Bytes left in this fwdl */
-    u32 dl_addr = fwdl->dl_addr;   /* Target address of fwdl image on XAP */
-    u32 dl_offs = fwdl->dl_offset; /* Offset of fwdl image data in source */
-    u16 csum;
-    u32 csum_start_offs;           /* first offset to include in checksum */
-    u32 sec_data_len;              /* section data byte count */
-    u32 sec_len;                   /* section data + header byte count */
-
-    /* FWDL maps to one or more PTDLs, as max size for a PTDL is 1K words */
-    while (left)
-    {
-        /* Calculate amount to be transferred */
-        sec_data_len = min_t(u32, left, PTDL_MAX_SIZE - PTDL_HDR_SIZE);
-        sec_len = sec_data_len + PTDL_HDR_SIZE;
-
-        /* Write PTDL header + entire PTDL size */
-        written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len);
-        /* bug digest implies 4 bytes of padding here, but that seems wrong */
-
-        /* Checksum starts here */
-        csum_start_offs = offset + written;
-
-        /* Patch-chunk header: fw_id. Note that this is in XAP word order */
-        written += write_uint16(buf, offset + written, (u16)(fw_id >> 16));
-        written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff));
-
-        /* Patch-chunk header: section length in uint16s */
-        written += write_uint16(buf, offset + written, (u16)(sec_len / 2));
-
-
-        /* Write the appropriate patch command for the data's destination ptr */
-        written += write_patchcmd(buf, offset + written, dl_addr, (u16)(sec_data_len / 2));
-
-        /* Write the data itself (limited to the max chunk length) */
-        if (readfn(NULL, (void *)dlpriv, dl_offs, fw_buf, sec_data_len) < 0)
-        {
-            return 0;
-        }
-
-        written += write_bytes(buf,
-                               offset + written,
-                               fw_buf,
-                               sec_data_len);
-
-        /* u16 checksum calculated over data written */
-        csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset));
-        written += write_uint16(buf, offset + written, csum);
-
-        left -= sec_data_len;
-        dl_addr += sec_data_len;
-        dl_offs += sec_data_len;
-        chunks++;
-    }
-
-    return written;
-}
-
-
-#define SEC_CMD_LEN         ((4 + 2) * 2) /* sizeof(cmd, vector) per XAP */
-#define PTDL_VEC_HDR_SIZE   (4 + 2 + 2)   /* sizeof(fw_id, sec_len, csum) */
-#define UF_MAC_START_VEC    0x00c00000    /* Start address of image on MAC */
-#define UF_PHY_START_VEC    0x00c00000    /* Start address of image on PHY */
-#define UF_MAC_START_CMD    0x6000        /* MAC "Set start address" command */
-#define UF_PHY_START_CMD    0x7000        /* PHY "Set start address" command */
-
-static u32 write_reset_ptdl(void *buf, const u32 offset, const xbv1_t *fwinfo, u32 fw_id)
-{
-    u32 written = 0;
-    u16 csum;
-    u32 csum_start_offs;                 /* first offset to include in checksum */
-    u32 sec_len;                         /* section data + header byte count */
-
-    sec_len = SEC_CMD_LEN + PTDL_VEC_HDR_SIZE; /* Total section byte length */
-
-    /* Write PTDL header + entire PTDL size */
-    written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len);
-
-    /* Checksum starts here */
-    csum_start_offs = offset + written;
-
-    /* Patch-chunk header: fw_id. Note that this is in XAP word order */
-    written += write_uint16(buf, offset + written, (u16)(fw_id >> 16));
-    written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff));
-
-    /* Patch-chunk header: section length in uint16s */
-    written += write_uint16(buf, offset + written, (u16)(sec_len / 2));
-
-    /*
-     * Restart addresses to be executed on subsequent loader restart command.
-     */
-
-    /* Setup the MAC start address, note word ordering */
-    written += write_uint16(buf, offset + written, UF_MAC_START_CMD);
-    written += write_uint16(buf, offset + written, (UF_MAC_START_VEC >> 16));
-    written += write_uint16(buf, offset + written, (UF_MAC_START_VEC & 0xffff));
-
-    /* Setup the PHY start address, note word ordering */
-    written += write_uint16(buf, offset + written, UF_PHY_START_CMD);
-    written += write_uint16(buf, offset + written, (UF_PHY_START_VEC >> 16));
-    written += write_uint16(buf, offset + written, (UF_PHY_START_VEC & 0xffff));
-
-    /* u16 checksum calculated over data written */
-    csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset));
-    written += write_uint16(buf, offset + written, csum);
-
-    return written;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  read_slut
- *
- *      desc
- *
- *  Arguments:
- *      readfn          Pointer to function to call to read from the file.
- *      dlpriv          Opaque pointer arg to pass to readfn.
- *      addr            Offset into firmware image of SLUT.
- *      fwinfo          Pointer to fwinfo struct to fill in.
- *
- *  Returns:
- *      Number of SLUT entries in the f/w, or -1 if the image was corrupt.
- * ---------------------------------------------------------------------------
- */
-s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
-                        symbol_t *slut, u32 slut_len)
-{
-    s16 i;
-    s32 offset;
-    u32 magic;
-    u32 count = 0;
-    ct_t ct;
-
-    if (fwinfo->mode != xbv_firmware)
-    {
-        return -1;
-    }
-
-    /* Find the d/l segment containing the SLUT */
-    /* This relies on the SLUT being entirely contained in one segment */
-    offset = -1;
-    for (i = 0; i < fwinfo->num_fwdl; i++)
-    {
-        if ((fwinfo->slut_addr >= fwinfo->fwdl[i].dl_addr) &&
-            (fwinfo->slut_addr < (fwinfo->fwdl[i].dl_addr + fwinfo->fwdl[i].dl_size)))
-        {
-            offset = fwinfo->fwdl[i].dl_offset +
-                     (fwinfo->slut_addr - fwinfo->fwdl[i].dl_addr);
-        }
-    }
-    if (offset < 0)
-    {
-        return -1;
-    }
-
-    ct.dlpriv = dlpriv;
-    ct.ioffset = offset;
-    ct.iread = readfn;
-
-    if (read_uint(card, &ct, &magic, 2))
-    {
-        return -1;
-    }
-    if (magic != SLUT_FINGERPRINT)
-    {
-        return -1;
-    }
-
-    while (count < slut_len)
-    {
-        u32 id, obj;
-
-        /* Read Symbol Id */
-        if (read_uint(card, &ct, &id, 2))
-        {
-            return -1;
-        }
-
-        /* Check for end of table marker */
-        if (id == CSR_SLT_END)
-        {
-            break;
-        }
-
-        /* Read Symbol Value */
-        if (read_uint(card, &ct, &obj, 4))
-        {
-            return -1;
-        }
-
-        slut[count].id  = (u16)id;
-        slut[count].obj = obj;
-        count++;
-    }
-
-    return count;
-} /* read_slut() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  xbv_to_patch
- *
- *      Convert (the relevant parts of) a firmware xbv file into a patch xbv
- *
- *  Arguments:
- *      card
- *      fw_buf - pointer to xbv firmware image
- *      fwinfo - structure describing the firmware image
- *      size   - pointer to location into which size of f/w is written.
- *
- *  Returns:
- *      Pointer to firmware image, or NULL on error. Caller must free this
- *      buffer via kfree() once it's finished with.
- *
- *  Notes:
- *      The input fw_buf should have been checked via xbv1_parse prior to
- *      calling this function, so the input image is assumed valid.
- * ---------------------------------------------------------------------------
- */
-#define PTCH_LIST_SIZE 16         /* sizeof PTCH+FWID chunk in LIST header */
-
-void* xbv_to_patch(card_t *card, fwreadfn_t readfn,
-                   const void *fw_buf, const xbv1_t *fwinfo, u32 *size)
-{
-    void *patch_buf = NULL;
-    u32 patch_buf_size;
-    u32 payload_offs = 0;           /* Start of XBV payload */
-    s16 i;
-    u32 patch_offs = 0;
-    u32 list_len_offs = 0;          /* Offset of PTDL LIST length parameter */
-    u32 ptdl_start_offs = 0;        /* Offset of first PTDL chunk */
-    u32 fw_id;
-    void *rdbuf;
-
-    if (!fw_buf || !fwinfo || !card)
-    {
-        return NULL;
-    }
-
-    if (fwinfo->mode != xbv_firmware)
-    {
-        unifi_error(NULL, "Not a firmware file\n");
-        return NULL;
-    }
-
-    /* Pre-allocate read buffer for chunk conversion */
-    rdbuf = kmalloc(PTDL_MAX_SIZE, GFP_KERNEL);
-    if (!rdbuf)
-    {
-        unifi_error(card, "Couldn't alloc conversion buffer\n");
-        return NULL;
-    }
-
-    /* Loader requires patch file's build ID to match the running firmware's */
-    fw_id = card->build_id;
-
-    /* Firmware XBV1 contains VERF, optional INFO, SLUT(s), FWDL(s)          */
-    /* Other chunks should get skipped.                                      */
-    /* VERF should be sanity-checked against chip version                    */
-
-    /* Patch    XBV1 contains VERF, optional INFO, PTCH                      */
-    /*          PTCH contains FWID, optional INFO, PTDL(s), PTDL(start_vec)  */
-    /* Each FWDL is split into PTDLs (each is 1024 XAP words max)            */
-    /* Each PTDL contains running ROM f/w version, and checksum              */
-    /* MAC/PHY reset addresses (known) are added into a final PTDL           */
-
-    /* The input image has already been parsed, and loaded into fwinfo, so we
-     * can use that to build the output image
-     */
-    patch_buf_size = calc_patch_size(fwinfo);
-
-    patch_buf = kmalloc(patch_buf_size, GFP_KERNEL);
-    if (!patch_buf)
-    {
-        kfree(rdbuf);
-        unifi_error(NULL, "Can't malloc buffer for patch conversion\n");
-        return NULL;
-    }
-
-    memset(patch_buf, 0xdd, patch_buf_size);
-
-    /* Write XBV + VERF headers */
-    patch_offs += write_xbv_header(patch_buf, patch_offs, 0);
-    payload_offs = patch_offs;
-
-    /* Write patch (LIST) header */
-    list_len_offs = patch_offs + 4;    /* Save LIST.length offset for later update */
-    patch_offs += write_ptch_header(patch_buf, patch_offs, fw_id);
-
-    /* Save start offset of the PTDL chunks */
-    ptdl_start_offs = patch_offs;
-
-    /* Write LIST of firmware PTDL blocks */
-    for (i = 0; i < fwinfo->num_fwdl; i++)
-    {
-        patch_offs += write_fwdl_to_ptdl(patch_buf,
-                                         patch_offs,
-                                         readfn,
-                                         &fwinfo->fwdl[i],
-                                         fw_buf,
-                                         fw_id,
-                                         rdbuf);
-    }
-
-    /* Write restart-vector PTDL last */
-    patch_offs += write_reset_ptdl(patch_buf, patch_offs, fwinfo, fw_id);
-
-    /* Now the length is known, update the LIST.length */
-    (void)write_uint32(patch_buf, list_len_offs,
-                       (patch_offs - ptdl_start_offs) + PTCH_LIST_SIZE);
-
-    /* Re write XBV headers just to fill in the correct file size */
-    (void)write_xbv_header(patch_buf, 0, (patch_offs - payload_offs));
-
-    unifi_trace(card->ospriv, UDBG1, "XBV:PTCH size %u, fw_id %u\n",
-                patch_offs, fw_id);
-    if (size)
-    {
-        *size = patch_offs;
-    }
-    kfree(rdbuf);
-
-    return patch_buf;
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.h b/drivers/staging/csr/csr_wifi_hip_xbv.h
deleted file mode 100644 (file)
index 3c50723..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/*
- * ---------------------------------------------------------------------------
- * FILE: csr_wifi_hip_xbv.h
- *
- * PURPOSE:
- *      Definitions and declarations for code to read XBV files - the UniFi
- *      firmware download file format.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __XBV_H__
-#define __XBV_H__
-
-#ifndef CSR_WIFI_XBV_TEST
-/* Driver includes */
-#include "csr_wifi_hip_unifi.h"
-#endif
-
-
-struct VMEQ
-{
-    u32 addr;
-    u16 mask;
-    u16 value;
-};
-
-struct VAND
-{
-    u32 first;
-    u32 count;
-};
-
-struct VERS
-{
-    u32 num_vand;
-};
-
-struct FWDL
-{
-    u32 dl_addr;
-    u32 dl_size;
-    u32 dl_offset;
-};
-
-struct FWOV
-{
-    u32 dl_size;
-    u32 dl_offset;
-};
-
-struct PTDL
-{
-    u32 dl_size;
-    u32 dl_offset;
-};
-
-#define MAX_VMEQ 64
-#define MAX_VAND 64
-#define MAX_FWDL 256
-#define MAX_PTDL 256
-
-/* An XBV1 file can either contain firmware or patches (at the
- * moment).  The 'mode' member of the xbv1_t structure tells us which
- * one is the case. */
-typedef enum
-{
-    xbv_unknown,
-    xbv_firmware,
-    xbv_patch
-} xbv_mode;
-
-typedef struct
-{
-    xbv_mode mode;
-
-    /* Parts of a Firmware XBV1 */
-
-    struct VMEQ vmeq[MAX_VMEQ];
-    u32   num_vmeq;
-    struct VAND vand[MAX_VAND];
-    struct VERS vers;
-
-    u32 slut_addr;
-
-    /* F/W download image, possibly more than one part */
-    struct FWDL fwdl[MAX_FWDL];
-    s16    num_fwdl;
-
-    /* F/W overlay image, add r not used */
-    struct FWOV fwov;
-
-    /* Parts of a Patch XBV1 */
-
-    u32 build_id;
-
-    struct PTDL ptdl[MAX_PTDL];
-    s16    num_ptdl;
-}  xbv1_t;
-
-
-typedef s32 (*fwreadfn_t)(void *ospriv, void *dlpriv, u32 offset, void *buf, u32 len);
-
-CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo);
-s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
-                        symbol_t *slut, u32 slut_len);
-void* xbv_to_patch(card_t *card, fwreadfn_t readfn, const void *fw_buf, const xbv1_t *fwinfo,
-                   u32 *size);
-
-#endif /* __XBV_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hostio_prim.h b/drivers/staging/csr/csr_wifi_hostio_prim.h
deleted file mode 100644 (file)
index cfb3e27..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-
-#ifndef CSR_WIFI_HOSTIO_H
-#define CSR_WIFI_HOSTIO_H
-
-#define CSR_WIFI_HOSTIO_PRIM 0x0453
-
-#endif /* CSR_WIFI_HOSTIO_H */
-
diff --git a/drivers/staging/csr/csr_wifi_lib.h b/drivers/staging/csr/csr_wifi_lib.h
deleted file mode 100644 (file)
index 5fde0ef..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-#ifndef CSR_WIFI_LIB_H__
-#define CSR_WIFI_LIB_H__
-
-#include "csr_wifi_fsm_event.h"
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiFsmEventInit
- *
- *  DESCRIPTION
- *      Macro to initialise the members of a CsrWifiFsmEvent.
- *----------------------------------------------------------------------------*/
-#define CsrWifiFsmEventInit(evt, p_primtype, p_msgtype, p_dst, p_src) \
-    (evt)->primtype = p_primtype; \
-    (evt)->type = p_msgtype; \
-    (evt)->destination = p_dst; \
-    (evt)->source = p_src
-
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiEvent_struct
- *
- *  DESCRIPTION
- *      Generic message creator.
- *      Allocates and fills in a message with the signature CsrWifiEvent
- *
- *----------------------------------------------------------------------------*/
-CsrWifiFsmEvent* CsrWifiEvent_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src);
-
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u8        value;
-} CsrWifiEventCsrUint8;
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiEventCsrUint8_struct
- *
- *  DESCRIPTION
- *      Generic message creator.
- *      Allocates and fills in a message with the signature CsrWifiEventCsrUint8
- *
- *----------------------------------------------------------------------------*/
-CsrWifiEventCsrUint8* CsrWifiEventCsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u8 value);
-
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       value;
-} CsrWifiEventCsrUint16;
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiEventCsrUint16_struct
- *
- *  DESCRIPTION
- *      Generic message creator.
- *      Allocates and fills in a message with the signature CsrWifiEventCsrUint16
- *
- *----------------------------------------------------------------------------*/
-CsrWifiEventCsrUint16* CsrWifiEventCsrUint16_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value);
-
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u32       value;
-} CsrWifiEventCsrUint32;
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiEventCsrUint32_struct
- *
- *  DESCRIPTION
- *      Generic message creator.
- *      Allocates and fills in a message with the signature CsrWifiEventCsrUint32
- *
- *----------------------------------------------------------------------------*/
-CsrWifiEventCsrUint32* CsrWifiEventCsrUint32_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u32 value);
-
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       value16;
-    u8        value8;
-} CsrWifiEventCsrUint16CsrUint8;
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiEventCsrUint16CsrUint8_struct
- *
- *  DESCRIPTION
- *      Generic message creator.
- *      Allocates and fills in a message with the signature CsrWifiEventCsrUint16CsrUint8
- *
- *----------------------------------------------------------------------------*/
-CsrWifiEventCsrUint16CsrUint8* CsrWifiEventCsrUint16CsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value16, u8 value8);
-
-#endif /* CSR_WIFI_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_msgconv.h b/drivers/staging/csr/csr_wifi_msgconv.h
deleted file mode 100644 (file)
index f8b4029..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_MSGCONV_H__
-#define CSR_WIFI_MSGCONV_H__
-
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-
-void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v);
-void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v);
-void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v);
-
-void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset);
-void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset);
-void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset);
-
-void CsrUint24Ser(u8 *ptr, size_t *len, u32 v);
-void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset);
-
-
-size_t CsrWifiEventSizeof(void *msg);
-u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg);
-void* CsrWifiEventDes(u8 *buffer, size_t length);
-
-size_t CsrWifiEventCsrUint8Sizeof(void *msg);
-u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg);
-void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length);
-
-size_t CsrWifiEventCsrUint16Sizeof(void *msg);
-u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg);
-void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length);
-
-size_t CsrWifiEventCsrUint32Sizeof(void *msg);
-u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg);
-void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length);
-
-size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg);
-u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg);
-void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length);
-
-#endif /* CSR_WIFI_MSGCONV_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c
deleted file mode 100644 (file)
index 0689d6f..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#include "csr_msgconv.h"
-#include "csr_macro.h"
-
-#ifdef CSR_WIFI_NME_ENABLE
-#ifdef CSR_WIFI_AP_ENABLE
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-#endif
-
-#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE
-#include "csr_wifi_nme_ap_serialize.h"
-#include "csr_wifi_nme_ap_prim.h"
-
-static CsrMsgConvMsgEntry csrwifinmeap_conv_lut[] = {
-    { CSR_WIFI_NME_AP_CONFIG_SET_REQ, CsrWifiNmeApConfigSetReqSizeof, CsrWifiNmeApConfigSetReqSer, CsrWifiNmeApConfigSetReqDes, CsrWifiNmeApConfigSetReqSerFree },
-    { CSR_WIFI_NME_AP_WPS_REGISTER_REQ, CsrWifiNmeApWpsRegisterReqSizeof, CsrWifiNmeApWpsRegisterReqSer, CsrWifiNmeApWpsRegisterReqDes, CsrWifiNmeApWpsRegisterReqSerFree },
-    { CSR_WIFI_NME_AP_START_REQ, CsrWifiNmeApStartReqSizeof, CsrWifiNmeApStartReqSer, CsrWifiNmeApStartReqDes, CsrWifiNmeApStartReqSerFree },
-    { CSR_WIFI_NME_AP_STOP_REQ, CsrWifiNmeApStopReqSizeof, CsrWifiNmeApStopReqSer, CsrWifiNmeApStopReqDes, CsrWifiNmeApStopReqSerFree },
-    { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, CsrWifiNmeApWmmParamUpdateReqSizeof, CsrWifiNmeApWmmParamUpdateReqSer, CsrWifiNmeApWmmParamUpdateReqDes, CsrWifiNmeApWmmParamUpdateReqSerFree },
-    { CSR_WIFI_NME_AP_STA_REMOVE_REQ, CsrWifiNmeApStaRemoveReqSizeof, CsrWifiNmeApStaRemoveReqSer, CsrWifiNmeApStaRemoveReqDes, CsrWifiNmeApStaRemoveReqSerFree },
-    { CSR_WIFI_NME_AP_CONFIG_SET_CFM, CsrWifiNmeApConfigSetCfmSizeof, CsrWifiNmeApConfigSetCfmSer, CsrWifiNmeApConfigSetCfmDes, CsrWifiNmeApConfigSetCfmSerFree },
-    { CSR_WIFI_NME_AP_WPS_REGISTER_CFM, CsrWifiNmeApWpsRegisterCfmSizeof, CsrWifiNmeApWpsRegisterCfmSer, CsrWifiNmeApWpsRegisterCfmDes, CsrWifiNmeApWpsRegisterCfmSerFree },
-    { CSR_WIFI_NME_AP_START_CFM, CsrWifiNmeApStartCfmSizeof, CsrWifiNmeApStartCfmSer, CsrWifiNmeApStartCfmDes, CsrWifiNmeApStartCfmSerFree },
-    { CSR_WIFI_NME_AP_STOP_CFM, CsrWifiNmeApStopCfmSizeof, CsrWifiNmeApStopCfmSer, CsrWifiNmeApStopCfmDes, CsrWifiNmeApStopCfmSerFree },
-    { CSR_WIFI_NME_AP_STOP_IND, CsrWifiNmeApStopIndSizeof, CsrWifiNmeApStopIndSer, CsrWifiNmeApStopIndDes, CsrWifiNmeApStopIndSerFree },
-    { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, CsrWifiNmeApWmmParamUpdateCfmSizeof, CsrWifiNmeApWmmParamUpdateCfmSer, CsrWifiNmeApWmmParamUpdateCfmDes, CsrWifiNmeApWmmParamUpdateCfmSerFree },
-    { CSR_WIFI_NME_AP_STATION_IND, CsrWifiNmeApStationIndSizeof, CsrWifiNmeApStationIndSer, CsrWifiNmeApStationIndDes, CsrWifiNmeApStationIndSerFree },
-
-    { 0, NULL, NULL, NULL, NULL },
-};
-
-CsrMsgConvMsgEntry* CsrWifiNmeApConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
-{
-    if (msgType & CSR_PRIM_UPSTREAM)
-    {
-        u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT;
-        if (idx < (CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT) &&
-            csrwifinmeap_conv_lut[idx].msgType == msgType)
-        {
-            return &csrwifinmeap_conv_lut[idx];
-        }
-    }
-    else
-    {
-        if (msgType < CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT &&
-            csrwifinmeap_conv_lut[msgType].msgType == msgType)
-        {
-            return &csrwifinmeap_conv_lut[msgType];
-        }
-    }
-    return NULL;
-}
-
-
-void CsrWifiNmeApConverterInit(void)
-{
-    CsrMsgConvInsert(CSR_WIFI_NME_AP_PRIM, csrwifinmeap_conv_lut);
-    CsrMsgConvCustomLookupRegister(CSR_WIFI_NME_AP_PRIM, CsrWifiNmeApConverterLookup);
-}
-
-
-#ifdef CSR_LOG_ENABLE
-static const CsrLogPrimitiveInformation csrwifinmeap_conv_info = {
-    CSR_WIFI_NME_AP_PRIM,
-    (char *)"CSR_WIFI_NME_AP_PRIM",
-    csrwifinmeap_conv_lut
-};
-const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void)
-{
-    return &csrwifinmeap_conv_info;
-}
-
-
-#endif /* CSR_LOG_ENABLE */
-#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
-#endif /* CSR_WIFI_NME_ENABLE */
-#endif /* CSR_WIFI_AP_ENABLE */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h
deleted file mode 100644 (file)
index b89d7c7..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_AP_CONVERTER_INIT_H__
-#define CSR_WIFI_NME_AP_CONVERTER_INIT_H__
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h
-#endif
-#ifndef CSR_WIFI_AP_ENABLE
-#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h
-#endif
-
-#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE
-
-#include "csr_msgconv.h"
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-
-extern const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void);
-#endif /* CSR_LOG_ENABLE */
-
-extern void CsrWifiNmeApConverterInit(void);
-
-#else /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
-
-#define CsrWifiNmeApConverterInit()
-
-#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
-
-#endif /* CSR_WIFI_NME_AP_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c
deleted file mode 100644 (file)
index ab93588..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_nme_ap_prim.h"
-#include "csr_wifi_nme_ap_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiNmeApFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_NME_AP_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-
-    switch (*((CsrWifiNmeApPrim *) message))
-    {
-        case CSR_WIFI_NME_AP_CONFIG_SET_REQ:
-        {
-            CsrWifiNmeApConfigSetReq *p = (CsrWifiNmeApConfigSetReq *)message;
-            kfree(p->apMacConfig.macAddressList);
-            p->apMacConfig.macAddressList = NULL;
-            break;
-        }
-        case CSR_WIFI_NME_AP_START_REQ:
-        {
-            CsrWifiNmeApStartReq *p = (CsrWifiNmeApStartReq *)message;
-            switch (p->apCredentials.authType)
-            {
-                case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
-                    switch (p->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
-                    {
-                        case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
-                            kfree(p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
-                            p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase = NULL;
-                            break;
-                        default:
-                            break;
-                    }
-                    break;
-                default:
-                    break;
-            }
-            {
-                u16 i3;
-                for (i3 = 0; i3 < p->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
-                {
-                    kfree(p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel);
-                    p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL;
-                }
-            }
-            kfree(p->p2pGoParam.operatingChanList.channelEntryList);
-            p->p2pGoParam.operatingChanList.channelEntryList = NULL;
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c
deleted file mode 100644 (file)
index 2786a6b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#include "csr_wifi_nme_ap_prim.h"
-#include "csr_wifi_nme_ap_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiNmeApFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_NME_AP_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_lib.h b/drivers/staging/csr/csr_wifi_nme_ap_lib.h
deleted file mode 100644 (file)
index 6d8df83..0000000
+++ /dev/null
@@ -1,495 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_AP_LIB_H__
-#define CSR_WIFI_NME_AP_LIB_H__
-
-#include "csr_sched.h"
-#include "csr_macro.h"
-#include "csr_msg_transport.h"
-
-#include "csr_wifi_lib.h"
-
-#include "csr_wifi_nme_ap_prim.h"
-#include "csr_wifi_nme_task.h"
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h
-#endif
-#ifndef CSR_WIFI_AP_ENABLE
-#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h
-#endif
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiNmeApFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_NME_AP upstream message. Does not
- *      free the message itself, and can only be used for upstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_NME_AP upstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiNmeApFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_NME_AP downstream message. Does not
- *      free the message itself, and can only be used for downstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_NME_AP downstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApConfigSetReqSend
-
-  DESCRIPTION
-    This primitive passes AP configuration info for NME. This can be sent at
-    any time but will be acted upon when the AP is started again. This
-    information is common to both P2P GO and AP
-
-  PARAMETERS
-    queue       - Message Source Task Queue (Cfm's will be sent to this Queue)
-    apConfig    - AP configuration for the NME.
-    apMacConfig - MAC configuration to be acted on when
-                  CSR_WIFI_NME_AP_START.request is sent.
-
-*******************************************************************************/
-#define CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_REQ, dst__, src__); \
-    msg__->apConfig = (apConfig__); \
-    msg__->apMacConfig = (apMacConfig__);
-
-#define CsrWifiNmeApConfigSetReqSendTo(dst__, src__, apConfig__, apMacConfig__) \
-    { \
-        CsrWifiNmeApConfigSetReq *msg__; \
-        CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApConfigSetReqSend(src__, apConfig__, apMacConfig__) \
-    CsrWifiNmeApConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, apConfig__, apMacConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeApConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeApConfigSetCfm *msg__; \
-        CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApConfigSetCfmSend(dst__, status__) \
-    CsrWifiNmeApConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStaRemoveReqSend
-
-  DESCRIPTION
-    This primitive disconnects a connected station. If keepBlocking is set to
-    TRUE, the station with the specified MAC address is not allowed to
-    connect. If the requested station is not already connected,it may be
-    blocked based on keepBlocking parameter.
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    staMacAddress - Mac Address of the station to be disconnected or blocked
-    keepBlocking  - If TRUE, the station is blocked. If FALSE and the station is
-                    connected, disconnect the station. If FALSE and the station
-                    is not connected, no action is taken.
-
-*******************************************************************************/
-#define CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STA_REMOVE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->staMacAddress = (staMacAddress__); \
-    msg__->keepBlocking = (keepBlocking__);
-
-#define CsrWifiNmeApStaRemoveReqSendTo(dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \
-    { \
-        CsrWifiNmeApStaRemoveReq *msg__; \
-        CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStaRemoveReqSend(src__, interfaceTag__, staMacAddress__, keepBlocking__) \
-    CsrWifiNmeApStaRemoveReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, staMacAddress__, keepBlocking__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStartReqSend
-
-  DESCRIPTION
-    This primitive requests NME to started the AP operation.
-
-  PARAMETERS
-    queue          - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag   - Interface identifier; unique identifier of an interface
-    apType         - AP Type specifies the Legacy AP or P2P GO operation
-    cloakSsid      - Indicates whether the SSID should be cloaked (hidden and
-                     not broadcast in beacon) or not
-    ssid           - Service Set Identifier
-    ifIndex        - Radio interface
-    channel        - Channel number of the channel to use
-    apCredentials  - Security credential configuration.
-    maxConnections - Maximum number of stations/P2P clients allowed
-    p2pGoParam     - P2P specific GO parameters.
-    wpsEnabled     - Indicates whether WPS should be enabled or not
-
-*******************************************************************************/
-#define CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->apType = (apType__); \
-    msg__->cloakSsid = (cloakSsid__); \
-    msg__->ssid = (ssid__); \
-    msg__->ifIndex = (ifIndex__); \
-    msg__->channel = (channel__); \
-    msg__->apCredentials = (apCredentials__); \
-    msg__->maxConnections = (maxConnections__); \
-    msg__->p2pGoParam = (p2pGoParam__); \
-    msg__->wpsEnabled = (wpsEnabled__);
-
-#define CsrWifiNmeApStartReqSendTo(dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
-    { \
-        CsrWifiNmeApStartReq *msg__; \
-        CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStartReqSend(src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
-    CsrWifiNmeApStartReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStartCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of CSR_WIFI_NME_AP_START.request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface identifier; unique identifier of an interface
-    status       - Status of the request.
-    ssid         - Service Set Identifier
-
-*******************************************************************************/
-#define CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->ssid = (ssid__);
-
-#define CsrWifiNmeApStartCfmSendTo(dst__, src__, interfaceTag__, status__, ssid__) \
-    { \
-        CsrWifiNmeApStartCfm *msg__; \
-        CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStartCfmSend(dst__, interfaceTag__, status__, ssid__) \
-    CsrWifiNmeApStartCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, ssid__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStationIndSend
-
-  DESCRIPTION
-    This primitive indicates that a station has joined or a previously joined
-    station has left the BSS/group
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    interfaceTag      - Interface Identifier; unique identifier of an interface
-    mediaStatus       - Indicates whether the station is connected or
-                        disconnected
-    peerMacAddress    - MAC address of the station
-    peerDeviceAddress - P2P Device Address
-
-*******************************************************************************/
-#define CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STATION_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->mediaStatus = (mediaStatus__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->peerDeviceAddress = (peerDeviceAddress__);
-
-#define CsrWifiNmeApStationIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
-    { \
-        CsrWifiNmeApStationInd *msg__; \
-        CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStationIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
-    CsrWifiNmeApStationIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStopReqSend
-
-  DESCRIPTION
-    This primitive requests NME to stop the AP operation.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStopReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiNmeApStopReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiNmeApStopReq *msg__; \
-        CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStopReqSend(src__, interfaceTag__) \
-    CsrWifiNmeApStopReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStopIndSend
-
-  DESCRIPTION
-    Indicates that AP operation had stopped because of some unrecoverable
-    error after AP operation was started successfully. NME sends this signal
-    after failing to restart the AP operation internally following an error
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    apType       - Reports AP Type (P2PGO or AP)
-    status       - Error Status
-
-*******************************************************************************/
-#define CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->apType = (apType__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeApStopIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \
-    { \
-        CsrWifiNmeApStopInd *msg__; \
-        CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStopIndSend(dst__, interfaceTag__, apType__, status__) \
-    CsrWifiNmeApStopIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, apType__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStopCfmSend
-
-  DESCRIPTION
-    This primitive confirms that the AP operation is stopped. NME shall send
-    this primitive in response to the request even if AP operation has
-    already been stopped
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface identifier; unique identifier of an interface
-    status       - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeApStopCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiNmeApStopCfm *msg__; \
-        CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApStopCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiNmeApStopCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWmmParamUpdateReqSend
-
-  DESCRIPTION
-    Application uses this primitive to update the WMM parameters
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    wmmApParams   - WMM Access point parameters per access category. The array
-                    index corresponds to the ACI
-    wmmApBcParams - WMM station parameters per access category to be advertised
-                    in the beacons and probe response The array index
-                    corresponds to the ACI
-
-*******************************************************************************/
-#define CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \
-    memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \
-    memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4);
-
-#define CsrWifiNmeApWmmParamUpdateReqSendTo(dst__, src__, wmmApParams__, wmmApBcParams__) \
-    { \
-        CsrWifiNmeApWmmParamUpdateReq *msg__; \
-        CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApWmmParamUpdateReqSend(src__, wmmApParams__, wmmApBcParams__) \
-    CsrWifiNmeApWmmParamUpdateReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wmmApParams__, wmmApBcParams__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWmmParamUpdateCfmSend
-
-  DESCRIPTION
-    A confirm for for the WMM parameters update
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeApWmmParamUpdateCfm *msg__; \
-        CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApWmmParamUpdateCfmSend(dst__, status__) \
-    CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWpsRegisterReqSend
-
-  DESCRIPTION
-    This primitive allows the NME to accept the WPS registration from an
-    enrollee. Such registration procedure can be cancelled by sending
-    CSR_WIFI_NME_WPS_CANCEL.request.
-
-  PARAMETERS
-    queue                    - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag             - Interface Identifier; unique identifier of an
-                               interface
-    selectedDevicePasswordId - Selected password type
-    selectedConfigMethod     - Selected WPS configuration method type
-    pin                      - PIN value.
-                               Relevant if selected device password ID is PIN.4
-                               digit pin is passed by sending the pin digits in
-                               pin[0]..pin[3] and rest of the contents filled
-                               with '-'.
-
-*******************************************************************************/
-#define CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->selectedDevicePasswordId = (selectedDevicePasswordId__); \
-    msg__->selectedConfigMethod = (selectedConfigMethod__); \
-    memcpy(msg__->pin, (pin__), sizeof(u8) * 8);
-
-#define CsrWifiNmeApWpsRegisterReqSendTo(dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
-    { \
-        CsrWifiNmeApWpsRegisterReq *msg__; \
-        CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApWpsRegisterReqSend(src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
-    CsrWifiNmeApWpsRegisterReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWpsRegisterCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of WPS procedure.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface identifier; unique identifier of an interface
-    status       - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeApWpsRegisterCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiNmeApWpsRegisterCfm *msg__; \
-        CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeApWpsRegisterCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiNmeApWpsRegisterCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
-
-#endif /* CSR_WIFI_NME_AP_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_prim.h b/drivers/staging/csr/csr_wifi_nme_ap_prim.h
deleted file mode 100644 (file)
index b32bdbc..0000000
+++ /dev/null
@@ -1,494 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_AP_PRIM_H__
-#define CSR_WIFI_NME_AP_PRIM_H__
-
-#include <linux/types.h>
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-#include "csr_wifi_common.h"
-#include "csr_result.h"
-#include "csr_wifi_fsm_event.h"
-#include "csr_wifi_sme_ap_prim.h"
-#include "csr_wifi_nme_prim.h"
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h
-#endif
-#ifndef CSR_WIFI_AP_ENABLE
-#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h
-#endif
-
-#define CSR_WIFI_NME_AP_PRIM                                            (0x0426)
-
-typedef CsrPrim CsrWifiNmeApPrim;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApPersCredentialType
-
-  DESCRIPTION
-    NME Credential Types
-
- VALUES
-    CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK
-                   - Use PSK as credential.
-    CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE
-                   - Use the specified passphrase as credential
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeApPersCredentialType;
-#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK          ((CsrWifiNmeApPersCredentialType) 0x00)
-#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE   ((CsrWifiNmeApPersCredentialType) 0x01)
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApConfig
-
-  DESCRIPTION
-    Structure holding AP config data.
-
-  MEMBERS
-    apGroupkeyTimeout - Access point group key timeout.
-    apStrictGtkRekey  - Access point strict GTK rekey flag. If set TRUE, the AP
-                        shall rekey GTK every time a connected STA leaves BSS.
-    apGmkTimeout      - Access point GMK timeout
-    apResponseTimeout - Response timeout
-    apRetransLimit    - Max allowed retransmissions
-
-*******************************************************************************/
-typedef struct
-{
-    u16 apGroupkeyTimeout;
-    u8   apStrictGtkRekey;
-    u16 apGmkTimeout;
-    u16 apResponseTimeout;
-    u8  apRetransLimit;
-} CsrWifiNmeApConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApAuthPers
-
-  DESCRIPTION
-
-  MEMBERS
-    authSupport                     - Credential type value (as defined in the
-                                      enumeration type).
-    rsnCapabilities                 - RSN capabilities mask
-    wapiCapabilities                - WAPI capabilities mask
-    pskOrPassphrase                 - Credential type value (as defined in the
-                                      enumeration type).
-    authPers_credentials            - Union containing credentials which depends
-                                      on credentialType parameter.
-    authPers_credentialspsk         -
-    authPers_credentialspassphrase  -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeApAuthSupportMask      authSupport;
-    CsrWifiSmeApRsnCapabilitiesMask  rsnCapabilities;
-    CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities;
-    CsrWifiNmeApPersCredentialType   pskOrPassphrase;
-    union {
-        CsrWifiNmePsk        psk;
-        CsrWifiNmePassphrase passphrase;
-    } authPers_credentials;
-} CsrWifiNmeApAuthPers;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApCredentials
-
-  DESCRIPTION
-    Structure containing the Credentials data.
-
-  MEMBERS
-    authType                     - Authentication type
-    nmeAuthType                  - Authentication parameters
-    nmeAuthTypeopenSystemEmpty   -
-    nmeAuthTypeauthwep           -
-    nmeAuthTypeauthTypePersonal  -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeApAuthType authType;
-    union {
-        CsrWifiSmeEmpty      openSystemEmpty;
-        CsrWifiSmeWepAuth    authwep;
-        CsrWifiNmeApAuthPers authTypePersonal;
-    } nmeAuthType;
-} CsrWifiNmeApCredentials;
-
-
-/* Downstream */
-#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST            (0x0000)
-
-#define CSR_WIFI_NME_AP_CONFIG_SET_REQ                    ((CsrWifiNmeApPrim) (0x0000 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_WPS_REGISTER_REQ                  ((CsrWifiNmeApPrim) (0x0001 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_START_REQ                         ((CsrWifiNmeApPrim) (0x0002 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_STOP_REQ                          ((CsrWifiNmeApPrim) (0x0003 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ              ((CsrWifiNmeApPrim) (0x0004 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_STA_REMOVE_REQ                    ((CsrWifiNmeApPrim) (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
-
-
-#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST           (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)
-
-/* Upstream */
-#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST              (0x0000 + CSR_PRIM_UPSTREAM)
-
-#define CSR_WIFI_NME_AP_CONFIG_SET_CFM                    ((CsrWifiNmeApPrim)(0x0000 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_WPS_REGISTER_CFM                  ((CsrWifiNmeApPrim)(0x0001 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_START_CFM                         ((CsrWifiNmeApPrim)(0x0002 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_STOP_CFM                          ((CsrWifiNmeApPrim)(0x0003 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_STOP_IND                          ((CsrWifiNmeApPrim)(0x0004 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM              ((CsrWifiNmeApPrim)(0x0005 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_AP_STATION_IND                       ((CsrWifiNmeApPrim)(0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
-
-#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST             (0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)
-
-#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT             (CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)
-#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT               (CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST   + 1 - CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApConfigSetReq
-
-  DESCRIPTION
-    This primitive passes AP configuration info for NME. This can be sent at
-    any time but will be acted upon when the AP is started again. This
-    information is common to both P2P GO and AP
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    apConfig    - AP configuration for the NME.
-    apMacConfig - MAC configuration to be acted on when
-                  CSR_WIFI_NME_AP_START.request is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrWifiNmeApConfig    apConfig;
-    CsrWifiSmeApMacConfig apMacConfig;
-} CsrWifiNmeApConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWpsRegisterReq
-
-  DESCRIPTION
-    This primitive allows the NME to accept the WPS registration from an
-    enrollee. Such registration procedure can be cancelled by sending
-    CSR_WIFI_NME_WPS_CANCEL.request.
-
-  MEMBERS
-    common                   - Common header for use with the CsrWifiFsm Module
-    interfaceTag             - Interface Identifier; unique identifier of an
-                               interface
-    selectedDevicePasswordId - Selected password type
-    selectedConfigMethod     - Selected WPS configuration method type
-    pin                      - PIN value.
-                               Relevant if selected device password ID is PIN.4
-                               digit pin is passed by sending the pin digits in
-                               pin[0]..pin[3] and rest of the contents filled
-                               with '-'.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    CsrWifiSmeWpsDpid       selectedDevicePasswordId;
-    CsrWifiSmeWpsConfigType selectedConfigMethod;
-    u8                pin[8];
-} CsrWifiNmeApWpsRegisterReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStartReq
-
-  DESCRIPTION
-    This primitive requests NME to started the AP operation.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface identifier; unique identifier of an interface
-    apType         - AP Type specifies the Legacy AP or P2P GO operation
-    cloakSsid      - Indicates whether the SSID should be cloaked (hidden and
-                     not broadcast in beacon) or not
-    ssid           - Service Set Identifier
-    ifIndex        - Radio interface
-    channel        - Channel number of the channel to use
-    apCredentials  - Security credential configuration.
-    maxConnections - Maximum number of stations/P2P clients allowed
-    p2pGoParam     - P2P specific GO parameters.
-    wpsEnabled     - Indicates whether WPS should be enabled or not
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    CsrWifiSmeApType        apType;
-    u8                 cloakSsid;
-    CsrWifiSsid             ssid;
-    CsrWifiSmeRadioIF       ifIndex;
-    u8                channel;
-    CsrWifiNmeApCredentials apCredentials;
-    u8                maxConnections;
-    CsrWifiSmeApP2pGoConfig p2pGoParam;
-    u8                 wpsEnabled;
-} CsrWifiNmeApStartReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStopReq
-
-  DESCRIPTION
-    This primitive requests NME to stop the AP operation.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiNmeApStopReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWmmParamUpdateReq
-
-  DESCRIPTION
-    Application uses this primitive to update the WMM parameters
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    wmmApParams   - WMM Access point parameters per access category. The array
-                    index corresponds to the ACI
-    wmmApBcParams - WMM station parameters per access category to be advertised
-                    in the beacons and probe response The array index
-                    corresponds to the ACI
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrWifiSmeWmmAcParams wmmApParams[4];
-    CsrWifiSmeWmmAcParams wmmApBcParams[4];
-} CsrWifiNmeApWmmParamUpdateReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStaRemoveReq
-
-  DESCRIPTION
-    This primitive disconnects a connected station. If keepBlocking is set to
-    TRUE, the station with the specified MAC address is not allowed to
-    connect. If the requested station is not already connected,it may be
-    blocked based on keepBlocking parameter.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    staMacAddress - Mac Address of the station to be disconnected or blocked
-    keepBlocking  - If TRUE, the station is blocked. If FALSE and the station is
-                    connected, disconnect the station. If FALSE and the station
-                    is not connected, no action is taken.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    CsrWifiMacAddress staMacAddress;
-    u8           keepBlocking;
-} CsrWifiNmeApStaRemoveReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeApConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWpsRegisterCfm
-
-  DESCRIPTION
-    This primitive reports the result of WPS procedure.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface identifier; unique identifier of an interface
-    status       - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiNmeApWpsRegisterCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStartCfm
-
-  DESCRIPTION
-    This primitive reports the result of CSR_WIFI_NME_AP_START.request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface identifier; unique identifier of an interface
-    status       - Status of the request.
-    ssid         - Service Set Identifier
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-    CsrWifiSsid     ssid;
-} CsrWifiNmeApStartCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStopCfm
-
-  DESCRIPTION
-    This primitive confirms that the AP operation is stopped. NME shall send
-    this primitive in response to the request even if AP operation has
-    already been stopped
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface identifier; unique identifier of an interface
-    status       - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiNmeApStopCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStopInd
-
-  DESCRIPTION
-    Indicates that AP operation had stopped because of some unrecoverable
-    error after AP operation was started successfully. NME sends this signal
-    after failing to restart the AP operation internally following an error
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    apType       - Reports AP Type (P2PGO or AP)
-    status       - Error Status
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent  common;
-    u16        interfaceTag;
-    CsrWifiSmeApType apType;
-    CsrResult        status;
-} CsrWifiNmeApStopInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApWmmParamUpdateCfm
-
-  DESCRIPTION
-    A confirm for for the WMM parameters update
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeApWmmParamUpdateCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeApStationInd
-
-  DESCRIPTION
-    This primitive indicates that a station has joined or a previously joined
-    station has left the BSS/group
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    interfaceTag      - Interface Identifier; unique identifier of an interface
-    mediaStatus       - Indicates whether the station is connected or
-                        disconnected
-    peerMacAddress    - MAC address of the station
-    peerDeviceAddress - P2P Device Address
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    u16             interfaceTag;
-    CsrWifiSmeMediaStatus mediaStatus;
-    CsrWifiMacAddress     peerMacAddress;
-    CsrWifiMacAddress     peerDeviceAddress;
-} CsrWifiNmeApStationInd;
-
-#endif /* CSR_WIFI_NME_AP_PRIM_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_sef.c b/drivers/staging/csr/csr_wifi_nme_ap_sef.c
deleted file mode 100644 (file)
index bfebb15..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*****************************************************************************
-
-  FILE: csr_wifi_nme_sef.c
-
-  (c) Cambridge Silicon Radio Limited 2010
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-#include "csr_wifi_nme_ap_sef.h"
-#include "unifi_priv.h"
-
-void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    switch(msg->type) {
-        case CSR_WIFI_NME_AP_START_CFM:
-            CsrWifiNmeApStartCfmHandler(drvpriv, msg);
-            break;
-        case CSR_WIFI_NME_AP_STOP_CFM:
-            CsrWifiNmeApStopCfmHandler(drvpriv, msg);
-            break;
-        case CSR_WIFI_NME_AP_CONFIG_SET_CFM:
-            CsrWifiNmeApConfigSetCfmHandler(drvpriv, msg);
-            break;
-        default:
-           unifi_error(drvpriv, "CsrWifiNmeApUpstreamStateHandlers: unhandled NME_AP message type 0x%.4X\n", msg->type);
-            break;
-    }
-}
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_sef.h b/drivers/staging/csr/csr_wifi_nme_ap_sef.h
deleted file mode 100644 (file)
index 3daaa09..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*****************************************************************************
-    FILE: csr_wifi_nme_sef.h
-    (c) Cambridge Silicon Radio Limited 2010
-
-    Refer to LICENSE.txt included with this source for details
-    on the license terms.
-
-*****************************************************************************/
-#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__
-#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__
-
-#include "csr_wifi_nme_prim.h"
-
-void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg);
-
-
-extern void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-extern void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-extern void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-
-#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c b/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
deleted file mode 100644 (file)
index 1a901a7..0000000
+++ /dev/null
@@ -1,909 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "csr_msgconv.h"
-
-#ifdef CSR_WIFI_NME_ENABLE
-#ifdef CSR_WIFI_AP_ENABLE
-
-#include "csr_wifi_nme_ap_prim.h"
-#include "csr_wifi_nme_ap_serialize.h"
-
-void CsrWifiNmeApPfree(void *ptr)
-{
-    kfree(ptr);
-}
-
-
-size_t CsrWifiNmeApConfigSetReqSizeof(void *msg)
-{
-    CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 104) */
-    bufferSize += 2;  /* u16 primitive->apConfig.apGroupkeyTimeout */
-    bufferSize += 1;  /* u8 primitive->apConfig.apStrictGtkRekey */
-    bufferSize += 2;  /* u16 primitive->apConfig.apGmkTimeout */
-    bufferSize += 2;  /* u16 primitive->apConfig.apResponseTimeout */
-    bufferSize += 1;  /* u8 primitive->apConfig.apRetransLimit */
-    bufferSize += 1;  /* CsrWifiSmeApPhySupportMask primitive->apMacConfig.phySupportedBitmap */
-    bufferSize += 2;  /* u16 primitive->apMacConfig.beaconInterval */
-    bufferSize += 1;  /* u8 primitive->apMacConfig.dtimPeriod */
-    bufferSize += 2;  /* u16 primitive->apMacConfig.maxListenInterval */
-    bufferSize += 1;  /* u8 primitive->apMacConfig.supportedRatesCount */
-    bufferSize += 20; /* u8 primitive->apMacConfig.supportedRates[20] */
-    bufferSize += 1;  /* CsrWifiSmePreambleType primitive->apMacConfig.preamble */
-    bufferSize += 1;  /* u8 primitive->apMacConfig.shortSlotTimeEnabled */
-    bufferSize += 1;  /* CsrWifiSmeCtsProtectionType primitive->apMacConfig.ctsProtectionType */
-    bufferSize += 1;  /* u8 primitive->apMacConfig.wmmEnabled */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMin */
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMax */
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].aifs */
-            bufferSize += 2; /* u16 primitive->apMacConfig.wmmApParams[i2].txopLimit */
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory */
-        }
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMin */
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMax */
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].aifs */
-            bufferSize += 2; /* u16 primitive->apMacConfig.wmmApBcParams[i2].txopLimit */
-            bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory */
-        }
-    }
-    bufferSize += 1;         /* CsrWifiSmeApAccessType primitive->apMacConfig.accessType */
-    bufferSize += 1;         /* u8 primitive->apMacConfig.macAddressListCount */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
-        {
-            bufferSize += 6; /* u8 primitive->apMacConfig.macAddressList[i2].a[6] */
-        }
-    }
-    bufferSize += 1;         /* u8 primitive->apMacConfig.apHtParams.greenfieldSupported */
-    bufferSize += 1;         /* u8 primitive->apMacConfig.apHtParams.shortGi20MHz */
-    bufferSize += 1;         /* u8 primitive->apMacConfig.apHtParams.rxStbc */
-    bufferSize += 1;         /* u8 primitive->apMacConfig.apHtParams.rifsModeAllowed */
-    bufferSize += 1;         /* u8 primitive->apMacConfig.apHtParams.htProtection */
-    bufferSize += 1;         /* u8 primitive->apMacConfig.apHtParams.dualCtsProtection */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGroupkeyTimeout);
-    CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apStrictGtkRekey);
-    CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGmkTimeout);
-    CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apResponseTimeout);
-    CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apRetransLimit);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.phySupportedBitmap);
-    CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.beaconInterval);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.dtimPeriod);
-    CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.maxListenInterval);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.supportedRatesCount);
-    CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.supportedRates, ((u16) (20)));
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.preamble);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.shortSlotTimeEnabled);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.ctsProtectionType);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmEnabled);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMin);
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMax);
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].aifs);
-            CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApParams[i2].txopLimit);
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory);
-        }
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMin);
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMax);
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].aifs);
-            CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApBcParams[i2].txopLimit);
-            CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory);
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.accessType);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.macAddressListCount);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.macAddressList[i2].a, ((u16) (6)));
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.greenfieldSupported);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.shortGi20MHz);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rxStbc);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rifsModeAllowed);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.htProtection);
-    CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.dualCtsProtection);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApConfigSetReq *primitive = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->apConfig.apGroupkeyTimeout, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apConfig.apStrictGtkRekey, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->apConfig.apGmkTimeout, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->apConfig.apResponseTimeout, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apConfig.apRetransLimit, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.phySupportedBitmap, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->apMacConfig.beaconInterval, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.dtimPeriod, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->apMacConfig.maxListenInterval, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.supportedRatesCount, buffer, &offset);
-    CsrMemCpyDes(primitive->apMacConfig.supportedRates, buffer, &offset, ((u16) (20)));
-    CsrUint8Des((u8 *) &primitive->apMacConfig.preamble, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.shortSlotTimeEnabled, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.ctsProtectionType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.wmmEnabled, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMin, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMax, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].aifs, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApParams[i2].txopLimit, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory, buffer, &offset);
-        }
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMin, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMax, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].aifs, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApBcParams[i2].txopLimit, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory, buffer, &offset);
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->apMacConfig.accessType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.macAddressListCount, buffer, &offset);
-    primitive->apMacConfig.macAddressList = NULL;
-    if (primitive->apMacConfig.macAddressListCount)
-    {
-        primitive->apMacConfig.macAddressList = kmalloc(sizeof(CsrWifiMacAddress) * primitive->apMacConfig.macAddressListCount, GFP_KERNEL);
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
-        {
-            CsrMemCpyDes(primitive->apMacConfig.macAddressList[i2].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.greenfieldSupported, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.shortGi20MHz, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rxStbc, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rifsModeAllowed, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.htProtection, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.dualCtsProtection, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiNmeApConfigSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) voidPrimitivePointer;
-    kfree(primitive->apMacConfig.macAddressList);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiSmeWpsDpid primitive->selectedDevicePasswordId */
-    bufferSize += 2; /* CsrWifiSmeWpsConfigType primitive->selectedConfigMethod */
-    bufferSize += 8; /* u8 primitive->pin[8] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApWpsRegisterReq *primitive = (CsrWifiNmeApWpsRegisterReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->selectedDevicePasswordId);
-    CsrUint16Ser(ptr, len, (u16) primitive->selectedConfigMethod);
-    CsrMemCpySer(ptr, len, (const void *) primitive->pin, ((u16) (8)));
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApWpsRegisterReq *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->selectedDevicePasswordId, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->selectedConfigMethod, buffer, &offset);
-    CsrMemCpyDes(primitive->pin, buffer, &offset, ((u16) (8)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApStartReqSizeof(void *msg)
-{
-    CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 112) */
-    bufferSize += 2;  /* u16 primitive->interfaceTag */
-    bufferSize += 1;  /* CsrWifiSmeApType primitive->apType */
-    bufferSize += 1;  /* u8 primitive->cloakSsid */
-    bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
-    bufferSize += 1;  /* u8 primitive->ssid.length */
-    bufferSize += 1;  /* CsrWifiSmeRadioIF primitive->ifIndex */
-    bufferSize += 1;  /* u8 primitive->channel */
-    bufferSize += 1;  /* CsrWifiSmeApAuthType primitive->apCredentials.authType */
-    switch (primitive->apCredentials.authType)
-    {
-        case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
-            bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.openSystemEmpty.empty */
-            break;
-        case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
-            bufferSize += 1; /* CsrWifiSmeWepCredentialType primitive->apCredentials.nmeAuthType.authwep.wepKeyType */
-            switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
-            {
-                case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
-                    bufferSize += 1;  /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType */
-                    bufferSize += 1;  /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey */
-                    bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1[13] */
-                    bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2[13] */
-                    bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3[13] */
-                    bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4[13] */
-                    break;
-                case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
-                    bufferSize += 1;  /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType */
-                    bufferSize += 1;  /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey */
-                    bufferSize += 5;  /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1[5] */
-                    bufferSize += 5;  /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2[5] */
-                    bufferSize += 5;  /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3[5] */
-                    bufferSize += 5;  /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4[5] */
-                    break;
-                default:
-                    break;
-            }
-            break;
-        case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
-            bufferSize += 1; /* CsrWifiSmeApAuthSupportMask primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport */
-            bufferSize += 2; /* CsrWifiSmeApRsnCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities */
-            bufferSize += 2; /* CsrWifiSmeApWapiCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities */
-            bufferSize += 1; /* CsrWifiNmeApPersCredentialType primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase */
-            switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
-            {
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
-                    bufferSize += 2;                                                                                                                                                                                                                      /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode */
-                    bufferSize += 32;                                                                                                                                                                                                                     /* u8 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk[32] */
-                    break;
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
-                    bufferSize += 2;                                                                                                                                                                                                                      /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode */
-                    bufferSize += (primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase ? strlen(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase) : 0) + 1; /* char* primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase (0 byte len + 1 for NULL Term) */
-                    break;
-                default:
-                    break;
-            }
-            break;
-        default:
-            break;
-    }
-    bufferSize += 1; /* u8 primitive->maxConnections */
-    bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->p2pGoParam.groupCapability */
-    bufferSize += 3; /* u8 primitive->p2pGoParam.operatingChanList.country[3] */
-    bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryListCount */
-    {
-        u16 i3;
-        for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
-        {
-            bufferSize += 1;                                                                                  /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass */
-            bufferSize += 1;                                                                                  /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount */
-            bufferSize += primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel */
-        }
-    }
-    bufferSize += 1;                                                                                          /* u8 primitive->p2pGoParam.opPsEnabled */
-    bufferSize += 1;                                                                                          /* u8 primitive->p2pGoParam.ctWindow */
-    bufferSize += 1;                                                                                          /* CsrWifiSmeP2pNoaConfigMethod primitive->p2pGoParam.noaConfigMethod */
-    bufferSize += 1;                                                                                          /* u8 primitive->p2pGoParam.allowNoaWithNonP2pDevices */
-    bufferSize += 1;                                                                                          /* u8 primitive->wpsEnabled */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->apType);
-    CsrUint8Ser(ptr, len, (u8) primitive->cloakSsid);
-    CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
-    CsrUint8Ser(ptr, len, (u8) primitive->ifIndex);
-    CsrUint8Ser(ptr, len, (u8) primitive->channel);
-    CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.authType);
-    switch (primitive->apCredentials.authType)
-    {
-        case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
-            CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.openSystemEmpty.empty);
-            break;
-        case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
-            CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepKeyType);
-            switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
-            {
-                case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
-                    CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType);
-                    CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey);
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, ((u16) (13)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, ((u16) (13)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, ((u16) (13)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, ((u16) (13)));
-                    break;
-                case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
-                    CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType);
-                    CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey);
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, ((u16) (5)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, ((u16) (5)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, ((u16) (5)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, ((u16) (5)));
-                    break;
-                default:
-                    break;
-            }
-            break;
-        case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
-            CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport);
-            CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities);
-            CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities);
-            CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase);
-            switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
-            {
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
-                    CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode);
-                    CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, ((u16) (32)));
-                    break;
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
-                    CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode);
-                    CsrCharStringSer(ptr, len, primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
-                    break;
-                default:
-                    break;
-            }
-            break;
-        default:
-            break;
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->maxConnections);
-    CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.groupCapability);
-    CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.country, ((u16) (3)));
-    CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryListCount);
-    {
-        u16 i3;
-        for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
-        {
-            CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass);
-            CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount);
-            if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)
-            {
-                CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)));
-            }
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.opPsEnabled);
-    CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.ctWindow);
-    CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.noaConfigMethod);
-    CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.allowNoaWithNonP2pDevices);
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsEnabled);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApStartReq *primitive = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->cloakSsid, buffer, &offset);
-    CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ifIndex, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->channel, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apCredentials.authType, buffer, &offset);
-    switch (primitive->apCredentials.authType)
-    {
-        case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
-            CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.openSystemEmpty.empty, buffer, &offset);
-            break;
-        case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
-            CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepKeyType, buffer, &offset);
-            switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
-            {
-                case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
-                    CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType, buffer, &offset);
-                    CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey, buffer, &offset);
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, buffer, &offset, ((u16) (13)));
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, buffer, &offset, ((u16) (13)));
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, buffer, &offset, ((u16) (13)));
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, buffer, &offset, ((u16) (13)));
-                    break;
-                case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
-                    CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType, buffer, &offset);
-                    CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey, buffer, &offset);
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, buffer, &offset, ((u16) (5)));
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, buffer, &offset, ((u16) (5)));
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, buffer, &offset, ((u16) (5)));
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, buffer, &offset, ((u16) (5)));
-                    break;
-                default:
-                    break;
-            }
-            break;
-        case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
-            CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase, buffer, &offset);
-            switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
-            {
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
-                    CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode, buffer, &offset);
-                    CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, buffer, &offset, ((u16) (32)));
-                    break;
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
-                    CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode, buffer, &offset);
-                    CsrCharStringDes(&primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase, buffer, &offset);
-                    break;
-                default:
-                    break;
-            }
-            break;
-        default:
-            break;
-    }
-    CsrUint8Des((u8 *) &primitive->maxConnections, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->p2pGoParam.groupCapability, buffer, &offset);
-    CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.country, buffer, &offset, ((u16) (3)));
-    CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryListCount, buffer, &offset);
-    primitive->p2pGoParam.operatingChanList.channelEntryList = NULL;
-    if (primitive->p2pGoParam.operatingChanList.channelEntryListCount)
-    {
-        primitive->p2pGoParam.operatingChanList.channelEntryList = kmalloc(sizeof(CsrWifiSmeApP2pOperatingChanEntry) * primitive->p2pGoParam.operatingChanList.channelEntryListCount, GFP_KERNEL);
-    }
-    {
-        u16 i3;
-        for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
-        {
-            CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, buffer, &offset);
-            if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)
-            {
-                primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = kmalloc(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, GFP_KERNEL);
-                CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, buffer, &offset, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)));
-            }
-            else
-            {
-                primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL;
-            }
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->p2pGoParam.opPsEnabled, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->p2pGoParam.ctWindow, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->p2pGoParam.noaConfigMethod, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->p2pGoParam.allowNoaWithNonP2pDevices, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->wpsEnabled, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiNmeApStartReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) voidPrimitivePointer;
-    switch (primitive->apCredentials.authType)
-    {
-        case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
-            switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
-            {
-                case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
-                    kfree(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
-                    break;
-                default:
-                    break;
-            }
-            break;
-        default:
-            break;
-    }
-    {
-        u16 i3;
-        for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
-        {
-            kfree(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel);
-        }
-    }
-    kfree(primitive->p2pGoParam.operatingChanList.channelEntryList);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 51) */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 4; i1++)
-        {
-            bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMin */
-            bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMax */
-            bufferSize += 1; /* u8 primitive->wmmApParams[i1].aifs */
-            bufferSize += 2; /* u16 primitive->wmmApParams[i1].txopLimit */
-            bufferSize += 1; /* u8 primitive->wmmApParams[i1].admissionControlMandatory */
-        }
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 4; i1++)
-        {
-            bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMin */
-            bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMax */
-            bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].aifs */
-            bufferSize += 2; /* u16 primitive->wmmApBcParams[i1].txopLimit */
-            bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].admissionControlMandatory */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApWmmParamUpdateReq *primitive = (CsrWifiNmeApWmmParamUpdateReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 4; i1++)
-        {
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMin);
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMax);
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].aifs);
-            CsrUint16Ser(ptr, len, (u16) primitive->wmmApParams[i1].txopLimit);
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].admissionControlMandatory);
-        }
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 4; i1++)
-        {
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMin);
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMax);
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].aifs);
-            CsrUint16Ser(ptr, len, (u16) primitive->wmmApBcParams[i1].txopLimit);
-            CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].admissionControlMandatory);
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApWmmParamUpdateReq *primitive = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 4; i1++)
-        {
-            CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMin, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMax, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->wmmApParams[i1].aifs, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->wmmApParams[i1].txopLimit, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->wmmApParams[i1].admissionControlMandatory, buffer, &offset);
-        }
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 4; i1++)
-        {
-            CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMin, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMax, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].aifs, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->wmmApBcParams[i1].txopLimit, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].admissionControlMandatory, buffer, &offset);
-        }
-    }
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->staMacAddress.a[6] */
-    bufferSize += 1; /* u8 primitive->keepBlocking */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApStaRemoveReq *primitive = (CsrWifiNmeApStaRemoveReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->staMacAddress.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->keepBlocking);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApStaRemoveReq *primitive = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->staMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->keepBlocking, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApWpsRegisterCfm *primitive = (CsrWifiNmeApWpsRegisterCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApWpsRegisterCfm *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApStartCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 40) */
-    bufferSize += 2;  /* u16 primitive->interfaceTag */
-    bufferSize += 2;  /* CsrResult primitive->status */
-    bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
-    bufferSize += 1;  /* u8 primitive->ssid.length */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApStartCfm *primitive = (CsrWifiNmeApStartCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApStartCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApStopCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApStopCfm *primitive = (CsrWifiNmeApStopCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApStopCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApStopIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeApType primitive->apType */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApStopInd *primitive = (CsrWifiNmeApStopInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->apType);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApStopInd *primitive = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->apType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiNmeApStationIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 6; /* u8 primitive->peerDeviceAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiNmeApStationInd *primitive = (CsrWifiNmeApStationInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerDeviceAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiNmeApStationInd *primitive = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrMemCpyDes(primitive->peerDeviceAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-#endif /* CSR_WIFI_NME_ENABLE */
-#endif /* CSR_WIFI_AP_ENABLE */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.h b/drivers/staging/csr/csr_wifi_nme_ap_serialize.h
deleted file mode 100644 (file)
index c04585e..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_AP_SERIALIZE_H__
-#define CSR_WIFI_NME_AP_SERIALIZE_H__
-
-#include "csr_wifi_msgconv.h"
-
-#include "csr_wifi_nme_ap_prim.h"
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h
-#endif
-#ifndef CSR_WIFI_AP_ENABLE
-#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h
-#endif
-
-extern void CsrWifiNmeApPfree(void *ptr);
-
-extern u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApConfigSetReqSizeof(void *msg);
-extern void CsrWifiNmeApConfigSetReqSerFree(void *msg);
-
-extern u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg);
-#define CsrWifiNmeApWpsRegisterReqSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApStartReqSizeof(void *msg);
-extern void CsrWifiNmeApStartReqSerFree(void *msg);
-
-#define CsrWifiNmeApStopReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeApStopReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeApStopReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeApStopReqSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg);
-#define CsrWifiNmeApWmmParamUpdateReqSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg);
-#define CsrWifiNmeApStaRemoveReqSerFree CsrWifiNmeApPfree
-
-#define CsrWifiNmeApConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeApConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeApConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeApConfigSetCfmSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg);
-#define CsrWifiNmeApWpsRegisterCfmSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApStartCfmSizeof(void *msg);
-#define CsrWifiNmeApStartCfmSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApStopCfmSizeof(void *msg);
-#define CsrWifiNmeApStopCfmSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApStopIndSizeof(void *msg);
-#define CsrWifiNmeApStopIndSerFree CsrWifiNmeApPfree
-
-#define CsrWifiNmeApWmmParamUpdateCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeApWmmParamUpdateCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeApWmmParamUpdateCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeApWmmParamUpdateCfmSerFree CsrWifiNmeApPfree
-
-extern u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeApStationIndSizeof(void *msg);
-#define CsrWifiNmeApStationIndSerFree CsrWifiNmeApPfree
-
-#endif /* CSR_WIFI_NME_AP_SERIALIZE_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_converter_init.h b/drivers/staging/csr/csr_wifi_nme_converter_init.h
deleted file mode 100644 (file)
index 85e6f5f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_CONVERTER_INIT_H__
-#define CSR_WIFI_NME_CONVERTER_INIT_H__
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_converter_init.h
-#endif
-
-#ifndef EXCLUDE_CSR_WIFI_NME_MODULE
-
-#include "csr_msgconv.h"
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-
-extern const CsrLogPrimitiveInformation* CsrWifiNmeTechInfoGet(void);
-#endif /* CSR_LOG_ENABLE */
-
-extern void CsrWifiNmeConverterInit(void);
-
-#else /* EXCLUDE_CSR_WIFI_NME_MODULE */
-
-#define CsrWifiNmeConverterInit()
-
-#endif /* EXCLUDE_CSR_WIFI_NME_MODULE */
-
-#endif /* CSR_WIFI_NME_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_lib.h b/drivers/staging/csr/csr_wifi_nme_lib.h
deleted file mode 100644 (file)
index 5a1f132..0000000
+++ /dev/null
@@ -1,991 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_LIB_H__
-#define CSR_WIFI_NME_LIB_H__
-
-#include "csr_sched.h"
-#include "csr_macro.h"
-#include "csr_msg_transport.h"
-
-#include "csr_wifi_lib.h"
-
-#include "csr_wifi_nme_prim.h"
-#include "csr_wifi_nme_task.h"
-
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_lib.h
-#endif
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConnectionStatusGetReqSend
-
-  DESCRIPTION
-    Requests the current connection status of the NME.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiNmeConnectionStatusGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiNmeConnectionStatusGetReq *msg__; \
-        CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeConnectionStatusGetReqSend(src__, interfaceTag__) \
-    CsrWifiNmeConnectionStatusGetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConnectionStatusGetCfmSend
-
-  DESCRIPTION
-    Reports the connection status of the NME.
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    status           - Indicates the success or otherwise of the requested
-                       operation.
-    connectionStatus - NME current connection status
-
-*******************************************************************************/
-#define CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->connectionStatus = (connectionStatus__);
-
-#define CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStatus__) \
-    { \
-        CsrWifiNmeConnectionStatusGetCfm *msg__; \
-        CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeConnectionStatusGetCfmSend(dst__, interfaceTag__, status__, connectionStatus__) \
-    CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectionStatus__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEventMaskSetReqSend
-
-  DESCRIPTION
-    The wireless manager application may register with the NME to receive
-    notification of interesting events. Indications will be sent only if the
-    wireless manager explicitly registers to be notified of that event.
-    indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask.
-
-  PARAMETERS
-    queue   - Message Source Task Queue (Cfm's will be sent to this Queue)
-    indMask - Set mask with values from CsrWifiNmeIndications
-
-*******************************************************************************/
-#define CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_REQ, dst__, src__); \
-    msg__->indMask = (indMask__);
-
-#define CsrWifiNmeEventMaskSetReqSendTo(dst__, src__, indMask__) \
-    { \
-        CsrWifiNmeEventMaskSetReq *msg__; \
-        CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeEventMaskSetReqSend(src__, indMask__) \
-    CsrWifiNmeEventMaskSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, indMask__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEventMaskSetCfmSend
-
-  DESCRIPTION
-    The NME calls the primitive to report the result of the request
-    primitive.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeEventMaskSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeEventMaskSetCfm *msg__; \
-        CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeEventMaskSetCfmSend(dst__, status__) \
-    CsrWifiNmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileConnectReqSend
-
-  DESCRIPTION
-    Requests the NME to attempt to connect to the specified profile.
-    Overrides any current connection attempt.
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    profileIdentity - Identity (BSSID, SSID) of profile to be connected to.
-                      It must match an existing profile in the NME.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->profileIdentity = (profileIdentity__);
-
-#define CsrWifiNmeProfileConnectReqSendTo(dst__, src__, interfaceTag__, profileIdentity__) \
-    { \
-        CsrWifiNmeProfileConnectReq *msg__; \
-        CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileConnectReqSend(src__, interfaceTag__, profileIdentity__) \
-    CsrWifiNmeProfileConnectReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentity__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileConnectCfmSend
-
-  DESCRIPTION
-    Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the
-    connectAttempt parameters contain details of the APs that the NME
-    attempted to connect to before reporting the failure of the request.
-
-  PARAMETERS
-    queue                - Destination Task Queue
-    interfaceTag         - Interface Identifier; unique identifier of an
-                           interface
-    status               - Indicates the success or otherwise of the requested
-                           operation.
-    connectAttemptsCount - This parameter is relevant only if
-                           status!=CSR_WIFI_NME_STATUS_SUCCESS.
-                           Number of connection attempt elements provided with
-                           this primitive
-    connectAttempts      - This parameter is relevant only if
-                           status!=CSR_WIFI_NME_STATUS_SUCCESS.
-                           Points to the list of connection attempt elements
-                           provided with this primitive
-                           Each element of the list provides information about
-                           an AP on which the connection attempt was made and
-                           the error that occurred during the attempt.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->connectAttemptsCount = (connectAttemptsCount__); \
-    msg__->connectAttempts = (connectAttempts__);
-
-#define CsrWifiNmeProfileConnectCfmSendTo(dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
-    { \
-        CsrWifiNmeProfileConnectCfm *msg__; \
-        CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileConnectCfmSend(dst__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
-    CsrWifiNmeProfileConnectCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteAllReqSend
-
-  DESCRIPTION
-    Deletes all profiles present in the NME, but does NOT modify the
-    preferred profile list.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ, dst__, src__);
-
-#define CsrWifiNmeProfileDeleteAllReqSendTo(dst__, src__) \
-    { \
-        CsrWifiNmeProfileDeleteAllReq *msg__; \
-        CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileDeleteAllReqSend(src__) \
-    CsrWifiNmeProfileDeleteAllReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteAllCfmSend
-
-  DESCRIPTION
-    Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ.
-    Returns always CSR_WIFI_NME_STATUS_SUCCESS.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Indicates the success or otherwise of the requested operation, but
-             in this case it always set to success.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeProfileDeleteAllCfm *msg__; \
-        CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileDeleteAllCfmSend(dst__, status__) \
-    CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteReqSend
-
-  DESCRIPTION
-    Will delete the profile with a matching identity, but does NOT modify the
-    preferred profile list.
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    profileIdentity - Identity (BSSID, SSID) of profile to be deleted.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_REQ, dst__, src__); \
-    msg__->profileIdentity = (profileIdentity__);
-
-#define CsrWifiNmeProfileDeleteReqSendTo(dst__, src__, profileIdentity__) \
-    { \
-        CsrWifiNmeProfileDeleteReq *msg__; \
-        CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileDeleteReqSend(src__, profileIdentity__) \
-    CsrWifiNmeProfileDeleteReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profileIdentity__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteCfmSend
-
-  DESCRIPTION
-    Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ.
-    Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Indicates the success or otherwise of the requested operation.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeProfileDeleteCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeProfileDeleteCfm *msg__; \
-        CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileDeleteCfmSend(dst__, status__) \
-    CsrWifiNmeProfileDeleteCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDisconnectIndSend
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that informs that application that the current profile
-    connection has disconnected. The indication will contain information
-    about APs that it attempted to maintain the connection via i.e. in the
-    case of failed roaming.
-
-  PARAMETERS
-    queue                - Destination Task Queue
-    interfaceTag         - Interface Identifier; unique identifier of an
-                           interface
-    connectAttemptsCount - Number of connection attempt elements provided with
-                           this primitive
-    connectAttempts      - Points to the list of connection attempt elements
-                           provided with this primitive
-                           Each element of the list provides information about
-                           an AP on which the connection attempt was made and
-                           the error occurred during the attempt.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileDisconnectInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DISCONNECT_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->connectAttemptsCount = (connectAttemptsCount__); \
-    msg__->connectAttempts = (connectAttempts__);
-
-#define CsrWifiNmeProfileDisconnectIndSendTo(dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
-    { \
-        CsrWifiNmeProfileDisconnectInd *msg__; \
-        CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileDisconnectIndSend(dst__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
-    CsrWifiNmeProfileDisconnectIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, connectAttemptsCount__, connectAttempts__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileOrderSetReqSend
-
-  DESCRIPTION
-    Defines the preferred order that profiles present in the NME should be
-    used during the NME auto-connect behaviour.
-    If profileIdentitysCount == 0, it removes any existing preferred profile
-    list already present in the NME, effectively disabling the auto-connect
-    behaviour.
-    NOTE: Profile identities that do not match any profile stored in the NME
-    are ignored during the auto-connect procedure.
-    NOTE: during auto-connect the NME will only attempt to join an existing
-    adhoc network and it will never attempt to host an adhoc network; for
-    hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ
-
-  PARAMETERS
-    queue                 - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag          - Interface Identifier; unique identifier of an
-                            interface
-    profileIdentitysCount - The number of profiles identities in the list.
-    profileIdentitys      - Points to the list of profile identities.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->profileIdentitysCount = (profileIdentitysCount__); \
-    msg__->profileIdentitys = (profileIdentitys__);
-
-#define CsrWifiNmeProfileOrderSetReqSendTo(dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
-    { \
-        CsrWifiNmeProfileOrderSetReq *msg__; \
-        CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileOrderSetReqSend(src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
-    CsrWifiNmeProfileOrderSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileOrderSetCfmSend
-
-  DESCRIPTION
-    Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Indicates the success or otherwise of the requested
-                   operation.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeProfileOrderSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiNmeProfileOrderSetCfm *msg__; \
-        CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileOrderSetCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiNmeProfileOrderSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileSetReqSend
-
-  DESCRIPTION
-    Creates or updates an existing profile in the NME that matches the unique
-    identity of the profile. Each profile is identified by the combination of
-    BSSID and SSID. The profile contains all the required credentials for
-    attempting to connect to the network. Creating or updating a profile via
-    the NME PROFILE SET REQ does NOT add the profile to the preferred profile
-    list within the NME used for the NME auto-connect behaviour.
-
-  PARAMETERS
-    queue   - Message Source Task Queue (Cfm's will be sent to this Queue)
-    profile - Specifies the identity and credentials of the network.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_REQ, dst__, src__); \
-    msg__->profile = (profile__);
-
-#define CsrWifiNmeProfileSetReqSendTo(dst__, src__, profile__) \
-    { \
-        CsrWifiNmeProfileSetReq *msg__; \
-        CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileSetReqSend(src__, profile__) \
-    CsrWifiNmeProfileSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profile__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileSetCfmSend
-
-  DESCRIPTION
-    Reports the status of the NME PROFILE SET REQ; the request will only fail
-    if the details specified in the profile contains an invalid combination
-    of parameters for example specifying the profile as cloaked but not
-    specifying the SSID. The NME doesn't limit the number of profiles that
-    may be created. The NME assumes that the entity configuring it is aware
-    of the appropriate limits.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Indicates the success or otherwise of the requested operation.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeProfileSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeProfileSetCfm *msg__; \
-        CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileSetCfmSend(dst__, status__) \
-    CsrWifiNmeProfileSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileUpdateIndSend
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that informs that application that the contained profile has
-    changed.
-    For example, either the credentials EAP-FAST PAC file or the session data
-    within the profile has changed.
-    It is up to the application whether it stores this updated profile or
-    not.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    profile      - The identity and credentials of the network.
-
-*******************************************************************************/
-#define CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeProfileUpdateInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_UPDATE_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->profile = (profile__);
-
-#define CsrWifiNmeProfileUpdateIndSendTo(dst__, src__, interfaceTag__, profile__) \
-    { \
-        CsrWifiNmeProfileUpdateInd *msg__; \
-        CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeProfileUpdateIndSend(dst__, interfaceTag__, profile__) \
-    CsrWifiNmeProfileUpdateIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, profile__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimGsmAuthIndSend
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that requests the UICC Manager to perform a GSM
-    authentication on behalf of the NME. This indication is generated when
-    the NME is attempting to connect to a profile configured for EAP-SIM. An
-    application MUST register to receive this indication for the NME to
-    support the EAP-SIM credential types. Otherwise the NME has no route to
-    obtain the information from the UICC. EAP-SIM authentication requires 2
-    or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random
-    Challenges) are included.
-
-  PARAMETERS
-    queue       - Destination Task Queue
-    randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS)
-                  or 48 (3 RANDs).
-    rands       - 2 or 3 RANDs values.
-
-*******************************************************************************/
-#define CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_IND, dst__, src__); \
-    msg__->randsLength = (randsLength__); \
-    msg__->rands = (rands__);
-
-#define CsrWifiNmeSimGsmAuthIndSendTo(dst__, src__, randsLength__, rands__) \
-    { \
-        CsrWifiNmeSimGsmAuthInd *msg__; \
-        CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeSimGsmAuthIndSend(dst__, randsLength__, rands__) \
-    CsrWifiNmeSimGsmAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, randsLength__, rands__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimGsmAuthResSend
-
-  DESCRIPTION
-    Response from the application that received the NME SIM GSM AUTH IND. For
-    each GSM authentication round a GSM Ciphering key (Kc) and a signed
-    response (SRES) are produced. Since 2 or 3 GSM authentication rounds are
-    used the 2 or 3 Kc's obtained respectively are combined into one buffer
-    and similarly the 2 or 3 SRES's obtained are combined into another
-    buffer. The order of Kc values (SRES values respectively) in their buffer
-    is the same as that of their corresponding RAND values in the incoming
-    indication.
-
-  PARAMETERS
-    status     - Indicates the outcome of the requested operation:
-                 STATUS_SUCCESS or STATUS_ERROR
-    kcsLength  - Length in Bytes of Kc buffer. Legal values are: 16 or 24.
-    kcs        - Kc buffer holding 2 or 3 Kc values.
-    sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12.
-    sres       - SRES buffer holding 2 or 3 SRES values.
-
-*******************************************************************************/
-#define CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_RES, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->kcsLength = (kcsLength__); \
-    msg__->kcs = (kcs__); \
-    msg__->sresLength = (sresLength__); \
-    msg__->sres = (sres__);
-
-#define CsrWifiNmeSimGsmAuthResSendTo(dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
-    { \
-        CsrWifiNmeSimGsmAuthRes *msg__; \
-        CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeSimGsmAuthResSend(src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
-    CsrWifiNmeSimGsmAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, kcsLength__, kcs__, sresLength__, sres__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimImsiGetIndSend
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that requests the IMSI and UICC type from the UICC Manager.
-    This indication is generated when the NME is attempting to connect to a
-    profile configured for EAP-SIM/AKA. An application MUST register to
-    receive this indication for the NME to support the EAP-SIM/AKA credential
-    types. Otherwise the NME has no route to obtain the information from the
-    UICC.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-
-*******************************************************************************/
-#define CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_IND, dst__, src__);
-
-#define CsrWifiNmeSimImsiGetIndSendTo(dst__, src__) \
-    { \
-        CsrWifiNmeSimImsiGetInd *msg__; \
-        CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeSimImsiGetIndSend(dst__) \
-    CsrWifiNmeSimImsiGetIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimImsiGetResSend
-
-  DESCRIPTION
-    Response from the application that received the NME SIM IMSI GET IND.
-
-  PARAMETERS
-    status   - Indicates the outcome of the requested operation: STATUS_SUCCESS
-               or STATUS_ERROR.
-    imsi     - The value of the IMSI obtained from the UICC.
-    cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both).
-
-*******************************************************************************/
-#define CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_RES, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->imsi = (imsi__); \
-    msg__->cardType = (cardType__);
-
-#define CsrWifiNmeSimImsiGetResSendTo(dst__, src__, status__, imsi__, cardType__) \
-    { \
-        CsrWifiNmeSimImsiGetRes *msg__; \
-        CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeSimImsiGetResSend(src__, status__, imsi__, cardType__) \
-    CsrWifiNmeSimImsiGetResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, imsi__, cardType__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimUmtsAuthIndSend
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that requests the UICC Manager to perform a UMTS
-    authentication on behalf of the NME. This indication is generated when
-    the NME is attempting to connect to a profile configured for EAP-AKA. An
-    application MUST register to receive this indication for the NME to
-    support the EAP-AKA credential types. Otherwise the NME has no route to
-    obtain the information from the USIM. EAP-AKA requires one UMTS
-    authentication round and therefore only one RAND and one AUTN values are
-    included.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    rand   - UMTS RAND value.
-    autn   - UMTS AUTN value.
-
-*******************************************************************************/
-#define CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_IND, dst__, src__); \
-    memcpy(msg__->rand, (rand__), sizeof(u8) * 16); \
-    memcpy(msg__->autn, (autn__), sizeof(u8) * 16);
-
-#define CsrWifiNmeSimUmtsAuthIndSendTo(dst__, src__, rand__, autn__) \
-    { \
-        CsrWifiNmeSimUmtsAuthInd *msg__; \
-        CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeSimUmtsAuthIndSend(dst__, rand__, autn__) \
-    CsrWifiNmeSimUmtsAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, rand__, autn__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimUmtsAuthResSend
-
-  DESCRIPTION
-    Response from the application that received the NME SIM UMTS AUTH IND.
-    The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and
-    resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS.
-    The value of auts is only meaningful when
-    result=UMTS_AUTH_RESULT_SYNC_FAIL.
-
-  PARAMETERS
-    status             - Indicates the outcome of the requested operation:
-                         STATUS_SUCCESS or STATUS_ERROR.
-    result             - The result of UMTS authentication as performed by the
-                         UICC which could be: Success, Authentication Reject or
-                         Synchronisation Failure. For all these 3 outcomes the
-                         value of status is success.
-    umtsCipherKey      - The UMTS Cipher Key as calculated and returned by the
-                         UICC.
-    umtsIntegrityKey   - The UMTS Integrity Key as calculated and returned by
-                         the UICC.
-    resParameterLength - The length (in bytes) of the RES parameter (min=4; max
-                         = 16).
-    resParameter       - The RES parameter as calculated and returned by the
-                         UICC.
-    auts               - The AUTS parameter as calculated and returned by the
-                         UICC.
-
-*******************************************************************************/
-#define CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_RES, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->result = (result__); \
-    memcpy(msg__->umtsCipherKey, (umtsCipherKey__), sizeof(u8) * 16); \
-    memcpy(msg__->umtsIntegrityKey, (umtsIntegrityKey__), sizeof(u8) * 16); \
-    msg__->resParameterLength = (resParameterLength__); \
-    msg__->resParameter = (resParameter__); \
-    memcpy(msg__->auts, (auts__), sizeof(u8) * 14);
-
-#define CsrWifiNmeSimUmtsAuthResSendTo(dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
-    { \
-        CsrWifiNmeSimUmtsAuthRes *msg__; \
-        CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeSimUmtsAuthResSend(src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
-    CsrWifiNmeSimUmtsAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsCancelReqSend
-
-  DESCRIPTION
-    Requests the NME to cancel any WPS procedure that it is currently
-    performing. This includes WPS registrar activities started because of
-    CSR_WIFI_NME_AP_REGISTER.request
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiNmeWpsCancelReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiNmeWpsCancelReq *msg__; \
-        CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeWpsCancelReqSend(src__, interfaceTag__) \
-    CsrWifiNmeWpsCancelReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsCancelCfmSend
-
-  DESCRIPTION
-    Reports the status of the NME WPS REQ, the request is always SUCCESSFUL.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Only returns CSR_WIFI_NME_STATUS_SUCCESS
-
-*******************************************************************************/
-#define CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeWpsCancelCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiNmeWpsCancelCfm *msg__; \
-        CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeWpsCancelCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiNmeWpsCancelCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsCfmSend
-
-  DESCRIPTION
-    Reports the status of the NME WPS REQ.
-    If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the
-    identity and credentials of the AP.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Indicates the success or otherwise of the requested
-                   operation.
-    profile      - This parameter is relevant only if
-                   status==CSR_WIFI_NME_STATUS_SUCCESS.
-                   The identity and credentials of the network.
-
-*******************************************************************************/
-#define CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeWpsCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->profile = (profile__);
-
-#define CsrWifiNmeWpsCfmSendTo(dst__, src__, interfaceTag__, status__, profile__) \
-    { \
-        CsrWifiNmeWpsCfm *msg__; \
-        CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeWpsCfmSend(dst__, interfaceTag__, status__, profile__) \
-    CsrWifiNmeWpsCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, profile__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsConfigSetReqSend
-
-  DESCRIPTION
-    This primitive passes the WPS information for the device to NME. This may
-    be accepted only if no interface is active.
-
-  PARAMETERS
-    queue     - Message Source Task Queue (Cfm's will be sent to this Queue)
-    wpsConfig - WPS config.
-
-*******************************************************************************/
-#define CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_REQ, dst__, src__); \
-    msg__->wpsConfig = (wpsConfig__);
-
-#define CsrWifiNmeWpsConfigSetReqSendTo(dst__, src__, wpsConfig__) \
-    { \
-        CsrWifiNmeWpsConfigSetReq *msg__; \
-        CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeWpsConfigSetReqSend(src__, wpsConfig__) \
-    CsrWifiNmeWpsConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wpsConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsConfigSetCfmSend
-
-  DESCRIPTION
-    Confirm.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiNmeWpsConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiNmeWpsConfigSetCfm *msg__; \
-        CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeWpsConfigSetCfmSend(dst__, status__) \
-    CsrWifiNmeWpsConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsReqSend
-
-  DESCRIPTION
-    Requests the NME to look for WPS enabled APs and attempt to perform WPS
-    to determine the appropriate security credentials to connect to the AP.
-    If the PIN == '00000000' then 'push button mode' is indicated, otherwise
-    the PIN has to match that of the AP. 4 digit pin is passed by sending the
-    pin digits in pin[0]..pin[3] and rest of the contents filled with '-'.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    pin          - PIN value.
-    ssid         - Service Set identifier
-    bssid        - ID of Basic Service Set for which a WPS connection attempt is
-                   being made.
-
-*******************************************************************************/
-#define CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \
-    msg__ = kmalloc(sizeof(CsrWifiNmeWpsReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    memcpy(msg__->pin, (pin__), sizeof(u8) * 8); \
-    msg__->ssid = (ssid__); \
-    msg__->bssid = (bssid__);
-
-#define CsrWifiNmeWpsReqSendTo(dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \
-    { \
-        CsrWifiNmeWpsReq *msg__; \
-        CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__); \
-        CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
-    }
-
-#define CsrWifiNmeWpsReqSend(src__, interfaceTag__, pin__, ssid__, bssid__) \
-    CsrWifiNmeWpsReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, pin__, ssid__, bssid__)
-
-#endif /* CSR_WIFI_NME_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_prim.h b/drivers/staging/csr/csr_wifi_nme_prim.h
deleted file mode 100644 (file)
index 9a7927a..0000000
+++ /dev/null
@@ -1,1657 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_PRIM_H__
-#define CSR_WIFI_NME_PRIM_H__
-
-#include <linux/types.h>
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-#include "csr_wifi_common.h"
-#include "csr_result.h"
-#include "csr_wifi_fsm_event.h"
-#include "csr_wifi_sme_prim.h"
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_prim.h
-#endif
-
-#define CSR_WIFI_NME_PRIM                                               (0x0424)
-
-typedef CsrPrim CsrWifiNmePrim;
-
-typedef void (*CsrWifiNmeFrameFreeFunction)(void *frame);
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeAuthMode
-
-  DESCRIPTION
-    WiFi Authentication Mode
-
- VALUES
-    CSR_WIFI_NME_AUTH_MODE_80211_OPEN
-                   - Connects to an open system network (i.e. no authentication,
-                     no encryption) or to a WEP enabled network.
-    CSR_WIFI_NME_AUTH_MODE_80211_SHARED
-                   - Connect to a WEP enabled network.
-    CSR_WIFI_NME_AUTH_MODE_8021X_WPA
-                   - Connects to a WPA Enterprise enabled network.
-    CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK
-                   - Connects to a WPA with Pre-Shared Key enabled network.
-    CSR_WIFI_NME_AUTH_MODE_8021X_WPA2
-                   - Connects to a WPA2 Enterprise enabled network.
-    CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK
-                   - Connects to a WPA2 with Pre-Shared Key enabled network.
-    CSR_WIFI_NME_AUTH_MODE_8021X_CCKM
-                   - Connects to a CCKM enabled network.
-    CSR_WIFI_NME_AUTH_MODE_WAPI_WAI
-                   - Connects to a WAPI Enterprise enabled network.
-    CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK
-                   - Connects to a WAPI with Pre-Shared Key enabled network.
-    CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X
-                   - For future use.
-
-*******************************************************************************/
-typedef u16 CsrWifiNmeAuthMode;
-#define CSR_WIFI_NME_AUTH_MODE_80211_OPEN      ((CsrWifiNmeAuthMode) 0x0001)
-#define CSR_WIFI_NME_AUTH_MODE_80211_SHARED    ((CsrWifiNmeAuthMode) 0x0002)
-#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA       ((CsrWifiNmeAuthMode) 0x0004)
-#define CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK    ((CsrWifiNmeAuthMode) 0x0008)
-#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2      ((CsrWifiNmeAuthMode) 0x0010)
-#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK   ((CsrWifiNmeAuthMode) 0x0020)
-#define CSR_WIFI_NME_AUTH_MODE_8021X_CCKM      ((CsrWifiNmeAuthMode) 0x0040)
-#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAI        ((CsrWifiNmeAuthMode) 0x0080)
-#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK     ((CsrWifiNmeAuthMode) 0x0100)
-#define CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X   ((CsrWifiNmeAuthMode) 0x0200)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeBssType
-
-  DESCRIPTION
-    Type of BSS
-
- VALUES
-    CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE
-                   - Infrastructure BSS type where access to the network is via
-                     one or several Access Points.
-    CSR_WIFI_NME_BSS_TYPE_ADHOC
-                   - Adhoc or Independent BSS Type where one Station acts as a
-                     host and future stations can join the adhoc network without
-                     needing an access point.
-    CSR_WIFI_NME_BSS_TYPE_RESERVED
-                   - To be in sync with SME.This is not used.
-    CSR_WIFI_NME_BSS_TYPE_P2P
-                   - P2P mode of operation.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeBssType;
-#define CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE   ((CsrWifiNmeBssType) 0x00)
-#define CSR_WIFI_NME_BSS_TYPE_ADHOC            ((CsrWifiNmeBssType) 0x01)
-#define CSR_WIFI_NME_BSS_TYPE_RESERVED         ((CsrWifiNmeBssType) 0x02)
-#define CSR_WIFI_NME_BSS_TYPE_P2P              ((CsrWifiNmeBssType) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeCcxOptionsMask
-
-  DESCRIPTION
-    Enumeration type defining possible mask values for setting CCX options.
-
- VALUES
-    CSR_WIFI_NME_CCX_OPTION_NONE - No CCX option is set.
-    CSR_WIFI_NME_CCX_OPTION_CCKM - CCX option cckm is set.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeCcxOptionsMask;
-#define CSR_WIFI_NME_CCX_OPTION_NONE   ((CsrWifiNmeCcxOptionsMask) 0x00)
-#define CSR_WIFI_NME_CCX_OPTION_CCKM   ((CsrWifiNmeCcxOptionsMask) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConfigAction
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_PIN_ENTRY_PUSH_BUTTON -
-    CSR_WIFI_PIN_ENTRY_DISPLAY_PIN -
-    CSR_WIFI_PIN_ENTRY_ENTER_PIN   -
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeConfigAction;
-#define CSR_WIFI_PIN_ENTRY_PUSH_BUTTON   ((CsrWifiNmeConfigAction) 0x00)
-#define CSR_WIFI_PIN_ENTRY_DISPLAY_PIN   ((CsrWifiNmeConfigAction) 0x01)
-#define CSR_WIFI_PIN_ENTRY_ENTER_PIN     ((CsrWifiNmeConfigAction) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConnectionStatus
-
-  DESCRIPTION
-    Indicate the NME Connection Status when connecting or when disconnecting
-
- VALUES
-    CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED
-                   - NME is disconnected.
-    CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING
-                   - NME is in the process of connecting.
-    CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING
-                   - NME is in the authentication stage of a connection attempt.
-    CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED
-                   - NME is connected.
-    CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING
-                   - NME is in the process of disconnecting.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeConnectionStatus;
-#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED     ((CsrWifiNmeConnectionStatus) 0x00)
-#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING       ((CsrWifiNmeConnectionStatus) 0x01)
-#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING   ((CsrWifiNmeConnectionStatus) 0x02)
-#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED        ((CsrWifiNmeConnectionStatus) 0x03)
-#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING    ((CsrWifiNmeConnectionStatus) 0x04)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeCredentialType
-
-  DESCRIPTION
-    NME Credential Types
-
- VALUES
-    CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM
-                   - Credential Type Open System.
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64
-                   - Credential Type WEP-64
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128
-                   - Credential Type WEP-128
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK
-                   - Credential Type WPA Pre-Shared Key
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE
-                   - Credential Type WPA pass phrase
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK
-                   - Credential Type WPA2 Pre-Shared Key.
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE
-                   - Credential Type WPA2 pass phrase
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK
-                   - Credential Type WAPI Pre-Shared Key.
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE
-                   - Credential Type WAPI pass phrase
-    CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI
-                   - Credential Type WAPI certificates
-    CSR_WIFI_NME_CREDENTIAL_TYPE_8021X
-                   - Credential Type 802.1X: the associated type supports
-                     FAST/LEAP/TLS/TTLS/PEAP/etc.
-
-*******************************************************************************/
-typedef u16 CsrWifiNmeCredentialType;
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM       ((CsrWifiNmeCredentialType) 0x0000)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64             ((CsrWifiNmeCredentialType) 0x0001)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128            ((CsrWifiNmeCredentialType) 0x0002)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK           ((CsrWifiNmeCredentialType) 0x0003)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE    ((CsrWifiNmeCredentialType) 0x0004)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK          ((CsrWifiNmeCredentialType) 0x0005)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE   ((CsrWifiNmeCredentialType) 0x0006)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK          ((CsrWifiNmeCredentialType) 0x0007)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE   ((CsrWifiNmeCredentialType) 0x0008)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI              ((CsrWifiNmeCredentialType) 0x0009)
-#define CSR_WIFI_NME_CREDENTIAL_TYPE_8021X             ((CsrWifiNmeCredentialType) 0x000A)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEapMethod
-
-  DESCRIPTION
-    Outer EAP method with possibly inner method.
-
- VALUES
-    CSR_WIFI_NME_EAP_METHOD_TLS
-                   - EAP-TLS Method.
-    CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2
-                   - EAP-TTLS Method with MSCHAPV2.
-    CSR_WIFI_NME_EAP_METHOD_PEAP_GTC
-                   - EAP-PEAP Method with GTC.
-    CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2
-                   - EAP-PEAP Method with MSCHAPV2.
-    CSR_WIFI_NME_EAP_METHOD_SIM
-                   - EAP-SIM Method.
-    CSR_WIFI_NME_EAP_METHOD_AKA
-                   - EAP-AKA Method.
-    CSR_WIFI_NME_EAP_METHOD_FAST_GTC
-                   - EAP-FAST Method with GTC.
-    CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2
-                   - EAP-FAST Method with MSCHAPV2.
-    CSR_WIFI_NME_EAP_METHOD_LEAP
-                   - EAP-LEAP Method.
-
-*******************************************************************************/
-typedef u16 CsrWifiNmeEapMethod;
-#define CSR_WIFI_NME_EAP_METHOD_TLS             ((CsrWifiNmeEapMethod) 0x0001)
-#define CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2   ((CsrWifiNmeEapMethod) 0x0002)
-#define CSR_WIFI_NME_EAP_METHOD_PEAP_GTC        ((CsrWifiNmeEapMethod) 0x0004)
-#define CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2   ((CsrWifiNmeEapMethod) 0x0008)
-#define CSR_WIFI_NME_EAP_METHOD_SIM             ((CsrWifiNmeEapMethod) 0x0010)
-#define CSR_WIFI_NME_EAP_METHOD_AKA             ((CsrWifiNmeEapMethod) 0x0020)
-#define CSR_WIFI_NME_EAP_METHOD_FAST_GTC        ((CsrWifiNmeEapMethod) 0x0040)
-#define CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2   ((CsrWifiNmeEapMethod) 0x0080)
-#define CSR_WIFI_NME_EAP_METHOD_LEAP            ((CsrWifiNmeEapMethod) 0x0100)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEncryption
-
-  DESCRIPTION
-    WiFi Encryption method
-
- VALUES
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE
-                   - No encryprion set.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
-                   - 40 bytes WEP key for peer to peer communication.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
-                   - 104 bytes WEP key for peer to peer communication.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
-                   - TKIP key for peer to peer communication.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
-                   - CCMP key for peer to peer communication.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
-                   - SMS4 key for peer to peer communication.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40
-                   - 40 bytes WEP key for broadcast messages.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104
-                   - 104 bytes WEP key for broadcast messages.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP
-                   - TKIP key for broadcast messages.
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP
-                   - CCMP key for broadcast messages
-    CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4
-                   - SMS4 key for broadcast messages.
-
-*******************************************************************************/
-typedef u16 CsrWifiNmeEncryption;
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE              ((CsrWifiNmeEncryption) 0x0000)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40    ((CsrWifiNmeEncryption) 0x0001)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104   ((CsrWifiNmeEncryption) 0x0002)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP     ((CsrWifiNmeEncryption) 0x0004)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP     ((CsrWifiNmeEncryption) 0x0008)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4     ((CsrWifiNmeEncryption) 0x0010)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40       ((CsrWifiNmeEncryption) 0x0020)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104      ((CsrWifiNmeEncryption) 0x0040)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP        ((CsrWifiNmeEncryption) 0x0080)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP        ((CsrWifiNmeEncryption) 0x0100)
-#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4        ((CsrWifiNmeEncryption) 0x0200)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeIndications
-
-  DESCRIPTION
-    NME indications
-
- VALUES
-    CSR_WIFI_NME_INDICATIONS_IND_AP_STATION
-                   - NME AP Station Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_AP_STOP
-                   - NME AP Stop Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH
-                   - NME UMTS Authentication Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START
-                   - NME P2P Group Start Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS
-                   - NME P2P Group Status Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE
-                   - NME P2P Group Role Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT
-                   - NME Profile Disconnect Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE
-                   - NME Profile Update Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET
-                   - NME GET IMSI Indication.
-    CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH
-                   - NME GSM Authentication Indication.
-    CSR_WIFI_NME_INDICATIONS_ALL
-                   - Used to register for all available indications
-
-*******************************************************************************/
-typedef u32 CsrWifiNmeIndications;
-#define CSR_WIFI_NME_INDICATIONS_IND_AP_STATION           ((CsrWifiNmeIndications) 0x00100000)
-#define CSR_WIFI_NME_INDICATIONS_IND_AP_STOP              ((CsrWifiNmeIndications) 0x00200000)
-#define CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH        ((CsrWifiNmeIndications) 0x01000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START      ((CsrWifiNmeIndications) 0x02000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS     ((CsrWifiNmeIndications) 0x04000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE       ((CsrWifiNmeIndications) 0x08000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT   ((CsrWifiNmeIndications) 0x10000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE       ((CsrWifiNmeIndications) 0x20000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET         ((CsrWifiNmeIndications) 0x40000000)
-#define CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH         ((CsrWifiNmeIndications) 0x80000000)
-#define CSR_WIFI_NME_INDICATIONS_ALL                      ((CsrWifiNmeIndications) 0xFFFFFFFF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSecError
-
-  DESCRIPTION
-    NME Security Errors
-    place holder for the security library abort reason
-
- VALUES
-    CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN
-                   - Unknown Security Error.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeSecError;
-#define CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN   ((CsrWifiNmeSecError) 0x00)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimCardType
-
-  DESCRIPTION
-    (U)SIM Card (or UICC) types
-
- VALUES
-    CSR_WIFI_NME_SIM_CARD_TYPE_2G   - 2G SIM card, capable of performing GSM
-                                      authentication only.
-    CSR_WIFI_NME_SIM_CARD_TYPE_3G   - UICC supporting USIM application, capable
-                                      of performing UMTS authentication only.
-    CSR_WIFI_NME_SIM_CARD_TYPE_2G3G - UICC supporting both USIM and SIM
-                                      applications, capable of performing both
-                                      UMTS and GSM authentications.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeSimCardType;
-#define CSR_WIFI_NME_SIM_CARD_TYPE_2G     ((CsrWifiNmeSimCardType) 0x01)
-#define CSR_WIFI_NME_SIM_CARD_TYPE_3G     ((CsrWifiNmeSimCardType) 0x02)
-#define CSR_WIFI_NME_SIM_CARD_TYPE_2G3G   ((CsrWifiNmeSimCardType) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeUmtsAuthResult
-
-  DESCRIPTION
-    Only relevant for UMTS Authentication. It indicates if the UICC has
-    successfully authenticated the network or otherwise.
-
- VALUES
-    CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS
-                   - Successful outcome from USIM indicating that the card has
-                     successfully authenticated the network.
-    CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL
-                   - Unsuccessful outcome from USIM indicating that the card is
-                     requesting the network to synchronise and re-try again. If
-                     no further request is received an NME timer will expire and
-                     the authentication is aborted.
-    CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT
-                   - Unsuccessful outcome from USIM indicating that the card has
-                     rejected the network and that the authentication is
-                     aborted.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeUmtsAuthResult;
-#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS     ((CsrWifiNmeUmtsAuthResult) 0x00)
-#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL   ((CsrWifiNmeUmtsAuthResult) 0x01)
-#define CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT      ((CsrWifiNmeUmtsAuthResult) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWmmQosInfo
-
-  DESCRIPTION
-    Defines bits for the QoS Info octect as defined in the WMM specification.
-    The values of this type are used across the NME/SME/Router API's and they
-    must be kept consistent with the corresponding types in the .xml of the
-    other interfaces
-
- VALUES
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL
-                   - WMM AP may deliver all buffered frames.
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_VO
-                   - To enable the triggering and delivery of QoS Voice.
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_VI
-                   - To enable the triggering and delivery of QoS Video.
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_BK
-                   - To enable the triggering and delivery of QoS Background.
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_BE
-                   - To enable the triggering and delivery of QoS Best Effort.
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO
-                   - WMM AP may deliver a maximum of 2 buffered frames per
-                     Unscheduled Service Period (USP).
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR
-                   - WMM AP may deliver a maximum of 4 buffered frames per USP.
-    CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX
-                   - WMM AP may deliver a maximum of 6 buffered frames per USP.
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeWmmQosInfo;
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL    ((CsrWifiNmeWmmQosInfo) 0x00)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VO            ((CsrWifiNmeWmmQosInfo) 0x01)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VI            ((CsrWifiNmeWmmQosInfo) 0x02)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BK            ((CsrWifiNmeWmmQosInfo) 0x04)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BE            ((CsrWifiNmeWmmQosInfo) 0x08)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO    ((CsrWifiNmeWmmQosInfo) 0x20)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR   ((CsrWifiNmeWmmQosInfo) 0x40)
-#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX    ((CsrWifiNmeWmmQosInfo) 0x60)
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEapMethodMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiNmeEapMethod.
-
-*******************************************************************************/
-typedef u16 CsrWifiNmeEapMethodMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEncryptionMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiNmeEncryption
-
-*******************************************************************************/
-typedef u16 CsrWifiNmeEncryptionMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeIndicationsMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiNmeIndications
-
-*******************************************************************************/
-typedef u32 CsrWifiNmeIndicationsMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeNmeIndicationsMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiNmeNmeIndications.
-    Used to overlap the unused portion of the unifi_IndicationsMask For NME
-    specific indications
-
-*******************************************************************************/
-typedef u32 CsrWifiNmeNmeIndicationsMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWmmQosInfoMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiNmeWmmQosInfo
-
-*******************************************************************************/
-typedef u8 CsrWifiNmeWmmQosInfoMask;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEmpty
-
-  DESCRIPTION
-    Empty Structure to indicate that no credentials are available.
-
-  MEMBERS
-    empty  - Only element of the empty structure (always set to 0).
-
-*******************************************************************************/
-typedef struct
-{
-    u8 empty;
-} CsrWifiNmeEmpty;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmePassphrase
-
-  DESCRIPTION
-    Structure holding the ASCII Pass Phrase data.
-
-  MEMBERS
-    encryptionMode - Encryption type as defined in CsrWifiSmeEncryption.
-    passphrase     - Pass phrase ASCII value.
-
-*******************************************************************************/
-typedef struct
-{
-    u16      encryptionMode;
-    char *passphrase;
-} CsrWifiNmePassphrase;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmePsk
-
-  DESCRIPTION
-    Structure holding the Pre-Shared Key data.
-
-  MEMBERS
-    encryptionMode - Encryption type as defined in CsrWifiSmeEncryption.
-    psk            - Pre-Shared Key value.
-
-*******************************************************************************/
-typedef struct
-{
-    u16 encryptionMode;
-    u8  psk[32];
-} CsrWifiNmePsk;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWapiCredentials
-
-  DESCRIPTION
-    Structure holding WAPI credentials data.
-
-  MEMBERS
-    certificateLength   - Length in bytes of the following client certificate.
-    certificate         - The actual client certificate data (if present).
-                          DER/PEM format supported.
-    privateKeyLength    - Length in bytes of the following private key.
-    privateKey          - The actual private key. DER/PEM format.
-    caCertificateLength - Length in bytes of the following certificate authority
-                          certificate.
-    caCertificate       - The actual certificate authority certificate data. If
-                          not supplied the received certificate authority
-                          certificate is assumed to be validate, if present the
-                          received certificate is validated against it. DER/PEM
-                          format supported.
-
-*******************************************************************************/
-typedef struct
-{
-    u32 certificateLength;
-    u8 *certificate;
-    u16 privateKeyLength;
-    u8 *privateKey;
-    u32 caCertificateLength;
-    u8 *caCertificate;
-} CsrWifiNmeWapiCredentials;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConnectAttempt
-
-  DESCRIPTION
-    Structure holding Connection attempt data.
-
-  MEMBERS
-    bssid         - Id of Basic Service Set connections attempt have been made
-                    to.
-    status        - Status returned to indicate the success or otherwise of the
-                    connection attempt.
-    securityError - Security error status indicating the nature of the failure
-                    to connect.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress  bssid;
-    CsrResult          status;
-    CsrWifiNmeSecError securityError;
-} CsrWifiNmeConnectAttempt;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEapCredentials
-
-  DESCRIPTION
-    Supports the use of multiple EAP methods via a single structure. The
-    methods required are indicated by the value set in the eapMethodMask
-
-  MEMBERS
-    eapMethodMask
-                   - Bit mask of supported EAP methods
-                     Currently only supports the setting of one bit.
-                     Required for all the EAP methods.
-    authMode
-                   - Bit mask representing the authentication types that may be
-                     supported by a suitable AP. An AP must support at least one
-                     of the authentication types specified to be considered for
-                     connection. Required for all EAP methods.
-    encryptionMode
-                   - Bit mask representing the encryption types that may be
-                     supported by a suitable AP. An AP must support a suitable
-                     mix of the pairwise and group encryption types requested to
-                     be considered for connection. Required for all EAP methods.
-    userName
-                   - User name. Required for all EAP methods except: SIM or AKA.
-    userPassword
-                   - User Password. Required for all EAP methods except: TLS,
-                     SIM or AKA.
-    authServerUserIdentity
-                   - Authentication server user Identity. Required for all EAP
-                     methods except: TLS, SIM, AKA or FAST.
-    clientCertificateLength
-                   - Length in bytes of the following client certificate (if
-                     present). Only required for TLS.
-    clientCertificate
-                   - The actual client certificate data (if present). Only
-                     required for TLS. DER/PEM format supported.
-    certificateAuthorityCertificateLength
-                   - Length in bytes of the following certificate authority
-                     certificate (if present). Optional for TLS, TTLS, PEAP.
-    certificateAuthorityCertificate
-                   - The actual certificate authority certificate data (if
-                     present). If not supplied the received certificate
-                     authority certificate is assumed to be valid, if present
-                     the received certificate is validated against it. Optional
-                     for TLS, TTLS, PEAP. DER/PEM format supported.
-    privateKeyLength
-                   - Length in bytes of the following private key (if present).
-                     Only required for TLS.
-    privateKey
-                   - The actual private key (if present). Only required for TLS.
-                     DER/PEM format, maybe password protected.
-    privateKeyPassword
-                   - Optional password to protect the private key.
-    sessionLength
-                   - Length in bytes of the following session field Supported
-                     for all EAP methods except: SIM or AKA.
-    session
-                   - Session information to support faster re-authentication.
-                     Supported for all EAP methods except: SIM or AKA.
-    allowPacProvisioning
-                   - If TRUE: PAC provisioning is allowed 'over-the_air';
-                     If FALSE: a PAC must be supplied.
-                     Only required for FAST.
-    pacLength
-                   - Length the following PAC field. If allowPacProvisioning is
-                     FALSE then the PAC MUST be supplied (i.e. non-zero). Only
-                     required for FAST.
-    pac
-                   - The actual PAC data. If allowPacProvisioning is FALSE then
-                     the PAC MUST be supplied. Only required for FAST.
-    pacPassword
-                   - Optional password to protect the PAC. Only required for
-                     FAST.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiNmeEapMethodMask  eapMethodMask;
-    CsrWifiSmeAuthModeMask   authMode;
-    CsrWifiNmeEncryptionMask encryptionMode;
-    char           *userName;
-    char           *userPassword;
-    char           *authServerUserIdentity;
-    u32                clientCertificateLength;
-    u8                *clientCertificate;
-    u32                certificateAuthorityCertificateLength;
-    u8                *certificateAuthorityCertificate;
-    u16                privateKeyLength;
-    u8                *privateKey;
-    char           *privateKeyPassword;
-    u32                sessionLength;
-    u8                *session;
-    u8                  allowPacProvisioning;
-    u32                pacLength;
-    u8                *pac;
-    char           *pacPassword;
-} CsrWifiNmeEapCredentials;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmePeerConfig
-
-  DESCRIPTION
-    Structure holding Peer Config data.
-
-  MEMBERS
-    p2pDeviceId         -
-    groupCapabilityMask -
-    groupOwnerIntent    -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress                p2pDeviceId;
-    CsrWifiSmeP2pGroupCapabilityMask groupCapabilityMask;
-    u8                         groupOwnerIntent;
-} CsrWifiNmePeerConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileIdentity
-
-  DESCRIPTION
-    The identity of a profile is defined as the unique combination the BSSID
-    and SSID.
-
-  MEMBERS
-    bssid  - ID of Basic Service Set for or the P2pDevice address of the GO for
-             which a connection attempt was made.
-    ssid   - Service Set Id.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress bssid;
-    CsrWifiSsid       ssid;
-} CsrWifiNmeProfileIdentity;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWep128Keys
-
-  DESCRIPTION
-    Structure holding WEP Authentication Type and WEP keys that can be used
-    when using WEP128.
-
-  MEMBERS
-    wepAuthType    - Mask to select the WEP authentication type (Open or Shared)
-    selectedWepKey - Index to one of the four keys below indicating the
-                     currently used WEP key.
-    key1           - Value for key number 1.
-    key2           - Value for key number 2.
-    key3           - Value for key number 3.
-    key4           - Value for key number 4.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeAuthModeMask wepAuthType;
-    u8               selectedWepKey;
-    u8               key1[13];
-    u8               key2[13];
-    u8               key3[13];
-    u8               key4[13];
-} CsrWifiNmeWep128Keys;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWep64Keys
-
-  DESCRIPTION
-    Structure for holding WEP Authentication Type and WEP keys that can be
-    used when using WEP64.
-
-  MEMBERS
-    wepAuthType    - Mask to select the WEP authentication type (Open or Shared)
-    selectedWepKey - Index to one of the four keys below indicating the
-                     currently used WEP key.
-    key1           - Value for key number 1.
-    key2           - Value for key number 2.
-    key3           - Value for key number 3.
-    key4           - Value for key number 4.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeAuthModeMask wepAuthType;
-    u8               selectedWepKey;
-    u8               key1[5];
-    u8               key2[5];
-    u8               key3[5];
-    u8               key4[5];
-} CsrWifiNmeWep64Keys;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeCredentials
-
-  DESCRIPTION
-    Structure containing the Credentials data.
-
-  MEMBERS
-    credentialType            - Credential type value (as defined in the
-                                enumeration type).
-    credential                - Union containing credentials which depends on
-                                credentialType parameter.
-    credentialeap             -
-    credentialwapiPassphrase  -
-    credentialwpa2Passphrase  -
-    credentialwpa2Psk         -
-    credentialwapiPsk         -
-    credentialwpaPassphrase   -
-    credentialwapi            -
-    credentialwep128Key       -
-    credentialwpaPsk          -
-    credentialopenSystem      -
-    credentialwep64Key        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiNmeCredentialType credentialType;
-    union {
-        CsrWifiNmeEapCredentials  eap;
-        CsrWifiNmePassphrase      wapiPassphrase;
-        CsrWifiNmePassphrase      wpa2Passphrase;
-        CsrWifiNmePsk             wpa2Psk;
-        CsrWifiNmePsk             wapiPsk;
-        CsrWifiNmePassphrase      wpaPassphrase;
-        CsrWifiNmeWapiCredentials wapi;
-        CsrWifiNmeWep128Keys      wep128Key;
-        CsrWifiNmePsk             wpaPsk;
-        CsrWifiNmeEmpty           openSystem;
-        CsrWifiNmeWep64Keys       wep64Key;
-    } credential;
-} CsrWifiNmeCredentials;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfile
-
-  DESCRIPTION
-    Structure containing the Profile data.
-
-  MEMBERS
-    profileIdentity - Profile Identity.
-    wmmQosInfoMask  - Mask for WMM QoS information.
-    bssType         - Type of BSS (Infrastructure or Adhoc).
-    channelNo       - Channel Number.
-    ccxOptionsMask  - Options mask for Cisco Compatible Extentions.
-    cloakedSsid     - Flag to decide whether the SSID is cloaked (not
-                      transmitted) or not.
-    credentials     - Credentials data.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiNmeProfileIdentity profileIdentity;
-    CsrWifiNmeWmmQosInfoMask  wmmQosInfoMask;
-    CsrWifiNmeBssType         bssType;
-    u8                  channelNo;
-    u8                  ccxOptionsMask;
-    u8                   cloakedSsid;
-    CsrWifiNmeCredentials     credentials;
-} CsrWifiNmeProfile;
-
-
-/* Downstream */
-#define CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST            (0x0000)
-
-#define CSR_WIFI_NME_PROFILE_SET_REQ                      ((CsrWifiNmePrim) (0x0000 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_DELETE_REQ                   ((CsrWifiNmePrim) (0x0001 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ               ((CsrWifiNmePrim) (0x0002 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_ORDER_SET_REQ                ((CsrWifiNmePrim) (0x0003 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_CONNECT_REQ                  ((CsrWifiNmePrim) (0x0004 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_WPS_REQ                              ((CsrWifiNmePrim) (0x0005 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_WPS_CANCEL_REQ                       ((CsrWifiNmePrim) (0x0006 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ            ((CsrWifiNmePrim) (0x0007 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_SIM_IMSI_GET_RES                     ((CsrWifiNmePrim) (0x0008 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_SIM_GSM_AUTH_RES                     ((CsrWifiNmePrim) (0x0009 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_SIM_UMTS_AUTH_RES                    ((CsrWifiNmePrim) (0x000A + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_WPS_CONFIG_SET_REQ                   ((CsrWifiNmePrim) (0x000B + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_NME_EVENT_MASK_SET_REQ                   ((CsrWifiNmePrim) (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
-
-
-#define CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST           (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)
-
-/* Upstream */
-#define CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST              (0x0000 + CSR_PRIM_UPSTREAM)
-
-#define CSR_WIFI_NME_PROFILE_SET_CFM                      ((CsrWifiNmePrim)(0x0000 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_DELETE_CFM                   ((CsrWifiNmePrim)(0x0001 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM               ((CsrWifiNmePrim)(0x0002 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_ORDER_SET_CFM                ((CsrWifiNmePrim)(0x0003 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_CONNECT_CFM                  ((CsrWifiNmePrim)(0x0004 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_WPS_CFM                              ((CsrWifiNmePrim)(0x0005 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_WPS_CANCEL_CFM                       ((CsrWifiNmePrim)(0x0006 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM            ((CsrWifiNmePrim)(0x0007 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_UPDATE_IND                   ((CsrWifiNmePrim)(0x0008 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_PROFILE_DISCONNECT_IND               ((CsrWifiNmePrim)(0x0009 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_SIM_IMSI_GET_IND                     ((CsrWifiNmePrim)(0x000A + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_SIM_GSM_AUTH_IND                     ((CsrWifiNmePrim)(0x000B + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_SIM_UMTS_AUTH_IND                    ((CsrWifiNmePrim)(0x000C + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_WPS_CONFIG_SET_CFM                   ((CsrWifiNmePrim)(0x000D + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_NME_EVENT_MASK_SET_CFM                   ((CsrWifiNmePrim)(0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
-
-#define CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST             (0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)
-
-#define CSR_WIFI_NME_PRIM_DOWNSTREAM_COUNT             (CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)
-#define CSR_WIFI_NME_PRIM_UPSTREAM_COUNT               (CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST   + 1 - CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileSetReq
-
-  DESCRIPTION
-    Creates or updates an existing profile in the NME that matches the unique
-    identity of the profile. Each profile is identified by the combination of
-    BSSID and SSID. The profile contains all the required credentials for
-    attempting to connect to the network. Creating or updating a profile via
-    the NME PROFILE SET REQ does NOT add the profile to the preferred profile
-    list within the NME used for the NME auto-connect behaviour.
-
-  MEMBERS
-    common  - Common header for use with the CsrWifiFsm Module
-    profile - Specifies the identity and credentials of the network.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    CsrWifiNmeProfile profile;
-} CsrWifiNmeProfileSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteReq
-
-  DESCRIPTION
-    Will delete the profile with a matching identity, but does NOT modify the
-    preferred profile list.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    profileIdentity - Identity (BSSID, SSID) of profile to be deleted.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    CsrWifiNmeProfileIdentity profileIdentity;
-} CsrWifiNmeProfileDeleteReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteAllReq
-
-  DESCRIPTION
-    Deletes all profiles present in the NME, but does NOT modify the
-    preferred profile list.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiNmeProfileDeleteAllReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileOrderSetReq
-
-  DESCRIPTION
-    Defines the preferred order that profiles present in the NME should be
-    used during the NME auto-connect behaviour.
-    If profileIdentitysCount == 0, it removes any existing preferred profile
-    list already present in the NME, effectively disabling the auto-connect
-    behaviour.
-    NOTE: Profile identities that do not match any profile stored in the NME
-    are ignored during the auto-connect procedure.
-    NOTE: during auto-connect the NME will only attempt to join an existing
-    adhoc network and it will never attempt to host an adhoc network; for
-    hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ
-
-  MEMBERS
-    common                - Common header for use with the CsrWifiFsm Module
-    interfaceTag          - Interface Identifier; unique identifier of an
-                            interface
-    profileIdentitysCount - The number of profiles identities in the list.
-    profileIdentitys      - Points to the list of profile identities.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent            common;
-    u16                  interfaceTag;
-    u8                   profileIdentitysCount;
-    CsrWifiNmeProfileIdentity *profileIdentitys;
-} CsrWifiNmeProfileOrderSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileConnectReq
-
-  DESCRIPTION
-    Requests the NME to attempt to connect to the specified profile.
-    Overrides any current connection attempt.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    profileIdentity - Identity (BSSID, SSID) of profile to be connected to.
-                      It must match an existing profile in the NME.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrWifiNmeProfileIdentity profileIdentity;
-} CsrWifiNmeProfileConnectReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsReq
-
-  DESCRIPTION
-    Requests the NME to look for WPS enabled APs and attempt to perform WPS
-    to determine the appropriate security credentials to connect to the AP.
-    If the PIN == '00000000' then 'push button mode' is indicated, otherwise
-    the PIN has to match that of the AP. 4 digit pin is passed by sending the
-    pin digits in pin[0]..pin[3] and rest of the contents filled with '-'.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    pin          - PIN value.
-    ssid         - Service Set identifier
-    bssid        - ID of Basic Service Set for which a WPS connection attempt is
-                   being made.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    u8          pin[8];
-    CsrWifiSsid       ssid;
-    CsrWifiMacAddress bssid;
-} CsrWifiNmeWpsReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsCancelReq
-
-  DESCRIPTION
-    Requests the NME to cancel any WPS procedure that it is currently
-    performing. This includes WPS registrar activities started because of
-    CSR_WIFI_NME_AP_REGISTER.request
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiNmeWpsCancelReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConnectionStatusGetReq
-
-  DESCRIPTION
-    Requests the current connection status of the NME.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiNmeConnectionStatusGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimImsiGetRes
-
-  DESCRIPTION
-    Response from the application that received the NME SIM IMSI GET IND.
-
-  MEMBERS
-    common   - Common header for use with the CsrWifiFsm Module
-    status   - Indicates the outcome of the requested operation: STATUS_SUCCESS
-               or STATUS_ERROR.
-    imsi     - The value of the IMSI obtained from the UICC.
-    cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both).
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrResult             status;
-    char        *imsi;
-    CsrWifiNmeSimCardType cardType;
-} CsrWifiNmeSimImsiGetRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimGsmAuthRes
-
-  DESCRIPTION
-    Response from the application that received the NME SIM GSM AUTH IND. For
-    each GSM authentication round a GSM Ciphering key (Kc) and a signed
-    response (SRES) are produced. Since 2 or 3 GSM authentication rounds are
-    used the 2 or 3 Kc's obtained respectively are combined into one buffer
-    and similarly the 2 or 3 SRES's obtained are combined into another
-    buffer. The order of Kc values (SRES values respectively) in their buffer
-    is the same as that of their corresponding RAND values in the incoming
-    indication.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    status     - Indicates the outcome of the requested operation:
-                 STATUS_SUCCESS or STATUS_ERROR
-    kcsLength  - Length in Bytes of Kc buffer. Legal values are: 16 or 24.
-    kcs        - Kc buffer holding 2 or 3 Kc values.
-    sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12.
-    sres       - SRES buffer holding 2 or 3 SRES values.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-    u8        kcsLength;
-    u8       *kcs;
-    u8        sresLength;
-    u8       *sres;
-} CsrWifiNmeSimGsmAuthRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimUmtsAuthRes
-
-  DESCRIPTION
-    Response from the application that received the NME SIM UMTS AUTH IND.
-    The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and
-    resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS.
-    The value of auts is only meaningful when
-    result=UMTS_AUTH_RESULT_SYNC_FAIL.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    status             - Indicates the outcome of the requested operation:
-                         STATUS_SUCCESS or STATUS_ERROR.
-    result             - The result of UMTS authentication as performed by the
-                         UICC which could be: Success, Authentication Reject or
-                         Synchronisation Failure. For all these 3 outcomes the
-                         value of status is success.
-    umtsCipherKey      - The UMTS Cipher Key as calculated and returned by the
-                         UICC.
-    umtsIntegrityKey   - The UMTS Integrity Key as calculated and returned by
-                         the UICC.
-    resParameterLength - The length (in bytes) of the RES parameter (min=4; max
-                         = 16).
-    resParameter       - The RES parameter as calculated and returned by the
-                         UICC.
-    auts               - The AUTS parameter as calculated and returned by the
-                         UICC.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent          common;
-    CsrResult                status;
-    CsrWifiNmeUmtsAuthResult result;
-    u8                 umtsCipherKey[16];
-    u8                 umtsIntegrityKey[16];
-    u8                 resParameterLength;
-    u8                *resParameter;
-    u8                 auts[14];
-} CsrWifiNmeSimUmtsAuthRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsConfigSetReq
-
-  DESCRIPTION
-    This primitive passes the WPS information for the device to NME. This may
-    be accepted only if no interface is active.
-
-  MEMBERS
-    common    - Common header for use with the CsrWifiFsm Module
-    wpsConfig - WPS config.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    CsrWifiSmeWpsConfig wpsConfig;
-} CsrWifiNmeWpsConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEventMaskSetReq
-
-  DESCRIPTION
-    The wireless manager application may register with the NME to receive
-    notification of interesting events. Indications will be sent only if the
-    wireless manager explicitly registers to be notified of that event.
-    indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask.
-
-  MEMBERS
-    common  - Common header for use with the CsrWifiFsm Module
-    indMask - Set mask with values from CsrWifiNmeIndications
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    CsrWifiNmeIndicationsMask indMask;
-} CsrWifiNmeEventMaskSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileSetCfm
-
-  DESCRIPTION
-    Reports the status of the NME PROFILE SET REQ; the request will only fail
-    if the details specified in the profile contains an invalid combination
-    of parameters for example specifying the profile as cloaked but not
-    specifying the SSID. The NME doesn't limit the number of profiles that
-    may be created. The NME assumes that the entity configuring it is aware
-    of the appropriate limits.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Indicates the success or otherwise of the requested operation.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeProfileSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteCfm
-
-  DESCRIPTION
-    Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ.
-    Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Indicates the success or otherwise of the requested operation.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeProfileDeleteCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDeleteAllCfm
-
-  DESCRIPTION
-    Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ.
-    Returns always CSR_WIFI_NME_STATUS_SUCCESS.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Indicates the success or otherwise of the requested operation, but
-             in this case it always set to success.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeProfileDeleteAllCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileOrderSetCfm
-
-  DESCRIPTION
-    Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Indicates the success or otherwise of the requested
-                   operation.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiNmeProfileOrderSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileConnectCfm
-
-  DESCRIPTION
-    Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the
-    connectAttempt parameters contain details of the APs that the NME
-    attempted to connect to before reporting the failure of the request.
-
-  MEMBERS
-    common               - Common header for use with the CsrWifiFsm Module
-    interfaceTag         - Interface Identifier; unique identifier of an
-                           interface
-    status               - Indicates the success or otherwise of the requested
-                           operation.
-    connectAttemptsCount - This parameter is relevant only if
-                           status!=CSR_WIFI_NME_STATUS_SUCCESS.
-                           Number of connection attempt elements provided with
-                           this primitive
-    connectAttempts      - This parameter is relevant only if
-                           status!=CSR_WIFI_NME_STATUS_SUCCESS.
-                           Points to the list of connection attempt elements
-                           provided with this primitive
-                           Each element of the list provides information about
-                           an AP on which the connection attempt was made and
-                           the error that occurred during the attempt.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrResult                 status;
-    u8                  connectAttemptsCount;
-    CsrWifiNmeConnectAttempt *connectAttempts;
-} CsrWifiNmeProfileConnectCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsCfm
-
-  DESCRIPTION
-    Reports the status of the NME WPS REQ.
-    If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the
-    identity and credentials of the AP.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Indicates the success or otherwise of the requested
-                   operation.
-    profile      - This parameter is relevant only if
-                   status==CSR_WIFI_NME_STATUS_SUCCESS.
-                   The identity and credentials of the network.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    CsrResult         status;
-    CsrWifiNmeProfile profile;
-} CsrWifiNmeWpsCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsCancelCfm
-
-  DESCRIPTION
-    Reports the status of the NME WPS REQ, the request is always SUCCESSFUL.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Only returns CSR_WIFI_NME_STATUS_SUCCESS
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiNmeWpsCancelCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeConnectionStatusGetCfm
-
-  DESCRIPTION
-    Reports the connection status of the NME.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    status           - Indicates the success or otherwise of the requested
-                       operation.
-    connectionStatus - NME current connection status
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent            common;
-    u16                  interfaceTag;
-    CsrResult                  status;
-    CsrWifiNmeConnectionStatus connectionStatus;
-} CsrWifiNmeConnectionStatusGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileUpdateInd
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that informs that application that the contained profile has
-    changed.
-    For example, either the credentials EAP-FAST PAC file or the session data
-    within the profile has changed.
-    It is up to the application whether it stores this updated profile or
-    not.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    profile      - The identity and credentials of the network.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    CsrWifiNmeProfile profile;
-} CsrWifiNmeProfileUpdateInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeProfileDisconnectInd
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that informs that application that the current profile
-    connection has disconnected. The indication will contain information
-    about APs that it attempted to maintain the connection via i.e. in the
-    case of failed roaming.
-
-  MEMBERS
-    common               - Common header for use with the CsrWifiFsm Module
-    interfaceTag         - Interface Identifier; unique identifier of an
-                           interface
-    connectAttemptsCount - Number of connection attempt elements provided with
-                           this primitive
-    connectAttempts      - Points to the list of connection attempt elements
-                           provided with this primitive
-                           Each element of the list provides information about
-                           an AP on which the connection attempt was made and
-                           the error occurred during the attempt.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    u8                  connectAttemptsCount;
-    CsrWifiNmeConnectAttempt *connectAttempts;
-} CsrWifiNmeProfileDisconnectInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimImsiGetInd
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that requests the IMSI and UICC type from the UICC Manager.
-    This indication is generated when the NME is attempting to connect to a
-    profile configured for EAP-SIM/AKA. An application MUST register to
-    receive this indication for the NME to support the EAP-SIM/AKA credential
-    types. Otherwise the NME has no route to obtain the information from the
-    UICC.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiNmeSimImsiGetInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimGsmAuthInd
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that requests the UICC Manager to perform a GSM
-    authentication on behalf of the NME. This indication is generated when
-    the NME is attempting to connect to a profile configured for EAP-SIM. An
-    application MUST register to receive this indication for the NME to
-    support the EAP-SIM credential types. Otherwise the NME has no route to
-    obtain the information from the UICC. EAP-SIM authentication requires 2
-    or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random
-    Challenges) are included.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS)
-                  or 48 (3 RANDs).
-    rands       - 2 or 3 RANDs values.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u8        randsLength;
-    u8       *rands;
-} CsrWifiNmeSimGsmAuthInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeSimUmtsAuthInd
-
-  DESCRIPTION
-    Indication generated from the NME (if an application subscribes to
-    receive it) that requests the UICC Manager to perform a UMTS
-    authentication on behalf of the NME. This indication is generated when
-    the NME is attempting to connect to a profile configured for EAP-AKA. An
-    application MUST register to receive this indication for the NME to
-    support the EAP-AKA credential types. Otherwise the NME has no route to
-    obtain the information from the USIM. EAP-AKA requires one UMTS
-    authentication round and therefore only one RAND and one AUTN values are
-    included.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    rand   - UMTS RAND value.
-    autn   - UMTS AUTN value.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u8        rand[16];
-    u8        autn[16];
-} CsrWifiNmeSimUmtsAuthInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeWpsConfigSetCfm
-
-  DESCRIPTION
-    Confirm.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeWpsConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiNmeEventMaskSetCfm
-
-  DESCRIPTION
-    The NME calls the primitive to report the result of the request
-    primitive.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiNmeEventMaskSetCfm;
-
-#endif /* CSR_WIFI_NME_PRIM_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_nme_serialize.h b/drivers/staging/csr/csr_wifi_nme_serialize.h
deleted file mode 100644 (file)
index ebac484..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_SERIALIZE_H__
-#define CSR_WIFI_NME_SERIALIZE_H__
-
-#include "csr_wifi_msgconv.h"
-#include "csr_wifi_nme_prim.h"
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_serialize.h
-#endif
-
-extern void CsrWifiNmePfree(void *ptr);
-
-extern u8* CsrWifiNmeProfileSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileSetReqSizeof(void *msg);
-extern void CsrWifiNmeProfileSetReqSerFree(void *msg);
-
-extern u8* CsrWifiNmeProfileDeleteReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileDeleteReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileDeleteReqSizeof(void *msg);
-#define CsrWifiNmeProfileDeleteReqSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeProfileDeleteAllReqSer CsrWifiEventSer
-#define CsrWifiNmeProfileDeleteAllReqDes CsrWifiEventDes
-#define CsrWifiNmeProfileDeleteAllReqSizeof CsrWifiEventSizeof
-#define CsrWifiNmeProfileDeleteAllReqSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeProfileOrderSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileOrderSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileOrderSetReqSizeof(void *msg);
-extern void CsrWifiNmeProfileOrderSetReqSerFree(void *msg);
-
-extern u8* CsrWifiNmeProfileConnectReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileConnectReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileConnectReqSizeof(void *msg);
-#define CsrWifiNmeProfileConnectReqSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeWpsReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeWpsReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeWpsReqSizeof(void *msg);
-#define CsrWifiNmeWpsReqSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeWpsCancelReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeWpsCancelReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeWpsCancelReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeWpsCancelReqSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeConnectionStatusGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeConnectionStatusGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeConnectionStatusGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeConnectionStatusGetReqSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeSimImsiGetResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeSimImsiGetResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeSimImsiGetResSizeof(void *msg);
-extern void CsrWifiNmeSimImsiGetResSerFree(void *msg);
-
-extern u8* CsrWifiNmeSimGsmAuthResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeSimGsmAuthResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeSimGsmAuthResSizeof(void *msg);
-extern void CsrWifiNmeSimGsmAuthResSerFree(void *msg);
-
-extern u8* CsrWifiNmeSimUmtsAuthResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeSimUmtsAuthResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeSimUmtsAuthResSizeof(void *msg);
-extern void CsrWifiNmeSimUmtsAuthResSerFree(void *msg);
-
-extern u8* CsrWifiNmeWpsConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeWpsConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeWpsConfigSetReqSizeof(void *msg);
-extern void CsrWifiNmeWpsConfigSetReqSerFree(void *msg);
-
-#define CsrWifiNmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser
-#define CsrWifiNmeEventMaskSetReqDes CsrWifiEventCsrUint32Des
-#define CsrWifiNmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof
-#define CsrWifiNmeEventMaskSetReqSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeProfileSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeProfileSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeProfileSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeProfileSetCfmSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeProfileDeleteCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeProfileDeleteCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeProfileDeleteCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeProfileDeleteCfmSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeProfileDeleteAllCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeProfileDeleteAllCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeProfileDeleteAllCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeProfileDeleteAllCfmSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeProfileOrderSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileOrderSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileOrderSetCfmSizeof(void *msg);
-#define CsrWifiNmeProfileOrderSetCfmSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeProfileConnectCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileConnectCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileConnectCfmSizeof(void *msg);
-extern void CsrWifiNmeProfileConnectCfmSerFree(void *msg);
-
-extern u8* CsrWifiNmeWpsCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeWpsCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeWpsCfmSizeof(void *msg);
-extern void CsrWifiNmeWpsCfmSerFree(void *msg);
-
-extern u8* CsrWifiNmeWpsCancelCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeWpsCancelCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeWpsCancelCfmSizeof(void *msg);
-#define CsrWifiNmeWpsCancelCfmSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeConnectionStatusGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeConnectionStatusGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeConnectionStatusGetCfmSizeof(void *msg);
-#define CsrWifiNmeConnectionStatusGetCfmSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeProfileUpdateIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileUpdateIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileUpdateIndSizeof(void *msg);
-extern void CsrWifiNmeProfileUpdateIndSerFree(void *msg);
-
-extern u8* CsrWifiNmeProfileDisconnectIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeProfileDisconnectIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeProfileDisconnectIndSizeof(void *msg);
-extern void CsrWifiNmeProfileDisconnectIndSerFree(void *msg);
-
-#define CsrWifiNmeSimImsiGetIndSer CsrWifiEventSer
-#define CsrWifiNmeSimImsiGetIndDes CsrWifiEventDes
-#define CsrWifiNmeSimImsiGetIndSizeof CsrWifiEventSizeof
-#define CsrWifiNmeSimImsiGetIndSerFree CsrWifiNmePfree
-
-extern u8* CsrWifiNmeSimGsmAuthIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeSimGsmAuthIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeSimGsmAuthIndSizeof(void *msg);
-extern void CsrWifiNmeSimGsmAuthIndSerFree(void *msg);
-
-extern u8* CsrWifiNmeSimUmtsAuthIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiNmeSimUmtsAuthIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiNmeSimUmtsAuthIndSizeof(void *msg);
-#define CsrWifiNmeSimUmtsAuthIndSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeWpsConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeWpsConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeWpsConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeWpsConfigSetCfmSerFree CsrWifiNmePfree
-
-#define CsrWifiNmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiNmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiNmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiNmeEventMaskSetCfmSerFree CsrWifiNmePfree
-
-#endif /* CSR_WIFI_NME_SERIALIZE_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_nme_task.h b/drivers/staging/csr/csr_wifi_nme_task.h
deleted file mode 100644 (file)
index 84e973a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_NME_TASK_H__
-#define CSR_WIFI_NME_TASK_H__
-
-#include <linux/types.h>
-#include "csr_sched.h"
-
-#ifndef CSR_WIFI_NME_ENABLE
-#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_task.h
-#endif
-
-#define CSR_WIFI_NME_LOG_ID 0x1203FFFF
-extern CsrSchedQid CSR_WIFI_NME_IFACEQUEUE;
-
-#endif /* CSR_WIFI_NME_TASK_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_private_common.h b/drivers/staging/csr/csr_wifi_private_common.h
deleted file mode 100644 (file)
index ee3bd51..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_PRIVATE_COMMON_H__
-#define CSR_WIFI_PRIVATE_COMMON_H__
-
-/**
- * @brief maximum number of STAs allowed to be connected
- *
- * @par Description
- *   min & max Beacon Interval
- */
-#define CSR_WIFI_AP_MAX_ASSOC_STA   8
-
-/** Number of only b rates */
-#define CSR_WIFI_SME_AP_MAX_ONLY_B_RATES        4
-
-
-/** Number of mandatory b rates */
-#define CSR_WIFI_SME_AP_MAX_MANDATORY_B_RATES   2
-
-
-/** Number of mandatory bg rates */
-#define CSR_WIFI_SME_AP_MAX_MANDATORY_BG_RATES  4
-
-
-/** Number of bg rates */
-#define CSR_WIFI_SME_AP_MAX_BG_RATES            12
-
-
-/** Number of no b only g rates */
-#define CSR_WIFI_SME_AP_MAX_NO_B_ONLY_G_RATES   8
-
-
-/** Number of mandatory g rates */
-#define CSR_WIFI_SME_AP_MAX_MANDATORY_G_RATES   7
-
-
-/* Number of g mandatory rates */
-#define CSR_WIFI_SME_AP_G_MANDATORY_RATES_NUM   7
-
-
-/* Number of b mandatory rates */
-#define CSR_WIFI_SME_AP_B_MANDATORY_RATES_NUM   2
-
-
-/* Number of b/g mandatory rates */
-#define CSR_WIFI_SME_AP_BG_MANDATORY_RATES_NUM   4
-
-
-/* The maximum allowed length of SSID */
-#define CSR_WIFI_SME_AP_SSID_MAX_LENGTH         32
-
-/* Refer 8.4.2.27 RSN element - we support TKIP, WPA2, WAPI and PSK only, no pmkid, group cipher suite */
-#define CSR_WIFI_SME_RSN_PACKED_SIZE (1 + 1 + 2 + 4 + 2 + 4 * 2 + 2 + 4 * 1 + 2 + 24)
-
-/* Refer 7.3.2.9 (ISO/IEC 8802-11:2006) WAPI element - we support WAPI PSK only, no bkid, group cipher suite */
-#define CSR_WIFI_SME_WAPI_PACKED_SIZE (1 + 1 + 2 + 2 + 4 * 1 + 2 + 4 * 1 + 4 + 2 + 24)
-
-
-/* Common structure for NME and SME to maintain Interface mode*/
-typedef u8 CsrWifiInterfaceMode;
-#define  CSR_WIFI_MODE_NONE                             ((CsrWifiInterfaceMode) 0xFF)
-#define  CSR_WIFI_MODE_STA                              ((CsrWifiInterfaceMode) 0x00)
-#define  CSR_WIFI_MODE_AP                               ((CsrWifiInterfaceMode) 0x01)
-#define  CSR_WIFI_MODE_P2P_DEVICE                       ((CsrWifiInterfaceMode) 0x02)
-#define  CSR_WIFI_MODE_P2P_CLI                          ((CsrWifiInterfaceMode) 0x03)
-#define  CSR_WIFI_MODE_P2P_GO                           ((CsrWifiInterfaceMode) 0x04)
-#define  CSR_WIFI_MODE_AMP                              ((CsrWifiInterfaceMode) 0x05)
-#define  CSR_WIFI_MODE_WPS_ENROLLEE                     ((CsrWifiInterfaceMode) 0x06)
-#define  CSR_WIFI_MODE_IBSS                             ((CsrWifiInterfaceMode) 0x07)
-
-#endif
-
diff --git a/drivers/staging/csr/csr_wifi_result.h b/drivers/staging/csr/csr_wifi_result.h
deleted file mode 100644 (file)
index 3c394c7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_RESULT_H__
-#define CSR_WIFI_RESULT_H__
-
-#include "csr_result.h"
-
-/* THIS FILE SHOULD CONTAIN ONLY RESULT CODES */
-
-/* Result Codes */
-#define CSR_WIFI_HIP_RESULT_INVALID_VALUE    ((CsrResult) 1) /* Invalid argument value */
-#define CSR_WIFI_HIP_RESULT_NO_DEVICE        ((CsrResult) 2) /* The specified device is no longer present */
-#define CSR_WIFI_HIP_RESULT_NO_SPACE         ((CsrResult) 3) /* A queue or buffer is full */
-#define CSR_WIFI_HIP_RESULT_NO_MEMORY        ((CsrResult) 4) /* Fatal error, no memory */
-#define CSR_WIFI_HIP_RESULT_RANGE            ((CsrResult) 5) /* Request exceeds the range of a file or a buffer */
-#define CSR_WIFI_HIP_RESULT_NOT_FOUND        ((CsrResult) 6) /* A file (typically a f/w patch) is not found */
-
-#endif /* CSR_WIFI_RESULT_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_router_converter_init.c b/drivers/staging/csr/csr_wifi_router_converter_init.c
deleted file mode 100644 (file)
index 775c013..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#include "csr_msgconv.h"
-#include "csr_macro.h"
-
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-#endif
-
-#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE
-#include "csr_wifi_router_serialize.h"
-#include "csr_wifi_router_prim.h"
-
-static CsrMsgConvMsgEntry csrwifirouter_conv_lut[] = {
-    { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, CsrWifiRouterMaPacketSubscribeReqSizeof, CsrWifiRouterMaPacketSubscribeReqSer, CsrWifiRouterMaPacketSubscribeReqDes, CsrWifiRouterMaPacketSubscribeReqSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, CsrWifiRouterMaPacketUnsubscribeReqSizeof, CsrWifiRouterMaPacketUnsubscribeReqSer, CsrWifiRouterMaPacketUnsubscribeReqDes, CsrWifiRouterMaPacketUnsubscribeReqSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_REQ, CsrWifiRouterMaPacketReqSizeof, CsrWifiRouterMaPacketReqSer, CsrWifiRouterMaPacketReqDes, CsrWifiRouterMaPacketReqSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_RES, CsrWifiRouterMaPacketResSizeof, CsrWifiRouterMaPacketResSer, CsrWifiRouterMaPacketResDes, CsrWifiRouterMaPacketResSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, CsrWifiRouterMaPacketCancelReqSizeof, CsrWifiRouterMaPacketCancelReqSer, CsrWifiRouterMaPacketCancelReqDes, CsrWifiRouterMaPacketCancelReqSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, CsrWifiRouterMaPacketSubscribeCfmSizeof, CsrWifiRouterMaPacketSubscribeCfmSer, CsrWifiRouterMaPacketSubscribeCfmDes, CsrWifiRouterMaPacketSubscribeCfmSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, CsrWifiRouterMaPacketUnsubscribeCfmSizeof, CsrWifiRouterMaPacketUnsubscribeCfmSer, CsrWifiRouterMaPacketUnsubscribeCfmDes, CsrWifiRouterMaPacketUnsubscribeCfmSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_CFM, CsrWifiRouterMaPacketCfmSizeof, CsrWifiRouterMaPacketCfmSer, CsrWifiRouterMaPacketCfmDes, CsrWifiRouterMaPacketCfmSerFree },
-    { CSR_WIFI_ROUTER_MA_PACKET_IND, CsrWifiRouterMaPacketIndSizeof, CsrWifiRouterMaPacketIndSer, CsrWifiRouterMaPacketIndDes, CsrWifiRouterMaPacketIndSerFree },
-
-    { 0, NULL, NULL, NULL, NULL },
-};
-
-CsrMsgConvMsgEntry* CsrWifiRouterConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
-{
-    if (msgType & CSR_PRIM_UPSTREAM)
-    {
-        u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT;
-        if (idx < (CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT) &&
-            csrwifirouter_conv_lut[idx].msgType == msgType)
-        {
-            return &csrwifirouter_conv_lut[idx];
-        }
-    }
-    else
-    {
-        if (msgType < CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT &&
-            csrwifirouter_conv_lut[msgType].msgType == msgType)
-        {
-            return &csrwifirouter_conv_lut[msgType];
-        }
-    }
-    return NULL;
-}
-
-
-void CsrWifiRouterConverterInit(void)
-{
-    CsrMsgConvInsert(CSR_WIFI_ROUTER_PRIM, csrwifirouter_conv_lut);
-    CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_PRIM, CsrWifiRouterConverterLookup);
-}
-
-
-#ifdef CSR_LOG_ENABLE
-static const CsrLogPrimitiveInformation csrwifirouter_conv_info = {
-    CSR_WIFI_ROUTER_PRIM,
-    (char *)"CSR_WIFI_ROUTER_PRIM",
-    csrwifirouter_conv_lut
-};
-const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void)
-{
-    return &csrwifirouter_conv_info;
-}
-
-
-#endif /* CSR_LOG_ENABLE */
-#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
diff --git a/drivers/staging/csr/csr_wifi_router_converter_init.h b/drivers/staging/csr/csr_wifi_router_converter_init.h
deleted file mode 100644 (file)
index 478327b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_CONVERTER_INIT_H__
-#define CSR_WIFI_ROUTER_CONVERTER_INIT_H__
-
-#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE
-
-#include "csr_msgconv.h"
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-
-extern const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void);
-#endif /* CSR_LOG_ENABLE */
-
-extern void CsrWifiRouterConverterInit(void);
-
-#else /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
-
-#define CsrWifiRouterConverterInit()
-
-#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
-
-#endif /* CSR_WIFI_ROUTER_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c
deleted file mode 100644 (file)
index a02e307..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#include "csr_msgconv.h"
-#include "csr_macro.h"
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-#endif
-
-#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE
-#include "csr_wifi_router_ctrl_serialize.h"
-#include "csr_wifi_router_ctrl_prim.h"
-
-static CsrMsgConvMsgEntry csrwifirouterctrl_conv_lut[] = {
-    { CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, CsrWifiRouterCtrlConfigurePowerModeReqSizeof, CsrWifiRouterCtrlConfigurePowerModeReqSer, CsrWifiRouterCtrlConfigurePowerModeReqDes, CsrWifiRouterCtrlConfigurePowerModeReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_HIP_REQ, CsrWifiRouterCtrlHipReqSizeof, CsrWifiRouterCtrlHipReqSer, CsrWifiRouterCtrlHipReqDes, CsrWifiRouterCtrlHipReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, CsrWifiRouterCtrlMediaStatusReqSizeof, CsrWifiRouterCtrlMediaStatusReqSer, CsrWifiRouterCtrlMediaStatusReqDes, CsrWifiRouterCtrlMediaStatusReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, CsrWifiRouterCtrlMulticastAddressResSizeof, CsrWifiRouterCtrlMulticastAddressResSer, CsrWifiRouterCtrlMulticastAddressResDes, CsrWifiRouterCtrlMulticastAddressResSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, CsrWifiRouterCtrlPortConfigureReqSizeof, CsrWifiRouterCtrlPortConfigureReqSer, CsrWifiRouterCtrlPortConfigureReqDes, CsrWifiRouterCtrlPortConfigureReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, CsrWifiRouterCtrlQosControlReqSizeof, CsrWifiRouterCtrlQosControlReqSer, CsrWifiRouterCtrlQosControlReqDes, CsrWifiRouterCtrlQosControlReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, CsrWifiRouterCtrlSuspendResSizeof, CsrWifiRouterCtrlSuspendResSer, CsrWifiRouterCtrlSuspendResDes, CsrWifiRouterCtrlSuspendResSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, CsrWifiRouterCtrlTclasAddReqSizeof, CsrWifiRouterCtrlTclasAddReqSer, CsrWifiRouterCtrlTclasAddReqDes, CsrWifiRouterCtrlTclasAddReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_RESUME_RES, CsrWifiRouterCtrlResumeResSizeof, CsrWifiRouterCtrlResumeResSer, CsrWifiRouterCtrlResumeResDes, CsrWifiRouterCtrlResumeResSerFree },
-    { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseReqSer, CsrWifiRouterCtrlRawSdioDeinitialiseReqDes, CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, CsrWifiRouterCtrlRawSdioInitialiseReqSizeof, CsrWifiRouterCtrlRawSdioInitialiseReqSer, CsrWifiRouterCtrlRawSdioInitialiseReqDes, CsrWifiRouterCtrlRawSdioInitialiseReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, CsrWifiRouterCtrlTclasDelReqSizeof, CsrWifiRouterCtrlTclasDelReqSer, CsrWifiRouterCtrlTclasDelReqDes, CsrWifiRouterCtrlTclasDelReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, CsrWifiRouterCtrlTrafficClassificationReqSizeof, CsrWifiRouterCtrlTrafficClassificationReqSer, CsrWifiRouterCtrlTrafficClassificationReqDes, CsrWifiRouterCtrlTrafficClassificationReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, CsrWifiRouterCtrlTrafficConfigReqSizeof, CsrWifiRouterCtrlTrafficConfigReqSer, CsrWifiRouterCtrlTrafficConfigReqDes, CsrWifiRouterCtrlTrafficConfigReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, CsrWifiRouterCtrlWifiOffReqSizeof, CsrWifiRouterCtrlWifiOffReqSer, CsrWifiRouterCtrlWifiOffReqDes, CsrWifiRouterCtrlWifiOffReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, CsrWifiRouterCtrlWifiOffResSizeof, CsrWifiRouterCtrlWifiOffResSer, CsrWifiRouterCtrlWifiOffResDes, CsrWifiRouterCtrlWifiOffResSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, CsrWifiRouterCtrlWifiOnReqSizeof, CsrWifiRouterCtrlWifiOnReqSer, CsrWifiRouterCtrlWifiOnReqDes, CsrWifiRouterCtrlWifiOnReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, CsrWifiRouterCtrlWifiOnResSizeof, CsrWifiRouterCtrlWifiOnResSer, CsrWifiRouterCtrlWifiOnResDes, CsrWifiRouterCtrlWifiOnResSerFree },
-    { CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, CsrWifiRouterCtrlM4TransmitReqSizeof, CsrWifiRouterCtrlM4TransmitReqSer, CsrWifiRouterCtrlM4TransmitReqDes, CsrWifiRouterCtrlM4TransmitReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, CsrWifiRouterCtrlModeSetReqSizeof, CsrWifiRouterCtrlModeSetReqSer, CsrWifiRouterCtrlModeSetReqDes, CsrWifiRouterCtrlModeSetReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, CsrWifiRouterCtrlPeerAddReqSizeof, CsrWifiRouterCtrlPeerAddReqSer, CsrWifiRouterCtrlPeerAddReqDes, CsrWifiRouterCtrlPeerAddReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, CsrWifiRouterCtrlPeerDelReqSizeof, CsrWifiRouterCtrlPeerDelReqSer, CsrWifiRouterCtrlPeerDelReqDes, CsrWifiRouterCtrlPeerDelReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, CsrWifiRouterCtrlPeerUpdateReqSizeof, CsrWifiRouterCtrlPeerUpdateReqSer, CsrWifiRouterCtrlPeerUpdateReqDes, CsrWifiRouterCtrlPeerUpdateReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, CsrWifiRouterCtrlCapabilitiesReqSizeof, CsrWifiRouterCtrlCapabilitiesReqSer, CsrWifiRouterCtrlCapabilitiesReqDes, CsrWifiRouterCtrlCapabilitiesReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, CsrWifiRouterCtrlBlockAckEnableReqSizeof, CsrWifiRouterCtrlBlockAckEnableReqSer, CsrWifiRouterCtrlBlockAckEnableReqDes, CsrWifiRouterCtrlBlockAckEnableReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, CsrWifiRouterCtrlBlockAckDisableReqSizeof, CsrWifiRouterCtrlBlockAckDisableReqSer, CsrWifiRouterCtrlBlockAckDisableReqDes, CsrWifiRouterCtrlBlockAckDisableReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, CsrWifiRouterCtrlWapiRxPktReqSizeof, CsrWifiRouterCtrlWapiRxPktReqSer, CsrWifiRouterCtrlWapiRxPktReqDes, CsrWifiRouterCtrlWapiRxPktReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, CsrWifiRouterCtrlWapiMulticastFilterReqSizeof, CsrWifiRouterCtrlWapiMulticastFilterReqSer, CsrWifiRouterCtrlWapiMulticastFilterReqDes, CsrWifiRouterCtrlWapiMulticastFilterReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, CsrWifiRouterCtrlWapiUnicastFilterReqSizeof, CsrWifiRouterCtrlWapiUnicastFilterReqSer, CsrWifiRouterCtrlWapiUnicastFilterReqDes, CsrWifiRouterCtrlWapiUnicastFilterReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof, CsrWifiRouterCtrlWapiUnicastTxPktReqSer, CsrWifiRouterCtrlWapiUnicastTxPktReqDes, CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, CsrWifiRouterCtrlWapiFilterReqSizeof, CsrWifiRouterCtrlWapiFilterReqSer, CsrWifiRouterCtrlWapiFilterReqDes, CsrWifiRouterCtrlWapiFilterReqSerFree },
-    { CSR_WIFI_ROUTER_CTRL_HIP_IND, CsrWifiRouterCtrlHipIndSizeof, CsrWifiRouterCtrlHipIndSer, CsrWifiRouterCtrlHipIndDes, CsrWifiRouterCtrlHipIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, CsrWifiRouterCtrlMulticastAddressIndSizeof, CsrWifiRouterCtrlMulticastAddressIndSer, CsrWifiRouterCtrlMulticastAddressIndDes, CsrWifiRouterCtrlMulticastAddressIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, CsrWifiRouterCtrlPortConfigureCfmSizeof, CsrWifiRouterCtrlPortConfigureCfmSer, CsrWifiRouterCtrlPortConfigureCfmDes, CsrWifiRouterCtrlPortConfigureCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_RESUME_IND, CsrWifiRouterCtrlResumeIndSizeof, CsrWifiRouterCtrlResumeIndSer, CsrWifiRouterCtrlResumeIndDes, CsrWifiRouterCtrlResumeIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, CsrWifiRouterCtrlSuspendIndSizeof, CsrWifiRouterCtrlSuspendIndSer, CsrWifiRouterCtrlSuspendIndDes, CsrWifiRouterCtrlSuspendIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, CsrWifiRouterCtrlTclasAddCfmSizeof, CsrWifiRouterCtrlTclasAddCfmSer, CsrWifiRouterCtrlTclasAddCfmDes, CsrWifiRouterCtrlTclasAddCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer, CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioInitialiseCfmSer, CsrWifiRouterCtrlRawSdioInitialiseCfmDes, CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, CsrWifiRouterCtrlTclasDelCfmSizeof, CsrWifiRouterCtrlTclasDelCfmSer, CsrWifiRouterCtrlTclasDelCfmDes, CsrWifiRouterCtrlTclasDelCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, CsrWifiRouterCtrlTrafficProtocolIndSizeof, CsrWifiRouterCtrlTrafficProtocolIndSer, CsrWifiRouterCtrlTrafficProtocolIndDes, CsrWifiRouterCtrlTrafficProtocolIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, CsrWifiRouterCtrlTrafficSampleIndSizeof, CsrWifiRouterCtrlTrafficSampleIndSer, CsrWifiRouterCtrlTrafficSampleIndDes, CsrWifiRouterCtrlTrafficSampleIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, CsrWifiRouterCtrlWifiOffIndSizeof, CsrWifiRouterCtrlWifiOffIndSer, CsrWifiRouterCtrlWifiOffIndDes, CsrWifiRouterCtrlWifiOffIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, CsrWifiRouterCtrlWifiOffCfmSizeof, CsrWifiRouterCtrlWifiOffCfmSer, CsrWifiRouterCtrlWifiOffCfmDes, CsrWifiRouterCtrlWifiOffCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, CsrWifiRouterCtrlWifiOnIndSizeof, CsrWifiRouterCtrlWifiOnIndSer, CsrWifiRouterCtrlWifiOnIndDes, CsrWifiRouterCtrlWifiOnIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, CsrWifiRouterCtrlWifiOnCfmSizeof, CsrWifiRouterCtrlWifiOnCfmSer, CsrWifiRouterCtrlWifiOnCfmDes, CsrWifiRouterCtrlWifiOnCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, CsrWifiRouterCtrlM4ReadyToSendIndSizeof, CsrWifiRouterCtrlM4ReadyToSendIndSer, CsrWifiRouterCtrlM4ReadyToSendIndDes, CsrWifiRouterCtrlM4ReadyToSendIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, CsrWifiRouterCtrlM4TransmittedIndSizeof, CsrWifiRouterCtrlM4TransmittedIndSer, CsrWifiRouterCtrlM4TransmittedIndDes, CsrWifiRouterCtrlM4TransmittedIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, CsrWifiRouterCtrlMicFailureIndSizeof, CsrWifiRouterCtrlMicFailureIndSer, CsrWifiRouterCtrlMicFailureIndDes, CsrWifiRouterCtrlMicFailureIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, CsrWifiRouterCtrlConnectedIndSizeof, CsrWifiRouterCtrlConnectedIndSer, CsrWifiRouterCtrlConnectedIndDes, CsrWifiRouterCtrlConnectedIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, CsrWifiRouterCtrlPeerAddCfmSizeof, CsrWifiRouterCtrlPeerAddCfmSer, CsrWifiRouterCtrlPeerAddCfmDes, CsrWifiRouterCtrlPeerAddCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, CsrWifiRouterCtrlPeerDelCfmSizeof, CsrWifiRouterCtrlPeerDelCfmSer, CsrWifiRouterCtrlPeerDelCfmDes, CsrWifiRouterCtrlPeerDelCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, CsrWifiRouterCtrlUnexpectedFrameIndSizeof, CsrWifiRouterCtrlUnexpectedFrameIndSer, CsrWifiRouterCtrlUnexpectedFrameIndDes, CsrWifiRouterCtrlUnexpectedFrameIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, CsrWifiRouterCtrlPeerUpdateCfmSizeof, CsrWifiRouterCtrlPeerUpdateCfmSer, CsrWifiRouterCtrlPeerUpdateCfmDes, CsrWifiRouterCtrlPeerUpdateCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, CsrWifiRouterCtrlCapabilitiesCfmSizeof, CsrWifiRouterCtrlCapabilitiesCfmSer, CsrWifiRouterCtrlCapabilitiesCfmDes, CsrWifiRouterCtrlCapabilitiesCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, CsrWifiRouterCtrlBlockAckEnableCfmSizeof, CsrWifiRouterCtrlBlockAckEnableCfmSer, CsrWifiRouterCtrlBlockAckEnableCfmDes, CsrWifiRouterCtrlBlockAckEnableCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, CsrWifiRouterCtrlBlockAckDisableCfmSizeof, CsrWifiRouterCtrlBlockAckDisableCfmSer, CsrWifiRouterCtrlBlockAckDisableCfmDes, CsrWifiRouterCtrlBlockAckDisableCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, CsrWifiRouterCtrlBlockAckErrorIndSizeof, CsrWifiRouterCtrlBlockAckErrorIndSer, CsrWifiRouterCtrlBlockAckErrorIndDes, CsrWifiRouterCtrlBlockAckErrorIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, CsrWifiRouterCtrlStaInactiveIndSizeof, CsrWifiRouterCtrlStaInactiveIndSer, CsrWifiRouterCtrlStaInactiveIndDes, CsrWifiRouterCtrlStaInactiveIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, CsrWifiRouterCtrlWapiRxMicCheckIndSizeof, CsrWifiRouterCtrlWapiRxMicCheckIndSer, CsrWifiRouterCtrlWapiRxMicCheckIndDes, CsrWifiRouterCtrlWapiRxMicCheckIndSerFree },
-    { CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, CsrWifiRouterCtrlModeSetCfmSizeof, CsrWifiRouterCtrlModeSetCfmSer, CsrWifiRouterCtrlModeSetCfmDes, CsrWifiRouterCtrlModeSetCfmSerFree },
-    { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer, CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree },
-
-    { 0, NULL, NULL, NULL, NULL },
-};
-
-CsrMsgConvMsgEntry* CsrWifiRouterCtrlConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
-{
-    if (msgType & CSR_PRIM_UPSTREAM)
-    {
-        u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT;
-        if (idx < (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT) &&
-            csrwifirouterctrl_conv_lut[idx].msgType == msgType)
-        {
-            return &csrwifirouterctrl_conv_lut[idx];
-        }
-    }
-    else
-    {
-        if (msgType < CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT &&
-            csrwifirouterctrl_conv_lut[msgType].msgType == msgType)
-        {
-            return &csrwifirouterctrl_conv_lut[msgType];
-        }
-    }
-    return NULL;
-}
-
-
-void CsrWifiRouterCtrlConverterInit(void)
-{
-    CsrMsgConvInsert(CSR_WIFI_ROUTER_CTRL_PRIM, csrwifirouterctrl_conv_lut);
-    CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_CTRL_PRIM, CsrWifiRouterCtrlConverterLookup);
-}
-
-
-#ifdef CSR_LOG_ENABLE
-static const CsrLogPrimitiveInformation csrwifirouterctrl_conv_info = {
-    CSR_WIFI_ROUTER_CTRL_PRIM,
-    (char *)"CSR_WIFI_ROUTER_CTRL_PRIM",
-    csrwifirouterctrl_conv_lut
-};
-const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void)
-{
-    return &csrwifirouterctrl_conv_info;
-}
-
-
-#endif /* CSR_LOG_ENABLE */
-#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h
deleted file mode 100644 (file)
index c984589..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__
-#define CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__
-
-#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE
-
-#include "csr_msgconv.h"
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-
-extern const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void);
-#endif /* CSR_LOG_ENABLE */
-
-extern void CsrWifiRouterCtrlConverterInit(void);
-
-#else /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
-
-#define CsrWifiRouterCtrlConverterInit()
-
-#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
-
-#endif /* CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c
deleted file mode 100644 (file)
index 7fa85fb..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_router_ctrl_prim.h"
-#include "csr_wifi_router_ctrl_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiRouterCtrlFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-
-    switch (*((CsrWifiRouterCtrlPrim *) message))
-    {
-        case CSR_WIFI_ROUTER_CTRL_HIP_REQ:
-        {
-            CsrWifiRouterCtrlHipReq *p = (CsrWifiRouterCtrlHipReq *)message;
-            kfree(p->mlmeCommand);
-            p->mlmeCommand = NULL;
-            kfree(p->dataRef1);
-            p->dataRef1 = NULL;
-            kfree(p->dataRef2);
-            p->dataRef2 = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES:
-        {
-            CsrWifiRouterCtrlMulticastAddressRes *p = (CsrWifiRouterCtrlMulticastAddressRes *)message;
-            kfree(p->getAddresses);
-            p->getAddresses = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ:
-        {
-            CsrWifiRouterCtrlTclasAddReq *p = (CsrWifiRouterCtrlTclasAddReq *)message;
-            kfree(p->tclas);
-            p->tclas = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ:
-        {
-            CsrWifiRouterCtrlTclasDelReq *p = (CsrWifiRouterCtrlTclasDelReq *)message;
-            kfree(p->tclas);
-            p->tclas = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ:
-        {
-            CsrWifiRouterCtrlWifiOnReq *p = (CsrWifiRouterCtrlWifiOnReq *)message;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES:
-        {
-            CsrWifiRouterCtrlWifiOnRes *p = (CsrWifiRouterCtrlWifiOnRes *)message;
-            kfree(p->smeVersions.smeBuild);
-            p->smeVersions.smeBuild = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ:
-        {
-            CsrWifiRouterCtrlWapiRxPktReq *p = (CsrWifiRouterCtrlWapiRxPktReq *)message;
-            kfree(p->signal);
-            p->signal = NULL;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ:
-        {
-            CsrWifiRouterCtrlWapiUnicastTxPktReq *p = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)message;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c
deleted file mode 100644 (file)
index 954b3de..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_router_ctrl_prim.h"
-#include "csr_wifi_router_ctrl_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiRouterCtrlFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-
-    switch (*((CsrWifiRouterCtrlPrim *) message))
-    {
-        case CSR_WIFI_ROUTER_CTRL_HIP_IND:
-        {
-            CsrWifiRouterCtrlHipInd *p = (CsrWifiRouterCtrlHipInd *)message;
-            kfree(p->mlmeCommand);
-            p->mlmeCommand = NULL;
-            kfree(p->dataRef1);
-            p->dataRef1 = NULL;
-            kfree(p->dataRef2);
-            p->dataRef2 = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND:
-        {
-            CsrWifiRouterCtrlMulticastAddressInd *p = (CsrWifiRouterCtrlMulticastAddressInd *)message;
-            kfree(p->setAddresses);
-            p->setAddresses = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND:
-        {
-            CsrWifiRouterCtrlWifiOnInd *p = (CsrWifiRouterCtrlWifiOnInd *)message;
-            kfree(p->versions.routerBuild);
-            p->versions.routerBuild = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND:
-        {
-            CsrWifiRouterCtrlWapiRxMicCheckInd *p = (CsrWifiRouterCtrlWapiRxMicCheckInd *)message;
-            kfree(p->signal);
-            p->signal = NULL;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-        case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND:
-        {
-            CsrWifiRouterCtrlWapiUnicastTxEncryptInd *p = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)message;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_lib.h b/drivers/staging/csr/csr_wifi_router_ctrl_lib.h
deleted file mode 100644 (file)
index f235153..0000000
+++ /dev/null
@@ -1,2082 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_CTRL_LIB_H__
-#define CSR_WIFI_ROUTER_CTRL_LIB_H__
-
-#include "csr_sched.h"
-#include "csr_macro.h"
-#include "csr_msg_transport.h"
-
-#include "csr_wifi_lib.h"
-
-#include "csr_wifi_router_ctrl_prim.h"
-#include "csr_wifi_router_task.h"
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiRouterCtrlFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_ROUTER_CTRL upstream message. Does not
- *      free the message itself, and can only be used for upstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_ROUTER_CTRL upstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiRouterCtrlFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_ROUTER_CTRL downstream message. Does not
- *      free the message itself, and can only be used for downstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_ROUTER_CTRL downstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- * Enum to string functions
- *----------------------------------------------------------------------------*/
-const char* CsrWifiRouterCtrlBlockAckRoleToString(CsrWifiRouterCtrlBlockAckRole value);
-const char* CsrWifiRouterCtrlControlIndicationToString(CsrWifiRouterCtrlControlIndication value);
-const char* CsrWifiRouterCtrlListActionToString(CsrWifiRouterCtrlListAction value);
-const char* CsrWifiRouterCtrlLowPowerModeToString(CsrWifiRouterCtrlLowPowerMode value);
-const char* CsrWifiRouterCtrlMediaStatusToString(CsrWifiRouterCtrlMediaStatus value);
-const char* CsrWifiRouterCtrlModeToString(CsrWifiRouterCtrlMode value);
-const char* CsrWifiRouterCtrlPeerStatusToString(CsrWifiRouterCtrlPeerStatus value);
-const char* CsrWifiRouterCtrlPortActionToString(CsrWifiRouterCtrlPortAction value);
-const char* CsrWifiRouterCtrlPowersaveTypeToString(CsrWifiRouterCtrlPowersaveType value);
-const char* CsrWifiRouterCtrlProtocolDirectionToString(CsrWifiRouterCtrlProtocolDirection value);
-const char* CsrWifiRouterCtrlQoSControlToString(CsrWifiRouterCtrlQoSControl value);
-const char* CsrWifiRouterCtrlQueueConfigToString(CsrWifiRouterCtrlQueueConfig value);
-const char* CsrWifiRouterCtrlTrafficConfigTypeToString(CsrWifiRouterCtrlTrafficConfigType value);
-const char* CsrWifiRouterCtrlTrafficPacketTypeToString(CsrWifiRouterCtrlTrafficPacketType value);
-const char* CsrWifiRouterCtrlTrafficTypeToString(CsrWifiRouterCtrlTrafficType value);
-
-
-/*----------------------------------------------------------------------------*
- * CsrPrim Type toString function.
- * Converts a message type to the String name of the Message
- *----------------------------------------------------------------------------*/
-const char* CsrWifiRouterCtrlPrimTypeToString(CsrPrim msgType);
-
-/*----------------------------------------------------------------------------*
- * Lookup arrays for PrimType name Strings
- *----------------------------------------------------------------------------*/
-extern const char *CsrWifiRouterCtrlUpstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT];
-extern const char *CsrWifiRouterCtrlDownstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT];
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckDisableReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag    -
-    clientData      -
-    macAddress      -
-    trafficStreamID -
-    role            -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->macAddress = (macAddress__); \
-    msg__->trafficStreamID = (trafficStreamID__); \
-    msg__->role = (role__);
-
-#define CsrWifiRouterCtrlBlockAckDisableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
-    { \
-        CsrWifiRouterCtrlBlockAckDisableReq *msg__; \
-        CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlBlockAckDisableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
-    CsrWifiRouterCtrlBlockAckDisableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckDisableCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlBlockAckDisableCfm *msg__; \
-        CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlBlockAckDisableCfmSend(dst__, clientData__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckEnableReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag    -
-    clientData      -
-    macAddress      -
-    trafficStreamID -
-    role            -
-    bufferSize      -
-    timeout         -
-    ssn             -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->macAddress = (macAddress__); \
-    msg__->trafficStreamID = (trafficStreamID__); \
-    msg__->role = (role__); \
-    msg__->bufferSize = (bufferSize__); \
-    msg__->timeout = (timeout__); \
-    msg__->ssn = (ssn__);
-
-#define CsrWifiRouterCtrlBlockAckEnableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
-    { \
-        CsrWifiRouterCtrlBlockAckEnableReq *msg__; \
-        CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlBlockAckEnableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
-    CsrWifiRouterCtrlBlockAckEnableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckEnableCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlBlockAckEnableCfm *msg__; \
-        CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlBlockAckEnableCfmSend(dst__, clientData__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckErrorIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue           - Destination Task Queue
-    clientData      -
-    interfaceTag    -
-    trafficStreamID -
-    peerMacAddress  -
-    status          -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->trafficStreamID = (trafficStreamID__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
-    { \
-        CsrWifiRouterCtrlBlockAckErrorInd *msg__; \
-        CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlBlockAckErrorIndSend(dst__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
-    CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlCapabilitiesReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    clientData -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, dst__, src__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlCapabilitiesReqSendTo(dst__, src__, clientData__) \
-    { \
-        CsrWifiRouterCtrlCapabilitiesReq *msg__; \
-        CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlCapabilitiesReqSend(src__, clientData__) \
-    CsrWifiRouterCtrlCapabilitiesReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlCapabilitiesCfmSend
-
-  DESCRIPTION
-    The router sends this primitive to confirm the size of the queues of the
-    HIP.
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    clientData       -
-    commandQueueSize - Size of command queue
-    trafficQueueSize - Size of traffic queue (per AC)
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->commandQueueSize = (commandQueueSize__); \
-    msg__->trafficQueueSize = (trafficQueueSize__);
-
-#define CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \
-    { \
-        CsrWifiRouterCtrlCapabilitiesCfm *msg__; \
-        CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlCapabilitiesCfmSend(dst__, clientData__, commandQueueSize__, trafficQueueSize__) \
-    CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, commandQueueSize__, trafficQueueSize__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlConfigurePowerModeReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    clientData -
-    mode       -
-    wakeHost   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->mode = (mode__); \
-    msg__->wakeHost = (wakeHost__);
-
-#define CsrWifiRouterCtrlConfigurePowerModeReqSendTo(dst__, src__, clientData__, mode__, wakeHost__) \
-    { \
-        CsrWifiRouterCtrlConfigurePowerModeReq *msg__; \
-        CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlConfigurePowerModeReqSend(src__, clientData__, mode__, wakeHost__) \
-    CsrWifiRouterCtrlConfigurePowerModeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, mode__, wakeHost__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlConnectedIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-    peerStatus     -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->peerStatus = (peerStatus__);
-
-#define CsrWifiRouterCtrlConnectedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
-    { \
-        CsrWifiRouterCtrlConnectedInd *msg__; \
-        CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlConnectedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
-    CsrWifiRouterCtrlConnectedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerStatus__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlHipReqSend
-
-  DESCRIPTION
-    This primitive is used for transferring MLME messages to the HIP.
-
-  PARAMETERS
-    queue             - Message Source Task Queue (Cfm's will be sent to this Queue)
-    mlmeCommandLength - Length of the MLME signal
-    mlmeCommand       - Pointer to the MLME signal
-    dataRef1Length    - Length of the dataRef1 bulk data
-    dataRef1          - Pointer to the bulk data 1
-    dataRef2Length    - Length of the dataRef2 bulk data
-    dataRef2          - Pointer to the bulk data 2
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_REQ, dst__, src__); \
-    msg__->mlmeCommandLength = (mlmeCommandLength__); \
-    msg__->mlmeCommand = (mlmeCommand__); \
-    msg__->dataRef1Length = (dataRef1Length__); \
-    msg__->dataRef1 = (dataRef1__); \
-    msg__->dataRef2Length = (dataRef2Length__); \
-    msg__->dataRef2 = (dataRef2__);
-
-#define CsrWifiRouterCtrlHipReqSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
-    { \
-        CsrWifiRouterCtrlHipReq *msg__; \
-        CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlHipReqSend(src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
-    CsrWifiRouterCtrlHipReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlHipIndSend
-
-  DESCRIPTION
-    This primitive is used for transferring MLME messages from the HIP.
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    mlmeCommandLength - Length of the MLME signal
-    mlmeCommand       - Pointer to the MLME signal
-    dataRef1Length    - Length of the dataRef1 bulk data
-    dataRef1          - Pointer to the bulk data 1
-    dataRef2Length    - Length of the dataRef2 bulk data
-    dataRef2          - Pointer to the bulk data 2
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_IND, dst__, src__); \
-    msg__->mlmeCommandLength = (mlmeCommandLength__); \
-    msg__->mlmeCommand = (mlmeCommand__); \
-    msg__->dataRef1Length = (dataRef1Length__); \
-    msg__->dataRef1 = (dataRef1__); \
-    msg__->dataRef2Length = (dataRef2Length__); \
-    msg__->dataRef2 = (dataRef2__);
-
-#define CsrWifiRouterCtrlHipIndSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
-    { \
-        CsrWifiRouterCtrlHipInd *msg__; \
-        CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlHipIndSend(dst__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
-    CsrWifiRouterCtrlHipIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlM4ReadyToSendIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__);
-
-#define CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
-    { \
-        CsrWifiRouterCtrlM4ReadyToSendInd *msg__; \
-        CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlM4ReadyToSendIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \
-    CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlM4TransmitReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    clientData   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlM4TransmitReqSendTo(dst__, src__, interfaceTag__, clientData__) \
-    { \
-        CsrWifiRouterCtrlM4TransmitReq *msg__; \
-        CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlM4TransmitReqSend(src__, interfaceTag__, clientData__) \
-    CsrWifiRouterCtrlM4TransmitReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlM4TransmittedIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-    status         -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \
-    { \
-        CsrWifiRouterCtrlM4TransmittedInd *msg__; \
-        CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlM4TransmittedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, status__) \
-    CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMediaStatusReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    clientData   -
-    mediaStatus  -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->mediaStatus = (mediaStatus__);
-
-#define CsrWifiRouterCtrlMediaStatusReqSendTo(dst__, src__, interfaceTag__, clientData__, mediaStatus__) \
-    { \
-        CsrWifiRouterCtrlMediaStatusReq *msg__; \
-        CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlMediaStatusReqSend(src__, interfaceTag__, clientData__, mediaStatus__) \
-    CsrWifiRouterCtrlMediaStatusReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mediaStatus__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMicFailureIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-    unicastPdu     -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->unicastPdu = (unicastPdu__);
-
-#define CsrWifiRouterCtrlMicFailureIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
-    { \
-        CsrWifiRouterCtrlMicFailureInd *msg__; \
-        CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlMicFailureIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
-    CsrWifiRouterCtrlMicFailureIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlModeSetReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue               - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag        -
-    clientData          -
-    mode                -
-    bssid               - BSSID of the network the device is going to be a part
-                          of
-    protection          - Set to TRUE if encryption is enabled for the
-                          connection/broadcast frames
-    intraBssDistEnabled - If set to TRUE, intra BSS destribution will be
-                          enabled. If set to FALSE, any unicast PDU which does
-                          not have the RA as the the local MAC address, shall be
-                          ignored. This field is interpreted by the receive if
-                          mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->mode = (mode__); \
-    msg__->bssid = (bssid__); \
-    msg__->protection = (protection__); \
-    msg__->intraBssDistEnabled = (intraBssDistEnabled__);
-
-#define CsrWifiRouterCtrlModeSetReqSendTo(dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
-    { \
-        CsrWifiRouterCtrlModeSetReq *msg__; \
-        CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlModeSetReqSend(src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
-    CsrWifiRouterCtrlModeSetReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlModeSetCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    mode         -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->mode = (mode__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlModeSetCfmSendTo(dst__, src__, clientData__, interfaceTag__, mode__, status__) \
-    { \
-        CsrWifiRouterCtrlModeSetCfm *msg__; \
-        CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlModeSetCfmSend(dst__, clientData__, interfaceTag__, mode__, status__) \
-    CsrWifiRouterCtrlModeSetCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, mode__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMulticastAddressIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    clientData        -
-    interfaceTag      -
-    action            -
-    setAddressesCount -
-    setAddresses      -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->action = (action__); \
-    msg__->setAddressesCount = (setAddressesCount__); \
-    msg__->setAddresses = (setAddresses__);
-
-#define CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
-    { \
-        CsrWifiRouterCtrlMulticastAddressInd *msg__; \
-        CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlMulticastAddressIndSend(dst__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
-    CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMulticastAddressResSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    interfaceTag      -
-    clientData        -
-    status            -
-    action            -
-    getAddressesCount -
-    getAddresses      -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->status = (status__); \
-    msg__->action = (action__); \
-    msg__->getAddressesCount = (getAddressesCount__); \
-    msg__->getAddresses = (getAddresses__);
-
-#define CsrWifiRouterCtrlMulticastAddressResSendTo(dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
-    { \
-        CsrWifiRouterCtrlMulticastAddressRes *msg__; \
-        CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlMulticastAddressResSend(src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
-    CsrWifiRouterCtrlMulticastAddressResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerAddReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue          - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag   -
-    clientData     -
-    peerMacAddress -
-    associationId  -
-    staInfo        -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->associationId = (associationId__); \
-    msg__->staInfo = (staInfo__);
-
-#define CsrWifiRouterCtrlPeerAddReqSendTo(dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
-    { \
-        CsrWifiRouterCtrlPeerAddReq *msg__; \
-        CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPeerAddReqSend(src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
-    CsrWifiRouterCtrlPeerAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerAddCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    clientData       -
-    interfaceTag     -
-    peerMacAddress   -
-    peerRecordHandle -
-    status           -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->peerRecordHandle = (peerRecordHandle__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
-    { \
-        CsrWifiRouterCtrlPeerAddCfm *msg__; \
-        CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPeerAddCfmSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
-    CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerDelReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue            - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag     -
-    clientData       -
-    peerRecordHandle -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->peerRecordHandle = (peerRecordHandle__);
-
-#define CsrWifiRouterCtrlPeerDelReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \
-    { \
-        CsrWifiRouterCtrlPeerDelReq *msg__; \
-        CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPeerDelReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__) \
-    CsrWifiRouterCtrlPeerDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerDelCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlPeerDelCfm *msg__; \
-        CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPeerDelCfmSend(dst__, clientData__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerUpdateReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue            - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag     -
-    clientData       -
-    peerRecordHandle -
-    powersaveMode    -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->peerRecordHandle = (peerRecordHandle__); \
-    msg__->powersaveMode = (powersaveMode__);
-
-#define CsrWifiRouterCtrlPeerUpdateReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
-    { \
-        CsrWifiRouterCtrlPeerUpdateReq *msg__; \
-        CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPeerUpdateReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
-    CsrWifiRouterCtrlPeerUpdateReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerUpdateCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlPeerUpdateCfm *msg__; \
-        CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPeerUpdateCfmSend(dst__, clientData__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPortConfigureReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue                  - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag           -
-    clientData             -
-    uncontrolledPortAction -
-    controlledPortAction   -
-    macAddress             -
-    setProtection          -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->uncontrolledPortAction = (uncontrolledPortAction__); \
-    msg__->controlledPortAction = (controlledPortAction__); \
-    msg__->macAddress = (macAddress__); \
-    msg__->setProtection = (setProtection__);
-
-#define CsrWifiRouterCtrlPortConfigureReqSendTo(dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
-    { \
-        CsrWifiRouterCtrlPortConfigureReq *msg__; \
-        CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPortConfigureReqSend(src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
-    CsrWifiRouterCtrlPortConfigureReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPortConfigureCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-    macAddress   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->macAddress = (macAddress__);
-
-#define CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \
-    { \
-        CsrWifiRouterCtrlPortConfigureCfm *msg__; \
-        CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlPortConfigureCfmSend(dst__, clientData__, interfaceTag__, status__, macAddress__) \
-    CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__, macAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlQosControlReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    clientData   -
-    control      -
-    queueConfig  -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->control = (control__); \
-    msg__->queueConfig = (queueConfig__);
-
-#define CsrWifiRouterCtrlQosControlReqSendTo(dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \
-    { \
-        CsrWifiRouterCtrlQosControlReq *msg__; \
-        CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlQosControlReqSend(src__, interfaceTag__, clientData__, control__, queueConfig__) \
-    CsrWifiRouterCtrlQosControlReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, control__, queueConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioDeinitialiseReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    clientData -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, dst__, src__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(dst__, src__, clientData__) \
-    { \
-        CsrWifiRouterCtrlRawSdioDeinitialiseReq *msg__; \
-        CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSend(src__, clientData__) \
-    CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    clientData -
-    result     -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->result = (result__);
-
-#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, src__, clientData__, result__) \
-    { \
-        CsrWifiRouterCtrlRawSdioDeinitialiseCfm *msg__; \
-        CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend(dst__, clientData__, result__) \
-    CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioInitialiseReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    clientData -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, dst__, src__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(dst__, src__, clientData__) \
-    { \
-        CsrWifiRouterCtrlRawSdioInitialiseReq *msg__; \
-        CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlRawSdioInitialiseReqSend(src__, clientData__) \
-    CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioInitialiseCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    clientData       -
-    result           -
-    byteRead         -
-    byteWrite        -
-    firmwareDownload -
-    reset            -
-    coreDumpPrepare  -
-    byteBlockRead    -
-    gpRead16         -
-    gpWrite16        -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->result = (result__); \
-    msg__->byteRead = (byteRead__); \
-    msg__->byteWrite = (byteWrite__); \
-    msg__->firmwareDownload = (firmwareDownload__); \
-    msg__->reset = (reset__); \
-    msg__->coreDumpPrepare = (coreDumpPrepare__); \
-    msg__->byteBlockRead = (byteBlockRead__); \
-    msg__->gpRead16 = (gpRead16__); \
-    msg__->gpWrite16 = (gpWrite16__);
-
-#define CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
-    { \
-        CsrWifiRouterCtrlRawSdioInitialiseCfm *msg__; \
-        CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlRawSdioInitialiseCfmSend(dst__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
-    CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlResumeIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue           - Destination Task Queue
-    clientData      -
-    powerMaintained -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->powerMaintained = (powerMaintained__);
-
-#define CsrWifiRouterCtrlResumeIndSendTo(dst__, src__, clientData__, powerMaintained__) \
-    { \
-        CsrWifiRouterCtrlResumeInd *msg__; \
-        CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlResumeIndSend(dst__, clientData__, powerMaintained__) \
-    CsrWifiRouterCtrlResumeIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, powerMaintained__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlResumeResSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    clientData -
-    status     -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_RES, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlResumeResSendTo(dst__, src__, clientData__, status__) \
-    { \
-        CsrWifiRouterCtrlResumeRes *msg__; \
-        CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlResumeResSend(src__, clientData__, status__) \
-    CsrWifiRouterCtrlResumeResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlStaInactiveIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    staAddress   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->staAddress = (staAddress__);
-
-#define CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, src__, clientData__, interfaceTag__, staAddress__) \
-    { \
-        CsrWifiRouterCtrlStaInactiveInd *msg__; \
-        CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlStaInactiveIndSend(dst__, clientData__, interfaceTag__, staAddress__) \
-    CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, staAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlSuspendIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue       - Destination Task Queue
-    clientData  -
-    hardSuspend -
-    d3Suspend   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->hardSuspend = (hardSuspend__); \
-    msg__->d3Suspend = (d3Suspend__);
-
-#define CsrWifiRouterCtrlSuspendIndSendTo(dst__, src__, clientData__, hardSuspend__, d3Suspend__) \
-    { \
-        CsrWifiRouterCtrlSuspendInd *msg__; \
-        CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlSuspendIndSend(dst__, clientData__, hardSuspend__, d3Suspend__) \
-    CsrWifiRouterCtrlSuspendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, hardSuspend__, d3Suspend__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlSuspendResSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    clientData -
-    status     -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlSuspendResSendTo(dst__, src__, clientData__, status__) \
-    { \
-        CsrWifiRouterCtrlSuspendRes *msg__; \
-        CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlSuspendResSend(src__, clientData__, status__) \
-    CsrWifiRouterCtrlSuspendResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasAddReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    clientData   -
-    tclasLength  -
-    tclas        -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->tclasLength = (tclasLength__); \
-    msg__->tclas = (tclas__);
-
-#define CsrWifiRouterCtrlTclasAddReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
-    { \
-        CsrWifiRouterCtrlTclasAddReq *msg__; \
-        CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTclasAddReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
-    CsrWifiRouterCtrlTclasAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasAddCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlTclasAddCfm *msg__; \
-        CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTclasAddCfmSend(dst__, clientData__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasDelReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    clientData   -
-    tclasLength  -
-    tclas        -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->tclasLength = (tclasLength__); \
-    msg__->tclas = (tclas__);
-
-#define CsrWifiRouterCtrlTclasDelReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
-    { \
-        CsrWifiRouterCtrlTclasDelReq *msg__; \
-        CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTclasDelReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
-    CsrWifiRouterCtrlTclasDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasDelCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlTclasDelCfm *msg__; \
-        CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTclasDelCfmSend(dst__, clientData__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficClassificationReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    clientData   -
-    trafficType  -
-    period       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->trafficType = (trafficType__); \
-    msg__->period = (period__);
-
-#define CsrWifiRouterCtrlTrafficClassificationReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \
-    { \
-        CsrWifiRouterCtrlTrafficClassificationReq *msg__; \
-        CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTrafficClassificationReqSend(src__, interfaceTag__, clientData__, trafficType__, period__) \
-    CsrWifiRouterCtrlTrafficClassificationReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficType__, period__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficConfigReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue             - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag      -
-    clientData        -
-    trafficConfigType -
-    config            -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->clientData = (clientData__); \
-    msg__->trafficConfigType = (trafficConfigType__); \
-    msg__->config = (config__);
-
-#define CsrWifiRouterCtrlTrafficConfigReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
-    { \
-        CsrWifiRouterCtrlTrafficConfigReq *msg__; \
-        CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTrafficConfigReqSend(src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
-    CsrWifiRouterCtrlTrafficConfigReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficConfigType__, config__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficProtocolIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    packetType   -
-    direction    -
-    srcAddress   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->packetType = (packetType__); \
-    msg__->direction = (direction__); \
-    msg__->srcAddress = (srcAddress__);
-
-#define CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
-    { \
-        CsrWifiRouterCtrlTrafficProtocolInd *msg__; \
-        CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTrafficProtocolIndSend(dst__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
-    CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, packetType__, direction__, srcAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficSampleIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    stats        -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->stats = (stats__);
-
-#define CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, src__, clientData__, interfaceTag__, stats__) \
-    { \
-        CsrWifiRouterCtrlTrafficSampleInd *msg__; \
-        CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlTrafficSampleIndSend(dst__, clientData__, interfaceTag__, stats__) \
-    CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, stats__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlUnexpectedFrameIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__);
-
-#define CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
-    { \
-        CsrWifiRouterCtrlUnexpectedFrameInd *msg__; \
-        CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlUnexpectedFrameIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \
-    CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiFilterReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag    -
-    isWapiConnected -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiFilterReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->isWapiConnected = (isWapiConnected__);
-
-#define CsrWifiRouterCtrlWapiFilterReqSendTo(dst__, src__, interfaceTag__, isWapiConnected__) \
-    { \
-        CsrWifiRouterCtrlWapiFilterReq *msg__; \
-        CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiFilterReqSend(src__, interfaceTag__, isWapiConnected__) \
-    CsrWifiRouterCtrlWapiFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, isWapiConnected__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiMulticastFilterReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiMulticastFilterReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlWapiMulticastFilterReq *msg__; \
-        CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiMulticastFilterReqSend(src__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiRxMicCheckIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    signalLength -
-    signal       -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->signalLength = (signalLength__); \
-    msg__->signal = (signal__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
-    { \
-        CsrWifiRouterCtrlWapiRxMicCheckInd *msg__; \
-        CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiRxMicCheckIndSend(dst__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
-    CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiRxPktReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    signalLength -
-    signal       -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->signalLength = (signalLength__); \
-    msg__->signal = (signal__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiRouterCtrlWapiRxPktReqSendTo(dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
-    { \
-        CsrWifiRouterCtrlWapiRxPktReq *msg__; \
-        CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiRxPktReqSend(src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
-    CsrWifiRouterCtrlWapiRxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiUnicastFilterReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastFilterReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterCtrlWapiUnicastFilterReq *msg__; \
-        CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiUnicastFilterReqSend(src__, interfaceTag__, status__) \
-    CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    clientData   -
-    interfaceTag -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \
-    { \
-        CsrWifiRouterCtrlWapiUnicastTxEncryptInd *msg__; \
-        CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(dst__, clientData__, interfaceTag__, dataLength__, data__) \
-    CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiUnicastTxPktReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(dst__, src__, interfaceTag__, dataLength__, data__) \
-    { \
-        CsrWifiRouterCtrlWapiUnicastTxPktReq *msg__; \
-        CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWapiUnicastTxPktReqSend(src__, interfaceTag__, dataLength__, data__) \
-    CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    clientData -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, dst__, src__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlWifiOffReqSendTo(dst__, src__, clientData__) \
-    { \
-        CsrWifiRouterCtrlWifiOffReq *msg__; \
-        CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOffReqSend(src__, clientData__) \
-    CsrWifiRouterCtrlWifiOffReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    clientData        -
-    controlIndication -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->controlIndication = (controlIndication__);
-
-#define CsrWifiRouterCtrlWifiOffIndSendTo(dst__, src__, clientData__, controlIndication__) \
-    { \
-        CsrWifiRouterCtrlWifiOffInd *msg__; \
-        CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOffIndSend(dst__, clientData__, controlIndication__) \
-    CsrWifiRouterCtrlWifiOffIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, controlIndication__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffResSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    clientData -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, dst__, src__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlWifiOffResSendTo(dst__, src__, clientData__) \
-    { \
-        CsrWifiRouterCtrlWifiOffRes *msg__; \
-        CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOffResSend(src__, clientData__) \
-    CsrWifiRouterCtrlWifiOffResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    clientData -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, dst__, src__); \
-    msg__->clientData = (clientData__);
-
-#define CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, src__, clientData__) \
-    { \
-        CsrWifiRouterCtrlWifiOffCfm *msg__; \
-        CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOffCfmSend(dst__, clientData__) \
-    CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnReqSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    clientData -
-    dataLength - Number of bytes in the buffer pointed to by 'data'
-    data       - Pointer to the buffer containing 'dataLength' bytes
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiRouterCtrlWifiOnReqSendTo(dst__, src__, clientData__, dataLength__, data__) \
-    { \
-        CsrWifiRouterCtrlWifiOnReq *msg__; \
-        CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOnReqSend(src__, clientData__, dataLength__, data__) \
-    CsrWifiRouterCtrlWifiOnReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnIndSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    clientData -
-    status     -
-    versions   -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->status = (status__); \
-    msg__->versions = (versions__);
-
-#define CsrWifiRouterCtrlWifiOnIndSendTo(dst__, src__, clientData__, status__, versions__) \
-    { \
-        CsrWifiRouterCtrlWifiOnInd *msg__; \
-        CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOnIndSend(dst__, clientData__, status__, versions__) \
-    CsrWifiRouterCtrlWifiOnIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__, versions__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnResSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    clientData          -
-    status              -
-    numInterfaceAddress -
-    stationMacAddress   - array size 1 MUST match CSR_WIFI_NUM_INTERFACES
-    smeVersions         -
-    scheduledInterrupt  -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->status = (status__); \
-    msg__->numInterfaceAddress = (numInterfaceAddress__); \
-    memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2); \
-    msg__->smeVersions = (smeVersions__); \
-    msg__->scheduledInterrupt = (scheduledInterrupt__);
-
-#define CsrWifiRouterCtrlWifiOnResSendTo(dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
-    { \
-        CsrWifiRouterCtrlWifiOnRes *msg__; \
-        CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOnResSend(src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
-    CsrWifiRouterCtrlWifiOnResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnCfmSend
-
-  DESCRIPTION
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    clientData -
-    status     -
-
-*******************************************************************************/
-#define CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, dst__, src__); \
-    msg__->clientData = (clientData__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, src__, clientData__, status__) \
-    { \
-        CsrWifiRouterCtrlWifiOnCfm *msg__; \
-        CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterCtrlWifiOnCfmSend(dst__, clientData__, status__) \
-    CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__)
-
-#endif /* CSR_WIFI_ROUTER_CTRL_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_prim.h b/drivers/staging/csr/csr_wifi_router_ctrl_prim.h
deleted file mode 100644 (file)
index 1312a33..0000000
+++ /dev/null
@@ -1,2113 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_CTRL_PRIM_H__
-#define CSR_WIFI_ROUTER_CTRL_PRIM_H__
-
-#include <linux/types.h>
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-#include "csr_wifi_common.h"
-#include "csr_result.h"
-#include "csr_wifi_fsm_event.h"
-
-#define CSR_WIFI_ROUTER_CTRL_PRIM                                       (0x0401)
-
-typedef CsrPrim CsrWifiRouterCtrlPrim;
-
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteWrite)(u8 func, u32 address, u8 data);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteRead)(u8 func, u32 address, u8 *pdata);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioFirmwareDownload)(u32 length, const u8 *pdata);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioReset)(void);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioCoreDumpPrepare)(u8 suspendSme);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteBlockRead)(u8 func, u32 address, u8 *pdata, u32 length);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpRead16)(u8 func, u32 address, u16 *pdata);
-typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpWrite16)(u8 func, u32 address, u16 data);
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckRole
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
-                   -
-    CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlBlockAckRole;
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR   ((CsrWifiRouterCtrlBlockAckRole) 0x00)
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT    ((CsrWifiRouterCtrlBlockAckRole) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlControlIndication
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR
-                   -
-    CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT
-                   -
-    CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlControlIndication;
-#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR            ((CsrWifiRouterCtrlControlIndication) 0x01)
-#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT             ((CsrWifiRouterCtrlControlIndication) 0x02)
-#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED   ((CsrWifiRouterCtrlControlIndication) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlListAction
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET
-                   -
-    CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD
-                   -
-    CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE
-                   -
-    CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlListAction;
-#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET      ((CsrWifiRouterCtrlListAction) 0x00)
-#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD      ((CsrWifiRouterCtrlListAction) 0x01)
-#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE   ((CsrWifiRouterCtrlListAction) 0x02)
-#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH    ((CsrWifiRouterCtrlListAction) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlLowPowerMode
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlLowPowerMode;
-#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED   ((CsrWifiRouterCtrlLowPowerMode) 0x0000)
-#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED    ((CsrWifiRouterCtrlLowPowerMode) 0x0001)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMediaStatus
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED
-                   -
-    CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlMediaStatus;
-#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED      ((CsrWifiRouterCtrlMediaStatus) 0x00)
-#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED   ((CsrWifiRouterCtrlMediaStatus) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMode
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_MODE_NONE    -
-    CSR_WIFI_ROUTER_CTRL_MODE_IBSS    -
-    CSR_WIFI_ROUTER_CTRL_MODE_STA     -
-    CSR_WIFI_ROUTER_CTRL_MODE_AP      -
-    CSR_WIFI_ROUTER_CTRL_MODE_MONITOR -
-    CSR_WIFI_ROUTER_CTRL_MODE_AMP     -
-    CSR_WIFI_ROUTER_CTRL_MODE_P2P     -
-    CSR_WIFI_ROUTER_CTRL_MODE_P2PGO   -
-    CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI  -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlMode;
-#define CSR_WIFI_ROUTER_CTRL_MODE_NONE      ((CsrWifiRouterCtrlMode) 0x00)
-#define CSR_WIFI_ROUTER_CTRL_MODE_IBSS      ((CsrWifiRouterCtrlMode) 0x01)
-#define CSR_WIFI_ROUTER_CTRL_MODE_STA       ((CsrWifiRouterCtrlMode) 0x02)
-#define CSR_WIFI_ROUTER_CTRL_MODE_AP        ((CsrWifiRouterCtrlMode) 0x03)
-#define CSR_WIFI_ROUTER_CTRL_MODE_MONITOR   ((CsrWifiRouterCtrlMode) 0x04)
-#define CSR_WIFI_ROUTER_CTRL_MODE_AMP       ((CsrWifiRouterCtrlMode) 0x05)
-#define CSR_WIFI_ROUTER_CTRL_MODE_P2P       ((CsrWifiRouterCtrlMode) 0x06)
-#define CSR_WIFI_ROUTER_CTRL_MODE_P2PGO     ((CsrWifiRouterCtrlMode) 0x07)
-#define CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI    ((CsrWifiRouterCtrlMode) 0x08)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerStatus
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE
-                   -
-    CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE
-                   -
-    CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlPeerStatus;
-#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE       ((CsrWifiRouterCtrlPeerStatus) 0x00)
-#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE   ((CsrWifiRouterCtrlPeerStatus) 0x01)
-#define CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED           ((CsrWifiRouterCtrlPeerStatus) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPortAction
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
-                   -
-    CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
-                   -
-    CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlPortAction;
-#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN             ((CsrWifiRouterCtrlPortAction) 0x0000)
-#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD   ((CsrWifiRouterCtrlPortAction) 0x0001)
-#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK     ((CsrWifiRouterCtrlPortAction) 0x0002)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPowersaveType
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT
-                   - If set, AC BK PS info is present in b4 and b5
-    CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT
-                   - If set, AC BE PS info is present in b6 and b7
-    CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT
-                   - If set, AC VI PS info is present in b8 and b9
-    CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT
-                   - If set, AC VO PS info is present in b10 and b11
-    CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED
-                   -
-    CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlPowersaveType;
-#define CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT    ((CsrWifiRouterCtrlPowersaveType) 0x0001)
-#define CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT    ((CsrWifiRouterCtrlPowersaveType) 0x0002)
-#define CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT    ((CsrWifiRouterCtrlPowersaveType) 0x0004)
-#define CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT    ((CsrWifiRouterCtrlPowersaveType) 0x0008)
-#define CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED    ((CsrWifiRouterCtrlPowersaveType) 0x0010)
-#define CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED   ((CsrWifiRouterCtrlPowersaveType) 0x0020)
-#define CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED    ((CsrWifiRouterCtrlPowersaveType) 0x0040)
-#define CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED   ((CsrWifiRouterCtrlPowersaveType) 0x0080)
-#define CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED    ((CsrWifiRouterCtrlPowersaveType) 0x0100)
-#define CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED   ((CsrWifiRouterCtrlPowersaveType) 0x0200)
-#define CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED    ((CsrWifiRouterCtrlPowersaveType) 0x0400)
-#define CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED   ((CsrWifiRouterCtrlPowersaveType) 0x0800)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlProtocolDirection
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX
-                   -
-    CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlProtocolDirection;
-#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX   ((CsrWifiRouterCtrlProtocolDirection) 0x0000)
-#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX   ((CsrWifiRouterCtrlProtocolDirection) 0x0001)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlQoSControl
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF
-                   -
-    CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON
-                   -
-    CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlQoSControl;
-#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF        ((CsrWifiRouterCtrlQoSControl) 0x0000)
-#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON     ((CsrWifiRouterCtrlQoSControl) 0x0001)
-#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON   ((CsrWifiRouterCtrlQoSControl) 0x0002)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlQueueConfig
-
-  DESCRIPTION
-    Defines which Queues are enabled for use.
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE
-                   -
-    CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE
-                   -
-    CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE
-                   -
-    CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlQueueConfig;
-#define CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE   ((CsrWifiRouterCtrlQueueConfig) 0x01)
-#define CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE   ((CsrWifiRouterCtrlQueueConfig) 0x02)
-#define CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE   ((CsrWifiRouterCtrlQueueConfig) 0x04)
-#define CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE   ((CsrWifiRouterCtrlQueueConfig) 0x08)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficConfigType
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlTrafficConfigType;
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET    ((CsrWifiRouterCtrlTrafficConfigType) 0x0000)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER   ((CsrWifiRouterCtrlTrafficConfigType) 0x0001)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS      ((CsrWifiRouterCtrlTrafficConfigType) 0x0002)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficPacketType
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL
-                   -
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlTrafficPacketType;
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE       ((CsrWifiRouterCtrlTrafficPacketType) 0x0000)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL      ((CsrWifiRouterCtrlTrafficPacketType) 0x0001)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP       ((CsrWifiRouterCtrlTrafficPacketType) 0x0002)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK   ((CsrWifiRouterCtrlTrafficPacketType) 0x0004)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP        ((CsrWifiRouterCtrlTrafficPacketType) 0x0008)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET    ((CsrWifiRouterCtrlTrafficPacketType) 0x0010)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM     ((CsrWifiRouterCtrlTrafficPacketType) 0x0020)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL        ((CsrWifiRouterCtrlTrafficPacketType) 0x00FF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficType
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC
-                   -
-    CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS
-                   -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlTrafficType;
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL   ((CsrWifiRouterCtrlTrafficType) 0x00)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY       ((CsrWifiRouterCtrlTrafficType) 0x01)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC     ((CsrWifiRouterCtrlTrafficType) 0x02)
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS   ((CsrWifiRouterCtrlTrafficType) 0x03)
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerRecordHandle
-
-  DESCRIPTION
-
-*******************************************************************************/
-typedef u32 CsrWifiRouterCtrlPeerRecordHandle;
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPowersaveTypeMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by
-    CsrWifiRouterCtrlPowersaveType
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlPowersaveTypeMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlQueueConfigMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiRouterCtrlQueueConfig
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlQueueConfigMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRequestorInfo
-
-  DESCRIPTION
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterCtrlRequestorInfo;
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficStreamId
-
-  DESCRIPTION
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterCtrlTrafficStreamId;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlSmeVersions
-
-  DESCRIPTION
-
-  MEMBERS
-    firmwarePatch -
-    smeBuild      -
-    smeHip        -
-
-*******************************************************************************/
-typedef struct
-{
-    u32      firmwarePatch;
-    char *smeBuild;
-    u32      smeHip;
-} CsrWifiRouterCtrlSmeVersions;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlStaInfo
-
-  DESCRIPTION
-
-  MEMBERS
-    wmmOrQosEnabled     -
-    powersaveMode       -
-    maxSpLength         -
-    listenIntervalInTus -
-
-*******************************************************************************/
-typedef struct
-{
-    u8                            wmmOrQosEnabled;
-    CsrWifiRouterCtrlPowersaveTypeMask powersaveMode;
-    u8                           maxSpLength;
-    u16                          listenIntervalInTus;
-} CsrWifiRouterCtrlStaInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficFilter
-
-  DESCRIPTION
-
-  MEMBERS
-    etherType     -
-    ipType        -
-    udpSourcePort -
-    udpDestPort   -
-
-*******************************************************************************/
-typedef struct
-{
-    u32 etherType;
-    u8  ipType;
-    u32 udpSourcePort;
-    u32 udpDestPort;
-} CsrWifiRouterCtrlTrafficFilter;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficStats
-
-  DESCRIPTION
-
-  MEMBERS
-    rxMeanRate   - Mean rx data rate over the interval
-    rxFramesNum  - Keep number of Rx frames per second, for CYCLE_3.
-    txFramesNum  - Keep number of Tx frames per second, for CYCLE_3.
-    rxBytesCount - Keep calculated Rx throughput per second, for CYCLE_2.
-    txBytesCount - Keep calculated Tx throughput per second, for CYCLE_2.
-    intervals    - array size 11 MUST match TA_INTERVALS_NUM
-
-*******************************************************************************/
-typedef struct
-{
-    u32 rxMeanRate;
-    u32 rxFramesNum;
-    u32 txFramesNum;
-    u32 rxBytesCount;
-    u32 txBytesCount;
-    u8  intervals[11];
-} CsrWifiRouterCtrlTrafficStats;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlVersions
-
-  DESCRIPTION
-
-  MEMBERS
-    chipId        -
-    chipVersion   -
-    firmwareBuild -
-    firmwareHip   -
-    routerBuild   -
-    routerHip     -
-
-*******************************************************************************/
-typedef struct
-{
-    u32      chipId;
-    u32      chipVersion;
-    u32      firmwareBuild;
-    u32      firmwareHip;
-    char *routerBuild;
-    u32      routerHip;
-} CsrWifiRouterCtrlVersions;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficConfig
-
-  DESCRIPTION
-
-  MEMBERS
-    packetFilter -
-    customFilter -
-
-*******************************************************************************/
-typedef struct
-{
-    u16                      packetFilter;
-    CsrWifiRouterCtrlTrafficFilter customFilter;
-} CsrWifiRouterCtrlTrafficConfig;
-
-
-/* Downstream */
-#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST            (0x0000)
-
-#define CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ     ((CsrWifiRouterCtrlPrim) (0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_HIP_REQ                      ((CsrWifiRouterCtrlPrim) (0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ             ((CsrWifiRouterCtrlPrim) (0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES        ((CsrWifiRouterCtrlPrim) (0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ           ((CsrWifiRouterCtrlPrim) (0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ              ((CsrWifiRouterCtrlPrim) (0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_SUSPEND_RES                  ((CsrWifiRouterCtrlPrim) (0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ                ((CsrWifiRouterCtrlPrim) (0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_RESUME_RES                   ((CsrWifiRouterCtrlPrim) (0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ    ((CsrWifiRouterCtrlPrim) (0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ      ((CsrWifiRouterCtrlPrim) (0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ                ((CsrWifiRouterCtrlPrim) (0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ   ((CsrWifiRouterCtrlPrim) (0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ           ((CsrWifiRouterCtrlPrim) (0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ                 ((CsrWifiRouterCtrlPrim) (0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES                 ((CsrWifiRouterCtrlPrim) (0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ                  ((CsrWifiRouterCtrlPrim) (0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES                  ((CsrWifiRouterCtrlPrim) (0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ              ((CsrWifiRouterCtrlPrim) (0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ                 ((CsrWifiRouterCtrlPrim) (0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ                 ((CsrWifiRouterCtrlPrim) (0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ                 ((CsrWifiRouterCtrlPrim) (0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ              ((CsrWifiRouterCtrlPrim) (0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ             ((CsrWifiRouterCtrlPrim) (0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ         ((CsrWifiRouterCtrlPrim) (0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ        ((CsrWifiRouterCtrlPrim) (0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ              ((CsrWifiRouterCtrlPrim) (0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ    ((CsrWifiRouterCtrlPrim) (0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ      ((CsrWifiRouterCtrlPrim) (0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ      ((CsrWifiRouterCtrlPrim) (0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ              ((CsrWifiRouterCtrlPrim) (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
-
-
-#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST           (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)
-
-/* Upstream */
-#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST              (0x0000 + CSR_PRIM_UPSTREAM)
-
-#define CSR_WIFI_ROUTER_CTRL_HIP_IND                      ((CsrWifiRouterCtrlPrim)(0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND        ((CsrWifiRouterCtrlPrim)(0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM           ((CsrWifiRouterCtrlPrim)(0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_RESUME_IND                   ((CsrWifiRouterCtrlPrim)(0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_SUSPEND_IND                  ((CsrWifiRouterCtrlPrim)(0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM                ((CsrWifiRouterCtrlPrim)(0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM    ((CsrWifiRouterCtrlPrim)(0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM      ((CsrWifiRouterCtrlPrim)(0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM                ((CsrWifiRouterCtrlPrim)(0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND         ((CsrWifiRouterCtrlPrim)(0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND           ((CsrWifiRouterCtrlPrim)(0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND                 ((CsrWifiRouterCtrlPrim)(0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM                 ((CsrWifiRouterCtrlPrim)(0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND                  ((CsrWifiRouterCtrlPrim)(0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM                  ((CsrWifiRouterCtrlPrim)(0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND         ((CsrWifiRouterCtrlPrim)(0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND           ((CsrWifiRouterCtrlPrim)(0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND              ((CsrWifiRouterCtrlPrim)(0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_CONNECTED_IND                ((CsrWifiRouterCtrlPrim)(0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM                 ((CsrWifiRouterCtrlPrim)(0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM                 ((CsrWifiRouterCtrlPrim)(0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND         ((CsrWifiRouterCtrlPrim)(0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM              ((CsrWifiRouterCtrlPrim)(0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM             ((CsrWifiRouterCtrlPrim)(0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM         ((CsrWifiRouterCtrlPrim)(0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM        ((CsrWifiRouterCtrlPrim)(0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND          ((CsrWifiRouterCtrlPrim)(0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND             ((CsrWifiRouterCtrlPrim)(0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND        ((CsrWifiRouterCtrlPrim)(0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM                 ((CsrWifiRouterCtrlPrim)(0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND  ((CsrWifiRouterCtrlPrim)(0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
-
-#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST             (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)
-
-#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT             (CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)
-#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT               (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST   + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlConfigurePowerModeReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    mode       -
-    wakeHost   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrWifiRouterCtrlLowPowerMode  mode;
-    u8                        wakeHost;
-} CsrWifiRouterCtrlConfigurePowerModeReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlHipReq
-
-  DESCRIPTION
-    This primitive is used for transferring MLME messages to the HIP.
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    mlmeCommandLength - Length of the MLME signal
-    mlmeCommand       - Pointer to the MLME signal
-    dataRef1Length    - Length of the dataRef1 bulk data
-    dataRef1          - Pointer to the bulk data 1
-    dataRef2Length    - Length of the dataRef2 bulk data
-    dataRef2          - Pointer to the bulk data 2
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       mlmeCommandLength;
-    u8       *mlmeCommand;
-    u16       dataRef1Length;
-    u8       *dataRef1;
-    u16       dataRef2Length;
-    u8       *dataRef2;
-} CsrWifiRouterCtrlHipReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMediaStatusReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    clientData   -
-    mediaStatus  -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrWifiRouterCtrlMediaStatus   mediaStatus;
-} CsrWifiRouterCtrlMediaStatusReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMulticastAddressRes
-
-  DESCRIPTION
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    interfaceTag      -
-    clientData        -
-    status            -
-    action            -
-    getAddressesCount -
-    getAddresses      -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      status;
-    CsrWifiRouterCtrlListAction    action;
-    u8                       getAddressesCount;
-    CsrWifiMacAddress             *getAddresses;
-} CsrWifiRouterCtrlMulticastAddressRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPortConfigureReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common                 - Common header for use with the CsrWifiFsm Module
-    interfaceTag           -
-    clientData             -
-    uncontrolledPortAction -
-    controlledPortAction   -
-    macAddress             -
-    setProtection          -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrWifiRouterCtrlPortAction    uncontrolledPortAction;
-    CsrWifiRouterCtrlPortAction    controlledPortAction;
-    CsrWifiMacAddress              macAddress;
-    u8                        setProtection;
-} CsrWifiRouterCtrlPortConfigureReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlQosControlReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    clientData   -
-    control      -
-    queueConfig  -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                  common;
-    u16                        interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo   clientData;
-    CsrWifiRouterCtrlQoSControl      control;
-    CsrWifiRouterCtrlQueueConfigMask queueConfig;
-} CsrWifiRouterCtrlQosControlReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlSuspendRes
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    status     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      status;
-} CsrWifiRouterCtrlSuspendRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasAddReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    clientData   -
-    tclasLength  -
-    tclas        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      tclasLength;
-    u8                      *tclas;
-} CsrWifiRouterCtrlTclasAddReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlResumeRes
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    status     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      status;
-} CsrWifiRouterCtrlResumeRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioDeinitialiseReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlRawSdioDeinitialiseReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioInitialiseReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlRawSdioInitialiseReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasDelReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    clientData   -
-    tclasLength  -
-    tclas        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      tclasLength;
-    u8                      *tclas;
-} CsrWifiRouterCtrlTclasDelReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficClassificationReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    clientData   -
-    trafficType  -
-    period       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrWifiRouterCtrlTrafficType   trafficType;
-    u16                      period;
-} CsrWifiRouterCtrlTrafficClassificationReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficConfigReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    interfaceTag      -
-    clientData        -
-    trafficConfigType -
-    config            -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                    common;
-    u16                          interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo     clientData;
-    CsrWifiRouterCtrlTrafficConfigType trafficConfigType;
-    CsrWifiRouterCtrlTrafficConfig     config;
-} CsrWifiRouterCtrlTrafficConfigReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlWifiOffReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffRes
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlWifiOffRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    dataLength - Number of bytes in the buffer pointed to by 'data'
-    data       - Pointer to the buffer containing 'dataLength' bytes
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u32                      dataLength;
-    u8                      *data;
-} CsrWifiRouterCtrlWifiOnReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnRes
-
-  DESCRIPTION
-
-  MEMBERS
-    common              - Common header for use with the CsrWifiFsm Module
-    clientData          -
-    status              -
-    numInterfaceAddress -
-    stationMacAddress   - array size 1 MUST match CSR_WIFI_NUM_INTERFACES
-    smeVersions         -
-    scheduledInterrupt  -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      status;
-    u16                      numInterfaceAddress;
-    CsrWifiMacAddress              stationMacAddress[2];
-    CsrWifiRouterCtrlSmeVersions   smeVersions;
-    u8                        scheduledInterrupt;
-} CsrWifiRouterCtrlWifiOnRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlM4TransmitReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    clientData   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlM4TransmitReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlModeSetReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common              - Common header for use with the CsrWifiFsm Module
-    interfaceTag        -
-    clientData          -
-    mode                -
-    bssid               - BSSID of the network the device is going to be a part
-                          of
-    protection          - Set to TRUE if encryption is enabled for the
-                          connection/broadcast frames
-    intraBssDistEnabled - If set to TRUE, intra BSS destribution will be
-                          enabled. If set to FALSE, any unicast PDU which does
-                          not have the RA as the the local MAC address, shall be
-                          ignored. This field is interpreted by the receive if
-                          mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrWifiRouterCtrlMode          mode;
-    CsrWifiMacAddress              bssid;
-    u8                        protection;
-    u8                        intraBssDistEnabled;
-} CsrWifiRouterCtrlModeSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerAddReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   -
-    clientData     -
-    peerMacAddress -
-    associationId  -
-    staInfo        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrWifiMacAddress              peerMacAddress;
-    u16                      associationId;
-    CsrWifiRouterCtrlStaInfo       staInfo;
-} CsrWifiRouterCtrlPeerAddReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerDelReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     -
-    clientData       -
-    peerRecordHandle -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                   common;
-    u16                         interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo    clientData;
-    CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
-} CsrWifiRouterCtrlPeerDelReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerUpdateReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     -
-    clientData       -
-    peerRecordHandle -
-    powersaveMode    -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                    common;
-    u16                          interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo     clientData;
-    CsrWifiRouterCtrlPeerRecordHandle  peerRecordHandle;
-    CsrWifiRouterCtrlPowersaveTypeMask powersaveMode;
-} CsrWifiRouterCtrlPeerUpdateReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlCapabilitiesReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlCapabilitiesReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckEnableReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    -
-    clientData      -
-    macAddress      -
-    trafficStreamID -
-    role            -
-    bufferSize      -
-    timeout         -
-    ssn             -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                  common;
-    u16                        interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo   clientData;
-    CsrWifiMacAddress                macAddress;
-    CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
-    CsrWifiRouterCtrlBlockAckRole    role;
-    u16                        bufferSize;
-    u16                        timeout;
-    u16                        ssn;
-} CsrWifiRouterCtrlBlockAckEnableReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckDisableReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    -
-    clientData      -
-    macAddress      -
-    trafficStreamID -
-    role            -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                  common;
-    u16                        interfaceTag;
-    CsrWifiRouterCtrlRequestorInfo   clientData;
-    CsrWifiMacAddress                macAddress;
-    CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
-    CsrWifiRouterCtrlBlockAckRole    role;
-} CsrWifiRouterCtrlBlockAckDisableReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiRxPktReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    signalLength -
-    signal       -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u16       signalLength;
-    u8       *signal;
-    u16       dataLength;
-    u8       *data;
-} CsrWifiRouterCtrlWapiRxPktReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiMulticastFilterReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u8        status;
-} CsrWifiRouterCtrlWapiMulticastFilterReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiUnicastFilterReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u8        status;
-} CsrWifiRouterCtrlWapiUnicastFilterReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiUnicastTxPktReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u16       dataLength;
-    u8       *data;
-} CsrWifiRouterCtrlWapiUnicastTxPktReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiFilterReq
-
-  DESCRIPTION
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    -
-    isWapiConnected -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u8         isWapiConnected;
-} CsrWifiRouterCtrlWapiFilterReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlHipInd
-
-  DESCRIPTION
-    This primitive is used for transferring MLME messages from the HIP.
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    mlmeCommandLength - Length of the MLME signal
-    mlmeCommand       - Pointer to the MLME signal
-    dataRef1Length    - Length of the dataRef1 bulk data
-    dataRef1          - Pointer to the bulk data 1
-    dataRef2Length    - Length of the dataRef2 bulk data
-    dataRef2          - Pointer to the bulk data 2
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       mlmeCommandLength;
-    u8       *mlmeCommand;
-    u16       dataRef1Length;
-    u8       *dataRef1;
-    u16       dataRef2Length;
-    u8       *dataRef2;
-} CsrWifiRouterCtrlHipInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMulticastAddressInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    clientData        -
-    interfaceTag      -
-    action            -
-    setAddressesCount -
-    setAddresses      -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlListAction    action;
-    u8                       setAddressesCount;
-    CsrWifiMacAddress             *setAddresses;
-} CsrWifiRouterCtrlMulticastAddressInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPortConfigureCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-    macAddress   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-    CsrWifiMacAddress              macAddress;
-} CsrWifiRouterCtrlPortConfigureCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlResumeInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    clientData      -
-    powerMaintained -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u8                        powerMaintained;
-} CsrWifiRouterCtrlResumeInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlSuspendInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    clientData  -
-    hardSuspend -
-    d3Suspend   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u8                        hardSuspend;
-    u8                        d3Suspend;
-} CsrWifiRouterCtrlSuspendInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasAddCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-} CsrWifiRouterCtrlTclasAddCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioDeinitialiseCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    result     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      result;
-} CsrWifiRouterCtrlRawSdioDeinitialiseCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlRawSdioInitialiseCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    clientData       -
-    result           -
-    byteRead         -
-    byteWrite        -
-    firmwareDownload -
-    reset            -
-    coreDumpPrepare  -
-    byteBlockRead    -
-    gpRead16         -
-    gpWrite16        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                          common;
-    CsrWifiRouterCtrlRequestorInfo           clientData;
-    CsrResult                                result;
-    CsrWifiRouterCtrlRawSdioByteRead         byteRead;
-    CsrWifiRouterCtrlRawSdioByteWrite        byteWrite;
-    CsrWifiRouterCtrlRawSdioFirmwareDownload firmwareDownload;
-    CsrWifiRouterCtrlRawSdioReset            reset;
-    CsrWifiRouterCtrlRawSdioCoreDumpPrepare  coreDumpPrepare;
-    CsrWifiRouterCtrlRawSdioByteBlockRead    byteBlockRead;
-    CsrWifiRouterCtrlRawSdioGpRead16         gpRead16;
-    CsrWifiRouterCtrlRawSdioGpWrite16        gpWrite16;
-} CsrWifiRouterCtrlRawSdioInitialiseCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTclasDelCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-} CsrWifiRouterCtrlTclasDelCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficProtocolInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    packetType   -
-    direction    -
-    srcAddress   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                    common;
-    CsrWifiRouterCtrlRequestorInfo     clientData;
-    u16                          interfaceTag;
-    CsrWifiRouterCtrlTrafficPacketType packetType;
-    CsrWifiRouterCtrlProtocolDirection direction;
-    CsrWifiMacAddress                  srcAddress;
-} CsrWifiRouterCtrlTrafficProtocolInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlTrafficSampleInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    stats        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlTrafficStats  stats;
-} CsrWifiRouterCtrlTrafficSampleInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    clientData        -
-    controlIndication -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                    common;
-    CsrWifiRouterCtrlRequestorInfo     clientData;
-    CsrWifiRouterCtrlControlIndication controlIndication;
-} CsrWifiRouterCtrlWifiOffInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOffCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-} CsrWifiRouterCtrlWifiOffCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    status     -
-    versions   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      status;
-    CsrWifiRouterCtrlVersions      versions;
-} CsrWifiRouterCtrlWifiOnInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWifiOnCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    clientData -
-    status     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    CsrResult                      status;
-} CsrWifiRouterCtrlWifiOnCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlM4ReadyToSendInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiMacAddress              peerMacAddress;
-} CsrWifiRouterCtrlM4ReadyToSendInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlM4TransmittedInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-    status         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiMacAddress              peerMacAddress;
-    CsrResult                      status;
-} CsrWifiRouterCtrlM4TransmittedInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlMicFailureInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-    unicastPdu     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiMacAddress              peerMacAddress;
-    u8                        unicastPdu;
-} CsrWifiRouterCtrlMicFailureInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlConnectedInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-    peerStatus     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiMacAddress              peerMacAddress;
-    CsrWifiRouterCtrlPeerStatus    peerStatus;
-} CsrWifiRouterCtrlConnectedInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerAddCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    clientData       -
-    interfaceTag     -
-    peerMacAddress   -
-    peerRecordHandle -
-    status           -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                   common;
-    CsrWifiRouterCtrlRequestorInfo    clientData;
-    u16                         interfaceTag;
-    CsrWifiMacAddress                 peerMacAddress;
-    CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
-    CsrResult                         status;
-} CsrWifiRouterCtrlPeerAddCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerDelCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-} CsrWifiRouterCtrlPeerDelCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlUnexpectedFrameInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    clientData     -
-    interfaceTag   -
-    peerMacAddress -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiMacAddress              peerMacAddress;
-} CsrWifiRouterCtrlUnexpectedFrameInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlPeerUpdateCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-} CsrWifiRouterCtrlPeerUpdateCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlCapabilitiesCfm
-
-  DESCRIPTION
-    The router sends this primitive to confirm the size of the queues of the
-    HIP.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    clientData       -
-    commandQueueSize - Size of command queue
-    trafficQueueSize - Size of traffic queue (per AC)
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      commandQueueSize;
-    u16                      trafficQueueSize;
-} CsrWifiRouterCtrlCapabilitiesCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckEnableCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-} CsrWifiRouterCtrlBlockAckEnableCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckDisableCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrResult                      status;
-} CsrWifiRouterCtrlBlockAckDisableCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlBlockAckErrorInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    clientData      -
-    interfaceTag    -
-    trafficStreamID -
-    peerMacAddress  -
-    status          -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                  common;
-    CsrWifiRouterCtrlRequestorInfo   clientData;
-    u16                        interfaceTag;
-    CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
-    CsrWifiMacAddress                peerMacAddress;
-    CsrResult                        status;
-} CsrWifiRouterCtrlBlockAckErrorInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlStaInactiveInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    staAddress   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiMacAddress              staAddress;
-} CsrWifiRouterCtrlStaInactiveInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiRxMicCheckInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    signalLength -
-    signal       -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    u16                      signalLength;
-    u8                      *signal;
-    u16                      dataLength;
-    u8                      *data;
-} CsrWifiRouterCtrlWapiRxMicCheckInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlModeSetCfm
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    mode         -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    CsrWifiRouterCtrlMode          mode;
-    CsrResult                      status;
-} CsrWifiRouterCtrlModeSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterCtrlWapiUnicastTxEncryptInd
-
-  DESCRIPTION
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    clientData   -
-    interfaceTag -
-    dataLength   -
-    data         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrWifiRouterCtrlRequestorInfo clientData;
-    u16                      interfaceTag;
-    u16                      dataLength;
-    u8                      *data;
-} CsrWifiRouterCtrlWapiUnicastTxEncryptInd;
-
-#endif /* CSR_WIFI_ROUTER_CTRL_PRIM_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_sef.c b/drivers/staging/csr/csr_wifi_router_ctrl_sef.c
deleted file mode 100644 (file)
index 99cf930..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*****************************************************************************
-
-  (c) Cambridge Silicon Radio Limited 2010
-  Confidential information of CSR
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-#include "csr_wifi_router_ctrl_sef.h"
-
-const CsrWifiRouterCtrlStateHandlerType
-       CsrWifiRouterCtrlDownstreamStateHandlers
-       [CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT] = {
-               /* 0x0000 */ CsrWifiRouterCtrlConfigurePowerModeReqHandler,
-               /* 0x0001 */ CsrWifiRouterCtrlHipReqHandler,
-               /* 0x0002 */ CsrWifiRouterCtrlMediaStatusReqHandler,
-               /* 0x0003 */ CsrWifiRouterCtrlMulticastAddressResHandler,
-               /* 0x0004 */ CsrWifiRouterCtrlPortConfigureReqHandler,
-               /* 0x0005 */ CsrWifiRouterCtrlQosControlReqHandler,
-               /* 0x0006 */ CsrWifiRouterCtrlSuspendResHandler,
-               /* 0x0007 */ CsrWifiRouterCtrlTclasAddReqHandler,
-               /* 0x0008 */ CsrWifiRouterCtrlResumeResHandler,
-               /* 0x0009 */ CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler,
-               /* 0x000A */ CsrWifiRouterCtrlRawSdioInitialiseReqHandler,
-               /* 0x000B */ CsrWifiRouterCtrlTclasDelReqHandler,
-               /* 0x000C */ CsrWifiRouterCtrlTrafficClassificationReqHandler,
-               /* 0x000D */ CsrWifiRouterCtrlTrafficConfigReqHandler,
-               /* 0x000E */ CsrWifiRouterCtrlWifiOffReqHandler,
-               /* 0x000F */ CsrWifiRouterCtrlWifiOffResHandler,
-               /* 0x0010 */ CsrWifiRouterCtrlWifiOnReqHandler,
-               /* 0x0011 */ CsrWifiRouterCtrlWifiOnResHandler,
-               /* 0x0012 */ CsrWifiRouterCtrlM4TransmitReqHandler,
-               /* 0x0013 */ CsrWifiRouterCtrlModeSetReqHandler,
-               /* 0x0014 */ CsrWifiRouterCtrlPeerAddReqHandler,
-               /* 0x0015 */ CsrWifiRouterCtrlPeerDelReqHandler,
-               /* 0x0016 */ CsrWifiRouterCtrlPeerUpdateReqHandler,
-               /* 0x0017 */ CsrWifiRouterCtrlCapabilitiesReqHandler,
-               /* 0x0018 */ CsrWifiRouterCtrlBlockAckEnableReqHandler,
-               /* 0x0019 */ CsrWifiRouterCtrlBlockAckDisableReqHandler,
-               /* 0x001A */ CsrWifiRouterCtrlWapiRxPktReqHandler,
-               /* 0x001B */ CsrWifiRouterCtrlWapiMulticastFilterReqHandler,
-               /* 0x001C */ CsrWifiRouterCtrlWapiUnicastFilterReqHandler,
-               /* 0x001D */ CsrWifiRouterCtrlWapiUnicastTxPktReqHandler,
-               /* 0x001E */ CsrWifiRouterCtrlWapiFilterReqHandler,
-};
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_sef.h b/drivers/staging/csr/csr_wifi_router_ctrl_sef.h
deleted file mode 100644 (file)
index 2fb4937..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************************
-
-  (c) Cambridge Silicon Radio Limited 2010
-  Confidential information of CSR
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__
-#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__
-
-#include "csr_wifi_router_ctrl_prim.h"
-
-    typedef void (*CsrWifiRouterCtrlStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
-
-    extern const CsrWifiRouterCtrlStateHandlerType CsrWifiRouterCtrlDownstreamStateHandlers[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT];
-
-    extern void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-
-#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
deleted file mode 100644 (file)
index 3eda1b6..0000000
+++ /dev/null
@@ -1,2591 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "csr_msgconv.h"
-#include "csr_wifi_router_ctrl_prim.h"
-#include "csr_wifi_router_ctrl_serialize.h"
-
-void CsrWifiRouterCtrlPfree(void *ptr)
-{
-    kfree(ptr);
-}
-
-
-size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrWifiRouterCtrlLowPowerMode primitive->mode */
-    bufferSize += 1; /* u8 primitive->wakeHost */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlConfigurePowerModeReq *primitive = (CsrWifiRouterCtrlConfigurePowerModeReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->mode);
-    CsrUint8Ser(ptr, len, (u8) primitive->wakeHost);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlConfigurePowerModeReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mode, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->wakeHost, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlHipReqSizeof(void *msg)
-{
-    CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
-    bufferSize += 2;                            /* u16 primitive->mlmeCommandLength */
-    bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */
-    bufferSize += 2;                            /* u16 primitive->dataRef1Length */
-    bufferSize += primitive->dataRef1Length;    /* u8 primitive->dataRef1 */
-    bufferSize += 2;                            /* u16 primitive->dataRef2Length */
-    bufferSize += primitive->dataRef2Length;    /* u8 primitive->dataRef2 */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength);
-    if (primitive->mlmeCommandLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length);
-    if (primitive->dataRef1Length)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length);
-    if (primitive->dataRef2Length)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlHipReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset);
-    if (primitive->mlmeCommandLength)
-    {
-        primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength)));
-    }
-    else
-    {
-        primitive->mlmeCommand = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset);
-    if (primitive->dataRef1Length)
-    {
-        primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL);
-        CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length)));
-    }
-    else
-    {
-        primitive->dataRef1 = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset);
-    if (primitive->dataRef2Length)
-    {
-        primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL);
-        CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length)));
-    }
-    else
-    {
-        primitive->dataRef2 = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlHipReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) voidPrimitivePointer;
-    kfree(primitive->mlmeCommand);
-    kfree(primitive->dataRef1);
-    kfree(primitive->dataRef2);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 1; /* CsrWifiRouterCtrlMediaStatus primitive->mediaStatus */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlMediaStatusReq *primitive = (CsrWifiRouterCtrlMediaStatusReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlMediaStatusReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg)
-{
-    CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->getAddressesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlMulticastAddressRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset);
-    primitive->getAddresses = NULL;
-    if (primitive->getAddressesCount)
-    {
-        primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
-        {
-            CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlMulticastAddressResSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) voidPrimitivePointer;
-    kfree(primitive->getAddresses);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->uncontrolledPortAction */
-    bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->controlledPortAction */
-    bufferSize += 6; /* u8 primitive->macAddress.a[6] */
-    bufferSize += 1; /* u8 primitive->setProtection */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPortConfigureReq *primitive = (CsrWifiRouterCtrlPortConfigureReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->uncontrolledPortAction);
-    CsrUint16Ser(ptr, len, (u16) primitive->controlledPortAction);
-    CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->setProtection);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPortConfigureReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->uncontrolledPortAction, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->controlledPortAction, buffer, &offset);
-    CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->setProtection, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrWifiRouterCtrlQoSControl primitive->control */
-    bufferSize += 1; /* CsrWifiRouterCtrlQueueConfigMask primitive->queueConfig */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlQosControlReq *primitive = (CsrWifiRouterCtrlQosControlReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->control);
-    CsrUint8Ser(ptr, len, (u8) primitive->queueConfig);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlQosControlReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->control, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->queueConfig, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlSuspendRes *primitive = (CsrWifiRouterCtrlSuspendRes *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlSuspendRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg)
-{
-    CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 2;                      /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2;                      /* u16 primitive->tclasLength */
-    bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
-    if (primitive->tclasLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTclasAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
-    if (primitive->tclasLength)
-    {
-        primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
-    }
-    else
-    {
-        primitive->tclas = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlTclasAddReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) voidPrimitivePointer;
-    kfree(primitive->tclas);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlResumeResSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlResumeRes *primitive = (CsrWifiRouterCtrlResumeRes *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlResumeRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg)
-{
-    CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 2;                      /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2;                      /* u16 primitive->tclasLength */
-    bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
-    if (primitive->tclasLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTclasDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
-    if (primitive->tclasLength)
-    {
-        primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
-    }
-    else
-    {
-        primitive->tclas = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlTclasDelReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) voidPrimitivePointer;
-    kfree(primitive->tclas);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 1; /* CsrWifiRouterCtrlTrafficType primitive->trafficType */
-    bufferSize += 2; /* u16 primitive->period */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTrafficClassificationReq *primitive = (CsrWifiRouterCtrlTrafficClassificationReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint8Ser(ptr, len, (u8) primitive->trafficType);
-    CsrUint16Ser(ptr, len, (u16) primitive->period);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTrafficClassificationReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->trafficType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->period, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrWifiRouterCtrlTrafficConfigType primitive->trafficConfigType */
-    bufferSize += 2; /* u16 primitive->config.packetFilter */
-    bufferSize += 4; /* u32 primitive->config.customFilter.etherType */
-    bufferSize += 1; /* u8 primitive->config.customFilter.ipType */
-    bufferSize += 4; /* u32 primitive->config.customFilter.udpSourcePort */
-    bufferSize += 4; /* u32 primitive->config.customFilter.udpDestPort */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTrafficConfigReq *primitive = (CsrWifiRouterCtrlTrafficConfigReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->trafficConfigType);
-    CsrUint16Ser(ptr, len, (u16) primitive->config.packetFilter);
-    CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.etherType);
-    CsrUint8Ser(ptr, len, (u8) primitive->config.customFilter.ipType);
-    CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpSourcePort);
-    CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpDestPort);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTrafficConfigReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->trafficConfigType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->config.packetFilter, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->config.customFilter.etherType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->config.customFilter.ipType, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->config.customFilter.udpSourcePort, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->config.customFilter.udpDestPort, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2;                     /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 4;                     /* u32 primitive->dataLength */
-    bufferSize += primitive->dataLength; /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWifiOnReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWifiOnReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) voidPrimitivePointer;
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 30) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 2; /* u16 primitive->numInterfaceAddress */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 2; i1++)
-        {
-            bufferSize += 6;                                                                            /* u8 primitive->stationMacAddress[i1].a[6] */
-        }
-    }
-    bufferSize += 4;                                                                                    /* u32 primitive->smeVersions.firmwarePatch */
-    bufferSize += (primitive->smeVersions.smeBuild ? strlen(primitive->smeVersions.smeBuild) : 0) + 1;  /* char* primitive->smeVersions.smeBuild (0 byte len + 1 for NULL Term) */
-    bufferSize += 4;                                                                                    /* u32 primitive->smeVersions.smeHip */
-    bufferSize += 1;                                                                                    /* u8 primitive->scheduledInterrupt */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->numInterfaceAddress);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 2; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6)));
-        }
-    }
-    CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.firmwarePatch);
-    CsrCharStringSer(ptr, len, primitive->smeVersions.smeBuild);
-    CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.smeHip);
-    CsrUint8Ser(ptr, len, (u8) primitive->scheduledInterrupt);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWifiOnRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->numInterfaceAddress, buffer, &offset);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 2; i1++)
-        {
-            CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-    CsrUint32Des((u32 *) &primitive->smeVersions.firmwarePatch, buffer, &offset);
-    CsrCharStringDes(&primitive->smeVersions.smeBuild, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->smeVersions.smeHip, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scheduledInterrupt, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWifiOnResSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) voidPrimitivePointer;
-    kfree(primitive->smeVersions.smeBuild);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlM4TransmitReq *primitive = (CsrWifiRouterCtrlM4TransmitReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlM4TransmitReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */
-    bufferSize += 6; /* u8 primitive->bssid.a[6] */
-    bufferSize += 1; /* u8 primitive->protection */
-    bufferSize += 1; /* u8 primitive->intraBssDistEnabled */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlModeSetReq *primitive = (CsrWifiRouterCtrlModeSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint8Ser(ptr, len, (u8) primitive->mode);
-    CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->protection);
-    CsrUint8Ser(ptr, len, (u8) primitive->intraBssDistEnabled);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlModeSetReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
-    CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->protection, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->intraBssDistEnabled, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 2; /* u16 primitive->associationId */
-    bufferSize += 1; /* u8 primitive->staInfo.wmmOrQosEnabled */
-    bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->staInfo.powersaveMode */
-    bufferSize += 1; /* u8 primitive->staInfo.maxSpLength */
-    bufferSize += 2; /* u16 primitive->staInfo.listenIntervalInTus */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPeerAddReq *primitive = (CsrWifiRouterCtrlPeerAddReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->associationId);
-    CsrUint8Ser(ptr, len, (u8) primitive->staInfo.wmmOrQosEnabled);
-    CsrUint16Ser(ptr, len, (u16) primitive->staInfo.powersaveMode);
-    CsrUint8Ser(ptr, len, (u8) primitive->staInfo.maxSpLength);
-    CsrUint16Ser(ptr, len, (u16) primitive->staInfo.listenIntervalInTus);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPeerAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->associationId, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->staInfo.wmmOrQosEnabled, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->staInfo.powersaveMode, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->staInfo.maxSpLength, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->staInfo.listenIntervalInTus, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPeerDelReq *primitive = (CsrWifiRouterCtrlPeerDelReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPeerDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
-    bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->powersaveMode */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPeerUpdateReq *primitive = (CsrWifiRouterCtrlPeerUpdateReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
-    CsrUint16Ser(ptr, len, (u16) primitive->powersaveMode);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPeerUpdateReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->powersaveMode, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 6; /* u8 primitive->macAddress.a[6] */
-    bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
-    bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */
-    bufferSize += 2; /* u16 primitive->bufferSize */
-    bufferSize += 2; /* u16 primitive->timeout */
-    bufferSize += 2; /* u16 primitive->ssn */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlBlockAckEnableReq *primitive = (CsrWifiRouterCtrlBlockAckEnableReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
-    CsrUint8Ser(ptr, len, (u8) primitive->role);
-    CsrUint16Ser(ptr, len, (u16) primitive->bufferSize);
-    CsrUint16Ser(ptr, len, (u16) primitive->timeout);
-    CsrUint16Ser(ptr, len, (u16) primitive->ssn);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlBlockAckEnableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->role, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->bufferSize, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->timeout, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->ssn, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 6; /* u8 primitive->macAddress.a[6] */
-    bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
-    bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlBlockAckDisableReq *primitive = (CsrWifiRouterCtrlBlockAckDisableReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
-    CsrUint8Ser(ptr, len, (u8) primitive->role);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlBlockAckDisableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->role, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2;                       /* u16 primitive->interfaceTag */
-    bufferSize += 2;                       /* u16 primitive->signalLength */
-    bufferSize += primitive->signalLength; /* u8 primitive->signal */
-    bufferSize += 2;                       /* u16 primitive->dataLength */
-    bufferSize += primitive->dataLength;   /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->signalLength);
-    if (primitive->signalLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWapiRxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset);
-    if (primitive->signalLength)
-    {
-        primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength)));
-    }
-    else
-    {
-        primitive->signal = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) voidPrimitivePointer;
-    kfree(primitive->signal);
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2;                     /* u16 primitive->interfaceTag */
-    bufferSize += 2;                     /* u16 primitive->dataLength */
-    bufferSize += primitive->dataLength; /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) voidPrimitivePointer;
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlHipIndSizeof(void *msg)
-{
-    CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
-    bufferSize += 2;                            /* u16 primitive->mlmeCommandLength */
-    bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */
-    bufferSize += 2;                            /* u16 primitive->dataRef1Length */
-    bufferSize += primitive->dataRef1Length;    /* u8 primitive->dataRef1 */
-    bufferSize += 2;                            /* u16 primitive->dataRef2Length */
-    bufferSize += primitive->dataRef2Length;    /* u8 primitive->dataRef2 */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength);
-    if (primitive->mlmeCommandLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length);
-    if (primitive->dataRef1Length)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length);
-    if (primitive->dataRef2Length)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlHipInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset);
-    if (primitive->mlmeCommandLength)
-    {
-        primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength)));
-    }
-    else
-    {
-        primitive->mlmeCommand = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset);
-    if (primitive->dataRef1Length)
-    {
-        primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL);
-        CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length)));
-    }
-    else
-    {
-        primitive->dataRef1 = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset);
-    if (primitive->dataRef2Length)
-    {
-        primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL);
-        CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length)));
-    }
-    else
-    {
-        primitive->dataRef2 = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlHipIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) voidPrimitivePointer;
-    kfree(primitive->mlmeCommand);
-    kfree(primitive->dataRef1);
-    kfree(primitive->dataRef2);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg)
-{
-    CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->setAddressesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlMulticastAddressInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset);
-    primitive->setAddresses = NULL;
-    if (primitive->setAddressesCount)
-    {
-        primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
-        {
-            CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) voidPrimitivePointer;
-    kfree(primitive->setAddresses);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 6; /* u8 primitive->macAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPortConfigureCfm *primitive = (CsrWifiRouterCtrlPortConfigureCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPortConfigureCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 1; /* u8 primitive->hardSuspend */
-    bufferSize += 1; /* u8 primitive->d3Suspend */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlSuspendInd *primitive = (CsrWifiRouterCtrlSuspendInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint8Ser(ptr, len, (u8) primitive->hardSuspend);
-    CsrUint8Ser(ptr, len, (u8) primitive->d3Suspend);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlSuspendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->hardSuspend, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->d3Suspend, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTclasAddCfm *primitive = (CsrWifiRouterCtrlTclasAddCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTclasAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->result */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioDeinitialiseCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->result);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->result */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteRead primitive->byteRead */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteWrite primitive->byteWrite */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioFirmwareDownload primitive->firmwareDownload */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioReset primitive->reset */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioCoreDumpPrepare primitive->coreDumpPrepare */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteBlockRead primitive->byteBlockRead */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpRead16 primitive->gpRead16 */
-    bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpWrite16 primitive->gpWrite16 */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioInitialiseCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->result);
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteRead */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteWrite */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->firmwareDownload */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->reset */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->coreDumpPrepare */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteBlockRead */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpRead16 */
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpWrite16 */
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
-    primitive->byteRead = NULL;         /* Special for Function Pointers... */
-    offset += 4;
-    primitive->byteWrite = NULL;        /* Special for Function Pointers... */
-    offset += 4;
-    primitive->firmwareDownload = NULL; /* Special for Function Pointers... */
-    offset += 4;
-    primitive->reset = NULL;            /* Special for Function Pointers... */
-    offset += 4;
-    primitive->coreDumpPrepare = NULL;  /* Special for Function Pointers... */
-    offset += 4;
-    primitive->byteBlockRead = NULL;    /* Special for Function Pointers... */
-    offset += 4;
-    primitive->gpRead16 = NULL;         /* Special for Function Pointers... */
-    offset += 4;
-    primitive->gpWrite16 = NULL;        /* Special for Function Pointers... */
-    offset += 4;
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTclasDelCfm *primitive = (CsrWifiRouterCtrlTclasDelCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTclasDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrWifiRouterCtrlTrafficPacketType primitive->packetType */
-    bufferSize += 2; /* CsrWifiRouterCtrlProtocolDirection primitive->direction */
-    bufferSize += 6; /* u8 primitive->srcAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTrafficProtocolInd *primitive = (CsrWifiRouterCtrlTrafficProtocolInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->packetType);
-    CsrUint16Ser(ptr, len, (u16) primitive->direction);
-    CsrMemCpySer(ptr, len, (const void *) primitive->srcAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTrafficProtocolInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->packetType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->direction, buffer, &offset);
-    CsrMemCpyDes(primitive->srcAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 38) */
-    bufferSize += 2;  /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2;  /* u16 primitive->interfaceTag */
-    bufferSize += 4;  /* u32 primitive->stats.rxMeanRate */
-    bufferSize += 4;  /* u32 primitive->stats.rxFramesNum */
-    bufferSize += 4;  /* u32 primitive->stats.txFramesNum */
-    bufferSize += 4;  /* u32 primitive->stats.rxBytesCount */
-    bufferSize += 4;  /* u32 primitive->stats.txBytesCount */
-    bufferSize += 11; /* u8 primitive->stats.intervals[11] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlTrafficSampleInd *primitive = (CsrWifiRouterCtrlTrafficSampleInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint32Ser(ptr, len, (u32) primitive->stats.rxMeanRate);
-    CsrUint32Ser(ptr, len, (u32) primitive->stats.rxFramesNum);
-    CsrUint32Ser(ptr, len, (u32) primitive->stats.txFramesNum);
-    CsrUint32Ser(ptr, len, (u32) primitive->stats.rxBytesCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->stats.txBytesCount);
-    CsrMemCpySer(ptr, len, (const void *) primitive->stats.intervals, ((u16) (11)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlTrafficSampleInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->stats.rxMeanRate, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->stats.rxFramesNum, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->stats.txFramesNum, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->stats.rxBytesCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->stats.txBytesCount, buffer, &offset);
-    CsrMemCpyDes(primitive->stats.intervals, buffer, &offset, ((u16) (11)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 27) */
-    bufferSize += 2;                                                                                    /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2;                                                                                    /* CsrResult primitive->status */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.chipId */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.chipVersion */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.firmwareBuild */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.firmwareHip */
-    bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1;  /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.routerHip */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip);
-    CsrCharStringSer(ptr, len, primitive->versions.routerBuild);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWifiOnInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset);
-    CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWifiOnIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) voidPrimitivePointer;
-    kfree(primitive->versions.routerBuild);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWifiOnCfm *primitive = (CsrWifiRouterCtrlWifiOnCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWifiOnCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlM4ReadyToSendInd *primitive = (CsrWifiRouterCtrlM4ReadyToSendInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlM4ReadyToSendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlM4TransmittedInd *primitive = (CsrWifiRouterCtrlM4TransmittedInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlM4TransmittedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 1; /* u8 primitive->unicastPdu */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlMicFailureInd *primitive = (CsrWifiRouterCtrlMicFailureInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->unicastPdu);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlMicFailureInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->unicastPdu, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 1; /* CsrWifiRouterCtrlPeerStatus primitive->peerStatus */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlConnectedInd *primitive = (CsrWifiRouterCtrlConnectedInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->peerStatus);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlConnectedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->peerStatus, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 19) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPeerAddCfm *primitive = (CsrWifiRouterCtrlPeerAddCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPeerAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPeerDelCfm *primitive = (CsrWifiRouterCtrlPeerDelCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPeerDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlUnexpectedFrameInd *primitive = (CsrWifiRouterCtrlUnexpectedFrameInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlUnexpectedFrameInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlPeerUpdateCfm *primitive = (CsrWifiRouterCtrlPeerUpdateCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlPeerUpdateCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->commandQueueSize */
-    bufferSize += 2; /* u16 primitive->trafficQueueSize */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlCapabilitiesCfm *primitive = (CsrWifiRouterCtrlCapabilitiesCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->commandQueueSize);
-    CsrUint16Ser(ptr, len, (u16) primitive->trafficQueueSize);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlCapabilitiesCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->commandQueueSize, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->trafficQueueSize, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlBlockAckEnableCfm *primitive = (CsrWifiRouterCtrlBlockAckEnableCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlBlockAckEnableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlBlockAckDisableCfm *primitive = (CsrWifiRouterCtrlBlockAckDisableCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlBlockAckDisableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlBlockAckErrorInd *primitive = (CsrWifiRouterCtrlBlockAckErrorInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlBlockAckErrorInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 6; /* u8 primitive->staAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlStaInactiveInd *primitive = (CsrWifiRouterCtrlStaInactiveInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->staAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlStaInactiveInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->staAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2;                       /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2;                       /* u16 primitive->interfaceTag */
-    bufferSize += 2;                       /* u16 primitive->signalLength */
-    bufferSize += primitive->signalLength; /* u8 primitive->signal */
-    bufferSize += 2;                       /* u16 primitive->dataLength */
-    bufferSize += primitive->dataLength;   /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->signalLength);
-    if (primitive->signalLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset);
-    if (primitive->signalLength)
-    {
-        primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength)));
-    }
-    else
-    {
-        primitive->signal = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) voidPrimitivePointer;
-    kfree(primitive->signal);
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlModeSetCfm *primitive = (CsrWifiRouterCtrlModeSetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->mode);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlModeSetCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg)
-{
-    CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2;                     /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
-    bufferSize += 2;                     /* u16 primitive->interfaceTag */
-    bufferSize += 2;                     /* u16 primitive->dataLength */
-    bufferSize += primitive->dataLength; /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->clientData);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) voidPrimitivePointer;
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h
deleted file mode 100644 (file)
index c904838..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__
-#define CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__
-
-#include "csr_wifi_msgconv.h"
-
-#include "csr_wifi_router_ctrl_prim.h"
-
-extern void CsrWifiRouterCtrlPfree(void *ptr);
-
-extern u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg);
-#define CsrWifiRouterCtrlConfigurePowerModeReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlHipReqSizeof(void *msg);
-extern void CsrWifiRouterCtrlHipReqSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg);
-#define CsrWifiRouterCtrlMediaStatusReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg);
-extern void CsrWifiRouterCtrlMulticastAddressResSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg);
-#define CsrWifiRouterCtrlPortConfigureReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg);
-#define CsrWifiRouterCtrlQosControlReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg);
-#define CsrWifiRouterCtrlSuspendResSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg);
-extern void CsrWifiRouterCtrlTclasAddReqSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlResumeResSizeof(void *msg);
-#define CsrWifiRouterCtrlResumeResSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlRawSdioInitialiseReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiRouterCtrlRawSdioInitialiseReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiRouterCtrlRawSdioInitialiseReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiRouterCtrlRawSdioInitialiseReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg);
-extern void CsrWifiRouterCtrlTclasDelReqSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg);
-#define CsrWifiRouterCtrlTrafficClassificationReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg);
-#define CsrWifiRouterCtrlTrafficConfigReqSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlWifiOffReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiRouterCtrlWifiOffReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiRouterCtrlWifiOffReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiRouterCtrlWifiOffReqSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlWifiOffResSer CsrWifiEventCsrUint16Ser
-#define CsrWifiRouterCtrlWifiOffResDes CsrWifiEventCsrUint16Des
-#define CsrWifiRouterCtrlWifiOffResSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiRouterCtrlWifiOffResSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg);
-extern void CsrWifiRouterCtrlWifiOnReqSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg);
-extern void CsrWifiRouterCtrlWifiOnResSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg);
-#define CsrWifiRouterCtrlM4TransmitReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg);
-#define CsrWifiRouterCtrlModeSetReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg);
-#define CsrWifiRouterCtrlPeerAddReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg);
-#define CsrWifiRouterCtrlPeerDelReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg);
-#define CsrWifiRouterCtrlPeerUpdateReqSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlCapabilitiesReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiRouterCtrlCapabilitiesReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiRouterCtrlCapabilitiesReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiRouterCtrlCapabilitiesReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg);
-#define CsrWifiRouterCtrlBlockAckEnableReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg);
-#define CsrWifiRouterCtrlBlockAckDisableReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg);
-extern void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *msg);
-
-#define CsrWifiRouterCtrlWapiMulticastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiRouterCtrlWapiMulticastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiRouterCtrlWapiMulticastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiRouterCtrlWapiMulticastFilterReqSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlWapiUnicastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiRouterCtrlWapiUnicastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiRouterCtrlWapiUnicastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiRouterCtrlWapiUnicastFilterReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg);
-extern void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *msg);
-
-#define CsrWifiRouterCtrlWapiFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiRouterCtrlWapiFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiRouterCtrlWapiFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiRouterCtrlWapiFilterReqSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlHipIndSizeof(void *msg);
-extern void CsrWifiRouterCtrlHipIndSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg);
-extern void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlPortConfigureCfmSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlResumeIndSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiRouterCtrlResumeIndDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiRouterCtrlResumeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiRouterCtrlResumeIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg);
-#define CsrWifiRouterCtrlSuspendIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlTclasAddCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlTclasDelCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg);
-#define CsrWifiRouterCtrlTrafficProtocolIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg);
-#define CsrWifiRouterCtrlTrafficSampleIndSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlWifiOffIndSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiRouterCtrlWifiOffIndDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiRouterCtrlWifiOffIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiRouterCtrlWifiOffIndSerFree CsrWifiRouterCtrlPfree
-
-#define CsrWifiRouterCtrlWifiOffCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiRouterCtrlWifiOffCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiRouterCtrlWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiRouterCtrlWifiOffCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg);
-extern void CsrWifiRouterCtrlWifiOnIndSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlWifiOnCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg);
-#define CsrWifiRouterCtrlM4ReadyToSendIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg);
-#define CsrWifiRouterCtrlM4TransmittedIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg);
-#define CsrWifiRouterCtrlMicFailureIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg);
-#define CsrWifiRouterCtrlConnectedIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlPeerAddCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlPeerDelCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg);
-#define CsrWifiRouterCtrlUnexpectedFrameIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlPeerUpdateCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlCapabilitiesCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlBlockAckEnableCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlBlockAckDisableCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg);
-#define CsrWifiRouterCtrlBlockAckErrorIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg);
-#define CsrWifiRouterCtrlStaInactiveIndSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg);
-extern void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *msg);
-
-extern u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg);
-#define CsrWifiRouterCtrlModeSetCfmSerFree CsrWifiRouterCtrlPfree
-
-extern u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg);
-extern void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *msg);
-
-#endif /* CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c
deleted file mode 100644 (file)
index c4badc5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_router_prim.h"
-#include "csr_wifi_router_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiRouterFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_ROUTER_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-
-    switch (*((CsrWifiRouterPrim *) message))
-    {
-        case CSR_WIFI_ROUTER_MA_PACKET_REQ:
-        {
-            CsrWifiRouterMaPacketReq *p = (CsrWifiRouterMaPacketReq *)message;
-            kfree(p->frame);
-            p->frame = NULL;
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c
deleted file mode 100644 (file)
index 4cd1263..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2011
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_router_prim.h"
-#include "csr_wifi_router_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiRouterFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message)
-{
-       if (eventClass != CSR_WIFI_ROUTER_PRIM)
-               return;
-       if (NULL == message)
-               return;
-       switch (*((CsrWifiRouterPrim *) message)) {
-       case CSR_WIFI_ROUTER_MA_PACKET_IND:
-       {
-               CsrWifiRouterMaPacketInd *p =
-                       (CsrWifiRouterMaPacketInd *) message;
-               kfree(p->frame);
-               p->frame = NULL;
-               break;
-       }
-       default:
-               break;
-       }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_router_lib.h b/drivers/staging/csr/csr_wifi_router_lib.h
deleted file mode 100644 (file)
index b0477c4..0000000
+++ /dev/null
@@ -1,417 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_LIB_H__
-#define CSR_WIFI_ROUTER_LIB_H__
-
-#include "csr_sched.h"
-#include "csr_macro.h"
-#include "csr_msg_transport.h"
-
-#include "csr_wifi_lib.h"
-
-#include "csr_wifi_router_prim.h"
-#include "csr_wifi_router_task.h"
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiRouterFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_ROUTER upstream message. Does not
- *      free the message itself, and can only be used for upstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_ROUTER upstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiRouterFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_ROUTER downstream message. Does not
- *      free the message itself, and can only be used for downstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_ROUTER downstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- * Enum to string functions
- *----------------------------------------------------------------------------*/
-const char* CsrWifiRouterAppTypeToString(CsrWifiRouterAppType value);
-const char* CsrWifiRouterEncapsulationToString(CsrWifiRouterEncapsulation value);
-const char* CsrWifiRouterOuiToString(CsrWifiRouterOui value);
-const char* CsrWifiRouterPriorityToString(CsrWifiRouterPriority value);
-
-
-/*----------------------------------------------------------------------------*
- * CsrPrim Type toString function.
- * Converts a message type to the String name of the Message
- *----------------------------------------------------------------------------*/
-const char* CsrWifiRouterPrimTypeToString(CsrPrim msgType);
-
-/*----------------------------------------------------------------------------*
- * Lookup arrays for PrimType name Strings
- *----------------------------------------------------------------------------*/
-extern const char *CsrWifiRouterUpstreamPrimNames[CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT];
-extern const char *CsrWifiRouterDownstreamPrimNames[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketCancelReqSend
-
-  DESCRIPTION
-    This primitive is used to request cancellation of a previously send
-    CsrWifiRouterMaPacketReq.
-    The frame may already have been transmitted so there is no guarantees
-    that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
-    of the frame in question.
-    If the cancellation fails, the Router will send, if required,
-    CsrWifiRouterMaPacketCfm.
-    If the cancellation succeeds, the Router will not send
-    CsrWifiRouterMaPacketCfm.
-
-  PARAMETERS
-    queue          - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    hostTag        - The hostTag for the frame, which should be cancelled.
-    priority       - Priority of the frame, which should be cancelled
-    peerMacAddress - Destination MAC address of the frame, which should be
-                     cancelled
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->hostTag = (hostTag__); \
-    msg__->priority = (priority__); \
-    msg__->peerMacAddress = (peerMacAddress__);
-
-#define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
-    { \
-        CsrWifiRouterMaPacketCancelReq *msg__; \
-        CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
-    CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketReqSend
-
-  DESCRIPTION
-    A task sends this primitive to transmit a frame.
-
-  PARAMETERS
-    queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-    frameLength        - Length of the frame to be sent in bytes
-    frame              - Pointer to the frame to be sent
-    freeFunction       - Pointer to function to be used to free the frame
-    priority           - Priority of the frame, which should be sent
-    hostTag            - An application shall set the bits b31..b28 using one of
-                         the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
-                         be used by the requestor without any restrictions, but
-                         the hostTag shall be unique so the hostTag for
-                         CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
-                         in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
-                         (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
-                         (20 bits) ]. If the hostTag is not unique, the
-                         behaviour of the system is unpredicatable with respect
-                         to data/management frame transfer.
-    cfmRequested       - Indicates if the requestor needs a confirm for packet
-                         requests sent under this subscription. If set to TRUE,
-                         the router will send a confirm, else it will not send
-                         any confirm
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->subscriptionHandle = (subscriptionHandle__); \
-    msg__->frameLength = (frameLength__); \
-    msg__->frame = (frame__); \
-    msg__->freeFunction = (freeFunction__); \
-    msg__->priority = (priority__); \
-    msg__->hostTag = (hostTag__); \
-    msg__->cfmRequested = (cfmRequested__);
-
-#define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
-    { \
-        CsrWifiRouterMaPacketReq *msg__; \
-        CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketReqSend(src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
-    CsrWifiRouterMaPacketReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketIndSend
-
-  DESCRIPTION
-    The router sends the primitive to a subscribed task when it receives a
-    frame matching the subscription.
-
-  PARAMETERS
-    queue              - Destination Task Queue
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-    result             - Status of the operation
-    frameLength        - Length of the received frame in bytes
-    frame              - Pointer to the received frame
-    freeFunction       - Pointer to function to be used to free the frame
-    rssi               - Received signal strength indication in dBm
-    snr                - Signal to Noise Ratio
-    rate               - Transmission/Reception rate
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->subscriptionHandle = (subscriptionHandle__); \
-    msg__->result = (result__); \
-    msg__->frameLength = (frameLength__); \
-    msg__->frame = (frame__); \
-    msg__->freeFunction = (freeFunction__); \
-    msg__->rssi = (rssi__); \
-    msg__->snr = (snr__); \
-    msg__->rate = (rate__);
-
-#define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
-    { \
-        CsrWifiRouterMaPacketInd *msg__; \
-        CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketIndSend(dst__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
-    CsrWifiRouterMaPacketIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketResSend
-
-  DESCRIPTION
-    A task send this primitive to confirm the reception of the received
-    frame.
-
-  PARAMETERS
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-    result             - Status of the operation
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_RES, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->subscriptionHandle = (subscriptionHandle__); \
-    msg__->result = (result__);
-
-#define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
-    { \
-        CsrWifiRouterMaPacketRes *msg__; \
-        CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \
-    CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketCfmSend
-
-  DESCRIPTION
-    The router sends the primitive to confirm the result of the transmission
-    of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    result       - Status of the operation
-    hostTag      - The hostTrag will match the hostTag sent in the request.
-    rate         - Transmission/Reception rate
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->result = (result__); \
-    msg__->hostTag = (hostTag__); \
-    msg__->rate = (rate__);
-
-#define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
-    { \
-        CsrWifiRouterMaPacketCfm *msg__; \
-        CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \
-    CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketSubscribeReqSend
-
-  DESCRIPTION
-    A task can use this primitive to subscribe for a particular OUI/protocol
-    and transmit and receive frames matching the subscription.
-    NOTE: Multiple subscriptions for a given protocol and OUI will result in
-    the first subscription receiving the data and not the subsequent
-    subscriptions.
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    encapsulation - Specifies the encapsulation type, which will be used for the
-                    subscription
-    protocol      - Together with the OUI, specifies the protocol, which a task
-                    wants to subscribe to
-    oui           - Specifies the OUI for the protocol, which a task wants to
-                    subscribe to
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->encapsulation = (encapsulation__); \
-    msg__->protocol = (protocol__); \
-    msg__->oui = (oui__);
-
-#define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
-    { \
-        CsrWifiRouterMaPacketSubscribeReq *msg__; \
-        CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \
-    CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketSubscribeCfmSend
-
-  DESCRIPTION
-    The router sends this primitive to confirm the result of the
-    subscription.
-
-  PARAMETERS
-    queue              - Destination Task Queue
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - Handle to the subscription
-                         This handle must be used in all subsequent requests
-    status             - Status of the operation
-    allocOffset        - Size of the offset for the frames of the subscription
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->subscriptionHandle = (subscriptionHandle__); \
-    msg__->status = (status__); \
-    msg__->allocOffset = (allocOffset__);
-
-#define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
-    { \
-        CsrWifiRouterMaPacketSubscribeCfm *msg__; \
-        CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
-    CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketUnsubscribeReqSend
-
-  DESCRIPTION
-    A task sends this primitive to unsubscribe a subscription
-
-  PARAMETERS
-    queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->subscriptionHandle = (subscriptionHandle__);
-
-#define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \
-    { \
-        CsrWifiRouterMaPacketUnsubscribeReq *msg__; \
-        CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \
-        CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \
-    CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketUnsubscribeCfmSend
-
-  DESCRIPTION
-    The router sends this primitive to confirm the result of the
-    unsubscription.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Status of the operation
-
-*******************************************************************************/
-#define CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \
-        CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
-    }
-
-#define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__)
-
-#endif /* CSR_WIFI_ROUTER_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_prim.h b/drivers/staging/csr/csr_wifi_router_prim.h
deleted file mode 100644 (file)
index c52344b..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_PRIM_H__
-#define CSR_WIFI_ROUTER_PRIM_H__
-
-#include <linux/types.h>
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-#include "csr_wifi_common.h"
-#include "csr_result.h"
-#include "csr_wifi_fsm_event.h"
-
-#define CSR_WIFI_ROUTER_PRIM                                            (0x0400)
-
-typedef CsrPrim CsrWifiRouterPrim;
-
-typedef void (*CsrWifiRouterFrameFreeFunction)(void *frame);
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterAppType
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_APP_TYPE_SME   -
-    CSR_WIFI_ROUTER_APP_TYPE_PAL   -
-    CSR_WIFI_ROUTER_APP_TYPE_NME   -
-    CSR_WIFI_ROUTER_APP_TYPE_OTHER -
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterAppType;
-#define CSR_WIFI_ROUTER_APP_TYPE_SME     ((CsrWifiRouterAppType) 0x0)
-#define CSR_WIFI_ROUTER_APP_TYPE_PAL     ((CsrWifiRouterAppType) 0x1)
-#define CSR_WIFI_ROUTER_APP_TYPE_NME     ((CsrWifiRouterAppType) 0x2)
-#define CSR_WIFI_ROUTER_APP_TYPE_OTHER   ((CsrWifiRouterAppType) 0x3)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterEncapsulation
-
-  DESCRIPTION
-    Indicates the type of encapsulation used for the subscription
-
- VALUES
-    CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET
-                   - Ethernet encapsulation
-    CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP
-                   - LLC/SNAP encapsulation
-
-*******************************************************************************/
-typedef u8 CsrWifiRouterEncapsulation;
-#define CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET   ((CsrWifiRouterEncapsulation) 0x00)
-#define CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP   ((CsrWifiRouterEncapsulation) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterOui
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_ROUTER_OUI_RFC_1042 -
-    CSR_WIFI_ROUTER_OUI_BT       -
-
-*******************************************************************************/
-typedef u32 CsrWifiRouterOui;
-#define CSR_WIFI_ROUTER_OUI_RFC_1042   ((CsrWifiRouterOui) 0x000000)
-#define CSR_WIFI_ROUTER_OUI_BT         ((CsrWifiRouterOui) 0x001958)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterPriority
-
-  DESCRIPTION
-    As defined in the IEEE 802.11 standards
-
- VALUES
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP0
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP1
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP2
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP3
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP4
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP5
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP6
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_QOS_UP7
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_CONTENTION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT
-                   - See IEEE 802.11 Standard
-
-*******************************************************************************/
-typedef u16 CsrWifiRouterPriority;
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP0      ((CsrWifiRouterPriority) 0x0000)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP1      ((CsrWifiRouterPriority) 0x0001)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP2      ((CsrWifiRouterPriority) 0x0002)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP3      ((CsrWifiRouterPriority) 0x0003)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP4      ((CsrWifiRouterPriority) 0x0004)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP5      ((CsrWifiRouterPriority) 0x0005)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP6      ((CsrWifiRouterPriority) 0x0006)
-#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP7      ((CsrWifiRouterPriority) 0x0007)
-#define CSR_WIFI_ROUTER_PRIORITY_CONTENTION   ((CsrWifiRouterPriority) 0x8000)
-#define CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT   ((CsrWifiRouterPriority) 0x8010)
-
-
-/* Downstream */
-#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST            (0x0000)
-
-#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ           ((CsrWifiRouterPrim) (0x0000 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ         ((CsrWifiRouterPrim) (0x0001 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_REQ                     ((CsrWifiRouterPrim) (0x0002 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_RES                     ((CsrWifiRouterPrim) (0x0003 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ              ((CsrWifiRouterPrim) (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
-
-
-#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST           (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)
-
-/* Upstream */
-#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST              (0x0000 + CSR_PRIM_UPSTREAM)
-
-#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM           ((CsrWifiRouterPrim)(0x0000 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM         ((CsrWifiRouterPrim)(0x0001 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_CFM                     ((CsrWifiRouterPrim)(0x0002 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_ROUTER_MA_PACKET_IND                     ((CsrWifiRouterPrim)(0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
-
-#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST             (0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)
-
-#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT             (CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)
-#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT               (CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST   + 1 - CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketSubscribeReq
-
-  DESCRIPTION
-    A task can use this primitive to subscribe for a particular OUI/protocol
-    and transmit and receive frames matching the subscription.
-    NOTE: Multiple subscriptions for a given protocol and OUI will result in
-    the first subscription receiving the data and not the subsequent
-    subscriptions.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    encapsulation - Specifies the encapsulation type, which will be used for the
-                    subscription
-    protocol      - Together with the OUI, specifies the protocol, which a task
-                    wants to subscribe to
-    oui           - Specifies the OUI for the protocol, which a task wants to
-                    subscribe to
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent            common;
-    u16                  interfaceTag;
-    CsrWifiRouterEncapsulation encapsulation;
-    u16                  protocol;
-    u32                  oui;
-} CsrWifiRouterMaPacketSubscribeReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketUnsubscribeReq
-
-  DESCRIPTION
-    A task sends this primitive to unsubscribe a subscription
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u8        subscriptionHandle;
-} CsrWifiRouterMaPacketUnsubscribeReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketReq
-
-  DESCRIPTION
-    A task sends this primitive to transmit a frame.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-    frameLength        - Length of the frame to be sent in bytes
-    frame              - Pointer to the frame to be sent
-    freeFunction       - Pointer to function to be used to free the frame
-    priority           - Priority of the frame, which should be sent
-    hostTag            - An application shall set the bits b31..b28 using one of
-                         the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
-                         be used by the requestor without any restrictions, but
-                         the hostTag shall be unique so the hostTag for
-                         CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
-                         in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
-                         (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
-                         (20 bits) ]. If the hostTag is not unique, the
-                         behaviour of the system is unpredicatable with respect
-                         to data/management frame transfer.
-    cfmRequested       - Indicates if the requestor needs a confirm for packet
-                         requests sent under this subscription. If set to TRUE,
-                         the router will send a confirm, else it will not send
-                         any confirm
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    u8                       subscriptionHandle;
-    u16                      frameLength;
-    u8                      *frame;
-    CsrWifiRouterFrameFreeFunction freeFunction;
-    CsrWifiRouterPriority          priority;
-    u32                      hostTag;
-    u8                        cfmRequested;
-} CsrWifiRouterMaPacketReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketRes
-
-  DESCRIPTION
-    A task send this primitive to confirm the reception of the received
-    frame.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-    result             - Status of the operation
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u8        subscriptionHandle;
-    CsrResult       result;
-} CsrWifiRouterMaPacketRes;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketCancelReq
-
-  DESCRIPTION
-    This primitive is used to request cancellation of a previously send
-    CsrWifiRouterMaPacketReq.
-    The frame may already have been transmitted so there is no guarantees
-    that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
-    of the frame in question.
-    If the cancellation fails, the Router will send, if required,
-    CsrWifiRouterMaPacketCfm.
-    If the cancellation succeeds, the Router will not send
-    CsrWifiRouterMaPacketCfm.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    hostTag        - The hostTag for the frame, which should be cancelled.
-    priority       - Priority of the frame, which should be cancelled
-    peerMacAddress - Destination MAC address of the frame, which should be
-                     cancelled
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    u16             interfaceTag;
-    u32             hostTag;
-    CsrWifiRouterPriority priority;
-    CsrWifiMacAddress     peerMacAddress;
-} CsrWifiRouterMaPacketCancelReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketSubscribeCfm
-
-  DESCRIPTION
-    The router sends this primitive to confirm the result of the
-    subscription.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - Handle to the subscription
-                         This handle must be used in all subsequent requests
-    status             - Status of the operation
-    allocOffset        - Size of the offset for the frames of the subscription
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    u8        subscriptionHandle;
-    CsrResult       status;
-    u16       allocOffset;
-} CsrWifiRouterMaPacketSubscribeCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketUnsubscribeCfm
-
-  DESCRIPTION
-    The router sends this primitive to confirm the result of the
-    unsubscription.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Status of the operation
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiRouterMaPacketUnsubscribeCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketCfm
-
-  DESCRIPTION
-    The router sends the primitive to confirm the result of the transmission
-    of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    result       - Status of the operation
-    hostTag      - The hostTrag will match the hostTag sent in the request.
-    rate         - Transmission/Reception rate
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       result;
-    u32       hostTag;
-    u16       rate;
-} CsrWifiRouterMaPacketCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiRouterMaPacketInd
-
-  DESCRIPTION
-    The router sends the primitive to a subscribed task when it receives a
-    frame matching the subscription.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    interfaceTag       - Interface Identifier; unique identifier of an interface
-    subscriptionHandle - The handle of the subscription
-    result             - Status of the operation
-    frameLength        - Length of the received frame in bytes
-    frame              - Pointer to the received frame
-    freeFunction       - Pointer to function to be used to free the frame
-    rssi               - Received signal strength indication in dBm
-    snr                - Signal to Noise Ratio
-    rate               - Transmission/Reception rate
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    u16                      interfaceTag;
-    u8                       subscriptionHandle;
-    CsrResult                      result;
-    u16                      frameLength;
-    u8                      *frame;
-    CsrWifiRouterFrameFreeFunction freeFunction;
-    s16                       rssi;
-    s16                       snr;
-    u16                      rate;
-} CsrWifiRouterMaPacketInd;
-
-#endif /* CSR_WIFI_ROUTER_PRIM_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_router_sef.c b/drivers/staging/csr/csr_wifi_router_sef.c
deleted file mode 100644 (file)
index 45a10fb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*****************************************************************************
-
-  (c) Cambridge Silicon Radio Limited 2010
-  Confidential information of CSR
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-#include "csr_wifi_router_sef.h"
-
-const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT] =
-{
-    /* 0x0000 */ CsrWifiRouterMaPacketSubscribeReqHandler,
-    /* 0x0001 */ CsrWifiRouterMaPacketUnsubscribeReqHandler,
-    /* 0x0002 */ CsrWifiRouterMaPacketReqHandler,
-    /* 0x0003 */ CsrWifiRouterMaPacketResHandler,
-    /* 0x0004 */ CsrWifiRouterMaPacketCancelReqHandler,
-};
diff --git a/drivers/staging/csr/csr_wifi_router_sef.h b/drivers/staging/csr/csr_wifi_router_sef.h
deleted file mode 100644 (file)
index 86692c7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*****************************************************************************
-
-  (c) Cambridge Silicon Radio Limited 2010
-  Confidential information of CSR
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__
-#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__
-
-#include "csr_wifi_router_prim.h"
-
-    typedef void (*CsrWifiRouterStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
-
-    extern const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
-
-    extern void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-    extern void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
-
-#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_serialize.c b/drivers/staging/csr/csr_wifi_router_serialize.c
deleted file mode 100644 (file)
index 4eccf5d..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_msgconv.h"
-#include "csr_wifi_router_prim.h"
-#include "csr_wifi_router_serialize.h"
-
-void CsrWifiRouterPfree(void *ptr)
-{
-    kfree(ptr);
-}
-
-
-size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiRouterEncapsulation primitive->encapsulation */
-    bufferSize += 2; /* u16 primitive->protocol */
-    bufferSize += 4; /* u32 primitive->oui */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketSubscribeReq *primitive = (CsrWifiRouterMaPacketSubscribeReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->encapsulation);
-    CsrUint16Ser(ptr, len, (u16) primitive->protocol);
-    CsrUint32Ser(ptr, len, (u32) primitive->oui);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketSubscribeReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->encapsulation, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->protocol, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->oui, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterMaPacketReqSizeof(void *msg)
-{
-    CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 20) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 1;                      /* u8 primitive->subscriptionHandle */
-    bufferSize += 2;                      /* u16 primitive->frameLength */
-    bufferSize += primitive->frameLength; /* u8 primitive->frame */
-    bufferSize += 4;                      /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */
-    bufferSize += 2;                      /* CsrWifiRouterPriority primitive->priority */
-    bufferSize += 4;                      /* u32 primitive->hostTag */
-    bufferSize += 1;                      /* u8 primitive->cfmRequested */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
-    CsrUint16Ser(ptr, len, (u16) primitive->frameLength);
-    if (primitive->frameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength)));
-    }
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */
-    CsrUint16Ser(ptr, len, (u16) primitive->priority);
-    CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->cfmRequested);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset);
-    if (primitive->frameLength)
-    {
-        primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength)));
-    }
-    else
-    {
-        primitive->frame = NULL;
-    }
-    primitive->freeFunction = NULL; /* Special for Function Pointers... */
-    offset += 4;
-    CsrUint16Des((u16 *) &primitive->priority, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->cfmRequested, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiRouterMaPacketReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) voidPrimitivePointer;
-    kfree(primitive->frame);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiRouterMaPacketResSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* u8 primitive->subscriptionHandle */
-    bufferSize += 2; /* CsrResult primitive->result */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketRes *primitive = (CsrWifiRouterMaPacketRes *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
-    CsrUint16Ser(ptr, len, (u16) primitive->result);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketRes *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 4; /* u32 primitive->hostTag */
-    bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketCancelReq *primitive = (CsrWifiRouterMaPacketCancelReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->priority);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketCancelReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->priority, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* u8 primitive->subscriptionHandle */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 2; /* u16 primitive->allocOffset */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketSubscribeCfm *primitive = (CsrWifiRouterMaPacketSubscribeCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->allocOffset);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketSubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->allocOffset, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketUnsubscribeCfm *primitive = (CsrWifiRouterMaPacketUnsubscribeCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketUnsubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterMaPacketCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->result */
-    bufferSize += 4; /* u32 primitive->hostTag */
-    bufferSize += 2; /* u16 primitive->rate */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketCfm *primitive = (CsrWifiRouterMaPacketCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->result);
-    CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->rate);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->rate, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiRouterMaPacketIndSizeof(void *msg)
-{
-    CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 1;                      /* u8 primitive->subscriptionHandle */
-    bufferSize += 2;                      /* CsrResult primitive->result */
-    bufferSize += 2;                      /* u16 primitive->frameLength */
-    bufferSize += primitive->frameLength; /* u8 primitive->frame */
-    bufferSize += 4;                      /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */
-    bufferSize += 2;                      /* s16 primitive->rssi */
-    bufferSize += 2;                      /* s16 primitive->snr */
-    bufferSize += 2;                      /* u16 primitive->rate */
-    return bufferSize;
-}
-
-
-u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
-    CsrUint16Ser(ptr, len, (u16) primitive->result);
-    CsrUint16Ser(ptr, len, (u16) primitive->frameLength);
-    if (primitive->frameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength)));
-    }
-    CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */
-    CsrUint16Ser(ptr, len, (u16) primitive->rssi);
-    CsrUint16Ser(ptr, len, (u16) primitive->snr);
-    CsrUint16Ser(ptr, len, (u16) primitive->rate);
-    return(ptr);
-}
-
-
-void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiRouterMaPacketInd *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset);
-    if (primitive->frameLength)
-    {
-        primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength)));
-    }
-    else
-    {
-        primitive->frame = NULL;
-    }
-    primitive->freeFunction = NULL; /* Special for Function Pointers... */
-    offset += 4;
-    CsrUint16Des((u16 *) &primitive->rssi, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->snr, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->rate, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiRouterMaPacketIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) voidPrimitivePointer;
-    kfree(primitive->frame);
-    kfree(primitive);
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_router_serialize.h b/drivers/staging/csr/csr_wifi_router_serialize.h
deleted file mode 100644 (file)
index 94ccdac..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_SERIALIZE_H__
-#define CSR_WIFI_ROUTER_SERIALIZE_H__
-
-#include "csr_wifi_msgconv.h"
-#include "csr_wifi_router_prim.h"
-
-extern void CsrWifiRouterPfree(void *ptr);
-
-extern u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg);
-#define CsrWifiRouterMaPacketSubscribeReqSerFree CsrWifiRouterPfree
-
-#define CsrWifiRouterMaPacketUnsubscribeReqSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiRouterMaPacketUnsubscribeReqDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiRouterMaPacketUnsubscribeReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiRouterMaPacketUnsubscribeReqSerFree CsrWifiRouterPfree
-
-extern u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketReqSizeof(void *msg);
-extern void CsrWifiRouterMaPacketReqSerFree(void *msg);
-
-extern u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketResSizeof(void *msg);
-#define CsrWifiRouterMaPacketResSerFree CsrWifiRouterPfree
-
-extern u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg);
-#define CsrWifiRouterMaPacketCancelReqSerFree CsrWifiRouterPfree
-
-extern u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg);
-#define CsrWifiRouterMaPacketSubscribeCfmSerFree CsrWifiRouterPfree
-
-extern u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg);
-#define CsrWifiRouterMaPacketUnsubscribeCfmSerFree CsrWifiRouterPfree
-
-extern u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketCfmSizeof(void *msg);
-#define CsrWifiRouterMaPacketCfmSerFree CsrWifiRouterPfree
-
-extern u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg);
-extern void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiRouterMaPacketIndSizeof(void *msg);
-extern void CsrWifiRouterMaPacketIndSerFree(void *msg);
-
-#endif /* CSR_WIFI_ROUTER_SERIALIZE_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_router_task.h b/drivers/staging/csr/csr_wifi_router_task.h
deleted file mode 100644 (file)
index 9ba892f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_ROUTER_TASK_H__
-#define CSR_WIFI_ROUTER_TASK_H__
-
-#include "csr_sched.h"
-
-#define CSR_WIFI_ROUTER_LOG_ID 0x1201FFFF
-extern CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE;
-void CsrWifiRouterInit(void **gash);
-void CsrWifiRouterDeinit(void **gash);
-void CsrWifiRouterHandler(void **gash);
-
-#endif /* CSR_WIFI_ROUTER_TASK_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_router_transport.c b/drivers/staging/csr/csr_wifi_router_transport.c
deleted file mode 100644 (file)
index e905ead..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/** @file router_transport.c
- *
- *
- * Copyright (C) Cambridge Silicon Radio Ltd 2006-2010. All rights reserved.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- ****************************************************************************/
-
-#include "unifi_priv.h"
-
-#include "csr_sched.h"
-#include "csr_msgconv.h"
-
-#include "sme_userspace.h"
-
-#include "csr_wifi_hostio_prim.h"
-#include "csr_wifi_router_lib.h"
-#include "csr_wifi_router_sef.h"
-#include "csr_wifi_router_converter_init.h"
-#include "csr_wifi_router_ctrl_lib.h"
-#include "csr_wifi_router_ctrl_sef.h"
-#include "csr_wifi_router_ctrl_converter_init.h"
-#include "csr_wifi_sme_prim.h"
-#include "csr_wifi_sme_sef.h"
-#include "csr_wifi_sme_converter_init.h"
-#ifdef CSR_SUPPORT_WEXT
-#ifdef CSR_SUPPORT_WEXT_AP
-#include "csr_wifi_nme_ap_prim.h"
-#include "csr_wifi_nme_ap_sef.h"
-#include "csr_wifi_nme_ap_converter_init.h"
-#endif
-#endif
-
-static unifi_priv_t *drvpriv = NULL;
-void CsrWifiRouterTransportInit(unifi_priv_t *priv)
-{
-    unifi_trace(priv, UDBG1, "CsrWifiRouterTransportInit: \n");
-
-    drvpriv = priv;
-    (void)CsrMsgConvInit();
-    CsrWifiRouterConverterInit();
-    CsrWifiRouterCtrlConverterInit();
-    CsrWifiSmeConverterInit();
-#ifdef CSR_SUPPORT_WEXT
-#ifdef CSR_SUPPORT_WEXT_AP
-    CsrWifiNmeApConverterInit();
-#endif
-#endif
-}
-
-void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8* buffer, size_t bufferLength)
-{
-    CsrMsgConvMsgEntry* msgEntry;
-    u16 primType;
-    CsrSchedQid src;
-    CsrSchedQid dest;
-    u16 msgType;
-    size_t offset = 0;
-    CsrWifiFsmEvent* msg;
-
-    /* Decode the prim and message type */
-    CsrUint16Des(&primType, buffer, &offset);
-    CsrUint16Des(&src, buffer, &offset);
-    CsrUint16Des(&dest, buffer, &offset);
-    CsrUint16Des(&msgType, buffer, &offset);
-    offset -= 2; /* Adjust as the Deserialise Function will read this as well */
-
-    unifi_trace(priv, UDBG4, "CsrWifiRouterTransportRecv: primType=0x%.4X, msgType=0x%.4X, bufferLength=%d\n",
-                primType, msgType, bufferLength);
-
-    /* Special handling for HOSTIO messages.... */
-    if (primType == CSR_WIFI_HOSTIO_PRIM)
-    {
-        CsrWifiRouterCtrlHipReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, CSR_WIFI_ROUTER_CTRL_PRIM, dest, src, NULL}, 0, NULL, 0, NULL, 0, NULL};
-
-        req.mlmeCommandLength = bufferLength;
-        req.mlmeCommand = buffer;
-
-        offset += 8;/* Skip the id, src, dest and slot number */
-        CsrUint16Des(&req.dataRef1Length, buffer, &offset);
-        offset += 2; /* Skip the slot number */
-        CsrUint16Des(&req.dataRef2Length, buffer, &offset);
-
-        if (req.dataRef1Length)
-        {
-            u16 dr1Offset = (bufferLength - req.dataRef2Length) - req.dataRef1Length;
-            req.dataRef1 = &buffer[dr1Offset];
-        }
-
-        if (req.dataRef2Length)
-        {
-            u16 dr2Offset = bufferLength - req.dataRef2Length;
-            req.dataRef2 = &buffer[dr2Offset];
-        }
-
-        /* Copy the hip data but strip off the prim type */
-        req.mlmeCommandLength -= (req.dataRef1Length + req.dataRef2Length + 6);
-        req.mlmeCommand = &buffer[6];
-
-        CsrWifiRouterCtrlHipReqHandler(priv, &req.common);
-        return;
-    }
-
-    msgEntry = CsrMsgConvFindEntry(primType, msgType);
-    if (!msgEntry)
-    {
-        unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n",
-                    primType, msgType);
-        dump(buffer, bufferLength);
-        return;
-    }
-
-    msg = (CsrWifiFsmEvent*)(msgEntry->deserFunc)(&buffer[offset], bufferLength - offset);
-
-    msg->primtype = primType;
-    msg->type = msgType;
-    msg->source = src;
-    msg->destination = dest;
-
-    switch(primType)
-    {
-    case CSR_WIFI_ROUTER_CTRL_PRIM:
-        CsrWifiRouterCtrlDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST](priv, msg);
-        CsrWifiRouterCtrlFreeDownstreamMessageContents(CSR_WIFI_ROUTER_CTRL_PRIM, msg);
-        break;
-    case CSR_WIFI_ROUTER_PRIM:
-        CsrWifiRouterDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST](priv, msg);
-        CsrWifiRouterFreeDownstreamMessageContents(CSR_WIFI_ROUTER_PRIM, msg);
-        break;
-        case CSR_WIFI_SME_PRIM:
-            CsrWifiSmeUpstreamStateHandlers[msg->type - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST](priv, msg);
-            CsrWifiSmeFreeUpstreamMessageContents(CSR_WIFI_SME_PRIM, msg);
-            break;
-#ifdef CSR_SUPPORT_WEXT
-#ifdef CSR_SUPPORT_WEXT_AP
-        case CSR_WIFI_NME_AP_PRIM:
-            CsrWifiNmeApUpstreamStateHandlers(priv, msg);
-            CsrWifiNmeApFreeUpstreamMessageContents(CSR_WIFI_NME_AP_PRIM, msg);
-            break;
-#endif
-#endif
-        default:
-            unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend unhandled prim type 0x%.4X\n", primType);
-            break;
-    }
-    kfree(msg);
-}
-
-static void CsrWifiRouterTransportSerialiseAndSend(u16 primType, void* msg)
-{
-    CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)msg;
-    CsrMsgConvMsgEntry* msgEntry;
-    size_t msgSize;
-    size_t encodeBufferLen = 0;
-    size_t offset = 0;
-    u8* encodeBuffer;
-
-    unifi_trace(drvpriv, UDBG4, "CsrWifiRouterTransportSerialiseAndSend: primType=0x%.4X, msgType=0x%.4X\n",
-                primType, evt->type);
-
-    msgEntry = CsrMsgConvFindEntry(primType, evt->type);
-    if (!msgEntry)
-    {
-        unifi_error(drvpriv, "CsrWifiRouterTransportSerialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n",
-                    primType, evt->type);
-        return;
-    }
-
-    msgSize = 6 + (msgEntry->sizeofFunc)((void*)msg);
-
-    encodeBuffer = kmalloc(msgSize, GFP_KERNEL);
-
-    /* Encode PrimType */
-    CsrUint16Ser(encodeBuffer, &encodeBufferLen, primType);
-    CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->source);
-    CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->destination);
-
-    (void)(msgEntry->serFunc)(&encodeBuffer[encodeBufferLen], &offset, msg);
-    encodeBufferLen += offset;
-
-    uf_sme_queue_message(drvpriv, encodeBuffer, encodeBufferLen);
-
-    /* Do not use msgEntry->freeFunc because the memory is owned by the driver */
-    kfree(msg);
-}
-
-#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
-void CsrSchedMessagePutStringLog(CsrSchedQid q, u16 mi, void *mv, u32 line, char *file)
-#else
-void CsrSchedMessagePut(CsrSchedQid q, u16 mi, void *mv)
-#endif
-{
-    CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)mv;
-    evt->destination = q;
-    CsrWifiRouterTransportSerialiseAndSend(mi, mv);
-}
-
diff --git a/drivers/staging/csr/csr_wifi_serialize_primitive_types.c b/drivers/staging/csr/csr_wifi_serialize_primitive_types.c
deleted file mode 100644 (file)
index dd93d00..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include "csr_macro.h"
-#include "csr_msgconv.h"
-#include "csr_wifi_msgconv.h"
-#include "csr_wifi_lib.h"
-
-void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset)
-{
-    u32 val;
-
-    val = ((buffer[(*offset) + 2] << 16) |
-           (buffer[(*offset) + 1] << 8) |
-           (buffer[(*offset)]));
-
-    *offset += 3;
-    *v = val;
-}
-
-
-/* Big endian :e.g WSC, TCLAS */
-void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset)
-{
-    u16 val;
-
-    val = (buffer[(*offset)] << 8) | (buffer[(*offset) + 1]);
-    *offset += 2;
-
-    *v = val;
-}
-
-
-void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
-{
-    u32 val;
-
-    val = ((buffer[(*offset)] << 16) |
-           (buffer[(*offset) + 1] << 8) |
-           (buffer[(*offset) + 2]));
-
-    *offset += 3;
-    *v = val;
-}
-
-
-void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
-{
-    u32 val;
-
-    val = ((buffer[(*offset)] << 24) |
-           (buffer[(*offset) + 1] << 16) |
-           (buffer[(*offset) + 2] << 8) |
-           (buffer[(*offset) + 3]));
-
-    *offset += 4;
-    *v = val;
-}
-
-
-void CsrUint24Ser(u8 *ptr, size_t *len, u32 v)
-{
-    ptr[(*len) + 2] = (u8)((v & 0x00ff0000) >> 16);
-    ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
-    ptr[(*len)]     = (u8)((v & 0x000000ff));
-
-    *len += 3;
-}
-
-
-/* Big endian :e.g WSC, TCLAS */
-void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v)
-{
-    ptr[(*len)] = (u8)((v & 0xff00) >> 8);
-    ptr[(*len) + 1] = (u8)((v & 0x00ff));
-
-    *len += 2;
-}
-
-
-void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v)
-{
-    ptr[(*len)] = (u8)((v & 0xff000000) >> 24);
-    ptr[(*len) + 1] = (u8)((v & 0x00ff0000) >> 16);
-    ptr[(*len) + 2] = (u8)((v & 0x0000ff00) >> 8);
-    ptr[(*len) + 3] = (u8)((v & 0x000000ff));
-
-    *len += 4;
-}
-
-
-void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v)
-{
-    ptr[(*len)] = (u8)((v & 0x00ff0000) >> 16);
-    ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
-    ptr[(*len) + 2] = (u8)((v & 0x000000ff));
-
-    *len += 3;
-}
-
-
-size_t CsrWifiEventSizeof(void *msg)
-{
-    return 2;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventSizeof);
-
-u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiFsmEvent *primitive = (CsrWifiFsmEvent *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->type);
-    return(ptr);
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventSer);
-
-void* CsrWifiEventDes(u8 *buffer, size_t length)
-{
-    CsrWifiFsmEvent *primitive = kmalloc(sizeof(CsrWifiFsmEvent), GFP_KERNEL);
-    size_t offset = 0;
-    CsrUint16Des(&primitive->type, buffer, &offset);
-
-    return primitive;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventDes);
-
-size_t CsrWifiEventCsrUint8Sizeof(void *msg)
-{
-    return 3;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Sizeof);
-
-u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiEventCsrUint8 *primitive = (CsrWifiEventCsrUint8 *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, primitive->value);
-    return(ptr);
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Ser);
-
-
-void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length)
-{
-    CsrWifiEventCsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint8), GFP_KERNEL);
-
-    size_t offset = 0;
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des(&primitive->value, buffer, &offset);
-
-    return primitive;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Des);
-
-
-size_t CsrWifiEventCsrUint16Sizeof(void *msg)
-{
-    return 4;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Sizeof);
-
-
-u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiEventCsrUint16 *primitive = (CsrWifiEventCsrUint16 *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, primitive->value);
-    return(ptr);
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Ser);
-
-void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length)
-{
-    CsrWifiEventCsrUint16 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16), GFP_KERNEL);
-
-    size_t offset = 0;
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des(&primitive->value, buffer, &offset);
-
-    return primitive;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Des);
-
-
-size_t CsrWifiEventCsrUint32Sizeof(void *msg)
-{
-    return 6;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Sizeof);
-
-u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiEventCsrUint32 *primitive = (CsrWifiEventCsrUint32 *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint32Ser(ptr, len, primitive->value);
-    return(ptr);
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Ser);
-
-
-void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length)
-{
-    CsrWifiEventCsrUint32 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint32), GFP_KERNEL);
-
-    size_t offset = 0;
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint32Des(&primitive->value, buffer, &offset);
-
-    return primitive;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Des);
-
-size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg)
-{
-    return 5;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Sizeof);
-
-u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiEventCsrUint16CsrUint8 *primitive = (CsrWifiEventCsrUint16CsrUint8 *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, primitive->value16);
-    CsrUint8Ser(ptr, len, primitive->value8);
-    return(ptr);
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Ser);
-
-
-void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length)
-{
-    CsrWifiEventCsrUint16CsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16CsrUint8), GFP_KERNEL);
-
-    size_t offset = 0;
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des(&primitive->value16, buffer, &offset);
-    CsrUint8Des(&primitive->value8, buffer, &offset);
-
-    return primitive;
-}
-EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Des);
-
-
diff --git a/drivers/staging/csr/csr_wifi_sme_ap_lib.h b/drivers/staging/csr/csr_wifi_sme_ap_lib.h
deleted file mode 100644 (file)
index 48ea914..0000000
+++ /dev/null
@@ -1,774 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_AP_LIB_H__
-#define CSR_WIFI_SME_AP_LIB_H__
-
-#include "csr_sched.h"
-#include "csr_macro.h"
-#include "csr_msg_transport.h"
-
-#include "csr_wifi_lib.h"
-
-#include "csr_wifi_sme_ap_prim.h"
-#include "csr_wifi_sme_task.h"
-
-#ifndef CSR_WIFI_AP_ENABLE
-#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_lib.h
-#endif
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiSmeApFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_SME_AP upstream message. Does not
- *      free the message itself, and can only be used for upstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_SME_AP upstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiSmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiSmeApFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_SME_AP downstream message. Does not
- *      free the message itself, and can only be used for downstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_SME_AP downstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiSmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- * Enum to string functions
- *----------------------------------------------------------------------------*/
-const char* CsrWifiSmeApAccessTypeToString(CsrWifiSmeApAccessType value);
-const char* CsrWifiSmeApAuthSupportToString(CsrWifiSmeApAuthSupport value);
-const char* CsrWifiSmeApAuthTypeToString(CsrWifiSmeApAuthType value);
-const char* CsrWifiSmeApDirectionToString(CsrWifiSmeApDirection value);
-const char* CsrWifiSmeApPhySupportToString(CsrWifiSmeApPhySupport value);
-const char* CsrWifiSmeApTypeToString(CsrWifiSmeApType value);
-
-
-/*----------------------------------------------------------------------------*
- * CsrPrim Type toString function.
- * Converts a message type to the String name of the Message
- *----------------------------------------------------------------------------*/
-const char* CsrWifiSmeApPrimTypeToString(CsrPrim msgType);
-
-/*----------------------------------------------------------------------------*
- * Lookup arrays for PrimType name Strings
- *----------------------------------------------------------------------------*/
-extern const char *CsrWifiSmeApUpstreamPrimNames[CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT];
-extern const char *CsrWifiSmeApDownstreamPrimNames[CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT];
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApActiveBaGetReqSend
-
-  DESCRIPTION
-    This primitive used to retrieve information related to the active block
-    ack sessions
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-
-*******************************************************************************/
-#define CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeApActiveBaGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeApActiveBaGetReq *msg__; \
-        CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApActiveBaGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeApActiveBaGetReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApActiveBaGetCfmSend
-
-  DESCRIPTION
-    This primitive carries the information related to the active ba sessions
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    interfaceTag     -
-    status           - Reports the result of the request
-    activeBaCount    - Number of active block ack session
-    activeBaSessions - Points to a buffer containing an array of
-                       CsrWifiSmeApBaSession structures.
-
-*******************************************************************************/
-#define CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->activeBaCount = (activeBaCount__); \
-    msg__->activeBaSessions = (activeBaSessions__);
-
-#define CsrWifiSmeApActiveBaGetCfmSendTo(dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
-    { \
-        CsrWifiSmeApActiveBaGetCfm *msg__; \
-        CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApActiveBaGetCfmSend(dst__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
-    CsrWifiSmeApActiveBaGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, activeBaCount__, activeBaSessions__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBaDeleteReqSend
-
-  DESCRIPTION
-    This primitive is used to delete an active block ack session
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-    reason       -
-    baSession    - BA session to be deleted
-
-*******************************************************************************/
-#define CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->reason = (reason__); \
-    msg__->baSession = (baSession__);
-
-#define CsrWifiSmeApBaDeleteReqSendTo(dst__, src__, interfaceTag__, reason__, baSession__) \
-    { \
-        CsrWifiSmeApBaDeleteReq *msg__; \
-        CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApBaDeleteReqSend(src__, interfaceTag__, reason__, baSession__) \
-    CsrWifiSmeApBaDeleteReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, reason__, baSession__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBaDeleteCfmSend
-
-  DESCRIPTION
-    This primitive confirms the BA is deleted
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag -
-    status       - Reports the result of the request
-    baSession    - deleted BA session
-
-*******************************************************************************/
-#define CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->baSession = (baSession__);
-
-#define CsrWifiSmeApBaDeleteCfmSendTo(dst__, src__, interfaceTag__, status__, baSession__) \
-    { \
-        CsrWifiSmeApBaDeleteCfm *msg__; \
-        CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApBaDeleteCfmSend(dst__, interfaceTag__, status__, baSession__) \
-    CsrWifiSmeApBaDeleteCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, baSession__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStartReqSend
-
-  DESCRIPTION
-    This primitive requests the SME to start AP or GO functionality
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag    -
-    initialPresence - Set to 0, if Not in a group fomration phase, set to 1 ,
-                      during group formation phase
-    apType          - apType : Legacy AP or P2PGO
-    cloakSsid       - cloakSsid flag.
-    ssid            - ssid.
-    ifIndex         - Radio Interface
-    channel         - channel.
-    maxConnections  - Maximum Stations + P2PClients allowed
-    apCredentials   - AP security credeitals used to advertise in beacon /probe
-                      response
-    smeApConfig     - AP configuration
-    p2pGoParam      - P2P specific GO parameters. Ignored if it is a leagacy AP
-
-*******************************************************************************/
-#define CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->initialPresence = (initialPresence__); \
-    msg__->apType = (apType__); \
-    msg__->cloakSsid = (cloakSsid__); \
-    msg__->ssid = (ssid__); \
-    msg__->ifIndex = (ifIndex__); \
-    msg__->channel = (channel__); \
-    msg__->maxConnections = (maxConnections__); \
-    msg__->apCredentials = (apCredentials__); \
-    msg__->smeApConfig = (smeApConfig__); \
-    msg__->p2pGoParam = (p2pGoParam__);
-
-#define CsrWifiSmeApBeaconingStartReqSendTo(dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
-    { \
-        CsrWifiSmeApBeaconingStartReq *msg__; \
-        CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApBeaconingStartReqSend(src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
-    CsrWifiSmeApBeaconingStartReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStartCfmSend
-
-  DESCRIPTION
-    This primitive confirms the completion of the request along with the
-    status
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag -
-    status       -
-    secIeLength  -
-    secIe        -
-
-*******************************************************************************/
-#define CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->secIeLength = (secIeLength__); \
-    msg__->secIe = (secIe__);
-
-#define CsrWifiSmeApBeaconingStartCfmSendTo(dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \
-    { \
-        CsrWifiSmeApBeaconingStartCfm *msg__; \
-        CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApBeaconingStartCfmSend(dst__, interfaceTag__, status__, secIeLength__, secIe__) \
-    CsrWifiSmeApBeaconingStartCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, secIeLength__, secIe__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStopReqSend
-
-  DESCRIPTION
-    This primitive requests the SME to STOP AP or P2PGO operation
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-
-*******************************************************************************/
-#define CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeApBeaconingStopReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeApBeaconingStopReq *msg__; \
-        CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApBeaconingStopReqSend(src__, interfaceTag__) \
-    CsrWifiSmeApBeaconingStopReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStopCfmSend
-
-  DESCRIPTION
-    This primitive confirms AP or P2PGO operation is terminated
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeApBeaconingStopCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeApBeaconingStopCfm *msg__; \
-        CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApBeaconingStopCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeApBeaconingStopCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApErrorIndSend
-
-  DESCRIPTION
-    This primitve is sent by SME to indicate some error in AP operationi
-    after AP operations were started successfully and continuing the AP
-    operation may lead to undesired behaviour. It is the responsibility of
-    the upper layers to stop AP operation if needed
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Range 0-1
-    apType       -
-    status       - Contains the error status
-
-*******************************************************************************/
-#define CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApErrorInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ERROR_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->apType = (apType__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeApErrorIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \
-    { \
-        CsrWifiSmeApErrorInd *msg__; \
-        CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApErrorIndSend(dst__, interfaceTag__, apType__, status__) \
-    CsrWifiSmeApErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, apType__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaConnectStartIndSend
-
-  DESCRIPTION
-    This primitive indicates that a stations request to join the group/BSS is
-    accepted
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   -
-    peerMacAddress -
-
-*******************************************************************************/
-#define CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApStaConnectStartInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_CONNECT_START_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->peerMacAddress = (peerMacAddress__);
-
-#define CsrWifiSmeApStaConnectStartIndSendTo(dst__, src__, interfaceTag__, peerMacAddress__) \
-    { \
-        CsrWifiSmeApStaConnectStartInd *msg__; \
-        CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApStaConnectStartIndSend(dst__, interfaceTag__, peerMacAddress__) \
-    CsrWifiSmeApStaConnectStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, peerMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaDisconnectReqSend
-
-  DESCRIPTION
-    This primitive tells SME to deauth ot disassociate a particular station
-    within BSS
-
-  PARAMETERS
-    queue          - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag   -
-    deauthReason   -
-    disassocReason -
-    peerMacaddress -
-    keepBlocking   - If TRUE, the station is blocked. If FALSE and the station
-                     is connected, disconnect the station. If FALSE and the
-                     station is not connected, no action is taken.
-
-*******************************************************************************/
-#define CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->deauthReason = (deauthReason__); \
-    msg__->disassocReason = (disassocReason__); \
-    msg__->peerMacaddress = (peerMacaddress__); \
-    msg__->keepBlocking = (keepBlocking__);
-
-#define CsrWifiSmeApStaDisconnectReqSendTo(dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
-    { \
-        CsrWifiSmeApStaDisconnectReq *msg__; \
-        CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApStaDisconnectReqSend(src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
-    CsrWifiSmeApStaDisconnectReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaDisconnectCfmSend
-
-  DESCRIPTION
-    This primitive confirms the station is disconnected
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   -
-    status         -
-    peerMacaddress -
-
-*******************************************************************************/
-#define CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->peerMacaddress = (peerMacaddress__);
-
-#define CsrWifiSmeApStaDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__, peerMacaddress__) \
-    { \
-        CsrWifiSmeApStaDisconnectCfm *msg__; \
-        CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApStaDisconnectCfmSend(dst__, interfaceTag__, status__, peerMacaddress__) \
-    CsrWifiSmeApStaDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, peerMacaddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaNotifyIndSend
-
-  DESCRIPTION
-    This primitive indicates that a station has joined or a previously joined
-    station has left the BSS/group
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    interfaceTag      -
-    mediaStatus       -
-    peerMacAddress    -
-    peerDeviceAddress -
-    disassocReason    -
-    deauthReason      -
-    WpsRegistration   -
-    secIeLength       -
-    secIe             -
-    groupKeyId        -
-    seqNumber         -
-
-*******************************************************************************/
-#define CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApStaNotifyInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_NOTIFY_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->mediaStatus = (mediaStatus__); \
-    msg__->peerMacAddress = (peerMacAddress__); \
-    msg__->peerDeviceAddress = (peerDeviceAddress__); \
-    msg__->disassocReason = (disassocReason__); \
-    msg__->deauthReason = (deauthReason__); \
-    msg__->WpsRegistration = (WpsRegistration__); \
-    msg__->secIeLength = (secIeLength__); \
-    msg__->secIe = (secIe__); \
-    msg__->groupKeyId = (groupKeyId__); \
-    memcpy(msg__->seqNumber, (seqNumber__), sizeof(u16) * 8);
-
-#define CsrWifiSmeApStaNotifyIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
-    { \
-        CsrWifiSmeApStaNotifyInd *msg__; \
-        CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApStaNotifyIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
-    CsrWifiSmeApStaNotifyIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWmmParamUpdateReqSend
-
-  DESCRIPTION
-    Application uses this primitive to update the WMM parameters on the fly
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag  -
-    wmmApParams   - WMM parameters to be used for local firmware queue
-                    configuration
-    wmmApBcParams - WMM parameters to be advertised in beacon/probe response
-
-*******************************************************************************/
-#define CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \
-    memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4);
-
-#define CsrWifiSmeApWmmParamUpdateReqSendTo(dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
-    { \
-        CsrWifiSmeApWmmParamUpdateReq *msg__; \
-        CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWmmParamUpdateReqSend(src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
-    CsrWifiSmeApWmmParamUpdateReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, wmmApParams__, wmmApBcParams__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWmmParamUpdateCfmSend
-
-  DESCRIPTION
-    A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeApWmmParamUpdateCfm *msg__; \
-        CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWmmParamUpdateCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsConfigurationReqSend
-
-  DESCRIPTION
-    This primitive passes the WPS information for the device to SME. This may
-    be accepted only if no interface is active.
-
-  PARAMETERS
-    queue     - Message Source Task Queue (Cfm's will be sent to this Queue)
-    wpsConfig - WPS config.
-
-*******************************************************************************/
-#define CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ, dst__, src__); \
-    msg__->wpsConfig = (wpsConfig__);
-
-#define CsrWifiSmeApWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \
-    { \
-        CsrWifiSmeApWpsConfigurationReq *msg__; \
-        CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWpsConfigurationReqSend(src__, wpsConfig__) \
-    CsrWifiSmeApWpsConfigurationReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, wpsConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsConfigurationCfmSend
-
-  DESCRIPTION
-    Confirm.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeApWpsConfigurationCfm *msg__; \
-        CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWpsConfigurationCfmSend(dst__, status__) \
-    CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationFinishedReqSend
-
-  DESCRIPTION
-    This primitive tells SME that WPS registration procedure has finished
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag -
-
-*******************************************************************************/
-#define CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeApWpsRegistrationFinishedReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeApWpsRegistrationFinishedReq *msg__; \
-        CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWpsRegistrationFinishedReqSend(src__, interfaceTag__) \
-    CsrWifiSmeApWpsRegistrationFinishedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationFinishedCfmSend
-
-  DESCRIPTION
-    A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeApWpsRegistrationFinishedCfm *msg__; \
-        CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWpsRegistrationFinishedCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationStartedReqSend
-
-  DESCRIPTION
-    This primitive tells SME that WPS registration procedure has started
-
-  PARAMETERS
-    queue                    - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag             -
-    SelectedDevicePasswordId -
-    SelectedconfigMethod     -
-
-*******************************************************************************/
-#define CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->SelectedDevicePasswordId = (SelectedDevicePasswordId__); \
-    msg__->SelectedconfigMethod = (SelectedconfigMethod__);
-
-#define CsrWifiSmeApWpsRegistrationStartedReqSendTo(dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
-    { \
-        CsrWifiSmeApWpsRegistrationStartedReq *msg__; \
-        CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWpsRegistrationStartedReqSend(src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
-    CsrWifiSmeApWpsRegistrationStartedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationStartedCfmSend
-
-  DESCRIPTION
-    A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-#define CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeApWpsRegistrationStartedCfm *msg__; \
-        CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeApWpsRegistrationStartedCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-
-#endif /* CSR_WIFI_SME_AP_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_ap_prim.h b/drivers/staging/csr/csr_wifi_sme_ap_prim.h
deleted file mode 100644 (file)
index 3c4bcbc..0000000
+++ /dev/null
@@ -1,1030 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_AP_PRIM_H__
-#define CSR_WIFI_SME_AP_PRIM_H__
-
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-#include "csr_wifi_common.h"
-#include "csr_result.h"
-#include "csr_wifi_fsm_event.h"
-#include "csr_wifi_sme_prim.h"
-
-#ifndef CSR_WIFI_AP_ENABLE
-#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_prim.h
-#endif
-
-#define CSR_WIFI_SME_AP_PRIM                                            (0x0407)
-
-typedef CsrPrim CsrWifiSmeApPrim;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApAccessType
-
-  DESCRIPTION
-    Allow or deny STAs based on MAC address
-
- VALUES
-    CSR_WIFI_AP_ACCESS_TYPE_NONE  - None
-    CSR_WIFI_AP_ACCESS_TYPE_ALLOW - Allow only if MAC address is from the list
-    CSR_WIFI_AP_ACCESS_TYPE_DENY  - Disallow if MAC address is from the list
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApAccessType;
-#define CSR_WIFI_AP_ACCESS_TYPE_NONE    ((CsrWifiSmeApAccessType) 0x00)
-#define CSR_WIFI_AP_ACCESS_TYPE_ALLOW   ((CsrWifiSmeApAccessType) 0x01)
-#define CSR_WIFI_AP_ACCESS_TYPE_DENY    ((CsrWifiSmeApAccessType) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApAuthSupport
-
-  DESCRIPTION
-    Define bits for AP authentication support
-
- VALUES
-    CSR_WIFI_SME_RSN_AUTH_WPAPSK  - RSN WPA-PSK Support
-    CSR_WIFI_SME_RSN_AUTH_WPA2PSK - RSN WPA2-PSK Support
-    CSR_WIFI_SME_AUTH_WAPIPSK     - WAPI-PSK Support
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApAuthSupport;
-#define CSR_WIFI_SME_RSN_AUTH_WPAPSK    ((CsrWifiSmeApAuthSupport) 0x01)
-#define CSR_WIFI_SME_RSN_AUTH_WPA2PSK   ((CsrWifiSmeApAuthSupport) 0x02)
-#define CSR_WIFI_SME_AUTH_WAPIPSK       ((CsrWifiSmeApAuthSupport) 0x04)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApAuthType
-
-  DESCRIPTION
-    Definition of the SME AP Authentication Options
-
- VALUES
-    CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM
-                   - Open  authentication
-    CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL
-                   - Personal authentication using a passphrase or a pre-shared
-                     key.
-    CSR_WIFI_SME_AP_AUTH_TYPE_WEP
-                   - WEP authentication. This can be either open or shared key
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApAuthType;
-#define CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM   ((CsrWifiSmeApAuthType) 0x00)
-#define CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL      ((CsrWifiSmeApAuthType) 0x01)
-#define CSR_WIFI_SME_AP_AUTH_TYPE_WEP           ((CsrWifiSmeApAuthType) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApDirection
-
-  DESCRIPTION
-    Definition of Direction
-
- VALUES
-    CSR_WIFI_AP_DIRECTION_RECEIPIENT - Receipient
-    CSR_WIFI_AP_DIRECTION_ORIGINATOR - Originator
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApDirection;
-#define CSR_WIFI_AP_DIRECTION_RECEIPIENT   ((CsrWifiSmeApDirection) 0x00)
-#define CSR_WIFI_AP_DIRECTION_ORIGINATOR   ((CsrWifiSmeApDirection) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApPhySupport
-
-  DESCRIPTION
-    Define bits for CsrWifiSmeApPhySupportMask
-
- VALUES
-    CSR_WIFI_SME_AP_PHY_SUPPORT_A - 802.11a. It is not supported in the current
-                                    release.
-    CSR_WIFI_SME_AP_PHY_SUPPORT_B - 802.11b
-    CSR_WIFI_SME_AP_PHY_SUPPORT_G - 802.11g
-    CSR_WIFI_SME_AP_PHY_SUPPORT_N - 802.11n
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApPhySupport;
-#define CSR_WIFI_SME_AP_PHY_SUPPORT_A   ((CsrWifiSmeApPhySupport) 0x01)
-#define CSR_WIFI_SME_AP_PHY_SUPPORT_B   ((CsrWifiSmeApPhySupport) 0x02)
-#define CSR_WIFI_SME_AP_PHY_SUPPORT_G   ((CsrWifiSmeApPhySupport) 0x04)
-#define CSR_WIFI_SME_AP_PHY_SUPPORT_N   ((CsrWifiSmeApPhySupport) 0x08)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApType
-
-  DESCRIPTION
-    Definition of AP types
-
- VALUES
-    CSR_WIFI_AP_TYPE_LEGACY - Legacy AP
-    CSR_WIFI_AP_TYPE_P2P    - P2P Group Owner(GO)
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApType;
-#define CSR_WIFI_AP_TYPE_LEGACY   ((CsrWifiSmeApType) 0x00)
-#define CSR_WIFI_AP_TYPE_P2P      ((CsrWifiSmeApType) 0x01)
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApAuthSupportMask
-
-  DESCRIPTION
-    See CsrWifiSmeApAuthSupport for bit definitions
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApAuthSupportMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApPhySupportMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeApPhySupport
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeApPhySupportMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApRsnCapabilities
-
-  DESCRIPTION
-    Set to 0 for the current release
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeApRsnCapabilities;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApRsnCapabilitiesMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeApRsnCapabilities
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeApRsnCapabilitiesMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWapiCapabilities
-
-  DESCRIPTION
-    Ignored by the stack as WAPI is not supported for AP operations in the
-    current release
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeApWapiCapabilities;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWapiCapabilitiesMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeApWapiCapabilities
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeApWapiCapabilitiesMask;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApHtParams
-
-  DESCRIPTION
-    Structure holding HT parameters
-
-  MEMBERS
-    greenfieldSupported - Indicates if the AP supports Htgreenfield operation
-                          subject to the chip capability. If the chip does not
-                          support Htgreenfield operation, this parameter will be
-                          ignored.
-                          NOTE: if shortGi20MHz is set to TRUE and the chip
-                          supports short GI operation for 20MHz this field will
-                          be be ignored and the AP will not support Htgreenfield
-                          operation.
-                          NOTE: This field is ignored by the Wi-Fi stack for the
-                          current release. It implies that AP does not support
-                          greenfield operation.
-    shortGi20MHz        - Indicates if the AP support short GI operation for
-                          20MHz subject to the chip capability.If the chip does
-                          not support short GI for 20MHz, this parameter is
-                          ignored
-    rxStbc              - Support for STBC for receive. 0 => No support for STBC
-                          , 1=> Use STBC for Rx
-    rifsModeAllowed     - RIFS Mode is allowed to protect overlapping non-HT BSS
-    htProtection        - Deprecated
-    dualCtsProtection   - Dual CTS Protection enabled
-
-*******************************************************************************/
-typedef struct
-{
-    u8  greenfieldSupported;
-    u8  shortGi20MHz;
-    u8 rxStbc;
-    u8  rifsModeAllowed;
-    u8 htProtection;
-    u8  dualCtsProtection;
-} CsrWifiSmeApHtParams;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApP2pOperatingChanEntry
-
-  DESCRIPTION
-
-  MEMBERS
-    operatingClass        - Channel operating class
-    operatingChannelCount - Number of channels in this entry
-    operatingChannel      - List of channels
-
-*******************************************************************************/
-typedef struct
-{
-    u8  operatingClass;
-    u8  operatingChannelCount;
-    u8 *operatingChannel;
-} CsrWifiSmeApP2pOperatingChanEntry;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApP2pOperatingChanList
-
-  DESCRIPTION
-    This structure contains the lists of P2P operating channels
-
-  MEMBERS
-    country               - Country
-    channelEntryListCount - Number of entries
-    channelEntryList      - List of entries
-
-*******************************************************************************/
-typedef struct
-{
-    u8                           country[3];
-    u8                           channelEntryListCount;
-    CsrWifiSmeApP2pOperatingChanEntry *channelEntryList;
-} CsrWifiSmeApP2pOperatingChanList;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApAuthPers
-
-  DESCRIPTION
-
-  MEMBERS
-    authSupport        -
-    encryptionModeMask -
-    rsnCapabilities    -
-    wapiCapabilities   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeApAuthSupportMask      authSupport;
-    CsrWifiSmeEncryptionMask         encryptionModeMask;
-    CsrWifiSmeApRsnCapabilitiesMask  rsnCapabilities;
-    CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities;
-} CsrWifiSmeApAuthPers;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBaSession
-
-  DESCRIPTION
-
-  MEMBERS
-    peerMacAddress - Indicates MAC address of the peer station
-    tid            - Specifies the TID of the MSDUs for which this Block Ack has
-                     been set up. Range: 0-15
-    direction      - Specifies if the AP is the originator or the recipient of
-                     the data stream that uses the Block Ack.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress     peerMacAddress;
-    u8              tid;
-    CsrWifiSmeApDirection direction;
-} CsrWifiSmeApBaSession;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApMacConfig
-
-  DESCRIPTION
-    Structure holding AP MAC configuration.
-
-  MEMBERS
-    phySupportedBitmap   - Indicates supported physical layers
-    beaconInterval       - Beacon interval in terms of TUs
-    dtimPeriod           - DTIM period in terms of number of beacon intervals
-    maxListenInterval    - Maximum allowed listen interval as number of beacon
-                           intervals
-    supportedRatesCount  - Number of supported rates. Range : 0  to 20
-    supportedRates       - List of supportedRates. A rate is specied in the
-                           units of 500kbps. An entry for a basic rate shall
-                           have the MSB set to 1.
-    preamble             - Preamble to be advertised in beacons and probe
-                           responses
-    shortSlotTimeEnabled - TRUE indicates the AP shall use short slot time if
-                           all the stations use short slot operation.
-    ctsProtectionType    - CTS protection to be used
-    wmmEnabled           - Indicate whether WMM is enabled or not. If set to
-                           FALSE,the WMM parameters shall be ignored by the
-                           receiver.
-    wmmApParams          - WMM parameters to be used for local firmware queue
-                           configuration. Array index corresponds to the ACI.
-    wmmApBcParams        - WMM parameters to be advertised in beacon/probe
-                           response. Array index corresponds to the ACI
-    accessType           - Specifies whether the MAC addresses from the list
-                           should be allowed or denied
-    macAddressListCount  - Number of MAC addresses
-    macAddressList       - List of MAC addresses
-    apHtParams           - AP HT parameters. The stack shall use these
-                           parameters only if phySupportedBitmap indicates
-                           support for IEEE 802.11n
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeApPhySupportMask  phySupportedBitmap;
-    u16                   beaconInterval;
-    u8                    dtimPeriod;
-    u16                   maxListenInterval;
-    u8                    supportedRatesCount;
-    u8                    supportedRates[20];
-    CsrWifiSmePreambleType      preamble;
-    u8                     shortSlotTimeEnabled;
-    CsrWifiSmeCtsProtectionType ctsProtectionType;
-    u8                     wmmEnabled;
-    CsrWifiSmeWmmAcParams       wmmApParams[4];
-    CsrWifiSmeWmmAcParams       wmmApBcParams[4];
-    CsrWifiSmeApAccessType      accessType;
-    u8                    macAddressListCount;
-    CsrWifiMacAddress          *macAddressList;
-    CsrWifiSmeApHtParams        apHtParams;
-} CsrWifiSmeApMacConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApP2pGoConfig
-
-  DESCRIPTION
-
-  MEMBERS
-    groupCapability           - Indicates the P2P group capabilities
-    operatingChanList         - List of operating channels in the order of
-                                decreasing priority. It may contain channel
-                                entry/entries not supported by the wifi stack.
-                                These shall be filtered out by the wifi stack
-    opPsEnabled               - Indicates whether opportunistic power save can
-                                be used.
-                                Note: This parameter is ignored by the WiFi
-                                stack for the current release
-    ctWindow                  - Define Client Traffic window to be used in terms
-                                of number of TUs. Range: 0 to 127.
-                                Note: This parameter is ignored by the WiFi
-                                stack for the current release.
-    noaConfigMethod           - Notice of Absence configuration method.
-                                Note: This parameter is ignored by the WiFi
-                                stack for the current release.
-    allowNoaWithNonP2pDevices - Indicates if NOA should be allowed if non P2P
-                                devices are connected. If allowed the non P2P
-                                devices may suffer in throughput.
-                                Note: This parameter is ignored by the WiFi
-                                stack for the current release.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeP2pGroupCapabilityMask groupCapability;
-    CsrWifiSmeApP2pOperatingChanList operatingChanList;
-    u8                          opPsEnabled;
-    u8                         ctWindow;
-    CsrWifiSmeP2pNoaConfigMethod     noaConfigMethod;
-    u8                          allowNoaWithNonP2pDevices;
-} CsrWifiSmeApP2pGoConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApCredentials
-
-  DESCRIPTION
-
-  MEMBERS
-    authType                    -
-    smeAuthType                 -
-    smeAuthTypeopenSystemEmpty  -
-    smeAuthTypeauthwep          -
-    smeAuthTypeauthPers         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeApAuthType authType;
-    union {
-        CsrWifiSmeEmpty      openSystemEmpty;
-        CsrWifiSmeWepAuth    authwep;
-        CsrWifiSmeApAuthPers authPers;
-    } smeAuthType;
-} CsrWifiSmeApCredentials;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApSecConfig
-
-  DESCRIPTION
-
-  MEMBERS
-    apCredentials -
-    wpsEnabled    -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeApCredentials apCredentials;
-    u8                 wpsEnabled;
-} CsrWifiSmeApSecConfig;
-
-
-/* Downstream */
-#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST            (0x0000)
-
-#define CSR_WIFI_SME_AP_BEACONING_START_REQ               ((CsrWifiSmeApPrim) (0x0000 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_BEACONING_STOP_REQ                ((CsrWifiSmeApPrim) (0x0001 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ      ((CsrWifiSmeApPrim) (0x0002 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ     ((CsrWifiSmeApPrim) (0x0003 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ              ((CsrWifiSmeApPrim) (0x0004 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_STA_DISCONNECT_REQ                ((CsrWifiSmeApPrim) (0x0005 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ             ((CsrWifiSmeApPrim) (0x0006 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ                 ((CsrWifiSmeApPrim) (0x0007 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_BA_DELETE_REQ                     ((CsrWifiSmeApPrim) (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
-
-
-#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST           (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)
-
-/* Upstream */
-#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST              (0x0000 + CSR_PRIM_UPSTREAM)
-
-#define CSR_WIFI_SME_AP_BEACONING_START_CFM               ((CsrWifiSmeApPrim)(0x0000 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_BEACONING_STOP_CFM                ((CsrWifiSmeApPrim)(0x0001 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_STA_NOTIFY_IND                    ((CsrWifiSmeApPrim)(0x0002 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_STA_CONNECT_START_IND             ((CsrWifiSmeApPrim)(0x0003 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM      ((CsrWifiSmeApPrim)(0x0004 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM     ((CsrWifiSmeApPrim)(0x0005 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM              ((CsrWifiSmeApPrim)(0x0006 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_STA_DISCONNECT_CFM                ((CsrWifiSmeApPrim)(0x0007 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM             ((CsrWifiSmeApPrim)(0x0008 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_ERROR_IND                         ((CsrWifiSmeApPrim)(0x0009 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM                 ((CsrWifiSmeApPrim)(0x000A + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AP_BA_DELETE_CFM                     ((CsrWifiSmeApPrim)(0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
-
-#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST             (0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)
-
-#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT             (CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)
-#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT               (CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST   + 1 - CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStartReq
-
-  DESCRIPTION
-    This primitive requests the SME to start AP or GO functionality
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    -
-    initialPresence - Set to 0, if Not in a group fomration phase, set to 1 ,
-                      during group formation phase
-    apType          - apType : Legacy AP or P2PGO
-    cloakSsid       - cloakSsid flag.
-    ssid            - ssid.
-    ifIndex         - Radio Interface
-    channel         - channel.
-    maxConnections  - Maximum Stations + P2PClients allowed
-    apCredentials   - AP security credeitals used to advertise in beacon /probe
-                      response
-    smeApConfig     - AP configuration
-    p2pGoParam      - P2P specific GO parameters. Ignored if it is a leagacy AP
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    u8                initialPresence;
-    CsrWifiSmeApType        apType;
-    u8                 cloakSsid;
-    CsrWifiSsid             ssid;
-    CsrWifiSmeRadioIF       ifIndex;
-    u8                channel;
-    u8                maxConnections;
-    CsrWifiSmeApSecConfig   apCredentials;
-    CsrWifiSmeApMacConfig   smeApConfig;
-    CsrWifiSmeApP2pGoConfig p2pGoParam;
-} CsrWifiSmeApBeaconingStartReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStopReq
-
-  DESCRIPTION
-    This primitive requests the SME to STOP AP or P2PGO operation
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeApBeaconingStopReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationStartedReq
-
-  DESCRIPTION
-    This primitive tells SME that WPS registration procedure has started
-
-  MEMBERS
-    common                   - Common header for use with the CsrWifiFsm Module
-    interfaceTag             -
-    SelectedDevicePasswordId -
-    SelectedconfigMethod     -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    CsrWifiSmeWpsDpid       SelectedDevicePasswordId;
-    CsrWifiSmeWpsConfigType SelectedconfigMethod;
-} CsrWifiSmeApWpsRegistrationStartedReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationFinishedReq
-
-  DESCRIPTION
-    This primitive tells SME that WPS registration procedure has finished
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeApWpsRegistrationFinishedReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWmmParamUpdateReq
-
-  DESCRIPTION
-    Application uses this primitive to update the WMM parameters on the fly
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  -
-    wmmApParams   - WMM parameters to be used for local firmware queue
-                    configuration
-    wmmApBcParams - WMM parameters to be advertised in beacon/probe response
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    u16             interfaceTag;
-    CsrWifiSmeWmmAcParams wmmApParams[4];
-    CsrWifiSmeWmmAcParams wmmApBcParams[4];
-} CsrWifiSmeApWmmParamUpdateReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaDisconnectReq
-
-  DESCRIPTION
-    This primitive tells SME to deauth ot disassociate a particular station
-    within BSS
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   -
-    deauthReason   -
-    disassocReason -
-    peerMacaddress -
-    keepBlocking   - If TRUE, the station is blocked. If FALSE and the station
-                     is connected, disconnect the station. If FALSE and the
-                     station is not connected, no action is taken.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrWifiSmeIEEE80211Reason deauthReason;
-    CsrWifiSmeIEEE80211Reason disassocReason;
-    CsrWifiMacAddress         peerMacaddress;
-    u8                   keepBlocking;
-} CsrWifiSmeApStaDisconnectReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsConfigurationReq
-
-  DESCRIPTION
-    This primitive passes the WPS information for the device to SME. This may
-    be accepted only if no interface is active.
-
-  MEMBERS
-    common    - Common header for use with the CsrWifiFsm Module
-    wpsConfig - WPS config.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    CsrWifiSmeWpsConfig wpsConfig;
-} CsrWifiSmeApWpsConfigurationReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApActiveBaGetReq
-
-  DESCRIPTION
-    This primitive used to retrieve information related to the active block
-    ack sessions
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeApActiveBaGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBaDeleteReq
-
-  DESCRIPTION
-    This primitive is used to delete an active block ack session
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    reason       -
-    baSession    - BA session to be deleted
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrWifiSmeIEEE80211Reason reason;
-    CsrWifiSmeApBaSession     baSession;
-} CsrWifiSmeApBaDeleteReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStartCfm
-
-  DESCRIPTION
-    This primitive confirms the completion of the request along with the
-    status
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-    secIeLength  -
-    secIe        -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-    u16       secIeLength;
-    u8       *secIe;
-} CsrWifiSmeApBeaconingStartCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBeaconingStopCfm
-
-  DESCRIPTION
-    This primitive confirms AP or P2PGO operation is terminated
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeApBeaconingStopCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaNotifyInd
-
-  DESCRIPTION
-    This primitive indicates that a station has joined or a previously joined
-    station has left the BSS/group
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    interfaceTag      -
-    mediaStatus       -
-    peerMacAddress    -
-    peerDeviceAddress -
-    disassocReason    -
-    deauthReason      -
-    WpsRegistration   -
-    secIeLength       -
-    secIe             -
-    groupKeyId        -
-    seqNumber         -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrWifiSmeMediaStatus     mediaStatus;
-    CsrWifiMacAddress         peerMacAddress;
-    CsrWifiMacAddress         peerDeviceAddress;
-    CsrWifiSmeIEEE80211Reason disassocReason;
-    CsrWifiSmeIEEE80211Reason deauthReason;
-    CsrWifiSmeWpsRegistration WpsRegistration;
-    u8                  secIeLength;
-    u8                 *secIe;
-    u8                  groupKeyId;
-    u16                 seqNumber[8];
-} CsrWifiSmeApStaNotifyInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaConnectStartInd
-
-  DESCRIPTION
-    This primitive indicates that a stations request to join the group/BSS is
-    accepted
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   -
-    peerMacAddress -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    CsrWifiMacAddress peerMacAddress;
-} CsrWifiSmeApStaConnectStartInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationStartedCfm
-
-  DESCRIPTION
-    A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeApWpsRegistrationStartedCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsRegistrationFinishedCfm
-
-  DESCRIPTION
-    A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeApWpsRegistrationFinishedCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWmmParamUpdateCfm
-
-  DESCRIPTION
-    A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeApWmmParamUpdateCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApStaDisconnectCfm
-
-  DESCRIPTION
-    This primitive confirms the station is disconnected
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   -
-    status         -
-    peerMacaddress -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    CsrResult         status;
-    CsrWifiMacAddress peerMacaddress;
-} CsrWifiSmeApStaDisconnectCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApWpsConfigurationCfm
-
-  DESCRIPTION
-    Confirm.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeApWpsConfigurationCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApErrorInd
-
-  DESCRIPTION
-    This primitve is sent by SME to indicate some error in AP operationi
-    after AP operations were started successfully and continuing the AP
-    operation may lead to undesired behaviour. It is the responsibility of
-    the upper layers to stop AP operation if needed
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Range 0-1
-    apType       -
-    status       - Contains the error status
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent  common;
-    u16        interfaceTag;
-    CsrWifiSmeApType apType;
-    CsrResult        status;
-} CsrWifiSmeApErrorInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApActiveBaGetCfm
-
-  DESCRIPTION
-    This primitive carries the information related to the active ba sessions
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     -
-    status           - Reports the result of the request
-    activeBaCount    - Number of active block ack session
-    activeBaSessions - Points to a buffer containing an array of
-                       CsrWifiSmeApBaSession structures.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent        common;
-    u16              interfaceTag;
-    CsrResult              status;
-    u16              activeBaCount;
-    CsrWifiSmeApBaSession *activeBaSessions;
-} CsrWifiSmeApActiveBaGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeApBaDeleteCfm
-
-  DESCRIPTION
-    This primitive confirms the BA is deleted
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag -
-    status       - Reports the result of the request
-    baSession    - deleted BA session
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    u16             interfaceTag;
-    CsrResult             status;
-    CsrWifiSmeApBaSession baSession;
-} CsrWifiSmeApBaDeleteCfm;
-
-
-#endif /* CSR_WIFI_SME_AP_PRIM_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_sme_converter_init.c b/drivers/staging/csr/csr_wifi_sme_converter_init.c
deleted file mode 100644 (file)
index 31835f0..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#include "csr_msgconv.h"
-#include "csr_macro.h"
-
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-#endif
-
-#ifndef EXCLUDE_CSR_WIFI_SME_MODULE
-#include "csr_wifi_sme_serialize.h"
-#include "csr_wifi_sme_prim.h"
-
-static CsrMsgConvMsgEntry csrwifisme_conv_lut[] = {
-    { CSR_WIFI_SME_ACTIVATE_REQ, CsrWifiSmeActivateReqSizeof, CsrWifiSmeActivateReqSer, CsrWifiSmeActivateReqDes, CsrWifiSmeActivateReqSerFree },
-    { CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, CsrWifiSmeAdhocConfigGetReqSizeof, CsrWifiSmeAdhocConfigGetReqSer, CsrWifiSmeAdhocConfigGetReqDes, CsrWifiSmeAdhocConfigGetReqSerFree },
-    { CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, CsrWifiSmeAdhocConfigSetReqSizeof, CsrWifiSmeAdhocConfigSetReqSer, CsrWifiSmeAdhocConfigSetReqDes, CsrWifiSmeAdhocConfigSetReqSerFree },
-    { CSR_WIFI_SME_BLACKLIST_REQ, CsrWifiSmeBlacklistReqSizeof, CsrWifiSmeBlacklistReqSer, CsrWifiSmeBlacklistReqDes, CsrWifiSmeBlacklistReqSerFree },
-    { CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, CsrWifiSmeCalibrationDataGetReqSizeof, CsrWifiSmeCalibrationDataGetReqSer, CsrWifiSmeCalibrationDataGetReqDes, CsrWifiSmeCalibrationDataGetReqSerFree },
-    { CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, CsrWifiSmeCalibrationDataSetReqSizeof, CsrWifiSmeCalibrationDataSetReqSer, CsrWifiSmeCalibrationDataSetReqDes, CsrWifiSmeCalibrationDataSetReqSerFree },
-    { CSR_WIFI_SME_CCX_CONFIG_GET_REQ, CsrWifiSmeCcxConfigGetReqSizeof, CsrWifiSmeCcxConfigGetReqSer, CsrWifiSmeCcxConfigGetReqDes, CsrWifiSmeCcxConfigGetReqSerFree },
-    { CSR_WIFI_SME_CCX_CONFIG_SET_REQ, CsrWifiSmeCcxConfigSetReqSizeof, CsrWifiSmeCcxConfigSetReqSer, CsrWifiSmeCcxConfigSetReqDes, CsrWifiSmeCcxConfigSetReqSerFree },
-    { CSR_WIFI_SME_COEX_CONFIG_GET_REQ, CsrWifiSmeCoexConfigGetReqSizeof, CsrWifiSmeCoexConfigGetReqSer, CsrWifiSmeCoexConfigGetReqDes, CsrWifiSmeCoexConfigGetReqSerFree },
-    { CSR_WIFI_SME_COEX_CONFIG_SET_REQ, CsrWifiSmeCoexConfigSetReqSizeof, CsrWifiSmeCoexConfigSetReqSer, CsrWifiSmeCoexConfigSetReqDes, CsrWifiSmeCoexConfigSetReqSerFree },
-    { CSR_WIFI_SME_COEX_INFO_GET_REQ, CsrWifiSmeCoexInfoGetReqSizeof, CsrWifiSmeCoexInfoGetReqSer, CsrWifiSmeCoexInfoGetReqDes, CsrWifiSmeCoexInfoGetReqSerFree },
-    { CSR_WIFI_SME_CONNECT_REQ, CsrWifiSmeConnectReqSizeof, CsrWifiSmeConnectReqSer, CsrWifiSmeConnectReqDes, CsrWifiSmeConnectReqSerFree },
-    { CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, CsrWifiSmeConnectionConfigGetReqSizeof, CsrWifiSmeConnectionConfigGetReqSer, CsrWifiSmeConnectionConfigGetReqDes, CsrWifiSmeConnectionConfigGetReqSerFree },
-    { CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, CsrWifiSmeConnectionInfoGetReqSizeof, CsrWifiSmeConnectionInfoGetReqSer, CsrWifiSmeConnectionInfoGetReqDes, CsrWifiSmeConnectionInfoGetReqSerFree },
-    { CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, CsrWifiSmeConnectionStatsGetReqSizeof, CsrWifiSmeConnectionStatsGetReqSer, CsrWifiSmeConnectionStatsGetReqDes, CsrWifiSmeConnectionStatsGetReqSerFree },
-    { CSR_WIFI_SME_DEACTIVATE_REQ, CsrWifiSmeDeactivateReqSizeof, CsrWifiSmeDeactivateReqSer, CsrWifiSmeDeactivateReqDes, CsrWifiSmeDeactivateReqSerFree },
-    { CSR_WIFI_SME_DISCONNECT_REQ, CsrWifiSmeDisconnectReqSizeof, CsrWifiSmeDisconnectReqSer, CsrWifiSmeDisconnectReqDes, CsrWifiSmeDisconnectReqSerFree },
-    { CSR_WIFI_SME_EVENT_MASK_SET_REQ, CsrWifiSmeEventMaskSetReqSizeof, CsrWifiSmeEventMaskSetReqSer, CsrWifiSmeEventMaskSetReqDes, CsrWifiSmeEventMaskSetReqSerFree },
-    { CSR_WIFI_SME_HOST_CONFIG_GET_REQ, CsrWifiSmeHostConfigGetReqSizeof, CsrWifiSmeHostConfigGetReqSer, CsrWifiSmeHostConfigGetReqDes, CsrWifiSmeHostConfigGetReqSerFree },
-    { CSR_WIFI_SME_HOST_CONFIG_SET_REQ, CsrWifiSmeHostConfigSetReqSizeof, CsrWifiSmeHostConfigSetReqSer, CsrWifiSmeHostConfigSetReqDes, CsrWifiSmeHostConfigSetReqSerFree },
-    { CSR_WIFI_SME_KEY_REQ, CsrWifiSmeKeyReqSizeof, CsrWifiSmeKeyReqSer, CsrWifiSmeKeyReqDes, CsrWifiSmeKeyReqSerFree },
-    { CSR_WIFI_SME_LINK_QUALITY_GET_REQ, CsrWifiSmeLinkQualityGetReqSizeof, CsrWifiSmeLinkQualityGetReqSer, CsrWifiSmeLinkQualityGetReqDes, CsrWifiSmeLinkQualityGetReqSerFree },
-    { CSR_WIFI_SME_MIB_CONFIG_GET_REQ, CsrWifiSmeMibConfigGetReqSizeof, CsrWifiSmeMibConfigGetReqSer, CsrWifiSmeMibConfigGetReqDes, CsrWifiSmeMibConfigGetReqSerFree },
-    { CSR_WIFI_SME_MIB_CONFIG_SET_REQ, CsrWifiSmeMibConfigSetReqSizeof, CsrWifiSmeMibConfigSetReqSer, CsrWifiSmeMibConfigSetReqDes, CsrWifiSmeMibConfigSetReqSerFree },
-    { CSR_WIFI_SME_MIB_GET_NEXT_REQ, CsrWifiSmeMibGetNextReqSizeof, CsrWifiSmeMibGetNextReqSer, CsrWifiSmeMibGetNextReqDes, CsrWifiSmeMibGetNextReqSerFree },
-    { CSR_WIFI_SME_MIB_GET_REQ, CsrWifiSmeMibGetReqSizeof, CsrWifiSmeMibGetReqSer, CsrWifiSmeMibGetReqDes, CsrWifiSmeMibGetReqSerFree },
-    { CSR_WIFI_SME_MIB_SET_REQ, CsrWifiSmeMibSetReqSizeof, CsrWifiSmeMibSetReqSer, CsrWifiSmeMibSetReqDes, CsrWifiSmeMibSetReqSerFree },
-    { CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, CsrWifiSmeMulticastAddressReqSizeof, CsrWifiSmeMulticastAddressReqSer, CsrWifiSmeMulticastAddressReqDes, CsrWifiSmeMulticastAddressReqSerFree },
-    { CSR_WIFI_SME_PACKET_FILTER_SET_REQ, CsrWifiSmePacketFilterSetReqSizeof, CsrWifiSmePacketFilterSetReqSer, CsrWifiSmePacketFilterSetReqDes, CsrWifiSmePacketFilterSetReqSerFree },
-    { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, CsrWifiSmePermanentMacAddressGetReqSizeof, CsrWifiSmePermanentMacAddressGetReqSer, CsrWifiSmePermanentMacAddressGetReqDes, CsrWifiSmePermanentMacAddressGetReqSerFree },
-    { CSR_WIFI_SME_PMKID_REQ, CsrWifiSmePmkidReqSizeof, CsrWifiSmePmkidReqSer, CsrWifiSmePmkidReqDes, CsrWifiSmePmkidReqSerFree },
-    { CSR_WIFI_SME_POWER_CONFIG_GET_REQ, CsrWifiSmePowerConfigGetReqSizeof, CsrWifiSmePowerConfigGetReqSer, CsrWifiSmePowerConfigGetReqDes, CsrWifiSmePowerConfigGetReqSerFree },
-    { CSR_WIFI_SME_POWER_CONFIG_SET_REQ, CsrWifiSmePowerConfigSetReqSizeof, CsrWifiSmePowerConfigSetReqSer, CsrWifiSmePowerConfigSetReqDes, CsrWifiSmePowerConfigSetReqSerFree },
-    { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, CsrWifiSmeRegulatoryDomainInfoGetReqSizeof, CsrWifiSmeRegulatoryDomainInfoGetReqSer, CsrWifiSmeRegulatoryDomainInfoGetReqDes, CsrWifiSmeRegulatoryDomainInfoGetReqSerFree },
-    { CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, CsrWifiSmeRoamingConfigGetReqSizeof, CsrWifiSmeRoamingConfigGetReqSer, CsrWifiSmeRoamingConfigGetReqDes, CsrWifiSmeRoamingConfigGetReqSerFree },
-    { CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, CsrWifiSmeRoamingConfigSetReqSizeof, CsrWifiSmeRoamingConfigSetReqSer, CsrWifiSmeRoamingConfigSetReqDes, CsrWifiSmeRoamingConfigSetReqSerFree },
-    { CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, CsrWifiSmeScanConfigGetReqSizeof, CsrWifiSmeScanConfigGetReqSer, CsrWifiSmeScanConfigGetReqDes, CsrWifiSmeScanConfigGetReqSerFree },
-    { CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, CsrWifiSmeScanConfigSetReqSizeof, CsrWifiSmeScanConfigSetReqSer, CsrWifiSmeScanConfigSetReqDes, CsrWifiSmeScanConfigSetReqSerFree },
-    { CSR_WIFI_SME_SCAN_FULL_REQ, CsrWifiSmeScanFullReqSizeof, CsrWifiSmeScanFullReqSer, CsrWifiSmeScanFullReqDes, CsrWifiSmeScanFullReqSerFree },
-    { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, CsrWifiSmeScanResultsFlushReqSizeof, CsrWifiSmeScanResultsFlushReqSer, CsrWifiSmeScanResultsFlushReqDes, CsrWifiSmeScanResultsFlushReqSerFree },
-    { CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, CsrWifiSmeScanResultsGetReqSizeof, CsrWifiSmeScanResultsGetReqSer, CsrWifiSmeScanResultsGetReqDes, CsrWifiSmeScanResultsGetReqSerFree },
-    { CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, CsrWifiSmeSmeStaConfigGetReqSizeof, CsrWifiSmeSmeStaConfigGetReqSer, CsrWifiSmeSmeStaConfigGetReqDes, CsrWifiSmeSmeStaConfigGetReqSerFree },
-    { CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, CsrWifiSmeSmeStaConfigSetReqSizeof, CsrWifiSmeSmeStaConfigSetReqSer, CsrWifiSmeSmeStaConfigSetReqDes, CsrWifiSmeSmeStaConfigSetReqSerFree },
-    { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, CsrWifiSmeStationMacAddressGetReqSizeof, CsrWifiSmeStationMacAddressGetReqSer, CsrWifiSmeStationMacAddressGetReqDes, CsrWifiSmeStationMacAddressGetReqSerFree },
-    { CSR_WIFI_SME_TSPEC_REQ, CsrWifiSmeTspecReqSizeof, CsrWifiSmeTspecReqSer, CsrWifiSmeTspecReqDes, CsrWifiSmeTspecReqSerFree },
-    { CSR_WIFI_SME_VERSIONS_GET_REQ, CsrWifiSmeVersionsGetReqSizeof, CsrWifiSmeVersionsGetReqSer, CsrWifiSmeVersionsGetReqDes, CsrWifiSmeVersionsGetReqSerFree },
-    { CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, CsrWifiSmeWifiFlightmodeReqSizeof, CsrWifiSmeWifiFlightmodeReqSer, CsrWifiSmeWifiFlightmodeReqDes, CsrWifiSmeWifiFlightmodeReqSerFree },
-    { CSR_WIFI_SME_WIFI_OFF_REQ, CsrWifiSmeWifiOffReqSizeof, CsrWifiSmeWifiOffReqSer, CsrWifiSmeWifiOffReqDes, CsrWifiSmeWifiOffReqSerFree },
-    { CSR_WIFI_SME_WIFI_ON_REQ, CsrWifiSmeWifiOnReqSizeof, CsrWifiSmeWifiOnReqSer, CsrWifiSmeWifiOnReqDes, CsrWifiSmeWifiOnReqSerFree },
-    { CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, CsrWifiSmeCloakedSsidsSetReqSizeof, CsrWifiSmeCloakedSsidsSetReqSer, CsrWifiSmeCloakedSsidsSetReqDes, CsrWifiSmeCloakedSsidsSetReqSerFree },
-    { CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, CsrWifiSmeCloakedSsidsGetReqSizeof, CsrWifiSmeCloakedSsidsGetReqSer, CsrWifiSmeCloakedSsidsGetReqDes, CsrWifiSmeCloakedSsidsGetReqSerFree },
-    { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, CsrWifiSmeSmeCommonConfigGetReqSizeof, CsrWifiSmeSmeCommonConfigGetReqSer, CsrWifiSmeSmeCommonConfigGetReqDes, CsrWifiSmeSmeCommonConfigGetReqSerFree },
-    { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, CsrWifiSmeSmeCommonConfigSetReqSizeof, CsrWifiSmeSmeCommonConfigSetReqSer, CsrWifiSmeSmeCommonConfigSetReqDes, CsrWifiSmeSmeCommonConfigSetReqSerFree },
-    { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, CsrWifiSmeInterfaceCapabilityGetReqSizeof, CsrWifiSmeInterfaceCapabilityGetReqSer, CsrWifiSmeInterfaceCapabilityGetReqDes, CsrWifiSmeInterfaceCapabilityGetReqSerFree },
-    { CSR_WIFI_SME_WPS_CONFIGURATION_REQ, CsrWifiSmeWpsConfigurationReqSizeof, CsrWifiSmeWpsConfigurationReqSer, CsrWifiSmeWpsConfigurationReqDes, CsrWifiSmeWpsConfigurationReqSerFree },
-    { CSR_WIFI_SME_SET_REQ, CsrWifiSmeSetReqSizeof, CsrWifiSmeSetReqSer, CsrWifiSmeSetReqDes, CsrWifiSmeSetReqSerFree },
-    { CSR_WIFI_SME_ACTIVATE_CFM, CsrWifiSmeActivateCfmSizeof, CsrWifiSmeActivateCfmSer, CsrWifiSmeActivateCfmDes, CsrWifiSmeActivateCfmSerFree },
-    { CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, CsrWifiSmeAdhocConfigGetCfmSizeof, CsrWifiSmeAdhocConfigGetCfmSer, CsrWifiSmeAdhocConfigGetCfmDes, CsrWifiSmeAdhocConfigGetCfmSerFree },
-    { CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, CsrWifiSmeAdhocConfigSetCfmSizeof, CsrWifiSmeAdhocConfigSetCfmSer, CsrWifiSmeAdhocConfigSetCfmDes, CsrWifiSmeAdhocConfigSetCfmSerFree },
-    { CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, CsrWifiSmeAssociationCompleteIndSizeof, CsrWifiSmeAssociationCompleteIndSer, CsrWifiSmeAssociationCompleteIndDes, CsrWifiSmeAssociationCompleteIndSerFree },
-    { CSR_WIFI_SME_ASSOCIATION_START_IND, CsrWifiSmeAssociationStartIndSizeof, CsrWifiSmeAssociationStartIndSer, CsrWifiSmeAssociationStartIndDes, CsrWifiSmeAssociationStartIndSerFree },
-    { CSR_WIFI_SME_BLACKLIST_CFM, CsrWifiSmeBlacklistCfmSizeof, CsrWifiSmeBlacklistCfmSer, CsrWifiSmeBlacklistCfmDes, CsrWifiSmeBlacklistCfmSerFree },
-    { CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, CsrWifiSmeCalibrationDataGetCfmSizeof, CsrWifiSmeCalibrationDataGetCfmSer, CsrWifiSmeCalibrationDataGetCfmDes, CsrWifiSmeCalibrationDataGetCfmSerFree },
-    { CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, CsrWifiSmeCalibrationDataSetCfmSizeof, CsrWifiSmeCalibrationDataSetCfmSer, CsrWifiSmeCalibrationDataSetCfmDes, CsrWifiSmeCalibrationDataSetCfmSerFree },
-    { CSR_WIFI_SME_CCX_CONFIG_GET_CFM, CsrWifiSmeCcxConfigGetCfmSizeof, CsrWifiSmeCcxConfigGetCfmSer, CsrWifiSmeCcxConfigGetCfmDes, CsrWifiSmeCcxConfigGetCfmSerFree },
-    { CSR_WIFI_SME_CCX_CONFIG_SET_CFM, CsrWifiSmeCcxConfigSetCfmSizeof, CsrWifiSmeCcxConfigSetCfmSer, CsrWifiSmeCcxConfigSetCfmDes, CsrWifiSmeCcxConfigSetCfmSerFree },
-    { CSR_WIFI_SME_COEX_CONFIG_GET_CFM, CsrWifiSmeCoexConfigGetCfmSizeof, CsrWifiSmeCoexConfigGetCfmSer, CsrWifiSmeCoexConfigGetCfmDes, CsrWifiSmeCoexConfigGetCfmSerFree },
-    { CSR_WIFI_SME_COEX_CONFIG_SET_CFM, CsrWifiSmeCoexConfigSetCfmSizeof, CsrWifiSmeCoexConfigSetCfmSer, CsrWifiSmeCoexConfigSetCfmDes, CsrWifiSmeCoexConfigSetCfmSerFree },
-    { CSR_WIFI_SME_COEX_INFO_GET_CFM, CsrWifiSmeCoexInfoGetCfmSizeof, CsrWifiSmeCoexInfoGetCfmSer, CsrWifiSmeCoexInfoGetCfmDes, CsrWifiSmeCoexInfoGetCfmSerFree },
-    { CSR_WIFI_SME_CONNECT_CFM, CsrWifiSmeConnectCfmSizeof, CsrWifiSmeConnectCfmSer, CsrWifiSmeConnectCfmDes, CsrWifiSmeConnectCfmSerFree },
-    { CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, CsrWifiSmeConnectionConfigGetCfmSizeof, CsrWifiSmeConnectionConfigGetCfmSer, CsrWifiSmeConnectionConfigGetCfmDes, CsrWifiSmeConnectionConfigGetCfmSerFree },
-    { CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, CsrWifiSmeConnectionInfoGetCfmSizeof, CsrWifiSmeConnectionInfoGetCfmSer, CsrWifiSmeConnectionInfoGetCfmDes, CsrWifiSmeConnectionInfoGetCfmSerFree },
-    { CSR_WIFI_SME_CONNECTION_QUALITY_IND, CsrWifiSmeConnectionQualityIndSizeof, CsrWifiSmeConnectionQualityIndSer, CsrWifiSmeConnectionQualityIndDes, CsrWifiSmeConnectionQualityIndSerFree },
-    { CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, CsrWifiSmeConnectionStatsGetCfmSizeof, CsrWifiSmeConnectionStatsGetCfmSer, CsrWifiSmeConnectionStatsGetCfmDes, CsrWifiSmeConnectionStatsGetCfmSerFree },
-    { CSR_WIFI_SME_DEACTIVATE_CFM, CsrWifiSmeDeactivateCfmSizeof, CsrWifiSmeDeactivateCfmSer, CsrWifiSmeDeactivateCfmDes, CsrWifiSmeDeactivateCfmSerFree },
-    { CSR_WIFI_SME_DISCONNECT_CFM, CsrWifiSmeDisconnectCfmSizeof, CsrWifiSmeDisconnectCfmSer, CsrWifiSmeDisconnectCfmDes, CsrWifiSmeDisconnectCfmSerFree },
-    { CSR_WIFI_SME_EVENT_MASK_SET_CFM, CsrWifiSmeEventMaskSetCfmSizeof, CsrWifiSmeEventMaskSetCfmSer, CsrWifiSmeEventMaskSetCfmDes, CsrWifiSmeEventMaskSetCfmSerFree },
-    { CSR_WIFI_SME_HOST_CONFIG_GET_CFM, CsrWifiSmeHostConfigGetCfmSizeof, CsrWifiSmeHostConfigGetCfmSer, CsrWifiSmeHostConfigGetCfmDes, CsrWifiSmeHostConfigGetCfmSerFree },
-    { CSR_WIFI_SME_HOST_CONFIG_SET_CFM, CsrWifiSmeHostConfigSetCfmSizeof, CsrWifiSmeHostConfigSetCfmSer, CsrWifiSmeHostConfigSetCfmDes, CsrWifiSmeHostConfigSetCfmSerFree },
-    { CSR_WIFI_SME_IBSS_STATION_IND, CsrWifiSmeIbssStationIndSizeof, CsrWifiSmeIbssStationIndSer, CsrWifiSmeIbssStationIndDes, CsrWifiSmeIbssStationIndSerFree },
-    { CSR_WIFI_SME_KEY_CFM, CsrWifiSmeKeyCfmSizeof, CsrWifiSmeKeyCfmSer, CsrWifiSmeKeyCfmDes, CsrWifiSmeKeyCfmSerFree },
-    { CSR_WIFI_SME_LINK_QUALITY_GET_CFM, CsrWifiSmeLinkQualityGetCfmSizeof, CsrWifiSmeLinkQualityGetCfmSer, CsrWifiSmeLinkQualityGetCfmDes, CsrWifiSmeLinkQualityGetCfmSerFree },
-    { CSR_WIFI_SME_MEDIA_STATUS_IND, CsrWifiSmeMediaStatusIndSizeof, CsrWifiSmeMediaStatusIndSer, CsrWifiSmeMediaStatusIndDes, CsrWifiSmeMediaStatusIndSerFree },
-    { CSR_WIFI_SME_MIB_CONFIG_GET_CFM, CsrWifiSmeMibConfigGetCfmSizeof, CsrWifiSmeMibConfigGetCfmSer, CsrWifiSmeMibConfigGetCfmDes, CsrWifiSmeMibConfigGetCfmSerFree },
-    { CSR_WIFI_SME_MIB_CONFIG_SET_CFM, CsrWifiSmeMibConfigSetCfmSizeof, CsrWifiSmeMibConfigSetCfmSer, CsrWifiSmeMibConfigSetCfmDes, CsrWifiSmeMibConfigSetCfmSerFree },
-    { CSR_WIFI_SME_MIB_GET_CFM, CsrWifiSmeMibGetCfmSizeof, CsrWifiSmeMibGetCfmSer, CsrWifiSmeMibGetCfmDes, CsrWifiSmeMibGetCfmSerFree },
-    { CSR_WIFI_SME_MIB_GET_NEXT_CFM, CsrWifiSmeMibGetNextCfmSizeof, CsrWifiSmeMibGetNextCfmSer, CsrWifiSmeMibGetNextCfmDes, CsrWifiSmeMibGetNextCfmSerFree },
-    { CSR_WIFI_SME_MIB_SET_CFM, CsrWifiSmeMibSetCfmSizeof, CsrWifiSmeMibSetCfmSer, CsrWifiSmeMibSetCfmDes, CsrWifiSmeMibSetCfmSerFree },
-    { CSR_WIFI_SME_MIC_FAILURE_IND, CsrWifiSmeMicFailureIndSizeof, CsrWifiSmeMicFailureIndSer, CsrWifiSmeMicFailureIndDes, CsrWifiSmeMicFailureIndSerFree },
-    { CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, CsrWifiSmeMulticastAddressCfmSizeof, CsrWifiSmeMulticastAddressCfmSer, CsrWifiSmeMulticastAddressCfmDes, CsrWifiSmeMulticastAddressCfmSerFree },
-    { CSR_WIFI_SME_PACKET_FILTER_SET_CFM, CsrWifiSmePacketFilterSetCfmSizeof, CsrWifiSmePacketFilterSetCfmSer, CsrWifiSmePacketFilterSetCfmDes, CsrWifiSmePacketFilterSetCfmSerFree },
-    { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, CsrWifiSmePermanentMacAddressGetCfmSizeof, CsrWifiSmePermanentMacAddressGetCfmSer, CsrWifiSmePermanentMacAddressGetCfmDes, CsrWifiSmePermanentMacAddressGetCfmSerFree },
-    { CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, CsrWifiSmePmkidCandidateListIndSizeof, CsrWifiSmePmkidCandidateListIndSer, CsrWifiSmePmkidCandidateListIndDes, CsrWifiSmePmkidCandidateListIndSerFree },
-    { CSR_WIFI_SME_PMKID_CFM, CsrWifiSmePmkidCfmSizeof, CsrWifiSmePmkidCfmSer, CsrWifiSmePmkidCfmDes, CsrWifiSmePmkidCfmSerFree },
-    { CSR_WIFI_SME_POWER_CONFIG_GET_CFM, CsrWifiSmePowerConfigGetCfmSizeof, CsrWifiSmePowerConfigGetCfmSer, CsrWifiSmePowerConfigGetCfmDes, CsrWifiSmePowerConfigGetCfmSerFree },
-    { CSR_WIFI_SME_POWER_CONFIG_SET_CFM, CsrWifiSmePowerConfigSetCfmSizeof, CsrWifiSmePowerConfigSetCfmSer, CsrWifiSmePowerConfigSetCfmDes, CsrWifiSmePowerConfigSetCfmSerFree },
-    { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof, CsrWifiSmeRegulatoryDomainInfoGetCfmSer, CsrWifiSmeRegulatoryDomainInfoGetCfmDes, CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree },
-    { CSR_WIFI_SME_ROAM_COMPLETE_IND, CsrWifiSmeRoamCompleteIndSizeof, CsrWifiSmeRoamCompleteIndSer, CsrWifiSmeRoamCompleteIndDes, CsrWifiSmeRoamCompleteIndSerFree },
-    { CSR_WIFI_SME_ROAM_START_IND, CsrWifiSmeRoamStartIndSizeof, CsrWifiSmeRoamStartIndSer, CsrWifiSmeRoamStartIndDes, CsrWifiSmeRoamStartIndSerFree },
-    { CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, CsrWifiSmeRoamingConfigGetCfmSizeof, CsrWifiSmeRoamingConfigGetCfmSer, CsrWifiSmeRoamingConfigGetCfmDes, CsrWifiSmeRoamingConfigGetCfmSerFree },
-    { CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, CsrWifiSmeRoamingConfigSetCfmSizeof, CsrWifiSmeRoamingConfigSetCfmSer, CsrWifiSmeRoamingConfigSetCfmDes, CsrWifiSmeRoamingConfigSetCfmSerFree },
-    { CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, CsrWifiSmeScanConfigGetCfmSizeof, CsrWifiSmeScanConfigGetCfmSer, CsrWifiSmeScanConfigGetCfmDes, CsrWifiSmeScanConfigGetCfmSerFree },
-    { CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, CsrWifiSmeScanConfigSetCfmSizeof, CsrWifiSmeScanConfigSetCfmSer, CsrWifiSmeScanConfigSetCfmDes, CsrWifiSmeScanConfigSetCfmSerFree },
-    { CSR_WIFI_SME_SCAN_FULL_CFM, CsrWifiSmeScanFullCfmSizeof, CsrWifiSmeScanFullCfmSer, CsrWifiSmeScanFullCfmDes, CsrWifiSmeScanFullCfmSerFree },
-    { CSR_WIFI_SME_SCAN_RESULT_IND, CsrWifiSmeScanResultIndSizeof, CsrWifiSmeScanResultIndSer, CsrWifiSmeScanResultIndDes, CsrWifiSmeScanResultIndSerFree },
-    { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, CsrWifiSmeScanResultsFlushCfmSizeof, CsrWifiSmeScanResultsFlushCfmSer, CsrWifiSmeScanResultsFlushCfmDes, CsrWifiSmeScanResultsFlushCfmSerFree },
-    { CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, CsrWifiSmeScanResultsGetCfmSizeof, CsrWifiSmeScanResultsGetCfmSer, CsrWifiSmeScanResultsGetCfmDes, CsrWifiSmeScanResultsGetCfmSerFree },
-    { CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, CsrWifiSmeSmeStaConfigGetCfmSizeof, CsrWifiSmeSmeStaConfigGetCfmSer, CsrWifiSmeSmeStaConfigGetCfmDes, CsrWifiSmeSmeStaConfigGetCfmSerFree },
-    { CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, CsrWifiSmeSmeStaConfigSetCfmSizeof, CsrWifiSmeSmeStaConfigSetCfmSer, CsrWifiSmeSmeStaConfigSetCfmDes, CsrWifiSmeSmeStaConfigSetCfmSerFree },
-    { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, CsrWifiSmeStationMacAddressGetCfmSizeof, CsrWifiSmeStationMacAddressGetCfmSer, CsrWifiSmeStationMacAddressGetCfmDes, CsrWifiSmeStationMacAddressGetCfmSerFree },
-    { CSR_WIFI_SME_TSPEC_IND, CsrWifiSmeTspecIndSizeof, CsrWifiSmeTspecIndSer, CsrWifiSmeTspecIndDes, CsrWifiSmeTspecIndSerFree },
-    { CSR_WIFI_SME_TSPEC_CFM, CsrWifiSmeTspecCfmSizeof, CsrWifiSmeTspecCfmSer, CsrWifiSmeTspecCfmDes, CsrWifiSmeTspecCfmSerFree },
-    { CSR_WIFI_SME_VERSIONS_GET_CFM, CsrWifiSmeVersionsGetCfmSizeof, CsrWifiSmeVersionsGetCfmSer, CsrWifiSmeVersionsGetCfmDes, CsrWifiSmeVersionsGetCfmSerFree },
-    { CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, CsrWifiSmeWifiFlightmodeCfmSizeof, CsrWifiSmeWifiFlightmodeCfmSer, CsrWifiSmeWifiFlightmodeCfmDes, CsrWifiSmeWifiFlightmodeCfmSerFree },
-    { CSR_WIFI_SME_WIFI_OFF_IND, CsrWifiSmeWifiOffIndSizeof, CsrWifiSmeWifiOffIndSer, CsrWifiSmeWifiOffIndDes, CsrWifiSmeWifiOffIndSerFree },
-    { CSR_WIFI_SME_WIFI_OFF_CFM, CsrWifiSmeWifiOffCfmSizeof, CsrWifiSmeWifiOffCfmSer, CsrWifiSmeWifiOffCfmDes, CsrWifiSmeWifiOffCfmSerFree },
-    { CSR_WIFI_SME_WIFI_ON_CFM, CsrWifiSmeWifiOnCfmSizeof, CsrWifiSmeWifiOnCfmSer, CsrWifiSmeWifiOnCfmDes, CsrWifiSmeWifiOnCfmSerFree },
-    { CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, CsrWifiSmeCloakedSsidsSetCfmSizeof, CsrWifiSmeCloakedSsidsSetCfmSer, CsrWifiSmeCloakedSsidsSetCfmDes, CsrWifiSmeCloakedSsidsSetCfmSerFree },
-    { CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, CsrWifiSmeCloakedSsidsGetCfmSizeof, CsrWifiSmeCloakedSsidsGetCfmSer, CsrWifiSmeCloakedSsidsGetCfmDes, CsrWifiSmeCloakedSsidsGetCfmSerFree },
-    { CSR_WIFI_SME_WIFI_ON_IND, CsrWifiSmeWifiOnIndSizeof, CsrWifiSmeWifiOnIndSer, CsrWifiSmeWifiOnIndDes, CsrWifiSmeWifiOnIndSerFree },
-    { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, CsrWifiSmeSmeCommonConfigGetCfmSizeof, CsrWifiSmeSmeCommonConfigGetCfmSer, CsrWifiSmeSmeCommonConfigGetCfmDes, CsrWifiSmeSmeCommonConfigGetCfmSerFree },
-    { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, CsrWifiSmeSmeCommonConfigSetCfmSizeof, CsrWifiSmeSmeCommonConfigSetCfmSer, CsrWifiSmeSmeCommonConfigSetCfmDes, CsrWifiSmeSmeCommonConfigSetCfmSerFree },
-    { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, CsrWifiSmeInterfaceCapabilityGetCfmSizeof, CsrWifiSmeInterfaceCapabilityGetCfmSer, CsrWifiSmeInterfaceCapabilityGetCfmDes, CsrWifiSmeInterfaceCapabilityGetCfmSerFree },
-    { CSR_WIFI_SME_ERROR_IND, CsrWifiSmeErrorIndSizeof, CsrWifiSmeErrorIndSer, CsrWifiSmeErrorIndDes, CsrWifiSmeErrorIndSerFree },
-    { CSR_WIFI_SME_INFO_IND, CsrWifiSmeInfoIndSizeof, CsrWifiSmeInfoIndSer, CsrWifiSmeInfoIndDes, CsrWifiSmeInfoIndSerFree },
-    { CSR_WIFI_SME_CORE_DUMP_IND, CsrWifiSmeCoreDumpIndSizeof, CsrWifiSmeCoreDumpIndSer, CsrWifiSmeCoreDumpIndDes, CsrWifiSmeCoreDumpIndSerFree },
-    { CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, CsrWifiSmeAmpStatusChangeIndSizeof, CsrWifiSmeAmpStatusChangeIndSer, CsrWifiSmeAmpStatusChangeIndDes, CsrWifiSmeAmpStatusChangeIndSerFree },
-    { CSR_WIFI_SME_WPS_CONFIGURATION_CFM, CsrWifiSmeWpsConfigurationCfmSizeof, CsrWifiSmeWpsConfigurationCfmSer, CsrWifiSmeWpsConfigurationCfmDes, CsrWifiSmeWpsConfigurationCfmSerFree },
-
-    { 0, NULL, NULL, NULL, NULL },
-};
-
-CsrMsgConvMsgEntry* CsrWifiSmeConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
-{
-    if (msgType & CSR_PRIM_UPSTREAM)
-    {
-        u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT;
-        if (idx < (CSR_WIFI_SME_PRIM_UPSTREAM_COUNT + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT) &&
-            csrwifisme_conv_lut[idx].msgType == msgType)
-        {
-            return &csrwifisme_conv_lut[idx];
-        }
-    }
-    else
-    {
-        if (msgType < CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT &&
-            csrwifisme_conv_lut[msgType].msgType == msgType)
-        {
-            return &csrwifisme_conv_lut[msgType];
-        }
-    }
-    return NULL;
-}
-
-
-void CsrWifiSmeConverterInit(void)
-{
-    CsrMsgConvInsert(CSR_WIFI_SME_PRIM, csrwifisme_conv_lut);
-    CsrMsgConvCustomLookupRegister(CSR_WIFI_SME_PRIM, CsrWifiSmeConverterLookup);
-}
-
-
-#ifdef CSR_LOG_ENABLE
-static const CsrLogPrimitiveInformation csrwifisme_conv_info = {
-    CSR_WIFI_SME_PRIM,
-    (char *)"CSR_WIFI_SME_PRIM",
-    csrwifisme_conv_lut
-};
-const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void)
-{
-    return &csrwifisme_conv_info;
-}
-
-
-#endif /* CSR_LOG_ENABLE */
-#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */
diff --git a/drivers/staging/csr/csr_wifi_sme_converter_init.h b/drivers/staging/csr/csr_wifi_sme_converter_init.h
deleted file mode 100644 (file)
index ba5e4b4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_CONVERTER_INIT_H__
-#define CSR_WIFI_SME_CONVERTER_INIT_H__
-
-#ifndef EXCLUDE_CSR_WIFI_SME_MODULE
-
-#include "csr_msgconv.h"
-
-#ifdef CSR_LOG_ENABLE
-#include "csr_log.h"
-
-extern const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void);
-#endif /* CSR_LOG_ENABLE */
-
-extern void CsrWifiSmeConverterInit(void);
-
-#else /* EXCLUDE_CSR_WIFI_SME_MODULE */
-
-#define CsrWifiSmeConverterInit()
-
-#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */
-
-#endif /* CSR_WIFI_SME_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c
deleted file mode 100644 (file)
index 03b5ddb..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_sme_prim.h"
-#include "csr_wifi_sme_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiSmeFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_SME_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_SME_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-
-    switch (*((CsrWifiSmePrim *) message))
-    {
-        case CSR_WIFI_SME_BLACKLIST_REQ:
-        {
-            CsrWifiSmeBlacklistReq *p = (CsrWifiSmeBlacklistReq *)message;
-            kfree(p->setAddresses);
-            p->setAddresses = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ:
-        {
-            CsrWifiSmeCalibrationDataSetReq *p = (CsrWifiSmeCalibrationDataSetReq *)message;
-            kfree(p->calibrationData);
-            p->calibrationData = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CONNECT_REQ:
-        {
-            CsrWifiSmeConnectReq *p = (CsrWifiSmeConnectReq *)message;
-            kfree(p->connectionConfig.mlmeAssociateReqInformationElements);
-            p->connectionConfig.mlmeAssociateReqInformationElements = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MIB_GET_NEXT_REQ:
-        {
-            CsrWifiSmeMibGetNextReq *p = (CsrWifiSmeMibGetNextReq *)message;
-            kfree(p->mibAttribute);
-            p->mibAttribute = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MIB_GET_REQ:
-        {
-            CsrWifiSmeMibGetReq *p = (CsrWifiSmeMibGetReq *)message;
-            kfree(p->mibAttribute);
-            p->mibAttribute = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MIB_SET_REQ:
-        {
-            CsrWifiSmeMibSetReq *p = (CsrWifiSmeMibSetReq *)message;
-            kfree(p->mibAttribute);
-            p->mibAttribute = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MULTICAST_ADDRESS_REQ:
-        {
-            CsrWifiSmeMulticastAddressReq *p = (CsrWifiSmeMulticastAddressReq *)message;
-            kfree(p->setAddresses);
-            p->setAddresses = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_PACKET_FILTER_SET_REQ:
-        {
-            CsrWifiSmePacketFilterSetReq *p = (CsrWifiSmePacketFilterSetReq *)message;
-            kfree(p->filter);
-            p->filter = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_PMKID_REQ:
-        {
-            CsrWifiSmePmkidReq *p = (CsrWifiSmePmkidReq *)message;
-            kfree(p->setPmkids);
-            p->setPmkids = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_SCAN_CONFIG_SET_REQ:
-        {
-            CsrWifiSmeScanConfigSetReq *p = (CsrWifiSmeScanConfigSetReq *)message;
-            kfree(p->scanConfig.passiveChannelList);
-            p->scanConfig.passiveChannelList = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_SCAN_FULL_REQ:
-        {
-            CsrWifiSmeScanFullReq *p = (CsrWifiSmeScanFullReq *)message;
-            kfree(p->ssid);
-            p->ssid = NULL;
-            kfree(p->channelList);
-            p->channelList = NULL;
-            kfree(p->probeIe);
-            p->probeIe = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_TSPEC_REQ:
-        {
-            CsrWifiSmeTspecReq *p = (CsrWifiSmeTspecReq *)message;
-            kfree(p->tspec);
-            p->tspec = NULL;
-            kfree(p->tclas);
-            p->tclas = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ:
-        {
-            CsrWifiSmeWifiFlightmodeReq *p = (CsrWifiSmeWifiFlightmodeReq *)message;
-            {
-                u16 i1;
-                for (i1 = 0; i1 < p->mibFilesCount; i1++)
-                {
-                    kfree(p->mibFiles[i1].data);
-                    p->mibFiles[i1].data = NULL;
-                }
-            }
-            kfree(p->mibFiles);
-            p->mibFiles = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_WIFI_ON_REQ:
-        {
-            CsrWifiSmeWifiOnReq *p = (CsrWifiSmeWifiOnReq *)message;
-            {
-                u16 i1;
-                for (i1 = 0; i1 < p->mibFilesCount; i1++)
-                {
-                    kfree(p->mibFiles[i1].data);
-                    p->mibFiles[i1].data = NULL;
-                }
-            }
-            kfree(p->mibFiles);
-            p->mibFiles = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ:
-        {
-            CsrWifiSmeCloakedSsidsSetReq *p = (CsrWifiSmeCloakedSsidsSetReq *)message;
-            kfree(p->cloakedSsids.cloakedSsids);
-            p->cloakedSsids.cloakedSsids = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_WPS_CONFIGURATION_REQ:
-        {
-            CsrWifiSmeWpsConfigurationReq *p = (CsrWifiSmeWpsConfigurationReq *)message;
-            kfree(p->wpsConfig.secondaryDeviceType);
-            p->wpsConfig.secondaryDeviceType = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_SET_REQ:
-        {
-            CsrWifiSmeSetReq *p = (CsrWifiSmeSetReq *)message;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c
deleted file mode 100644 (file)
index c04767b..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/slab.h>
-#include "csr_wifi_sme_prim.h"
-#include "csr_wifi_sme_lib.h"
-
-/*----------------------------------------------------------------------------*
- *  NAME
- *      CsrWifiSmeFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *
- *
- *  PARAMETERS
- *      eventClass: only the value CSR_WIFI_SME_PRIM will be handled
- *      message:    the message to free
- *----------------------------------------------------------------------------*/
-void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message)
-{
-    if (eventClass != CSR_WIFI_SME_PRIM)
-    {
-        return;
-    }
-    if (NULL == message)
-    {
-        return;
-    }
-
-    switch (*((CsrWifiSmePrim *) message))
-    {
-        case CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND:
-        {
-            CsrWifiSmeAssociationCompleteInd *p = (CsrWifiSmeAssociationCompleteInd *)message;
-            kfree(p->connectionInfo.beaconFrame);
-            p->connectionInfo.beaconFrame = NULL;
-            kfree(p->connectionInfo.associationReqFrame);
-            p->connectionInfo.associationReqFrame = NULL;
-            kfree(p->connectionInfo.associationRspFrame);
-            p->connectionInfo.associationRspFrame = NULL;
-            kfree(p->connectionInfo.assocScanInfoElements);
-            p->connectionInfo.assocScanInfoElements = NULL;
-            kfree(p->connectionInfo.assocReqInfoElements);
-            p->connectionInfo.assocReqInfoElements = NULL;
-            kfree(p->connectionInfo.assocRspInfoElements);
-            p->connectionInfo.assocRspInfoElements = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_BLACKLIST_CFM:
-        {
-            CsrWifiSmeBlacklistCfm *p = (CsrWifiSmeBlacklistCfm *)message;
-            kfree(p->getAddresses);
-            p->getAddresses = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM:
-        {
-            CsrWifiSmeCalibrationDataGetCfm *p = (CsrWifiSmeCalibrationDataGetCfm *)message;
-            kfree(p->calibrationData);
-            p->calibrationData = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM:
-        {
-            CsrWifiSmeConnectionConfigGetCfm *p = (CsrWifiSmeConnectionConfigGetCfm *)message;
-            kfree(p->connectionConfig.mlmeAssociateReqInformationElements);
-            p->connectionConfig.mlmeAssociateReqInformationElements = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CONNECTION_INFO_GET_CFM:
-        {
-            CsrWifiSmeConnectionInfoGetCfm *p = (CsrWifiSmeConnectionInfoGetCfm *)message;
-            kfree(p->connectionInfo.beaconFrame);
-            p->connectionInfo.beaconFrame = NULL;
-            kfree(p->connectionInfo.associationReqFrame);
-            p->connectionInfo.associationReqFrame = NULL;
-            kfree(p->connectionInfo.associationRspFrame);
-            p->connectionInfo.associationRspFrame = NULL;
-            kfree(p->connectionInfo.assocScanInfoElements);
-            p->connectionInfo.assocScanInfoElements = NULL;
-            kfree(p->connectionInfo.assocReqInfoElements);
-            p->connectionInfo.assocReqInfoElements = NULL;
-            kfree(p->connectionInfo.assocRspInfoElements);
-            p->connectionInfo.assocRspInfoElements = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MEDIA_STATUS_IND:
-        {
-            CsrWifiSmeMediaStatusInd *p = (CsrWifiSmeMediaStatusInd *)message;
-            kfree(p->connectionInfo.beaconFrame);
-            p->connectionInfo.beaconFrame = NULL;
-            kfree(p->connectionInfo.associationReqFrame);
-            p->connectionInfo.associationReqFrame = NULL;
-            kfree(p->connectionInfo.associationRspFrame);
-            p->connectionInfo.associationRspFrame = NULL;
-            kfree(p->connectionInfo.assocScanInfoElements);
-            p->connectionInfo.assocScanInfoElements = NULL;
-            kfree(p->connectionInfo.assocReqInfoElements);
-            p->connectionInfo.assocReqInfoElements = NULL;
-            kfree(p->connectionInfo.assocRspInfoElements);
-            p->connectionInfo.assocRspInfoElements = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MIB_GET_CFM:
-        {
-            CsrWifiSmeMibGetCfm *p = (CsrWifiSmeMibGetCfm *)message;
-            kfree(p->mibAttribute);
-            p->mibAttribute = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MIB_GET_NEXT_CFM:
-        {
-            CsrWifiSmeMibGetNextCfm *p = (CsrWifiSmeMibGetNextCfm *)message;
-            kfree(p->mibAttribute);
-            p->mibAttribute = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_MULTICAST_ADDRESS_CFM:
-        {
-            CsrWifiSmeMulticastAddressCfm *p = (CsrWifiSmeMulticastAddressCfm *)message;
-            kfree(p->getAddresses);
-            p->getAddresses = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND:
-        {
-            CsrWifiSmePmkidCandidateListInd *p = (CsrWifiSmePmkidCandidateListInd *)message;
-            kfree(p->pmkidCandidates);
-            p->pmkidCandidates = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_PMKID_CFM:
-        {
-            CsrWifiSmePmkidCfm *p = (CsrWifiSmePmkidCfm *)message;
-            kfree(p->getPmkids);
-            p->getPmkids = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_SCAN_CONFIG_GET_CFM:
-        {
-            CsrWifiSmeScanConfigGetCfm *p = (CsrWifiSmeScanConfigGetCfm *)message;
-            kfree(p->scanConfig.passiveChannelList);
-            p->scanConfig.passiveChannelList = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_SCAN_RESULT_IND:
-        {
-            CsrWifiSmeScanResultInd *p = (CsrWifiSmeScanResultInd *)message;
-            kfree(p->result.informationElements);
-            p->result.informationElements = NULL;
-            switch (p->result.p2pDeviceRole)
-            {
-                case CSR_WIFI_SME_P2P_ROLE_GO:
-                {
-                    u16 i4;
-                    for (i4 = 0; i4 < p->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                    {
-                        kfree(p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
-                        p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
-                    }
-                }
-                    kfree(p->result.deviceInfo.groupInfo.p2PClientInfo);
-                    p->result.deviceInfo.groupInfo.p2PClientInfo = NULL;
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-                    kfree(p->result.deviceInfo.standalonedevInfo.secDeviceType);
-                    p->result.deviceInfo.standalonedevInfo.secDeviceType = NULL;
-                    break;
-                default:
-                    break;
-            }
-            break;
-        }
-        case CSR_WIFI_SME_SCAN_RESULTS_GET_CFM:
-        {
-            CsrWifiSmeScanResultsGetCfm *p = (CsrWifiSmeScanResultsGetCfm *)message;
-            {
-                u16 i1;
-                for (i1 = 0; i1 < p->scanResultsCount; i1++)
-                {
-                    kfree(p->scanResults[i1].informationElements);
-                    p->scanResults[i1].informationElements = NULL;
-                    switch (p->scanResults[i1].p2pDeviceRole)
-                    {
-                        case CSR_WIFI_SME_P2P_ROLE_GO:
-                        {
-                            u16 i4;
-                            for (i4 = 0; i4 < p->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                            {
-                                kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
-                                p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
-                            }
-                        }
-                            kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo);
-                            p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL;
-                            break;
-                        case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-                            kfree(p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType);
-                            p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL;
-                            break;
-                        default:
-                            break;
-                    }
-                }
-            }
-            kfree(p->scanResults);
-            p->scanResults = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_TSPEC_IND:
-        {
-            CsrWifiSmeTspecInd *p = (CsrWifiSmeTspecInd *)message;
-            kfree(p->tspec);
-            p->tspec = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_TSPEC_CFM:
-        {
-            CsrWifiSmeTspecCfm *p = (CsrWifiSmeTspecCfm *)message;
-            kfree(p->tspec);
-            p->tspec = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_VERSIONS_GET_CFM:
-        {
-            CsrWifiSmeVersionsGetCfm *p = (CsrWifiSmeVersionsGetCfm *)message;
-            kfree(p->versions.routerBuild);
-            p->versions.routerBuild = NULL;
-            kfree(p->versions.smeBuild);
-            p->versions.smeBuild = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM:
-        {
-            CsrWifiSmeCloakedSsidsGetCfm *p = (CsrWifiSmeCloakedSsidsGetCfm *)message;
-            kfree(p->cloakedSsids.cloakedSsids);
-            p->cloakedSsids.cloakedSsids = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_ERROR_IND:
-        {
-            CsrWifiSmeErrorInd *p = (CsrWifiSmeErrorInd *)message;
-            kfree(p->errorMessage);
-            p->errorMessage = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_INFO_IND:
-        {
-            CsrWifiSmeInfoInd *p = (CsrWifiSmeInfoInd *)message;
-            kfree(p->infoMessage);
-            p->infoMessage = NULL;
-            break;
-        }
-        case CSR_WIFI_SME_CORE_DUMP_IND:
-        {
-            CsrWifiSmeCoreDumpInd *p = (CsrWifiSmeCoreDumpInd *)message;
-            kfree(p->data);
-            p->data = NULL;
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_sme_lib.h b/drivers/staging/csr/csr_wifi_sme_lib.h
deleted file mode 100644 (file)
index 53cf126..0000000
+++ /dev/null
@@ -1,4303 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_LIB_H__
-#define CSR_WIFI_SME_LIB_H__
-
-#include "csr_sched.h"
-#include "csr_macro.h"
-#include "csr_msg_transport.h"
-
-#include "csr_wifi_lib.h"
-
-#include "csr_wifi_sme_prim.h"
-#include "csr_wifi_sme_task.h"
-
-
-#ifndef CSR_WIFI_SME_LIB_DESTINATION_QUEUE
-# ifdef CSR_WIFI_NME_ENABLE
-# include "csr_wifi_nme_task.h"
-# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_NME_IFACEQUEUE
-# else
-# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_SME_IFACEQUEUE
-# endif
-#endif
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiSmeFreeUpstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_SME upstream message. Does not
- *      free the message itself, and can only be used for upstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_SME upstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- *  CsrWifiSmeFreeDownstreamMessageContents
- *
- *  DESCRIPTION
- *      Free the allocated memory in a CSR_WIFI_SME downstream message. Does not
- *      free the message itself, and can only be used for downstream messages.
- *
- *  PARAMETERS
- *      Deallocates the resources in a CSR_WIFI_SME downstream message
- *----------------------------------------------------------------------------*/
-void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message);
-
-/*----------------------------------------------------------------------------*
- * Enum to string functions
- *----------------------------------------------------------------------------*/
-const char* CsrWifiSme80211NetworkTypeToString(CsrWifiSme80211NetworkType value);
-const char* CsrWifiSme80211PrivacyModeToString(CsrWifiSme80211PrivacyMode value);
-const char* CsrWifiSme80211dTrustLevelToString(CsrWifiSme80211dTrustLevel value);
-const char* CsrWifiSmeAmpStatusToString(CsrWifiSmeAmpStatus value);
-const char* CsrWifiSmeAuthModeToString(CsrWifiSmeAuthMode value);
-const char* CsrWifiSmeBasicUsabilityToString(CsrWifiSmeBasicUsability value);
-const char* CsrWifiSmeBssTypeToString(CsrWifiSmeBssType value);
-const char* CsrWifiSmeCoexSchemeToString(CsrWifiSmeCoexScheme value);
-const char* CsrWifiSmeControlIndicationToString(CsrWifiSmeControlIndication value);
-const char* CsrWifiSmeCtsProtectionTypeToString(CsrWifiSmeCtsProtectionType value);
-const char* CsrWifiSmeD3AutoScanModeToString(CsrWifiSmeD3AutoScanMode value);
-const char* CsrWifiSmeEncryptionToString(CsrWifiSmeEncryption value);
-const char* CsrWifiSmeFirmwareDriverInterfaceToString(CsrWifiSmeFirmwareDriverInterface value);
-const char* CsrWifiSmeHostPowerModeToString(CsrWifiSmeHostPowerMode value);
-const char* CsrWifiSmeIEEE80211ReasonToString(CsrWifiSmeIEEE80211Reason value);
-const char* CsrWifiSmeIEEE80211ResultToString(CsrWifiSmeIEEE80211Result value);
-const char* CsrWifiSmeIndicationsToString(CsrWifiSmeIndications value);
-const char* CsrWifiSmeKeyTypeToString(CsrWifiSmeKeyType value);
-const char* CsrWifiSmeListActionToString(CsrWifiSmeListAction value);
-const char* CsrWifiSmeMediaStatusToString(CsrWifiSmeMediaStatus value);
-const char* CsrWifiSmeP2pCapabilityToString(CsrWifiSmeP2pCapability value);
-const char* CsrWifiSmeP2pGroupCapabilityToString(CsrWifiSmeP2pGroupCapability value);
-const char* CsrWifiSmeP2pNoaConfigMethodToString(CsrWifiSmeP2pNoaConfigMethod value);
-const char* CsrWifiSmeP2pRoleToString(CsrWifiSmeP2pRole value);
-const char* CsrWifiSmeP2pStatusToString(CsrWifiSmeP2pStatus value);
-const char* CsrWifiSmePacketFilterModeToString(CsrWifiSmePacketFilterMode value);
-const char* CsrWifiSmePowerSaveLevelToString(CsrWifiSmePowerSaveLevel value);
-const char* CsrWifiSmePreambleTypeToString(CsrWifiSmePreambleType value);
-const char* CsrWifiSmeRadioIFToString(CsrWifiSmeRadioIF value);
-const char* CsrWifiSmeRegulatoryDomainToString(CsrWifiSmeRegulatoryDomain value);
-const char* CsrWifiSmeRoamReasonToString(CsrWifiSmeRoamReason value);
-const char* CsrWifiSmeScanTypeToString(CsrWifiSmeScanType value);
-const char* CsrWifiSmeTrafficTypeToString(CsrWifiSmeTrafficType value);
-const char* CsrWifiSmeTspecCtrlToString(CsrWifiSmeTspecCtrl value);
-const char* CsrWifiSmeTspecResultCodeToString(CsrWifiSmeTspecResultCode value);
-const char* CsrWifiSmeWepAuthModeToString(CsrWifiSmeWepAuthMode value);
-const char* CsrWifiSmeWepCredentialTypeToString(CsrWifiSmeWepCredentialType value);
-const char* CsrWifiSmeWmmModeToString(CsrWifiSmeWmmMode value);
-const char* CsrWifiSmeWmmQosInfoToString(CsrWifiSmeWmmQosInfo value);
-const char* CsrWifiSmeWpsConfigTypeToString(CsrWifiSmeWpsConfigType value);
-const char* CsrWifiSmeWpsDeviceCategoryToString(CsrWifiSmeWpsDeviceCategory value);
-const char* CsrWifiSmeWpsDeviceSubCategoryToString(CsrWifiSmeWpsDeviceSubCategory value);
-const char* CsrWifiSmeWpsDpidToString(CsrWifiSmeWpsDpid value);
-const char* CsrWifiSmeWpsRegistrationToString(CsrWifiSmeWpsRegistration value);
-
-
-/*----------------------------------------------------------------------------*
- * CsrPrim Type toString function.
- * Converts a message type to the String name of the Message
- *----------------------------------------------------------------------------*/
-const char* CsrWifiSmePrimTypeToString(CsrPrim msgType);
-
-/*----------------------------------------------------------------------------*
- * Lookup arrays for PrimType name Strings
- *----------------------------------------------------------------------------*/
-extern const char *CsrWifiSmeUpstreamPrimNames[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT];
-extern const char *CsrWifiSmeDownstreamPrimNames[CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT];
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeActivateReqSend
-
-  DESCRIPTION
-    The WMA sends this primitive to activate the SME.
-    The WMA must activate the SME before it can send any other primitive.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeActivateReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeActivateReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_REQ, dst__, src__);
-
-#define CsrWifiSmeActivateReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeActivateReq *msg__; \
-        CsrWifiSmeActivateReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeActivateReqSend(src__) \
-    CsrWifiSmeActivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeActivateCfmSend
-
-  DESCRIPTION
-    The SME sends this primitive when the activation is complete.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeActivateCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeActivateCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeActivateCfm *msg__; \
-        CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeActivateCfmSend(dst__, status__) \
-    CsrWifiSmeActivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the adHocConfig parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeAdhocConfigGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeAdhocConfigGetReq *msg__; \
-        CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAdhocConfigGetReqSend(src__) \
-    CsrWifiSmeAdhocConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue       - Destination Task Queue
-    status      - Reports the result of the request
-    adHocConfig - Contains the values used when starting an Ad-hoc (IBSS)
-                  connection.
-
-*******************************************************************************/
-#define CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->adHocConfig = (adHocConfig__);
-
-#define CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, src__, status__, adHocConfig__) \
-    { \
-        CsrWifiSmeAdhocConfigGetCfm *msg__; \
-        CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAdhocConfigGetCfmSend(dst__, status__, adHocConfig__) \
-    CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, adHocConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the adHocConfig parameter.
-
-  PARAMETERS
-    queue       - Message Source Task Queue (Cfm's will be sent to this Queue)
-    adHocConfig - Sets the values to use when starting an ad hoc network.
-
-*******************************************************************************/
-#define CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, dst__, src__); \
-    msg__->adHocConfig = (adHocConfig__);
-
-#define CsrWifiSmeAdhocConfigSetReqSendTo(dst__, src__, adHocConfig__) \
-    { \
-        CsrWifiSmeAdhocConfigSetReq *msg__; \
-        CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAdhocConfigSetReqSend(src__, adHocConfig__) \
-    CsrWifiSmeAdhocConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, adHocConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeAdhocConfigSetCfm *msg__; \
-        CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAdhocConfigSetCfmSend(dst__, status__) \
-    CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAmpStatusChangeIndSend
-
-  DESCRIPTION
-    Indication of change to AMP activity.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface on which the AMP activity changed.
-    ampStatus    - The new status of AMP activity.Range: {AMP_ACTIVE,
-                   AMP_INACTIVE}.
-
-*******************************************************************************/
-#define CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAmpStatusChangeInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->ampStatus = (ampStatus__);
-
-#define CsrWifiSmeAmpStatusChangeIndSendTo(dst__, src__, interfaceTag__, ampStatus__) \
-    { \
-        CsrWifiSmeAmpStatusChangeInd *msg__; \
-        CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAmpStatusChangeIndSend(dst__, interfaceTag__, ampStatus__) \
-    CsrWifiSmeAmpStatusChangeIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, ampStatus__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAssociationCompleteIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it completes an attempt to associate with an AP. If
-    the association was successful, status will be set to
-    CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be
-    set to appropriate error codes.
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the association procedure
-    connectionInfo - This parameter is relevant only if result is
-                     CSR_WIFI_SME_STATUS_SUCCESS:
-                     it points to the connection information for the new network
-    deauthReason   - This parameter is relevant only if result is not
-                     CSR_WIFI_SME_STATUS_SUCCESS:
-                     if the AP deauthorised the station, it gives the reason of
-                     the deauthorization
-
-*******************************************************************************/
-#define CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->connectionInfo = (connectionInfo__); \
-    msg__->deauthReason = (deauthReason__);
-
-#define CsrWifiSmeAssociationCompleteIndSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
-    { \
-        CsrWifiSmeAssociationCompleteInd *msg__; \
-        CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAssociationCompleteIndSend(dst__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
-    CsrWifiSmeAssociationCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__, deauthReason__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAssociationStartIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it begins an attempt to associate with an AP.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    address      - BSSID of the associating network
-    ssid         - Service Set identifier of the associating network
-
-*******************************************************************************/
-#define CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_START_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->address = (address__); \
-    msg__->ssid = (ssid__);
-
-#define CsrWifiSmeAssociationStartIndSendTo(dst__, src__, interfaceTag__, address__, ssid__) \
-    { \
-        CsrWifiSmeAssociationStartInd *msg__; \
-        CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeAssociationStartIndSend(dst__, interfaceTag__, address__, ssid__) \
-    CsrWifiSmeAssociationStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, address__, ssid__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeBlacklistReqSend
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to notify the
-    driver of any networks that should not be connected to. The interface
-    allows the wireless manager application to query, add, remove, and flush
-    the BSSIDs that the driver may not connect or roam to.
-    When this primitive adds to the black list the BSSID to which the SME is
-    currently connected, the SME will try to roam, if applicable, to another
-    BSSID in the same ESS; if the roaming procedure fails, the SME will
-    disconnect.
-
-  PARAMETERS
-    queue           - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    action          - The value of the CsrWifiSmeListAction parameter instructs
-                      the driver to modify or provide the list of blacklisted
-                      networks.
-    setAddressCount - Number of BSSIDs sent with this primitive
-    setAddresses    - Pointer to the list of BBSIDs sent with the primitive, set
-                      to NULL if none is sent.
-
-*******************************************************************************/
-#define CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->action = (action__); \
-    msg__->setAddressCount = (setAddressCount__); \
-    msg__->setAddresses = (setAddresses__);
-
-#define CsrWifiSmeBlacklistReqSendTo(dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
-    { \
-        CsrWifiSmeBlacklistReq *msg__; \
-        CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeBlacklistReqSend(src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
-    CsrWifiSmeBlacklistReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressCount__, setAddresses__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeBlacklistCfmSend
-
-  DESCRIPTION
-    The SME will call this primitive when the action on the blacklist has
-    completed. For a GET action, this primitive also reports the list of
-    BBSIDs in the blacklist.
-
-  PARAMETERS
-    queue           - Destination Task Queue
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    status          - Reports the result of the request
-    action          - Action in the request
-    getAddressCount - This parameter is only relevant if action is
-                      CSR_WIFI_SME_LIST_ACTION_GET:
-                      number of BSSIDs sent with this primitive
-    getAddresses    - Pointer to the list of BBSIDs sent with the primitive, set
-                      to NULL if none is sent.
-
-*******************************************************************************/
-#define CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->action = (action__); \
-    msg__->getAddressCount = (getAddressCount__); \
-    msg__->getAddresses = (getAddresses__);
-
-#define CsrWifiSmeBlacklistCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
-    { \
-        CsrWifiSmeBlacklistCfm *msg__; \
-        CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeBlacklistCfmSend(dst__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
-    CsrWifiSmeBlacklistCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressCount__, getAddresses__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataGetReqSend
-
-  DESCRIPTION
-    This primitive retrieves the Wi-Fi radio calibration data.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeCalibrationDataGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeCalibrationDataGetReq *msg__; \
-        CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCalibrationDataGetReqSend(src__) \
-    CsrWifiSmeCalibrationDataGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue                 - Destination Task Queue
-    status                - Reports the result of the request
-    calibrationDataLength - Number of bytes in the buffer pointed by
-                            calibrationData
-    calibrationData       - Pointer to a buffer of length calibrationDataLength
-                            containing the calibration data
-
-*******************************************************************************/
-#define CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->calibrationDataLength = (calibrationDataLength__); \
-    msg__->calibrationData = (calibrationData__);
-
-#define CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, src__, status__, calibrationDataLength__, calibrationData__) \
-    { \
-        CsrWifiSmeCalibrationDataGetCfm *msg__; \
-        CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCalibrationDataGetCfmSend(dst__, status__, calibrationDataLength__, calibrationData__) \
-    CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, calibrationDataLength__, calibrationData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataSetReqSend
-
-  DESCRIPTION
-    This primitive sets the Wi-Fi radio calibration data.
-    The usage of the primitive with proper calibration data will avoid
-    time-consuming configuration after power-up.
-
-  PARAMETERS
-    queue                 - Message Source Task Queue (Cfm's will be sent to this Queue)
-    calibrationDataLength - Number of bytes in the buffer pointed by
-                            calibrationData
-    calibrationData       - Pointer to a buffer of length calibrationDataLength
-                            containing the calibration data
-
-*******************************************************************************/
-#define CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, dst__, src__); \
-    msg__->calibrationDataLength = (calibrationDataLength__); \
-    msg__->calibrationData = (calibrationData__);
-
-#define CsrWifiSmeCalibrationDataSetReqSendTo(dst__, src__, calibrationDataLength__, calibrationData__) \
-    { \
-        CsrWifiSmeCalibrationDataSetReq *msg__; \
-        CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCalibrationDataSetReqSend(src__, calibrationDataLength__, calibrationData__) \
-    CsrWifiSmeCalibrationDataSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, calibrationDataLength__, calibrationData__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeCalibrationDataSetCfm *msg__; \
-        CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCalibrationDataSetCfmSend(dst__, status__) \
-    CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the CcxConfig parameter.
-    CURRENTLY NOT SUPPORTED.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeCcxConfigGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeCcxConfigGetReq *msg__; \
-        CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCcxConfigGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeCcxConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    ccxConfig    - Currently not supported
-
-*******************************************************************************/
-#define CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->ccxConfig = (ccxConfig__);
-
-#define CsrWifiSmeCcxConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, ccxConfig__) \
-    { \
-        CsrWifiSmeCcxConfigGetCfm *msg__; \
-        CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCcxConfigGetCfmSend(dst__, interfaceTag__, status__, ccxConfig__) \
-    CsrWifiSmeCcxConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, ccxConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the CcxConfig parameter.
-    CURRENTLY NOT SUPPORTED.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    ccxConfig    - Currently not supported
-
-*******************************************************************************/
-#define CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->ccxConfig = (ccxConfig__);
-
-#define CsrWifiSmeCcxConfigSetReqSendTo(dst__, src__, interfaceTag__, ccxConfig__) \
-    { \
-        CsrWifiSmeCcxConfigSetReq *msg__; \
-        CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCcxConfigSetReqSend(src__, interfaceTag__, ccxConfig__) \
-    CsrWifiSmeCcxConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, ccxConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeCcxConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeCcxConfigSetCfm *msg__; \
-        CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCcxConfigSetCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeCcxConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the CloakedSsids parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeCloakedSsidsGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeCloakedSsidsGetReq *msg__; \
-        CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCloakedSsidsGetReqSend(src__) \
-    CsrWifiSmeCloakedSsidsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    status       - Reports the result of the request
-    cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for
-                   by the driver
-
-*******************************************************************************/
-#define CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->cloakedSsids = (cloakedSsids__);
-
-#define CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, src__, status__, cloakedSsids__) \
-    { \
-        CsrWifiSmeCloakedSsidsGetCfm *msg__; \
-        CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCloakedSsidsGetCfmSend(dst__, status__, cloakedSsids__) \
-    CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, cloakedSsids__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsSetReqSend
-
-  DESCRIPTION
-    This primitive sets the list of cloaked SSIDs for which the WMA possesses
-    profiles.
-    When the driver detects a cloaked AP, the SME will explicitly scan for it
-    using the list of cloaked SSIDs provided it, and, if the scan succeeds,
-    it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND
-    (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    cloakedSsids - Sets the list of cloaked SSIDs
-
-*******************************************************************************/
-#define CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, dst__, src__); \
-    msg__->cloakedSsids = (cloakedSsids__);
-
-#define CsrWifiSmeCloakedSsidsSetReqSendTo(dst__, src__, cloakedSsids__) \
-    { \
-        CsrWifiSmeCloakedSsidsSetReq *msg__; \
-        CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCloakedSsidsSetReqSend(src__, cloakedSsids__) \
-    CsrWifiSmeCloakedSsidsSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, cloakedSsids__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeCloakedSsidsSetCfm *msg__; \
-        CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCloakedSsidsSetCfmSend(dst__, status__) \
-    CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the CoexConfig parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeCoexConfigGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeCoexConfigGetReq *msg__; \
-        CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoexConfigGetReqSend(src__) \
-    CsrWifiSmeCoexConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    status     - Reports the result of the request
-    coexConfig - Reports the parameters used to configure the coexistence
-                 behaviour
-
-*******************************************************************************/
-#define CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->coexConfig = (coexConfig__);
-
-#define CsrWifiSmeCoexConfigGetCfmSendTo(dst__, src__, status__, coexConfig__) \
-    { \
-        CsrWifiSmeCoexConfigGetCfm *msg__; \
-        CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoexConfigGetCfmSend(dst__, status__, coexConfig__) \
-    CsrWifiSmeCoexConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the CoexConfig parameter.
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    coexConfig - Configures the coexistence behaviour
-
-*******************************************************************************/
-#define CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_REQ, dst__, src__); \
-    msg__->coexConfig = (coexConfig__);
-
-#define CsrWifiSmeCoexConfigSetReqSendTo(dst__, src__, coexConfig__) \
-    { \
-        CsrWifiSmeCoexConfigSetReq *msg__; \
-        CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoexConfigSetReqSend(src__, coexConfig__) \
-    CsrWifiSmeCoexConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, coexConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeCoexConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeCoexConfigSetCfm *msg__; \
-        CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoexConfigSetCfmSend(dst__, status__) \
-    CsrWifiSmeCoexConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexInfoGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the CoexInfo parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeCoexInfoGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeCoexInfoGetReq *msg__; \
-        CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoexInfoGetReqSend(src__) \
-    CsrWifiSmeCoexInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexInfoGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue    - Destination Task Queue
-    status   - Reports the result of the request
-    coexInfo - Reports information and state related to coexistence.
-
-*******************************************************************************/
-#define CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->coexInfo = (coexInfo__);
-
-#define CsrWifiSmeCoexInfoGetCfmSendTo(dst__, src__, status__, coexInfo__) \
-    { \
-        CsrWifiSmeCoexInfoGetCfm *msg__; \
-        CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoexInfoGetCfmSend(dst__, status__, coexInfo__) \
-    CsrWifiSmeCoexInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexInfo__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to start the
-    process of joining an 802.11 wireless network or to start an ad hoc
-    network.
-    The structure pointed by connectionConfig contains parameters describing
-    the network to join or, in case of an ad hoc network, to host or join.
-    The SME will select a network, perform the IEEE 802.11 Join, Authenticate
-    and Associate exchanges.
-    The SME selects the networks from the current scan list that match both
-    the SSID and BSSID, however either or both of these may be the wildcard
-    value. Using this rule, the following operations are possible:
-      * To connect to a network by name, specify the SSID and set the BSSID to
-        0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible,
-        the SME will select the one with the strongest signal.
-      * To connect to a specific network, specify the BSSID. The SSID is
-        optional, but if given it must match the SSID of the network. An empty
-        SSID may be specified by setting the SSID length to zero. Please note
-        that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF
-        0xFF 0xFF), the SME will not attempt to roam if signal conditions become
-        poor, even if there is an alternative AP with an SSID that matches the
-        current network SSID.
-      * To connect to any network matching the other parameters (i.e. security,
-        etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF
-        0xFF 0xFF 0xFF. In this case, the SME will order all available networks
-        by their signal strengths and will iterate through this list until it
-        successfully connects.
-    NOTE: Specifying the BSSID will restrict the selection to one specific
-    network. If SSID and BSSID are given, they must both match the network
-    for it to be selected. To select a network based on the SSID only, the
-    wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF
-    0xFF 0xFF.
-    The SME will try to connect to each network that matches the provided
-    parameters, one by one, until it succeeds or has tried unsuccessfully
-    with all the matching networks.
-    If there is no network that matches the parameters and the request allows
-    to host an ad hoc network, the SME will advertise a new ad hoc network
-    instead.
-    If the SME cannot connect, it will notify the failure in the confirm.
-
-  PARAMETERS
-    queue            - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    connectionConfig - Describes the candidate network to join or to host.
-
-*******************************************************************************/
-#define CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->connectionConfig = (connectionConfig__);
-
-#define CsrWifiSmeConnectReqSendTo(dst__, src__, interfaceTag__, connectionConfig__) \
-    { \
-        CsrWifiSmeConnectReq *msg__; \
-        CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectReqSend(src__, interfaceTag__, connectionConfig__) \
-    CsrWifiSmeConnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, connectionConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectCfmSend
-
-  DESCRIPTION
-    The SME calls this primitive when the connection exchange is complete or
-    all connection attempts fail.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request.
-                   CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to
-                   locate the requested AP failed
-
-*******************************************************************************/
-#define CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeConnectCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeConnectCfm *msg__; \
-        CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeConnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the ConnectionConfig parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeConnectionConfigGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeConnectionConfigGetReq *msg__; \
-        CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionConfigGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeConnectionConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    status           - Reports the result of the request
-    connectionConfig - Parameters used by the SME for selecting a network
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->connectionConfig = (connectionConfig__);
-
-#define CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionConfig__) \
-    { \
-        CsrWifiSmeConnectionConfigGetCfm *msg__; \
-        CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionConfigGetCfmSend(dst__, interfaceTag__, status__, connectionConfig__) \
-    CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionInfoGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the ConnectionInfo parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeConnectionInfoGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeConnectionInfoGetReq *msg__; \
-        CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionInfoGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeConnectionInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionInfoGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the request
-    connectionInfo - Information about the current connection
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->connectionInfo = (connectionInfo__);
-
-#define CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__) \
-    { \
-        CsrWifiSmeConnectionInfoGetCfm *msg__; \
-        CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionInfoGetCfmSend(dst__, interfaceTag__, status__, connectionInfo__) \
-    CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionQualityIndSend
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it whenever the value of the current connection quality
-    parameters change by more than a certain configurable amount.
-    The wireless manager application may configure the trigger thresholds for
-    this indication using the field in smeConfig parameter of
-    CSR_WIFI_SME_SME_CONFIG_SET_REQ.
-    Connection quality messages can be suppressed by setting both thresholds
-    to zero.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    linkQuality  - Indicates the quality of the link
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_QUALITY_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->linkQuality = (linkQuality__);
-
-#define CsrWifiSmeConnectionQualityIndSendTo(dst__, src__, interfaceTag__, linkQuality__) \
-    { \
-        CsrWifiSmeConnectionQualityInd *msg__; \
-        CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionQualityIndSend(dst__, interfaceTag__, linkQuality__) \
-    CsrWifiSmeConnectionQualityIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, linkQuality__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionStatsGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the ConnectionStats parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeConnectionStatsGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeConnectionStatsGetReq *msg__; \
-        CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionStatsGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeConnectionStatsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionStatsGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue           - Destination Task Queue
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    status          - Reports the result of the request
-    connectionStats - Statistics for current connection.
-
-*******************************************************************************/
-#define CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->connectionStats = (connectionStats__);
-
-#define CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStats__) \
-    { \
-        CsrWifiSmeConnectionStatsGetCfm *msg__; \
-        CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeConnectionStatsGetCfmSend(dst__, interfaceTag__, status__, connectionStats__) \
-    CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionStats__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoreDumpIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive Wi-Fi Chip core dump data.
-    The core dump data may be fragmented and sent using more than one
-    indication.
-    To indicate that all the data has been sent, the last indication contains
-    a 'length' of 0 and 'data' of NULL.
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    dataLength - Number of bytes in the buffer pointed to by 'data'
-    data       - Pointer to the buffer containing 'dataLength' bytes of core
-                 dump data
-
-*******************************************************************************/
-#define CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CORE_DUMP_IND, dst__, src__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiSmeCoreDumpIndSendTo(dst__, src__, dataLength__, data__) \
-    { \
-        CsrWifiSmeCoreDumpInd *msg__; \
-        CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeCoreDumpIndSend(dst__, dataLength__, data__) \
-    CsrWifiSmeCoreDumpIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeactivateReqSend
-
-  DESCRIPTION
-    The WMA sends this primitive to deactivate the SME.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_REQ, dst__, src__);
-
-#define CsrWifiSmeDeactivateReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeDeactivateReq *msg__; \
-        CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeDeactivateReqSend(src__) \
-    CsrWifiSmeDeactivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeactivateCfmSend
-
-  DESCRIPTION
-    The SME sends this primitive when the deactivation is complete.
-    The WMA cannot send any more primitives until it actives the SME again
-    sending another CSR_WIFI_SME_ACTIVATE_REQ.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeDeactivateCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeDeactivateCfm *msg__; \
-        CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeDeactivateCfmSend(dst__, status__) \
-    CsrWifiSmeDeactivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDisconnectReqSend
-
-  DESCRIPTION
-    The wireless manager application may disconnect from the current network
-    by calling this primitive
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeDisconnectReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeDisconnectReq *msg__; \
-        CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeDisconnectReqSend(src__, interfaceTag__) \
-    CsrWifiSmeDisconnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDisconnectCfmSend
-
-  DESCRIPTION
-    On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a
-    disconnect operation, sending a CsrWifiSmeMediaStatusInd with
-    CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when
-    disconnection is complete.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeDisconnectCfm *msg__; \
-        CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeDisconnectCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeErrorIndSend
-
-  DESCRIPTION
-    Important error message indicating a error of some importance
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    errorMessage - Contains the error message.
-
-*******************************************************************************/
-#define CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ERROR_IND, dst__, src__); \
-    msg__->errorMessage = (errorMessage__);
-
-#define CsrWifiSmeErrorIndSendTo(dst__, src__, errorMessage__) \
-    { \
-        CsrWifiSmeErrorInd *msg__; \
-        CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeErrorIndSend(dst__, errorMessage__) \
-    CsrWifiSmeErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, errorMessage__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEventMaskSetReqSend
-
-  DESCRIPTION
-    The wireless manager application may register with the SME to receive
-    notification of interesting events. Indications will be sent only if the
-    wireless manager explicitly registers to be notified of that event.
-    indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask.
-
-  PARAMETERS
-    queue   - Message Source Task Queue (Cfm's will be sent to this Queue)
-    indMask - Set mask with values from CsrWifiSmeIndications
-
-*******************************************************************************/
-#define CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_REQ, dst__, src__); \
-    msg__->indMask = (indMask__);
-
-#define CsrWifiSmeEventMaskSetReqSendTo(dst__, src__, indMask__) \
-    { \
-        CsrWifiSmeEventMaskSetReq *msg__; \
-        CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeEventMaskSetReqSend(src__, indMask__) \
-    CsrWifiSmeEventMaskSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, indMask__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEventMaskSetCfmSend
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the request
-    primitive.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeEventMaskSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeEventMaskSetCfm *msg__; \
-        CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeEventMaskSetCfmSend(dst__, status__) \
-    CsrWifiSmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the hostConfig parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeHostConfigGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeHostConfigGetReq *msg__; \
-        CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeHostConfigGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeHostConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    hostConfig   - Current host power state.
-
-*******************************************************************************/
-#define CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->hostConfig = (hostConfig__);
-
-#define CsrWifiSmeHostConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, hostConfig__) \
-    { \
-        CsrWifiSmeHostConfigGetCfm *msg__; \
-        CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeHostConfigGetCfmSend(dst__, interfaceTag__, status__, hostConfig__) \
-    CsrWifiSmeHostConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, hostConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the hostConfig parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    hostConfig   - Communicates a change of host power state (for example, on
-                   mains power, on battery power etc) and of the periodicity of
-                   traffic data
-
-*******************************************************************************/
-#define CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->hostConfig = (hostConfig__);
-
-#define CsrWifiSmeHostConfigSetReqSendTo(dst__, src__, interfaceTag__, hostConfig__) \
-    { \
-        CsrWifiSmeHostConfigSetReq *msg__; \
-        CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeHostConfigSetReqSend(src__, interfaceTag__, hostConfig__) \
-    CsrWifiSmeHostConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, hostConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeHostConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeHostConfigSetCfm *msg__; \
-        CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeHostConfigSetCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeHostConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeIbssStationIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to indicate that a station has joined or
-    left the ad-hoc network.
-
-  PARAMETERS
-    queue       - Destination Task Queue
-    address     - MAC address of the station that has joined or left
-    isconnected - TRUE if the station joined, FALSE if the station left
-
-*******************************************************************************/
-#define CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_IBSS_STATION_IND, dst__, src__); \
-    msg__->address = (address__); \
-    msg__->isconnected = (isconnected__);
-
-#define CsrWifiSmeIbssStationIndSendTo(dst__, src__, address__, isconnected__) \
-    { \
-        CsrWifiSmeIbssStationInd *msg__; \
-        CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeIbssStationIndSend(dst__, address__, isconnected__) \
-    CsrWifiSmeIbssStationIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__, isconnected__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeInfoIndSend
-
-  DESCRIPTION
-    Message indicating a some info about current activity. Mostly of interest
-    in testing but may be useful in the field.
-
-  PARAMETERS
-    queue       - Destination Task Queue
-    infoMessage - Contains the message.
-
-*******************************************************************************/
-#define CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INFO_IND, dst__, src__); \
-    msg__->infoMessage = (infoMessage__);
-
-#define CsrWifiSmeInfoIndSendTo(dst__, src__, infoMessage__) \
-    { \
-        CsrWifiSmeInfoInd *msg__; \
-        CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeInfoIndSend(dst__, infoMessage__) \
-    CsrWifiSmeInfoIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, infoMessage__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeInterfaceCapabilityGetReqSend
-
-  DESCRIPTION
-    The Wireless Manager calls this primitive to ask the SME for the
-    capabilities of the supported interfaces
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeInterfaceCapabilityGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeInterfaceCapabilityGetReq *msg__; \
-        CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeInterfaceCapabilityGetReqSend(src__) \
-    CsrWifiSmeInterfaceCapabilityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeInterfaceCapabilityGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue         - Destination Task Queue
-    status        - Result of the request
-    numInterfaces - Number of the interfaces supported
-    capBitmap     - Points to the list of capabilities bitmaps provided for each
-                    interface.
-                    The bits represent the following capabilities:
-                    -bits 7 to 4-Reserved
-                    -bit 3-AMP
-                    -bit 2-P2P
-                    -bit 1-AP
-                    -bit 0-STA
-
-*******************************************************************************/
-#define CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->numInterfaces = (numInterfaces__); \
-    memcpy(msg__->capBitmap, (capBitmap__), sizeof(u8) * 2);
-
-#define CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, src__, status__, numInterfaces__, capBitmap__) \
-    { \
-        CsrWifiSmeInterfaceCapabilityGetCfm *msg__; \
-        CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeInterfaceCapabilityGetCfmSend(dst__, status__, numInterfaces__, capBitmap__) \
-    CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, numInterfaces__, capBitmap__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeKeyReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to add or remove
-    keys that the chip should use for encryption of data.
-    The interface allows the wireless manager application to add and remove
-    keys according to the specified action.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    action       - The value of the CsrWifiSmeListAction parameter instructs the
-                   driver to modify or provide the list of keys.
-                   CSR_WIFI_SME_LIST_ACTION_GET is not supported here.
-    key          - Key to be added or removed
-
-*******************************************************************************/
-#define CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->action = (action__); \
-    msg__->key = (key__);
-
-#define CsrWifiSmeKeyReqSendTo(dst__, src__, interfaceTag__, action__, key__) \
-    { \
-        CsrWifiSmeKeyReq *msg__; \
-        CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeKeyReqSend(src__, interfaceTag__, action__, key__) \
-    CsrWifiSmeKeyReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, key__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeKeyCfmSend
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the request
-    primitive.
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the request
-    action         - Action in the request
-    keyType        - Type of the key added/deleted
-    peerMacAddress - Peer MAC Address of the key added/deleted
-
-*******************************************************************************/
-#define CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->action = (action__); \
-    msg__->keyType = (keyType__); \
-    msg__->peerMacAddress = (peerMacAddress__);
-
-#define CsrWifiSmeKeyCfmSendTo(dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
-    { \
-        CsrWifiSmeKeyCfm *msg__; \
-        CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeKeyCfmSend(dst__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
-    CsrWifiSmeKeyCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, keyType__, peerMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeLinkQualityGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the LinkQuality parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeLinkQualityGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeLinkQualityGetReq *msg__; \
-        CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeLinkQualityGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeLinkQualityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeLinkQualityGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    linkQuality  - Indicates the quality of the link
-
-*******************************************************************************/
-#define CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->linkQuality = (linkQuality__);
-
-#define CsrWifiSmeLinkQualityGetCfmSendTo(dst__, src__, interfaceTag__, status__, linkQuality__) \
-    { \
-        CsrWifiSmeLinkQualityGetCfm *msg__; \
-        CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeLinkQualityGetCfmSend(dst__, interfaceTag__, status__, linkQuality__) \
-    CsrWifiSmeLinkQualityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, linkQuality__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMediaStatusIndSend
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it when a network connection is established, lost or has moved to
-    another AP.
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    mediaStatus    - Indicates the media status
-    connectionInfo - This parameter is relevant only if the mediaStatus is
-                     CSR_WIFI_SME_MEDIA_STATUS_CONNECTED:
-                     it points to the connection information for the new network
-    disassocReason - This parameter is relevant only if the mediaStatus is
-                     CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
-                     if a disassociation has occurred it gives the reason of the
-                     disassociation
-    deauthReason   - This parameter is relevant only if the mediaStatus is
-                     CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
-                     if a deauthentication has occurred it gives the reason of
-                     the deauthentication
-
-*******************************************************************************/
-#define CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MEDIA_STATUS_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->mediaStatus = (mediaStatus__); \
-    msg__->connectionInfo = (connectionInfo__); \
-    msg__->disassocReason = (disassocReason__); \
-    msg__->deauthReason = (deauthReason__);
-
-#define CsrWifiSmeMediaStatusIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
-    { \
-        CsrWifiSmeMediaStatusInd *msg__; \
-        CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMediaStatusIndSend(dst__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
-    CsrWifiSmeMediaStatusIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the MibConfig parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeMibConfigGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeMibConfigGetReq *msg__; \
-        CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibConfigGetReqSend(src__) \
-    CsrWifiSmeMibConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue     - Destination Task Queue
-    status    - Reports the result of the request
-    mibConfig - Reports various IEEE 802.11 attributes as currently configured
-
-*******************************************************************************/
-#define CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->mibConfig = (mibConfig__);
-
-#define CsrWifiSmeMibConfigGetCfmSendTo(dst__, src__, status__, mibConfig__) \
-    { \
-        CsrWifiSmeMibConfigGetCfm *msg__; \
-        CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibConfigGetCfmSend(dst__, status__, mibConfig__) \
-    CsrWifiSmeMibConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the MibConfig parameter.
-
-  PARAMETERS
-    queue     - Message Source Task Queue (Cfm's will be sent to this Queue)
-    mibConfig - Conveys the desired value of various IEEE 802.11 attributes as
-                currently configured
-
-*******************************************************************************/
-#define CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_REQ, dst__, src__); \
-    msg__->mibConfig = (mibConfig__);
-
-#define CsrWifiSmeMibConfigSetReqSendTo(dst__, src__, mibConfig__) \
-    { \
-        CsrWifiSmeMibConfigSetReq *msg__; \
-        CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibConfigSetReqSend(src__, mibConfig__) \
-    CsrWifiSmeMibConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeMibConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeMibConfigSetCfm *msg__; \
-        CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibConfigSetCfmSend(dst__, status__) \
-    CsrWifiSmeMibConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetCfmSend
-
-  DESCRIPTION
-    The SME calls this primitive to return the requested MIB variable values.
-
-  PARAMETERS
-    queue              - Destination Task Queue
-    status             - Reports the result of the request
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to the VarBind or VarBindList containing the
-                         names and values of the MIB variables requested
-
-*******************************************************************************/
-#define CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->mibAttributeLength = (mibAttributeLength__); \
-    msg__->mibAttribute = (mibAttribute__);
-
-#define CsrWifiSmeMibGetCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
-    { \
-        CsrWifiSmeMibGetCfm *msg__; \
-        CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibGetCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \
-    CsrWifiSmeMibGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetNextReqSend
-
-  DESCRIPTION
-    To read a sequence of MIB parameters, for example a table, call this
-    primitive to find the name of the next MIB variable
-
-  PARAMETERS
-    queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to a VarBind or VarBindList containing the
-                         name(s) of the MIB variable(s) to search from.
-
-*******************************************************************************/
-#define CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_REQ, dst__, src__); \
-    msg__->mibAttributeLength = (mibAttributeLength__); \
-    msg__->mibAttribute = (mibAttribute__);
-
-#define CsrWifiSmeMibGetNextReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
-    { \
-        CsrWifiSmeMibGetNextReq *msg__; \
-        CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibGetNextReqSend(src__, mibAttributeLength__, mibAttribute__) \
-    CsrWifiSmeMibGetNextReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetNextCfmSend
-
-  DESCRIPTION
-    The SME calls this primitive to return the requested MIB name(s).
-    The wireless manager application can then read the value of the MIB
-    variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided.
-
-  PARAMETERS
-    queue              - Destination Task Queue
-    status             - Reports the result of the request
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to a VarBind or VarBindList containing the
-                         name(s) of the MIB variable(s) lexicographically
-                         following the name(s) given in the request
-
-*******************************************************************************/
-#define CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->mibAttributeLength = (mibAttributeLength__); \
-    msg__->mibAttribute = (mibAttribute__);
-
-#define CsrWifiSmeMibGetNextCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
-    { \
-        CsrWifiSmeMibGetNextCfm *msg__; \
-        CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibGetNextCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \
-    CsrWifiSmeMibGetNextCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to retrieve one or
-    more MIB variables.
-
-  PARAMETERS
-    queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to the VarBind or VarBindList containing the
-                         names of the MIB variables to be retrieved
-
-*******************************************************************************/
-#define CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_REQ, dst__, src__); \
-    msg__->mibAttributeLength = (mibAttributeLength__); \
-    msg__->mibAttribute = (mibAttribute__);
-
-#define CsrWifiSmeMibGetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
-    { \
-        CsrWifiSmeMibGetReq *msg__; \
-        CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibGetReqSend(src__, mibAttributeLength__, mibAttribute__) \
-    CsrWifiSmeMibGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibSetReqSend
-
-  DESCRIPTION
-    The SME provides raw access to the MIB on the chip, which may be used by
-    some configuration or diagnostic utilities, but is not normally needed by
-    the wireless manager application.
-    The MIB access functions use BER encoded names (OID) of the MIB
-    parameters and BER encoded values, as described in the chip Host
-    Interface Protocol Specification.
-    The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information
-    Base Reference Guide'.
-    The wireless manager application calls this primitive to set one or more
-    MIB variables
-
-  PARAMETERS
-    queue              - Message Source Task Queue (Cfm's will be sent to this Queue)
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to the VarBind or VarBindList containing the
-                         names and values of the MIB variables to set
-
-*******************************************************************************/
-#define CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_REQ, dst__, src__); \
-    msg__->mibAttributeLength = (mibAttributeLength__); \
-    msg__->mibAttribute = (mibAttribute__);
-
-#define CsrWifiSmeMibSetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
-    { \
-        CsrWifiSmeMibSetReq *msg__; \
-        CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibSetReqSend(src__, mibAttributeLength__, mibAttribute__) \
-    CsrWifiSmeMibSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibSetCfmSend
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the set primitive.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMibSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeMibSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeMibSetCfm *msg__; \
-        CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMibSetCfmSend(dst__, status__) \
-    CsrWifiSmeMibSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMicFailureIndSend
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it whenever the chip firmware reports a MIC failure.
-
-  PARAMETERS
-    queue         - Destination Task Queue
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    secondFailure - TRUE if this indication is for a second failure in 60
-                    seconds
-    count         - The number of MIC failure events since the connection was
-                    established
-    address       - MAC address of the transmitter that caused the MIC failure
-    keyType       - Type of key for which the failure occurred
-
-*******************************************************************************/
-#define CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIC_FAILURE_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->secondFailure = (secondFailure__); \
-    msg__->count = (count__); \
-    msg__->address = (address__); \
-    msg__->keyType = (keyType__);
-
-#define CsrWifiSmeMicFailureIndSendTo(dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
-    { \
-        CsrWifiSmeMicFailureInd *msg__; \
-        CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMicFailureIndSend(dst__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
-    CsrWifiSmeMicFailureIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, secondFailure__, count__, address__, keyType__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMulticastAddressReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to specify the
-    multicast addresses which the chip should recognise. The interface allows
-    the wireless manager application to query, add, remove and flush the
-    multicast addresses for the network interface according to the specified
-    action.
-
-  PARAMETERS
-    queue             - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag      - Interface Identifier; unique identifier of an interface
-    action            - The value of the CsrWifiSmeListAction parameter
-                        instructs the driver to modify or provide the list of
-                        MAC addresses.
-    setAddressesCount - Number of MAC addresses sent with the primitive
-    setAddresses      - Pointer to the list of MAC Addresses sent with the
-                        primitive, set to NULL if none is sent.
-
-*******************************************************************************/
-#define CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->action = (action__); \
-    msg__->setAddressesCount = (setAddressesCount__); \
-    msg__->setAddresses = (setAddresses__);
-
-#define CsrWifiSmeMulticastAddressReqSendTo(dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
-    { \
-        CsrWifiSmeMulticastAddressReq *msg__; \
-        CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMulticastAddressReqSend(src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
-    CsrWifiSmeMulticastAddressReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMulticastAddressCfmSend
-
-  DESCRIPTION
-    The SME will call this primitive when the operation is complete. For a
-    GET action, this primitive reports the current list of MAC addresses.
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    interfaceTag      - Interface Identifier; unique identifier of an interface
-    status            - Reports the result of the request
-    action            - Action in the request
-    getAddressesCount - This parameter is only relevant if action is
-                        CSR_WIFI_SME_LIST_ACTION_GET:
-                        number of MAC addresses sent with the primitive
-    getAddresses      - Pointer to the list of MAC Addresses sent with the
-                        primitive, set to NULL if none is sent.
-
-*******************************************************************************/
-#define CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->action = (action__); \
-    msg__->getAddressesCount = (getAddressesCount__); \
-    msg__->getAddresses = (getAddresses__);
-
-#define CsrWifiSmeMulticastAddressCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
-    { \
-        CsrWifiSmeMulticastAddressCfm *msg__; \
-        CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeMulticastAddressCfmSend(dst__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
-    CsrWifiSmeMulticastAddressCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePacketFilterSetReqSend
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to enable or
-    disable filtering of broadcast packets: uninteresting broadcast packets
-    will be dropped by the Wi-Fi chip, instead of passing them up to the
-    host.
-    This has the advantage of saving power in the host application processor
-    as it removes the need to process unwanted packets.
-    All broadcast packets are filtered according to the filter and the filter
-    mode provided, except ARP packets, which are filtered using
-    arpFilterAddress.
-    Filters are not cumulative: only the parameters specified in the most
-    recent successful request are significant.
-    For more information, see 'UniFi Firmware API Specification'.
-
-  PARAMETERS
-    queue            - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    filterLength     - Length of the filter in bytes.
-                       filterLength=0 disables the filter previously set
-    filter           - Points to the first byte of the filter provided, if any.
-                       This shall include zero or more instance of the
-                       information elements of one of these types
-                         * Traffic Classification (TCLAS) elements
-                         * WMM-SA TCLAS elements
-    mode             - Specifies whether the filter selects or excludes packets
-                       matching the filter
-    arpFilterAddress - IPv4 address to be used for filtering the ARP packets.
-                         * If the specified address is the IPv4 broadcast address
-                           (255.255.255.255), all ARP packets are reported to the
-                           host,
-                         * If the specified address is NOT the IPv4 broadcast
-                           address, only ARP packets with the specified address in
-                           the Source or Target Protocol Address fields are reported
-                           to the host
-
-*******************************************************************************/
-#define CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->filterLength = (filterLength__); \
-    msg__->filter = (filter__); \
-    msg__->mode = (mode__); \
-    msg__->arpFilterAddress = (arpFilterAddress__);
-
-#define CsrWifiSmePacketFilterSetReqSendTo(dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
-    { \
-        CsrWifiSmePacketFilterSetReq *msg__; \
-        CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePacketFilterSetReqSend(src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
-    CsrWifiSmePacketFilterSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePacketFilterSetCfmSend
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the set primitive.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmePacketFilterSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmePacketFilterSetCfm *msg__; \
-        CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePacketFilterSetCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmePacketFilterSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePermanentMacAddressGetReqSend
-
-  DESCRIPTION
-    This primitive retrieves the MAC address stored in EEPROM
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, dst__, src__);
-
-#define CsrWifiSmePermanentMacAddressGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmePermanentMacAddressGetReq *msg__; \
-        CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePermanentMacAddressGetReqSend(src__) \
-    CsrWifiSmePermanentMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePermanentMacAddressGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue               - Destination Task Queue
-    status              - Reports the result of the request
-    permanentMacAddress - MAC address stored in the EEPROM
-
-*******************************************************************************/
-#define CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->permanentMacAddress = (permanentMacAddress__);
-
-#define CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, src__, status__, permanentMacAddress__) \
-    { \
-        CsrWifiSmePermanentMacAddressGetCfm *msg__; \
-        CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePermanentMacAddressGetCfmSend(dst__, status__, permanentMacAddress__) \
-    CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, permanentMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidCandidateListIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it when a new network supporting preauthentication and/or PMK
-    caching is seen.
-
-  PARAMETERS
-    queue                - Destination Task Queue
-    interfaceTag         - Interface Identifier; unique identifier of an
-                           interface
-    pmkidCandidatesCount - Number of PMKID candidates provided
-    pmkidCandidates      - Points to the first PMKID candidate
-
-*******************************************************************************/
-#define CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->pmkidCandidatesCount = (pmkidCandidatesCount__); \
-    msg__->pmkidCandidates = (pmkidCandidates__);
-
-#define CsrWifiSmePmkidCandidateListIndSendTo(dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
-    { \
-        CsrWifiSmePmkidCandidateListInd *msg__; \
-        CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePmkidCandidateListIndSend(dst__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
-    CsrWifiSmePmkidCandidateListIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to request an
-    operation on the SME PMKID list.
-    The action argument specifies the operation to perform.
-    When the connection is complete, the wireless manager application may
-    then send and receive EAPOL packets to complete WPA or WPA2
-    authentication if appropriate.
-    The wireless manager application can then pass the resulting encryption
-    keys using this primitive.
-
-  PARAMETERS
-    queue          - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    action         - The value of the CsrWifiSmeListAction parameter instructs
-                     the driver to modify or provide the list of PMKIDs.
-    setPmkidsCount - Number of PMKIDs sent with the primitive
-    setPmkids      - Pointer to the list of PMKIDs sent with the primitive, set
-                     to NULL if none is sent.
-
-*******************************************************************************/
-#define CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->action = (action__); \
-    msg__->setPmkidsCount = (setPmkidsCount__); \
-    msg__->setPmkids = (setPmkids__);
-
-#define CsrWifiSmePmkidReqSendTo(dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
-    { \
-        CsrWifiSmePmkidReq *msg__; \
-        CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePmkidReqSend(src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
-    CsrWifiSmePmkidReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidCfmSend
-
-  DESCRIPTION
-    The SME will call this primitive when the operation is complete. For a
-    GET action, this primitive reports the current list of PMKIDs
-
-  PARAMETERS
-    queue          - Destination Task Queue
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the request
-    action         - Action in the request
-    getPmkidsCount - This parameter is only relevant if action is
-                     CSR_WIFI_SME_LIST_ACTION_GET:
-                     number of PMKIDs sent with the primitive
-    getPmkids      - Pointer to the list of PMKIDs sent with the primitive, set
-                     to NULL if none is sent.
-
-*******************************************************************************/
-#define CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->action = (action__); \
-    msg__->getPmkidsCount = (getPmkidsCount__); \
-    msg__->getPmkids = (getPmkids__);
-
-#define CsrWifiSmePmkidCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
-    { \
-        CsrWifiSmePmkidCfm *msg__; \
-        CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePmkidCfmSend(dst__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
-    CsrWifiSmePmkidCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the PowerConfig parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_REQ, dst__, src__);
-
-#define CsrWifiSmePowerConfigGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmePowerConfigGetReq *msg__; \
-        CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePowerConfigGetReqSend(src__) \
-    CsrWifiSmePowerConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue       - Destination Task Queue
-    status      - Reports the result of the request
-    powerConfig - Returns the current parameters for the power configuration of
-                  the firmware
-
-*******************************************************************************/
-#define CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->powerConfig = (powerConfig__);
-
-#define CsrWifiSmePowerConfigGetCfmSendTo(dst__, src__, status__, powerConfig__) \
-    { \
-        CsrWifiSmePowerConfigGetCfm *msg__; \
-        CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePowerConfigGetCfmSend(dst__, status__, powerConfig__) \
-    CsrWifiSmePowerConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, powerConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the PowerConfig parameter.
-
-  PARAMETERS
-    queue       - Message Source Task Queue (Cfm's will be sent to this Queue)
-    powerConfig - Power saving configuration
-
-*******************************************************************************/
-#define CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_REQ, dst__, src__); \
-    msg__->powerConfig = (powerConfig__);
-
-#define CsrWifiSmePowerConfigSetReqSendTo(dst__, src__, powerConfig__) \
-    { \
-        CsrWifiSmePowerConfigSetReq *msg__; \
-        CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePowerConfigSetReqSend(src__, powerConfig__) \
-    CsrWifiSmePowerConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, powerConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmePowerConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmePowerConfigSetCfm *msg__; \
-        CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmePowerConfigSetCfmSend(dst__, status__) \
-    CsrWifiSmePowerConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRegulatoryDomainInfoGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the RegulatoryDomainInfo parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeRegulatoryDomainInfoGetReq *msg__; \
-        CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRegulatoryDomainInfoGetReqSend(src__) \
-    CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRegulatoryDomainInfoGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    status     - Reports the result of the request
-    regDomInfo - Reports information and state related to regulatory domain
-                 operation.
-
-*******************************************************************************/
-#define CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->regDomInfo = (regDomInfo__);
-
-#define CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, src__, status__, regDomInfo__) \
-    { \
-        CsrWifiSmeRegulatoryDomainInfoGetCfm *msg__; \
-        CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRegulatoryDomainInfoGetCfmSend(dst__, status__, regDomInfo__) \
-    CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, regDomInfo__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamCompleteIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it completes an attempt to roam to an AP. If the roam
-    attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS,
-    otherwise it shall be set to the appropriate error code.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the roaming procedure
-
-*******************************************************************************/
-#define CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_COMPLETE_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeRoamCompleteIndSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeRoamCompleteInd *msg__; \
-        CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRoamCompleteIndSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeRoamCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamStartIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it begins an attempt to roam to an AP.
-    If the wireless manager application connect request specified the SSID
-    and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF
-    0xFF), the SME monitors the signal quality and maintains a list of
-    candidates to roam to. When the signal quality of the current connection
-    falls below a threshold, and there is a candidate with better quality,
-    the SME will attempt to the candidate AP.
-    If the roaming procedure succeeds, the SME will also issue a Media
-    Connect indication to inform the wireless manager application of the
-    change.
-    NOTE: to prevent the SME from initiating roaming the WMA must specify the
-    BSSID in the connection request; this forces the SME to connect only to
-    that AP.
-    The wireless manager application can obtain statistics for roaming
-    purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and
-    CSR_WIFI_SME_CONNECTION_STATS_GET_REQ.
-    When the wireless manager application wishes to roam to another AP, it
-    must issue a connection request specifying the BSSID of the desired AP.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    roamReason   - Indicates the reason for starting the roaming procedure
-    reason80211  - Indicates the reason for deauthentication or disassociation
-
-*******************************************************************************/
-#define CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_START_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->roamReason = (roamReason__); \
-    msg__->reason80211 = (reason80211__);
-
-#define CsrWifiSmeRoamStartIndSendTo(dst__, src__, interfaceTag__, roamReason__, reason80211__) \
-    { \
-        CsrWifiSmeRoamStartInd *msg__; \
-        CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRoamStartIndSend(dst__, interfaceTag__, roamReason__, reason80211__) \
-    CsrWifiSmeRoamStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, roamReason__, reason80211__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the RoamingConfig parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeRoamingConfigGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeRoamingConfigGetReq *msg__; \
-        CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRoamingConfigGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeRoamingConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue         - Destination Task Queue
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    status        - Reports the result of the request
-    roamingConfig - Reports the roaming behaviour of the driver and firmware
-
-*******************************************************************************/
-#define CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->roamingConfig = (roamingConfig__);
-
-#define CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, roamingConfig__) \
-    { \
-        CsrWifiSmeRoamingConfigGetCfm *msg__; \
-        CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRoamingConfigGetCfmSend(dst__, interfaceTag__, status__, roamingConfig__) \
-    CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, roamingConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the RoamingConfig parameter.
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    roamingConfig - Desired roaming behaviour values
-
-*******************************************************************************/
-#define CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->roamingConfig = (roamingConfig__);
-
-#define CsrWifiSmeRoamingConfigSetReqSendTo(dst__, src__, interfaceTag__, roamingConfig__) \
-    { \
-        CsrWifiSmeRoamingConfigSetReq *msg__; \
-        CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRoamingConfigSetReqSend(src__, interfaceTag__, roamingConfig__) \
-    CsrWifiSmeRoamingConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, roamingConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive sets the value of the RoamingConfig parameter.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeRoamingConfigSetCfm *msg__; \
-        CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeRoamingConfigSetCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the ScanConfig parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeScanConfigGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeScanConfigGetReq *msg__; \
-        CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanConfigGetReqSend(src__) \
-    CsrWifiSmeScanConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue      - Destination Task Queue
-    status     - Reports the result of the request
-    scanConfig - Returns the current parameters for the autonomous scanning
-                 behaviour of the firmware
-
-*******************************************************************************/
-#define CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->scanConfig = (scanConfig__);
-
-#define CsrWifiSmeScanConfigGetCfmSendTo(dst__, src__, status__, scanConfig__) \
-    { \
-        CsrWifiSmeScanConfigGetCfm *msg__; \
-        CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanConfigGetCfmSend(dst__, status__, scanConfig__) \
-    CsrWifiSmeScanConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the ScanConfig parameter.
-    The SME normally configures the firmware to perform autonomous scanning
-    without involving the host.
-    The firmware passes beacon / probe response or indicates loss of beacon
-    on certain changes of state, for example:
-      * A new AP is seen for the first time
-      * An AP is no longer visible
-      * The signal strength of an AP changes by more than a certain amount, as
-        configured by the thresholds in the scanConfig parameter
-    In addition to the autonomous scan, the wireless manager application may
-    request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ.
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    scanConfig - Reports the configuration for the autonomous scanning behaviour
-                 of the firmware
-
-*******************************************************************************/
-#define CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, dst__, src__); \
-    msg__->scanConfig = (scanConfig__);
-
-#define CsrWifiSmeScanConfigSetReqSendTo(dst__, src__, scanConfig__) \
-    { \
-        CsrWifiSmeScanConfigSetReq *msg__; \
-        CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanConfigSetReqSend(src__, scanConfig__) \
-    CsrWifiSmeScanConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, scanConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeScanConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeScanConfigSetCfm *msg__; \
-        CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanConfigSetCfmSend(dst__, status__) \
-    CsrWifiSmeScanConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanFullReqSend
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to request a
-    full scan.
-    Channels are scanned actively or passively according to the requirement
-    set by regulatory domain.
-    If the SME receives this primitive while a full scan is going on, the new
-    request is buffered and it will be served after the current full scan is
-    completed.
-
-  PARAMETERS
-    queue            - Message Source Task Queue (Cfm's will be sent to this Queue)
-    ssidCount        - Number of SSIDs provided.
-                       If it is 0, the SME will attempt to detect any network
-    ssid             - Points to the first SSID provided, if any.
-    bssid            - BSS identifier.
-                       If it is equal to FF-FF-FF-FF-FF, the SME will listen for
-                       messages from any BSS.
-                       If it is different from FF-FF-FF-FF-FF and any SSID is
-                       provided, one SSID must match the network of the BSS.
-    forceScan        - Forces the scan even if the SME is in a state which would
-                       normally prevent it (e.g. autonomous scan is running).
-    bssType          - Type of BSS to scan for
-    scanType         - Type of scan to perform
-    channelListCount - Number of channels provided.
-                       If it is 0, the SME will initiate a scan of all the
-                       supported channels that are permitted by the current
-                       regulatory domain.
-    channelList      - Points to the first channel , or NULL if channelListCount
-                       is zero.
-    probeIeLength    - Length of the information element in bytes to be sent
-                       with the probe message.
-    probeIe          - Points to the first byte of the information element to be
-                       sent with the probe message.
-
-*******************************************************************************/
-#define CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_REQ, dst__, src__); \
-    msg__->ssidCount = (ssidCount__); \
-    msg__->ssid = (ssid__); \
-    msg__->bssid = (bssid__); \
-    msg__->forceScan = (forceScan__); \
-    msg__->bssType = (bssType__); \
-    msg__->scanType = (scanType__); \
-    msg__->channelListCount = (channelListCount__); \
-    msg__->channelList = (channelList__); \
-    msg__->probeIeLength = (probeIeLength__); \
-    msg__->probeIe = (probeIe__);
-
-#define CsrWifiSmeScanFullReqSendTo(dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
-    { \
-        CsrWifiSmeScanFullReq *msg__; \
-        CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanFullReqSend(src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
-    CsrWifiSmeScanFullReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanFullCfmSend
-
-  DESCRIPTION
-    The SME calls this primitive when the results from the scan are
-    available.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanFullCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeScanFullCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeScanFullCfm *msg__; \
-        CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanFullCfmSend(dst__, status__) \
-    CsrWifiSmeScanFullCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultIndSend
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it whenever a scan indication is received from the firmware.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    result - Points to a buffer containing a scan result.
-
-*******************************************************************************/
-#define CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULT_IND, dst__, src__); \
-    msg__->result = (result__);
-
-#define CsrWifiSmeScanResultIndSendTo(dst__, src__, result__) \
-    { \
-        CsrWifiSmeScanResultInd *msg__; \
-        CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanResultIndSend(dst__, result__) \
-    CsrWifiSmeScanResultIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, result__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsFlushReqSend
-
-  DESCRIPTION
-    The Wireless Manager calls this primitive to ask the SME to delete all
-    scan results from its cache, except for the scan result of any currently
-    connected network.
-    As scan results are received by the SME from the firmware, they are
-    cached in the SME memory.
-    Any time the Wireless Manager requests scan results, they are returned
-    from the SME internal cache.
-    For some applications it may be desirable to clear this cache prior to
-    requesting that a scan be performed; this will ensure that the cache then
-    only contains the networks detected in the most recent scan.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, dst__, src__);
-
-#define CsrWifiSmeScanResultsFlushReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeScanResultsFlushReq *msg__; \
-        CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanResultsFlushReqSend(src__) \
-    CsrWifiSmeScanResultsFlushReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsFlushCfmSend
-
-  DESCRIPTION
-    The SME will call this primitive when the cache has been cleared.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeScanResultsFlushCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeScanResultsFlushCfm *msg__; \
-        CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanResultsFlushCfmSend(dst__, status__) \
-    CsrWifiSmeScanResultsFlushCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsGetReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to retrieve the
-    current set of scan results, either after receiving a successful
-    CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeScanResultsGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeScanResultsGetReq *msg__; \
-        CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanResultsGetReqSend(src__) \
-    CsrWifiSmeScanResultsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsGetCfmSend
-
-  DESCRIPTION
-    The SME sends this primitive to provide the current set of scan results.
-
-  PARAMETERS
-    queue            - Destination Task Queue
-    status           - Reports the result of the request
-    scanResultsCount - Number of scan results
-    scanResults      - Points to a buffer containing an array of
-                       CsrWifiSmeScanResult structures.
-
-*******************************************************************************/
-#define CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->scanResultsCount = (scanResultsCount__); \
-    msg__->scanResults = (scanResults__);
-
-#define CsrWifiSmeScanResultsGetCfmSendTo(dst__, src__, status__, scanResultsCount__, scanResults__) \
-    { \
-        CsrWifiSmeScanResultsGetCfm *msg__; \
-        CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeScanResultsGetCfmSend(dst__, status__, scanResultsCount__, scanResults__) \
-    CsrWifiSmeScanResultsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanResultsCount__, scanResults__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSetReqSend
-
-  DESCRIPTION
-    Used to pass custom data to the SME. Format is the same as 802.11 Info
-    Elements => | Id | Length | Data
-    1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01
-    (0x00|0x01)"
-
-  PARAMETERS
-    queue      - Message Source Task Queue (Cfm's will be sent to this Queue)
-    dataLength - Number of bytes in the buffer pointed to by 'data'
-    data       - Pointer to the buffer containing 'dataLength' bytes
-
-*******************************************************************************/
-#define CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SET_REQ, dst__, src__); \
-    msg__->dataLength = (dataLength__); \
-    msg__->data = (data__);
-
-#define CsrWifiSmeSetReqSendTo(dst__, src__, dataLength__, data__) \
-    { \
-        CsrWifiSmeSetReq *msg__; \
-        CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSetReqSend(src__, dataLength__, data__) \
-    CsrWifiSmeSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, dataLength__, data__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the Sme common parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeSmeCommonConfigGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeSmeCommonConfigGetReq *msg__; \
-        CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeCommonConfigGetReqSend(src__) \
-    CsrWifiSmeSmeCommonConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    status       - Reports the result of the request
-    deviceConfig - Configuration options in the SME
-
-*******************************************************************************/
-#define CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->deviceConfig = (deviceConfig__);
-
-#define CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, src__, status__, deviceConfig__) \
-    { \
-        CsrWifiSmeSmeCommonConfigGetCfm *msg__; \
-        CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeCommonConfigGetCfmSend(dst__, status__, deviceConfig__) \
-    CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, deviceConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the Sme common.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    deviceConfig - Configuration options in the SME
-
-*******************************************************************************/
-#define CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, dst__, src__); \
-    msg__->deviceConfig = (deviceConfig__);
-
-#define CsrWifiSmeSmeCommonConfigSetReqSendTo(dst__, src__, deviceConfig__) \
-    { \
-        CsrWifiSmeSmeCommonConfigSetReq *msg__; \
-        CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeCommonConfigSetReqSend(src__, deviceConfig__) \
-    CsrWifiSmeSmeCommonConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, deviceConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigSetCfmSend
-
-  DESCRIPTION
-    Reports the result of the request
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeSmeCommonConfigSetCfm *msg__; \
-        CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeCommonConfigSetCfmSend(dst__, status__) \
-    CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the SmeStaConfig parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-#define CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__);
-
-#define CsrWifiSmeSmeStaConfigGetReqSendTo(dst__, src__, interfaceTag__) \
-    { \
-        CsrWifiSmeSmeStaConfigGetReq *msg__; \
-        CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeStaConfigGetReqSend(src__, interfaceTag__) \
-    CsrWifiSmeSmeStaConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    smeConfig    - Current SME Station Parameters
-
-*******************************************************************************/
-#define CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->smeConfig = (smeConfig__);
-
-#define CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, smeConfig__) \
-    { \
-        CsrWifiSmeSmeStaConfigGetCfm *msg__; \
-        CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeStaConfigGetCfmSend(dst__, interfaceTag__, status__, smeConfig__) \
-    CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, smeConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigSetReqSend
-
-  DESCRIPTION
-    This primitive sets the value of the SmeConfig parameter.
-
-  PARAMETERS
-    queue        - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    smeConfig    - SME Station Parameters to be set
-
-*******************************************************************************/
-#define CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->smeConfig = (smeConfig__);
-
-#define CsrWifiSmeSmeStaConfigSetReqSendTo(dst__, src__, interfaceTag__, smeConfig__) \
-    { \
-        CsrWifiSmeSmeStaConfigSetReq *msg__; \
-        CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeStaConfigSetReqSend(src__, interfaceTag__, smeConfig__) \
-    CsrWifiSmeSmeStaConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, smeConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigSetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue        - Destination Task Queue
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
-    { \
-        CsrWifiSmeSmeStaConfigSetCfm *msg__; \
-        CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeSmeStaConfigSetCfmSend(dst__, interfaceTag__, status__) \
-    CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeStationMacAddressGetReqSend
-
-  DESCRIPTION
-    This primitives is used to retrieve the current MAC address used by the
-    station.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeStationMacAddressGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeStationMacAddressGetReq *msg__; \
-        CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeStationMacAddressGetReqSend(src__) \
-    CsrWifiSmeStationMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeStationMacAddressGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue             - Destination Task Queue
-    status            - Reports the result of the request
-    stationMacAddress - Current MAC address of the station.
-
-*******************************************************************************/
-#define CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2);
-
-#define CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, src__, status__, stationMacAddress__) \
-    { \
-        CsrWifiSmeStationMacAddressGetCfm *msg__; \
-        CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeStationMacAddressGetCfmSend(dst__, status__, stationMacAddress__) \
-    CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, stationMacAddress__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecReqSend
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to use the
-    TSPEC feature.
-    The chip supports the use of TSPECs and TCLAS for the use of IEEE
-    802.11/WMM Quality of Service features.
-    The API allows the wireless manager application to supply a correctly
-    formatted TSPEC and TCLAS pair to the driver.
-    After performing basic validation, the driver negotiates the installation
-    of the TSPEC with the AP as defined by the 802.11 specification.
-    The driver retains all TSPEC and TCLAS pairs until they are specifically
-    removed.
-    It is not compulsory for a TSPEC to have a TCLAS (NULL is used to
-    indicate that no TCLAS is supplied), while a TCLASS always require a
-    TSPEC.
-    The format of the TSPEC element is specified in 'WMM (including WMM Power
-    Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'.
-    For more information, see 'UniFi Configuring WMM and WMM-PS'.
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    action        - Specifies the action to be carried out on the list of TSPECs.
-                    CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here.
-    transactionId - Unique Transaction ID for the TSPEC, as assigned by the
-                    driver
-    strict        - If it set to false, allows the SME to perform automatic
-                    TSPEC negotiation
-    ctrlMask      - Additional TSPEC configuration for CCX.
-                    Set mask with values from CsrWifiSmeTspecCtrl.
-                    CURRENTLY NOT SUPPORTED
-    tspecLength   - Length of the TSPEC.
-    tspec         - Points to the first byte of the TSPEC
-    tclasLength   - Length of the TCLAS.
-                    If it is equal to 0, no TCLASS is provided for the TSPEC
-    tclas         - Points to the first byte of the TCLAS, if any.
-
-*******************************************************************************/
-#define CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_REQ, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->action = (action__); \
-    msg__->transactionId = (transactionId__); \
-    msg__->strict = (strict__); \
-    msg__->ctrlMask = (ctrlMask__); \
-    msg__->tspecLength = (tspecLength__); \
-    msg__->tspec = (tspec__); \
-    msg__->tclasLength = (tclasLength__); \
-    msg__->tclas = (tclas__);
-
-#define CsrWifiSmeTspecReqSendTo(dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
-    { \
-        CsrWifiSmeTspecReq *msg__; \
-        CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeTspecReqSend(src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
-    CsrWifiSmeTspecReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecIndSend
-
-  DESCRIPTION
-    The SME will send this primitive to all the task that have registered to
-    receive it when a status change in the TSPEC occurs.
-
-  PARAMETERS
-    queue           - Destination Task Queue
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    transactionId   - Unique Transaction ID for the TSPEC, as assigned by the
-                      driver
-    tspecResultCode - Specifies the TSPEC operation requested by the peer
-                      station
-    tspecLength     - Length of the TSPEC.
-    tspec           - Points to the first byte of the TSPEC
-
-*******************************************************************************/
-#define CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_IND, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->transactionId = (transactionId__); \
-    msg__->tspecResultCode = (tspecResultCode__); \
-    msg__->tspecLength = (tspecLength__); \
-    msg__->tspec = (tspec__);
-
-#define CsrWifiSmeTspecIndSendTo(dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
-    { \
-        CsrWifiSmeTspecInd *msg__; \
-        CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeTspecIndSend(dst__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
-    CsrWifiSmeTspecIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecCfmSend
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the TSpec primitive
-    request.
-
-  PARAMETERS
-    queue           - Destination Task Queue
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    status          - Reports the result of the request
-    transactionId   - Unique Transaction ID for the TSPEC, as assigned by the
-                      driver
-    tspecResultCode - Specifies the result of the negotiated TSPEC operation
-    tspecLength     - Length of the TSPEC.
-    tspec           - Points to the first byte of the TSPEC
-
-*******************************************************************************/
-#define CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_CFM, dst__, src__); \
-    msg__->interfaceTag = (interfaceTag__); \
-    msg__->status = (status__); \
-    msg__->transactionId = (transactionId__); \
-    msg__->tspecResultCode = (tspecResultCode__); \
-    msg__->tspecLength = (tspecLength__); \
-    msg__->tspec = (tspec__);
-
-#define CsrWifiSmeTspecCfmSendTo(dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
-    { \
-        CsrWifiSmeTspecCfm *msg__; \
-        CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeTspecCfmSend(dst__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
-    CsrWifiSmeTspecCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeVersionsGetReqSend
-
-  DESCRIPTION
-    This primitive gets the value of the Versions parameter.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_REQ, dst__, src__);
-
-#define CsrWifiSmeVersionsGetReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeVersionsGetReq *msg__; \
-        CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeVersionsGetReqSend(src__) \
-    CsrWifiSmeVersionsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeVersionsGetCfmSend
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  PARAMETERS
-    queue    - Destination Task Queue
-    status   - Reports the result of the request
-    versions - Version IDs of the product
-
-*******************************************************************************/
-#define CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_CFM, dst__, src__); \
-    msg__->status = (status__); \
-    msg__->versions = (versions__);
-
-#define CsrWifiSmeVersionsGetCfmSendTo(dst__, src__, status__, versions__) \
-    { \
-        CsrWifiSmeVersionsGetCfm *msg__; \
-        CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeVersionsGetCfmSend(dst__, status__, versions__) \
-    CsrWifiSmeVersionsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, versions__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiFlightmodeReqSend
-
-  DESCRIPTION
-    The wireless manager application may call this primitive on boot-up of
-    the platform to ensure that the chip is placed in a mode that prevents
-    any emission of RF energy.
-    This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ.
-    As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file
-    (if any) and the programming of the initial MIB settings (if supplied by
-    the WMA), but it also ensures that the chip is left in its lowest
-    possible power-mode with the radio subsystems disabled.
-    This feature is useful on platforms where power cannot be removed from
-    the chip (leaving the chip not initialised will cause it to consume more
-    power so calling this function ensures that the chip is initialised into
-    a low power mode but without entering a state where it could emit any RF
-    energy).
-    NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi
-    stays conceptually off. Configuration primitives can be sent after
-    CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained.
-    Requests that require the state of the Wi-Fi to be ON will return
-    CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms.
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    address       - Optionally specifies a station MAC address.
-                    In normal use, the manager should set the address to 0xFF
-                    0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
-                    the MAC address in the MIB.
-    mibFilesCount - Number of provided data blocks with initial MIB values
-    mibFiles      - Points to the first data block with initial MIB values.
-                    These data blocks are typically the contents of the provided
-                    files ufmib.dat and localmib.dat, available from the host
-                    file system, if they exist.
-                    These files typically contain radio tuning and calibration
-                    values.
-                    More values can be created using the Host Tools.
-
-*******************************************************************************/
-#define CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, dst__, src__); \
-    msg__->address = (address__); \
-    msg__->mibFilesCount = (mibFilesCount__); \
-    msg__->mibFiles = (mibFiles__);
-
-#define CsrWifiSmeWifiFlightmodeReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \
-    { \
-        CsrWifiSmeWifiFlightmodeReq *msg__; \
-        CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiFlightmodeReqSend(src__, address__, mibFilesCount__, mibFiles__) \
-    CsrWifiSmeWifiFlightmodeReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiFlightmodeCfmSend
-
-  DESCRIPTION
-    The SME calls this primitive when the chip is initialised for low power
-    mode and with the radio subsystem disabled. To leave flight mode, and
-    enable Wi-Fi, the wireless manager application should call
-    CSR_WIFI_SME_WIFI_ON_REQ.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeWifiFlightmodeCfm *msg__; \
-        CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiFlightmodeCfmSend(dst__, status__) \
-    CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOffReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to turn off the
-    chip, thus saving power when Wi-Fi is not in use.
-
-  PARAMETERS
-    queue  - Message Source Task Queue (Cfm's will be sent to this Queue)
-
-*******************************************************************************/
-#define CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_REQ, dst__, src__);
-
-#define CsrWifiSmeWifiOffReqSendTo(dst__, src__) \
-    { \
-        CsrWifiSmeWifiOffReq *msg__; \
-        CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiOffReqSend(src__) \
-    CsrWifiSmeWifiOffReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOffIndSend
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it to report that the chip has been turned off.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    reason - Indicates the reason why the Wi-Fi has been switched off.
-
-*******************************************************************************/
-#define CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_IND, dst__, src__); \
-    msg__->reason = (reason__);
-
-#define CsrWifiSmeWifiOffIndSendTo(dst__, src__, reason__) \
-    { \
-        CsrWifiSmeWifiOffInd *msg__; \
-        CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiOffIndSend(dst__, reason__) \
-    CsrWifiSmeWifiOffIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, reason__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOffCfmSend
-
-  DESCRIPTION
-    After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a
-    network, the SME will perform a disconnect operation, will send a
-    CSR_WIFI_SME_MEDIA_STATUS_IND with
-    CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call
-    CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeWifiOffCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeWifiOffCfm *msg__; \
-        CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiOffCfmSend(dst__, status__) \
-    CsrWifiSmeWifiOffCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOnReqSend
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to turn on the
-    Wi-Fi chip.
-    If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on,
-    downloads the patch file (if any), and programs the initial MIB settings
-    (if supplied by the WMA).
-    The patch file is not provided with the SME API; its downloading is
-    automatic and handled internally by the system.
-    The MIB settings, when provided, override the default values that the
-    firmware loads from EEPROM.
-    If the Wi-Fi chip is already on, the SME takes no action and returns a
-    successful status in the confirm.
-
-  PARAMETERS
-    queue         - Message Source Task Queue (Cfm's will be sent to this Queue)
-    address       - Optionally specifies a station MAC address.
-                    In normal use, the manager should set the address to 0xFF
-                    0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
-                    the MAC address in the MIB
-    mibFilesCount - Number of provided data blocks with initial MIB values
-    mibFiles      - Points to the first data block with initial MIB values.
-                    These data blocks are typically the contents of the provided
-                    files ufmib.dat and localmib.dat, available from the host
-                    file system, if they exist.
-                    These files typically contain radio tuning and calibration
-                    values.
-                    More values can be created using the Host Tools.
-
-*******************************************************************************/
-#define CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_REQ, dst__, src__); \
-    msg__->address = (address__); \
-    msg__->mibFilesCount = (mibFilesCount__); \
-    msg__->mibFiles = (mibFiles__);
-
-#define CsrWifiSmeWifiOnReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \
-    { \
-        CsrWifiSmeWifiOnReq *msg__; \
-        CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiOnReqSend(src__, address__, mibFilesCount__, mibFiles__) \
-    CsrWifiSmeWifiOnReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOnIndSend
-
-  DESCRIPTION
-    The SME sends this primitive to all tasks that have registered to receive
-    it once the chip becomes available and ready to use.
-
-  PARAMETERS
-    queue   - Destination Task Queue
-    address - Current MAC address
-
-*******************************************************************************/
-#define CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_IND, dst__, src__); \
-    msg__->address = (address__);
-
-#define CsrWifiSmeWifiOnIndSendTo(dst__, src__, address__) \
-    { \
-        CsrWifiSmeWifiOnInd *msg__; \
-        CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiOnIndSend(dst__, address__) \
-    CsrWifiSmeWifiOnIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOnCfmSend
-
-  DESCRIPTION
-    The SME sends this primitive to the task that has sent the request once
-    the chip has been initialised and is available for use.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Reports the result of the request
-
-*******************************************************************************/
-#define CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeWifiOnCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeWifiOnCfm *msg__; \
-        CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWifiOnCfmSend(dst__, status__) \
-    CsrWifiSmeWifiOnCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfigurationReqSend
-
-  DESCRIPTION
-    This primitive passes the WPS information for the device to SME. This may
-    be accepted only if no interface is active.
-
-  PARAMETERS
-    queue     - Message Source Task Queue (Cfm's will be sent to this Queue)
-    wpsConfig - WPS config.
-
-*******************************************************************************/
-#define CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_REQ, dst__, src__); \
-    msg__->wpsConfig = (wpsConfig__);
-
-#define CsrWifiSmeWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \
-    { \
-        CsrWifiSmeWpsConfigurationReq *msg__; \
-        CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \
-        CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWpsConfigurationReqSend(src__, wpsConfig__) \
-    CsrWifiSmeWpsConfigurationReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, wpsConfig__)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfigurationCfmSend
-
-  DESCRIPTION
-    Confirm.
-
-  PARAMETERS
-    queue  - Destination Task Queue
-    status - Status of the request.
-
-*******************************************************************************/
-#define CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \
-    msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationCfm), GFP_KERNEL); \
-    CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_CFM, dst__, src__); \
-    msg__->status = (status__);
-
-#define CsrWifiSmeWpsConfigurationCfmSendTo(dst__, src__, status__) \
-    { \
-        CsrWifiSmeWpsConfigurationCfm *msg__; \
-        CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \
-        CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
-    }
-
-#define CsrWifiSmeWpsConfigurationCfmSend(dst__, status__) \
-    CsrWifiSmeWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
-
-#endif /* CSR_WIFI_SME_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_prim.h b/drivers/staging/csr/csr_wifi_sme_prim.h
deleted file mode 100644 (file)
index 17ec79c..0000000
+++ /dev/null
@@ -1,6510 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_PRIM_H__
-#define CSR_WIFI_SME_PRIM_H__
-
-#include <linux/types.h>
-#include "csr_prim_defs.h"
-#include "csr_sched.h"
-#include "csr_wifi_common.h"
-#include "csr_result.h"
-#include "csr_wifi_fsm_event.h"
-
-#define CSR_WIFI_SME_PRIM                                               (0x0404)
-
-typedef CsrPrim CsrWifiSmePrim;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSme80211NetworkType
-
-  DESCRIPTION
-    Indicates the physical layer of the network
-
- VALUES
-    CSR_WIFI_SME_80211_NETWORK_TYPE_DS
-                   - Direct-sequence spread spectrum
-    CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24
-                   - Orthogonal Frequency Division Multiplexing at 2.4 GHz
-    CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5
-                   - Orthogonal Frequency Division Multiplexing at 5 GHz
-    CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO
-                   - Automatic
-
-*******************************************************************************/
-typedef u8 CsrWifiSme80211NetworkType;
-#define CSR_WIFI_SME_80211_NETWORK_TYPE_DS       ((CsrWifiSme80211NetworkType) 0x00)
-#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24   ((CsrWifiSme80211NetworkType) 0x01)
-#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5    ((CsrWifiSme80211NetworkType) 0x02)
-#define CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO     ((CsrWifiSme80211NetworkType) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSme80211PrivacyMode
-
-  DESCRIPTION
-    Bits to enable or disable the privacy mode
-
- VALUES
-    CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
-                   - Privacy mode is enabled: use of WEP for confidentiality is
-                     required.
-    CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED
-                   - Privacy mode is disabled
-
-*******************************************************************************/
-typedef u8 CsrWifiSme80211PrivacyMode;
-#define CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED   ((CsrWifiSme80211PrivacyMode) 0x00)
-#define CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED    ((CsrWifiSme80211PrivacyMode) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSme80211dTrustLevel
-
-  DESCRIPTION
-    Level of trust for the information coming from the network
-
- VALUES
-    CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT
-                   - Start with passive scanning and only accept country IE for
-                     updating channel lists
-    CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT
-                   - As above plus accept adjunct technology location
-                     information
-    CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS
-                   - As above accept plus receiving channel from infrastructure
-                     networks
-    CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS
-                   - As above accept plus receiving channel from the ad hoc
-                     networks
-    CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB
-                   - Start with active scanning with list of active channels
-                     from the MIB and accept as above
-    CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED
-                   - Start with active scanning with list of active channels
-                     from the MIB and ignore any channel information from the
-                     network
-
-*******************************************************************************/
-typedef u8 CsrWifiSme80211dTrustLevel;
-#define CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT     ((CsrWifiSme80211dTrustLevel) 0x01)
-#define CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT    ((CsrWifiSme80211dTrustLevel) 0x02)
-#define CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS        ((CsrWifiSme80211dTrustLevel) 0x03)
-#define CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS       ((CsrWifiSme80211dTrustLevel) 0x04)
-#define CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB        ((CsrWifiSme80211dTrustLevel) 0x05)
-#define CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED   ((CsrWifiSme80211dTrustLevel) 0x06)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAmpStatus
-
-  DESCRIPTION
-    AMP Current Status
-
- VALUES
-    CSR_WIFI_SME_AMP_ACTIVE   - AMP ACTIVE.
-    CSR_WIFI_SME_AMP_INACTIVE - AMP INACTIVE
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeAmpStatus;
-#define CSR_WIFI_SME_AMP_ACTIVE     ((CsrWifiSmeAmpStatus) 0x00)
-#define CSR_WIFI_SME_AMP_INACTIVE   ((CsrWifiSmeAmpStatus) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAuthMode
-
-  DESCRIPTION
-    Define bits for CsrWifiSmeAuthMode
-
- VALUES
-    CSR_WIFI_SME_AUTH_MODE_80211_OPEN
-                   - Connects to an open system network (i.e. no authentication,
-                     no encryption) or to a WEP enabled network.
-    CSR_WIFI_SME_AUTH_MODE_80211_SHARED
-                   - Connect to a WEP enabled network.
-    CSR_WIFI_SME_AUTH_MODE_8021X_WPA
-                   - Connects to a WPA Enterprise enabled network.
-    CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK
-                   - Connects to a WPA with Pre-Shared Key enabled network.
-    CSR_WIFI_SME_AUTH_MODE_8021X_WPA2
-                   - Connects to a WPA2 Enterprise enabled network.
-    CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK
-                   - Connects to a WPA2 with Pre-Shared Key enabled network.
-    CSR_WIFI_SME_AUTH_MODE_8021X_CCKM
-                   - Connects to a CCKM enabled network.
-    CSR_WIFI_SME_AUTH_MODE_WAPI_WAI
-                   - Connects to a WAPI Enterprise enabled network.
-    CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK
-                   - Connects to a WAPI with Pre-Shared Key enabled network.
-    CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X
-                   - For future use.
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeAuthMode;
-#define CSR_WIFI_SME_AUTH_MODE_80211_OPEN      ((CsrWifiSmeAuthMode) 0x0001)
-#define CSR_WIFI_SME_AUTH_MODE_80211_SHARED    ((CsrWifiSmeAuthMode) 0x0002)
-#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA       ((CsrWifiSmeAuthMode) 0x0004)
-#define CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK    ((CsrWifiSmeAuthMode) 0x0008)
-#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2      ((CsrWifiSmeAuthMode) 0x0010)
-#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK   ((CsrWifiSmeAuthMode) 0x0020)
-#define CSR_WIFI_SME_AUTH_MODE_8021X_CCKM      ((CsrWifiSmeAuthMode) 0x0040)
-#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAI        ((CsrWifiSmeAuthMode) 0x0080)
-#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK     ((CsrWifiSmeAuthMode) 0x0100)
-#define CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X   ((CsrWifiSmeAuthMode) 0x0200)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeBasicUsability
-
-  DESCRIPTION
-    Indicates the usability level of a channel
-
- VALUES
-    CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE
-                   - Not usable; connection not recommended
-    CSR_WIFI_SME_BASIC_USABILITY_POOR
-                   - Poor quality; connect only if nothing better is available
-    CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY
-                   - Quality is satisfactory
-    CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED
-                   - Not connected
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeBasicUsability;
-#define CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE        ((CsrWifiSmeBasicUsability) 0x00)
-#define CSR_WIFI_SME_BASIC_USABILITY_POOR            ((CsrWifiSmeBasicUsability) 0x01)
-#define CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY    ((CsrWifiSmeBasicUsability) 0x02)
-#define CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED   ((CsrWifiSmeBasicUsability) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeBssType
-
-  DESCRIPTION
-    Indicates the BSS type
-
- VALUES
-    CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
-                   - Infrastructure BSS.
-    CSR_WIFI_SME_BSS_TYPE_ADHOC
-                   - Ad hoc or Independent BSS.
-    CSR_WIFI_SME_BSS_TYPE_ANY_BSS
-                   - Specifies any type of BSS
-    CSR_WIFI_SME_BSS_TYPE_P2P
-                   - Specifies P2P
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeBssType;
-#define CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE   ((CsrWifiSmeBssType) 0x00)
-#define CSR_WIFI_SME_BSS_TYPE_ADHOC            ((CsrWifiSmeBssType) 0x01)
-#define CSR_WIFI_SME_BSS_TYPE_ANY_BSS          ((CsrWifiSmeBssType) 0x02)
-#define CSR_WIFI_SME_BSS_TYPE_P2P              ((CsrWifiSmeBssType) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexScheme
-
-  DESCRIPTION
-    Options for the coexistence signalling
-    Same as MibValues
-
- VALUES
-    CSR_WIFI_SME_COEX_SCHEME_DISABLED
-                   - The coexistence signalling is disabled
-    CSR_WIFI_SME_COEX_SCHEME_CSR
-                   - Basic CSR coexistence signalling
-    CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL
-                   - Full CSR coexistence signalling
-    CSR_WIFI_SME_COEX_SCHEME_PTA
-                   - Packet Traffic Arbitrator coexistence signalling
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeCoexScheme;
-#define CSR_WIFI_SME_COEX_SCHEME_DISABLED      ((CsrWifiSmeCoexScheme) 0x00)
-#define CSR_WIFI_SME_COEX_SCHEME_CSR           ((CsrWifiSmeCoexScheme) 0x01)
-#define CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL   ((CsrWifiSmeCoexScheme) 0x02)
-#define CSR_WIFI_SME_COEX_SCHEME_PTA           ((CsrWifiSmeCoexScheme) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeControlIndication
-
-  DESCRIPTION
-    Indicates the reason why the Wi-Fi has been switched off.
-    The values of this type are used across the NME/SME/Router API's and they
-    must be kept consistent with the corresponding types in the .xml of the
-    ottherinterfaces
-
- VALUES
-    CSR_WIFI_SME_CONTROL_INDICATION_ERROR
-                   - An unrecoverable error (for example, an unrecoverable SDIO
-                     error) has occurred.
-                     The wireless manager application should reinitialise the
-                     chip by calling CSR_WIFI_SME_WIFI_ON_REQ.
-    CSR_WIFI_SME_CONTROL_INDICATION_EXIT
-                   - The chip became unavailable due to an external action, for
-                     example, when a plug-in card is ejected or the driver is
-                     unloaded.
-    CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED
-                   - The Wi-Fi has been switched off as the wireless manager
-                     application has sent CSR_WIFI_SME_WIFI_OFF_REQ
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeControlIndication;
-#define CSR_WIFI_SME_CONTROL_INDICATION_ERROR            ((CsrWifiSmeControlIndication) 0x01)
-#define CSR_WIFI_SME_CONTROL_INDICATION_EXIT             ((CsrWifiSmeControlIndication) 0x02)
-#define CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED   ((CsrWifiSmeControlIndication) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCtsProtectionType
-
-  DESCRIPTION
-    SME CTS Protection Types
-
- VALUES
-    CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC
-                   - AP CTS Protection automatic based on non-ERP station in own
-                     BSS or neighbouring BSS on the same channel based on OLBC.
-                     This requires monitoring of beacons from other APs.
-    CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED
-                   - AP CTS Protection Force enabled
-    CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED
-                   - AP CTS Protection Force disabled.
-    CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC
-                   - AP CTS Protection automatic without considering OLBC but
-                     considering non-ERP station in the own BSS Valid only if AP
-                     is configured to work in 802.11bg or 802.11g mode otherwise
-                     this option specifies the same behaviour as AUTOMATIC
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeCtsProtectionType;
-#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC           ((CsrWifiSmeCtsProtectionType) 0x00)
-#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED       ((CsrWifiSmeCtsProtectionType) 0x01)
-#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED      ((CsrWifiSmeCtsProtectionType) 0x02)
-#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC   ((CsrWifiSmeCtsProtectionType) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeD3AutoScanMode
-
-  DESCRIPTION
-    Autonomous scan status while in D3 suspended period
-
- VALUES
-    CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON
-                   - Autonomous scan stays on
-    CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF
-                   - Autonomous scan is switched off
-    CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO
-                   - Automatically select autoscanning behaviour.
-                     CURRENTLY NOT SUPPORTED
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeD3AutoScanMode;
-#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON     ((CsrWifiSmeD3AutoScanMode) 0x00)
-#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF    ((CsrWifiSmeD3AutoScanMode) 0x01)
-#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO   ((CsrWifiSmeD3AutoScanMode) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEncryption
-
-  DESCRIPTION
-    Defines bits for CsrWifiSmeEncryption
-    For a WEP enabled network, the caller must specify the correct
-    combination of flags in the encryptionModeMask.
-
- VALUES
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
-                   - No encryption set
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
-                   - Selects 40 byte key WEP for unicast communication
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
-                   - Selects 104 byte key WEP for unicast communication
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
-                   - Selects TKIP for unicast communication
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
-                   - Selects CCMP for unicast communication
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
-                   - Selects SMS4 for unicast communication
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
-                   - Selects 40 byte key WEP for broadcast messages
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
-                   - Selects 104 byte key WEP for broadcast messages
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP
-                   - Selects a TKIP for broadcast messages
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP
-                   - Selects CCMP for broadcast messages
-    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4
-                   - Selects SMS4 for broadcast messages
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeEncryption;
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE              ((CsrWifiSmeEncryption) 0x0000)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40    ((CsrWifiSmeEncryption) 0x0001)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104   ((CsrWifiSmeEncryption) 0x0002)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP     ((CsrWifiSmeEncryption) 0x0004)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP     ((CsrWifiSmeEncryption) 0x0008)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4     ((CsrWifiSmeEncryption) 0x0010)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40       ((CsrWifiSmeEncryption) 0x0020)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104      ((CsrWifiSmeEncryption) 0x0040)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP        ((CsrWifiSmeEncryption) 0x0080)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP        ((CsrWifiSmeEncryption) 0x0100)
-#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4        ((CsrWifiSmeEncryption) 0x0200)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeFirmwareDriverInterface
-
-  DESCRIPTION
-    Type of communication between Host and Firmware
-
- VALUES
-    CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE
-                   - No preformated header. NOT SUPPORTED in the current release
-    CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE
-                   - Preformated IEEE 802.11 header for user plane
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeFirmwareDriverInterface;
-#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE   ((CsrWifiSmeFirmwareDriverInterface) 0x00)
-#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE      ((CsrWifiSmeFirmwareDriverInterface) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostPowerMode
-
-  DESCRIPTION
-    Defines the power mode
-
- VALUES
-    CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE
-                   - Host device is running on external power.
-    CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE
-                   - Host device is running on (internal) battery power.
-    CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE
-                   - For future use.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeHostPowerMode;
-#define CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE            ((CsrWifiSmeHostPowerMode) 0x00)
-#define CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE        ((CsrWifiSmeHostPowerMode) 0x01)
-#define CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE   ((CsrWifiSmeHostPowerMode) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeIEEE80211Reason
-
-  DESCRIPTION
-    As definined in the IEEE 802.11 standards
-
- VALUES
-    CSR_WIFI_SME_IEEE80211_REASON_SUCCESS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_END_TS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_END_DLS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_END_BA
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED
-                   - See IEEE 802.11 Standard
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeIEEE80211Reason;
-#define CSR_WIFI_SME_IEEE80211_REASON_SUCCESS                                   ((CsrWifiSmeIEEE80211Reason) 0x0000)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON                        ((CsrWifiSmeIEEE80211Reason) 0x0001)
-#define CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID                  ((CsrWifiSmeIEEE80211Reason) 0x0002)
-#define CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS                 ((CsrWifiSmeIEEE80211Reason) 0x0003)
-#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY                  ((CsrWifiSmeIEEE80211Reason) 0x0004)
-#define CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD                               ((CsrWifiSmeIEEE80211Reason) 0x0005)
-#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR                        ((CsrWifiSmeIEEE80211Reason) 0x0006)
-#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR                        ((CsrWifiSmeIEEE80211Reason) 0x0007)
-#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS                   ((CsrWifiSmeIEEE80211Reason) 0x0008)
-#define CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED             ((CsrWifiSmeIEEE80211Reason) 0x0009)
-#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY            ((CsrWifiSmeIEEE80211Reason) 0x000a)
-#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS          ((CsrWifiSmeIEEE80211Reason) 0x000b)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT               ((CsrWifiSmeIEEE80211Reason) 0x000d)
-#define CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE                       ((CsrWifiSmeIEEE80211Reason) 0x000e)
-#define CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT                 ((CsrWifiSmeIEEE80211Reason) 0x000f)
-#define CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT                  ((CsrWifiSmeIEEE80211Reason) 0x0010)
-#define CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT               ((CsrWifiSmeIEEE80211Reason) 0x0011)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER                      ((CsrWifiSmeIEEE80211Reason) 0x0012)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER                   ((CsrWifiSmeIEEE80211Reason) 0x0013)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP                              ((CsrWifiSmeIEEE80211Reason) 0x0014)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION                 ((CsrWifiSmeIEEE80211Reason) 0x0015)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES                ((CsrWifiSmeIEEE80211Reason) 0x0016)
-#define CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED                         ((CsrWifiSmeIEEE80211Reason) 0x0017)
-#define CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY                 ((CsrWifiSmeIEEE80211Reason) 0x0018)
-#define CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS               ((CsrWifiSmeIEEE80211Reason) 0x001F)
-#define CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON                    ((CsrWifiSmeIEEE80211Reason) 0x0020)
-#define CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH                ((CsrWifiSmeIEEE80211Reason) 0x0021)
-#define CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK                     ((CsrWifiSmeIEEE80211Reason) 0x0022)
-#define CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED                    ((CsrWifiSmeIEEE80211Reason) 0x0023)
-#define CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING                              ((CsrWifiSmeIEEE80211Reason) 0x0024)
-#define CSR_WIFI_SME_IEEE80211_REASON_END_TS                                    ((CsrWifiSmeIEEE80211Reason) 0x0025)
-#define CSR_WIFI_SME_IEEE80211_REASON_END_DLS                                   ((CsrWifiSmeIEEE80211Reason) 0x0025)
-#define CSR_WIFI_SME_IEEE80211_REASON_END_BA                                    ((CsrWifiSmeIEEE80211Reason) 0x0025)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS                                ((CsrWifiSmeIEEE80211Reason) 0x0026)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA                                ((CsrWifiSmeIEEE80211Reason) 0x0026)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS                               ((CsrWifiSmeIEEE80211Reason) 0x0026)
-#define CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT                                   ((CsrWifiSmeIEEE80211Reason) 0x0027)
-#define CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH                           ((CsrWifiSmeIEEE80211Reason) 0x002d)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT           ((CsrWifiSmeIEEE80211Reason) 0xf019)
-#define CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT        ((CsrWifiSmeIEEE80211Reason) 0xf01a)
-#define CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE   ((CsrWifiSmeIEEE80211Reason) 0xf01b)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER                  ((CsrWifiSmeIEEE80211Reason) 0xf01c)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER                    ((CsrWifiSmeIEEE80211Reason) 0xf01d)
-#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION               ((CsrWifiSmeIEEE80211Reason) 0xf01e)
-#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE                ((CsrWifiSmeIEEE80211Reason) 0xf01f)
-#define CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED     ((CsrWifiSmeIEEE80211Reason) 0xf020)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeIEEE80211Result
-
-  DESCRIPTION
-    As definined in the IEEE 802.11 standards
-
- VALUES
-    CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_FAILURE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE
-                   - See IEEE 802.11 Standard
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeIEEE80211Result;
-#define CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS                                          ((CsrWifiSmeIEEE80211Result) 0x0000)
-#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE                              ((CsrWifiSmeIEEE80211Result) 0x0001)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH                    ((CsrWifiSmeIEEE80211Result) 0x000a)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION              ((CsrWifiSmeIEEE80211Result) 0x000b)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON                          ((CsrWifiSmeIEEE80211Result) 0x000c)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH                  ((CsrWifiSmeIEEE80211Result) 0x000d)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER   ((CsrWifiSmeIEEE80211Result) 0x000e)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE                        ((CsrWifiSmeIEEE80211Result) 0x000f)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT                   ((CsrWifiSmeIEEE80211Result) 0x0010)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY                         ((CsrWifiSmeIEEE80211Result) 0x0011)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH                     ((CsrWifiSmeIEEE80211Result) 0x0012)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED                  ((CsrWifiSmeIEEE80211Result) 0x0013)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED                 ((CsrWifiSmeIEEE80211Result) 0x0014)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED                 ((CsrWifiSmeIEEE80211Result) 0x0015)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED             ((CsrWifiSmeIEEE80211Result) 0x0016)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE            ((CsrWifiSmeIEEE80211Result) 0x0017)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE          ((CsrWifiSmeIEEE80211Result) 0x0018)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED                      ((CsrWifiSmeIEEE80211Result) 0x0019)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED                        ((CsrWifiSmeIEEE80211Result) 0x001a)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT                            ((CsrWifiSmeIEEE80211Result) 0x001b)
-#define CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE                                 ((CsrWifiSmeIEEE80211Result) 0x001c)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT                   ((CsrWifiSmeIEEE80211Result) 0x001d)
-#define CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY         ((CsrWifiSmeIEEE80211Result) 0x001e)
-#define CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION         ((CsrWifiSmeIEEE80211Result) 0x001f)
-#define CSR_WIFI_SME_IEEE80211_RESULT_FAILURE                                          ((CsrWifiSmeIEEE80211Result) 0x0020)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT                ((CsrWifiSmeIEEE80211Result) 0x0021)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL                   ((CsrWifiSmeIEEE80211Result) 0x0022)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED                             ((CsrWifiSmeIEEE80211Result) 0x0023)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED                       ((CsrWifiSmeIEEE80211Result) 0x0025)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED                                          ((CsrWifiSmeIEEE80211Result) 0x0025)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS                               ((CsrWifiSmeIEEE80211Result) 0x0026)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES            ((CsrWifiSmeIEEE80211Result) 0x0027)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE                              ((CsrWifiSmeIEEE80211Result) 0x0028)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER                    ((CsrWifiSmeIEEE80211Result) 0x0029)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER                 ((CsrWifiSmeIEEE80211Result) 0x002a)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP                            ((CsrWifiSmeIEEE80211Result) 0x002b)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION                 ((CsrWifiSmeIEEE80211Result) 0x002c)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY                  ((CsrWifiSmeIEEE80211Result) 0x002d)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY                         ((CsrWifiSmeIEEE80211Result) 0x002e)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD                        ((CsrWifiSmeIEEE80211Result) 0x002f)
-#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED                                      ((CsrWifiSmeIEEE80211Result) 0x0030)
-#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT                                      ((CsrWifiSmeIEEE80211Result) 0x0031)
-#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA                                         ((CsrWifiSmeIEEE80211Result) 0x0032)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE               ((CsrWifiSmeIEEE80211Result) 0x0033)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT                    ((CsrWifiSmeIEEE80211Result) 0x0034)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID                                    ((CsrWifiSmeIEEE80211Result) 0x0035)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE                                     ((CsrWifiSmeIEEE80211Result) 0x0036)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE                                     ((CsrWifiSmeIEEE80211Result) 0x0037)
-#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE                          ((CsrWifiSmeIEEE80211Result) 0x00c8)
-#define CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY                                     ((CsrWifiSmeIEEE80211Result) 0x00c9)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH                           ((CsrWifiSmeIEEE80211Result) 0x00ca)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS                         ((CsrWifiSmeIEEE80211Result) 0x00cb)
-#define CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT                                          ((CsrWifiSmeIEEE80211Result) 0x8000)
-#define CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS                   ((CsrWifiSmeIEEE80211Result) 0x8001)
-#define CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED                    ((CsrWifiSmeIEEE80211Result) 0x8002)
-#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED                                    ((CsrWifiSmeIEEE80211Result) 0x8003)
-#define CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE                             ((CsrWifiSmeIEEE80211Result) 0x8004)
-#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED                        ((CsrWifiSmeIEEE80211Result) 0x8005)
-#define CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START                      ((CsrWifiSmeIEEE80211Result) 0x8006)
-#define CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE                              ((CsrWifiSmeIEEE80211Result) 0x8007)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER                           ((CsrWifiSmeIEEE80211Result) 0xf02f)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER                         ((CsrWifiSmeIEEE80211Result) 0xf030)
-#define CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION                      ((CsrWifiSmeIEEE80211Result) 0xf031)
-#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE                       ((CsrWifiSmeIEEE80211Result) 0xf032)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeIndications
-
-  DESCRIPTION
-    Defines bits for CsrWifiSmeIndicationsMask
-
- VALUES
-    CSR_WIFI_SME_INDICATIONS_NONE
-                   - Used to cancel the registrations for receiving indications
-    CSR_WIFI_SME_INDICATIONS_WIFIOFF
-                   - Used to register for CSR_WIFI_SME_WIFI_OFF_IND events
-    CSR_WIFI_SME_INDICATIONS_SCANRESULT
-                   - Used to register for CSR_WIFI_SME_SCAN_RESULT_IND events
-    CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY
-                   - Used to register for CSR_WIFI_SME_CONNECTION_QUALITY_IND
-                     events
-    CSR_WIFI_SME_INDICATIONS_MEDIASTATUS
-                   - Used to register for CSR_WIFI_SME_MEDIA_STATUS_IND events
-    CSR_WIFI_SME_INDICATIONS_MICFAILURE
-                   - Used to register for CSR_WIFI_SME_MICFAILURE_IND events
-    CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST
-                   - Used to register for CSR_WIFI_SME_PMKIDCANDIDATE_LIST_IND
-                     events
-    CSR_WIFI_SME_INDICATIONS_TSPEC
-                   - Used to register for CSR_WIFI_SME_TSPEC_IND events
-    CSR_WIFI_SME_INDICATIONS_ROAMSTART
-                   - Used to register for CSR_WIFI_SME_ROAM_START_IND events
-    CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE
-                   - Used to register for CSR_WIFI_SME_ROAM_COMPLETE_IND events
-    CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART
-                   - Used to register for CSR_WIFI_SME_ASSOCIATION_START_IND
-                     events
-    CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE
-                   - Used to register for CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND
-                     events
-    CSR_WIFI_SME_INDICATIONS_IBSSSTATION
-                   - Used to register for CSR_WIFI_SME_IBSS_STATION_IND events
-    CSR_WIFI_SME_INDICATIONS_WIFION
-                   - Used to register for CSR_WIFI_SME_WIFI_ON_IND events
-    CSR_WIFI_SME_INDICATIONS_ERROR
-                   - Used to register for CSR_WIFI_SME_ERROR_IND events
-    CSR_WIFI_SME_INDICATIONS_INFO
-                   - Used to register for CSR_WIFI_SME_INFO_IND events
-    CSR_WIFI_SME_INDICATIONS_COREDUMP
-                   - Used to register for CSR_WIFI_SME_CORE_DUMP_IND events
-    CSR_WIFI_SME_INDICATIONS_ALL
-                   - Used to register for all available indications
-
-*******************************************************************************/
-typedef u32 CsrWifiSmeIndications;
-#define CSR_WIFI_SME_INDICATIONS_NONE                  ((CsrWifiSmeIndications) 0x00000000)
-#define CSR_WIFI_SME_INDICATIONS_WIFIOFF               ((CsrWifiSmeIndications) 0x00000001)
-#define CSR_WIFI_SME_INDICATIONS_SCANRESULT            ((CsrWifiSmeIndications) 0x00000002)
-#define CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY     ((CsrWifiSmeIndications) 0x00000004)
-#define CSR_WIFI_SME_INDICATIONS_MEDIASTATUS           ((CsrWifiSmeIndications) 0x00000008)
-#define CSR_WIFI_SME_INDICATIONS_MICFAILURE            ((CsrWifiSmeIndications) 0x00000010)
-#define CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST    ((CsrWifiSmeIndications) 0x00000020)
-#define CSR_WIFI_SME_INDICATIONS_TSPEC                 ((CsrWifiSmeIndications) 0x00000040)
-#define CSR_WIFI_SME_INDICATIONS_ROAMSTART             ((CsrWifiSmeIndications) 0x00000080)
-#define CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE          ((CsrWifiSmeIndications) 0x00000100)
-#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART      ((CsrWifiSmeIndications) 0x00000200)
-#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE   ((CsrWifiSmeIndications) 0x00000400)
-#define CSR_WIFI_SME_INDICATIONS_IBSSSTATION           ((CsrWifiSmeIndications) 0x00000800)
-#define CSR_WIFI_SME_INDICATIONS_WIFION                ((CsrWifiSmeIndications) 0x00001000)
-#define CSR_WIFI_SME_INDICATIONS_ERROR                 ((CsrWifiSmeIndications) 0x00002000)
-#define CSR_WIFI_SME_INDICATIONS_INFO                  ((CsrWifiSmeIndications) 0x00004000)
-#define CSR_WIFI_SME_INDICATIONS_COREDUMP              ((CsrWifiSmeIndications) 0x00008000)
-#define CSR_WIFI_SME_INDICATIONS_ALL                   ((CsrWifiSmeIndications) 0xFFFFFFFF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeKeyType
-
-  DESCRIPTION
-    Indicates the type of the key
-
- VALUES
-    CSR_WIFI_SME_KEY_TYPE_GROUP    - Key for broadcast communication
-    CSR_WIFI_SME_KEY_TYPE_PAIRWISE - Key for unicast communication
-    CSR_WIFI_SME_KEY_TYPE_STAKEY   - Key for direct link communication to
-                                     another station in infrastructure networks
-    CSR_WIFI_SME_KEY_TYPE_IGTK     - Integrity Group Temporal Key
-    CSR_WIFI_SME_KEY_TYPE_CCKM     - Key for Cisco Centralized Key Management
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeKeyType;
-#define CSR_WIFI_SME_KEY_TYPE_GROUP      ((CsrWifiSmeKeyType) 0x00)
-#define CSR_WIFI_SME_KEY_TYPE_PAIRWISE   ((CsrWifiSmeKeyType) 0x01)
-#define CSR_WIFI_SME_KEY_TYPE_STAKEY     ((CsrWifiSmeKeyType) 0x02)
-#define CSR_WIFI_SME_KEY_TYPE_IGTK       ((CsrWifiSmeKeyType) 0x03)
-#define CSR_WIFI_SME_KEY_TYPE_CCKM       ((CsrWifiSmeKeyType) 0x04)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeListAction
-
-  DESCRIPTION
-    Identifies the type of action to be performed on a list of items
-    The values of this type are used across the NME/SME/Router API's and they
-    must be kept consistent with the corresponding types in the .xml of the
-    ottherinterfaces
-
- VALUES
-    CSR_WIFI_SME_LIST_ACTION_GET    - Retrieve the current list of items
-    CSR_WIFI_SME_LIST_ACTION_ADD    - Add one or more items
-    CSR_WIFI_SME_LIST_ACTION_REMOVE - Remove one or more items
-    CSR_WIFI_SME_LIST_ACTION_FLUSH  - Remove all items
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeListAction;
-#define CSR_WIFI_SME_LIST_ACTION_GET      ((CsrWifiSmeListAction) 0x00)
-#define CSR_WIFI_SME_LIST_ACTION_ADD      ((CsrWifiSmeListAction) 0x01)
-#define CSR_WIFI_SME_LIST_ACTION_REMOVE   ((CsrWifiSmeListAction) 0x02)
-#define CSR_WIFI_SME_LIST_ACTION_FLUSH    ((CsrWifiSmeListAction) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMediaStatus
-
-  DESCRIPTION
-    Indicates the connection status
-    The values of this type are used across the NME/SME/Router API's and they
-    must be kept consistent with the corresponding types in the .xml of the
-    ottherinterfaces
-
- VALUES
-    CSR_WIFI_SME_MEDIA_STATUS_CONNECTED
-                   - Value CSR_WIFI_SME_MEDIA_STATUS_CONNECTED can happen in two
-                     situations:
-                       * A network connection is established. Specifically, this is
-                         when the MLME_ASSOCIATION completes or the first peer
-                         relationship is established in an IBSS. In a WPA/WPA2
-                         network, this indicates that the stack is ready to perform
-                         the 4-way handshake or 802.1x authentication if CSR NME
-                         security library is not used. If CSR NME security library
-                         is used this indicates, completion of 4way handshake or
-                         802.1x authentication
-                       * The SME roams to another AP on the same ESS
-                     During the AP operation, it indicates that the peer station
-                     is connected to the AP and is ready for data transfer.
-    CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED
-                   - Value CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED can happen in
-                     two situations:
-                       * when the connection to a network is lost and there is no
-                         alternative on the same ESS to roam to
-                       * when a CSR_WIFI_SME_DISCONNECT_REQ request is issued
-                     During AP or P2PGO operation, it indicates that the peer
-                     station has disconnected from the AP
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeMediaStatus;
-#define CSR_WIFI_SME_MEDIA_STATUS_CONNECTED      ((CsrWifiSmeMediaStatus) 0x00)
-#define CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED   ((CsrWifiSmeMediaStatus) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pCapability
-
-  DESCRIPTION
-    Defines P2P Device Capabilities
-
- VALUES
-    CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY
-                   - This field is set to 1 if the P2P Device supports Service
-                     Discovery, and to 0 otherwise
-    CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY
-                   - This field is set to 1 when the P2P Device supports P2P
-                     Client Discoverability, and to 0 otherwise.
-    CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY
-                   - This field is set to 1 when the P2P Device supports
-                     Concurrent Operation with WLAN, and to 0 otherwise.
-    CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY
-                   - This field is set to 1 when the P2P interface of the P2P
-                     Device is capable of being managed by the WLAN
-                     (infrastructure network) based on P2P coexistence
-                     parameters, and to 0 otherwise
-    CSR_WIFI_SME_P2P_INVITAION_CAPABILITY
-                   - This field is set to 1 if the P2P Device is capable of
-                     processing P2P Invitation Procedure signaling, and to 0
-                     otherwise.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pCapability;
-#define CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY        ((CsrWifiSmeP2pCapability) 0x01)
-#define CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY   ((CsrWifiSmeP2pCapability) 0x02)
-#define CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY     ((CsrWifiSmeP2pCapability) 0x04)
-#define CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY           ((CsrWifiSmeP2pCapability) 0x08)
-#define CSR_WIFI_SME_P2P_INVITAION_CAPABILITY                ((CsrWifiSmeP2pCapability) 0x20)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pGroupCapability
-
-  DESCRIPTION
-    Define bits for P2P Group Capability
-
- VALUES
-    CSR_WIFI_P2P_GRP_CAP_GO
-                   - Indicates if the local device has become a GO after GO
-                     negotiation
-    CSR_WIFI_P2P_GRP_CAP_PERSISTENT
-                   - Persistent group
-    CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST
-                   - Intra-BSS data distribution support
-    CSR_WIFI_P2P_GRP_CAP_CROSS_CONN
-                   - Support of cross connection
-    CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT
-                   - Support of persistent reconnect
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pGroupCapability;
-#define CSR_WIFI_P2P_GRP_CAP_GO                     ((CsrWifiSmeP2pGroupCapability) 0x01)
-#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT             ((CsrWifiSmeP2pGroupCapability) 0x02)
-#define CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST          ((CsrWifiSmeP2pGroupCapability) 0x08)
-#define CSR_WIFI_P2P_GRP_CAP_CROSS_CONN             ((CsrWifiSmeP2pGroupCapability) 0x10)
-#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT   ((CsrWifiSmeP2pGroupCapability) 0x20)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pNoaConfigMethod
-
-  DESCRIPTION
-    Notice of Absece Configuration
-
- VALUES
-    CSR_WIFI_P2P_NOA_NONE         - Do not use NOA
-    CSR_WIFI_P2P_NOA_AUTONOMOUS   - NOA based on the traffic analysis
-    CSR_WIFI_P2P_NOA_USER_DEFINED - NOA as specified by the user
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pNoaConfigMethod;
-#define CSR_WIFI_P2P_NOA_NONE           ((CsrWifiSmeP2pNoaConfigMethod) 0x00)
-#define CSR_WIFI_P2P_NOA_AUTONOMOUS     ((CsrWifiSmeP2pNoaConfigMethod) 0x01)
-#define CSR_WIFI_P2P_NOA_USER_DEFINED   ((CsrWifiSmeP2pNoaConfigMethod) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pRole
-
-  DESCRIPTION
-    Definition of roles for a P2P Device
-
- VALUES
-    CSR_WIFI_SME_P2P_ROLE_NONE       - A non-P2PDevice device
-    CSR_WIFI_SME_P2P_ROLE_STANDALONE - A Standalone P2P device
-    CSR_WIFI_SME_P2P_ROLE_GO         - Role Assumed is that of a Group Owner
-                                       within a P2P Group
-    CSR_WIFI_SME_P2P_ROLE_CLI        - Role Assumed is that of a P2P Client
-                                       within a P2P Group
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pRole;
-#define CSR_WIFI_SME_P2P_ROLE_NONE         ((CsrWifiSmeP2pRole) 0x00)
-#define CSR_WIFI_SME_P2P_ROLE_STANDALONE   ((CsrWifiSmeP2pRole) 0x01)
-#define CSR_WIFI_SME_P2P_ROLE_GO           ((CsrWifiSmeP2pRole) 0x02)
-#define CSR_WIFI_SME_P2P_ROLE_CLI          ((CsrWifiSmeP2pRole) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pStatus
-
-  DESCRIPTION
-    This data type enumerates the outcome of P2P procedure
-
- VALUES
-    CSR_WIFI_SME_P2P_STATUS_SUCCESS
-                   - Success
-    CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE
-                   - Fail; information is currently unavailable
-    CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM
-                   - Fail; incompatible parameters
-    CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED
-                   - Fail; limit reached
-    CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM
-                   - Fail; invalid parameters
-    CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE
-                   - Fail; unable to accommodate request
-    CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR
-                   - Fail; previous protocol error, or disruptive behavior
-    CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS
-                   - Fail; no common channels
-    CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP
-                   - Fail; unknown P2P Group
-    CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT
-                   - Fail: both P2P Devices indicated an Intent of 15 in Group
-                     Owner Negotiation
-    CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE
-                   - Fail; incompatible provisioning method
-    CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT
-                   - Fail: rejected by user
-    CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED
-                   - Fail; Status Reserved
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pStatus;
-#define CSR_WIFI_SME_P2P_STATUS_SUCCESS                              ((CsrWifiSmeP2pStatus) 0x00)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE                ((CsrWifiSmeP2pStatus) 0x01)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM              ((CsrWifiSmeP2pStatus) 0x02)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED                   ((CsrWifiSmeP2pStatus) 0x03)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM                   ((CsrWifiSmeP2pStatus) 0x04)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE                      ((CsrWifiSmeP2pStatus) 0x05)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR                      ((CsrWifiSmeP2pStatus) 0x06)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS                 ((CsrWifiSmeP2pStatus) 0x07)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP                   ((CsrWifiSmeP2pStatus) 0x08)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT                       ((CsrWifiSmeP2pStatus) 0x09)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE   ((CsrWifiSmeP2pStatus) 0x0A)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT                          ((CsrWifiSmeP2pStatus) 0x0B)
-#define CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED                        ((CsrWifiSmeP2pStatus) 0xFF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePacketFilterMode
-
-  DESCRIPTION
-    Options for the filter mode parameter.
-    The Values here match the HIP interface
-
- VALUES
-    CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT
-                   - Broadcast packets are always reported to the host unless
-                     they match at least one of the specified TCLAS IEs.
-    CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN
-                   - Broadcast packets are reported to the host only if they
-                     match at least one of the specified TCLAS IEs.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmePacketFilterMode;
-#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT   ((CsrWifiSmePacketFilterMode) 0x00)
-#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN    ((CsrWifiSmePacketFilterMode) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerSaveLevel
-
-  DESCRIPTION
-    Power Save Level options as defined in the IEEE 802.11 standards
-    First 3 values are set to match the mlme PowerManagementMode
-
- VALUES
-    CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW  - No power save: the driver will remain
-                                         active at all times
-    CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH - Enter power save after all packets in
-                                         the queues are transmitted and received
-    CSR_WIFI_SME_POWER_SAVE_LEVEL_MED  - Enter power save after all packets in
-                                         the queues are transmitted and received
-                                         and a further configurable delay
-                                         (default 1s) has elapsed
-    CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO - The SME will decide when to enter power
-                                         save mode according to the traffic
-                                         analysis
-
-*******************************************************************************/
-typedef u8 CsrWifiSmePowerSaveLevel;
-#define CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW    ((CsrWifiSmePowerSaveLevel) 0x00)
-#define CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH   ((CsrWifiSmePowerSaveLevel) 0x01)
-#define CSR_WIFI_SME_POWER_SAVE_LEVEL_MED    ((CsrWifiSmePowerSaveLevel) 0x02)
-#define CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO   ((CsrWifiSmePowerSaveLevel) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePreambleType
-
-  DESCRIPTION
-    SME Preamble Types
-
- VALUES
-    CSR_WIFI_SME_USE_LONG_PREAMBLE  - Use legacy (long) preamble
-    CSR_WIFI_SME_USE_SHORT_PREAMBLE - Use short PPDU format
-
-*******************************************************************************/
-typedef u8 CsrWifiSmePreambleType;
-#define CSR_WIFI_SME_USE_LONG_PREAMBLE    ((CsrWifiSmePreambleType) 0x00)
-#define CSR_WIFI_SME_USE_SHORT_PREAMBLE   ((CsrWifiSmePreambleType) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRadioIF
-
-  DESCRIPTION
-    Indicates the frequency
-
- VALUES
-    CSR_WIFI_SME_RADIO_IF_GHZ_2_4 - Indicates the 2.4 GHZ frequency
-    CSR_WIFI_SME_RADIO_IF_GHZ_5_0 - Future use: currently not supported
-    CSR_WIFI_SME_RADIO_IF_BOTH    - Future use: currently not supported
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeRadioIF;
-#define CSR_WIFI_SME_RADIO_IF_GHZ_2_4   ((CsrWifiSmeRadioIF) 0x01)
-#define CSR_WIFI_SME_RADIO_IF_GHZ_5_0   ((CsrWifiSmeRadioIF) 0x02)
-#define CSR_WIFI_SME_RADIO_IF_BOTH      ((CsrWifiSmeRadioIF) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRegulatoryDomain
-
-  DESCRIPTION
-    Indicates the regulatory domain as defined in IEEE 802.11 standards
-
- VALUES
-    CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_FCC
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_IC
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS
-                   - See IEEE 802.11 Standard
-    CSR_WIFI_SME_REGULATORY_DOMAIN_NONE
-                   - See IEEE 802.11 Standard
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeRegulatoryDomain;
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER      ((CsrWifiSmeRegulatoryDomain) 0x00)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_FCC        ((CsrWifiSmeRegulatoryDomain) 0x10)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_IC         ((CsrWifiSmeRegulatoryDomain) 0x20)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI       ((CsrWifiSmeRegulatoryDomain) 0x30)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN      ((CsrWifiSmeRegulatoryDomain) 0x31)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE     ((CsrWifiSmeRegulatoryDomain) 0x32)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN      ((CsrWifiSmeRegulatoryDomain) 0x40)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS   ((CsrWifiSmeRegulatoryDomain) 0x41)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA      ((CsrWifiSmeRegulatoryDomain) 0x50)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS   ((CsrWifiSmeRegulatoryDomain) 0x51)
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_NONE       ((CsrWifiSmeRegulatoryDomain) 0xFF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamReason
-
-  DESCRIPTION
-    Indicates the reason for roaming
-
- VALUES
-    CSR_WIFI_SME_ROAM_REASON_BEACONLOST
-                   - The station cannot receive the beacon signal any more
-    CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED
-                   - The station has been disassociated
-    CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED
-                   - The station has been deauthenticated
-    CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND
-                   - A better AP has been found
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeRoamReason;
-#define CSR_WIFI_SME_ROAM_REASON_BEACONLOST        ((CsrWifiSmeRoamReason) 0x00)
-#define CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED     ((CsrWifiSmeRoamReason) 0x01)
-#define CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED   ((CsrWifiSmeRoamReason) 0x02)
-#define CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND     ((CsrWifiSmeRoamReason) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanType
-
-  DESCRIPTION
-    Identifies the type of scan to be performed
-
- VALUES
-    CSR_WIFI_SME_SCAN_TYPE_ALL     - Scan actively or passively according to the
-                                     regulatory domain restrictions
-    CSR_WIFI_SME_SCAN_TYPE_ACTIVE  - Scan actively only: send probes and listen
-                                     for answers
-    CSR_WIFI_SME_SCAN_TYPE_PASSIVE - Scan passively only: listen for beacon
-                                     messages
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeScanType;
-#define CSR_WIFI_SME_SCAN_TYPE_ALL       ((CsrWifiSmeScanType) 0x00)
-#define CSR_WIFI_SME_SCAN_TYPE_ACTIVE    ((CsrWifiSmeScanType) 0x01)
-#define CSR_WIFI_SME_SCAN_TYPE_PASSIVE   ((CsrWifiSmeScanType) 0x02)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTrafficType
-
-  DESCRIPTION
-    Identifies the type of traffic going on on the connection.
-    The values of this type are used across the NME/SME/Router API's and they
-    must be kept consistent with the corresponding types in the .xml of the
-    ottherinterfaces
-
- VALUES
-    CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL
-                   - During the last 30 seconds there were fewer than 20 packets
-                     per seconds in each second in both directions
-    CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY
-                   - During the last 30 seconds there was at least one second
-                     during which more than 20 packets were received in either
-                     direction
-    CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC
-                   - During the last 5 seconds there were at least 10 packets
-                     received each second and a defined period for the traffic
-                     can be recognized
-    CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS
-                   - During the last 5 seconds there were at least 20 packets
-                     received each second in either direction
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeTrafficType;
-#define CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL   ((CsrWifiSmeTrafficType) 0x00)
-#define CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY       ((CsrWifiSmeTrafficType) 0x01)
-#define CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC     ((CsrWifiSmeTrafficType) 0x02)
-#define CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS   ((CsrWifiSmeTrafficType) 0x03)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecCtrl
-
-  DESCRIPTION
-    Defines bits for CsrWifiSmeTspecCtrlMask for additional CCX configuration.
-    CURRENTLY NOT SUPPORTED.
-
- VALUES
-    CSR_WIFI_SME_TSPEC_CTRL_STRICT
-                   - No automatic negotiation
-    CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING
-                   - Signalling TSPEC
-    CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE
-                   - Voice traffic TSPEC
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeTspecCtrl;
-#define CSR_WIFI_SME_TSPEC_CTRL_STRICT           ((CsrWifiSmeTspecCtrl) 0x01)
-#define CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING   ((CsrWifiSmeTspecCtrl) 0x02)
-#define CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE        ((CsrWifiSmeTspecCtrl) 0x04)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecResultCode
-
-  DESCRIPTION
-    Defines the result of the TSPEC exchanges with the AP
-
- VALUES
-    CSR_WIFI_SME_TSPEC_RESULT_SUCCESS
-                   - TSPEC command has been processed correctly
-    CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE
-                   - The Access Point reported a failure
-    CSR_WIFI_SME_TSPEC_RESULT_FAILURE
-                   - Internal failure in the SME
-    CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS
-                   - The TSPEC parameters are invalid
-    CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS
-                   - The TCLASS parameters are invalid
-    CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH
-                   - As specified by the WMM Spec
-    CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY
-                   - As specified by the WMM Spec
-    CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES
-                   - As specified by the WMM Spec
-    CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT
-                   - The TSPEC negotiation timed out
-    CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED
-                   - The Access Point does not support the TSPEC
-    CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT
-                   - The length of the TSPEC is not correct
-    CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID
-                   - The TSPEC transaction id is not in the list
-    CSR_WIFI_SME_TSPEC_RESULT_INSTALLED
-                   - The TSPEC has been installed and it is now active.
-    CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED
-                   - The Traffic ID has already been installed
-    CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED
-                   - The AP has deleted the TSPEC
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeTspecResultCode;
-#define CSR_WIFI_SME_TSPEC_RESULT_SUCCESS                           ((CsrWifiSmeTspecResultCode) 0x00)
-#define CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE           ((CsrWifiSmeTspecResultCode) 0x01)
-#define CSR_WIFI_SME_TSPEC_RESULT_FAILURE                           ((CsrWifiSmeTspecResultCode) 0x02)
-#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS          ((CsrWifiSmeTspecResultCode) 0x05)
-#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS          ((CsrWifiSmeTspecResultCode) 0x06)
-#define CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH            ((CsrWifiSmeTspecResultCode) 0x07)
-#define CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY                      ((CsrWifiSmeTspecResultCode) 0x08)
-#define CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES   ((CsrWifiSmeTspecResultCode) 0x09)
-#define CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT                           ((CsrWifiSmeTspecResultCode) 0x0D)
-#define CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED                     ((CsrWifiSmeTspecResultCode) 0x0E)
-#define CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT               ((CsrWifiSmeTspecResultCode) 0x10)
-#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID            ((CsrWifiSmeTspecResultCode) 0x11)
-#define CSR_WIFI_SME_TSPEC_RESULT_INSTALLED                         ((CsrWifiSmeTspecResultCode) 0x12)
-#define CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED             ((CsrWifiSmeTspecResultCode) 0x13)
-#define CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED            ((CsrWifiSmeTspecResultCode) 0x14)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWepAuthMode
-
-  DESCRIPTION
-    Define bits for CsrWifiSmeWepAuthMode
-
- VALUES
-    CSR_WIFI_SME_WEP_AUTH_MODE_OPEN   - Open-WEP enabled network
-    CSR_WIFI_SME_WEP_AUTH_MODE_SHARED - Shared-key WEP enabled network.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWepAuthMode;
-#define CSR_WIFI_SME_WEP_AUTH_MODE_OPEN     ((CsrWifiSmeWepAuthMode) 0x00)
-#define CSR_WIFI_SME_WEP_AUTH_MODE_SHARED   ((CsrWifiSmeWepAuthMode) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWepCredentialType
-
-  DESCRIPTION
-    Definition of types of WEP Credentials
-
- VALUES
-    CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64
-                   - WEP 64 credential
-    CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128
-                   - WEP 128 credential
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWepCredentialType;
-#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64    ((CsrWifiSmeWepCredentialType) 0x00)
-#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128   ((CsrWifiSmeWepCredentialType) 0x01)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWmmMode
-
-  DESCRIPTION
-    Defines bits for CsrWifiSmeWmmModeMask: enable/disable WMM features.
-
- VALUES
-    CSR_WIFI_SME_WMM_MODE_DISABLED   - Disables the WMM features.
-    CSR_WIFI_SME_WMM_MODE_AC_ENABLED - Enables support for WMM-AC.
-    CSR_WIFI_SME_WMM_MODE_PS_ENABLED - Enables support for WMM Power Save.
-    CSR_WIFI_SME_WMM_MODE_SA_ENABLED - Currently not supported
-    CSR_WIFI_SME_WMM_MODE_ENABLED    - Enables support for all currently
-                                       available WMM features.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWmmMode;
-#define CSR_WIFI_SME_WMM_MODE_DISABLED     ((CsrWifiSmeWmmMode) 0x00)
-#define CSR_WIFI_SME_WMM_MODE_AC_ENABLED   ((CsrWifiSmeWmmMode) 0x01)
-#define CSR_WIFI_SME_WMM_MODE_PS_ENABLED   ((CsrWifiSmeWmmMode) 0x02)
-#define CSR_WIFI_SME_WMM_MODE_SA_ENABLED   ((CsrWifiSmeWmmMode) 0x04)
-#define CSR_WIFI_SME_WMM_MODE_ENABLED      ((CsrWifiSmeWmmMode) 0xFF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWmmQosInfo
-
-  DESCRIPTION
-    Defines bits for the QoS Info Octect as defined in the WMM specification.
-    The first four values define one bit each that can be set or cleared.
-    Each of the last four values define all the remaining 4 bits and only one
-    of them at the time shall be used.
-    For more information, see 'WMM (including WMM Power Save) Specification -
-    Version 1.1' and 'UniFi Configuring WMM and WMM-PS, Application Note'.
-
- VALUES
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL
-                   - WMM AP may deliver all buffered frames
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_VO
-                   - Enable UAPSD(both trigger and delivery) for Voice Access
-                     Category
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_VI
-                   - Enable UAPSD(both trigger and delivery) for  Video Access
-                     Category
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_BK
-                   - Enable UAPSD(both trigger and delivery) for  Background
-                     Access Category
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_BE
-                   - Enable UAPSD(both trigger and delivery) for  Best Effort
-                     Access Category
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO
-                   - WMM AP may deliver a maximum of 2 buffered frames (MSDUs
-                     and MMPDUs) per USP
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR
-                   - WMM AP may deliver a maximum of 4 buffered frames (MSDUs
-                     and MMPDUs) per USP
-    CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX
-                   - WMM AP may deliver a maximum of 6 buffered frames (MSDUs
-                     and MMPDUs) per USP
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWmmQosInfo;
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL    ((CsrWifiSmeWmmQosInfo) 0x00)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VO            ((CsrWifiSmeWmmQosInfo) 0x01)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VI            ((CsrWifiSmeWmmQosInfo) 0x02)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BK            ((CsrWifiSmeWmmQosInfo) 0x04)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BE            ((CsrWifiSmeWmmQosInfo) 0x08)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO    ((CsrWifiSmeWmmQosInfo) 0x20)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR   ((CsrWifiSmeWmmQosInfo) 0x40)
-#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX    ((CsrWifiSmeWmmQosInfo) 0x60)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfigType
-
-  DESCRIPTION
-    WPS config methods supported/used by a device
-
- VALUES
-    CSR_WIFI_WPS_CONFIG_LABEL
-                   - Label
-    CSR_WIFI_WPS_CONFIG_DISPLAY
-                   - Display
-    CSR_WIFI_WPS_CONFIG_EXT_NFC
-                   - External NFC : Not supported in this release
-    CSR_WIFI_WPS_CONFIG_INT_NFC
-                   - Internal NFC : Not supported in this release
-    CSR_WIFI_WPS_CONFIG_NFC_IFACE
-                   - NFC interface : Not supported in this release
-    CSR_WIFI_WPS_CONFIG_PBC
-                   - PBC
-    CSR_WIFI_WPS_CONFIG_KEYPAD
-                   - KeyPad
-    CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC
-                   - PBC through software user interface
-    CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC
-                   - Physical PBC
-    CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY
-                   - Virtual Display : via html config page etc
-    CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY
-                   - Physical Display : Attached to the device
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeWpsConfigType;
-#define CSR_WIFI_WPS_CONFIG_LABEL              ((CsrWifiSmeWpsConfigType) 0x0004)
-#define CSR_WIFI_WPS_CONFIG_DISPLAY            ((CsrWifiSmeWpsConfigType) 0x0008)
-#define CSR_WIFI_WPS_CONFIG_EXT_NFC            ((CsrWifiSmeWpsConfigType) 0x0010)
-#define CSR_WIFI_WPS_CONFIG_INT_NFC            ((CsrWifiSmeWpsConfigType) 0x0020)
-#define CSR_WIFI_WPS_CONFIG_NFC_IFACE          ((CsrWifiSmeWpsConfigType) 0x0040)
-#define CSR_WIFI_WPS_CONFIG_PBC                ((CsrWifiSmeWpsConfigType) 0x0080)
-#define CSR_WIFI_WPS_CONFIG_KEYPAD             ((CsrWifiSmeWpsConfigType) 0x0100)
-#define CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC        ((CsrWifiSmeWpsConfigType) 0x0280)
-#define CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC       ((CsrWifiSmeWpsConfigType) 0x0480)
-#define CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY    ((CsrWifiSmeWpsConfigType) 0x2008)
-#define CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY   ((CsrWifiSmeWpsConfigType) 0x4008)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsDeviceCategory
-
-  DESCRIPTION
-    Wps Primary Device Types
-
- VALUES
-    CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED
-                   - Unspecified.
-    CSR_WIFI_SME_WPS_CATEGORY_COMPUTER
-                   - Computer.
-    CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV
-                   - Input device
-    CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP
-                   - Printer Scanner Fax Copier etc
-    CSR_WIFI_SME_WPS_CATEGORY_CAMERA
-                   - Camera
-    CSR_WIFI_SME_WPS_CATEGORY_STORAGE
-                   - Storage
-    CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA
-                   - Net Infra
-    CSR_WIFI_SME_WPS_CATEGORY_DISPLAY
-                   - Display
-    CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA
-                   - Multimedia
-    CSR_WIFI_SME_WPS_CATEGORY_GAMING
-                   - Gaming.
-    CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE
-                   - Telephone.
-    CSR_WIFI_SME_WPS_CATEGORY_AUDIO
-                   - Audio
-    CSR_WIFI_SME_WPS_CATEOARY_OTHERS
-                   - Others.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWpsDeviceCategory;
-#define CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED      ((CsrWifiSmeWpsDeviceCategory) 0x00)
-#define CSR_WIFI_SME_WPS_CATEGORY_COMPUTER         ((CsrWifiSmeWpsDeviceCategory) 0x01)
-#define CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV        ((CsrWifiSmeWpsDeviceCategory) 0x02)
-#define CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP   ((CsrWifiSmeWpsDeviceCategory) 0x03)
-#define CSR_WIFI_SME_WPS_CATEGORY_CAMERA           ((CsrWifiSmeWpsDeviceCategory) 0x04)
-#define CSR_WIFI_SME_WPS_CATEGORY_STORAGE          ((CsrWifiSmeWpsDeviceCategory) 0x05)
-#define CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA        ((CsrWifiSmeWpsDeviceCategory) 0x06)
-#define CSR_WIFI_SME_WPS_CATEGORY_DISPLAY          ((CsrWifiSmeWpsDeviceCategory) 0x07)
-#define CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA       ((CsrWifiSmeWpsDeviceCategory) 0x08)
-#define CSR_WIFI_SME_WPS_CATEGORY_GAMING           ((CsrWifiSmeWpsDeviceCategory) 0x09)
-#define CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE        ((CsrWifiSmeWpsDeviceCategory) 0x0A)
-#define CSR_WIFI_SME_WPS_CATEGORY_AUDIO            ((CsrWifiSmeWpsDeviceCategory) 0x0B)
-#define CSR_WIFI_SME_WPS_CATEOARY_OTHERS           ((CsrWifiSmeWpsDeviceCategory) 0xFF)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsDeviceSubCategory
-
-  DESCRIPTION
-    Wps Secondary Device Types
-
- VALUES
-    CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED
-                   - Unspecied
-    CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS
-                   - Network Associated Storage
-    CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR
-                   - Printer or print server
-    CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM
-                   - Windows mobile
-    CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER
-                   - Audio tuner/receiver
-    CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL
-                   - Digital still camera
-    CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP
-                   - Access Point
-    CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV
-                   - TV.
-    CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR
-                   - DAR.
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD
-                   - Keyboard.
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC
-                   - PC.
-    CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX
-                   - Xbox.
-    CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR
-                   - Scanner
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER
-                   - Server
-    CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER
-                   - Router
-    CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR
-                   - PVR
-    CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER
-                   - Speaker
-    CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM
-                   - Feature phone - Single mode
-    CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO
-                   - Video camera
-    CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM
-                   - Picture frame
-    CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360
-                   - Xbox360
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE
-                   - Mouse
-    CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH
-                   - Switch
-    CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP
-                   - Portable music player
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK
-                   - Joy stick
-    CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN
-                   - Play-station
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT
-                   - Media Center
-    CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX
-                   - MCX
-    CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM
-                   - Feature phone - Dual mode
-    CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB
-                   - Web camera
-    CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX
-                   - Fax
-    CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR
-                   - Projector
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL
-                   - Track Ball
-    CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX
-                   - Set-Top-Box
-    CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY
-                   - GateWay.
-    CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY
-                   - Security camera
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC
-                   - Ultra mobile PC.
-    CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE
-                   - Game console/Game console adapter
-    CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR
-                   - Copier
-    CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET
-                   - Headset(headphones + microphone)
-    CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM
-                   - Smart phone - Single mode
-    CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR
-                   - Monitor.
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL
-                   - Game control.
-    CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL
-                   - All-in-One
-    CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA
-                   - Media Server/Media Adapter/Media Extender
-    CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM
-                   - Smart phone - Dual mode
-    CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV
-                   - Portable gaming device
-    CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE
-                   - Headphone.
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK
-                   - Notebook.
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE
-                   - Remote control
-    CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC
-                   - Microphone
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP
-                   - Desktop.
-    CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP
-                   - Portable video player
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID
-                   - Mobile internet device
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN
-                   - Touch screen
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR
-                   - Biometric reader
-    CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK
-                   - Netbook
-    CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR
-                   - Bar code reader.
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWpsDeviceSubCategory;
-#define CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED             ((CsrWifiSmeWpsDeviceSubCategory) 0x00)
-#define CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS             ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR              ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM            ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER             ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL          ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP            ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV              ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR                  ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD         ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC             ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX             ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
-#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR               ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER         ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER        ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR                  ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER           ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM         ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO            ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM         ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360         ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE         ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
-#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH        ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP               ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK        ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN         ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT       ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX                  ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM         ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB              ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX                ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR       ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL         ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX               ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY       ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY         ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC   ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE          ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR                ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET           ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM         ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR         ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL     ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL                ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA                ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM         ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV         ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE         ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK       ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE        ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
-#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC               ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP        ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
-#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP                   ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID            ((CsrWifiSmeWpsDeviceSubCategory) 0x07)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN    ((CsrWifiSmeWpsDeviceSubCategory) 0x07)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR    ((CsrWifiSmeWpsDeviceSubCategory) 0x08)
-#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK        ((CsrWifiSmeWpsDeviceSubCategory) 0x08)
-#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR      ((CsrWifiSmeWpsDeviceSubCategory) 0x09)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsDpid
-
-  DESCRIPTION
-    Device Password ID for the chosen config method
-
- VALUES
-    CSR_WIFI_SME_WPS_DPID_PIN       - PIN
-    CSR_WIFI_SME_WPS_DPID_USER      - User specified : Used only during P2P GO
-                                      negotiation procedure
-    CSR_WIFI_SME_WPS_DPID_MACHINE   - Machine specified i: Not used in this
-                                      release
-    CSR_WIFI_SME_WPS_DPID_REKEY     - Rekey : Not used in this release
-    CSR_WIFI_SME_WPS_DPID_PBC       - PBC
-    CSR_WIFI_SME_WPS_DPID_REGISTRAR - Registrar specified : Used only in P2P Go
-                                      negotiation procedure
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeWpsDpid;
-#define CSR_WIFI_SME_WPS_DPID_PIN         ((CsrWifiSmeWpsDpid) 0x0000)
-#define CSR_WIFI_SME_WPS_DPID_USER        ((CsrWifiSmeWpsDpid) 0x0001)
-#define CSR_WIFI_SME_WPS_DPID_MACHINE     ((CsrWifiSmeWpsDpid) 0x0002)
-#define CSR_WIFI_SME_WPS_DPID_REKEY       ((CsrWifiSmeWpsDpid) 0x0003)
-#define CSR_WIFI_SME_WPS_DPID_PBC         ((CsrWifiSmeWpsDpid) 0x0004)
-#define CSR_WIFI_SME_WPS_DPID_REGISTRAR   ((CsrWifiSmeWpsDpid) 0x0005)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsRegistration
-
-  DESCRIPTION
-
- VALUES
-    CSR_WIFI_SME_WPS_REG_NOT_REQUIRED - No encryption set
-    CSR_WIFI_SME_WPS_REG_REQUIRED     - No encryption set
-    CSR_WIFI_SME_WPS_REG_UNKNOWN      - No encryption set
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWpsRegistration;
-#define CSR_WIFI_SME_WPS_REG_NOT_REQUIRED   ((CsrWifiSmeWpsRegistration) 0x00)
-#define CSR_WIFI_SME_WPS_REG_REQUIRED       ((CsrWifiSmeWpsRegistration) 0x01)
-#define CSR_WIFI_SME_WPS_REG_UNKNOWN        ((CsrWifiSmeWpsRegistration) 0x02)
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAuthModeMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeAuthMode
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeAuthModeMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEncryptionMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeEncryption
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeEncryptionMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeIndicationsMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeIndications
-
-*******************************************************************************/
-typedef u32 CsrWifiSmeIndicationsMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pCapabilityMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeP2pCapability
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pCapabilityMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pGroupCapabilityMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeP2pGroupCapability
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeP2pGroupCapabilityMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecCtrlMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeTspecCtrl
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeTspecCtrlMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWmmModeMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeWmmMode
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWmmModeMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWmmQosInfoMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeWmmQosInfo
-
-*******************************************************************************/
-typedef u8 CsrWifiSmeWmmQosInfoMask;
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfigTypeMask
-
-  DESCRIPTION
-    Mask type for use with the values defined by CsrWifiSmeWpsConfigType
-
-*******************************************************************************/
-typedef u16 CsrWifiSmeWpsConfigTypeMask;
-
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdHocConfig
-
-  DESCRIPTION
-    Defines values to use when starting an Ad-hoc (IBSS) network.
-
-  MEMBERS
-    atimWindowTu          - ATIM window specified for IBSS
-    beaconPeriodTu        - Interval between beacon packets
-    joinOnlyAttempts      - Maximum number of attempts to join an ad-hoc network.
-                            The default value is 1.
-                            Set to 0 for infinite attempts.
-    joinAttemptIntervalMs - Time between scans for joining the requested IBSS.
-
-*******************************************************************************/
-typedef struct
-{
-    u16 atimWindowTu;
-    u16 beaconPeriodTu;
-    u16 joinOnlyAttempts;
-    u16 joinAttemptIntervalMs;
-} CsrWifiSmeAdHocConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAvailabilityConfig
-
-  DESCRIPTION
-
-  MEMBERS
-    listenChannel        -
-    availabilityDuration -
-    avalabilityPeriod    -
-
-*******************************************************************************/
-typedef struct
-{
-    u8  listenChannel;
-    u16 availabilityDuration;
-    u16 avalabilityPeriod;
-} CsrWifiSmeAvailabilityConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfig
-
-  DESCRIPTION
-    This type is reserved for future use and should not be used.
-
-  MEMBERS
-    keepAliveTimeMs    - NOT USED
-    apRoamingEnabled   - NOT USED
-    measurementsMask   - NOT USED
-    ccxRadioMgtEnabled - NOT USED
-
-*******************************************************************************/
-typedef struct
-{
-    u8 keepAliveTimeMs;
-    u8  apRoamingEnabled;
-    u8 measurementsMask;
-    u8  ccxRadioMgtEnabled;
-} CsrWifiSmeCcxConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfig
-
-  DESCRIPTION
-    Parameters for the coexistence behaviour.
-
-  MEMBERS
-    coexEnableSchemeManagement     - Enables the Coexistence Management Scheme
-    coexPeriodicWakeHost           - If TRUE the firmware wakes up the host
-                                     periodically according to the traffic
-                                     period and latency parameters; the host
-                                     will then send the data to transmit only
-                                     when woken up.
-                                     If FALSE, the firmware does not wake up the
-                                     host and the host will send the data to
-                                     transmit to the firmware whenever there is
-                                     data to transmit
-    coexTrafficBurstyLatencyMs     - Period of awakening for the firmware used
-                                     when bursty traffic is detected
-    coexTrafficContinuousLatencyMs - Period of awakening for the firmware used
-                                     when continuous traffic is detected
-    coexObexBlackoutDurationMs     - Blackout Duration when a Obex Connection is
-                                     used
-    coexObexBlackoutPeriodMs       - Blackout Period when a Obex Connection is
-                                     used
-    coexA2dpBrBlackoutDurationMs   - Blackout Duration when a Basic Rate A2DP
-                                     Connection streaming data
-    coexA2dpBrBlackoutPeriodMs     - Blackout Period when a Basic Rate A2DP
-                                     Connection streaming data
-    coexA2dpEdrBlackoutDurationMs  - Blackout Duration when an Enhanced Data
-                                     Rate A2DP Connection streaming data
-    coexA2dpEdrBlackoutPeriodMs    - Blackout Period when an Enhanced Data Rate
-                                     A2DP Connection streaming data
-    coexPagingBlackoutDurationMs   - Blackout Duration when a BT page is active
-    coexPagingBlackoutPeriodMs     - Blackout Period when a BT page is active
-    coexInquiryBlackoutDurationMs  - Blackout Duration when a BT inquiry is
-                                     active
-    coexInquiryBlackoutPeriodMs    - Blackout Period when a BT inquiry is active
-
-*******************************************************************************/
-typedef struct
-{
-    u8   coexEnableSchemeManagement;
-    u8   coexPeriodicWakeHost;
-    u16 coexTrafficBurstyLatencyMs;
-    u16 coexTrafficContinuousLatencyMs;
-    u16 coexObexBlackoutDurationMs;
-    u16 coexObexBlackoutPeriodMs;
-    u16 coexA2dpBrBlackoutDurationMs;
-    u16 coexA2dpBrBlackoutPeriodMs;
-    u16 coexA2dpEdrBlackoutDurationMs;
-    u16 coexA2dpEdrBlackoutPeriodMs;
-    u16 coexPagingBlackoutDurationMs;
-    u16 coexPagingBlackoutPeriodMs;
-    u16 coexInquiryBlackoutDurationMs;
-    u16 coexInquiryBlackoutPeriodMs;
-} CsrWifiSmeCoexConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionStats
-
-  DESCRIPTION
-    Indicates the statistics of the connection.
-    The dot11 fields are defined in the Annex D of the IEEE 802.11 standard.
-
-  MEMBERS
-    unifiTxDataRate
-                   - The bit rate currently in use for transmissions of unicast
-                     data frames; a data rate in units of 500kbit/s.
-                     On an infrastructure BSS, this is the data rate used in
-                     communicating with the associated access point; if there is
-                     none, an error is returned.
-                     On an IBSS, this is the data rate used for the last
-                     transmission of a unicast data frame to any station in the
-                     IBSS. If no such transmission has been made, an error is
-                     returned.
-    unifiRxDataRate
-                   - As above for receiving data
-    dot11RetryCount
-                   - See IEEE 802.11 Standard
-    dot11MultipleRetryCount
-                   - See IEEE 802.11 Standard
-    dot11AckFailureCount
-                   - See IEEE 802.11 Standard
-    dot11FrameDuplicateCount
-                   - See IEEE 802.11 Standard
-    dot11FcsErrorCount
-                   - See IEEE 802.11 Standard
-    dot11RtsSuccessCount
-                   - See IEEE 802.11 Standard
-    dot11RtsFailureCount
-                   - See IEEE 802.11 Standard
-    dot11FailedCount
-                   - See IEEE 802.11 Standard
-    dot11TransmittedFragmentCount
-                   - See IEEE 802.11 Standard
-    dot11TransmittedFrameCount
-                   - See IEEE 802.11 Standard
-    dot11WepExcludedCount
-                   - See IEEE 802.11 Standard
-    dot11WepIcvErrorCount
-                   - See IEEE 802.11 Standard
-    dot11WepUndecryptableCount
-                   - See IEEE 802.11 Standard
-    dot11MulticastReceivedFrameCount
-                   - See IEEE 802.11 Standard
-    dot11MulticastTransmittedFrameCount
-                   - See IEEE 802.11 Standard
-    dot11ReceivedFragmentCount
-                   - See IEEE 802.11 Standard
-    dot11Rsna4WayHandshakeFailures
-                   - See IEEE 802.11 Standard
-    dot11RsnaTkipCounterMeasuresInvoked
-                   - See IEEE 802.11 Standard
-    dot11RsnaStatsTkipLocalMicFailures
-                   - See IEEE 802.11 Standard
-    dot11RsnaStatsTkipReplays
-                   - See IEEE 802.11 Standard
-    dot11RsnaStatsTkipIcvErrors
-                   - See IEEE 802.11 Standard
-    dot11RsnaStatsCcmpReplays
-                   - See IEEE 802.11 Standard
-    dot11RsnaStatsCcmpDecryptErrors
-                   - See IEEE 802.11 Standard
-
-*******************************************************************************/
-typedef struct
-{
-    u8  unifiTxDataRate;
-    u8  unifiRxDataRate;
-    u32 dot11RetryCount;
-    u32 dot11MultipleRetryCount;
-    u32 dot11AckFailureCount;
-    u32 dot11FrameDuplicateCount;
-    u32 dot11FcsErrorCount;
-    u32 dot11RtsSuccessCount;
-    u32 dot11RtsFailureCount;
-    u32 dot11FailedCount;
-    u32 dot11TransmittedFragmentCount;
-    u32 dot11TransmittedFrameCount;
-    u32 dot11WepExcludedCount;
-    u32 dot11WepIcvErrorCount;
-    u32 dot11WepUndecryptableCount;
-    u32 dot11MulticastReceivedFrameCount;
-    u32 dot11MulticastTransmittedFrameCount;
-    u32 dot11ReceivedFragmentCount;
-    u32 dot11Rsna4WayHandshakeFailures;
-    u32 dot11RsnaTkipCounterMeasuresInvoked;
-    u32 dot11RsnaStatsTkipLocalMicFailures;
-    u32 dot11RsnaStatsTkipReplays;
-    u32 dot11RsnaStatsTkipIcvErrors;
-    u32 dot11RsnaStatsCcmpReplays;
-    u32 dot11RsnaStatsCcmpDecryptErrors;
-} CsrWifiSmeConnectionStats;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDataBlock
-
-  DESCRIPTION
-    Holds a generic data block to be passed through the interface
-
-  MEMBERS
-    length - Length of the data block
-    data   - Points to the first byte of the data block
-
-*******************************************************************************/
-typedef struct
-{
-    u16 length;
-    u8 *data;
-} CsrWifiSmeDataBlock;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEmpty
-
-  DESCRIPTION
-    Empty Structure to indicate that no parameters are available.
-
-  MEMBERS
-    empty  - Only element of the empty structure (always set to 0).
-
-*******************************************************************************/
-typedef struct
-{
-    u8 empty;
-} CsrWifiSmeEmpty;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeLinkQuality
-
-  DESCRIPTION
-    Indicates the quality of the link
-
-  MEMBERS
-    unifiRssi - Indicates the received signal strength indication of the link in
-                dBm
-    unifiSnr  - Indicates the signal to noise ratio of the link in dB
-
-*******************************************************************************/
-typedef struct
-{
-    s16 unifiRssi;
-    s16 unifiSnr;
-} CsrWifiSmeLinkQuality;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfig
-
-  DESCRIPTION
-    Allows low level configuration in the chip.
-
-  MEMBERS
-    unifiFixMaxTxDataRate       - This attribute is used in combination with
-                                  unifiFixTxDataRate. If it is FALSE, then
-                                  unifiFixTxDataRate specifies a specific data
-                                  rate to use. If it is TRUE, unifiFixTxDataRate
-                                  instead specifies a maximum data rate.
-    unifiFixTxDataRate          - Transmit rate for unicast data.
-                                  See MIB description for more details
-    dot11RtsThreshold           - See IEEE 802.11 Standard
-    dot11FragmentationThreshold - See IEEE 802.11 Standard
-    dot11CurrentTxPowerLevel    - See IEEE 802.11 Standard
-
-*******************************************************************************/
-typedef struct
-{
-    u8   unifiFixMaxTxDataRate;
-    u8  unifiFixTxDataRate;
-    u16 dot11RtsThreshold;
-    u16 dot11FragmentationThreshold;
-    u16 dot11CurrentTxPowerLevel;
-} CsrWifiSmeMibConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pProfileIdentity
-
-  DESCRIPTION
-    Details to be filled in
-
-  MEMBERS
-    listenChannel        -
-    availabilityDuration -
-    avalabilityPeriod    -
-
-*******************************************************************************/
-typedef struct
-{
-    u8  listenChannel;
-    u16 availabilityDuration;
-    u16 avalabilityPeriod;
-} CsrWifiSmeP2pProfileIdentity;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkid
-
-  DESCRIPTION
-    Defines a PMKID association with BSS
-
-  MEMBERS
-    bssid  - BSS identifier
-    pmkid  - PMKID
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress bssid;
-    u8          pmkid[16];
-} CsrWifiSmePmkid;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidCandidate
-
-  DESCRIPTION
-    Information for a PMKID candidate
-
-  MEMBERS
-    bssid          - BSS identifier
-    preAuthAllowed - Indicates whether preauthentication is allowed
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress bssid;
-    u8           preAuthAllowed;
-} CsrWifiSmePmkidCandidate;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidList
-
-  DESCRIPTION
-    NOT USED
-    Used in the Sync access API
-
-  MEMBERS
-    pmkidsCount - Number of PMKIDs in the list
-    pmkids      - Points to the first PMKID in the list
-
-*******************************************************************************/
-typedef struct
-{
-    u8         pmkidsCount;
-    CsrWifiSmePmkid *pmkids;
-} CsrWifiSmePmkidList;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRegulatoryDomainInfo
-
-  DESCRIPTION
-    Regulatory domain options.
-
-  MEMBERS
-    dot11MultiDomainCapabilityImplemented
-                   - TRUE is the multi domain capability is implemented
-    dot11MultiDomainCapabilityEnabled
-                   - TRUE is the multi domain capability is enabled
-    currentRegulatoryDomain
-                   - Current regulatory domain
-    currentCountryCode
-                   - Current country code as defined by the IEEE 802.11
-                     standards
-
-*******************************************************************************/
-typedef struct
-{
-    u8                    dot11MultiDomainCapabilityImplemented;
-    u8                    dot11MultiDomainCapabilityEnabled;
-    CsrWifiSmeRegulatoryDomain currentRegulatoryDomain;
-    u8                   currentCountryCode[2];
-} CsrWifiSmeRegulatoryDomainInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingBandData
-
-  DESCRIPTION
-    Thresholds to define one usability level category for the received signal
-
-  MEMBERS
-    rssiHighThreshold - Received Signal Strength Indication upper bound in dBm
-                        for the usability level
-    rssiLowThreshold  - Received Signal Strength Indication lower bound in dBm
-                        for the usability level
-    snrHighThreshold  - Signal to Noise Ratio upper bound in dB for the
-                        usability level
-    snrLowThreshold   - Signal to Noise Ratio lower bound in dB for the
-                        usability level
-
-*******************************************************************************/
-typedef struct
-{
-    s16 rssiHighThreshold;
-    s16 rssiLowThreshold;
-    s16 snrHighThreshold;
-    s16 snrLowThreshold;
-} CsrWifiSmeRoamingBandData;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigData
-
-  DESCRIPTION
-    Configures the scanning behaviour of the driver and firmware
-
-  MEMBERS
-    intervalSeconds         - All the channels will be scanned once in this time
-                              interval.
-                              If connected, the channel scans are spread across
-                              the interval.
-                              If disconnected, all the channels will be scanned
-                              together
-    validitySeconds         - How long the scan result are cached
-    minActiveChannelTimeTu  - Minimum time of listening on a channel being
-                              actively scanned before leaving if no probe
-                              responses or beacon frames have been received
-    maxActiveChannelTimeTu  - Maximum time of listening on a channel being
-                              actively scanned
-    minPassiveChannelTimeTu - Minimum time of listening on a channel being
-                              passive scanned before leaving if no beacon frames
-                              have been received
-    maxPassiveChannelTimeTu - Maximum time of listening on a channel being
-                              passively scanned
-
-*******************************************************************************/
-typedef struct
-{
-    u16 intervalSeconds;
-    u16 validitySeconds;
-    u16 minActiveChannelTimeTu;
-    u16 maxActiveChannelTimeTu;
-    u16 minPassiveChannelTimeTu;
-    u16 maxPassiveChannelTimeTu;
-} CsrWifiSmeScanConfigData;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTsfTime
-
-  DESCRIPTION
-    Time stamp representation
-
-  MEMBERS
-    data   - TSF Bytes
-
-*******************************************************************************/
-typedef struct
-{
-    u8 data[8];
-} CsrWifiSmeTsfTime;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeVersions
-
-  DESCRIPTION
-    Reports version information for the chip, the firmware and the driver and
-    the SME.
-
-  MEMBERS
-    chipId        - Chip ID
-    chipVersion   - Chip version ID
-    firmwareBuild - Firmware Rom build number
-    firmwarePatch - Firmware Patch build number (if applicable)
-    firmwareHip   - Firmware HIP protocol version number
-    routerBuild   - Router build number
-    routerHip     - Router HIP protocol version number
-    smeBuild      - SME build number
-    smeHip        - SME HIP protocol version number
-
-*******************************************************************************/
-typedef struct
-{
-    u32      chipId;
-    u32      chipVersion;
-    u32      firmwareBuild;
-    u32      firmwarePatch;
-    u32      firmwareHip;
-    char *routerBuild;
-    u32      routerHip;
-    char *smeBuild;
-    u32      smeHip;
-} CsrWifiSmeVersions;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWmmAcParams
-
-  DESCRIPTION
-    Structure holding WMM AC params data.
-
-  MEMBERS
-    cwMin                     - Exponent for the calculation of CWmin. Range: 0
-                                to 15
-    cwMax                     - Exponent for the calculation of CWmax. Range: 0
-                                to15
-    aifs                      - Arbitration Inter Frame Spacing in terms of
-                                number of timeslots. Range 2 to 15
-    txopLimit                 - TXOP Limit in the units of 32 microseconds
-    admissionControlMandatory - Indicates whether the admission control is
-                                mandatory or not. Current release does not
-                                support admission control , hence shall be set
-                                to FALSE.
-
-*******************************************************************************/
-typedef struct
-{
-    u8  cwMin;
-    u8  cwMax;
-    u8  aifs;
-    u16 txopLimit;
-    u8   admissionControlMandatory;
-} CsrWifiSmeWmmAcParams;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsDeviceType
-
-  DESCRIPTION
-    Structure holding AP WPS device type data.
-
-  MEMBERS
-    deviceDetails - category , sub category etc
-
-*******************************************************************************/
-typedef struct
-{
-    u8 deviceDetails[8];
-} CsrWifiSmeWpsDeviceType;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsDeviceTypeCommon
-
-  DESCRIPTION
-
-  MEMBERS
-    spportWps  -
-    deviceType -
-
-*******************************************************************************/
-typedef struct
-{
-    u8  spportWps;
-    u8 deviceType;
-} CsrWifiSmeWpsDeviceTypeCommon;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsInfo
-
-  DESCRIPTION
-
-  MEMBERS
-    version         -
-    configMethods   -
-    devicePassworId -
-
-*******************************************************************************/
-typedef struct
-{
-    u16 version;
-    u16 configMethods;
-    u16 devicePassworId;
-} CsrWifiSmeWpsInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidConfig
-
-  DESCRIPTION
-    List of cloaked SSIDs .
-
-  MEMBERS
-    cloakedSsidsCount - Number of cloaked SSID
-    cloakedSsids      - Points to the first byte of the first SSID provided
-
-*******************************************************************************/
-typedef struct
-{
-    u8     cloakedSsidsCount;
-    CsrWifiSsid *cloakedSsids;
-} CsrWifiSmeCloakedSsidConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexInfo
-
-  DESCRIPTION
-    Information and state related to coexistence.
-
-  MEMBERS
-    hasTrafficData            - TRUE if any Wi-Fi traffic is detected
-    currentTrafficType        - Current type of traffic
-    currentPeriodMs           - Period of the traffic as detected by the traffic
-                                analysis.
-                                If the traffic is not periodic, it is set to 0.
-    currentPowerSave          - Current power save level
-    currentCoexPeriodMs       - Period of awakening for the firmware used when
-                                periodic traffic is detected.
-                                If the traffic is not periodic, it is set to 0.
-    currentCoexLatencyMs      - Period of awakening for the firmware used when
-                                non-periodic traffic is detected
-    hasBtDevice               - TRUE if there is a Bluetooth device connected
-    currentBlackoutDurationUs - Current blackout duration for protecting
-                                Bluetooth
-    currentBlackoutPeriodUs   - Current blackout period
-    currentCoexScheme         - Defines the scheme for the coexistence
-                                signalling
-
-*******************************************************************************/
-typedef struct
-{
-    u8                  hasTrafficData;
-    CsrWifiSmeTrafficType    currentTrafficType;
-    u16                currentPeriodMs;
-    CsrWifiSmePowerSaveLevel currentPowerSave;
-    u16                currentCoexPeriodMs;
-    u16                currentCoexLatencyMs;
-    u8                  hasBtDevice;
-    u32                currentBlackoutDurationUs;
-    u32                currentBlackoutPeriodUs;
-    CsrWifiSmeCoexScheme     currentCoexScheme;
-} CsrWifiSmeCoexInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionConfig
-
-  DESCRIPTION
-    Specifies the parameters that the SME should use in selecting a network.
-
-  MEMBERS
-    ssid
-                   - Service Set identifier
-    bssid
-                   - BSS identifier
-    bssType
-                   - Indicates the type of BSS
-    ifIndex
-                   - Indicates the radio interface
-    privacyMode
-                   - Specifies whether the privacy mode is enabled or disabled.
-    authModeMask
-                   - Sets the authentication options that the SME can use while
-                     associating to the AP
-                     Set mask with values from CsrWifiSmeAuthMode
-    encryptionModeMask
-                   - Sets the encryption options that the SME can use while
-                     associating to the AP
-                     Set mask with values from CsrWifiSmeEncryption
-    mlmeAssociateReqInformationElementsLength
-                   - Length in bytes of information elements to be sent in the
-                     Association Request.
-    mlmeAssociateReqInformationElements
-                   - Points to the first byte of the information elements, if
-                     any.
-    wmmQosInfo
-                   - This parameter allows the driver's WMM behaviour to be
-                     configured.
-                     To enable support for WMM, use
-                     CSR_WIFI_SME_SME_CONFIG_SET_REQ with the
-                     CSR_WIFI_SME_WMM_MODE_AC_ENABLED bit set in wmmModeMask
-                     field in smeConfig parameter.
-                     Set mask with values from CsrWifiSmeWmmQosInfo
-    adhocJoinOnly
-                   - This parameter is relevant only if bssType is NOT set to
-                     CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
-                     if TRUE the SME will only try to join an ad-hoc network if
-                     there is one already established;
-                     if FALSE the SME will try to join an ad-hoc network if
-                     there is one already established or it will try to
-                     establish a new one
-    adhocChannel
-                   - This parameter is relevant only if bssType is NOT set to
-                     CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
-                     it indicates the channel to use joining an ad hoc network.
-                     Setting this to 0 causes the SME to select a channel from
-                     those permitted in the regulatory domain.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSsid                ssid;
-    CsrWifiMacAddress          bssid;
-    CsrWifiSmeBssType          bssType;
-    CsrWifiSmeRadioIF          ifIndex;
-    CsrWifiSme80211PrivacyMode privacyMode;
-    CsrWifiSmeAuthModeMask     authModeMask;
-    CsrWifiSmeEncryptionMask   encryptionModeMask;
-    u16                  mlmeAssociateReqInformationElementsLength;
-    u8                  *mlmeAssociateReqInformationElements;
-    CsrWifiSmeWmmQosInfoMask   wmmQosInfo;
-    u8                    adhocJoinOnly;
-    u8                   adhocChannel;
-} CsrWifiSmeConnectionConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionInfo
-
-  DESCRIPTION
-    Parameters that the SME should use in selecting a network
-
-  MEMBERS
-    ssid                        - Service set identifier
-    bssid                       - BSS identifier
-    networkType80211            - Physical layer used for the connection
-    channelNumber               - Channel number
-    channelFrequency            - Channel frequency
-    authMode                    - Authentication mode used for the connection
-    pairwiseCipher              - Encryption type for peer to peer communication
-    groupCipher                 - Encryption type for broadcast and multicast
-                                  communication
-    ifIndex                     - Indicates the radio interface
-    atimWindowTu                - ATIM window specified for IBSS
-    beaconPeriodTu              - Interval between beacon packets
-    reassociation               - Indicates whether a reassociation occurred
-    beaconFrameLength           - Indicates the number of bytes of the beacon
-                                  frame
-    beaconFrame                 - Points at the first byte of the beacon frame
-    associationReqFrameLength   - Indicates the number of bytes of the
-                                  association request frame
-    associationReqFrame         - Points at the first byte of the association
-                                  request frame
-    associationRspFrameLength   - Indicates the number of bytes of the
-                                  association response frame
-    associationRspFrame         - Points at the first byte of the association
-                                  response frame
-    assocScanInfoElementsLength - Indicates the number of bytes in the buffer
-                                  pointed by assocScanInfoElements
-    assocScanInfoElements       - Pointer to the buffer containing the
-                                  information elements of the probe response
-                                  received after the probe requests sent before
-                                  attempting to authenticate to the network
-    assocReqCapabilities        - Reports the content of the Capability
-                                  information element as specified in the
-                                  association request.
-    assocReqListenIntervalTu    - Listen Interval specified in the association
-                                  request
-    assocReqApAddress           - AP address to which the association requests
-                                  has been sent
-    assocReqInfoElementsLength  - Indicates the number of bytes of the
-                                  association request information elements
-    assocReqInfoElements        - Points at the first byte of the association
-                                  request information elements
-    assocRspResult              - Result reported in the association response
-    assocRspCapabilityInfo      - Reports the content of the Capability
-                                  information element as received in the
-                                  association response.
-    assocRspAssociationId       - Reports the association ID received in the
-                                  association response.
-    assocRspInfoElementsLength  - Indicates the number of bytes of the
-                                  association response information elements
-    assocRspInfoElements        - Points at the first byte of the association
-                                  response information elements
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSsid                ssid;
-    CsrWifiMacAddress          bssid;
-    CsrWifiSme80211NetworkType networkType80211;
-    u8                   channelNumber;
-    u16                  channelFrequency;
-    CsrWifiSmeAuthMode         authMode;
-    CsrWifiSmeEncryption       pairwiseCipher;
-    CsrWifiSmeEncryption       groupCipher;
-    CsrWifiSmeRadioIF          ifIndex;
-    u16                  atimWindowTu;
-    u16                  beaconPeriodTu;
-    u8                    reassociation;
-    u16                  beaconFrameLength;
-    u8                  *beaconFrame;
-    u16                  associationReqFrameLength;
-    u8                  *associationReqFrame;
-    u16                  associationRspFrameLength;
-    u8                  *associationRspFrame;
-    u16                  assocScanInfoElementsLength;
-    u8                  *assocScanInfoElements;
-    u16                  assocReqCapabilities;
-    u16                  assocReqListenIntervalTu;
-    CsrWifiMacAddress          assocReqApAddress;
-    u16                  assocReqInfoElementsLength;
-    u8                  *assocReqInfoElements;
-    CsrWifiSmeIEEE80211Result  assocRspResult;
-    u16                  assocRspCapabilityInfo;
-    u16                  assocRspAssociationId;
-    u16                  assocRspInfoElementsLength;
-    u8                  *assocRspInfoElements;
-} CsrWifiSmeConnectionInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeviceConfig
-
-  DESCRIPTION
-    General configuration options in the SME
-
-  MEMBERS
-    trustLevel              - Level of trust of the information coming from the
-                              network
-    countryCode             - Country code as specified by IEEE 802.11 standard
-    firmwareDriverInterface - Specifies the type of communication between Host
-                              and Firmware
-    enableStrictDraftN      - If TRUE TKIP is disallowed when connecting to
-                              802.11n enabled access points
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSme80211dTrustLevel        trustLevel;
-    u8                          countryCode[2];
-    CsrWifiSmeFirmwareDriverInterface firmwareDriverInterface;
-    u8                           enableStrictDraftN;
-} CsrWifiSmeDeviceConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeviceInfo
-
-  DESCRIPTION
-    P2P Information for a P2P Device
-
-  MEMBERS
-    deviceAddress            - Device Address of the P2P device
-    configMethods            - Supported WPS configuration methods.
-    p2PDeviceCap             - P2P device capabilities
-    primDeviceType           - Primary WPS device type
-    secondaryDeviceTypeCount - Number of secondary device types
-    secDeviceType            - list of secondary WPS device types
-    deviceName               - Device name without up to 32 characters'\0'.
-    deviceNameLength         - Number of characters of the device name
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress           deviceAddress;
-    CsrWifiSmeWpsConfigTypeMask configMethods;
-    CsrWifiSmeP2pCapabilityMask p2PDeviceCap;
-    CsrWifiSmeWpsDeviceType     primDeviceType;
-    u8                    secondaryDeviceTypeCount;
-    CsrWifiSmeWpsDeviceType    *secDeviceType;
-    u8                    deviceName[32];
-    u8                    deviceNameLength;
-} CsrWifiSmeDeviceInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeviceInfoCommon
-
-  DESCRIPTION
-    Structure holding device information.
-
-  MEMBERS
-    p2pDeviceAddress          -
-    primaryDeviceType         -
-    secondaryDeviceTypesCount -
-    secondaryDeviceTypes      -
-    deviceNameLength          -
-    deviceName                -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress             p2pDeviceAddress;
-    CsrWifiSmeWpsDeviceTypeCommon primaryDeviceType;
-    u8                      secondaryDeviceTypesCount;
-    u8                      secondaryDeviceTypes[10];
-    u8                      deviceNameLength;
-    u8                      deviceName[32];
-} CsrWifiSmeDeviceInfoCommon;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfig
-
-  DESCRIPTION
-    Defines the host power state (for example, on mains power, on battery
-    power etc) and the periodicity of the traffic data.
-
-  MEMBERS
-    powerMode               - The wireless manager application should use the
-                              powerMode parameter to inform the SME of the host
-                              power state.
-    applicationDataPeriodMs - The applicationDataPeriodMs parameter allows a
-                              wireless manager application to inform the SME
-                              that an application is running that generates
-                              periodic network traffic and the period of the
-                              traffic.
-                              An example of such an application is a VoIP client.
-                              The wireless manager application should set
-                              applicationDataPeriodMs to the period in
-                              milliseconds between data packets or zero if no
-                              periodic application is running.
-                              Voip etc 0 = No Periodic Data
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeHostPowerMode powerMode;
-    u16               applicationDataPeriodMs;
-} CsrWifiSmeHostConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeKey
-
-  DESCRIPTION
-    Information for a key to be used for encryption
-
-  MEMBERS
-    keyType       - Specifies whether the key is a pairwise or group key; it
-                    should be set to CSR_WIFI_SME_GROUP_KEY or
-                    CSR_WIFI_SME_PAIRWISE_KEY, as required.
-    keyIndex      - Specifies which WEP key (0-3) to set; it should be set to 0
-                    for a WPA/WPA2 pairwise key and non-zero for a WPA/WPA2
-                    group key.
-    wepTxKey      - If wepTxKey is TRUE, and the key is a WEP key, the key will
-                    be selected for encrypting transmitted packets.
-                    To select a previously defined key as the transmit
-                    encryption key, set keyIndex to the required key, wepTxKey
-                    to TRUE and the keyLength to 0.
-    keyRsc        - Key Receive Sequence Counter
-    authenticator - If TRUE the WMA will act as authenticator.
-                    CURRENTLY NOT SUPPORTED
-    address       - BSS identifier of the AP
-    keyLength     - Length of the key in bytes
-    key           - Points to the first byte of the key
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeKeyType keyType;
-    u8          keyIndex;
-    u8           wepTxKey;
-    u16         keyRsc[8];
-    u8           authenticator;
-    CsrWifiMacAddress address;
-    u8          keyLength;
-    u8          key[32];
-} CsrWifiSmeKey;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pClientInfoType
-
-  DESCRIPTION
-    P2P Information for a P2P Client
-
-  MEMBERS
-    p2PClientInterfaceAddress - MAC address of the P2P Client
-    clientDeviceInfo          - Device Information
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiMacAddress    p2PClientInterfaceAddress;
-    CsrWifiSmeDeviceInfo clientDeviceInfo;
-} CsrWifiSmeP2pClientInfoType;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeP2pGroupInfo
-
-  DESCRIPTION
-    P2P Information for a P2P Group
-
-  MEMBERS
-    groupCapability    - P2P group capabilities
-    p2pDeviceAddress   - Device Address of the GO
-    p2pClientInfoCount - Number of P2P Clients that belong to the group.
-    p2PClientInfo      - Pointer to the list containing client information for
-                         each client in the group
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeP2pGroupCapabilityMask groupCapability;
-    CsrWifiMacAddress                p2pDeviceAddress;
-    u8                         p2pClientInfoCount;
-    CsrWifiSmeP2pClientInfoType     *p2PClientInfo;
-} CsrWifiSmeP2pGroupInfo;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfig
-
-  DESCRIPTION
-    Configures the power-save behaviour of the driver and firmware.
-
-  MEMBERS
-    powerSaveLevel         - Power Save Level option
-    listenIntervalTu       - Interval for waking to receive beacon frames
-    rxDtims                - If TRUE, wake for DTIM every beacon period, to
-                             allow the reception broadcast packets
-    d3AutoScanMode         - Defines whether the autonomous scanning will be
-                             turned off or will stay on during a D3 suspended
-                             period
-    clientTrafficWindow    - Deprecated
-    opportunisticPowerSave - Deprecated
-    noticeOfAbsence        - Deprecated
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmePowerSaveLevel powerSaveLevel;
-    u16                listenIntervalTu;
-    u8                  rxDtims;
-    CsrWifiSmeD3AutoScanMode d3AutoScanMode;
-    u8                 clientTrafficWindow;
-    u8                  opportunisticPowerSave;
-    u8                  noticeOfAbsence;
-} CsrWifiSmePowerConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfig
-
-  DESCRIPTION
-    Configures the roaming behaviour of the driver and firmware
-
-  MEMBERS
-    roamingBands             - Defines the thresholds to determine the usability
-                               level of the current connection.
-                               roamingBands is indexed by the first 3 entries of
-                               the CsrWifiSmeBasicUsability enum
-    disableSmoothRoaming     - Disable the RSSI/SNR triggers from the Firmware
-                               that the SME uses to detect the quality of the
-                               connection.
-                               This implicitly disables disableRoamScans
-    disableRoamScans         - Disables the scanning for the roaming operation
-    reconnectLimit           - Maximum number of times SME may reconnect in the
-                               given interval
-    reconnectLimitIntervalMs - Interval for maximum number of times SME may
-                               reconnect to the same Access Point
-    roamScanCfg              - Scanning behaviour for the specifically aimed at
-                               improving roaming performance.
-                               roamScanCfg is indexed by the first 3 entries of
-                               the CsrWifiSmeBasicUsability enum
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeRoamingBandData roamingBands[3];
-    u8                   disableSmoothRoaming;
-    u8                   disableRoamScans;
-    u8                  reconnectLimit;
-    u16                 reconnectLimitIntervalMs;
-    CsrWifiSmeScanConfigData  roamScanCfg[3];
-} CsrWifiSmeRoamingConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfig
-
-  DESCRIPTION
-    Parameters for the autonomous scanning behaviour of the system
-
-  MEMBERS
-    scanCfg                 - Scan configuration data.
-                              Indexed by the CsrWifiSmeBasicUsability enum
-    disableAutonomousScans  - Enables or disables the autonomous scan
-    maxResults              - Maximum number of results to be cached in the SME
-    highRssiThreshold       - High received signal strength indication threshold
-                              in dBm for an AP above which the system will
-                              report scan indications
-    lowRssiThreshold        - Low received signal strength indication threshold
-                              in dBm for an AP below which the system will
-                              report scan indications
-    deltaRssiThreshold      - Minimum difference for received signal strength
-                              indication in dBm for an AP which trigger a scan
-                              indication to be sent.
-    highSnrThreshold        - High Signal to Noise Ratio threshold in dB for an
-                              AP above which the system will report scan
-                              indications
-    lowSnrThreshold         - Low Signal to Noise Ratio threshold in dB for an
-                              AP below which the system will report scan
-                              indications
-    deltaSnrThreshold       - Minimum difference for Signal to Noise Ratio in dB
-                              for an AP which trigger a scan indication to be
-                              sent.
-    passiveChannelListCount - Number of channels to be scanned passively.
-    passiveChannelList      - Points to the first channel to be scanned
-                              passively , if any.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeScanConfigData scanCfg[4];
-    u8                  disableAutonomousScans;
-    u16                maxResults;
-    s8                  highRssiThreshold;
-    s8                  lowRssiThreshold;
-    s8                  deltaRssiThreshold;
-    s8                  highSnrThreshold;
-    s8                  lowSnrThreshold;
-    s8                  deltaSnrThreshold;
-    u16                passiveChannelListCount;
-    u8                *passiveChannelList;
-} CsrWifiSmeScanConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResult
-
-  DESCRIPTION
-    This structure defines the scan result for each BSS found
-
-  MEMBERS
-    ssid                         - Service set identifier
-    bssid                        - BSS identifier
-    rssi                         - Received signal strength indication in dBm
-    snr                          - Signal to noise ratio in dB
-    ifIndex                      - Indicates the radio interface
-    beaconPeriodTu               - Interval between beacon frames
-    timeStamp                    - Timestamp in the BSS
-    localTime                    - Timestamp in the Access Point
-    channelFrequency             - Channel frequency
-    capabilityInformation        - Capabilities of the BSS.
-    channelNumber                - Channel number
-    usability                    - Indicates the usability level.
-    bssType                      - Type of BSS.
-    informationElementsLength    - Number of bytes of the information elements
-                                   received as part of the beacon or probe
-                                   response.
-    informationElements          - Points to the first byte of the IEs received
-                                   as part of the beacon or probe response.
-                                   The format of the IEs is as specified in the
-                                   IEEE 802.11 specification.
-    p2pDeviceRole                - Role of the P2P device.
-                                   Relevant only if bssType is
-                                   CSR_WIFI_SME_BSS_TYPE_P2P
-    deviceInfo                   - Union containing P2P device info which
-                                   depends on p2pDeviceRole parameter.
-    deviceInforeservedCli        -
-    deviceInfogroupInfo          -
-    deviceInforeservedNone       -
-    deviceInfostandalonedevInfo  -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSsid              ssid;
-    CsrWifiMacAddress        bssid;
-    s16                 rssi;
-    s16                 snr;
-    CsrWifiSmeRadioIF        ifIndex;
-    u16                beaconPeriodTu;
-    CsrWifiSmeTsfTime        timeStamp;
-    CsrWifiSmeTsfTime        localTime;
-    u16                channelFrequency;
-    u16                capabilityInformation;
-    u8                 channelNumber;
-    CsrWifiSmeBasicUsability usability;
-    CsrWifiSmeBssType        bssType;
-    u16                informationElementsLength;
-    u8                *informationElements;
-    CsrWifiSmeP2pRole        p2pDeviceRole;
-    union {
-        CsrWifiSmeEmpty        reservedCli;
-        CsrWifiSmeP2pGroupInfo groupInfo;
-        CsrWifiSmeEmpty        reservedNone;
-        CsrWifiSmeDeviceInfo   standalonedevInfo;
-    } deviceInfo;
-} CsrWifiSmeScanResult;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeStaConfig
-
-  DESCRIPTION
-    Station configuration options in the SME
-
-  MEMBERS
-    connectionQualityRssiChangeTrigger - Sets the difference of RSSI
-                                         measurements which triggers reports
-                                         from the Firmware
-    connectionQualitySnrChangeTrigger  - Sets the difference of SNR measurements
-                                         which triggers reports from the
-                                         Firmware
-    wmmModeMask                        - Mask containing one or more values from
-                                         CsrWifiSmeWmmMode
-    ifIndex                            - Indicates the band of frequencies used
-    allowUnicastUseGroupCipher         - If TRUE, it allows to use groupwise
-                                         keys if no pairwise key is specified
-    enableOpportunisticKeyCaching      - If TRUE, enables the Opportunistic Key
-                                         Caching feature
-
-*******************************************************************************/
-typedef struct
-{
-    u8              connectionQualityRssiChangeTrigger;
-    u8              connectionQualitySnrChangeTrigger;
-    CsrWifiSmeWmmModeMask wmmModeMask;
-    CsrWifiSmeRadioIF     ifIndex;
-    u8               allowUnicastUseGroupCipher;
-    u8               enableOpportunisticKeyCaching;
-} CsrWifiSmeStaConfig;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWep128Keys
-
-  DESCRIPTION
-    Structure holding WEP Authentication Type and WEP keys that can be used
-    when using WEP128.
-
-  MEMBERS
-    wepAuthType    - Mask to select the WEP authentication type (Open or Shared)
-    selectedWepKey - Index to one of the four keys below indicating the
-                     currently used WEP key. Mapping From SME/User -> firmware.
-                     Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key
-                     4-> Index 3.
-    key1           - Value for key number 1.
-    key2           - Value for key number 2.
-    key3           - Value for key number 3.
-    key4           - Value for key number 4.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeWepAuthMode wepAuthType;
-    u8              selectedWepKey;
-    u8              key1[13];
-    u8              key2[13];
-    u8              key3[13];
-    u8              key4[13];
-} CsrWifiSmeWep128Keys;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWep64Keys
-
-  DESCRIPTION
-    Structure holding WEP Authentication Type and WEP keys that can be used
-    when using WEP64.
-
-  MEMBERS
-    wepAuthType    - Mask to select the WEP authentication type (Open or Shared)
-    selectedWepKey - Index to one of the four keys below indicating the
-                     currently used WEP key. Mapping From SME/User -> firmware.
-                     Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key
-                     4-> Index 3.
-    key1           - Value for key number 1.
-    key2           - Value for key number 2.
-    key3           - Value for key number 3.
-    key4           - Value for key number 4.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeWepAuthMode wepAuthType;
-    u8              selectedWepKey;
-    u8              key1[5];
-    u8              key2[5];
-    u8              key3[5];
-    u8              key4[5];
-} CsrWifiSmeWep64Keys;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWepAuth
-
-  DESCRIPTION
-    WEP authentication parameter structure
-
-  MEMBERS
-    wepKeyType               - WEP key try (128 bit or 64 bit)
-    wepCredentials           - Union containing credentials which depends on
-                               wepKeyType parameter.
-    wepCredentialswep128Key  -
-    wepCredentialswep64Key   -
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiSmeWepCredentialType wepKeyType;
-    union {
-        CsrWifiSmeWep128Keys wep128Key;
-        CsrWifiSmeWep64Keys  wep64Key;
-    } wepCredentials;
-} CsrWifiSmeWepAuth;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfig
-
-  DESCRIPTION
-    Structure holding AP WPS Config data.
-
-  MEMBERS
-    wpsVersion               - wpsVersion should be 0x10 for WPS1.0h or 0x20 for
-                               WSC2.0
-    uuid                     - uuid.
-    deviceName               - Device name upto 32 characters without '\0'.
-    deviceNameLength         - deviceNameLen.
-    manufacturer             - manufacturer: CSR
-    manufacturerLength       - manufacturerLen.
-    modelName                - modelName Unifi
-    modelNameLength          - modelNameLen.
-    modelNumber              - modelNumber
-    modelNumberLength        - modelNumberLen.
-    serialNumber             - serialNumber
-    primDeviceType           - Primary WPS device type
-    secondaryDeviceTypeCount - Number of secondary device types
-    secondaryDeviceType      - list of secondary WPS device types
-    configMethods            - Supported WPS config methods
-    rfBands                  - RfBands.
-    osVersion                - Os version on which the device is running
-
-*******************************************************************************/
-typedef struct
-{
-    u8                    wpsVersion;
-    u8                    uuid[16];
-    u8                    deviceName[32];
-    u8                    deviceNameLength;
-    u8                    manufacturer[64];
-    u8                    manufacturerLength;
-    u8                    modelName[32];
-    u8                    modelNameLength;
-    u8                    modelNumber[32];
-    u8                    modelNumberLength;
-    u8                    serialNumber[32];
-    CsrWifiSmeWpsDeviceType     primDeviceType;
-    u8                    secondaryDeviceTypeCount;
-    CsrWifiSmeWpsDeviceType    *secondaryDeviceType;
-    CsrWifiSmeWpsConfigTypeMask configMethods;
-    u8                    rfBands;
-    u8                    osVersion[4];
-} CsrWifiSmeWpsConfig;
-
-
-/* Downstream */
-#define CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST            (0x0000)
-
-#define CSR_WIFI_SME_ACTIVATE_REQ                         ((CsrWifiSmePrim) (0x0000 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ                 ((CsrWifiSmePrim) (0x0001 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ                 ((CsrWifiSmePrim) (0x0002 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_BLACKLIST_REQ                        ((CsrWifiSmePrim) (0x0003 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ             ((CsrWifiSmePrim) (0x0004 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ             ((CsrWifiSmePrim) (0x0005 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CCX_CONFIG_GET_REQ                   ((CsrWifiSmePrim) (0x0006 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CCX_CONFIG_SET_REQ                   ((CsrWifiSmePrim) (0x0007 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_COEX_CONFIG_GET_REQ                  ((CsrWifiSmePrim) (0x0008 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_COEX_CONFIG_SET_REQ                  ((CsrWifiSmePrim) (0x0009 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_COEX_INFO_GET_REQ                    ((CsrWifiSmePrim) (0x000A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECT_REQ                          ((CsrWifiSmePrim) (0x000B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ            ((CsrWifiSmePrim) (0x000C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_INFO_GET_REQ              ((CsrWifiSmePrim) (0x000D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_STATS_GET_REQ             ((CsrWifiSmePrim) (0x000E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_DEACTIVATE_REQ                       ((CsrWifiSmePrim) (0x000F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_DISCONNECT_REQ                       ((CsrWifiSmePrim) (0x0010 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_EVENT_MASK_SET_REQ                   ((CsrWifiSmePrim) (0x0011 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_HOST_CONFIG_GET_REQ                  ((CsrWifiSmePrim) (0x0012 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_HOST_CONFIG_SET_REQ                  ((CsrWifiSmePrim) (0x0013 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_KEY_REQ                              ((CsrWifiSmePrim) (0x0014 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_LINK_QUALITY_GET_REQ                 ((CsrWifiSmePrim) (0x0015 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_CONFIG_GET_REQ                   ((CsrWifiSmePrim) (0x0016 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_CONFIG_SET_REQ                   ((CsrWifiSmePrim) (0x0017 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_GET_NEXT_REQ                     ((CsrWifiSmePrim) (0x0018 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_GET_REQ                          ((CsrWifiSmePrim) (0x0019 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_SET_REQ                          ((CsrWifiSmePrim) (0x001A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_MULTICAST_ADDRESS_REQ                ((CsrWifiSmePrim) (0x001B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_PACKET_FILTER_SET_REQ                ((CsrWifiSmePrim) (0x001C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ        ((CsrWifiSmePrim) (0x001D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_PMKID_REQ                            ((CsrWifiSmePrim) (0x001E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_POWER_CONFIG_GET_REQ                 ((CsrWifiSmePrim) (0x001F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_POWER_CONFIG_SET_REQ                 ((CsrWifiSmePrim) (0x0020 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ       ((CsrWifiSmePrim) (0x0021 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ               ((CsrWifiSmePrim) (0x0022 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ               ((CsrWifiSmePrim) (0x0023 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_CONFIG_GET_REQ                  ((CsrWifiSmePrim) (0x0024 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_CONFIG_SET_REQ                  ((CsrWifiSmePrim) (0x0025 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_FULL_REQ                        ((CsrWifiSmePrim) (0x0026 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ               ((CsrWifiSmePrim) (0x0027 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_RESULTS_GET_REQ                 ((CsrWifiSmePrim) (0x0028 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ               ((CsrWifiSmePrim) (0x0029 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ               ((CsrWifiSmePrim) (0x002A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ          ((CsrWifiSmePrim) (0x002B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_TSPEC_REQ                            ((CsrWifiSmePrim) (0x002C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_VERSIONS_GET_REQ                     ((CsrWifiSmePrim) (0x002D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ                  ((CsrWifiSmePrim) (0x002E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_OFF_REQ                         ((CsrWifiSmePrim) (0x002F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_ON_REQ                          ((CsrWifiSmePrim) (0x0030 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ                ((CsrWifiSmePrim) (0x0031 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ                ((CsrWifiSmePrim) (0x0032 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ            ((CsrWifiSmePrim) (0x0033 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ            ((CsrWifiSmePrim) (0x0034 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ         ((CsrWifiSmePrim) (0x0035 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_WPS_CONFIGURATION_REQ                ((CsrWifiSmePrim) (0x0036 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-#define CSR_WIFI_SME_SET_REQ                              ((CsrWifiSmePrim) (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
-
-
-#define CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST           (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)
-
-/* Upstream */
-#define CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST              (0x0000 + CSR_PRIM_UPSTREAM)
-
-#define CSR_WIFI_SME_ACTIVATE_CFM                         ((CsrWifiSmePrim)(0x0000 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM                 ((CsrWifiSmePrim)(0x0001 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM                 ((CsrWifiSmePrim)(0x0002 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND             ((CsrWifiSmePrim)(0x0003 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ASSOCIATION_START_IND                ((CsrWifiSmePrim)(0x0004 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_BLACKLIST_CFM                        ((CsrWifiSmePrim)(0x0005 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM             ((CsrWifiSmePrim)(0x0006 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM             ((CsrWifiSmePrim)(0x0007 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CCX_CONFIG_GET_CFM                   ((CsrWifiSmePrim)(0x0008 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CCX_CONFIG_SET_CFM                   ((CsrWifiSmePrim)(0x0009 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_COEX_CONFIG_GET_CFM                  ((CsrWifiSmePrim)(0x000A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_COEX_CONFIG_SET_CFM                  ((CsrWifiSmePrim)(0x000B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_COEX_INFO_GET_CFM                    ((CsrWifiSmePrim)(0x000C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECT_CFM                          ((CsrWifiSmePrim)(0x000D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM            ((CsrWifiSmePrim)(0x000E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_INFO_GET_CFM              ((CsrWifiSmePrim)(0x000F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_QUALITY_IND               ((CsrWifiSmePrim)(0x0010 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CONNECTION_STATS_GET_CFM             ((CsrWifiSmePrim)(0x0011 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_DEACTIVATE_CFM                       ((CsrWifiSmePrim)(0x0012 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_DISCONNECT_CFM                       ((CsrWifiSmePrim)(0x0013 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_EVENT_MASK_SET_CFM                   ((CsrWifiSmePrim)(0x0014 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_HOST_CONFIG_GET_CFM                  ((CsrWifiSmePrim)(0x0015 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_HOST_CONFIG_SET_CFM                  ((CsrWifiSmePrim)(0x0016 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_IBSS_STATION_IND                     ((CsrWifiSmePrim)(0x0017 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_KEY_CFM                              ((CsrWifiSmePrim)(0x0018 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_LINK_QUALITY_GET_CFM                 ((CsrWifiSmePrim)(0x0019 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MEDIA_STATUS_IND                     ((CsrWifiSmePrim)(0x001A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_CONFIG_GET_CFM                   ((CsrWifiSmePrim)(0x001B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_CONFIG_SET_CFM                   ((CsrWifiSmePrim)(0x001C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_GET_CFM                          ((CsrWifiSmePrim)(0x001D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_GET_NEXT_CFM                     ((CsrWifiSmePrim)(0x001E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIB_SET_CFM                          ((CsrWifiSmePrim)(0x001F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MIC_FAILURE_IND                      ((CsrWifiSmePrim)(0x0020 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_MULTICAST_ADDRESS_CFM                ((CsrWifiSmePrim)(0x0021 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_PACKET_FILTER_SET_CFM                ((CsrWifiSmePrim)(0x0022 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM        ((CsrWifiSmePrim)(0x0023 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND             ((CsrWifiSmePrim)(0x0024 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_PMKID_CFM                            ((CsrWifiSmePrim)(0x0025 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_POWER_CONFIG_GET_CFM                 ((CsrWifiSmePrim)(0x0026 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_POWER_CONFIG_SET_CFM                 ((CsrWifiSmePrim)(0x0027 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM       ((CsrWifiSmePrim)(0x0028 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ROAM_COMPLETE_IND                    ((CsrWifiSmePrim)(0x0029 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ROAM_START_IND                       ((CsrWifiSmePrim)(0x002A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM               ((CsrWifiSmePrim)(0x002B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM               ((CsrWifiSmePrim)(0x002C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_CONFIG_GET_CFM                  ((CsrWifiSmePrim)(0x002D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_CONFIG_SET_CFM                  ((CsrWifiSmePrim)(0x002E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_FULL_CFM                        ((CsrWifiSmePrim)(0x002F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_RESULT_IND                      ((CsrWifiSmePrim)(0x0030 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM               ((CsrWifiSmePrim)(0x0031 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SCAN_RESULTS_GET_CFM                 ((CsrWifiSmePrim)(0x0032 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM               ((CsrWifiSmePrim)(0x0033 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM               ((CsrWifiSmePrim)(0x0034 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM          ((CsrWifiSmePrim)(0x0035 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_TSPEC_IND                            ((CsrWifiSmePrim)(0x0036 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_TSPEC_CFM                            ((CsrWifiSmePrim)(0x0037 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_VERSIONS_GET_CFM                     ((CsrWifiSmePrim)(0x0038 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM                  ((CsrWifiSmePrim)(0x0039 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_OFF_IND                         ((CsrWifiSmePrim)(0x003A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_OFF_CFM                         ((CsrWifiSmePrim)(0x003B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_ON_CFM                          ((CsrWifiSmePrim)(0x003C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM                ((CsrWifiSmePrim)(0x003D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM                ((CsrWifiSmePrim)(0x003E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_WIFI_ON_IND                          ((CsrWifiSmePrim)(0x003F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM            ((CsrWifiSmePrim)(0x0040 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM            ((CsrWifiSmePrim)(0x0041 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM         ((CsrWifiSmePrim)(0x0042 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_ERROR_IND                            ((CsrWifiSmePrim)(0x0043 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_INFO_IND                             ((CsrWifiSmePrim)(0x0044 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_CORE_DUMP_IND                        ((CsrWifiSmePrim)(0x0045 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_AMP_STATUS_CHANGE_IND                ((CsrWifiSmePrim)(0x0046 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-#define CSR_WIFI_SME_WPS_CONFIGURATION_CFM                ((CsrWifiSmePrim)(0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
-
-#define CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST             (0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)
-
-#define CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT             (CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)
-#define CSR_WIFI_SME_PRIM_UPSTREAM_COUNT               (CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST   + 1 - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeActivateReq
-
-  DESCRIPTION
-    The WMA sends this primitive to activate the SME.
-    The WMA must activate the SME before it can send any other primitive.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeActivateReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the adHocConfig parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeAdhocConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the adHocConfig parameter.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    adHocConfig - Sets the values to use when starting an ad hoc network.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrWifiSmeAdHocConfig adHocConfig;
-} CsrWifiSmeAdhocConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeBlacklistReq
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to notify the
-    driver of any networks that should not be connected to. The interface
-    allows the wireless manager application to query, add, remove, and flush
-    the BSSIDs that the driver may not connect or roam to.
-    When this primitive adds to the black list the BSSID to which the SME is
-    currently connected, the SME will try to roam, if applicable, to another
-    BSSID in the same ESS; if the roaming procedure fails, the SME will
-    disconnect.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    action          - The value of the CsrWifiSmeListAction parameter instructs
-                      the driver to modify or provide the list of blacklisted
-                      networks.
-    setAddressCount - Number of BSSIDs sent with this primitive
-    setAddresses    - Pointer to the list of BBSIDs sent with the primitive, set
-                      to NULL if none is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrWifiSmeListAction action;
-    u8             setAddressCount;
-    CsrWifiMacAddress   *setAddresses;
-} CsrWifiSmeBlacklistReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataGetReq
-
-  DESCRIPTION
-    This primitive retrieves the Wi-Fi radio calibration data.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeCalibrationDataGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataSetReq
-
-  DESCRIPTION
-    This primitive sets the Wi-Fi radio calibration data.
-    The usage of the primitive with proper calibration data will avoid
-    time-consuming configuration after power-up.
-
-  MEMBERS
-    common                - Common header for use with the CsrWifiFsm Module
-    calibrationDataLength - Number of bytes in the buffer pointed by
-                            calibrationData
-    calibrationData       - Pointer to a buffer of length calibrationDataLength
-                            containing the calibration data
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       calibrationDataLength;
-    u8       *calibrationData;
-} CsrWifiSmeCalibrationDataSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the CcxConfig parameter.
-    CURRENTLY NOT SUPPORTED.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeCcxConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the CcxConfig parameter.
-    CURRENTLY NOT SUPPORTED.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    ccxConfig    - Currently not supported
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    u16           interfaceTag;
-    CsrWifiSmeCcxConfig ccxConfig;
-} CsrWifiSmeCcxConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the CoexConfig parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeCoexConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the CoexConfig parameter.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    coexConfig - Configures the coexistence behaviour
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrWifiSmeCoexConfig coexConfig;
-} CsrWifiSmeCoexConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexInfoGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the CoexInfo parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeCoexInfoGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to start the
-    process of joining an 802.11 wireless network or to start an ad hoc
-    network.
-    The structure pointed by connectionConfig contains parameters describing
-    the network to join or, in case of an ad hoc network, to host or join.
-    The SME will select a network, perform the IEEE 802.11 Join, Authenticate
-    and Associate exchanges.
-    The SME selects the networks from the current scan list that match both
-    the SSID and BSSID, however either or both of these may be the wildcard
-    value. Using this rule, the following operations are possible:
-      * To connect to a network by name, specify the SSID and set the BSSID to
-        0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible,
-        the SME will select the one with the strongest signal.
-      * To connect to a specific network, specify the BSSID. The SSID is
-        optional, but if given it must match the SSID of the network. An empty
-        SSID may be specified by setting the SSID length to zero. Please note
-        that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF
-        0xFF 0xFF), the SME will not attempt to roam if signal conditions become
-        poor, even if there is an alternative AP with an SSID that matches the
-        current network SSID.
-      * To connect to any network matching the other parameters (i.e. security,
-        etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF
-        0xFF 0xFF 0xFF. In this case, the SME will order all available networks
-        by their signal strengths and will iterate through this list until it
-        successfully connects.
-    NOTE: Specifying the BSSID will restrict the selection to one specific
-    network. If SSID and BSSID are given, they must both match the network
-    for it to be selected. To select a network based on the SSID only, the
-    wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF
-    0xFF 0xFF.
-    The SME will try to connect to each network that matches the provided
-    parameters, one by one, until it succeeds or has tried unsuccessfully
-    with all the matching networks.
-    If there is no network that matches the parameters and the request allows
-    to host an ad hoc network, the SME will advertise a new ad hoc network
-    instead.
-    If the SME cannot connect, it will notify the failure in the confirm.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    connectionConfig - Describes the candidate network to join or to host.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent            common;
-    u16                  interfaceTag;
-    CsrWifiSmeConnectionConfig connectionConfig;
-} CsrWifiSmeConnectReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the ConnectionConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeConnectionConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionInfoGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the ConnectionInfo parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeConnectionInfoGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionStatsGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the ConnectionStats parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeConnectionStatsGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeactivateReq
-
-  DESCRIPTION
-    The WMA sends this primitive to deactivate the SME.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeDeactivateReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDisconnectReq
-
-  DESCRIPTION
-    The wireless manager application may disconnect from the current network
-    by calling this primitive
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeDisconnectReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEventMaskSetReq
-
-  DESCRIPTION
-    The wireless manager application may register with the SME to receive
-    notification of interesting events. Indications will be sent only if the
-    wireless manager explicitly registers to be notified of that event.
-    indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask.
-
-  MEMBERS
-    common  - Common header for use with the CsrWifiFsm Module
-    indMask - Set mask with values from CsrWifiSmeIndications
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    CsrWifiSmeIndicationsMask indMask;
-} CsrWifiSmeEventMaskSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the hostConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeHostConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the hostConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    hostConfig   - Communicates a change of host power state (for example, on
-                   mains power, on battery power etc) and of the periodicity of
-                   traffic data
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrWifiSmeHostConfig hostConfig;
-} CsrWifiSmeHostConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeKeyReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to add or remove
-    keys that the chip should use for encryption of data.
-    The interface allows the wireless manager application to add and remove
-    keys according to the specified action.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    action       - The value of the CsrWifiSmeListAction parameter instructs the
-                   driver to modify or provide the list of keys.
-                   CSR_WIFI_SME_LIST_ACTION_GET is not supported here.
-    key          - Key to be added or removed
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrWifiSmeListAction action;
-    CsrWifiSmeKey        key;
-} CsrWifiSmeKeyReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeLinkQualityGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the LinkQuality parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeLinkQualityGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the MibConfig parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeMibConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the MibConfig parameter.
-
-  MEMBERS
-    common    - Common header for use with the CsrWifiFsm Module
-    mibConfig - Conveys the desired value of various IEEE 802.11 attributes as
-                currently configured
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    CsrWifiSmeMibConfig mibConfig;
-} CsrWifiSmeMibConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetNextReq
-
-  DESCRIPTION
-    To read a sequence of MIB parameters, for example a table, call this
-    primitive to find the name of the next MIB variable
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to a VarBind or VarBindList containing the
-                         name(s) of the MIB variable(s) to search from.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       mibAttributeLength;
-    u8       *mibAttribute;
-} CsrWifiSmeMibGetNextReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to retrieve one or
-    more MIB variables.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to the VarBind or VarBindList containing the
-                         names of the MIB variables to be retrieved
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       mibAttributeLength;
-    u8       *mibAttribute;
-} CsrWifiSmeMibGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibSetReq
-
-  DESCRIPTION
-    The SME provides raw access to the MIB on the chip, which may be used by
-    some configuration or diagnostic utilities, but is not normally needed by
-    the wireless manager application.
-    The MIB access functions use BER encoded names (OID) of the MIB
-    parameters and BER encoded values, as described in the chip Host
-    Interface Protocol Specification.
-    The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information
-    Base Reference Guide'.
-    The wireless manager application calls this primitive to set one or more
-    MIB variables
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to the VarBind or VarBindList containing the
-                         names and values of the MIB variables to set
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       mibAttributeLength;
-    u8       *mibAttribute;
-} CsrWifiSmeMibSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMulticastAddressReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to specify the
-    multicast addresses which the chip should recognise. The interface allows
-    the wireless manager application to query, add, remove and flush the
-    multicast addresses for the network interface according to the specified
-    action.
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    interfaceTag      - Interface Identifier; unique identifier of an interface
-    action            - The value of the CsrWifiSmeListAction parameter
-                        instructs the driver to modify or provide the list of
-                        MAC addresses.
-    setAddressesCount - Number of MAC addresses sent with the primitive
-    setAddresses      - Pointer to the list of MAC Addresses sent with the
-                        primitive, set to NULL if none is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrWifiSmeListAction action;
-    u8             setAddressesCount;
-    CsrWifiMacAddress   *setAddresses;
-} CsrWifiSmeMulticastAddressReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePacketFilterSetReq
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to enable or
-    disable filtering of broadcast packets: uninteresting broadcast packets
-    will be dropped by the Wi-Fi chip, instead of passing them up to the
-    host.
-    This has the advantage of saving power in the host application processor
-    as it removes the need to process unwanted packets.
-    All broadcast packets are filtered according to the filter and the filter
-    mode provided, except ARP packets, which are filtered using
-    arpFilterAddress.
-    Filters are not cumulative: only the parameters specified in the most
-    recent successful request are significant.
-    For more information, see 'UniFi Firmware API Specification'.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    filterLength     - Length of the filter in bytes.
-                       filterLength=0 disables the filter previously set
-    filter           - Points to the first byte of the filter provided, if any.
-                       This shall include zero or more instance of the
-                       information elements of one of these types
-                         * Traffic Classification (TCLAS) elements
-                         * WMM-SA TCLAS elements
-    mode             - Specifies whether the filter selects or excludes packets
-                       matching the filter
-    arpFilterAddress - IPv4 address to be used for filtering the ARP packets.
-                         * If the specified address is the IPv4 broadcast address
-                           (255.255.255.255), all ARP packets are reported to the
-                           host,
-                         * If the specified address is NOT the IPv4 broadcast
-                           address, only ARP packets with the specified address in
-                           the Source or Target Protocol Address fields are reported
-                           to the host
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent            common;
-    u16                  interfaceTag;
-    u16                  filterLength;
-    u8                  *filter;
-    CsrWifiSmePacketFilterMode mode;
-    CsrWifiIp4Address          arpFilterAddress;
-} CsrWifiSmePacketFilterSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePermanentMacAddressGetReq
-
-  DESCRIPTION
-    This primitive retrieves the MAC address stored in EEPROM
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmePermanentMacAddressGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to request an
-    operation on the SME PMKID list.
-    The action argument specifies the operation to perform.
-    When the connection is complete, the wireless manager application may
-    then send and receive EAPOL packets to complete WPA or WPA2
-    authentication if appropriate.
-    The wireless manager application can then pass the resulting encryption
-    keys using this primitive.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    action         - The value of the CsrWifiSmeListAction parameter instructs
-                     the driver to modify or provide the list of PMKIDs.
-    setPmkidsCount - Number of PMKIDs sent with the primitive
-    setPmkids      - Pointer to the list of PMKIDs sent with the primitive, set
-                     to NULL if none is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrWifiSmeListAction action;
-    u8             setPmkidsCount;
-    CsrWifiSmePmkid     *setPmkids;
-} CsrWifiSmePmkidReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the PowerConfig parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmePowerConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the PowerConfig parameter.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    powerConfig - Power saving configuration
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrWifiSmePowerConfig powerConfig;
-} CsrWifiSmePowerConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRegulatoryDomainInfoGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the RegulatoryDomainInfo parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeRegulatoryDomainInfoGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the RoamingConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeRoamingConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the RoamingConfig parameter.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    roamingConfig - Desired roaming behaviour values
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    CsrWifiSmeRoamingConfig roamingConfig;
-} CsrWifiSmeRoamingConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the ScanConfig parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeScanConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the ScanConfig parameter.
-    The SME normally configures the firmware to perform autonomous scanning
-    without involving the host.
-    The firmware passes beacon / probe response or indicates loss of beacon
-    on certain changes of state, for example:
-      * A new AP is seen for the first time
-      * An AP is no longer visible
-      * The signal strength of an AP changes by more than a certain amount, as
-        configured by the thresholds in the scanConfig parameter
-    In addition to the autonomous scan, the wireless manager application may
-    request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    scanConfig - Reports the configuration for the autonomous scanning behaviour
-                 of the firmware
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrWifiSmeScanConfig scanConfig;
-} CsrWifiSmeScanConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanFullReq
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to request a
-    full scan.
-    Channels are scanned actively or passively according to the requirement
-    set by regulatory domain.
-    If the SME receives this primitive while a full scan is going on, the new
-    request is buffered and it will be served after the current full scan is
-    completed.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    ssidCount        - Number of SSIDs provided.
-                       If it is 0, the SME will attempt to detect any network
-    ssid             - Points to the first SSID provided, if any.
-    bssid            - BSS identifier.
-                       If it is equal to FF-FF-FF-FF-FF, the SME will listen for
-                       messages from any BSS.
-                       If it is different from FF-FF-FF-FF-FF and any SSID is
-                       provided, one SSID must match the network of the BSS.
-    forceScan        - Forces the scan even if the SME is in a state which would
-                       normally prevent it (e.g. autonomous scan is running).
-    bssType          - Type of BSS to scan for
-    scanType         - Type of scan to perform
-    channelListCount - Number of channels provided.
-                       If it is 0, the SME will initiate a scan of all the
-                       supported channels that are permitted by the current
-                       regulatory domain.
-    channelList      - Points to the first channel , or NULL if channelListCount
-                       is zero.
-    probeIeLength    - Length of the information element in bytes to be sent
-                       with the probe message.
-    probeIe          - Points to the first byte of the information element to be
-                       sent with the probe message.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent    common;
-    u8           ssidCount;
-    CsrWifiSsid       *ssid;
-    CsrWifiMacAddress  bssid;
-    u8            forceScan;
-    CsrWifiSmeBssType  bssType;
-    CsrWifiSmeScanType scanType;
-    u16          channelListCount;
-    u8          *channelList;
-    u16          probeIeLength;
-    u8          *probeIe;
-} CsrWifiSmeScanFullReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsFlushReq
-
-  DESCRIPTION
-    The Wireless Manager calls this primitive to ask the SME to delete all
-    scan results from its cache, except for the scan result of any currently
-    connected network.
-    As scan results are received by the SME from the firmware, they are
-    cached in the SME memory.
-    Any time the Wireless Manager requests scan results, they are returned
-    from the SME internal cache.
-    For some applications it may be desirable to clear this cache prior to
-    requesting that a scan be performed; this will ensure that the cache then
-    only contains the networks detected in the most recent scan.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeScanResultsFlushReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsGetReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to retrieve the
-    current set of scan results, either after receiving a successful
-    CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeScanResultsGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the SmeStaConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-} CsrWifiSmeSmeStaConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the SmeConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    smeConfig    - SME Station Parameters to be set
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    u16           interfaceTag;
-    CsrWifiSmeStaConfig smeConfig;
-} CsrWifiSmeSmeStaConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeStationMacAddressGetReq
-
-  DESCRIPTION
-    This primitives is used to retrieve the current MAC address used by the
-    station.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeStationMacAddressGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecReq
-
-  DESCRIPTION
-    The wireless manager application should call this primitive to use the
-    TSPEC feature.
-    The chip supports the use of TSPECs and TCLAS for the use of IEEE
-    802.11/WMM Quality of Service features.
-    The API allows the wireless manager application to supply a correctly
-    formatted TSPEC and TCLAS pair to the driver.
-    After performing basic validation, the driver negotiates the installation
-    of the TSPEC with the AP as defined by the 802.11 specification.
-    The driver retains all TSPEC and TCLAS pairs until they are specifically
-    removed.
-    It is not compulsory for a TSPEC to have a TCLAS (NULL is used to
-    indicate that no TCLAS is supplied), while a TCLASS always require a
-    TSPEC.
-    The format of the TSPEC element is specified in 'WMM (including WMM Power
-    Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'.
-    For more information, see 'UniFi Configuring WMM and WMM-PS'.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    action        - Specifies the action to be carried out on the list of TSPECs.
-                    CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here.
-    transactionId - Unique Transaction ID for the TSPEC, as assigned by the
-                    driver
-    strict        - If it set to false, allows the SME to perform automatic
-                    TSPEC negotiation
-    ctrlMask      - Additional TSPEC configuration for CCX.
-                    Set mask with values from CsrWifiSmeTspecCtrl.
-                    CURRENTLY NOT SUPPORTED
-    tspecLength   - Length of the TSPEC.
-    tspec         - Points to the first byte of the TSPEC
-    tclasLength   - Length of the TCLAS.
-                    If it is equal to 0, no TCLASS is provided for the TSPEC
-    tclas         - Points to the first byte of the TCLAS, if any.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    CsrWifiSmeListAction    action;
-    u32               transactionId;
-    u8                 strict;
-    CsrWifiSmeTspecCtrlMask ctrlMask;
-    u16               tspecLength;
-    u8               *tspec;
-    u16               tclasLength;
-    u8               *tclas;
-} CsrWifiSmeTspecReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeVersionsGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the Versions parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeVersionsGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiFlightmodeReq
-
-  DESCRIPTION
-    The wireless manager application may call this primitive on boot-up of
-    the platform to ensure that the chip is placed in a mode that prevents
-    any emission of RF energy.
-    This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ.
-    As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file
-    (if any) and the programming of the initial MIB settings (if supplied by
-    the WMA), but it also ensures that the chip is left in its lowest
-    possible power-mode with the radio subsystems disabled.
-    This feature is useful on platforms where power cannot be removed from
-    the chip (leaving the chip not initialised will cause it to consume more
-    power so calling this function ensures that the chip is initialised into
-    a low power mode but without entering a state where it could emit any RF
-    energy).
-    NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi
-    stays conceptually off. Configuration primitives can be sent after
-    CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained.
-    Requests that require the state of the Wi-Fi to be ON will return
-    CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    address       - Optionally specifies a station MAC address.
-                    In normal use, the manager should set the address to 0xFF
-                    0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
-                    the MAC address in the MIB.
-    mibFilesCount - Number of provided data blocks with initial MIB values
-    mibFiles      - Points to the first data block with initial MIB values.
-                    These data blocks are typically the contents of the provided
-                    files ufmib.dat and localmib.dat, available from the host
-                    file system, if they exist.
-                    These files typically contain radio tuning and calibration
-                    values.
-                    More values can be created using the Host Tools.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrWifiMacAddress    address;
-    u16            mibFilesCount;
-    CsrWifiSmeDataBlock *mibFiles;
-} CsrWifiSmeWifiFlightmodeReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOffReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to turn off the
-    chip, thus saving power when Wi-Fi is not in use.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeWifiOffReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOnReq
-
-  DESCRIPTION
-    The wireless manager application calls this primitive to turn on the
-    Wi-Fi chip.
-    If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on,
-    downloads the patch file (if any), and programs the initial MIB settings
-    (if supplied by the WMA).
-    The patch file is not provided with the SME API; its downloading is
-    automatic and handled internally by the system.
-    The MIB settings, when provided, override the default values that the
-    firmware loads from EEPROM.
-    If the Wi-Fi chip is already on, the SME takes no action and returns a
-    successful status in the confirm.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    address       - Optionally specifies a station MAC address.
-                    In normal use, the manager should set the address to 0xFF
-                    0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
-                    the MAC address in the MIB
-    mibFilesCount - Number of provided data blocks with initial MIB values
-    mibFiles      - Points to the first data block with initial MIB values.
-                    These data blocks are typically the contents of the provided
-                    files ufmib.dat and localmib.dat, available from the host
-                    file system, if they exist.
-                    These files typically contain radio tuning and calibration
-                    values.
-                    More values can be created using the Host Tools.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrWifiMacAddress    address;
-    u16            mibFilesCount;
-    CsrWifiSmeDataBlock *mibFiles;
-} CsrWifiSmeWifiOnReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsSetReq
-
-  DESCRIPTION
-    This primitive sets the list of cloaked SSIDs for which the WMA possesses
-    profiles.
-    When the driver detects a cloaked AP, the SME will explicitly scan for it
-    using the list of cloaked SSIDs provided it, and, if the scan succeeds,
-    it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND
-    (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    cloakedSsids - Sets the list of cloaked SSIDs
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent             common;
-    CsrWifiSmeCloakedSsidConfig cloakedSsids;
-} CsrWifiSmeCloakedSsidsSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the CloakedSsids parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeCloakedSsidsGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigGetReq
-
-  DESCRIPTION
-    This primitive gets the value of the Sme common parameter.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeSmeCommonConfigGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigSetReq
-
-  DESCRIPTION
-    This primitive sets the value of the Sme common.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    deviceConfig - Configuration options in the SME
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent        common;
-    CsrWifiSmeDeviceConfig deviceConfig;
-} CsrWifiSmeSmeCommonConfigSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeInterfaceCapabilityGetReq
-
-  DESCRIPTION
-    The Wireless Manager calls this primitive to ask the SME for the
-    capabilities of the supported interfaces
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-} CsrWifiSmeInterfaceCapabilityGetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfigurationReq
-
-  DESCRIPTION
-    This primitive passes the WPS information for the device to SME. This may
-    be accepted only if no interface is active.
-
-  MEMBERS
-    common    - Common header for use with the CsrWifiFsm Module
-    wpsConfig - WPS config.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    CsrWifiSmeWpsConfig wpsConfig;
-} CsrWifiSmeWpsConfigurationReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSetReq
-
-  DESCRIPTION
-    Used to pass custom data to the SME. Format is the same as 802.11 Info
-    Elements => | Id | Length | Data
-    1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01
-    (0x00|0x01)"
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    dataLength - Number of bytes in the buffer pointed to by 'data'
-    data       - Pointer to the buffer containing 'dataLength' bytes
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u32       dataLength;
-    u8       *data;
-} CsrWifiSmeSetReq;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeActivateCfm
-
-  DESCRIPTION
-    The SME sends this primitive when the activation is complete.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeActivateCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    status      - Reports the result of the request
-    adHocConfig - Contains the values used when starting an Ad-hoc (IBSS)
-                  connection.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrResult             status;
-    CsrWifiSmeAdHocConfig adHocConfig;
-} CsrWifiSmeAdhocConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAdhocConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeAdhocConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAssociationCompleteInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it completes an attempt to associate with an AP. If
-    the association was successful, status will be set to
-    CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be
-    set to appropriate error codes.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the association procedure
-    connectionInfo - This parameter is relevant only if result is
-                     CSR_WIFI_SME_STATUS_SUCCESS:
-                     it points to the connection information for the new network
-    deauthReason   - This parameter is relevant only if result is not
-                     CSR_WIFI_SME_STATUS_SUCCESS:
-                     if the AP deauthorised the station, it gives the reason of
-                     the deauthorization
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrResult                 status;
-    CsrWifiSmeConnectionInfo  connectionInfo;
-    CsrWifiSmeIEEE80211Reason deauthReason;
-} CsrWifiSmeAssociationCompleteInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAssociationStartInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it begins an attempt to associate with an AP.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    address      - BSSID of the associating network
-    ssid         - Service Set identifier of the associating network
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    CsrWifiMacAddress address;
-    CsrWifiSsid       ssid;
-} CsrWifiSmeAssociationStartInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeBlacklistCfm
-
-  DESCRIPTION
-    The SME will call this primitive when the action on the blacklist has
-    completed. For a GET action, this primitive also reports the list of
-    BBSIDs in the blacklist.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    status          - Reports the result of the request
-    action          - Action in the request
-    getAddressCount - This parameter is only relevant if action is
-                      CSR_WIFI_SME_LIST_ACTION_GET:
-                      number of BSSIDs sent with this primitive
-    getAddresses    - Pointer to the list of BBSIDs sent with the primitive, set
-                      to NULL if none is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrResult            status;
-    CsrWifiSmeListAction action;
-    u8             getAddressCount;
-    CsrWifiMacAddress   *getAddresses;
-} CsrWifiSmeBlacklistCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common                - Common header for use with the CsrWifiFsm Module
-    status                - Reports the result of the request
-    calibrationDataLength - Number of bytes in the buffer pointed by
-                            calibrationData
-    calibrationData       - Pointer to a buffer of length calibrationDataLength
-                            containing the calibration data
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-    u16       calibrationDataLength;
-    u8       *calibrationData;
-} CsrWifiSmeCalibrationDataGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCalibrationDataSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeCalibrationDataSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    ccxConfig    - Currently not supported
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    u16           interfaceTag;
-    CsrResult           status;
-    CsrWifiSmeCcxConfig ccxConfig;
-} CsrWifiSmeCcxConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCcxConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeCcxConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    status     - Reports the result of the request
-    coexConfig - Reports the parameters used to configure the coexistence
-                 behaviour
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrResult            status;
-    CsrWifiSmeCoexConfig coexConfig;
-} CsrWifiSmeCoexConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeCoexConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoexInfoGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common   - Common header for use with the CsrWifiFsm Module
-    status   - Reports the result of the request
-    coexInfo - Reports information and state related to coexistence.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent    common;
-    CsrResult          status;
-    CsrWifiSmeCoexInfo coexInfo;
-} CsrWifiSmeCoexInfoGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectCfm
-
-  DESCRIPTION
-    The SME calls this primitive when the connection exchange is complete or
-    all connection attempts fail.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request.
-                   CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to
-                   locate the requested AP failed
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeConnectCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    interfaceTag     - Interface Identifier; unique identifier of an interface
-    status           - Reports the result of the request
-    connectionConfig - Parameters used by the SME for selecting a network
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent            common;
-    u16                  interfaceTag;
-    CsrResult                  status;
-    CsrWifiSmeConnectionConfig connectionConfig;
-} CsrWifiSmeConnectionConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionInfoGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the request
-    connectionInfo - Information about the current connection
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent          common;
-    u16                interfaceTag;
-    CsrResult                status;
-    CsrWifiSmeConnectionInfo connectionInfo;
-} CsrWifiSmeConnectionInfoGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionQualityInd
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it whenever the value of the current connection quality
-    parameters change by more than a certain configurable amount.
-    The wireless manager application may configure the trigger thresholds for
-    this indication using the field in smeConfig parameter of
-    CSR_WIFI_SME_SME_CONFIG_SET_REQ.
-    Connection quality messages can be suppressed by setting both thresholds
-    to zero.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    linkQuality  - Indicates the quality of the link
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    u16             interfaceTag;
-    CsrWifiSmeLinkQuality linkQuality;
-} CsrWifiSmeConnectionQualityInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeConnectionStatsGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    status          - Reports the result of the request
-    connectionStats - Statistics for current connection.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrResult                 status;
-    CsrWifiSmeConnectionStats connectionStats;
-} CsrWifiSmeConnectionStatsGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDeactivateCfm
-
-  DESCRIPTION
-    The SME sends this primitive when the deactivation is complete.
-    The WMA cannot send any more primitives until it actives the SME again
-    sending another CSR_WIFI_SME_ACTIVATE_REQ.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeDeactivateCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeDisconnectCfm
-
-  DESCRIPTION
-    On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a
-    disconnect operation, sending a CsrWifiSmeMediaStatusInd with
-    CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when
-    disconnection is complete.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeDisconnectCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeEventMaskSetCfm
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the request
-    primitive.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeEventMaskSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    hostConfig   - Current host power state.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrResult            status;
-    CsrWifiSmeHostConfig hostConfig;
-} CsrWifiSmeHostConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeHostConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeHostConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeIbssStationInd
-
-  DESCRIPTION
-    The SME will send this primitive to indicate that a station has joined or
-    left the ad-hoc network.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    address     - MAC address of the station that has joined or left
-    isconnected - TRUE if the station joined, FALSE if the station left
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    CsrWifiMacAddress address;
-    u8           isconnected;
-} CsrWifiSmeIbssStationInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeKeyCfm
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the request
-    primitive.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the request
-    action         - Action in the request
-    keyType        - Type of the key added/deleted
-    peerMacAddress - Peer MAC Address of the key added/deleted
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrResult            status;
-    CsrWifiSmeListAction action;
-    CsrWifiSmeKeyType    keyType;
-    CsrWifiMacAddress    peerMacAddress;
-} CsrWifiSmeKeyCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeLinkQualityGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    linkQuality  - Indicates the quality of the link
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    u16             interfaceTag;
-    CsrResult             status;
-    CsrWifiSmeLinkQuality linkQuality;
-} CsrWifiSmeLinkQualityGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMediaStatusInd
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it when a network connection is established, lost or has moved to
-    another AP.
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    mediaStatus    - Indicates the media status
-    connectionInfo - This parameter is relevant only if the mediaStatus is
-                     CSR_WIFI_SME_MEDIA_STATUS_CONNECTED:
-                     it points to the connection information for the new network
-    disassocReason - This parameter is relevant only if the mediaStatus is
-                     CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
-                     if a disassociation has occurred it gives the reason of the
-                     disassociation
-    deauthReason   - This parameter is relevant only if the mediaStatus is
-                     CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
-                     if a deauthentication has occurred it gives the reason of
-                     the deauthentication
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrWifiSmeMediaStatus     mediaStatus;
-    CsrWifiSmeConnectionInfo  connectionInfo;
-    CsrWifiSmeIEEE80211Reason disassocReason;
-    CsrWifiSmeIEEE80211Reason deauthReason;
-} CsrWifiSmeMediaStatusInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common    - Common header for use with the CsrWifiFsm Module
-    status    - Reports the result of the request
-    mibConfig - Reports various IEEE 802.11 attributes as currently configured
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    CsrResult           status;
-    CsrWifiSmeMibConfig mibConfig;
-} CsrWifiSmeMibConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeMibConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetCfm
-
-  DESCRIPTION
-    The SME calls this primitive to return the requested MIB variable values.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    status             - Reports the result of the request
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to the VarBind or VarBindList containing the
-                         names and values of the MIB variables requested
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-    u16       mibAttributeLength;
-    u8       *mibAttribute;
-} CsrWifiSmeMibGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibGetNextCfm
-
-  DESCRIPTION
-    The SME calls this primitive to return the requested MIB name(s).
-    The wireless manager application can then read the value of the MIB
-    variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided.
-
-  MEMBERS
-    common             - Common header for use with the CsrWifiFsm Module
-    status             - Reports the result of the request
-    mibAttributeLength - Length of mibAttribute
-    mibAttribute       - Points to a VarBind or VarBindList containing the
-                         name(s) of the MIB variable(s) lexicographically
-                         following the name(s) given in the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-    u16       mibAttributeLength;
-    u8       *mibAttribute;
-} CsrWifiSmeMibGetNextCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMibSetCfm
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the set primitive.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeMibSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMicFailureInd
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it whenever the chip firmware reports a MIC failure.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    secondFailure - TRUE if this indication is for a second failure in 60
-                    seconds
-    count         - The number of MIC failure events since the connection was
-                    established
-    address       - MAC address of the transmitter that caused the MIC failure
-    keyType       - Type of key for which the failure occurred
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    u16         interfaceTag;
-    u8           secondFailure;
-    u16         count;
-    CsrWifiMacAddress address;
-    CsrWifiSmeKeyType keyType;
-} CsrWifiSmeMicFailureInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeMulticastAddressCfm
-
-  DESCRIPTION
-    The SME will call this primitive when the operation is complete. For a
-    GET action, this primitive reports the current list of MAC addresses.
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    interfaceTag      - Interface Identifier; unique identifier of an interface
-    status            - Reports the result of the request
-    action            - Action in the request
-    getAddressesCount - This parameter is only relevant if action is
-                        CSR_WIFI_SME_LIST_ACTION_GET:
-                        number of MAC addresses sent with the primitive
-    getAddresses      - Pointer to the list of MAC Addresses sent with the
-                        primitive, set to NULL if none is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrResult            status;
-    CsrWifiSmeListAction action;
-    u8             getAddressesCount;
-    CsrWifiMacAddress   *getAddresses;
-} CsrWifiSmeMulticastAddressCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePacketFilterSetCfm
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the set primitive.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmePacketFilterSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePermanentMacAddressGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common              - Common header for use with the CsrWifiFsm Module
-    status              - Reports the result of the request
-    permanentMacAddress - MAC address stored in the EEPROM
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    CsrResult         status;
-    CsrWifiMacAddress permanentMacAddress;
-} CsrWifiSmePermanentMacAddressGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidCandidateListInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it when a new network supporting preauthentication and/or PMK
-    caching is seen.
-
-  MEMBERS
-    common               - Common header for use with the CsrWifiFsm Module
-    interfaceTag         - Interface Identifier; unique identifier of an
-                           interface
-    pmkidCandidatesCount - Number of PMKID candidates provided
-    pmkidCandidates      - Points to the first PMKID candidate
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    u8                  pmkidCandidatesCount;
-    CsrWifiSmePmkidCandidate *pmkidCandidates;
-} CsrWifiSmePmkidCandidateListInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePmkidCfm
-
-  DESCRIPTION
-    The SME will call this primitive when the operation is complete. For a
-    GET action, this primitive reports the current list of PMKIDs
-
-  MEMBERS
-    common         - Common header for use with the CsrWifiFsm Module
-    interfaceTag   - Interface Identifier; unique identifier of an interface
-    status         - Reports the result of the request
-    action         - Action in the request
-    getPmkidsCount - This parameter is only relevant if action is
-                     CSR_WIFI_SME_LIST_ACTION_GET:
-                     number of PMKIDs sent with the primitive
-    getPmkids      - Pointer to the list of PMKIDs sent with the primitive, set
-                     to NULL if none is sent.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    u16            interfaceTag;
-    CsrResult            status;
-    CsrWifiSmeListAction action;
-    u8             getPmkidsCount;
-    CsrWifiSmePmkid     *getPmkids;
-} CsrWifiSmePmkidCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    status      - Reports the result of the request
-    powerConfig - Returns the current parameters for the power configuration of
-                  the firmware
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrResult             status;
-    CsrWifiSmePowerConfig powerConfig;
-} CsrWifiSmePowerConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmePowerConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmePowerConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRegulatoryDomainInfoGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    status     - Reports the result of the request
-    regDomInfo - Reports information and state related to regulatory domain
-                 operation.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent                common;
-    CsrResult                      status;
-    CsrWifiSmeRegulatoryDomainInfo regDomInfo;
-} CsrWifiSmeRegulatoryDomainInfoGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamCompleteInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it completes an attempt to roam to an AP. If the roam
-    attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS,
-    otherwise it shall be set to the appropriate error code.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the roaming procedure
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeRoamCompleteInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamStartInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive it whenever it begins an attempt to roam to an AP.
-    If the wireless manager application connect request specified the SSID
-    and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF
-    0xFF), the SME monitors the signal quality and maintains a list of
-    candidates to roam to. When the signal quality of the current connection
-    falls below a threshold, and there is a candidate with better quality,
-    the SME will attempt to the candidate AP.
-    If the roaming procedure succeeds, the SME will also issue a Media
-    Connect indication to inform the wireless manager application of the
-    change.
-    NOTE: to prevent the SME from initiating roaming the WMA must specify the
-    BSSID in the connection request; this forces the SME to connect only to
-    that AP.
-    The wireless manager application can obtain statistics for roaming
-    purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and
-    CSR_WIFI_SME_CONNECTION_STATS_GET_REQ.
-    When the wireless manager application wishes to roam to another AP, it
-    must issue a connection request specifying the BSSID of the desired AP.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    roamReason   - Indicates the reason for starting the roaming procedure
-    reason80211  - Indicates the reason for deauthentication or disassociation
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrWifiSmeRoamReason      roamReason;
-    CsrWifiSmeIEEE80211Reason reason80211;
-} CsrWifiSmeRoamStartInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    interfaceTag  - Interface Identifier; unique identifier of an interface
-    status        - Reports the result of the request
-    roamingConfig - Reports the roaming behaviour of the driver and firmware
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent         common;
-    u16               interfaceTag;
-    CsrResult               status;
-    CsrWifiSmeRoamingConfig roamingConfig;
-} CsrWifiSmeRoamingConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeRoamingConfigSetCfm
-
-  DESCRIPTION
-    This primitive sets the value of the RoamingConfig parameter.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeRoamingConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    status     - Reports the result of the request
-    scanConfig - Returns the current parameters for the autonomous scanning
-                 behaviour of the firmware
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrResult            status;
-    CsrWifiSmeScanConfig scanConfig;
-} CsrWifiSmeScanConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeScanConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanFullCfm
-
-  DESCRIPTION
-    The SME calls this primitive when the results from the scan are
-    available.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeScanFullCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultInd
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it whenever a scan indication is received from the firmware.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    result - Points to a buffer containing a scan result.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent      common;
-    CsrWifiSmeScanResult result;
-} CsrWifiSmeScanResultInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsFlushCfm
-
-  DESCRIPTION
-    The SME will call this primitive when the cache has been cleared.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeScanResultsFlushCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeScanResultsGetCfm
-
-  DESCRIPTION
-    The SME sends this primitive to provide the current set of scan results.
-
-  MEMBERS
-    common           - Common header for use with the CsrWifiFsm Module
-    status           - Reports the result of the request
-    scanResultsCount - Number of scan results
-    scanResults      - Points to a buffer containing an array of
-                       CsrWifiSmeScanResult structures.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent       common;
-    CsrResult             status;
-    u16             scanResultsCount;
-    CsrWifiSmeScanResult *scanResults;
-} CsrWifiSmeScanResultsGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-    smeConfig    - Current SME Station Parameters
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    u16           interfaceTag;
-    CsrResult           status;
-    CsrWifiSmeStaConfig smeConfig;
-} CsrWifiSmeSmeStaConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeStaConfigSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface Identifier; unique identifier of an interface
-    status       - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u16       interfaceTag;
-    CsrResult       status;
-} CsrWifiSmeSmeStaConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeStationMacAddressGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common            - Common header for use with the CsrWifiFsm Module
-    status            - Reports the result of the request
-    stationMacAddress - Current MAC address of the station.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    CsrResult         status;
-    CsrWifiMacAddress stationMacAddress[2];
-} CsrWifiSmeStationMacAddressGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the task that have registered to
-    receive it when a status change in the TSPEC occurs.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    transactionId   - Unique Transaction ID for the TSPEC, as assigned by the
-                      driver
-    tspecResultCode - Specifies the TSPEC operation requested by the peer
-                      station
-    tspecLength     - Length of the TSPEC.
-    tspec           - Points to the first byte of the TSPEC
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    u32                 transactionId;
-    CsrWifiSmeTspecResultCode tspecResultCode;
-    u16                 tspecLength;
-    u8                 *tspec;
-} CsrWifiSmeTspecInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeTspecCfm
-
-  DESCRIPTION
-    The SME calls the primitive to report the result of the TSpec primitive
-    request.
-
-  MEMBERS
-    common          - Common header for use with the CsrWifiFsm Module
-    interfaceTag    - Interface Identifier; unique identifier of an interface
-    status          - Reports the result of the request
-    transactionId   - Unique Transaction ID for the TSPEC, as assigned by the
-                      driver
-    tspecResultCode - Specifies the result of the negotiated TSPEC operation
-    tspecLength     - Length of the TSPEC.
-    tspec           - Points to the first byte of the TSPEC
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent           common;
-    u16                 interfaceTag;
-    CsrResult                 status;
-    u32                 transactionId;
-    CsrWifiSmeTspecResultCode tspecResultCode;
-    u16                 tspecLength;
-    u8                 *tspec;
-} CsrWifiSmeTspecCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeVersionsGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common   - Common header for use with the CsrWifiFsm Module
-    status   - Reports the result of the request
-    versions - Version IDs of the product
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent    common;
-    CsrResult          status;
-    CsrWifiSmeVersions versions;
-} CsrWifiSmeVersionsGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiFlightmodeCfm
-
-  DESCRIPTION
-    The SME calls this primitive when the chip is initialised for low power
-    mode and with the radio subsystem disabled. To leave flight mode, and
-    enable Wi-Fi, the wireless manager application should call
-    CSR_WIFI_SME_WIFI_ON_REQ.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeWifiFlightmodeCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOffInd
-
-  DESCRIPTION
-    The SME sends this primitive to all the tasks that have registered to
-    receive it to report that the chip has been turned off.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    reason - Indicates the reason why the Wi-Fi has been switched off.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent             common;
-    CsrWifiSmeControlIndication reason;
-} CsrWifiSmeWifiOffInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOffCfm
-
-  DESCRIPTION
-    After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a
-    network, the SME will perform a disconnect operation, will send a
-    CSR_WIFI_SME_MEDIA_STATUS_IND with
-    CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call
-    CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeWifiOffCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOnCfm
-
-  DESCRIPTION
-    The SME sends this primitive to the task that has sent the request once
-    the chip has been initialised and is available for use.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeWifiOnCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsSetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeCloakedSsidsSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCloakedSsidsGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    status       - Reports the result of the request
-    cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for
-                   by the driver
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent             common;
-    CsrResult                   status;
-    CsrWifiSmeCloakedSsidConfig cloakedSsids;
-} CsrWifiSmeCloakedSsidsGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWifiOnInd
-
-  DESCRIPTION
-    The SME sends this primitive to all tasks that have registered to receive
-    it once the chip becomes available and ready to use.
-
-  MEMBERS
-    common  - Common header for use with the CsrWifiFsm Module
-    address - Current MAC address
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent   common;
-    CsrWifiMacAddress address;
-} CsrWifiSmeWifiOnInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    status       - Reports the result of the request
-    deviceConfig - Configuration options in the SME
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent        common;
-    CsrResult              status;
-    CsrWifiSmeDeviceConfig deviceConfig;
-} CsrWifiSmeSmeCommonConfigGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeSmeCommonConfigSetCfm
-
-  DESCRIPTION
-    Reports the result of the request
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Reports the result of the request
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeSmeCommonConfigSetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeInterfaceCapabilityGetCfm
-
-  DESCRIPTION
-    This primitive reports the result of the request.
-
-  MEMBERS
-    common        - Common header for use with the CsrWifiFsm Module
-    status        - Result of the request
-    numInterfaces - Number of the interfaces supported
-    capBitmap     - Points to the list of capabilities bitmaps provided for each
-                    interface.
-                    The bits represent the following capabilities:
-                    -bits 7 to 4-Reserved
-                    -bit 3-AMP
-                    -bit 2-P2P
-                    -bit 1-AP
-                    -bit 0-STA
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-    u16       numInterfaces;
-    u8        capBitmap[2];
-} CsrWifiSmeInterfaceCapabilityGetCfm;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeErrorInd
-
-  DESCRIPTION
-    Important error message indicating a error of some importance
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    errorMessage - Contains the error message.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    char  *errorMessage;
-} CsrWifiSmeErrorInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeInfoInd
-
-  DESCRIPTION
-    Message indicating a some info about current activity. Mostly of interest
-    in testing but may be useful in the field.
-
-  MEMBERS
-    common      - Common header for use with the CsrWifiFsm Module
-    infoMessage - Contains the message.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    char  *infoMessage;
-} CsrWifiSmeInfoInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeCoreDumpInd
-
-  DESCRIPTION
-    The SME will send this primitive to all the tasks that have registered to
-    receive Wi-Fi Chip core dump data.
-    The core dump data may be fragmented and sent using more than one
-    indication.
-    To indicate that all the data has been sent, the last indication contains
-    a 'length' of 0 and 'data' of NULL.
-
-  MEMBERS
-    common     - Common header for use with the CsrWifiFsm Module
-    dataLength - Number of bytes in the buffer pointed to by 'data'
-    data       - Pointer to the buffer containing 'dataLength' bytes of core
-                 dump data
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    u32       dataLength;
-    u8       *data;
-} CsrWifiSmeCoreDumpInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeAmpStatusChangeInd
-
-  DESCRIPTION
-    Indication of change to AMP activity.
-
-  MEMBERS
-    common       - Common header for use with the CsrWifiFsm Module
-    interfaceTag - Interface on which the AMP activity changed.
-    ampStatus    - The new status of AMP activity.Range: {AMP_ACTIVE,
-                   AMP_INACTIVE}.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent     common;
-    u16           interfaceTag;
-    CsrWifiSmeAmpStatus ampStatus;
-} CsrWifiSmeAmpStatusChangeInd;
-
-/*******************************************************************************
-
-  NAME
-    CsrWifiSmeWpsConfigurationCfm
-
-  DESCRIPTION
-    Confirm.
-
-  MEMBERS
-    common - Common header for use with the CsrWifiFsm Module
-    status - Status of the request.
-
-*******************************************************************************/
-typedef struct
-{
-    CsrWifiFsmEvent common;
-    CsrResult       status;
-} CsrWifiSmeWpsConfigurationCfm;
-
-#endif /* CSR_WIFI_SME_PRIM_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_sme_sef.c b/drivers/staging/csr/csr_wifi_sme_sef.c
deleted file mode 100644 (file)
index cf32254..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*****************************************************************************
-
-  (c) Cambridge Silicon Radio Limited 2010
-  Confidential information of CSR
-
-  Refer to LICENSE.txt included with this source for details
-  on the license terms.
-
- *****************************************************************************/
-#include "csr_wifi_sme_sef.h"
-
-const CsrWifiSmeStateHandlerType CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT] =
-{
-    /* 0x8000 */ CsrWifiSmeActivateCfmHandler,
-    /* 0x8001 */ CsrWifiSmeAdhocConfigGetCfmHandler,
-    /* 0x8002 */ CsrWifiSmeAdhocConfigSetCfmHandler,
-    /* 0x8003 */ CsrWifiSmeAssociationCompleteIndHandler,
-    /* 0x8004 */ CsrWifiSmeAssociationStartIndHandler,
-    /* 0x8005 */ CsrWifiSmeBlacklistCfmHandler,
-    /* 0x8006 */ CsrWifiSmeCalibrationDataGetCfmHandler,
-    /* 0x8007 */ CsrWifiSmeCalibrationDataSetCfmHandler,
-    /* 0x8008 */ CsrWifiSmeCcxConfigGetCfmHandler,
-    /* 0x8009 */ CsrWifiSmeCcxConfigSetCfmHandler,
-    /* 0x800A */ CsrWifiSmeCoexConfigGetCfmHandler,
-    /* 0x800B */ CsrWifiSmeCoexConfigSetCfmHandler,
-    /* 0x800C */ CsrWifiSmeCoexInfoGetCfmHandler,
-    /* 0x800D */ CsrWifiSmeConnectCfmHandler,
-    /* 0x800E */ CsrWifiSmeConnectionConfigGetCfmHandler,
-    /* 0x800F */ CsrWifiSmeConnectionInfoGetCfmHandler,
-    /* 0x8010 */ CsrWifiSmeConnectionQualityIndHandler,
-    /* 0x8011 */ CsrWifiSmeConnectionStatsGetCfmHandler,
-    /* 0x8012 */ CsrWifiSmeDeactivateCfmHandler,
-    /* 0x8013 */ CsrWifiSmeDisconnectCfmHandler,
-    /* 0x8014 */ CsrWifiSmeEventMaskSetCfmHandler,
-    /* 0x8015 */ CsrWifiSmeHostConfigGetCfmHandler,
-    /* 0x8016 */ CsrWifiSmeHostConfigSetCfmHandler,
-    /* 0x8017 */ CsrWifiSmeIbssStationIndHandler,
-    /* 0x8018 */ CsrWifiSmeKeyCfmHandler,
-    /* 0x8019 */ CsrWifiSmeLinkQualityGetCfmHandler,
-    /* 0x801A */ CsrWifiSmeMediaStatusIndHandler,
-    /* 0x801B */ CsrWifiSmeMibConfigGetCfmHandler,
-    /* 0x801C */ CsrWifiSmeMibConfigSetCfmHandler,
-    /* 0x801D */ CsrWifiSmeMibGetCfmHandler,
-    /* 0x801E */ CsrWifiSmeMibGetNextCfmHandler,
-    /* 0x801F */ CsrWifiSmeMibSetCfmHandler,
-    /* 0x8020 */ CsrWifiSmeMicFailureIndHandler,
-    /* 0x8021 */ CsrWifiSmeMulticastAddressCfmHandler,
-    /* 0x8022 */ CsrWifiSmePacketFilterSetCfmHandler,
-    /* 0x8023 */ CsrWifiSmePermanentMacAddressGetCfmHandler,
-    /* 0x8024 */ CsrWifiSmePmkidCandidateListIndHandler,
-    /* 0x8025 */ CsrWifiSmePmkidCfmHandler,
-    /* 0x8026 */ CsrWifiSmePowerConfigGetCfmHandler,
-    /* 0x8027 */ CsrWifiSmePowerConfigSetCfmHandler,
-    /* 0x8028 */ CsrWifiSmeRegulatoryDomainInfoGetCfmHandler,
-    /* 0x8029 */ CsrWifiSmeRoamCompleteIndHandler,
-    /* 0x802A */ CsrWifiSmeRoamStartIndHandler,
-    /* 0x802B */ CsrWifiSmeRoamingConfigGetCfmHandler,
-    /* 0x802C */ CsrWifiSmeRoamingConfigSetCfmHandler,
-    /* 0x802D */ CsrWifiSmeScanConfigGetCfmHandler,
-    /* 0x802E */ CsrWifiSmeScanConfigSetCfmHandler,
-    /* 0x802F */ CsrWifiSmeScanFullCfmHandler,
-    /* 0x8030 */ CsrWifiSmeScanResultIndHandler,
-    /* 0x8031 */ CsrWifiSmeScanResultsFlushCfmHandler,
-    /* 0x8032 */ CsrWifiSmeScanResultsGetCfmHandler,
-    /* 0x8033 */ CsrWifiSmeSmeStaConfigGetCfmHandler,
-    /* 0x8034 */ CsrWifiSmeSmeStaConfigSetCfmHandler,
-    /* 0x8035 */ CsrWifiSmeStationMacAddressGetCfmHandler,
-    /* 0x8036 */ CsrWifiSmeTspecIndHandler,
-    /* 0x8037 */ CsrWifiSmeTspecCfmHandler,
-    /* 0x8038 */ CsrWifiSmeVersionsGetCfmHandler,
-    /* 0x8039 */ CsrWifiSmeWifiFlightmodeCfmHandler,
-    /* 0x803A */ CsrWifiSmeWifiOffIndHandler,
-    /* 0x803B */ CsrWifiSmeWifiOffCfmHandler,
-    /* 0x803C */ CsrWifiSmeWifiOnCfmHandler,
-    /* 0x803D */ CsrWifiSmeCloakedSsidsSetCfmHandler,
-    /* 0x803E */ CsrWifiSmeCloakedSsidsGetCfmHandler,
-    /* 0x803F */ CsrWifiSmeWifiOnIndHandler,
-    /* 0x8040 */ CsrWifiSmeSmeCommonConfigGetCfmHandler,
-    /* 0x8041 */ CsrWifiSmeSmeCommonConfigSetCfmHandler,
-    /* 0x8042 */ CsrWifiSmeGetInterfaceCapabilityCfmHandler,
-    /* 0x8043 */ CsrWifiSmeErrorIndHandler,
-    /* 0x8044 */ CsrWifiSmeInfoIndHandler,
-    /* 0x8045 */ CsrWifiSmeCoreDumpIndHandler,
-    /* 0x8046 */ CsrWifiSmeAmpStatusChangeIndHandler,
-};
diff --git a/drivers/staging/csr/csr_wifi_sme_sef.h b/drivers/staging/csr/csr_wifi_sme_sef.h
deleted file mode 100644 (file)
index 78b88c0..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2010
-       Confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__
-#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__
-
-#include "csr_wifi_sme_prim.h"
-
-typedef void (*CsrWifiSmeStateHandlerType)(void *drvpriv, CsrWifiFsmEvent *msg);
-
-extern const CsrWifiSmeStateHandlerType
-       CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT];
-
-
-extern void CsrWifiSmeActivateCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeAdhocConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeAdhocConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeAssociationCompleteIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeAssociationStartIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeBlacklistCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCalibrationDataGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCalibrationDataSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCcxConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCcxConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCoexConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCoexConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCoexInfoGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeConnectCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeConnectionConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeConnectionInfoGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeConnectionQualityIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeConnectionStatsGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeDeactivateCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeDisconnectCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeEventMaskSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeHostConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeHostConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeIbssStationIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeKeyCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeLinkQualityGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMediaStatusIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMibConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMibConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMibGetCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMibGetNextCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMibSetCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMicFailureIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeMulticastAddressCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmePacketFilterSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmePermanentMacAddressGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmePmkidCandidateListIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmePmkidCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmePowerConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmePowerConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeRoamCompleteIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeRoamStartIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeRoamingConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeRoamingConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeScanConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeScanConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeScanFullCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeScanResultIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeScanResultsFlushCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeScanResultsGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeSmeStaConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeSmeStaConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeStationMacAddressGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeTspecIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeTspecCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeVersionsGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeWifiFlightmodeCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeWifiOffIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeWifiOffCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeWifiOnCfmHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCloakedSsidsSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCloakedSsidsGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeWifiOnIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeSmeCommonConfigGetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeSmeCommonConfigSetCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeErrorIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeInfoIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeCoreDumpIndHandler(void *drvpriv, CsrWifiFsmEvent *msg);
-extern void CsrWifiSmeAmpStatusChangeIndHandler(void *drvpriv,
-       CsrWifiFsmEvent *msg);
-
-#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.c b/drivers/staging/csr/csr_wifi_sme_serialize.c
deleted file mode 100644 (file)
index 7d7e1d8..0000000
+++ /dev/null
@@ -1,5809 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2012
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "csr_msgconv.h"
-#include "csr_wifi_sme_prim.h"
-#include "csr_wifi_sme_serialize.h"
-
-void CsrWifiSmePfree(void *ptr)
-{
-    kfree(ptr);
-}
-
-
-size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */
-    bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */
-    bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */
-    bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeAdhocConfigSetReq *primitive = (CsrWifiSmeAdhocConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeAdhocConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeBlacklistReqSizeof(void *msg)
-{
-    CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->setAddressCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->setAddressCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeBlacklistReq *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->setAddressCount, buffer, &offset);
-    primitive->setAddresses = NULL;
-    if (primitive->setAddressCount)
-    {
-        primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressCount; i1++)
-        {
-            CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeBlacklistReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) voidPrimitivePointer;
-    kfree(primitive->setAddresses);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg)
-{
-    CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
-    bufferSize += 2;                                /* u16 primitive->calibrationDataLength */
-    bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength);
-    if (primitive->calibrationDataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCalibrationDataSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset);
-    if (primitive->calibrationDataLength)
-    {
-        primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength)));
-    }
-    else
-    {
-        primitive->calibrationData = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeCalibrationDataSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) voidPrimitivePointer;
-    kfree(primitive->calibrationData);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */
-    bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */
-    bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */
-    bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCcxConfigSetReq *primitive = (CsrWifiSmeCcxConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCcxConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */
-    bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */
-    bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCoexConfigSetReq *primitive = (CsrWifiSmeCoexConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCoexConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeConnectReqSizeof(void *msg)
-{
-    CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 57) */
-    bufferSize += 2;                                                                     /* u16 primitive->interfaceTag */
-    bufferSize += 32;                                                                    /* u8 primitive->connectionConfig.ssid.ssid[32] */
-    bufferSize += 1;                                                                     /* u8 primitive->connectionConfig.ssid.length */
-    bufferSize += 6;                                                                     /* u8 primitive->connectionConfig.bssid.a[6] */
-    bufferSize += 1;                                                                     /* CsrWifiSmeBssType primitive->connectionConfig.bssType */
-    bufferSize += 1;                                                                     /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */
-    bufferSize += 1;                                                                     /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */
-    bufferSize += 2;                                                                     /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */
-    bufferSize += 2;                                                                     /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */
-    bufferSize += 2;                                                                     /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */
-    bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */
-    bufferSize += 1;                                                                     /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */
-    bufferSize += 1;                                                                     /* u8 primitive->connectionConfig.adhocJoinOnly */
-    bufferSize += 1;                                                                     /* u8 primitive->connectionConfig.adhocChannel */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength);
-    if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeConnectReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeConnectReq *primitive = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset);
-    if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
-    {
-        primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
-    }
-    else
-    {
-        primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL;
-    }
-    CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeConnectReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) voidPrimitivePointer;
-    kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */
-    bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeHostConfigSetReq *primitive = (CsrWifiSmeHostConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeHostConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeKeyReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* CsrWifiSmeKeyType primitive->key.keyType */
-    bufferSize += 1; /* u8 primitive->key.keyIndex */
-    bufferSize += 1; /* u8 primitive->key.wepTxKey */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 8; i2++)
-        {
-            bufferSize += 2; /* u16 primitive->key.keyRsc[8] */
-        }
-    }
-    bufferSize += 1;         /* u8 primitive->key.authenticator */
-    bufferSize += 6;         /* u8 primitive->key.address.a[6] */
-    bufferSize += 1;         /* u8 primitive->key.keyLength */
-    bufferSize += 32;        /* u8 primitive->key.key[32] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeKeyReq *primitive = (CsrWifiSmeKeyReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->key.keyType);
-    CsrUint8Ser(ptr, len, (u8) primitive->key.keyIndex);
-    CsrUint8Ser(ptr, len, (u8) primitive->key.wepTxKey);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 8; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->key.keyRsc[i2]);
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->key.authenticator);
-    CsrMemCpySer(ptr, len, (const void *) primitive->key.address.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->key.keyLength);
-    CsrMemCpySer(ptr, len, (const void *) primitive->key.key, ((u16) (32)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmeKeyReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeKeyReq *primitive = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->key.keyType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->key.keyIndex, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->key.wepTxKey, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 8; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->key.keyRsc[i2], buffer, &offset);
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->key.authenticator, buffer, &offset);
-    CsrMemCpyDes(primitive->key.address.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->key.keyLength, buffer, &offset);
-    CsrMemCpyDes(primitive->key.key, buffer, &offset, ((u16) (32)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */
-    bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */
-    bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */
-    bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */
-    bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibConfigSetReq *primitive = (CsrWifiSmeMibConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate);
-    CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeMibGetNextReqSizeof(void *msg)
-{
-    CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
-    bufferSize += 2;                             /* u16 primitive->mibAttributeLength */
-    bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
-    if (primitive->mibAttributeLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibGetNextReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
-    if (primitive->mibAttributeLength)
-    {
-        primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
-    }
-    else
-    {
-        primitive->mibAttribute = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMibGetNextReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) voidPrimitivePointer;
-    kfree(primitive->mibAttribute);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeMibGetReqSizeof(void *msg)
-{
-    CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
-    bufferSize += 2;                             /* u16 primitive->mibAttributeLength */
-    bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
-    if (primitive->mibAttributeLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibGetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibGetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
-    if (primitive->mibAttributeLength)
-    {
-        primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
-    }
-    else
-    {
-        primitive->mibAttribute = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMibGetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) voidPrimitivePointer;
-    kfree(primitive->mibAttribute);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeMibSetReqSizeof(void *msg)
-{
-    CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
-    bufferSize += 2;                             /* u16 primitive->mibAttributeLength */
-    bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
-    if (primitive->mibAttributeLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
-    if (primitive->mibAttributeLength)
-    {
-        primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
-    }
-    else
-    {
-        primitive->mibAttribute = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMibSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) voidPrimitivePointer;
-    kfree(primitive->mibAttribute);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg)
-{
-    CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->setAddressesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMulticastAddressReq *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset);
-    primitive->setAddresses = NULL;
-    if (primitive->setAddressesCount)
-    {
-        primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
-        {
-            CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMulticastAddressReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) voidPrimitivePointer;
-    kfree(primitive->setAddresses);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg)
-{
-    CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2;                       /* u16 primitive->interfaceTag */
-    bufferSize += 2;                       /* u16 primitive->filterLength */
-    bufferSize += primitive->filterLength; /* u8 primitive->filter */
-    bufferSize += 1;                       /* CsrWifiSmePacketFilterMode primitive->mode */
-    bufferSize += 4;                       /* u8 primitive->arpFilterAddress.a[4] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->filterLength);
-    if (primitive->filterLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->filter, ((u16) (primitive->filterLength)));
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->mode);
-    CsrMemCpySer(ptr, len, (const void *) primitive->arpFilterAddress.a, ((u16) (4)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePacketFilterSetReq *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->filterLength, buffer, &offset);
-    if (primitive->filterLength)
-    {
-        primitive->filter = kmalloc(primitive->filterLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->filter, buffer, &offset, ((u16) (primitive->filterLength)));
-    }
-    else
-    {
-        primitive->filter = NULL;
-    }
-    CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
-    CsrMemCpyDes(primitive->arpFilterAddress.a, buffer, &offset, ((u16) (4)));
-
-    return primitive;
-}
-
-
-void CsrWifiSmePacketFilterSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) voidPrimitivePointer;
-    kfree(primitive->filter);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmePmkidReqSizeof(void *msg)
-{
-    CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->setPmkidsCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
-        {
-            bufferSize += 6;  /* u8 primitive->setPmkids[i1].bssid.a[6] */
-            bufferSize += 16; /* u8 primitive->setPmkids[i1].pmkid[16] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->setPmkidsCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].bssid.a, ((u16) (6)));
-            CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].pmkid, ((u16) (16)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmePmkidReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePmkidReq *primitive = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->setPmkidsCount, buffer, &offset);
-    primitive->setPmkids = NULL;
-    if (primitive->setPmkidsCount)
-    {
-        primitive->setPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->setPmkidsCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
-        {
-            CsrMemCpyDes(primitive->setPmkids[i1].bssid.a, buffer, &offset, ((u16) (6)));
-            CsrMemCpyDes(primitive->setPmkids[i1].pmkid, buffer, &offset, ((u16) (16)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmePmkidReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) voidPrimitivePointer;
-    kfree(primitive->setPmkids);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */
-    bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */
-    bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */
-    bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */
-    bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */
-    bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */
-    bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePowerConfigSetReq *primitive = (CsrWifiSmePowerConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel);
-    CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence);
-    return(ptr);
-}
-
-
-void* CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePowerConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 70) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */
-        }
-    }
-    bufferSize += 1;         /* u8 primitive->roamingConfig.disableSmoothRoaming */
-    bufferSize += 1;         /* u8 primitive->roamingConfig.disableRoamScans */
-    bufferSize += 1;         /* u8 primitive->roamingConfig.reconnectLimit */
-    bufferSize += 2;         /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeRoamingConfigSetReq *primitive = (CsrWifiSmeRoamingConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold);
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming);
-    CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans);
-    CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit);
-    CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu);
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeRoamingConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset);
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
-        }
-    }
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg)
-{
-    CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 63) */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */
-        }
-    }
-    bufferSize += 1;                                             /* u8 primitive->scanConfig.disableAutonomousScans */
-    bufferSize += 2;                                             /* u16 primitive->scanConfig.maxResults */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.highRssiThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.lowRssiThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.deltaRssiThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.highSnrThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.lowSnrThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.deltaSnrThreshold */
-    bufferSize += 2;                                             /* u16 primitive->scanConfig.passiveChannelListCount */
-    bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu);
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans);
-    CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold);
-    CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount);
-    if (primitive->scanConfig.passiveChannelListCount)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeScanConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset);
-    if (primitive->scanConfig.passiveChannelListCount)
-    {
-        primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL);
-        CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount)));
-    }
-    else
-    {
-        primitive->scanConfig.passiveChannelList = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeScanConfigSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) voidPrimitivePointer;
-    kfree(primitive->scanConfig.passiveChannelList);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeScanFullReqSizeof(void *msg)
-{
-    CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 52) */
-    bufferSize += 1; /* u8 primitive->ssidCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->ssidCount; i1++)
-        {
-            bufferSize += 32;                  /* u8 primitive->ssid[i1].ssid[32] */
-            bufferSize += 1;                   /* u8 primitive->ssid[i1].length */
-        }
-    }
-    bufferSize += 6;                           /* u8 primitive->bssid.a[6] */
-    bufferSize += 1;                           /* u8 primitive->forceScan */
-    bufferSize += 1;                           /* CsrWifiSmeBssType primitive->bssType */
-    bufferSize += 1;                           /* CsrWifiSmeScanType primitive->scanType */
-    bufferSize += 2;                           /* u16 primitive->channelListCount */
-    bufferSize += primitive->channelListCount; /* u8 primitive->channelList */
-    bufferSize += 2;                           /* u16 primitive->probeIeLength */
-    bufferSize += primitive->probeIeLength;    /* u8 primitive->probeIe */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->ssidCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->ssidCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->ssid[i1].ssid, ((u16) (32)));
-            CsrUint8Ser(ptr, len, (u8) primitive->ssid[i1].length);
-        }
-    }
-    CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->forceScan);
-    CsrUint8Ser(ptr, len, (u8) primitive->bssType);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanType);
-    CsrUint16Ser(ptr, len, (u16) primitive->channelListCount);
-    if (primitive->channelListCount)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->channelList, ((u16) (primitive->channelListCount)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->probeIeLength);
-    if (primitive->probeIeLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->probeIe, ((u16) (primitive->probeIeLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeScanFullReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeScanFullReq *primitive = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ssidCount, buffer, &offset);
-    primitive->ssid = NULL;
-    if (primitive->ssidCount)
-    {
-        primitive->ssid = kmalloc(sizeof(CsrWifiSsid) * primitive->ssidCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->ssidCount; i1++)
-        {
-            CsrMemCpyDes(primitive->ssid[i1].ssid, buffer, &offset, ((u16) (32)));
-            CsrUint8Des((u8 *) &primitive->ssid[i1].length, buffer, &offset);
-        }
-    }
-    CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->forceScan, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->bssType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->channelListCount, buffer, &offset);
-    if (primitive->channelListCount)
-    {
-        primitive->channelList = kmalloc(primitive->channelListCount, GFP_KERNEL);
-        CsrMemCpyDes(primitive->channelList, buffer, &offset, ((u16) (primitive->channelListCount)));
-    }
-    else
-    {
-        primitive->channelList = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->probeIeLength, buffer, &offset);
-    if (primitive->probeIeLength)
-    {
-        primitive->probeIe = kmalloc(primitive->probeIeLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->probeIe, buffer, &offset, ((u16) (primitive->probeIeLength)));
-    }
-    else
-    {
-        primitive->probeIe = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeScanFullReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) voidPrimitivePointer;
-    kfree(primitive->ssid);
-    kfree(primitive->channelList);
-    kfree(primitive->probeIe);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */
-    bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */
-    bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */
-    bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */
-    bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */
-    bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeSmeStaConfigSetReq *primitive = (CsrWifiSmeSmeStaConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeSmeStaConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeTspecReqSizeof(void *msg)
-{
-    CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 1;                      /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 4;                      /* u32 primitive->transactionId */
-    bufferSize += 1;                      /* u8 primitive->strict */
-    bufferSize += 1;                      /* CsrWifiSmeTspecCtrlMask primitive->ctrlMask */
-    bufferSize += 2;                      /* u16 primitive->tspecLength */
-    bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
-    bufferSize += 2;                      /* u16 primitive->tclasLength */
-    bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
-    CsrUint8Ser(ptr, len, (u8) primitive->strict);
-    CsrUint8Ser(ptr, len, (u8) primitive->ctrlMask);
-    CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
-    if (primitive->tspecLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
-    if (primitive->tclasLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeTspecReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeTspecReq *primitive = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->strict, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ctrlMask, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
-    if (primitive->tspecLength)
-    {
-        primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
-    }
-    else
-    {
-        primitive->tspec = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
-    if (primitive->tclasLength)
-    {
-        primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
-    }
-    else
-    {
-        primitive->tclas = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeTspecReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) voidPrimitivePointer;
-    kfree(primitive->tspec);
-    kfree(primitive->tclas);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg)
-{
-    CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
-    bufferSize += 6; /* u8 primitive->address.a[6] */
-    bufferSize += 2; /* u16 primitive->mibFilesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            bufferSize += 2;                              /* u16 primitive->mibFiles[i1].length */
-            bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length);
-            if (primitive->mibFiles[i1].length)
-            {
-                CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length)));
-            }
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeWifiFlightmodeReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset);
-    primitive->mibFiles = NULL;
-    if (primitive->mibFilesCount)
-    {
-        primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset);
-            if (primitive->mibFiles[i1].length)
-            {
-                primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL);
-                CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length)));
-            }
-            else
-            {
-                primitive->mibFiles[i1].data = NULL;
-            }
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeWifiFlightmodeReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) voidPrimitivePointer;
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            kfree(primitive->mibFiles[i1].data);
-        }
-    }
-    kfree(primitive->mibFiles);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeWifiOnReqSizeof(void *msg)
-{
-    CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
-    bufferSize += 6; /* u8 primitive->address.a[6] */
-    bufferSize += 2; /* u16 primitive->mibFilesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            bufferSize += 2;                              /* u16 primitive->mibFiles[i1].length */
-            bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length);
-            if (primitive->mibFiles[i1].length)
-            {
-                CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length)));
-            }
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeWifiOnReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset);
-    primitive->mibFiles = NULL;
-    if (primitive->mibFilesCount)
-    {
-        primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset);
-            if (primitive->mibFiles[i1].length)
-            {
-                primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL);
-                CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length)));
-            }
-            else
-            {
-                primitive->mibFiles[i1].data = NULL;
-            }
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeWifiOnReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) voidPrimitivePointer;
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
-        {
-            kfree(primitive->mibFiles[i1].data);
-        }
-    }
-    kfree(primitive->mibFiles);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg)
-{
-    CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 37) */
-    bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
-        {
-            bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */
-            bufferSize += 1;  /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32)));
-            CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length);
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCloakedSsidsSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset);
-    primitive->cloakedSsids.cloakedSsids = NULL;
-    if (primitive->cloakedSsids.cloakedSsidsCount)
-    {
-        primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL);
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
-        {
-            CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32)));
-            CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset);
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeCloakedSsidsSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) voidPrimitivePointer;
-    kfree(primitive->cloakedSsids.cloakedSsids);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */
-    bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */
-    bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */
-    bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeSmeCommonConfigSetReq *primitive = (CsrWifiSmeSmeCommonConfigSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel);
-    CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2)));
-    CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface);
-    CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeSmeCommonConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset);
-    CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2)));
-    CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg)
-{
-    CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 240) */
-    bufferSize += 1;  /* u8 primitive->wpsConfig.wpsVersion */
-    bufferSize += 16; /* u8 primitive->wpsConfig.uuid[16] */
-    bufferSize += 32; /* u8 primitive->wpsConfig.deviceName[32] */
-    bufferSize += 1;  /* u8 primitive->wpsConfig.deviceNameLength */
-    bufferSize += 64; /* u8 primitive->wpsConfig.manufacturer[64] */
-    bufferSize += 1;  /* u8 primitive->wpsConfig.manufacturerLength */
-    bufferSize += 32; /* u8 primitive->wpsConfig.modelName[32] */
-    bufferSize += 1;  /* u8 primitive->wpsConfig.modelNameLength */
-    bufferSize += 32; /* u8 primitive->wpsConfig.modelNumber[32] */
-    bufferSize += 1;  /* u8 primitive->wpsConfig.modelNumberLength */
-    bufferSize += 32; /* u8 primitive->wpsConfig.serialNumber[32] */
-    bufferSize += 8;  /* u8 primitive->wpsConfig.primDeviceType.deviceDetails[8] */
-    bufferSize += 1;  /* u8 primitive->wpsConfig.secondaryDeviceTypeCount */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
-        {
-            bufferSize += 8; /* u8 primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails[8] */
-        }
-    }
-    bufferSize += 2;         /* CsrWifiSmeWpsConfigTypeMask primitive->wpsConfig.configMethods */
-    bufferSize += 1;         /* u8 primitive->wpsConfig.rfBands */
-    bufferSize += 4;         /* u8 primitive->wpsConfig.osVersion[4] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.wpsVersion);
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.uuid, ((u16) (16)));
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.deviceName, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.deviceNameLength);
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.manufacturer, ((u16) (64)));
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.manufacturerLength);
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelName, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNameLength);
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelNumber, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNumberLength);
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.serialNumber, ((u16) (32)));
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.primDeviceType.deviceDetails, ((u16) (8)));
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.secondaryDeviceTypeCount);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, ((u16) (8)));
-        }
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->wpsConfig.configMethods);
-    CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.rfBands);
-    CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.osVersion, ((u16) (4)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeWpsConfigurationReq *primitive = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->wpsConfig.wpsVersion, buffer, &offset);
-    CsrMemCpyDes(primitive->wpsConfig.uuid, buffer, &offset, ((u16) (16)));
-    CsrMemCpyDes(primitive->wpsConfig.deviceName, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->wpsConfig.deviceNameLength, buffer, &offset);
-    CsrMemCpyDes(primitive->wpsConfig.manufacturer, buffer, &offset, ((u16) (64)));
-    CsrUint8Des((u8 *) &primitive->wpsConfig.manufacturerLength, buffer, &offset);
-    CsrMemCpyDes(primitive->wpsConfig.modelName, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->wpsConfig.modelNameLength, buffer, &offset);
-    CsrMemCpyDes(primitive->wpsConfig.modelNumber, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->wpsConfig.modelNumberLength, buffer, &offset);
-    CsrMemCpyDes(primitive->wpsConfig.serialNumber, buffer, &offset, ((u16) (32)));
-    CsrMemCpyDes(primitive->wpsConfig.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
-    CsrUint8Des((u8 *) &primitive->wpsConfig.secondaryDeviceTypeCount, buffer, &offset);
-    primitive->wpsConfig.secondaryDeviceType = NULL;
-    if (primitive->wpsConfig.secondaryDeviceTypeCount)
-    {
-        primitive->wpsConfig.secondaryDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->wpsConfig.secondaryDeviceTypeCount, GFP_KERNEL);
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
-        {
-            CsrMemCpyDes(primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, buffer, &offset, ((u16) (8)));
-        }
-    }
-    CsrUint16Des((u16 *) &primitive->wpsConfig.configMethods, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->wpsConfig.rfBands, buffer, &offset);
-    CsrMemCpyDes(primitive->wpsConfig.osVersion, buffer, &offset, ((u16) (4)));
-
-    return primitive;
-}
-
-
-void CsrWifiSmeWpsConfigurationReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) voidPrimitivePointer;
-    kfree(primitive->wpsConfig.secondaryDeviceType);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeSetReqSizeof(void *msg)
-{
-    CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 4;                     /* u32 primitive->dataLength */
-    bufferSize += primitive->dataLength; /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeSetReqDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeSetReqSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) voidPrimitivePointer;
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */
-    bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */
-    bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */
-    bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeAdhocConfigGetCfm *primitive = (CsrWifiSmeAdhocConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts);
-    CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeAdhocConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg)
-{
-    CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 98) */
-    bufferSize += 2;                                                     /* u16 primitive->interfaceTag */
-    bufferSize += 2;                                                     /* CsrResult primitive->status */
-    bufferSize += 32;                                                    /* u8 primitive->connectionInfo.ssid.ssid[32] */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.ssid.length */
-    bufferSize += 6;                                                     /* u8 primitive->connectionInfo.bssid.a[6] */
-    bufferSize += 1;                                                     /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.channelNumber */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.channelFrequency */
-    bufferSize += 2;                                                     /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
-    bufferSize += 2;                                                     /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
-    bufferSize += 2;                                                     /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
-    bufferSize += 1;                                                     /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.atimWindowTu */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.beaconPeriodTu */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.reassociation */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.beaconFrameLength */
-    bufferSize += primitive->connectionInfo.beaconFrameLength;           /* u8 primitive->connectionInfo.beaconFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.associationReqFrameLength */
-    bufferSize += primitive->connectionInfo.associationReqFrameLength;   /* u8 primitive->connectionInfo.associationReqFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.associationRspFrameLength */
-    bufferSize += primitive->connectionInfo.associationRspFrameLength;   /* u8 primitive->connectionInfo.associationRspFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqCapabilities */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
-    bufferSize += 6;                                                     /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocReqInfoElementsLength;  /* u8 primitive->connectionInfo.assocReqInfoElements */
-    bufferSize += 2;                                                     /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspAssociationId */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocRspInfoElementsLength;  /* u8 primitive->connectionInfo.assocRspInfoElements */
-    bufferSize += 2;                                                     /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
-    if (primitive->connectionInfo.beaconFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
-    if (primitive->connectionInfo.associationReqFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
-    if (primitive->connectionInfo.associationRspFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
-    if (primitive->connectionInfo.assocScanInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
-    if (primitive->connectionInfo.assocReqInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
-    if (primitive->connectionInfo.assocRspInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->deauthReason);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeAssociationCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.beaconFrameLength)
-    {
-        primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.beaconFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.associationReqFrameLength)
-    {
-        primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.associationReqFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.associationRspFrameLength)
-    {
-        primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.associationRspFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocScanInfoElementsLength)
-    {
-        primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocScanInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocReqInfoElementsLength)
-    {
-        primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocReqInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocRspInfoElementsLength)
-    {
-        primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocRspInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeAssociationCompleteIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) voidPrimitivePointer;
-    kfree(primitive->connectionInfo.beaconFrame);
-    kfree(primitive->connectionInfo.associationReqFrame);
-    kfree(primitive->connectionInfo.associationRspFrame);
-    kfree(primitive->connectionInfo.assocScanInfoElements);
-    kfree(primitive->connectionInfo.assocReqInfoElements);
-    kfree(primitive->connectionInfo.assocRspInfoElements);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeAssociationStartIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 44) */
-    bufferSize += 2;  /* u16 primitive->interfaceTag */
-    bufferSize += 6;  /* u8 primitive->address.a[6] */
-    bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
-    bufferSize += 1;  /* u8 primitive->ssid.length */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeAssociationStartInd *primitive = (CsrWifiSmeAssociationStartInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
-    CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeAssociationStartInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
-    CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeBlacklistCfmSizeof(void *msg)
-{
-    CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->getAddressCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->getAddressCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeBlacklistCfm *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->getAddressCount, buffer, &offset);
-    primitive->getAddresses = NULL;
-    if (primitive->getAddressCount)
-    {
-        primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressCount; i1++)
-        {
-            CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeBlacklistCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) voidPrimitivePointer;
-    kfree(primitive->getAddresses);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2;                                /* CsrResult primitive->status */
-    bufferSize += 2;                                /* u16 primitive->calibrationDataLength */
-    bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength);
-    if (primitive->calibrationDataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCalibrationDataGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset);
-    if (primitive->calibrationDataLength)
-    {
-        primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength)));
-    }
-    else
-    {
-        primitive->calibrationData = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeCalibrationDataGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) voidPrimitivePointer;
-    kfree(primitive->calibrationData);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */
-    bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */
-    bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */
-    bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCcxConfigGetCfm *primitive = (CsrWifiSmeCcxConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask);
-    CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCcxConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCcxConfigSetCfm *primitive = (CsrWifiSmeCcxConfigSetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCcxConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */
-    bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */
-    bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCoexConfigGetCfm *primitive = (CsrWifiSmeCoexConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCoexConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->coexInfo.hasTrafficData */
-    bufferSize += 1; /* CsrWifiSmeTrafficType primitive->coexInfo.currentTrafficType */
-    bufferSize += 2; /* u16 primitive->coexInfo.currentPeriodMs */
-    bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->coexInfo.currentPowerSave */
-    bufferSize += 2; /* u16 primitive->coexInfo.currentCoexPeriodMs */
-    bufferSize += 2; /* u16 primitive->coexInfo.currentCoexLatencyMs */
-    bufferSize += 1; /* u8 primitive->coexInfo.hasBtDevice */
-    bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutDurationUs */
-    bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutPeriodUs */
-    bufferSize += 1; /* CsrWifiSmeCoexScheme primitive->coexInfo.currentCoexScheme */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCoexInfoGetCfm *primitive = (CsrWifiSmeCoexInfoGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasTrafficData);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentTrafficType);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentPeriodMs);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentPowerSave);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexPeriodMs);
-    CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexLatencyMs);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasBtDevice);
-    CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutDurationUs);
-    CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutPeriodUs);
-    CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentCoexScheme);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCoexInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexInfo.hasTrafficData, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexInfo.currentTrafficType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexInfo.currentPeriodMs, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexInfo.currentPowerSave, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexPeriodMs, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexLatencyMs, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexInfo.hasBtDevice, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutDurationUs, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutPeriodUs, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->coexInfo.currentCoexScheme, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeConnectCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeConnectCfm *primitive = (CsrWifiSmeConnectCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeConnectCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeConnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 59) */
-    bufferSize += 2;                                                                     /* u16 primitive->interfaceTag */
-    bufferSize += 2;                                                                     /* CsrResult primitive->status */
-    bufferSize += 32;                                                                    /* u8 primitive->connectionConfig.ssid.ssid[32] */
-    bufferSize += 1;                                                                     /* u8 primitive->connectionConfig.ssid.length */
-    bufferSize += 6;                                                                     /* u8 primitive->connectionConfig.bssid.a[6] */
-    bufferSize += 1;                                                                     /* CsrWifiSmeBssType primitive->connectionConfig.bssType */
-    bufferSize += 1;                                                                     /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */
-    bufferSize += 1;                                                                     /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */
-    bufferSize += 2;                                                                     /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */
-    bufferSize += 2;                                                                     /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */
-    bufferSize += 2;                                                                     /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */
-    bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */
-    bufferSize += 1;                                                                     /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */
-    bufferSize += 1;                                                                     /* u8 primitive->connectionConfig.adhocJoinOnly */
-    bufferSize += 1;                                                                     /* u8 primitive->connectionConfig.adhocChannel */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength);
-    if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeConnectionConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset);
-    if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
-    {
-        primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
-    }
-    else
-    {
-        primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL;
-    }
-    CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeConnectionConfigGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) voidPrimitivePointer;
-    kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 96) */
-    bufferSize += 2;                                                     /* u16 primitive->interfaceTag */
-    bufferSize += 2;                                                     /* CsrResult primitive->status */
-    bufferSize += 32;                                                    /* u8 primitive->connectionInfo.ssid.ssid[32] */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.ssid.length */
-    bufferSize += 6;                                                     /* u8 primitive->connectionInfo.bssid.a[6] */
-    bufferSize += 1;                                                     /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.channelNumber */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.channelFrequency */
-    bufferSize += 2;                                                     /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
-    bufferSize += 2;                                                     /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
-    bufferSize += 2;                                                     /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
-    bufferSize += 1;                                                     /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.atimWindowTu */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.beaconPeriodTu */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.reassociation */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.beaconFrameLength */
-    bufferSize += primitive->connectionInfo.beaconFrameLength;           /* u8 primitive->connectionInfo.beaconFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.associationReqFrameLength */
-    bufferSize += primitive->connectionInfo.associationReqFrameLength;   /* u8 primitive->connectionInfo.associationReqFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.associationRspFrameLength */
-    bufferSize += primitive->connectionInfo.associationRspFrameLength;   /* u8 primitive->connectionInfo.associationRspFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqCapabilities */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
-    bufferSize += 6;                                                     /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocReqInfoElementsLength;  /* u8 primitive->connectionInfo.assocReqInfoElements */
-    bufferSize += 2;                                                     /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspAssociationId */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocRspInfoElementsLength;  /* u8 primitive->connectionInfo.assocRspInfoElements */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
-    if (primitive->connectionInfo.beaconFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
-    if (primitive->connectionInfo.associationReqFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
-    if (primitive->connectionInfo.associationRspFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
-    if (primitive->connectionInfo.assocScanInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
-    if (primitive->connectionInfo.assocReqInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
-    if (primitive->connectionInfo.assocRspInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeConnectionInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.beaconFrameLength)
-    {
-        primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.beaconFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.associationReqFrameLength)
-    {
-        primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.associationReqFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.associationRspFrameLength)
-    {
-        primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.associationRspFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocScanInfoElementsLength)
-    {
-        primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocScanInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocReqInfoElementsLength)
-    {
-        primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocReqInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocRspInfoElementsLength)
-    {
-        primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocRspInfoElements = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeConnectionInfoGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) voidPrimitivePointer;
-    kfree(primitive->connectionInfo.beaconFrame);
-    kfree(primitive->connectionInfo.associationReqFrame);
-    kfree(primitive->connectionInfo.associationRspFrame);
-    kfree(primitive->connectionInfo.assocScanInfoElements);
-    kfree(primitive->connectionInfo.assocReqInfoElements);
-    kfree(primitive->connectionInfo.assocRspInfoElements);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */
-    bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeConnectionQualityInd *primitive = (CsrWifiSmeConnectionQualityInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi);
-    CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeConnectionQualityInd *primitive = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 101) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->connectionStats.unifiTxDataRate */
-    bufferSize += 1; /* u8 primitive->connectionStats.unifiRxDataRate */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RetryCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11MultipleRetryCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11AckFailureCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11FrameDuplicateCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11FcsErrorCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsSuccessCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsFailureCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11FailedCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFragmentCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFrameCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11WepExcludedCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11WepIcvErrorCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11WepUndecryptableCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastReceivedFrameCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastTransmittedFrameCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11ReceivedFragmentCount */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11Rsna4WayHandshakeFailures */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipReplays */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipIcvErrors */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpReplays */
-    bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeConnectionStatsGetCfm *primitive = (CsrWifiSmeConnectionStatsGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiTxDataRate);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiRxDataRate);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RetryCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MultipleRetryCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11AckFailureCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FrameDuplicateCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FcsErrorCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsSuccessCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsFailureCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FailedCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFragmentCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFrameCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepExcludedCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepIcvErrorCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepUndecryptableCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastReceivedFrameCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastTransmittedFrameCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11ReceivedFragmentCount);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11Rsna4WayHandshakeFailures);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipReplays);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipIcvErrors);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpReplays);
-    CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeConnectionStatsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionStats.unifiTxDataRate, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionStats.unifiRxDataRate, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RetryCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11MultipleRetryCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11AckFailureCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11FrameDuplicateCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11FcsErrorCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsSuccessCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsFailureCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11FailedCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFragmentCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFrameCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepExcludedCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepIcvErrorCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepUndecryptableCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastReceivedFrameCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastTransmittedFrameCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11ReceivedFragmentCount, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11Rsna4WayHandshakeFailures, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipReplays, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipIcvErrors, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpReplays, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeDisconnectCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeDisconnectCfm *primitive = (CsrWifiSmeDisconnectCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeDisconnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */
-    bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeHostConfigGetCfm *primitive = (CsrWifiSmeHostConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeHostConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeHostConfigSetCfm *primitive = (CsrWifiSmeHostConfigSetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeHostConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeIbssStationIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 6; /* u8 primitive->address.a[6] */
-    bufferSize += 1; /* u8 primitive->isconnected */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeIbssStationInd *primitive = (CsrWifiSmeIbssStationInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->isconnected);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeIbssStationInd *primitive = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->isconnected, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeKeyCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */
-    bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeKeyCfm *primitive = (CsrWifiSmeKeyCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->keyType);
-    CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmeKeyCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeKeyCfm *primitive = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset);
-    CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */
-    bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeLinkQualityGetCfm *primitive = (CsrWifiSmeLinkQualityGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi);
-    CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeLinkQualityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeMediaStatusIndSizeof(void *msg)
-{
-    CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 99) */
-    bufferSize += 2;                                                     /* u16 primitive->interfaceTag */
-    bufferSize += 1;                                                     /* CsrWifiSmeMediaStatus primitive->mediaStatus */
-    bufferSize += 32;                                                    /* u8 primitive->connectionInfo.ssid.ssid[32] */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.ssid.length */
-    bufferSize += 6;                                                     /* u8 primitive->connectionInfo.bssid.a[6] */
-    bufferSize += 1;                                                     /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.channelNumber */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.channelFrequency */
-    bufferSize += 2;                                                     /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
-    bufferSize += 2;                                                     /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
-    bufferSize += 2;                                                     /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
-    bufferSize += 1;                                                     /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.atimWindowTu */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.beaconPeriodTu */
-    bufferSize += 1;                                                     /* u8 primitive->connectionInfo.reassociation */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.beaconFrameLength */
-    bufferSize += primitive->connectionInfo.beaconFrameLength;           /* u8 primitive->connectionInfo.beaconFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.associationReqFrameLength */
-    bufferSize += primitive->connectionInfo.associationReqFrameLength;   /* u8 primitive->connectionInfo.associationReqFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.associationRspFrameLength */
-    bufferSize += primitive->connectionInfo.associationRspFrameLength;   /* u8 primitive->connectionInfo.associationRspFrame */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqCapabilities */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
-    bufferSize += 6;                                                     /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocReqInfoElementsLength;  /* u8 primitive->connectionInfo.assocReqInfoElements */
-    bufferSize += 2;                                                     /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspAssociationId */
-    bufferSize += 2;                                                     /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
-    bufferSize += primitive->connectionInfo.assocRspInfoElementsLength;  /* u8 primitive->connectionInfo.assocRspInfoElements */
-    bufferSize += 2;                                                     /* CsrWifiSmeIEEE80211Reason primitive->disassocReason */
-    bufferSize += 2;                                                     /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
-    CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
-    if (primitive->connectionInfo.beaconFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
-    if (primitive->connectionInfo.associationReqFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
-    if (primitive->connectionInfo.associationRspFrameLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
-    if (primitive->connectionInfo.assocScanInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
-    CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
-    if (primitive->connectionInfo.assocReqInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
-    CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
-    if (primitive->connectionInfo.assocRspInfoElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
-    }
-    CsrUint16Ser(ptr, len, (u16) primitive->disassocReason);
-    CsrUint16Ser(ptr, len, (u16) primitive->deauthReason);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMediaStatusInd *primitive = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.beaconFrameLength)
-    {
-        primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.beaconFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.associationReqFrameLength)
-    {
-        primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.associationReqFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
-    if (primitive->connectionInfo.associationRspFrameLength)
-    {
-        primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.associationRspFrame = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocScanInfoElementsLength)
-    {
-        primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocScanInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
-    CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocReqInfoElementsLength)
-    {
-        primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocReqInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
-    if (primitive->connectionInfo.assocRspInfoElementsLength)
-    {
-        primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
-    }
-    else
-    {
-        primitive->connectionInfo.assocRspInfoElements = NULL;
-    }
-    CsrUint16Des((u16 *) &primitive->disassocReason, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMediaStatusIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) voidPrimitivePointer;
-    kfree(primitive->connectionInfo.beaconFrame);
-    kfree(primitive->connectionInfo.associationReqFrame);
-    kfree(primitive->connectionInfo.associationRspFrame);
-    kfree(primitive->connectionInfo.assocScanInfoElements);
-    kfree(primitive->connectionInfo.assocReqInfoElements);
-    kfree(primitive->connectionInfo.assocRspInfoElements);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */
-    bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */
-    bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */
-    bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */
-    bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibConfigGetCfm *primitive = (CsrWifiSmeMibConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate);
-    CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeMibGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2;                             /* CsrResult primitive->status */
-    bufferSize += 2;                             /* u16 primitive->mibAttributeLength */
-    bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
-    if (primitive->mibAttributeLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
-    if (primitive->mibAttributeLength)
-    {
-        primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
-    }
-    else
-    {
-        primitive->mibAttribute = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMibGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) voidPrimitivePointer;
-    kfree(primitive->mibAttribute);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg)
-{
-    CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2;                             /* CsrResult primitive->status */
-    bufferSize += 2;                             /* u16 primitive->mibAttributeLength */
-    bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
-    if (primitive->mibAttributeLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMibGetNextCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
-    if (primitive->mibAttributeLength)
-    {
-        primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
-    }
-    else
-    {
-        primitive->mibAttribute = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMibGetNextCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) voidPrimitivePointer;
-    kfree(primitive->mibAttribute);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeMicFailureIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* u8 primitive->secondFailure */
-    bufferSize += 2; /* u16 primitive->count */
-    bufferSize += 6; /* u8 primitive->address.a[6] */
-    bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMicFailureInd *primitive = (CsrWifiSmeMicFailureInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->secondFailure);
-    CsrUint16Ser(ptr, len, (u16) primitive->count);
-    CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
-    CsrUint8Ser(ptr, len, (u8) primitive->keyType);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMicFailureInd *primitive = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->secondFailure, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->count, buffer, &offset);
-    CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
-    CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg)
-{
-    CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->getAddressesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeMulticastAddressCfm *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset);
-    primitive->getAddresses = NULL;
-    if (primitive->getAddressesCount)
-    {
-        primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
-        {
-            CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeMulticastAddressCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) voidPrimitivePointer;
-    kfree(primitive->getAddresses);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePacketFilterSetCfm *primitive = (CsrWifiSmePacketFilterSetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePacketFilterSetCfm *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 6; /* u8 primitive->permanentMacAddress.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePermanentMacAddressGetCfm *primitive = (CsrWifiSmePermanentMacAddressGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrMemCpySer(ptr, len, (const void *) primitive->permanentMacAddress.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePermanentMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrMemCpyDes(primitive->permanentMacAddress.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg)
-{
-    CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* u8 primitive->pmkidCandidatesCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->pmkidCandidates[i1].bssid.a[6] */
-            bufferSize += 1; /* u8 primitive->pmkidCandidates[i1].preAuthAllowed */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidatesCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->pmkidCandidates[i1].bssid.a, ((u16) (6)));
-            CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidates[i1].preAuthAllowed);
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePmkidCandidateListInd *primitive = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->pmkidCandidatesCount, buffer, &offset);
-    primitive->pmkidCandidates = NULL;
-    if (primitive->pmkidCandidatesCount)
-    {
-        primitive->pmkidCandidates = kmalloc(sizeof(CsrWifiSmePmkidCandidate) * primitive->pmkidCandidatesCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
-        {
-            CsrMemCpyDes(primitive->pmkidCandidates[i1].bssid.a, buffer, &offset, ((u16) (6)));
-            CsrUint8Des((u8 *) &primitive->pmkidCandidates[i1].preAuthAllowed, buffer, &offset);
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmePmkidCandidateListIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) voidPrimitivePointer;
-    kfree(primitive->pmkidCandidates);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmePmkidCfmSizeof(void *msg)
-{
-    CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
-    bufferSize += 1; /* u8 primitive->getPmkidsCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
-        {
-            bufferSize += 6;  /* u8 primitive->getPmkids[i1].bssid.a[6] */
-            bufferSize += 16; /* u8 primitive->getPmkids[i1].pmkid[16] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->action);
-    CsrUint8Ser(ptr, len, (u8) primitive->getPmkidsCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].bssid.a, ((u16) (6)));
-            CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].pmkid, ((u16) (16)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmePmkidCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePmkidCfm *primitive = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->getPmkidsCount, buffer, &offset);
-    primitive->getPmkids = NULL;
-    if (primitive->getPmkidsCount)
-    {
-        primitive->getPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->getPmkidsCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
-        {
-            CsrMemCpyDes(primitive->getPmkids[i1].bssid.a, buffer, &offset, ((u16) (6)));
-            CsrMemCpyDes(primitive->getPmkids[i1].pmkid, buffer, &offset, ((u16) (16)));
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmePmkidCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) voidPrimitivePointer;
-    kfree(primitive->getPmkids);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */
-    bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */
-    bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */
-    bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */
-    bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */
-    bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */
-    bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmePowerConfigGetCfm *primitive = (CsrWifiSmePowerConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel);
-    CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave);
-    CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence);
-    return(ptr);
-}
-
-
-void* CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmePowerConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityImplemented */
-    bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityEnabled */
-    bufferSize += 1; /* CsrWifiSmeRegulatoryDomain primitive->regDomInfo.currentRegulatoryDomain */
-    bufferSize += 2; /* u8 primitive->regDomInfo.currentCountryCode[2] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = (CsrWifiSmeRegulatoryDomainInfoGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityImplemented);
-    CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityEnabled);
-    CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.currentRegulatoryDomain);
-    CsrMemCpySer(ptr, len, (const void *) primitive->regDomInfo.currentCountryCode, ((u16) (2)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityImplemented, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityEnabled, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->regDomInfo.currentRegulatoryDomain, buffer, &offset);
-    CsrMemCpyDes(primitive->regDomInfo.currentCountryCode, buffer, &offset, ((u16) (2)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeRoamCompleteInd *primitive = (CsrWifiSmeRoamCompleteInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeRoamCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeRoamStartIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 1; /* CsrWifiSmeRoamReason primitive->roamReason */
-    bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->reason80211 */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeRoamStartInd *primitive = (CsrWifiSmeRoamStartInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint8Ser(ptr, len, (u8) primitive->roamReason);
-    CsrUint16Ser(ptr, len, (u16) primitive->reason80211);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeRoamStartInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->roamReason, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->reason80211, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 72) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */
-            bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */
-        }
-    }
-    bufferSize += 1;         /* u8 primitive->roamingConfig.disableSmoothRoaming */
-    bufferSize += 1;         /* u8 primitive->roamingConfig.disableRoamScans */
-    bufferSize += 1;         /* u8 primitive->roamingConfig.reconnectLimit */
-    bufferSize += 2;         /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */
-            bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeRoamingConfigGetCfm *primitive = (CsrWifiSmeRoamingConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold);
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming);
-    CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans);
-    CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit);
-    CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu);
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeRoamingConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset);
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 3; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
-        }
-    }
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeRoamingConfigSetCfm *primitive = (CsrWifiSmeRoamingConfigSetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeRoamingConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */
-            bufferSize += 2;                                     /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */
-        }
-    }
-    bufferSize += 1;                                             /* u8 primitive->scanConfig.disableAutonomousScans */
-    bufferSize += 2;                                             /* u16 primitive->scanConfig.maxResults */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.highRssiThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.lowRssiThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.deltaRssiThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.highSnrThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.lowSnrThreshold */
-    bufferSize += 1;                                             /* s8 primitive->scanConfig.deltaSnrThreshold */
-    bufferSize += 2;                                             /* u16 primitive->scanConfig.passiveChannelListCount */
-    bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu);
-        }
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans);
-    CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold);
-    CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold);
-    CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount);
-    if (primitive->scanConfig.passiveChannelListCount)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeScanConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < 4; i2++)
-        {
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
-        }
-    }
-    CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset);
-    if (primitive->scanConfig.passiveChannelListCount)
-    {
-        primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL);
-        CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount)));
-    }
-    else
-    {
-        primitive->scanConfig.passiveChannelList = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeScanConfigGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) voidPrimitivePointer;
-    kfree(primitive->scanConfig.passiveChannelList);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeScanResultIndSizeof(void *msg)
-{
-    CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 149) */
-    bufferSize += 32;                                          /* u8 primitive->result.ssid.ssid[32] */
-    bufferSize += 1;                                           /* u8 primitive->result.ssid.length */
-    bufferSize += 6;                                           /* u8 primitive->result.bssid.a[6] */
-    bufferSize += 2;                                           /* s16 primitive->result.rssi */
-    bufferSize += 2;                                           /* s16 primitive->result.snr */
-    bufferSize += 1;                                           /* CsrWifiSmeRadioIF primitive->result.ifIndex */
-    bufferSize += 2;                                           /* u16 primitive->result.beaconPeriodTu */
-    bufferSize += 8;                                           /* u8 primitive->result.timeStamp.data[8] */
-    bufferSize += 8;                                           /* u8 primitive->result.localTime.data[8] */
-    bufferSize += 2;                                           /* u16 primitive->result.channelFrequency */
-    bufferSize += 2;                                           /* u16 primitive->result.capabilityInformation */
-    bufferSize += 1;                                           /* u8 primitive->result.channelNumber */
-    bufferSize += 1;                                           /* CsrWifiSmeBasicUsability primitive->result.usability */
-    bufferSize += 1;                                           /* CsrWifiSmeBssType primitive->result.bssType */
-    bufferSize += 2;                                           /* u16 primitive->result.informationElementsLength */
-    bufferSize += primitive->result.informationElementsLength; /* u8 primitive->result.informationElements */
-    bufferSize += 1;                                           /* CsrWifiSmeP2pRole primitive->result.p2pDeviceRole */
-    switch (primitive->result.p2pDeviceRole)
-    {
-        case CSR_WIFI_SME_P2P_ROLE_CLI:
-            bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedCli.empty */
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_GO:
-            bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->result.deviceInfo.groupInfo.groupCapability */
-            bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a[6] */
-            bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2pClientInfoCount */
-            {
-                u16 i4;
-                for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                {
-                    bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */
-                    bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */
-                    bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */
-                    bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */
-                    bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */
-                    bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */
-                    {
-                        u16 i6;
-                        for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
-                        {
-                            bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */
-                        }
-                    }
-                    bufferSize += 32;        /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */
-                    bufferSize += 1;         /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */
-                }
-            }
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_NONE:
-            bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedNone.empty */
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-            bufferSize += 6; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a[6] */
-            bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.standalonedevInfo.configMethods */
-            bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap */
-            bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */
-            bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */
-            {
-                u16 i4;
-                for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
-                {
-                    bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */
-                }
-            }
-            bufferSize += 32;        /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceName[32] */
-            bufferSize += 1;         /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceNameLength */
-            break;
-        default:
-            break;
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrMemCpySer(ptr, len, (const void *) primitive->result.ssid.ssid, ((u16) (32)));
-    CsrUint8Ser(ptr, len, (u8) primitive->result.ssid.length);
-    CsrMemCpySer(ptr, len, (const void *) primitive->result.bssid.a, ((u16) (6)));
-    CsrUint16Ser(ptr, len, (u16) primitive->result.rssi);
-    CsrUint16Ser(ptr, len, (u16) primitive->result.snr);
-    CsrUint8Ser(ptr, len, (u8) primitive->result.ifIndex);
-    CsrUint16Ser(ptr, len, (u16) primitive->result.beaconPeriodTu);
-    CsrMemCpySer(ptr, len, (const void *) primitive->result.timeStamp.data, ((u16) (8)));
-    CsrMemCpySer(ptr, len, (const void *) primitive->result.localTime.data, ((u16) (8)));
-    CsrUint16Ser(ptr, len, (u16) primitive->result.channelFrequency);
-    CsrUint16Ser(ptr, len, (u16) primitive->result.capabilityInformation);
-    CsrUint8Ser(ptr, len, (u8) primitive->result.channelNumber);
-    CsrUint8Ser(ptr, len, (u8) primitive->result.usability);
-    CsrUint8Ser(ptr, len, (u8) primitive->result.bssType);
-    CsrUint16Ser(ptr, len, (u16) primitive->result.informationElementsLength);
-    if (primitive->result.informationElementsLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->result.informationElements, ((u16) (primitive->result.informationElementsLength)));
-    }
-    CsrUint8Ser(ptr, len, (u8) primitive->result.p2pDeviceRole);
-    switch (primitive->result.p2pDeviceRole)
-    {
-        case CSR_WIFI_SME_P2P_ROLE_CLI:
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedCli.empty);
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_GO:
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.groupCapability);
-            CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6)));
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2pClientInfoCount);
-            {
-                u16 i4;
-                for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                {
-                    CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6)));
-                    CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6)));
-                    CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods);
-                    CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap);
-                    CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8)));
-                    CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount);
-                    {
-                        u16 i6;
-                        for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
-                        {
-                            CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8)));
-                        }
-                    }
-                    CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32)));
-                    CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength);
-                }
-            }
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_NONE:
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedNone.empty);
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-            CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6)));
-            CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.standalonedevInfo.configMethods);
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap);
-            CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8)));
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount);
-            {
-                u16 i4;
-                for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
-                {
-                    CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8)));
-                }
-            }
-            CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceName, ((u16) (32)));
-            CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.deviceNameLength);
-            break;
-        default:
-            break;
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeScanResultIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeScanResultInd *primitive = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrMemCpyDes(primitive->result.ssid.ssid, buffer, &offset, ((u16) (32)));
-    CsrUint8Des((u8 *) &primitive->result.ssid.length, buffer, &offset);
-    CsrMemCpyDes(primitive->result.bssid.a, buffer, &offset, ((u16) (6)));
-    CsrUint16Des((u16 *) &primitive->result.rssi, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result.snr, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->result.ifIndex, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result.beaconPeriodTu, buffer, &offset);
-    CsrMemCpyDes(primitive->result.timeStamp.data, buffer, &offset, ((u16) (8)));
-    CsrMemCpyDes(primitive->result.localTime.data, buffer, &offset, ((u16) (8)));
-    CsrUint16Des((u16 *) &primitive->result.channelFrequency, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result.capabilityInformation, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->result.channelNumber, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->result.usability, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->result.bssType, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->result.informationElementsLength, buffer, &offset);
-    if (primitive->result.informationElementsLength)
-    {
-        primitive->result.informationElements = kmalloc(primitive->result.informationElementsLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->result.informationElements, buffer, &offset, ((u16) (primitive->result.informationElementsLength)));
-    }
-    else
-    {
-        primitive->result.informationElements = NULL;
-    }
-    CsrUint8Des((u8 *) &primitive->result.p2pDeviceRole, buffer, &offset);
-    switch (primitive->result.p2pDeviceRole)
-    {
-        case CSR_WIFI_SME_P2P_ROLE_CLI:
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedCli.empty, buffer, &offset);
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_GO:
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.groupCapability, buffer, &offset);
-            CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6)));
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset);
-            primitive->result.deviceInfo.groupInfo.p2PClientInfo = NULL;
-            if (primitive->result.deviceInfo.groupInfo.p2pClientInfoCount)
-            {
-                primitive->result.deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL);
-            }
-            {
-                u16 i4;
-                for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                {
-                    CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6)));
-                    CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
-                    CsrUint16Des((u16 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset);
-                    CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset);
-                    CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
-                    CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset);
-                    primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
-                    if (primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount)
-                    {
-                        primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL);
-                    }
-                    {
-                        u16 i6;
-                        for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
-                        {
-                            CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8)));
-                        }
-                    }
-                    CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32)));
-                    CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset);
-                }
-            }
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_NONE:
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedNone.empty, buffer, &offset);
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-            CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
-            CsrUint16Des((u16 *) &primitive->result.deviceInfo.standalonedevInfo.configMethods, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset);
-            CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset);
-            primitive->result.deviceInfo.standalonedevInfo.secDeviceType = NULL;
-            if (primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount)
-            {
-                primitive->result.deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL);
-            }
-            {
-                u16 i4;
-                for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
-                {
-                    CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8)));
-                }
-            }
-            CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32)));
-            CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset);
-            break;
-        default:
-            break;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeScanResultIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) voidPrimitivePointer;
-    kfree(primitive->result.informationElements);
-    switch (primitive->result.p2pDeviceRole)
-    {
-        case CSR_WIFI_SME_P2P_ROLE_GO:
-        {
-            u16 i4;
-            for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-            {
-                kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
-            }
-        }
-            kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo);
-            break;
-        case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-            kfree(primitive->result.deviceInfo.standalonedevInfo.secDeviceType);
-            break;
-        default:
-            break;
-    }
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 153) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 2; /* u16 primitive->scanResultsCount */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
-        {
-            bufferSize += 32;                                                   /* u8 primitive->scanResults[i1].ssid.ssid[32] */
-            bufferSize += 1;                                                    /* u8 primitive->scanResults[i1].ssid.length */
-            bufferSize += 6;                                                    /* u8 primitive->scanResults[i1].bssid.a[6] */
-            bufferSize += 2;                                                    /* s16 primitive->scanResults[i1].rssi */
-            bufferSize += 2;                                                    /* s16 primitive->scanResults[i1].snr */
-            bufferSize += 1;                                                    /* CsrWifiSmeRadioIF primitive->scanResults[i1].ifIndex */
-            bufferSize += 2;                                                    /* u16 primitive->scanResults[i1].beaconPeriodTu */
-            bufferSize += 8;                                                    /* u8 primitive->scanResults[i1].timeStamp.data[8] */
-            bufferSize += 8;                                                    /* u8 primitive->scanResults[i1].localTime.data[8] */
-            bufferSize += 2;                                                    /* u16 primitive->scanResults[i1].channelFrequency */
-            bufferSize += 2;                                                    /* u16 primitive->scanResults[i1].capabilityInformation */
-            bufferSize += 1;                                                    /* u8 primitive->scanResults[i1].channelNumber */
-            bufferSize += 1;                                                    /* CsrWifiSmeBasicUsability primitive->scanResults[i1].usability */
-            bufferSize += 1;                                                    /* CsrWifiSmeBssType primitive->scanResults[i1].bssType */
-            bufferSize += 2;                                                    /* u16 primitive->scanResults[i1].informationElementsLength */
-            bufferSize += primitive->scanResults[i1].informationElementsLength; /* u8 primitive->scanResults[i1].informationElements */
-            bufferSize += 1;                                                    /* CsrWifiSmeP2pRole primitive->scanResults[i1].p2pDeviceRole */
-            switch (primitive->scanResults[i1].p2pDeviceRole)
-            {
-                case CSR_WIFI_SME_P2P_ROLE_CLI:
-                    bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedCli.empty */
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_GO:
-                    bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability */
-                    bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a[6] */
-                    bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount */
-                    {
-                        u16 i4;
-                        for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                        {
-                            bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */
-                            bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */
-                            bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */
-                            bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */
-                            bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */
-                            bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */
-                            {
-                                u16 i6;
-                                for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
-                                {
-                                    bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */
-                                }
-                            }
-                            bufferSize += 32;        /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */
-                            bufferSize += 1;         /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */
-                        }
-                    }
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_NONE:
-                    bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedNone.empty */
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-                    bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a[6] */
-                    bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods */
-                    bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap */
-                    bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */
-                    bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */
-                    {
-                        u16 i4;
-                        for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
-                        {
-                            bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */
-                        }
-                    }
-                    bufferSize += 32;        /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName[32] */
-                    bufferSize += 1;         /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength */
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->scanResultsCount);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].ssid.ssid, ((u16) (32)));
-            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ssid.length);
-            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].bssid.a, ((u16) (6)));
-            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].rssi);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].snr);
-            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ifIndex);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].beaconPeriodTu);
-            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].timeStamp.data, ((u16) (8)));
-            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].localTime.data, ((u16) (8)));
-            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].channelFrequency);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].capabilityInformation);
-            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].channelNumber);
-            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].usability);
-            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].bssType);
-            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].informationElementsLength);
-            if (primitive->scanResults[i1].informationElementsLength)
-            {
-                CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].informationElements, ((u16) (primitive->scanResults[i1].informationElementsLength)));
-            }
-            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].p2pDeviceRole);
-            switch (primitive->scanResults[i1].p2pDeviceRole)
-            {
-                case CSR_WIFI_SME_P2P_ROLE_CLI:
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedCli.empty);
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_GO:
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability);
-                    CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6)));
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount);
-                    {
-                        u16 i4;
-                        for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                        {
-                            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6)));
-                            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6)));
-                            CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods);
-                            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap);
-                            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8)));
-                            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount);
-                            {
-                                u16 i6;
-                                for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
-                                {
-                                    CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8)));
-                                }
-                            }
-                            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32)));
-                            CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength);
-                        }
-                    }
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_NONE:
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedNone.empty);
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-                    CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6)));
-                    CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods);
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap);
-                    CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8)));
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount);
-                    {
-                        u16 i4;
-                        for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
-                        {
-                            CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8)));
-                        }
-                    }
-                    CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, ((u16) (32)));
-                    CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength);
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeScanResultsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->scanResultsCount, buffer, &offset);
-    primitive->scanResults = NULL;
-    if (primitive->scanResultsCount)
-    {
-        primitive->scanResults = kmalloc(sizeof(CsrWifiSmeScanResult) * primitive->scanResultsCount, GFP_KERNEL);
-    }
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
-        {
-            CsrMemCpyDes(primitive->scanResults[i1].ssid.ssid, buffer, &offset, ((u16) (32)));
-            CsrUint8Des((u8 *) &primitive->scanResults[i1].ssid.length, buffer, &offset);
-            CsrMemCpyDes(primitive->scanResults[i1].bssid.a, buffer, &offset, ((u16) (6)));
-            CsrUint16Des((u16 *) &primitive->scanResults[i1].rssi, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanResults[i1].snr, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->scanResults[i1].ifIndex, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanResults[i1].beaconPeriodTu, buffer, &offset);
-            CsrMemCpyDes(primitive->scanResults[i1].timeStamp.data, buffer, &offset, ((u16) (8)));
-            CsrMemCpyDes(primitive->scanResults[i1].localTime.data, buffer, &offset, ((u16) (8)));
-            CsrUint16Des((u16 *) &primitive->scanResults[i1].channelFrequency, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanResults[i1].capabilityInformation, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->scanResults[i1].channelNumber, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->scanResults[i1].usability, buffer, &offset);
-            CsrUint8Des((u8 *) &primitive->scanResults[i1].bssType, buffer, &offset);
-            CsrUint16Des((u16 *) &primitive->scanResults[i1].informationElementsLength, buffer, &offset);
-            if (primitive->scanResults[i1].informationElementsLength)
-            {
-                primitive->scanResults[i1].informationElements = kmalloc(primitive->scanResults[i1].informationElementsLength, GFP_KERNEL);
-                CsrMemCpyDes(primitive->scanResults[i1].informationElements, buffer, &offset, ((u16) (primitive->scanResults[i1].informationElementsLength)));
-            }
-            else
-            {
-                primitive->scanResults[i1].informationElements = NULL;
-            }
-            CsrUint8Des((u8 *) &primitive->scanResults[i1].p2pDeviceRole, buffer, &offset);
-            switch (primitive->scanResults[i1].p2pDeviceRole)
-            {
-                case CSR_WIFI_SME_P2P_ROLE_CLI:
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedCli.empty, buffer, &offset);
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_GO:
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability, buffer, &offset);
-                    CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6)));
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset);
-                    primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL;
-                    if (primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount)
-                    {
-                        primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL);
-                    }
-                    {
-                        u16 i4;
-                        for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                        {
-                            CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6)));
-                            CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
-                            CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset);
-                            CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset);
-                            CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
-                            CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset);
-                            primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
-                            if (primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount)
-                            {
-                                primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL);
-                            }
-                            {
-                                u16 i6;
-                                for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
-                                {
-                                    CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8)));
-                                }
-                            }
-                            CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32)));
-                            CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset);
-                        }
-                    }
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_NONE:
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedNone.empty, buffer, &offset);
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-                    CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
-                    CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods, buffer, &offset);
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset);
-                    CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset);
-                    primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL;
-                    if (primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount)
-                    {
-                        primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL);
-                    }
-                    {
-                        u16 i4;
-                        for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
-                        {
-                            CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8)));
-                        }
-                    }
-                    CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32)));
-                    CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset);
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeScanResultsGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) voidPrimitivePointer;
-    {
-        u16 i1;
-        for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
-        {
-            kfree(primitive->scanResults[i1].informationElements);
-            switch (primitive->scanResults[i1].p2pDeviceRole)
-            {
-                case CSR_WIFI_SME_P2P_ROLE_GO:
-                {
-                    u16 i4;
-                    for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
-                    {
-                        kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
-                    }
-                }
-                    kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo);
-                    break;
-                case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
-                    kfree(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType);
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-    kfree(primitive->scanResults);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */
-    bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */
-    bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */
-    bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */
-    bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */
-    bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeSmeStaConfigGetCfm *primitive = (CsrWifiSmeSmeStaConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher);
-    CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeSmeStaConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
-    bufferSize += 2; /* u16 primitive->interfaceTag */
-    bufferSize += 2; /* CsrResult primitive->status */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeSmeStaConfigSetCfm *primitive = (CsrWifiSmeSmeStaConfigSetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeSmeStaConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 2; i1++)
-        {
-            bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeStationMacAddressGetCfm *primitive = (CsrWifiSmeStationMacAddressGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 2; i1++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6)));
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeStationMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    {
-        u16 i1;
-        for (i1 = 0; i1 < 2; i1++)
-        {
-            CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6)));
-        }
-    }
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeTspecIndSizeof(void *msg)
-{
-    CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 4;                      /* u32 primitive->transactionId */
-    bufferSize += 1;                      /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */
-    bufferSize += 2;                      /* u16 primitive->tspecLength */
-    bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
-    CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode);
-    CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
-    if (primitive->tspecLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeTspecIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeTspecInd *primitive = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
-    if (primitive->tspecLength)
-    {
-        primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
-    }
-    else
-    {
-        primitive->tspec = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeTspecIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) voidPrimitivePointer;
-    kfree(primitive->tspec);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeTspecCfmSizeof(void *msg)
-{
-    CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
-    bufferSize += 2;                      /* u16 primitive->interfaceTag */
-    bufferSize += 2;                      /* CsrResult primitive->status */
-    bufferSize += 4;                      /* u32 primitive->transactionId */
-    bufferSize += 1;                      /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */
-    bufferSize += 2;                      /* u16 primitive->tspecLength */
-    bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
-    CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode);
-    CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
-    if (primitive->tspecLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeTspecCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeTspecCfm *primitive = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
-    if (primitive->tspecLength)
-    {
-        primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
-    }
-    else
-    {
-        primitive->tspec = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeTspecCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) voidPrimitivePointer;
-    kfree(primitive->tspec);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 33) */
-    bufferSize += 2;                                                                                    /* CsrResult primitive->status */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.chipId */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.chipVersion */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.firmwareBuild */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.firmwarePatch */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.firmwareHip */
-    bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1;  /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.routerHip */
-    bufferSize += (primitive->versions.smeBuild ? strlen(primitive->versions.smeBuild) : 0) + 1;        /* char* primitive->versions.smeBuild (0 byte len + 1 for NULL Term) */
-    bufferSize += 4;                                                                                    /* u32 primitive->versions.smeHip */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwarePatch);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip);
-    CsrCharStringSer(ptr, len, primitive->versions.routerBuild);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip);
-    CsrCharStringSer(ptr, len, primitive->versions.smeBuild);
-    CsrUint32Ser(ptr, len, (u32) primitive->versions.smeHip);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeVersionsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.firmwarePatch, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset);
-    CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset);
-    CsrCharStringDes(&primitive->versions.smeBuild, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->versions.smeHip, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeVersionsGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) voidPrimitivePointer;
-    kfree(primitive->versions.routerBuild);
-    kfree(primitive->versions.smeBuild);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg)
-{
-    CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
-        {
-            bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */
-            bufferSize += 1;  /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */
-        }
-    }
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount);
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
-        {
-            CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32)));
-            CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length);
-        }
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCloakedSsidsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset);
-    primitive->cloakedSsids.cloakedSsids = NULL;
-    if (primitive->cloakedSsids.cloakedSsidsCount)
-    {
-        primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL);
-    }
-    {
-        u16 i2;
-        for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
-        {
-            CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32)));
-            CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset);
-        }
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) voidPrimitivePointer;
-    kfree(primitive->cloakedSsids.cloakedSsids);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeWifiOnIndSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 6; /* u8 primitive->address.a[6] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeWifiOnInd *primitive = (CsrWifiSmeWifiOnInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeWifiOnInd *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */
-    bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */
-    bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */
-    bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeSmeCommonConfigGetCfm *primitive = (CsrWifiSmeSmeCommonConfigGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel);
-    CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2)));
-    CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface);
-    CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeSmeCommonConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset);
-    CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2)));
-    CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset);
-    CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset);
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg)
-{
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
-    bufferSize += 2; /* CsrResult primitive->status */
-    bufferSize += 2; /* u16 primitive->numInterfaces */
-    bufferSize += 2; /* u8 primitive->capBitmap[2] */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeInterfaceCapabilityGetCfm *primitive = (CsrWifiSmeInterfaceCapabilityGetCfm *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint16Ser(ptr, len, (u16) primitive->status);
-    CsrUint16Ser(ptr, len, (u16) primitive->numInterfaces);
-    CsrMemCpySer(ptr, len, (const void *) primitive->capBitmap, ((u16) (2)));
-    return(ptr);
-}
-
-
-void* CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeInterfaceCapabilityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
-    CsrUint16Des((u16 *) &primitive->numInterfaces, buffer, &offset);
-    CsrMemCpyDes(primitive->capBitmap, buffer, &offset, ((u16) (2)));
-
-    return primitive;
-}
-
-
-size_t CsrWifiSmeErrorIndSizeof(void *msg)
-{
-    CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */
-    bufferSize += (primitive->errorMessage ? strlen(primitive->errorMessage) : 0) + 1; /* char* primitive->errorMessage (0 byte len + 1 for NULL Term) */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrCharStringSer(ptr, len, primitive->errorMessage);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeErrorIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeErrorInd *primitive = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrCharStringDes(&primitive->errorMessage, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeErrorIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) voidPrimitivePointer;
-    kfree(primitive->errorMessage);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeInfoIndSizeof(void *msg)
-{
-    CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */
-    bufferSize += (primitive->infoMessage ? strlen(primitive->infoMessage) : 0) + 1; /* char* primitive->infoMessage (0 byte len + 1 for NULL Term) */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrCharStringSer(ptr, len, primitive->infoMessage);
-    return(ptr);
-}
-
-
-void* CsrWifiSmeInfoIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeInfoInd *primitive = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrCharStringDes(&primitive->infoMessage, buffer, &offset);
-
-    return primitive;
-}
-
-
-void CsrWifiSmeInfoIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) voidPrimitivePointer;
-    kfree(primitive->infoMessage);
-    kfree(primitive);
-}
-
-
-size_t CsrWifiSmeCoreDumpIndSizeof(void *msg)
-{
-    CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) msg;
-    size_t bufferSize = 2;
-
-    /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
-    bufferSize += 4;                     /* u32 primitive->dataLength */
-    bufferSize += primitive->dataLength; /* u8 primitive->data */
-    return bufferSize;
-}
-
-
-u8* CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg)
-{
-    CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *)msg;
-    *len = 0;
-    CsrUint16Ser(ptr, len, primitive->common.type);
-    CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
-    if (primitive->dataLength)
-    {
-        CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
-    }
-    return(ptr);
-}
-
-
-void* CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t length)
-{
-    CsrWifiSmeCoreDumpInd *primitive = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL);
-    size_t offset;
-    offset = 0;
-
-    CsrUint16Des(&primitive->common.type, buffer, &offset);
-    CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
-    if (primitive->dataLength)
-    {
-        primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
-        CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
-    }
-    else
-    {
-        primitive->data = NULL;
-    }
-
-    return primitive;
-}
-
-
-void CsrWifiSmeCoreDumpIndSerFree(void *voidPrimitivePointer)
-{
-    CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) voidPrimitivePointer;
-    kfree(primitive->data);
-    kfree(primitive);
-}
-
-
diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.h b/drivers/staging/csr/csr_wifi_sme_serialize.h
deleted file mode 100644 (file)
index f852626..0000000
+++ /dev/null
@@ -1,666 +0,0 @@
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2012
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_SERIALIZE_H__
-#define CSR_WIFI_SME_SERIALIZE_H__
-
-#include "csr_wifi_msgconv.h"
-#include "csr_wifi_sme_prim.h"
-
-extern void CsrWifiSmePfree(void *ptr);
-
-#define CsrWifiSmeActivateReqSer CsrWifiEventSer
-#define CsrWifiSmeActivateReqDes CsrWifiEventDes
-#define CsrWifiSmeActivateReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeActivateReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeAdhocConfigGetReqSer CsrWifiEventSer
-#define CsrWifiSmeAdhocConfigGetReqDes CsrWifiEventDes
-#define CsrWifiSmeAdhocConfigGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeAdhocConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeAdhocConfigSetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeBlacklistReqSizeof(void *msg);
-extern void CsrWifiSmeBlacklistReqSerFree(void *msg);
-
-#define CsrWifiSmeCalibrationDataGetReqSer CsrWifiEventSer
-#define CsrWifiSmeCalibrationDataGetReqDes CsrWifiEventDes
-#define CsrWifiSmeCalibrationDataGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeCalibrationDataGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg);
-extern void CsrWifiSmeCalibrationDataSetReqSerFree(void *msg);
-
-#define CsrWifiSmeCcxConfigGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeCcxConfigGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeCcxConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeCcxConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeCcxConfigSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeCoexConfigGetReqSer CsrWifiEventSer
-#define CsrWifiSmeCoexConfigGetReqDes CsrWifiEventDes
-#define CsrWifiSmeCoexConfigGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeCoexConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeCoexConfigSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeCoexInfoGetReqSer CsrWifiEventSer
-#define CsrWifiSmeCoexInfoGetReqDes CsrWifiEventDes
-#define CsrWifiSmeCoexInfoGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeCoexInfoGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeConnectReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeConnectReqSizeof(void *msg);
-extern void CsrWifiSmeConnectReqSerFree(void *msg);
-
-#define CsrWifiSmeConnectionConfigGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeConnectionConfigGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeConnectionConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeConnectionConfigGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeConnectionInfoGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeConnectionInfoGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeConnectionInfoGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeConnectionInfoGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeConnectionStatsGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeConnectionStatsGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeConnectionStatsGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeConnectionStatsGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeDeactivateReqSer CsrWifiEventSer
-#define CsrWifiSmeDeactivateReqDes CsrWifiEventDes
-#define CsrWifiSmeDeactivateReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeDeactivateReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeDisconnectReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeDisconnectReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeDisconnectReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeDisconnectReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser
-#define CsrWifiSmeEventMaskSetReqDes CsrWifiEventCsrUint32Des
-#define CsrWifiSmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof
-#define CsrWifiSmeEventMaskSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeHostConfigGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeHostConfigGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeHostConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeHostConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeHostConfigSetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeKeyReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeKeyReqSizeof(void *msg);
-#define CsrWifiSmeKeyReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeLinkQualityGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeLinkQualityGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeLinkQualityGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeLinkQualityGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeMibConfigGetReqSer CsrWifiEventSer
-#define CsrWifiSmeMibConfigGetReqDes CsrWifiEventDes
-#define CsrWifiSmeMibConfigGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeMibConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeMibConfigSetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibGetNextReqSizeof(void *msg);
-extern void CsrWifiSmeMibGetNextReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibGetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibGetReqSizeof(void *msg);
-extern void CsrWifiSmeMibGetReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibSetReqSizeof(void *msg);
-extern void CsrWifiSmeMibSetReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg);
-extern void CsrWifiSmeMulticastAddressReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg);
-extern void CsrWifiSmePacketFilterSetReqSerFree(void *msg);
-
-#define CsrWifiSmePermanentMacAddressGetReqSer CsrWifiEventSer
-#define CsrWifiSmePermanentMacAddressGetReqDes CsrWifiEventDes
-#define CsrWifiSmePermanentMacAddressGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmePermanentMacAddressGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePmkidReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePmkidReqSizeof(void *msg);
-extern void CsrWifiSmePmkidReqSerFree(void *msg);
-
-#define CsrWifiSmePowerConfigGetReqSer CsrWifiEventSer
-#define CsrWifiSmePowerConfigGetReqDes CsrWifiEventDes
-#define CsrWifiSmePowerConfigGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmePowerConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg);
-#define CsrWifiSmePowerConfigSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeRegulatoryDomainInfoGetReqSer CsrWifiEventSer
-#define CsrWifiSmeRegulatoryDomainInfoGetReqDes CsrWifiEventDes
-#define CsrWifiSmeRegulatoryDomainInfoGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeRegulatoryDomainInfoGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeRoamingConfigGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeRoamingConfigGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeRoamingConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeRoamingConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeRoamingConfigSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeScanConfigGetReqSer CsrWifiEventSer
-#define CsrWifiSmeScanConfigGetReqDes CsrWifiEventDes
-#define CsrWifiSmeScanConfigGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeScanConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg);
-extern void CsrWifiSmeScanConfigSetReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeScanFullReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeScanFullReqSizeof(void *msg);
-extern void CsrWifiSmeScanFullReqSerFree(void *msg);
-
-#define CsrWifiSmeScanResultsFlushReqSer CsrWifiEventSer
-#define CsrWifiSmeScanResultsFlushReqDes CsrWifiEventDes
-#define CsrWifiSmeScanResultsFlushReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeScanResultsFlushReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeScanResultsGetReqSer CsrWifiEventSer
-#define CsrWifiSmeScanResultsGetReqDes CsrWifiEventDes
-#define CsrWifiSmeScanResultsGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeScanResultsGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeSmeStaConfigGetReqSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeSmeStaConfigGetReqDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeSmeStaConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeSmeStaConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeSmeStaConfigSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeStationMacAddressGetReqSer CsrWifiEventSer
-#define CsrWifiSmeStationMacAddressGetReqDes CsrWifiEventDes
-#define CsrWifiSmeStationMacAddressGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeStationMacAddressGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeTspecReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeTspecReqSizeof(void *msg);
-extern void CsrWifiSmeTspecReqSerFree(void *msg);
-
-#define CsrWifiSmeVersionsGetReqSer CsrWifiEventSer
-#define CsrWifiSmeVersionsGetReqDes CsrWifiEventDes
-#define CsrWifiSmeVersionsGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeVersionsGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg);
-extern void CsrWifiSmeWifiFlightmodeReqSerFree(void *msg);
-
-#define CsrWifiSmeWifiOffReqSer CsrWifiEventSer
-#define CsrWifiSmeWifiOffReqDes CsrWifiEventDes
-#define CsrWifiSmeWifiOffReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeWifiOffReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeWifiOnReqSizeof(void *msg);
-extern void CsrWifiSmeWifiOnReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg);
-extern void CsrWifiSmeCloakedSsidsSetReqSerFree(void *msg);
-
-#define CsrWifiSmeCloakedSsidsGetReqSer CsrWifiEventSer
-#define CsrWifiSmeCloakedSsidsGetReqDes CsrWifiEventDes
-#define CsrWifiSmeCloakedSsidsGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeCloakedSsidsGetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeSmeCommonConfigGetReqSer CsrWifiEventSer
-#define CsrWifiSmeSmeCommonConfigGetReqDes CsrWifiEventDes
-#define CsrWifiSmeSmeCommonConfigGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeSmeCommonConfigGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg);
-#define CsrWifiSmeSmeCommonConfigSetReqSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeInterfaceCapabilityGetReqSer CsrWifiEventSer
-#define CsrWifiSmeInterfaceCapabilityGetReqDes CsrWifiEventDes
-#define CsrWifiSmeInterfaceCapabilityGetReqSizeof CsrWifiEventSizeof
-#define CsrWifiSmeInterfaceCapabilityGetReqSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg);
-extern void CsrWifiSmeWpsConfigurationReqSerFree(void *msg);
-
-extern u8 *CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeSetReqDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeSetReqSizeof(void *msg);
-extern void CsrWifiSmeSetReqSerFree(void *msg);
-
-#define CsrWifiSmeActivateCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeActivateCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeActivateCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeActivateCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeAdhocConfigGetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeAdhocConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeAdhocConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeAdhocConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeAdhocConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg);
-extern void CsrWifiSmeAssociationCompleteIndSerFree(void *msg);
-
-extern u8 *CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeAssociationStartIndSizeof(void *msg);
-#define CsrWifiSmeAssociationStartIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeBlacklistCfmSizeof(void *msg);
-extern void CsrWifiSmeBlacklistCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg);
-extern void CsrWifiSmeCalibrationDataGetCfmSerFree(void *msg);
-
-#define CsrWifiSmeCalibrationDataSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeCalibrationDataSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeCalibrationDataSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeCalibrationDataSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeCcxConfigGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg);
-#define CsrWifiSmeCcxConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeCoexConfigGetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeCoexConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeCoexConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeCoexConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeCoexConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg);
-#define CsrWifiSmeCoexInfoGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeConnectCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeConnectCfmSizeof(void *msg);
-#define CsrWifiSmeConnectCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg);
-extern void CsrWifiSmeConnectionConfigGetCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg);
-extern void CsrWifiSmeConnectionInfoGetCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg);
-#define CsrWifiSmeConnectionQualityIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg);
-#define CsrWifiSmeConnectionStatsGetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeDeactivateCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeDeactivateCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeDeactivateCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeDeactivateCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeDisconnectCfmSizeof(void *msg);
-#define CsrWifiSmeDisconnectCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeEventMaskSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeHostConfigGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg);
-#define CsrWifiSmeHostConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeIbssStationIndSizeof(void *msg);
-#define CsrWifiSmeIbssStationIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeKeyCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeKeyCfmSizeof(void *msg);
-#define CsrWifiSmeKeyCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg);
-#define CsrWifiSmeLinkQualityGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMediaStatusIndSizeof(void *msg);
-extern void CsrWifiSmeMediaStatusIndSerFree(void *msg);
-
-extern u8 *CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeMibConfigGetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeMibConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeMibConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeMibConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeMibConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibGetCfmSizeof(void *msg);
-extern void CsrWifiSmeMibGetCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg);
-extern void CsrWifiSmeMibGetNextCfmSerFree(void *msg);
-
-#define CsrWifiSmeMibSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeMibSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeMibSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeMibSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMicFailureIndSizeof(void *msg);
-#define CsrWifiSmeMicFailureIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg);
-extern void CsrWifiSmeMulticastAddressCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg);
-#define CsrWifiSmePacketFilterSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len,
-       void *msg);
-extern void *CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg);
-#define CsrWifiSmePermanentMacAddressGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg);
-extern void CsrWifiSmePmkidCandidateListIndSerFree(void *msg);
-
-extern u8 *CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePmkidCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePmkidCfmSizeof(void *msg);
-extern void CsrWifiSmePmkidCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmePowerConfigGetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmePowerConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmePowerConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmePowerConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmePowerConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len,
-       void *msg);
-extern void *CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg);
-#define CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg);
-#define CsrWifiSmeRoamCompleteIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeRoamStartIndSizeof(void *msg);
-#define CsrWifiSmeRoamStartIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeRoamingConfigGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg);
-#define CsrWifiSmeRoamingConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg);
-extern void CsrWifiSmeScanConfigGetCfmSerFree(void *msg);
-
-#define CsrWifiSmeScanConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeScanConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeScanConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeScanConfigSetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeScanFullCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeScanFullCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeScanFullCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeScanFullCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeScanResultIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeScanResultIndSizeof(void *msg);
-extern void CsrWifiSmeScanResultIndSerFree(void *msg);
-
-#define CsrWifiSmeScanResultsFlushCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeScanResultsFlushCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeScanResultsFlushCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeScanResultsFlushCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg);
-extern void CsrWifiSmeScanResultsGetCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeSmeStaConfigGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg);
-#define CsrWifiSmeSmeStaConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len,
-       void *msg);
-extern void *CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg);
-#define CsrWifiSmeStationMacAddressGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeTspecIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeTspecIndSizeof(void *msg);
-extern void CsrWifiSmeTspecIndSerFree(void *msg);
-
-extern u8 *CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeTspecCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeTspecCfmSizeof(void *msg);
-extern void CsrWifiSmeTspecCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg);
-extern void CsrWifiSmeVersionsGetCfmSerFree(void *msg);
-
-#define CsrWifiSmeWifiFlightmodeCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeWifiFlightmodeCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeWifiFlightmodeCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeWifiFlightmodeCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeWifiOffIndSer CsrWifiEventCsrUint8Ser
-#define CsrWifiSmeWifiOffIndDes CsrWifiEventCsrUint8Des
-#define CsrWifiSmeWifiOffIndSizeof CsrWifiEventCsrUint8Sizeof
-#define CsrWifiSmeWifiOffIndSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeWifiOffCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeWifiOffCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeWifiOffCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeWifiOnCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeWifiOnCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeWifiOnCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeWifiOnCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeCloakedSsidsSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeCloakedSsidsSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeCloakedSsidsSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeCloakedSsidsSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg);
-extern void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *msg);
-
-extern u8 *CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeWifiOnIndSizeof(void *msg);
-#define CsrWifiSmeWifiOnIndSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg);
-#define CsrWifiSmeSmeCommonConfigGetCfmSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeSmeCommonConfigSetCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeSmeCommonConfigSetCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeSmeCommonConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeSmeCommonConfigSetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len,
-       void *msg);
-extern void *CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg);
-#define CsrWifiSmeInterfaceCapabilityGetCfmSerFree CsrWifiSmePfree
-
-extern u8 *CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeErrorIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeErrorIndSizeof(void *msg);
-extern void CsrWifiSmeErrorIndSerFree(void *msg);
-
-extern u8 *CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeInfoIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeInfoIndSizeof(void *msg);
-extern void CsrWifiSmeInfoIndSerFree(void *msg);
-
-extern u8 *CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg);
-extern void *CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t len);
-extern size_t CsrWifiSmeCoreDumpIndSizeof(void *msg);
-extern void CsrWifiSmeCoreDumpIndSerFree(void *msg);
-
-#define CsrWifiSmeAmpStatusChangeIndSer CsrWifiEventCsrUint16CsrUint8Ser
-#define CsrWifiSmeAmpStatusChangeIndDes CsrWifiEventCsrUint16CsrUint8Des
-#define CsrWifiSmeAmpStatusChangeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
-#define CsrWifiSmeAmpStatusChangeIndSerFree CsrWifiSmePfree
-
-#define CsrWifiSmeWpsConfigurationCfmSer CsrWifiEventCsrUint16Ser
-#define CsrWifiSmeWpsConfigurationCfmDes CsrWifiEventCsrUint16Des
-#define CsrWifiSmeWpsConfigurationCfmSizeof CsrWifiEventCsrUint16Sizeof
-#define CsrWifiSmeWpsConfigurationCfmSerFree CsrWifiSmePfree
-
-#endif /* CSR_WIFI_SME_SERIALIZE_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_sme_task.h b/drivers/staging/csr/csr_wifi_sme_task.h
deleted file mode 100644 (file)
index 1e938c1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*****************************************************************************
-
-       (c) Cambridge Silicon Radio Limited 2011
-       All rights reserved and confidential information of CSR
-
-       Refer to LICENSE.txt included with this source for details
-       on the license terms.
-
-*****************************************************************************/
-
-/* Note: this is an auto-generated file. */
-
-#ifndef CSR_WIFI_SME_TASK_H__
-#define CSR_WIFI_SME_TASK_H__
-
-#include "csr_sched.h"
-
-#define CSR_WIFI_SME_LOG_ID 0x1202FFFF
-extern CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
-void CsrWifiSmeInit(void **gash);
-void CsrWifiSmeDeinit(void **gash);
-void CsrWifiSmeHandler(void **gash);
-
-#endif /* CSR_WIFI_SME_TASK_H__ */
-
diff --git a/drivers/staging/csr/csr_wifi_vif_utils.h b/drivers/staging/csr/csr_wifi_vif_utils.h
deleted file mode 100644 (file)
index 8ff9788..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*****************************************************************************
-
-            (c) Cambridge Silicon Radio Limited 2011
-            All rights reserved and confidential information of CSR
-
-            Refer to LICENSE.txt included with this source for details
-            on the license terms.
-
-*****************************************************************************/
-
-#ifndef CSR_WIFI_VIF_UTILS_H
-#define CSR_WIFI_VIF_UTILS_H
-
-/* STANDARD INCLUDES ********************************************************/
-
-/* PROJECT INCLUDES *********************************************************/
-/* including this file for CsrWifiInterfaceMode*/
-#include "csr_wifi_private_common.h"
-
-/* MACROS *******************************************************************/
-
-/* Common macros for NME and SME to be used temporarily until SoftMAC changes are made */
-#define CSR_WIFI_NUM_INTERFACES        (u8)0x1
-#define CSR_WIFI_INTERFACE_IN_USE      (u16)0x0
-
-#endif /* CSR_WIFI_VIF_UTILS_H */
-
diff --git a/drivers/staging/csr/data_tx.c b/drivers/staging/csr/data_tx.c
deleted file mode 100644 (file)
index 9e3d8b8..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     data_tx.c
- *
- * PURPOSE:
- *      This file provides functions to send data requests to the UniFi.
- *
- * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include "csr_wifi_hip_unifi.h"
-#include "unifi_priv.h"
-
-int
-uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet, unsigned int length)
-{
-       const unsigned char *p = packet;
-       u16 keyinfo;
-
-
-       if (length < (4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1 + 8))
-               return 1;
-
-       p += 8;
-       keyinfo = p[5] << 8 | p[6]; /* big-endian */
-       if (
-         (p[0] == 1 || p[0] == 2) /* protocol version 802.1X-2001 (WPA) or -2004 (WPA2) */ &&
-         p[1] == 3 /* EAPOL-Key */ &&
-         /* don't bother checking p[2] p[3] (hh ll, packet body length) */
-         (p[4] == 254 || p[4] == 2) /* descriptor type P802.1i-D3.0 (WPA) or 802.11i-2004 (WPA2) */ &&
-         ((keyinfo & 0x0007) == 1 || (keyinfo & 0x0007) == 2) /* key descriptor version */ &&
-        (keyinfo & ~0x0207U) == 0x0108 && /* key info for 4/4 or 4/2 -- ignore key desc version and sec bit (since varies in WPA 4/4) */
-         (p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 0] == 0 && /* key data length (2 octets) 0 for 4/4 only */
-          p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1] == 0)
-       ) {
-               unifi_trace(priv, UDBG1, "uf_verify_m4: M4 detected\n");
-               return 0;
-       } else {
-               return 1;
-       }
-}
-
-/*
- * ---------------------------------------------------------------------------
- *
- *      Data transport signals.
- *
- * ---------------------------------------------------------------------------
- */
-
diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c
deleted file mode 100644 (file)
index 92898de..0000000
+++ /dev/null
@@ -1,2193 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     drv.c
- *
- *  PURPOSE:
- *      Conventional device interface for debugging/monitoring of the
- *      driver and h/w using unicli. This interface is also being used
- *      by the SME linux implementation and the helper apps.
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-/*
- * Porting Notes:
- * Part of this file contains an example for how to glue the OS layer
- * with the HIP core lib, the SDIO glue layer, and the SME.
- *
- * When the unifi_sdio.ko modules loads, the linux kernel calls unifi_load().
- * unifi_load() calls uf_sdio_load() which is exported by the SDIO glue
- * layer. uf_sdio_load() registers this driver with the underlying SDIO driver.
- * When a card is detected, the SDIO glue layer calls register_unifi_sdio()
- * to pass the SDIO function context and ask the OS layer to initialise
- * the card. register_unifi_sdio() allocates all the private data of the OS
- * layer and calls uf_run_unifihelper() to start the SME. The SME calls
- * unifi_sys_wifi_on_req() which uses the HIP core lib to initialise the card.
- */
-
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <asm/uaccess.h>
-#include <linux/jiffies.h>
-#include <linux/version.h>
-
-#include "csr_wifi_hip_unifiversion.h"
-#include "unifi_priv.h"
-#include "csr_wifi_hip_conversions.h"
-#include "unifi_native.h"
-
-/* Module parameter variables */
-int buswidth = 0;               /* 0 means use default, values 1,4 */
-int sdio_clock = 50000;         /* kHz */
-int unifi_debug = 0;
-/* fw_init prevents f/w initialisation on error. */
-int fw_init[MAX_UNIFI_DEVS] = {-1, -1};
-int use_5g = 0;
-int led_mask = 0;               /* 0x0c00 for dev-pc-1503c, dev-pc-1528a */
-int disable_hw_reset = 0;
-int disable_power_control = 0;
-int enable_wol = UNIFI_WOL_OFF; /* 0 for none, 1 for SDIO IRQ, 2 for PIO */
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-int tl_80211d = (int)CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB;
-#endif
-int sdio_block_size = -1;      /* Override SDIO block size */
-int sdio_byte_mode = 0;        /* 0 for block mode + padding, 1 for byte mode */
-int coredump_max = CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS;
-int run_bh_once = -1;          /* Set for scheduled interrupt mode, -1 = default */
-int bh_priority = -1;
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-#define UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA   (1 << 1)
-#define UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP  (1 << 2)
-int log_hip_signals = 0;
-#endif
-
-MODULE_DESCRIPTION("CSR UniFi (SDIO)");
-
-module_param(buswidth,    int, S_IRUGO|S_IWUSR);
-module_param(sdio_clock,  int, S_IRUGO|S_IWUSR);
-module_param(unifi_debug, int, S_IRUGO|S_IWUSR);
-module_param_array(fw_init, int, NULL, S_IRUGO|S_IWUSR);
-module_param(use_5g,      int, S_IRUGO|S_IWUSR);
-module_param(led_mask,    int, S_IRUGO|S_IWUSR);
-module_param(disable_hw_reset,  int, S_IRUGO|S_IWUSR);
-module_param(disable_power_control,  int, S_IRUGO|S_IWUSR);
-module_param(enable_wol,  int, S_IRUGO|S_IWUSR);
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-module_param(tl_80211d,   int, S_IRUGO|S_IWUSR);
-#endif
-module_param(sdio_block_size, int, S_IRUGO|S_IWUSR);
-module_param(sdio_byte_mode, int, S_IRUGO|S_IWUSR);
-module_param(coredump_max, int, S_IRUGO|S_IWUSR);
-module_param(run_bh_once, int, S_IRUGO|S_IWUSR);
-module_param(bh_priority, int, S_IRUGO|S_IWUSR);
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-module_param(log_hip_signals, int, S_IRUGO|S_IWUSR);
-#endif
-
-MODULE_PARM_DESC(buswidth, "SDIO bus width (0=default), set 1 for 1-bit or 4 for 4-bit mode");
-MODULE_PARM_DESC(sdio_clock, "SDIO bus frequency in kHz, (default = 50 MHz)");
-MODULE_PARM_DESC(unifi_debug, "Diagnostic reporting level");
-MODULE_PARM_DESC(fw_init, "Set to 0 to prevent f/w initialization on error");
-MODULE_PARM_DESC(use_5g, "Use the 5G (802.11a) radio band");
-MODULE_PARM_DESC(led_mask, "LED mask flags");
-MODULE_PARM_DESC(disable_hw_reset, "Set to 1 to disable hardware reset");
-MODULE_PARM_DESC(disable_power_control, "Set to 1 to disable SDIO power control");
-MODULE_PARM_DESC(enable_wol, "Enable wake-on-wlan function 0=off, 1=SDIO, 2=PIO");
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-MODULE_PARM_DESC(tl_80211d, "802.11d Trust Level (1-6, default = 5)");
-#endif
-MODULE_PARM_DESC(sdio_block_size, "Set to override SDIO block size");
-MODULE_PARM_DESC(sdio_byte_mode, "Set to 1 for byte mode SDIO");
-MODULE_PARM_DESC(coredump_max, "Number of chip mini-coredump buffers to allocate");
-MODULE_PARM_DESC(run_bh_once, "Run BH only when firmware interrupts");
-MODULE_PARM_DESC(bh_priority, "Modify the BH thread priority");
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-MODULE_PARM_DESC(log_hip_signals, "Set to 1 to enable HIP signal offline logging");
-#endif
-
-
-/* Callback for event logging to UDI clients */
-static void udi_log_event(ul_client_t *client,
-                          const u8 *signal, int signal_len,
-                          const bulk_data_param_t *bulkdata,
-                          int dir);
-
-static void udi_set_log_filter(ul_client_t *pcli,
-                               unifiio_filter_t *udi_filter);
-
-
-/* Mutex to protect access to  priv->sme_cli */
-DEFINE_SEMAPHORE(udi_mutex);
-
-s32 CsrHipResultToStatus(CsrResult csrResult)
-{
-    s32 r = -EIO;
-
-    switch (csrResult)
-    {
-    case CSR_RESULT_SUCCESS:
-        r = 0;
-        break;
-    case CSR_WIFI_HIP_RESULT_RANGE:
-        r = -ERANGE;
-        break;
-    case CSR_WIFI_HIP_RESULT_NO_DEVICE:
-        r = -ENODEV;
-        break;
-    case CSR_WIFI_HIP_RESULT_INVALID_VALUE:
-        r = -EINVAL;
-        break;
-    case CSR_WIFI_HIP_RESULT_NOT_FOUND:
-        r = -ENOENT;
-        break;
-    case CSR_WIFI_HIP_RESULT_NO_SPACE:
-        r = -ENOSPC;
-        break;
-    case CSR_WIFI_HIP_RESULT_NO_MEMORY:
-        r = -ENOMEM;
-        break;
-    case CSR_RESULT_FAILURE:
-        r = -EIO;
-        break;
-    default:
-        /*unifi_warning(card->ospriv, "CsrHipResultToStatus: Unrecognised csrResult error code: %d\n", csrResult);*/
-        r = -EIO;
-    }
-    return r;
-}
-
-
-static const char*
-trace_putest_cmdid(unifi_putest_command_t putest_cmd)
-{
-       switch (putest_cmd) {
-       case UNIFI_PUTEST_START:
-               return "START";
-       case UNIFI_PUTEST_STOP:
-               return "STOP";
-       case UNIFI_PUTEST_SET_SDIO_CLOCK:
-               return "SET CLOCK";
-       case UNIFI_PUTEST_CMD52_READ:
-               return "CMD52R";
-       case UNIFI_PUTEST_CMD52_BLOCK_READ:
-               return "CMD52BR";
-       case UNIFI_PUTEST_CMD52_WRITE:
-               return "CMD52W";
-       case UNIFI_PUTEST_DL_FW:
-               return "D/L FW";
-       case UNIFI_PUTEST_DL_FW_BUFF:
-               return "D/L FW BUFFER";
-       case UNIFI_PUTEST_COREDUMP_PREPARE:
-               return "PREPARE COREDUMP";
-       case UNIFI_PUTEST_GP_READ16:
-               return "GP16R";
-       case UNIFI_PUTEST_GP_WRITE16:
-               return "GP16W";
-       default:
-               return "ERROR: unrecognised command";
-       }
- }
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-int uf_register_hip_offline_debug(unifi_priv_t *priv)
-{
-    ul_client_t *udi_cli;
-    int i;
-
-    udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event);
-    if (udi_cli == NULL) {
-        /* Too many clients already using this device */
-        unifi_error(priv, "Too many UDI clients already open\n");
-        return -ENOSPC;
-    }
-    unifi_trace(priv, UDBG1, "Offline HIP client is registered\n");
-
-    down(&priv->udi_logging_mutex);
-    udi_cli->event_hook = udi_log_event;
-    unifi_set_udi_hook(priv->card, logging_handler);
-    /* Log all signals by default */
-    for (i = 0; i < SIG_FILTER_SIZE; i++) {
-        udi_cli->signal_filter[i] = 0xFFFF;
-    }
-    priv->logging_client = udi_cli;
-    up(&priv->udi_logging_mutex);
-
-    return 0;
-}
-
-int uf_unregister_hip_offline_debug(unifi_priv_t *priv)
-{
-    ul_client_t *udi_cli = priv->logging_client;
-    if (udi_cli == NULL)
-    {
-        unifi_error(priv, "Unknown HIP client unregister request\n");
-        return -ERANGE;
-    }
-
-    unifi_trace(priv, UDBG1, "Offline HIP client is unregistered\n");
-
-    down(&priv->udi_logging_mutex);
-    priv->logging_client = NULL;
-    udi_cli->event_hook = NULL;
-    up(&priv->udi_logging_mutex);
-
-    ul_deregister_client(udi_cli);
-
-    return 0;
-}
-#endif
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_open
- *  unifi_release
- *
- *      Open and release entry points for the UniFi debug driver.
- *
- *  Arguments:
- *      Normal linux driver args.
- *
- *  Returns:
- *      Linux error code.
- * ---------------------------------------------------------------------------
- */
-static int
-unifi_open(struct inode *inode, struct file *file)
-{
-    int devno;
-    unifi_priv_t *priv;
-    ul_client_t *udi_cli;
-
-    devno = MINOR(inode->i_rdev) >> 1;
-
-    /*
-     * Increase the ref_count for the char device clients.
-     * Make sure you call uf_put_instance() to decreace it if
-     * unifi_open returns an error.
-     */
-    priv = uf_get_instance(devno);
-    if (priv == NULL) {
-        unifi_error(NULL, "unifi_open: No device present\n");
-        return -ENODEV;
-    }
-
-    /* Register this instance in the client's list. */
-    /* The minor number determines the nature of the client (Unicli or SME). */
-    if (MINOR(inode->i_rdev) & 0x1) {
-        udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event);
-        if (udi_cli == NULL) {
-            /* Too many clients already using this device */
-            unifi_error(priv, "Too many clients already open\n");
-            uf_put_instance(devno);
-            return -ENOSPC;
-        }
-        unifi_trace(priv, UDBG1, "Client is registered to /dev/unifiudi%d\n", devno);
-    } else {
-        /*
-         * Even-numbered device nodes are the control application.
-         * This is the userspace helper containing SME or
-         * unifi_manager.
-         */
-
-        down(&udi_mutex);
-
-#ifdef CSR_SME_USERSPACE
-        /* Check if a config client is already attached */
-        if (priv->sme_cli) {
-            up(&udi_mutex);
-            uf_put_instance(devno);
-
-            unifi_info(priv, "There is already a configuration client using the character device\n");
-            return -EBUSY;
-        }
-#endif /* CSR_SME_USERSPACE */
-
-#ifdef CSR_SUPPORT_SME
-        udi_cli = ul_register_client(priv,
-                                     CLI_USING_WIRE_FORMAT | CLI_SME_USERSPACE,
-                                     sme_log_event);
-#else
-        /* Config client for native driver */
-        udi_cli = ul_register_client(priv,
-                                     0,
-                                     sme_native_log_event);
-#endif
-        if (udi_cli == NULL) {
-            /* Too many clients already using this device */
-            up(&udi_mutex);
-            uf_put_instance(devno);
-
-            unifi_error(priv, "Too many clients already open\n");
-            return -ENOSPC;
-        }
-
-        /*
-         * Fill-in the pointer to the configuration client.
-         * This is the SME userspace helper or unifi_manager.
-         * Not used in the SME embedded version.
-         */
-        unifi_trace(priv, UDBG1, "SME client (id:%d s:0x%X) is registered\n",
-                    udi_cli->client_id, udi_cli->sender_id);
-        /* Store the SME UniFi Linux Client */
-        if (priv->sme_cli == NULL) {
-            priv->sme_cli = udi_cli;
-        }
-
-        up(&udi_mutex);
-    }
-
-
-    /*
-     * Store the pointer to the client.
-     * All char driver's entry points will pass this pointer.
-     */
-    file->private_data = udi_cli;
-
-    return 0;
-} /* unifi_open() */
-
-
-static int
-unifi_release(struct inode *inode, struct file *filp)
-{
-    ul_client_t *udi_cli = (void*)filp->private_data;
-    int devno;
-    unifi_priv_t *priv;
-
-    priv = uf_find_instance(udi_cli->instance);
-    if (!priv) {
-        unifi_error(priv, "unifi_close: instance for device not found\n");
-        return -ENODEV;
-    }
-
-    devno = MINOR(inode->i_rdev) >> 1;
-
-    /* Even device nodes are the config client (i.e. SME or unifi_manager) */
-    if ((MINOR(inode->i_rdev) & 0x1) == 0) {
-
-        if (priv->sme_cli != udi_cli) {
-            unifi_notice(priv, "Surprise closing config device: not the sme client\n");
-        }
-        unifi_notice(priv, "SME client close (unifi%d)\n", devno);
-
-        /*
-         * Clear sme_cli before calling unifi_sys_... so it doesn't try to
-         * queue a reply to the (now gone) SME.
-         */
-        down(&udi_mutex);
-        priv->sme_cli = NULL;
-        up(&udi_mutex);
-
-#ifdef CSR_SME_USERSPACE
-        /* Power-down when config client closes */
-        {
-            CsrWifiRouterCtrlWifiOffReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, 0, 0, 0, NULL}};
-            CsrWifiRouterCtrlWifiOffReqHandler(priv, &req.common);
-        }
-
-        uf_sme_deinit(priv);
-
-       /* It is possible that a blocking SME request was made from another process
-        * which did not get read by the SME before the WifiOffReq.
-        * So check for a pending request which will go unanswered and cancel
-        * the wait for event. As only one blocking request can be in progress at
-        * a time, up to one event should be completed.
-        */
-       uf_sme_cancel_request(priv, 0);
-
-#endif /* CSR_SME_USERSPACE */
-    } else {
-
-        unifi_trace(priv, UDBG2, "UDI client close (unifiudi%d)\n", devno);
-
-        /* If the pointer matches the logging client, stop logging. */
-        down(&priv->udi_logging_mutex);
-        if (udi_cli == priv->logging_client) {
-            priv->logging_client = NULL;
-        }
-        up(&priv->udi_logging_mutex);
-
-        if (udi_cli == priv->amp_client) {
-            priv->amp_client = NULL;
-        }
-    }
-
-    /* Deregister this instance from the client's list. */
-    ul_deregister_client(udi_cli);
-
-    uf_put_instance(devno);
-
-    return 0;
-} /* unifi_release() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_read
- *
- *      The read() driver entry point.
- *
- *  Arguments:
- *      filp        The file descriptor returned by unifi_open()
- *      p           The user space buffer to copy the read data
- *      len         The size of the p buffer
- *      poff
- *
- *  Returns:
- *      number of bytes read or an error code on failure
- * ---------------------------------------------------------------------------
- */
-static ssize_t
-unifi_read(struct file *filp, char *p, size_t len, loff_t *poff)
-{
-    ul_client_t *pcli = (void*)filp->private_data;
-    unifi_priv_t *priv;
-    udi_log_t *logptr = NULL;
-    udi_msg_t *msgptr;
-    struct list_head *l;
-    int msglen;
-
-    priv = uf_find_instance(pcli->instance);
-    if (!priv) {
-        unifi_error(priv, "invalid priv\n");
-        return -ENODEV;
-    }
-
-    if (!pcli->udi_enabled) {
-        unifi_error(priv, "unifi_read: unknown client.");
-        return -EINVAL;
-    }
-
-    if (list_empty(&pcli->udi_log)) {
-        if (filp->f_flags & O_NONBLOCK) {
-            /* Non-blocking - just return if the udi_log is empty */
-            return 0;
-        } else {
-            /* Blocking - wait on the UDI wait queue */
-            if (wait_event_interruptible(pcli->udi_wq,
-                !list_empty(&pcli->udi_log)))
-            {
-                unifi_error(priv, "unifi_read: wait_event_interruptible failed.");
-                return -ERESTARTSYS;
-            }
-        }
-    }
-
-    /* Read entry from list head and remove it from the list */
-    if (down_interruptible(&pcli->udi_sem)) {
-        return -ERESTARTSYS;
-    }
-    l = pcli->udi_log.next;
-    list_del(l);
-    up(&pcli->udi_sem);
-
-    /* Get a pointer to whole struct */
-    logptr = list_entry(l, udi_log_t, q);
-    if (logptr == NULL) {
-        unifi_error(priv, "unifi_read: failed to get event.\n");
-        return -EINVAL;
-    }
-
-    /* Get the real message */
-    msgptr = &logptr->msg;
-    msglen = msgptr->length;
-    if (msglen > len) {
-        printk(KERN_WARNING "truncated read to %d actual msg len is %lu\n", msglen, (long unsigned int)len);
-        msglen = len;
-    }
-
-    /* and pass it to the client (SME or Unicli). */
-    if (copy_to_user(p, msgptr, msglen))
-    {
-        printk(KERN_ERR "Failed to copy UDI log to user\n");
-        kfree(logptr);
-        return -EFAULT;
-    }
-
-    /* It is our resposibility to free the message buffer. */
-    kfree(logptr);
-
-    return msglen;
-
-} /* unifi_read() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- * udi_send_signal_unpacked
- *
- *      Sends an unpacked signal to UniFi.
- *
- * Arguments:
- *      priv            Pointer to private context struct
- *      data            Pointer to request structure and data to send
- *      data_len        Length of data in data pointer.
- *
- * Returns:
- *      Number of bytes written, error otherwise.
- *
- * Notes:
- *      All clients that use this function to send a signal to the unifi
- *      must use the host formatted structures.
- * ---------------------------------------------------------------------------
- */
-static int
-udi_send_signal_unpacked(unifi_priv_t *priv, unsigned char* data, uint data_len)
-{
-    CSR_SIGNAL *sigptr = (CSR_SIGNAL*)data;
-    CSR_DATAREF *datarefptr;
-    bulk_data_param_t bulk_data;
-    uint signal_size, i;
-    uint bulk_data_offset = 0;
-    int bytecount, r;
-    CsrResult csrResult;
-
-    /* Number of bytes in the signal */
-    signal_size = SigGetSize(sigptr);
-    if (!signal_size || (signal_size > data_len)) {
-        unifi_error(priv, "unifi_sme_mlme_req - Invalid signal 0x%x size should be %d bytes\n",
-                    sigptr->SignalPrimitiveHeader.SignalId,
-                    signal_size);
-        return -EINVAL;
-    }
-    bytecount = signal_size;
-
-    /* Get a pointer to the information of the first data reference */
-    datarefptr = (CSR_DATAREF*)&sigptr->u;
-
-    /* Initialize the offset in the data buffer, bulk data is right after the signal. */
-    bulk_data_offset = signal_size;
-
-    /* store the references and the size of the bulk data to the bulkdata structure */
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-        /* the length of the bulk data is in the signal */
-        if ((datarefptr+i)->DataLength) {
-            void *dest;
-
-            csrResult = unifi_net_data_malloc(priv, &bulk_data.d[i], (datarefptr+i)->DataLength);
-            if (csrResult != CSR_RESULT_SUCCESS) {
-                unifi_error(priv, "udi_send_signal_unpacked: failed to allocate request_data.\n");
-                return -EIO;
-            }
-
-            dest = (void*)bulk_data.d[i].os_data_ptr;
-            memcpy(dest, data + bulk_data_offset, bulk_data.d[i].data_length);
-        } else {
-            bulk_data.d[i].data_length = 0;
-        }
-
-        bytecount += bulk_data.d[i].data_length;
-        /* advance the offset, to point the next bulk data */
-        bulk_data_offset += bulk_data.d[i].data_length;
-    }
-
-
-    unifi_trace(priv, UDBG3, "SME Send: signal 0x%.4X\n", sigptr->SignalPrimitiveHeader.SignalId);
-
-    /* Send the signal. */
-    r = ul_send_signal_unpacked(priv, sigptr, &bulk_data);
-    if (r < 0) {
-        unifi_error(priv, "udi_send_signal_unpacked: send failed (%d)\n", r);
-        for(i=0;i<UNIFI_MAX_DATA_REFERENCES;i++) {
-            if(bulk_data.d[i].data_length != 0) {
-                unifi_net_data_free(priv, &bulk_data.d[i]);
-            }
-        }
-        return -EIO;
-    }
-
-    return bytecount;
-} /* udi_send_signal_unpacked() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- * udi_send_signal_raw
- *
- *      Sends a packed signal to UniFi.
- *
- * Arguments:
- *      priv            Pointer to private context struct
- *      buf             Pointer to request structure and data to send
- *      buflen          Length of data in data pointer.
- *
- * Returns:
- *      Number of bytes written, error otherwise.
- *
- * Notes:
- *      All clients that use this function to send a signal to the unifi
- *      must use the wire formatted structures.
- * ---------------------------------------------------------------------------
- */
-static int
-udi_send_signal_raw(unifi_priv_t *priv, unsigned char *buf, int buflen)
-{
-    int signal_size;
-    int sig_id;
-    bulk_data_param_t data_ptrs;
-    int i, r;
-    unsigned int num_data_refs;
-    int bytecount;
-    CsrResult csrResult;
-
-    /*
-     * The signal is the first thing in buf, the signal id is the
-     * first 16 bits of the signal.
-     */
-    /* Number of bytes in the signal */
-    sig_id = GET_SIGNAL_ID(buf);
-    signal_size = buflen;
-    signal_size -= GET_PACKED_DATAREF_LEN(buf, 0);
-    signal_size -= GET_PACKED_DATAREF_LEN(buf, 1);
-    if ((signal_size <= 0) || (signal_size > buflen)) {
-        unifi_error(priv, "udi_send_signal_raw - Couldn't find length of signal 0x%x\n",
-                    sig_id);
-        return -EINVAL;
-    }
-    unifi_trace(priv, UDBG2, "udi_send_signal_raw: signal 0x%.4X len:%d\n",
-                sig_id, signal_size);
-    /* Zero the data ref arrays */
-    memset(&data_ptrs, 0, sizeof(data_ptrs));
-
-    /*
-     * Find the number of associated bulk data packets.  Scan through
-     * the data refs to check that we have enough data and pick out
-     * pointers to appended bulk data.
-     */
-    num_data_refs = 0;
-    bytecount = signal_size;
-
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
-    {
-        unsigned int len = GET_PACKED_DATAREF_LEN(buf, i);
-        unifi_trace(priv, UDBG3, "udi_send_signal_raw: data_ref length = %d\n", len);
-
-        if (len != 0) {
-            void *dest;
-
-            csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[i], len);
-            if (csrResult != CSR_RESULT_SUCCESS) {
-                unifi_error(priv, "udi_send_signal_raw: failed to allocate request_data.\n");
-                return -EIO;
-            }
-
-            dest = (void*)data_ptrs.d[i].os_data_ptr;
-            memcpy(dest, buf + bytecount, len);
-
-            bytecount += len;
-            num_data_refs++;
-        }
-        data_ptrs.d[i].data_length = len;
-    }
-
-    unifi_trace(priv, UDBG3, "Queueing signal 0x%.4X from UDI with %u data refs\n",
-          sig_id,
-          num_data_refs);
-
-    if (bytecount > buflen) {
-        unifi_error(priv, "udi_send_signal_raw: Not enough data (%d instead of %d)\n", buflen, bytecount);
-        return -EINVAL;
-    }
-
-    /* Send the signal calling the function that uses the wire-formatted signals. */
-    r = ul_send_signal_raw(priv, buf, signal_size, &data_ptrs);
-    if (r < 0) {
-        unifi_error(priv, "udi_send_signal_raw: send failed (%d)\n", r);
-        return -EIO;
-    }
-
-#ifdef CSR_NATIVE_LINUX
-    if (sig_id == CSR_MLME_POWERMGT_REQUEST_ID) {
-        int power_mode = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((buf +
-                                              SIZEOF_SIGNAL_HEADER + (UNIFI_MAX_DATA_REFERENCES*SIZEOF_DATAREF)));
-#ifdef CSR_SUPPORT_WEXT
-        /* Overide the wext power mode to the new value */
-        priv->wext_conf.power_mode = power_mode;
-#endif
-        /* Configure deep sleep signaling */
-        if (power_mode || (priv->interfacePriv[0]->connected == UnifiNotConnected)) {
-            csrResult = unifi_configure_low_power_mode(priv->card,
-                                                   UNIFI_LOW_POWER_ENABLED,
-                                                   UNIFI_PERIODIC_WAKE_HOST_DISABLED);
-        } else {
-            csrResult = unifi_configure_low_power_mode(priv->card,
-                                                   UNIFI_LOW_POWER_DISABLED,
-                                                   UNIFI_PERIODIC_WAKE_HOST_DISABLED);
-        }
-    }
-#endif
-
-    return bytecount;
-} /* udi_send_signal_raw */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_write
- *
- *      The write() driver entry point.
- *      A UniFi Debug Interface client such as unicli can write a signal
- *      plus bulk data to the driver for sending to the UniFi chip.
- *
- *      Only one signal may be sent per write operation.
- *
- *  Arguments:
- *      filp        The file descriptor returned by unifi_open()
- *      p           The user space buffer to get the data from
- *      len         The size of the p buffer
- *      poff
- *
- *  Returns:
- *      number of bytes written or an error code on failure
- * ---------------------------------------------------------------------------
- */
-static ssize_t
-unifi_write(struct file *filp, const char *p, size_t len, loff_t *poff)
-{
-    ul_client_t *pcli = (ul_client_t*)filp->private_data;
-    unifi_priv_t *priv;
-    unsigned char *buf;
-    unsigned char *bufptr;
-    int remaining;
-    int bytes_written;
-    int r;
-    bulk_data_param_t bulkdata;
-    CsrResult csrResult;
-
-    priv = uf_find_instance(pcli->instance);
-    if (!priv) {
-        unifi_error(priv, "invalid priv\n");
-        return -ENODEV;
-    }
-
-    unifi_trace(priv, UDBG5, "unifi_write: len = %d\n", len);
-
-    if (!pcli->udi_enabled) {
-        unifi_error(priv, "udi disabled\n");
-        return -EINVAL;
-    }
-
-    /*
-     * AMP client sends only one signal at a time, so we can use
-     * unifi_net_data_malloc to save the extra copy.
-     */
-    if (pcli == priv->amp_client) {
-        int signal_size;
-        int sig_id;
-        unsigned char *signal_buf;
-        char *user_data_buf;
-
-        csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], len);
-        if (csrResult != CSR_RESULT_SUCCESS) {
-            unifi_error(priv, "unifi_write: failed to allocate request_data.\n");
-            return -ENOMEM;
-        }
-
-        user_data_buf = (char*)bulkdata.d[0].os_data_ptr;
-
-        /* Get the data from the AMP client. */
-        if (copy_from_user((void*)user_data_buf, p, len)) {
-            unifi_error(priv, "unifi_write: copy from user failed\n");
-            unifi_net_data_free(priv, &bulkdata.d[0]);
-            return -EFAULT;
-        }
-
-        bulkdata.d[1].os_data_ptr = NULL;
-        bulkdata.d[1].data_length = 0;
-
-        /* Number of bytes in the signal */
-        sig_id = GET_SIGNAL_ID(bulkdata.d[0].os_data_ptr);
-        signal_size = len;
-        signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 0);
-        signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 1);
-        if ((signal_size <= 0) || (signal_size > len)) {
-            unifi_error(priv, "unifi_write - Couldn't find length of signal 0x%x\n",
-                        sig_id);
-            unifi_net_data_free(priv, &bulkdata.d[0]);
-            return -EINVAL;
-        }
-
-        unifi_trace(priv, UDBG2, "unifi_write: signal 0x%.4X len:%d\n",
-                    sig_id, signal_size);
-
-       /* Allocate a buffer for the signal */
-       signal_buf = kmemdup(bulkdata.d[0].os_data_ptr, signal_size,
-                               GFP_KERNEL);
-        if (!signal_buf) {
-            unifi_net_data_free(priv, &bulkdata.d[0]);
-            return -ENOMEM;
-        }
-
-        /* Get the signal from the os_data_ptr */
-        signal_buf[5] = (pcli->sender_id >> 8) & 0xff;
-
-        if (signal_size < len) {
-            /* Remove the signal from the os_data_ptr */
-            bulkdata.d[0].data_length -= signal_size;
-            bulkdata.d[0].os_data_ptr += signal_size;
-        } else {
-            bulkdata.d[0].data_length = 0;
-            bulkdata.d[0].os_data_ptr = NULL;
-        }
-
-        /* Send the signal calling the function that uses the wire-formatted signals. */
-        r = ul_send_signal_raw(priv, signal_buf, signal_size, &bulkdata);
-        if (r < 0) {
-            unifi_error(priv, "unifi_write: send failed (%d)\n", r);
-            if (bulkdata.d[0].os_data_ptr != NULL) {
-                unifi_net_data_free(priv, &bulkdata.d[0]);
-            }
-        }
-
-        /* Free the signal buffer and return */
-        kfree(signal_buf);
-        return len;
-    }
-
-    buf = kmalloc(len, GFP_KERNEL);
-    if (!buf) {
-        return -ENOMEM;
-    }
-
-    /* Get the data from the client (SME or Unicli). */
-    if (copy_from_user((void*)buf, p, len)) {
-        unifi_error(priv, "copy from user failed\n");
-        kfree(buf);
-        return -EFAULT;
-    }
-
-    /*
-     * In SME userspace build read() contains a SYS or MGT message.
-     * Note that even though the SME sends one signal at a time, we can not
-     * use unifi_net_data_malloc because in the early stages, before having
-     * initialised the core, it will fail since the I/O block size is unknown.
-     */
-#ifdef CSR_SME_USERSPACE
-    if (pcli->configuration & CLI_SME_USERSPACE) {
-        CsrWifiRouterTransportRecv(priv, buf, len);
-        kfree(buf);
-        return len;
-    }
-#endif
-
-    /* ul_send_signal_raw will  do a sanity check of len against signal content */
-
-    /*
-     * udi_send_signal_raw() and udi_send_signal_unpacked() return the number of bytes consumed.
-     * A write call can pass multiple signal concatenated together.
-     */
-    bytes_written = 0;
-    remaining = len;
-    bufptr = buf;
-    while (remaining > 0)
-    {
-        int r;
-
-        /*
-         * Set the SenderProcessId.
-         * The SignalPrimitiveHeader is the first 3 16-bit words of the signal,
-         * the SenderProcessId is bytes 4,5.
-         * The MSB of the sender ID needs to be set to the client ID.
-         * The LSB is controlled by the SME.
-         */
-        bufptr[5] = (pcli->sender_id >> 8) & 0xff;
-
-        /* use the appropriate interface, depending on the clients' configuration */
-        if (pcli->configuration & CLI_USING_WIRE_FORMAT) {
-            unifi_trace(priv, UDBG1, "unifi_write: call udi_send_signal().\n");
-            r = udi_send_signal_raw(priv, bufptr, remaining);
-        } else {
-            r = udi_send_signal_unpacked(priv, bufptr, remaining);
-        }
-        if (r < 0) {
-            /* Set the return value to the error code */
-            unifi_error(priv, "unifi_write: (udi or sme)_send_signal() returns %d\n", r);
-            bytes_written = r;
-            break;
-        }
-        bufptr += r;
-        remaining -= r;
-        bytes_written += r;
-    }
-
-    kfree(buf);
-
-    return bytes_written;
-} /* unifi_write() */
-
-
-static const char* build_type_to_string(unsigned char build_type)
-{
-    switch (build_type)
-    {
-    case UNIFI_BUILD_NME: return "NME";
-    case UNIFI_BUILD_WEXT: return "WEXT";
-    case UNIFI_BUILD_AP: return "AP";
-    }
-    return "unknown";
-}
-
-
-/*
- * ----------------------------------------------------------------
- *  unifi_ioctl
- *
- *      Ioctl handler for unifi driver.
- *
- * Arguments:
- *  inodep          Pointer to inode structure.
- *  filp            Pointer to file structure.
- *  cmd             Ioctl cmd passed by user.
- *  arg             Ioctl arg passed by user.
- *
- * Returns:
- *      0 on success, -ve error code on error.
- * ----------------------------------------------------------------
- */
-static long
-unifi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-    ul_client_t *pcli = (ul_client_t*)filp->private_data;
-    unifi_priv_t *priv;
-    struct net_device *dev;
-    int r = 0;
-    int int_param, i;
-    u8* buf;
-    CsrResult csrResult;
-#if (defined CSR_SUPPORT_SME)
-    unifi_cfg_command_t cfg_cmd;
-#if (defined CSR_SUPPORT_WEXT)
-    CsrWifiSmeCoexConfig coex_config;
-    unsigned char uchar_param;
-    unsigned char varbind[MAX_VARBIND_LENGTH];
-    int vblen;
-#endif
-#endif
-    unifi_putest_command_t putest_cmd;
-
-    priv = uf_find_instance(pcli->instance);
-    if (!priv) {
-        unifi_error(priv, "ioctl error: unknown instance=%d\n", pcli->instance);
-        r = -ENODEV;
-        goto out;
-    }
-    unifi_trace(priv, UDBG5, "unifi_ioctl: cmd=0x%X, arg=0x%lX\n", cmd, arg);
-
-    switch (cmd) {
-
-      case UNIFI_GET_UDI_ENABLE:
-        unifi_trace(priv, UDBG4, "UniFi Get UDI Enable\n");
-
-        down(&priv->udi_logging_mutex);
-        int_param = (priv->logging_client == NULL) ? 0 : 1;
-        up(&priv->udi_logging_mutex);
-
-        if (put_user(int_param, (int*)arg))
-        {
-            unifi_error(priv, "UNIFI_GET_UDI_ENABLE: Failed to copy to user\n");
-            r = -EFAULT;
-            goto out;
-        }
-        break;
-
-      case UNIFI_SET_UDI_ENABLE:
-        unifi_trace(priv, UDBG4, "UniFi Set UDI Enable\n");
-        if (get_user(int_param, (int*)arg))
-        {
-            unifi_error(priv, "UNIFI_SET_UDI_ENABLE: Failed to copy from user\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-        if (log_hip_signals) {
-            unifi_error(priv, "omnicli cannot be used when log_hip_signals is used\n");
-            r = -EFAULT;
-            goto out;
-        }
-#endif
-
-        down(&priv->udi_logging_mutex);
-        if (int_param) {
-            pcli->event_hook = udi_log_event;
-            unifi_set_udi_hook(priv->card, logging_handler);
-            /* Log all signals by default */
-            for (i = 0; i < SIG_FILTER_SIZE; i++) {
-                pcli->signal_filter[i] = 0xFFFF;
-            }
-            priv->logging_client = pcli;
-
-        } else {
-            priv->logging_client = NULL;
-            pcli->event_hook = NULL;
-        }
-        up(&priv->udi_logging_mutex);
-
-        break;
-
-      case UNIFI_SET_MIB:
-        unifi_trace(priv, UDBG4, "UniFi Set MIB\n");
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-        /* Read first 2 bytes and check length */
-        if (copy_from_user((void*)varbind, (void*)arg, 2)) {
-            unifi_error(priv,
-                        "UNIFI_SET_MIB: Failed to copy in varbind header\n");
-            r = -EFAULT;
-            goto out;
-        }
-        vblen = varbind[1];
-        if ((vblen + 2) > MAX_VARBIND_LENGTH) {
-            unifi_error(priv,
-                        "UNIFI_SET_MIB: Varbind too long (%d, limit %d)\n",
-                        (vblen+2), MAX_VARBIND_LENGTH);
-            r = -EINVAL;
-            goto out;
-        }
-        /* Read rest of varbind */
-        if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) {
-            unifi_error(priv, "UNIFI_SET_MIB: Failed to copy in varbind\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        /* send to SME */
-        vblen += 2;
-        r = sme_mgt_mib_set(priv, varbind, vblen);
-        if (r) {
-            goto out;
-        }
-#else
-        unifi_notice(priv, "UNIFI_SET_MIB: Unsupported.\n");
-#endif /* CSR_SUPPORT_WEXT */
-        break;
-
-      case UNIFI_GET_MIB:
-        unifi_trace(priv, UDBG4, "UniFi Get MIB\n");
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-        /* Read first 2 bytes and check length */
-        if (copy_from_user((void*)varbind, (void*)arg, 2)) {
-            unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind header\n");
-            r = -EFAULT;
-            goto out;
-        }
-        vblen = varbind[1];
-        if ((vblen+2) > MAX_VARBIND_LENGTH) {
-            unifi_error(priv, "UNIFI_GET_MIB: Varbind too long (%d, limit %d)\n",
-                        (vblen+2), MAX_VARBIND_LENGTH);
-            r = -EINVAL;
-            goto out;
-        }
-        /* Read rest of varbind */
-        if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) {
-            unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        vblen += 2;
-        r = sme_mgt_mib_get(priv, varbind, &vblen);
-        if (r) {
-            goto out;
-        }
-        /* copy out varbind */
-        if (vblen > MAX_VARBIND_LENGTH) {
-            unifi_error(priv,
-                        "UNIFI_GET_MIB: Varbind result too long (%d, limit %d)\n",
-                        vblen, MAX_VARBIND_LENGTH);
-            r = -EINVAL;
-            goto out;
-        }
-        if (copy_to_user((void*)arg, varbind, vblen)) {
-            r = -EFAULT;
-            goto out;
-        }
-#else
-        unifi_notice(priv, "UNIFI_GET_MIB: Unsupported.\n");
-#endif /* CSR_SUPPORT_WEXT */
-        break;
-
-      case UNIFI_CFG:
-#if (defined CSR_SUPPORT_SME)
-        if (get_user(cfg_cmd, (unifi_cfg_command_t*)arg))
-        {
-            unifi_error(priv, "UNIFI_CFG: Failed to get the command\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        unifi_trace(priv, UDBG1, "UNIFI_CFG: Command is %d (t=%u) sz=%d\n",
-                    cfg_cmd, jiffies_to_msecs(jiffies), sizeof(unifi_cfg_command_t));
-        switch (cfg_cmd) {
-          case UNIFI_CFG_POWER:
-            r = unifi_cfg_power(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_POWERSAVE:
-            r = unifi_cfg_power_save(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_POWERSUPPLY:
-            r = unifi_cfg_power_supply(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_FILTER:
-            r = unifi_cfg_packet_filters(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_GET:
-            r = unifi_cfg_get_info(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_WMM_QOSINFO:
-            r = unifi_cfg_wmm_qos_info(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_WMM_ADDTS:
-            r = unifi_cfg_wmm_addts(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_WMM_DELTS:
-            r = unifi_cfg_wmm_delts(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_STRICT_DRAFT_N:
-            r = unifi_cfg_strict_draft_n(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_CFG_ENABLE_OKC:
-            r = unifi_cfg_enable_okc(priv, (unsigned char*)arg);
-            break;
-#ifdef CSR_SUPPORT_SME
-          case UNIFI_CFG_CORE_DUMP:
-            CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, CSR_WIFI_SME_CONTROL_INDICATION_ERROR);
-            unifi_trace(priv, UDBG2, "UNIFI_CFG_CORE_DUMP: sent wifi off indication\n");
-            break;
-#endif
-#ifdef CSR_SUPPORT_WEXT_AP
-          case UNIFI_CFG_SET_AP_CONFIG:
-            r= unifi_cfg_set_ap_config(priv, (unsigned char*)arg);
-            break;
-#endif
-          default:
-            unifi_error(priv, "UNIFI_CFG: Unknown Command (%d)\n", cfg_cmd);
-            r = -EINVAL;
-            goto out;
-        }
-#endif
-
-        break;
-
-      case UNIFI_PUTEST:
-        if (get_user(putest_cmd, (unifi_putest_command_t*)arg))
-        {
-            unifi_error(priv, "UNIFI_PUTEST: Failed to get the command\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        unifi_trace(priv, UDBG1, "UNIFI_PUTEST: Command is %s\n",
-                    trace_putest_cmdid(putest_cmd));
-        switch (putest_cmd) {
-          case UNIFI_PUTEST_START:
-            r = unifi_putest_start(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_STOP:
-            r = unifi_putest_stop(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_SET_SDIO_CLOCK:
-            r = unifi_putest_set_sdio_clock(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_CMD52_READ:
-            r = unifi_putest_cmd52_read(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_CMD52_BLOCK_READ:
-            r = unifi_putest_cmd52_block_read(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_CMD52_WRITE:
-            r = unifi_putest_cmd52_write(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_DL_FW:
-            r = unifi_putest_dl_fw(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_DL_FW_BUFF:
-            r = unifi_putest_dl_fw_buff(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_COREDUMP_PREPARE:
-            r = unifi_putest_coredump_prepare(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_GP_READ16:
-            r = unifi_putest_gp_read16(priv, (unsigned char*)arg);
-            break;
-          case UNIFI_PUTEST_GP_WRITE16:
-            r = unifi_putest_gp_write16(priv, (unsigned char*)arg);
-            break;
-          default:
-            unifi_error(priv, "UNIFI_PUTEST: Unknown Command (%d)\n", putest_cmd);
-            r = -EINVAL;
-            goto out;
-        }
-
-        break;
-      case UNIFI_BUILD_TYPE:
-        unifi_trace(priv, UDBG2, "UNIFI_BUILD_TYPE userspace=%s\n", build_type_to_string(*(unsigned char*)arg));
-#ifndef CSR_SUPPORT_WEXT_AP
-        if (UNIFI_BUILD_AP == *(unsigned char*)arg)
-        {
-            unifi_error(priv, "Userspace has AP support, which is incompatible\n");
-        }
-#endif
-
-#ifndef CSR_SUPPORT_WEXT
-        if (UNIFI_BUILD_WEXT == *(unsigned char*)arg)
-        {
-            unifi_error(priv, "Userspace has WEXT support, which is incompatible\n");
-        }
-#endif
-        break;
-      case UNIFI_INIT_HW:
-        unifi_trace(priv, UDBG2, "UNIFI_INIT_HW.\n");
-        priv->init_progress = UNIFI_INIT_NONE;
-
-#if defined(CSR_SUPPORT_WEXT) || defined (CSR_NATIVE_LINUX)
-        /* At this point we are ready to start the SME. */
-        r = sme_mgt_wifi_on(priv);
-        if (r) {
-            goto out;
-        }
-#endif
-
-        break;
-
-      case UNIFI_INIT_NETDEV:
-        {
-            /* get the proper interfaceTagId */
-            u16 interfaceTag=0;
-            netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-            dev = priv->netdev[interfaceTag];
-            unifi_trace(priv, UDBG2, "UNIFI_INIT_NETDEV.\n");
-
-            if (copy_from_user((void*)dev->dev_addr, (void*)arg, 6)) {
-                r = -EFAULT;
-                goto out;
-            }
-
-            /* Attach the network device to the stack */
-            if (!interfacePriv->netdev_registered)
-            {
-                r = uf_register_netdev(priv, interfaceTag);
-                if (r) {
-                    unifi_error(priv, "Failed to register the network device.\n");
-                    goto out;
-                }
-            }
-
-            /* Apply scheduled interrupt mode, if requested by module param */
-            if (run_bh_once != -1) {
-                unifi_set_interrupt_mode(priv->card, (u32)run_bh_once);
-            }
-
-            priv->init_progress = UNIFI_INIT_COMPLETED;
-
-            /* Firmware initialisation is complete, so let the SDIO bus
-             * clock be raised when convienent to the core.
-             */
-            unifi_request_max_sdio_clock(priv->card);
-
-#ifdef CSR_SUPPORT_WEXT
-            /* Notify the Android wpa_supplicant that we are ready */
-            wext_send_started_event(priv);
-#endif
-
-            unifi_info(priv, "UniFi ready\n");
-
-#ifdef ANDROID_BUILD
-            /* Release the wakelock */
-            unifi_trace(priv, UDBG1, "netdev_init: release wake lock\n");
-            wake_unlock(&unifi_sdio_wake_lock);
-#endif
-#ifdef CSR_NATIVE_SOFTMAC /* For softmac dev, force-enable the network interface rather than wait for a connected-ind */
-            {
-                struct net_device *dev = priv->netdev[interfaceTag];
-#ifdef CSR_SUPPORT_WEXT
-                interfacePriv->wait_netdev_change = TRUE;
-#endif
-                netif_carrier_on(dev);
-            }
-#endif
-        }
-        break;
-      case UNIFI_GET_INIT_STATUS:
-        unifi_trace(priv, UDBG2, "UNIFI_GET_INIT_STATUS.\n");
-        if (put_user(priv->init_progress, (int*)arg))
-        {
-            printk(KERN_ERR "UNIFI_GET_INIT_STATUS: Failed to copy to user\n");
-            r = -EFAULT;
-            goto out;
-        }
-        break;
-
-      case UNIFI_KICK:
-        unifi_trace(priv, UDBG4, "Kick UniFi\n");
-        unifi_sdio_interrupt_handler(priv->card);
-        break;
-
-      case UNIFI_SET_DEBUG:
-        unifi_debug = arg;
-        unifi_trace(priv, UDBG4, "unifi_debug set to %d\n", unifi_debug);
-        break;
-
-      case UNIFI_SET_TRACE:
-        /* no longer supported */
-        r = -EINVAL;
-        break;
-
-
-      case UNIFI_SET_UDI_LOG_MASK:
-        {
-            unifiio_filter_t udi_filter;
-            uint16_t *sig_ids_addr;
-#define UF_MAX_SIG_IDS  128     /* Impose a sensible limit */
-
-            if (copy_from_user((void*)(&udi_filter), (void*)arg, sizeof(udi_filter))) {
-                r = -EFAULT;
-                goto out;
-            }
-            if ((udi_filter.action < UfSigFil_AllOn) ||
-                (udi_filter.action > UfSigFil_SelectOff))
-            {
-                printk(KERN_WARNING
-                       "UNIFI_SET_UDI_LOG_MASK: Bad action value: %d\n",
-                       udi_filter.action);
-                r = -EINVAL;
-                goto out;
-            }
-            /* No signal list for "All" actions */
-            if ((udi_filter.action == UfSigFil_AllOn) ||
-                (udi_filter.action == UfSigFil_AllOff))
-            {
-                udi_filter.num_sig_ids = 0;
-            }
-
-            if (udi_filter.num_sig_ids > UF_MAX_SIG_IDS) {
-                printk(KERN_WARNING
-                       "UNIFI_SET_UDI_LOG_MASK: too many signal ids (%d, max %d)\n",
-                       udi_filter.num_sig_ids, UF_MAX_SIG_IDS);
-                r = -EINVAL;
-                goto out;
-            }
-
-            /* Copy in signal id list if given */
-            if (udi_filter.num_sig_ids > 0) {
-                /* Preserve userspace address of sig_ids array */
-                sig_ids_addr = udi_filter.sig_ids;
-                /* Allocate kernel memory for sig_ids and copy to it */
-                udi_filter.sig_ids =
-                    kmalloc(udi_filter.num_sig_ids * sizeof(uint16_t), GFP_KERNEL);
-                if (!udi_filter.sig_ids) {
-                    r = -ENOMEM;
-                    goto out;
-                }
-                if (copy_from_user((void*)udi_filter.sig_ids,
-                                   (void*)sig_ids_addr,
-                                   udi_filter.num_sig_ids * sizeof(uint16_t)))
-                {
-                    kfree(udi_filter.sig_ids);
-                    r = -EFAULT;
-                    goto out;
-                }
-            }
-
-            udi_set_log_filter(pcli, &udi_filter);
-
-            if (udi_filter.num_sig_ids > 0) {
-                kfree(udi_filter.sig_ids);
-            }
-        }
-        break;
-
-      case UNIFI_SET_AMP_ENABLE:
-        unifi_trace(priv, UDBG4, "UniFi Set AMP Enable\n");
-        if (get_user(int_param, (int*)arg))
-        {
-            unifi_error(priv, "UNIFI_SET_AMP_ENABLE: Failed to copy from user\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        if (int_param) {
-            priv->amp_client = pcli;
-        } else {
-            priv->amp_client = NULL;
-        }
-
-        int_param = 0;
-        buf = (u8*)&int_param;
-        buf[0] = UNIFI_SOFT_COMMAND_Q_LENGTH - 1;
-        buf[1] = UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1;
-        if (copy_to_user((void*)arg, &int_param, sizeof(int))) {
-            r = -EFAULT;
-            goto out;
-        }
-        break;
-
-      case UNIFI_SET_UDI_SNAP_MASK:
-        {
-            unifiio_snap_filter_t snap_filter;
-
-            if (copy_from_user((void*)(&snap_filter), (void*)arg, sizeof(snap_filter))) {
-                r = -EFAULT;
-                goto out;
-            }
-
-            if (pcli->snap_filter.count) {
-                pcli->snap_filter.count = 0;
-                kfree(pcli->snap_filter.protocols);
-            }
-
-            if (snap_filter.count == 0) {
-                break;
-            }
-
-            pcli->snap_filter.protocols = kmalloc(snap_filter.count * sizeof(u16), GFP_KERNEL);
-            if (!pcli->snap_filter.protocols) {
-                r = -ENOMEM;
-                goto out;
-            }
-            if (copy_from_user((void*)pcli->snap_filter.protocols,
-                               (void*)snap_filter.protocols,
-                               snap_filter.count * sizeof(u16)))
-            {
-                kfree(pcli->snap_filter.protocols);
-                r = -EFAULT;
-                goto out;
-            }
-
-            pcli->snap_filter.count = snap_filter.count;
-
-        }
-        break;
-
-      case UNIFI_SME_PRESENT:
-        {
-            u8 ind;
-            unifi_trace(priv, UDBG4, "UniFi SME Present IOCTL.\n");
-            if (copy_from_user((void*)(&int_param), (void*)arg, sizeof(int)))
-            {
-                printk(KERN_ERR "UNIFI_SME_PRESENT: Failed to copy from user\n");
-                r = -EFAULT;
-                goto out;
-            }
-
-            priv->sme_is_present = int_param;
-            if (priv->sme_is_present == 1) {
-                ind = CONFIG_SME_PRESENT;
-            } else {
-                ind = CONFIG_SME_NOT_PRESENT;
-            }
-            /* Send an indication to the helper app. */
-            ul_log_config_ind(priv, &ind, sizeof(u8));
-        }
-        break;
-
-      case UNIFI_CFG_PERIOD_TRAFFIC:
-      {
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-          CsrWifiSmeCoexConfig coexConfig;
-#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
-        unifi_trace(priv, UDBG4, "UniFi Configure Periodic Traffic.\n");
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-        if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) {
-            unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        if (uchar_param == 0) {
-            r = sme_mgt_coex_config_get(priv, &coexConfig);
-            if (r) {
-                unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Get unifi_CoexInfoValue failed.\n");
-                goto out;
-            }
-            if (copy_to_user((void*)(arg + 1),
-                             (void*)&coexConfig,
-                             sizeof(CsrWifiSmeCoexConfig))) {
-                r = -EFAULT;
-                goto out;
-            }
-            goto out;
-        }
-
-        if (copy_from_user((void*)(&coex_config), (void*)(arg + 1), sizeof(CsrWifiSmeCoexConfig)))
-        {
-            unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n");
-            r = -EFAULT;
-            goto out;
-        }
-
-        coexConfig = coex_config;
-        r = sme_mgt_coex_config_set(priv, &coexConfig);
-        if (r) {
-            unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Set unifi_CoexInfoValue failed.\n");
-            goto out;
-        }
-
-#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
-        break;
-      }
-      case UNIFI_CFG_UAPSD_TRAFFIC:
-        unifi_trace(priv, UDBG4, "UniFi Configure U-APSD Mask.\n");
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-        if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) {
-            unifi_error(priv, "UNIFI_CFG_UAPSD_TRAFFIC: Failed to copy from user\n");
-            r = -EFAULT;
-            goto out;
-        }
-        unifi_trace(priv, UDBG4, "New U-APSD Mask: 0x%x\n", uchar_param);
-#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
-        break;
-
-#ifndef UNIFI_DISABLE_COREDUMP
-      case UNIFI_COREDUMP_GET_REG:
-        unifi_trace(priv, UDBG4, "Mini-coredump data request\n");
-        {
-            unifiio_coredump_req_t dump_req;    /* Public OS layer structure */
-            unifi_coredump_req_t priv_req;      /* Private HIP structure */
-
-            if (copy_from_user((void*)(&dump_req), (void*)arg, sizeof(dump_req))) {
-                r = -EFAULT;
-                goto out;
-            }
-            memset(&priv_req, 0, sizeof(priv_req));
-            priv_req.index = dump_req.index;
-            priv_req.offset = dump_req.offset;
-
-            /* Convert OS-layer's XAP memory space ID to HIP's ID in case they differ */
-            switch (dump_req.space) {
-                case UNIFIIO_COREDUMP_MAC_REG: priv_req.space = UNIFI_COREDUMP_MAC_REG; break;
-                case UNIFIIO_COREDUMP_PHY_REG: priv_req.space = UNIFI_COREDUMP_PHY_REG; break;
-                case UNIFIIO_COREDUMP_SH_DMEM: priv_req.space = UNIFI_COREDUMP_SH_DMEM; break;
-                case UNIFIIO_COREDUMP_MAC_DMEM: priv_req.space = UNIFI_COREDUMP_MAC_DMEM; break;
-                case UNIFIIO_COREDUMP_PHY_DMEM: priv_req.space = UNIFI_COREDUMP_PHY_DMEM; break;
-                case UNIFIIO_COREDUMP_TRIGGER_MAGIC: priv_req.space = UNIFI_COREDUMP_TRIGGER_MAGIC; break;
-                default:
-                  r = -EINVAL;
-                  goto out;
-            }
-
-            if (priv_req.space == UNIFI_COREDUMP_TRIGGER_MAGIC) {
-                /* Force a coredump grab now */
-                unifi_trace(priv, UDBG2, "UNIFI_COREDUMP_GET_REG: Force capture\n");
-                csrResult = unifi_coredump_capture(priv->card, &priv_req);
-                r = CsrHipResultToStatus(csrResult);
-                unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: status %d\n", r);
-            } else {
-                /* Retrieve the appropriate register entry */
-                csrResult = unifi_coredump_get_value(priv->card, &priv_req);
-                r = CsrHipResultToStatus(csrResult);
-                if (r) {
-                    unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: Status %d\n", r);
-                    goto out;
-                }
-                /* Update the OS-layer structure with values returned in the private */
-                dump_req.value = priv_req.value;
-                dump_req.timestamp = priv_req.timestamp;
-                dump_req.requestor = priv_req.requestor;
-                dump_req.serial = priv_req.serial;
-                dump_req.chip_ver = priv_req.chip_ver;
-                dump_req.fw_ver = priv_req.fw_ver;
-                dump_req.drv_build = 0;
-
-                unifi_trace(priv, UDBG6,
-                            "Dump: %d (seq %d): V:0x%04x (%d) @0x%02x:%04x = 0x%04x\n",
-                            dump_req.index, dump_req.serial,
-                            dump_req.chip_ver, dump_req.drv_build,
-                            dump_req.space, dump_req.offset, dump_req.value);
-            }
-            if (copy_to_user((void*)arg, (void*)&dump_req, sizeof(dump_req))) {
-                r = -EFAULT;
-                goto out;
-            }
-        }
-        break;
-#endif
-      default:
-        r = -EINVAL;
-    }
-
-out:
-    return (long)r;
-} /* unifi_ioctl() */
-
-
-
-static unsigned int
-unifi_poll(struct file *filp, poll_table *wait)
-{
-    ul_client_t *pcli = (ul_client_t*)filp->private_data;
-    unsigned int mask = 0;
-    int ready;
-
-    ready = !list_empty(&pcli->udi_log);
-
-    poll_wait(filp, &pcli->udi_wq, wait);
-
-    if (ready) {
-        mask |= POLLIN | POLLRDNORM;    /* readable */
-    }
-
-    return mask;
-} /* unifi_poll() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  udi_set_log_filter
- *
- *      Configure the bit mask that determines which signal primitives are
- *      passed to the logging process.
- *
- *  Arguments:
- *      pcli            Pointer to the client to configure.
- *      udi_filter      Pointer to a unifiio_filter_t containing instructions.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      SigGetFilterPos() returns a 32-bit value that contains an index and a
- *      mask for accessing a signal_filter array. The top 16 bits specify an
- *      index into a signal_filter, the bottom 16 bits specify a mask to
- *      apply.
- * ---------------------------------------------------------------------------
- */
-static void
-udi_set_log_filter(ul_client_t *pcli, unifiio_filter_t *udi_filter)
-{
-    u32 filter_pos;
-    int i;
-
-    if (udi_filter->action == UfSigFil_AllOn)
-    {
-        for (i = 0; i < SIG_FILTER_SIZE; i++) {
-            pcli->signal_filter[i] = 0xFFFF;
-        }
-    }
-    else if (udi_filter->action == UfSigFil_AllOff)
-    {
-        for (i = 0; i < SIG_FILTER_SIZE; i++) {
-            pcli->signal_filter[i] = 0;
-        }
-    }
-    else if (udi_filter->action == UfSigFil_SelectOn)
-    {
-        for (i = 0; i < udi_filter->num_sig_ids; i++) {
-            filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]);
-            if (filter_pos == 0xFFFFFFFF)
-            {
-                printk(KERN_WARNING
-                       "Unrecognised signal id (0x%X) specifed in logging filter\n",
-                       udi_filter->sig_ids[i]);
-            } else {
-                pcli->signal_filter[filter_pos >> 16] |= (filter_pos & 0xFFFF);
-            }
-        }
-    }
-    else if (udi_filter->action == UfSigFil_SelectOff)
-    {
-        for (i = 0; i < udi_filter->num_sig_ids; i++) {
-            filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]);
-            if (filter_pos == 0xFFFFFFFF)
-            {
-                printk(KERN_WARNING
-                       "Unrecognised signal id (0x%X) specifed in logging filter\n",
-                       udi_filter->sig_ids[i]);
-            } else {
-                pcli->signal_filter[filter_pos >> 16] &= ~(filter_pos & 0xFFFF);
-            }
-        }
-    }
-
-} /* udi_set_log_filter() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  udi_log_event
- *
- *      Callback function to be registered as the UDI hook callback.
- *      Copies the signal content into a new udi_log_t struct and adds
- *      it to the read queue for this UDI client.
- *
- *  Arguments:
- *      pcli            A pointer to the client instance.
- *      signal          Pointer to the received signal.
- *      signal_len      Size of the signal structure in bytes.
- *      bulkdata        Pointers to any associated bulk data.
- *      dir             Direction of the signal. Zero means from host,
- *                      non-zero means to host.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-udi_log_event(ul_client_t *pcli,
-              const u8 *signal, int signal_len,
-              const bulk_data_param_t *bulkdata,
-              int dir)
-{
-    udi_log_t *logptr;
-    u8 *p;
-    int i;
-    int total_len;
-    udi_msg_t *msgptr;
-    u32 filter_pos;
-#ifdef OMNICLI_LINUX_EXTRA_LOG
-    static volatile unsigned int printk_cpu = UINT_MAX;
-    unsigned long long t;
-    unsigned long nanosec_rem;
-    unsigned long n_1000;
-#endif
-
-    /* Just a sanity check */
-    if ((signal == NULL) || (signal_len <= 0)) {
-        return;
-    }
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-    /* When HIP offline signal logging is enabled, omnicli cannot run */
-    if (log_hip_signals)
-    {
-        /* Add timestamp */
-        if (log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP)
-        {
-            int timestamp = jiffies_to_msecs(jiffies);
-            unifi_debug_log_to_buf("T:");
-            unifi_debug_log_to_buf("%04X%04X ", *(((u16*)&timestamp) + 1),
-                                   *(u16*)&timestamp);
-        }
-
-        /* Add signal */
-        unifi_debug_log_to_buf("S%s:%04X R:%04X D:%04X ",
-                               dir ? "T" : "F",
-                               *(u16*)signal,
-                               *(u16*)(signal + 2),
-                               *(u16*)(signal + 4));
-        unifi_debug_hex_to_buf(signal + 6, signal_len - 6);
-
-        /* Add bulk data (assume 1 bulk data per signal) */
-        if ((log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA) &&
-            (bulkdata->d[0].data_length > 0))
-        {
-            unifi_debug_log_to_buf("\nD:");
-            unifi_debug_hex_to_buf(bulkdata->d[0].os_data_ptr, bulkdata->d[0].data_length);
-        }
-        unifi_debug_log_to_buf("\n");
-
-        return;
-    }
-#endif
-
-#ifdef CSR_NATIVE_LINUX
-    uf_native_process_udi_signal(pcli, signal, signal_len, bulkdata, dir);
-#endif
-
-    /*
-     * Apply the logging filter - only report signals that have their
-     * bit set in the filter mask.
-     */
-    filter_pos = SigGetFilterPos(GET_SIGNAL_ID(signal));
-
-    if ((filter_pos != 0xFFFFFFFF) &&
-        ((pcli->signal_filter[filter_pos >> 16] & (filter_pos & 0xFFFF)) == 0))
-    {
-        /* Signal is not wanted by client */
-        return;
-    }
-
-
-    /* Calculate the buffer we need to store signal plus bulk data */
-    total_len = signal_len;
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-        total_len += bulkdata->d[i].data_length;
-    }
-
-    /* Allocate log structure plus actual signal. */
-    logptr = kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL);
-
-    if (logptr == NULL) {
-        printk(KERN_ERR
-               "Failed to allocate %lu bytes for a UDI log record\n",
-               (long unsigned int)(sizeof(udi_log_t) + total_len));
-        return;
-    }
-
-    /* Fill in udi_log struct */
-    INIT_LIST_HEAD(&logptr->q);
-    msgptr = &logptr->msg;
-    msgptr->length = sizeof(udi_msg_t) + total_len;
-#ifdef OMNICLI_LINUX_EXTRA_LOG
-    t = cpu_clock(printk_cpu);
-    nanosec_rem = do_div(t, 1000000000);
-    n_1000 = nanosec_rem/1000;
-    msgptr->timestamp = (t <<10 ) | ((unsigned long)(n_1000 >> 10) & 0x3ff);
-#else
-    msgptr->timestamp = jiffies_to_msecs(jiffies);
-#endif
-    msgptr->direction = dir;
-    msgptr->signal_length = signal_len;
-
-    /* Copy signal and bulk data to the log */
-    p = (u8 *)(msgptr + 1);
-    memcpy(p, signal, signal_len);
-    p += signal_len;
-
-    /* Append any bulk data */
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-        int len = bulkdata->d[i].data_length;
-
-        /*
-         * Len here might not be the same as the length in the bulk data slot.
-         * The slot length will always be even, but len could be odd.
-         */
-        if (len > 0) {
-            if (bulkdata->d[i].os_data_ptr) {
-                memcpy(p, bulkdata->d[i].os_data_ptr, len);
-            } else {
-                memset(p, 0, len);
-            }
-            p += len;
-        }
-    }
-
-    /* Add to tail of log queue */
-    if (down_interruptible(&pcli->udi_sem)) {
-        printk(KERN_WARNING "udi_log_event_q: Failed to get udi sem\n");
-        kfree(logptr);
-        return;
-    }
-    list_add_tail(&logptr->q, &pcli->udi_log);
-    up(&pcli->udi_sem);
-
-    /* Wake any waiting user process */
-    wake_up_interruptible(&pcli->udi_wq);
-
-} /* udi_log_event() */
-
-#ifdef CSR_SME_USERSPACE
-int
-uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length)
-{
-    udi_log_t *logptr;
-    udi_msg_t *msgptr;
-    u8 *p;
-
-    /* Just a sanity check */
-    if ((buffer == NULL) || (length <= 0)) {
-        return -EINVAL;
-    }
-
-    /* Allocate log structure plus actual signal. */
-    logptr = kmalloc(sizeof(udi_log_t) + length, GFP_ATOMIC);
-    if (logptr == NULL) {
-        unifi_error(priv, "Failed to allocate %d bytes for an SME message\n",
-                    sizeof(udi_log_t) + length);
-                    kfree(buffer);
-                    return -ENOMEM;
-    }
-
-    /* Fill in udi_log struct */
-    INIT_LIST_HEAD(&logptr->q);
-    msgptr = &logptr->msg;
-    msgptr->length = sizeof(udi_msg_t) + length;
-    msgptr->signal_length = length;
-
-    /* Copy signal and bulk data to the log */
-    p = (u8 *)(msgptr + 1);
-    memcpy(p, buffer, length);
-
-    /* Add to tail of log queue */
-    down(&udi_mutex);
-    if (priv->sme_cli == NULL) {
-        kfree(logptr);
-        kfree(buffer);
-        up(&udi_mutex);
-        unifi_info(priv, "Message for the SME dropped, SME has gone away\n");
-        return 0;
-    }
-
-    down(&priv->sme_cli->udi_sem);
-    list_add_tail(&logptr->q, &priv->sme_cli->udi_log);
-    up(&priv->sme_cli->udi_sem);
-
-    /* Wake any waiting user process */
-    wake_up_interruptible(&priv->sme_cli->udi_wq);
-    up(&udi_mutex);
-
-    /* It is our responsibility to free the buffer allocated in build_packed_*() */
-    kfree(buffer);
-
-    return 0;
-
-} /* uf_sme_queue_message() */
-#endif
-
-/*
- ****************************************************************************
- *
- *      Driver instantiation
- *
- ****************************************************************************
- */
-static const struct file_operations unifi_fops = {
-    .owner      = THIS_MODULE,
-    .open       = unifi_open,
-    .release    = unifi_release,
-    .read       = unifi_read,
-    .write      = unifi_write,
-    .unlocked_ioctl = unifi_ioctl,
-    .poll       = unifi_poll,
-};
-
-static dev_t unifi_first_devno;
-static struct class *unifi_class;
-
-
-int uf_create_device_nodes(unifi_priv_t *priv, int bus_id)
-{
-    dev_t devno;
-    int r;
-
-    cdev_init(&priv->unifi_cdev, &unifi_fops);
-
-    /* cdev_init() should set the cdev owner, but it does not */
-    priv->unifi_cdev.owner = THIS_MODULE;
-
-    devno = MKDEV(MAJOR(unifi_first_devno),
-                  MINOR(unifi_first_devno) + (bus_id * 2));
-    r = cdev_add(&priv->unifi_cdev, devno, 1);
-    if (r) {
-        return r;
-    }
-
-#ifdef SDIO_EXPORTS_STRUCT_DEVICE
-    if (!device_create(unifi_class, priv->unifi_device,
-                       devno, priv, "unifi%d", bus_id)) {
-#else
-    priv->unifi_device = device_create(unifi_class, NULL,
-                                       devno, priv, "unifi%d", bus_id);
-    if (priv->unifi_device == NULL) {
-#endif /* SDIO_EXPORTS_STRUCT_DEVICE */
-
-        cdev_del(&priv->unifi_cdev);
-        return -EINVAL;
-    }
-
-    cdev_init(&priv->unifiudi_cdev, &unifi_fops);
-
-    /* cdev_init() should set the cdev owner, but it does not */
-    priv->unifiudi_cdev.owner = THIS_MODULE;
-
-    devno = MKDEV(MAJOR(unifi_first_devno),
-                  MINOR(unifi_first_devno) + (bus_id * 2) + 1);
-    r = cdev_add(&priv->unifiudi_cdev, devno, 1);
-    if (r) {
-        device_destroy(unifi_class, priv->unifi_cdev.dev);
-        cdev_del(&priv->unifi_cdev);
-        return r;
-    }
-
-    if (!device_create(unifi_class,
-#ifdef SDIO_EXPORTS_STRUCT_DEVICE
-                       priv->unifi_device,
-#else
-                       NULL,
-#endif /* SDIO_EXPORTS_STRUCT_DEVICE */
-                       devno, priv, "unifiudi%d", bus_id)) {
-        device_destroy(unifi_class, priv->unifi_cdev.dev);
-        cdev_del(&priv->unifiudi_cdev);
-        cdev_del(&priv->unifi_cdev);
-        return -EINVAL;
-    }
-
-    return 0;
-}
-
-
-void uf_destroy_device_nodes(unifi_priv_t *priv)
-{
-       device_destroy(unifi_class, priv->unifiudi_cdev.dev);
-       device_destroy(unifi_class, priv->unifi_cdev.dev);
-       cdev_del(&priv->unifiudi_cdev);
-       cdev_del(&priv->unifi_cdev);
-}
-
-
-
-/*
- * ----------------------------------------------------------------
- *  uf_create_debug_device
- *
- *      Allocates device numbers for unifi character device nodes
- *      and creates a unifi class in sysfs
- *
- * Arguments:
- *  fops          Pointer to the char device operations structure.
- *
- * Returns:
- *      0 on success, -ve error code on error.
- * ----------------------------------------------------------------
- */
-static int
-uf_create_debug_device(const struct file_operations *fops)
-{
-    int ret;
-
-    /* Allocate two device numbers for each device. */
-    ret = alloc_chrdev_region(&unifi_first_devno, 0, MAX_UNIFI_DEVS*2, UNIFI_NAME);
-    if (ret) {
-        unifi_error(NULL, "Failed to add alloc dev numbers: %d\n", ret);
-        return ret;
-    }
-
-    /* Create a UniFi class */
-    unifi_class = class_create(THIS_MODULE, UNIFI_NAME);
-    if (IS_ERR(unifi_class)) {
-        unifi_error(NULL, "Failed to create UniFi class\n");
-
-        /* Release device numbers */
-        unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2);
-        unifi_first_devno = 0;
-        return -EINVAL;
-    }
-
-    return 0;
-} /* uf_create_debug_device() */
-
-
-/*
- * ----------------------------------------------------------------
- *  uf_remove_debug_device
- *
- *      Destroys the unifi class and releases the allocated
- *      device numbers for unifi character device nodes.
- *
- * Arguments:
- *
- * Returns:
- * ----------------------------------------------------------------
- */
-static void
-uf_remove_debug_device(void)
-{
-    /* Destroy the UniFi class */
-    class_destroy(unifi_class);
-
-    /* Release device numbers */
-    unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2);
-    unifi_first_devno = 0;
-
-} /* uf_remove_debug_device() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *
- *      Module loading.
- *
- * ---------------------------------------------------------------------------
- */
-int __init
-unifi_load(void)
-{
-    int r;
-
-    printk("UniFi SDIO Driver: %s %s %s\n",
-            CSR_WIFI_VERSION,
-           __DATE__, __TIME__);
-
-#ifdef CSR_SME_USERSPACE
-#ifdef CSR_SUPPORT_WEXT
-    printk("CSR SME with WEXT support\n");
-#else
-    printk("CSR SME no WEXT support\n");
-#endif /* CSR_SUPPORT_WEXT */
-#endif /* CSR_SME_USERSPACE */
-
-#ifdef CSR_NATIVE_LINUX
-#ifdef CSR_SUPPORT_WEXT
-#error WEXT unsupported in the native driver
-#endif
-    printk("CSR native no WEXT support\n");
-#endif
-#ifdef CSR_WIFI_SPLIT_PATCH
-    printk("Split patch support\n");
-#endif
-    printk("Kernel %d.%d.%d\n",
-           ((LINUX_VERSION_CODE) >> 16) & 0xff,
-           ((LINUX_VERSION_CODE) >> 8) & 0xff,
-           (LINUX_VERSION_CODE) & 0xff);
-    /*
-     * Instantiate the /dev/unifi* device nodes.
-     * We must do this before registering with the SDIO driver because it
-     * will immediately call the "insert" callback if the card is
-     * already present.
-     */
-    r = uf_create_debug_device(&unifi_fops);
-    if (r) {
-        return r;
-    }
-
-    /* Now register with the SDIO driver */
-    r = uf_sdio_load();
-    if (r) {
-        uf_remove_debug_device();
-        return r;
-    }
-
-    if (sdio_block_size > -1) {
-        unifi_info(NULL, "sdio_block_size %d\n", sdio_block_size);
-    }
-
-    if (sdio_byte_mode) {
-        unifi_info(NULL, "sdio_byte_mode\n");
-    }
-
-    if (disable_power_control) {
-        unifi_info(NULL, "disable_power_control\n");
-    }
-
-    if (disable_hw_reset) {
-        unifi_info(NULL, "disable_hw_reset\n");
-    }
-
-    if (enable_wol) {
-        unifi_info(NULL, "enable_wol %d\n", enable_wol);
-    }
-
-    if (run_bh_once != -1) {
-        unifi_info(NULL, "run_bh_once %d\n", run_bh_once);
-    }
-
-    return 0;
-} /* unifi_load() */
-
-
-void __exit
-unifi_unload(void)
-{
-    /* The SDIO remove hook will call unifi_disconnect(). */
-    uf_sdio_unload();
-
-    uf_remove_debug_device();
-
-} /* unifi_unload() */
-
-module_init(unifi_load);
-module_exit(unifi_unload);
-
-MODULE_DESCRIPTION("UniFi Device driver");
-MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
-MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/staging/csr/firmware.c b/drivers/staging/csr/firmware.c
deleted file mode 100644 (file)
index b42a4d6..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     firmware.c
- *
- *  PURPOSE:
- *      Implements the f/w related HIP core lib API.
- *      It is part of the porting exercise in Linux.
- *
- *      Also, it contains example code for reading the loader and f/w files
- *      from the userspace and starting the SME in Linux.
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/kmod.h>
-#include <linux/vmalloc.h>
-#include <linux/firmware.h>
-#include <asm/uaccess.h>
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_unifi_udi.h"
-#include "unifiio.h"
-#include "unifi_priv.h"
-
-/*
- * ---------------------------------------------------------------------------
- *
- *      F/W download. Part of the HIP core API
- *
- * ---------------------------------------------------------------------------
- */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_fw_read_start
- *
- *      Returns a structure to be passed in unifi_fw_read().
- *      This structure is an OS specific description of the f/w file.
- *      In the linux implementation it is a buffer with the f/w and its' length.
- *      The HIP driver calls this functions to request for the loader or
- *      the firmware file.
- *      The structure pointer can be freed when unifi_fw_read_stop() is called.
- *
- *  Arguments:
- *      ospriv          Pointer to driver context.
- *      is_fw           Type of firmware to retrieve
- *      info            Versions information. Can be used to determine
- *                      the appropriate f/w file to load.
- *
- *  Returns:
- *      O on success, non-zero otherwise.
- *
- * ---------------------------------------------------------------------------
- */
-void*
-unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    CSR_UNUSED(info);
-
-    if (is_fw == UNIFI_FW_STA) {
-        /* F/w may have been released after a previous successful download. */
-        if (priv->fw_sta.dl_data == NULL) {
-            unifi_trace(priv, UDBG2, "Attempt reload of sta f/w\n");
-            uf_request_firmware_files(priv, UNIFI_FW_STA);
-        }
-        /* Set up callback struct for readfunc() */
-        if (priv->fw_sta.dl_data != NULL) {
-            return &priv->fw_sta;
-        }
-
-    } else {
-        unifi_error(priv, "downloading firmware... unknown request: %d\n", is_fw);
-    }
-
-    return NULL;
-} /* unifi_fw_read_start() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_fw_read_stop
- *
- *      Called when the HIP driver has finished using the loader or
- *      the firmware file.
- *      The firmware buffer may be released now.
- *
- *  Arguments:
- *      ospriv          Pointer to driver context.
- *      dlpriv          The pointer returned by unifi_fw_read_start()
- *
- * ---------------------------------------------------------------------------
- */
-void
-unifi_fw_read_stop(void *ospriv, void *dlpriv)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    struct dlpriv *dl_struct = (struct dlpriv *)dlpriv;
-
-    if (dl_struct != NULL) {
-        if (dl_struct->dl_data != NULL) {
-            unifi_trace(priv, UDBG2, "Release f/w buffer %p, %d bytes\n",
-                        dl_struct->dl_data, dl_struct->dl_len);
-        }
-        uf_release_firmware(priv, dl_struct);
-    }
-
-} /* unifi_fw_read_stop() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_fw_open_buffer
- *
- *  Returns a handle for a buffer dynamically allocated by the driver,
- *  e.g. into which a firmware file may have been converted from another format
- *  which is the case with some production test images.
- *
- *  The handle may then be used by unifi_fw_read() to access the contents of
- *  the buffer.
- *
- *  Arguments:
- *      ospriv          Pointer to driver context.
- *      fwbuf           Buffer containing firmware image
- *      len             Length of buffer in bytes
- *
- *  Returns
- *      Handle for buffer, or NULL on error
- * ---------------------------------------------------------------------------
- */
-void *
-unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-
-    if (fwbuf == NULL) {
-        return NULL;
-    }
-    priv->fw_conv.dl_data = fwbuf;
-    priv->fw_conv.dl_len = len;
-    priv->fw_conv.fw_desc = NULL;   /* No OS f/w resource is associated */
-
-    return &priv->fw_conv;
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_fw_close_buffer
- *
- *  Releases any handle for a buffer dynamically allocated by the driver,
- *  e.g. into which a firmware file may have been converted from another format
- *  which is the case with some production test images.
- *
- *
- *  Arguments:
- *      ospriv          Pointer to driver context.
- *      fwbuf           Buffer containing firmware image
- *
- *  Returns
- *      Handle for buffer, or NULL on error
- * ---------------------------------------------------------------------------
- */
-void unifi_fw_close_buffer(void *ospriv, void *fwbuf)
-{
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_fw_read
- *
- *      The HIP driver calls this function to ask for a part of the loader or
- *      the firmware file.
- *
- *  Arguments:
- *      ospriv          Pointer to driver context.
- *      arg             The pointer returned by unifi_fw_read_start().
- *      offset          The offset in the file to return from.
- *      buf             A buffer to store the requested data.
- *      len             The size of the buf and the size of the requested data.
- *
- *  Returns
- *      The number of bytes read from the firmware image, or -ve on error
- * ---------------------------------------------------------------------------
- */
-s32
-unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len)
-{
-    const struct dlpriv *dlpriv = arg;
-
-    if (offset >= dlpriv->dl_len) {
-        /* at end of file */
-        return 0;
-    }
-
-    if ((offset + len) > dlpriv->dl_len) {
-        /* attempt to read past end of file */
-        return -1;
-    }
-
-    memcpy(buf, dlpriv->dl_data+offset, len);
-
-    return len;
-
-} /* unifi_fw_read() */
-
-
-
-
-#define UNIFIHELPER_INIT_MODE_SMEUSER   2
-#define UNIFIHELPER_INIT_MODE_NATIVE    1
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_run_unifihelper
- *
- *      Ask userspace to send us firmware for download by running
- *      '/usr/sbin/unififw'.
- *      The same script starts the SME userspace application.
- *      Derived from net_run_sbin_hotplug().
- *
- *  Arguments:
- *      priv            Pointer to OS private struct.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-int
-uf_run_unifihelper(unifi_priv_t *priv)
-{
-#ifdef ANDROID_BUILD
-    char *prog = "/system/bin/unififw";
-#else
-    char *prog = "/usr/sbin/unififw";
-#endif /* ANDROID_BUILD */
-
-    char *argv[6], *envp[4];
-    char inst_str[8];
-    char init_mode[8];
-    int i, r;
-
-#if (defined CSR_SME_USERSPACE) && (!defined CSR_SUPPORT_WEXT)
-    unifi_trace(priv, UDBG1, "SME userspace build: run unifi_helper manually\n");
-    return 0;
-#endif
-
-    unifi_trace(priv, UDBG1, "starting %s\n", prog);
-
-    snprintf(inst_str,   8, "%d", priv->instance);
-#if (defined CSR_SME_USERSPACE)
-    snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_SMEUSER);
-#else
-    snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_NATIVE);
-#endif /* CSR_SME_USERSPACE */
-
-    i = 0;
-    argv[i++] = prog;
-    argv[i++] = inst_str;
-    argv[i++] = init_mode;
-    argv[i++] = 0;
-    argv[i] = 0;
-    /* Don't add more args without making argv bigger */
-
-    /* minimal command environment */
-    i = 0;
-    envp[i++] = "HOME=/";
-    envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
-    envp[i] = 0;
-    /* Don't add more without making envp bigger */
-
-    unifi_trace(priv, UDBG2, "running %s %s %s\n", argv[0], argv[1], argv[2]);
-
-    r = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
-
-    return r;
-} /* uf_run_unifihelper() */
-
-#ifdef CSR_WIFI_SPLIT_PATCH
-static u8 is_ap_mode(unifi_priv_t *priv)
-{
-    if (priv == NULL || priv->interfacePriv[0] == NULL)
-    {
-        return FALSE;
-    }
-
-    /* Test for mode requiring AP patch */
-    return(CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode));
-}
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_request_firmware_files
- *
- *      Get the firmware files from userspace.
- *
- *  Arguments:
- *      priv            Pointer to OS private struct.
- *      is_fw           type of firmware to load (UNIFI_FW_STA/LOADER)
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-int uf_request_firmware_files(unifi_priv_t *priv, int is_fw)
-{
-    /* uses the default method to get the firmware */
-    const struct firmware *fw_entry;
-    int postfix;
-#define UNIFI_MAX_FW_PATH_LEN       32
-    char fw_name[UNIFI_MAX_FW_PATH_LEN];
-    int r;
-
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-    if (priv->mib_data.length) {
-        vfree(priv->mib_data.data);
-        priv->mib_data.data = NULL;
-        priv->mib_data.length = 0;
-    }
-#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/
-
-    postfix = priv->instance;
-
-    if (is_fw == UNIFI_FW_STA) {
-        /* Free kernel buffer and reload */
-        uf_release_firmware(priv, &priv->fw_sta);
-#ifdef CSR_WIFI_SPLIT_PATCH
-        scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
-                  postfix, (is_ap_mode(priv) ? "ap.xbv" : "staonly.xbv") );
-#else
-        scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
-                  postfix, "sta.xbv" );
-#endif
-        r = request_firmware(&fw_entry, fw_name, priv->unifi_device);
-        if (r == 0) {
-            priv->fw_sta.dl_data = fw_entry->data;
-            priv->fw_sta.dl_len = fw_entry->size;
-            priv->fw_sta.fw_desc = (void *)fw_entry;
-        } else {
-            unifi_trace(priv, UDBG2, "Firmware file not available\n");
-        }
-    }
-
-    return 0;
-
-} /* uf_request_firmware_files() */
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_release_firmware_files
- *
- *      Release all buffers used to store firmware files
- *
- *  Arguments:
- *      priv            Pointer to OS private struct.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-int uf_release_firmware_files(unifi_priv_t *priv)
-{
-    uf_release_firmware(priv, &priv->fw_sta);
-
-    return 0;
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_release_firmware
- *
- *      Release specific buffer used to store firmware
- *
- *  Arguments:
- *      priv            Pointer to OS private struct.
- *      to_free         Pointer to specific buffer to release
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free)
-{
-    if (to_free != NULL) {
-        release_firmware((const struct firmware *)to_free->fw_desc);
-        to_free->fw_desc = NULL;
-        to_free->dl_data = NULL;
-        to_free->dl_len = 0;
-    }
-    return 0;
-}
diff --git a/drivers/staging/csr/inet.c b/drivers/staging/csr/inet.c
deleted file mode 100644 (file)
index b3ef818..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     inet.c
- *
- *  PURPOSE:
- *      Routines related to IP address changes.
- *      Optional part of the porting exercise. It uses system network
- *      handlers to obtain the UniFi IP address and pass it to the SME
- *      using the unifi_sys_ip_configured_ind().
- *
- * Copyright (C) 2008-2009 Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/inetdevice.h>
-#include <linux/notifier.h>
-
-#include "unifi_priv.h"
-#include "csr_wifi_hip_conversions.h"
-
-/*
- * The inet notifier is global and not per-netdev.  To avoid having a
- * notifier registered when there are no unifi devices present, it's
- * registered after the first unifi network device is registered, and
- * unregistered when the last unifi network device is unregistered.
- */
-
-static atomic_t inet_notif_refs = ATOMIC_INIT(0);
-
-static int uf_inetaddr_event(struct notifier_block *notif, unsigned long event, void *ifa)
-{
-    struct net_device *ndev;
-    unifi_priv_t *priv;
-    struct in_ifaddr *if_addr;
-    netInterface_priv_t *InterfacePriv = (netInterface_priv_t *)NULL;
-
-    if (!ifa || !((struct in_ifaddr *)ifa)->ifa_dev) {
-        unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ifa=%p\n", event, ifa);
-        return NOTIFY_DONE;
-    }
-
-    ndev = ((struct in_ifaddr *)ifa)->ifa_dev->dev;
-    InterfacePriv = (netInterface_priv_t*) netdev_priv(ndev);
-
-    /* As the notifier is global, the call may be for a non-UniFi netdev.
-     * Therefore check the netdev_priv to make sure it's a known UniFi one.
-     */
-    if (uf_find_netdev_priv(InterfacePriv) == -1) {
-        unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ndev=%p, other netdev_priv=%p\n",
-                    event, ndev, InterfacePriv);
-        return NOTIFY_DONE;
-    }
-
-    if (!InterfacePriv->privPtr) {
-        unifi_error(NULL, "uf_inetaddr_event null priv (%lu) ndev=%p, InterfacePriv=%p\n",
-                    event, ndev, InterfacePriv);
-        return NOTIFY_DONE;
-    }
-
-    priv = InterfacePriv->privPtr;
-    if_addr = (struct in_ifaddr *)ifa;
-
-    /* If this event is for a UniFi device, notify the SME that an IP
-     * address has been added or removed. */
-    if (uf_find_priv(priv) != -1) {
-        switch (event) {
-            case NETDEV_UP:
-                unifi_info(priv, "IP address assigned for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name);
-                priv->sta_ip_address = if_addr->ifa_address;
-#ifdef CSR_SUPPORT_WEXT
-                sme_mgt_packet_filter_set(priv);
-#endif
-                break;
-            case NETDEV_DOWN:
-                unifi_info(priv, "IP address removed for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name);
-                priv->sta_ip_address = 0xFFFFFFFF;
-#ifdef CSR_SUPPORT_WEXT
-                sme_mgt_packet_filter_set(priv);
-#endif
-                break;
-        }
-    }
-
-    return NOTIFY_DONE;
-}
-
-static struct notifier_block uf_inetaddr_notifier = {
-    .notifier_call = uf_inetaddr_event,
-};
-
-void uf_register_inet_notifier(void)
-{
-       if (atomic_inc_return(&inet_notif_refs) == 1)
-               register_inetaddr_notifier(&uf_inetaddr_notifier);
-}
-
-void uf_unregister_inet_notifier(void)
-{
-       if (atomic_dec_return(&inet_notif_refs) == 0)
-               unregister_inetaddr_notifier(&uf_inetaddr_notifier);
-}
diff --git a/drivers/staging/csr/init_hw.c b/drivers/staging/csr/init_hw.c
deleted file mode 100644 (file)
index 3b8a4ba..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     init_hw.c
- *
- * PURPOSE:
- *      Use the HIP core lib to initialise the UniFi chip.
- *      It is part of the porting exercise in Linux.
- *
- * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include "csr_wifi_hip_unifi.h"
-#include "unifi_priv.h"
-
-
-#define MAX_INIT_ATTEMPTS        4
-
-extern int led_mask;
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_init_hw
- *
- *      Resets hardware, downloads and initialises f/w.
- *      This function demonstrates how to use the HIP core lib API
- *      to implement the SME unifi_sys_wifi_on_req() part of the SYS API.
- *
- *      In a simple implementation, all this function needs to do is call
- *      unifi_init_card() and then unifi_card_info().
- *      In the Linux implementation, it will retry to initialise UniFi or
- *      try to debug the reasons if unifi_init_card() returns an error.
- *
- *  Arguments:
- *      ospriv          Pointer to OS driver structure for the device.
- *
- *  Returns:
- *      O on success, non-zero otherwise.
- *
- * ---------------------------------------------------------------------------
- */
-int
-uf_init_hw(unifi_priv_t *priv)
-{
-    int attempts = 0;
-    int priv_instance;
-    CsrResult csrResult = CSR_RESULT_FAILURE;
-
-    priv_instance = uf_find_priv(priv);
-    if (priv_instance == -1) {
-        unifi_warning(priv, "uf_init_hw: Unknown priv instance, will use fw_init[0]\n");
-        priv_instance = 0;
-    }
-
-    while (1) {
-        if (attempts > MAX_INIT_ATTEMPTS) {
-            unifi_error(priv, "Failed to initialise UniFi after %d attempts, "
-                        "giving up.\n",
-                        attempts);
-            break;
-        }
-        attempts++;
-
-        unifi_info(priv, "Initialising UniFi, attempt %d\n", attempts);
-
-        if (fw_init[priv_instance] > 0) {
-            unifi_notice(priv, "f/w init prevented by module parameter\n");
-            break;
-        } else if (fw_init[priv_instance] == 0) {
-            fw_init[priv_instance] ++;
-        }
-
-        /*
-         * Initialise driver core. This will perform a reset of UniFi
-         * internals, but not the SDIO CCCR.
-         */
-        CsrSdioClaim(priv->sdio);
-        csrResult = unifi_init_card(priv->card, led_mask);
-        CsrSdioRelease(priv->sdio);
-
-        if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
-            return CsrHipResultToStatus(csrResult);
-        }
-        if (csrResult == CSR_WIFI_HIP_RESULT_NOT_FOUND) {
-            unifi_error(priv, "Firmware file required, but not found.\n");
-            return CsrHipResultToStatus(csrResult);
-        }
-        if (csrResult != CSR_RESULT_SUCCESS) {
-            /* failed. Reset h/w and try again */
-            unifi_error(priv, "Failed to initialise UniFi chip.\n");
-            continue;
-        }
-
-        /* Get the version information from the lib_hip */
-        unifi_card_info(priv->card, &priv->card_info);
-
-        return CsrHipResultToStatus(csrResult);
-    }
-
-    return CsrHipResultToStatus(csrResult);
-
-} /* uf_init_hw */
-
-
diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c
deleted file mode 100644 (file)
index f903022..0000000
+++ /dev/null
@@ -1,1098 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     io.c
- *
- *  PURPOSE:
- *      This file contains routines that the SDIO driver can call when a
- *      UniFi card is first inserted (or detected) and removed.
- *
- *      When used with sdioemb, the udev scripts (at least on Ubuntu) don't
- *      recognise a UniFi being added to the system. This is because sdioemb
- *      does not register itself as a device_driver, it uses it's own code
- *      to handle insert and remove.
- *      To have Ubuntu recognise UniFi, edit /etc/udev/rules.d/85-ifupdown.rules
- *      to change this line:
- *          SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"
- *      to these:
- *          #SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"
- *          SUBSYSTEM=="net", GOTO="net_start"
- *
- *      Then you can add a stanza to /etc/network/interfaces like this:
- *          auto eth1
- *          iface eth1 inet dhcp
- *          wpa-conf /etc/wpa_supplicant.conf
- *      This will then automatically associate when a car dis inserted.
- *
- * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_unifiversion.h"
-#include "csr_wifi_hip_unifi_udi.h"   /* for unifi_print_status() */
-#include "unifiio.h"
-#include "unifi_priv.h"
-
-/*
- * Array of pointers to context structs for unifi devices that are present.
- * The index in the array corresponds to the wlan interface number
- * (if "wlan*" is used). If "eth*" is used, the eth* numbers are allocated
- * after any Ethernet cards.
- *
- * The Arasan PCI-SDIO controller card supported by this driver has 2 slots,
- * hence a max of 2 devices.
- */
-static unifi_priv_t *Unifi_instances[MAX_UNIFI_DEVS];
-
-/* Array of pointers to netdev objects used by the UniFi driver, as there
- * are now many per instance. This is used to determine which netdev events
- * are for UniFi as opposed to other net interfaces.
- */
-static netInterface_priv_t *Unifi_netdev_instances[MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES];
-
-/*
- * Array to hold the status of each unifi device in each slot.
- * We only process an insert event when In_use[] for the slot is
- * UNIFI_DEV_NOT_IN_USE. Otherwise, it means that the slot is in use or
- * we are in the middle of a cleanup (the action on unplug).
- */
-#define UNIFI_DEV_NOT_IN_USE    0
-#define UNIFI_DEV_IN_USE        1
-#define UNIFI_DEV_CLEANUP       2
-static int In_use[MAX_UNIFI_DEVS];
-/*
- * Mutex to prevent UDI clients to open the character device before the priv
- * is created and initialised.
- */
-DEFINE_SEMAPHORE(Unifi_instance_mutex);
-/*
- * When the device is removed, unregister waits on Unifi_cleanup_wq
- * until all the UDI clients release the character device.
- */
-DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq);
-
-#ifdef CONFIG_PROC_FS
-/*
- * seq_file wrappers for procfile show routines.
- */
-static int uf_proc_show(struct seq_file *m, void *v);
-
-#define UNIFI_DEBUG_TXT_BUFFER (8 * 1024)
-
-static int uf_proc_open(struct inode *inode, struct file *file)
-{
-       return single_open_size(file, uf_proc_show, PDE_DATA(inode),
-                               UNIFI_DEBUG_TXT_BUFFER);
-}
-
-static const struct file_operations uf_proc_fops = {
-       .open           = uf_proc_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-#endif /* CONFIG_PROC_FS */
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-
-static CsrResult signal_buffer_init(unifi_priv_t * priv, int size)
-{
-    int i;
-
-    priv->rxSignalBuffer.writePointer =
-    priv->rxSignalBuffer.readPointer = 0;
-    priv->rxSignalBuffer.size = size;
-    /* Allocating Memory for Signal primitive pointer */
-    for(i=0; i<size; i++)
-    {
-         priv->rxSignalBuffer.rx_buff[i].sig_len=0;
-         priv->rxSignalBuffer.rx_buff[i].bufptr = kmalloc(UNIFI_PACKED_SIGBUF_SIZE, GFP_KERNEL);
-         if (priv->rxSignalBuffer.rx_buff[i].bufptr == NULL)
-         {
-             int j;
-             unifi_error(priv, "signal_buffer_init:Failed to Allocate shared memory for T-H signals \n");
-             for(j=0;j<i;j++)
-             {
-                 priv->rxSignalBuffer.rx_buff[j].sig_len=0;
-                 kfree(priv->rxSignalBuffer.rx_buff[j].bufptr);
-                 priv->rxSignalBuffer.rx_buff[j].bufptr = NULL;
-             }
-             return -1;
-         }
-    }
-    return 0;
-}
-
-
-static void signal_buffer_free(unifi_priv_t * priv, int size)
-{
-    int i;
-
-    for(i=0; i<size; i++)
-    {
-         priv->rxSignalBuffer.rx_buff[i].sig_len=0;
-         kfree(priv->rxSignalBuffer.rx_buff[i].bufptr);
-         priv->rxSignalBuffer.rx_buff[i].bufptr = NULL;
-    }
-}
-#endif
-/*
- * ---------------------------------------------------------------------------
- *  uf_register_netdev
- *
- *      Registers the network interface, installes the qdisc,
- *      and registers the inet handler.
- *      In the porting exercise, register the driver to the network
- *      stack if necessary.
- *
- *  Arguments:
- *      priv          Pointer to driver context.
- *
- *  Returns:
- *      O on success, non-zero otherwise.
- *
- *  Notes:
- *      We will only unregister when the card is ejected, so we must
- *      only do it once.
- * ---------------------------------------------------------------------------
- */
-int
-uf_register_netdev(unifi_priv_t *priv, int interfaceTag)
-{
-    int r;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_register_netdev bad interfaceTag\n");
-        return -EINVAL;
-    }
-
-    /*
-     * Allocates a device number and registers device with the network
-     * stack.
-     */
-    unifi_trace(priv, UDBG5, "uf_register_netdev: netdev %d - 0x%p\n",
-            interfaceTag, priv->netdev[interfaceTag]);
-    r = register_netdev(priv->netdev[interfaceTag]);
-    if (r) {
-        unifi_error(priv, "Failed to register net device\n");
-        return -EINVAL;
-    }
-
-    /* The device is registed */
-    interfacePriv->netdev_registered = 1;
-
-#ifdef CSR_SUPPORT_SME
-    /*
-     * Register the inet handler; it notifies us for changes in the IP address.
-     */
-    uf_register_inet_notifier();
-#endif /* CSR_SUPPORT_SME */
-
-    unifi_notice(priv, "unifi%d is %s\n",
-            priv->instance, priv->netdev[interfaceTag]->name);
-
-    return 0;
-} /* uf_register_netdev */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_unregister_netdev
- *
- *      Unregisters the network interface and the inet handler.
- *
- *  Arguments:
- *      priv          Pointer to driver context.
- *
- *  Returns:
- *      None.
- *
- * ---------------------------------------------------------------------------
- */
-void
-uf_unregister_netdev(unifi_priv_t *priv)
-{
-    int i=0;
-
-#ifdef CSR_SUPPORT_SME
-    /* Unregister the inet handler... */
-    uf_unregister_inet_notifier();
-#endif /* CSR_SUPPORT_SME */
-
-    for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-        if (interfacePriv->netdev_registered) {
-            unifi_trace(priv, UDBG5,
-                    "uf_unregister_netdev: netdev %d - 0x%p\n",
-                    i, priv->netdev[i]);
-
-            /* ... and the netdev */
-            unregister_netdev(priv->netdev[i]);
-            interfacePriv->netdev_registered = 0;
-        }
-
-        interfacePriv->interfaceMode = 0;
-
-        /* Enable all queues by default */
-        interfacePriv->queueEnabled[0] = 1;
-        interfacePriv->queueEnabled[1] = 1;
-        interfacePriv->queueEnabled[2] = 1;
-        interfacePriv->queueEnabled[3] = 1;
-    }
-
-    priv->totalInterfaceCount = 0;
-} /* uf_unregister_netdev() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  register_unifi_sdio
- *
- *      This function is called from the Probe (or equivalent) method of
- *      the SDIO driver when a UniFi card is detected.
- *      We allocate the Linux net_device struct, initialise the HIP core
- *      lib, create the char device nodes and start the userspace helper
- *      to initialise the device.
- *
- *  Arguments:
- *      sdio_dev        Pointer to SDIO context handle to use for all
- *                      SDIO ops.
- *      bus_id          A small number indicating the SDIO card position on the
- *                      bus. Typically this is the slot number, e.g. 0, 1 etc.
- *                      Valid values are 0 to MAX_UNIFI_DEVS-1.
- *      dev             Pointer to kernel device manager struct.
- *
- *  Returns:
- *      Pointer to the unifi instance, or NULL on error.
- * ---------------------------------------------------------------------------
- */
-static unifi_priv_t *
-register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev)
-{
-    unifi_priv_t *priv = NULL;
-    int r = -1;
-    CsrResult csrResult;
-
-    if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
-        unifi_error(priv, "register_unifi_sdio: invalid device %d\n",
-                bus_id);
-        return NULL;
-    }
-
-    down(&Unifi_instance_mutex);
-
-    if (In_use[bus_id] != UNIFI_DEV_NOT_IN_USE) {
-        unifi_error(priv, "register_unifi_sdio: device %d is already in use\n",
-                bus_id);
-        goto failed0;
-    }
-
-
-    /* Allocate device private and net_device structs */
-    priv = uf_alloc_netdevice(sdio_dev, bus_id);
-    if (priv == NULL) {
-        unifi_error(priv, "Failed to allocate driver private\n");
-        goto failed0;
-    }
-
-    priv->unifi_device = dev;
-
-    SET_NETDEV_DEV(priv->netdev[0], dev);
-
-    /* We are not ready to send data yet. */
-    netif_carrier_off(priv->netdev[0]);
-
-    /* Allocate driver context. */
-    priv->card = unifi_alloc_card(priv->sdio, priv);
-    if (priv->card == NULL) {
-        unifi_error(priv, "Failed to allocate UniFi driver card struct.\n");
-        goto failed1;
-    }
-
-    if (Unifi_instances[bus_id]) {
-        unifi_error(priv, "Internal error: instance for slot %d is already taken\n",
-                bus_id);
-    }
-    Unifi_instances[bus_id] = priv;
-    In_use[bus_id] = UNIFI_DEV_IN_USE;
-
-    /* Save the netdev_priv for use by the netdev event callback mechanism */
-    Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES] = netdev_priv(priv->netdev[0]);
-
-    /* Initialise the mini-coredump capture buffers */
-    csrResult = unifi_coredump_init(priv->card, (u16)coredump_max);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Couldn't allocate mini-coredump buffers\n");
-    }
-
-    /* Create the character device nodes */
-    r = uf_create_device_nodes(priv, bus_id);
-    if (r) {
-        goto failed1;
-    }
-
-    /*
-     * We use the slot number as unifi device index.
-     */
-    scnprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance);
-    /*
-     * The following complex casting is in place in order to eliminate 64-bit compilation warning
-     * "cast to/from pointer from/to integer of different size"
-     */
-    if (!proc_create_data(priv->proc_entry_name, 0, NULL,
-                         &uf_proc_fops, (void *)(long)priv->instance))
-    {
-        unifi_error(priv, "unifi: can't create /proc/driver/unifi\n");
-    }
-
-    /* Allocate the net_device for interfaces other than 0. */
-    {
-        int i;
-        priv->totalInterfaceCount =0;
-
-        for(i=1;i<CSR_WIFI_NUM_INTERFACES;i++)
-        {
-            if( !uf_alloc_netdevice_for_other_interfaces(priv, i) )
-            {
-                /* error occured while allocating the net_device for interface[i]. The net_device are
-                 * allocated for the interfaces with id<i. Dont worry, all the allocated net_device will
-                 * be releasing chen the control goes to the label failed0.
-                 */
-                unifi_error(priv, "Failed to allocate driver private for interface[%d]\n", i);
-                goto failed0;
-            }
-            else
-            {
-                SET_NETDEV_DEV(priv->netdev[i], dev);
-
-                /* We are not ready to send data yet. */
-                netif_carrier_off(priv->netdev[i]);
-
-                /* Save the netdev_priv for use by the netdev event callback mechanism */
-                Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES + i] = netdev_priv(priv->netdev[i]);
-            }
-        }
-
-        for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
-        {
-            netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-            interfacePriv->netdev_registered=0;
-        }
-    }
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-    if (signal_buffer_init(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE))
-    {
-        unifi_error(priv, "Failed to allocate shared memory for T-H signals\n");
-        goto failed2;
-    }
-    priv->rx_workqueue = create_singlethread_workqueue("rx_workq");
-    if (priv->rx_workqueue == NULL) {
-        unifi_error(priv, "create_singlethread_workqueue failed \n");
-        goto failed3;
-    }
-    INIT_WORK(&priv->rx_work_struct, rx_wq_handler);
-#endif
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-    if (log_hip_signals)
-    {
-        uf_register_hip_offline_debug(priv);
-    }
-#endif
-
-    /* Initialise the SME related threads and parameters */
-    r = uf_sme_init(priv);
-    if (r) {
-        unifi_error(priv, "SME initialisation failed.\n");
-        goto failed4;
-    }
-
-    /*
-     * Run the userspace helper program (unififw) to perform
-     * the device initialisation.
-     */
-    unifi_trace(priv, UDBG1, "run UniFi helper app...\n");
-    r = uf_run_unifihelper(priv);
-    if (r) {
-        unifi_notice(priv, "unable to run UniFi helper app\n");
-        /* Not a fatal error. */
-    }
-
-    up(&Unifi_instance_mutex);
-
-    return priv;
-
-failed4:
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-if (log_hip_signals)
-{
-    uf_unregister_hip_offline_debug(priv);
-}
-#endif
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-    flush_workqueue(priv->rx_workqueue);
-    destroy_workqueue(priv->rx_workqueue);
-failed3:
-    signal_buffer_free(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
-failed2:
-#endif
-    /* Remove the device nodes */
-    uf_destroy_device_nodes(priv);
-failed1:
-    /* Deregister priv->netdev_client */
-    ul_deregister_client(priv->netdev_client);
-
-failed0:
-    if (priv && priv->card) {
-        unifi_coredump_free(priv->card);
-        unifi_free_card(priv->card);
-    }
-    if (priv) {
-        uf_free_netdevice(priv);
-    }
-
-    up(&Unifi_instance_mutex);
-
-    return NULL;
-} /* register_unifi_sdio() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ask_unifi_sdio_cleanup
- *
- *      We can not free our private context, until all the char device
- *      clients have closed the file handles. unregister_unifi_sdio() which
- *      is called when a card is removed, waits on Unifi_cleanup_wq until
- *      the reference count becomes zero. It is time to wake it up now.
- *
- *  Arguments:
- *      priv          Pointer to driver context.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-ask_unifi_sdio_cleanup(unifi_priv_t *priv)
-{
-
-    /*
-     * Now clear the flag that says the old instance is in use.
-     * This is used to prevent a new instance being started before old
-     * one has finshed closing down, for example if bounce makes the card
-     * appear to be ejected and re-inserted quickly.
-     */
-    In_use[priv->instance] = UNIFI_DEV_CLEANUP;
-
-    unifi_trace(NULL, UDBG5, "ask_unifi_sdio_cleanup: wake up cleanup workqueue.\n");
-    wake_up(&Unifi_cleanup_wq);
-
-} /* ask_unifi_sdio_cleanup() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  cleanup_unifi_sdio
- *
- *      Release any resources owned by a unifi instance.
- *
- *  Arguments:
- *      priv          Pointer to the instance to free.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-cleanup_unifi_sdio(unifi_priv_t *priv)
-{
-    int priv_instance;
-    int i;
-    static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
-
-    /* Remove the device nodes */
-    uf_destroy_device_nodes(priv);
-
-    /* Mark this device as gone away by NULLing the entry in Unifi_instances */
-    Unifi_instances[priv->instance] = NULL;
-
-    unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: remove_proc_entry\n");
-    /*
-     * Free the children of priv before unifi_free_netdevice() frees
-     * the priv struct
-     */
-    remove_proc_entry(priv->proc_entry_name, 0);
-
-
-    /* Unregister netdev as a client. */
-    if (priv->netdev_client) {
-        unifi_trace(priv, UDBG2, "Netdev client (id:%d s:0x%X) is unregistered\n",
-                priv->netdev_client->client_id, priv->netdev_client->sender_id);
-        ul_deregister_client(priv->netdev_client);
-    }
-
-    /* Destroy the SME related threads and parameters */
-    uf_sme_deinit(priv);
-
-#ifdef CSR_SME_USERSPACE
-    priv->smepriv = NULL;
-#endif
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-    if (log_hip_signals)
-    {
-        uf_unregister_hip_offline_debug(priv);
-    }
-#endif
-
-    /* Free any packets left in the Rx queues */
-    for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
-    {
-        uf_free_pending_rx_packets(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, i);
-        uf_free_pending_rx_packets(priv, UF_CONTROLLED_PORT_Q, broadcast_address, i);
-    }
-    /*
-     * We need to free the resources held by the core, which include tx skbs,
-     * otherwise we can not call unregister_netdev().
-     */
-    if (priv->card) {
-        unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: free card\n");
-        unifi_coredump_free(priv->card);
-        unifi_free_card(priv->card);
-        priv->card = NULL;
-    }
-
-    /*
-     * Unregister the network device.
-     * We can not unregister the netdev before we release
-     * all pending packets in the core.
-     */
-    uf_unregister_netdev(priv);
-    priv->totalInterfaceCount = 0;
-
-    /* Clear the table of registered netdev_priv's */
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        Unifi_netdev_instances[priv->instance * CSR_WIFI_NUM_INTERFACES + i] = NULL;
-    }
-
-    unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: uf_free_netdevice\n");
-    /*
-     * When uf_free_netdevice() returns, the priv is invalid
-     * so we need to remember the instance to clear the global flag later.
-     */
-    priv_instance = priv->instance;
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-    flush_workqueue(priv->rx_workqueue);
-    destroy_workqueue(priv->rx_workqueue);
-    signal_buffer_free(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
-#endif
-
-    /* Priv is freed as part of the net_device */
-    uf_free_netdevice(priv);
-
-    /*
-     * Now clear the flag that says the old instance is in use.
-     * This is used to prevent a new instance being started before old
-     * one has finshed closing down, for example if bounce makes the card
-     * appear to be ejected and re-inserted quickly.
-     */
-    In_use[priv_instance] = UNIFI_DEV_NOT_IN_USE;
-
-    unifi_trace(NULL, UDBG5, "cleanup_unifi_sdio: DONE.\n");
-
-} /* cleanup_unifi_sdio() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unregister_unifi_sdio
- *
- *      Call from SDIO driver when it detects that UniFi has been removed.
- *
- *  Arguments:
- *      bus_id          Number of the card that was ejected.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-unregister_unifi_sdio(int bus_id)
-{
-    unifi_priv_t *priv;
-    int interfaceTag=0;
-    u8 reason = CONFIG_IND_EXIT;
-
-    if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
-        unifi_error(NULL, "unregister_unifi_sdio: invalid device %d\n",
-                bus_id);
-        return;
-    }
-
-    priv = Unifi_instances[bus_id];
-    if (priv == NULL) {
-        unifi_error(priv, "unregister_unifi_sdio: device %d is not registered\n",
-                bus_id);
-        return;
-    }
-
-    /* Stop the network traffic before freeing the core. */
-    for(interfaceTag=0;interfaceTag<priv->totalInterfaceCount;interfaceTag++)
-    {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-        if(interfacePriv->netdev_registered)
-        {
-            netif_carrier_off(priv->netdev[interfaceTag]);
-            netif_tx_stop_all_queues(priv->netdev[interfaceTag]);
-        }
-    }
-
-#ifdef CSR_NATIVE_LINUX
-    /*
-     * If the unifi thread was started, signal it to stop.  This
-     * should cause any userspace processes with open unifi device to
-     * close them.
-     */
-    uf_stop_thread(priv, &priv->bh_thread);
-
-    /* Unregister the interrupt handler */
-    if (csr_sdio_linux_remove_irq(priv->sdio)) {
-        unifi_notice(priv,
-                "csr_sdio_linux_remove_irq failed to talk to card.\n");
-    }
-
-    /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
-    uf_abort_mlme(priv);
-#endif /* CSR_NATIVE_LINUX */
-
-    ul_log_config_ind(priv, &reason, sizeof(u8));
-
-    /* Deregister the UDI hook from the core. */
-    unifi_remove_udi_hook(priv->card, logging_handler);
-
-    uf_put_instance(bus_id);
-
-    /*
-     * Wait until the device is cleaned up. i.e., when all userspace
-     * processes have closed any open unifi devices.
-     */
-    wait_event(Unifi_cleanup_wq, In_use[bus_id] == UNIFI_DEV_CLEANUP);
-    unifi_trace(NULL, UDBG5, "Received clean up event\n");
-
-    /* Now we can free the private context and the char device nodes */
-    cleanup_unifi_sdio(priv);
-
-} /* unregister_unifi_sdio() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_find_instance
- *
- *      Find the context structure for a given UniFi device instance.
- *
- *  Arguments:
- *      inst            The instance number to look for.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-unifi_priv_t *
-uf_find_instance(int inst)
-{
-    if ((inst < 0) || (inst >= MAX_UNIFI_DEVS)) {
-        return NULL;
-    }
-    return Unifi_instances[inst];
-} /* uf_find_instance() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_find_priv
- *
- *      Find the device instance for a given context structure.
- *
- *  Arguments:
- *      priv            The context structure pointer to look for.
- *
- *  Returns:
- *      index of instance, -1 otherwise.
- * ---------------------------------------------------------------------------
- */
-int
-uf_find_priv(unifi_priv_t *priv)
-{
-    int inst;
-
-    if (!priv) {
-        return -1;
-    }
-
-    for (inst = 0; inst < MAX_UNIFI_DEVS; inst++) {
-        if (Unifi_instances[inst] == priv) {
-            return inst;
-        }
-    }
-
-    return -1;
-} /* uf_find_priv() */
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_find_netdev_priv
- *
- *      Find the device instance for a given netdev context structure.
- *
- *  Arguments:
- *      priv            The context structure pointer to look for.
- *
- *  Returns:
- *      index of instance, -1 otherwise.
- * ---------------------------------------------------------------------------
- */
-int
-uf_find_netdev_priv(netInterface_priv_t *priv)
-{
-    int inst;
-
-    if (!priv) {
-        return -1;
-    }
-
-    for (inst = 0; inst < MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES; inst++) {
-        if (Unifi_netdev_instances[inst] == priv) {
-            return inst;
-        }
-    }
-
-    return -1;
-} /* uf_find_netdev_priv() */
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_get_instance
- *
- *      Find the context structure for a given UniFi device instance
- *      and increment the reference count.
- *
- *  Arguments:
- *      inst            The instance number to look for.
- *
- *  Returns:
- *      Pointer to the instance or NULL if no instance exists.
- * ---------------------------------------------------------------------------
- */
-unifi_priv_t *
-uf_get_instance(int inst)
-{
-    unifi_priv_t *priv;
-
-    down(&Unifi_instance_mutex);
-
-    priv = uf_find_instance(inst);
-    if (priv) {
-        priv->ref_count++;
-    }
-
-    up(&Unifi_instance_mutex);
-
-    return priv;
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_put_instance
- *
- *      Decrement the context reference count, freeing resources and
- *      shutting down the driver when the count reaches zero.
- *
- *  Arguments:
- *      inst            The instance number to look for.
- *
- *  Returns:
- *      Pointer to the instance or NULL if no instance exists.
- * ---------------------------------------------------------------------------
- */
-void
-uf_put_instance(int inst)
-{
-    unifi_priv_t *priv;
-
-    down(&Unifi_instance_mutex);
-
-    priv = uf_find_instance(inst);
-    if (priv) {
-        priv->ref_count--;
-        if (priv->ref_count == 0) {
-            ask_unifi_sdio_cleanup(priv);
-        }
-    }
-
-    up(&Unifi_instance_mutex);
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_proc_show
- *
- *      Read method for driver node in /proc/driver/unifi0
- *
- *  Arguments:
- *      page
- *      start
- *      offset
- *      count
- *      eof
- *      data
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-#ifdef CONFIG_PROC_FS
-static int uf_proc_show(struct seq_file *m, void *v)
-{
-       unifi_priv_t *priv;
-       int i;
-
-       /*
-        * The following complex casting is in place in order to eliminate
-        * 64-bit compilation warning "cast to/from pointer from/to integer of
-        * different size"
-        */
-       priv = uf_find_instance((long)m->private);
-       if (!priv)
-               return 0;
-
-       seq_printf(m, "UniFi SDIO Driver: %s %s %s\n",
-                  CSR_WIFI_VERSION, __DATE__, __TIME__);
-#ifdef CSR_SME_USERSPACE
-       seq_puts(m, "SME: CSR userspace ");
-#ifdef CSR_SUPPORT_WEXT
-       seq_puts(m, "with WEXT support\n");
-#else
-       seq_putc(m, '\n');
-#endif /* CSR_SUPPORT_WEXT */
-#endif /* CSR_SME_USERSPACE */
-#ifdef CSR_NATIVE_LINUX
-       seq_puts(m, "SME: native\n");
-#endif
-
-#ifdef CSR_SUPPORT_SME
-       seq_printf(m, "Firmware (ROM) build:%u, Patch:%u\n",
-                  priv->card_info.fw_build,
-                  priv->sme_versions.firmwarePatch);
-#endif
-
-       unifi_print_status(priv->card, m);
-
-       seq_printf(m, "Last dbg str: %s\n", priv->last_debug_string);
-
-       seq_puts(m, "Last dbg16:");
-       for (i = 0; i < 8; i++)
-               seq_printf(m, " %04X", priv->last_debug_word16[i]);
-       seq_putc(m, '\n');
-       seq_puts(m, "           ");
-       for (; i < 16; i++)
-               seq_printf(m, " %04X", priv->last_debug_word16[i]);
-       seq_putc(m, '\n');
-       return 0;
-}
-#endif
-
-
-
-
-static void
-uf_lx_suspend(CsrSdioFunction *sdio_ctx)
-{
-    unifi_priv_t *priv = sdio_ctx->driverData;
-    unifi_suspend(priv);
-
-    CsrSdioSuspendAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
-}
-
-static void
-uf_lx_resume(CsrSdioFunction *sdio_ctx)
-{
-    unifi_priv_t *priv = sdio_ctx->driverData;
-    unifi_resume(priv);
-
-    CsrSdioResumeAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
-}
-
-static int active_slot = MAX_UNIFI_DEVS;
-static struct device *os_devices[MAX_UNIFI_DEVS];
-
-void
-uf_add_os_device(int bus_id, struct device *os_device)
-{
-    if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
-        unifi_error(NULL, "uf_add_os_device: invalid device %d\n",
-                bus_id);
-        return;
-    }
-
-    active_slot = bus_id;
-    os_devices[bus_id] = os_device;
-} /* uf_add_os_device() */
-
-void
-uf_remove_os_device(int bus_id)
-{
-    if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
-        unifi_error(NULL, "uf_remove_os_device: invalid device %d\n",
-                bus_id);
-        return;
-    }
-
-    active_slot = bus_id;
-    os_devices[bus_id] = NULL;
-} /* uf_remove_os_device() */
-
-static void
-uf_sdio_inserted(CsrSdioFunction *sdio_ctx)
-{
-       unifi_priv_t *priv;
-
-       unifi_trace(NULL, UDBG5, "uf_sdio_inserted(0x%p), slot_id=%d, dev=%p\n",
-                     sdio_ctx, active_slot, os_devices[active_slot]);
-
-       priv = register_unifi_sdio(sdio_ctx, active_slot, os_devices[active_slot]);
-       if (priv == NULL) {
-               CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_FAILURE);
-               return;
-       }
-
-       sdio_ctx->driverData = priv;
-
-       CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
-} /* uf_sdio_inserted() */
-
-
-static void
-uf_sdio_removed(CsrSdioFunction *sdio_ctx)
-{
-       unregister_unifi_sdio(active_slot);
-       CsrSdioRemovedAcknowledge(sdio_ctx);
-} /* uf_sdio_removed() */
-
-
-static void
-uf_sdio_dsr_handler(CsrSdioFunction *sdio_ctx)
-{
-       unifi_priv_t *priv = sdio_ctx->driverData;
-
-       unifi_sdio_interrupt_handler(priv->card);
-} /* uf_sdio_dsr_handler() */
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_sdio_int_handler
- *
- *      Interrupt callback function for SDIO interrupts.
- *      This is called in kernel context (i.e. not interrupt context).
- *      We retrieve the unifi context pointer and call the main UniFi
- *      interrupt handler.
- *
- *  Arguments:
- *      fdev      SDIO context pointer
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static CsrSdioInterruptDsrCallback
-uf_sdio_int_handler(CsrSdioFunction *sdio_ctx)
-{
-       return uf_sdio_dsr_handler;
-} /* uf_sdio_int_handler() */
-
-
-
-
-static CsrSdioFunctionId unifi_ids[] =
-{
-       {
-               .manfId = SDIO_MANF_ID_CSR,
-               .cardId = SDIO_CARD_ID_UNIFI_3,
-               .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_3,
-               .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE,
-       },
-       {
-               .manfId = SDIO_MANF_ID_CSR,
-               .cardId = SDIO_CARD_ID_UNIFI_4,
-               .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_4,
-               .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE,
-       }
-};
-
-
-/*
- * Structure to register with the glue layer.
- */
-static CsrSdioFunctionDriver unifi_sdioFunction_drv =
-{
-       .inserted = uf_sdio_inserted,
-       .removed = uf_sdio_removed,
-       .intr = uf_sdio_int_handler,
-       .suspend = uf_lx_suspend,
-       .resume = uf_lx_resume,
-
-       .ids = unifi_ids,
-       .idsCount = sizeof(unifi_ids) / sizeof(unifi_ids[0])
-};
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_sdio_load
- *  uf_sdio_unload
- *
- *      These functions are called from the main module load and unload
- *      functions. They perform the appropriate operations for the monolithic
- *      driver.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-int __init
-uf_sdio_load(void)
-{
-       CsrResult csrResult;
-
-       csrResult = CsrSdioFunctionDriverRegister(&unifi_sdioFunction_drv);
-       if (csrResult != CSR_RESULT_SUCCESS) {
-               unifi_error(NULL, "Failed to register UniFi SDIO driver: csrResult=%d\n", csrResult);
-               return -EIO;
-       }
-
-       return 0;
-} /* uf_sdio_load() */
-
-
-
-void __exit
-uf_sdio_unload(void)
-{
-       CsrSdioFunctionDriverUnregister(&unifi_sdioFunction_drv);
-} /* uf_sdio_unload() */
-
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
deleted file mode 100644 (file)
index 861d6b7..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     mlme.c
- *
- * PURPOSE:
- *      This file provides functions to send MLME requests to the UniFi.
- *
- * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include "csr_wifi_hip_unifi.h"
-#include "unifi_priv.h"
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_mlme_wait_for_reply
- *
- *      Wait for a reply after sending a signal.
- *
- * Arguments:
- *      priv            Pointer to device private context struct
- *      ul_client       Pointer to linux client
- *      sig_reply_id    ID of the expected reply (defined in sigs.h).
- *      timeout         timeout in ms
- *
- * Returns:
- *      0 on success, -ve POSIX code on error.
- *
- * Notes:
- *      This function waits for a specific (sig_reply_id) signal from UniFi.
- *      It also match the sequence number of the received (cfm) signal, with
- *      the latest sequence number of the signal (req) we have sent.
- *      These two number match be equal.
- *      Should only be used for waiting xxx.cfm signals and only after
- *      we have sent the matching xxx.req signal to UniFi.
- *      If no response is received within the expected time (timeout), we assume
- *      that the UniFi is busy and return an error.
- *      If the wait is aborted by a kernel signal arriving, we stop waiting.
- *      If a response from UniFi is not what we expected, we discard it and
- *      wait again. This could be a response from an aborted request. If we
- *      see several bad responses we assume we have lost synchronisation with
- *      UniFi.
- * ---------------------------------------------------------------------------
- */
-static int
-unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout)
-{
-    int retries = 0;
-    long r;
-    long t = timeout;
-    unsigned int sent_seq_no;
-
-    /* Convert t in ms to jiffies */
-    t = msecs_to_jiffies(t);
-
-    do {
-        /* Wait for the confirm or timeout. */
-        r = wait_event_interruptible_timeout(pcli->udi_wq,
-                                             (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
-                                             t);
-        /* Check for general i/o error */
-        if (priv->io_aborted) {
-            unifi_error(priv, "MLME operation aborted\n");
-            return -EIO;
-        }
-
-        /*
-         * If r=0 the request has timed-out.
-         * If r>0 the request has completed successfully.
-         * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
-         */
-        if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
-            unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
-                        sig_reply_id,  jiffies_to_msecs(t));
-            pcli->wake_up_wq_id = 0;
-            return -ETIMEDOUT;
-        } else if (r == -ERESTARTSYS) {
-            unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
-            pcli->wake_up_wq_id = 0;
-            return -EINTR;
-        } else {
-            /* Get the sequence number of the signal that we previously set. */
-            if (pcli->seq_no != 0) {
-                sent_seq_no = pcli->seq_no - 1;
-            } else {
-                sent_seq_no = 0x0F;
-            }
-
-            unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
-                        pcli->wake_up_wq_id,
-                        pcli->wake_seq_no, sent_seq_no);
-
-            /* The two sequence ids must match. */
-            if (pcli->wake_seq_no == sent_seq_no) {
-                /* and the signal ids must match. */
-                if (sig_reply_id == pcli->wake_up_wq_id) {
-                    /* Found the expected signal */
-                    break;
-                } else {
-                    /* This should never happen ... */
-                    unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
-                                pcli->wake_up_wq_id,
-                                sig_reply_id,
-                                pcli->wake_seq_no);
-                    pcli->wake_up_wq_id = 0;
-                    return -EIO;
-                }
-            }
-            /* Wait for the next signal. */
-            pcli->wake_up_wq_id = 0;
-
-            retries ++;
-            if (retries >= 3) {
-                unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
-                            pcli->wake_up_wq_id,
-                            sig_reply_id);
-                pcli->wake_up_wq_id = 0;
-                return -EIO;
-            }
-        }
-    } while (1);
-
-    pcli->wake_up_wq_id = 0;
-
-    return 0;
-} /* unifi_mlme_wait_for_reply() */
-
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_mlme_blocking_request
- *
- *      Send a MLME request signal to UniFi.
- *
- * Arguments:
- *      priv            Pointer to device private context struct
- *      pcli            Pointer to context of calling process
- *      sig             Pointer to the signal to send
- *      data_ptrs       Pointer to the bulk data of the signal
- *      timeout         The request's timeout.
- *
- * Returns:
- *      0 on success, 802.11 result code on error.
- * ---------------------------------------------------------------------------
- */
-int
-unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
-                            CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
-                            int timeout)
-{
-    int r;
-
-    if (sig->SignalPrimitiveHeader.SignalId == 0) {
-        unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
-                    sig->SignalPrimitiveHeader.SignalId);
-        return -EINVAL;
-    }
-
-    down(&priv->mlme_blocking_mutex);
-
-    sig->SignalPrimitiveHeader.ReceiverProcessId = 0;
-    sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no;
-
-    unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n",
-                pcli->client_id,
-                sig->SignalPrimitiveHeader.SenderProcessId,
-                sig->SignalPrimitiveHeader.SignalId);
-    /* Send the signal to UniFi */
-    r = ul_send_signal_unpacked(priv, sig, data_ptrs);
-    if (r) {
-        up(&priv->mlme_blocking_mutex);
-        unifi_error(priv, "Error queueing MLME REQUEST signal\n");
-        return r;
-    }
-
-    unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n",
-                sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
-
-    /*
-     * Advance the sequence number of the last sent signal, only
-     * if the signal has been successfully set.
-     */
-    pcli->seq_no++;
-    if (pcli->seq_no > 0x0F) {
-        pcli->seq_no = 0;
-    }
-
-    r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
-    up(&priv->mlme_blocking_mutex);
-
-    if (r) {
-        unifi_error(priv, "Error waiting for MLME CONFIRM signal\n");
-        return r;
-    }
-
-    return 0;
-} /* unifi_mlme_blocking_request() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_mlme_copy_reply_and_wakeup_client
- *
- *      Copy the reply signal from UniFi to the client's structure
- *      and wake up the waiting client.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
-                                        CSR_SIGNAL *signal, int signal_len,
-                                        const bulk_data_param_t *bulkdata)
-{
-    int i;
-
-    /* Copy the signal to the reply */
-    memcpy(pcli->reply_signal, signal, signal_len);
-
-    /* Get the sequence number of the signal that woke us up. */
-    pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F;
-
-    /* Append any bulk data */
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-        if (bulkdata->d[i].data_length > 0) {
-            if (bulkdata->d[i].os_data_ptr) {
-                memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length);
-                pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length;
-            } else {
-                pcli->reply_bulkdata[i]->length = 0;
-            }
-        }
-    }
-
-    /* Wake the requesting MLME function. */
-    pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId;
-    wake_up_interruptible(&pcli->udi_wq);
-
-} /* unifi_mlme_copy_reply_and_wakeup_client() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_abort_mlme
- *
- *      Abort any MLME operation in progress.
- *      This is used in the error recovery mechanism.
- *
- *  Arguments:
- *      priv          Pointer to driver context.
- *
- *  Returns:
- *      0 on success.
- * ---------------------------------------------------------------------------
- */
-int
-uf_abort_mlme(unifi_priv_t *priv)
-{
-    ul_client_t *ul_cli;
-
-    /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
-    priv->io_aborted = 1;
-
-    ul_cli = priv->netdev_client;
-    if (ul_cli) {
-        wake_up_interruptible(&ul_cli->udi_wq);
-    }
-
-    ul_cli = priv->wext_client;
-    if (ul_cli) {
-        wake_up_interruptible(&ul_cli->udi_wq);
-    }
-
-    return 0;
-} /* uf_abort_mlme() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *
- *      Human-readable decoding of Reason and Result codes.
- *
- * ---------------------------------------------------------------------------
- */
-
-struct mlme_code {
-    const char *name;
-    int id;
-};
-
-static const struct mlme_code Result_codes[] = {
-    { "Success",                             0x0000 },
-    { "Unspecified Failure",                 0x0001 },
-    /* (Reserved)                      0x0002 - 0x0009 */
-    { "Refused Capabilities Mismatch",       0x000A },
-    /* (Reserved)                          0x000B */
-    { "Refused External Reason",             0x000C },
-    /* (Reserved)                      0x000D - 0x0010 */
-    { "Refused AP Out Of Memory",            0x0011 },
-    { "Refused Basic Rates Mismatch",        0x0012 },
-    /* (Reserved)                      0x0013 - 0x001F */
-    { "Failure",                             0x0020 },
-    /* (Reserved)                      0x0021 - 0x0024 */
-    { "Refused Reason Unspecified",          0x0025 },
-    { "Invalid Parameters",                  0x0026 },
-    { "Rejected With Suggested Changes",     0x0027 },
-    /* (Reserved)                      0x0028 - 0x002E */
-    { "Rejected For Delay Period",           0x002F },
-    { "Not Allowed",                         0x0030 },
-    { "Not Present",                         0x0031 },
-    { "Not QSTA",                            0x0032 },
-    /* (Reserved)                      0x0033 - 0x7FFF */
-    { "Timeout",                             0x8000 },
-    { "Too Many Simultaneous Requests",      0x8001 },
-    { "BSS Already Started Or Joined",       0x8002 },
-    { "Not Supported",                       0x8003 },
-    { "Transmission Failure",                0x8004 },
-    { "Refused Not Authenticated",           0x8005 },
-    { "Reset Required Before Start",         0x8006 },
-    { "LM Info Unavailable",                 0x8007 },
-    { NULL, -1 }
-};
-
-static const struct mlme_code Reason_codes[] = {
-    /* (Reserved)                      0x0000 */
-    { "Unspecified Reason",              0x0001 },
-    { "Authentication Not Valid",        0x0002 },
-    { "Deauthenticated Leave BSS",       0x0003 },
-    { "Disassociated Inactivity",        0x0004 },
-    { "AP Overload",                     0x0005 },
-    { "Class2 Frame Error",              0x0006 },
-    { "Class3 Frame Error",              0x0007 },
-    { "Disassociated Leave BSS",         0x0008 },
-    { "Association Not Authenticated",   0x0009 },
-    { "Disassociated Power Capability",  0x000A },
-    { "Disassociated Supported Channels", 0x000B },
-    /* (Reserved)                      0x000C */
-    { "Invalid Information Element",     0x000D },
-    { "Michael MIC Failure",             0x000E },
-    { "Fourway Handshake Timeout",       0x000F },
-    { "Group Key Update Timeout",        0x0010 },
-    { "Handshake Element Different",     0x0011 },
-    { "Invalid Group Cipher",            0x0012 },
-    { "Invalid Pairwise Cipher",         0x0013 },
-    { "Invalid AKMP",                    0x0014 },
-    { "Unsupported RSN IE Version",      0x0015 },
-    { "Invalid RSN IE Capabilities",     0x0016 },
-    { "Dot1X Auth Failed",               0x0017 },
-    { "Cipher Rejected By Policy",       0x0018 },
-    /* (Reserved)                  0x0019 - 0x001F */
-    { "QoS Unspecified Reason",          0x0020 },
-    { "QoS Insufficient Bandwidth",      0x0021 },
-    { "QoS Excessive Not Ack",           0x0022 },
-    { "QoS TXOP Limit Exceeded",         0x0023 },
-    { "QSTA Leaving",                    0x0024 },
-    { "End TS, End DLS, End BA",         0x0025 },
-    { "Unknown TS, Unknown DLS, Unknown BA", 0x0026 },
-    { "Timeout",                         0x0027 },
-    /* (Reserved)                  0x0028 - 0x002C */
-    { "STAKey Mismatch",                 0x002D },
-    { NULL, -1 }
-};
-
-
-static const char *
-lookup_something(const struct mlme_code *n, int id)
-{
-    for (; n->name; n++) {
-        if (n->id == id) {
-            return n->name;
-        }
-    }
-
-    /* not found */
-    return NULL;
-} /* lookup_something() */
-
-
-const char *
-lookup_result_code(int result)
-{
-    static char fallback[16];
-    const char *str;
-
-    str = lookup_something(Result_codes, result);
-
-    if (str == NULL) {
-        snprintf(fallback, 16, "%d", result);
-        str = fallback;
-    }
-
-    return str;
-} /* lookup_result_code() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  lookup_reason
- *
- *      Return a description string for a WiFi MLME ReasonCode.
- *
- *  Arguments:
- *      reason          The ReasonCode to interpret.
- *
- *  Returns:
- *      Pointer to description string.
- * ---------------------------------------------------------------------------
- */
-const char *
-lookup_reason_code(int reason)
-{
-    static char fallback[16];
-    const char *str;
-
-    str = lookup_something(Reason_codes, reason);
-
-    if (str == NULL) {
-        snprintf(fallback, 16, "%d", reason);
-        str = fallback;
-    }
-
-    return str;
-} /* lookup_reason_code() */
-
diff --git a/drivers/staging/csr/monitor.c b/drivers/staging/csr/monitor.c
deleted file mode 100644 (file)
index e11f6cb..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     monitor.c
- *
- * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-#include "unifi_priv.h"
-
-#ifdef UNIFI_SNIFF_ARPHRD
-
-
-#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
-#include <net/ieee80211_radiotap.h>
-#endif
-
-#ifndef ETH_P_80211_RAW
-#define ETH_P_80211_RAW ETH_P_ALL
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_start_sniff
- *
- *      Start UniFi capture in SNIFF mode, i.e capture everything it hears.
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *
- *  Returns:
- *      0 on success or kernel error code
- * ---------------------------------------------------------------------------
- */
-int
-uf_start_sniff(unifi_priv_t *priv)
-{
-    ul_client_t *pcli = priv->wext_client;
-    CSR_SIGNAL signal;
-    CSR_MLME_SNIFFJOIN_REQUEST *req = &signal.u.MlmeSniffjoinRequest;
-    int timeout = 1000;
-    int r;
-
-    req->Ifindex = priv->if_index;
-    req->Channel = priv->wext_conf.channel;
-    req->ChannelStartingFactor = 0;
-
-    signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SNIFFJOIN_REQUEST_ID;
-
-    r = unifi_mlme_blocking_request(priv, pcli, &signal, NULL, timeout);
-    if (r < 0) {
-        unifi_error(priv, "failed to send SNIFFJOIN request, error %d\n", r);
-        return r;
-    }
-
-    r = pcli->reply_signal->u.MlmeSniffjoinConfirm.Resultcode;
-    if (r) {
-        unifi_notice(priv, "SNIFFJOIN request was rejected with result 0x%X (%s)\n",
-                     r, lookup_result_code(r));
-        return -EIO;
-    }
-
-    return 0;
-} /* uf_start_sniff() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- * netrx_radiotap
- *
- *      Reformat a UniFi SNIFFDATA signal into a radiotap packet.
- *
- * Arguments:
- *      priv            OS private context pointer.
- *      ind             Pointer to a MA_UNITDATA_INDICATION or
- *                      DS_UNITDATA_INDICATION indication structure.
- *
- * Notes:
- *      Radiotap header values are all little-endian, UniFi signals will have
- *      been converted to host-endian.
- * ---------------------------------------------------------------------------
- */
-#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
-static void
-netrx_radiotap(unifi_priv_t *priv,
-               const CSR_MA_SNIFFDATA_INDICATION *ind,
-               struct sk_buff *skb_orig)
-{
-    struct net_device *dev = priv->netdev;
-    struct sk_buff *skb = NULL;
-    unsigned char *ptr;
-    unsigned char *base;
-    int ind_data_len = skb_orig->len - 2 - ETH_HLEN;
-    struct unifi_rx_radiotap_header {
-        struct ieee80211_radiotap_header rt_hdr;
-        /* IEEE80211_RADIOTAP_TSFT */
-        u64 rt_tsft;
-        /* IEEE80211_RADIOTAP_FLAGS */
-        u8  rt_flags;
-        /* IEEE80211_RADIOTAP_RATE */
-        u8  rt_rate;
-        /* IEEE80211_RADIOTAP_CHANNEL */
-        u16 rt_chan;
-        u16 rt_chan_flags;
-        /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
-        u8  rt_dbm_antsignal;
-        /* IEEE80211_RADIOTAP_DBM_ANTNOISE */
-        u8  rt_dbm_antnoise;
-        /* IEEE80211_RADIOTAP_ANTENNA */
-        u8  rt_antenna;
-
-        /* pad to 4-byte boundary */
-        u8 pad[3];
-    } __attribute__((__packed__));
-
-    struct unifi_rx_radiotap_header *unifi_rt;
-    int signal, noise, snr;
-
-    if (ind_data_len <= 0) {
-        unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n");
-        return;
-    }
-
-    /*
-     * Allocate a SKB for the received data packet, including radiotap
-     * header.
-     */
-    skb = dev_alloc_skb(ind_data_len + sizeof(struct unifi_rx_radiotap_header) + 4);
-    if (! skb) {
-        unifi_error(priv, "alloc_skb failed.\n");
-        priv->stats.rx_errors++;
-        return;
-    }
-
-    base = skb->data;
-
-    /* Reserve the radiotap header at the front of skb */
-    unifi_rt = (struct unifi_rx_radiotap_header *)
-        skb_put(skb, sizeof(struct unifi_rx_radiotap_header));
-
-    /* Copy in the 802.11 frame */
-    ptr = skb_put(skb, ind_data_len);
-    memcpy(ptr, skb_orig->data, ind_data_len);
-
-    unifi_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
-    unifi_rt->rt_hdr.it_pad = 0;       /* always good to zero */
-    unifi_rt->rt_hdr.it_len = sizeof(struct unifi_rx_radiotap_header);
-
-    /* Big bitfield of all the fields we provide in radiotap */
-    unifi_rt->rt_hdr.it_present = 0
-        | (1 << IEEE80211_RADIOTAP_TSFT)
-        | (1 << IEEE80211_RADIOTAP_FLAGS)
-        | (1 << IEEE80211_RADIOTAP_RATE)
-        | (1 << IEEE80211_RADIOTAP_CHANNEL)
-        | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)
-        | (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)
-        | (1 << IEEE80211_RADIOTAP_ANTENNA)
-        ;
-
-
-    /* No flags to set */
-    unifi_rt->rt_tsft = (((u64)ind->Timestamp.x[7]) | (((u64)ind->Timestamp.x[6]) << 8) |
-                         (((u64)ind->Timestamp.x[5]) << 16) | (((u64)ind->Timestamp.x[4]) << 24) |
-                         (((u64)ind->Timestamp.x[3]) << 32) | (((u64)ind->Timestamp.x[2]) << 40) |
-                         (((u64)ind->Timestamp.x[1]) << 48) | (((u64)ind->Timestamp.x[0]) << 56));
-
-    unifi_rt->rt_flags = 0;
-
-    unifi_rt->rt_rate = ind->Rate;
-
-    unifi_rt->rt_chan = cpu_to_le16(ieee80211chan2mhz(priv->wext_conf.channel));
-    unifi_rt->rt_chan_flags = 0;
-
-    /* Convert signal to dBm */
-    signal = (s16)unifi2host_16(ind->Rssi);  /* in dBm */
-    snr    = (s16)unifi2host_16(ind->Snr);   /* in dB */
-    noise  = signal - snr;
-
-    unifi_rt->rt_dbm_antsignal = signal;
-    unifi_rt->rt_dbm_antnoise = noise;
-
-    unifi_rt->rt_antenna = ind->AntennaId;
-
-
-    skb->dev = dev;
-    skb_reset_mac_header(skb);
-    skb->pkt_type = PACKET_OTHERHOST;
-    skb->protocol = __constant_htons(ETH_P_80211_RAW);
-    memset(skb->cb, 0, sizeof(skb->cb));
-
-    /* Pass up to Linux network stack */
-    netif_rx_ni(skb);
-
-    dev->last_rx = jiffies;
-
-    /* Bump the rx stats */
-    priv->stats.rx_packets++;
-    priv->stats.rx_bytes += ind_data_len;
-
-} /* netrx_radiotap() */
-#endif /* RADIOTAP */
-
-
-/*
- * ---------------------------------------------------------------------------
- * netrx_prism
- *
- *      Reformat a UniFi SNIFFDATA signal into a Prism format sniff packet.
- *
- * Arguments:
- *      priv            OS private context pointer.
- *      ind             Pointer to a MA_UNITDATA_INDICATION or
- *                      DS_UNITDATA_INDICATION indication structure.
- *
- * Notes:
- *      Radiotap header values are all little-endian, UniFi signals will have
- *      been converted to host-endian.
- * ---------------------------------------------------------------------------
- */
-#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM)
-static void
-netrx_prism(unifi_priv_t *priv,
-            const CSR_MA_SNIFFDATA_INDICATION *ind,
-            struct sk_buff *skb_orig)
-{
-    struct net_device *dev = priv->netdev;
-    struct sk_buff *skb = NULL;
-    unsigned char *ptr;
-    unsigned char *base;
-    int ind_data_len = skb_orig->len - 2 - ETH_HLEN;
-#define WLANCAP_MAGIC_COOKIE_V1 0x80211001
-    struct avs_header_v1 {
-        uint32  version;
-        uint32  length;
-        uint64  mactime;
-        uint64  hosttime;
-        uint32  phytype;
-        uint32  channel;
-        uint32  datarate;
-        uint32  antenna;
-        uint32  priority;
-        uint32  ssi_type;
-        int32   ssi_signal;
-        int32   ssi_noise;
-        uint32  preamble;
-        uint32  encoding;
-    } *avs;
-    int signal, noise, snr;
-
-    if (ind_data_len <= 0) {
-        unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n");
-        return;
-    }
-
-    /*
-     * Allocate a SKB for the received data packet, including radiotap
-     * header.
-     */
-    skb = dev_alloc_skb(ind_data_len + sizeof(struct avs_header_v1) + 4);
-    if (! skb) {
-        unifi_error(priv, "alloc_skb failed.\n");
-        priv->stats.rx_errors++;
-        return;
-    }
-
-    base = skb->data;
-
-    /* Reserve the radiotap header at the front of skb */
-    avs = (struct avs_header_v1 *)skb_put(skb, sizeof(struct avs_header_v1));
-
-    /* Copy in the 802.11 frame */
-    ptr = skb_put(skb, ind_data_len);
-    memcpy(ptr, skb_orig->data, ind_data_len);
-
-    /* Convert signal to dBm */
-    signal = 0x10000 - ((s16)unifi2host_16(ind->Rssi));  /* in dBm */
-    snr    = (s16)unifi2host_16(ind->Snr);   /* in dB */
-    noise  = signal - snr;
-
-    avs->version        = htonl(WLANCAP_MAGIC_COOKIE_V1);
-    avs->length         = htonl(sizeof(struct avs_header_v1));
-    avs->mactime        = __cpu_to_be64(ind->Timestamp);
-    avs->hosttime       = __cpu_to_be64(jiffies);
-    avs->phytype        = htonl(9);             /* dss_ofdm_dot11_g */
-    avs->channel        = htonl(priv->wext_conf.channel);
-    avs->datarate       = htonl(ind->Rate * 5);
-    avs->antenna        = htonl(ind->Antenna);
-    avs->priority       = htonl(0);             /* unknown */
-    avs->ssi_type       = htonl(2);             /* dBm */
-    avs->ssi_signal     = htonl(signal);
-    avs->ssi_noise      = htonl(noise);
-    avs->preamble       = htonl(0); /* unknown */
-    avs->encoding       = htonl(0); /* unknown */
-
-
-    skb->dev = dev;
-    skb->mac.raw = skb->data;
-    skb->pkt_type = PACKET_OTHERHOST;
-    skb->protocol = __constant_htons(ETH_P_80211_RAW);
-    memset(skb->cb, 0, sizeof(skb->cb));
-
-    /* Pass up to Linux network stack */
-    netif_rx_ni(skb);
-
-    dev->last_rx = jiffies;
-
-    /* Bump the rx stats */
-    priv->stats.rx_packets++;
-    priv->stats.rx_bytes += ind_data_len;
-
-} /* netrx_prism() */
-#endif /* PRISM */
-
-
-/*
- * ---------------------------------------------------------------------------
- * ma_sniffdata_ind
- *
- *      Reformat a UniFi SNIFFDATA signal into a network
- *
- * Arguments:
- *      ospriv          OS private context pointer.
- *      ind             Pointer to a MA_UNITDATA_INDICATION or
- *                      DS_UNITDATA_INDICATION indication structure.
- *      bulkdata        Pointer to a bulk data structure, describing
- *                      the data received.
- *
- * Notes:
- *      Radiotap header values are all little-endian, UniFi signals will have
- *      been converted to host-endian.
- * ---------------------------------------------------------------------------
- */
-void
-ma_sniffdata_ind(void *ospriv,
-                 const CSR_MA_SNIFFDATA_INDICATION *ind,
-                 const bulk_data_param_t *bulkdata)
-{
-    unifi_priv_t *priv = ospriv;
-    struct net_device *dev = priv->netdev;
-    struct sk_buff *skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
-
-    if (bulkdata->d[0].data_length == 0) {
-        unifi_warning(priv, "rx: MA-SNIFFDATA indication with zero bulk data\n");
-        return;
-    }
-
-    skb->len = bulkdata->d[0].data_length;
-
-    /* We only process data packets if the interface is open */
-    if (unlikely(!netif_running(dev))) {
-        priv->stats.rx_dropped++;
-        priv->wext_conf.wireless_stats.discard.misc++;
-        dev_kfree_skb(skb);
-        return;
-    }
-
-    if (ind->ReceptionStatus) {
-        priv->stats.rx_dropped++;
-        priv->wext_conf.wireless_stats.discard.misc++;
-        printk(KERN_INFO "unifi: Dropping corrupt sniff packet\n");
-        dev_kfree_skb(skb);
-        return;
-    }
-
-#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM)
-    netrx_prism(priv, ind, skb);
-#endif /* PRISM */
-
-#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
-    netrx_radiotap(priv, ind, skb);
-#endif /* RADIOTAP */
-
-    dev_kfree_skb(skb);
-
-} /* ma_sniffdata_ind() */
-
-
-#endif /* UNIFI_SNIFF_ARPHRD */
-
diff --git a/drivers/staging/csr/netdev.c b/drivers/staging/csr/netdev.c
deleted file mode 100644 (file)
index 9c716c1..0000000
+++ /dev/null
@@ -1,3307 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     netdev.c
- *
- * PURPOSE:
- *      This file provides the upper edge interface to the linux netdevice
- *      and wireless extensions.
- *      It is part of the porting exercise.
- *
- * Copyright (C) 2005-2010 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-/*
- * Porting Notes:
- * This file implements the data plane of the UniFi linux driver.
- *
- * All the Tx packets are passed to the HIP core lib, using the
- * unifi_send_signal() API. For EAPOL packets use the MLME-EAPOL.req
- * signal, for all other use the MLME-UNITDATA.req. The unifi_send_signal()
- * expects the wire-formatted (packed) signal. For convenience, in the OS
- * layer we only use the native (unpacked) signal structures. The HIP core lib
- * provides the write_pack() helper function to convert to the packed signal.
- * The packet is stored in the bulk data of the signal. We do not need to
- * allocate new memory to store the packet, because unifi_net_data_malloc()
- * is implemented to return a skb, which is the format of packet in Linux.
- * The HIP core lib frees the bulk data buffers, so we do not need to do
- * this in the OS layer.
- *
- * All the Rx packets are MLME-UNITDATA.ind signals, passed by the HIP core lib
- * in unifi_receive_event(). We do not need to allocate an skb and copy the
- * received packet because the HIP core lib has stored in memory allocated by
- * unifi_net_data_malloc(). Also, we can perform the 802.11 to Ethernet
- * translation in-place because we allocate the extra memory allocated in
- * unifi_net_data_malloc().
- *
- * If possible, the porting exercise should appropriately implement
- * unifi_net_data_malloc() and unifi_net_data_free() to save copies between
- * network and driver buffers.
- */
-
-#include <linux/types.h>
-#include <linux/etherdevice.h>
-#include <linux/mutex.h>
-#include <linux/semaphore.h>
-#include <linux/vmalloc.h>
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "unifi_priv.h"
-#include <net/pkt_sched.h>
-
-
-/* Wext handler is supported only if CSR_SUPPORT_WEXT is defined */
-#ifdef CSR_SUPPORT_WEXT
-extern struct iw_handler_def unifi_iw_handler_def;
-#endif /* CSR_SUPPORT_WEXT */
-static void check_ba_frame_age_timeout( unifi_priv_t *priv,
-                                            netInterface_priv_t *interfacePriv,
-                                            ba_session_rx_struct *ba_session);
-static void process_ba_frame(unifi_priv_t *priv,
-                             netInterface_priv_t *interfacePriv,
-                             ba_session_rx_struct *ba_session,
-                             frame_desc_struct *frame_desc);
-static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv);
-static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata);
-static void process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata);
-static int uf_net_open(struct net_device *dev);
-static int uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static int uf_net_stop(struct net_device *dev);
-static struct net_device_stats *uf_net_get_stats(struct net_device *dev);
-static u16 uf_net_select_queue(struct net_device *dev, struct sk_buff *skb);
-static netdev_tx_t uf_net_xmit(struct sk_buff *skb, struct net_device *dev);
-static void uf_set_multicast_list(struct net_device *dev);
-
-
-typedef int (*tx_signal_handler)(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority);
-
-#ifdef CONFIG_NET_SCHED
-/*
- * Queueing Discipline Interface
- * Only used if kernel is configured with CONFIG_NET_SCHED
- */
-
-/*
- * The driver uses the qdisc interface to buffer and control all
- * outgoing traffic. We create a root qdisc, register our qdisc operations
- * and later we create two subsidiary pfifo queues for the uncontrolled
- * and controlled ports.
- *
- * The network stack delivers all outgoing packets in our enqueue handler.
- * There, we classify the packet and decide whether to store it or drop it
- * (if the controlled port state is set to "discard").
- * If the packet is enqueued, the network stack call our dequeue handler.
- * There, we decide whether we can send the packet, delay it or drop it
- * (the controlled port configuration might have changed meanwhile).
- * If a packet is dequeued, then the network stack calls our hard_start_xmit
- * handler where finally we send the packet.
- *
- * If the hard_start_xmit handler fails to send the packet, we return
- * NETDEV_TX_BUSY and the network stack call our requeue handler where
- * we put the packet back in the same queue in came from.
- *
- */
-
-struct uf_sched_data
-{
-    /* Traffic Classifier TBD */
-    struct tcf_proto *filter_list;
-    /* Our two queues */
-    struct Qdisc *queues[UNIFI_TRAFFIC_Q_MAX];
-};
-
-struct uf_tx_packet_data {
-    /* Queue the packet is stored in */
-    unifi_TrafficQueue queue;
-    /* QoS Priority determined when enqueing packet */
-    CSR_PRIORITY priority;
-    /* Debug */
-    unsigned long host_tag;
-};
-
-#endif /* CONFIG_NET_SCHED */
-
-static const struct net_device_ops uf_netdev_ops =
-{
-    .ndo_open = uf_net_open,
-    .ndo_stop = uf_net_stop,
-    .ndo_start_xmit = uf_net_xmit,
-    .ndo_do_ioctl = uf_net_ioctl,
-    .ndo_get_stats = uf_net_get_stats, /* called by /proc/net/dev */
-    .ndo_set_rx_mode = uf_set_multicast_list,
-    .ndo_select_queue = uf_net_select_queue,
-};
-
-static u8 oui_rfc1042[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
-static u8 oui_8021h[P80211_OUI_LEN]   = { 0x00, 0x00, 0xf8 };
-
-
-/* Callback for event logging to blocking clients */
-static void netdev_mlme_event_handler(ul_client_t  *client,
-                                      const u8 *sig_packed, int sig_len,
-                                      const bulk_data_param_t *bulkdata,
-                                      int dir);
-
-#ifdef CSR_SUPPORT_WEXT
-/* Declare netdev_notifier block which will contain the state change
- * handler callback function
- */
-static struct notifier_block uf_netdev_notifier;
-#endif
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_alloc_netdevice
- *
- *      Allocate memory for the net_device and device private structs
- *      for this interface.
- *      Fill in the fields, but don't register the interface yet.
- *      We need to configure the UniFi first.
- *
- *  Arguments:
- *      sdio_dev        Pointer to SDIO context handle to use for all
- *                      SDIO ops.
- *      bus_id          A small number indicating the SDIO card position on the
- *                      bus. Typically this is the slot number, e.g. 0, 1 etc.
- *                      Valid values are 0 to MAX_UNIFI_DEVS-1.
- *
- *  Returns:
- *      Pointer to device private struct.
- *
- *  Notes:
- *      The net_device and device private structs are allocated together
- *      and should be freed by freeing the net_device pointer.
- * ---------------------------------------------------------------------------
- */
-unifi_priv_t *
-uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id)
-{
-    struct net_device *dev;
-    unifi_priv_t *priv;
-    netInterface_priv_t *interfacePriv;
-#ifdef CSR_SUPPORT_WEXT
-    int rc;
-#endif
-    unsigned char i; /* loop index */
-
-    /*
-     * Allocate netdevice struct, assign name template and
-     * setup as an ethernet device.
-     * The net_device and private structs are zeroed. Ether_setup() then
-     * sets up ethernet handlers and values.
-     * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices,
-     * so use "eth*" (like other wireless extns drivers).
-     */
-    dev = alloc_etherdev_mq(sizeof(unifi_priv_t) + sizeof(netInterface_priv_t), UNIFI_TRAFFIC_Q_MAX);
-
-    if (dev == NULL) {
-        return NULL;
-    }
-
-    /* Set up back pointer from priv to netdev */
-    interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    priv = (unifi_priv_t *)(interfacePriv + 1);
-    interfacePriv->privPtr = priv;
-    interfacePriv->InterfaceTag = 0;
-
-
-    /* Initialize all supported netdev interface to be NULL */
-    for(i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
-        priv->netdev[i] = NULL;
-        priv->interfacePriv[i] = NULL;
-    }
-    priv->netdev[0] = dev;
-    priv->interfacePriv[0] = interfacePriv;
-
-    /* Setup / override net_device fields */
-    dev->netdev_ops = &uf_netdev_ops;
-
-#ifdef CSR_SUPPORT_WEXT
-    dev->wireless_handlers = &unifi_iw_handler_def;
-#if IW_HANDLER_VERSION < 6
-    dev->get_wireless_stats = unifi_get_wireless_stats;
-#endif /* IW_HANDLER_VERSION */
-#endif /* CSR_SUPPORT_WEXT */
-
-    /* This gives us enough headroom to add the 802.11 header */
-    dev->needed_headroom = 32;
-
-    /* Use bus_id as instance number */
-    priv->instance = bus_id;
-    /* Store SDIO pointer to pass in the core */
-    priv->sdio = sdio_dev;
-
-    sdio_dev->driverData = (void*)priv;
-    /* Consider UniFi to be uninitialised */
-    priv->init_progress = UNIFI_INIT_NONE;
-
-    priv->prev_queue = 0;
-
-    /*
-     * Initialise the clients structure array.
-     * We do not need protection around ul_init_clients() because
-     * the character device can not be used until uf_alloc_netdevice()
-     * returns and Unifi_instances[bus_id]=priv is set, since unifi_open()
-     * will return -ENODEV.
-     */
-    ul_init_clients(priv);
-
-    /*
-     * Register a new ul client to send the multicast list signals.
-     * Note: priv->instance must be set before calling this.
-     */
-    priv->netdev_client = ul_register_client(priv,
-            0,
-            netdev_mlme_event_handler);
-    if (priv->netdev_client == NULL) {
-        unifi_error(priv,
-                "Failed to register a unifi client for background netdev processing\n");
-        free_netdev(priv->netdev[0]);
-        return NULL;
-    }
-    unifi_trace(priv, UDBG2, "Netdev %p client (id:%d s:0x%X) is registered\n",
-            dev, priv->netdev_client->client_id, priv->netdev_client->sender_id);
-
-    priv->sta_wmm_capabilities = 0;
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_SUPPORT_SME))
-    priv->wapi_multicast_filter = 0;
-    priv->wapi_unicast_filter = 0;
-    priv->wapi_unicast_queued_pkt_filter = 0;
-#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
-    priv->isWapiConnection = FALSE;
-#endif
-#endif
-
-    /* Enable all queues by default */
-    interfacePriv->queueEnabled[0] = 1;
-    interfacePriv->queueEnabled[1] = 1;
-    interfacePriv->queueEnabled[2] = 1;
-    interfacePriv->queueEnabled[3] = 1;
-
-#ifdef CSR_SUPPORT_SME
-    priv->allPeerDozing = 0;
-#endif
-    /*
-     * Initialise the OS private struct.
-     */
-    /*
-     * Instead of deciding in advance to use 11bg or 11a, we could do a more
-     * clever scan on both radios.
-     */
-    if (use_5g) {
-        priv->if_index = CSR_INDEX_5G;
-        unifi_info(priv, "Using the 802.11a radio\n");
-    } else {
-        priv->if_index = CSR_INDEX_2G4;
-    }
-
-    /* Initialise bh thread structure */
-    priv->bh_thread.thread_task = NULL;
-    priv->bh_thread.block_thread = 1;
-    init_waitqueue_head(&priv->bh_thread.wakeup_q);
-    priv->bh_thread.wakeup_flag = 0;
-    sprintf(priv->bh_thread.name, "uf_bh_thread");
-
-    /* reset the connected state for the interface */
-    interfacePriv->connected = UnifiConnectedUnknown;  /* -1 unknown, 0 no, 1 yes */
-
-#ifdef USE_DRIVER_LOCK
-    sema_init(&priv->lock, 1);
-#endif /* USE_DRIVER_LOCK */
-
-    spin_lock_init(&priv->send_signal_lock);
-
-    spin_lock_init(&priv->m4_lock);
-    sema_init(&priv->ba_mutex, 1);
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-    spin_lock_init(&priv->wapi_lock);
-#endif
-
-#ifdef CSR_SUPPORT_SME
-    spin_lock_init(&priv->staRecord_lock);
-    spin_lock_init(&priv->tx_q_lock);
-#endif
-
-    /* Create the Traffic Analysis workqueue */
-    priv->unifi_workqueue = create_singlethread_workqueue("unifi_workq");
-    if (priv->unifi_workqueue == NULL) {
-        /* Deregister priv->netdev_client */
-        ul_deregister_client(priv->netdev_client);
-        free_netdev(priv->netdev[0]);
-        return NULL;
-    }
-
-#ifdef CSR_SUPPORT_SME
-    /* Create the Multicast Addresses list work structure */
-    INIT_WORK(&priv->multicast_list_task, uf_multicast_list_wq);
-
-    /* Create m4 buffering work structure */
-    INIT_WORK(&interfacePriv->send_m4_ready_task, uf_send_m4_ready_wq);
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-    /* Create work structure to buffer the WAPI data packets to be sent to SME for encryption */
-    INIT_WORK(&interfacePriv->send_pkt_to_encrypt, uf_send_pkt_to_encrypt);
-#endif
-#endif
-
-    priv->ref_count = 1;
-
-    priv->amp_client = NULL;
-    priv->coredump_mode = 0;
-    priv->ptest_mode = 0;
-    priv->wol_suspend = FALSE;
-    INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list);
-    INIT_LIST_HEAD(&interfacePriv->rx_controlled_list);
-    sema_init(&priv->rx_q_sem, 1);
-
-#ifdef CSR_SUPPORT_WEXT
-    interfacePriv->netdev_callback_registered = FALSE;
-    interfacePriv->wait_netdev_change = FALSE;
-    /* Register callback for netdevice state changes */
-    if ((rc = register_netdevice_notifier(&uf_netdev_notifier)) == 0) {
-        interfacePriv->netdev_callback_registered = TRUE;
-    }
-    else {
-        unifi_warning(priv, "Failed to register netdevice notifier : %d %p\n", rc, dev);
-    }
-#endif /* CSR_SUPPORT_WEXT */
-
-#ifdef CSR_WIFI_SPLIT_PATCH
-    /* set it to some invalid value */
-    priv->pending_mode_set.common.destination = 0xaaaa;
-#endif
-
-    return priv;
-} /* uf_alloc_netdevice() */
-
-/*
- *---------------------------------------------------------------------------
- *  uf_alloc_netdevice_for_other_interfaces
- *
- *      Allocate memory for the net_device and device private structs
- *      for this interface.
- *      Fill in the fields, but don't register the interface yet.
- *      We need to configure the UniFi first.
- *
- *  Arguments:
- *      interfaceTag   Interface number.
- *      sdio_dev        Pointer to SDIO context handle to use for all
- *                      SDIO ops.
- *      bus_id          A small number indicating the SDIO card position on the
- *                      bus. Typically this is the slot number, e.g. 0, 1 etc.
- *                      Valid values are 0 to MAX_UNIFI_DEVS-1.
- *
- *  Returns:
- *      Pointer to device private struct.
- *
- *  Notes:
- *      The device private structure contains the interfaceTag and pointer to the unifi_priv
- *      structure created allocated by net_device od interface0.
- *      The net_device and device private structs are allocated together
- *      and should be freed by freeing the net_device pointer.
- * ---------------------------------------------------------------------------
- */
-u8
-uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag)
-{
-    struct net_device *dev;
-    netInterface_priv_t *interfacePriv;
-
-    /*
-     * Allocate netdevice struct, assign name template and
-     * setup as an ethernet device.
-     * The net_device and private structs are zeroed. Ether_setup() then
-     * sets up ethernet handlers and values.
-     * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices,
-     * so use "eth*" (like other wireless extns drivers).
-     */
-    dev = alloc_etherdev_mq(sizeof(netInterface_priv_t), 1);
-    if (dev == NULL) {
-        return FALSE;
-    }
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_alloc_netdevice_for_other_interfaces bad interfaceTag\n");
-        return FALSE;
-    }
-
-    /* Set up back pointer from priv to netdev */
-    interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    interfacePriv->privPtr = priv;
-    interfacePriv->InterfaceTag = interfaceTag;
-    priv->netdev[interfaceTag] = dev;
-    priv->interfacePriv[interfacePriv->InterfaceTag] = interfacePriv;
-
-    /* reset the connected state for the interface */
-    interfacePriv->connected = UnifiConnectedUnknown;  /* -1 unknown, 0 no, 1 yes */
-    INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list);
-    INIT_LIST_HEAD(&interfacePriv->rx_controlled_list);
-
-    /* Setup / override net_device fields */
-    dev->netdev_ops = &uf_netdev_ops;
-
-#ifdef CSR_SUPPORT_WEXT
-    dev->wireless_handlers = &unifi_iw_handler_def;
-#if IW_HANDLER_VERSION < 6
-    dev->get_wireless_stats = unifi_get_wireless_stats;
-#endif /* IW_HANDLER_VERSION */
-#endif /* CSR_SUPPORT_WEXT */
-    return TRUE;
-} /* uf_alloc_netdevice() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_free_netdevice
- *
- *      Unregister the network device and free the memory allocated for it.
- *      NB This includes the memory for the priv struct.
- *
- *  Arguments:
- *      priv            Device private pointer.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-int
-uf_free_netdevice(unifi_priv_t *priv)
-{
-    int i;
-    unsigned long flags;
-
-    unifi_trace(priv, UDBG1, "uf_free_netdevice\n");
-
-    if (!priv) {
-        return -EINVAL;
-    }
-
-    /*
-     * Free any buffers used for holding firmware
-     */
-    uf_release_firmware_files(priv);
-
-#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
-    if (priv->connection_config.mlmeAssociateReqInformationElements) {
-        kfree(priv->connection_config.mlmeAssociateReqInformationElements);
-    }
-    priv->connection_config.mlmeAssociateReqInformationElements = NULL;
-    priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
-
-    if (priv->mib_data.length) {
-        vfree(priv->mib_data.data);
-    }
-    priv->mib_data.data = NULL;
-    priv->mib_data.length = 0;
-
-#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/
-
-    /* Free any bulkdata buffers allocated for M4 caching */
-    spin_lock_irqsave(&priv->m4_lock, flags);
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-        if (interfacePriv->m4_bulk_data.data_length > 0) {
-            unifi_trace(priv, UDBG5, "uf_free_netdevice: free M4 bulkdata %d\n", i);
-            unifi_net_data_free(priv, &interfacePriv->m4_bulk_data);
-        }
-    }
-    spin_unlock_irqrestore(&priv->m4_lock, flags);
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-    /* Free any bulkdata buffers allocated for M4 caching */
-    spin_lock_irqsave(&priv->wapi_lock, flags);
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-        if (interfacePriv->wapi_unicast_bulk_data.data_length > 0) {
-            unifi_trace(priv, UDBG5, "uf_free_netdevice: free WAPI PKT bulk data %d\n", i);
-            unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
-        }
-    }
-    spin_unlock_irqrestore(&priv->wapi_lock, flags);
-#endif
-
-#ifdef CSR_SUPPORT_WEXT
-    /* Unregister callback for netdevice state changes */
-    unregister_netdevice_notifier(&uf_netdev_notifier);
-#endif /* CSR_SUPPORT_WEXT */
-
-#ifdef CSR_SUPPORT_SME
-    /* Cancel work items and destroy the workqueue */
-    cancel_work_sync(&priv->multicast_list_task);
-#endif
-/* Destroy the workqueues. */
-    flush_workqueue(priv->unifi_workqueue);
-    destroy_workqueue(priv->unifi_workqueue);
-
-    /* Free up netdev in reverse order: priv is allocated with netdev[0].
-     * So, netdev[0] should be freed after all other netdevs are freed up
-     */
-    for (i=CSR_WIFI_NUM_INTERFACES-1; i>=0; i--) {
-        /*Free the netdev struct and priv, which are all one lump*/
-        if (priv->netdev[i]) {
-            unifi_error(priv, "uf_free_netdevice: netdev %d %p\n", i, priv->netdev[i]);
-            free_netdev(priv->netdev[i]);
-        }
-    }
-
-    return 0;
-} /* uf_free_netdevice() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_net_open
- *
- *      Called when userland does "ifconfig wlan0 up".
- *
- *  Arguments:
- *      dev             Device pointer.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static int
-uf_net_open(struct net_device *dev)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    /* If we haven't finished UniFi initialisation, we can't start */
-    if (priv->init_progress != UNIFI_INIT_COMPLETED) {
-        unifi_warning(priv, "%s: unifi not ready, failing net_open\n", __FUNCTION__);
-        return -EINVAL;
-    }
-
-#if (defined CSR_NATIVE_LINUX) && (defined UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT)
-    /*
-     * To sniff, the user must do "iwconfig mode monitor", which sets
-     * priv->wext_conf.mode to IW_MODE_MONITOR.
-     * Then he/she must do "ifconfig ethn up", which calls this fn.
-     * There is no point in starting the sniff with SNIFFJOIN until
-     * this point.
-     */
-    if (priv->wext_conf.mode == IW_MODE_MONITOR) {
-        int err;
-        err = uf_start_sniff(priv);
-        if (err) {
-            return err;
-        }
-        netif_carrier_on(dev);
-    }
-#endif
-
-#ifdef CSR_SUPPORT_WEXT
-    if (interfacePriv->wait_netdev_change) {
-        unifi_trace(priv, UDBG1, "%s: Waiting for NETDEV_CHANGE, assume connected\n",
-                    __FUNCTION__);
-        interfacePriv->connected = UnifiConnected;
-        interfacePriv->wait_netdev_change = FALSE;
-    }
-#endif
-
-    netif_tx_start_all_queues(dev);
-
-    return 0;
-} /* uf_net_open() */
-
-
-static int
-uf_net_stop(struct net_device *dev)
-{
-#if defined(CSR_NATIVE_LINUX) && defined(UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT)
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t*)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    /* Stop sniffing if in Monitor mode */
-    if (priv->wext_conf.mode == IW_MODE_MONITOR) {
-        if (priv->card) {
-            int err;
-            err = unifi_reset_state(priv, dev->dev_addr, 1);
-            if (err) {
-                return err;
-            }
-        }
-    }
-#endif
-
-    netif_tx_stop_all_queues(dev);
-
-    return 0;
-} /* uf_net_stop() */
-
-
-/* This is called after the WE handlers */
-static int
-uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
-    int rc;
-
-    rc = -EOPNOTSUPP;
-
-    return rc;
-} /* uf_net_ioctl() */
-
-
-
-static struct net_device_stats *
-uf_net_get_stats(struct net_device *dev)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-
-    return &interfacePriv->stats;
-} /* uf_net_get_stats() */
-
-static CSR_PRIORITY uf_get_packet_priority(unifi_priv_t *priv, netInterface_priv_t *interfacePriv, struct sk_buff *skb, const int proto)
-{
-    CSR_PRIORITY priority = CSR_CONTENTION;
-
-    priority = (CSR_PRIORITY) (skb->priority >> 5);
-
-    if (priority == CSR_QOS_UP0) { /* 0 */
-
-        unifi_trace(priv, UDBG5, "uf_get_packet_priority: proto = 0x%.4X\n", proto);
-
-        switch (proto) {
-            case 0x0800:        /* IPv4 */
-            case 0x814C:        /* SNMP */
-            case 0x880C:        /* GSMP */
-                priority = (CSR_PRIORITY) (skb->data[1 + ETH_HLEN] >> 5);
-                break;
-
-            case 0x8100:        /* VLAN */
-                priority = (CSR_PRIORITY) (skb->data[0 + ETH_HLEN] >> 5);
-                break;
-
-            case 0x86DD:        /* IPv6 */
-                priority = (CSR_PRIORITY) ((skb->data[0 + ETH_HLEN] & 0x0E) >> 1);
-                break;
-
-            default:
-                priority = CSR_QOS_UP0;
-                break;
-        }
-    }
-
-    /* Check if we are allowed to transmit on this AC. Because of ACM we may have to downgrade to a lower
-     * priority */
-    if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA ||
-        interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) {
-        unifi_TrafficQueue queue;
-
-        /* Keep trying lower priorities until we find a queue
-         * Priority to queue mapping is 1,2 - BK, 0,3 - BE, 4,5 - VI, 6,7 - VO */
-        queue = unifi_frame_priority_to_queue(priority);
-
-        while (queue > UNIFI_TRAFFIC_Q_BK && !interfacePriv->queueEnabled[queue]) {
-            queue--;
-            priority = unifi_get_default_downgrade_priority(queue);
-        }
-    }
-
-    unifi_trace(priv, UDBG5, "Packet priority = %d\n", priority);
-
-    return priority;
-}
-
-/*
- */
-/*
- * ---------------------------------------------------------------------------
- *  get_packet_priority
- *
- *  Arguments:
- *      priv             private data area of functional driver
- *      skb              socket buffer
- *      ehdr             ethernet header to fetch protocol
- *      interfacePriv    For accessing station record database
- *
- *
- *  Returns:
- *      CSR_PRIORITY.
- * ---------------------------------------------------------------------------
- */
-CSR_PRIORITY
-get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv)
-{
-    CSR_PRIORITY priority = CSR_CONTENTION;
-    const int proto = ntohs(ehdr->h_proto);
-
-    u8 interfaceMode = interfacePriv->interfaceMode;
-
-    /* Priority Mapping for all the Modes */
-    switch(interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-            unifi_trace(priv, UDBG4, "mode is STA \n");
-            if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1) {
-                priority = uf_get_packet_priority(priv, interfacePriv, skb, proto);
-            } else {
-                priority = CSR_CONTENTION;
-            }
-            break;
-#ifdef CSR_SUPPORT_SME
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            {
-                CsrWifiRouterCtrlStaInfo_t * dstStaInfo =
-                    CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfacePriv->InterfaceTag);
-                unifi_trace(priv, UDBG4, "mode is AP \n");
-                if (!(ehdr->h_dest[0] & 0x01) && dstStaInfo && dstStaInfo->wmmOrQosEnabled) {
-                    /* If packet is not Broadcast/multicast */
-                    priority = uf_get_packet_priority(priv, interfacePriv, skb, proto);
-                } else {
-                    /* Since packet destination is not QSTA, set priority to CSR_CONTENTION */
-                    unifi_trace(priv, UDBG4, "Destination is not QSTA or BroadCast/Multicast\n");
-                    priority = CSR_CONTENTION;
-                }
-            }
-            break;
-#endif
-        default:
-            unifi_trace(priv, UDBG3, " mode unknown in %s func, mode=%x\n", __FUNCTION__, interfaceMode);
-    }
-    unifi_trace(priv, UDBG5, "priority = %x\n", priority);
-
-    return priority;
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_net_select_queue
- *
- *      Called by the kernel to select which queue to put the packet in
- *
- *  Arguments:
- *      dev             Device pointer
- *      skb             Packet
- *
- *  Returns:
- *      Queue index
- * ---------------------------------------------------------------------------
- */
-static u16
-uf_net_select_queue(struct net_device *dev, struct sk_buff *skb)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = (unifi_priv_t *)interfacePriv->privPtr;
-    struct ethhdr ehdr;
-    unifi_TrafficQueue queue;
-    int proto;
-    CSR_PRIORITY priority;
-
-    memcpy(&ehdr, skb->data, ETH_HLEN);
-    proto = ntohs(ehdr.h_proto);
-
-    /* 802.1x - apply controlled/uncontrolled port rules */
-    if ((proto != ETH_P_PAE)
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-            && (proto != ETH_P_WAI)
-#endif
-       ) {
-        /* queues 0 - 3 */
-        priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
-        queue = unifi_frame_priority_to_queue(priority);
-    } else {
-        /* queue 4 */
-        queue = UNIFI_TRAFFIC_Q_EAPOL;
-    }
-
-
-    return (u16)queue;
-} /* uf_net_select_queue() */
-
-int
-skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto)
-{
-    llc_snap_hdr_t *snap;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int headroom;
-
-    /* get the headroom available in skb */
-    headroom = skb_headroom(skb);
-    /* step 1: classify ether frame, DIX or 802.3? */
-
-    if (proto < 0x600) {
-        /* codes <= 1500 reserved for 802.3 lengths */
-        /* it's 802.3, pass ether payload unchanged,  */
-        unifi_trace(priv, UDBG3, "802.3 len: %d\n", skb->len);
-
-        /*   leave off any PAD octets.  */
-        skb_trim(skb, proto);
-    } else if (proto == ETH_P_8021Q) {
-
-        /* Store the VLAN SNAP (should be 87-65). */
-        u16 vlan_snap = *(u16*)skb->data;
-        /* check for headroom availability before skb_push 14 = (4 + 10) */
-        if (headroom < 14) {
-            unifi_trace(priv, UDBG3, "cant append vlan snap: debug\n");
-            return -1;
-        }
-        /* Add AA-AA-03-00-00-00 */
-        snap = (llc_snap_hdr_t *)skb_push(skb, 4);
-        snap->dsap = snap->ssap = 0xAA;
-        snap->ctrl = 0x03;
-        memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
-
-        /* Add AA-AA-03-00-00-00 */
-        snap = (llc_snap_hdr_t *)skb_push(skb, 10);
-        snap->dsap = snap->ssap = 0xAA;
-        snap->ctrl = 0x03;
-        memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
-
-        /* Add the VLAN specific information */
-        snap->protocol = htons(proto);
-        *(u16*)(snap + 1) = vlan_snap;
-
-    } else
-    {
-        /* it's DIXII, time for some conversion */
-        unifi_trace(priv, UDBG3, "DIXII len: %d\n", skb->len);
-
-        /* check for headroom availability before skb_push */
-        if (headroom < sizeof(llc_snap_hdr_t)) {
-            unifi_trace(priv, UDBG3, "cant append snap: debug\n");
-            return -1;
-        }
-        /* tack on SNAP */
-        snap = (llc_snap_hdr_t *)skb_push(skb, sizeof(llc_snap_hdr_t));
-        snap->dsap = snap->ssap = 0xAA;
-        snap->ctrl = 0x03;
-        /* Use the appropriate OUI. */
-        if ((proto == ETH_P_AARP) || (proto == ETH_P_IPX)) {
-            memcpy(snap->oui, oui_8021h, P80211_OUI_LEN);
-        } else {
-            memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
-        }
-        snap->protocol = htons(proto);
-    }
-
-    return 0;
-} /* skb_add_llc_snap() */
-
-#ifdef CSR_SUPPORT_SME
-static int
-_identify_sme_ma_pkt_ind(unifi_priv_t *priv,
-                         const s8 *oui, u16 protocol,
-                         const CSR_SIGNAL *signal,
-                         bulk_data_param_t *bulkdata,
-                         const unsigned char *daddr,
-                         const unsigned char *saddr)
-{
-    CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication;
-    int r;
-    u8 i;
-
-    unifi_trace(priv, UDBG5,
-            "_identify_sme_ma_pkt_ind -->\n");
-    for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
-        if (priv->sme_unidata_ind_filters[i].in_use) {
-            if (!memcmp(oui, priv->sme_unidata_ind_filters[i].oui, 3) &&
-                    (protocol == priv->sme_unidata_ind_filters[i].protocol)) {
-
-                /* Send to client */
-                if (priv->sme_cli) {
-                    /*
-                     * Pass the packet to the SME, using unifi_sys_ma_unitdata_ind().
-                     * The frame needs to be converted according to the encapsulation.
-                     */
-                    unifi_trace(priv, UDBG1,
-                            "_identify_sme_ma_pkt_ind: handle=%d, encap=%d, proto=%x\n",
-                            i, priv->sme_unidata_ind_filters[i].encapsulation,
-                            priv->sme_unidata_ind_filters[i].protocol);
-                    if (priv->sme_unidata_ind_filters[i].encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) {
-                        struct sk_buff *skb;
-                        /* The translation is performed on skb... */
-                        skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
-                        skb->len = bulkdata->d[0].data_length;
-
-                        unifi_trace(priv, UDBG1,
-                                "_identify_sme_ma_pkt_ind: skb_80211_to_ether -->\n");
-                        r = skb_80211_to_ether(priv, skb, daddr, saddr,
-                                signal, bulkdata);
-                        unifi_trace(priv, UDBG1,
-                                "_identify_sme_ma_pkt_ind: skb_80211_to_ether <--\n");
-                        if (r) {
-                            return -EINVAL;
-                        }
-
-                        /* ... but we indicate buffer and length */
-                        bulkdata->d[0].os_data_ptr = skb->data;
-                        bulkdata->d[0].data_length = skb->len;
-                    } else {
-                        /* Add the MAC addresses before the SNAP */
-                        bulkdata->d[0].os_data_ptr -= 2*ETH_ALEN;
-                        bulkdata->d[0].data_length += 2*ETH_ALEN;
-                        memcpy((void*)bulkdata->d[0].os_data_ptr, daddr, ETH_ALEN);
-                        memcpy((void*)bulkdata->d[0].os_data_ptr + ETH_ALEN, saddr, ETH_ALEN);
-                    }
-
-                    unifi_trace(priv, UDBG1,
-                            "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind -->\n");
-                    CsrWifiRouterMaPacketIndSend(priv->sme_unidata_ind_filters[i].appHandle,
-                            (pkt_ind->VirtualInterfaceIdentifier & 0xff),
-                            i,
-                            pkt_ind->ReceptionStatus,
-                            bulkdata->d[0].data_length,
-                            (u8*)bulkdata->d[0].os_data_ptr,
-                            NULL,
-                            pkt_ind->Rssi,
-                            pkt_ind->Snr,
-                            pkt_ind->ReceivedRate);
-
-
-                    unifi_trace(priv, UDBG1,
-                            "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind <--\n");
-                }
-
-                return 1;
-            }
-        }
-    }
-
-    return -1;
-}
-#endif /* CSR_SUPPORT_SME */
-
-/*
- * ---------------------------------------------------------------------------
- *  skb_80211_to_ether
- *
- *      Make sure the received frame is in Ethernet (802.3) form.
- *      De-encapsulates SNAP if necessary, adds a ethernet header.
- *      The source buffer should not contain an 802.11 MAC header
- *
- *  Arguments:
- *      payload         Pointer to packet data received from UniFi.
- *      payload_length  Number of bytes of data received from UniFi.
- *      daddr           Destination MAC address.
- *      saddr           Source MAC address.
- *
- *  Returns:
- *      0 on success, -1 if the packet is bad and should be dropped,
- *      1 if the packet was forwarded to the SME or AMP client.
- * ---------------------------------------------------------------------------
- */
-int
-skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
-                   const unsigned char *daddr, const unsigned char *saddr,
-                   const CSR_SIGNAL *signal,
-                   bulk_data_param_t *bulkdata)
-{
-    unsigned char *payload;
-    int payload_length;
-    struct ethhdr *eth;
-    llc_snap_hdr_t *snap;
-    int headroom;
-#define UF_VLAN_LLC_HEADER_SIZE     18
-    static const u8 vlan_inner_snap[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
-#if defined(CSR_NATIVE_SOFTMAC) && defined(CSR_SUPPORT_SME)
-    const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
-#endif
-
-    if(skb== NULL || daddr == NULL || saddr == NULL){
-        unifi_error(priv, "skb_80211_to_ether: PBC fail\n");
-        return 1;
-    }
-
-    payload = skb->data;
-    payload_length = skb->len;
-
-    snap = (llc_snap_hdr_t *)payload;
-    eth  = (struct ethhdr *)payload;
-
-    /* get the skb headroom size */
-    headroom = skb_headroom(skb);
-
-    /*
-     * Test for the various encodings
-     */
-    if ((payload_length >= sizeof(llc_snap_hdr_t)) &&
-            (snap->dsap == 0xAA) &&
-            (snap->ssap == 0xAA) &&
-            (snap->ctrl == 0x03) &&
-            (snap->oui[0] == 0) &&
-            (snap->oui[1] == 0) &&
-            ((snap->oui[2] == 0) || (snap->oui[2] == 0xF8)))
-    {
-        /* AppleTalk AARP (2) or IPX SNAP */
-        if ((snap->oui[2] == 0) &&
-                ((ntohs(snap->protocol) == ETH_P_AARP) || (ntohs(snap->protocol) == ETH_P_IPX)))
-        {
-            u16 len;
-
-            unifi_trace(priv, UDBG3, "%s len: %d\n",
-                    (ntohs(snap->protocol) == ETH_P_AARP) ? "ETH_P_AARP" : "ETH_P_IPX",
-                    payload_length);
-
-            /* check for headroom availability before skb_push */
-            if (headroom < (2 * ETH_ALEN + 2)) {
-                unifi_warning(priv, "headroom not available to skb_push ether header\n");
-                return -1;
-            }
-
-            /* Add 802.3 header and leave full payload */
-            len = htons(skb->len);
-            memcpy(skb_push(skb, 2), &len, 2);
-            memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN);
-            memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN);
-
-            return 0;
-        }
-        /* VLAN-tagged IP */
-        if ((snap->oui[2] == 0) && (ntohs(snap->protocol) == ETH_P_8021Q))
-        {
-            /*
-             * The translation doesn't change the packet length, so is done in-place.
-             *
-             * Example header (from Std 802.11-2007 Annex M):
-             * AA-AA-03-00-00-00-81-00-87-65-AA-AA-03-00-00-00-08-06
-             * -------SNAP-------p1-p1-ll-ll-------SNAP--------p2-p2
-             * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-p1-p1-ll-ll-p2-p2
-             * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-81-00-87-65-08-06
-             */
-            u16 vlan_snap;
-
-            if (payload_length < UF_VLAN_LLC_HEADER_SIZE) {
-                unifi_warning(priv, "VLAN SNAP header too short: %d bytes\n", payload_length);
-                return -1;
-            }
-
-            if (memcmp(payload + 10, vlan_inner_snap, 6)) {
-                unifi_warning(priv, "VLAN malformatted SNAP header.\n");
-                return -1;
-            }
-
-            unifi_trace(priv, UDBG3, "VLAN SNAP: %02x-%02x\n", payload[8], payload[9]);
-            unifi_trace(priv, UDBG3, "VLAN len: %d\n", payload_length);
-
-            /* Create the 802.3 header */
-
-            vlan_snap = *((u16*)(payload + 8));
-
-            /* Create LLC header without byte-swapping */
-            eth->h_proto = snap->protocol;
-
-            memcpy(eth->h_dest, daddr, ETH_ALEN);
-            memcpy(eth->h_source, saddr, ETH_ALEN);
-            *(u16*)(eth + 1) = vlan_snap;
-            return 0;
-        }
-
-        /* it's a SNAP + RFC1042 frame */
-        unifi_trace(priv, UDBG3, "SNAP+RFC1042 len: %d\n", payload_length);
-
-        /* chop SNAP+llc header from skb. */
-        skb_pull(skb, sizeof(llc_snap_hdr_t));
-
-        /* Since skb_pull called above to chop snap+llc, no need to check for headroom
-         * availability before skb_push
-         */
-        /* create 802.3 header at beginning of skb. */
-        eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
-        memcpy(eth->h_dest, daddr, ETH_ALEN);
-        memcpy(eth->h_source, saddr, ETH_ALEN);
-        /* Copy protocol field without byte-swapping */
-        eth->h_proto = snap->protocol;
-    } else {
-        u16 len;
-
-        /* check for headroom availability before skb_push */
-        if (headroom < (2 * ETH_ALEN + 2)) {
-            unifi_warning(priv, "headroom not available to skb_push ether header\n");
-            return -1;
-        }
-        /* Add 802.3 header and leave full payload */
-        len = htons(skb->len);
-        memcpy(skb_push(skb, 2), &len, 2);
-        memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN);
-        memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN);
-
-        return 1;
-    }
-
-    return 0;
-} /* skb_80211_to_ether() */
-
-
-static CsrWifiRouterCtrlPortAction verify_port(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
-{
-#ifdef CSR_NATIVE_LINUX
-#ifdef CSR_SUPPORT_WEXT
-    if (queue == UF_CONTROLLED_PORT_Q) {
-        return priv->wext_conf.block_controlled_port;
-    } else {
-        return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
-    }
-#else
-    return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN; /* default to open for softmac dev */
-#endif
-#else
-    return uf_sme_port_state(priv, address, queue, interfaceTag);
-#endif
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  prepare_and_add_macheader
- *
- *
- *      These functions adds mac header for packet from netdev
- *      to UniFi for transmission.
- *      EAP protocol packets are also appended with Mac header &
- *      sent using send_ma_pkt_request().
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      skb             Socket buffer containing data packet to transmit
- *      newSkb          Socket buffer containing data packet + Mac header if no sufficient headroom in skb
- *      serviceClass    to append QOS control header in Mac header
- *      bulkdata        if newSkb allocated then bulkdata updated to send to unifi
- *      interfaceTag    the interfaceID on which activity going on
- *      daddr           destination address
- *      saddr           source address
- *      protection      protection bit set in framce control of mac header
- *
- *  Returns:
- *      Zero on success or error code.
- * ---------------------------------------------------------------------------
- */
-
-int prepare_and_add_macheader(unifi_priv_t *priv, struct sk_buff *skb, struct sk_buff *newSkb,
-                              CSR_PRIORITY priority,
-                              bulk_data_param_t *bulkdata,
-                              u16 interfaceTag,
-                              const u8 *daddr,
-                              const u8 *saddr,
-                              u8 protection)
-{
-    u16 fc = 0;
-    u8 qc = 0;
-    u8 macHeaderLengthInBytes = MAC_HEADER_SIZE, *bufPtr = NULL;
-    bulk_data_param_t data_ptrs;
-    CsrResult csrResult;
-    int headroom =0;
-    u8 direction = 0;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    u8 *addressOne;
-    u8 bQosNull = false;
-
-    if (skb == NULL) {
-        unifi_error(priv, "prepare_and_add_macheader: Invalid SKB reference\n");
-        return -1;
-    }
-
-    /* add a MAC header refer: 7.1.3.1 Frame Control field in P802.11REVmb.book */
-    if (priority != CSR_CONTENTION) {
-        /* EAPOL packets don't go as QOS_DATA */
-        if (priority == CSR_MANAGEMENT) {
-            fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
-        } else {
-            /* Qos Control Field */
-            macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
-
-            if (skb->len) {
-
-                fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
-            } else {
-                fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_NULL);
-                bQosNull = true;
-            }
-        }
-    } else {
-        if(skb->len == 0) {
-            fc |= cpu_to_le16(IEEE802_11_FC_TYPE_NULL);
-        } else {
-            fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
-        }
-    }
-
-    switch (interfacePriv->interfaceMode)
-    {
-        case  CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-            direction = 2;
-            fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK);
-            break;
-        case  CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            direction = 0;
-            break;
-        case  CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            direction = 1;
-            fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
-            if (priority == CSR_MANAGEMENT ) {
-
-                direction = 2;
-                fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK);
-            } else {
-                /* Data frames have to use WDS 4 address frames */
-                direction = 3;
-                fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK | IEEE802_11_FC_FROM_DS_MASK);
-                macHeaderLengthInBytes += 6;
-            }
-            break;
-        default:
-            unifi_warning(priv, "prepare_and_add_macheader: Unknown mode %d\n",
-                          interfacePriv->interfaceMode);
-    }
-
-
-    /* If Sta is QOS & HTC is supported then need to set 'order' bit */
-    /* We don't support HT Control for now */
-
-    if(protection) {
-        fc |= cpu_to_le16(IEEE802_11_FC_PROTECTED_MASK);
-    }
-
-    /* check the skb headroom before pushing mac header */
-    headroom = skb_headroom(skb);
-
-    if (headroom < macHeaderLengthInBytes) {
-        unifi_trace(priv, UDBG5,
-                    "prepare_and_add_macheader: Allocate headroom extra %d bytes\n",
-                    macHeaderLengthInBytes);
-
-        csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
-
-        if (csrResult != CSR_RESULT_SUCCESS) {
-            unifi_error(priv, " failed to allocate request_data. in %s func\n", __FUNCTION__);
-            return -1;
-        }
-        newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
-        newSkb->len = skb->len + macHeaderLengthInBytes;
-
-        memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
-                skb->data, skb->len);
-
-        bulkdata->d[0].os_data_ptr = newSkb->data;
-        bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
-        bulkdata->d[0].data_length = newSkb->len;
-
-        bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
-
-        /* The old skb will not be used again */
-            kfree_skb(skb);
-    } else {
-
-        /* headroom has sufficient size, so will get proper pointer */
-        bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
-        bulkdata->d[0].os_data_ptr = skb->data;
-        bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
-        bulkdata->d[0].data_length = skb->len;
-    }
-
-    /* Frame the actual MAC header */
-
-    memset(bufPtr, 0, macHeaderLengthInBytes);
-
-    /* copy frameControl field */
-    memcpy(bufPtr, &fc, sizeof(fc));
-    bufPtr += sizeof(fc);
-    macHeaderLengthInBytes -= sizeof(fc);
-
-    /* Duration/ID field which is 2 bytes */
-    bufPtr += 2;
-    macHeaderLengthInBytes -= 2;
-
-    switch(direction)
-    {
-        case 0:
-            /* Its an Ad-Hoc no need to route it through AP */
-            /* Address1: MAC address of the destination from eth header */
-            memcpy(bufPtr, daddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address2: MAC address of the source */
-            memcpy(bufPtr, saddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address3: the BSSID (locally generated in AdHoc (creators Bssid)) */
-            memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-            break;
-        case 1:
-           /* Address1: MAC address of the actual destination */
-            memcpy(bufPtr, daddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-            /* Address2: The MAC address of the AP */
-            memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address3: MAC address of the source from eth header */
-            memcpy(bufPtr, saddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-            break;
-        case  2:
-            /* Address1: To AP is the MAC address of the AP to which its associated */
-            memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address2: MAC address of the source from eth header */
-            memcpy(bufPtr, saddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address3: MAC address of the actual destination on the distribution system */
-            memcpy(bufPtr, daddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-            break;
-        case 3:
-            memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address2: MAC address of the source from eth header */
-            memcpy(bufPtr, saddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-
-            /* Address3: MAC address of the actual destination on the distribution system */
-            memcpy(bufPtr, daddr, ETH_ALEN);
-            bufPtr += ETH_ALEN;
-            macHeaderLengthInBytes -= ETH_ALEN;
-            break;
-        default:
-            unifi_error(priv, "Unknown direction =%d : Not handled now\n", direction);
-            return -1;
-    }
-    /* 2 bytes of frame control field, appended by firmware */
-    bufPtr += 2;
-    macHeaderLengthInBytes -= 2;
-
-    if (3 == direction) {
-        /* Address4: MAC address of the source */
-        memcpy(bufPtr, saddr, ETH_ALEN);
-        bufPtr += ETH_ALEN;
-        macHeaderLengthInBytes -= ETH_ALEN;
-    }
-
-    /* IF Qos Data or Qos Null Data then set QosControl field */
-    if ((priority != CSR_CONTENTION) && (macHeaderLengthInBytes >= QOS_CONTROL_HEADER_SIZE)) {
-
-        if (priority > 7) {
-            unifi_trace(priv, UDBG1, "data packets priority is more than 7, priority = %x\n", priority);
-            qc |= 7;
-        } else {
-            qc |= priority;
-        }
-        /*assigning address1
-        * Address1 offset taken fromm bufPtr(currently bufPtr pointing to Qos contorl) variable in reverse direction
-        * Address4 don't exit
-        */
-
-        addressOne = bufPtr- ADDRESS_ONE_OFFSET;
-
-        if (addressOne[0] & 0x1) {
-            /* multicast/broadcast frames, no acknowledgement needed */
-            qc |= 1 << 5;
-        }
-        /* non-AP mode only for now */
-        if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA ||
-           interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS ||
-           interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) {
-           /* In case of STA and IBSS case eosp and txop limit is 0. */
-        } else {
-            if(bQosNull) {
-                qc |= 1 << 4;
-            }
-        }
-
-        /* append Qos control field to mac header */
-        bufPtr[0] = qc;
-        /* txop limit is 0 */
-        bufPtr[1] = 0;
-        macHeaderLengthInBytes -= QOS_CONTROL_HEADER_SIZE;
-    }
-    if (macHeaderLengthInBytes) {
-        unifi_warning(priv, " Mac header not appended properly\n");
-        return -1;
-    }
-    return 0;
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  send_ma_pkt_request
- *
- *      These functions send a data packet to UniFi for transmission.
- *      EAP protocol packets are also sent as send_ma_pkt_request().
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      skb             Socket buffer containing data packet to transmit
- *      ehdr            Pointer to Ethernet header within skb.
- *
- *  Returns:
- *      Zero on success or error code.
- * ---------------------------------------------------------------------------
- */
-
-static int
-send_ma_pkt_request(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority)
-{
-    int r;
-    u16 i;
-    u8 eapolStore = FALSE;
-    struct sk_buff *newSkb = NULL;
-    bulk_data_param_t bulkdata;
-    const int proto = ntohs(ehdr->h_proto);
-    u16 interfaceTag;
-    CsrWifiMacAddress peerAddress;
-    CSR_TRANSMISSION_CONTROL transmissionControl = CSR_NO_CONFIRM_REQUIRED;
-    s8 protection;
-    netInterface_priv_t *interfacePriv = NULL;
-    CSR_RATE TransmitRate = (CSR_RATE)0;
-
-    unifi_trace(priv, UDBG5, "entering send_ma_pkt_request\n");
-
-    /* Get the interface Tag by means of source Mac address */
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        if (!memcmp(priv->netdev[i]->dev_addr, ehdr->h_source, ETH_ALEN)) {
-            interfaceTag = i;
-            interfacePriv = priv->interfacePriv[interfaceTag];
-            break;
-        }
-    }
-
-    if (interfacePriv == NULL) {
-        /* No match found - error */
-        interfaceTag = 0;
-        interfacePriv = priv->interfacePriv[interfaceTag];
-        unifi_warning(priv, "Mac address not matching ... debugging needed\n");
-        interfacePriv->stats.tx_dropped++;
-        kfree_skb(skb);
-        return -1;
-    }
-
-    /* Add a SNAP header if necessary */
-    if (skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto) != 0) {
-        /* convert failed */
-        unifi_error(priv, "skb_add_llc_snap failed.\n");
-        kfree_skb(skb);
-        return -1;
-    }
-
-    bulkdata.d[0].os_data_ptr = skb->data;
-    bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
-    bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].os_net_buf_ptr = NULL;
-    bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
-
-#ifdef CSR_SUPPORT_SME
-    /* Notify the TA module for the Tx frame  for non AP/P2PGO mode*/
-    if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) &&
-        (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) {
-        unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX,
-                        &bulkdata.d[0], ehdr->h_source,
-                        priv->netdev[interfaceTag]->dev_addr,
-                        jiffies_to_msecs(jiffies),
-                        0);     /* rate is unknown on tx */
-    }
-#endif /* CSR_SUPPORT_SME */
-
-    if ((proto == ETH_P_PAE)
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-            || (proto == ETH_P_WAI)
-#endif
-       )
-    {
-        /* check for m4 detection */
-        if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) {
-            eapolStore = TRUE;
-        }
-    }
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    if (proto == ETH_P_WAI)
-     {
-        protection = 0; /*WAI packets always sent unencrypted*/
-     }
-   else
-     {
-#endif
-#ifdef CSR_SUPPORT_SME
-    if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, ehdr->h_dest)) < 0) {
-        unifi_warning(priv, "unicast address, but destination not in station record database\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return -1;
-    }
-#else
-    protection = 0;
-#endif
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-   }
-#endif
-
-    /* append Mac header for Eapol as well as data packet */
-    if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, ehdr->h_dest, ehdr->h_source, protection)) {
-        unifi_error(priv, "failed to create MAC header\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return -1;
-    }
-
-    /* RA address must contain the immediate destination MAC address that is similar to
-     * the Address 1 field of 802.11 Mac header here 4 is: (sizeof(framecontrol) + sizeof (durationID))
-     * which is address 1 field
-     */
-    memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
-
-    unifi_trace(priv, UDBG5, "RA[0]=%x, RA[1]=%x, RA[2]=%x, RA[3]=%x, RA[4]=%x, RA[5]=%x\n",
-                peerAddress.a[0], peerAddress.a[1], peerAddress.a[2], peerAddress.a[3],
-                peerAddress.a[4], peerAddress.a[5]);
-
-
-    if ((proto == ETH_P_PAE)
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-            || (proto == ETH_P_WAI)
-#endif
-       )
-    {
-        CSR_SIGNAL signal;
-        CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
-
-        /* initialize signal to zero */
-        memset(&signal, 0, sizeof(CSR_SIGNAL));
-
-        /* Frame MA_PACKET request */
-        signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
-        signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
-        signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
-
-        transmissionControl = req->TransmissionControl = 0;
-#ifdef CSR_SUPPORT_SME
-        if (eapolStore)
-        {
-            netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]);
-
-            /* Fill the MA-PACKET.req */
-
-            req->Priority = priority;
-            unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority);
-
-            /* rate selected by firmware */
-            req->TransmitRate = 0;
-            req->HostTag = CSR_WIFI_EAPOL_M4_HOST_TAG;
-            /* RA address matching with address 1 of Mac header */
-            memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
-
-            spin_lock(&priv->m4_lock);
-            /* Store the M4-PACKET.req for later */
-            interfacePriv->m4_signal = signal;
-            interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
-            interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length;
-            interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
-            interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
-            spin_unlock(&priv->m4_lock);
-
-            /* Signal the workqueue to call CsrWifiRouterCtrlM4ReadyToSendIndSend().
-             * It cannot be called directly from the tx path because it
-             * does a non-atomic kmalloc via the framework's CsrPmemAlloc().
-             */
-            queue_work(priv->unifi_workqueue, &netpriv->send_m4_ready_task);
-
-            return 0;
-        }
-#endif
-    }/*EAPOL or WAI packet*/
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-    if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) && \
-        (priv->wapi_unicast_filter) && \
-        (proto != ETH_P_PAE) && \
-        (proto != ETH_P_WAI) && \
-        (skb->len > 0))
-    {
-        CSR_SIGNAL signal;
-        CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
-        netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]);
-
-        unifi_trace(priv, UDBG4, "send_ma_pkt_request() - WAPI unicast data packet when USKID = 1 \n");
-
-        /* initialize signal to zero */
-        memset(&signal, 0, sizeof(CSR_SIGNAL));
-        /* Frame MA_PACKET request */
-        signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
-        signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
-        signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
-
-        /* Fill the MA-PACKET.req */
-        req->TransmissionControl = 0;
-        req->Priority = priority;
-        unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority);
-        req->TransmitRate = (CSR_RATE) 0; /* rate selected by firmware */
-        req->HostTag = 0xffffffff;        /* Ask for a new HostTag */
-        /* RA address matching with address 1 of Mac header */
-        memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
-
-        /* Store the M4-PACKET.req for later */
-        spin_lock(&priv->wapi_lock);
-        interfacePriv->wapi_unicast_ma_pkt_sig = signal;
-        interfacePriv->wapi_unicast_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
-        interfacePriv->wapi_unicast_bulk_data.data_length = bulkdata.d[0].data_length;
-        interfacePriv->wapi_unicast_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
-        interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
-        spin_unlock(&priv->wapi_lock);
-
-        /* Signal the workqueue to call CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend().
-         * It cannot be called directly from the tx path because it
-         * does a non-atomic kmalloc via the framework's CsrPmemAlloc().
-         */
-        queue_work(priv->unifi_workqueue, &netpriv->send_pkt_to_encrypt);
-
-        return 0;
-    }
-#endif
-
-    if(priv->cmanrTestMode)
-    {
-        TransmitRate = priv->cmanrTestModeTransmitRate;
-        unifi_trace(priv, UDBG2, "send_ma_pkt_request: cmanrTestModeTransmitRate = %d TransmitRate=%d\n",
-                    priv->cmanrTestModeTransmitRate,
-                    TransmitRate
-                   );
-    }
-
-    /* Send UniFi msg */
-    /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
-    r = uf_process_ma_packet_req(priv,
-                                 peerAddress.a,
-                                 0xffffffff,  /* Ask for a new HostTag */
-                                 interfaceTag,
-                                 transmissionControl,
-                                 TransmitRate,
-                                 priority,
-                                 priv->netdev_client->sender_id,
-                                 &bulkdata);
-
-    if (r) {
-        unifi_trace(priv, UDBG1, "(HIP validation failure) r = %x\n", r);
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return -1;
-    }
-
-    unifi_trace(priv, UDBG3, "leaving send_ma_pkt_request, UNITDATA result code = %d\n", r);
-
-    return r;
-} /* send_ma_pkt_request() */
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_net_xmit
- *
- *      This function is called by the higher level stack to transmit an
- *      ethernet packet.
- *
- *  Arguments:
- *      skb     Ethernet packet to send.
- *      dev     Pointer to the linux net device.
- *
- *  Returns:
- *      0   on success (packet was consumed, not necessarily transmitted)
- *      1   if packet was requeued
- *     -1   on error
- *
- *
- *  Notes:
- *      The controlled port is handled in the qdisc dequeue handler.
- * ---------------------------------------------------------------------------
- */
-static netdev_tx_t
-uf_net_xmit(struct sk_buff *skb, struct net_device *dev)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct ethhdr ehdr;
-    int proto, port;
-    int result;
-    static tx_signal_handler tx_handler;
-    CSR_PRIORITY priority;
-    CsrWifiRouterCtrlPortAction port_action;
-
-    unifi_trace(priv, UDBG5, "unifi_net_xmit: skb = %x\n", skb);
-
-    memcpy(&ehdr, skb->data, ETH_HLEN);
-    proto = ntohs(ehdr.h_proto);
-    priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
-
-    /* All frames are sent as MA-PACKET.req (EAPOL also) */
-    tx_handler = send_ma_pkt_request;
-
-    /* 802.1x - apply controlled/uncontrolled port rules */
-    if ((proto != ETH_P_PAE)
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-            && (proto != ETH_P_WAI)
-#endif
-       ) {
-        port = UF_CONTROLLED_PORT_Q;
-    } else {
-        /* queue 4 */
-        port = UF_UNCONTROLLED_PORT_Q;
-    }
-
-    /* Uncontrolled port rules apply */
-    port_action = verify_port(priv
-        , (((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode)||(CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI== interfacePriv->interfaceMode))? interfacePriv->bssid.a: ehdr.h_dest)
-        , port
-        , interfacePriv->InterfaceTag);
-
-    if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
-        unifi_trace(priv, UDBG5,
-                    "uf_net_xmit: %s controlled port open\n",
-                    port ? "" : "un");
-        /* Remove the ethernet header */
-        skb_pull(skb, ETH_HLEN);
-        result = tx_handler(priv, skb, &ehdr, priority);
-    } else {
-
-        /* Discard the packet if necessary */
-        unifi_trace(priv, UDBG2,
-                "uf_net_xmit: %s controlled port %s\n",
-                port ? "" : "un", port_action==CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ? "blocked" : "closed");
-        interfacePriv->stats.tx_dropped++;
-        kfree_skb(skb);
-
-        return NETDEV_TX_OK;
-    }
-
-    if (result == NETDEV_TX_OK) {
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-       /* Don't update the tx stats when the pkt is to be sent for sw encryption*/
-       if (!((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) &&
-              (priv->wapi_unicast_filter == 1)))
-        {
-            dev->trans_start = jiffies;
-            /* Should really count tx stats in the UNITDATA.status signal but
-             * that doesn't have the length.
-             */
-            interfacePriv->stats.tx_packets++;
-            /* count only the packet payload */
-            interfacePriv->stats.tx_bytes += skb->len;
-
-        }
-#else
-       dev->trans_start = jiffies;
-
-        /*
-         * Should really count tx stats in the UNITDATA.status signal but
-         * that doesn't have the length.
-         */
-        interfacePriv->stats.tx_packets++;
-        /* count only the packet payload */
-        interfacePriv->stats.tx_bytes += skb->len;
-#endif
-    } else if (result < 0) {
-
-        /* Failed to send: fh queue was full, and the skb was discarded.
-         * Return OK to indicate that the buffer was consumed, to stop the
-         * kernel re-transmitting the freed buffer.
-         */
-        interfacePriv->stats.tx_dropped++;
-        unifi_trace(priv, UDBG1, "unifi_net_xmit: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped);
-        result = NETDEV_TX_OK;
-    }
-
-    /* The skb will have been freed by send_XXX_request() */
-
-    return result;
-} /* uf_net_xmit() */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_pause_xmit
- *  unifi_restart_xmit
- *
- *      These functions are called from the UniFi core to control the flow
- *      of packets from the upper layers.
- *      unifi_pause_xmit() is called when the internal queue is full and
- *      should take action to stop unifi_ma_unitdata() being called.
- *      When the queue has drained, unifi_restart_xmit() will be called to
- *      re-enable the flow of packets for transmission.
- *
- *  Arguments:
- *      ospriv          OS private context pointer.
- *
- *  Returns:
- *      unifi_pause_xmit() is called from interrupt context.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue)
-{
-    unifi_priv_t *priv = ospriv;
-    int i; /* used as a loop counter */
-
-    unifi_trace(priv, UDBG2, "Stopping queue %d\n", queue);
-
-    for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
-    {
-        if (netif_running(priv->netdev[i]))
-        {
-            netif_stop_subqueue(priv->netdev[i], (u16)queue);
-        }
-    }
-
-#ifdef CSR_SUPPORT_SME
-    if(queue<=3) {
-        routerStartBuffering(priv, queue);
-        unifi_trace(priv, UDBG2, "Start buffering %d\n", queue);
-     } else {
-        routerStartBuffering(priv, 0);
-        unifi_error(priv, "Start buffering %d defaulting to 0\n", queue);
-     }
-#endif
-
-} /* unifi_pause_xmit() */
-
-void
-unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue)
-{
-    unifi_priv_t *priv = ospriv;
-    int i=0; /* used as a loop counter */
-
-    unifi_trace(priv, UDBG2, "Waking queue %d\n", queue);
-
-    for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
-    {
-        if (netif_running(priv->netdev[i]))
-        {
-            netif_wake_subqueue(priv->netdev[i], (u16)queue);
-        }
-    }
-
-#ifdef CSR_SUPPORT_SME
-    if(queue <=3) {
-        routerStopBuffering(priv, queue);
-        uf_send_buffered_frames(priv, queue);
-    } else {
-        routerStopBuffering(priv, 0);
-        uf_send_buffered_frames(priv, 0);
-    }
-#endif
-} /* unifi_restart_xmit() */
-
-
-static void
-indicate_rx_skb(unifi_priv_t *priv, u16 ifTag, u8* dst_a, u8* src_a, struct sk_buff *skb, CSR_SIGNAL *signal,
-                bulk_data_param_t *bulkdata)
-{
-    int r, sr = 0;
-    struct net_device *dev;
-
-#ifdef CSR_SUPPORT_SME
-    llc_snap_hdr_t *snap;
-
-    snap = (llc_snap_hdr_t *)skb->data;
-
-    sr = _identify_sme_ma_pkt_ind(priv,
-                                  snap->oui, ntohs(snap->protocol),
-                                  signal,
-                                  bulkdata,
-                                  dst_a, src_a );
-#endif
-
-    /*
-     * Decapsulate any SNAP header and
-     * prepend an ethernet header so that the skb manipulation and ARP
-     * stuff works.
-     */
-    r = skb_80211_to_ether(priv, skb, dst_a, src_a,
-                           signal, bulkdata);
-    if (r == -1) {
-        /* Drop the packet and return */
-        priv->interfacePriv[ifTag]->stats.rx_errors++;
-        priv->interfacePriv[ifTag]->stats.rx_frame_errors++;
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        unifi_notice(priv, "indicate_rx_skb: Discard unknown frame.\n");
-        return;
-    }
-
-    /* Handle the case where packet is sent up through the subscription
-     * API but should not be given to the network stack (AMP PAL case)
-     * LLC header is different from WiFi and the packet has been subscribed for
-     */
-    if (r == 1 && sr == 1) {
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        unifi_trace(priv, UDBG5, "indicate_rx_skb: Data given to subscription"
-                "API, not being given to kernel\n");
-        return;
-    }
-
-    dev = priv->netdev[ifTag];
-    /* Now we look like a regular ethernet frame */
-    /* Fill in SKB meta data */
-    skb->dev = dev;
-    skb->protocol = eth_type_trans(skb, dev);
-    skb->ip_summed = CHECKSUM_UNNECESSARY;
-
-    /* Test for an overlength frame */
-    if (skb->len > (dev->mtu + ETH_HLEN)) {
-        /* A bogus length ethfrm has been encap'd. */
-        /* Is someone trying an oflow attack? */
-        unifi_error(priv, "%s: oversize frame (%d > %d)\n",
-                    dev->name,
-                    skb->len, dev->mtu + ETH_HLEN);
-
-        /* Drop the packet and return */
-        priv->interfacePriv[ifTag]->stats.rx_errors++;
-        priv->interfacePriv[ifTag]->stats.rx_length_errors++;
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-
-    if(priv->cmanrTestMode)
-    {
-        const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
-        priv->cmanrTestModeTransmitRate = pkt_ind->ReceivedRate;
-        unifi_trace(priv, UDBG2, "indicate_rx_skb: cmanrTestModeTransmitRate=%d\n", priv->cmanrTestModeTransmitRate);
-    }
-
-    /* Pass SKB up the stack */
-#ifdef CSR_WIFI_USE_NETIF_RX
-        netif_rx(skb);
-#else
-        netif_rx_ni(skb);
-#endif
-
-    if (dev != NULL) {
-        dev->last_rx = jiffies;
-    }
-
-    /* Bump rx stats */
-    priv->interfacePriv[ifTag]->stats.rx_packets++;
-    priv->interfacePriv[ifTag]->stats.rx_bytes += bulkdata->d[0].data_length;
-
-    return;
-}
-
-void
-uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
-                            CsrWifiMacAddress source_address,
-                            int indicate, u16 interfaceTag)
-{
-    rx_buffered_packets_t *rx_q_item;
-    struct list_head *rx_list;
-    struct list_head *n;
-    struct list_head *l_h;
-    static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_process_rx_pending_queue bad interfaceTag\n");
-        return;
-    }
-
-    if (queue == UF_CONTROLLED_PORT_Q) {
-        rx_list = &interfacePriv->rx_controlled_list;
-    } else {
-        rx_list = &interfacePriv->rx_uncontrolled_list;
-    }
-
-    down(&priv->rx_q_sem);
-    list_for_each_safe(l_h, n, rx_list) {
-        rx_q_item = list_entry(l_h, rx_buffered_packets_t, q);
-
-        /* Validate against the source address */
-        if (memcmp(broadcast_address.a, source_address.a, ETH_ALEN) &&
-                memcmp(rx_q_item->sa.a, source_address.a, ETH_ALEN)) {
-
-            unifi_trace(priv, UDBG2,
-                        "uf_process_rx_pending_queue: Skipping sa=%02X%02X%02X%02X%02X%02X skb=%p, bulkdata=%p\n",
-                        rx_q_item->sa.a[0], rx_q_item->sa.a[1],
-                        rx_q_item->sa.a[2], rx_q_item->sa.a[3],
-                        rx_q_item->sa.a[4], rx_q_item->sa.a[5],
-                        rx_q_item->skb, &rx_q_item->bulkdata.d[0]);
-            continue;
-        }
-
-        list_del(l_h);
-
-
-        unifi_trace(priv, UDBG2,
-                    "uf_process_rx_pending_queue: Was Blocked skb=%p, bulkdata=%p\n",
-                    rx_q_item->skb, &rx_q_item->bulkdata);
-
-        if (indicate) {
-            indicate_rx_skb(priv, interfaceTag, rx_q_item->da.a, rx_q_item->sa.a, rx_q_item->skb, &rx_q_item->signal, &rx_q_item->bulkdata);
-        } else {
-            interfacePriv->stats.rx_dropped++;
-            unifi_net_data_free(priv, &rx_q_item->bulkdata.d[0]);
-        }
-
-        /* It is our resposibility to free the Rx structure object. */
-        kfree(rx_q_item);
-    }
-    up(&priv->rx_q_sem);
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_resume_data_plane
- *
- *      Is called when the (un)controlled port is set to open,
- *      to notify the network stack to schedule for transmission
- *      any packets queued in the qdisk while port was closed and
- *      indicated to the stack any packets buffered in the Rx queues.
- *
- *  Arguments:
- *      priv        Pointer to device private struct
- *
- *  Returns:
- * ---------------------------------------------------------------------------
- */
-void
-uf_resume_data_plane(unifi_priv_t *priv, int queue,
-                     CsrWifiMacAddress peer_address,
-                     u16 interfaceTag)
-{
-#ifdef CSR_SUPPORT_WEXT
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-#endif
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_resume_data_plane bad interfaceTag\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG2, "Resuming netif\n");
-
-    /*
-     * If we are waiting for the net device to enter the up state, don't
-     * process the rx queue yet as it will be done by the callback when
-     * the device is ready.
-     */
-#ifdef CSR_SUPPORT_WEXT
-    if (!interfacePriv->wait_netdev_change)
-#endif
-    {
-#ifdef CONFIG_NET_SCHED
-        if (netif_running(priv->netdev[interfaceTag])) {
-            netif_tx_schedule_all(priv->netdev[interfaceTag]);
-        }
-#endif
-        uf_process_rx_pending_queue(priv, queue, peer_address, 1, interfaceTag);
-    }
-} /* uf_resume_data_plane() */
-
-
-void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue, CsrWifiMacAddress peer_address, u16 interfaceTag)
-{
-    uf_process_rx_pending_queue(priv, queue, peer_address, 0, interfaceTag);
-
-} /* uf_free_pending_rx_packets() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_rx
- *
- *      Reformat a UniFi data received packet into a p80211 packet and
- *      pass it up the protocol stack.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-unifi_rx(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
-{
-    u16 interfaceTag;
-    bulk_data_desc_t *pData;
-    const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
-    struct sk_buff *skb;
-    CsrWifiRouterCtrlPortAction port_action;
-    u8 dataFrameType;
-    int proto;
-    int queue;
-
-    u8 da[ETH_ALEN], sa[ETH_ALEN];
-    u8 toDs, fromDs, frameType, macHeaderLengthInBytes = MAC_HEADER_SIZE;
-    u16 frameControl;
-    netInterface_priv_t *interfacePriv;
-    struct ethhdr ehdr;
-
-    interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff);
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    /* Sanity check that the VIF refers to a sensible interface */
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-    /* Sanity check that the VIF refers to an allocated netdev */
-    if (!interfacePriv->netdev_registered)
-    {
-        unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-    if (bulkdata->d[0].data_length == 0) {
-        unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-
-    skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
-    skb->len = bulkdata->d[0].data_length;
-
-    /* Point to the addresses */
-    toDs = (skb->data[1] & 0x01) ? 1 : 0;
-    fromDs = (skb->data[1] & 0x02) ? 1 : 0;
-
-    memcpy(da, (skb->data+4+toDs*12), ETH_ALEN);/* Address1 or 3 */
-    memcpy(sa, (skb->data+10+fromDs*(6+toDs*8)), ETH_ALEN); /* Address2, 3 or 4 */
-
-
-    pData = &bulkdata->d[0];
-    frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr);
-    frameType = ((frameControl & 0x000C) >> 2);
-
-    dataFrameType =((frameControl & 0x00f0) >> 4);
-    unifi_trace(priv, UDBG6,
-                "%s: Receive Data Frame Type %d \n", __FUNCTION__, dataFrameType);
-
-    switch(dataFrameType)
-    {
-        case QOS_DATA:
-        case QOS_DATA_NULL:
-            /* If both are set then the Address4 exists (only for AP) */
-            if (fromDs && toDs)
-            {
-                /* 6 is the size of Address4 field */
-                macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
-            }
-            else
-            {
-                macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
-            }
-
-            /* If order bit set then HT control field is the part of MAC header */
-            if (frameControl & FRAME_CONTROL_ORDER_BIT)
-                macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
-            break;
-        default:
-            if (fromDs && toDs)
-                macHeaderLengthInBytes += 6;
-    }
-
-    /* Prepare the ethernet header from snap header of skb data */
-    switch(dataFrameType)
-    {
-        case DATA_NULL:
-        case QOS_DATA_NULL:
-            /* This is for only queue info fetching, EAPOL wont come as
-             * null data so the proto is initialized as zero
-             */
-            proto = 0x0;
-            break;
-        default:
-            {
-                llc_snap_hdr_t *snap;
-                /* Fetch a snap header to find protocol (for IPV4/IPV6 packets
-                 * the snap header fetching offset is same)
-                 */
-                snap = (llc_snap_hdr_t *) (skb->data + macHeaderLengthInBytes);
-
-                /* prepare the ethernet header from the snap header & addresses */
-                ehdr.h_proto = snap->protocol;
-                memcpy(ehdr.h_dest, da, ETH_ALEN);
-                memcpy(ehdr.h_source, sa, ETH_ALEN);
-            }
-            proto = ntohs(ehdr.h_proto);
-    }
-    unifi_trace(priv, UDBG3, "in unifi_rx protocol from snap header = 0x%x\n", proto);
-
-    if ((proto != ETH_P_PAE)
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-            && (proto != ETH_P_WAI)
-#endif
-       ) {
-        queue = UF_CONTROLLED_PORT_Q;
-    } else {
-        queue = UF_UNCONTROLLED_PORT_Q;
-    }
-
-    port_action = verify_port(priv, (unsigned char*)sa, queue, interfaceTag);
-    unifi_trace(priv, UDBG3, "in unifi_rx port action is = 0x%x & queue = %x\n", port_action, queue);
-
-#ifdef CSR_SUPPORT_SME
-    /* Notify the TA module for the Rx frame for non P2PGO and AP cases*/
-    if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) &&
-            (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))
-    {
-        /* Remove MAC header of length(macHeaderLengthInBytes) before sampling */
-        skb_pull(skb, macHeaderLengthInBytes);
-        pData->os_data_ptr = skb->data;
-        pData->data_length -= macHeaderLengthInBytes;
-
-        if (pData->data_length) {
-            unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX,
-                            &bulkdata->d[0],
-                            sa, priv->netdev[interfaceTag]->dev_addr,
-                            jiffies_to_msecs(jiffies),
-                            pkt_ind->ReceivedRate);
-        }
-    } else {
-
-        /* AP/P2PGO specific handling here */
-        CsrWifiRouterCtrlStaInfo_t * srcStaInfo =
-            CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
-
-        /* Defensive check only; Source address is already checked in
-        process_ma_packet_ind and we should have a valid source address here */
-
-         if(srcStaInfo == NULL) {
-            CsrWifiMacAddress peerMacAddress;
-            /* Unknown data PDU */
-            memcpy(peerMacAddress.a, sa, ETH_ALEN);
-            unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__,
-            sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
-            CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            return;
-        }
-
-       /* For AP GO mode, don't store the PDUs */
-        if (port_action != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
-            /* Drop the packet and return */
-            CsrWifiMacAddress peerMacAddress;
-            memcpy(peerMacAddress.a, sa, ETH_ALEN);
-            unifi_trace(priv, UDBG3, "%s: Port is not open: unexpected frame from peer = %x:%x:%x:%x:%x:%x\n",
-                        __FUNCTION__, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
-
-            CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
-            interfacePriv->stats.rx_dropped++;
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n", __FUNCTION__,
-                         proto, queue ? "Controlled" : "Un-controlled");
-            return;
-        }
-
-         /* Qos NULL/Data NULL  are freed here and not processed further */
-        if((dataFrameType == QOS_DATA_NULL) || (dataFrameType == DATA_NULL)){
-            unifi_trace(priv, UDBG5, "%s: Null Frame Received and Freed\n", __FUNCTION__);
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            return;
-        }
-
-        /* Now we have done with MAC header so proceed with the real data part*/
-        /* This function takes care of appropriate routing for AP/P2PGO case*/
-        /* the function hadnles following things
-           2. Routing the PDU to appropriate location
-           3. Error case handling
-           */
-        if(!(uf_ap_process_data_pdu(priv, skb, &ehdr, srcStaInfo,
-             signal,
-             bulkdata,
-             macHeaderLengthInBytes)))
-        {
-            return;
-        }
-        unifi_trace(priv, UDBG5, "unifi_rx: no specific AP handling process as normal frame, MAC Header len %d\n", macHeaderLengthInBytes);
-        /* Remove the MAC header for subsequent conversion */
-        skb_pull(skb, macHeaderLengthInBytes);
-        pData->os_data_ptr = skb->data;
-        pData->data_length -= macHeaderLengthInBytes;
-        pData->os_net_buf_ptr = (unsigned char*)skb;
-        pData->net_buf_length = skb->len;
-    }
-#endif /* CSR_SUPPORT_SME */
-
-
-    /* Now that the MAC header is removed, null-data frames have zero length
-     * and can be dropped
-     */
-    if (pData->data_length == 0) {
-        if (((frameControl & 0x00f0) >> 4) != QOS_DATA_NULL &&
-            ((frameControl & 0x00f0) >> 4) != DATA_NULL) {
-            unifi_trace(priv, UDBG1, "Zero length frame, but not null-data %04x\n", frameControl);
-        }
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-    if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
-        /* Drop the packet and return */
-        interfacePriv->stats.rx_dropped++;
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n",
-                     __FUNCTION__, proto, queue ? "controlled" : "uncontrolled");
-        return;
-    } else if ( (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK) ||
-                   (interfacePriv->connected != UnifiConnected) ) {
-
-        /* Buffer the packet into the Rx queues */
-        rx_buffered_packets_t *rx_q_item;
-        struct list_head *rx_list;
-
-        rx_q_item = kmalloc(sizeof(rx_buffered_packets_t),
-                GFP_KERNEL);
-        if (rx_q_item == NULL) {
-            unifi_error(priv, "%s: Failed to allocate %d bytes for rx packet record\n",
-                        __FUNCTION__, sizeof(rx_buffered_packets_t));
-            interfacePriv->stats.rx_dropped++;
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            return;
-        }
-
-        INIT_LIST_HEAD(&rx_q_item->q);
-        rx_q_item->bulkdata = *bulkdata;
-        rx_q_item->skb = skb;
-        rx_q_item->signal = *signal;
-        memcpy(rx_q_item->sa.a, sa, ETH_ALEN);
-        memcpy(rx_q_item->da.a, da, ETH_ALEN);
-        unifi_trace(priv, UDBG2, "%s: Blocked skb=%p, bulkdata=%p\n",
-                    __FUNCTION__, rx_q_item->skb, &rx_q_item->bulkdata);
-
-        if (queue == UF_CONTROLLED_PORT_Q) {
-            rx_list = &interfacePriv->rx_controlled_list;
-        } else {
-            rx_list = &interfacePriv->rx_uncontrolled_list;
-        }
-
-        /* Add to tail of packets queue */
-        down(&priv->rx_q_sem);
-        list_add_tail(&rx_q_item->q, rx_list);
-        up(&priv->rx_q_sem);
-
-        return;
-
-    }
-
-    indicate_rx_skb(priv, interfaceTag, da, sa, skb, signal, bulkdata);
-
-} /* unifi_rx() */
-
-static void process_ma_packet_cfm(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
-{
-    u16 interfaceTag;
-    const CSR_MA_PACKET_CONFIRM *pkt_cfm = &signal->u.MaPacketConfirm;
-    netInterface_priv_t *interfacePriv;
-
-    interfaceTag = (pkt_cfm->VirtualInterfaceIdentifier & 0xff);
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    /* Sanity check that the VIF refers to a sensible interface */
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "%s: MA-PACKET confirm with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
-        return;
-    }
-#ifdef CSR_SUPPORT_SME
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-
-        uf_process_ma_pkt_cfm_for_ap(priv, interfaceTag, pkt_cfm);
-    } else if (interfacePriv->m4_sent && (pkt_cfm->HostTag == interfacePriv->m4_hostTag)) {
-        /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
-        CsrResult result = pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE;
-        CsrWifiMacAddress peerMacAddress;
-        memcpy(peerMacAddress.a, interfacePriv->m4_signal.u.MaPacketRequest.Ra.x, ETH_ALEN);
-
-        unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
-        CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
-                                              interfaceTag,
-                                              peerMacAddress,
-                                              result);
-        interfacePriv->m4_sent = FALSE;
-        interfacePriv->m4_hostTag = 0xffffffff;
-    }
-#endif
-    return;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_rx
- *
- *      Reformat a UniFi data received packet into a p80211 packet and
- *      pass it up the protocol stack.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void process_ma_packet_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
-{
-    u16 interfaceTag;
-    bulk_data_desc_t *pData;
-    CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication;
-    struct sk_buff *skb;
-    u16 frameControl;
-    netInterface_priv_t *interfacePriv;
-    u8 da[ETH_ALEN], sa[ETH_ALEN];
-    u8 *bssid = NULL, *ba_addr = NULL;
-    u8 toDs, fromDs, frameType;
-    u8 i =0;
-
-#ifdef CSR_SUPPORT_SME
-    u8 dataFrameType = 0;
-    u8 powerSaveChanged = FALSE;
-    u8 pmBit = 0;
-    CsrWifiRouterCtrlStaInfo_t *srcStaInfo = NULL;
-    u16 qosControl;
-
-#endif
-
-    interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff);
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-
-    /* Sanity check that the VIF refers to a sensible interface */
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-    /* Sanity check that the VIF refers to an allocated netdev */
-    if (!interfacePriv->netdev_registered)
-    {
-        unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-    if (bulkdata->d[0].data_length == 0) {
-        unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-    /* For monitor mode we need to pass this indication to the registered application
-    handle this separately*/
-    /* MIC failure is already taken care of so no need to send the PDUs which are not successfully received in non-monitor mode*/
-    if(pkt_ind->ReceptionStatus != CSR_RX_SUCCESS)
-    {
-        unifi_warning(priv, "%s: MA-PACKET indication with status = %d\n", __FUNCTION__, pkt_ind->ReceptionStatus);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-
-    skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
-    skb->len = bulkdata->d[0].data_length;
-
-    /* Point to the addresses */
-    toDs = (skb->data[1] & 0x01) ? 1 : 0;
-    fromDs = (skb->data[1] & 0x02) ? 1 : 0;
-
-    memcpy(da, (skb->data+4+toDs*12), ETH_ALEN);/* Address1 or 3 */
-    memcpy(sa, (skb->data+10+fromDs*(6+toDs*8)), ETH_ALEN); /* Address2, 3 or 4 */
-
-    /* Find the BSSID, which will be used to match the BA session */
-    if (toDs && fromDs)
-    {
-        unifi_trace(priv, UDBG6, "4 address frame - don't try to find BSSID\n");
-        bssid = NULL;
-    }
-    else
-    {
-        bssid = (u8 *) (skb->data + 4 + 12 - (fromDs * 6) - (toDs * 12));
-    }
-
-    pData = &bulkdata->d[0];
-    frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr);
-    frameType = ((frameControl & 0x000C) >> 2);
-
-    unifi_trace(priv, UDBG3, "Rx Frame Type: %d sn: %d\n", frameType,
-         (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff);
-    if(frameType == IEEE802_11_FRAMETYPE_CONTROL){
-#ifdef CSR_SUPPORT_SME
-        unifi_trace(priv, UDBG6, "%s: Received Control Frame\n", __FUNCTION__);
-
-        if((frameControl & 0x00f0) == 0x00A0){
-            /* This is a PS-POLL request */
-            u8 pmBit = (frameControl & 0x1000)?0x01:0x00;
-            unifi_trace(priv, UDBG6, "%s: Received PS-POLL Frame\n", __FUNCTION__);
-
-            uf_process_ps_poll(priv, sa, da, pmBit, interfaceTag);
-        }
-        else {
-            unifi_warning(priv, "%s: Non PS-POLL control frame is received\n", __FUNCTION__);
-        }
-#endif
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-    if(frameType != IEEE802_11_FRAMETYPE_DATA) {
-        unifi_warning(priv, "%s: Non control Non Data frame is received\n", __FUNCTION__);
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return;
-    }
-
-#ifdef CSR_SUPPORT_SME
-    if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
-       (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)){
-
-        srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
-
-        if(srcStaInfo == NULL) {
-            CsrWifiMacAddress peerMacAddress;
-            /* Unknown data PDU */
-            memcpy(peerMacAddress.a, sa, ETH_ALEN);
-            unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__,
-            sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
-            CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            return;
-        }
-
-        /*
-        verify power management bit here so as to ensure host and unifi are always
-        in sync with power management status of peer.
-
-        If we do it later, it may so happen we have stored the frame in BA re-ordering
-        buffer and hence host and unifi are out of sync for power management status
-        */
-
-        pmBit = (frameControl & 0x1000)?0x01:0x00;
-        powerSaveChanged = uf_process_pm_bit_for_peer(priv, srcStaInfo, pmBit, interfaceTag);
-
-        /* Update station last activity time */
-        srcStaInfo->activity_flag = TRUE;
-
-        /* For Qos Frame if PM bit is toggled to indicate the change in power save state then it shall not be
-        considered as Trigger Frame. Enter only if WMM STA and peer is in Power save */
-
-        dataFrameType = ((frameControl & 0x00f0) >> 4);
-
-        if((powerSaveChanged == FALSE)&&(srcStaInfo->wmmOrQosEnabled == TRUE)&&
-        (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)){
-
-            if((dataFrameType == QOS_DATA) || (dataFrameType == QOS_DATA_NULL)){
-
-                /*
-                 * QoS control field is offset from frame control by 2 (frame control)
-                 * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
-                 */
-                if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){
-                    qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 30);
-                }
-                else{
-                    qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 24);
-                }
-                unifi_trace(priv, UDBG5, "%s: Check if U-APSD operations are triggered for qosControl: 0x%x\n", __FUNCTION__, qosControl);
-                uf_process_wmm_deliver_ac_uapsd(priv, srcStaInfo, qosControl, interfaceTag);
-            }
-        }
-    }
-
-#endif
-
-    if( ((frameControl & 0x00f0) >> 4) == QOS_DATA) {
-        u8 *qos_control_ptr = (u8*)bulkdata->d[0].os_data_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24);
-        int tID = *qos_control_ptr & IEEE802_11_QC_TID_MASK; /* using ls octet of qos control */
-        ba_session_rx_struct *ba_session;
-        u8 ba_session_idx = 0;
-        /* Get the BA originator address */
-        if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-           interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
-            ba_addr = sa;
-        }else{
-            ba_addr = bssid;
-        }
-
-        down(&priv->ba_mutex);
-        for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
-            ba_session = interfacePriv->ba_session_rx[ba_session_idx];
-            if (ba_session){
-                unifi_trace(priv, UDBG6, "found ba_session=0x%x ba_session_idx=%d", ba_session, ba_session_idx);
-                if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == tID)){
-                        frame_desc_struct frame_desc;
-                        frame_desc.bulkdata = *bulkdata;
-                        frame_desc.signal = *signal;
-                        frame_desc.sn = (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff;
-                        frame_desc.active = TRUE;
-                        unifi_trace(priv, UDBG6, "%s: calling process_ba_frame (session=%d)\n", __FUNCTION__, ba_session_idx);
-                        process_ba_frame(priv, interfacePriv, ba_session, &frame_desc);
-                        up(&priv->ba_mutex);
-                        process_ba_complete(priv, interfacePriv);
-                        break;
-                }
-            }
-        }
-        if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
-            up(&priv->ba_mutex);
-            unifi_trace(priv, UDBG6, "%s: calling process_amsdu()", __FUNCTION__);
-            process_amsdu(priv, signal, bulkdata);
-        }
-    } else {
-        unifi_trace(priv, UDBG6, "calling unifi_rx()");
-        unifi_rx(priv, signal, bulkdata);
-    }
-
-    /* check if the frames in reorder buffer has aged, the check
-     * is done after receive processing so that if the missing frame
-     * has arrived in this receive process, then it is handled cleanly.
-     *
-     * And also this code here takes care that timeout check is made for all
-     * the receive indications
-     */
-    down(&priv->ba_mutex);
-    for (i=0; i < MAX_SUPPORTED_BA_SESSIONS_RX; i++){
-        ba_session_rx_struct *ba_session;
-        ba_session = interfacePriv->ba_session_rx[i];
-            if (ba_session){
-                check_ba_frame_age_timeout(priv, interfacePriv, ba_session);
-            }
-    }
-    up(&priv->ba_mutex);
-    process_ba_complete(priv, interfacePriv);
-
-}
-/*
- * ---------------------------------------------------------------------------
- *  uf_set_multicast_list
- *
- *      This function is called by the higher level stack to set
- *      a list of multicast rx addresses.
- *
- *  Arguments:
- *      dev             Network Device pointer.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-
-static void
-uf_set_multicast_list(struct net_device *dev)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-#ifdef CSR_NATIVE_LINUX
-    unifi_trace(priv, UDBG3, "uf_set_multicast_list unsupported\n");
-    return;
-#else
-
-    u8 *mc_list = interfacePriv->mc_list;
-    struct netdev_hw_addr *mc_addr;
-    int mc_addr_count;
-
-    if (priv->init_progress != UNIFI_INIT_COMPLETED) {
-        return;
-    }
-
-    mc_addr_count = netdev_mc_count(dev);
-
-    unifi_trace(priv, UDBG3,
-            "uf_set_multicast_list (count=%d)\n", mc_addr_count);
-
-
-    /* Not enough space? */
-    if (mc_addr_count > UNIFI_MAX_MULTICAST_ADDRESSES) {
-        return;
-    }
-
-    /* Store the list to be processed by the work item. */
-    interfacePriv->mc_list_count = mc_addr_count;
-    netdev_hw_addr_list_for_each(mc_addr, &dev->mc) {
-        memcpy(mc_list, mc_addr->addr, ETH_ALEN);
-        mc_list += ETH_ALEN;
-    }
-
-    /* Send a message to the workqueue */
-    queue_work(priv->unifi_workqueue, &priv->multicast_list_task);
-#endif
-
-} /* uf_set_multicast_list() */
-
-/*
- * ---------------------------------------------------------------------------
- *  netdev_mlme_event_handler
- *
- *      Callback function to be used as the udi_event_callback when registering
- *      as a netdev client.
- *      To use it, a client specifies this function as the udi_event_callback
- *      to ul_register_client(). The signal dispatcher in
- *      unifi_receive_event() will call this function to deliver a signal.
- *
- *  Arguments:
- *      pcli            Pointer to the client instance.
- *      signal          Pointer to the received signal.
- *      signal_len      Size of the signal structure in bytes.
- *      bulkdata        Pointer to structure containing any associated bulk data.
- *      dir             Direction of the signal. Zero means from host,
- *                      non-zero means to host.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-netdev_mlme_event_handler(ul_client_t *pcli, const u8 *sig_packed, int sig_len,
-                          const bulk_data_param_t *bulkdata_o, int dir)
-{
-    CSR_SIGNAL signal;
-    unifi_priv_t *priv = uf_find_instance(pcli->instance);
-    int id, r;
-    bulk_data_param_t bulkdata;
-
-    /* Just a sanity check */
-    if (sig_packed == NULL) {
-        return;
-    }
-
-    /*
-     * This copy is to silence a compiler warning about discarding the
-     * const qualifier.
-     */
-    bulkdata = *bulkdata_o;
-
-    /* Get the unpacked signal */
-    r = read_unpack_signal(sig_packed, &signal);
-    if (r) {
-        /*
-         * The CSR_MLME_CONNECTED_INDICATION_ID has a receiverID=0 so will
-         * fall through this case. It is safe to ignore this signal.
-         */
-        unifi_trace(priv, UDBG1,
-                    "Netdev - Received unknown signal 0x%.4X.\n",
-                    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
-        return;
-    }
-
-    id = signal.SignalPrimitiveHeader.SignalId;
-    unifi_trace(priv, UDBG3, "Netdev - Process signal 0x%.4X\n", id);
-
-    /*
-     * Take the appropriate action for the signal.
-     */
-    switch (id) {
-        case CSR_MA_PACKET_ERROR_INDICATION_ID:
-            process_ma_packet_error_ind(priv, &signal, &bulkdata);
-            break;
-        case CSR_MA_PACKET_INDICATION_ID:
-            process_ma_packet_ind(priv, &signal, &bulkdata);
-            break;
-        case  CSR_MA_PACKET_CONFIRM_ID:
-            process_ma_packet_cfm(priv, &signal, &bulkdata);
-            break;
-#ifdef CSR_SUPPORT_SME
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-            /* Handle TIM confirms from FW & set the station record's TIM state appropriately,
-             * In case of failures, tries with max_retransmit limit
-             */
-            uf_handle_tim_cfm(priv, &signal.u.MlmeSetTimConfirm, signal.SignalPrimitiveHeader.ReceiverProcessId);
-            break;
-#endif
-        case CSR_DEBUG_STRING_INDICATION_ID:
-            debug_string_indication(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length);
-            break;
-
-        case CSR_DEBUG_WORD16_INDICATION_ID:
-            debug_word16_indication(priv, &signal);
-            break;
-
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-        case CSR_DEBUG_GENERIC_INDICATION_ID:
-            debug_generic_indication(priv, &signal);
-            break;
-        default:
-            break;
-    }
-
-} /* netdev_mlme_event_handler() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_net_get_name
- *
- *      Retrieve the name (e.g. eth1) associated with this network device
- *
- *  Arguments:
- *      dev             Pointer to the network device.
- *      name            Buffer to write name
- *      len             Size of buffer in bytes
- *
- *  Returns:
- *      None
- *
- *  Notes:
- * ---------------------------------------------------------------------------
- */
-void uf_net_get_name(struct net_device *dev, char *name, int len)
-{
-    *name = '\0';
-    if (dev) {
-        strlcpy(name, dev->name, (len > IFNAMSIZ) ? IFNAMSIZ : len);
-    }
-
-} /* uf_net_get_name */
-
-#ifdef CSR_SUPPORT_WEXT
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_netdev_event
- *
- *     Callback function to handle netdev state changes
- *
- *  Arguments:
- *      notif           Pointer to a notifier_block.
- *      event           Event prompting notification
- *      ptr             net_device pointer
- *
- *  Returns:
- *      None
- *
- *  Notes:
- *   The event handler is global, and may occur on non-UniFi netdevs.
- * ---------------------------------------------------------------------------
- */
-static int
-uf_netdev_event(struct notifier_block *notif, unsigned long event, void* ptr) {
-    struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(netdev);
-    unifi_priv_t *priv = NULL;
-    static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
-
-    /* Check that the event is for a UniFi netdev. If it's not, the netdev_priv
-     * structure is not safe to use.
-     */
-    if (uf_find_netdev_priv(interfacePriv) == -1) {
-        unifi_trace(NULL, UDBG1, "uf_netdev_event: ignore e=%d, ptr=%p, priv=%p %s\n",
-                    event, ptr, interfacePriv, netdev->name);
-        return 0;
-    }
-
-    switch(event) {
-    case NETDEV_CHANGE:
-        priv = interfacePriv->privPtr;
-        unifi_trace(priv, UDBG1, "NETDEV_CHANGE: %p %s %s waiting for it\n",
-                    ptr,
-                    netdev->name,
-                    interfacePriv->wait_netdev_change ? "" : "not");
-
-        if (interfacePriv->wait_netdev_change) {
-            netif_tx_wake_all_queues(priv->netdev[interfacePriv->InterfaceTag]);
-            interfacePriv->connected = UnifiConnected;
-            interfacePriv->wait_netdev_change = FALSE;
-            /* Note: passing the broadcast address here will allow anyone to attempt to join our adhoc network */
-            uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
-            uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
-        }
-        break;
-
-    default:
-        break;
-    }
-    return 0;
-}
-
-static struct notifier_block uf_netdev_notifier = {
-    .notifier_call = uf_netdev_event,
-};
-#endif /* CSR_SUPPORT_WEXT */
-
-
-static void
-        process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
-{
-    u32 offset;
-    u32 length = bulkdata->d[0].data_length;
-    u32 subframe_length, subframe_body_length, dot11_hdr_size;
-    u8 *ptr;
-    bulk_data_param_t subframe_bulkdata;
-    u8 *dot11_hdr_ptr = (u8*)bulkdata->d[0].os_data_ptr;
-    CsrResult csrResult;
-    u16 frameControl;
-    u8 *qos_control_ptr;
-
-    frameControl = le16_to_cpu(*((u16*)dot11_hdr_ptr));
-    qos_control_ptr = dot11_hdr_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24);
-    if(!(*qos_control_ptr & IEEE802_11_QC_A_MSDU_PRESENT)) {
-        unifi_trace(priv, UDBG6, "%s: calling unifi_rx()", __FUNCTION__);
-        unifi_rx(priv, signal, bulkdata);
-        return;
-    }
-    *qos_control_ptr &= ~(IEEE802_11_QC_A_MSDU_PRESENT);
-
-    ptr = qos_control_ptr + 2;
-    offset = dot11_hdr_size = ptr - dot11_hdr_ptr;
-
-    while(length > (offset + sizeof(struct ethhdr) + sizeof(llc_snap_hdr_t))) {
-        subframe_body_length = ntohs(((struct ethhdr*)ptr)->h_proto);
-        if(subframe_body_length > IEEE802_11_MAX_DATA_LEN) {
-            unifi_error(priv, "%s: bad subframe_body_length = %d\n", __FUNCTION__, subframe_body_length);
-            break;
-        }
-        subframe_length = sizeof(struct ethhdr) + subframe_body_length;
-        memset(&subframe_bulkdata, 0, sizeof(bulk_data_param_t));
-
-        csrResult = unifi_net_data_malloc(priv, &subframe_bulkdata.d[0], dot11_hdr_size + subframe_body_length);
-
-        if (csrResult != CSR_RESULT_SUCCESS) {
-            unifi_error(priv, "%s: unifi_net_data_malloc failed\n", __FUNCTION__);
-            break;
-        }
-
-        memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr, dot11_hdr_ptr, dot11_hdr_size);
-
-
-        /* When to DS=0 and from DS=0, address 3 will already have BSSID so no need to re-program */
-        if ((frameControl & IEEE802_11_FC_TO_DS_MASK) && !(frameControl & IEEE802_11_FC_FROM_DS_MASK)){
-                memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET, ((struct ethhdr*)ptr)->h_dest, ETH_ALEN);
-        }
-        else if (!(frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){
-                memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET,
-                         ((struct ethhdr*)ptr)->h_source,
-                           ETH_ALEN);
-        }
-
-        memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + dot11_hdr_size,
-                ptr + sizeof(struct ethhdr),
-                             subframe_body_length);
-        unifi_trace(priv, UDBG6, "%s: calling unifi_rx. length = %d subframe_length = %d\n", __FUNCTION__, length, subframe_length);
-        unifi_rx(priv, signal, &subframe_bulkdata);
-
-        subframe_length = (subframe_length + 3)&(~0x3);
-        ptr += subframe_length;
-        offset += subframe_length;
-    }
-    unifi_net_data_free(priv, &bulkdata->d[0]);
-}
-
-
-#define SN_TO_INDEX(__ba_session, __sn) (((__sn - __ba_session->start_sn) & 0xFFF) % __ba_session->wind_size)
-
-
-#define ADVANCE_EXPECTED_SN(__ba_session) \
-{ \
-    __ba_session->expected_sn++; \
-    __ba_session->expected_sn &= 0xFFF; \
-}
-
-#define FREE_BUFFER_SLOT(__ba_session, __index) \
-{ \
-    __ba_session->occupied_slots--; \
-    __ba_session->buffer[__index].active = FALSE; \
-    ADVANCE_EXPECTED_SN(__ba_session); \
-}
-
-static void add_frame_to_ba_complete(unifi_priv_t *priv,
-                          netInterface_priv_t *interfacePriv,
-                          frame_desc_struct *frame_desc)
-{
-    interfacePriv->ba_complete[interfacePriv->ba_complete_index] = *frame_desc;
-    interfacePriv->ba_complete_index++;
-}
-
-
-static void update_expected_sn(unifi_priv_t *priv,
-                          netInterface_priv_t *interfacePriv,
-                          ba_session_rx_struct *ba_session,
-                          u16 sn)
-{
-    int i, j;
-    u16 gap;
-
-    gap = (sn - ba_session->expected_sn) & 0xFFF;
-    unifi_trace(priv, UDBG6, "%s: process the frames up to new_expected_sn = %d gap = %d\n", __FUNCTION__, sn, gap);
-    for(j = 0; j < gap && j < ba_session->wind_size; j++) {
-        i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
-        unifi_trace(priv, UDBG6, "%s: process the slot index = %d\n", __FUNCTION__, i);
-        if(ba_session->buffer[i].active) {
-            add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
-            unifi_trace(priv, UDBG6, "%s: process the frame at index = %d expected_sn = %d\n", __FUNCTION__, i, ba_session->expected_sn);
-            FREE_BUFFER_SLOT(ba_session, i);
-        } else {
-            unifi_trace(priv, UDBG6, "%s: empty slot at index = %d\n", __FUNCTION__, i);
-            ADVANCE_EXPECTED_SN(ba_session);
-        }
-    }
-    ba_session->expected_sn = sn;
-}
-
-
-static void complete_ready_sequence(unifi_priv_t *priv,
-                               netInterface_priv_t *interfacePriv,
-                               ba_session_rx_struct *ba_session)
-{
-    int i;
-
-    i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
-    while (ba_session->buffer[i].active) {
-        add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
-        unifi_trace(priv, UDBG6, "%s: completed stored frame(expected_sn=%d) at i = %d\n", __FUNCTION__, ba_session->expected_sn, i);
-        FREE_BUFFER_SLOT(ba_session, i);
-        i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
-    }
-}
-
-
-void scroll_ba_window(unifi_priv_t *priv,
-                                netInterface_priv_t *interfacePriv,
-                                ba_session_rx_struct *ba_session,
-                                u16 sn)
-{
-    if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) {
-        update_expected_sn(priv, interfacePriv, ba_session, sn);
-        complete_ready_sequence(priv, interfacePriv, ba_session);
-    }
-}
-
-
-static int consume_frame_or_get_buffer_index(unifi_priv_t *priv,
-                                            netInterface_priv_t *interfacePriv,
-                                            ba_session_rx_struct *ba_session,
-                                            u16 sn,
-                                            frame_desc_struct *frame_desc) {
-    int i;
-    u16 sn_temp;
-
-    if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) {
-
-        /* once we are in BA window, set the flag for BA trigger */
-        if(!ba_session->trigger_ba_after_ssn){
-            ba_session->trigger_ba_after_ssn = TRUE;
-        }
-
-        sn_temp = ba_session->expected_sn + ba_session->wind_size;
-        unifi_trace(priv, UDBG6, "%s: new frame: sn=%d\n", __FUNCTION__, sn);
-        if(!(((sn - sn_temp) & 0xFFF) > 2048)) {
-            u16 new_expected_sn;
-            unifi_trace(priv, UDBG6, "%s: frame is out of window\n", __FUNCTION__);
-            sn_temp = (sn - ba_session->wind_size) & 0xFFF;
-            new_expected_sn = (sn_temp + 1) & 0xFFF;
-            update_expected_sn(priv, interfacePriv, ba_session, new_expected_sn);
-        }
-        i = -1;
-        if (sn == ba_session->expected_sn) {
-            unifi_trace(priv, UDBG6, "%s: sn = ba_session->expected_sn = %d\n", __FUNCTION__, sn);
-            ADVANCE_EXPECTED_SN(ba_session);
-            add_frame_to_ba_complete(priv, interfacePriv, frame_desc);
-        } else {
-            i = SN_TO_INDEX(ba_session, sn);
-            unifi_trace(priv, UDBG6, "%s: sn(%d) != ba_session->expected_sn(%d), i = %d\n", __FUNCTION__, sn, ba_session->expected_sn, i);
-            if (ba_session->buffer[i].active) {
-                unifi_trace(priv, UDBG6, "%s: free frame at i = %d\n", __FUNCTION__, i);
-                i = -1;
-                unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
-            }
-        }
-    } else {
-        i = -1;
-        if(!ba_session->trigger_ba_after_ssn){
-            unifi_trace(priv, UDBG6, "%s: frame before ssn, pass it up: sn=%d\n", __FUNCTION__, sn);
-            add_frame_to_ba_complete(priv, interfacePriv, frame_desc);
-        }else{
-            unifi_trace(priv, UDBG6, "%s: old frame, drop: sn=%d, expected_sn=%d\n", __FUNCTION__, sn, ba_session->expected_sn);
-            unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
-        }
-    }
-    return i;
-}
-
-
-
-static void process_ba_frame(unifi_priv_t *priv,
-                                             netInterface_priv_t *interfacePriv,
-                                             ba_session_rx_struct *ba_session,
-                                             frame_desc_struct *frame_desc)
-{
-    int i;
-    u16 sn = frame_desc->sn;
-
-    if (ba_session->timeout) {
-        mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024)));
-    }
-    unifi_trace(priv, UDBG6, "%s: got frame(sn=%d)\n", __FUNCTION__, sn);
-
-    i = consume_frame_or_get_buffer_index(priv, interfacePriv, ba_session, sn, frame_desc);
-    if(i >= 0) {
-        unifi_trace(priv, UDBG6, "%s: store frame(sn=%d) at i = %d\n", __FUNCTION__, sn, i);
-        ba_session->buffer[i] = *frame_desc;
-        ba_session->buffer[i].recv_time = CsrTimeGet(NULL);
-        ba_session->occupied_slots++;
-    } else {
-        unifi_trace(priv, UDBG6, "%s: frame consumed - sn = %d\n", __FUNCTION__, sn);
-    }
-    complete_ready_sequence(priv, interfacePriv, ba_session);
-}
-
-
-static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv)
-{
-    frame_desc_struct *frame_desc;
-    u8 i;
-
-    for(i = 0; i < interfacePriv->ba_complete_index; i++) {
-        frame_desc = &interfacePriv->ba_complete[i];
-        unifi_trace(priv, UDBG6, "%s: calling process_amsdu()\n", __FUNCTION__);
-        process_amsdu(priv, &frame_desc->signal, &frame_desc->bulkdata);
-    }
-    interfacePriv->ba_complete_index = 0;
-
-}
-
-
-/* Check if the frames in BA reoder buffer has aged and
- * if so release the frames to upper processes and move
- * the window
- */
-static void check_ba_frame_age_timeout( unifi_priv_t *priv,
-                                        netInterface_priv_t *interfacePriv,
-                                        ba_session_rx_struct *ba_session)
-{
-    u32 now;
-    u32 age;
-    u8 i, j;
-    u16 sn_temp;
-
-    /* gap is started at 1 because we have buffered frames and
-     * hence a minimum gap of 1 exists
-     */
-    u8 gap=1;
-
-    now = CsrTimeGet(NULL);
-
-    if (ba_session->occupied_slots)
-    {
-        /* expected sequence has not arrived so start searching from next
-         * sequence number until a frame is available and determine the gap.
-         * Check if the frame available has timedout, if so advance the
-         * expected sequence number and release the frames
-         */
-        sn_temp = (ba_session->expected_sn + 1) & 0xFFF;
-
-        for(j = 0; j < ba_session->wind_size; j++)
-        {
-            i = SN_TO_INDEX(ba_session, sn_temp);
-
-            if(ba_session->buffer[i].active)
-            {
-                unifi_trace(priv, UDBG6, "check age at slot index = %d sn = %d recv_time = %u now = %u\n",
-                                        i,
-                                        ba_session->buffer[i].sn,
-                                        ba_session->buffer[i].recv_time,
-                                        now);
-
-                if (ba_session->buffer[i].recv_time > now)
-                {
-                    /* timer wrap */
-                    age = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, ba_session->buffer[i].recv_time), now);
-                }
-                else
-                {
-                    age = (u32)CsrTimeSub(now, ba_session->buffer[i].recv_time);
-                }
-
-                if (age >= CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT)
-                {
-                    unifi_trace(priv, UDBG2, "release the frame at index = %d gap = %d expected_sn = %d sn = %d\n",
-                                            i,
-                                            gap,
-                                            ba_session->expected_sn,
-                                            ba_session->buffer[i].sn);
-
-                    /* if it has timedout don't wait for missing frames, move the window */
-                    while (gap--)
-                    {
-                        ADVANCE_EXPECTED_SN(ba_session);
-                    }
-                    add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
-                    FREE_BUFFER_SLOT(ba_session, i);
-                    complete_ready_sequence(priv, interfacePriv, ba_session);
-                }
-                break;
-
-            }
-            else
-            {
-                /* advance temp sequence number and frame gap */
-                sn_temp = (sn_temp + 1) & 0xFFF;
-                gap++;
-            }
-        }
-    }
-}
-
-
-static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
-{
-    u16 interfaceTag;
-    const CSR_MA_PACKET_ERROR_INDICATION *pkt_err_ind = &signal->u.MaPacketErrorIndication;
-    netInterface_priv_t *interfacePriv;
-    ba_session_rx_struct *ba_session;
-    u8 ba_session_idx = 0;
-    CSR_PRIORITY        UserPriority;
-    CSR_SEQUENCE_NUMBER sn;
-
-    interfaceTag = (pkt_err_ind->VirtualInterfaceIdentifier & 0xff);
-
-
-    /* Sanity check that the VIF refers to a sensible interface */
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "%s: MaPacketErrorIndication indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-    UserPriority = pkt_err_ind->UserPriority;
-    if(UserPriority > 15) {
-        unifi_error(priv, "%s: MaPacketErrorIndication indication with bad UserPriority=%d\n", __FUNCTION__, UserPriority);
-    }
-    sn = pkt_err_ind->SequenceNumber;
-
-    down(&priv->ba_mutex);
-    /* To find the right ba_session loop through the BA sessions, compare MAC address and tID */
-    for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
-        ba_session = interfacePriv->ba_session_rx[ba_session_idx];
-        if (ba_session){
-            if ((!memcmp(ba_session->macAddress.a, pkt_err_ind->PeerQstaAddress.x, ETH_ALEN)) && (ba_session->tID == UserPriority)){
-                if (ba_session->timeout) {
-                    mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024)));
-                }
-                scroll_ba_window(priv, interfacePriv, ba_session, sn);
-                break;
-            }
-        }
-    }
-
-    up(&priv->ba_mutex);
-    process_ba_complete(priv, interfacePriv);
-}
-
-
diff --git a/drivers/staging/csr/os.c b/drivers/staging/csr/os.c
deleted file mode 100644 (file)
index 37ec59d..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *  FILE:     os.c
- *
- *  PURPOSE:
- *      Routines to fulfil the OS-abstraction for the HIP lib.
- *      It is part of the porting exercise.
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-/**
- * The HIP lib OS abstraction consists of the implementation
- * of the functions in this file. It is part of the porting exercise.
- */
-
-#include "unifi_priv.h"
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_net_data_malloc
- *
- *      Allocate an OS specific net data buffer of "size" bytes.
- *      The bulk_data_slot.os_data_ptr must be initialised to point
- *      to the buffer allocated. The bulk_data_slot.length must be
- *      initialised to the requested size, zero otherwise.
- *      The bulk_data_slot.os_net_buf_ptr can be initialised to
- *      an OS specific pointer to be used in the unifi_net_data_free().
- *
- *
- *  Arguments:
- *      ospriv              Pointer to device private context struct.
- *      bulk_data_slot      Pointer to the bulk data structure to initialise.
- *      size                Size of the buffer to be allocated.
- *
- *  Returns:
- *      CSR_RESULT_SUCCESS on success, CSR_RESULT_FAILURE otherwise.
- * ---------------------------------------------------------------------------
- */
-CsrResult
-unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size)
-{
-    struct sk_buff *skb;
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    int rounded_length;
-
-    if (priv->card_info.sdio_block_size == 0) {
-        unifi_error(priv, "unifi_net_data_malloc: Invalid SDIO block size\n");
-        return CSR_RESULT_FAILURE;
-    }
-
-    rounded_length = (size + priv->card_info.sdio_block_size - 1) & ~(priv->card_info.sdio_block_size - 1);
-
-    /*
-     * (ETH_HLEN + 2) bytes tailroom for header manipulation
-     * CSR_WIFI_ALIGN_BYTES bytes headroom for alignment manipulation
-     */
-    skb = dev_alloc_skb(rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES);
-    if (! skb) {
-        unifi_error(ospriv, "alloc_skb failed.\n");
-        bulk_data_slot->os_net_buf_ptr = NULL;
-        bulk_data_slot->net_buf_length = 0;
-        bulk_data_slot->os_data_ptr = NULL;
-        bulk_data_slot->data_length = 0;
-        return CSR_RESULT_FAILURE;
-    }
-
-    bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb;
-    bulk_data_slot->net_buf_length = rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES;
-    bulk_data_slot->os_data_ptr = (const void*)skb->data;
-    bulk_data_slot->data_length = size;
-
-    return CSR_RESULT_SUCCESS;
-} /* unifi_net_data_malloc() */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_net_data_free
- *
- *      Free an OS specific net data buffer.
- *      The bulk_data_slot.length must be initialised to 0.
- *
- *
- *  Arguments:
- *      ospriv              Pointer to device private context struct.
- *      bulk_data_slot      Pointer to the bulk data structure that
- *                          holds the data to be freed.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot)
-{
-    struct sk_buff *skb;
-    CSR_UNUSED(ospriv);
-
-    skb = (struct sk_buff *)bulk_data_slot->os_net_buf_ptr;
-    dev_kfree_skb(skb);
-
-    bulk_data_slot->net_buf_length = 0;
-    bulk_data_slot->data_length = 0;
-    bulk_data_slot->os_data_ptr = bulk_data_slot->os_net_buf_ptr = NULL;
-
-} /* unifi_net_data_free() */
-
-
-/*
-* ---------------------------------------------------------------------------
-*  unifi_net_dma_align
-*
-*      DMA align an OS specific net data buffer.
-*      The buffer must be empty.
-*
-*
-*  Arguments:
-*      ospriv              Pointer to device private context struct.
-*      bulk_data_slot      Pointer to the bulk data structure that
-*                          holds the data to be aligned.
-*
-*  Returns:
-*      None.
-* ---------------------------------------------------------------------------
-*/
-CsrResult
-unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot)
-{
-    struct sk_buff *skb;
-    unsigned long buf_address;
-    int offset;
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-
-    if ((bulk_data_slot == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) {
-        return CSR_RESULT_SUCCESS;
-    }
-
-    if ((bulk_data_slot->os_data_ptr == NULL) || (bulk_data_slot->data_length == 0)) {
-        return CSR_RESULT_SUCCESS;
-    }
-
-    buf_address = (unsigned long)(bulk_data_slot->os_data_ptr) & (CSR_WIFI_ALIGN_BYTES - 1);
-
-    unifi_trace(priv, UDBG5,
-                "unifi_net_dma_align: Allign buffer (0x%p) by %d bytes\n",
-                bulk_data_slot->os_data_ptr, buf_address);
-
-    offset = CSR_WIFI_ALIGN_BYTES - buf_address;
-    if (offset < 0) {
-        unifi_error(priv, "unifi_net_dma_align: Failed (offset=%d)\n", offset);
-        return CSR_RESULT_FAILURE;
-    }
-
-    skb = (struct sk_buff*)(bulk_data_slot->os_net_buf_ptr);
-    skb_reserve(skb, offset);
-    bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb;
-    bulk_data_slot->os_data_ptr = (const void*)(skb->data);
-
-    return CSR_RESULT_SUCCESS;
-
-} /* unifi_net_dma_align() */
-
-#ifdef ANDROID_TIMESTAMP
-static volatile unsigned int printk_cpu = UINT_MAX;
-char tbuf[30];
-
-char* print_time(void )
-{
-    unsigned long long t;
-    unsigned long nanosec_rem;
-
-    t = cpu_clock(printk_cpu);
-    nanosec_rem = do_div(t, 1000000000);
-    sprintf(tbuf, "[%5lu.%06lu] ",
-                    (unsigned long) t,
-                    nanosec_rem / 1000);
-
-    return tbuf;
-}
-#endif
-
-
-/* Module parameters */
-extern int unifi_debug;
-
-#ifdef UNIFI_DEBUG
-#define DEBUG_BUFFER_SIZE       120
-
-#define FORMAT_TRACE(_s, _len, _args, _fmt)             \
-    do {                                                \
-        va_start(_args, _fmt);                          \
-        _len += vsnprintf(&(_s)[_len],                  \
-                         (DEBUG_BUFFER_SIZE - _len),    \
-                         _fmt, _args);                  \
-        va_end(_args);                                  \
-        if (_len >= DEBUG_BUFFER_SIZE) {                \
-            (_s)[DEBUG_BUFFER_SIZE - 2] = '\n';         \
-            (_s)[DEBUG_BUFFER_SIZE - 1] = 0;            \
-        }                                               \
-    } while (0)
-
-void
-unifi_error(void* ospriv, const char *fmt, ...)
-{
-    unifi_priv_t *priv = (unifi_priv_t*) ospriv;
-    char s[DEBUG_BUFFER_SIZE];
-    va_list args;
-    unsigned int len;
-#ifdef ANDROID_TIMESTAMP
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time());
-    }
-#else
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: ");
-    }
-#endif /* ANDROID_TIMESTAMP */
-    FORMAT_TRACE(s, len, args, fmt);
-
-    printk("%s", s);
-}
-
-void
-unifi_warning(void* ospriv, const char *fmt, ...)
-{
-    unifi_priv_t *priv = (unifi_priv_t*) ospriv;
-    char s[DEBUG_BUFFER_SIZE];
-    va_list args;
-    unsigned int len;
-
-#ifdef ANDROID_TIMESTAMP
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi%d: ", print_time(), priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi: ", print_time());
-    }
-#else
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi%d: ", priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi: ");
-    }
-#endif /* ANDROID_TIMESTAMP */
-
-    FORMAT_TRACE(s, len, args, fmt);
-
-    printk("%s", s);
-}
-
-
-void
-unifi_notice(void* ospriv, const char *fmt, ...)
-{
-    unifi_priv_t *priv = (unifi_priv_t*) ospriv;
-    char s[DEBUG_BUFFER_SIZE];
-    va_list args;
-    unsigned int len;
-
-#ifdef ANDROID_TIMESTAMP
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi%d: ", print_time(), priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi: ", print_time());
-    }
-#else
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi%d: ", priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi: ");
-    }
-#endif /* ANDROID_TIMESTAMP */
-
-    FORMAT_TRACE(s, len, args, fmt);
-
-    printk("%s", s);
-}
-
-
-void
-unifi_info(void* ospriv, const char *fmt, ...)
-{
-    unifi_priv_t *priv = (unifi_priv_t*) ospriv;
-    char s[DEBUG_BUFFER_SIZE];
-    va_list args;
-    unsigned int len;
-
-#ifdef ANDROID_TIMESTAMP
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi%d: ", print_time(), priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi: ", print_time());
-    }
-#else
-    if (priv != NULL) {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi%d: ", priv->instance);
-    } else {
-        len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi: ");
-    }
-#endif /* ANDROID_TIMESTAMP */
-
-    FORMAT_TRACE(s, len, args, fmt);
-
-    printk("%s", s);
-}
-
-/* debugging */
-void
-unifi_trace(void* ospriv, int level, const char *fmt, ...)
-{
-    unifi_priv_t *priv = (unifi_priv_t*) ospriv;
-    char s[DEBUG_BUFFER_SIZE];
-    va_list args;
-    unsigned int len;
-
-    if (unifi_debug >= level) {
-#ifdef ANDROID_TIMESTAMP
-        if (priv != NULL) {
-            len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance);
-        } else {
-            len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time());
-        }
-#else
-        if (priv != NULL) {
-            len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance);
-        } else {
-            len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: ");
-        }
-#endif /* ANDROID_TIMESTAMP */
-
-        FORMAT_TRACE(s, len, args, fmt);
-
-        printk("%s", s);
-    }
-}
-
-#else
-
-void
-unifi_error_nop(void* ospriv, const char *fmt, ...)
-{
-}
-
-void
-unifi_trace_nop(void* ospriv, int level, const char *fmt, ...)
-{
-}
-
-#endif /* UNIFI_DEBUG */
-
-
-/*
- * ---------------------------------------------------------------------------
- *
- *      Debugging support.
- *
- * ---------------------------------------------------------------------------
- */
-
-#ifdef UNIFI_DEBUG
-
-/* Memory dump with level filter controlled by unifi_debug */
-void
-unifi_dump(void *ospriv, int level, const char *msg, void *mem, u16 len)
-{
-    unifi_priv_t *priv = (unifi_priv_t*) ospriv;
-
-    if (unifi_debug >= level) {
-#ifdef ANDROID_TIMESTAMP
-        if (priv != NULL) {
-            printk(KERN_ERR "%s unifi%d: --- dump: %s ---\n", print_time(), priv->instance, msg ? msg : "");
-        } else {
-            printk(KERN_ERR "%s unifi: --- dump: %s ---\n", print_time(), msg ? msg : "");
-        }
-#else
-        if (priv != NULL) {
-            printk(KERN_ERR "unifi%d: --- dump: %s ---\n", priv->instance, msg ? msg : "");
-        } else {
-            printk(KERN_ERR "unifi: --- dump: %s ---\n", msg ? msg : "");
-        }
-#endif /* ANDROID_TIMESTAMP */
-        dump(mem, len);
-
-        if (priv != NULL) {
-            printk(KERN_ERR "unifi%d: --- end of dump ---\n", priv->instance);
-        } else {
-            printk(KERN_ERR "unifi: --- end of dump ---\n");
-        }
-    }
-}
-
-/* Memory dump that appears all the time, use sparingly */
-void
-dump(void *mem, u16 len)
-{
-    int i, col = 0;
-    unsigned char *pdata = (unsigned char *)mem;
-#ifdef ANDROID_TIMESTAMP
-    printk("timestamp %s \n", print_time());
-#endif /* ANDROID_TIMESTAMP */
-    if (mem == NULL) {
-        printk("(null dump)\n");
-        return;
-    }
-    for (i = 0; i < len; i++) {
-        if (col == 0)
-            printk("0x%02X: ", i);
-
-        printk(" %02X", pdata[i]);
-
-        if (++col == 16) {
-            printk("\n");
-            col = 0;
-        }
-    }
-    if (col)
-        printk("\n");
-} /* dump() */
-
-
-void
-dump16(void *mem, u16 len)
-{
-    int i, col=0;
-    unsigned short *p = (unsigned short *)mem;
-#ifdef ANDROID_TIMESTAMP
-    printk("timestamp %s \n", print_time());
-#endif /* ANDROID_TIMESTAMP */
-    for (i = 0; i < len; i+=2) {
-        if (col == 0)
-            printk("0x%02X: ", i);
-
-        printk(" %04X", *p++);
-
-        if (++col == 8) {
-            printk("\n");
-            col = 0;
-        }
-    }
-    if (col)
-        printk("\n");
-}
-
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-void
-dump_str(void *mem, u16 len)
-{
-    int i;
-    unsigned char *pdata = (unsigned char *)mem;
-#ifdef ANDROID_TIMESTAMP
-    printk("timestamp %s \n", print_time());
-#endif /* ANDROID_TIMESTAMP */
-    for (i = 0; i < len; i++) {
-        printk("%c", pdata[i]);
-    }
-       printk("\n");
-
-} /* dump_str() */
-#endif /* CSR_ONLY_NOTES */
-
-
-#endif /* UNIFI_DEBUG */
-
-
-/* ---------------------------------------------------------------------------
- *                              - End -
- * ------------------------------------------------------------------------- */
diff --git a/drivers/staging/csr/putest.c b/drivers/staging/csr/putest.c
deleted file mode 100644 (file)
index 5613cf0..0000000
+++ /dev/null
@@ -1,685 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     putest.c
- *
- *  PURPOSE:    putest related functions.
- *
- *  Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-
-#include <linux/vmalloc.h>
-#include <linux/firmware.h>
-
-#include "unifi_priv.h"
-#include "csr_wifi_hip_chiphelper.h"
-
-#define UNIFI_PROC_BOTH 3
-
-
-int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg)
-{
-    struct unifi_putest_cmd52 cmd52_params;
-    u8 *arg_pos;
-    unsigned int cmd_param_size;
-    int r;
-    CsrResult csrResult;
-    unsigned char ret_buffer[32];
-    u8 *ret_buffer_pos;
-    u8 retries;
-
-    arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
-    if (get_user(cmd_param_size, (int*)arg_pos)) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_read: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_read: cmd52 struct mismatch\n");
-        return -EINVAL;
-    }
-
-    arg_pos += sizeof(unsigned int);
-    if (copy_from_user(&cmd52_params,
-                       (void*)arg_pos,
-                       sizeof(struct unifi_putest_cmd52))) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_read: Failed to get the cmd52 params\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "cmd52r: func=%d addr=0x%x ",
-                cmd52_params.funcnum, cmd52_params.addr);
-
-    retries = 3;
-    CsrSdioClaim(priv->sdio);
-    do {
-        if (cmd52_params.funcnum == 0) {
-            csrResult = CsrSdioF0Read8(priv->sdio, cmd52_params.addr, &cmd52_params.data);
-        } else {
-            csrResult = CsrSdioRead8(priv->sdio, cmd52_params.addr, &cmd52_params.data);
-        }
-    } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT)));
-    CsrSdioRelease(priv->sdio);
-
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "\nunifi_putest_cmd52_read: Read8() failed (csrResult=0x%x)\n", csrResult);
-        return -EFAULT;
-    }
-    unifi_trace(priv, UDBG2, "data=%d\n", cmd52_params.data);
-
-    /* Copy the info to the out buffer */
-    *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_CMD52_READ;
-    ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1);
-    *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_cmd52);
-    ret_buffer_pos += sizeof(unsigned int);
-    memcpy(ret_buffer_pos, &cmd52_params, sizeof(struct unifi_putest_cmd52));
-    ret_buffer_pos += sizeof(struct unifi_putest_cmd52);
-
-    r = copy_to_user((void*)arg,
-                     ret_buffer,
-                     ret_buffer_pos - ret_buffer);
-    if (r) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_read: Failed to return the data\n");
-        return -EFAULT;
-    }
-
-    return 0;
-}
-
-
-int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg)
-{
-    struct unifi_putest_cmd52 cmd52_params;
-    u8 *arg_pos;
-    unsigned int cmd_param_size;
-    CsrResult csrResult;
-    u8 retries;
-
-    arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
-    if (get_user(cmd_param_size, (int*)arg_pos)) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_write: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_write: cmd52 struct mismatch\n");
-        return -EINVAL;
-    }
-
-    arg_pos += sizeof(unsigned int);
-    if (copy_from_user(&cmd52_params,
-                       (void*)(arg_pos),
-                       sizeof(struct unifi_putest_cmd52))) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_write: Failed to get the cmd52 params\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "cmd52w: func=%d addr=0x%x data=%d\n",
-                cmd52_params.funcnum, cmd52_params.addr, cmd52_params.data);
-
-    retries = 3;
-    CsrSdioClaim(priv->sdio);
-    do {
-        if (cmd52_params.funcnum == 0) {
-            csrResult = CsrSdioF0Write8(priv->sdio, cmd52_params.addr, cmd52_params.data);
-        } else {
-            csrResult = CsrSdioWrite8(priv->sdio, cmd52_params.addr, cmd52_params.data);
-        }
-    } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT)));
-    CsrSdioRelease(priv->sdio);
-
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_cmd52_write: Write8() failed (csrResult=0x%x)\n", csrResult);
-        return -EFAULT;
-    }
-
-    return 0;
-}
-
-int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg)
-{
-    struct unifi_putest_gp_rw16 gp_r16_params;
-    u8 *arg_pos;
-    unsigned int cmd_param_size;
-    int r;
-    CsrResult csrResult;
-    unsigned char ret_buffer[32];
-    u8 *ret_buffer_pos;
-
-    arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
-    if (get_user(cmd_param_size, (int*)arg_pos)) {
-        unifi_error(priv,
-                    "unifi_putest_gp_read16: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) {
-        unifi_error(priv,
-                    "unifi_putest_gp_read16: struct mismatch\n");
-        return -EINVAL;
-    }
-
-    arg_pos += sizeof(unsigned int);
-    if (copy_from_user(&gp_r16_params,
-                       (void*)arg_pos,
-                       sizeof(struct unifi_putest_gp_rw16))) {
-        unifi_error(priv,
-                    "unifi_putest_gp_read16: Failed to get the params\n");
-        return -EFAULT;
-    }
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_card_read16(priv->card, gp_r16_params.addr, &gp_r16_params.data);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_gp_read16: unifi_card_read16() GP=0x%x failed (csrResult=0x%x)\n", gp_r16_params.addr, csrResult);
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "gp_r16: GP=0x%08x, data=0x%04x\n", gp_r16_params.addr, gp_r16_params.data);
-
-    /* Copy the info to the out buffer */
-    *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_GP_READ16;
-    ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1);
-    *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_gp_rw16);
-    ret_buffer_pos += sizeof(unsigned int);
-    memcpy(ret_buffer_pos, &gp_r16_params, sizeof(struct unifi_putest_gp_rw16));
-    ret_buffer_pos += sizeof(struct unifi_putest_gp_rw16);
-
-    r = copy_to_user((void*)arg,
-                     ret_buffer,
-                     ret_buffer_pos - ret_buffer);
-    if (r) {
-        unifi_error(priv,
-                    "unifi_putest_gp_read16: Failed to return the data\n");
-        return -EFAULT;
-    }
-
-    return 0;
-}
-
-int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg)
-{
-    struct unifi_putest_gp_rw16 gp_w16_params;
-    u8 *arg_pos;
-    unsigned int cmd_param_size;
-    CsrResult csrResult;
-
-    arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
-    if (get_user(cmd_param_size, (int*)arg_pos)) {
-        unifi_error(priv,
-                    "unifi_putest_gp_write16: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) {
-        unifi_error(priv,
-                    "unifi_putest_gp_write16: struct mismatch\n");
-        return -EINVAL;
-    }
-
-    arg_pos += sizeof(unsigned int);
-    if (copy_from_user(&gp_w16_params,
-                       (void*)(arg_pos),
-                       sizeof(struct unifi_putest_gp_rw16))) {
-        unifi_error(priv,
-                    "unifi_putest_gp_write16: Failed to get the params\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "gp_w16: GP=0x%08x, data=0x%04x\n", gp_w16_params.addr, gp_w16_params.data);
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_card_write16(priv->card, gp_w16_params.addr, gp_w16_params.data);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_gp_write16: unifi_card_write16() GP=%x failed (csrResult=0x%x)\n", gp_w16_params.addr, csrResult);
-        return -EFAULT;
-    }
-
-    return 0;
-}
-
-int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg)
-{
-    int sdio_clock_speed;
-    CsrResult csrResult;
-
-    if (get_user(sdio_clock_speed, (int*)(((unifi_putest_command_t*)arg) + 1))) {
-        unifi_error(priv,
-                    "unifi_putest_set_sdio_clock: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "set sdio clock: %d KHz\n", sdio_clock_speed);
-
-    CsrSdioClaim(priv->sdio);
-    csrResult = CsrSdioMaxBusClockFrequencySet(priv->sdio, sdio_clock_speed * 1000);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_set_sdio_clock: Set clock failed (csrResult=0x%x)\n", csrResult);
-        return -EFAULT;
-    }
-
-    return 0;
-}
-
-
-int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg)
-{
-    int r;
-    CsrResult csrResult;
-    int already_in_test = priv->ptest_mode;
-
-    /* Ensure that sme_sys_suspend() doesn't power down the chip because:
-     *  1) Power is needed anyway for ptest.
-     *  2) The app code uses the START ioctl as a reset, so it gets called
-     *     multiple times. If the app stops the XAPs, but the power_down/up
-     *     sequence doesn't actually power down the chip, there can be problems
-     *     resetting, because part of the power_up sequence disables function 1
-     */
-    priv->ptest_mode = 1;
-
-    /* Suspend the SME and UniFi */
-    if (priv->sme_cli) {
-        r = sme_sys_suspend(priv);
-        if (r) {
-            unifi_error(priv,
-                        "unifi_putest_start: failed to suspend UniFi\n");
-            return r;
-        }
-    }
-
-    /* Application may have stopped the XAPs, but they are needed for reset */
-    if (already_in_test) {
-        CsrSdioClaim(priv->sdio);
-        csrResult = unifi_start_processors(priv->card);
-        CsrSdioRelease(priv->sdio);
-        if (csrResult != CSR_RESULT_SUCCESS) {
-            unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
-        }
-    } else {
-        /* Ensure chip is powered for the case where there's no unifi_helper */
-        CsrSdioClaim(priv->sdio);
-        csrResult = CsrSdioPowerOn(priv->sdio);
-        CsrSdioRelease(priv->sdio);
-        if (csrResult != CSR_RESULT_SUCCESS) {
-            unifi_error(priv, "CsrSdioPowerOn csrResult = %d\n", csrResult);
-        }
-    }
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_init(priv->card);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_start: failed to init UniFi\n");
-        return CsrHipResultToStatus(csrResult);
-    }
-
-    return 0;
-}
-
-
-int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg)
-{
-    int r = 0;
-    CsrResult csrResult;
-
-    /* Application may have stopped the XAPs, but they are needed for reset */
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_start_processors(priv->card);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
-    }
-
-    /* PUTEST_STOP is also used to resume the XAPs after SME coredump.
-     * Don't power off the chip, leave that to the normal wifi-off which is
-     * about to carry on. No need to resume the SME either, as it wasn't suspended.
-     */
-    if (priv->coredump_mode) {
-        priv->coredump_mode = 0;
-        return 0;
-    }
-
-    /* At this point function 1 is enabled and the XAPs are running, so it is
-     * safe to let the card power down. Power is restored later, asynchronously,
-     * during the wifi_on requested by the SME.
-     */
-    CsrSdioClaim(priv->sdio);
-    CsrSdioPowerOff(priv->sdio);
-    CsrSdioRelease(priv->sdio);
-
-    /* Resume the SME and UniFi */
-    if (priv->sme_cli) {
-        r = sme_sys_resume(priv);
-        if (r) {
-            unifi_error(priv,
-                        "unifi_putest_stop: failed to resume SME\n");
-        }
-    }
-    priv->ptest_mode = 0;
-
-    return r;
-}
-
-
-int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg)
-{
-#define UF_PUTEST_MAX_FW_FILE_NAME      16
-#define UNIFI_MAX_FW_PATH_LEN           32
-    unsigned int fw_name_length;
-    unsigned char fw_name[UF_PUTEST_MAX_FW_FILE_NAME+1];
-    unsigned char *name_buffer;
-    int postfix;
-    char fw_path[UNIFI_MAX_FW_PATH_LEN];
-    const struct firmware *fw_entry;
-    struct dlpriv temp_fw_sta;
-    int r;
-    CsrResult csrResult;
-
-    /* Get the f/w file name length */
-    if (get_user(fw_name_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) {
-        unifi_error(priv,
-                    "unifi_putest_dl_fw: Failed to get the length argument\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file name size = %d\n", fw_name_length);
-
-    /* Sanity check for the f/w file name length */
-    if (fw_name_length > UF_PUTEST_MAX_FW_FILE_NAME) {
-        unifi_error(priv,
-                    "unifi_putest_dl_fw: F/W file name is too long\n");
-        return -EINVAL;
-    }
-
-    /* Get the f/w file name */
-    name_buffer = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int);
-    if (copy_from_user(fw_name, (void*)name_buffer, fw_name_length)) {
-        unifi_error(priv, "unifi_putest_dl_fw: Failed to get the file name\n");
-        return -EFAULT;
-    }
-    fw_name[fw_name_length] = '\0';
-    unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file = %s\n", fw_name);
-
-    /* Keep the existing f/w to a temp, we need to restore it later */
-    temp_fw_sta = priv->fw_sta;
-
-    /* Get the putest f/w */
-    postfix = priv->instance;
-    scnprintf(fw_path, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
-              postfix, fw_name);
-    r = request_firmware(&fw_entry, fw_path, priv->unifi_device);
-    if (r == 0) {
-        priv->fw_sta.fw_desc = (void *)fw_entry;
-        priv->fw_sta.dl_data = fw_entry->data;
-        priv->fw_sta.dl_len = fw_entry->size;
-    } else {
-        unifi_error(priv, "Firmware file not available\n");
-        return -EINVAL;
-    }
-
-    /* Application may have stopped the XAPs, but they are needed for reset */
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_start_processors(priv->card);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
-    }
-
-    /* Download the f/w. On UF6xxx this will cause the f/w file to convert
-     * into patch format and download via the ROM boot loader
-     */
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_download(priv->card, 0x0c00);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_dl_fw: failed to download the f/w\n");
-        goto free_fw;
-    }
-
-    /* Free the putest f/w... */
-free_fw:
-    uf_release_firmware(priv, &priv->fw_sta);
-    /* ... and restore the original f/w */
-    priv->fw_sta = temp_fw_sta;
-
-    return CsrHipResultToStatus(csrResult);
-}
-
-
-int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg)
-{
-    unsigned int fw_length;
-    unsigned char *fw_buf = NULL;
-    unsigned char *fw_user_ptr;
-    struct dlpriv temp_fw_sta;
-    CsrResult csrResult;
-
-    /* Get the f/w buffer length */
-    if (get_user(fw_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) {
-        unifi_error(priv,
-                    "unifi_putest_dl_fw_buff: Failed to get the length arg\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "unifi_putest_dl_fw_buff: size = %d\n", fw_length);
-
-    /* Sanity check for the buffer length */
-    if (fw_length == 0 || fw_length > 0xfffffff) {
-        unifi_error(priv,
-                    "unifi_putest_dl_fw_buff: buffer length bad %u\n", fw_length);
-        return -EINVAL;
-    }
-
-    /* Buffer for kernel copy of the f/w image */
-    fw_buf = kmalloc(fw_length, GFP_KERNEL);
-    if (!fw_buf) {
-        unifi_error(priv, "unifi_putest_dl_fw_buff: malloc fail\n");
-        return -ENOMEM;
-    }
-
-    /* Get the f/w image */
-    fw_user_ptr = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int);
-    if (copy_from_user(fw_buf, (void*)fw_user_ptr, fw_length)) {
-        unifi_error(priv, "unifi_putest_dl_fw_buff: Failed to get the buffer\n");
-        kfree(fw_buf);
-        return -EFAULT;
-    }
-
-    /* Save the existing f/w to a temp, we need to restore it later */
-    temp_fw_sta = priv->fw_sta;
-
-    /* Setting fw_desc NULL indicates to the core that no f/w file was loaded
-     * via the kernel request_firmware() mechanism. This indicates to the core
-     * that it shouldn't call release_firmware() after the download is done.
-     */
-    priv->fw_sta.fw_desc = NULL;            /* No OS f/w resource */
-    priv->fw_sta.dl_data = fw_buf;
-    priv->fw_sta.dl_len = fw_length;
-
-    /* Application may have stopped the XAPs, but they are needed for reset */
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_start_processors(priv->card);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
-    }
-
-    /* Download the f/w. On UF6xxx this will cause the f/w file to convert
-     * into patch format and download via the ROM boot loader
-     */
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_download(priv->card, 0x0c00);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv,
-                    "unifi_putest_dl_fw_buff: failed to download the f/w\n");
-        goto free_fw;
-    }
-
-free_fw:
-    /* Finished with the putest f/w, so restore the station f/w */
-    priv->fw_sta = temp_fw_sta;
-    kfree(fw_buf);
-
-    return CsrHipResultToStatus(csrResult);
-}
-
-
-int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg)
-{
-    u16 data_u16;
-    s32 i;
-    CsrResult r;
-
-    unifi_info(priv, "Preparing for SDIO coredump\n");
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
-    unifi_debug_buf_dump();
-#endif
-
-    /* Sanity check that userspace hasn't called a PUTEST_START, because that
-     * would have reset UniFi, potentially power cycling it and losing context
-     */
-    if (priv->ptest_mode) {
-        unifi_error(priv, "PUTEST_START shouldn't be used before a coredump\n");
-    }
-
-    /* Flag that the userspace has requested coredump. Even if this preparation
-     * fails, the SME will call PUTEST_STOP to tidy up.
-     */
-    priv->coredump_mode = 1;
-
-    for (i = 0; i < 3; i++) {
-        CsrSdioClaim(priv->sdio);
-        r = CsrSdioRead16(priv->sdio, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION*2, &data_u16);
-        CsrSdioRelease(priv->sdio);
-        if (r != CSR_RESULT_SUCCESS) {
-            unifi_info(priv, "Failed to read chip version! Try %d\n", i);
-
-            /* First try, re-enable function which may have been disabled by f/w panic */
-            if (i == 0) {
-                unifi_info(priv, "Try function enable\n");
-                CsrSdioClaim(priv->sdio);
-                r = CsrSdioFunctionEnable(priv->sdio);
-                CsrSdioRelease(priv->sdio);
-                if (r != CSR_RESULT_SUCCESS) {
-                    unifi_error(priv, "CsrSdioFunctionEnable failed %d\n", r);
-                }
-                continue;
-            }
-
-            /* Subsequent tries, reset */
-
-            /* Set clock speed low */
-            CsrSdioClaim(priv->sdio);
-            r = CsrSdioMaxBusClockFrequencySet(priv->sdio, UNIFI_SDIO_CLOCK_SAFE_HZ);
-            CsrSdioRelease(priv->sdio);
-            if (r != CSR_RESULT_SUCCESS) {
-                unifi_error(priv, "CsrSdioMaxBusClockFrequencySet() failed %d\n", r);
-            }
-
-            /* Card software reset */
-            CsrSdioClaim(priv->sdio);
-            r = unifi_card_hard_reset(priv->card);
-            CsrSdioRelease(priv->sdio);
-            if (r != CSR_RESULT_SUCCESS) {
-                unifi_error(priv, "unifi_card_hard_reset() failed %d\n", r);
-            }
-        } else {
-            unifi_info(priv, "Read chip version of 0x%04x\n", data_u16);
-            break;
-        }
-    }
-
-    if (r != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Failed to prepare chip\n");
-        return -EIO;
-    }
-
-    /* Stop the XAPs for coredump. The PUTEST_STOP must be called, e.g. at
-     * Raw SDIO deinit, to resume them.
-     */
-    CsrSdioClaim(priv->sdio);
-    r = unifi_card_stop_processor(priv->card, UNIFI_PROC_BOTH);
-    CsrSdioRelease(priv->sdio);
-    if (r != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Failed to stop processors\n");
-    }
-
-    return 0;
-}
-
-int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg)
-{
-    struct unifi_putest_block_cmd52_r block_cmd52;
-    u8 *arg_pos;
-    unsigned int cmd_param_size;
-    CsrResult r;
-    u8 *block_local_buffer;
-
-    arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
-    if (get_user(cmd_param_size, (int*)arg_pos)) {
-        unifi_error(priv,
-                    "cmd52r_block: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    if (cmd_param_size != sizeof(struct unifi_putest_block_cmd52_r)) {
-        unifi_error(priv,
-                    "cmd52r_block: cmd52 struct mismatch\n");
-        return -EINVAL;
-    }
-
-    arg_pos += sizeof(unsigned int);
-    if (copy_from_user(&block_cmd52,
-                       (void*)arg_pos,
-                       sizeof(struct unifi_putest_block_cmd52_r))) {
-        unifi_error(priv,
-                    "cmd52r_block: Failed to get the cmd52 params\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG2, "cmd52r_block: func=%d addr=0x%x len=0x%x ",
-                block_cmd52.funcnum, block_cmd52.addr, block_cmd52.length);
-
-    block_local_buffer = vmalloc(block_cmd52.length);
-    if (block_local_buffer == NULL) {
-        unifi_error(priv, "cmd52r_block: Failed to allocate buffer\n");
-        return -ENOMEM;
-    }
-
-    CsrSdioClaim(priv->sdio);
-    r = unifi_card_readn(priv->card, block_cmd52.addr, block_local_buffer, block_cmd52.length);
-    CsrSdioRelease(priv->sdio);
-    if (r != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "cmd52r_block: unifi_readn failed\n");
-        return -EIO;
-    }
-
-    if (copy_to_user((void*)block_cmd52.data,
-                     block_local_buffer,
-                     block_cmd52.length)) {
-        unifi_error(priv,
-                    "cmd52r_block: Failed to return the data\n");
-        return -EFAULT;
-    }
-
-    return 0;
-}
diff --git a/drivers/staging/csr/sdio_events.c b/drivers/staging/csr/sdio_events.c
deleted file mode 100644 (file)
index 2a80b9e..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     sdio_events.c
- *
- * PURPOSE:
- *      Process the events received by the SDIO glue layer.
- *      Optional part of the porting exercise.
- *
- * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include "unifi_priv.h"
-
-
-/*
- * Porting Notes:
- * There are two ways to support the suspend/resume system events in a driver.
- * In some operating systems these events are delivered to the OS driver
- * directly from the system. In this case, the OS driver needs to pass these
- * events to the API described in the CSR SDIO Abstration API document.
- * In Linux, and other embedded operating systems, the suspend/resume events
- * come from the SDIO driver. In this case, simply get these events in the
- * SDIO glue layer and notify the OS layer.
- *
- * In either case, typically, the events are processed by the SME.
- * Use the unifi_sys_suspend_ind() and unifi_sys_resume_ind() to pass
- * the events to the SME.
- */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_suspend
- *
- *      Handles a suspend request from the SDIO driver.
- *
- *  Arguments:
- *      ospriv          Pointer to OS driver context.
- *
- * ---------------------------------------------------------------------------
- */
-void unifi_suspend(void *ospriv)
-{
-    unifi_priv_t *priv = ospriv;
-    int interfaceTag=0;
-
-    /* For powered suspend, tell the resume's wifi_on() not to reinit UniFi */
-    priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
-
-    unifi_trace(priv, UDBG1, "unifi_suspend: wol_suspend %d, enable_wol %d",
-                priv->wol_suspend, enable_wol );
-
-    /* Stop network traffic. */
-    /* need to stop all the netdevices*/
-    for( interfaceTag=0;interfaceTag<CSR_WIFI_NUM_INTERFACES;interfaceTag++)
-    {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-        if (interfacePriv->netdev_registered == 1)
-        {
-            if( priv->wol_suspend ) {
-                unifi_trace(priv, UDBG1, "unifi_suspend: Don't netif_carrier_off");
-            } else {
-                unifi_trace(priv, UDBG1, "unifi_suspend: netif_carrier_off");
-                netif_carrier_off(priv->netdev[interfaceTag]);
-            }
-            netif_tx_stop_all_queues(priv->netdev[interfaceTag]);
-        }
-    }
-
-    unifi_trace(priv, UDBG1, "unifi_suspend: suspend SME");
-
-    sme_sys_suspend(priv);
-
-} /* unifi_suspend() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_resume
- *
- *      Handles a resume request from the SDIO driver.
- *
- *  Arguments:
- *      ospriv          Pointer to OS driver context.
- *
- * ---------------------------------------------------------------------------
- */
-void unifi_resume(void *ospriv)
-{
-    unifi_priv_t *priv = ospriv;
-    int interfaceTag=0;
-    int r;
-    int wol = priv->wol_suspend;
-
-    unifi_trace(priv, UDBG1, "unifi_resume: resume SME, enable_wol=%d", enable_wol);
-
-    /* The resume causes wifi-on which will re-enable the BH and reinstall the ISR */
-    r = sme_sys_resume(priv);
-    if (r) {
-        unifi_error(priv, "Failed to resume UniFi\n");
-    }
-
-    /* Resume the network interfaces. For the cold resume case, this will
-     * happen upon reconnection.
-     */
-    if (wol) {
-        unifi_trace(priv, UDBG1, "unifi_resume: try to enable carrier");
-
-        /* need to start all the netdevices*/
-        for( interfaceTag=0;interfaceTag<CSR_WIFI_NUM_INTERFACES;interfaceTag++) {
-            netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-            unifi_trace(priv, UDBG1, "unifi_resume: interfaceTag %d netdev_registered %d mode %d\n",
-                   interfaceTag, interfacePriv->netdev_registered, interfacePriv->interfaceMode);
-
-            if (interfacePriv->netdev_registered == 1)
-            {
-                netif_carrier_on(priv->netdev[interfaceTag]);
-                netif_tx_start_all_queues(priv->netdev[interfaceTag]);
-            }
-        }
-
-        /* Kick the BH thread (with reason=host) to poll for data that may have
-         * arrived during a powered suspend. This caters for the case where the SME
-         * doesn't interact with the chip (e.g install autonomous scans) during resume.
-         */
-        unifi_send_signal(priv->card, NULL, 0, NULL);
-    }
-
-} /* unifi_resume() */
-
diff --git a/drivers/staging/csr/sdio_mmc.c b/drivers/staging/csr/sdio_mmc.c
deleted file mode 100644 (file)
index 2b503c2..0000000
+++ /dev/null
@@ -1,1288 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *
- * FILE: sdio_mmc.c
- *
- * PURPOSE: SDIO driver interface for generic MMC stack.
- *
- * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/mutex.h>
-#include <linux/gfp.h>
-#include <linux/mmc/core.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/sdio.h>
-#include <linux/suspend.h>
-
-#include "unifi_priv.h"
-
-#ifdef ANDROID_BUILD
-struct wake_lock unifi_sdio_wake_lock; /* wakelock to prevent suspend while resuming */
-#endif
-
-static CsrSdioFunctionDriver *sdio_func_drv;
-
-#ifdef CONFIG_PM
-static int uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr);
-#endif
-
-/*
- * We need to keep track of the power on/off because we can not call
- * mmc_power_restore_host() when the card is already powered.
- * Even then, we need to patch the MMC driver to add a power_restore handler
- * in the mmc_sdio_ops structure. If the MMC driver before 2.6.37 is not patched,
- * mmc_power_save_host() and mmc_power_restore_host() are no-ops in the kernel,
- * returning immediately (at least on x86).
- */
-static int card_is_powered = 1;
-
-/* MMC uses ENOMEDIUM to indicate card gone away */
-
-static CsrResult
-ConvertSdioToCsrSdioResult(int r)
-{
-    CsrResult csrResult = CSR_RESULT_FAILURE;
-
-    switch (r) {
-    case 0:
-        csrResult = CSR_RESULT_SUCCESS;
-    break;
-    case -EIO:
-    case -EILSEQ:
-        csrResult = CSR_SDIO_RESULT_CRC_ERROR;
-    break;
-    /* Timeout errors */
-    case -ETIMEDOUT:
-    case -EBUSY:
-        csrResult = CSR_SDIO_RESULT_TIMEOUT;
-    break;
-    case -ENODEV:
-    case -ENOMEDIUM:
-        csrResult = CSR_SDIO_RESULT_NO_DEVICE;
-    break;
-    case -EINVAL:
-        csrResult = CSR_SDIO_RESULT_INVALID_VALUE;
-    break;
-    case -ENOMEM:
-    case -ENOSYS:
-    case -ERANGE:
-    case -ENXIO:
-        csrResult = CSR_RESULT_FAILURE;
-    break;
-    default:
-        unifi_warning(NULL, "Unrecognised SDIO error code: %d\n", r);
-    break;
-    }
-
-    return csrResult;
-}
-
-
-static int
-csr_io_rw_direct(struct mmc_card *card, int write, uint8_t fn,
-                 uint32_t addr, uint8_t in, uint8_t* out)
-{
-    struct mmc_command cmd;
-    int err;
-
-    BUG_ON(!card);
-    BUG_ON(fn > 7);
-
-    memset(&cmd, 0, sizeof(struct mmc_command));
-
-    cmd.opcode = SD_IO_RW_DIRECT;
-    cmd.arg = write ? 0x80000000 : 0x00000000;
-    cmd.arg |= fn << 28;
-    cmd.arg |= (write && out) ? 0x08000000 : 0x00000000;
-    cmd.arg |= addr << 9;
-    cmd.arg |= in;
-    cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC;
-
-    err = mmc_wait_for_cmd(card->host, &cmd, 0);
-    if (err)
-        return err;
-
-    /* this function is not exported, so we will need to sort it out here
-     * for now, lets hard code it to sdio */
-    if (0) {
-        /* old arg (mmc_host_is_spi(card->host)) { */
-        /* host driver already reported errors */
-    } else {
-        if (cmd.resp[0] & R5_ERROR) {
-            printk(KERN_ERR "%s: r5 error 0x%02x\n",
-                   __FUNCTION__, cmd.resp[0]);
-            return -EIO;
-        }
-        if (cmd.resp[0] & R5_FUNCTION_NUMBER)
-            return -EINVAL;
-        if (cmd.resp[0] & R5_OUT_OF_RANGE)
-            return -ERANGE;
-    }
-
-    if (out) {
-        if (0) {    /* old argument (mmc_host_is_spi(card->host)) */
-            *out = (cmd.resp[0] >> 8) & 0xFF;
-        }
-        else {
-            *out = cmd.resp[0] & 0xFF;
-        }
-    }
-
-    return CSR_RESULT_SUCCESS;
-}
-
-
-CsrResult
-CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err = 0;
-
-    _sdio_claim_host(func);
-    *data = sdio_readb(func, address, &err);
-    _sdio_release_host(func);
-
-    if (err) {
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioRead8() */
-
-CsrResult
-CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err = 0;
-
-    _sdio_claim_host(func);
-    sdio_writeb(func, data, address, &err);
-    _sdio_release_host(func);
-
-    if (err) {
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioWrite8() */
-
-CsrResult
-CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err;
-    uint8_t b0, b1;
-
-    _sdio_claim_host(func);
-    b0 = sdio_readb(func, address, &err);
-    if (err) {
-        _sdio_release_host(func);
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    b1 = sdio_readb(func, address+1, &err);
-    if (err) {
-        _sdio_release_host(func);
-        return ConvertSdioToCsrSdioResult(err);
-    }
-    _sdio_release_host(func);
-
-    *data = ((uint16_t)b1 << 8) | b0;
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioRead16() */
-
-
-CsrResult
-CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err;
-    uint8_t b0, b1;
-
-    _sdio_claim_host(func);
-    b1 = (data >> 8) & 0xFF;
-    sdio_writeb(func, b1, address+1, &err);
-    if (err) {
-        _sdio_release_host(func);
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    b0 = data & 0xFF;
-    sdio_writeb(func, b0, address, &err);
-    if (err) {
-        _sdio_release_host(func);
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    _sdio_release_host(func);
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioWrite16() */
-
-
-CsrResult
-CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err = 0;
-
-    _sdio_claim_host(func);
-#ifdef MMC_QUIRK_LENIENT_FN0
-    *data = sdio_f0_readb(func, address, &err);
-#else
-    err = csr_io_rw_direct(func->card, 0, 0, address, 0, data);
-#endif
-    _sdio_release_host(func);
-
-    if (err) {
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioF0Read8() */
-
-CsrResult
-CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err = 0;
-
-    _sdio_claim_host(func);
-#ifdef MMC_QUIRK_LENIENT_FN0
-    sdio_f0_writeb(func, data, address, &err);
-#else
-    err = csr_io_rw_direct(func->card, 1, 0, address, data, NULL);
-#endif
-    _sdio_release_host(func);
-
-    if (err) {
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioF0Write8() */
-
-
-CsrResult
-CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err;
-
-    _sdio_claim_host(func);
-    err = sdio_readsb(func, data, address, length);
-    _sdio_release_host(func);
-
-    if (err) {
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioRead() */
-
-CsrResult
-CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err;
-
-    _sdio_claim_host(func);
-    err = sdio_writesb(func, address, (void*)data, length);
-    _sdio_release_host(func);
-
-    if (err) {
-        return ConvertSdioToCsrSdioResult(err);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioWrite() */
-
-
-static int
-csr_sdio_enable_hs(struct mmc_card *card)
-{
-    int ret;
-    u8 speed;
-
-    if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) {
-        /* We've asked for HS clock rates, but controller doesn't
-         * claim to support it. We should limit the clock
-         * to 25MHz via module parameter.
-         */
-        printk(KERN_INFO "unifi: request HS but not MMC_CAP_SD_HIGHSPEED");
-        return 0;
-    }
-
-    if (!card->cccr.high_speed)
-        return 0;
-
-#if 1
-    ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);
-    if (ret)
-        return ret;
-
-    speed |= SDIO_SPEED_EHS;
-#else
-    /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */
-    speed = SDIO_SPEED_EHS | SDIO_SPEED_SHS;
-#endif
-
-    ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);
-    if (ret)
-        return ret;
-
-    mmc_card_set_highspeed(card);
-    card->host->ios.timing = MMC_TIMING_SD_HS;
-    card->host->ops->set_ios(card->host, &card->host->ios);
-
-    return 0;
-}
-
-static int
-csr_sdio_disable_hs(struct mmc_card *card)
-{
-    int ret;
-    u8 speed;
-
-    if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
-        return 0;
-
-    if (!card->cccr.high_speed)
-        return 0;
-#if 1
-    ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);
-    if (ret)
-        return ret;
-
-    speed &= ~SDIO_SPEED_EHS;
-#else
-    /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */
-    speed = SDIO_SPEED_SHS; /* clear SDIO_SPEED_EHS */
-#endif
-
-    ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);
-    if (ret)
-        return ret;
-
-    card->state &= ~MMC_STATE_HIGHSPEED;
-    card->host->ios.timing = MMC_TIMING_LEGACY;
-    card->host->ops->set_ios(card->host, &card->host->ios);
-
-    return 0;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioMaxBusClockFrequencySet
- *
- *      Set the maximum SDIO bus clock speed to use.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- *      maxFrequency         maximum clock speed in Hz
- *
- *  Returns:
- *      an error code.
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    struct mmc_host *host = func->card->host;
-    struct mmc_ios *ios = &host->ios;
-    unsigned int max_hz;
-    int err;
-       u32 max_khz = maxFrequency/1000;
-
-    if (!max_khz || max_khz > sdio_clock) {
-        max_khz = sdio_clock;
-    }
-
-    _sdio_claim_host(func);
-    max_hz = 1000 * max_khz;
-    if (max_hz > host->f_max) {
-        max_hz = host->f_max;
-    }
-
-    if (max_hz > 25000000) {
-        err = csr_sdio_enable_hs(func->card);
-    } else {
-        err = csr_sdio_disable_hs(func->card);
-    }
-    if (err) {
-        printk(KERN_ERR "SDIO warning: Failed to configure SDIO clock mode\n");
-        _sdio_release_host(func);
-               return CSR_RESULT_SUCCESS;
-    }
-
-    ios->clock = max_hz;
-    host->ops->set_ios(host, ios);
-
-    _sdio_release_host(func);
-
-       return CSR_RESULT_SUCCESS;
-} /* CsrSdioMaxBusClockFrequencySet() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioInterruptEnable
- *  CsrSdioInterruptDisable
- *
- *      Enable or disable the SDIO interrupt.
- *      The driver disables the SDIO interrupt until the i/o thread can
- *      process it.
- *      The SDIO interrupt can be disabled by modifying the SDIO_INT_ENABLE
- *      register in the Card Common Control Register block, but this requires
- *      two CMD52 operations. A better solution is to mask the interrupt at
- *      the host controller.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- *
- *  Returns:
- *      Zero on success or a UniFi driver error code.
- *
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioInterruptEnable(CsrSdioFunction *function)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err = 0;
-
-#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
-    sdio_unblock_card_irq(func);
-#else
-    _sdio_claim_host(func);
-    /* Write the Int Enable in CCCR block */
-#ifdef MMC_QUIRK_LENIENT_FN0
-    sdio_f0_writeb(func, 0x3, SDIO_CCCR_IENx, &err);
-#else
-    err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x03, NULL);
-#endif
-    _sdio_release_host(func);
-
-    if (err) {
-        printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err);
-        return ConvertSdioToCsrSdioResult(err);
-    }
-#endif
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioInterruptEnable() */
-
-CsrResult
-CsrSdioInterruptDisable(CsrSdioFunction *function)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err = 0;
-
-#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
-    sdio_block_card_irq(func);
-#else
-    _sdio_claim_host(func);
-    /* Write the Int Enable in CCCR block */
-#ifdef MMC_QUIRK_LENIENT_FN0
-    sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &err);
-#else
-    err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL);
-#endif
-    _sdio_release_host(func);
-
-    if (err) {
-        printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err);
-        return ConvertSdioToCsrSdioResult(err);
-    }
-#endif
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioInterruptDisable() */
-
-
-void CsrSdioInterruptAcknowledge(CsrSdioFunction *function)
-{
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioFunctionEnable
- *
- *      Enable i/o on function 1.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- *
- * Returns:
- *      UniFi driver error code.
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioFunctionEnable(CsrSdioFunction *function)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err;
-
-    /* Enable UniFi function 1 (the 802.11 part). */
-    _sdio_claim_host(func);
-    err = sdio_enable_func(func);
-    _sdio_release_host(func);
-    if (err) {
-        unifi_error(NULL, "Failed to enable SDIO function %d\n", func->num);
-    }
-
-    return ConvertSdioToCsrSdioResult(err);
-} /* CsrSdioFunctionEnable() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioFunctionDisable
- *
- *      Enable i/o on function 1.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- *
- * Returns:
- *      UniFi driver error code.
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioFunctionDisable(CsrSdioFunction *function)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int err;
-
-    /* Disable UniFi function 1 (the 802.11 part). */
-    _sdio_claim_host(func);
-    err = sdio_disable_func(func);
-    _sdio_release_host(func);
-    if (err) {
-        unifi_error(NULL, "Failed to disable SDIO function %d\n", func->num);
-    }
-
-    return ConvertSdioToCsrSdioResult(err);
-} /* CsrSdioFunctionDisable() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioFunctionActive
- *
- *      No-op as the bus goes to an active state at the start of every
- *      command.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- * ---------------------------------------------------------------------------
- */
-void
-CsrSdioFunctionActive(CsrSdioFunction *function)
-{
-} /* CsrSdioFunctionActive() */
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioFunctionIdle
- *
- *      Set the function as idle.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- * ---------------------------------------------------------------------------
- */
-void
-CsrSdioFunctionIdle(CsrSdioFunction *function)
-{
-} /* CsrSdioFunctionIdle() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioPowerOn
- *
- *      Power on UniFi.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioPowerOn(CsrSdioFunction *function)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    struct mmc_host *host = func->card->host;
-
-    _sdio_claim_host(func);
-    if (!card_is_powered) {
-        mmc_power_restore_host(host);
-        card_is_powered = 1;
-    } else {
-        printk(KERN_INFO "SDIO: Skip power on; card is already powered.\n");
-    }
-    _sdio_release_host(func);
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioPowerOn() */
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioPowerOff
- *
- *      Power off UniFi.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- * ---------------------------------------------------------------------------
- */
-void
-CsrSdioPowerOff(CsrSdioFunction *function)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    struct mmc_host *host = func->card->host;
-
-    _sdio_claim_host(func);
-    if (card_is_powered) {
-        mmc_power_save_host(host);
-        card_is_powered = 0;
-    } else {
-        printk(KERN_INFO "SDIO: Skip power off; card is already powered off.\n");
-    }
-    _sdio_release_host(func);
-} /* CsrSdioPowerOff() */
-
-
-static int
-sdio_set_block_size_ignore_first_error(struct sdio_func *func, unsigned blksz)
-{
-    int ret;
-
-    if (blksz > func->card->host->max_blk_size)
-        return -EINVAL;
-
-    if (blksz == 0) {
-        blksz = min(func->max_blksize, func->card->host->max_blk_size);
-        blksz = min(blksz, 512u);
-    }
-
-    /*
-     * Ignore -ERANGE (OUT_OF_RANGE in R5) on the first byte as
-     * the block size may be invalid until both bytes are written.
-     */
-    ret = csr_io_rw_direct(func->card, 1, 0,
-                           SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE,
-                           blksz & 0xff, NULL);
-    if (ret && ret != -ERANGE)
-        return ret;
-    ret = csr_io_rw_direct(func->card, 1, 0,
-                           SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1,
-                           (blksz >> 8) & 0xff, NULL);
-    if (ret)
-        return ret;
-    func->cur_blksize = blksz;
-
-    return 0;
-}
-
-CsrResult
-CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize)
-{
-    struct sdio_func *func = (struct sdio_func *)function->priv;
-    int r = 0;
-
-    /* Module parameter overrides */
-    if (sdio_block_size > -1) {
-        blockSize = sdio_block_size;
-    }
-
-    unifi_trace(NULL, UDBG1, "Set SDIO function block size to %d\n",
-                blockSize);
-
-    _sdio_claim_host(func);
-    r = sdio_set_block_size(func, blockSize);
-    _sdio_release_host(func);
-
-    /*
-     * The MMC driver for kernels prior to 2.6.32 may fail this request
-     * with -ERANGE. In this case use our workaround.
-     */
-    if (r == -ERANGE) {
-        _sdio_claim_host(func);
-        r = sdio_set_block_size_ignore_first_error(func, blockSize);
-        _sdio_release_host(func);
-    }
-    if (r) {
-        unifi_error(NULL, "Error %d setting block size\n", r);
-    }
-
-    /* Determine the achieved block size to pass to the core */
-    function->blockSize = func->cur_blksize;
-
-    return ConvertSdioToCsrSdioResult(r);
-} /* CsrSdioBlockSizeSet() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioHardReset
- *
- *      Hard Resets UniFi is possible.
- *
- *  Arguments:
- *      sdio            SDIO context pointer
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioHardReset(CsrSdioFunction *function)
-{
-    return CSR_RESULT_FAILURE;
-} /* CsrSdioHardReset() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_glue_sdio_int_handler
- *
- *      Interrupt callback function for SDIO interrupts.
- *      This is called in kernel context (i.e. not interrupt context).
- *
- *  Arguments:
- *      func      SDIO context pointer
- *
- *  Returns:
- *      None.
- *
- *  Note: Called with host already claimed.
- * ---------------------------------------------------------------------------
- */
-static void
-uf_glue_sdio_int_handler(struct sdio_func *func)
-{
-    CsrSdioFunction *sdio_ctx;
-    CsrSdioInterruptDsrCallback func_dsr_callback;
-    int r;
-
-    sdio_ctx = sdio_get_drvdata(func);
-    if (!sdio_ctx) {
-        return;
-    }
-
-#ifndef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
-    /*
-     * Normally, we are not allowed to do any SDIO commands here.
-     * However, this is called in a thread context and with the SDIO lock
-     * so we disable the interrupts here instead of trying to do complicated
-     * things with the SDIO lock.
-     */
-#ifdef MMC_QUIRK_LENIENT_FN0
-    sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &r);
-#else
-    r = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL);
-#endif
-    if (r) {
-        printk(KERN_ERR "UniFi MMC Int handler: Failed to disable interrupts %d\n", r);
-    }
-#endif
-
-    /* If the function driver has registered a handler, call it */
-    if (sdio_func_drv && sdio_func_drv->intr) {
-
-        func_dsr_callback = sdio_func_drv->intr(sdio_ctx);
-
-        /* If interrupt handle returns a DSR handle, call it */
-        if (func_dsr_callback) {
-            func_dsr_callback(sdio_ctx);
-        }
-    }
-
-} /* uf_glue_sdio_int_handler() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  csr_sdio_linux_remove_irq
- *
- *      Unregister the interrupt handler.
- *      This means that the linux layer can not process interrupts any more.
- *
- *  Arguments:
- *      sdio      SDIO context pointer
- *
- *  Returns:
- *      Status of the removal.
- * ---------------------------------------------------------------------------
- */
-int csr_sdio_linux_remove_irq(CsrSdioFunction *function)
-{
-       struct sdio_func *func = (struct sdio_func *)function->priv;
-       int r;
-
-       unifi_trace(NULL, UDBG1, "csr_sdio_linux_remove_irq\n");
-
-       sdio_claim_host(func);
-       r = sdio_release_irq(func);
-       sdio_release_host(func);
-
-       return r;
-
-} /* csr_sdio_linux_remove_irq() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  csr_sdio_linux_install_irq
- *
- *      Register the interrupt handler.
- *      This means that the linux layer can process interrupts.
- *
- *  Arguments:
- *      sdio      SDIO context pointer
- *
- *  Returns:
- *      Status of the removal.
- * ---------------------------------------------------------------------------
- */
-int csr_sdio_linux_install_irq(CsrSdioFunction *function)
-{
-       struct sdio_func *func = (struct sdio_func *)function->priv;
-       int r;
-
-       unifi_trace(NULL, UDBG1, "csr_sdio_linux_install_irq\n");
-
-       /* Register our interrupt handle */
-       sdio_claim_host(func);
-       r = sdio_claim_irq(func, uf_glue_sdio_int_handler);
-       sdio_release_host(func);
-
-       /* If the interrupt was installed earlier, is fine */
-       if (r == -EBUSY)
-               r = 0;
-
-       return r;
-} /* csr_sdio_linux_install_irq() */
-
-#ifdef CONFIG_PM
-
-/*
- * Power Management notifier
- */
-struct uf_sdio_mmc_pm_notifier
-{
-    struct list_head list;
-
-    CsrSdioFunction *sdio_ctx;
-    struct notifier_block pm_notifier;
-};
-
-/* PM notifier list head */
-static struct uf_sdio_mmc_pm_notifier uf_sdio_mmc_pm_notifiers = {
-    .sdio_ctx = NULL,
-};
-
-/*
- * ---------------------------------------------------------------------------
- * uf_sdio_mmc_register_pm_notifier
- * uf_sdio_mmc_unregister_pm_notifier
- *
- *      Register/unregister for power management events. A list is used to
- *      allow multiple card instances to be supported.
- *
- *  Arguments:
- *      sdio_ctx - CSR SDIO context to associate PM notifier to
- *
- *  Returns:
- *      Register function returns NULL on error
- * ---------------------------------------------------------------------------
- */
-static struct uf_sdio_mmc_pm_notifier *
-uf_sdio_mmc_register_pm_notifier(CsrSdioFunction *sdio_ctx)
-{
-    /* Allocate notifier context for this card instance */
-    struct uf_sdio_mmc_pm_notifier *notifier_ctx = kmalloc(sizeof(struct uf_sdio_mmc_pm_notifier), GFP_KERNEL);
-
-    if (notifier_ctx)
-    {
-        notifier_ctx->sdio_ctx = sdio_ctx;
-        notifier_ctx->pm_notifier.notifier_call = uf_sdio_mmc_power_event;
-
-        list_add(&notifier_ctx->list, &uf_sdio_mmc_pm_notifiers.list);
-
-        if (register_pm_notifier(&notifier_ctx->pm_notifier)) {
-            printk(KERN_ERR "unifi: register_pm_notifier failed\n");
-        }
-    }
-
-    return notifier_ctx;
-}
-
-static void
-uf_sdio_mmc_unregister_pm_notifier(CsrSdioFunction *sdio_ctx)
-{
-    struct uf_sdio_mmc_pm_notifier *notifier_ctx;
-    struct list_head *node, *q;
-
-    list_for_each_safe(node, q, &uf_sdio_mmc_pm_notifiers.list) {
-        notifier_ctx = list_entry(node, struct uf_sdio_mmc_pm_notifier, list);
-
-        /* If it matches, unregister and free the notifier context */
-        if (notifier_ctx && notifier_ctx->sdio_ctx == sdio_ctx)
-        {
-            if (unregister_pm_notifier(&notifier_ctx->pm_notifier)) {
-                printk(KERN_ERR "unifi: unregister_pm_notifier failed\n");
-            }
-
-            /* Remove from list */
-            notifier_ctx->sdio_ctx = NULL;
-            list_del(node);
-            kfree(notifier_ctx);
-        }
-    }
-}
-
-/*
- * ---------------------------------------------------------------------------
- * uf_sdio_mmc_power_event
- *
- *      Handler for power management events.
- *
- *      We need to handle suspend/resume events while the userspace is unsuspended
- *      to allow the SME to run its suspend/resume state machines.
- *
- *  Arguments:
- *      event   event ID
- *
- *  Returns:
- *      Status of the event handling
- * ---------------------------------------------------------------------------
- */
-static int
-uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr)
-{
-    struct uf_sdio_mmc_pm_notifier *notifier_ctx = container_of(this,
-                                                                struct uf_sdio_mmc_pm_notifier,
-                                                                pm_notifier);
-
-    /* Call the CSR SDIO function driver's suspend/resume method
-     * while the userspace is unsuspended.
-     */
-    switch (event) {
-        case PM_POST_HIBERNATION:
-        case PM_POST_SUSPEND:
-            printk(KERN_INFO "%s:%d resume\n", __FUNCTION__, __LINE__ );
-            if (sdio_func_drv && sdio_func_drv->resume) {
-                sdio_func_drv->resume(notifier_ctx->sdio_ctx);
-            }
-            break;
-
-        case PM_HIBERNATION_PREPARE:
-        case PM_SUSPEND_PREPARE:
-            printk(KERN_INFO "%s:%d suspend\n", __FUNCTION__, __LINE__ );
-            if (sdio_func_drv && sdio_func_drv->suspend) {
-                sdio_func_drv->suspend(notifier_ctx->sdio_ctx);
-            }
-            break;
-    }
-    return NOTIFY_DONE;
-}
-
-#endif /* CONFIG_PM */
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_glue_sdio_probe
- *
- *      Card insert callback.
- *
- * Arguments:
- *      func            Our (glue layer) context pointer.
- *
- * Returns:
- *      UniFi driver error code.
- * ---------------------------------------------------------------------------
- */
-static int
-uf_glue_sdio_probe(struct sdio_func *func,
-                   const struct sdio_device_id *id)
-{
-    int instance;
-    CsrSdioFunction *sdio_ctx;
-
-    /* First of all claim the SDIO driver */
-    sdio_claim_host(func);
-
-    /* Assume that the card is already powered */
-    card_is_powered = 1;
-
-    /* Assumes one card per host, which is true for SDIO */
-    instance = func->card->host->index;
-    printk("sdio bus_id: %16s - UniFi card 0x%X inserted\n",
-           sdio_func_id(func), instance);
-
-    /* Allocate context */
-    sdio_ctx = kmalloc(sizeof(CsrSdioFunction), GFP_KERNEL);
-    if (sdio_ctx == NULL) {
-        sdio_release_host(func);
-        return -ENOMEM;
-    }
-
-    /* Initialise the context */
-    sdio_ctx->sdioId.manfId  = func->vendor;
-    sdio_ctx->sdioId.cardId  = func->device;
-    sdio_ctx->sdioId.sdioFunction  = func->num;
-    sdio_ctx->sdioId.sdioInterface = func->class;
-    sdio_ctx->blockSize = func->cur_blksize;
-    sdio_ctx->priv = (void *)func;
-    sdio_ctx->features = 0;
-
-    /* Module parameter enables byte mode */
-    if (sdio_byte_mode) {
-        sdio_ctx->features |= CSR_SDIO_FEATURE_BYTE_MODE;
-    }
-
-    if (func->card->host->caps & MMC_CAP_SD_HIGHSPEED) {
-        unifi_trace(NULL, UDBG1, "MMC_CAP_SD_HIGHSPEED is available\n");
-    }
-
-#ifdef MMC_QUIRK_LENIENT_FN0
-    func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
-#endif
-
-    /* Pass context to the SDIO driver */
-    sdio_set_drvdata(func, sdio_ctx);
-
-#ifdef CONFIG_PM
-    /* Register to get PM events */
-    if (uf_sdio_mmc_register_pm_notifier(sdio_ctx) == NULL) {
-        unifi_error(NULL, "%s: Failed to register for PM events\n", __FUNCTION__);
-    }
-#endif
-
-    /* Register this device with the SDIO function driver */
-    /* Call the main UniFi driver inserted handler */
-    if (sdio_func_drv && sdio_func_drv->inserted) {
-        uf_add_os_device(instance, &func->dev);
-        sdio_func_drv->inserted(sdio_ctx);
-    }
-
-    /* We have finished, so release the SDIO driver */
-    sdio_release_host(func);
-
-#ifdef ANDROID_BUILD
-    /* Take the wakelock */
-    unifi_trace(NULL, UDBG1, "probe: take wake lock\n");
-    wake_lock(&unifi_sdio_wake_lock);
-#endif
-
-    return 0;
-} /* uf_glue_sdio_probe() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_glue_sdio_remove
- *
- *      Card removal callback.
- *
- * Arguments:
- *      func            Our (glue layer) context pointer.
- *
- * Returns:
- *      UniFi driver error code.
- * ---------------------------------------------------------------------------
- */
-static void
-uf_glue_sdio_remove(struct sdio_func *func)
-{
-    CsrSdioFunction *sdio_ctx;
-
-    sdio_ctx = sdio_get_drvdata(func);
-    if (!sdio_ctx) {
-        return;
-    }
-
-    unifi_info(NULL, "UniFi card removed\n");
-
-    /* Clean up the SDIO function driver */
-    if (sdio_func_drv && sdio_func_drv->removed) {
-        uf_remove_os_device(func->card->host->index);
-        sdio_func_drv->removed(sdio_ctx);
-    }
-
-#ifdef CONFIG_PM
-    /* Unregister for PM events */
-    uf_sdio_mmc_unregister_pm_notifier(sdio_ctx);
-#endif
-
-    kfree(sdio_ctx);
-
-} /* uf_glue_sdio_remove */
-
-
-/*
- * SDIO ids *must* be statically declared, so we can't take
- * them from the list passed in csr_sdio_register_driver().
- */
-static const struct sdio_device_id unifi_ids[] = {
-    { SDIO_DEVICE(SDIO_MANF_ID_CSR, SDIO_CARD_ID_UNIFI_3) },
-    { SDIO_DEVICE(SDIO_MANF_ID_CSR, SDIO_CARD_ID_UNIFI_4) },
-    { /* end: all zeroes */                            },
-};
-
-MODULE_DEVICE_TABLE(sdio, unifi_ids);
-
-#ifdef CONFIG_PM
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_glue_sdio_suspend
- *
- *      Card suspend callback. The userspace will already be suspended.
- *
- * Arguments:
- *      dev            The struct device owned by the MMC driver
- *
- * Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-static int
-uf_glue_sdio_suspend(struct device *dev)
-{
-    unifi_trace(NULL, UDBG1, "uf_glue_sdio_suspend");
-
-    return 0;
-} /* uf_glue_sdio_suspend */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_glue_sdio_resume
- *
- *      Card resume callback. The userspace will still be suspended.
- *
- * Arguments:
- *      dev            The struct device owned by the MMC driver
- *
- * Returns:
- *      None
- * ---------------------------------------------------------------------------
- */
-static int
-uf_glue_sdio_resume(struct device *dev)
-{
-    unifi_trace(NULL, UDBG1, "uf_glue_sdio_resume");
-
-#ifdef ANDROID_BUILD
-    unifi_trace(NULL, UDBG1, "resume: take wakelock\n");
-    wake_lock(&unifi_sdio_wake_lock);
-#endif
-
-    return 0;
-
-} /* uf_glue_sdio_resume */
-
-static struct dev_pm_ops unifi_pm_ops = {
-    .suspend = uf_glue_sdio_suspend,
-    .resume  = uf_glue_sdio_resume,
-};
-
-#define UNIFI_PM_OPS  (&unifi_pm_ops)
-
-#else
-
-#define UNIFI_PM_OPS  NULL
-
-#endif /* CONFIG_PM */
-
-static struct sdio_driver unifi_driver = {
-    .probe      = uf_glue_sdio_probe,
-    .remove     = uf_glue_sdio_remove,
-    .name       = "unifi",
-    .id_table  = unifi_ids,
-    .drv.pm     = UNIFI_PM_OPS,
-};
-
-
-/*
- * ---------------------------------------------------------------------------
- *  CsrSdioFunctionDriverRegister
- *  CsrSdioFunctionDriverUnregister
- *
- *      These functions are called from the main module load and unload
- *      functions. They perform the appropriate operations for the
- *      linux MMC/SDIO driver.
- *
- *  Arguments:
- *      sdio_drv    Pointer to the function driver's SDIO structure.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-CsrResult
-CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *sdio_drv)
-{
-    int r;
-
-    printk("UniFi: Using native Linux MMC driver for SDIO.\n");
-
-    if (sdio_func_drv) {
-        unifi_error(NULL, "sdio_mmc: UniFi driver already registered\n");
-        return CSR_SDIO_RESULT_INVALID_VALUE;
-    }
-
-#ifdef ANDROID_BUILD
-    wake_lock_init(&unifi_sdio_wake_lock, WAKE_LOCK_SUSPEND, "unifi_sdio_work");
-#endif
-
-    /* Save the registered driver description */
-    /*
-     * FIXME:
-     * Need a table here to handle a call to register for just one function.
-     * mmc only allows us to register for the whole device
-     */
-    sdio_func_drv = sdio_drv;
-
-#ifdef CONFIG_PM
-    /* Initialise PM notifier list */
-    INIT_LIST_HEAD(&uf_sdio_mmc_pm_notifiers.list);
-#endif
-
-    /* Register ourself with mmc_core */
-    r = sdio_register_driver(&unifi_driver);
-    if (r) {
-        printk(KERN_ERR "unifi_sdio: Failed to register UniFi SDIO driver: %d\n", r);
-        return ConvertSdioToCsrSdioResult(r);
-    }
-
-    return CSR_RESULT_SUCCESS;
-} /* CsrSdioFunctionDriverRegister() */
-
-
-
-void
-CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *sdio_drv)
-{
-    printk(KERN_INFO "UniFi: unregister from MMC sdio\n");
-
-#ifdef ANDROID_BUILD
-    wake_lock_destroy(&unifi_sdio_wake_lock);
-#endif
-    sdio_unregister_driver(&unifi_driver);
-
-    sdio_func_drv = NULL;
-
-} /* CsrSdioFunctionDriverUnregister() */
-
diff --git a/drivers/staging/csr/sdio_stubs.c b/drivers/staging/csr/sdio_stubs.c
deleted file mode 100644 (file)
index 839fae0..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Stubs for some of the bottom edge functions.
- *
- * These stubs are optional functions in the bottom edge (SDIO driver
- * interface) API that not all platforms or SDIO drivers may support.
- *
- * They're declared as weak symbols so they can be overridden by
- * simply providing a non-weak declaration.
- *
- * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- */
-#include "csr_wifi_hip_unifi.h"
-
-void __attribute__((weak)) CsrSdioFunctionIdle(CsrSdioFunction *function)
-{
-}
-
-void __attribute__((weak)) CsrSdioFunctionActive(CsrSdioFunction *function)
-{
-}
-
-CsrResult __attribute__((weak)) CsrSdioPowerOn(CsrSdioFunction *function)
-{
-    return CSR_RESULT_SUCCESS;
-}
-
-void __attribute__((weak)) CsrSdioPowerOff(CsrSdioFunction *function)
-{
-}
-
-CsrResult __attribute__((weak)) CsrSdioHardReset(CsrSdioFunction *function)
-{
-    return CSR_SDIO_RESULT_NOT_RESET;
-}
-
-CsrResult __attribute__((weak)) CsrSdioBlockSizeSet(CsrSdioFunction *function,
-                                                   u16 blockSize)
-{
-    return CSR_RESULT_SUCCESS;
-}
-
-CsrResult __attribute__((weak)) CsrSdioSuspend(CsrSdioFunction *function)
-{
-    return CSR_RESULT_SUCCESS;
-}
-
-CsrResult __attribute__((weak)) CsrSdioResume(CsrSdioFunction *function)
-{
-    return CSR_RESULT_SUCCESS;
-}
-
-int __attribute__((weak)) csr_sdio_linux_install_irq(CsrSdioFunction *function)
-{
-    return 0;
-}
-
-int __attribute__((weak)) csr_sdio_linux_remove_irq(CsrSdioFunction *function)
-{
-    return 0;
-}
-
-void __attribute__((weak)) CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result)
-{
-}
-
-void __attribute__((weak)) CsrSdioRemovedAcknowledge(CsrSdioFunction *function)
-{
-}
-
-void __attribute__((weak)) CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result)
-{
-}
-
-void __attribute__((weak)) CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result)
-{
-}
-
-
diff --git a/drivers/staging/csr/sme_blocking.c b/drivers/staging/csr/sme_blocking.c
deleted file mode 100644 (file)
index 0c6e216..0000000
+++ /dev/null
@@ -1,1466 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     sme_mgt_blocking.c
- *
- * PURPOSE:
- *      This file contains the driver specific implementation of
- *      the WEXT <==> SME MGT interface for all SME builds that support WEXT.
- *
- * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-#include "unifi_priv.h"
-
-
-/*
- * This file also contains the implementation of the asynchronous
- * requests to the SME.
- *
- * Before calling an asynchronous SME function, we call sme_init_request()
- * which gets hold of the SME semaphore and updates the request status.
- * The semaphore makes sure that there is only one pending request to
- * the SME at a time.
- *
- * Now we are ready to call the SME function, but only if
- * sme_init_request() has returned 0.
- *
- * When the SME function returns, we need to wait
- * for the reply. This is done in sme_wait_for_reply().
- * If the request times-out, the request status is set to SME_REQUEST_TIMEDOUT
- * and the sme_wait_for_reply() returns.
- *
- * If the SME replies in time, we call sme_complete_request().
- * There we change the request status to SME_REQUEST_RECEIVED. This will
- * wake up the process waiting on sme_wait_for_reply().
- * It is important that we copy the reply data in priv->sme_reply
- * before calling sme_complete_request().
- *
- * Handling the wext requests, we need to block
- * until the SME sends the response to our request.
- * We use the sme_init_request() and sme_wait_for_reply()
- * to implement this behavior in the following functions:
- * sme_mgt_wifi_on()
- * sme_mgt_wifi_off()
- * sme_mgt_scan_full()
- * sme_mgt_scan_results_get_async()
- * sme_mgt_connect()
- * unifi_mgt_media_status_ind()
- * sme_mgt_disconnect()
- * sme_mgt_pmkid()
- * sme_mgt_key()
- * sme_mgt_mib_get()
- * sme_mgt_mib_set()
- * sme_mgt_versions_get()
- * sme_mgt_set_value()
- * sme_mgt_get_value()
- * sme_mgt_set_value_async()
- * sme_mgt_get_value_async()
- * sme_mgt_packet_filter_set()
- * sme_mgt_tspec()
- */
-
-
-/*
- * Handling the suspend and resume system events, we need to block
- * until the SME sends the response to our indication.
- * We use the sme_init_request() and sme_wait_for_reply()
- * to implement this behavior in the following functions:
- * sme_sys_suspend()
- * sme_sys_resume()
- */
-
-#define UNIFI_SME_MGT_SHORT_TIMEOUT    10000
-#define UNIFI_SME_MGT_LONG_TIMEOUT     19000
-#define UNIFI_SME_SYS_LONG_TIMEOUT     10000
-
-#ifdef UNIFI_DEBUG
-# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, __func__)
-#else
-# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, NULL)
-#endif
-
-static int
-sme_init_request(unifi_priv_t *priv)
-{
-    if (priv == NULL) {
-        unifi_error(priv, "sme_init_request: Invalid priv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG5, "sme_init_request: wait sem\n");
-
-    /* Grab the SME semaphore until the reply comes, or timeout */
-    if (down_interruptible(&priv->sme_sem)) {
-        unifi_error(priv, "sme_init_request: Failed to get SME semaphore\n");
-        return -EIO;
-    }
-    unifi_trace(priv, UDBG5, "sme_init_request: got sem: pending\n");
-
-    priv->sme_reply.request_status = SME_REQUEST_PENDING;
-
-    return 0;
-
-} /* sme_init_request() */
-
-
-void
-uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func)
-{
-    if (priv == NULL) {
-        unifi_error(priv, "sme_complete_request: Invalid priv\n");
-        return;
-    }
-
-    if (priv->sme_reply.request_status != SME_REQUEST_PENDING) {
-        unifi_notice(priv,
-                    "sme_complete_request: request not pending %s (s:%d)\n",
-                    (func ? func : ""), priv->sme_reply.request_status);
-        return;
-    }
-    unifi_trace(priv, UDBG5,
-                "sme_complete_request: completed %s (s:%d)\n",
-                (func ? func : ""), priv->sme_reply.request_status);
-
-    priv->sme_reply.request_status = SME_REQUEST_RECEIVED;
-    priv->sme_reply.reply_status = reply_status;
-
-    wake_up_interruptible(&priv->sme_request_wq);
-
-    return;
-}
-
-
-void
-uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status)
-{
-    /* Check for a blocking SME request in progress, and cancel the wait.
-     * This should be used when the character device is closed.
-     */
-
-    if (priv == NULL) {
-        unifi_error(priv, "sme_cancel_request: Invalid priv\n");
-        return;
-    }
-
-    /* If no request is pending, nothing to wake up */
-    if (priv->sme_reply.request_status != SME_REQUEST_PENDING) {
-        unifi_trace(priv, UDBG5,
-                    "sme_cancel_request: no request was pending (s:%d)\n",
-                    priv->sme_reply.request_status);
-        /* Nothing to do */
-        return;
-    }
-    unifi_trace(priv, UDBG5,
-                "sme_cancel_request: request cancelled (s:%d)\n",
-                priv->sme_reply.request_status);
-
-    /* Wake up the wait with an error status */
-    priv->sme_reply.request_status = SME_REQUEST_CANCELLED;
-    priv->sme_reply.reply_status = reply_status; /* unimportant since the CANCELLED state will fail the ioctl */
-
-    wake_up_interruptible(&priv->sme_request_wq);
-
-    return;
-}
-
-
-static int
-_sme_wait_for_reply(unifi_priv_t *priv,
-        unsigned long timeout, const char *func)
-{
-    long r;
-
-    unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s sleep\n", func ? func : "");
-    r = wait_event_interruptible_timeout(priv->sme_request_wq,
-                                         (priv->sme_reply.request_status != SME_REQUEST_PENDING),
-                                         msecs_to_jiffies(timeout));
-    unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s awake (%d)\n", func ? func : "", r);
-
-    if (r == -ERESTARTSYS) {
-        /* The thread was killed */
-        unifi_info(priv, "ERESTARTSYS in _sme_wait_for_reply\n");
-        up(&priv->sme_sem);
-        return r;
-    }
-    if (priv->sme_reply.request_status == SME_REQUEST_CANCELLED) {
-        unifi_trace(priv, UDBG5, "Cancelled waiting for SME to reply (%s s:%d, t:%d, r:%d)\n",
-                    (func ? func : ""), priv->sme_reply.request_status, timeout, r);
-
-        /* Release the SME semaphore that was downed in sme_init_request() */
-        up(&priv->sme_sem);
-        return -EIO; /* fail the ioctl */
-    }
-    if ((r == 0) && (priv->sme_reply.request_status != SME_REQUEST_RECEIVED)) {
-        unifi_notice(priv, "Timeout waiting for SME to reply (%s s:%d, t:%d)\n",
-                     (func ? func : ""), priv->sme_reply.request_status, timeout);
-
-        priv->sme_reply.request_status = SME_REQUEST_TIMEDOUT;
-
-        /* Release the SME semaphore that was downed in sme_init_request() */
-        up(&priv->sme_sem);
-
-        return -ETIMEDOUT;
-    }
-
-    unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s received (%d)\n",
-                func ? func : "", r);
-
-    /* Release the SME semaphore that was downed in sme_init_request() */
-    up(&priv->sme_sem);
-
-    return 0;
-} /* sme_wait_for_reply() */
-
-
-
-
-#ifdef CSR_SUPPORT_WEXT
-int sme_mgt_wifi_on(unifi_priv_t *priv)
-{
-    u16 numElements;
-    CsrWifiSmeDataBlock* dataList;
-#ifdef CSR_SUPPORT_WEXT_AP
-    int r;
-#endif
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_wifi_on: invalid smepriv\n");
-        return -EIO;
-    }
-
-    if (priv->mib_data.length) {
-        numElements = 1;
-        dataList = &priv->mib_data;
-    } else {
-        numElements = 0;
-        dataList = NULL;
-    }
-    /* Start the SME */
-#ifdef CSR_SUPPORT_WEXT_AP
-    r = sme_init_request(priv);
-    if (r) {
-        return -EIO;
-    }
-#endif
-    CsrWifiSmeWifiOnReqSend(0, priv->sta_mac_address, numElements, dataList);
-#ifdef CSR_SUPPORT_WEXT_AP
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_wifi_on: unifi_mgt_wifi_oo_req <-- (r=%d, status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    return 0;
-#endif
-} /* sme_mgt_wifi_on() */
-
-
-int sme_mgt_wifi_off(unifi_priv_t *priv)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_wifi_off: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    /* Stop the SME */
-    CsrWifiSmeWifiOffReqSend(0);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_wifi_off: unifi_mgt_wifi_off_req <-- (r=%d, status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-
-} /* sme_mgt_wifi_off */
-
-int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
-        CsrWifiSmeListAction action)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_key: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeKeyReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action, *sme_key);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-int sme_mgt_scan_full(unifi_priv_t *priv,
-        CsrWifiSsid *specific_ssid,
-        int num_channels,
-        unsigned char *channel_list)
-{
-    CsrWifiMacAddress bcastAddress = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
-    u8 is_active = (num_channels > 0) ? TRUE : FALSE;
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_scan_full: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_scan_full: -->\n");
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    /* If a channel list is provided, do an active scan */
-    if (is_active) {
-        unifi_trace(priv, UDBG1,
-                    "channel list - num_channels: %d, active scan\n",
-                    num_channels);
-    }
-
-    CsrWifiSmeScanFullReqSend(0,
-                              specific_ssid->length?1:0, /* 0 or 1 SSIDS */
-                              specific_ssid,
-                              bcastAddress,
-                              is_active,
-                              CSR_WIFI_SME_BSS_TYPE_ANY_BSS,
-                              CSR_WIFI_SME_SCAN_TYPE_ALL,
-                              (u16)num_channels, channel_list,
-                              0, NULL);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4, "sme_mgt_scan_full: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    if (priv->sme_reply.reply_status == CSR_WIFI_RESULT_UNAVAILABLE)
-        return 0; /* initial scan already underway */
-    else
-        return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
-        struct iw_request_info *info,
-        char *scan_results,
-        long scan_results_len)
-{
-    u16 scan_result_list_count;
-    CsrWifiSmeScanResult *scan_result_list;
-    CsrWifiSmeScanResult *scan_result;
-    int r;
-    int i;
-    char *current_ev = scan_results;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_scan_results_get_async: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeScanResultsGetReqSend(0);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
-    if (r)
-        return r;
-
-    scan_result_list_count = priv->sme_reply.reply_scan_results_count;
-    scan_result_list = priv->sme_reply.reply_scan_results;
-    unifi_trace(priv, UDBG2,
-                "scan_results: Scan returned %d, numElements=%d\n",
-                r, scan_result_list_count);
-
-    /* OK, now we have the scan results */
-    for (i = 0; i < scan_result_list_count; ++i) {
-        scan_result = &scan_result_list[i];
-
-        unifi_trace(priv, UDBG2, "Scan Result: %.*s\n",
-                    scan_result->ssid.length,
-                    scan_result->ssid.ssid);
-
-        r = unifi_translate_scan(priv->netdev[0], info,
-                                 current_ev,
-                                 scan_results + scan_results_len,
-                                 scan_result, i+1);
-
-        if (r < 0) {
-            kfree(scan_result_list);
-            priv->sme_reply.reply_scan_results_count = 0;
-            priv->sme_reply.reply_scan_results = NULL;
-            return r;
-        }
-
-        current_ev += r;
-    }
-
-    /*
-     * Free the scan results allocated in unifi_mgt_scan_results_get_cfm()
-     * and invalidate the reply_scan_results to avoid re-using
-     * the freed pointers.
-     */
-    kfree(scan_result_list);
-    priv->sme_reply.reply_scan_results_count = 0;
-    priv->sme_reply.reply_scan_results = NULL;
-
-    unifi_trace(priv, UDBG2,
-                "scan_results: Scan translated to %d bytes\n",
-                current_ev - scan_results);
-    return (current_ev - scan_results);
-}
-
-
-int sme_mgt_connect(unifi_priv_t *priv)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_connect: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG2, "sme_mgt_connect: %.*s\n",
-                priv->connection_config.ssid.length,
-                priv->connection_config.ssid.ssid);
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeConnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE, priv->connection_config);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    if (priv->sme_reply.reply_status)
-        unifi_trace(priv, UDBG1, "sme_mgt_connect: failed with SME status %d\n",
-                    priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-int sme_mgt_disconnect(unifi_priv_t *priv)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_disconnect: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeDisconnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4, "sme_mgt_disconnect: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-int sme_mgt_pmkid(unifi_priv_t *priv,
-        CsrWifiSmeListAction action,
-        CsrWifiSmePmkidList *pmkid_list)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_pmkid: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmePmkidReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action,
-                        pmkid_list->pmkidsCount, pmkid_list->pmkids);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4, "sme_mgt_pmkid: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-int sme_mgt_mib_get(unifi_priv_t *priv,
-        unsigned char *varbind, int *length)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    priv->mib_cfm_buffer = varbind;
-    priv->mib_cfm_buffer_length = MAX_VARBIND_LENGTH;
-
-    CsrWifiSmeMibGetReqSend(0, *length, varbind);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r) {
-        priv->mib_cfm_buffer_length = 0;
-        priv->mib_cfm_buffer = NULL;
-        return r;
-    }
-
-    *length = priv->mib_cfm_buffer_length;
-
-    priv->mib_cfm_buffer_length = 0;
-    priv->mib_cfm_buffer = NULL;
-    unifi_trace(priv, UDBG4, "sme_mgt_mib_get: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-int sme_mgt_mib_set(unifi_priv_t *priv,
-        unsigned char *varbind, int length)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeMibSetReqSend(0, length, varbind);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4, "sme_mgt_mib_set: <-- (status=%d)\n", priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-#endif /* CSR_SUPPORT_WEXT */
-
-int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_set_value_async: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmePowerConfigSetReqSend(0, *powerConfig);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_set_value_async: unifi_mgt_set_value_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_set_value: invalid smepriv\n");
-        return -EIO;
-    }
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtPowerConfigSetReq(priv->smepriv, *powerConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeSmeStaConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *staConfig);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_sme_config_set: CsrWifiSmeSmeStaConfigSetReq <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeSmeCommonConfigSetReqSend(0, *deviceConfig);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_sme_config_set: CsrWifiSmeSmeCommonConfigSetReq <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtSmeConfigSetReq(priv->smepriv, *staConfig);
-    status = CsrWifiSmeMgtDeviceConfigSetReq(priv->smepriv, *deviceConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-#ifdef CSR_SUPPORT_WEXT
-
-int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeMibConfigSetReqSend(0, *mibConfig);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_mib_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtMibConfigSetReq(priv->smepriv, *mibConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeCoexConfigSetReqSend(0, *coexConfig);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_coex_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtCoexConfigSetReq(priv->smepriv, *coexConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-#endif /* CSR_SUPPORT_WEXT */
-
-int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeHostConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *hostConfig);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_host_config_set: unifi_mgt_set_host_config_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n");
-        return -EIO;
-    }
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtHostConfigSetReq(priv->smepriv, *hostConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-#ifdef CSR_SUPPORT_WEXT
-
-int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_versions_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_versions_get: unifi_mgt_versions_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeVersionsGetReqSend(0);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (versions != NULL) {
-        memcpy((unsigned char*)versions,
-               (unsigned char*)&priv->sme_reply.versions,
-               sizeof(CsrWifiSmeVersions));
-    }
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_versions_get: unifi_mgt_versions_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtVersionsGetReq(priv->smepriv, versions);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-#endif /* CSR_SUPPORT_WEXT */
-
-int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_power_config_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_power_config_get: unifi_mgt_power_config_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmePowerConfigGetReqSend(0);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (powerConfig != NULL) {
-        memcpy((unsigned char*)powerConfig,
-               (unsigned char*)&priv->sme_reply.powerConfig,
-               sizeof(CsrWifiSmePowerConfig));
-    }
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_get_versions: unifi_mgt_power_config_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtPowerConfigGetReq(priv->smepriv, powerConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_host_config_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_host_config_get: unifi_mgt_host_config_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeHostConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (hostConfig != NULL)
-        memcpy((unsigned char*)hostConfig,
-               (unsigned char*)&priv->sme_reply.hostConfig,
-               sizeof(CsrWifiSmeHostConfig));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_host_config_get: unifi_mgt_host_config_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtHostConfigGetReq(priv->smepriv, hostConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_sme_config_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req -->\n");
-
-    /* Common device config */
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeSmeCommonConfigGetReqSend(0);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (deviceConfig != NULL)
-        memcpy((unsigned char*)deviceConfig,
-               (unsigned char*)&priv->sme_reply.deviceConfig,
-               sizeof(CsrWifiSmeDeviceConfig));
-
-    /* STA config */
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeSmeStaConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (staConfig != NULL)
-        memcpy((unsigned char*)staConfig,
-               (unsigned char*)&priv->sme_reply.staConfig,
-               sizeof(CsrWifiSmeStaConfig));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtSmeConfigGetReq(priv->smepriv, staConfig);
-    status = CsrWifiSmeMgtDeviceConfigGetReq(priv->smepriv, deviceConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_coex_info_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeCoexInfoGetReqSend(0);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (coexInfo != NULL)
-        memcpy((unsigned char*)coexInfo,
-               (unsigned char*)&priv->sme_reply.coexInfo,
-               sizeof(CsrWifiSmeCoexInfo));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtCoexInfoGetReq(priv->smepriv, coexInfo);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-#ifdef CSR_SUPPORT_WEXT
-
-int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_coex_config_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeCoexConfigGetReqSend(0);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (coexConfig != NULL)
-        memcpy((unsigned char*)coexConfig,
-               (unsigned char*)&priv->sme_reply.coexConfig,
-               sizeof(CsrWifiSmeCoexConfig));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtCoexConfigGetReq(priv->smepriv, coexConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_mib_config_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeMibConfigGetReqSend(0);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (mibConfig != NULL)
-        memcpy((unsigned char*)mibConfig,
-               (unsigned char*)&priv->sme_reply.mibConfig,
-               sizeof(CsrWifiSmeMibConfig));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtMibConfigGetReq(priv->smepriv, mibConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_connection_info_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeConnectionInfoGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (connectionInfo != NULL)
-        memcpy((unsigned char*)connectionInfo,
-               (unsigned char*)&priv->sme_reply.connectionInfo,
-               sizeof(CsrWifiSmeConnectionInfo));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtConnectionInfoGetReq(priv->smepriv, connectionInfo);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_connection_config_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeConnectionConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (connectionConfig != NULL)
-        memcpy((unsigned char*)connectionConfig,
-               (unsigned char*)&priv->sme_reply.connectionConfig,
-               sizeof(CsrWifiSmeConnectionConfig));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtConnectionConfigGetReq(priv->smepriv, connectionConfig);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats)
-{
-#ifdef CSR_SME_USERSPACE
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_mgt_connection_stats_get: invalid smepriv\n");
-        return -EIO;
-    }
-
-    unifi_trace(priv, UDBG4, "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req -->\n");
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiSmeConnectionStatsGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    /* store the reply */
-    if (connectionStats != NULL)
-        memcpy((unsigned char*)connectionStats,
-               (unsigned char*)&priv->sme_reply.connectionStats,
-               sizeof(CsrWifiSmeConnectionStats));
-
-    unifi_trace(priv, UDBG4,
-                "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-
-    return convert_sme_error(priv->sme_reply.reply_status);
-#else
-    CsrResult status;
-    CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
-    status = CsrWifiSmeMgtConnectionStatsGetReq(priv->smepriv, connectionStats);
-    CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
-    return convert_sme_error(status);
-#endif
-}
-
-#endif /* CSR_SUPPORT_WEXT */
-
-int sme_mgt_packet_filter_set(unifi_priv_t *priv)
-{
-       CsrWifiIp4Address ipAddress = {{0xFF, 0xFF, 0xFF, 0xFF }};
-       if (priv->smepriv == NULL) {
-               unifi_error(priv, "sme_mgt_packet_filter_set: invalid smepriv\n");
-               return -EIO;
-       }
-       if (priv->packet_filters.arp_filter) {
-               ipAddress.a[0] = (priv->sta_ip_address      ) & 0xFF;
-               ipAddress.a[1] = (priv->sta_ip_address >>  8) & 0xFF;
-               ipAddress.a[2] = (priv->sta_ip_address >> 16) & 0xFF;
-               ipAddress.a[3] = (priv->sta_ip_address >> 24) & 0xFF;
-       }
-
-       unifi_trace(priv, UDBG5,
-               "sme_mgt_packet_filter_set: IP address %d.%d.%d.%d\n",
-               ipAddress.a[0], ipAddress.a[1],
-               ipAddress.a[2], ipAddress.a[3]);
-
-       /* Doesn't block for a confirm */
-       CsrWifiSmePacketFilterSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
-                                    priv->packet_filters.tclas_ies_length,
-                                    priv->filter_tclas_ies,
-                                    priv->packet_filters.filter_mode,
-                                    ipAddress);
-       return 0;
-}
-
-int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
-        u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas)
-{
-       int r;
-
-       if (priv->smepriv == NULL) {
-               unifi_error(priv, "sme_mgt_tspec: invalid smepriv\n");
-               return -EIO;
-       }
-
-       r = sme_init_request(priv);
-       if (r)
-               return -EIO;
-
-       CsrWifiSmeTspecReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
-                             action, tid, TRUE, 0,
-                             tspec->length, tspec->data,
-                             tclas->length, tclas->data);
-       r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-       if (r)
-               return r;
-
-       unifi_trace(priv, UDBG4, "sme_mgt_tspec: <-- (status=%d)\n", priv->sme_reply.reply_status);
-       return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-
-int sme_sys_suspend(unifi_priv_t *priv)
-{
-    int r;
-    CsrResult csrResult;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_sys_suspend: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    /* Suspend the SME, which MAY cause it to power down UniFi */
-    CsrWifiRouterCtrlSuspendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, 0, priv->wol_suspend);
-    r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
-    if (r) {
-        /* No reply - forcibly power down in case the request wasn't processed */
-        unifi_notice(priv,
-                     "suspend: SME did not reply %s, ",
-                     (priv->ptest_mode | priv->wol_suspend) ? "leave powered" : "power off UniFi anyway\n");
-
-        /* Leave power on for production test, though */
-        if (!priv->ptest_mode) {
-            /* Put UniFi to deep sleep, in case we can not power it off */
-            CsrSdioClaim(priv->sdio);
-            unifi_trace(priv, UDBG1, "Force deep sleep");
-            csrResult = unifi_force_low_power_mode(priv->card);
-
-            /* For WOL, the UniFi must stay powered */
-            if (!priv->wol_suspend) {
-                unifi_trace(priv, UDBG1, "Power off\n");
-                CsrSdioPowerOff(priv->sdio);
-            }
-            CsrSdioRelease(priv->sdio);
-        }
-    }
-
-    if (priv->wol_suspend) {
-        unifi_trace(priv, UDBG1, "UniFi left powered for WOL\n");
-
-        /* Remove the IRQ, which also disables the card SDIO interrupt.
-         * Disabling the card SDIO interrupt enables the PIO WOL source.
-         * Removal of the of the handler ensures that in both SDIO and PIO cases
-         * the card interrupt only wakes the host. The card will be polled
-         * after resume to handle any pending data.
-         */
-        if (csr_sdio_linux_remove_irq(priv->sdio)) {
-            unifi_notice(priv, "WOL csr_sdio_linux_remove_irq failed\n");
-        }
-
-        if (enable_wol == UNIFI_WOL_SDIO) {
-            /* Because csr_sdio_linux_remove_irq() disabled the card SDIO interrupt,
-             * it must be left enabled to wake-on-SDIO.
-             */
-            unifi_trace(priv, UDBG1, "Enable card SDIO interrupt for SDIO WOL\n");
-
-            CsrSdioClaim(priv->sdio);
-            csrResult = CsrSdioInterruptEnable(priv->sdio);
-            CsrSdioRelease(priv->sdio);
-
-            if (csrResult != CSR_RESULT_SUCCESS) {
-                unifi_error(priv, "WOL CsrSdioInterruptEnable failed %d\n", csrResult);
-            }
-        } else {
-            unifi_trace(priv, UDBG1, "Disabled card SDIO interrupt for PIO WOL\n");
-        }
-
-        /* Prevent the BH thread from running during the suspend.
-         * Upon resume, sme_sys_resume() will trigger a wifi-on, this will cause
-         * the BH thread to be re-enabled and reinstall the ISR.
-         */
-        priv->bh_thread.block_thread = 1;
-
-        unifi_trace(priv, UDBG1, "unifi_suspend: suspended BH");
-    }
-
-    /* Consider UniFi to be uninitialised */
-    priv->init_progress = UNIFI_INIT_NONE;
-
-    unifi_trace(priv, UDBG1, "sme_sys_suspend: <-- (r=%d status=%d)\n", r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-
-int sme_sys_resume(unifi_priv_t *priv)
-{
-    int r;
-
-    unifi_trace(priv, UDBG1, "sme_sys_resume %s\n", priv->wol_suspend ? "warm" : "");
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_sys_resume: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiRouterCtrlResumeIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, priv->wol_suspend);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
-    if (r)
-        unifi_notice(priv,
-                "resume: SME did not reply, return success anyway\n");
-
-    return 0;
-}
-
-#ifdef CSR_SUPPORT_WEXT_AP
-int sme_ap_stop(unifi_priv_t *priv, u16 interface_tag)
-{
-    int r;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_ap_stop: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiNmeApStopReqSend(0, interface_tag);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_ap_stop <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-
-}
-
-int sme_ap_start(unifi_priv_t *priv, u16 interface_tag,
-                 CsrWifiSmeApConfig_t * ap_config)
-{
-    int r;
-    CsrWifiSmeApP2pGoConfig p2p_go_param;
-    memset(&p2p_go_param, 0, sizeof(CsrWifiSmeApP2pGoConfig));
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_ap_start: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiNmeApStartReqSend(0, interface_tag, CSR_WIFI_AP_TYPE_LEGACY, FALSE,
-                             ap_config->ssid, 1, ap_config->channel,
-                             ap_config->credentials, ap_config->max_connections,
-                             p2p_go_param, FALSE);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-    if (r)
-        return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_ap_start <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-
-int sme_ap_config(unifi_priv_t *priv,
-                  CsrWifiSmeApMacConfig *ap_mac_config,
-                  CsrWifiNmeApConfig *group_security_config)
-{
-    int r;
-    CsrWifiSmeApP2pGoConfig p2p_go_param;
-    memset(&p2p_go_param, 0, sizeof(CsrWifiSmeApP2pGoConfig));
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_ap_config: invalid smepriv\n");
-        return -EIO;
-    }
-
-    r = sme_init_request(priv);
-    if (r)
-        return -EIO;
-
-    CsrWifiNmeApConfigSetReqSend(0, *group_security_config,
-                                 *ap_mac_config);
-
-    r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
-       if (r)
-               return r;
-
-    unifi_trace(priv, UDBG4,
-                "sme_ap_config <-- (r=%d status=%d)\n",
-                r, priv->sme_reply.reply_status);
-    return convert_sme_error(priv->sme_reply.reply_status);
-}
-#endif
diff --git a/drivers/staging/csr/sme_mgt.c b/drivers/staging/csr/sme_mgt.c
deleted file mode 100644 (file)
index 58d1b3b..0000000
+++ /dev/null
@@ -1,1012 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     sme_mgt.c
- *
- * PURPOSE:
- *      This file contains the driver specific implementation of
- *      the SME MGT SAP.
- *      It is part of the porting exercise.
- *
- * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-#include "csr_wifi_hip_unifiversion.h"
-#include "unifi_priv.h"
-#include "csr_wifi_hip_conversions.h"
-/*
- * This file implements the SME MGT API. It contains the following functions:
- * CsrWifiSmeWifiFlightmodeCfmSend()
- * CsrWifiSmeWifiOnCfmSend()
- * CsrWifiSmeWifiOffCfmSend()
- * CsrWifiSmeWifiOffIndSend()
- * CsrWifiSmeScanFullCfmSend()
- * CsrWifiSmeScanResultsGetCfmSend()
- * CsrWifiSmeScanResultIndSend()
- * CsrWifiSmeScanResultsFlushCfmSend()
- * CsrWifiSmeConnectCfmSend()
- * CsrWifiSmeMediaStatusIndSend()
- * CsrWifiSmeDisconnectCfmSend()
- * CsrWifiSmeKeyCfmSend()
- * CsrWifiSmeMulticastAddressCfmSend()
- * CsrWifiSmeSetValueCfmSend()
- * CsrWifiSmeGetValueCfmSend()
- * CsrWifiSmeMicFailureIndSend()
- * CsrWifiSmePmkidCfmSend()
- * CsrWifiSmePmkidCandidateListIndSend()
- * CsrWifiSmeMibSetCfmSend()
- * CsrWifiSmeMibGetCfmSend()
- * CsrWifiSmeMibGetNextCfmSend()
- * CsrWifiSmeConnectionQualityIndSend()
- * CsrWifiSmePacketFilterSetCfmSend()
- * CsrWifiSmeTspecCfmSend()
- * CsrWifiSmeTspecIndSend()
- * CsrWifiSmeBlacklistCfmSend()
- * CsrWifiSmeEventMaskSetCfmSend()
- * CsrWifiSmeRoamStartIndSend()
- * CsrWifiSmeRoamCompleteIndSend()
- * CsrWifiSmeAssociationStartIndSend()
- * CsrWifiSmeAssociationCompleteIndSend()
- * CsrWifiSmeIbssStationIndSend()
- */
-
-
-void CsrWifiSmeMicFailureIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMicFailureInd* ind = (CsrWifiSmeMicFailureInd*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeMicFailureIndSend: invalid priv\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG1,
-                "CsrWifiSmeMicFailureIndSend: count=%d, KeyType=%d\n",
-                ind->count, ind->keyType);
-
-    wext_send_michaelmicfailure_event(priv, ind->count, ind->address, ind->keyType, ind->interfaceTag);
-#endif
-}
-
-
-void CsrWifiSmePmkidCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmePmkidCfm* cfm = (CsrWifiSmePmkidCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmePmkidCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    /*
-     * WEXT never does a GET operation the PMKIDs, so we don't need
-     * handle data returned in pmkids.
-     */
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmePmkidCandidateListIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmePmkidCandidateListInd* ind = (CsrWifiSmePmkidCandidateListInd*)msg;
-    int i;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiSmePmkidCandidateListIndSend: invalid smepriv\n");
-        return;
-    }
-
-    for (i = 0; i < ind->pmkidCandidatesCount; i++)
-    {
-        wext_send_pmkid_candidate_event(priv, ind->pmkidCandidates[i].bssid, ind->pmkidCandidates[i].preAuthAllowed, ind->interfaceTag);
-    }
-#endif
-}
-
-void CsrWifiSmeScanResultsFlushCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeScanResultsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeScanResultsGetCfm* cfm = (CsrWifiSmeScanResultsGetCfm*)msg;
-    int bytesRequired = cfm->scanResultsCount * sizeof(CsrWifiSmeScanResult);
-    int i;
-    u8* current_buff;
-    CsrWifiSmeScanResult* scanCopy;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeScanResultsGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    /* Calc the size of the buffer reuired */
-    for (i = 0; i < cfm->scanResultsCount; ++i) {
-        const CsrWifiSmeScanResult *scan_result = &cfm->scanResults[i];
-        bytesRequired += scan_result->informationElementsLength;
-    }
-
-    /* Take a Copy of the scan Results :-) */
-    scanCopy = kmalloc(bytesRequired, GFP_KERNEL);
-    memcpy(scanCopy, cfm->scanResults, sizeof(CsrWifiSmeScanResult) * cfm->scanResultsCount);
-
-    /* Take a Copy of the Info Elements AND update the scan result pointers */
-    current_buff = (u8*)&scanCopy[cfm->scanResultsCount];
-    for (i = 0; i < cfm->scanResultsCount; ++i)
-    {
-        CsrWifiSmeScanResult *scan_result = &scanCopy[i];
-        memcpy(current_buff, scan_result->informationElements, scan_result->informationElementsLength);
-        scan_result->informationElements = current_buff;
-        current_buff += scan_result->informationElementsLength;
-    }
-
-    priv->sme_reply.reply_scan_results_count = cfm->scanResultsCount;
-    priv->sme_reply.reply_scan_results = scanCopy;
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeScanFullCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeScanFullCfm* cfm = (CsrWifiSmeScanFullCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeScanFullCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeScanResultIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-
-}
-
-
-void CsrWifiSmeConnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeConnectCfm* cfm = (CsrWifiSmeConnectCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeConnectCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeDisconnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeDisconnectCfm* cfm = (CsrWifiSmeDisconnectCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeDisconnectCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeKeyCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeKeyCfm* cfm = (CsrWifiSmeKeyCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeKeyCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeMulticastAddressCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMulticastAddressCfm* cfm = (CsrWifiSmeMulticastAddressCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeMulticastAddressCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeWifiFlightmodeCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeWifiFlightmodeCfm* cfm = (CsrWifiSmeWifiFlightmodeCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeWifiFlightmodeCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeWifiOnCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeWifiOnCfm* cfm = (CsrWifiSmeWifiOnCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeWifiOnCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG4,
-                "CsrWifiSmeWifiOnCfmSend: wake up status %d\n", cfm->status);
-#ifdef CSR_SUPPORT_WEXT_AP
-    sme_complete_request(priv, cfm->status);
-#endif
-
-#endif
-}
-
-void CsrWifiSmeWifiOffCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeWifiOffCfm* cfm = (CsrWifiSmeWifiOffCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeWifiOffCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeWifiOffIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeWifiOffInd* ind = (CsrWifiSmeWifiOffInd*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiRouterCtrlStoppedReqSend: Invalid ospriv.\n");
-        return;
-    }
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlStoppedReqSend: invalid smepriv\n");
-        return;
-    }
-
-    /*
-     * If the status indicates an error, the SME is in a stopped state.
-     * We need to start it again in order to reinitialise UniFi.
-     */
-    switch (ind->reason) {
-        case CSR_WIFI_SME_CONTROL_INDICATION_ERROR:
-          unifi_trace(priv, UDBG1,
-                      "CsrWifiRouterCtrlStoppedReqSend: Restarting SME (ind:%d)\n",
-                      ind->reason);
-
-          /* On error, restart the SME */
-          sme_mgt_wifi_on(priv);
-          break;
-        case CSR_WIFI_SME_CONTROL_INDICATION_EXIT:
-#ifdef CSR_SUPPORT_WEXT_AP
-          sme_complete_request(priv, 0);
-#endif
-          break;
-        default:
-          break;
-    }
-
-#endif
-}
-
-void CsrWifiSmeVersionsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeVersionsGetCfm* cfm = (CsrWifiSmeVersionsGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeVersionsGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.versions = cfm->versions;
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmePowerConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmePowerConfigGetCfm* cfm = (CsrWifiSmePowerConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmePowerConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.powerConfig = cfm->powerConfig;
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeHostConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeHostConfigGetCfm* cfm = (CsrWifiSmeHostConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeHostConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.hostConfig = cfm->hostConfig;
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeCoexInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeCoexInfoGetCfm* cfm = (CsrWifiSmeCoexInfoGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeCoexInfoGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.coexInfo = cfm->coexInfo;
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeCoexConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeCoexConfigGetCfm* cfm = (CsrWifiSmeCoexConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeCoexConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.coexConfig = cfm->coexConfig;
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeMibConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMibConfigGetCfm* cfm = (CsrWifiSmeMibConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeMibConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.mibConfig = cfm->mibConfig;
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeConnectionInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeConnectionInfoGetCfm* cfm = (CsrWifiSmeConnectionInfoGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeConnectionInfoGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.connectionInfo = cfm->connectionInfo;
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeConnectionConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeConnectionConfigGetCfm* cfm = (CsrWifiSmeConnectionConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeConnectionConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.connectionConfig = cfm->connectionConfig;
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeConnectionStatsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeConnectionStatsGetCfm* cfm = (CsrWifiSmeConnectionStatsGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeConnectionStatsGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.connectionStats = cfm->connectionStats;
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeMibSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMibSetCfm* cfm = (CsrWifiSmeMibSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeMibSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeMibGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMibGetCfm* cfm = (CsrWifiSmeMibGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeMibGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    if (cfm->mibAttribute == NULL) {
-        unifi_error(priv, "CsrWifiSmeMibGetCfmSend: Empty reply.\n");
-        sme_complete_request(priv, cfm->status);
-        return;
-    }
-
-    if ((priv->mib_cfm_buffer != NULL) &&
-        (priv->mib_cfm_buffer_length >= cfm->mibAttributeLength)) {
-        memcpy(priv->mib_cfm_buffer, cfm->mibAttribute, cfm->mibAttributeLength);
-        priv->mib_cfm_buffer_length = cfm->mibAttributeLength;
-    } else {
-        unifi_error(priv,
-                    "CsrWifiSmeMibGetCfmSend: No room to store MIB data (have=%d need=%d).\n",
-                    priv->mib_cfm_buffer_length, cfm->mibAttributeLength);
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeMibGetNextCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMibGetNextCfm* cfm = (CsrWifiSmeMibGetNextCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeMibGetNextCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    /* Need to copy MIB data */
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeConnectionQualityIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeConnectionQualityInd* ind = (CsrWifiSmeConnectionQualityInd*)msg;
-    int signal, noise, snr;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeConnectionQualityIndSend: Invalid ospriv.\n");
-        return;
-    }
-
-    /*
-     * level and noise below are mapped into an unsigned 8 bit number,
-     * ranging from [-192; 63]. The way this is achieved is simply to
-     * add 0x100 onto the number if it is negative,
-     * once clipped to the correct range.
-     */
-    signal = ind->linkQuality.unifiRssi;
-    /* Clip range of snr */
-    snr    = (ind->linkQuality.unifiSnr > 0) ? ind->linkQuality.unifiSnr : 0; /* In dB relative, from 0 - 255 */
-    snr    = (snr < 255) ? snr : 255;
-    noise  = signal - snr;
-
-    /* Clip range of signal */
-    signal = (signal < 63) ? signal : 63;
-    signal = (signal > -192) ? signal : -192;
-
-    /* Clip range of noise */
-    noise = (noise < 63) ? noise : 63;
-    noise = (noise > -192) ? noise : -192;
-
-    /* Make u8 */
-    signal = ( signal < 0 ) ? signal + 0x100 : signal;
-    noise = ( noise < 0 ) ? noise + 0x100 : noise;
-
-    priv->wext_wireless_stats.qual.level   = (u8)signal; /* -192 : 63 */
-    priv->wext_wireless_stats.qual.noise   = (u8)noise;  /* -192 : 63 */
-    priv->wext_wireless_stats.qual.qual    = snr;         /* 0 : 255 */
-    priv->wext_wireless_stats.qual.updated = 0;
-
-#if WIRELESS_EXT > 16
-    priv->wext_wireless_stats.qual.updated |= IW_QUAL_LEVEL_UPDATED |
-                                              IW_QUAL_NOISE_UPDATED |
-                                              IW_QUAL_QUAL_UPDATED;
-#if WIRELESS_EXT > 18
-    priv->wext_wireless_stats.qual.updated |= IW_QUAL_DBM;
-#endif
-#endif
-#endif
-}
-
-void CsrWifiSmePacketFilterSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmePacketFilterSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    /* The packet filter set request does not block for a reply */
-}
-
-void CsrWifiSmeTspecCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeTspecCfm* cfm = (CsrWifiSmeTspecCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeTspecCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeTspecIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeBlacklistCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeEventMaskSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-
-void CsrWifiSmeRoamStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeRoamCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    /* This is called when the association completes, before any 802.1x authentication */
-}
-
-void CsrWifiSmeAssociationStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeAssociationCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeIbssStationIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeWifiOnIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeRestrictedAccessEnableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeRestrictedAccessDisableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-
-void CsrWifiSmeAdhocConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeAdhocConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeAdhocConfigSetCfm* cfm = (CsrWifiSmeAdhocConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeCalibrationDataGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeCalibrationDataSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeCalibrationDataSetCfm* cfm = (CsrWifiSmeCalibrationDataSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeCcxConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeCcxConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeCcxConfigSetCfm* cfm = (CsrWifiSmeCcxConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeCloakedSsidsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeCloakedSsidsSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeCloakedSsidsSetCfm* cfm = (CsrWifiSmeCloakedSsidsSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-
-void CsrWifiSmeCoexConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeCoexConfigSetCfm* cfm = (CsrWifiSmeCoexConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeHostConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeHostConfigSetCfm* cfm = (CsrWifiSmeHostConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeLinkQualityGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-
-void CsrWifiSmeMibConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMibConfigSetCfm* cfm = (CsrWifiSmeMibConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmePermanentMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmePowerConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmePowerConfigSetCfm* cfm = (CsrWifiSmePowerConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeRoamingConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeMediaStatusIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeMediaStatusInd* ind = (CsrWifiSmeMediaStatusInd*)msg;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiSmeMediaStatusIndSend: invalid smepriv\n");
-        return;
-    }
-
-    if (ind->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) {
-        /*
-         * Send wireless-extension event up to userland to announce
-         * connection.
-         */
-        wext_send_assoc_event(priv,
-                              (unsigned char *)ind->connectionInfo.bssid.a,
-                              (unsigned char *)ind->connectionInfo.assocReqInfoElements,
-                              ind->connectionInfo.assocReqInfoElementsLength,
-                              (unsigned char *)ind->connectionInfo.assocRspInfoElements,
-                              ind->connectionInfo.assocRspInfoElementsLength,
-                              (unsigned char *)ind->connectionInfo.assocScanInfoElements,
-                              ind->connectionInfo.assocScanInfoElementsLength);
-
-       unifi_trace(priv, UDBG2, "CsrWifiSmeMediaStatusIndSend: IBSS=%pM\n",
-                                ind->connectionInfo.bssid.a);
-
-        sme_mgt_packet_filter_set(priv);
-
-    } else  {
-        /*
-         * Send wireless-extension event up to userland to announce
-         * connection lost to a BSS.
-         */
-        wext_send_disassoc_event(priv);
-    }
-#endif
-}
-
-void CsrWifiSmeRoamingConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeRoamingConfigSetCfm* cfm = (CsrWifiSmeRoamingConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeRoamingConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeScanConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeScanConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_SUPPORT_WEXT
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeScanConfigSetCfm* cfm = (CsrWifiSmeScanConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-#endif
-}
-
-void CsrWifiSmeStationMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeSmeCommonConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeSmeCommonConfigGetCfm* cfm = (CsrWifiSmeSmeCommonConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.deviceConfig = cfm->deviceConfig;
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeSmeStaConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeSmeStaConfigGetCfm* cfm = (CsrWifiSmeSmeStaConfigGetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    priv->sme_reply.staConfig = cfm->smeConfig;
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeSmeCommonConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeSmeCommonConfigSetCfm* cfm = (CsrWifiSmeSmeCommonConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeSmeStaConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiSmeSmeStaConfigSetCfm* cfm = (CsrWifiSmeSmeStaConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeErrorIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeInfoIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeCoreDumpIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-void CsrWifiSmeAmpStatusChangeIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiSmeActivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-void CsrWifiSmeDeactivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-#ifdef CSR_SUPPORT_WEXT
-#ifdef CSR_SUPPORT_WEXT_AP
-void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiNmeApStartCfm* cfm = (CsrWifiNmeApStartCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiNmeApStartCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiNmeApStopCfm* cfm = (CsrWifiNmeApStopCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiNmeApStopCfmSend: Invalid ospriv.\n");
-        return;
-    }
-
-    sme_complete_request(priv, cfm->status);
-}
-
-void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiNmeApConfigSetCfm* cfm = (CsrWifiNmeApConfigSetCfm*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiNmeApConfigSetCfmSend: Invalid ospriv.\n");
-        return;
-    }
-    sme_complete_request(priv, cfm->status);
-}
-#endif
-#endif
diff --git a/drivers/staging/csr/sme_native.c b/drivers/staging/csr/sme_native.c
deleted file mode 100644 (file)
index d0b9be3..0000000
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
- * ***************************************************************************
- *
- *  FILE:     sme_native.c
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-
-#include <linux/netdevice.h>
-#include "unifi_priv.h"
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-
-static const unsigned char wildcard_address[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-int
-uf_sme_init(unifi_priv_t *priv)
-{
-    sema_init(&priv->mlme_blocking_mutex, 1);
-
-#ifdef CSR_SUPPORT_WEXT
-    {
-        int r = uf_init_wext_interface(priv);
-        if (r != 0) {
-            return r;
-        }
-    }
-#endif
-
-    return 0;
-} /* uf_sme_init() */
-
-
-void
-uf_sme_deinit(unifi_priv_t *priv)
-{
-
-    /* Free memory allocated for the scan table */
-/*    unifi_clear_scan_table(priv); */
-
-    /* Cancel any pending workqueue tasks */
-    flush_workqueue(priv->unifi_workqueue);
-
-#ifdef CSR_SUPPORT_WEXT
-    uf_deinit_wext_interface(priv);
-#endif
-
-} /* uf_sme_deinit() */
-
-
-int sme_mgt_wifi_on(unifi_priv_t *priv)
-{
-    int r, i;
-    s32 csrResult;
-
-    if (priv == NULL) {
-        return -EINVAL;
-    }
-    /* Initialize the interface mode to None */
-    for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
-        priv->interfacePriv[i]->interfaceMode = 0;
-    }
-
-    /* Set up interface mode so that get_packet_priority() can
-     * select the right QOS priority when WMM is enabled.
-     */
-    priv->interfacePriv[0]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_STA;
-
-    r = uf_request_firmware_files(priv, UNIFI_FW_STA);
-    if (r) {
-        unifi_error(priv, "sme_mgt_wifi_on: Failed to get f/w\n");
-        return r;
-    }
-
-    /*
-     * The request to initialise UniFi might come while UniFi is running.
-     * We need to block all I/O activity until the reset completes, otherwise
-     * an SDIO error might occur resulting an indication to the SME which
-     * makes it think that the initialisation has failed.
-     */
-    priv->bh_thread.block_thread = 1;
-
-    /* Power on UniFi */
-    CsrSdioClaim(priv->sdio);
-    csrResult = CsrSdioPowerOn(priv->sdio);
-    CsrSdioRelease(priv->sdio);
-    if(csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) {
-        return -EIO;
-    }
-
-    if (csrResult == CSR_RESULT_SUCCESS) {
-        /* Initialise UniFi hardware */
-        r = uf_init_hw(priv);
-        if (r) {
-            return r;
-        }
-    }
-
-    /* Re-enable the I/O thread */
-    priv->bh_thread.block_thread = 0;
-
-    /* Disable deep sleep signalling during the firmware initialisation, to
-     * prevent the wakeup mechanism raising the SDIO clock beyond INIT before
-     * the first MLME-RESET.ind. It gets re-enabled at the CONNECTED.ind,
-     * immediately after the MLME-RESET.ind
-     */
-    csrResult = unifi_configure_low_power_mode(priv->card,
-                                           UNIFI_LOW_POWER_DISABLED,
-                                           UNIFI_PERIODIC_WAKE_HOST_DISABLED);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_warning(priv,
-                      "sme_mgt_wifi_on: unifi_configure_low_power_mode() returned an error\n");
-    }
-
-
-    /* Start the I/O thread */
-    CsrSdioClaim(priv->sdio);
-    r = uf_init_bh(priv);
-    if (r) {
-        CsrSdioPowerOff(priv->sdio);
-        CsrSdioRelease(priv->sdio);
-        return r;
-    }
-    CsrSdioRelease(priv->sdio);
-
-    priv->init_progress = UNIFI_INIT_FW_DOWNLOADED;
-
-    return 0;
-}
-
-int
-sme_sys_suspend(unifi_priv_t *priv)
-{
-    const int interfaceNum = 0;     /* FIXME */
-    CsrResult csrResult;
-
-    /* Abort any pending requests. */
-    uf_abort_mlme(priv);
-
-    /* Allow our mlme request to go through. */
-    priv->io_aborted = 0;
-
-    /* Send MLME-RESET.req to UniFi. */
-    unifi_reset_state(priv, priv->netdev[interfaceNum]->dev_addr, 0);
-
-    /* Stop the network traffic */
-    netif_carrier_off(priv->netdev[interfaceNum]);
-
-    /* Put UniFi to deep sleep */
-    CsrSdioClaim(priv->sdio);
-    csrResult = unifi_force_low_power_mode(priv->card);
-    CsrSdioRelease(priv->sdio);
-
-    return 0;
-} /* sme_sys_suspend() */
-
-
-int
-sme_sys_resume(unifi_priv_t *priv)
-{
-#ifdef CSR_SUPPORT_WEXT
-    /* Send disconnect event so clients will re-initialise connection. */
-    memset(priv->wext_conf.current_ssid, 0, UNIFI_MAX_SSID_LEN);
-    memset((void*)priv->wext_conf.current_bssid, 0, ETH_ALEN);
-    priv->wext_conf.capability = 0;
-    wext_send_disassoc_event(priv);
-#endif
-    return 0;
-} /* sme_sys_resume() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  sme_native_log_event
- *
- *      Callback function to be registered as the SME event callback.
- *      Copies the signal content into a new udi_log_t struct and adds
- *      it to the read queue for the SME client.
- *
- *  Arguments:
- *      arg             This is the value given to unifi_add_udi_hook, in
- *                      this case a pointer to the client instance.
- *      signal          Pointer to the received signal.
- *      signal_len      Size of the signal structure in bytes.
- *      bulkdata        Pointers to any associated bulk data.
- *      dir             Direction of the signal. Zero means from host,
- *                      non-zero means to host.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-sme_native_log_event(ul_client_t *pcli,
-                     const u8 *sig_packed, int sig_len,
-                     const bulk_data_param_t *bulkdata,
-                     int dir)
-{
-    unifi_priv_t *priv;
-    udi_log_t *logptr;
-    u8 *p;
-    int i, r;
-    int signal_len;
-    int total_len;
-    udi_msg_t *msgptr;
-    CSR_SIGNAL signal;
-    ul_client_t *client = pcli;
-
-    if (client == NULL) {
-        unifi_error(NULL, "sme_native_log_event: client has exited\n");
-        return;
-    }
-
-    priv = uf_find_instance(client->instance);
-    if (!priv) {
-        unifi_error(priv, "invalid priv\n");
-        return;
-    }
-
-    /* Just a sanity check */
-    if ((sig_packed == NULL) || (sig_len <= 0)) {
-        return;
-    }
-
-    /* Get the unpacked signal */
-    r = read_unpack_signal(sig_packed, &signal);
-    if (r == 0) {
-        signal_len = SigGetSize(&signal);
-    } else {
-        u16 receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sig_packed) + sizeof(u16)) & 0xFF00;
-
-        /* The control indications are 1 byte, pass them to client. */
-        if (sig_len == 1) {
-            unifi_trace(priv, UDBG5,
-                        "Control indication (0x%x) for native SME.\n",
-                        *sig_packed);
-
-            *(u8*)&signal = *sig_packed;
-            signal_len = sig_len;
-        } else if (receiver_id == 0) {
-            /*
-             * Also "unknown" signals with a ReceiverId of 0 are passed to the client
-             * without unpacking. (This is a code size optimisation to allow signals
-             * that the driver not interested in to be dropped from the unpack code).
-             */
-            unifi_trace(priv, UDBG5,
-                        "Signal 0x%.4X with ReceiverId 0 for native SME.\n",
-                        CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
-
-            *(u8*)&signal = *sig_packed;
-            signal_len = sig_len;
-        } else {
-            unifi_error(priv,
-                        "sme_native_log_event - Received unknown signal 0x%.4X.\n",
-                        CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
-            return;
-        }
-    }
-
-    unifi_trace(priv, UDBG3, "sme_native_log_event: signal 0x%.4X for %d\n",
-                signal.SignalPrimitiveHeader.SignalId,
-                client->client_id);
-
-    total_len = signal_len;
-    /* Calculate the buffer we need to store signal plus bulk data */
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-        total_len += bulkdata->d[i].data_length;
-    }
-
-    /* Allocate log structure plus actual signal. */
-    logptr = kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL);
-
-    if (logptr == NULL) {
-        unifi_error(priv,
-                    "Failed to allocate %d bytes for a UDI log record\n",
-                    sizeof(udi_log_t) + total_len);
-        return;
-    }
-
-    /* Fill in udi_log struct */
-    INIT_LIST_HEAD(&logptr->q);
-    msgptr = &logptr->msg;
-    msgptr->length = sizeof(udi_msg_t) + total_len;
-    msgptr->timestamp = jiffies_to_msecs(jiffies);
-    msgptr->direction = dir;
-    msgptr->signal_length = signal_len;
-
-    /* Copy signal and bulk data to the log */
-    p = (u8 *)(msgptr + 1);
-    memcpy(p, &signal, signal_len);
-    p += signal_len;
-
-    /* Append any bulk data */
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-        int len = bulkdata->d[i].data_length;
-
-        /*
-         * Len here might not be the same as the length in the bulk data slot.
-         * The slot length will always be even, but len could be odd.
-         */
-        if (len > 0) {
-            if (bulkdata->d[i].os_data_ptr) {
-                memcpy(p, bulkdata->d[i].os_data_ptr, len);
-            } else {
-                memset(p, 0, len);
-            }
-            p += len;
-        }
-    }
-
-    /* Add to tail of log queue */
-    down(&client->udi_sem);
-    list_add_tail(&logptr->q, &client->udi_log);
-    up(&client->udi_sem);
-
-    /* Wake any waiting user process */
-    wake_up_interruptible(&client->udi_wq);
-
-} /* sme_native_log_event() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_ta_indicate_protocol
- *
- *      Report that a packet of a particular type has been seen
- *
- *  Arguments:
- *      drv_priv        The device context pointer passed to ta_init.
- *      protocol        The protocol type enum value.
- *      direction       Whether the packet was a tx or rx.
- *      src_addr        The source MAC address from the data packet.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      We defer the actual sending to a background workqueue,
- *      see uf_ta_ind_wq().
- * ---------------------------------------------------------------------------
- */
-void
-unifi_ta_indicate_protocol(void *ospriv,
-                           CsrWifiRouterCtrlTrafficPacketType packet_type,
-                           CsrWifiRouterCtrlProtocolDirection direction,
-                           const CsrWifiMacAddress *src_addr)
-{
-
-} /* unifi_ta_indicate_protocol */
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_ta_indicate_sampling
- *
- *      Send the TA sampling information to the SME.
- *
- *  Arguments:
- *      drv_priv        The device context pointer passed to ta_init.
- *      stats           The TA sampling data to send.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats)
-{
-
-} /* unifi_ta_indicate_sampling() */
-
-
-void
-unifi_ta_indicate_l4stats(void *ospriv,
-                            u32 rxTcpThroughput,
-                            u32 txTcpThroughput,
-                            u32 rxUdpThroughput,
-                            u32 txUdpThroughput)
-{
-
-} /* unifi_ta_indicate_l4stats() */
-
-/*
- * ---------------------------------------------------------------------------
- * uf_native_process_udi_signal
- *
- *      Process interesting signals from the UDI interface.
- *
- *  Arguments:
- *      pcli            A pointer to the client instance.
- *      signal          Pointer to the received signal.
- *      signal_len      Size of the signal structure in bytes.
- *      bulkdata        Pointers to any associated bulk data.
- *      dir             Direction of the signal. Zero means from host,
- *                      non-zero means to host.
- *
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-uf_native_process_udi_signal(ul_client_t *pcli,
-                             const u8 *packed_signal, int packed_signal_len,
-                             const bulk_data_param_t *bulkdata, int dir)
-{
-
-} /* uf_native_process_udi_signal() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  sme_native_mlme_event_handler
- *
- *      Callback function to be used as the udi_event_callback when registering
- *      as a client.
- *      This function implements a blocking request-reply interface for WEXT.
- *      To use it, a client specifies this function as the udi_event_callback
- *      to ul_register_client(). The signal dispatcher in
- *      unifi_receive_event() will call this function to deliver a signal.
- *
- *  Arguments:
- *      pcli            Pointer to the client instance.
- *      signal          Pointer to the received signal.
- *      signal_len      Size of the signal structure in bytes.
- *      bulkdata        Pointer to structure containing any associated bulk data.
- *      dir             Direction of the signal. Zero means from host,
- *                      non-zero means to host.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-sme_native_mlme_event_handler(ul_client_t *pcli,
-                              const u8 *sig_packed, int sig_len,
-                              const bulk_data_param_t *bulkdata,
-                              int dir)
-{
-    CSR_SIGNAL signal;
-    int signal_len;
-    unifi_priv_t *priv = uf_find_instance(pcli->instance);
-    int id, r;
-
-    /* Just a sanity check */
-    if ((sig_packed == NULL) || (sig_len <= 0)) {
-        return;
-    }
-
-    /* Get the unpacked signal */
-    r = read_unpack_signal(sig_packed, &signal);
-    if (r == 0) {
-        signal_len = SigGetSize(&signal);
-    } else {
-        unifi_error(priv,
-                    "sme_native_mlme_event_handler - Received unknown signal 0x%.4X.\n",
-                    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
-        return;
-    }
-
-    id = signal.SignalPrimitiveHeader.SignalId;
-    unifi_trace(priv, UDBG4, "wext - Process signal 0x%.4X\n", id);
-
-    /*
-     * Take the appropriate action for the signal.
-     */
-    switch (id) {
-        /*
-         * Confirm replies from UniFi.
-         * These all have zero or one CSR_DATAREF member. (FIXME: check this is still true for softmac)
-         */
-        case CSR_MA_PACKET_CONFIRM_ID:
-        case CSR_MLME_RESET_CONFIRM_ID:
-        case CSR_MLME_GET_CONFIRM_ID:
-        case CSR_MLME_SET_CONFIRM_ID:
-        case CSR_MLME_GET_NEXT_CONFIRM_ID:
-        case CSR_MLME_POWERMGT_CONFIRM_ID:
-        case CSR_MLME_SCAN_CONFIRM_ID:
-        case CSR_MLME_HL_SYNC_CONFIRM_ID:
-        case CSR_MLME_MEASURE_CONFIRM_ID:
-        case CSR_MLME_SETKEYS_CONFIRM_ID:
-        case CSR_MLME_DELETEKEYS_CONFIRM_ID:
-        case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
-        case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
-        case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
-        case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
-        case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
-        case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
-        case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
-        case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
-        case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
-        case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
-        case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
-        case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
-        case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
-        case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
-        case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
-        case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
-        case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
-        case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
-        case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
-        case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
-        case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
-        case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
-        case CSR_MLME_SM_START_CONFIRM_ID:
-        case CSR_MLME_LEAVE_CONFIRM_ID:
-        case CSR_MLME_SET_TIM_CONFIRM_ID:
-        case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
-        case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
-        case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
-        case CSR_DEBUG_GENERIC_CONFIRM_ID:
-            unifi_mlme_copy_reply_and_wakeup_client(pcli, &signal, signal_len, bulkdata);
-            break;
-
-        case CSR_MLME_CONNECTED_INDICATION_ID:
-            /* We currently ignore the connected-ind for softmac f/w development */
-            unifi_info(priv, "CSR_MLME_CONNECTED_INDICATION_ID ignored\n");
-            break;
-
-        default:
-            break;
-    }
-
-} /* sme_native_mlme_event_handler() */
-
-
-
-/*
- * -------------------------------------------------------------------------
- *  unifi_reset_state
- *
- *      Ensure that a MAC address has been set.
- *      Send the MLME-RESET signal.
- *      This must be called at least once before starting to do any
- *      network activities (e.g. scan, join etc).
- *
- * Arguments:
- *      priv            Pointer to device private context struct
- *      macaddr         Pointer to chip MAC address.
- *                      If this is FF:FF:FF:FF:FF:FF it will be replaced
- *                      with the MAC address from the chip.
- *      set_default_mib 1 if the f/w must reset the MIB to the default values
- *                      0 otherwise
- *
- * Returns:
- *      0 on success, an error code otherwise.
- * -------------------------------------------------------------------------
- */
-int
-unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr,
-                  unsigned char set_default_mib)
-{
-    int r = 0;
-
-#ifdef CSR_SUPPORT_WEXT
-    /* The reset clears any 802.11 association. */
-    priv->wext_conf.flag_associated = 0;
-#endif
-
-    return r;
-} /* unifi_reset_state() */
-
diff --git a/drivers/staging/csr/sme_sys.c b/drivers/staging/csr/sme_sys.c
deleted file mode 100644 (file)
index b5258d7..0000000
+++ /dev/null
@@ -1,3260 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     sme_sys.c
- *
- * PURPOSE:
- *      Driver specific implementation of the SME SYS SAP.
- *      It is part of the porting exercise.
- *
- * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-#include "csr_wifi_hip_unifiversion.h"
-#include "unifi_priv.h"
-#include "csr_wifi_hip_conversions.h"
-#ifdef CSR_SUPPORT_WEXT_AP
-#include "csr_wifi_sme_sef.h"
-#endif
-
-/*
- * This file implements the SME SYS API and contains the following functions:
- * CsrWifiRouterCtrlMediaStatusReqHandler()
- * CsrWifiRouterCtrlHipReqHandler()
- * CsrWifiRouterCtrlPortConfigureReqHandler()
- * CsrWifiRouterCtrlWifiOnReqHandler()
- * CsrWifiRouterCtrlWifiOffReqHandler()
- * CsrWifiRouterCtrlSuspendResHandler()
- * CsrWifiRouterCtrlResumeResHandler()
- * CsrWifiRouterCtrlQosControlReqHandler()
- * CsrWifiRouterCtrlConfigurePowerModeReqHandler()
- * CsrWifiRouterCtrlWifiOnResHandler()
- * CsrWifiRouterCtrlWifiOffRspHandler()
- * CsrWifiRouterCtrlMulticastAddressResHandler()
- * CsrWifiRouterCtrlTrafficConfigReqHandler()
- * CsrWifiRouterCtrlTrafficClassificationReqHandler()
- * CsrWifiRouterCtrlTclasAddReqHandler()
- * CsrWifiRouterCtrlTclasDelReqHandler()
- * CsrWifiRouterCtrlSetModeReqHandler()
- * CsrWifiRouterCtrlWapiMulticastFilterReqHandler()
- * CsrWifiRouterCtrlWapiUnicastFilterReqHandler()
- * CsrWifiRouterCtrlWapiUnicastTxPktReqHandler()
- * CsrWifiRouterCtrlWapiRxPktReqHandler()
- * CsrWifiRouterCtrlWapiFilterReqHandler()
- */
-
-#ifdef CSR_SUPPORT_SME
-static void check_inactivity_timer_expire_func(unsigned long data);
-void uf_send_disconnected_ind_wq(struct work_struct *work);
-#endif
-
-void send_auto_ma_packet_confirm(unifi_priv_t *priv,
-                                 netInterface_priv_t *interfacePriv,
-                                 struct list_head *buffered_frames_list)
-{
-    tx_buffered_packets_t *buffered_frame_item = NULL;
-    struct list_head *listHead;
-    struct list_head *placeHolder;
-    int client_id;
-
-    CSR_SIGNAL unpacked_signal;
-    u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
-    u16 packed_siglen;
-
-
-    list_for_each_safe(listHead, placeHolder, buffered_frames_list)
-    {
-        buffered_frame_item = list_entry(listHead, tx_buffered_packets_t, q);
-
-        if(!buffered_frame_item) {
-            unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
-            continue;
-        }
-
-        if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_NONE) &&
-            (priv->wifi_on_state == wifi_on_done))
-        {
-
-            unifi_warning(priv, "Send MA_PACKET_CONFIRM to SenderProcessId = %x for (HostTag = %x TransmissionControl = %x)\n",
-                                 (buffered_frame_item->leSenderProcessId),
-                                 buffered_frame_item->hostTag,
-                                 buffered_frame_item->transmissionControl);
-
-            client_id = buffered_frame_item->leSenderProcessId & 0xFF00;
-
-            if (client_id == priv->sme_cli->sender_id)
-            {
-                /* construct a MA-PACKET.confirm message for SME */
-                memset(&unpacked_signal, 0, sizeof(unpacked_signal));
-                unpacked_signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_CONFIRM_ID;
-                unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId = buffered_frame_item->leSenderProcessId;
-                unpacked_signal.SignalPrimitiveHeader.SenderProcessId = CSR_WIFI_ROUTER_IFACEQUEUE;
-
-                unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,
-                                                                                                     interfacePriv->InterfaceTag);
-                unpacked_signal.u.MaPacketConfirm.TransmissionStatus = CSR_RESULT_FAILURE;
-                unpacked_signal.u.MaPacketConfirm.RetryCount = 0;
-                unpacked_signal.u.MaPacketConfirm.Rate = buffered_frame_item->rate;
-                unpacked_signal.u.MaPacketConfirm.HostTag = buffered_frame_item->hostTag;
-
-                write_pack(&unpacked_signal, sigbuf, &packed_siglen);
-                unifi_warning(priv, "MA_PACKET_CONFIRM for SME (0x%x, 0x%x, 0x%x, 0x%x)\n",
-                                         unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId,
-                                         unpacked_signal.SignalPrimitiveHeader.SenderProcessId,
-                                         unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier,
-                                         unpacked_signal.u.MaPacketConfirm.HostTag);
-
-                CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
-                                            packed_siglen,
-                                            (u8 *)sigbuf,
-                                            0, NULL,
-                                            0, NULL);
-            }
-            else if((buffered_frame_item->hostTag & 0x80000000))
-            {
-                /* construct a MA-PACKET.confirm message for NME */
-                unifi_warning(priv, "MA_PACKET_CONFIRM for NME (0x%x, 0x%x, 0x%x, 0x%x)\n",
-                                    buffered_frame_item->leSenderProcessId,
-                                    buffered_frame_item->interfaceTag,
-                                    buffered_frame_item->transmissionControl,
-                                    (buffered_frame_item->hostTag & 0x3FFFFFFF));
-
-                CsrWifiRouterMaPacketCfmSend((buffered_frame_item->leSenderProcessId & 0xFF),
-                                            buffered_frame_item->interfaceTag,
-                                            CSR_RESULT_FAILURE,
-                                            (buffered_frame_item->hostTag & 0x3FFFFFFF),
-                                            buffered_frame_item->rate);
-
-            }
-            else
-            {
-                unifi_warning(priv, "Buffered packet dropped without sending a confirm\n");
-            }
-
-        }
-
-        list_del(listHead);
-        kfree(buffered_frame_item);
-        buffered_frame_item = NULL;
-    }
-}
-
-void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlMediaStatusReq* req = (CsrWifiRouterCtrlMediaStatusReq*)msg;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-    unsigned long flags;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid smepriv\n");
-        return;
-    }
-    if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid interfaceTag\n");
-        return;
-    }
-    unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlMediaStatusReqHandler: Mode = %d req->mediaStatus = %d\n", interfacePriv->interfaceMode, req->mediaStatus);
-    if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AMP) {
-        bulk_data_desc_t bulk_data;
-
-        bulk_data.data_length = 0;
-
-        spin_lock_irqsave(&priv->m4_lock, flags);
-        if (interfacePriv->m4_bulk_data.data_length > 0) {
-            bulk_data = interfacePriv->m4_bulk_data;
-            interfacePriv->m4_bulk_data.net_buf_length = 0;
-            interfacePriv->m4_bulk_data.data_length = 0;
-            interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
-        }
-        spin_unlock_irqrestore(&priv->m4_lock, flags);
-
-        if (bulk_data.data_length != 0) {
-            unifi_trace(priv, UDBG5, "CsrWifiRouterCtrlMediaStatusReqHandler: free M4\n");
-            unifi_net_data_free(priv, &bulk_data);
-        }
-
-        if ((req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) &&
-            (interfacePriv->connected != UnifiConnected)) {
-
-            switch(interfacePriv->interfaceMode){
-                case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-                case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-                    interfacePriv->connected = UnifiConnected;
-                    netif_carrier_on(priv->netdev[req->interfaceTag]);
-#ifdef CSR_SUPPORT_WEXT
-                    wext_send_started_event(priv);
-#endif
-                    unifi_trace(priv, UDBG1,
-                                "CsrWifiRouterCtrlMediaStatusReqHandler: AP/P2PGO setting netif_carrier_on\n");
-                    netif_tx_wake_all_queues(priv->netdev[req->interfaceTag]);
-                    break;
-
-                default:
-#ifdef CSR_SUPPORT_WEXT
-                /* In the WEXT builds (sme and native), the userspace is not ready
-                 * to process any EAPOL or WAPI packets, until it has been informed
-                 * of the NETDEV_CHANGE.
-                 */
-                if (interfacePriv->netdev_callback_registered && (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI)) {
-                    interfacePriv->wait_netdev_change = TRUE;
-                    unifi_trace(priv, UDBG1,
-                                "CsrWifiRouterCtrlMediaStatusReqHandler: waiting for NETDEV_CHANGE\n");
-                    /*
-                     * Carrier can go to on, only after wait_netdev_change is set to TRUE.
-                     * Otherwise there can be a race in uf_netdev_event().
-                     */
-                    netif_carrier_on(priv->netdev[req->interfaceTag]);
-                    unifi_trace(priv, UDBG1,
-                                "CsrWifiRouterCtrlMediaStatusReqHandler: STA/P2PCLI setting netif_carrier_on\n");
-                }
-                else
-#endif
-                {
-                    /* In the NME build, the userspace does not wait for the NETDEV_CHANGE
-                     * so it is ready to process all the EAPOL or WAPI packets.
-                     * At this point, we enable all the Tx queues, and we indicate any packets
-                     * that are queued (and the respective port is opened).
-                     */
-                    static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
-                    interfacePriv->connected = UnifiConnected;
-                    unifi_trace(priv, UDBG1,
-                                "CsrWifiRouterMediaStatusReqHandler: UnifiConnected && netif_carrier_on\n");
-                    netif_carrier_on(priv->netdev[req->interfaceTag]);
-                    netif_tx_wake_all_queues(priv->netdev[req->interfaceTag]);
-                    uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
-                    uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
-                }
-                break;
-            }
-        }
-
-        if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED) {
-#ifdef CSR_SUPPORT_WEXT
-            unifi_trace(priv, UDBG1,
-                        "CsrWifiRouterMediaStatusReqHandler: cancel waiting for NETDEV_CHANGE\n");
-            interfacePriv->wait_netdev_change = FALSE;
-#endif
-            unifi_trace(priv, UDBG1,
-                        "CsrWifiRouterMediaStatusReqHandler: setting netif_carrier_off\n");
-            netif_carrier_off(priv->netdev[req->interfaceTag]);
-#ifdef CSR_SUPPORT_WEXT
-            switch(interfacePriv->interfaceMode){
-                case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-                case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-                     wext_send_started_event(priv);
-                     break;
-                default:
-                     break;
-            }
-#endif
-            interfacePriv->connected = UnifiNotConnected;
-        }
-    } else {
-        /* For AMP, just update the L2 connected flag */
-        if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) {
-            unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP connected\n");
-            interfacePriv->connected = UnifiConnected;
-        } else {
-            unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP disconnected\n");
-            interfacePriv->connected = UnifiNotConnected;
-        }
-    }
-}
-
-
-void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlHipReq* hipreq = (CsrWifiRouterCtrlHipReq*)msg;
-    bulk_data_param_t bulkdata;
-    u8 *signal_ptr;
-    int signal_length;
-    int r=0;
-    void *dest;
-    CsrResult csrResult;
-    CSR_SIGNAL *signal;
-    u16 interfaceTag = 0;
-    CSR_MA_PACKET_REQUEST *req;
-    netInterface_priv_t *interfacePriv;
-
-    if (priv == NULL) {
-        return;
-    }
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid smepriv\n");
-        return;
-    }
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid interfaceTag\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    /* Initialize bulkdata to avoid os_net_buf is garbage */
-    memset(&bulkdata, 0, sizeof(bulk_data_param_t));
-
-    signal = (CSR_SIGNAL *)hipreq->mlmeCommand;
-
-    unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: 0x04%X ---->\n",
-                *((u16*)hipreq->mlmeCommand));
-
-    /* Construct the signal. */
-    signal_ptr = (u8*)hipreq->mlmeCommand;
-    signal_length = hipreq->mlmeCommandLength;
-
-    /*
-     * The MSB of the sender ID needs to be set to the client ID.
-     * The LSB is controlled by the SME.
-     */
-    signal_ptr[5] = (priv->sme_cli->sender_id >> 8) & 0xff;
-
-    /* Allocate buffers for the bulk data. */
-    if (hipreq->dataRef1Length) {
-        csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], hipreq->dataRef1Length);
-        if (csrResult == CSR_RESULT_SUCCESS) {
-            dest = (void*)bulkdata.d[0].os_data_ptr;
-            memcpy(dest, hipreq->dataRef1, hipreq->dataRef1Length);
-            bulkdata.d[0].data_length = hipreq->dataRef1Length;
-        } else {
-            unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
-            return;
-        }
-    } else {
-        bulkdata.d[0].os_data_ptr = NULL;
-        bulkdata.d[0].data_length = 0;
-    }
-    if (hipreq->dataRef2Length) {
-        csrResult = unifi_net_data_malloc(priv, &bulkdata.d[1], hipreq->dataRef2Length);
-        if (csrResult == CSR_RESULT_SUCCESS) {
-            dest = (void*)bulkdata.d[1].os_data_ptr;
-            memcpy(dest, hipreq->dataRef2, hipreq->dataRef2Length);
-            bulkdata.d[1].data_length = hipreq->dataRef2Length;
-        } else {
-            if (bulkdata.d[0].data_length)
-            {
-                unifi_net_data_free(priv, &bulkdata.d[0]);
-            }
-            unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
-            return;
-        }
-    } else {
-        bulkdata.d[1].os_data_ptr = NULL;
-        bulkdata.d[1].data_length = 0;
-    }
-
-    unifi_trace(priv, UDBG3, "SME SEND: Signal 0x%.4X \n",
-                *((u16*)signal_ptr));
-    if (signal->SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_REQUEST_ID)
-    {
-        CSR_SIGNAL unpacked_signal;
-        read_unpack_signal((u8 *) signal, &unpacked_signal);
-        req = &unpacked_signal.u.MaPacketRequest;
-        interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
-        switch(interfacePriv->interfaceMode)
-        {
-            case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
-                unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid mode: NONE \n");
-                break;
-            default:
-                unifi_trace(priv, UDBG5, "mode is %x\n", interfacePriv->interfaceMode);
-        }
-        /* While sending ensure that first 2 bits b31 and b30 are 00. These are used for local routing*/
-        r = uf_process_ma_packet_req(priv, req->Ra.x, (req->HostTag & 0x3FFFFFFF), interfaceTag,
-                                     req->TransmissionControl, req->TransmitRate,
-                                     req->Priority, signal->SignalPrimitiveHeader.SenderProcessId,
-                                     &bulkdata);
-        if (r)
-        {
-            if (bulkdata.d[0].data_length)
-            {
-                unifi_net_data_free(priv, &bulkdata.d[0]);
-            }
-            if (bulkdata.d[1].data_length)
-            {
-                unifi_net_data_free(priv, &bulkdata.d[1]);
-            }
-        }
-    } else {
-        /* ul_send_signal_raw frees the bulk data if it fails */
-        r = ul_send_signal_raw(priv, signal_ptr, signal_length, &bulkdata);
-    }
-
-    if (r) {
-        unifi_error(priv,
-                    "CsrWifiRouterCtrlHipReqHandler: Failed to send signal (0x%.4X - %u)\n",
-                    *((u16*)signal_ptr), r);
-        CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, CSR_WIFI_SME_CONTROL_INDICATION_ERROR);
-    }
-
-    unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: <----\n");
-}
-
-#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
-static void
-uf_send_gratuitous_arp(unifi_priv_t *priv, u16 interfaceTag)
-{
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    CSR_PRIORITY priority;
-    CSR_SIGNAL signal;
-    bulk_data_param_t bulkdata;
-    CsrResult csrResult;
-    struct sk_buff *skb, *newSkb = NULL;
-    s8 protection;
-    int r;
-    static const u8 arp_req[36] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,
-                                         0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01,
-                                         0x00, 0x02, 0x5f, 0x20, 0x2f, 0x02,
-                                         0xc0, 0xa8, 0x00, 0x02,
-                                         0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-                                         0xc0, 0xa8, 0x00, 0x02};
-
-    csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], sizeof(arp_req));
-    if (csrResult != CSR_RESULT_SUCCESS)
-    {
-        unifi_error(priv, "Failed to allocate bulk data in CsrWifiSmeRoamCompleteIndHandler()\n");
-        return;
-    }
-    skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
-    skb->len = bulkdata.d[0].data_length;
-
-    memcpy(skb->data, arp_req, sizeof(arp_req));
-    /* add MAC and IP address */
-    memcpy(skb->data + 16, priv->netdev[interfaceTag]->dev_addr, ETH_ALEN);
-    skb->data[22] = (priv->sta_ip_address      ) & 0xFF;
-    skb->data[23] = (priv->sta_ip_address >>  8) & 0xFF;
-    skb->data[24] = (priv->sta_ip_address >> 16) & 0xFF;
-    skb->data[25] = (priv->sta_ip_address >> 24) & 0xFF;
-    skb->data[32] = (priv->sta_ip_address      ) & 0xFF;
-    skb->data[33] = (priv->sta_ip_address >>  8) & 0xFF;
-    skb->data[34] = (priv->sta_ip_address >> 16) & 0xFF;
-    skb->data[35] = (priv->sta_ip_address >> 24) & 0xFF;
-
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].os_net_buf_ptr = NULL;
-    bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
-
-    if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, &arp_req[26])) < 0)
-    {
-        unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: Failed to determine protection mode\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return;
-    }
-
-    if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1)
-    {
-        priority = CSR_QOS_UP0;
-    }
-    else
-    {
-        priority = CSR_CONTENTION;
-    }
-
-    if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata,
-                                  interfaceTag, &arp_req[26],
-                                  priv->netdev[interfaceTag]->dev_addr, protection))
-    {
-        unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to create MAC header\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return;
-    }
-    bulkdata.d[0].os_data_ptr = skb->data;
-    bulkdata.d[0].os_net_buf_ptr = skb;
-    bulkdata.d[0].data_length = skb->len;
-
-    unifi_frame_ma_packet_req(priv, priority, 0, 0xffffffff, interfaceTag,
-                              CSR_NO_CONFIRM_REQUIRED, priv->netdev_client->sender_id,
-                              interfacePriv->bssid.a, &signal);
-
-    r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
-    if (r)
-    {
-        unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to send QOS data null packet result: %d\n", r);
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return;
-    }
-
-}
-#endif /* CSR_WIFI_SEND_GRATUITOUS_ARP */
-
-/*
- * ---------------------------------------------------------------------------
- * configure_data_port
- *
- *      Store the new controlled port configuration.
- *
- * Arguments:
- *      priv            Pointer to device private context struct
- *      port_cfg        Pointer to the port configuration
- *
- * Returns:
- *      An unifi_ControlledPortAction value.
- * ---------------------------------------------------------------------------
- */
-static int
-configure_data_port(unifi_priv_t *priv,
-        CsrWifiRouterCtrlPortAction port_action,
-        const CsrWifiMacAddress *macAddress,
-        const int queue,
-        u16 interfaceTag)
-{
-    const u8 broadcast_mac_address[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
-    unifi_port_config_t *port;
-    netInterface_priv_t *interfacePriv;
-    int i;
-    const char* controlled_string; /* cosmetic "controlled"/"uncontrolled" for trace */
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "configure_data_port: bad interfaceTag\n");
-        return -EFAULT;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if (queue == UF_CONTROLLED_PORT_Q) {
-        port = &interfacePriv->controlled_data_port;
-        controlled_string = "controlled";
-    } else {
-        port = &interfacePriv->uncontrolled_data_port;
-        controlled_string = "uncontrolled";
-    }
-
-       unifi_trace(priv, UDBG2,
-               "port config request %pM %s with port_action %d.\n",
-               macAddress->a, controlled_string, port_action);
-
-    /* If the new configuration has the broadcast MAC address or if we are in infrastructure mode then clear the list first and set port overide mode */
-    if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode ||
-        interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) ||
-        !memcmp(macAddress->a, broadcast_mac_address, ETH_ALEN)) {
-
-        port->port_cfg[0].port_action = port_action;
-        port->port_cfg[0].mac_address = *macAddress;
-        port->port_cfg[0].in_use = TRUE;
-        port->entries_in_use = 1;
-        port->overide_action = UF_DATA_PORT_OVERIDE;
-
-        unifi_trace(priv, UDBG2, "%s port override on\n",
-                    (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
-
-        /* Discard the remaining entries in the port config table */
-        for (i = 1; i < UNIFI_MAX_CONNECTIONS; i++) {
-            port->port_cfg[i].in_use = FALSE;
-        }
-
-        if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
-            unifi_trace(priv, UDBG1, "%s port broadcast set to open.\n",
-                        (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
-
-            /*
-             * Ask stack to schedule for transmission any packets queued
-             * while controlled port was not open.
-             * Use netif_schedule() instead of netif_wake_queue() because
-             * transmission should be already enabled at this point. If it
-             * is not, probably the interface is down and should remain as is.
-             */
-            uf_resume_data_plane(priv, queue, *macAddress, interfaceTag);
-
-#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
-            if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) &&
-                (queue == UF_CONTROLLED_PORT_Q) && (priv->sta_ip_address != 0xFFFFFFFF))
-            {
-                uf_send_gratuitous_arp(priv, interfaceTag);
-            }
-#endif
-        } else {
-            unifi_trace(priv, UDBG1, "%s port broadcast set to %s.\n",
-                        (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled",
-                        (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) ? "discard": "closed");
-
-            /* If port is closed, discard all the pending Rx packets */
-            if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
-                uf_free_pending_rx_packets(priv, queue, *macAddress, interfaceTag);
-            }
-        }
-    } else {
-        /* store the new configuration, either in the entry with matching mac address (if already present),
-         * otherwise in a new entry
-         */
-
-        int found_entry_flag;
-        int first_free_slot = -1;
-
-        /* If leaving override mode, free the port entry used for override */
-        if (port->overide_action == UF_DATA_PORT_OVERIDE) {
-            port->port_cfg[0].in_use = FALSE;
-            port->entries_in_use = 0;
-            port->overide_action = UF_DATA_PORT_NOT_OVERIDE;
-
-            unifi_trace(priv, UDBG2, "%s port override off\n",
-                        (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
-        }
-
-        found_entry_flag = 0;
-        for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-            if (port->port_cfg[i].in_use) {
-                if (!memcmp(&port->port_cfg[i].mac_address.a, macAddress->a, ETH_ALEN)) {
-                    /* We've seen this address before, reconfigure it */
-                    port->port_cfg[i].port_action = port_action;
-                    found_entry_flag = 1;
-                    break;
-                }
-            } else if (first_free_slot == -1) {
-                /* Remember the first free slot on the way past so it can be claimed
-                 * if this turns out to be a new MAC address (to save walking the list again).
-                 */
-                first_free_slot = i;
-            }
-        }
-
-        /* At this point we found an existing entry and have updated it, or need to
-         * add a new entry. If all slots are allocated, give up and return an error.
-         */
-        if (!found_entry_flag) {
-            if (first_free_slot == -1) {
-                unifi_error(priv, "no free slot found in port config array (%d used)\n", port->entries_in_use);
-                return -EFAULT;
-            } else {
-                port->entries_in_use++;
-            }
-
-            unifi_trace(priv, UDBG3, "port config index assigned in config_data_port = %d\n", first_free_slot);
-            port->port_cfg[first_free_slot].in_use = TRUE;
-            port->port_cfg[first_free_slot].port_action = port_action;
-            port->port_cfg[first_free_slot].mac_address = *macAddress;
-        }
-
-        if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
-            /*
-             * Ask stack to schedule for transmission any packets queued
-             * while controlled port was not open.
-             * Use netif_schedule() instead of netif_wake_queue() because
-             * transmission should be already enabled at this point. If it
-             * is not, probably the interface is down and should remain as is.
-             */
-            uf_resume_data_plane(priv, queue, *macAddress, interfaceTag);
-        }
-
-        /*
-         * If port is closed, discard all the pending Rx packets
-         * coming from the peer station.
-         */
-        if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
-            uf_free_pending_rx_packets(priv, queue, *macAddress, interfaceTag);
-        }
-
-       unifi_trace(priv, UDBG2,
-               "port config %pM with port_action %d.\n",
-               macAddress->a, port_action);
-    }
-    return 0;
-} /* configure_data_port() */
-
-
-void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlPortConfigureReq* req = (CsrWifiRouterCtrlPortConfigureReq*)msg;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    unifi_trace(priv, UDBG3, "entering CsrWifiRouterCtrlPortConfigureReqHandler\n");
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlPortConfigureReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    /* To update the protection status of the peer/station */
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-           case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-            /* Since for Unifi as a station, the station record not maintained & interfaceID is
-             * only needed to update the peer protection status
-             */
-            interfacePriv->protect = req->setProtection;
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            {
-                u8 i;
-                CsrWifiRouterCtrlStaInfo_t *staRecord;
-                /* Ifscontrolled port is open means, The peer has been added to station record
-                 * so that the protection corresponding to the peer is valid in this req
-                 */
-                if (req->controlledPortAction == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
-                    for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
-                        staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
-                        if (staRecord) {
-                                /* Find the matching station record & set the protection type */
-                                if (!memcmp(req->macAddress.a, staRecord->peerMacAddress.a, ETH_ALEN)) {
-                                        staRecord->protection = req->setProtection;
-                                        break;
-                                }
-                        }
-                    }
-                }
-            }
-            break;
-        default:
-            unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlPortConfigureReqHandler(0x%.4X) Uncaught mode %d\n",
-                        msg->source, interfacePriv->interfaceMode);
-    }
-
-    configure_data_port(priv, req->uncontrolledPortAction, (const CsrWifiMacAddress *)&req->macAddress,
-                        UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
-    configure_data_port(priv, req->controlledPortAction, (const CsrWifiMacAddress *)&req->macAddress,
-                        UF_CONTROLLED_PORT_Q, req->interfaceTag);
-
-    CsrWifiRouterCtrlPortConfigureCfmSend(msg->source, req->clientData, req->interfaceTag,
-                                      CSR_RESULT_SUCCESS, req->macAddress);
-    unifi_trace(priv, UDBG3, "leaving CsrWifiRouterCtrlPortConfigureReqHandler\n");
-}
-
-
-void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlVersions versions;
-    CsrWifiRouterCtrlWifiOnReq* req = (CsrWifiRouterCtrlWifiOnReq*)msg;
-    int r, i;
-    CsrResult csrResult;
-
-    if (priv == NULL) {
-        return;
-    }
-    if( priv->wol_suspend ) {
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n");
-    } else {
-#ifdef ANDROID_BUILD
-        /* Take the wakelock while Wi-Fi On is in progress */
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n");
-        wake_lock(&unifi_sdio_wake_lock);
-#endif
-        for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
-            unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n", i );
-
-            priv->interfacePriv[i]->interfaceMode = 0;
-        }
-    }
-    unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler(0x%.4X) req->dataLength=%d req->data=0x%x\n", msg->source, req->dataLength, req->data);
-
-    if(req->dataLength==3 && req->data && req->data[0]==0 && req->data[1]==1 && req->data[2]==1)
-    {
-        priv->cmanrTestMode = TRUE;
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: cmanrTestMode=%d\n", priv->cmanrTestMode);
-    }
-    else
-    {
-        priv->cmanrTestMode = FALSE;
-    }
-
-    /*
-     * The request to initialise UniFi might come while UniFi is running.
-     * We need to block all I/O activity until the reset completes, otherwise
-     * an SDIO error might occur resulting an indication to the SME which
-     * makes it think that the initialisation has failed.
-     */
-    priv->bh_thread.block_thread = 1;
-
-    /* Update the wifi_on state */
-    priv->wifi_on_state = wifi_on_in_progress;
-
-    /* If UniFi was unpowered, acquire the firmware for download to chip */
-    if (!priv->wol_suspend) {
-        r = uf_request_firmware_files(priv, UNIFI_FW_STA);
-        if (r) {
-            unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to get f/w\n");
-            CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
-            return;
-        }
-    } else {
-        unifi_trace(priv, UDBG1, "Don't need firmware\n");
-    }
-
-    /* Power on UniFi (which may not necessarily have been off) */
-    CsrSdioClaim(priv->sdio);
-    csrResult = CsrSdioPowerOn(priv->sdio);
-    CsrSdioRelease(priv->sdio);
-    if (csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) {
-        unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to power on UniFi\n");
-        CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
-        return;
-    }
-
-    /* If CsrSdioPowerOn() returns CSR_RESULT_SUCCESS, it means that we need to initialise UniFi */
-    if (csrResult == CSR_RESULT_SUCCESS && !priv->wol_suspend) {
-        /* Initialise UniFi hardware */
-        r = uf_init_hw(priv);
-        if (r) {
-            unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
-            CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
-            return;
-        }
-    } else {
-        unifi_trace(priv, UDBG1, "UniFi already initialised\n");
-    }
-
-    /* Completed handling of wake up from suspend with UniFi powered */
-    priv->wol_suspend = FALSE;
-
-    /* Re-enable the I/O thread */
-    priv->bh_thread.block_thread = 0;
-
-    /*
-     * Start the I/O thread. The thread might be already running.
-     * This fine, just carry on with the request.
-     */
-    r = uf_init_bh(priv);
-    if (r) {
-        CsrSdioClaim(priv->sdio);
-        CsrSdioPowerOff(priv->sdio);
-        CsrSdioRelease(priv->sdio);
-        CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
-        return;
-    }
-
-    /* Get the version information from the core */
-    unifi_card_info(priv->card, &priv->card_info);
-
-    /* Set the sme queue id */
-    priv->CSR_WIFI_SME_IFACEQUEUE = msg->source;
-    CSR_WIFI_SME_IFACEQUEUE = msg->source;
-
-
-    /* Copy to the unifiio_card_info structure. */
-    versions.chipId = priv->card_info.chip_id;
-    versions.chipVersion = priv->card_info.chip_version;
-    versions.firmwareBuild = priv->card_info.fw_build;
-    versions.firmwareHip = priv->card_info.fw_hip_version;
-    versions.routerBuild = (char*)CSR_WIFI_VERSION;
-    versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION;
-
-    CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions);
-
-    /* Update the wifi_on state */
-    priv->wifi_on_state = wifi_on_done;
-}
-
-
-/*
- * wifi_off:
- *      Common code for CsrWifiRouterCtrlWifiOffReqHandler() and
- *      CsrWifiRouterCtrlWifiOffRspHandler().
- */
-static void
-wifi_off(unifi_priv_t *priv)
-{
-    int power_off;
-    int priv_instance;
-    int i;
-    CsrResult csrResult;
-
-
-    /* Already off? */
-    if (priv->wifi_on_state == wifi_on_unspecified) {
-        unifi_trace(priv, UDBG1, "wifi_off already\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG1, "wifi_off\n");
-
-    /* Destroy the Traffic Analysis Module */
-    cancel_work_sync(&priv->ta_ind_work.task);
-    cancel_work_sync(&priv->ta_sample_ind_work.task);
-#ifdef CSR_SUPPORT_WEXT
-    cancel_work_sync(&priv->sme_config_task);
-    wext_send_disassoc_event(priv);
-#endif
-
-    /* Cancel pending M4 stuff */
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        if (priv->netdev[i]) {
-            netInterface_priv_t *netpriv = (netInterface_priv_t *) netdev_priv(priv->netdev[i]);
-            cancel_work_sync(&netpriv->send_m4_ready_task);
-        }
-    }
-    flush_workqueue(priv->unifi_workqueue);
-
-    /* fw_init parameter can prevent power off UniFi, for debugging */
-    priv_instance = uf_find_priv(priv);
-    if (priv_instance == -1) {
-        unifi_warning(priv,
-                "CsrWifiRouterCtrlStopReqHandler: Unknown priv instance, will power off card.\n");
-        power_off = 1;
-    } else {
-        power_off = (fw_init[priv_instance] > 0) ? 0 : 1;
-    }
-
-    /* Production test mode requires power to the chip, too */
-    if (priv->ptest_mode) {
-        power_off = 0;
-    }
-
-    /* Stop the bh_thread */
-    uf_stop_thread(priv, &priv->bh_thread);
-
-    /* Read the f/w panic codes, if any. Protect against second wifi_off() call,
-     * which may happen if SME requests a wifi_off and closes the char device */
-    if (priv->init_progress != UNIFI_INIT_NONE) {
-        CsrSdioClaim(priv->sdio);
-        unifi_capture_panic(priv->card);
-        CsrSdioRelease(priv->sdio);
-    }
-
-    /* Unregister the interrupt handler */
-    if (csr_sdio_linux_remove_irq(priv->sdio)) {
-        unifi_notice(priv,
-                "csr_sdio_linux_remove_irq failed to talk to card.\n");
-    }
-
-    if (power_off) {
-        unifi_trace(priv, UDBG2,
-                    "Force low power and try to power off\n");
-        /* Put UniFi to deep sleep, in case we can not power it off */
-        CsrSdioClaim(priv->sdio);
-        csrResult = unifi_force_low_power_mode(priv->card);
-        CsrSdioRelease(priv->sdio);
-
-        CsrSdioPowerOff(priv->sdio);
-    }
-
-    /* Consider UniFi to be uninitialised */
-    priv->init_progress = UNIFI_INIT_NONE;
-    priv->wifi_on_state = wifi_on_unspecified;
-
-
-} /* wifi_off() */
-
-
-void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlWifiOffReq* req = (CsrWifiRouterCtrlWifiOffReq*)msg;
-    int i = 0;
-
-    if (priv == NULL) {
-        return;
-    }
-
-    unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOffReqHandler(0x%.4X)\n", msg->source);
-
-    /* Stop the network traffic on all interfaces before freeing the core. */
-    for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-        if (interfacePriv->netdev_registered == 1) {
-            netif_carrier_off(priv->netdev[i]);
-            netif_tx_stop_all_queues(priv->netdev[i]);
-            interfacePriv->connected = UnifiConnectedUnknown;
-        }
-        interfacePriv->interfaceMode = 0;
-
-        /* Enable all queues by default */
-        interfacePriv->queueEnabled[0] = 1;
-        interfacePriv->queueEnabled[1] = 1;
-        interfacePriv->queueEnabled[2] = 1;
-        interfacePriv->queueEnabled[3] = 1;
-    }
-    wifi_off(priv);
-
-    CsrWifiRouterCtrlWifiOffCfmSend(msg->source, req->clientData);
-
-    /* If this is called in response to closing the character device, the
-     * caller must use uf_sme_cancel_request() to terminate any pending SME
-     * blocking request or there will be a delay while the operation times out.
-     */
-}
-
-
-void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlQosControlReq* req = (CsrWifiRouterCtrlQosControlReq*)msg;
-    netInterface_priv_t *interfacePriv;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlQosControlReqHandler:scontrol = %d", req->control);
-
-    if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
-        return;
-    }
-    interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    if (req->control == CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON) {
-        priv->sta_wmm_capabilities |= QOS_CAPABILITY_WMM_ENABLED;
-        unifi_trace(priv, UDBG1, "WMM enabled\n");
-
-        unifi_trace(priv, UDBG1, "Queue Config %x\n", req->queueConfig);
-
-        interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BK] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE)?1:0;
-        interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BE] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE)?1:0;
-        interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VI] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE)?1:0;
-        interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VO] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE)?1:0;
-
-    } else {
-        priv->sta_wmm_capabilities = 0;
-        unifi_trace(priv, UDBG1, "WMM disabled\n");
-    }
-}
-
-
-void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlTclasAddReq* req = (CsrWifiRouterCtrlTclasAddReq*)msg;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlTclasAddReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    CsrWifiRouterCtrlTclasAddCfmSend(msg->source, req->clientData, req->interfaceTag , CSR_RESULT_SUCCESS);
-}
-
-void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlTclasDelReq* req = (CsrWifiRouterCtrlTclasDelReq*)msg;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlTclasDelReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    CsrWifiRouterCtrlTclasDelCfmSend(msg->source, req->clientData, req->interfaceTag, CSR_RESULT_SUCCESS);
-}
-
-
-void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlConfigurePowerModeReq* req = (CsrWifiRouterCtrlConfigurePowerModeReq*)msg;
-    enum unifi_low_power_mode pm;
-    CsrResult csrResult;
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlConfigurePowerModeReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    if (req->mode == CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED) {
-        pm = UNIFI_LOW_POWER_DISABLED;
-    } else {
-        pm = UNIFI_LOW_POWER_ENABLED;
-    }
-
-    unifi_trace(priv, UDBG2,
-                "CsrWifiRouterCtrlConfigurePowerModeReqHandler (mode=%d, wake=%d)\n",
-                req->mode, req->wakeHost);
-    csrResult = unifi_configure_low_power_mode(priv->card, pm,
-                                               (req->wakeHost ? UNIFI_PERIODIC_WAKE_HOST_ENABLED : UNIFI_PERIODIC_WAKE_HOST_DISABLED));
-}
-
-
-void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlWifiOnRes* res = (CsrWifiRouterCtrlWifiOnRes*)msg;
-
-    if (priv == NULL) {
-        unifi_error(NULL, "CsrWifiRouterCtrlWifiOnResHandler: Invalid ospriv.\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG1,
-                "CsrWifiRouterCtrlWifiOnResHandler: status %d (patch %u)\n", res->status, res->smeVersions.firmwarePatch);
-
-    if (res->smeVersions.firmwarePatch != 0) {
-        unifi_info(priv, "Firmware patch %d\n", res->smeVersions.firmwarePatch);
-    }
-
-    if (res->numInterfaceAddress > CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "WifiOnResHandler bad numInterfaceAddress %d\n", res->numInterfaceAddress);
-        return;
-    }
-
-    /* UniFi is now initialised, complete the init. */
-    if (res->status == CSR_RESULT_SUCCESS)
-    {
-        int i; /* used as a loop counter */
-        u32 intmode = CSR_WIFI_INTMODE_DEFAULT;
-#ifdef CSR_WIFI_SPLIT_PATCH
-        u8 switching_ap_fw = FALSE;
-#endif
-        /* Register the UniFi device with the OS network manager */
-        unifi_trace(priv, UDBG3, "Card Init Completed Successfully\n");
-
-        /* Store the MAC address in the netdev */
-        for(i=0;i<res->numInterfaceAddress;i++)
-        {
-            memcpy(priv->netdev[i]->dev_addr, res->stationMacAddress[i].a, ETH_ALEN);
-        }
-
-        /* Copy version structure into the private versions field */
-        priv->sme_versions = res->smeVersions;
-
-        unifi_trace(priv, UDBG2, "network interfaces count = %d\n",
-                    res->numInterfaceAddress);
-
-        /* Register the netdevs for each interface. */
-        for(i=0;i<res->numInterfaceAddress;i++)
-        {
-            netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-            if(!interfacePriv->netdev_registered)
-            {
-                int r;
-                unifi_trace(priv, UDBG3, "registering net device %d\n", i);
-                r = uf_register_netdev(priv, i);
-                if (r)
-                {
-                    /* unregister the net_device that are registered in the previous iterations */
-                    uf_unregister_netdev(priv);
-                    unifi_error(priv, "Failed to register the network device.\n");
-                    CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE);
-                    return;
-                }
-            }
-#ifdef CSR_WIFI_SPLIT_PATCH
-            else
-            {
-                /* If a netdev is already registered, we have received this WifiOnRes
-                 * in response to switching AP/STA firmware in a ModeSetReq.
-                 * Rememeber this in order to send a ModeSetCfm once
-                 */
-                switching_ap_fw = TRUE;
-            }
-#endif
-        }
-        priv->totalInterfaceCount = res->numInterfaceAddress;
-
-        /* If the MIB has selected f/w scheduled interrupt mode, apply it now
-         * but let module param override.
-         */
-        if (run_bh_once != -1) {
-            intmode = (u32)run_bh_once;
-        } else if (res->scheduledInterrupt) {
-            intmode = CSR_WIFI_INTMODE_RUN_BH_ONCE;
-        }
-        unifi_set_interrupt_mode(priv->card, intmode);
-
-        priv->init_progress = UNIFI_INIT_COMPLETED;
-
-        /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
-        CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_SUCCESS);
-
-#ifdef CSR_WIFI_SPLIT_PATCH
-        if (switching_ap_fw && (priv->pending_mode_set.common.destination != 0xaaaa)) {
-            unifi_info(priv, "Completed firmware reload with %s patch\n",
-                CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode) ? "AP" : "STA");
-
-            /* Confirm the ModeSetReq that requested the AP/STA patch switch */
-            CsrWifiRouterCtrlModeSetCfmSend(priv->pending_mode_set.common.source,
-                                            priv->pending_mode_set.clientData,
-                                            priv->pending_mode_set.interfaceTag,
-                                            priv->pending_mode_set.mode,
-                                            CSR_RESULT_SUCCESS);
-            priv->pending_mode_set.common.destination = 0xaaaa;
-        }
-#endif
-        unifi_info(priv, "UniFi ready\n");
-
-#ifdef ANDROID_BUILD
-        /* Release the wakelock */
-        unifi_trace(priv, UDBG1, "ready: release wake lock\n");
-        wake_unlock(&unifi_sdio_wake_lock);
-#endif
-        /* Firmware initialisation is complete, so let the SDIO bus
-         * clock be raised when convienent to the core.
-         */
-        unifi_request_max_sdio_clock(priv->card);
-
-#ifdef CSR_SUPPORT_WEXT
-        /* Notify the Android wpa_supplicant that we are ready */
-        wext_send_started_event(priv);
-
-        queue_work(priv->unifi_workqueue, &priv->sme_config_task);
-#endif
-
-    } else {
-        /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
-        CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE);
-    }
-}
-
-
-void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-
-void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-
-void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterMaPacketSubscribeReq* req = (CsrWifiRouterMaPacketSubscribeReq*)msg;
-    u8 i;
-    CsrResult result;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterMaPacketSubscribeReqHandler: invalid priv\n");
-        return;
-    }
-
-    /* Look for an unused filter */
-
-    result = CSR_WIFI_RESULT_NO_ROOM;
-    for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
-
-        if (!priv->sme_unidata_ind_filters[i].in_use) {
-
-            priv->sme_unidata_ind_filters[i].in_use = 1;
-            priv->sme_unidata_ind_filters[i].appHandle = msg->source;
-            priv->sme_unidata_ind_filters[i].encapsulation = req->encapsulation;
-            priv->sme_unidata_ind_filters[i].protocol = req->protocol;
-
-            priv->sme_unidata_ind_filters[i].oui[2] = (u8)  (req->oui        & 0xFF);
-            priv->sme_unidata_ind_filters[i].oui[1] = (u8) ((req->oui >>  8) & 0xFF);
-            priv->sme_unidata_ind_filters[i].oui[0] = (u8) ((req->oui >> 16) & 0xFF);
-
-            result = CSR_RESULT_SUCCESS;
-            break;
-        }
-    }
-
-    unifi_trace(priv, UDBG1,
-                "subscribe_req: encap=%d, handle=%d, result=%d\n",
-                req->encapsulation, i, result);
-    CsrWifiRouterMaPacketSubscribeCfmSend(msg->source, req->interfaceTag, i, result, 0);
-}
-
-
-void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterMaPacketUnsubscribeReq* req = (CsrWifiRouterMaPacketUnsubscribeReq*)msg;
-    CsrResult result;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterMaPacketUnsubscribeReqHandler: invalid priv\n");
-        return;
-    }
-
-    result = CSR_WIFI_RESULT_NOT_FOUND;
-
-    if (req->subscriptionHandle < MAX_MA_UNIDATA_IND_FILTERS) {
-        if (priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use) {
-            priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use = 0;
-            result = CSR_RESULT_SUCCESS;
-        } else {
-            result = CSR_WIFI_RESULT_NOT_FOUND;
-        }
-    }
-
-    unifi_trace(priv, UDBG1,
-                "unsubscribe_req: handle=%d, result=%d\n",
-                req->subscriptionHandle, result);
-    CsrWifiRouterMaPacketUnsubscribeCfmSend(msg->source, req->interfaceTag, result);
-}
-
-
-void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlCapabilitiesReq* req = (CsrWifiRouterCtrlCapabilitiesReq*)msg;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlCapabilitiesReqHandler: invalid priv\n");
-        return;
-    }
-
-    CsrWifiRouterCtrlCapabilitiesCfmSend(msg->source, req->clientData,
-            UNIFI_SOFT_COMMAND_Q_LENGTH - 1,
-            UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1);
-}
-
-
-void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlSuspendRes* res = (CsrWifiRouterCtrlSuspendRes*)msg;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlSuspendResHandler: invalid priv\n");
-        return;
-    }
-
-    sme_complete_request(priv, res->status);
-}
-
-
-void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlResumeRes* res = (CsrWifiRouterCtrlResumeRes*)msg;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlResumeResHandler: invalid priv\n");
-        return;
-    }
-
-    sme_complete_request(priv, res->status);
-}
-
-
-void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlTrafficConfigReq* req = (CsrWifiRouterCtrlTrafficConfigReq*)msg;
-    CsrResult csrResult;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlTrafficConfigReqHandler: invalid smepriv\n");
-        return;
-    }
-    if (req->trafficConfigType == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER)
-    {
-        req->config.packetFilter |= CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM;
-    }
-    csrResult = unifi_ta_configure(priv->card, req->trafficConfigType, (const CsrWifiRouterCtrlTrafficConfig *)&req->config);
-}
-
-void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlTrafficClassificationReq* req = (CsrWifiRouterCtrlTrafficClassificationReq*)msg;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlTrafficClassificationReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    unifi_ta_classification(priv->card, req->trafficType, req->period);
-}
-
-static int
-_sys_packet_req(unifi_priv_t *priv, const CSR_SIGNAL *signal,
-        u8 subscriptionHandle,
-        u16 frameLength, u8 *frame,
-        int proto)
-{
-    int r;
-    const sme_ma_unidata_ind_filter_t *subs;
-    bulk_data_param_t bulkdata;
-    CSR_MA_PACKET_REQUEST req = signal->u.MaPacketRequest;
-    struct sk_buff *skb, *newSkb = NULL;
-    CsrWifiMacAddress peerMacAddress;
-    CsrResult csrResult;
-    u16 interfaceTag = req.VirtualInterfaceIdentifier & 0xff;
-    u8 eapolStore = FALSE;
-    s8 protection = 0;
-    netInterface_priv_t *interfacePriv;
-    unsigned long flags;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "_sys_packet_req: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
-        return -EINVAL;
-    }
-    interfacePriv = priv->interfacePriv[interfaceTag];
-    if (!priv->sme_unidata_ind_filters[subscriptionHandle].in_use) {
-        unifi_error(priv, "_sys_packet_req: unknown subscription.\n");
-        return -EINVAL;
-    }
-
-    subs = &priv->sme_unidata_ind_filters[subscriptionHandle];
-    unifi_trace(priv, UDBG1,
-                "_sys_packet_req: handle=%d, subs=%p, encap=%d\n",
-                subscriptionHandle, subs, subs->encapsulation);
-
-    csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], frameLength);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "_sys_packet_req: failed to allocate bulkdata.\n");
-        return (int)CsrHipResultToStatus(csrResult);
-    }
-
-    /* get the peer Mac address */
-    memcpy(&peerMacAddress, frame, ETH_ALEN);
-
-    /* Determine if we need to add encapsulation header */
-    if (subs->encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) {
-        memcpy((void*)bulkdata.d[0].os_data_ptr, frame, frameLength);
-
-        /* The translation is performed on the skb */
-        skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr;
-
-        unifi_trace(priv, UDBG1,
-                    "_sys_packet_req: skb_add_llc_snap -->\n");
-        r = skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto);
-        unifi_trace(priv, UDBG1,
-                    "_sys_packet_req: skb_add_llc_snap <--\n");
-        if (r) {
-            unifi_error(priv,
-                        "_sys_packet_req: failed to translate eth frame.\n");
-            unifi_net_data_free(priv, &bulkdata.d[0]);
-            return r;
-        }
-
-        bulkdata.d[0].data_length = skb->len;
-    } else {
-        /* Crop the MAC addresses from the packet */
-        memcpy((void*)bulkdata.d[0].os_data_ptr, frame + 2*ETH_ALEN, frameLength - 2*ETH_ALEN);
-        bulkdata.d[0].data_length = frameLength - 2*ETH_ALEN;
-        skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr;
-        skb->len = bulkdata.d[0].data_length;
-
-    }
-
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].os_net_buf_ptr = NULL;
-    bulkdata.d[1].data_length = 0;
-
-    /* check for m4 detection */
-    if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) {
-        eapolStore = TRUE;
-    }
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    if (proto == ETH_P_WAI)
-     {
-        protection = 0; /*WAI packets always sent unencrypted*/
-     }
-   else
-     {
-#endif
-
-#ifdef CSR_SUPPORT_SME
-    if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, peerMacAddress.a)) < 0) {
-        unifi_error(priv, "unicast address, but destination not in station record database\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return -1;
-    }
-#else
-    protection = 0;
-#endif
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    }
-#endif
-
-    /* add Mac header */
-    if (prepare_and_add_macheader(priv, skb, newSkb, req.Priority, &bulkdata, interfaceTag, frame, frame + ETH_ALEN, protection)) {
-        unifi_error(priv, "failed to create MAC header\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return -1;
-    }
-
-    if (eapolStore) {
-        spin_lock_irqsave(&priv->m4_lock, flags);
-        /* Store the EAPOL M4 packet for later */
-        interfacePriv->m4_signal = *signal;
-        interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
-        interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length;
-        interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
-        interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
-        spin_unlock_irqrestore(&priv->m4_lock, flags);
-        /* Send a signal to SME */
-        unifi_trace(priv, UDBG1, "_sys_packet_req: Sending CsrWifiRouterCtrlM4ReadyToSendInd\n");
-        CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
-        return 0;
-    }
-
-    /* Send the signal to UniFi */
-      /* Set the B31 to 1 for local routing*/
-    r= uf_process_ma_packet_req(priv,  peerMacAddress.a, (req.HostTag | 0x80000000), interfaceTag, 0,
-                                (CSR_RATE)0, req.Priority, signal->SignalPrimitiveHeader.SenderProcessId, &bulkdata);
-    if (r) {
-        unifi_error(priv,
-                    "_sys_packet_req: failed to send signal.\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return r;
-    }
-    /* The final CsrWifiRouterMaPacketCfmSend() will called when the actual MA-PACKET.cfm is received from the chip */
-
-    return 0;
-}
-
-void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    int r;
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterMaPacketReq* mareq = (CsrWifiRouterMaPacketReq*)msg;
-    llc_snap_hdr_t *snap;
-    u16 snap_protocol;
-    CSR_SIGNAL signal;
-    CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
-    CsrWifiRouterCtrlPortAction controlPortaction;
-    u8 *daddr, *saddr;
-    u16 interfaceTag = mareq->interfaceTag & 0x00ff;
-    int queue;
-    netInterface_priv_t *interfacePriv;
-
-    if (!mareq->frame || !priv || !priv->smepriv)
-    {
-        unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: invalid frame/priv/priv->smepriv\n");
-        return;
-    }
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-    /* get a pointer to dest & source Mac address */
-    daddr = mareq->frame;
-    saddr = (mareq->frame + ETH_ALEN);
-    /* point to the proper position of frame, since frame has MAC header */
-    snap = (llc_snap_hdr_t *) (mareq->frame + 2 * ETH_ALEN);
-    snap_protocol = ntohs(snap->protocol);
-    if((snap_protocol == ETH_P_PAE)
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-       || (snap_protocol == ETH_P_WAI)
-#endif
-    )
-    {
-        queue = UF_UNCONTROLLED_PORT_Q;
-    }
-    else
-    {
-        queue = UF_CONTROLLED_PORT_Q;
-    }
-
-    /* Controlled port restrictions apply to the packets */
-    controlPortaction = uf_sme_port_state(priv, daddr, queue, interfaceTag);
-    if (controlPortaction != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)
-    {
-        unifi_warning(priv, "CsrWifiRouterMaPacketReqHandler: (%s)controlled port is closed.\n", (queue == UF_CONTROLLED_PORT_Q)?"":"un");
-        if(mareq->cfmRequested)
-        {
-            CsrWifiRouterMaPacketCfmSend(msg->source,
-                                     interfaceTag,
-                                     CSR_RESULT_FAILURE,
-                                     mareq->hostTag, 0);
-        }
-        return;
-    }
-
-    signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
-    /* Store the appHandle in the LSB of the SenderId. */
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->sme_cli->sender_id & 0xff00) | (unsigned int)msg->source),
-                                     (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
-    signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
-
-    /* Fill in the MA-PACKET.req signal */
-    memcpy(req->Ra.x, daddr, ETH_ALEN);
-    req->Priority = mareq->priority;
-    req->TransmitRate = 0; /* Let firmware select the rate*/
-    req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag);
-    req->HostTag = mareq->hostTag;
-
-    if(mareq->cfmRequested)
-        req->TransmissionControl = 0;
-    else
-        req->TransmissionControl = CSR_NO_CONFIRM_REQUIRED;
-
-    r = _sys_packet_req(priv, &signal, mareq->subscriptionHandle,
-            mareq->frameLength, mareq->frame, snap_protocol);
-
-    if (r && mareq->cfmRequested)
-    {
-        CsrWifiRouterMaPacketCfmSend(msg->source, interfaceTag,
-                                     CSR_RESULT_FAILURE,
-                                     mareq->hostTag, 0);
-    }
-    return;
-}
-
-void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlM4TransmitReq* req = (CsrWifiRouterCtrlM4TransmitReq*)msg;
-    int r;
-    bulk_data_param_t bulkdata;
-    netInterface_priv_t *interfacePriv;
-    CSR_SIGNAL m4_signal;
-    unsigned long flags;
-
-    if (priv == NULL) {
-        unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid smepriv\n");
-        return;
-    }
-    if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "M4TransmitReqHandler: interfaceTag >= CSR_WIFI_NUM_INTERFACES\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[req->interfaceTag];
-    spin_lock_irqsave(&priv->m4_lock, flags);
-    if (interfacePriv->m4_bulk_data.data_length == 0) {
-        spin_unlock_irqrestore(&priv->m4_lock, flags);
-        unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid buffer\n");
-        return;
-    }
-
-    memcpy(&bulkdata.d[0], &interfacePriv->m4_bulk_data, sizeof(bulk_data_desc_t));
-
-    interfacePriv->m4_bulk_data.net_buf_length = 0;
-    interfacePriv->m4_bulk_data.data_length = 0;
-    interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
-    m4_signal = interfacePriv->m4_signal;
-    spin_unlock_irqrestore(&priv->m4_lock, flags);
-
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].data_length = 0;
-
-    interfacePriv->m4_sent = TRUE;
-    m4_signal.u.MaPacketRequest.HostTag |= 0x80000000;
-    /* Store the hostTag for later varification */
-    interfacePriv->m4_hostTag = m4_signal.u.MaPacketRequest.HostTag;
-    r = ul_send_signal_unpacked(priv, &m4_signal, &bulkdata);
-    unifi_trace(priv, UDBG1,
-                "CsrWifiRouterCtrlM4TransmitReqHandler: sent\n");
-    if (r) {
-        unifi_error(priv,
-                    "CsrWifiRouterCtrlM4TransmitReqHandler: failed to send signal.\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-    }
-}
-
-/* reset the station records when the mode is set as CSR_WIFI_ROUTER_CTRL_MODE_NONE */
-static void CsrWifiRouterCtrlResetStationRecordList(unifi_priv_t *priv, u16 interfaceTag)
-{
-    u8 i, j;
-    CsrWifiRouterCtrlStaInfo_t *staInfo=NULL;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    unsigned long lock_flags;
-
-    /* create a list for sending confirms of un-delivered packets */
-    struct list_head send_cfm_list;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "CsrWifiRouterCtrlResetStationRecordList: bad interfaceTag\n");
-        return;
-    }
-
-    INIT_LIST_HEAD(&send_cfm_list);
-
-    /* Reset the station record to NULL if mode is NONE */
-    for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        if ((staInfo=interfacePriv->staInfo[i]) != NULL) {
-            uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                 &send_cfm_list,
-                                                 &(staInfo->mgtFrames));
-            uf_flush_list(priv, &(staInfo->mgtFrames));
-            for(j=0;j<MAX_ACCESS_CATOGORY;j++){
-                uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                     &send_cfm_list,
-                                                     &(staInfo->dataPdu[j]));
-                uf_flush_list(priv, &(staInfo->dataPdu[j]));
-            }
-
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            /* Removing station record information from port config array */
-            memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t));
-            staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-            staInfo->peerControlledPort->in_use = FALSE;
-            interfacePriv->controlled_data_port.entries_in_use--;
-
-            memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t));
-            staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-            staInfo->peerUnControlledPort->in_use = FALSE;
-            interfacePriv->uncontrolled_data_port.entries_in_use--;
-
-            kfree(interfacePriv->staInfo[i]);
-            interfacePriv->staInfo[i] = NULL;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }
-    }
-    /* after the critical region process the list of frames that requested cfm
-     * and send cfm to requestor one by one
-     */
-    send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
-
-#ifdef CSR_SUPPORT_SME
-    /* Interface Independent, no of packet queued, incase of mode is None or AP set to 0 */
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-        case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
-            if (priv->noOfPktQueuedInDriver) {
-                unifi_warning(priv, "After reset the noOfPktQueuedInDriver = %x\n", priv->noOfPktQueuedInDriver);
-                spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                priv->noOfPktQueuedInDriver = 0;
-                spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-            }
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            break;
-        default:
-            unifi_error(priv, "interfacemode is not correct in CsrWifiRouterCtrlResetStationRecordList: debug\n");
-    }
-#endif
-
-    if (((interfacePriv->controlled_data_port.entries_in_use != 0) || (interfacePriv->uncontrolled_data_port.entries_in_use != 0))
-            && (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE)) {
-        /* Print in case if the value of entries goes to -ve/+ve (apart from 0)
-         * we expect the entries should be zero here if mode is set as NONE
-         */
-        unifi_trace(priv, UDBG3, "In %s controlled port entries = %d, uncontrolled port entries = %d\n",
-                   __FUNCTION__, interfacePriv->controlled_data_port.entries_in_use,
-                   interfacePriv->uncontrolled_data_port.entries_in_use);
-    }
-}
-
-void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag)
-{
-    netInterface_priv_t *interfacePriv;
-
-    /* create a list for sending confirms of un-delivered packets */
-    struct list_head send_cfm_list;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "CsrWifiRouterCtrlInterfaceReset: bad interfaceTag\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    INIT_LIST_HEAD(&send_cfm_list);
-
-    /* Enable all queues by default */
-    interfacePriv->queueEnabled[0] = 1;
-    interfacePriv->queueEnabled[1] = 1;
-    interfacePriv->queueEnabled[2] = 1;
-    interfacePriv->queueEnabled[3] = 1;
-
-    uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                             &send_cfm_list,
-                                             &(interfacePriv->genericMgtFrames));
-    uf_flush_list(priv, &(interfacePriv->genericMgtFrames));
-
-    uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                             &send_cfm_list,
-                                             &(interfacePriv->genericMulticastOrBroadCastMgtFrames));
-    uf_flush_list(priv, &(interfacePriv->genericMulticastOrBroadCastMgtFrames));
-
-    uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                             &send_cfm_list,
-                                             &(interfacePriv->genericMulticastOrBroadCastFrames));
-
-    uf_flush_list(priv, &(interfacePriv->genericMulticastOrBroadCastFrames));
-
-    /*  process the list of frames that requested cfm
-    and send cfm to requestor one by one */
-    send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
-
-    /* Reset the station record to NULL if mode is tried to set as NONE */
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-        case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
-        case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
-            /* station records not available in these modes */
-            break;
-        default:
-            CsrWifiRouterCtrlResetStationRecordList(priv, interfaceTag);
-    }
-
-    interfacePriv->num_stations_joined = 0;
-    interfacePriv->sta_activity_check_enabled = FALSE;
-}
-
-
-void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlModeSetReq* req = (CsrWifiRouterCtrlModeSetReq*)msg;
-
-    if (priv == NULL)
-    {
-        unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    if (req->interfaceTag < CSR_WIFI_NUM_INTERFACES)
-    {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-#ifdef CSR_WIFI_SPLIT_PATCH
-        u8 old_mode = interfacePriv->interfaceMode;
-#endif
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlModeSetReqHandler: interfacePriv->interfaceMode = %d\n",
-                interfacePriv->interfaceMode);
-
-        interfacePriv->interfaceMode = req->mode;
-
-#ifdef CSR_WIFI_SPLIT_PATCH
-        /* Detect a change in mode that requires a switch to/from the AP firmware patch.
-         * This should only happen when transitioning in/out of AP modes.
-         */
-        if (CSR_WIFI_HIP_IS_AP_FW(req->mode) != CSR_WIFI_HIP_IS_AP_FW(old_mode))
-        {
-            CsrWifiRouterCtrlVersions versions;
-            int r;
-
-#ifdef ANDROID_BUILD
-            /* Take the wakelock while switching patch */
-            unifi_trace(priv, UDBG1, "patch switch: take wake lock\n");
-            wake_lock(&unifi_sdio_wake_lock);
-#endif
-            unifi_info(priv, "Resetting UniFi with %s patch\n", CSR_WIFI_HIP_IS_AP_FW(req->mode) ? "AP" : "STA");
-
-            r = uf_request_firmware_files(priv, UNIFI_FW_STA);
-            if (r) {
-                unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: Failed to get f/w\n");
-                CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
-                                                req->mode, CSR_RESULT_FAILURE);
-                return;
-            }
-
-            /* Block the I/O thread */
-            priv->bh_thread.block_thread = 1;
-
-            /* Reset and download the new patch */
-            r = uf_init_hw(priv);
-            if (r) {
-                unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
-                CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
-                                                req->mode, CSR_RESULT_FAILURE);
-                return;
-            }
-
-            /* Re-enable the I/O thread */
-            priv->bh_thread.block_thread = 0;
-
-            /* Get the version information from the core */
-            unifi_card_info(priv->card, &priv->card_info);
-
-            /* Copy to the unifiio_card_info structure. */
-            versions.chipId = priv->card_info.chip_id;
-            versions.chipVersion = priv->card_info.chip_version;
-            versions.firmwareBuild = priv->card_info.fw_build;
-            versions.firmwareHip = priv->card_info.fw_hip_version;
-            versions.routerBuild = (char*)CSR_WIFI_VERSION;
-            versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION;
-
-            /* Now that new firmware is running, send a WifiOnInd to the NME. This will
-             * cause it to retransfer the MIB.
-             */
-            CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions);
-
-            /* Store the request so we know where to send the ModeSetCfm */
-            priv->pending_mode_set = *req;
-        }
-        else
-#endif
-        {
-            /* No patch switch, confirm straightaway */
-            CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
-                                            req->mode, CSR_RESULT_SUCCESS);
-        }
-
-        interfacePriv->bssid = req->bssid;
-        /* For modes other than AP/P2PGO, set below member FALSE */
-        interfacePriv->intraBssEnabled = FALSE;
-        /* Initialise the variable bcTimSet with a value
-         * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
-         */
-        interfacePriv->bcTimSet = 0xFF;
-        interfacePriv->bcTimSetReqPendingFlag = FALSE;
-        /* Initialise the variable bcTimSetReqQueued with a value
-         * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
-         */
-        interfacePriv->bcTimSetReqQueued =0xFF;
-        CsrWifiRouterCtrlInterfaceReset(priv, req->interfaceTag);
-
-        if(req->mode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-           req->mode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-            interfacePriv->protect = req->protection;
-            interfacePriv->dtimActive=FALSE;
-            interfacePriv->multicastPduHostTag = 0xffffffff;
-            /* For AP/P2PGO mode SME sending intraBssDistEnabled
-             * i.e. for AP: intraBssDistEnabled = TRUE, for P2PGO
-             * intraBssDistEnabled = TRUE/FALSE on requirement
-             */
-            interfacePriv->intraBssEnabled = req->intraBssDistEnabled;
-            unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlModeSetReqHandler: IntraBssDisEnabled = %d\n",
-                        req->intraBssDistEnabled);
-        } else if (req->mode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
-              netif_carrier_off(priv->netdev[req->interfaceTag]);
-              interfacePriv->connected = UnifiConnectedUnknown;
-        }
-    }
-    else {
-        unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid interfaceTag :%d\n", req->interfaceTag);
-    }
-}
-
-void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-}
-
-/* delete the station record from the station record data base */
-static int peer_delete_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerDelReq *req)
-{
-    u8 j;
-    CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
-    unifi_port_config_t *controlledPort;
-    unifi_port_config_t *unControlledPort;
-    netInterface_priv_t *interfacePriv;
-
-    u8 ba_session_idx = 0;
-    ba_session_rx_struct *ba_session_rx = NULL;
-    ba_session_tx_struct *ba_session_tx = NULL;
-
-    /* create a list for sending confirms of un-delivered packets */
-    struct list_head send_cfm_list;
-
-    unsigned long lock_flags;
-
-    if ((req->peerRecordHandle >= UNIFI_MAX_CONNECTIONS) || (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
-        unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", req->peerRecordHandle, req->interfaceTag);
-        return CSR_RESULT_FAILURE;
-    }
-
-    INIT_LIST_HEAD(&send_cfm_list);
-
-    interfacePriv = priv->interfacePriv[req->interfaceTag];
-    /* remove the station record & make it NULL */
-    if ((staInfo=interfacePriv->staInfo[req->peerRecordHandle])!=NULL) {
-
-        uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                 &send_cfm_list,
-                                                 &(staInfo->mgtFrames));
-
-        uf_flush_list(priv, &(staInfo->mgtFrames));
-        for(j=0;j<MAX_ACCESS_CATOGORY;j++){
-            uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                     &send_cfm_list,
-                                                     &(staInfo->dataPdu[j]));
-            uf_flush_list(priv, &(staInfo->dataPdu[j]));
-        }
-
-        spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-        /* clear the port configure array info, for the corresponding peer entry */
-        controlledPort = &interfacePriv->controlled_data_port;
-        unControlledPort = &interfacePriv->uncontrolled_data_port;
-
-        unifi_trace(priv, UDBG1, "peer_delete_record: Peer found handle = %d, port in use: cont(%d), unCont(%d)\n",
-                    req->peerRecordHandle, controlledPort->entries_in_use, unControlledPort->entries_in_use);
-
-        memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t));
-        staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-        staInfo->peerControlledPort->in_use = FALSE;
-        if (controlledPort->entries_in_use) {
-            controlledPort->entries_in_use--;
-        } else {
-            unifi_warning(priv, "number of controlled port entries is zero, trying to decrement: debug\n");
-        }
-
-        memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t));
-        staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-        staInfo->peerUnControlledPort->in_use = FALSE;
-        if (unControlledPort->entries_in_use) {
-            unControlledPort->entries_in_use--;
-        } else {
-            unifi_warning(priv, "number of uncontrolled port entries is zero, trying to decrement: debug\n");
-        }
-
-        spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        /* update the TIM with zero */
-        if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS &&
-                staInfo->timSet == CSR_WIFI_TIM_SET) {
-            unifi_trace(priv, UDBG3, "peer is deleted so TIM updated to 0, in firmware\n");
-            update_tim(priv, staInfo->aid, 0, req->interfaceTag, req->peerRecordHandle);
-        }
-
-
-        /* Stop BA session if it is active, for this peer address all BA sessions
-        (per tID per role) are closed */
-
-        down(&priv->ba_mutex);
-        for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
-            ba_session_rx = priv->interfacePriv[req->interfaceTag]->ba_session_rx[ba_session_idx];
-            if(ba_session_rx) {
-                if(!memcmp(ba_session_rx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){
-                    blockack_session_stop(priv,
-                                        req->interfaceTag,
-                                        CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT,
-                                        ba_session_rx->tID,
-                                        ba_session_rx->macAddress);
-                }
-            }
-        }
-
-        for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
-            ba_session_tx = priv->interfacePriv[req->interfaceTag]->ba_session_tx[ba_session_idx];
-            if(ba_session_tx) {
-                if(!memcmp(ba_session_tx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){
-                    blockack_session_stop(priv,
-                                        req->interfaceTag,
-                                        CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR,
-                                        ba_session_tx->tID,
-                                        ba_session_tx->macAddress);
-                }
-            }
-        }
-
-        up(&priv->ba_mutex);
-
-#ifdef CSR_SUPPORT_SME
-        unifi_trace(priv, UDBG1, "Canceling work queue for STA with AID: %d\n", staInfo->aid);
-        cancel_work_sync(&staInfo->send_disconnected_ind_task);
-#endif
-
-        spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-#ifdef CSR_SUPPORT_SME
-        interfacePriv->num_stations_joined--;
-
-        staInfo->nullDataHostTag = INVALID_HOST_TAG;
-
-        if ((interfacePriv->sta_activity_check_enabled) &&
-            (interfacePriv->num_stations_joined < STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD))
-        {
-            unifi_trace(priv, UDBG1, "STOPPING the Inactivity Timer (num of stations = %d)\n", interfacePriv->num_stations_joined);
-            interfacePriv->sta_activity_check_enabled = FALSE;
-            del_timer_sync(&interfacePriv->sta_activity_check_timer);
-        }
-#endif
-
-        /* Free the station record for corresponding peer */
-        kfree(interfacePriv->staInfo[req->peerRecordHandle]);
-        interfacePriv->staInfo[req->peerRecordHandle] = NULL;
-        spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-        /* after the critical region process the list of frames that requested cfm
-        and send cfm to requestor one by one */
-        send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
-
-
-    }
-    else
-    {
-        unifi_trace(priv, UDBG3, " peer not found: Delete request Peer handle[%d]\n", req->peerRecordHandle);
-    }
-
-    return CSR_RESULT_SUCCESS;
-}
-
-void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    CsrWifiRouterCtrlPeerDelReq* req = (CsrWifiRouterCtrlPeerDelReq*)msg;
-    CsrResult status = CSR_RESULT_SUCCESS;
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    netInterface_priv_t *interfacePriv;
-
-    unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler\n");
-    if (priv == NULL)
-    {
-        unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: bad interfaceTag\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            /* remove the station from station record data base */
-            status = peer_delete_record(priv, req);
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-        default:
-            /* No station record to maintain in these modes */
-            break;
-    }
-
-    CsrWifiRouterCtrlPeerDelCfmSend(msg->source, req->clientData, req->interfaceTag, status);
-    unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerDelReqHandler \n");
-}
-
-/* Add the new station to the station record data base */
-static int peer_add_new_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerAddReq *req, u32 *handle)
-{
-    u8 i, powerModeTemp = 0;
-    u8 freeSlotFound = FALSE;
-    CsrWifiRouterCtrlStaInfo_t *newRecord = NULL;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-    u32 currentTime, currentTimeHi;
-    unsigned long lock_flags;
-
-    if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "peer_add_new_record: bad interfaceTag\n");
-        return CSR_RESULT_FAILURE;
-    }
-
-    currentTime = CsrTimeGet(&currentTimeHi);
-
-    for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        if(interfacePriv->staInfo[i] == NULL) {
-            /* Slot is empty, so can be used for station record */
-            freeSlotFound = TRUE;
-            *handle = i;
-
-            /* Allocate for the new station record , to avoid race condition would happen between ADD_PEER &
-             * DEL_PEER the allocation made atomic memory rather than kernel memory
-             */
-            newRecord = kmalloc(sizeof(CsrWifiRouterCtrlStaInfo_t), GFP_ATOMIC);
-            if (!newRecord) {
-                unifi_error(priv, "failed to allocate the %d bytes of mem for station record\n",
-                            sizeof(CsrWifiRouterCtrlStaInfo_t));
-                return CSR_RESULT_FAILURE;
-            }
-
-            unifi_trace(priv, UDBG1, "peer_add_new_record: handle = %d AID = %d addr = %x:%x:%x:%x:%x:%x LI=%u\n",
-                        *handle, req->associationId, req->peerMacAddress.a[0], req->peerMacAddress.a[1], req->peerMacAddress.a[2],
-                        req->peerMacAddress.a[3], req->peerMacAddress.a[4], req->peerMacAddress.a[5],
-                        req->staInfo.listenIntervalInTus);
-
-            /* disable the preemption until station record updated */
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-
-            interfacePriv->staInfo[i] = newRecord;
-            /* Initialize the record*/
-            memset(newRecord, 0, sizeof(CsrWifiRouterCtrlStaInfo_t));
-            /* update the station record */
-            memcpy(newRecord->peerMacAddress.a, req->peerMacAddress.a, ETH_ALEN);
-            newRecord->wmmOrQosEnabled = req->staInfo.wmmOrQosEnabled;
-
-            /* maxSpLength is bit map in qosInfo field, so converting accordingly */
-            newRecord->maxSpLength = req->staInfo.maxSpLength * 2;
-
-            /*Max SP 0 mean any number of packets. since we buffer only 512
-            packets we are hard coding this to zero for the moment */
-
-            if(newRecord->maxSpLength == 0)
-                newRecord->maxSpLength=512;
-
-            newRecord->assignedHandle = i;
-
-             /* copy power save mode of all access catagory (Trigger/Delivery/both enabled/disabled) */
-            powerModeTemp = (u8) ((req->staInfo.powersaveMode >> 4) & 0xff);
-
-            if(!(req->staInfo.powersaveMode & 0x0001))
-                newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
-            else
-               newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= powerModeTemp & 0x03;
-
-            if(!(req->staInfo.powersaveMode & 0x0002))
-                newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
-            else
-               newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= ((powerModeTemp & 0x0C)>> 2);
-
-            if(!(req->staInfo.powersaveMode & 0x0004))
-                newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
-            else
-               newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= ((powerModeTemp & 0x30)>> 4);
-
-            if(!(req->staInfo.powersaveMode & 0x0008))
-                newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
-            else
-               newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= ((powerModeTemp & 0xC0)>> 6);
-
-            {
-                u8 k;
-                for(k=0; k< MAX_ACCESS_CATOGORY ;k++)
-                    unifi_trace(priv, UDBG2, "peer_add_new_record: WMM : %d ,AC %d, powersaveMode %x \n",
-                            req->staInfo.wmmOrQosEnabled, k, newRecord->powersaveMode[k]);
-            }
-
-            unifi_trace(priv, UDBG3, "newRecord->wmmOrQosEnabled : %d , MAX SP : %d\n",
-                    newRecord->wmmOrQosEnabled, newRecord->maxSpLength);
-
-            /* Initialize the mgtFrames & data Pdu list */
-            {
-                u8 j;
-                INIT_LIST_HEAD(&newRecord->mgtFrames);
-                for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
-                    INIT_LIST_HEAD(&newRecord->dataPdu[j]);
-                }
-            }
-
-            newRecord->lastActivity = currentTime;
-            newRecord->activity_flag = TRUE;
-
-            /* enable the preemption as station record updated */
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-            /* First time port actions are set for the peer with below information */
-            configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress,
-                                UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
-
-            if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS) {
-                configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress,
-                                    UF_CONTROLLED_PORT_Q, req->interfaceTag);
-            } else {
-                configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD, &newRecord->peerMacAddress,
-                                    UF_CONTROLLED_PORT_Q, req->interfaceTag);
-            }
-
-
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            /* Port status must be already set before calling the Add Peer request */
-            newRecord->peerControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a,
-                                                                      UF_CONTROLLED_PORT_Q, req->interfaceTag);
-            newRecord->peerUnControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a,
-                                                                        UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
-
-            if (!newRecord->peerControlledPort || !newRecord->peerUnControlledPort) {
-                /* enable the preemption as station record failed to update */
-                unifi_warning(priv, "Un/ControlledPort record not found in port configuration array index = %d\n", i);
-                kfree(interfacePriv->staInfo[i]);
-                interfacePriv->staInfo[i] = NULL;
-                spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-                return CSR_RESULT_FAILURE;
-            }
-
-            newRecord->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
-
-            /* changes done during block ack handling */
-            newRecord->txSuspend = FALSE;
-
-            /*U-APSD related data structure*/
-            newRecord->timRequestPendingFlag = FALSE;
-
-            /* Initialise the variable updateTimReqQueued with a value
-             * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
-             */
-            newRecord->updateTimReqQueued = 0xFF;
-            newRecord->timSet = CSR_WIFI_TIM_RESET;
-            newRecord->uapsdActive = FALSE;
-            newRecord->noOfSpFramesSent =0;
-            newRecord->triggerFramePriority = CSR_QOS_UP0;
-
-            /* The protection bit is updated once the port opens for corresponding peer in
-             * routerPortConfigure request */
-
-            /* update the association ID */
-            newRecord->aid = req->associationId;
-
-#ifdef CSR_SUPPORT_SME
-            interfacePriv->num_stations_joined++;
-            newRecord->interfacePriv = interfacePriv;
-            newRecord->listenIntervalInTus = req->staInfo.listenIntervalInTus;
-            newRecord->nullDataHostTag = INVALID_HOST_TAG;
-
-            INIT_WORK(&newRecord->send_disconnected_ind_task, uf_send_disconnected_ind_wq);
-
-            if(!(interfacePriv->sta_activity_check_enabled) &&
-               (interfacePriv->num_stations_joined >= STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD)){
-                unifi_trace(priv, UDBG1,
-                            "peer_add_new_record: STARTING the Inactivity Timer (num of stations = %d)",
-                            interfacePriv->num_stations_joined);
-
-                interfacePriv->sta_activity_check_enabled = TRUE;
-                interfacePriv->sta_activity_check_timer.function = check_inactivity_timer_expire_func;
-                interfacePriv->sta_activity_check_timer.data = (unsigned long)interfacePriv;
-
-                init_timer(&interfacePriv->sta_activity_check_timer);
-                mod_timer(&interfacePriv->sta_activity_check_timer,
-                          (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000)));
-
-            }
-#endif
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-            break;
-        }
-    }
-
-    if(!freeSlotFound) {
-        unifi_error(priv, "Limited connectivity, Free slot not found for station record addition\n");
-        return CSR_RESULT_FAILURE;
-    }
-    return CSR_RESULT_SUCCESS;
-}
-
-#ifdef CSR_SUPPORT_SME
-static void check_inactivity_timer_expire_func(unsigned long data)
-{
-    struct unifi_priv *priv;
-    CsrWifiRouterCtrlStaInfo_t *sta_record = NULL;
-    u8 i = 0;
-    u32 now;
-    u32 inactive_time;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *) data;
-
-    if (!interfacePriv)
-    {
-        return;
-    }
-
-    priv = interfacePriv->privPtr;
-
-    if (interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "check_inactivity_timer_expire_func: Invalid interfaceTag\n");
-        return;
-    }
-
-    /* RUN Algorithm to check inactivity for each connected station */
-    now = CsrTimeGet(NULL);
-
-    for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        if(interfacePriv->staInfo[i] != NULL) {
-            sta_record = interfacePriv->staInfo[i];
-
-            if (sta_record->activity_flag == TRUE){
-                sta_record->activity_flag = FALSE;
-                sta_record->lastActivity = now;
-                continue;
-            }
-
-            if (sta_record->lastActivity > now)
-            {
-                /* simple timer wrap (for 1 wrap) */
-                inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, sta_record->lastActivity), now);
-            }
-            else
-            {
-                inactive_time = (u32)CsrTimeSub(now, sta_record->lastActivity);
-            }
-
-            if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
-            {
-                unifi_trace(priv, UDBG1, "STA is Inactive - AID = %d inactive_time = %d\n",
-                                        sta_record->aid,
-                                        inactive_time);
-
-                /* station is in-active, if it is in active mode send a null frame
-                 * and the station should acknowledge the null frame, if acknowledgement
-                 * is not received throw out the station.
-                 * If the station is in Power Save, update TIM for the station so
-                 * that it wakes up and register some activity through PS-Poll or
-                 * trigger frame.
-                 */
-                 if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
-                 {
-                    unifi_trace(priv, UDBG1, "STA power save state - Active, send a NULL frame to check if it is ALIVE\n");
-                    uf_send_nulldata ( priv,
-                                       sta_record->interfacePriv->InterfaceTag,
-                                       sta_record->peerMacAddress.a,
-                                       CSR_CONTENTION,
-                                       sta_record);
-                 }
-                 else if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
-                 {
-                    if((sta_record->timSet == CSR_WIFI_TIM_SET) ||
-                       (sta_record->timSet == CSR_WIFI_TIM_SETTING))
-                    {
-                        unifi_trace(priv, UDBG1, "STA power save state - PS, TIM is already SET\n");
-
-                        /* If TIM is set and we do not have any activity for
-                         * more than 3 listen intervals then send a disconnected
-                         * indication to SME, to delete the station from station
-                         * record list.
-                         * The inactivity is already more than STA_INACTIVE_TIMEOUT_VAL
-                         * and this check ensures if the listen interval is a larger
-                         * value than STA_INACTIVE_TIMEOUT_VAL.
-                         */
-                         if (inactive_time > (3 * (sta_record->listenIntervalInTus * 1024)))
-                         {
-                            unifi_trace(priv, UDBG1, "STA is inactive for more than 3 listen intervals\n");
-                            queue_work( priv->unifi_workqueue,
-                                        &sta_record->send_disconnected_ind_task);
-                         }
-
-                    }
-                    else
-                    {
-                        unifi_trace(priv, UDBG1, "STA power save state - PS, update TIM to see if it is ALIVE\n");
-                        update_tim(priv,
-                                   sta_record->aid,
-                                   CSR_WIFI_TIM_SET,
-                                   interfacePriv->InterfaceTag,
-                                   sta_record->assignedHandle);
-                    }
-                 }
-            }
-        }
-    }
-
-    /* re-run the timer interrupt */
-    mod_timer(&interfacePriv->sta_activity_check_timer,
-              (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000)));
-
-}
-
-
-void uf_send_disconnected_ind_wq(struct work_struct *work)
-{
-
-    CsrWifiRouterCtrlStaInfo_t *staInfo = container_of(work, CsrWifiRouterCtrlStaInfo_t, send_disconnected_ind_task);
-    unifi_priv_t *priv;
-    u16 interfaceTag;
-    struct list_head send_cfm_list;
-    u8 j;
-
-    if(!staInfo) {
-        return;
-    }
-
-    if(!staInfo->interfacePriv) {
-        return;
-    }
-
-    priv = staInfo->interfacePriv->privPtr;
-    interfaceTag =  staInfo->interfacePriv->InterfaceTag;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_send_disconnected_ind_wq: invalid interfaceTag\n");
-        return;
-    }
-
-    /* The SME/NME may be waiting for confirmation for requested frames to this station.
-     * So loop through buffered frames for this station and if confirmation is
-     * requested, send auto confirmation with failure status. Also flush the frames so
-     * that these are not processed again in PEER_DEL_REQ handler.
-     */
-    INIT_LIST_HEAD(&send_cfm_list);
-
-    uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                             &send_cfm_list,
-                                             &(staInfo->mgtFrames));
-
-    uf_flush_list(priv, &(staInfo->mgtFrames));
-
-    for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
-        uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                 &send_cfm_list,
-                                                 &(staInfo->dataPdu[j]));
-
-        uf_flush_list(priv, &(staInfo->dataPdu[j]));
-    }
-
-    send_auto_ma_packet_confirm(priv, staInfo->interfacePriv, &send_cfm_list);
-
-    unifi_warning(priv, "uf_send_disconnected_ind_wq: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
-                staInfo->peerMacAddress.a[0],
-                staInfo->peerMacAddress.a[1],
-                staInfo->peerMacAddress.a[2],
-                staInfo->peerMacAddress.a[3],
-                staInfo->peerMacAddress.a[4],
-                staInfo->peerMacAddress.a[5]);
-
-    CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
-                                      0,
-                                      staInfo->interfacePriv->InterfaceTag,
-                                      staInfo->peerMacAddress,
-                                      CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
-
-
-    return;
-}
-
-
-#endif
-void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    CsrWifiRouterCtrlPeerAddReq* req = (CsrWifiRouterCtrlPeerAddReq*)msg;
-    CsrResult status = CSR_RESULT_SUCCESS;
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    u32 handle = 0;
-    netInterface_priv_t *interfacePriv;
-
-    unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerAddReqHandler \n");
-    if (priv == NULL)
-    {
-        unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-    {
-        unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: bad interfaceTag\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            /* Add station record */
-            status = peer_add_new_record(priv, req, &handle);
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-        default:
-            /* No station record to maintain in these modes */
-            break;
-    }
-
-    CsrWifiRouterCtrlPeerAddCfmSend(msg->source, req->clientData, req->interfaceTag, req->peerMacAddress, handle, status);
-    unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerAddReqHandler \n");
-}
-
-void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    CsrWifiRouterCtrlPeerUpdateReq* req = (CsrWifiRouterCtrlPeerUpdateReq*)msg;
-    CsrResult status = CSR_RESULT_SUCCESS;
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-
-    unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerUpdateReqHandler \n");
-    if (priv == NULL)
-    {
-        unifi_error(priv, "CsrWifiRouterCtrlPeerUpdateReqHandler: invalid smepriv\n");
-        return;
-    }
-
-    CsrWifiRouterCtrlPeerUpdateCfmSend(msg->source, req->clientData, req->interfaceTag, status);
-    unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerUpdateReqHandler \n");
-}
-
-
- void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    /* This will never be called as it is intercepted in the Userspace */
-}
-
-void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    /* This will never be called as it is intercepted in the Userspace */
-}
-
-void
-uf_send_ba_err_wq(struct work_struct *work)
-{
-    ba_session_rx_struct *ba_session = container_of(work, ba_session_rx_struct, send_ba_err_task);
-    unifi_priv_t *priv;
-
-    if(!ba_session) {
-        return;
-    }
-
-    if(!ba_session->interfacePriv) {
-        return;
-    }
-
-    priv = ba_session->interfacePriv->privPtr;
-
-    if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__);
-        return;
-    }
-
-    unifi_warning(priv, "%s: Calling CsrWifiRouterCtrlBlockAckErrorIndSend(%d, %d, %d, %d, %x:%x:%x:%x:%x:%x, %d)\n",
-                    __FUNCTION__,
-                    priv->CSR_WIFI_SME_IFACEQUEUE,
-                    0,
-                    ba_session->interfacePriv->InterfaceTag,
-                    ba_session->tID,
-                    ba_session->macAddress.a[0],
-                    ba_session->macAddress.a[1],
-                    ba_session->macAddress.a[2],
-                    ba_session->macAddress.a[3],
-                    ba_session->macAddress.a[4],
-                    ba_session->macAddress.a[5],
-                    CSR_RESULT_SUCCESS
-                 );
-    CsrWifiRouterCtrlBlockAckErrorIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
-                    0,
-                    ba_session->interfacePriv->InterfaceTag,
-                    ba_session->tID,
-                    ba_session->macAddress,
-                    CSR_RESULT_SUCCESS);
-}
-
-
-static void ba_session_terminate_timer_func(unsigned long data)
-{
-    ba_session_rx_struct *ba_session = (ba_session_rx_struct*)data;
-    struct unifi_priv *priv;
-
-    if(!ba_session) {
-        return;
-    }
-
-    if(!ba_session->interfacePriv) {
-        return;
-    }
-
-    priv = ba_session->interfacePriv->privPtr;
-
-    if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__);
-        return;
-    }
-
-    queue_work(priv->unifi_workqueue, &ba_session->send_ba_err_task);
-}
-
-
-u8 blockack_session_stop(unifi_priv_t *priv,
-                                     u16 interfaceTag,
-                                     CsrWifiRouterCtrlBlockAckRole role,
-                                     u16 tID,
-                                     CsrWifiMacAddress macAddress)
-{
-    netInterface_priv_t *interfacePriv;
-    ba_session_rx_struct *ba_session_rx = NULL;
-    ba_session_tx_struct *ba_session_tx = NULL;
-    u8 ba_session_idx = 0;
-    int i;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag);
-        return FALSE;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if(!interfacePriv) {
-        unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__);
-        return FALSE;
-    }
-
-    if(tID > 15) {
-        unifi_error(priv, "%s: bad tID = %d\n", __FUNCTION__, tID);
-        return FALSE;
-    }
-
-    if((role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR) &&
-        (role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT)) {
-        unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role);
-        return FALSE;
-        }
-
-       unifi_warning(priv,
-               "%s: stopping ba_session for peer = %pM role = %d tID = %d\n",
-               __func__, macAddress.a, role, tID);
-
-    /* find out the appropriate ba session (/station /tid /role) for which stop is requested */
-    if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){
-        for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
-
-            ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx];
-
-            if(ba_session_rx){
-                if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){
-                    break;
-                }
-            }
-        }
-
-        if (!ba_session_rx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX)) {
-            unifi_error(priv, "%s: bad ba_session for Rx [tID=%d]\n", __FUNCTION__, tID);
-            return FALSE;
-        }
-
-
-        if(ba_session_rx->timeout) {
-            del_timer_sync(&ba_session_rx->timer);
-        }
-        cancel_work_sync(&ba_session_rx->send_ba_err_task);
-        for (i = 0; i < ba_session_rx->wind_size; i++) {
-            if(ba_session_rx->buffer[i].active) {
-                frame_desc_struct *frame_desc = &ba_session_rx->buffer[i];
-                unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
-            }
-        }
-        kfree(ba_session_rx->buffer);
-
-        interfacePriv->ba_session_rx[ba_session_idx] = NULL;
-        kfree(ba_session_rx);
-    }else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){
-        for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
-        ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx];
-            if(ba_session_tx){
-                if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){
-                    break;
-                }
-            }
-        }
-
-        if (!ba_session_tx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX)) {
-            unifi_error(priv, "%s: bad ba_session for Tx [tID=%d]\n", __FUNCTION__, tID);
-            return FALSE;
-        }
-        interfacePriv->ba_session_tx[ba_session_idx] = NULL;
-        kfree(ba_session_tx);
-
-    }
-
-    return TRUE;
-}
-
-
-void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    CsrWifiRouterCtrlBlockAckDisableReq* req = (CsrWifiRouterCtrlBlockAckDisableReq*)msg;
-    u8 r;
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-
-    unifi_trace(priv, UDBG6, "%s: in ok\n", __FUNCTION__);
-
-    down(&priv->ba_mutex);
-    r = blockack_session_stop(priv,
-                              req->interfaceTag,
-                              req->role,
-                              req->trafficStreamID,
-                              req->macAddress);
-    up(&priv->ba_mutex);
-
-    CsrWifiRouterCtrlBlockAckDisableCfmSend(msg->source,
-                                            req->clientData,
-                                            req->interfaceTag,
-                                            r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE);
-
-    unifi_trace(priv, UDBG6, "%s: out ok\n", __FUNCTION__);
-}
-
-
-u8 blockack_session_start(unifi_priv_t *priv,
-                               u16 interfaceTag,
-                               u16 tID,
-                               u16 timeout,
-                               CsrWifiRouterCtrlBlockAckRole role,
-                               u16 wind_size,
-                               u16 start_sn,
-                               CsrWifiMacAddress macAddress
-                              )
-{
-    netInterface_priv_t *interfacePriv;
-    ba_session_rx_struct *ba_session_rx = NULL;
-    ba_session_tx_struct *ba_session_tx = NULL;
-    u8 ba_session_idx = 0;
-
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag);
-        return FALSE;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if(!interfacePriv) {
-        unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__);
-        return FALSE;
-    }
-
-    if(tID > 15)
-    {
-        unifi_error(priv, "%s: bad tID=%d\n", __FUNCTION__, tID);
-        return FALSE;
-    }
-
-    if(wind_size > MAX_BA_WIND_SIZE) {
-        unifi_error(priv, "%s: bad wind_size = %d\n", __FUNCTION__, wind_size);
-        return FALSE;
-    }
-
-    if(role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR &&
-       role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT) {
-        unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role);
-        return FALSE;
-    }
-
-       unifi_warning(priv,
-               "%s: ba session with peer= (%pM)\n", __func__,
-               macAddress.a);
-
-    unifi_warning(priv, "%s: ba session for tID=%d timeout=%d role=%d wind_size=%d start_sn=%d\n", __FUNCTION__,
-                  tID,
-                  timeout,
-                  role,
-                  wind_size,
-                  start_sn);
-
-    /* Check if BA session exists for per station, per TID, per role or not.
-    if BA session exists update parameters and if it does not exist
-    create a new BA session */
-    if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){
-        for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
-            ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx];
-            if (ba_session_tx) {
-                if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){
-                    unifi_warning(priv, "%s: ba_session for Tx already exists\n", __FUNCTION__);
-                    return TRUE;
-                }
-            }
-        }
-
-        /* we have to create new ba_session_tx struct */
-         ba_session_tx = NULL;
-
-        /* loop through until an empty BA session slot is there and save the session there */
-        for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX ; ba_session_idx++){
-            if (!(interfacePriv->ba_session_tx[ba_session_idx])){
-                break;
-            }
-        }
-        if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX){
-            unifi_error(priv, "%s: All ba_session used for Tx, NO free session available\n", __FUNCTION__);
-            return FALSE;
-        }
-
-        /* create and populate the new BA session structure */
-        ba_session_tx = kzalloc(sizeof(ba_session_tx_struct), GFP_KERNEL);
-        if (!ba_session_tx) {
-            unifi_error(priv, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__);
-            return FALSE;
-        }
-
-        ba_session_tx->interfacePriv = interfacePriv;
-        ba_session_tx->tID = tID;
-        ba_session_tx->macAddress = macAddress;
-
-        interfacePriv->ba_session_tx[ba_session_idx] = ba_session_tx;
-
-    } else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){
-
-        for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
-            ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx];
-            if (ba_session_rx) {
-                if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){
-                    unifi_warning(priv, "%s: ba_session for Rx[tID = %d] already exists\n", __FUNCTION__, tID);
-
-                    if(ba_session_rx->wind_size == wind_size &&
-                        ba_session_rx->timeout == timeout &&
-                        ba_session_rx->expected_sn == start_sn) {
-                        return TRUE;
-                    }
-
-                    if(ba_session_rx->timeout) {
-                        del_timer_sync(&ba_session_rx->timer);
-                        ba_session_rx->timeout = 0;
-                    }
-
-                    if(ba_session_rx->wind_size != wind_size) {
-                        blockack_session_stop(priv, interfaceTag, role, tID, macAddress);
-                    } else {
-                        if (timeout) {
-                            ba_session_rx->timeout = timeout;
-                            ba_session_rx->timer.function = ba_session_terminate_timer_func;
-                            ba_session_rx->timer.data = (unsigned long)ba_session_rx;
-                            init_timer(&ba_session_rx->timer);
-                            mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024)));
-                        }
-                        /*
-                         * The starting sequence number shall remain same if the BA
-                         * enable request is issued to update BA parameters only. If
-                         * it is not same, then we scroll our window to the new starting
-                         * sequence number. This could happen if the DELBA frame from
-                         * originator is lost and then we receive ADDBA frame with new SSN.
-                        */
-                        if(ba_session_rx->start_sn != start_sn) {
-                            scroll_ba_window(priv, interfacePriv, ba_session_rx, start_sn);
-                        }
-                        return TRUE;
-                    }
-                }
-            }
-        }
-
-        /* we could have a valid BA session pointer here or un-initialized
-        ba session pointer. but in any case we have to create a new session.
-        so re-initialize the ba_session pointer */
-        ba_session_rx = NULL;
-
-        /* loop through until an empty BA session slot is there and save the session there */
-        for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX ; ba_session_idx++){
-            if (!(interfacePriv->ba_session_rx[ba_session_idx])){
-                break;
-            }
-        }
-        if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
-            unifi_error(priv, "%s: All ba_session used for Rx, NO free session available\n", __FUNCTION__);
-            return FALSE;
-        }
-
-        /* It is observed that with some devices there is a race between
-         * EAPOL exchanges and BA session establishment. This results in
-         * some EAPOL authentication packets getting stuck in BA reorder
-         * buffer and hence the conection cannot be established. To avoid
-         * this we check here if the EAPOL authentication is complete and
-         * if so then only allow the BA session to establish.
-         *
-         * It is verified that the peers normally re-establish
-         * the BA session after the initial rejection.
-         */
-        if (CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN != uf_sme_port_state(priv, macAddress.a, UF_CONTROLLED_PORT_Q, interfacePriv->InterfaceTag))
-        {
-            unifi_warning(priv, "blockack_session_start: Controlled port not opened, Reject BA request\n");
-            return FALSE;
-        }
-
-        ba_session_rx = kzalloc(sizeof(ba_session_rx_struct), GFP_KERNEL);
-        if (!ba_session_rx) {
-            unifi_error(priv, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__);
-            return FALSE;
-        }
-
-        ba_session_rx->wind_size = wind_size;
-        ba_session_rx->start_sn = ba_session_rx->expected_sn = start_sn;
-        ba_session_rx->trigger_ba_after_ssn = FALSE;
-
-        ba_session_rx->buffer = kzalloc(ba_session_rx->wind_size*sizeof(frame_desc_struct), GFP_KERNEL);
-        if (!ba_session_rx->buffer) {
-            kfree(ba_session_rx);
-            unifi_error(priv, "%s: kmalloc failed for buffer\n", __FUNCTION__);
-            return FALSE;
-        }
-
-        INIT_WORK(&ba_session_rx->send_ba_err_task, uf_send_ba_err_wq);
-        if (timeout) {
-            ba_session_rx->timeout = timeout;
-            ba_session_rx->timer.function = ba_session_terminate_timer_func;
-            ba_session_rx->timer.data = (unsigned long)ba_session_rx;
-            init_timer(&ba_session_rx->timer);
-            mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024)));
-        }
-
-        ba_session_rx->interfacePriv = interfacePriv;
-        ba_session_rx->tID = tID;
-        ba_session_rx->macAddress = macAddress;
-
-        interfacePriv->ba_session_rx[ba_session_idx] = ba_session_rx;
-    }
-    return TRUE;
-}
-
-void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-    CsrWifiRouterCtrlBlockAckEnableReq* req = (CsrWifiRouterCtrlBlockAckEnableReq*)msg;
-    u8 r;
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-
-    unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
-    down(&priv->ba_mutex);
-    r = blockack_session_start(priv,
-                               req->interfaceTag,
-                               req->trafficStreamID,
-                               req->timeout,
-                               req->role,
-                               req->bufferSize,
-                               req->ssn,
-                               req->macAddress
-                              );
-    up(&priv->ba_mutex);
-
-    CsrWifiRouterCtrlBlockAckEnableCfmSend(msg->source,
-                                           req->clientData,
-                                           req->interfaceTag,
-                                           r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE);
-    unifi_trace(priv, UDBG6, "<<%s: r=%d\n", __FUNCTION__, r);
-
-}
-
-void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlWapiMulticastFilterReq* req = (CsrWifiRouterCtrlWapiMulticastFilterReq*)msg;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
-
-        unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
-
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiMulticastFilterReq: req->status = %d\n", req->status);
-
-        /* status 1 - Filter on
-        * status 0 - Filter off */
-        priv->wapi_multicast_filter = req->status;
-
-        unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
-    } else {
-
-       unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
-
-    }
-#elif defined(UNIFI_DEBUG)
-    /*WAPI Disabled*/
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    unifi_error(priv, "CsrWifiRouterCtrlWapiMulticastFilterReqHandler: called when WAPI isn't enabled\n");
-#endif
-}
-
-void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlWapiUnicastFilterReq* req = (CsrWifiRouterCtrlWapiUnicastFilterReq*)msg;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
-
-        unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
-
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastFilterReq: req->status= %d\n", req->status);
-
-        if ((priv->wapi_unicast_filter == 1) && (req->status == 0)) {
-            /* When we have successfully re-associated and obtained a new unicast key with keyid = 0 */
-            priv->wapi_unicast_queued_pkt_filter = 1;
-        }
-
-        /* status 1 - Filter ON
-         * status 0 - Filter OFF */
-        priv->wapi_unicast_filter = req->status;
-
-        unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
-    } else {
-
-        unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
-
-    }
-#elif defined(UNIFI_DEBUG)
-    /*WAPI Disabled*/
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastFilterReqHandler: called when WAPI isn't enabled\n");
-#endif
-}
-
-void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlWapiRxPktReq* req =  (CsrWifiRouterCtrlWapiRxPktReq*)msg;
-    int client_id, receiver_id;
-    bulk_data_param_t bulkdata;
-    CsrResult res;
-    ul_client_t *client;
-    CSR_SIGNAL signal;
-    CSR_MA_PACKET_INDICATION *pkt_ind;
-    netInterface_priv_t *interfacePriv;
-
-    if (priv == NULL) {
-           unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n", __func__);
-           return;
-    }
-
-    if (priv->smepriv == NULL) {
-           unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n", __func__);
-           return;
-    }
-
-    interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
-
-       unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
-
-
-        if (req->dataLength == 0 || req->data == NULL) {
-             unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n", __FUNCTION__);
-             return;
-        }
-
-        res = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength);
-        if (res != CSR_RESULT_SUCCESS) {
-             unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: Could not allocate net data\n", __FUNCTION__);
-             return;
-        }
-
-        /* This function is expected to be called only when the MIC has been verified by SME to be correct
-         * So reset the reception status to rx_success */
-        res = read_unpack_signal(req->signal, &signal);
-        if (res) {
-                 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: Received unknown or corrupted signal.\n");
-                 return;
-        }
-        pkt_ind = (CSR_MA_PACKET_INDICATION*) (&((&signal)->u).MaPacketIndication);
-        if (pkt_ind->ReceptionStatus != CSR_MICHAEL_MIC_ERROR) {
-                 unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: Unknown signal with reception status = %d\n", pkt_ind->ReceptionStatus);
-                 return;
-        } else {
-                 unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlWapiRxPktReqHandler: MIC verified , RX_SUCCESS \n", __FUNCTION__);
-                 pkt_ind->ReceptionStatus = CSR_RX_SUCCESS;
-                 write_pack(&signal, req->signal, &(req->signalLength));
-        }
-
-        memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength);
-
-        receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((req->signal) + sizeof(s16)) & 0xFFF0;
-        client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT;
-
-        client = &priv->ul_clients[client_id];
-
-        if (client && client->event_hook) {
-              unifi_trace(priv, UDBG3,
-                          "CsrWifiRouterCtrlWapiRxPktReq: "
-                          "Sending signal to client %d, (s:0x%X, r:0x%X) - Signal 0x%X \n",
-                          client->client_id, client->sender_id, receiver_id,
-                          CSR_GET_UINT16_FROM_LITTLE_ENDIAN(req->signal));
-
-              client->event_hook(client, req->signal, req->signalLength, &bulkdata, UDI_TO_HOST);
-        } else {
-              unifi_trace(priv, UDBG4, "No client to give the packet to\n");
-              unifi_net_data_free(priv, &bulkdata.d[0]);
-        }
-
-        unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
-    } else {
-       unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
-    }
-#elif defined(UNIFI_DEBUG)
-    /*WAPI Disabled*/
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReqHandler: called when WAPI isn't enabled\n");
-#endif
-}
-
-void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-
-       unifi_priv_t *priv = (unifi_priv_t*) drvpriv;
-    CsrWifiRouterCtrlWapiUnicastTxPktReq *req  = (CsrWifiRouterCtrlWapiUnicastTxPktReq*) msg;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-    bulk_data_param_t bulkdata;
-    u8 macHeaderLengthInBytes = MAC_HEADER_SIZE;
-    /*KeyID, Reserved, PN, MIC*/
-    u8 appendedCryptoFields = 1 + 1 + 16 + 16;
-    CsrResult result;
-    /* Retrieve the MA PACKET REQ fields from the Signal retained from send_ma_pkt_request() */
-    CSR_MA_PACKET_REQUEST *storedSignalMAPktReq = &interfacePriv->wapi_unicast_ma_pkt_sig.u.MaPacketRequest;
-
-    if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
-
-        unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
-
-        if (priv == NULL) {
-            unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid priv\n", __FUNCTION__);
-            return;
-        }
-        if (priv->smepriv == NULL) {
-            unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid sme priv\n", __FUNCTION__);
-            return;
-        }
-        if (req->data == NULL) {
-            unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid request\n", __FUNCTION__);
-            return;
-        } else {
-            /* If it is QoS data (type = data subtype = QoS), frame header contains QoS control field */
-            if ((req->data[0] & 0x88) == 0x88) {
-               macHeaderLengthInBytes  = macHeaderLengthInBytes + QOS_CONTROL_HEADER_SIZE;
-            }
-        }
-        if ( !(req->dataLength>(macHeaderLengthInBytes+appendedCryptoFields)) ) {
-            unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid dataLength\n", __FUNCTION__);
-            return;
-        }
-
-           /* Encrypted DATA Packet contained in (req->data)
-         * -------------------------------------------------------------------
-         * |MAC Header|  KeyId   | Reserved |    PN    | xxDataxx | xxMICxxx |
-         * -------------------------------------------------------------------
-         *                                             (<-----Encrypted----->)
-         * -------------------------------------------------------------------
-         * |24/26(QoS)|    1     |    1     |    16    |    x     |    16    |
-         * -------------------------------------------------------------------
-         */
-        result = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength);
-        if (result != CSR_RESULT_SUCCESS) {
-             unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: Could not allocate net data\n", __FUNCTION__);
-             return;
-        }
-        memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength);
-        bulkdata.d[0].data_length = req->dataLength;
-        bulkdata.d[1].os_data_ptr = NULL;
-        bulkdata.d[1].data_length = 0;
-
-        /* Send UniFi msg */
-        /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
-        result = uf_process_ma_packet_req(priv,
-                                         storedSignalMAPktReq->Ra.x,
-                                          storedSignalMAPktReq->HostTag,/* Ask for a new HostTag */
-                                          req->interfaceTag,
-                                          storedSignalMAPktReq->TransmissionControl,
-                                          storedSignalMAPktReq->TransmitRate,
-                                          storedSignalMAPktReq->Priority, /* Retained value */
-                                          interfacePriv->wapi_unicast_ma_pkt_sig.SignalPrimitiveHeader.SenderProcessId, /*FIXME AP: VALIDATE ???*/
-                                          &bulkdata);
-
-        if (result == NETDEV_TX_OK) {
-             (priv->netdev[req->interfaceTag])->trans_start = jiffies;
-             /* Should really count tx stats in the UNITDATA.status signal but
-              * that doesn't have the length.
-              */
-             interfacePriv->stats.tx_packets++;
-
-             /* count only the packet payload */
-             interfacePriv->stats.tx_bytes += req->dataLength - macHeaderLengthInBytes - appendedCryptoFields;
-             unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Sent), sent count = %x\n", interfacePriv->stats.tx_packets);
-        } else {
-             /* Failed to send: fh queue was full, and the skb was discarded*/
-             unifi_trace(priv, UDBG1, "(HIP validation failure) Result = %d\n", result);
-             unifi_net_data_free(priv, &bulkdata.d[0]);
-
-             interfacePriv->stats.tx_dropped++;
-             unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped);
-        }
-
-        unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
-
-    } else {
-
-       unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
-
-    }
-#elif defined(UNIFI_DEBUG)
-    /*WAPI Disabled*/
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: called when WAPI SW ENCRYPTION isn't enabled\n");
-#endif
-}
-
-void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
-{
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-
-#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    CsrWifiRouterCtrlWapiFilterReq* req = (CsrWifiRouterCtrlWapiFilterReq*)msg;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
-
-    if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
-
-        unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
-
-        unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiFilterReq: req->isWapiConnected [0/1] = %d \n", req->isWapiConnected);
-
-        priv->isWapiConnection = req->isWapiConnected;
-
-        unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
-    } else {
-
-       unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__, interfacePriv->interfaceMode);
-
-    }
-#endif
-
-#elif defined(UNIFI_DEBUG)
-    /*WAPI Disabled*/
-    unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    unifi_error(priv, "CsrWifiRouterCtrlWapiFilterReq: called when WAPI isn't enabled\n");
-#endif
-}
diff --git a/drivers/staging/csr/sme_userspace.c b/drivers/staging/csr/sme_userspace.c
deleted file mode 100644 (file)
index b919b00..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *****************************************************************************
- *
- * FILE : sme_userspace.c
- *
- * PURPOSE : Support functions for userspace SME helper application.
- *
- *
- * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- *****************************************************************************
- */
-
-#include "unifi_priv.h"
-
-/*
- * Fix Me..... These need to be the correct values...
- * Dynamic from the user space.
- */
-CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE   = 0xFFFF;
-CsrSchedQid CSR_WIFI_SME_IFACEQUEUE      = 0xFFFF;
-#ifdef CSR_SUPPORT_WEXT_AP
-CsrSchedQid CSR_WIFI_NME_IFACEQUEUE      = 0xFFFF;
-#endif
-int
-uf_sme_init(unifi_priv_t *priv)
-{
-    int i, j;
-
-    CsrWifiRouterTransportInit(priv);
-
-    priv->smepriv = priv;
-
-    init_waitqueue_head(&priv->sme_request_wq);
-
-    priv->filter_tclas_ies = NULL;
-    memset(&priv->packet_filters, 0, sizeof(uf_cfg_bcast_packet_filter_t));
-
-#ifdef CSR_SUPPORT_WEXT
-    priv->ignore_bssid_join = FALSE;
-    priv->mib_data.length = 0;
-
-    uf_sme_wext_set_defaults(priv);
-#endif /* CSR_SUPPORT_WEXT*/
-
-    priv->sta_ip_address = 0xFFFFFFFF;
-
-    priv->wifi_on_state = wifi_on_unspecified;
-
-    sema_init(&priv->sme_sem, 1);
-    memset(&priv->sme_reply, 0, sizeof(sme_reply_t));
-
-    priv->ta_ind_work.in_use = 0;
-    priv->ta_sample_ind_work.in_use = 0;
-
-    priv->CSR_WIFI_SME_IFACEQUEUE = 0xFFFF;
-
-    for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
-        priv->sme_unidata_ind_filters[i].in_use = 0;
-    }
-
-    /* Create a work queue item for Traffic Analysis indications to SME */
-    INIT_WORK(&priv->ta_ind_work.task, uf_ta_ind_wq);
-    INIT_WORK(&priv->ta_sample_ind_work.task, uf_ta_sample_ind_wq);
-#ifdef CSR_SUPPORT_WEXT
-    INIT_WORK(&priv->sme_config_task, uf_sme_config_wq);
-#endif
-
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
-        interfacePriv->m4_sent = FALSE;
-        interfacePriv->m4_bulk_data.net_buf_length = 0;
-        interfacePriv->m4_bulk_data.data_length = 0;
-        interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
-
-        memset(&interfacePriv->controlled_data_port, 0, sizeof(unifi_port_config_t));
-        interfacePriv->controlled_data_port.entries_in_use = 1;
-        interfacePriv->controlled_data_port.port_cfg[0].in_use = TRUE;
-        interfacePriv->controlled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-        interfacePriv->controlled_data_port.overide_action = UF_DATA_PORT_OVERIDE;
-
-        memset(&interfacePriv->uncontrolled_data_port, 0, sizeof(unifi_port_config_t));
-        interfacePriv->uncontrolled_data_port.entries_in_use = 1;
-        interfacePriv->uncontrolled_data_port.port_cfg[0].in_use = TRUE;
-        interfacePriv->uncontrolled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-        interfacePriv->uncontrolled_data_port.overide_action = UF_DATA_PORT_OVERIDE;
-
-        /* Mark the remainder of the port config table as unallocated */
-        for(j = 1; j < UNIFI_MAX_CONNECTIONS; j++) {
-            interfacePriv->controlled_data_port.port_cfg[j].in_use = FALSE;
-            interfacePriv->controlled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-
-            interfacePriv->uncontrolled_data_port.port_cfg[j].in_use = FALSE;
-            interfacePriv->uncontrolled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-        }
-
-        /* intializing the lists */
-        INIT_LIST_HEAD(&interfacePriv->genericMgtFrames);
-        INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastMgtFrames);
-        INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastFrames);
-
-        for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) {
-            interfacePriv->staInfo[j] = NULL;
-        }
-
-        interfacePriv->num_stations_joined = 0;
-        interfacePriv->sta_activity_check_enabled = FALSE;
-    }
-
-
-    return 0;
-} /* uf_sme_init() */
-
-
-void
-uf_sme_deinit(unifi_priv_t *priv)
-{
-    int i, j;
-    u8 ba_session_idx;
-    ba_session_rx_struct *ba_session_rx = NULL;
-    ba_session_tx_struct *ba_session_tx = NULL;
-    CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
-    netInterface_priv_t *interfacePriv = NULL;
-
-    /* Free any TCLASs previously allocated */
-    if (priv->packet_filters.tclas_ies_length) {
-        priv->packet_filters.tclas_ies_length = 0;
-        kfree(priv->filter_tclas_ies);
-        priv->filter_tclas_ies = NULL;
-    }
-
-    for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
-        priv->sme_unidata_ind_filters[i].in_use = 0;
-    }
-
-    /* Remove all the Peer database, before going down */
-    for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
-        down(&priv->ba_mutex);
-        for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
-            ba_session_rx = priv->interfacePriv[i]->ba_session_rx[ba_session_idx];
-            if(ba_session_rx) {
-                blockack_session_stop(priv,
-                                    i,
-                                    CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT,
-                                    ba_session_rx->tID,
-                                    ba_session_rx->macAddress);
-            }
-        }
-        for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
-            ba_session_tx = priv->interfacePriv[i]->ba_session_tx[ba_session_idx];
-            if(ba_session_tx) {
-                blockack_session_stop(priv,
-                                    i,
-                                    CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR,
-                                    ba_session_tx->tID,
-                                    ba_session_tx->macAddress);
-            }
-        }
-
-        up(&priv->ba_mutex);
-        interfacePriv = priv->interfacePriv[i];
-        if(interfacePriv){
-            for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) {
-                if ((staInfo=interfacePriv->staInfo[j]) != NULL) {
-                    /* Clear the STA activity parameters before freeing station Record */
-                    unifi_trace(priv, UDBG1, "uf_sme_deinit: Canceling work queue for STA with AID: %d\n", staInfo->aid);
-                    cancel_work_sync(&staInfo->send_disconnected_ind_task);
-                    staInfo->nullDataHostTag = INVALID_HOST_TAG;
-                }
-            }
-            if (interfacePriv->sta_activity_check_enabled){
-                interfacePriv->sta_activity_check_enabled = FALSE;
-                del_timer_sync(&interfacePriv->sta_activity_check_timer);
-            }
-        }
-        CsrWifiRouterCtrlInterfaceReset(priv, i);
-        priv->interfacePriv[i]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_NONE;
-    }
-
-
-} /* uf_sme_deinit() */
-
-
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_ta_indicate_protocol
- *
- *      Report that a packet of a particular type has been seen
- *
- *  Arguments:
- *      drv_priv        The device context pointer passed to ta_init.
- *      protocol        The protocol type enum value.
- *      direction       Whether the packet was a tx or rx.
- *      src_addr        The source MAC address from the data packet.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      We defer the actual sending to a background workqueue,
- *      see uf_ta_ind_wq().
- * ---------------------------------------------------------------------------
- */
-void
-unifi_ta_indicate_protocol(void *ospriv,
-                           CsrWifiRouterCtrlTrafficPacketType packet_type,
-                           CsrWifiRouterCtrlProtocolDirection direction,
-                           const CsrWifiMacAddress *src_addr)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-
-    if (priv->ta_ind_work.in_use) {
-        unifi_warning(priv,
-                "unifi_ta_indicate_protocol: workqueue item still in use, not sending\n");
-        return;
-    }
-
-    if (CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX == direction)
-    {
-        u16 interfaceTag = 0;
-        CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
-                interfaceTag,
-                packet_type,
-                direction,
-                *src_addr);
-    }
-    else
-    {
-        priv->ta_ind_work.packet_type = packet_type;
-        priv->ta_ind_work.direction = direction;
-        priv->ta_ind_work.src_addr = *src_addr;
-
-        queue_work(priv->unifi_workqueue, &priv->ta_ind_work.task);
-    }
-
-} /* unifi_ta_indicate_protocol() */
-
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_ta_indicate_sampling
- *
- *      Send the TA sampling information to the SME.
- *
- *  Arguments:
- *      drv_priv        The device context pointer passed to ta_init.
- *      stats   The TA sampling data to send.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-
-    if (!priv) {
-        return;
-    }
-
-    if (priv->ta_sample_ind_work.in_use) {
-        unifi_warning(priv,
-                     "unifi_ta_indicate_sampling: workqueue item still in use, not sending\n");
-        return;
-    }
-
-    priv->ta_sample_ind_work.stats = *stats;
-
-    queue_work(priv->unifi_workqueue, &priv->ta_sample_ind_work.task);
-
-} /* unifi_ta_indicate_sampling() */
-
-
-/*
- * ---------------------------------------------------------------------------
- * unifi_ta_indicate_l4stats
- *
- *      Send the TA TCP/UDP throughput information to the driver.
- *
- *  Arguments:
- *    drv_priv        The device context pointer passed to ta_init.
- *    rxTcpThroughput TCP RX throughput in KiloBytes
- *    txTcpThroughput TCP TX throughput in KiloBytes
- *    rxUdpThroughput UDP RX throughput in KiloBytes
- *    txUdpThroughput UDP TX throughput in KiloBytes
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_ta_indicate_l4stats(void *ospriv,
-                          u32 rxTcpThroughput,
-                          u32 txTcpThroughput,
-                          u32 rxUdpThroughput,
-                          u32 txUdpThroughput)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-
-    if (!priv) {
-        return;
-    }
-    /* Save the info. The actual action will be taken in unifi_ta_indicate_sampling() */
-    priv->rxTcpThroughput = rxTcpThroughput;
-    priv->txTcpThroughput = txTcpThroughput;
-    priv->rxUdpThroughput = rxUdpThroughput;
-    priv->txUdpThroughput = txUdpThroughput;
-} /* unifi_ta_indicate_l4stats() */
diff --git a/drivers/staging/csr/sme_userspace.h b/drivers/staging/csr/sme_userspace.h
deleted file mode 100644 (file)
index ebe371c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     sme_userspace.h
- *
- *  PURPOSE:    SME related definitions.
- *
- *  Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-#ifndef __LINUX_SME_USERSPACE_H__
-#define __LINUX_SME_USERSPACE_H__ 1
-
-#include <linux/kernel.h>
-
-int uf_sme_init(unifi_priv_t *priv);
-void uf_sme_deinit(unifi_priv_t *priv);
-int uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length);
-
-
-#include "csr_wifi_router_lib.h"
-#include "csr_wifi_router_sef.h"
-#include "csr_wifi_router_ctrl_lib.h"
-#include "csr_wifi_router_ctrl_sef.h"
-#include "csr_wifi_sme_task.h"
-#ifdef CSR_SUPPORT_WEXT_AP
-#include "csr_wifi_nme_ap_lib.h"
-#endif
-#include "csr_wifi_sme_lib.h"
-
-void CsrWifiRouterTransportInit(unifi_priv_t *priv);
-void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8 *buffer, size_t bufferLength);
-void CsrWifiRouterTransportDeInit(unifi_priv_t *priv);
-
-#endif /* __LINUX_SME_USERSPACE_H__ */
diff --git a/drivers/staging/csr/sme_wext.c b/drivers/staging/csr/sme_wext.c
deleted file mode 100644 (file)
index 84f11cb..0000000
+++ /dev/null
@@ -1,3327 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     sme_wext.c
- *
- * PURPOSE:
- *      Handlers for ioctls from iwconfig.
- *      These provide the control plane operations.
- *
- * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/types.h>
-#include <linux/etherdevice.h>
-#include <linux/if_arp.h>
-#include <asm/uaccess.h>
-#include <linux/ctype.h>
-#include "unifi_priv.h"
-#include <linux/rtnetlink.h>
-
-#define CHECK_INITED(_priv)                             \
-    do {                                                    \
-        if (_priv->init_progress != UNIFI_INIT_COMPLETED) { \
-            unifi_trace(_priv, UDBG2, "%s unifi not ready, failing wext call\n", __FUNCTION__); \
-            return -ENODEV;                                 \
-        }                                                   \
-    } while (0)
-
-/* Workaround for the wpa_supplicant hanging issue - disabled on Android */
-#ifndef ANDROID_BUILD
-#define CSR_WIFI_WEXT_HANG_WORKAROUND
-#endif
-
-#ifdef CSR_WIFI_WEXT_HANG_WORKAROUND
-# define UF_RTNL_LOCK()    rtnl_lock()
-# define UF_RTNL_UNLOCK()  rtnl_unlock()
-#else
-# define UF_RTNL_LOCK()
-# define UF_RTNL_UNLOCK()
-#endif
-
-
-/*
- * ---------------------------------------------------------------------------
- *      Helper functions
- * ---------------------------------------------------------------------------
- */
-
-/*
- * ---------------------------------------------------------------------------
- *  wext_freq_to_channel
- *  channel_to_mhz
- *
- *      These functions convert between channel number and frequency.
- *
- *  Arguments:
- *      ch      Channel number, as defined in 802.11 specs
- *      m, e    Mantissa and exponent as provided by wireless extension.
- *
- *  Returns:
- *      channel or frequency (in MHz) value
- * ---------------------------------------------------------------------------
- */
-static int
-wext_freq_to_channel(int m, int e)
-{
-    int mhz;
-
-    mhz = m;
-    while (e < 6) {
-        mhz /= 10;
-        e++;
-    }
-    while (e > 6) {
-        mhz *= 10;
-        e--;
-    }
-
-    if (mhz >= 5000) {
-        return ((mhz - 5000) / 5);
-    }
-
-    if (mhz == 2482) {
-        return 14;
-    }
-
-    if (mhz >= 2407) {
-        return ((mhz - 2407) / 5);
-    }
-
-    return 0;
-} /* wext_freq_to_channel() */
-
-static int
-channel_to_mhz(int ch, int dot11a)
-{
-
-    if (ch == 0) return 0;
-    if (ch > 200) return 0;
-
-    /* 5G */
-    if (dot11a) {
-        return (5000 + (5 * ch));
-    }
-
-    /* 2.4G */
-    if (ch == 14) {
-        return 2484;
-    }
-
-    if ((ch < 14) && (ch > 0)) {
-        return (2407 + (5 * ch));
-    }
-
-    return 0;
-}
-#ifdef CSR_SUPPORT_WEXT_AP
-void uf_sme_wext_ap_set_defaults(unifi_priv_t *priv)
-{
-    memcpy(priv->ap_config.ssid.ssid, "defaultssid", sizeof("defaultssid"));
-
-    priv->ap_config.ssid.length = 8;
-    priv->ap_config.channel = 6;
-    priv->ap_config.if_index = 1;
-    priv->ap_config.credentials.authType = 0;
-    priv->ap_config.max_connections=8;
-
-    priv->group_sec_config.apGroupkeyTimeout = 0;
-    priv->group_sec_config.apStrictGtkRekey = 0;
-    priv->group_sec_config.apGmkTimeout = 0;
-    priv->group_sec_config.apResponseTimeout = 100; /* Default*/
-    priv->group_sec_config.apRetransLimit = 3; /* Default*/
-    /* Set default params even if they may not be used*/
-    /* Until Here*/
-
-    priv->ap_mac_config.preamble = CSR_WIFI_SME_USE_LONG_PREAMBLE;
-    priv->ap_mac_config.shortSlotTimeEnabled = FALSE;
-    priv->ap_mac_config.ctsProtectionType=CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC;
-
-    priv->ap_mac_config.wmmEnabled = TRUE;
-    priv->ap_mac_config.wmmApParams[0].cwMin=4;
-    priv->ap_mac_config.wmmApParams[0].cwMax=10;
-    priv->ap_mac_config.wmmApParams[0].aifs=3;
-    priv->ap_mac_config.wmmApParams[0].txopLimit=0;
-    priv->ap_mac_config.wmmApParams[0].admissionControlMandatory=FALSE;
-    priv->ap_mac_config.wmmApParams[1].cwMin=4;
-    priv->ap_mac_config.wmmApParams[1].cwMax=10;
-    priv->ap_mac_config.wmmApParams[1].aifs=7;
-    priv->ap_mac_config.wmmApParams[1].txopLimit=0;
-    priv->ap_mac_config.wmmApParams[1].admissionControlMandatory=FALSE;
-    priv->ap_mac_config.wmmApParams[2].cwMin=3;
-    priv->ap_mac_config.wmmApParams[2].cwMax=4;
-    priv->ap_mac_config.wmmApParams[2].aifs=1;
-    priv->ap_mac_config.wmmApParams[2].txopLimit=94;
-    priv->ap_mac_config.wmmApParams[2].admissionControlMandatory=FALSE;
-    priv->ap_mac_config.wmmApParams[3].cwMin=2;
-    priv->ap_mac_config.wmmApParams[3].cwMax=3;
-    priv->ap_mac_config.wmmApParams[3].aifs=1;
-    priv->ap_mac_config.wmmApParams[3].txopLimit=47;
-    priv->ap_mac_config.wmmApParams[3].admissionControlMandatory=FALSE;
-
-    priv->ap_mac_config.wmmApBcParams[0].cwMin=4;
-    priv->ap_mac_config.wmmApBcParams[0].cwMax=10;
-    priv->ap_mac_config.wmmApBcParams[0].aifs=3;
-    priv->ap_mac_config.wmmApBcParams[0].txopLimit=0;
-    priv->ap_mac_config.wmmApBcParams[0].admissionControlMandatory=FALSE;
-    priv->ap_mac_config.wmmApBcParams[1].cwMin=4;
-    priv->ap_mac_config.wmmApBcParams[1].cwMax=10;
-    priv->ap_mac_config.wmmApBcParams[1].aifs=7;
-    priv->ap_mac_config.wmmApBcParams[1].txopLimit=0;
-    priv->ap_mac_config.wmmApBcParams[1].admissionControlMandatory=FALSE;
-    priv->ap_mac_config.wmmApBcParams[2].cwMin=3;
-    priv->ap_mac_config.wmmApBcParams[2].cwMax=4;
-    priv->ap_mac_config.wmmApBcParams[2].aifs=2;
-    priv->ap_mac_config.wmmApBcParams[2].txopLimit=94;
-    priv->ap_mac_config.wmmApBcParams[2].admissionControlMandatory=FALSE;
-    priv->ap_mac_config.wmmApBcParams[3].cwMin=2;
-    priv->ap_mac_config.wmmApBcParams[3].cwMax=3;
-    priv->ap_mac_config.wmmApBcParams[3].aifs=2;
-    priv->ap_mac_config.wmmApBcParams[3].txopLimit=47;
-    priv->ap_mac_config.wmmApBcParams[3].admissionControlMandatory=FALSE;
-
-    priv->ap_mac_config.accessType=CSR_WIFI_AP_ACCESS_TYPE_NONE;
-    priv->ap_mac_config.macAddressListCount=0;
-    priv->ap_mac_config.macAddressList=NULL;
-
-    priv->ap_mac_config.apHtParams.rxStbc=1;
-    priv->ap_mac_config.apHtParams.rifsModeAllowed=TRUE;
-    priv->ap_mac_config.apHtParams.greenfieldSupported=FALSE;
-    priv->ap_mac_config.apHtParams.shortGi20MHz=TRUE;
-    priv->ap_mac_config.apHtParams.htProtection=0;
-    priv->ap_mac_config.apHtParams.dualCtsProtection=FALSE;
-
-    priv->ap_mac_config.phySupportedBitmap =
-            (CSR_WIFI_SME_AP_PHY_SUPPORT_B|CSR_WIFI_SME_AP_PHY_SUPPORT_G|CSR_WIFI_SME_AP_PHY_SUPPORT_N);
-    priv->ap_mac_config.beaconInterval= 100;
-    priv->ap_mac_config.dtimPeriod=3;
-    priv->ap_mac_config.maxListenInterval=0x00ff;/* Set it to a large value
-                                                    to enable different types of
-                                                    devices to join us */
-    priv->ap_mac_config.supportedRatesCount =
-           uf_configure_supported_rates(priv->ap_mac_config.supportedRates, priv->ap_mac_config.phySupportedBitmap);
-}
-#endif
-/*
- * ---------------------------------------------------------------------------
- *  uf_sme_wext_set_defaults
- *
- *      Set up power-on defaults for driver config.
- *
- *      Note: The SME Management API *cannot* be used in this function.
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-uf_sme_wext_set_defaults(unifi_priv_t *priv)
-{
-    memset(&priv->connection_config, 0, sizeof(CsrWifiSmeConnectionConfig));
-
-    priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE;
-    priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-    priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
-    priv->connection_config.privacyMode = CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
-    priv->connection_config.wmmQosInfo = 0xFF;
-    priv->connection_config.ifIndex = CSR_WIFI_SME_RADIO_IF_BOTH;
-    priv->connection_config.adhocJoinOnly = FALSE;
-    priv->connection_config.adhocChannel = 6;
-
-    priv->wep_tx_key_index = 0;
-
-    priv->wext_wireless_stats.qual.qual = 0;
-    priv->wext_wireless_stats.qual.level = 0;
-    priv->wext_wireless_stats.qual.noise = 0;
-    priv->wext_wireless_stats.qual.updated = 0x70;
-#ifdef CSR_SUPPORT_WEXT_AP
-    /* Initialize the default configuration for AP */
-    uf_sme_wext_ap_set_defaults(priv);
-#endif
-
-
-} /* uf_sme_wext_set_defaults() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *      WEXT methods
- * ---------------------------------------------------------------------------
- */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_giwname   - handler for SIOCGIWNAME
- *  unifi_siwfreq   - handler for SIOCSIWFREQ
- *  unifi_giwfreq   - handler for SIOCGIWFREQ
- *  unifi_siwmode   - handler for SIOCSIWMODE
- *  unifi_giwmode   - handler for SIOCGIWMODE
- *  unifi_giwrange  - handler for SIOCGIWRANGE
- *  unifi_siwap     - handler for SIOCSIWAP
- *  unifi_giwap     - handler for SIOCGIWAP
- *  unifi_siwscan   - handler for SIOCSIWSCAN
- *  unifi_giwscan   - handler for SIOCGIWSCAN
- *  unifi_siwessid  - handler for SIOCSIWESSID
- *  unifi_giwessid  - handler for SIOCGIWESSID
- *  unifi_siwencode - handler for SIOCSIWENCODE
- *  unifi_giwencode - handler for SIOCGIWENCODE
- *
- *      Handler functions for IW extensions.
- *      These are registered via the unifi_iw_handler_def struct below
- *      and called by the generic IW driver support code.
- *      See include/net/iw_handler.h.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static int
-iwprivsdefs(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    int r;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    CsrWifiSmeMibConfig mibConfig;
-    CsrWifiSmePowerConfig powerConfig;
-
-    unifi_trace(priv, UDBG1, "iwprivs80211defaults: reload defaults\n");
-
-    uf_sme_wext_set_defaults(priv);
-
-    /* Get, modify and set the MIB data */
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    if (r) {
-        unifi_error(priv, "iwprivs80211defaults: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-    mibConfig.dot11RtsThreshold = 2347;
-    mibConfig.dot11FragmentationThreshold = 2346;
-    r = sme_mgt_mib_config_set(priv, &mibConfig);
-    if (r) {
-        unifi_error(priv, "iwprivs80211defaults: Set CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
-    powerConfig.listenIntervalTu = 100;
-    powerConfig.rxDtims = 1;
-
-    r = sme_mgt_power_config_set(priv, &powerConfig);
-    if (r) {
-        unifi_error(priv, "iwprivs80211defaults: Set unifi_PowerConfigValue failed.\n");
-        return r;
-    }
-
-    return 0;
-} /* iwprivsdefs() */
-
-static int
-iwprivs80211ps(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    int r = 0;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    int ps_mode = (int)(*extra);
-    CsrWifiSmePowerConfig powerConfig;
-
-    unifi_trace(priv, UDBG1, "iwprivs80211ps: power save mode = %d\n", ps_mode);
-
-    r = sme_mgt_power_config_get(priv, &powerConfig);
-    if (r) {
-        unifi_error(priv, "iwprivs80211ps: Get unifi_PowerConfigValue failed.\n");
-        return r;
-    }
-
-    switch (ps_mode) {
-        case CSR_PMM_ACTIVE_MODE:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
-            break;
-        case CSR_PMM_POWER_SAVE:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
-            break;
-        case CSR_PMM_FAST_POWER_SAVE:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
-            break;
-        default:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
-            break;
-    }
-
-    r = sme_mgt_power_config_set(priv, &powerConfig);
-    if (r) {
-        unifi_error(priv, "iwprivs80211ps: Set unifi_PowerConfigValue failed.\n");
-    }
-
-    return r;
-}
-
-static int
-iwprivg80211ps(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    CsrWifiSmePowerConfig powerConfig;
-    int r;
-
-    r = sme_mgt_power_config_get(priv, &powerConfig);
-    if (r) {
-        unifi_error(priv, "iwprivg80211ps: Get 802.11 power mode failed.\n");
-        return r;
-    }
-
-    switch (powerConfig.powerSaveLevel) {
-        case CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW:
-            snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
-                     "Power save mode: %d (Active)",
-                     powerConfig.powerSaveLevel);
-            break;
-        case CSR_WIFI_SME_POWER_SAVE_LEVEL_MED:
-            snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
-                     "Power save mode: %d (Fast)",
-                     powerConfig.powerSaveLevel);
-            break;
-        case CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH:
-            snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
-                     "Power save mode: %d (Full)",
-                     powerConfig.powerSaveLevel);
-            break;
-        case CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO:
-            snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
-                     "Power save mode: %d (Auto)",
-                     powerConfig.powerSaveLevel);
-            break;
-        default:
-            snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
-                     "Power save mode: %d (Unknown)",
-                     powerConfig.powerSaveLevel);
-            break;
-    }
-
-    wrqu->data.length = strlen(extra) + 1;
-
-    return 0;
-}
-
-static int
-iwprivssmedebug(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    /* No longer supported on the API */
-#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
-    unifi_debug_buf_dump();
-#endif
-
-    return 0;
-}
-
-#ifdef CSR_SUPPORT_WEXT_AP
-#define PARAM_TYPE_INT 0
-#define PARAM_TYPE_STRING 1
-#define CSR_WIFI_MAX_SSID_LEN 32
-#define CSR_WIFI_MAX_SEC_LEN 16
-#define CSR_WIFI_MAX_KEY_LEN 65
-
-static int hex_look_up(char x)
-{
-    if(x>='0' && x<='9')
-        return (x-48);
-    if(x>= 'a' && x <= 'f')
-        return (x-87);
-    return -1;
-}
-
-static int power (int a, int b)
-{
-    int i;
-    int num =1;
-    for(i=0;i<b;i++)
-       num *=a;
-    return num;
-}
-
-static int decode_parameter_from_string(unifi_priv_t* priv, char **str_ptr,
-                                        const char *token, int param_type,
-                                        void  *dst, int param_max_len)
-{
-    u8 int_str[7] = "0";
-    u32 param_str_len;
-    u8  *param_str_begin, *param_str_end;
-    u8  *orig_str = *str_ptr;
-
-    if (!strncmp(*str_ptr, token, strlen(token))) {
-        strsep(str_ptr, "=,");
-        param_str_begin = *str_ptr;
-        strsep(str_ptr, "=,");
-        if (*str_ptr == NULL) {
-            param_str_len = strlen(param_str_begin);
-        } else {
-            param_str_end = *str_ptr-1;
-            param_str_len = param_str_end - param_str_begin;
-        }
-        unifi_trace(priv, UDBG2, "'token:%s', len:%d, ", token, param_str_len);
-        if (param_str_len > param_max_len) {
-            unifi_notice(priv, "extracted param len:%d is > MAX:%d\n", param_str_len, param_max_len);
-            param_str_len = param_max_len;
-        }
-        switch (param_type) {
-            case PARAM_TYPE_INT:
-            {
-                u32 *pdst_int = dst, num =0;
-                int i, j=0;
-                if (param_str_len > sizeof(int_str)) {
-                    param_str_len = sizeof(int_str);
-                }
-                memcpy(int_str, param_str_begin, param_str_len);
-                for(i = param_str_len; i>0;i--) {
-                    if(int_str[i-1] >= '0' && int_str[i-1] <='9') {
-                        num += ((int_str[i-1]-'0')*power(10, j));
-                        j++;
-                    } else {
-                        unifi_error(priv, "decode_parameter_from_string:not a number %c\n", (int_str[i-1]));
-                        return -1;
-                    }
-                }
-                *pdst_int = num;
-                unifi_trace(priv, UDBG2, "decode_parameter_from_string:decoded int = %d\n", *pdst_int);
-            }
-            break;
-            default:
-                memcpy(dst, param_str_begin, param_str_len);
-                *((char *)dst + param_str_len) = 0;
-                unifi_trace(priv, UDBG2, "decode_parameter_from_string:decoded string = %s\n", (char *)dst);
-            break;
-        }
-    } else {
-        unifi_error(priv, "decode_parameter_from_string: Token:%s not found in %s \n", token, orig_str);
-        return -1;
-    }
-    return 0;
-}
-static int store_ap_advanced_config_from_string(unifi_priv_t *priv, char *param_str)
-{
-    char * str_ptr=param_str;
-    int ret = 0, tmp_var;
-    char phy_mode[6];
-    CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config;
-
-    /* Check for BI */
-    ret = decode_parameter_from_string(priv, &str_ptr, "BI=",
-                                       PARAM_TYPE_INT, &tmp_var, 5);
-    if(ret) {
-        unifi_error(priv, "store_ap_advanced_config_from_string: BI not found\n");
-        return -1;
-    }
-    ap_mac_config->beaconInterval = tmp_var;
-    ret = decode_parameter_from_string(priv, &str_ptr, "DTIM_PER=",
-                                        PARAM_TYPE_INT, &tmp_var, 5);
-    if(ret) {
-        unifi_error(priv, "store_ap_advanced_config_from_string: DTIM_PER not found\n");
-        return -1;
-    }
-    ap_mac_config->dtimPeriod = tmp_var;
-    ret = decode_parameter_from_string(priv, &str_ptr, "WMM=",
-                                        PARAM_TYPE_INT, &tmp_var, 5);
-    if(ret) {
-        unifi_error(priv, "store_ap_advanced_config_from_string: WMM not found\n");
-        return -1;
-    }
-    ap_mac_config->wmmEnabled = tmp_var;
-    ret = decode_parameter_from_string(priv, &str_ptr, "PHY=",
-                                        PARAM_TYPE_STRING, phy_mode, 5);
-    if(ret) {
-        unifi_error(priv, "store_ap_advanced_config_from_string: PHY not found\n");
-    } else {
-       if(strstr(phy_mode, "b")){
-           ap_mac_config->phySupportedBitmap = CSR_WIFI_SME_AP_PHY_SUPPORT_B;
-       }
-       if(strstr(phy_mode, "g")) {
-           ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_G;
-       }
-       if(strstr(phy_mode, "n")) {
-           ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_N;
-       }
-       ap_mac_config->supportedRatesCount =
-       uf_configure_supported_rates(ap_mac_config->supportedRates, ap_mac_config->phySupportedBitmap);
-    }
-    return ret;
-}
-
-static int store_ap_config_from_string( unifi_priv_t * priv, char *param_str)
-
-{
-    char *str_ptr = param_str;
-    char sub_cmd[16];
-    char sec[CSR_WIFI_MAX_SEC_LEN];
-    char key[CSR_WIFI_MAX_KEY_LEN];
-    int ret = 0, tmp_var;
-    CsrWifiSmeApConfig_t *ap_config = &priv->ap_config;
-    CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config;
-    memset(sub_cmd, 0, sizeof(sub_cmd));
-    if(!strstr(param_str, "END")) {
-        unifi_error(priv, "store_ap_config_from_string:Invalid config string:%s\n", param_str);
-        return -1;
-    }
-    if (decode_parameter_from_string(priv, &str_ptr, "ASCII_CMD=",
-        PARAM_TYPE_STRING, sub_cmd, 6) != 0) {
-         return -1;
-    }
-    if (strncmp(sub_cmd, "AP_CFG", 6)) {
-
-        if(!strncmp(sub_cmd , "ADVCFG", 6)) {
-           return store_ap_advanced_config_from_string(priv, str_ptr);
-        }
-        unifi_error(priv, "store_ap_config_from_string: sub_cmd:%s != 'AP_CFG or ADVCFG'!\n", sub_cmd);
-        return -1;
-    }
-    memset(ap_config, 0, sizeof(CsrWifiSmeApConfig_t));
-    ret = decode_parameter_from_string(priv, &str_ptr, "SSID=",
-                                       PARAM_TYPE_STRING, ap_config->ssid.ssid,
-                                       CSR_WIFI_MAX_SSID_LEN);
-    if(ret) {
-        unifi_error(priv, "store_ap_config_from_string: SSID not found\n");
-        return -1;
-    }
-    ap_config->ssid.length = strlen(ap_config->ssid.ssid);
-
-    ret = decode_parameter_from_string(priv, &str_ptr, "SEC=",
-                                       PARAM_TYPE_STRING, sec, CSR_WIFI_MAX_SEC_LEN);
-    if(ret) {
-        unifi_error(priv, "store_ap_config_from_string: SEC not found\n");
-        return -1;
-    }
-    ret = decode_parameter_from_string(priv, &str_ptr, "KEY=",
-                         PARAM_TYPE_STRING, key, CSR_WIFI_MAX_KEY_LEN);
-    if(!strcasecmp(sec, "open")) {
-        unifi_trace(priv, UDBG2, "store_ap_config_from_string: security open");
-        ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM;
-        if(ret) {
-            unifi_notice(priv, "store_ap_config_from_string: KEY not found:fine with Open\n");
-        }
-    }
-    else if(!strcasecmp(sec, "wpa2-psk")) {
-        int i, j=0;
-        CsrWifiNmeApAuthPers *pers =
-                            ((CsrWifiNmeApAuthPers *)&(ap_config->credentials.nmeAuthType.authTypePersonal));
-        u8 *psk = pers->authPers_credentials.psk.psk;
-
-        unifi_trace(priv, UDBG2, "store_ap_config_from_string: security WPA2");
-        if(ret) {
-            unifi_error(priv, "store_ap_config_from_string: KEY not found for WPA2\n");
-            return -1;
-        }
-        ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL;
-        pers->authSupport = CSR_WIFI_SME_RSN_AUTH_WPA2PSK;
-        pers->rsnCapabilities =0;
-        pers->wapiCapabilities =0;
-        pers->pskOrPassphrase=CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK;
-        pers->authPers_credentials.psk.encryptionMode =
-                 (CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP |CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP) ;
-        for(i=0;i<32;i++){
-           psk[i] = (16*hex_look_up(key[j]))+hex_look_up(key[j+1]);
-           j+=2;
-        }
-
-    } else {
-       unifi_notice(priv, "store_ap_config_from_string: Unknown security: Assuming Open");
-       ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM;
-       return -1;
-    }
-   /* Get the decoded value in a temp int variable to ensure that other fields within the struct
-      which are of type other than int are not over written */
-    ret = decode_parameter_from_string(priv, &str_ptr, "CHANNEL=", PARAM_TYPE_INT, &tmp_var, 5);
-    if(ret)
-        return -1;
-    ap_config->channel = tmp_var;
-    ret = decode_parameter_from_string(priv, &str_ptr, "PREAMBLE=", PARAM_TYPE_INT, &tmp_var, 5);
-    if(ret)
-        return -1;
-    ap_mac_config->preamble = tmp_var;
-    ret = decode_parameter_from_string(priv, &str_ptr, "MAX_SCB=", PARAM_TYPE_INT, &tmp_var, 5);
-    ap_config->max_connections = tmp_var;
-    return ret;
-}
-
-static int
-iwprivsapstart(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int r;
-
-    unifi_trace(priv, UDBG1, "iwprivsapstart\n" );
-    r = sme_ap_start(priv, interfacePriv->InterfaceTag, &priv->ap_config);
-    if(r) {
-        unifi_error(priv, "iwprivsapstart AP START failed : %d\n", -r);
-    }
-    return r;
-}
-
-static int
-iwprivsapconfig(struct net_device *dev, struct iw_request_info *info,
-                union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    char  *cfg_str = NULL;
-    int r;
-
-    unifi_trace(priv, UDBG1, "iwprivsapconfig\n" );
-    if (wrqu->data.length != 0) {
-        char *str;
-        if (!(cfg_str = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
-        {
-            return -ENOMEM;
-        }
-        if (copy_from_user(cfg_str, wrqu->data.pointer, wrqu->data.length)) {
-            kfree(cfg_str);
-            return -EFAULT;
-        }
-        cfg_str[wrqu->data.length] = 0;
-        unifi_trace(priv, UDBG2, "length:%d\n", wrqu->data.length);
-        unifi_trace(priv, UDBG2, "AP configuration string:%s\n", cfg_str);
-        str = cfg_str;
-       if ((r = store_ap_config_from_string(priv, str))) {
-           unifi_error(priv, "iwprivsapconfig:Failed  to decode the string %d\n", r);
-           kfree(cfg_str);
-           return -EIO;
-
-       }
-    } else {
-        unifi_error(priv, "iwprivsapconfig argument length = 0 \n");
-        return -EIO;
-    }
-    r = sme_ap_config(priv, &priv->ap_mac_config, &priv->group_sec_config);
-    if(r) {
-        unifi_error(priv, "iwprivsapstop AP Config failed : %d\n", -r);
-    } else if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-        interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-        unifi_trace(priv, UDBG1, "iwprivsapconfig: Starting the AP");
-        r = sme_ap_start(priv, interfacePriv->InterfaceTag, &priv->ap_config);
-        if(r) {
-            unifi_error(priv, "iwprivsapstart AP START failed : %d\n", -r);
-        }
-    }
-    kfree(cfg_str);
-    return r;
-}
-
-static int
-iwprivsapstop(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int r;
-    u16 interface_tag = interfacePriv->InterfaceTag;
-
-    unifi_trace(priv, UDBG1, "iwprivsapstop\n" );
-    r = sme_ap_stop(priv, interface_tag);
-    if(r) {
-        unifi_error(priv, "iwprivsapstop AP STOP failed : %d\n", -r);
-    }
-    return r;
-}
-
-#ifdef ANDROID_BUILD
-static int
-iwprivsapfwreload(struct net_device *dev, struct iw_request_info *info,
-                  union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    unifi_trace(priv, UDBG1, "iwprivsapfwreload\n" );
-    return 0;
-}
-
-static int
-iwprivsstackstart(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    unifi_trace(priv, UDBG1, "iwprivsstackstart\n" );
-    return 0;
-}
-
-static int
-iwprivsstackstop(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int r = 0;
-    u16 interface_tag = interfacePriv->InterfaceTag;
-
-    unifi_trace(priv, UDBG1, "iwprivsstackstop\n" );
-
-    switch(interfacePriv->interfaceMode) {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            r = sme_mgt_disconnect(priv);
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            r = sme_ap_stop(priv, interface_tag);
-            break;
-        default :
-            break;
-    }
-
-    if(r) {
-        unifi_error(priv, "iwprivsstackstop Stack stop failed : %d\n", -r);
-    }
-    return 0;
-}
-#endif /* ANDROID_BUILD */
-#endif /* CSR_SUPPORT_WEXT_AP */
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-static int
-iwprivsconfwapi(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    u8 enable;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    unifi_trace(priv, UDBG1, "iwprivsconfwapi\n" );
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "iwprivsconfwapi: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-    enable = *(u8*)(extra);
-
-    if (enable) {
-        priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-        priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI);
-        priv->connection_config.encryptionModeMask |=
-            CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4;
-    } else {
-        priv->connection_config.authModeMask &= ~(CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI);
-        priv->connection_config.encryptionModeMask &=
-            ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4);
-    }
-
-    return 0;
-}
-
-static int
-iwprivswpikey(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    int r = 0, i;
-    CsrWifiSmeKey key;
-    unifiio_wapi_key_t inKey;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    unifi_trace(priv, UDBG1, "iwprivswpikey\n" );
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-    inKey = *(unifiio_wapi_key_t*)(extra);
-
-    if (inKey.unicastKey) {
-        key.keyType   = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
-    } else {
-        key.keyType   = CSR_WIFI_SME_KEY_TYPE_GROUP;
-    }
-
-    key.keyIndex  = inKey.keyIndex;
-
-    /* memcpy(key.keyRsc, inKey.keyRsc, 16); */
-    for (i = 0; i < 16; i+= 2)
-    {
-        key.keyRsc[i/2] = inKey.keyRsc[i+1] << 8 | inKey.keyRsc[i];
-    }
-
-    memcpy(key.address.a, inKey.address, 6);
-    key.keyLength = 32;
-    memcpy(key.key, inKey.key, 32);
-    key.authenticator = 0;
-    key.wepTxKey = 0;
-
-    unifi_trace(priv, UDBG1, "keyType = %d, keyIndex = %d, wepTxKey = %d, keyRsc = %x:%x, auth = %d, address = %x:%x, "
-                "keylength = %d, key = %x:%x\n", key.keyType, key.keyIndex, key.wepTxKey,
-                key.keyRsc[0], key.keyRsc[7], key.authenticator,
-                key.address.a[0], key.address.a[5], key.keyLength, key.key[0],
-                key.key[15]);
-
-    r = sme_mgt_key(priv, &key, CSR_WIFI_SME_LIST_ACTION_ADD);
-    if (r) {
-        unifi_error(priv, "SETKEYS request was rejected with result %d\n", r);
-        return convert_sme_error(r);
-    }
-
-    return r;
-}
-#endif
-
-
-static int
-unifi_giwname(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    char *name = wrqu->name;
-    unifi_trace(priv, UDBG2, "unifi_giwname\n");
-
-    if (priv->if_index == CSR_INDEX_5G) {
-        strcpy(name, "IEEE 802.11-a");
-    } else {
-        strcpy(name, "IEEE 802.11-bgn");
-    }
-    return 0;
-} /* unifi_giwname() */
-
-
-static int
-unifi_siwfreq(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_freq *freq = (struct iw_freq *)wrqu;
-
-    unifi_trace(priv, UDBG2, "unifi_siwfreq\n");
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwfreq: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    /*
-     * Channel is stored in the connection configuration,
-     * and set later when ask for a connection.
-     */
-    if ((freq->e == 0) && (freq->m <= 1000)) {
-        priv->connection_config.adhocChannel = freq->m;
-    } else {
-        priv->connection_config.adhocChannel = wext_freq_to_channel(freq->m, freq->e);
-    }
-
-    return 0;
-} /* unifi_siwfreq() */
-
-
-static int
-unifi_giwfreq(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_freq *freq = (struct iw_freq *)wrqu;
-    int err = 0;
-    CsrWifiSmeConnectionInfo connectionInfo;
-
-    unifi_trace(priv, UDBG2, "unifi_giwfreq\n");
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_giwfreq: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    UF_RTNL_UNLOCK();
-    err = sme_mgt_connection_info_get(priv, &connectionInfo);
-    UF_RTNL_LOCK();
-
-    freq->m = channel_to_mhz(connectionInfo.channelNumber,
-            (connectionInfo.networkType80211 == CSR_WIFI_SME_RADIO_IF_GHZ_5_0));
-    freq->e = 6;
-
-    return convert_sme_error(err);
-} /* unifi_giwfreq() */
-
-
-static int
-unifi_siwmode(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    unifi_trace(priv, UDBG2, "unifi_siwmode\n");
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwmode: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    switch(wrqu->mode) {
-        case IW_MODE_ADHOC:
-            priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ADHOC;
-            break;
-        case IW_MODE_INFRA:
-            priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE;
-            break;
-        case IW_MODE_AUTO:
-            priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ANY_BSS;
-            break;
-        default:
-            unifi_notice(priv, "Unknown IW MODE value.\n");
-    }
-
-    /* Clear the SSID and BSSID configuration */
-    priv->connection_config.ssid.length = 0;
-    memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN);
-
-    return 0;
-} /* unifi_siwmode() */
-
-
-
-static int
-unifi_giwmode(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    int r = 0;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    CsrWifiSmeConnectionConfig connectionConfig;
-
-    unifi_trace(priv, UDBG2, "unifi_giwmode\n");
-    CHECK_INITED(priv);
-
-    unifi_trace(priv, UDBG2, "unifi_giwmode: Exisitng mode = 0x%x\n",
-                interfacePriv->interfaceMode);
-    switch(interfacePriv->interfaceMode) {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-           wrqu->mode = IW_MODE_INFRA;
-           break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            wrqu->mode = IW_MODE_MASTER;
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            wrqu->mode = IW_MODE_ADHOC;
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2P:
-        case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
-            UF_RTNL_UNLOCK();
-            r = sme_mgt_connection_config_get(priv, &connectionConfig);
-            UF_RTNL_LOCK();
-            if (r == 0) {
-                switch(connectionConfig.bssType) {
-                    case CSR_WIFI_SME_BSS_TYPE_ADHOC:
-                        wrqu->mode = IW_MODE_ADHOC;
-                        break;
-                    case CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
-                        wrqu->mode = IW_MODE_INFRA;
-                        break;
-                    default:
-                        wrqu->mode = IW_MODE_AUTO;
-                        unifi_notice(priv, "Unknown IW MODE value.\n");
-                }
-            }
-            break;
-        default:
-            wrqu->mode = IW_MODE_AUTO;
-            unifi_notice(priv, "Unknown IW MODE value.\n");
-
-    }
-    unifi_trace(priv, UDBG4, "unifi_giwmode: mode = 0x%x\n", wrqu->mode);
-    return r;
-} /* unifi_giwmode() */
-
-
-
-static int
-unifi_giwrange(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    struct iw_point *dwrq = &wrqu->data;
-    struct iw_range *range = (struct iw_range *) extra;
-    int i;
-
-    unifi_trace(NULL, UDBG2, "unifi_giwrange\n");
-
-    dwrq->length = sizeof(struct iw_range);
-    memset(range, 0, sizeof(*range));
-    range->min_nwid = 0x0000;
-    range->max_nwid = 0x0000;
-
-    /*
-     * Don't report the frequency/channel table, then the channel
-     * number returned elsewhere will be printed as a channel number.
-     */
-
-    /* Ranges of values reported in quality structs */
-    range->max_qual.qual  = 40;         /* Max expected qual value */
-    range->max_qual.level = -120;       /* Noise floor in dBm */
-    range->max_qual.noise = -120;       /* Noise floor in dBm */
-
-
-    /* space for IW_MAX_BITRATES (8 up to WE15, 32 later) */
-    i = 0;
-#if WIRELESS_EXT > 15
-    range->bitrate[i++] =   2 * 500000;
-    range->bitrate[i++] =   4 * 500000;
-    range->bitrate[i++] =  11 * 500000;
-    range->bitrate[i++] =  22 * 500000;
-    range->bitrate[i++] =  12 * 500000;
-    range->bitrate[i++] =  18 * 500000;
-    range->bitrate[i++] =  24 * 500000;
-    range->bitrate[i++] =  36 * 500000;
-    range->bitrate[i++] =  48 * 500000;
-    range->bitrate[i++] =  72 * 500000;
-    range->bitrate[i++] =  96 * 500000;
-    range->bitrate[i++] = 108 * 500000;
-#else
-    range->bitrate[i++] =   2 * 500000;
-    range->bitrate[i++] =   4 * 500000;
-    range->bitrate[i++] =  11 * 500000;
-    range->bitrate[i++] =  22 * 500000;
-    range->bitrate[i++] =  24 * 500000;
-    range->bitrate[i++] =  48 * 500000;
-    range->bitrate[i++] =  96 * 500000;
-    range->bitrate[i++] = 108 * 500000;
-#endif /* WIRELESS_EXT < 16 */
-    range->num_bitrates = i;
-
-    range->max_encoding_tokens = NUM_WEPKEYS;
-    range->num_encoding_sizes = 2;
-    range->encoding_size[0] = 5;
-    range->encoding_size[1] = 13;
-
-    range->we_version_source = 20;
-    range->we_version_compiled = WIRELESS_EXT;
-
-    /* Number of channels available in h/w */
-    range->num_channels = 14;
-    /* Number of entries in freq[] array */
-    range->num_frequency = 14;
-    for (i = 0; (i < range->num_frequency) && (i < IW_MAX_FREQUENCIES); i++) {
-        int chan = i + 1;
-        range->freq[i].i = chan;
-        range->freq[i].m = channel_to_mhz(chan, 0);
-        range->freq[i].e = 6;
-    }
-    if ((i+3) < IW_MAX_FREQUENCIES) {
-        range->freq[i].i = 36;
-        range->freq[i].m = channel_to_mhz(36, 1);
-        range->freq[i].e = 6;
-        range->freq[i+1].i = 40;
-        range->freq[i+1].m = channel_to_mhz(40, 1);
-        range->freq[i+1].e = 6;
-        range->freq[i+2].i = 44;
-        range->freq[i+2].m = channel_to_mhz(44, 1);
-        range->freq[i+2].e = 6;
-        range->freq[i+3].i = 48;
-        range->freq[i+3].m = channel_to_mhz(48, 1);
-        range->freq[i+3].e = 6;
-    }
-
-#if WIRELESS_EXT > 16
-    /* Event capability (kernel + driver) */
-    range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
-            IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
-            IW_EVENT_CAPA_MASK(SIOCGIWAP) |
-            IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
-    range->event_capa[1] = IW_EVENT_CAPA_K_1;
-    range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
-            IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
-            IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
-            IW_EVENT_CAPA_MASK(IWEVEXPIRED));
-#endif /* WIRELESS_EXT > 16 */
-
-#if WIRELESS_EXT > 17
-    range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
-        IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
-#endif /* WIRELESS_EXT > 17 */
-
-
-    return 0;
-} /* unifi_giwrange() */
-
-
-static int
-unifi_siwap(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int err = 0;
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwap: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) {
-        return -EINVAL;
-    }
-
-       unifi_trace(priv, UDBG1, "unifi_siwap: asked for %pM\n",
-               wrqu->ap_addr.sa_data);
-
-    if (is_zero_ether_addr(wrqu->ap_addr.sa_data)) {
-        priv->ignore_bssid_join = FALSE;
-        err = sme_mgt_disconnect(priv);
-        if (err) {
-            unifi_trace(priv, UDBG4, "unifi_siwap: Disconnect failed, status %d\n", err);
-        }
-        return 0;
-    }
-
-    if (priv->ignore_bssid_join) {
-        unifi_trace(priv, UDBG4, "unifi_siwap: ignoring second join\n");
-        priv->ignore_bssid_join = FALSE;
-    } else {
-        memcpy(priv->connection_config.bssid.a, wrqu->ap_addr.sa_data, ETH_ALEN);
-        unifi_trace(priv, UDBG1, "unifi_siwap: Joining %X:%X:%X:%X:%X:%X\n",
-                    priv->connection_config.bssid.a[0],
-                    priv->connection_config.bssid.a[1],
-                    priv->connection_config.bssid.a[2],
-                    priv->connection_config.bssid.a[3],
-                    priv->connection_config.bssid.a[4],
-                    priv->connection_config.bssid.a[5]);
-        err = sme_mgt_connect(priv);
-        if (err) {
-            unifi_error(priv, "unifi_siwap: Join failed, status %d\n", err);
-            return convert_sme_error(err);
-        }
-    }
-
-    return 0;
-} /* unifi_siwap() */
-
-
-static int
-unifi_giwap(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    CsrWifiSmeConnectionInfo connectionInfo;
-    int r = 0;
-    u8 *bssid;
-
-    CHECK_INITED(priv);
-    unifi_trace(priv, UDBG2, "unifi_giwap\n");
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_connection_info_get(priv, &connectionInfo);
-    UF_RTNL_LOCK();
-
-    if (r == 0) {
-        bssid = connectionInfo.bssid.a;
-        wrqu->ap_addr.sa_family = ARPHRD_ETHER;
-               unifi_trace(priv, UDBG4, "unifi_giwap: BSSID = %pM\n", bssid);
-
-        memcpy(wrqu->ap_addr.sa_data, bssid, ETH_ALEN);
-    } else {
-        memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
-    }
-
-    return 0;
-} /* unifi_giwap() */
-
-
-static int
-unifi_siwscan(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int r;
-    CsrWifiSsid scan_ssid;
-    unsigned char *channel_list = NULL;
-    int chans_good = 0;
-#if WIRELESS_EXT > 17
-    struct iw_point *data = &wrqu->data;
-    struct iw_scan_req *req = (struct iw_scan_req *) extra;
-#endif
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwscan: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-#if WIRELESS_EXT > 17
-    /* Providing a valid channel list will force an active scan */
-    if (req) {
-        if ((req->num_channels > 0) && (req->num_channels < IW_MAX_FREQUENCIES)) {
-            channel_list = kmalloc(req->num_channels, GFP_KERNEL);
-            if (channel_list) {
-                int i;
-                for (i = 0; i < req->num_channels; i++) {
-                    /* Convert frequency to channel number */
-                    int ch = wext_freq_to_channel(req->channel_list[i].m,
-                            req->channel_list[i].e);
-                    if (ch) {
-                        channel_list[chans_good++] = ch;
-                    }
-                }
-                unifi_trace(priv, UDBG1,
-                            "SIWSCAN: Scanning %d channels\n", chans_good);
-            } else {
-                /* Fall back to scanning all */
-                unifi_error(priv, "SIWSCAN: Can't alloc channel_list (%d)\n",
-                        req->num_channels);
-            }
-        }
-    }
-
-    if (req && (data->flags & IW_SCAN_THIS_ESSID)) {
-        memcpy(scan_ssid.ssid, req->essid, req->essid_len);
-        scan_ssid.length = req->essid_len;
-        unifi_trace(priv, UDBG1,
-                    "SIWSCAN: Scanning for %.*s\n",
-                    scan_ssid.length, scan_ssid.ssid);
-    } else
-#endif
-    {
-        unifi_trace(priv, UDBG1, "SIWSCAN: Scanning for all APs\n");
-        scan_ssid.length = 0;
-    }
-
-    r = sme_mgt_scan_full(priv, &scan_ssid, chans_good, channel_list);
-    if (r) {
-        unifi_error(priv, "SIWSCAN: Scan returned error %d\n", r);
-    } else {
-        unifi_trace(priv, UDBG1, "SIWSCAN: Scan done\n");
-        wext_send_scan_results_event(priv);
-    }
-
-    if (channel_list) {
-        kfree(channel_list);
-    }
-
-    return r;
-
-} /* unifi_siwscan() */
-
-
-static const unsigned char *
-unifi_find_info_element(int id, const unsigned char *info, int len)
-{
-    const unsigned char *ie = info;
-
-    while (len > 1)
-    {
-        int e_id, e_len;
-        e_id = ie[0];
-        e_len = ie[1];
-
-        /* Return if we find a match */
-        if (e_id == id)
-        {
-            return ie;
-        }
-
-        len -= (e_len + 2);
-        ie  += (e_len + 2);
-    }
-
-    return NULL;
-} /* unifi_find_info_element() */
-
-
-/*
- * Translate scan data returned from the card to a card independent
- * format that the Wireless Tools will understand - Jean II
- */
-int
-unifi_translate_scan(struct net_device *dev,
-                     struct iw_request_info *info,
-                     char *current_ev, char *end_buf,
-                     CsrWifiSmeScanResult *scan_data,
-                     int scan_index)
-{
-    struct iw_event iwe;                /* Temporary buffer */
-    unsigned char *info_elems;
-    int info_elem_len;
-    const unsigned char *elem;
-    u16 capabilities;
-    int signal, noise, snr;
-    char *start_buf = current_ev;
-    char *current_val;  /* For rates */
-    int i, r;
-
-    info_elems    = scan_data->informationElements;
-    info_elem_len = scan_data->informationElementsLength;
-
-    if (!scan_data->informationElementsLength || !scan_data->informationElements) {
-        unifi_error(NULL, "*** NULL SCAN IEs ***\n");
-        return -EIO;
-    }
-
-    /* get capinfo bits */
-    capabilities = scan_data->capabilityInformation;
-
-    unifi_trace(NULL, UDBG5, "Capabilities: 0x%x\n", capabilities);
-
-    /* First entry *MUST* be the AP MAC address */
-    memset(&iwe, 0, sizeof(iwe));
-    iwe.cmd = SIOCGIWAP;
-    iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-    memcpy(iwe.u.ap_addr.sa_data, scan_data->bssid.a, ETH_ALEN);
-    iwe.len = IW_EV_ADDR_LEN;
-    r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_ADDR_LEN);
-    if (r < 0) {
-        return r;
-    }
-    start_buf += r;
-
-    /* Other entries will be displayed in the order we give them */
-
-    /* Add the ESSID */
-    /* find SSID in Info Elems */
-    elem = unifi_find_info_element(IE_SSID_ID, info_elems, info_elem_len);
-    if (elem) {
-        int e_len = elem[1];
-        const unsigned char *e_ptr = elem + 2;
-        unsigned char buf[33];
-
-        memset(&iwe, 0, sizeof(iwe));
-        iwe.cmd = SIOCGIWESSID;
-        iwe.u.essid.length = e_len;
-        if (iwe.u.essid.length > 32) {
-            iwe.u.essid.length = 32;
-        }
-        iwe.u.essid.flags = scan_index;
-        memcpy(buf, e_ptr, iwe.u.essid.length);
-        buf[iwe.u.essid.length] = '\0';
-        r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, buf);
-        if (r < 0) {
-            return r;
-        }
-        start_buf += r;
-
-    }
-
-    /* Add mode */
-    memset(&iwe, 0, sizeof(iwe));
-    iwe.cmd = SIOCGIWMODE;
-    if (scan_data->bssType == CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE) {
-        iwe.u.mode = IW_MODE_INFRA;
-    } else {
-        iwe.u.mode = IW_MODE_ADHOC;
-    }
-    iwe.len = IW_EV_UINT_LEN;
-    r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_UINT_LEN);
-    if (r < 0) {
-        return r;
-    }
-    start_buf += r;
-
-    /* Add frequency. iwlist will convert to channel using table given in giwrange */
-    memset(&iwe, 0, sizeof(iwe));
-    iwe.cmd = SIOCGIWFREQ;
-    iwe.u.freq.m = scan_data->channelFrequency;
-    iwe.u.freq.e = 6;
-    r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_FREQ_LEN);
-    if (r < 0) {
-        return r;
-    }
-    start_buf += r;
-
-
-    /* Add quality statistics */
-    iwe.cmd = IWEVQUAL;
-    /*
-     * level and noise below are mapped into an unsigned 8 bit number,
-     * ranging from [-192; 63]. The way this is achieved is simply to
-     * add 0x100 onto the number if it is negative,
-     * once clipped to the correct range.
-     */
-    signal = scan_data->rssi; /* This value is in dBm */
-    /* Clip range of snr */
-    snr    = (scan_data->snr > 0) ? scan_data->snr : 0; /* In dB relative, from 0 - 255 */
-    snr    = (snr < 255) ? snr : 255;
-    noise  = signal - snr;
-
-    /* Clip range of signal */
-    signal = (signal < 63) ? signal : 63;
-    signal = (signal > -192) ? signal : -192;
-
-    /* Clip range of noise */
-    noise = (noise < 63) ? noise : 63;
-    noise = (noise > -192) ? noise : -192;
-
-    /* Make u8 */
-    signal = ( signal < 0 ) ? signal + 0x100 : signal;
-    noise = ( noise < 0 ) ? noise + 0x100 : noise;
-
-    iwe.u.qual.level = (u8)signal; /* -192 : 63 */
-    iwe.u.qual.noise = (u8)noise;  /* -192 : 63 */
-    iwe.u.qual.qual = snr;         /* 0 : 255 */
-    iwe.u.qual.updated = 0;
-#if WIRELESS_EXT > 16
-    iwe.u.qual.updated |= IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED |
-        IW_QUAL_QUAL_UPDATED;
-#if WIRELESS_EXT > 18
-    iwe.u.qual.updated |= IW_QUAL_DBM;
-#endif
-#endif
-    r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_QUAL_LEN);
-    if (r < 0) {
-        return r;
-    }
-    start_buf += r;
-
-    /* Add encryption capability */
-    iwe.cmd = SIOCGIWENCODE;
-    if (capabilities & SIG_CAP_PRIVACY) {
-        iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-    } else {
-        iwe.u.data.flags = IW_ENCODE_DISABLED;
-    }
-    iwe.u.data.length = 0;
-    iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
-    r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, "");
-    if (r < 0) {
-        return r;
-    }
-    start_buf += r;
-
-
-    /*
-     * Rate : stuffing multiple values in a single event require a bit
-     * more of magic - Jean II
-     */
-    current_val = start_buf + IW_EV_LCP_LEN;
-
-    iwe.cmd = SIOCGIWRATE;
-    /* Those two flags are ignored... */
-    iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
-
-    elem = unifi_find_info_element(IE_SUPPORTED_RATES_ID,
-            info_elems, info_elem_len);
-    if (elem) {
-        int e_len = elem[1];
-        const unsigned char *e_ptr = elem + 2;
-
-        /*
-         * Count how many rates we have.
-         * Zero marks the end of the list, if the list is not truncated.
-         */
-        /* Max 8 values */
-        for (i = 0; i < e_len; i++) {
-            if (e_ptr[i] == 0) {
-                break;
-            }
-            /* Bit rate given in 500 kb/s units (+ 0x80) */
-            iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000);
-            /* Add new value to event */
-            r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
-            if (r < 0) {
-                return r;
-            }
-            current_val +=r;
-
-        }
-    }
-    elem = unifi_find_info_element(IE_EXTENDED_SUPPORTED_RATES_ID,
-            info_elems, info_elem_len);
-    if (elem) {
-        int e_len = elem[1];
-        const unsigned char *e_ptr = elem + 2;
-
-        /*
-         * Count how many rates we have.
-         * Zero marks the end of the list, if the list is not truncated.
-         */
-        /* Max 8 values */
-        for (i = 0; i < e_len; i++) {
-            if (e_ptr[i] == 0) {
-                break;
-            }
-            /* Bit rate given in 500 kb/s units (+ 0x80) */
-            iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000);
-            /* Add new value to event */
-            r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
-            if (r < 0) {
-                return r;
-            }
-            current_val +=r;
-        }
-    }
-    /* Check if we added any rates event */
-    if ((current_val - start_buf) > IW_EV_LCP_LEN) {
-        start_buf = current_val;
-    }
-
-
-#if WIRELESS_EXT > 17
-    memset(&iwe, 0, sizeof(iwe));
-    iwe.cmd = IWEVGENIE;
-    iwe.u.data.length = info_elem_len;
-
-    r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, info_elems);
-    if (r < 0) {
-        return r;
-    }
-
-    start_buf += r;
-#endif /* WE > 17 */
-
-    return (start_buf - current_ev);
-} /* unifi_translate_scan() */
-
-
-
-static int
-unifi_giwscan(struct net_device *dev, struct iw_request_info *info,
-              union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_point *dwrq = &wrqu->data;
-    int r;
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_giwscan: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    unifi_trace(priv, UDBG1,
-            "unifi_giwscan: buffer (%d bytes) \n",
-            dwrq->length);
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_scan_results_get_async(priv, info, extra, dwrq->length);
-    UF_RTNL_LOCK();
-    if (r < 0) {
-        unifi_trace(priv, UDBG1,
-                "unifi_giwscan: buffer (%d bytes) not big enough.\n",
-                dwrq->length);
-        return r;
-    }
-
-    dwrq->length = r;
-    dwrq->flags = 0;
-
-    return 0;
-} /* unifi_giwscan() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_siwessid
- *
- *      Request to join a network or start and AdHoc.
- *
- *  Arguments:
- *      dev             Pointer to network device struct.
- *      info            Pointer to broken-out ioctl request.
- *      data            Pointer to argument data.
- *      essid           Pointer to string giving name of network to join
- *                      or start
- *
- *  Returns:
- *      0 on success and everything complete
- *      -EINPROGRESS to have the higher level call the commit method.
- * ---------------------------------------------------------------------------
- */
-static int
-unifi_siwessid(struct net_device *dev, struct iw_request_info *info,
-               struct iw_point *data, char *essid)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int len;
-    int err = 0;
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwessid: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    len = 0;
-    if (data->flags & 1) {
-        /* Limit length  */
-        len = data->length;
-        if (len > UNIFI_MAX_SSID_LEN) {
-            len = UNIFI_MAX_SSID_LEN;
-        }
-    }
-
-#ifdef UNIFI_DEBUG
-    {
-        char essid_str[UNIFI_MAX_SSID_LEN+1];
-        int i;
-
-        for (i = 0; i < len; i++) {
-            essid_str[i] = (isprint(essid[i]) ? essid[i] : '?');
-        }
-        essid_str[i] = '\0';
-
-        unifi_trace(priv, UDBG1, "unifi_siwessid: asked for '%*s' (%d)\n", len, essid_str, len);
-        unifi_trace(priv, UDBG2, " with authModeMask = %d", priv->connection_config.authModeMask);
-    }
-#endif
-
-    memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN);
-    if (len) {
-        if (essid[len - 1] == 0) {
-            len --;
-        }
-
-        memcpy(priv->connection_config.ssid.ssid, essid, len);
-        priv->connection_config.ssid.length = len;
-
-    } else {
-        priv->connection_config.ssid.length = 0;
-    }
-
-    UF_RTNL_UNLOCK();
-    err = sme_mgt_connect(priv);
-    UF_RTNL_LOCK();
-    if (err) {
-        unifi_error(priv, "unifi_siwessid: Join failed, status %d\n", err);
-        return convert_sme_error(err);
-    }
-
-    return 0;
-} /* unifi_siwessid() */
-
-
-static int
-unifi_giwessid(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *essid)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_point *data = &wrqu->essid;
-    CsrWifiSmeConnectionInfo connectionInfo;
-    int r = 0;
-
-    unifi_trace(priv, UDBG2, "unifi_giwessid\n");
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_giwessid: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_connection_info_get(priv, &connectionInfo);
-    UF_RTNL_LOCK();
-
-    if (r == 0) {
-        data->length = connectionInfo.ssid.length;
-        strncpy(essid,
-                connectionInfo.ssid.ssid,
-                data->length);
-        data->flags = 1;            /* active */
-
-        unifi_trace(priv, UDBG2, "unifi_giwessid: %.*s\n",
-                data->length, essid);
-    }
-
-
-    return 0;
-} /* unifi_giwessid() */
-
-
-static int
-unifi_siwrate(struct net_device *dev, struct iw_request_info *info,
-              union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_param *args = &wrqu->bitrate;
-    CsrWifiSmeMibConfig mibConfig;
-    int r;
-
-    CHECK_INITED(priv);
-    unifi_trace(priv, UDBG2, "unifi_siwrate\n");
-
-    /*
-     * If args->fixed == 0, value is max rate or -1 for best
-     * If args->fixed == 1, value is rate to set or -1 for best
-     * args->disabled and args->flags are not used in SIOCSIWRATE
-     */
-
-    /* Get, modify and set the MIB data */
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwrate: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    /* Default to auto rate algorithm */
-    /* in 500Kbit/s, 0 means auto */
-    mibConfig.unifiFixTxDataRate = 0;
-
-    if (args->value != -1) {
-        mibConfig.unifiFixTxDataRate = args->value / 500000;
-    }
-
-    /* 1 means rate is a maximum, 2 means rate is a set value */
-    if (args->fixed == 1) {
-        mibConfig.unifiFixMaxTxDataRate = 0;
-    } else {
-        mibConfig.unifiFixMaxTxDataRate = 1;
-    }
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_set(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwrate: Set CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-
-    return 0;
-} /* unifi_siwrate() */
-
-
-
-static int
-unifi_giwrate(struct net_device *dev, struct iw_request_info *info,
-              union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_param *args = &wrqu->bitrate;
-    int r;
-    int bitrate, flag;
-    CsrWifiSmeMibConfig mibConfig;
-    CsrWifiSmeConnectionStats connectionStats;
-
-    unifi_trace(priv, UDBG2, "unifi_giwrate\n");
-    CHECK_INITED(priv);
-
-    flag = 0;
-    bitrate = 0;
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_giwrate: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    bitrate = mibConfig.unifiFixTxDataRate;
-    flag = mibConfig.unifiFixMaxTxDataRate;
-
-    /* Used the value returned by the SME if MIB returns 0 */
-    if (bitrate == 0) {
-        UF_RTNL_UNLOCK();
-        r = sme_mgt_connection_stats_get(priv, &connectionStats);
-        UF_RTNL_LOCK();
-        /* Ignore errors, we may be disconnected */
-        if (r == 0) {
-            bitrate = connectionStats.unifiTxDataRate;
-        }
-    }
-
-    args->value = bitrate * 500000;
-    args->fixed = !flag;
-
-    return 0;
-} /* unifi_giwrate() */
-
-
-static int
-unifi_siwrts(struct net_device *dev, struct iw_request_info *info,
-             union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int val = wrqu->rts.value;
-    int r = 0;
-    CsrWifiSmeMibConfig mibConfig;
-
-    unifi_trace(priv, UDBG2, "unifi_siwrts\n");
-    CHECK_INITED(priv);
-
-    if (wrqu->rts.disabled) {
-        val = 2347;
-    }
-
-    if ( (val < 0) || (val > 2347) )
-    {
-        return -EINVAL;
-    }
-
-    /* Get, modify and set the MIB data */
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwrts: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-    mibConfig.dot11RtsThreshold = val;
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_set(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwrts: Set CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    return 0;
-}
-
-
-static int
-unifi_giwrts(struct net_device *dev, struct iw_request_info *info,
-             union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int r;
-    int rts_thresh;
-    CsrWifiSmeMibConfig mibConfig;
-
-    unifi_trace(priv, UDBG2, "unifi_giwrts\n");
-    CHECK_INITED(priv);
-
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_giwrts: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    rts_thresh = mibConfig.dot11RtsThreshold;
-    if (rts_thresh > 2347) {
-        rts_thresh = 2347;
-    }
-
-    wrqu->rts.value = rts_thresh;
-    wrqu->rts.disabled = (rts_thresh == 2347);
-    wrqu->rts.fixed = 1;
-
-    return 0;
-}
-
-
-static int
-unifi_siwfrag(struct net_device *dev, struct iw_request_info *info,
-              union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int val = wrqu->frag.value;
-    int r = 0;
-    CsrWifiSmeMibConfig mibConfig;
-
-    unifi_trace(priv, UDBG2, "unifi_siwfrag\n");
-    CHECK_INITED(priv);
-
-    if (wrqu->frag.disabled)
-        val = 2346;
-
-    if ( (val < 256) || (val > 2347) )
-        return -EINVAL;
-
-    /* Get, modify and set the MIB data */
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-    /* Fragmentation Threashold must be even */
-    mibConfig.dot11FragmentationThreshold = (val & ~0x1);
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_set(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwfrag: Set CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    return 0;
-}
-
-
-static int
-unifi_giwfrag(struct net_device *dev, struct iw_request_info *info,
-              union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int r;
-    int frag_thresh;
-    CsrWifiSmeMibConfig mibConfig;
-
-    unifi_trace(priv, UDBG2, "unifi_giwfrag\n");
-    CHECK_INITED(priv);
-
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_mib_config_get(priv, &mibConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_giwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
-        return r;
-    }
-
-    frag_thresh = mibConfig.dot11FragmentationThreshold;
-
-    /* Build the return structure */
-    wrqu->frag.value = frag_thresh;
-    wrqu->frag.disabled = (frag_thresh >= 2346);
-    wrqu->frag.fixed = 1;
-
-    return 0;
-}
-
-
-static int
-unifi_siwencode(struct net_device *dev, struct iw_request_info *info,
-                union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_point *erq = &wrqu->encoding;
-    int index;
-    int rc = 0;
-    int privacy = -1;
-    CsrWifiSmeKey sme_key;
-
-    unifi_trace(priv, UDBG2, "unifi_siwencode\n");
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwencode: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    /*
-     * Key index is encoded in the flags.
-     * 0 - use current default,
-     * 1-4 - if a key value is given set that key
-     *       if not use that key
-     */
-    index = (erq->flags & IW_ENCODE_INDEX);  /* key number, 1-4 */
-    if ((index < 0) || (index > 4)) {
-        unifi_error(priv, "unifi_siwencode: Request to set an invalid key (index:%d)", index);
-        return -EINVAL;
-    }
-
-    /*
-     * Basic checking: do we have a key to set ?
-     * The IW_ENCODE_NOKEY flag is set when no key is present (only change flags),
-     * but older versions rely on sending a key id 1-4.
-     */
-    if (erq->length > 0) {
-
-        /* Check the size of the key */
-        if ((erq->length > LARGE_KEY_SIZE) || (erq->length < SMALL_KEY_SIZE)) {
-            unifi_error(priv, "unifi_siwencode: Request to set an invalid key (length:%d)",
-                        erq->length);
-            return -EINVAL;
-        }
-
-        /* Check the index (none (i.e. 0) means use current) */
-        if ((index < 1) || (index > 4)) {
-            /* If we do not have a previous key, use 1 as default */
-            if (!priv->wep_tx_key_index) {
-                priv->wep_tx_key_index = 1;
-            }
-            index = priv->wep_tx_key_index;
-        }
-
-        /* If we didn't have a key and a valid index is set, we want to remember it*/
-        if (!priv->wep_tx_key_index) {
-            priv->wep_tx_key_index = index;
-        }
-
-        unifi_trace(priv, UDBG1, "Tx key Index is %d\n", priv->wep_tx_key_index);
-
-        privacy = 1;
-
-        /* Check if the key is not marked as invalid */
-        if ((erq->flags & IW_ENCODE_NOKEY) == 0) {
-
-            unifi_trace(priv, UDBG1, "New %s key (len=%d, index=%d)\n",
-                        (priv->wep_tx_key_index == index) ? "tx" : "",
-                        erq->length, index);
-
-            sme_key.wepTxKey = (priv->wep_tx_key_index == index);
-            if (priv->wep_tx_key_index == index) {
-                sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
-            } else {
-                sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
-            }
-            /* Key index is zero based in SME but 1 based in wext */
-            sme_key.keyIndex = (index - 1);
-            sme_key.keyLength = erq->length;
-            sme_key.authenticator = 0;
-            memset(sme_key.address.a, 0xFF, ETH_ALEN);
-            memcpy(sme_key.key, extra, erq->length);
-
-            UF_RTNL_UNLOCK();
-            rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
-            UF_RTNL_LOCK();
-            if (rc) {
-                unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc);
-                return convert_sme_error(rc);
-            }
-
-            /* Store the key to be reported by the SIOCGIWENCODE handler */
-            priv->wep_keys[index - 1].len = erq->length;
-            memcpy(priv->wep_keys[index - 1].key, extra, erq->length);
-        }
-    } else {
-        /*
-         * No additional key data, so it must be a request to change the
-         * active key.
-         */
-        if (index != 0) {
-            unifi_trace(priv, UDBG1, "Tx key Index is %d\n", index - 1);
-
-            /* Store the index to be reported by the SIOCGIWENCODE handler */
-            priv->wep_tx_key_index = index;
-
-            sme_key.wepTxKey = 1;
-            sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
-
-            /* Key index is zero based in SME but 1 based in wext */
-            sme_key.keyIndex = (index - 1);
-            sme_key.keyLength = 0;
-            sme_key.authenticator = 0;
-            UF_RTNL_UNLOCK();
-            rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
-            UF_RTNL_LOCK();
-            if (rc) {
-                unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc);
-                return convert_sme_error(rc);
-            }
-
-            /* Turn on encryption */
-            privacy = 1;
-        }
-    }
-
-    /* Read the flags */
-    if (erq->flags & IW_ENCODE_DISABLED) {
-        /* disable encryption */
-        unifi_trace(priv, UDBG1, "disable WEP encryption\n");
-        privacy = 0;
-
-        priv->wep_tx_key_index = 0;
-
-        unifi_trace(priv, UDBG1, "IW_ENCODE_DISABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
-        priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-    }
-
-    if (erq->flags & IW_ENCODE_RESTRICTED) {
-        /* Use shared key auth */
-        unifi_trace(priv, UDBG1, "IW_ENCODE_RESTRICTED: CSR_WIFI_SME_AUTH_MODE_80211_SHARED\n");
-        priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_SHARED;
-
-        /* Turn on encryption */
-        privacy = 1;
-    }
-    if (erq->flags & IW_ENCODE_OPEN) {
-        unifi_trace(priv, UDBG1, "IW_ENCODE_OPEN: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
-        priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-    }
-
-    /* Commit the changes to flags if needed */
-    if (privacy != -1) {
-        priv->connection_config.privacyMode = privacy ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
-        priv->connection_config.encryptionModeMask = privacy ? (CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 |
-                CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 |
-                CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 |
-                CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104) :
-            CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
-    }
-
-    return convert_sme_error(rc);
-
-} /* unifi_siwencode() */
-
-
-
-static int
-unifi_giwencode(struct net_device *dev, struct iw_request_info *info,
-                union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_point *erq = &wrqu->encoding;
-
-    unifi_trace(priv, UDBG2, "unifi_giwencode\n");
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_giwencode: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    if (priv->connection_config.authModeMask == CSR_WIFI_SME_AUTH_MODE_80211_SHARED) {
-        erq->flags = IW_ENCODE_RESTRICTED;
-    }
-    else {
-        if (priv->connection_config.privacyMode == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED) {
-            erq->flags = IW_ENCODE_DISABLED;
-        } else {
-            erq->flags = IW_ENCODE_OPEN;
-        }
-    }
-
-    erq->length = 0;
-
-    if (erq->flags != IW_ENCODE_DISABLED) {
-        int index = priv->wep_tx_key_index;
-
-        if ((index > 0) && (index <= NUM_WEPKEYS)) {
-            erq->flags |= (index & IW_ENCODE_INDEX);
-            erq->length = priv->wep_keys[index - 1].len;
-            memcpy(extra, priv->wep_keys[index - 1].key, erq->length);
-        } else {
-            unifi_notice(priv, "unifi_giwencode: Surprise, do not have a valid key index (%d)\n",
-                         index);
-        }
-    }
-
-    return 0;
-} /* unifi_giwencode() */
-
-
-static int
-unifi_siwpower(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-    struct iw_param *args = &wrqu->power;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int listen_interval, wake_for_dtim;
-    int r = 0;
-    CsrWifiSmePowerConfig powerConfig;
-
-    unifi_trace(priv, UDBG2, "unifi_siwpower\n");
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwpower: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_power_config_get(priv, &powerConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwpower: Get unifi_PowerConfigValue failed.\n");
-        return r;
-    }
-
-    listen_interval = -1;
-    wake_for_dtim = -1;
-    if (args->disabled) {
-        powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
-    }
-    else
-    {
-        powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
-
-        switch (args->flags & IW_POWER_TYPE) {
-            case 0:
-                /* not specified */
-                break;
-            case IW_POWER_PERIOD:
-                listen_interval = args->value / 1000;
-                break;
-            default:
-                return -EINVAL;
-        }
-
-        switch (args->flags & IW_POWER_MODE) {
-            case 0:
-                /* not specified */
-                break;
-            case IW_POWER_UNICAST_R:
-                /* not interested in broadcast packets */
-                wake_for_dtim = 0;
-                break;
-            case IW_POWER_ALL_R:
-                /* yes, we are interested in broadcast packets */
-                wake_for_dtim = 1;
-                break;
-            default:
-                return -EINVAL;
-        }
-    }
-
-    if (listen_interval > 0) {
-        powerConfig.listenIntervalTu = listen_interval;
-        unifi_trace(priv, UDBG4, "unifi_siwpower: new Listen Interval = %d.\n",
-                    powerConfig.listenIntervalTu);
-    }
-
-    if (wake_for_dtim >= 0) {
-        powerConfig.rxDtims = wake_for_dtim;
-    }
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_power_config_set(priv, &powerConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_siwpower: Set unifi_PowerConfigValue failed.\n");
-        return r;
-    }
-
-    return 0;
-} /* unifi_siwpower() */
-
-
-static int
-unifi_giwpower(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-    struct iw_param *args = &wrqu->power;
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    CsrWifiSmePowerConfig powerConfig;
-    int r;
-
-    unifi_trace(priv, UDBG2, "unifi_giwpower\n");
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_giwpower: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    args->flags = 0;
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_power_config_get(priv, &powerConfig);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "unifi_giwpower: Get unifi_PowerConfigValue failed.\n");
-        return r;
-    }
-
-    unifi_trace(priv, UDBG4, "unifi_giwpower: mode=%d\n",
-                powerConfig.powerSaveLevel);
-
-    args->disabled = (powerConfig.powerSaveLevel == CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW);
-    if (args->disabled) {
-        args->flags = 0;
-        return 0;
-    }
-
-    args->value = powerConfig.listenIntervalTu * 1000;
-    args->flags |= IW_POWER_PERIOD;
-
-    if (powerConfig.rxDtims) {
-        args->flags |= IW_POWER_ALL_R;
-    } else {
-        args->flags |= IW_POWER_UNICAST_R;
-    }
-
-    return 0;
-} /* unifi_giwpower() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_siwcommit - handler for SIOCSIWCOMMIT
- *
- *      Apply all the parameters that have been set.
- *      In practice this means:
- *       - do a scan
- *       - join a network or start an AdHoc
- *       - authenticate and associate.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static int
-unifi_siwcommit(struct net_device *dev, struct iw_request_info *info,
-                union iwreq_data *wrqu, char *extra)
-{
-    return 0;
-} /* unifi_siwcommit() */
-
-
-
-static int
-unifi_siwmlme(struct net_device *dev, struct iw_request_info *info,
-              union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_mlme *mlme = (struct iw_mlme *)extra;
-
-    unifi_trace(priv, UDBG2, "unifi_siwmlme\n");
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwmlme: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    switch (mlme->cmd) {
-        case IW_MLME_DEAUTH:
-        case IW_MLME_DISASSOC:
-            UF_RTNL_UNLOCK();
-            sme_mgt_disconnect(priv);
-            UF_RTNL_LOCK();
-            break;
-        default:
-            return -EOPNOTSUPP;
-    }
-
-    return 0;
-} /* unifi_siwmlme() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_siwgenie
- *  unifi_giwgenie
- *
- *      WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM).
- *      Handlers for SIOCSIWGENIE, SIOCGIWGENIE - set/get generic IE
- *
- *      The host program (e.g. wpa_supplicant) uses this call to set the
- *      additional IEs to accompany the next (Associate?) request.
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- *  Notes:
- *      From wireless.h:
- *        This ioctl uses struct iw_point and data buffer that includes IE id
- *        and len fields. More than one IE may be included in the
- *        request. Setting the generic IE to empty buffer (len=0) removes the
- *        generic IE from the driver.
- * ---------------------------------------------------------------------------
- */
-static int
-unifi_siwgenie(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int len;
-
-    unifi_trace(priv, UDBG2, "unifi_siwgenie\n");
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwgenie: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    if ( priv->connection_config.mlmeAssociateReqInformationElements) {
-        kfree( priv->connection_config.mlmeAssociateReqInformationElements);
-    }
-    priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
-    priv->connection_config.mlmeAssociateReqInformationElements = NULL;
-
-    len = wrqu->data.length;
-    if (len == 0) {
-        return 0;
-    }
-
-    priv->connection_config.mlmeAssociateReqInformationElements = kmalloc(len, GFP_KERNEL);
-    if (priv->connection_config.mlmeAssociateReqInformationElements == NULL) {
-        return -ENOMEM;
-    }
-
-    priv->connection_config.mlmeAssociateReqInformationElementsLength = len;
-    memcpy( priv->connection_config.mlmeAssociateReqInformationElements, extra, len);
-
-    return 0;
-} /* unifi_siwgenie() */
-
-
-static int
-unifi_giwgenie(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    int len;
-
-    unifi_trace(priv, UDBG2, "unifi_giwgenie\n");
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_giwgenie: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    len = priv->connection_config.mlmeAssociateReqInformationElementsLength;
-
-    if (len == 0) {
-        wrqu->data.length = 0;
-        return 0;
-    }
-
-    if (wrqu->data.length < len) {
-        return -E2BIG;
-    }
-
-    wrqu->data.length = len;
-    memcpy(extra, priv->connection_config.mlmeAssociateReqInformationElements, len);
-
-    return 0;
-} /* unifi_giwgenie() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_siwauth
- *  unifi_giwauth
- *
- *      Handlers for SIOCSIWAUTH, SIOCGIWAUTH
- *      Set/get various authentication parameters.
- *
- *  Arguments:
- *
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static int
-_unifi_siwauth(struct net_device *dev, struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    CsrWifiSmeAuthModeMask new_auth;
-
-    unifi_trace(priv, UDBG2, "unifi_siwauth\n");
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwauth: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    /*
-     * This ioctl is safe to call even when UniFi is powered off.
-     * wpa_supplicant calls it to test whether we support WPA.
-     */
-
-    switch (wrqu->param.flags & IW_AUTH_INDEX) {
-
-        case IW_AUTH_WPA_ENABLED:
-            unifi_trace(priv, UDBG1, "IW_AUTH_WPA_ENABLED: %d\n", wrqu->param.value);
-
-            if (wrqu->param.value == 0) {
-                unifi_trace(priv, UDBG5, "IW_AUTH_WPA_ENABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
-                priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-            }
-            break;
-
-        case IW_AUTH_PRIVACY_INVOKED:
-            unifi_trace(priv, UDBG1, "IW_AUTH_PRIVACY_INVOKED: %d\n", wrqu->param.value);
-
-            priv->connection_config.privacyMode = wrqu->param.value ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
-            if (wrqu->param.value == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED)
-            {
-                priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
-            }
-            break;
-
-        case IW_AUTH_80211_AUTH_ALG:
-            /*
-               IW_AUTH_ALG_OPEN_SYSTEM      0x00000001
-               IW_AUTH_ALG_SHARED_KEY       0x00000002
-               IW_AUTH_ALG_LEAP             0x00000004
-               */
-            new_auth = 0;
-            if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM) {
-                unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_OPEN_SYSTEM)\n", wrqu->param.value);
-                new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-            }
-            if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY) {
-                unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_SHARED_KEY)\n", wrqu->param.value);
-                new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_SHARED;
-            }
-            if (wrqu->param.value & IW_AUTH_ALG_LEAP) {
-                /* Initial exchanges using open-system to set EAP */
-                unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_LEAP)\n", wrqu->param.value);
-                new_auth |= CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X;
-            }
-            if (new_auth == 0) {
-                unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: invalid value %d\n",
-                        wrqu->param.value);
-                return -EINVAL;
-            } else {
-                priv->connection_config.authModeMask = new_auth;
-            }
-            break;
-
-        case IW_AUTH_WPA_VERSION:
-            unifi_trace(priv, UDBG1, "IW_AUTH_WPA_VERSION: %d\n", wrqu->param.value);
-            priv->ignore_bssid_join = TRUE;
-            /*
-               IW_AUTH_WPA_VERSION_DISABLED 0x00000001
-               IW_AUTH_WPA_VERSION_WPA      0x00000002
-               IW_AUTH_WPA_VERSION_WPA2     0x00000004
-               */
-
-            if (!(wrqu->param.value & IW_AUTH_WPA_VERSION_DISABLED)) {
-
-                priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
-
-                if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA) {
-                    unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA, WPA-PSK\n");
-                    priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK);
-                }
-                if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA2) {
-                    unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA2, WPA2-PSK\n");
-                    priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK);
-                }
-            }
-            break;
-
-        case IW_AUTH_CIPHER_PAIRWISE:
-            unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_PAIRWISE: %d\n", wrqu->param.value);
-            /*
-             * one of:
-             IW_AUTH_CIPHER_NONE       0x00000001
-             IW_AUTH_CIPHER_WEP40      0x00000002
-             IW_AUTH_CIPHER_TKIP       0x00000004
-             IW_AUTH_CIPHER_CCMP       0x00000008
-             IW_AUTH_CIPHER_WEP104     0x00000010
-             */
-
-            priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
-
-            if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
-                priv->connection_config.encryptionModeMask |=
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40;
-            }
-            if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
-                priv->connection_config.encryptionModeMask |=
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104;
-            }
-            if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
-                priv->connection_config.encryptionModeMask |=
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP;
-            }
-            if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
-                priv->connection_config.encryptionModeMask |=
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP;
-            }
-
-            break;
-
-        case IW_AUTH_CIPHER_GROUP:
-            unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_GROUP: %d\n", wrqu->param.value);
-            /*
-             * Use the WPA version and the group cipher suite to set the permitted
-             * group key in the MIB. f/w uses this value to validate WPA and RSN IEs
-             * in the probe responses from the desired BSS(ID)
-             */
-
-            priv->connection_config.encryptionModeMask &= ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 |
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 |
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP |
-                    CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP);
-            if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
-                priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40;
-            }
-            if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
-                priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104;
-            }
-            if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
-                priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP;
-            }
-            if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
-                priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP;
-            }
-
-            break;
-
-        case IW_AUTH_KEY_MGMT:
-            unifi_trace(priv, UDBG1, "IW_AUTH_KEY_MGMT: %d\n", wrqu->param.value);
-            /*
-               IW_AUTH_KEY_MGMT_802_1X 1
-               IW_AUTH_KEY_MGMT_PSK    2
-               */
-            if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK)) {
-                /* Check for explicitly set mode. */
-                if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) {
-                    priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK;
-                }
-                if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) {
-                    priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA;
-                }
-                unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA: %d\n",
-                            priv->connection_config.authModeMask);
-            }
-            if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK)) {
-                /* Check for explicitly set mode. */
-                if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) {
-                    priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK;
-                }
-                if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) {
-                    priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2;
-                }
-                unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA2: %d\n",
-                            priv->connection_config.authModeMask);
-            }
-
-            break;
-        case IW_AUTH_TKIP_COUNTERMEASURES:
-            /*
-             * Set to true at the start of the 60 second backup-off period
-             * following 2 MichaelMIC failures within 60s.
-             */
-            unifi_trace(priv, UDBG1, "IW_AUTH_TKIP_COUNTERMEASURES: %d\n", wrqu->param.value);
-            break;
-
-        case IW_AUTH_DROP_UNENCRYPTED:
-            /*
-             * Set to true on init.
-             * Set to false just before associate if encryption will not be
-             * required.
-             *
-             * Note this is not the same as the 802.1X controlled port
-             */
-            unifi_trace(priv, UDBG1, "IW_AUTH_DROP_UNENCRYPTED: %d\n", wrqu->param.value);
-            break;
-
-        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-            /*
-             * This is set by wpa_supplicant to allow unencrypted EAPOL messages
-             * even if pairwise keys are set when not using WPA. IEEE 802.1X
-             * specifies that these frames are not encrypted, but WPA encrypts
-             * them when pairwise keys are in use.
-             * I think the UniFi f/w handles this decision for us.
-             */
-            unifi_trace(priv, UDBG1, "IW_AUTH_RX_UNENCRYPTED_EAPOL: %d\n", wrqu->param.value);
-            break;
-
-        case IW_AUTH_ROAMING_CONTROL:
-            unifi_trace(priv, UDBG1, "IW_AUTH_ROAMING_CONTROL: %d\n", wrqu->param.value);
-            break;
-
-        default:
-            unifi_trace(priv, UDBG1, "Unsupported auth param %d to 0x%X\n",
-                        wrqu->param.flags & IW_AUTH_INDEX,
-                        wrqu->param.value);
-            return -EOPNOTSUPP;
-    }
-
-    unifi_trace(priv, UDBG2, "authModeMask = %d", priv->connection_config.authModeMask);
-
-    return 0;
-} /* _unifi_siwauth() */
-
-
-static int
-unifi_siwauth(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    int err = 0;
-
-    UF_RTNL_UNLOCK();
-    err = _unifi_siwauth(dev, info, wrqu, extra);
-    UF_RTNL_LOCK();
-
-    return err;
-} /* unifi_siwauth() */
-
-
-static int
-unifi_giwauth(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    unifi_trace(NULL, UDBG2, "unifi_giwauth\n");
-    return -EOPNOTSUPP;
-} /* unifi_giwauth() */
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_siwencodeext
- *  unifi_giwencodeext
- *
- *      Handlers for SIOCSIWENCODEEXT, SIOCGIWENCODEEXT - set/get
- *      encoding token & mode
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      For WPA/WPA2 we don't take note of the IW_ENCODE_EXT_SET_TX_KEY flag.
- *      This flag means "use this key to encode transmissions"; we just
- *      assume only one key will be set and that is the one to use.
- * ---------------------------------------------------------------------------
- */
-static int
-_unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-    int r = 0;
-    unsigned char *keydata;
-    unsigned char tkip_key[32];
-    int keyid;
-    unsigned char *a = (unsigned char *)ext->addr.sa_data;
-    CsrWifiSmeKey sme_key;
-    CsrWifiSmeKeyType key_type;
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwencodeext: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-    unifi_trace(priv, UDBG1, "siwencodeext: flags=0x%X, alg=%d, ext_flags=0x%X, len=%d, index=%d,\n",
-                wrqu->encoding.flags, ext->alg, ext->ext_flags,
-                ext->key_len, (wrqu->encoding.flags & IW_ENCODE_INDEX));
-       unifi_trace(priv, UDBG3, "              addr=%pM\n", a);
-
-    if ((ext->key_len == 0) && (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) {
-        /* This means use a different key (given by key_idx) for Tx. */
-        /* NYI */
-        unifi_trace(priv, UDBG1, KERN_ERR "unifi_siwencodeext: NYI should change tx key id here!!\n");
-        return -ENOTSUPP;
-    }
-
-    memset(&sme_key, 0, sizeof(sme_key));
-
-    keydata = (unsigned char *)(ext + 1);
-    keyid = (wrqu->encoding.flags & IW_ENCODE_INDEX);
-
-    /*
-     * Check for request to delete keys for an address.
-     */
-    /* Pick out request for no privacy. */
-    if (ext->alg == IW_ENCODE_ALG_NONE) {
-
-        unifi_trace(priv, UDBG1, "Deleting %s key %d\n",
-                    (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ? "GROUP" : "PAIRWISE",
-                    keyid);
-
-        if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-            sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
-        } else {
-            sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
-        }
-        sme_key.keyIndex = (keyid - 1);
-        sme_key.keyLength = 0;
-        sme_key.authenticator = 0;
-        memcpy(sme_key.address.a, a, ETH_ALEN);
-        UF_RTNL_UNLOCK();
-        r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_REMOVE);
-        UF_RTNL_LOCK();
-        if (r) {
-            unifi_error(priv, "Delete key request was rejected with result %d\n", r);
-            return convert_sme_error(r);
-        }
-
-        return 0;
-    }
-
-    /*
-     * Request is to set a key, not delete
-     */
-
-    /* Pick out WEP and use set_wep_key(). */
-    if (ext->alg == IW_ENCODE_ALG_WEP) {
-        /* WEP-40, WEP-104 */
-
-        /* Check for valid key length */
-        if (!((ext->key_len == 5) || (ext->key_len == 13))) {
-            unifi_trace(priv, UDBG1, KERN_ERR "Invalid length for WEP key: %d\n", ext->key_len);
-            return -EINVAL;
-        }
-
-        unifi_trace(priv, UDBG1, "Setting WEP key %d tx:%d\n",
-                    keyid, ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY);
-
-        if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-            sme_key.wepTxKey = TRUE;
-            sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
-        } else {
-            sme_key.wepTxKey = FALSE;
-            sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
-        }
-        sme_key.keyIndex = (keyid - 1);
-        sme_key.keyLength = ext->key_len;
-        sme_key.authenticator = 0;
-        memset(sme_key.address.a, 0xFF, ETH_ALEN);
-        memcpy(sme_key.key, keydata, ext->key_len);
-        UF_RTNL_UNLOCK();
-        r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
-        UF_RTNL_LOCK();
-        if (r) {
-            unifi_error(priv, "siwencodeext: Set key failed (%d)", r);
-            return convert_sme_error(r);
-        }
-
-        return 0;
-    }
-
-    /*
-     *
-     * If we reach here, we are dealing with a WPA/WPA2 key
-     *
-     */
-    if (ext->key_len > 32) {
-        return -EINVAL;
-    }
-
-    /*
-     * TKIP keys from wpa_supplicant need swapping.
-     * What about other supplicants (when they come along)?
-     */
-    if ((ext->alg == IW_ENCODE_ALG_TKIP) && (ext->key_len == 32)) {
-        memcpy(tkip_key, keydata, 16);
-        memcpy(tkip_key + 16, keydata + 24, 8);
-        memcpy(tkip_key + 24, keydata + 16, 8);
-        keydata = tkip_key;
-    }
-
-    key_type = (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ?
-        CSR_WIFI_SME_KEY_TYPE_GROUP : /* Group Key */
-        CSR_WIFI_SME_KEY_TYPE_PAIRWISE; /* Pairwise Key */
-
-    sme_key.keyType = key_type;
-    sme_key.keyIndex = (keyid - 1);
-    sme_key.keyLength = ext->key_len;
-    sme_key.authenticator = 0;
-    memcpy(sme_key.address.a, ext->addr.sa_data, ETH_ALEN);
-    if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
-
-               unifi_trace(priv, UDBG5, "RSC first 6 bytes = %*phC\n",
-                                        6, ext->rx_seq);
-
-        /* memcpy((u8*)(&sme_key.keyRsc), ext->rx_seq, 8); */
-        sme_key.keyRsc[0] = ext->rx_seq[1] << 8 | ext->rx_seq[0];
-        sme_key.keyRsc[1] = ext->rx_seq[3] << 8 | ext->rx_seq[2];
-        sme_key.keyRsc[2] = ext->rx_seq[5] << 8 | ext->rx_seq[4];
-        sme_key.keyRsc[3] = ext->rx_seq[7] << 8 | ext->rx_seq[6];
-
-    }
-
-    memcpy(sme_key.key, keydata, ext->key_len);
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "SETKEYS request was rejected with result %d\n", r);
-        return convert_sme_error(r);
-    }
-
-    return r;
-} /* _unifi_siwencodeext() */
-
-
-static int
-unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    int err = 0;
-
-    err = _unifi_siwencodeext(dev, info, wrqu, extra);
-
-    return err;
-} /* unifi_siwencodeext() */
-
-
-static int
-unifi_giwencodeext(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    return -EOPNOTSUPP;
-} /* unifi_giwencodeext() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_siwpmksa
- *
- *      SIOCSIWPMKSA - PMKSA cache operation
- *      The caller passes a pmksa structure:
- *        - cmd         one of ADD, REMOVE, FLUSH
- *        - bssid       MAC address
- *        - pmkid       ID string (16 bytes)
- *
- *  Arguments:
- *      None.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      This is not needed since we provide a siwgenie method.
- * ---------------------------------------------------------------------------
- */
-#define UNIFI_PMKID_KEY_SIZE 16
-static int
-unifi_siwpmksa(struct net_device *dev, struct iw_request_info *info,
-        union iwreq_data *wrqu, char *extra)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-    struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
-    CsrResult r = 0;
-    CsrWifiSmePmkidList pmkid_list;
-    CsrWifiSmePmkid pmkid;
-    CsrWifiSmeListAction action;
-
-    CHECK_INITED(priv);
-
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-       unifi_error(priv, "unifi_siwpmksa: not permitted in Mode %d\n",
-                                      interfacePriv->interfaceMode);
-       return -EPERM;
-    }
-
-
-       unifi_trace(priv, UDBG1, "SIWPMKSA: cmd %d, %pM\n", pmksa->cmd,
-               pmksa->bssid.sa_data);
-
-    pmkid_list.pmkids = NULL;
-    switch (pmksa->cmd) {
-      case IW_PMKSA_ADD:
-        pmkid_list.pmkids = &pmkid;
-        action = CSR_WIFI_SME_LIST_ACTION_ADD;
-        pmkid_list.pmkidsCount = 1;
-        memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN);
-        memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE);
-        break;
-      case IW_PMKSA_REMOVE:
-        pmkid_list.pmkids = &pmkid;
-        action = CSR_WIFI_SME_LIST_ACTION_REMOVE;
-        pmkid_list.pmkidsCount = 1;
-        memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN);
-        memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE);
-        break;
-      case IW_PMKSA_FLUSH:
-        /* Replace current PMKID's with an empty list */
-        pmkid_list.pmkidsCount = 0;
-        action = CSR_WIFI_SME_LIST_ACTION_FLUSH;
-        break;
-      default:
-        unifi_notice(priv, "SIWPMKSA: Unknown command (0x%x)\n", pmksa->cmd);
-        return -EINVAL;
-    }
-
-    /* Set the Value the pmkid's will have 1 added OR 1 removed OR be cleared at this point */
-    UF_RTNL_UNLOCK();
-    r = sme_mgt_pmkid(priv, action, &pmkid_list);
-    UF_RTNL_LOCK();
-    if (r) {
-        unifi_error(priv, "SIWPMKSA: Set PMKID's Failed.\n");
-    }
-
-    return r;
-
-} /* unifi_siwpmksa() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_get_wireless_stats
- *
- *      get_wireless_stats method for Linux wireless extensions.
- *
- *  Arguments:
- *      dev             Pointer to associated netdevice.
- *
- *  Returns:
- *      Pointer to iw_statistics struct.
- * ---------------------------------------------------------------------------
- */
-struct iw_statistics *
-unifi_get_wireless_stats(struct net_device *dev)
-{
-    netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    if (priv->init_progress != UNIFI_INIT_COMPLETED) {
-        return NULL;
-    }
-
-    return &priv->wext_wireless_stats;
-} /* unifi_get_wireless_stats() */
-
-
-/*
- * Structures to export the Wireless Handlers
- */
-
-static const struct iw_priv_args unifi_private_args[] = {
-    /*{ cmd,         set_args,                            get_args, name } */
-    { SIOCIWS80211POWERSAVEPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
-        IW_PRIV_TYPE_NONE, "iwprivs80211ps" },
-    { SIOCIWG80211POWERSAVEPRIV, IW_PRIV_TYPE_NONE,
-        IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IWPRIV_POWER_SAVE_MAX_STRING, "iwprivg80211ps" },
-    { SIOCIWS80211RELOADDEFAULTSPRIV, IW_PRIV_TYPE_NONE,
-        IW_PRIV_TYPE_NONE, "iwprivsdefs" },
-    { SIOCIWSSMEDEBUGPRIV, IW_PRIV_TYPE_CHAR | IWPRIV_SME_DEBUG_MAX_STRING, IW_PRIV_TYPE_NONE, "iwprivssmedebug" },
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    { SIOCIWSCONFWAPIPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
-        IW_PRIV_TYPE_NONE, "iwprivsconfwapi" },
-    { SIOCIWSWAPIKEYPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(unifiio_wapi_key_t),
-        IW_PRIV_TYPE_NONE, "iwprivswpikey" },
-#endif
-#ifdef CSR_SUPPORT_WEXT_AP
-    { SIOCIWSAPCFGPRIV, IW_PRIV_TYPE_CHAR | 256, IW_PRIV_TYPE_NONE, "AP_SET_CFG" },
-    { SIOCIWSAPSTARTPRIV, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "AP_BSS_START" },
-    { SIOCIWSAPSTOPPRIV, IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0,
-      IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "AP_BSS_STOP" },
-#ifdef ANDROID_BUILD
-    { SIOCIWSFWRELOADPRIV, IW_PRIV_TYPE_CHAR |256,
-      IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "WL_FW_RELOAD" },
-    { SIOCIWSSTACKSTART, 0,
-      IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "START" },
-    { SIOCIWSSTACKSTOP, 0,
-      IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "STOP" },
-#endif /* ANDROID_BUILD */
-#endif /* CSR_SUPPORT_WEXT_AP */
-};
-
-static const iw_handler unifi_handler[] =
-{
-    (iw_handler) unifi_siwcommit,           /* SIOCSIWCOMMIT */
-    (iw_handler) unifi_giwname,             /* SIOCGIWNAME */
-    (iw_handler) NULL,                      /* SIOCSIWNWID */
-    (iw_handler) NULL,                      /* SIOCGIWNWID */
-    (iw_handler) unifi_siwfreq,             /* SIOCSIWFREQ */
-    (iw_handler) unifi_giwfreq,             /* SIOCGIWFREQ */
-    (iw_handler) unifi_siwmode,             /* SIOCSIWMODE */
-    (iw_handler) unifi_giwmode,             /* SIOCGIWMODE */
-    (iw_handler) NULL,                      /* SIOCSIWSENS */
-    (iw_handler) NULL,                      /* SIOCGIWSENS */
-    (iw_handler) NULL,                      /* SIOCSIWRANGE */
-    (iw_handler) unifi_giwrange,            /* SIOCGIWRANGE */
-    (iw_handler) NULL,                      /* SIOCSIWPRIV */
-    (iw_handler) NULL,                      /* SIOCGIWPRIV */
-    (iw_handler) NULL,                      /* SIOCSIWSTATS */
-    (iw_handler) NULL,                      /* SIOCGIWSTATS */
-    (iw_handler) NULL,                      /* SIOCSIWSPY */
-    (iw_handler) NULL,                      /* SIOCGIWSPY */
-    (iw_handler) NULL,                      /* SIOCSIWTHRSPY */
-    (iw_handler) NULL,                      /* SIOCGIWTHRSPY */
-    (iw_handler) unifi_siwap,               /* SIOCSIWAP */
-    (iw_handler) unifi_giwap,               /* SIOCGIWAP */
-#if WIRELESS_EXT > 17
-    /* WPA : IEEE 802.11 MLME requests */
-    unifi_siwmlme,              /* SIOCSIWMLME, request MLME operation */
-#else
-    (iw_handler) NULL,                      /* -- hole -- */
-#endif
-    (iw_handler) NULL,                      /* SIOCGIWAPLIST */
-    (iw_handler) unifi_siwscan,             /* SIOCSIWSCAN */
-    (iw_handler) unifi_giwscan,             /* SIOCGIWSCAN */
-    (iw_handler) unifi_siwessid,            /* SIOCSIWESSID */
-    (iw_handler) unifi_giwessid,            /* SIOCGIWESSID */
-    (iw_handler) NULL,                      /* SIOCSIWNICKN */
-    (iw_handler) NULL,                      /* SIOCGIWNICKN */
-    (iw_handler) NULL,                      /* -- hole -- */
-    (iw_handler) NULL,                      /* -- hole -- */
-    unifi_siwrate,                          /* SIOCSIWRATE */
-    unifi_giwrate,                          /* SIOCGIWRATE */
-    unifi_siwrts,                           /* SIOCSIWRTS */
-    unifi_giwrts,                           /* SIOCGIWRTS */
-    unifi_siwfrag,                          /* SIOCSIWFRAG */
-    unifi_giwfrag,                          /* SIOCGIWFRAG */
-    (iw_handler) NULL,                      /* SIOCSIWTXPOW */
-    (iw_handler) NULL,                      /* SIOCGIWTXPOW */
-    (iw_handler) NULL,                      /* SIOCSIWRETRY */
-    (iw_handler) NULL,                      /* SIOCGIWRETRY */
-    unifi_siwencode,                        /* SIOCSIWENCODE */
-    unifi_giwencode,                        /* SIOCGIWENCODE */
-    unifi_siwpower,                         /* SIOCSIWPOWER */
-    unifi_giwpower,                         /* SIOCGIWPOWER */
-#if WIRELESS_EXT > 17
-    (iw_handler) NULL,                      /* -- hole -- */
-    (iw_handler) NULL,                      /* -- hole -- */
-
-    /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
-    unifi_siwgenie,             /* SIOCSIWGENIE */      /* set generic IE */
-    unifi_giwgenie,             /* SIOCGIWGENIE */      /* get generic IE */
-
-    /* WPA : Authentication mode parameters */
-    unifi_siwauth,              /* SIOCSIWAUTH */       /* set authentication mode params */
-    unifi_giwauth,              /* SIOCGIWAUTH */       /* get authentication mode params */
-
-    /* WPA : Extended version of encoding configuration */
-    unifi_siwencodeext,         /* SIOCSIWENCODEEXT */  /* set encoding token & mode */
-    unifi_giwencodeext,         /* SIOCGIWENCODEEXT */  /* get encoding token & mode */
-
-    /* WPA2 : PMKSA cache management */
-    unifi_siwpmksa,             /* SIOCSIWPMKSA */      /* PMKSA cache operation */
-    (iw_handler) NULL,          /* -- hole -- */
-#endif /* WIRELESS_EXT > 17 */
-};
-
-
-static const iw_handler unifi_private_handler[] =
-{
-    iwprivs80211ps,                 /* SIOCIWFIRSTPRIV */
-    iwprivg80211ps,                 /* SIOCIWFIRSTPRIV + 1 */
-    iwprivsdefs,                    /* SIOCIWFIRSTPRIV + 2 */
-    (iw_handler) NULL,
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    iwprivsconfwapi,                /* SIOCIWFIRSTPRIV + 4 */
-    (iw_handler) NULL,              /* SIOCIWFIRSTPRIV + 5 */
-    iwprivswpikey,                  /* SIOCIWFIRSTPRIV + 6 */
-#else
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-#endif
-    (iw_handler) NULL,
-    iwprivssmedebug,                /* SIOCIWFIRSTPRIV + 8 */
-#ifdef CSR_SUPPORT_WEXT_AP
-    (iw_handler) NULL,
-    iwprivsapconfig,
-    (iw_handler) NULL,
-    iwprivsapstart,
-    (iw_handler) NULL,
-    iwprivsapstop,
-    (iw_handler) NULL,
-#ifdef ANDROID_BUILD
-    iwprivsapfwreload,
-    (iw_handler) NULL,
-    iwprivsstackstart,
-    (iw_handler) NULL,
-    iwprivsstackstop,
-#else
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-#endif /* ANDROID_BUILD */
-#else
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-    (iw_handler) NULL,
-#endif /* CSR_SUPPORT_WEXT_AP */
-};
-
-struct iw_handler_def unifi_iw_handler_def =
-{
-    .num_standard       = sizeof(unifi_handler) / sizeof(iw_handler),
-    .num_private        = sizeof(unifi_private_handler) / sizeof(iw_handler),
-    .num_private_args   = sizeof(unifi_private_args) / sizeof(struct iw_priv_args),
-    .standard           = (iw_handler *) unifi_handler,
-    .private            = (iw_handler *) unifi_private_handler,
-    .private_args       = (struct iw_priv_args *) unifi_private_args,
-#if IW_HANDLER_VERSION >= 6
-    .get_wireless_stats = unifi_get_wireless_stats,
-#endif
-};
-
-
diff --git a/drivers/staging/csr/ul_int.c b/drivers/staging/csr/ul_int.c
deleted file mode 100644 (file)
index eb286e5..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     ul_int.c
- *
- *  PURPOSE:
- *      Manage list of client applications using UniFi.
- *
- * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "unifi_priv.h"
-#include "unifiio.h"
-#include "unifi_os.h"
-
-static void free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata);
-static void reset_driver_status(unifi_priv_t *priv);
-
-/*
- * ---------------------------------------------------------------------------
- *  ul_init_clients
- *
- *      Initialise the clients array to empty.
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      This function needs to be called before priv is stored in
- *      Unifi_instances[].
- * ---------------------------------------------------------------------------
- */
-void
-ul_init_clients(unifi_priv_t *priv)
-{
-    int id;
-    ul_client_t *ul_clients;
-
-    sema_init(&priv->udi_logging_mutex, 1);
-    priv->logging_client = NULL;
-
-    ul_clients = priv->ul_clients;
-
-    for (id = 0; id < MAX_UDI_CLIENTS; id++) {
-        memset(&ul_clients[id], 0, sizeof(ul_client_t));
-
-        ul_clients[id].client_id = id;
-        ul_clients[id].sender_id = UDI_SENDER_ID_BASE + (id << UDI_SENDER_ID_SHIFT);
-        ul_clients[id].instance = -1;
-        ul_clients[id].event_hook = NULL;
-
-        INIT_LIST_HEAD(&ul_clients[id].udi_log);
-        init_waitqueue_head(&ul_clients[id].udi_wq);
-        sema_init(&ul_clients[id].udi_sem, 1);
-
-        ul_clients[id].wake_up_wq_id = 0;
-        ul_clients[id].seq_no = 0;
-        ul_clients[id].wake_seq_no = 0;
-        ul_clients[id].snap_filter.count = 0;
-    }
-} /* ul_init_clients() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ul_register_client
- *
- *      This function registers a new ul client.
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      configuration   Special configuration for the client.
- *      udi_event_clbk  Callback for receiving event from unifi.
- *
- *  Returns:
- *      0 if a new clients is registered, -1 otherwise.
- * ---------------------------------------------------------------------------
- */
-ul_client_t *
-ul_register_client(unifi_priv_t *priv, unsigned int configuration,
-                   udi_event_t udi_event_clbk)
-{
-    unsigned char id, ref;
-    ul_client_t *ul_clients;
-
-    ul_clients = priv->ul_clients;
-
-    /* check for an unused entry */
-    for (id = 0; id < MAX_UDI_CLIENTS; id++) {
-        if (ul_clients[id].udi_enabled == 0) {
-            ul_clients[id].instance = priv->instance;
-            ul_clients[id].udi_enabled = 1;
-            ul_clients[id].configuration = configuration;
-
-            /* Allocate memory for the reply signal.. */
-            ul_clients[id].reply_signal = kmalloc(sizeof(CSR_SIGNAL), GFP_KERNEL);
-            if (ul_clients[id].reply_signal == NULL) {
-                unifi_error(priv, "Failed to allocate reply signal for client.\n");
-                return NULL;
-            }
-            /* .. and the bulk data of the reply signal. */
-            for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) {
-                ul_clients[id].reply_bulkdata[ref] = kmalloc(sizeof(bulk_data_t), GFP_KERNEL);
-                /* If allocation fails, free allocated memory. */
-                if (ul_clients[id].reply_bulkdata[ref] == NULL) {
-                    for (; ref > 0; ref --) {
-                        kfree(ul_clients[id].reply_bulkdata[ref - 1]);
-                    }
-                    kfree(ul_clients[id].reply_signal);
-                    unifi_error(priv, "Failed to allocate bulk data buffers for client.\n");
-                    return NULL;
-                }
-            }
-
-            /* Set the event callback. */
-            ul_clients[id].event_hook = udi_event_clbk;
-
-            unifi_trace(priv, UDBG2, "UDI %d (0x%x) registered. configuration = 0x%x\n",
-                        id, &ul_clients[id], configuration);
-            return &ul_clients[id];
-        }
-    }
-    return NULL;
-} /* ul_register_client() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ul_deregister_client
- *
- *      This function deregisters a blocking UDI client.
- *
- *  Arguments:
- *      client      Pointer to the client we deregister.
- *
- *  Returns:
- *      0 if a new clients is deregistered.
- * ---------------------------------------------------------------------------
- */
-int
-ul_deregister_client(ul_client_t *ul_client)
-{
-    struct list_head *pos, *n;
-    udi_log_t *logptr;
-    unifi_priv_t *priv = uf_find_instance(ul_client->instance);
-    int ref;
-
-    ul_client->instance = -1;
-    ul_client->event_hook = NULL;
-    ul_client->udi_enabled = 0;
-    unifi_trace(priv, UDBG5, "UDI (0x%x) deregistered.\n", ul_client);
-
-    /* Free memory allocated for the reply signal and its bulk data. */
-    kfree(ul_client->reply_signal);
-    for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) {
-        kfree(ul_client->reply_bulkdata[ref]);
-    }
-
-    if (ul_client->snap_filter.count) {
-        ul_client->snap_filter.count = 0;
-        kfree(ul_client->snap_filter.protocols);
-    }
-
-    /* Free anything pending on the udi_log list */
-    down(&ul_client->udi_sem);
-    list_for_each_safe(pos, n, &ul_client->udi_log)
-    {
-        logptr = list_entry(pos, udi_log_t, q);
-        list_del(pos);
-        kfree(logptr);
-    }
-    up(&ul_client->udi_sem);
-
-    return 0;
-} /* ul_deregister_client() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  logging_handler
- *
- *      This function is registered with the driver core.
- *      It is called every time a UniFi HIP Signal is sent. It iterates over
- *      the list of processes interested in receiving log events and
- *      delivers the events to them.
- *
- *  Arguments:
- *      ospriv      Pointer to driver's private data.
- *      sigdata     Pointer to the packed signal buffer.
- *      signal_len  Length of the packed signal.
- *      bulkdata    Pointer to the signal's bulk data.
- *      dir         Direction of the signal
- *                  0 = from-host
- *                  1 = to-host
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-logging_handler(void *ospriv,
-                u8 *sigdata, u32 signal_len,
-                const bulk_data_param_t *bulkdata,
-                enum udi_log_direction direction)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    ul_client_t *client;
-    int dir;
-
-    dir = (direction == UDI_LOG_FROM_HOST) ? UDI_FROM_HOST : UDI_TO_HOST;
-
-    down(&priv->udi_logging_mutex);
-    client = priv->logging_client;
-    if (client != NULL) {
-        client->event_hook(client, sigdata, signal_len,
-                           bulkdata, dir);
-    }
-    up(&priv->udi_logging_mutex);
-
-} /* logging_handler() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ul_log_config_ind
- *
- *      This function uses the client's register callback
- *      to indicate configuration information e.g core errors.
- *
- *  Arguments:
- *      priv        Pointer to driver's private data.
- *      conf_param  Pointer to the configuration data.
- *      len         Length of the configuration data.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len)
-{
-#ifdef CSR_SUPPORT_SME
-    if (priv->smepriv == NULL)
-    {
-        return;
-    }
-    if ((CONFIG_IND_ERROR == (*conf_param)) && (priv->wifi_on_state == wifi_on_in_progress)) {
-        unifi_notice(priv, "ul_log_config_ind: wifi on in progress, suppress error\n");
-    } else {
-        /* wifi_off_ind (error or exit) */
-        CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, (CsrWifiRouterCtrlControlIndication)(*conf_param));
-    }
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-    unifi_debug_buf_dump();
-#endif
-#else
-    bulk_data_param_t bulkdata;
-
-    /*
-     * If someone killed unifi_managed before the driver was unloaded
-     * the g_drvpriv pointer is going to be NULL. In this case it is
-     * safe to assume that there is no client to get the indication.
-     */
-    if (!priv) {
-        unifi_notice(NULL, "uf_sme_event_ind: NULL priv\n");
-        return;
-    }
-
-    /* Create a null bulkdata structure. */
-    bulkdata.d[0].data_length = 0;
-    bulkdata.d[1].data_length = 0;
-
-    sme_native_log_event(priv->sme_cli, conf_param, sizeof(u8),
-                         &bulkdata, UDI_CONFIG_IND);
-
-#endif /* CSR_SUPPORT_SME */
-
-} /* ul_log_config_ind */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  free_bulkdata_buffers
- *
- *      Free the bulkdata buffers e.g. after a failed unifi_send_signal().
- *
- *  Arguments:
- *      priv        Pointer to device private struct
- *      bulkdata    Pointer to bulkdata parameter table
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata)
-{
-    int i;
-
-    if (bulkdata) {
-        for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) {
-            if (bulkdata->d[i].data_length != 0) {
-                unifi_net_data_free(priv, (bulk_data_desc_t *)(&bulkdata->d[i]));
-                /* data_length is now 0 */
-            }
-        }
-    }
-
-} /* free_bulkdata_buffers */
-
-static int
-_align_bulk_data_buffers(unifi_priv_t *priv, u8 *signal,
-                         bulk_data_param_t *bulkdata)
-{
-    unsigned int i;
-
-    if ((bulkdata == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) {
-        return 0;
-    }
-
-    for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
-    {
-        struct sk_buff *skb;
-        /*
-        * The following complex casting is in place in order to eliminate 64-bit compilation warning
-        * "cast to/from pointer from/to integer of different size"
-        */
-        u32 align_offset = (u32)(long)(bulkdata->d[i].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
-        if (align_offset)
-        {
-            skb = (struct sk_buff*)bulkdata->d[i].os_net_buf_ptr;
-            if (skb == NULL) {
-                unifi_warning(priv,
-                              "_align_bulk_data_buffers: Align offset found (%d) but skb is NULL!\n",
-                              align_offset);
-                return -EINVAL;
-            }
-            if (bulkdata->d[i].data_length == 0) {
-                unifi_warning(priv,
-                              "_align_bulk_data_buffers: Align offset found (%d) but length is zero\n",
-                              align_offset);
-                return CSR_RESULT_SUCCESS;
-            }
-            unifi_trace(priv, UDBG5,
-                        "Align f-h buffer (0x%p) by %d bytes (skb->data: 0x%p)\n",
-                        bulkdata->d[i].os_data_ptr, align_offset, skb->data);
-
-
-            /* Check if there is enough headroom... */
-            if (unlikely(skb_headroom(skb) < align_offset))
-            {
-                struct sk_buff *tmp = skb;
-
-                unifi_trace(priv, UDBG5, "Headroom not enough - realloc it\n");
-                skb = skb_realloc_headroom(skb, align_offset);
-                if (skb == NULL) {
-                    unifi_error(priv,
-                                "_align_bulk_data_buffers: skb_realloc_headroom failed - signal is dropped\n");
-                    return -EFAULT;
-                }
-                /* Free the old bulk data only if allocation succeeds */
-                kfree_skb(tmp);
-                /* Bulkdata needs to point to the new skb */
-                bulkdata->d[i].os_net_buf_ptr = (const unsigned char*)skb;
-                bulkdata->d[i].os_data_ptr = (const void*)skb->data;
-            }
-            /* ... before pushing the data to the right alignment offset */
-            skb_push(skb, align_offset);
-
-        }
-        /* The direction bit is zero for the from-host */
-        signal[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1] = align_offset;
-
-    }
-    return 0;
-} /* _align_bulk_data_buffers() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ul_send_signal_unpacked
- *
- *      This function sends a host formatted signal to unifi.
- *
- *  Arguments:
- *      priv        Pointer to driver's private data.
- *      sigptr      Pointer to the signal.
- *      bulkdata    Pointer to the signal's bulk data.
- *
- *  Returns:
- *      O on success, error code otherwise.
- *
- *  Notes:
- *  The signals have to be sent in the format described in the host interface
- *  specification, i.e wire formatted. Certain clients use the host formatted
- *  structures. The write_pack() transforms the host formatted signal
- *  into the wired formatted signal. The code is in the core, since the signals
- *  are defined therefore binded to the host interface specification.
- * ---------------------------------------------------------------------------
- */
-int
-ul_send_signal_unpacked(unifi_priv_t *priv, CSR_SIGNAL *sigptr,
-                        bulk_data_param_t *bulkdata)
-{
-    u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
-    u16 packed_siglen;
-    CsrResult csrResult;
-    unsigned long lock_flags;
-    int r;
-
-
-    csrResult = write_pack(sigptr, sigbuf, &packed_siglen);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "Malformed HIP signal in ul_send_signal_unpacked()\n");
-        return CsrHipResultToStatus(csrResult);
-    }
-    r = _align_bulk_data_buffers(priv, sigbuf, (bulk_data_param_t*)bulkdata);
-    if (r) {
-        return r;
-    }
-
-    spin_lock_irqsave(&priv->send_signal_lock, lock_flags);
-    csrResult = unifi_send_signal(priv->card, sigbuf, packed_siglen, bulkdata);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-  /*      free_bulkdata_buffers(priv, (bulk_data_param_t *)bulkdata); */
-        spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
-        return CsrHipResultToStatus(csrResult);
-    }
-    spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
-
-    return 0;
-} /* ul_send_signal_unpacked() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  reset_driver_status
- *
- *      This function is called from ul_send_signal_raw() when it detects
- *      that the SME has sent a MLME-RESET request.
- *
- *  Arguments:
- *      priv        Pointer to device private struct
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-static void
-reset_driver_status(unifi_priv_t *priv)
-{
-    priv->sta_wmm_capabilities = 0;
-#ifdef CSR_NATIVE_LINUX
-#ifdef CSR_SUPPORT_WEXT
-    priv->wext_conf.flag_associated = 0;
-    priv->wext_conf.block_controlled_port = CSR_WIFI_ROUTER_PORT_ACTION_8021X_PORT_OPEN;
-    priv->wext_conf.bss_wmm_capabilities = 0;
-    priv->wext_conf.disable_join_on_ssid_set = 0;
-#endif
-#endif
-} /* reset_driver_status() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  ul_send_signal_raw
- *
- *      This function sends a wire formatted data signal to unifi.
- *
- *  Arguments:
- *      priv        Pointer to driver's private data.
- *      sigptr      Pointer to the signal.
- *      siglen      Length of the signal.
- *      bulkdata    Pointer to the signal's bulk data.
- *
- *  Returns:
- *      O on success, error code otherwise.
- * ---------------------------------------------------------------------------
- */
-int
-ul_send_signal_raw(unifi_priv_t *priv, unsigned char *sigptr, int siglen,
-                   bulk_data_param_t *bulkdata)
-{
-    CsrResult csrResult;
-    unsigned long lock_flags;
-    int r;
-
-    /*
-     * Make sure that the signal is updated with the bulk data
-     * alignment for DMA.
-     */
-    r = _align_bulk_data_buffers(priv, (u8*)sigptr, bulkdata);
-    if (r) {
-        return r;
-    }
-
-    spin_lock_irqsave(&priv->send_signal_lock, lock_flags);
-    csrResult = unifi_send_signal(priv->card, sigptr, siglen, bulkdata);
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        free_bulkdata_buffers(priv, bulkdata);
-        spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
-        return CsrHipResultToStatus(csrResult);
-    }
-    spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
-
-    /*
-     * Since this is use by unicli, if we get an MLME reset request
-     * we need to initialize a few status parameters
-     * that the driver uses to make decisions.
-     */
-    if (GET_SIGNAL_ID(sigptr) == CSR_MLME_RESET_REQUEST_ID) {
-        reset_driver_status(priv);
-    }
-
-    return 0;
-} /* ul_send_signal_raw() */
-
-
diff --git a/drivers/staging/csr/unifi_clients.h b/drivers/staging/csr/unifi_clients.h
deleted file mode 100644 (file)
index df853e1..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *****************************************************************************
- *
- * FILE : unifi_clients.h
- *
- * PURPOSE : Private header file for unifi clients.
- *
- *           UDI = UniFi Debug Interface
- *
- * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- *****************************************************************************
- */
-#ifndef __LINUX_UNIFI_CLIENTS_H__
-#define __LINUX_UNIFI_CLIENTS_H__ 1
-
-#include <linux/kernel.h>
-
-#define MAX_UDI_CLIENTS 8
-
-/* The start of the range of process ids allocated for ul clients */
-#define UDI_SENDER_ID_BASE      0xC000
-#define UDI_SENDER_ID_SHIFT     8
-
-
-/* Structure to hold a UDI logged signal */
-typedef struct {
-
-    /* List link structure */
-    struct list_head q;
-
-    /* The message that will be passed to the user app */
-    udi_msg_t msg;
-
-    /* Signal body and data follow */
-
-} udi_log_t;
-
-
-
-typedef struct ul_client ul_client_t;
-
-typedef void (*udi_event_t)(ul_client_t *client,
-                            const u8 *sigdata, int signal_len,
-                            const bulk_data_param_t *bulkdata,
-                            int dir);
-
-void logging_handler(void *ospriv,
-                     u8 *sigdata, u32 signal_len,
-                     const bulk_data_param_t *bulkdata,
-                     enum udi_log_direction direction);
-
-
-/*
- * Structure describing a bulk data slot.
- * The length field is used to indicate empty/occupied state.
- */
-typedef struct _bulk_data
-{
-    unsigned char ptr[2000];
-    unsigned int length;
-} bulk_data_t;
-
-
-struct ul_client {
-    /* Index of this client in the ul_clients array. */
-    int client_id;
-
-    /* Index of UniFi device to which this client is attached. */
-    int instance;
-
-    /* Flag to say whether this client has been enabled. */
-    int udi_enabled;
-
-    /* Value to use in signal->SenderProcessId */
-    int sender_id;
-
-    /* Configuration flags, e.g blocking, logging, etc. */
-    unsigned int configuration;
-
-    udi_event_t event_hook;
-
-    /* A list to hold signals received from UniFi for reading by read() */
-    struct list_head udi_log;
-
-    /* Semaphore to protect the udi_log list */
-    struct semaphore udi_sem;
-
-    /*
-     * Linux waitqueue to support blocking read and poll.
-     * Logging clients should wait on udi_log. while
-     * blocking clients should wait on wake_up_wq.
-     */
-    wait_queue_head_t udi_wq;
-    CSR_SIGNAL* reply_signal;
-    bulk_data_t* reply_bulkdata[UNIFI_MAX_DATA_REFERENCES];
-
-    u16 signal_filter[SIG_FILTER_SIZE];
-
-
-    /* ------------------------------------------------------------------- */
-    /* Code below here is used by the sme_native configuration only */
-
-    /* Flag to wake up blocking clients waiting on udi_wq. */
-    int wake_up_wq_id;
-
-    /*
-     * A 0x00 - 0x0F mask to apply in signal->SenderProcessId.
-     * Every time we do a blocking mlme request we increase this value.
-     * The mlme_wait_for_reply() will wait for this sequence number.
-     * Only the MLME blocking functions update this field.
-     */
-    unsigned char seq_no;
-
-    /*
-     * A 0x00 - 0x0F counter, containing the sequence number of
-     * the signal that this client has last received.
-     * Only the MLME blocking functions update this field.
-     */
-    unsigned char wake_seq_no;
-
-    unifiio_snap_filter_t snap_filter;
-}; /* struct ul_client */
-
-
-#endif /* __LINUX_UNIFI_CLIENTS_H__ */
diff --git a/drivers/staging/csr/unifi_config.h b/drivers/staging/csr/unifi_config.h
deleted file mode 100644 (file)
index fe11970..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *
- * FILE: unifi_config.h
- *
- * PURPOSE:
- *      This header file provides parameters that configure the operation
- *      of the driver.
- *
- * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __UNIFI_CONFIG_H__
-#define __UNIFI_CONFIG_H__ 1
-
-/*
- * Override for the SDIO function block size on this host. When byte mode CMD53s
- * are not used/supported by the SD host controller, transfers are padded up to
- * the next block boundary. The 512-byte default on UF6xxx wastes too much space
- * on the chip, so the block size is reduced to support this configuration.
- */
-#define CSR_WIFI_HIP_SDIO_BLOCK_SIZE  64
-
-/* Define the number of mini-coredump buffers to allocate at startup. These are
- * used to record chip status for the last n unexpected resets.
- */
-#define CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS  5
-
-
-#endif /* __UNIFI_CONFIG_H__ */
diff --git a/drivers/staging/csr/unifi_dbg.c b/drivers/staging/csr/unifi_dbg.c
deleted file mode 100644 (file)
index 38d5708..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     unifi_dbg.c
- *
- *  PURPOSE:
- *      Handle debug signals received from UniFi.
- *
- * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-#include "unifi_priv.h"
-
-/*
- * ---------------------------------------------------------------------------
- *  debug_string_indication
- *  debug_word16_indication
- *
- *      Handlers for debug indications.
- *
- *  Arguments:
- *      priv            Pointer to private context structure.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-debug_string_indication(unifi_priv_t *priv, const unsigned char *extra, unsigned int extralen)
-{
-    const unsigned int maxlen = sizeof(priv->last_debug_string) - 1;
-
-    if (extralen > maxlen) {
-        extralen = maxlen;
-    }
-
-    strncpy(priv->last_debug_string, extra, extralen);
-
-    /* Make sure the string is terminated */
-    priv->last_debug_string[extralen] = '\0';
-
-    unifi_info(priv, "unifi debug: %s\n", priv->last_debug_string);
-
-} /* debug_string_indication() */
-
-
-
-void
-debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
-{
-    int i;
-
-    if (priv == NULL) {
-        unifi_info(priv, "Priv is NULL\n");
-        return;
-    }
-
-    for (i = 0; i < 16; i++) {
-        priv->last_debug_word16[i] =
-                sigptr->u.DebugWord16Indication.DebugWords[i];
-    }
-
-    if (priv->last_debug_word16[0] == 0xFA11) {
-        unsigned long ts;
-        ts = (priv->last_debug_word16[6] << 16) | priv->last_debug_word16[5];
-        unifi_info(priv, " %10lu: %s fault %04x, arg %04x (x%d)\n",
-                   ts,
-                   priv->last_debug_word16[3] == 0x8000 ? "MAC" :
-                   priv->last_debug_word16[3] == 0x4000 ? "PHY" :
-                   "???",
-                   priv->last_debug_word16[1],
-                   priv->last_debug_word16[2],
-                   priv->last_debug_word16[4]);
-    }
-    else if (priv->last_debug_word16[0] != 0xDBAC)
-        /* suppress SDL Trace output (note: still available to unicli). */
-    {
-        unifi_info(priv, "unifi debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
-                   priv->last_debug_word16[0], priv->last_debug_word16[1],
-                   priv->last_debug_word16[2], priv->last_debug_word16[3],
-                   priv->last_debug_word16[4], priv->last_debug_word16[5],
-                   priv->last_debug_word16[6], priv->last_debug_word16[7]);
-        unifi_info(priv, "             %04X %04X %04X %04X %04X %04X %04X %04X\n",
-                   priv->last_debug_word16[8], priv->last_debug_word16[9],
-                   priv->last_debug_word16[10], priv->last_debug_word16[11],
-                   priv->last_debug_word16[12], priv->last_debug_word16[13],
-                   priv->last_debug_word16[14], priv->last_debug_word16[15]);
-    }
-
-} /* debug_word16_indication() */
-
-
-void
-debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
-{
-    unifi_info(priv, "debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
-               sigptr->u.DebugGenericIndication.DebugWords[0],
-               sigptr->u.DebugGenericIndication.DebugWords[1],
-               sigptr->u.DebugGenericIndication.DebugWords[2],
-               sigptr->u.DebugGenericIndication.DebugWords[3],
-               sigptr->u.DebugGenericIndication.DebugWords[4],
-               sigptr->u.DebugGenericIndication.DebugWords[5],
-               sigptr->u.DebugGenericIndication.DebugWords[6],
-               sigptr->u.DebugGenericIndication.DebugWords[7]);
-
-} /* debug_generic_indication() */
-
diff --git a/drivers/staging/csr/unifi_event.c b/drivers/staging/csr/unifi_event.c
deleted file mode 100644 (file)
index 71fdb21..0000000
+++ /dev/null
@@ -1,692 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     unifi_event.c
- *
- *  PURPOSE:
- *      Process the signals received by UniFi.
- *      It is part of the porting exercise.
- *
- * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-
-
-/*
- * Porting notes:
- * The implementation of unifi_receive_event() in Linux is fairly complicated.
- * The linux driver support multiple userspace applications and several
- * build configurations, so the received signals are processed by different
- * processes and multiple times.
- * In a simple implementation, this function needs to deliver:
- * - The MLME-UNITDATA.ind signals to the Rx data plane and to the Traffic
- *   Analysis using unifi_ta_sample().
- * - The MLME-UNITDATA-STATUS.ind signals to the Tx data plane.
- * - All the other signals to the SME using unifi_sys_hip_ind().
- */
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "unifi_priv.h"
-
-
-/*
- * ---------------------------------------------------------------------------
- *  send_to_client
- *
- *      Helper for unifi_receive_event.
- *
- *      This function forwards a signal to one client.
- *
- *  Arguments:
- *      priv        Pointer to driver's private data.
- *      client      Pointer to the client structure.
- *      receiver_id The reciever id of the signal.
- *      sigdata     Pointer to the packed signal buffer.
- *      siglen      Length of the packed signal.
- *      bulkdata    Pointer to the signal's bulk data.
- *
- *  Returns:
- *      None.
- *
- * ---------------------------------------------------------------------------
- */
-static void send_to_client(unifi_priv_t *priv, ul_client_t *client,
-        int receiver_id,
-        unsigned char *sigdata, int siglen,
-        const bulk_data_param_t *bulkdata)
-{
-    if (client && client->event_hook) {
-        /*unifi_trace(priv, UDBG3,
-                "Receive: client %d, (s:0x%X, r:0x%X) - Signal 0x%.4X \n",
-                client->client_id, client->sender_id, receiver_id,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));*/
-
-        client->event_hook(client, sigdata, siglen, bulkdata, UDI_TO_HOST);
-    }
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  process_pkt_data_ind
- *
- *      Dispatcher for received signals.
- *
- *      This function receives the 'to host' signals and forwards
- *      them to the unifi linux clients.
- *
- *  Arguments:
- *      priv         Context
- *      sigdata      Pointer to the packed signal buffer(Its in form of MA-PACKET.ind).
- *      bulkdata     Pointer to signal's bulkdata
- *      freeBulkData Pointer to a flag which gets set if the bulkdata needs to
- *                   be freed after calling the logging handlers. If it is not
- *                   set the bulkdata must be freed by the MLME handler or
- *                   passed to the network stack.
- *  Returns:
- *      TRUE if the packet should be routed to the SME etc.
- *      FALSE if the packet is for the driver or network stack
- * ---------------------------------------------------------------------------
- */
-static u8 check_routing_pkt_data_ind(unifi_priv_t *priv,
-        u8 *sigdata,
-        const bulk_data_param_t* bulkdata,
-        u8 *freeBulkData,
-        netInterface_priv_t *interfacePriv)
-{
-    u16  frmCtrl, receptionStatus, frmCtrlSubType;
-    u8 *macHdrLocation;
-    u8 interfaceTag;
-    u8 isDataFrame;
-    u8 isProtocolVerInvalid = FALSE;
-    u8 isDataFrameSubTypeNoData = FALSE;
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    static const u8 wapiProtocolIdSNAPHeader[] = {0x88, 0xb4};
-    static const u8 wapiProtocolIdSNAPHeaderOffset = 6;
-    u8 *destAddr;
-    u8 *srcAddr;
-    u8 isWapiUnicastPkt = FALSE;
-
-#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
-    u16 qosControl;
-#endif
-
-    u8 llcSnapHeaderOffset = 0;
-
-    destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET;
-    srcAddr  = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET;
-
-    /*Individual/Group bit - Bit 0 of first byte*/
-    isWapiUnicastPkt = (!(destAddr[0] & 0x01)) ? TRUE : FALSE;
-#endif
-
-#define CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET    sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22
-
-    *freeBulkData = FALSE;
-
-    /* Fetch the MAC header location from  MA_PKT_IND packet */
-    macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
-    /* Fetch the Frame Control value from  MAC header */
-    frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
-
-    /* Pull out interface tag from virtual interface identifier */
-    interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + 14)) & 0xff;
-
-    /* check for MIC failure before processing the signal */
-    receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET);
-
-    /* To discard any spurious MIC failures that could be reported by the firmware */
-    isDataFrame = ((frmCtrl & IEEE80211_FC_TYPE_MASK) == (IEEE802_11_FC_TYPE_DATA & IEEE80211_FC_TYPE_MASK)) ? TRUE : FALSE;
-    /* 0x00 is the only valid protocol version*/
-    isProtocolVerInvalid = (frmCtrl & IEEE80211_FC_PROTO_VERSION_MASK) ? TRUE : FALSE;
-    frmCtrlSubType = (frmCtrl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET;
-    /*Exclude the no data & reserved sub-types from MIC failure processing*/
-    isDataFrameSubTypeNoData = (((frmCtrlSubType>0x03)&&(frmCtrlSubType<0x08)) || (frmCtrlSubType>0x0B)) ? TRUE : FALSE;
-    if ((receptionStatus == CSR_MICHAEL_MIC_ERROR) &&
-        ((!isDataFrame) || isProtocolVerInvalid || (isDataFrame && isDataFrameSubTypeNoData))) {
-        /* Currently MIC errors are discarded for frames other than data frames. This might need changing when we start
-         * supporting 802.11w (Protected Management frames)
-         */
-        *freeBulkData = TRUE;
-        unifi_trace(priv, UDBG4, "Discarding this frame and ignoring the MIC failure as this is a garbage/non-data/no data frame\n");
-        return FALSE;
-     }
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-
-    if (receptionStatus == CSR_MICHAEL_MIC_ERROR) {
-
-        if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
-
-#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
-            if ((isDataFrame) &&
-                ((IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK) == (frmCtrl & IEEE80211_FC_SUBTYPE_MASK)) &&
-                (priv->isWapiConnection))
-            {
-               qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation + (((frmCtrl & IEEE802_11_FC_TO_DS_MASK) && (frmCtrl & IEEE802_11_FC_FROM_DS_MASK)) ? 30 : 24) );
-
-               unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind() :: Value of the QoS control field - 0x%04x \n", qosControl);
-
-                if (qosControl & IEEE802_11_QC_NON_TID_BITS_MASK)
-                {
-                       unifi_trace(priv, UDBG4, "Ignore the MIC failure and pass the MPDU to the stack when any of bits [4-15] is set in the QoS control field\n");
-
-                       /*Exclude the MIC [16] and the PN [16] that are appended by the firmware*/
-                       ((bulk_data_param_t*)bulkdata)->d[0].data_length = bulkdata->d[0].data_length - 32;
-
-                       /*Clear the reception status of the signal (CSR_RX_SUCCESS)*/
-                       *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET)     = 0x00;
-                       *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET+1)   = 0x00;
-
-                       *freeBulkData = FALSE;
-
-                       return FALSE;
-                }
-            }
-#endif
-            /* If this MIC ERROR reported by the firmware is either for
-             *    [1] a WAPI Multicast MPDU and the Multicast filter has NOT been set (It is set only when group key index (MSKID) = 1 in Group Rekeying)   OR
-             *    [2] a WAPI Unicast MPDU and either the CONTROL PORT is open or the WAPI Unicast filter or filter(s) is NOT set
-             * then report a MIC FAILURE indication to the SME.
-             */
-#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
-       if ((priv->wapi_multicast_filter == 0) || isWapiUnicastPkt) {
-#else
-        /*When SW encryption is enabled and USKID=1 (wapi_unicast_filter = 1), we are expected
-                *to receive MIC failure INDs for unicast MPDUs*/
-       if ( ((priv->wapi_multicast_filter == 0) && !isWapiUnicastPkt) ||
-             ((priv->wapi_unicast_filter   == 0) &&  isWapiUnicastPkt) ) {
-#endif
-                /*Discard the frame*/
-                *freeBulkData = TRUE;
-                unifi_trace(priv, UDBG4, "Discarding the contents of the frame with MIC failure \n");
-
-                if (isWapiUnicastPkt &&
-                    ((uf_sme_port_state(priv, srcAddr, UF_CONTROLLED_PORT_Q, interfaceTag) != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)||
-#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
-                    (priv->wapi_unicast_filter) ||
-#endif
-                    (priv->wapi_unicast_queued_pkt_filter))) {
-
-                    /* Workaround to handle MIC failures reported by the firmware for encrypted packets from the AP
-                     * while we are in the process of re-association induced by unsupported WAPI Unicast key index
-                     *             - Discard the packets with MIC failures "until" we have
-                     *               a. negotiated a key,
-                     *               b. opened the CONTROL PORT and
-                     *               c. the AP has started using the new key
-                     */
-                    unifi_trace(priv, UDBG4, "Ignoring the MIC failure as either a. CONTROL PORT isn't OPEN or b. Unicast filter is set or c. WAPI AP using old key for buffered pkts\n");
-
-                    /*Ignore this MIC failure*/
-                    return FALSE;
-
-                }/*WAPI re-key specific workaround*/
-
-                unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n",
-                            interfaceTag, srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcAddr[4], srcAddr[5]);
-                unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Dest Addr %x:%x:%x:%x:%x:%x\n",
-                            destAddr[0], destAddr[1], destAddr[2], destAddr[3], destAddr[4], destAddr[5]);
-                unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Control Port State - 0x%.4X \n",
-                            uf_sme_port_state(priv, srcAddr, UF_CONTROLLED_PORT_Q, interfaceTag));
-
-                unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
-
-                /*Report the MIC failure to the SME*/
-                return TRUE;
-            }
-        }/* STA mode */
-        else {
-            /* Its AP Mode . Just Return */
-            *freeBulkData = TRUE;
-            unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
-            return TRUE;
-         } /* AP mode */
-    }/* MIC error */
-#else
-    if (receptionStatus == CSR_MICHAEL_MIC_ERROR) {
-        *freeBulkData = TRUE;
-        unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
-        return TRUE;
-    }
-#endif /*CSR_WIFI_SECURITY_WAPI_ENABLE*/
-
-    unifi_trace(priv, UDBG4, "frmCtrl = 0x%04x %s\n",
-                frmCtrl,
-                (((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) == IEEE802_11_FRAMETYPE_MANAGEMENT) ?
-                    "Mgt" : "Ctrl/Data");
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    /* To ignore MIC failures reported due to the WAPI AP using the old key for queued packets before
-     * starting to use the new key negotiated as part of unicast re-keying
-     */
-    if ((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA)&&
-        isWapiUnicastPkt &&
-        (receptionStatus == CSR_RX_SUCCESS) &&
-        (priv->wapi_unicast_queued_pkt_filter==1)) {
-
-        unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI unicast pkt received when the (wapi_unicast_queued_pkt_filter) is set\n");
-
-        if (isDataFrame) {
-            switch(frmCtrl & IEEE80211_FC_SUBTYPE_MASK) {
-                case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
-                    llcSnapHeaderOffset = MAC_HEADER_SIZE + 2;
-                    break;
-                case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
-                case IEEE802_11_FC_TYPE_NULL & IEEE80211_FC_SUBTYPE_MASK:
-                    break;
-                default:
-                    llcSnapHeaderOffset = MAC_HEADER_SIZE;
-            }
-        }
-
-        if (llcSnapHeaderOffset > 0) {
-               /* QoS data or Data */
-            unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): SNAP header found & its offset %d\n", llcSnapHeaderOffset);
-            if (memcmp((u8 *)(bulkdata->d[0].os_data_ptr+llcSnapHeaderOffset+wapiProtocolIdSNAPHeaderOffset),
-                       wapiProtocolIdSNAPHeader, sizeof(wapiProtocolIdSNAPHeader))) {
-
-               unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): This is a data & NOT a WAI protocol packet\n");
-                /* On the first unicast data pkt that is decrypted successfully after re-keying, reset the filter */
-                priv->wapi_unicast_queued_pkt_filter = 0;
-                unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind(): WAPI AP has started using the new unicast key, no more MIC failures expected (reset filter)\n");
-            }
-            else {
-                unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI - This is a WAI protocol packet\n");
-            }
-        }
-       }
-#endif
-
-
-    switch ((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) {
-        case IEEE802_11_FRAMETYPE_MANAGEMENT:
-            *freeBulkData = TRUE;       /* Free (after SME handler copies it) */
-
-            /* In P2P device mode, filter the legacy AP beacons here */
-            if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2P)&&\
-               ((CSR_WIFI_80211_GET_FRAME_SUBTYPE(macHdrLocation)) == CSR_WIFI_80211_FRAME_SUBTYPE_BEACON)){
-
-                u8 *pSsid, *pSsidLen;
-                static u8 P2PWildCardSsid[CSR_WIFI_P2P_WILDCARD_SSID_LENGTH] = {'D', 'I', 'R', 'E', 'C', 'T', '-'};
-
-                pSsidLen = macHdrLocation + MAC_HEADER_SIZE + CSR_WIFI_BEACON_FIXED_LENGTH;
-                pSsid = pSsidLen + 2;
-
-                if(*(pSsidLen + 1) >= CSR_WIFI_P2P_WILDCARD_SSID_LENGTH){
-                    if(memcmp(pSsid, P2PWildCardSsid, CSR_WIFI_P2P_WILDCARD_SSID_LENGTH) == 0){
-                        unifi_trace(priv, UDBG6, "Received a P2P Beacon, pass it to SME\n");
-                        return TRUE;
-                    }
-                }
-                unifi_trace(priv, UDBG6, "Received a Legacy AP beacon in P2P mode, drop it\n");
-                return FALSE;
-            }
-            return TRUE;                /* Route to SME */
-        case IEEE802_11_FRAMETYPE_DATA:
-        case IEEE802_11_FRAMETYPE_CONTROL:
-            *freeBulkData = FALSE;      /* Network stack or MLME handler frees */
-            return FALSE;
-        default:
-            unifi_error(priv, "Unhandled frame type %04x\n", frmCtrl);
-            *freeBulkData = TRUE;       /* Not interested, but must free it */
-            return FALSE;
-    }
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_process_receive_event
- *
- *      Dispatcher for received signals.
- *
- *      This function receives the 'to host' signals and forwards
- *      them to the unifi linux clients.
- *
- *  Arguments:
- *      ospriv      Pointer to driver's private data.
- *      sigdata     Pointer to the packed signal buffer.
- *      siglen      Length of the packed signal.
- *      bulkdata    Pointer to the signal's bulk data.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *  The signals are received in the format described in the host interface
- *  specification, i.e wire formatted. Certain clients use the same format
- *  to interpret them and other clients use the host formatted structures.
- *  Each client has to call read_unpack_signal() to transform the wire
- *  formatted signal into the host formatted signal, if necessary.
- *  The code is in the core, since the signals are defined therefore
- *  binded to the host interface specification.
- * ---------------------------------------------------------------------------
- */
-static void
-unifi_process_receive_event(void *ospriv,
-                            u8 *sigdata, u32 siglen,
-                            const bulk_data_param_t *bulkdata)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    int i, receiver_id;
-    int client_id;
-    s16 signal_id;
-    u8 pktIndToSme = FALSE, freeBulkData = FALSE;
-
-    unifi_trace(priv, UDBG5, "unifi_process_receive_event: "
-                "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n",
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF,
-                CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF,
-                siglen);
-
-    receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)) & 0xFF00;
-    client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT;
-    signal_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata);
-
-
-
-    /* check for the type of frame received (checks for 802.11 management frames) */
-    if (signal_id == CSR_MA_PACKET_INDICATION_ID)
-    {
-#define CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET    14
-        u8 interfaceTag;
-        netInterface_priv_t *interfacePriv;
-
-        /* Pull out interface tag from virtual interface identifier */
-        interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff;
-        interfacePriv = priv->interfacePriv[interfaceTag];
-
-        /* Update activity for this station in case of IBSS */
-#ifdef CSR_SUPPORT_SME
-        if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS)
-        {
-            u8 *saddr;
-            /* Fetch the source address from  mac header */
-            saddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET;
-            unifi_trace(priv, UDBG5,
-                                    "Updating sta activity in IBSS interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n",
-                                    interfaceTag, saddr[0], saddr[1], saddr[2], saddr[3], saddr[4], saddr[5]);
-
-            uf_update_sta_activity(priv, interfaceTag, saddr);
-        }
-#endif
-
-        pktIndToSme = check_routing_pkt_data_ind(priv, sigdata, bulkdata, &freeBulkData, interfacePriv);
-
-        unifi_trace(priv, UDBG6, "RX: packet entry point to driver from HIP,pkt to SME ?(%s) \n", (pktIndToSme)? "YES":"NO");
-
-    }
-
-    if (pktIndToSme)
-    {
-        /* Management MA_PACKET_IND for SME */
-        if(sigdata != NULL && bulkdata != NULL){
-            send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata);
-        }
-        else{
-            unifi_error(priv, "unifi_receive_event2: sigdata or Bulkdata is NULL \n");
-        }
-#ifdef CSR_NATIVE_LINUX
-        send_to_client(priv, priv->wext_client,
-                receiver_id,
-                sigdata, siglen, bulkdata);
-#endif
-    }
-    else
-    {
-        /* Signals with ReceiverId==0 are also reported to SME / WEXT,
-         * unless they are data/control MA_PACKET_INDs or VIF_AVAILABILITY_INDs
-         */
-        if (!receiver_id) {
-               if(signal_id == CSR_MA_VIF_AVAILABILITY_INDICATION_ID) {
-                      uf_process_ma_vif_availibility_ind(priv, sigdata, siglen);
-               }
-               else if (signal_id != CSR_MA_PACKET_INDICATION_ID) {
-                      send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata);
-#ifdef CSR_NATIVE_LINUX
-                      send_to_client(priv, priv->wext_client,
-                                     receiver_id,
-                                     sigdata, siglen, bulkdata);
-#endif
-               }
-               else
-               {
-
-#if (defined(CSR_SUPPORT_SME) && defined(CSR_WIFI_SECURITY_WAPI_ENABLE))
-                   #define CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET    sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22
-                   netInterface_priv_t *interfacePriv;
-                   u8 interfaceTag;
-                   u16 receptionStatus = CSR_RX_SUCCESS;
-
-                   /* Pull out interface tag from virtual interface identifier */
-                   interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff;
-                   interfacePriv = priv->interfacePriv[interfaceTag];
-
-                   /* check for MIC failure */
-                   receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET);
-
-                   /* Send a WAPI MPDU to SME for re-check MIC if the respective filter has been set*/
-                   if ((!freeBulkData) &&
-                       (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) &&
-                       (receptionStatus == CSR_MICHAEL_MIC_ERROR) &&
-                       ((priv->wapi_multicast_filter == 1)
-#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
-                         || (priv->wapi_unicast_filter == 1)
-#endif
-                       ))
-                   {
-                       CSR_SIGNAL signal;
-                       u8 *destAddr;
-                       CsrResult res;
-                       u16 interfaceTag = 0;
-                       u8 isMcastPkt = TRUE;
-
-                       unifi_trace(priv, UDBG6, "Received a WAPI data packet when the Unicast/Multicast filter is set\n");
-                       res = read_unpack_signal(sigdata, &signal);
-                       if (res) {
-                           unifi_error(priv, "Received unknown or corrupted signal (0x%x).\n",
-                                       CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
-                           return;
-                       }
-
-                       /* Check if the type of MPDU and the respective filter status*/
-                       destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET;
-                       isMcastPkt = (destAddr[0] & 0x01) ? TRUE : FALSE;
-                       unifi_trace(priv, UDBG6,
-                                   "1.MPDU type: (%s), 2.Multicast filter: (%s), 3. Unicast filter: (%s)\n",
-                                   ((isMcastPkt) ? "Multiast":"Unicast"),
-                                   ((priv->wapi_multicast_filter) ? "Enabled":"Disabled"),
-                                   ((priv->wapi_unicast_filter)  ? "Enabled":"Disabled"));
-
-                       if (((isMcastPkt) && (priv->wapi_multicast_filter == 1))
-#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
-                           || ((!isMcastPkt) && (priv->wapi_unicast_filter == 1))
-#endif
-                          )
-                        {
-                            unifi_trace(priv, UDBG4, "Sending the WAPI MPDU for MIC check\n");
-                            CsrWifiRouterCtrlWapiRxMicCheckIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, siglen, sigdata, bulkdata->d[0].data_length, (u8*)bulkdata->d[0].os_data_ptr);
-
-                            for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-                                if (bulkdata->d[i].data_length != 0) {
-                                    unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
-                                }
-                           }
-                           return;
-                       }
-                   } /* CSR_MA_PACKET_INDICATION_ID */
-#endif /*CSR_SUPPORT_SME && CSR_WIFI_SECURITY_WAPI_ENABLE*/
-               }
-        }
-
-        /* calls the registered clients handler callback func.
-         * netdev_mlme_event_handler is one of the registered handler used to route
-         * data packet to network stack or AMP/EAPOL related data to SME
-         *
-         * The freeBulkData check ensures that, it has received a management frame and
-         * the frame needs to be freed here. So not to be passed to netdev handler
-         */
-        if(!freeBulkData){
-            if ((client_id < MAX_UDI_CLIENTS) &&
-                    (&priv->ul_clients[client_id] != priv->logging_client)) {
-               unifi_trace(priv, UDBG6, "Call the registered clients handler callback func\n");
-                send_to_client(priv, &priv->ul_clients[client_id],
-                        receiver_id,
-                        sigdata, siglen, bulkdata);
-            }
-        }
-    }
-
-    /*
-     * Free bulk data buffers here unless it is a CSR_MA_PACKET_INDICATION
-     */
-    switch (signal_id)
-    {
-#ifdef UNIFI_SNIFF_ARPHRD
-        case CSR_MA_SNIFFDATA_INDICATION_ID:
-#endif
-            break;
-
-        case CSR_MA_PACKET_INDICATION_ID:
-            if (!freeBulkData)
-            {
-                break;
-            }
-            /* FALLS THROUGH... */
-        default:
-            for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-                if (bulkdata->d[i].data_length != 0) {
-                    unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
-                }
-            }
-    }
-
-} /* unifi_process_receive_event() */
-
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-static u8 signal_buffer_is_full(unifi_priv_t* priv)
-{
-    return (((priv->rxSignalBuffer.writePointer + 1)% priv->rxSignalBuffer.size) == (priv->rxSignalBuffer.readPointer));
-}
-
-void unifi_rx_queue_flush(void *ospriv)
-{
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-
-    unifi_trace(priv, UDBG4, "rx_wq_handler: RdPtr = %d WritePtr =  %d\n",
-                priv->rxSignalBuffer.readPointer, priv->rxSignalBuffer.writePointer);
-    if(priv != NULL) {
-        u8 readPointer = priv->rxSignalBuffer.readPointer;
-        while (readPointer != priv->rxSignalBuffer.writePointer)
-        {
-             rx_buff_struct_t *buf = &priv->rxSignalBuffer.rx_buff[readPointer];
-             unifi_trace(priv, UDBG6, "rx_wq_handler: RdPtr = %d WritePtr =  %d\n",
-                         readPointer, priv->rxSignalBuffer.writePointer);
-             unifi_process_receive_event(priv, buf->bufptr, buf->sig_len, &buf->data_ptrs);
-             readPointer ++;
-             if(readPointer >= priv->rxSignalBuffer.size) {
-                    readPointer = 0;
-             }
-        }
-        priv->rxSignalBuffer.readPointer = readPointer;
-    }
-}
-
-void rx_wq_handler(struct work_struct *work)
-{
-    unifi_priv_t *priv = container_of(work, unifi_priv_t, rx_work_struct);
-    unifi_rx_queue_flush(priv);
-}
-#endif
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  unifi_receive_event
- *
- *      Dispatcher for received signals.
- *
- *      This function receives the 'to host' signals and forwards
- *      them to the unifi linux clients.
- *
- *  Arguments:
- *      ospriv      Pointer to driver's private data.
- *      sigdata     Pointer to the packed signal buffer.
- *      siglen      Length of the packed signal.
- *      bulkdata    Pointer to the signal's bulk data.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *  The signals are received in the format described in the host interface
- *  specification, i.e wire formatted. Certain clients use the same format
- *  to interpret them and other clients use the host formatted structures.
- *  Each client has to call read_unpack_signal() to transform the wire
- *  formatted signal into the host formatted signal, if necessary.
- *  The code is in the core, since the signals are defined therefore
- *  binded to the host interface specification.
- * ---------------------------------------------------------------------------
- */
-void
-unifi_receive_event(void *ospriv,
-                    u8 *sigdata, u32 siglen,
-                    const bulk_data_param_t *bulkdata)
-{
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    u8 writePointer;
-    int i;
-    rx_buff_struct_t * rx_buff;
-
-    unifi_trace(priv, UDBG5, "unifi_receive_event: "
-            "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n",
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF,
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF, siglen);
-    if(signal_buffer_is_full(priv)) {
-        unifi_error(priv, "TO HOST signal queue FULL dropping the PDU\n");
-        for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
-            if (bulkdata->d[i].data_length != 0) {
-                unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
-            }
-        }
-        return;
-    }
-    writePointer = priv->rxSignalBuffer.writePointer;
-    rx_buff = &priv->rxSignalBuffer.rx_buff[writePointer];
-    memcpy(rx_buff->bufptr, sigdata, siglen);
-    rx_buff->sig_len = siglen;
-    rx_buff->data_ptrs = *bulkdata;
-    writePointer++;
-    if(writePointer >= priv->rxSignalBuffer.size) {
-        writePointer =0;
-    }
-    unifi_trace(priv, UDBG4, "unifi_receive_event:writePtr = %d\n", priv->rxSignalBuffer.writePointer);
-    priv->rxSignalBuffer.writePointer = writePointer;
-
-#ifndef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
-    queue_work(priv->rx_workqueue, &priv->rx_work_struct);
-#endif
-
-#else
-    unifi_process_receive_event(ospriv, sigdata, siglen, bulkdata);
-#endif
-} /* unifi_receive_event() */
-
diff --git a/drivers/staging/csr/unifi_native.h b/drivers/staging/csr/unifi_native.h
deleted file mode 100644 (file)
index a73b38e..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- *****************************************************************************
- *
- * FILE : unifi_native.h
- *
- * PURPOSE : Private header file for unifi driver support to wireless extensions.
- *
- *           UDI = UniFi Debug Interface
- *
- * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- *****************************************************************************
- */
-#ifndef __LINUX_UNIFI_NATIVE_H__
-#define __LINUX_UNIFI_NATIVE_H__ 1
-
-#include <linux/kernel.h>
-#include <linux/if_arp.h>
-
-
-/*
- *      scan.c wext.c autojoin.c
- */
-/* Structure to hold results of a scan */
-typedef struct scan_info {
-
-/*    CSR_MLME_SCAN_INDICATION msi; */
-
-    unsigned char *info_elems;
-    int info_elem_length;
-
-} scan_info_t;
-
-
-#define IE_VECTOR_MAXLEN 1024
-
-#ifdef CSR_SUPPORT_WEXT
-/*
- * Structre to hold the wireless network configuration info.
- */
-struct wext_config {
-
-    /* Requested channel when setting up an adhoc network */
-    int channel;
-
-    /* wireless extns mode: IW_MODE_AUTO, ADHOC, INFRA, MASTER ... MONITOR */
-    int mode;
-
-    /* The capabilities of the currently joined network */
-    int capability;
-
-    /* The interval between beacons if we create an IBSS */
-    int beacon_period;
-
-    /*
-    * Power-save parameters
-    */
-    /* The listen interval to ask for in Associate req. */
-    int assoc_listen_interval;
-    /* Power-mode to put UniFi into */
-
-    unsigned char desired_ssid[UNIFI_MAX_SSID_LEN];     /* the last ESSID set by SIOCSIWESSID */
-    int power_mode;
-    /* Whether to wake for broadcast packets (using DTIM interval) */
-    int wakeup_for_dtims;
-
-    /* Currently selected WEP Key ID (0..3) */
-    int wep_key_id;
-
-    wep_key_t wep_keys[NUM_WEPKEYS];
-
-/*    CSR_AUTHENTICATION_TYPE auth_type; */
-    int privacy;
-
-    u32 join_failure_timeout;
-    u32 auth_failure_timeout;
-    u32 assoc_failure_timeout;
-
-    unsigned char generic_ie[IE_VECTOR_MAXLEN];
-    int generic_ie_len;
-
-    struct iw_statistics wireless_stats;
-
-
-    /* the ESSID we are currently associated to */
-    unsigned char current_ssid[UNIFI_MAX_SSID_LEN];
-    /* the BSSID we are currently associated to */
-    unsigned char current_bssid[6];
-
-    /*
-    * IW_AUTH_WPA_VERSION_DISABLED 0x00000001
-    * IW_AUTH_WPA_VERSION_WPA      0x00000002
-    * IW_AUTH_WPA_VERSION_WPA2     0x00000004
-    */
-    unsigned char wpa_version;
-
-    /*
-     * cipher selection:
-    * IW_AUTH_CIPHER_NONE      0x00000001
-    * IW_AUTH_CIPHER_WEP40     0x00000002
-    * IW_AUTH_CIPHER_TKIP      0x00000004
-    * IW_AUTH_CIPHER_CCMP      0x00000008
-    * IW_AUTH_CIPHER_WEP104    0x00000010
-    */
-    unsigned char pairwise_cipher_used;
-    unsigned char group_cipher_used;
-
-    unsigned int frag_thresh;
-    unsigned int rts_thresh;
-
-    /* U-APSD value, send with Association Request to WMM Enabled APs */
-    unsigned char wmm_bss_uapsd_mask;
-    /* The WMM capabilities of the selected BSS */
-    unsigned int bss_wmm_capabilities;
-
-    /* Flag to prevent a join when the ssid is set */
-    int disable_join_on_ssid_set;
-
-    /* Scan info */
-#define UNIFI_MAX_SCANS 32
-    scan_info_t scan_list[UNIFI_MAX_SCANS];
-    int num_scan_info;
-
-    /* Flag on whether non-802.1x packets are allowed out */
-/*    CsrWifiRouterPortAction block_controlled_port;*/
-
-    /* Flag on whether we have completed an authenticate/associate process */
-    unsigned int flag_associated        : 1;
-}; /* struct wext_config */
-
-#endif /* CSR_SUPPORT_WEXT */
-
-
-/*
- *      wext.c
- */
-/*int mlme_set_protection(unifi_priv_t *priv, unsigned char *addr,
-                        CSR_PROTECT_TYPE prot, CSR_KEY_TYPE key_type);
-*/
-
-/*
- * scan.c
- */
-/*
-void unifi_scan_indication_handler(unifi_priv_t *priv,
-                                   const CSR_MLME_SCAN_INDICATION *msg,
-                                   const unsigned char *extra,
-                                   unsigned int len);
-*/
-void unifi_clear_scan_table(unifi_priv_t *priv);
-scan_info_t *unifi_get_scan_report(unifi_priv_t *priv, int index);
-
-
-/*
- * Utility functions
- */
-const unsigned char *unifi_find_info_element(int id,
-                                             const unsigned char *info,
-                                             int len);
-int unifi_add_info_element(unsigned char *info,
-                           int ie_id,
-                           const unsigned char *ie_data,
-                           int ie_len);
-
-/*
- *      autojoin.c
- */
-/* Higher level fns */
-int unifi_autojoin(unifi_priv_t *priv, const char *ssid);
-/*
-int unifi_do_scan(unifi_priv_t *priv, int scantype, CSR_BSS_TYPE bsstype,
-                  const char *ssid, int ssid_len);
-*/
-int unifi_set_powermode(unifi_priv_t *priv);
-int unifi_join_ap(unifi_priv_t *priv, scan_info_t *si);
-int unifi_join_bss(unifi_priv_t *priv, unsigned char *macaddr);
-int unifi_leave(unifi_priv_t *priv);
-unsigned int unifi_get_wmm_bss_capabilities(unifi_priv_t *priv,
-                                            unsigned char *ie_vector,
-                                            int ie_len, int *ap_capabilities);
-
-/*
- * Status and management.
- */
-int uf_init_wext_interface(unifi_priv_t *priv);
-void uf_deinit_wext_interface(unifi_priv_t *priv);
-
-/*
- * Function to reset UniFi's 802.11 state by sending MLME-RESET.req
- */
-int unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr, unsigned char set_default_mib);
-
-
-/*
- *      mlme.c
- */
-/* Abort an MLME operation - useful in error recovery */
-int uf_abort_mlme(unifi_priv_t *priv);
-
-int unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
-                                CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
-                                int timeout);
-void unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
-                                             CSR_SIGNAL *signal, int signal_len,
-                                             const bulk_data_param_t *bulkdata);
-
-/*
- * Utility functions
- */
-const char *lookup_reason_code(int reason);
-const char *lookup_result_code(int result);
-
-
-/*
- *      sme_native.c
- */
-int uf_sme_init(unifi_priv_t *priv);
-void uf_sme_deinit(unifi_priv_t *priv);
-int sme_sys_suspend(unifi_priv_t *priv);
-int sme_sys_resume(unifi_priv_t *priv);
-int sme_mgt_wifi_on(unifi_priv_t *priv);
-
-/* Callback for event logging to SME clients (unifi_manager) */
-void sme_native_log_event(ul_client_t *client,
-                          const u8 *sig_packed, int sig_len,
-                          const bulk_data_param_t *bulkdata,
-                          int dir);
-
-void sme_native_mlme_event_handler(ul_client_t *pcli,
-                                   const u8 *sig_packed, int sig_len,
-                                   const bulk_data_param_t *bulkdata,
-                                   int dir);
-
-/* Task to query statistics from the MIB */
-#define UF_SME_STATS_WQ_TIMEOUT     2000    /* in msecs */
-void uf_sme_stats_wq(struct work_struct *work);
-
-void uf_native_process_udi_signal(ul_client_t *pcli,
-                                  const u8 *packed_signal,
-                                  int packed_signal_len,
-                                  const bulk_data_param_t *bulkdata, int dir);
-#ifdef UNIFI_SNIFF_ARPHRD
-/*
- * monitor.c
- */
-int uf_start_sniff(unifi_priv_t *priv);
-/*
-void ma_sniffdata_ind(void *ospriv,
-                      const CSR_MA_SNIFFDATA_INDICATION *ind,
-                      const bulk_data_param_t *bulkdata);
-*/
-#endif /* ARPHRD_IEEE80211_PRISM */
-
-#endif /* __LINUX_UNIFI_NATIVE_H__ */
diff --git a/drivers/staging/csr/unifi_os.h b/drivers/staging/csr/unifi_os.h
deleted file mode 100644 (file)
index 56a2698..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *
- * FILE: os_linux/unifi_os.h
- *
- * PURPOSE:
- *      This header file provides the OS-dependent facilities for a linux
- *      environment.
- *
- * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __UNIFI_OS_LINUX_H__
-#define __UNIFI_OS_LINUX_H__ 1
-
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <linux/list.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-
-/*
- * Needed for core/signals.c
- */
-#include <stddef.h>
-
-
-/* Define INLINE directive*/
-#define INLINE      inline
-
-/* Malloc and free */
-CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
-void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
-#define CSR_WIFI_ALIGN_BYTES    4
-CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot);
-
-/*
- * Byte Order
- * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value!
- */
-#ifdef __KERNEL__
-#define unifi2host_16(n)       (__le16_to_cpu((n)))
-#define unifi2host_32(n)       (__le32_to_cpu((n)))
-#define host2unifi_16(n)       (__cpu_to_le16((n)))
-#define host2unifi_32(n)       (__cpu_to_le32((n)))
-#endif
-
-/* Module parameters */
-extern int unifi_debug;
-
-/* debugging */
-#ifdef UNIFI_DEBUG
-/*
- * unifi_debug is a verbosity level for debug messages
- * UDBG0 msgs are always printed if UNIFI_DEBUG is defined
- * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0
- * etc.
- */
-
-#define ASSERT(cond)                                            \
-    do {                                                            \
-        if (!(cond)) {                                              \
-            printk("Assertion failed in %s at %s:%d: %s\n",         \
-                    __FUNCTION__, __FILE__, __LINE__, #cond);        \
-        }                                                           \
-    } while (0)
-
-
-void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
-void dump(void *mem, u16 len);
-void dump16(void *mem, u16 len);
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-void dump_str(void *mem, u16 len);
-#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
-
-void unifi_error(void* ospriv, const char *fmt, ...);
-void unifi_warning(void* ospriv, const char *fmt, ...);
-void unifi_notice(void* ospriv, const char *fmt, ...);
-void unifi_info(void* ospriv, const char *fmt, ...);
-
-void unifi_trace(void* ospriv, int level, const char *fmt, ...);
-
-#else
-
-/* Stubs */
-
-#define ASSERT(cond)
-
-static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
-static inline void dump(void *mem, u16 len) {}
-static inline void dump16(void *mem, u16 len) {}
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-static inline void dump_str(void *mem, u16 len) {}
-#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
-
-void unifi_error_nop(void* ospriv, const char *fmt, ...);
-void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
-#define unifi_error if(1);else unifi_error_nop
-#define unifi_warning if(1);else unifi_error_nop
-#define unifi_notice if(1);else unifi_error_nop
-#define unifi_info if(1);else unifi_error_nop
-#define unifi_trace if(1);else unifi_trace_nop
-
-#endif /* UNIFI_DEBUG */
-
-
-/* Different levels of diagnostic detail... */
-#define UDBG0       0   /* always prints in debug build */
-#define UDBG1       1
-#define UDBG2       2
-#define UDBG3       3
-#define UDBG4       4
-#define UDBG5       5
-#define UDBG6       6
-#define UDBG7       7
-
-
-#endif /* __UNIFI_OS_LINUX_H__ */
diff --git a/drivers/staging/csr/unifi_pdu_processing.c b/drivers/staging/csr/unifi_pdu_processing.c
deleted file mode 100644 (file)
index 04fe9e2..0000000
+++ /dev/null
@@ -1,3729 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     unifi_pdu_processing.c
- *
- * PURPOSE:
- *      This file provides the PDU handling functionality before it gets sent to unfi and after
- *      receiving a PDU from unifi
- *
- * Copyright (C) 2010 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-
-#include <linux/types.h>
-#include <linux/etherdevice.h>
-#include <linux/vmalloc.h>
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include "csr_time.h"
-#include "unifi_priv.h"
-#include <net/pkt_sched.h>
-
-#ifdef CSR_SUPPORT_SME
-static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
-                                                        tx_buffered_packets_t* buffered_pkt)
-{
-    struct sk_buff *skb ;
-    u32 align_offset;
-
-    if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){
-        return;
-    }
-
-    skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
-    align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
-    if(align_offset){
-        skb_pull(skb, align_offset);
-    }
-
-    buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
-    buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length;
-    buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
-    buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
-}
-#endif
-
-void
-unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
-                          CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
-                          u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
-                          CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
-                          CSR_SIGNAL *signal)
-{
-
-    CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
-    netInterface_priv_t *interfacePriv;
-    u8 ba_session_idx = 0;
-    ba_session_tx_struct *ba_session = NULL;
-    u8 *ba_addr = NULL;
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-       unifi_trace(priv, UDBG5,
-               "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n",
-               peerMacAddress);
-    signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
-    signal->SignalPrimitiveHeader.ReceiverProcessId = 0;
-    signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId;
-
-    /* Fill the MA-PACKET.req */
-    req->Priority = priority;
-    unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority);
-
-    /* A value of 0 is used for auto selection of rates. But for P2P GO case
-     * for action frames the rate is governed by SME. Hence instead of 0,
-     * the rate is filled in with the value passed here
-     */
-    req->TransmitRate = TransmitRate;
-
-    /* packets from netdev then no confirm required but packets from
-     * Nme/Sme eapol data frames requires the confirmation
-     */
-    req->TransmissionControl = transmissionControl;
-    req->VirtualInterfaceIdentifier =
-           uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag);
-    memcpy(req->Ra.x, peerMacAddress, ETH_ALEN);
-
-    if (hostTag == 0xffffffff) {
-        req->HostTag = interfacePriv->tag++;
-        req->HostTag |= 0x40000000;
-        unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag);
-        interfacePriv->tag &= 0x0fffffff;
-    } else {
-        req->HostTag = hostTag;
-        unifi_trace(priv, UDBG3, "host tag got from SME  = 0x%x\n", req->HostTag);
-    }
-    /* check if BA session exists for the peer MAC address on same tID */
-    if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-       interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
-        ba_addr = peerMacAddress;
-    }else{
-        ba_addr = interfacePriv->bssid.a;
-    }
-    for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
-        ba_session = interfacePriv->ba_session_tx[ba_session_idx];
-        if (ba_session){
-           if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){
-                req->TransmissionControl |= CSR_ALLOW_BA;
-                break;
-            }
-        }
-    }
-
-    unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n");
-}
-
-#ifdef CSR_SUPPORT_SME
-
-#define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001
-#define TRANSMISSION_CONTROL_EOSP_MASK 0x0002
-
-static
-int frame_and_send_queued_pdu(unifi_priv_t* priv, tx_buffered_packets_t* buffered_pkt,
-            CsrWifiRouterCtrlStaInfo_t *staRecord, u8 moreData , u8 eosp)
-{
-
-    CSR_SIGNAL signal;
-    bulk_data_param_t bulkdata;
-    int result;
-    u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE;
-    u8 *qc;
-    u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr);
-    unsigned long lock_flags;
-    unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n", moreData, eosp);
-    unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag,
-               buffered_pkt->interfaceTag, buffered_pkt->transmissionControl,
-               buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal);
-    bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr;
-    bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length;
-    bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr;
-    bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length;
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].data_length = 0;
-    bulkdata.d[1].os_net_buf_ptr =0;
-    bulkdata.d[1].net_buf_length =0;
-
-    if(moreData) {
-        *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK);
-    } else {
-        *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK);
-    }
-
-    if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE))
-    {
-        unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n", staRecord->wmmOrQosEnabled);
-
-        toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
-        fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
-
-        switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
-        {
-            case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
-            case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
-                /* If both are set then the Address4 exists (only for AP) */
-                if (fromDs && toDs) {
-                    /* 6 is the size of Address4 field */
-                    macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
-                } else {
-                    macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
-                }
-
-                /* If order bit set then HT control field is the part of MAC header */
-                if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
-                    macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
-                    qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6));
-                } else {
-                    qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2));
-                }
-                *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4));
-                break;
-            default:
-                if (fromDs && toDs)
-                    macHeaderLengthInBytes += 6;
-        }
-
-    }
-    result = ul_send_signal_unpacked(priv, &signal, &bulkdata);
-    if(result){
-        _update_buffered_pkt_params_after_alignment(priv, &bulkdata, buffered_pkt);
-    }
-
- /* Decrement the packet counts queued in driver */
-    if (result != -ENOSPC) {
-        /* protect entire counter updation by disabling preemption */
-        if (!priv->noOfPktQueuedInDriver) {
-            unifi_error(priv, "packets queued in driver 0 still decrementing\n");
-        } else {
-            spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-            priv->noOfPktQueuedInDriver--;
-            spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-        }
-        /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
-        if (staRecord) {
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            if (!staRecord->noOfPktQueued) {
-                unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n");
-            } else {
-                staRecord->noOfPktQueued--;
-            }
-            /* if the STA alive probe frame has failed then reset the saved host tag */
-            if (result){
-                if (staRecord->nullDataHostTag == buffered_pkt->hostTag){
-                    staRecord->nullDataHostTag = INVALID_HOST_TAG;
-                }
-            }
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }
-
-    }
-    return result;
-}
-#ifdef CSR_SUPPORT_SME
-static
-void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList)
-{
-    /* dequeue the tx data packets from the appropriate queue */
-    tx_buffered_packets_t *tx_q_item = NULL;
-    struct list_head *listHead;
-    struct list_head *placeHolder;
-    unsigned long lock_flags;
-
-
-    unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n");
-    /* check for list empty */
-    if (list_empty(txList)) {
-        unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n");
-        return;
-    }
-
-    /* return the last node , and modify it. */
-
-    spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-    list_for_each_prev_safe(listHead, placeHolder, txList) {
-        tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-        tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
-        tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
-        unifi_trace(priv, UDBG1,
-                "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n", tx_q_item->transmissionControl, tx_q_item->hostTag);
-        unifi_trace(priv, UDBG3, "in set_eosp_transmit_ctrl no.of buffered frames %d\n", priv->noOfPktQueuedInDriver);
-        break;
-    }
-    spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-    unifi_trace(priv, UDBG1, "List Empty %d\n", list_empty(txList));
-    unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n");
-    return;
-}
-
-static
-void send_vif_availibility_rsp(unifi_priv_t *priv, CSR_VIF_IDENTIFIER vif, CSR_RESULT_CODE resultCode)
-{
-    CSR_SIGNAL signal;
-    CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp;
-    bulk_data_param_t *bulkdata = NULL;
-    int r;
-
-    unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode);
-
-    memset(&signal, 0, sizeof(CSR_SIGNAL));
-    rsp = &signal.u.MaVifAvailabilityResponse;
-    rsp->VirtualInterfaceIdentifier = vif;
-    rsp->ResultCode = resultCode;
-    signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID;
-    signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
-    signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
-
-    /* Send the signal to UniFi */
-    r = ul_send_signal_unpacked(priv, &signal, bulkdata);
-    if(r) {
-        unifi_error(priv, "Availibility response sending failed %x status %d\n", vif, r);
-    }
-    else {
-        unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r);
-    }
-}
-#endif
-
-static
-void verify_and_accomodate_tx_packet(unifi_priv_t *priv)
-{
-    tx_buffered_packets_t *tx_q_item;
-    unsigned long lock_flags;
-    struct list_head *listHead, *list;
-    struct list_head *placeHolder;
-    u8 i, j, eospFramedeleted=0;
-    u8 thresholdExcedeDueToBroadcast = TRUE;
-    /* it will be made it interface Specific in the future when multi interfaces are supported ,
-    right now interface 0 is considered */
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[0];
-    CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
-
-    unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n");
-
-    for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        staInfo = interfacePriv->staInfo[i];
-            if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) {
-            /* remove the first(oldest) packet from the all the access catogory, since data
-             * packets for station record crossed the threshold limit (64 for AP supporting
-             * 8 peers)
-             */
-            unifi_trace(priv, UDBG3, "number of station pkts queued=  %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid);
-            for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
-                list = &staInfo->dataPdu[j];
-                spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                list_for_each_safe(listHead, placeHolder, list) {
-                    tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-                    list_del(listHead);
-                    thresholdExcedeDueToBroadcast = FALSE;
-                    unifi_net_data_free(priv, &tx_q_item->bulkdata);
-                    kfree(tx_q_item);
-                    tx_q_item = NULL;
-                    if (!priv->noOfPktQueuedInDriver) {
-                        unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
-                    } else {
-                        /* protection provided by spinlock */
-                        priv->noOfPktQueuedInDriver--;
-
-                    }
-                    /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
-                    if (!staInfo->noOfPktQueued) {
-                        unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__);
-                    } else {
-                        spin_lock(&priv->staRecord_lock);
-                        staInfo->noOfPktQueued--;
-                        spin_unlock(&priv->staRecord_lock);
-                    }
-                    break;
-                }
-                spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-            }
-        }
-    }
-    if (thresholdExcedeDueToBroadcast &&  interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) {
-        /* Remove the packets from genericMulticastOrBroadCastFrames queue
-         * (the max packets in driver is reached due to broadcast/multicast frames)
-         */
-        spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-        list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
-            tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-            if(eospFramedeleted){
-                tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
-                tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
-                unifi_trace(priv, UDBG1, "updating eosp for next packet hostTag:= 0x%x ", tx_q_item->hostTag);
-                eospFramedeleted =0;
-                break;
-            }
-
-            if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){
-               eospFramedeleted = 1;
-            }
-            unifi_trace(priv, UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n", tx_q_item->transmissionControl, tx_q_item->hostTag);
-            list_del(listHead);
-            unifi_net_data_free(priv, &tx_q_item->bulkdata);
-            kfree(tx_q_item);
-            priv->noOfPktQueuedInDriver--;
-            spin_lock(&priv->staRecord_lock);
-            interfacePriv->noOfbroadcastPktQueued--;
-            spin_unlock(&priv->staRecord_lock);
-            if(!eospFramedeleted){
-                break;
-            }
-        }
-        spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-    }
-    unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n");
-}
-
-static
-CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
-                            struct list_head *list, CSR_SIGNAL *signal,
-                            u8 requeueOnSamePos)
-{
-
-    /* queue the tx data packets on to appropriate queue */
-    CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
-    tx_buffered_packets_t *tx_q_item;
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n");
-    if(!list) {
-       unifi_error(priv, "List is not specified\n");
-       return CSR_RESULT_FAILURE;
-    }
-
-    /* Removes aged packets & adds the incoming packet */
-    if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) {
-        unifi_trace(priv, UDBG3, "number of pkts queued=  %d \n", priv->noOfPktQueuedInDriver);
-        verify_and_accomodate_tx_packet(priv);
-    }
-
-
-
-    tx_q_item = kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
-    if (tx_q_item == NULL) {
-        unifi_error(priv,
-                "Failed to allocate %d bytes for tx packet record\n",
-                sizeof(tx_buffered_packets_t));
-        return CSR_RESULT_FAILURE;
-    }
-
-    /* disable the preemption */
-    spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-    INIT_LIST_HEAD(&tx_q_item->q);
-    /* fill the tx_q structure members */
-    tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
-    tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length;
-    tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
-    tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
-    tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
-    tx_q_item->hostTag = req->HostTag;
-    tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId;
-    tx_q_item->transmissionControl = req->TransmissionControl;
-    tx_q_item->priority = req->Priority;
-    tx_q_item->rate = req->TransmitRate;
-    memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN);
-
-
-
-    if (requeueOnSamePos) {
-        list_add(&tx_q_item->q, list);
-    } else {
-        list_add_tail(&tx_q_item->q, list);
-    }
-
-    /* Count of packet queued in driver */
-    priv->noOfPktQueuedInDriver++;
-    spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-    unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n");
-    return CSR_RESULT_SUCCESS;
-}
-
-#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
-CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag,
-                                         u16 txStatus, bulk_data_desc_t *bulkDataDesc)
-{
-    CsrResult status = CSR_RESULT_SUCCESS;
-    unifi_priv_t *priv = (unifi_priv_t*)ospriv;
-    netInterface_priv_t *interfacePriv;
-    struct list_head *list = NULL;
-    CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
-    bulk_data_param_t bulkData;
-    CSR_SIGNAL signal;
-    CSR_PRIORITY priority = 0;
-    u16 interfaceTag = 0;
-    unifi_TrafficQueue priority_q;
-    u16 frameControl = 0, frameType = 0;
-    unsigned long lock_flags;
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    /* If the current mode is not AP or P2PGO then just return failure
-     * to clear the hip slot
-     */
-    if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
-        (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) {
-        return CSR_RESULT_FAILURE;
-    }
-
-    unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag);
-
-    staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,
-                                                                    (((u8 *) bulkDataDesc->os_data_ptr) + 4),
-                                                                    interfaceTag);
-    if (NULL == staRecord) {
-        unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n");
-        return CSR_RESULT_FAILURE;
-    }
-
-    /* Update TIM if MA-PACKET.cfm fails with status as Tx-retry-limit or No-BSS and then just return failure
-     * to clear the hip slot associated with the Packet
-     */
-    if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) {
-        if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING)
-        {
-            unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n");
-            if (!staRecord->timRequestPendingFlag) {
-                update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle);
-            }
-            else {
-                /* Cache the TimSet value so that it will processed immidiatly after
-                 * completing the current setTim Request
-                 */
-                staRecord->updateTimReqQueued = 1;
-                unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n",
-                                         staRecord->updateTimReqQueued, staRecord->aid);
-            }
-        }
-        return CSR_RESULT_FAILURE;
-    }
-    else if ((CSR_TX_LIFETIME == txStatus) ||  (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) ||
-             (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) ||
-             (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus)    ||
-             (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) {
-        /* Extract the Frame control and the frame type */
-        frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr);
-        frameType =  ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
-
-        /* Mgmt frames will not be re-queued for Tx
-         * so just return failure to clear the hip slot
-         */
-        if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) {
-            return CSR_RESULT_FAILURE;
-        }
-        else if (IEEE802_11_FRAMETYPE_DATA == frameType) {
-            /* QOS NULL and DATA NULL frames will not be re-queued for Tx
-             * so just return failure to clear the hip slot
-             */
-            if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) ||
-                (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) {
-                return CSR_RESULT_FAILURE;
-            }
-        }
-
-        /* Extract the Packet priority */
-        if (TRUE == staRecord->wmmOrQosEnabled) {
-            u16 qosControl = 0;
-            u8  dataFrameType = 0;
-
-            dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4);
-
-            if (dataFrameType == QOS_DATA) {
-                /* QoS control field is offset from frame control by 2 (frame control)
-                 * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
-                 */
-                if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) {
-                    qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30);
-                }
-                else {
-                    qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24);
-                }
-            }
-
-            priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
-
-            if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) {
-                unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority);
-                return CSR_RESULT_FAILURE;
-            }
-        }
-        else {
-            priority = CSR_CONTENTION;
-        }
-
-        /* Frame Bulk data to requeue it back to HAL Queues */
-        bulkData.d[0].os_data_ptr    = bulkDataDesc->os_data_ptr;
-        bulkData.d[0].data_length    = bulkDataDesc->data_length;
-        bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr;
-        bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length;
-
-        bulkData.d[1].os_data_ptr    = NULL;
-        bulkData.d[1].os_net_buf_ptr = NULL;
-        bulkData.d[1].data_length    = bulkData.d[1].net_buf_length = 0;
-
-        /* Initialize signal to zero */
-        memset(&signal, 0, sizeof(CSR_SIGNAL));
-
-        /* Frame MA Packet Req */
-        unifi_frame_ma_packet_req(priv, priority, 0, host_tag,
-                              interfaceTag, CSR_NO_CONFIRM_REQUIRED,
-                              priv->netdev_client->sender_id,
-                              staRecord->peerMacAddress.a, &signal);
-
-        /* Find the Q-Priority */
-        priority_q = unifi_frame_priority_to_queue(priority);
-        list = &staRecord->dataPdu[priority_q];
-
-        /* Place the Packet on to HAL Queue */
-        status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE);
-
-        /* Update the Per-station queued packet counter */
-        if (!status) {
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            staRecord->noOfPktQueued++;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }
-    }
-    else {
-        /* Packet will not be re-queued for any of the other MA Packet Tx failure
-         * reasons so just return failure to clear the hip slot
-         */
-        return CSR_RESULT_FAILURE;
-    }
-
-    return status;
-}
-#endif
-
-static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable)
-{
-    u8 i;
-    *allDeliveryEnabled = TRUE;
-    for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) {
-        if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
-            /* One is is not Delivery Enabled */
-            *allDeliveryEnabled = FALSE;
-            break;
-        }
-    }
-    if (*allDeliveryEnabled) {
-        *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1])
-                          ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3])
-                          ||!list_empty(&staRecord->mgtFrames));
-    }
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_handle_tim_cfm
- *
- *
- *      This function updates tim status in host depending confirm status from firmware
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      cfm             CSR_MLME_SET_TIM_CONFIRM
- *      receiverProcessId SenderProcessID to fetch handle & timSet status
- *
- * ---------------------------------------------------------------------------
- */
-void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId)
-{
-    u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId);
-    u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId);
-    u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
-    /* This variable holds what TIM value we wanted to set in firmware */
-    u16 timSetValue = 0;
-    /* Irrespective of interface the count maintained */
-    static u8 retryCount = 0;
-    unsigned long lock_flags;
-    unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus);
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag);
-        return;
-    }
-
-    if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) {
-        unifi_warning(priv, "bad station Handle = %x\n", handle);
-        return;
-    }
-
-    if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
-        spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-        if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-            unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL  handle = %x\n", handle);
-            return;
-        }
-       spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-    }
-    switch(timSetStatus)
-    {
-        case CSR_WIFI_TIM_SETTING:
-            timSetValue = CSR_WIFI_TIM_SET;
-            break;
-        case CSR_WIFI_TIM_RESETTING:
-            timSetValue = CSR_WIFI_TIM_RESET;
-            break;
-        default:
-            unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus);
-            return;
-    }
-
-    /* check TIM confirm for success/failures */
-    switch(cfm->ResultCode)
-    {
-        case CSR_RC_SUCCESS:
-            if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
-                /* Unicast frame & station record available */
-                if (timSetStatus == staRecord->timSet) {
-                    staRecord->timSet = timSetValue;
-                    /* fh_cmd_q can also be full at some point of time!,
-                     * resetting count as queue is cleaned by firmware at this point
-                     */
-                    retryCount = 0;
-                    unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET");
-                } else {
-                    unifi_trace(priv, UDBG3, "receiver processID = %x, success: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x, handle = %x\n",
-                                 receiverProcessId, timSetStatus, staRecord->timSet, handle);
-                }
-
-                /* Reset TIM pending flag to send next TIM request */
-                staRecord->timRequestPendingFlag = FALSE;
-
-                /* Make sure that one more UpdateTim request is queued, if Queued its value
-                 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
-                 */
-                if (0xFF != staRecord->updateTimReqQueued)
-                {
-                    /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
-                    if (staRecord->timSet != staRecord->updateTimReqQueued)
-                    {
-                       unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n");
-
-                       update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle);
-
-                       staRecord->updateTimReqQueued = 0xFF;
-                    }
-                }
-            } else {
-
-                interfacePriv->bcTimSet = timSetValue;
-                /* fh_cmd_q can also be full at some point of time!,
-                 * resetting count as queue is cleaned by firmware at this point
-                 */
-                retryCount = 0;
-                unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET");
-
-                /* Reset DTIM pending flag to send next DTIM request */
-                interfacePriv->bcTimSetReqPendingFlag = FALSE;
-
-                /* Make sure that one more UpdateDTim request is queued, if Queued its value
-                 * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
-                 */
-                if (0xFF != interfacePriv->bcTimSetReqQueued)
-                {
-                    /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
-                    if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued)
-                    {
-                        unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n");
-
-                        update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF);
-
-                        interfacePriv->bcTimSetReqQueued = 0xFF;
-                    }
-                }
-
-            }
-            break;
-        case CSR_RC_INVALID_PARAMETERS:
-        case CSR_RC_INSUFFICIENT_RESOURCE:
-            /* check for max retry limit & send again
-             * MAX_RETRY_LIMIT is not maintained for each set of transactions..Its generic
-             * If failure crosses this Limit, we have to take a call to FIX
-             */
-            if (retryCount > UNIFI_MAX_RETRY_LIMIT) {
-                u8 moreData = FALSE;
-                retryCount = 0;
-                /* Because of continuos traffic in fh_cmd_q the tim set request is failing (exceeding retry limit)
-                 * but if we didn't synchronize our timSet varible state with firmware then it can cause below issues
-                 * cond 1. We want to SET tim in firmware if its fails & max retry limit reached
-                 *   -> If host set's the timSet to 1, we wont try to send(as max retry reached) update tim but
-                 *   firmware is not updated with queue(TIM) status so it wont set TIM in beacon finally host start piling
-                 *    up data & wont try to set tim in firmware (This can cause worser performance)
-                 * cond 2. We want to reset tim in firmware it fails & reaches max retry limit
-                 *   -> If host sets the timSet to Zero, it wont try to set a TIM request unless we wont have any packets
-                 *   to be queued, so beacon unnecessarily advertizes the TIM
-                 */
-
-                if(staRecord) {
-                    if(!staRecord->wmmOrQosEnabled) {
-                        moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
-                                !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
-                                !list_empty(&staRecord->mgtFrames));
-                    } else {
-                        /* Peer is QSTA */
-                        u8 allDeliveryEnabled = 0, dataAvailable = 0;
-                        /* Check if all AC's are Delivery Enabled */
-                        is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
-                        /*check for more data in non-delivery enabled queues*/
-                        moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
-
-                    }
-                    /* To avoid cond 1 & 2, check internal Queues status, if we have more Data then set RESET the timSet(0),
-                     *  so we are trying to be in sync with firmware & next packets before queuing atleast try to
-                     *  set TIM in firmware otherwise it SET timSet(1)
-                     */
-                    if (moreData) {
-                        staRecord->timSet = CSR_WIFI_TIM_RESET;
-                    } else {
-                        staRecord->timSet = CSR_WIFI_TIM_SET;
-                    }
-                } else {
-                    /* Its a broadcast frames */
-                    moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
-                               !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
-                    if (moreData) {
-                        update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF);
-                    } else {
-                        update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
-                    }
-                }
-
-                unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n");
-                return;
-            }
-            retryCount++;
-
-            if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
-                if (timSetStatus == staRecord->timSet) {
-                    unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid);
-                    update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle);
-                } else {
-                    unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n",
-                                  timSetStatus, staRecord->timSet);
-                }
-            } else {
-                unifi_warning(priv, "tim request failed, retry for broadcast frames\n");
-                update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF);
-            }
-            break;
-        default:
-            unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode);
-    }
-
-    unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__);
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  update_tim
- *
- *
- *      This function updates tim status in firmware for AID[1 to UNIFI_MAX_CONNECTIONS] or
- *       AID[0] for broadcast/multicast packets.
- *
- *      NOTE: The LSB (least significant BYTE) of senderId while sending this MLME premitive
- *       has been modified(utilized) as below
- *
- *       SenderID in signal's SignalPrimitiveHeader is 2 byte the lowe byte bitmap is below
- *
- *       station handle(6 bits)      timSet Status (2 bits)
- *       ---------------------       ----------------------
- *       0  0  0  0  0  0        |       0  0
- *
- * timSet Status can be one of below:
- *
- * CSR_WIFI_TIM_RESET
- * CSR_WIFI_TIM_RESETTING
- * CSR_WIFI_TIM_SET
- * CSR_WIFI_TIM_SETTING
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      aid             can be 1 t0 UNIFI_MAX_CONNECTIONS & 0 means multicast/broadcast
- *      setTim          value SET(1) / RESET(0)
- *      interfaceTag    the interfaceID on which activity going on
- *      handle          from  (0 <= handle < UNIFI_MAX_CONNECTIONS)
- *
- * ---------------------------------------------------------------------------
- */
-void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle)
-{
-    CSR_SIGNAL signal;
-    s32 r;
-    CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest;
-    bulk_data_param_t *bulkdata = NULL;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    u8 senderIdLsb = 0;
-    CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
-    u32 oldTimSetStatus = 0, timSetStatus = 0;
-
-    unifi_trace(priv, UDBG5, "entering the update_tim routine\n");
-
-
-    if (handle == 0xFFFFFFFF) {
-        handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE;
-        if (setTim == interfacePriv->bcTimSet)
-        {
-            unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet);
-            return;
-        }
-    } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) {
-        unifi_warning(priv, "bad station Handle = %x\n", handle);
-        return;
-    }
-
-    if (setTim) {
-        timSetStatus =  CSR_WIFI_TIM_SETTING;
-    } else {
-        timSetStatus =  CSR_WIFI_TIM_RESETTING;
-    }
-
-    if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
-        if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
-            unifi_warning(priv, "station record is NULL in  update_tim: handle = %x :debug\n", handle);
-            return;
-        }
-        /* In case of signal sending failed, revert back to old state */
-        oldTimSetStatus = staRecord->timSet;
-        staRecord->timSet = timSetStatus;
-    }
-
-    /* pack senderID LSB */
-    senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle,  timSetStatus);
-
-    /* initialize signal to zero */
-    memset(&signal, 0, sizeof(CSR_SIGNAL));
-
-    /* Frame the MLME-SET-TIM request */
-    signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID;
-    signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
-    CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb),
-                   (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
-
-    /* set The virtual interfaceIdentifier, aid, tim value */
-    req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag);
-    req->AssociationId = aid;
-    req->TimValue = setTim;
-
-
-    unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n",
-                aid, senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId);
-
-    /* Send the signal to UniFi */
-    r = ul_send_signal_unpacked(priv, &signal, bulkdata);
-    if (r) {
-        /* No need to free bulk data, as TIM request doesn't carries any data */
-        unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n");
-        if (staRecord) {
-            staRecord->timSet = oldTimSetStatus ;
-        }
-        else
-        {
-            /* MLME_SET_TIM.req sending failed here for AID0, so revert back our bcTimSet status */
-            interfacePriv->bcTimSet = !setTim;
-        }
-    }
-    else {
-        /* Update tim request pending flag and ensure no more TIM set requests are send
-           for the same station until TIM confirm is received */
-        if (staRecord) {
-            staRecord->timRequestPendingFlag = TRUE;
-        }
-        else
-        {
-            /* Update tim request (for AID 0) pending flag and ensure no more DTIM set requests are send
-             * for the same station until TIM confirm is received
-             */
-            interfacePriv->bcTimSetReqPendingFlag = TRUE;
-        }
-    }
-    unifi_trace(priv, UDBG5, "leaving the update_tim routine\n");
-}
-
-static
-void process_peer_active_transition(unifi_priv_t * priv,
-                                    CsrWifiRouterCtrlStaInfo_t *staRecord,
-                                    u16 interfaceTag)
-{
-    int r, i;
-    u8 spaceAvail[4] = {TRUE, TRUE, TRUE, TRUE};
-    tx_buffered_packets_t * buffered_pkt = NULL;
-    unsigned long lock_flags;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n");
-
-    if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
-        /* giving more priority to multicast packets so delaying unicast packets*/
-        unifi_trace(priv, UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n");
-
-        /* As station is active now, even though AP is not able to send frames to it
-         * because of DTIM, it needs to reset the TIM here
-         */
-        if (!staRecord->timRequestPendingFlag){
-            if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){
-                update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
-            }
-        }
-        else
-        {
-            /* Cache the TimSet value so that it will processed immidiatly after
-             * completing the current setTim Request
-             */
-            staRecord->updateTimReqQueued = 0;
-            unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                        staRecord->aid);
-        }
-        return;
-    }
-    while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
-        buffered_pkt->transmissionControl &=
-                     ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
-        if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, 0, FALSE)) == -ENOSPC) {
-            unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n");
-            /* Enqueue at the head of the queue */
-            spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-            list_add(&buffered_pkt->q, &staRecord->mgtFrames);
-            spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-            priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
-            spaceAvail[3] = FALSE;
-            break;
-        } else {
-            if(r){
-                unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                /* the PDU failed where we can't do any thing so free the storage */
-                unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-            }
-            kfree(buffered_pkt);
-        }
-    }
-    if (!staRecord->timRequestPendingFlag) {
-        if (staRecord->txSuspend) {
-            if(staRecord->timSet == CSR_WIFI_TIM_SET) {
-                update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
-            }
-            return;
-        }
-    }
-    else
-    {
-        /* Cache the TimSet value so that it will processed immidiatly after
-         * completing the current setTim Request
-         */
-        staRecord->updateTimReqQueued = 0;
-        unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                    staRecord->aid);
-    }
-    for(i=3;i>=0;i--) {
-        if(!spaceAvail[i])
-            continue;
-        unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n", i);
-        while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
-           buffered_pkt->transmissionControl &=
-                      ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
-           if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, 0, FALSE)) == -ENOSPC) {
-               /* Clear the trigger bit transmission control*/
-               /* Enqueue at the head of the queue */
-               spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-               list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
-               spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-               priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle);
-               break;
-           } else {
-              if(r){
-                  unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                  /* the PDU failed where we can't do any thing so free the storage */
-                  unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-               }
-              kfree(buffered_pkt);
-           }
-        }
-    }
-    if (!staRecord->timRequestPendingFlag){
-        if((staRecord->timSet  == CSR_WIFI_TIM_SET) || (staRecord->timSet  == CSR_WIFI_TIM_SETTING)) {
-            unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n");
-            update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
-        }
-    }
-    else
-    {
-        /* Cache the TimSet value so that it will processed immidiatly after
-         * completing the current setTim Request
-         */
-        staRecord->updateTimReqQueued = 0;
-        unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                    staRecord->aid);
-    }
-    unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n");
-}
-
-
-
-void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm)
-{
-    netInterface_priv_t *interfacePriv;
-    u8 i;
-    CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-
-    if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) {
-         unifi_trace(priv, UDBG2, "CFM for marked Multicast Tag = %x\n", interfacePriv->multicastPduHostTag);
-         interfacePriv->multicastPduHostTag = 0xffffffff;
-         resume_suspended_uapsd(priv, interfaceTag);
-         resume_unicast_buffered_frames(priv, interfaceTag);
-         if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) &&
-              list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
-            unifi_trace(priv, UDBG1, "Resetting multicastTIM");
-            if (!interfacePriv->bcTimSetReqPendingFlag)
-            {
-                update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
-            }
-            else
-            {
-                /* Cache the DTimSet value so that it will processed immidiatly after
-                 * completing the current setDTim Request
-                 */
-                 interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
-                 unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n",
-                             interfacePriv->bcTimSetReqQueued);
-            }
-
-        }
-        return;
-    }
-
-    /* Check if it is a Confirm for null data frame used
-     * for probing station activity
-     */
-    for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
-        if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) {
-
-            unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n",
-                                    pkt_cfm->HostTag,
-                                    pkt_cfm->TransmissionStatus
-                                    );
-            staRecord->nullDataHostTag = INVALID_HOST_TAG;
-
-            if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){
-                u32 now;
-                u32 inactive_time;
-
-                unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n");
-                /* Recheck if there is some activity after null data is sent.
-                *
-                * If still there is no activity then send a disconnected indication
-                * to SME to delete the station record.
-                */
-                if (staRecord->activity_flag){
-                    return;
-                }
-                now = CsrTimeGet(NULL);
-
-                if (staRecord->lastActivity > now)
-                {
-                    /* simple timer wrap (for 1 wrap) */
-                    inactive_time = CsrTimeAdd((u32)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity),
-                                               now);
-                }
-                else
-                {
-                    inactive_time = (u32)CsrTimeSub(now, staRecord->lastActivity);
-                }
-
-                if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
-                {
-                    struct list_head send_cfm_list;
-                    u8 j;
-
-                    /* The SME/NME may be waiting for confirmation for requested frames to this station.
-                     * Though this is --VERY UNLIKELY-- in case of station in active mode. But still as a
-                     * a defensive check, it loops through buffered frames for this station and if confirmation
-                     * is requested, send auto confirmation with failure status. Also flush the frames so
-                     * that these are not processed again in PEER_DEL_REQ handler.
-                     */
-                    INIT_LIST_HEAD(&send_cfm_list);
-
-                    uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                             &send_cfm_list,
-                                                             &(staRecord->mgtFrames));
-
-                    uf_flush_list(priv, &(staRecord->mgtFrames));
-
-                    for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
-                        uf_prepare_send_cfm_list_for_queued_pkts(priv,
-                                                                 &send_cfm_list,
-                                                                 &(staRecord->dataPdu[j]));
-
-                        uf_flush_list(priv, &(staRecord->dataPdu[j]));
-                    }
-
-                    send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list);
-
-
-
-                    unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
-                                             staRecord->peerMacAddress.a[0],
-                                             staRecord->peerMacAddress.a[1],
-                                             staRecord->peerMacAddress.a[2],
-                                             staRecord->peerMacAddress.a[3],
-                                             staRecord->peerMacAddress.a[4],
-                                             staRecord->peerMacAddress.a[5]);
-
-                    CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
-                                                      0,
-                                                      staRecord->interfacePriv->InterfaceTag,
-                                                      staRecord->peerMacAddress,
-                                                      CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
-                }
-
-            }
-            else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL)
-            {
-                 staRecord->activity_flag = TRUE;
-            }
-        }
-    }
-}
-
-#endif
-u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag)
-{
-    switch(mode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-            return (0x02<<8|tag);
-
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            return (0x03<<8|tag);
-
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            return (0x01<<8|tag);
-
-        case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
-            return (0x04<<8|tag);
-        case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
-            return (0x05<<8|tag);
-        default:
-            return tag;
-    }
-}
-
-#ifdef CSR_SUPPORT_SME
-
-/*
- * ---------------------------------------------------------------------------
- *  update_macheader
- *
- *
- *      These functions updates mac header for intra BSS packet
- *      routing.
- *      NOTE: This function always has to be called in rx context which
- *      is in bh thread context since GFP_KERNEL is used. In soft IRQ/ Interrupt
- *      context shouldn't be used
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      skb             Socket buffer containing data packet to transmit
- *      newSkb          Socket buffer containing data packet + Mac header if no sufficient headroom in skb
- *      priority        to append QOS control header in Mac header
- *      bulkdata        if newSkb allocated then bulkdata updated to send to unifi
- *      interfaceTag    the interfaceID on which activity going on
- *      macHeaderLengthInBytes no. of bytes of mac header in received frame
- *      qosDestination  used to append Qos control field
- *
- *  Returns:
- *      Zero on success or -1 on error.
- * ---------------------------------------------------------------------------
- */
-
-static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb,
-                            struct sk_buff *newSkb, CSR_PRIORITY *priority,
-                            bulk_data_param_t *bulkdata, u16 interfaceTag,
-                            u8 macHeaderLengthInBytes,
-                            u8 qosDestination)
-{
-
-    u16 *fc = NULL;
-    u8 direction = 0, toDs, fromDs;
-    u8 *bufPtr = NULL;
-    u8 sa[ETH_ALEN], da[ETH_ALEN];
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    int headroom;
-    u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0};
-
-    unifi_trace(priv, UDBG5, "entering the update_macheader function\n");
-
-    /* temporary buffer for the Mac header storage */
-    memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes);
-
-    /* remove the Macheader from the skb */
-    skb_pull(skb, macHeaderLengthInBytes);
-
-    /* get the skb headroom for skb_push check */
-    headroom = skb_headroom(skb);
-
-    /*  pointer to frame control field */
-    fc = (u16*) macHeaderBuf;
-
-    toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
-    fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
-    unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs);
-    direction = ((fromDs | (toDs << 1)) & 0x3);
-
-    /* Address1 or 3 from the macheader */
-    memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN);
-    /* Address2, 3 or 4 from the mac header */
-    memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN);
-
-    unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction);
-    /* update the toDs, fromDs & address fields in Mac header */
-    switch(direction)
-    {
-        case 2:
-            /* toDs = 1 & fromDs = 0 , toAp when frames received from peer
-             * while sending this packet to Destination the Mac header changed
-             * as fromDs = 1 & toDs = 0, fromAp
-             */
-            *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK);
-            *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
-            /* Address1: MAC address of the actual destination (4 = 2+2) */
-            memcpy(macHeaderBuf + 4, da, ETH_ALEN);
-            /* Address2: The MAC address of the AP (10 = 2+2+6) */
-            memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN);
-            /* Address3: MAC address of the actual source from mac header (16 = 2+2+6+6) */
-            memcpy(macHeaderBuf + 16, sa, ETH_ALEN);
-            break;
-        case 3:
-            unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n");
-            break;
-        default:
-            unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n");
-            return -1;
-    }
-
-    /* frameType is Data always, Validation is done before calling this function */
-
-    /* check for the souce station type */
-    switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
-    {
-        case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
-            /* No need to modify the qos control field */
-            if (!qosDestination) {
-
-                /* If source Sta is QOS enabled & if this bit set, then HTC is supported by
-                 * peer station & htc field present in macHeader
-                 */
-                if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
-                    /* HT control field present in Mac header
-                     * 6 = sizeof(qosControl) + sizeof(htc)
-                     */
-                    macHeaderLengthInBytes -= 6;
-                } else {
-                    macHeaderLengthInBytes -= 2;
-                }
-                /* Destination STA is non qos so change subtype to DATA */
-                *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
-                *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
-                /* remove the qos control field & HTC(if present). new macHeaderLengthInBytes is less than old
-                 * macHeaderLengthInBytes so no need to verify skb headroom
-                 */
-                if (headroom < macHeaderLengthInBytes) {
-                    unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n");
-                    return -1;
-                }
-                bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
-
-                /*  update bulk data os_data_ptr */
-                bulkdata->d[0].os_data_ptr = skb->data;
-                bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
-                bulkdata->d[0].data_length = skb->len;
-
-            } else {
-                /* pointing to QOS control field */
-                u8 qc;
-                if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
-                    qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2)));
-                } else {
-                    qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2)));
-                }
-
-                if ((qc & IEEE802_11_QC_TID_MASK) > 7) {
-                    *priority = 7;
-                } else {
-                    *priority = qc & IEEE802_11_QC_TID_MASK;
-                }
-
-                unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority);
-
-                if (headroom < macHeaderLengthInBytes) {
-                    unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n");
-                    return -1;
-                }
-                bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
-            }
-            break;
-        default:
-            {
-                bulk_data_param_t data_ptrs;
-                CsrResult csrResult;
-                unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n");
-
-                if (qosDestination) {
-                    u8 qc = 0;
-                    unifi_trace(priv, UDBG3, "destination is QOS station \n");
-
-                    /* Set Ma-Packet.req UP to UP0 */
-                    *priority = CSR_QOS_UP0;
-
-                    /* prepare the qos control field */
-                    qc |= CSR_QOS_UP0;
-                    /* no Amsdu is in ap buffer so eosp is left 0 */
-                    if (da[0] & 0x1) {
-                        /* multicast/broadcast frames, no acknowledgement needed */
-                        qc |= 1 << 5;
-                    }
-
-                    /* update new Mac header Length with 2 = sizeof(qos control) */
-                    macHeaderLengthInBytes += 2;
-
-                    /* received DATA frame but destiantion is QOS station so update subtype to QOS*/
-                    *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
-                    *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
-
-                    /* appendQosControlOffset = macHeaderLengthInBytes - 2, since source sta is not QOS */
-                    macHeaderBuf[macHeaderLengthInBytes - 2] = qc;
-                    /* txopLimit is 0 */
-                    macHeaderBuf[macHeaderLengthInBytes - 1] = 0;
-                    if (headroom < macHeaderLengthInBytes) {
-                        csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
-
-                        if (csrResult != CSR_RESULT_SUCCESS) {
-                            unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
-                            return -1;
-                        }
-                        newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
-                        newSkb->len = skb->len + macHeaderLengthInBytes;
-
-                        memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
-                                skb->data, skb->len);
-
-                        bulkdata->d[0].os_data_ptr = newSkb->data;
-                        bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
-                        bulkdata->d[0].data_length = newSkb->len;
-
-                        bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
-
-                        /* The old skb will not be used again */
-                        kfree_skb(skb);
-                    } else {
-                        /* skb headroom is sufficient to append Macheader */
-                        bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
-                        bulkdata->d[0].os_data_ptr = skb->data;
-                        bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
-                        bulkdata->d[0].data_length = skb->len;
-                    }
-                } else {
-                    unifi_trace(priv, UDBG3, "destination is not a QSTA\n");
-                    if (headroom < macHeaderLengthInBytes) {
-                        csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
-
-                        if (csrResult != CSR_RESULT_SUCCESS) {
-                            unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
-                            return -1;
-                        }
-                        newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
-                        newSkb->len = skb->len + macHeaderLengthInBytes;
-
-                        memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
-                                skb->data, skb->len);
-
-                        bulkdata->d[0].os_data_ptr = newSkb->data;
-                        bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
-                        bulkdata->d[0].data_length = newSkb->len;
-
-                        bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
-
-                        /* The old skb will not be used again */
-                        kfree_skb(skb);
-                    } else {
-                        /* skb headroom is sufficient to append Macheader */
-                        bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
-                        bulkdata->d[0].os_data_ptr = skb->data;
-                        bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
-                        bulkdata->d[0].data_length = skb->len;
-                    }
-                }
-            }
-    }
-
-    /* prepare the complete skb, by pushing the MAC header to the beginning of the skb->data */
-    unifi_trace(priv, UDBG5, "updated Mac Header: %d \n", macHeaderLengthInBytes);
-    memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes);
-
-    unifi_trace(priv, UDBG5, "leaving the update_macheader function\n");
-    return 0;
-}
-/*
- * ---------------------------------------------------------------------------
- *  uf_ap_process_data_pdu
- *
- *
- *      Takes care of intra BSS admission control & routing packets within BSS
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      skb             Socket buffer containing data packet to transmit
- *      ehdr            ethernet header to fetch priority of packet
- *      srcStaInfo      source stations record for connection verification
- *      packed_signal
- *      signal_len
- *      signal          MA-PACKET.indication signal
- *      bulkdata        if newSkb allocated then bulkdata updated to send to unifi
- *      macHeaderLengthInBytes no. of bytes of mac header in received frame
- *
- *  Returns:
- *      Zero on success(ap processing complete) or -1 if packet also have to be sent to NETDEV.
- * ---------------------------------------------------------------------------
- */
-int
-uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
-                       struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
-                       const CSR_SIGNAL *signal,
-                       bulk_data_param_t *bulkdata,
-                       u8 macHeaderLengthInBytes)
-{
-    const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication);
-    u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff);
-    struct sk_buff *newSkb = NULL;
-    /* pointer to skb or private skb created using skb_copy() */
-    struct sk_buff *skbPtr = skb;
-    u8 sendToNetdev = FALSE;
-    u8 qosDestination = FALSE;
-    CSR_PRIORITY priority = CSR_CONTENTION;
-    CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
-    netInterface_priv_t *interfacePriv;
-
-    unifi_trace(priv, UDBG5, "entering  uf_ap_process_data_pdu %d\n", macHeaderLengthInBytes);
-    /* InterfaceTag validation from MA_PACKET.indication */
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n");
-        unifi_net_data_free(priv, &bulkdata->d[0]);
-        return 0;
-    }
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) &&
-       (interfacePriv->intraBssEnabled == FALSE)) {
-        unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled);
-
-        /*In P2P GO case, if intraBSS distribution Disabled then don't do IntraBSS routing */
-        /* If destination in our BSS then drop otherwise give packet to netdev */
-        dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
-        if (dstStaInfo) {
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            return 0;
-        }
-        /* May be associated P2PCLI trying to send the packets on backbone (Netdev) */
-        return -1;
-    }
-
-    if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) {
-        /* This packet will be given to the TCP/IP stack since this packet is for us(AP)
-         * No routing needed */
-        unifi_trace(priv, UDBG4, "destination address is csr_ap\n");
-        return -1;
-    }
-
-    /* fetch the destination record from station record database */
-    dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
-
-    /* AP mode processing, & if packet is unicast */
-    if(!dstStaInfo) {
-        if (!(ehdr->h_dest[0] & 0x1)) {
-            /* destination not in station record & its a unicast packet, so pass the packet to network stack */
-            unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol));
-            return -1;
-        } else {
-            /* packet is multicast/broadcast */
-            /* copy the skb to skbPtr, send skb to netdev & skbPtr to multicast/broad cast list */
-            unifi_trace(priv, UDBG5, "skb_copy, in  uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol));
-            skbPtr = skb_copy(skb, GFP_KERNEL);
-            if(skbPtr == NULL) {
-                /* We don't have memory to don't send the frame in BSS*/
-                unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol));
-                return -1;
-            }
-            sendToNetdev = TRUE;
-        }
-    } else {
-
-        /* validate the Peer & Destination Station record */
-        if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) {
-            unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n");
-            interfacePriv->stats.rx_errors++;
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-            return 0;
-        }
-    }
-
-    /* BroadCast packet received and it's been sent as non QOS packets.
-     * Since WMM spec not mandates broadcast/multicast to be sent as QOS data only,
-     * if all Peers are QSTA
-     */
-    if(sendToNetdev) {
-       /* BroadCast packet and it's been sent as non QOS packets */
-        qosDestination = FALSE;
-    } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) {
-          qosDestination = TRUE;
-    }
-
-    unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination  = %s\n", (qosDestination)? "TRUE": "FALSE");
-
-    /* packet is allowed to send to unifi, update the Mac header */
-    if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) {
-        interfacePriv->stats.rx_errors++;
-        unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n");
-        if (sendToNetdev) {
-            /*  Free's the skb_copy(skbPtr) data since packet processing failed */
-            bulkdata->d[0].os_data_ptr = skbPtr->data;
-            bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
-            bulkdata->d[0].data_length = skbPtr->len;
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-        }
-        return -1;
-    }
-
-    unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n");
-
-    /* Packet is ready to send to unifi ,transmissionControl = 0x0004, confirmation is not needed for data packets */
-    if (uf_process_ma_packet_req(priv, ehdr->h_dest, 0xffffffff, interfaceTag, CSR_NO_CONFIRM_REQUIRED, (CSR_RATE)0, priority, priv->netdev_client->sender_id, bulkdata)) {
-        if (sendToNetdev) {
-            unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop) uf_process_ma_packet_req failed. freeing skb_copy data (original data sent to Netdev)\n");
-            /*  Free's the skb_copy(skbPtr) data since packet processing failed */
-            bulkdata->d[0].os_data_ptr = skbPtr->data;
-            bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
-            bulkdata->d[0].data_length = skbPtr->len;
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-        } else {
-            /* This free's the skb data */
-            unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n");
-            unifi_net_data_free(priv, &bulkdata->d[0]);
-        }
-    }
-    unifi_trace(priv, UDBG5, "leaving  uf_ap_process_data_pdu\n");
-
-    if (sendToNetdev) {
-        /* The packet is multicast/broadcast, so after AP processing packet has to
-         * be sent to netdev, if peer port state is open
-        */
-        unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n");
-        return -1;
-    }
-    /* Ap handled the packet & its a unicast packet, no need to send to netdev */
-    return 0;
-}
-
-#endif
-
-CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,
-                                   u8 *peerMacAddress,
-                                   CSR_CLIENT_TAG hostTag,
-                                   u16 interfaceTag,
-                                   CSR_TRANSMISSION_CONTROL transmissionControl,
-                                   CSR_RATE TransmitRate,
-                                   CSR_PRIORITY priority,
-                                   CSR_PROCESS_ID leSenderProcessId,
-                                   bulk_data_param_t *bulkdata)
-{
-    CsrResult status = CSR_RESULT_SUCCESS;
-    CSR_SIGNAL signal;
-    int result;
-#ifdef CSR_SUPPORT_SME
-   CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
-    const u8 *macHdrLocation =  bulkdata->d[0].os_data_ptr;
-    CsrWifiPacketType pktType;
-    int frameType = 0;
-    u8 queuePacketDozing = FALSE;
-    u32 priority_q;
-    u16 frmCtrl;
-    struct list_head * list = NULL; /* List to which buffered PDUs are to be enqueued*/
-    u8 setBcTim=FALSE;
-    netInterface_priv_t *interfacePriv;
-    u8 requeueOnSamePos = FALSE;
-    u32 handle = 0xFFFFFFFF;
-    unsigned long lock_flags;
-
-       unifi_trace(priv, UDBG5,
-               "entering uf_process_ma_packet_req, peer: %pMF\n",
-               peerMacAddress);
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
-        return CSR_RESULT_FAILURE;
-    }
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-
-    /* fetch the station record for corresponding peer mac address */
-    if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) {
-        handle = staRecord->assignedHandle;
-    }
-
-    /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
-    unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag,
-                              interfaceTag, transmissionControl, leSenderProcessId,
-                              peerMacAddress, &signal);
-
-   /* Since it's common path between STA & AP mode, in case of STA packet
-     * need not to be queued but in AP case we have to queue PDU's in
-     * different scenarios
-     */
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            /* For this mode processing done below */
-            break;
-        default:
-            /* In case of STA/IBSS/P2PCLI/AMP, no checks needed send the packet down & return */
-            unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode);
-            if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
-                unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__);
-            }
-            if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) {
-                status = CSR_RESULT_FAILURE;
-            }
-            return status;
-    }
-
-    /* -----Only AP/P2pGO mode handling falls below----- */
-
-    /* convert priority to queue */
-    priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
-
-    /* check the powersave status of the peer */
-    if (staRecord && (staRecord->currentPeerState ==
-                     CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) {
-        /* Peer is dozing & packet have to be delivered, so buffer the packet &
-         * update the TIM
-         */
-        queuePacketDozing = TRUE;
-    }
-
-    /* find the type of frame unicast or mulicast/broadcast */
-    if (*peerMacAddress & 0x1) {
-        /* Multicast/broadCast data are always triggered by vif_availability.ind
-         * at the DTIM
-         */
-        pktType = CSR_WIFI_MULTICAST_PDU;
-    } else {
-        pktType = CSR_WIFI_UNICAST_PDU;
-    }
-
-    /* Fetch the frame control field from mac header & check for frame type */
-    frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
-
-    /* Processing done according to Frame/Packet type */
-    frameType =  ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
-    switch(frameType)
-    {
-        case IEEE802_11_FRAMETYPE_MANAGEMENT:
-
-            switch(pktType)
-            {
-                case CSR_WIFI_UNICAST_PDU:
-                    unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n");
-                    /* push the packet in to the queue with appropriate mgt list */
-                    if (!staRecord) {
-                        /* push the packet to the unifi if list is empty (if packet lost how to re-enque) */
-                        if (list_empty(&interfacePriv->genericMgtFrames)) {
-#ifdef CSR_SUPPORT_SME
-                            if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
-#endif
-
-                            unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n");
-                            result = ul_send_signal_unpacked(priv, &signal, bulkdata);
-                            /*  reque only on ENOSPC */
-                            if(result == -ENOSPC) {
-                                /* requeue the failed packet to genericMgtFrame with same position */
-                                unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n");
-                                list = &interfacePriv->genericMgtFrames;
-                                requeueOnSamePos = TRUE;
-                            }
-#ifdef CSR_SUPPORT_SME
-                            }else{
-                                list = &interfacePriv->genericMgtFrames;
-                                unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n", signal.u.MaPacketRequest.HostTag);
-                                update_eosp_to_head_of_broadcast_list_head(priv, interfaceTag);
-                           }
-#endif
-                        } else {
-                            /* Queue the packet to genericMgtFrame of unifi_priv_t data structure */
-                            list = &interfacePriv->genericMgtFrames;
-                            unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n");
-                        }
-                    } else {
-                        /* check peer power state */
-                        if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
-                            /* peer is in dozing mode, so queue packet in mgt frame list of station record */
-                           /*if multicast traffic is going on, buffer the unicast packets*/
-                            list = &staRecord->mgtFrames;
-
-                            unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n",
-                                        (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing);
-                            if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)){
-                                update_eosp_to_head_of_broadcast_list_head(priv, interfaceTag);
-                            }
-
-                        } else {
-                            unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n");
-                            result = ul_send_signal_unpacked(priv, &signal, bulkdata);
-                            if(result == -ENOSPC) {
-                                /* requeue the failed packet to staRecord->mgtFrames with same position */
-                                list = &staRecord->mgtFrames;
-                                requeueOnSamePos = TRUE;
-                                unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n", staRecord->assignedHandle);
-                                priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
-                            } else if (result) {
-                                status = CSR_RESULT_FAILURE;
-                            }
-                        }
-                    }
-                    break;
-                case CSR_WIFI_MULTICAST_PDU:
-                    unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n");
-                    /* Queue the packet to genericMulticastOrBroadCastMgtFrames of unifi_priv_t data structure
-                     * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
-                     */
-
-                    list = &interfacePriv->genericMulticastOrBroadCastMgtFrames;
-                    if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) &&
-                            (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
-                        setBcTim=TRUE;
-                    }
-                    break;
-                default:
-                    unifi_error(priv, "condition never meets: packet type unrecognized\n");
-            }
-            break;
-        case IEEE802_11_FRAMETYPE_DATA:
-            switch(pktType)
-            {
-                case CSR_WIFI_UNICAST_PDU:
-                    unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n");
-                    /* check peer power state, list status & peer port status */
-                    if(!staRecord) {
-                        unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__);
-                        return CSR_RESULT_FAILURE;
-                    } else if (queuePacketDozing || isRouterBufferEnabled(priv, priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
-                        /* peer is in dozing mode, so queue packet in mgt frame list of station record */
-                        /* if multicast traffic is going on, buffet the unicast packets */
-                        unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\
-                                Buffering enabled = %d \n", priority_q, queuePacketDozing, isRouterBufferEnabled(priv, priority_q));
-                        list = &staRecord->dataPdu[priority_q];
-                    } else {
-                        unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q);
-                        /* Pdu allowed to send to unifi */
-                        result = ul_send_signal_unpacked(priv, &signal, bulkdata);
-                        if(result == -ENOSPC) {
-                            /* requeue the failed packet to staRecord->dataPdu[priority_q] with same position */
-                            unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n", priority_q);
-                            requeueOnSamePos = TRUE;
-                            list = &staRecord->dataPdu[priority_q];
-                            priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle);
-                            if(!isRouterBufferEnabled(priv, priority_q)) {
-                                unifi_error(priv, "Buffering Not enabled for queue %d \n", priority_q);
-                            }
-                        } else if (result) {
-                            status = CSR_RESULT_FAILURE;
-                        }
-                    }
-                    break;
-                case CSR_WIFI_MULTICAST_PDU:
-                    unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n");
-                    /* Queue the packet to genericMulticastOrBroadCastFrames list of unifi_priv_t data structure
-                     * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
-                     */
-                    list = &interfacePriv->genericMulticastOrBroadCastFrames;
-                    if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
-                        setBcTim = TRUE;
-                    }
-                    break;
-                default:
-                    unifi_error(priv, "condition never meets: packet type un recognized\n");
-            }
-            break;
-        default:
-            unifi_error(priv, "unrecognized frame type\n");
-    }
-    if(list) {
-        status = enque_tx_data_pdu(priv, bulkdata, list, &signal, requeueOnSamePos);
-        /* Record no. of packet queued for each peer */
-        if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) {
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            staRecord->noOfPktQueued++;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }
-        else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status))
-        {
-            /* If broadcast Tim is set && queuing is successful, then only update TIM */
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            interfacePriv->noOfbroadcastPktQueued++;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }
-    }
-    /* If broadcast Tim is set && queuing is successful, then only update TIM */
-    if(setBcTim && !status) {
-        unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n");
-        if (!interfacePriv->bcTimSetReqPendingFlag)
-        {
-            update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, handle);
-        }
-        else
-        {
-            /* Cache the TimSet value so that it will processed immidiatly after
-            * completing the current setTim Request
-            */
-            interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET;
-            unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n",
-                        interfacePriv->bcTimSetReqQueued);
-        }
-    } else if(staRecord && staRecord->currentPeerState ==
-                            CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
-        if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) {
-            if(!staRecord->wmmOrQosEnabled) {
-                if(!list_empty(&staRecord->mgtFrames) ||
-                   !list_empty(&staRecord->dataPdu[3]) ||
-                   !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) {
-                    unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n");
-                    if (!staRecord->timRequestPendingFlag){
-                        update_tim(priv, staRecord->aid, 1, interfaceTag, handle);
-                    }
-                    else
-                    {
-                        /* Cache the TimSet value so that it will processed immidiatly after
-                         * completing the current setTim Request
-                         */
-                        staRecord->updateTimReqQueued = 1;
-                        unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                                    staRecord->aid);
-                    }
-                }
-            } else {
-                /* Check for non delivery enable(i.e trigger enable), all delivery enable & legacy AC for TIM update in firmware */
-                u8 allDeliveryEnabled = 0, dataAvailable = 0;
-                /* Check if all AC's are Delivery Enabled */
-                is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
-                if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)
-                    || (!list_empty(&staRecord->mgtFrames))) {
-                    if (!staRecord->timRequestPendingFlag) {
-                        update_tim(priv, staRecord->aid, 1, interfaceTag, handle);
-                    }
-                    else
-                    {
-                        /* Cache the TimSet value so that it will processed immidiatly after
-                         * completing the current setTim Request
-                         */
-                        staRecord->updateTimReqQueued = 1;
-                        unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                                    staRecord->aid);
-                    }
-                }
-            }
-        }
-    }
-
-    if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv, priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
-        unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n", priority_q);
-        uf_send_buffered_frames(priv, priority_q);
-    }
-    unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n");
-    return status;
-#else
-#ifdef CSR_NATIVE_LINUX
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
-        return CSR_RESULT_FAILURE;
-    }
-    /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
-    unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag,
-            transmissionControl, leSenderProcessId,
-            peerMacAddress, &signal);
-    result = ul_send_signal_unpacked(priv, &signal, bulkdata);
-    if (result) {
-        return CSR_RESULT_FAILURE;
-    }
-#endif
-    return status;
-#endif
-}
-
-#ifdef CSR_SUPPORT_SME
-s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr)
-{
-    s8 protection = 0;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    switch(interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_STA:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
-        case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
-            protection = interfacePriv->protect;
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            {
-                CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
-                if (daddr[0] & 0x1) {
-                    unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n");
-                    /* In this mode, the protect member of priv structure has an information of how
-                     * AP/P2PGO has started, & the member updated in set mode request for AP/P2PGO
-                     */
-                    protection = interfacePriv->protect;
-                } else {
-                    /* fetch the destination record from station record database */
-                    dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag);
-                    if (!dstStaInfo) {
-                        unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n");
-                        return -1;
-                    }
-                    protection = dstStaInfo->protection;
-                }
-            }
-            break;
-        default:
-            unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n");
-    }
-    return protection;
-}
-#endif
-#ifdef CSR_SUPPORT_SME
-u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag)
-{
-    int r;
-    tx_buffered_packets_t * buffered_pkt = NULL;
-    u8 moreData = FALSE;
-    u8 pduSent =0;
-    unsigned long lock_flags;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    u32 hostTag = 0xffffffff;
-
-    if(!isRouterBufferEnabled(priv, UNIFI_TRAFFIC_Q_VO)) {
-        while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
-            buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK);
-            moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
-
-
-            unifi_trace(priv, UDBG2, "DTIM Occurred for interface:sending Mgt packet %d\n", interfaceTag);
-
-            if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, moreData, FALSE)) == -ENOSPC) {
-               unifi_trace(priv, UDBG1, "frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag);
-               /* Enqueue at the head of the queue */
-               spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-               list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
-               spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-               break;
-            } else {
-                unifi_trace(priv, UDBG1, "send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n",
-                                        buffered_pkt->hostTag,
-                                        r);
-                if(r) {
-                   unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                }
-                if(!moreData) {
-
-                    interfacePriv->dtimActive = FALSE;
-                    if(!r) {
-                        hostTag = buffered_pkt->hostTag;
-                        pduSent++;
-                    } else {
-                        send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_UNSPECIFIED_FAILURE);
-                    }
-                }
-                /* Buffered frame sent successfully */
-                spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-                interfacePriv->noOfbroadcastPktQueued--;
-                spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-                kfree(buffered_pkt);
-           }
-
-        }
-    }
-    if(!isRouterBufferEnabled(priv, UNIFI_TRAFFIC_Q_CONTENTION)) {
-        while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMulticastOrBroadCastFrames))) {
-            buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
-            moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
-
-
-            if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, moreData, FALSE)) == -ENOSPC) {
-                /* Clear the trigger bit transmission control*/
-                buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK);
-                /* Enqueue at the head of the queue */
-                spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames);
-                spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                break;
-            } else {
-                if(r) {
-                    unifi_trace(priv, UDBG1, "send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n",
-                                            buffered_pkt->hostTag,
-                                            r);
-                    unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                }
-                if(!moreData) {
-                    interfacePriv->dtimActive = FALSE;
-                    if(!r) {
-                        pduSent ++;
-                        hostTag = buffered_pkt->hostTag;
-                    } else {
-                        send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_UNSPECIFIED_FAILURE);
-                    }
-                }
-                /* Buffered frame sent successfully */
-                spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-                interfacePriv->noOfbroadcastPktQueued--;
-                spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-                kfree(buffered_pkt);
-            }
-        }
-    }
-    if((interfacePriv->dtimActive == FALSE)) {
-        /* Record the host Tag*/
-        unifi_trace(priv, UDBG2, "send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n", hostTag);
-        interfacePriv->multicastPduHostTag = hostTag;
-    }
-    return pduSent;
-}
-#endif
-void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata,
-                                        u32 siglen)
-{
-#ifdef CSR_SUPPORT_SME
-    CSR_SIGNAL signal;
-    CSR_MA_VIF_AVAILABILITY_INDICATION *ind;
-    int r;
-    u16 interfaceTag;
-    u8 pduSent =0;
-    CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS;
-    netInterface_priv_t *interfacePriv;
-
-    unifi_trace(priv, UDBG3,
-            "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n",
-            *((u16*)sigdata));
-
-    r = read_unpack_signal(sigdata, &signal);
-    if (r) {
-        unifi_error(priv,
-                    "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n",
-                    CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
-        return;
-    }
-    ind = &signal.u.MaVifAvailabilityIndication;
-    interfaceTag=ind->VirtualInterfaceIdentifier & 0xff;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n");
-        return;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if(ind->Multicast) {
-        if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) &&
-            list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) {
-            /* This condition can occur because of a potential race where the
-               TIM is not yet reset as host is waiting for confirm but it is sent
-               by firmware and DTIM occurs*/
-            unifi_notice(priv, "ma_vif_availibility_ind recevied for multicast but queues are empty%d\n", interfaceTag);
-            send_vif_availibility_rsp(priv, ind->VirtualInterfaceIdentifier, CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
-            interfacePriv->dtimActive = FALSE;
-            if(interfacePriv->multicastPduHostTag == 0xffffffff) {
-                unifi_notice(priv, "ma_vif_availibility_ind recevied for multicast but queues are empty%d\n", interfaceTag);
-                /* This may be an extra request in very rare race conditions but it is fine as it would atleast remove the potential lock up */
-                if (!interfacePriv->bcTimSetReqPendingFlag)
-                {
-                    update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
-                }
-                else
-                {
-                    /* Cache the TimSet value so that it will processed immidiatly after
-                     * completing the current setTim Request
-                     */
-                    interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
-                    unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n",
-                                interfacePriv->bcTimSetReqQueued);
-                }
-            }
-            return;
-        }
-        if(interfacePriv->dtimActive) {
-            unifi_trace(priv, UDBG2, "DTIM Occurred for already active DTIM interface %d\n", interfaceTag);
-            return;
-        } else {
-            unifi_trace(priv, UDBG2, "DTIM Occurred for interface %d\n", interfaceTag);
-            if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
-                set_eosp_transmit_ctrl(priv, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
-            } else {
-                set_eosp_transmit_ctrl(priv, &interfacePriv->genericMulticastOrBroadCastFrames);
-            }
-        }
-        interfacePriv->dtimActive = TRUE;
-        pduSent = send_multicast_frames(priv, interfaceTag);
-    }
-    else {
-        unifi_error(priv, "Interface switching is not supported %d\n", interfaceTag);
-        resultCode = CSR_RC_NOT_SUPPORTED;
-        send_vif_availibility_rsp(priv, ind->VirtualInterfaceIdentifier, CSR_RC_NOT_SUPPORTED);
-    }
-#endif
-}
-#ifdef CSR_SUPPORT_SME
-
-#define  GET_ACTIVE_INTERFACE_TAG(priv) 0
-
-static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord)
-{
-    s8 i;
-
-    for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--)
-    {
-        if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
-             ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
-             &&(!list_empty(&staRecord->dataPdu[i]))) {
-            unifi_trace(priv, UDBG2, "uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i);
-            return TRUE;
-        }
-    }
-
-    unifi_trace(priv, UDBG2, "uf_is_more_data_for_delivery_ac: Data NOT Available \n");
-    return FALSE;
-}
-
-static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue)
-{
-    s8 i;
-
-    for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--)
-    {
-        if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
-             ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
-             &&(!list_empty(&staRecord->dataPdu[i]))) {
-            unifi_trace(priv, UDBG2, "uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i);
-            return TRUE;
-        }
-    }
-
-    unifi_trace(priv, UDBG2, "uf_is_more_data_for_usp_delivery: Data NOT Available \n");
-    return FALSE;
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_send_buffered_data_from_delivery_ac
- *
- *      This function takes care of
- *      -> Parsing the delivery enabled queue & sending frame down to HIP
- *      -> Setting EOSP=1 when USP to be terminated
- *      -> Depending on MAX SP length services the USP
- *
- * NOTE:This function always called from uf_handle_uspframes_delivery(), Dont
- *      call this function from any other location in code
- *
- *  Arguments:
- *      priv        Pointer to device private context struct
- *      vif         interface specific HIP vif instance
- *      staInfo     peer for which UAPSD to be scheduled
- *      queue       AC from which Data to be sent in USP
- *      txList      access category for processing list
- * ---------------------------------------------------------------------------
- */
-void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv,
-                                            CsrWifiRouterCtrlStaInfo_t * staInfo,
-                                            u8 queue,
-                                            struct list_head *txList)
-{
-
-    u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
-    tx_buffered_packets_t * buffered_pkt = NULL;
-    unsigned long lock_flags;
-    u8 eosp=FALSE;
-    s8 r =0;
-    u8 moreData = FALSE;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
-
-    if (queue > UNIFI_TRAFFIC_Q_VO)
-    {
-        return;
-    }
-    while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) {
-        if((IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
-            unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n",
-                        staInfo->aid);
-
-            /* Once resume called, the U-APSD delivery operation will resume */
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            staInfo->uspSuspend = TRUE;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-            /* re-queueing the packet as DTIM started */
-            spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-            list_add(&buffered_pkt->q, txList);
-            spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-            break;
-        }
-
-        buffered_pkt->transmissionControl &=
-                 ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-
-
-        if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) {
-
-             buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK;
-
-             /* Check All delivery enables Ac for more data, because caller of this
-              * function not aware about last packet
-              * (First check in moreData fetching helps in draining out Mgt frames Q)
-              */
-              moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue));
-
-              if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) {
-                  moreData = FALSE;
-              }
-
-              if(moreData == FALSE) {
-                  eosp = TRUE;
-                  buffered_pkt->transmissionControl =
-                      (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-              }
-        } else {
-            /* Non QoS and non U-APSD */
-            unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n");
-        }
-
-        unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n", moreData, eosp);
-
-        if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, moreData, eosp)) == -ENOSPC) {
-
-            unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue);
-
-            /* Once resume called, the U-APSD delivery operation will resume */
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            staInfo->uspSuspend = TRUE;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-            spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-            list_add(&buffered_pkt->q, txList);
-            spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-            priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
-            break;
-        } else {
-            if(r){
-                /* the PDU failed where we can't do any thing so free the storage */
-                unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-            }
-            kfree(buffered_pkt);
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            staInfo->noOfSpFramesSent++;
-            if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) {
-                unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n");
-                staInfo->uapsdActive = FALSE;
-                staInfo->uspSuspend = FALSE;
-                staInfo->noOfSpFramesSent = 0;
-                spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-                break;
-            }
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }
-    }
-    unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
-}
-
-void uf_send_buffered_data_from_ac(unifi_priv_t *priv,
-                                   CsrWifiRouterCtrlStaInfo_t * staInfo,
-                                   u8 queue,
-                                   struct list_head *txList)
-{
-    tx_buffered_packets_t * buffered_pkt = NULL;
-    unsigned long lock_flags;
-    u8 eosp=FALSE;
-    u8 moreData = FALSE;
-    s8 r =0;
-
-    unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_ac :\n");
-
-    while(!isRouterBufferEnabled(priv, queue) &&
-                    ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){
-
-        buffered_pkt->transmissionControl &=
-                 ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
-
-        unifi_trace(priv, UDBG3, "uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n", moreData, eosp);
-
-        if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, moreData, eosp)) == -ENOSPC) {
-           /* Enqueue at the head of the queue */
-           spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-           list_add(&buffered_pkt->q, txList);
-           spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-           if(staInfo != NULL){
-              priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
-           }
-           unifi_trace(priv, UDBG3, " uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n", queue);
-           } else {
-            if(r){
-                /* the PDU failed where we can't do any thing so free the storage */
-                unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-            }
-            kfree(buffered_pkt);
-      }
-  }
-
-}
-
-void uf_send_buffered_frames(unifi_priv_t *priv, unifi_TrafficQueue q)
-{
-    u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
-    u32 startIndex=0, endIndex=0;
-    CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
-    u8 queue;
-    u8 moreData = FALSE;
-
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
-        (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)))
-        return;
-
-    queue = (q<=3)?q:0;
-
-    if(interfacePriv->dtimActive) {
-        /* this function updates dtimActive*/
-        send_multicast_frames(priv, interfaceTag);
-        if(!interfacePriv->dtimActive) {
-            moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
-             !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
-            if(!moreData) {
-                if (!interfacePriv->bcTimSetReqPendingFlag)
-                {
-                    update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0XFFFFFFFF);
-                }
-                else
-                {
-                    /* Cache the TimSet value so that it will processed immidiatly after
-                     * completing the current setTim Request
-                     */
-                    interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
-                    unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n",
-                                interfacePriv->bcTimSetReqQueued);
-                }
-            }
-        } else {
-            moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
-                        !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
-           if(!moreData) {
-               /* This should never happen but if it happens, we need a way out */
-               unifi_error(priv, "ERROR: No More Data but DTIM is active sending Response\n");
-               send_vif_availibility_rsp(priv, uf_get_vif_identifier(interfacePriv->interfaceMode, interfaceTag), CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
-               interfacePriv->dtimActive = FALSE;
-           }
-        }
-        return;
-    }
-    if(priv->pausedStaHandle[queue] > 7) {
-        priv->pausedStaHandle[queue] = 0;
-    }
-
-    if(queue == UNIFI_TRAFFIC_Q_VO) {
-
-
-        unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying mgt from queue=%d\n", queue);
-        for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
-            staInfo =  CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag);
-            if(!staInfo ) {
-                continue;
-            } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
-                       &&(staInfo->uapsdActive == FALSE) ) {
-                continue;
-            }
-
-            if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
-                               &&(staInfo->uapsdActive == FALSE)){
-                            /*Non-UAPSD case push the management frames out*/
-               if(!list_empty(&staInfo->mgtFrames)){
-                    uf_send_buffered_data_from_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
-                }
-            }
-
-            if(isRouterBufferEnabled(priv, queue)) {
-                unifi_notice(priv, "uf_send_buffered_frames : No space Left for queue = %d\n", queue);
-                break;
-            }
-        }
-        /*push generic management frames out*/
-        if(!list_empty(&interfacePriv->genericMgtFrames)) {
-            unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying generic mgt from queue=%d\n", queue);
-            uf_send_buffered_data_from_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames);
-        }
-    }
-
-
-    unifi_trace(priv, UDBG2, "uf_send_buffered_frames : Resume called for Queue=%d\n", queue);
-    unifi_trace(priv, UDBG2, "uf_send_buffered_frames : start=%d end=%d\n", startIndex, endIndex);
-
-    startIndex = priv->pausedStaHandle[queue];
-    endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS;
-
-    while(startIndex != endIndex) {
-        staInfo =  CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag);
-        if(!staInfo) {
-            startIndex ++;
-            if(startIndex >= UNIFI_MAX_CONNECTIONS) {
-                startIndex = 0;
-            }
-            continue;
-        } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
-                   &&(staInfo->uapsdActive == FALSE)) {
-            startIndex ++;
-            if(startIndex >= UNIFI_MAX_CONNECTIONS) {
-                startIndex = 0;
-            }
-            continue;
-        }
-        /* Peer is active or U-APSD is active so send PDUs to the peer */
-        unifi_trace(priv, UDBG2, "uf_send_buffered_frames : trying data from queue=%d\n", queue);
-
-
-        if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
-                           &&(staInfo->uapsdActive == FALSE)) {
-           if(!list_empty(&staInfo->dataPdu[queue])) {
-
-               /*Non-UAPSD case push the AC frames out*/
-               uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue]));
-           }
-        }
-        startIndex ++;
-        if(startIndex >= UNIFI_MAX_CONNECTIONS) {
-           startIndex = 0;
-        }
-    }
-    if(isRouterBufferEnabled(priv, queue)) {
-        priv->pausedStaHandle[queue] = endIndex;
-    } else {
-        priv->pausedStaHandle[queue] = 0;
-    }
-
-    /* U-APSD might have stopped because of ENOSPC in lib_hip (pause activity).
-     * So restart it if U-APSD was active with any of the station
-     */
-    unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue);
-    resume_suspended_uapsd(priv, interfaceTag);
-}
-
-
-u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord)
-{
-    u8 i;
-
-    for(i=0;i<=3;i++)
-    {
-        if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
-                ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
-                &&(!list_empty(&staRecord->dataPdu[i]))){
-
-         return TRUE;
-        }
-    }
-
-    if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
-            ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
-            &&(!list_empty(&staRecord->mgtFrames))){
-
-     return TRUE;
-    }
-
-
-
-    return FALSE;
-}
-
-
-int uf_process_station_records_for_sending_data(unifi_priv_t *priv, u16 interfaceTag,
-                                                 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
-                                                 CsrWifiRouterCtrlStaInfo_t *dstStaInfo)
-{
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n");
-
-    if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) {
-        unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n",
-                    srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action);
-        return -1;
-    }
-    switch (interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-            unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n");
-            break;
-        default:
-            unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n");
-            return -1;
-    }
-
-    switch(dstStaInfo->peerControlledPort->port_action)
-    {
-        case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD:
-        case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK:
-            unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n");
-            return -1;
-        default:
-            unifi_trace(priv, UDBG5, "destination port state is open\n");
-    }
-
-    /* port state is open, destination station record is valid, Power save state is
-     * validated in uf_process_ma_packet_req function
-     */
-    unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n");
-    return 0;
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_handle_uspframes_delivery
- *
- *      This function takes care of handling USP session for peer, when
- *      -> trigger frame from peer
- *      -> suspended USP to be processed (resumed)
- *
- *      NOTE: uf_send_buffered_data_from_delivery_ac() always called from this function, Dont
- *      make a direct call to uf_send_buffered_data_from_delivery_ac() from any other part of
- *      code
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      staInfo         peer for which UAPSD to be scheduled
- *      interfaceTag    virtual interface tag
- * ---------------------------------------------------------------------------
- */
-static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag)
-{
-
-    s8 i;
-    u8 allDeliveryEnabled = 0, dataAvailable = 0;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n",
-                staInfo->uapsdActive, staInfo->uspSuspend);
-
-    /* Check for Buffered frames according to priority order & deliver it
-     *  1. AC_VO delivery enable & Mgt frames available
-     *  2. Process remaining Ac's from order AC_VO to AC_BK
-     */
-
-    /* USP initiated by WMMPS enabled peer  & SET the status flag to TRUE */
-    if (!staInfo->uspSuspend && staInfo->uapsdActive)
-    {
-        unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n",
-                staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1],
-                staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3],
-                staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]);
-        return;
-    }
-
-    spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-    staInfo->uapsdActive = TRUE;
-    staInfo->uspSuspend = FALSE;
-    spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-    if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)||
-        (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE))
-        && (!list_empty(&staInfo->mgtFrames))) {
-
-         /* Management queue has data &&  UNIFI_TRAFFIC_Q_VO is delivery enable */
-        unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n");
-        uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
-    }
-
-    if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) {
-        /* All delivery enable AC's are empty, so QNULL to be sent to terminate the USP
-         * NOTE: If we have sent Mgt frame also, we must send QNULL followed to terminate USP
-         */
-        if (!staInfo->uspSuspend) {
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            staInfo->uapsdActive = FALSE;
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-            unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n");
-            uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo);
-            staInfo->triggerFramePriority = CSR_QOS_UP0;
-        } else {
-            unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n");
-        }
-    } else {
-        for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) {
-            if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
-                ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
-                && (!list_empty(&staInfo->dataPdu[i]))) {
-                /* Deliver Data according to AC priority (from VO to BK) as part of USP */
-                unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i);
-                uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]);
-            }
-
-            if ((!staInfo->uapsdActive) ||
-                    (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag))) {
-                /* If DTIM active found on one AC, No need to parse the remaining AC's
-                 * as USP suspended. Break out of loop
-                 */
-                unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x,  DTIM=%x, USP terminated=%s\n",
-                           staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag),
-                           staInfo->uapsdActive?"NO":"YES");
-                break;
-            }
-        }
-    }
-
-    /* Depending on the USP status, update the TIM accordingly for delivery enabled AC only
-     * (since we are not manipulating any Non-delivery list(AC))
-     */
-    is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable);
-    if ((allDeliveryEnabled && !dataAvailable)) {
-        if ((staInfo->timSet != CSR_WIFI_TIM_RESET) && (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) {
-            staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET;
-            unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n");
-            if (!staInfo->timRequestPendingFlag) {
-                update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle);
-            }
-        }
-    }
-    unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n",
-                staInfo->uapsdActive, staInfo->uspSuspend);
-}
-
-void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv,
-                                     CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
-                                     u16 qosControl,
-                                     u16 interfaceTag)
-{
-    CSR_PRIORITY priority;
-    unifi_TrafficQueue priority_q;
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
-    /* If recceived Frames trigger Frame and Devlivery enabled AC has data
-     * then transmit from High priorty delivery enabled AC
-     */
-    priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
-    priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
-
-    if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
-        ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) {
-        spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-        srcStaInfo->triggerFramePriority = priority;
-        spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q);
-        uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag);
-    }
-    unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
-}
-
-
-void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
-{
-    bulk_data_param_t bulkdata;
-    CsrResult csrResult;
-    struct sk_buff *skb, *newSkb = NULL;
-    CsrWifiMacAddress peerAddress;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK);
-    int r;
-    CSR_SIGNAL signal;
-    u32 priority_q;
-    CSR_RATE transmitRate = 0;
-
-
-    /* Send a Null Frame to Peer,
-     * 32= size of mac header  */
-    csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE);
-
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n");
-        return ;
-    }
-    skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
-    skb->len = 0;
-    bulkdata.d[0].os_data_ptr = skb->data;
-    bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
-    bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].os_net_buf_ptr = NULL;
-    bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
-
-    /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
-
-    if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
-        unifi_error(priv, "failed to create MAC header\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return;
-    }
-    memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
-    /* convert priority to queue */
-    priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
-
-    /* Frame ma-packet.req, this is saved/transmitted depend on queue state
-     * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
-     */
-    switch (interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-            transmitRate = 2;
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            transmitRate = 12;
-            break;
-        default:
-            transmitRate = 0;
-    }
-    unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag,
-                              transmissionControl, priv->netdev_client->sender_id,
-                              peerAddress.a, &signal);
-
-    r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
-    if(r) {
-        unifi_error(priv, "failed to send QOS data null packet result: %d\n", r);
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-    }
-
-    return;
-
-}
-void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
-{
-    bulk_data_param_t bulkdata;
-    CsrResult csrResult;
-    struct sk_buff *skb, *newSkb = NULL;
-    CsrWifiMacAddress peerAddress;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    CSR_TRANSMISSION_CONTROL transmissionControl = 0;
-    int r;
-    CSR_SIGNAL signal;
-    u32 priority_q;
-    CSR_RATE transmitRate = 0;
-    CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
-    unsigned long lock_flags;
-
-    /* Send a Null Frame to Peer, size = 24 for MAC header */
-    csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE);
-
-    if (csrResult != CSR_RESULT_SUCCESS) {
-        unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n");
-        return ;
-    }
-    skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
-    skb->len = 0;
-    bulkdata.d[0].os_data_ptr = skb->data;
-    bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
-    bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
-    bulkdata.d[1].os_data_ptr = NULL;
-    bulkdata.d[1].os_net_buf_ptr = NULL;
-    bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
-
-    /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
-    if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
-        unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n");
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        return;
-    }
-    memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
-    /* convert priority to queue */
-    priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
-    transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED);
-
-    /* Frame ma-packet.req, this is saved/transmitted depend on queue state
-     * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
-     */
-    switch (interfacePriv->interfaceMode)
-    {
-        case CSR_WIFI_ROUTER_CTRL_MODE_AP:
-            transmitRate = 2;
-            break;
-        case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
-            transmitRate = 12;
-            break;
-        default:
-            transmitRate = 0;
-    }
-    unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag,
-                              transmissionControl, priv->netdev_client->sender_id,
-                              peerAddress.a, &signal);
-
-    /* Save host tag to check the status on reception of MA packet confirm */
-    srcStaInfo->nullDataHostTag = req->HostTag;
-    unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag);
-
-    r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
-
-    if(r == -ENOSPC) {
-        unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n");
-        enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1);
-        spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-        srcStaInfo->noOfPktQueued++;
-        spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-
-    }
-    if(r && r != -ENOSPC){
-        unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n", r);
-        unifi_net_data_free(priv, &bulkdata.d[0]);
-        srcStaInfo->nullDataHostTag = INVALID_HOST_TAG;
-    }
-
-    return;
-}
-
-u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata)
-{
-    u8 *bssid = NULL;
-    static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
-    u8 toDs, fromDs;
-
-    toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0;
-    fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0;
-
-     if (toDs && fromDs)
-    {
-        unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n");
-        bssid = NULL;
-    }
-    else if((toDs == 0) && (fromDs ==0))
-    {
-        /* BSSID is Address 3 */
-        bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN));
-    }
-    else if(toDs)
-    {
-        /* BSSID is Address 1 */
-        bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4);
-    }
-    else if(fromDs)
-    {
-        /* BSSID is Address 2 */
-        bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN);
-    }
-
-    if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0)
-    {
-        return TRUE;
-    }
-    else
-    {
-        return FALSE;
-    }
-}
-
-
-u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
-                                u8 pmBit, u16 interfaceTag)
-{
-    u8 moreData = FALSE;
-    u8 powerSaveChanged = FALSE;
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n");
-    if (pmBit) {
-        priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle));
-    } else {
-        priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle));
-    }
-    if(pmBit) {
-        if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
-
-            /* disable the preemption */
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE;
-            powerSaveChanged = TRUE;
-            /* enable the preemption */
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        } else {
-            return powerSaveChanged;
-        }
-    } else {
-        if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
-            /* disable the preemption */
-            spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-            srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
-            powerSaveChanged = TRUE;
-            /* enable the preemption */
-            spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-        }else {
-            return powerSaveChanged;
-        }
-    }
-
-
-    if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
-        unifi_trace(priv, UDBG3, "Peer with AID = %d is active now\n", srcStaInfo->aid);
-        process_peer_active_transition(priv, srcStaInfo, interfaceTag);
-    } else {
-        unifi_trace(priv, UDBG3, "Peer with AID = %d is in PS Now\n", srcStaInfo->aid);
-        /* Set TIM if needed */
-        if(!srcStaInfo->wmmOrQosEnabled) {
-            moreData = (!list_empty(&srcStaInfo->mgtFrames) ||
-                        !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])||
-                        !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]));
-            if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
-                unifi_trace(priv, UDBG3, "This condition should not occur\n");
-                if (!srcStaInfo->timRequestPendingFlag){
-                    update_tim(priv, srcStaInfo->aid, 1, interfaceTag, srcStaInfo->assignedHandle);
-                }
-                else
-                {
-                    /* Cache the TimSet value so that it will processed immidiatly after
-                     * completing the current setTim Request
-                     */
-                    srcStaInfo->updateTimReqQueued = 1;
-                    unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
-                                srcStaInfo->aid);
-                }
-
-            }
-        } else {
-            u8 allDeliveryEnabled = 0, dataAvailable = 0;
-            unifi_trace(priv, UDBG5, "Qos in AP Mode\n");
-            /* Check if all AC's are Delivery Enabled */
-            is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable);
-            /*check for more data in non-delivery enabled queues*/
-            moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable));
-
-            if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
-                if (!srcStaInfo->timRequestPendingFlag){
-                    update_tim(priv, srcStaInfo->aid, 1, interfaceTag, srcStaInfo->assignedHandle);
-                }
-                else
-                {
-                    /* Cache the TimSet value so that it will processed immidiatly after
-                     * completing the current setTim Request
-                     */
-                    srcStaInfo->updateTimReqQueued = 1;
-                    unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
-                                srcStaInfo->aid);
-                }
-            }
-        }
-    }
-    unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n");
-    return powerSaveChanged;
-}
-
-
-
-void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag)
-{
-    CsrWifiRouterCtrlStaInfo_t *staRecord =
-    CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
-    tx_buffered_packets_t * buffered_pkt = NULL;
-    CsrWifiMacAddress peerMacAddress;
-    unsigned long lock_flags;
-    s8 r =0;
-    u8 moreData = FALSE;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n");
-    if(!staRecord) {
-        memcpy(peerMacAddress.a, sa, ETH_ALEN);
-        unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n",
-                sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
-        CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
-        return;
-    }
-
-    uf_process_pm_bit_for_peer(priv, staRecord, pmBit, interfaceTag);
-
-    /* Update station last activity time */
-    staRecord->activity_flag = TRUE;
-
-    /* This should not change the PM bit as PS-POLL has PM bit always set */
-    if(!pmBit) {
-        unifi_notice (priv, " PM bit reset in PS-POLL\n");
-        return;
-    }
-
-    if(IS_DTIM_ACTIVE(interfacePriv->dtimActive, interfacePriv->multicastPduHostTag)) {
-        /* giving more priority to multicast packets so dropping ps-poll*/
-        unifi_notice (priv, " multicast transmission is going on so don't take action on PS-POLL\n");
-        return;
-    }
-
-    if(!staRecord->wmmOrQosEnabled) {
-        if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
-            buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
-            moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
-                        !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
-                        !list_empty(&staRecord->mgtFrames));
-
-            buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-            if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
-                /* Clear the trigger bit transmission control*/
-                buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-                /* Enqueue at the head of the queue */
-                spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                list_add(&buffered_pkt->q, &staRecord->mgtFrames);
-                spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
-                priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
-            } else {
-                if(r){
-                    unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                    /* the PDU failed where we can't do any thing so free the storage */
-                    unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                }
-                kfree(buffered_pkt);
-            }
-        } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) {
-            buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
-            moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
-                        !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]));
-
-            buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-            if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
-                /* Clear the trigger bit transmission control*/
-                buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-                /* Enqueue at the head of the queue */
-                spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]);
-                spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
-                unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
-            } else {
-                if(r){
-                    unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                    /* the PDU failed where we can't do any thing so free the storage */
-                    unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                }
-                kfree(buffered_pkt);
-            }
-        } else  if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) {
-            buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
-            moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
-
-            buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-            if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
-                /* Clear the trigger bit transmission control*/
-                buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-                /* Enqueue at the head of the queue */
-                spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
-                spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
-                unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
-            } else {
-                if(r){
-                    unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                    /* the PDU failed where we can't do any thing so free the storage */
-                    unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                }
-                kfree(buffered_pkt);
-            }
-        } else {
-         /* Actually since we have sent an ACK, there
-         * there is no need to send a NULL frame*/
-        }
-        moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
-           !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
-            !list_empty(&staRecord->mgtFrames));
-        if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
-            unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
-            if (!staRecord->timRequestPendingFlag){
-                update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
-            }
-            else
-            {
-                /* Cache the TimSet value so that it will processed immidiatly after
-                 * completing the current setTim Request
-                 */
-                staRecord->updateTimReqQueued = 0;
-                unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                            staRecord->aid);
-            }
-        }
-    } else {
-
-        u8 allDeliveryEnabled = 0, dataAvailable = 0;
-        unifi_trace(priv, UDBG3, "Qos Support station.Processing PS-Poll\n");
-
-        /*Send Data From Management Frames*/
-        /* Priority orders for delivering the buffered packets are
-         * 1. Deliver the Management frames if there
-         * 2. Other access category frames which are non deliver enable including UNIFI_TRAFFIC_Q_VO
-         * priority is from VO->BK
-         */
-
-        /* Check if all AC's are Delivery Enabled */
-        is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
-
-        if (allDeliveryEnabled) {
-            unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n");
-            uf_send_qos_null(priv, interfaceTag, sa, CSR_QOS_UP0, staRecord);
-            return;
-        }
-
-        if (!list_empty(&staRecord->mgtFrames)) {
-             if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
-                    /* We dont have packets in non delivery enabled UNIFI_TRAFFIC_Q_VO, So we are looking in management
-                     * queue of the station record
-                     */
-                    moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
-                    buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-
-                    /* Last parameter is EOSP & its false always for PS-POLL processing */
-                    if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
-                        /* Clear the trigger bit transmission control*/
-                        buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-                        /* Enqueue at the head of the queue */
-                        spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                        list_add(&buffered_pkt->q, &staRecord->mgtFrames);
-                        spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                        priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
-                        unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
-                    } else {
-                        if(r){
-                            unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                            /* the PDU failed where we can't do any thing so free the storage */
-                            unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                        }
-                        kfree(buffered_pkt);
-                    }
-                } else {
-                    unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n");
-                }
-
-        } else {
-            s8 i;
-            /* We dont have buffered packet in mangement frame queue (1 failed), So proceed with condition 2
-             * UNIFI_TRAFFIC_Q_VO -> VI -> BE -> BK
-             */
-            for(i= 3; i>=0; i--) {
-                if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
-                    /* Send One packet, if queue is NULL then continue */
-                    if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
-                        moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
-
-                        buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-
-                        /* Last parameter is EOSP & its false always for PS-POLL processing */
-                        if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staRecord, moreData, FALSE)) == -ENOSPC) {
-                            /* Clear the trigger bit transmission control*/
-                            buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
-                            /* Enqueue at the head of the queue */
-                            spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                            list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
-                            spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                            priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
-                            unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
-                        } else {
-                            if(r) {
-                                unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                                /* the PDU failed where we can't do any thing so free the storage */
-                                unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                            }
-                            kfree(buffered_pkt);
-                        }
-                        break;
-                    }
-                }
-            }
-        }
-        /* Check if all AC's are Delivery Enabled */
-        is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
-        /*check for more data in non-delivery enabled queues*/
-        moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
-        if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
-            unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
-            if (!staRecord->timRequestPendingFlag){
-                update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
-            }
-            else
-            {
-                /* Cache the TimSet value so that it will processed immidiatly after
-                 * completing the current setTim Request
-                 */
-                staRecord->updateTimReqQueued = 0;
-                unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
-                            staRecord->aid);
-            }
-
-        }
-    }
-
-        unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n");
-}
-
-
-
-void add_to_send_cfm_list(unifi_priv_t * priv,
-                          tx_buffered_packets_t *tx_q_item,
-                          struct list_head *frames_need_cfm_list)
-{
-    tx_buffered_packets_t *send_cfm_list_item = NULL;
-
-    send_cfm_list_item = kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
-
-    if(send_cfm_list_item == NULL){
-        unifi_warning(priv, "%s: Failed to allocate memory for new list item \n");
-        return;
-    }
-
-    INIT_LIST_HEAD(&send_cfm_list_item->q);
-
-    send_cfm_list_item->hostTag = tx_q_item->hostTag;
-    send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag;
-    send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl;
-    send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId;
-    send_cfm_list_item->rate = tx_q_item->rate;
-    memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN);
-    send_cfm_list_item->priority = tx_q_item->priority;
-
-    list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list);
-}
-
-void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
-                                                 struct list_head *frames_need_cfm_list,
-                                                 struct list_head * list)
-{
-    tx_buffered_packets_t *tx_q_item = NULL;
-    struct list_head *listHead;
-    struct list_head *placeHolder;
-    unsigned long lock_flags;
-
-    spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-
-    /* Search through the list and if confirmation required for any frames,
-    add it to the send_cfm list */
-    list_for_each_safe(listHead, placeHolder, list) {
-        tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-
-        if(!tx_q_item) {
-            unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
-            continue;
-        }
-
-        /* check if confirmation is requested and if the sender ID
-        is not netdevice client then save the entry in the list for need cfms */
-        if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) &&
-            (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){
-             unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n",
-                __FUNCTION__,
-                tx_q_item->leSenderProcessId,
-                tx_q_item->hostTag,
-                tx_q_item->transmissionControl);
-
-             add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list);
-        }
-    }
-
-    spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-
-}
-
-
-
-void uf_flush_list(unifi_priv_t * priv, struct list_head * list)
-{
-    tx_buffered_packets_t *tx_q_item;
-    struct list_head *listHead;
-    struct list_head *placeHolder;
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG5, "entering the uf_flush_list \n");
-
-    spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-    /* go through list, delete & free memory */
-    list_for_each_safe(listHead, placeHolder, list) {
-        tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-
-        if(!tx_q_item) {
-            unifi_error(priv, "entry should exists, otherwise crashes (bug)\n");
-        }
-        unifi_trace(priv, UDBG5,
-                "proccess_tx:  in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
-                tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
-                tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
-                tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
-                tx_q_item->leSenderProcessId);
-
-        list_del(listHead);
-        /* free the allocated memory */
-        unifi_net_data_free(priv, &tx_q_item->bulkdata);
-        kfree(tx_q_item);
-        tx_q_item = NULL;
-        if (!priv->noOfPktQueuedInDriver) {
-            unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
-        } else {
-            priv->noOfPktQueuedInDriver--;
-        }
-    }
-    spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-}
-
-tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList)
-{
-    /* dequeue the tx data packets from the appropriate queue */
-    tx_buffered_packets_t *tx_q_item = NULL;
-    struct list_head *listHead;
-    struct list_head *placeHolder;
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n");
-    /* check for list empty */
-    if (list_empty(txList)) {
-        unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n");
-        return NULL;
-    }
-
-    /* Verification, if packet count is negetive */
-    if (priv->noOfPktQueuedInDriver == 0xFFFF) {
-        unifi_warning(priv, "no packet available in queue: debug");
-        return NULL;
-    }
-
-    /* return first node after header, & delete from the list  && atleast one item exist */
-    spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-    list_for_each_safe(listHead, placeHolder, txList) {
-        tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-        list_del(listHead);
-        break;
-    }
-    spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-
-    if (tx_q_item) {
-        unifi_trace(priv, UDBG5,
-                "proccess_tx:  In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
-                tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
-                tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
-                tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
-                tx_q_item->leSenderProcessId);
-    }
-
-    unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n");
-    return tx_q_item;
-}
-/* generic function to get the station record handler */
-CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
-        const u8 *peerMacAddress,
-        u16 interfaceTag)
-{
-    u8 i;
-    netInterface_priv_t *interfacePriv;
-    unsigned long lock_flags;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag);
-        return NULL;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    /* disable the preemption until station record is fetched */
-    spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-
-    for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        if (interfacePriv->staInfo[i]!= NULL) {
-            if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) {
-                /* enable the preemption as station record is fetched */
-                spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-                unifi_trace(priv, UDBG5, "peer entry found in station record\n");
-                return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]));
-            }
-        }
-    }
-    /* enable the preemption as station record is fetched */
-    spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-    unifi_trace(priv, UDBG5, "peer entry not found in station record\n");
-    return NULL;
-}
-/* generic function to get the station record handler from the handle */
-CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
-                                                                 u32 handle,
-                                                                 u16 interfaceTag)
-{
-    netInterface_priv_t *interfacePriv;
-
-    if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
-        unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag);
-        return NULL;
-    }
-    interfacePriv = priv->interfacePriv[interfaceTag];
-    return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]));
-}
-
-/* Function to do inactivity */
-void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, u32 currentTime)
-{
-    u32 i;
-    CsrWifiRouterCtrlStaInfo_t *staInfo;
-    u32 elapsedTime;    /* Time in microseconds */
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    CsrWifiMacAddress peerMacAddress;
-    unsigned long lock_flags;
-
-    if (interfacePriv == NULL) {
-        unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
-        return;
-    }
-
-    spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-    /* Go through the list of stations to check for inactivity */
-    for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        staInfo =  CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag);
-        if(!staInfo ) {
-            continue;
-        }
-
-        unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n",
-                currentTime, staInfo->lastActivity);
-
-
-        elapsedTime = (currentTime >= staInfo->lastActivity)?
-                (currentTime - staInfo->lastActivity):
-                (~((u32)0) - staInfo->lastActivity + currentTime);
-        spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-        if (elapsedTime > MAX_INACTIVITY_INTERVAL) {
-            memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress));
-
-            /* Indicate inactivity for the station */
-            unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n",
-                        peerMacAddress.a[0], peerMacAddress.a[1],
-                        peerMacAddress.a[2], peerMacAddress.a[3],
-                        peerMacAddress.a[4], peerMacAddress.a[5],
-                        elapsedTime);
-
-            CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
-        }
-    }
-
-    interfacePriv->last_inactivity_check = currentTime;
-}
-
-/* Function to update activity of a station */
-void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress)
-{
-    u32 elapsedTime, currentTime;    /* Time in microseconds */
-    u32 timeHi;         /* Not used - Time in microseconds */
-    CsrWifiRouterCtrlStaInfo_t *staInfo;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    unsigned long lock_flags;
-
-    if (interfacePriv == NULL) {
-        unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
-        return;
-    }
-
-    currentTime = CsrTimeGet(&timeHi);
-
-
-    staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag);
-
-    if (staInfo == NULL) {
-        unifi_trace(priv, UDBG4, "Sta does not exist yet");
-        return;
-    }
-
-    spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-    /* Update activity */
-    staInfo->lastActivity = currentTime;
-
-    /* See if inactivity handler needs to be run
-     * Here it is theoretically possible that the counter may have wrapped around. But
-     * since we just want to know when to run the inactivity handler it does not really matter.
-     * Especially since this is data path it makes sense in keeping it simple and avoiding
-     * 64 bit handling */
-    elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)?
-                    (currentTime - interfacePriv->last_inactivity_check):
-                    (~((u32)0) - interfacePriv->last_inactivity_check + currentTime);
-
-    spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-
-    /* Check if it is time to run the inactivity handler */
-    if (elapsedTime > INACTIVITY_CHECK_INTERVAL) {
-        uf_check_inactivity(priv, interfaceTag, currentTime);
-    }
-}
-void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag)
-{
-
-   netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-   u8 i;
-   int j;
-   tx_buffered_packets_t * buffered_pkt = NULL;
-   u8 hipslotFree[4] = {TRUE, TRUE, TRUE, TRUE};
-   int r;
-   unsigned long lock_flags;
-
-   while(!isRouterBufferEnabled(priv, 3) &&
-                            ((buffered_pkt=dequeue_tx_data_pdu(priv, &interfacePriv->genericMgtFrames))!=NULL)) {
-        buffered_pkt->transmissionControl &=
-                     ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
-        if((r=frame_and_send_queued_pdu(priv, buffered_pkt, NULL, 0, FALSE)) == -ENOSPC) {
-            /* Enqueue at the head of the queue */
-            spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-            list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames);
-            spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-            hipslotFree[3]=FALSE;
-            break;
-        }else {
-            if(r){
-                unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                /* the PDU failed where we can't do any thing so free the storage */
-                unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-            }
-            kfree(buffered_pkt);
-        }
-   }
-   for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i];
-        if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) {
-            unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n");
-            break;
-        }
-        if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) {
-          while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) {
-              buffered_pkt->transmissionControl &=
-                           ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
-              if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, 0, FALSE)) == -ENOSPC) {
-                  unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n");
-                  /* Enqueue at the head of the queue */
-                  spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                  list_add(&buffered_pkt->q, &staInfo->mgtFrames);
-                  spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                  priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle);
-                  hipslotFree[3] = FALSE;
-                  break;
-              } else {
-                  if(r){
-                      unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                      /* the PDU failed where we can't do any thing so free the storage */
-                      unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                  }
-                  kfree(buffered_pkt);
-              }
-          }
-
-          for(j=3;j>=0;j--) {
-              if(!hipslotFree[j])
-                  continue;
-
-              while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) {
-                 buffered_pkt->transmissionControl &=
-                            ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
-                 if((r=frame_and_send_queued_pdu(priv, buffered_pkt, staInfo, 0, FALSE)) == -ENOSPC) {
-                     /* Enqueue at the head of the queue */
-                     spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-                     list_add(&buffered_pkt->q, &staInfo->dataPdu[j]);
-                     spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-                     priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle);
-                     hipslotFree[j]=FALSE;
-                     break;
-                 } else {
-                    if(r){
-                        unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
-                        /* the PDU failed where we can't do any thing so free the storage */
-                        unifi_net_data_free(priv, &buffered_pkt->bulkdata);
-                     }
-                    kfree(buffered_pkt);
-                 }
-              }
-          }
-       }
-    }
-}
-void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag)
-{
-
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-    unsigned long lock_flags;
-    struct list_head *listHead;
-    struct list_head *placeHolder;
-    tx_buffered_packets_t *tx_q_item;
-
-    if (interfacePriv->noOfbroadcastPktQueued) {
-
-        /* Update the EOSP to the HEAD of b/c list
-         * because we have received any mgmt packet so it should not hold for long time
-         * peer may time out.
-         */
-        spin_lock_irqsave(&priv->tx_q_lock, lock_flags);
-        list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
-            tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
-            tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
-            tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
-            unifi_trace(priv, UDBG1, "updating eosp for list Head hostTag:= 0x%x ", tx_q_item->hostTag);
-            break;
-        }
-        spin_unlock_irqrestore(&priv->tx_q_lock, lock_flags);
-    }
-}
-
-/*
- * ---------------------------------------------------------------------------
- *  resume_suspended_uapsd
- *
- *      This function takes care processing packets of Unscheduled Service Period,
- *      which been suspended earlier due to DTIM/HIP ENOSPC scenarios
- *
- *  Arguments:
- *      priv            Pointer to device private context struct
- *      interfaceTag    For which resume should happen
- * ---------------------------------------------------------------------------
- */
-void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag)
-{
-
-   u8 startIndex;
-   CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
-    unsigned long lock_flags;
-
-    unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n");
-    for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
-        staInfo =  CsrWifiRouterCtrlGetStationRecordFromHandle(priv, startIndex, interfaceTag);
-
-        if(!staInfo || !staInfo->wmmOrQosEnabled) {
-            continue;
-        } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
-                   &&staInfo->uapsdActive && staInfo->uspSuspend) {
-            /* U-APSD Still active & previously suspended either ENOSPC of FH queues OR
-             * due to DTIM activity
-             */
-            uf_handle_uspframes_delivery(priv, staInfo, interfaceTag);
-        } else {
-            unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n",
-                        staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend);
-            if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
-            {
-                spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
-                staInfo->uapsdActive = FALSE;
-                staInfo->uspSuspend = FALSE;
-                spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
-            }
-        }
-    }
-    unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n");
-}
-
-#endif
diff --git a/drivers/staging/csr/unifi_priv.h b/drivers/staging/csr/unifi_priv.h
deleted file mode 100644 (file)
index 37302f3..0000000
+++ /dev/null
@@ -1,1136 +0,0 @@
-/*
- *****************************************************************************
- *
- * FILE : unifi_priv.h
- *
- * PURPOSE : Private header file for unifi driver.
- *
- *           UDI = UniFi Debug Interface
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- *****************************************************************************
- */
-#ifndef __LINUX_UNIFI_PRIV_H__
-#define __LINUX_UNIFI_PRIV_H__ 1
-
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/wireless.h>
-#include <linux/cdev.h>
-#include <linux/kthread.h>
-#include <linux/freezer.h>
-
-#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
-#include <linux/mmc/core.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/sdio.h>
-#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
-
-#include <linux/fs.h>
-
-#ifdef ANDROID_BUILD
-#include <linux/wakelock.h>
-#endif
-
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_unifi_udi.h"
-#include "csr_wifi_router_lib.h"
-#include "unifiio.h"
-#ifndef CSR_WIFI_HIP_TA_DISABLE
-#include "csr_wifi_vif_utils.h"
-#endif
-
-/* Define the unifi_priv_t before include the unifi_native.h */
-struct unifi_priv;
-typedef struct unifi_priv unifi_priv_t;
-#ifdef CSR_SUPPORT_WEXT_AP
-struct CsrWifiSmeApConfig;
-typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
-#endif
-#ifdef CSR_SUPPORT_WEXT
-#include "unifi_wext.h"
-#endif
-
-#ifdef ANDROID_BUILD
-extern struct wake_lock unifi_sdio_wake_lock;
-#endif
-
-#include "unifi_clients.h"
-
-#ifdef CSR_NATIVE_LINUX
-#include "sme_native/unifi_native.h"
-#else
-#include "unifi_sme.h"
-#endif
-
-/* The device major number to use when registering the udi driver */
-#define UNIFI_NAME      "unifi"
-/*
- * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present.
- * This number should be set to the number of SDIO slots supported by the SDIO
- * host controller on the platform.
- * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c
- */
-#define MAX_UNIFI_DEVS  2
-
-/* 802.11 Mac header offsets */
-#define MAC_HEADER_SIZE  24
-#define QOS_CONTROL_HEADER_SIZE 2
-#define HT_CONTROL_HEADER_SIZE  4
-#define QOS_DATA 0x8
-#define QOS_DATA_NULL 0xc
-#define DATA_NULL 0x04
-#define FRAME_CONTROL_ORDER_BIT 0x8000
-#define FRAME_CONTROL_TYPE_FIELD_OFFSET  2
-#define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET  4
-#define IEEE802_11_FRAMETYPE_DATA 0x02
-#define IEEE802_11_FRAMETYPE_CONTROL 0x01
-#define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
-#define IEEE802_11_FRAMETYPE_RESERVED 0x03
-
-/* octet offset from start of mac header for certain fields */
-#define IEEE802_11_ADDR3_OFFSET 16
-#define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
-#define IEEE802_11_MAX_DATA_LEN 2304
-
-/* frame control (FC) masks, for frame control as 16 bit integer */
-#define IEEE802_11_FC_TO_DS_MASK 0x100
-#define IEEE802_11_FC_FROM_DS_MASK 0x200
-#define IEEE802_11_FC_MOREDATA_MASK 0x2000
-#define IEEE802_11_FC_PROTECTED_MASK 0x4000
-#define IEEE80211_FC_ORDER_MASK 0x8000
-#define IEEE80211_FC_SUBTYPE_MASK 0x00f0
-#define IEEE80211_FC_TYPE_MASK 0x000c
-#define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
-
-/*  selected type and subtype combinations as in 7.1.3.1 table 1
-    For frame control as 16 bit integer, or for ls octet
-*/
-#define IEEE802_11_FC_TYPE_DATA 0x08
-#define IEEE802_11_FC_TYPE_NULL 0x48
-#define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
-#define IEEE802_11_FC_TYPE_QOS_DATA 0x88
-
-#define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
-
-/* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
-#define IEEE802_11_QC_TID_MASK 0x0f
-#define IEEE802_11_QC_A_MSDU_PRESENT 0x80
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND))
-#define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0
-#endif
-
-#define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
-#define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
-#define MAX_ACCESS_CATOGORY 4
-
-/* Time in us to check for inactivity of stations 5 mins */
-#define INACTIVITY_CHECK_INTERVAL   300000000
-/* Time in us before a station is flagged as inactive */
-#define MAX_INACTIVITY_INTERVAL     300000000
-
-
-/* Define for maximum BA session */
-#define MAX_SUPPORTED_BA_SESSIONS_TX   1
-#define MAX_SUPPORTED_BA_SESSIONS_RX   4
-
-#define MAX_BA_WIND_SIZE 64
-#define MAC_HEADER_ADDR1_OFFSET     4
-#define MAC_HEADER_ADDR2_OFFSET     10
-
-/* Define for age (in us) value for frames in MPDU reorder buffer */
-#define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT  30000 /* 30 milli seconds */
-
-/* This macro used in prepare_and_add_macheader*/
-#define ADDRESS_ONE_OFFSET 20
-
-/* Defines for STA inactivity detection */
-#define     STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD           1                /* in number of stations */
-#define     STA_INACTIVE_DETECTION_TIMER_INTERVAL              30               /* in seconds */
-#define     STA_INACTIVE_TIMEOUT_VAL                           120*1000*1000    /* 120 seconds */
-
-/* Test for modes requiring AP firmware patch */
-#define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \
-                                      ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE)
-
-/* Defines used in beacon filtering in case of P2P */
-#define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH        0x7
-#define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON      0x8
-#define CSR_WIFI_BEACON_FIXED_LENGTH             12
-#define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET        4
-#define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK    ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
-
-#define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
-    ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
-
-/* For M4 request received via netdev*/
-
-typedef u8 CsrWifiPacketType;
-#define CSR_WIFI_UNICAST_PDU   ((CsrWifiPacketType) 0x00)
-#define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
-#define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
-
-#define PRIO_TO_NICE(prio)  ((prio) - MAX_RT_PRIO - 20)
-
-/* Module parameter variables */
-extern int buswidth;
-extern int sdio_clock;
-extern int use_5g;
-extern int disable_hw_reset;
-extern int disable_power_control;
-extern int enable_wol;
-extern int sme_debug;
-extern int fw_init[MAX_UNIFI_DEVS];
-extern int tl_80211d;
-extern int sdio_byte_mode;
-extern int sdio_block_size;
-extern int coredump_max;
-extern int run_bh_once;
-extern int bh_priority;
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-extern int log_hip_signals;
-#endif
-
-struct dlpriv {
-    const unsigned char *dl_data;
-    int dl_len;
-    void *fw_desc;
-};
-
-
-struct uf_thread {
-
-    struct task_struct *thread_task;
-
-    /* wait_queue for waking the unifi_thread kernel thread */
-    wait_queue_head_t wakeup_q;
-    unsigned int wakeup_flag;
-
-    /*
-     * Use it to block the I/O thread when
-     * an error occurs or UniFi is reinitialised.
-     */
-    int block_thread;
-
-    char name[16];
-    int prio;
-};
-
-/*
- * Link list to hold the received packets for the period the port
- * remains closed.
- */
-typedef struct rx_buffered_packets {
-    /* List link structure */
-    struct list_head q;
-    /* Packet to indicate when the port reopens */
-    struct sk_buff *skb;
-    /* Bulkdata to free in case the port closes and need to discard the packet */
-    bulk_data_param_t bulkdata;
-    /* The source address of the packet */
-    CsrWifiMacAddress sa;
-    /* The destination address of the packet */
-    CsrWifiMacAddress da;
-    /* Corresponding signal */
-    CSR_SIGNAL signal;
-} rx_buffered_packets_t;
-
-
-typedef u8 CsrWifiAcPowersaveMode;
-#define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
-#define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
-#define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
-#define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
-
-
-#define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
-#define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
-#define IS_DTIM_ACTIVE(flag, hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
-#define INVALID_HOST_TAG 0xFFFFFFFF
-#define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
-
-
-
-
-/* Queue to be used for contention priority */
-
-/*
- * Link list to hold the tx packets for the period the peer
- * powersave/free slots in unifi
- */
-typedef struct tx_buffered_packets {
-    /* List link structure */
-    struct list_head q;
-    u16 interfaceTag;
-    CSR_CLIENT_TAG hostTag;
-    CSR_PROCESS_ID leSenderProcessId;
-    CSR_TRANSMISSION_CONTROL transmissionControl;
-    CSR_RATE rate;
-    /* Bulkdata to free in case the port closes and need to discard the packet */
-    bulk_data_desc_t bulkdata;
-    /* The source address of the packet */
-    CsrWifiMacAddress peerMacAddress;
-    CSR_PRIORITY priority;
-} tx_buffered_packets_t;
-
-/* station record has this data structure */
-typedef struct CsrWifiRouterCtrlStaInfo_t {
-
-    /* Sme sends these parameters */
-    CsrWifiMacAddress peerMacAddress;
-    u32 assignedHandle;
-    u8 wmmOrQosEnabled;
-    CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
-    u16 maxSpLength;
-    u8 uapsdActive;
-    u16 noOfSpFramesSent;
-
-    /* Router/Driver database */
-#ifdef CSR_SUPPORT_SME
-    unifi_port_cfg_t *peerControlledPort;
-    unifi_port_cfg_t *peerUnControlledPort;
-
-    /* Inactivity feature parameters */
-    struct netInterface_priv *interfacePriv;
-    struct work_struct send_disconnected_ind_task;
-    u8 activity_flag;
-    u16 listenIntervalInTus;
-    CSR_CLIENT_TAG nullDataHostTag;
-
-    /* Activity timestamps for the station */
-    u32 lastActivity;
-
-    /* during m/c transmission sp suspended */
-    u8 uspSuspend;
-    CSR_PRIORITY triggerFramePriority;
-#endif
-    CsrWifiRouterCtrlPeerStatus currentPeerState;
-    struct list_head dataPdu[MAX_ACCESS_CATOGORY];
-    struct list_head mgtFrames;
-    u8 spStatus;
-    u8 prevFrmType;
-    u8 prevFrmAccessCatogory;
-    u8 protection;
-    u16 aid;
-    u8 txSuspend;
-    u8 timSet;
-    /* Dont change the value of below macro for SET & RESET */
-#define CSR_WIFI_TIM_RESET       0
-#define CSR_WIFI_TIM_SET         1
-#define CSR_WIFI_TIM_RESETTING   2
-#define CSR_WIFI_TIM_SETTING     3
-
-    u8 timRequestPendingFlag;
-    u8 updateTimReqQueued;
-    u16 noOfPktQueued;
-}CsrWifiRouterCtrlStaInfo_t;
-
-#ifdef CSR_SUPPORT_WEXT_AP
-struct CsrWifiSmeApConfig {
-    CsrWifiSsid ssid;
-    u16 channel;
-    CsrWifiNmeApCredentials credentials;
-    u8 max_connections;
-    u8 if_index;
-};
-#endif
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-/* This is a test code and may be removed later*/
-#define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE    (60+1)
-
-typedef struct
-{
-    u8 *bufptr; /* Signal Primitive */
-    bulk_data_param_t data_ptrs; /* Bulk Data pointers */
-    u16 sig_len;
-}rx_buff_struct_t;
-
-typedef struct
-{
-    u8 writePointer; /**< write pointer */
-    u8 readPointer;  /**< read pointer */
-    u8 size;         /**< size of circular buffer */
-    rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE];    /**< Element of ciruclar buffer */
-} rxCircularBuffer_t;
-
-void rx_wq_handler(struct work_struct *work);
-#endif
-
-struct unifi_priv {
-
-    card_t *card;
-    CsrSdioFunction *sdio;
-
-    /* Index into Unifi_instances[] for this device. */
-    int instance;
-    /* Reference count for this instance */
-    int ref_count;
-
-    /* Firmware images */
-    struct dlpriv fw_sta;
-    struct dlpriv fw_conv;  /* used for conversion of production test image */
-
-    /* Char device related structures */
-    struct cdev unifi_cdev;
-    struct cdev unifiudi_cdev;
-    struct device *unifi_device;
-
-    /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
-    CSR_IFINTERFACE if_index;
-
-    /* For multiple interface support */
-    struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
-    struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
-
-    u8 totalInterfaceCount;
-
-    int prev_queue;
-
-    /* Name of node under /proc */
-    char proc_entry_name[64];
-
-    /*
-     * Flags:
-     *  drop_unencrypted
-     *                - Not used?
-     *  netdev_registered
-     *                - whether the netdev has been registered.
-     */
-    unsigned int drop_unencrypted       : 1;
-
-    /* Our list of unifi linux clients. */
-    ul_client_t ul_clients[MAX_UDI_CLIENTS];
-
-    /* Mutex to protect using the logging hook after UDI client is gone */
-    struct semaphore udi_logging_mutex;
-    /* Pointer to the ul_clients[] array */
-    ul_client_t *logging_client;
-
-    /* A ul_client_t* used to send the netdev related MIB requests. */
-    ul_client_t *netdev_client;
-
-    /* The SME ul_client_t pointer. */
-    ul_client_t *sme_cli;
-
-    /* The AMP ul_client_t pointer. */
-    ul_client_t *amp_client;
-
-    /*
-     * Semaphore for locking the top-half to one user process.
-     * This is necessary to prevent multiple processes calling driver
-     * operations. This can happen because the network driver entry points
-     * can be called from multiple processes.
-     */
-#ifdef USE_DRIVER_LOCK
-    struct semaphore lock;
-#endif /* USE_DRIVER_LOCK */
-
-    /* Flag to say that an operation was aborted */
-    int io_aborted;
-
-    struct uf_thread bh_thread;
-
-#define UNIFI_INIT_NONE         0x00
-#define UNIFI_INIT_IN_PROGRESS  0x01
-#define UNIFI_INIT_FW_DOWNLOADED 0x02
-#define UNIFI_INIT_COMPLETED    0x04
-    unsigned char init_progress;
-
-    int sme_is_present;
-
-    /* The WMM features that UniFi uses in the current BSS */
-    unsigned int sta_wmm_capabilities;
-
-    /* Debug only */
-    char last_debug_string[256];
-    unsigned short last_debug_word16[16];
-
-#ifdef CSR_SUPPORT_SME
-  /* lock to protect the tx queues list */
-    spinlock_t tx_q_lock;
-    u8 allPeerDozing;
-    u8 pausedStaHandle[MAX_ACCESS_CATOGORY];
-    /* Max packet the driver can queue, irrespective of interface number */
-    u16 noOfPktQueuedInDriver;
-#define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
-#define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
-#define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
-
-    u8 routerBufferEnable[MAX_ACCESS_CATOGORY];
-    /* lock to protect stainfo members and priv members*/
-    spinlock_t staRecord_lock;
-#endif
-#ifdef CSR_NATIVE_LINUX
-#ifdef CSR_SUPPORT_WEXT
-    /* wireless config */
-    struct wext_config wext_conf;
-#endif
-
-    /* Mutex to protect the MLME blocking requests */
-    struct semaphore mlme_blocking_mutex;
-
-    /* The ul_client that provides the blocking API for WEXT calls */
-    ul_client_t *wext_client;
-
-#endif /* CSR_NATIVE_LINUX */
-
-#ifdef CSR_SUPPORT_SME
-    wait_queue_head_t sme_request_wq;
-    /* Semaphore to protect the SME blocking requests */
-    struct semaphore sme_sem;
-    /* Structure to hold the SME blocking requests data*/
-    sme_reply_t sme_reply;
-
-    /* Structure to hold a traffic protocol indication */
-    struct ta_ind {
-        struct work_struct task;
-        CsrWifiRouterCtrlTrafficPacketType packet_type;
-        CsrWifiRouterCtrlProtocolDirection direction;
-        CsrWifiMacAddress src_addr;
-        int in_use;
-    } ta_ind_work;
-
-    struct ta_sample_ind {
-        struct work_struct task;
-        CsrWifiRouterCtrlTrafficStats stats;
-        int in_use;
-    } ta_sample_ind_work;
-
-    __be32 sta_ip_address;
-    CsrWifiRouterCtrlSmeVersions    sme_versions;
-
-    /*
-     * Flag to reflect state of unifi_sys_wifi_on_*() progress.
-     * This indicates whether we are in an "wifi on" state when we are
-     * allowed to indication errors with unifi_mgt_wifi_off_ind()
-     */
-    enum {
-        wifi_on_unspecified = -1,
-        wifi_on_in_progress = 0,
-        wifi_on_done = 1,
-    } wifi_on_state;
-
-    /* Userspace TaskId for the SME Set when a wifi on req is received */
-    CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
-
-    struct work_struct multicast_list_task;
-    /*
-     * The SME installs filters to ask for specific MA-UNITDATA.req
-     * to be passed to different SME components.
-     */
-#define MAX_MA_UNIDATA_IND_FILTERS      8
-    sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
-
-/* UNIFI_CFG related parameters */
-    uf_cfg_bcast_packet_filter_t packet_filters;
-    unsigned char *filter_tclas_ies;
- /* The structure that holds all the connection configuration. */
-    CsrWifiSmeConnectionConfig connection_config;
-#ifdef CSR_SUPPORT_WEXT
-
-    int ignore_bssid_join;
-    struct iw_statistics wext_wireless_stats;
-
-    /* The MIB and MAC address files contents, read from userspace */
-    CsrWifiSmeDataBlock mib_data;
-    CsrWifiMacAddress sta_mac_address;
-
-    int wep_tx_key_index;
-    wep_key_t wep_keys[NUM_WEPKEYS];
-
-
-#ifdef CSR_SUPPORT_WEXT_AP
-    CsrWifiSmeApMacConfig ap_mac_config;
-    CsrWifiNmeApConfig group_sec_config;
-    CsrWifiSmeApConfig_t ap_config;
-#endif
-    struct work_struct sme_config_task;
-
-#endif /* CSR_SUPPORT_WEXT */
-
-#endif /* CSR_SUPPORT_SME */
-
-#ifdef CSR_SME_USERSPACE
-    void *smepriv;
-#endif /* CSR_SME_USERSPACE */
-
-    card_info_t card_info;
-
-    /* Mutex to protect unifi_send_signal() */
-    spinlock_t send_signal_lock;
-
-
-    /*
-     * The workqueue to offload the TA run
-     * and the multicast addresses list set
-     */
-    struct workqueue_struct *unifi_workqueue;
-
-    unsigned char *mib_cfm_buffer;
-    unsigned int mib_cfm_buffer_length;
-
-    int ptest_mode;     /* Set when in production test mode */
-    int coredump_mode;  /* Set when SME has requested a coredump */
-    u8 wol_suspend; /* Set when suspending with UniFi powered */
-
-#define UF_UNCONTROLLED_PORT_Q      0
-#define UF_CONTROLLED_PORT_Q        1
-
-    /* Semaphore to protect the rx queues list */
-    struct semaphore rx_q_sem;
-
-    /* Spinlock to protect M4 data */
-    spinlock_t m4_lock;
-    /* Mutex to protect BA RX data */
-    struct semaphore ba_mutex;
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-    /* Spinlock to protect the WAPI data */
-    spinlock_t wapi_lock;
-#endif
-
-    /* Array to indicate if a particular Tx queue is paused, this may not be
-     * required in a multiqueue implementation since we can directly stop kernel
-     * queues */
-    u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
-
-#ifdef CSR_WIFI_RX_PATH_SPLIT
-    struct workqueue_struct *rx_workqueue;
-    struct work_struct rx_work_struct;
-    rxCircularBuffer_t rxSignalBuffer;
-
-#endif
-
-    u32 rxTcpThroughput;
-    u32 txTcpThroughput;
-    u32 rxUdpThroughput;
-    u32 txUdpThroughput;
-
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    /*Set if multicast KeyID = 1*/
-    u8 wapi_multicast_filter;
-    /*Set if unicast KeyID = 1*/
-    u8 wapi_unicast_filter;
-    u8 wapi_unicast_queued_pkt_filter;
-#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
-    u8  isWapiConnection;
-#endif
-#endif
-
-#ifdef CSR_WIFI_SPLIT_PATCH
-    CsrWifiRouterCtrlModeSetReq pending_mode_set;
-#endif
-
-    u8 cmanrTestMode;
-    CSR_RATE cmanrTestModeTransmitRate;
-
-};
-
-typedef struct {
-    u16 queue_length[4];
-    u8 os_queue_paused;
-} unifi_OsQosInfo;
-
-
-typedef struct {
-    u8 active;
-    bulk_data_param_t bulkdata;
-    CSR_SIGNAL signal;
-    u16 sn;
-    u32 recv_time;
-} frame_desc_struct;
-
-typedef struct {
-    frame_desc_struct *buffer;
-    u16 wind_size;
-    u16 occupied_slots;
-    struct timer_list timer;
-    u16 timeout;
-    u16 expected_sn;
-    u16 start_sn;
-    u8   trigger_ba_after_ssn;
-    struct netInterface_priv *interfacePriv;
-    u16 tID;
-    CsrWifiMacAddress macAddress;
-    struct work_struct send_ba_err_task;
-} ba_session_rx_struct;
-
-
-typedef struct {
-    struct netInterface_priv *interfacePriv;
-    u16 tID;
-    CsrWifiMacAddress macAddress;
-} ba_session_tx_struct;
-
-typedef struct netInterface_priv
-{
-    u16 InterfaceTag;
-    struct unifi_priv *privPtr;
-    ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
-    ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
-    frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
-    u8 ba_complete_index;
-    u8 queueEnabled[UNIFI_NO_OF_TX_QS];
-    struct work_struct send_m4_ready_task;
-#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
-    struct work_struct send_pkt_to_encrypt;
-#endif
-    struct net_device_stats stats;
-    u8 interfaceMode;
-    u8 protect;
-    CsrWifiMacAddress bssid;
-    /*
-    * Flag to reflect state of CONNECTED indication signal.
-    * This indicates whether we are "joined" an Access Point (i.e. have
-    * nominated an AP and are receiving beacons) but give no indication
-    * of whether we are authenticated and/or associated.
-    */
-    enum {
-        UnifiConnectedUnknown = -1,
-        UnifiNotConnected = 0,
-        UnifiConnected = 1,
-    } connected;
-#ifdef CSR_SUPPORT_WEXT
-    /* Tracks when we are waiting for a netdevice state change callback */
-    u8 wait_netdev_change;
-    /* True if we have successfully registered for netdev callbacks */
-    u8 netdev_callback_registered;
-#endif /* CSR_SUPPORT_WEXT */
-    unsigned int netdev_registered;
-#define UNIFI_MAX_MULTICAST_ADDRESSES 10
-    /* The multicast addresses list that the thread needs to set. */
-    u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
-    /* The multicast addresses count that the thread needs to set. */
-    int mc_list_count;
-    u32 tag;
-#ifdef CSR_SUPPORT_SME
-    /* (un)controlled port configuration */
-    unifi_port_config_t controlled_data_port;
-    unifi_port_config_t uncontrolled_data_port;
-
-    /* station record maintenance related data structures */
-    u8 num_stations_joined;
-    CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
-    struct list_head genericMgtFrames;
-    struct list_head genericMulticastOrBroadCastFrames;
-    struct list_head genericMulticastOrBroadCastMgtFrames;
-
-    /* Timer for detecting station inactivity */
-    struct timer_list sta_activity_check_timer;
-    u8 sta_activity_check_enabled;
-
-    /* Timestamp when the last inactivity check was done */
-    u32 last_inactivity_check;
-
-    /*number of multicast or borad cast packets  queued*/
-    u16 noOfbroadcastPktQueued;
-#endif
-    /* A list to hold the buffered uncontrolled port packets */
-    struct list_head rx_uncontrolled_list;
-    /* A list to hold the buffered controlled port packets */
-    struct list_head rx_controlled_list;
-    /* Buffered M4 signal to take care of WPA race condition */
-    CSR_SIGNAL m4_signal;
-    bulk_data_desc_t m4_bulk_data;
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-    /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */
-    CSR_SIGNAL wapi_unicast_ma_pkt_sig;
-    bulk_data_desc_t wapi_unicast_bulk_data;
-#endif
-
-    /* This should be removed and m4_hostTag should be used for checking*/
-    u8 m4_sent;
-    CSR_CLIENT_TAG m4_hostTag;
-    u8 dtimActive;
-    u8 intraBssEnabled;
-    u32 multicastPduHostTag; /* Used to set the tim after getting
-       a confirm for it */
-    u8 bcTimSet;
-    u8 bcTimSetReqPendingFlag;
-    u8 bcTimSetReqQueued;
-} netInterface_priv_t;
-
-#ifdef CSR_SUPPORT_SME
-#define routerStartBuffering(priv, queue) priv->routerBufferEnable[(queue)] = TRUE;
-#define routerStopBuffering(priv, queue) priv->routerBufferEnable[(queue)]  = FALSE;
-#define isRouterBufferEnabled(priv, queue) priv->routerBufferEnable[(queue)]
-#endif
-
-#ifdef USE_DRIVER_LOCK
-#define LOCK_DRIVER(_p)         down_interruptible(&(_p)->lock)
-#define UNLOCK_DRIVER(_p)       up(&(_p)->lock)
-#else
-#define LOCK_DRIVER(_p)         (void)(_p); /* as nothing */
-#define UNLOCK_DRIVER(_p)       (void)(_p); /* as nothing */
-#endif /* USE_DRIVER_LOCK */
-
-s32 CsrHipResultToStatus(CsrResult csrResult);
-
-
-/*
- * SDIO related functions and callbacks
- */
-int  uf_sdio_load(void);
-void uf_sdio_unload(void);
-unifi_priv_t *uf_find_instance(int inst);
-int uf_find_priv(unifi_priv_t *priv);
-int uf_find_netdev_priv(netInterface_priv_t *priv);
-unifi_priv_t *uf_get_instance(int inst);
-void uf_put_instance(int inst);
-int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
-int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
-
-void uf_add_os_device(int bus_id, struct device *os_device);
-void uf_remove_os_device(int bus_id);
-
-
-
-/*
- * Claim/release SDIO
- *
- * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
- * as this prevents other functions using SDIO.
- * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
- * we have followed this scheme:
- * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
- *    then we call CsrSdioClaim/CsrSdioRelease().
- * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
- *    then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
- *    to the SDIO glue layer only (e.g. sdio_mmc.c).
- * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
- *    then we call directly the sdio_claim_host/sdio_release_host().
- *    Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
- *
- * Note: The _func and function pointers are _not_ the same.
- * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
- * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
- */
-
-#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
-
-#ifdef CSR_WIFI_SINGLE_FUNCTION
-#define CsrSdioClaim(function)    sdio_claim_host((function)->priv);
-#define CsrSdioRelease(function)  sdio_release_host((function)->priv);
-
-#define _sdio_claim_host(_func)
-#define _sdio_release_host(_func)
-
-#else
-#define CsrSdioClaim(function)
-#define CsrSdioRelease(function)
-
-#define _sdio_claim_host(_func)     sdio_claim_host(_func)
-#define _sdio_release_host(_func)   sdio_release_host(_func)
-
-#endif /* CSR_WIFI_SINGLE_FUNCTION */
-
-#else
-#define _sdio_claim_host(_func)
-#define _sdio_release_host(_func)
-
-#define CsrSdioClaim(function)
-#define CsrSdioRelease(function)
-
-#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
-
-
-/*
- * Functions to allocate and free an ethernet device.
- */
-unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
-int uf_free_netdevice(unifi_priv_t *priv);
-
-/* Allocating function for other interfaces */
-u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag);
-
-/*
- * Firmware download related functions.
- */
-int uf_run_unifihelper(unifi_priv_t *priv);
-int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
-int uf_release_firmware_files(unifi_priv_t *priv);
-int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
-
-/*
- * Functions to create and delete the device nodes.
- */
-int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
-void uf_destroy_device_nodes(unifi_priv_t *priv);
-
-/*
- * Upper Edge Initialisation functions
- */
-int uf_init_bh(unifi_priv_t *priv);
-int uf_init_hw(unifi_priv_t *priv);
-
-/* Thread related helper functions */
-int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
-void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
-void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
-
-
-/*
- * Unifi Linux functions
- */
-void ul_init_clients(unifi_priv_t *priv);
-
-/* Configuration flags */
-#define CLI_USING_WIRE_FORMAT   0x0002
-#define CLI_SME_USERSPACE       0x0020
-ul_client_t *ul_register_client(unifi_priv_t *priv,
-        unsigned int configuration,
-        udi_event_t udi_event_clbk);
-int ul_deregister_client(ul_client_t *pcli);
-
-int ul_send_signal_unpacked(unifi_priv_t *priv,
-                            CSR_SIGNAL *sigptr,
-                            bulk_data_param_t *bulkdata);
-int ul_send_signal_raw(unifi_priv_t *priv,
-                       unsigned char *sigptr, int siglen,
-                       bulk_data_param_t *bulkdata);
-
-void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
-
-
-/*
- * Data plane operations
- */
-/*
- *      data_tx.c
- */
-int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
-        unsigned int length);
-
-#ifdef CSR_SUPPORT_SME
-u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
-u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo, u8 pmBit, u16 interfaceTag);
-void uf_process_ps_poll(unifi_priv_t *priv, u8* sa, u8* da, u8 pmBit, u16 interfaceTag);
-int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
-                   struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
-                   const CSR_SIGNAL *signal,
-                   bulk_data_param_t *bulkdata,
-                   u8 macHeaderLengthInBytes);
-u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
-void uf_process_wmm_deliver_ac_uapsd (  unifi_priv_t * priv,
-                                        CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
-                                        u16 qosControl,
-                                        u16 interfaceTag);
-
-void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
-void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
-
-void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
-void uf_send_qos_null(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
-void uf_send_nulldata(unifi_priv_t * priv, u16 interfaceTag, const u8 *da, CSR_PRIORITY priority, CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
-
-
-
-#endif
-CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,  u8 *peerMacAddress, CSR_CLIENT_TAG hostTag, u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, CSR_RATE TransmitRate, CSR_PRIORITY priority, CSR_PROCESS_ID senderId, bulk_data_param_t *bulkdata);
-void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv, u8 *sigdata, u32 siglen);
-#ifdef CSR_SUPPORT_SME
-void uf_send_buffered_frames(unifi_priv_t *priv, unifi_TrafficQueue queue);
-int uf_process_station_records_for_sending_data(unifi_priv_t *priv, u16 interfaceTag,
-                                                 CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
-                                                 CsrWifiRouterCtrlStaInfo_t *dstStaInfo);
-void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
-                                                 struct list_head *frames_need_cfm_list,
-                                                 struct list_head * list);
-void send_auto_ma_packet_confirm(unifi_priv_t *priv,
-                                 netInterface_priv_t *interfacePriv,
-                                 struct list_head *buffered_frames_list);
-void uf_flush_list(unifi_priv_t * priv, struct list_head * list);
-tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList);
-void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag);
-void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv, u16 interfaceTag);
-void resume_suspended_uapsd(unifi_priv_t* priv, u16 interfaceTag);
-#endif
-/*
- *      netdev.c
- */
-
-#ifndef P80211_OUI_LEN
-#define P80211_OUI_LEN  3
-#endif
-typedef struct {
-    u8    dsap;   /* always 0xAA */
-    u8    ssap;   /* always 0xAA */
-    u8    ctrl;   /* always 0x03 */
-    u8    oui[P80211_OUI_LEN];    /* organizational universal id */
-    u16 protocol;
-} __attribute__ ((packed)) llc_snap_hdr_t;
-int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto);
-int skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
-        const unsigned char *daddr, const unsigned char *saddr,
-        const CSR_SIGNAL *signal,
-        bulk_data_param_t *bulkdata);
-
-const char *result_code_str(int result);
-
-
-/* prepares & appends the Mac header for the payload */
-int prepare_and_add_macheader(unifi_priv_t *priv,
-                              struct sk_buff *skb,
-                              struct sk_buff *newSkb,
-                              CSR_PRIORITY priority,
-                              bulk_data_param_t *bulkdata,
-                              u16 interfaceTag,
-                              const u8 *daddr,
-                              const u8 *saddr,
-                              u8 protection);
-CSR_PRIORITY
-get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
-
-void
-unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
-                          CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
-                          u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
-                          CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
-                          CSR_SIGNAL *signal);
-
-
-/* Pack the LSB to include station handle & status of tim set */
-#define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState)  ((handle << 2) | timState)
-/* get the station record handle from the sender ID */
-#define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
-/* get the timSet status from the sender ID */
-#define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId)  (u8) (receiverProcessId & 0x03)
-
-/* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */
-#define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
-
-void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle);
-void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId);
-
-/* Clear the Peer station Record, in case of wifioff/unexpected card removal */
-void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
-
-void scroll_ba_window(unifi_priv_t *priv,
-                      netInterface_priv_t *interfacePriv,
-                      ba_session_rx_struct *ba_session,
-                      u16 sn);
-
-u8 blockack_session_stop(unifi_priv_t *priv,
-                              u16 interfaceTag,
-                              CsrWifiRouterCtrlBlockAckRole role,
-                              u16 tID,
-                              CsrWifiMacAddress macAddress);
-#ifdef CSR_SUPPORT_SME
-/* Fetch the protection information from interface Mode */
-s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr);
-#endif
-
-/* Fetch the station record handler from data base for matching Mac address */
-#ifdef CSR_SUPPORT_SME
-CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
-                                                                                const u8 *peerMacAddress,
-                                                                                u16 interfaceTag);
-
-/* Fetch the station record handler from data base for matching handle */
-CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
-                                                                 u32 handle,
-                                                                 u16 interfaceTag);
-
-void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress);
-void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv, u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
-#endif
-
-void uf_resume_data_plane(unifi_priv_t *priv, int queue,
-                          CsrWifiMacAddress peer_address,
-                          u16 interfaceTag);
-void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
-        CsrWifiMacAddress peer_address, u16 interfaceTag);
-
-int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
-void uf_unregister_netdev(unifi_priv_t *priv);
-
-void uf_net_get_name(struct net_device *dev, char *name, int len);
-
-void uf_send_queue_info(unifi_priv_t *priv);
-u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag);
-
-void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
-                                 CsrWifiMacAddress source_address,
-                                 int indicate, u16 interfaceTag);
-
-#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
-int uf_register_hip_offline_debug(unifi_priv_t *priv);
-int uf_unregister_hip_offline_debug(unifi_priv_t *priv);
-#endif
-
-/*
- *      inet.c
- */
-void uf_register_inet_notifier(void);
-void uf_unregister_inet_notifier(void);
-
-
-/*
- * Suspend / Resume handlers
- */
-void unifi_resume(void *ospriv);
-void unifi_suspend(void *ospriv);
-
-
-#define QOS_CAPABILITY_WMM_ENABLED      0x0001
-#define QOS_CAPABILITY_WMM_UAPSD        0x0002
-#define QOS_CAPABILITY_ACM_BE_ENABLED   0x0010
-#define QOS_CAPABILITY_ACM_BK_ENABLED   0x0020
-#define QOS_CAPABILITY_ACM_VI_ENABLED   0x0040
-#define QOS_CAPABILITY_ACM_VO_ENABLED   0x0080
-#define QOS_CAPABILITY_TS_BE_ENABLED    0x0100
-#define QOS_CAPABILITY_TS_BK_ENABLED    0x0200
-#define QOS_CAPABILITY_TS_VI_ENABLED    0x0400
-#define QOS_CAPABILITY_TS_VO_ENABLED    0x0800
-
-
-/* EAPOL PDUS */
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888e
-#endif
-#ifndef ETH_P_WAI
-#define ETH_P_WAI 0x88b4
-#endif
-/*
- * unifi_dbg.c
- */
-void debug_string_indication(unifi_priv_t *priv,
-        const unsigned char *extra,
-        unsigned int extralen);
-void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
-void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
-
-
-/*
- * putest.c
- */
-int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
-
-int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
-int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
-
-#endif /* __LINUX_UNIFI_PRIV_H__ */
diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c
deleted file mode 100644 (file)
index 5090882..0000000
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     unifi_sme.c
- *
- *  PURPOSE:    SME related functions.
- *
- *  Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ***************************************************************************
- */
-
-#include "unifi_priv.h"
-#include "csr_wifi_hip_unifi.h"
-#include "csr_wifi_hip_conversions.h"
-#include <linux/sched/rt.h>
-
-
-
-    int
-convert_sme_error(CsrResult error)
-{
-    switch (error) {
-        case CSR_RESULT_SUCCESS:
-            return 0;
-        case CSR_RESULT_FAILURE:
-        case CSR_WIFI_RESULT_NOT_FOUND:
-        case CSR_WIFI_RESULT_TIMED_OUT:
-        case CSR_WIFI_RESULT_CANCELLED:
-        case CSR_WIFI_RESULT_UNAVAILABLE:
-            return -EIO;
-        case CSR_WIFI_RESULT_NO_ROOM:
-            return -EBUSY;
-        case CSR_WIFI_RESULT_INVALID_PARAMETER:
-            return -EINVAL;
-        case CSR_WIFI_RESULT_UNSUPPORTED:
-            return -EOPNOTSUPP;
-        default:
-            return -EIO;
-    }
-}
-
-
-/*
- * ---------------------------------------------------------------------------
- *  sme_log_event
- *
- *      Callback function to be registered as the SME event callback.
- *      Copies the signal content into a new udi_log_t struct and adds
- *      it to the read queue for the SME client.
- *
- *  Arguments:
- *      arg             This is the value given to unifi_add_udi_hook, in
- *                      this case a pointer to the client instance.
- *      signal          Pointer to the received signal.
- *      signal_len      Size of the signal structure in bytes.
- *      bulkdata        Pointers to any associated bulk data.
- *      dir             Direction of the signal. Zero means from host,
- *                      non-zero means to host.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-    void
-sme_log_event(ul_client_t *pcli,
-        const u8 *signal, int signal_len,
-        const bulk_data_param_t *bulkdata,
-        int dir)
-{
-    unifi_priv_t *priv;
-    CSR_SIGNAL unpacked_signal;
-    CsrWifiSmeDataBlock mlmeCommand;
-    CsrWifiSmeDataBlock dataref1;
-    CsrWifiSmeDataBlock dataref2;
-    CsrResult result = CSR_RESULT_SUCCESS;
-    int r;
-
-    /* Just a sanity check */
-    if ((signal == NULL) || (signal_len <= 0)) {
-        return;
-    }
-
-    priv = uf_find_instance(pcli->instance);
-    if (!priv) {
-        unifi_error(priv, "sme_log_event: invalid priv\n");
-        return;
-    }
-
-    if (priv->smepriv == NULL) {
-        unifi_error(priv, "sme_log_event: invalid smepriv\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG3,
-            "sme_log_event: Process signal 0x%.4X\n",
-            CSR_GET_UINT16_FROM_LITTLE_ENDIAN(signal));
-
-
-    /* If the signal is known, then do any filtering required, otherwise it pass it to the SME. */
-    r = read_unpack_signal(signal, &unpacked_signal);
-    if (r == CSR_RESULT_SUCCESS) {
-        if ((unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_STRING_INDICATION_ID) ||
-            (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_WORD16_INDICATION_ID))
-        {
-            return;
-        }
-        if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_INDICATION_ID)
-        {
-            u16 frmCtrl;
-            u8 unicastPdu = TRUE;
-            u8 *macHdrLocation;
-            u8 *raddr = NULL, *taddr = NULL;
-            CsrWifiMacAddress peerMacAddress;
-            /* Check if we need to send CsrWifiRouterCtrlMicFailureInd*/
-            CSR_MA_PACKET_INDICATION *ind = &unpacked_signal.u.MaPacketIndication;
-
-            macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
-            /* Fetch the frame control value from  mac header */
-            frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
-
-            /* Point to the addresses */
-            raddr = macHdrLocation + MAC_HEADER_ADDR1_OFFSET;
-            taddr = macHdrLocation + MAC_HEADER_ADDR2_OFFSET;
-
-            memcpy(peerMacAddress.a, taddr, ETH_ALEN);
-
-            if(ind->ReceptionStatus == CSR_MICHAEL_MIC_ERROR)
-            {
-                if (*raddr & 0x1)
-                    unicastPdu = FALSE;
-
-                CsrWifiRouterCtrlMicFailureIndSend (priv->CSR_WIFI_SME_IFACEQUEUE, 0,
-                        (ind->VirtualInterfaceIdentifier & 0xff), peerMacAddress,
-                        unicastPdu);
-                return;
-            }
-            else
-            {
-                if(ind->ReceptionStatus == CSR_RX_SUCCESS)
-                {
-                    u8 pmBit = (frmCtrl & 0x1000)?0x01:0x00;
-                    u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff);
-                    CsrWifiRouterCtrlStaInfo_t *srcStaInfo =  CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, taddr, interfaceTag);
-                    if((srcStaInfo != NULL) && (uf_check_broadcast_bssid(priv, bulkdata)== FALSE))
-                    {
-                        uf_process_pm_bit_for_peer(priv, srcStaInfo, pmBit, interfaceTag);
-
-                        /* Update station last activity flag */
-                        srcStaInfo->activity_flag = TRUE;
-                    }
-                }
-            }
-        }
-
-        if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_CONFIRM_ID)
-        {
-            CSR_MA_PACKET_CONFIRM *cfm = &unpacked_signal.u.MaPacketConfirm;
-            u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
-            netInterface_priv_t *interfacePriv;
-            CSR_MA_PACKET_REQUEST *req;
-            CsrWifiMacAddress peerMacAddress;
-
-            if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
-            {
-                unifi_error(priv, "Bad MA_PACKET_CONFIRM interfaceTag %d\n", interfaceTag);
-                return;
-            }
-
-            unifi_trace(priv, UDBG1, "MA-PACKET Confirm (%x, %x)\n", cfm->HostTag, cfm->TransmissionStatus);
-
-            interfacePriv = priv->interfacePriv[interfaceTag];
-#ifdef CSR_SUPPORT_SME
-            if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
-                 interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
-
-                if(cfm->HostTag == interfacePriv->multicastPduHostTag){
-                    uf_process_ma_pkt_cfm_for_ap(priv, interfaceTag, cfm);
-                }
-            }
-#endif
-
-            req = &interfacePriv->m4_signal.u.MaPacketRequest;
-
-            if(cfm->HostTag & 0x80000000)
-            {
-                if (cfm->TransmissionStatus != CSR_TX_SUCCESSFUL)
-                {
-                    result = CSR_RESULT_FAILURE;
-                }
-#ifdef CSR_SUPPORT_SME
-                memcpy(peerMacAddress.a, req->Ra.x, ETH_ALEN);
-                /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
-                if (interfacePriv->m4_sent && (cfm->HostTag == interfacePriv->m4_hostTag))
-                {
-                    unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
-                    CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
-                            interfaceTag,
-                            peerMacAddress,
-                            result);
-                    interfacePriv->m4_sent = FALSE;
-                    interfacePriv->m4_hostTag = 0xffffffff;
-                }
-#endif
-                /* If EAPOL was requested via router APIs then send cfm else ignore*/
-                if((cfm->HostTag & 0x80000000) != CSR_WIFI_EAPOL_M4_HOST_TAG) {
-                    CsrWifiRouterMaPacketCfmSend((u16)signal[2],
-                        cfm->VirtualInterfaceIdentifier,
-                        result,
-                        (cfm->HostTag & 0x3fffffff), cfm->Rate);
-                } else {
-                    unifi_trace(priv, UDBG1, "%s: M4 received from netdevice\n", __FUNCTION__);
-                }
-                return;
-            }
-        }
-    }
-
-    mlmeCommand.length = signal_len;
-    mlmeCommand.data = (u8*)signal;
-
-    dataref1.length = bulkdata->d[0].data_length;
-    if (dataref1.length > 0) {
-        dataref1.data = (u8 *) bulkdata->d[0].os_data_ptr;
-    } else
-    {
-        dataref1.data = NULL;
-    }
-
-    dataref2.length = bulkdata->d[1].data_length;
-    if (dataref2.length > 0) {
-        dataref2.data = (u8 *) bulkdata->d[1].os_data_ptr;
-    } else
-    {
-        dataref2.data = NULL;
-    }
-
-    CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, mlmeCommand.length, mlmeCommand.data,
-            dataref1.length, dataref1.data,
-            dataref2.length, dataref2.data);
-
-} /* sme_log_event() */
-
-
-/*
- * ---------------------------------------------------------------------------
- * uf_sme_port_state
- *
- *      Return the state of the controlled port.
- *
- * Arguments:
- *      priv            Pointer to device private context struct
- *      address    Pointer to the destination for tx or sender for rx address
- *      queue           Controlled or uncontrolled queue
- *
- * Returns:
- *      An unifi_ControlledPortAction value.
- * ---------------------------------------------------------------------------
- */
-CsrWifiRouterCtrlPortAction
-uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
-{
-    int i;
-    unifi_port_config_t *port;
-    netInterface_priv_t *interfacePriv;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_sme_port_state: bad interfaceTag\n");
-        return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-    }
-
-    interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if (queue == UF_CONTROLLED_PORT_Q) {
-        port = &interfacePriv->controlled_data_port;
-    } else {
-        port = &interfacePriv->uncontrolled_data_port;
-    }
-
-    if (!port->entries_in_use) {
-        unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
-        return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
-    }
-
-    /* If the port configuration is common for all destinations, return it. */
-    if (port->overide_action == UF_DATA_PORT_OVERIDE) {
-        unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
-                port->port_cfg[0].port_action);
-        return port->port_cfg[0].port_action;
-    }
-
-    unifi_trace(priv, UDBG5, "Multiple (%d) port configurations.\n", port->entries_in_use);
-
-    /* If multiple configurations exist.. */
-    for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        /* .. go through the list and match the destination address. */
-        if (port->port_cfg[i].in_use &&
-            memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
-            /* Return the desired action. */
-            return port->port_cfg[i].port_action;
-        }
-    }
-
-    /* Could not find any information, return Open. */
-    unifi_trace(priv, UDBG5, "port configuration not found, return Open.\n");
-    return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
-} /* uf_sme_port_state() */
-
-/*
- * ---------------------------------------------------------------------------
- * uf_sme_port_config_handle
- *
- *      Return the port config handle of the controlled/uncontrolled port.
- *
- * Arguments:
- *      priv            Pointer to device private context struct
- *      address    Pointer to the destination for tx or sender for rx address
- *      queue           Controlled or uncontrolled queue
- *
- * Returns:
- *      An  unifi_port_cfg_t* .
- * ---------------------------------------------------------------------------
- */
-unifi_port_cfg_t*
-uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
-{
-    int i;
-    unifi_port_config_t *port;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_sme_port_config_handle: bad interfaceTag\n");
-        return NULL;
-    }
-
-    if (queue == UF_CONTROLLED_PORT_Q) {
-        port = &interfacePriv->controlled_data_port;
-    } else {
-        port = &interfacePriv->uncontrolled_data_port;
-    }
-
-    if (!port->entries_in_use) {
-        unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
-        return NULL;
-    }
-
-    /* If the port configuration is common for all destinations, return it. */
-    if (port->overide_action == UF_DATA_PORT_OVERIDE) {
-        unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
-                port->port_cfg[0].port_action);
-        if (address) {
-            unifi_trace(priv, UDBG5, "addr[0] = %x, addr[1] = %x, addr[2] = %x, addr[3] = %x\n", address[0], address[1], address[2], address[3]);
-        }
-        return &port->port_cfg[0];
-    }
-
-    unifi_trace(priv, UDBG5, "Multiple port configurations.\n");
-
-    /* If multiple configurations exist.. */
-    for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
-        /* .. go through the list and match the destination address. */
-        if (port->port_cfg[i].in_use &&
-            memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
-            /* Return the desired action. */
-            return &port->port_cfg[i];
-        }
-    }
-
-    /* Could not find any information, return Open. */
-    unifi_trace(priv, UDBG5, "port configuration not found, returning NULL (debug).\n");
-    return NULL;
-} /* uf_sme_port_config_handle */
-
-void
-uf_multicast_list_wq(struct work_struct *work)
-{
-    unifi_priv_t *priv = container_of(work, unifi_priv_t,
-            multicast_list_task);
-    int i;
-    u16 interfaceTag = 0;
-    CsrWifiMacAddress* multicast_address_list = NULL;
-    int mc_count;
-    u8 *mc_list;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "uf_multicast_list_wq: bad interfaceTag\n");
-        return;
-    }
-
-    unifi_trace(priv, UDBG5,
-            "uf_multicast_list_wq: list count = %d\n",
-            interfacePriv->mc_list_count);
-
-    /* Flush the current list */
-    CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, CSR_WIFI_SME_LIST_ACTION_FLUSH, 0, NULL);
-
-    mc_count = interfacePriv->mc_list_count;
-    mc_list = interfacePriv->mc_list;
-    /*
-     * Allocate a new list, need to free it later
-     * in unifi_mgt_multicast_address_cfm().
-     */
-    multicast_address_list = kmalloc(mc_count * sizeof(CsrWifiMacAddress), GFP_KERNEL);
-
-    if (multicast_address_list == NULL) {
-        return;
-    }
-
-    for (i = 0; i < mc_count; i++) {
-        memcpy(multicast_address_list[i].a, mc_list, ETH_ALEN);
-        mc_list += ETH_ALEN;
-    }
-
-    if (priv->smepriv == NULL) {
-        kfree(multicast_address_list);
-        return;
-    }
-
-    CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
-            interfaceTag,
-            CSR_WIFI_SME_LIST_ACTION_ADD,
-            mc_count, multicast_address_list);
-
-    /* The SME will take a copy of the addreses*/
-    kfree(multicast_address_list);
-}
-
-
-int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg)
-{
-    unifi_cfg_power_t cfg_power;
-    int rc;
-    int wol;
-
-    if (get_user(cfg_power, (unifi_cfg_power_t*)(((unifi_cfg_command_t*)arg) + 1))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    switch (cfg_power) {
-        case UNIFI_CFG_POWER_OFF:
-            priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
-            rc = sme_sys_suspend(priv);
-            if (rc) {
-                return rc;
-            }
-            break;
-        case UNIFI_CFG_POWER_ON:
-            wol = priv->wol_suspend;
-            rc = sme_sys_resume(priv);
-            if (rc) {
-                return rc;
-            }
-            if (wol) {
-                /* Kick the BH to ensure pending transfers are handled when
-                 * a suspend happened with card powered.
-                 */
-                unifi_send_signal(priv->card, NULL, 0, NULL);
-            }
-            break;
-        default:
-            unifi_error(priv, "WIFI POWER: Unknown value.\n");
-            return -EINVAL;
-    }
-
-    return 0;
-}
-
-
-int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg)
-{
-    unifi_cfg_powersave_t cfg_power_save;
-    CsrWifiSmePowerConfig powerConfig;
-    int rc;
-
-    if (get_user(cfg_power_save, (unifi_cfg_powersave_t*)(((unifi_cfg_command_t*)arg) + 1))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    /* Get the coex info from the SME */
-    rc = sme_mgt_power_config_get(priv, &powerConfig);
-    if (rc) {
-        unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
-        return rc;
-    }
-
-    switch (cfg_power_save) {
-        case UNIFI_CFG_POWERSAVE_NONE:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
-            break;
-        case UNIFI_CFG_POWERSAVE_FAST:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
-            break;
-        case UNIFI_CFG_POWERSAVE_FULL:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
-            break;
-        case UNIFI_CFG_POWERSAVE_AUTO:
-            powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
-            break;
-        default:
-            unifi_error(priv, "POWERSAVE: Unknown value.\n");
-            return -EINVAL;
-    }
-
-    rc = sme_mgt_power_config_set(priv, &powerConfig);
-
-    if (rc) {
-        unifi_error(priv, "UNIFI_CFG: Set unifi_PowerConfigValue failed.\n");
-    }
-
-    return rc;
-}
-
-
-int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg)
-{
-    unifi_cfg_powersupply_t cfg_power_supply;
-    CsrWifiSmeHostConfig hostConfig;
-    int rc;
-
-    if (get_user(cfg_power_supply, (unifi_cfg_powersupply_t*)(((unifi_cfg_command_t*)arg) + 1))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    /* Get the coex info from the SME */
-    rc = sme_mgt_host_config_get(priv, &hostConfig);
-    if (rc) {
-        unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
-        return rc;
-    }
-
-    switch (cfg_power_supply) {
-        case UNIFI_CFG_POWERSUPPLY_MAINS:
-            hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE;
-            break;
-        case UNIFI_CFG_POWERSUPPLY_BATTERIES:
-            hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE;
-            break;
-        default:
-            unifi_error(priv, "POWERSUPPLY: Unknown value.\n");
-            return -EINVAL;
-    }
-
-    rc = sme_mgt_host_config_set(priv, &hostConfig);
-    if (rc) {
-        unifi_error(priv, "UNIFI_CFG: Set unifi_HostConfigValue failed.\n");
-    }
-
-    return rc;
-}
-
-
-int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
-{
-    unsigned char *tclas_buffer;
-    unsigned int tclas_buffer_length;
-    tclas_t *dhcp_tclas;
-    int rc;
-
-    /* Free any TCLASs previously allocated */
-    if (priv->packet_filters.tclas_ies_length) {
-        kfree(priv->filter_tclas_ies);
-        priv->filter_tclas_ies = NULL;
-    }
-
-    tclas_buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
-    if (copy_from_user(&priv->packet_filters, (void*)tclas_buffer,
-                sizeof(uf_cfg_bcast_packet_filter_t))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the filter struct\n");
-        return -EFAULT;
-    }
-
-    tclas_buffer_length = priv->packet_filters.tclas_ies_length;
-
-    /* Allocate TCLASs if necessary */
-    if (priv->packet_filters.dhcp_filter) {
-        priv->packet_filters.tclas_ies_length += sizeof(tclas_t);
-    }
-    if (priv->packet_filters.tclas_ies_length > 0) {
-        priv->filter_tclas_ies = kmalloc(priv->packet_filters.tclas_ies_length, GFP_KERNEL);
-        if (priv->filter_tclas_ies == NULL) {
-            return -ENOMEM;
-        }
-        if (tclas_buffer_length) {
-            tclas_buffer += sizeof(uf_cfg_bcast_packet_filter_t) - sizeof(unsigned char*);
-            if (copy_from_user(priv->filter_tclas_ies,
-                        tclas_buffer,
-                        tclas_buffer_length)) {
-                unifi_error(priv, "UNIFI_CFG: Failed to get the TCLAS buffer\n");
-                return -EFAULT;
-            }
-        }
-    }
-
-    if(priv->packet_filters.dhcp_filter)
-    {
-        /* Append the DHCP tclas IE */
-        dhcp_tclas = (tclas_t*)(priv->filter_tclas_ies + tclas_buffer_length);
-        memset(dhcp_tclas, 0, sizeof(tclas_t));
-        dhcp_tclas->element_id = 14;
-        dhcp_tclas->length = sizeof(tcpip_clsfr_t) + 1;
-        dhcp_tclas->user_priority = 0;
-        dhcp_tclas->tcp_ip_cls_fr.cls_fr_type = 1;
-        dhcp_tclas->tcp_ip_cls_fr.version = 4;
-        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00;
-        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44;
-        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00;
-        ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43;
-        dhcp_tclas->tcp_ip_cls_fr.protocol = 0x11;
-        dhcp_tclas->tcp_ip_cls_fr.cls_fr_mask = 0x58; //bits: 3,4,6
-    }
-
-    rc = sme_mgt_packet_filter_set(priv);
-
-    return rc;
-}
-
-
-int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg)
-{
-    u8 wmm_qos_info;
-    int rc = 0;
-
-    if (get_user(wmm_qos_info, (u8*)(((unifi_cfg_command_t*)arg) + 1))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    /* Store the value in the connection info */
-    priv->connection_config.wmmQosInfo = wmm_qos_info;
-
-    return rc;
-}
-
-
-int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
-{
-    u32 addts_tid;
-    u8 addts_ie_length;
-    u8 *addts_ie;
-    u8 *addts_params;
-    CsrWifiSmeDataBlock tspec;
-    CsrWifiSmeDataBlock tclas;
-    int rc;
-
-    addts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(addts_tid, (u32*)addts_params)) {
-        unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    addts_params += sizeof(u32);
-    if (get_user(addts_ie_length, (u8*)addts_params)) {
-        unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n",
-            addts_tid, addts_ie_length);
-
-    addts_ie = kmalloc(addts_ie_length, GFP_KERNEL);
-    if (addts_ie == NULL) {
-        unifi_error(priv,
-                "unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n",
-                addts_ie_length);
-        return -ENOMEM;
-    }
-
-    addts_params += sizeof(u8);
-    rc = copy_from_user(addts_ie, addts_params, addts_ie_length);
-    if (rc) {
-        unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n");
-        kfree(addts_ie);
-        return -EFAULT;
-    }
-
-    tspec.data = addts_ie;
-    tspec.length = addts_ie_length;
-    tclas.data = NULL;
-    tclas.length = 0;
-
-    rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_ADD, addts_tid,
-            &tspec, &tclas);
-
-    kfree(addts_ie);
-    return rc;
-}
-
-
-int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg)
-{
-    u32 delts_tid;
-    u8 *delts_params;
-    CsrWifiSmeDataBlock tspec;
-    CsrWifiSmeDataBlock tclas;
-    int rc;
-
-    delts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(delts_tid, (u32*)delts_params)) {
-        unifi_error(priv, "unifi_cfg_wmm_delts: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG4, "delts: tid = 0x%x\n", delts_tid);
-
-    tspec.data = tclas.data = NULL;
-    tspec.length = tclas.length = 0;
-
-    rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_REMOVE, delts_tid,
-            &tspec, &tclas);
-
-    return rc;
-}
-
-int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg)
-{
-    u8 strict_draft_n;
-    u8 *strict_draft_n_params;
-    int rc;
-
-    CsrWifiSmeStaConfig  staConfig;
-    CsrWifiSmeDeviceConfig  deviceConfig;
-
-    strict_draft_n_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(strict_draft_n, (u8*)strict_draft_n_params)) {
-        unifi_error(priv, "unifi_cfg_strict_draft_n: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG4, "strict_draft_n: = %s\n", ((strict_draft_n) ? "yes":"no"));
-
-    rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
-
-    if (rc) {
-        unifi_warning(priv, "unifi_cfg_strict_draft_n: Get unifi_SMEConfigValue failed.\n");
-        return -EFAULT;
-    }
-
-    deviceConfig.enableStrictDraftN = strict_draft_n;
-
-    rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
-    if (rc) {
-        unifi_warning(priv, "unifi_cfg_strict_draft_n: Set unifi_SMEConfigValue failed.\n");
-        rc = -EFAULT;
-    }
-
-    return rc;
-}
-
-
-int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg)
-{
-    u8 enable_okc;
-    u8 *enable_okc_params;
-    int rc;
-
-    CsrWifiSmeStaConfig staConfig;
-    CsrWifiSmeDeviceConfig deviceConfig;
-
-    enable_okc_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
-    if (get_user(enable_okc, (u8*)enable_okc_params)) {
-        unifi_error(priv, "unifi_cfg_enable_okc: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    unifi_trace(priv, UDBG4, "enable_okc: = %s\n", ((enable_okc) ? "yes":"no"));
-
-    rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
-    if (rc) {
-        unifi_warning(priv, "unifi_cfg_enable_okc: Get unifi_SMEConfigValue failed.\n");
-        return -EFAULT;
-    }
-
-    staConfig.enableOpportunisticKeyCaching = enable_okc;
-
-    rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
-    if (rc) {
-        unifi_warning(priv, "unifi_cfg_enable_okc: Set unifi_SMEConfigValue failed.\n");
-        rc = -EFAULT;
-    }
-
-    return rc;
-}
-
-
-int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
-{
-    unifi_cfg_get_t get_cmd;
-    char inst_name[IFNAMSIZ];
-    int rc;
-
-    if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
-        return -EFAULT;
-    }
-
-    switch (get_cmd) {
-        case UNIFI_CFG_GET_COEX:
-            {
-                CsrWifiSmeCoexInfo coexInfo;
-                /* Get the coex info from the SME */
-                rc = sme_mgt_coex_info_get(priv, &coexInfo);
-                if (rc) {
-                    unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n");
-                    return rc;
-                }
-
-                /* Copy the info to the out buffer */
-                if (copy_to_user((void*)arg,
-                            &coexInfo,
-                            sizeof(CsrWifiSmeCoexInfo))) {
-                    unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n");
-                    return -EFAULT;
-                }
-                break;
-            }
-        case UNIFI_CFG_GET_POWER_MODE:
-            {
-                CsrWifiSmePowerConfig powerConfig;
-                rc = sme_mgt_power_config_get(priv, &powerConfig);
-                if (rc) {
-                    unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
-                    return rc;
-                }
-
-                /* Copy the info to the out buffer */
-                if (copy_to_user((void*)arg,
-                            &powerConfig.powerSaveLevel,
-                            sizeof(CsrWifiSmePowerSaveLevel))) {
-                    unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n");
-                    return -EFAULT;
-                }
-                break;
-            }
-        case UNIFI_CFG_GET_POWER_SUPPLY:
-            {
-                CsrWifiSmeHostConfig hostConfig;
-                rc = sme_mgt_host_config_get(priv, &hostConfig);
-                if (rc) {
-                    unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
-                    return rc;
-                }
-
-                /* Copy the info to the out buffer */
-                if (copy_to_user((void*)arg,
-                            &hostConfig.powerMode,
-                            sizeof(CsrWifiSmeHostPowerMode))) {
-                    unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n");
-                    return -EFAULT;
-                }
-                break;
-            }
-        case UNIFI_CFG_GET_VERSIONS:
-            break;
-        case UNIFI_CFG_GET_INSTANCE:
-            {
-                u16 InterfaceId=0;
-                uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name));
-
-                /* Copy the info to the out buffer */
-                if (copy_to_user((void*)arg,
-                            &inst_name[0],
-                            sizeof(inst_name))) {
-                    unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n");
-                    return -EFAULT;
-                }
-            }
-            break;
-
-        case UNIFI_CFG_GET_AP_CONFIG:
-            {
-#ifdef CSR_SUPPORT_WEXT_AP
-                uf_cfg_ap_config_t cfg_ap_config;
-
-               memset(&cfg_ap_config, 0, sizeof(cfg_ap_config));
-                cfg_ap_config.channel = priv->ap_config.channel;
-                cfg_ap_config.beaconInterval = priv->ap_mac_config.beaconInterval;
-                cfg_ap_config.wmmEnabled = priv->ap_mac_config.wmmEnabled;
-                cfg_ap_config.dtimPeriod = priv->ap_mac_config.dtimPeriod;
-                cfg_ap_config.phySupportedBitmap = priv->ap_mac_config.phySupportedBitmap;
-                if (copy_to_user((void*)arg,
-                            &cfg_ap_config,
-                            sizeof(uf_cfg_ap_config_t))) {
-                    unifi_error(priv, "UNIFI_CFG: Failed to copy the AP configuration\n");
-                    return -EFAULT;
-                }
-#else
-                   return -EPERM;
-#endif
-            }
-            break;
-
-
-        default:
-            unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n");
-            return -EINVAL;
-    }
-
-    return 0;
-}
-#ifdef CSR_SUPPORT_WEXT_AP
-int
- uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap)
-{
-    int i=0;
-    u8 b=FALSE, g = FALSE, n = FALSE;
-    b = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_B;
-    n = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_N;
-    g = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_G;
-    if(b || g) {
-        supportedRates[i++]=0x82;
-        supportedRates[i++]=0x84;
-        supportedRates[i++]=0x8b;
-        supportedRates[i++]=0x96;
-    } else if(n) {
-        /* For some strange reasons WiFi stack needs both b and g rates*/
-        supportedRates[i++]=0x02;
-        supportedRates[i++]=0x04;
-        supportedRates[i++]=0x0b;
-        supportedRates[i++]=0x16;
-        supportedRates[i++]=0x0c;
-        supportedRates[i++]=0x12;
-        supportedRates[i++]=0x18;
-       supportedRates[i++]=0x24;
-        supportedRates[i++]=0x30;
-        supportedRates[i++]=0x48;
-        supportedRates[i++]=0x60;
-        supportedRates[i++]=0x6c;
-    }
-    if(g) {
-        if(!b) {
-            supportedRates[i++]=0x8c;
-            supportedRates[i++]=0x98;
-            supportedRates[i++]=0xb0;
-        } else {
-            supportedRates[i++]=0x0c;
-            supportedRates[i++]=0x18;
-            supportedRates[i++]=0x30;
-        }
-        supportedRates[i++]=0x48;
-        supportedRates[i++]=0x12;
-        supportedRates[i++]=0x24;
-        supportedRates[i++]=0x60;
-        supportedRates[i++]=0x6c;
-    }
-    return i;
-}
-int unifi_cfg_set_ap_config(unifi_priv_t * priv, unsigned char* arg)
-{
-    uf_cfg_ap_config_t cfg_ap_config;
-    char *buffer;
-
-    buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
-    if (copy_from_user(&cfg_ap_config, (void*)buffer,
-                sizeof(uf_cfg_ap_config_t))) {
-        unifi_error(priv, "UNIFI_CFG: Failed to get the ap config struct\n");
-        return -EFAULT;
-    }
-    priv->ap_config.channel = cfg_ap_config.channel;
-    priv->ap_mac_config.dtimPeriod = cfg_ap_config.dtimPeriod;
-    priv->ap_mac_config.beaconInterval = cfg_ap_config.beaconInterval;
-    priv->group_sec_config.apGroupkeyTimeout = cfg_ap_config.groupkeyTimeout;
-    priv->group_sec_config.apStrictGtkRekey = cfg_ap_config.strictGtkRekeyEnabled;
-    priv->group_sec_config.apGmkTimeout = cfg_ap_config.gmkTimeout;
-    priv->group_sec_config.apResponseTimeout = cfg_ap_config.responseTimeout;
-    priv->group_sec_config.apRetransLimit = cfg_ap_config.retransLimit;
-
-    priv->ap_mac_config.shortSlotTimeEnabled = cfg_ap_config.shortSlotTimeEnabled;
-    priv->ap_mac_config.ctsProtectionType=cfg_ap_config.ctsProtectionType;
-
-    priv->ap_mac_config.wmmEnabled = cfg_ap_config.wmmEnabled;
-
-    priv->ap_mac_config.apHtParams.rxStbc=cfg_ap_config.rxStbc;
-    priv->ap_mac_config.apHtParams.rifsModeAllowed=cfg_ap_config.rifsModeAllowed;
-
-    priv->ap_mac_config.phySupportedBitmap = cfg_ap_config.phySupportedBitmap;
-    priv->ap_mac_config.maxListenInterval=cfg_ap_config.maxListenInterval;
-
-    priv->ap_mac_config.supportedRatesCount=     uf_configure_supported_rates(priv->ap_mac_config.supportedRates, priv->ap_mac_config.phySupportedBitmap);
-
-    return 0;
-}
-
-#endif
-#ifdef CSR_SUPPORT_WEXT
-
-    void
-uf_sme_config_wq(struct work_struct *work)
-{
-    CsrWifiSmeStaConfig  staConfig;
-    CsrWifiSmeDeviceConfig  deviceConfig;
-    unifi_priv_t *priv = container_of(work, unifi_priv_t, sme_config_task);
-
-    /* Register to receive indications from the SME */
-    CsrWifiSmeEventMaskSetReqSend(0,
-            CSR_WIFI_SME_INDICATIONS_WIFIOFF | CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY |
-            CSR_WIFI_SME_INDICATIONS_MEDIASTATUS | CSR_WIFI_SME_INDICATIONS_MICFAILURE);
-
-    if (sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig)) {
-        unifi_warning(priv, "uf_sme_config_wq: Get unifi_SMEConfigValue failed.\n");
-        return;
-    }
-
-    if (priv->if_index == CSR_INDEX_5G) {
-        staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_5_0;
-    } else {
-        staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_2_4;
-    }
-
-    deviceConfig.trustLevel = (CsrWifiSme80211dTrustLevel)tl_80211d;
-    if (sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig)) {
-        unifi_warning(priv,
-                "SME config for 802.11d Trust Level and Radio Band failed.\n");
-        return;
-    }
-
-} /* uf_sme_config_wq() */
-
-#endif /* CSR_SUPPORT_WEXT */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_ta_ind_wq
- *
- *      Deferred work queue function to send Traffic Analysis protocols
- *      indications to the SME.
- *      These are done in a deferred work queue for two reasons:
- *       - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
- *       - we want to load the main driver data path as lightly as possible
- *
- *      The TA classifications already come from a workqueue.
- *
- *  Arguments:
- *      work    Pointer to work queue item.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-    void
-uf_ta_ind_wq(struct work_struct *work)
-{
-    struct ta_ind *ind = container_of(work, struct ta_ind, task);
-    unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_ind_work);
-    u16 interfaceTag = 0;
-
-
-    CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
-            interfaceTag,
-            ind->packet_type,
-            ind->direction,
-            ind->src_addr);
-    ind->in_use = 0;
-
-} /* uf_ta_ind_wq() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_ta_sample_ind_wq
- *
- *      Deferred work queue function to send Traffic Analysis sample
- *      indications to the SME.
- *      These are done in a deferred work queue for two reasons:
- *       - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
- *       - we want to load the main driver data path as lightly as possible
- *
- *      The TA classifications already come from a workqueue.
- *
- *  Arguments:
- *      work    Pointer to work queue item.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-    void
-uf_ta_sample_ind_wq(struct work_struct *work)
-{
-    struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task);
-    unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work);
-    u16 interfaceTag = 0;
-
-     unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n",
-        priv->rxTcpThroughput,
-        priv->txTcpThroughput,
-        priv->rxUdpThroughput,
-        priv->txUdpThroughput,
-        priv->bh_thread.prio);
-
-    if(priv->rxTcpThroughput > 1000)
-    {
-        if (bh_priority == -1 && priv->bh_thread.prio != 1)
-        {
-            struct sched_param param;
-            priv->bh_thread.prio = 1;
-            unifi_trace(priv, UDBG1, "%s new thread (RT) priority = %d\n",
-                        priv->bh_thread.name, priv->bh_thread.prio);
-            param.sched_priority = priv->bh_thread.prio;
-            sched_setscheduler(priv->bh_thread.thread_task, SCHED_FIFO, &param);
-        }
-    } else
-    {
-        if (bh_priority == -1 && priv->bh_thread.prio != DEFAULT_PRIO)
-        {
-            struct sched_param param;
-            param.sched_priority = 0;
-            sched_setscheduler(priv->bh_thread.thread_task, SCHED_NORMAL, &param);
-            priv->bh_thread.prio = DEFAULT_PRIO;
-            unifi_trace(priv, UDBG1, "%s new thread priority = %d\n",
-                        priv->bh_thread.name, priv->bh_thread.prio);
-            set_user_nice(priv->bh_thread.thread_task, PRIO_TO_NICE(priv->bh_thread.prio));
-        }
-    }
-
-    CsrWifiRouterCtrlTrafficSampleIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, ind->stats);
-
-    ind->in_use = 0;
-
-} /* uf_ta_sample_ind_wq() */
-
-
-/*
- * ---------------------------------------------------------------------------
- *  uf_send_m4_ready_wq
- *
- *      Deferred work queue function to send M4 ReadyToSend inds to the SME.
- *      These are done in a deferred work queue for two reasons:
- *       - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
- *       - we want to load the main driver data path as lightly as possible
- *
- *  Arguments:
- *      work    Pointer to work queue item.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void
-uf_send_m4_ready_wq(struct work_struct *work)
-{
-    netInterface_priv_t *InterfacePriv = container_of(work, netInterface_priv_t, send_m4_ready_task);
-    u16 iface = InterfacePriv->InterfaceTag;
-    unifi_priv_t *priv = InterfacePriv->privPtr;
-    CSR_MA_PACKET_REQUEST *req = &InterfacePriv->m4_signal.u.MaPacketRequest;
-    CsrWifiMacAddress peer;
-    unsigned long flags;
-
-    /* The peer address was stored in the signal */
-    spin_lock_irqsave(&priv->m4_lock, flags);
-    memcpy(peer.a, req->Ra.x, sizeof(peer.a));
-    spin_unlock_irqrestore(&priv->m4_lock, flags);
-
-    /* Send a signal to SME */
-    CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, iface, peer);
-
-       unifi_trace(priv, UDBG1, "M4ReadyToSendInd sent for peer %pMF\n",
-               peer.a);
-
-} /* uf_send_m4_ready_wq() */
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-/*
- * ---------------------------------------------------------------------------
- *  uf_send_pkt_to_encrypt
- *
- *      Deferred work queue function to send the WAPI data pkts to SME when unicast KeyId = 1
- *      These are done in a deferred work queue for two reasons:
- *       - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
- *       - we want to load the main driver data path as lightly as possible
- *
- *  Arguments:
- *      work    Pointer to work queue item.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-void uf_send_pkt_to_encrypt(struct work_struct *work)
-{
-    netInterface_priv_t *interfacePriv = container_of(work, netInterface_priv_t, send_pkt_to_encrypt);
-    u16 interfaceTag = interfacePriv->InterfaceTag;
-    unifi_priv_t *priv = interfacePriv->privPtr;
-
-    u32 pktBulkDataLength;
-    u8 *pktBulkData;
-    unsigned long flags;
-
-    if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
-
-        pktBulkDataLength = interfacePriv->wapi_unicast_bulk_data.data_length;
-
-        if (pktBulkDataLength > 0) {
-                   pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
-           } else {
-                   unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n");
-                   return;
-           }
-
-        spin_lock_irqsave(&priv->wapi_lock, flags);
-        /* Copy over the MA PKT REQ bulk data */
-        memcpy(pktBulkData, (u8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength);
-        /* Free any bulk data buffers allocated for the WAPI Data pkt */
-        unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
-        interfacePriv->wapi_unicast_bulk_data.net_buf_length = 0;
-        interfacePriv->wapi_unicast_bulk_data.data_length = 0;
-        interfacePriv->wapi_unicast_bulk_data.os_data_ptr = interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = NULL;
-        spin_unlock_irqrestore(&priv->wapi_lock, flags);
-
-        CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, pktBulkDataLength, pktBulkData);
-        unifi_trace(priv, UDBG1, "WapiUnicastTxEncryptInd sent to SME\n");
-
-        kfree(pktBulkData); /* Would have been copied over by the SME Handler */
-
-    } else {
-           unifi_warning(priv, "uf_send_pkt_to_encrypt() is NOT applicable for interface mode - %d\n", interfacePriv->interfaceMode);
-    }
-}/* uf_send_pkt_to_encrypt() */
-#endif
diff --git a/drivers/staging/csr/unifi_sme.h b/drivers/staging/csr/unifi_sme.h
deleted file mode 100644 (file)
index aff9aa1..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * ***************************************************************************
- *  FILE:     unifi_sme.h
- *
- *  PURPOSE:    SME related definitions.
- *
- *  Copyright (C) 2007-2011 by Cambridge Silicon Radio Ltd.
- *
- *  Refer to LICENSE.txt included with this source code for details on
- *  the license terms.
- *
- * ***************************************************************************
- */
-#ifndef __LINUX_UNIFI_SME_H__
-#define __LINUX_UNIFI_SME_H__ 1
-
-#include <linux/kernel.h>
-
-#ifdef CSR_SME_USERSPACE
-#include "sme_userspace.h"
-#endif
-
-#include "csr_wifi_sme_lib.h"
-
-typedef int unifi_data_port_action;
-
-typedef struct unifi_port_cfg
-{
-    /* TRUE if this port entry is allocated */
-    u8 in_use;
-    CsrWifiRouterCtrlPortAction port_action;
-    CsrWifiMacAddress mac_address;
-} unifi_port_cfg_t;
-
-#define UNIFI_MAX_CONNECTIONS           8
-#define UNIFI_MAX_RETRY_LIMIT           5
-#define UF_DATA_PORT_NOT_OVERIDE        0
-#define UF_DATA_PORT_OVERIDE            1
-
-typedef struct unifi_port_config
-{
-    int entries_in_use;
-    int overide_action;
-    unifi_port_cfg_t port_cfg[UNIFI_MAX_CONNECTIONS];
-} unifi_port_config_t;
-
-
-enum sme_request_status {
-    SME_REQUEST_EMPTY,
-    SME_REQUEST_PENDING,
-    SME_REQUEST_RECEIVED,
-    SME_REQUEST_TIMEDOUT,
-    SME_REQUEST_CANCELLED,
-};
-
-/* Structure to hold a UDI logged signal */
-typedef struct {
-
-    /* The current status of the request */
-    enum sme_request_status request_status;
-
-    /* The status the SME has passed to us */
-    CsrResult reply_status;
-
-    /* SME's reply to a get request */
-    CsrWifiSmeVersions versions;
-    CsrWifiSmePowerConfig powerConfig;
-    CsrWifiSmeHostConfig hostConfig;
-    CsrWifiSmeStaConfig staConfig;
-    CsrWifiSmeDeviceConfig deviceConfig;
-    CsrWifiSmeCoexInfo coexInfo;
-    CsrWifiSmeCoexConfig coexConfig;
-    CsrWifiSmeMibConfig mibConfig;
-    CsrWifiSmeConnectionInfo connectionInfo;
-    CsrWifiSmeConnectionConfig connectionConfig;
-    CsrWifiSmeConnectionStats connectionStats;
-
-
-    /* SME's reply to a scan request */
-    u16 reply_scan_results_count;
-    CsrWifiSmeScanResult* reply_scan_results;
-
-} sme_reply_t;
-
-
-typedef struct {
-    u16 appHandle;
-    CsrWifiRouterEncapsulation encapsulation;
-    u16 protocol;
-    u8 oui[3];
-    u8 in_use;
-} sme_ma_unidata_ind_filter_t;
-
-
-CsrWifiRouterCtrlPortAction uf_sme_port_state(unifi_priv_t *priv,
-                                          unsigned char *address,
-                                          int queue,
-                                          u16 interfaceTag);
-unifi_port_cfg_t *uf_sme_port_config_handle(unifi_priv_t *priv,
-                                            unsigned char *address,
-                                            int queue,
-                                            u16 interfaceTag);
-
-
-
-/* Callback for event logging to SME clients */
-void sme_log_event(ul_client_t *client, const u8 *signal, int signal_len,
-                   const bulk_data_param_t *bulkdata, int dir);
-
-/* The workqueue task to the set the multicast addresses list */
-void uf_multicast_list_wq(struct work_struct *work);
-
-/* The workqueue task to execute the TA module */
-void uf_ta_wq(struct work_struct *work);
-
-
-/*
- * SME blocking helper functions
- */
-#ifdef UNIFI_DEBUG
-# define sme_complete_request(priv, status)   uf_sme_complete_request(priv, status, __func__)
-#else
-# define sme_complete_request(priv, status)   uf_sme_complete_request(priv, status, NULL)
-#endif
-
-void uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func);
-void uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status);
-
-
-/*
- * Blocking functions using the SME SYS API.
- */
-int sme_sys_suspend(unifi_priv_t *priv);
-int sme_sys_resume(unifi_priv_t *priv);
-
-
-/*
- * Traffic Analysis workqueue jobs
- */
-void uf_ta_ind_wq(struct work_struct *work);
-void uf_ta_sample_ind_wq(struct work_struct *work);
-
-/*
- * SME config workqueue job
- */
-void uf_sme_config_wq(struct work_struct *work);
-
-/*
- * To send M4 read to send IND
- */
-void uf_send_m4_ready_wq(struct work_struct *work);
-
-#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
-/*
- * To send data pkt to Sme for encryption
- */
-void uf_send_pkt_to_encrypt(struct work_struct *work);
-#endif
-
-int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig);
-int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig);
-int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig);
-int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig);
-int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig);
-int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig);
-int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo);
-int sme_mgt_packet_filter_set(unifi_priv_t *priv);
-int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
-                  u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas);
-
-#ifdef CSR_SUPPORT_WEXT
-/*
- * Blocking functions using the SME MGT API.
- */
-int sme_mgt_wifi_on(unifi_priv_t *priv);
-int sme_mgt_wifi_off(unifi_priv_t *priv);
-/*int sme_mgt_set_value_async(unifi_priv_t *priv, unifi_AppValue *app_value);
-int sme_mgt_get_value_async(unifi_priv_t *priv, unifi_AppValue *app_value);
-int sme_mgt_get_value(unifi_priv_t *priv, unifi_AppValue *app_value);
-int sme_mgt_set_value(unifi_priv_t *priv, unifi_AppValue *app_value);
-*/
-int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig);
-int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig);
-int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig);
-int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig);
-
-int sme_mgt_connection_info_set(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo);
-int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo);
-int sme_mgt_connection_config_set(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig);
-int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig);
-int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats);
-
-int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions);
-
-
-int sme_mgt_scan_full(unifi_priv_t *priv, CsrWifiSsid *specific_ssid,
-                      int num_channels, unsigned char *channel_list);
-int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
-                                   struct iw_request_info *info,
-                                   char *scan_results,
-                                   long scan_results_len);
-int sme_mgt_disconnect(unifi_priv_t *priv);
-int sme_mgt_connect(unifi_priv_t *priv);
-int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
-                CsrWifiSmeListAction action);
-int sme_mgt_pmkid(unifi_priv_t *priv, CsrWifiSmeListAction action,
-                  CsrWifiSmePmkidList *pmkid_list);
-int sme_mgt_mib_get(unifi_priv_t *priv,
-                    unsigned char *varbind, int *length);
-int sme_mgt_mib_set(unifi_priv_t *priv,
-                    unsigned char *varbind, int length);
-#ifdef CSR_SUPPORT_WEXT_AP
-int sme_ap_start(unifi_priv_t *priv, u16 interface_tag, CsrWifiSmeApConfig_t *ap_config);
-int sme_ap_stop(unifi_priv_t *priv, u16 interface_tag);
-int sme_ap_config(unifi_priv_t *priv, CsrWifiSmeApMacConfig *ap_mac_config, CsrWifiNmeApConfig *group_security_config);
-int uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap);
-#endif
-int unifi_translate_scan(struct net_device *dev,
-                         struct iw_request_info *info,
-                         char *current_ev, char *end_buf,
-                         CsrWifiSmeScanResult *scan_data,
-                         int scan_index);
-
-#endif /* CSR_SUPPORT_WEXT */
-
-int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg);
-int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg);
-#ifdef CSR_SUPPORT_WEXT_AP
-int unifi_cfg_set_ap_config(unifi_priv_t * priv, unsigned char* arg);
-#endif
-
-
-
-int convert_sme_error(CsrResult error);
-
-
-#endif /* __LINUX_UNIFI_SME_H__ */
diff --git a/drivers/staging/csr/unifi_wext.h b/drivers/staging/csr/unifi_wext.h
deleted file mode 100644 (file)
index beba089..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *****************************************************************************
- *
- * FILE : unifi_wext.h
- *
- * PURPOSE : Private header file for unifi driver support to wireless extensions.
- *
- * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
-*****************************************************************************
- */
-#ifndef __LINUX_UNIFI_WEXT_H__
-#define __LINUX_UNIFI_WEXT_H__ 1
-
-#include <linux/kernel.h>
-#include <net/iw_handler.h>
-#include "csr_wifi_sme_prim.h"
-
-/*
- *      wext.c
- */
-/* A few details needed for WEP (Wireless Equivalent Privacy) */
-#define UNIFI_MAX_KEY_SIZE      16
-#define NUM_WEPKEYS              4
-#define SMALL_KEY_SIZE           5
-#define LARGE_KEY_SIZE          13
-typedef struct wep_key_t {
-    int len;
-    unsigned char key[UNIFI_MAX_KEY_SIZE];  /* 40-bit and 104-bit keys */
-} wep_key_t;
-
-#define UNIFI_SCAN_ACTIVE       0
-#define UNIFI_SCAN_PASSIVE      1
-#define UNIFI_MAX_SSID_LEN      32
-
-#define MAX_WPA_IE_LEN 64
-#define MAX_RSN_IE_LEN 255
-
-/*
- * Function to register in the netdev to report wireless stats.
- */
-struct iw_statistics *unifi_get_wireless_stats(struct net_device *dev);
-
-void uf_sme_wext_set_defaults(unifi_priv_t *priv);
-
-
-/*
- *      wext_events.c
- */
-/* Functions to generate Wireless Extension events */
-void wext_send_scan_results_event(unifi_priv_t *priv);
-void wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid,
-                           unsigned char *req_ie, int req_ie_len,
-                           unsigned char *resp_ie, int resp_ie_len,
-                           unsigned char *scan_ie, unsigned int scan_ie_len);
-void wext_send_disassoc_event(unifi_priv_t *priv);
-void wext_send_michaelmicfailure_event(unifi_priv_t *priv,
-                                       u16 count, CsrWifiMacAddress address,
-                                       CsrWifiSmeKeyType keyType, u16 interfaceTag);
-void wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag);
-void wext_send_started_event(unifi_priv_t *priv);
-
-
-static inline int
-uf_iwe_stream_add_point(struct iw_request_info *info, char *start, char *stop,
-                        struct iw_event *piwe, char *extra)
-{
-    char *new_start;
-
-    new_start = iwe_stream_add_point(info, start, stop, piwe, extra);
-    if (unlikely(new_start == start))
-        return -E2BIG;
-
-    return (new_start - start);
-}
-
-
-static inline int
-uf_iwe_stream_add_event(struct iw_request_info *info, char *start, char *stop,
-                        struct iw_event *piwe, int len)
-{
-    char *new_start;
-
-    new_start = iwe_stream_add_event(info, start, stop, piwe, len);
-    if (unlikely(new_start == start))
-        return -E2BIG;
-
-    return (new_start - start);
-}
-
-static inline int
-uf_iwe_stream_add_value(struct iw_request_info *info, char *stream, char *start,
-                        char *stop, struct iw_event *piwe, int len)
-{
-    char *new_start;
-
-    new_start = iwe_stream_add_value(info, stream, start, stop, piwe, len);
-    if (unlikely(new_start == start))
-        return -E2BIG;
-
-    return (new_start - start);
-}
-
-
-#endif /* __LINUX_UNIFI_WEXT_H__ */
diff --git a/drivers/staging/csr/unifiio.h b/drivers/staging/csr/unifiio.h
deleted file mode 100644 (file)
index b9de0cb..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- *
- *  FILE: unifiio.h
- *
- *      Public definitions for the UniFi linux driver.
- *      This is mostly ioctl command values and structs.
- *
- *      Include <sys/ioctl.h> or similar before this file
- *
- * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#ifndef __UNIFIIO_H__
-#define __UNIFIIO_H__
-
-#include <linux/types.h>
-
-#define UNIFI_GET_UDI_ENABLE    _IOR('u',  1, int)
-#define UNIFI_SET_UDI_ENABLE    _IOW('u',  2, int)
-/* Values for UDI_ENABLE */
-#define UDI_ENABLE_DATA         0x1
-#define UDI_ENABLE_CONTROL      0x2
-
-/* MIB set/get. Arg is a pointer to a varbind */
-#define UNIFI_GET_MIB           _IOWR('u',  3, unsigned char *)
-#define UNIFI_SET_MIB           _IOW ('u',  4, unsigned char *)
-#define MAX_VARBIND_LENGTH 127
-
-/* Private IOCTLs */
-#define SIOCIWS80211POWERSAVEPRIV           SIOCIWFIRSTPRIV
-#define SIOCIWG80211POWERSAVEPRIV           SIOCIWFIRSTPRIV + 1
-#define SIOCIWS80211RELOADDEFAULTSPRIV      SIOCIWFIRSTPRIV + 2
-#define SIOCIWSCONFWAPIPRIV                 SIOCIWFIRSTPRIV + 4
-#define SIOCIWSWAPIKEYPRIV                  SIOCIWFIRSTPRIV + 6
-#define SIOCIWSSMEDEBUGPRIV                 SIOCIWFIRSTPRIV + 8
-#define SIOCIWSAPCFGPRIV                    SIOCIWFIRSTPRIV + 10
-#define SIOCIWSAPSTARTPRIV                  SIOCIWFIRSTPRIV + 12
-#define SIOCIWSAPSTOPPRIV                   SIOCIWFIRSTPRIV + 14
-#define SIOCIWSFWRELOADPRIV                 SIOCIWFIRSTPRIV + 16
-#define SIOCIWSSTACKSTART                   SIOCIWFIRSTPRIV + 18
-#define SIOCIWSSTACKSTOP                    SIOCIWFIRSTPRIV + 20
-
-
-
-#define IWPRIV_POWER_SAVE_MAX_STRING 32
-#define IWPRIV_SME_DEBUG_MAX_STRING 32
-#define IWPRIV_SME_MAX_STRING 120
-
-
-/* Private configuration commands */
-#define UNIFI_CFG               _IOWR('u',  5, unsigned char *)
-/*
- * <------------------  Read/Write Buffer  -------------------->
- * _____________________________________________________________
- * |    Cmd    |    Arg    |   ...  Buffer (opt)  ...          |
- * -------------------------------------------------------------
- * <-- uint --><-- uint --><-----  unsigned char buffer  ------>
- *
- * Cmd:    A unifi_cfg_command_t command.
- * Arg:    Out:Length     if Cmd==UNIFI_CFG_GET
- *         In:PowerOnOff  if Cmd==UNIFI_CFG_POWER
- *         In:PowerMode   if Cmd==UNIFI_CFG_POWERSAVE
- *         In:Length      if Cmd==UNIFI_CFG_FILTER
- *         In:WMM Qos Info if Cmd==UNIFI_CFG_WMM_QOS_INFO
- * Buffer: Out:Data       if Cmd==UNIFI_CFG_GET
- *         NULL           if Cmd==UNIFI_CFG_POWER
- *         NULL           if Cmd==UNIFI_CFG_POWERSAVE
- *         In:Filters     if Cmd==UNIFI_CFG_FILTER
- *
- * where Filters is a uf_cfg_bcast_packet_filter_t structure
- * followed by 0 - n tclas_t structures. The length of the tclas_t
- * structures is obtained by uf_cfg_bcast_packet_filter_t::tclas_ies_length.
- */
-
-
-#define UNIFI_PUTEST            _IOWR('u',  6, unsigned char *)
-/*
- * <------------------  Read/Write Buffer  -------------------->
- * _____________________________________________________________
- * |    Cmd    |    Arg    |   ...  Buffer (opt)  ...          |
- * -------------------------------------------------------------
- * <-- uint --><-- uint --><-----  unsigned char buffer  ------>
- *
- * Cmd:    A unifi_putest_command_t command.
- * Arg:    N/A                           if Cmd==UNIFI_PUTEST_START
- *         N/A                           if Cmd==UNIFI_PUTEST_STOP
- *         In:int (Clock Speed)          if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK
- *         In/Out:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_READ
- *         In:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_WRITE
- *         In:uint (f/w file name length) if Cmd==UNIFI_PUTEST_DL_FW
- * Buffer: NULL                          if Cmd==UNIFI_PUTEST_START
- *         NULL                          if Cmd==UNIFI_PUTEST_STOP
- *         NULL                          if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK
- *         In/Out:unifi_putest_cmd52     if Cmd==UNIFI_PUTEST_CMD52_READ
- *         In:unifi_putest_cmd52         if Cmd==UNIFI_PUTEST_CMD52_WRITE
- *         In:f/w file name              if Cmd==UNIFI_PUTEST_DL_FW
- */
-
-#define UNIFI_BUILD_TYPE _IOWR('u', 7, unsigned char)
-#define UNIFI_BUILD_NME 1
-#define UNIFI_BUILD_WEXT 2
-#define UNIFI_BUILD_AP 3
-
-/* debugging */
-#define UNIFI_KICK              _IO ('u',  0x10)
-#define UNIFI_SET_DEBUG         _IO ('u',  0x11)
-#define UNIFI_SET_TRACE         _IO ('u',  0x12)
-
-#define UNIFI_GET_INIT_STATUS   _IOR ('u', 0x15, int)
-#define UNIFI_SET_UDI_LOG_MASK  _IOR('u',  0x18, unifiio_filter_t)
-#define UNIFI_SET_UDI_SNAP_MASK _IOW('u',  0x1a, unifiio_snap_filter_t)
-#define UNIFI_SET_AMP_ENABLE    _IOWR('u',  0x1b, int)
-
-#define UNIFI_INIT_HW           _IOR ('u', 0x13, unsigned char)
-#define UNIFI_INIT_NETDEV       _IOW ('u', 0x14, unsigned char[6])
-#define UNIFI_SME_PRESENT       _IOW ('u', 0x19, int)
-
-#define UNIFI_CFG_PERIOD_TRAFFIC _IOW ('u', 0x21, unsigned char *)
-#define UNIFI_CFG_UAPSD_TRAFFIC _IOW ('u', 0x22, unsigned char)
-
-#define UNIFI_COREDUMP_GET_REG  _IOWR('u', 0x23, unifiio_coredump_req_t)
-
-
-/*
- * Following reset, f/w may only be downloaded using CMD52.
- * This is slow, so there is a facility to download a secondary
- * loader first which supports CMD53.
- * If loader_len is > 0, then loader_data is assumed to point to
- * a suitable secondary loader that can be used to download the
- * main image.
- *
- * The driver will run the host protocol initialisation sequence
- * after downloading the image.
- *
- * If both lengths are zero, then the f/w is assumed to have been
- * booted from Flash and the host protocol initialisation sequence
- * is run.
- */
-typedef struct {
-
-    /* Number of bytes in the image */
-    int img_len;
-
-    /* Pointer to image data. */
-    unsigned char *img_data;
-
-
-    /* Number of bytes in the loader image */
-    int loader_len;
-
-    /* Pointer to loader image data. */
-    unsigned char *loader_data;
-
-} unifiio_img_t;
-
-
-/* Structure of data read from the unifi device. */
-typedef struct
-{
-    /* Length (in bytes) of entire structure including appended bulk data */
-    int length;
-
-    /* System time (in milliseconds) that signal was transferred */
-    int timestamp;
-
-    /* Direction in which signal was transferred. */
-    int direction;
-#define UDI_FROM_HOST   0
-#define UDI_TO_HOST     1
-#define UDI_CONFIG_IND  2
-
-    /* The length of the signal (in bytes) not including bulk data */
-    int signal_length;
-
-    /* Signal body follows, then any bulk data */
-
-} udi_msg_t;
-
-
-typedef enum
-{
-    UfSigFil_AllOn = 0,         /* Log all signal IDs */
-    UfSigFil_AllOff = 1,        /* Don't log any signal IDs */
-    UfSigFil_SelectOn = 2,      /* Log these signal IDs */
-    UfSigFil_SelectOff = 3      /* Don't log these signal IDs */
-} uf_sigfilter_action_t;
-
-typedef struct {
-
-    /* Number of 16-bit ints in the sig_ids array */
-    int num_sig_ids;
-    /* The action to perform */
-    uf_sigfilter_action_t action;
-    /* List of signal IDs to pass or block */
-    unsigned short *sig_ids;
-
-} unifiio_filter_t;
-
-
-typedef struct {
-    /* Number of 16-bit ints in the protocols array */
-    u16 count;
-    /* List of protocol ids to pass */
-    u16 *protocols;
-} unifiio_snap_filter_t;
-
-
-
-typedef u8 unifi_putest_command_t;
-
-#define UNIFI_PUTEST_START 0
-#define UNIFI_PUTEST_STOP 1
-#define UNIFI_PUTEST_SET_SDIO_CLOCK 2
-#define UNIFI_PUTEST_CMD52_READ 3
-#define UNIFI_PUTEST_CMD52_WRITE 4
-#define UNIFI_PUTEST_DL_FW 5
-#define UNIFI_PUTEST_DL_FW_BUFF 6
-#define UNIFI_PUTEST_CMD52_BLOCK_READ 7
-#define UNIFI_PUTEST_COREDUMP_PREPARE 8
-#define UNIFI_PUTEST_GP_READ16 9
-#define UNIFI_PUTEST_GP_WRITE16 10
-
-
-struct unifi_putest_cmd52 {
-    int funcnum;
-    unsigned long addr;
-    unsigned char data;
-};
-
-
-struct unifi_putest_block_cmd52_r {
-    int           funcnum;
-    unsigned long addr;
-    unsigned int  length;
-    unsigned char *data;
-};
-
-struct unifi_putest_gp_rw16 {
-    unsigned long addr;        /* generic address */
-    unsigned short data;
-};
-
-typedef enum unifi_cfg_command {
-    UNIFI_CFG_GET,
-    UNIFI_CFG_POWER,
-    UNIFI_CFG_POWERSAVE,
-    UNIFI_CFG_FILTER,
-    UNIFI_CFG_POWERSUPPLY,
-    UNIFI_CFG_WMM_QOSINFO,
-    UNIFI_CFG_WMM_ADDTS,
-    UNIFI_CFG_WMM_DELTS,
-    UNIFI_CFG_STRICT_DRAFT_N,
-    UNIFI_CFG_ENABLE_OKC,
-    UNIFI_CFG_SET_AP_CONFIG,
-    UNIFI_CFG_CORE_DUMP /* request to take a fw core dump */
-} unifi_cfg_command_t;
-
-typedef enum unifi_cfg_power {
-    UNIFI_CFG_POWER_UNSPECIFIED,
-    UNIFI_CFG_POWER_OFF,
-    UNIFI_CFG_POWER_ON
-} unifi_cfg_power_t;
-
-typedef enum unifi_cfg_powersupply {
-    UNIFI_CFG_POWERSUPPLY_UNSPECIFIED,
-    UNIFI_CFG_POWERSUPPLY_MAINS,
-    UNIFI_CFG_POWERSUPPLY_BATTERIES
-} unifi_cfg_powersupply_t;
-
-typedef enum unifi_cfg_powersave {
-    UNIFI_CFG_POWERSAVE_UNSPECIFIED,
-    UNIFI_CFG_POWERSAVE_NONE,
-    UNIFI_CFG_POWERSAVE_FAST,
-    UNIFI_CFG_POWERSAVE_FULL,
-    UNIFI_CFG_POWERSAVE_AUTO
-} unifi_cfg_powersave_t;
-
-typedef enum unifi_cfg_get {
-    UNIFI_CFG_GET_COEX,
-    UNIFI_CFG_GET_POWER_MODE,
-    UNIFI_CFG_GET_VERSIONS,
-    UNIFI_CFG_GET_POWER_SUPPLY,
-    UNIFI_CFG_GET_INSTANCE,
-    UNIFI_CFG_GET_AP_CONFIG
-} unifi_cfg_get_t;
-
-#define UNIFI_CFG_FILTER_NONE            0x0000
-#define UNIFI_CFG_FILTER_DHCP            0x0001
-#define UNIFI_CFG_FILTER_ARP             0x0002
-#define UNIFI_CFG_FILTER_NBNS            0x0004
-#define UNIFI_CFG_FILTER_NBDS            0x0008
-#define UNIFI_CFG_FILTER_CUPS            0x0010
-#define UNIFI_CFG_FILTER_ALL             0xFFFF
-
-
-typedef struct uf_cfg_bcast_packet_filter
-{
-    unsigned long filter_mode;     //as defined by HIP protocol
-    unsigned char arp_filter;
-    unsigned char dhcp_filter;
-    unsigned long tclas_ies_length; // length of tclas_ies in bytes
-    unsigned char tclas_ies[1];    // variable length depending on above field
-} uf_cfg_bcast_packet_filter_t;
-
-typedef struct uf_cfg_ap_config
-{
-    u8    phySupportedBitmap;
-    u8    channel;
-    u16   beaconInterval;
-    u8    dtimPeriod;
-    u8     wmmEnabled;
-    u8    shortSlotTimeEnabled;
-    u16   groupkeyTimeout;
-    u8     strictGtkRekeyEnabled;
-    u16   gmkTimeout;
-    u16   responseTimeout;
-    u8    retransLimit;
-    u8    rxStbc;
-    u8     rifsModeAllowed;
-    u8    dualCtsProtection;
-    u8    ctsProtectionType;
-    u16   maxListenInterval;
-}uf_cfg_ap_config_t;
-
-typedef struct tcpic_clsfr
-{
-    __u8 cls_fr_type;
-    __u8 cls_fr_mask;
-    __u8 version;
-    __u8 source_ip_addr[4];
-    __u8 dest_ip_addr[4];
-    __u16 source_port;
-    __u16 dest_port;
-    __u8 dscp;
-    __u8 protocol;
-    __u8 reserved;
-} __attribute__ ((packed)) tcpip_clsfr_t;
-
-typedef struct tclas {
-    __u8 element_id;
-    __u8 length;
-    __u8 user_priority;
-    tcpip_clsfr_t tcp_ip_cls_fr;
-} __attribute__ ((packed)) tclas_t;
-
-
-#define CONFIG_IND_ERROR            0x01
-#define CONFIG_IND_EXIT             0x02
-#define CONFIG_SME_NOT_PRESENT      0x10
-#define CONFIG_SME_PRESENT          0x20
-
-/* WAPI Key */
-typedef struct
-{
-    u8                          unicastKey;
-    /* If non zero, then unicast key otherwise group key */
-    u8                          keyIndex;
-    u8                          keyRsc[16];
-    u8                          authenticator;
-    /* If non zero, then authenticator otherwise supplicant */
-    u8                          address[6];
-    u8                          key[32];
-} unifiio_wapi_key_t;
-
-/* Values describing XAP memory regions captured by the mini-coredump system */
-typedef enum unifiio_coredump_space {
-    UNIFIIO_COREDUMP_MAC_REG,
-    UNIFIIO_COREDUMP_PHY_REG,
-    UNIFIIO_COREDUMP_SH_DMEM,
-    UNIFIIO_COREDUMP_MAC_DMEM,
-    UNIFIIO_COREDUMP_PHY_DMEM,
-    UNIFIIO_COREDUMP_TRIGGER_MAGIC = 0xFEED
-} unifiio_coredump_space_t;
-
-/* Userspace tool uses this structure to retrieve a register value from a
- * mini-coredump buffer previously saved by the HIP
- */
-typedef struct unifiio_coredump_req {
-    /* From user */
-    int index;                      /* 0=newest, -1=oldest */
-    unsigned int offset;            /* register offset in space */
-    unifiio_coredump_space_t space; /* memory space */
-    /* Filled by driver */
-    unsigned int drv_build;         /* driver build id */
-    unsigned int chip_ver;          /* chip version */
-    unsigned int fw_ver;            /* firmware version */
-    int requestor;                  /* requestor: 0=auto dump, 1=manual */
-    unsigned int timestamp;         /* time of capture by driver */
-    unsigned int serial;            /* capture serial number */
-    int value;                      /* 16 bit register value, -ve for error */
-} unifiio_coredump_req_t;           /* Core-dumped register value request */
-
-#endif /* __UNIFIIO_H__ */
diff --git a/drivers/staging/csr/wext_events.c b/drivers/staging/csr/wext_events.c
deleted file mode 100644 (file)
index 9860ea3..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * ---------------------------------------------------------------------------
- * FILE:     wext_events.c
- *
- * PURPOSE:
- *      Code to generate iwevents.
- *
- * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
- *
- * Refer to LICENSE.txt included with this source code for details on
- * the license terms.
- *
- * ---------------------------------------------------------------------------
- */
-#include <linux/types.h>
-#include <linux/etherdevice.h>
-#include <linux/if_arp.h>
-#include "csr_wifi_hip_unifi.h"
-#include "unifi_priv.h"
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  wext_send_assoc_event
- *
- *      Send wireless-extension events up to userland to announce
- *      successful association with an AP.
- *
- *  Arguments:
- *      priv                    Pointer to driver context.
- *      bssid                   MAC address of AP we associated with
- *      req_ie, req_ie_len      IEs in the original request
- *      resp_ie, resp_ie_len    IEs in the response
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      This is sent on first successful association, and again if we
- *      roam to another AP.
- * ---------------------------------------------------------------------------
- */
-void
-wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid,
-                      unsigned char *req_ie, int req_ie_len,
-                      unsigned char *resp_ie, int resp_ie_len,
-                      unsigned char *scan_ie, unsigned int scan_ie_len)
-{
-#if WIRELESS_EXT > 17
-    union iwreq_data wrqu;
-
-    if (req_ie_len == 0) req_ie = NULL;
-    wrqu.data.length = req_ie_len;
-    wrqu.data.flags = 0;
-    wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCREQIE, &wrqu, req_ie);
-
-    if (resp_ie_len == 0) resp_ie = NULL;
-    wrqu.data.length = resp_ie_len;
-    wrqu.data.flags = 0;
-    wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCRESPIE, &wrqu, resp_ie);
-
-    if (scan_ie_len > 0) {
-        wrqu.data.length = scan_ie_len;
-        wrqu.data.flags = 0;
-        wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVGENIE, &wrqu, scan_ie);
-    }
-
-    memcpy(&wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
-    wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL);
-#endif
-} /* wext_send_assoc_event() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  wext_send_disassoc_event
- *
- *      Send a wireless-extension event up to userland to announce
- *      that we disassociated from an AP.
- *
- *  Arguments:
- *      priv                    Pointer to driver context.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      The semantics of wpa_supplicant (the userland SME application) are
- *      that a SIOCGIWAP event with MAC address of all zero means
- *      disassociate.
- * ---------------------------------------------------------------------------
- */
-void
-wext_send_disassoc_event(unifi_priv_t *priv)
-{
-#if WIRELESS_EXT > 17
-    union iwreq_data wrqu;
-
-    memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
-    wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL);
-#endif
-} /* wext_send_disassoc_event() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  wext_send_scan_results_event
- *
- *      Send wireless-extension events up to userland to announce
- *      completion of a scan.
- *
- *  Arguments:
- *      priv                    Pointer to driver context.
- *
- *  Returns:
- *      None.
- *
- *  Notes:
- *      This doesn't actually report the results, they are retrieved
- *      using the SIOCGIWSCAN ioctl command.
- * ---------------------------------------------------------------------------
- */
-void
-wext_send_scan_results_event(unifi_priv_t *priv)
-{
-#if WIRELESS_EXT > 17
-    union iwreq_data wrqu;
-
-    wrqu.data.length = 0;
-    wrqu.data.flags = 0;
-    wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWSCAN, &wrqu, NULL);
-
-#endif
-} /* wext_send_scan_results_event() */
-
-
-
-/*
- * ---------------------------------------------------------------------------
- *  wext_send_michaelmicfailure_event
- *
- *      Send wireless-extension events up to userland to announce
- *      completion of a scan.
- *
- *  Arguments:
- *      priv            Pointer to driver context.
- *      count, macaddr, key_type, key_idx, tsc
- *                      Parameters from report from UniFi.
- *
- *  Returns:
- *      None.
- * ---------------------------------------------------------------------------
- */
-#if WIRELESS_EXT >= 18
-static inline void
-_send_michaelmicfailure_event(struct net_device *dev,
-                              int count, const unsigned char *macaddr,
-                              int key_type, int key_idx,
-                              unsigned char *tsc)
-{
-    union iwreq_data wrqu;
-    struct iw_michaelmicfailure mmf;
-
-    memset(&mmf, 0, sizeof(mmf));
-
-    mmf.flags = key_idx & IW_MICFAILURE_KEY_ID;
-    if (key_type == CSR_GROUP) {
-        mmf.flags |= IW_MICFAILURE_GROUP;
-    } else {
-        mmf.flags |= IW_MICFAILURE_PAIRWISE;
-    }
-    mmf.flags |= ((count << 5) & IW_MICFAILURE_COUNT);
-
-    mmf.src_addr.sa_family = ARPHRD_ETHER;
-    memcpy(mmf.src_addr.sa_data, macaddr, ETH_ALEN);
-
-    memcpy(mmf.tsc, tsc, IW_ENCODE_SEQ_MAX_SIZE);
-
-    memset(&wrqu, 0, sizeof(wrqu));
-    wrqu.data.length = sizeof(mmf);
-
-    wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&mmf);
-}
-#elif WIRELESS_EXT >= 15
-static inline void
-_send_michaelmicfailure_event(struct net_device *dev,
-                              int count, const unsigned char *macaddr,
-                              int key_type, int key_idx,
-                              unsigned char *tsc)
-{
-    union iwreq_data wrqu;
-    char buf[128];
-
-       sprintf(buf,
-               "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=%pM)",
-               key_idx, (key_type == CSR_GROUP) ? "broad" : "uni", macaddr);
-    memset(&wrqu, 0, sizeof(wrqu));
-    wrqu.data.length = strlen(buf);
-    wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
-}
-#else /* WIRELESS_EXT >= 15 */
-static inline void
-_send_michaelmicfailure_event(struct net_device *dev,
-                              int count, const unsigned char *macaddr,
-                              int key_type, int key_idx,
-                              unsigned char *tsc)
-{
-    /* Not supported before WEXT 15 */
-}
-#endif /* WIRELESS_EXT >= 15 */
-
-
-void
-wext_send_michaelmicfailure_event(unifi_priv_t *priv,
-                                  u16 count,
-                                  CsrWifiMacAddress address,
-                                  CsrWifiSmeKeyType keyType,
-                                  u16 interfaceTag)
-{
-    unsigned char tsc[8] = {0};
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "wext_send_michaelmicfailure_event bad interfaceTag\n");
-        return;
-    }
-
-    _send_michaelmicfailure_event(priv->netdev[interfaceTag],
-                                  count,
-                                  address.a,
-                                  keyType,
-                                  0,
-                                  tsc);
-} /* wext_send_michaelmicfailure_event() */
-
-void
-wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag)
-{
-#if WIRELESS_EXT > 17
-    union iwreq_data wrqu;
-    struct iw_pmkid_cand pmkid_cand;
-
-    if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
-        unifi_error(priv, "wext_send_pmkid_candidate_event bad interfaceTag\n");
-        return;
-    }
-
-    memset(&pmkid_cand, 0, sizeof(pmkid_cand));
-
-    if (preauth_allowed) {
-        pmkid_cand.flags |= IW_PMKID_CAND_PREAUTH;
-    }
-    pmkid_cand.bssid.sa_family = ARPHRD_ETHER;
-    memcpy(pmkid_cand.bssid.sa_data, bssid.a, ETH_ALEN);
-    /* Used as priority, smaller the number higher the priority, not really used in our case */
-    pmkid_cand.index = 1;
-
-    memset(&wrqu, 0, sizeof(wrqu));
-    wrqu.data.length = sizeof(pmkid_cand);
-
-    wireless_send_event(priv->netdev[interfaceTag], IWEVPMKIDCAND, &wrqu, (char *)&pmkid_cand);
-#endif
-} /* wext_send_pmkid_candidate_event() */
-
-/*
- * Send a custom WEXT event to say we have completed initialisation
- * and are now ready for WEXT ioctls. Used by Android wpa_supplicant.
- */
-void
-wext_send_started_event(unifi_priv_t *priv)
-{
-#if WIRELESS_EXT > 17
-    union iwreq_data wrqu;
-    char data[] = "STARTED";
-
-    wrqu.data.length = sizeof(data);
-    wrqu.data.flags = 0;
-    wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVCUSTOM, &wrqu, data);
-#endif
-} /* wext_send_started_event() */
-
index 5590ebf1da15218c50561fcbd01b0ebc907ce693..817f837b240d656ccf4379bd3f68be4bbf49b867 100644 (file)
@@ -827,11 +827,11 @@ static void usb_alphatrack_disconnect(struct usb_interface *intf)
                mutex_unlock(&dev->mtx);
                usb_alphatrack_delete(dev);
        } else {
+               atomic_set(&dev->writes_pending, 0);
                dev->intf = NULL;
                mutex_unlock(&dev->mtx);
        }
 
-       atomic_set(&dev->writes_pending, 0);
        mutex_unlock(&disconnect_mutex);
 
        dev_info(&intf->dev, "Alphatrack Surface #%d now disconnected\n",
index b795353e8348a3fcab6d1a01d0472a7168c370a1..cc3692439a5c95fedc0f2c584a52b3d03c0bf391 100644 (file)
@@ -250,8 +250,8 @@ static void send_qos_list(struct nic *nic, struct list_head *head)
 
        list_for_each_entry_safe(entry, n, head, list) {
                list_del(&entry->list);
-               free_qos_entry(entry);
                gdm_wimax_send_tx(entry->skb, entry->dev);
+               free_qos_entry(entry);
        }
 }
 
index 1bfe5d81792ba47c9aae04eeb9f0174e9653289e..8ed75a94f4658b73babc284a5d3f3b87f63073a5 100644 (file)
@@ -257,6 +257,8 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
                        ret = lis3l02dq_read_reg_s16(indio_dev, reg, val);
                }
                mutex_unlock(&indio_dev->mlock);
+               if (ret < 0)
+                       goto error_ret;
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
                *val = 0;
index 3fc79e5827500f97a8f843078fc3ff91cf6d9105..a2e61c2fc8d19a319aa1d29e4bfadc7866d6c3f3 100644 (file)
@@ -517,6 +517,7 @@ static const struct iio_info ad7291_info = {
        .read_event_value = &ad7291_read_event_value,
        .write_event_value = &ad7291_write_event_value,
        .event_attrs = &ad7291_event_attribute_group,
+       .driver_module = THIS_MODULE,
 };
 
 static int ad7291_probe(struct i2c_client *client,
index d92c97a59d61f808abb5795c937dbd689f2d8d4d..9f52a2857929ffa975f3a8289074f3fc0fb7ee0e 100644 (file)
@@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
 {
        struct mxs_lradc *lradc = iio_priv(iio_dev);
        int ret;
-       unsigned long mask;
 
        if (m != IIO_CHAN_INFO_RAW)
                return -EINVAL;
@@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
        if (chan->channel > LRADC_MAX_TOTAL_CHANS)
                return -EINVAL;
 
-       /* Validate the channel if it doesn't intersect with reserved chans. */
-       bitmap_set(&mask, chan->channel, 1);
-       ret = iio_validate_scan_mask_onehot(iio_dev, &mask);
-       if (ret)
-               return -EINVAL;
-
        /*
         * See if there is no buffered operation in progess. If there is, simply
         * bail out. This can be improved to support both buffered and raw IO at
@@ -661,12 +654,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
 {
        int ret;
        struct iio_trigger *trig;
+       struct mxs_lradc *lradc = iio_priv(iio);
 
        trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
        if (trig == NULL)
                return -ENOMEM;
 
-       trig->dev.parent = iio->dev.parent;
+       trig->dev.parent = lradc->dev;
        iio_trigger_set_drvdata(trig, iio);
        trig->ops = &mxs_lradc_trigger_ops;
 
@@ -676,15 +670,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
                return ret;
        }
 
-       iio->trig = trig;
+       lradc->trig = trig;
 
        return 0;
 }
 
 static void mxs_lradc_trigger_remove(struct iio_dev *iio)
 {
-       iio_trigger_unregister(iio->trig);
-       iio_trigger_free(iio->trig);
+       struct mxs_lradc *lradc = iio_priv(iio);
+
+       iio_trigger_unregister(lradc->trig);
+       iio_trigger_free(lradc->trig);
 }
 
 static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
index 22339059837ff34a15919ca319ede0e0bb1bbf9f..bd0f2fd01db4be91e4f16709c1d788ab1ec2336f 100644 (file)
@@ -33,7 +33,6 @@ config DRM_IMX_TVE
 config DRM_IMX_LDB
        tristate "Support for LVDS displays"
        depends on DRM_IMX
-       select OF_VIDEOMODE
        help
          Choose this to enable the internal LVDS Display Bridge (LDB)
          found on i.MX53 and i.MX6 processors.
index 4795f128490636a48909b21816f4985cc66a46c0..0dd08ef51398cabe6164cb90f4280ca401fb996f 100644 (file)
@@ -392,8 +392,11 @@ static int snd_line6_pcm_free(struct snd_device *device)
 */
 static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
 {
-       if (substream->runtime && snd_pcm_running(substream))
+       if (substream->runtime && snd_pcm_running(substream)) {
+               snd_pcm_stream_lock_irq(substream);
                snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
+               snd_pcm_stream_unlock_irq(substream);
+       }
 }
 
 /*
index c191ae20356583a48aaba72526a64c92261c073b..41e88abe47af1f518ddf7f0ac955d8ca0812203e 100644 (file)
@@ -1120,8 +1120,11 @@ static int dbll_rmm_alloc(struct dynamic_loader_allocate *this,
           or DYN_EXTERNAL, then mem granularity information is present
           within the section name - only process if there are at least three
           tokens within the section name (just a minor optimization) */
-       if (count >= 3)
-               strict_strtol(sz_last_token, 10, (long *)&req);
+       if (count >= 3) {
+               status = kstrtos32(sz_last_token, 10, &req);
+               if (status)
+                       goto func_cont;
+       }
 
        if ((req == 0) || (req == 1)) {
                if (strcmp(sz_sec_last_token, "DYN_DARAM") == 0) {
index dcceed29d31ae415818d1fceecc6518cbc017845..81972fa47bebab17ad635a4d855d5cd691f5daad 100644 (file)
@@ -1811,10 +1811,12 @@ static int zcache_comp_init(void)
 #else
        if (*zcache_comp_name != '\0') {
                ret = crypto_has_comp(zcache_comp_name, 0, 0);
-               if (!ret)
+               if (!ret) {
                        pr_info("zcache: %s not supported\n",
                                        zcache_comp_name);
-               goto out;
+                       ret = 1;
+                       goto out;
+               }
        }
        if (!ret)
                strcpy(zcache_comp_name, "lzo");
index 82c7202fd5cc963668dc8e74caf7dfce11e8f66a..e77fb6ea40c905f3cb72571ef3ca424b44b37440 100644 (file)
@@ -527,8 +527,11 @@ static void zram_reset_device(struct zram *zram)
        size_t index;
        struct zram_meta *meta;
 
-       if (!zram->init_done)
+       down_write(&zram->init_lock);
+       if (!zram->init_done) {
+               up_write(&zram->init_lock);
                return;
+       }
 
        meta = zram->meta;
        zram->init_done = 0;
@@ -549,6 +552,7 @@ static void zram_reset_device(struct zram *zram)
 
        zram->disksize = 0;
        set_capacity(zram->disk, 0);
+       up_write(&zram->init_lock);
 }
 
 static void zram_init_device(struct zram *zram, struct zram_meta *meta)
index 5de56f671a9dd207faa954cf1868e7ef21284747..f36950e4134f55deb02e3a6eb172e9481828ea18 100644 (file)
@@ -54,6 +54,8 @@ MODULE_PARM_DESC(notify_delay_ms,
 * is some wrong values returned by cpuid for number of thresholds.
 */
 #define MAX_NUMBER_OF_TRIPS    2
+/* Limit number of package temp zones */
+#define MAX_PKG_TEMP_ZONE_IDS  256
 
 struct phy_dev_entry {
        struct list_head list;
@@ -394,12 +396,16 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
        char buffer[30];
        int thres_count;
        u32 eax, ebx, ecx, edx;
+       u8 *temp;
 
        cpuid(6, &eax, &ebx, &ecx, &edx);
        thres_count = ebx & 0x07;
        if (!thres_count)
                return -ENODEV;
 
+       if (topology_physical_package_id(cpu) > MAX_PKG_TEMP_ZONE_IDS)
+               return -ENODEV;
+
        thres_count = clamp_val(thres_count, 0, MAX_NUMBER_OF_TRIPS);
 
        err = get_tj_max(cpu, &tj_max);
@@ -417,13 +423,14 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
        spin_lock(&pkg_work_lock);
        if (topology_physical_package_id(cpu) > max_phy_id)
                max_phy_id = topology_physical_package_id(cpu);
-       pkg_work_scheduled = krealloc(pkg_work_scheduled,
-                               (max_phy_id+1) * sizeof(u8), GFP_ATOMIC);
-       if (!pkg_work_scheduled) {
+       temp = krealloc(pkg_work_scheduled,
+                       (max_phy_id+1) * sizeof(u8), GFP_ATOMIC);
+       if (!temp) {
                spin_unlock(&pkg_work_lock);
                err = -ENOMEM;
                goto err_ret_free;
        }
+       pkg_work_scheduled = temp;
        pkg_work_scheduled[topology_physical_package_id(cpu)] = 0;
        spin_unlock(&pkg_work_lock);
 
@@ -511,7 +518,7 @@ static int get_core_online(unsigned int cpu)
 
        /* Check if there is already an instance for this package */
        if (!phdev) {
-               if (!cpu_has(c, X86_FEATURE_DTHERM) &&
+               if (!cpu_has(c, X86_FEATURE_DTHERM) ||
                                        !cpu_has(c, X86_FEATURE_PTS))
                        return -ENODEV;
                if (pkg_temp_thermal_device_add(cpu))
@@ -562,7 +569,7 @@ static struct notifier_block pkg_temp_thermal_notifier __refdata = {
 };
 
 static const struct x86_cpu_id __initconst pkg_temp_thermal_ids[] = {
-       { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_DTHERM },
+       { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_PTS },
        {}
 };
 MODULE_DEVICE_TABLE(x86cpu, pkg_temp_thermal_ids);
@@ -592,7 +599,6 @@ static int __init pkg_temp_thermal_init(void)
        return 0;
 
 err_ret:
-       get_online_cpus();
        for_each_online_cpu(i)
                put_core_offline(i);
        put_online_cpus();
index 721904f8efa92b8816665410822b355619679f47..946ddd2b3a541990277aabad488843a429e3e6f5 100644 (file)
@@ -193,7 +193,8 @@ static int __init parse_options(struct early_serial8250_device *device,
        if (options) {
                options++;
                device->baud = simple_strtoul(options, NULL, 0);
-               length = min(strcspn(options, " "), sizeof(device->options));
+               length = min(strcspn(options, " ") + 1,
+                            sizeof(device->options));
                strlcpy(device->options, options, length);
        } else {
                device->baud = probe_baud(port);
index bb91b4713ebdb8c7ba8849cba643d046c5bc9973..2e3ea1a70d7b90768f33f26a39f098eed7df2c12 100644 (file)
@@ -31,9 +31,8 @@ static int __init serial_init_chip(struct parisc_device *dev)
        int err;
 
 #ifdef CONFIG_64BIT
-       extern int iosapic_serial_irq(int cellnum);
        if (!dev->irq && (dev->id.sversion == 0xad))
-               dev->irq = iosapic_serial_irq(dev->mod_index-1);
+               dev->irq = iosapic_serial_irq(dev);
 #endif
 
        if (!dev->irq) {
index 5e3d68917ffed2529c3cd0181d40d7ae95f8ebcd..1456673bcca09b58cc4d1e7c27fd31569b8439bf 100644 (file)
@@ -277,7 +277,7 @@ config SERIAL_TEGRA
        select SERIAL_CORE
        help
          Support for the on-chip UARTs on the NVIDIA Tegra series SOCs
-         providing /dev/ttyHS0, 1, 2, 3 and 4 (note, some machines may not
+         providing /dev/ttyTHS0, 1, 2, 3 and 4 (note, some machines may not
          provide all of these ports, depending on how the serial port
          are enabled). This driver uses the APB DMA to achieve higher baudrate
          and better performance.
index cbf1d155b7b2a8c80ef782443edbf77c0e7f5595..22f280aa4f2c521b5829a6ea5e72b8c05f2265d9 100644 (file)
@@ -773,6 +773,6 @@ module_init(arc_serial_init);
 module_exit(arc_serial_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("plat-arcfpga/uart");
+MODULE_ALIAS("platform:" DRIVER_NAME);
 MODULE_AUTHOR("Vineet Gupta");
 MODULE_DESCRIPTION("ARC(Synopsys) On-Chip(fpga) serial driver");
index 4f5f161896a139852e46f93f30239be979838bda..f85b8e6d0346fc472fbc835b0451a706ce46aab3 100644 (file)
@@ -678,11 +678,18 @@ static void mxs_auart_settermios(struct uart_port *u,
 
 static irqreturn_t mxs_auart_irq_handle(int irq, void *context)
 {
-       u32 istatus, istat;
+       u32 istat;
        struct mxs_auart_port *s = context;
        u32 stat = readl(s->port.membase + AUART_STAT);
 
-       istatus = istat = readl(s->port.membase + AUART_INTR);
+       istat = readl(s->port.membase + AUART_INTR);
+
+       /* ack irq */
+       writel(istat & (AUART_INTR_RTIS
+               | AUART_INTR_TXIS
+               | AUART_INTR_RXIS
+               | AUART_INTR_CTSMIS),
+                       s->port.membase + AUART_INTR_CLR);
 
        if (istat & AUART_INTR_CTSMIS) {
                uart_handle_cts_change(&s->port, stat & AUART_STAT_CTS);
@@ -702,12 +709,6 @@ static irqreturn_t mxs_auart_irq_handle(int irq, void *context)
                istat &= ~AUART_INTR_TXIS;
        }
 
-       writel(istatus & (AUART_INTR_RTIS
-               | AUART_INTR_TXIS
-               | AUART_INTR_RXIS
-               | AUART_INTR_CTSMIS),
-                       s->port.membase + AUART_INTR_CLR);
-
        return IRQ_HANDLED;
 }
 
@@ -850,7 +851,7 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
        struct mxs_auart_port *s;
        struct uart_port *port;
        unsigned int old_ctrl0, old_ctrl2;
-       unsigned int to = 1000;
+       unsigned int to = 20000;
 
        if (co->index >= MXS_AUART_PORTS || co->index < 0)
                return;
@@ -871,18 +872,23 @@ auart_console_write(struct console *co, const char *str, unsigned int count)
 
        uart_console_write(port, str, count, mxs_auart_console_putchar);
 
-       /*
-        * Finally, wait for transmitter to become empty
-        * and restore the TCR
-        */
+       /* Finally, wait for transmitter to become empty ... */
        while (readl(port->membase + AUART_STAT) & AUART_STAT_BUSY) {
+               udelay(1);
                if (!to--)
                        break;
-               udelay(1);
        }
 
-       writel(old_ctrl0, port->membase + AUART_CTRL0);
-       writel(old_ctrl2, port->membase + AUART_CTRL2);
+       /*
+        * ... and restore the TCR if we waited long enough for the transmitter
+        * to be idle. This might keep the transmitter enabled although it is
+        * unused, but that is better than to disable it while it is still
+        * transmitting.
+        */
+       if (!(readl(port->membase + AUART_STAT) & AUART_STAT_BUSY)) {
+               writel(old_ctrl0, port->membase + AUART_CTRL0);
+               writel(old_ctrl2, port->membase + AUART_CTRL2);
+       }
 
        clk_disable(s->clk);
 }
index ff171384ea5256cabcf018c3a3dc839279f71392..dc6e96996ead4796eace1ba3bb4b61232f132302 100644 (file)
@@ -3478,7 +3478,7 @@ static int alloc_buf_list(SLMP_INFO *info)
        for ( i = 0; i < info->rx_buf_count; i++ ) {
                /* calculate and store physical address of this buffer entry */
                info->rx_buf_list_ex[i].phys_entry =
-                       info->buffer_list_phys + (i * sizeof(SCABUFSIZE));
+                       info->buffer_list_phys + (i * SCABUFSIZE);
 
                /* calculate and store physical address of */
                /* next entry in cirular list of entries */
index 121aeb9393e1172e75fe5972a7c4b8ab4640557f..f597e88a705d1fa8e65cf36ae98a61f84f20b9a3 100644 (file)
@@ -256,10 +256,9 @@ void tty_port_tty_hangup(struct tty_port *port, bool check_clocal)
 {
        struct tty_struct *tty = tty_port_tty_get(port);
 
-       if (tty && (!check_clocal || !C_CLOCAL(tty))) {
+       if (tty && (!check_clocal || !C_CLOCAL(tty)))
                tty_hangup(tty);
-               tty_kref_put(tty);
-       }
+       tty_kref_put(tty);
 }
 EXPORT_SYMBOL_GPL(tty_port_tty_hangup);
 
index eb2aa2e5a842f48eae096d29e279572982e215b8..d1bd8ef1f9c1d48b7e0566220149deaf0de10da4 100644 (file)
@@ -12,7 +12,7 @@ if USB_CHIPIDEA
 
 config USB_CHIPIDEA_UDC
        bool "ChipIdea device controller"
-       depends on USB_GADGET=y || USB_CHIPIDEA=m
+       depends on USB_GADGET=y || (USB_CHIPIDEA=m && USB_GADGET=m)
        help
          Say Y here to enable device controller functionality of the
          ChipIdea driver.
@@ -20,7 +20,7 @@ config USB_CHIPIDEA_UDC
 config USB_CHIPIDEA_HOST
        bool "ChipIdea host controller"
        depends on USB=y
-       depends on USB_EHCI_HCD=y || USB_CHIPIDEA=m
+       depends on USB_EHCI_HCD=y || (USB_CHIPIDEA=m && USB_EHCI_HCD=m)
        select USB_EHCI_ROOT_HUB_TT
        help
          Say Y here to enable host controller functionality of the
index aefa0261220c048322a62059ddc35f9df047e7bb..1b23e354f9fb371f5851206b58944b0221109600 100644 (file)
@@ -50,7 +50,7 @@
 #define PORTSC_PTC            (0x0FUL << 16)
 /* PTS and PTW for non lpm version only */
 #define PORTSC_PTS(d)                                          \
-       ((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
+       (u32)((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0))
 #define PORTSC_PTW            BIT(28)
 #define PORTSC_STS            BIT(29)
 
@@ -59,7 +59,7 @@
 #define DEVLC_PSPD_HS         (0x02UL << 25)
 #define DEVLC_PTW             BIT(27)
 #define DEVLC_STS             BIT(28)
-#define DEVLC_PTS(d)          (((d) & 0x7) << 29)
+#define DEVLC_PTS(d)          (u32)(((d) & 0x7) << 29)
 
 /* Encoding for DEVLC_PTS and PORTSC_PTS */
 #define PTS_UTMI              0
index 609dbc2f7151d52a08cf2f7b62d229637491ce55..83b4ef4dfcf80c71248555c5378c082182235bcf 100644 (file)
@@ -1119,11 +1119,11 @@ static int usbtmc_probe(struct usb_interface *intf,
        /* Determine if it is a Rigol or not */
        data->rigol_quirk = 0;
        dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk\n",
-               data->usb_dev->descriptor.idVendor,
-               data->usb_dev->descriptor.idProduct);
+               le16_to_cpu(data->usb_dev->descriptor.idVendor),
+               le16_to_cpu(data->usb_dev->descriptor.idProduct));
        for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) {
-               if ((usbtmc_id_quirk[n].idVendor == data->usb_dev->descriptor.idVendor) &&
-                   (usbtmc_id_quirk[n].idProduct == data->usb_dev->descriptor.idProduct)) {
+               if ((usbtmc_id_quirk[n].idVendor == le16_to_cpu(data->usb_dev->descriptor.idVendor)) &&
+                   (usbtmc_id_quirk[n].idProduct == le16_to_cpu(data->usb_dev->descriptor.idProduct))) {
                        dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk\n");
                        data->rigol_quirk = 1;
                        break;
index 4191db32f12c2ccf4901287c6ccb1a357c9b552a..558313de49111025e03c1b6b6d015a2688800498 100644 (file)
@@ -668,6 +668,15 @@ resubmit:
 static inline int
 hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
 {
+       /* Need to clear both directions for control ep */
+       if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) ==
+                       USB_ENDPOINT_XFER_CONTROL) {
+               int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
+                               HUB_CLEAR_TT_BUFFER, USB_RT_PORT,
+                               devinfo ^ 0x8000, tt, NULL, 0, 1000);
+               if (status)
+                       return status;
+       }
        return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
                               HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo,
                               tt, NULL, 0, 1000);
@@ -2848,6 +2857,15 @@ static int usb_disable_function_remotewakeup(struct usb_device *udev)
                                USB_CTRL_SET_TIMEOUT);
 }
 
+/* Count of wakeup-enabled devices at or below udev */
+static unsigned wakeup_enabled_descendants(struct usb_device *udev)
+{
+       struct usb_hub *hub = usb_hub_to_struct_hub(udev);
+
+       return udev->do_remote_wakeup +
+                       (hub ? hub->wakeup_enabled_descendants : 0);
+}
+
 /*
  * usb_port_suspend - suspend a usb device's upstream port
  * @udev: device that's no longer in active use, not a root hub
@@ -2888,8 +2906,8 @@ static int usb_disable_function_remotewakeup(struct usb_device *udev)
  * Linux (2.6) currently has NO mechanisms to initiate that:  no khubd
  * timer, no SRP, no requests through sysfs.
  *
- * If Runtime PM isn't enabled or used, non-SuperSpeed devices really get
- * suspended only when their bus goes into global suspend (i.e., the root
+ * If Runtime PM isn't enabled or used, non-SuperSpeed devices may not get
+ * suspended until their bus goes into global suspend (i.e., the root
  * hub is suspended).  Nevertheless, we change @udev->state to
  * USB_STATE_SUSPENDED as this is the device's "logical" state.  The actual
  * upstream port setting is stored in @udev->port_is_suspended.
@@ -2960,15 +2978,21 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
        /* see 7.1.7.6 */
        if (hub_is_superspeed(hub->hdev))
                status = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_U3);
-       else if (PMSG_IS_AUTO(msg))
-               status = set_port_feature(hub->hdev, port1,
-                                               USB_PORT_FEAT_SUSPEND);
+
        /*
         * For system suspend, we do not need to enable the suspend feature
         * on individual USB-2 ports.  The devices will automatically go
         * into suspend a few ms after the root hub stops sending packets.
         * The USB 2.0 spec calls this "global suspend".
+        *
+        * However, many USB hubs have a bug: They don't relay wakeup requests
+        * from a downstream port if the port's suspend feature isn't on.
+        * Therefore we will turn on the suspend feature if udev or any of its
+        * descendants is enabled for remote wakeup.
         */
+       else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0)
+               status = set_port_feature(hub->hdev, port1,
+                               USB_PORT_FEAT_SUSPEND);
        else {
                really_suspend = false;
                status = 0;
@@ -3003,15 +3027,16 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
                if (!PMSG_IS_AUTO(msg))
                        status = 0;
        } else {
-               /* device has up to 10 msec to fully suspend */
                dev_dbg(&udev->dev, "usb %ssuspend, wakeup %d\n",
                                (PMSG_IS_AUTO(msg) ? "auto-" : ""),
                                udev->do_remote_wakeup);
-               usb_set_device_state(udev, USB_STATE_SUSPENDED);
                if (really_suspend) {
                        udev->port_is_suspended = 1;
+
+                       /* device has up to 10 msec to fully suspend */
                        msleep(10);
                }
+               usb_set_device_state(udev, USB_STATE_SUSPENDED);
        }
 
        /*
@@ -3293,7 +3318,11 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
        unsigned                port1;
        int                     status;
 
-       /* Warn if children aren't already suspended */
+       /*
+        * Warn if children aren't already suspended.
+        * Also, add up the number of wakeup-enabled descendants.
+        */
+       hub->wakeup_enabled_descendants = 0;
        for (port1 = 1; port1 <= hdev->maxchild; port1++) {
                struct usb_device       *udev;
 
@@ -3303,6 +3332,9 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
                        if (PMSG_IS_AUTO(msg))
                                return -EBUSY;
                }
+               if (udev)
+                       hub->wakeup_enabled_descendants +=
+                                       wakeup_enabled_descendants(udev);
        }
 
        if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) {
@@ -4766,7 +4798,8 @@ static void hub_events(void)
                                        hub->ports[i - 1]->child;
 
                                dev_dbg(hub_dev, "warm reset port %d\n", i);
-                               if (!udev) {
+                               if (!udev || !(portstatus &
+                                               USB_PORT_STAT_CONNECTION)) {
                                        status = hub_port_reset(hub, i,
                                                        NULL, HUB_BH_RESET_TIME,
                                                        true);
@@ -4776,8 +4809,8 @@ static void hub_events(void)
                                        usb_lock_device(udev);
                                        status = usb_reset_device(udev);
                                        usb_unlock_device(udev);
+                                       connect_change = 0;
                                }
-                               connect_change = 0;
                        }
 
                        if (connect_change)
index 6508e02b3dac91718c31dda7e90b6984fed0c898..4e4790dea3439fc10a57b9fac30f73d77245fdf8 100644 (file)
@@ -59,6 +59,9 @@ struct usb_hub {
        struct usb_tt           tt;             /* Transaction Translator */
 
        unsigned                mA_per_port;    /* current for each child */
+#ifdef CONFIG_PM
+       unsigned                wakeup_enabled_descendants;
+#endif
 
        unsigned                limited_power:1;
        unsigned                quiescing:1;
index a63598895077ff8c984c0ed473d5ee90afa52086..5b44cd47da5b28b30046bead355aa54eda3eec0f 100644 (file)
@@ -78,6 +78,12 @@ static const struct usb_device_id usb_quirk_list[] = {
        { USB_DEVICE(0x04d8, 0x000c), .driver_info =
                        USB_QUIRK_CONFIG_INTF_STRINGS },
 
+       /* CarrolTouch 4000U */
+       { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
+
+       /* CarrolTouch 4500U */
+       { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
+
        /* Samsung Android phone modem - ID conflict with SPH-I500 */
        { USB_DEVICE(0x04e8, 0x6601), .driver_info =
                        USB_QUIRK_CONFIG_INTF_STRINGS },
index 757aa18027d05ca0eb198d97d92f1710e8e58def..2378958ea63e01426edbda87183674256a4334ff 100644 (file)
@@ -1,6 +1,6 @@
 config USB_DWC3
        tristate "DesignWare USB3 DRD Core Support"
-       depends on (USB || USB_GADGET) && GENERIC_HARDIRQS
+       depends on (USB || USB_GADGET) && GENERIC_HARDIRQS && HAS_DMA
        select USB_XHCI_PLATFORM if USB_SUPPORT && USB_XHCI_HCD
        help
          Say Y or M here if your system has a Dual Role SuperSpeed
index c35d49d39b7615f83e7e71a9f009643e33c8d760..358375e0b291098d8be40d65bdfbbff7f97f0826 100644 (file)
@@ -450,7 +450,7 @@ static int dwc3_probe(struct platform_device *pdev)
        }
 
        if (IS_ERR(dwc->usb3_phy)) {
-               ret = PTR_ERR(dwc->usb2_phy);
+               ret = PTR_ERR(dwc->usb3_phy);
 
                /*
                 * if -ENXIO is returned, it means PHY layer wasn't
index b69d322e3cab51c4bcdb784d8f0e3eeda66028e2..27dad993b00706ef5a14a257c40bd353ca6ee560 100644 (file)
@@ -759,8 +759,8 @@ struct dwc3 {
 
 struct dwc3_event_type {
        u32     is_devspec:1;
-       u32     type:6;
-       u32     reserved8_31:25;
+       u32     type:7;
+       u32     reserved8_31:24;
 } __packed;
 
 #define DWC3_DEPEVT_XFERCOMPLETE       0x01
index b5e5b35df49c8ff49ca5817ced0838e79dad9ccf..f77083fedc68d0d1bfc7afb579e6aae96edb1d63 100644 (file)
@@ -1584,6 +1584,7 @@ err1:
        __dwc3_gadget_ep_disable(dwc->eps[0]);
 
 err0:
+       dwc->gadget_driver = NULL;
        spin_unlock_irqrestore(&dwc->lock, flags);
 
        return ret;
index 62f6802f6e0fd98bec3aa03abe3d0fff4a1ee191..8e9368330b103a60cc7fb53be21991315c489fd8 100644 (file)
@@ -193,6 +193,7 @@ config USB_FUSB300
           Faraday usb device controller FUSB300 driver
 
 config USB_FOTG210_UDC
+       depends on HAS_DMA
        tristate "Faraday FOTG210 USB Peripheral Controller"
        help
           Faraday USB2.0 OTG controller which can be configured as
@@ -328,13 +329,14 @@ config USB_S3C_HSUDC
 
 config USB_MV_UDC
        tristate "Marvell USB2.0 Device Controller"
-       depends on GENERIC_HARDIRQS
+       depends on GENERIC_HARDIRQS && HAS_DMA
        help
          Marvell Socs (including PXA and MMP series) include a high speed
          USB2.0 OTG controller, which can be configured as high speed or
          full speed USB peripheral.
 
 config USB_MV_U3D
+       depends on HAS_DMA
        tristate "MARVELL PXA2128 USB 3.0 controller"
        help
          MARVELL PXA2128 Processor series include a super speed USB3.0 device
@@ -639,6 +641,7 @@ config USB_CONFIGFS_RNDIS
        depends on USB_CONFIGFS
        depends on NET
        select USB_U_ETHER
+       select USB_U_RNDIS
        select USB_F_RNDIS
        help
           Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
index 073b938f913546793d24443a89dc928982eecaaa..d9a6add0c8526e06778addb733ce3e53da78a291 100644 (file)
@@ -870,8 +870,8 @@ static void clk_on(struct at91_udc *udc)
        if (udc->clocked)
                return;
        udc->clocked = 1;
-       clk_enable(udc->iclk);
-       clk_enable(udc->fclk);
+       clk_prepare_enable(udc->iclk);
+       clk_prepare_enable(udc->fclk);
 }
 
 static void clk_off(struct at91_udc *udc)
@@ -880,8 +880,8 @@ static void clk_off(struct at91_udc *udc)
                return;
        udc->clocked = 0;
        udc->gadget.speed = USB_SPEED_UNKNOWN;
-       clk_disable(udc->fclk);
-       clk_disable(udc->iclk);
+       clk_disable_unprepare(udc->fclk);
+       clk_disable_unprepare(udc->iclk);
 }
 
 /*
@@ -1725,7 +1725,7 @@ static int at91udc_probe(struct platform_device *pdev)
        /* init software state */
        udc = &controller;
        udc->gadget.dev.parent = dev;
-       if (pdev->dev.of_node)
+       if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
                at91udc_of_init(udc, pdev->dev.of_node);
        else
                memcpy(&udc->board, dev->platform_data,
@@ -1782,12 +1782,14 @@ static int at91udc_probe(struct platform_device *pdev)
        }
 
        /* don't do anything until we have both gadget driver and VBUS */
-       clk_enable(udc->iclk);
+       retval = clk_prepare_enable(udc->iclk);
+       if (retval)
+               goto fail1;
        at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
        at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff);
        /* Clear all pending interrupts - UDP may be used by bootloader. */
        at91_udp_write(udc, AT91_UDP_ICR, 0xffffffff);
-       clk_disable(udc->iclk);
+       clk_disable_unprepare(udc->iclk);
 
        /* request UDC and maybe VBUS irqs */
        udc->udp_irq = platform_get_irq(pdev, 0);
index f48712ffe261470487f7be0476ad7d89d8a808cf..c1c113ef950c86d9c4170cebaa47a91426cf74fa 100644 (file)
@@ -449,14 +449,20 @@ fail:
 
 static int __exit eth_unbind(struct usb_composite_dev *cdev)
 {
-       if (has_rndis())
+       if (has_rndis()) {
+               usb_put_function(f_rndis);
                usb_put_function_instance(fi_rndis);
-       if (use_eem)
+       }
+       if (use_eem) {
+               usb_put_function(f_eem);
                usb_put_function_instance(fi_eem);
-       else if (can_support_ecm(cdev->gadget))
+       } else if (can_support_ecm(cdev->gadget)) {
+               usb_put_function(f_ecm);
                usb_put_function_instance(fi_ecm);
-       else
+       } else {
+               usb_put_function(f_geth);
                usb_put_function_instance(fi_geth);
+       }
        return 0;
 }
 
index 5d3561ea1c1595ea30f07bc3ad35253647701d97..edab45da37417e16960b75033a46a8453475b77b 100644 (file)
@@ -959,8 +959,11 @@ static struct usb_function_instance *ecm_alloc_inst(void)
        mutex_init(&opts->lock);
        opts->func_inst.free_func_inst = ecm_free_inst;
        opts->net = gether_setup_default();
-       if (IS_ERR(opts->net))
-               return ERR_PTR(PTR_ERR(opts->net));
+       if (IS_ERR(opts->net)) {
+               struct net_device *net = opts->net;
+               kfree(opts);
+               return ERR_CAST(net);
+       }
 
        config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type);
 
index 90ee8022e8d80c29fbff9a1298d62c13ec869b42..d00392d879db3aa3e75d093d4e26041fa42bcb54 100644 (file)
@@ -593,8 +593,11 @@ static struct usb_function_instance *eem_alloc_inst(void)
        mutex_init(&opts->lock);
        opts->func_inst.free_func_inst = eem_free_inst;
        opts->net = gether_setup_default();
-       if (IS_ERR(opts->net))
-               return ERR_CAST(opts->net);
+       if (IS_ERR(opts->net)) {
+               struct net_device *net = opts->net;
+               kfree(opts);
+               return ERR_CAST(net);
+       }
 
        config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
 
index 952177f7eb9b40e8045bfa85730239ab22efd97c..1c28fe13328a13935a3976ecc409cba113a81221 100644 (file)
@@ -1350,8 +1350,11 @@ static struct usb_function_instance *ncm_alloc_inst(void)
        mutex_init(&opts->lock);
        opts->func_inst.free_func_inst = ncm_free_inst;
        opts->net = gether_setup_default();
-       if (IS_ERR(opts->net))
-               return ERR_PTR(PTR_ERR(opts->net));
+       if (IS_ERR(opts->net)) {
+               struct net_device *net = opts->net;
+               kfree(opts);
+               return ERR_CAST(net);
+       }
 
        config_group_init_type_name(&opts->func_inst.group, "", &ncm_func_type);
 
index 7944fb0efe3b6a67471e7379a03a5d8ebc9b23fb..eb3aa817a662616810a4c9d9c6232c1e8f2a2e2f 100644 (file)
@@ -488,7 +488,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f)
        struct usb_ep *ep;
        int status, i;
 
-#ifndef USBF_PHONET_INCLUDED
        struct f_phonet_opts *phonet_opts;
 
        phonet_opts = container_of(f->fi, struct f_phonet_opts, func_inst);
@@ -507,7 +506,6 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f)
                        return status;
                phonet_opts->bound = true;
        }
-#endif
 
        /* Reserve interface IDs */
        status = usb_interface_id(c, f);
@@ -656,8 +654,11 @@ static struct usb_function_instance *phonet_alloc_inst(void)
 
        opts->func_inst.free_func_inst = phonet_free_inst;
        opts->net = gphonet_setup_default();
-       if (IS_ERR(opts->net))
-               return ERR_PTR(PTR_ERR(opts->net));
+       if (IS_ERR(opts->net)) {
+               struct net_device *net = opts->net;
+               kfree(opts);
+               return ERR_CAST(net);
+       }
 
        config_group_init_type_name(&opts->func_inst.group, "",
                        &phonet_func_type);
index 191df35ae69d04e31c6fc70ac7d76f2b4ff83be3..717ed7f956395412bf5d6da1d605921c71b82532 100644 (file)
@@ -963,8 +963,11 @@ static struct usb_function_instance *rndis_alloc_inst(void)
        mutex_init(&opts->lock);
        opts->func_inst.free_func_inst = rndis_free_inst;
        opts->net = gether_setup_default();
-       if (IS_ERR(opts->net))
-               return ERR_CAST(opts->net);
+       if (IS_ERR(opts->net)) {
+               struct net_device *net = opts->net;
+               kfree(opts);
+               return ERR_CAST(net);
+       }
 
        config_group_init_type_name(&opts->func_inst.group, "",
                                    &rndis_func_type);
index 5601e1d96c4fabd7f8a44bc80703080495fba56a..7c8674fa7e8094074aa794fe9407e2adeab7548a 100644 (file)
@@ -505,8 +505,11 @@ static struct usb_function_instance *geth_alloc_inst(void)
        mutex_init(&opts->lock);
        opts->func_inst.free_func_inst = geth_free_inst;
        opts->net = gether_setup_default();
-       if (IS_ERR(opts->net))
-               return ERR_CAST(opts->net);
+       if (IS_ERR(opts->net)) {
+               struct net_device *net = opts->net;
+               kfree(opts);
+               return ERR_CAST(net);
+       }
 
        config_group_init_type_name(&opts->func_inst.group, "",
                                    &gether_func_type);
index cce5535b1dc6744f86a2a3c88d35c756ef4335cd..10cd18ddd0d40207f2d33bd94e41dff040c842f2 100644 (file)
@@ -1074,7 +1074,7 @@ static struct usb_gadget_ops fotg210_gadget_ops = {
        .udc_stop               = fotg210_udc_stop,
 };
 
-static int __exit fotg210_udc_remove(struct platform_device *pdev)
+static int fotg210_udc_remove(struct platform_device *pdev)
 {
        struct fotg210_udc *fotg210 = dev_get_drvdata(&pdev->dev);
 
@@ -1088,7 +1088,7 @@ static int __exit fotg210_udc_remove(struct platform_device *pdev)
        return 0;
 }
 
-static int __init fotg210_udc_probe(struct platform_device *pdev)
+static int fotg210_udc_probe(struct platform_device *pdev)
 {
        struct resource *res, *ires;
        struct fotg210_udc *fotg210 = NULL;
index 032b96a51ce4e06a517f35070542067a002275e2..2a1ebefd8f9eb31318fc861fbc010214148db18d 100644 (file)
@@ -160,10 +160,8 @@ static __init int rndis_do_config(struct usb_configuration *c)
                return ret;
 
        f_acm_rndis = usb_get_function(fi_acm);
-       if (IS_ERR(f_acm_rndis)) {
-               ret = PTR_ERR(f_acm_rndis);
-               goto err_func_acm;
-       }
+       if (IS_ERR(f_acm_rndis))
+               return PTR_ERR(f_acm_rndis);
 
        ret = usb_add_function(c, f_acm_rndis);
        if (ret)
@@ -178,7 +176,6 @@ err_fsg:
        usb_remove_function(c, f_acm_rndis);
 err_conf:
        usb_put_function(f_acm_rndis);
-err_func_acm:
        return ret;
 }
 
@@ -226,7 +223,7 @@ static __init int cdc_do_config(struct usb_configuration *c)
        /* implicit port_num is zero */
        f_acm_multi = usb_get_function(fi_acm);
        if (IS_ERR(f_acm_multi))
-               goto err_func_acm;
+               return PTR_ERR(f_acm_multi);
 
        ret = usb_add_function(c, f_acm_multi);
        if (ret)
@@ -241,7 +238,6 @@ err_fsg:
        usb_remove_function(c, f_acm_multi);
 err_conf:
        usb_put_function(f_acm_multi);
-err_func_acm:
        return ret;
 }
 
index 07fdb3eaf48a4fd1be386e346e6e9fccc53e78ce..ec6a2d2903988ffb7a23aa12b63b0f95fd4f601a 100644 (file)
@@ -1776,7 +1776,7 @@ static int mv_u3d_remove(struct platform_device *dev)
        kfree(u3d->eps);
 
        if (u3d->irq)
-               free_irq(u3d->irq, &dev->dev);
+               free_irq(u3d->irq, u3d);
 
        if (u3d->cap_regs)
                iounmap(u3d->cap_regs);
@@ -1974,7 +1974,7 @@ static int mv_u3d_probe(struct platform_device *dev)
        return 0;
 
 err_unregister:
-       free_irq(u3d->irq, &dev->dev);
+       free_irq(u3d->irq, u3d);
 err_request_irq:
 err_get_irq:
        kfree(u3d->status_req);
index ffd8fa5411015f823bc5701777e20cd928848f56..13e25f80fc201f347784ace2f35c7003850f381a 100644 (file)
@@ -50,6 +50,8 @@ static DEFINE_MUTEX(udc_lock);
 
 /* ------------------------------------------------------------------------- */
 
+#ifdef CONFIG_HAS_DMA
+
 int usb_gadget_map_request(struct usb_gadget *gadget,
                struct usb_request *req, int is_in)
 {
@@ -99,13 +101,15 @@ void usb_gadget_unmap_request(struct usb_gadget *gadget,
 }
 EXPORT_SYMBOL_GPL(usb_gadget_unmap_request);
 
+#endif /* CONFIG_HAS_DMA */
+
 /* ------------------------------------------------------------------------- */
 
 void usb_gadget_set_state(struct usb_gadget *gadget,
                enum usb_device_state state)
 {
        gadget->state = state;
-       sysfs_notify(&gadget->dev.kobj, NULL, "status");
+       sysfs_notify(&gadget->dev.kobj, NULL, "state");
 }
 EXPORT_SYMBOL_GPL(usb_gadget_set_state);
 
@@ -194,9 +198,11 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
        dev_set_name(&gadget->dev, "gadget");
        gadget->dev.parent = parent;
 
+#ifdef CONFIG_HAS_DMA
        dma_set_coherent_mask(&gadget->dev, parent->coherent_dma_mask);
        gadget->dev.dma_parms = parent->dma_parms;
        gadget->dev.dma_mask = parent->dma_mask;
+#endif
 
        if (release)
                gadget->dev.release = release;
index 2b702772d04d3353cc570c340f04c9701fa11210..6dce37555c4f6303b5efa657af88096db2b2140e 100644 (file)
@@ -874,6 +874,7 @@ static int ehci_hub_control (
                                ehci->reset_done[wIndex] = jiffies
                                                + msecs_to_jiffies(20);
                                usb_hcd_start_port_resume(&hcd->self, wIndex);
+                               set_bit(wIndex, &ehci->resuming_ports);
                                /* check the port again */
                                mod_timer(&ehci_to_hcd(ehci)->rh_timer,
                                                ehci->reset_done[wIndex]);
index f80d0330d548d36564e9332d60392c9671360263..8e3c878f38cf57e64cb24c25a992b59e184ce322 100644 (file)
@@ -1391,21 +1391,20 @@ iso_stream_schedule (
 
                /* Behind the scheduling threshold? */
                if (unlikely(start < next)) {
+                       unsigned now2 = (now - base) & (mod - 1);
 
                        /* USB_ISO_ASAP: Round up to the first available slot */
                        if (urb->transfer_flags & URB_ISO_ASAP)
                                start += (next - start + period - 1) & -period;
 
                        /*
-                        * Not ASAP: Use the next slot in the stream.  If
-                        * the entire URB falls before the threshold, fail.
+                        * Not ASAP: Use the next slot in the stream,
+                        * no matter what.
                         */
-                       else if (start + span - period < next) {
-                               ehci_dbg(ehci, "iso urb late %p (%u+%u < %u)\n",
+                       else if (start + span - period < now2) {
+                               ehci_dbg(ehci, "iso underrun %p (%u+%u < %u)\n",
                                                urb, start + base,
-                                               span - period, next + base);
-                               status = -EXDEV;
-                               goto fail;
+                                               span - period, now2 + base);
                        }
                }
 
index 4b8a2092432f8911b5d73053e34b135041fd0e4d..978c849f9c9a1ef9631d86fa80ccea93371f61ea 100644 (file)
@@ -13,6 +13,7 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev);
 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
 void sb800_prefetch(struct device *dev, int on);
 #else
+struct pci_dev;
 static inline void usb_amd_quirk_pll_disable(void) {}
 static inline void usb_amd_quirk_pll_enable(void) {}
 static inline void usb_amd_dev_put(void) {}
index df6978abd7e6f756c6d81ebeef324473e7f36a87..6f8c2fd47675dc2432902f5fbf8b4cfec8a306de 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/dmapool.h>
+#include <linux/dma-mapping.h>
 
 #include "xhci.h"
 
index cc24e39b97d5b8b2bdf7faada7f7767b4f8013c2..f00cb203faea569b2e87e79e8371455a7abd77b4 100644 (file)
@@ -93,7 +93,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
        }
        if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
                        pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) {
-               xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
                xhci->quirks |= XHCI_EP_LIMIT_QUIRK;
                xhci->limit_active_eps = 64;
                xhci->quirks |= XHCI_SW_BW_CHECKING;
index 1e57eafa69101aaee797b7890020c66865ef4c16..5b08cd85f8e7fe9646228da946166dfb188c10d2 100644 (file)
@@ -434,7 +434,7 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
 
        /* A ring has pending URBs if its TD list is not empty */
        if (!(ep->ep_state & EP_HAS_STREAMS)) {
-               if (!(list_empty(&ep->ring->td_list)))
+               if (ep->ring && !(list_empty(&ep->ring->td_list)))
                        xhci_ring_ep_doorbell(xhci, slot_id, ep_index, 0);
                return;
        }
index 2c49f00260ca2ad9cd0e79bb3078dbd25bb864d6..9478caa2f71fb12912ddea1bfa06f37580e7c3ce 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
 #include <linux/dmi.h>
+#include <linux/dma-mapping.h>
 
 #include "xhci.h"
 
@@ -329,7 +330,7 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
        return;
 }
 
-static void xhci_msix_sync_irqs(struct xhci_hcd *xhci)
+static void __maybe_unused xhci_msix_sync_irqs(struct xhci_hcd *xhci)
 {
        int i;
 
@@ -1181,9 +1182,6 @@ static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
        }
 
        xhci = hcd_to_xhci(hcd);
-       if (xhci->xhc_state & XHCI_STATE_HALTED)
-               return -ENODEV;
-
        if (check_virt_dev) {
                if (!udev->slot_id || !xhci->devs[udev->slot_id]) {
                        printk(KERN_DEBUG "xHCI %s called with unaddressed "
@@ -1199,6 +1197,9 @@ static int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
                }
        }
 
+       if (xhci->xhc_state & XHCI_STATE_HALTED)
+               return -ENODEV;
+
        return 1;
 }
 
@@ -3898,7 +3899,7 @@ int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1)
  * Issue an Evaluate Context command to change the Maximum Exit Latency in the
  * slot context.  If that succeeds, store the new MEL in the xhci_virt_device.
  */
-static int xhci_change_max_exit_latency(struct xhci_hcd *xhci,
+static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
                        struct usb_device *udev, u16 max_exit_latency)
 {
        struct xhci_virt_device *virt_dev;
@@ -4892,6 +4893,13 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
 
        get_quirks(dev, xhci);
 
+       /* In xhci controllers which follow xhci 1.0 spec gives a spurious
+        * success event after a short transfer. This quirk will ignore such
+        * spurious event.
+        */
+       if (xhci->hci_version > 0x96)
+               xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
+
        /* Make sure the HC is halted. */
        retval = xhci_halt(xhci);
        if (retval)
index eb3c8c142fa988de1aaaee07d036e93554bb48a3..eeb27208c0d153de863f16ba12e62d0222e8c5d3 100644 (file)
@@ -830,7 +830,7 @@ static int adu_probe(struct usb_interface *interface,
 
        /* let the user know what node this device is now attached to */
        dev_info(&interface->dev, "ADU%d %s now attached to /dev/usb/adutux%d\n",
-                udev->descriptor.idProduct, dev->serial_number,
+                le16_to_cpu(udev->descriptor.idProduct), dev->serial_number,
                 (dev->minor - ADU_MINOR_BASE));
 exit:
        dbg(2, " %s : leave, return value %p (dev)", __func__, dev);
index c21386ec5d35d142b7d0d84abe2e3f3cb5be7125..de98906f786d08ebac625b3cc8213de5d79cf68e 100644 (file)
@@ -3247,6 +3247,7 @@ static const struct usb_device_id sisusb_table[] = {
        { USB_DEVICE(0x0711, 0x0903) },
        { USB_DEVICE(0x0711, 0x0918) },
        { USB_DEVICE(0x0711, 0x0920) },
+       { USB_DEVICE(0x0711, 0x0950) },
        { USB_DEVICE(0x182d, 0x021c) },
        { USB_DEVICE(0x182d, 0x0269) },
        { }
index 6708a3b78ad8b3d06130dabefe2c2e11e78fa106..f44e8b5e00c94b3b22ddf06b632041e0c462b060 100644 (file)
@@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32);
 
 static int omap2430_probe(struct platform_device *pdev)
 {
-       struct resource                 musb_resources[2];
+       struct resource                 musb_resources[3];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct omap_musb_board_data     *data;
        struct platform_device          *musb;
@@ -581,6 +581,11 @@ static int omap2430_probe(struct platform_device *pdev)
        musb_resources[1].end = pdev->resource[1].end;
        musb_resources[1].flags = pdev->resource[1].flags;
 
+       musb_resources[2].name = pdev->resource[2].name;
+       musb_resources[2].start = pdev->resource[2].start;
+       musb_resources[2].end = pdev->resource[2].end;
+       musb_resources[2].flags = pdev->resource[2].flags;
+
        ret = platform_device_add_resources(musb, musb_resources,
                        ARRAY_SIZE(musb_resources));
        if (ret) {
index 2c06a8969a9f793153d6f6f0546be9d5eb1ff8a0..6f8a9ca96ae753f31b637d0f0c08c1d27a550699 100644 (file)
@@ -1156,7 +1156,7 @@ static u64 tusb_dmamask = DMA_BIT_MASK(32);
 
 static int tusb_probe(struct platform_device *pdev)
 {
-       struct resource musb_resources[2];
+       struct resource musb_resources[3];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct platform_device          *musb;
        struct tusb6010_glue            *glue;
@@ -1199,6 +1199,11 @@ static int tusb_probe(struct platform_device *pdev)
        musb_resources[1].end = pdev->resource[1].end;
        musb_resources[1].flags = pdev->resource[1].flags;
 
+       musb_resources[2].name = pdev->resource[2].name;
+       musb_resources[2].start = pdev->resource[2].start;
+       musb_resources[2].end = pdev->resource[2].end;
+       musb_resources[2].flags = pdev->resource[2].flags;
+
        ret = platform_device_add_resources(musb, musb_resources,
                        ARRAY_SIZE(musb_resources));
        if (ret) {
index efe6e1464f45b59fb831a9ca5c05361593b3b7a5..a2fb30bbb971c41f76fc8ad1eb358449f0117657 100644 (file)
@@ -71,9 +71,9 @@ static struct usb_dpll_params omap_usb3_dpll_params[NUM_SYS_CLKS] = {
        {1250, 5, 4, 20, 0},            /* 12 MHz */
        {3125, 20, 4, 20, 0},           /* 16.8 MHz */
        {1172, 8, 4, 20, 65537},        /* 19.2 MHz */
+       {1000, 7, 4, 10, 0},            /* 20 MHz */
        {1250, 12, 4, 20, 0},           /* 26 MHz */
        {3125, 47, 4, 20, 92843},       /* 38.4 MHz */
-       {1000, 7, 4, 10, 0},            /* 20 MHz */
 
 };
 
index 1011c16ade7e4b2de81db46d0ab8ddfc599b24bc..758b86d0fcb386af39561d2d25e8ad9983c97fbf 100644 (file)
@@ -388,7 +388,7 @@ static int samsung_usb2phy_probe(struct platform_device *pdev)
                clk = devm_clk_get(dev, "otg");
 
        if (IS_ERR(clk)) {
-               dev_err(dev, "Failed to get otg clock\n");
+               dev_err(dev, "Failed to get usbhost/otg clock\n");
                return PTR_ERR(clk);
        }
 
index ed4949faa70d14502a6669a3fb35b6fb814b35c6..805940c373532bd4d548b5cf4d868ce4d75024ad 100644 (file)
@@ -855,10 +855,6 @@ static int usbhsg_gadget_stop(struct usb_gadget *gadget,
        struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
        struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
 
-       if (!driver             ||
-           !driver->unbind)
-               return -EINVAL;
-
        usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD);
        gpriv->driver = NULL;
 
index 8c3a42ea910cd1d6ef7b503bf4a753f7f521e343..7eef9b33fde66c78405509adf6ca8b461f8045c7 100644 (file)
@@ -719,6 +719,13 @@ config USB_SERIAL_FLASHLOADER
          To compile this driver as a module, choose M here: the
          module will be called flashloader.
 
+config USB_SERIAL_SUUNTO
+       tristate "USB Suunto ANT+ driver"
+       help
+         Say Y here if you want to use the Suunto ANT+ USB device.
+
+         To compile this driver as a module, choose M here: the
+         module will be called suunto.
 
 config USB_SERIAL_DEBUG
        tristate "USB Debugging Device"
index f7130114488f8b95a4ee1c8570c61417cfcdb97b..a14a870d993fe3bc1ea60001c9f1dcb6637c620a 100644 (file)
@@ -54,6 +54,7 @@ obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI)          += siemens_mpi.o
 obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS)                += sierra.o
 obj-$(CONFIG_USB_SERIAL_SPCP8X5)               += spcp8x5.o
 obj-$(CONFIG_USB_SERIAL_SSU100)                        += ssu100.o
+obj-$(CONFIG_USB_SERIAL_SUUNTO)                        += suunto.o
 obj-$(CONFIG_USB_SERIAL_SYMBOL)                        += symbolserial.o
 obj-$(CONFIG_USB_SERIAL_WWAN)                  += usb_wwan.o
 obj-$(CONFIG_USB_SERIAL_TI)                    += ti_usb_3410_5052.o
index d6ef2f8da37dca2f7206f26db7d6269bdf0d13e6..0eae4ba3760ed87f633b0d449a833f1e5109107d 100644 (file)
@@ -53,6 +53,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
        { USB_DEVICE(0x0489, 0xE003) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
        { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */
+       { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */
        { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
        { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
        { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
@@ -118,6 +119,8 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
        { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */
        { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
+       { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
+       { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
        { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
        { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
        { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
@@ -148,6 +151,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
        { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
        { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
+       { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
        { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
        { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
        { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */
index 7260ec66034715e7a065d0f5fe6441f49a37f6b4..b65e657c641da56a1545be79e22a13a9fdad653c 100644 (file)
@@ -735,9 +735,34 @@ static struct usb_device_id id_table_combined [] = {
        { USB_DEVICE(FTDI_VID, FTDI_NDI_AURORA_SCU_PID),
                .driver_info = (kernel_ulong_t)&ftdi_NDI_device_quirk },
        { USB_DEVICE(TELLDUS_VID, TELLDUS_TELLSTICK_PID) },
-       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_SERIAL_VX7_PID) },
-       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_CT29B_PID) },
-       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_RTS01_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S03_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_59_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57A_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_57B_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29A_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29B_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29F_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62B_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S01_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_29C_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_81B_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_82B_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5D_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K4Y_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_K5G_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_S05_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_60_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_61_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_62_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_63B_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_64_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_65_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_92D_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_W5R_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_A5R_PID) },
+       { USB_DEVICE(RTSYSTEMS_VID, RTSYSTEMS_USB_PW1_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_MAXSTREAM_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_PHI_FISCO_PID) },
        { USB_DEVICE(TML_VID, TML_USB_SERIAL_PID) },
index 6dd79253205dd7ec54278ddb078f08346cdbb4f8..1b8af461b522c65a111983226ba1e704f012ac8c 100644 (file)
 /*
  * RT Systems programming cables for various ham radios
  */
-#define RTSYSTEMS_VID                  0x2100  /* Vendor ID */
-#define RTSYSTEMS_SERIAL_VX7_PID       0x9e52  /* Serial converter for VX-7 Radios using FT232RL */
-#define RTSYSTEMS_CT29B_PID            0x9e54  /* CT29B Radio Cable */
-#define RTSYSTEMS_RTS01_PID            0x9e57  /* USB-RTS01 Radio Cable */
-
+#define RTSYSTEMS_VID          0x2100  /* Vendor ID */
+#define RTSYSTEMS_USB_S03_PID  0x9001  /* RTS-03 USB to Serial Adapter */
+#define RTSYSTEMS_USB_59_PID   0x9e50  /* USB-59 USB to 8 pin plug */
+#define RTSYSTEMS_USB_57A_PID  0x9e51  /* USB-57A USB to 4pin 3.5mm plug */
+#define RTSYSTEMS_USB_57B_PID  0x9e52  /* USB-57B USB to extended 4pin 3.5mm plug */
+#define RTSYSTEMS_USB_29A_PID  0x9e53  /* USB-29A USB to 3.5mm stereo plug */
+#define RTSYSTEMS_USB_29B_PID  0x9e54  /* USB-29B USB to 6 pin mini din */
+#define RTSYSTEMS_USB_29F_PID  0x9e55  /* USB-29F USB to 6 pin modular plug */
+#define RTSYSTEMS_USB_62B_PID  0x9e56  /* USB-62B USB to 8 pin mini din plug*/
+#define RTSYSTEMS_USB_S01_PID  0x9e57  /* USB-RTS01 USB to 3.5 mm stereo plug*/
+#define RTSYSTEMS_USB_63_PID   0x9e58  /* USB-63 USB to 9 pin female*/
+#define RTSYSTEMS_USB_29C_PID  0x9e59  /* USB-29C USB to 4 pin modular plug*/
+#define RTSYSTEMS_USB_81B_PID  0x9e5A  /* USB-81 USB to 8 pin mini din plug*/
+#define RTSYSTEMS_USB_82B_PID  0x9e5B  /* USB-82 USB to 2.5 mm stereo plug*/
+#define RTSYSTEMS_USB_K5D_PID  0x9e5C  /* USB-K5D USB to 8 pin modular plug*/
+#define RTSYSTEMS_USB_K4Y_PID  0x9e5D  /* USB-K4Y USB to 2.5/3.5 mm plugs*/
+#define RTSYSTEMS_USB_K5G_PID  0x9e5E  /* USB-K5G USB to 8 pin modular plug*/
+#define RTSYSTEMS_USB_S05_PID  0x9e5F  /* USB-RTS05 USB to 2.5 mm stereo plug*/
+#define RTSYSTEMS_USB_60_PID   0x9e60  /* USB-60 USB to 6 pin din*/
+#define RTSYSTEMS_USB_61_PID   0x9e61  /* USB-61 USB to 6 pin mini din*/
+#define RTSYSTEMS_USB_62_PID   0x9e62  /* USB-62 USB to 8 pin mini din*/
+#define RTSYSTEMS_USB_63B_PID  0x9e63  /* USB-63 USB to 9 pin female*/
+#define RTSYSTEMS_USB_64_PID   0x9e64  /* USB-64 USB to 9 pin male*/
+#define RTSYSTEMS_USB_65_PID   0x9e65  /* USB-65 USB to 9 pin female null modem*/
+#define RTSYSTEMS_USB_92_PID   0x9e66  /* USB-92 USB to 12 pin plug*/
+#define RTSYSTEMS_USB_92D_PID  0x9e67  /* USB-92D USB to 12 pin plug data*/
+#define RTSYSTEMS_USB_W5R_PID  0x9e68  /* USB-W5R USB to 8 pin modular plug*/
+#define RTSYSTEMS_USB_A5R_PID  0x9e69  /* USB-A5R USB to 8 pin modular plug*/
+#define RTSYSTEMS_USB_PW1_PID  0x9e6A  /* USB-PW1 USB to 8 pin modular plug*/
 
 /*
  * Physik Instrumente
index 5a979729f8ec4695a1fa4e4395b86a430184e1c9..58c17fdc85eb77ea40718e7791475d341d34d0d8 100644 (file)
@@ -2303,7 +2303,7 @@ static int keyspan_startup(struct usb_serial *serial)
        if (d_details == NULL) {
                dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
                    __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
-               return 1;
+               return -ENODEV;
        }
 
        /* Setup private data for serial driver */
index 51da424327b0f7c1f64ac90fe482df9e063548ea..b01300164fc03cd26cbc81d62afd5a647c04d8be 100644 (file)
@@ -90,6 +90,7 @@ struct urbtracker {
        struct list_head        urblist_entry;
        struct kref             ref_count;
        struct urb              *urb;
+       struct usb_ctrlrequest  *setup;
 };
 
 enum mos7715_pp_modes {
@@ -271,6 +272,7 @@ static void destroy_urbtracker(struct kref *kref)
        struct mos7715_parport *mos_parport = urbtrack->mos_parport;
 
        usb_free_urb(urbtrack->urb);
+       kfree(urbtrack->setup);
        kfree(urbtrack);
        kref_put(&mos_parport->ref_count, destroy_mos_parport);
 }
@@ -355,7 +357,6 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
        struct urbtracker *urbtrack;
        int ret_val;
        unsigned long flags;
-       struct usb_ctrlrequest setup;
        struct usb_serial *serial = mos_parport->serial;
        struct usb_device *usbdev = serial->dev;
 
@@ -373,14 +374,20 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
                kfree(urbtrack);
                return -ENOMEM;
        }
-       setup.bRequestType = (__u8)0x40;
-       setup.bRequest = (__u8)0x0e;
-       setup.wValue = get_reg_value(reg, dummy);
-       setup.wIndex = get_reg_index(reg);
-       setup.wLength = 0;
+       urbtrack->setup = kmalloc(sizeof(*urbtrack->setup), GFP_KERNEL);
+       if (!urbtrack->setup) {
+               usb_free_urb(urbtrack->urb);
+               kfree(urbtrack);
+               return -ENOMEM;
+       }
+       urbtrack->setup->bRequestType = (__u8)0x40;
+       urbtrack->setup->bRequest = (__u8)0x0e;
+       urbtrack->setup->wValue = get_reg_value(reg, dummy);
+       urbtrack->setup->wIndex = get_reg_index(reg);
+       urbtrack->setup->wLength = 0;
        usb_fill_control_urb(urbtrack->urb, usbdev,
                             usb_sndctrlpipe(usbdev, 0),
-                            (unsigned char *)&setup,
+                            (unsigned char *)urbtrack->setup,
                             NULL, 0, async_complete, urbtrack);
        kref_init(&urbtrack->ref_count);
        INIT_LIST_HEAD(&urbtrack->urblist_entry);
index 0a818b238508e26ab4b1932a844b740ba25c5d3c..3bac4693c03829c9d5ca23d280e8c9b580548e66 100644 (file)
 #define LED_ON_MS      500
 #define LED_OFF_MS     500
 
-static int device_type;
+enum mos7840_flag {
+       MOS7840_FLAG_CTRL_BUSY,
+       MOS7840_FLAG_LED_BUSY,
+};
 
 static const struct usb_device_id id_table[] = {
        {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
@@ -238,9 +241,12 @@ struct moschip_port {
 
        /* For device(s) with LED indicator */
        bool has_led;
-       bool led_flag;
        struct timer_list led_timer1;   /* Timer for LED on */
        struct timer_list led_timer2;   /* Timer for LED off */
+       struct urb *led_urb;
+       struct usb_ctrlrequest *led_dr;
+
+       unsigned long flags;
 };
 
 /*
@@ -460,10 +466,10 @@ static void mos7840_control_callback(struct urb *urb)
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
                dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status);
-               return;
+               goto out;
        default:
                dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
-               return;
+               goto out;
        }
 
        dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
@@ -476,6 +482,8 @@ static void mos7840_control_callback(struct urb *urb)
                mos7840_handle_new_msr(mos7840_port, regval);
        else if (mos7840_port->MsrLsr == 1)
                mos7840_handle_new_lsr(mos7840_port, regval);
+out:
+       clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, &mos7840_port->flags);
 }
 
 static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
@@ -486,6 +494,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
        unsigned char *buffer = mcs->ctrl_buf;
        int ret;
 
+       if (test_and_set_bit_lock(MOS7840_FLAG_CTRL_BUSY, &mcs->flags))
+               return -EBUSY;
+
        dr->bRequestType = MCS_RD_RTYPE;
        dr->bRequest = MCS_RDREQ;
        dr->wValue = cpu_to_le16(Wval); /* 0 */
@@ -497,6 +508,9 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
                             mos7840_control_callback, mcs);
        mcs->control_urb->transfer_buffer_length = 2;
        ret = usb_submit_urb(mcs->control_urb, GFP_ATOMIC);
+       if (ret)
+               clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, &mcs->flags);
+
        return ret;
 }
 
@@ -523,7 +537,7 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval,
                                __u16 reg)
 {
        struct usb_device *dev = mcs->port->serial->dev;
-       struct usb_ctrlrequest *dr = mcs->dr;
+       struct usb_ctrlrequest *dr = mcs->led_dr;
 
        dr->bRequestType = MCS_WR_RTYPE;
        dr->bRequest = MCS_WRREQ;
@@ -531,10 +545,10 @@ static void mos7840_set_led_async(struct moschip_port *mcs, __u16 wval,
        dr->wIndex = cpu_to_le16(reg);
        dr->wLength = cpu_to_le16(0);
 
-       usb_fill_control_urb(mcs->control_urb, dev, usb_sndctrlpipe(dev, 0),
+       usb_fill_control_urb(mcs->led_urb, dev, usb_sndctrlpipe(dev, 0),
                (unsigned char *)dr, NULL, 0, mos7840_set_led_callback, NULL);
 
-       usb_submit_urb(mcs->control_urb, GFP_ATOMIC);
+       usb_submit_urb(mcs->led_urb, GFP_ATOMIC);
 }
 
 static void mos7840_set_led_sync(struct usb_serial_port *port, __u16 reg,
@@ -560,7 +574,19 @@ static void mos7840_led_flag_off(unsigned long arg)
 {
        struct moschip_port *mcs = (struct moschip_port *) arg;
 
-       mcs->led_flag = false;
+       clear_bit_unlock(MOS7840_FLAG_LED_BUSY, &mcs->flags);
+}
+
+static void mos7840_led_activity(struct usb_serial_port *port)
+{
+       struct moschip_port *mos7840_port = usb_get_serial_port_data(port);
+
+       if (test_and_set_bit_lock(MOS7840_FLAG_LED_BUSY, &mos7840_port->flags))
+               return;
+
+       mos7840_set_led_async(mos7840_port, 0x0301, MODEM_CONTROL_REGISTER);
+       mod_timer(&mos7840_port->led_timer1,
+                               jiffies + msecs_to_jiffies(LED_ON_MS));
 }
 
 /*****************************************************************************
@@ -758,14 +784,8 @@ static void mos7840_bulk_in_callback(struct urb *urb)
                return;
        }
 
-       /* Turn on LED */
-       if (mos7840_port->has_led && !mos7840_port->led_flag) {
-               mos7840_port->led_flag = true;
-               mos7840_set_led_async(mos7840_port, 0x0301,
-                                       MODEM_CONTROL_REGISTER);
-               mod_timer(&mos7840_port->led_timer1,
-                               jiffies + msecs_to_jiffies(LED_ON_MS));
-       }
+       if (mos7840_port->has_led)
+               mos7840_led_activity(port);
 
        mos7840_port->read_urb_busy = true;
        retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
@@ -816,18 +836,6 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
 /************************************************************************/
 /*       D R I V E R  T T Y  I N T E R F A C E  F U N C T I O N S       */
 /************************************************************************/
-#ifdef MCSSerialProbe
-static int mos7840_serial_probe(struct usb_serial *serial,
-                               const struct usb_device_id *id)
-{
-
-       /*need to implement the mode_reg reading and updating\
-          structures usb_serial_ device_type\
-          (i.e num_ports, num_bulkin,bulkout etc) */
-       /* Also we can update the changes  attach */
-       return 1;
-}
-#endif
 
 /*****************************************************************************
  * mos7840_open
@@ -905,20 +913,20 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
        status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
        if (status < 0) {
                dev_dbg(&port->dev, "Reading Spreg failed\n");
-               return -1;
+               goto err;
        }
        Data |= 0x80;
        status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
        if (status < 0) {
                dev_dbg(&port->dev, "writing Spreg failed\n");
-               return -1;
+               goto err;
        }
 
        Data &= ~0x80;
        status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
        if (status < 0) {
                dev_dbg(&port->dev, "writing Spreg failed\n");
-               return -1;
+               goto err;
        }
        /* End of block to be checked */
 
@@ -927,7 +935,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
                                                                        &Data);
        if (status < 0) {
                dev_dbg(&port->dev, "Reading Controlreg failed\n");
-               return -1;
+               goto err;
        }
        Data |= 0x08;           /* Driver done bit */
        Data |= 0x20;           /* rx_disable */
@@ -935,7 +943,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
                                mos7840_port->ControlRegOffset, Data);
        if (status < 0) {
                dev_dbg(&port->dev, "writing Controlreg failed\n");
-               return -1;
+               goto err;
        }
        /* do register settings here */
        /* Set all regs to the device default values. */
@@ -946,21 +954,21 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
        status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
        if (status < 0) {
                dev_dbg(&port->dev, "disabling interrupts failed\n");
-               return -1;
+               goto err;
        }
        /* Set FIFO_CONTROL_REGISTER to the default value */
        Data = 0x00;
        status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
        if (status < 0) {
                dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER  failed\n");
-               return -1;
+               goto err;
        }
 
        Data = 0xcf;
        status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
        if (status < 0) {
                dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER  failed\n");
-               return -1;
+               goto err;
        }
 
        Data = 0x03;
@@ -1103,6 +1111,15 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
        /* mos7840_change_port_settings(mos7840_port,old_termios); */
 
        return 0;
+err:
+       for (j = 0; j < NUM_URBS; ++j) {
+               urb = mos7840_port->write_urb_pool[j];
+               if (!urb)
+                       continue;
+               kfree(urb->transfer_buffer);
+               usb_free_urb(urb);
+       }
+       return status;
 }
 
 /*****************************************************************************
@@ -1445,13 +1462,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
        data1 = urb->transfer_buffer;
        dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress);
 
-       /* Turn on LED */
-       if (mos7840_port->has_led && !mos7840_port->led_flag) {
-               mos7840_port->led_flag = true;
-               mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0301);
-               mod_timer(&mos7840_port->led_timer1,
-                               jiffies + msecs_to_jiffies(LED_ON_MS));
-       }
+       if (mos7840_port->has_led)
+               mos7840_led_activity(port);
 
        /* send it down the pipe */
        status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -2178,38 +2190,48 @@ static int mos7810_check(struct usb_serial *serial)
        return 0;
 }
 
-static int mos7840_calc_num_ports(struct usb_serial *serial)
+static int mos7840_probe(struct usb_serial *serial,
+                               const struct usb_device_id *id)
 {
-       __u16 data = 0x00;
+       u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
        u8 *buf;
-       int mos7840_num_ports;
+       int device_type;
+
+       if (product == MOSCHIP_DEVICE_ID_7810 ||
+               product == MOSCHIP_DEVICE_ID_7820) {
+               device_type = product;
+               goto out;
+       }
 
        buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
-       if (buf) {
-               usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+       if (!buf)
+               return -ENOMEM;
+
+       usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
                        MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, buf,
                        VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT);
-               data = *buf;
-               kfree(buf);
-       }
 
-       if (serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7810 ||
-               serial->dev->descriptor.idProduct == MOSCHIP_DEVICE_ID_7820) {
-               device_type = serial->dev->descriptor.idProduct;
-       } else {
-               /* For a MCS7840 device GPIO0 must be set to 1 */
-               if ((data & 0x01) == 1)
-                       device_type = MOSCHIP_DEVICE_ID_7840;
-               else if (mos7810_check(serial))
-                       device_type = MOSCHIP_DEVICE_ID_7810;
-               else
-                       device_type = MOSCHIP_DEVICE_ID_7820;
-       }
+       /* For a MCS7840 device GPIO0 must be set to 1 */
+       if (buf[0] & 0x01)
+               device_type = MOSCHIP_DEVICE_ID_7840;
+       else if (mos7810_check(serial))
+               device_type = MOSCHIP_DEVICE_ID_7810;
+       else
+               device_type = MOSCHIP_DEVICE_ID_7820;
+
+       kfree(buf);
+out:
+       usb_set_serial_data(serial, (void *)(unsigned long)device_type);
+
+       return 0;
+}
+
+static int mos7840_calc_num_ports(struct usb_serial *serial)
+{
+       int device_type = (unsigned long)usb_get_serial_data(serial);
+       int mos7840_num_ports;
 
        mos7840_num_ports = (device_type >> 4) & 0x000F;
-       serial->num_bulk_in = mos7840_num_ports;
-       serial->num_bulk_out = mos7840_num_ports;
-       serial->num_ports = mos7840_num_ports;
 
        return mos7840_num_ports;
 }
@@ -2217,6 +2239,7 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
 static int mos7840_port_probe(struct usb_serial_port *port)
 {
        struct usb_serial *serial = port->serial;
+       int device_type = (unsigned long)usb_get_serial_data(serial);
        struct moschip_port *mos7840_port;
        int status;
        int pnum;
@@ -2392,6 +2415,14 @@ static int mos7840_port_probe(struct usb_serial_port *port)
        if (device_type == MOSCHIP_DEVICE_ID_7810) {
                mos7840_port->has_led = true;
 
+               mos7840_port->led_urb = usb_alloc_urb(0, GFP_KERNEL);
+               mos7840_port->led_dr = kmalloc(sizeof(*mos7840_port->led_dr),
+                                                               GFP_KERNEL);
+               if (!mos7840_port->led_urb || !mos7840_port->led_dr) {
+                       status = -ENOMEM;
+                       goto error;
+               }
+
                init_timer(&mos7840_port->led_timer1);
                mos7840_port->led_timer1.function = mos7840_led_off;
                mos7840_port->led_timer1.expires =
@@ -2404,8 +2435,6 @@ static int mos7840_port_probe(struct usb_serial_port *port)
                        jiffies + msecs_to_jiffies(LED_OFF_MS);
                mos7840_port->led_timer2.data = (unsigned long)mos7840_port;
 
-               mos7840_port->led_flag = false;
-
                /* Turn off LED */
                mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0300);
        }
@@ -2427,6 +2456,8 @@ out:
        }
        return 0;
 error:
+       kfree(mos7840_port->led_dr);
+       usb_free_urb(mos7840_port->led_urb);
        kfree(mos7840_port->dr);
        kfree(mos7840_port->ctrl_buf);
        usb_free_urb(mos7840_port->control_urb);
@@ -2447,6 +2478,10 @@ static int mos7840_port_remove(struct usb_serial_port *port)
 
                del_timer_sync(&mos7840_port->led_timer1);
                del_timer_sync(&mos7840_port->led_timer2);
+
+               usb_kill_urb(mos7840_port->led_urb);
+               usb_free_urb(mos7840_port->led_urb);
+               kfree(mos7840_port->led_dr);
        }
        usb_kill_urb(mos7840_port->control_urb);
        usb_free_urb(mos7840_port->control_urb);
@@ -2473,9 +2508,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
        .throttle = mos7840_throttle,
        .unthrottle = mos7840_unthrottle,
        .calc_num_ports = mos7840_calc_num_ports,
-#ifdef MCSSerialProbe
-       .probe = mos7840_serial_probe,
-#endif
+       .probe = mos7840_probe,
        .ioctl = mos7840_ioctl,
        .set_termios = mos7840_set_termios,
        .break_ctl = mos7840_break,
index 5dd857de05b04f5ecf4cefe7a370e6013db67118..1cf6f125f5f078624b41bd1256686d35f28ee4b7 100644 (file)
@@ -341,17 +341,12 @@ static void option_instat_callback(struct urb *urb);
 #define OLIVETTI_VENDOR_ID                     0x0b3c
 #define OLIVETTI_PRODUCT_OLICARD100            0xc000
 #define OLIVETTI_PRODUCT_OLICARD145            0xc003
+#define OLIVETTI_PRODUCT_OLICARD200            0xc005
 
 /* Celot products */
 #define CELOT_VENDOR_ID                                0x211f
 #define CELOT_PRODUCT_CT680M                   0x6801
 
-/* ONDA Communication vendor id */
-#define ONDA_VENDOR_ID       0x1ee8
-
-/* ONDA MT825UP HSDPA 14.2 modem */
-#define ONDA_MT825UP         0x000b
-
 /* Samsung products */
 #define SAMSUNG_VENDOR_ID                       0x04e8
 #define SAMSUNG_PRODUCT_GT_B3730                0x6889
@@ -444,7 +439,8 @@ static void option_instat_callback(struct urb *urb);
 
 /* Hyundai Petatel Inc. products */
 #define PETATEL_VENDOR_ID                      0x1ff4
-#define PETATEL_PRODUCT_NP10T                  0x600e
+#define PETATEL_PRODUCT_NP10T_600A             0x600a
+#define PETATEL_PRODUCT_NP10T_600E             0x600e
 
 /* TP-LINK Incorporated products */
 #define TPLINK_VENDOR_ID                       0x2357
@@ -782,6 +778,7 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
        { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
+       { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
@@ -817,7 +814,8 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff),
                .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
        { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0018, 0xff, 0xff, 0xff) },
-       { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0019, 0xff, 0xff, 0xff) },
+       { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0019, 0xff, 0xff, 0xff),
+               .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
        { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0020, 0xff, 0xff, 0xff) },
        { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0021, 0xff, 0xff, 0xff),
                .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
@@ -1256,8 +1254,8 @@ static const struct usb_device_id option_ids[] = {
 
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
+       { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200) },
        { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
-       { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
        { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
        { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
        { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM610) },
@@ -1329,9 +1327,12 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) },
        { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) },
        { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) },
-       { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T) },
+       { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600A) },
+       { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T_600E) },
        { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180),
          .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
+       { USB_DEVICE(TPLINK_VENDOR_ID, 0x9000),                                 /* TP-Link MA260 */
+         .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
        { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) },
        { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) },    /* D-Link DWM-156 (variant) */
        { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) },    /* D-Link DWM-156 (variant) */
@@ -1339,6 +1340,8 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
        { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
        { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
+       { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
+       { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
        { } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/suunto.c b/drivers/usb/serial/suunto.c
new file mode 100644 (file)
index 0000000..2248e7a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Suunto ANT+ USB Driver
+ *
+ * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+ * Copyright (C) 2013 Linux Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation only.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/tty.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+#include <linux/usb/serial.h>
+#include <linux/uaccess.h>
+
+static const struct usb_device_id id_table[] = {
+       { USB_DEVICE(0x0fcf, 0x1008) },
+       { },
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+static struct usb_serial_driver suunto_device = {
+       .driver = {
+               .owner =        THIS_MODULE,
+               .name =         KBUILD_MODNAME,
+       },
+       .id_table =             id_table,
+       .num_ports =            1,
+};
+
+static struct usb_serial_driver * const serial_drivers[] = {
+       &suunto_device,
+       NULL,
+};
+
+module_usb_serial_driver(serial_drivers, id_table);
+MODULE_LICENSE("GPL");
index 7182bb774b7958f70f50efb823b084c5ea9284d5..5c9f9b1d7736d0b7fade9780920d8916477c81fa 100644 (file)
@@ -371,7 +371,7 @@ static int ti_startup(struct usb_serial *serial)
        usb_set_serial_data(serial, tdev);
 
        /* determine device type */
-       if (usb_match_id(serial->interface, ti_id_table_3410))
+       if (serial->type == &ti_1port_device)
                tdev->td_is_3410 = 1;
        dev_dbg(&dev->dev, "%s - device type is %s\n", __func__,
                tdev->td_is_3410 ? "3410" : "5052");
@@ -1536,14 +1536,15 @@ static int ti_download_firmware(struct ti_device *tdev)
        char buf[32];
 
        /* try ID specific firmware first, then try generic firmware */
-       sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
-           dev->descriptor.idProduct);
+       sprintf(buf, "ti_usb-v%04x-p%04x.fw",
+                       le16_to_cpu(dev->descriptor.idVendor),
+                       le16_to_cpu(dev->descriptor.idProduct));
        status = request_firmware(&fw_p, buf, &dev->dev);
 
        if (status != 0) {
                buf[0] = '\0';
-               if (dev->descriptor.idVendor == MTS_VENDOR_ID) {
-                       switch (dev->descriptor.idProduct) {
+               if (le16_to_cpu(dev->descriptor.idVendor) == MTS_VENDOR_ID) {
+                       switch (le16_to_cpu(dev->descriptor.idProduct)) {
                        case MTS_CDMA_PRODUCT_ID:
                                strcpy(buf, "mts_cdma.fw");
                                break;
index 8257d30c40720f348de427ef4d04ea3d1835d03a..85365784040b28a2c8c92a23ff4f4d5fe758834e 100644 (file)
@@ -291,18 +291,18 @@ static void usb_wwan_indat_callback(struct urb *urb)
                        tty_flip_buffer_push(&port->port);
                } else
                        dev_dbg(dev, "%s: empty read urb received\n", __func__);
-
-               /* Resubmit urb so we continue receiving */
-               err = usb_submit_urb(urb, GFP_ATOMIC);
-               if (err) {
-                       if (err != -EPERM) {
-                               dev_err(dev, "%s: resubmit read urb failed. (%d)\n", __func__, err);
-                               /* busy also in error unless we are killed */
-                               usb_mark_last_busy(port->serial->dev);
-                       }
-               } else {
+       }
+       /* Resubmit urb so we continue receiving */
+       err = usb_submit_urb(urb, GFP_ATOMIC);
+       if (err) {
+               if (err != -EPERM) {
+                       dev_err(dev, "%s: resubmit read urb failed. (%d)\n",
+                               __func__, err);
+                       /* busy also in error unless we are killed */
                        usb_mark_last_busy(port->serial->dev);
                }
+       } else {
+               usb_mark_last_busy(port->serial->dev);
        }
 }
 
index 1799335288bd5e60522a60def1c311f07df62286..c015f2c16729c5b4030fc829fae9a3cfb90acde6 100644 (file)
@@ -665,6 +665,13 @@ UNUSUAL_DEV(  0x054c, 0x016a, 0x0000, 0x9999,
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
                US_FL_FIX_INQUIRY ),
 
+/* Submitted by Ren Bigcren <bigcren.ren@sonymobile.com> */
+UNUSUAL_DEV(  0x054c, 0x02a5, 0x0100, 0x0100,
+               "Sony Corp.",
+               "MicroVault Flash Drive",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_NO_READ_CAPACITY_16 ),
+
 /* floppy reports multiple luns */
 UNUSUAL_DEV(  0x055d, 0x2020, 0x0000, 0x0210,
                "SAMSUNG",
index 16968c899493db24a40481e151b0da591405c1bf..d3493ca0525d4c727ed8d0fb86223fde6cb001e7 100644 (file)
@@ -1226,6 +1226,12 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
        }
        spin_lock_irqsave(&xfer->lock, flags);
        rpipe = xfer->ep->hcpriv;
+       if (rpipe == NULL) {
+               pr_debug("%s: xfer id 0x%08X has no RPIPE.  %s",
+                       __func__, wa_xfer_id(xfer),
+                       "Probably already aborted.\n" );
+               goto out_unlock;
+       }
        /* Check the delayed list -> if there, release and complete */
        spin_lock_irqsave(&wa->xfer_list_lock, flags2);
        if (!list_empty(&xfer->list_node) && xfer->seg == NULL)
@@ -1644,8 +1650,7 @@ static void wa_xfer_result_cb(struct urb *urb)
                        break;
                }
                usb_status = xfer_result->bTransferStatus & 0x3f;
-               if (usb_status == WA_XFER_STATUS_ABORTED
-                   || usb_status == WA_XFER_STATUS_NOT_FOUND)
+               if (usb_status == WA_XFER_STATUS_NOT_FOUND)
                        /* taken care of already */
                        break;
                xfer_id = xfer_result->dwTransferID;
index c5179e269df64ade2de20a384b6732a6922c9bcf..cef6002acbd49aa078568fe2fe9ea4511230e861 100644 (file)
@@ -137,8 +137,27 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
         */
        pci_write_config_word(pdev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE);
 
-       if (vdev->reset_works)
-               __pci_reset_function(pdev);
+       /*
+        * Careful, device_lock may already be held.  This is the case if
+        * a driver unbind is blocked.  Try to get the locks ourselves to
+        * prevent a deadlock.
+        */
+       if (vdev->reset_works) {
+               bool reset_done = false;
+
+               if (pci_cfg_access_trylock(pdev)) {
+                       if (device_trylock(&pdev->dev)) {
+                               __pci_reset_function_locked(pdev);
+                               reset_done = true;
+                               device_unlock(&pdev->dev);
+                       }
+                       pci_cfg_access_unlock(pdev);
+               }
+
+               if (!reset_done)
+                       pr_warn("%s: Unable to acquire locks for reset of %s\n",
+                               __func__, dev_name(&pdev->dev));
+       }
 
        pci_restore_state(pdev);
 }
index c488da5db7c7f1b0bda8e3b7559971ebfba0c442..842f4507883e1b1d10c99d343e35e450abf56db0 100644 (file)
@@ -494,27 +494,6 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
        return 0;
 }
 
-static int vfio_group_nb_del_dev(struct vfio_group *group, struct device *dev)
-{
-       struct vfio_device *device;
-
-       /*
-        * Expect to fall out here.  If a device was in use, it would
-        * have been bound to a vfio sub-driver, which would have blocked
-        * in .remove at vfio_del_group_dev.  Sanity check that we no
-        * longer track the device, so it's safe to remove.
-        */
-       device = vfio_group_get_device(group, dev);
-       if (likely(!device))
-               return 0;
-
-       WARN("Device %s removed from live group %d!\n", dev_name(dev),
-            iommu_group_id(group->iommu_group));
-
-       vfio_device_put(device);
-       return 0;
-}
-
 static int vfio_group_nb_verify(struct vfio_group *group, struct device *dev)
 {
        /* We don't care what happens when the group isn't in use */
@@ -531,13 +510,11 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb,
        struct device *dev = data;
 
        /*
-        * Need to go through a group_lock lookup to get a reference or
-        * we risk racing a group being removed.  Leave a WARN_ON for
-        * debuging, but if the group no longer exists, a spurious notify
-        * is harmless.
+        * Need to go through a group_lock lookup to get a reference or we
+        * risk racing a group being removed.  Ignore spurious notifies.
         */
        group = vfio_group_try_get(group);
-       if (WARN_ON(!group))
+       if (!group)
                return NOTIFY_OK;
 
        switch (action) {
@@ -545,7 +522,13 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb,
                vfio_group_nb_add_dev(group, dev);
                break;
        case IOMMU_GROUP_NOTIFY_DEL_DEVICE:
-               vfio_group_nb_del_dev(group, dev);
+               /*
+                * Nothing to do here.  If the device is in use, then the
+                * vfio sub-driver should block the remove callback until
+                * it is unused.  If the device is unused or attached to a
+                * stub driver, then it should be released and we don't
+                * care that it will be going away.
+                */
                break;
        case IOMMU_GROUP_NOTIFY_BIND_DRIVER:
                pr_debug("%s: Device %s, group %d binding to driver\n",
index 027be91db139c43eaadd5e12727c2b18c1a65bcc..969a85960e9f6bf09a5bb9a6b1ea828d9f5ae9fb 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
-#include <linux/rcupdate.h>
 #include <linux/file.h>
 #include <linux/slab.h>
 
@@ -346,12 +345,11 @@ static void handle_tx(struct vhost_net *net)
        struct vhost_net_ubuf_ref *uninitialized_var(ubufs);
        bool zcopy, zcopy_used;
 
-       /* TODO: check that we are running from vhost_worker? */
-       sock = rcu_dereference_check(vq->private_data, 1);
+       mutex_lock(&vq->mutex);
+       sock = vq->private_data;
        if (!sock)
-               return;
+               goto out;
 
-       mutex_lock(&vq->mutex);
        vhost_disable_notify(&net->dev, vq);
 
        hdr_size = nvq->vhost_hlen;
@@ -461,7 +459,7 @@ static void handle_tx(struct vhost_net *net)
                        break;
                }
        }
-
+out:
        mutex_unlock(&vq->mutex);
 }
 
@@ -570,14 +568,14 @@ static void handle_rx(struct vhost_net *net)
        s16 headcount;
        size_t vhost_hlen, sock_hlen;
        size_t vhost_len, sock_len;
-       /* TODO: check that we are running from vhost_worker? */
-       struct socket *sock = rcu_dereference_check(vq->private_data, 1);
-
-       if (!sock)
-               return;
+       struct socket *sock;
 
        mutex_lock(&vq->mutex);
+       sock = vq->private_data;
+       if (!sock)
+               goto out;
        vhost_disable_notify(&net->dev, vq);
+
        vhost_hlen = nvq->vhost_hlen;
        sock_hlen = nvq->sock_hlen;
 
@@ -652,7 +650,7 @@ static void handle_rx(struct vhost_net *net)
                        break;
                }
        }
-
+out:
        mutex_unlock(&vq->mutex);
 }
 
@@ -750,8 +748,7 @@ static int vhost_net_enable_vq(struct vhost_net *n,
        struct vhost_poll *poll = n->poll + (nvq - n->vqs);
        struct socket *sock;
 
-       sock = rcu_dereference_protected(vq->private_data,
-                                        lockdep_is_held(&vq->mutex));
+       sock = vq->private_data;
        if (!sock)
                return 0;
 
@@ -764,10 +761,9 @@ static struct socket *vhost_net_stop_vq(struct vhost_net *n,
        struct socket *sock;
 
        mutex_lock(&vq->mutex);
-       sock = rcu_dereference_protected(vq->private_data,
-                                        lockdep_is_held(&vq->mutex));
+       sock = vq->private_data;
        vhost_net_disable_vq(n, vq);
-       rcu_assign_pointer(vq->private_data, NULL);
+       vq->private_data = NULL;
        mutex_unlock(&vq->mutex);
        return sock;
 }
@@ -923,8 +919,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
        }
 
        /* start polling new socket */
-       oldsock = rcu_dereference_protected(vq->private_data,
-                                           lockdep_is_held(&vq->mutex));
+       oldsock = vq->private_data;
        if (sock != oldsock) {
                ubufs = vhost_net_ubuf_alloc(vq,
                                             sock && vhost_sock_zcopy(sock));
@@ -934,7 +929,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
                }
 
                vhost_net_disable_vq(n, vq);
-               rcu_assign_pointer(vq->private_data, sock);
+               vq->private_data = sock;
                r = vhost_init_used(vq);
                if (r)
                        goto err_used;
@@ -968,7 +963,7 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
        return 0;
 
 err_used:
-       rcu_assign_pointer(vq->private_data, oldsock);
+       vq->private_data = oldsock;
        vhost_net_enable_vq(n, vq);
        if (ubufs)
                vhost_net_ubuf_put_wait_and_free(ubufs);
index 06adf31a92484a6f32f01ab71c2dd76c6553c920..0c27c7df1b093e6ad64292a5211387a3103543e2 100644 (file)
@@ -902,19 +902,15 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
        int head, ret;
        u8 target;
 
+       mutex_lock(&vq->mutex);
        /*
         * We can handle the vq only after the endpoint is setup by calling the
         * VHOST_SCSI_SET_ENDPOINT ioctl.
-        *
-        * TODO: Check that we are running from vhost_worker which acts
-        * as read-side critical section for vhost kind of RCU.
-        * See the comments in struct vhost_virtqueue in drivers/vhost/vhost.h
         */
-       vs_tpg = rcu_dereference_check(vq->private_data, 1);
+       vs_tpg = vq->private_data;
        if (!vs_tpg)
-               return;
+               goto out;
 
-       mutex_lock(&vq->mutex);
        vhost_disable_notify(&vs->dev, vq);
 
        for (;;) {
@@ -1064,6 +1060,7 @@ err_free:
        vhost_scsi_free_cmd(cmd);
 err_cmd:
        vhost_scsi_send_bad_target(vs, vq, head, out);
+out:
        mutex_unlock(&vq->mutex);
 }
 
@@ -1232,9 +1229,8 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
                       sizeof(vs->vs_vhost_wwpn));
                for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
                        vq = &vs->vqs[i].vq;
-                       /* Flushing the vhost_work acts as synchronize_rcu */
                        mutex_lock(&vq->mutex);
-                       rcu_assign_pointer(vq->private_data, vs_tpg);
+                       vq->private_data = vs_tpg;
                        vhost_init_used(vq);
                        mutex_unlock(&vq->mutex);
                }
@@ -1313,9 +1309,8 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
        if (match) {
                for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
                        vq = &vs->vqs[i].vq;
-                       /* Flushing the vhost_work acts as synchronize_rcu */
                        mutex_lock(&vq->mutex);
-                       rcu_assign_pointer(vq->private_data, NULL);
+                       vq->private_data = NULL;
                        mutex_unlock(&vq->mutex);
                }
        }
index a73ea217f24dc79a0f92a95cca39c416e828a6b9..339eae85859a58afbd6ea563b4b9fae3f667100c 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
-#include <linux/rcupdate.h>
 #include <linux/file.h>
 #include <linux/slab.h>
 
@@ -200,9 +199,8 @@ static long vhost_test_run(struct vhost_test *n, int test)
                priv = test ? n : NULL;
 
                /* start polling new socket */
-               oldpriv = rcu_dereference_protected(vq->private_data,
-                                                   lockdep_is_held(&vq->mutex));
-               rcu_assign_pointer(vq->private_data, priv);
+               oldpriv = vq->private_data;
+               vq->private_data = priv;
 
                r = vhost_init_used(&n->vqs[index]);
 
index e58cf0001cee10bbe789fdbf7d7fe94260f4eaa9..448efe01f18a173d8d560fc68387d9393d415a62 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <linux/eventfd.h>
 #include <linux/vhost.h>
-#include <linux/socket.h> /* memcpy_fromiovec */
+#include <linux/uio.h>
 #include <linux/mm.h>
 #include <linux/mmu_context.h>
 #include <linux/miscdevice.h>
index 42298cd23c73842e6a4ec7f8434428b56e700098..4465ed5f316d6e9b36e1f43c05df1c980aa908ae 100644 (file)
@@ -103,14 +103,8 @@ struct vhost_virtqueue {
        struct iovec iov[UIO_MAXIOV];
        struct iovec *indirect;
        struct vring_used_elem *heads;
-       /* We use a kind of RCU to access private pointer.
-        * All readers access it from worker, which makes it possible to
-        * flush the vhost_work instead of synchronize_rcu. Therefore readers do
-        * not need to call rcu_read_lock/rcu_read_unlock: the beginning of
-        * vhost_work execution acts instead of rcu_read_lock() and the end of
-        * vhost_work execution acts instead of rcu_read_unlock().
-        * Writers use virtqueue mutex. */
-       void __rcu *private_data;
+       /* Protected by virtqueue mutex. */
+       void *private_data;
        /* Log write descriptors */
        void __user *log_base;
        struct vhost_log *log;
index a89c15de9f45c885f3dc7fe76bad22bde184013d..9b0f12c5c2842f783501821d7c6bb4a9527f936f 100644 (file)
@@ -435,8 +435,8 @@ static int correct_chipset(struct atyfb_par *par)
        const char *name;
        int i;
 
-       for (i = ARRAY_SIZE(aty_chips); i > 0; i--)
-               if (par->pci_id == aty_chips[i - 1].pci_id)
+       for (i = (int)ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
+               if (par->pci_id == aty_chips[i].pci_id)
                        break;
 
        if (i < 0)
index 5ca11b066b7e51b31e346759fed356e98bfe0d12..886e797f75f9e7b0c6571f2f8ba0ec0b561f0d83 100644 (file)
@@ -101,33 +101,37 @@ static const struct backlight_ops max8925_backlight_ops = {
        .get_brightness = max8925_backlight_get_brightness,
 };
 
-#ifdef CONFIG_OF
-static int max8925_backlight_dt_init(struct platform_device *pdev,
-                             struct max8925_backlight_pdata *pdata)
+static void max8925_backlight_dt_init(struct platform_device *pdev)
 {
        struct device_node *nproot = pdev->dev.parent->of_node, *np;
-       int dual_string;
+       struct max8925_backlight_pdata *pdata;
+       u32 val;
+
+       if (!nproot || !IS_ENABLED(CONFIG_OF))
+               return;
+
+       pdata = devm_kzalloc(&pdev->dev,
+                            sizeof(struct max8925_backlight_pdata),
+                            GFP_KERNEL);
+       if (!pdata)
+               return;
 
-       if (!nproot)
-               return -ENODEV;
        np = of_find_node_by_name(nproot, "backlight");
        if (!np) {
                dev_err(&pdev->dev, "failed to find backlight node\n");
-               return -ENODEV;
+               return;
        }
 
-       of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string);
-       pdata->dual_string = dual_string;
-       return 0;
+       if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val))
+               pdata->dual_string = val;
+
+       pdev->dev.platform_data = pdata;
 }
-#else
-#define max8925_backlight_dt_init(x, y)        (-1)
-#endif
 
 static int max8925_backlight_probe(struct platform_device *pdev)
 {
        struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
-       struct max8925_backlight_pdata *pdata = pdev->dev.platform_data;
+       struct max8925_backlight_pdata *pdata;
        struct max8925_backlight_data *data;
        struct backlight_device *bl;
        struct backlight_properties props;
@@ -170,13 +174,10 @@ static int max8925_backlight_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, bl);
 
        value = 0;
-       if (pdev->dev.parent->of_node && !pdata) {
-               pdata = devm_kzalloc(&pdev->dev,
-                                    sizeof(struct max8925_backlight_pdata),
-                                    GFP_KERNEL);
-               max8925_backlight_dt_init(pdev, pdata);
-       }
+       if (!pdev->dev.platform_data)
+               max8925_backlight_dt_init(pdev);
 
+       pdata = pdev->dev.platform_data;
        if (pdata) {
                if (pdata->lxw_scl)
                        value |= (1 << 7);
index 3ba37713b1f97795c875ded477e5dfe37b2259b7..dc09ebe4aba53d078881b28e123bc072142f423c 100644 (file)
@@ -239,24 +239,6 @@ static const struct fb_bitfield def_rgb565[] = {
        }
 };
 
-static const struct fb_bitfield def_rgb666[] = {
-       [RED] = {
-               .offset = 16,
-               .length = 6,
-       },
-       [GREEN] = {
-               .offset = 8,
-               .length = 6,
-       },
-       [BLUE] = {
-               .offset = 0,
-               .length = 6,
-       },
-       [TRANSP] = {    /* no support for transparency */
-               .length = 0,
-       }
-};
-
 static const struct fb_bitfield def_rgb888[] = {
        [RED] = {
                .offset = 16,
@@ -309,9 +291,6 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
                        break;
                case STMLCDIF_16BIT:
                case STMLCDIF_18BIT:
-                       /* 24 bit to 18 bit mapping */
-                       rgb = def_rgb666;
-                       break;
                case STMLCDIF_24BIT:
                        /* real 24 bit */
                        rgb = def_rgb888;
@@ -453,11 +432,6 @@ static int mxsfb_set_par(struct fb_info *fb_info)
                        return -EINVAL;
                case STMLCDIF_16BIT:
                case STMLCDIF_18BIT:
-                       /* 24 bit to 18 bit mapping */
-                       ctrl |= CTRL_DF24; /* ignore the upper 2 bits in
-                                           *  each colour component
-                                           */
-                       break;
                case STMLCDIF_24BIT:
                        /* real 24 bit */
                        break;
index 8c527e5b293cbe5bf91718f5c1f68b0ffbcc4c44..796e5112ceeeb1f139bf947197e96ea2af42ee60 100644 (file)
@@ -587,8 +587,7 @@ static int nuc900fb_probe(struct platform_device *pdev)
        fbinfo->flags                   = FBINFO_FLAG_DEFAULT;
        fbinfo->pseudo_palette          = &fbi->pseudo_pal;
 
-       ret = request_irq(irq, nuc900fb_irqhandler, 0,
-                         pdev->name, fbinfo);
+       ret = request_irq(irq, nuc900fb_irqhandler, 0, pdev->name, fbi);
        if (ret) {
                dev_err(&pdev->dev, "cannot register irq handler %d -err %d\n",
                        irq, ret);
index 5338f362293b27a9d6050e856fd878f5c88b4684..1b60698f141ed983e2661743f2a5c79f471a02a6 100644 (file)
@@ -28,6 +28,20 @@ struct panel_drv_data {
        bool invert_polarity;
 };
 
+static const struct omap_video_timings tvc_pal_timings = {
+       .x_res          = 720,
+       .y_res          = 574,
+       .pixel_clock    = 13500,
+       .hsw            = 64,
+       .hfp            = 12,
+       .hbp            = 68,
+       .vsw            = 5,
+       .vfp            = 5,
+       .vbp            = 41,
+
+       .interlace      = true,
+};
+
 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
 
 static int tvc_connect(struct omap_dss_device *dssdev)
@@ -212,14 +226,14 @@ static int tvc_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       ddata->timings = omap_dss_pal_timings;
+       ddata->timings = tvc_pal_timings;
 
        dssdev = &ddata->dssdev;
        dssdev->driver = &tvc_driver;
        dssdev->dev = &pdev->dev;
        dssdev->type = OMAP_DISPLAY_TYPE_VENC;
        dssdev->owner = THIS_MODULE;
-       dssdev->panel.timings = omap_dss_pal_timings;
+       dssdev->panel.timings = tvc_pal_timings;
 
        r = omapdss_register_display(dssdev);
        if (r) {
index b2a8912f6435ac504e4b09361c12dbe8b7d01bc6..a9ac3ce2d0e9de56aaab9f836b0037fe62651596 100644 (file)
@@ -713,7 +713,7 @@ static int sgivwfb_mmap(struct fb_info *info,
        r = vm_iomap_memory(vma, sgivwfb_mem_phys, sgivwfb_mem_size);
 
        printk(KERN_DEBUG "sgivwfb: mmap framebuffer P(%lx)->V(%lx)\n",
-              offset, vma->vm_start);
+               sgivwfb_mem_phys + (vma->vm_pgoff << PAGE_SHIFT), vma->vm_start);
 
        return r;
 }
index a8c6c43a4658565c8b21fa38a3baaf1c5bd82e36..1265b25f9f99993efd8d094716acb65563d8570f 100644 (file)
@@ -567,7 +567,7 @@ static int sh7760fb_remove(struct platform_device *dev)
        fb_dealloc_cmap(&info->cmap);
        sh7760fb_free_mem(info);
        if (par->irq >= 0)
-               free_irq(par->irq, par);
+               free_irq(par->irq, &par->vsync);
        iounmap(par->base);
        release_mem_region(par->ioarea->start, resource_size(par->ioarea));
        framebuffer_release(info);
index b963ea12d175b1527242ab790cd86b982a60f749..7aec6f39fdd5461beb16d700ed201212ba9d1704 100644 (file)
@@ -1891,7 +1891,7 @@ static int uvesafb_setup(char *options)
                }
        }
 
-       if (mtrr != 3 && mtrr != 1)
+       if (mtrr != 3 && mtrr != 0)
                pr_warn("uvesafb: mtrr should be set to 0 or 3; %d is unsupported", mtrr);
 
        return 0;
index 830ded45fd4758a9a3d9ba6c6640653ac9b32490..2827333703d96d151b86952470c590a5d2820636 100644 (file)
@@ -1265,7 +1265,6 @@ static void vga16fb_imageblit(struct fb_info *info, const struct fb_image *image
 
 static void vga16fb_destroy(struct fb_info *info)
 {
-       struct platform_device *dev = container_of(info->device, struct platform_device, dev);
        iounmap(info->screen_base);
        fb_dealloc_cmap(&info->cmap);
        /* XXX unshare VGA regions */
index f3d4a69e1e4e9058c4c4cc605705f1d62d923a48..6629b29a820221eedfe774a1cd4c62163bd29bb1 100644 (file)
@@ -341,8 +341,8 @@ static int xilinxfb_assign(struct platform_device *pdev,
 
        if (drvdata->flags & BUS_ACCESS_FLAG) {
                /* Put a banner in the log (for DEBUG) */
-               dev_dbg(dev, "regs: phys=%x, virt=%p\n", drvdata->regs_phys,
-                                       drvdata->regs);
+               dev_dbg(dev, "regs: phys=%pa, virt=%p\n",
+                       &drvdata->regs_phys, drvdata->regs);
        }
        /* Put a banner in the log (for DEBUG) */
        dev_dbg(dev, "fb: phys=%llx, virt=%p, size=%x\n",
index 9e02d60a364b00d271efb0b4d4eda046a25fbf08..23eae5cb69c21e16d2f71ce2c29e1b307ba3c05c 100644 (file)
@@ -145,7 +145,7 @@ config SWIOTLB_XEN
 
 config XEN_TMEM
        tristate
-       depends on !ARM
+       depends on !ARM && !ARM64
        default m if (CLEANCACHE || FRONTSWAP)
        help
          Shim to interface in-kernel Transcendent Memory hooks
index eabd0ee1c2bc2f298d0938515e204b42430e9852..14fe79d8634abfe2307d53e65e151f403c86bcad 100644 (file)
@@ -1,9 +1,8 @@
-ifneq ($(CONFIG_ARM),y)
-obj-y  += manage.o
+ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
 obj-$(CONFIG_HOTPLUG_CPU)              += cpu_hotplug.o
 endif
 obj-$(CONFIG_X86)                      += fallback.o
-obj-y  += grant-table.o features.o events.o balloon.o
+obj-y  += grant-table.o features.o events.o balloon.o manage.o
 obj-y  += xenbus/
 
 nostackp := $(call cc-option, -fno-stack-protector)
index a58ac435a9a4a03f39274f8b5a41ea659d44eee7..5e8be462aed56da7060792b0abb8d4426e838d06 100644 (file)
@@ -348,7 +348,7 @@ static void init_evtchn_cpu_bindings(void)
 
        for_each_possible_cpu(i)
                memset(per_cpu(cpu_evtchn_mask, i),
-                      (i == 0) ? ~0 : 0, sizeof(*per_cpu(cpu_evtchn_mask, i)));
+                      (i == 0) ? ~0 : 0, NR_EVENT_CHANNELS/8);
 }
 
 static inline void clear_evtchn(int port)
@@ -1493,8 +1493,10 @@ void rebind_evtchn_irq(int evtchn, int irq)
 /* Rebind an evtchn so that it gets delivered to a specific cpu */
 static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
 {
+       struct shared_info *s = HYPERVISOR_shared_info;
        struct evtchn_bind_vcpu bind_vcpu;
        int evtchn = evtchn_from_irq(irq);
+       int masked;
 
        if (!VALID_EVTCHN(evtchn))
                return -1;
@@ -1510,6 +1512,12 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
        bind_vcpu.port = evtchn;
        bind_vcpu.vcpu = tcpu;
 
+       /*
+        * Mask the event while changing the VCPU binding to prevent
+        * it being delivered on an unexpected VCPU.
+        */
+       masked = sync_test_and_set_bit(evtchn, BM(s->evtchn_mask));
+
        /*
         * If this fails, it usually just indicates that we're dealing with a
         * virq or IPI channel, which don't actually need to be rebound. Ignore
@@ -1518,6 +1526,9 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
        if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
                bind_evtchn_to_cpu(evtchn, tcpu);
 
+       if (!masked)
+               unmask_evtchn(evtchn);
+
        return 0;
 }
 
index 8feecf01d55c95c9241080cf36823f197b3b2d5c..b6165e047f48083c5a254dc66a6f4bc3e6e9ddb9 100644 (file)
@@ -379,18 +379,12 @@ static long evtchn_ioctl(struct file *file,
                if (unbind.port >= NR_EVENT_CHANNELS)
                        break;
 
-               spin_lock_irq(&port_user_lock);
-
                rc = -ENOTCONN;
-               if (get_port_user(unbind.port) != u) {
-                       spin_unlock_irq(&port_user_lock);
+               if (get_port_user(unbind.port) != u)
                        break;
-               }
 
                disable_irq(irq_from_evtchn(unbind.port));
 
-               spin_unlock_irq(&port_user_lock);
-
                evtchn_unbind_from_user(u, unbind.port);
 
                rc = 0;
@@ -490,26 +484,15 @@ static int evtchn_release(struct inode *inode, struct file *filp)
        int i;
        struct per_user_data *u = filp->private_data;
 
-       spin_lock_irq(&port_user_lock);
-
-       free_page((unsigned long)u->ring);
-
        for (i = 0; i < NR_EVENT_CHANNELS; i++) {
                if (get_port_user(i) != u)
                        continue;
 
                disable_irq(irq_from_evtchn(i));
-       }
-
-       spin_unlock_irq(&port_user_lock);
-
-       for (i = 0; i < NR_EVENT_CHANNELS; i++) {
-               if (get_port_user(i) != u)
-                       continue;
-
                evtchn_unbind_from_user(get_port_user(i), i);
        }
 
+       free_page((unsigned long)u->ring);
        kfree(u->name);
        kfree(u);
 
index 0caf4863be8cc6e007a69d588c509588c9496ae6..8dae6c13063af5df3846d0c3a700876fe23eefe0 100644 (file)
@@ -91,7 +91,7 @@ static int xen_acpi_processor_enable(struct acpi_device *device)
        return 0;
 }
 
-static int __cpuinit xen_acpi_processor_add(struct acpi_device *device)
+static int xen_acpi_processor_add(struct acpi_device *device)
 {
        int ret;
        struct acpi_processor *pr;
index 6ed8a9df4472edc36b91b70ca3a0f463f237108d..34b20bfa4e8c3cf813194a45c4545e01c1d88eb1 100644 (file)
@@ -115,7 +115,6 @@ static int xenbus_frontend_dev_resume(struct device *dev)
                        return -EFAULT;
                }
 
-               INIT_WORK(&xdev->work, xenbus_frontend_delayed_resume);
                queue_work(xenbus_frontend_wq, &xdev->work);
 
                return 0;
@@ -124,6 +123,16 @@ static int xenbus_frontend_dev_resume(struct device *dev)
        return xenbus_dev_resume(dev);
 }
 
+static int xenbus_frontend_dev_probe(struct device *dev)
+{
+       if (xen_store_domain_type == XS_LOCAL) {
+               struct xenbus_device *xdev = to_xenbus_device(dev);
+               INIT_WORK(&xdev->work, xenbus_frontend_delayed_resume);
+       }
+
+       return xenbus_dev_probe(dev);
+}
+
 static const struct dev_pm_ops xenbus_pm_ops = {
        .suspend        = xenbus_dev_suspend,
        .resume         = xenbus_frontend_dev_resume,
@@ -142,7 +151,7 @@ static struct xen_bus_type xenbus_frontend = {
                .name           = "xen",
                .match          = xenbus_match,
                .uevent         = xenbus_uevent_frontend,
-               .probe          = xenbus_dev_probe,
+               .probe          = xenbus_frontend_dev_probe,
                .remove         = xenbus_dev_remove,
                .shutdown       = xenbus_dev_shutdown,
                .dev_attrs      = xenbus_dev_attrs,
@@ -474,7 +483,11 @@ static int __init xenbus_probe_frontend_init(void)
 
        register_xenstore_notifier(&xenstore_notifier);
 
-       xenbus_frontend_wq = create_workqueue("xenbus_frontend");
+       if (xen_store_domain_type == XS_LOCAL) {
+               xenbus_frontend_wq = create_workqueue("xenbus_frontend");
+               if (!xenbus_frontend_wq)
+                       pr_warn("create xenbus frontend workqueue failed, S3 resume is likely to fail\n");
+       }
 
        return 0;
 }
index eaf133384a8f97497098ab82cc94a67862116705..8bc5e8ccb091852dd53f262eb556fe5578a419a3 100644 (file)
@@ -36,16 +36,23 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
                                u64 extent_item_pos,
                                struct extent_inode_elem **eie)
 {
-       u64 data_offset;
-       u64 data_len;
+       u64 offset = 0;
        struct extent_inode_elem *e;
 
-       data_offset = btrfs_file_extent_offset(eb, fi);
-       data_len = btrfs_file_extent_num_bytes(eb, fi);
+       if (!btrfs_file_extent_compression(eb, fi) &&
+           !btrfs_file_extent_encryption(eb, fi) &&
+           !btrfs_file_extent_other_encoding(eb, fi)) {
+               u64 data_offset;
+               u64 data_len;
 
-       if (extent_item_pos < data_offset ||
-           extent_item_pos >= data_offset + data_len)
-               return 1;
+               data_offset = btrfs_file_extent_offset(eb, fi);
+               data_len = btrfs_file_extent_num_bytes(eb, fi);
+
+               if (extent_item_pos < data_offset ||
+                   extent_item_pos >= data_offset + data_len)
+                       return 1;
+               offset = extent_item_pos - data_offset;
+       }
 
        e = kmalloc(sizeof(*e), GFP_NOFS);
        if (!e)
@@ -53,7 +60,7 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
 
        e->next = *eie;
        e->inum = key->objectid;
-       e->offset = key->offset + (extent_item_pos - data_offset);
+       e->offset = key->offset + offset;
        *eie = e;
 
        return 0;
@@ -189,7 +196,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
        struct extent_buffer *eb;
        struct btrfs_key key;
        struct btrfs_file_extent_item *fi;
-       struct extent_inode_elem *eie = NULL;
+       struct extent_inode_elem *eie = NULL, *old = NULL;
        u64 disk_byte;
 
        if (level != 0) {
@@ -223,6 +230,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
 
                if (disk_byte == wanted_disk_byte) {
                        eie = NULL;
+                       old = NULL;
                        if (extent_item_pos) {
                                ret = check_extent_in_eb(&key, eb, fi,
                                                *extent_item_pos,
@@ -230,18 +238,20 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
                                if (ret < 0)
                                        break;
                        }
-                       if (!ret) {
-                               ret = ulist_add(parents, eb->start,
-                                               (uintptr_t)eie, GFP_NOFS);
-                               if (ret < 0)
-                                       break;
-                               if (!extent_item_pos) {
-                                       ret = btrfs_next_old_leaf(root, path,
-                                                       time_seq);
-                                       continue;
-                               }
+                       if (ret > 0)
+                               goto next;
+                       ret = ulist_add_merge(parents, eb->start,
+                                             (uintptr_t)eie,
+                                             (u64 *)&old, GFP_NOFS);
+                       if (ret < 0)
+                               break;
+                       if (!ret && extent_item_pos) {
+                               while (old->next)
+                                       old = old->next;
+                               old->next = eie;
                        }
                }
+next:
                ret = btrfs_next_old_item(root, path, time_seq);
        }
 
index 5bf4c39e2ad625f2e90bfbbc765fd4e13db47a2b..ed504607d8ecc9e7e492b9c0f2d88ce02ae1d32b 100644 (file)
@@ -1271,7 +1271,6 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
                BUG_ON(!eb_rewin);
        }
 
-       extent_buffer_get(eb_rewin);
        btrfs_tree_read_unlock(eb);
        free_extent_buffer(eb);
 
index 0236de711989097bbf5191dbb6871281d840de22..1204c8ef6f32751bd859d2ef1a2ab3444061f708 100644 (file)
@@ -7466,6 +7466,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
        int err = 0;
        int ret;
        int level;
+       bool root_dropped = false;
 
        path = btrfs_alloc_path();
        if (!path) {
@@ -7523,6 +7524,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                while (1) {
                        btrfs_tree_lock(path->nodes[level]);
                        btrfs_set_lock_blocking(path->nodes[level]);
+                       path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
 
                        ret = btrfs_lookup_extent_info(trans, root,
                                                path->nodes[level]->start,
@@ -7538,6 +7540,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                                break;
 
                        btrfs_tree_unlock(path->nodes[level]);
+                       path->locks[level] = 0;
                        WARN_ON(wc->refs[level] != 1);
                        level--;
                }
@@ -7552,11 +7555,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
        wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
 
        while (1) {
-               if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
-                       pr_debug("btrfs: drop snapshot early exit\n");
-                       err = -EAGAIN;
-                       goto out_end_trans;
-               }
 
                ret = walk_down_tree(trans, root, path, wc);
                if (ret < 0) {
@@ -7584,7 +7582,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                }
 
                BUG_ON(wc->level == 0);
-               if (btrfs_should_end_transaction(trans, tree_root)) {
+               if (btrfs_should_end_transaction(trans, tree_root) ||
+                   (!for_reloc && btrfs_need_cleaner_sleep(root))) {
                        ret = btrfs_update_root(trans, tree_root,
                                                &root->root_key,
                                                root_item);
@@ -7595,6 +7594,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                        }
 
                        btrfs_end_transaction_throttle(trans, tree_root);
+                       if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
+                               pr_debug("btrfs: drop snapshot early exit\n");
+                               err = -EAGAIN;
+                               goto out_free;
+                       }
+
                        trans = btrfs_start_transaction(tree_root, 0);
                        if (IS_ERR(trans)) {
                                err = PTR_ERR(trans);
@@ -7639,12 +7644,22 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
                free_extent_buffer(root->commit_root);
                btrfs_put_fs_root(root);
        }
+       root_dropped = true;
 out_end_trans:
        btrfs_end_transaction_throttle(trans, tree_root);
 out_free:
        kfree(wc);
        btrfs_free_path(path);
 out:
+       /*
+        * So if we need to stop dropping the snapshot for whatever reason we
+        * need to make sure to add it back to the dead root list so that we
+        * keep trying to do the work later.  This also cleans up roots if we
+        * don't have it in the radix (like when we recover after a power fail
+        * or unmount) so we don't leak memory.
+        */
+       if (root_dropped == false)
+               btrfs_add_dead_root(root);
        if (err)
                btrfs_std_error(root->fs_info, err);
        return err;
index 583d98bd065ed83ca979a2786b59ae4342380c47..fe443fece85111d69b833f9cac4e2bbb85b6ea80 100644 (file)
@@ -4048,7 +4048,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
        }
 
        while (!end) {
-               u64 offset_in_extent;
+               u64 offset_in_extent = 0;
 
                /* break if the extent we found is outside the range */
                if (em->start >= max || extent_map_end(em) < off)
@@ -4064,9 +4064,12 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
                /*
                 * record the offset from the start of the extent
-                * for adjusting the disk offset below
+                * for adjusting the disk offset below.  Only do this if the
+                * extent isn't compressed since our in ram offset may be past
+                * what we have actually allocated on disk.
                 */
-               offset_in_extent = em_start - em->start;
+               if (!test_bit(EXTENT_FLAG_COMPRESSED, &em->flags))
+                       offset_in_extent = em_start - em->start;
                em_end = extent_map_end(em);
                em_len = em_end - em_start;
                emflags = em->flags;
index a005fe2c072ad0751254adba0fa4e04db10cc996..8e686a427ce2e8e5e824419321f1f8f2dfe19acb 100644 (file)
@@ -596,20 +596,29 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
                if (no_splits)
                        goto next;
 
-               if (em->block_start < EXTENT_MAP_LAST_BYTE &&
-                   em->start < start) {
+               if (em->start < start) {
                        split->start = em->start;
                        split->len = start - em->start;
-                       split->orig_start = em->orig_start;
-                       split->block_start = em->block_start;
 
-                       if (compressed)
-                               split->block_len = em->block_len;
-                       else
-                               split->block_len = split->len;
-                       split->ram_bytes = em->ram_bytes;
-                       split->orig_block_len = max(split->block_len,
-                                                   em->orig_block_len);
+                       if (em->block_start < EXTENT_MAP_LAST_BYTE) {
+                               split->orig_start = em->orig_start;
+                               split->block_start = em->block_start;
+
+                               if (compressed)
+                                       split->block_len = em->block_len;
+                               else
+                                       split->block_len = split->len;
+                               split->orig_block_len = max(split->block_len,
+                                               em->orig_block_len);
+                               split->ram_bytes = em->ram_bytes;
+                       } else {
+                               split->orig_start = split->start;
+                               split->block_len = 0;
+                               split->block_start = em->block_start;
+                               split->orig_block_len = 0;
+                               split->ram_bytes = split->len;
+                       }
+
                        split->generation = gen;
                        split->bdev = em->bdev;
                        split->flags = flags;
@@ -620,8 +629,7 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
                        split = split2;
                        split2 = NULL;
                }
-               if (em->block_start < EXTENT_MAP_LAST_BYTE &&
-                   testend && em->start + em->len > start + len) {
+               if (testend && em->start + em->len > start + len) {
                        u64 diff = start + len - em->start;
 
                        split->start = start + len;
@@ -630,18 +638,28 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
                        split->flags = flags;
                        split->compress_type = em->compress_type;
                        split->generation = gen;
-                       split->orig_block_len = max(em->block_len,
+
+                       if (em->block_start < EXTENT_MAP_LAST_BYTE) {
+                               split->orig_block_len = max(em->block_len,
                                                    em->orig_block_len);
-                       split->ram_bytes = em->ram_bytes;
 
-                       if (compressed) {
-                               split->block_len = em->block_len;
-                               split->block_start = em->block_start;
-                               split->orig_start = em->orig_start;
+                               split->ram_bytes = em->ram_bytes;
+                               if (compressed) {
+                                       split->block_len = em->block_len;
+                                       split->block_start = em->block_start;
+                                       split->orig_start = em->orig_start;
+                               } else {
+                                       split->block_len = split->len;
+                                       split->block_start = em->block_start
+                                               + diff;
+                                       split->orig_start = em->orig_start;
+                               }
                        } else {
-                               split->block_len = split->len;
-                               split->block_start = em->block_start + diff;
-                               split->orig_start = em->orig_start;
+                               split->ram_bytes = split->len;
+                               split->orig_start = split->start;
+                               split->block_len = 0;
+                               split->block_start = em->block_start;
+                               split->orig_block_len = 0;
                        }
 
                        ret = add_extent_mapping(em_tree, split, modified);
index 6d1b93c8aafb8a4d7b832cab8585ebf1ac1ced42..021694c081814828272ff03a8b9e1f64732a46cc 100644 (file)
@@ -2166,16 +2166,23 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
                if (btrfs_file_extent_disk_bytenr(leaf, extent) != old->bytenr)
                        continue;
 
-               extent_offset = btrfs_file_extent_offset(leaf, extent);
-               if (key.offset - extent_offset != offset)
+               /*
+                * 'offset' refers to the exact key.offset,
+                * NOT the 'offset' field in btrfs_extent_data_ref, ie.
+                * (key.offset - extent_offset).
+                */
+               if (key.offset != offset)
                        continue;
 
+               extent_offset = btrfs_file_extent_offset(leaf, extent);
                num_bytes = btrfs_file_extent_num_bytes(leaf, extent);
+
                if (extent_offset >= old->extent_offset + old->offset +
                    old->len || extent_offset + num_bytes <=
                    old->extent_offset + old->offset)
                        continue;
 
+               ret = 0;
                break;
        }
 
@@ -2187,7 +2194,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
 
        backref->root_id = root_id;
        backref->inum = inum;
-       backref->file_pos = offset + extent_offset;
+       backref->file_pos = offset;
        backref->num_bytes = num_bytes;
        backref->extent_offset = extent_offset;
        backref->generation = btrfs_file_extent_generation(leaf, extent);
@@ -2210,7 +2217,8 @@ static noinline bool record_extent_backrefs(struct btrfs_path *path,
        new->path = path;
 
        list_for_each_entry_safe(old, tmp, &new->head, list) {
-               ret = iterate_inodes_from_logical(old->bytenr, fs_info,
+               ret = iterate_inodes_from_logical(old->bytenr +
+                                                 old->extent_offset, fs_info,
                                                  path, record_one_backref,
                                                  old);
                BUG_ON(ret < 0 && ret != -ENOENT);
@@ -4391,9 +4399,6 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
        int mask = attr->ia_valid;
        int ret;
 
-       if (newsize == oldsize)
-               return 0;
-
        /*
         * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a
         * special case where we need to update the times despite not having
@@ -5165,14 +5170,31 @@ next:
        }
 
        /* Reached end of directory/root. Bump pos past the last item. */
-       if (key_type == BTRFS_DIR_INDEX_KEY)
-               /*
-                * 32-bit glibc will use getdents64, but then strtol -
-                * so the last number we can serve is this.
-                */
-               ctx->pos = 0x7fffffff;
-       else
-               ctx->pos++;
+       ctx->pos++;
+
+       /*
+        * Stop new entries from being returned after we return the last
+        * entry.
+        *
+        * New directory entries are assigned a strictly increasing
+        * offset.  This means that new entries created during readdir
+        * are *guaranteed* to be seen in the future by that readdir.
+        * This has broken buggy programs which operate on names as
+        * they're returned by readdir.  Until we re-use freed offsets
+        * we have this hack to stop new entries from being returned
+        * under the assumption that they'll never reach this huge
+        * offset.
+        *
+        * This is being careful not to overflow 32bit loff_t unless the
+        * last entry requires it because doing so has broken 32bit apps
+        * in the past.
+        */
+       if (key_type == BTRFS_DIR_INDEX_KEY) {
+               if (ctx->pos >= INT_MAX)
+                       ctx->pos = LLONG_MAX;
+               else
+                       ctx->pos = INT_MAX;
+       }
 nopos:
        ret = 0;
 err:
index 4ba2a69a60ad4ffc327697ec4a8db3d04159d0a8..64a157becbe573f778c02e9475483cff5e167ea9 100644 (file)
@@ -2495,7 +2495,7 @@ again:
                        ret = scrub_extent(sctx, extent_logical, extent_len,
                                           extent_physical, extent_dev, flags,
                                           generation, extent_mirror_num,
-                                          extent_physical);
+                                          extent_logical - logical + physical);
                        if (ret)
                                goto out;
 
index d58cce77fc6c581625c3dd0449c83b6836bf4894..af1931a5960d9d602688fe8bb89242d752b71c5f 100644 (file)
@@ -983,12 +983,12 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans,
  * a dirty root struct and adds it into the list of dead roots that need to
  * be deleted
  */
-int btrfs_add_dead_root(struct btrfs_root *root)
+void btrfs_add_dead_root(struct btrfs_root *root)
 {
        spin_lock(&root->fs_info->trans_lock);
-       list_add_tail(&root->root_list, &root->fs_info->dead_roots);
+       if (list_empty(&root->root_list))
+               list_add_tail(&root->root_list, &root->fs_info->dead_roots);
        spin_unlock(&root->fs_info->trans_lock);
-       return 0;
 }
 
 /*
@@ -1925,7 +1925,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
        }
        root = list_first_entry(&fs_info->dead_roots,
                        struct btrfs_root, root_list);
-       list_del(&root->root_list);
+       list_del_init(&root->root_list);
        spin_unlock(&fs_info->trans_lock);
 
        pr_debug("btrfs: cleaner removing %llu\n",
index 005b0375d18cfc6131a4480a9e67e0cbe44ed46a..defbc426989787e405e69f6e360fa82b3dc26556 100644 (file)
@@ -143,7 +143,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid);
 int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
                                     struct btrfs_root *root);
 
-int btrfs_add_dead_root(struct btrfs_root *root);
+void btrfs_add_dead_root(struct btrfs_root *root);
 int btrfs_defrag_root(struct btrfs_root *root);
 int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
 int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
index 2c6791493637250423ac2c9bc21d9ca3f752ed11..ff60d8978ae264d95709d83342e1c309113521f0 100644 (file)
@@ -3746,8 +3746,9 @@ next_slot:
        }
 
 log_extents:
+       btrfs_release_path(path);
+       btrfs_release_path(dst_path);
        if (fast_search) {
-               btrfs_release_path(dst_path);
                ret = btrfs_log_changed_extents(trans, root, inode, dst_path);
                if (ret) {
                        err = ret;
@@ -3764,8 +3765,6 @@ log_extents:
        }
 
        if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) {
-               btrfs_release_path(path);
-               btrfs_release_path(dst_path);
                ret = log_directory_changes(trans, root, inode, path, dst_path);
                if (ret) {
                        err = ret;
index 45e57cc38200448da67b1ce2c896efff555f0e73..fc6f4f3a1a9d6c4c2f8b0c7afa1eb20d8029febf 100644 (file)
@@ -43,17 +43,18 @@ cifs_crypto_shash_md5_allocate(struct TCP_Server_Info *server)
        server->secmech.md5 = crypto_alloc_shash("md5", 0, 0);
        if (IS_ERR(server->secmech.md5)) {
                cifs_dbg(VFS, "could not allocate crypto md5\n");
-               return PTR_ERR(server->secmech.md5);
+               rc = PTR_ERR(server->secmech.md5);
+               server->secmech.md5 = NULL;
+               return rc;
        }
 
        size = sizeof(struct shash_desc) +
                        crypto_shash_descsize(server->secmech.md5);
        server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL);
        if (!server->secmech.sdescmd5) {
-               rc = -ENOMEM;
                crypto_free_shash(server->secmech.md5);
                server->secmech.md5 = NULL;
-               return rc;
+               return -ENOMEM;
        }
        server->secmech.sdescmd5->shash.tfm = server->secmech.md5;
        server->secmech.sdescmd5->shash.flags = 0x0;
@@ -421,7 +422,7 @@ find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp)
                if (blobptr + attrsize > blobend)
                        break;
                if (type == NTLMSSP_AV_NB_DOMAIN_NAME) {
-                       if (!attrsize)
+                       if (!attrsize || attrsize >= CIFS_MAX_DOMAINNAME_LEN)
                                break;
                        if (!ses->domainName) {
                                ses->domainName =
@@ -591,6 +592,7 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
 
 static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server)
 {
+       int rc;
        unsigned int size;
 
        /* check if already allocated */
@@ -600,7 +602,9 @@ static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server)
        server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0);
        if (IS_ERR(server->secmech.hmacmd5)) {
                cifs_dbg(VFS, "could not allocate crypto hmacmd5\n");
-               return PTR_ERR(server->secmech.hmacmd5);
+               rc = PTR_ERR(server->secmech.hmacmd5);
+               server->secmech.hmacmd5 = NULL;
+               return rc;
        }
 
        size = sizeof(struct shash_desc) +
index 4bdd547dbf6fb3d10a2b2b962b710b722d0b9685..85ea98d139fc5643b0606b67959bb1f320037d80 100644 (file)
@@ -147,18 +147,17 @@ cifs_read_super(struct super_block *sb)
                goto out_no_root;
        }
 
+       if (cifs_sb_master_tcon(cifs_sb)->nocase)
+               sb->s_d_op = &cifs_ci_dentry_ops;
+       else
+               sb->s_d_op = &cifs_dentry_ops;
+
        sb->s_root = d_make_root(inode);
        if (!sb->s_root) {
                rc = -ENOMEM;
                goto out_no_root;
        }
 
-       /* do that *after* d_make_root() - we want NULL ->d_op for root here */
-       if (cifs_sb_master_tcon(cifs_sb)->nocase)
-               sb->s_d_op = &cifs_ci_dentry_ops;
-       else
-               sb->s_d_op = &cifs_dentry_ops;
-
 #ifdef CONFIG_CIFS_NFSD_EXPORT
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
                cifs_dbg(FYI, "export ops supported\n");
index 1fdc370410576e1a3f5a36a133245468160ae4b4..52ca861ed35e4fe3fbf78ec387ff401fb0e8fb94 100644 (file)
@@ -44,6 +44,7 @@
 #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
 #define MAX_SERVER_SIZE 15
 #define MAX_SHARE_SIZE 80
+#define CIFS_MAX_DOMAINNAME_LEN 256 /* max domain name length */
 #define MAX_USERNAME_SIZE 256  /* reasonable maximum for current servers */
 #define MAX_PASSWORD_SIZE 512  /* max for windows seems to be 256 wide chars */
 
@@ -369,6 +370,9 @@ struct smb_version_operations {
        void (*generate_signingkey)(struct TCP_Server_Info *server);
        int (*calc_signature)(struct smb_rqst *rqst,
                                   struct TCP_Server_Info *server);
+       int (*query_mf_symlink)(const unsigned char *path, char *pbuf,
+                       unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
+                       unsigned int xid);
 };
 
 struct smb_version_values {
index f7e584d047e202e0185f4936a71ef189e1a2781a..b29a012bed33a24b6ba45b17f95c70303e3e3014 100644 (file)
@@ -497,5 +497,7 @@ void cifs_writev_complete(struct work_struct *work);
 struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages,
                                                work_func_t complete);
 void cifs_writedata_release(struct kref *refcount);
-
+int open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
+                       unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
+                       unsigned int xid);
 #endif                 /* _CIFSPROTO_H */
index fa68813396b5acb7e7a2e5a65e1202d740688cbb..d67c550c49806254da76ca6f7dd32d29144c3c16 100644 (file)
@@ -1675,7 +1675,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
                        if (string == NULL)
                                goto out_nomem;
 
-                       if (strnlen(string, 256) == 256) {
+                       if (strnlen(string, CIFS_MAX_DOMAINNAME_LEN)
+                                       == CIFS_MAX_DOMAINNAME_LEN) {
                                printk(KERN_WARNING "CIFS: domain name too"
                                                    " long\n");
                                goto cifs_parse_mount_err;
@@ -2276,8 +2277,8 @@ cifs_put_smb_ses(struct cifs_ses *ses)
 
 #ifdef CONFIG_KEYS
 
-/* strlen("cifs:a:") + INET6_ADDRSTRLEN + 1 */
-#define CIFSCREDS_DESC_SIZE (7 + INET6_ADDRSTRLEN + 1)
+/* strlen("cifs:a:") + CIFS_MAX_DOMAINNAME_LEN + 1 */
+#define CIFSCREDS_DESC_SIZE (7 + CIFS_MAX_DOMAINNAME_LEN + 1)
 
 /* Populate username and pw fields from keyring if possible */
 static int
index 1e57f36ea1b2f84ac43c486cf6aa9cff4b2280a0..7e36ae34e9479b2614d61c919d393291593ef28f 100644 (file)
@@ -647,6 +647,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
                                     oflags, &oplock, &cfile->fid.netfid, xid);
                if (rc == 0) {
                        cifs_dbg(FYI, "posix reopen succeeded\n");
+                       oparms.reconnect = true;
                        goto reopen_success;
                }
                /*
index b83c3f5646bde6e21e80806541a00987198a5ce1..562044f700e56bf27997bf7ef7490bddf6bc1c91 100644 (file)
@@ -305,67 +305,89 @@ CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr)
 }
 
 int
-CIFSCheckMFSymlink(struct cifs_fattr *fattr,
-                  const unsigned char *path,
-                  struct cifs_sb_info *cifs_sb, unsigned int xid)
+open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
+                       unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
+                       unsigned int xid)
 {
        int rc;
        int oplock = 0;
        __u16 netfid = 0;
        struct tcon_link *tlink;
-       struct cifs_tcon *pTcon;
+       struct cifs_tcon *ptcon;
        struct cifs_io_parms io_parms;
-       u8 *buf;
-       char *pbuf;
-       unsigned int bytes_read = 0;
        int buf_type = CIFS_NO_BUFFER;
-       unsigned int link_len = 0;
        FILE_ALL_INFO file_info;
 
-       if (!CIFSCouldBeMFSymlink(fattr))
-               /* it's not a symlink */
-               return 0;
-
        tlink = cifs_sb_tlink(cifs_sb);
        if (IS_ERR(tlink))
                return PTR_ERR(tlink);
-       pTcon = tlink_tcon(tlink);
+       ptcon = tlink_tcon(tlink);
 
-       rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
+       rc = CIFSSMBOpen(xid, ptcon, path, FILE_OPEN, GENERIC_READ,
                         CREATE_NOT_DIR, &netfid, &oplock, &file_info,
                         cifs_sb->local_nls,
                         cifs_sb->mnt_cifs_flags &
                                CIFS_MOUNT_MAP_SPECIAL_CHR);
-       if (rc != 0)
-               goto out;
+       if (rc != 0) {
+               cifs_put_tlink(tlink);
+               return rc;
+       }
 
        if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
-               CIFSSMBClose(xid, pTcon, netfid);
+               CIFSSMBClose(xid, ptcon, netfid);
+               cifs_put_tlink(tlink);
                /* it's not a symlink */
-               goto out;
+               return rc;
        }
 
-       buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
-       if (!buf) {
-               rc = -ENOMEM;
-               goto out;
-       }
-       pbuf = buf;
        io_parms.netfid = netfid;
        io_parms.pid = current->tgid;
-       io_parms.tcon = pTcon;
+       io_parms.tcon = ptcon;
        io_parms.offset = 0;
        io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
 
-       rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type);
-       CIFSSMBClose(xid, pTcon, netfid);
-       if (rc != 0) {
-               kfree(buf);
+       rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
+       CIFSSMBClose(xid, ptcon, netfid);
+       cifs_put_tlink(tlink);
+       return rc;
+}
+
+
+int
+CIFSCheckMFSymlink(struct cifs_fattr *fattr,
+                  const unsigned char *path,
+                  struct cifs_sb_info *cifs_sb, unsigned int xid)
+{
+       int rc = 0;
+       u8 *buf = NULL;
+       unsigned int link_len = 0;
+       unsigned int bytes_read = 0;
+       struct cifs_tcon *ptcon;
+
+       if (!CIFSCouldBeMFSymlink(fattr))
+               /* it's not a symlink */
+               return 0;
+
+       buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
+       if (!buf) {
+               rc = -ENOMEM;
                goto out;
        }
 
+       ptcon = tlink_tcon(cifs_sb_tlink(cifs_sb));
+       if ((ptcon->ses) && (ptcon->ses->server->ops->query_mf_symlink))
+               rc = ptcon->ses->server->ops->query_mf_symlink(path, buf,
+                                                &bytes_read, cifs_sb, xid);
+       else
+               goto out;
+
+       if (rc != 0)
+               goto out;
+
+       if (bytes_read == 0) /* not a symlink */
+               goto out;
+
        rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, NULL);
-       kfree(buf);
        if (rc == -EINVAL) {
                /* it's not a symlink */
                rc = 0;
@@ -381,7 +403,7 @@ CIFSCheckMFSymlink(struct cifs_fattr *fattr,
        fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
        fattr->cf_dtype = DT_LNK;
 out:
-       cifs_put_tlink(tlink);
+       kfree(buf);
        return rc;
 }
 
index ab877846939499c18cb454c83ed26c43dc60040c..69d2c826a23badc552bb686b518beaea297b473c 100644 (file)
@@ -111,6 +111,14 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
                        return;
        }
 
+       /*
+        * If we know that the inode will need to be revalidated immediately,
+        * then don't create a new dentry for it. We'll end up doing an on
+        * the wire call either way and this spares us an invalidation.
+        */
+       if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)
+               return;
+
        dentry = d_alloc(parent, name);
        if (!dentry)
                return;
index 79358e341fd2ea63cff42e6d608c58f65b5f9804..08dd37bb23aac8ea04fe979743f8c963990a80f7 100644 (file)
@@ -197,7 +197,7 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses,
                bytes_ret = 0;
        } else
                bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName,
-                                           256, nls_cp);
+                                           CIFS_MAX_DOMAINNAME_LEN, nls_cp);
        bcc_ptr += 2 * bytes_ret;
        bcc_ptr += 2;  /* account for null terminator */
 
@@ -255,8 +255,8 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
 
        /* copy domain */
        if (ses->domainName != NULL) {
-               strncpy(bcc_ptr, ses->domainName, 256);
-               bcc_ptr += strnlen(ses->domainName, 256);
+               strncpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
+               bcc_ptr += strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
        } /* else we will send a null domain name
             so the server will default to its own domain */
        *bcc_ptr = 0;
index 6457690731a220b58fa2be3f55bd6bf430f27b8b..60943978aec35bb06360adb7e060802d5775bee1 100644 (file)
@@ -944,6 +944,7 @@ struct smb_version_operations smb1_operations = {
        .mand_lock = cifs_mand_lock,
        .mand_unlock_range = cifs_unlock_range,
        .push_mand_locks = cifs_push_mandatory_locks,
+       .query_mf_symlink = open_query_close_cifs_symlink,
 };
 
 struct smb_version_values smb1_values = {
index 301b191270b9bcf09edbea5ad47100267f32e859..4f2300d020c7e517a6fa89be5d955fa4b12753da 100644 (file)
@@ -42,6 +42,7 @@
 static int
 smb2_crypto_shash_allocate(struct TCP_Server_Info *server)
 {
+       int rc;
        unsigned int size;
 
        if (server->secmech.sdeschmacsha256 != NULL)
@@ -50,7 +51,9 @@ smb2_crypto_shash_allocate(struct TCP_Server_Info *server)
        server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0);
        if (IS_ERR(server->secmech.hmacsha256)) {
                cifs_dbg(VFS, "could not allocate crypto hmacsha256\n");
-               return PTR_ERR(server->secmech.hmacsha256);
+               rc = PTR_ERR(server->secmech.hmacsha256);
+               server->secmech.hmacsha256 = NULL;
+               return rc;
        }
 
        size = sizeof(struct shash_desc) +
@@ -87,7 +90,9 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
                server->secmech.sdeschmacsha256 = NULL;
                crypto_free_shash(server->secmech.hmacsha256);
                server->secmech.hmacsha256 = NULL;
-               return PTR_ERR(server->secmech.cmacaes);
+               rc = PTR_ERR(server->secmech.cmacaes);
+               server->secmech.cmacaes = NULL;
+               return rc;
        }
 
        size = sizeof(struct shash_desc) +
index 4888cb3fdef76037b7af5f9db898bdcb82ce48c2..c7c83ff0f752ce6a86d6e42a420e34ed996ae8ca 100644 (file)
@@ -533,8 +533,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);
  */
 void debugfs_remove_recursive(struct dentry *dentry)
 {
-       struct dentry *child;
-       struct dentry *parent;
+       struct dentry *child, *next, *parent;
 
        if (IS_ERR_OR_NULL(dentry))
                return;
@@ -544,61 +543,37 @@ void debugfs_remove_recursive(struct dentry *dentry)
                return;
 
        parent = dentry;
+ down:
        mutex_lock(&parent->d_inode->i_mutex);
+       list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {
+               if (!debugfs_positive(child))
+                       continue;
 
-       while (1) {
-               /*
-                * When all dentries under "parent" has been removed,
-                * walk up the tree until we reach our starting point.
-                */
-               if (list_empty(&parent->d_subdirs)) {
-                       mutex_unlock(&parent->d_inode->i_mutex);
-                       if (parent == dentry)
-                               break;
-                       parent = parent->d_parent;
-                       mutex_lock(&parent->d_inode->i_mutex);
-               }
-               child = list_entry(parent->d_subdirs.next, struct dentry,
-                               d_u.d_child);
- next_sibling:
-
-               /*
-                * If "child" isn't empty, walk down the tree and
-                * remove all its descendants first.
-                */
+               /* perhaps simple_empty(child) makes more sense */
                if (!list_empty(&child->d_subdirs)) {
                        mutex_unlock(&parent->d_inode->i_mutex);
                        parent = child;
-                       mutex_lock(&parent->d_inode->i_mutex);
-                       continue;
+                       goto down;
                }
-               __debugfs_remove(child, parent);
-               if (parent->d_subdirs.next == &child->d_u.d_child) {
-                       /*
-                        * Try the next sibling.
-                        */
-                       if (child->d_u.d_child.next != &parent->d_subdirs) {
-                               child = list_entry(child->d_u.d_child.next,
-                                                  struct dentry,
-                                                  d_u.d_child);
-                               goto next_sibling;
-                       }
-
-                       /*
-                        * Avoid infinite loop if we fail to remove
-                        * one dentry.
-                        */
-                       mutex_unlock(&parent->d_inode->i_mutex);
-                       break;
-               }
-               simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ up:
+               if (!__debugfs_remove(child, parent))
+                       simple_release_fs(&debugfs_mount, &debugfs_mount_count);
        }
 
-       parent = dentry->d_parent;
+       mutex_unlock(&parent->d_inode->i_mutex);
+       child = parent;
+       parent = parent->d_parent;
        mutex_lock(&parent->d_inode->i_mutex);
-       __debugfs_remove(dentry, parent);
+
+       if (child != dentry) {
+               next = list_entry(child->d_u.d_child.next, struct dentry,
+                                       d_u.d_child);
+               goto up;
+       }
+
+       if (!__debugfs_remove(child, parent))
+               simple_release_fs(&debugfs_mount, &debugfs_mount_count);
        mutex_unlock(&parent->d_inode->i_mutex);
-       simple_release_fs(&debugfs_mount, &debugfs_mount_count);
 }
 EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
 
index 911649a47dd5ae5b000bfabb2b73b0c71a95ec52..812149119fa3c36291508af6fc33a7646c84155f 100644 (file)
@@ -686,7 +686,6 @@ static int device_close(struct inode *inode, struct file *file)
           device_remove_lockspace() */
 
        sigprocmask(SIG_SETMASK, &tmpsig, NULL);
-       recalc_sigpending();
 
        return 0;
 }
index 9c73def87642fc8f36624b7fa525504541a59a04..fd774c7cb4831be8817799ed6cab355a368fa19f 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -608,7 +608,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
                return -ENOMEM;
 
        lru_add_drain();
-       tlb_gather_mmu(&tlb, mm, 0);
+       tlb_gather_mmu(&tlb, mm, old_start, old_end);
        if (new_end > old_start) {
                /*
                 * when the old and new regions overlap clear from new_end.
@@ -625,7 +625,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
                free_pgd_range(&tlb, old_start, old_end, new_end,
                        vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
        }
-       tlb_finish_mmu(&tlb, new_end, old_end);
+       tlb_finish_mmu(&tlb, old_start, old_end);
 
        /*
         * Shrink the vma to just the new range.  Always succeeds.
index 998ea111e537e8502dd33b15d5d9eb5f5374306d..1194b1f0f8396c934ab6a382deadab6c0a6c4c2f 100644 (file)
@@ -1780,11 +1780,11 @@ retry:
                inode->i_op = &ext3_file_inode_operations;
                inode->i_fop = &ext3_file_operations;
                ext3_set_aops(inode);
+               d_tmpfile(dentry, inode);
                err = ext3_orphan_add(handle, inode);
                if (err)
                        goto err_drop_inode;
                mark_inode_dirty(inode);
-               d_tmpfile(dentry, inode);
                unlock_new_inode(inode);
        }
        ext3_journal_stop(handle);
index 58339393fa6e55c689adfa375b804a108a25c924..ddd715e42a5c516be8e576015e073846d872f578 100644 (file)
@@ -38,8 +38,8 @@ ext4_group_t ext4_get_group_number(struct super_block *sb,
        ext4_group_t group;
 
        if (test_opt2(sb, STD_GROUP_SIZE))
-               group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) +
-                        block) >>
+               group = (block -
+                        le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) >>
                        (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3);
        else
                ext4_get_group_no_and_offset(sb, block, &group, NULL);
index b577e45425b0ac921ae1f0904b6ef84b7ace8fb3..0ab26fbf33808c565ae9ef4449d6836e4cb01fae 100644 (file)
@@ -2086,6 +2086,7 @@ extern int  ext4_sync_inode(handle_t *, struct inode *);
 extern void ext4_dirty_inode(struct inode *, int);
 extern int ext4_change_inode_journal_flag(struct inode *, int);
 extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
+extern int ext4_inode_attach_jinode(struct inode *inode);
 extern int ext4_can_truncate(struct inode *inode);
 extern void ext4_truncate(struct inode *);
 extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length);
index 72a3600aedbdffe48b5f2756bb0ad863f120a7b8..17ac112ab1012bd88ff32d145f27a29f025efdde 100644 (file)
@@ -255,10 +255,10 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
        set_buffer_prio(bh);
        if (ext4_handle_valid(handle)) {
                err = jbd2_journal_dirty_metadata(handle, bh);
-               if (err) {
-                       /* Errors can only happen if there is a bug */
-                       handle->h_err = err;
-                       __ext4_journal_stop(where, line, handle);
+               /* Errors can only happen if there is a bug */
+               if (WARN_ON_ONCE(err)) {
+                       ext4_journal_abort_handle(where, line, __func__, bh,
+                                                 handle, err);
                }
        } else {
                if (inode)
index 7097b0f680e62bbf674364008ef66887a5e0fdca..72ba4705d4fa40e12edd1097f0815381688df7e6 100644 (file)
@@ -2835,6 +2835,9 @@ again:
                                err = -EIO;
                                break;
                        }
+                       /* Yield here to deal with large extent trees.
+                        * Should be a no-op if we did IO above. */
+                       cond_resched();
                        if (WARN_ON(i + 1 > depth)) {
                                err = -EIO;
                                break;
@@ -4261,8 +4264,8 @@ got_allocated_blocks:
                /* not a good idea to call discard here directly,
                 * but otherwise we'd need to call it every free() */
                ext4_discard_preallocations(inode);
-               ext4_free_blocks(handle, inode, NULL, ext4_ext_pblock(&newex),
-                                ext4_ext_get_actual_len(&newex), fb_flags);
+               ext4_free_blocks(handle, inode, NULL, newblock,
+                                EXT4_C2B(sbi, allocated_clusters), fb_flags);
                goto out2;
        }
 
@@ -4382,8 +4385,9 @@ out2:
        }
 
 out3:
-       trace_ext4_ext_map_blocks_exit(inode, flags, map, err ? err : allocated);
-
+       trace_ext4_ext_map_blocks_exit(inode, flags, map,
+                                      err ? err : allocated);
+       ext4_es_lru_add(inode);
        return err ? err : allocated;
 }
 
@@ -4405,9 +4409,20 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode)
 
        last_block = (inode->i_size + sb->s_blocksize - 1)
                        >> EXT4_BLOCK_SIZE_BITS(sb);
+retry:
        err = ext4_es_remove_extent(inode, last_block,
                                    EXT_MAX_BLOCKS - last_block);
+       if (err == -ENOMEM) {
+               cond_resched();
+               congestion_wait(BLK_RW_ASYNC, HZ/50);
+               goto retry;
+       }
+       if (err) {
+               ext4_std_error(inode->i_sb, err);
+               return;
+       }
        err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
+       ext4_std_error(inode->i_sb, err);
 }
 
 static void ext4_falloc_update_inode(struct inode *inode,
index ee018d5f397e6ba88ec0bf21196e1ad0612d4e53..91cb110da1b4fe6fe9e334073ddae337507cd5d6 100644 (file)
@@ -148,6 +148,8 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
                              ext4_lblk_t end);
 static int __es_try_to_reclaim_extents(struct ext4_inode_info *ei,
                                       int nr_to_scan);
+static int __ext4_es_shrink(struct ext4_sb_info *sbi, int nr_to_scan,
+                           struct ext4_inode_info *locked_ei);
 
 int __init ext4_init_es(void)
 {
@@ -439,7 +441,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
                 */
                if (!ext4_es_is_written(es) && !ext4_es_is_unwritten(es)) {
                        if (in_range(es->es_lblk, ee_block, ee_len)) {
-                               pr_warn("ES insert assertation failed for "
+                               pr_warn("ES insert assertion failed for "
                                        "inode: %lu we can find an extent "
                                        "at block [%d/%d/%llu/%c], but we "
                                        "want to add an delayed/hole extent "
@@ -458,7 +460,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
                 */
                if (es->es_lblk < ee_block ||
                    ext4_es_pblock(es) != ee_start + es->es_lblk - ee_block) {
-                       pr_warn("ES insert assertation failed for inode: %lu "
+                       pr_warn("ES insert assertion failed for inode: %lu "
                                "ex_status [%d/%d/%llu/%c] != "
                                "es_status [%d/%d/%llu/%c]\n", inode->i_ino,
                                ee_block, ee_len, ee_start,
@@ -468,7 +470,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
                }
 
                if (ee_status ^ es_status) {
-                       pr_warn("ES insert assertation failed for inode: %lu "
+                       pr_warn("ES insert assertion failed for inode: %lu "
                                "ex_status [%d/%d/%llu/%c] != "
                                "es_status [%d/%d/%llu/%c]\n", inode->i_ino,
                                ee_block, ee_len, ee_start,
@@ -481,7 +483,7 @@ static void ext4_es_insert_extent_ext_check(struct inode *inode,
                 * that we don't want to add an written/unwritten extent.
                 */
                if (!ext4_es_is_delayed(es) && !ext4_es_is_hole(es)) {
-                       pr_warn("ES insert assertation failed for inode: %lu "
+                       pr_warn("ES insert assertion failed for inode: %lu "
                                "can't find an extent at block %d but we want "
                                "to add an written/unwritten extent "
                                "[%d/%d/%llu/%llx]\n", inode->i_ino,
@@ -519,7 +521,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
                         * We want to add a delayed/hole extent but this
                         * block has been allocated.
                         */
-                       pr_warn("ES insert assertation failed for inode: %lu "
+                       pr_warn("ES insert assertion failed for inode: %lu "
                                "We can find blocks but we want to add a "
                                "delayed/hole extent [%d/%d/%llu/%llx]\n",
                                inode->i_ino, es->es_lblk, es->es_len,
@@ -527,13 +529,13 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
                        return;
                } else if (ext4_es_is_written(es)) {
                        if (retval != es->es_len) {
-                               pr_warn("ES insert assertation failed for "
+                               pr_warn("ES insert assertion failed for "
                                        "inode: %lu retval %d != es_len %d\n",
                                        inode->i_ino, retval, es->es_len);
                                return;
                        }
                        if (map.m_pblk != ext4_es_pblock(es)) {
-                               pr_warn("ES insert assertation failed for "
+                               pr_warn("ES insert assertion failed for "
                                        "inode: %lu m_pblk %llu != "
                                        "es_pblk %llu\n",
                                        inode->i_ino, map.m_pblk,
@@ -549,7 +551,7 @@ static void ext4_es_insert_extent_ind_check(struct inode *inode,
                }
        } else if (retval == 0) {
                if (ext4_es_is_written(es)) {
-                       pr_warn("ES insert assertation failed for inode: %lu "
+                       pr_warn("ES insert assertion failed for inode: %lu "
                                "We can't find the block but we want to add "
                                "an written extent [%d/%d/%llu/%llx]\n",
                                inode->i_ino, es->es_lblk, es->es_len,
@@ -632,10 +634,8 @@ out:
 }
 
 /*
- * ext4_es_insert_extent() adds a space to a extent status tree.
- *
- * ext4_es_insert_extent is called by ext4_da_write_begin and
- * ext4_es_remove_extent.
+ * ext4_es_insert_extent() adds information to an inode's extent
+ * status tree.
  *
  * Return 0 on success, error code on failure.
  */
@@ -667,7 +667,13 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
        err = __es_remove_extent(inode, lblk, end);
        if (err != 0)
                goto error;
+retry:
        err = __es_insert_extent(inode, &newes);
+       if (err == -ENOMEM && __ext4_es_shrink(EXT4_SB(inode->i_sb), 1,
+                                              EXT4_I(inode)))
+               goto retry;
+       if (err == -ENOMEM && !ext4_es_is_delayed(&newes))
+               err = 0;
 
 error:
        write_unlock(&EXT4_I(inode)->i_es_lock);
@@ -746,8 +752,10 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
        struct extent_status orig_es;
        ext4_lblk_t len1, len2;
        ext4_fsblk_t block;
-       int err = 0;
+       int err;
 
+retry:
+       err = 0;
        es = __es_tree_search(&tree->root, lblk);
        if (!es)
                goto out;
@@ -782,6 +790,10 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
                        if (err) {
                                es->es_lblk = orig_es.es_lblk;
                                es->es_len = orig_es.es_len;
+                               if ((err == -ENOMEM) &&
+                                   __ext4_es_shrink(EXT4_SB(inode->i_sb), 1,
+                                                    EXT4_I(inode)))
+                                       goto retry;
                                goto out;
                        }
                } else {
@@ -891,22 +903,14 @@ static int ext4_inode_touch_time_cmp(void *priv, struct list_head *a,
                return -1;
 }
 
-static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
+static int __ext4_es_shrink(struct ext4_sb_info *sbi, int nr_to_scan,
+                           struct ext4_inode_info *locked_ei)
 {
-       struct ext4_sb_info *sbi = container_of(shrink,
-                                       struct ext4_sb_info, s_es_shrinker);
        struct ext4_inode_info *ei;
        struct list_head *cur, *tmp;
        LIST_HEAD(skiped);
-       int nr_to_scan = sc->nr_to_scan;
        int ret, nr_shrunk = 0;
 
-       ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt);
-       trace_ext4_es_shrink_enter(sbi->s_sb, nr_to_scan, ret);
-
-       if (!nr_to_scan)
-               return ret;
-
        spin_lock(&sbi->s_es_lru_lock);
 
        /*
@@ -935,7 +939,7 @@ static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
                        continue;
                }
 
-               if (ei->i_es_lru_nr == 0)
+               if (ei->i_es_lru_nr == 0 || ei == locked_ei)
                        continue;
 
                write_lock(&ei->i_es_lock);
@@ -954,6 +958,27 @@ static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
        list_splice_tail(&skiped, &sbi->s_es_lru);
        spin_unlock(&sbi->s_es_lru_lock);
 
+       if (locked_ei && nr_shrunk == 0)
+               nr_shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan);
+
+       return nr_shrunk;
+}
+
+static int ext4_es_shrink(struct shrinker *shrink, struct shrink_control *sc)
+{
+       struct ext4_sb_info *sbi = container_of(shrink,
+                                       struct ext4_sb_info, s_es_shrinker);
+       int nr_to_scan = sc->nr_to_scan;
+       int ret, nr_shrunk;
+
+       ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt);
+       trace_ext4_es_shrink_enter(sbi->s_sb, nr_to_scan, ret);
+
+       if (!nr_to_scan)
+               return ret;
+
+       nr_shrunk = __ext4_es_shrink(sbi, nr_to_scan, NULL);
+
        ret = percpu_counter_read_positive(&sbi->s_extent_cache_cnt);
        trace_ext4_es_shrink_exit(sbi->s_sb, nr_shrunk, ret);
        return ret;
index 6f4cc567c382b7289e2b35a7038756a581b4cd95..319c9d26279a94fa7039dc2f8730747fe2404697 100644 (file)
@@ -219,7 +219,6 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
 {
        struct super_block *sb = inode->i_sb;
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-       struct ext4_inode_info *ei = EXT4_I(inode);
        struct vfsmount *mnt = filp->f_path.mnt;
        struct path path;
        char buf[64], *cp;
@@ -259,22 +258,10 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
         * Set up the jbd2_inode if we are opening the inode for
         * writing and the journal is present
         */
-       if (sbi->s_journal && !ei->jinode && (filp->f_mode & FMODE_WRITE)) {
-               struct jbd2_inode *jinode = jbd2_alloc_inode(GFP_KERNEL);
-
-               spin_lock(&inode->i_lock);
-               if (!ei->jinode) {
-                       if (!jinode) {
-                               spin_unlock(&inode->i_lock);
-                               return -ENOMEM;
-                       }
-                       ei->jinode = jinode;
-                       jbd2_journal_init_jbd_inode(ei->jinode, inode);
-                       jinode = NULL;
-               }
-               spin_unlock(&inode->i_lock);
-               if (unlikely(jinode != NULL))
-                       jbd2_free_inode(jinode);
+       if (filp->f_mode & FMODE_WRITE) {
+               int ret = ext4_inode_attach_jinode(inode);
+               if (ret < 0)
+                       return ret;
        }
        return dquot_file_open(inode, filp);
 }
index f03598c6ffd3a48282193a13ff30ab6e412e471b..8bf5999875ee454c67899dad4c49ed2ec9445ffc 100644 (file)
@@ -734,11 +734,8 @@ repeat_in_this_group:
                ino = ext4_find_next_zero_bit((unsigned long *)
                                              inode_bitmap_bh->b_data,
                                              EXT4_INODES_PER_GROUP(sb), ino);
-               if (ino >= EXT4_INODES_PER_GROUP(sb)) {
-                       if (++group == ngroups)
-                               group = 0;
-                       continue;
-               }
+               if (ino >= EXT4_INODES_PER_GROUP(sb))
+                       goto next_group;
                if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) {
                        ext4_error(sb, "reserved inode found cleared - "
                                   "inode=%lu", ino + 1);
@@ -769,6 +766,9 @@ repeat_in_this_group:
                        goto got; /* we grabbed the inode! */
                if (ino < EXT4_INODES_PER_GROUP(sb))
                        goto repeat_in_this_group;
+next_group:
+               if (++group == ngroups)
+                       group = 0;
        }
        err = -ENOSPC;
        goto out;
index 0188e65e1f589efbf1be3726ad1cc1a2236a0739..c2ca04e67a4fce6a40316550215e2b2fbe107d01 100644 (file)
@@ -465,7 +465,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle,
        if (es_map->m_lblk != map->m_lblk ||
            es_map->m_flags != map->m_flags ||
            es_map->m_pblk != map->m_pblk) {
-               printk("ES cache assertation failed for inode: %lu "
+               printk("ES cache assertion failed for inode: %lu "
                       "es_cached ex [%d/%d/%llu/%x] != "
                       "found ex [%d/%d/%llu/%x] retval %d flags %x\n",
                       inode->i_ino, es_map->m_lblk, es_map->m_len,
@@ -514,10 +514,9 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
                  "logical block %lu\n", inode->i_ino, flags, map->m_len,
                  (unsigned long) map->m_lblk);
 
-       ext4_es_lru_add(inode);
-
        /* Lookup extent status tree firstly */
        if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
+               ext4_es_lru_add(inode);
                if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) {
                        map->m_pblk = ext4_es_pblock(&es) +
                                        map->m_lblk - es.es_lblk;
@@ -556,14 +555,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
                int ret;
                unsigned long long status;
 
-#ifdef ES_AGGRESSIVE_TEST
-               if (retval != map->m_len) {
-                       printk("ES len assertation failed for inode: %lu "
-                              "retval %d != map->m_len %d "
-                              "in %s (lookup)\n", inode->i_ino, retval,
-                              map->m_len, __func__);
+               if (unlikely(retval != map->m_len)) {
+                       ext4_warning(inode->i_sb,
+                                    "ES len assertion failed for inode "
+                                    "%lu: retval %d != map->m_len %d",
+                                    inode->i_ino, retval, map->m_len);
+                       WARN_ON(1);
                }
-#endif
 
                status = map->m_flags & EXT4_MAP_UNWRITTEN ?
                                EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
@@ -657,14 +655,13 @@ found:
                int ret;
                unsigned long long status;
 
-#ifdef ES_AGGRESSIVE_TEST
-               if (retval != map->m_len) {
-                       printk("ES len assertation failed for inode: %lu "
-                              "retval %d != map->m_len %d "
-                              "in %s (allocation)\n", inode->i_ino, retval,
-                              map->m_len, __func__);
+               if (unlikely(retval != map->m_len)) {
+                       ext4_warning(inode->i_sb,
+                                    "ES len assertion failed for inode "
+                                    "%lu: retval %d != map->m_len %d",
+                                    inode->i_ino, retval, map->m_len);
+                       WARN_ON(1);
                }
-#endif
 
                /*
                 * If the extent has been zeroed out, we don't need to update
@@ -1529,11 +1526,9 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
                  "logical block %lu\n", inode->i_ino, map->m_len,
                  (unsigned long) map->m_lblk);
 
-       ext4_es_lru_add(inode);
-
        /* Lookup extent status tree firstly */
        if (ext4_es_lookup_extent(inode, iblock, &es)) {
-
+               ext4_es_lru_add(inode);
                if (ext4_es_is_hole(&es)) {
                        retval = 0;
                        down_read((&EXT4_I(inode)->i_data_sem));
@@ -1640,14 +1635,13 @@ add_delayed:
                int ret;
                unsigned long long status;
 
-#ifdef ES_AGGRESSIVE_TEST
-               if (retval != map->m_len) {
-                       printk("ES len assertation failed for inode: %lu "
-                              "retval %d != map->m_len %d "
-                              "in %s (lookup)\n", inode->i_ino, retval,
-                              map->m_len, __func__);
+               if (unlikely(retval != map->m_len)) {
+                       ext4_warning(inode->i_sb,
+                                    "ES len assertion failed for inode "
+                                    "%lu: retval %d != map->m_len %d",
+                                    inode->i_ino, retval, map->m_len);
+                       WARN_ON(1);
                }
-#endif
 
                status = map->m_flags & EXT4_MAP_UNWRITTEN ?
                                EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
@@ -2163,7 +2157,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
 
        mpd->io_submit.io_end->offset =
                                ((loff_t)map->m_lblk) << inode->i_blkbits;
-       while (map->m_len) {
+       do {
                err = mpage_map_one_extent(handle, mpd);
                if (err < 0) {
                        struct super_block *sb = inode->i_sb;
@@ -2201,7 +2195,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
                err = mpage_map_and_submit_buffers(mpd);
                if (err < 0)
                        return err;
-       }
+       } while (map->m_len);
 
        /* Update on-disk size after IO is submitted */
        disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT;
@@ -3539,6 +3533,18 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
                   offset;
        }
 
+       if (offset & (sb->s_blocksize - 1) ||
+           (offset + length) & (sb->s_blocksize - 1)) {
+               /*
+                * Attach jinode to inode for jbd2 if we do any zeroing of
+                * partial block
+                */
+               ret = ext4_inode_attach_jinode(inode);
+               if (ret < 0)
+                       goto out_mutex;
+
+       }
+
        first_block_offset = round_up(offset, sb->s_blocksize);
        last_block_offset = round_down((offset + length), sb->s_blocksize) - 1;
 
@@ -3607,6 +3613,31 @@ out_mutex:
        return ret;
 }
 
+int ext4_inode_attach_jinode(struct inode *inode)
+{
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       struct jbd2_inode *jinode;
+
+       if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal)
+               return 0;
+
+       jinode = jbd2_alloc_inode(GFP_KERNEL);
+       spin_lock(&inode->i_lock);
+       if (!ei->jinode) {
+               if (!jinode) {
+                       spin_unlock(&inode->i_lock);
+                       return -ENOMEM;
+               }
+               ei->jinode = jinode;
+               jbd2_journal_init_jbd_inode(ei->jinode, inode);
+               jinode = NULL;
+       }
+       spin_unlock(&inode->i_lock);
+       if (unlikely(jinode != NULL))
+               jbd2_free_inode(jinode);
+       return 0;
+}
+
 /*
  * ext4_truncate()
  *
@@ -3667,6 +3698,12 @@ void ext4_truncate(struct inode *inode)
                        return;
        }
 
+       /* If we zero-out tail of the page, we have to create jinode for jbd2 */
+       if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
+               if (ext4_inode_attach_jinode(inode) < 0)
+                       return;
+       }
+
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
                credits = ext4_writepage_trans_blocks(inode);
        else
index 9491ac0590f746b9abe56e484e7646022a0bd1c3..c0427e2f66481a13f3018b4630901688fdd6646e 100644 (file)
@@ -77,8 +77,10 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
        memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data));
        memswap(&ei1->i_flags, &ei2->i_flags, sizeof(ei1->i_flags));
        memswap(&ei1->i_disksize, &ei2->i_disksize, sizeof(ei1->i_disksize));
-       memswap(&ei1->i_es_tree, &ei2->i_es_tree, sizeof(ei1->i_es_tree));
-       memswap(&ei1->i_es_lru_nr, &ei2->i_es_lru_nr, sizeof(ei1->i_es_lru_nr));
+       ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
+       ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
+       ext4_es_lru_del(inode1);
+       ext4_es_lru_del(inode2);
 
        isize = i_size_read(inode1);
        i_size_write(inode1, i_size_read(inode2));
index a9ff5e5137ca85306f408eda2cab09669962f603..4bbbf13bd7435fd2181aee091dfd6212347463da 100644 (file)
@@ -4740,11 +4740,16 @@ do_more:
                 * blocks being freed are metadata. these blocks shouldn't
                 * be used until this transaction is committed
                 */
+       retry:
                new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS);
                if (!new_entry) {
-                       ext4_mb_unload_buddy(&e4b);
-                       err = -ENOMEM;
-                       goto error_return;
+                       /*
+                        * We use a retry loop because
+                        * ext4_free_blocks() is not allowed to fail.
+                        */
+                       cond_resched();
+                       congestion_wait(BLK_RW_ASYNC, HZ/50);
+                       goto retry;
                }
                new_entry->efd_start_cluster = bit;
                new_entry->efd_group = block_group;
index 234b834d5a9749991e30a97e24e6017124c4e51d..35f55a0dbc4b0bb044571a647a8d1982e9533c4b 100644 (file)
@@ -2316,11 +2316,11 @@ retry:
                inode->i_op = &ext4_file_inode_operations;
                inode->i_fop = &ext4_file_operations;
                ext4_set_aops(inode);
+               d_tmpfile(dentry, inode);
                err = ext4_orphan_add(handle, inode);
                if (err)
                        goto err_drop_inode;
                mark_inode_dirty(inode);
-               d_tmpfile(dentry, inode);
                unlock_new_inode(inode);
        }
        if (handle)
index 48786cdb5e6c8ccc9d94039d34432e8019c3d840..6625d210fb45543507acfed8da8d9312aa4326d7 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
+#include <linux/ratelimit.h>
 
 #include "ext4_jbd2.h"
 #include "xattr.h"
@@ -55,7 +56,7 @@ void ext4_exit_pageio(void)
 static void buffer_io_error(struct buffer_head *bh)
 {
        char b[BDEVNAME_SIZE];
-       printk(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n",
+       printk_ratelimited(KERN_ERR "Buffer I/O error on device %s, logical block %llu\n",
                        bdevname(bh->b_bdev, b),
                        (unsigned long long)bh->b_blocknr);
 }
@@ -308,6 +309,7 @@ ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end)
        return io_end;
 }
 
+/* BIO completion function for page writeback */
 static void ext4_end_bio(struct bio *bio, int error)
 {
        ext4_io_end_t *io_end = bio->bi_private;
@@ -318,18 +320,6 @@ static void ext4_end_bio(struct bio *bio, int error)
        if (test_bit(BIO_UPTODATE, &bio->bi_flags))
                error = 0;
 
-       if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
-               /*
-                * Link bio into list hanging from io_end. We have to do it
-                * atomically as bio completions can be racing against each
-                * other.
-                */
-               bio->bi_private = xchg(&io_end->bio, bio);
-       } else {
-               ext4_finish_bio(bio);
-               bio_put(bio);
-       }
-
        if (error) {
                struct inode *inode = io_end->inode;
 
@@ -341,7 +331,24 @@ static void ext4_end_bio(struct bio *bio, int error)
                             (unsigned long long)
                             bi_sector >> (inode->i_blkbits - 9));
        }
-       ext4_put_io_end_defer(io_end);
+
+       if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
+               /*
+                * Link bio into list hanging from io_end. We have to do it
+                * atomically as bio completions can be racing against each
+                * other.
+                */
+               bio->bi_private = xchg(&io_end->bio, bio);
+               ext4_put_io_end_defer(io_end);
+       } else {
+               /*
+                * Drop io_end reference early. Inode can get freed once
+                * we finish the bio.
+                */
+               ext4_put_io_end_defer(io_end);
+               ext4_finish_bio(bio);
+               bio_put(bio);
+       }
 }
 
 void ext4_io_submit(struct ext4_io_submit *io)
index 85b3dd60169beba2b2535ae4342a436387273e32..b59373b625e9bcacaf3a63e409b21b1ef6212dfa 100644 (file)
@@ -1359,7 +1359,7 @@ static const struct mount_opts {
        {Opt_delalloc, EXT4_MOUNT_DELALLOC,
         MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT},
        {Opt_nodelalloc, EXT4_MOUNT_DELALLOC,
-        MOPT_EXT4_ONLY | MOPT_CLEAR | MOPT_EXPLICIT},
+        MOPT_EXT4_ONLY | MOPT_CLEAR},
        {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM,
         MOPT_EXT4_ONLY | MOPT_SET},
        {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT |
@@ -1702,12 +1702,6 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
 
        if (sbi->s_qf_names[GRPQUOTA])
                seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
-
-       if (test_opt(sb, USRQUOTA))
-               seq_puts(seq, ",usrquota");
-
-       if (test_opt(sb, GRPQUOTA))
-               seq_puts(seq, ",grpquota");
 #endif
 }
 
@@ -3489,7 +3483,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                }
                if (test_opt(sb, DIOREAD_NOLOCK)) {
                        ext4_msg(sb, KERN_ERR, "can't mount with "
-                                "both data=journal and delalloc");
+                                "both data=journal and dioread_nolock");
                        goto failed_mount;
                }
                if (test_opt(sb, DELALLOC))
@@ -3624,10 +3618,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
        sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
        sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
 
-       /* Do we have standard group size of blocksize * 8 blocks ? */
-       if (sbi->s_blocks_per_group == blocksize << 3)
-               set_opt2(sb, STD_GROUP_SIZE);
-
        for (i = 0; i < 4; i++)
                sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
        sbi->s_def_hash_version = es->s_def_hash_version;
@@ -3697,6 +3687,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                goto failed_mount;
        }
 
+       /* Do we have standard group size of clustersize * 8 blocks ? */
+       if (sbi->s_blocks_per_group == clustersize << 3)
+               set_opt2(sb, STD_GROUP_SIZE);
+
        /*
         * Test whether we have more sectors than will fit in sector_t,
         * and whether the max offset is addressable by the page cache.
@@ -4733,6 +4727,21 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                goto restore_opts;
        }
 
+       if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
+               if (test_opt2(sb, EXPLICIT_DELALLOC)) {
+                       ext4_msg(sb, KERN_ERR, "can't mount with "
+                                "both data=journal and delalloc");
+                       err = -EINVAL;
+                       goto restore_opts;
+               }
+               if (test_opt(sb, DIOREAD_NOLOCK)) {
+                       ext4_msg(sb, KERN_ERR, "can't mount with "
+                                "both data=journal and dioread_nolock");
+                       err = -EINVAL;
+                       goto restore_opts;
+               }
+       }
+
        if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
                ext4_abort(sb, "Abort forced by user");
 
@@ -5487,6 +5496,7 @@ static void __exit ext4_exit_fs(void)
        kset_unregister(ext4_kset);
        ext4_exit_system_zone();
        ext4_exit_pageio();
+       ext4_exit_es();
 }
 
 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
index 6599222536eb20e9deb22884bdc305efcf2cf1ae..65343c3741ff86876418deb9d18e3f72f5872898 100644 (file)
@@ -730,14 +730,14 @@ static int __init fcntl_init(void)
         * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
         * is defined as O_NONBLOCK on some platforms and not on others.
         */
-       BUILD_BUG_ON(19 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
+       BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
                O_RDONLY        | O_WRONLY      | O_RDWR        |
                O_CREAT         | O_EXCL        | O_NOCTTY      |
                O_TRUNC         | O_APPEND      | /* O_NONBLOCK | */
                __O_SYNC        | O_DSYNC       | FASYNC        |
                O_DIRECT        | O_LARGEFILE   | O_DIRECTORY   |
                O_NOFOLLOW      | O_NOATIME     | O_CLOEXEC     |
-               __FMODE_EXEC    | O_PATH
+               __FMODE_EXEC    | O_PATH        | __O_TMPFILE
                ));
 
        fasync_cache = kmem_cache_create("fasync_cache",
index 0eda52738ec4d0fc6cac460fab9d4baddde4ff4b..72a5d5b04494ded2468bc4a2f5f30e30c9ca12f7 100644 (file)
@@ -1223,30 +1223,46 @@ static int fuse_direntplus_link(struct file *file,
                if (name.name[1] == '.' && name.len == 2)
                        return 0;
        }
+
+       if (invalid_nodeid(o->nodeid))
+               return -EIO;
+       if (!fuse_valid_type(o->attr.mode))
+               return -EIO;
+
        fc = get_fuse_conn(dir);
 
        name.hash = full_name_hash(name.name, name.len);
        dentry = d_lookup(parent, &name);
-       if (dentry && dentry->d_inode) {
+       if (dentry) {
                inode = dentry->d_inode;
-               if (get_node_id(inode) == o->nodeid) {
+               if (!inode) {
+                       d_drop(dentry);
+               } else if (get_node_id(inode) != o->nodeid ||
+                          ((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
+                       err = d_invalidate(dentry);
+                       if (err)
+                               goto out;
+               } else if (is_bad_inode(inode)) {
+                       err = -EIO;
+                       goto out;
+               } else {
                        struct fuse_inode *fi;
                        fi = get_fuse_inode(inode);
                        spin_lock(&fc->lock);
                        fi->nlookup++;
                        spin_unlock(&fc->lock);
 
+                       fuse_change_attributes(inode, &o->attr,
+                                              entry_attr_timeout(o),
+                                              attr_version);
+
                        /*
                         * The other branch to 'found' comes via fuse_iget()
                         * which bumps nlookup inside
                         */
                        goto found;
                }
-               err = d_invalidate(dentry);
-               if (err)
-                       goto out;
                dput(dentry);
-               dentry = NULL;
        }
 
        dentry = d_alloc(parent, &name);
@@ -1259,25 +1275,30 @@ static int fuse_direntplus_link(struct file *file,
        if (!inode)
                goto out;
 
-       alias = d_materialise_unique(dentry, inode);
-       err = PTR_ERR(alias);
-       if (IS_ERR(alias))
-               goto out;
+       if (S_ISDIR(inode->i_mode)) {
+               mutex_lock(&fc->inst_mutex);
+               alias = fuse_d_add_directory(dentry, inode);
+               mutex_unlock(&fc->inst_mutex);
+               err = PTR_ERR(alias);
+               if (IS_ERR(alias)) {
+                       iput(inode);
+                       goto out;
+               }
+       } else {
+               alias = d_splice_alias(inode, dentry);
+       }
+
        if (alias) {
                dput(dentry);
                dentry = alias;
        }
 
 found:
-       fuse_change_attributes(inode, &o->attr, entry_attr_timeout(o),
-                              attr_version);
-
        fuse_change_entry_timeout(dentry, o);
 
        err = 0;
 out:
-       if (dentry)
-               dput(dentry);
+       dput(dentry);
        return err;
 }
 
index 9435384562a271cacd5219651269b36d5d2923c4..544a809819c3ee5c16ddaa42a8ce0ce26d2194f4 100644 (file)
@@ -1838,14 +1838,14 @@ int __init gfs2_glock_init(void)
 
        glock_workqueue = alloc_workqueue("glock_workqueue", WQ_MEM_RECLAIM |
                                          WQ_HIGHPRI | WQ_FREEZABLE, 0);
-       if (IS_ERR(glock_workqueue))
-               return PTR_ERR(glock_workqueue);
+       if (!glock_workqueue)
+               return -ENOMEM;
        gfs2_delete_workqueue = alloc_workqueue("delete_workqueue",
                                                WQ_MEM_RECLAIM | WQ_FREEZABLE,
                                                0);
-       if (IS_ERR(gfs2_delete_workqueue)) {
+       if (!gfs2_delete_workqueue) {
                destroy_workqueue(glock_workqueue);
-               return PTR_ERR(gfs2_delete_workqueue);
+               return -ENOMEM;
        }
 
        register_shrinker(&glock_shrinker);
index 5f2e5224c51c9ae79e34a1eb0f405a7b304cd0be..e2e0a90396e7823da9aa47c44a727d5e75751cc6 100644 (file)
@@ -47,7 +47,8 @@ static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
  * None of the buffers should be dirty, locked, or pinned.
  */
 
-static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
+static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync,
+                            unsigned int nr_revokes)
 {
        struct gfs2_sbd *sdp = gl->gl_sbd;
        struct list_head *head = &gl->gl_ail_list;
@@ -57,7 +58,9 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
 
        gfs2_log_lock(sdp);
        spin_lock(&sdp->sd_ail_lock);
-       list_for_each_entry_safe(bd, tmp, head, bd_ail_gl_list) {
+       list_for_each_entry_safe_reverse(bd, tmp, head, bd_ail_gl_list) {
+               if (nr_revokes == 0)
+                       break;
                bh = bd->bd_bh;
                if (bh->b_state & b_state) {
                        if (fsync)
@@ -65,6 +68,7 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
                        gfs2_ail_error(gl, bh);
                }
                gfs2_trans_add_revoke(sdp, bd);
+               nr_revokes--;
        }
        GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
        spin_unlock(&sdp->sd_ail_lock);
@@ -91,7 +95,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
        WARN_ON_ONCE(current->journal_info);
        current->journal_info = &tr;
 
-       __gfs2_ail_flush(gl, 0);
+       __gfs2_ail_flush(gl, 0, tr.tr_revokes);
 
        gfs2_trans_end(sdp);
        gfs2_log_flush(sdp, NULL);
@@ -101,15 +105,19 @@ void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
 {
        struct gfs2_sbd *sdp = gl->gl_sbd;
        unsigned int revokes = atomic_read(&gl->gl_ail_count);
+       unsigned int max_revokes = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / sizeof(u64);
        int ret;
 
        if (!revokes)
                return;
 
-       ret = gfs2_trans_begin(sdp, 0, revokes);
+       while (revokes > max_revokes)
+               max_revokes += (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / sizeof(u64);
+
+       ret = gfs2_trans_begin(sdp, 0, max_revokes);
        if (ret)
                return;
-       __gfs2_ail_flush(gl, fsync);
+       __gfs2_ail_flush(gl, fsync, max_revokes);
        gfs2_trans_end(sdp);
        gfs2_log_flush(sdp, NULL);
 }
index bbb2715171cd0c983770cf86b4b57ed69e04c98d..64915eeae5a7112f59256185a00a1cc9f3b2a193 100644 (file)
@@ -594,7 +594,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
                }
                gfs2_glock_dq_uninit(ghs);
                if (IS_ERR(d))
-                       return PTR_RET(d);
+                       return PTR_ERR(d);
                return error;
        } else if (error != -ENOENT) {
                goto fail_gunlock;
@@ -1750,6 +1750,10 @@ static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name,
        struct gfs2_holder gh;
        int ret;
 
+       /* For selinux during lookup */
+       if (gfs2_glock_is_locked_by_me(ip->i_gl))
+               return generic_getxattr(dentry, name, data, size);
+
        gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
        ret = gfs2_glock_nq(&gh);
        if (ret == 0) {
index e04d0e09ee7b59d5959d69e5df872a5871e9ae64..7b0f5043cf24c253612451787588d638da5483ce 100644 (file)
@@ -155,7 +155,7 @@ static int __init init_gfs2_fs(void)
                goto fail_wq;
 
        gfs2_control_wq = alloc_workqueue("gfs2_control",
-                              WQ_NON_REENTRANT | WQ_UNBOUND | WQ_FREEZABLE, 0);
+                                         WQ_UNBOUND | WQ_FREEZABLE, 0);
        if (!gfs2_control_wq)
                goto fail_recovery;
 
index a3f868ae3fd48f043f91a059ede274b20b431c3b..34423978b17083d73b038d360d72b47dc08c6693 100644 (file)
@@ -463,6 +463,14 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
        return inode;
 }
 
+/*
+ * Hugetlbfs is not reclaimable; therefore its i_mmap_mutex will never
+ * be taken from reclaim -- unlike regular filesystems. This needs an
+ * annotation because huge_pmd_share() does an allocation under
+ * i_mmap_mutex.
+ */
+struct lock_class_key hugetlbfs_i_mmap_mutex_key;
+
 static struct inode *hugetlbfs_get_inode(struct super_block *sb,
                                        struct inode *dir,
                                        umode_t mode, dev_t dev)
@@ -474,6 +482,8 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
                struct hugetlbfs_inode_info *info;
                inode->i_ino = get_next_ino();
                inode_init_owner(inode, dir, mode);
+               lockdep_set_class(&inode->i_mapping->i_mmap_mutex,
+                               &hugetlbfs_i_mmap_mutex_key);
                inode->i_mapping->a_ops = &hugetlbfs_aops;
                inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
                inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
index 01bfe76627516d836241b249bdeac7b0a02b0f97..41e491b8e5d7e40164e0e51d90534c9d8660a94e 100644 (file)
@@ -64,12 +64,17 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
                                   nlm_init->protocol, nlm_version,
                                   nlm_init->hostname, nlm_init->noresvport,
                                   nlm_init->net);
-       if (host == NULL) {
-               lockd_down(nlm_init->net);
-               return ERR_PTR(-ENOLCK);
-       }
+       if (host == NULL)
+               goto out_nohost;
+       if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL)
+               goto out_nobind;
 
        return host;
+out_nobind:
+       nlmclnt_release_host(host);
+out_nohost:
+       lockd_down(nlm_init->net);
+       return ERR_PTR(-ENOLCK);
 }
 EXPORT_SYMBOL_GPL(nlmclnt_init);
 
index 9760ecb9b60f6ae39471ea09fd8f286ca0285da7..acd3947163497b802544a632aa02512c37b88d9d 100644 (file)
@@ -125,14 +125,15 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
 {
        struct nlm_args *argp = &req->a_args;
        struct nlm_lock *lock = &argp->lock;
+       char *nodename = req->a_host->h_rpcclnt->cl_nodename;
 
        nlmclnt_next_cookie(&argp->cookie);
        memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh));
-       lock->caller  = utsname()->nodename;
+       lock->caller  = nodename;
        lock->oh.data = req->a_owner;
        lock->oh.len  = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
                                (unsigned int)fl->fl_u.nfs_fl.owner->pid,
-                               utsname()->nodename);
+                               nodename);
        lock->svid = fl->fl_u.nfs_fl.owner->pid;
        lock->fl.fl_start = fl->fl_start;
        lock->fl.fl_end = fl->fl_end;
index 067778b0ccc9dddd878277d6ca88e9c5d2fddc5b..e066a3902973640ae3d75dc0c768ceb8f15eb9d8 100644 (file)
@@ -951,6 +951,7 @@ nlmsvc_retry_blocked(void)
        unsigned long   timeout = MAX_SCHEDULE_TIMEOUT;
        struct nlm_block *block;
 
+       spin_lock(&nlm_blocked_lock);
        while (!list_empty(&nlm_blocked) && !kthread_should_stop()) {
                block = list_entry(nlm_blocked.next, struct nlm_block, b_list);
 
@@ -960,6 +961,7 @@ nlmsvc_retry_blocked(void)
                        timeout = block->b_when - jiffies;
                        break;
                }
+               spin_unlock(&nlm_blocked_lock);
 
                dprintk("nlmsvc_retry_blocked(%p, when=%ld)\n",
                        block, block->b_when);
@@ -969,7 +971,9 @@ nlmsvc_retry_blocked(void)
                        retry_deferred_block(block);
                } else
                        nlmsvc_grant_blocked(block);
+               spin_lock(&nlm_blocked_lock);
        }
+       spin_unlock(&nlm_blocked_lock);
 
        return timeout;
 }
index 8b61d103a8a7a15b0c5e8eab070e92f940a64b88..89a612e392ebb28e9a00bfa1c2c8562d8a3fb7c6 100644 (file)
@@ -3671,15 +3671,11 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
        if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0)
                return -EINVAL;
        /*
-        * To use null names we require CAP_DAC_READ_SEARCH
-        * This ensures that not everyone will be able to create
-        * handlink using the passed filedescriptor.
+        * Using empty names is equivalent to using AT_SYMLINK_FOLLOW
+        * on /proc/self/fd/<fd>.
         */
-       if (flags & AT_EMPTY_PATH) {
-               if (!capable(CAP_DAC_READ_SEARCH))
-                       return -ENOENT;
+       if (flags & AT_EMPTY_PATH)
                how = LOOKUP_EMPTY;
-       }
 
        if (flags & AT_SYMLINK_FOLLOW)
                how |= LOOKUP_FOLLOW;
index af6e806044d7cee5d8047a56de6693388fc8d34f..941246f2b43d266827666dee7fec5051c2289586 100644 (file)
@@ -463,7 +463,6 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
                unlock_new_inode(inode);
        } else
                nfs_refresh_inode(inode, fattr);
-               nfs_setsecurity(inode, fattr, label);
        dprintk("NFS: nfs_fhget(%s/%Ld fh_crc=0x%08x ct=%d)\n",
                inode->i_sb->s_id,
                (long long)NFS_FILEID(inode),
@@ -963,9 +962,15 @@ EXPORT_SYMBOL_GPL(nfs_revalidate_inode);
 static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
-       
+       int ret;
+
        if (mapping->nrpages != 0) {
-               int ret = invalidate_inode_pages2(mapping);
+               if (S_ISREG(inode->i_mode)) {
+                       ret = nfs_sync_mapping(mapping);
+                       if (ret < 0)
+                               return ret;
+               }
+               ret = invalidate_inode_pages2(mapping);
                if (ret < 0)
                        return ret;
        }
index cf11799297c42d50dc33aca126e6da11f033ce4b..108a774095f7ef6a53fc04366aec3caa3bfea717 100644 (file)
@@ -3071,15 +3071,13 @@ struct rpc_clnt *
 nfs4_proc_lookup_mountpoint(struct inode *dir, struct qstr *name,
                            struct nfs_fh *fhandle, struct nfs_fattr *fattr)
 {
+       struct rpc_clnt *client = NFS_CLIENT(dir);
        int status;
-       struct rpc_clnt *client = rpc_clone_client(NFS_CLIENT(dir));
 
        status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, NULL);
-       if (status < 0) {
-               rpc_shutdown_client(client);
+       if (status < 0)
                return ERR_PTR(status);
-       }
-       return client;
+       return (client == NFS_CLIENT(dir)) ? rpc_clone_client(client) : client;
 }
 
 static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry)
index 0abfb8466e796cb8c0894ae6fbc38180865904f4..3850b018815f2d07e4740fdd3ff8200523b9fe92 100644 (file)
@@ -999,6 +999,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
        __be32 *p;
        __be32 *q;
        int len;
+       uint32_t bmval_len = 2;
        uint32_t bmval0 = 0;
        uint32_t bmval1 = 0;
        uint32_t bmval2 = 0;
@@ -1010,7 +1011,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
         * = 40 bytes, plus any contribution from variable-length fields
         *            such as owner/group.
         */
-       len = 20;
+       len = 8;
 
        /* Sigh */
        if (iap->ia_valid & ATTR_SIZE)
@@ -1040,8 +1041,6 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
                }
                len += 4 + (XDR_QUADLEN(owner_grouplen) << 2);
        }
-       if (label)
-               len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
        if (iap->ia_valid & ATTR_ATIME_SET)
                len += 16;
        else if (iap->ia_valid & ATTR_ATIME)
@@ -1050,15 +1049,22 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
                len += 16;
        else if (iap->ia_valid & ATTR_MTIME)
                len += 4;
+       if (label) {
+               len += 4 + 4 + 4 + (XDR_QUADLEN(label->len) << 2);
+               bmval_len = 3;
+       }
+
+       len += bmval_len << 2;
        p = reserve_space(xdr, len);
 
        /*
         * We write the bitmap length now, but leave the bitmap and the attribute
         * buffer length to be backfilled at the end of this routine.
         */
-       *p++ = cpu_to_be32(3);
+       *p++ = cpu_to_be32(bmval_len);
        q = p;
-       p += 4;
+       /* Skip bitmap entries + attrlen */
+       p += bmval_len + 1;
 
        if (iap->ia_valid & ATTR_SIZE) {
                bmval0 |= FATTR4_WORD0_SIZE;
@@ -1112,10 +1118,11 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
                                len, ((char *)p - (char *)q) + 4);
                BUG();
        }
-       len = (char *)p - (char *)q - 16;
        *q++ = htonl(bmval0);
        *q++ = htonl(bmval1);
-       *q++ = htonl(bmval2);
+       if (bmval_len == 3)
+               *q++ = htonl(bmval2);
+       len = (char *)p - (char *)(q + 1);
        *q = htonl(len);
 
 /* out: */
index 71fdc0dfa0d28d9e293cbb58729d63395af7cc99..f6db66d8f647069a4cffde4e609bc7f23e3a2da0 100644 (file)
@@ -2478,6 +2478,10 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
        if (server->flags & NFS_MOUNT_NOAC)
                sb_mntdata.mntflags |= MS_SYNCHRONOUS;
 
+       if (mount_info->cloned != NULL && mount_info->cloned->sb != NULL)
+               if (mount_info->cloned->sb->s_flags & MS_SYNCHRONOUS)
+                       sb_mntdata.mntflags |= MS_SYNCHRONOUS;
+
        /* Get a superblock - note that we may end up sharing one that already exists */
        s = sget(nfs_mod->nfs_fs, compare_super, nfs_set_super, flags, &sb_mntdata);
        if (IS_ERR(s)) {
index a7cee864e7b245e5ead7c8f04b509a5cfe9c59a8..419572f33b72dafaf04a770fb53e29e250e5f42b 100644 (file)
@@ -1293,7 +1293,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
         * According to RFC3010, this takes precedence over all other errors.
         */
        status = nfserr_minor_vers_mismatch;
-       if (args->minorversion > nfsd_supported_minorversion)
+       if (nfsd_minorversion(args->minorversion, NFSD_TEST) <= 0)
                goto out;
 
        status = nfs41_check_op_ordering(args);
@@ -1524,7 +1524,7 @@ static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
 static inline u32 nfsd4_exchange_id_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
 {
        return (op_encode_hdr_size + 2 + 1 + /* eir_clientid, eir_sequenceid */\
-               1 + 1 + 0 + /* eir_flags, spr_how, SP4_NONE (for now) */\
+               1 + 1 + 2 + /* eir_flags, spr_how, spo_must_enforce & _allow */\
                2 + /*eir_server_owner.so_minor_id */\
                /* eir_server_owner.so_major_id<> */\
                XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 +\
index 280acef6f0dc45e29365b197a8242f7d26bb22f7..43f42290e5df096fe7eced0266759b45264a61a1 100644 (file)
@@ -1264,6 +1264,8 @@ static bool svc_rqst_integrity_protected(struct svc_rqst *rqstp)
        struct svc_cred *cr = &rqstp->rq_cred;
        u32 service;
 
+       if (!cr->cr_gss_mech)
+               return false;
        service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor);
        return service == RPC_GSS_SVC_INTEGRITY ||
               service == RPC_GSS_SVC_PRIVACY;
index 0c0f3ea90de59f9c9e0c21aebd46e8b07b2f45f9..c2a4701d7286478cca66cda986565a7b3105504c 100644 (file)
@@ -3360,7 +3360,8 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
                8 /* eir_clientid */ +
                4 /* eir_sequenceid */ +
                4 /* eir_flags */ +
-               4 /* spr_how (SP4_NONE) */ +
+               4 /* spr_how */ +
+               8 /* spo_must_enforce, spo_must_allow */ +
                8 /* so_minor_id */ +
                4 /* so_major_id.len */ +
                (XDR_QUADLEN(major_id_sz) * 4) +
@@ -3372,8 +3373,6 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
        WRITE32(exid->seqid);
        WRITE32(exid->flags);
 
-       /* state_protect4_r. Currently only support SP4_NONE */
-       BUG_ON(exid->spa_how != SP4_NONE);
        WRITE32(exid->spa_how);
        switch (exid->spa_how) {
        case SP4_NONE:
index 2bbd94e51efc7dcc8bcba377e2e8373290b3a189..30f34ab02137f8e41aa95bcbf7c51967e694f3c1 100644 (file)
@@ -53,7 +53,6 @@ struct readdir_cd {
 extern struct svc_program      nfsd_program;
 extern struct svc_version      nfsd_version2, nfsd_version3,
                                nfsd_version4;
-extern u32                     nfsd_supported_minorversion;
 extern struct mutex            nfsd_mutex;
 extern spinlock_t              nfsd_drc_lock;
 extern unsigned long           nfsd_drc_max_mem;
index 6b9f48ca4c25183abab7759a588a8ec5d4da4257..760c85a6f534a45b0eb396a62acc305484163109 100644 (file)
@@ -116,7 +116,10 @@ struct svc_program         nfsd_program = {
 
 };
 
-u32 nfsd_supported_minorversion = 1;
+static bool nfsd_supported_minorversions[NFSD_SUPPORTED_MINOR_VERSION + 1] = {
+       [0] = 1,
+       [1] = 1,
+};
 
 int nfsd_vers(int vers, enum vers_op change)
 {
@@ -151,15 +154,13 @@ int nfsd_minorversion(u32 minorversion, enum vers_op change)
                return -1;
        switch(change) {
        case NFSD_SET:
-               nfsd_supported_minorversion = minorversion;
+               nfsd_supported_minorversions[minorversion] = true;
                break;
        case NFSD_CLEAR:
-               if (minorversion == 0)
-                       return -1;
-               nfsd_supported_minorversion = minorversion - 1;
+               nfsd_supported_minorversions[minorversion] = false;
                break;
        case NFSD_TEST:
-               return minorversion <= nfsd_supported_minorversion;
+               return nfsd_supported_minorversions[minorversion];
        case NFSD_AVAIL:
                return minorversion <= NFSD_SUPPORTED_MINOR_VERSION;
        }
index 8ff6a0019b0b9cc6016da02c3210ae6840a20dfa..c827acb0e943bdab08fd077e56228b170a6a9549 100644 (file)
@@ -830,9 +830,10 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type,
                        flags = O_WRONLY|O_LARGEFILE;
        }
        *filp = dentry_open(&path, flags, current_cred());
-       if (IS_ERR(*filp))
+       if (IS_ERR(*filp)) {
                host_err = PTR_ERR(*filp);
-       else {
+               *filp = NULL;
+       } else {
                host_err = ima_file_check(*filp, may_flags);
 
                if (may_flags & NFSD_MAY_64BIT_COOKIE)
index dc9a913784ab94127fba6e4503d12a0708069f41..2d8be51f90dc9257bf74cad77b719d17f781c739 100644 (file)
@@ -345,8 +345,7 @@ static void nilfs_end_bio_write(struct bio *bio, int err)
 
        if (err == -EOPNOTSUPP) {
                set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
-               bio_put(bio);
-               /* to be detected by submit_seg_bio() */
+               /* to be detected by nilfs_segbuf_submit_bio() */
        }
 
        if (!uptodate)
@@ -377,12 +376,12 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
        bio->bi_private = segbuf;
        bio_get(bio);
        submit_bio(mode, bio);
+       segbuf->sb_nbio++;
        if (bio_flagged(bio, BIO_EOPNOTSUPP)) {
                bio_put(bio);
                err = -EOPNOTSUPP;
                goto failed;
        }
-       segbuf->sb_nbio++;
        bio_put(bio);
 
        wi->bio = NULL;
index 79736a28d84f911dd66acca86c844912284ad9fa..2abf97b2a592b7dafaad4e2cfc0f9a6f7442f475 100644 (file)
@@ -1757,7 +1757,7 @@ try_again:
                goto out;
        } else if (ret == 1) {
                clusters_need = wc->w_clen;
-               ret = ocfs2_refcount_cow(inode, filp, di_bh,
+               ret = ocfs2_refcount_cow(inode, di_bh,
                                         wc->w_cpos, wc->w_clen, UINT_MAX);
                if (ret) {
                        mlog_errno(ret);
index eb760d8acd500c96bd45195ce2a2c79fb0942ed5..30544ce8e9f78cc66cc0eb61387f84b21cef4309 100644 (file)
@@ -2153,11 +2153,9 @@ int ocfs2_empty_dir(struct inode *inode)
 {
        int ret;
        struct ocfs2_empty_dir_priv priv = {
-               .ctx.actor = ocfs2_empty_dir_filldir
+               .ctx.actor = ocfs2_empty_dir_filldir,
        };
 
-       memset(&priv, 0, sizeof(priv));
-
        if (ocfs2_dir_indexed(inode)) {
                ret = ocfs2_empty_dir_dx(inode, &priv);
                if (ret)
index 41000f223ca42bb855a57f1cc27f08a28ecccba9..3261d71319eeb27d3a569aeccf4f3f6e27a95496 100644 (file)
@@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
        if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
                goto out;
 
-       return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
+       return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
 
 out:
        return status;
@@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
                zero_clusters = last_cpos - zero_cpos;
 
        if (needs_cow) {
-               rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
+               rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
                                        zero_clusters, UINT_MAX);
                if (rc) {
                        mlog_errno(rc);
@@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
 
        *meta_level = 1;
 
-       ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
+       ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
        if (ret)
                mlog_errno(ret);
 out:
index 96f9ac237e86dbc301339c07b882bbff508f9143..0a992737dcaf8e76d0b57b18dcb21b57d5ed6479 100644 (file)
@@ -537,7 +537,7 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb,
        extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth);
 
        return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks +
-              ocfs2_quota_trans_credits(sb) + bits_wanted;
+              ocfs2_quota_trans_credits(sb);
 }
 
 static inline int ocfs2_calc_symlink_credits(struct super_block *sb)
index f1fc172175b6c47454cfbb4f10bfd239102e92a9..452068b45749a7545002543f0b0b450b52612dec 100644 (file)
@@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
        u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
        u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
 
-       ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
+       ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
                                               p_cpos, new_p_cpos, len);
        if (ret) {
                mlog_errno(ret);
index 998b17eda09d807b2b1d2ccc0b94cdc2a45974a1..a70d604593b61c0ffbce761a92b1207148f3b346 100644 (file)
@@ -49,7 +49,6 @@
 
 struct ocfs2_cow_context {
        struct inode *inode;
-       struct file *file;
        u32 cow_start;
        u32 cow_len;
        struct ocfs2_extent_tree data_et;
@@ -66,7 +65,7 @@ struct ocfs2_cow_context {
                            u32 *num_clusters,
                            unsigned int *extent_flags);
        int (*cow_duplicate_clusters)(handle_t *handle,
-                                     struct file *file,
+                                     struct inode *inode,
                                      u32 cpos, u32 old_cluster,
                                      u32 new_cluster, u32 new_len);
 };
@@ -2922,14 +2921,12 @@ static int ocfs2_clear_cow_buffer(handle_t *handle, struct buffer_head *bh)
 }
 
 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
-                                    struct file *file,
+                                    struct inode *inode,
                                     u32 cpos, u32 old_cluster,
                                     u32 new_cluster, u32 new_len)
 {
        int ret = 0, partial;
-       struct inode *inode = file_inode(file);
-       struct ocfs2_caching_info *ci = INODE_CACHE(inode);
-       struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
+       struct super_block *sb = inode->i_sb;
        u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
        struct page *page;
        pgoff_t page_index;
@@ -2965,6 +2962,11 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
                        to = map_end & (PAGE_CACHE_SIZE - 1);
 
                page = find_or_create_page(mapping, page_index, GFP_NOFS);
+               if (!page) {
+                       ret = -ENOMEM;
+                       mlog_errno(ret);
+                       break;
+               }
 
                /*
                 * In case PAGE_CACHE_SIZE <= CLUSTER_SIZE, This page
@@ -2973,13 +2975,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
                if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
                        BUG_ON(PageDirty(page));
 
-               if (PageReadahead(page)) {
-                       page_cache_async_readahead(mapping,
-                                                  &file->f_ra, file,
-                                                  page, page_index,
-                                                  readahead_pages);
-               }
-
                if (!PageUptodate(page)) {
                        ret = block_read_full_page(page, ocfs2_get_block);
                        if (ret) {
@@ -2999,7 +2994,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
                        }
                }
 
-               ocfs2_map_and_dirty_page(inode, handle, from, to,
+               ocfs2_map_and_dirty_page(inode,
+                                        handle, from, to,
                                         page, 0, &new_block);
                mark_page_accessed(page);
 unlock:
@@ -3015,12 +3011,11 @@ unlock:
 }
 
 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
-                                   struct file *file,
+                                   struct inode *inode,
                                    u32 cpos, u32 old_cluster,
                                    u32 new_cluster, u32 new_len)
 {
        int ret = 0;
-       struct inode *inode = file_inode(file);
        struct super_block *sb = inode->i_sb;
        struct ocfs2_caching_info *ci = INODE_CACHE(inode);
        int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
@@ -3145,7 +3140,7 @@ static int ocfs2_replace_clusters(handle_t *handle,
 
        /*If the old clusters is unwritten, no need to duplicate. */
        if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) {
-               ret = context->cow_duplicate_clusters(handle, context->file,
+               ret = context->cow_duplicate_clusters(handle, context->inode,
                                                      cpos, old, new, len);
                if (ret) {
                        mlog_errno(ret);
@@ -3423,35 +3418,12 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
        return ret;
 }
 
-static void ocfs2_readahead_for_cow(struct inode *inode,
-                                   struct file *file,
-                                   u32 start, u32 len)
-{
-       struct address_space *mapping;
-       pgoff_t index;
-       unsigned long num_pages;
-       int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
-
-       if (!file)
-               return;
-
-       mapping = file->f_mapping;
-       num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT;
-       if (!num_pages)
-               num_pages = 1;
-
-       index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT;
-       page_cache_sync_readahead(mapping, &file->f_ra, file,
-                                 index, num_pages);
-}
-
 /*
  * Starting at cpos, try to CoW write_len clusters.  Don't CoW
  * past max_cpos.  This will stop when it runs into a hole or an
  * unrefcounted extent.
  */
 static int ocfs2_refcount_cow_hunk(struct inode *inode,
-                                  struct file *file,
                                   struct buffer_head *di_bh,
                                   u32 cpos, u32 write_len, u32 max_cpos)
 {
@@ -3480,8 +3452,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
 
        BUG_ON(cow_len == 0);
 
-       ocfs2_readahead_for_cow(inode, file, cow_start, cow_len);
-
        context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
        if (!context) {
                ret = -ENOMEM;
@@ -3503,7 +3473,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
        context->ref_root_bh = ref_root_bh;
        context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
        context->get_clusters = ocfs2_di_get_clusters;
-       context->file = file;
 
        ocfs2_init_dinode_extent_tree(&context->data_et,
                                      INODE_CACHE(inode), di_bh);
@@ -3532,7 +3501,6 @@ out:
  * clusters between cpos and cpos+write_len are safe to modify.
  */
 int ocfs2_refcount_cow(struct inode *inode,
-                      struct file *file,
                       struct buffer_head *di_bh,
                       u32 cpos, u32 write_len, u32 max_cpos)
 {
@@ -3552,7 +3520,7 @@ int ocfs2_refcount_cow(struct inode *inode,
                        num_clusters = write_len;
 
                if (ext_flags & OCFS2_EXT_REFCOUNTED) {
-                       ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos,
+                       ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
                                                      num_clusters, max_cpos);
                        if (ret) {
                                mlog_errno(ret);
index 7754608c83a47b1b44425c8f9c5e13a2adc65675..6422bbcdb52506b1631ce495ddf4524a4ae71c92 100644 (file)
@@ -53,7 +53,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
                                          int *credits,
                                          int *ref_blocks);
 int ocfs2_refcount_cow(struct inode *inode,
-                      struct file *filep, struct buffer_head *di_bh,
+                      struct buffer_head *di_bh,
                       u32 cpos, u32 write_len, u32 max_cpos);
 
 typedef int (ocfs2_post_refcount_func)(struct inode *inode,
@@ -85,11 +85,11 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
                             u32 cpos, u32 write_len,
                             struct ocfs2_post_refcount *post);
 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
-                                    struct file *file,
+                                    struct inode *inode,
                                     u32 cpos, u32 old_cluster,
                                     u32 new_cluster, u32 new_len);
 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
-                                   struct file *file,
+                                   struct inode *inode,
                                    u32 cpos, u32 old_cluster,
                                    u32 new_cluster, u32 new_len);
 int ocfs2_cow_sync_writeback(struct super_block *sb,
index 9156cb050d0873b65e8083671ef0ffdbe1ff1a47..7931f76acc2beede0298747df1d505b30cd225b4 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -823,7 +823,7 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
        int lookup_flags = 0;
        int acc_mode;
 
-       if (flags & O_CREAT)
+       if (flags & (O_CREAT | __O_TMPFILE))
                op->mode = (mode & S_IALLUGO) | S_IFREG;
        else
                op->mode = 0;
@@ -844,6 +844,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
                if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
                        return -EINVAL;
                acc_mode = MAY_OPEN | ACC_MODE(flags);
+               if (!(acc_mode & MAY_WRITE))
+                       return -EINVAL;
        } else if (flags & O_PATH) {
                /*
                 * If we have O_PATH in the open flag. Then we
index 94441a407337bb02fb77e89fe93dfbbed169f827..737e15615b0490c40d002a315217033f5463d5b3 100644 (file)
@@ -271,7 +271,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *file,
                de = next;
        } while (de);
        spin_unlock(&proc_subdir_lock);
-       return 0;
+       return 1;
 }
 
 int proc_readdir(struct file *file, struct dir_context *ctx)
index 229e366598daecd4e905e8f51f13efaf0a44e773..e0a790da726d0f710a7585b0a8b6663e9902a0ac 100644 (file)
@@ -205,7 +205,9 @@ static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentr
 static int proc_root_readdir(struct file *file, struct dir_context *ctx)
 {
        if (ctx->pos < FIRST_PROCESS_ENTRY) {
-               proc_readdir(file, ctx);
+               int error = proc_readdir(file, ctx);
+               if (unlikely(error <= 0))
+                       return error;
                ctx->pos = FIRST_PROCESS_ENTRY;
        }
 
index dbf61f6174f0f473d3d9a19311a09170f8dab9f3..107d026f5d6e0cbebc068fce65f201f167c425c5 100644 (file)
@@ -730,8 +730,16 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma,
         * of how soft-dirty works.
         */
        pte_t ptent = *pte;
-       ptent = pte_wrprotect(ptent);
-       ptent = pte_clear_flags(ptent, _PAGE_SOFT_DIRTY);
+
+       if (pte_present(ptent)) {
+               ptent = pte_wrprotect(ptent);
+               ptent = pte_clear_flags(ptent, _PAGE_SOFT_DIRTY);
+       } else if (is_swap_pte(ptent)) {
+               ptent = pte_swp_clear_soft_dirty(ptent);
+       } else if (pte_file(ptent)) {
+               ptent = pte_file_clear_soft_dirty(ptent);
+       }
+
        set_pte_at(vma->vm_mm, addr, pte, ptent);
 #endif
 }
@@ -752,14 +760,15 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
        pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
        for (; addr != end; pte++, addr += PAGE_SIZE) {
                ptent = *pte;
-               if (!pte_present(ptent))
-                       continue;
 
                if (cp->type == CLEAR_REFS_SOFT_DIRTY) {
                        clear_soft_dirty(vma, addr, pte);
                        continue;
                }
 
+               if (!pte_present(ptent))
+                       continue;
+
                page = vm_normal_page(vma, addr, ptent);
                if (!page)
                        continue;
@@ -859,7 +868,7 @@ typedef struct {
 } pagemap_entry_t;
 
 struct pagemapread {
-       int pos, len;
+       int pos, len;           /* units: PM_ENTRY_BYTES, not bytes */
        pagemap_entry_t *buffer;
        bool v2;
 };
@@ -867,7 +876,7 @@ struct pagemapread {
 #define PAGEMAP_WALK_SIZE      (PMD_SIZE)
 #define PAGEMAP_WALK_MASK      (PMD_MASK)
 
-#define PM_ENTRY_BYTES      sizeof(u64)
+#define PM_ENTRY_BYTES      sizeof(pagemap_entry_t)
 #define PM_STATUS_BITS      3
 #define PM_STATUS_OFFSET    (64 - PM_STATUS_BITS)
 #define PM_STATUS_MASK      (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET)
@@ -930,8 +939,10 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm,
                flags = PM_PRESENT;
                page = vm_normal_page(vma, addr, pte);
        } else if (is_swap_pte(pte)) {
-               swp_entry_t entry = pte_to_swp_entry(pte);
-
+               swp_entry_t entry;
+               if (pte_swp_soft_dirty(pte))
+                       flags2 |= __PM_SOFT_DIRTY;
+               entry = pte_to_swp_entry(pte);
                frame = swp_type(entry) |
                        (swp_offset(entry) << MAX_SWAPFILES_SHIFT);
                flags = PM_SWAP;
@@ -1116,8 +1127,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
                goto out_task;
 
        pm.v2 = soft_dirty_cleared;
-       pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
-       pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
+       pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
+       pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_TEMPORARY);
        ret = -ENOMEM;
        if (!pm.buffer)
                goto out_task;
index 28503172f2e4a2d16a87a87098ad5db615317565..a1a16eb97c7bd141c7a68419b44769ebea35c854 100644 (file)
@@ -223,7 +223,7 @@ static inline char *alloc_elfnotes_buf(size_t notes_sz)
  * regions in the 1st kernel pointed to by PT_LOAD entries) into
  * virtually contiguous user-space in ELF layout.
  */
-#ifdef CONFIG_MMU
+#if defined(CONFIG_MMU) && !defined(CONFIG_S390)
 static int mmap_vmcore(struct file *file, struct vm_area_struct *vma)
 {
        size_t size = vma->vm_end - vma->vm_start;
index 33532f79b4f714923ec951fa5fb75d1758fbfda3..a958444a75fc310627d56de6a37e28a15a99273a 100644 (file)
 /*
  * LOCKING:
  *
- * We rely on new Alexander Viro's super-block locking.
+ * These guys are evicted from procfs as the very first step in ->kill_sb().
  *
  */
 
-static int show_version(struct seq_file *m, struct super_block *sb)
+static int show_version(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        char *format;
 
        if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
@@ -66,8 +67,9 @@ static int show_version(struct seq_file *m, struct super_block *sb)
 #define DJP( x ) le32_to_cpu( jp -> x )
 #define JF( x ) ( r -> s_journal -> x )
 
-static int show_super(struct seq_file *m, struct super_block *sb)
+static int show_super(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        struct reiserfs_sb_info *r = REISERFS_SB(sb);
 
        seq_printf(m, "state: \t%s\n"
@@ -128,8 +130,9 @@ static int show_super(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-static int show_per_level(struct seq_file *m, struct super_block *sb)
+static int show_per_level(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        struct reiserfs_sb_info *r = REISERFS_SB(sb);
        int level;
 
@@ -186,8 +189,9 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-static int show_bitmap(struct seq_file *m, struct super_block *sb)
+static int show_bitmap(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        struct reiserfs_sb_info *r = REISERFS_SB(sb);
 
        seq_printf(m, "free_block: %lu\n"
@@ -218,8 +222,9 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
+static int show_on_disk_super(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
        struct reiserfs_super_block *rs = sb_info->s_rs;
        int hash_code = DFL(s_hash_function_code);
@@ -261,8 +266,9 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-static int show_oidmap(struct seq_file *m, struct super_block *sb)
+static int show_oidmap(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
        struct reiserfs_super_block *rs = sb_info->s_rs;
        unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
@@ -291,8 +297,9 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-static int show_journal(struct seq_file *m, struct super_block *sb)
+static int show_journal(struct seq_file *m, void *unused)
 {
+       struct super_block *sb = m->private;
        struct reiserfs_sb_info *r = REISERFS_SB(sb);
        struct reiserfs_super_block *rs = r->s_rs;
        struct journal_params *jp = &rs->s_v1.s_journal;
@@ -383,92 +390,24 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-/* iterator */
-static int test_sb(struct super_block *sb, void *data)
-{
-       return data == sb;
-}
-
-static int set_sb(struct super_block *sb, void *data)
-{
-       return -ENOENT;
-}
-
-struct reiserfs_seq_private {
-       struct super_block *sb;
-       int (*show) (struct seq_file *, struct super_block *);
-};
-
-static void *r_start(struct seq_file *m, loff_t * pos)
-{
-       struct reiserfs_seq_private *priv = m->private;
-       loff_t l = *pos;
-
-       if (l)
-               return NULL;
-
-       if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, priv->sb)))
-               return NULL;
-
-       up_write(&priv->sb->s_umount);
-       return priv->sb;
-}
-
-static void *r_next(struct seq_file *m, void *v, loff_t * pos)
-{
-       ++*pos;
-       if (v)
-               deactivate_super(v);
-       return NULL;
-}
-
-static void r_stop(struct seq_file *m, void *v)
-{
-       if (v)
-               deactivate_super(v);
-}
-
-static int r_show(struct seq_file *m, void *v)
-{
-       struct reiserfs_seq_private *priv = m->private;
-       return priv->show(m, v);
-}
-
-static const struct seq_operations r_ops = {
-       .start = r_start,
-       .next = r_next,
-       .stop = r_stop,
-       .show = r_show,
-};
-
 static int r_open(struct inode *inode, struct file *file)
 {
-       struct reiserfs_seq_private *priv;
-       int ret = seq_open_private(file, &r_ops,
-                                  sizeof(struct reiserfs_seq_private));
-
-       if (!ret) {
-               struct seq_file *m = file->private_data;
-               priv = m->private;
-               priv->sb = proc_get_parent_data(inode);
-               priv->show = PDE_DATA(inode);
-       }
-       return ret;
+       return single_open(file, PDE_DATA(inode), 
+                               proc_get_parent_data(inode));
 }
 
 static const struct file_operations r_file_operations = {
        .open = r_open,
        .read = seq_read,
        .llseek = seq_lseek,
-       .release = seq_release_private,
-       .owner = THIS_MODULE,
+       .release = single_release,
 };
 
 static struct proc_dir_entry *proc_info_root = NULL;
 static const char proc_info_root_name[] = "fs/reiserfs";
 
 static void add_file(struct super_block *sb, char *name,
-                    int (*func) (struct seq_file *, struct super_block *))
+                    int (*func) (struct seq_file *, void *))
 {
        proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
                         &r_file_operations, func);
index f8a23c3078f87d5eda59c30d55cea7ecc94b9273..e2e202a07b317cff5c84d8b51e3b66efafd689ea 100644 (file)
@@ -499,6 +499,7 @@ int remove_save_link(struct inode *inode, int truncate)
 static void reiserfs_kill_sb(struct super_block *s)
 {
        if (REISERFS_SB(s)) {
+               reiserfs_proc_info_done(s);
                /*
                 * Force any pending inode evictions to occur now. Any
                 * inodes to be removed that have extended attributes
@@ -554,8 +555,6 @@ static void reiserfs_put_super(struct super_block *s)
                                 REISERFS_SB(s)->reserved_blocks);
        }
 
-       reiserfs_proc_info_done(s);
-
        reiserfs_write_unlock(s);
        mutex_destroy(&REISERFS_SB(s)->lock);
        kfree(s->s_fs_info);
index 7465d4364208a2e751d2d3a7c8a8c1cc10d2d7c3..68307c029228c51efc0e7967c90c39edd1a85113 100644 (file)
@@ -336,19 +336,19 @@ EXPORT_SYMBOL(deactivate_super);
  *     and want to turn it into a full-blown active reference.  grab_super()
  *     is called with sb_lock held and drops it.  Returns 1 in case of
  *     success, 0 if we had failed (superblock contents was already dead or
- *     dying when grab_super() had been called).
+ *     dying when grab_super() had been called).  Note that this is only
+ *     called for superblocks not in rundown mode (== ones still on ->fs_supers
+ *     of their type), so increment of ->s_count is OK here.
  */
 static int grab_super(struct super_block *s) __releases(sb_lock)
 {
-       if (atomic_inc_not_zero(&s->s_active)) {
-               spin_unlock(&sb_lock);
-               return 1;
-       }
-       /* it's going away */
        s->s_count++;
        spin_unlock(&sb_lock);
-       /* wait for it to die */
        down_write(&s->s_umount);
+       if ((s->s_flags & MS_BORN) && atomic_inc_not_zero(&s->s_active)) {
+               put_super(s);
+               return 1;
+       }
        up_write(&s->s_umount);
        put_super(s);
        return 0;
@@ -463,11 +463,6 @@ retry:
                                destroy_super(s);
                                s = NULL;
                        }
-                       down_write(&old->s_umount);
-                       if (unlikely(!(old->s_flags & MS_BORN))) {
-                               deactivate_locked_super(old);
-                               goto retry;
-                       }
                        return old;
                }
        }
@@ -660,10 +655,10 @@ restart:
                if (hlist_unhashed(&sb->s_instances))
                        continue;
                if (sb->s_bdev == bdev) {
-                       if (grab_super(sb)) /* drops sb_lock */
-                               return sb;
-                       else
+                       if (!grab_super(sb))
                                goto restart;
+                       up_write(&sb->s_umount);
+                       return sb;
                }
        }
        spin_unlock(&sb_lock);
index aec3d5c98c94fa1d3d79de15a44dfa2a4a77e329..09a1a25cd14540c77d0713b7d1ecd381f78c4886 100644 (file)
@@ -20,38 +20,64 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
                         const struct attribute_group *grp)
 {
        struct attribute *const* attr;
-       int i;
+       struct bin_attribute *const* bin_attr;
 
-       for (i = 0, attr = grp->attrs; *attr; i++, attr++)
-               sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
+       if (grp->attrs)
+               for (attr = grp->attrs; *attr; attr++)
+                       sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
+       if (grp->bin_attrs)
+               for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++)
+                       sysfs_remove_bin_file(kobj, *bin_attr);
 }
 
 static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
                        const struct attribute_group *grp, int update)
 {
        struct attribute *const* attr;
+       struct bin_attribute *const* bin_attr;
        int error = 0, i;
 
-       for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) {
-               umode_t mode = 0;
+       if (grp->attrs) {
+               for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) {
+                       umode_t mode = 0;
+
+                       /*
+                        * In update mode, we're changing the permissions or
+                        * visibility.  Do this by first removing then
+                        * re-adding (if required) the file.
+                        */
+                       if (update)
+                               sysfs_hash_and_remove(dir_sd, NULL,
+                                                     (*attr)->name);
+                       if (grp->is_visible) {
+                               mode = grp->is_visible(kobj, *attr, i);
+                               if (!mode)
+                                       continue;
+                       }
+                       error = sysfs_add_file_mode(dir_sd, *attr,
+                                                   SYSFS_KOBJ_ATTR,
+                                                   (*attr)->mode | mode);
+                       if (unlikely(error))
+                               break;
+               }
+               if (error) {
+                       remove_files(dir_sd, kobj, grp);
+                       goto exit;
+               }
+       }
 
-               /* in update mode, we're changing the permissions or
-                * visibility.  Do this by first removing then
-                * re-adding (if required) the file */
-               if (update)
-                       sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
-               if (grp->is_visible) {
-                       mode = grp->is_visible(kobj, *attr, i);
-                       if (!mode)
-                               continue;
+       if (grp->bin_attrs) {
+               for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
+                       if (update)
+                               sysfs_remove_bin_file(kobj, *bin_attr);
+                       error = sysfs_create_bin_file(kobj, *bin_attr);
+                       if (error)
+                               break;
                }
-               error = sysfs_add_file_mode(dir_sd, *attr, SYSFS_KOBJ_ATTR,
-                                           (*attr)->mode | mode);
-               if (unlikely(error))
-                       break;
+               if (error)
+                       remove_files(dir_sd, kobj, grp);
        }
-       if (error)
-               remove_files(dir_sd, kobj, grp);
+exit:
        return error;
 }
 
@@ -67,8 +93,8 @@ static int internal_create_group(struct kobject *kobj, int update,
        /* Updates may happen before the object has been instantiated */
        if (unlikely(update && !kobj->sd))
                return -EINVAL;
-       if (!grp->attrs) {
-               WARN(1, "sysfs: attrs not set by subsystem for group: %s/%s\n",
+       if (!grp->attrs && !grp->bin_attrs) {
+               WARN(1, "sysfs: (bin_)attrs not set by subsystem for group: %s/%s\n",
                        kobj->name, grp->name ? "" : grp->name);
                return -EINVAL;
        }
index 07d735a80a0f777c342c4323ba9393556afe182b..e5869b50dc41acd1788123e0cd49ea2670101e3f 100644 (file)
@@ -39,6 +39,9 @@ typedef struct xfs_timestamp {
  * There is a very similar struct icdinode in xfs_inode which matches the
  * layout of the first 96 bytes of this structure, but is kept in native
  * format instead of big endian.
+ *
+ * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed
+ * padding field for v3 inodes.
  */
 typedef struct xfs_dinode {
        __be16          di_magic;       /* inode magic # = XFS_DINODE_MAGIC */
index b78481f99d9d6a683f0d18815432fce69d8d2838..bb262c25c8de463276e9282d64b299c975eceb7b 100644 (file)
@@ -896,7 +896,6 @@ xfs_dinode_to_disk(
        to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
        to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
        memcpy(to->di_pad, from->di_pad, sizeof(to->di_pad));
-       to->di_flushiter = cpu_to_be16(from->di_flushiter);
        to->di_atime.t_sec = cpu_to_be32(from->di_atime.t_sec);
        to->di_atime.t_nsec = cpu_to_be32(from->di_atime.t_nsec);
        to->di_mtime.t_sec = cpu_to_be32(from->di_mtime.t_sec);
@@ -924,6 +923,9 @@ xfs_dinode_to_disk(
                to->di_lsn = cpu_to_be64(from->di_lsn);
                memcpy(to->di_pad2, from->di_pad2, sizeof(to->di_pad2));
                uuid_copy(&to->di_uuid, &from->di_uuid);
+               to->di_flushiter = 0;
+       } else {
+               to->di_flushiter = cpu_to_be16(from->di_flushiter);
        }
 }
 
@@ -1029,10 +1031,14 @@ xfs_dinode_calc_crc(
 /*
  * Read the disk inode attributes into the in-core inode structure.
  *
- * If we are initialising a new inode and we are not utilising the
- * XFS_MOUNT_IKEEP inode cluster mode, we can simple build the new inode core
- * with a random generation number. If we are keeping inodes around, we need to
- * read the inode cluster to get the existing generation number off disk.
+ * For version 5 superblocks, if we are initialising a new inode and we are not
+ * utilising the XFS_MOUNT_IKEEP inode cluster mode, we can simple build the new
+ * inode core with a random generation number. If we are keeping inodes around,
+ * we need to read the inode cluster to get the existing generation number off
+ * disk. Further, if we are using version 4 superblocks (i.e. v1/v2 inode
+ * format) then log recovery is dependent on the di_flushiter field being
+ * initialised from the current on-disk value and hence we must also read the
+ * inode off disk.
  */
 int
 xfs_iread(
@@ -1054,6 +1060,7 @@ xfs_iread(
 
        /* shortcut IO on inode allocation if possible */
        if ((iget_flags & XFS_IGET_CREATE) &&
+           xfs_sb_version_hascrc(&mp->m_sb) &&
            !(mp->m_flags & XFS_MOUNT_IKEEP)) {
                /* initialise the on-disk inode core */
                memset(&ip->i_d, 0, sizeof(ip->i_d));
@@ -2882,12 +2889,18 @@ xfs_iflush_int(
                        __func__, ip->i_ino, ip->i_d.di_forkoff, ip);
                goto corrupt_out;
        }
+
        /*
-        * bump the flush iteration count, used to detect flushes which
-        * postdate a log record during recovery. This is redundant as we now
-        * log every change and hence this can't happen. Still, it doesn't hurt.
+        * Inode item log recovery for v1/v2 inodes are dependent on the
+        * di_flushiter count for correct sequencing. We bump the flush
+        * iteration count so we can detect flushes which postdate a log record
+        * during recovery. This is redundant as we now log every change and
+        * hence this can't happen but we need to still do it to ensure
+        * backwards compatibility with old kernels that predate logging all
+        * inode changes.
         */
-       ip->i_d.di_flushiter++;
+       if (ip->i_d.di_version < 3)
+               ip->i_d.di_flushiter++;
 
        /*
         * Copy the dirty parts of the inode into the on-disk
index 6fcc910a50b9d7e3fbd3c15851aa0ee0cfc1b6af..7681b19aa5dc565a9807005ff3f1d6428a22f016 100644 (file)
@@ -2592,8 +2592,16 @@ xlog_recover_inode_pass2(
                goto error;
        }
 
-       /* Skip replay when the on disk inode is newer than the log one */
-       if (dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
+       /*
+        * di_flushiter is only valid for v1/2 inodes. All changes for v3 inodes
+        * are transactional and if ordering is necessary we can determine that
+        * more accurately by the LSN field in the V3 inode core. Don't trust
+        * the inode versions we might be changing them here - use the
+        * superblock flag to determine whether we need to look at di_flushiter
+        * to skip replay when the on disk inode is newer than the log one
+        */
+       if (!xfs_sb_version_hascrc(&mp->m_sb) &&
+           dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
                /*
                 * Deal with the wrap case, DI_MAX_FLUSH is less
                 * than smaller numbers
@@ -2608,6 +2616,7 @@ xlog_recover_inode_pass2(
                        goto error;
                }
        }
+
        /* Take the opportunity to reset the flush iteration count */
        dicp->di_flushiter = 0;
 
index 56e6b68c8d2fcb36fae154ebe6bb687f9e74760d..94383a70c1a3d738413e06389cc6937909554823 100644 (file)
@@ -274,15 +274,12 @@ struct acpi_device_wakeup {
 };
 
 struct acpi_device_physical_node {
-       u8 node_id;
+       unsigned int node_id;
        struct list_head node;
        struct device *dev;
        bool put_online:1;
 };
 
-/* set maximum of physical nodes to 32 for expansibility */
-#define ACPI_MAX_PHYSICAL_NODE 32
-
 /* Device */
 struct acpi_device {
        int device_type;
@@ -302,10 +299,9 @@ struct acpi_device {
        struct acpi_driver *driver;
        void *driver_data;
        struct device dev;
-       u8 physical_node_count;
+       unsigned int physical_node_count;
        struct list_head physical_node_list;
        struct mutex physical_node_lock;
-       DECLARE_BITMAP(physical_node_id_bitmap, ACPI_MAX_PHYSICAL_NODE);
        struct list_head power_dependent;
        void (*remove)(struct acpi_device *);
 };
@@ -445,7 +441,11 @@ struct acpi_pci_root {
 };
 
 /* helper */
-acpi_handle acpi_get_child(acpi_handle, u64);
+acpi_handle acpi_find_child(acpi_handle, u64, bool);
+static inline acpi_handle acpi_get_child(acpi_handle handle, u64 addr)
+{
+       return acpi_find_child(handle, addr, false);
+}
 int acpi_is_root_bridge(acpi_handle);
 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
 #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)ACPI_HANDLE(dev))
index 1b09300810e647dc71fbd7b490cd081ef7c0862d..22d497ee6ef95032977a5b4d533f5343d29c4fa5 100644 (file)
@@ -62,6 +62,7 @@ extern u32 acpi_current_gpe_count;
 extern struct acpi_table_fadt acpi_gbl_FADT;
 extern u8 acpi_gbl_system_awake_and_running;
 extern u8 acpi_gbl_reduced_hardware;   /* ACPI 5.0 */
+extern u8 acpi_gbl_osi_data;
 
 /* Runtime configuration of debug print levels */
 
index a64adcc29ae5b5316bde21354eab5015d6fcddd5..22b03c9286e94d0d4819d5e6610f96a850b4f713 100644 (file)
@@ -1144,4 +1144,19 @@ struct acpi_memory_list {
 #endif
 };
 
+/* Definitions for _OSI support */
+
+#define ACPI_OSI_WIN_2000               0x01
+#define ACPI_OSI_WIN_XP                 0x02
+#define ACPI_OSI_WIN_XP_SP1             0x03
+#define ACPI_OSI_WINSRV_2003            0x04
+#define ACPI_OSI_WIN_XP_SP2             0x05
+#define ACPI_OSI_WINSRV_2003_SP1        0x06
+#define ACPI_OSI_WIN_VISTA              0x07
+#define ACPI_OSI_WINSRV_2008            0x08
+#define ACPI_OSI_WIN_VISTA_SP1          0x09
+#define ACPI_OSI_WIN_VISTA_SP2          0x0A
+#define ACPI_OSI_WIN_7                  0x0B
+#define ACPI_OSI_WIN_8                  0x0C
+
 #endif                         /* __ACTYPES_H__ */
index 2f47ade1b5678f325faea455656a9578839b8638..0807ddf97b058fb04b1eedfd82c34b76e4253335 100644 (file)
@@ -417,6 +417,36 @@ static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
 {
        return pmd;
 }
+
+static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
+{
+       return pte;
+}
+
+static inline int pte_swp_soft_dirty(pte_t pte)
+{
+       return 0;
+}
+
+static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
+{
+       return pte;
+}
+
+static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
+{
+       return pte;
+}
+
+static inline pte_t pte_file_mksoft_dirty(pte_t pte)
+{
+       return pte;
+}
+
+static inline int pte_file_soft_dirty(pte_t pte)
+{
+       return 0;
+}
 #endif
 
 #ifndef __HAVE_PFNMAP_TRACKING
index 13821c339a4151912b88f2e4de04cbf99653a612..5672d7ea1fa066175b33c8f4c19457fcdc0614ed 100644 (file)
@@ -112,7 +112,7 @@ struct mmu_gather {
 
 #define HAVE_GENERIC_MMU_GATHER
 
-void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm);
+void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end);
 void tlb_flush_mmu(struct mmu_gather *tlb);
 void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start,
                                                        unsigned long end);
index f5e1168c76473d3c1180cbcac654eac67ee2373f..d639049a613dfdb264650f8ee938836e6ed28e10 100644 (file)
@@ -84,12 +84,12 @@ static inline int drm_fixp2int(int64_t a)
        return ((s64)a) >> DRM_FIXED_POINT;
 }
 
-static inline s64 drm_fixp_msbset(int64_t a)
+static inline unsigned drm_fixp_msbset(int64_t a)
 {
        unsigned shift, sign = (a >> 63) & 1;
 
        for (shift = 62; shift > 0; --shift)
-               if ((a >> shift) != sign)
+               if (((a >> shift) & 1) != sign)
                        return shift;
 
        return 0;
@@ -100,9 +100,9 @@ static inline s64 drm_fixp_mul(s64 a, s64 b)
        unsigned shift = drm_fixp_msbset(a) + drm_fixp_msbset(b);
        s64 result;
 
-       if (shift > 63) {
-               shift = shift - 63;
-               a >>= shift >> 1;
+       if (shift > 61) {
+               shift = shift - 61;
+               a >>= (shift >> 1) + (shift & 1);
                b >>= shift >> 1;
        } else
                shift = 0;
@@ -120,7 +120,7 @@ static inline s64 drm_fixp_mul(s64 a, s64 b)
 
 static inline s64 drm_fixp_div(s64 a, s64 b)
 {
-       unsigned shift = 63 - drm_fixp_msbset(a);
+       unsigned shift = 62 - drm_fixp_msbset(a);
        s64 result;
 
        a <<= shift;
@@ -154,7 +154,7 @@ static inline s64 drm_fixp_exp(s64 x)
        }
 
        if (x < 0)
-               sum = drm_fixp_div(1, sum);
+               sum = drm_fixp_div(DRM_FIXED_ONE, sum);
 
        return sum;
 }
index 15e997fa78f24d9822defea3d2eb097b088580e7..4aa2b48cd15183e457a3eb96288dca81039cef37 100644 (file)
 #define VF610_CLK_GPU_SEL              145
 #define VF610_CLK_GPU_EN               146
 #define VF610_CLK_GPU2D                        147
-#define VF610_CLK_END                  148
+#define VF610_CLK_ENET0                        148
+#define VF610_CLK_ENET1                        149
+#define VF610_CLK_END                  150
 
 #endif /* __DT_BINDINGS_CLOCK_VF610_H */
index 469e0325e6f4b409fb07168da7b9adb1ddce5915..2fbc804e1a45cea943c9241309601f941abd5d14 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef _DT_BINDINGS_PINCTRL_AM33XX_H
 #define _DT_BINDINGS_PINCTRL_AM33XX_H
 
-#include <include/dt-bindings/pinctrl/omap.h>
+#include <dt-bindings/pinctrl/omap.h>
 
 /* am33xx specific mux bit defines */
 #undef PULL_ENA
index 089fe43211a492ec8258256b63a07a90ca2660b7..dc029dba7a030d384d9389038b6f7d600eee3dbf 100644 (file)
@@ -9,26 +9,13 @@
 
 #include <linux/spi/spi.h>
 
-/**
+/*
  * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data
  * @oscillator_frequency:       - oscillator frequency in Hz
- * @irq_flags:                  - IRQF configuration flags
- * @board_specific_setup:       - called before probing the chip (power,reset)
- * @transceiver_enable:         - called to power on/off the transceiver
- * @power_enable:               - called to power on/off the mcp *and* the
- *                                transceiver
- *
- * Please note that you should define power_enable or transceiver_enable or
- * none of them. Defining both of them is no use.
- *
  */
 
 struct mcp251x_platform_data {
        unsigned long oscillator_frequency;
-       unsigned long irq_flags;
-       int (*board_specific_setup)(struct spi_device *spi);
-       int (*transceiver_enable)(int enable);
-       int (*power_enable) (int enable);
 };
 
 #endif /* __CAN_PLATFORM_MCP251X_H__ */
index 297462b9f41acb7c95607daa36516b017e37be53..e9ac882868c0353f8f6bb7f2baba2a73c8602c41 100644 (file)
@@ -542,8 +542,7 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
 bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
 
 int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
-int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id,
-                                   char *buf, size_t buflen);
+int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
 
 int cgroup_task_count(const struct cgroup *cgrp);
 
index 6e7ec64b69ab4b7aa5ee7aacef569f633f0de296..b613ffd402d1bdd38747e45e26260b28a4355768 100644 (file)
@@ -1,86 +1,55 @@
-/* Add subsystem definitions of the form SUBSYS(<name>) in this
- * file. Surround each one by a line of comment markers so that
- * patches don't collide
+/*
+ * List of cgroup subsystems.
+ *
+ * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
  */
-
-/* */
-
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CPUSETS)
 SUBSYS(cpuset)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEBUG)
 SUBSYS(debug)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_SCHED)
 SUBSYS(cpu_cgroup)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_CPUACCT)
 SUBSYS(cpuacct)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_MEMCG)
 SUBSYS(mem_cgroup)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_DEVICE)
 SUBSYS(devices)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_FREEZER)
 SUBSYS(freezer)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_NET_CLS_CGROUP)
 SUBSYS(net_cls)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_BLK_CGROUP)
 SUBSYS(blkio)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_PERF)
 SUBSYS(perf)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_NETPRIO_CGROUP)
 SUBSYS(net_prio)
 #endif
 
-/* */
-
 #if IS_SUBSYS_ENABLED(CONFIG_CGROUP_HUGETLB)
 SUBSYS(hugetlb)
 #endif
-
-/* */
-
-#ifdef CONFIG_CGROUP_BCACHE
-SUBSYS(bcache)
-#endif
-
-/* */
+/*
+ * DO NOT ADD ANY SUBSYSTEM WITHOUT EXPLICIT ACKS FROM CGROUP MAINTAINERS.
+ */
index 944f283f01c497cc2aa5127614bc64c3bd86c403..ab0eade730392265b298833bd9db4579f387d1bb 100644 (file)
@@ -114,7 +114,7 @@ enum {
 /* Need to know about CPUs going up/down? */
 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
 #define cpu_notifier(fn, pri) {                                        \
-       static struct notifier_block fn##_nb __cpuinitdata =    \
+       static struct notifier_block fn##_nb =                  \
                { .notifier_call = fn, .priority = pri };       \
        register_cpu_notifier(&fn##_nb);                        \
 }
index b3cb71f0d3b0d19b8c08e70348dee1bb5e5ba6ad..a9c96d865ee7144b577afc3752c0a1a94cd95e11 100644 (file)
@@ -3,10 +3,6 @@
 
 #include <linux/types.h>
 
-#define CRC_T10DIF_DIGEST_SIZE 2
-#define CRC_T10DIF_BLOCK_SIZE 1
-
-__u16 crc_t10dif_generic(__u16 crc, const unsigned char *buffer, size_t len);
 __u16 crc_t10dif(unsigned char const *, size_t);
 
 #endif
index 3092df3614ae4651a867571ccbaa1d670e97c314..b90337c9d468ead13e94f4c6ed110bdf75723755 100644 (file)
@@ -324,7 +324,7 @@ static inline int __d_rcu_to_refcount(struct dentry *dentry, unsigned seq)
        return ret;
 }
 
-static inline unsigned d_count(struct dentry *dentry)
+static inline unsigned d_count(const struct dentry *dentry)
 {
        return dentry->d_count;
 }
index bcf8c0d4cd981b49ff9b545d8942d9810fd1f169..22b546a585916b2c8b5754c3f321130c7231d1fe 100644 (file)
@@ -47,7 +47,11 @@ struct bus_attribute {
 };
 
 #define BUS_ATTR(_name, _mode, _show, _store)  \
-struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
+       struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
+#define BUS_ATTR_RW(_name) \
+       struct bus_attribute bus_attr_##_name = __ATTR_RW(_name)
+#define BUS_ATTR_RO(_name) \
+       struct bus_attribute bus_attr_##_name = __ATTR_RO(_name)
 
 extern int __must_check bus_create_file(struct bus_type *,
                                        struct bus_attribute *);
@@ -261,9 +265,12 @@ struct driver_attribute {
                         size_t count);
 };
 
-#define DRIVER_ATTR(_name, _mode, _show, _store)       \
-struct driver_attribute driver_attr_##_name =          \
-       __ATTR(_name, _mode, _show, _store)
+#define DRIVER_ATTR(_name, _mode, _show, _store) \
+       struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
+#define DRIVER_ATTR_RW(_name) \
+       struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
+#define DRIVER_ATTR_RO(_name) \
+       struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
 
 extern int __must_check driver_create_file(struct device_driver *driver,
                                        const struct driver_attribute *attr);
@@ -313,6 +320,7 @@ int subsys_virtual_register(struct bus_type *subsys,
  * @name:      Name of the class.
  * @owner:     The module owner.
  * @class_attrs: Default attributes of this class.
+ * @dev_groups:        Default attributes of the devices that belong to the class.
  * @dev_attrs: Default attributes of the devices belong to the class.
  * @dev_bin_attrs: Default binary attributes of the devices belong to the class.
  * @dev_kobj:  The kobject that represents this class and links it into the hierarchy.
@@ -342,7 +350,8 @@ struct class {
        struct module           *owner;
 
        struct class_attribute          *class_attrs;
-       struct device_attribute         *dev_attrs;
+       struct device_attribute         *dev_attrs;     /* use dev_groups instead */
+       const struct attribute_group    **dev_groups;
        struct bin_attribute            *dev_bin_attrs;
        struct kobject                  *dev_kobj;
 
@@ -414,8 +423,12 @@ struct class_attribute {
                                 const struct class_attribute *attr);
 };
 
-#define CLASS_ATTR(_name, _mode, _show, _store)                        \
-struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
+#define CLASS_ATTR(_name, _mode, _show, _store) \
+       struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
+#define CLASS_ATTR_RW(_name) \
+       struct class_attribute class_attr_##_name = __ATTR_RW(_name)
+#define CLASS_ATTR_RO(_name) \
+       struct class_attribute class_attr_##_name = __ATTR_RO(_name)
 
 extern int __must_check class_create_file(struct class *class,
                                          const struct class_attribute *attr);
@@ -423,7 +436,6 @@ extern void class_remove_file(struct class *class,
                              const struct class_attribute *attr);
 
 /* Simple class attribute that is just a static string */
-
 struct class_attribute_string {
        struct class_attribute attr;
        char *str;
@@ -512,6 +524,10 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
 
 #define DEVICE_ATTR(_name, _mode, _show, _store) \
        struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
+#define DEVICE_ATTR_RW(_name) \
+       struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
+#define DEVICE_ATTR_RO(_name) \
+       struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
 #define DEVICE_ULONG_ATTR(_name, _mode, _var) \
        struct dev_ext_attribute dev_attr_##_name = \
                { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) }
@@ -924,6 +940,11 @@ extern __printf(5, 6)
 struct device *device_create(struct class *cls, struct device *parent,
                             dev_t devt, void *drvdata,
                             const char *fmt, ...);
+extern __printf(6, 7)
+struct device *device_create_with_groups(struct class *cls,
+                            struct device *parent, dev_t devt, void *drvdata,
+                            const struct attribute_group **groups,
+                            const char *fmt, ...);
 extern void device_destroy(struct class *cls, dev_t devt);
 
 /*
index 96e87693d93349c92563585f1abf59efd8d4c029..841925fbfe8a737f4953deb85cc4f5841be2302b 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef __DM9000_PLATFORM_DATA
 #define __DM9000_PLATFORM_DATA __FILE__
 
+#include <linux/if_ether.h>
+
 /* IO control flags */
 
 #define DM9000_PLATF_8BITONLY  (0x0001)
@@ -27,7 +29,7 @@
 
 struct dm9000_plat_data {
        unsigned int    flags;
-       unsigned char   dev_addr[6];
+       unsigned char   dev_addr[ETH_ALEN];
 
        /* allow replacement IO routines */
 
index 1b4d4ee1168ffb3b8ac90c42aaad073753573b1f..de7d74ab3de6df5237c5b117fa2dced482779842 100644 (file)
@@ -177,7 +177,11 @@ enum drbd_ret_code {
        ERR_NEED_APV_100        = 163,
        ERR_NEED_ALLOW_TWO_PRI  = 164,
        ERR_MD_UNCLEAN          = 165,
-
+       ERR_MD_LAYOUT_CONNECTED = 166,
+       ERR_MD_LAYOUT_TOO_BIG   = 167,
+       ERR_MD_LAYOUT_TOO_SMALL = 168,
+       ERR_MD_LAYOUT_NO_FIT    = 169,
+       ERR_IMPLICIT_SHRINK     = 170,
        /* insert new ones above this line */
        AFTER_LAST_ERR_CODE
 };
index d0d8fac8a6e4ffa77141b038f898537f31ed28f0..e8c44572b8cba2d244d87c528d3e683173d5fd1e 100644 (file)
@@ -181,6 +181,8 @@ GENL_struct(DRBD_NLA_RESIZE_PARMS, 7, resize_parms,
        __u64_field(1, DRBD_GENLA_F_MANDATORY,  resize_size)
        __flg_field(2, DRBD_GENLA_F_MANDATORY,  resize_force)
        __flg_field(3, DRBD_GENLA_F_MANDATORY,  no_resync)
+       __u32_field_def(4, 0 /* OPTIONAL */, al_stripes, DRBD_AL_STRIPES_DEF)
+       __u32_field_def(5, 0 /* OPTIONAL */, al_stripe_size, DRBD_AL_STRIPE_SIZE_DEF)
 )
 
 GENL_struct(DRBD_NLA_STATE_INFO, 8, state_info,
index 1fedf2b17cc801805581a185638fe97184be27b3..17e50bb00521362f0840eae9e79da52e2b34d139 100644 (file)
 #define DRBD_ALWAYS_ASBP_DEF   0
 #define DRBD_USE_RLE_DEF       1
 
+#define DRBD_AL_STRIPES_MIN     1
+#define DRBD_AL_STRIPES_MAX     1024
+#define DRBD_AL_STRIPES_DEF     1
+#define DRBD_AL_STRIPES_SCALE   '1'
+
+#define DRBD_AL_STRIPE_SIZE_MIN   4
+#define DRBD_AL_STRIPE_SIZE_MAX   16777216
+#define DRBD_AL_STRIPE_SIZE_DEF   32
+#define DRBD_AL_STRIPE_SIZE_SCALE 'k' /* kilobytes */
 #endif
index 0b763276f6199a255d304b572e0c414c90252056..5c6d7fbaf89e00dbed2d9cc418318980f7de3d2b 100644 (file)
@@ -622,7 +622,7 @@ struct edac_raw_error_desc {
  */
 struct mem_ctl_info {
        struct device                   dev;
-       struct bus_type                 bus;
+       struct bus_type                 *bus;
 
        struct list_head link;  /* for global list of mem_ctl_info structs */
 
@@ -742,4 +742,9 @@ struct mem_ctl_info {
 #endif
 };
 
+/*
+ * Maximum number of memory controllers in the coherent fabric.
+ */
+#define EDAC_MAX_MCS   16
+
 #endif
index 3b0e820375ab90c2e0f9a05ffaa94f7a36f76abd..5d7782e42b8f22f81df12652348ff9a21aebc7e4 100644 (file)
@@ -436,6 +436,7 @@ struct fw_iso_context {
        int type;
        int channel;
        int speed;
+       bool drop_overflow_headers;
        size_t header_size;
        union {
                fw_iso_callback_t sc;
index 51b793466ff3adcadb4e6bcc0d372494dbf7440c..efb05961bdd8fbebbde2d2f534f486defe1ca095 100644 (file)
 #ifndef FS_ENET_PD_H
 #define FS_ENET_PD_H
 
+#include <linux/clk.h>
 #include <linux/string.h>
 #include <linux/of_mdio.h>
+#include <linux/if_ether.h>
 #include <asm/types.h>
 
 #define FS_ENET_NAME   "fs_enet"
@@ -135,13 +137,15 @@ struct fs_platform_info {
        const struct fs_mii_bus_info *bus_info;
 
        int rx_ring, tx_ring;   /* number of buffers on rx     */
-       __u8 macaddr[6];        /* mac address                 */
+       __u8 macaddr[ETH_ALEN]; /* mac address                 */
        int rx_copybreak;       /* limit we copy small frames  */
        int use_napi;           /* use NAPI                    */
        int napi_weight;        /* NAPI weight                 */
 
        int use_rmii;           /* use RMII mode               */
        int has_phy;            /* if the network is phy container as well...*/
+
+       struct clk *clk_per;    /* 'per' clock for register access */
 };
 struct fs_mii_fec_platform_info {
        u32 irq[32];
index 4372658c73ae5eddd3dd6570d4dfac8c5d8825c8..120d57a1c3a5dcb452a75d4fd21a6d338b128a0d 100644 (file)
@@ -78,6 +78,11 @@ struct trace_iterator {
        /* trace_seq for __print_flags() and __print_symbolic() etc. */
        struct trace_seq        tmp_seq;
 
+       cpumask_var_t           started;
+
+       /* it's true when current open file is snapshot */
+       bool                    snapshot;
+
        /* The below is zeroed out in pipe_read */
        struct trace_seq        seq;
        struct trace_entry      *ent;
@@ -90,10 +95,7 @@ struct trace_iterator {
        loff_t                  pos;
        long                    idx;
 
-       cpumask_var_t           started;
-
-       /* it's true when current open file is snapshot */
-       bool                    snapshot;
+       /* All new field here will be zeroed out in pipe_read */
 };
 
 enum trace_iter_flags {
@@ -332,7 +334,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
                              const char *name, int offset, int size,
                              int is_signed, int filter_type);
 extern int trace_add_event_call(struct ftrace_event_call *call);
-extern void trace_remove_event_call(struct ftrace_event_call *call);
+extern int trace_remove_event_call(struct ftrace_event_call *call);
 
 #define is_signed_type(type)   (((type)(-1)) < (type)1)
 
index 23a8877f4ded09298346170666af052cfe2c0328..a5b598a79becb99eb3554886cbec7708ee426309 100644 (file)
@@ -16,6 +16,7 @@
 #define LINUX_IEEE80211_H
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
 #include <asm/byteorder.h>
 
 /*
@@ -209,28 +210,28 @@ static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
 struct ieee80211_hdr {
        __le16 frame_control;
        __le16 duration_id;
-       u8 addr1[6];
-       u8 addr2[6];
-       u8 addr3[6];
+       u8 addr1[ETH_ALEN];
+       u8 addr2[ETH_ALEN];
+       u8 addr3[ETH_ALEN];
        __le16 seq_ctrl;
-       u8 addr4[6];
+       u8 addr4[ETH_ALEN];
 } __packed __aligned(2);
 
 struct ieee80211_hdr_3addr {
        __le16 frame_control;
        __le16 duration_id;
-       u8 addr1[6];
-       u8 addr2[6];
-       u8 addr3[6];
+       u8 addr1[ETH_ALEN];
+       u8 addr2[ETH_ALEN];
+       u8 addr3[ETH_ALEN];
        __le16 seq_ctrl;
 } __packed __aligned(2);
 
 struct ieee80211_qos_hdr {
        __le16 frame_control;
        __le16 duration_id;
-       u8 addr1[6];
-       u8 addr2[6];
-       u8 addr3[6];
+       u8 addr1[ETH_ALEN];
+       u8 addr2[ETH_ALEN];
+       u8 addr3[ETH_ALEN];
        __le16 seq_ctrl;
        __le16 qos_ctrl;
 } __packed __aligned(2);
@@ -608,8 +609,8 @@ struct ieee80211s_hdr {
        u8 flags;
        u8 ttl;
        __le32 seqnum;
-       u8 eaddr1[6];
-       u8 eaddr2[6];
+       u8 eaddr1[ETH_ALEN];
+       u8 eaddr2[ETH_ALEN];
 } __packed __aligned(2);
 
 /* Mesh flags */
@@ -758,7 +759,7 @@ struct ieee80211_rann_ie {
        u8 rann_flags;
        u8 rann_hopcount;
        u8 rann_ttl;
-       u8 rann_addr[6];
+       u8 rann_addr[ETH_ALEN];
        __le32 rann_seq;
        __le32 rann_interval;
        __le32 rann_metric;
@@ -802,9 +803,9 @@ enum ieee80211_vht_opmode_bits {
 struct ieee80211_mgmt {
        __le16 frame_control;
        __le16 duration;
-       u8 da[6];
-       u8 sa[6];
-       u8 bssid[6];
+       u8 da[ETH_ALEN];
+       u8 sa[ETH_ALEN];
+       u8 bssid[ETH_ALEN];
        __le16 seq_ctrl;
        union {
                struct {
@@ -833,7 +834,7 @@ struct ieee80211_mgmt {
                struct {
                        __le16 capab_info;
                        __le16 listen_interval;
-                       u8 current_ap[6];
+                       u8 current_ap[ETH_ALEN];
                        /* followed by SSID and Supported rates */
                        u8 variable[0];
                } __packed reassoc_req;
@@ -966,21 +967,21 @@ struct ieee80211_vendor_ie {
 struct ieee80211_rts {
        __le16 frame_control;
        __le16 duration;
-       u8 ra[6];
-       u8 ta[6];
+       u8 ra[ETH_ALEN];
+       u8 ta[ETH_ALEN];
 } __packed __aligned(2);
 
 struct ieee80211_cts {
        __le16 frame_control;
        __le16 duration;
-       u8 ra[6];
+       u8 ra[ETH_ALEN];
 } __packed __aligned(2);
 
 struct ieee80211_pspoll {
        __le16 frame_control;
        __le16 aid;
-       u8 bssid[6];
-       u8 ta[6];
+       u8 bssid[ETH_ALEN];
+       u8 ta[ETH_ALEN];
 } __packed __aligned(2);
 
 /* TDLS */
@@ -989,14 +990,14 @@ struct ieee80211_pspoll {
 struct ieee80211_tdls_lnkie {
        u8 ie_type; /* Link Identifier IE */
        u8 ie_len;
-       u8 bssid[6];
-       u8 init_sta[6];
-       u8 resp_sta[6];
+       u8 bssid[ETH_ALEN];
+       u8 init_sta[ETH_ALEN];
+       u8 resp_sta[ETH_ALEN];
 } __packed;
 
 struct ieee80211_tdls_data {
-       u8 da[6];
-       u8 sa[6];
+       u8 da[ETH_ALEN];
+       u8 sa[ETH_ALEN];
        __be16 ether_type;
        u8 payload_type;
        u8 category;
@@ -1090,8 +1091,8 @@ struct ieee80211_p2p_noa_attr {
 struct ieee80211_bar {
        __le16 frame_control;
        __le16 duration;
-       __u8 ra[6];
-       __u8 ta[6];
+       __u8 ra[ETH_ALEN];
+       __u8 ta[ETH_ALEN];
        __le16 control;
        __le16 start_seq_num;
 } __packed;
index f6156f91eb1cb0fb06597e83b95a8bf74664cee6..a899dc24be152ab29525ee4cdcc4e8f2a7a6636f 100644 (file)
@@ -10,9 +10,9 @@
 #ifndef _LINUX_IF_TEAM_H_
 #define _LINUX_IF_TEAM_H_
 
-
 #include <linux/netpoll.h>
 #include <net/sch_generic.h>
+#include <linux/types.h>
 #include <uapi/linux/if_team.h>
 
 struct team_pcpu_stats {
@@ -194,6 +194,18 @@ struct team {
        bool user_carrier_enabled;
        bool queue_override_enabled;
        struct list_head *qom_lists; /* array of queue override mapping lists */
+       struct {
+               unsigned int count;
+               unsigned int interval; /* in ms */
+               atomic_t count_pending;
+               struct delayed_work dw;
+       } notify_peers;
+       struct {
+               unsigned int count;
+               unsigned int interval; /* in ms */
+               atomic_t count_pending;
+               struct delayed_work dw;
+       } mcast_rejoin;
        long mode_priv[TEAM_MODE_PRIV_LONGS];
 };
 
index cdcbafa9b39a0a80082d9c2c9123edae798142a4..715c343f7c0009554d430a8e9cf613f9318263a5 100644 (file)
@@ -79,9 +79,8 @@ static inline int is_vlan_dev(struct net_device *dev)
 }
 
 #define vlan_tx_tag_present(__skb)     ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
-#define vlan_tx_nonzero_tag_present(__skb) \
-       (vlan_tx_tag_present(__skb) && ((__skb)->vlan_tci & VLAN_VID_MASK))
 #define vlan_tx_tag_get(__skb)         ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
+#define vlan_tx_tag_get_id(__skb)      ((__skb)->vlan_tci & VLAN_VID_MASK)
 
 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
 
index e3362b5f13e8258857f50a64e73fe3e70f9039f3..f47550d75f85fddd53186c92f0e1383c8f693b90 100644 (file)
@@ -129,6 +129,5 @@ extern void ip_mc_unmap(struct in_device *);
 extern void ip_mc_remap(struct in_device *);
 extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr);
 extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
-extern void ip_mc_rejoin_groups(struct in_device *in_dev);
 
 #endif
index 8d171f42763261cc15f7944fd3f27f22fb003c1b..3d35b7023591facc722dc58a22e9acbb44302726 100644 (file)
@@ -211,8 +211,8 @@ struct iio_chan_spec {
 static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
        enum iio_chan_info_enum type)
 {
-       return (chan->info_mask_separate & type) |
-              (chan->info_mask_shared_by_type & type);
+       return (chan->info_mask_separate & BIT(type)) |
+              (chan->info_mask_shared_by_type & BIT(type));
 }
 
 #define IIO_ST(si, rb, sb, sh)                                         \
index 3869c525b052171fff8bbe3000d61d5999bae7ee..369cf2cd51448b690cb812e6310cbd450ab83386 100644 (file)
@@ -8,6 +8,7 @@
  */
 #include <linux/irq.h>
 #include <linux/module.h>
+#include <linux/atomic.h>
 
 #ifndef _IIO_TRIGGER_H_
 #define _IIO_TRIGGER_H_
@@ -61,7 +62,7 @@ struct iio_trigger {
 
        struct list_head                list;
        struct list_head                alloc_list;
-       int use_count;
+       atomic_t                        use_count;
 
        struct irq_chip                 subirq_chip;
        int                             subirq_base;
index b99cd23f347489ea0a3c2a14d58193c6e1117331..79640e015a86c6eb4a8bab2c0d2ee78eaf241558 100644 (file)
@@ -5,45 +5,13 @@
 
 #include <linux/bitmap.h>
 #include <linux/if.h>
+#include <linux/ip.h>
 #include <linux/netdevice.h>
 #include <linux/rcupdate.h>
 #include <linux/timer.h>
 #include <linux/sysctl.h>
 #include <linux/rtnetlink.h>
 
-enum
-{
-       IPV4_DEVCONF_FORWARDING=1,
-       IPV4_DEVCONF_MC_FORWARDING,
-       IPV4_DEVCONF_PROXY_ARP,
-       IPV4_DEVCONF_ACCEPT_REDIRECTS,
-       IPV4_DEVCONF_SECURE_REDIRECTS,
-       IPV4_DEVCONF_SEND_REDIRECTS,
-       IPV4_DEVCONF_SHARED_MEDIA,
-       IPV4_DEVCONF_RP_FILTER,
-       IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
-       IPV4_DEVCONF_BOOTP_RELAY,
-       IPV4_DEVCONF_LOG_MARTIANS,
-       IPV4_DEVCONF_TAG,
-       IPV4_DEVCONF_ARPFILTER,
-       IPV4_DEVCONF_MEDIUM_ID,
-       IPV4_DEVCONF_NOXFRM,
-       IPV4_DEVCONF_NOPOLICY,
-       IPV4_DEVCONF_FORCE_IGMP_VERSION,
-       IPV4_DEVCONF_ARP_ANNOUNCE,
-       IPV4_DEVCONF_ARP_IGNORE,
-       IPV4_DEVCONF_PROMOTE_SECONDARIES,
-       IPV4_DEVCONF_ARP_ACCEPT,
-       IPV4_DEVCONF_ARP_NOTIFY,
-       IPV4_DEVCONF_ACCEPT_LOCAL,
-       IPV4_DEVCONF_SRC_VMARK,
-       IPV4_DEVCONF_PROXY_ARP_PVLAN,
-       IPV4_DEVCONF_ROUTE_LOCALNET,
-       __IPV4_DEVCONF_MAX
-};
-
-#define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
-
 struct ipv4_devconf {
        void    *sysctl;
        int     data[IPV4_DEVCONF_MAX];
index 850e95bc766c8504d4fbc2c592c1327ef5994431..9ac5047062c826d85102355d9a4bb98bcda795f1 100644 (file)
@@ -19,6 +19,8 @@ struct ipv6_devconf {
        __s32           rtr_solicit_interval;
        __s32           rtr_solicit_delay;
        __s32           force_mld_version;
+       __s32           mldv1_unsolicited_report_interval;
+       __s32           mldv2_unsolicited_report_interval;
 #ifdef CONFIG_IPV6_PRIVACY
        __s32           use_tempaddr;
        __s32           temp_valid_lft;
@@ -101,6 +103,7 @@ struct inet6_skb_parm {
 #define IP6SKB_FORWARDED       2
 #define IP6SKB_REROUTED                4
 #define IP6SKB_ROUTERALERT     8
+#define IP6SKB_FRAGMENTED      16
 };
 
 #define IP6CB(skb)     ((struct inet6_skb_parm*)((skb)->cb))
index 3bef14c6586bc9d7d875e6579352a62e53e13c6a..482ad2d84a32dae333c74cccb2d1394b247d5ae8 100644 (file)
@@ -629,7 +629,7 @@ extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
 static inline void tracing_start(void) { }
 static inline void tracing_stop(void) { }
 static inline void ftrace_off_permanent(void) { }
-static inline void trace_dump_stack(void) { }
+static inline void trace_dump_stack(int skip) { }
 
 static inline void tracing_on(void) { }
 static inline void tracing_off(void) { }
index b83e5657365adcd30bd816d7d0e57ce3d3691980..f4d8a2f12a33263b63ebc50fc61d8d7b5b3eb6d3 100644 (file)
@@ -380,17 +380,6 @@ static inline void list_splice_tail_init(struct list_head *list,
 #define list_for_each(pos, head) \
        for (pos = (head)->next; pos != (head); pos = pos->next)
 
-/**
- * __list_for_each     -       iterate over a list
- * @pos:       the &struct list_head to use as a loop cursor.
- * @head:      the head for your list.
- *
- * This variant doesn't differ from list_for_each() any more.
- * We don't do prefetching in either case.
- */
-#define __list_for_each(pos, head) \
-       for (pos = (head)->next; pos != (head); pos = pos->next)
-
 /**
  * list_for_each_prev  -       iterate over a list backwards
  * @pos:       the &struct list_head to use as a loop cursor.
index dab34a1deb2c156ecdb8a67328d6cfbb6b0d5c8d..b6bdcd66c07d2e758ba677f9c9c1796ada542bc8 100644 (file)
 #define IMX6Q_GPR1_EXC_MON_MASK                        BIT(22)
 #define IMX6Q_GPR1_EXC_MON_OKAY                        0x0
 #define IMX6Q_GPR1_EXC_MON_SLVE                        BIT(22)
-#define IMX6Q_GPR1_MIPI_IPU2_SEL_MASK          BIT(21)
-#define IMX6Q_GPR1_MIPI_IPU2_SEL_GASKET                0x0
-#define IMX6Q_GPR1_MIPI_IPU2_SEL_IOMUX         BIT(21)
-#define IMX6Q_GPR1_MIPI_IPU1_MUX_MASK          BIT(20)
-#define IMX6Q_GPR1_MIPI_IPU1_MUX_GASKET                0x0
-#define IMX6Q_GPR1_MIPI_IPU1_MUX_IOMUX         BIT(20)
-#define IMX6Q_GPR1_MIPI_IPU2_MUX_MASK          BIT(19)
+#define IMX6Q_GPR1_ENET_CLK_SEL_MASK           BIT(21)
+#define IMX6Q_GPR1_ENET_CLK_SEL_PAD            0
+#define IMX6Q_GPR1_ENET_CLK_SEL_ANATOP         BIT(21)
+#define IMX6Q_GPR1_MIPI_IPU2_MUX_MASK          BIT(20)
 #define IMX6Q_GPR1_MIPI_IPU2_MUX_GASKET                0x0
-#define IMX6Q_GPR1_MIPI_IPU2_MUX_IOMUX         BIT(19)
+#define IMX6Q_GPR1_MIPI_IPU2_MUX_IOMUX         BIT(20)
+#define IMX6Q_GPR1_MIPI_IPU1_MUX_MASK          BIT(19)
+#define IMX6Q_GPR1_MIPI_IPU1_MUX_GASKET                0x0
+#define IMX6Q_GPR1_MIPI_IPU1_MUX_IOMUX         BIT(19)
 #define IMX6Q_GPR1_PCIE_TEST_PD                        BIT(18)
 #define IMX6Q_GPR1_IPU_VPU_MUX_MASK            BIT(17)
 #define IMX6Q_GPR1_IPU_VPU_MUX_IPU1            0x0
 #define IMX6Q_GPR13_CAN2_STOP_REQ              BIT(29)
 #define IMX6Q_GPR13_CAN1_STOP_REQ              BIT(28)
 #define IMX6Q_GPR13_ENET_STOP_REQ              BIT(27)
-#define IMX6Q_GPR13_SATA_PHY_8_MASK            (0x7 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_0_5_DB          (0x0 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_1_0_DB          (0x1 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_1_5_DB          (0x2 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_2_0_DB          (0x3 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_2_5_DB          (0x4 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_3_0_DB          (0x5 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_3_5_DB          (0x6 << 24)
-#define IMX6Q_GPR13_SATA_PHY_8_4_0_DB          (0x7 << 24)
-#define IMX6Q_GPR13_SATA_PHY_7_MASK            (0x1f << 19)
-#define IMX6Q_GPR13_SATA_PHY_7_SATA1I          (0x10 << 19)
-#define IMX6Q_GPR13_SATA_PHY_7_SATA1M          (0x10 << 19)
-#define IMX6Q_GPR13_SATA_PHY_7_SATA1X          (0x1a << 19)
-#define IMX6Q_GPR13_SATA_PHY_7_SATA2I          (0x12 << 19)
-#define IMX6Q_GPR13_SATA_PHY_7_SATA2M          (0x12 << 19)
-#define IMX6Q_GPR13_SATA_PHY_7_SATA2X          (0x1a << 19)
-#define IMX6Q_GPR13_SATA_PHY_6_MASK            (0x7 << 16)
-#define IMX6Q_GPR13_SATA_SPEED_MASK            BIT(15)
-#define IMX6Q_GPR13_SATA_SPEED_1P5G            0x0
-#define IMX6Q_GPR13_SATA_SPEED_3P0G            BIT(15)
-#define IMX6Q_GPR13_SATA_PHY_5                 BIT(14)
-#define IMX6Q_GPR13_SATA_PHY_4_MASK            (0x7 << 11)
-#define IMX6Q_GPR13_SATA_PHY_4_16_16           (0x0 << 11)
-#define IMX6Q_GPR13_SATA_PHY_4_14_16           (0x1 << 11)
-#define IMX6Q_GPR13_SATA_PHY_4_12_16           (0x2 << 11)
-#define IMX6Q_GPR13_SATA_PHY_4_10_16           (0x3 << 11)
-#define IMX6Q_GPR13_SATA_PHY_4_9_16            (0x4 << 11)
-#define IMX6Q_GPR13_SATA_PHY_4_8_16            (0x5 << 11)
-#define IMX6Q_GPR13_SATA_PHY_3_MASK            (0xf << 7)
-#define IMX6Q_GPR13_SATA_PHY_3_OFF             0x7
-#define IMX6Q_GPR13_SATA_PHY_2_MASK            (0x1f << 2)
-#define IMX6Q_GPR13_SATA_PHY_2_OFF             0x2
-#define IMX6Q_GPR13_SATA_PHY_1_MASK            (0x3 << 0)
-#define IMX6Q_GPR13_SATA_PHY_1_FAST            (0x0 << 0)
-#define IMX6Q_GPR13_SATA_PHY_1_MED             (0x1 << 0)
-#define IMX6Q_GPR13_SATA_PHY_1_SLOW            (0x2 << 0)
-
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK                (0x7 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_0_5_DB      (0x0 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_1_0_DB      (0x1 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_1_5_DB      (0x2 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_2_0_DB      (0x3 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_2_5_DB      (0x4 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB      (0x5 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_3_5_DB      (0x6 << 24)
+#define IMX6Q_GPR13_SATA_RX_EQ_VAL_4_0_DB      (0x7 << 24)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK       (0x1f << 19)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA1I     (0x10 << 19)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA1M     (0x10 << 19)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA1X     (0x1a << 19)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2I     (0x12 << 19)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M     (0x12 << 19)
+#define IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2X     (0x1a << 19)
+#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK     (0x7 << 16)
+#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_1P_1F    (0x0 << 16)
+#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_2F    (0x1 << 16)
+#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_1P_4F    (0x2 << 16)
+#define IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F    (0x3 << 16)
+#define IMX6Q_GPR13_SATA_SPD_MODE_MASK         BIT(15)
+#define IMX6Q_GPR13_SATA_SPD_MODE_1P5G         0x0
+#define IMX6Q_GPR13_SATA_SPD_MODE_3P0G         BIT(15)
+#define IMX6Q_GPR13_SATA_MPLL_SS_EN            BIT(14)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_MASK         (0x7 << 11)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_16_16                (0x0 << 11)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_14_16                (0x1 << 11)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_12_16                (0x2 << 11)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_10_16                (0x3 << 11)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_9_16         (0x4 << 11)
+#define IMX6Q_GPR13_SATA_TX_ATTEN_8_16         (0x5 << 11)
+#define IMX6Q_GPR13_SATA_TX_BOOST_MASK         (0xf << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_0_00_DB      (0x0 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_0_37_DB      (0x1 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_0_74_DB      (0x2 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_1_11_DB      (0x3 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_1_48_DB      (0x4 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_1_85_DB      (0x5 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_2_22_DB      (0x6 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_2_59_DB      (0x7 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_2_96_DB      (0x8 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB      (0x9 << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_3_70_DB      (0xa << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_4_07_DB      (0xb << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_4_44_DB      (0xc << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_4_81_DB      (0xd << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_5_28_DB      (0xe << 7)
+#define IMX6Q_GPR13_SATA_TX_BOOST_5_75_DB      (0xf << 7)
+#define IMX6Q_GPR13_SATA_TX_LVL_MASK           (0x1f << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_937_V                (0x00 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_947_V                (0x01 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_957_V                (0x02 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_966_V                (0x03 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_976_V                (0x04 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_986_V                (0x05 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_0_996_V                (0x06 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_005_V                (0x07 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_015_V                (0x08 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_025_V                (0x09 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_035_V                (0x0a << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_045_V                (0x0b << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_054_V                (0x0c << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_064_V                (0x0d << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_074_V                (0x0e << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_084_V                (0x0f << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_094_V                (0x10 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_104_V                (0x11 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_113_V                (0x12 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_123_V                (0x13 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_133_V                (0x14 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_143_V                (0x15 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_152_V                (0x16 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_162_V                (0x17 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_172_V                (0x18 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_182_V                (0x19 << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_191_V                (0x1a << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_201_V                (0x1b << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_211_V                (0x1c << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_221_V                (0x1d << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_230_V                (0x1e << 2)
+#define IMX6Q_GPR13_SATA_TX_LVL_1_240_V                (0x1f << 2)
+#define IMX6Q_GPR13_SATA_MPLL_CLK_EN           BIT(1)
+#define IMX6Q_GPR13_SATA_TX_EDGE_RATE          BIT(0)
 #endif /* __LINUX_IMX6Q_IOMUXC_GPR_H */
index 8d73fe29796a9bc1ce8687c9e18e6963cc278c62..db1791bb997ae495d65637e506b6f13ab4945b6d 100644 (file)
 #define CNTRLREG_8WIRE         CNTRLREG_AFE_CTRL(3)
 #define CNTRLREG_TSCENB                BIT(7)
 
+/* FIFO READ Register */
+#define FIFOREAD_DATA_MASK (0xfff << 0)
+#define FIFOREAD_CHNLID_MASK (0xf << 16)
+
+/* Sequencer Status */
+#define SEQ_STATUS BIT(5)
+
 #define ADC_CLK                        3000000
 #define        MAX_CLK_DIV             7
 #define TOTAL_STEPS            16
 #define TOTAL_CHANNELS         8
 
+/*
+* ADC runs at 3MHz, and it takes
+* 15 cycles to latch one data output.
+* Hence the idle time for ADC to
+* process one sample data would be
+* around 5 micro seconds.
+*/
+#define IDLE_TIMEOUT 5 /* microsec */
+
 #define TSCADC_CELLS           2
 
 struct ti_tscadc_dev {
index bb1c8096a7eb28a5b9c9c24f37dd4603dc727b98..cd1fdf75103b7bd26350490cffc7de8e054bc366 100644 (file)
@@ -69,6 +69,7 @@ enum {
        MLX4_CMD_SET_ICM_SIZE    = 0xffd,
        /*master notify fw on finish for slave's flr*/
        MLX4_CMD_INFORM_FLR_DONE = 0x5b,
+       MLX4_CMD_GET_OP_REQ      = 0x59,
 
        /* TPT commands */
        MLX4_CMD_SW2HW_MPT       = 0xd,
index 52c23a892bab3cec77af9e8f662fe2ea3d47adfb..09ef2f448a001f6771852f87215437b1e0561fa7 100644 (file)
@@ -33,6 +33,7 @@
 #ifndef MLX4_DEVICE_H
 #define MLX4_DEVICE_H
 
+#include <linux/if_ether.h>
 #include <linux/pci.h>
 #include <linux/completion.h>
 #include <linux/radix-tree.h>
@@ -207,6 +208,7 @@ enum mlx4_event {
        MLX4_EVENT_TYPE_CMD                = 0x0a,
        MLX4_EVENT_TYPE_VEP_UPDATE         = 0x19,
        MLX4_EVENT_TYPE_COMM_CHANNEL       = 0x18,
+       MLX4_EVENT_TYPE_OP_REQUIRED        = 0x1a,
        MLX4_EVENT_TYPE_FATAL_WARNING      = 0x1b,
        MLX4_EVENT_TYPE_FLR_EVENT          = 0x1c,
        MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT = 0x1d,
@@ -619,7 +621,7 @@ struct mlx4_eth_av {
        u8              dgid[16];
        u32             reserved4[2];
        __be16          vlan;
-       u8              mac[6];
+       u8              mac[ETH_ALEN];
 };
 
 union mlx4_ext_av {
@@ -913,10 +915,10 @@ enum mlx4_net_trans_promisc_mode {
 };
 
 struct mlx4_spec_eth {
-       u8      dst_mac[6];
-       u8      dst_mac_msk[6];
-       u8      src_mac[6];
-       u8      src_mac_msk[6];
+       u8      dst_mac[ETH_ALEN];
+       u8      dst_mac_msk[ETH_ALEN];
+       u8      src_mac[ETH_ALEN];
+       u8      src_mac_msk[ETH_ALEN];
        u8      ether_type_enable;
        __be16  ether_type;
        __be16  vlan_id_msk;
index 262deac02c9ea87cdf5e3dea5cc64fc15bdd6e08..6d351473c29200526a98bbbf275b479f79cfa146 100644 (file)
@@ -34,6 +34,7 @@
 #define MLX4_QP_H
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
 
 #include <linux/mlx4/device.h>
 
@@ -143,7 +144,7 @@ struct mlx4_qp_path {
        u8                      feup;
        u8                      fvl_rx;
        u8                      reserved4[2];
-       u8                      dmac[6];
+       u8                      dmac[ETH_ALEN];
 };
 
 enum { /* fl */
@@ -318,7 +319,7 @@ struct mlx4_wqe_datagram_seg {
        __be32                  dqpn;
        __be32                  qkey;
        __be16                  vlan;
-       u8                      mac[6];
+       u8                      mac[ETH_ALEN];
 };
 
 struct mlx4_wqe_lso_seg {
index 8de8d8f22384b9abcd83ce0f76898c7afdf7ded9..68029b30c3dc89e2d2620fd41101b2ab05069344 100644 (file)
@@ -309,21 +309,20 @@ struct mlx5_hca_cap {
        __be16  max_desc_sz_rq;
        u8      rsvd21[2];
        __be16  max_desc_sz_sq_dc;
-       u8      rsvd22[4];
-       __be16  max_qp_mcg;
-       u8      rsvd23;
+       __be32  max_qp_mcg;
+       u8      rsvd22[3];
        u8      log_max_mcg;
-       u8      rsvd24;
+       u8      rsvd23;
        u8      log_max_pd;
-       u8      rsvd25;
+       u8      rsvd24;
        u8      log_max_xrcd;
-       u8      rsvd26[42];
+       u8      rsvd25[42];
        __be16  log_uar_page_sz;
-       u8      rsvd27[28];
+       u8      rsvd26[28];
        u8      log_msx_atomic_size_qp;
-       u8      rsvd28[2];
+       u8      rsvd27[2];
        u8      log_msx_atomic_size_dc;
-       u8      rsvd29[76];
+       u8      rsvd28[76];
 };
 
 
@@ -472,9 +471,8 @@ struct mlx5_eqe_cmd {
 struct mlx5_eqe_page_req {
        u8              rsvd0[2];
        __be16          func_id;
-       u8              rsvd1[2];
-       __be16          num_pages;
-       __be32          rsvd2[5];
+       __be32          num_pages;
+       __be32          rsvd1[5];
 };
 
 union ev_data {
@@ -690,6 +688,26 @@ struct mlx5_query_cq_mbox_out {
        __be64                  pas[0];
 };
 
+struct mlx5_enable_hca_mbox_in {
+       struct mlx5_inbox_hdr   hdr;
+       u8                      rsvd[8];
+};
+
+struct mlx5_enable_hca_mbox_out {
+       struct mlx5_outbox_hdr  hdr;
+       u8                      rsvd[8];
+};
+
+struct mlx5_disable_hca_mbox_in {
+       struct mlx5_inbox_hdr   hdr;
+       u8                      rsvd[8];
+};
+
+struct mlx5_disable_hca_mbox_out {
+       struct mlx5_outbox_hdr  hdr;
+       u8                      rsvd[8];
+};
+
 struct mlx5_eq_context {
        u8                      status;
        u8                      ec_oi;
index f22e4419839b372b9cf6b6535b27cacf721ba9fc..8888381fc150b8f3f852077407ee8187a54cb7aa 100644 (file)
@@ -101,6 +101,8 @@ enum {
        MLX5_CMD_OP_QUERY_ADAPTER               = 0x101,
        MLX5_CMD_OP_INIT_HCA                    = 0x102,
        MLX5_CMD_OP_TEARDOWN_HCA                = 0x103,
+       MLX5_CMD_OP_ENABLE_HCA                  = 0x104,
+       MLX5_CMD_OP_DISABLE_HCA                 = 0x105,
        MLX5_CMD_OP_QUERY_PAGES                 = 0x107,
        MLX5_CMD_OP_MANAGE_PAGES                = 0x108,
        MLX5_CMD_OP_SET_HCA_CAP                 = 0x109,
@@ -356,7 +358,7 @@ struct mlx5_caps {
        u32     reserved_lkey;
        u8      local_ca_ack_delay;
        u8      log_max_mcg;
-       u16     max_qp_mcg;
+       u32     max_qp_mcg;
        int     min_page_sz;
 };
 
@@ -689,8 +691,8 @@ void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
 int mlx5_pagealloc_start(struct mlx5_core_dev *dev);
 void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
 void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
-                                s16 npages);
-int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev);
+                                s32 npages);
+int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
 int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
 void mlx5_register_debugfs(void);
 void mlx5_unregister_debugfs(void);
@@ -729,9 +731,6 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
 int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db);
 void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db);
 
-typedef void (*health_handler_t)(struct pci_dev *pdev, struct health_buffer __iomem *buf, int size);
-int mlx5_register_health_report_handler(health_handler_t handler);
-void mlx5_unregister_health_report_handler(void);
 const char *mlx5_command_str(int command);
 int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev);
 void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
index fb425aa16c0149fdf35b9fe6a1be3a56577d3ff7..faf4b7c1ad12702db919bd03a448741b7e579789 100644 (file)
@@ -332,6 +332,7 @@ struct mm_struct {
                                unsigned long pgoff, unsigned long flags);
 #endif
        unsigned long mmap_base;                /* base of mmap area */
+       unsigned long mmap_legacy_base;         /* base of mmap area in bottom-up allocations */
        unsigned long task_size;                /* size of task vm space */
        unsigned long highest_vm_end;           /* highest vma end address */
        pgd_t * pgd;
index 6e8215b159982378847cc7aacd75747da9c604d6..61a0da38d0cbc163e88b46e0b0fdf0fb50c62934 100644 (file)
@@ -6,6 +6,7 @@
 #define __LINUX_MV643XX_ETH_H
 
 #include <linux/mbus.h>
+#include <linux/if_ether.h>
 
 #define MV643XX_ETH_SHARED_NAME                "mv643xx_eth"
 #define MV643XX_ETH_NAME               "mv643xx_eth_port"
@@ -48,7 +49,7 @@ struct mv643xx_eth_platform_data {
         * Use this MAC address if it is valid, overriding the
         * address that is already in the hardware.
         */
-       u8                      mac_addr[6];
+       u8                      mac_addr[ETH_ALEN];
 
        /*
         * If speed is 0, autonegotiation is enabled.
index 0741a1e919a542c53e50003560d01ed06322e658..077363dcd860702b67003c1721badf92d187e020 100644 (file)
@@ -728,6 +728,16 @@ struct netdev_fcoe_hbainfo {
 };
 #endif
 
+#define MAX_PHYS_PORT_ID_LEN 32
+
+/* This structure holds a unique identifier to identify the
+ * physical port used by a netdevice.
+ */
+struct netdev_phys_port_id {
+       unsigned char id[MAX_PHYS_PORT_ID_LEN];
+       unsigned char id_len;
+};
+
 /*
  * This structure defines the management hooks for network devices.
  * The following hooks can be defined; unless noted otherwise, they are
@@ -932,6 +942,12 @@ struct netdev_fcoe_hbainfo {
  *     that determine carrier state from physical hardware properties (eg
  *     network cables) or protocol-dependent mechanisms (eg
  *     USB_CDC_NOTIFY_NETWORK_CONNECTION) should NOT implement this function.
+ *
+ * int (*ndo_get_phys_port_id)(struct net_device *dev,
+ *                            struct netdev_phys_port_id *ppid);
+ *     Called to get ID of physical port of this device. If driver does
+ *     not implement this, it is assumed that the hw is not able to have
+ *     multiple net devices on single physical port.
  */
 struct net_device_ops {
        int                     (*ndo_init)(struct net_device *dev);
@@ -973,7 +989,7 @@ struct net_device_ops {
                                                     gfp_t gfp);
        void                    (*ndo_netpoll_cleanup)(struct net_device *dev);
 #endif
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        int                     (*ndo_busy_poll)(struct napi_struct *dev);
 #endif
        int                     (*ndo_set_vf_mac)(struct net_device *dev,
@@ -1060,6 +1076,8 @@ struct net_device_ops {
                                                      struct nlmsghdr *nlh);
        int                     (*ndo_change_carrier)(struct net_device *dev,
                                                      bool new_carrier);
+       int                     (*ndo_get_phys_port_id)(struct net_device *dev,
+                                                       struct netdev_phys_port_id *ppid);
 };
 
 /*
@@ -1633,6 +1651,7 @@ struct packet_offload {
 #define NETDEV_NOTIFY_PEERS    0x0013
 #define NETDEV_JOIN            0x0014
 #define NETDEV_CHANGEUPPER     0x0015
+#define NETDEV_RESEND_IGMP     0x0016
 
 extern int register_netdevice_notifier(struct notifier_block *nb);
 extern int unregister_netdevice_notifier(struct notifier_block *nb);
@@ -1665,9 +1684,6 @@ extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
 
 extern rwlock_t                                dev_base_lock;          /* Device list lock */
 
-extern seqcount_t      devnet_rename_seq;      /* Device rename seq */
-
-
 #define for_each_netdev(net, d)                \
                list_for_each_entry(d, &(net)->dev_base_head, dev_list)
 #define for_each_netdev_reverse(net, d)        \
@@ -2317,6 +2333,8 @@ extern int                dev_set_mac_address(struct net_device *,
                                            struct sockaddr *);
 extern int             dev_change_carrier(struct net_device *,
                                           bool new_carrier);
+extern int             dev_get_phys_port_id(struct net_device *dev,
+                                            struct netdev_phys_port_id *ppid);
 extern int             dev_hard_start_xmit(struct sk_buff *skb,
                                            struct net_device *dev,
                                            struct netdev_queue *txq);
index de70f7b45b682126284a4162535659bfde8e5be1..708fe72ab913ba71e5421b080d0c9a8c90c7a3d9 100644 (file)
@@ -314,25 +314,24 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
 #endif /*CONFIG_NETFILTER*/
 
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
-extern void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *) __rcu;
-extern void nf_ct_attach(struct sk_buff *, struct sk_buff *);
+extern void (*ip_ct_attach)(struct sk_buff *, const struct sk_buff *) __rcu;
+extern void nf_ct_attach(struct sk_buff *, const struct sk_buff *);
 extern void (*nf_ct_destroy)(struct nf_conntrack *) __rcu;
 
 struct nf_conn;
+enum ip_conntrack_info;
 struct nlattr;
 
 struct nfq_ct_hook {
        size_t (*build_size)(const struct nf_conn *ct);
        int (*build)(struct sk_buff *skb, struct nf_conn *ct);
        int (*parse)(const struct nlattr *attr, struct nf_conn *ct);
-};
-extern struct nfq_ct_hook __rcu *nfq_ct_hook;
-
-struct nfq_ct_nat_hook {
+       int (*attach_expect)(const struct nlattr *attr, struct nf_conn *ct,
+                            u32 portid, u32 report);
        void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
-                          u32 ctinfo, int off);
+                          enum ip_conntrack_info ctinfo, s32 off);
 };
-extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook;
+extern struct nfq_ct_hook __rcu *nfq_ct_hook;
 #else
 static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
 #endif
diff --git a/include/linux/netfilter/xt_HMARK.h b/include/linux/netfilter/xt_HMARK.h
deleted file mode 100644 (file)
index 826fc58..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef XT_HMARK_H_
-#define XT_HMARK_H_
-
-#include <linux/types.h>
-
-enum {
-       XT_HMARK_SADDR_MASK,
-       XT_HMARK_DADDR_MASK,
-       XT_HMARK_SPI,
-       XT_HMARK_SPI_MASK,
-       XT_HMARK_SPORT,
-       XT_HMARK_DPORT,
-       XT_HMARK_SPORT_MASK,
-       XT_HMARK_DPORT_MASK,
-       XT_HMARK_PROTO_MASK,
-       XT_HMARK_RND,
-       XT_HMARK_MODULUS,
-       XT_HMARK_OFFSET,
-       XT_HMARK_CT,
-       XT_HMARK_METHOD_L3,
-       XT_HMARK_METHOD_L3_4,
-};
-#define XT_HMARK_FLAG(flag)    (1 << flag)
-
-union hmark_ports {
-       struct {
-               __u16   src;
-               __u16   dst;
-       } p16;
-       struct {
-               __be16  src;
-               __be16  dst;
-       } b16;
-       __u32   v32;
-       __be32  b32;
-};
-
-struct xt_hmark_info {
-       union nf_inet_addr      src_mask;
-       union nf_inet_addr      dst_mask;
-       union hmark_ports       port_mask;
-       union hmark_ports       port_set;
-       __u32                   flags;
-       __u16                   proto_mask;
-       __u32                   hashrnd;
-       __u32                   hmodulus;
-       __u32                   hoffset;        /* Mark offset to start from */
-};
-
-#endif /* XT_HMARK_H_ */
diff --git a/include/linux/netfilter/xt_rpfilter.h b/include/linux/netfilter/xt_rpfilter.h
deleted file mode 100644 (file)
index 8358d4f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _XT_RPATH_H
-#define _XT_RPATH_H
-
-#include <linux/types.h>
-
-enum {
-       XT_RPFILTER_LOOSE = 1 << 0,
-       XT_RPFILTER_VALID_MARK = 1 << 1,
-       XT_RPFILTER_ACCEPT_LOCAL = 1 << 2,
-       XT_RPFILTER_INVERT = 1 << 3,
-#ifdef __KERNEL__
-       XT_RPFILTER_OPTION_MASK = XT_RPFILTER_LOOSE |
-                                 XT_RPFILTER_VALID_MARK |
-                                 XT_RPFILTER_ACCEPT_LOCAL |
-                                 XT_RPFILTER_INVERT,
-#endif
-};
-
-struct xt_rpfilter_info {
-       __u8 flags;
-};
-
-#endif
index 0fd1f1582fa1cdf359b33f3cddeaa60026f492ac..2edbee64aeba5aeaecd5012f33202be4d929b166 100644 (file)
@@ -183,6 +183,19 @@ enum pci_bus_flags {
        PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
 };
 
+/* These values come from the PCI Express Spec */
+enum pcie_link_width {
+       PCIE_LNK_WIDTH_RESRV    = 0x00,
+       PCIE_LNK_X1             = 0x01,
+       PCIE_LNK_X2             = 0x02,
+       PCIE_LNK_X4             = 0x04,
+       PCIE_LNK_X8             = 0x08,
+       PCIE_LNK_X12            = 0x0C,
+       PCIE_LNK_X16            = 0x10,
+       PCIE_LNK_X32            = 0x20,
+       PCIE_LNK_WIDTH_UNKNOWN  = 0xFF,
+};
+
 /* Based on the PCI Hotplug Spec, but some values are made up by us */
 enum pci_bus_speed {
        PCI_SPEED_33MHz                 = 0x00,
@@ -921,6 +934,8 @@ int pcie_get_readrq(struct pci_dev *dev);
 int pcie_set_readrq(struct pci_dev *dev, int rq);
 int pcie_get_mps(struct pci_dev *dev);
 int pcie_set_mps(struct pci_dev *dev, int mps);
+int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
+                         enum pcie_link_width *width);
 int __pci_reset_function(struct pci_dev *dev);
 int __pci_reset_function_locked(struct pci_dev *dev);
 int pci_reset_function(struct pci_dev *dev);
index 8db71dcd633740a8a7290aff4a99f6a23ee8e366..64e61e05d9a03452c217e27f79573dea4d4afd48 100644 (file)
 #ifndef _PCI_HOTPLUG_H
 #define _PCI_HOTPLUG_H
 
-/* These values come from the PCI Express Spec */
-enum pcie_link_width {
-       PCIE_LNK_WIDTH_RESRV    = 0x00,
-       PCIE_LNK_X1             = 0x01,
-       PCIE_LNK_X2             = 0x02,
-       PCIE_LNK_X4             = 0x04,
-       PCIE_LNK_X8             = 0x08,
-       PCIE_LNK_X12            = 0x0C,
-       PCIE_LNK_X16            = 0x10,
-       PCIE_LNK_X32            = 0x20,
-       PCIE_LNK_WIDTH_UNKNOWN  = 0xFF,
-};
-
 /**
  * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
  * @owner: The module owner of this structure
index 8873f82c7baa2bd1ae165966471fd8cad5f0d57b..c43f6eabad5bd97915d0e43926e31c4500739104 100644 (file)
@@ -826,7 +826,7 @@ static inline void perf_restore_debug_store(void)                   { }
  */
 #define perf_cpu_notifier(fn)                                          \
 do {                                                                   \
-       static struct notifier_block fn##_nb __cpuinitdata =            \
+       static struct notifier_block fn##_nb =                          \
                { .notifier_call = fn, .priority = CPU_PRI_PERF };      \
        unsigned long cpu = smp_processor_id();                         \
        unsigned long flags;                                            \
diff --git a/include/linux/platform_data/cpsw.h b/include/linux/platform_data/cpsw.h
deleted file mode 100644 (file)
index bb3cd58..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Texas Instruments Ethernet Switch Driver
- *
- * Copyright (C) 2012 Texas Instruments
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-#ifndef __CPSW_H__
-#define __CPSW_H__
-
-#include <linux/if_ether.h>
-
-struct cpsw_slave_data {
-       char            phy_id[MII_BUS_ID_SIZE];
-       int             phy_if;
-       u8              mac_addr[ETH_ALEN];
-       u16             dual_emac_res_vlan;     /* Reserved VLAN for DualEMAC */
-
-};
-
-struct cpsw_platform_data {
-       u32     ss_reg_ofs;     /* Subsystem control register offset */
-       u32     channels;       /* number of cpdma channels (symmetric) */
-       u32     slaves;         /* number of slave cpgmac ports */
-       struct cpsw_slave_data  *slave_data;
-       u32     active_slave; /* time stamping, ethtool and SIOCGMIIPHY slave */
-       u32     cpts_clock_mult;  /* convert input clock ticks to nanoseconds */
-       u32     cpts_clock_shift; /* convert input clock ticks to nanoseconds */
-       u32     ale_entries;    /* ale table size */
-       u32     bd_ram_size;  /*buffer descriptor ram size */
-       u32     rx_descs;       /* Number of Rx Descriptios */
-       u32     mac_control;    /* Mac control register */
-       u16     default_vlan;   /* Def VLAN for ALE lookup in VLAN aware mode*/
-       bool    dual_emac;      /* Enable Dual EMAC mode */
-};
-
-#endif /* __CPSW_H__ */
index 9eb515bb799d071bdad4c342fa61b00e32072588..1706b3597ce00c10776d8c8fbf8e0c6067afcb6a 100644 (file)
@@ -12,7 +12,7 @@ struct pxamci_platform_data {
        unsigned long detect_delay_ms;          /* delay in millisecond before detecting cards after interrupt */
        int (*init)(struct device *, irq_handler_t , void *);
        int (*get_ro)(struct device *);
-       void (*setpower)(struct device *, unsigned int);
+       int (*setpower)(struct device *, unsigned int);
        void (*exit)(struct device *, void *);
        int gpio_card_detect;                   /* gpio detecting card insertion */
        int gpio_card_ro;                       /* gpio detecting read only toggle */
index 569781faa5042a7930e082a74985bceac6f89786..a0f70808d7f48432967c60a8a0d686ab077d08e8 100644 (file)
@@ -36,8 +36,8 @@
  * @last_time: Monotonic clock when the wakeup source's was touched last time.
  * @prevent_sleep_time: Total time this source has been preventing autosleep.
  * @event_count: Number of signaled wakeup events.
- * @active_count: Number of times the wakeup sorce was activated.
- * @relax_count: Number of times the wakeup sorce was deactivated.
+ * @active_count: Number of times the wakeup source was activated.
+ * @relax_count: Number of times the wakeup source was deactivated.
  * @expire_count: Number of times the wakeup source's timeout has expired.
  * @wakeup_count: Number of times the wakeup source might abort suspend.
  * @active: Status of the wakeup source.
index 75981d0b57dccd4b6a3b5e9833557973f33d9404..580a5320cc96afd21807cddaaa40bdff47694d5d 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/list.h>
 #include <linux/rbtree.h>
+#include <linux/err.h>
 
 struct module;
 struct device;
index 50d04b92cedaf900532f72d1acef35d04d7ecb69..078066daffd486d426027e9c97c3a40b8202e950 100644 (file)
@@ -1532,6 +1532,8 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
  * Test if a process is not yet dead (at most zombie state)
  * If pid_alive fails, then pointers within the task structure
  * can be stale and must not be dereferenced.
+ *
+ * Return: 1 if the process is alive. 0 otherwise.
  */
 static inline int pid_alive(struct task_struct *p)
 {
@@ -1543,6 +1545,8 @@ static inline int pid_alive(struct task_struct *p)
  * @tsk: Task structure to be checked.
  *
  * Check if a task structure is the first user space task the kernel created.
+ *
+ * Return: 1 if the task structure is init. 0 otherwise.
  */
 static inline int is_global_init(struct task_struct *tsk)
 {
@@ -1628,6 +1632,7 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
 #define PF_MEMPOLICY   0x10000000      /* Non-default NUMA mempolicy */
 #define PF_MUTEX_TESTER        0x20000000      /* Thread belongs to the rt mutex tester */
 #define PF_FREEZER_SKIP        0x40000000      /* Freezer should not count it as freezable */
+#define PF_SUSPEND_TASK 0x80000000      /* this thread called freeze_processes and should not be frozen */
 
 /*
  * Only the _current_ task can read/write to tsk->flags, but other
@@ -1893,6 +1898,8 @@ extern struct task_struct *idle_task(int cpu);
 /**
  * is_idle_task - is the specified task an idle task?
  * @p: the task in question.
+ *
+ * Return: 1 if @p is an idle task. 0 otherwise.
  */
 static inline bool is_idle_task(const struct task_struct *p)
 {
index fc305713fc6d4e09d05ef30dd1be1ce24407cfd4..90b5e30c2f222ba8e06deb9d347940bf7d5aa94b 100644 (file)
@@ -2,23 +2,17 @@
 #define __ASM_SH_ETH_H__
 
 #include <linux/phy.h>
+#include <linux/if_ether.h>
 
 enum {EDMAC_LITTLE_ENDIAN, EDMAC_BIG_ENDIAN};
-enum {
-       SH_ETH_REG_GIGABIT,
-       SH_ETH_REG_FAST_RCAR,
-       SH_ETH_REG_FAST_SH4,
-       SH_ETH_REG_FAST_SH3_SH2
-};
 
 struct sh_eth_plat_data {
        int phy;
        int edmac_endian;
-       int register_type;
        phy_interface_t phy_interface;
        void (*set_mdio_gate)(void *addr);
 
-       unsigned char mac_addr[6];
+       unsigned char mac_addr[ETH_ALEN];
        unsigned no_ether_link:1;
        unsigned ether_link_active_low:1;
        unsigned needs_init:1;
index 382cf710ca9aa11b001d874efa516e229f5b8254..5b1c9848124cb8c366f95a0dbfaa6d54d64d1927 100644 (file)
@@ -124,6 +124,10 @@ void shdma_chan_remove(struct shdma_chan *schan);
 int shdma_init(struct device *dev, struct shdma_dev *sdev,
                    int chan_num);
 void shdma_cleanup(struct shdma_dev *sdev);
+#if IS_ENABLED(CONFIG_SH_DMAE_BASE)
 bool shdma_chan_filter(struct dma_chan *chan, void *arg);
+#else
+#define shdma_chan_filter NULL
+#endif
 
 #endif
index 5afefa01a13c892e1fe9eb7ce6fc3f047e5880ba..5ac96f31d546609403768ea462e88f3e2a02b8dd 100644 (file)
@@ -501,7 +501,7 @@ struct sk_buff {
        /* 7/9 bit hole (depending on ndisc_nodetype presence) */
        kmemcheck_bitfield_end(flags2);
 
-#if defined CONFIG_NET_DMA || defined CONFIG_NET_LL_RX_POLL
+#if defined CONFIG_NET_DMA || defined CONFIG_NET_RX_BUSY_POLL
        union {
                unsigned int    napi_id;
                dma_cookie_t    dma_cookie;
@@ -1805,10 +1805,13 @@ static inline void pskb_trim_unique(struct sk_buff *skb, unsigned int len)
  */
 static inline void skb_orphan(struct sk_buff *skb)
 {
-       if (skb->destructor)
+       if (skb->destructor) {
                skb->destructor(skb);
-       skb->destructor = NULL;
-       skb->sk         = NULL;
+               skb->destructor = NULL;
+               skb->sk         = NULL;
+       } else {
+               BUG_ON(skb->sk);
+       }
 }
 
 /**
@@ -2356,6 +2359,10 @@ extern int              skb_copy_datagram_from_iovec(struct sk_buff *skb,
                                                    const struct iovec *from,
                                                    int from_offset,
                                                    int len);
+extern int            zerocopy_sg_from_iovec(struct sk_buff *skb,
+                                             const struct iovec *frm,
+                                             int offset,
+                                             size_t count);
 extern int            skb_copy_datagram_const_iovec(const struct sk_buff *from,
                                                     int offset,
                                                     const struct iovec *to,
index 4dde70e74822be5d13198a15c0816978f3ff4b2a..eec3efd19beb0b8fb059acd97939f0efba09d7fb 100644 (file)
@@ -22,6 +22,7 @@
 #define __LINUX_SMSC911X_H__
 
 #include <linux/phy.h>
+#include <linux/if_ether.h>
 
 /* platform_device configuration data, should be assigned to
  * the platform_device's dev.platform_data */
@@ -31,7 +32,7 @@ struct smsc911x_platform_config {
        unsigned int flags;
        unsigned int shift;
        phy_interface_t phy_interface;
-       unsigned char mac[6];
+       unsigned char mac[ETH_ALEN];
 };
 
 /* Constants for platform_device irq polarity configuration */
index 230c04bda3e2da37e2c8ce387b3ef0e8c0a36118..445ef7519dc28625e7cb19dd698c1918f36b90bf 100644 (file)
@@ -313,6 +313,8 @@ extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
                                          struct iovec *iov, 
                                          int offset, 
                                          unsigned int len, __wsum *csump);
+extern unsigned long iov_pages(const struct iovec *iov, int offset,
+                              unsigned long nr_segs);
 
 extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *address, int mode);
 extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
index 7d537ced949aa83b33b4c20e32c991d2123ca5a5..75f34949d9ab998adf5941c0321ea45005cc7d62 100644 (file)
@@ -117,9 +117,17 @@ do {                                                               \
 #endif /*arch_spin_is_contended*/
 #endif
 
-/* The lock does not imply full memory barrier. */
-#ifndef ARCH_HAS_SMP_MB_AFTER_LOCK
-static inline void smp_mb__after_lock(void) { smp_mb(); }
+/*
+ * Despite its name it doesn't necessarily has to be a full barrier.
+ * It should only guarantee that a STORE before the critical section
+ * can not be reordered with a LOAD inside this section.
+ * spin_lock() is the one-way barrier, this LOAD can not escape out
+ * of the region. So the default implementation simply ensures that
+ * a STORE can not move into the critical section, smp_wmb() should
+ * serialize it with another STORE done by spin_lock().
+ */
+#ifndef smp_mb__before_spinlock
+#define smp_mb__before_spinlock()      smp_wmb()
 #endif
 
 /**
index 6d870353674ac274a3f27e0f454749f7e5c18485..1821445708d62d81bb1176ecb20f8480fa4799fa 100644 (file)
@@ -121,6 +121,7 @@ struct rpc_task_setup {
 #define RPC_TASK_SOFTCONN      0x0400          /* Fail if can't connect */
 #define RPC_TASK_SENT          0x0800          /* message was sent */
 #define RPC_TASK_TIMEOUT       0x1000          /* fail with ETIMEDOUT on timeout */
+#define RPC_TASK_NOCONNECT     0x2000          /* return ENOTCONN if not connected */
 
 #define RPC_IS_ASYNC(t)                ((t)->tk_flags & RPC_TASK_ASYNC)
 #define RPC_IS_SWAPPER(t)      ((t)->tk_flags & RPC_TASK_SWAPPER)
index c5fd30d2a415a48964eb1fb2aaaac0db255656e1..8d4fa82bfb913d0021d93c49e71dab940804fdf7 100644 (file)
@@ -67,6 +67,8 @@ static inline swp_entry_t pte_to_swp_entry(pte_t pte)
        swp_entry_t arch_entry;
 
        BUG_ON(pte_file(pte));
+       if (pte_swp_soft_dirty(pte))
+               pte = pte_swp_clear_soft_dirty(pte);
        arch_entry = __pte_to_swp_entry(pte);
        return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
 }
index 4147d700a293623b63615b987c797f14d380a7a1..84662ecc7b51468233175959ddd5c04bd0efac0d 100644 (file)
@@ -802,9 +802,14 @@ asmlinkage long sys_vfork(void);
 asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, int,
               int __user *);
 #else
+#ifdef CONFIG_CLONE_BACKWARDS3
+asmlinkage long sys_clone(unsigned long, unsigned long, int, int __user *,
+                         int __user *, int);
+#else
 asmlinkage long sys_clone(unsigned long, unsigned long, int __user *,
               int __user *, int);
 #endif
+#endif
 
 asmlinkage long sys_execve(const char __user *filename,
                const char __user *const __user *argv,
index e2cee22f578a6b24d7eb39c1ad298f15115bcb2d..9e8a9b555ad6ac31eb37a2fe83416399be95c826 100644 (file)
 #include <linux/list.h>
 #include <linux/lockdep.h>
 #include <linux/kobject_ns.h>
+#include <linux/stat.h>
 #include <linux/atomic.h>
 
 struct kobject;
 struct module;
+struct bin_attribute;
 enum kobj_ns_type;
 
 struct attribute {
@@ -59,26 +61,28 @@ struct attribute_group {
        umode_t                 (*is_visible)(struct kobject *,
                                              struct attribute *, int);
        struct attribute        **attrs;
+       struct bin_attribute    **bin_attrs;
 };
 
-
-
 /**
  * Use these macros to make defining attributes easier. See include/linux/device.h
  * for examples..
  */
 
-#define __ATTR(_name,_mode,_show,_store) { \
-       .attr = {.name = __stringify(_name), .mode = _mode },   \
-       .show   = _show,                                        \
-       .store  = _store,                                       \
+#define __ATTR(_name,_mode,_show,_store) {                             \
+       .attr = {.name = __stringify(_name), .mode = _mode },           \
+       .show   = _show,                                                \
+       .store  = _store,                                               \
 }
 
-#define __ATTR_RO(_name) { \
-       .attr   = { .name = __stringify(_name), .mode = 0444 }, \
-       .show   = _name##_show,                                 \
+#define __ATTR_RO(_name) {                                             \
+       .attr   = { .name = __stringify(_name), .mode = S_IRUGO },      \
+       .show   = _name##_show,                                         \
 }
 
+#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO),            \
+                        _name##_show, _name##_store)
+
 #define __ATTR_NULL { .attr = { .name = NULL } }
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -92,6 +96,18 @@ struct attribute_group {
 #define __ATTR_IGNORE_LOCKDEP  __ATTR
 #endif
 
+#define __ATTRIBUTE_GROUPS(_name)                              \
+static const struct attribute_group *_name##_groups[] = {      \
+       &_name##_group,                                         \
+       NULL,                                                   \
+}
+
+#define ATTRIBUTE_GROUPS(_name)                                        \
+static const struct attribute_group _name##_group = {          \
+       .attrs = _name##_attrs,                                 \
+};                                                             \
+__ATTRIBUTE_GROUPS(_name)
+
 #define attr_name(_attr) (_attr).attr.name
 
 struct file;
@@ -121,6 +137,36 @@ struct bin_attribute {
  */
 #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
 
+/* macros to create static binary attributes easier */
+#define __BIN_ATTR(_name, _mode, _read, _write, _size) {               \
+       .attr = { .name = __stringify(_name), .mode = _mode },          \
+       .read   = _read,                                                \
+       .write  = _write,                                               \
+       .size   = _size,                                                \
+}
+
+#define __BIN_ATTR_RO(_name, _size) {                                  \
+       .attr   = { .name = __stringify(_name), .mode = S_IRUGO },      \
+       .read   = _name##_read,                                         \
+       .size   = _size,                                                \
+}
+
+#define __BIN_ATTR_RW(_name, _size) __BIN_ATTR(_name,                  \
+                                  (S_IWUSR | S_IRUGO), _name##_read,   \
+                                  _name##_write)
+
+#define __BIN_ATTR_NULL __ATTR_NULL
+
+#define BIN_ATTR(_name, _mode, _read, _write, _size)                   \
+struct bin_attribute bin_attr_##_name = __BIN_ATTR(_name, _mode, _read,        \
+                                       _write, _size)
+
+#define BIN_ATTR_RO(_name, _size)                                      \
+struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
+
+#define BIN_ATTR_RW(_name, _size)                                      \
+struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
+
 struct sysfs_ops {
        ssize_t (*show)(struct kobject *, struct attribute *,char *);
        ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
index 472120b4fac57584f30998d1be87c672607eb643..d68633452d9b070ce12056e5a17dc40f1f148c4d 100644 (file)
@@ -107,7 +107,6 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
  * only four options will fit in a standard TCP header */
 #define TCP_NUM_SACKS 4
 
-struct tcp_cookie_values;
 struct tcp_request_sock_ops;
 
 struct tcp_request_sock {
@@ -238,6 +237,7 @@ struct tcp_sock {
 
        u32     rcv_wnd;        /* Current receiver window              */
        u32     write_seq;      /* Tail(+1) of data held in tcp send buffer */
+       u32     notsent_lowat;  /* TCP_NOTSENT_LOWAT */
        u32     pushed_seq;     /* Last pushed seq, required to talk to windows */
        u32     lost_out;       /* Lost packets                 */
        u32     sacked_out;     /* SACK'd packets                       */
index 9180f4b85e6deedd827fa071add91940c3ac48e5..62bd8b72873c0bed1702d41a2a8982831d01564b 100644 (file)
@@ -174,10 +174,4 @@ static inline void tick_nohz_task_switch(struct task_struct *tsk) { }
 #endif
 
 
-# ifdef CONFIG_CPU_IDLE_GOV_MENU
-extern void menu_hrtimer_cancel(void);
-# else
-static inline void menu_hrtimer_cancel(void) {}
-# endif /* CONFIG_CPU_IDLE_GOV_MENU */
-
 #endif
index a232b7ece1f63c687a2f50da506c9e70ec33555e..0eec2689b9556bee0c3aae530a3035ccbbe29d2a 100644 (file)
@@ -367,17 +367,6 @@ struct usb_bus {
 
 /* ----------------------------------------------------------------------- */
 
-/* This is arbitrary.
- * From USB 2.0 spec Table 11-13, offset 7, a hub can
- * have up to 255 ports. The most yet reported is 10.
- *
- * Current Wireless USB host hardware (Intel i1480 for example) allows
- * up to 22 devices to connect. Upcoming hardware might raise that
- * limit. Because the arrays need to add a bit for hub status data, we
- * do 31, so plus one evens out to four bytes.
- */
-#define USB_MAXCHILDREN                (31)
-
 struct usb_tt;
 
 enum usb_device_removable {
index f18d64129f99982f966f3c2fe733cd85260dc625..8fbc008e183e33704ddbc0f8cc63c3cd69b5f753 100644 (file)
@@ -34,6 +34,7 @@ struct usbnet {
        struct mutex            phy_mutex;
        unsigned char           suspend_count;
        unsigned char           pkt_cnt, pkt_err;
+       unsigned short          rx_qlen, tx_qlen;
 
        /* i/o info: pipes etc */
        unsigned                in, out;
@@ -253,4 +254,6 @@ extern void usbnet_link_change(struct usbnet *, bool, bool);
 extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags);
 extern void usbnet_status_stop(struct usbnet *dev);
 
+extern void usbnet_update_max_qlen(struct usbnet *dev);
+
 #endif /* __LINUX_USB_USBNET_H */
index b6b215f13b453091ff2be0fae11b37a5a51c0c84..14105c26a83618da5d91ae09331fb83ba8f8ad6b 100644 (file)
@@ -23,6 +23,7 @@ struct user_namespace {
        struct uid_gid_map      projid_map;
        atomic_t                count;
        struct user_namespace   *parent;
+       int                     level;
        kuid_t                  owner;
        kgid_t                  group;
        unsigned int            proc_inum;
index b52e44f1bd33039b6317e6702212138275db2c45..0df24bfcdb3891408556253a5602cf0d9ddb0ffd 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/types.h>
 #include <linux/bitmap.h>
+#include <linux/if_ether.h>
 
 #define i1480_FW 0x00000303
 /* #define i1480_FW 0x00000302 */
@@ -130,7 +131,7 @@ enum { UWB_DRP_BACKOFF_WIN_MAX = 16 };
  * it is also used to define headers sent down and up the wire/radio).
  */
 struct uwb_mac_addr {
-       u8 data[6];
+       u8 data[ETH_ALEN];
 } __attribute__((packed));
 
 
@@ -568,7 +569,7 @@ struct uwb_rc_evt_confirm {
 /* Device Address Management event. [WHCI] section 3.1.3.2. */
 struct uwb_rc_evt_dev_addr_mgmt {
        struct uwb_rceb rceb;
-       u8 baAddr[6];
+       u8 baAddr[ETH_ALEN];
        u8 bResultCode;
 } __attribute__((packed));
 
index 76be077340ea5c7c4d96f1299bea48b9aa40a98d..7dc17e2456de141ef3241a73af02fbec9b9c1ee5 100644 (file)
@@ -12,7 +12,7 @@ struct vmpressure {
        unsigned long scanned;
        unsigned long reclaimed;
        /* The lock is used to keep the scanned/reclaimed above in sync. */
-       struct mutex sr_lock;
+       struct spinlock sr_lock;
 
        /* The list of vmpressure_event structs. */
        struct list_head events;
@@ -30,6 +30,7 @@ extern void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
 extern void vmpressure_prio(gfp_t gfp, struct mem_cgroup *memcg, int prio);
 
 extern void vmpressure_init(struct vmpressure *vmpr);
+extern void vmpressure_cleanup(struct vmpressure *vmpr);
 extern struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg);
 extern struct cgroup_subsys_state *vmpressure_to_css(struct vmpressure *vmpr);
 extern struct vmpressure *css_to_vmpressure(struct cgroup_subsys_state *css);
index 4a1191abd936df57986be2f99b44cfcd1f0203ee..f7119ee3977b22541cb5faa8d0282d62b435fe2c 100644 (file)
@@ -12,6 +12,8 @@ enum tveeprom_audio_processor {
        TVEEPROM_AUDPROC_OTHER,
 };
 
+#include <linux/if_ether.h>
+
 struct tveeprom {
        u32 has_radio;
        /* If has_ir == 0, then it is unknown what the IR capabilities are,
@@ -40,7 +42,7 @@ struct tveeprom {
        u32 revision;
        u32 serial_number;
        char rev_str[5];
-       u8 MAC_address[6];
+       u8 MAC_address[ETH_ALEN];
 };
 
 void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
index 7343a27fe81966372c3ee8dc72241f2822891543..47ada23345a195973c3942681566244d50c7f34d 100644 (file)
@@ -22,6 +22,7 @@
 #define _V4L2_CTRLS_H
 
 #include <linux/list.h>
+#include <linux/mutex.h>
 #include <linux/videodev2.h>
 
 /* forward references */
index d9fa68f26c41c34c33db5f743a4142faf7886792..9a36d929711482da1f4090fb9e51c4ab9a261ffd 100644 (file)
@@ -40,8 +40,6 @@
  * @close: member function to discard a connection on this transport
  * @request: member function to issue a request to the transport
  * @cancel: member function to cancel a request (if it hasn't been sent)
- * @cancelled: member function to notify that a cancelled request will not
- *             not receive a reply
  *
  * This is the basic API for a transport module which is registered by the
  * transport module with the 9P core network module and used by the client
@@ -60,7 +58,6 @@ struct p9_trans_module {
        void (*close) (struct p9_client *);
        int (*request) (struct p9_client *, struct p9_req_t *req);
        int (*cancel) (struct p9_client *, struct p9_req_t *req);
-       int (*cancelled)(struct p9_client *, struct p9_req_t *req);
        int (*zc_request)(struct p9_client *, struct p9_req_t *,
                          char *, char *, int , int, int, int);
 };
index b8ffac7b6bab755f5adb4d648b5d34bd57eb028f..9e90fdff470d5a8b358b35c8aa3bc660728ffc05 100644 (file)
@@ -82,36 +82,36 @@ struct tc_action_ops {
        int     (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *);
 };
 
-extern struct tcf_common *tcf_hash_lookup(u32 index,
-                                         struct tcf_hashinfo *hinfo);
-extern void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo);
-extern int tcf_hash_release(struct tcf_common *p, int bind,
-                           struct tcf_hashinfo *hinfo);
-extern int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
-                             int type, struct tc_action *a);
-extern u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
-extern int tcf_hash_search(struct tc_action *a, u32 index);
-extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
-                                        int bind, struct tcf_hashinfo *hinfo);
-extern struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
-                                         struct tc_action *a, int size,
-                                         int bind, u32 *idx_gen,
-                                         struct tcf_hashinfo *hinfo);
-extern void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
+struct tcf_common *tcf_hash_lookup(u32 index, struct tcf_hashinfo *hinfo);
+void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo);
+int tcf_hash_release(struct tcf_common *p, int bind,
+                    struct tcf_hashinfo *hinfo);
+int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
+                      int type, struct tc_action *a);
+u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
+int tcf_hash_search(struct tc_action *a, u32 index);
+struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
+                                 int bind, struct tcf_hashinfo *hinfo);
+struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
+                                  struct tc_action *a, int size,
+                                  int bind, u32 *idx_gen,
+                                  struct tcf_hashinfo *hinfo);
+void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
 
-extern int tcf_register_action(struct tc_action_ops *a);
-extern int tcf_unregister_action(struct tc_action_ops *a);
-extern void tcf_action_destroy(struct tc_action *a, int bind);
-extern int tcf_action_exec(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res);
-extern struct tc_action *tcf_action_init(struct net *net, struct nlattr *nla,
-                                        struct nlattr *est, char *n, int ovr,
-                                        int bind);
-extern struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
-                                          struct nlattr *est, char *n, int ovr,
-                                          int bind);
-extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
-extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
-extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
-extern int tcf_action_copy_stats (struct sk_buff *,struct tc_action *, int);
+int tcf_register_action(struct tc_action_ops *a);
+int tcf_unregister_action(struct tc_action_ops *a);
+void tcf_action_destroy(struct tc_action *a, int bind);
+int tcf_action_exec(struct sk_buff *skb, const struct tc_action *a,
+                   struct tcf_result *res);
+struct tc_action *tcf_action_init(struct net *net, struct nlattr *nla,
+                                 struct nlattr *est, char *n, int ovr,
+                                 int bind);
+struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
+                                   struct nlattr *est, char *n, int ovr,
+                                   int bind);
+int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
+int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
+int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
+int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
 #endif /* CONFIG_NET_CLS_ACT */
 #endif
index c7b181cb47a6a9ae4b4e30ca2d94ce74f5f9ef40..43fa31a610b81e9d7ae8677d58d34b431cd47576 100644 (file)
@@ -53,51 +53,36 @@ struct prefix_info {
 #define IN6_ADDR_HSIZE_SHIFT   4
 #define IN6_ADDR_HSIZE         (1 << IN6_ADDR_HSIZE_SHIFT)
 
-extern int                     addrconf_init(void);
-extern void                    addrconf_cleanup(void);
+int addrconf_init(void);
+void addrconf_cleanup(void);
 
-extern int                     addrconf_add_ifaddr(struct net *net,
-                                                   void __user *arg);
-extern int                     addrconf_del_ifaddr(struct net *net,
-                                                   void __user *arg);
-extern int                     addrconf_set_dstaddr(struct net *net,
-                                                    void __user *arg);
+int addrconf_add_ifaddr(struct net *net, void __user *arg);
+int addrconf_del_ifaddr(struct net *net, void __user *arg);
+int addrconf_set_dstaddr(struct net *net, void __user *arg);
 
-extern int                     ipv6_chk_addr(struct net *net,
-                                             const struct in6_addr *addr,
-                                             const struct net_device *dev,
-                                             int strict);
+int ipv6_chk_addr(struct net *net, const struct in6_addr *addr,
+                 const struct net_device *dev, int strict);
 
 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
-extern int                     ipv6_chk_home_addr(struct net *net,
-                                                  const struct in6_addr *addr);
+int ipv6_chk_home_addr(struct net *net, const struct in6_addr *addr);
 #endif
 
-extern int                     ipv6_chk_prefix(const struct in6_addr *addr,
-                                               struct net_device *dev);
-
-extern struct inet6_ifaddr      *ipv6_get_ifaddr(struct net *net,
-                                                const struct in6_addr *addr,
-                                                struct net_device *dev,
-                                                int strict);
-
-extern int                     ipv6_dev_get_saddr(struct net *net,
-                                              const struct net_device *dev,
-                                              const struct in6_addr *daddr,
-                                              unsigned int srcprefs,
-                                              struct in6_addr *saddr);
-extern int                     __ipv6_get_lladdr(struct inet6_dev *idev,
-                                                 struct in6_addr *addr,
-                                                 unsigned char banned_flags);
-extern int                     ipv6_get_lladdr(struct net_device *dev,
-                                               struct in6_addr *addr,
-                                               unsigned char banned_flags);
-extern int                     ipv6_rcv_saddr_equal(const struct sock *sk,
-                                                   const struct sock *sk2);
-extern void                    addrconf_join_solict(struct net_device *dev,
-                                       const struct in6_addr *addr);
-extern void                    addrconf_leave_solict(struct inet6_dev *idev,
-                                       const struct in6_addr *addr);
+int ipv6_chk_prefix(const struct in6_addr *addr, struct net_device *dev);
+
+struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
+                                    const struct in6_addr *addr,
+                                    struct net_device *dev, int strict);
+
+int ipv6_dev_get_saddr(struct net *net, const struct net_device *dev,
+                      const struct in6_addr *daddr, unsigned int srcprefs,
+                      struct in6_addr *saddr);
+int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
+                     unsigned char banned_flags);
+int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr,
+                   unsigned char banned_flags);
+int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2);
+void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr);
+void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr);
 
 static inline unsigned long addrconf_timeout_fixup(u32 timeout,
                                                   unsigned int unit)
@@ -124,41 +109,38 @@ static inline int addrconf_finite_timeout(unsigned long timeout)
 /*
  *     IPv6 Address Label subsystem (addrlabel.c)
  */
-extern int                     ipv6_addr_label_init(void);
-extern void                    ipv6_addr_label_cleanup(void);
-extern void                    ipv6_addr_label_rtnl_register(void);
-extern u32                     ipv6_addr_label(struct net *net,
-                                               const struct in6_addr *addr,
-                                               int type, int ifindex);
+int ipv6_addr_label_init(void);
+void ipv6_addr_label_cleanup(void);
+void ipv6_addr_label_rtnl_register(void);
+u32 ipv6_addr_label(struct net *net, const struct in6_addr *addr,
+                   int type, int ifindex);
 
 /*
  *     multicast prototypes (mcast.c)
  */
-extern int ipv6_sock_mc_join(struct sock *sk, int ifindex,
-                            const struct in6_addr *addr);
-extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
-                            const struct in6_addr *addr);
-extern void ipv6_sock_mc_close(struct sock *sk);
-extern bool inet6_mc_check(struct sock *sk,
-                          const struct in6_addr *mc_addr,
-                          const struct in6_addr *src_addr);
-
-extern int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr);
-extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr);
-extern int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr);
-extern void ipv6_mc_up(struct inet6_dev *idev);
-extern void ipv6_mc_down(struct inet6_dev *idev);
-extern void ipv6_mc_unmap(struct inet6_dev *idev);
-extern void ipv6_mc_remap(struct inet6_dev *idev);
-extern void ipv6_mc_init_dev(struct inet6_dev *idev);
-extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
-extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
-
-extern bool ipv6_chk_mcast_addr(struct net_device *dev,
-                               const struct in6_addr *group,
-                               const struct in6_addr *src_addr);
-
-extern void ipv6_mc_dad_complete(struct inet6_dev *idev);
+int ipv6_sock_mc_join(struct sock *sk, int ifindex,
+                     const struct in6_addr *addr);
+int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
+                     const struct in6_addr *addr);
+void ipv6_sock_mc_close(struct sock *sk);
+bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
+                   const struct in6_addr *src_addr);
+
+int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr);
+int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr);
+int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr);
+void ipv6_mc_up(struct inet6_dev *idev);
+void ipv6_mc_down(struct inet6_dev *idev);
+void ipv6_mc_unmap(struct inet6_dev *idev);
+void ipv6_mc_remap(struct inet6_dev *idev);
+void ipv6_mc_init_dev(struct inet6_dev *idev);
+void ipv6_mc_destroy_dev(struct inet6_dev *idev);
+void addrconf_dad_failure(struct inet6_ifaddr *ifp);
+
+bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
+                        const struct in6_addr *src_addr);
+
+void ipv6_mc_dad_complete(struct inet6_dev *idev);
 /*
  * identify MLD packets for MLD filter exceptions
  */
@@ -184,29 +166,31 @@ static inline bool ipv6_is_mld(struct sk_buff *skb, int nexthdr, int offset)
        return false;
 }
 
-extern void addrconf_prefix_rcv(struct net_device *dev,
-                               u8 *opt, int len, bool sllao);
+void addrconf_prefix_rcv(struct net_device *dev,
+                        u8 *opt, int len, bool sllao);
 
 /*
  *     anycast prototypes (anycast.c)
  */
-extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr);
-extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr);
-extern void ipv6_sock_ac_close(struct sock *sk);
-
-extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
-extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
-extern bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
+int ipv6_sock_ac_join(struct sock *sk, int ifindex,
+                     const struct in6_addr *addr);
+int ipv6_sock_ac_drop(struct sock *sk, int ifindex,
+                     const struct in6_addr *addr);
+void ipv6_sock_ac_close(struct sock *sk);
+
+int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
+int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
+bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
                                const struct in6_addr *addr);
 
 
 /* Device notifier */
-extern int register_inet6addr_notifier(struct notifier_block *nb);
-extern int unregister_inet6addr_notifier(struct notifier_block *nb);
-extern int inet6addr_notifier_call_chain(unsigned long val, void *v);
+int register_inet6addr_notifier(struct notifier_block *nb);
+int unregister_inet6addr_notifier(struct notifier_block *nb);
+int inet6addr_notifier_call_chain(unsigned long val, void *v);
 
-extern void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex,
-                                        struct ipv6_devconf *devconf);
+void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex,
+                                 struct ipv6_devconf *devconf);
 
 /**
  * __in6_dev_get - get inet6_dev pointer from netdevice
@@ -240,7 +224,7 @@ static inline struct inet6_dev *in6_dev_get(const struct net_device *dev)
        return idev;
 }
 
-extern void in6_dev_finish_destroy(struct inet6_dev *idev);
+void in6_dev_finish_destroy(struct inet6_dev *idev);
 
 static inline void in6_dev_put(struct inet6_dev *idev)
 {
@@ -258,7 +242,7 @@ static inline void in6_dev_hold(struct inet6_dev *idev)
        atomic_inc(&idev->refcnt);
 }
 
-extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
+void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
 
 static inline void in6_ifa_put(struct inet6_ifaddr *ifp)
 {
@@ -340,8 +324,8 @@ static inline bool ipv6_addr_is_solict_mult(const struct in6_addr *addr)
 }
 
 #ifdef CONFIG_PROC_FS
-extern int if6_proc_init(void);
-extern void if6_proc_exit(void);
+int if6_proc_init(void);
+void if6_proc_exit(void);
 #endif
 
 #endif
index 03e6e94536231559b95b67bd1d9f99f313556459..e797d45a5ae62697361e1ca827a7638542cc4f41 100644 (file)
@@ -31,24 +31,21 @@ enum {
 
 typedef void (*rxrpc_interceptor_t)(struct sock *, unsigned long,
                                    struct sk_buff *);
-extern void rxrpc_kernel_intercept_rx_messages(struct socket *,
-                                              rxrpc_interceptor_t);
-extern struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *,
-                                                 struct sockaddr_rxrpc *,
-                                                 struct key *,
-                                                 unsigned long,
-                                                 gfp_t);
-extern int rxrpc_kernel_send_data(struct rxrpc_call *, struct msghdr *,
-                                 size_t);
-extern void rxrpc_kernel_abort_call(struct rxrpc_call *, u32);
-extern void rxrpc_kernel_end_call(struct rxrpc_call *);
-extern bool rxrpc_kernel_is_data_last(struct sk_buff *);
-extern u32 rxrpc_kernel_get_abort_code(struct sk_buff *);
-extern int rxrpc_kernel_get_error_number(struct sk_buff *);
-extern void rxrpc_kernel_data_delivered(struct sk_buff *);
-extern void rxrpc_kernel_free_skb(struct sk_buff *);
-extern struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *,
-                                                  unsigned long);
-extern int rxrpc_kernel_reject_call(struct socket *);
+void rxrpc_kernel_intercept_rx_messages(struct socket *, rxrpc_interceptor_t);
+struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *,
+                                          struct sockaddr_rxrpc *,
+                                          struct key *,
+                                          unsigned long,
+                                          gfp_t);
+int rxrpc_kernel_send_data(struct rxrpc_call *, struct msghdr *, size_t);
+void rxrpc_kernel_abort_call(struct rxrpc_call *, u32);
+void rxrpc_kernel_end_call(struct rxrpc_call *);
+bool rxrpc_kernel_is_data_last(struct sk_buff *);
+u32 rxrpc_kernel_get_abort_code(struct sk_buff *);
+int rxrpc_kernel_get_error_number(struct sk_buff *);
+void rxrpc_kernel_data_delivered(struct sk_buff *);
+void rxrpc_kernel_free_skb(struct sk_buff *);
+struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *, unsigned long);
+int rxrpc_kernel_reject_call(struct socket *);
 
 #endif /* _NET_RXRPC_H */
index dbdfd2b0f3b3dbe0a4470d83e19052db4ba3aa04..a175ba4a7adbc615c350d8b8daaf7b082049f1ec 100644 (file)
@@ -6,12 +6,12 @@
 #include <linux/mutex.h>
 #include <net/sock.h>
 
-extern void unix_inflight(struct file *fp);
-extern void unix_notinflight(struct file *fp);
-extern void unix_gc(void);
-extern void wait_for_unix_gc(void);
-extern struct sock *unix_get_socket(struct file *filp);
-extern struct sock *unix_peer_get(struct sock *);
+void unix_inflight(struct file *fp);
+void unix_notinflight(struct file *fp);
+void unix_gc(void);
+void wait_for_unix_gc(void);
+struct sock *unix_get_socket(struct file *filp);
+struct sock *unix_peer_get(struct sock *);
 
 #define UNIX_HASH_SIZE 256
 #define UNIX_HASH_BITS 8
@@ -35,6 +35,7 @@ struct unix_skb_parms {
 #ifdef CONFIG_SECURITY_NETWORK
        u32                     secid;          /* Security ID          */
 #endif
+       u32                     consumed;
 };
 
 #define UNIXCB(skb)    (*(struct unix_skb_parms *)&((skb)->cb))
@@ -71,8 +72,8 @@ long unix_inq_len(struct sock *sk);
 long unix_outq_len(struct sock *sk);
 
 #ifdef CONFIG_SYSCTL
-extern int unix_sysctl_register(struct net *net);
-extern void unix_sysctl_unregister(struct net *net);
+int unix_sysctl_register(struct net *net);
+void unix_sysctl_unregister(struct net *net);
 #else
 static inline int unix_sysctl_register(struct net *net) { return 0; }
 static inline void unix_sysctl_unregister(struct net *net) {}
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
new file mode 100644 (file)
index 0000000..7d64d36
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __AF_VSOCK_H__
+#define __AF_VSOCK_H__
+
+#include <linux/kernel.h>
+#include <linux/workqueue.h>
+#include <linux/vm_sockets.h>
+
+#include "vsock_addr.h"
+
+#define LAST_RESERVED_PORT 1023
+
+#define vsock_sk(__sk)    ((struct vsock_sock *)__sk)
+#define sk_vsock(__vsk)   (&(__vsk)->sk)
+
+struct vsock_sock {
+       /* sk must be the first member. */
+       struct sock sk;
+       struct sockaddr_vm local_addr;
+       struct sockaddr_vm remote_addr;
+       /* Links for the global tables of bound and connected sockets. */
+       struct list_head bound_table;
+       struct list_head connected_table;
+       /* Accessed without the socket lock held. This means it can never be
+        * modified outsided of socket create or destruct.
+        */
+       bool trusted;
+       bool cached_peer_allow_dgram;   /* Dgram communication allowed to
+                                        * cached peer?
+                                        */
+       u32 cached_peer;  /* Context ID of last dgram destination check. */
+       const struct cred *owner;
+       /* Rest are SOCK_STREAM only. */
+       long connect_timeout;
+       /* Listening socket that this came from. */
+       struct sock *listener;
+       /* Used for pending list and accept queue during connection handshake.
+        * The listening socket is the head for both lists.  Sockets created
+        * for connection requests are placed in the pending list until they
+        * are connected, at which point they are put in the accept queue list
+        * so they can be accepted in accept().  If accept() cannot accept the
+        * connection, it is marked as rejected so the cleanup function knows
+        * to clean up the socket.
+        */
+       struct list_head pending_links;
+       struct list_head accept_queue;
+       bool rejected;
+       struct delayed_work dwork;
+       u32 peer_shutdown;
+       bool sent_request;
+       bool ignore_connecting_rst;
+
+       /* Private to transport. */
+       void *trans;
+};
+
+s64 vsock_stream_has_data(struct vsock_sock *vsk);
+s64 vsock_stream_has_space(struct vsock_sock *vsk);
+void vsock_pending_work(struct work_struct *work);
+struct sock *__vsock_create(struct net *net,
+                           struct socket *sock,
+                           struct sock *parent,
+                           gfp_t priority, unsigned short type);
+
+/**** TRANSPORT ****/
+
+struct vsock_transport_recv_notify_data {
+       u64 data1; /* Transport-defined. */
+       u64 data2; /* Transport-defined. */
+       bool notify_on_block;
+};
+
+struct vsock_transport_send_notify_data {
+       u64 data1; /* Transport-defined. */
+       u64 data2; /* Transport-defined. */
+};
+
+struct vsock_transport {
+       /* Initialize/tear-down socket. */
+       int (*init)(struct vsock_sock *, struct vsock_sock *);
+       void (*destruct)(struct vsock_sock *);
+       void (*release)(struct vsock_sock *);
+
+       /* Connections. */
+       int (*connect)(struct vsock_sock *);
+
+       /* DGRAM. */
+       int (*dgram_bind)(struct vsock_sock *, struct sockaddr_vm *);
+       int (*dgram_dequeue)(struct kiocb *kiocb, struct vsock_sock *vsk,
+                            struct msghdr *msg, size_t len, int flags);
+       int (*dgram_enqueue)(struct vsock_sock *, struct sockaddr_vm *,
+                            struct iovec *, size_t len);
+       bool (*dgram_allow)(u32 cid, u32 port);
+
+       /* STREAM. */
+       /* TODO: stream_bind() */
+       ssize_t (*stream_dequeue)(struct vsock_sock *, struct iovec *,
+                                 size_t len, int flags);
+       ssize_t (*stream_enqueue)(struct vsock_sock *, struct iovec *,
+                                 size_t len);
+       s64 (*stream_has_data)(struct vsock_sock *);
+       s64 (*stream_has_space)(struct vsock_sock *);
+       u64 (*stream_rcvhiwat)(struct vsock_sock *);
+       bool (*stream_is_active)(struct vsock_sock *);
+       bool (*stream_allow)(u32 cid, u32 port);
+
+       /* Notification. */
+       int (*notify_poll_in)(struct vsock_sock *, size_t, bool *);
+       int (*notify_poll_out)(struct vsock_sock *, size_t, bool *);
+       int (*notify_recv_init)(struct vsock_sock *, size_t,
+               struct vsock_transport_recv_notify_data *);
+       int (*notify_recv_pre_block)(struct vsock_sock *, size_t,
+               struct vsock_transport_recv_notify_data *);
+       int (*notify_recv_pre_dequeue)(struct vsock_sock *, size_t,
+               struct vsock_transport_recv_notify_data *);
+       int (*notify_recv_post_dequeue)(struct vsock_sock *, size_t,
+               ssize_t, bool, struct vsock_transport_recv_notify_data *);
+       int (*notify_send_init)(struct vsock_sock *,
+               struct vsock_transport_send_notify_data *);
+       int (*notify_send_pre_block)(struct vsock_sock *,
+               struct vsock_transport_send_notify_data *);
+       int (*notify_send_pre_enqueue)(struct vsock_sock *,
+               struct vsock_transport_send_notify_data *);
+       int (*notify_send_post_enqueue)(struct vsock_sock *, ssize_t,
+               struct vsock_transport_send_notify_data *);
+
+       /* Shutdown. */
+       int (*shutdown)(struct vsock_sock *, int);
+
+       /* Buffer sizes. */
+       void (*set_buffer_size)(struct vsock_sock *, u64);
+       void (*set_min_buffer_size)(struct vsock_sock *, u64);
+       void (*set_max_buffer_size)(struct vsock_sock *, u64);
+       u64 (*get_buffer_size)(struct vsock_sock *);
+       u64 (*get_min_buffer_size)(struct vsock_sock *);
+       u64 (*get_max_buffer_size)(struct vsock_sock *);
+
+       /* Addressing. */
+       u32 (*get_local_cid)(void);
+};
+
+/**** CORE ****/
+
+int vsock_core_init(const struct vsock_transport *t);
+void vsock_core_exit(void);
+
+/**** UTILS ****/
+
+void vsock_release_pending(struct sock *pending);
+void vsock_add_pending(struct sock *listener, struct sock *pending);
+void vsock_remove_pending(struct sock *listener, struct sock *pending);
+void vsock_enqueue_accept(struct sock *listener, struct sock *connected);
+void vsock_insert_connected(struct vsock_sock *vsk);
+void vsock_remove_bound(struct vsock_sock *vsk);
+void vsock_remove_connected(struct vsock_sock *vsk);
+struct sock *vsock_find_bound_socket(struct sockaddr_vm *addr);
+struct sock *vsock_find_connected_socket(struct sockaddr_vm *src,
+                                        struct sockaddr_vm *dst);
+void vsock_for_each_connected_socket(void (*fn)(struct sock *sk));
+
+#endif /* __AF_VSOCK_H__ */
index b630dae03411ae69694e842d75108a254c0584aa..7509d9da4e3631ee9f00fba4d27922ace90cb9ae 100644 (file)
@@ -46,22 +46,22 @@ static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32
        return n;
 }
 
-extern void    arp_init(void);
-extern int     arp_find(unsigned char *haddr, struct sk_buff *skb);
-extern int     arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
-extern void     arp_send(int type, int ptype, __be32 dest_ip,
-                        struct net_device *dev, __be32 src_ip,
-                        const unsigned char *dest_hw,
-                        const unsigned char *src_hw, const unsigned char *th);
-extern int     arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
-extern void    arp_ifdown(struct net_device *dev);
+void arp_init(void);
+int arp_find(unsigned char *haddr, struct sk_buff *skb);
+int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
+void arp_send(int type, int ptype, __be32 dest_ip,
+             struct net_device *dev, __be32 src_ip,
+             const unsigned char *dest_hw,
+             const unsigned char *src_hw, const unsigned char *th);
+int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
+void arp_ifdown(struct net_device *dev);
 
-extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
-                                 struct net_device *dev, __be32 src_ip,
-                                 const unsigned char *dest_hw,
-                                 const unsigned char *src_hw,
-                                 const unsigned char *target_hw);
-extern void arp_xmit(struct sk_buff *skb);
+struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
+                          struct net_device *dev, __be32 src_ip,
+                          const unsigned char *dest_hw,
+                          const unsigned char *src_hw,
+                          const unsigned char *target_hw);
+void arp_xmit(struct sk_buff *skb);
 int arp_invalidate(struct net_device *dev, __be32 ip);
 
 #endif /* _ARP_H */
index 89ed9ac5701fcc3c309890bb3403eef85c97a63e..bf0396e9a5d3f3c946b30a64c030c9f5c4f17ca0 100644 (file)
@@ -195,7 +195,7 @@ static inline void ax25_hold_route(ax25_route *ax25_rt)
        atomic_inc(&ax25_rt->refcount);
 }
 
-extern void __ax25_put_route(ax25_route *ax25_rt);
+void __ax25_put_route(ax25_route *ax25_rt);
 
 static inline void ax25_put_route(ax25_route *ax25_rt)
 {
@@ -272,30 +272,31 @@ static inline __be16 ax25_type_trans(struct sk_buff *skb, struct net_device *dev
 /* af_ax25.c */
 extern struct hlist_head ax25_list;
 extern spinlock_t ax25_list_lock;
-extern void ax25_cb_add(ax25_cb *);
+void ax25_cb_add(ax25_cb *);
 struct sock *ax25_find_listener(ax25_address *, int, struct net_device *, int);
 struct sock *ax25_get_socket(ax25_address *, ax25_address *, int);
-extern ax25_cb *ax25_find_cb(ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
-extern void ax25_send_to_raw(ax25_address *, struct sk_buff *, int);
-extern void ax25_destroy_socket(ax25_cb *);
-extern ax25_cb * __must_check ax25_create_cb(void);
-extern void ax25_fillin_cb(ax25_cb *, ax25_dev *);
-extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
+ax25_cb *ax25_find_cb(ax25_address *, ax25_address *, ax25_digi *,
+                     struct net_device *);
+void ax25_send_to_raw(ax25_address *, struct sk_buff *, int);
+void ax25_destroy_socket(ax25_cb *);
+ax25_cb * __must_check ax25_create_cb(void);
+void ax25_fillin_cb(ax25_cb *, ax25_dev *);
+struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
 
 /* ax25_addr.c */
 extern const ax25_address ax25_bcast;
 extern const ax25_address ax25_defaddr;
 extern const ax25_address null_ax25_address;
-extern char *ax2asc(char *buf, const ax25_address *);
-extern void asc2ax(ax25_address *addr, const char *callsign);
-extern int ax25cmp(const ax25_address *, const ax25_address *);
-extern int ax25digicmp(const ax25_digi *, const ax25_digi *);
-extern const unsigned char *ax25_addr_parse(const unsigned char *, int,
+char *ax2asc(char *buf, const ax25_address *);
+void asc2ax(ax25_address *addr, const char *callsign);
+int ax25cmp(const ax25_address *, const ax25_address *);
+int ax25digicmp(const ax25_digi *, const ax25_digi *);
+const unsigned char *ax25_addr_parse(const unsigned char *, int,
        ax25_address *, ax25_address *, ax25_digi *, int *, int *);
-extern int  ax25_addr_build(unsigned char *, const ax25_address *,
-       const ax25_address *, const ax25_digi *, int, int);
-extern int  ax25_addr_size(const ax25_digi *);
-extern void ax25_digi_invert(const ax25_digi *, ax25_digi *);
+int ax25_addr_build(unsigned char *, const ax25_address *,
+                   const ax25_address *, const ax25_digi *, int, int);
+int ax25_addr_size(const ax25_digi *);
+void ax25_digi_invert(const ax25_digi *, ax25_digi *);
 
 /* ax25_dev.c */
 extern ax25_dev *ax25_dev_list;
@@ -306,33 +307,33 @@ static inline ax25_dev *ax25_dev_ax25dev(struct net_device *dev)
        return dev->ax25_ptr;
 }
 
-extern ax25_dev *ax25_addr_ax25dev(ax25_address *);
-extern void ax25_dev_device_up(struct net_device *);
-extern void ax25_dev_device_down(struct net_device *);
-extern int  ax25_fwd_ioctl(unsigned int, struct ax25_fwd_struct *);
-extern struct net_device *ax25_fwd_dev(struct net_device *);
-extern void ax25_dev_free(void);
+ax25_dev *ax25_addr_ax25dev(ax25_address *);
+void ax25_dev_device_up(struct net_device *);
+void ax25_dev_device_down(struct net_device *);
+int ax25_fwd_ioctl(unsigned int, struct ax25_fwd_struct *);
+struct net_device *ax25_fwd_dev(struct net_device *);
+void ax25_dev_free(void);
 
 /* ax25_ds_in.c */
-extern int  ax25_ds_frame_in(ax25_cb *, struct sk_buff *, int);
+int ax25_ds_frame_in(ax25_cb *, struct sk_buff *, int);
 
 /* ax25_ds_subr.c */
-extern void ax25_ds_nr_error_recovery(ax25_cb *);
-extern void ax25_ds_enquiry_response(ax25_cb *);
-extern void ax25_ds_establish_data_link(ax25_cb *);
-extern void ax25_dev_dama_off(ax25_dev *);
-extern void ax25_dama_on(ax25_cb *);
-extern void ax25_dama_off(ax25_cb *);
+void ax25_ds_nr_error_recovery(ax25_cb *);
+void ax25_ds_enquiry_response(ax25_cb *);
+void ax25_ds_establish_data_link(ax25_cb *);
+void ax25_dev_dama_off(ax25_dev *);
+void ax25_dama_on(ax25_cb *);
+void ax25_dama_off(ax25_cb *);
 
 /* ax25_ds_timer.c */
-extern void ax25_ds_setup_timer(ax25_dev *);
-extern void ax25_ds_set_timer(ax25_dev *);
-extern void ax25_ds_del_timer(ax25_dev *);
-extern void ax25_ds_timer(ax25_cb *);
-extern void ax25_ds_t1_timeout(ax25_cb *);
-extern void ax25_ds_heartbeat_expiry(ax25_cb *);
-extern void ax25_ds_t3timer_expiry(ax25_cb *);
-extern void ax25_ds_idletimer_expiry(ax25_cb *);
+void ax25_ds_setup_timer(ax25_dev *);
+void ax25_ds_set_timer(ax25_dev *);
+void ax25_ds_del_timer(ax25_dev *);
+void ax25_ds_timer(ax25_cb *);
+void ax25_ds_t1_timeout(ax25_cb *);
+void ax25_ds_heartbeat_expiry(ax25_cb *);
+void ax25_ds_t3timer_expiry(ax25_cb *);
+void ax25_ds_idletimer_expiry(ax25_cb *);
 
 /* ax25_iface.c */
 
@@ -342,107 +343,109 @@ struct ax25_protocol {
        int (*func)(struct sk_buff *, ax25_cb *);
 };
 
-extern void ax25_register_pid(struct ax25_protocol *ap);
-extern void ax25_protocol_release(unsigned int);
+void ax25_register_pid(struct ax25_protocol *ap);
+void ax25_protocol_release(unsigned int);
 
 struct ax25_linkfail {
        struct hlist_node lf_node;
        void (*func)(ax25_cb *, int);
 };
 
-extern void ax25_linkfail_register(struct ax25_linkfail *lf);
-extern void ax25_linkfail_release(struct ax25_linkfail *lf);
-extern int __must_check ax25_listen_register(ax25_address *,
-       struct net_device *);
-extern void ax25_listen_release(ax25_address *, struct net_device *);
-extern int  (*ax25_protocol_function(unsigned int))(struct sk_buff *, ax25_cb *);
-extern int  ax25_listen_mine(ax25_address *, struct net_device *);
-extern void ax25_link_failed(ax25_cb *, int);
-extern int  ax25_protocol_is_registered(unsigned int);
+void ax25_linkfail_register(struct ax25_linkfail *lf);
+void ax25_linkfail_release(struct ax25_linkfail *lf);
+int __must_check ax25_listen_register(ax25_address *, struct net_device *);
+void ax25_listen_release(ax25_address *, struct net_device *);
+int(*ax25_protocol_function(unsigned int))(struct sk_buff *, ax25_cb *);
+int ax25_listen_mine(ax25_address *, struct net_device *);
+void ax25_link_failed(ax25_cb *, int);
+int ax25_protocol_is_registered(unsigned int);
 
 /* ax25_in.c */
-extern int  ax25_rx_iframe(ax25_cb *, struct sk_buff *);
-extern int  ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
+int ax25_rx_iframe(ax25_cb *, struct sk_buff *);
+int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *,
+                 struct net_device *);
 
 /* ax25_ip.c */
-extern int ax25_hard_header(struct sk_buff *, struct net_device *,
-                           unsigned short, const void *,
-                           const void *, unsigned int);
-extern int  ax25_rebuild_header(struct sk_buff *);
+int ax25_hard_header(struct sk_buff *, struct net_device *, unsigned short,
+                    const void *, const void *, unsigned int);
+int ax25_rebuild_header(struct sk_buff *);
 extern const struct header_ops ax25_header_ops;
 
 /* ax25_out.c */
-extern ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
-extern void ax25_output(ax25_cb *, int, struct sk_buff *);
-extern void ax25_kick(ax25_cb *);
-extern void ax25_transmit_buffer(ax25_cb *, struct sk_buff *, int);
-extern void ax25_queue_xmit(struct sk_buff *skb, struct net_device *dev);
-extern int  ax25_check_iframes_acked(ax25_cb *, unsigned short);
+ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_address *,
+                        ax25_digi *, struct net_device *);
+void ax25_output(ax25_cb *, int, struct sk_buff *);
+void ax25_kick(ax25_cb *);
+void ax25_transmit_buffer(ax25_cb *, struct sk_buff *, int);
+void ax25_queue_xmit(struct sk_buff *skb, struct net_device *dev);
+int ax25_check_iframes_acked(ax25_cb *, unsigned short);
 
 /* ax25_route.c */
-extern void ax25_rt_device_down(struct net_device *);
-extern int  ax25_rt_ioctl(unsigned int, void __user *);
+void ax25_rt_device_down(struct net_device *);
+int ax25_rt_ioctl(unsigned int, void __user *);
 extern const struct file_operations ax25_route_fops;
-extern ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev);
-extern int  ax25_rt_autobind(ax25_cb *, ax25_address *);
-extern struct sk_buff *ax25_rt_build_path(struct sk_buff *, ax25_address *, ax25_address *, ax25_digi *);
-extern void ax25_rt_free(void);
+ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev);
+int ax25_rt_autobind(ax25_cb *, ax25_address *);
+struct sk_buff *ax25_rt_build_path(struct sk_buff *, ax25_address *,
+                                  ax25_address *, ax25_digi *);
+void ax25_rt_free(void);
 
 /* ax25_std_in.c */
-extern int  ax25_std_frame_in(ax25_cb *, struct sk_buff *, int);
+int ax25_std_frame_in(ax25_cb *, struct sk_buff *, int);
 
 /* ax25_std_subr.c */
-extern void ax25_std_nr_error_recovery(ax25_cb *);
-extern void ax25_std_establish_data_link(ax25_cb *);
-extern void ax25_std_transmit_enquiry(ax25_cb *);
-extern void ax25_std_enquiry_response(ax25_cb *);
-extern void ax25_std_timeout_response(ax25_cb *);
+void ax25_std_nr_error_recovery(ax25_cb *);
+void ax25_std_establish_data_link(ax25_cb *);
+void ax25_std_transmit_enquiry(ax25_cb *);
+void ax25_std_enquiry_response(ax25_cb *);
+void ax25_std_timeout_response(ax25_cb *);
 
 /* ax25_std_timer.c */
-extern void ax25_std_heartbeat_expiry(ax25_cb *);
-extern void ax25_std_t1timer_expiry(ax25_cb *);
-extern void ax25_std_t2timer_expiry(ax25_cb *);
-extern void ax25_std_t3timer_expiry(ax25_cb *);
-extern void ax25_std_idletimer_expiry(ax25_cb *);
+void ax25_std_heartbeat_expiry(ax25_cb *);
+void ax25_std_t1timer_expiry(ax25_cb *);
+void ax25_std_t2timer_expiry(ax25_cb *);
+void ax25_std_t3timer_expiry(ax25_cb *);
+void ax25_std_idletimer_expiry(ax25_cb *);
 
 /* ax25_subr.c */
-extern void ax25_clear_queues(ax25_cb *);
-extern void ax25_frames_acked(ax25_cb *, unsigned short);
-extern void ax25_requeue_frames(ax25_cb *);
-extern int  ax25_validate_nr(ax25_cb *, unsigned short);
-extern int  ax25_decode(ax25_cb *, struct sk_buff *, int *, int *, int *);
-extern void ax25_send_control(ax25_cb *, int, int, int);
-extern void ax25_return_dm(struct net_device *, ax25_address *, ax25_address *, ax25_digi *);
-extern void ax25_calculate_t1(ax25_cb *);
-extern void ax25_calculate_rtt(ax25_cb *);
-extern void ax25_disconnect(ax25_cb *, int);
+void ax25_clear_queues(ax25_cb *);
+void ax25_frames_acked(ax25_cb *, unsigned short);
+void ax25_requeue_frames(ax25_cb *);
+int ax25_validate_nr(ax25_cb *, unsigned short);
+int ax25_decode(ax25_cb *, struct sk_buff *, int *, int *, int *);
+void ax25_send_control(ax25_cb *, int, int, int);
+void ax25_return_dm(struct net_device *, ax25_address *, ax25_address *,
+                   ax25_digi *);
+void ax25_calculate_t1(ax25_cb *);
+void ax25_calculate_rtt(ax25_cb *);
+void ax25_disconnect(ax25_cb *, int);
 
 /* ax25_timer.c */
-extern void ax25_setup_timers(ax25_cb *);
-extern void ax25_start_heartbeat(ax25_cb *);
-extern void ax25_start_t1timer(ax25_cb *);
-extern void ax25_start_t2timer(ax25_cb *);
-extern void ax25_start_t3timer(ax25_cb *);
-extern void ax25_start_idletimer(ax25_cb *);
-extern void ax25_stop_heartbeat(ax25_cb *);
-extern void ax25_stop_t1timer(ax25_cb *);
-extern void ax25_stop_t2timer(ax25_cb *);
-extern void ax25_stop_t3timer(ax25_cb *);
-extern void ax25_stop_idletimer(ax25_cb *);
-extern int  ax25_t1timer_running(ax25_cb *);
-extern unsigned long ax25_display_timer(struct timer_list *);
+void ax25_setup_timers(ax25_cb *);
+void ax25_start_heartbeat(ax25_cb *);
+void ax25_start_t1timer(ax25_cb *);
+void ax25_start_t2timer(ax25_cb *);
+void ax25_start_t3timer(ax25_cb *);
+void ax25_start_idletimer(ax25_cb *);
+void ax25_stop_heartbeat(ax25_cb *);
+void ax25_stop_t1timer(ax25_cb *);
+void ax25_stop_t2timer(ax25_cb *);
+void ax25_stop_t3timer(ax25_cb *);
+void ax25_stop_idletimer(ax25_cb *);
+int ax25_t1timer_running(ax25_cb *);
+unsigned long ax25_display_timer(struct timer_list *);
 
 /* ax25_uid.c */
 extern int  ax25_uid_policy;
-extern ax25_uid_assoc *ax25_findbyuid(kuid_t);
-extern int __must_check ax25_uid_ioctl(int, struct sockaddr_ax25 *);
+ax25_uid_assoc *ax25_findbyuid(kuid_t);
+int __must_check ax25_uid_ioctl(int, struct sockaddr_ax25 *);
 extern const struct file_operations ax25_uid_fops;
-extern void ax25_uid_free(void);
+void ax25_uid_free(void);
 
 /* sysctl_net_ax25.c */
 #ifdef CONFIG_SYSCTL
-extern int ax25_register_dev_sysctl(ax25_dev *ax25_dev);
-extern void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev);
+int ax25_register_dev_sysctl(ax25_dev *ax25_dev);
+void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev);
 #else
 static inline int ax25_register_dev_sysctl(ax25_dev *ax25_dev) { return 0; }
 static inline void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev) {}
index a14339c2985ff0f24e259861fa39dcf335f601b5..8a358a2c97e6a82cb98dd6b9586133828306f961 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/netdevice.h>
 #include <net/ip.h>
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 
 struct napi_struct;
 extern unsigned int sysctl_net_busy_read __read_mostly;
@@ -122,7 +122,7 @@ static inline bool sk_busy_loop(struct sock *sk, int nonblock)
                if (rc > 0)
                        /* local bh are disabled so it is ok to use _BH */
                        NET_ADD_STATS_BH(sock_net(sk),
-                                        LINUX_MIB_LOWLATENCYRXPACKETS, rc);
+                                        LINUX_MIB_BUSYPOLLRXPACKETS, rc);
 
        } while (!nonblock && skb_queue_empty(&sk->sk_receive_queue) &&
                 !need_resched() && !busy_loop_timeout(end_time));
@@ -146,7 +146,7 @@ static inline void sk_mark_napi_id(struct sock *sk, struct sk_buff *skb)
        sk->sk_napi_id = skb->napi_id;
 }
 
-#else /* CONFIG_NET_LL_RX_POLL */
+#else /* CONFIG_NET_RX_BUSY_POLL */
 static inline unsigned long net_busy_loop_on(void)
 {
        return 0;
@@ -162,11 +162,6 @@ static inline bool sk_can_busy_loop(struct sock *sk)
        return false;
 }
 
-static inline bool sk_busy_poll(struct sock *sk, int nonblock)
-{
-       return false;
-}
-
 static inline void skb_mark_napi_id(struct sk_buff *skb,
                                    struct napi_struct *napi)
 {
@@ -181,5 +176,10 @@ static inline bool busy_loop_timeout(unsigned long end_time)
        return true;
 }
 
-#endif /* CONFIG_NET_LL_RX_POLL */
+static inline bool sk_busy_loop(struct sock *sk, int nonblock)
+{
+       return false;
+}
+
+#endif /* CONFIG_NET_RX_BUSY_POLL */
 #endif /* _LINUX_NET_BUSY_POLL_H */
index d530c54a366286f2baccab70be91e68985ebebbb..cb710913d5c8db68e20bd3cca10f72710d1ef1ae 100644 (file)
@@ -2967,7 +2967,7 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv);
  *
  * Return: A non-negative wiphy index or a negative error code.
  */
-extern int wiphy_register(struct wiphy *wiphy);
+int wiphy_register(struct wiphy *wiphy);
 
 /**
  * wiphy_unregister - deregister a wiphy from cfg80211
@@ -2978,14 +2978,14 @@ extern int wiphy_register(struct wiphy *wiphy);
  * pointer, but the call may sleep to wait for an outstanding
  * request that is being handled.
  */
-extern void wiphy_unregister(struct wiphy *wiphy);
+void wiphy_unregister(struct wiphy *wiphy);
 
 /**
  * wiphy_free - free wiphy
  *
  * @wiphy: The wiphy to free
  */
-extern void wiphy_free(struct wiphy *wiphy);
+void wiphy_free(struct wiphy *wiphy);
 
 /* internal structs */
 struct cfg80211_conn;
@@ -3140,14 +3140,14 @@ static inline void *wdev_priv(struct wireless_dev *wdev)
  * @band: band, necessary due to channel number overlap
  * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
  */
-extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band);
+int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band);
 
 /**
  * ieee80211_frequency_to_channel - convert frequency to channel number
  * @freq: center frequency
  * Return: The corresponding channel, or 0 if the conversion failed.
  */
-extern int ieee80211_frequency_to_channel(int freq);
+int ieee80211_frequency_to_channel(int freq);
 
 /*
  * Name indirection necessary because the ieee80211 code also has
@@ -3156,8 +3156,8 @@ extern int ieee80211_frequency_to_channel(int freq);
  * to include both header files you'll (rightfully!) get a symbol
  * clash.
  */
-extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
-                                                        int freq);
+struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
+                                                 int freq);
 /**
  * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  * @wiphy: the struct wiphy to get the channel for
@@ -3269,13 +3269,14 @@ struct ieee80211_radiotap_iterator {
        int _reset_on_ext;
 };
 
-extern int ieee80211_radiotap_iterator_init(
-       struct ieee80211_radiotap_iterator *iterator,
-       struct ieee80211_radiotap_header *radiotap_header,
-       int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns);
+int
+ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
+                                struct ieee80211_radiotap_header *radiotap_header,
+                                int max_length,
+                                const struct ieee80211_radiotap_vendor_namespaces *vns);
 
-extern int ieee80211_radiotap_iterator_next(
-       struct ieee80211_radiotap_iterator *iterator);
+int
+ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
 
 
 extern const unsigned char rfc1042_header[6];
@@ -3435,7 +3436,7 @@ const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type,
  *
  * Return: 0 on success. -ENOMEM.
  */
-extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
+int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
 
 /**
  * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
@@ -3449,9 +3450,8 @@ extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  * default channel settings will be disregarded. If no rule is found for a
  * channel on the regulatory domain the channel will be disabled.
  */
-extern void wiphy_apply_custom_regulatory(
-       struct wiphy *wiphy,
-       const struct ieee80211_regdomain *regd);
+void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
+                                  const struct ieee80211_regdomain *regd);
 
 /**
  * freq_reg_info - get regulatory information for the given frequency
index 600d1d705bb86f23b00a8d0feebabe6ea303934d..8f59ca50477c6424c6a21d8a5f5ca60af62c7d32 100644 (file)
@@ -107,11 +107,11 @@ static inline void csum_replace2(__sum16 *sum, __be16 from, __be16 to)
 }
 
 struct sk_buff;
-extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
-                                    __be32 from, __be32 to, int pseudohdr);
-extern void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
-                                     const __be32 *from, const __be32 *to,
-                                     int pseudohdr);
+void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
+                             __be32 from, __be32 to, int pseudohdr);
+void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
+                              const __be32 *from, const __be32 *to,
+                              int pseudohdr);
 
 static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb,
                                            __be16 from, __be16 to,
index 0fee0617fb7d243728583ee351de284f36aca14a..f55c14510bd60e06930e1f95850b0d9ea6d38649 100644 (file)
@@ -24,7 +24,7 @@ struct cgroup_cls_state
        u32 classid;
 };
 
-extern void sock_update_classid(struct sock *sk);
+void sock_update_classid(struct sock *sk);
 
 #if IS_BUILTIN(CONFIG_NET_CLS_CGROUP)
 static inline u32 task_cls_classid(struct task_struct *p)
index e361f4882426d26fa8e21dd20e9a6a285c578546..4b2b557fb0e8c2d709e1733a13e4ca3dbc02ff0e 100644 (file)
 
 struct fib_rule {
        struct list_head        list;
-       atomic_t                refcnt;
        int                     iifindex;
        int                     oifindex;
        u32                     mark;
        u32                     mark_mask;
-       u32                     pref;
        u32                     flags;
        u32                     table;
        u8                      action;
+       /* 3 bytes hole, try to use */
        u32                     target;
        struct fib_rule __rcu   *ctarget;
+       struct net              *fr_net;
+
+       atomic_t                refcnt;
+       u32                     pref;
+       int                     suppress_ifgroup;
+       int                     suppress_prefixlen;
        char                    iifname[IFNAMSIZ];
        char                    oifname[IFNAMSIZ];
        struct rcu_head         rcu;
-       struct net *            fr_net;
 };
 
 struct fib_lookup_arg {
@@ -46,6 +50,8 @@ struct fib_rules_ops {
        int                     (*action)(struct fib_rule *,
                                          struct flowi *, int,
                                          struct fib_lookup_arg *);
+       bool                    (*suppress)(struct fib_rule *,
+                                           struct fib_lookup_arg *);
        int                     (*match)(struct fib_rule *,
                                         struct flowi *, int);
        int                     (*configure)(struct fib_rule *,
@@ -80,6 +86,8 @@ struct fib_rules_ops {
        [FRA_FWMARK]    = { .type = NLA_U32 }, \
        [FRA_FWMASK]    = { .type = NLA_U32 }, \
        [FRA_TABLE]     = { .type = NLA_U32 }, \
+       [FRA_SUPPRESS_PREFIXLEN] = { .type = NLA_U32 }, \
+       [FRA_SUPPRESS_IFGROUP] = { .type = NLA_U32 }, \
        [FRA_GOTO]      = { .type = NLA_U32 }
 
 static inline void fib_rule_get(struct fib_rule *rule)
index 2a601e7da1bfc8b97490075531975dcdfebc8370..48ec25a7fcb60a09a2c323c70221a31853a82261 100644 (file)
@@ -300,7 +300,7 @@ extern void                 inet6_rt_notify(int event, struct rt6_info *rt,
                                                struct nl_info *info);
 
 extern void                    fib6_run_gc(unsigned long expires,
-                                           struct net *net);
+                                           struct net *net, bool force);
 
 extern void                    fib6_gc_cleanup(void);
 
index 260f83f16bcfb3e79f2572604fc373c1830e2310..f667248202b6be9aacd3dc51f93eb43c9936a217 100644 (file)
@@ -135,6 +135,8 @@ extern void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,
 extern void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk,
                               __be32 mtu);
 extern void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark);
+extern void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
+                                  u32 mark);
 extern void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk);
 
 struct netlink_callback;
index 4da5de10d1d49f62bbbe33e770e4c95f2b5c9ddd..2265b0bf97e523817ea307d554451c4cebe4fc58 100644 (file)
@@ -36,6 +36,7 @@ struct __ip6_tnl_parm {
 struct ip6_tnl {
        struct ip6_tnl __rcu *next;     /* next tunnel in list */
        struct net_device *dev; /* virtual device associated with tunnel */
+       struct net *net;        /* netns for packet i/o */
        struct __ip6_tnl_parm parms;    /* tunnel configuration parameters */
        struct flowi fl;        /* flowi template for xmit */
        struct dst_entry *dst_cache;    /* cached dst */
index 781b3cf86a2f534ff71e03037b7984a0e84a8c8e..0ce316bb3c65c4f7725c24d8963dd306ba23ced6 100644 (file)
@@ -86,12 +86,12 @@ struct tnl_ptk_info {
 #define PACKET_RCVD    0
 #define PACKET_REJECT  1
 
-#define IP_TNL_HASH_BITS   10
+#define IP_TNL_HASH_BITS   7
 #define IP_TNL_HASH_SIZE   (1 << IP_TNL_HASH_BITS)
 
 struct ip_tunnel_net {
-       struct hlist_head *tunnels;
        struct net_device *fb_tunnel_dev;
+       struct hlist_head tunnels[IP_TNL_HASH_SIZE];
 };
 
 #ifdef CONFIG_INET
@@ -102,7 +102,7 @@ void  ip_tunnel_dellink(struct net_device *dev, struct list_head *head);
 int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
                       struct rtnl_link_ops *ops, char *devname);
 
-void ip_tunnel_delete_net(struct ip_tunnel_net *itn);
+void ip_tunnel_delete_net(struct ip_tunnel_net *itn, struct rtnl_link_ops *ops);
 
 void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
                    const struct iphdr *tnl_params, const u8 protocol);
@@ -145,20 +145,6 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,
        return INET_ECN_encapsulate(tos, inner);
 }
 
-static inline void tunnel_ip_select_ident(struct sk_buff *skb,
-                                         const struct iphdr  *old_iph,
-                                         struct dst_entry *dst)
-{
-       struct iphdr *iph = ip_hdr(skb);
-
-       /* Use inner packet iph-id if possible. */
-       if (skb->protocol == htons(ETH_P_IP) && old_iph->id)
-               iph->id = old_iph->id;
-       else
-               __ip_select_ident(iph, dst,
-                                 (skb_shinfo(skb)->gso_segs ?: 1) - 1);
-}
-
 int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
 int iptunnel_xmit(struct net *net, struct rtable *rt,
                  struct sk_buff *skb,
index 5fe5649851713e7858a2d016988cbe175ea7eaa6..7bdff0455065655fe55ae6e6761ee6beb9dd0818 100644 (file)
@@ -41,6 +41,7 @@
 #define NEXTHDR_ICMP           58      /* ICMP for IPv6. */
 #define NEXTHDR_NONE           59      /* No next header */
 #define NEXTHDR_DEST           60      /* Destination options header. */
+#define NEXTHDR_SCTP           132     /* SCTP message. */
 #define NEXTHDR_MOBILITY       135     /* Mobility header. */
 
 #define NEXTHDR_MAX            255
index 0af8b8dfbc227898badec117e2abe759889f8a20..550c2d6ec7ffefdaaf40c528042d19d8955bf090 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
+#include <linux/if_ether.h>
 
 #include <net/irda/irttp.h>
 
@@ -161,7 +162,7 @@ struct irlan_provider_cb {
        int access_type;     /* Access type */
        __u16 send_arb_val;
 
-       __u8 mac_address[6]; /* Generated MAC address for peer device */
+       __u8 mac_address[ETH_ALEN]; /* Generated MAC address for peer device */
 };
 
 /*
index 4be8785332b10df67668739242cccfa12890446f..cc6035f1a2f11c1b68f5a82235d4698441e8cddd 100644 (file)
@@ -2914,14 +2914,14 @@ enum ieee80211_tpt_led_trigger_flags {
 };
 
 #ifdef CONFIG_MAC80211_LEDS
-extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
-extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
-extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
-extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
-extern char *__ieee80211_create_tpt_led_trigger(
-                               struct ieee80211_hw *hw, unsigned int flags,
-                               const struct ieee80211_tpt_blink *blink_table,
-                               unsigned int blink_table_len);
+char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
+char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
+char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
+char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
+char *__ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
+                                        unsigned int flags,
+                                        const struct ieee80211_tpt_blink *blink_table,
+                                        unsigned int blink_table_len);
 #endif
 /**
  * ieee80211_get_tx_led_name - get name of TX LED
index 949d77528f2f9cd87839029b424bded13cb52136..6fea32340ae8a5c697a18b7909c9b44d86cddeaf 100644 (file)
@@ -119,7 +119,7 @@ extern struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
  * if RFC 3831 IPv6-over-Fibre Channel is ever implemented it may
  * also need a pad of 2.
  */
-static int ndisc_addr_option_pad(unsigned short type)
+static inline int ndisc_addr_option_pad(unsigned short type)
 {
        switch (type) {
        case ARPHRD_INFINIBAND: return 2;
index 7e748ad8b50c71900bdcedaf09a8c69e41f567a3..536501a3e58d861211656b87ec2e0e9b0e4f9a47 100644 (file)
@@ -195,68 +195,67 @@ static inline void *neighbour_priv(const struct neighbour *n)
 #define NEIGH_UPDATE_F_ISROUTER                        0x40000000
 #define NEIGH_UPDATE_F_ADMIN                   0x80000000
 
-extern void                    neigh_table_init(struct neigh_table *tbl);
-extern int                     neigh_table_clear(struct neigh_table *tbl);
-extern struct neighbour *      neigh_lookup(struct neigh_table *tbl,
-                                            const void *pkey,
-                                            struct net_device *dev);
-extern struct neighbour *      neigh_lookup_nodev(struct neigh_table *tbl,
-                                                  struct net *net,
-                                                  const void *pkey);
-extern struct neighbour *      __neigh_create(struct neigh_table *tbl,
-                                              const void *pkey,
-                                              struct net_device *dev,
-                                              bool want_ref);
+void neigh_table_init(struct neigh_table *tbl);
+int neigh_table_clear(struct neigh_table *tbl);
+struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey,
+                              struct net_device *dev);
+struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net,
+                                    const void *pkey);
+struct neighbour *__neigh_create(struct neigh_table *tbl, const void *pkey,
+                                struct net_device *dev, bool want_ref);
 static inline struct neighbour *neigh_create(struct neigh_table *tbl,
                                             const void *pkey,
                                             struct net_device *dev)
 {
        return __neigh_create(tbl, pkey, dev, true);
 }
-extern void                    neigh_destroy(struct neighbour *neigh);
-extern int                     __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb);
-extern int                     neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, 
-                                            u32 flags);
-extern void                    neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
-extern int                     neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
-extern int                     neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
-extern int                     neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb);
-extern int                     neigh_compat_output(struct neighbour *neigh, struct sk_buff *skb);
-extern int                     neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb);
-extern struct neighbour        *neigh_event_ns(struct neigh_table *tbl,
+void neigh_destroy(struct neighbour *neigh);
+int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb);
+int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, u32 flags);
+void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
+int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
+int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
+int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb);
+int neigh_compat_output(struct neighbour *neigh, struct sk_buff *skb);
+int neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb);
+struct neighbour *neigh_event_ns(struct neigh_table *tbl,
                                                u8 *lladdr, void *saddr,
                                                struct net_device *dev);
 
-extern struct neigh_parms      *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl);
-extern void                    neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms);
+struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
+                                     struct neigh_table *tbl);
+void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms);
 
 static inline
-struct net                     *neigh_parms_net(const struct neigh_parms *parms)
+struct net *neigh_parms_net(const struct neigh_parms *parms)
 {
        return read_pnet(&parms->net);
 }
 
-extern unsigned long           neigh_rand_reach_time(unsigned long base);
+unsigned long neigh_rand_reach_time(unsigned long base);
 
-extern void                    pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
-                                              struct sk_buff *skb);
-extern struct pneigh_entry     *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat);
-extern struct pneigh_entry     *__pneigh_lookup(struct neigh_table *tbl,
-                                                struct net *net,
-                                                const void *key,
-                                                struct net_device *dev);
-extern int                     pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev);
+void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
+                   struct sk_buff *skb);
+struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net,
+                                  const void *key, struct net_device *dev,
+                                  int creat);
+struct pneigh_entry *__pneigh_lookup(struct neigh_table *tbl, struct net *net,
+                                    const void *key, struct net_device *dev);
+int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key,
+                 struct net_device *dev);
 
-static inline
-struct net                     *pneigh_net(const struct pneigh_entry *pneigh)
+static inline struct net *pneigh_net(const struct pneigh_entry *pneigh)
 {
        return read_pnet(&pneigh->net);
 }
 
-extern void neigh_app_ns(struct neighbour *n);
-extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
-extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct neighbour *));
-extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
+void neigh_app_ns(struct neighbour *n);
+void neigh_for_each(struct neigh_table *tbl,
+                   void (*cb)(struct neighbour *, void *), void *cookie);
+void __neigh_for_each_release(struct neigh_table *tbl,
+                             int (*cb)(struct neighbour *));
+void pneigh_for_each(struct neigh_table *tbl,
+                    void (*cb)(struct pneigh_entry *));
 
 struct neigh_seq_state {
        struct seq_net_private p;
@@ -270,15 +269,14 @@ struct neigh_seq_state {
 #define NEIGH_SEQ_IS_PNEIGH    0x00000002
 #define NEIGH_SEQ_SKIP_NOARP   0x00000004
 };
-extern void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *, unsigned int);
-extern void *neigh_seq_next(struct seq_file *, void *, loff_t *);
-extern void neigh_seq_stop(struct seq_file *, void *);
-
-extern int                     neigh_sysctl_register(struct net_device *dev, 
-                                                     struct neigh_parms *p,
-                                                     char *p_name,
-                                                     proc_handler *proc_handler);
-extern void                    neigh_sysctl_unregister(struct neigh_parms *p);
+void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *,
+                     unsigned int);
+void *neigh_seq_next(struct seq_file *, void *, loff_t *);
+void neigh_seq_stop(struct seq_file *, void *);
+
+int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
+                         char *p_name, proc_handler *proc_handler);
+void neigh_sysctl_unregister(struct neigh_parms *p);
 
 static inline void __neigh_parms_put(struct neigh_parms *parms)
 {
index 84e37b1ca9e17824ef33ac4fa7708d684f520edc..1313456a0994e03cab0859e7960773b0115f8652 100644 (file)
@@ -119,7 +119,6 @@ struct net {
        struct netns_ipvs       *ipvs;
 #endif
        struct sock             *diag_nlsk;
-       atomic_t                rt_genid;
        atomic_t                fnhe_genid;
 };
 
@@ -333,14 +332,42 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
 }
 #endif
 
-static inline int rt_genid(struct net *net)
+static inline int rt_genid_ipv4(struct net *net)
 {
-       return atomic_read(&net->rt_genid);
+       return atomic_read(&net->ipv4.rt_genid);
 }
 
-static inline void rt_genid_bump(struct net *net)
+static inline void rt_genid_bump_ipv4(struct net *net)
 {
-       atomic_inc(&net->rt_genid);
+       atomic_inc(&net->ipv4.rt_genid);
+}
+
+#if IS_ENABLED(CONFIG_IPV6)
+static inline int rt_genid_ipv6(struct net *net)
+{
+       return atomic_read(&net->ipv6.rt_genid);
+}
+
+static inline void rt_genid_bump_ipv6(struct net *net)
+{
+       atomic_inc(&net->ipv6.rt_genid);
+}
+#else
+static inline int rt_genid_ipv6(struct net *net)
+{
+       return 0;
+}
+
+static inline void rt_genid_bump_ipv6(struct net *net)
+{
+}
+#endif
+
+/* For callers who don't really care about whether it's IPv4 or IPv6 */
+static inline void rt_genid_bump_all(struct net *net)
+{
+       rt_genid_bump_ipv4(net);
+       rt_genid_bump_ipv6(net);
 }
 
 static inline int fnhe_genid(struct net *net)
index 644d9c223d249617291edce40d11c75cec6fd0fd..0c1288a50e8bde05d896ebf243d0b7c3a01deb11 100644 (file)
@@ -181,8 +181,7 @@ __nf_conntrack_find(struct net *net, u16 zone,
                    const struct nf_conntrack_tuple *tuple);
 
 extern int nf_conntrack_hash_check_insert(struct nf_conn *ct);
-extern void nf_ct_delete_from_lists(struct nf_conn *ct);
-extern void nf_ct_dying_timeout(struct nf_conn *ct);
+bool nf_ct_delete(struct nf_conn *ct, u32 pid, int report);
 
 extern void nf_conntrack_flush_report(struct net *net, u32 portid, int report);
 
@@ -235,7 +234,7 @@ static inline bool nf_ct_kill(struct nf_conn *ct)
 }
 
 /* These are for NAT.  Icky. */
-extern s16 (*nf_ct_nat_offset)(const struct nf_conn *ct,
+extern s32 (*nf_ct_nat_offset)(const struct nf_conn *ct,
                               enum ip_conntrack_dir dir,
                               u32 seq);
 
@@ -249,7 +248,9 @@ extern void nf_ct_untracked_status_or(unsigned long bits);
 
 /* Iterate over all conntracks: if iter returns true, it's deleted. */
 extern void
-nf_ct_iterate_cleanup(struct net *net, int (*iter)(struct nf_conn *i, void *data), void *data);
+nf_ct_iterate_cleanup(struct net *net,
+                     int (*iter)(struct nf_conn *i, void *data),
+                     void *data, u32 portid, int report);
 extern void nf_conntrack_free(struct nf_conn *ct);
 extern struct nf_conn *
 nf_conntrack_alloc(struct net *net, u16 zone,
index 977bc8a46444d12b960fd3646969a2e96ce064dd..ff95434e50ca4273e7e795e55f37134457cca69f 100644 (file)
@@ -10,6 +10,7 @@ enum nf_ct_ext_id {
 #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
        NF_CT_EXT_NAT,
 #endif
+       NF_CT_EXT_SEQADJ,
        NF_CT_EXT_ACCT,
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
        NF_CT_EXT_ECACHE,
@@ -25,18 +26,23 @@ enum nf_ct_ext_id {
 #endif
 #ifdef CONFIG_NF_CONNTRACK_LABELS
        NF_CT_EXT_LABELS,
+#endif
+#if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY)
+       NF_CT_EXT_SYNPROXY,
 #endif
        NF_CT_EXT_NUM,
 };
 
 #define NF_CT_EXT_HELPER_TYPE struct nf_conn_help
 #define NF_CT_EXT_NAT_TYPE struct nf_conn_nat
+#define NF_CT_EXT_SEQADJ_TYPE struct nf_conn_seqadj
 #define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
 #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache
 #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone
 #define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp
 #define NF_CT_EXT_TIMEOUT_TYPE struct nf_conn_timeout
 #define NF_CT_EXT_LABELS_TYPE struct nf_conn_labels
+#define NF_CT_EXT_SYNPROXY_TYPE struct nf_conn_synproxy
 
 /* Extensions: optional stuff which isn't permanently in struct. */
 struct nf_ct_ext {
index 914d8d9007981bd9b4cf7db67dc79ec78c6896d0..b411d7b17dec40a64cc41df315f6188004ac65fa 100644 (file)
@@ -148,17 +148,10 @@ extern int nf_ct_port_nlattr_tuple_size(void);
 extern const struct nla_policy nf_ct_port_nla_policy[];
 
 #ifdef CONFIG_SYSCTL
-#ifdef DEBUG_INVALID_PACKETS
 #define LOG_INVALID(net, proto)                                \
        ((net)->ct.sysctl_log_invalid == (proto) ||     \
         (net)->ct.sysctl_log_invalid == IPPROTO_RAW)
 #else
-#define LOG_INVALID(net, proto)                                \
-       (((net)->ct.sysctl_log_invalid == (proto) ||    \
-         (net)->ct.sysctl_log_invalid == IPPROTO_RAW)  \
-        && net_ratelimit())
-#endif
-#else
 static inline int LOG_INVALID(struct net *net, int proto) { return 0; }
 #endif /* CONFIG_SYSCTL */
 
diff --git a/include/net/netfilter/nf_conntrack_seqadj.h b/include/net/netfilter/nf_conntrack_seqadj.h
new file mode 100644 (file)
index 0000000..f6177a5
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _NF_CONNTRACK_SEQADJ_H
+#define _NF_CONNTRACK_SEQADJ_H
+
+#include <net/netfilter/nf_conntrack_extend.h>
+
+/**
+ * struct nf_ct_seqadj - sequence number adjustment information
+ *
+ * @correction_pos: position of the last TCP sequence number modification
+ * @offset_before: sequence number offset before last modification
+ * @offset_after: sequence number offset after last modification
+ */
+struct nf_ct_seqadj {
+       u32             correction_pos;
+       s32             offset_before;
+       s32             offset_after;
+};
+
+struct nf_conn_seqadj {
+       struct nf_ct_seqadj     seq[IP_CT_DIR_MAX];
+};
+
+static inline struct nf_conn_seqadj *nfct_seqadj(const struct nf_conn *ct)
+{
+       return nf_ct_ext_find(ct, NF_CT_EXT_SEQADJ);
+}
+
+static inline struct nf_conn_seqadj *nfct_seqadj_ext_add(struct nf_conn *ct)
+{
+       return nf_ct_ext_add(ct, NF_CT_EXT_SEQADJ, GFP_ATOMIC);
+}
+
+extern int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                            s32 off);
+extern int nf_ct_seqadj_set(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                           __be32 seq, s32 off);
+extern void nf_ct_tcp_seqadj_set(struct sk_buff *skb,
+                                struct nf_conn *ct,
+                                enum ip_conntrack_info ctinfo,
+                                s32 off);
+
+extern int nf_ct_seq_adjust(struct sk_buff *skb,
+                           struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                           unsigned int protoff);
+extern s32 nf_ct_seq_offset(const struct nf_conn *ct, enum ip_conntrack_dir,
+                           u32 seq);
+
+extern int nf_conntrack_seqadj_init(void);
+extern void nf_conntrack_seqadj_fini(void);
+
+#endif /* _NF_CONNTRACK_SEQADJ_H */
diff --git a/include/net/netfilter/nf_conntrack_synproxy.h b/include/net/netfilter/nf_conntrack_synproxy.h
new file mode 100644 (file)
index 0000000..806f54a
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef _NF_CONNTRACK_SYNPROXY_H
+#define _NF_CONNTRACK_SYNPROXY_H
+
+#include <net/netns/generic.h>
+
+struct nf_conn_synproxy {
+       u32     isn;
+       u32     its;
+       u32     tsoff;
+};
+
+static inline struct nf_conn_synproxy *nfct_synproxy(const struct nf_conn *ct)
+{
+#if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY)
+       return nf_ct_ext_find(ct, NF_CT_EXT_SYNPROXY);
+#else
+       return NULL;
+#endif
+}
+
+static inline struct nf_conn_synproxy *nfct_synproxy_ext_add(struct nf_conn *ct)
+{
+#if IS_ENABLED(CONFIG_NETFILTER_SYNPROXY)
+       return nf_ct_ext_add(ct, NF_CT_EXT_SYNPROXY, GFP_ATOMIC);
+#else
+       return NULL;
+#endif
+}
+
+struct synproxy_stats {
+       unsigned int                    syn_received;
+       unsigned int                    cookie_invalid;
+       unsigned int                    cookie_valid;
+       unsigned int                    cookie_retrans;
+       unsigned int                    conn_reopened;
+};
+
+struct synproxy_net {
+       struct nf_conn                  *tmpl;
+       struct synproxy_stats __percpu  *stats;
+};
+
+extern int synproxy_net_id;
+static inline struct synproxy_net *synproxy_pernet(struct net *net)
+{
+       return net_generic(net, synproxy_net_id);
+}
+
+struct synproxy_options {
+       u8                              options;
+       u8                              wscale;
+       u16                             mss;
+       u32                             tsval;
+       u32                             tsecr;
+};
+
+struct tcphdr;
+struct xt_synproxy_info;
+extern void synproxy_parse_options(const struct sk_buff *skb, unsigned int doff,
+                                  const struct tcphdr *th,
+                                  struct synproxy_options *opts);
+extern unsigned int synproxy_options_size(const struct synproxy_options *opts);
+extern void synproxy_build_options(struct tcphdr *th,
+                                  const struct synproxy_options *opts);
+
+extern void synproxy_init_timestamp_cookie(const struct xt_synproxy_info *info,
+                                          struct synproxy_options *opts);
+extern void synproxy_check_timestamp_cookie(struct synproxy_options *opts);
+
+extern unsigned int synproxy_tstamp_adjust(struct sk_buff *skb,
+                                          unsigned int protoff,
+                                          struct tcphdr *th,
+                                          struct nf_conn *ct,
+                                          enum ip_conntrack_info ctinfo,
+                                          const struct nf_conn_synproxy *synproxy);
+
+#endif /* _NF_CONNTRACK_SYNPROXY_H */
index ad14a799fd2e50b153e47e80a9cd6fbc4235be7f..59a1924200536b9fc5847998b7129c8aefeb7060 100644 (file)
@@ -13,15 +13,6 @@ enum nf_nat_manip_type {
 #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \
                             (hooknum) != NF_INET_LOCAL_IN)
 
-/* NAT sequence number modifications */
-struct nf_nat_seq {
-       /* position of the last TCP sequence number modification (if any) */
-       u_int32_t correction_pos;
-
-       /* sequence number offset before and after last modification */
-       int16_t offset_before, offset_after;
-};
-
 #include <linux/list.h>
 #include <linux/netfilter/nf_conntrack_pptp.h>
 #include <net/netfilter/nf_conntrack_extend.h>
@@ -39,7 +30,6 @@ struct nf_conn;
 /* The structure embedded in the conntrack structure. */
 struct nf_conn_nat {
        struct hlist_node bysource;
-       struct nf_nat_seq seq[IP_CT_DIR_MAX];
        struct nf_conn *ct;
        union nf_conntrack_nat_help help;
 #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
index b4d6bfc2af034a32c1a5f9b847c91b99039cd868..404324d1d0c4c2a07cb14352ec8623a53b08b541 100644 (file)
@@ -39,28 +39,9 @@ extern int nf_nat_mangle_udp_packet(struct sk_buff *skb,
                                    const char *rep_buffer,
                                    unsigned int rep_len);
 
-extern void nf_nat_set_seq_adjust(struct nf_conn *ct,
-                                 enum ip_conntrack_info ctinfo,
-                                 __be32 seq, s16 off);
-extern int nf_nat_seq_adjust(struct sk_buff *skb,
-                            struct nf_conn *ct,
-                            enum ip_conntrack_info ctinfo,
-                            unsigned int protoff);
-extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb,
-                                    struct nf_conn *ct,
-                                    enum ip_conntrack_info ctinfo,
-                                    unsigned int protoff);
-
 /* Setup NAT on this expected conntrack so it follows master, but goes
  * to port ct->master->saved_proto. */
 extern void nf_nat_follow_master(struct nf_conn *ct,
                                 struct nf_conntrack_expect *this);
 
-extern s16 nf_nat_get_offset(const struct nf_conn *ct,
-                            enum ip_conntrack_dir dir,
-                            u32 seq);
-
-extern void nf_nat_tcp_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
-                                 u32 dir, int off);
-
 #endif
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h
deleted file mode 100644 (file)
index 36d9379..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-#ifndef _NF_TPROXY_CORE_H
-#define _NF_TPROXY_CORE_H
-
-#include <linux/types.h>
-#include <linux/in.h>
-#include <linux/skbuff.h>
-#include <net/sock.h>
-#include <net/inet_hashtables.h>
-#include <net/inet6_hashtables.h>
-#include <net/tcp.h>
-
-#define NFT_LOOKUP_ANY         0
-#define NFT_LOOKUP_LISTENER    1
-#define NFT_LOOKUP_ESTABLISHED 2
-
-/* look up and get a reference to a matching socket */
-
-
-/* This function is used by the 'TPROXY' target and the 'socket'
- * match. The following lookups are supported:
- *
- * Explicit TProxy target rule
- * ===========================
- *
- * This is used when the user wants to intercept a connection matching
- * an explicit iptables rule. In this case the sockets are assumed
- * matching in preference order:
- *
- *   - match: if there's a fully established connection matching the
- *     _packet_ tuple, it is returned, assuming the redirection
- *     already took place and we process a packet belonging to an
- *     established connection
- *
- *   - match: if there's a listening socket matching the redirection
- *     (e.g. on-port & on-ip of the connection), it is returned,
- *     regardless if it was bound to 0.0.0.0 or an explicit
- *     address. The reasoning is that if there's an explicit rule, it
- *     does not really matter if the listener is bound to an interface
- *     or to 0. The user already stated that he wants redirection
- *     (since he added the rule).
- *
- * "socket" match based redirection (no specific rule)
- * ===================================================
- *
- * There are connections with dynamic endpoints (e.g. FTP data
- * connection) that the user is unable to add explicit rules
- * for. These are taken care of by a generic "socket" rule. It is
- * assumed that the proxy application is trusted to open such
- * connections without explicit iptables rule (except of course the
- * generic 'socket' rule). In this case the following sockets are
- * matched in preference order:
- *
- *   - match: if there's a fully established connection matching the
- *     _packet_ tuple
- *
- *   - match: if there's a non-zero bound listener (possibly with a
- *     non-local address) We don't accept zero-bound listeners, since
- *     then local services could intercept traffic going through the
- *     box.
- *
- * Please note that there's an overlap between what a TPROXY target
- * and a socket match will match. Normally if you have both rules the
- * "socket" match will be the first one, effectively all packets
- * belonging to established connections going through that one.
- */
-static inline struct sock *
-nf_tproxy_get_sock_v4(struct net *net, const u8 protocol,
-                     const __be32 saddr, const __be32 daddr,
-                     const __be16 sport, const __be16 dport,
-                     const struct net_device *in, int lookup_type)
-{
-       struct sock *sk;
-
-       /* look up socket */
-       switch (protocol) {
-       case IPPROTO_TCP:
-               switch (lookup_type) {
-               case NFT_LOOKUP_ANY:
-                       sk = __inet_lookup(net, &tcp_hashinfo,
-                                          saddr, sport, daddr, dport,
-                                          in->ifindex);
-                       break;
-               case NFT_LOOKUP_LISTENER:
-                       sk = inet_lookup_listener(net, &tcp_hashinfo,
-                                                   saddr, sport,
-                                                   daddr, dport,
-                                                   in->ifindex);
-
-                       /* NOTE: we return listeners even if bound to
-                        * 0.0.0.0, those are filtered out in
-                        * xt_socket, since xt_TPROXY needs 0 bound
-                        * listeners too */
-
-                       break;
-               case NFT_LOOKUP_ESTABLISHED:
-                       sk = inet_lookup_established(net, &tcp_hashinfo,
-                                                   saddr, sport, daddr, dport,
-                                                   in->ifindex);
-                       break;
-               default:
-                       WARN_ON(1);
-                       sk = NULL;
-                       break;
-               }
-               break;
-       case IPPROTO_UDP:
-               sk = udp4_lib_lookup(net, saddr, sport, daddr, dport,
-                                    in->ifindex);
-               if (sk && lookup_type != NFT_LOOKUP_ANY) {
-                       int connected = (sk->sk_state == TCP_ESTABLISHED);
-                       int wildcard = (inet_sk(sk)->inet_rcv_saddr == 0);
-
-                       /* NOTE: we return listeners even if bound to
-                        * 0.0.0.0, those are filtered out in
-                        * xt_socket, since xt_TPROXY needs 0 bound
-                        * listeners too */
-                       if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
-                           (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
-                               sock_put(sk);
-                               sk = NULL;
-                       }
-               }
-               break;
-       default:
-               WARN_ON(1);
-               sk = NULL;
-       }
-
-       pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n",
-                protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk);
-
-       return sk;
-}
-
-#if IS_ENABLED(CONFIG_IPV6)
-static inline struct sock *
-nf_tproxy_get_sock_v6(struct net *net, const u8 protocol,
-                     const struct in6_addr *saddr, const struct in6_addr *daddr,
-                     const __be16 sport, const __be16 dport,
-                     const struct net_device *in, int lookup_type)
-{
-       struct sock *sk;
-
-       /* look up socket */
-       switch (protocol) {
-       case IPPROTO_TCP:
-               switch (lookup_type) {
-               case NFT_LOOKUP_ANY:
-                       sk = inet6_lookup(net, &tcp_hashinfo,
-                                         saddr, sport, daddr, dport,
-                                         in->ifindex);
-                       break;
-               case NFT_LOOKUP_LISTENER:
-                       sk = inet6_lookup_listener(net, &tcp_hashinfo,
-                                                  saddr, sport,
-                                                  daddr, ntohs(dport),
-                                                  in->ifindex);
-
-                       /* NOTE: we return listeners even if bound to
-                        * 0.0.0.0, those are filtered out in
-                        * xt_socket, since xt_TPROXY needs 0 bound
-                        * listeners too */
-
-                       break;
-               case NFT_LOOKUP_ESTABLISHED:
-                       sk = __inet6_lookup_established(net, &tcp_hashinfo,
-                                                       saddr, sport, daddr, ntohs(dport),
-                                                       in->ifindex);
-                       break;
-               default:
-                       WARN_ON(1);
-                       sk = NULL;
-                       break;
-               }
-               break;
-       case IPPROTO_UDP:
-               sk = udp6_lib_lookup(net, saddr, sport, daddr, dport,
-                                    in->ifindex);
-               if (sk && lookup_type != NFT_LOOKUP_ANY) {
-                       int connected = (sk->sk_state == TCP_ESTABLISHED);
-                       int wildcard = ipv6_addr_any(&inet6_sk(sk)->rcv_saddr);
-
-                       /* NOTE: we return listeners even if bound to
-                        * 0.0.0.0, those are filtered out in
-                        * xt_socket, since xt_TPROXY needs 0 bound
-                        * listeners too */
-                       if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
-                           (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
-                               sock_put(sk);
-                               sk = NULL;
-                       }
-               }
-               break;
-       default:
-               WARN_ON(1);
-               sk = NULL;
-       }
-
-       pr_debug("tproxy socket lookup: proto %u %pI6:%u -> %pI6:%u, lookup type: %d, sock %p\n",
-                protocol, saddr, ntohs(sport), daddr, ntohs(dport), lookup_type, sk);
-
-       return sk;
-}
-#endif
-
-/* assign a socket to the skb -- consumes sk */
-void
-nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk);
-
-#endif
index 86267a529514e2f1ca0e181df54fe62f5a1e0863..aff88ba9139121445bfca2169e3f39b71f354fa6 100644 (file)
@@ -15,6 +15,8 @@ int nfqnl_ct_put(struct sk_buff *skb, struct nf_conn *ct,
                 enum ip_conntrack_info ctinfo);
 void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
                         enum ip_conntrack_info ctinfo, int diff);
+int nfqnl_attach_expect(struct nf_conn *ct, const struct nlattr *attr,
+                       u32 portid, u32 report);
 #else
 inline struct nf_conn *
 nfqnl_ct_get(struct sk_buff *entskb, size_t *size, enum ip_conntrack_info *ctinfo)
@@ -39,5 +41,11 @@ inline void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
                                enum ip_conntrack_info ctinfo, int diff)
 {
 }
+
+inline int nfqnl_attach_expect(struct nf_conn *ct, const struct nlattr *attr,
+                              u32 portid, u32 report)
+{
+       return 0;
+}
 #endif /* NF_CONNTRACK */
 #endif
index 2ba9de89e8ec778990e8b2ff5183fd3e97eee1aa..bf2ec2202c5698b1bb73e22df60b4a3bc9d95c01 100644 (file)
@@ -77,5 +77,6 @@ struct netns_ipv4 {
        struct fib_rules_ops    *mr_rules_ops;
 #endif
 #endif
+       atomic_t        rt_genid;
 };
 #endif
index 005e2c2e39a9022bad13f4205343263f1821cb22..0fb2401197c51ecf9dd041066975cf5f0bb6a264 100644 (file)
@@ -72,6 +72,7 @@ struct netns_ipv6 {
 #endif
 #endif
        atomic_t                dev_addr_genid;
+       atomic_t                rt_genid;
 };
 
 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
index 50ab8c26ab59b7ebe840e50d6f696d16f32969b8..379dd5db0f2f3d08955a2632c90a0d9633732c31 100644 (file)
@@ -29,7 +29,7 @@ struct cgroup_netprio_state {
        struct cgroup_subsys_state css;
 };
 
-extern void sock_update_netprioidx(struct sock *sk);
+void sock_update_netprioidx(struct sock *sk);
 
 #if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
 
index 13174509cdfd38485a48f6fb1055f285a7306936..2ebef77a2f9a39e770237c19ebf2a7bc7bd324f3 100644 (file)
@@ -14,8 +14,8 @@ struct tcf_walker {
        int     (*fn)(struct tcf_proto *, unsigned long node, struct tcf_walker *);
 };
 
-extern int register_tcf_proto_ops(struct tcf_proto_ops *ops);
-extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
+int register_tcf_proto_ops(struct tcf_proto_ops *ops);
+int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
 
 static inline unsigned long
 __cls_set_class(unsigned long *clp, unsigned long cl)
@@ -126,17 +126,17 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
        return 0;
 }
 
-extern int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
-                            struct nlattr **tb, struct nlattr *rate_tlv,
-                            struct tcf_exts *exts,
-                            const struct tcf_ext_map *map);
-extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts);
-extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
-                            struct tcf_exts *src);
-extern int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
-                        const struct tcf_ext_map *map);
-extern int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
-                              const struct tcf_ext_map *map);
+int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
+                     struct nlattr **tb, struct nlattr *rate_tlv,
+                     struct tcf_exts *exts,
+                     const struct tcf_ext_map *map);
+void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts);
+void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
+                    struct tcf_exts *src);
+int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
+                 const struct tcf_ext_map *map);
+int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
+                       const struct tcf_ext_map *map);
 
 /**
  * struct tcf_pkt_info - packet information
@@ -239,14 +239,14 @@ struct tcf_ematch_ops {
        struct list_head        link;
 };
 
-extern int tcf_em_register(struct tcf_ematch_ops *);
-extern void tcf_em_unregister(struct tcf_ematch_ops *);
-extern int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *,
-                               struct tcf_ematch_tree *);
-extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *);
-extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int);
-extern int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *,
-                              struct tcf_pkt_info *);
+int tcf_em_register(struct tcf_ematch_ops *);
+void tcf_em_unregister(struct tcf_ematch_ops *);
+int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *,
+                        struct tcf_ematch_tree *);
+void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *);
+int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int);
+int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *,
+                       struct tcf_pkt_info *);
 
 /**
  * tcf_em_tree_change - replace ematch tree of a running classifier
index 388bf8b6d06068558726943fa58d44a91ab01374..f7c24f8fbdc5c61208a26a11123f33d4d6d385df 100644 (file)
@@ -64,8 +64,8 @@ struct qdisc_watchdog {
        struct Qdisc    *qdisc;
 };
 
-extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
-extern void qdisc_watchdog_schedule_ns(struct qdisc_watchdog *wd, u64 expires);
+void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
+void qdisc_watchdog_schedule_ns(struct qdisc_watchdog *wd, u64 expires);
 
 static inline void qdisc_watchdog_schedule(struct qdisc_watchdog *wd,
                                           psched_time_t expires)
@@ -73,31 +73,31 @@ static inline void qdisc_watchdog_schedule(struct qdisc_watchdog *wd,
        qdisc_watchdog_schedule_ns(wd, PSCHED_TICKS2NS(expires));
 }
 
-extern void qdisc_watchdog_cancel(struct qdisc_watchdog *wd);
+void qdisc_watchdog_cancel(struct qdisc_watchdog *wd);
 
 extern struct Qdisc_ops pfifo_qdisc_ops;
 extern struct Qdisc_ops bfifo_qdisc_ops;
 extern struct Qdisc_ops pfifo_head_drop_qdisc_ops;
 
-extern int fifo_set_limit(struct Qdisc *q, unsigned int limit);
-extern struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
-                                     unsigned int limit);
-
-extern int register_qdisc(struct Qdisc_ops *qops);
-extern int unregister_qdisc(struct Qdisc_ops *qops);
-extern void qdisc_list_del(struct Qdisc *q);
-extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
-extern struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle);
-extern struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r,
-               struct nlattr *tab);
-extern void qdisc_put_rtab(struct qdisc_rate_table *tab);
-extern void qdisc_put_stab(struct qdisc_size_table *tab);
-extern void qdisc_warn_nonwc(char *txt, struct Qdisc *qdisc);
-extern int sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
-                          struct net_device *dev, struct netdev_queue *txq,
-                          spinlock_t *root_lock);
-
-extern void __qdisc_run(struct Qdisc *q);
+int fifo_set_limit(struct Qdisc *q, unsigned int limit);
+struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
+                              unsigned int limit);
+
+int register_qdisc(struct Qdisc_ops *qops);
+int unregister_qdisc(struct Qdisc_ops *qops);
+void qdisc_list_del(struct Qdisc *q);
+struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
+struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle);
+struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r,
+                                       struct nlattr *tab);
+void qdisc_put_rtab(struct qdisc_rate_table *tab);
+void qdisc_put_stab(struct qdisc_size_table *tab);
+void qdisc_warn_nonwc(char *txt, struct Qdisc *qdisc);
+int sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
+                   struct net_device *dev, struct netdev_queue *txq,
+                   spinlock_t *root_lock);
+
+void __qdisc_run(struct Qdisc *q);
 
 static inline void qdisc_run(struct Qdisc *q)
 {
@@ -105,10 +105,10 @@ static inline void qdisc_run(struct Qdisc *q)
                __qdisc_run(q);
 }
 
-extern int tc_classify_compat(struct sk_buff *skb, const struct tcf_proto *tp,
-                             struct tcf_result *res);
-extern int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
+int tc_classify_compat(struct sk_buff *skb, const struct tcf_proto *tp,
                       struct tcf_result *res);
+int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
+               struct tcf_result *res);
 
 /* Calculate maximal size of packet seen by hard_start_xmit
    routine of this device.
index 6eab63363e59fe82dc3fc6119633e5583b663dd1..76368c9d4503c124df44a5ed56fc942782209db8 100644 (file)
@@ -350,30 +350,32 @@ qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id)
        return NULL;
 }
 
-extern int qdisc_class_hash_init(struct Qdisc_class_hash *);
-extern void qdisc_class_hash_insert(struct Qdisc_class_hash *, struct Qdisc_class_common *);
-extern void qdisc_class_hash_remove(struct Qdisc_class_hash *, struct Qdisc_class_common *);
-extern void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
-extern void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
-
-extern void dev_init_scheduler(struct net_device *dev);
-extern void dev_shutdown(struct net_device *dev);
-extern void dev_activate(struct net_device *dev);
-extern void dev_deactivate(struct net_device *dev);
-extern void dev_deactivate_many(struct list_head *head);
-extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
-                                    struct Qdisc *qdisc);
-extern void qdisc_reset(struct Qdisc *qdisc);
-extern void qdisc_destroy(struct Qdisc *qdisc);
-extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
-extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
-                                struct Qdisc_ops *ops);
-extern struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
-                                      struct Qdisc_ops *ops, u32 parentid);
-extern void __qdisc_calculate_pkt_len(struct sk_buff *skb,
-                                     const struct qdisc_size_table *stab);
-extern void tcf_destroy(struct tcf_proto *tp);
-extern void tcf_destroy_chain(struct tcf_proto **fl);
+int qdisc_class_hash_init(struct Qdisc_class_hash *);
+void qdisc_class_hash_insert(struct Qdisc_class_hash *,
+                            struct Qdisc_class_common *);
+void qdisc_class_hash_remove(struct Qdisc_class_hash *,
+                            struct Qdisc_class_common *);
+void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
+void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
+
+void dev_init_scheduler(struct net_device *dev);
+void dev_shutdown(struct net_device *dev);
+void dev_activate(struct net_device *dev);
+void dev_deactivate(struct net_device *dev);
+void dev_deactivate_many(struct list_head *head);
+struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
+                             struct Qdisc *qdisc);
+void qdisc_reset(struct Qdisc *qdisc);
+void qdisc_destroy(struct Qdisc *qdisc);
+void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
+struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
+                         struct Qdisc_ops *ops);
+struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
+                               struct Qdisc_ops *ops, u32 parentid);
+void __qdisc_calculate_pkt_len(struct sk_buff *skb,
+                              const struct qdisc_size_table *stab);
+void tcf_destroy(struct tcf_proto *tp);
+void tcf_destroy_chain(struct tcf_proto **fl);
 
 /* Reset all TX qdiscs greater then index of a device.  */
 static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
@@ -683,16 +685,23 @@ struct psched_ratecfg {
        u64     rate_bytes_ps; /* bytes per second */
        u32     mult;
        u16     overhead;
+       u8      linklayer;
        u8      shift;
 };
 
 static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
                                unsigned int len)
 {
-       return ((u64)(len + r->overhead) * r->mult) >> r->shift;
+       len += r->overhead;
+
+       if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
+               return ((u64)(DIV_ROUND_UP(len,48)*53) * r->mult) >> r->shift;
+
+       return ((u64)len * r->mult) >> r->shift;
 }
 
-extern void psched_ratecfg_precompute(struct psched_ratecfg *r, const struct tc_ratespec *conf);
+void psched_ratecfg_precompute(struct psched_ratecfg *r,
+                              const struct tc_ratespec *conf);
 
 static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
                                          const struct psched_ratecfg *r)
@@ -700,6 +709,7 @@ static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
        memset(res, 0, sizeof(*res));
        res->rate = r->rate_bytes_ps;
        res->overhead = r->overhead;
+       res->linklayer = (r->linklayer & TC_LINKLAYER_MASK);
 }
 
 #endif
index 49bc9577c61efbfcb8caf37e686def5f3de17c81..aa80bef3c9d5392b8cf472013c4f1da8f7de87f4 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *   Vlad Yasevich     <vladislav.yasevich@hp.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __sctp_auth_h__
index 0cb08e6fb6df9eacfbb94ac53e9b81f51ead993e..259924d63ba6a6f0ab71f52ed0f9e7a62c6bfe1b 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Dinakaran Joseph
@@ -37,9 +34,6 @@
  *
  * Rewritten to use libcrc32c by:
  *    Vlad Yasevich <vladislav.yasevich@hp.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __sctp_checksum_h__
@@ -85,4 +79,19 @@ static inline __le32 sctp_end_cksum(__u32 crc32)
        return cpu_to_le32(~crc32);
 }
 
+/* Calculate the CRC32C checksum of an SCTP packet.  */
+static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
+                                       unsigned int offset)
+{
+       const struct sk_buff *iter;
+
+       __u32 crc32 = sctp_start_cksum(skb->data + offset,
+                                      skb_headlen(skb) - offset);
+       skb_walk_frags(skb, iter)
+               crc32 = sctp_update_cksum((__u8 *) iter->data,
+                                         skb_headlen(iter), crc32);
+
+       return sctp_end_cksum(crc32);
+}
+
 #endif /* __sctp_checksum_h__ */
index 35247271e5571153110fa7759e6c24c13c1114aa..832f2191489c946bebd68ce8b6cdfa92c0086979 100644 (file)
  * the Free Software Foundation, 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
- * Please send any bug reports or fixes you make to one of the
- * following email addresses:
+ * Please send any bug reports or fixes you make to the
+ * email address(es):
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
- * La Monte H.P. Yarroll <piggy@acm.org>
- * Karl Knutson <karl@athena.chicago.il.us>
- * Ardelle Fan <ardelle.fan@intel.com>
- * Sridhar Samudrala <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
+ * Written or modified by:
+ *   La Monte H.P. Yarroll <piggy@acm.org>
+ *   Karl Knutson <karl@athena.chicago.il.us>
+ *   Ardelle Fan <ardelle.fan@intel.com>
+ *   Sridhar Samudrala <sri@us.ibm.com>
  */
 
-
 #ifndef __net_sctp_command_h__
 #define __net_sctp_command_h__
 
index ca50e0751e47aabda8beac5a8af9eeff07dc88db..2f0a565a0fd57ee6914b60512d531fb057729d83 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *   La Monte H.P. Yarroll <piggy@acm.org>
@@ -39,9 +36,6 @@
  *   Xingang Guo           <xingang.guo@intel.com>
  *   Sridhar Samudrala     <samudrala@us.ibm.com>
  *   Daisy Chang           <daisyc@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __sctp_constants_h__
index d8e37ecea691ae2cc9a578063e304167b36e5740..3794c5ad20fef72a960c34323dab275d6f26bac7 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -41,9 +38,6 @@
  *    Ardelle Fan           <ardelle.fan@intel.com>
  *    Ryan Layer            <rmlayer@us.ibm.com>
  *    Kevin Gao             <kevin.gao@intel.com> 
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __net_sctp_h__
@@ -613,7 +607,7 @@ static inline void sctp_v4_map_v6(union sctp_addr *addr)
  */
 static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t)
 {
-       if (t->dst && !dst_check(t->dst, 0)) {
+       if (t->dst && !dst_check(t->dst, t->dst_cookie)) {
                dst_release(t->dst);
                t->dst = NULL;
        }
index 2a82d1384706c61a6757db53edf8d81a53cbc7de..4ef75af340b633c7e8a5fabeb34dd88cdbd73ef2 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email addresses:
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -42,9 +39,6 @@
  *    Daisy Chang <daisyc@us.ibm.com>
  *    Ardelle Fan <ardelle.fan@intel.com>
  *    Kevin Gao <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
index e745c92a153241d6f261a646b40de71a82f2d98b..422db6cc3214b77264eccec4288ece4315f045e7 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email addresses:
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Randall Stewart      <randall@sctp.chicago.il.us>
@@ -46,9 +43,6 @@
  *    Ryan Layer           <rmlayer@us.ibm.com>
  *    Anup Pemmaiah        <pemmaiah@cc.usu.edu>
  *    Kevin Gao             <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __sctp_structs_h__
@@ -782,6 +776,7 @@ struct sctp_transport {
 
        /* Has this transport moved the ctsn since we last sacked */
        __u32 sack_generation;
+       u32 dst_cookie;
 
        struct flowi fl;
 
index 2c5d2b4d5d1eb51542df26094700250ab6191070..54bbbe547303cc8d37c88d736e9e95894e054a69 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *   Jon Grimm             <jgrimm@us.ibm.com>
  *   La Monte H.P. Yarroll <piggy@acm.org>
  *   Karl Knutson          <karl@athena.chicago.il.us>
  *   Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 #include <net/sctp/constants.h>
 
index ca4693b4e09e4bb879c0ef8e483247c913bffb6b..27b9f5c90153610e75d9a7023b808e5b61174c33 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *   Jon Grimm             <jgrimm@us.ibm.com>
  *   La Monte H.P. Yarroll <piggy@acm.org>
  *   Karl Knutson          <karl@athena.chicago.il.us>
  *   Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __sctp_ulpevent_h__
index 00e50ba3f24b71a2db54d810ee9889f674444a7b..b0cf5d54d717a553a9135044237c2db563253b23 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email addresses:
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *   Jon Grimm             <jgrimm@us.ibm.com>
  *   La Monte H.P. Yarroll <piggy@acm.org>
  *   Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #ifndef __sctp_ulpqueue_h__
index 95a5a2c6925ab0745b563f7f04663721465460e7..e4bbcbfd07ea4d15f0ef63f3d765d261d0c25a68 100644 (file)
@@ -327,7 +327,7 @@ struct sock {
 #ifdef CONFIG_RPS
        __u32                   sk_rxhash;
 #endif
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        unsigned int            sk_napi_id;
        unsigned int            sk_ll_usec;
 #endif
@@ -746,11 +746,6 @@ static inline int sk_stream_wspace(const struct sock *sk)
 
 extern void sk_stream_write_space(struct sock *sk);
 
-static inline bool sk_stream_memory_free(const struct sock *sk)
-{
-       return sk->sk_wmem_queued < sk->sk_sndbuf;
-}
-
 /* OOB backlog add */
 static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
 {
@@ -950,6 +945,7 @@ struct proto {
        unsigned int            inuse_idx;
 #endif
 
+       bool                    (*stream_memory_free)(const struct sock *sk);
        /* Memory pressure */
        void                    (*enter_memory_pressure)(struct sock *sk);
        atomic_long_t           *memory_allocated;      /* Current allocated memory. */
@@ -1088,6 +1084,21 @@ static inline struct cg_proto *parent_cg_proto(struct proto *proto,
 }
 #endif
 
+static inline bool sk_stream_memory_free(const struct sock *sk)
+{
+       if (sk->sk_wmem_queued >= sk->sk_sndbuf)
+               return false;
+
+       return sk->sk_prot->stream_memory_free ?
+               sk->sk_prot->stream_memory_free(sk) : true;
+}
+
+static inline bool sk_stream_is_writeable(const struct sock *sk)
+{
+       return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) &&
+              sk_stream_memory_free(sk);
+}
+
 
 static inline bool sk_has_memory_pressure(const struct sock *sk)
 {
@@ -1509,6 +1520,7 @@ extern struct sk_buff             *sock_rmalloc(struct sock *sk,
                                              unsigned long size, int force,
                                              gfp_t priority);
 extern void                    sock_wfree(struct sk_buff *skb);
+extern void                    skb_orphan_partial(struct sk_buff *skb);
 extern void                    sock_rfree(struct sk_buff *skb);
 extern void                    sock_edemux(struct sk_buff *skb);
 
@@ -1527,7 +1539,8 @@ extern struct sk_buff             *sock_alloc_send_pskb(struct sock *sk,
                                                      unsigned long header_len,
                                                      unsigned long data_len,
                                                      int noblock,
-                                                     int *errcode);
+                                                     int *errcode,
+                                                     int max_page_order);
 extern void *sock_kmalloc(struct sock *sk, int size,
                          gfp_t priority);
 extern void sock_kfree_s(struct sock *sk, void *mem, int size);
@@ -2249,6 +2262,8 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb)
 extern void sock_enable_timestamp(struct sock *sk, int flag);
 extern int sock_get_timestamp(struct sock *, struct timeval __user *);
 extern int sock_get_timestampns(struct sock *, struct timespec __user *);
+extern int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
+                             int level, int type);
 
 /*
  *     Enable debug/info messages
index d1980054ec75b92c716097c377478b02fdee3762..dd5e16f66f84809b63fde1019f83901fc39671c1 100644 (file)
@@ -192,10 +192,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
 #define TCPOLEN_TIMESTAMP      10
 #define TCPOLEN_MD5SIG         18
 #define TCPOLEN_EXP_FASTOPEN_BASE  4
-#define TCPOLEN_COOKIE_BASE    2       /* Cookie-less header extension */
-#define TCPOLEN_COOKIE_PAIR    3       /* Cookie pair header extension */
-#define TCPOLEN_COOKIE_MIN     (TCPOLEN_COOKIE_BASE+TCP_COOKIE_MIN)
-#define TCPOLEN_COOKIE_MAX     (TCPOLEN_COOKIE_BASE+TCP_COOKIE_MAX)
 
 /* But this is what stacks really send out. */
 #define TCPOLEN_TSTAMP_ALIGNED         12
@@ -284,6 +280,7 @@ extern int sysctl_tcp_thin_dupack;
 extern int sysctl_tcp_early_retrans;
 extern int sysctl_tcp_limit_output_bytes;
 extern int sysctl_tcp_challenge_ack_limit;
+extern unsigned int sysctl_tcp_notsent_lowat;
 
 extern atomic_long_t tcp_memory_allocated;
 extern struct percpu_counter tcp_sockets_allocated;
@@ -479,9 +476,13 @@ void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb);
 
 /* From syncookies.c */
 extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
+extern int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th,
+                            u32 cookie);
 extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 
                                    struct ip_options *opt);
 #ifdef CONFIG_SYN_COOKIES
+extern u32 __cookie_v4_init_sequence(const struct iphdr *iph,
+                                    const struct tcphdr *th, u16 *mssp);
 extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, 
                                     __u16 *mss);
 #else
@@ -498,8 +499,12 @@ extern bool cookie_check_timestamp(struct tcp_options_received *opt,
                                struct net *net, bool *ecn_ok);
 
 /* From net/ipv6/syncookies.c */
+extern int __cookie_v6_check(const struct ipv6hdr *iph, const struct tcphdr *th,
+                            u32 cookie);
 extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
 #ifdef CONFIG_SYN_COOKIES
+extern u32 __cookie_v6_init_sequence(const struct ipv6hdr *iph,
+                                    const struct tcphdr *th, u16 *mssp);
 extern __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb,
                                     __u16 *mss);
 #else
@@ -591,7 +596,6 @@ extern void tcp_initialize_rcv_mss(struct sock *sk);
 extern int tcp_mtu_to_mss(struct sock *sk, int pmtu);
 extern int tcp_mss_to_mtu(struct sock *sk, int mss);
 extern void tcp_mtup_init(struct sock *sk);
-extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt);
 extern void tcp_init_buffer_space(struct sock *sk);
 
 static inline void tcp_bound_rto(const struct sock *sk)
@@ -1094,15 +1098,6 @@ static inline void tcp_openreq_init(struct request_sock *req,
        ireq->loc_port = tcp_hdr(skb)->dest;
 }
 
-/* Compute time elapsed between SYNACK and the ACK completing 3WHS */
-static inline void tcp_synack_rtt_meas(struct sock *sk,
-                                      struct request_sock *req)
-{
-       if (tcp_rsk(req)->snt_synack)
-               tcp_valid_rtt_meas(sk,
-                   tcp_time_stamp - tcp_rsk(req)->snt_synack);
-}
-
 extern void tcp_enter_memory_pressure(struct sock *sk);
 
 static inline int keepalive_intvl_when(const struct tcp_sock *tp)
@@ -1313,7 +1308,8 @@ void tcp_free_fastopen_req(struct tcp_sock *tp);
 
 extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
 int tcp_fastopen_reset_cipher(void *key, unsigned int len);
-void tcp_fastopen_cookie_gen(__be32 addr, struct tcp_fastopen_cookie *foc);
+extern void tcp_fastopen_cookie_gen(__be32 src, __be32 dst,
+                                   struct tcp_fastopen_cookie *foc);
 
 #define TCP_FASTOPEN_KEY_LENGTH 16
 
@@ -1549,6 +1545,19 @@ extern int tcp_gro_complete(struct sk_buff *skb);
 extern void __tcp_v4_send_check(struct sk_buff *skb, __be32 saddr,
                                __be32 daddr);
 
+static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp)
+{
+       return tp->notsent_lowat ?: sysctl_tcp_notsent_lowat;
+}
+
+static inline bool tcp_stream_memory_free(const struct sock *sk)
+{
+       const struct tcp_sock *tp = tcp_sk(sk);
+       u32 notsent_bytes = tp->write_seq - tp->snd_nxt;
+
+       return notsent_bytes < tcp_notsent_lowat(tp);
+}
+
 #ifdef CONFIG_PROC_FS
 extern int tcp4_proc_init(void);
 extern void tcp4_proc_exit(void);
index 74c10ec5e74fa12c74801f48e2716ec2d9518588..ef2e0b7843a0036c1b31d8e67e78b624bf05f44f 100644 (file)
@@ -183,6 +183,7 @@ extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk,
                            struct msghdr *msg, size_t len);
 extern int udp_push_pending_frames(struct sock *sk);
 extern void udp_flush_pending_frames(struct sock *sk);
+extern void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst);
 extern int udp_rcv(struct sk_buff *skb);
 extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
 extern int udp_disconnect(struct sock *sk, int flags);
diff --git a/include/net/vsock_addr.h b/include/net/vsock_addr.h
new file mode 100644 (file)
index 0000000..9ccd531
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * VMware vSockets Driver
+ *
+ * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef _VSOCK_ADDR_H_
+#define _VSOCK_ADDR_H_
+
+#include <linux/vm_sockets.h>
+
+void vsock_addr_init(struct sockaddr_vm *addr, u32 cid, u32 port);
+int vsock_addr_validate(const struct sockaddr_vm *addr);
+bool vsock_addr_bound(const struct sockaddr_vm *addr);
+void vsock_addr_unbind(struct sockaddr_vm *addr);
+bool vsock_addr_equals_addr(const struct sockaddr_vm *addr,
+                           const struct sockaddr_vm *other);
+int vsock_addr_cast(const struct sockaddr *addr, size_t len,
+                   struct sockaddr_vm **out_addr);
+
+#endif
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
new file mode 100644 (file)
index 0000000..ad342e3
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef __NET_VXLAN_H
+#define __NET_VXLAN_H 1
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/udp.h>
+
+#define VNI_HASH_BITS  10
+#define VNI_HASH_SIZE  (1<<VNI_HASH_BITS)
+
+struct vxlan_sock;
+typedef void (vxlan_rcv_t)(struct vxlan_sock *vh, struct sk_buff *skb, __be32 key);
+
+/* per UDP socket information */
+struct vxlan_sock {
+       struct hlist_node hlist;
+       vxlan_rcv_t      *rcv;
+       void             *data;
+       struct work_struct del_work;
+       struct socket    *sock;
+       struct rcu_head   rcu;
+       struct hlist_head vni_list[VNI_HASH_SIZE];
+       atomic_t          refcnt;
+};
+
+struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
+                                 vxlan_rcv_t *rcv, void *data,
+                                 bool no_share);
+
+void vxlan_sock_release(struct vxlan_sock *vs);
+
+int vxlan_xmit_skb(struct net *net, struct vxlan_sock *vs,
+                  struct rtable *rt, struct sk_buff *skb,
+                  __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
+                  __be16 src_port, __be16 dst_port, __be32 vni);
+
+__be16 vxlan_src_port(__u16 port_min, __u16 port_max, struct sk_buff *skb);
+
+#endif
index 94ce082b29dcdba2d726cbc90a0c4510fd38fb2b..89d3d8ae204ec9f8e331862175b660d4377898e0 100644 (file)
@@ -1548,7 +1548,7 @@ struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8, int dir, u32
 int xfrm_policy_flush(struct net *net, u8 type, struct xfrm_audit *audit_info);
 u32 xfrm_get_acqseq(void);
 extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
-struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark,
+struct xfrm_state *xfrm_find_acq(struct net *net, const struct xfrm_mark *mark,
                                 u8 mode, u32 reqid, u8 proto,
                                 const xfrm_address_t *daddr,
                                 const xfrm_address_t *saddr, int create,
index 3cc5a0b278c30c2045152d358254d11f109c6a0d..5ebda976ea93bd52c6ca80194d723e49e94c1558 100644 (file)
@@ -9,9 +9,7 @@
 struct search;
 
 DECLARE_EVENT_CLASS(bcache_request,
-
        TP_PROTO(struct search *s, struct bio *bio),
-
        TP_ARGS(s, bio),
 
        TP_STRUCT__entry(
@@ -22,7 +20,6 @@ DECLARE_EVENT_CLASS(bcache_request,
                __field(dev_t,          orig_sector             )
                __field(unsigned int,   nr_sector               )
                __array(char,           rwbs,   6               )
-               __array(char,           comm,   TASK_COMM_LEN   )
        ),
 
        TP_fast_assign(
@@ -33,36 +30,66 @@ DECLARE_EVENT_CLASS(bcache_request,
                __entry->orig_sector    = bio->bi_sector - 16;
                __entry->nr_sector      = bio->bi_size >> 9;
                blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
        ),
 
-       TP_printk("%d,%d %s %llu + %u [%s] (from %d,%d @ %llu)",
+       TP_printk("%d,%d %s %llu + %u (from %d,%d @ %llu)",
                  MAJOR(__entry->dev), MINOR(__entry->dev),
-                 __entry->rwbs,
-                 (unsigned long long)__entry->sector,
-                 __entry->nr_sector, __entry->comm,
-                 __entry->orig_major, __entry->orig_minor,
+                 __entry->rwbs, (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->orig_major, __entry->orig_minor,
                  (unsigned long long)__entry->orig_sector)
 );
 
-DEFINE_EVENT(bcache_request, bcache_request_start,
+DECLARE_EVENT_CLASS(bkey,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k),
 
-       TP_PROTO(struct search *s, struct bio *bio),
+       TP_STRUCT__entry(
+               __field(u32,    size                            )
+               __field(u32,    inode                           )
+               __field(u64,    offset                          )
+               __field(bool,   dirty                           )
+       ),
 
-       TP_ARGS(s, bio)
+       TP_fast_assign(
+               __entry->inode  = KEY_INODE(k);
+               __entry->offset = KEY_OFFSET(k);
+               __entry->size   = KEY_SIZE(k);
+               __entry->dirty  = KEY_DIRTY(k);
+       ),
+
+       TP_printk("%u:%llu len %u dirty %u", __entry->inode,
+                 __entry->offset, __entry->size, __entry->dirty)
 );
 
-DEFINE_EVENT(bcache_request, bcache_request_end,
+DECLARE_EVENT_CLASS(btree_node,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b),
+
+       TP_STRUCT__entry(
+               __field(size_t,         bucket                  )
+       ),
 
+       TP_fast_assign(
+               __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
+       ),
+
+       TP_printk("bucket %zu", __entry->bucket)
+);
+
+/* request.c */
+
+DEFINE_EVENT(bcache_request, bcache_request_start,
        TP_PROTO(struct search *s, struct bio *bio),
+       TP_ARGS(s, bio)
+);
 
+DEFINE_EVENT(bcache_request, bcache_request_end,
+       TP_PROTO(struct search *s, struct bio *bio),
        TP_ARGS(s, bio)
 );
 
 DECLARE_EVENT_CLASS(bcache_bio,
-
        TP_PROTO(struct bio *bio),
-
        TP_ARGS(bio),
 
        TP_STRUCT__entry(
@@ -70,7 +97,6 @@ DECLARE_EVENT_CLASS(bcache_bio,
                __field(sector_t,       sector                  )
                __field(unsigned int,   nr_sector               )
                __array(char,           rwbs,   6               )
-               __array(char,           comm,   TASK_COMM_LEN   )
        ),
 
        TP_fast_assign(
@@ -78,191 +104,328 @@ DECLARE_EVENT_CLASS(bcache_bio,
                __entry->sector         = bio->bi_sector;
                __entry->nr_sector      = bio->bi_size >> 9;
                blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
        ),
 
-       TP_printk("%d,%d  %s %llu + %u [%s]",
-                 MAJOR(__entry->dev), MINOR(__entry->dev),
-                 __entry->rwbs,
-                 (unsigned long long)__entry->sector,
-                 __entry->nr_sector, __entry->comm)
+       TP_printk("%d,%d  %s %llu + %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector, __entry->nr_sector)
 );
 
-
-DEFINE_EVENT(bcache_bio, bcache_passthrough,
-
+DEFINE_EVENT(bcache_bio, bcache_bypass_sequential,
        TP_PROTO(struct bio *bio),
+       TP_ARGS(bio)
+);
 
+DEFINE_EVENT(bcache_bio, bcache_bypass_congested,
+       TP_PROTO(struct bio *bio),
        TP_ARGS(bio)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_cache_hit,
+TRACE_EVENT(bcache_read,
+       TP_PROTO(struct bio *bio, bool hit, bool bypass),
+       TP_ARGS(bio, hit, bypass),
 
-       TP_PROTO(struct bio *bio),
+       TP_STRUCT__entry(
+               __field(dev_t,          dev                     )
+               __field(sector_t,       sector                  )
+               __field(unsigned int,   nr_sector               )
+               __array(char,           rwbs,   6               )
+               __field(bool,           cache_hit               )
+               __field(bool,           bypass                  )
+       ),
 
-       TP_ARGS(bio)
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev->bd_dev;
+               __entry->sector         = bio->bi_sector;
+               __entry->nr_sector      = bio->bi_size >> 9;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+               __entry->cache_hit = hit;
+               __entry->bypass = bypass;
+       ),
+
+       TP_printk("%d,%d  %s %llu + %u hit %u bypass %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->rwbs, (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->cache_hit, __entry->bypass)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_cache_miss,
+TRACE_EVENT(bcache_write,
+       TP_PROTO(struct bio *bio, bool writeback, bool bypass),
+       TP_ARGS(bio, writeback, bypass),
 
-       TP_PROTO(struct bio *bio),
+       TP_STRUCT__entry(
+               __field(dev_t,          dev                     )
+               __field(sector_t,       sector                  )
+               __field(unsigned int,   nr_sector               )
+               __array(char,           rwbs,   6               )
+               __field(bool,           writeback               )
+               __field(bool,           bypass                  )
+       ),
 
-       TP_ARGS(bio)
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev->bd_dev;
+               __entry->sector         = bio->bi_sector;
+               __entry->nr_sector      = bio->bi_size >> 9;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+               __entry->writeback = writeback;
+               __entry->bypass = bypass;
+       ),
+
+       TP_printk("%d,%d  %s %llu + %u hit %u bypass %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->rwbs, (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->writeback, __entry->bypass)
 );
 
 DEFINE_EVENT(bcache_bio, bcache_read_retry,
-
        TP_PROTO(struct bio *bio),
-
        TP_ARGS(bio)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_writethrough,
+DEFINE_EVENT(bkey, bcache_cache_insert,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k)
+);
 
-       TP_PROTO(struct bio *bio),
+/* Journal */
 
-       TP_ARGS(bio)
-);
+DECLARE_EVENT_CLASS(cache_set,
+       TP_PROTO(struct cache_set *c),
+       TP_ARGS(c),
 
-DEFINE_EVENT(bcache_bio, bcache_writeback,
+       TP_STRUCT__entry(
+               __array(char,           uuid,   16 )
+       ),
 
-       TP_PROTO(struct bio *bio),
+       TP_fast_assign(
+               memcpy(__entry->uuid, c->sb.set_uuid, 16);
+       ),
 
-       TP_ARGS(bio)
+       TP_printk("%pU", __entry->uuid)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_write_skip,
-
-       TP_PROTO(struct bio *bio),
+DEFINE_EVENT(bkey, bcache_journal_replay_key,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k)
+);
 
-       TP_ARGS(bio)
+DEFINE_EVENT(cache_set, bcache_journal_full,
+       TP_PROTO(struct cache_set *c),
+       TP_ARGS(c)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_btree_read,
+DEFINE_EVENT(cache_set, bcache_journal_entry_full,
+       TP_PROTO(struct cache_set *c),
+       TP_ARGS(c)
+);
 
+DEFINE_EVENT(bcache_bio, bcache_journal_write,
        TP_PROTO(struct bio *bio),
-
        TP_ARGS(bio)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_btree_write,
+/* Btree */
 
-       TP_PROTO(struct bio *bio),
+DEFINE_EVENT(cache_set, bcache_btree_cache_cannibalize,
+       TP_PROTO(struct cache_set *c),
+       TP_ARGS(c)
+);
 
-       TP_ARGS(bio)
+DEFINE_EVENT(btree_node, bcache_btree_read,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_write_dirty,
+TRACE_EVENT(bcache_btree_write,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b),
 
-       TP_PROTO(struct bio *bio),
+       TP_STRUCT__entry(
+               __field(size_t,         bucket                  )
+               __field(unsigned,       block                   )
+               __field(unsigned,       keys                    )
+       ),
 
-       TP_ARGS(bio)
+       TP_fast_assign(
+               __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
+               __entry->block  = b->written;
+               __entry->keys   = b->sets[b->nsets].data->keys;
+       ),
+
+       TP_printk("bucket %zu", __entry->bucket)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_read_dirty,
+DEFINE_EVENT(btree_node, bcache_btree_node_alloc,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b)
+);
 
-       TP_PROTO(struct bio *bio),
+DEFINE_EVENT(btree_node, bcache_btree_node_alloc_fail,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b)
+);
 
-       TP_ARGS(bio)
+DEFINE_EVENT(btree_node, bcache_btree_node_free,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_write_moving,
+TRACE_EVENT(bcache_btree_gc_coalesce,
+       TP_PROTO(unsigned nodes),
+       TP_ARGS(nodes),
 
-       TP_PROTO(struct bio *bio),
+       TP_STRUCT__entry(
+               __field(unsigned,       nodes                   )
+       ),
 
-       TP_ARGS(bio)
+       TP_fast_assign(
+               __entry->nodes  = nodes;
+       ),
+
+       TP_printk("coalesced %u nodes", __entry->nodes)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_read_moving,
+DEFINE_EVENT(cache_set, bcache_gc_start,
+       TP_PROTO(struct cache_set *c),
+       TP_ARGS(c)
+);
 
-       TP_PROTO(struct bio *bio),
+DEFINE_EVENT(cache_set, bcache_gc_end,
+       TP_PROTO(struct cache_set *c),
+       TP_ARGS(c)
+);
 
-       TP_ARGS(bio)
+DEFINE_EVENT(bkey, bcache_gc_copy,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_journal_write,
+DEFINE_EVENT(bkey, bcache_gc_copy_collision,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k)
+);
 
-       TP_PROTO(struct bio *bio),
+TRACE_EVENT(bcache_btree_insert_key,
+       TP_PROTO(struct btree *b, struct bkey *k, unsigned op, unsigned status),
+       TP_ARGS(b, k, op, status),
 
-       TP_ARGS(bio)
-);
+       TP_STRUCT__entry(
+               __field(u64,    btree_node                      )
+               __field(u32,    btree_level                     )
+               __field(u32,    inode                           )
+               __field(u64,    offset                          )
+               __field(u32,    size                            )
+               __field(u8,     dirty                           )
+               __field(u8,     op                              )
+               __field(u8,     status                          )
+       ),
 
-DECLARE_EVENT_CLASS(bcache_cache_bio,
+       TP_fast_assign(
+               __entry->btree_node = PTR_BUCKET_NR(b->c, &b->key, 0);
+               __entry->btree_level = b->level;
+               __entry->inode  = KEY_INODE(k);
+               __entry->offset = KEY_OFFSET(k);
+               __entry->size   = KEY_SIZE(k);
+               __entry->dirty  = KEY_DIRTY(k);
+               __entry->op = op;
+               __entry->status = status;
+       ),
 
-       TP_PROTO(struct bio *bio,
-                sector_t orig_sector,
-                struct block_device* orig_bdev),
+       TP_printk("%u for %u at %llu(%u): %u:%llu len %u dirty %u",
+                 __entry->status, __entry->op,
+                 __entry->btree_node, __entry->btree_level,
+                 __entry->inode, __entry->offset,
+                 __entry->size, __entry->dirty)
+);
 
-       TP_ARGS(bio, orig_sector, orig_bdev),
+DECLARE_EVENT_CLASS(btree_split,
+       TP_PROTO(struct btree *b, unsigned keys),
+       TP_ARGS(b, keys),
 
        TP_STRUCT__entry(
-               __field(dev_t,          dev                     )
-               __field(dev_t,          orig_dev                )
-               __field(sector_t,       sector                  )
-               __field(sector_t,       orig_sector             )
-               __field(unsigned int,   nr_sector               )
-               __array(char,           rwbs,   6               )
-               __array(char,           comm,   TASK_COMM_LEN   )
+               __field(size_t,         bucket                  )
+               __field(unsigned,       keys                    )
        ),
 
        TP_fast_assign(
-               __entry->dev            = bio->bi_bdev->bd_dev;
-               __entry->orig_dev       = orig_bdev->bd_dev;
-               __entry->sector         = bio->bi_sector;
-               __entry->orig_sector    = orig_sector;
-               __entry->nr_sector      = bio->bi_size >> 9;
-               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
-               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+               __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
+               __entry->keys   = keys;
        ),
 
-       TP_printk("%d,%d  %s %llu + %u [%s] (from %d,%d %llu)",
-                 MAJOR(__entry->dev), MINOR(__entry->dev),
-                 __entry->rwbs,
-                 (unsigned long long)__entry->sector,
-                 __entry->nr_sector, __entry->comm,
-                 MAJOR(__entry->orig_dev), MINOR(__entry->orig_dev),
-                 (unsigned long long)__entry->orig_sector)
+       TP_printk("bucket %zu keys %u", __entry->bucket, __entry->keys)
 );
 
-DEFINE_EVENT(bcache_cache_bio, bcache_cache_insert,
-
-       TP_PROTO(struct bio *bio,
-                sector_t orig_sector,
-                struct block_device *orig_bdev),
+DEFINE_EVENT(btree_split, bcache_btree_node_split,
+       TP_PROTO(struct btree *b, unsigned keys),
+       TP_ARGS(b, keys)
+);
 
-       TP_ARGS(bio, orig_sector, orig_bdev)
+DEFINE_EVENT(btree_split, bcache_btree_node_compact,
+       TP_PROTO(struct btree *b, unsigned keys),
+       TP_ARGS(b, keys)
 );
 
-DECLARE_EVENT_CLASS(bcache_gc,
+DEFINE_EVENT(btree_node, bcache_btree_set_root,
+       TP_PROTO(struct btree *b),
+       TP_ARGS(b)
+);
 
-       TP_PROTO(uint8_t *uuid),
+/* Allocator */
 
-       TP_ARGS(uuid),
+TRACE_EVENT(bcache_alloc_invalidate,
+       TP_PROTO(struct cache *ca),
+       TP_ARGS(ca),
 
        TP_STRUCT__entry(
-               __field(uint8_t *,      uuid)
+               __field(unsigned,       free                    )
+               __field(unsigned,       free_inc                )
+               __field(unsigned,       free_inc_size           )
+               __field(unsigned,       unused                  )
        ),
 
        TP_fast_assign(
-               __entry->uuid           = uuid;
+               __entry->free           = fifo_used(&ca->free);
+               __entry->free_inc       = fifo_used(&ca->free_inc);
+               __entry->free_inc_size  = ca->free_inc.size;
+               __entry->unused         = fifo_used(&ca->unused);
        ),
 
-       TP_printk("%pU", __entry->uuid)
+       TP_printk("free %u free_inc %u/%u unused %u", __entry->free,
+                 __entry->free_inc, __entry->free_inc_size, __entry->unused)
 );
 
+TRACE_EVENT(bcache_alloc_fail,
+       TP_PROTO(struct cache *ca),
+       TP_ARGS(ca),
 
-DEFINE_EVENT(bcache_gc, bcache_gc_start,
+       TP_STRUCT__entry(
+               __field(unsigned,       free                    )
+               __field(unsigned,       free_inc                )
+               __field(unsigned,       unused                  )
+               __field(unsigned,       blocked                 )
+       ),
 
-            TP_PROTO(uint8_t *uuid),
+       TP_fast_assign(
+               __entry->free           = fifo_used(&ca->free);
+               __entry->free_inc       = fifo_used(&ca->free_inc);
+               __entry->unused         = fifo_used(&ca->unused);
+               __entry->blocked        = atomic_read(&ca->set->prio_blocked);
+       ),
 
-            TP_ARGS(uuid)
+       TP_printk("free %u free_inc %u unused %u blocked %u", __entry->free,
+                 __entry->free_inc, __entry->unused, __entry->blocked)
 );
 
-DEFINE_EVENT(bcache_gc, bcache_gc_end,
+/* Background writeback */
 
-            TP_PROTO(uint8_t *uuid),
+DEFINE_EVENT(bkey, bcache_writeback,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k)
+);
 
-            TP_ARGS(uuid)
+DEFINE_EVENT(bkey, bcache_writeback_collision,
+       TP_PROTO(struct bkey *k),
+       TP_ARGS(k)
 );
 
 #endif /* _TRACE_BCACHE_H */
index d615f78cc6b6945d3fa73609056aa1f0bc577870..41a6643e21361cd3993a12e5135bf3e32db79163 100644 (file)
@@ -670,10 +670,6 @@ perf_trace_##call(void *__data, proto)                                     \
                             sizeof(u64));                              \
        __entry_size -= sizeof(u32);                                    \
                                                                        \
-       if (WARN_ONCE(__entry_size > PERF_MAX_TRACE_SIZE,               \
-                     "profile buffer not large enough"))               \
-               return;                                                 \
-                                                                       \
        entry = (struct ftrace_raw_##call *)perf_trace_buf_prepare(     \
                __entry_size, event_call->event.type, &__regs, &rctx);  \
        if (!entry)                                                     \
index 05ac354e124de3e4577667ebf292002f40f45579..95e46c8e05f90db319b2828eb53aa93bdca0629d 100644 (file)
@@ -89,8 +89,8 @@
 #endif
 
 /* a horrid kludge trying to make sure that this will fail on old kernels */
-#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR)
-#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE)      
+#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
+#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)      
 
 #ifndef O_NDELAY
 #define O_NDELAY       O_NONBLOCK
index 9c50445462d99dc755af6e442c217784ba940f83..5fbdd3d49ebabd77526ef5f29b73d66112380f70 100644 (file)
@@ -2,6 +2,7 @@
 #define _LINUX_DN_H
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
 
 /*
 
@@ -120,7 +121,7 @@ struct linkinfo_dn {
  * Ethernet address format (for DECnet)
  */
 union etheraddress {
-        __u8 dne_addr[6];             /* Full ethernet address */
+        __u8 dne_addr[ETH_ALEN];      /* Full ethernet address */
   struct {
                 __u8 dne_hiord[4];    /* DECnet HIORD prefix   */
                 __u8 dne_nodeaddr[2]; /* DECnet node address   */
index 51da65b68b8501cb2d25fe0064c2c6ff65e3d4e6..2b82d7e30974f93b9a93afc2fdf5c9137492043d 100644 (file)
@@ -44,8 +44,8 @@ enum {
        FRA_FWMARK,     /* mark */
        FRA_FLOW,       /* flow/class id */
        FRA_UNUSED6,
-       FRA_UNUSED7,
-       FRA_UNUSED8,
+       FRA_SUPPRESS_IFGROUP,
+       FRA_SUPPRESS_PREFIXLEN,
        FRA_TABLE,      /* Extended table id */
        FRA_FWMASK,     /* mask for netfilter mark */
        FRA_OIFNAME,
index d500369534972c2dede7208ba69d7815e389f299..1db453e4b550ebc84b10ca27f32dd4fdc2ecffd7 100644 (file)
@@ -215,8 +215,8 @@ struct fw_cdev_event_request2 {
  * with the %FW_CDEV_ISO_INTERRUPT bit set, when explicitly requested with
  * %FW_CDEV_IOC_FLUSH_ISO, or when there have been so many completed packets
  * without the interrupt bit set that the kernel's internal buffer for @header
- * is about to overflow.  (In the last case, kernels with ABI version < 5 drop
- * header data up to the next interrupt packet.)
+ * is about to overflow.  (In the last case, ABI versions < 5 drop header data
+ * up to the next interrupt packet.)
  *
  * Isochronous transmit events (context type %FW_CDEV_ISO_CONTEXT_TRANSMIT):
  *
index 2d70d79ce2fd8e816e0271f4b771572c05253cef..39f621a9fe826cb9a0eab487cd36a51aed5440ab 100644 (file)
@@ -14,6 +14,7 @@
 #define _UAPI_LINUX_IF_BRIDGE_H
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
 
 #define SYSFS_BRIDGE_ATTR      "bridge"
 #define SYSFS_BRIDGE_FDB       "brforward"
@@ -88,7 +89,7 @@ struct __port_info {
 };
 
 struct __fdb_entry {
-       __u8 mac_addr[6];
+       __u8 mac_addr[ETH_ALEN];
        __u8 port_no;
        __u8 is_local;
        __u32 ageing_timer_value;
index 03f6170ab3372f443c0989c7c5a503b00ef0c308..04c0e7a5d48421645ee23016064d143918a08ca3 100644 (file)
@@ -143,6 +143,7 @@ enum {
        IFLA_NUM_TX_QUEUES,
        IFLA_NUM_RX_QUEUES,
        IFLA_CARRIER,
+       IFLA_PHYS_PORT_ID,
        __IFLA_MAX
 };
 
index e36a4aecd3117ebdaf46c17ac115e5d0a29bcede..e128769331b5a7c6be4a10cf44c262be68a65772 100644 (file)
@@ -46,7 +46,7 @@ struct pppoe_addr {
  * PPTP addressing definition
  */
 struct pptp_addr {
-       __be16          call_id;
+       __u16           call_id;
        struct in_addr  sin_addr;
 };
 
index 82334f88967e9ba269d3e3fa121f563c33e64eed..e9502dd1ee2cc178e712e6ab05c59efecdaf980f 100644 (file)
@@ -56,6 +56,8 @@
 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
 #define TUNSETQUEUE  _IOW('T', 217, int)
+#define TUNSETIFINDEX  _IOW('T', 218, unsigned int)
+#define TUNGETFILTER _IOR('T', 219, struct sock_fprog)
 
 /* TUNSETIFF ifr flags */
 #define IFF_TUN                0x0001
 #define IFF_DETACH_QUEUE 0x0400
 /* read-only flag */
 #define IFF_PERSIST    0x0800
+#define IFF_NOFILTER   0x1000
+
+/* Socket options */
+#define TUN_TX_TIMESTAMP 1
 
 /* Features for GSO (TUNSETOFFLOAD). */
 #define TUN_F_CSUM     0x01    /* You can hand me unchecksummed packets. */
index 6cf06bfd841bc5e7c77df6cd32456309ff460d46..411959405ab6ed278d2a963c5931b546cff2dc2e 100644 (file)
@@ -133,4 +133,40 @@ struct ip_beet_phdr {
        __u8 reserved;
 };
 
+/* index values for the variables in ipv4_devconf */
+enum
+{
+       IPV4_DEVCONF_FORWARDING=1,
+       IPV4_DEVCONF_MC_FORWARDING,
+       IPV4_DEVCONF_PROXY_ARP,
+       IPV4_DEVCONF_ACCEPT_REDIRECTS,
+       IPV4_DEVCONF_SECURE_REDIRECTS,
+       IPV4_DEVCONF_SEND_REDIRECTS,
+       IPV4_DEVCONF_SHARED_MEDIA,
+       IPV4_DEVCONF_RP_FILTER,
+       IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
+       IPV4_DEVCONF_BOOTP_RELAY,
+       IPV4_DEVCONF_LOG_MARTIANS,
+       IPV4_DEVCONF_TAG,
+       IPV4_DEVCONF_ARPFILTER,
+       IPV4_DEVCONF_MEDIUM_ID,
+       IPV4_DEVCONF_NOXFRM,
+       IPV4_DEVCONF_NOPOLICY,
+       IPV4_DEVCONF_FORCE_IGMP_VERSION,
+       IPV4_DEVCONF_ARP_ANNOUNCE,
+       IPV4_DEVCONF_ARP_IGNORE,
+       IPV4_DEVCONF_PROMOTE_SECONDARIES,
+       IPV4_DEVCONF_ARP_ACCEPT,
+       IPV4_DEVCONF_ARP_NOTIFY,
+       IPV4_DEVCONF_ACCEPT_LOCAL,
+       IPV4_DEVCONF_SRC_VMARK,
+       IPV4_DEVCONF_PROXY_ARP_PVLAN,
+       IPV4_DEVCONF_ROUTE_LOCALNET,
+       IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL,
+       IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL,
+       __IPV4_DEVCONF_MAX
+};
+
+#define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
+
 #endif /* _UAPI_LINUX_IP_H */
index 4bda4cf5b0f56d84651497df86bd9fa09909fa85..d07ac6903e593cdc04279a70bde8a63a47da8bb8 100644 (file)
@@ -160,6 +160,8 @@ enum {
        DEVCONF_ACCEPT_DAD,
        DEVCONF_FORCE_TLLAO,
        DEVCONF_NDISC_NOTIFY,
+       DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL,
+       DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL,
        DEVCONF_MAX
 };
 
index 41115776d76f74996a0815e044533fc5e5ee8f78..174915420d3fe8231dc151519ceac551aceb148e 100644 (file)
@@ -22,6 +22,7 @@ header-y += xt_CONNMARK.h
 header-y += xt_CONNSECMARK.h
 header-y += xt_CT.h
 header-y += xt_DSCP.h
+header-y += xt_HMARK.h
 header-y += xt_IDLETIMER.h
 header-y += xt_LED.h
 header-y += xt_LOG.h
@@ -68,6 +69,7 @@ header-y += xt_quota.h
 header-y += xt_rateest.h
 header-y += xt_realm.h
 header-y += xt_recent.h
+header-y += xt_rpfilter.h
 header-y += xt_sctp.h
 header-y += xt_set.h
 header-y += xt_socket.h
index d69483fb382537e39c99251f5d3f580bf8115b62..8dd803818ebe34c63db7792dadf4614632bdd93e 100644 (file)
@@ -99,7 +99,8 @@ enum ip_conntrack_events {
        IPCT_PROTOINFO,         /* protocol information has changed */
        IPCT_HELPER,            /* new helper has been set */
        IPCT_MARK,              /* new mark has been set */
-       IPCT_NATSEQADJ,         /* NAT is doing sequence adjustment */
+       IPCT_SEQADJ,            /* sequence adjustment has changed */
+       IPCT_NATSEQADJ = IPCT_SEQADJ,
        IPCT_SECMARK,           /* new security mark has been set */
        IPCT_LABEL,             /* new connlabel has been set */
 };
index 08fabc6c93f3ae6d7fb7ae1f8e443b288a93d952..acad6c52a6521d0fe81d1078a95fc7bb032d796c 100644 (file)
@@ -42,8 +42,10 @@ enum ctattr_type {
        CTA_ID,
        CTA_NAT_DST,
        CTA_TUPLE_MASTER,
-       CTA_NAT_SEQ_ADJ_ORIG,
-       CTA_NAT_SEQ_ADJ_REPLY,
+       CTA_SEQ_ADJ_ORIG,
+       CTA_NAT_SEQ_ADJ_ORIG    = CTA_SEQ_ADJ_ORIG,
+       CTA_SEQ_ADJ_REPLY,
+       CTA_NAT_SEQ_ADJ_REPLY   = CTA_SEQ_ADJ_REPLY,
        CTA_SECMARK,            /* obsolete */
        CTA_ZONE,
        CTA_SECCTX,
@@ -165,6 +167,15 @@ enum ctattr_protonat {
 };
 #define CTA_PROTONAT_MAX (__CTA_PROTONAT_MAX - 1)
 
+enum ctattr_seqadj {
+       CTA_SEQADJ_UNSPEC,
+       CTA_SEQADJ_CORRECTION_POS,
+       CTA_SEQADJ_OFFSET_BEFORE,
+       CTA_SEQADJ_OFFSET_AFTER,
+       __CTA_SEQADJ_MAX
+};
+#define CTA_SEQADJ_MAX (__CTA_SEQADJ_MAX - 1)
+
 enum ctattr_natseq {
        CTA_NAT_SEQ_UNSPEC,
        CTA_NAT_SEQ_CORRECTION_POS,
index 3a9b92147339d14d871ba836e5b8840f6d5cce8c..0132bad79de7f6860120d13c6df2d508ad2d5d14 100644 (file)
@@ -46,6 +46,7 @@ enum nfqnl_attr_type {
        NFQA_CT_INFO,                   /* enum ip_conntrack_info */
        NFQA_CAP_LEN,                   /* __u32 length of captured packet */
        NFQA_SKB_INFO,                  /* __u32 skb meta information */
+       NFQA_EXP,                       /* nf_conntrack_netlink.h */
 
        __NFQA_MAX
 };
diff --git a/include/uapi/linux/netfilter/xt_HMARK.h b/include/uapi/linux/netfilter/xt_HMARK.h
new file mode 100644 (file)
index 0000000..826fc58
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef XT_HMARK_H_
+#define XT_HMARK_H_
+
+#include <linux/types.h>
+
+enum {
+       XT_HMARK_SADDR_MASK,
+       XT_HMARK_DADDR_MASK,
+       XT_HMARK_SPI,
+       XT_HMARK_SPI_MASK,
+       XT_HMARK_SPORT,
+       XT_HMARK_DPORT,
+       XT_HMARK_SPORT_MASK,
+       XT_HMARK_DPORT_MASK,
+       XT_HMARK_PROTO_MASK,
+       XT_HMARK_RND,
+       XT_HMARK_MODULUS,
+       XT_HMARK_OFFSET,
+       XT_HMARK_CT,
+       XT_HMARK_METHOD_L3,
+       XT_HMARK_METHOD_L3_4,
+};
+#define XT_HMARK_FLAG(flag)    (1 << flag)
+
+union hmark_ports {
+       struct {
+               __u16   src;
+               __u16   dst;
+       } p16;
+       struct {
+               __be16  src;
+               __be16  dst;
+       } b16;
+       __u32   v32;
+       __be32  b32;
+};
+
+struct xt_hmark_info {
+       union nf_inet_addr      src_mask;
+       union nf_inet_addr      dst_mask;
+       union hmark_ports       port_mask;
+       union hmark_ports       port_set;
+       __u32                   flags;
+       __u16                   proto_mask;
+       __u32                   hashrnd;
+       __u32                   hmodulus;
+       __u32                   hoffset;        /* Mark offset to start from */
+};
+
+#endif /* XT_HMARK_H_ */
diff --git a/include/uapi/linux/netfilter/xt_SYNPROXY.h b/include/uapi/linux/netfilter/xt_SYNPROXY.h
new file mode 100644 (file)
index 0000000..2d59fba
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _XT_SYNPROXY_H
+#define _XT_SYNPROXY_H
+
+#define XT_SYNPROXY_OPT_MSS            0x01
+#define XT_SYNPROXY_OPT_WSCALE         0x02
+#define XT_SYNPROXY_OPT_SACK_PERM      0x04
+#define XT_SYNPROXY_OPT_TIMESTAMP      0x08
+#define XT_SYNPROXY_OPT_ECN            0x10
+
+struct xt_synproxy_info {
+       __u8    options;
+       __u8    wscale;
+       __u16   mss;
+};
+
+#endif /* _XT_SYNPROXY_H */
diff --git a/include/uapi/linux/netfilter/xt_rpfilter.h b/include/uapi/linux/netfilter/xt_rpfilter.h
new file mode 100644 (file)
index 0000000..8358d4f
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _XT_RPATH_H
+#define _XT_RPATH_H
+
+#include <linux/types.h>
+
+enum {
+       XT_RPFILTER_LOOSE = 1 << 0,
+       XT_RPFILTER_VALID_MARK = 1 << 1,
+       XT_RPFILTER_ACCEPT_LOCAL = 1 << 2,
+       XT_RPFILTER_INVERT = 1 << 3,
+#ifdef __KERNEL__
+       XT_RPFILTER_OPTION_MASK = XT_RPFILTER_LOOSE |
+                                 XT_RPFILTER_VALID_MARK |
+                                 XT_RPFILTER_ACCEPT_LOCAL |
+                                 XT_RPFILTER_INVERT,
+#endif
+};
+
+struct xt_rpfilter_info {
+       __u8 flags;
+};
+
+#endif
index 5bf84912a082a53e5cc12b9b03eaae46bcd91116..f37522aade24e6b96e4c0c30670dcf833bb896ed 100644 (file)
@@ -2,6 +2,7 @@
 #define _UAPI__LINUX_BRIDGE_EBT_802_3_H
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
 
 #define EBT_802_3_SAP 0x01
 #define EBT_802_3_TYPE 0x02
@@ -42,8 +43,8 @@ struct hdr_ni {
 };
 
 struct ebt_802_3_hdr {
-       __u8  daddr[6];
-       __u8  saddr[6];
+       __u8  daddr[ETH_ALEN];
+       __u8  saddr[ETH_ALEN];
        __be16 len;
        union {
                struct hdr_ui ui;
index c6a204c97047a671bed64f03230064ef9e174175..eac0f6548f47f17cd918e50b835cc14078f81df0 100644 (file)
@@ -2,6 +2,7 @@
 #define _IPT_CLUSTERIP_H_target
 
 #include <linux/types.h>
+#include <linux/if_ether.h>
 
 enum clusterip_hashmode {
     CLUSTERIP_HASHMODE_SIP = 0,
@@ -22,7 +23,7 @@ struct ipt_clusterip_tgt_info {
        __u32 flags;
 
        /* only relevant for new ones */
-       __u8 clustermac[6];
+       __u8 clustermac[ETH_ALEN];
        __u16 num_total_nodes;
        __u16 num_local_nodes;
        __u16 local_nodes[CLUSTERIP_MAX_NODES];
index c55efaaa9bb4d889a6fdbee064a00b318f0043cc..a74d375b439bb82369f9d31bbd868d466cf0aa7d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2007-2011 Nicira Networks.
+ * Copyright (c) 2007-2013 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -165,6 +165,7 @@ enum ovs_vport_type {
        OVS_VPORT_TYPE_NETDEV,   /* network device */
        OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */
        OVS_VPORT_TYPE_GRE,      /* GRE tunnel. */
+       OVS_VPORT_TYPE_VXLAN,    /* VXLAN tunnel. */
        __OVS_VPORT_TYPE_MAX
 };
 
@@ -211,6 +212,16 @@ enum ovs_vport_attr {
 
 #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
 
+/* OVS_VPORT_ATTR_OPTIONS attributes for tunnels.
+ */
+enum {
+       OVS_TUNNEL_ATTR_UNSPEC,
+       OVS_TUNNEL_ATTR_DST_PORT, /* 16-bit UDP port, used by L4 tunnels. */
+       __OVS_TUNNEL_ATTR_MAX
+};
+
+#define OVS_TUNNEL_ATTR_MAX (__OVS_TUNNEL_ATTR_MAX - 1)
+
 /* Flows. */
 
 #define OVS_FLOW_FAMILY  "ovs_flow"
@@ -248,6 +259,7 @@ enum ovs_key_attr {
        OVS_KEY_ATTR_ND,        /* struct ovs_key_nd */
        OVS_KEY_ATTR_SKB_MARK,  /* u32 skb mark */
        OVS_KEY_ATTR_TUNNEL,    /* Nested set of ovs_tunnel attributes */
+       OVS_KEY_ATTR_SCTP,      /* struct ovs_key_sctp */
 
 #ifdef __KERNEL__
        OVS_KEY_ATTR_IPV4_TUNNEL,  /* struct ovs_key_ipv4_tunnel */
@@ -322,6 +334,11 @@ struct ovs_key_udp {
        __be16 udp_dst;
 };
 
+struct ovs_key_sctp {
+       __be16 sctp_src;
+       __be16 sctp_dst;
+};
+
 struct ovs_key_icmp {
        __u8 icmp_type;
        __u8 icmp_code;
@@ -368,6 +385,12 @@ struct ovs_key_nd {
  * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the
  * last-used time, accumulated TCP flags, and statistics for this flow.
  * Otherwise ignored in requests.  Never present in notifications.
+ * @OVS_FLOW_ATTR_MASK: Nested %OVS_KEY_ATTR_* attributes specifying the
+ * mask bits for wildcarded flow match. Mask bit value '1' specifies exact
+ * match with corresponding flow key bit, while mask bit value '0' specifies
+ * a wildcarded match. Omitting attribute is treated as wildcarding all
+ * corresponding fields. Optional for all requests. If not present,
+ * all flow key bits are exact match bits.
  *
  * These attributes follow the &struct ovs_header within the Generic Netlink
  * payload for %OVS_FLOW_* commands.
@@ -380,6 +403,7 @@ enum ovs_flow_attr {
        OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */
        OVS_FLOW_ATTR_USED,      /* u64 msecs last used in monotonic time. */
        OVS_FLOW_ATTR_CLEAR,     /* Flag to clear stats, tcp_flags, used. */
+       OVS_FLOW_ATTR_MASK,      /* Sequence of OVS_KEY_ATTR_* attributes. */
        __OVS_FLOW_ATTR_MAX
 };
 
index dbd71b0c7d8c93edbc80ae50ad7223db3665f00a..09d62b9228ffa061de1b5cb8ee80e20ef470db5c 100644 (file)
@@ -73,9 +73,17 @@ struct tc_estimator {
 #define TC_H_ROOT      (0xFFFFFFFFU)
 #define TC_H_INGRESS    (0xFFFFFFF1U)
 
+/* Need to corrospond to iproute2 tc/tc_core.h "enum link_layer" */
+enum tc_link_layer {
+       TC_LINKLAYER_UNAWARE, /* Indicate unaware old iproute2 util */
+       TC_LINKLAYER_ETHERNET,
+       TC_LINKLAYER_ATM,
+};
+#define TC_LINKLAYER_MASK 0x0F /* limit use to lower 4 bits */
+
 struct tc_ratespec {
        unsigned char   cell_log;
-       unsigned char   __reserved;
+       __u8            linklayer; /* lower 4 bits */
        unsigned short  overhead;
        short           cell_align;
        unsigned short  mpu;
index 66b466e4ca08df99479751c55ce03f3daa39ebcb..ca451e99b28b92f5a5e1d8fde7d99446e2df06cf 100644 (file)
@@ -28,7 +28,7 @@
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Or submit a bug report through the following website:
  *    http://www.sf.net/projects/lksctp
index af0a674cc677f570bf5d5e04683957605d5e9ea1..1bdb4a39d1e1512da2091f1c4e897c5e03527554 100644 (file)
@@ -51,6 +51,10 @@ enum
        IPSTATS_MIB_INBCASTOCTETS,              /* InBcastOctets */
        IPSTATS_MIB_OUTBCASTOCTETS,             /* OutBcastOctets */
        IPSTATS_MIB_CSUMERRORS,                 /* InCsumErrors */
+       IPSTATS_MIB_NOECTPKTS,                  /* InNoECTPkts */
+       IPSTATS_MIB_ECT1PKTS,                   /* InECT1Pkts */
+       IPSTATS_MIB_ECT0PKTS,                   /* InECT0Pkts */
+       IPSTATS_MIB_CEPKTS,                     /* InCEPkts */
        __IPSTATS_MIB_MAX
 };
 
@@ -253,7 +257,7 @@ enum
        LINUX_MIB_TCPFASTOPENLISTENOVERFLOW,    /* TCPFastOpenListenOverflow */
        LINUX_MIB_TCPFASTOPENCOOKIEREQD,        /* TCPFastOpenCookieReqd */
        LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES, /* TCPSpuriousRtxHostQueues */
-       LINUX_MIB_LOWLATENCYRXPACKETS,          /* LowLatencyRxPackets */
+       LINUX_MIB_BUSYPOLLRXPACKETS,            /* BusyPollRxPackets */
        __LINUX_MIB_MAX
 };
 
index 8d776ebc4829df669bbb70c4d6331ba21cc88884..377f1e59411d1572eb645b7b80be42347a7513f5 100644 (file)
@@ -111,6 +111,7 @@ enum {
 #define TCP_REPAIR_OPTIONS     22
 #define TCP_FASTOPEN           23      /* Enable FastOpen on listeners */
 #define TCP_TIMESTAMP          24
+#define TCP_NOTSENT_LOWAT      25      /* limit number of unsent bytes in write queue */
 
 struct tcp_repair_opt {
        __u32   opt_code;
index 7692dc69ccf7aeeb16ebc682b57d519c56642ba1..331499d597fa86cd941d99d5ad8ab9ec2120cb86 100644 (file)
 
 #include <linux/types.h>       /* __u8 etc */
 
+/* This is arbitrary.
+ * From USB 2.0 spec Table 11-13, offset 7, a hub can
+ * have up to 255 ports. The most yet reported is 10.
+ *
+ * Current Wireless USB host hardware (Intel i1480 for example) allows
+ * up to 22 devices to connect. Upcoming hardware might raise that
+ * limit. Because the arrays need to add a bit for hub status data, we
+ * use 31, so plus one evens out to four bytes.
+ */
+#define USB_MAXCHILDREN                31
+
 /*
  * Hub request types
  */
index c520203fac2f4b466f062e49f743e45391ac2f93..172a7f00780cc41398e54bd1e5c4314c6b1c9627 100644 (file)
@@ -60,7 +60,7 @@
 
 struct virtio_net_config {
        /* The config defining mac address (if VIRTIO_NET_F_MAC) */
-       __u8 mac[6];
+       __u8 mac[ETH_ALEN];
        /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
        __u16 status;
        /* Maximum number of each of transmit and receive queues;
@@ -70,7 +70,9 @@ struct virtio_net_config {
        __u16 max_virtqueue_pairs;
 } __attribute__((packed));
 
-/* This is the first element of the scatter-gather list.  If you don't
+/* This header comes first in the scatter-gather list.
+ * If VIRTIO_F_ANY_LAYOUT is not negotiated, it must
+ * be the first element of the scatter-gather list.  If you don't
  * specify GSO or CSUM features, you can simply ignore the header. */
 struct virtio_net_hdr {
 #define VIRTIO_NET_HDR_F_NEEDS_CSUM    1       // Use csum_start, csum_offset
index 62d356153565a51982cd97be580d8d43647bc003..fd198bc24a3c9d81ed0074fbacce6594cf90ceee 100644 (file)
 #define __LINUX__WIMAX__I2400M_H__
 
 #include <linux/types.h>
-
+#include <linux/if_ether.h>
 
 /*
  * Host Device Interface (HDI) common to all busses
@@ -487,7 +487,7 @@ struct i2400m_tlv_l4_message_versions {
 struct i2400m_tlv_detailed_device_info {
        struct i2400m_tlv_hdr hdr;
        __u8 reserved1[400];
-       __u8 mac_address[6];
+       __u8 mac_address[ETH_ALEN];
        __u8 reserved2[2];
 } __attribute__((packed));
 
index ffd4652de91ca390fff537f18f524300bf470246..65e12099ef89d9f3b5706858d956d8aabe427348 100644 (file)
@@ -102,6 +102,30 @@ typedef uint64_t blkif_sector_t;
  */
 #define BLKIF_OP_DISCARD           5
 
+/*
+ * Recognized if "feature-max-indirect-segments" in present in the backend
+ * xenbus info. The "feature-max-indirect-segments" node contains the maximum
+ * number of segments allowed by the backend per request. If the node is
+ * present, the frontend might use blkif_request_indirect structs in order to
+ * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The
+ * maximum number of indirect segments is fixed by the backend, but the
+ * frontend can issue requests with any number of indirect segments as long as
+ * it's less than the number provided by the backend. The indirect_grefs field
+ * in blkif_request_indirect should be filled by the frontend with the
+ * grant references of the pages that are holding the indirect segments.
+ * This pages are filled with an array of blkif_request_segment_aligned
+ * that hold the information about the segments. The number of indirect
+ * pages to use is determined by the maximum number of segments
+ * a indirect request contains. Every indirect page can contain a maximum
+ * of 512 segments (PAGE_SIZE/sizeof(blkif_request_segment_aligned)),
+ * so to calculate the number of indirect pages to use we have to do
+ * ceil(indirect_segments/512).
+ *
+ * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not*
+ * create the "feature-max-indirect-segments" node!
+ */
+#define BLKIF_OP_INDIRECT          6
+
 /*
  * Maximum scatter/gather segments per request.
  * This is carefully chosen so that sizeof(struct blkif_ring) <= PAGE_SIZE.
@@ -109,6 +133,16 @@ typedef uint64_t blkif_sector_t;
  */
 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
 
+#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
+
+struct blkif_request_segment_aligned {
+       grant_ref_t gref;        /* reference to I/O buffer frame        */
+       /* @first_sect: first sector in frame to transfer (inclusive).   */
+       /* @last_sect: last sector in frame to transfer (inclusive).     */
+       uint8_t     first_sect, last_sect;
+       uint16_t    _pad; /* padding to make it 8 bytes, so it's cache-aligned */
+} __attribute__((__packed__));
+
 struct blkif_request_rw {
        uint8_t        nr_segments;  /* number of segments                   */
        blkif_vdev_t   handle;       /* only for read/write requests         */
@@ -147,12 +181,31 @@ struct blkif_request_other {
        uint64_t     id;           /* private guest value, echoed in resp  */
 } __attribute__((__packed__));
 
+struct blkif_request_indirect {
+       uint8_t        indirect_op;
+       uint16_t       nr_segments;
+#ifdef CONFIG_X86_64
+       uint32_t       _pad1;        /* offsetof(blkif_...,u.indirect.id) == 8 */
+#endif
+       uint64_t       id;
+       blkif_sector_t sector_number;
+       blkif_vdev_t   handle;
+       uint16_t       _pad2;
+       grant_ref_t    indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST];
+#ifdef CONFIG_X86_64
+       uint32_t      _pad3;         /* make it 64 byte aligned */
+#else
+       uint64_t      _pad3;         /* make it 64 byte aligned */
+#endif
+} __attribute__((__packed__));
+
 struct blkif_request {
        uint8_t        operation;    /* BLKIF_OP_???                         */
        union {
                struct blkif_request_rw rw;
                struct blkif_request_discard discard;
                struct blkif_request_other other;
+               struct blkif_request_indirect indirect;
        } u;
 } __attribute__((__packed__));
 
index 75271b9a8f61bedcec5a18465b5a9ca8e84a38c7..7d28aff605c7eb600c4c3bfe93b8b5f1edbaebfe 100644 (file)
@@ -188,6 +188,11 @@ struct __name##_back_ring {                                                \
 #define RING_REQUEST_CONS_OVERFLOW(_r, _cons)                          \
     (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
 
+/* Ill-behaved frontend determination: Can there be this many requests? */
+#define RING_REQUEST_PROD_OVERFLOW(_r, _prod)               \
+    (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r))
+
+
 #define RING_PUSH_REQUESTS(_r) do {                                    \
     wmb(); /* back sees requests /before/ updated producer index */    \
     (_r)->sring->req_prod = (_r)->req_prod_pvt;                                \
index 247084be059030162838199c953ebac6409f7e01..fed81b576f29ad8003c48ed293bb9cd42bd95922 100644 (file)
@@ -955,7 +955,7 @@ config MEMCG_SWAP_ENABLED
          Memory Resource Controller Swap Extension comes with its price in
          a bigger memory consumption. General purpose distribution kernels
          which want to enable the feature but keep it disabled by default
-         and let the user enable it by swapaccount boot command line
+         and let the user enable it by swapaccount=1 boot command line
          parameter should have this option unselected.
          For those who want to have the feature enabled by default should
          select this option (if, for some reason, they need to disable it
index fda0a7b0f06c006467c43d04f658744b146a6266..520702db9accd25ff2e66579bfee4d231d5fa0e4 100644 (file)
@@ -31,7 +31,7 @@ __setup("lpj=", lpj_setup);
 #define DELAY_CALIBRATION_TICKS                        ((HZ < 100) ? 1 : (HZ/100))
 #define MAX_DIRECT_CALIBRATION_RETRIES         5
 
-static unsigned long __cpuinit calibrate_delay_direct(void)
+static unsigned long calibrate_delay_direct(void)
 {
        unsigned long pre_start, start, post_start;
        unsigned long pre_end, end, post_end;
@@ -166,7 +166,10 @@ static unsigned long __cpuinit calibrate_delay_direct(void)
        return 0;
 }
 #else
-static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;}
+static unsigned long calibrate_delay_direct(void)
+{
+       return 0;
+}
 #endif
 
 /*
@@ -180,7 +183,7 @@ static unsigned long __cpuinit calibrate_delay_direct(void) {return 0;}
  */
 #define LPS_PREC 8
 
-static unsigned long __cpuinit calibrate_delay_converge(void)
+static unsigned long calibrate_delay_converge(void)
 {
        /* First stage - slowly accelerate to find initial bounds */
        unsigned long lpj, lpj_base, ticks, loopadd, loopadd_base, chop_limit;
@@ -254,12 +257,12 @@ static DEFINE_PER_CPU(unsigned long, cpu_loops_per_jiffy) = { 0 };
  * Architectures should override this function if a faster calibration
  * method is available.
  */
-unsigned long __attribute__((weak)) __cpuinit calibrate_delay_is_known(void)
+unsigned long __attribute__((weak)) calibrate_delay_is_known(void)
 {
        return 0;
 }
 
-void __cpuinit calibrate_delay(void)
+void calibrate_delay(void)
 {
        unsigned long lpj;
        static bool printed;
index 470839d1a30ed72f68789df711bfa78bdc60e5f4..35ef1185e359457323d5513b578185ad16435bc2 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y     = fork.o exec_domain.o panic.o printk.o \
+obj-y     = fork.o exec_domain.o panic.o \
            cpu.o exit.o itimer.o time.o softirq.o resource.o \
            sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
            signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
@@ -24,6 +24,7 @@ endif
 
 obj-y += sched/
 obj-y += power/
+obj-y += printk/
 obj-y += cpu/
 
 obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o
index 0e0b20b8c5db172e8dc07fe4de10358c19939d60..781845a013ab23c8f99f2c2153c70c9fd679c45d 100644 (file)
@@ -1845,36 +1845,43 @@ out:
 EXPORT_SYMBOL_GPL(cgroup_path);
 
 /**
- * task_cgroup_path_from_hierarchy - cgroup path of a task on a hierarchy
+ * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
  * @task: target task
- * @hierarchy_id: the hierarchy to look up @task's cgroup from
  * @buf: the buffer to write the path into
  * @buflen: the length of the buffer
  *
- * Determine @task's cgroup on the hierarchy specified by @hierarchy_id and
- * copy its path into @buf.  This function grabs cgroup_mutex and shouldn't
- * be used inside locks used by cgroup controller callbacks.
+ * Determine @task's cgroup on the first (the one with the lowest non-zero
+ * hierarchy_id) cgroup hierarchy and copy its path into @buf.  This
+ * function grabs cgroup_mutex and shouldn't be used inside locks used by
+ * cgroup controller callbacks.
+ *
+ * Returns 0 on success, fails with -%ENAMETOOLONG if @buflen is too short.
  */
-int task_cgroup_path_from_hierarchy(struct task_struct *task, int hierarchy_id,
-                                   char *buf, size_t buflen)
+int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen)
 {
        struct cgroupfs_root *root;
-       struct cgroup *cgrp = NULL;
-       int ret = -ENOENT;
+       struct cgroup *cgrp;
+       int hierarchy_id = 1, ret = 0;
+
+       if (buflen < 2)
+               return -ENAMETOOLONG;
 
        mutex_lock(&cgroup_mutex);
 
-       root = idr_find(&cgroup_hierarchy_idr, hierarchy_id);
+       root = idr_get_next(&cgroup_hierarchy_idr, &hierarchy_id);
+
        if (root) {
                cgrp = task_cgroup_from_root(task, root);
                ret = cgroup_path(cgrp, buf, buflen);
+       } else {
+               /* if no hierarchy exists, everyone is in "/" */
+               memcpy(buf, "/", 2);
        }
 
        mutex_unlock(&cgroup_mutex);
-
        return ret;
 }
-EXPORT_SYMBOL_GPL(task_cgroup_path_from_hierarchy);
+EXPORT_SYMBOL_GPL(task_cgroup_path);
 
 /*
  * Control Group taskset
@@ -4328,8 +4335,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
                }
 
                err = percpu_ref_init(&css->refcnt, css_release);
-               if (err)
+               if (err) {
+                       ss->css_free(cgrp);
                        goto err_free_all;
+               }
 
                init_cgroup_css(css, ss, cgrp);
 
index 198a38883e64a0616437401ef2692f5b3c9029a5..b2b227b821232d811d371fc24c672ad0fb715cf2 100644 (file)
@@ -366,7 +366,7 @@ EXPORT_SYMBOL(cpu_down);
 #endif /*CONFIG_HOTPLUG_CPU*/
 
 /* Requires cpu_add_remove_lock to be held */
-static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
+static int _cpu_up(unsigned int cpu, int tasks_frozen)
 {
        int ret, nr_calls = 0;
        void *hcpu = (void *)(long)cpu;
@@ -419,7 +419,7 @@ out:
        return ret;
 }
 
-int __cpuinit cpu_up(unsigned int cpu)
+int cpu_up(unsigned int cpu)
 {
        int err = 0;
 
@@ -618,7 +618,7 @@ core_initcall(cpu_hotplug_pm_sync_init);
  * It must be called by the arch code on the new cpu, before the new cpu
  * enables interrupts and before the "boot" cpu returns from __cpu_up().
  */
-void __cpuinit notify_cpu_starting(unsigned int cpu)
+void notify_cpu_starting(unsigned int cpu)
 {
        unsigned long val = CPU_STARTING;
 
index e5657788feddfefaaed5f7ce3ce2ac26ca80a9c1..010a0083c0ae4cfa222e2d51f2e951893bac28c4 100644 (file)
@@ -1608,11 +1608,13 @@ static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val)
 {
        struct cpuset *cs = cgroup_cs(cgrp);
        cpuset_filetype_t type = cft->private;
-       int retval = -ENODEV;
+       int retval = 0;
 
        mutex_lock(&cpuset_mutex);
-       if (!is_cpuset_online(cs))
+       if (!is_cpuset_online(cs)) {
+               retval = -ENODEV;
                goto out_unlock;
+       }
 
        switch (type) {
        case FILE_CPU_EXCLUSIVE:
index eba8fb5834ae2e7d527693d7eff63556a987bd9a..f86599e8c12371c7d78248e0c6b2a6869b9122ee 100644 (file)
@@ -6234,8 +6234,6 @@ perf_event_mux_interval_ms_store(struct device *dev,
        return count;
 }
 
-#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
-
 static struct device_attribute pmu_dev_attrs[] = {
        __ATTR_RO(type),
        __ATTR_RW(perf_event_mux_interval_ms),
@@ -7630,7 +7628,7 @@ static void __init perf_event_init_all_cpus(void)
        }
 }
 
-static void __cpuinit perf_event_init_cpu(int cpu)
+static void perf_event_init_cpu(int cpu)
 {
        struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
 
@@ -7719,7 +7717,7 @@ static struct notifier_block perf_reboot_notifier = {
        .priority = INT_MIN,
 };
 
-static int __cpuinit
+static int
 perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
 {
        unsigned int cpu = (long)hcpu;
index 66635c80a813e876d3a3529ed13ce410ab987c4e..e23bb19e2a3e23c9d3ad3c68e0f49acb214d3e51 100644 (file)
@@ -1546,7 +1546,7 @@ static inline void init_idle_pids(struct pid_link *links)
        }
 }
 
-struct task_struct * __cpuinit fork_idle(int cpu)
+struct task_struct *fork_idle(int cpu)
 {
        struct task_struct *task;
        task = copy_process(CLONE_VM, 0, 0, NULL, &init_struct_pid, 0);
@@ -1679,6 +1679,12 @@ SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,
                 int __user *, parent_tidptr,
                 int __user *, child_tidptr,
                 int, tls_val)
+#elif defined(CONFIG_CLONE_BACKWARDS3)
+SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp,
+               int, stack_size,
+               int __user *, parent_tidptr,
+               int __user *, child_tidptr,
+               int, tls_val)
 #else
 SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
                 int __user *, parent_tidptr,
index 8b2afc1c9df0c698eccd86664d25c33ed647fea7..b462fa197517b6176701fa860cdb966bc44a69ba 100644 (file)
@@ -33,7 +33,7 @@ static DEFINE_SPINLOCK(freezer_lock);
  */
 bool freezing_slow_path(struct task_struct *p)
 {
-       if (p->flags & PF_NOFREEZE)
+       if (p->flags & (PF_NOFREEZE | PF_SUSPEND_TASK))
                return false;
 
        if (pm_nosig_freezing || cgroup_freezing(p))
index f0f4fe29cd21b1df3a60424bb8693b1892c17b8a..383319bae3f7d0d9e8154a3bb99798a477ee676f 100644 (file)
@@ -1659,7 +1659,7 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
 /*
  * Functions related to boot-time initialization:
  */
-static void __cpuinit init_hrtimers_cpu(int cpu)
+static void init_hrtimers_cpu(int cpu)
 {
        struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
        int i;
@@ -1740,7 +1740,7 @@ static void migrate_hrtimers(int scpu)
 
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
+static int hrtimer_cpu_notify(struct notifier_block *self,
                                        unsigned long action, void *hcpu)
 {
        int scpu = (long)hcpu;
@@ -1773,7 +1773,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata hrtimers_nb = {
+static struct notifier_block hrtimers_nb = {
        .notifier_call = hrtimer_cpu_notify,
 };
 
index ff05f4bd86eb6acf10ff49307e448ddb8b00916a..a52ee7bb830d3fa9db3cf898a34c8212664ac8b7 100644 (file)
@@ -686,7 +686,7 @@ __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
        might_sleep();
        ret =  __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE,
                                   0, &ctx->dep_map, _RET_IP_, ctx);
-       if (!ret && ctx->acquired > 0)
+       if (!ret && ctx->acquired > 1)
                return ww_mutex_deadlock_injection(lock, ctx);
 
        return ret;
@@ -702,7 +702,7 @@ __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
        ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE,
                                  0, &ctx->dep_map, _RET_IP_, ctx);
 
-       if (!ret && ctx->acquired > 0)
+       if (!ret && ctx->acquired > 1)
                return ww_mutex_deadlock_injection(lock, ctx);
 
        return ret;
index c6422ffeda9a9c304a750b9321d555278b6a39d3..9012ecf7b814f9b476abff1ddd40ea508a12f9e1 100644 (file)
@@ -32,7 +32,8 @@ static void try_to_suspend(struct work_struct *work)
 
        mutex_lock(&autosleep_lock);
 
-       if (!pm_save_wakeup_count(initial_count)) {
+       if (!pm_save_wakeup_count(initial_count) ||
+               system_state != SYSTEM_RUNNING) {
                mutex_unlock(&autosleep_lock);
                goto out;
        }
index fc0df84864495f8c44261961cb6909e66d24a21e..06ec8869dbf1629f2c7cabc63f2edc96426ea87d 100644 (file)
@@ -109,6 +109,8 @@ static int try_to_freeze_tasks(bool user_only)
 
 /**
  * freeze_processes - Signal user space processes to enter the refrigerator.
+ * The current thread will not be frozen.  The same process that calls
+ * freeze_processes must later call thaw_processes.
  *
  * On success, returns 0.  On failure, -errno and system is fully thawed.
  */
@@ -120,6 +122,9 @@ int freeze_processes(void)
        if (error)
                return error;
 
+       /* Make sure this task doesn't get frozen */
+       current->flags |= PF_SUSPEND_TASK;
+
        if (!pm_freezing)
                atomic_inc(&system_freezing_cnt);
 
@@ -168,6 +173,7 @@ int freeze_kernel_threads(void)
 void thaw_processes(void)
 {
        struct task_struct *g, *p;
+       struct task_struct *curr = current;
 
        if (pm_freezing)
                atomic_dec(&system_freezing_cnt);
@@ -182,10 +188,15 @@ void thaw_processes(void)
 
        read_lock(&tasklist_lock);
        do_each_thread(g, p) {
+               /* No other threads should have PF_SUSPEND_TASK set */
+               WARN_ON((p != curr) && (p->flags & PF_SUSPEND_TASK));
                __thaw_task(p);
        } while_each_thread(g, p);
        read_unlock(&tasklist_lock);
 
+       WARN_ON(!(curr->flags & PF_SUSPEND_TASK));
+       curr->flags &= ~PF_SUSPEND_TASK;
+
        usermodehelper_enable();
 
        schedule();
index 06fe28589e9c9e88b014315dfab33a9e6cdfd0eb..a394297f8b2f94ea806a545c6e92e4b7221d2f7e 100644 (file)
@@ -296,6 +296,17 @@ int pm_qos_request_active(struct pm_qos_request *req)
 }
 EXPORT_SYMBOL_GPL(pm_qos_request_active);
 
+static void __pm_qos_update_request(struct pm_qos_request *req,
+                          s32 new_value)
+{
+       trace_pm_qos_update_request(req->pm_qos_class, new_value);
+
+       if (new_value != req->node.prio)
+               pm_qos_update_target(
+                       pm_qos_array[req->pm_qos_class]->constraints,
+                       &req->node, PM_QOS_UPDATE_REQ, new_value);
+}
+
 /**
  * pm_qos_work_fn - the timeout handler of pm_qos_update_request_timeout
  * @work: work struct for the delayed work (timeout)
@@ -308,7 +319,7 @@ static void pm_qos_work_fn(struct work_struct *work)
                                                  struct pm_qos_request,
                                                  work);
 
-       pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE);
+       __pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE);
 }
 
 /**
@@ -364,12 +375,7 @@ void pm_qos_update_request(struct pm_qos_request *req,
        }
 
        cancel_delayed_work_sync(&req->work);
-
-       trace_pm_qos_update_request(req->pm_qos_class, new_value);
-       if (new_value != req->node.prio)
-               pm_qos_update_target(
-                       pm_qos_array[req->pm_qos_class]->constraints,
-                       &req->node, PM_QOS_UPDATE_REQ, new_value);
+       __pm_qos_update_request(req, new_value);
 }
 EXPORT_SYMBOL_GPL(pm_qos_update_request);
 
diff --git a/kernel/printk.c b/kernel/printk.c
deleted file mode 100644 (file)
index d37d45c..0000000
+++ /dev/null
@@ -1,2924 +0,0 @@
-/*
- *  linux/kernel/printk.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *
- * Modified to make sys_syslog() more flexible: added commands to
- * return the last 4k of kernel messages, regardless of whether
- * they've been read or not.  Added option to suppress kernel printk's
- * to the console.  Added hook for sending the console messages
- * elsewhere, in preparation for a serial line console (someday).
- * Ted Ts'o, 2/11/93.
- * Modified for sysctl support, 1/8/97, Chris Horn.
- * Fixed SMP synchronization, 08/08/99, Manfred Spraul
- *     manfred@colorfullife.com
- * Rewrote bits to get rid of console_lock
- *     01Mar01 Andrew Morton
- */
-
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/tty.h>
-#include <linux/tty_driver.h>
-#include <linux/console.h>
-#include <linux/init.h>
-#include <linux/jiffies.h>
-#include <linux/nmi.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/interrupt.h>                   /* For in_interrupt() */
-#include <linux/delay.h>
-#include <linux/smp.h>
-#include <linux/security.h>
-#include <linux/bootmem.h>
-#include <linux/memblock.h>
-#include <linux/aio.h>
-#include <linux/syscalls.h>
-#include <linux/kexec.h>
-#include <linux/kdb.h>
-#include <linux/ratelimit.h>
-#include <linux/kmsg_dump.h>
-#include <linux/syslog.h>
-#include <linux/cpu.h>
-#include <linux/notifier.h>
-#include <linux/rculist.h>
-#include <linux/poll.h>
-#include <linux/irq_work.h>
-#include <linux/utsname.h>
-
-#include <asm/uaccess.h>
-
-#define CREATE_TRACE_POINTS
-#include <trace/events/printk.h>
-
-/* printk's without a loglevel use this.. */
-#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
-
-/* We show everything that is MORE important than this.. */
-#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
-#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
-
-int console_printk[4] = {
-       DEFAULT_CONSOLE_LOGLEVEL,       /* console_loglevel */
-       DEFAULT_MESSAGE_LOGLEVEL,       /* default_message_loglevel */
-       MINIMUM_CONSOLE_LOGLEVEL,       /* minimum_console_loglevel */
-       DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
-};
-
-/*
- * Low level drivers may need that to know if they can schedule in
- * their unblank() callback or not. So let's export it.
- */
-int oops_in_progress;
-EXPORT_SYMBOL(oops_in_progress);
-
-/*
- * console_sem protects the console_drivers list, and also
- * provides serialisation for access to the entire console
- * driver system.
- */
-static DEFINE_SEMAPHORE(console_sem);
-struct console *console_drivers;
-EXPORT_SYMBOL_GPL(console_drivers);
-
-#ifdef CONFIG_LOCKDEP
-static struct lockdep_map console_lock_dep_map = {
-       .name = "console_lock"
-};
-#endif
-
-/*
- * This is used for debugging the mess that is the VT code by
- * keeping track if we have the console semaphore held. It's
- * definitely not the perfect debug tool (we don't know if _WE_
- * hold it are racing, but it helps tracking those weird code
- * path in the console code where we end up in places I want
- * locked without the console sempahore held
- */
-static int console_locked, console_suspended;
-
-/*
- * If exclusive_console is non-NULL then only this console is to be printed to.
- */
-static struct console *exclusive_console;
-
-/*
- *     Array of consoles built from command line options (console=)
- */
-struct console_cmdline
-{
-       char    name[8];                        /* Name of the driver       */
-       int     index;                          /* Minor dev. to use        */
-       char    *options;                       /* Options for the driver   */
-#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
-       char    *brl_options;                   /* Options for braille driver */
-#endif
-};
-
-#define MAX_CMDLINECONSOLES 8
-
-static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
-static int selected_console = -1;
-static int preferred_console = -1;
-int console_set_on_cmdline;
-EXPORT_SYMBOL(console_set_on_cmdline);
-
-/* Flag: console code may call schedule() */
-static int console_may_schedule;
-
-/*
- * The printk log buffer consists of a chain of concatenated variable
- * length records. Every record starts with a record header, containing
- * the overall length of the record.
- *
- * The heads to the first and last entry in the buffer, as well as the
- * sequence numbers of these both entries are maintained when messages
- * are stored..
- *
- * If the heads indicate available messages, the length in the header
- * tells the start next message. A length == 0 for the next message
- * indicates a wrap-around to the beginning of the buffer.
- *
- * Every record carries the monotonic timestamp in microseconds, as well as
- * the standard userspace syslog level and syslog facility. The usual
- * kernel messages use LOG_KERN; userspace-injected messages always carry
- * a matching syslog facility, by default LOG_USER. The origin of every
- * message can be reliably determined that way.
- *
- * The human readable log message directly follows the message header. The
- * length of the message text is stored in the header, the stored message
- * is not terminated.
- *
- * Optionally, a message can carry a dictionary of properties (key/value pairs),
- * to provide userspace with a machine-readable message context.
- *
- * Examples for well-defined, commonly used property names are:
- *   DEVICE=b12:8               device identifier
- *                                b12:8         block dev_t
- *                                c127:3        char dev_t
- *                                n8            netdev ifindex
- *                                +sound:card0  subsystem:devname
- *   SUBSYSTEM=pci              driver-core subsystem name
- *
- * Valid characters in property names are [a-zA-Z0-9.-_]. The plain text value
- * follows directly after a '=' character. Every property is terminated by
- * a '\0' character. The last property is not terminated.
- *
- * Example of a message structure:
- *   0000  ff 8f 00 00 00 00 00 00      monotonic time in nsec
- *   0008  34 00                        record is 52 bytes long
- *   000a        0b 00                  text is 11 bytes long
- *   000c              1f 00            dictionary is 23 bytes long
- *   000e                    03 00      LOG_KERN (facility) LOG_ERR (level)
- *   0010  69 74 27 73 20 61 20 6c      "it's a l"
- *         69 6e 65                     "ine"
- *   001b           44 45 56 49 43      "DEVIC"
- *         45 3d 62 38 3a 32 00 44      "E=b8:2\0D"
- *         52 49 56 45 52 3d 62 75      "RIVER=bu"
- *         67                           "g"
- *   0032     00 00 00                  padding to next message header
- *
- * The 'struct log' buffer header must never be directly exported to
- * userspace, it is a kernel-private implementation detail that might
- * need to be changed in the future, when the requirements change.
- *
- * /dev/kmsg exports the structured data in the following line format:
- *   "level,sequnum,timestamp;<message text>\n"
- *
- * The optional key/value pairs are attached as continuation lines starting
- * with a space character and terminated by a newline. All possible
- * non-prinatable characters are escaped in the "\xff" notation.
- *
- * Users of the export format should ignore possible additional values
- * separated by ',', and find the message after the ';' character.
- */
-
-enum log_flags {
-       LOG_NOCONS      = 1,    /* already flushed, do not print to console */
-       LOG_NEWLINE     = 2,    /* text ended with a newline */
-       LOG_PREFIX      = 4,    /* text started with a prefix */
-       LOG_CONT        = 8,    /* text is a fragment of a continuation line */
-};
-
-struct log {
-       u64 ts_nsec;            /* timestamp in nanoseconds */
-       u16 len;                /* length of entire record */
-       u16 text_len;           /* length of text buffer */
-       u16 dict_len;           /* length of dictionary buffer */
-       u8 facility;            /* syslog facility */
-       u8 flags:5;             /* internal record flags */
-       u8 level:3;             /* syslog level */
-};
-
-/*
- * The logbuf_lock protects kmsg buffer, indices, counters. It is also
- * used in interesting ways to provide interlocking in console_unlock();
- */
-static DEFINE_RAW_SPINLOCK(logbuf_lock);
-
-#ifdef CONFIG_PRINTK
-DECLARE_WAIT_QUEUE_HEAD(log_wait);
-/* the next printk record to read by syslog(READ) or /proc/kmsg */
-static u64 syslog_seq;
-static u32 syslog_idx;
-static enum log_flags syslog_prev;
-static size_t syslog_partial;
-
-/* index and sequence number of the first record stored in the buffer */
-static u64 log_first_seq;
-static u32 log_first_idx;
-
-/* index and sequence number of the next record to store in the buffer */
-static u64 log_next_seq;
-static u32 log_next_idx;
-
-/* the next printk record to write to the console */
-static u64 console_seq;
-static u32 console_idx;
-static enum log_flags console_prev;
-
-/* the next printk record to read after the last 'clear' command */
-static u64 clear_seq;
-static u32 clear_idx;
-
-#define PREFIX_MAX             32
-#define LOG_LINE_MAX           1024 - PREFIX_MAX
-
-/* record buffer */
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
-#define LOG_ALIGN 4
-#else
-#define LOG_ALIGN __alignof__(struct log)
-#endif
-#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
-static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
-static char *log_buf = __log_buf;
-static u32 log_buf_len = __LOG_BUF_LEN;
-
-/* cpu currently holding logbuf_lock */
-static volatile unsigned int logbuf_cpu = UINT_MAX;
-
-/* human readable text of the record */
-static char *log_text(const struct log *msg)
-{
-       return (char *)msg + sizeof(struct log);
-}
-
-/* optional key/value pair dictionary attached to the record */
-static char *log_dict(const struct log *msg)
-{
-       return (char *)msg + sizeof(struct log) + msg->text_len;
-}
-
-/* get record by index; idx must point to valid msg */
-static struct log *log_from_idx(u32 idx)
-{
-       struct log *msg = (struct log *)(log_buf + idx);
-
-       /*
-        * A length == 0 record is the end of buffer marker. Wrap around and
-        * read the message at the start of the buffer.
-        */
-       if (!msg->len)
-               return (struct log *)log_buf;
-       return msg;
-}
-
-/* get next record; idx must point to valid msg */
-static u32 log_next(u32 idx)
-{
-       struct log *msg = (struct log *)(log_buf + idx);
-
-       /* length == 0 indicates the end of the buffer; wrap */
-       /*
-        * A length == 0 record is the end of buffer marker. Wrap around and
-        * read the message at the start of the buffer as *this* one, and
-        * return the one after that.
-        */
-       if (!msg->len) {
-               msg = (struct log *)log_buf;
-               return msg->len;
-       }
-       return idx + msg->len;
-}
-
-/* insert record into the buffer, discard old ones, update heads */
-static void log_store(int facility, int level,
-                     enum log_flags flags, u64 ts_nsec,
-                     const char *dict, u16 dict_len,
-                     const char *text, u16 text_len)
-{
-       struct log *msg;
-       u32 size, pad_len;
-
-       /* number of '\0' padding bytes to next message */
-       size = sizeof(struct log) + text_len + dict_len;
-       pad_len = (-size) & (LOG_ALIGN - 1);
-       size += pad_len;
-
-       while (log_first_seq < log_next_seq) {
-               u32 free;
-
-               if (log_next_idx > log_first_idx)
-                       free = max(log_buf_len - log_next_idx, log_first_idx);
-               else
-                       free = log_first_idx - log_next_idx;
-
-               if (free > size + sizeof(struct log))
-                       break;
-
-               /* drop old messages until we have enough contiuous space */
-               log_first_idx = log_next(log_first_idx);
-               log_first_seq++;
-       }
-
-       if (log_next_idx + size + sizeof(struct log) >= log_buf_len) {
-               /*
-                * This message + an additional empty header does not fit
-                * at the end of the buffer. Add an empty header with len == 0
-                * to signify a wrap around.
-                */
-               memset(log_buf + log_next_idx, 0, sizeof(struct log));
-               log_next_idx = 0;
-       }
-
-       /* fill message */
-       msg = (struct log *)(log_buf + log_next_idx);
-       memcpy(log_text(msg), text, text_len);
-       msg->text_len = text_len;
-       memcpy(log_dict(msg), dict, dict_len);
-       msg->dict_len = dict_len;
-       msg->facility = facility;
-       msg->level = level & 7;
-       msg->flags = flags & 0x1f;
-       if (ts_nsec > 0)
-               msg->ts_nsec = ts_nsec;
-       else
-               msg->ts_nsec = local_clock();
-       memset(log_dict(msg) + dict_len, 0, pad_len);
-       msg->len = sizeof(struct log) + text_len + dict_len + pad_len;
-
-       /* insert message */
-       log_next_idx += msg->len;
-       log_next_seq++;
-}
-
-#ifdef CONFIG_SECURITY_DMESG_RESTRICT
-int dmesg_restrict = 1;
-#else
-int dmesg_restrict;
-#endif
-
-static int syslog_action_restricted(int type)
-{
-       if (dmesg_restrict)
-               return 1;
-       /*
-        * Unless restricted, we allow "read all" and "get buffer size"
-        * for everybody.
-        */
-       return type != SYSLOG_ACTION_READ_ALL &&
-              type != SYSLOG_ACTION_SIZE_BUFFER;
-}
-
-static int check_syslog_permissions(int type, bool from_file)
-{
-       /*
-        * If this is from /proc/kmsg and we've already opened it, then we've
-        * already done the capabilities checks at open time.
-        */
-       if (from_file && type != SYSLOG_ACTION_OPEN)
-               return 0;
-
-       if (syslog_action_restricted(type)) {
-               if (capable(CAP_SYSLOG))
-                       return 0;
-               /*
-                * For historical reasons, accept CAP_SYS_ADMIN too, with
-                * a warning.
-                */
-               if (capable(CAP_SYS_ADMIN)) {
-                       pr_warn_once("%s (%d): Attempt to access syslog with "
-                                    "CAP_SYS_ADMIN but no CAP_SYSLOG "
-                                    "(deprecated).\n",
-                                current->comm, task_pid_nr(current));
-                       return 0;
-               }
-               return -EPERM;
-       }
-       return security_syslog(type);
-}
-
-
-/* /dev/kmsg - userspace message inject/listen interface */
-struct devkmsg_user {
-       u64 seq;
-       u32 idx;
-       enum log_flags prev;
-       struct mutex lock;
-       char buf[8192];
-};
-
-static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
-                             unsigned long count, loff_t pos)
-{
-       char *buf, *line;
-       int i;
-       int level = default_message_loglevel;
-       int facility = 1;       /* LOG_USER */
-       size_t len = iov_length(iv, count);
-       ssize_t ret = len;
-
-       if (len > LOG_LINE_MAX)
-               return -EINVAL;
-       buf = kmalloc(len+1, GFP_KERNEL);
-       if (buf == NULL)
-               return -ENOMEM;
-
-       line = buf;
-       for (i = 0; i < count; i++) {
-               if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) {
-                       ret = -EFAULT;
-                       goto out;
-               }
-               line += iv[i].iov_len;
-       }
-
-       /*
-        * Extract and skip the syslog prefix <[0-9]*>. Coming from userspace
-        * the decimal value represents 32bit, the lower 3 bit are the log
-        * level, the rest are the log facility.
-        *
-        * If no prefix or no userspace facility is specified, we
-        * enforce LOG_USER, to be able to reliably distinguish
-        * kernel-generated messages from userspace-injected ones.
-        */
-       line = buf;
-       if (line[0] == '<') {
-               char *endp = NULL;
-
-               i = simple_strtoul(line+1, &endp, 10);
-               if (endp && endp[0] == '>') {
-                       level = i & 7;
-                       if (i >> 3)
-                               facility = i >> 3;
-                       endp++;
-                       len -= endp - line;
-                       line = endp;
-               }
-       }
-       line[len] = '\0';
-
-       printk_emit(facility, level, NULL, 0, "%s", line);
-out:
-       kfree(buf);
-       return ret;
-}
-
-static ssize_t devkmsg_read(struct file *file, char __user *buf,
-                           size_t count, loff_t *ppos)
-{
-       struct devkmsg_user *user = file->private_data;
-       struct log *msg;
-       u64 ts_usec;
-       size_t i;
-       char cont = '-';
-       size_t len;
-       ssize_t ret;
-
-       if (!user)
-               return -EBADF;
-
-       ret = mutex_lock_interruptible(&user->lock);
-       if (ret)
-               return ret;
-       raw_spin_lock_irq(&logbuf_lock);
-       while (user->seq == log_next_seq) {
-               if (file->f_flags & O_NONBLOCK) {
-                       ret = -EAGAIN;
-                       raw_spin_unlock_irq(&logbuf_lock);
-                       goto out;
-               }
-
-               raw_spin_unlock_irq(&logbuf_lock);
-               ret = wait_event_interruptible(log_wait,
-                                              user->seq != log_next_seq);
-               if (ret)
-                       goto out;
-               raw_spin_lock_irq(&logbuf_lock);
-       }
-
-       if (user->seq < log_first_seq) {
-               /* our last seen message is gone, return error and reset */
-               user->idx = log_first_idx;
-               user->seq = log_first_seq;
-               ret = -EPIPE;
-               raw_spin_unlock_irq(&logbuf_lock);
-               goto out;
-       }
-
-       msg = log_from_idx(user->idx);
-       ts_usec = msg->ts_nsec;
-       do_div(ts_usec, 1000);
-
-       /*
-        * If we couldn't merge continuation line fragments during the print,
-        * export the stored flags to allow an optional external merge of the
-        * records. Merging the records isn't always neccessarily correct, like
-        * when we hit a race during printing. In most cases though, it produces
-        * better readable output. 'c' in the record flags mark the first
-        * fragment of a line, '+' the following.
-        */
-       if (msg->flags & LOG_CONT && !(user->prev & LOG_CONT))
-               cont = 'c';
-       else if ((msg->flags & LOG_CONT) ||
-                ((user->prev & LOG_CONT) && !(msg->flags & LOG_PREFIX)))
-               cont = '+';
-
-       len = sprintf(user->buf, "%u,%llu,%llu,%c;",
-                     (msg->facility << 3) | msg->level,
-                     user->seq, ts_usec, cont);
-       user->prev = msg->flags;
-
-       /* escape non-printable characters */
-       for (i = 0; i < msg->text_len; i++) {
-               unsigned char c = log_text(msg)[i];
-
-               if (c < ' ' || c >= 127 || c == '\\')
-                       len += sprintf(user->buf + len, "\\x%02x", c);
-               else
-                       user->buf[len++] = c;
-       }
-       user->buf[len++] = '\n';
-
-       if (msg->dict_len) {
-               bool line = true;
-
-               for (i = 0; i < msg->dict_len; i++) {
-                       unsigned char c = log_dict(msg)[i];
-
-                       if (line) {
-                               user->buf[len++] = ' ';
-                               line = false;
-                       }
-
-                       if (c == '\0') {
-                               user->buf[len++] = '\n';
-                               line = true;
-                               continue;
-                       }
-
-                       if (c < ' ' || c >= 127 || c == '\\') {
-                               len += sprintf(user->buf + len, "\\x%02x", c);
-                               continue;
-                       }
-
-                       user->buf[len++] = c;
-               }
-               user->buf[len++] = '\n';
-       }
-
-       user->idx = log_next(user->idx);
-       user->seq++;
-       raw_spin_unlock_irq(&logbuf_lock);
-
-       if (len > count) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (copy_to_user(buf, user->buf, len)) {
-               ret = -EFAULT;
-               goto out;
-       }
-       ret = len;
-out:
-       mutex_unlock(&user->lock);
-       return ret;
-}
-
-static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
-{
-       struct devkmsg_user *user = file->private_data;
-       loff_t ret = 0;
-
-       if (!user)
-               return -EBADF;
-       if (offset)
-               return -ESPIPE;
-
-       raw_spin_lock_irq(&logbuf_lock);
-       switch (whence) {
-       case SEEK_SET:
-               /* the first record */
-               user->idx = log_first_idx;
-               user->seq = log_first_seq;
-               break;
-       case SEEK_DATA:
-               /*
-                * The first record after the last SYSLOG_ACTION_CLEAR,
-                * like issued by 'dmesg -c'. Reading /dev/kmsg itself
-                * changes no global state, and does not clear anything.
-                */
-               user->idx = clear_idx;
-               user->seq = clear_seq;
-               break;
-       case SEEK_END:
-               /* after the last record */
-               user->idx = log_next_idx;
-               user->seq = log_next_seq;
-               break;
-       default:
-               ret = -EINVAL;
-       }
-       raw_spin_unlock_irq(&logbuf_lock);
-       return ret;
-}
-
-static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
-{
-       struct devkmsg_user *user = file->private_data;
-       int ret = 0;
-
-       if (!user)
-               return POLLERR|POLLNVAL;
-
-       poll_wait(file, &log_wait, wait);
-
-       raw_spin_lock_irq(&logbuf_lock);
-       if (user->seq < log_next_seq) {
-               /* return error when data has vanished underneath us */
-               if (user->seq < log_first_seq)
-                       ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI;
-               else
-                       ret = POLLIN|POLLRDNORM;
-       }
-       raw_spin_unlock_irq(&logbuf_lock);
-
-       return ret;
-}
-
-static int devkmsg_open(struct inode *inode, struct file *file)
-{
-       struct devkmsg_user *user;
-       int err;
-
-       /* write-only does not need any file context */
-       if ((file->f_flags & O_ACCMODE) == O_WRONLY)
-               return 0;
-
-       err = check_syslog_permissions(SYSLOG_ACTION_READ_ALL,
-                                      SYSLOG_FROM_READER);
-       if (err)
-               return err;
-
-       user = kmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);
-       if (!user)
-               return -ENOMEM;
-
-       mutex_init(&user->lock);
-
-       raw_spin_lock_irq(&logbuf_lock);
-       user->idx = log_first_idx;
-       user->seq = log_first_seq;
-       raw_spin_unlock_irq(&logbuf_lock);
-
-       file->private_data = user;
-       return 0;
-}
-
-static int devkmsg_release(struct inode *inode, struct file *file)
-{
-       struct devkmsg_user *user = file->private_data;
-
-       if (!user)
-               return 0;
-
-       mutex_destroy(&user->lock);
-       kfree(user);
-       return 0;
-}
-
-const struct file_operations kmsg_fops = {
-       .open = devkmsg_open,
-       .read = devkmsg_read,
-       .aio_write = devkmsg_writev,
-       .llseek = devkmsg_llseek,
-       .poll = devkmsg_poll,
-       .release = devkmsg_release,
-};
-
-#ifdef CONFIG_KEXEC
-/*
- * This appends the listed symbols to /proc/vmcoreinfo
- *
- * /proc/vmcoreinfo is used by various utiilties, like crash and makedumpfile to
- * obtain access to symbols that are otherwise very difficult to locate.  These
- * symbols are specifically used so that utilities can access and extract the
- * dmesg log from a vmcore file after a crash.
- */
-void log_buf_kexec_setup(void)
-{
-       VMCOREINFO_SYMBOL(log_buf);
-       VMCOREINFO_SYMBOL(log_buf_len);
-       VMCOREINFO_SYMBOL(log_first_idx);
-       VMCOREINFO_SYMBOL(log_next_idx);
-       /*
-        * Export struct log size and field offsets. User space tools can
-        * parse it and detect any changes to structure down the line.
-        */
-       VMCOREINFO_STRUCT_SIZE(log);
-       VMCOREINFO_OFFSET(log, ts_nsec);
-       VMCOREINFO_OFFSET(log, len);
-       VMCOREINFO_OFFSET(log, text_len);
-       VMCOREINFO_OFFSET(log, dict_len);
-}
-#endif
-
-/* requested log_buf_len from kernel cmdline */
-static unsigned long __initdata new_log_buf_len;
-
-/* save requested log_buf_len since it's too early to process it */
-static int __init log_buf_len_setup(char *str)
-{
-       unsigned size = memparse(str, &str);
-
-       if (size)
-               size = roundup_pow_of_two(size);
-       if (size > log_buf_len)
-               new_log_buf_len = size;
-
-       return 0;
-}
-early_param("log_buf_len", log_buf_len_setup);
-
-void __init setup_log_buf(int early)
-{
-       unsigned long flags;
-       char *new_log_buf;
-       int free;
-
-       if (!new_log_buf_len)
-               return;
-
-       if (early) {
-               unsigned long mem;
-
-               mem = memblock_alloc(new_log_buf_len, PAGE_SIZE);
-               if (!mem)
-                       return;
-               new_log_buf = __va(mem);
-       } else {
-               new_log_buf = alloc_bootmem_nopanic(new_log_buf_len);
-       }
-
-       if (unlikely(!new_log_buf)) {
-               pr_err("log_buf_len: %ld bytes not available\n",
-                       new_log_buf_len);
-               return;
-       }
-
-       raw_spin_lock_irqsave(&logbuf_lock, flags);
-       log_buf_len = new_log_buf_len;
-       log_buf = new_log_buf;
-       new_log_buf_len = 0;
-       free = __LOG_BUF_LEN - log_next_idx;
-       memcpy(log_buf, __log_buf, __LOG_BUF_LEN);
-       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-
-       pr_info("log_buf_len: %d\n", log_buf_len);
-       pr_info("early log buf free: %d(%d%%)\n",
-               free, (free * 100) / __LOG_BUF_LEN);
-}
-
-static bool __read_mostly ignore_loglevel;
-
-static int __init ignore_loglevel_setup(char *str)
-{
-       ignore_loglevel = 1;
-       printk(KERN_INFO "debug: ignoring loglevel setting.\n");
-
-       return 0;
-}
-
-early_param("ignore_loglevel", ignore_loglevel_setup);
-module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
-       "print all kernel messages to the console.");
-
-#ifdef CONFIG_BOOT_PRINTK_DELAY
-
-static int boot_delay; /* msecs delay after each printk during bootup */
-static unsigned long long loops_per_msec;      /* based on boot_delay */
-
-static int __init boot_delay_setup(char *str)
-{
-       unsigned long lpj;
-
-       lpj = preset_lpj ? preset_lpj : 1000000;        /* some guess */
-       loops_per_msec = (unsigned long long)lpj / 1000 * HZ;
-
-       get_option(&str, &boot_delay);
-       if (boot_delay > 10 * 1000)
-               boot_delay = 0;
-
-       pr_debug("boot_delay: %u, preset_lpj: %ld, lpj: %lu, "
-               "HZ: %d, loops_per_msec: %llu\n",
-               boot_delay, preset_lpj, lpj, HZ, loops_per_msec);
-       return 1;
-}
-__setup("boot_delay=", boot_delay_setup);
-
-static void boot_delay_msec(int level)
-{
-       unsigned long long k;
-       unsigned long timeout;
-
-       if ((boot_delay == 0 || system_state != SYSTEM_BOOTING)
-               || (level >= console_loglevel && !ignore_loglevel)) {
-               return;
-       }
-
-       k = (unsigned long long)loops_per_msec * boot_delay;
-
-       timeout = jiffies + msecs_to_jiffies(boot_delay);
-       while (k) {
-               k--;
-               cpu_relax();
-               /*
-                * use (volatile) jiffies to prevent
-                * compiler reduction; loop termination via jiffies
-                * is secondary and may or may not happen.
-                */
-               if (time_after(jiffies, timeout))
-                       break;
-               touch_nmi_watchdog();
-       }
-}
-#else
-static inline void boot_delay_msec(int level)
-{
-}
-#endif
-
-#if defined(CONFIG_PRINTK_TIME)
-static bool printk_time = 1;
-#else
-static bool printk_time;
-#endif
-module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
-
-static size_t print_time(u64 ts, char *buf)
-{
-       unsigned long rem_nsec;
-
-       if (!printk_time)
-               return 0;
-
-       rem_nsec = do_div(ts, 1000000000);
-
-       if (!buf)
-               return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
-
-       return sprintf(buf, "[%5lu.%06lu] ",
-                      (unsigned long)ts, rem_nsec / 1000);
-}
-
-static size_t print_prefix(const struct log *msg, bool syslog, char *buf)
-{
-       size_t len = 0;
-       unsigned int prefix = (msg->facility << 3) | msg->level;
-
-       if (syslog) {
-               if (buf) {
-                       len += sprintf(buf, "<%u>", prefix);
-               } else {
-                       len += 3;
-                       if (prefix > 999)
-                               len += 3;
-                       else if (prefix > 99)
-                               len += 2;
-                       else if (prefix > 9)
-                               len++;
-               }
-       }
-
-       len += print_time(msg->ts_nsec, buf ? buf + len : NULL);
-       return len;
-}
-
-static size_t msg_print_text(const struct log *msg, enum log_flags prev,
-                            bool syslog, char *buf, size_t size)
-{
-       const char *text = log_text(msg);
-       size_t text_size = msg->text_len;
-       bool prefix = true;
-       bool newline = true;
-       size_t len = 0;
-
-       if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
-               prefix = false;
-
-       if (msg->flags & LOG_CONT) {
-               if ((prev & LOG_CONT) && !(prev & LOG_NEWLINE))
-                       prefix = false;
-
-               if (!(msg->flags & LOG_NEWLINE))
-                       newline = false;
-       }
-
-       do {
-               const char *next = memchr(text, '\n', text_size);
-               size_t text_len;
-
-               if (next) {
-                       text_len = next - text;
-                       next++;
-                       text_size -= next - text;
-               } else {
-                       text_len = text_size;
-               }
-
-               if (buf) {
-                       if (print_prefix(msg, syslog, NULL) +
-                           text_len + 1 >= size - len)
-                               break;
-
-                       if (prefix)
-                               len += print_prefix(msg, syslog, buf + len);
-                       memcpy(buf + len, text, text_len);
-                       len += text_len;
-                       if (next || newline)
-                               buf[len++] = '\n';
-               } else {
-                       /* SYSLOG_ACTION_* buffer size only calculation */
-                       if (prefix)
-                               len += print_prefix(msg, syslog, NULL);
-                       len += text_len;
-                       if (next || newline)
-                               len++;
-               }
-
-               prefix = true;
-               text = next;
-       } while (text);
-
-       return len;
-}
-
-static int syslog_print(char __user *buf, int size)
-{
-       char *text;
-       struct log *msg;
-       int len = 0;
-
-       text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
-       if (!text)
-               return -ENOMEM;
-
-       while (size > 0) {
-               size_t n;
-               size_t skip;
-
-               raw_spin_lock_irq(&logbuf_lock);
-               if (syslog_seq < log_first_seq) {
-                       /* messages are gone, move to first one */
-                       syslog_seq = log_first_seq;
-                       syslog_idx = log_first_idx;
-                       syslog_prev = 0;
-                       syslog_partial = 0;
-               }
-               if (syslog_seq == log_next_seq) {
-                       raw_spin_unlock_irq(&logbuf_lock);
-                       break;
-               }
-
-               skip = syslog_partial;
-               msg = log_from_idx(syslog_idx);
-               n = msg_print_text(msg, syslog_prev, true, text,
-                                  LOG_LINE_MAX + PREFIX_MAX);
-               if (n - syslog_partial <= size) {
-                       /* message fits into buffer, move forward */
-                       syslog_idx = log_next(syslog_idx);
-                       syslog_seq++;
-                       syslog_prev = msg->flags;
-                       n -= syslog_partial;
-                       syslog_partial = 0;
-               } else if (!len){
-                       /* partial read(), remember position */
-                       n = size;
-                       syslog_partial += n;
-               } else
-                       n = 0;
-               raw_spin_unlock_irq(&logbuf_lock);
-
-               if (!n)
-                       break;
-
-               if (copy_to_user(buf, text + skip, n)) {
-                       if (!len)
-                               len = -EFAULT;
-                       break;
-               }
-
-               len += n;
-               size -= n;
-               buf += n;
-       }
-
-       kfree(text);
-       return len;
-}
-
-static int syslog_print_all(char __user *buf, int size, bool clear)
-{
-       char *text;
-       int len = 0;
-
-       text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
-       if (!text)
-               return -ENOMEM;
-
-       raw_spin_lock_irq(&logbuf_lock);
-       if (buf) {
-               u64 next_seq;
-               u64 seq;
-               u32 idx;
-               enum log_flags prev;
-
-               if (clear_seq < log_first_seq) {
-                       /* messages are gone, move to first available one */
-                       clear_seq = log_first_seq;
-                       clear_idx = log_first_idx;
-               }
-
-               /*
-                * Find first record that fits, including all following records,
-                * into the user-provided buffer for this dump.
-                */
-               seq = clear_seq;
-               idx = clear_idx;
-               prev = 0;
-               while (seq < log_next_seq) {
-                       struct log *msg = log_from_idx(idx);
-
-                       len += msg_print_text(msg, prev, true, NULL, 0);
-                       prev = msg->flags;
-                       idx = log_next(idx);
-                       seq++;
-               }
-
-               /* move first record forward until length fits into the buffer */
-               seq = clear_seq;
-               idx = clear_idx;
-               prev = 0;
-               while (len > size && seq < log_next_seq) {
-                       struct log *msg = log_from_idx(idx);
-
-                       len -= msg_print_text(msg, prev, true, NULL, 0);
-                       prev = msg->flags;
-                       idx = log_next(idx);
-                       seq++;
-               }
-
-               /* last message fitting into this dump */
-               next_seq = log_next_seq;
-
-               len = 0;
-               prev = 0;
-               while (len >= 0 && seq < next_seq) {
-                       struct log *msg = log_from_idx(idx);
-                       int textlen;
-
-                       textlen = msg_print_text(msg, prev, true, text,
-                                                LOG_LINE_MAX + PREFIX_MAX);
-                       if (textlen < 0) {
-                               len = textlen;
-                               break;
-                       }
-                       idx = log_next(idx);
-                       seq++;
-                       prev = msg->flags;
-
-                       raw_spin_unlock_irq(&logbuf_lock);
-                       if (copy_to_user(buf + len, text, textlen))
-                               len = -EFAULT;
-                       else
-                               len += textlen;
-                       raw_spin_lock_irq(&logbuf_lock);
-
-                       if (seq < log_first_seq) {
-                               /* messages are gone, move to next one */
-                               seq = log_first_seq;
-                               idx = log_first_idx;
-                               prev = 0;
-                       }
-               }
-       }
-
-       if (clear) {
-               clear_seq = log_next_seq;
-               clear_idx = log_next_idx;
-       }
-       raw_spin_unlock_irq(&logbuf_lock);
-
-       kfree(text);
-       return len;
-}
-
-int do_syslog(int type, char __user *buf, int len, bool from_file)
-{
-       bool clear = false;
-       static int saved_console_loglevel = -1;
-       int error;
-
-       error = check_syslog_permissions(type, from_file);
-       if (error)
-               goto out;
-
-       error = security_syslog(type);
-       if (error)
-               return error;
-
-       switch (type) {
-       case SYSLOG_ACTION_CLOSE:       /* Close log */
-               break;
-       case SYSLOG_ACTION_OPEN:        /* Open log */
-               break;
-       case SYSLOG_ACTION_READ:        /* Read from log */
-               error = -EINVAL;
-               if (!buf || len < 0)
-                       goto out;
-               error = 0;
-               if (!len)
-                       goto out;
-               if (!access_ok(VERIFY_WRITE, buf, len)) {
-                       error = -EFAULT;
-                       goto out;
-               }
-               error = wait_event_interruptible(log_wait,
-                                                syslog_seq != log_next_seq);
-               if (error)
-                       goto out;
-               error = syslog_print(buf, len);
-               break;
-       /* Read/clear last kernel messages */
-       case SYSLOG_ACTION_READ_CLEAR:
-               clear = true;
-               /* FALL THRU */
-       /* Read last kernel messages */
-       case SYSLOG_ACTION_READ_ALL:
-               error = -EINVAL;
-               if (!buf || len < 0)
-                       goto out;
-               error = 0;
-               if (!len)
-                       goto out;
-               if (!access_ok(VERIFY_WRITE, buf, len)) {
-                       error = -EFAULT;
-                       goto out;
-               }
-               error = syslog_print_all(buf, len, clear);
-               break;
-       /* Clear ring buffer */
-       case SYSLOG_ACTION_CLEAR:
-               syslog_print_all(NULL, 0, true);
-               break;
-       /* Disable logging to console */
-       case SYSLOG_ACTION_CONSOLE_OFF:
-               if (saved_console_loglevel == -1)
-                       saved_console_loglevel = console_loglevel;
-               console_loglevel = minimum_console_loglevel;
-               break;
-       /* Enable logging to console */
-       case SYSLOG_ACTION_CONSOLE_ON:
-               if (saved_console_loglevel != -1) {
-                       console_loglevel = saved_console_loglevel;
-                       saved_console_loglevel = -1;
-               }
-               break;
-       /* Set level of messages printed to console */
-       case SYSLOG_ACTION_CONSOLE_LEVEL:
-               error = -EINVAL;
-               if (len < 1 || len > 8)
-                       goto out;
-               if (len < minimum_console_loglevel)
-                       len = minimum_console_loglevel;
-               console_loglevel = len;
-               /* Implicitly re-enable logging to console */
-               saved_console_loglevel = -1;
-               error = 0;
-               break;
-       /* Number of chars in the log buffer */
-       case SYSLOG_ACTION_SIZE_UNREAD:
-               raw_spin_lock_irq(&logbuf_lock);
-               if (syslog_seq < log_first_seq) {
-                       /* messages are gone, move to first one */
-                       syslog_seq = log_first_seq;
-                       syslog_idx = log_first_idx;
-                       syslog_prev = 0;
-                       syslog_partial = 0;
-               }
-               if (from_file) {
-                       /*
-                        * Short-cut for poll(/"proc/kmsg") which simply checks
-                        * for pending data, not the size; return the count of
-                        * records, not the length.
-                        */
-                       error = log_next_idx - syslog_idx;
-               } else {
-                       u64 seq = syslog_seq;
-                       u32 idx = syslog_idx;
-                       enum log_flags prev = syslog_prev;
-
-                       error = 0;
-                       while (seq < log_next_seq) {
-                               struct log *msg = log_from_idx(idx);
-
-                               error += msg_print_text(msg, prev, true, NULL, 0);
-                               idx = log_next(idx);
-                               seq++;
-                               prev = msg->flags;
-                       }
-                       error -= syslog_partial;
-               }
-               raw_spin_unlock_irq(&logbuf_lock);
-               break;
-       /* Size of the log buffer */
-       case SYSLOG_ACTION_SIZE_BUFFER:
-               error = log_buf_len;
-               break;
-       default:
-               error = -EINVAL;
-               break;
-       }
-out:
-       return error;
-}
-
-SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
-{
-       return do_syslog(type, buf, len, SYSLOG_FROM_READER);
-}
-
-/*
- * Call the console drivers, asking them to write out
- * log_buf[start] to log_buf[end - 1].
- * The console_lock must be held.
- */
-static void call_console_drivers(int level, const char *text, size_t len)
-{
-       struct console *con;
-
-       trace_console(text, len);
-
-       if (level >= console_loglevel && !ignore_loglevel)
-               return;
-       if (!console_drivers)
-               return;
-
-       for_each_console(con) {
-               if (exclusive_console && con != exclusive_console)
-                       continue;
-               if (!(con->flags & CON_ENABLED))
-                       continue;
-               if (!con->write)
-                       continue;
-               if (!cpu_online(smp_processor_id()) &&
-                   !(con->flags & CON_ANYTIME))
-                       continue;
-               con->write(con, text, len);
-       }
-}
-
-/*
- * Zap console related locks when oopsing. Only zap at most once
- * every 10 seconds, to leave time for slow consoles to print a
- * full oops.
- */
-static void zap_locks(void)
-{
-       static unsigned long oops_timestamp;
-
-       if (time_after_eq(jiffies, oops_timestamp) &&
-                       !time_after(jiffies, oops_timestamp + 30 * HZ))
-               return;
-
-       oops_timestamp = jiffies;
-
-       debug_locks_off();
-       /* If a crash is occurring, make sure we can't deadlock */
-       raw_spin_lock_init(&logbuf_lock);
-       /* And make sure that we print immediately */
-       sema_init(&console_sem, 1);
-}
-
-/* Check if we have any console registered that can be called early in boot. */
-static int have_callable_console(void)
-{
-       struct console *con;
-
-       for_each_console(con)
-               if (con->flags & CON_ANYTIME)
-                       return 1;
-
-       return 0;
-}
-
-/*
- * Can we actually use the console at this time on this cpu?
- *
- * Console drivers may assume that per-cpu resources have
- * been allocated. So unless they're explicitly marked as
- * being able to cope (CON_ANYTIME) don't call them until
- * this CPU is officially up.
- */
-static inline int can_use_console(unsigned int cpu)
-{
-       return cpu_online(cpu) || have_callable_console();
-}
-
-/*
- * Try to get console ownership to actually show the kernel
- * messages from a 'printk'. Return true (and with the
- * console_lock held, and 'console_locked' set) if it
- * is successful, false otherwise.
- *
- * This gets called with the 'logbuf_lock' spinlock held and
- * interrupts disabled. It should return with 'lockbuf_lock'
- * released but interrupts still disabled.
- */
-static int console_trylock_for_printk(unsigned int cpu)
-       __releases(&logbuf_lock)
-{
-       int retval = 0, wake = 0;
-
-       if (console_trylock()) {
-               retval = 1;
-
-               /*
-                * If we can't use the console, we need to release
-                * the console semaphore by hand to avoid flushing
-                * the buffer. We need to hold the console semaphore
-                * in order to do this test safely.
-                */
-               if (!can_use_console(cpu)) {
-                       console_locked = 0;
-                       wake = 1;
-                       retval = 0;
-               }
-       }
-       logbuf_cpu = UINT_MAX;
-       raw_spin_unlock(&logbuf_lock);
-       if (wake)
-               up(&console_sem);
-       return retval;
-}
-
-int printk_delay_msec __read_mostly;
-
-static inline void printk_delay(void)
-{
-       if (unlikely(printk_delay_msec)) {
-               int m = printk_delay_msec;
-
-               while (m--) {
-                       mdelay(1);
-                       touch_nmi_watchdog();
-               }
-       }
-}
-
-/*
- * Continuation lines are buffered, and not committed to the record buffer
- * until the line is complete, or a race forces it. The line fragments
- * though, are printed immediately to the consoles to ensure everything has
- * reached the console in case of a kernel crash.
- */
-static struct cont {
-       char buf[LOG_LINE_MAX];
-       size_t len;                     /* length == 0 means unused buffer */
-       size_t cons;                    /* bytes written to console */
-       struct task_struct *owner;      /* task of first print*/
-       u64 ts_nsec;                    /* time of first print */
-       u8 level;                       /* log level of first message */
-       u8 facility;                    /* log level of first message */
-       enum log_flags flags;           /* prefix, newline flags */
-       bool flushed:1;                 /* buffer sealed and committed */
-} cont;
-
-static void cont_flush(enum log_flags flags)
-{
-       if (cont.flushed)
-               return;
-       if (cont.len == 0)
-               return;
-
-       if (cont.cons) {
-               /*
-                * If a fragment of this line was directly flushed to the
-                * console; wait for the console to pick up the rest of the
-                * line. LOG_NOCONS suppresses a duplicated output.
-                */
-               log_store(cont.facility, cont.level, flags | LOG_NOCONS,
-                         cont.ts_nsec, NULL, 0, cont.buf, cont.len);
-               cont.flags = flags;
-               cont.flushed = true;
-       } else {
-               /*
-                * If no fragment of this line ever reached the console,
-                * just submit it to the store and free the buffer.
-                */
-               log_store(cont.facility, cont.level, flags, 0,
-                         NULL, 0, cont.buf, cont.len);
-               cont.len = 0;
-       }
-}
-
-static bool cont_add(int facility, int level, const char *text, size_t len)
-{
-       if (cont.len && cont.flushed)
-               return false;
-
-       if (cont.len + len > sizeof(cont.buf)) {
-               /* the line gets too long, split it up in separate records */
-               cont_flush(LOG_CONT);
-               return false;
-       }
-
-       if (!cont.len) {
-               cont.facility = facility;
-               cont.level = level;
-               cont.owner = current;
-               cont.ts_nsec = local_clock();
-               cont.flags = 0;
-               cont.cons = 0;
-               cont.flushed = false;
-       }
-
-       memcpy(cont.buf + cont.len, text, len);
-       cont.len += len;
-
-       if (cont.len > (sizeof(cont.buf) * 80) / 100)
-               cont_flush(LOG_CONT);
-
-       return true;
-}
-
-static size_t cont_print_text(char *text, size_t size)
-{
-       size_t textlen = 0;
-       size_t len;
-
-       if (cont.cons == 0 && (console_prev & LOG_NEWLINE)) {
-               textlen += print_time(cont.ts_nsec, text);
-               size -= textlen;
-       }
-
-       len = cont.len - cont.cons;
-       if (len > 0) {
-               if (len+1 > size)
-                       len = size-1;
-               memcpy(text + textlen, cont.buf + cont.cons, len);
-               textlen += len;
-               cont.cons = cont.len;
-       }
-
-       if (cont.flushed) {
-               if (cont.flags & LOG_NEWLINE)
-                       text[textlen++] = '\n';
-               /* got everything, release buffer */
-               cont.len = 0;
-       }
-       return textlen;
-}
-
-asmlinkage int vprintk_emit(int facility, int level,
-                           const char *dict, size_t dictlen,
-                           const char *fmt, va_list args)
-{
-       static int recursion_bug;
-       static char textbuf[LOG_LINE_MAX];
-       char *text = textbuf;
-       size_t text_len;
-       enum log_flags lflags = 0;
-       unsigned long flags;
-       int this_cpu;
-       int printed_len = 0;
-
-       boot_delay_msec(level);
-       printk_delay();
-
-       /* This stops the holder of console_sem just where we want him */
-       local_irq_save(flags);
-       this_cpu = smp_processor_id();
-
-       /*
-        * Ouch, printk recursed into itself!
-        */
-       if (unlikely(logbuf_cpu == this_cpu)) {
-               /*
-                * If a crash is occurring during printk() on this CPU,
-                * then try to get the crash message out but make sure
-                * we can't deadlock. Otherwise just return to avoid the
-                * recursion and return - but flag the recursion so that
-                * it can be printed at the next appropriate moment:
-                */
-               if (!oops_in_progress && !lockdep_recursing(current)) {
-                       recursion_bug = 1;
-                       goto out_restore_irqs;
-               }
-               zap_locks();
-       }
-
-       lockdep_off();
-       raw_spin_lock(&logbuf_lock);
-       logbuf_cpu = this_cpu;
-
-       if (recursion_bug) {
-               static const char recursion_msg[] =
-                       "BUG: recent printk recursion!";
-
-               recursion_bug = 0;
-               printed_len += strlen(recursion_msg);
-               /* emit KERN_CRIT message */
-               log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0,
-                         NULL, 0, recursion_msg, printed_len);
-       }
-
-       /*
-        * The printf needs to come first; we need the syslog
-        * prefix which might be passed-in as a parameter.
-        */
-       text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
-
-       /* mark and strip a trailing newline */
-       if (text_len && text[text_len-1] == '\n') {
-               text_len--;
-               lflags |= LOG_NEWLINE;
-       }
-
-       /* strip kernel syslog prefix and extract log level or control flags */
-       if (facility == 0) {
-               int kern_level = printk_get_level(text);
-
-               if (kern_level) {
-                       const char *end_of_header = printk_skip_level(text);
-                       switch (kern_level) {
-                       case '0' ... '7':
-                               if (level == -1)
-                                       level = kern_level - '0';
-                       case 'd':       /* KERN_DEFAULT */
-                               lflags |= LOG_PREFIX;
-                       case 'c':       /* KERN_CONT */
-                               break;
-                       }
-                       text_len -= end_of_header - text;
-                       text = (char *)end_of_header;
-               }
-       }
-
-       if (level == -1)
-               level = default_message_loglevel;
-
-       if (dict)
-               lflags |= LOG_PREFIX|LOG_NEWLINE;
-
-       if (!(lflags & LOG_NEWLINE)) {
-               /*
-                * Flush the conflicting buffer. An earlier newline was missing,
-                * or another task also prints continuation lines.
-                */
-               if (cont.len && (lflags & LOG_PREFIX || cont.owner != current))
-                       cont_flush(LOG_NEWLINE);
-
-               /* buffer line if possible, otherwise store it right away */
-               if (!cont_add(facility, level, text, text_len))
-                       log_store(facility, level, lflags | LOG_CONT, 0,
-                                 dict, dictlen, text, text_len);
-       } else {
-               bool stored = false;
-
-               /*
-                * If an earlier newline was missing and it was the same task,
-                * either merge it with the current buffer and flush, or if
-                * there was a race with interrupts (prefix == true) then just
-                * flush it out and store this line separately.
-                */
-               if (cont.len && cont.owner == current) {
-                       if (!(lflags & LOG_PREFIX))
-                               stored = cont_add(facility, level, text, text_len);
-                       cont_flush(LOG_NEWLINE);
-               }
-
-               if (!stored)
-                       log_store(facility, level, lflags, 0,
-                                 dict, dictlen, text, text_len);
-       }
-       printed_len += text_len;
-
-       /*
-        * Try to acquire and then immediately release the console semaphore.
-        * The release will print out buffers and wake up /dev/kmsg and syslog()
-        * users.
-        *
-        * The console_trylock_for_printk() function will release 'logbuf_lock'
-        * regardless of whether it actually gets the console semaphore or not.
-        */
-       if (console_trylock_for_printk(this_cpu))
-               console_unlock();
-
-       lockdep_on();
-out_restore_irqs:
-       local_irq_restore(flags);
-
-       return printed_len;
-}
-EXPORT_SYMBOL(vprintk_emit);
-
-asmlinkage int vprintk(const char *fmt, va_list args)
-{
-       return vprintk_emit(0, -1, NULL, 0, fmt, args);
-}
-EXPORT_SYMBOL(vprintk);
-
-asmlinkage int printk_emit(int facility, int level,
-                          const char *dict, size_t dictlen,
-                          const char *fmt, ...)
-{
-       va_list args;
-       int r;
-
-       va_start(args, fmt);
-       r = vprintk_emit(facility, level, dict, dictlen, fmt, args);
-       va_end(args);
-
-       return r;
-}
-EXPORT_SYMBOL(printk_emit);
-
-/**
- * printk - print a kernel message
- * @fmt: format string
- *
- * This is printk(). It can be called from any context. We want it to work.
- *
- * We try to grab the console_lock. If we succeed, it's easy - we log the
- * output and call the console drivers.  If we fail to get the semaphore, we
- * place the output into the log buffer and return. The current holder of
- * the console_sem will notice the new output in console_unlock(); and will
- * send it to the consoles before releasing the lock.
- *
- * One effect of this deferred printing is that code which calls printk() and
- * then changes console_loglevel may break. This is because console_loglevel
- * is inspected when the actual printing occurs.
- *
- * See also:
- * printf(3)
- *
- * See the vsnprintf() documentation for format string extensions over C99.
- */
-asmlinkage int printk(const char *fmt, ...)
-{
-       va_list args;
-       int r;
-
-#ifdef CONFIG_KGDB_KDB
-       if (unlikely(kdb_trap_printk)) {
-               va_start(args, fmt);
-               r = vkdb_printf(fmt, args);
-               va_end(args);
-               return r;
-       }
-#endif
-       va_start(args, fmt);
-       r = vprintk_emit(0, -1, NULL, 0, fmt, args);
-       va_end(args);
-
-       return r;
-}
-EXPORT_SYMBOL(printk);
-
-#else /* CONFIG_PRINTK */
-
-#define LOG_LINE_MAX           0
-#define PREFIX_MAX             0
-#define LOG_LINE_MAX 0
-static u64 syslog_seq;
-static u32 syslog_idx;
-static u64 console_seq;
-static u32 console_idx;
-static enum log_flags syslog_prev;
-static u64 log_first_seq;
-static u32 log_first_idx;
-static u64 log_next_seq;
-static enum log_flags console_prev;
-static struct cont {
-       size_t len;
-       size_t cons;
-       u8 level;
-       bool flushed:1;
-} cont;
-static struct log *log_from_idx(u32 idx) { return NULL; }
-static u32 log_next(u32 idx) { return 0; }
-static void call_console_drivers(int level, const char *text, size_t len) {}
-static size_t msg_print_text(const struct log *msg, enum log_flags prev,
-                            bool syslog, char *buf, size_t size) { return 0; }
-static size_t cont_print_text(char *text, size_t size) { return 0; }
-
-#endif /* CONFIG_PRINTK */
-
-#ifdef CONFIG_EARLY_PRINTK
-struct console *early_console;
-
-void early_vprintk(const char *fmt, va_list ap)
-{
-       if (early_console) {
-               char buf[512];
-               int n = vscnprintf(buf, sizeof(buf), fmt, ap);
-
-               early_console->write(early_console, buf, n);
-       }
-}
-
-asmlinkage void early_printk(const char *fmt, ...)
-{
-       va_list ap;
-
-       va_start(ap, fmt);
-       early_vprintk(fmt, ap);
-       va_end(ap);
-}
-#endif
-
-static int __add_preferred_console(char *name, int idx, char *options,
-                                  char *brl_options)
-{
-       struct console_cmdline *c;
-       int i;
-
-       /*
-        *      See if this tty is not yet registered, and
-        *      if we have a slot free.
-        */
-       for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
-               if (strcmp(console_cmdline[i].name, name) == 0 &&
-                         console_cmdline[i].index == idx) {
-                               if (!brl_options)
-                                       selected_console = i;
-                               return 0;
-               }
-       if (i == MAX_CMDLINECONSOLES)
-               return -E2BIG;
-       if (!brl_options)
-               selected_console = i;
-       c = &console_cmdline[i];
-       strlcpy(c->name, name, sizeof(c->name));
-       c->options = options;
-#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
-       c->brl_options = brl_options;
-#endif
-       c->index = idx;
-       return 0;
-}
-/*
- * Set up a list of consoles.  Called from init/main.c
- */
-static int __init console_setup(char *str)
-{
-       char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for index */
-       char *s, *options, *brl_options = NULL;
-       int idx;
-
-#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
-       if (!memcmp(str, "brl,", 4)) {
-               brl_options = "";
-               str += 4;
-       } else if (!memcmp(str, "brl=", 4)) {
-               brl_options = str + 4;
-               str = strchr(brl_options, ',');
-               if (!str) {
-                       printk(KERN_ERR "need port name after brl=\n");
-                       return 1;
-               }
-               *(str++) = 0;
-       }
-#endif
-
-       /*
-        * Decode str into name, index, options.
-        */
-       if (str[0] >= '0' && str[0] <= '9') {
-               strcpy(buf, "ttyS");
-               strncpy(buf + 4, str, sizeof(buf) - 5);
-       } else {
-               strncpy(buf, str, sizeof(buf) - 1);
-       }
-       buf[sizeof(buf) - 1] = 0;
-       if ((options = strchr(str, ',')) != NULL)
-               *(options++) = 0;
-#ifdef __sparc__
-       if (!strcmp(str, "ttya"))
-               strcpy(buf, "ttyS0");
-       if (!strcmp(str, "ttyb"))
-               strcpy(buf, "ttyS1");
-#endif
-       for (s = buf; *s; s++)
-               if ((*s >= '0' && *s <= '9') || *s == ',')
-                       break;
-       idx = simple_strtoul(s, NULL, 10);
-       *s = 0;
-
-       __add_preferred_console(buf, idx, options, brl_options);
-       console_set_on_cmdline = 1;
-       return 1;
-}
-__setup("console=", console_setup);
-
-/**
- * add_preferred_console - add a device to the list of preferred consoles.
- * @name: device name
- * @idx: device index
- * @options: options for this console
- *
- * The last preferred console added will be used for kernel messages
- * and stdin/out/err for init.  Normally this is used by console_setup
- * above to handle user-supplied console arguments; however it can also
- * be used by arch-specific code either to override the user or more
- * commonly to provide a default console (ie from PROM variables) when
- * the user has not supplied one.
- */
-int add_preferred_console(char *name, int idx, char *options)
-{
-       return __add_preferred_console(name, idx, options, NULL);
-}
-
-int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options)
-{
-       struct console_cmdline *c;
-       int i;
-
-       for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
-               if (strcmp(console_cmdline[i].name, name) == 0 &&
-                         console_cmdline[i].index == idx) {
-                               c = &console_cmdline[i];
-                               strlcpy(c->name, name_new, sizeof(c->name));
-                               c->name[sizeof(c->name) - 1] = 0;
-                               c->options = options;
-                               c->index = idx_new;
-                               return i;
-               }
-       /* not found */
-       return -1;
-}
-
-bool console_suspend_enabled = 1;
-EXPORT_SYMBOL(console_suspend_enabled);
-
-static int __init console_suspend_disable(char *str)
-{
-       console_suspend_enabled = 0;
-       return 1;
-}
-__setup("no_console_suspend", console_suspend_disable);
-module_param_named(console_suspend, console_suspend_enabled,
-               bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(console_suspend, "suspend console during suspend"
-       " and hibernate operations");
-
-/**
- * suspend_console - suspend the console subsystem
- *
- * This disables printk() while we go into suspend states
- */
-void suspend_console(void)
-{
-       if (!console_suspend_enabled)
-               return;
-       printk("Suspending console(s) (use no_console_suspend to debug)\n");
-       console_lock();
-       console_suspended = 1;
-       up(&console_sem);
-}
-
-void resume_console(void)
-{
-       if (!console_suspend_enabled)
-               return;
-       down(&console_sem);
-       console_suspended = 0;
-       console_unlock();
-}
-
-/**
- * console_cpu_notify - print deferred console messages after CPU hotplug
- * @self: notifier struct
- * @action: CPU hotplug event
- * @hcpu: unused
- *
- * If printk() is called from a CPU that is not online yet, the messages
- * will be spooled but will not show up on the console.  This function is
- * called when a new CPU comes online (or fails to come up), and ensures
- * that any such output gets printed.
- */
-static int __cpuinit console_cpu_notify(struct notifier_block *self,
-       unsigned long action, void *hcpu)
-{
-       switch (action) {
-       case CPU_ONLINE:
-       case CPU_DEAD:
-       case CPU_DOWN_FAILED:
-       case CPU_UP_CANCELED:
-               console_lock();
-               console_unlock();
-       }
-       return NOTIFY_OK;
-}
-
-/**
- * console_lock - lock the console system for exclusive use.
- *
- * Acquires a lock which guarantees that the caller has
- * exclusive access to the console system and the console_drivers list.
- *
- * Can sleep, returns nothing.
- */
-void console_lock(void)
-{
-       might_sleep();
-
-       down(&console_sem);
-       if (console_suspended)
-               return;
-       console_locked = 1;
-       console_may_schedule = 1;
-       mutex_acquire(&console_lock_dep_map, 0, 0, _RET_IP_);
-}
-EXPORT_SYMBOL(console_lock);
-
-/**
- * console_trylock - try to lock the console system for exclusive use.
- *
- * Tried to acquire a lock which guarantees that the caller has
- * exclusive access to the console system and the console_drivers list.
- *
- * returns 1 on success, and 0 on failure to acquire the lock.
- */
-int console_trylock(void)
-{
-       if (down_trylock(&console_sem))
-               return 0;
-       if (console_suspended) {
-               up(&console_sem);
-               return 0;
-       }
-       console_locked = 1;
-       console_may_schedule = 0;
-       mutex_acquire(&console_lock_dep_map, 0, 1, _RET_IP_);
-       return 1;
-}
-EXPORT_SYMBOL(console_trylock);
-
-int is_console_locked(void)
-{
-       return console_locked;
-}
-
-static void console_cont_flush(char *text, size_t size)
-{
-       unsigned long flags;
-       size_t len;
-
-       raw_spin_lock_irqsave(&logbuf_lock, flags);
-
-       if (!cont.len)
-               goto out;
-
-       /*
-        * We still queue earlier records, likely because the console was
-        * busy. The earlier ones need to be printed before this one, we
-        * did not flush any fragment so far, so just let it queue up.
-        */
-       if (console_seq < log_next_seq && !cont.cons)
-               goto out;
-
-       len = cont_print_text(text, size);
-       raw_spin_unlock(&logbuf_lock);
-       stop_critical_timings();
-       call_console_drivers(cont.level, text, len);
-       start_critical_timings();
-       local_irq_restore(flags);
-       return;
-out:
-       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-}
-
-/**
- * console_unlock - unlock the console system
- *
- * Releases the console_lock which the caller holds on the console system
- * and the console driver list.
- *
- * While the console_lock was held, console output may have been buffered
- * by printk().  If this is the case, console_unlock(); emits
- * the output prior to releasing the lock.
- *
- * If there is output waiting, we wake /dev/kmsg and syslog() users.
- *
- * console_unlock(); may be called from any context.
- */
-void console_unlock(void)
-{
-       static char text[LOG_LINE_MAX + PREFIX_MAX];
-       static u64 seen_seq;
-       unsigned long flags;
-       bool wake_klogd = false;
-       bool retry;
-
-       if (console_suspended) {
-               up(&console_sem);
-               return;
-       }
-
-       console_may_schedule = 0;
-
-       /* flush buffered message fragment immediately to console */
-       console_cont_flush(text, sizeof(text));
-again:
-       for (;;) {
-               struct log *msg;
-               size_t len;
-               int level;
-
-               raw_spin_lock_irqsave(&logbuf_lock, flags);
-               if (seen_seq != log_next_seq) {
-                       wake_klogd = true;
-                       seen_seq = log_next_seq;
-               }
-
-               if (console_seq < log_first_seq) {
-                       /* messages are gone, move to first one */
-                       console_seq = log_first_seq;
-                       console_idx = log_first_idx;
-                       console_prev = 0;
-               }
-skip:
-               if (console_seq == log_next_seq)
-                       break;
-
-               msg = log_from_idx(console_idx);
-               if (msg->flags & LOG_NOCONS) {
-                       /*
-                        * Skip record we have buffered and already printed
-                        * directly to the console when we received it.
-                        */
-                       console_idx = log_next(console_idx);
-                       console_seq++;
-                       /*
-                        * We will get here again when we register a new
-                        * CON_PRINTBUFFER console. Clear the flag so we
-                        * will properly dump everything later.
-                        */
-                       msg->flags &= ~LOG_NOCONS;
-                       console_prev = msg->flags;
-                       goto skip;
-               }
-
-               level = msg->level;
-               len = msg_print_text(msg, console_prev, false,
-                                    text, sizeof(text));
-               console_idx = log_next(console_idx);
-               console_seq++;
-               console_prev = msg->flags;
-               raw_spin_unlock(&logbuf_lock);
-
-               stop_critical_timings();        /* don't trace print latency */
-               call_console_drivers(level, text, len);
-               start_critical_timings();
-               local_irq_restore(flags);
-       }
-       console_locked = 0;
-       mutex_release(&console_lock_dep_map, 1, _RET_IP_);
-
-       /* Release the exclusive_console once it is used */
-       if (unlikely(exclusive_console))
-               exclusive_console = NULL;
-
-       raw_spin_unlock(&logbuf_lock);
-
-       up(&console_sem);
-
-       /*
-        * Someone could have filled up the buffer again, so re-check if there's
-        * something to flush. In case we cannot trylock the console_sem again,
-        * there's a new owner and the console_unlock() from them will do the
-        * flush, no worries.
-        */
-       raw_spin_lock(&logbuf_lock);
-       retry = console_seq != log_next_seq;
-       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-
-       if (retry && console_trylock())
-               goto again;
-
-       if (wake_klogd)
-               wake_up_klogd();
-}
-EXPORT_SYMBOL(console_unlock);
-
-/**
- * console_conditional_schedule - yield the CPU if required
- *
- * If the console code is currently allowed to sleep, and
- * if this CPU should yield the CPU to another task, do
- * so here.
- *
- * Must be called within console_lock();.
- */
-void __sched console_conditional_schedule(void)
-{
-       if (console_may_schedule)
-               cond_resched();
-}
-EXPORT_SYMBOL(console_conditional_schedule);
-
-void console_unblank(void)
-{
-       struct console *c;
-
-       /*
-        * console_unblank can no longer be called in interrupt context unless
-        * oops_in_progress is set to 1..
-        */
-       if (oops_in_progress) {
-               if (down_trylock(&console_sem) != 0)
-                       return;
-       } else
-               console_lock();
-
-       console_locked = 1;
-       console_may_schedule = 0;
-       for_each_console(c)
-               if ((c->flags & CON_ENABLED) && c->unblank)
-                       c->unblank();
-       console_unlock();
-}
-
-/*
- * Return the console tty driver structure and its associated index
- */
-struct tty_driver *console_device(int *index)
-{
-       struct console *c;
-       struct tty_driver *driver = NULL;
-
-       console_lock();
-       for_each_console(c) {
-               if (!c->device)
-                       continue;
-               driver = c->device(c, index);
-               if (driver)
-                       break;
-       }
-       console_unlock();
-       return driver;
-}
-
-/*
- * Prevent further output on the passed console device so that (for example)
- * serial drivers can disable console output before suspending a port, and can
- * re-enable output afterwards.
- */
-void console_stop(struct console *console)
-{
-       console_lock();
-       console->flags &= ~CON_ENABLED;
-       console_unlock();
-}
-EXPORT_SYMBOL(console_stop);
-
-void console_start(struct console *console)
-{
-       console_lock();
-       console->flags |= CON_ENABLED;
-       console_unlock();
-}
-EXPORT_SYMBOL(console_start);
-
-static int __read_mostly keep_bootcon;
-
-static int __init keep_bootcon_setup(char *str)
-{
-       keep_bootcon = 1;
-       printk(KERN_INFO "debug: skip boot console de-registration.\n");
-
-       return 0;
-}
-
-early_param("keep_bootcon", keep_bootcon_setup);
-
-/*
- * The console driver calls this routine during kernel initialization
- * to register the console printing procedure with printk() and to
- * print any messages that were printed by the kernel before the
- * console driver was initialized.
- *
- * This can happen pretty early during the boot process (because of
- * early_printk) - sometimes before setup_arch() completes - be careful
- * of what kernel features are used - they may not be initialised yet.
- *
- * There are two types of consoles - bootconsoles (early_printk) and
- * "real" consoles (everything which is not a bootconsole) which are
- * handled differently.
- *  - Any number of bootconsoles can be registered at any time.
- *  - As soon as a "real" console is registered, all bootconsoles
- *    will be unregistered automatically.
- *  - Once a "real" console is registered, any attempt to register a
- *    bootconsoles will be rejected
- */
-void register_console(struct console *newcon)
-{
-       int i;
-       unsigned long flags;
-       struct console *bcon = NULL;
-
-       /*
-        * before we register a new CON_BOOT console, make sure we don't
-        * already have a valid console
-        */
-       if (console_drivers && newcon->flags & CON_BOOT) {
-               /* find the last or real console */
-               for_each_console(bcon) {
-                       if (!(bcon->flags & CON_BOOT)) {
-                               printk(KERN_INFO "Too late to register bootconsole %s%d\n",
-                                       newcon->name, newcon->index);
-                               return;
-                       }
-               }
-       }
-
-       if (console_drivers && console_drivers->flags & CON_BOOT)
-               bcon = console_drivers;
-
-       if (preferred_console < 0 || bcon || !console_drivers)
-               preferred_console = selected_console;
-
-       if (newcon->early_setup)
-               newcon->early_setup();
-
-       /*
-        *      See if we want to use this console driver. If we
-        *      didn't select a console we take the first one
-        *      that registers here.
-        */
-       if (preferred_console < 0) {
-               if (newcon->index < 0)
-                       newcon->index = 0;
-               if (newcon->setup == NULL ||
-                   newcon->setup(newcon, NULL) == 0) {
-                       newcon->flags |= CON_ENABLED;
-                       if (newcon->device) {
-                               newcon->flags |= CON_CONSDEV;
-                               preferred_console = 0;
-                       }
-               }
-       }
-
-       /*
-        *      See if this console matches one we selected on
-        *      the command line.
-        */
-       for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0];
-                       i++) {
-               if (strcmp(console_cmdline[i].name, newcon->name) != 0)
-                       continue;
-               if (newcon->index >= 0 &&
-                   newcon->index != console_cmdline[i].index)
-                       continue;
-               if (newcon->index < 0)
-                       newcon->index = console_cmdline[i].index;
-#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
-               if (console_cmdline[i].brl_options) {
-                       newcon->flags |= CON_BRL;
-                       braille_register_console(newcon,
-                                       console_cmdline[i].index,
-                                       console_cmdline[i].options,
-                                       console_cmdline[i].brl_options);
-                       return;
-               }
-#endif
-               if (newcon->setup &&
-                   newcon->setup(newcon, console_cmdline[i].options) != 0)
-                       break;
-               newcon->flags |= CON_ENABLED;
-               newcon->index = console_cmdline[i].index;
-               if (i == selected_console) {
-                       newcon->flags |= CON_CONSDEV;
-                       preferred_console = selected_console;
-               }
-               break;
-       }
-
-       if (!(newcon->flags & CON_ENABLED))
-               return;
-
-       /*
-        * If we have a bootconsole, and are switching to a real console,
-        * don't print everything out again, since when the boot console, and
-        * the real console are the same physical device, it's annoying to
-        * see the beginning boot messages twice
-        */
-       if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV))
-               newcon->flags &= ~CON_PRINTBUFFER;
-
-       /*
-        *      Put this console in the list - keep the
-        *      preferred driver at the head of the list.
-        */
-       console_lock();
-       if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) {
-               newcon->next = console_drivers;
-               console_drivers = newcon;
-               if (newcon->next)
-                       newcon->next->flags &= ~CON_CONSDEV;
-       } else {
-               newcon->next = console_drivers->next;
-               console_drivers->next = newcon;
-       }
-       if (newcon->flags & CON_PRINTBUFFER) {
-               /*
-                * console_unlock(); will print out the buffered messages
-                * for us.
-                */
-               raw_spin_lock_irqsave(&logbuf_lock, flags);
-               console_seq = syslog_seq;
-               console_idx = syslog_idx;
-               console_prev = syslog_prev;
-               raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-               /*
-                * We're about to replay the log buffer.  Only do this to the
-                * just-registered console to avoid excessive message spam to
-                * the already-registered consoles.
-                */
-               exclusive_console = newcon;
-       }
-       console_unlock();
-       console_sysfs_notify();
-
-       /*
-        * By unregistering the bootconsoles after we enable the real console
-        * we get the "console xxx enabled" message on all the consoles -
-        * boot consoles, real consoles, etc - this is to ensure that end
-        * users know there might be something in the kernel's log buffer that
-        * went to the bootconsole (that they do not see on the real console)
-        */
-       if (bcon &&
-           ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) &&
-           !keep_bootcon) {
-               /* we need to iterate through twice, to make sure we print
-                * everything out, before we unregister the console(s)
-                */
-               printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",
-                       newcon->name, newcon->index);
-               for_each_console(bcon)
-                       if (bcon->flags & CON_BOOT)
-                               unregister_console(bcon);
-       } else {
-               printk(KERN_INFO "%sconsole [%s%d] enabled\n",
-                       (newcon->flags & CON_BOOT) ? "boot" : "" ,
-                       newcon->name, newcon->index);
-       }
-}
-EXPORT_SYMBOL(register_console);
-
-int unregister_console(struct console *console)
-{
-        struct console *a, *b;
-       int res = 1;
-
-#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
-       if (console->flags & CON_BRL)
-               return braille_unregister_console(console);
-#endif
-
-       console_lock();
-       if (console_drivers == console) {
-               console_drivers=console->next;
-               res = 0;
-       } else if (console_drivers) {
-               for (a=console_drivers->next, b=console_drivers ;
-                    a; b=a, a=b->next) {
-                       if (a == console) {
-                               b->next = a->next;
-                               res = 0;
-                               break;
-                       }
-               }
-       }
-
-       /*
-        * If this isn't the last console and it has CON_CONSDEV set, we
-        * need to set it on the next preferred console.
-        */
-       if (console_drivers != NULL && console->flags & CON_CONSDEV)
-               console_drivers->flags |= CON_CONSDEV;
-
-       console_unlock();
-       console_sysfs_notify();
-       return res;
-}
-EXPORT_SYMBOL(unregister_console);
-
-static int __init printk_late_init(void)
-{
-       struct console *con;
-
-       for_each_console(con) {
-               if (!keep_bootcon && con->flags & CON_BOOT) {
-                       printk(KERN_INFO "turn off boot console %s%d\n",
-                               con->name, con->index);
-                       unregister_console(con);
-               }
-       }
-       hotcpu_notifier(console_cpu_notify, 0);
-       return 0;
-}
-late_initcall(printk_late_init);
-
-#if defined CONFIG_PRINTK
-/*
- * Delayed printk version, for scheduler-internal messages:
- */
-#define PRINTK_BUF_SIZE                512
-
-#define PRINTK_PENDING_WAKEUP  0x01
-#define PRINTK_PENDING_SCHED   0x02
-
-static DEFINE_PER_CPU(int, printk_pending);
-static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);
-
-static void wake_up_klogd_work_func(struct irq_work *irq_work)
-{
-       int pending = __this_cpu_xchg(printk_pending, 0);
-
-       if (pending & PRINTK_PENDING_SCHED) {
-               char *buf = __get_cpu_var(printk_sched_buf);
-               printk(KERN_WARNING "[sched_delayed] %s", buf);
-       }
-
-       if (pending & PRINTK_PENDING_WAKEUP)
-               wake_up_interruptible(&log_wait);
-}
-
-static DEFINE_PER_CPU(struct irq_work, wake_up_klogd_work) = {
-       .func = wake_up_klogd_work_func,
-       .flags = IRQ_WORK_LAZY,
-};
-
-void wake_up_klogd(void)
-{
-       preempt_disable();
-       if (waitqueue_active(&log_wait)) {
-               this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
-               irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
-       }
-       preempt_enable();
-}
-
-int printk_sched(const char *fmt, ...)
-{
-       unsigned long flags;
-       va_list args;
-       char *buf;
-       int r;
-
-       local_irq_save(flags);
-       buf = __get_cpu_var(printk_sched_buf);
-
-       va_start(args, fmt);
-       r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
-       va_end(args);
-
-       __this_cpu_or(printk_pending, PRINTK_PENDING_SCHED);
-       irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
-       local_irq_restore(flags);
-
-       return r;
-}
-
-/*
- * printk rate limiting, lifted from the networking subsystem.
- *
- * This enforces a rate limit: not more than 10 kernel messages
- * every 5s to make a denial-of-service attack impossible.
- */
-DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10);
-
-int __printk_ratelimit(const char *func)
-{
-       return ___ratelimit(&printk_ratelimit_state, func);
-}
-EXPORT_SYMBOL(__printk_ratelimit);
-
-/**
- * printk_timed_ratelimit - caller-controlled printk ratelimiting
- * @caller_jiffies: pointer to caller's state
- * @interval_msecs: minimum interval between prints
- *
- * printk_timed_ratelimit() returns true if more than @interval_msecs
- * milliseconds have elapsed since the last time printk_timed_ratelimit()
- * returned true.
- */
-bool printk_timed_ratelimit(unsigned long *caller_jiffies,
-                       unsigned int interval_msecs)
-{
-       if (*caller_jiffies == 0
-                       || !time_in_range(jiffies, *caller_jiffies,
-                                       *caller_jiffies
-                                       + msecs_to_jiffies(interval_msecs))) {
-               *caller_jiffies = jiffies;
-               return true;
-       }
-       return false;
-}
-EXPORT_SYMBOL(printk_timed_ratelimit);
-
-static DEFINE_SPINLOCK(dump_list_lock);
-static LIST_HEAD(dump_list);
-
-/**
- * kmsg_dump_register - register a kernel log dumper.
- * @dumper: pointer to the kmsg_dumper structure
- *
- * Adds a kernel log dumper to the system. The dump callback in the
- * structure will be called when the kernel oopses or panics and must be
- * set. Returns zero on success and %-EINVAL or %-EBUSY otherwise.
- */
-int kmsg_dump_register(struct kmsg_dumper *dumper)
-{
-       unsigned long flags;
-       int err = -EBUSY;
-
-       /* The dump callback needs to be set */
-       if (!dumper->dump)
-               return -EINVAL;
-
-       spin_lock_irqsave(&dump_list_lock, flags);
-       /* Don't allow registering multiple times */
-       if (!dumper->registered) {
-               dumper->registered = 1;
-               list_add_tail_rcu(&dumper->list, &dump_list);
-               err = 0;
-       }
-       spin_unlock_irqrestore(&dump_list_lock, flags);
-
-       return err;
-}
-EXPORT_SYMBOL_GPL(kmsg_dump_register);
-
-/**
- * kmsg_dump_unregister - unregister a kmsg dumper.
- * @dumper: pointer to the kmsg_dumper structure
- *
- * Removes a dump device from the system. Returns zero on success and
- * %-EINVAL otherwise.
- */
-int kmsg_dump_unregister(struct kmsg_dumper *dumper)
-{
-       unsigned long flags;
-       int err = -EINVAL;
-
-       spin_lock_irqsave(&dump_list_lock, flags);
-       if (dumper->registered) {
-               dumper->registered = 0;
-               list_del_rcu(&dumper->list);
-               err = 0;
-       }
-       spin_unlock_irqrestore(&dump_list_lock, flags);
-       synchronize_rcu();
-
-       return err;
-}
-EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
-
-static bool always_kmsg_dump;
-module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR);
-
-/**
- * kmsg_dump - dump kernel log to kernel message dumpers.
- * @reason: the reason (oops, panic etc) for dumping
- *
- * Call each of the registered dumper's dump() callback, which can
- * retrieve the kmsg records with kmsg_dump_get_line() or
- * kmsg_dump_get_buffer().
- */
-void kmsg_dump(enum kmsg_dump_reason reason)
-{
-       struct kmsg_dumper *dumper;
-       unsigned long flags;
-
-       if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
-               return;
-
-       rcu_read_lock();
-       list_for_each_entry_rcu(dumper, &dump_list, list) {
-               if (dumper->max_reason && reason > dumper->max_reason)
-                       continue;
-
-               /* initialize iterator with data about the stored records */
-               dumper->active = true;
-
-               raw_spin_lock_irqsave(&logbuf_lock, flags);
-               dumper->cur_seq = clear_seq;
-               dumper->cur_idx = clear_idx;
-               dumper->next_seq = log_next_seq;
-               dumper->next_idx = log_next_idx;
-               raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-
-               /* invoke dumper which will iterate over records */
-               dumper->dump(dumper, reason);
-
-               /* reset iterator */
-               dumper->active = false;
-       }
-       rcu_read_unlock();
-}
-
-/**
- * kmsg_dump_get_line_nolock - retrieve one kmsg log line (unlocked version)
- * @dumper: registered kmsg dumper
- * @syslog: include the "<4>" prefixes
- * @line: buffer to copy the line to
- * @size: maximum size of the buffer
- * @len: length of line placed into buffer
- *
- * Start at the beginning of the kmsg buffer, with the oldest kmsg
- * record, and copy one record into the provided buffer.
- *
- * Consecutive calls will return the next available record moving
- * towards the end of the buffer with the youngest messages.
- *
- * A return value of FALSE indicates that there are no more records to
- * read.
- *
- * The function is similar to kmsg_dump_get_line(), but grabs no locks.
- */
-bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
-                              char *line, size_t size, size_t *len)
-{
-       struct log *msg;
-       size_t l = 0;
-       bool ret = false;
-
-       if (!dumper->active)
-               goto out;
-
-       if (dumper->cur_seq < log_first_seq) {
-               /* messages are gone, move to first available one */
-               dumper->cur_seq = log_first_seq;
-               dumper->cur_idx = log_first_idx;
-       }
-
-       /* last entry */
-       if (dumper->cur_seq >= log_next_seq)
-               goto out;
-
-       msg = log_from_idx(dumper->cur_idx);
-       l = msg_print_text(msg, 0, syslog, line, size);
-
-       dumper->cur_idx = log_next(dumper->cur_idx);
-       dumper->cur_seq++;
-       ret = true;
-out:
-       if (len)
-               *len = l;
-       return ret;
-}
-
-/**
- * kmsg_dump_get_line - retrieve one kmsg log line
- * @dumper: registered kmsg dumper
- * @syslog: include the "<4>" prefixes
- * @line: buffer to copy the line to
- * @size: maximum size of the buffer
- * @len: length of line placed into buffer
- *
- * Start at the beginning of the kmsg buffer, with the oldest kmsg
- * record, and copy one record into the provided buffer.
- *
- * Consecutive calls will return the next available record moving
- * towards the end of the buffer with the youngest messages.
- *
- * A return value of FALSE indicates that there are no more records to
- * read.
- */
-bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
-                       char *line, size_t size, size_t *len)
-{
-       unsigned long flags;
-       bool ret;
-
-       raw_spin_lock_irqsave(&logbuf_lock, flags);
-       ret = kmsg_dump_get_line_nolock(dumper, syslog, line, size, len);
-       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(kmsg_dump_get_line);
-
-/**
- * kmsg_dump_get_buffer - copy kmsg log lines
- * @dumper: registered kmsg dumper
- * @syslog: include the "<4>" prefixes
- * @buf: buffer to copy the line to
- * @size: maximum size of the buffer
- * @len: length of line placed into buffer
- *
- * Start at the end of the kmsg buffer and fill the provided buffer
- * with as many of the the *youngest* kmsg records that fit into it.
- * If the buffer is large enough, all available kmsg records will be
- * copied with a single call.
- *
- * Consecutive calls will fill the buffer with the next block of
- * available older records, not including the earlier retrieved ones.
- *
- * A return value of FALSE indicates that there are no more records to
- * read.
- */
-bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
-                         char *buf, size_t size, size_t *len)
-{
-       unsigned long flags;
-       u64 seq;
-       u32 idx;
-       u64 next_seq;
-       u32 next_idx;
-       enum log_flags prev;
-       size_t l = 0;
-       bool ret = false;
-
-       if (!dumper->active)
-               goto out;
-
-       raw_spin_lock_irqsave(&logbuf_lock, flags);
-       if (dumper->cur_seq < log_first_seq) {
-               /* messages are gone, move to first available one */
-               dumper->cur_seq = log_first_seq;
-               dumper->cur_idx = log_first_idx;
-       }
-
-       /* last entry */
-       if (dumper->cur_seq >= dumper->next_seq) {
-               raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-               goto out;
-       }
-
-       /* calculate length of entire buffer */
-       seq = dumper->cur_seq;
-       idx = dumper->cur_idx;
-       prev = 0;
-       while (seq < dumper->next_seq) {
-               struct log *msg = log_from_idx(idx);
-
-               l += msg_print_text(msg, prev, true, NULL, 0);
-               idx = log_next(idx);
-               seq++;
-               prev = msg->flags;
-       }
-
-       /* move first record forward until length fits into the buffer */
-       seq = dumper->cur_seq;
-       idx = dumper->cur_idx;
-       prev = 0;
-       while (l > size && seq < dumper->next_seq) {
-               struct log *msg = log_from_idx(idx);
-
-               l -= msg_print_text(msg, prev, true, NULL, 0);
-               idx = log_next(idx);
-               seq++;
-               prev = msg->flags;
-       }
-
-       /* last message in next interation */
-       next_seq = seq;
-       next_idx = idx;
-
-       l = 0;
-       prev = 0;
-       while (seq < dumper->next_seq) {
-               struct log *msg = log_from_idx(idx);
-
-               l += msg_print_text(msg, prev, syslog, buf + l, size - l);
-               idx = log_next(idx);
-               seq++;
-               prev = msg->flags;
-       }
-
-       dumper->next_seq = next_seq;
-       dumper->next_idx = next_idx;
-       ret = true;
-       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-out:
-       if (len)
-               *len = l;
-       return ret;
-}
-EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
-
-/**
- * kmsg_dump_rewind_nolock - reset the interator (unlocked version)
- * @dumper: registered kmsg dumper
- *
- * Reset the dumper's iterator so that kmsg_dump_get_line() and
- * kmsg_dump_get_buffer() can be called again and used multiple
- * times within the same dumper.dump() callback.
- *
- * The function is similar to kmsg_dump_rewind(), but grabs no locks.
- */
-void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
-{
-       dumper->cur_seq = clear_seq;
-       dumper->cur_idx = clear_idx;
-       dumper->next_seq = log_next_seq;
-       dumper->next_idx = log_next_idx;
-}
-
-/**
- * kmsg_dump_rewind - reset the interator
- * @dumper: registered kmsg dumper
- *
- * Reset the dumper's iterator so that kmsg_dump_get_line() and
- * kmsg_dump_get_buffer() can be called again and used multiple
- * times within the same dumper.dump() callback.
- */
-void kmsg_dump_rewind(struct kmsg_dumper *dumper)
-{
-       unsigned long flags;
-
-       raw_spin_lock_irqsave(&logbuf_lock, flags);
-       kmsg_dump_rewind_nolock(dumper);
-       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
-}
-EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
-
-static char dump_stack_arch_desc_str[128];
-
-/**
- * dump_stack_set_arch_desc - set arch-specific str to show with task dumps
- * @fmt: printf-style format string
- * @...: arguments for the format string
- *
- * The configured string will be printed right after utsname during task
- * dumps.  Usually used to add arch-specific system identifiers.  If an
- * arch wants to make use of such an ID string, it should initialize this
- * as soon as possible during boot.
- */
-void __init dump_stack_set_arch_desc(const char *fmt, ...)
-{
-       va_list args;
-
-       va_start(args, fmt);
-       vsnprintf(dump_stack_arch_desc_str, sizeof(dump_stack_arch_desc_str),
-                 fmt, args);
-       va_end(args);
-}
-
-/**
- * dump_stack_print_info - print generic debug info for dump_stack()
- * @log_lvl: log level
- *
- * Arch-specific dump_stack() implementations can use this function to
- * print out the same debug information as the generic dump_stack().
- */
-void dump_stack_print_info(const char *log_lvl)
-{
-       printk("%sCPU: %d PID: %d Comm: %.20s %s %s %.*s\n",
-              log_lvl, raw_smp_processor_id(), current->pid, current->comm,
-              print_tainted(), init_utsname()->release,
-              (int)strcspn(init_utsname()->version, " "),
-              init_utsname()->version);
-
-       if (dump_stack_arch_desc_str[0] != '\0')
-               printk("%sHardware name: %s\n",
-                      log_lvl, dump_stack_arch_desc_str);
-
-       print_worker_info(log_lvl, current);
-}
-
-/**
- * show_regs_print_info - print generic debug info for show_regs()
- * @log_lvl: log level
- *
- * show_regs() implementations can use this function to print out generic
- * debug information.
- */
-void show_regs_print_info(const char *log_lvl)
-{
-       dump_stack_print_info(log_lvl);
-
-       printk("%stask: %p ti: %p task.ti: %p\n",
-              log_lvl, current, current_thread_info(),
-              task_thread_info(current));
-}
-
-#endif
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
new file mode 100644 (file)
index 0000000..85405bd
--- /dev/null
@@ -0,0 +1,2 @@
+obj-y  = printk.o
+obj-$(CONFIG_A11Y_BRAILLE_CONSOLE)     += braille.o
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c
new file mode 100644 (file)
index 0000000..276762f
--- /dev/null
@@ -0,0 +1,49 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/string.h>
+
+#include "console_cmdline.h"
+#include "braille.h"
+
+char *_braille_console_setup(char **str, char **brl_options)
+{
+       if (!memcmp(*str, "brl,", 4)) {
+               *brl_options = "";
+               *str += 4;
+       } else if (!memcmp(str, "brl=", 4)) {
+               *brl_options = *str + 4;
+               *str = strchr(*brl_options, ',');
+               if (!*str)
+                       pr_err("need port name after brl=\n");
+               else
+                       *((*str)++) = 0;
+       } else
+               return NULL;
+
+       return *str;
+}
+
+int
+_braille_register_console(struct console *console, struct console_cmdline *c)
+{
+       int rtn = 0;
+
+       if (c->brl_options) {
+               console->flags |= CON_BRL;
+               rtn = braille_register_console(console, c->index, c->options,
+                                              c->brl_options);
+       }
+
+       return rtn;
+}
+
+int
+_braille_unregister_console(struct console *console)
+{
+       if (console->flags & CON_BRL)
+               return braille_unregister_console(console);
+
+       return 0;
+}
diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h
new file mode 100644 (file)
index 0000000..769d771
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef _PRINTK_BRAILLE_H
+#define _PRINTK_BRAILLE_H
+
+#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
+
+static inline void
+braille_set_options(struct console_cmdline *c, char *brl_options)
+{
+       c->brl_options = brl_options;
+}
+
+char *
+_braille_console_setup(char **str, char **brl_options);
+
+int
+_braille_register_console(struct console *console, struct console_cmdline *c);
+
+int
+_braille_unregister_console(struct console *console);
+
+#else
+
+static inline void
+braille_set_options(struct console_cmdline *c, char *brl_options)
+{
+}
+
+static inline char *
+_braille_console_setup(char **str, char **brl_options)
+{
+       return NULL;
+}
+
+static inline int
+_braille_register_console(struct console *console, struct console_cmdline *c)
+{
+       return 0;
+}
+
+static inline int
+_braille_unregister_console(struct console *console)
+{
+       return 0;
+}
+
+#endif
+
+#endif
diff --git a/kernel/printk/console_cmdline.h b/kernel/printk/console_cmdline.h
new file mode 100644 (file)
index 0000000..cbd69d8
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef _CONSOLE_CMDLINE_H
+#define _CONSOLE_CMDLINE_H
+
+struct console_cmdline
+{
+       char    name[8];                        /* Name of the driver       */
+       int     index;                          /* Minor dev. to use        */
+       char    *options;                       /* Options for the driver   */
+#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
+       char    *brl_options;                   /* Options for braille driver */
+#endif
+};
+
+#endif
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
new file mode 100644 (file)
index 0000000..5b5a708
--- /dev/null
@@ -0,0 +1,2903 @@
+/*
+ *  linux/kernel/printk.c
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ *
+ * Modified to make sys_syslog() more flexible: added commands to
+ * return the last 4k of kernel messages, regardless of whether
+ * they've been read or not.  Added option to suppress kernel printk's
+ * to the console.  Added hook for sending the console messages
+ * elsewhere, in preparation for a serial line console (someday).
+ * Ted Ts'o, 2/11/93.
+ * Modified for sysctl support, 1/8/97, Chris Horn.
+ * Fixed SMP synchronization, 08/08/99, Manfred Spraul
+ *     manfred@colorfullife.com
+ * Rewrote bits to get rid of console_lock
+ *     01Mar01 Andrew Morton
+ */
+
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/tty_driver.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+#include <linux/nmi.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/interrupt.h>                   /* For in_interrupt() */
+#include <linux/delay.h>
+#include <linux/smp.h>
+#include <linux/security.h>
+#include <linux/bootmem.h>
+#include <linux/memblock.h>
+#include <linux/aio.h>
+#include <linux/syscalls.h>
+#include <linux/kexec.h>
+#include <linux/kdb.h>
+#include <linux/ratelimit.h>
+#include <linux/kmsg_dump.h>
+#include <linux/syslog.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>
+#include <linux/rculist.h>
+#include <linux/poll.h>
+#include <linux/irq_work.h>
+#include <linux/utsname.h>
+
+#include <asm/uaccess.h>
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/printk.h>
+
+#include "console_cmdline.h"
+#include "braille.h"
+
+/* printk's without a loglevel use this.. */
+#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
+
+/* We show everything that is MORE important than this.. */
+#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
+#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
+
+int console_printk[4] = {
+       DEFAULT_CONSOLE_LOGLEVEL,       /* console_loglevel */
+       DEFAULT_MESSAGE_LOGLEVEL,       /* default_message_loglevel */
+       MINIMUM_CONSOLE_LOGLEVEL,       /* minimum_console_loglevel */
+       DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
+};
+
+/*
+ * Low level drivers may need that to know if they can schedule in
+ * their unblank() callback or not. So let's export it.
+ */
+int oops_in_progress;
+EXPORT_SYMBOL(oops_in_progress);
+
+/*
+ * console_sem protects the console_drivers list, and also
+ * provides serialisation for access to the entire console
+ * driver system.
+ */
+static DEFINE_SEMAPHORE(console_sem);
+struct console *console_drivers;
+EXPORT_SYMBOL_GPL(console_drivers);
+
+#ifdef CONFIG_LOCKDEP
+static struct lockdep_map console_lock_dep_map = {
+       .name = "console_lock"
+};
+#endif
+
+/*
+ * This is used for debugging the mess that is the VT code by
+ * keeping track if we have the console semaphore held. It's
+ * definitely not the perfect debug tool (we don't know if _WE_
+ * hold it are racing, but it helps tracking those weird code
+ * path in the console code where we end up in places I want
+ * locked without the console sempahore held
+ */
+static int console_locked, console_suspended;
+
+/*
+ * If exclusive_console is non-NULL then only this console is to be printed to.
+ */
+static struct console *exclusive_console;
+
+/*
+ *     Array of consoles built from command line options (console=)
+ */
+
+#define MAX_CMDLINECONSOLES 8
+
+static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
+
+static int selected_console = -1;
+static int preferred_console = -1;
+int console_set_on_cmdline;
+EXPORT_SYMBOL(console_set_on_cmdline);
+
+/* Flag: console code may call schedule() */
+static int console_may_schedule;
+
+/*
+ * The printk log buffer consists of a chain of concatenated variable
+ * length records. Every record starts with a record header, containing
+ * the overall length of the record.
+ *
+ * The heads to the first and last entry in the buffer, as well as the
+ * sequence numbers of these both entries are maintained when messages
+ * are stored..
+ *
+ * If the heads indicate available messages, the length in the header
+ * tells the start next message. A length == 0 for the next message
+ * indicates a wrap-around to the beginning of the buffer.
+ *
+ * Every record carries the monotonic timestamp in microseconds, as well as
+ * the standard userspace syslog level and syslog facility. The usual
+ * kernel messages use LOG_KERN; userspace-injected messages always carry
+ * a matching syslog facility, by default LOG_USER. The origin of every
+ * message can be reliably determined that way.
+ *
+ * The human readable log message directly follows the message header. The
+ * length of the message text is stored in the header, the stored message
+ * is not terminated.
+ *
+ * Optionally, a message can carry a dictionary of properties (key/value pairs),
+ * to provide userspace with a machine-readable message context.
+ *
+ * Examples for well-defined, commonly used property names are:
+ *   DEVICE=b12:8               device identifier
+ *                                b12:8         block dev_t
+ *                                c127:3        char dev_t
+ *                                n8            netdev ifindex
+ *                                +sound:card0  subsystem:devname
+ *   SUBSYSTEM=pci              driver-core subsystem name
+ *
+ * Valid characters in property names are [a-zA-Z0-9.-_]. The plain text value
+ * follows directly after a '=' character. Every property is terminated by
+ * a '\0' character. The last property is not terminated.
+ *
+ * Example of a message structure:
+ *   0000  ff 8f 00 00 00 00 00 00      monotonic time in nsec
+ *   0008  34 00                        record is 52 bytes long
+ *   000a        0b 00                  text is 11 bytes long
+ *   000c              1f 00            dictionary is 23 bytes long
+ *   000e                    03 00      LOG_KERN (facility) LOG_ERR (level)
+ *   0010  69 74 27 73 20 61 20 6c      "it's a l"
+ *         69 6e 65                     "ine"
+ *   001b           44 45 56 49 43      "DEVIC"
+ *         45 3d 62 38 3a 32 00 44      "E=b8:2\0D"
+ *         52 49 56 45 52 3d 62 75      "RIVER=bu"
+ *         67                           "g"
+ *   0032     00 00 00                  padding to next message header
+ *
+ * The 'struct printk_log' buffer header must never be directly exported to
+ * userspace, it is a kernel-private implementation detail that might
+ * need to be changed in the future, when the requirements change.
+ *
+ * /dev/kmsg exports the structured data in the following line format:
+ *   "level,sequnum,timestamp;<message text>\n"
+ *
+ * The optional key/value pairs are attached as continuation lines starting
+ * with a space character and terminated by a newline. All possible
+ * non-prinatable characters are escaped in the "\xff" notation.
+ *
+ * Users of the export format should ignore possible additional values
+ * separated by ',', and find the message after the ';' character.
+ */
+
+enum log_flags {
+       LOG_NOCONS      = 1,    /* already flushed, do not print to console */
+       LOG_NEWLINE     = 2,    /* text ended with a newline */
+       LOG_PREFIX      = 4,    /* text started with a prefix */
+       LOG_CONT        = 8,    /* text is a fragment of a continuation line */
+};
+
+struct printk_log {
+       u64 ts_nsec;            /* timestamp in nanoseconds */
+       u16 len;                /* length of entire record */
+       u16 text_len;           /* length of text buffer */
+       u16 dict_len;           /* length of dictionary buffer */
+       u8 facility;            /* syslog facility */
+       u8 flags:5;             /* internal record flags */
+       u8 level:3;             /* syslog level */
+};
+
+/*
+ * The logbuf_lock protects kmsg buffer, indices, counters. It is also
+ * used in interesting ways to provide interlocking in console_unlock();
+ */
+static DEFINE_RAW_SPINLOCK(logbuf_lock);
+
+#ifdef CONFIG_PRINTK
+DECLARE_WAIT_QUEUE_HEAD(log_wait);
+/* the next printk record to read by syslog(READ) or /proc/kmsg */
+static u64 syslog_seq;
+static u32 syslog_idx;
+static enum log_flags syslog_prev;
+static size_t syslog_partial;
+
+/* index and sequence number of the first record stored in the buffer */
+static u64 log_first_seq;
+static u32 log_first_idx;
+
+/* index and sequence number of the next record to store in the buffer */
+static u64 log_next_seq;
+static u32 log_next_idx;
+
+/* the next printk record to write to the console */
+static u64 console_seq;
+static u32 console_idx;
+static enum log_flags console_prev;
+
+/* the next printk record to read after the last 'clear' command */
+static u64 clear_seq;
+static u32 clear_idx;
+
+#define PREFIX_MAX             32
+#define LOG_LINE_MAX           1024 - PREFIX_MAX
+
+/* record buffer */
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+#define LOG_ALIGN 4
+#else
+#define LOG_ALIGN __alignof__(struct printk_log)
+#endif
+#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
+static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
+static char *log_buf = __log_buf;
+static u32 log_buf_len = __LOG_BUF_LEN;
+
+/* cpu currently holding logbuf_lock */
+static volatile unsigned int logbuf_cpu = UINT_MAX;
+
+/* human readable text of the record */
+static char *log_text(const struct printk_log *msg)
+{
+       return (char *)msg + sizeof(struct printk_log);
+}
+
+/* optional key/value pair dictionary attached to the record */
+static char *log_dict(const struct printk_log *msg)
+{
+       return (char *)msg + sizeof(struct printk_log) + msg->text_len;
+}
+
+/* get record by index; idx must point to valid msg */
+static struct printk_log *log_from_idx(u32 idx)
+{
+       struct printk_log *msg = (struct printk_log *)(log_buf + idx);
+
+       /*
+        * A length == 0 record is the end of buffer marker. Wrap around and
+        * read the message at the start of the buffer.
+        */
+       if (!msg->len)
+               return (struct printk_log *)log_buf;
+       return msg;
+}
+
+/* get next record; idx must point to valid msg */
+static u32 log_next(u32 idx)
+{
+       struct printk_log *msg = (struct printk_log *)(log_buf + idx);
+
+       /* length == 0 indicates the end of the buffer; wrap */
+       /*
+        * A length == 0 record is the end of buffer marker. Wrap around and
+        * read the message at the start of the buffer as *this* one, and
+        * return the one after that.
+        */
+       if (!msg->len) {
+               msg = (struct printk_log *)log_buf;
+               return msg->len;
+       }
+       return idx + msg->len;
+}
+
+/* insert record into the buffer, discard old ones, update heads */
+static void log_store(int facility, int level,
+                     enum log_flags flags, u64 ts_nsec,
+                     const char *dict, u16 dict_len,
+                     const char *text, u16 text_len)
+{
+       struct printk_log *msg;
+       u32 size, pad_len;
+
+       /* number of '\0' padding bytes to next message */
+       size = sizeof(struct printk_log) + text_len + dict_len;
+       pad_len = (-size) & (LOG_ALIGN - 1);
+       size += pad_len;
+
+       while (log_first_seq < log_next_seq) {
+               u32 free;
+
+               if (log_next_idx > log_first_idx)
+                       free = max(log_buf_len - log_next_idx, log_first_idx);
+               else
+                       free = log_first_idx - log_next_idx;
+
+               if (free > size + sizeof(struct printk_log))
+                       break;
+
+               /* drop old messages until we have enough contiuous space */
+               log_first_idx = log_next(log_first_idx);
+               log_first_seq++;
+       }
+
+       if (log_next_idx + size + sizeof(struct printk_log) >= log_buf_len) {
+               /*
+                * This message + an additional empty header does not fit
+                * at the end of the buffer. Add an empty header with len == 0
+                * to signify a wrap around.
+                */
+               memset(log_buf + log_next_idx, 0, sizeof(struct printk_log));
+               log_next_idx = 0;
+       }
+
+       /* fill message */
+       msg = (struct printk_log *)(log_buf + log_next_idx);
+       memcpy(log_text(msg), text, text_len);
+       msg->text_len = text_len;
+       memcpy(log_dict(msg), dict, dict_len);
+       msg->dict_len = dict_len;
+       msg->facility = facility;
+       msg->level = level & 7;
+       msg->flags = flags & 0x1f;
+       if (ts_nsec > 0)
+               msg->ts_nsec = ts_nsec;
+       else
+               msg->ts_nsec = local_clock();
+       memset(log_dict(msg) + dict_len, 0, pad_len);
+       msg->len = sizeof(struct printk_log) + text_len + dict_len + pad_len;
+
+       /* insert message */
+       log_next_idx += msg->len;
+       log_next_seq++;
+}
+
+#ifdef CONFIG_SECURITY_DMESG_RESTRICT
+int dmesg_restrict = 1;
+#else
+int dmesg_restrict;
+#endif
+
+static int syslog_action_restricted(int type)
+{
+       if (dmesg_restrict)
+               return 1;
+       /*
+        * Unless restricted, we allow "read all" and "get buffer size"
+        * for everybody.
+        */
+       return type != SYSLOG_ACTION_READ_ALL &&
+              type != SYSLOG_ACTION_SIZE_BUFFER;
+}
+
+static int check_syslog_permissions(int type, bool from_file)
+{
+       /*
+        * If this is from /proc/kmsg and we've already opened it, then we've
+        * already done the capabilities checks at open time.
+        */
+       if (from_file && type != SYSLOG_ACTION_OPEN)
+               return 0;
+
+       if (syslog_action_restricted(type)) {
+               if (capable(CAP_SYSLOG))
+                       return 0;
+               /*
+                * For historical reasons, accept CAP_SYS_ADMIN too, with
+                * a warning.
+                */
+               if (capable(CAP_SYS_ADMIN)) {
+                       pr_warn_once("%s (%d): Attempt to access syslog with "
+                                    "CAP_SYS_ADMIN but no CAP_SYSLOG "
+                                    "(deprecated).\n",
+                                current->comm, task_pid_nr(current));
+                       return 0;
+               }
+               return -EPERM;
+       }
+       return security_syslog(type);
+}
+
+
+/* /dev/kmsg - userspace message inject/listen interface */
+struct devkmsg_user {
+       u64 seq;
+       u32 idx;
+       enum log_flags prev;
+       struct mutex lock;
+       char buf[8192];
+};
+
+static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
+                             unsigned long count, loff_t pos)
+{
+       char *buf, *line;
+       int i;
+       int level = default_message_loglevel;
+       int facility = 1;       /* LOG_USER */
+       size_t len = iov_length(iv, count);
+       ssize_t ret = len;
+
+       if (len > LOG_LINE_MAX)
+               return -EINVAL;
+       buf = kmalloc(len+1, GFP_KERNEL);
+       if (buf == NULL)
+               return -ENOMEM;
+
+       line = buf;
+       for (i = 0; i < count; i++) {
+               if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) {
+                       ret = -EFAULT;
+                       goto out;
+               }
+               line += iv[i].iov_len;
+       }
+
+       /*
+        * Extract and skip the syslog prefix <[0-9]*>. Coming from userspace
+        * the decimal value represents 32bit, the lower 3 bit are the log
+        * level, the rest are the log facility.
+        *
+        * If no prefix or no userspace facility is specified, we
+        * enforce LOG_USER, to be able to reliably distinguish
+        * kernel-generated messages from userspace-injected ones.
+        */
+       line = buf;
+       if (line[0] == '<') {
+               char *endp = NULL;
+
+               i = simple_strtoul(line+1, &endp, 10);
+               if (endp && endp[0] == '>') {
+                       level = i & 7;
+                       if (i >> 3)
+                               facility = i >> 3;
+                       endp++;
+                       len -= endp - line;
+                       line = endp;
+               }
+       }
+       line[len] = '\0';
+
+       printk_emit(facility, level, NULL, 0, "%s", line);
+out:
+       kfree(buf);
+       return ret;
+}
+
+static ssize_t devkmsg_read(struct file *file, char __user *buf,
+                           size_t count, loff_t *ppos)
+{
+       struct devkmsg_user *user = file->private_data;
+       struct printk_log *msg;
+       u64 ts_usec;
+       size_t i;
+       char cont = '-';
+       size_t len;
+       ssize_t ret;
+
+       if (!user)
+               return -EBADF;
+
+       ret = mutex_lock_interruptible(&user->lock);
+       if (ret)
+               return ret;
+       raw_spin_lock_irq(&logbuf_lock);
+       while (user->seq == log_next_seq) {
+               if (file->f_flags & O_NONBLOCK) {
+                       ret = -EAGAIN;
+                       raw_spin_unlock_irq(&logbuf_lock);
+                       goto out;
+               }
+
+               raw_spin_unlock_irq(&logbuf_lock);
+               ret = wait_event_interruptible(log_wait,
+                                              user->seq != log_next_seq);
+               if (ret)
+                       goto out;
+               raw_spin_lock_irq(&logbuf_lock);
+       }
+
+       if (user->seq < log_first_seq) {
+               /* our last seen message is gone, return error and reset */
+               user->idx = log_first_idx;
+               user->seq = log_first_seq;
+               ret = -EPIPE;
+               raw_spin_unlock_irq(&logbuf_lock);
+               goto out;
+       }
+
+       msg = log_from_idx(user->idx);
+       ts_usec = msg->ts_nsec;
+       do_div(ts_usec, 1000);
+
+       /*
+        * If we couldn't merge continuation line fragments during the print,
+        * export the stored flags to allow an optional external merge of the
+        * records. Merging the records isn't always neccessarily correct, like
+        * when we hit a race during printing. In most cases though, it produces
+        * better readable output. 'c' in the record flags mark the first
+        * fragment of a line, '+' the following.
+        */
+       if (msg->flags & LOG_CONT && !(user->prev & LOG_CONT))
+               cont = 'c';
+       else if ((msg->flags & LOG_CONT) ||
+                ((user->prev & LOG_CONT) && !(msg->flags & LOG_PREFIX)))
+               cont = '+';
+
+       len = sprintf(user->buf, "%u,%llu,%llu,%c;",
+                     (msg->facility << 3) | msg->level,
+                     user->seq, ts_usec, cont);
+       user->prev = msg->flags;
+
+       /* escape non-printable characters */
+       for (i = 0; i < msg->text_len; i++) {
+               unsigned char c = log_text(msg)[i];
+
+               if (c < ' ' || c >= 127 || c == '\\')
+                       len += sprintf(user->buf + len, "\\x%02x", c);
+               else
+                       user->buf[len++] = c;
+       }
+       user->buf[len++] = '\n';
+
+       if (msg->dict_len) {
+               bool line = true;
+
+               for (i = 0; i < msg->dict_len; i++) {
+                       unsigned char c = log_dict(msg)[i];
+
+                       if (line) {
+                               user->buf[len++] = ' ';
+                               line = false;
+                       }
+
+                       if (c == '\0') {
+                               user->buf[len++] = '\n';
+                               line = true;
+                               continue;
+                       }
+
+                       if (c < ' ' || c >= 127 || c == '\\') {
+                               len += sprintf(user->buf + len, "\\x%02x", c);
+                               continue;
+                       }
+
+                       user->buf[len++] = c;
+               }
+               user->buf[len++] = '\n';
+       }
+
+       user->idx = log_next(user->idx);
+       user->seq++;
+       raw_spin_unlock_irq(&logbuf_lock);
+
+       if (len > count) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       if (copy_to_user(buf, user->buf, len)) {
+               ret = -EFAULT;
+               goto out;
+       }
+       ret = len;
+out:
+       mutex_unlock(&user->lock);
+       return ret;
+}
+
+static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
+{
+       struct devkmsg_user *user = file->private_data;
+       loff_t ret = 0;
+
+       if (!user)
+               return -EBADF;
+       if (offset)
+               return -ESPIPE;
+
+       raw_spin_lock_irq(&logbuf_lock);
+       switch (whence) {
+       case SEEK_SET:
+               /* the first record */
+               user->idx = log_first_idx;
+               user->seq = log_first_seq;
+               break;
+       case SEEK_DATA:
+               /*
+                * The first record after the last SYSLOG_ACTION_CLEAR,
+                * like issued by 'dmesg -c'. Reading /dev/kmsg itself
+                * changes no global state, and does not clear anything.
+                */
+               user->idx = clear_idx;
+               user->seq = clear_seq;
+               break;
+       case SEEK_END:
+               /* after the last record */
+               user->idx = log_next_idx;
+               user->seq = log_next_seq;
+               break;
+       default:
+               ret = -EINVAL;
+       }
+       raw_spin_unlock_irq(&logbuf_lock);
+       return ret;
+}
+
+static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
+{
+       struct devkmsg_user *user = file->private_data;
+       int ret = 0;
+
+       if (!user)
+               return POLLERR|POLLNVAL;
+
+       poll_wait(file, &log_wait, wait);
+
+       raw_spin_lock_irq(&logbuf_lock);
+       if (user->seq < log_next_seq) {
+               /* return error when data has vanished underneath us */
+               if (user->seq < log_first_seq)
+                       ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI;
+               else
+                       ret = POLLIN|POLLRDNORM;
+       }
+       raw_spin_unlock_irq(&logbuf_lock);
+
+       return ret;
+}
+
+static int devkmsg_open(struct inode *inode, struct file *file)
+{
+       struct devkmsg_user *user;
+       int err;
+
+       /* write-only does not need any file context */
+       if ((file->f_flags & O_ACCMODE) == O_WRONLY)
+               return 0;
+
+       err = check_syslog_permissions(SYSLOG_ACTION_READ_ALL,
+                                      SYSLOG_FROM_READER);
+       if (err)
+               return err;
+
+       user = kmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);
+       if (!user)
+               return -ENOMEM;
+
+       mutex_init(&user->lock);
+
+       raw_spin_lock_irq(&logbuf_lock);
+       user->idx = log_first_idx;
+       user->seq = log_first_seq;
+       raw_spin_unlock_irq(&logbuf_lock);
+
+       file->private_data = user;
+       return 0;
+}
+
+static int devkmsg_release(struct inode *inode, struct file *file)
+{
+       struct devkmsg_user *user = file->private_data;
+
+       if (!user)
+               return 0;
+
+       mutex_destroy(&user->lock);
+       kfree(user);
+       return 0;
+}
+
+const struct file_operations kmsg_fops = {
+       .open = devkmsg_open,
+       .read = devkmsg_read,
+       .aio_write = devkmsg_writev,
+       .llseek = devkmsg_llseek,
+       .poll = devkmsg_poll,
+       .release = devkmsg_release,
+};
+
+#ifdef CONFIG_KEXEC
+/*
+ * This appends the listed symbols to /proc/vmcoreinfo
+ *
+ * /proc/vmcoreinfo is used by various utiilties, like crash and makedumpfile to
+ * obtain access to symbols that are otherwise very difficult to locate.  These
+ * symbols are specifically used so that utilities can access and extract the
+ * dmesg log from a vmcore file after a crash.
+ */
+void log_buf_kexec_setup(void)
+{
+       VMCOREINFO_SYMBOL(log_buf);
+       VMCOREINFO_SYMBOL(log_buf_len);
+       VMCOREINFO_SYMBOL(log_first_idx);
+       VMCOREINFO_SYMBOL(log_next_idx);
+       /*
+        * Export struct printk_log size and field offsets. User space tools can
+        * parse it and detect any changes to structure down the line.
+        */
+       VMCOREINFO_STRUCT_SIZE(printk_log);
+       VMCOREINFO_OFFSET(printk_log, ts_nsec);
+       VMCOREINFO_OFFSET(printk_log, len);
+       VMCOREINFO_OFFSET(printk_log, text_len);
+       VMCOREINFO_OFFSET(printk_log, dict_len);
+}
+#endif
+
+/* requested log_buf_len from kernel cmdline */
+static unsigned long __initdata new_log_buf_len;
+
+/* save requested log_buf_len since it's too early to process it */
+static int __init log_buf_len_setup(char *str)
+{
+       unsigned size = memparse(str, &str);
+
+       if (size)
+               size = roundup_pow_of_two(size);
+       if (size > log_buf_len)
+               new_log_buf_len = size;
+
+       return 0;
+}
+early_param("log_buf_len", log_buf_len_setup);
+
+void __init setup_log_buf(int early)
+{
+       unsigned long flags;
+       char *new_log_buf;
+       int free;
+
+       if (!new_log_buf_len)
+               return;
+
+       if (early) {
+               unsigned long mem;
+
+               mem = memblock_alloc(new_log_buf_len, PAGE_SIZE);
+               if (!mem)
+                       return;
+               new_log_buf = __va(mem);
+       } else {
+               new_log_buf = alloc_bootmem_nopanic(new_log_buf_len);
+       }
+
+       if (unlikely(!new_log_buf)) {
+               pr_err("log_buf_len: %ld bytes not available\n",
+                       new_log_buf_len);
+               return;
+       }
+
+       raw_spin_lock_irqsave(&logbuf_lock, flags);
+       log_buf_len = new_log_buf_len;
+       log_buf = new_log_buf;
+       new_log_buf_len = 0;
+       free = __LOG_BUF_LEN - log_next_idx;
+       memcpy(log_buf, __log_buf, __LOG_BUF_LEN);
+       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+
+       pr_info("log_buf_len: %d\n", log_buf_len);
+       pr_info("early log buf free: %d(%d%%)\n",
+               free, (free * 100) / __LOG_BUF_LEN);
+}
+
+static bool __read_mostly ignore_loglevel;
+
+static int __init ignore_loglevel_setup(char *str)
+{
+       ignore_loglevel = 1;
+       printk(KERN_INFO "debug: ignoring loglevel setting.\n");
+
+       return 0;
+}
+
+early_param("ignore_loglevel", ignore_loglevel_setup);
+module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to"
+       "print all kernel messages to the console.");
+
+#ifdef CONFIG_BOOT_PRINTK_DELAY
+
+static int boot_delay; /* msecs delay after each printk during bootup */
+static unsigned long long loops_per_msec;      /* based on boot_delay */
+
+static int __init boot_delay_setup(char *str)
+{
+       unsigned long lpj;
+
+       lpj = preset_lpj ? preset_lpj : 1000000;        /* some guess */
+       loops_per_msec = (unsigned long long)lpj / 1000 * HZ;
+
+       get_option(&str, &boot_delay);
+       if (boot_delay > 10 * 1000)
+               boot_delay = 0;
+
+       pr_debug("boot_delay: %u, preset_lpj: %ld, lpj: %lu, "
+               "HZ: %d, loops_per_msec: %llu\n",
+               boot_delay, preset_lpj, lpj, HZ, loops_per_msec);
+       return 1;
+}
+__setup("boot_delay=", boot_delay_setup);
+
+static void boot_delay_msec(int level)
+{
+       unsigned long long k;
+       unsigned long timeout;
+
+       if ((boot_delay == 0 || system_state != SYSTEM_BOOTING)
+               || (level >= console_loglevel && !ignore_loglevel)) {
+               return;
+       }
+
+       k = (unsigned long long)loops_per_msec * boot_delay;
+
+       timeout = jiffies + msecs_to_jiffies(boot_delay);
+       while (k) {
+               k--;
+               cpu_relax();
+               /*
+                * use (volatile) jiffies to prevent
+                * compiler reduction; loop termination via jiffies
+                * is secondary and may or may not happen.
+                */
+               if (time_after(jiffies, timeout))
+                       break;
+               touch_nmi_watchdog();
+       }
+}
+#else
+static inline void boot_delay_msec(int level)
+{
+}
+#endif
+
+#if defined(CONFIG_PRINTK_TIME)
+static bool printk_time = 1;
+#else
+static bool printk_time;
+#endif
+module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
+
+static size_t print_time(u64 ts, char *buf)
+{
+       unsigned long rem_nsec;
+
+       if (!printk_time)
+               return 0;
+
+       rem_nsec = do_div(ts, 1000000000);
+
+       if (!buf)
+               return snprintf(NULL, 0, "[%5lu.000000] ", (unsigned long)ts);
+
+       return sprintf(buf, "[%5lu.%06lu] ",
+                      (unsigned long)ts, rem_nsec / 1000);
+}
+
+static size_t print_prefix(const struct printk_log *msg, bool syslog, char *buf)
+{
+       size_t len = 0;
+       unsigned int prefix = (msg->facility << 3) | msg->level;
+
+       if (syslog) {
+               if (buf) {
+                       len += sprintf(buf, "<%u>", prefix);
+               } else {
+                       len += 3;
+                       if (prefix > 999)
+                               len += 3;
+                       else if (prefix > 99)
+                               len += 2;
+                       else if (prefix > 9)
+                               len++;
+               }
+       }
+
+       len += print_time(msg->ts_nsec, buf ? buf + len : NULL);
+       return len;
+}
+
+static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,
+                            bool syslog, char *buf, size_t size)
+{
+       const char *text = log_text(msg);
+       size_t text_size = msg->text_len;
+       bool prefix = true;
+       bool newline = true;
+       size_t len = 0;
+
+       if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
+               prefix = false;
+
+       if (msg->flags & LOG_CONT) {
+               if ((prev & LOG_CONT) && !(prev & LOG_NEWLINE))
+                       prefix = false;
+
+               if (!(msg->flags & LOG_NEWLINE))
+                       newline = false;
+       }
+
+       do {
+               const char *next = memchr(text, '\n', text_size);
+               size_t text_len;
+
+               if (next) {
+                       text_len = next - text;
+                       next++;
+                       text_size -= next - text;
+               } else {
+                       text_len = text_size;
+               }
+
+               if (buf) {
+                       if (print_prefix(msg, syslog, NULL) +
+                           text_len + 1 >= size - len)
+                               break;
+
+                       if (prefix)
+                               len += print_prefix(msg, syslog, buf + len);
+                       memcpy(buf + len, text, text_len);
+                       len += text_len;
+                       if (next || newline)
+                               buf[len++] = '\n';
+               } else {
+                       /* SYSLOG_ACTION_* buffer size only calculation */
+                       if (prefix)
+                               len += print_prefix(msg, syslog, NULL);
+                       len += text_len;
+                       if (next || newline)
+                               len++;
+               }
+
+               prefix = true;
+               text = next;
+       } while (text);
+
+       return len;
+}
+
+static int syslog_print(char __user *buf, int size)
+{
+       char *text;
+       struct printk_log *msg;
+       int len = 0;
+
+       text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
+       if (!text)
+               return -ENOMEM;
+
+       while (size > 0) {
+               size_t n;
+               size_t skip;
+
+               raw_spin_lock_irq(&logbuf_lock);
+               if (syslog_seq < log_first_seq) {
+                       /* messages are gone, move to first one */
+                       syslog_seq = log_first_seq;
+                       syslog_idx = log_first_idx;
+                       syslog_prev = 0;
+                       syslog_partial = 0;
+               }
+               if (syslog_seq == log_next_seq) {
+                       raw_spin_unlock_irq(&logbuf_lock);
+                       break;
+               }
+
+               skip = syslog_partial;
+               msg = log_from_idx(syslog_idx);
+               n = msg_print_text(msg, syslog_prev, true, text,
+                                  LOG_LINE_MAX + PREFIX_MAX);
+               if (n - syslog_partial <= size) {
+                       /* message fits into buffer, move forward */
+                       syslog_idx = log_next(syslog_idx);
+                       syslog_seq++;
+                       syslog_prev = msg->flags;
+                       n -= syslog_partial;
+                       syslog_partial = 0;
+               } else if (!len){
+                       /* partial read(), remember position */
+                       n = size;
+                       syslog_partial += n;
+               } else
+                       n = 0;
+               raw_spin_unlock_irq(&logbuf_lock);
+
+               if (!n)
+                       break;
+
+               if (copy_to_user(buf, text + skip, n)) {
+                       if (!len)
+                               len = -EFAULT;
+                       break;
+               }
+
+               len += n;
+               size -= n;
+               buf += n;
+       }
+
+       kfree(text);
+       return len;
+}
+
+static int syslog_print_all(char __user *buf, int size, bool clear)
+{
+       char *text;
+       int len = 0;
+
+       text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
+       if (!text)
+               return -ENOMEM;
+
+       raw_spin_lock_irq(&logbuf_lock);
+       if (buf) {
+               u64 next_seq;
+               u64 seq;
+               u32 idx;
+               enum log_flags prev;
+
+               if (clear_seq < log_first_seq) {
+                       /* messages are gone, move to first available one */
+                       clear_seq = log_first_seq;
+                       clear_idx = log_first_idx;
+               }
+
+               /*
+                * Find first record that fits, including all following records,
+                * into the user-provided buffer for this dump.
+                */
+               seq = clear_seq;
+               idx = clear_idx;
+               prev = 0;
+               while (seq < log_next_seq) {
+                       struct printk_log *msg = log_from_idx(idx);
+
+                       len += msg_print_text(msg, prev, true, NULL, 0);
+                       prev = msg->flags;
+                       idx = log_next(idx);
+                       seq++;
+               }
+
+               /* move first record forward until length fits into the buffer */
+               seq = clear_seq;
+               idx = clear_idx;
+               prev = 0;
+               while (len > size && seq < log_next_seq) {
+                       struct printk_log *msg = log_from_idx(idx);
+
+                       len -= msg_print_text(msg, prev, true, NULL, 0);
+                       prev = msg->flags;
+                       idx = log_next(idx);
+                       seq++;
+               }
+
+               /* last message fitting into this dump */
+               next_seq = log_next_seq;
+
+               len = 0;
+               prev = 0;
+               while (len >= 0 && seq < next_seq) {
+                       struct printk_log *msg = log_from_idx(idx);
+                       int textlen;
+
+                       textlen = msg_print_text(msg, prev, true, text,
+                                                LOG_LINE_MAX + PREFIX_MAX);
+                       if (textlen < 0) {
+                               len = textlen;
+                               break;
+                       }
+                       idx = log_next(idx);
+                       seq++;
+                       prev = msg->flags;
+
+                       raw_spin_unlock_irq(&logbuf_lock);
+                       if (copy_to_user(buf + len, text, textlen))
+                               len = -EFAULT;
+                       else
+                               len += textlen;
+                       raw_spin_lock_irq(&logbuf_lock);
+
+                       if (seq < log_first_seq) {
+                               /* messages are gone, move to next one */
+                               seq = log_first_seq;
+                               idx = log_first_idx;
+                               prev = 0;
+                       }
+               }
+       }
+
+       if (clear) {
+               clear_seq = log_next_seq;
+               clear_idx = log_next_idx;
+       }
+       raw_spin_unlock_irq(&logbuf_lock);
+
+       kfree(text);
+       return len;
+}
+
+int do_syslog(int type, char __user *buf, int len, bool from_file)
+{
+       bool clear = false;
+       static int saved_console_loglevel = -1;
+       int error;
+
+       error = check_syslog_permissions(type, from_file);
+       if (error)
+               goto out;
+
+       error = security_syslog(type);
+       if (error)
+               return error;
+
+       switch (type) {
+       case SYSLOG_ACTION_CLOSE:       /* Close log */
+               break;
+       case SYSLOG_ACTION_OPEN:        /* Open log */
+               break;
+       case SYSLOG_ACTION_READ:        /* Read from log */
+               error = -EINVAL;
+               if (!buf || len < 0)
+                       goto out;
+               error = 0;
+               if (!len)
+                       goto out;
+               if (!access_ok(VERIFY_WRITE, buf, len)) {
+                       error = -EFAULT;
+                       goto out;
+               }
+               error = wait_event_interruptible(log_wait,
+                                                syslog_seq != log_next_seq);
+               if (error)
+                       goto out;
+               error = syslog_print(buf, len);
+               break;
+       /* Read/clear last kernel messages */
+       case SYSLOG_ACTION_READ_CLEAR:
+               clear = true;
+               /* FALL THRU */
+       /* Read last kernel messages */
+       case SYSLOG_ACTION_READ_ALL:
+               error = -EINVAL;
+               if (!buf || len < 0)
+                       goto out;
+               error = 0;
+               if (!len)
+                       goto out;
+               if (!access_ok(VERIFY_WRITE, buf, len)) {
+                       error = -EFAULT;
+                       goto out;
+               }
+               error = syslog_print_all(buf, len, clear);
+               break;
+       /* Clear ring buffer */
+       case SYSLOG_ACTION_CLEAR:
+               syslog_print_all(NULL, 0, true);
+               break;
+       /* Disable logging to console */
+       case SYSLOG_ACTION_CONSOLE_OFF:
+               if (saved_console_loglevel == -1)
+                       saved_console_loglevel = console_loglevel;
+               console_loglevel = minimum_console_loglevel;
+               break;
+       /* Enable logging to console */
+       case SYSLOG_ACTION_CONSOLE_ON:
+               if (saved_console_loglevel != -1) {
+                       console_loglevel = saved_console_loglevel;
+                       saved_console_loglevel = -1;
+               }
+               break;
+       /* Set level of messages printed to console */
+       case SYSLOG_ACTION_CONSOLE_LEVEL:
+               error = -EINVAL;
+               if (len < 1 || len > 8)
+                       goto out;
+               if (len < minimum_console_loglevel)
+                       len = minimum_console_loglevel;
+               console_loglevel = len;
+               /* Implicitly re-enable logging to console */
+               saved_console_loglevel = -1;
+               error = 0;
+               break;
+       /* Number of chars in the log buffer */
+       case SYSLOG_ACTION_SIZE_UNREAD:
+               raw_spin_lock_irq(&logbuf_lock);
+               if (syslog_seq < log_first_seq) {
+                       /* messages are gone, move to first one */
+                       syslog_seq = log_first_seq;
+                       syslog_idx = log_first_idx;
+                       syslog_prev = 0;
+                       syslog_partial = 0;
+               }
+               if (from_file) {
+                       /*
+                        * Short-cut for poll(/"proc/kmsg") which simply checks
+                        * for pending data, not the size; return the count of
+                        * records, not the length.
+                        */
+                       error = log_next_idx - syslog_idx;
+               } else {
+                       u64 seq = syslog_seq;
+                       u32 idx = syslog_idx;
+                       enum log_flags prev = syslog_prev;
+
+                       error = 0;
+                       while (seq < log_next_seq) {
+                               struct printk_log *msg = log_from_idx(idx);
+
+                               error += msg_print_text(msg, prev, true, NULL, 0);
+                               idx = log_next(idx);
+                               seq++;
+                               prev = msg->flags;
+                       }
+                       error -= syslog_partial;
+               }
+               raw_spin_unlock_irq(&logbuf_lock);
+               break;
+       /* Size of the log buffer */
+       case SYSLOG_ACTION_SIZE_BUFFER:
+               error = log_buf_len;
+               break;
+       default:
+               error = -EINVAL;
+               break;
+       }
+out:
+       return error;
+}
+
+SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
+{
+       return do_syslog(type, buf, len, SYSLOG_FROM_READER);
+}
+
+/*
+ * Call the console drivers, asking them to write out
+ * log_buf[start] to log_buf[end - 1].
+ * The console_lock must be held.
+ */
+static void call_console_drivers(int level, const char *text, size_t len)
+{
+       struct console *con;
+
+       trace_console(text, len);
+
+       if (level >= console_loglevel && !ignore_loglevel)
+               return;
+       if (!console_drivers)
+               return;
+
+       for_each_console(con) {
+               if (exclusive_console && con != exclusive_console)
+                       continue;
+               if (!(con->flags & CON_ENABLED))
+                       continue;
+               if (!con->write)
+                       continue;
+               if (!cpu_online(smp_processor_id()) &&
+                   !(con->flags & CON_ANYTIME))
+                       continue;
+               con->write(con, text, len);
+       }
+}
+
+/*
+ * Zap console related locks when oopsing. Only zap at most once
+ * every 10 seconds, to leave time for slow consoles to print a
+ * full oops.
+ */
+static void zap_locks(void)
+{
+       static unsigned long oops_timestamp;
+
+       if (time_after_eq(jiffies, oops_timestamp) &&
+                       !time_after(jiffies, oops_timestamp + 30 * HZ))
+               return;
+
+       oops_timestamp = jiffies;
+
+       debug_locks_off();
+       /* If a crash is occurring, make sure we can't deadlock */
+       raw_spin_lock_init(&logbuf_lock);
+       /* And make sure that we print immediately */
+       sema_init(&console_sem, 1);
+}
+
+/* Check if we have any console registered that can be called early in boot. */
+static int have_callable_console(void)
+{
+       struct console *con;
+
+       for_each_console(con)
+               if (con->flags & CON_ANYTIME)
+                       return 1;
+
+       return 0;
+}
+
+/*
+ * Can we actually use the console at this time on this cpu?
+ *
+ * Console drivers may assume that per-cpu resources have
+ * been allocated. So unless they're explicitly marked as
+ * being able to cope (CON_ANYTIME) don't call them until
+ * this CPU is officially up.
+ */
+static inline int can_use_console(unsigned int cpu)
+{
+       return cpu_online(cpu) || have_callable_console();
+}
+
+/*
+ * Try to get console ownership to actually show the kernel
+ * messages from a 'printk'. Return true (and with the
+ * console_lock held, and 'console_locked' set) if it
+ * is successful, false otherwise.
+ *
+ * This gets called with the 'logbuf_lock' spinlock held and
+ * interrupts disabled. It should return with 'lockbuf_lock'
+ * released but interrupts still disabled.
+ */
+static int console_trylock_for_printk(unsigned int cpu)
+       __releases(&logbuf_lock)
+{
+       int retval = 0, wake = 0;
+
+       if (console_trylock()) {
+               retval = 1;
+
+               /*
+                * If we can't use the console, we need to release
+                * the console semaphore by hand to avoid flushing
+                * the buffer. We need to hold the console semaphore
+                * in order to do this test safely.
+                */
+               if (!can_use_console(cpu)) {
+                       console_locked = 0;
+                       wake = 1;
+                       retval = 0;
+               }
+       }
+       logbuf_cpu = UINT_MAX;
+       raw_spin_unlock(&logbuf_lock);
+       if (wake)
+               up(&console_sem);
+       return retval;
+}
+
+int printk_delay_msec __read_mostly;
+
+static inline void printk_delay(void)
+{
+       if (unlikely(printk_delay_msec)) {
+               int m = printk_delay_msec;
+
+               while (m--) {
+                       mdelay(1);
+                       touch_nmi_watchdog();
+               }
+       }
+}
+
+/*
+ * Continuation lines are buffered, and not committed to the record buffer
+ * until the line is complete, or a race forces it. The line fragments
+ * though, are printed immediately to the consoles to ensure everything has
+ * reached the console in case of a kernel crash.
+ */
+static struct cont {
+       char buf[LOG_LINE_MAX];
+       size_t len;                     /* length == 0 means unused buffer */
+       size_t cons;                    /* bytes written to console */
+       struct task_struct *owner;      /* task of first print*/
+       u64 ts_nsec;                    /* time of first print */
+       u8 level;                       /* log level of first message */
+       u8 facility;                    /* log level of first message */
+       enum log_flags flags;           /* prefix, newline flags */
+       bool flushed:1;                 /* buffer sealed and committed */
+} cont;
+
+static void cont_flush(enum log_flags flags)
+{
+       if (cont.flushed)
+               return;
+       if (cont.len == 0)
+               return;
+
+       if (cont.cons) {
+               /*
+                * If a fragment of this line was directly flushed to the
+                * console; wait for the console to pick up the rest of the
+                * line. LOG_NOCONS suppresses a duplicated output.
+                */
+               log_store(cont.facility, cont.level, flags | LOG_NOCONS,
+                         cont.ts_nsec, NULL, 0, cont.buf, cont.len);
+               cont.flags = flags;
+               cont.flushed = true;
+       } else {
+               /*
+                * If no fragment of this line ever reached the console,
+                * just submit it to the store and free the buffer.
+                */
+               log_store(cont.facility, cont.level, flags, 0,
+                         NULL, 0, cont.buf, cont.len);
+               cont.len = 0;
+       }
+}
+
+static bool cont_add(int facility, int level, const char *text, size_t len)
+{
+       if (cont.len && cont.flushed)
+               return false;
+
+       if (cont.len + len > sizeof(cont.buf)) {
+               /* the line gets too long, split it up in separate records */
+               cont_flush(LOG_CONT);
+               return false;
+       }
+
+       if (!cont.len) {
+               cont.facility = facility;
+               cont.level = level;
+               cont.owner = current;
+               cont.ts_nsec = local_clock();
+               cont.flags = 0;
+               cont.cons = 0;
+               cont.flushed = false;
+       }
+
+       memcpy(cont.buf + cont.len, text, len);
+       cont.len += len;
+
+       if (cont.len > (sizeof(cont.buf) * 80) / 100)
+               cont_flush(LOG_CONT);
+
+       return true;
+}
+
+static size_t cont_print_text(char *text, size_t size)
+{
+       size_t textlen = 0;
+       size_t len;
+
+       if (cont.cons == 0 && (console_prev & LOG_NEWLINE)) {
+               textlen += print_time(cont.ts_nsec, text);
+               size -= textlen;
+       }
+
+       len = cont.len - cont.cons;
+       if (len > 0) {
+               if (len+1 > size)
+                       len = size-1;
+               memcpy(text + textlen, cont.buf + cont.cons, len);
+               textlen += len;
+               cont.cons = cont.len;
+       }
+
+       if (cont.flushed) {
+               if (cont.flags & LOG_NEWLINE)
+                       text[textlen++] = '\n';
+               /* got everything, release buffer */
+               cont.len = 0;
+       }
+       return textlen;
+}
+
+asmlinkage int vprintk_emit(int facility, int level,
+                           const char *dict, size_t dictlen,
+                           const char *fmt, va_list args)
+{
+       static int recursion_bug;
+       static char textbuf[LOG_LINE_MAX];
+       char *text = textbuf;
+       size_t text_len;
+       enum log_flags lflags = 0;
+       unsigned long flags;
+       int this_cpu;
+       int printed_len = 0;
+
+       boot_delay_msec(level);
+       printk_delay();
+
+       /* This stops the holder of console_sem just where we want him */
+       local_irq_save(flags);
+       this_cpu = smp_processor_id();
+
+       /*
+        * Ouch, printk recursed into itself!
+        */
+       if (unlikely(logbuf_cpu == this_cpu)) {
+               /*
+                * If a crash is occurring during printk() on this CPU,
+                * then try to get the crash message out but make sure
+                * we can't deadlock. Otherwise just return to avoid the
+                * recursion and return - but flag the recursion so that
+                * it can be printed at the next appropriate moment:
+                */
+               if (!oops_in_progress && !lockdep_recursing(current)) {
+                       recursion_bug = 1;
+                       goto out_restore_irqs;
+               }
+               zap_locks();
+       }
+
+       lockdep_off();
+       raw_spin_lock(&logbuf_lock);
+       logbuf_cpu = this_cpu;
+
+       if (recursion_bug) {
+               static const char recursion_msg[] =
+                       "BUG: recent printk recursion!";
+
+               recursion_bug = 0;
+               printed_len += strlen(recursion_msg);
+               /* emit KERN_CRIT message */
+               log_store(0, 2, LOG_PREFIX|LOG_NEWLINE, 0,
+                         NULL, 0, recursion_msg, printed_len);
+       }
+
+       /*
+        * The printf needs to come first; we need the syslog
+        * prefix which might be passed-in as a parameter.
+        */
+       text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
+
+       /* mark and strip a trailing newline */
+       if (text_len && text[text_len-1] == '\n') {
+               text_len--;
+               lflags |= LOG_NEWLINE;
+       }
+
+       /* strip kernel syslog prefix and extract log level or control flags */
+       if (facility == 0) {
+               int kern_level = printk_get_level(text);
+
+               if (kern_level) {
+                       const char *end_of_header = printk_skip_level(text);
+                       switch (kern_level) {
+                       case '0' ... '7':
+                               if (level == -1)
+                                       level = kern_level - '0';
+                       case 'd':       /* KERN_DEFAULT */
+                               lflags |= LOG_PREFIX;
+                       case 'c':       /* KERN_CONT */
+                               break;
+                       }
+                       text_len -= end_of_header - text;
+                       text = (char *)end_of_header;
+               }
+       }
+
+       if (level == -1)
+               level = default_message_loglevel;
+
+       if (dict)
+               lflags |= LOG_PREFIX|LOG_NEWLINE;
+
+       if (!(lflags & LOG_NEWLINE)) {
+               /*
+                * Flush the conflicting buffer. An earlier newline was missing,
+                * or another task also prints continuation lines.
+                */
+               if (cont.len && (lflags & LOG_PREFIX || cont.owner != current))
+                       cont_flush(LOG_NEWLINE);
+
+               /* buffer line if possible, otherwise store it right away */
+               if (!cont_add(facility, level, text, text_len))
+                       log_store(facility, level, lflags | LOG_CONT, 0,
+                                 dict, dictlen, text, text_len);
+       } else {
+               bool stored = false;
+
+               /*
+                * If an earlier newline was missing and it was the same task,
+                * either merge it with the current buffer and flush, or if
+                * there was a race with interrupts (prefix == true) then just
+                * flush it out and store this line separately.
+                */
+               if (cont.len && cont.owner == current) {
+                       if (!(lflags & LOG_PREFIX))
+                               stored = cont_add(facility, level, text, text_len);
+                       cont_flush(LOG_NEWLINE);
+               }
+
+               if (!stored)
+                       log_store(facility, level, lflags, 0,
+                                 dict, dictlen, text, text_len);
+       }
+       printed_len += text_len;
+
+       /*
+        * Try to acquire and then immediately release the console semaphore.
+        * The release will print out buffers and wake up /dev/kmsg and syslog()
+        * users.
+        *
+        * The console_trylock_for_printk() function will release 'logbuf_lock'
+        * regardless of whether it actually gets the console semaphore or not.
+        */
+       if (console_trylock_for_printk(this_cpu))
+               console_unlock();
+
+       lockdep_on();
+out_restore_irqs:
+       local_irq_restore(flags);
+
+       return printed_len;
+}
+EXPORT_SYMBOL(vprintk_emit);
+
+asmlinkage int vprintk(const char *fmt, va_list args)
+{
+       return vprintk_emit(0, -1, NULL, 0, fmt, args);
+}
+EXPORT_SYMBOL(vprintk);
+
+asmlinkage int printk_emit(int facility, int level,
+                          const char *dict, size_t dictlen,
+                          const char *fmt, ...)
+{
+       va_list args;
+       int r;
+
+       va_start(args, fmt);
+       r = vprintk_emit(facility, level, dict, dictlen, fmt, args);
+       va_end(args);
+
+       return r;
+}
+EXPORT_SYMBOL(printk_emit);
+
+/**
+ * printk - print a kernel message
+ * @fmt: format string
+ *
+ * This is printk(). It can be called from any context. We want it to work.
+ *
+ * We try to grab the console_lock. If we succeed, it's easy - we log the
+ * output and call the console drivers.  If we fail to get the semaphore, we
+ * place the output into the log buffer and return. The current holder of
+ * the console_sem will notice the new output in console_unlock(); and will
+ * send it to the consoles before releasing the lock.
+ *
+ * One effect of this deferred printing is that code which calls printk() and
+ * then changes console_loglevel may break. This is because console_loglevel
+ * is inspected when the actual printing occurs.
+ *
+ * See also:
+ * printf(3)
+ *
+ * See the vsnprintf() documentation for format string extensions over C99.
+ */
+asmlinkage int printk(const char *fmt, ...)
+{
+       va_list args;
+       int r;
+
+#ifdef CONFIG_KGDB_KDB
+       if (unlikely(kdb_trap_printk)) {
+               va_start(args, fmt);
+               r = vkdb_printf(fmt, args);
+               va_end(args);
+               return r;
+       }
+#endif
+       va_start(args, fmt);
+       r = vprintk_emit(0, -1, NULL, 0, fmt, args);
+       va_end(args);
+
+       return r;
+}
+EXPORT_SYMBOL(printk);
+
+#else /* CONFIG_PRINTK */
+
+#define LOG_LINE_MAX           0
+#define PREFIX_MAX             0
+#define LOG_LINE_MAX 0
+static u64 syslog_seq;
+static u32 syslog_idx;
+static u64 console_seq;
+static u32 console_idx;
+static enum log_flags syslog_prev;
+static u64 log_first_seq;
+static u32 log_first_idx;
+static u64 log_next_seq;
+static enum log_flags console_prev;
+static struct cont {
+       size_t len;
+       size_t cons;
+       u8 level;
+       bool flushed:1;
+} cont;
+static struct printk_log *log_from_idx(u32 idx) { return NULL; }
+static u32 log_next(u32 idx) { return 0; }
+static void call_console_drivers(int level, const char *text, size_t len) {}
+static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,
+                            bool syslog, char *buf, size_t size) { return 0; }
+static size_t cont_print_text(char *text, size_t size) { return 0; }
+
+#endif /* CONFIG_PRINTK */
+
+#ifdef CONFIG_EARLY_PRINTK
+struct console *early_console;
+
+void early_vprintk(const char *fmt, va_list ap)
+{
+       if (early_console) {
+               char buf[512];
+               int n = vscnprintf(buf, sizeof(buf), fmt, ap);
+
+               early_console->write(early_console, buf, n);
+       }
+}
+
+asmlinkage void early_printk(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       early_vprintk(fmt, ap);
+       va_end(ap);
+}
+#endif
+
+static int __add_preferred_console(char *name, int idx, char *options,
+                                  char *brl_options)
+{
+       struct console_cmdline *c;
+       int i;
+
+       /*
+        *      See if this tty is not yet registered, and
+        *      if we have a slot free.
+        */
+       for (i = 0, c = console_cmdline;
+            i < MAX_CMDLINECONSOLES && c->name[0];
+            i++, c++) {
+               if (strcmp(c->name, name) == 0 && c->index == idx) {
+                       if (!brl_options)
+                               selected_console = i;
+                       return 0;
+               }
+       }
+       if (i == MAX_CMDLINECONSOLES)
+               return -E2BIG;
+       if (!brl_options)
+               selected_console = i;
+       strlcpy(c->name, name, sizeof(c->name));
+       c->options = options;
+       braille_set_options(c, brl_options);
+
+       c->index = idx;
+       return 0;
+}
+/*
+ * Set up a list of consoles.  Called from init/main.c
+ */
+static int __init console_setup(char *str)
+{
+       char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for index */
+       char *s, *options, *brl_options = NULL;
+       int idx;
+
+       if (_braille_console_setup(&str, &brl_options))
+               return 1;
+
+       /*
+        * Decode str into name, index, options.
+        */
+       if (str[0] >= '0' && str[0] <= '9') {
+               strcpy(buf, "ttyS");
+               strncpy(buf + 4, str, sizeof(buf) - 5);
+       } else {
+               strncpy(buf, str, sizeof(buf) - 1);
+       }
+       buf[sizeof(buf) - 1] = 0;
+       if ((options = strchr(str, ',')) != NULL)
+               *(options++) = 0;
+#ifdef __sparc__
+       if (!strcmp(str, "ttya"))
+               strcpy(buf, "ttyS0");
+       if (!strcmp(str, "ttyb"))
+               strcpy(buf, "ttyS1");
+#endif
+       for (s = buf; *s; s++)
+               if ((*s >= '0' && *s <= '9') || *s == ',')
+                       break;
+       idx = simple_strtoul(s, NULL, 10);
+       *s = 0;
+
+       __add_preferred_console(buf, idx, options, brl_options);
+       console_set_on_cmdline = 1;
+       return 1;
+}
+__setup("console=", console_setup);
+
+/**
+ * add_preferred_console - add a device to the list of preferred consoles.
+ * @name: device name
+ * @idx: device index
+ * @options: options for this console
+ *
+ * The last preferred console added will be used for kernel messages
+ * and stdin/out/err for init.  Normally this is used by console_setup
+ * above to handle user-supplied console arguments; however it can also
+ * be used by arch-specific code either to override the user or more
+ * commonly to provide a default console (ie from PROM variables) when
+ * the user has not supplied one.
+ */
+int add_preferred_console(char *name, int idx, char *options)
+{
+       return __add_preferred_console(name, idx, options, NULL);
+}
+
+int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options)
+{
+       struct console_cmdline *c;
+       int i;
+
+       for (i = 0, c = console_cmdline;
+            i < MAX_CMDLINECONSOLES && c->name[0];
+            i++, c++)
+               if (strcmp(c->name, name) == 0 && c->index == idx) {
+                       strlcpy(c->name, name_new, sizeof(c->name));
+                       c->name[sizeof(c->name) - 1] = 0;
+                       c->options = options;
+                       c->index = idx_new;
+                       return i;
+               }
+       /* not found */
+       return -1;
+}
+
+bool console_suspend_enabled = 1;
+EXPORT_SYMBOL(console_suspend_enabled);
+
+static int __init console_suspend_disable(char *str)
+{
+       console_suspend_enabled = 0;
+       return 1;
+}
+__setup("no_console_suspend", console_suspend_disable);
+module_param_named(console_suspend, console_suspend_enabled,
+               bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(console_suspend, "suspend console during suspend"
+       " and hibernate operations");
+
+/**
+ * suspend_console - suspend the console subsystem
+ *
+ * This disables printk() while we go into suspend states
+ */
+void suspend_console(void)
+{
+       if (!console_suspend_enabled)
+               return;
+       printk("Suspending console(s) (use no_console_suspend to debug)\n");
+       console_lock();
+       console_suspended = 1;
+       up(&console_sem);
+}
+
+void resume_console(void)
+{
+       if (!console_suspend_enabled)
+               return;
+       down(&console_sem);
+       console_suspended = 0;
+       console_unlock();
+}
+
+/**
+ * console_cpu_notify - print deferred console messages after CPU hotplug
+ * @self: notifier struct
+ * @action: CPU hotplug event
+ * @hcpu: unused
+ *
+ * If printk() is called from a CPU that is not online yet, the messages
+ * will be spooled but will not show up on the console.  This function is
+ * called when a new CPU comes online (or fails to come up), and ensures
+ * that any such output gets printed.
+ */
+static int console_cpu_notify(struct notifier_block *self,
+       unsigned long action, void *hcpu)
+{
+       switch (action) {
+       case CPU_ONLINE:
+       case CPU_DEAD:
+       case CPU_DOWN_FAILED:
+       case CPU_UP_CANCELED:
+               console_lock();
+               console_unlock();
+       }
+       return NOTIFY_OK;
+}
+
+/**
+ * console_lock - lock the console system for exclusive use.
+ *
+ * Acquires a lock which guarantees that the caller has
+ * exclusive access to the console system and the console_drivers list.
+ *
+ * Can sleep, returns nothing.
+ */
+void console_lock(void)
+{
+       might_sleep();
+
+       down(&console_sem);
+       if (console_suspended)
+               return;
+       console_locked = 1;
+       console_may_schedule = 1;
+       mutex_acquire(&console_lock_dep_map, 0, 0, _RET_IP_);
+}
+EXPORT_SYMBOL(console_lock);
+
+/**
+ * console_trylock - try to lock the console system for exclusive use.
+ *
+ * Tried to acquire a lock which guarantees that the caller has
+ * exclusive access to the console system and the console_drivers list.
+ *
+ * returns 1 on success, and 0 on failure to acquire the lock.
+ */
+int console_trylock(void)
+{
+       if (down_trylock(&console_sem))
+               return 0;
+       if (console_suspended) {
+               up(&console_sem);
+               return 0;
+       }
+       console_locked = 1;
+       console_may_schedule = 0;
+       mutex_acquire(&console_lock_dep_map, 0, 1, _RET_IP_);
+       return 1;
+}
+EXPORT_SYMBOL(console_trylock);
+
+int is_console_locked(void)
+{
+       return console_locked;
+}
+
+static void console_cont_flush(char *text, size_t size)
+{
+       unsigned long flags;
+       size_t len;
+
+       raw_spin_lock_irqsave(&logbuf_lock, flags);
+
+       if (!cont.len)
+               goto out;
+
+       /*
+        * We still queue earlier records, likely because the console was
+        * busy. The earlier ones need to be printed before this one, we
+        * did not flush any fragment so far, so just let it queue up.
+        */
+       if (console_seq < log_next_seq && !cont.cons)
+               goto out;
+
+       len = cont_print_text(text, size);
+       raw_spin_unlock(&logbuf_lock);
+       stop_critical_timings();
+       call_console_drivers(cont.level, text, len);
+       start_critical_timings();
+       local_irq_restore(flags);
+       return;
+out:
+       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+}
+
+/**
+ * console_unlock - unlock the console system
+ *
+ * Releases the console_lock which the caller holds on the console system
+ * and the console driver list.
+ *
+ * While the console_lock was held, console output may have been buffered
+ * by printk().  If this is the case, console_unlock(); emits
+ * the output prior to releasing the lock.
+ *
+ * If there is output waiting, we wake /dev/kmsg and syslog() users.
+ *
+ * console_unlock(); may be called from any context.
+ */
+void console_unlock(void)
+{
+       static char text[LOG_LINE_MAX + PREFIX_MAX];
+       static u64 seen_seq;
+       unsigned long flags;
+       bool wake_klogd = false;
+       bool retry;
+
+       if (console_suspended) {
+               up(&console_sem);
+               return;
+       }
+
+       console_may_schedule = 0;
+
+       /* flush buffered message fragment immediately to console */
+       console_cont_flush(text, sizeof(text));
+again:
+       for (;;) {
+               struct printk_log *msg;
+               size_t len;
+               int level;
+
+               raw_spin_lock_irqsave(&logbuf_lock, flags);
+               if (seen_seq != log_next_seq) {
+                       wake_klogd = true;
+                       seen_seq = log_next_seq;
+               }
+
+               if (console_seq < log_first_seq) {
+                       /* messages are gone, move to first one */
+                       console_seq = log_first_seq;
+                       console_idx = log_first_idx;
+                       console_prev = 0;
+               }
+skip:
+               if (console_seq == log_next_seq)
+                       break;
+
+               msg = log_from_idx(console_idx);
+               if (msg->flags & LOG_NOCONS) {
+                       /*
+                        * Skip record we have buffered and already printed
+                        * directly to the console when we received it.
+                        */
+                       console_idx = log_next(console_idx);
+                       console_seq++;
+                       /*
+                        * We will get here again when we register a new
+                        * CON_PRINTBUFFER console. Clear the flag so we
+                        * will properly dump everything later.
+                        */
+                       msg->flags &= ~LOG_NOCONS;
+                       console_prev = msg->flags;
+                       goto skip;
+               }
+
+               level = msg->level;
+               len = msg_print_text(msg, console_prev, false,
+                                    text, sizeof(text));
+               console_idx = log_next(console_idx);
+               console_seq++;
+               console_prev = msg->flags;
+               raw_spin_unlock(&logbuf_lock);
+
+               stop_critical_timings();        /* don't trace print latency */
+               call_console_drivers(level, text, len);
+               start_critical_timings();
+               local_irq_restore(flags);
+       }
+       console_locked = 0;
+       mutex_release(&console_lock_dep_map, 1, _RET_IP_);
+
+       /* Release the exclusive_console once it is used */
+       if (unlikely(exclusive_console))
+               exclusive_console = NULL;
+
+       raw_spin_unlock(&logbuf_lock);
+
+       up(&console_sem);
+
+       /*
+        * Someone could have filled up the buffer again, so re-check if there's
+        * something to flush. In case we cannot trylock the console_sem again,
+        * there's a new owner and the console_unlock() from them will do the
+        * flush, no worries.
+        */
+       raw_spin_lock(&logbuf_lock);
+       retry = console_seq != log_next_seq;
+       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+
+       if (retry && console_trylock())
+               goto again;
+
+       if (wake_klogd)
+               wake_up_klogd();
+}
+EXPORT_SYMBOL(console_unlock);
+
+/**
+ * console_conditional_schedule - yield the CPU if required
+ *
+ * If the console code is currently allowed to sleep, and
+ * if this CPU should yield the CPU to another task, do
+ * so here.
+ *
+ * Must be called within console_lock();.
+ */
+void __sched console_conditional_schedule(void)
+{
+       if (console_may_schedule)
+               cond_resched();
+}
+EXPORT_SYMBOL(console_conditional_schedule);
+
+void console_unblank(void)
+{
+       struct console *c;
+
+       /*
+        * console_unblank can no longer be called in interrupt context unless
+        * oops_in_progress is set to 1..
+        */
+       if (oops_in_progress) {
+               if (down_trylock(&console_sem) != 0)
+                       return;
+       } else
+               console_lock();
+
+       console_locked = 1;
+       console_may_schedule = 0;
+       for_each_console(c)
+               if ((c->flags & CON_ENABLED) && c->unblank)
+                       c->unblank();
+       console_unlock();
+}
+
+/*
+ * Return the console tty driver structure and its associated index
+ */
+struct tty_driver *console_device(int *index)
+{
+       struct console *c;
+       struct tty_driver *driver = NULL;
+
+       console_lock();
+       for_each_console(c) {
+               if (!c->device)
+                       continue;
+               driver = c->device(c, index);
+               if (driver)
+                       break;
+       }
+       console_unlock();
+       return driver;
+}
+
+/*
+ * Prevent further output on the passed console device so that (for example)
+ * serial drivers can disable console output before suspending a port, and can
+ * re-enable output afterwards.
+ */
+void console_stop(struct console *console)
+{
+       console_lock();
+       console->flags &= ~CON_ENABLED;
+       console_unlock();
+}
+EXPORT_SYMBOL(console_stop);
+
+void console_start(struct console *console)
+{
+       console_lock();
+       console->flags |= CON_ENABLED;
+       console_unlock();
+}
+EXPORT_SYMBOL(console_start);
+
+static int __read_mostly keep_bootcon;
+
+static int __init keep_bootcon_setup(char *str)
+{
+       keep_bootcon = 1;
+       printk(KERN_INFO "debug: skip boot console de-registration.\n");
+
+       return 0;
+}
+
+early_param("keep_bootcon", keep_bootcon_setup);
+
+/*
+ * The console driver calls this routine during kernel initialization
+ * to register the console printing procedure with printk() and to
+ * print any messages that were printed by the kernel before the
+ * console driver was initialized.
+ *
+ * This can happen pretty early during the boot process (because of
+ * early_printk) - sometimes before setup_arch() completes - be careful
+ * of what kernel features are used - they may not be initialised yet.
+ *
+ * There are two types of consoles - bootconsoles (early_printk) and
+ * "real" consoles (everything which is not a bootconsole) which are
+ * handled differently.
+ *  - Any number of bootconsoles can be registered at any time.
+ *  - As soon as a "real" console is registered, all bootconsoles
+ *    will be unregistered automatically.
+ *  - Once a "real" console is registered, any attempt to register a
+ *    bootconsoles will be rejected
+ */
+void register_console(struct console *newcon)
+{
+       int i;
+       unsigned long flags;
+       struct console *bcon = NULL;
+       struct console_cmdline *c;
+
+       /*
+        * before we register a new CON_BOOT console, make sure we don't
+        * already have a valid console
+        */
+       if (console_drivers && newcon->flags & CON_BOOT) {
+               /* find the last or real console */
+               for_each_console(bcon) {
+                       if (!(bcon->flags & CON_BOOT)) {
+                               printk(KERN_INFO "Too late to register bootconsole %s%d\n",
+                                       newcon->name, newcon->index);
+                               return;
+                       }
+               }
+       }
+
+       if (console_drivers && console_drivers->flags & CON_BOOT)
+               bcon = console_drivers;
+
+       if (preferred_console < 0 || bcon || !console_drivers)
+               preferred_console = selected_console;
+
+       if (newcon->early_setup)
+               newcon->early_setup();
+
+       /*
+        *      See if we want to use this console driver. If we
+        *      didn't select a console we take the first one
+        *      that registers here.
+        */
+       if (preferred_console < 0) {
+               if (newcon->index < 0)
+                       newcon->index = 0;
+               if (newcon->setup == NULL ||
+                   newcon->setup(newcon, NULL) == 0) {
+                       newcon->flags |= CON_ENABLED;
+                       if (newcon->device) {
+                               newcon->flags |= CON_CONSDEV;
+                               preferred_console = 0;
+                       }
+               }
+       }
+
+       /*
+        *      See if this console matches one we selected on
+        *      the command line.
+        */
+       for (i = 0, c = console_cmdline;
+            i < MAX_CMDLINECONSOLES && c->name[0];
+            i++, c++) {
+               if (strcmp(c->name, newcon->name) != 0)
+                       continue;
+               if (newcon->index >= 0 &&
+                   newcon->index != c->index)
+                       continue;
+               if (newcon->index < 0)
+                       newcon->index = c->index;
+
+               if (_braille_register_console(newcon, c))
+                       return;
+
+               if (newcon->setup &&
+                   newcon->setup(newcon, console_cmdline[i].options) != 0)
+                       break;
+               newcon->flags |= CON_ENABLED;
+               newcon->index = c->index;
+               if (i == selected_console) {
+                       newcon->flags |= CON_CONSDEV;
+                       preferred_console = selected_console;
+               }
+               break;
+       }
+
+       if (!(newcon->flags & CON_ENABLED))
+               return;
+
+       /*
+        * If we have a bootconsole, and are switching to a real console,
+        * don't print everything out again, since when the boot console, and
+        * the real console are the same physical device, it's annoying to
+        * see the beginning boot messages twice
+        */
+       if (bcon && ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV))
+               newcon->flags &= ~CON_PRINTBUFFER;
+
+       /*
+        *      Put this console in the list - keep the
+        *      preferred driver at the head of the list.
+        */
+       console_lock();
+       if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) {
+               newcon->next = console_drivers;
+               console_drivers = newcon;
+               if (newcon->next)
+                       newcon->next->flags &= ~CON_CONSDEV;
+       } else {
+               newcon->next = console_drivers->next;
+               console_drivers->next = newcon;
+       }
+       if (newcon->flags & CON_PRINTBUFFER) {
+               /*
+                * console_unlock(); will print out the buffered messages
+                * for us.
+                */
+               raw_spin_lock_irqsave(&logbuf_lock, flags);
+               console_seq = syslog_seq;
+               console_idx = syslog_idx;
+               console_prev = syslog_prev;
+               raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+               /*
+                * We're about to replay the log buffer.  Only do this to the
+                * just-registered console to avoid excessive message spam to
+                * the already-registered consoles.
+                */
+               exclusive_console = newcon;
+       }
+       console_unlock();
+       console_sysfs_notify();
+
+       /*
+        * By unregistering the bootconsoles after we enable the real console
+        * we get the "console xxx enabled" message on all the consoles -
+        * boot consoles, real consoles, etc - this is to ensure that end
+        * users know there might be something in the kernel's log buffer that
+        * went to the bootconsole (that they do not see on the real console)
+        */
+       if (bcon &&
+           ((newcon->flags & (CON_CONSDEV | CON_BOOT)) == CON_CONSDEV) &&
+           !keep_bootcon) {
+               /* we need to iterate through twice, to make sure we print
+                * everything out, before we unregister the console(s)
+                */
+               printk(KERN_INFO "console [%s%d] enabled, bootconsole disabled\n",
+                       newcon->name, newcon->index);
+               for_each_console(bcon)
+                       if (bcon->flags & CON_BOOT)
+                               unregister_console(bcon);
+       } else {
+               printk(KERN_INFO "%sconsole [%s%d] enabled\n",
+                       (newcon->flags & CON_BOOT) ? "boot" : "" ,
+                       newcon->name, newcon->index);
+       }
+}
+EXPORT_SYMBOL(register_console);
+
+int unregister_console(struct console *console)
+{
+        struct console *a, *b;
+       int res;
+
+       res = _braille_unregister_console(console);
+       if (res)
+               return res;
+
+       res = 1;
+       console_lock();
+       if (console_drivers == console) {
+               console_drivers=console->next;
+               res = 0;
+       } else if (console_drivers) {
+               for (a=console_drivers->next, b=console_drivers ;
+                    a; b=a, a=b->next) {
+                       if (a == console) {
+                               b->next = a->next;
+                               res = 0;
+                               break;
+                       }
+               }
+       }
+
+       /*
+        * If this isn't the last console and it has CON_CONSDEV set, we
+        * need to set it on the next preferred console.
+        */
+       if (console_drivers != NULL && console->flags & CON_CONSDEV)
+               console_drivers->flags |= CON_CONSDEV;
+
+       console_unlock();
+       console_sysfs_notify();
+       return res;
+}
+EXPORT_SYMBOL(unregister_console);
+
+static int __init printk_late_init(void)
+{
+       struct console *con;
+
+       for_each_console(con) {
+               if (!keep_bootcon && con->flags & CON_BOOT) {
+                       printk(KERN_INFO "turn off boot console %s%d\n",
+                               con->name, con->index);
+                       unregister_console(con);
+               }
+       }
+       hotcpu_notifier(console_cpu_notify, 0);
+       return 0;
+}
+late_initcall(printk_late_init);
+
+#if defined CONFIG_PRINTK
+/*
+ * Delayed printk version, for scheduler-internal messages:
+ */
+#define PRINTK_BUF_SIZE                512
+
+#define PRINTK_PENDING_WAKEUP  0x01
+#define PRINTK_PENDING_SCHED   0x02
+
+static DEFINE_PER_CPU(int, printk_pending);
+static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf);
+
+static void wake_up_klogd_work_func(struct irq_work *irq_work)
+{
+       int pending = __this_cpu_xchg(printk_pending, 0);
+
+       if (pending & PRINTK_PENDING_SCHED) {
+               char *buf = __get_cpu_var(printk_sched_buf);
+               printk(KERN_WARNING "[sched_delayed] %s", buf);
+       }
+
+       if (pending & PRINTK_PENDING_WAKEUP)
+               wake_up_interruptible(&log_wait);
+}
+
+static DEFINE_PER_CPU(struct irq_work, wake_up_klogd_work) = {
+       .func = wake_up_klogd_work_func,
+       .flags = IRQ_WORK_LAZY,
+};
+
+void wake_up_klogd(void)
+{
+       preempt_disable();
+       if (waitqueue_active(&log_wait)) {
+               this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
+               irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
+       }
+       preempt_enable();
+}
+
+int printk_sched(const char *fmt, ...)
+{
+       unsigned long flags;
+       va_list args;
+       char *buf;
+       int r;
+
+       local_irq_save(flags);
+       buf = __get_cpu_var(printk_sched_buf);
+
+       va_start(args, fmt);
+       r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args);
+       va_end(args);
+
+       __this_cpu_or(printk_pending, PRINTK_PENDING_SCHED);
+       irq_work_queue(&__get_cpu_var(wake_up_klogd_work));
+       local_irq_restore(flags);
+
+       return r;
+}
+
+/*
+ * printk rate limiting, lifted from the networking subsystem.
+ *
+ * This enforces a rate limit: not more than 10 kernel messages
+ * every 5s to make a denial-of-service attack impossible.
+ */
+DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10);
+
+int __printk_ratelimit(const char *func)
+{
+       return ___ratelimit(&printk_ratelimit_state, func);
+}
+EXPORT_SYMBOL(__printk_ratelimit);
+
+/**
+ * printk_timed_ratelimit - caller-controlled printk ratelimiting
+ * @caller_jiffies: pointer to caller's state
+ * @interval_msecs: minimum interval between prints
+ *
+ * printk_timed_ratelimit() returns true if more than @interval_msecs
+ * milliseconds have elapsed since the last time printk_timed_ratelimit()
+ * returned true.
+ */
+bool printk_timed_ratelimit(unsigned long *caller_jiffies,
+                       unsigned int interval_msecs)
+{
+       if (*caller_jiffies == 0
+                       || !time_in_range(jiffies, *caller_jiffies,
+                                       *caller_jiffies
+                                       + msecs_to_jiffies(interval_msecs))) {
+               *caller_jiffies = jiffies;
+               return true;
+       }
+       return false;
+}
+EXPORT_SYMBOL(printk_timed_ratelimit);
+
+static DEFINE_SPINLOCK(dump_list_lock);
+static LIST_HEAD(dump_list);
+
+/**
+ * kmsg_dump_register - register a kernel log dumper.
+ * @dumper: pointer to the kmsg_dumper structure
+ *
+ * Adds a kernel log dumper to the system. The dump callback in the
+ * structure will be called when the kernel oopses or panics and must be
+ * set. Returns zero on success and %-EINVAL or %-EBUSY otherwise.
+ */
+int kmsg_dump_register(struct kmsg_dumper *dumper)
+{
+       unsigned long flags;
+       int err = -EBUSY;
+
+       /* The dump callback needs to be set */
+       if (!dumper->dump)
+               return -EINVAL;
+
+       spin_lock_irqsave(&dump_list_lock, flags);
+       /* Don't allow registering multiple times */
+       if (!dumper->registered) {
+               dumper->registered = 1;
+               list_add_tail_rcu(&dumper->list, &dump_list);
+               err = 0;
+       }
+       spin_unlock_irqrestore(&dump_list_lock, flags);
+
+       return err;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_register);
+
+/**
+ * kmsg_dump_unregister - unregister a kmsg dumper.
+ * @dumper: pointer to the kmsg_dumper structure
+ *
+ * Removes a dump device from the system. Returns zero on success and
+ * %-EINVAL otherwise.
+ */
+int kmsg_dump_unregister(struct kmsg_dumper *dumper)
+{
+       unsigned long flags;
+       int err = -EINVAL;
+
+       spin_lock_irqsave(&dump_list_lock, flags);
+       if (dumper->registered) {
+               dumper->registered = 0;
+               list_del_rcu(&dumper->list);
+               err = 0;
+       }
+       spin_unlock_irqrestore(&dump_list_lock, flags);
+       synchronize_rcu();
+
+       return err;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
+
+static bool always_kmsg_dump;
+module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR);
+
+/**
+ * kmsg_dump - dump kernel log to kernel message dumpers.
+ * @reason: the reason (oops, panic etc) for dumping
+ *
+ * Call each of the registered dumper's dump() callback, which can
+ * retrieve the kmsg records with kmsg_dump_get_line() or
+ * kmsg_dump_get_buffer().
+ */
+void kmsg_dump(enum kmsg_dump_reason reason)
+{
+       struct kmsg_dumper *dumper;
+       unsigned long flags;
+
+       if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
+               return;
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(dumper, &dump_list, list) {
+               if (dumper->max_reason && reason > dumper->max_reason)
+                       continue;
+
+               /* initialize iterator with data about the stored records */
+               dumper->active = true;
+
+               raw_spin_lock_irqsave(&logbuf_lock, flags);
+               dumper->cur_seq = clear_seq;
+               dumper->cur_idx = clear_idx;
+               dumper->next_seq = log_next_seq;
+               dumper->next_idx = log_next_idx;
+               raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+
+               /* invoke dumper which will iterate over records */
+               dumper->dump(dumper, reason);
+
+               /* reset iterator */
+               dumper->active = false;
+       }
+       rcu_read_unlock();
+}
+
+/**
+ * kmsg_dump_get_line_nolock - retrieve one kmsg log line (unlocked version)
+ * @dumper: registered kmsg dumper
+ * @syslog: include the "<4>" prefixes
+ * @line: buffer to copy the line to
+ * @size: maximum size of the buffer
+ * @len: length of line placed into buffer
+ *
+ * Start at the beginning of the kmsg buffer, with the oldest kmsg
+ * record, and copy one record into the provided buffer.
+ *
+ * Consecutive calls will return the next available record moving
+ * towards the end of the buffer with the youngest messages.
+ *
+ * A return value of FALSE indicates that there are no more records to
+ * read.
+ *
+ * The function is similar to kmsg_dump_get_line(), but grabs no locks.
+ */
+bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
+                              char *line, size_t size, size_t *len)
+{
+       struct printk_log *msg;
+       size_t l = 0;
+       bool ret = false;
+
+       if (!dumper->active)
+               goto out;
+
+       if (dumper->cur_seq < log_first_seq) {
+               /* messages are gone, move to first available one */
+               dumper->cur_seq = log_first_seq;
+               dumper->cur_idx = log_first_idx;
+       }
+
+       /* last entry */
+       if (dumper->cur_seq >= log_next_seq)
+               goto out;
+
+       msg = log_from_idx(dumper->cur_idx);
+       l = msg_print_text(msg, 0, syslog, line, size);
+
+       dumper->cur_idx = log_next(dumper->cur_idx);
+       dumper->cur_seq++;
+       ret = true;
+out:
+       if (len)
+               *len = l;
+       return ret;
+}
+
+/**
+ * kmsg_dump_get_line - retrieve one kmsg log line
+ * @dumper: registered kmsg dumper
+ * @syslog: include the "<4>" prefixes
+ * @line: buffer to copy the line to
+ * @size: maximum size of the buffer
+ * @len: length of line placed into buffer
+ *
+ * Start at the beginning of the kmsg buffer, with the oldest kmsg
+ * record, and copy one record into the provided buffer.
+ *
+ * Consecutive calls will return the next available record moving
+ * towards the end of the buffer with the youngest messages.
+ *
+ * A return value of FALSE indicates that there are no more records to
+ * read.
+ */
+bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
+                       char *line, size_t size, size_t *len)
+{
+       unsigned long flags;
+       bool ret;
+
+       raw_spin_lock_irqsave(&logbuf_lock, flags);
+       ret = kmsg_dump_get_line_nolock(dumper, syslog, line, size, len);
+       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_get_line);
+
+/**
+ * kmsg_dump_get_buffer - copy kmsg log lines
+ * @dumper: registered kmsg dumper
+ * @syslog: include the "<4>" prefixes
+ * @buf: buffer to copy the line to
+ * @size: maximum size of the buffer
+ * @len: length of line placed into buffer
+ *
+ * Start at the end of the kmsg buffer and fill the provided buffer
+ * with as many of the the *youngest* kmsg records that fit into it.
+ * If the buffer is large enough, all available kmsg records will be
+ * copied with a single call.
+ *
+ * Consecutive calls will fill the buffer with the next block of
+ * available older records, not including the earlier retrieved ones.
+ *
+ * A return value of FALSE indicates that there are no more records to
+ * read.
+ */
+bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
+                         char *buf, size_t size, size_t *len)
+{
+       unsigned long flags;
+       u64 seq;
+       u32 idx;
+       u64 next_seq;
+       u32 next_idx;
+       enum log_flags prev;
+       size_t l = 0;
+       bool ret = false;
+
+       if (!dumper->active)
+               goto out;
+
+       raw_spin_lock_irqsave(&logbuf_lock, flags);
+       if (dumper->cur_seq < log_first_seq) {
+               /* messages are gone, move to first available one */
+               dumper->cur_seq = log_first_seq;
+               dumper->cur_idx = log_first_idx;
+       }
+
+       /* last entry */
+       if (dumper->cur_seq >= dumper->next_seq) {
+               raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+               goto out;
+       }
+
+       /* calculate length of entire buffer */
+       seq = dumper->cur_seq;
+       idx = dumper->cur_idx;
+       prev = 0;
+       while (seq < dumper->next_seq) {
+               struct printk_log *msg = log_from_idx(idx);
+
+               l += msg_print_text(msg, prev, true, NULL, 0);
+               idx = log_next(idx);
+               seq++;
+               prev = msg->flags;
+       }
+
+       /* move first record forward until length fits into the buffer */
+       seq = dumper->cur_seq;
+       idx = dumper->cur_idx;
+       prev = 0;
+       while (l > size && seq < dumper->next_seq) {
+               struct printk_log *msg = log_from_idx(idx);
+
+               l -= msg_print_text(msg, prev, true, NULL, 0);
+               idx = log_next(idx);
+               seq++;
+               prev = msg->flags;
+       }
+
+       /* last message in next interation */
+       next_seq = seq;
+       next_idx = idx;
+
+       l = 0;
+       prev = 0;
+       while (seq < dumper->next_seq) {
+               struct printk_log *msg = log_from_idx(idx);
+
+               l += msg_print_text(msg, prev, syslog, buf + l, size - l);
+               idx = log_next(idx);
+               seq++;
+               prev = msg->flags;
+       }
+
+       dumper->next_seq = next_seq;
+       dumper->next_idx = next_idx;
+       ret = true;
+       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+out:
+       if (len)
+               *len = l;
+       return ret;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
+
+/**
+ * kmsg_dump_rewind_nolock - reset the interator (unlocked version)
+ * @dumper: registered kmsg dumper
+ *
+ * Reset the dumper's iterator so that kmsg_dump_get_line() and
+ * kmsg_dump_get_buffer() can be called again and used multiple
+ * times within the same dumper.dump() callback.
+ *
+ * The function is similar to kmsg_dump_rewind(), but grabs no locks.
+ */
+void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
+{
+       dumper->cur_seq = clear_seq;
+       dumper->cur_idx = clear_idx;
+       dumper->next_seq = log_next_seq;
+       dumper->next_idx = log_next_idx;
+}
+
+/**
+ * kmsg_dump_rewind - reset the interator
+ * @dumper: registered kmsg dumper
+ *
+ * Reset the dumper's iterator so that kmsg_dump_get_line() and
+ * kmsg_dump_get_buffer() can be called again and used multiple
+ * times within the same dumper.dump() callback.
+ */
+void kmsg_dump_rewind(struct kmsg_dumper *dumper)
+{
+       unsigned long flags;
+
+       raw_spin_lock_irqsave(&logbuf_lock, flags);
+       kmsg_dump_rewind_nolock(dumper);
+       raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
+
+static char dump_stack_arch_desc_str[128];
+
+/**
+ * dump_stack_set_arch_desc - set arch-specific str to show with task dumps
+ * @fmt: printf-style format string
+ * @...: arguments for the format string
+ *
+ * The configured string will be printed right after utsname during task
+ * dumps.  Usually used to add arch-specific system identifiers.  If an
+ * arch wants to make use of such an ID string, it should initialize this
+ * as soon as possible during boot.
+ */
+void __init dump_stack_set_arch_desc(const char *fmt, ...)
+{
+       va_list args;
+
+       va_start(args, fmt);
+       vsnprintf(dump_stack_arch_desc_str, sizeof(dump_stack_arch_desc_str),
+                 fmt, args);
+       va_end(args);
+}
+
+/**
+ * dump_stack_print_info - print generic debug info for dump_stack()
+ * @log_lvl: log level
+ *
+ * Arch-specific dump_stack() implementations can use this function to
+ * print out the same debug information as the generic dump_stack().
+ */
+void dump_stack_print_info(const char *log_lvl)
+{
+       printk("%sCPU: %d PID: %d Comm: %.20s %s %s %.*s\n",
+              log_lvl, raw_smp_processor_id(), current->pid, current->comm,
+              print_tainted(), init_utsname()->release,
+              (int)strcspn(init_utsname()->version, " "),
+              init_utsname()->version);
+
+       if (dump_stack_arch_desc_str[0] != '\0')
+               printk("%sHardware name: %s\n",
+                      log_lvl, dump_stack_arch_desc_str);
+
+       print_worker_info(log_lvl, current);
+}
+
+/**
+ * show_regs_print_info - print generic debug info for show_regs()
+ * @log_lvl: log level
+ *
+ * show_regs() implementations can use this function to print out generic
+ * debug information.
+ */
+void show_regs_print_info(const char *log_lvl)
+{
+       dump_stack_print_info(log_lvl);
+
+       printk("%stask: %p ti: %p task.ti: %p\n",
+              log_lvl, current, current_thread_info(),
+              task_thread_info(current));
+}
+
+#endif
index 0bf400737660d65a03280c23df130c9e17c776ea..6631e1ef55ab0970f095b42ec350982abd8d9678 100644 (file)
@@ -331,7 +331,7 @@ out:
        put_cpu();
 }
 
-static int __cpuinit profile_cpu_callback(struct notifier_block *info,
+static int profile_cpu_callback(struct notifier_block *info,
                                        unsigned long action, void *__cpu)
 {
        int node, cpu = (unsigned long)__cpu;
index 4041f5747e73bf70f8d8dbb412f8e7b7067a8017..a146ee327f6ac15029b64424f0abd07e8d316f67 100644 (file)
@@ -469,7 +469,6 @@ static int ptrace_detach(struct task_struct *child, unsigned int data)
        /* Architecture-specific hardware disable .. */
        ptrace_disable(child);
        clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-       flush_ptrace_hw_breakpoint(child);
 
        write_lock_irq(&tasklist_lock);
        /*
index b1fa5510388d12ff95afa6f38a090956551a5907..f4871e52c54600bb16d129d009e3d0828ad111fc 100644 (file)
@@ -1476,7 +1476,7 @@ rcu_torture_shutdown(void *arg)
  * Execute random CPU-hotplug operations at the interval specified
  * by the onoff_interval.
  */
-static int __cpuinit
+static int
 rcu_torture_onoff(void *arg)
 {
        int cpu;
@@ -1558,7 +1558,7 @@ rcu_torture_onoff(void *arg)
        return 0;
 }
 
-static int __cpuinit
+static int
 rcu_torture_onoff_init(void)
 {
        int ret;
@@ -1601,7 +1601,7 @@ static void rcu_torture_onoff_cleanup(void)
  * CPU-stall kthread.  It waits as specified by stall_cpu_holdoff, then
  * induces a CPU stall for the time specified by stall_cpu.
  */
-static int __cpuinit rcu_torture_stall(void *args)
+static int rcu_torture_stall(void *args)
 {
        unsigned long stop_at;
 
index e08abb9461acc13dda0a7c4901d228554c12443e..068de3a93606980268351ccaf6b19fc45573b4ea 100644 (file)
@@ -2910,7 +2910,7 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
  * can accept some slop in the rsp->completed access due to the fact
  * that this CPU cannot possibly have any RCU callbacks in flight yet.
  */
-static void __cpuinit
+static void
 rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
 {
        unsigned long flags;
@@ -2962,7 +2962,7 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
        mutex_unlock(&rsp->onoff_mutex);
 }
 
-static void __cpuinit rcu_prepare_cpu(int cpu)
+static void rcu_prepare_cpu(int cpu)
 {
        struct rcu_state *rsp;
 
@@ -2974,7 +2974,7 @@ static void __cpuinit rcu_prepare_cpu(int cpu)
 /*
  * Handle CPU online/offline notification events.
  */
-static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
+static int rcu_cpu_notify(struct notifier_block *self,
                                    unsigned long action, void *hcpu)
 {
        long cpu = (long)hcpu;
index 4a39d364493cf66bf64c161d46c2bc3fd089978f..b3832581043ceeff9c294669db5d26b58ba6a559 100644 (file)
@@ -521,10 +521,10 @@ static void invoke_rcu_callbacks_kthread(void);
 static bool rcu_is_callbacks_kthread(void);
 #ifdef CONFIG_RCU_BOOST
 static void rcu_preempt_do_callbacks(void);
-static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
+static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
                                                 struct rcu_node *rnp);
 #endif /* #ifdef CONFIG_RCU_BOOST */
-static void __cpuinit rcu_prepare_kthreads(int cpu);
+static void rcu_prepare_kthreads(int cpu);
 static void rcu_cleanup_after_idle(int cpu);
 static void rcu_prepare_for_idle(int cpu);
 static void rcu_idle_count_callbacks_posted(void);
index 63098a59216e5957c27b5f20d57ca58591e46426..769e12e3151b6ec9f7a557532ce5f3ae2984aaef 100644 (file)
@@ -1352,7 +1352,7 @@ static void rcu_preempt_boost_start_gp(struct rcu_node *rnp)
  * already exist.  We only create this kthread for preemptible RCU.
  * Returns zero if all is well, a negated errno otherwise.
  */
-static int __cpuinit rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
+static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
                                                 struct rcu_node *rnp)
 {
        int rnp_index = rnp - &rsp->node[0];
@@ -1507,7 +1507,7 @@ static int __init rcu_spawn_kthreads(void)
 }
 early_initcall(rcu_spawn_kthreads);
 
-static void __cpuinit rcu_prepare_kthreads(int cpu)
+static void rcu_prepare_kthreads(int cpu)
 {
        struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu);
        struct rcu_node *rnp = rdp->mynode;
@@ -1549,7 +1549,7 @@ static int __init rcu_scheduler_really_started(void)
 }
 early_initcall(rcu_scheduler_really_started);
 
-static void __cpuinit rcu_prepare_kthreads(int cpu)
+static void rcu_prepare_kthreads(int cpu)
 {
 }
 
index b91488ba2e5a7edb6e3cbdc5876adaf9ae7f2791..5001c9887db1a3ea22cb03d5dd843b1a44a2e1c5 100644 (file)
@@ -516,7 +516,7 @@ static void setup_callbacks(struct rchan *chan,
  *
  *     Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
  */
-static int __cpuinit relay_hotcpu_callback(struct notifier_block *nb,
+static int relay_hotcpu_callback(struct notifier_block *nb,
                                unsigned long action,
                                void *hcpu)
 {
index 0d8eb4525e7616953d1a0df16fd43bcf6fc4f0cc..05c39f030314698730349de8eb9346c1437d9aba 100644 (file)
@@ -933,6 +933,8 @@ static int effective_prio(struct task_struct *p)
 /**
  * task_curr - is this task currently executing on a CPU?
  * @p: the task in question.
+ *
+ * Return: 1 if the task is currently executing. 0 otherwise.
  */
 inline int task_curr(const struct task_struct *p)
 {
@@ -1482,7 +1484,7 @@ static void ttwu_queue(struct task_struct *p, int cpu)
  * the simpler "current->state = TASK_RUNNING" to mark yourself
  * runnable without the overhead of this.
  *
- * Returns %true if @p was woken up, %false if it was already running
+ * Return: %true if @p was woken up, %false if it was already running.
  * or @state didn't match @p's state.
  */
 static int
@@ -1491,7 +1493,13 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
        unsigned long flags;
        int cpu, success = 0;
 
-       smp_wmb();
+       /*
+        * If we are going to wake up a thread waiting for CONDITION we
+        * need to ensure that CONDITION=1 done by the caller can not be
+        * reordered with p->state check below. This pairs with mb() in
+        * set_current_state() the waiting thread does.
+        */
+       smp_mb__before_spinlock();
        raw_spin_lock_irqsave(&p->pi_lock, flags);
        if (!(p->state & state))
                goto out;
@@ -1577,8 +1585,9 @@ out:
  * @p: The process to be woken up.
  *
  * Attempt to wake up the nominated process and move it to the set of runnable
- * processes.  Returns 1 if the process was woken up, 0 if it was already
- * running.
+ * processes.
+ *
+ * Return: 1 if the process was woken up, 0 if it was already running.
  *
  * It may be assumed that this function implies a write memory barrier before
  * changing the task state if and only if any tasks are woken up.
@@ -2191,6 +2200,8 @@ void scheduler_tick(void)
  * This makes sure that uptime, CFS vruntime, load
  * balancing, etc... continue to move forward, even
  * with a very low granularity.
+ *
+ * Return: Maximum deferment in nanoseconds.
  */
 u64 scheduler_tick_max_deferment(void)
 {
@@ -2394,6 +2405,12 @@ need_resched:
        if (sched_feat(HRTICK))
                hrtick_clear(rq);
 
+       /*
+        * Make sure that signal_pending_state()->signal_pending() below
+        * can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
+        * done by the caller to avoid the race with signal_wake_up().
+        */
+       smp_mb__before_spinlock();
        raw_spin_lock_irq(&rq->lock);
 
        switch_count = &prev->nivcsw;
@@ -2796,8 +2813,8 @@ EXPORT_SYMBOL(wait_for_completion);
  * specified timeout to expire. The timeout is in jiffies. It is not
  * interruptible.
  *
- * The return value is 0 if timed out, and positive (at least 1, or number of
- * jiffies left till timeout) if completed.
+ * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
+ * till timeout) if completed.
  */
 unsigned long __sched
 wait_for_completion_timeout(struct completion *x, unsigned long timeout)
@@ -2829,8 +2846,8 @@ EXPORT_SYMBOL(wait_for_completion_io);
  * specified timeout to expire. The timeout is in jiffies. It is not
  * interruptible. The caller is accounted as waiting for IO.
  *
- * The return value is 0 if timed out, and positive (at least 1, or number of
- * jiffies left till timeout) if completed.
+ * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
+ * till timeout) if completed.
  */
 unsigned long __sched
 wait_for_completion_io_timeout(struct completion *x, unsigned long timeout)
@@ -2846,7 +2863,7 @@ EXPORT_SYMBOL(wait_for_completion_io_timeout);
  * This waits for completion of a specific task to be signaled. It is
  * interruptible.
  *
- * The return value is -ERESTARTSYS if interrupted, 0 if completed.
+ * Return: -ERESTARTSYS if interrupted, 0 if completed.
  */
 int __sched wait_for_completion_interruptible(struct completion *x)
 {
@@ -2865,8 +2882,8 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
  * This waits for either a completion of a specific task to be signaled or for a
  * specified timeout to expire. It is interruptible. The timeout is in jiffies.
  *
- * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
- * positive (at least 1, or number of jiffies left till timeout) if completed.
+ * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
+ * or number of jiffies left till timeout) if completed.
  */
 long __sched
 wait_for_completion_interruptible_timeout(struct completion *x,
@@ -2883,7 +2900,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
  * This waits to be signaled for completion of a specific task. It can be
  * interrupted by a kill signal.
  *
- * The return value is -ERESTARTSYS if interrupted, 0 if completed.
+ * Return: -ERESTARTSYS if interrupted, 0 if completed.
  */
 int __sched wait_for_completion_killable(struct completion *x)
 {
@@ -2903,8 +2920,8 @@ EXPORT_SYMBOL(wait_for_completion_killable);
  * signaled or for a specified timeout to expire. It can be
  * interrupted by a kill signal. The timeout is in jiffies.
  *
- * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
- * positive (at least 1, or number of jiffies left till timeout) if completed.
+ * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
+ * or number of jiffies left till timeout) if completed.
  */
 long __sched
 wait_for_completion_killable_timeout(struct completion *x,
@@ -2918,7 +2935,7 @@ EXPORT_SYMBOL(wait_for_completion_killable_timeout);
  *     try_wait_for_completion - try to decrement a completion without blocking
  *     @x:     completion structure
  *
- *     Returns: 0 if a decrement cannot be done without blocking
+ *     Return: 0 if a decrement cannot be done without blocking
  *              1 if a decrement succeeded.
  *
  *     If a completion is being used as a counting completion,
@@ -2945,7 +2962,7 @@ EXPORT_SYMBOL(try_wait_for_completion);
  *     completion_done - Test to see if a completion has any waiters
  *     @x:     completion structure
  *
- *     Returns: 0 if there are waiters (wait_for_completion() in progress)
+ *     Return: 0 if there are waiters (wait_for_completion() in progress)
  *              1 if there are no waiters.
  *
  */
@@ -3182,7 +3199,7 @@ SYSCALL_DEFINE1(nice, int, increment)
  * task_prio - return the priority value of a given task.
  * @p: the task in question.
  *
- * This is the priority value as seen by users in /proc.
+ * Return: The priority value as seen by users in /proc.
  * RT tasks are offset by -200. Normal tasks are centered
  * around 0, value goes from -16 to +15.
  */
@@ -3194,6 +3211,8 @@ int task_prio(const struct task_struct *p)
 /**
  * task_nice - return the nice value of a given task.
  * @p: the task in question.
+ *
+ * Return: The nice value [ -20 ... 0 ... 19 ].
  */
 int task_nice(const struct task_struct *p)
 {
@@ -3204,6 +3223,8 @@ EXPORT_SYMBOL(task_nice);
 /**
  * idle_cpu - is a given cpu idle currently?
  * @cpu: the processor in question.
+ *
+ * Return: 1 if the CPU is currently idle. 0 otherwise.
  */
 int idle_cpu(int cpu)
 {
@@ -3226,6 +3247,8 @@ int idle_cpu(int cpu)
 /**
  * idle_task - return the idle task for a given cpu.
  * @cpu: the processor in question.
+ *
+ * Return: The idle task for the cpu @cpu.
  */
 struct task_struct *idle_task(int cpu)
 {
@@ -3235,6 +3258,8 @@ struct task_struct *idle_task(int cpu)
 /**
  * find_process_by_pid - find a process with a matching PID value.
  * @pid: the pid in question.
+ *
+ * The task of @pid, if found. %NULL otherwise.
  */
 static struct task_struct *find_process_by_pid(pid_t pid)
 {
@@ -3432,6 +3457,8 @@ recheck:
  * @policy: new policy.
  * @param: structure containing the new RT priority.
  *
+ * Return: 0 on success. An error code otherwise.
+ *
  * NOTE that the task may be already dead.
  */
 int sched_setscheduler(struct task_struct *p, int policy,
@@ -3451,6 +3478,8 @@ EXPORT_SYMBOL_GPL(sched_setscheduler);
  * current context has permission.  For example, this is needed in
  * stop_machine(): we create temporary high priority worker threads,
  * but our caller might not have that capability.
+ *
+ * Return: 0 on success. An error code otherwise.
  */
 int sched_setscheduler_nocheck(struct task_struct *p, int policy,
                               const struct sched_param *param)
@@ -3485,6 +3514,8 @@ do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
  * @pid: the pid in question.
  * @policy: new policy.
  * @param: structure containing the new RT priority.
+ *
+ * Return: 0 on success. An error code otherwise.
  */
 SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
                struct sched_param __user *, param)
@@ -3500,6 +3531,8 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
  * sys_sched_setparam - set/change the RT priority of a thread
  * @pid: the pid in question.
  * @param: structure containing the new RT priority.
+ *
+ * Return: 0 on success. An error code otherwise.
  */
 SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
 {
@@ -3509,6 +3542,9 @@ SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
 /**
  * sys_sched_getscheduler - get the policy (scheduling class) of a thread
  * @pid: the pid in question.
+ *
+ * Return: On success, the policy of the thread. Otherwise, a negative error
+ * code.
  */
 SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
 {
@@ -3535,6 +3571,9 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
  * sys_sched_getparam - get the RT priority of a thread
  * @pid: the pid in question.
  * @param: structure containing the RT priority.
+ *
+ * Return: On success, 0 and the RT priority is in @param. Otherwise, an error
+ * code.
  */
 SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
 {
@@ -3659,6 +3698,8 @@ static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len,
  * @pid: pid of the process
  * @len: length in bytes of the bitmask pointed to by user_mask_ptr
  * @user_mask_ptr: user-space pointer to the new cpu mask
+ *
+ * Return: 0 on success. An error code otherwise.
  */
 SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len,
                unsigned long __user *, user_mask_ptr)
@@ -3710,6 +3751,8 @@ out_unlock:
  * @pid: pid of the process
  * @len: length in bytes of the bitmask pointed to by user_mask_ptr
  * @user_mask_ptr: user-space pointer to hold the current cpu mask
+ *
+ * Return: 0 on success. An error code otherwise.
  */
 SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
                unsigned long __user *, user_mask_ptr)
@@ -3744,6 +3787,8 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
  *
  * This function yields the current CPU to other tasks. If there are no
  * other threads running on this CPU then this function will return.
+ *
+ * Return: 0.
  */
 SYSCALL_DEFINE0(sched_yield)
 {
@@ -3869,7 +3914,7 @@ EXPORT_SYMBOL(yield);
  * It's the caller's job to ensure that the target task struct
  * can't go away on us before we can do any checks.
  *
- * Returns:
+ * Return:
  *     true (>0) if we indeed boosted the target task.
  *     false (0) if we failed to boost the target.
  *     -ESRCH if there's no task to yield to.
@@ -3972,8 +4017,9 @@ long __sched io_schedule_timeout(long timeout)
  * sys_sched_get_priority_max - return maximum RT priority.
  * @policy: scheduling class.
  *
- * this syscall returns the maximum rt_priority that can be used
- * by a given scheduling class.
+ * Return: On success, this syscall returns the maximum
+ * rt_priority that can be used by a given scheduling class.
+ * On failure, a negative error code is returned.
  */
 SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
 {
@@ -3997,8 +4043,9 @@ SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
  * sys_sched_get_priority_min - return minimum RT priority.
  * @policy: scheduling class.
  *
- * this syscall returns the minimum rt_priority that can be used
- * by a given scheduling class.
+ * Return: On success, this syscall returns the minimum
+ * rt_priority that can be used by a given scheduling class.
+ * On failure, a negative error code is returned.
  */
 SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
 {
@@ -4024,6 +4071,9 @@ SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
  *
  * this syscall writes the default timeslice value of a given process
  * into the user-space timespec buffer. A value of '0' means infinity.
+ *
+ * Return: On success, 0 and the timeslice is in @interval. Otherwise,
+ * an error code.
  */
 SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
                struct timespec __user *, interval)
@@ -4133,7 +4183,7 @@ void show_state_filter(unsigned long state_filter)
                debug_show_all_locks();
 }
 
-void __cpuinit init_idle_bootup_task(struct task_struct *idle)
+void init_idle_bootup_task(struct task_struct *idle)
 {
        idle->sched_class = &idle_sched_class;
 }
@@ -4146,7 +4196,7 @@ void __cpuinit init_idle_bootup_task(struct task_struct *idle)
  * NOTE: this function does not set the idle thread's NEED_RESCHED
  * flag, to make booting more robust.
  */
-void __cpuinit init_idle(struct task_struct *idle, int cpu)
+void init_idle(struct task_struct *idle, int cpu)
 {
        struct rq *rq = cpu_rq(cpu);
        unsigned long flags;
@@ -4630,7 +4680,7 @@ static void set_rq_offline(struct rq *rq)
  * migration_call - callback that gets triggered when a CPU is added.
  * Here we can start up the necessary migration thread for the new CPU.
  */
-static int __cpuinit
+static int
 migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
        int cpu = (long)hcpu;
@@ -4684,12 +4734,12 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
  * happens before everything else.  This has to be lower priority than
  * the notifier in the perf_event subsystem, though.
  */
-static struct notifier_block __cpuinitdata migration_notifier = {
+static struct notifier_block migration_notifier = {
        .notifier_call = migration_call,
        .priority = CPU_PRI_MIGRATION,
 };
 
-static int __cpuinit sched_cpu_active(struct notifier_block *nfb,
+static int sched_cpu_active(struct notifier_block *nfb,
                                      unsigned long action, void *hcpu)
 {
        switch (action & ~CPU_TASKS_FROZEN) {
@@ -4702,7 +4752,7 @@ static int __cpuinit sched_cpu_active(struct notifier_block *nfb,
        }
 }
 
-static int __cpuinit sched_cpu_inactive(struct notifier_block *nfb,
+static int sched_cpu_inactive(struct notifier_block *nfb,
                                        unsigned long action, void *hcpu)
 {
        switch (action & ~CPU_TASKS_FROZEN) {
@@ -6632,6 +6682,8 @@ void normalize_rt_tasks(void)
  * @cpu: the processor in question.
  *
  * ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED!
+ *
+ * Return: The current task for @cpu.
  */
 struct task_struct *curr_task(int cpu)
 {
index 1095e878a46fdbe4a7224eb07a68cf1fc90c2530..8b836b376d9129760066326eabf5040f72b2e4f3 100644 (file)
@@ -62,7 +62,7 @@ static int convert_prio(int prio)
  * any discrepancies created by racing against the uncertainty of the current
  * priority configuration.
  *
- * Returns: (int)bool - CPUs were found
+ * Return: (int)bool - CPUs were found
  */
 int cpupri_find(struct cpupri *cp, struct task_struct *p,
                struct cpumask *lowest_mask)
@@ -203,7 +203,7 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri)
  * cpupri_init - initialize the cpupri structure
  * @cp: The cpupri context
  *
- * Returns: -ENOMEM if memory fails.
+ * Return: -ENOMEM on memory allocation failure.
  */
 int cpupri_init(struct cpupri *cp)
 {
index f77f9c5274494f22b15bade21163a685e80a14e1..68f1609ca149e259fab8db2fdb6bc3d18587a049 100644 (file)
@@ -851,7 +851,7 @@ void task_numa_fault(int node, int pages, bool migrated)
 {
        struct task_struct *p = current;
 
-       if (!sched_feat_numa(NUMA))
+       if (!numabalancing_enabled)
                return;
 
        /* FIXME: Allocate task-specific structure for placement policy here */
@@ -2032,6 +2032,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
         */
        update_entity_load_avg(curr, 1);
        update_cfs_rq_blocked_load(cfs_rq, 1);
+       update_cfs_shares(cfs_rq);
 
 #ifdef CONFIG_SCHED_HRTICK
        /*
@@ -4280,6 +4281,8 @@ struct sg_lb_stats {
  * get_sd_load_idx - Obtain the load index for a given sched domain.
  * @sd: The sched_domain whose load_idx is to be obtained.
  * @idle: The Idle status of the CPU for whose sd load_icx is obtained.
+ *
+ * Return: The load index.
  */
 static inline int get_sd_load_idx(struct sched_domain *sd,
                                        enum cpu_idle_type idle)
@@ -4574,6 +4577,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,
  *
  * Determine if @sg is a busier group than the previously selected
  * busiest group.
+ *
+ * Return: %true if @sg is a busier group than the previously selected
+ * busiest group. %false otherwise.
  */
 static bool update_sd_pick_busiest(struct lb_env *env,
                                   struct sd_lb_stats *sds,
@@ -4691,7 +4697,7 @@ static inline void update_sd_lb_stats(struct lb_env *env,
  * assuming lower CPU number will be equivalent to lower a SMT thread
  * number.
  *
- * Returns 1 when packing is required and a task should be moved to
+ * Return: 1 when packing is required and a task should be moved to
  * this CPU.  The amount of the imbalance is returned in *imbalance.
  *
  * @env: The load balancing environment.
@@ -4869,7 +4875,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
  * @balance: Pointer to a variable indicating if this_cpu
  *     is the appropriate cpu to perform load balancing at this_level.
  *
- * Returns:    - the busiest group if imbalance exists.
+ * Return:     - The busiest group if imbalance exists.
  *             - If no imbalance and user has opted for power-savings balance,
  *                return the least loaded group whose CPUs can be
  *                put to idle by rebalancing its tasks onto our group.
@@ -5506,7 +5512,7 @@ void nohz_balance_enter_idle(int cpu)
        set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
 }
 
-static int __cpuinit sched_ilb_notifier(struct notifier_block *nfb,
+static int sched_ilb_notifier(struct notifier_block *nfb,
                                        unsigned long action, void *hcpu)
 {
        switch (action & ~CPU_TASKS_FROZEN) {
@@ -5786,7 +5792,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
                entity_tick(cfs_rq, se, queued);
        }
 
-       if (sched_feat_numa(NUMA))
+       if (numabalancing_enabled)
                task_tick_numa(rq, curr);
 
        update_rq_runnable_avg(rq, 1);
index 4dba0f7b72ad716cf447f1fdbdd082ff7e0e73cf..fe9f773d71146c82ad9c543ab0456490c9bebd0f 100644 (file)
@@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
+static struct notifier_block hotplug_cfd_notifier = {
        .notifier_call          = hotplug_cfd,
 };
 
index 02fc5c9336735a834378dbbb6fff8e57b919b0fa..eb89e1807408575257b8ea60b64559b1adf8afde 100644 (file)
@@ -24,7 +24,7 @@
  */
 static DEFINE_PER_CPU(struct task_struct *, idle_threads);
 
-struct task_struct * __cpuinit idle_thread_get(unsigned int cpu)
+struct task_struct *idle_thread_get(unsigned int cpu)
 {
        struct task_struct *tsk = per_cpu(idle_threads, cpu);
 
index ca25e6e704a2f8ba1277fd3bd5975ed3518b09f7..be3d3514c325f8aad38d62f65d2aee0393a70585 100644 (file)
@@ -699,7 +699,7 @@ void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq)
 }
 EXPORT_SYMBOL(send_remote_softirq);
 
-static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
+static int remote_softirq_cpu_notify(struct notifier_block *self,
                                               unsigned long action, void *hcpu)
 {
        /*
@@ -728,7 +728,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
+static struct notifier_block remote_softirq_cpu_notifier = {
        .notifier_call  = remote_softirq_cpu_notify,
 };
 
@@ -830,7 +830,7 @@ static void takeover_tasklets(unsigned int cpu)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static int __cpuinit cpu_callback(struct notifier_block *nfb,
+static int cpu_callback(struct notifier_block *nfb,
                                  unsigned long action,
                                  void *hcpu)
 {
@@ -845,7 +845,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata cpu_nfb = {
+static struct notifier_block cpu_nfb = {
        .notifier_call = cpu_callback
 };
 
index ac09d98490aabc0729eb1a4691e8d2b1ec10a34c..07f6fc468e1732734e7fcf5f73982a93670e4194 100644 (file)
@@ -2346,7 +2346,11 @@ static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
                                            int write, void *data)
 {
        if (write) {
-               *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
+               unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
+
+               if (jif > INT_MAX)
+                       return 1;
+               *valp = (int)jif;
        } else {
                int val = *valp;
                unsigned long lval;
index a326f27d7f09e0942ae2df9eb010d8caaabdb725..0b479a6a22bb8fe30e2b9d6c76c2ddb1d5646ae1 100644 (file)
@@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
        BUG_ON(bits > 32);
        WARN_ON(!irqs_disabled());
        read_sched_clock = read;
-       sched_clock_mask = (1 << bits) - 1;
+       sched_clock_mask = (1ULL << bits) - 1;
        cd.rate = rate;
 
        /* calculate the mult/shift to convert counter ticks to ns. */
index 69601726a745ef0ae4cff7c44afba6473cea2c82..e8a1516cc0a36d3c247d2bd4a18ef6d69f17b42c 100644 (file)
@@ -182,7 +182,8 @@ static bool can_stop_full_tick(void)
                 * Don't allow the user to think they can get
                 * full NO_HZ with this machine.
                 */
-               WARN_ONCE(1, "NO_HZ FULL will not work with unstable sched clock");
+               WARN_ONCE(have_nohz_full_mask,
+                         "NO_HZ FULL will not work with unstable sched clock");
                return false;
        }
 #endif
@@ -298,7 +299,7 @@ static int __init tick_nohz_full_setup(char *str)
 }
 __setup("nohz_full=", tick_nohz_full_setup);
 
-static int __cpuinit tick_nohz_cpu_down_callback(struct notifier_block *nfb,
+static int tick_nohz_cpu_down_callback(struct notifier_block *nfb,
                                                 unsigned long action,
                                                 void *hcpu)
 {
@@ -343,8 +344,6 @@ static int tick_nohz_init_all(void)
 
 void __init tick_nohz_init(void)
 {
-       int cpu;
-
        if (!have_nohz_full_mask) {
                if (tick_nohz_init_all() < 0)
                        return;
@@ -827,13 +826,10 @@ void tick_nohz_irq_exit(void)
 {
        struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
 
-       if (ts->inidle) {
-               /* Cancel the timer because CPU already waken up from the C-states*/
-               menu_hrtimer_cancel();
+       if (ts->inidle)
                __tick_nohz_idle_enter(ts);
-       } else {
+       else
                tick_nohz_full_stop_tick(ts);
-       }
 }
 
 /**
@@ -931,8 +927,6 @@ void tick_nohz_idle_exit(void)
 
        ts->inidle = 0;
 
-       /* Cancel the timer because CPU already waken up from the C-states*/
-       menu_hrtimer_cancel();
        if (ts->idle_active || ts->tick_stopped)
                now = ktime_get();
 
index 15bc1b41021dae203b7d3c43293b5edd54cff4cb..4296d13db3d15876f320070caee26c9a6ff06e6d 100644 (file)
@@ -1505,11 +1505,11 @@ signed long __sched schedule_timeout_uninterruptible(signed long timeout)
 }
 EXPORT_SYMBOL(schedule_timeout_uninterruptible);
 
-static int __cpuinit init_timers_cpu(int cpu)
+static int init_timers_cpu(int cpu)
 {
        int j;
        struct tvec_base *base;
-       static char __cpuinitdata tvec_base_done[NR_CPUS];
+       static char tvec_base_done[NR_CPUS];
 
        if (!tvec_base_done[cpu]) {
                static char boot_done;
@@ -1577,7 +1577,7 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea
        }
 }
 
-static void __cpuinit migrate_timers(int cpu)
+static void migrate_timers(int cpu)
 {
        struct tvec_base *old_base;
        struct tvec_base *new_base;
@@ -1610,7 +1610,7 @@ static void __cpuinit migrate_timers(int cpu)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static int __cpuinit timer_cpu_notify(struct notifier_block *self,
+static int timer_cpu_notify(struct notifier_block *self,
                                unsigned long action, void *hcpu)
 {
        long cpu = (long)hcpu;
@@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata timers_nb = {
+static struct notifier_block timers_nb = {
        .notifier_call  = timer_cpu_notify,
 };
 
index 67708f46baaefbd6bca64a34a213c2cc7fda5074..a6d098c6df3f47f960004019fb48468ecea64410 100644 (file)
@@ -1441,12 +1441,22 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable,
  * the hashes are freed with call_rcu_sched().
  */
 static int
-ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip)
+ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs)
 {
        struct ftrace_hash *filter_hash;
        struct ftrace_hash *notrace_hash;
        int ret;
 
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+       /*
+        * There's a small race when adding ops that the ftrace handler
+        * that wants regs, may be called without them. We can not
+        * allow that handler to be called if regs is NULL.
+        */
+       if (regs == NULL && (ops->flags & FTRACE_OPS_FL_SAVE_REGS))
+               return 0;
+#endif
+
        filter_hash = rcu_dereference_raw_notrace(ops->filter_hash);
        notrace_hash = rcu_dereference_raw_notrace(ops->notrace_hash);
 
@@ -2159,12 +2169,57 @@ static cycle_t          ftrace_update_time;
 static unsigned long   ftrace_update_cnt;
 unsigned long          ftrace_update_tot_cnt;
 
-static int ops_traces_mod(struct ftrace_ops *ops)
+static inline int ops_traces_mod(struct ftrace_ops *ops)
 {
-       struct ftrace_hash *hash;
+       /*
+        * Filter_hash being empty will default to trace module.
+        * But notrace hash requires a test of individual module functions.
+        */
+       return ftrace_hash_empty(ops->filter_hash) &&
+               ftrace_hash_empty(ops->notrace_hash);
+}
+
+/*
+ * Check if the current ops references the record.
+ *
+ * If the ops traces all functions, then it was already accounted for.
+ * If the ops does not trace the current record function, skip it.
+ * If the ops ignores the function via notrace filter, skip it.
+ */
+static inline bool
+ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
+{
+       /* If ops isn't enabled, ignore it */
+       if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
+               return 0;
+
+       /* If ops traces all mods, we already accounted for it */
+       if (ops_traces_mod(ops))
+               return 0;
+
+       /* The function must be in the filter */
+       if (!ftrace_hash_empty(ops->filter_hash) &&
+           !ftrace_lookup_ip(ops->filter_hash, rec->ip))
+               return 0;
+
+       /* If in notrace hash, we ignore it too */
+       if (ftrace_lookup_ip(ops->notrace_hash, rec->ip))
+               return 0;
 
-       hash = ops->filter_hash;
-       return ftrace_hash_empty(hash);
+       return 1;
+}
+
+static int referenced_filters(struct dyn_ftrace *rec)
+{
+       struct ftrace_ops *ops;
+       int cnt = 0;
+
+       for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
+               if (ops_references_rec(ops, rec))
+                   cnt++;
+       }
+
+       return cnt;
 }
 
 static int ftrace_update_code(struct module *mod)
@@ -2173,6 +2228,7 @@ static int ftrace_update_code(struct module *mod)
        struct dyn_ftrace *p;
        cycle_t start, stop;
        unsigned long ref = 0;
+       bool test = false;
        int i;
 
        /*
@@ -2186,9 +2242,12 @@ static int ftrace_update_code(struct module *mod)
 
                for (ops = ftrace_ops_list;
                     ops != &ftrace_list_end; ops = ops->next) {
-                       if (ops->flags & FTRACE_OPS_FL_ENABLED &&
-                           ops_traces_mod(ops))
-                               ref++;
+                       if (ops->flags & FTRACE_OPS_FL_ENABLED) {
+                               if (ops_traces_mod(ops))
+                                       ref++;
+                               else
+                                       test = true;
+                       }
                }
        }
 
@@ -2198,12 +2257,16 @@ static int ftrace_update_code(struct module *mod)
        for (pg = ftrace_new_pgs; pg; pg = pg->next) {
 
                for (i = 0; i < pg->index; i++) {
+                       int cnt = ref;
+
                        /* If something went wrong, bail without enabling anything */
                        if (unlikely(ftrace_disabled))
                                return -1;
 
                        p = &pg->records[i];
-                       p->flags = ref;
+                       if (test)
+                               cnt += referenced_filters(p);
+                       p->flags = cnt;
 
                        /*
                         * Do the initial record conversion from mcount jump
@@ -2223,7 +2286,7 @@ static int ftrace_update_code(struct module *mod)
                         * conversion puts the module to the correct state, thus
                         * passing the ftrace_make_call check.
                         */
-                       if (ftrace_start_up && ref) {
+                       if (ftrace_start_up && cnt) {
                                int failed = __ftrace_replace_code(p, 1);
                                if (failed)
                                        ftrace_bug(failed, p->ip);
@@ -3374,6 +3437,12 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
        return add_hash_entry(hash, ip);
 }
 
+static void ftrace_ops_update_code(struct ftrace_ops *ops)
+{
+       if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
+               ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+}
+
 static int
 ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
                unsigned long ip, int remove, int reset, int enable)
@@ -3416,9 +3485,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
 
        mutex_lock(&ftrace_lock);
        ret = ftrace_hash_move(ops, enable, orig_hash, hash);
-       if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED
-           && ftrace_enabled)
-               ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+       if (!ret)
+               ftrace_ops_update_code(ops);
 
        mutex_unlock(&ftrace_lock);
 
@@ -3645,9 +3713,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
                mutex_lock(&ftrace_lock);
                ret = ftrace_hash_move(iter->ops, filter_hash,
                                       orig_hash, iter->hash);
-               if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED)
-                   && ftrace_enabled)
-                       ftrace_run_update_code(FTRACE_UPDATE_CALLS);
+               if (!ret)
+                       ftrace_ops_update_code(iter->ops);
 
                mutex_unlock(&ftrace_lock);
        }
@@ -4218,7 +4285,7 @@ static inline void ftrace_startup_enable(int command) { }
 # define ftrace_shutdown_sysctl()      do { } while (0)
 
 static inline int
-ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip)
+ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs)
 {
        return 1;
 }
@@ -4241,7 +4308,7 @@ ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip,
        do_for_each_ftrace_op(op, ftrace_control_list) {
                if (!(op->flags & FTRACE_OPS_FL_STUB) &&
                    !ftrace_function_local_disabled(op) &&
-                   ftrace_ops_test(op, ip))
+                   ftrace_ops_test(op, ip, regs))
                        op->func(ip, parent_ip, op, regs);
        } while_for_each_ftrace_op(op);
        trace_recursion_clear(TRACE_CONTROL_BIT);
@@ -4274,7 +4341,7 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
         */
        preempt_disable_notrace();
        do_for_each_ftrace_op(op, ftrace_ops_list) {
-               if (ftrace_ops_test(op, ip))
+               if (ftrace_ops_test(op, ip, regs))
                        op->func(ip, parent_ip, op, regs);
        } while_for_each_ftrace_op(op);
        preempt_enable_notrace();
index e444ff88f0a425a00a4921291b46678b6a7efe21..cc2f66f68dc579c7e93967e4306821df29d7adce 100644 (file)
@@ -36,11 +36,11 @@ int ring_buffer_print_entry_header(struct trace_seq *s)
 {
        int ret;
 
-       ret = trace_seq_printf(s, "# compressed entry header\n");
-       ret = trace_seq_printf(s, "\ttype_len    :    5 bits\n");
-       ret = trace_seq_printf(s, "\ttime_delta  :   27 bits\n");
-       ret = trace_seq_printf(s, "\tarray       :   32 bits\n");
-       ret = trace_seq_printf(s, "\n");
+       ret = trace_seq_puts(s, "# compressed entry header\n");
+       ret = trace_seq_puts(s, "\ttype_len    :    5 bits\n");
+       ret = trace_seq_puts(s, "\ttime_delta  :   27 bits\n");
+       ret = trace_seq_puts(s, "\tarray       :   32 bits\n");
+       ret = trace_seq_putc(s, '\n');
        ret = trace_seq_printf(s, "\tpadding     : type == %d\n",
                               RINGBUF_TYPE_PADDING);
        ret = trace_seq_printf(s, "\ttime_extend : type == %d\n",
@@ -1066,7 +1066,7 @@ static int rb_check_list(struct ring_buffer_per_cpu *cpu_buffer,
 }
 
 /**
- * check_pages - integrity check of buffer pages
+ * rb_check_pages - integrity check of buffer pages
  * @cpu_buffer: CPU buffer with pages to test
  *
  * As a safety measure we check to make sure the data pages have not
@@ -1258,7 +1258,7 @@ static int rb_cpu_notify(struct notifier_block *self,
 #endif
 
 /**
- * ring_buffer_alloc - allocate a new ring_buffer
+ * __ring_buffer_alloc - allocate a new ring_buffer
  * @size: the size in bytes per cpu that is needed.
  * @flags: attributes to set for the ring buffer.
  *
@@ -1607,6 +1607,7 @@ static void update_pages_handler(struct work_struct *work)
  * ring_buffer_resize - resize the ring buffer
  * @buffer: the buffer to resize.
  * @size: the new size.
+ * @cpu_id: the cpu buffer to resize
  *
  * Minimum size is 2 * BUF_PAGE_SIZE.
  *
@@ -3956,11 +3957,11 @@ EXPORT_SYMBOL_GPL(ring_buffer_consume);
  * expected.
  *
  * After a sequence of ring_buffer_read_prepare calls, the user is
- * expected to make at least one call to ring_buffer_prepare_sync.
+ * expected to make at least one call to ring_buffer_read_prepare_sync.
  * Afterwards, ring_buffer_read_start is invoked to get things going
  * for real.
  *
- * This overall must be paired with ring_buffer_finish.
+ * This overall must be paired with ring_buffer_read_finish.
  */
 struct ring_buffer_iter *
 ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu)
@@ -4009,7 +4010,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_read_prepare_sync);
  * an intervening ring_buffer_read_prepare_sync must have been
  * performed.
  *
- * Must be paired with ring_buffer_finish.
+ * Must be paired with ring_buffer_read_finish.
  */
 void
 ring_buffer_read_start(struct ring_buffer_iter *iter)
@@ -4031,7 +4032,7 @@ ring_buffer_read_start(struct ring_buffer_iter *iter)
 EXPORT_SYMBOL_GPL(ring_buffer_read_start);
 
 /**
- * ring_buffer_finish - finish reading the iterator of the buffer
+ * ring_buffer_read_finish - finish reading the iterator of the buffer
  * @iter: The iterator retrieved by ring_buffer_start
  *
  * This re-enables the recording to the buffer, and frees the
@@ -4346,6 +4347,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
 /**
  * ring_buffer_alloc_read_page - allocate a page to read from buffer
  * @buffer: the buffer to allocate for.
+ * @cpu: the cpu buffer to allocate.
  *
  * This function is used in conjunction with ring_buffer_read_page.
  * When reading a full page from the ring buffer, these functions
@@ -4403,7 +4405,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_free_read_page);
  * to swap with a page in the ring buffer.
  *
  * for example:
- *     rpage = ring_buffer_alloc_read_page(buffer);
+ *     rpage = ring_buffer_alloc_read_page(buffer, cpu);
  *     if (!rpage)
  *             return error;
  *     ret = ring_buffer_read_page(buffer, &rpage, len, cpu, 0);
index 0cd500bffd9b0a26fc9d5f7107f51e8037e1d4bd..496f94d57698294966d2c0c9bd10de34854b34a5 100644 (file)
@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
 }
 EXPORT_SYMBOL_GPL(filter_current_check_discard);
 
-cycle_t ftrace_now(int cpu)
+cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
 {
        u64 ts;
 
        /* Early boot up does not have a buffer yet */
-       if (!global_trace.trace_buffer.buffer)
+       if (!buf->buffer)
                return trace_clock_local();
 
-       ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu);
-       ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts);
+       ts = ring_buffer_time_stamp(buf->buffer, cpu);
+       ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
 
        return ts;
 }
 
+cycle_t ftrace_now(int cpu)
+{
+       return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
+}
+
 /**
  * tracing_is_enabled - Show if global_trace has been disabled
  *
@@ -1211,7 +1216,7 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
        /* Make sure all commits have finished */
        synchronize_sched();
 
-       buf->time_start = ftrace_now(buf->cpu);
+       buf->time_start = buffer_ftrace_now(buf, buf->cpu);
 
        for_each_online_cpu(cpu)
                ring_buffer_reset_cpu(buffer, cpu);
@@ -1219,23 +1224,17 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
        ring_buffer_record_enable(buffer);
 }
 
-void tracing_reset_current(int cpu)
-{
-       tracing_reset(&global_trace.trace_buffer, cpu);
-}
-
+/* Must have trace_types_lock held */
 void tracing_reset_all_online_cpus(void)
 {
        struct trace_array *tr;
 
-       mutex_lock(&trace_types_lock);
        list_for_each_entry(tr, &ftrace_trace_arrays, list) {
                tracing_reset_online_cpus(&tr->trace_buffer);
 #ifdef CONFIG_TRACER_MAX_TRACE
                tracing_reset_online_cpus(&tr->max_buffer);
 #endif
        }
-       mutex_unlock(&trace_types_lock);
 }
 
 #define SAVED_CMDLINES 128
@@ -2843,6 +2842,17 @@ static int s_show(struct seq_file *m, void *v)
        return 0;
 }
 
+/*
+ * Should be used after trace_array_get(), trace_types_lock
+ * ensures that i_cdev was already initialized.
+ */
+static inline int tracing_get_cpu(struct inode *inode)
+{
+       if (inode->i_cdev) /* See trace_create_cpu_file() */
+               return (long)inode->i_cdev - 1;
+       return RING_BUFFER_ALL_CPUS;
+}
+
 static const struct seq_operations tracer_seq_ops = {
        .start          = s_start,
        .next           = s_next,
@@ -2851,9 +2861,9 @@ static const struct seq_operations tracer_seq_ops = {
 };
 
 static struct trace_iterator *
-__tracing_open(struct trace_array *tr, struct trace_cpu *tc,
-              struct inode *inode, struct file *file, bool snapshot)
+__tracing_open(struct inode *inode, struct file *file, bool snapshot)
 {
+       struct trace_array *tr = inode->i_private;
        struct trace_iterator *iter;
        int cpu;
 
@@ -2894,8 +2904,8 @@ __tracing_open(struct trace_array *tr, struct trace_cpu *tc,
                iter->trace_buffer = &tr->trace_buffer;
        iter->snapshot = snapshot;
        iter->pos = -1;
+       iter->cpu_file = tracing_get_cpu(inode);
        mutex_init(&iter->mutex);
-       iter->cpu_file = tc->cpu;
 
        /* Notify the tracer early; before we stop tracing. */
        if (iter->trace && iter->trace->open)
@@ -2971,45 +2981,22 @@ static int tracing_open_generic_tr(struct inode *inode, struct file *filp)
        filp->private_data = inode->i_private;
 
        return 0;
-       
-}
-
-static int tracing_open_generic_tc(struct inode *inode, struct file *filp)
-{
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
-
-       if (tracing_disabled)
-               return -ENODEV;
-
-       if (trace_array_get(tr) < 0)
-               return -ENODEV;
-
-       filp->private_data = inode->i_private;
-
-       return 0;
-       
 }
 
 static int tracing_release(struct inode *inode, struct file *file)
 {
+       struct trace_array *tr = inode->i_private;
        struct seq_file *m = file->private_data;
        struct trace_iterator *iter;
-       struct trace_array *tr;
        int cpu;
 
-       /* Writes do not use seq_file, need to grab tr from inode */
        if (!(file->f_mode & FMODE_READ)) {
-               struct trace_cpu *tc = inode->i_private;
-
-               trace_array_put(tc->tr);
+               trace_array_put(tr);
                return 0;
        }
 
+       /* Writes do not use seq_file */
        iter = m->private;
-       tr = iter->tr;
-       trace_array_put(tr);
-
        mutex_lock(&trace_types_lock);
 
        for_each_tracing_cpu(cpu) {
@@ -3023,6 +3010,9 @@ static int tracing_release(struct inode *inode, struct file *file)
        if (!iter->snapshot)
                /* reenable tracing if it was previously enabled */
                tracing_start_tr(tr);
+
+       __trace_array_put(tr);
+
        mutex_unlock(&trace_types_lock);
 
        mutex_destroy(&iter->mutex);
@@ -3042,15 +3032,6 @@ static int tracing_release_generic_tr(struct inode *inode, struct file *file)
        return 0;
 }
 
-static int tracing_release_generic_tc(struct inode *inode, struct file *file)
-{
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
-
-       trace_array_put(tr);
-       return 0;
-}
-
 static int tracing_single_release_tr(struct inode *inode, struct file *file)
 {
        struct trace_array *tr = inode->i_private;
@@ -3062,8 +3043,7 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)
 
 static int tracing_open(struct inode *inode, struct file *file)
 {
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
+       struct trace_array *tr = inode->i_private;
        struct trace_iterator *iter;
        int ret = 0;
 
@@ -3071,16 +3051,17 @@ static int tracing_open(struct inode *inode, struct file *file)
                return -ENODEV;
 
        /* If this file was open for write, then erase contents */
-       if ((file->f_mode & FMODE_WRITE) &&
-           (file->f_flags & O_TRUNC)) {
-               if (tc->cpu == RING_BUFFER_ALL_CPUS)
+       if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
+               int cpu = tracing_get_cpu(inode);
+
+               if (cpu == RING_BUFFER_ALL_CPUS)
                        tracing_reset_online_cpus(&tr->trace_buffer);
                else
-                       tracing_reset(&tr->trace_buffer, tc->cpu);
+                       tracing_reset(&tr->trace_buffer, cpu);
        }
 
        if (file->f_mode & FMODE_READ) {
-               iter = __tracing_open(tr, tc, inode, file, false);
+               iter = __tracing_open(inode, file, false);
                if (IS_ERR(iter))
                        ret = PTR_ERR(iter);
                else if (trace_flags & TRACE_ITER_LATENCY_FMT)
@@ -3447,6 +3428,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
 static int tracing_trace_options_open(struct inode *inode, struct file *file)
 {
        struct trace_array *tr = inode->i_private;
+       int ret;
 
        if (tracing_disabled)
                return -ENODEV;
@@ -3454,7 +3436,11 @@ static int tracing_trace_options_open(struct inode *inode, struct file *file)
        if (trace_array_get(tr) < 0)
                return -ENODEV;
 
-       return single_open(file, tracing_trace_options_show, inode->i_private);
+       ret = single_open(file, tracing_trace_options_show, inode->i_private);
+       if (ret < 0)
+               trace_array_put(tr);
+
+       return ret;
 }
 
 static const struct file_operations tracing_iter_fops = {
@@ -3537,14 +3523,14 @@ static const char readme_msg[] =
        "\n  snapshot\t\t- Like 'trace' but shows the content of the static snapshot buffer\n"
        "\t\t\t  Read the contents for more information\n"
 #endif
-#ifdef CONFIG_STACKTRACE
+#ifdef CONFIG_STACK_TRACER
        "  stack_trace\t\t- Shows the max stack trace when active\n"
        "  stack_max_size\t- Shows current max stack size that was traced\n"
        "\t\t\t  Write into this file to reset the max size (trigger a new trace)\n"
 #ifdef CONFIG_DYNAMIC_FTRACE
        "  stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace traces\n"
 #endif
-#endif /* CONFIG_STACKTRACE */
+#endif /* CONFIG_STACK_TRACER */
 ;
 
 static ssize_t
@@ -3941,8 +3927,7 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
 
 static int tracing_open_pipe(struct inode *inode, struct file *filp)
 {
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
+       struct trace_array *tr = inode->i_private;
        struct trace_iterator *iter;
        int ret = 0;
 
@@ -3958,6 +3943,7 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
        iter = kzalloc(sizeof(*iter), GFP_KERNEL);
        if (!iter) {
                ret = -ENOMEM;
+               __trace_array_put(tr);
                goto out;
        }
 
@@ -3987,9 +3973,9 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp)
        if (trace_clocks[tr->clock_id].in_ns)
                iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
 
-       iter->cpu_file = tc->cpu;
-       iter->tr = tc->tr;
-       iter->trace_buffer = &tc->tr->trace_buffer;
+       iter->tr = tr;
+       iter->trace_buffer = &tr->trace_buffer;
+       iter->cpu_file = tracing_get_cpu(inode);
        mutex_init(&iter->mutex);
        filp->private_data = iter;
 
@@ -4012,8 +3998,7 @@ fail:
 static int tracing_release_pipe(struct inode *inode, struct file *file)
 {
        struct trace_iterator *iter = file->private_data;
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
+       struct trace_array *tr = inode->i_private;
 
        mutex_lock(&trace_types_lock);
 
@@ -4166,6 +4151,7 @@ waitagain:
        memset(&iter->seq, 0,
               sizeof(struct trace_iterator) -
               offsetof(struct trace_iterator, seq));
+       cpumask_clear(iter->started);
        iter->pos = -1;
 
        trace_event_read_lock();
@@ -4366,15 +4352,16 @@ static ssize_t
 tracing_entries_read(struct file *filp, char __user *ubuf,
                     size_t cnt, loff_t *ppos)
 {
-       struct trace_cpu *tc = filp->private_data;
-       struct trace_array *tr = tc->tr;
+       struct inode *inode = file_inode(filp);
+       struct trace_array *tr = inode->i_private;
+       int cpu = tracing_get_cpu(inode);
        char buf[64];
        int r = 0;
        ssize_t ret;
 
        mutex_lock(&trace_types_lock);
 
-       if (tc->cpu == RING_BUFFER_ALL_CPUS) {
+       if (cpu == RING_BUFFER_ALL_CPUS) {
                int cpu, buf_size_same;
                unsigned long size;
 
@@ -4401,7 +4388,7 @@ tracing_entries_read(struct file *filp, char __user *ubuf,
                } else
                        r = sprintf(buf, "X\n");
        } else
-               r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->trace_buffer.data, tc->cpu)->entries >> 10);
+               r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->trace_buffer.data, cpu)->entries >> 10);
 
        mutex_unlock(&trace_types_lock);
 
@@ -4413,7 +4400,8 @@ static ssize_t
 tracing_entries_write(struct file *filp, const char __user *ubuf,
                      size_t cnt, loff_t *ppos)
 {
-       struct trace_cpu *tc = filp->private_data;
+       struct inode *inode = file_inode(filp);
+       struct trace_array *tr = inode->i_private;
        unsigned long val;
        int ret;
 
@@ -4427,8 +4415,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
 
        /* value is in KB */
        val <<= 10;
-
-       ret = tracing_resize_ring_buffer(tc->tr, val, tc->cpu);
+       ret = tracing_resize_ring_buffer(tr, val, tracing_get_cpu(inode));
        if (ret < 0)
                return ret;
 
@@ -4482,7 +4469,7 @@ tracing_free_buffer_release(struct inode *inode, struct file *filp)
 
        /* disable tracing ? */
        if (trace_flags & TRACE_ITER_STOP_ON_FREE)
-               tracing_off();
+               tracer_tracing_off(tr);
        /* resize the ring buffer to 0 */
        tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS);
 
@@ -4647,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
         * New clock may not be consistent with the previous clock.
         * Reset the buffer so that it doesn't have incomparable timestamps.
         */
-       tracing_reset_online_cpus(&global_trace.trace_buffer);
+       tracing_reset_online_cpus(&tr->trace_buffer);
 
 #ifdef CONFIG_TRACER_MAX_TRACE
        if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
                ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
-       tracing_reset_online_cpus(&global_trace.max_buffer);
+       tracing_reset_online_cpus(&tr->max_buffer);
 #endif
 
        mutex_unlock(&trace_types_lock);
@@ -4689,8 +4676,7 @@ struct ftrace_buffer_info {
 #ifdef CONFIG_TRACER_SNAPSHOT
 static int tracing_snapshot_open(struct inode *inode, struct file *file)
 {
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
+       struct trace_array *tr = inode->i_private;
        struct trace_iterator *iter;
        struct seq_file *m;
        int ret = 0;
@@ -4699,26 +4685,29 @@ static int tracing_snapshot_open(struct inode *inode, struct file *file)
                return -ENODEV;
 
        if (file->f_mode & FMODE_READ) {
-               iter = __tracing_open(tr, tc, inode, file, true);
+               iter = __tracing_open(inode, file, true);
                if (IS_ERR(iter))
                        ret = PTR_ERR(iter);
        } else {
                /* Writes still need the seq_file to hold the private data */
+               ret = -ENOMEM;
                m = kzalloc(sizeof(*m), GFP_KERNEL);
                if (!m)
-                       return -ENOMEM;
+                       goto out;
                iter = kzalloc(sizeof(*iter), GFP_KERNEL);
                if (!iter) {
                        kfree(m);
-                       return -ENOMEM;
+                       goto out;
                }
+               ret = 0;
+
                iter->tr = tr;
-               iter->trace_buffer = &tc->tr->max_buffer;
-               iter->cpu_file = tc->cpu;
+               iter->trace_buffer = &tr->max_buffer;
+               iter->cpu_file = tracing_get_cpu(inode);
                m->private = iter;
                file->private_data = m;
        }
-
+out:
        if (ret < 0)
                trace_array_put(tr);
 
@@ -4873,11 +4862,11 @@ static const struct file_operations tracing_pipe_fops = {
 };
 
 static const struct file_operations tracing_entries_fops = {
-       .open           = tracing_open_generic_tc,
+       .open           = tracing_open_generic_tr,
        .read           = tracing_entries_read,
        .write          = tracing_entries_write,
        .llseek         = generic_file_llseek,
-       .release        = tracing_release_generic_tc,
+       .release        = tracing_release_generic_tr,
 };
 
 static const struct file_operations tracing_total_entries_fops = {
@@ -4929,8 +4918,7 @@ static const struct file_operations snapshot_raw_fops = {
 
 static int tracing_buffers_open(struct inode *inode, struct file *filp)
 {
-       struct trace_cpu *tc = inode->i_private;
-       struct trace_array *tr = tc->tr;
+       struct trace_array *tr = inode->i_private;
        struct ftrace_buffer_info *info;
        int ret;
 
@@ -4948,10 +4936,8 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp)
 
        mutex_lock(&trace_types_lock);
 
-       tr->ref++;
-
        info->iter.tr           = tr;
-       info->iter.cpu_file     = tc->cpu;
+       info->iter.cpu_file     = tracing_get_cpu(inode);
        info->iter.trace        = tr->current_trace;
        info->iter.trace_buffer = &tr->trace_buffer;
        info->spare             = NULL;
@@ -5268,14 +5254,14 @@ static ssize_t
 tracing_stats_read(struct file *filp, char __user *ubuf,
                   size_t count, loff_t *ppos)
 {
-       struct trace_cpu *tc = filp->private_data;
-       struct trace_array *tr = tc->tr;
+       struct inode *inode = file_inode(filp);
+       struct trace_array *tr = inode->i_private;
        struct trace_buffer *trace_buf = &tr->trace_buffer;
+       int cpu = tracing_get_cpu(inode);
        struct trace_seq *s;
        unsigned long cnt;
        unsigned long long t;
        unsigned long usec_rem;
-       int cpu = tc->cpu;
 
        s = kmalloc(sizeof(*s), GFP_KERNEL);
        if (!s)
@@ -5328,9 +5314,10 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
 }
 
 static const struct file_operations tracing_stats_fops = {
-       .open           = tracing_open_generic,
+       .open           = tracing_open_generic_tr,
        .read           = tracing_stats_read,
        .llseek         = generic_file_llseek,
+       .release        = tracing_release_generic_tr,
 };
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -5519,10 +5506,20 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
        return tr->percpu_dir;
 }
 
+static struct dentry *
+trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
+                     void *data, long cpu, const struct file_operations *fops)
+{
+       struct dentry *ret = trace_create_file(name, mode, parent, data, fops);
+
+       if (ret) /* See tracing_get_cpu() */
+               ret->d_inode->i_cdev = (void *)(cpu + 1);
+       return ret;
+}
+
 static void
 tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
 {
-       struct trace_array_cpu *data = per_cpu_ptr(tr->trace_buffer.data, cpu);
        struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu);
        struct dentry *d_cpu;
        char cpu_dir[30]; /* 30 characters should be more than enough */
@@ -5538,28 +5535,28 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
        }
 
        /* per cpu trace_pipe */
-       trace_create_file("trace_pipe", 0444, d_cpu,
-                       (void *)&data->trace_cpu, &tracing_pipe_fops);
+       trace_create_cpu_file("trace_pipe", 0444, d_cpu,
+                               tr, cpu, &tracing_pipe_fops);
 
        /* per cpu trace */
-       trace_create_file("trace", 0644, d_cpu,
-                       (void *)&data->trace_cpu, &tracing_fops);
+       trace_create_cpu_file("trace", 0644, d_cpu,
+                               tr, cpu, &tracing_fops);
 
-       trace_create_file("trace_pipe_raw", 0444, d_cpu,
-                       (void *)&data->trace_cpu, &tracing_buffers_fops);
+       trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
+                               tr, cpu, &tracing_buffers_fops);
 
-       trace_create_file("stats", 0444, d_cpu,
-                       (void *)&data->trace_cpu, &tracing_stats_fops);
+       trace_create_cpu_file("stats", 0444, d_cpu,
+                               tr, cpu, &tracing_stats_fops);
 
-       trace_create_file("buffer_size_kb", 0444, d_cpu,
-                       (void *)&data->trace_cpu, &tracing_entries_fops);
+       trace_create_cpu_file("buffer_size_kb", 0444, d_cpu,
+                               tr, cpu, &tracing_entries_fops);
 
 #ifdef CONFIG_TRACER_SNAPSHOT
-       trace_create_file("snapshot", 0644, d_cpu,
-                         (void *)&data->trace_cpu, &snapshot_fops);
+       trace_create_cpu_file("snapshot", 0644, d_cpu,
+                               tr, cpu, &snapshot_fops);
 
-       trace_create_file("snapshot_raw", 0444, d_cpu,
-                       (void *)&data->trace_cpu, &snapshot_raw_fops);
+       trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
+                               tr, cpu, &snapshot_raw_fops);
 #endif
 }
 
@@ -5868,17 +5865,6 @@ struct dentry *trace_instance_dir;
 static void
 init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer);
 
-static void init_trace_buffers(struct trace_array *tr, struct trace_buffer *buf)
-{
-       int cpu;
-
-       for_each_tracing_cpu(cpu) {
-               memset(per_cpu_ptr(buf->data, cpu), 0, sizeof(struct trace_array_cpu));
-               per_cpu_ptr(buf->data, cpu)->trace_cpu.cpu = cpu;
-               per_cpu_ptr(buf->data, cpu)->trace_cpu.tr = tr;
-       }
-}
-
 static int
 allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size)
 {
@@ -5896,8 +5882,6 @@ allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size
                return -ENOMEM;
        }
 
-       init_trace_buffers(tr, buf);
-
        /* Allocate the first page for all buffers */
        set_buffer_entries(&tr->trace_buffer,
                           ring_buffer_size(tr->trace_buffer.buffer, 0));
@@ -5964,17 +5948,15 @@ static int new_instance_create(const char *name)
        if (allocate_trace_buffers(tr, trace_buf_size) < 0)
                goto out_free_tr;
 
-       /* Holder for file callbacks */
-       tr->trace_cpu.cpu = RING_BUFFER_ALL_CPUS;
-       tr->trace_cpu.tr = tr;
-
        tr->dir = debugfs_create_dir(name, trace_instance_dir);
        if (!tr->dir)
                goto out_free_tr;
 
        ret = event_trace_add_tracer(tr->dir, tr);
-       if (ret)
+       if (ret) {
+               debugfs_remove_recursive(tr->dir);
                goto out_free_tr;
+       }
 
        init_tracer_debugfs(tr, tr->dir);
 
@@ -6120,13 +6102,13 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
                          tr, &tracing_iter_fops);
 
        trace_create_file("trace", 0644, d_tracer,
-                       (void *)&tr->trace_cpu, &tracing_fops);
+                         tr, &tracing_fops);
 
        trace_create_file("trace_pipe", 0444, d_tracer,
-                       (void *)&tr->trace_cpu, &tracing_pipe_fops);
+                         tr, &tracing_pipe_fops);
 
        trace_create_file("buffer_size_kb", 0644, d_tracer,
-                       (void *)&tr->trace_cpu, &tracing_entries_fops);
+                         tr, &tracing_entries_fops);
 
        trace_create_file("buffer_total_size_kb", 0444, d_tracer,
                          tr, &tracing_total_entries_fops);
@@ -6141,11 +6123,11 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
                          &trace_clock_fops);
 
        trace_create_file("tracing_on", 0644, d_tracer,
-                           tr, &rb_simple_fops);
+                         tr, &rb_simple_fops);
 
 #ifdef CONFIG_TRACER_SNAPSHOT
        trace_create_file("snapshot", 0644, d_tracer,
-                         (void *)&tr->trace_cpu, &snapshot_fops);
+                         tr, &snapshot_fops);
 #endif
 
        for_each_tracing_cpu(cpu)
@@ -6439,10 +6421,6 @@ __init static int tracer_alloc_buffers(void)
 
        global_trace.flags = TRACE_ARRAY_FL_GLOBAL;
 
-       /* Holder for file callbacks */
-       global_trace.trace_cpu.cpu = RING_BUFFER_ALL_CPUS;
-       global_trace.trace_cpu.tr = &global_trace;
-
        INIT_LIST_HEAD(&global_trace.systems);
        INIT_LIST_HEAD(&global_trace.events);
        list_add(&global_trace.list, &ftrace_trace_arrays);
index 4a4f6e1828b633aa8a2ba8a7dc6db70ac87db6a3..afaae41b0a0269012ae394dc5df877cd5cf86045 100644 (file)
@@ -130,19 +130,12 @@ enum trace_flag_type {
 
 struct trace_array;
 
-struct trace_cpu {
-       struct trace_array      *tr;
-       struct dentry           *dir;
-       int                     cpu;
-};
-
 /*
  * The CPU trace array - it consists of thousands of trace entries
  * plus some other descriptor data: (for example which task started
  * the trace, etc.)
  */
 struct trace_array_cpu {
-       struct trace_cpu        trace_cpu;
        atomic_t                disabled;
        void                    *buffer_page;   /* ring buffer spare */
 
@@ -196,7 +189,6 @@ struct trace_array {
        bool                    allocated_snapshot;
 #endif
        int                     buffer_disabled;
-       struct trace_cpu        trace_cpu;      /* place holder */
 #ifdef CONFIG_FTRACE_SYSCALLS
        int                     sys_refcount_enter;
        int                     sys_refcount_exit;
@@ -214,7 +206,6 @@ struct trace_array {
        struct dentry           *event_dir;
        struct list_head        systems;
        struct list_head        events;
-       struct task_struct      *waiter;
        int                     ref;
 };
 
@@ -680,6 +671,15 @@ extern int trace_selftest_startup_sched_switch(struct tracer *trace,
                                               struct trace_array *tr);
 extern int trace_selftest_startup_branch(struct tracer *trace,
                                         struct trace_array *tr);
+/*
+ * Tracer data references selftest functions that only occur
+ * on boot up. These can be __init functions. Thus, when selftests
+ * are enabled, then the tracers need to reference __init functions.
+ */
+#define __tracer_data          __refdata
+#else
+/* Tracers are seldom changed. Optimize when selftests are disabled. */
+#define __tracer_data          __read_mostly
 #endif /* CONFIG_FTRACE_STARTUP_TEST */
 
 extern void *head_page(struct trace_array_cpu *data);
index 84b1e045faba836583fb371d285f49e79bfa6bd0..80c36bcf66e8e8d089776ff14b780f3f85efa418 100644 (file)
@@ -236,6 +236,10 @@ __kprobes void *perf_trace_buf_prepare(int size, unsigned short type,
 
        BUILD_BUG_ON(PERF_MAX_TRACE_SIZE % sizeof(unsigned long));
 
+       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
+                       "perf buffer not large enough"))
+               return NULL;
+
        pc = preempt_count();
 
        *rctxp = perf_swevent_get_recursion_context();
@@ -266,6 +270,10 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
        struct pt_regs regs;
        int rctx;
 
+       head = this_cpu_ptr(event_function.perf_events);
+       if (hlist_empty(head))
+               return;
+
 #define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \
                    sizeof(u64)) - sizeof(u32))
 
@@ -279,8 +287,6 @@ perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
 
        entry->ip = ip;
        entry->parent_ip = parent_ip;
-
-       head = this_cpu_ptr(event_function.perf_events);
        perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, 0,
                              1, &regs, head, NULL);
 
index 7d854290bf817ef8c6b116b031830dc060ae5dc7..29a7ebcfb42621d05cb9a74a7bcf291515b38461 100644 (file)
@@ -409,33 +409,42 @@ static void put_system(struct ftrace_subsystem_dir *dir)
        mutex_unlock(&event_mutex);
 }
 
-/*
- * Open and update trace_array ref count.
- * Must have the current trace_array passed to it.
- */
-static int tracing_open_generic_file(struct inode *inode, struct file *filp)
+static void remove_subsystem(struct ftrace_subsystem_dir *dir)
 {
-       struct ftrace_event_file *file = inode->i_private;
-       struct trace_array *tr = file->tr;
-       int ret;
+       if (!dir)
+               return;
 
-       if (trace_array_get(tr) < 0)
-               return -ENODEV;
+       if (!--dir->nr_events) {
+               debugfs_remove_recursive(dir->entry);
+               list_del(&dir->list);
+               __put_system_dir(dir);
+       }
+}
 
-       ret = tracing_open_generic(inode, filp);
-       if (ret < 0)
-               trace_array_put(tr);
-       return ret;
+static void *event_file_data(struct file *filp)
+{
+       return ACCESS_ONCE(file_inode(filp)->i_private);
 }
 
-static int tracing_release_generic_file(struct inode *inode, struct file *filp)
+static void remove_event_file_dir(struct ftrace_event_file *file)
 {
-       struct ftrace_event_file *file = inode->i_private;
-       struct trace_array *tr = file->tr;
+       struct dentry *dir = file->dir;
+       struct dentry *child;
 
-       trace_array_put(tr);
+       if (dir) {
+               spin_lock(&dir->d_lock);        /* probably unneeded */
+               list_for_each_entry(child, &dir->d_subdirs, d_u.d_child) {
+                       if (child->d_inode)     /* probably unneeded */
+                               child->d_inode->i_private = NULL;
+               }
+               spin_unlock(&dir->d_lock);
 
-       return 0;
+               debugfs_remove_recursive(dir);
+       }
+
+       list_del(&file->list);
+       remove_subsystem(file->system);
+       kmem_cache_free(file_cachep, file);
 }
 
 /*
@@ -679,15 +688,25 @@ static ssize_t
 event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
                  loff_t *ppos)
 {
-       struct ftrace_event_file *file = filp->private_data;
+       struct ftrace_event_file *file;
+       unsigned long flags;
        char buf[4] = "0";
 
-       if (file->flags & FTRACE_EVENT_FL_ENABLED &&
-           !(file->flags & FTRACE_EVENT_FL_SOFT_DISABLED))
+       mutex_lock(&event_mutex);
+       file = event_file_data(filp);
+       if (likely(file))
+               flags = file->flags;
+       mutex_unlock(&event_mutex);
+
+       if (!file)
+               return -ENODEV;
+
+       if (flags & FTRACE_EVENT_FL_ENABLED &&
+           !(flags & FTRACE_EVENT_FL_SOFT_DISABLED))
                strcpy(buf, "1");
 
-       if (file->flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
-           file->flags & FTRACE_EVENT_FL_SOFT_MODE)
+       if (flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
+           flags & FTRACE_EVENT_FL_SOFT_MODE)
                strcat(buf, "*");
 
        strcat(buf, "\n");
@@ -699,13 +718,10 @@ static ssize_t
 event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
                   loff_t *ppos)
 {
-       struct ftrace_event_file *file = filp->private_data;
+       struct ftrace_event_file *file;
        unsigned long val;
        int ret;
 
-       if (!file)
-               return -EINVAL;
-
        ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
        if (ret)
                return ret;
@@ -717,8 +733,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
        switch (val) {
        case 0:
        case 1:
+               ret = -ENODEV;
                mutex_lock(&event_mutex);
-               ret = ftrace_event_enable_disable(file, val);
+               file = event_file_data(filp);
+               if (likely(file))
+                       ret = ftrace_event_enable_disable(file, val);
                mutex_unlock(&event_mutex);
                break;
 
@@ -825,65 +844,39 @@ enum {
 
 static void *f_next(struct seq_file *m, void *v, loff_t *pos)
 {
-       struct ftrace_event_call *call = m->private;
-       struct ftrace_event_field *field;
+       struct ftrace_event_call *call = event_file_data(m->private);
        struct list_head *common_head = &ftrace_common_fields;
        struct list_head *head = trace_get_fields(call);
+       struct list_head *node = v;
 
        (*pos)++;
 
        switch ((unsigned long)v) {
        case FORMAT_HEADER:
-               if (unlikely(list_empty(common_head)))
-                       return NULL;
-
-               field = list_entry(common_head->prev,
-                                  struct ftrace_event_field, link);
-               return field;
+               node = common_head;
+               break;
 
        case FORMAT_FIELD_SEPERATOR:
-               if (unlikely(list_empty(head)))
-                       return NULL;
-
-               field = list_entry(head->prev, struct ftrace_event_field, link);
-               return field;
+               node = head;
+               break;
 
        case FORMAT_PRINTFMT:
                /* all done */
                return NULL;
        }
 
-       field = v;
-       if (field->link.prev == common_head)
+       node = node->prev;
+       if (node == common_head)
                return (void *)FORMAT_FIELD_SEPERATOR;
-       else if (field->link.prev == head)
+       else if (node == head)
                return (void *)FORMAT_PRINTFMT;
-
-       field = list_entry(field->link.prev, struct ftrace_event_field, link);
-
-       return field;
-}
-
-static void *f_start(struct seq_file *m, loff_t *pos)
-{
-       loff_t l = 0;
-       void *p;
-
-       /* Start by showing the header */
-       if (!*pos)
-               return (void *)FORMAT_HEADER;
-
-       p = (void *)FORMAT_HEADER;
-       do {
-               p = f_next(m, p, &l);
-       } while (p && l < *pos);
-
-       return p;
+       else
+               return node;
 }
 
 static int f_show(struct seq_file *m, void *v)
 {
-       struct ftrace_event_call *call = m->private;
+       struct ftrace_event_call *call = event_file_data(m->private);
        struct ftrace_event_field *field;
        const char *array_descriptor;
 
@@ -904,8 +897,7 @@ static int f_show(struct seq_file *m, void *v)
                return 0;
        }
 
-       field = v;
-
+       field = list_entry(v, struct ftrace_event_field, link);
        /*
         * Smartly shows the array type(except dynamic array).
         * Normal:
@@ -932,8 +924,25 @@ static int f_show(struct seq_file *m, void *v)
        return 0;
 }
 
+static void *f_start(struct seq_file *m, loff_t *pos)
+{
+       void *p = (void *)FORMAT_HEADER;
+       loff_t l = 0;
+
+       /* ->stop() is called even if ->start() fails */
+       mutex_lock(&event_mutex);
+       if (!event_file_data(m->private))
+               return ERR_PTR(-ENODEV);
+
+       while (l < *pos && p)
+               p = f_next(m, p, &l);
+
+       return p;
+}
+
 static void f_stop(struct seq_file *m, void *p)
 {
+       mutex_unlock(&event_mutex);
 }
 
 static const struct seq_operations trace_format_seq_ops = {
@@ -945,7 +954,6 @@ static const struct seq_operations trace_format_seq_ops = {
 
 static int trace_format_open(struct inode *inode, struct file *file)
 {
-       struct ftrace_event_call *call = inode->i_private;
        struct seq_file *m;
        int ret;
 
@@ -954,7 +962,7 @@ static int trace_format_open(struct inode *inode, struct file *file)
                return ret;
 
        m = file->private_data;
-       m->private = call;
+       m->private = file;
 
        return 0;
 }
@@ -962,45 +970,47 @@ static int trace_format_open(struct inode *inode, struct file *file)
 static ssize_t
 event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
 {
-       struct ftrace_event_call *call = filp->private_data;
-       struct trace_seq *s;
-       int r;
+       int id = (long)event_file_data(filp);
+       char buf[32];
+       int len;
 
        if (*ppos)
                return 0;
 
-       s = kmalloc(sizeof(*s), GFP_KERNEL);
-       if (!s)
-               return -ENOMEM;
+       if (unlikely(!id))
+               return -ENODEV;
 
-       trace_seq_init(s);
-       trace_seq_printf(s, "%d\n", call->event.type);
+       len = sprintf(buf, "%d\n", id);
 
-       r = simple_read_from_buffer(ubuf, cnt, ppos,
-                                   s->buffer, s->len);
-       kfree(s);
-       return r;
+       return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
 }
 
 static ssize_t
 event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
                  loff_t *ppos)
 {
-       struct ftrace_event_call *call = filp->private_data;
+       struct ftrace_event_call *call;
        struct trace_seq *s;
-       int r;
+       int r = -ENODEV;
 
        if (*ppos)
                return 0;
 
        s = kmalloc(sizeof(*s), GFP_KERNEL);
+
        if (!s)
                return -ENOMEM;
 
        trace_seq_init(s);
 
-       print_event_filter(call, s);
-       r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
+       mutex_lock(&event_mutex);
+       call = event_file_data(filp);
+       if (call)
+               print_event_filter(call, s);
+       mutex_unlock(&event_mutex);
+
+       if (call)
+               r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
 
        kfree(s);
 
@@ -1011,9 +1021,9 @@ static ssize_t
 event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
                   loff_t *ppos)
 {
-       struct ftrace_event_call *call = filp->private_data;
+       struct ftrace_event_call *call;
        char *buf;
-       int err;
+       int err = -ENODEV;
 
        if (cnt >= PAGE_SIZE)
                return -EINVAL;
@@ -1028,7 +1038,12 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
        }
        buf[cnt] = '\0';
 
-       err = apply_event_filter(call, buf);
+       mutex_lock(&event_mutex);
+       call = event_file_data(filp);
+       if (call)
+               err = apply_event_filter(call, buf);
+       mutex_unlock(&event_mutex);
+
        free_page((unsigned long) buf);
        if (err < 0)
                return err;
@@ -1218,6 +1233,7 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
 
 static int ftrace_event_avail_open(struct inode *inode, struct file *file);
 static int ftrace_event_set_open(struct inode *inode, struct file *file);
+static int ftrace_event_release(struct inode *inode, struct file *file);
 
 static const struct seq_operations show_event_seq_ops = {
        .start = t_start,
@@ -1245,14 +1261,13 @@ static const struct file_operations ftrace_set_event_fops = {
        .read = seq_read,
        .write = ftrace_event_write,
        .llseek = seq_lseek,
-       .release = seq_release,
+       .release = ftrace_event_release,
 };
 
 static const struct file_operations ftrace_enable_fops = {
-       .open = tracing_open_generic_file,
+       .open = tracing_open_generic,
        .read = event_enable_read,
        .write = event_enable_write,
-       .release = tracing_release_generic_file,
        .llseek = default_llseek,
 };
 
@@ -1264,7 +1279,6 @@ static const struct file_operations ftrace_event_format_fops = {
 };
 
 static const struct file_operations ftrace_event_id_fops = {
-       .open = tracing_open_generic,
        .read = event_id_read,
        .llseek = default_llseek,
 };
@@ -1323,6 +1337,15 @@ ftrace_event_open(struct inode *inode, struct file *file,
        return ret;
 }
 
+static int ftrace_event_release(struct inode *inode, struct file *file)
+{
+       struct trace_array *tr = inode->i_private;
+
+       trace_array_put(tr);
+
+       return seq_release(inode, file);
+}
+
 static int
 ftrace_event_avail_open(struct inode *inode, struct file *file)
 {
@@ -1336,12 +1359,19 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
 {
        const struct seq_operations *seq_ops = &show_set_event_seq_ops;
        struct trace_array *tr = inode->i_private;
+       int ret;
+
+       if (trace_array_get(tr) < 0)
+               return -ENODEV;
 
        if ((file->f_mode & FMODE_WRITE) &&
            (file->f_flags & O_TRUNC))
                ftrace_clear_events(tr);
 
-       return ftrace_event_open(inode, file, seq_ops);
+       ret = ftrace_event_open(inode, file, seq_ops);
+       if (ret < 0)
+               trace_array_put(tr);
+       return ret;
 }
 
 static struct event_subsystem *
@@ -1496,8 +1526,8 @@ event_create_dir(struct dentry *parent,
 
 #ifdef CONFIG_PERF_EVENTS
        if (call->event.type && call->class->reg)
-               trace_create_file("id", 0444, file->dir, call,
-                                 id);
+               trace_create_file("id", 0444, file->dir,
+                                 (void *)(long)call->event.type, id);
 #endif
 
        /*
@@ -1522,33 +1552,16 @@ event_create_dir(struct dentry *parent,
        return 0;
 }
 
-static void remove_subsystem(struct ftrace_subsystem_dir *dir)
-{
-       if (!dir)
-               return;
-
-       if (!--dir->nr_events) {
-               debugfs_remove_recursive(dir->entry);
-               list_del(&dir->list);
-               __put_system_dir(dir);
-       }
-}
-
 static void remove_event_from_tracers(struct ftrace_event_call *call)
 {
        struct ftrace_event_file *file;
        struct trace_array *tr;
 
        do_for_each_event_file_safe(tr, file) {
-
                if (file->event_call != call)
                        continue;
 
-               list_del(&file->list);
-               debugfs_remove_recursive(file->dir);
-               remove_subsystem(file->system);
-               kmem_cache_free(file_cachep, file);
-
+               remove_event_file_dir(file);
                /*
                 * The do_for_each_event_file_safe() is
                 * a double loop. After finding the call for this
@@ -1700,16 +1713,53 @@ static void __trace_remove_event_call(struct ftrace_event_call *call)
        destroy_preds(call);
 }
 
+static int probe_remove_event_call(struct ftrace_event_call *call)
+{
+       struct trace_array *tr;
+       struct ftrace_event_file *file;
+
+#ifdef CONFIG_PERF_EVENTS
+       if (call->perf_refcount)
+               return -EBUSY;
+#endif
+       do_for_each_event_file(tr, file) {
+               if (file->event_call != call)
+                       continue;
+               /*
+                * We can't rely on ftrace_event_enable_disable(enable => 0)
+                * we are going to do, FTRACE_EVENT_FL_SOFT_MODE can suppress
+                * TRACE_REG_UNREGISTER.
+                */
+               if (file->flags & FTRACE_EVENT_FL_ENABLED)
+                       return -EBUSY;
+               /*
+                * The do_for_each_event_file_safe() is
+                * a double loop. After finding the call for this
+                * trace_array, we use break to jump to the next
+                * trace_array.
+                */
+               break;
+       } while_for_each_event_file();
+
+       __trace_remove_event_call(call);
+
+       return 0;
+}
+
 /* Remove an event_call */
-void trace_remove_event_call(struct ftrace_event_call *call)
+int trace_remove_event_call(struct ftrace_event_call *call)
 {
+       int ret;
+
        mutex_lock(&trace_types_lock);
        mutex_lock(&event_mutex);
        down_write(&trace_event_sem);
-       __trace_remove_event_call(call);
+       ret = probe_remove_event_call(call);
        up_write(&trace_event_sem);
        mutex_unlock(&event_mutex);
        mutex_unlock(&trace_types_lock);
+
+       return ret;
 }
 
 #define for_each_event(event, start, end)                      \
@@ -2278,12 +2328,8 @@ __trace_remove_event_dirs(struct trace_array *tr)
 {
        struct ftrace_event_file *file, *next;
 
-       list_for_each_entry_safe(file, next, &tr->events, list) {
-               list_del(&file->list);
-               debugfs_remove_recursive(file->dir);
-               remove_subsystem(file->system);
-               kmem_cache_free(file_cachep, file);
-       }
+       list_for_each_entry_safe(file, next, &tr->events, list)
+               remove_event_file_dir(file);
 }
 
 static void
index 0d883dc057d68fe92bc36f0510298cff725256bb..97daa8cf958df8e73c9fa8090f89cbaf4e63893e 100644 (file)
@@ -637,17 +637,15 @@ static void append_filter_err(struct filter_parse_state *ps,
        free_page((unsigned long) buf);
 }
 
+/* caller must hold event_mutex */
 void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
 {
-       struct event_filter *filter;
+       struct event_filter *filter = call->filter;
 
-       mutex_lock(&event_mutex);
-       filter = call->filter;
        if (filter && filter->filter_string)
                trace_seq_printf(s, "%s\n", filter->filter_string);
        else
-               trace_seq_printf(s, "none\n");
-       mutex_unlock(&event_mutex);
+               trace_seq_puts(s, "none\n");
 }
 
 void print_subsystem_event_filter(struct event_subsystem *system,
@@ -660,7 +658,7 @@ void print_subsystem_event_filter(struct event_subsystem *system,
        if (filter && filter->filter_string)
                trace_seq_printf(s, "%s\n", filter->filter_string);
        else
-               trace_seq_printf(s, DEFAULT_SYS_FILTER_MESSAGE "\n");
+               trace_seq_puts(s, DEFAULT_SYS_FILTER_MESSAGE "\n");
        mutex_unlock(&event_mutex);
 }
 
@@ -1841,23 +1839,22 @@ static int create_system_filter(struct event_subsystem *system,
        return err;
 }
 
+/* caller must hold event_mutex */
 int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
 {
        struct event_filter *filter;
-       int err = 0;
-
-       mutex_lock(&event_mutex);
+       int err;
 
        if (!strcmp(strstrip(filter_string), "0")) {
                filter_disable(call);
                filter = call->filter;
                if (!filter)
-                       goto out_unlock;
+                       return 0;
                RCU_INIT_POINTER(call->filter, NULL);
                /* Make sure the filter is not being used */
                synchronize_sched();
                __free_filter(filter);
-               goto out_unlock;
+               return 0;
        }
 
        err = create_filter(call, filter_string, true, &filter);
@@ -1884,8 +1881,6 @@ int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
                        __free_filter(tmp);
                }
        }
-out_unlock:
-       mutex_unlock(&event_mutex);
 
        return err;
 }
index b863f93b30f35caae4239629ea56d05b58b38639..38fe1483c50817cc4b1b6a33807985cda37d9b6a 100644 (file)
@@ -199,7 +199,7 @@ static int func_set_flag(u32 old_flags, u32 bit, int set)
        return 0;
 }
 
-static struct tracer function_trace __read_mostly =
+static struct tracer function_trace __tracer_data =
 {
        .name           = "function",
        .init           = function_trace_init,
index 8388bc99f2eee165efacbef7ddde4f7f21d49ea3..b5c09242683d8cd1c989d2706702d4d42e182d73 100644 (file)
@@ -446,7 +446,7 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
 
        /* First spaces to align center */
        for (i = 0; i < spaces / 2; i++) {
-               ret = trace_seq_printf(s, " ");
+               ret = trace_seq_putc(s, ' ');
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -457,7 +457,7 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
 
        /* Last spaces to align center */
        for (i = 0; i < spaces - (spaces / 2); i++) {
-               ret = trace_seq_printf(s, " ");
+               ret = trace_seq_putc(s, ' ');
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -503,7 +503,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
  ------------------------------------------
 
  */
-       ret = trace_seq_printf(s,
+       ret = trace_seq_puts(s,
                " ------------------------------------------\n");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
@@ -516,7 +516,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
        if (ret == TRACE_TYPE_PARTIAL_LINE)
                return TRACE_TYPE_PARTIAL_LINE;
 
-       ret = trace_seq_printf(s, " => ");
+       ret = trace_seq_puts(s, " => ");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
@@ -524,7 +524,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data)
        if (ret == TRACE_TYPE_PARTIAL_LINE)
                return TRACE_TYPE_PARTIAL_LINE;
 
-       ret = trace_seq_printf(s,
+       ret = trace_seq_puts(s,
                "\n ------------------------------------------\n\n");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
@@ -645,7 +645,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
                        ret = print_graph_proc(s, pid);
                        if (ret == TRACE_TYPE_PARTIAL_LINE)
                                return TRACE_TYPE_PARTIAL_LINE;
-                       ret = trace_seq_printf(s, " | ");
+                       ret = trace_seq_puts(s, " | ");
                        if (!ret)
                                return TRACE_TYPE_PARTIAL_LINE;
                }
@@ -657,9 +657,9 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
                return ret;
 
        if (type == TRACE_GRAPH_ENT)
-               ret = trace_seq_printf(s, "==========>");
+               ret = trace_seq_puts(s, "==========>");
        else
-               ret = trace_seq_printf(s, "<==========");
+               ret = trace_seq_puts(s, "<==========");
 
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
@@ -668,7 +668,7 @@ print_graph_irq(struct trace_iterator *iter, unsigned long addr,
        if (ret != TRACE_TYPE_HANDLED)
                return ret;
 
-       ret = trace_seq_printf(s, "\n");
+       ret = trace_seq_putc(s, '\n');
 
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
@@ -705,13 +705,13 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
                len += strlen(nsecs_str);
        }
 
-       ret = trace_seq_printf(s, " us ");
+       ret = trace_seq_puts(s, " us ");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
        /* Print remaining spaces to fit the row's width */
        for (i = len; i < 7; i++) {
-               ret = trace_seq_printf(s, " ");
+               ret = trace_seq_putc(s, ' ');
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -731,13 +731,13 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
        /* No real adata, just filling the column with spaces */
        switch (duration) {
        case DURATION_FILL_FULL:
-               ret = trace_seq_printf(s, "              |  ");
+               ret = trace_seq_puts(s, "              |  ");
                return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
        case DURATION_FILL_START:
-               ret = trace_seq_printf(s, "  ");
+               ret = trace_seq_puts(s, "  ");
                return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
        case DURATION_FILL_END:
-               ret = trace_seq_printf(s, " |");
+               ret = trace_seq_puts(s, " |");
                return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
        }
 
@@ -745,10 +745,10 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
        if (flags & TRACE_GRAPH_PRINT_OVERHEAD) {
                /* Duration exceeded 100 msecs */
                if (duration > 100000ULL)
-                       ret = trace_seq_printf(s, "! ");
+                       ret = trace_seq_puts(s, "! ");
                /* Duration exceeded 10 msecs */
                else if (duration > 10000ULL)
-                       ret = trace_seq_printf(s, "+ ");
+                       ret = trace_seq_puts(s, "+ ");
        }
 
        /*
@@ -757,7 +757,7 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
         * to fill out the space.
         */
        if (ret == -1)
-               ret = trace_seq_printf(s, "  ");
+               ret = trace_seq_puts(s, "  ");
 
        /* Catching here any failure happenned above */
        if (!ret)
@@ -767,7 +767,7 @@ print_graph_duration(unsigned long long duration, struct trace_seq *s,
        if (ret != TRACE_TYPE_HANDLED)
                return ret;
 
-       ret = trace_seq_printf(s, "|  ");
+       ret = trace_seq_puts(s, "|  ");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
@@ -817,7 +817,7 @@ print_graph_entry_leaf(struct trace_iterator *iter,
 
        /* Function */
        for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
-               ret = trace_seq_printf(s, " ");
+               ret = trace_seq_putc(s, ' ');
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -858,7 +858,7 @@ print_graph_entry_nested(struct trace_iterator *iter,
 
        /* Function */
        for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) {
-               ret = trace_seq_printf(s, " ");
+               ret = trace_seq_putc(s, ' ');
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -917,7 +917,7 @@ print_graph_prologue(struct trace_iterator *iter, struct trace_seq *s,
                if (ret == TRACE_TYPE_PARTIAL_LINE)
                        return TRACE_TYPE_PARTIAL_LINE;
 
-               ret = trace_seq_printf(s, " | ");
+               ret = trace_seq_puts(s, " | ");
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -1117,7 +1117,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
 
        /* Closing brace */
        for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) {
-               ret = trace_seq_printf(s, " ");
+               ret = trace_seq_putc(s, ' ');
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        }
@@ -1129,7 +1129,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s,
         * belongs to, write out the function name.
         */
        if (func_match) {
-               ret = trace_seq_printf(s, "}\n");
+               ret = trace_seq_puts(s, "}\n");
                if (!ret)
                        return TRACE_TYPE_PARTIAL_LINE;
        } else {
@@ -1179,13 +1179,13 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
        /* Indentation */
        if (depth > 0)
                for (i = 0; i < (depth + 1) * TRACE_GRAPH_INDENT; i++) {
-                       ret = trace_seq_printf(s, " ");
+                       ret = trace_seq_putc(s, ' ');
                        if (!ret)
                                return TRACE_TYPE_PARTIAL_LINE;
                }
 
        /* The comment */
-       ret = trace_seq_printf(s, "/* ");
+       ret = trace_seq_puts(s, "/* ");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
@@ -1216,7 +1216,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent,
                s->len--;
        }
 
-       ret = trace_seq_printf(s, " */\n");
+       ret = trace_seq_puts(s, " */\n");
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
@@ -1448,7 +1448,7 @@ static struct trace_event graph_trace_ret_event = {
        .funcs          = &graph_functions
 };
 
-static struct tracer graph_trace __read_mostly = {
+static struct tracer graph_trace __tracer_data = {
        .name           = "function_graph",
        .open           = graph_trace_open,
        .pipe_open      = graph_trace_open,
index 7ed6976493c87ec2d31637a60a285bc39b4925b8..243f6834d02675c9c1101e1eabe18e56eb7d3244 100644 (file)
@@ -95,7 +95,7 @@ static __kprobes bool trace_probe_is_on_module(struct trace_probe *tp)
 }
 
 static int register_probe_event(struct trace_probe *tp);
-static void unregister_probe_event(struct trace_probe *tp);
+static int unregister_probe_event(struct trace_probe *tp);
 
 static DEFINE_MUTEX(probe_lock);
 static LIST_HEAD(probe_list);
@@ -243,11 +243,11 @@ find_event_file_link(struct trace_probe *tp, struct ftrace_event_file *file)
 static int
 disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
 {
+       struct event_file_link *link = NULL;
+       int wait = 0;
        int ret = 0;
 
        if (file) {
-               struct event_file_link *link;
-
                link = find_event_file_link(tp, file);
                if (!link) {
                        ret = -EINVAL;
@@ -255,10 +255,7 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
                }
 
                list_del_rcu(&link->list);
-               /* synchronize with kprobe_trace_func/kretprobe_trace_func */
-               synchronize_sched();
-               kfree(link);
-
+               wait = 1;
                if (!list_empty(&tp->files))
                        goto out;
 
@@ -271,8 +268,22 @@ disable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
                        disable_kretprobe(&tp->rp);
                else
                        disable_kprobe(&tp->rp.kp);
+               wait = 1;
        }
  out:
+       if (wait) {
+               /*
+                * Synchronize with kprobe_trace_func/kretprobe_trace_func
+                * to ensure disabled (all running handlers are finished).
+                * This is not only for kfree(), but also the caller,
+                * trace_remove_event_call() supposes it for releasing
+                * event_call related objects, which will be accessed in
+                * the kprobe_trace_func/kretprobe_trace_func.
+                */
+               synchronize_sched();
+               kfree(link);    /* Ignored if link == NULL */
+       }
+
        return ret;
 }
 
@@ -340,9 +351,12 @@ static int unregister_trace_probe(struct trace_probe *tp)
        if (trace_probe_is_enabled(tp))
                return -EBUSY;
 
+       /* Will fail if probe is being used by ftrace or perf */
+       if (unregister_probe_event(tp))
+               return -EBUSY;
+
        __unregister_trace_probe(tp);
        list_del(&tp->list);
-       unregister_probe_event(tp);
 
        return 0;
 }
@@ -621,7 +635,9 @@ static int release_all_trace_probes(void)
        /* TODO: Use batch unregistration */
        while (!list_empty(&probe_list)) {
                tp = list_entry(probe_list.next, struct trace_probe, list);
-               unregister_trace_probe(tp);
+               ret = unregister_trace_probe(tp);
+               if (ret)
+                       goto end;
                free_trace_probe(tp);
        }
 
@@ -1087,9 +1103,6 @@ kprobe_perf_func(struct trace_probe *tp, struct pt_regs *regs)
        __size = sizeof(*entry) + tp->size + dsize;
        size = ALIGN(__size + sizeof(u32), sizeof(u64));
        size -= sizeof(u32);
-       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
-                    "profile buffer not large enough"))
-               return;
 
        entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
        if (!entry)
@@ -1120,9 +1133,6 @@ kretprobe_perf_func(struct trace_probe *tp, struct kretprobe_instance *ri,
        __size = sizeof(*entry) + tp->size + dsize;
        size = ALIGN(__size + sizeof(u32), sizeof(u64));
        size -= sizeof(u32);
-       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
-                    "profile buffer not large enough"))
-               return;
 
        entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
        if (!entry)
@@ -1242,11 +1252,15 @@ static int register_probe_event(struct trace_probe *tp)
        return ret;
 }
 
-static void unregister_probe_event(struct trace_probe *tp)
+static int unregister_probe_event(struct trace_probe *tp)
 {
+       int ret;
+
        /* tp->event is unregistered in trace_remove_event_call() */
-       trace_remove_event_call(&tp->call);
-       kfree(tp->call.print_fmt);
+       ret = trace_remove_event_call(&tp->call);
+       if (!ret)
+               kfree(tp->call.print_fmt);
+       return ret;
 }
 
 /* Make a debugfs interface for controlling probe points */
index a5e8f4878bfa3015ebb3372c8d09c2aa641b5bc1..b3dcfb2f0fef4e1bc9e9815021adc3e8dfe7d32a 100644 (file)
@@ -90,7 +90,7 @@ static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
        if (drv)
                ret += trace_seq_printf(s, " %s\n", drv->name);
        else
-               ret += trace_seq_printf(s, " \n");
+               ret += trace_seq_puts(s, " \n");
        return ret;
 }
 
@@ -107,7 +107,7 @@ static void mmio_pipe_open(struct trace_iterator *iter)
        struct header_iter *hiter;
        struct trace_seq *s = &iter->seq;
 
-       trace_seq_printf(s, "VERSION 20070824\n");
+       trace_seq_puts(s, "VERSION 20070824\n");
 
        hiter = kzalloc(sizeof(*hiter), GFP_KERNEL);
        if (!hiter)
@@ -209,7 +209,7 @@ static enum print_line_t mmio_print_rw(struct trace_iterator *iter)
                        (rw->value >> 0) & 0xff, rw->pc, 0);
                break;
        default:
-               ret = trace_seq_printf(s, "rw what?\n");
+               ret = trace_seq_puts(s, "rw what?\n");
                break;
        }
        if (ret)
@@ -245,7 +245,7 @@ static enum print_line_t mmio_print_map(struct trace_iterator *iter)
                        secs, usec_rem, m->map_id, 0UL, 0);
                break;
        default:
-               ret = trace_seq_printf(s, "map what?\n");
+               ret = trace_seq_puts(s, "map what?\n");
                break;
        }
        if (ret)
index bb922d9ee51ba7b51171db284f6cd20576b012b2..34e7cbac0c9c17f8de2a0c8c137552deb9498b60 100644 (file)
@@ -78,7 +78,7 @@ enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter)
 
        trace_assign_type(field, entry);
 
-       ret = trace_seq_printf(s, "%s", field->buf);
+       ret = trace_seq_puts(s, field->buf);
        if (!ret)
                return TRACE_TYPE_PARTIAL_LINE;
 
@@ -558,14 +558,14 @@ seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
                        if (ret)
                                ret = trace_seq_puts(s, "??");
                        if (ret)
-                               ret = trace_seq_puts(s, "\n");
+                               ret = trace_seq_putc(s, '\n');
                        continue;
                }
                if (!ret)
                        break;
                if (ret)
                        ret = seq_print_user_ip(s, mm, ip, sym_flags);
-               ret = trace_seq_puts(s, "\n");
+               ret = trace_seq_putc(s, '\n');
        }
 
        if (mm)
@@ -579,7 +579,7 @@ seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
        int ret;
 
        if (!ip)
-               return trace_seq_printf(s, "0");
+               return trace_seq_putc(s, '0');
 
        if (sym_flags & TRACE_ITER_SYM_OFFSET)
                ret = seq_print_sym_offset(s, "%s", ip);
@@ -964,14 +964,14 @@ static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags,
                goto partial;
 
        if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) {
-               if (!trace_seq_printf(s, " <-"))
+               if (!trace_seq_puts(s, " <-"))
                        goto partial;
                if (!seq_print_ip_sym(s,
                                      field->parent_ip,
                                      flags))
                        goto partial;
        }
-       if (!trace_seq_printf(s, "\n"))
+       if (!trace_seq_putc(s, '\n'))
                goto partial;
 
        return TRACE_TYPE_HANDLED;
@@ -1210,7 +1210,7 @@ static enum print_line_t trace_stack_print(struct trace_iterator *iter,
 
                if (!seq_print_ip_sym(s, *p, flags))
                        goto partial;
-               if (!trace_seq_puts(s, "\n"))
+               if (!trace_seq_putc(s, '\n'))
                        goto partial;
        }
 
index 322e16461072575e6d8439208891b5730bd41438..8fd03657bc7d1f684279c46681519e16a1812f87 100644 (file)
@@ -175,7 +175,7 @@ print_syscall_exit(struct trace_iterator *iter, int flags,
        entry = syscall_nr_to_meta(syscall);
 
        if (!entry) {
-               trace_seq_printf(s, "\n");
+               trace_seq_putc(s, '\n');
                return TRACE_TYPE_HANDLED;
        }
 
@@ -566,15 +566,15 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
        if (!sys_data)
                return;
 
+       head = this_cpu_ptr(sys_data->enter_event->perf_events);
+       if (hlist_empty(head))
+               return;
+
        /* get the size after alignment with the u32 buffer size field */
        size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
        size = ALIGN(size + sizeof(u32), sizeof(u64));
        size -= sizeof(u32);
 
-       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
-                     "perf buffer not large enough"))
-               return;
-
        rec = (struct syscall_trace_enter *)perf_trace_buf_prepare(size,
                                sys_data->enter_event->event.type, regs, &rctx);
        if (!rec)
@@ -583,8 +583,6 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
        rec->nr = syscall_nr;
        syscall_get_arguments(current, regs, 0, sys_data->nb_args,
                               (unsigned long *)&rec->args);
-
-       head = this_cpu_ptr(sys_data->enter_event->perf_events);
        perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
 }
 
@@ -642,18 +640,14 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
        if (!sys_data)
                return;
 
+       head = this_cpu_ptr(sys_data->exit_event->perf_events);
+       if (hlist_empty(head))
+               return;
+
        /* We can probably do that at build time */
        size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));
        size -= sizeof(u32);
 
-       /*
-        * Impossible, but be paranoid with the future
-        * How to put this check outside runtime?
-        */
-       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
-               "exit event has grown above perf buffer size"))
-               return;
-
        rec = (struct syscall_trace_exit *)perf_trace_buf_prepare(size,
                                sys_data->exit_event->event.type, regs, &rctx);
        if (!rec)
@@ -661,8 +655,6 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 
        rec->nr = syscall_nr;
        rec->ret = syscall_get_return_value(current, regs);
-
-       head = this_cpu_ptr(sys_data->exit_event->perf_events);
        perf_trace_buf_submit(rec, size, rctx, 0, 1, regs, head, NULL);
 }
 
index d5d0cd368a5635737f749324b61d1037c361c968..272261b5f94ff84e3291be05aaa3b1a8c1ca00ca 100644 (file)
@@ -70,7 +70,7 @@ struct trace_uprobe {
        (sizeof(struct probe_arg) * (n)))
 
 static int register_uprobe_event(struct trace_uprobe *tu);
-static void unregister_uprobe_event(struct trace_uprobe *tu);
+static int unregister_uprobe_event(struct trace_uprobe *tu);
 
 static DEFINE_MUTEX(uprobe_lock);
 static LIST_HEAD(uprobe_list);
@@ -164,11 +164,17 @@ static struct trace_uprobe *find_probe_event(const char *event, const char *grou
 }
 
 /* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
-static void unregister_trace_uprobe(struct trace_uprobe *tu)
+static int unregister_trace_uprobe(struct trace_uprobe *tu)
 {
+       int ret;
+
+       ret = unregister_uprobe_event(tu);
+       if (ret)
+               return ret;
+
        list_del(&tu->list);
-       unregister_uprobe_event(tu);
        free_trace_uprobe(tu);
+       return 0;
 }
 
 /* Register a trace_uprobe and probe_event */
@@ -181,9 +187,12 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
 
        /* register as an event */
        old_tp = find_probe_event(tu->call.name, tu->call.class->system);
-       if (old_tp)
+       if (old_tp) {
                /* delete old event */
-               unregister_trace_uprobe(old_tp);
+               ret = unregister_trace_uprobe(old_tp);
+               if (ret)
+                       goto end;
+       }
 
        ret = register_uprobe_event(tu);
        if (ret) {
@@ -256,6 +265,8 @@ static int create_trace_uprobe(int argc, char **argv)
                group = UPROBE_EVENT_SYSTEM;
 
        if (is_delete) {
+               int ret;
+
                if (!event) {
                        pr_info("Delete command needs an event name.\n");
                        return -EINVAL;
@@ -269,9 +280,9 @@ static int create_trace_uprobe(int argc, char **argv)
                        return -ENOENT;
                }
                /* delete an event */
-               unregister_trace_uprobe(tu);
+               ret = unregister_trace_uprobe(tu);
                mutex_unlock(&uprobe_lock);
-               return 0;
+               return ret;
        }
 
        if (argc < 2) {
@@ -408,16 +419,20 @@ fail_address_parse:
        return ret;
 }
 
-static void cleanup_all_probes(void)
+static int cleanup_all_probes(void)
 {
        struct trace_uprobe *tu;
+       int ret = 0;
 
        mutex_lock(&uprobe_lock);
        while (!list_empty(&uprobe_list)) {
                tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
-               unregister_trace_uprobe(tu);
+               ret = unregister_trace_uprobe(tu);
+               if (ret)
+                       break;
        }
        mutex_unlock(&uprobe_lock);
+       return ret;
 }
 
 /* Probes listing interfaces */
@@ -462,8 +477,13 @@ static const struct seq_operations probes_seq_op = {
 
 static int probes_open(struct inode *inode, struct file *file)
 {
-       if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC))
-               cleanup_all_probes();
+       int ret;
+
+       if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
+               ret = cleanup_all_probes();
+               if (ret)
+                       return ret;
+       }
 
        return seq_open(file, &probes_seq_op);
 }
@@ -818,8 +838,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
 
        size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
        size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
-       if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
-               return;
 
        preempt_disable();
        head = this_cpu_ptr(call->perf_events);
@@ -970,12 +988,17 @@ static int register_uprobe_event(struct trace_uprobe *tu)
        return ret;
 }
 
-static void unregister_uprobe_event(struct trace_uprobe *tu)
+static int unregister_uprobe_event(struct trace_uprobe *tu)
 {
+       int ret;
+
        /* tu->event is unregistered in trace_remove_event_call() */
-       trace_remove_event_call(&tu->call);
+       ret = trace_remove_event_call(&tu->call);
+       if (ret)
+               return ret;
        kfree(tu->call.print_fmt);
        tu->call.print_fmt = NULL;
+       return 0;
 }
 
 /* Make a trace interface for controling probe points */
index d8c30db06c5b75456098fe2f1a26785e9a9110ee..9064b919a4066fe9fca676581479e9162de56717 100644 (file)
@@ -62,6 +62,9 @@ int create_user_ns(struct cred *new)
        kgid_t group = new->egid;
        int ret;
 
+       if (parent_ns->level > 32)
+               return -EUSERS;
+
        /*
         * Verify that we can not violate the policy of which files
         * may be accessed that is specified by the root directory,
@@ -92,6 +95,7 @@ int create_user_ns(struct cred *new)
        atomic_set(&ns->count, 1);
        /* Leave the new->user_ns reference with the new user namespace. */
        ns->parent = parent_ns;
+       ns->level = parent_ns->level + 1;
        ns->owner = owner;
        ns->group = group;
 
@@ -105,16 +109,21 @@ int create_user_ns(struct cred *new)
 int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
 {
        struct cred *cred;
+       int err = -ENOMEM;
 
        if (!(unshare_flags & CLONE_NEWUSER))
                return 0;
 
        cred = prepare_creds();
-       if (!cred)
-               return -ENOMEM;
+       if (cred) {
+               err = create_user_ns(cred);
+               if (err)
+                       put_cred(cred);
+               else
+                       *new_cred = cred;
+       }
 
-       *new_cred = cred;
-       return create_user_ns(cred);
+       return err;
 }
 
 void free_user_ns(struct user_namespace *ns)
index ce0daa320a261f1aebfc5e16d7d7b3e7caf71c37..d550920e040c4515c7c865bb6ba2ab884f7ef7bd 100644 (file)
@@ -333,7 +333,8 @@ int __wait_on_atomic_t(wait_queue_head_t *wq, struct wait_bit_queue *q,
                prepare_to_wait(wq, &q->wait, mode);
                val = q->key.flags;
                if (atomic_read(val) == 0)
-                       ret = (*action)(val);
+                       break;
+               ret = (*action)(val);
        } while (!ret && atomic_read(val) != 0);
        finish_wait(wq, &q->wait);
        return ret;
@@ -362,8 +363,7 @@ EXPORT_SYMBOL(out_of_line_wait_on_atomic_t);
 
 /**
  * wake_up_atomic_t - Wake up a waiter on a atomic_t
- * @word: The word being waited on, a kernel virtual address
- * @bit: The bit of the word being waited on
+ * @p: The atomic_t being waited on, a kernel virtual address
  *
  * Wake up anyone waiting for the atomic_t to go to zero.
  *
index f02c4a4a0c3c8925f61c29982d87b6edcef7dd95..7f5d4be220345b0899d38ced692f2458b9278ce7 100644 (file)
@@ -2817,6 +2817,19 @@ already_gone:
        return false;
 }
 
+static bool __flush_work(struct work_struct *work)
+{
+       struct wq_barrier barr;
+
+       if (start_flush_work(work, &barr)) {
+               wait_for_completion(&barr.done);
+               destroy_work_on_stack(&barr.work);
+               return true;
+       } else {
+               return false;
+       }
+}
+
 /**
  * flush_work - wait for a work to finish executing the last queueing instance
  * @work: the work to flush
@@ -2830,18 +2843,10 @@ already_gone:
  */
 bool flush_work(struct work_struct *work)
 {
-       struct wq_barrier barr;
-
        lock_map_acquire(&work->lockdep_map);
        lock_map_release(&work->lockdep_map);
 
-       if (start_flush_work(work, &barr)) {
-               wait_for_completion(&barr.done);
-               destroy_work_on_stack(&barr.work);
-               return true;
-       } else {
-               return false;
-       }
+       return __flush_work(work);
 }
 EXPORT_SYMBOL_GPL(flush_work);
 
@@ -3411,6 +3416,12 @@ static void copy_workqueue_attrs(struct workqueue_attrs *to,
 {
        to->nice = from->nice;
        cpumask_copy(to->cpumask, from->cpumask);
+       /*
+        * Unlike hash and equality test, this function doesn't ignore
+        * ->no_numa as it is used for both pool and wq attrs.  Instead,
+        * get_unbound_pool() explicitly clears ->no_numa after copying.
+        */
+       to->no_numa = from->no_numa;
 }
 
 /* hash value of the content of @attr */
@@ -3578,6 +3589,12 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
        lockdep_set_subclass(&pool->lock, 1);   /* see put_pwq() */
        copy_workqueue_attrs(pool->attrs, attrs);
 
+       /*
+        * no_numa isn't a worker_pool attribute, always clear it.  See
+        * 'struct workqueue_attrs' comments for detail.
+        */
+       pool->attrs->no_numa = false;
+
        /* if cpumask is contained inside a NUMA node, we belong to that node */
        if (wq_numa_enabled) {
                for_each_node(node) {
@@ -4644,7 +4661,7 @@ static void restore_unbound_workers_cpumask(struct worker_pool *pool, int cpu)
  * Workqueues should be brought up before normal priority CPU notifiers.
  * This will be registered high priority CPU notifier.
  */
-static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb,
+static int workqueue_cpu_up_callback(struct notifier_block *nfb,
                                               unsigned long action,
                                               void *hcpu)
 {
@@ -4697,7 +4714,7 @@ static int __cpuinit workqueue_cpu_up_callback(struct notifier_block *nfb,
  * Workqueues should be brought down after normal priority CPU notifiers.
  * This will be registered as low priority CPU notifier.
  */
-static int __cpuinit workqueue_cpu_down_callback(struct notifier_block *nfb,
+static int workqueue_cpu_down_callback(struct notifier_block *nfb,
                                                 unsigned long action,
                                                 void *hcpu)
 {
@@ -4756,7 +4773,14 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
 
        INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
        schedule_work_on(cpu, &wfc.work);
-       flush_work(&wfc.work);
+
+       /*
+        * The work item is on-stack and can't lead to deadlock through
+        * flushing.  Use __flush_work() to avoid spurious lockdep warnings
+        * when work_on_cpu()s are nested.
+        */
+       __flush_work(&wfc.work);
+
        return wfc.ret;
 }
 EXPORT_SYMBOL_GPL(work_on_cpu);
index 35da51359d404180c8214c007195e97ca89563dd..71d9f81f6eed17e7623ce9d0b55934acac54358c 100644 (file)
@@ -66,8 +66,6 @@ config CRC16
 
 config CRC_T10DIF
        tristate "CRC calculation for the T10 Data Integrity Field"
-       select CRYPTO
-       select CRYPTO_CRCT10DIF
        help
          This option is only needed if a module that's not in the
          kernel tree needs to calculate CRC checks for use with the
index 98ac17ed6222a8982bd6a7435e0269f91e4de195..1501aa553221497a1d8e632439d75a36917fb687 100644 (file)
@@ -238,7 +238,7 @@ config DEBUG_SECTION_MISMATCH
          any use of code/data previously in these sections would
          most likely result in an oops.
          In the code, functions and variables are annotated with
-         __init, __cpuinit, etc. (see the full list in include/linux/init.h),
+         __init,, etc. (see the full list in include/linux/init.h),
          which results in the code/data being placed in specific sections.
          The section mismatch analysis is always performed after a full
          kernel build, and enabling this option causes the following
index fe3428c07b47fb605f53dc1f4d9a48f32fce54c1..fbbd66ed86cde5ed7724ed8f17986cdf1a37edaa 100644 (file)
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/crc-t10dif.h>
-#include <linux/err.h>
-#include <linux/init.h>
-#include <crypto/hash.h>
 
-static struct crypto_shash *crct10dif_tfm;
+/* Table generated using the following polynomium:
+ * x^16 + x^15 + x^11 + x^9 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
+ * gt: 0x8bb7
+ */
+static const __u16 t10_dif_crc_table[256] = {
+       0x0000, 0x8BB7, 0x9CD9, 0x176E, 0xB205, 0x39B2, 0x2EDC, 0xA56B,
+       0xEFBD, 0x640A, 0x7364, 0xF8D3, 0x5DB8, 0xD60F, 0xC161, 0x4AD6,
+       0x54CD, 0xDF7A, 0xC814, 0x43A3, 0xE6C8, 0x6D7F, 0x7A11, 0xF1A6,
+       0xBB70, 0x30C7, 0x27A9, 0xAC1E, 0x0975, 0x82C2, 0x95AC, 0x1E1B,
+       0xA99A, 0x222D, 0x3543, 0xBEF4, 0x1B9F, 0x9028, 0x8746, 0x0CF1,
+       0x4627, 0xCD90, 0xDAFE, 0x5149, 0xF422, 0x7F95, 0x68FB, 0xE34C,
+       0xFD57, 0x76E0, 0x618E, 0xEA39, 0x4F52, 0xC4E5, 0xD38B, 0x583C,
+       0x12EA, 0x995D, 0x8E33, 0x0584, 0xA0EF, 0x2B58, 0x3C36, 0xB781,
+       0xD883, 0x5334, 0x445A, 0xCFED, 0x6A86, 0xE131, 0xF65F, 0x7DE8,
+       0x373E, 0xBC89, 0xABE7, 0x2050, 0x853B, 0x0E8C, 0x19E2, 0x9255,
+       0x8C4E, 0x07F9, 0x1097, 0x9B20, 0x3E4B, 0xB5FC, 0xA292, 0x2925,
+       0x63F3, 0xE844, 0xFF2A, 0x749D, 0xD1F6, 0x5A41, 0x4D2F, 0xC698,
+       0x7119, 0xFAAE, 0xEDC0, 0x6677, 0xC31C, 0x48AB, 0x5FC5, 0xD472,
+       0x9EA4, 0x1513, 0x027D, 0x89CA, 0x2CA1, 0xA716, 0xB078, 0x3BCF,
+       0x25D4, 0xAE63, 0xB90D, 0x32BA, 0x97D1, 0x1C66, 0x0B08, 0x80BF,
+       0xCA69, 0x41DE, 0x56B0, 0xDD07, 0x786C, 0xF3DB, 0xE4B5, 0x6F02,
+       0x3AB1, 0xB106, 0xA668, 0x2DDF, 0x88B4, 0x0303, 0x146D, 0x9FDA,
+       0xD50C, 0x5EBB, 0x49D5, 0xC262, 0x6709, 0xECBE, 0xFBD0, 0x7067,
+       0x6E7C, 0xE5CB, 0xF2A5, 0x7912, 0xDC79, 0x57CE, 0x40A0, 0xCB17,
+       0x81C1, 0x0A76, 0x1D18, 0x96AF, 0x33C4, 0xB873, 0xAF1D, 0x24AA,
+       0x932B, 0x189C, 0x0FF2, 0x8445, 0x212E, 0xAA99, 0xBDF7, 0x3640,
+       0x7C96, 0xF721, 0xE04F, 0x6BF8, 0xCE93, 0x4524, 0x524A, 0xD9FD,
+       0xC7E6, 0x4C51, 0x5B3F, 0xD088, 0x75E3, 0xFE54, 0xE93A, 0x628D,
+       0x285B, 0xA3EC, 0xB482, 0x3F35, 0x9A5E, 0x11E9, 0x0687, 0x8D30,
+       0xE232, 0x6985, 0x7EEB, 0xF55C, 0x5037, 0xDB80, 0xCCEE, 0x4759,
+       0x0D8F, 0x8638, 0x9156, 0x1AE1, 0xBF8A, 0x343D, 0x2353, 0xA8E4,
+       0xB6FF, 0x3D48, 0x2A26, 0xA191, 0x04FA, 0x8F4D, 0x9823, 0x1394,
+       0x5942, 0xD2F5, 0xC59B, 0x4E2C, 0xEB47, 0x60F0, 0x779E, 0xFC29,
+       0x4BA8, 0xC01F, 0xD771, 0x5CC6, 0xF9AD, 0x721A, 0x6574, 0xEEC3,
+       0xA415, 0x2FA2, 0x38CC, 0xB37B, 0x1610, 0x9DA7, 0x8AC9, 0x017E,
+       0x1F65, 0x94D2, 0x83BC, 0x080B, 0xAD60, 0x26D7, 0x31B9, 0xBA0E,
+       0xF0D8, 0x7B6F, 0x6C01, 0xE7B6, 0x42DD, 0xC96A, 0xDE04, 0x55B3
+};
 
 __u16 crc_t10dif(const unsigned char *buffer, size_t len)
 {
-       struct {
-               struct shash_desc shash;
-               char ctx[2];
-       } desc;
-       int err;
-
-       desc.shash.tfm = crct10dif_tfm;
-       desc.shash.flags = 0;
-       *(__u16 *)desc.ctx = 0;
+       __u16 crc = 0;
+       unsigned int i;
 
-       err = crypto_shash_update(&desc.shash, buffer, len);
-       BUG_ON(err);
+       for (i = 0 ; i < len ; i++)
+               crc = (crc << 8) ^ t10_dif_crc_table[((crc >> 8) ^ buffer[i]) & 0xff];
 
-       return *(__u16 *)desc.ctx;
+       return crc;
 }
 EXPORT_SYMBOL(crc_t10dif);
 
-static int __init crc_t10dif_mod_init(void)
-{
-       crct10dif_tfm = crypto_alloc_shash("crct10dif", 0, 0);
-       return PTR_RET(crct10dif_tfm);
-}
-
-static void __exit crc_t10dif_mod_fini(void)
-{
-       crypto_free_shash(crct10dif_tfm);
-}
-
-module_init(crc_t10dif_mod_init);
-module_exit(crc_t10dif_mod_fini);
-
 MODULE_DESCRIPTION("T10 DIF CRC calculation");
 MODULE_LICENSE("GPL");
index 8078ef49cb793fe475c05cf033944fff5e05a8bb..7aa7ce250c94d236143ea4ecedd532632a665700 100644 (file)
@@ -63,7 +63,7 @@ enum cpio_fields {
  *          the match returned an empty filename string.
  */
 
-struct cpio_data __cpuinit find_cpio_data(const char *path, void *data,
+struct cpio_data find_cpio_data(const char *path, void *data,
                                          size_t len,  long *offset)
 {
        const size_t cpio_header_len = 8*C_NFIELDS - 2;
index fd94058bd7f9496fe69699b85177e1c18e4af2e7..28321d8f75eff530ca6832f67f0418cf0abad936 100644 (file)
@@ -437,7 +437,7 @@ int lz4_compress(const unsigned char *src, size_t src_len,
 exit:
        return ret;
 }
-EXPORT_SYMBOL_GPL(lz4_compress);
+EXPORT_SYMBOL(lz4_compress);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("LZ4 compressor");
index d3414eae73a1dfcbbe520e116385ae7c44cb7b44..411be80ddb46942242fb11013844219f8a5bf39c 100644 (file)
@@ -299,7 +299,7 @@ exit_0:
        return ret;
 }
 #ifndef STATIC
-EXPORT_SYMBOL_GPL(lz4_decompress);
+EXPORT_SYMBOL(lz4_decompress);
 #endif
 
 int lz4_decompress_unknownoutputsize(const char *src, size_t src_len,
@@ -319,8 +319,8 @@ exit_0:
        return ret;
 }
 #ifndef STATIC
-EXPORT_SYMBOL_GPL(lz4_decompress_unknownoutputsize);
+EXPORT_SYMBOL(lz4_decompress_unknownoutputsize);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("LZ4 Decompressor");
 #endif
index eb1a74f5e36828ca3617e721daa06ae43ed658c6..f344f76b6559620bf7ae3bdaaeb6ab25265a344e 100644 (file)
@@ -533,7 +533,7 @@ int lz4hc_compress(const unsigned char *src, size_t src_len,
 exit:
        return ret;
 }
-EXPORT_SYMBOL_GPL(lz4hc_compress);
+EXPORT_SYMBOL(lz4hc_compress);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("LZ4HC compressor");
index d411355f238e2088247f0cbf51631c77ae78b10e..aac511417ad19af5d9e3472747a983be5ed3ee4b 100644 (file)
@@ -151,15 +151,12 @@ do { \
 #endif /* __a29k__ */
 
 #if defined(__alpha) && W_TYPE_SIZE == 64
-#define umul_ppmm(ph, pl, m0, m1) \
-do { \
-               UDItype __m0 = (m0), __m1 = (m1); \
-               __asm__ ("umulh %r1,%2,%0" \
-               : "=r" ((UDItype) ph) \
-               : "%rJ" (__m0), \
-                       "rI" (__m1)); \
-               (pl) = __m0 * __m1; \
-       } while (0)
+#define umul_ppmm(ph, pl, m0, m1)                      \
+do {                                                   \
+       UDItype __m0 = (m0), __m1 = (m1);               \
+       (ph) = __builtin_alpha_umulh(__m0, __m1);       \
+       (pl) = __m0 * __m1;                             \
+} while (0)
 #define UMUL_TIME 46
 #ifndef LONGLONG_STANDALONE
 #define udiv_qrnnd(q, r, n1, n0, d) \
@@ -167,7 +164,7 @@ do { UDItype __r; \
        (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \
        (r) = __r; \
 } while (0)
-extern UDItype __udiv_qrnnd();
+extern UDItype __udiv_qrnnd(UDItype *, UDItype, UDItype, UDItype);
 #define UDIV_TIME 220
 #endif /* LONGLONG_STANDALONE */
 #endif /* __alpha */
index 1fc23a3277e13794eca7d230ae2ff79aa9c1e4b5..93c5d5ecff4eacf79d10acfacb67dc4b205828e3 100644 (file)
@@ -158,7 +158,7 @@ static void compute_batch_value(void)
        percpu_counter_batch = max(32, nr*2);
 }
 
-static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
+static int percpu_counter_hotcpu_callback(struct notifier_block *nb,
                                        unsigned long action, void *hcpu)
 {
 #ifdef CONFIG_HOTPLUG_CPU
index d014ee5fcbbd2fa8004ae642f83571ddd949a5e6..e04454cdb33f4d58809c36b0212aa0ad74c1e22c 100644 (file)
@@ -232,8 +232,6 @@ static ssize_t stable_pages_required_show(struct device *dev,
                        bdi_cap_stable_pages_required(bdi) ? 1 : 0);
 }
 
-#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
-
 static struct device_attribute bdi_dev_attrs[] = {
        __ATTR_RW(read_ahead_kb),
        __ATTR_RW(min_ratio),
index 87da3590c61e20287b4854e8212c178f96cb73c6..5bff0814776870e2974e6e436ad99f99f264e05a 100644 (file)
@@ -57,17 +57,22 @@ static int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
                unsigned long addr, unsigned long pgoff, pgprot_t prot)
 {
        int err = -ENOMEM;
-       pte_t *pte;
+       pte_t *pte, ptfile;
        spinlock_t *ptl;
 
        pte = get_locked_pte(mm, addr, &ptl);
        if (!pte)
                goto out;
 
-       if (!pte_none(*pte))
+       ptfile = pgoff_to_pte(pgoff);
+
+       if (!pte_none(*pte)) {
+               if (pte_present(*pte) && pte_soft_dirty(*pte))
+                       pte_file_mksoft_dirty(ptfile);
                zap_pte(mm, vma, addr, pte);
+       }
 
-       set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
+       set_pte_at(mm, addr, pte, ptfile);
        /*
         * We don't need to run update_mmu_cache() here because the "file pte"
         * being installed by install_file_pte() is not a real pte - it's a
index 243e710c6039a287f93ec9f303639c7316dbdf0e..a92012a71702e7156baba919e636bcfcce8971f2 100644 (file)
@@ -1620,7 +1620,9 @@ static void __split_huge_page_refcount(struct page *page,
                                     ((1L << PG_referenced) |
                                      (1L << PG_swapbacked) |
                                      (1L << PG_mlocked) |
-                                     (1L << PG_uptodate)));
+                                     (1L << PG_uptodate) |
+                                     (1L << PG_active) |
+                                     (1L << PG_unevictable)));
                page_tail->flags |= (1L << PG_dirty);
 
                /* clear PageTail before overwriting first_page */
index 83aff0a4d0938e308619a703dfca17265419e628..b60f33080a28f0a078f8186e65ab8d878fced928 100644 (file)
@@ -2490,7 +2490,7 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
 
        mm = vma->vm_mm;
 
-       tlb_gather_mmu(&tlb, mm, 0);
+       tlb_gather_mmu(&tlb, mm, start, end);
        __unmap_hugepage_range(&tlb, vma, start, end, ref_page);
        tlb_finish_mmu(&tlb, start, end);
 }
index d12ca6f3c2934bc83bd83c467ed672c7f352d172..0878ff7c26a95bcf40e23e6e257ee8b9e1704dac 100644 (file)
@@ -2522,7 +2522,7 @@ static void mem_cgroup_drain_pcp_counter(struct mem_cgroup *memcg, int cpu)
        spin_unlock(&memcg->pcp_counter_lock);
 }
 
-static int __cpuinit memcg_cpu_hotplug_callback(struct notifier_block *nb,
+static int memcg_cpu_hotplug_callback(struct notifier_block *nb,
                                        unsigned long action,
                                        void *hcpu)
 {
@@ -3195,11 +3195,11 @@ int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
        if (!s->memcg_params)
                return -ENOMEM;
 
-       INIT_WORK(&s->memcg_params->destroy,
-                       kmem_cache_destroy_work_func);
        if (memcg) {
                s->memcg_params->memcg = memcg;
                s->memcg_params->root_cache = root_cache;
+               INIT_WORK(&s->memcg_params->destroy,
+                               kmem_cache_destroy_work_func);
        } else
                s->memcg_params->is_root_cache = true;
 
@@ -6335,6 +6335,7 @@ static void mem_cgroup_css_offline(struct cgroup *cont)
        mem_cgroup_invalidate_reclaim_iterators(memcg);
        mem_cgroup_reparent_charges(memcg);
        mem_cgroup_destroy_all_caches(memcg);
+       vmpressure_cleanup(&memcg->vmpressure);
 }
 
 static void mem_cgroup_css_free(struct cgroup *cont)
@@ -6968,7 +6969,6 @@ struct cgroup_subsys mem_cgroup_subsys = {
 #ifdef CONFIG_MEMCG_SWAP
 static int __init enable_swap_account(char *s)
 {
-       /* consider enabled if no parameter or 1 is given */
        if (!strcmp(s, "1"))
                really_do_swap_account = 1;
        else if (!strcmp(s, "0"))
index 1ce2e2a734fc2b0812845279a69cb87f48588d3e..af84bc0ec17c213054b023815ae197fefde7ffb6 100644 (file)
@@ -209,14 +209,15 @@ static int tlb_next_batch(struct mmu_gather *tlb)
  *     tear-down from @mm. The @fullmm argument is used when @mm is without
  *     users and we're going to destroy the full address space (exit/execve).
  */
-void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm)
+void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
 {
        tlb->mm = mm;
 
-       tlb->fullmm     = fullmm;
+       /* Is it from 0 to ~0? */
+       tlb->fullmm     = !(start | (end+1));
        tlb->need_flush_all = 0;
-       tlb->start      = -1UL;
-       tlb->end        = 0;
+       tlb->start      = start;
+       tlb->end        = end;
        tlb->need_flush = 0;
        tlb->local.next = NULL;
        tlb->local.nr   = 0;
@@ -256,8 +257,6 @@ void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long e
 {
        struct mmu_gather_batch *batch, *next;
 
-       tlb->start = start;
-       tlb->end   = end;
        tlb_flush_mmu(tlb);
 
        /* keep the page table cache within bounds */
@@ -1099,7 +1098,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
        spinlock_t *ptl;
        pte_t *start_pte;
        pte_t *pte;
-       unsigned long range_start = addr;
 
 again:
        init_rss_vec(rss);
@@ -1141,9 +1139,12 @@ again:
                                continue;
                        if (unlikely(details) && details->nonlinear_vma
                            && linear_page_index(details->nonlinear_vma,
-                                               addr) != page->index)
-                               set_pte_at(mm, addr, pte,
-                                          pgoff_to_pte(page->index));
+                                               addr) != page->index) {
+                               pte_t ptfile = pgoff_to_pte(page->index);
+                               if (pte_soft_dirty(ptent))
+                                       pte_file_mksoft_dirty(ptfile);
+                               set_pte_at(mm, addr, pte, ptfile);
+                       }
                        if (PageAnon(page))
                                rss[MM_ANONPAGES]--;
                        else {
@@ -1202,17 +1203,25 @@ again:
         * and page-free while holding it.
         */
        if (force_flush) {
+               unsigned long old_end;
+
                force_flush = 0;
 
-#ifdef HAVE_GENERIC_MMU_GATHER
-               tlb->start = range_start;
+               /*
+                * Flush the TLB just for the previous segment,
+                * then update the range to be the remaining
+                * TLB range.
+                */
+               old_end = tlb->end;
                tlb->end = addr;
-#endif
+
                tlb_flush_mmu(tlb);
-               if (addr != end) {
-                       range_start = addr;
+
+               tlb->start = addr;
+               tlb->end = old_end;
+
+               if (addr != end)
                        goto again;
-               }
        }
 
        return addr;
@@ -1397,7 +1406,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
        unsigned long end = start + size;
 
        lru_add_drain();
-       tlb_gather_mmu(&tlb, mm, 0);
+       tlb_gather_mmu(&tlb, mm, start, end);
        update_hiwater_rss(mm);
        mmu_notifier_invalidate_range_start(mm, start, end);
        for ( ; vma && vma->vm_start < end; vma = vma->vm_next)
@@ -1423,7 +1432,7 @@ static void zap_page_range_single(struct vm_area_struct *vma, unsigned long addr
        unsigned long end = address + size;
 
        lru_add_drain();
-       tlb_gather_mmu(&tlb, mm, 0);
+       tlb_gather_mmu(&tlb, mm, address, end);
        update_hiwater_rss(mm);
        mmu_notifier_invalidate_range_start(mm, address, end);
        unmap_single_vma(&tlb, vma, address, end, details);
@@ -3115,6 +3124,8 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
                exclusive = 1;
        }
        flush_icache_page(vma, page);
+       if (pte_swp_soft_dirty(orig_pte))
+               pte = pte_mksoft_dirty(pte);
        set_pte_at(mm, address, page_table, pte);
        if (page == swapcache)
                do_page_add_anon_rmap(page, vma, address, exclusive);
@@ -3408,6 +3419,8 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
                entry = mk_pte(page, vma->vm_page_prot);
                if (flags & FAULT_FLAG_WRITE)
                        entry = maybe_mkwrite(pte_mkdirty(entry), vma);
+               else if (pte_file(orig_pte) && pte_file_soft_dirty(orig_pte))
+                       pte_mksoft_dirty(entry);
                if (anon) {
                        inc_mm_counter_fast(mm, MM_ANONPAGES);
                        page_add_new_anon_rmap(page, vma, address);
index 74310017296ee02317b79a2c28b25ef303fc7720..4baf12e534d19031d28ddc5eba5335f72de54099 100644 (file)
@@ -732,7 +732,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
                if (prev) {
                        vma = prev;
                        next = vma->vm_next;
-                       continue;
+                       if (mpol_equal(vma_policy(vma), new_pol))
+                               continue;
+                       /* vma_merge() joined vma && vma->next, case 8 */
+                       goto replace;
                }
                if (vma->vm_start != vmstart) {
                        err = split_vma(vma->vm_mm, vma, vmstart, 1);
@@ -744,6 +747,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
                        if (err)
                                goto out;
                }
+ replace:
                err = vma_replace_policy(vma, new_pol);
                if (err)
                        goto out;
index fbad7b091090d12ba0b101815fdc8699b092ee0d..f9c97d10b873ae4a896c3a22266707653d941c90 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -865,7 +865,7 @@ again:                      remove_next = 1 + (end > next->vm_end);
                if (next->anon_vma)
                        anon_vma_merge(vma, next);
                mm->map_count--;
-               vma_set_policy(vma, vma_policy(next));
+               mpol_put(vma_policy(next));
                kmem_cache_free(vm_area_cachep, next);
                /*
                 * In mprotect's case 6 (see comments on vma_merge),
@@ -2336,7 +2336,7 @@ static void unmap_region(struct mm_struct *mm,
        struct mmu_gather tlb;
 
        lru_add_drain();
-       tlb_gather_mmu(&tlb, mm, 0);
+       tlb_gather_mmu(&tlb, mm, start, end);
        update_hiwater_rss(mm);
        unmap_vmas(&tlb, vma, start, end);
        free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
@@ -2709,7 +2709,7 @@ void exit_mmap(struct mm_struct *mm)
 
        lru_add_drain();
        flush_cache_mm(mm);
-       tlb_gather_mmu(&tlb, mm, 1);
+       tlb_gather_mmu(&tlb, mm, 0, -1);
        /* update_hiwater_rss(mm) here? but nobody should be looking */
        /* Use -1 here to ensure all VMAs in the mm are unmapped */
        unmap_vmas(&tlb, vma, 0, -1);
index 4514ad7415c327bfbbe9837f3a7955291f3a172d..3f0c895c71fee656619de3a6f1c8299cc1f95d6e 100644 (file)
@@ -1619,7 +1619,7 @@ void writeback_set_ratelimit(void)
                ratelimit_pages = 16;
 }
 
-static int __cpuinit
+static int
 ratelimit_handler(struct notifier_block *self, unsigned long action,
                  void *hcpu)
 {
@@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
        }
 }
 
-static struct notifier_block __cpuinitdata ratelimit_nb = {
+static struct notifier_block ratelimit_nb = {
        .notifier_call  = ratelimit_handler,
        .next           = NULL,
 };
index cd356df4f71ab5aa0514e7685b4cce50eafceb6e..b2e29acd7e3d6267a626f7bde5656c4f7fd49640 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1236,6 +1236,7 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                           swp_entry_to_pte(make_hwpoison_entry(page)));
        } else if (PageAnon(page)) {
                swp_entry_t entry = { .val = page_private(page) };
+               pte_t swp_pte;
 
                if (PageSwapCache(page)) {
                        /*
@@ -1264,7 +1265,10 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                        BUG_ON(TTU_ACTION(flags) != TTU_MIGRATION);
                        entry = make_migration_entry(page, pte_write(pteval));
                }
-               set_pte_at(mm, address, pte, swp_entry_to_pte(entry));
+               swp_pte = swp_entry_to_pte(entry);
+               if (pte_soft_dirty(pteval))
+                       swp_pte = pte_swp_mksoft_dirty(swp_pte);
+               set_pte_at(mm, address, pte, swp_pte);
                BUG_ON(pte_file(*pte));
        } else if (IS_ENABLED(CONFIG_MIGRATION) &&
                   (TTU_ACTION(flags) == TTU_MIGRATION)) {
@@ -1401,8 +1405,12 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
                pteval = ptep_clear_flush(vma, address, pte);
 
                /* If nonlinear, store the file page offset in the pte. */
-               if (page->index != linear_page_index(vma, address))
-                       set_pte_at(mm, address, pte, pgoff_to_pte(page->index));
+               if (page->index != linear_page_index(vma, address)) {
+                       pte_t ptfile = pgoff_to_pte(page->index);
+                       if (pte_soft_dirty(pteval))
+                               pte_file_mksoft_dirty(ptfile);
+                       set_pte_at(mm, address, pte, ptfile);
+               }
 
                /* Move the dirty bit to the physical page now the pte is gone. */
                if (pte_dirty(pteval))
index a87990cf9f94019c70d7263d247c1c94945aee5b..8335dbd3fc358ed1fe9d6521785ecee1dc031313 100644 (file)
@@ -1798,7 +1798,8 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
                }
        }
 
-       offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
+       if (offset >= 0)
+               offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
        mutex_unlock(&inode->i_mutex);
        return offset;
 }
index 35cb0c861508c898264c56818ac431086c6f39e1..2580db062df97488a92beeb1e008d866db4d7f7e 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -787,7 +787,7 @@ static void next_reap_node(void)
  * the CPUs getting into lockstep and contending for the global cache chain
  * lock.
  */
-static void __cpuinit start_cpu_timer(int cpu)
+static void start_cpu_timer(int cpu)
 {
        struct delayed_work *reap_work = &per_cpu(slab_reap_work, cpu);
 
@@ -1186,7 +1186,7 @@ static inline int slabs_tofree(struct kmem_cache *cachep,
        return (n->free_objects + cachep->num - 1) / cachep->num;
 }
 
-static void __cpuinit cpuup_canceled(long cpu)
+static void cpuup_canceled(long cpu)
 {
        struct kmem_cache *cachep;
        struct kmem_cache_node *n = NULL;
@@ -1251,7 +1251,7 @@ free_array_cache:
        }
 }
 
-static int __cpuinit cpuup_prepare(long cpu)
+static int cpuup_prepare(long cpu)
 {
        struct kmem_cache *cachep;
        struct kmem_cache_node *n = NULL;
@@ -1334,7 +1334,7 @@ bad:
        return -ENOMEM;
 }
 
-static int __cpuinit cpuup_callback(struct notifier_block *nfb,
+static int cpuup_callback(struct notifier_block *nfb,
                                    unsigned long action, void *hcpu)
 {
        long cpu = (long)hcpu;
@@ -1390,7 +1390,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
        return notifier_from_errno(err);
 }
 
-static struct notifier_block __cpuinitdata cpucache_notifier = {
+static struct notifier_block cpucache_notifier = {
        &cpuup_callback, NULL, 0
 };
 
index 3b482c863002525c6962e0d5a48182273674ad59..e3ba1f2cf60cc0caa5dd7ed059dbe583b477e073 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1968,9 +1968,6 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
        int pages;
        int pobjects;
 
-       if (!s->cpu_partial)
-               return;
-
        do {
                pages = 0;
                pobjects = 0;
@@ -3773,7 +3770,7 @@ int __kmem_cache_create(struct kmem_cache *s, unsigned long flags)
  * Use the cpu notifier to insure that the cpu slabs are flushed when
  * necessary.
  */
-static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
+static int slab_cpuup_callback(struct notifier_block *nfb,
                unsigned long action, void *hcpu)
 {
        long cpu = (long)hcpu;
@@ -3799,7 +3796,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata slab_notifier = {
+static struct notifier_block slab_notifier = {
        .notifier_call = slab_cpuup_callback
 };
 
index 4a1d0d2c52fa4ab4ca66ff4a2025e093521556c9..62b78a6e224f2f10682e9fa11f28b8d01da1c324 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -512,12 +512,7 @@ EXPORT_SYMBOL(__lru_cache_add);
  */
 void lru_cache_add(struct page *page)
 {
-       if (PageActive(page)) {
-               VM_BUG_ON(PageUnevictable(page));
-       } else if (PageUnevictable(page)) {
-               VM_BUG_ON(PageActive(page));
-       }
-
+       VM_BUG_ON(PageActive(page) && PageUnevictable(page));
        VM_BUG_ON(PageLRU(page));
        __lru_cache_add(page);
 }
@@ -539,6 +534,7 @@ void add_page_to_unevictable_list(struct page *page)
 
        spin_lock_irq(&zone->lru_lock);
        lruvec = mem_cgroup_page_lruvec(page, zone);
+       ClearPageActive(page);
        SetPageUnevictable(page);
        SetPageLRU(page);
        add_page_to_lru_list(page, lruvec, LRU_UNEVICTABLE);
@@ -774,8 +770,6 @@ EXPORT_SYMBOL(__pagevec_release);
 void lru_add_page_tail(struct page *page, struct page *page_tail,
                       struct lruvec *lruvec, struct list_head *list)
 {
-       int uninitialized_var(active);
-       enum lru_list lru;
        const int file = 0;
 
        VM_BUG_ON(!PageHead(page));
@@ -787,20 +781,6 @@ void lru_add_page_tail(struct page *page, struct page *page_tail,
        if (!list)
                SetPageLRU(page_tail);
 
-       if (page_evictable(page_tail)) {
-               if (PageActive(page)) {
-                       SetPageActive(page_tail);
-                       active = 1;
-                       lru = LRU_ACTIVE_ANON;
-               } else {
-                       active = 0;
-                       lru = LRU_INACTIVE_ANON;
-               }
-       } else {
-               SetPageUnevictable(page_tail);
-               lru = LRU_UNEVICTABLE;
-       }
-
        if (likely(PageLRU(page)))
                list_add_tail(&page_tail->lru, &page->lru);
        else if (list) {
@@ -816,13 +796,13 @@ void lru_add_page_tail(struct page *page, struct page *page_tail,
                 * Use the standard add function to put page_tail on the list,
                 * but then correct its position so they all end up in order.
                 */
-               add_page_to_lru_list(page_tail, lruvec, lru);
+               add_page_to_lru_list(page_tail, lruvec, page_lru(page_tail));
                list_head = page_tail->lru.prev;
                list_move_tail(&page_tail->lru, list_head);
        }
 
        if (!PageUnevictable(page))
-               update_page_reclaim_stat(lruvec, file, active);
+               update_page_reclaim_stat(lruvec, file, PageActive(page_tail));
 }
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
@@ -833,7 +813,6 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec,
        int active = PageActive(page);
        enum lru_list lru = page_lru(page);
 
-       VM_BUG_ON(PageUnevictable(page));
        VM_BUG_ON(PageLRU(page));
 
        SetPageLRU(page);
index 36af6eeaa67eaa0532442706e668e9a268596c90..6cf2e60983b7c36c5dea0b745e6aadd907c01532 100644 (file)
@@ -866,6 +866,21 @@ unsigned int count_swap_pages(int type, int free)
 }
 #endif /* CONFIG_HIBERNATION */
 
+static inline int maybe_same_pte(pte_t pte, pte_t swp_pte)
+{
+#ifdef CONFIG_MEM_SOFT_DIRTY
+       /*
+        * When pte keeps soft dirty bit the pte generated
+        * from swap entry does not has it, still it's same
+        * pte from logical point of view.
+        */
+       pte_t swp_pte_dirty = pte_swp_mksoft_dirty(swp_pte);
+       return pte_same(pte, swp_pte) || pte_same(pte, swp_pte_dirty);
+#else
+       return pte_same(pte, swp_pte);
+#endif
+}
+
 /*
  * No need to decide whether this PTE shares the swap entry with others,
  * just let do_wp_page work it out if a write is requested later - to
@@ -892,7 +907,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
        }
 
        pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
-       if (unlikely(!pte_same(*pte, swp_entry_to_pte(entry)))) {
+       if (unlikely(!maybe_same_pte(*pte, swp_entry_to_pte(entry)))) {
                mem_cgroup_cancel_charge_swapin(memcg);
                ret = 0;
                goto out;
@@ -947,7 +962,7 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
                 * swapoff spends a _lot_ of time in this loop!
                 * Test inline before going to call unuse_pte.
                 */
-               if (unlikely(pte_same(*pte, swp_pte))) {
+               if (unlikely(maybe_same_pte(*pte, swp_pte))) {
                        pte_unmap(pte);
                        ret = unuse_pte(vma, pmd, addr, entry, page);
                        if (ret)
index 736a6011c2c88606cc7908fe429b14823be18625..0c1e37d829fa026a9fc61ef93b569087939867c5 100644 (file)
@@ -180,12 +180,12 @@ static void vmpressure_work_fn(struct work_struct *work)
        if (!vmpr->scanned)
                return;
 
-       mutex_lock(&vmpr->sr_lock);
+       spin_lock(&vmpr->sr_lock);
        scanned = vmpr->scanned;
        reclaimed = vmpr->reclaimed;
        vmpr->scanned = 0;
        vmpr->reclaimed = 0;
-       mutex_unlock(&vmpr->sr_lock);
+       spin_unlock(&vmpr->sr_lock);
 
        do {
                if (vmpressure_event(vmpr, scanned, reclaimed))
@@ -240,13 +240,13 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
        if (!scanned)
                return;
 
-       mutex_lock(&vmpr->sr_lock);
+       spin_lock(&vmpr->sr_lock);
        vmpr->scanned += scanned;
        vmpr->reclaimed += reclaimed;
        scanned = vmpr->scanned;
-       mutex_unlock(&vmpr->sr_lock);
+       spin_unlock(&vmpr->sr_lock);
 
-       if (scanned < vmpressure_win || work_pending(&vmpr->work))
+       if (scanned < vmpressure_win)
                return;
        schedule_work(&vmpr->work);
 }
@@ -367,8 +367,24 @@ void vmpressure_unregister_event(struct cgroup *cg, struct cftype *cft,
  */
 void vmpressure_init(struct vmpressure *vmpr)
 {
-       mutex_init(&vmpr->sr_lock);
+       spin_lock_init(&vmpr->sr_lock);
        mutex_init(&vmpr->events_lock);
        INIT_LIST_HEAD(&vmpr->events);
        INIT_WORK(&vmpr->work, vmpressure_work_fn);
 }
+
+/**
+ * vmpressure_cleanup() - shuts down vmpressure control structure
+ * @vmpr:      Structure to be cleaned up
+ *
+ * This function should be called before the structure in which it is
+ * embedded is cleaned up.
+ */
+void vmpressure_cleanup(struct vmpressure *vmpr)
+{
+       /*
+        * Make sure there is no pending work before eventfd infrastructure
+        * goes away.
+        */
+       flush_work(&vmpr->work);
+}
index f42745e65780b97a1875cde1df81fe527350d59a..20c2ef4458fac9ba3a5af98afd34b135ec86e5cb 100644 (file)
@@ -1182,7 +1182,7 @@ static void vmstat_update(struct work_struct *w)
                round_jiffies_relative(sysctl_stat_interval));
 }
 
-static void __cpuinit start_cpu_timer(int cpu)
+static void start_cpu_timer(int cpu)
 {
        struct delayed_work *work = &per_cpu(vmstat_work, cpu);
 
@@ -1194,7 +1194,7 @@ static void __cpuinit start_cpu_timer(int cpu)
  * Use the cpu notifier to insure that the thresholds are recalculated
  * when necessary.
  */
-static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
+static int vmstat_cpuup_callback(struct notifier_block *nfb,
                unsigned long action,
                void *hcpu)
 {
@@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata vmstat_notifier =
+static struct notifier_block vmstat_notifier =
        { &vmstat_cpuup_callback, NULL, 0 };
 #endif
 
index 9bb4710e35898b61c6824253501107898db76f36..ad1e781284fdd48492e7bac46c245fae5d578f95 100644 (file)
--- a/mm/zbud.c
+++ b/mm/zbud.c
@@ -257,7 +257,7 @@ int zbud_alloc(struct zbud_pool *pool, int size, gfp_t gfp,
 
        if (size <= 0 || gfp & __GFP_HIGHMEM)
                return -EINVAL;
-       if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED)
+       if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE)
                return -ENOSPC;
        chunks = size_to_chunks(size);
        spin_lock(&pool->lock);
index 2fb2d88e8c2e329ec11653c20478bede1c4e5ad8..61fc573f1142f707fee7d886e67153a62c91c14a 100644 (file)
@@ -210,6 +210,7 @@ out_vid_del:
 static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
 {
        struct net_device *new_dev;
+       struct vlan_dev_priv *vlan;
        struct net *net = dev_net(real_dev);
        struct vlan_net *vn = net_generic(net, vlan_net_id);
        char name[IFNAMSIZ];
@@ -260,11 +261,12 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
        new_dev->mtu = real_dev->mtu;
        new_dev->priv_flags |= (real_dev->priv_flags & IFF_UNICAST_FLT);
 
-       vlan_dev_priv(new_dev)->vlan_proto = htons(ETH_P_8021Q);
-       vlan_dev_priv(new_dev)->vlan_id = vlan_id;
-       vlan_dev_priv(new_dev)->real_dev = real_dev;
-       vlan_dev_priv(new_dev)->dent = NULL;
-       vlan_dev_priv(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
+       vlan = vlan_dev_priv(new_dev);
+       vlan->vlan_proto = htons(ETH_P_8021Q);
+       vlan->vlan_id = vlan_id;
+       vlan->real_dev = real_dev;
+       vlan->dent = NULL;
+       vlan->flags = VLAN_FLAG_REORDER_HDR;
 
        new_dev->rtnl_link_ops = &vlan_link_ops;
        err = register_vlan_dev(new_dev);
@@ -459,6 +461,7 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
        case NETDEV_NOTIFY_PEERS:
        case NETDEV_BONDING_FAILOVER:
+       case NETDEV_RESEND_IGMP:
                /* Propagate to vlan devices */
                vlan_group_for_each_dev(grp, i, vlandev)
                        call_netdevice_notifiers(event, vlandev);
index 8a15eaadc4bd655c9969b0b19197a424d79aaa36..6ee48aac776fbe84db68a503d9aca10ca45b0081 100644 (file)
@@ -9,7 +9,7 @@ bool vlan_do_receive(struct sk_buff **skbp)
 {
        struct sk_buff *skb = *skbp;
        __be16 vlan_proto = skb->vlan_proto;
-       u16 vlan_id = skb->vlan_tci & VLAN_VID_MASK;
+       u16 vlan_id = vlan_tx_tag_get_id(skb);
        struct net_device *vlan_dev;
        struct vlan_pcpu_stats *rx_stats;
 
@@ -91,7 +91,12 @@ EXPORT_SYMBOL(__vlan_find_dev_deep);
 
 struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
-       return vlan_dev_priv(dev)->real_dev;
+       struct net_device *ret = vlan_dev_priv(dev)->real_dev;
+
+       while (is_vlan_dev(ret))
+               ret = vlan_dev_priv(ret)->real_dev;
+
+       return ret;
 }
 EXPORT_SYMBOL(vlan_dev_real_dev);
 
index 3a8c8fd63c88e2c204a8f1ac3b6dc4eb3f15cc63..9ab8a7ed99c0e983c1d6a0c97b378f3b70c4397f 100644 (file)
@@ -73,6 +73,8 @@ vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
 {
        struct vlan_priority_tci_mapping *mp;
 
+       smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */
+
        mp = vlan_dev_priv(dev)->egress_priority_map[(skb->priority & 0xF)];
        while (mp) {
                if (mp->priority == skb->priority) {
@@ -105,10 +107,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
        u16 vlan_tci = 0;
        int rc;
 
-       if (!(vlan_dev_priv(dev)->flags & VLAN_FLAG_REORDER_HDR)) {
+       if (!(vlan->flags & VLAN_FLAG_REORDER_HDR)) {
                vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
 
-               vlan_tci = vlan_dev_priv(dev)->vlan_id;
+               vlan_tci = vlan->vlan_id;
                vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
                vhdr->h_vlan_TCI = htons(vlan_tci);
 
@@ -131,7 +133,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
                saddr = dev->dev_addr;
 
        /* Now make the underlying real hard header */
-       dev = vlan_dev_priv(dev)->real_dev;
+       dev = vlan->real_dev;
        rc = dev_hard_header(skb, dev, type, daddr, saddr, len + vhdrlen);
        if (rc > 0)
                rc += vhdrlen;
@@ -249,6 +251,11 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
        np->next = mp;
        np->priority = skb_prio;
        np->vlan_qos = vlan_qos;
+       /* Before inserting this element in hash table, make sure all its fields
+        * are committed to memory.
+        * coupled with smp_rmb() in vlan_dev_get_egress_qos_mask()
+        */
+       smp_wmb();
        vlan->egress_priority_map[skb_prio & 0xF] = np;
        if (vlan_qos)
                vlan->nr_egress_mappings++;
index 8b93cae2d11d7d013d50c276bd08fc11a1187d08..ba93bdab2701939e2488b30c5c55be315acb0670 100644 (file)
@@ -658,17 +658,12 @@ static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq)
 
        /*
         * if we haven't received a response for oldreq,
-        * remove it from the list, and notify the transport
-        * layer that the reply will never arrive.
+        * remove it from the list
         */
-       spin_lock(&c->lock);
        if (oldreq->status == REQ_STATUS_FLSH) {
+               spin_lock(&c->lock);
                list_del(&oldreq->req_list);
                spin_unlock(&c->lock);
-               if (c->trans_mod->cancelled)
-                       c->trans_mod->cancelled(c, req);
-       } else {
-               spin_unlock(&c->lock);
        }
 
        p9_free_req(c, req);
index 928f2bb9bf8d5d4d43d6324c3ea989a9daf12728..8f68df5d29731cf23b6de1bbee5284c904006c93 100644 (file)
@@ -588,17 +588,6 @@ static int rdma_cancel(struct p9_client *client, struct p9_req_t *req)
        return 1;
 }
 
-/* A request has been fully flushed without a reply.
- * That means we have posted one buffer in excess.
- */
-static int rdma_cancelled(struct p9_client *client, struct p9_req_t *req)
-{
-       struct p9_trans_rdma *rdma = client->trans;
-
-       atomic_inc(&rdma->excess_rc);
-       return 0;
-}
-
 /**
  * trans_create_rdma - Transport method for creating atransport instance
  * @client: client instance
index 37702491abe98eedd91738408851c56d3a8ea3a5..ee0213667272cc8eb5425af16921c69bee385311 100644 (file)
@@ -244,7 +244,7 @@ config NETPRIO_CGROUP
          Cgroup subsystem for use in assigning processes to network priorities on
          a per-interface basis
 
-config NET_LL_RX_POLL
+config NET_RX_BUSY_POLL
        boolean
        default y
 
@@ -281,7 +281,7 @@ menu "Network testing"
 
 config NET_PKTGEN
        tristate "Packet Generator (USE WITH CAUTION)"
-       depends on PROC_FS
+       depends on INET && PROC_FS
        ---help---
          This module will inject preconfigured packets, at a configurable
          rate, out of a given interface.  It is used for network interface
index c30f3a0717fb8a609239cd8578416eac63c61dd5..af46bc49e1e9946ce1ff4ff0fc772ce14a231670 100644 (file)
@@ -178,7 +178,7 @@ static int atalk_seq_socket_show(struct seq_file *seq, void *v)
        at = at_sk(s);
 
        seq_printf(seq, "%02X   %04X:%02X:%02X  %04X:%02X:%02X  %08X:%08X "
-                       "%02X %d\n",
+                       "%02X %u\n",
                   s->sk_type, ntohs(at->src_net), at->src_node, at->src_port,
                   ntohs(at->dest_net), at->dest_node, at->dest_port,
                   sk_wmem_alloc_get(s),
index 62da5278014a77e1e8a60902541b1999b2f85964..0a8a80cd4bf19819f797169a9b5c6122f3dc47b3 100644 (file)
 #include "bat_algo.h"
 #include "network-coding.h"
 
+
+/**
+ * batadv_dup_status - duplicate status
+ * @BATADV_NO_DUP: the packet is a duplicate
+ * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
+ *  neighbor)
+ * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
+ * @BATADV_PROTECTED: originator is currently protected (after reboot)
+ */
+enum batadv_dup_status {
+       BATADV_NO_DUP = 0,
+       BATADV_ORIG_DUP,
+       BATADV_NEIGH_DUP,
+       BATADV_PROTECTED,
+};
+
 /**
  * batadv_ring_buffer_set - update the ring buffer with the given value
  * @lq_recv: pointer to the ring buffer
@@ -71,21 +87,6 @@ static uint8_t batadv_ring_buffer_avg(const uint8_t lq_recv[])
        return (uint8_t)(sum / count);
 }
 
-/*
- * batadv_dup_status - duplicate status
- * @BATADV_NO_DUP: the packet is a duplicate
- * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
- *  neighbor)
- * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
- * @BATADV_PROTECTED: originator is currently protected (after reboot)
- */
-enum batadv_dup_status {
-       BATADV_NO_DUP = 0,
-       BATADV_ORIG_DUP,
-       BATADV_NEIGH_DUP,
-       BATADV_PROTECTED,
-};
-
 static struct batadv_neigh_node *
 batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
                        const uint8_t *neigh_addr,
@@ -478,6 +479,7 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
                kfree(forw_packet_aggr);
                goto out;
        }
+       forw_packet_aggr->skb->priority = TC_PRIO_CONTROL;
        skb_reserve(forw_packet_aggr->skb, ETH_HLEN);
 
        skb_buff = skb_put(forw_packet_aggr->skb, packet_len);
index e14531f1ce1c5258ccc816f9a739ed464b6c364f..264de88db3208290b940cc27b09e44f79e1616c9 100644 (file)
@@ -1529,6 +1529,8 @@ out:
  * in these cases, the skb is further handled by this function and
  * returns 1, otherwise it returns 0 and the caller shall further
  * process the skb.
+ *
+ * This call might reallocate skb data.
  */
 int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
                  unsigned short vid)
index f105219f4a4b120810973e0ae8cb31a8c4e2aca1..1ce4b8763ef289f3679177c5a1fdc96df6e6126f 100644 (file)
@@ -190,6 +190,33 @@ next:
        return curr_gw;
 }
 
+/**
+ * batadv_gw_check_client_stop - check if client mode has been switched off
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * This function assumes the caller has checked that the gw state *is actually
+ * changing*. This function is not supposed to be called when there is no state
+ * change.
+ */
+void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
+{
+       struct batadv_gw_node *curr_gw;
+
+       if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT)
+               return;
+
+       curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
+       if (!curr_gw)
+               return;
+
+       /* if batman-adv is switching the gw client mode off and a gateway was
+        * already selected, send a DEL uevent
+        */
+       batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL);
+
+       batadv_gw_node_free_ref(curr_gw);
+}
+
 void batadv_gw_election(struct batadv_priv *bat_priv)
 {
        struct batadv_gw_node *curr_gw = NULL, *next_gw = NULL;
@@ -508,6 +535,7 @@ out:
        return 0;
 }
 
+/* this call might reallocate skb data */
 static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
 {
        int ret = false;
@@ -568,6 +596,7 @@ out:
        return ret;
 }
 
+/* this call might reallocate skb data */
 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
 {
        struct ethhdr *ethhdr;
@@ -619,6 +648,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
 
        if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
                return false;
+
+       /* skb->data might have been reallocated by pskb_may_pull() */
+       ethhdr = (struct ethhdr *)skb->data;
+       if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
+               ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN);
+
        udphdr = (struct udphdr *)(skb->data + *header_len);
        *header_len += sizeof(*udphdr);
 
@@ -634,12 +669,14 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
        return true;
 }
 
+/* this call might reallocate skb data */
 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
-                           struct sk_buff *skb, struct ethhdr *ethhdr)
+                           struct sk_buff *skb)
 {
        struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
        struct batadv_orig_node *orig_dst_node = NULL;
        struct batadv_gw_node *curr_gw = NULL;
+       struct ethhdr *ethhdr;
        bool ret, out_of_range = false;
        unsigned int header_len = 0;
        uint8_t curr_tq_avg;
@@ -648,6 +685,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
        if (!ret)
                goto out;
 
+       ethhdr = (struct ethhdr *)skb->data;
        orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
                                                 ethhdr->h_dest);
        if (!orig_dst_node)
index 039902dca4a691074856d7846c59ad89f0bd8b8e..ceef4ebe8bcd6a89711000c0d52b20e536c5375a 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
 #define _NET_BATMAN_ADV_GATEWAY_CLIENT_H_
 
+void batadv_gw_check_client_stop(struct batadv_priv *bat_priv);
 void batadv_gw_deselect(struct batadv_priv *bat_priv);
 void batadv_gw_election(struct batadv_priv *bat_priv);
 struct batadv_orig_node *
@@ -34,7 +35,6 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
 void batadv_gw_node_purge(struct batadv_priv *bat_priv);
 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
-bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
-                           struct sk_buff *skb, struct ethhdr *ethhdr);
+bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
 
 #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
index b27508b8085cd84727bf89c434b0b56adcdcd87f..5a99bb4b6b823c8d2b042aec32cb2ff70ee3a8b9 100644 (file)
@@ -183,6 +183,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
                goto out;
        }
 
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(skb, ETH_HLEN);
        icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len);
 
index 08125f3f6064ddf42e63c872a43b8f2e68a9f941..c72d1bcdcf4906a1a23808cab2a464804a3fcda6 100644 (file)
 
 #include <linux/crc32c.h>
 #include <linux/highmem.h>
+#include <linux/if_vlan.h>
+#include <net/ip.h>
+#include <net/ipv6.h>
+#include <net/dsfield.h>
 #include "main.h"
 #include "sysfs.h"
 #include "debugfs.h"
@@ -249,6 +253,60 @@ out:
        return primary_if;
 }
 
+/**
+ * batadv_skb_set_priority - sets skb priority according to packet content
+ * @skb: the packet to be sent
+ * @offset: offset to the packet content
+ *
+ * This function sets a value between 256 and 263 (802.1d priority), which
+ * can be interpreted by the cfg80211 or other drivers.
+ */
+void batadv_skb_set_priority(struct sk_buff *skb, int offset)
+{
+       struct iphdr ip_hdr_tmp, *ip_hdr;
+       struct ipv6hdr ip6_hdr_tmp, *ip6_hdr;
+       struct ethhdr ethhdr_tmp, *ethhdr;
+       struct vlan_ethhdr *vhdr, vhdr_tmp;
+       u32 prio;
+
+       /* already set, do nothing */
+       if (skb->priority >= 256 && skb->priority <= 263)
+               return;
+
+       ethhdr = skb_header_pointer(skb, offset, sizeof(*ethhdr), &ethhdr_tmp);
+       if (!ethhdr)
+               return;
+
+       switch (ethhdr->h_proto) {
+       case htons(ETH_P_8021Q):
+               vhdr = skb_header_pointer(skb, offset + sizeof(*vhdr),
+                                         sizeof(*vhdr), &vhdr_tmp);
+               if (!vhdr)
+                       return;
+               prio = ntohs(vhdr->h_vlan_TCI) & VLAN_PRIO_MASK;
+               prio = prio >> VLAN_PRIO_SHIFT;
+               break;
+       case htons(ETH_P_IP):
+               ip_hdr = skb_header_pointer(skb, offset + sizeof(*ethhdr),
+                                           sizeof(*ip_hdr), &ip_hdr_tmp);
+               if (!ip_hdr)
+                       return;
+               prio = (ipv4_get_dsfield(ip_hdr) & 0xfc) >> 5;
+               break;
+       case htons(ETH_P_IPV6):
+               ip6_hdr = skb_header_pointer(skb, offset + sizeof(*ethhdr),
+                                            sizeof(*ip6_hdr), &ip6_hdr_tmp);
+               if (!ip6_hdr)
+                       return;
+               prio = (ipv6_get_dsfield(ip6_hdr) & 0xfc) >> 5;
+               break;
+       default:
+               return;
+       }
+
+       skb->priority = prio + 256;
+}
+
 static int batadv_recv_unhandled_packet(struct sk_buff *skb,
                                        struct batadv_hard_iface *recv_if)
 {
index 5e9aebb7d56b5c117ebc80a893145a1cb9b975ab..5d00f23b462158804e6d7d14b5c39a47030023df 100644 (file)
@@ -26,7 +26,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2013.3.0"
+#define BATADV_SOURCE_VERSION "2013.4.0"
 #endif
 
 /* B.A.T.M.A.N. parameters */
@@ -184,6 +184,7 @@ void batadv_mesh_free(struct net_device *soft_iface);
 int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr);
 struct batadv_hard_iface *
 batadv_seq_print_text_primary_if_get(struct seq_file *seq);
+void batadv_skb_set_priority(struct sk_buff *skb, int offset);
 int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
                           struct packet_type *ptype,
                           struct net_device *orig_dev);
index 2f0bd3ffe6e8588cb1bf3f75d1dbc3d6b427f331..0439395d7ba5f3f11eea51ebc53e9760ff175111 100644 (file)
@@ -775,7 +775,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
        struct batadv_neigh_node *neigh_node = NULL;
        struct batadv_unicast_packet *unicast_packet;
        struct ethhdr *ethhdr = eth_hdr(skb);
-       int res, ret = NET_RX_DROP;
+       int res, hdr_len, ret = NET_RX_DROP;
        struct sk_buff *new_skb;
 
        unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@ -835,6 +835,22 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
        /* decrement ttl */
        unicast_packet->header.ttl--;
 
+       switch (unicast_packet->header.packet_type) {
+       case BATADV_UNICAST_4ADDR:
+               hdr_len = sizeof(struct batadv_unicast_4addr_packet);
+               break;
+       case BATADV_UNICAST:
+               hdr_len = sizeof(struct batadv_unicast_packet);
+               break;
+       default:
+               /* other packet types not supported - yet */
+               hdr_len = -1;
+               break;
+       }
+
+       if (hdr_len > 0)
+               batadv_skb_set_priority(skb, hdr_len);
+
        res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
 
        /* translate transmit result into receive result */
@@ -1193,6 +1209,8 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
        if (batadv_bla_check_bcast_duplist(bat_priv, skb))
                goto out;
 
+       batadv_skb_set_priority(skb, sizeof(struct batadv_bcast_packet));
+
        /* rebroadcast packet */
        batadv_add_bcast_packet_to_list(bat_priv, skb, 1);
 
index e9ff8d801201279eaf91f347c730dbdd9e17f13d..0266edd0fa7f7acb0be56f896de95ba7775108f6 100644 (file)
@@ -67,7 +67,6 @@ int batadv_send_skb_packet(struct sk_buff *skb,
        ethhdr->h_proto = __constant_htons(ETH_P_BATMAN);
 
        skb_set_network_header(skb, ETH_HLEN);
-       skb->priority = TC_PRIO_CONTROL;
        skb->protocol = __constant_htons(ETH_P_BATMAN);
 
        skb->dev = hard_iface->net_dev;
index 700d0b49742da54d0a1280b84c87416977d7d721..4493913f0d5c973446e0597b38f9dda2269d3c48 100644 (file)
@@ -180,6 +180,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
        if (batadv_bla_tx(bat_priv, skb, vid))
                goto dropped;
 
+       /* skb->data might have been reallocated by batadv_bla_tx() */
+       ethhdr = (struct ethhdr *)skb->data;
+
        /* Register the client MAC in the transtable */
        if (!is_multicast_ether_addr(ethhdr->h_source))
                batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
@@ -220,8 +223,14 @@ static int batadv_interface_tx(struct sk_buff *skb,
                default:
                        break;
                }
+
+               /* reminder: ethhdr might have become unusable from here on
+                * (batadv_gw_is_dhcp_target() might have reallocated skb data)
+                */
        }
 
+       batadv_skb_set_priority(skb, 0);
+
        /* ethernet packet should be broadcasted */
        if (do_bcast) {
                primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -266,7 +275,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
        /* unicast packet */
        } else {
                if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) {
-                       ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
+                       ret = batadv_gw_out_of_range(bat_priv, skb);
                        if (ret)
                                goto dropped;
                }
index 929e304dacb254c333dd3dfbb94ba8de832153c6..4114b961bc2c8400acc6bd776e2732313674b0e4 100644 (file)
@@ -385,6 +385,10 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
                    curr_gw_mode_str, buff);
 
        batadv_gw_deselect(bat_priv);
+       /* always call batadv_gw_check_client_stop() before changing the gateway
+        * state
+        */
+       batadv_gw_check_client_stop(bat_priv);
        atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
        return count;
 }
index 429aeef3d8b2d98e86e5e0772496d6796dc86798..34510f38708fbd192ac5be8d4911e456c5d8ab50 100644 (file)
@@ -1626,6 +1626,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
        if (!skb)
                goto out;
 
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(skb, ETH_HLEN);
        tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len);
        tt_response->ttvn = ttvn;
@@ -1691,6 +1692,7 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
        if (!skb)
                goto out;
 
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(skb, ETH_HLEN);
 
        tt_req_len = sizeof(*tt_request);
@@ -1788,6 +1790,7 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv,
                if (!skb)
                        goto unlock;
 
+               skb->priority = TC_PRIO_CONTROL;
                skb_reserve(skb, ETH_HLEN);
                packet_pos = skb_put(skb, len);
                tt_response = (struct batadv_tt_query_packet *)packet_pos;
@@ -1906,6 +1909,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv,
                if (!skb)
                        goto unlock;
 
+               skb->priority = TC_PRIO_CONTROL;
                skb_reserve(skb, ETH_HLEN);
                packet_pos = skb_put(skb, len);
                tt_response = (struct batadv_tt_query_packet *)packet_pos;
@@ -2240,6 +2244,7 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
        if (!skb)
                goto out;
 
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(skb, ETH_HLEN);
 
        roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len);
index dc8b5d4dd636d3d5ed982a5d93c2783f203ac4f5..48b31d33ce6bb58f6757f6e7f69da6260bf68c57 100644 (file)
@@ -242,6 +242,8 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
        frag_skb = dev_alloc_skb(data_len - (data_len / 2) + ucf_hdr_len);
        if (!frag_skb)
                goto dropped;
+
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(frag_skb, ucf_hdr_len);
 
        unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@ -326,7 +328,9 @@ static bool batadv_unicast_push_and_fill_skb(struct sk_buff *skb, int hdr_size,
  * @skb: the skb containing the payload to encapsulate
  * @orig_node: the destination node
  *
- * Returns false if the payload could not be encapsulated or true otherwise
+ * Returns false if the payload could not be encapsulated or true otherwise.
+ *
+ * This call might reallocate skb data.
  */
 static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
                                       struct batadv_orig_node *orig_node)
@@ -343,7 +347,9 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
  * @orig_node: the destination node
  * @packet_subtype: the batman 4addr packet subtype to use
  *
- * Returns false if the payload could not be encapsulated or true otherwise
+ * Returns false if the payload could not be encapsulated or true otherwise.
+ *
+ * This call might reallocate skb data.
  */
 bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv,
                                      struct sk_buff *skb,
@@ -401,7 +407,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv,
        struct batadv_neigh_node *neigh_node;
        int data_len = skb->len;
        int ret = NET_RX_DROP;
-       unsigned int dev_mtu;
+       unsigned int dev_mtu, header_len;
 
        /* get routing information */
        if (is_multicast_ether_addr(ethhdr->h_dest)) {
@@ -428,11 +434,17 @@ find_router:
 
        switch (packet_type) {
        case BATADV_UNICAST:
-               batadv_unicast_prepare_skb(skb, orig_node);
+               if (!batadv_unicast_prepare_skb(skb, orig_node))
+                       goto out;
+
+               header_len = sizeof(struct batadv_unicast_packet);
                break;
        case BATADV_UNICAST_4ADDR:
-               batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
-                                                packet_subtype);
+               if (!batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
+                                                     packet_subtype))
+                       goto out;
+
+               header_len = sizeof(struct batadv_unicast_4addr_packet);
                break;
        default:
                /* this function supports UNICAST and UNICAST_4ADDR only. It
@@ -441,6 +453,7 @@ find_router:
                goto out;
        }
 
+       ethhdr = (struct ethhdr *)(skb->data + header_len);
        unicast_packet = (struct batadv_unicast_packet *)skb->data;
 
        /* inform the destination node that we are still missing a correct route
index 4983340f1943c5a0cc491785bf835981e7c44a1a..d8ea31a58457c1cc58d7ff753b8101d3ca0b7320 100644 (file)
@@ -397,6 +397,7 @@ batadv_add_packet(struct batadv_priv *bat_priv,
                kfree(info);
                return NULL;
        }
+       info->skb_packet->priority = TC_PRIO_CONTROL;
        skb_reserve(info->skb_packet, ETH_HLEN);
        packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len);
 
@@ -861,6 +862,7 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
        if (!bat_priv->vis.my_info->skb_packet)
                goto free_info;
 
+       bat_priv->vis.my_info->skb_packet->priority = TC_PRIO_CONTROL;
        skb_reserve(bat_priv->vis.my_info->skb_packet, ETH_HLEN);
        tmp_skb = bat_priv->vis.my_info->skb_packet;
        packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet));
index 2ef66781fedb3a9211448fa3db73eedab2c7d8a2..0feaaa0d37d11979999a898fe297f0e31397c07b 100644 (file)
@@ -70,7 +70,8 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
                }
 
                mdst = br_mdb_get(br, skb, vid);
-               if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb))
+               if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) &&
+                   br_multicast_querier_exists(br))
                        br_multicast_deliver(mdst, skb);
                else
                        br_flood_deliver(br, skb, false);
@@ -244,22 +245,22 @@ fail:
 int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp)
 {
        struct netpoll *np;
-       int err = 0;
+       int err;
+
+       if (!p->br->dev->npinfo)
+               return 0;
 
        np = kzalloc(sizeof(*p->np), gfp);
-       err = -ENOMEM;
        if (!np)
-               goto out;
+               return -ENOMEM;
 
        err = __netpoll_setup(np, p->dev, gfp);
        if (err) {
                kfree(np);
-               goto out;
+               return err;
        }
 
        p->np = np;
-
-out:
        return err;
 }
 
index 60aca9109a508d5a75c5b34befbdca8c7364fe52..ffd5874f25920a94c74f5d97ebf4a0e2aa77f48d 100644 (file)
@@ -161,7 +161,7 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
        if (!pv)
                return;
 
-       for_each_set_bit_from(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
+       for_each_set_bit_from(vid, pv->vlan_bitmap, VLAN_N_VID) {
                f = __br_fdb_get(br, br->dev->dev_addr, vid);
                if (f && f->is_local && !f->dst)
                        fdb_delete(br, f);
@@ -730,7 +730,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
                /* VID was specified, so use it. */
                err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
        } else {
-               if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) {
+               if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID)) {
                        err = __br_fdb_add(ndm, p, addr, nlh_flags, 0);
                        goto out;
                }
@@ -739,7 +739,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
                 * specify a VLAN.  To be nice, add/update entry for every
                 * vlan on this port.
                 */
-               for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
+               for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
                        err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
                        if (err)
                                goto out;
@@ -817,7 +817,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 
                err = __br_fdb_delete(p, addr, vid);
        } else {
-               if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) {
+               if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID)) {
                        err = __br_fdb_delete(p, addr, 0);
                        goto out;
                }
@@ -827,7 +827,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
                 * vlan on this port.
                 */
                err = -ENOENT;
-               for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
+               for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
                        err &= __br_fdb_delete(p, addr, vid);
                }
        }
index 5623be6b9ecda3f77d62cb2db7fc5e9aef2bd65c..aa6c9a8ba32a8df827e0749c6c4f870f6c3f2362 100644 (file)
@@ -363,7 +363,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
        if (err)
                goto err2;
 
-       if (br_netpoll_info(br) && ((err = br_netpoll_enable(p, GFP_KERNEL))))
+       err = br_netpoll_enable(p, GFP_KERNEL);
+       if (err)
                goto err3;
 
        err = netdev_master_upper_dev_link(dev, br->dev);
index 1b8b8b824cd766b05665e1d89f0e1394abdfbe2f..8c561c0aa636e49615b13e267c98e4e5bdce1a23 100644 (file)
@@ -101,7 +101,8 @@ int br_handle_frame_finish(struct sk_buff *skb)
                unicast = false;
        } else if (is_multicast_ether_addr(dest)) {
                mdst = br_mdb_get(br, skb, vid);
-               if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) {
+               if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) &&
+                   br_multicast_querier_exists(br)) {
                        if ((mdst && mdst->mglist) ||
                            br_multicast_is_router(br))
                                skb2 = skb;
index 0daae3ec2355543bce3600001db5fd32cf6d6ff7..e4d5cd43b7fbd2596ab9c785e91273ba64626f97 100644 (file)
@@ -61,7 +61,8 @@ static int br_mdb_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
 
        for (i = 0; i < mdb->max; i++) {
                struct net_bridge_mdb_entry *mp;
-               struct net_bridge_port_group *p, **pp;
+               struct net_bridge_port_group *p;
+               struct net_bridge_port_group __rcu **pp;
                struct net_bridge_port *port;
 
                hlist_for_each_entry_rcu(mp, &mdb->mhash[i], hlist[mdb->ver]) {
index 69af490cce4437bdc107f8b5b1216780b4c126af..08e576ada0b2699922b85c9e2783773baee404dc 100644 (file)
@@ -619,6 +619,9 @@ rehash:
        mp->br = br;
        mp->addr = *group;
 
+       setup_timer(&mp->timer, br_multicast_group_expired,
+                   (unsigned long)mp);
+
        hlist_add_head_rcu(&mp->hlist[mdb->ver], &mdb->mhash[hash]);
        mdb->size++;
 
@@ -1011,6 +1014,16 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,
 }
 #endif
 
+static void br_multicast_update_querier_timer(struct net_bridge *br,
+                                             unsigned long max_delay)
+{
+       if (!timer_pending(&br->multicast_querier_timer))
+               br->multicast_querier_delay_time = jiffies + max_delay;
+
+       mod_timer(&br->multicast_querier_timer,
+                 jiffies + br->multicast_querier_interval);
+}
+
 /*
  * Add port to router_list
  *  list is maintained ordered by pointer value
@@ -1061,11 +1074,11 @@ timer:
 
 static void br_multicast_query_received(struct net_bridge *br,
                                        struct net_bridge_port *port,
-                                       int saddr)
+                                       int saddr,
+                                       unsigned long max_delay)
 {
        if (saddr)
-               mod_timer(&br->multicast_querier_timer,
-                         jiffies + br->multicast_querier_interval);
+               br_multicast_update_querier_timer(br, max_delay);
        else if (timer_pending(&br->multicast_querier_timer))
                return;
 
@@ -1093,8 +1106,6 @@ static int br_ip4_multicast_query(struct net_bridge *br,
            (port && port->state == BR_STATE_DISABLED))
                goto out;
 
-       br_multicast_query_received(br, port, !!iph->saddr);
-
        group = ih->group;
 
        if (skb->len == sizeof(*ih)) {
@@ -1118,6 +1129,8 @@ static int br_ip4_multicast_query(struct net_bridge *br,
                            IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1;
        }
 
+       br_multicast_query_received(br, port, !!iph->saddr, max_delay);
+
        if (!group)
                goto out;
 
@@ -1126,7 +1139,6 @@ static int br_ip4_multicast_query(struct net_bridge *br,
        if (!mp)
                goto out;
 
-       setup_timer(&mp->timer, br_multicast_group_expired, (unsigned long)mp);
        mod_timer(&mp->timer, now + br->multicast_membership_interval);
        mp->timer_armed = true;
 
@@ -1174,8 +1186,6 @@ static int br_ip6_multicast_query(struct net_bridge *br,
            (port && port->state == BR_STATE_DISABLED))
                goto out;
 
-       br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr));
-
        if (skb->len == sizeof(*mld)) {
                if (!pskb_may_pull(skb, sizeof(*mld))) {
                        err = -EINVAL;
@@ -1185,7 +1195,7 @@ static int br_ip6_multicast_query(struct net_bridge *br,
                max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay));
                if (max_delay)
                        group = &mld->mld_mca;
-       } else if (skb->len >= sizeof(*mld2q)) {
+       } else {
                if (!pskb_may_pull(skb, sizeof(*mld2q))) {
                        err = -EINVAL;
                        goto out;
@@ -1196,6 +1206,9 @@ static int br_ip6_multicast_query(struct net_bridge *br,
                max_delay = mld2q->mld2q_mrc ? MLDV2_MRC(ntohs(mld2q->mld2q_mrc)) : 1;
        }
 
+       br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr),
+                                   max_delay);
+
        if (!group)
                goto out;
 
@@ -1204,7 +1217,6 @@ static int br_ip6_multicast_query(struct net_bridge *br,
        if (!mp)
                goto out;
 
-       setup_timer(&mp->timer, br_multicast_group_expired, (unsigned long)mp);
        mod_timer(&mp->timer, now + br->multicast_membership_interval);
        mp->timer_armed = true;
 
@@ -1642,6 +1654,8 @@ void br_multicast_init(struct net_bridge *br)
        br->multicast_querier_interval = 255 * HZ;
        br->multicast_membership_interval = 260 * HZ;
 
+       br->multicast_querier_delay_time = 0;
+
        spin_lock_init(&br->multicast_lock);
        setup_timer(&br->multicast_router_timer,
                    br_multicast_local_router_expired, 0);
@@ -1830,6 +1844,8 @@ unlock:
 
 int br_multicast_set_querier(struct net_bridge *br, unsigned long val)
 {
+       unsigned long max_delay;
+
        val = !!val;
 
        spin_lock_bh(&br->multicast_lock);
@@ -1837,8 +1853,14 @@ int br_multicast_set_querier(struct net_bridge *br, unsigned long val)
                goto unlock;
 
        br->multicast_querier = val;
-       if (val)
-               br_multicast_start_querier(br);
+       if (!val)
+               goto unlock;
+
+       max_delay = br->multicast_query_response_interval;
+       if (!timer_pending(&br->multicast_querier_timer))
+               br->multicast_querier_delay_time = jiffies + max_delay;
+
+       br_multicast_start_querier(br);
 
 unlock:
        spin_unlock_bh(&br->multicast_lock);
index 1fc30abd3a523912376ce01fcae932f3b6b8c746..b9259efa636ef8fe2b79ec25de49a16efa9034db 100644 (file)
@@ -132,7 +132,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
                else
                        pv = br_get_vlan_info(br);
 
-               if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN))
+               if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID))
                        goto done;
 
                af = nla_nest_start(skb, IFLA_AF_SPEC);
@@ -140,7 +140,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
                        goto nla_put_failure;
 
                pvid = br_get_pvid(pv);
-               for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
+               for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
                        vinfo.vid = vid;
                        vinfo.flags = 0;
                        if (vid == pvid)
index 3a3f371b28415c110e4db6a21069f9153dafe904..2998dd1769a055b244c21a4fb9d9579b04099222 100644 (file)
@@ -102,6 +102,11 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
        case NETDEV_PRE_TYPE_CHANGE:
                /* Forbid underlaying device to change its type. */
                return NOTIFY_BAD;
+
+       case NETDEV_RESEND_IGMP:
+               /* Propagate to master device */
+               call_netdevice_notifiers(event, br->dev);
+               break;
        }
 
        /* Events that may cause spanning tree to refresh */
index 3be89b3ce17b5a314215609790cadec6e5453727..d41283c57952104c57f0eb674e7c6294599b32dc 100644 (file)
@@ -267,6 +267,7 @@ struct net_bridge
        unsigned long                   multicast_query_interval;
        unsigned long                   multicast_query_response_interval;
        unsigned long                   multicast_startup_query_interval;
+       unsigned long                   multicast_querier_delay_time;
 
        spinlock_t                      multicast_lock;
        struct net_bridge_mdb_htable __rcu *mdb;
@@ -333,11 +334,6 @@ extern void br_dev_delete(struct net_device *dev, struct list_head *list);
 extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
                               struct net_device *dev);
 #ifdef CONFIG_NET_POLL_CONTROLLER
-static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
-{
-       return br->dev->npinfo;
-}
-
 static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
                                       struct sk_buff *skb)
 {
@@ -350,11 +346,6 @@ static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
 extern int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp);
 extern void br_netpoll_disable(struct net_bridge_port *p);
 #else
-static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
-{
-       return NULL;
-}
-
 static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
                                       struct sk_buff *skb)
 {
@@ -475,7 +466,7 @@ extern void br_multicast_free_pg(struct rcu_head *head);
 extern struct net_bridge_port_group *br_multicast_new_port_group(
                                struct net_bridge_port *port,
                                struct br_ip *group,
-                               struct net_bridge_port_group *next,
+                               struct net_bridge_port_group __rcu *next,
                                unsigned char state);
 extern void br_mdb_init(void);
 extern void br_mdb_uninit(void);
@@ -501,6 +492,13 @@ static inline bool br_multicast_is_router(struct net_bridge *br)
               (br->multicast_router == 1 &&
                timer_pending(&br->multicast_router_timer));
 }
+
+static inline bool br_multicast_querier_exists(struct net_bridge *br)
+{
+       return time_is_before_jiffies(br->multicast_querier_delay_time) &&
+              (br->multicast_querier ||
+               timer_pending(&br->multicast_querier_timer));
+}
 #else
 static inline int br_multicast_rcv(struct net_bridge *br,
                                   struct net_bridge_port *port,
@@ -557,6 +555,10 @@ static inline bool br_multicast_is_router(struct net_bridge *br)
 {
        return 0;
 }
+static inline bool br_multicast_querier_exists(struct net_bridge *br)
+{
+       return false;
+}
 static inline void br_mdb_init(void)
 {
 }
index 394bb96b608707aa1ab943f66bc52fa173859706..3b9637fb7939a146e8a172a1e009e84c6ca4e841 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *     Sysfs attributes of bridge ports
+ *     Sysfs attributes of bridge
  *     Linux ethernet bridge
  *
  *     Authors:
index bd58b45f5f901fd4c6a3ad00abe068baeba8d898..9a9ffe7e4019741d75456e3b9afdba21c44785b3 100644 (file)
@@ -108,7 +108,7 @@ static int __vlan_del(struct net_port_vlans *v, u16 vid)
 
        clear_bit(vid, v->vlan_bitmap);
        v->num_vlans--;
-       if (bitmap_empty(v->vlan_bitmap, BR_VLAN_BITMAP_LEN)) {
+       if (bitmap_empty(v->vlan_bitmap, VLAN_N_VID)) {
                if (v->port_idx)
                        rcu_assign_pointer(v->parent.port->vlan_info, NULL);
                else
@@ -122,7 +122,7 @@ static void __vlan_flush(struct net_port_vlans *v)
 {
        smp_wmb();
        v->pvid = 0;
-       bitmap_zero(v->vlan_bitmap, BR_VLAN_BITMAP_LEN);
+       bitmap_zero(v->vlan_bitmap, VLAN_N_VID);
        if (v->port_idx)
                rcu_assign_pointer(v->parent.port->vlan_info, NULL);
        else
index eb0a46a49bd42351d23878f118384ab09a8d2ee8..3be308e143026ac3d831e4aefc13faa198400d21 100644 (file)
@@ -409,7 +409,7 @@ static void ceph_sock_write_space(struct sock *sk)
         * and net/core/stream.c:sk_stream_write_space().
         */
        if (con_flag_test(con, CON_FLAG_WRITE_PENDING)) {
-               if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+               if (sk_stream_is_writeable(sk)) {
                        dout("%s %p queueing write work\n", __func__, con);
                        clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
                        queue_con(con);
index 8ab48cd8955971ec7db7e60464a946380a7be49a..af814e764206f6d4221b91f03dc2e3bfa1da05f2 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/highmem.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
+#include <linux/pagemap.h>
 
 #include <net/protocol.h>
 #include <linux/skbuff.h>
@@ -573,6 +574,77 @@ fault:
 }
 EXPORT_SYMBOL(skb_copy_datagram_from_iovec);
 
+/**
+ *     zerocopy_sg_from_iovec - Build a zerocopy datagram from an iovec
+ *     @skb: buffer to copy
+ *     @from: io vector to copy to
+ *     @offset: offset in the io vector to start copying from
+ *     @count: amount of vectors to copy to buffer from
+ *
+ *     The function will first copy up to headlen, and then pin the userspace
+ *     pages and build frags through them.
+ *
+ *     Returns 0, -EFAULT or -EMSGSIZE.
+ *     Note: the iovec is not modified during the copy
+ */
+int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
+                                 int offset, size_t count)
+{
+       int len = iov_length(from, count) - offset;
+       int copy = min_t(int, skb_headlen(skb), len);
+       int size;
+       int i = 0;
+
+       /* copy up to skb headlen */
+       if (skb_copy_datagram_from_iovec(skb, 0, from, offset, copy))
+               return -EFAULT;
+
+       if (len == copy)
+               return 0;
+
+       offset += copy;
+       while (count--) {
+               struct page *page[MAX_SKB_FRAGS];
+               int num_pages;
+               unsigned long base;
+               unsigned long truesize;
+
+               /* Skip over from offset and copied */
+               if (offset >= from->iov_len) {
+                       offset -= from->iov_len;
+                       ++from;
+                       continue;
+               }
+               len = from->iov_len - offset;
+               base = (unsigned long)from->iov_base + offset;
+               size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
+               if (i + size > MAX_SKB_FRAGS)
+                       return -EMSGSIZE;
+               num_pages = get_user_pages_fast(base, size, 0, &page[i]);
+               if (num_pages != size) {
+                       release_pages(&page[i], num_pages, 0);
+                       return -EFAULT;
+               }
+               truesize = size * PAGE_SIZE;
+               skb->data_len += len;
+               skb->len += len;
+               skb->truesize += truesize;
+               atomic_add(truesize, &skb->sk->sk_wmem_alloc);
+               while (len) {
+                       int off = base & ~PAGE_MASK;
+                       int size = min_t(int, len, PAGE_SIZE - off);
+                       skb_fill_page_desc(skb, i, page[i], off, size);
+                       base += size;
+                       len -= size;
+                       i++;
+               }
+               offset = 0;
+               ++from;
+       }
+       return 0;
+}
+EXPORT_SYMBOL(zerocopy_sg_from_iovec);
+
 static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
                                      u8 __user *to, int len,
                                      __wsum *csump)
index a3d8d44cb7f46dddc7e2b04772c97264e021a89f..1ed2b66a10a6009c219292b17b4046e3e970f15b 100644 (file)
@@ -174,7 +174,7 @@ static DEFINE_SPINLOCK(napi_hash_lock);
 static unsigned int napi_gen_id;
 static DEFINE_HASHTABLE(napi_hash, 8);
 
-seqcount_t devnet_rename_seq;
+static seqcount_t devnet_rename_seq;
 
 static inline void dev_base_seq_inc(struct net *net)
 {
@@ -1691,13 +1691,13 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
                kfree_skb(skb);
                return NET_RX_DROP;
        }
-       skb_scrub_packet(skb);
        skb->protocol = eth_type_trans(skb, dev);
 
        /* eth_type_trans() can set pkt_type.
-        * clear pkt_type _after_ calling eth_type_trans()
+        * call skb_scrub_packet() after it to clear pkt_type _after_ calling
+        * eth_type_trans().
         */
-       skb->pkt_type = PACKET_HOST;
+       skb_scrub_packet(skb);
 
        return netif_rx(skb);
 }
@@ -3580,8 +3580,15 @@ ncls:
                }
        }
 
-       if (vlan_tx_nonzero_tag_present(skb))
-               skb->pkt_type = PACKET_OTHERHOST;
+       if (unlikely(vlan_tx_tag_present(skb))) {
+               if (vlan_tx_tag_get_id(skb))
+                       skb->pkt_type = PACKET_OTHERHOST;
+               /* Note: we might in the future use prio bits
+                * and set skb->priority like in vlan_do_receive()
+                * For the time being, just ignore Priority Code Point
+                */
+               skb->vlan_tci = 0;
+       }
 
        /* deliver only exact match when indicated */
        null_or_dev = deliver_exact ? skb->dev : NULL;
@@ -4981,6 +4988,24 @@ int dev_change_carrier(struct net_device *dev, bool new_carrier)
 }
 EXPORT_SYMBOL(dev_change_carrier);
 
+/**
+ *     dev_get_phys_port_id - Get device physical port ID
+ *     @dev: device
+ *     @ppid: port ID
+ *
+ *     Get device physical port ID
+ */
+int dev_get_phys_port_id(struct net_device *dev,
+                        struct netdev_phys_port_id *ppid)
+{
+       const struct net_device_ops *ops = dev->netdev_ops;
+
+       if (!ops->ndo_get_phys_port_id)
+               return -EOPNOTSUPP;
+       return ops->ndo_get_phys_port_id(dev, ppid);
+}
+EXPORT_SYMBOL(dev_get_phys_port_id);
+
 /**
  *     dev_new_index   -       allocate an ifindex
  *     @net: the applicable net namespace
index ab5fa6336c840785b93c6f469b441d6fcdec1379..78e9d9223e40dfe5bc9956170619e0a8e3335e9d 100644 (file)
@@ -279,11 +279,16 @@ static u32 __ethtool_get_flags(struct net_device *dev)
 {
        u32 flags = 0;
 
-       if (dev->features & NETIF_F_LRO)             flags |= ETH_FLAG_LRO;
-       if (dev->features & NETIF_F_HW_VLAN_CTAG_RX) flags |= ETH_FLAG_RXVLAN;
-       if (dev->features & NETIF_F_HW_VLAN_CTAG_TX) flags |= ETH_FLAG_TXVLAN;
-       if (dev->features & NETIF_F_NTUPLE)          flags |= ETH_FLAG_NTUPLE;
-       if (dev->features & NETIF_F_RXHASH)          flags |= ETH_FLAG_RXHASH;
+       if (dev->features & NETIF_F_LRO)
+               flags |= ETH_FLAG_LRO;
+       if (dev->features & NETIF_F_HW_VLAN_CTAG_RX)
+               flags |= ETH_FLAG_RXVLAN;
+       if (dev->features & NETIF_F_HW_VLAN_CTAG_TX)
+               flags |= ETH_FLAG_TXVLAN;
+       if (dev->features & NETIF_F_NTUPLE)
+               flags |= ETH_FLAG_NTUPLE;
+       if (dev->features & NETIF_F_RXHASH)
+               flags |= ETH_FLAG_RXHASH;
 
        return flags;
 }
@@ -295,11 +300,16 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
        if (data & ~ETH_ALL_FLAGS)
                return -EINVAL;
 
-       if (data & ETH_FLAG_LRO)        features |= NETIF_F_LRO;
-       if (data & ETH_FLAG_RXVLAN)     features |= NETIF_F_HW_VLAN_CTAG_RX;
-       if (data & ETH_FLAG_TXVLAN)     features |= NETIF_F_HW_VLAN_CTAG_TX;
-       if (data & ETH_FLAG_NTUPLE)     features |= NETIF_F_NTUPLE;
-       if (data & ETH_FLAG_RXHASH)     features |= NETIF_F_RXHASH;
+       if (data & ETH_FLAG_LRO)
+               features |= NETIF_F_LRO;
+       if (data & ETH_FLAG_RXVLAN)
+               features |= NETIF_F_HW_VLAN_CTAG_RX;
+       if (data & ETH_FLAG_TXVLAN)
+               features |= NETIF_F_HW_VLAN_CTAG_TX;
+       if (data & ETH_FLAG_NTUPLE)
+               features |= NETIF_F_NTUPLE;
+       if (data & ETH_FLAG_RXHASH)
+               features |= NETIF_F_RXHASH;
 
        /* allow changing only bits set in hw_features */
        changed = (features ^ dev->features) & ETH_ALL_FEATURES;
index 21735440c44a85b611308e6b3c97bef77452c9a1..2e654138433c0521cee0b07992e6aa7535e970b0 100644 (file)
@@ -33,6 +33,9 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
        r->flags = flags;
        r->fr_net = hold_net(ops->fro_net);
 
+       r->suppress_prefixlen = -1;
+       r->suppress_ifgroup = -1;
+
        /* The lock is not required here, the list in unreacheable
         * at the moment this function is called */
        list_add_tail(&r->list, &ops->rules_list);
@@ -226,6 +229,9 @@ jumped:
                else
                        err = ops->action(rule, fl, flags, arg);
 
+               if (!err && ops->suppress && ops->suppress(rule, arg))
+                       continue;
+
                if (err != -EAGAIN) {
                        if ((arg->flags & FIB_LOOKUP_NOREF) ||
                            likely(atomic_inc_not_zero(&rule->refcnt))) {
@@ -337,6 +343,15 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
        rule->action = frh->action;
        rule->flags = frh->flags;
        rule->table = frh_get_table(frh, tb);
+       if (tb[FRA_SUPPRESS_PREFIXLEN])
+               rule->suppress_prefixlen = nla_get_u32(tb[FRA_SUPPRESS_PREFIXLEN]);
+       else
+               rule->suppress_prefixlen = -1;
+
+       if (tb[FRA_SUPPRESS_IFGROUP])
+               rule->suppress_ifgroup = nla_get_u32(tb[FRA_SUPPRESS_IFGROUP]);
+       else
+               rule->suppress_ifgroup = -1;
 
        if (!tb[FRA_PRIORITY] && ops->default_pref)
                rule->pref = ops->default_pref(ops);
@@ -523,6 +538,8 @@ static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
                         + nla_total_size(IFNAMSIZ) /* FRA_OIFNAME */
                         + nla_total_size(4) /* FRA_PRIORITY */
                         + nla_total_size(4) /* FRA_TABLE */
+                        + nla_total_size(4) /* FRA_SUPPRESS_PREFIXLEN */
+                        + nla_total_size(4) /* FRA_SUPPRESS_IFGROUP */
                         + nla_total_size(4) /* FRA_FWMARK */
                         + nla_total_size(4); /* FRA_FWMASK */
 
@@ -548,6 +565,8 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
        frh->table = rule->table;
        if (nla_put_u32(skb, FRA_TABLE, rule->table))
                goto nla_put_failure;
+       if (nla_put_u32(skb, FRA_SUPPRESS_PREFIXLEN, rule->suppress_prefixlen))
+               goto nla_put_failure;
        frh->res1 = 0;
        frh->res2 = 0;
        frh->action = rule->action;
@@ -580,6 +599,12 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
            (rule->target &&
             nla_put_u32(skb, FRA_GOTO, rule->target)))
                goto nla_put_failure;
+
+       if (rule->suppress_ifgroup != -1) {
+               if (nla_put_u32(skb, FRA_SUPPRESS_IFGROUP, rule->suppress_ifgroup))
+                       goto nla_put_failure;
+       }
+
        if (ops->fill(rule, skb, frh) < 0)
                goto nla_put_failure;
 
index 7102f166482d326f4135556bb8000f75fadf8b21..dfa602ceb8cd846a2fdbbd24ac5367356ebb3906 100644 (file)
@@ -403,7 +403,7 @@ void flow_cache_flush_deferred(void)
        schedule_work(&flow_cache_flush_work);
 }
 
-static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
+static int flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
 {
        struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
        size_t sz = sizeof(struct hlist_head) * flow_cache_hash_size(fc);
@@ -421,7 +421,7 @@ static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
        return 0;
 }
 
-static int __cpuinit flow_cache_cpu(struct notifier_block *nfb,
+static int flow_cache_cpu(struct notifier_block *nfb,
                          unsigned long action,
                          void *hcpu)
 {
index 00ee068efc1c2374bc0195d9458eca00392359c6..159737cac76c3d180be308b64e5e37bf34cc51f0 100644 (file)
@@ -65,6 +65,7 @@ ipv6:
                nhoff += sizeof(struct ipv6hdr);
                break;
        }
+       case __constant_htons(ETH_P_8021AD):
        case __constant_htons(ETH_P_8021Q): {
                const struct vlan_hdr *vlan;
                struct vlan_hdr _vlan;
@@ -139,7 +140,11 @@ ipv6:
                break;
        }
        case IPPROTO_IPIP:
-               goto again;
+               proto = htons(ETH_P_IP);
+               goto ip;
+       case IPPROTO_IPV6:
+               proto = htons(ETH_P_IPV6);
+               goto ipv6;
        default:
                break;
        }
index de178e462682af6c97dbfc4326df85942ec25174..b77eeecc00115eefd2395648e71cb337ee53757a 100644 (file)
@@ -212,3 +212,27 @@ out_fault:
        goto out;
 }
 EXPORT_SYMBOL(csum_partial_copy_fromiovecend);
+
+unsigned long iov_pages(const struct iovec *iov, int offset,
+                       unsigned long nr_segs)
+{
+       unsigned long seg, base;
+       int pages = 0, len, size;
+
+       while (nr_segs && (offset >= iov->iov_len)) {
+               offset -= iov->iov_len;
+               ++iov;
+               --nr_segs;
+       }
+
+       for (seg = 0; seg < nr_segs; seg++) {
+               base = (unsigned long)iov[seg].iov_base + offset;
+               len = iov[seg].iov_len - offset;
+               size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
+               pages += size;
+               offset = 0;
+       }
+
+       return pages;
+}
+EXPORT_SYMBOL(iov_pages);
index b7de821f98df2875dd5c4c7b08f32b2f3d7f98a2..60533db8b72db4bafa73d336d697575ba3138c90 100644 (file)
@@ -1441,16 +1441,18 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
                atomic_set(&p->refcnt, 1);
                p->reachable_time =
                                neigh_rand_reach_time(p->base_reachable_time);
+               dev_hold(dev);
+               p->dev = dev;
+               write_pnet(&p->net, hold_net(net));
+               p->sysctl_table = NULL;
 
                if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
+                       release_net(net);
+                       dev_put(dev);
                        kfree(p);
                        return NULL;
                }
 
-               dev_hold(dev);
-               p->dev = dev;
-               write_pnet(&p->net, hold_net(net));
-               p->sysctl_table = NULL;
                write_lock_bh(&tbl->lock);
                p->next         = tbl->parms.next;
                tbl->parms.next = p;
@@ -2767,6 +2769,7 @@ EXPORT_SYMBOL(neigh_app_ns);
 
 #ifdef CONFIG_SYSCTL
 static int zero;
+static int int_max = INT_MAX;
 static int unres_qlen_max = INT_MAX / SKB_TRUESIZE(ETH_FRAME_LEN);
 
 static int proc_unres_qlen(struct ctl_table *ctl, int write,
@@ -2819,19 +2822,25 @@ static struct neigh_sysctl_table {
                        .procname       = "mcast_solicit",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                [NEIGH_VAR_UCAST_PROBE] = {
                        .procname       = "ucast_solicit",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                [NEIGH_VAR_APP_PROBE] = {
                        .procname       = "app_solicit",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                [NEIGH_VAR_RETRANS_TIME] = {
                        .procname       = "retrans_time",
@@ -2874,7 +2883,9 @@ static struct neigh_sysctl_table {
                        .procname       = "proxy_qlen",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                [NEIGH_VAR_ANYCAST_DELAY] = {
                        .procname       = "anycast_delay",
@@ -2916,19 +2927,25 @@ static struct neigh_sysctl_table {
                        .procname       = "gc_thresh1",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                [NEIGH_VAR_GC_THRESH2] = {
                        .procname       = "gc_thresh2",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                [NEIGH_VAR_GC_THRESH3] = {
                        .procname       = "gc_thresh3",
                        .maxlen         = sizeof(int),
                        .mode           = 0644,
-                       .proc_handler   = proc_dointvec,
+                       .extra1         = &zero,
+                       .extra2         = &int_max,
+                       .proc_handler   = proc_dointvec_minmax,
                },
                {},
        },
index 981fed397d1d8af3b0d607a1ac260ad0cc847ade..8826b0d1e0cc4f6d9db1ebf7d7c54811432c008d 100644 (file)
@@ -334,6 +334,27 @@ static ssize_t store_group(struct device *dev, struct device_attribute *attr,
        return netdev_store(dev, attr, buf, len, change_group);
 }
 
+static ssize_t show_phys_port_id(struct device *dev,
+                                struct device_attribute *attr, char *buf)
+{
+       struct net_device *netdev = to_net_dev(dev);
+       ssize_t ret = -EINVAL;
+
+       if (!rtnl_trylock())
+               return restart_syscall();
+
+       if (dev_isalive(netdev)) {
+               struct netdev_phys_port_id ppid;
+
+               ret = dev_get_phys_port_id(netdev, &ppid);
+               if (!ret)
+                       ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
+       }
+       rtnl_unlock();
+
+       return ret;
+}
+
 static struct device_attribute net_class_attributes[] = {
        __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL),
        __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
@@ -355,6 +376,7 @@ static struct device_attribute net_class_attributes[] = {
        __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len,
               store_tx_queue_len),
        __ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group),
+       __ATTR(phys_port_id, S_IRUGO, show_phys_port_id, NULL),
        {}
 };
 
index 9640972ec50e5658eac7493fb0da180a0de353c9..261357a663001ccf98a92ba5f6d0f6ad141c7ce3 100644 (file)
 #include <net/net_namespace.h>
 #include <net/checksum.h>
 #include <net/ipv6.h>
+#include <net/udp.h>
+#include <net/ip6_checksum.h>
 #include <net/addrconf.h>
 #ifdef CONFIG_XFRM
 #include <net/xfrm.h>
 #define F_QUEUE_MAP_RND (1<<13)        /* queue map Random */
 #define F_QUEUE_MAP_CPU (1<<14)        /* queue map mirrors smp_processor_id() */
 #define F_NODE          (1<<15)        /* Node memory alloc*/
+#define F_UDPCSUM       (1<<16)        /* Include UDP checksum */
 
 /* Thread control flag bits */
 #define T_STOP        (1<<0)   /* Stop run */
@@ -631,6 +634,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
        if (pkt_dev->flags & F_UDPDST_RND)
                seq_printf(seq, "UDPDST_RND  ");
 
+       if (pkt_dev->flags & F_UDPCSUM)
+               seq_printf(seq, "UDPCSUM  ");
+
        if (pkt_dev->flags & F_MPLS_RND)
                seq_printf(seq,  "MPLS_RND  ");
 
@@ -1228,6 +1234,12 @@ static ssize_t pktgen_if_write(struct file *file,
                else if (strcmp(f, "!NODE_ALLOC") == 0)
                        pkt_dev->flags &= ~F_NODE;
 
+               else if (strcmp(f, "UDPCSUM") == 0)
+                       pkt_dev->flags |= F_UDPCSUM;
+
+               else if (strcmp(f, "!UDPCSUM") == 0)
+                       pkt_dev->flags &= ~F_UDPCSUM;
+
                else {
                        sprintf(pg_result,
                                "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
@@ -2733,7 +2745,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
        udph->source = htons(pkt_dev->cur_udp_src);
        udph->dest = htons(pkt_dev->cur_udp_dst);
        udph->len = htons(datalen + 8); /* DATA + udphdr */
-       udph->check = 0;        /* No checksum */
+       udph->check = 0;
 
        iph->ihl = 5;
        iph->version = 4;
@@ -2747,11 +2759,28 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
        iph->frag_off = 0;
        iplen = 20 + 8 + datalen;
        iph->tot_len = htons(iplen);
-       iph->check = 0;
-       iph->check = ip_fast_csum((void *)iph, iph->ihl);
+       ip_send_check(iph);
        skb->protocol = protocol;
        skb->dev = odev;
        skb->pkt_type = PACKET_HOST;
+
+       if (!(pkt_dev->flags & F_UDPCSUM)) {
+               skb->ip_summed = CHECKSUM_NONE;
+       } else if (odev->features & NETIF_F_V4_CSUM) {
+               skb->ip_summed = CHECKSUM_PARTIAL;
+               skb->csum = 0;
+               udp4_hwcsum(skb, udph->source, udph->dest);
+       } else {
+               __wsum csum = udp_csum(skb);
+
+               /* add protocol-dependent pseudo-header */
+               udph->check = csum_tcpudp_magic(udph->source, udph->dest,
+                                               datalen + 8, IPPROTO_UDP, csum);
+
+               if (udph->check == 0)
+                       udph->check = CSUM_MANGLED_0;
+       }
+
        pktgen_finalize_skb(pkt_dev, skb, datalen);
 
 #ifdef CONFIG_XFRM
@@ -2768,7 +2797,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
        struct sk_buff *skb = NULL;
        __u8 *eth;
        struct udphdr *udph;
-       int datalen;
+       int datalen, udplen;
        struct ipv6hdr *iph;
        __be16 protocol = htons(ETH_P_IPV6);
        __be32 *mpls;
@@ -2844,10 +2873,11 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
                net_info_ratelimited("increased datalen to %d\n", datalen);
        }
 
+       udplen = datalen + sizeof(struct udphdr);
        udph->source = htons(pkt_dev->cur_udp_src);
        udph->dest = htons(pkt_dev->cur_udp_dst);
-       udph->len = htons(datalen + sizeof(struct udphdr));
-       udph->check = 0;        /* No checksum */
+       udph->len = htons(udplen);
+       udph->check = 0;
 
        *(__be32 *) iph = htonl(0x60000000);    /* Version + flow */
 
@@ -2858,7 +2888,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
 
        iph->hop_limit = 32;
 
-       iph->payload_len = htons(sizeof(struct udphdr) + datalen);
+       iph->payload_len = htons(udplen);
        iph->nexthdr = IPPROTO_UDP;
 
        iph->daddr = pkt_dev->cur_in6_daddr;
@@ -2868,6 +2898,23 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
        skb->dev = odev;
        skb->pkt_type = PACKET_HOST;
 
+       if (!(pkt_dev->flags & F_UDPCSUM)) {
+               skb->ip_summed = CHECKSUM_NONE;
+       } else if (odev->features & NETIF_F_V6_CSUM) {
+               skb->ip_summed = CHECKSUM_PARTIAL;
+               skb->csum_start = skb_transport_header(skb) - skb->head;
+               skb->csum_offset = offsetof(struct udphdr, check);
+               udph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, udplen, IPPROTO_UDP, 0);
+       } else {
+               __wsum csum = udp_csum(skb);
+
+               /* add protocol-dependent pseudo-header */
+               udph->check = csum_ipv6_magic(&iph->saddr, &iph->daddr, udplen, IPPROTO_UDP, csum);
+
+               if (udph->check == 0)
+                       udph->check = CSUM_MANGLED_0;
+       }
+
        pktgen_finalize_skb(pkt_dev, skb, datalen);
 
        return skb;
index 3de740834d1ffcfa35fe31735b41d5a0dcb58c3a..2a0e21de3060cddbc9cd657acb24ee84b748c4d1 100644 (file)
@@ -767,7 +767,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
               + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
               + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
               + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
-              + rtnl_link_get_af_size(dev); /* IFLA_AF_SPEC */
+              + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
+              + nla_total_size(MAX_PHYS_PORT_ID_LEN); /* IFLA_PHYS_PORT_ID */
 }
 
 static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
@@ -846,6 +847,24 @@ static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev)
        return 0;
 }
 
+static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)
+{
+       int err;
+       struct netdev_phys_port_id ppid;
+
+       err = dev_get_phys_port_id(dev, &ppid);
+       if (err) {
+               if (err == -EOPNOTSUPP)
+                       return 0;
+               return err;
+       }
+
+       if (nla_put(skb, IFLA_PHYS_PORT_ID, ppid.id_len, ppid.id))
+               return -EMSGSIZE;
+
+       return 0;
+}
+
 static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
                            int type, u32 pid, u32 seq, u32 change,
                            unsigned int flags, u32 ext_filter_mask)
@@ -913,6 +932,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
                        goto nla_put_failure;
        }
 
+       if (rtnl_phys_port_id_fill(skb, dev))
+               goto nla_put_failure;
+
        attr = nla_reserve(skb, IFLA_STATS,
                        sizeof(struct rtnl_link_stats));
        if (attr == NULL)
@@ -1113,6 +1135,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
        [IFLA_PROMISCUITY]      = { .type = NLA_U32 },
        [IFLA_NUM_TX_QUEUES]    = { .type = NLA_U32 },
        [IFLA_NUM_RX_QUEUES]    = { .type = NLA_U32 },
+       [IFLA_PHYS_PORT_ID]     = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
 };
 EXPORT_SYMBOL(ifla_policy);
 
@@ -1844,10 +1867,10 @@ replay:
                else
                        err = register_netdevice(dev);
 
-               if (err < 0 && !IS_ERR(dev))
+               if (err < 0) {
                        free_netdev(dev);
-               if (err < 0)
                        goto out;
+               }
 
                err = rtnl_configure_link(dev, ifm);
                if (err < 0)
@@ -2156,7 +2179,7 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm,
        /* If aging addresses are supported device will need to
         * implement its own handler for this.
         */
-       if (ndm->ndm_state & NUD_PERMANENT) {
+       if (!(ndm->ndm_state & NUD_PERMANENT)) {
                pr_info("%s: FDB only supports static addresses\n", dev->name);
                return -EINVAL;
        }
@@ -2384,7 +2407,7 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
        struct nlattr *extfilt;
        u32 filter_mask = 0;
 
-       extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct rtgenmsg),
+       extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
                                  IFLA_EXT_MASK);
        if (extfilt)
                filter_mask = nla_get_u32(extfilt);
index 20e02d2605ecb2f10f5f74ab6f00cbd8fb852615..2c3d0f53d198c5915669a967f273c5f5b13b12af 100644 (file)
@@ -309,7 +309,8 @@ EXPORT_SYMBOL(__alloc_skb);
  * @frag_size: size of fragment, or 0 if head was kmalloced
  *
  * Allocate a new &sk_buff. Caller provides space holding head and
- * skb_shared_info. @data must have been allocated by kmalloc()
+ * skb_shared_info. @data must have been allocated by kmalloc() only if
+ * @frag_size is 0, otherwise data should come from the page allocator.
  * The return is the new skb buffer.
  * On a failure the return is %NULL, and @data is not freed.
  * Notes :
@@ -739,7 +740,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 
        skb_copy_secmark(new, old);
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        new->napi_id    = old->napi_id;
 #endif
 }
index 548d716c5f62ac8c9d90d0959d19022714f9585d..5b6beba494a350cb28adfc7724487f1a13e6c011 100644 (file)
@@ -93,6 +93,7 @@
 
 #include <linux/capability.h>
 #include <linux/errno.h>
+#include <linux/errqueue.h>
 #include <linux/types.h>
 #include <linux/socket.h>
 #include <linux/in.h>
@@ -900,7 +901,7 @@ set_rcvbuf:
                sock_valbool_flag(sk, SOCK_SELECT_ERR_QUEUE, valbool);
                break;
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        case SO_BUSY_POLL:
                /* allow unprivileged users to decrease the value */
                if ((val > sk->sk_ll_usec) && !capable(CAP_NET_ADMIN))
@@ -1170,7 +1171,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                v.val = sock_flag(sk, SOCK_SELECT_ERR_QUEUE);
                break;
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        case SO_BUSY_POLL:
                v.val = sk->sk_ll_usec;
                break;
@@ -1575,6 +1576,25 @@ void sock_wfree(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(sock_wfree);
 
+void skb_orphan_partial(struct sk_buff *skb)
+{
+       /* TCP stack sets skb->ooo_okay based on sk_wmem_alloc,
+        * so we do not completely orphan skb, but transfert all
+        * accounted bytes but one, to avoid unexpected reorders.
+        */
+       if (skb->destructor == sock_wfree
+#ifdef CONFIG_INET
+           || skb->destructor == tcp_wfree
+#endif
+               ) {
+               atomic_sub(skb->truesize - 1, &skb->sk->sk_wmem_alloc);
+               skb->truesize = 1;
+       } else {
+               skb_orphan(skb);
+       }
+}
+EXPORT_SYMBOL(skb_orphan_partial);
+
 /*
  * Read buffer destructor automatically called from kfree_skb.
  */
@@ -1721,24 +1741,23 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
 
 struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
                                     unsigned long data_len, int noblock,
-                                    int *errcode)
+                                    int *errcode, int max_page_order)
 {
-       struct sk_buff *skb;
+       struct sk_buff *skb = NULL;
+       unsigned long chunk;
        gfp_t gfp_mask;
        long timeo;
        int err;
        int npages = (data_len + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
+       struct page *page;
+       int i;
 
        err = -EMSGSIZE;
        if (npages > MAX_SKB_FRAGS)
                goto failure;
 
-       gfp_mask = sk->sk_allocation;
-       if (gfp_mask & __GFP_WAIT)
-               gfp_mask |= __GFP_REPEAT;
-
        timeo = sock_sndtimeo(sk, noblock);
-       while (1) {
+       while (!skb) {
                err = sock_error(sk);
                if (err != 0)
                        goto failure;
@@ -1747,50 +1766,52 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
                if (sk->sk_shutdown & SEND_SHUTDOWN)
                        goto failure;
 
-               if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) {
-                       skb = alloc_skb(header_len, gfp_mask);
-                       if (skb) {
-                               int i;
-
-                               /* No pages, we're done... */
-                               if (!data_len)
-                                       break;
-
-                               skb->truesize += data_len;
-                               skb_shinfo(skb)->nr_frags = npages;
-                               for (i = 0; i < npages; i++) {
-                                       struct page *page;
-
-                                       page = alloc_pages(sk->sk_allocation, 0);
-                                       if (!page) {
-                                               err = -ENOBUFS;
-                                               skb_shinfo(skb)->nr_frags = i;
-                                               kfree_skb(skb);
-                                               goto failure;
-                                       }
-
-                                       __skb_fill_page_desc(skb, i,
-                                                       page, 0,
-                                                       (data_len >= PAGE_SIZE ?
-                                                        PAGE_SIZE :
-                                                        data_len));
-                                       data_len -= PAGE_SIZE;
-                               }
+               if (atomic_read(&sk->sk_wmem_alloc) >= sk->sk_sndbuf) {
+                       set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
+                       set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+                       err = -EAGAIN;
+                       if (!timeo)
+                               goto failure;
+                       if (signal_pending(current))
+                               goto interrupted;
+                       timeo = sock_wait_for_wmem(sk, timeo);
+                       continue;
+               }
 
-                               /* Full success... */
-                               break;
-                       }
-                       err = -ENOBUFS;
+               err = -ENOBUFS;
+               gfp_mask = sk->sk_allocation;
+               if (gfp_mask & __GFP_WAIT)
+                       gfp_mask |= __GFP_REPEAT;
+
+               skb = alloc_skb(header_len, gfp_mask);
+               if (!skb)
                        goto failure;
+
+               skb->truesize += data_len;
+
+               for (i = 0; npages > 0; i++) {
+                       int order = max_page_order;
+
+                       while (order) {
+                               if (npages >= 1 << order) {
+                                       page = alloc_pages(sk->sk_allocation |
+                                                          __GFP_COMP | __GFP_NOWARN,
+                                                          order);
+                                       if (page)
+                                               goto fill_page;
+                               }
+                               order--;
+                       }
+                       page = alloc_page(sk->sk_allocation);
+                       if (!page)
+                               goto failure;
+fill_page:
+                       chunk = min_t(unsigned long, data_len,
+                                     PAGE_SIZE << order);
+                       skb_fill_page_desc(skb, i, page, 0, chunk);
+                       data_len -= chunk;
+                       npages -= 1 << order;
                }
-               set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
-               set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
-               err = -EAGAIN;
-               if (!timeo)
-                       goto failure;
-               if (signal_pending(current))
-                       goto interrupted;
-               timeo = sock_wait_for_wmem(sk, timeo);
        }
 
        skb_set_owner_w(skb, sk);
@@ -1799,6 +1820,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
 interrupted:
        err = sock_intr_errno(timeo);
 failure:
+       kfree_skb(skb);
        *errcode = err;
        return NULL;
 }
@@ -1807,7 +1829,7 @@ EXPORT_SYMBOL(sock_alloc_send_pskb);
 struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
                                    int noblock, int *errcode)
 {
-       return sock_alloc_send_pskb(sk, size, 0, noblock, errcode);
+       return sock_alloc_send_pskb(sk, size, 0, noblock, errcode, 0);
 }
 EXPORT_SYMBOL(sock_alloc_send_skb);
 
@@ -2292,7 +2314,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
 
        sk->sk_stamp = ktime_set(-1L, 0);
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        sk->sk_napi_id          =       0;
        sk->sk_ll_usec          =       sysctl_net_busy_read;
 #endif
@@ -2425,6 +2447,52 @@ void sock_enable_timestamp(struct sock *sk, int flag)
        }
 }
 
+int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
+                      int level, int type)
+{
+       struct sock_exterr_skb *serr;
+       struct sk_buff *skb, *skb2;
+       int copied, err;
+
+       err = -EAGAIN;
+       skb = skb_dequeue(&sk->sk_error_queue);
+       if (skb == NULL)
+               goto out;
+
+       copied = skb->len;
+       if (copied > len) {
+               msg->msg_flags |= MSG_TRUNC;
+               copied = len;
+       }
+       err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
+       if (err)
+               goto out_free_skb;
+
+       sock_recv_timestamp(msg, sk, skb);
+
+       serr = SKB_EXT_ERR(skb);
+       put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
+
+       msg->msg_flags |= MSG_ERRQUEUE;
+       err = copied;
+
+       /* Reset and regenerate socket error */
+       spin_lock_bh(&sk->sk_error_queue.lock);
+       sk->sk_err = 0;
+       if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) {
+               sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno;
+               spin_unlock_bh(&sk->sk_error_queue.lock);
+               sk->sk_error_report(sk);
+       } else
+               spin_unlock_bh(&sk->sk_error_queue.lock);
+
+out_free_skb:
+       kfree_skb(skb);
+out:
+       return err;
+}
+EXPORT_SYMBOL(sock_recv_errqueue);
+
 /*
  *     Get a socket option on an socket.
  *
index f5df85dcd20bc7f790aec8f58967f55e02586444..512f0a24269b59cc45baa14c13e586b34fce9b60 100644 (file)
@@ -30,7 +30,7 @@ void sk_stream_write_space(struct sock *sk)
        struct socket *sock = sk->sk_socket;
        struct socket_wq *wq;
 
-       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock) {
+       if (sk_stream_is_writeable(sk) && sock) {
                clear_bit(SOCK_NOSPACE, &sock->flags);
 
                rcu_read_lock();
index 6609686166379765233cdbfab0e3d580a3d23051..31107abd278391dfe6752a46fea03ec22978b604 100644 (file)
@@ -21,7 +21,9 @@
 #include <net/net_ratelimit.h>
 #include <net/busy_poll.h>
 
+static int zero = 0;
 static int one = 1;
+static int ushort_max = USHRT_MAX;
 
 #ifdef CONFIG_RPS
 static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
@@ -298,7 +300,7 @@ static struct ctl_table net_core_table[] = {
                .proc_handler   = flow_limit_table_len_sysctl
        },
 #endif /* CONFIG_NET_FLOW_LIMIT */
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
        {
                .procname       = "busy_poll",
                .data           = &sysctl_net_busy_poll,
@@ -339,7 +341,9 @@ static struct ctl_table netns_core_table[] = {
                .data           = &init_net.core.sysctl_somaxconn,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec
+               .extra1         = &zero,
+               .extra2         = &ushort_max,
+               .proc_handler   = proc_dointvec_minmax
        },
        { }
 };
index 6c7c78b839403f7582c8fd9daef4cfe0e1e571a0..ba64750f038726a990caa71d90e45f77bad93230 100644 (file)
@@ -336,7 +336,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
                        mask |= POLLIN | POLLRDNORM;
 
                if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
-                       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+                       if (sk_stream_is_writeable(sk)) {
                                mask |= POLLOUT | POLLWRNORM;
                        } else {  /* send SIGIO later */
                                set_bit(SOCK_ASYNC_NOSPACE,
@@ -347,7 +347,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
                                 * wspace test but before the flags are set,
                                 * IO signal will be lost.
                                 */
-                               if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+                               if (sk_stream_is_writeable(sk))
                                        mask |= POLLOUT | POLLWRNORM;
                        }
                }
index 5359560926bcf8f17f87c94474fd96cda1f1d6e2..be1f64d35358fbfbf61d84683c52e4d6fb423f34 100644 (file)
@@ -401,27 +401,8 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
 }
 EXPORT_SYMBOL(alloc_etherdev_mqs);
 
-static size_t _format_mac_addr(char *buf, int buflen,
-                              const unsigned char *addr, int len)
-{
-       int i;
-       char *cp = buf;
-
-       for (i = 0; i < len; i++) {
-               cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]);
-               if (i == len - 1)
-                       break;
-               cp += scnprintf(cp, buflen - (cp - buf), ":");
-       }
-       return cp - buf;
-}
-
 ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
 {
-       size_t l;
-
-       l = _format_mac_addr(buf, PAGE_SIZE, addr, len);
-       l += scnprintf(buf + l, PAGE_SIZE - l, "\n");
-       return (ssize_t)l;
+       return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);
 }
 EXPORT_SYMBOL(sysfs_format_mac);
index 3b9d5f20bd1c695de768db960b190beb4370fa35..c85e71e0c7ffc640bd9592ce52b03dbde6cad926 100644 (file)
@@ -67,39 +67,6 @@ static const u8 lowpan_ttl_values[] = {0, 1, 64, 255};
 
 static LIST_HEAD(lowpan_devices);
 
-/*
- * Uncompression of linklocal:
- *   0 -> 16 bytes from packet
- *   1 -> 2  bytes from prefix - bunch of zeroes and 8 from packet
- *   2 -> 2  bytes from prefix - zeroes + 2 from packet
- *   3 -> 2  bytes from prefix - infer 8 bytes from lladdr
- *
- *  NOTE: => the uncompress function does change 0xf to 0x10
- *  NOTE: 0x00 => no-autoconfig => unspecified
- */
-static const u8 lowpan_unc_llconf[] = {0x0f, 0x28, 0x22, 0x20};
-
-/*
- * Uncompression of ctx-based:
- *   0 -> 0 bits  from packet [unspecified / reserved]
- *   1 -> 8 bytes from prefix - bunch of zeroes and 8 from packet
- *   2 -> 8 bytes from prefix - zeroes + 2 from packet
- *   3 -> 8 bytes from prefix - infer 8 bytes from lladdr
- */
-static const u8 lowpan_unc_ctxconf[] = {0x00, 0x88, 0x82, 0x80};
-
-/*
- * Uncompression of ctx-base
- *   0 -> 0 bits from packet
- *   1 -> 2 bytes from prefix - bunch of zeroes 5 from packet
- *   2 -> 2 bytes from prefix - zeroes + 3 from packet
- *   3 -> 2 bytes from prefix - infer 1 bytes from lladdr
- */
-static const u8 lowpan_unc_mxconf[] = {0x0f, 0x25, 0x23, 0x21};
-
-/* Link local prefix */
-static const u8 lowpan_llprefix[] = {0xfe, 0x80};
-
 /* private device info */
 struct lowpan_dev_info {
        struct net_device       *real_dev; /* real WPAN device ptr */
@@ -191,55 +158,177 @@ lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, const struct in6_addr *ipaddr,
        return rol8(val, shift);
 }
 
-static void
-lowpan_uip_ds6_set_addr_iid(struct in6_addr *ipaddr, unsigned char *lladdr)
+/*
+ * Uncompress address function for source and
+ * destination address(non-multicast).
+ *
+ * address_mode is sam value or dam value.
+ */
+static int
+lowpan_uncompress_addr(struct sk_buff *skb,
+               struct in6_addr *ipaddr,
+               const u8 address_mode,
+               const struct ieee802154_addr *lladdr)
 {
-       memcpy(&ipaddr->s6_addr[8], lladdr, IEEE802154_ADDR_LEN);
-       /* second bit-flip (Universe/Local) is done according RFC2464 */
-       ipaddr->s6_addr[8] ^= 0x02;
+       bool fail;
+
+       switch (address_mode) {
+       case LOWPAN_IPHC_ADDR_00:
+               /* for global link addresses */
+               fail = lowpan_fetch_skb(skb, ipaddr->s6_addr, 16);
+               break;
+       case LOWPAN_IPHC_ADDR_01:
+               /* fe:80::XXXX:XXXX:XXXX:XXXX */
+               ipaddr->s6_addr[0] = 0xFE;
+               ipaddr->s6_addr[1] = 0x80;
+               fail = lowpan_fetch_skb(skb, &ipaddr->s6_addr[8], 8);
+               break;
+       case LOWPAN_IPHC_ADDR_02:
+               /* fe:80::ff:fe00:XXXX */
+               ipaddr->s6_addr[0] = 0xFE;
+               ipaddr->s6_addr[1] = 0x80;
+               ipaddr->s6_addr[11] = 0xFF;
+               ipaddr->s6_addr[12] = 0xFE;
+               fail = lowpan_fetch_skb(skb, &ipaddr->s6_addr[14], 2);
+               break;
+       case LOWPAN_IPHC_ADDR_03:
+               fail = false;
+               switch (lladdr->addr_type) {
+               case IEEE802154_ADDR_LONG:
+                       /* fe:80::XXXX:XXXX:XXXX:XXXX
+                        *        \_________________/
+                        *              hwaddr
+                        */
+                       ipaddr->s6_addr[0] = 0xFE;
+                       ipaddr->s6_addr[1] = 0x80;
+                       memcpy(&ipaddr->s6_addr[8], lladdr->hwaddr,
+                                       IEEE802154_ADDR_LEN);
+                       /* second bit-flip (Universe/Local)
+                        * is done according RFC2464
+                        */
+                       ipaddr->s6_addr[8] ^= 0x02;
+                       break;
+               case IEEE802154_ADDR_SHORT:
+                       /* fe:80::ff:fe00:XXXX
+                        *                \__/
+                        *             short_addr
+                        *
+                        * Universe/Local bit is zero.
+                        */
+                       ipaddr->s6_addr[0] = 0xFE;
+                       ipaddr->s6_addr[1] = 0x80;
+                       ipaddr->s6_addr[11] = 0xFF;
+                       ipaddr->s6_addr[12] = 0xFE;
+                       ipaddr->s6_addr16[7] = htons(lladdr->short_addr);
+                       break;
+               default:
+                       pr_debug("Invalid addr_type set\n");
+                       return -EINVAL;
+               }
+               break;
+       default:
+               pr_debug("Invalid address mode value: 0x%x\n", address_mode);
+               return -EINVAL;
+       }
+
+       if (fail) {
+               pr_debug("Failed to fetch skb data\n");
+               return -EIO;
+       }
+
+       lowpan_raw_dump_inline(NULL, "Reconstructed ipv6 addr is:\n",
+                       ipaddr->s6_addr, 16);
+
+       return 0;
 }
 
-/*
- * Uncompress addresses based on a prefix and a postfix with zeroes in
- * between. If the postfix is zero in length it will use the link address
- * to configure the IP address (autoconf style).
- * pref_post_count takes a byte where the first nibble specify prefix count
- * and the second postfix count (NOTE: 15/0xf => 16 bytes copy).
+/* Uncompress address function for source context
+ * based address(non-multicast).
  */
 static int
-lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr,
-       u8 const *prefix, u8 pref_post_count, unsigned char *lladdr)
+lowpan_uncompress_context_based_src_addr(struct sk_buff *skb,
+               struct in6_addr *ipaddr,
+               const u8 sam)
 {
-       u8 prefcount = pref_post_count >> 4;
-       u8 postcount = pref_post_count & 0x0f;
-
-       /* full nibble 15 => 16 */
-       prefcount = (prefcount == 15 ? 16 : prefcount);
-       postcount = (postcount == 15 ? 16 : postcount);
-
-       if (lladdr)
-               lowpan_raw_dump_inline(__func__, "linklocal address",
-                                               lladdr, IEEE802154_ADDR_LEN);
-       if (prefcount > 0)
-               memcpy(ipaddr, prefix, prefcount);
-
-       if (prefcount + postcount < 16)
-               memset(&ipaddr->s6_addr[prefcount], 0,
-                                       16 - (prefcount + postcount));
-
-       if (postcount > 0) {
-               memcpy(&ipaddr->s6_addr[16 - postcount], skb->data, postcount);
-               skb_pull(skb, postcount);
-       } else if (prefcount > 0) {
-               if (lladdr == NULL)
-                       return -EINVAL;
+       switch (sam) {
+       case LOWPAN_IPHC_ADDR_00:
+               /* unspec address ::
+                * Do nothing, address is already ::
+                */
+               break;
+       case LOWPAN_IPHC_ADDR_01:
+               /* TODO */
+       case LOWPAN_IPHC_ADDR_02:
+               /* TODO */
+       case LOWPAN_IPHC_ADDR_03:
+               /* TODO */
+               netdev_warn(skb->dev, "SAM value 0x%x not supported\n", sam);
+               return -EINVAL;
+       default:
+               pr_debug("Invalid sam value: 0x%x\n", sam);
+               return -EINVAL;
+       }
+
+       lowpan_raw_dump_inline(NULL,
+                       "Reconstructed context based ipv6 src addr is:\n",
+                       ipaddr->s6_addr, 16);
+
+       return 0;
+}
 
-               /* no IID based configuration if no prefix and no data */
-               lowpan_uip_ds6_set_addr_iid(ipaddr, lladdr);
+/* Uncompress function for multicast destination address,
+ * when M bit is set.
+ */
+static int
+lowpan_uncompress_multicast_daddr(struct sk_buff *skb,
+               struct in6_addr *ipaddr,
+               const u8 dam)
+{
+       bool fail;
+
+       switch (dam) {
+       case LOWPAN_IPHC_DAM_00:
+               /* 00:  128 bits.  The full address
+                * is carried in-line.
+                */
+               fail = lowpan_fetch_skb(skb, ipaddr->s6_addr, 16);
+               break;
+       case LOWPAN_IPHC_DAM_01:
+               /* 01:  48 bits.  The address takes
+                * the form ffXX::00XX:XXXX:XXXX.
+                */
+               ipaddr->s6_addr[0] = 0xFF;
+               fail = lowpan_fetch_skb(skb, &ipaddr->s6_addr[1], 1);
+               fail |= lowpan_fetch_skb(skb, &ipaddr->s6_addr[11], 5);
+               break;
+       case LOWPAN_IPHC_DAM_10:
+               /* 10:  32 bits.  The address takes
+                * the form ffXX::00XX:XXXX.
+                */
+               ipaddr->s6_addr[0] = 0xFF;
+               fail = lowpan_fetch_skb(skb, &ipaddr->s6_addr[1], 1);
+               fail |= lowpan_fetch_skb(skb, &ipaddr->s6_addr[13], 3);
+               break;
+       case LOWPAN_IPHC_DAM_11:
+               /* 11:  8 bits.  The address takes
+                * the form ff02::00XX.
+                */
+               ipaddr->s6_addr[0] = 0xFF;
+               ipaddr->s6_addr[1] = 0x02;
+               fail = lowpan_fetch_skb(skb, &ipaddr->s6_addr[15], 1);
+               break;
+       default:
+               pr_debug("DAM value has a wrong value: 0x%x\n", dam);
+               return -EINVAL;
+       }
+
+       if (fail) {
+               pr_debug("Failed to fetch skb data\n");
+               return -EIO;
        }
 
-       pr_debug("uncompressing %d + %d => ", prefcount, postcount);
-       lowpan_raw_dump_inline(NULL, NULL, ipaddr->s6_addr, 16);
+       lowpan_raw_dump_inline(NULL, "Reconstructed ipv6 multicast addr is:\n",
+                       ipaddr->s6_addr, 16);
 
        return 0;
 }
@@ -702,6 +791,12 @@ lowpan_alloc_new_frame(struct sk_buff *skb, u16 len, u16 tag)
        skb_reserve(frame->skb, sizeof(struct ipv6hdr));
        skb_put(frame->skb, frame->length);
 
+       /* copy the first control block to keep a
+        * trace of the link-layer addresses in case
+        * of a link-local compressed address
+        */
+       memcpy(frame->skb->cb, skb->cb, sizeof(skb->cb));
+
        init_timer(&frame->timer);
        /* time out is the same as for ipv6 - 60 sec */
        frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT;
@@ -723,9 +818,9 @@ frame_err:
 static int
 lowpan_process_data(struct sk_buff *skb)
 {
-       struct ipv6hdr hdr;
+       struct ipv6hdr hdr = {};
        u8 tmp, iphc0, iphc1, num_context = 0;
-       u8 *_saddr, *_daddr;
+       const struct ieee802154_addr *_saddr, *_daddr;
        int err;
 
        lowpan_raw_dump_table(__func__, "raw skb data dump", skb->data,
@@ -828,8 +923,8 @@ lowpan_process_data(struct sk_buff *skb)
        if (lowpan_fetch_skb_u8(skb, &iphc1))
                goto drop;
 
-       _saddr = mac_cb(skb)->sa.hwaddr;
-       _daddr = mac_cb(skb)->da.hwaddr;
+       _saddr = &mac_cb(skb)->sa;
+       _daddr = &mac_cb(skb)->da;
 
        pr_debug("iphc0 = %02x, iphc1 = %02x\n", iphc0, iphc1);
 
@@ -868,8 +963,6 @@ lowpan_process_data(struct sk_buff *skb)
 
                hdr.priority = ((tmp >> 2) & 0x0f);
                hdr.flow_lbl[0] = ((tmp << 6) & 0xC0) | ((tmp >> 2) & 0x30);
-               hdr.flow_lbl[1] = 0;
-               hdr.flow_lbl[2] = 0;
                break;
        /*
         * Flow Label carried in-line
@@ -885,10 +978,6 @@ lowpan_process_data(struct sk_buff *skb)
                break;
        /* Traffic Class and Flow Label are elided */
        case 3: /* 11b */
-               hdr.priority = 0;
-               hdr.flow_lbl[0] = 0;
-               hdr.flow_lbl[1] = 0;
-               hdr.flow_lbl[2] = 0;
                break;
        default:
                break;
@@ -915,10 +1004,18 @@ lowpan_process_data(struct sk_buff *skb)
        /* Extract SAM to the tmp variable */
        tmp = ((iphc1 & LOWPAN_IPHC_SAM) >> LOWPAN_IPHC_SAM_BIT) & 0x03;
 
-       /* Source address uncompression */
-       pr_debug("source address stateless compression\n");
-       err = lowpan_uncompress_addr(skb, &hdr.saddr, lowpan_llprefix,
-                               lowpan_unc_llconf[tmp], skb->data);
+       if (iphc1 & LOWPAN_IPHC_SAC) {
+               /* Source address context based uncompression */
+               pr_debug("SAC bit is set. Handle context based source address.\n");
+               err = lowpan_uncompress_context_based_src_addr(
+                               skb, &hdr.saddr, tmp);
+       } else {
+               /* Source address uncompression */
+               pr_debug("source address stateless compression\n");
+               err = lowpan_uncompress_addr(skb, &hdr.saddr, tmp, _saddr);
+       }
+
+       /* Check on error of previous branch */
        if (err)
                goto drop;
 
@@ -931,23 +1028,14 @@ lowpan_process_data(struct sk_buff *skb)
                        pr_debug("dest: context-based mcast compression\n");
                        /* TODO: implement this */
                } else {
-                       u8 prefix[] = {0xff, 0x02};
-
-                       pr_debug("dest: non context-based mcast compression\n");
-                       if (0 < tmp && tmp < 3) {
-                               if (lowpan_fetch_skb_u8(skb, &prefix[1]))
-                                       goto drop;
-                       }
-
-                       err = lowpan_uncompress_addr(skb, &hdr.daddr, prefix,
-                                       lowpan_unc_mxconf[tmp], NULL);
+                       err = lowpan_uncompress_multicast_daddr(
+                                       skb, &hdr.daddr, tmp);
                        if (err)
                                goto drop;
                }
        } else {
                pr_debug("dest: stateless compression\n");
-               err = lowpan_uncompress_addr(skb, &hdr.daddr, lowpan_llprefix,
-                               lowpan_unc_llconf[tmp], skb->data);
+               err = lowpan_uncompress_addr(skb, &hdr.daddr, tmp, _daddr);
                if (err)
                        goto drop;
        }
index 4b8f917658b52fa028200d9ec1ab788130ecd143..2869c0526dad698b574ddd05f3f2175d5fb69455 100644 (file)
 /* Values of fields within the IPHC encoding second byte */
 #define LOWPAN_IPHC_CID                0x80
 
+#define LOWPAN_IPHC_ADDR_00    0x00
+#define LOWPAN_IPHC_ADDR_01    0x01
+#define LOWPAN_IPHC_ADDR_02    0x02
+#define LOWPAN_IPHC_ADDR_03    0x03
+
 #define LOWPAN_IPHC_SAC                0x40
-#define LOWPAN_IPHC_SAM_00     0x00
-#define LOWPAN_IPHC_SAM_01     0x10
-#define LOWPAN_IPHC_SAM_10     0x20
 #define LOWPAN_IPHC_SAM                0x30
 
 #define LOWPAN_IPHC_SAM_BIT    4
                                        dest = 16 bit inline */
 #define LOWPAN_NHC_UDP_CS_P_11 0xF3 /* source & dest = 0xF0B + 4bit inline */
 
+static inline bool lowpan_fetch_skb(struct sk_buff *skb,
+               void *data, const unsigned int len)
+{
+       if (unlikely(!pskb_may_pull(skb, len)))
+               return true;
+
+       skb_copy_from_linear_data(skb, data, len);
+       skb_pull(skb, len);
+
+       return false;
+}
+
 #endif /* __6LOWPAN_H__ */
index 8d48c392adccec6dc1f2ca8e3c8fd5a6750283e5..a1b5bcbd04ae01e358d1542c354fac083c9f8582 100644 (file)
@@ -73,6 +73,8 @@ static struct ipv4_devconf ipv4_devconf = {
                [IPV4_DEVCONF_SEND_REDIRECTS - 1] = 1,
                [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
                [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
+               [IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL - 1] = 10000 /*ms*/,
+               [IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL - 1] =  1000 /*ms*/,
        },
 };
 
@@ -83,6 +85,8 @@ static struct ipv4_devconf ipv4_devconf_dflt = {
                [IPV4_DEVCONF_SECURE_REDIRECTS - 1] = 1,
                [IPV4_DEVCONF_SHARED_MEDIA - 1] = 1,
                [IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE - 1] = 1,
+               [IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL - 1] = 10000 /*ms*/,
+               [IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL - 1] =  1000 /*ms*/,
        },
 };
 
@@ -772,7 +776,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
                ci = nla_data(tb[IFA_CACHEINFO]);
                if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) {
                        err = -EINVAL;
-                       goto errout;
+                       goto errout_free;
                }
                *pvalid_lft = ci->ifa_valid;
                *pprefered_lft = ci->ifa_prefered;
@@ -780,6 +784,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
 
        return ifa;
 
+errout_free:
+       inet_free_ifa(ifa);
 errout:
        return ERR_PTR(err);
 }
@@ -1124,10 +1130,7 @@ static int inet_gifconf(struct net_device *dev, char __user *buf, int len)
                if (len < (int) sizeof(ifr))
                        break;
                memset(&ifr, 0, sizeof(struct ifreq));
-               if (ifa->ifa_label)
-                       strcpy(ifr.ifr_name, ifa->ifa_label);
-               else
-                       strcpy(ifr.ifr_name, dev->name);
+               strcpy(ifr.ifr_name, ifa->ifa_label);
 
                (*(struct sockaddr_in *)&ifr.ifr_addr).sin_family = AF_INET;
                (*(struct sockaddr_in *)&ifr.ifr_addr).sin_addr.s_addr =
@@ -2095,11 +2098,15 @@ static struct devinet_sysctl_table {
                DEVINET_SYSCTL_RW_ENTRY(ARP_ACCEPT, "arp_accept"),
                DEVINET_SYSCTL_RW_ENTRY(ARP_NOTIFY, "arp_notify"),
                DEVINET_SYSCTL_RW_ENTRY(PROXY_ARP_PVLAN, "proxy_arp_pvlan"),
+               DEVINET_SYSCTL_RW_ENTRY(FORCE_IGMP_VERSION,
+                                       "force_igmp_version"),
+               DEVINET_SYSCTL_RW_ENTRY(IGMPV2_UNSOLICITED_REPORT_INTERVAL,
+                                       "igmpv2_unsolicited_report_interval"),
+               DEVINET_SYSCTL_RW_ENTRY(IGMPV3_UNSOLICITED_REPORT_INTERVAL,
+                                       "igmpv3_unsolicited_report_interval"),
 
                DEVINET_SYSCTL_FLUSHING_ENTRY(NOXFRM, "disable_xfrm"),
                DEVINET_SYSCTL_FLUSHING_ENTRY(NOPOLICY, "disable_policy"),
-               DEVINET_SYSCTL_FLUSHING_ENTRY(FORCE_IGMP_VERSION,
-                                             "force_igmp_version"),
                DEVINET_SYSCTL_FLUSHING_ENTRY(PROMOTE_SECONDARIES,
                                              "promote_secondaries"),
                DEVINET_SYSCTL_FLUSHING_ENTRY(ROUTE_LOCALNET,
index ab3d814bc80af8f377da971af189a49ae4f2f094..109ee89f123e5e51714cae1fa9097e6ec65f0627 100644 (file)
@@ -477,7 +477,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
        }
 
        return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
-                net_adj) & ~(align - 1)) + (net_adj - 2);
+                net_adj) & ~(align - 1)) + net_adj - 2;
 }
 
 static void esp4_err(struct sk_buff *skb, u32 info)
index 26aa65d1fce49dfeaa45cbc02046218b5bc70453..523be38e37de82736a28bc9aa229f1911d2eaa31 100644 (file)
@@ -101,6 +101,30 @@ errout:
        return err;
 }
 
+static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
+{
+       struct fib_result *result = (struct fib_result *) arg->result;
+       struct net_device *dev = result->fi->fib_dev;
+
+       /* do not accept result if the route does
+        * not meet the required prefix length
+        */
+       if (result->prefixlen <= rule->suppress_prefixlen)
+               goto suppress_route;
+
+       /* do not accept result if the route uses a device
+        * belonging to a forbidden interface group
+        */
+       if (rule->suppress_ifgroup != -1 && dev && dev->group == rule->suppress_ifgroup)
+               goto suppress_route;
+
+       return false;
+
+suppress_route:
+       if (!(arg->flags & FIB_LOOKUP_NOREF))
+               fib_info_put(result->fi);
+       return true;
+}
 
 static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
 {
@@ -267,6 +291,7 @@ static const struct fib_rules_ops __net_initconst fib4_rules_ops_template = {
        .rule_size      = sizeof(struct fib4_rule),
        .addr_size      = sizeof(u32),
        .action         = fib4_rule_action,
+       .suppress       = fib4_rule_suppress,
        .match          = fib4_rule_match,
        .configure      = fib4_rule_configure,
        .delete         = fib4_rule_delete,
index 49616fed9340265b203c7b1fbf10390f92c38020..3df6d3edb2a15a98cb0e90a4e5ed935f42f15f1c 100644 (file)
@@ -71,7 +71,6 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/slab.h>
-#include <linux/prefetch.h>
 #include <linux/export.h>
 #include <net/net_namespace.h>
 #include <net/ip.h>
@@ -1761,10 +1760,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
                        if (!c)
                                continue;
 
-                       if (IS_LEAF(c)) {
-                               prefetch(rcu_dereference_rtnl(p->child[idx]));
+                       if (IS_LEAF(c))
                                return (struct leaf *) c;
-                       }
 
                        /* Rescan start scanning in new node */
                        p = (struct tnode *) c;
@@ -2133,7 +2130,7 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
                max--;
 
        pointers = 0;
-       for (i = 1; i <= max; i++)
+       for (i = 1; i < max; i++)
                if (stat->nodesizes[i] != 0) {
                        seq_printf(seq, "  %u: %u",  i, stat->nodesizes[i]);
                        pointers += (1<<i) * stat->nodesizes[i];
index cd71190d29625c11fe25aa603026cc98e0e2c34b..d6c0e64ec97f2147124e84d4b634f263bac9eb95 100644 (file)
@@ -88,6 +88,7 @@
 #include <linux/if_arp.h>
 #include <linux/rtnetlink.h>
 #include <linux/times.h>
+#include <linux/pkt_sched.h>
 
 #include <net/net_namespace.h>
 #include <net/arp.h>
 
 #define IGMP_V1_Router_Present_Timeout         (400*HZ)
 #define IGMP_V2_Router_Present_Timeout         (400*HZ)
-#define IGMP_Unsolicited_Report_Interval       (10*HZ)
+#define IGMP_V2_Unsolicited_Report_Interval    (10*HZ)
+#define IGMP_V3_Unsolicited_Report_Interval    (1*HZ)
 #define IGMP_Query_Response_Interval           (10*HZ)
 #define IGMP_Unsolicited_Report_Count          2
 
         ((in_dev)->mr_v2_seen && \
          time_before(jiffies, (in_dev)->mr_v2_seen)))
 
+static int unsolicited_report_interval(struct in_device *in_dev)
+{
+       int interval_ms, interval_jiffies;
+
+       if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev))
+               interval_ms = IN_DEV_CONF_GET(
+                       in_dev,
+                       IGMPV2_UNSOLICITED_REPORT_INTERVAL);
+       else /* v3 */
+               interval_ms = IN_DEV_CONF_GET(
+                       in_dev,
+                       IGMPV3_UNSOLICITED_REPORT_INTERVAL);
+
+       interval_jiffies = msecs_to_jiffies(interval_ms);
+
+       /* _timer functions can't handle a delay of 0 jiffies so ensure
+        *  we always return a positive value.
+        */
+       if (interval_jiffies <= 0)
+               interval_jiffies = 1;
+       return interval_jiffies;
+}
+
 static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im);
 static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr);
 static void igmpv3_clear_delrec(struct in_device *in_dev);
@@ -315,6 +340,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
                if (size < 256)
                        return NULL;
        }
+       skb->priority = TC_PRIO_CONTROL;
        igmp_skb_size(skb) = size;
 
        rt = ip_route_output_ports(net, &fl4, NULL, IGMPV3_ALL_MCR, 0,
@@ -670,6 +696,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
                ip_rt_put(rt);
                return -1;
        }
+       skb->priority = TC_PRIO_CONTROL;
 
        skb_dst_set(skb, &rt->dst);
 
@@ -719,7 +746,8 @@ static void igmp_ifc_timer_expire(unsigned long data)
        igmpv3_send_cr(in_dev);
        if (in_dev->mr_ifc_count) {
                in_dev->mr_ifc_count--;
-               igmp_ifc_start_timer(in_dev, IGMP_Unsolicited_Report_Interval);
+               igmp_ifc_start_timer(in_dev,
+                                    unsolicited_report_interval(in_dev));
        }
        __in_dev_put(in_dev);
 }
@@ -744,7 +772,7 @@ static void igmp_timer_expire(unsigned long data)
 
        if (im->unsolicit_count) {
                im->unsolicit_count--;
-               igmp_start_timer(im, IGMP_Unsolicited_Report_Interval);
+               igmp_start_timer(im, unsolicited_report_interval(in_dev));
        }
        im->reporter = 1;
        spin_unlock(&im->lock);
@@ -1323,16 +1351,17 @@ out:
 EXPORT_SYMBOL(ip_mc_inc_group);
 
 /*
- *     Resend IGMP JOIN report; used for bonding.
- *     Called with rcu_read_lock()
+ *     Resend IGMP JOIN report; used by netdev notifier.
  */
-void ip_mc_rejoin_groups(struct in_device *in_dev)
+static void ip_mc_rejoin_groups(struct in_device *in_dev)
 {
 #ifdef CONFIG_IP_MULTICAST
        struct ip_mc_list *im;
        int type;
 
-       for_each_pmc_rcu(in_dev, im) {
+       ASSERT_RTNL();
+
+       for_each_pmc_rtnl(in_dev, im) {
                if (im->multiaddr == IGMP_ALL_HOSTS)
                        continue;
 
@@ -1349,7 +1378,6 @@ void ip_mc_rejoin_groups(struct in_device *in_dev)
        }
 #endif
 }
-EXPORT_SYMBOL(ip_mc_rejoin_groups);
 
 /*
  *     A socket has left a multicast group on device dev
@@ -2735,8 +2763,42 @@ static struct pernet_operations igmp_net_ops = {
        .exit = igmp_net_exit,
 };
 
+static int igmp_netdev_event(struct notifier_block *this,
+                            unsigned long event, void *ptr)
+{
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+       struct in_device *in_dev;
+
+       switch (event) {
+       case NETDEV_RESEND_IGMP:
+               in_dev = __in_dev_get_rtnl(dev);
+               if (in_dev)
+                       ip_mc_rejoin_groups(in_dev);
+               break;
+       default:
+               break;
+       }
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block igmp_notifier = {
+       .notifier_call = igmp_netdev_event,
+};
+
 int __init igmp_mc_proc_init(void)
 {
-       return register_pernet_subsys(&igmp_net_ops);
+       int err;
+
+       err = register_pernet_subsys(&igmp_net_ops);
+       if (err)
+               return err;
+       err = register_netdevice_notifier(&igmp_notifier);
+       if (err)
+               goto reg_notif_fail;
+       return 0;
+
+reg_notif_fail:
+       unregister_pernet_subsys(&igmp_net_ops);
+       return err;
 }
 #endif
index 1f6eab66f7cee5f94e1a5cfd6b6ea919184b5d35..d7aea4c5b9400efec37d15db3c5a896769d0da68 100644 (file)
@@ -383,7 +383,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
        if (daddr)
                memcpy(&iph->daddr, daddr, 4);
        if (iph->daddr)
-               return t->hlen;
+               return t->hlen + sizeof(*iph);
 
        return -(t->hlen + sizeof(*iph));
 }
@@ -534,7 +534,7 @@ static int __net_init ipgre_init_net(struct net *net)
 static void __net_exit ipgre_exit_net(struct net *net)
 {
        struct ip_tunnel_net *itn = net_generic(net, ipgre_net_id);
-       ip_tunnel_delete_net(itn);
+       ip_tunnel_delete_net(itn, &ipgre_link_ops);
 }
 
 static struct pernet_operations ipgre_net_ops = {
@@ -767,7 +767,7 @@ static int __net_init ipgre_tap_init_net(struct net *net)
 static void __net_exit ipgre_tap_exit_net(struct net *net)
 {
        struct ip_tunnel_net *itn = net_generic(net, gre_tap_net_id);
-       ip_tunnel_delete_net(itn);
+       ip_tunnel_delete_net(itn, &ipgre_tap_ops);
 }
 
 static struct pernet_operations ipgre_tap_net_ops = {
index 3da817b89e9bf5376a3603028fb548dac2d58715..054a3e97d822b61646cfff92c2ff2ed0f1e0740a 100644 (file)
 #include <net/icmp.h>
 #include <net/raw.h>
 #include <net/checksum.h>
+#include <net/inet_ecn.h>
 #include <linux/netfilter_ipv4.h>
 #include <net/xfrm.h>
 #include <linux/mroute.h>
@@ -190,10 +191,7 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
 {
        struct net *net = dev_net(skb->dev);
 
-       __skb_pull(skb, ip_hdrlen(skb));
-
-       /* Point into the IP datagram, just past the header. */
-       skb_reset_transport_header(skb);
+       __skb_pull(skb, skb_network_header_len(skb));
 
        rcu_read_lock();
        {
@@ -413,6 +411,13 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
        if (iph->ihl < 5 || iph->version != 4)
                goto inhdr_error;
 
+       BUILD_BUG_ON(IPSTATS_MIB_ECT1PKTS != IPSTATS_MIB_NOECTPKTS + INET_ECN_ECT_1);
+       BUILD_BUG_ON(IPSTATS_MIB_ECT0PKTS != IPSTATS_MIB_NOECTPKTS + INET_ECN_ECT_0);
+       BUILD_BUG_ON(IPSTATS_MIB_CEPKTS != IPSTATS_MIB_NOECTPKTS + INET_ECN_CE);
+       IP_ADD_STATS_BH(dev_net(dev),
+                       IPSTATS_MIB_NOECTPKTS + (iph->tos & INET_ECN_MASK),
+                       max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
+
        if (!pskb_may_pull(skb, iph->ihl*4))
                goto inhdr_error;
 
@@ -437,6 +442,8 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
                goto drop;
        }
 
+       skb->transport_header = skb->network_header + iph->ihl*4;
+
        /* Remove any debris in the socket control block */
        memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
 
index ca1cb2d5f6e2bcb81eea9d35e3178518492a7a63..830de3f4e2935d17e241e37b7c563bd6a6eb191d 100644 (file)
@@ -350,7 +350,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
                struct flowi4 fl4;
                struct rtable *rt;
 
-               rt = ip_route_output_tunnel(dev_net(dev), &fl4,
+               rt = ip_route_output_tunnel(tunnel->net, &fl4,
                                            tunnel->parms.iph.protocol,
                                            iph->daddr, iph->saddr,
                                            tunnel->parms.o_key,
@@ -365,7 +365,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
        }
 
        if (!tdev && tunnel->parms.link)
-               tdev = __dev_get_by_index(dev_net(dev), tunnel->parms.link);
+               tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
 
        if (tdev) {
                hlen = tdev->hard_header_len + tdev->needed_headroom;
@@ -454,15 +454,16 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
        tstats->rx_bytes += skb->len;
        u64_stats_update_end(&tstats->syncp);
 
-       if (tunnel->net != dev_net(tunnel->dev))
-               skb_scrub_packet(skb);
-
        if (tunnel->dev->type == ARPHRD_ETHER) {
                skb->protocol = eth_type_trans(skb, tunnel->dev);
                skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
        } else {
                skb->dev = tunnel->dev;
        }
+
+       if (!net_eq(tunnel->net, dev_net(tunnel->dev)))
+               skb_scrub_packet(skb);
+
        gro_cells_receive(&tunnel->gro_cells, skb);
        return 0;
 
@@ -613,7 +614,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
                goto tx_error;
        }
 
-       if (tunnel->net != dev_net(dev))
+       if (!net_eq(tunnel->net, dev_net(dev)))
                skb_scrub_packet(skb);
 
        if (tunnel->err_count > 0) {
@@ -653,7 +654,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
                }
        }
 
-       err = iptunnel_xmit(dev_net(dev), rt, skb,
+       err = iptunnel_xmit(tunnel->net, rt, skb,
                            fl4.saddr, fl4.daddr, protocol,
                            ip_tunnel_ecn_encap(tos, inner_iph, skb), ttl, df);
        iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
@@ -820,11 +821,10 @@ static void ip_tunnel_dev_free(struct net_device *dev)
 
 void ip_tunnel_dellink(struct net_device *dev, struct list_head *head)
 {
-       struct net *net = dev_net(dev);
        struct ip_tunnel *tunnel = netdev_priv(dev);
        struct ip_tunnel_net *itn;
 
-       itn = net_generic(net, tunnel->ip_tnl_net_id);
+       itn = net_generic(tunnel->net, tunnel->ip_tnl_net_id);
 
        if (itn->fb_tunnel_dev != dev) {
                ip_tunnel_del(netdev_priv(dev));
@@ -838,56 +838,68 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
 {
        struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
        struct ip_tunnel_parm parms;
+       unsigned int i;
 
-       itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL);
-       if (!itn->tunnels)
-               return -ENOMEM;
+       for (i = 0; i < IP_TNL_HASH_SIZE; i++)
+               INIT_HLIST_HEAD(&itn->tunnels[i]);
 
        if (!ops) {
                itn->fb_tunnel_dev = NULL;
                return 0;
        }
+
        memset(&parms, 0, sizeof(parms));
        if (devname)
                strlcpy(parms.name, devname, IFNAMSIZ);
 
        rtnl_lock();
        itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
+       /* FB netdevice is special: we have one, and only one per netns.
+        * Allowing to move it to another netns is clearly unsafe.
+        */
+       if (!IS_ERR(itn->fb_tunnel_dev))
+               itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL;
        rtnl_unlock();
-       if (IS_ERR(itn->fb_tunnel_dev)) {
-               kfree(itn->tunnels);
-               return PTR_ERR(itn->fb_tunnel_dev);
-       }
 
-       return 0;
+       return PTR_RET(itn->fb_tunnel_dev);
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_init_net);
 
-static void ip_tunnel_destroy(struct ip_tunnel_net *itn, struct list_head *head)
+static void ip_tunnel_destroy(struct ip_tunnel_net *itn, struct list_head *head,
+                             struct rtnl_link_ops *ops)
 {
+       struct net *net = dev_net(itn->fb_tunnel_dev);
+       struct net_device *dev, *aux;
        int h;
 
+       for_each_netdev_safe(net, dev, aux)
+               if (dev->rtnl_link_ops == ops)
+                       unregister_netdevice_queue(dev, head);
+
        for (h = 0; h < IP_TNL_HASH_SIZE; h++) {
                struct ip_tunnel *t;
                struct hlist_node *n;
                struct hlist_head *thead = &itn->tunnels[h];
 
                hlist_for_each_entry_safe(t, n, thead, hash_node)
-                       unregister_netdevice_queue(t->dev, head);
+                       /* If dev is in the same netns, it has already
+                        * been added to the list by the previous loop.
+                        */
+                       if (!net_eq(dev_net(t->dev), net))
+                               unregister_netdevice_queue(t->dev, head);
        }
        if (itn->fb_tunnel_dev)
                unregister_netdevice_queue(itn->fb_tunnel_dev, head);
 }
 
-void ip_tunnel_delete_net(struct ip_tunnel_net *itn)
+void ip_tunnel_delete_net(struct ip_tunnel_net *itn, struct rtnl_link_ops *ops)
 {
        LIST_HEAD(list);
 
        rtnl_lock();
-       ip_tunnel_destroy(itn, &list);
+       ip_tunnel_destroy(itn, &list, ops);
        unregister_netdevice_many(&list);
        rtnl_unlock();
-       kfree(itn->tunnels);
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_delete_net);
 
@@ -929,23 +941,21 @@ EXPORT_SYMBOL_GPL(ip_tunnel_newlink);
 int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[],
                         struct ip_tunnel_parm *p)
 {
-       struct ip_tunnel *t, *nt;
-       struct net *net = dev_net(dev);
+       struct ip_tunnel *t;
        struct ip_tunnel *tunnel = netdev_priv(dev);
+       struct net *net = tunnel->net;
        struct ip_tunnel_net *itn = net_generic(net, tunnel->ip_tnl_net_id);
 
        if (dev == itn->fb_tunnel_dev)
                return -EINVAL;
 
-       nt = netdev_priv(dev);
-
        t = ip_tunnel_find(itn, p, dev->type);
 
        if (t) {
                if (t->dev != dev)
                        return -EEXIST;
        } else {
-               t = nt;
+               t = tunnel;
 
                if (dev->type != ARPHRD_ETHER) {
                        unsigned int nflags = 0;
@@ -984,6 +994,7 @@ int ip_tunnel_init(struct net_device *dev)
        }
 
        tunnel->dev = dev;
+       tunnel->net = dev_net(dev);
        strcpy(tunnel->parms.name, dev->name);
        iph->version            = 4;
        iph->ihl                = 5;
@@ -994,8 +1005,8 @@ EXPORT_SYMBOL_GPL(ip_tunnel_init);
 
 void ip_tunnel_uninit(struct net_device *dev)
 {
-       struct net *net = dev_net(dev);
        struct ip_tunnel *tunnel = netdev_priv(dev);
+       struct net *net = tunnel->net;
        struct ip_tunnel_net *itn;
 
        itn = net_generic(net, tunnel->ip_tnl_net_id);
index 7167b08977df582bd38565cf960568a8553f29d4..850525b34899f3a50d0e19f6bd326821b0c2423a 100644 (file)
@@ -76,9 +76,7 @@ int iptunnel_xmit(struct net *net, struct rtable *rt,
        iph->daddr      =       dst;
        iph->saddr      =       src;
        iph->ttl        =       ttl;
-       tunnel_ip_select_ident(skb,
-                              (const struct iphdr *)skb_inner_network_header(skb),
-                              &rt->dst);
+       __ip_select_ident(iph, &rt->dst, (skb_shinfo(skb)->gso_segs ?: 1) - 1);
 
        err = ip_local_out(skb);
        if (unlikely(net_xmit_eval(err)))
index 17cc0ffa8c0d0ea2a3732b76b63be1f85c896778..e805e7b3030e3dad2f8fd83d140f0bb7f100d69c 100644 (file)
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 
-#define HASH_SIZE  16
-#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
-
 static struct rtnl_link_ops vti_link_ops __read_mostly;
 
 static int vti_net_id __read_mostly;
-struct vti_net {
-       struct ip_tunnel __rcu *tunnels_r_l[HASH_SIZE];
-       struct ip_tunnel __rcu *tunnels_r[HASH_SIZE];
-       struct ip_tunnel __rcu *tunnels_l[HASH_SIZE];
-       struct ip_tunnel __rcu *tunnels_wc[1];
-       struct ip_tunnel __rcu **tunnels[4];
-
-       struct net_device *fb_tunnel_dev;
-};
-
-static int vti_fb_tunnel_init(struct net_device *dev);
 static int vti_tunnel_init(struct net_device *dev);
-static void vti_tunnel_setup(struct net_device *dev);
-static void vti_dev_free(struct net_device *dev);
-static int vti_tunnel_bind_dev(struct net_device *dev);
-
-#define VTI_XMIT(stats1, stats2) do {                          \
-       int err;                                                \
-       int pkt_len = skb->len;                                 \
-       err = dst_output(skb);                                  \
-       if (net_xmit_eval(err) == 0) {                          \
-               u64_stats_update_begin(&(stats1)->syncp);       \
-               (stats1)->tx_bytes += pkt_len;                  \
-               (stats1)->tx_packets++;                         \
-               u64_stats_update_end(&(stats1)->syncp);         \
-       } else {                                                \
-               (stats2)->tx_errors++;                          \
-               (stats2)->tx_aborted_errors++;                  \
-       }                                                       \
-} while (0)
-
-
-static struct ip_tunnel *vti_tunnel_lookup(struct net *net,
-                                          __be32 remote, __be32 local)
-{
-       unsigned h0 = HASH(remote);
-       unsigned h1 = HASH(local);
-       struct ip_tunnel *t;
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-
-       for_each_ip_tunnel_rcu(t, ipn->tunnels_r_l[h0 ^ h1])
-               if (local == t->parms.iph.saddr &&
-                   remote == t->parms.iph.daddr && (t->dev->flags&IFF_UP))
-                       return t;
-       for_each_ip_tunnel_rcu(t, ipn->tunnels_r[h0])
-               if (remote == t->parms.iph.daddr && (t->dev->flags&IFF_UP))
-                       return t;
-
-       for_each_ip_tunnel_rcu(t, ipn->tunnels_l[h1])
-               if (local == t->parms.iph.saddr && (t->dev->flags&IFF_UP))
-                       return t;
-
-       for_each_ip_tunnel_rcu(t, ipn->tunnels_wc[0])
-               if (t && (t->dev->flags&IFF_UP))
-                       return t;
-       return NULL;
-}
-
-static struct ip_tunnel __rcu **__vti_bucket(struct vti_net *ipn,
-                                            struct ip_tunnel_parm *parms)
-{
-       __be32 remote = parms->iph.daddr;
-       __be32 local = parms->iph.saddr;
-       unsigned h = 0;
-       int prio = 0;
-
-       if (remote) {
-               prio |= 2;
-               h ^= HASH(remote);
-       }
-       if (local) {
-               prio |= 1;
-               h ^= HASH(local);
-       }
-       return &ipn->tunnels[prio][h];
-}
-
-static inline struct ip_tunnel __rcu **vti_bucket(struct vti_net *ipn,
-                                                 struct ip_tunnel *t)
-{
-       return __vti_bucket(ipn, &t->parms);
-}
-
-static void vti_tunnel_unlink(struct vti_net *ipn, struct ip_tunnel *t)
-{
-       struct ip_tunnel __rcu **tp;
-       struct ip_tunnel *iter;
-
-       for (tp = vti_bucket(ipn, t);
-            (iter = rtnl_dereference(*tp)) != NULL;
-            tp = &iter->next) {
-               if (t == iter) {
-                       rcu_assign_pointer(*tp, t->next);
-                       break;
-               }
-       }
-}
-
-static void vti_tunnel_link(struct vti_net *ipn, struct ip_tunnel *t)
-{
-       struct ip_tunnel __rcu **tp = vti_bucket(ipn, t);
-
-       rcu_assign_pointer(t->next, rtnl_dereference(*tp));
-       rcu_assign_pointer(*tp, t);
-}
-
-static struct ip_tunnel *vti_tunnel_locate(struct net *net,
-                                          struct ip_tunnel_parm *parms,
-                                          int create)
-{
-       __be32 remote = parms->iph.daddr;
-       __be32 local = parms->iph.saddr;
-       struct ip_tunnel *t, *nt;
-       struct ip_tunnel __rcu **tp;
-       struct net_device *dev;
-       char name[IFNAMSIZ];
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-
-       for (tp = __vti_bucket(ipn, parms);
-            (t = rtnl_dereference(*tp)) != NULL;
-            tp = &t->next) {
-               if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr)
-                       return t;
-       }
-       if (!create)
-               return NULL;
-
-       if (parms->name[0])
-               strlcpy(name, parms->name, IFNAMSIZ);
-       else
-               strcpy(name, "vti%d");
-
-       dev = alloc_netdev(sizeof(*t), name, vti_tunnel_setup);
-       if (dev == NULL)
-               return NULL;
-
-       dev_net_set(dev, net);
-
-       nt = netdev_priv(dev);
-       nt->parms = *parms;
-       dev->rtnl_link_ops = &vti_link_ops;
-
-       vti_tunnel_bind_dev(dev);
-
-       if (register_netdevice(dev) < 0)
-               goto failed_free;
-
-       dev_hold(dev);
-       vti_tunnel_link(ipn, nt);
-       return nt;
-
-failed_free:
-       free_netdev(dev);
-       return NULL;
-}
-
-static void vti_tunnel_uninit(struct net_device *dev)
-{
-       struct net *net = dev_net(dev);
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-
-       vti_tunnel_unlink(ipn, netdev_priv(dev));
-       dev_put(dev);
-}
 
 static int vti_err(struct sk_buff *skb, u32 info)
 {
@@ -222,6 +56,8 @@ static int vti_err(struct sk_buff *skb, u32 info)
         * 8 bytes of packet payload. It means, that precise relaying of
         * ICMP in the real Internet is absolutely infeasible.
         */
+       struct net *net = dev_net(skb->dev);
+       struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
        struct iphdr *iph = (struct iphdr *)skb->data;
        const int type = icmp_hdr(skb)->type;
        const int code = icmp_hdr(skb)->code;
@@ -252,7 +88,8 @@ static int vti_err(struct sk_buff *skb, u32 info)
 
        err = -ENOENT;
 
-       t = vti_tunnel_lookup(dev_net(skb->dev), iph->daddr, iph->saddr);
+       t = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
+                            iph->daddr, iph->saddr, 0);
        if (t == NULL)
                goto out;
 
@@ -281,8 +118,11 @@ static int vti_rcv(struct sk_buff *skb)
 {
        struct ip_tunnel *tunnel;
        const struct iphdr *iph = ip_hdr(skb);
+       struct net *net = dev_net(skb->dev);
+       struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
 
-       tunnel = vti_tunnel_lookup(dev_net(skb->dev), iph->saddr, iph->daddr);
+       tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
+                                 iph->saddr, iph->daddr, 0);
        if (tunnel != NULL) {
                struct pcpu_tstats *tstats;
 
@@ -311,7 +151,6 @@ static int vti_rcv(struct sk_buff *skb)
 static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
-       struct pcpu_tstats *tstats;
        struct iphdr  *tiph = &tunnel->parms.iph;
        u8     tos;
        struct rtable *rt;              /* Route to the other host */
@@ -319,6 +158,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
        struct iphdr  *old_iph = ip_hdr(skb);
        __be32 dst = tiph->daddr;
        struct flowi4 fl4;
+       int err;
 
        if (skb->protocol != htons(ETH_P_IP))
                goto tx_error;
@@ -367,8 +207,10 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
        nf_reset(skb);
        skb->dev = skb_dst(skb)->dev;
 
-       tstats = this_cpu_ptr(dev->tstats);
-       VTI_XMIT(tstats, &dev->stats);
+       err = dst_output(skb);
+       if (net_xmit_eval(err) == 0)
+               err = skb->len;
+       iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
        return NETDEV_TX_OK;
 
 tx_error_icmp:
@@ -379,198 +221,57 @@ tx_error:
        return NETDEV_TX_OK;
 }
 
-static int vti_tunnel_bind_dev(struct net_device *dev)
-{
-       struct net_device *tdev = NULL;
-       struct ip_tunnel *tunnel;
-       struct iphdr *iph;
-
-       tunnel = netdev_priv(dev);
-       iph = &tunnel->parms.iph;
-
-       if (iph->daddr) {
-               struct rtable *rt;
-               struct flowi4 fl4;
-               memset(&fl4, 0, sizeof(fl4));
-               flowi4_init_output(&fl4, tunnel->parms.link,
-                                  be32_to_cpu(tunnel->parms.i_key),
-                                  RT_TOS(iph->tos), RT_SCOPE_UNIVERSE,
-                                  IPPROTO_IPIP, 0,
-                                  iph->daddr, iph->saddr, 0, 0);
-               rt = ip_route_output_key(dev_net(dev), &fl4);
-               if (!IS_ERR(rt)) {
-                       tdev = rt->dst.dev;
-                       ip_rt_put(rt);
-               }
-               dev->flags |= IFF_POINTOPOINT;
-       }
-
-       if (!tdev && tunnel->parms.link)
-               tdev = __dev_get_by_index(dev_net(dev), tunnel->parms.link);
-
-       if (tdev) {
-               dev->hard_header_len = tdev->hard_header_len +
-                                      sizeof(struct iphdr);
-               dev->mtu = tdev->mtu;
-       }
-       dev->iflink = tunnel->parms.link;
-       return dev->mtu;
-}
-
 static int
 vti_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
        int err = 0;
        struct ip_tunnel_parm p;
-       struct ip_tunnel *t;
-       struct net *net = dev_net(dev);
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-
-       switch (cmd) {
-       case SIOCGETTUNNEL:
-               t = NULL;
-               if (dev == ipn->fb_tunnel_dev) {
-                       if (copy_from_user(&p, ifr->ifr_ifru.ifru_data,
-                                          sizeof(p))) {
-                               err = -EFAULT;
-                               break;
-                       }
-                       t = vti_tunnel_locate(net, &p, 0);
-               }
-               if (t == NULL)
-                       t = netdev_priv(dev);
-               memcpy(&p, &t->parms, sizeof(p));
-               p.i_flags |= GRE_KEY | VTI_ISVTI;
-               p.o_flags |= GRE_KEY;
-               if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
-                       err = -EFAULT;
-               break;
-
-       case SIOCADDTUNNEL:
-       case SIOCCHGTUNNEL:
-               err = -EPERM;
-               if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
-                       goto done;
 
-               err = -EFAULT;
-               if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
-                       goto done;
+       if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
+               return -EFAULT;
 
-               err = -EINVAL;
+       if (cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) {
                if (p.iph.version != 4 || p.iph.protocol != IPPROTO_IPIP ||
                    p.iph.ihl != 5)
-                       goto done;
-
-               t = vti_tunnel_locate(net, &p, cmd == SIOCADDTUNNEL);
-
-               if (dev != ipn->fb_tunnel_dev && cmd == SIOCCHGTUNNEL) {
-                       if (t != NULL) {
-                               if (t->dev != dev) {
-                                       err = -EEXIST;
-                                       break;
-                               }
-                       } else {
-                               if (((dev->flags&IFF_POINTOPOINT) &&
-                                   !p.iph.daddr) ||
-                                   (!(dev->flags&IFF_POINTOPOINT) &&
-                                   p.iph.daddr)) {
-                                       err = -EINVAL;
-                                       break;
-                               }
-                               t = netdev_priv(dev);
-                               vti_tunnel_unlink(ipn, t);
-                               synchronize_net();
-                               t->parms.iph.saddr = p.iph.saddr;
-                               t->parms.iph.daddr = p.iph.daddr;
-                               t->parms.i_key = p.i_key;
-                               t->parms.o_key = p.o_key;
-                               t->parms.iph.protocol = IPPROTO_IPIP;
-                               memcpy(dev->dev_addr, &p.iph.saddr, 4);
-                               memcpy(dev->broadcast, &p.iph.daddr, 4);
-                               vti_tunnel_link(ipn, t);
-                               netdev_state_change(dev);
-                       }
-               }
-
-               if (t) {
-                       err = 0;
-                       if (cmd == SIOCCHGTUNNEL) {
-                               t->parms.i_key = p.i_key;
-                               t->parms.o_key = p.o_key;
-                               if (t->parms.link != p.link) {
-                                       t->parms.link = p.link;
-                                       vti_tunnel_bind_dev(dev);
-                                       netdev_state_change(dev);
-                               }
-                       }
-                       p.i_flags |= GRE_KEY | VTI_ISVTI;
-                       p.o_flags |= GRE_KEY;
-                       if (copy_to_user(ifr->ifr_ifru.ifru_data, &t->parms,
-                                        sizeof(p)))
-                               err = -EFAULT;
-               } else
-                       err = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT);
-               break;
+                       return -EINVAL;
+       }
 
-       case SIOCDELTUNNEL:
-               err = -EPERM;
-               if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
-                       goto done;
-
-               if (dev == ipn->fb_tunnel_dev) {
-                       err = -EFAULT;
-                       if (copy_from_user(&p, ifr->ifr_ifru.ifru_data,
-                                          sizeof(p)))
-                               goto done;
-                       err = -ENOENT;
-
-                       t = vti_tunnel_locate(net, &p, 0);
-                       if (t == NULL)
-                               goto done;
-                       err = -EPERM;
-                       if (t->dev == ipn->fb_tunnel_dev)
-                               goto done;
-                       dev = t->dev;
-               }
-               unregister_netdevice(dev);
-               err = 0;
-               break;
+       err = ip_tunnel_ioctl(dev, &p, cmd);
+       if (err)
+               return err;
 
-       default:
-               err = -EINVAL;
+       if (cmd != SIOCDELTUNNEL) {
+               p.i_flags |= GRE_KEY | VTI_ISVTI;
+               p.o_flags |= GRE_KEY;
        }
 
-done:
-       return err;
-}
-
-static int vti_tunnel_change_mtu(struct net_device *dev, int new_mtu)
-{
-       if (new_mtu < 68 || new_mtu > 0xFFF8)
-               return -EINVAL;
-       dev->mtu = new_mtu;
+       if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
+               return -EFAULT;
        return 0;
 }
 
 static const struct net_device_ops vti_netdev_ops = {
        .ndo_init       = vti_tunnel_init,
-       .ndo_uninit     = vti_tunnel_uninit,
+       .ndo_uninit     = ip_tunnel_uninit,
        .ndo_start_xmit = vti_tunnel_xmit,
        .ndo_do_ioctl   = vti_tunnel_ioctl,
-       .ndo_change_mtu = vti_tunnel_change_mtu,
+       .ndo_change_mtu = ip_tunnel_change_mtu,
        .ndo_get_stats64 = ip_tunnel_get_stats64,
 };
 
-static void vti_dev_free(struct net_device *dev)
+static void vti_tunnel_setup(struct net_device *dev)
 {
-       free_percpu(dev->tstats);
-       free_netdev(dev);
+       dev->netdev_ops         = &vti_netdev_ops;
+       ip_tunnel_setup(dev, vti_net_id);
 }
 
-static void vti_tunnel_setup(struct net_device *dev)
+static int vti_tunnel_init(struct net_device *dev)
 {
-       dev->netdev_ops         = &vti_netdev_ops;
-       dev->destructor         = vti_dev_free;
+       struct ip_tunnel *tunnel = netdev_priv(dev);
+       struct iphdr *iph = &tunnel->parms.iph;
+
+       memcpy(dev->dev_addr, &iph->saddr, 4);
+       memcpy(dev->broadcast, &iph->daddr, 4);
 
        dev->type               = ARPHRD_TUNNEL;
        dev->hard_header_len    = LL_MAX_HEADER + sizeof(struct iphdr);
@@ -581,38 +282,18 @@ static void vti_tunnel_setup(struct net_device *dev)
        dev->features           |= NETIF_F_NETNS_LOCAL;
        dev->features           |= NETIF_F_LLTX;
        dev->priv_flags         &= ~IFF_XMIT_DST_RELEASE;
-}
 
-static int vti_tunnel_init(struct net_device *dev)
-{
-       struct ip_tunnel *tunnel = netdev_priv(dev);
-
-       tunnel->dev = dev;
-       strcpy(tunnel->parms.name, dev->name);
-
-       memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
-       memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
-
-       dev->tstats = alloc_percpu(struct pcpu_tstats);
-       if (!dev->tstats)
-               return -ENOMEM;
-
-       return 0;
+       return ip_tunnel_init(dev);
 }
 
-static int __net_init vti_fb_tunnel_init(struct net_device *dev)
+static void __net_init vti_fb_tunnel_init(struct net_device *dev)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
        struct iphdr *iph = &tunnel->parms.iph;
-       struct vti_net *ipn = net_generic(dev_net(dev), vti_net_id);
 
        iph->version            = 4;
        iph->protocol           = IPPROTO_IPIP;
        iph->ihl                = 5;
-
-       dev_hold(dev);
-       rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
-       return 0;
 }
 
 static struct xfrm_tunnel vti_handler __read_mostly = {
@@ -621,76 +302,30 @@ static struct xfrm_tunnel vti_handler __read_mostly = {
        .priority       =       1,
 };
 
-static void vti_destroy_tunnels(struct vti_net *ipn, struct list_head *head)
-{
-       int prio;
-
-       for (prio = 1; prio < 4; prio++) {
-               int h;
-               for (h = 0; h < HASH_SIZE; h++) {
-                       struct ip_tunnel *t;
-
-                       t = rtnl_dereference(ipn->tunnels[prio][h]);
-                       while (t != NULL) {
-                               unregister_netdevice_queue(t->dev, head);
-                               t = rtnl_dereference(t->next);
-                       }
-               }
-       }
-}
-
 static int __net_init vti_init_net(struct net *net)
 {
        int err;
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-
-       ipn->tunnels[0] = ipn->tunnels_wc;
-       ipn->tunnels[1] = ipn->tunnels_l;
-       ipn->tunnels[2] = ipn->tunnels_r;
-       ipn->tunnels[3] = ipn->tunnels_r_l;
-
-       ipn->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel),
-                                         "ip_vti0",
-                                         vti_tunnel_setup);
-       if (!ipn->fb_tunnel_dev) {
-               err = -ENOMEM;
-               goto err_alloc_dev;
-       }
-       dev_net_set(ipn->fb_tunnel_dev, net);
-
-       err = vti_fb_tunnel_init(ipn->fb_tunnel_dev);
-       if (err)
-               goto err_reg_dev;
-       ipn->fb_tunnel_dev->rtnl_link_ops = &vti_link_ops;
+       struct ip_tunnel_net *itn;
 
-       err = register_netdev(ipn->fb_tunnel_dev);
+       err = ip_tunnel_init_net(net, vti_net_id, &vti_link_ops, "ip_vti0");
        if (err)
-               goto err_reg_dev;
+               return err;
+       itn = net_generic(net, vti_net_id);
+       vti_fb_tunnel_init(itn->fb_tunnel_dev);
        return 0;
-
-err_reg_dev:
-       vti_dev_free(ipn->fb_tunnel_dev);
-err_alloc_dev:
-       /* nothing */
-       return err;
 }
 
 static void __net_exit vti_exit_net(struct net *net)
 {
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-       LIST_HEAD(list);
-
-       rtnl_lock();
-       vti_destroy_tunnels(ipn, &list);
-       unregister_netdevice_many(&list);
-       rtnl_unlock();
+       struct ip_tunnel_net *itn = net_generic(net, vti_net_id);
+       ip_tunnel_delete_net(itn, &vti_link_ops);
 }
 
 static struct pernet_operations vti_net_ops = {
        .init = vti_init_net,
        .exit = vti_exit_net,
        .id   = &vti_net_id,
-       .size = sizeof(struct vti_net),
+       .size = sizeof(struct ip_tunnel_net),
 };
 
 static int vti_tunnel_validate(struct nlattr *tb[], struct nlattr *data[])
@@ -728,78 +363,19 @@ static void vti_netlink_parms(struct nlattr *data[],
 static int vti_newlink(struct net *src_net, struct net_device *dev,
                       struct nlattr *tb[], struct nlattr *data[])
 {
-       struct ip_tunnel *nt;
-       struct net *net = dev_net(dev);
-       struct vti_net *ipn = net_generic(net, vti_net_id);
-       int mtu;
-       int err;
-
-       nt = netdev_priv(dev);
-       vti_netlink_parms(data, &nt->parms);
-
-       if (vti_tunnel_locate(net, &nt->parms, 0))
-               return -EEXIST;
+       struct ip_tunnel_parm parms;
 
-       mtu = vti_tunnel_bind_dev(dev);
-       if (!tb[IFLA_MTU])
-               dev->mtu = mtu;
-
-       err = register_netdevice(dev);
-       if (err)
-               goto out;
-
-       dev_hold(dev);
-       vti_tunnel_link(ipn, nt);
-
-out:
-       return err;
+       vti_netlink_parms(data, &parms);
+       return ip_tunnel_newlink(dev, tb, &parms);
 }
 
 static int vti_changelink(struct net_device *dev, struct nlattr *tb[],
                          struct nlattr *data[])
 {
-       struct ip_tunnel *t, *nt;
-       struct net *net = dev_net(dev);
-       struct vti_net *ipn = net_generic(net, vti_net_id);
        struct ip_tunnel_parm p;
-       int mtu;
-
-       if (dev == ipn->fb_tunnel_dev)
-               return -EINVAL;
 
-       nt = netdev_priv(dev);
        vti_netlink_parms(data, &p);
-
-       t = vti_tunnel_locate(net, &p, 0);
-
-       if (t) {
-               if (t->dev != dev)
-                       return -EEXIST;
-       } else {
-               t = nt;
-
-               vti_tunnel_unlink(ipn, t);
-               t->parms.iph.saddr = p.iph.saddr;
-               t->parms.iph.daddr = p.iph.daddr;
-               t->parms.i_key = p.i_key;
-               t->parms.o_key = p.o_key;
-               if (dev->type != ARPHRD_ETHER) {
-                       memcpy(dev->dev_addr, &p.iph.saddr, 4);
-                       memcpy(dev->broadcast, &p.iph.daddr, 4);
-               }
-               vti_tunnel_link(ipn, t);
-               netdev_state_change(dev);
-       }
-
-       if (t->parms.link != p.link) {
-               t->parms.link = p.link;
-               mtu = vti_tunnel_bind_dev(dev);
-               if (!tb[IFLA_MTU])
-                       dev->mtu = mtu;
-               netdev_state_change(dev);
-       }
-
-       return 0;
+       return ip_tunnel_changelink(dev, tb, &p);
 }
 
 static size_t vti_get_size(const struct net_device *dev)
@@ -865,7 +441,7 @@ static int __init vti_init(void)
        err = xfrm4_mode_tunnel_input_register(&vti_handler);
        if (err < 0) {
                unregister_pernet_device(&vti_net_ops);
-               pr_info(KERN_INFO "vti init: can't register tunnel\n");
+               pr_info("vti init: can't register tunnel\n");
        }
 
        err = rtnl_link_register(&vti_link_ops);
index 51fc2a1dcdd3aa564147933d7485ec6356e9ad12..87bd2952c7334e54ed49b1fa6bf5cb8237269ba6 100644 (file)
@@ -286,7 +286,6 @@ static void ipip_tunnel_setup(struct net_device *dev)
        dev->flags              = IFF_NOARP;
        dev->iflink             = 0;
        dev->addr_len           = 4;
-       dev->features           |= NETIF_F_NETNS_LOCAL;
        dev->features           |= NETIF_F_LLTX;
        dev->priv_flags         &= ~IFF_XMIT_DST_RELEASE;
 
@@ -437,7 +436,7 @@ static int __net_init ipip_init_net(struct net *net)
 static void __net_exit ipip_exit_net(struct net *net)
 {
        struct ip_tunnel_net *itn = net_generic(net, ipip_net_id);
-       ip_tunnel_delete_net(itn);
+       ip_tunnel_delete_net(itn, &ipip_link_ops);
 }
 
 static struct pernet_operations ipip_net_ops = {
index 132a09664704ed73ed850e8961f11fa3e3641473..bacc0bcf48ce5b1cec365e5886d820492d41566d 100644 (file)
@@ -127,9 +127,9 @@ static struct kmem_cache *mrt_cachep __read_mostly;
 static struct mr_table *ipmr_new_table(struct net *net, u32 id);
 static void ipmr_free_table(struct mr_table *mrt);
 
-static int ip_mr_forward(struct net *net, struct mr_table *mrt,
-                        struct sk_buff *skb, struct mfc_cache *cache,
-                        int local);
+static void ip_mr_forward(struct net *net, struct mr_table *mrt,
+                         struct sk_buff *skb, struct mfc_cache *cache,
+                         int local);
 static int ipmr_cache_report(struct mr_table *mrt,
                             struct sk_buff *pkt, vifi_t vifi, int assert);
 static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
@@ -1795,9 +1795,9 @@ static int ipmr_find_vif(struct mr_table *mrt, struct net_device *dev)
 
 /* "local" means that we should preserve one skb (for local delivery) */
 
-static int ip_mr_forward(struct net *net, struct mr_table *mrt,
-                        struct sk_buff *skb, struct mfc_cache *cache,
-                        int local)
+static void ip_mr_forward(struct net *net, struct mr_table *mrt,
+                         struct sk_buff *skb, struct mfc_cache *cache,
+                         int local)
 {
        int psend = -1;
        int vif, ct;
@@ -1903,14 +1903,13 @@ last_forward:
                                ipmr_queue_xmit(net, mrt, skb2, cache, psend);
                } else {
                        ipmr_queue_xmit(net, mrt, skb, cache, psend);
-                       return 0;
+                       return;
                }
        }
 
 dont_forward:
        if (!local)
                kfree_skb(skb);
-       return 0;
 }
 
 static struct mr_table *ipmr_rt_fib_lookup(struct net *net, struct sk_buff *skb)
index 4e9028017428405ef2005f7558406c5ba3086a24..1657e39b291f2ae8747e21e944627def23ebfcbb 100644 (file)
@@ -110,6 +110,19 @@ config IP_NF_TARGET_REJECT
 
          To compile it as a module, choose M here.  If unsure, say N.
 
+config IP_NF_TARGET_SYNPROXY
+       tristate "SYNPROXY target support"
+       depends on NF_CONNTRACK && NETFILTER_ADVANCED
+       select NETFILTER_SYNPROXY
+       select SYN_COOKIES
+       help
+         The SYNPROXY target allows you to intercept TCP connections and
+         establish them using syncookies before they are passed on to the
+         server. This allows to avoid conntrack and server resource usage
+         during SYN-flood attacks.
+
+         To compile it as a module, choose M here. If unsure, say N.
+
 config IP_NF_TARGET_ULOG
        tristate "ULOG target support (obsolete)"
        default m if NETFILTER_ADVANCED=n
index 007b128eecc90246af3353f1e210bb07f267fe20..3622b248b6dd7ad78aa4411243b4b507731d7e2b 100644 (file)
@@ -46,6 +46,7 @@ obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
+obj-$(CONFIG_IP_NF_TARGET_SYNPROXY) += ipt_SYNPROXY.o
 obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
 
 # generic ARP tables
index 30e4de94056722535ee5304e93b49bfb6c5cf889..00352ce0f0dec43f0f0d08e0e77115c97625ab89 100644 (file)
@@ -118,7 +118,7 @@ static int masq_device_event(struct notifier_block *this,
                NF_CT_ASSERT(dev->ifindex != 0);
 
                nf_ct_iterate_cleanup(net, device_cmp,
-                                     (void *)(long)dev->ifindex);
+                                     (void *)(long)dev->ifindex, 0, 0);
        }
 
        return NOTIFY_DONE;
index 04b18c1ac3458503a2b5d79bd7fd1547c13e76d7..b969131ad1c198c6983b07fb1903abd2498f1374 100644 (file)
@@ -119,7 +119,26 @@ static void send_reset(struct sk_buff *oldskb, int hook)
 
        nf_ct_attach(nskb, oldskb);
 
-       ip_local_out(nskb);
+#ifdef CONFIG_BRIDGE_NETFILTER
+       /* If we use ip_local_out for bridged traffic, the MAC source on
+        * the RST will be ours, instead of the destination's.  This confuses
+        * some routers/firewalls, and they drop the packet.  So we need to
+        * build the eth header using the original destination's MAC as the
+        * source, and send the RST packet directly.
+        */
+       if (oldskb->nf_bridge) {
+               struct ethhdr *oeth = eth_hdr(oldskb);
+               nskb->dev = oldskb->nf_bridge->physindev;
+               niph->tot_len = htons(nskb->len);
+               ip_send_check(niph);
+               if (dev_hard_header(nskb, nskb->dev, ntohs(nskb->protocol),
+                                   oeth->h_source, oeth->h_dest, nskb->len) < 0)
+                       goto free_nskb;
+               dev_queue_xmit(nskb);
+       } else
+#endif
+               ip_local_out(nskb);
+
        return;
 
  free_nskb:
diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c
new file mode 100644 (file)
index 0000000..94371db
--- /dev/null
@@ -0,0 +1,472 @@
+/*
+ * Copyright (c) 2013 Patrick McHardy <kaber@trash.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <net/tcp.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_SYNPROXY.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
+#include <net/netfilter/nf_conntrack_synproxy.h>
+
+static struct iphdr *
+synproxy_build_ip(struct sk_buff *skb, u32 saddr, u32 daddr)
+{
+       struct iphdr *iph;
+
+       skb_reset_network_header(skb);
+       iph = (struct iphdr *)skb_put(skb, sizeof(*iph));
+       iph->version    = 4;
+       iph->ihl        = sizeof(*iph) / 4;
+       iph->tos        = 0;
+       iph->id         = 0;
+       iph->frag_off   = htons(IP_DF);
+       iph->ttl        = sysctl_ip_default_ttl;
+       iph->protocol   = IPPROTO_TCP;
+       iph->check      = 0;
+       iph->saddr      = saddr;
+       iph->daddr      = daddr;
+
+       return iph;
+}
+
+static void
+synproxy_send_tcp(const struct sk_buff *skb, struct sk_buff *nskb,
+                 struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo,
+                 struct iphdr *niph, struct tcphdr *nth,
+                 unsigned int tcp_hdr_size)
+{
+       nth->check = ~tcp_v4_check(tcp_hdr_size, niph->saddr, niph->daddr, 0);
+       nskb->ip_summed   = CHECKSUM_PARTIAL;
+       nskb->csum_start  = (unsigned char *)nth - nskb->head;
+       nskb->csum_offset = offsetof(struct tcphdr, check);
+
+       skb_dst_set_noref(nskb, skb_dst(skb));
+       nskb->protocol = htons(ETH_P_IP);
+       if (ip_route_me_harder(nskb, RTN_UNSPEC))
+               goto free_nskb;
+
+       if (nfct) {
+               nskb->nfct = nfct;
+               nskb->nfctinfo = ctinfo;
+               nf_conntrack_get(nfct);
+       }
+
+       ip_local_out(nskb);
+       return;
+
+free_nskb:
+       kfree_skb(nskb);
+}
+
+static void
+synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th,
+                           const struct synproxy_options *opts)
+{
+       struct sk_buff *nskb;
+       struct iphdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+       u16 mss = opts->mss;
+
+       iph = ip_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, iph->daddr, iph->saddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->dest;
+       nth->dest       = th->source;
+       nth->seq        = htonl(__cookie_v4_init_sequence(iph, th, &mss));
+       nth->ack_seq    = htonl(ntohl(th->seq) + 1);
+       tcp_flag_word(nth) = TCP_FLAG_SYN | TCP_FLAG_ACK;
+       if (opts->options & XT_SYNPROXY_OPT_ECN)
+               tcp_flag_word(nth) |= TCP_FLAG_ECE;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = 0;
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
+                         niph, nth, tcp_hdr_size);
+}
+
+static void
+synproxy_send_server_syn(const struct synproxy_net *snet,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        const struct synproxy_options *opts, u32 recv_seq)
+{
+       struct sk_buff *nskb;
+       struct iphdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+
+       iph = ip_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, iph->saddr, iph->daddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->source;
+       nth->dest       = th->dest;
+       nth->seq        = htonl(recv_seq - 1);
+       /* ack_seq is used to relay our ISN to the synproxy hook to initialize
+        * sequence number translation once a connection tracking entry exists.
+        */
+       nth->ack_seq    = htonl(ntohl(th->ack_seq) - 1);
+       tcp_flag_word(nth) = TCP_FLAG_SYN;
+       if (opts->options & XT_SYNPROXY_OPT_ECN)
+               tcp_flag_word(nth) |= TCP_FLAG_ECE | TCP_FLAG_CWR;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = th->window;
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW,
+                         niph, nth, tcp_hdr_size);
+}
+
+static void
+synproxy_send_server_ack(const struct synproxy_net *snet,
+                        const struct ip_ct_tcp *state,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        const struct synproxy_options *opts)
+{
+       struct sk_buff *nskb;
+       struct iphdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+
+       iph = ip_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, iph->daddr, iph->saddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->dest;
+       nth->dest       = th->source;
+       nth->seq        = htonl(ntohl(th->ack_seq));
+       nth->ack_seq    = htonl(ntohl(th->seq) + 1);
+       tcp_flag_word(nth) = TCP_FLAG_ACK;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = htons(state->seen[IP_CT_DIR_ORIGINAL].td_maxwin);
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
+}
+
+static void
+synproxy_send_client_ack(const struct synproxy_net *snet,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        const struct synproxy_options *opts)
+{
+       struct sk_buff *nskb;
+       struct iphdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+
+       iph = ip_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, iph->saddr, iph->daddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->source;
+       nth->dest       = th->dest;
+       nth->seq        = htonl(ntohl(th->seq) + 1);
+       nth->ack_seq    = th->ack_seq;
+       tcp_flag_word(nth) = TCP_FLAG_ACK;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = ntohs(htons(th->window) >> opts->wscale);
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
+}
+
+static bool
+synproxy_recv_client_ack(const struct synproxy_net *snet,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        struct synproxy_options *opts, u32 recv_seq)
+{
+       int mss;
+
+       mss = __cookie_v4_check(ip_hdr(skb), th, ntohl(th->ack_seq) - 1);
+       if (mss == 0) {
+               this_cpu_inc(snet->stats->cookie_invalid);
+               return false;
+       }
+
+       this_cpu_inc(snet->stats->cookie_valid);
+       opts->mss = mss;
+
+       if (opts->options & XT_SYNPROXY_OPT_TIMESTAMP)
+               synproxy_check_timestamp_cookie(opts);
+
+       synproxy_send_server_syn(snet, skb, th, opts, recv_seq);
+       return true;
+}
+
+static unsigned int
+synproxy_tg4(struct sk_buff *skb, const struct xt_action_param *par)
+{
+       const struct xt_synproxy_info *info = par->targinfo;
+       struct synproxy_net *snet = synproxy_pernet(dev_net(par->in));
+       struct synproxy_options opts = {};
+       struct tcphdr *th, _th;
+
+       if (nf_ip_checksum(skb, par->hooknum, par->thoff, IPPROTO_TCP))
+               return NF_DROP;
+
+       th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
+       if (th == NULL)
+               return NF_DROP;
+
+       synproxy_parse_options(skb, par->thoff, th, &opts);
+
+       if (th->syn && !th->ack) {
+               /* Initial SYN from client */
+               this_cpu_inc(snet->stats->syn_received);
+
+               if (th->ece && th->cwr)
+                       opts.options |= XT_SYNPROXY_OPT_ECN;
+
+               opts.options &= info->options;
+               if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
+                       synproxy_init_timestamp_cookie(info, &opts);
+               else
+                       opts.options &= ~(XT_SYNPROXY_OPT_WSCALE |
+                                         XT_SYNPROXY_OPT_SACK_PERM |
+                                         XT_SYNPROXY_OPT_ECN);
+
+               synproxy_send_client_synack(skb, th, &opts);
+       } else if (th->ack && !(th->fin || th->rst))
+               /* ACK from client */
+               synproxy_recv_client_ack(snet, skb, th, &opts, ntohl(th->seq));
+
+       return NF_DROP;
+}
+
+static unsigned int ipv4_synproxy_hook(unsigned int hooknum,
+                                      struct sk_buff *skb,
+                                      const struct net_device *in,
+                                      const struct net_device *out,
+                                      int (*okfn)(struct sk_buff *))
+{
+       struct synproxy_net *snet = synproxy_pernet(dev_net(in ? : out));
+       enum ip_conntrack_info ctinfo;
+       struct nf_conn *ct;
+       struct nf_conn_synproxy *synproxy;
+       struct synproxy_options opts = {};
+       const struct ip_ct_tcp *state;
+       struct tcphdr *th, _th;
+       unsigned int thoff;
+
+       ct = nf_ct_get(skb, &ctinfo);
+       if (ct == NULL)
+               return NF_ACCEPT;
+
+       synproxy = nfct_synproxy(ct);
+       if (synproxy == NULL)
+               return NF_ACCEPT;
+
+       if (nf_is_loopback_packet(skb))
+               return NF_ACCEPT;
+
+       thoff = ip_hdrlen(skb);
+       th = skb_header_pointer(skb, thoff, sizeof(_th), &_th);
+       if (th == NULL)
+               return NF_DROP;
+
+       state = &ct->proto.tcp;
+       switch (state->state) {
+       case TCP_CONNTRACK_CLOSE:
+               if (th->rst && !test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
+                       nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
+                                                     ntohl(th->seq) + 1);
+                       break;
+               }
+
+               if (!th->syn || th->ack ||
+                   CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL)
+                       break;
+
+               /* Reopened connection - reset the sequence number and timestamp
+                * adjustments, they will get initialized once the connection is
+                * reestablished.
+                */
+               nf_ct_seqadj_init(ct, ctinfo, 0);
+               synproxy->tsoff = 0;
+               this_cpu_inc(snet->stats->conn_reopened);
+
+               /* fall through */
+       case TCP_CONNTRACK_SYN_SENT:
+               synproxy_parse_options(skb, thoff, th, &opts);
+
+               if (!th->syn && th->ack &&
+                   CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) {
+                       /* Keep-Alives are sent with SEG.SEQ = SND.NXT-1,
+                        * therefore we need to add 1 to make the SYN sequence
+                        * number match the one of first SYN.
+                        */
+                       if (synproxy_recv_client_ack(snet, skb, th, &opts,
+                                                    ntohl(th->seq) + 1))
+                               this_cpu_inc(snet->stats->cookie_retrans);
+
+                       return NF_DROP;
+               }
+
+               synproxy->isn = ntohl(th->ack_seq);
+               if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
+                       synproxy->its = opts.tsecr;
+               break;
+       case TCP_CONNTRACK_SYN_RECV:
+               if (!th->syn || !th->ack)
+                       break;
+
+               synproxy_parse_options(skb, thoff, th, &opts);
+               if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
+                       synproxy->tsoff = opts.tsval - synproxy->its;
+
+               opts.options &= ~(XT_SYNPROXY_OPT_MSS |
+                                 XT_SYNPROXY_OPT_WSCALE |
+                                 XT_SYNPROXY_OPT_SACK_PERM);
+
+               swap(opts.tsval, opts.tsecr);
+               synproxy_send_server_ack(snet, state, skb, th, &opts);
+
+               nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
+
+               swap(opts.tsval, opts.tsecr);
+               synproxy_send_client_ack(snet, skb, th, &opts);
+
+               consume_skb(skb);
+               return NF_STOLEN;
+       default:
+               break;
+       }
+
+       synproxy_tstamp_adjust(skb, thoff, th, ct, ctinfo, synproxy);
+       return NF_ACCEPT;
+}
+
+static int synproxy_tg4_check(const struct xt_tgchk_param *par)
+{
+       const struct ipt_entry *e = par->entryinfo;
+
+       if (e->ip.proto != IPPROTO_TCP ||
+           e->ip.invflags & XT_INV_PROTO)
+               return -EINVAL;
+
+       return nf_ct_l3proto_try_module_get(par->family);
+}
+
+static void synproxy_tg4_destroy(const struct xt_tgdtor_param *par)
+{
+       nf_ct_l3proto_module_put(par->family);
+}
+
+static struct xt_target synproxy_tg4_reg __read_mostly = {
+       .name           = "SYNPROXY",
+       .family         = NFPROTO_IPV4,
+       .target         = synproxy_tg4,
+       .targetsize     = sizeof(struct xt_synproxy_info),
+       .checkentry     = synproxy_tg4_check,
+       .destroy        = synproxy_tg4_destroy,
+       .me             = THIS_MODULE,
+};
+
+static struct nf_hook_ops ipv4_synproxy_ops[] __read_mostly = {
+       {
+               .hook           = ipv4_synproxy_hook,
+               .owner          = THIS_MODULE,
+               .pf             = NFPROTO_IPV4,
+               .hooknum        = NF_INET_LOCAL_IN,
+               .priority       = NF_IP_PRI_CONNTRACK_CONFIRM - 1,
+       },
+       {
+               .hook           = ipv4_synproxy_hook,
+               .owner          = THIS_MODULE,
+               .pf             = NFPROTO_IPV4,
+               .hooknum        = NF_INET_POST_ROUTING,
+               .priority       = NF_IP_PRI_CONNTRACK_CONFIRM - 1,
+       },
+};
+
+static int __init synproxy_tg4_init(void)
+{
+       int err;
+
+       err = nf_register_hooks(ipv4_synproxy_ops,
+                               ARRAY_SIZE(ipv4_synproxy_ops));
+       if (err < 0)
+               goto err1;
+
+       err = xt_register_target(&synproxy_tg4_reg);
+       if (err < 0)
+               goto err2;
+
+       return 0;
+
+err2:
+       nf_unregister_hooks(ipv4_synproxy_ops, ARRAY_SIZE(ipv4_synproxy_ops));
+err1:
+       return err;
+}
+
+static void __exit synproxy_tg4_exit(void)
+{
+       xt_unregister_target(&synproxy_tg4_reg);
+       nf_unregister_hooks(ipv4_synproxy_ops, ARRAY_SIZE(ipv4_synproxy_ops));
+}
+
+module_init(synproxy_tg4_init);
+module_exit(synproxy_tg4_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
index 0a2e0e3e95ba0e64e17d4e4ba6a47a8201a35dfe..86f5b34a4ed1865cd1438817bfb46f6eb589f61e 100644 (file)
@@ -25,6 +25,7 @@
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_zones.h>
 #include <net/netfilter/nf_conntrack_core.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
 #include <net/netfilter/nf_nat_helper.h>
 #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
@@ -136,11 +137,7 @@ static unsigned int ipv4_confirm(unsigned int hooknum,
        /* adjust seqs for loopback traffic only in outgoing direction */
        if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
            !nf_is_loopback_packet(skb)) {
-               typeof(nf_nat_seq_adjust_hook) seq_adjust;
-
-               seq_adjust = rcu_dereference(nf_nat_seq_adjust_hook);
-               if (!seq_adjust ||
-                   !seq_adjust(skb, ct, ctinfo, ip_hdrlen(skb))) {
+               if (!nf_ct_seq_adjust(skb, ct, ctinfo, ip_hdrlen(skb))) {
                        NF_CT_STAT_INC_ATOMIC(nf_ct_net(ct), drop);
                        return NF_DROP;
                }
index 746427c9e7199513c12f4254ce048234f108a35d..d7d9882d4caea169964a58e294ffe6c73a99d36c 100644 (file)
@@ -1082,7 +1082,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
        __u16 srcp = ntohs(inet->inet_sport);
 
        seq_printf(f, "%5d: %08X:%04X %08X:%04X"
-               " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %pK %d%n",
+               " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d%n",
                bucket, src, srcp, dest, destp, sp->sk_state,
                sk_wmem_alloc_get(sp),
                sk_rmem_alloc_get(sp),
index 6577a1149a47c17853e8c7e0e3daa267ef16d1cd..4a0335854b89c305442e257057ca560811159df8 100644 (file)
@@ -111,7 +111,7 @@ static const struct snmp_mib snmp4_ipstats_list[] = {
        SNMP_MIB_SENTINEL
 };
 
-/* Following RFC4293 items are displayed in /proc/net/netstat */
+/* Following items are displayed in /proc/net/netstat */
 static const struct snmp_mib snmp4_ipextstats_list[] = {
        SNMP_MIB_ITEM("InNoRoutes", IPSTATS_MIB_INNOROUTES),
        SNMP_MIB_ITEM("InTruncatedPkts", IPSTATS_MIB_INTRUNCATEDPKTS),
@@ -125,7 +125,12 @@ static const struct snmp_mib snmp4_ipextstats_list[] = {
        SNMP_MIB_ITEM("OutMcastOctets", IPSTATS_MIB_OUTMCASTOCTETS),
        SNMP_MIB_ITEM("InBcastOctets", IPSTATS_MIB_INBCASTOCTETS),
        SNMP_MIB_ITEM("OutBcastOctets", IPSTATS_MIB_OUTBCASTOCTETS),
+       /* Non RFC4293 fields */
        SNMP_MIB_ITEM("InCsumErrors", IPSTATS_MIB_CSUMERRORS),
+       SNMP_MIB_ITEM("InNoECTPkts", IPSTATS_MIB_NOECTPKTS),
+       SNMP_MIB_ITEM("InECT1Pkts", IPSTATS_MIB_ECT1PKTS),
+       SNMP_MIB_ITEM("InECT0Pkts", IPSTATS_MIB_ECT0PKTS),
+       SNMP_MIB_ITEM("InCEPkts", IPSTATS_MIB_CEPKTS),
        SNMP_MIB_SENTINEL
 };
 
@@ -273,7 +278,7 @@ static const struct snmp_mib snmp4_net_list[] = {
        SNMP_MIB_ITEM("TCPFastOpenListenOverflow", LINUX_MIB_TCPFASTOPENLISTENOVERFLOW),
        SNMP_MIB_ITEM("TCPFastOpenCookieReqd", LINUX_MIB_TCPFASTOPENCOOKIEREQD),
        SNMP_MIB_ITEM("TCPSpuriousRtxHostQueues", LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES),
-       SNMP_MIB_ITEM("LowLatencyRxPackets", LINUX_MIB_LOWLATENCYRXPACKETS),
+       SNMP_MIB_ITEM("BusyPollRxPackets", LINUX_MIB_BUSYPOLLRXPACKETS),
        SNMP_MIB_SENTINEL
 };
 
index dd44e0ab600cafe76ac50f74aaff5c6d429ea534..41d84505a9225af90386b135c4b053019070f7b4 100644 (file)
@@ -987,7 +987,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
              srcp  = inet->inet_num;
 
        seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
-               " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %pK %d\n",
+               " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n",
                i, src, srcp, dest, destp, sp->sk_state,
                sk_wmem_alloc_get(sp),
                sk_rmem_alloc_get(sp),
index a9a54a2368323243be30f536d45646d48ec6c42d..727f4365bcdff3acdb415fe75fd878a3bc5050af 100644 (file)
 #define RT_FL_TOS(oldflp4) \
        ((oldflp4)->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))
 
-#define IP_MAX_MTU     0xFFF0
+/* IPv4 datagram length is stored into 16bit field (tot_len) */
+#define IP_MAX_MTU     0xFFFF
 
 #define RT_GC_TIMEOUT (300*HZ)
 
@@ -435,12 +436,12 @@ static inline int ip_rt_proc_init(void)
 
 static inline bool rt_is_expired(const struct rtable *rth)
 {
-       return rth->rt_genid != rt_genid(dev_net(rth->dst.dev));
+       return rth->rt_genid != rt_genid_ipv4(dev_net(rth->dst.dev));
 }
 
 void rt_cache_flush(struct net *net)
 {
-       rt_genid_bump(net);
+       rt_genid_bump_ipv4(net);
 }
 
 static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
@@ -1227,10 +1228,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst)
                        mtu = 576;
        }
 
-       if (mtu > IP_MAX_MTU)
-               mtu = IP_MAX_MTU;
-
-       return mtu;
+       return min_t(unsigned int, mtu, IP_MAX_MTU);
 }
 
 static struct fib_nh_exception *find_exception(struct fib_nh *nh, __be32 daddr)
@@ -1458,7 +1456,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 #endif
        rth->dst.output = ip_rt_bug;
 
-       rth->rt_genid   = rt_genid(dev_net(dev));
+       rth->rt_genid   = rt_genid_ipv4(dev_net(dev));
        rth->rt_flags   = RTCF_MULTICAST;
        rth->rt_type    = RTN_MULTICAST;
        rth->rt_is_input= 1;
@@ -1589,7 +1587,7 @@ static int __mkroute_input(struct sk_buff *skb,
                goto cleanup;
        }
 
-       rth->rt_genid = rt_genid(dev_net(rth->dst.dev));
+       rth->rt_genid = rt_genid_ipv4(dev_net(rth->dst.dev));
        rth->rt_flags = flags;
        rth->rt_type = res->type;
        rth->rt_is_input = 1;
@@ -1760,7 +1758,7 @@ local_input:
        rth->dst.tclassid = itag;
 #endif
 
-       rth->rt_genid = rt_genid(net);
+       rth->rt_genid = rt_genid_ipv4(net);
        rth->rt_flags   = flags|RTCF_LOCAL;
        rth->rt_type    = res.type;
        rth->rt_is_input = 1;
@@ -1945,7 +1943,7 @@ add:
 
        rth->dst.output = ip_output;
 
-       rth->rt_genid = rt_genid(dev_net(dev_out));
+       rth->rt_genid = rt_genid_ipv4(dev_net(dev_out));
        rth->rt_flags   = flags;
        rth->rt_type    = type;
        rth->rt_is_input = 0;
@@ -2227,7 +2225,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
                rt->rt_iif = ort->rt_iif;
                rt->rt_pmtu = ort->rt_pmtu;
 
-               rt->rt_genid = rt_genid(net);
+               rt->rt_genid = rt_genid_ipv4(net);
                rt->rt_flags = ort->rt_flags;
                rt->rt_type = ort->rt_type;
                rt->rt_gateway = ort->rt_gateway;
@@ -2665,7 +2663,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
 
 static __net_init int rt_genid_init(struct net *net)
 {
-       atomic_set(&net->rt_genid, 0);
+       atomic_set(&net->ipv4.rt_genid, 0);
        atomic_set(&net->fnhe_genid, 0);
        get_random_bytes(&net->ipv4.dev_addr_genid,
                         sizeof(net->ipv4.dev_addr_genid));
index b05c96e7af8b810a62bb07d95436eea07c651008..14a15c49129df8984076c05c4dd757012fed03b3 100644 (file)
@@ -160,26 +160,33 @@ static __u16 const msstab[] = {
  * Generate a syncookie.  mssp points to the mss, which is returned
  * rounded down to the value encoded in the cookie.
  */
-__u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
+u32 __cookie_v4_init_sequence(const struct iphdr *iph, const struct tcphdr *th,
+                             u16 *mssp)
 {
-       const struct iphdr *iph = ip_hdr(skb);
-       const struct tcphdr *th = tcp_hdr(skb);
        int mssind;
        const __u16 mss = *mssp;
 
-       tcp_synq_overflow(sk);
-
        for (mssind = ARRAY_SIZE(msstab) - 1; mssind ; mssind--)
                if (mss >= msstab[mssind])
                        break;
        *mssp = msstab[mssind];
 
-       NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
-
        return secure_tcp_syn_cookie(iph->saddr, iph->daddr,
                                     th->source, th->dest, ntohl(th->seq),
                                     jiffies / (HZ * 60), mssind);
 }
+EXPORT_SYMBOL_GPL(__cookie_v4_init_sequence);
+
+__u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
+{
+       const struct iphdr *iph = ip_hdr(skb);
+       const struct tcphdr *th = tcp_hdr(skb);
+
+       tcp_synq_overflow(sk);
+       NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
+
+       return __cookie_v4_init_sequence(iph, th, mssp);
+}
 
 /*
  * This (misnamed) value is the age of syncookie which is permitted.
@@ -192,10 +199,9 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
  * Check if a ack sequence number is a valid syncookie.
  * Return the decoded mss if it is, or 0 if not.
  */
-static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
+int __cookie_v4_check(const struct iphdr *iph, const struct tcphdr *th,
+                     u32 cookie)
 {
-       const struct iphdr *iph = ip_hdr(skb);
-       const struct tcphdr *th = tcp_hdr(skb);
        __u32 seq = ntohl(th->seq) - 1;
        __u32 mssind = check_tcp_syn_cookie(cookie, iph->saddr, iph->daddr,
                                            th->source, th->dest, seq,
@@ -204,6 +210,7 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
 
        return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
 }
+EXPORT_SYMBOL_GPL(__cookie_v4_check);
 
 static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
                                           struct request_sock *req,
@@ -284,7 +291,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
                goto out;
 
        if (tcp_synq_no_recent_overflow(sk) ||
-           (mss = cookie_check(skb, cookie)) == 0) {
+           (mss = __cookie_v4_check(ip_hdr(skb), th, cookie)) == 0) {
                NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
                goto out;
        }
index b2c123c44d6947afe1f6d588808643c5db3be9b8..8ed7c32ae28e47bbb73052f4686643d0f5cf7eb6 100644 (file)
@@ -36,6 +36,8 @@ static int tcp_adv_win_scale_min = -31;
 static int tcp_adv_win_scale_max = 31;
 static int ip_ttl_min = 1;
 static int ip_ttl_max = 255;
+static int tcp_syn_retries_min = 1;
+static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
 static int ip_ping_group_range_min[] = { 0, 0 };
 static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
 
@@ -332,7 +334,9 @@ static struct ctl_table ipv4_table[] = {
                .data           = &sysctl_tcp_syn_retries,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = &tcp_syn_retries_min,
+               .extra2         = &tcp_syn_retries_max
        },
        {
                .procname       = "tcp_synack_retries",
@@ -554,6 +558,13 @@ static struct ctl_table ipv4_table[] = {
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = &one,
        },
+       {
+               .procname       = "tcp_notsent_lowat",
+               .data           = &sysctl_tcp_notsent_lowat,
+               .maxlen         = sizeof(sysctl_tcp_notsent_lowat),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
        {
                .procname       = "tcp_rmem",
                .data           = &sysctl_tcp_rmem,
index 5423223e93c25074f87c92dc60b338fddcb66f3f..4e42c03859f46e9b8067494710b3db71bf803593 100644 (file)
@@ -410,10 +410,6 @@ void tcp_init_sock(struct sock *sk)
 
        icsk->icsk_sync_mss = tcp_sync_mss;
 
-       /* Presumed zeroed, in order of appearance:
-        *      cookie_in_always, cookie_out_never,
-        *      s_data_constant, s_data_in, s_data_out
-        */
        sk->sk_sndbuf = sysctl_tcp_wmem[1];
        sk->sk_rcvbuf = sysctl_tcp_rmem[1];
 
@@ -499,7 +495,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
                        mask |= POLLIN | POLLRDNORM;
 
                if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
-                       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+                       if (sk_stream_is_writeable(sk)) {
                                mask |= POLLOUT | POLLWRNORM;
                        } else {  /* send SIGIO later */
                                set_bit(SOCK_ASYNC_NOSPACE,
@@ -510,7 +506,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
                                 * wspace test but before the flags are set,
                                 * IO signal will be lost.
                                 */
-                               if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+                               if (sk_stream_is_writeable(sk))
                                        mask |= POLLOUT | POLLWRNORM;
                        }
                } else
@@ -1120,6 +1116,13 @@ new_segment:
                                if (!skb)
                                        goto wait_for_memory;
 
+                               /*
+                                * All packets are restored as if they have
+                                * already been sent.
+                                */
+                               if (tp->repair)
+                                       TCP_SKB_CB(skb)->when = tcp_time_stamp;
+
                                /*
                                 * Check whether we can use HW checksum.
                                 */
@@ -2631,6 +2634,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
                else
                        tp->tsoffset = val - tcp_time_stamp;
                break;
+       case TCP_NOTSENT_LOWAT:
+               tp->notsent_lowat = val;
+               sk->sk_write_space(sk);
+               break;
        default:
                err = -ENOPROTOOPT;
                break;
@@ -2847,6 +2854,9 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
        case TCP_TIMESTAMP:
                val = tcp_time_stamp + tp->tsoffset;
                break;
+       case TCP_NOTSENT_LOWAT:
+               val = tp->notsent_lowat;
+               break;
        default:
                return -ENOPROTOOPT;
        }
index a9077f441cb27b693d8ad1d710e4dba67aa93ebb..b6ae92a51f58607f7c32be2d0762a49380205012 100644 (file)
@@ -206,8 +206,8 @@ static u32 cubic_root(u64 a)
  */
 static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
 {
-       u64 offs;
-       u32 delta, t, bic_target, max_cnt;
+       u32 delta, bic_target, max_cnt;
+       u64 offs, t;
 
        ca->ack_cnt++;  /* count the number of ACKs */
 
@@ -250,9 +250,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
         * if the cwnd < 1 million packets !!!
         */
 
+       t = (s32)(tcp_time_stamp - ca->epoch_start);
+       t += msecs_to_jiffies(ca->delay_min >> 3);
        /* change the unit from HZ to bictcp_HZ */
-       t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3)
-             - ca->epoch_start) << BICTCP_HZ) / HZ;
+       t <<= BICTCP_HZ;
+       do_div(t, HZ);
 
        if (t < ca->bic_K)              /* t - K */
                offs = ca->bic_K - t;
@@ -414,7 +416,7 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
                return;
 
        /* Discard delay samples right after fast recovery */
-       if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ)
+       if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
                return;
 
        delay = (rtt_us << 3) / USEC_PER_MSEC;
index 8f7ef0ad80e5b6b062b7b40f3049634e63b93b40..ab7bd35bb312c6e9e07aa2950d75ec4bbc982eac 100644 (file)
@@ -58,23 +58,22 @@ error:              kfree(ctx);
        return err;
 }
 
-/* Computes the fastopen cookie for the peer.
- * The peer address is a 128 bits long (pad with zeros for IPv4).
+/* Computes the fastopen cookie for the IP path.
+ * The path is a 128 bits long (pad with zeros for IPv4).
  *
  * The caller must check foc->len to determine if a valid cookie
  * has been generated successfully.
 */
-void tcp_fastopen_cookie_gen(__be32 addr, struct tcp_fastopen_cookie *foc)
+void tcp_fastopen_cookie_gen(__be32 src, __be32 dst,
+                            struct tcp_fastopen_cookie *foc)
 {
-       __be32 peer_addr[4] = { addr, 0, 0, 0 };
+       __be32 path[4] = { src, dst, 0, 0 };
        struct tcp_fastopen_context *ctx;
 
        rcu_read_lock();
        ctx = rcu_dereference(tcp_fastopen_ctx);
        if (ctx) {
-               crypto_cipher_encrypt_one(ctx->tfm,
-                                         foc->val,
-                                         (__u8 *)peer_addr);
+               crypto_cipher_encrypt_one(ctx->tfm, foc->val, (__u8 *)path);
                foc->len = TCP_FASTOPEN_COOKIE_SIZE;
        }
        rcu_read_unlock();
index 28af45abe0622fabac4d53ab651099a580808766..ec492eae0cd75684cc83d0bce697eb39fb37fdd5 100644 (file)
@@ -1048,6 +1048,7 @@ struct tcp_sacktag_state {
        int reord;
        int fack_count;
        int flag;
+       s32 rtt; /* RTT measured by SACKing never-retransmitted data */
 };
 
 /* Check if skb is fully within the SACK block. In presence of GSO skbs,
@@ -1108,7 +1109,7 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb,
 static u8 tcp_sacktag_one(struct sock *sk,
                          struct tcp_sacktag_state *state, u8 sacked,
                          u32 start_seq, u32 end_seq,
-                         bool dup_sack, int pcount)
+                         int dup_sack, int pcount, u32 xmit_time)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        int fack_count = state->fack_count;
@@ -1148,6 +1149,9 @@ static u8 tcp_sacktag_one(struct sock *sk,
                                                           state->reord);
                                if (!after(end_seq, tp->high_seq))
                                        state->flag |= FLAG_ORIG_SACK_ACKED;
+                               /* Pick the earliest sequence sacked for RTT */
+                               if (state->rtt < 0)
+                                       state->rtt = tcp_time_stamp - xmit_time;
                        }
 
                        if (sacked & TCPCB_LOST) {
@@ -1205,7 +1209,8 @@ static bool tcp_shifted_skb(struct sock *sk, struct sk_buff *skb,
         * tcp_highest_sack_seq() when skb is highest_sack.
         */
        tcp_sacktag_one(sk, state, TCP_SKB_CB(skb)->sacked,
-                       start_seq, end_seq, dup_sack, pcount);
+                       start_seq, end_seq, dup_sack, pcount,
+                       TCP_SKB_CB(skb)->when);
 
        if (skb == tp->lost_skb_hint)
                tp->lost_cnt_hint += pcount;
@@ -1479,7 +1484,8 @@ static struct sk_buff *tcp_sacktag_walk(struct sk_buff *skb, struct sock *sk,
                                                TCP_SKB_CB(skb)->seq,
                                                TCP_SKB_CB(skb)->end_seq,
                                                dup_sack,
-                                               tcp_skb_pcount(skb));
+                                               tcp_skb_pcount(skb),
+                                               TCP_SKB_CB(skb)->when);
 
                        if (!before(TCP_SKB_CB(skb)->seq,
                                    tcp_highest_sack_seq(tp)))
@@ -1536,7 +1542,7 @@ static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_bl
 
 static int
 tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb,
-                       u32 prior_snd_una)
+                       u32 prior_snd_una, s32 *sack_rtt)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        const unsigned char *ptr = (skb_transport_header(ack_skb) +
@@ -1554,6 +1560,7 @@ tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb,
 
        state.flag = 0;
        state.reord = tp->packets_out;
+       state.rtt = -1;
 
        if (!tp->sacked_out) {
                if (WARN_ON(tp->fackets_out))
@@ -1737,6 +1744,7 @@ out:
        WARN_ON((int)tp->retrans_out < 0);
        WARN_ON((int)tcp_packets_in_flight(tp) < 0);
 #endif
+       *sack_rtt = state.rtt;
        return state.flag;
 }
 
@@ -1869,8 +1877,13 @@ void tcp_enter_loss(struct sock *sk, int how)
        }
        tcp_verify_left_out(tp);
 
-       tp->reordering = min_t(unsigned int, tp->reordering,
-                              sysctl_tcp_reordering);
+       /* Timeout in disordered state after receiving substantial DUPACKs
+        * suggests that the degree of reordering is over-estimated.
+        */
+       if (icsk->icsk_ca_state <= TCP_CA_Disorder &&
+           tp->sacked_out >= sysctl_tcp_reordering)
+               tp->reordering = min_t(unsigned int, tp->reordering,
+                                      sysctl_tcp_reordering);
        tcp_set_ca_state(sk, TCP_CA_Loss);
        tp->high_seq = tp->snd_nxt;
        TCP_ECN_queue_cwr(tp);
@@ -2472,8 +2485,6 @@ static void tcp_try_to_open(struct sock *sk, int flag, const int prior_unsacked)
 
        if (inet_csk(sk)->icsk_ca_state != TCP_CA_CWR) {
                tcp_try_keep_open(sk);
-               if (inet_csk(sk)->icsk_ca_state != TCP_CA_Open)
-                       tcp_moderate_cwnd(tp);
        } else {
                tcp_cwnd_reduction(sk, prior_unsacked, 0);
        }
@@ -2792,65 +2803,51 @@ static void tcp_fastretrans_alert(struct sock *sk, const int acked,
        tcp_xmit_retransmit_queue(sk);
 }
 
-void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt)
+static inline bool tcp_ack_update_rtt(struct sock *sk, const int flag,
+                                     s32 seq_rtt, s32 sack_rtt)
 {
-       tcp_rtt_estimator(sk, seq_rtt);
-       tcp_set_rto(sk);
-       inet_csk(sk)->icsk_backoff = 0;
-}
-EXPORT_SYMBOL(tcp_valid_rtt_meas);
+       const struct tcp_sock *tp = tcp_sk(sk);
+
+       /* Prefer RTT measured from ACK's timing to TS-ECR. This is because
+        * broken middle-boxes or peers may corrupt TS-ECR fields. But
+        * Karn's algorithm forbids taking RTT if some retransmitted data
+        * is acked (RFC6298).
+        */
+       if (flag & FLAG_RETRANS_DATA_ACKED)
+               seq_rtt = -1;
+
+       if (seq_rtt < 0)
+               seq_rtt = sack_rtt;
 
-/* Read draft-ietf-tcplw-high-performance before mucking
- * with this code. (Supersedes RFC1323)
- */
-static void tcp_ack_saw_tstamp(struct sock *sk, int flag)
-{
        /* RTTM Rule: A TSecr value received in a segment is used to
         * update the averaged RTT measurement only if the segment
         * acknowledges some new data, i.e., only if it advances the
         * left edge of the send window.
-        *
         * See draft-ietf-tcplw-high-performance-00, section 3.3.
-        * 1998/04/10 Andrey V. Savochkin <saw@msu.ru>
-        *
-        * Changed: reset backoff as soon as we see the first valid sample.
-        * If we do not, we get strongly overestimated rto. With timestamps
-        * samples are accepted even from very old segments: f.e., when rtt=1
-        * increases to 8, we retransmit 5 times and after 8 seconds delayed
-        * answer arrives rto becomes 120 seconds! If at least one of segments
-        * in window is lost... Voila.                          --ANK (010210)
         */
-       struct tcp_sock *tp = tcp_sk(sk);
-
-       tcp_valid_rtt_meas(sk, tcp_time_stamp - tp->rx_opt.rcv_tsecr);
-}
+       if (seq_rtt < 0 && tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr)
+               seq_rtt = tcp_time_stamp - tp->rx_opt.rcv_tsecr;
 
-static void tcp_ack_no_tstamp(struct sock *sk, u32 seq_rtt, int flag)
-{
-       /* We don't have a timestamp. Can only use
-        * packets that are not retransmitted to determine
-        * rtt estimates. Also, we must not reset the
-        * backoff for rto until we get a non-retransmitted
-        * packet. This allows us to deal with a situation
-        * where the network delay has increased suddenly.
-        * I.e. Karn's algorithm. (SIGCOMM '87, p5.)
-        */
+       if (seq_rtt < 0)
+               return false;
 
-       if (flag & FLAG_RETRANS_DATA_ACKED)
-               return;
+       tcp_rtt_estimator(sk, seq_rtt);
+       tcp_set_rto(sk);
 
-       tcp_valid_rtt_meas(sk, seq_rtt);
+       /* RFC6298: only reset backoff on valid RTT measurement. */
+       inet_csk(sk)->icsk_backoff = 0;
+       return true;
 }
 
-static inline void tcp_ack_update_rtt(struct sock *sk, const int flag,
-                                     const s32 seq_rtt)
+/* Compute time elapsed between (last) SYNACK and the ACK completing 3WHS. */
+static void tcp_synack_rtt_meas(struct sock *sk, struct request_sock *req)
 {
-       const struct tcp_sock *tp = tcp_sk(sk);
-       /* Note that peer MAY send zero echo. In this case it is ignored. (rfc1323) */
-       if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr)
-               tcp_ack_saw_tstamp(sk, flag);
-       else if (seq_rtt >= 0)
-               tcp_ack_no_tstamp(sk, seq_rtt, flag);
+       struct tcp_sock *tp = tcp_sk(sk);
+       s32 seq_rtt = -1;
+
+       if (tp->lsndtime && !tp->total_retrans)
+               seq_rtt = tcp_time_stamp - tp->lsndtime;
+       tcp_ack_update_rtt(sk, FLAG_SYN_ACKED, seq_rtt, -1);
 }
 
 static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
@@ -2939,7 +2936,7 @@ static u32 tcp_tso_acked(struct sock *sk, struct sk_buff *skb)
  * arrived at the other end.
  */
 static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
-                              u32 prior_snd_una)
+                              u32 prior_snd_una, s32 sack_rtt)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -2978,8 +2975,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
                        if (sacked & TCPCB_SACKED_RETRANS)
                                tp->retrans_out -= acked_pcount;
                        flag |= FLAG_RETRANS_DATA_ACKED;
-                       ca_seq_rtt = -1;
-                       seq_rtt = -1;
                } else {
                        ca_seq_rtt = now - scb->when;
                        last_ackt = skb->tstamp;
@@ -3031,6 +3026,10 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
        if (skb && (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED))
                flag |= FLAG_SACK_RENEGING;
 
+       if (tcp_ack_update_rtt(sk, flag, seq_rtt, sack_rtt) ||
+           (flag & FLAG_ACKED))
+               tcp_rearm_rto(sk);
+
        if (flag & FLAG_ACKED) {
                const struct tcp_congestion_ops *ca_ops
                        = inet_csk(sk)->icsk_ca_ops;
@@ -3040,9 +3039,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
                        tcp_mtup_probe_success(sk);
                }
 
-               tcp_ack_update_rtt(sk, flag, seq_rtt);
-               tcp_rearm_rto(sk);
-
                if (tcp_is_reno(tp)) {
                        tcp_remove_reno_sacks(sk, pkts_acked);
                } else {
@@ -3130,11 +3126,24 @@ static inline bool tcp_ack_is_dubious(const struct sock *sk, const int flag)
                inet_csk(sk)->icsk_ca_state != TCP_CA_Open;
 }
 
+/* Decide wheather to run the increase function of congestion control. */
 static inline bool tcp_may_raise_cwnd(const struct sock *sk, const int flag)
 {
-       const struct tcp_sock *tp = tcp_sk(sk);
-       return (!(flag & FLAG_ECE) || tp->snd_cwnd < tp->snd_ssthresh) &&
-               !tcp_in_cwnd_reduction(sk);
+       if (tcp_in_cwnd_reduction(sk))
+               return false;
+
+       /* If reordering is high then always grow cwnd whenever data is
+        * delivered regardless of its ordering. Otherwise stay conservative
+        * and only grow cwnd on in-order delivery in Open state, and retain
+        * cwnd in Disordered state (RFC5681). A stretched ACK with
+        * new SACK or ECE mark may first advance cwnd here and later reduce
+        * cwnd in tcp_fastretrans_alert() based on more states.
+        */
+       if (tcp_sk(sk)->reordering > sysctl_tcp_reordering)
+               return flag & FLAG_FORWARD_PROGRESS;
+
+       return inet_csk(sk)->icsk_ca_state == TCP_CA_Open &&
+              flag & FLAG_DATA_ACKED;
 }
 
 /* Check that window update is acceptable.
@@ -3274,6 +3283,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
        int prior_packets = tp->packets_out;
        const int prior_unsacked = tp->packets_out - tp->sacked_out;
        int acked = 0; /* Number of packets newly acked */
+       s32 sack_rtt = -1;
 
        /* If the ack is older than previous acks
         * then we can probably ignore it.
@@ -3330,7 +3340,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
                flag |= tcp_ack_update_window(sk, skb, ack, ack_seq);
 
                if (TCP_SKB_CB(skb)->sacked)
-                       flag |= tcp_sacktag_write_queue(sk, skb, prior_snd_una);
+                       flag |= tcp_sacktag_write_queue(sk, skb, prior_snd_una,
+                                                       &sack_rtt);
 
                if (TCP_ECN_rcv_ecn_echo(tp, tcp_hdr(skb)))
                        flag |= FLAG_ECE;
@@ -3349,21 +3360,18 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
 
        /* See if we can take anything off of the retransmit queue. */
        acked = tp->packets_out;
-       flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una);
+       flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una, sack_rtt);
        acked -= tp->packets_out;
 
+       /* Advance cwnd if state allows */
+       if (tcp_may_raise_cwnd(sk, flag))
+               tcp_cong_avoid(sk, ack, prior_in_flight);
+
        if (tcp_ack_is_dubious(sk, flag)) {
-               /* Advance CWND, if state allows this. */
-               if ((flag & FLAG_DATA_ACKED) && tcp_may_raise_cwnd(sk, flag))
-                       tcp_cong_avoid(sk, ack, prior_in_flight);
                is_dupack = !(flag & (FLAG_SND_UNA_ADVANCED | FLAG_NOT_DUP));
                tcp_fastretrans_alert(sk, acked, prior_unsacked,
                                      is_dupack, flag);
-       } else {
-               if (flag & FLAG_DATA_ACKED)
-                       tcp_cong_avoid(sk, ack, prior_in_flight);
        }
-
        if (tp->tlp_high_seq)
                tcp_process_tlp_ack(sk, ack, flag);
 
@@ -3402,7 +3410,8 @@ old_ack:
         * If data was DSACKed, see if we can undo a cwnd reduction.
         */
        if (TCP_SKB_CB(skb)->sacked) {
-               flag |= tcp_sacktag_write_queue(sk, skb, prior_snd_una);
+               flag |= tcp_sacktag_write_queue(sk, skb, prior_snd_una,
+                                               &sack_rtt);
                tcp_fastretrans_alert(sk, acked, prior_unsacked,
                                      is_dupack, flag);
        }
@@ -5624,9 +5633,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                 * so release it.
                 */
                if (req) {
-                       tcp_synack_rtt_meas(sk, req);
                        tp->total_retrans = req->num_retrans;
-
                        reqsk_fastopen_remove(sk, req, false);
                } else {
                        /* Make sure socket is routed, for correct metrics. */
@@ -5651,6 +5658,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                tp->snd_una = TCP_SKB_CB(skb)->ack_seq;
                tp->snd_wnd = ntohs(th->window) << tp->rx_opt.snd_wscale;
                tcp_init_wl(tp, TCP_SKB_CB(skb)->seq);
+               tcp_synack_rtt_meas(sk, req);
 
                if (tp->rx_opt.tstamp_ok)
                        tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;
index b299da5ff4996fb5785d2725c66c43d91db918d4..09d45d718973398918879d1321000ca82cdf1e3d 100644 (file)
@@ -821,8 +821,7 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
  */
 static int tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst,
                              struct request_sock *req,
-                             u16 queue_mapping,
-                             bool nocache)
+                             u16 queue_mapping)
 {
        const struct inet_request_sock *ireq = inet_rsk(req);
        struct flowi4 fl4;
@@ -852,7 +851,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct dst_entry *dst,
 
 static int tcp_v4_rtx_synack(struct sock *sk, struct request_sock *req)
 {
-       int res = tcp_v4_send_synack(sk, NULL, req, 0, false);
+       int res = tcp_v4_send_synack(sk, NULL, req, 0);
 
        if (!res)
                TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS);
@@ -890,7 +889,7 @@ bool tcp_syn_flood_action(struct sock *sk,
                NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
 
        lopt = inet_csk(sk)->icsk_accept_queue.listen_opt;
-       if (!lopt->synflood_warned) {
+       if (!lopt->synflood_warned && sysctl_tcp_syncookies != 2) {
                lopt->synflood_warned = 1;
                pr_info("%s: Possible SYN flooding on port %d. %s.  Check SNMP counters.\n",
                        proto, ntohs(tcp_hdr(skb)->dest), msg);
@@ -1316,9 +1315,11 @@ static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
                tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
                return true;
        }
+
        if (foc->len == TCP_FASTOPEN_COOKIE_SIZE) {
                if ((sysctl_tcp_fastopen & TFO_SERVER_COOKIE_NOT_CHKED) == 0) {
-                       tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr, valid_foc);
+                       tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr,
+                                               ip_hdr(skb)->daddr, valid_foc);
                        if ((valid_foc->len != TCP_FASTOPEN_COOKIE_SIZE) ||
                            memcmp(&foc->val[0], &valid_foc->val[0],
                            TCP_FASTOPEN_COOKIE_SIZE) != 0)
@@ -1329,14 +1330,16 @@ static bool tcp_fastopen_check(struct sock *sk, struct sk_buff *skb,
                tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
                return true;
        } else if (foc->len == 0) { /* Client requesting a cookie */
-               tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr, valid_foc);
+               tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr,
+                                       ip_hdr(skb)->daddr, valid_foc);
                NET_INC_STATS_BH(sock_net(sk),
                    LINUX_MIB_TCPFASTOPENCOOKIEREQD);
        } else {
                /* Client sent a cookie with wrong size. Treat it
                 * the same as invalid and return a valid one.
                 */
-               tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr, valid_foc);
+               tcp_fastopen_cookie_gen(ip_hdr(skb)->saddr,
+                                       ip_hdr(skb)->daddr, valid_foc);
        }
        return false;
 }
@@ -1462,7 +1465,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
         * limitations, they conserve resources and peer is
         * evidently real one.
         */
-       if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
+       if ((sysctl_tcp_syncookies == 2 ||
+            inet_csk_reqsk_queue_is_full(sk)) && !isn) {
                want_cookie = tcp_syn_flood_action(sk, skb, "TCP");
                if (!want_cookie)
                        goto drop;
@@ -1671,8 +1675,6 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
                newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
 
        tcp_initialize_rcv_mss(newsk);
-       tcp_synack_rtt_meas(newsk, req);
-       newtp->total_retrans = req->num_retrans;
 
 #ifdef CONFIG_TCP_MD5SIG
        /* Copy over the MD5 key from the original socket */
@@ -2605,7 +2607,7 @@ static void get_openreq4(const struct sock *sk, const struct request_sock *req,
        long delta = req->expires - jiffies;
 
        seq_printf(f, "%4d: %08X:%04X %08X:%04X"
-               " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
+               " %02X %08X:%08X %02X:%08lX %08X %5u %8d %u %d %pK%n",
                i,
                ireq->loc_addr,
                ntohs(inet_sk(sk)->inet_sport),
@@ -2663,7 +2665,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
                rx_queue = max_t(int, tp->rcv_nxt - tp->copied_seq, 0);
 
        seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
-                       "%08X %5d %8d %lu %d %pK %lu %lu %u %u %d%n",
+                       "%08X %5u %8d %lu %d %pK %lu %lu %u %u %d%n",
                i, src, srcp, dest, destp, sk->sk_state,
                tp->write_seq - tp->snd_una,
                rx_queue,
@@ -2802,6 +2804,7 @@ struct proto tcp_prot = {
        .unhash                 = inet_unhash,
        .get_port               = inet_csk_get_port,
        .enter_memory_pressure  = tcp_enter_memory_pressure,
+       .stream_memory_free     = tcp_stream_memory_free,
        .sockets_allocated      = &tcp_sockets_allocated,
        .orphan_count           = &tcp_orphan_count,
        .memory_allocated       = &tcp_memory_allocated,
index ab1c08658528e7737fd1683841a4d11701cbc0bb..58a3e69aef6440d36061ea9e6291152442954239 100644 (file)
@@ -411,6 +411,8 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
                newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
                tcp_enable_early_retrans(newtp);
                newtp->tlp_high_seq = 0;
+               newtp->lsndtime = treq->snt_synack;
+               newtp->total_retrans = req->num_retrans;
 
                /* So many TCP implementations out there (incorrectly) count the
                 * initial SYN frame in their delayed-ACK and congestion control
@@ -666,12 +668,6 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
        if (!(flg & TCP_FLAG_ACK))
                return NULL;
 
-       /* Got ACK for our SYNACK, so update baseline for SYNACK RTT sample. */
-       if (tmp_opt.saw_tstamp && tmp_opt.rcv_tsecr)
-               tcp_rsk(req)->snt_synack = tmp_opt.rcv_tsecr;
-       else if (req->num_retrans) /* don't take RTT sample if retrans && ~TS */
-               tcp_rsk(req)->snt_synack = 0;
-
        /* For Fast Open no more processing is needed (sk is the
         * child socket).
         */
index 92fde8d1aa821c38b59ba467fe386eb3306c2dfe..884efff5b531f9c6177a789ea5013c0492939afa 100644 (file)
@@ -65,6 +65,9 @@ int sysctl_tcp_base_mss __read_mostly = TCP_BASE_MSS;
 /* By default, RFC2861 behavior.  */
 int sysctl_tcp_slow_start_after_idle __read_mostly = 1;
 
+unsigned int sysctl_tcp_notsent_lowat __read_mostly = UINT_MAX;
+EXPORT_SYMBOL(sysctl_tcp_notsent_lowat);
+
 static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
                           int push_one, gfp_t gfp);
 
index d4943f67aff2ae6d7bd486ee14880f281f43ec45..622a4377b3973f5d60f6171e814cce5c44d282ae 100644 (file)
@@ -46,6 +46,10 @@ static unsigned int bufsize __read_mostly = 4096;
 MODULE_PARM_DESC(bufsize, "Log buffer size in packets (4096)");
 module_param(bufsize, uint, 0);
 
+static unsigned int fwmark __read_mostly = 0;
+MODULE_PARM_DESC(fwmark, "skb mark to match (0=no mark)");
+module_param(fwmark, uint, 0);
+
 static int full __read_mostly;
 MODULE_PARM_DESC(full, "Full log (1=every ack packet received,  0=only cwnd changes)");
 module_param(full, int, 0);
@@ -54,12 +58,16 @@ static const char procname[] = "tcpprobe";
 
 struct tcp_log {
        ktime_t tstamp;
-       __be32  saddr, daddr;
-       __be16  sport, dport;
+       union {
+               struct sockaddr         raw;
+               struct sockaddr_in      v4;
+               struct sockaddr_in6     v6;
+       }       src, dst;
        u16     length;
        u32     snd_nxt;
        u32     snd_una;
        u32     snd_wnd;
+       u32     rcv_wnd;
        u32     snd_cwnd;
        u32     ssthresh;
        u32     srtt;
@@ -86,19 +94,45 @@ static inline int tcp_probe_avail(void)
        return bufsize - tcp_probe_used() - 1;
 }
 
+#define tcp_probe_copy_fl_to_si4(inet, si4, mem)               \
+       do {                                                    \
+               si4.sin_family = AF_INET;                       \
+               si4.sin_port = inet->inet_##mem##port;          \
+               si4.sin_addr.s_addr = inet->inet_##mem##addr;   \
+       } while (0)                                             \
+
+#if IS_ENABLED(CONFIG_IPV6)
+#define tcp_probe_copy_fl_to_si6(inet, si6, mem)               \
+       do {                                                    \
+               struct ipv6_pinfo *pi6 = inet->pinet6;          \
+               si6.sin6_family = AF_INET6;                     \
+               si6.sin6_port = inet->inet_##mem##port;         \
+               si6.sin6_addr = pi6->mem##addr;                 \
+               si6.sin6_flowinfo = 0; /* No need here. */      \
+               si6.sin6_scope_id = 0;  /* No need here. */     \
+       } while (0)
+#else
+#define tcp_probe_copy_fl_to_si6(fl, si6, mem)                 \
+       do {                                                    \
+               memset(&si6, 0, sizeof(si6));                   \
+       } while (0)
+#endif
+
 /*
  * Hook inserted to be called before each receive packet.
  * Note: arguments must match tcp_rcv_established()!
  */
 static int jtcp_rcv_established(struct sock *sk, struct sk_buff *skb,
-                              struct tcphdr *th, unsigned int len)
+                               const struct tcphdr *th, unsigned int len)
 {
        const struct tcp_sock *tp = tcp_sk(sk);
        const struct inet_sock *inet = inet_sk(sk);
 
-       /* Only update if port matches */
-       if ((port == 0 || ntohs(inet->inet_dport) == port ||
-            ntohs(inet->inet_sport) == port) &&
+       /* Only update if port or skb mark matches */
+       if (((port == 0 && fwmark == 0) ||
+            ntohs(inet->inet_dport) == port ||
+            ntohs(inet->inet_sport) == port ||
+            (fwmark > 0 && skb->mark == fwmark)) &&
            (full || tp->snd_cwnd != tcp_probe.lastcwnd)) {
 
                spin_lock(&tcp_probe.lock);
@@ -107,15 +141,25 @@ static int jtcp_rcv_established(struct sock *sk, struct sk_buff *skb,
                        struct tcp_log *p = tcp_probe.log + tcp_probe.head;
 
                        p->tstamp = ktime_get();
-                       p->saddr = inet->inet_saddr;
-                       p->sport = inet->inet_sport;
-                       p->daddr = inet->inet_daddr;
-                       p->dport = inet->inet_dport;
+                       switch (sk->sk_family) {
+                       case AF_INET:
+                               tcp_probe_copy_fl_to_si4(inet, p->src.v4, s);
+                               tcp_probe_copy_fl_to_si4(inet, p->dst.v4, d);
+                               break;
+                       case AF_INET6:
+                               tcp_probe_copy_fl_to_si6(inet, p->src.v6, s);
+                               tcp_probe_copy_fl_to_si6(inet, p->dst.v6, d);
+                               break;
+                       default:
+                               BUG();
+                       }
+
                        p->length = skb->len;
                        p->snd_nxt = tp->snd_nxt;
                        p->snd_una = tp->snd_una;
                        p->snd_cwnd = tp->snd_cwnd;
                        p->snd_wnd = tp->snd_wnd;
+                       p->rcv_wnd = tp->rcv_wnd;
                        p->ssthresh = tcp_current_ssthresh(sk);
                        p->srtt = tp->srtt >> 3;
 
@@ -157,13 +201,11 @@ static int tcpprobe_sprint(char *tbuf, int n)
                = ktime_to_timespec(ktime_sub(p->tstamp, tcp_probe.start));
 
        return scnprintf(tbuf, n,
-                       "%lu.%09lu %pI4:%u %pI4:%u %d %#x %#x %u %u %u %u\n",
+                       "%lu.%09lu %pISpc %pISpc %d %#x %#x %u %u %u %u %u\n",
                        (unsigned long) tv.tv_sec,
                        (unsigned long) tv.tv_nsec,
-                       &p->saddr, ntohs(p->sport),
-                       &p->daddr, ntohs(p->dport),
-                       p->length, p->snd_nxt, p->snd_una,
-                       p->snd_cwnd, p->ssthresh, p->snd_wnd, p->srtt);
+                       &p->src, &p->dst, p->length, p->snd_nxt, p->snd_una,
+                       p->snd_cwnd, p->ssthresh, p->snd_wnd, p->srtt, p->rcv_wnd);
 }
 
 static ssize_t tcpprobe_read(struct file *file, char __user *buf,
@@ -223,6 +265,13 @@ static __init int tcpprobe_init(void)
 {
        int ret = -ENOMEM;
 
+       /* Warning: if the function signature of tcp_rcv_established,
+        * has been changed, you also have to change the signature of
+        * jtcp_rcv_established, otherwise you end up right here!
+        */
+       BUILD_BUG_ON(__same_type(tcp_rcv_established,
+                                jtcp_rcv_established) == 0);
+
        init_waitqueue_head(&tcp_probe.wait);
        spin_lock_init(&tcp_probe.lock);
 
@@ -241,7 +290,8 @@ static __init int tcpprobe_init(void)
        if (ret)
                goto err1;
 
-       pr_info("probe registered (port=%d) bufsize=%u\n", port, bufsize);
+       pr_info("probe registered (port=%d/fwmark=%u) bufsize=%u\n",
+               port, fwmark, bufsize);
        return 0;
  err1:
        remove_proc_entry(procname, init_net.proc_net);
index 766e6bab911362cb0caa44511b10bb82418e7980..0b24508bcdc47fceb9d6a3e2755d0653e1f0e731 100644 (file)
@@ -704,7 +704,7 @@ EXPORT_SYMBOL(udp_flush_pending_frames);
  *     @src:   source IP address
  *     @dst:   destination IP address
  */
-static void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst)
+void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst)
 {
        struct udphdr *uh = udp_hdr(skb);
        struct sk_buff *frags = skb_shinfo(skb)->frag_list;
@@ -740,6 +740,7 @@ static void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst)
                        uh->check = CSUM_MANGLED_0;
        }
 }
+EXPORT_SYMBOL_GPL(udp4_hwcsum);
 
 static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4)
 {
@@ -2158,7 +2159,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
        __u16 srcp        = ntohs(inet->inet_sport);
 
        seq_printf(f, "%5d: %08X:%04X %08X:%04X"
-               " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %pK %d%n",
+               " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d%n",
                bucket, src, srcp, dest, destp, sp->sk_state,
                sk_wmem_alloc_get(sp),
                sk_rmem_alloc_get(sp),
index cfdcf7b2daf68ff681608351e0bca7202923824b..2d6d1793bbfed73fc001ccfbff9485601ea527d7 100644 (file)
@@ -99,9 +99,9 @@
 #define ACONF_DEBUG 2
 
 #if ACONF_DEBUG >= 3
-#define ADBG(x) printk x
+#define ADBG(fmt, ...) printk(fmt, ##__VA_ARGS__)
 #else
-#define ADBG(x)
+#define ADBG(fmt, ...) do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
 #endif
 
 #define        INFINITY_LIFE_TIME      0xFFFFFFFF
@@ -177,6 +177,8 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
        .accept_redirects       = 1,
        .autoconf               = 1,
        .force_mld_version      = 0,
+       .mldv1_unsolicited_report_interval = 10 * HZ,
+       .mldv2_unsolicited_report_interval = HZ,
        .dad_transmits          = 1,
        .rtr_solicits           = MAX_RTR_SOLICITATIONS,
        .rtr_solicit_interval   = RTR_SOLICITATION_INTERVAL,
@@ -211,6 +213,9 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
        .accept_ra              = 1,
        .accept_redirects       = 1,
        .autoconf               = 1,
+       .force_mld_version      = 0,
+       .mldv1_unsolicited_report_interval = 10 * HZ,
+       .mldv2_unsolicited_report_interval = HZ,
        .dad_transmits          = 1,
        .rtr_solicits           = MAX_RTR_SOLICITATIONS,
        .rtr_solicit_interval   = RTR_SOLICITATION_INTERVAL,
@@ -369,9 +374,9 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
        dev_hold(dev);
 
        if (snmp6_alloc_dev(ndev) < 0) {
-               ADBG((KERN_WARNING
+               ADBG(KERN_WARNING
                        "%s: cannot allocate memory for statistics; dev=%s.\n",
-                       __func__, dev->name));
+                       __func__, dev->name);
                neigh_parms_release(&nd_tbl, ndev->nd_parms);
                dev_put(dev);
                kfree(ndev);
@@ -379,9 +384,9 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev)
        }
 
        if (snmp6_register_dev(ndev) < 0) {
-               ADBG((KERN_WARNING
+               ADBG(KERN_WARNING
                        "%s: cannot create /proc/net/dev_snmp6/%s\n",
-                       __func__, dev->name));
+                       __func__, dev->name);
                neigh_parms_release(&nd_tbl, ndev->nd_parms);
                ndev->dead = 1;
                in6_dev_finish_destroy(ndev);
@@ -813,8 +818,9 @@ static u32 inet6_addr_hash(const struct in6_addr *addr)
 /* On success it returns ifp with increased reference count */
 
 static struct inet6_ifaddr *
-ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
-             int scope, u32 flags)
+ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
+             const struct in6_addr *peer_addr, int pfxlen,
+             int scope, u32 flags, u32 valid_lft, u32 prefered_lft)
 {
        struct inet6_ifaddr *ifa = NULL;
        struct rt6_info *rt;
@@ -843,7 +849,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
 
        /* Ignore adding duplicate addresses on an interface */
        if (ipv6_chk_same_addr(dev_net(idev->dev), addr, idev->dev)) {
-               ADBG(("ipv6_add_addr: already assigned\n"));
+               ADBG("ipv6_add_addr: already assigned\n");
                err = -EEXIST;
                goto out;
        }
@@ -851,7 +857,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
        ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC);
 
        if (ifa == NULL) {
-               ADBG(("ipv6_add_addr: malloc failed\n"));
+               ADBG("ipv6_add_addr: malloc failed\n");
                err = -ENOBUFS;
                goto out;
        }
@@ -863,6 +869,8 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
        }
 
        ifa->addr = *addr;
+       if (peer_addr)
+               ifa->peer_addr = *peer_addr;
 
        spin_lock_init(&ifa->lock);
        spin_lock_init(&ifa->state_lock);
@@ -872,6 +880,8 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
        ifa->scope = scope;
        ifa->prefix_len = pfxlen;
        ifa->flags = flags | IFA_F_TENTATIVE;
+       ifa->valid_lft = valid_lft;
+       ifa->prefered_lft = prefered_lft;
        ifa->cstamp = ifa->tstamp = jiffies;
        ifa->tokenized = false;
 
@@ -1121,11 +1131,10 @@ retry:
        if (ifp->flags & IFA_F_OPTIMISTIC)
                addr_flags |= IFA_F_OPTIMISTIC;
 
-       ift = !max_addresses ||
-             ipv6_count_addresses(idev) < max_addresses ?
-               ipv6_add_addr(idev, &addr, tmp_plen, ipv6_addr_scope(&addr),
-                             addr_flags) : NULL;
-       if (IS_ERR_OR_NULL(ift)) {
+       ift = ipv6_add_addr(idev, &addr, NULL, tmp_plen,
+                           ipv6_addr_scope(&addr), addr_flags,
+                           tmp_valid_lft, tmp_prefered_lft);
+       if (IS_ERR(ift)) {
                in6_ifa_put(ifp);
                in6_dev_put(idev);
                pr_info("%s: retry temporary address regeneration\n", __func__);
@@ -1136,8 +1145,6 @@ retry:
 
        spin_lock_bh(&ift->lock);
        ift->ifpub = ifp;
-       ift->valid_lft = tmp_valid_lft;
-       ift->prefered_lft = tmp_prefered_lft;
        ift->cstamp = now;
        ift->tstamp = tmp_tstamp;
        spin_unlock_bh(&ift->lock);
@@ -1805,6 +1812,16 @@ static int addrconf_ifid_gre(u8 *eui, struct net_device *dev)
        return __ipv6_isatap_ifid(eui, *(__be32 *)dev->dev_addr);
 }
 
+static int addrconf_ifid_ip6tnl(u8 *eui, struct net_device *dev)
+{
+       memcpy(eui, dev->perm_addr, 3);
+       memcpy(eui + 5, dev->perm_addr + 3, 3);
+       eui[3] = 0xFF;
+       eui[4] = 0xFE;
+       eui[0] ^= 2;
+       return 0;
+}
+
 static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
 {
        switch (dev->type) {
@@ -1823,6 +1840,8 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
                return addrconf_ifid_eui64(eui, dev);
        case ARPHRD_IEEE1394:
                return addrconf_ifid_ieee1394(eui, dev);
+       case ARPHRD_TUNNEL6:
+               return addrconf_ifid_ip6tnl(eui, dev);
        }
        return -1;
 }
@@ -2048,7 +2067,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
        pinfo = (struct prefix_info *) opt;
 
        if (len < sizeof(struct prefix_info)) {
-               ADBG(("addrconf: prefix option too short\n"));
+               ADBG("addrconf: prefix option too short\n");
                return;
        }
 
@@ -2179,16 +2198,19 @@ ok:
                         */
                        if (!max_addresses ||
                            ipv6_count_addresses(in6_dev) < max_addresses)
-                               ifp = ipv6_add_addr(in6_dev, &addr, pinfo->prefix_len,
+                               ifp = ipv6_add_addr(in6_dev, &addr, NULL,
+                                                   pinfo->prefix_len,
                                                    addr_type&IPV6_ADDR_SCOPE_MASK,
-                                                   addr_flags);
+                                                   addr_flags, valid_lft,
+                                                   prefered_lft);
 
                        if (IS_ERR_OR_NULL(ifp)) {
                                in6_dev_put(in6_dev);
                                return;
                        }
 
-                       update_lft = create = 1;
+                       update_lft = 0;
+                       create = 1;
                        ifp->cstamp = jiffies;
                        ifp->tokenized = tokenized;
                        addrconf_dad_start(ifp);
@@ -2209,7 +2231,7 @@ ok:
                                stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ;
                        else
                                stored_lft = 0;
-                       if (!update_lft && stored_lft) {
+                       if (!update_lft && !create && stored_lft) {
                                if (valid_lft > MIN_VALID_LIFETIME ||
                                    valid_lft > stored_lft)
                                        update_lft = 1;
@@ -2455,17 +2477,10 @@ static int inet6_addr_add(struct net *net, int ifindex, const struct in6_addr *p
                prefered_lft = timeout;
        }
 
-       ifp = ipv6_add_addr(idev, pfx, plen, scope, ifa_flags);
+       ifp = ipv6_add_addr(idev, pfx, peer_pfx, plen, scope, ifa_flags,
+                           valid_lft, prefered_lft);
 
        if (!IS_ERR(ifp)) {
-               spin_lock_bh(&ifp->lock);
-               ifp->valid_lft = valid_lft;
-               ifp->prefered_lft = prefered_lft;
-               ifp->tstamp = jiffies;
-               if (peer_pfx)
-                       ifp->peer_addr = *peer_pfx;
-               spin_unlock_bh(&ifp->lock);
-
                addrconf_prefix_route(&ifp->addr, ifp->prefix_len, dev,
                                      expires, flags);
                /*
@@ -2557,7 +2572,8 @@ static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr,
 {
        struct inet6_ifaddr *ifp;
 
-       ifp = ipv6_add_addr(idev, addr, plen, scope, IFA_F_PERMANENT);
+       ifp = ipv6_add_addr(idev, addr, NULL, plen,
+                           scope, IFA_F_PERMANENT, 0, 0);
        if (!IS_ERR(ifp)) {
                spin_lock_bh(&ifp->lock);
                ifp->flags &= ~IFA_F_TENTATIVE;
@@ -2683,7 +2699,7 @@ static void addrconf_add_linklocal(struct inet6_dev *idev, const struct in6_addr
 #endif
 
 
-       ifp = ipv6_add_addr(idev, addr, 64, IFA_LINK, addr_flags);
+       ifp = ipv6_add_addr(idev, addr, NULL, 64, IFA_LINK, addr_flags, 0, 0);
        if (!IS_ERR(ifp)) {
                addrconf_prefix_route(&ifp->addr, ifp->prefix_len, idev->dev, 0, 0);
                addrconf_dad_start(ifp);
@@ -2703,7 +2719,8 @@ static void addrconf_dev_config(struct net_device *dev)
            (dev->type != ARPHRD_ARCNET) &&
            (dev->type != ARPHRD_INFINIBAND) &&
            (dev->type != ARPHRD_IEEE802154) &&
-           (dev->type != ARPHRD_IEEE1394)) {
+           (dev->type != ARPHRD_IEEE1394) &&
+           (dev->type != ARPHRD_TUNNEL6)) {
                /* Alas, we support only Ethernet autoconfiguration. */
                return;
        }
@@ -2789,44 +2806,6 @@ ipv6_inherit_linklocal(struct inet6_dev *idev, struct net_device *link_dev)
        return -1;
 }
 
-static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
-{
-       struct net_device *link_dev;
-       struct net *net = dev_net(idev->dev);
-
-       /* first try to inherit the link-local address from the link device */
-       if (idev->dev->iflink &&
-           (link_dev = __dev_get_by_index(net, idev->dev->iflink))) {
-               if (!ipv6_inherit_linklocal(idev, link_dev))
-                       return;
-       }
-       /* then try to inherit it from any device */
-       for_each_netdev(net, link_dev) {
-               if (!ipv6_inherit_linklocal(idev, link_dev))
-                       return;
-       }
-       pr_debug("init ip6-ip6: add_linklocal failed\n");
-}
-
-/*
- * Autoconfigure tunnel with a link-local address so routing protocols,
- * DHCPv6, MLD etc. can be run over the virtual link
- */
-
-static void addrconf_ip6_tnl_config(struct net_device *dev)
-{
-       struct inet6_dev *idev;
-
-       ASSERT_RTNL();
-
-       idev = addrconf_add_dev(dev);
-       if (IS_ERR(idev)) {
-               pr_debug("init ip6-ip6: add_dev failed\n");
-               return;
-       }
-       ip6_tnl_add_linklocal(idev);
-}
-
 static int addrconf_notify(struct notifier_block *this, unsigned long event,
                           void *ptr)
 {
@@ -2894,9 +2873,6 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
                        addrconf_gre_config(dev);
                        break;
 #endif
-               case ARPHRD_TUNNEL6:
-                       addrconf_ip6_tnl_config(dev);
-                       break;
                case ARPHRD_LOOPBACK:
                        init_loopback(dev);
                        break;
@@ -3631,8 +3607,8 @@ restart:
        if (time_before(next_sched, jiffies + ADDRCONF_TIMER_FUZZ_MAX))
                next_sched = jiffies + ADDRCONF_TIMER_FUZZ_MAX;
 
-       ADBG((KERN_DEBUG "now = %lu, schedule = %lu, rounded schedule = %lu => %lu\n",
-             now, next, next_sec, next_sched));
+       ADBG(KERN_DEBUG "now = %lu, schedule = %lu, rounded schedule = %lu => %lu\n",
+             now, next, next_sec, next_sched);
 
        addr_chk_timer.expires = next_sched;
        add_timer(&addr_chk_timer);
@@ -4178,6 +4154,10 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
        array[DEVCONF_RTR_SOLICIT_DELAY] =
                jiffies_to_msecs(cnf->rtr_solicit_delay);
        array[DEVCONF_FORCE_MLD_VERSION] = cnf->force_mld_version;
+       array[DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL] =
+               jiffies_to_msecs(cnf->mldv1_unsolicited_report_interval);
+       array[DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL] =
+               jiffies_to_msecs(cnf->mldv2_unsolicited_report_interval);
 #ifdef CONFIG_IPV6_PRIVACY
        array[DEVCONF_USE_TEMPADDR] = cnf->use_tempaddr;
        array[DEVCONF_TEMP_VALID_LFT] = cnf->temp_valid_lft;
@@ -4653,6 +4633,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
                break;
        }
        atomic_inc(&net->ipv6.dev_addr_genid);
+       rt_genid_bump_ipv6(net);
 }
 
 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
@@ -4860,6 +4841,22 @@ static struct addrconf_sysctl_table
                        .mode           = 0644,
                        .proc_handler   = proc_dointvec,
                },
+               {
+                       .procname       = "mldv1_unsolicited_report_interval",
+                       .data           =
+                               &ipv6_devconf.mldv1_unsolicited_report_interval,
+                       .maxlen         = sizeof(int),
+                       .mode           = 0644,
+                       .proc_handler   = proc_dointvec_ms_jiffies,
+               },
+               {
+                       .procname       = "mldv2_unsolicited_report_interval",
+                       .data           =
+                               &ipv6_devconf.mldv2_unsolicited_report_interval,
+                       .maxlen         = sizeof(int),
+                       .mode           = 0644,
+                       .proc_handler   = proc_dointvec_ms_jiffies,
+               },
 #ifdef CONFIG_IPV6_PRIVACY
                {
                        .procname       = "use_tempaddr",
index a5ac969aeefe5337d7fa4c5601912fb96b1a5496..0d1a9b153fbb8c82d680015d382429472d42cfcb 100644 (file)
@@ -766,6 +766,7 @@ static int __net_init inet6_net_init(struct net *net)
 
        net->ipv6.sysctl.bindv6only = 0;
        net->ipv6.sysctl.icmpv6_time = 1*HZ;
+       atomic_set(&net->ipv6.rt_genid, 0);
 
        err = ipv6_init_mibs(net);
        if (err)
index 197e6f4a2b7499c67440b66e04d646d631caefa5..48b6bd2a9a1451b7adf9a678ccce859003d57a79 100644 (file)
@@ -890,7 +890,7 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
        src   = &np->rcv_saddr;
        seq_printf(seq,
                   "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-                  "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %pK %d\n",
+                  "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n",
                   bucket,
                   src->s6_addr32[0], src->s6_addr32[1],
                   src->s6_addr32[2], src->s6_addr32[3], srcp,
index 40ffd72243a4f2d1ec9e5da494b3f2650dd027a6..aeac0dc3635d98458a1f70ec84103c89a3f5a648 100644 (file)
@@ -425,7 +425,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
                net_adj = 0;
 
        return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
-                net_adj) & ~(align - 1)) + (net_adj - 2);
+                net_adj) & ~(align - 1)) + net_adj - 2;
 }
 
 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
index 2e1a432867c0897f4e0d4439f9c6fd5d3f4c66cb..a6c58ce43d34aaa878c6ea239e0ff7c3616bd302 100644 (file)
@@ -55,26 +55,33 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
        struct fib6_table *table;
        struct net *net = rule->fr_net;
        pol_lookup_t lookup = arg->lookup_ptr;
+       int err = 0;
 
        switch (rule->action) {
        case FR_ACT_TO_TBL:
                break;
        case FR_ACT_UNREACHABLE:
+               err = -ENETUNREACH;
                rt = net->ipv6.ip6_null_entry;
                goto discard_pkt;
        default:
        case FR_ACT_BLACKHOLE:
+               err = -EINVAL;
                rt = net->ipv6.ip6_blk_hole_entry;
                goto discard_pkt;
        case FR_ACT_PROHIBIT:
+               err = -EACCES;
                rt = net->ipv6.ip6_prohibit_entry;
                goto discard_pkt;
        }
 
        table = fib6_get_table(net, rule->table);
-       if (table)
-               rt = lookup(net, table, flp6, flags);
+       if (!table) {
+               err = -EAGAIN;
+               goto out;
+       }
 
+       rt = lookup(net, table, flp6, flags);
        if (rt != net->ipv6.ip6_null_entry) {
                struct fib6_rule *r = (struct fib6_rule *)rule;
 
@@ -101,6 +108,7 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
        }
 again:
        ip6_rt_put(rt);
+       err = -EAGAIN;
        rt = NULL;
        goto out;
 
@@ -108,9 +116,31 @@ discard_pkt:
        dst_hold(&rt->dst);
 out:
        arg->result = rt;
-       return rt == NULL ? -EAGAIN : 0;
+       return err;
 }
 
+static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
+{
+       struct rt6_info *rt = (struct rt6_info *) arg->result;
+       struct net_device *dev = rt->rt6i_idev->dev;
+       /* do not accept result if the route does
+        * not meet the required prefix length
+        */
+       if (rt->rt6i_dst.plen <= rule->suppress_prefixlen)
+               goto suppress_route;
+
+       /* do not accept result if the route uses a device
+        * belonging to a forbidden interface group
+        */
+       if (rule->suppress_ifgroup != -1 && dev && dev->group == rule->suppress_ifgroup)
+               goto suppress_route;
+
+       return false;
+
+suppress_route:
+               ip6_rt_put(rt);
+               return true;
+}
 
 static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
 {
@@ -244,6 +274,7 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = {
        .addr_size              = sizeof(struct in6_addr),
        .action                 = fib6_rule_action,
        .match                  = fib6_rule_match,
+       .suppress               = fib6_rule_suppress,
        .configure              = fib6_rule_configure,
        .compare                = fib6_rule_compare,
        .fill                   = fib6_rule_fill,
index 5fc9c7a68d8d102aef37b7b13ab1dd772553a9cb..73db48eba1c48faa046c584912f09cda8f6ae2fa 100644 (file)
@@ -425,8 +425,8 @@ out:
  *     node.
  */
 
-static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
-                                    int addrlen, int plen,
+static struct fib6_node *fib6_add_1(struct fib6_node *root,
+                                    struct in6_addr *addr, int plen,
                                     int offset, int allow_create,
                                     int replace_required)
 {
@@ -543,7 +543,7 @@ insert_above:
           but if it is >= plen, the value is ignored in any case.
         */
 
-       bit = __ipv6_addr_diff(addr, &key->addr, addrlen);
+       bit = __ipv6_addr_diff(addr, &key->addr, sizeof(*addr));
 
        /*
         *              (intermediate)[in]
@@ -822,9 +822,9 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
        if (!allow_create && !replace_required)
                pr_warn("RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE\n");
 
-       fn = fib6_add_1(root, &rt->rt6i_dst.addr, sizeof(struct in6_addr),
-                       rt->rt6i_dst.plen, offsetof(struct rt6_info, rt6i_dst),
-                       allow_create, replace_required);
+       fn = fib6_add_1(root, &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
+                       offsetof(struct rt6_info, rt6i_dst), allow_create,
+                       replace_required);
 
        if (IS_ERR(fn)) {
                err = PTR_ERR(fn);
@@ -863,7 +863,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
                        /* Now add the first leaf node to new subtree */
 
                        sn = fib6_add_1(sfn, &rt->rt6i_src.addr,
-                                       sizeof(struct in6_addr), rt->rt6i_src.plen,
+                                       rt->rt6i_src.plen,
                                        offsetof(struct rt6_info, rt6i_src),
                                        allow_create, replace_required);
 
@@ -882,7 +882,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info)
                        fn->subtree = sfn;
                } else {
                        sn = fib6_add_1(fn->subtree, &rt->rt6i_src.addr,
-                                       sizeof(struct in6_addr), rt->rt6i_src.plen,
+                                       rt->rt6i_src.plen,
                                        offsetof(struct rt6_info, rt6i_src),
                                        allow_create, replace_required);
 
@@ -993,14 +993,22 @@ static struct fib6_node * fib6_lookup_1(struct fib6_node *root,
 
                        if (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) {
 #ifdef CONFIG_IPV6_SUBTREES
-                               if (fn->subtree)
-                                       fn = fib6_lookup_1(fn->subtree, args + 1);
+                               if (fn->subtree) {
+                                       struct fib6_node *sfn;
+                                       sfn = fib6_lookup_1(fn->subtree,
+                                                           args + 1);
+                                       if (!sfn)
+                                               goto backtrack;
+                                       fn = sfn;
+                               }
 #endif
-                               if (!fn || fn->fn_flags & RTN_RTINFO)
+                               if (fn->fn_flags & RTN_RTINFO)
                                        return fn;
                        }
                }
-
+#ifdef CONFIG_IPV6_SUBTREES
+backtrack:
+#endif
                if (fn->fn_flags & RTN_ROOT)
                        break;
 
@@ -1632,27 +1640,28 @@ static int fib6_age(struct rt6_info *rt, void *arg)
 
 static DEFINE_SPINLOCK(fib6_gc_lock);
 
-void fib6_run_gc(unsigned long expires, struct net *net)
+void fib6_run_gc(unsigned long expires, struct net *net, bool force)
 {
-       if (expires != ~0UL) {
+       unsigned long now;
+
+       if (force) {
                spin_lock_bh(&fib6_gc_lock);
-               gc_args.timeout = expires ? (int)expires :
-                       net->ipv6.sysctl.ip6_rt_gc_interval;
-       } else {
-               if (!spin_trylock_bh(&fib6_gc_lock)) {
-                       mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ);
-                       return;
-               }
-               gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval;
+       } else if (!spin_trylock_bh(&fib6_gc_lock)) {
+               mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ);
+               return;
        }
+       gc_args.timeout = expires ? (int)expires :
+                         net->ipv6.sysctl.ip6_rt_gc_interval;
 
        gc_args.more = icmp6_dst_gc();
 
        fib6_clean_all(net, fib6_age, 0, NULL);
+       now = jiffies;
+       net->ipv6.ip6_rt_last_gc = now;
 
        if (gc_args.more)
                mod_timer(&net->ipv6.ip6_fib_timer,
-                         round_jiffies(jiffies
+                         round_jiffies(now
                                        + net->ipv6.sysctl.ip6_rt_gc_interval));
        else
                del_timer(&net->ipv6.ip6_fib_timer);
@@ -1661,7 +1670,7 @@ void fib6_run_gc(unsigned long expires, struct net *net)
 
 static void fib6_gc_timer_cb(unsigned long arg)
 {
-       fib6_run_gc(0, (struct net *)arg);
+       fib6_run_gc(0, (struct net *)arg, true);
 }
 
 static int __net_init fib6_net_init(struct net *net)
index ecd60733e5e24afdb28a52c95686fec28e2e4d73..f2d0a42f80576b7bbeaebe7009fe6a476fb07236 100644 (file)
@@ -335,6 +335,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
        dev->rtnl_link_ops = &ip6gre_link_ops;
 
        nt->dev = dev;
+       nt->net = dev_net(dev);
        ip6gre_tnl_link_config(nt, 1);
 
        if (register_netdevice(dev) < 0)
@@ -1255,6 +1256,7 @@ static int ip6gre_tunnel_init(struct net_device *dev)
        tunnel = netdev_priv(dev);
 
        tunnel->dev = dev;
+       tunnel->net = dev_net(dev);
        strcpy(tunnel->parms.name, dev->name);
 
        memcpy(dev->dev_addr, &tunnel->parms.laddr, sizeof(struct in6_addr));
@@ -1275,6 +1277,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
        struct ip6_tnl *tunnel = netdev_priv(dev);
 
        tunnel->dev = dev;
+       tunnel->net = dev_net(dev);
        strcpy(tunnel->parms.name, dev->name);
 
        tunnel->hlen            = sizeof(struct ipv6hdr) + 4;
@@ -1450,6 +1453,7 @@ static int ip6gre_tap_init(struct net_device *dev)
        tunnel = netdev_priv(dev);
 
        tunnel->dev = dev;
+       tunnel->net = dev_net(dev);
        strcpy(tunnel->parms.name, dev->name);
 
        ip6gre_tnl_link_config(tunnel, 1);
@@ -1501,6 +1505,7 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
                eth_hw_addr_random(dev);
 
        nt->dev = dev;
+       nt->net = dev_net(dev);
        ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);
 
        /* Can use a lockless transmit, unless we generate output sequences */
index 2bab2aa597450813ae4bd60d362998830a7e7e3b..302d6fb1ff2b43fb027a633a0ba3f87eea58d4e9 100644 (file)
@@ -44,7 +44,7 @@
 #include <net/ip6_route.h>
 #include <net/addrconf.h>
 #include <net/xfrm.h>
-
+#include <net/inet_ecn.h>
 
 
 int ip6_rcv_finish(struct sk_buff *skb)
@@ -109,6 +109,10 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
        if (hdr->version != 6)
                goto err;
 
+       IP6_ADD_STATS_BH(dev_net(dev), idev,
+                        IPSTATS_MIB_NOECTPKTS +
+                               (ipv6_get_dsfield(hdr) & INET_ECN_MASK),
+                        max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
        /*
         * RFC4291 2.5.3
         * A packet received on an interface with a destination address
index 1e55866cead7425eefdff36c1ddca1aab9504286..d6e00a39274c4d62401b08fd7142338c8fb10c8d 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/netfilter_ipv6.h>
 #include <linux/slab.h>
 #include <linux/hash.h>
+#include <linux/etherdevice.h>
 
 #include <asm/uaccess.h>
 #include <linux/atomic.h>
@@ -315,6 +316,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
 
        t = netdev_priv(dev);
        t->parms = *p;
+       t->net = dev_net(dev);
        err = ip6_tnl_create2(dev);
        if (err < 0)
                goto failed_free;
@@ -374,7 +376,7 @@ static void
 ip6_tnl_dev_uninit(struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
-       struct net *net = dev_net(dev);
+       struct net *net = t->net;
        struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
 
        if (dev == ip6n->fb_tnl_dev)
@@ -741,7 +743,7 @@ int ip6_tnl_rcv_ctl(struct ip6_tnl *t,
 {
        struct __ip6_tnl_parm *p = &t->parms;
        int ret = 0;
-       struct net *net = dev_net(t->dev);
+       struct net *net = t->net;
 
        if ((p->flags & IP6_TNL_F_CAP_RCV) ||
            ((p->flags & IP6_TNL_F_CAP_PER_PACKET) &&
@@ -827,6 +829,9 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol,
                tstats->rx_packets++;
                tstats->rx_bytes += skb->len;
 
+               if (!net_eq(t->net, dev_net(t->dev)))
+                       skb_scrub_packet(skb);
+
                netif_rx(skb);
 
                rcu_read_unlock();
@@ -895,7 +900,7 @@ int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
 {
        struct __ip6_tnl_parm *p = &t->parms;
        int ret = 0;
-       struct net *net = dev_net(t->dev);
+       struct net *net = t->net;
 
        if (p->flags & IP6_TNL_F_CAP_XMIT) {
                struct net_device *ldev = NULL;
@@ -945,8 +950,8 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
                         int encap_limit,
                         __u32 *pmtu)
 {
-       struct net *net = dev_net(dev);
        struct ip6_tnl *t = netdev_priv(dev);
+       struct net *net = t->net;
        struct net_device_stats *stats = &t->dev->stats;
        struct ipv6hdr *ipv6h = ipv6_hdr(skb);
        struct ipv6_tel_txoption opt;
@@ -996,6 +1001,9 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
                goto tx_err_dst_release;
        }
 
+       if (!net_eq(t->net, dev_net(dev)))
+               skb_scrub_packet(skb);
+
        /*
         * Okay, now see if we can stuff it in the buffer as-is.
         */
@@ -1202,7 +1210,7 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
                int strict = (ipv6_addr_type(&p->raddr) &
                              (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
 
-               struct rt6_info *rt = rt6_lookup(dev_net(dev),
+               struct rt6_info *rt = rt6_lookup(t->net,
                                                 &p->raddr, &p->laddr,
                                                 p->link, strict);
 
@@ -1251,7 +1259,7 @@ ip6_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p)
 
 static int ip6_tnl_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p)
 {
-       struct net *net = dev_net(t->dev);
+       struct net *net = t->net;
        struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
        int err;
 
@@ -1463,8 +1471,10 @@ static void ip6_tnl_dev_setup(struct net_device *dev)
                dev->mtu-=8;
        dev->flags |= IFF_NOARP;
        dev->addr_len = sizeof(struct in6_addr);
-       dev->features |= NETIF_F_NETNS_LOCAL;
        dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
+       /* This perm addr will be used as interface identifier by IPv6 */
+       dev->addr_assign_type = NET_ADDR_RANDOM;
+       eth_random_addr(dev->perm_addr);
 }
 
 
@@ -1479,6 +1489,7 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
        struct ip6_tnl *t = netdev_priv(dev);
 
        t->dev = dev;
+       t->net = dev_net(dev);
        dev->tstats = alloc_percpu(struct pcpu_tstats);
        if (!dev->tstats)
                return -ENOMEM;
@@ -1596,9 +1607,9 @@ static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
 static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[],
                              struct nlattr *data[])
 {
-       struct ip6_tnl *t;
+       struct ip6_tnl *t = netdev_priv(dev);
        struct __ip6_tnl_parm p;
-       struct net *net = dev_net(dev);
+       struct net *net = t->net;
        struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
 
        if (dev == ip6n->fb_tnl_dev)
@@ -1699,14 +1710,24 @@ static struct xfrm6_tunnel ip6ip6_handler __read_mostly = {
 
 static void __net_exit ip6_tnl_destroy_tunnels(struct ip6_tnl_net *ip6n)
 {
+       struct net *net = dev_net(ip6n->fb_tnl_dev);
+       struct net_device *dev, *aux;
        int h;
        struct ip6_tnl *t;
        LIST_HEAD(list);
 
+       for_each_netdev_safe(net, dev, aux)
+               if (dev->rtnl_link_ops == &ip6_link_ops)
+                       unregister_netdevice_queue(dev, &list);
+
        for (h = 0; h < HASH_SIZE; h++) {
                t = rtnl_dereference(ip6n->tnls_r_l[h]);
                while (t != NULL) {
-                       unregister_netdevice_queue(t->dev, &list);
+                       /* If dev is in the same netns, it has already
+                        * been added to the list by the previous loop.
+                        */
+                       if (!net_eq(dev_net(t->dev), net))
+                               unregister_netdevice_queue(t->dev, &list);
                        t = rtnl_dereference(t->next);
                }
        }
@@ -1732,6 +1753,10 @@ static int __net_init ip6_tnl_init_net(struct net *net)
        if (!ip6n->fb_tnl_dev)
                goto err_alloc_dev;
        dev_net_set(ip6n->fb_tnl_dev, net);
+       /* FB netdevice is special: we have one, and only one per netns.
+        * Allowing to move it to another netns is clearly unsafe.
+        */
+       ip6n->fb_tnl_dev->features |= NETIF_F_NETNS_LOCAL;
 
        err = ip6_fb_tnl_dev_init(ip6n->fb_tnl_dev);
        if (err < 0)
index 583e8d435f9a2c47437d3897b7167ac4a4025a40..a60a84ef04f7f880b23479e9f8fa047b3905af75 100644 (file)
@@ -110,8 +110,8 @@ static struct kmem_cache *mrt_cachep __read_mostly;
 static struct mr6_table *ip6mr_new_table(struct net *net, u32 id);
 static void ip6mr_free_table(struct mr6_table *mrt);
 
-static int ip6_mr_forward(struct net *net, struct mr6_table *mrt,
-                         struct sk_buff *skb, struct mfc6_cache *cache);
+static void ip6_mr_forward(struct net *net, struct mr6_table *mrt,
+                          struct sk_buff *skb, struct mfc6_cache *cache);
 static int ip6mr_cache_report(struct mr6_table *mrt, struct sk_buff *pkt,
                              mifi_t mifi, int assert);
 static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
@@ -259,10 +259,12 @@ static void __net_exit ip6mr_rules_exit(struct net *net)
 {
        struct mr6_table *mrt, *next;
 
+       rtnl_lock();
        list_for_each_entry_safe(mrt, next, &net->ipv6.mr6_tables, list) {
                list_del(&mrt->list);
                ip6mr_free_table(mrt);
        }
+       rtnl_unlock();
        fib_rules_unregister(net->ipv6.mr6_rules_ops);
 }
 #else
@@ -289,7 +291,10 @@ static int __net_init ip6mr_rules_init(struct net *net)
 
 static void __net_exit ip6mr_rules_exit(struct net *net)
 {
+       rtnl_lock();
        ip6mr_free_table(net->ipv6.mrt6);
+       net->ipv6.mrt6 = NULL;
+       rtnl_unlock();
 }
 #endif
 
@@ -2069,8 +2074,8 @@ static int ip6mr_find_vif(struct mr6_table *mrt, struct net_device *dev)
        return ct;
 }
 
-static int ip6_mr_forward(struct net *net, struct mr6_table *mrt,
-                         struct sk_buff *skb, struct mfc6_cache *cache)
+static void ip6_mr_forward(struct net *net, struct mr6_table *mrt,
+                          struct sk_buff *skb, struct mfc6_cache *cache)
 {
        int psend = -1;
        int vif, ct;
@@ -2151,12 +2156,11 @@ forward:
 last_forward:
        if (psend != -1) {
                ip6mr_forward2(net, mrt, skb, cache, psend);
-               return 0;
+               return;
        }
 
 dont_forward:
        kfree_skb(skb);
-       return 0;
 }
 
 
index 99cd65c715cdd4a41a31f6ddc1fa28d327651634..98ead2b1a669272be8c60676505e831dcda87afb 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/pkt_sched.h>
 #include <net/mld.h>
 
 #include <linux/netfilter.h>
@@ -106,10 +107,12 @@ static int ip6_mc_add_src(struct inet6_dev *idev, const struct in6_addr *pmca,
 static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
                            struct inet6_dev *idev);
 
-
-#define IGMP6_UNSOLICITED_IVAL (10*HZ)
 #define MLD_QRV_DEFAULT                2
 
+/* RFC3810, 8.1 Query Version Distinctions */
+#define MLD_V1_QUERY_LEN       24
+#define MLD_V2_QUERY_LEN_MIN   28
+
 #define MLD_V1_SEEN(idev) (dev_net((idev)->dev)->ipv6.devconf_all->force_mld_version == 1 || \
                (idev)->cnf.force_mld_version == 1 || \
                ((idev)->mc_v1_seen && \
@@ -128,6 +131,18 @@ int sysctl_mld_max_msf __read_mostly = IPV6_MLD_MAX_MSF;
             pmc != NULL;                                       \
             pmc = rcu_dereference(pmc->next))
 
+static int unsolicited_report_interval(struct inet6_dev *idev)
+{
+       int iv;
+
+       if (MLD_V1_SEEN(idev))
+               iv = idev->cnf.mldv1_unsolicited_report_interval;
+       else
+               iv = idev->cnf.mldv2_unsolicited_report_interval;
+
+       return iv > 0 ? iv : 1;
+}
+
 int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
 {
        struct net_device *dev = NULL;
@@ -984,24 +999,24 @@ bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
 
 static void mld_gq_start_timer(struct inet6_dev *idev)
 {
-       int tv = net_random() % idev->mc_maxdelay;
+       unsigned long tv = net_random() % idev->mc_maxdelay;
 
        idev->mc_gq_running = 1;
        if (!mod_timer(&idev->mc_gq_timer, jiffies+tv+2))
                in6_dev_hold(idev);
 }
 
-static void mld_ifc_start_timer(struct inet6_dev *idev, int delay)
+static void mld_ifc_start_timer(struct inet6_dev *idev, unsigned long delay)
 {
-       int tv = net_random() % delay;
+       unsigned long tv = net_random() % delay;
 
        if (!mod_timer(&idev->mc_ifc_timer, jiffies+tv+2))
                in6_dev_hold(idev);
 }
 
-static void mld_dad_start_timer(struct inet6_dev *idev, int delay)
+static void mld_dad_start_timer(struct inet6_dev *idev, unsigned long delay)
 {
-       int tv = net_random() % delay;
+       unsigned long tv = net_random() % delay;
 
        if (!mod_timer(&idev->mc_dad_timer, jiffies+tv+2))
                in6_dev_hold(idev);
@@ -1134,13 +1149,11 @@ int igmp6_event_query(struct sk_buff *skb)
            !(group_type&IPV6_ADDR_MULTICAST))
                return -EINVAL;
 
-       if (len == 24) {
+       if (len == MLD_V1_QUERY_LEN) {
                int switchback;
                /* MLDv1 router present */
 
-               /* Translate milliseconds to jiffies */
-               max_delay = (ntohs(mld->mld_maxdelay)*HZ)/1000;
-
+               max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay));
                switchback = (idev->mc_qrv + 1) * max_delay;
                idev->mc_v1_seen = jiffies + switchback;
 
@@ -1150,17 +1163,18 @@ int igmp6_event_query(struct sk_buff *skb)
                        __in6_dev_put(idev);
                /* clear deleted report items */
                mld_clear_delrec(idev);
-       } else if (len >= 28) {
+       } else if (len >= MLD_V2_QUERY_LEN_MIN) {
                int srcs_offset = sizeof(struct mld2_query) -
                                  sizeof(struct icmp6hdr);
                if (!pskb_may_pull(skb, srcs_offset))
                        return -EINVAL;
 
                mlh2 = (struct mld2_query *)skb_transport_header(skb);
-               max_delay = (MLDV2_MRC(ntohs(mlh2->mld2q_mrc))*HZ)/1000;
-               if (!max_delay)
-                       max_delay = 1;
+
+               max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mlh2->mld2q_mrc))), 1UL);
+
                idev->mc_maxdelay = max_delay;
+
                if (mlh2->mld2q_qrv)
                        idev->mc_qrv = mlh2->mld2q_qrv;
                if (group_type == IPV6_ADDR_ANY) { /* general query */
@@ -1376,6 +1390,7 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size)
        if (!skb)
                return NULL;
 
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(skb, hlen);
 
        if (__ipv6_get_lladdr(idev, &addr_buf, IFA_F_TENTATIVE)) {
@@ -1769,7 +1784,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
                rcu_read_unlock();
                return;
        }
-
+       skb->priority = TC_PRIO_CONTROL;
        skb_reserve(skb, hlen);
 
        if (ipv6_get_lladdr(dev, &addr_buf, IFA_F_TENTATIVE)) {
@@ -2156,7 +2171,7 @@ static void igmp6_join_group(struct ifmcaddr6 *ma)
 
        igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REPORT);
 
-       delay = net_random() % IGMP6_UNSOLICITED_IVAL;
+       delay = net_random() % unsolicited_report_interval(ma->idev);
 
        spin_lock_bh(&ma->mca_lock);
        if (del_timer(&ma->mca_timer)) {
@@ -2323,7 +2338,7 @@ void ipv6_mc_init_dev(struct inet6_dev *idev)
        setup_timer(&idev->mc_dad_timer, mld_dad_timer_expire,
                    (unsigned long)idev);
        idev->mc_qrv = MLD_QRV_DEFAULT;
-       idev->mc_maxdelay = IGMP6_UNSOLICITED_IVAL;
+       idev->mc_maxdelay = unsolicited_report_interval(idev);
        idev->mc_v1_seen = 0;
        write_unlock_bh(&idev->lock);
 }
index b3b5730b48c5c297e1d425fc1d9654a8e9fd8bfa..04d31c2fbef1ede543bbc4942873722f66a9b524 100644 (file)
@@ -479,7 +479,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
        if (ifp) {
                src_addr = solicited_addr;
                if (ifp->flags & IFA_F_OPTIMISTIC)
-                       override = 0;
+                       override = false;
                inc_opt |= ifp->idev->cnf.force_tllao;
                in6_ifa_put(ifp);
        } else {
@@ -557,7 +557,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
        }
 
        if (ipv6_addr_any(saddr))
-               inc_opt = 0;
+               inc_opt = false;
        if (inc_opt)
                optlen += ndisc_opt_addr_space(dev);
 
@@ -790,7 +790,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
                     (is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
                        if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
                            skb->pkt_type != PACKET_HOST &&
-                           inc != 0 &&
+                           inc &&
                            idev->nd_parms->proxy_delay != 0) {
                                /*
                                 * for anycast or proxy,
@@ -1369,8 +1369,10 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
        if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts))
                return;
 
-       if (!ndopts.nd_opts_rh)
+       if (!ndopts.nd_opts_rh) {
+               ip6_redirect_no_header(skb, dev_net(skb->dev), 0, 0);
                return;
+       }
 
        hdr = (u8 *)ndopts.nd_opts_rh;
        hdr += 8;
@@ -1576,7 +1578,7 @@ static int ndisc_netdev_event(struct notifier_block *this, unsigned long event,
        switch (event) {
        case NETDEV_CHANGEADDR:
                neigh_changeaddr(&nd_tbl, dev);
-               fib6_run_gc(~0UL, net);
+               fib6_run_gc(0, net, false);
                idev = in6_dev_get(dev);
                if (!idev)
                        break;
@@ -1586,7 +1588,7 @@ static int ndisc_netdev_event(struct notifier_block *this, unsigned long event,
                break;
        case NETDEV_DOWN:
                neigh_ifdown(&nd_tbl, dev);
-               fib6_run_gc(~0UL, net);
+               fib6_run_gc(0, net, false);
                break;
        case NETDEV_NOTIFY_PEERS:
                ndisc_send_unsol_na(dev);
index 4433ab40e7de05a2b518e20dacfa370d736bded3..a7f842b29b67b2ca5ff2c2cbe13588e3098ce44b 100644 (file)
@@ -153,6 +153,19 @@ config IP6_NF_TARGET_REJECT
 
          To compile it as a module, choose M here.  If unsure, say N.
 
+config IP6_NF_TARGET_SYNPROXY
+       tristate "SYNPROXY target support"
+       depends on NF_CONNTRACK && NETFILTER_ADVANCED
+       select NETFILTER_SYNPROXY
+       select SYN_COOKIES
+       help
+         The SYNPROXY target allows you to intercept TCP connections and
+         establish them using syncookies before they are passed on to the
+         server. This allows to avoid conntrack and server resource usage
+         during SYN-flood attacks.
+
+         To compile it as a module, choose M here. If unsure, say N.
+
 config IP6_NF_MANGLE
        tristate "Packet mangling"
        default m if NETFILTER_ADVANCED=n
index 2d11fcc2cf3c5c3906b851e9c5daad69de26e0ed..2b53738f798cd3a9898d89a2a1a76b48ffe983b8 100644 (file)
@@ -14,7 +14,7 @@ obj-$(CONFIG_NF_NAT_IPV6) += ip6table_nat.o
 nf_conntrack_ipv6-y  :=  nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o
 
 # l3 independent conntrack
-obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o nf_defrag_ipv6.o
+obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o
 
 nf_nat_ipv6-y          := nf_nat_l3proto_ipv6.o nf_nat_proto_icmpv6.o
 obj-$(CONFIG_NF_NAT_IPV6) += nf_nat_ipv6.o
@@ -37,3 +37,4 @@ obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o
 obj-$(CONFIG_IP6_NF_TARGET_MASQUERADE) += ip6t_MASQUERADE.o
 obj-$(CONFIG_IP6_NF_TARGET_NPT) += ip6t_NPT.o
 obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o
+obj-$(CONFIG_IP6_NF_TARGET_SYNPROXY) += ip6t_SYNPROXY.o
index 47bff610751922ebd80b21eb59387a334af9b3fb..3e4e92d5e157358520fc5dc1cb04c3c18175df9f 100644 (file)
@@ -76,7 +76,7 @@ static int masq_device_event(struct notifier_block *this,
 
        if (event == NETDEV_DOWN)
                nf_ct_iterate_cleanup(net, device_cmp,
-                                     (void *)(long)dev->ifindex);
+                                     (void *)(long)dev->ifindex, 0, 0);
 
        return NOTIFY_DONE;
 }
index 70f9abc0efe9a0ba0bc8fdbb6060f3bfe593291f..56eef30ee5f6afb2ad1338649b30ffe8a5c5b948 100644 (file)
@@ -169,7 +169,25 @@ static void send_reset(struct net *net, struct sk_buff *oldskb)
 
        nf_ct_attach(nskb, oldskb);
 
-       ip6_local_out(nskb);
+#ifdef CONFIG_BRIDGE_NETFILTER
+       /* If we use ip6_local_out for bridged traffic, the MAC source on
+        * the RST will be ours, instead of the destination's.  This confuses
+        * some routers/firewalls, and they drop the packet.  So we need to
+        * build the eth header using the original destination's MAC as the
+        * source, and send the RST packet directly.
+        */
+       if (oldskb->nf_bridge) {
+               struct ethhdr *oeth = eth_hdr(oldskb);
+               nskb->dev = oldskb->nf_bridge->physindev;
+               nskb->protocol = htons(ETH_P_IPV6);
+               ip6h->payload_len = htons(sizeof(struct tcphdr));
+               if (dev_hard_header(nskb, nskb->dev, ntohs(nskb->protocol),
+                                   oeth->h_source, oeth->h_dest, nskb->len) < 0)
+                       return;
+               dev_queue_xmit(nskb);
+       } else
+#endif
+               ip6_local_out(nskb);
 }
 
 static inline void
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
new file mode 100644 (file)
index 0000000..4270a9b
--- /dev/null
@@ -0,0 +1,495 @@
+/*
+ * Copyright (c) 2013 Patrick McHardy <kaber@trash.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <net/ip6_checksum.h>
+#include <net/ip6_route.h>
+#include <net/tcp.h>
+
+#include <linux/netfilter_ipv6/ip6_tables.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_SYNPROXY.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
+#include <net/netfilter/nf_conntrack_synproxy.h>
+
+static struct ipv6hdr *
+synproxy_build_ip(struct sk_buff *skb, const struct in6_addr *saddr,
+                                      const struct in6_addr *daddr)
+{
+       struct ipv6hdr *iph;
+
+       skb_reset_network_header(skb);
+       iph = (struct ipv6hdr *)skb_put(skb, sizeof(*iph));
+       ip6_flow_hdr(iph, 0, 0);
+       iph->hop_limit  = 64;   //XXX
+       iph->nexthdr    = IPPROTO_TCP;
+       iph->saddr      = *saddr;
+       iph->daddr      = *daddr;
+
+       return iph;
+}
+
+static void
+synproxy_send_tcp(const struct sk_buff *skb, struct sk_buff *nskb,
+                 struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo,
+                 struct ipv6hdr *niph, struct tcphdr *nth,
+                 unsigned int tcp_hdr_size)
+{
+       struct net *net = nf_ct_net((struct nf_conn *)nfct);
+       struct dst_entry *dst;
+       struct flowi6 fl6;
+
+       nth->check = ~tcp_v6_check(tcp_hdr_size, &niph->saddr, &niph->daddr, 0);
+       nskb->ip_summed   = CHECKSUM_PARTIAL;
+       nskb->csum_start  = (unsigned char *)nth - nskb->head;
+       nskb->csum_offset = offsetof(struct tcphdr, check);
+
+       memset(&fl6, 0, sizeof(fl6));
+       fl6.flowi6_proto = IPPROTO_TCP;
+       fl6.saddr = niph->saddr;
+       fl6.daddr = niph->daddr;
+       fl6.fl6_sport = nth->source;
+       fl6.fl6_dport = nth->dest;
+       security_skb_classify_flow((struct sk_buff *)skb, flowi6_to_flowi(&fl6));
+       dst = ip6_route_output(net, NULL, &fl6);
+       if (dst == NULL || dst->error) {
+               dst_release(dst);
+               goto free_nskb;
+       }
+       dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
+       if (IS_ERR(dst))
+               goto free_nskb;
+
+       skb_dst_set(nskb, dst);
+
+       if (nfct) {
+               nskb->nfct = nfct;
+               nskb->nfctinfo = ctinfo;
+               nf_conntrack_get(nfct);
+       }
+
+       ip6_local_out(nskb);
+       return;
+
+free_nskb:
+       kfree_skb(nskb);
+}
+
+static void
+synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th,
+                           const struct synproxy_options *opts)
+{
+       struct sk_buff *nskb;
+       struct ipv6hdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+       u16 mss = opts->mss;
+
+       iph = ipv6_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, &iph->daddr, &iph->saddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->dest;
+       nth->dest       = th->source;
+       nth->seq        = htonl(__cookie_v6_init_sequence(iph, th, &mss));
+       nth->ack_seq    = htonl(ntohl(th->seq) + 1);
+       tcp_flag_word(nth) = TCP_FLAG_SYN | TCP_FLAG_ACK;
+       if (opts->options & XT_SYNPROXY_OPT_ECN)
+               tcp_flag_word(nth) |= TCP_FLAG_ECE;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = 0;
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY,
+                         niph, nth, tcp_hdr_size);
+}
+
+static void
+synproxy_send_server_syn(const struct synproxy_net *snet,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        const struct synproxy_options *opts, u32 recv_seq)
+{
+       struct sk_buff *nskb;
+       struct ipv6hdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+
+       iph = ipv6_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, &iph->saddr, &iph->daddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->source;
+       nth->dest       = th->dest;
+       nth->seq        = htonl(recv_seq - 1);
+       /* ack_seq is used to relay our ISN to the synproxy hook to initialize
+        * sequence number translation once a connection tracking entry exists.
+        */
+       nth->ack_seq    = htonl(ntohl(th->ack_seq) - 1);
+       tcp_flag_word(nth) = TCP_FLAG_SYN;
+       if (opts->options & XT_SYNPROXY_OPT_ECN)
+               tcp_flag_word(nth) |= TCP_FLAG_ECE | TCP_FLAG_CWR;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = th->window;
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW,
+                         niph, nth, tcp_hdr_size);
+}
+
+static void
+synproxy_send_server_ack(const struct synproxy_net *snet,
+                        const struct ip_ct_tcp *state,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        const struct synproxy_options *opts)
+{
+       struct sk_buff *nskb;
+       struct ipv6hdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+
+       iph = ipv6_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, &iph->daddr, &iph->saddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->dest;
+       nth->dest       = th->source;
+       nth->seq        = htonl(ntohl(th->ack_seq));
+       nth->ack_seq    = htonl(ntohl(th->seq) + 1);
+       tcp_flag_word(nth) = TCP_FLAG_ACK;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = htons(state->seen[IP_CT_DIR_ORIGINAL].td_maxwin);
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
+}
+
+static void
+synproxy_send_client_ack(const struct synproxy_net *snet,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        const struct synproxy_options *opts)
+{
+       struct sk_buff *nskb;
+       struct ipv6hdr *iph, *niph;
+       struct tcphdr *nth;
+       unsigned int tcp_hdr_size;
+
+       iph = ipv6_hdr(skb);
+
+       tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts);
+       nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER,
+                        GFP_ATOMIC);
+       if (nskb == NULL)
+               return;
+       skb_reserve(nskb, MAX_TCP_HEADER);
+
+       niph = synproxy_build_ip(nskb, &iph->saddr, &iph->daddr);
+
+       skb_reset_transport_header(nskb);
+       nth = (struct tcphdr *)skb_put(nskb, tcp_hdr_size);
+       nth->source     = th->source;
+       nth->dest       = th->dest;
+       nth->seq        = htonl(ntohl(th->seq) + 1);
+       nth->ack_seq    = th->ack_seq;
+       tcp_flag_word(nth) = TCP_FLAG_ACK;
+       nth->doff       = tcp_hdr_size / 4;
+       nth->window     = ntohs(htons(th->window) >> opts->wscale);
+       nth->check      = 0;
+       nth->urg_ptr    = 0;
+
+       synproxy_build_options(nth, opts);
+
+       synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size);
+}
+
+static bool
+synproxy_recv_client_ack(const struct synproxy_net *snet,
+                        const struct sk_buff *skb, const struct tcphdr *th,
+                        struct synproxy_options *opts, u32 recv_seq)
+{
+       int mss;
+
+       mss = __cookie_v6_check(ipv6_hdr(skb), th, ntohl(th->ack_seq) - 1);
+       if (mss == 0) {
+               this_cpu_inc(snet->stats->cookie_invalid);
+               return false;
+       }
+
+       this_cpu_inc(snet->stats->cookie_valid);
+       opts->mss = mss;
+
+       if (opts->options & XT_SYNPROXY_OPT_TIMESTAMP)
+               synproxy_check_timestamp_cookie(opts);
+
+       synproxy_send_server_syn(snet, skb, th, opts, recv_seq);
+       return true;
+}
+
+static unsigned int
+synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par)
+{
+       const struct xt_synproxy_info *info = par->targinfo;
+       struct synproxy_net *snet = synproxy_pernet(dev_net(par->in));
+       struct synproxy_options opts = {};
+       struct tcphdr *th, _th;
+
+       if (nf_ip6_checksum(skb, par->hooknum, par->thoff, IPPROTO_TCP))
+               return NF_DROP;
+
+       th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th);
+       if (th == NULL)
+               return NF_DROP;
+
+       synproxy_parse_options(skb, par->thoff, th, &opts);
+
+       if (th->syn) {
+               /* Initial SYN from client */
+               this_cpu_inc(snet->stats->syn_received);
+
+               if (th->ece && th->cwr)
+                       opts.options |= XT_SYNPROXY_OPT_ECN;
+
+               opts.options &= info->options;
+               if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
+                       synproxy_init_timestamp_cookie(info, &opts);
+               else
+                       opts.options &= ~(XT_SYNPROXY_OPT_WSCALE |
+                                         XT_SYNPROXY_OPT_SACK_PERM |
+                                         XT_SYNPROXY_OPT_ECN);
+
+               synproxy_send_client_synack(skb, th, &opts);
+       } else if (th->ack && !(th->fin || th->rst))
+               /* ACK from client */
+               synproxy_recv_client_ack(snet, skb, th, &opts, ntohl(th->seq));
+
+       return NF_DROP;
+}
+
+static unsigned int ipv6_synproxy_hook(unsigned int hooknum,
+                                      struct sk_buff *skb,
+                                      const struct net_device *in,
+                                      const struct net_device *out,
+                                      int (*okfn)(struct sk_buff *))
+{
+       struct synproxy_net *snet = synproxy_pernet(dev_net(in ? : out));
+       enum ip_conntrack_info ctinfo;
+       struct nf_conn *ct;
+       struct nf_conn_synproxy *synproxy;
+       struct synproxy_options opts = {};
+       const struct ip_ct_tcp *state;
+       struct tcphdr *th, _th;
+       __be16 frag_off;
+       u8 nexthdr;
+       int thoff;
+
+       ct = nf_ct_get(skb, &ctinfo);
+       if (ct == NULL)
+               return NF_ACCEPT;
+
+       synproxy = nfct_synproxy(ct);
+       if (synproxy == NULL)
+               return NF_ACCEPT;
+
+       if (nf_is_loopback_packet(skb))
+               return NF_ACCEPT;
+
+       nexthdr = ipv6_hdr(skb)->nexthdr;
+       thoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr,
+                                &frag_off);
+       if (thoff < 0)
+               return NF_ACCEPT;
+
+       th = skb_header_pointer(skb, thoff, sizeof(_th), &_th);
+       if (th == NULL)
+               return NF_DROP;
+
+       state = &ct->proto.tcp;
+       switch (state->state) {
+       case TCP_CONNTRACK_CLOSE:
+               if (th->rst && !test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
+                       nf_ct_seqadj_init(ct, ctinfo, synproxy->isn -
+                                                     ntohl(th->seq) + 1);
+                       break;
+               }
+
+               if (!th->syn || th->ack ||
+                   CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL)
+                       break;
+
+               /* Reopened connection - reset the sequence number and timestamp
+                * adjustments, they will get initialized once the connection is
+                * reestablished.
+                */
+               nf_ct_seqadj_init(ct, ctinfo, 0);
+               synproxy->tsoff = 0;
+               this_cpu_inc(snet->stats->conn_reopened);
+
+               /* fall through */
+       case TCP_CONNTRACK_SYN_SENT:
+               synproxy_parse_options(skb, thoff, th, &opts);
+
+               if (!th->syn && th->ack &&
+                   CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) {
+                       /* Keep-Alives are sent with SEG.SEQ = SND.NXT-1,
+                        * therefore we need to add 1 to make the SYN sequence
+                        * number match the one of first SYN.
+                        */
+                       if (synproxy_recv_client_ack(snet, skb, th, &opts,
+                                                    ntohl(th->seq) + 1))
+                               this_cpu_inc(snet->stats->cookie_retrans);
+
+                       return NF_DROP;
+               }
+
+               synproxy->isn = ntohl(th->ack_seq);
+               if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
+                       synproxy->its = opts.tsecr;
+               break;
+       case TCP_CONNTRACK_SYN_RECV:
+               if (!th->syn || !th->ack)
+                       break;
+
+               synproxy_parse_options(skb, thoff, th, &opts);
+               if (opts.options & XT_SYNPROXY_OPT_TIMESTAMP)
+                       synproxy->tsoff = opts.tsval - synproxy->its;
+
+               opts.options &= ~(XT_SYNPROXY_OPT_MSS |
+                                 XT_SYNPROXY_OPT_WSCALE |
+                                 XT_SYNPROXY_OPT_SACK_PERM);
+
+               swap(opts.tsval, opts.tsecr);
+               synproxy_send_server_ack(snet, state, skb, th, &opts);
+
+               nf_ct_seqadj_init(ct, ctinfo, synproxy->isn - ntohl(th->seq));
+
+               swap(opts.tsval, opts.tsecr);
+               synproxy_send_client_ack(snet, skb, th, &opts);
+
+               consume_skb(skb);
+               return NF_STOLEN;
+       default:
+               break;
+       }
+
+       synproxy_tstamp_adjust(skb, thoff, th, ct, ctinfo, synproxy);
+       return NF_ACCEPT;
+}
+
+static int synproxy_tg6_check(const struct xt_tgchk_param *par)
+{
+       const struct ip6t_entry *e = par->entryinfo;
+
+       if (!(e->ipv6.flags & IP6T_F_PROTO) ||
+           e->ipv6.proto != IPPROTO_TCP ||
+           e->ipv6.invflags & XT_INV_PROTO)
+               return -EINVAL;
+
+       return nf_ct_l3proto_try_module_get(par->family);
+}
+
+static void synproxy_tg6_destroy(const struct xt_tgdtor_param *par)
+{
+       nf_ct_l3proto_module_put(par->family);
+}
+
+static struct xt_target synproxy_tg6_reg __read_mostly = {
+       .name           = "SYNPROXY",
+       .family         = NFPROTO_IPV6,
+       .target         = synproxy_tg6,
+       .targetsize     = sizeof(struct xt_synproxy_info),
+       .checkentry     = synproxy_tg6_check,
+       .destroy        = synproxy_tg6_destroy,
+       .me             = THIS_MODULE,
+};
+
+static struct nf_hook_ops ipv6_synproxy_ops[] __read_mostly = {
+       {
+               .hook           = ipv6_synproxy_hook,
+               .owner          = THIS_MODULE,
+               .pf             = NFPROTO_IPV6,
+               .hooknum        = NF_INET_LOCAL_IN,
+               .priority       = NF_IP_PRI_CONNTRACK_CONFIRM - 1,
+       },
+       {
+               .hook           = ipv6_synproxy_hook,
+               .owner          = THIS_MODULE,
+               .pf             = NFPROTO_IPV6,
+               .hooknum        = NF_INET_POST_ROUTING,
+               .priority       = NF_IP_PRI_CONNTRACK_CONFIRM - 1,
+       },
+};
+
+static int __init synproxy_tg6_init(void)
+{
+       int err;
+
+       err = nf_register_hooks(ipv6_synproxy_ops,
+                               ARRAY_SIZE(ipv6_synproxy_ops));
+       if (err < 0)
+               goto err1;
+
+       err = xt_register_target(&synproxy_tg6_reg);
+       if (err < 0)
+               goto err2;
+
+       return 0;
+
+err2:
+       nf_unregister_hooks(ipv6_synproxy_ops, ARRAY_SIZE(ipv6_synproxy_ops));
+err1:
+       return err;
+}
+
+static void __exit synproxy_tg6_exit(void)
+{
+       xt_unregister_target(&synproxy_tg6_reg);
+       nf_unregister_hooks(ipv6_synproxy_ops, ARRAY_SIZE(ipv6_synproxy_ops));
+}
+
+module_init(synproxy_tg6_init);
+module_exit(synproxy_tg6_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
index c9b6a6e6a1e8877dd634b51680fa2d5a5d9f2148..d6e4dd8b58dfaf67a9f64fe8bfafcf2f9f6b24ea 100644 (file)
@@ -28,6 +28,7 @@
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_zones.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
 #include <net/netfilter/nf_nat_helper.h>
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
@@ -158,11 +159,7 @@ static unsigned int ipv6_confirm(unsigned int hooknum,
        /* adjust seqs for loopback traffic only in outgoing direction */
        if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
            !nf_is_loopback_packet(skb)) {
-               typeof(nf_nat_seq_adjust_hook) seq_adjust;
-
-               seq_adjust = rcu_dereference(nf_nat_seq_adjust_hook);
-               if (!seq_adjust ||
-                   !seq_adjust(skb, ct, ctinfo, protoff)) {
+               if (!nf_ct_seq_adjust(skb, ct, ctinfo, protoff)) {
                        NF_CT_STAT_INC_ATOMIC(nf_ct_net(ct), drop);
                        return NF_DROP;
                }
index 51c3285b5d9b582cb1d6101d3fafc70c781f5a74..091d066a57b3711c5bd0eb5a352573d0aa2f3776 100644 (file)
@@ -91,6 +91,10 @@ static const struct snmp_mib snmp6_ipstats_list[] = {
        SNMP_MIB_ITEM("Ip6InBcastOctets", IPSTATS_MIB_INBCASTOCTETS),
        SNMP_MIB_ITEM("Ip6OutBcastOctets", IPSTATS_MIB_OUTBCASTOCTETS),
        /* IPSTATS_MIB_CSUMERRORS is not relevant in IPv6 (no checksum) */
+       SNMP_MIB_ITEM("Ip6InNoECTPkts", IPSTATS_MIB_NOECTPKTS),
+       SNMP_MIB_ITEM("Ip6InECT1Pkts", IPSTATS_MIB_ECT1PKTS),
+       SNMP_MIB_ITEM("Ip6InECT0Pkts", IPSTATS_MIB_ECT0PKTS),
+       SNMP_MIB_ITEM("Ip6InCEPkts", IPSTATS_MIB_CEPKTS),
        SNMP_MIB_SENTINEL
 };
 
index c45f7a5c36e96f98487ca194c5f08e5d0f931852..c1e53349820348b859f2f973454b40786635838f 100644 (file)
@@ -63,6 +63,8 @@
 #include <linux/seq_file.h>
 #include <linux/export.h>
 
+#define        ICMPV6_HDRLEN   4       /* ICMPv6 header, RFC 4443 Section 2.1 */
+
 static struct raw_hashinfo raw_v6_hashinfo = {
        .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock),
 };
@@ -108,11 +110,14 @@ found:
  */
 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
 {
-       struct icmp6hdr *_hdr;
+       struct icmp6hdr _hdr;
        const struct icmp6hdr *hdr;
 
+       /* We require only the four bytes of the ICMPv6 header, not any
+        * additional bytes of message body in "struct icmp6hdr".
+        */
        hdr = skb_header_pointer(skb, skb_transport_offset(skb),
-                                sizeof(_hdr), &_hdr);
+                                ICMPV6_HDRLEN, &_hdr);
        if (hdr) {
                const __u32 *data = &raw6_sk(sk)->filter.data[0];
                unsigned int type = hdr->icmp6_type;
index 790d9f4b8b0b21c1d4dd4577ee6a472bd96fd729..1aeb473b2cc695d8d2b0a3696972ec9228455d14 100644 (file)
@@ -490,6 +490,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
        ipv6_hdr(head)->payload_len = htons(payload_len);
        ipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn);
        IP6CB(head)->nhoff = nhoff;
+       IP6CB(head)->flags |= IP6SKB_FRAGMENTED;
 
        /* Yes, and fold redundant checksum back. 8) */
        if (head->ip_summed == CHECKSUM_COMPLETE)
@@ -524,6 +525,9 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
        struct net *net = dev_net(skb_dst(skb)->dev);
        int evicted;
 
+       if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED)
+               goto fail_hdr;
+
        IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMREQDS);
 
        /* Jumbo payload inhibits frag. header */
@@ -544,6 +548,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
                                 ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMOKS);
 
                IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb);
+               IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
                return 1;
        }
 
index a8c891aa24645e9a45d2f8e47712b0698a29b216..55236a84c7481b2393dc2f1e6130bd257686d4e2 100644 (file)
@@ -283,9 +283,8 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net,
 
                memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
                rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
-               rt->rt6i_genid = rt_genid(net);
+               rt->rt6i_genid = rt_genid_ipv6(net);
                INIT_LIST_HEAD(&rt->rt6i_siblings);
-               rt->rt6i_nsiblings = 0;
        }
        return rt;
 }
@@ -1062,7 +1061,7 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie)
         * DST_OBSOLETE_FORCE_CHK which forces validation calls down
         * into this function always.
         */
-       if (rt->rt6i_genid != rt_genid(dev_net(rt->dst.dev)))
+       if (rt->rt6i_genid != rt_genid_ipv6(dev_net(rt->dst.dev)))
                return NULL;
 
        if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie))
@@ -1178,6 +1177,27 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark)
 }
 EXPORT_SYMBOL_GPL(ip6_redirect);
 
+void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
+                           u32 mark)
+{
+       const struct ipv6hdr *iph = ipv6_hdr(skb);
+       const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
+       struct dst_entry *dst;
+       struct flowi6 fl6;
+
+       memset(&fl6, 0, sizeof(fl6));
+       fl6.flowi6_oif = oif;
+       fl6.flowi6_mark = mark;
+       fl6.flowi6_flags = 0;
+       fl6.daddr = msg->dest;
+       fl6.saddr = iph->daddr;
+
+       dst = ip6_route_output(net, NULL, &fl6);
+       if (!dst->error)
+               rt6_do_redirect(dst, NULL, skb);
+       dst_release(dst);
+}
+
 void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk)
 {
        ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if, sk->sk_mark);
@@ -1311,7 +1331,6 @@ static void icmp6_clean_all(int (*func)(struct rt6_info *rt, void *arg),
 
 static int ip6_dst_gc(struct dst_ops *ops)
 {
-       unsigned long now = jiffies;
        struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops);
        int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval;
        int rt_max_size = net->ipv6.sysctl.ip6_rt_max_size;
@@ -1321,13 +1340,12 @@ static int ip6_dst_gc(struct dst_ops *ops)
        int entries;
 
        entries = dst_entries_get_fast(ops);
-       if (time_after(rt_last_gc + rt_min_interval, now) &&
+       if (time_after(rt_last_gc + rt_min_interval, jiffies) &&
            entries <= rt_max_size)
                goto out;
 
        net->ipv6.ip6_rt_gc_expire++;
-       fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net);
-       net->ipv6.ip6_rt_last_gc = now;
+       fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net, entries > rt_max_size);
        entries = dst_entries_get_slow(ops);
        if (entries < ops->gc_thresh)
                net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1;
@@ -2827,7 +2845,7 @@ int ipv6_sysctl_rtcache_flush(struct ctl_table *ctl, int write,
        net = (struct net *)ctl->extra1;
        delay = net->ipv6.sysctl.flush_delay;
        proc_dointvec(ctl, write, buffer, lenp, ppos);
-       fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net);
+       fib6_run_gc(delay <= 0 ? 0 : (unsigned long)delay, net, delay > 0);
        return 0;
 }
 
index a3437a4cd07ecfdd28cbe47e0acd00e379ba9b19..f18f842ac8931a7702ebe0e250e3d595f5d187bb 100644 (file)
@@ -621,7 +621,7 @@ static int ipip6_rcv(struct sk_buff *skb)
                tstats->rx_packets++;
                tstats->rx_bytes += skb->len;
 
-               if (tunnel->net != dev_net(tunnel->dev))
+               if (!net_eq(tunnel->net, dev_net(tunnel->dev)))
                        skb_scrub_packet(skb);
                netif_rx(skb);
 
@@ -860,7 +860,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
                        tunnel->err_count = 0;
        }
 
-       if (tunnel->net != dev_net(dev))
+       if (!net_eq(tunnel->net, dev_net(dev)))
                skb_scrub_packet(skb);
 
        /*
@@ -1589,7 +1589,7 @@ static void __net_exit sit_destroy_tunnels(struct sit_net *sitn, struct list_hea
                                /* If dev is in the same netns, it has already
                                 * been added to the list by the previous loop.
                                 */
-                               if (dev_net(t->dev) != net)
+                               if (!net_eq(dev_net(t->dev), net))
                                        unregister_netdevice_queue(t->dev,
                                                                   head);
                                t = rtnl_dereference(t->next);
index d5dda20bd717404a07d4dd45567b5bba23997250..bf63ac8a49b9df8601a5e0dabc4074e65007f94b 100644 (file)
@@ -112,32 +112,38 @@ static __u32 check_tcp_syn_cookie(__u32 cookie, const struct in6_addr *saddr,
                & COOKIEMASK;
 }
 
-__u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, __u16 *mssp)
+u32 __cookie_v6_init_sequence(const struct ipv6hdr *iph,
+                             const struct tcphdr *th, __u16 *mssp)
 {
-       const struct ipv6hdr *iph = ipv6_hdr(skb);
-       const struct tcphdr *th = tcp_hdr(skb);
        int mssind;
        const __u16 mss = *mssp;
 
-       tcp_synq_overflow(sk);
-
        for (mssind = ARRAY_SIZE(msstab) - 1; mssind ; mssind--)
                if (mss >= msstab[mssind])
                        break;
 
        *mssp = msstab[mssind];
 
-       NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
-
        return secure_tcp_syn_cookie(&iph->saddr, &iph->daddr, th->source,
                                     th->dest, ntohl(th->seq),
                                     jiffies / (HZ * 60), mssind);
 }
+EXPORT_SYMBOL_GPL(__cookie_v6_init_sequence);
 
-static inline int cookie_check(const struct sk_buff *skb, __u32 cookie)
+__u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, __u16 *mssp)
 {
        const struct ipv6hdr *iph = ipv6_hdr(skb);
        const struct tcphdr *th = tcp_hdr(skb);
+
+       tcp_synq_overflow(sk);
+       NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
+
+       return __cookie_v6_init_sequence(iph, th, mssp);
+}
+
+int __cookie_v6_check(const struct ipv6hdr *iph, const struct tcphdr *th,
+                     __u32 cookie)
+{
        __u32 seq = ntohl(th->seq) - 1;
        __u32 mssind = check_tcp_syn_cookie(cookie, &iph->saddr, &iph->daddr,
                                            th->source, th->dest, seq,
@@ -145,6 +151,7 @@ static inline int cookie_check(const struct sk_buff *skb, __u32 cookie)
 
        return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
 }
+EXPORT_SYMBOL_GPL(__cookie_v6_check);
 
 struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
 {
@@ -167,7 +174,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
                goto out;
 
        if (tcp_synq_no_recent_overflow(sk) ||
-               (mss = cookie_check(skb, cookie)) == 0) {
+               (mss = __cookie_v6_check(ipv6_hdr(skb), th, cookie)) == 0) {
                NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
                goto out;
        }
index 6e1649d58533fd9a1b0a3f9f4373348a625bfb60..5bcfadf09e9533787d82957830a26de46cf66097 100644 (file)
@@ -963,7 +963,8 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        if (!ipv6_unicast_destination(skb))
                goto drop;
 
-       if (inet_csk_reqsk_queue_is_full(sk) && !isn) {
+       if ((sysctl_tcp_syncookies == 2 ||
+            inet_csk_reqsk_queue_is_full(sk)) && !isn) {
                want_cookie = tcp_syn_flood_action(sk, skb, "TCPv6");
                if (!want_cookie)
                        goto drop;
@@ -1237,8 +1238,6 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
                newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
 
        tcp_initialize_rcv_mss(newsk);
-       tcp_synack_rtt_meas(newsk, req);
-       newtp->total_retrans = req->num_retrans;
 
        newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;
        newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
@@ -1732,7 +1731,7 @@ static void get_openreq6(struct seq_file *seq,
 
        seq_printf(seq,
                   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-                  "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %pK\n",
+                  "%02X %08X:%08X %02X:%08lX %08X %5u %8d %d %d %pK\n",
                   i,
                   src->s6_addr32[0], src->s6_addr32[1],
                   src->s6_addr32[2], src->s6_addr32[3],
@@ -1783,7 +1782,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
 
        seq_printf(seq,
                   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
-                  "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %pK %lu %lu %u %u %d\n",
+                  "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %lu %lu %u %u %d\n",
                   i,
                   src->s6_addr32[0], src->s6_addr32[1],
                   src->s6_addr32[2], src->s6_addr32[3], srcp,
@@ -1926,6 +1925,7 @@ struct proto tcpv6_prot = {
        .unhash                 = inet_unhash,
        .get_port               = inet_csk_get_port,
        .enter_memory_pressure  = tcp_enter_memory_pressure,
+       .stream_memory_free     = tcp_stream_memory_free,
        .sockets_allocated      = &tcp_sockets_allocated,
        .memory_allocated       = &tcp_memory_allocated,
        .memory_pressure        = &tcp_memory_pressure,
index 65e8833a251097885ca2c84fbb7bd761b1510a69..e15c16a517e72c162d3442bfa11fccfe3ef371b5 100644 (file)
@@ -213,7 +213,7 @@ static int ipx_seq_socket_show(struct seq_file *seq, void *v)
                           ntohs(ipxs->dest_addr.sock));
        }
 
-       seq_printf(seq, "%08X  %08X  %02X     %03d\n",
+       seq_printf(seq, "%08X  %08X  %02X     %03u\n",
                   sk_wmem_alloc_get(s),
                   sk_rmem_alloc_get(s),
                   s->sk_state,
index d14152e866d9d8bdb96adaad512a4f6ff78907ed..ffcec225b5d98eb766e2a6396a3e7fe2a65ee729 100644 (file)
@@ -44,12 +44,12 @@ static int  irlan_eth_open(struct net_device *dev);
 static int  irlan_eth_close(struct net_device *dev);
 static netdev_tx_t  irlan_eth_xmit(struct sk_buff *skb,
                                         struct net_device *dev);
-static void irlan_eth_set_multicast_list( struct net_device *dev);
+static void irlan_eth_set_multicast_list(struct net_device *dev);
 
 static const struct net_device_ops irlan_eth_netdev_ops = {
-       .ndo_open               = irlan_eth_open,
-       .ndo_stop               = irlan_eth_close,
-       .ndo_start_xmit         = irlan_eth_xmit,
+       .ndo_open               = irlan_eth_open,
+       .ndo_stop               = irlan_eth_close,
+       .ndo_start_xmit         = irlan_eth_xmit,
        .ndo_set_rx_mode        = irlan_eth_set_multicast_list,
        .ndo_change_mtu         = eth_change_mtu,
        .ndo_validate_addr      = eth_validate_addr,
@@ -110,7 +110,7 @@ static int irlan_eth_open(struct net_device *dev)
 {
        struct irlan_cb *self = netdev_priv(dev);
 
-       IRDA_DEBUG(2, "%s()\n", __func__ );
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        /* Ready to play! */
        netif_stop_queue(dev); /* Wait until data link is ready */
@@ -137,7 +137,7 @@ static int irlan_eth_close(struct net_device *dev)
 {
        struct irlan_cb *self = netdev_priv(dev);
 
-       IRDA_DEBUG(2, "%s()\n", __func__ );
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        /* Stop device */
        netif_stop_queue(dev);
@@ -310,35 +310,32 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
 {
        struct irlan_cb *self = netdev_priv(dev);
 
-       IRDA_DEBUG(2, "%s()\n", __func__ );
+       IRDA_DEBUG(2, "%s()\n", __func__);
 
        /* Check if data channel has been connected yet */
        if (self->client.state != IRLAN_DATA) {
-               IRDA_DEBUG(1, "%s(), delaying!\n", __func__ );
+               IRDA_DEBUG(1, "%s(), delaying!\n", __func__);
                return;
        }
 
        if (dev->flags & IFF_PROMISC) {
                /* Enable promiscuous mode */
                IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n");
-       }
-       else if ((dev->flags & IFF_ALLMULTI) ||
+       } else if ((dev->flags & IFF_ALLMULTI) ||
                 netdev_mc_count(dev) > HW_MAX_ADDRS) {
                /* Disable promiscuous mode, use normal mode. */
-               IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ );
+               IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__);
                /* hardware_set_filter(NULL); */
 
                irlan_set_multicast_filter(self, TRUE);
-       }
-       else if (!netdev_mc_empty(dev)) {
-               IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ );
+       } else if (!netdev_mc_empty(dev)) {
+               IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__);
                /* Walk the address list, and load the filter */
                /* hardware_set_filter(dev->mc_list); */
 
                irlan_set_multicast_filter(self, TRUE);
-       }
-       else {
-               IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__ );
+       } else {
+               IRDA_DEBUG(4, "%s(), Clearing multicast filter\n", __func__);
                irlan_set_multicast_filter(self, FALSE);
        }
 
index ae43c62f9045ba94ced0f025a9ecacb3bf145af1..85372cfa7b9f82b690579de4533ac27cf4ad09f6 100644 (file)
@@ -75,7 +75,7 @@ static pi_minor_info_t pi_minor_call_table[] = {
        { NULL, 0 },                                             /* 0x00 */
        { irttp_param_max_sdu_size, PV_INTEGER | PV_BIG_ENDIAN } /* 0x01 */
 };
-static pi_major_info_t pi_major_call_table[] = {{ pi_minor_call_table, 2 }};
+static pi_major_info_t pi_major_call_table[] = { { pi_minor_call_table, 2 } };
 static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 };
 
 /************************ GLOBAL PROCEDURES ************************/
@@ -205,7 +205,7 @@ static void irttp_todo_expired(unsigned long data)
  */
 static void irttp_flush_queues(struct tsap_cb *self)
 {
-       struct sk_buffskb;
+       struct sk_buff *skb;
 
        IRDA_DEBUG(4, "%s()\n", __func__);
 
@@ -400,7 +400,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
        /* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to
         * use only 0x01-0x6F. Of course, we can use LSAP_ANY as well.
         * JeanII */
-       if((stsap_sel != LSAP_ANY) &&
+       if ((stsap_sel != LSAP_ANY) &&
           ((stsap_sel < 0x01) || (stsap_sel >= 0x70))) {
                IRDA_DEBUG(0, "%s(), invalid tsap!\n", __func__);
                return NULL;
@@ -427,7 +427,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
        ttp_notify.data_indication = irttp_data_indication;
        ttp_notify.udata_indication = irttp_udata_indication;
        ttp_notify.flow_indication = irttp_flow_indication;
-       if(notify->status_indication != NULL)
+       if (notify->status_indication != NULL)
                ttp_notify.status_indication = irttp_status_indication;
        ttp_notify.instance = self;
        strncpy(ttp_notify.name, notify->name, NOTIFY_MAX_NAME);
@@ -639,8 +639,7 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
         */
        if ((self->tx_max_sdu_size != 0) &&
            (self->tx_max_sdu_size != TTP_SAR_UNBOUND) &&
-           (skb->len > self->tx_max_sdu_size))
-       {
+           (skb->len > self->tx_max_sdu_size)) {
                IRDA_ERROR("%s: SAR enabled, but data is larger than TxMaxSduSize!\n",
                           __func__);
                ret = -EMSGSIZE;
@@ -733,8 +732,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
         * poll us through irttp_flow_indication() - Jean II */
        while ((self->send_credit > 0) &&
               (!irlmp_lap_tx_queue_full(self->lsap)) &&
-              (skb = skb_dequeue(&self->tx_queue)))
-       {
+              (skb = skb_dequeue(&self->tx_queue))) {
                /*
                 *  Since we can transmit and receive frames concurrently,
                 *  the code below is a critical region and we must assure that
@@ -798,8 +796,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
         * where we can spend a bit of time doing stuff. - Jean II */
        if ((self->tx_sdu_busy) &&
            (skb_queue_len(&self->tx_queue) < TTP_TX_LOW_THRESHOLD) &&
-           (!self->close_pend))
-       {
+           (!self->close_pend)) {
                if (self->notify.flow_indication)
                        self->notify.flow_indication(self->notify.instance,
                                                     self, FLOW_START);
@@ -892,7 +889,7 @@ static int irttp_udata_indication(void *instance, void *sap,
        /* Just pass data to layer above */
        if (self->notify.udata_indication) {
                err = self->notify.udata_indication(self->notify.instance,
-                                                   self,skb);
+                                                   self, skb);
                /* Same comment as in irttp_do_data_indication() */
                if (!err)
                        return 0;
@@ -1057,7 +1054,7 @@ static void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
         * to do that. Jean II */
 
        /* If we need to send disconnect. try to do it now */
-       if(self->disconnect_pend)
+       if (self->disconnect_pend)
                irttp_start_todo_timer(self, 0);
 }
 
@@ -1116,7 +1113,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
        IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -EBADR;);
 
        if (self->connected) {
-               if(userdata)
+               if (userdata)
                        dev_kfree_skb(userdata);
                return -EISCONN;
        }
@@ -1137,7 +1134,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
                 *  headers
                 */
                IRDA_ASSERT(skb_headroom(userdata) >= TTP_MAX_HEADER,
-                       { dev_kfree_skb(userdata); return -1; } );
+                       { dev_kfree_skb(userdata); return -1; });
        }
 
        /* Initialize connection parameters */
@@ -1157,7 +1154,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
         *  Give away max 127 credits for now
         */
        if (n > 127) {
-               self->avail_credit=n-127;
+               self->avail_credit = n - 127;
                n = 127;
        }
 
@@ -1166,10 +1163,10 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
        /* SAR enabled? */
        if (max_sdu_size > 0) {
                IRDA_ASSERT(skb_headroom(tx_skb) >= (TTP_MAX_HEADER + TTP_SAR_HEADER),
-                       { dev_kfree_skb(tx_skb); return -1; } );
+                       { dev_kfree_skb(tx_skb); return -1; });
 
                /* Insert SAR parameters */
-               frame = skb_push(tx_skb, TTP_HEADER+TTP_SAR_HEADER);
+               frame = skb_push(tx_skb, TTP_HEADER + TTP_SAR_HEADER);
 
                frame[0] = TTP_PARAMETERS | n;
                frame[1] = 0x04; /* Length */
@@ -1386,7 +1383,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
                 *  headers
                 */
                IRDA_ASSERT(skb_headroom(userdata) >= TTP_MAX_HEADER,
-                       { dev_kfree_skb(userdata); return -1; } );
+                       { dev_kfree_skb(userdata); return -1; });
        }
 
        self->avail_credit = 0;
@@ -1409,10 +1406,10 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
        /* SAR enabled? */
        if (max_sdu_size > 0) {
                IRDA_ASSERT(skb_headroom(tx_skb) >= (TTP_MAX_HEADER + TTP_SAR_HEADER),
-                       { dev_kfree_skb(tx_skb); return -1; } );
+                       { dev_kfree_skb(tx_skb); return -1; });
 
                /* Insert TTP header with SAR parameters */
-               frame = skb_push(tx_skb, TTP_HEADER+TTP_SAR_HEADER);
+               frame = skb_push(tx_skb, TTP_HEADER + TTP_SAR_HEADER);
 
                frame[0] = TTP_PARAMETERS | n;
                frame[1] = 0x04; /* Length */
@@ -1522,7 +1519,7 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
         * function may be called from various context, like user, timer
         * for following a disconnect_indication() (i.e. net_bh).
         * Jean II */
-       if(test_and_set_bit(0, &self->disconnect_pend)) {
+       if (test_and_set_bit(0, &self->disconnect_pend)) {
                IRDA_DEBUG(0, "%s(), disconnect already pending\n",
                           __func__);
                if (userdata)
@@ -1627,7 +1624,7 @@ static void irttp_disconnect_indication(void *instance, void *sap,
         * Jean II */
 
        /* No need to notify the client if has already tried to disconnect */
-       if(self->notify.disconnect_indication)
+       if (self->notify.disconnect_indication)
                self->notify.disconnect_indication(self->notify.instance, self,
                                                   reason, skb);
        else
@@ -1738,8 +1735,7 @@ static void irttp_run_rx_queue(struct tsap_cb *self)
                 *  This is the last fragment, so time to reassemble!
                 */
                if ((self->rx_sdu_size <= self->rx_max_sdu_size) ||
-                   (self->rx_max_sdu_size == TTP_SAR_UNBOUND))
-               {
+                   (self->rx_max_sdu_size == TTP_SAR_UNBOUND)) {
                        /*
                         * A little optimizing. Only queue the fragment if
                         * there are other fragments. Since if this is the
@@ -1860,7 +1856,7 @@ static int irttp_seq_show(struct seq_file *seq, void *v)
        seq_printf(seq, "dtsap_sel: %02x\n",
                   self->dtsap_sel);
        seq_printf(seq, "  connected: %s, ",
-                  self->connected? "TRUE":"FALSE");
+                  self->connected ? "TRUE" : "FALSE");
        seq_printf(seq, "avail credit: %d, ",
                   self->avail_credit);
        seq_printf(seq, "remote credit: %d, ",
@@ -1876,9 +1872,9 @@ static int irttp_seq_show(struct seq_file *seq, void *v)
        seq_printf(seq, "rx_queue len: %u\n",
                   skb_queue_len(&self->rx_queue));
        seq_printf(seq, "  tx_sdu_busy: %s, ",
-                  self->tx_sdu_busy? "TRUE":"FALSE");
+                  self->tx_sdu_busy ? "TRUE" : "FALSE");
        seq_printf(seq, "rx_sdu_busy: %s\n",
-                  self->rx_sdu_busy? "TRUE":"FALSE");
+                  self->rx_sdu_busy ? "TRUE" : "FALSE");
        seq_printf(seq, "  max_seg_size: %u, ",
                   self->max_seg_size);
        seq_printf(seq, "tx_max_sdu_size: %u, ",
index 4fe76ff214c2aab08d703a0114ec0a86cbef6ca3..cd5b8ec9be0459db10432aad57836f96b3388d63 100644 (file)
@@ -621,7 +621,7 @@ static void iucv_disable(void)
        put_online_cpus();
 }
 
-static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
+static int iucv_cpu_notify(struct notifier_block *self,
                                     unsigned long action, void *hcpu)
 {
        cpumask_t cpumask;
index 9da862070dd84fe596f77582c82af6eec8ad660c..9d585370c5b4d6a1e60728df4dad6c79ca196ee3 100644 (file)
@@ -45,7 +45,7 @@ struct netns_pfkey {
 static DEFINE_MUTEX(pfkey_mutex);
 
 #define DUMMY_MARK 0
-static struct xfrm_mark dummy_mark = {0, 0};
+static const struct xfrm_mark dummy_mark = {0, 0};
 struct pfkey_sock {
        /* struct sock must be the first member of struct pfkey_sock */
        struct sock     sk;
@@ -338,7 +338,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk)
        return 0;
 }
 
-static u8 sadb_ext_min_len[] = {
+static const u8 sadb_ext_min_len[] = {
        [SADB_EXT_RESERVED]             = (u8) 0,
        [SADB_EXT_SA]                   = (u8) sizeof(struct sadb_sa),
        [SADB_EXT_LIFETIME_CURRENT]     = (u8) sizeof(struct sadb_lifetime),
@@ -1196,10 +1196,6 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
 
        x->props.family = pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_SRC-1],
                                                    &x->props.saddr);
-       if (!x->props.family) {
-               err = -EAFNOSUPPORT;
-               goto out;
-       }
        pfkey_sadb_addr2xfrm_addr((struct sadb_address *) ext_hdrs[SADB_EXT_ADDRESS_DST-1],
                                  &x->id.daddr);
 
@@ -2081,6 +2077,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
                        pol->sadb_x_policy_type = IPSEC_POLICY_NONE;
        }
        pol->sadb_x_policy_dir = dir+1;
+       pol->sadb_x_policy_reserved = 0;
        pol->sadb_x_policy_id = xp->index;
        pol->sadb_x_policy_priority = xp->priority;
 
@@ -2204,10 +2201,6 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, const struct sadb_
 
        sa = ext_hdrs[SADB_EXT_ADDRESS_SRC-1];
        xp->family = pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.saddr);
-       if (!xp->family) {
-               err = -EINVAL;
-               goto out;
-       }
        xp->selector.family = xp->family;
        xp->selector.prefixlen_s = sa->sadb_address_prefixlen;
        xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
@@ -2736,7 +2729,7 @@ static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, const struct sad
 
 typedef int (*pfkey_handler)(struct sock *sk, struct sk_buff *skb,
                             const struct sadb_msg *hdr, void * const *ext_hdrs);
-static pfkey_handler pfkey_funcs[SADB_MAX + 1] = {
+static const pfkey_handler pfkey_funcs[SADB_MAX + 1] = {
        [SADB_RESERVED]         = pfkey_reserved,
        [SADB_GETSPI]           = pfkey_getspi,
        [SADB_UPDATE]           = pfkey_add,
@@ -3137,7 +3130,9 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
        pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
        pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
        pol->sadb_x_policy_dir = XFRM_POLICY_OUT + 1;
+       pol->sadb_x_policy_reserved = 0;
        pol->sadb_x_policy_id = xp->index;
+       pol->sadb_x_policy_priority = xp->priority;
 
        /* Set sadb_comb's. */
        if (x->id.proto == IPPROTO_AH)
@@ -3525,6 +3520,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
        pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
        pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
        pol->sadb_x_policy_dir = dir + 1;
+       pol->sadb_x_policy_reserved = 0;
        pol->sadb_x_policy_id = 0;
        pol->sadb_x_policy_priority = 0;
 
index 7b4799cfbf8dbf456fc8f356b4fe01d02e1f396f..1a3c7e0f5d0de3c1d35759e1b2ae1bfa7849af84 100644 (file)
@@ -147,7 +147,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
        }
        seq_printf(seq, "@%02X ", llc->sap->laddr.lsap);
        llc_ui_format_mac(seq, llc->daddr.mac);
-       seq_printf(seq, "@%02X %8d %8d %2d %3d %4d\n", llc->daddr.lsap,
+       seq_printf(seq, "@%02X %8d %8d %2d %3u %4d\n", llc->daddr.lsap,
                   sk_wmem_alloc_get(sk),
                   sk_rmem_alloc_get(sk) - llc->copied_seq,
                   sk->sk_state,
index 56d22cae590683c9a3b530ad0152b105d5c19c2d..62a171ab204f46ed1f0f9a55840db91d3ce076e6 100644 (file)
@@ -408,21 +408,10 @@ config NF_NAT_TFTP
        depends on NF_CONNTRACK && NF_NAT
        default NF_NAT && NF_CONNTRACK_TFTP
 
-endif # NF_CONNTRACK
-
-# transparent proxy support
-config NETFILTER_TPROXY
-       tristate "Transparent proxying support"
-       depends on IP_NF_MANGLE
-       depends on NETFILTER_ADVANCED
-       help
-         This option enables transparent proxying support, that is,
-         support for handling non-locally bound IPv4 TCP and UDP sockets.
-         For it to work you will have to configure certain iptables rules
-         and use policy routing. For more information on how to set it up
-         see Documentation/networking/tproxy.txt.
+config NETFILTER_SYNPROXY
+       tristate
 
-         To compile it as a module, choose M here.  If unsure, say N.
+endif # NF_CONNTRACK
 
 config NETFILTER_XTABLES
        tristate "Netfilter Xtables support (required for ip_tables)"
@@ -720,10 +709,10 @@ config NETFILTER_XT_TARGET_TEE
        this clone be rerouted to another nexthop.
 
 config NETFILTER_XT_TARGET_TPROXY
-       tristate '"TPROXY" target support'
-       depends on NETFILTER_TPROXY
+       tristate '"TPROXY" target transparent proxying support'
        depends on NETFILTER_XTABLES
        depends on NETFILTER_ADVANCED
+       depends on IP_NF_MANGLE
        select NF_DEFRAG_IPV4
        select NF_DEFRAG_IPV6 if IP6_NF_IPTABLES
        help
@@ -731,6 +720,9 @@ config NETFILTER_XT_TARGET_TPROXY
          REDIRECT.  It can only be used in the mangle table and is useful
          to redirect traffic to a transparent proxy.  It does _not_ depend
          on Netfilter connection tracking and NAT, unlike REDIRECT.
+         For it to work you will have to configure certain iptables rules
+         and use policy routing. For more information on how to set it up
+         see Documentation/networking/tproxy.txt.
 
          To compile it as a module, choose M here.  If unsure, say N.
 
@@ -1180,7 +1172,6 @@ config NETFILTER_XT_MATCH_SCTP
 
 config NETFILTER_XT_MATCH_SOCKET
        tristate '"socket" match support'
-       depends on NETFILTER_TPROXY
        depends on NETFILTER_XTABLES
        depends on NETFILTER_ADVANCED
        depends on !NF_CONNTRACK || NF_CONNTRACK
index a1abf87d43bfbd902f82cc9f8aae156d936cd89a..c3a0a12907f693630b841400d3e47babfd338bde 100644 (file)
@@ -1,6 +1,6 @@
 netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o
 
-nf_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 nf_conntrack_extend.o nf_conntrack_acct.o
+nf_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 nf_conntrack_extend.o nf_conntrack_acct.o nf_conntrack_seqadj.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMEOUT) += nf_conntrack_timeout.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_TIMESTAMP) += nf_conntrack_timestamp.o
 nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o
@@ -61,8 +61,8 @@ obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o
 obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
 obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o
 
-# transparent proxy support
-obj-$(CONFIG_NETFILTER_TPROXY) += nf_tproxy_core.o
+# SYNPROXY
+obj-$(CONFIG_NETFILTER_SYNPROXY) += nf_synproxy_core.o
 
 # generic X tables 
 obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
index 2217363ab4229212b0f309d1f724e1f23f5ceb17..593b16ea45e0d817787c4d06d9d3d703df2fc65b 100644 (file)
@@ -234,12 +234,13 @@ EXPORT_SYMBOL(skb_make_writable);
 /* This does not belong here, but locally generated errors need it if connection
    tracking in use: without this, connection may not be in hash table, and hence
    manufactured ICMP or RST packets will not be associated with it. */
-void (*ip_ct_attach)(struct sk_buff *, struct sk_buff *) __rcu __read_mostly;
+void (*ip_ct_attach)(struct sk_buff *, const struct sk_buff *)
+               __rcu __read_mostly;
 EXPORT_SYMBOL(ip_ct_attach);
 
-void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb)
+void nf_ct_attach(struct sk_buff *new, const struct sk_buff *skb)
 {
-       void (*attach)(struct sk_buff *, struct sk_buff *);
+       void (*attach)(struct sk_buff *, const struct sk_buff *);
 
        if (skb->nfct) {
                rcu_read_lock();
index 3cd85b2fc67c83e7f4a12b6fa35765d8ebc986ec..5199448697f64fcf0da0e35dbc38903477a92861 100644 (file)
@@ -414,7 +414,7 @@ static void ip_vs_lblcr_flush(struct ip_vs_service *svc)
 
        spin_lock_bh(&svc->sched_lock);
        tbl->dead = 1;
-       for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) {
+       for (i = 0; i < IP_VS_LBLCR_TAB_SIZE; i++) {
                hlist_for_each_entry_safe(en, next, &tbl->bucket[i], list) {
                        ip_vs_lblcr_free(en);
                }
@@ -440,7 +440,7 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
        struct ip_vs_lblcr_entry *en;
        struct hlist_node *next;
 
-       for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) {
+       for (i = 0, j = tbl->rover; i < IP_VS_LBLCR_TAB_SIZE; i++) {
                j = (j + 1) & IP_VS_LBLCR_TAB_MASK;
 
                spin_lock(&svc->sched_lock);
@@ -495,7 +495,7 @@ static void ip_vs_lblcr_check_expire(unsigned long data)
        if (goal > tbl->max_size/2)
                goal = tbl->max_size/2;
 
-       for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) {
+       for (i = 0, j = tbl->rover; i < IP_VS_LBLCR_TAB_SIZE; i++) {
                j = (j + 1) & IP_VS_LBLCR_TAB_MASK;
 
                spin_lock(&svc->sched_lock);
@@ -536,7 +536,7 @@ static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
        /*
         *    Initialize the hash buckets
         */
-       for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) {
+       for (i = 0; i < IP_VS_LBLCR_TAB_SIZE; i++) {
                INIT_HLIST_HEAD(&tbl->bucket[i]);
        }
        tbl->max_size = IP_VS_LBLCR_TAB_SIZE*16;
index 3c0da8728036346a6a9ba235821779b49931b311..23e596e438b3fb4e51a97782c4cf00ad7d33af68 100644 (file)
@@ -66,15 +66,7 @@ sctp_conn_schedule(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd,
 static void sctp_nat_csum(struct sk_buff *skb, sctp_sctphdr_t *sctph,
                          unsigned int sctphoff)
 {
-       __u32 crc32;
-       struct sk_buff *iter;
-
-       crc32 = sctp_start_cksum((__u8 *)sctph, skb_headlen(skb) - sctphoff);
-       skb_walk_frags(skb, iter)
-               crc32 = sctp_update_cksum((u8 *) iter->data,
-                                         skb_headlen(iter), crc32);
-       sctph->checksum = sctp_end_cksum(crc32);
-
+       sctph->checksum = sctp_compute_cksum(skb, sctphoff);
        skb->ip_summed = CHECKSUM_UNNECESSARY;
 }
 
@@ -151,10 +143,7 @@ sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
 {
        unsigned int sctphoff;
        struct sctphdr *sh, _sctph;
-       struct sk_buff *iter;
-       __le32 cmp;
-       __le32 val;
-       __u32 tmp;
+       __le32 cmp, val;
 
 #ifdef CONFIG_IP_VS_IPV6
        if (af == AF_INET6)
@@ -168,13 +157,7 @@ sctp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
                return 0;
 
        cmp = sh->checksum;
-
-       tmp = sctp_start_cksum((__u8 *) sh, skb_headlen(skb));
-       skb_walk_frags(skb, iter)
-               tmp = sctp_update_cksum((__u8 *) iter->data,
-                                       skb_headlen(iter), tmp);
-
-       val = sctp_end_cksum(tmp);
+       val = sctp_compute_cksum(skb, sctphoff);
 
        if (val != cmp) {
                /* CRC failure, dump it. */
index f16c027df15bb38241d6750428fdad1733de88ac..3588faebe5298149b918614656ca8b6ee7d12e4e 100644 (file)
@@ -269,14 +269,20 @@ ip_vs_sh_get_port(const struct sk_buff *skb, struct ip_vs_iphdr *iph)
        switch (iph->protocol) {
        case IPPROTO_TCP:
                th = skb_header_pointer(skb, iph->len, sizeof(_tcph), &_tcph);
+               if (unlikely(th == NULL))
+                       return 0;
                port = th->source;
                break;
        case IPPROTO_UDP:
                uh = skb_header_pointer(skb, iph->len, sizeof(_udph), &_udph);
+               if (unlikely(uh == NULL))
+                       return 0;
                port = uh->source;
                break;
        case IPPROTO_SCTP:
                sh = skb_header_pointer(skb, iph->len, sizeof(_sctph), &_sctph);
+               if (unlikely(sh == NULL))
+                       return 0;
                port = sh->source;
                break;
        default:
index 0283baedcdfb5b48627002607731dabb992e15ae..5d892febd64ca88d957d6eeffac5de12daeaff77 100644 (file)
@@ -39,6 +39,7 @@
 #include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_extend.h>
 #include <net/netfilter/nf_conntrack_acct.h>
@@ -47,6 +48,7 @@
 #include <net/netfilter/nf_conntrack_timestamp.h>
 #include <net/netfilter/nf_conntrack_timeout.h>
 #include <net/netfilter/nf_conntrack_labels.h>
+#include <net/netfilter/nf_conntrack_synproxy.h>
 #include <net/netfilter/nf_nat.h>
 #include <net/netfilter/nf_nat_core.h>
 #include <net/netfilter/nf_nat_helper.h>
@@ -238,7 +240,7 @@ destroy_conntrack(struct nf_conntrack *nfct)
        nf_conntrack_free(ct);
 }
 
-void nf_ct_delete_from_lists(struct nf_conn *ct)
+static void nf_ct_delete_from_lists(struct nf_conn *ct)
 {
        struct net *net = nf_ct_net(ct);
 
@@ -253,7 +255,6 @@ void nf_ct_delete_from_lists(struct nf_conn *ct)
                             &net->ct.dying);
        spin_unlock_bh(&nf_conntrack_lock);
 }
-EXPORT_SYMBOL_GPL(nf_ct_delete_from_lists);
 
 static void death_by_event(unsigned long ul_conntrack)
 {
@@ -275,7 +276,7 @@ static void death_by_event(unsigned long ul_conntrack)
        nf_ct_put(ct);
 }
 
-void nf_ct_dying_timeout(struct nf_conn *ct)
+static void nf_ct_dying_timeout(struct nf_conn *ct)
 {
        struct net *net = nf_ct_net(ct);
        struct nf_conntrack_ecache *ecache = nf_ct_ecache_find(ct);
@@ -288,27 +289,33 @@ void nf_ct_dying_timeout(struct nf_conn *ct)
                (prandom_u32() % net->ct.sysctl_events_retry_timeout);
        add_timer(&ecache->timeout);
 }
-EXPORT_SYMBOL_GPL(nf_ct_dying_timeout);
 
-static void death_by_timeout(unsigned long ul_conntrack)
+bool nf_ct_delete(struct nf_conn *ct, u32 portid, int report)
 {
-       struct nf_conn *ct = (void *)ul_conntrack;
        struct nf_conn_tstamp *tstamp;
 
        tstamp = nf_conn_tstamp_find(ct);
        if (tstamp && tstamp->stop == 0)
                tstamp->stop = ktime_to_ns(ktime_get_real());
 
-       if (!test_bit(IPS_DYING_BIT, &ct->status) &&
-           unlikely(nf_conntrack_event(IPCT_DESTROY, ct) < 0)) {
+       if (!nf_ct_is_dying(ct) &&
+           unlikely(nf_conntrack_event_report(IPCT_DESTROY, ct,
+           portid, report) < 0)) {
                /* destroy event was not delivered */
                nf_ct_delete_from_lists(ct);
                nf_ct_dying_timeout(ct);
-               return;
+               return false;
        }
        set_bit(IPS_DYING_BIT, &ct->status);
        nf_ct_delete_from_lists(ct);
        nf_ct_put(ct);
+       return true;
+}
+EXPORT_SYMBOL_GPL(nf_ct_delete);
+
+static void death_by_timeout(unsigned long ul_conntrack)
+{
+       nf_ct_delete((struct nf_conn *)ul_conntrack, 0, 0);
 }
 
 /*
@@ -643,10 +650,7 @@ static noinline int early_drop(struct net *net, unsigned int hash)
                return dropped;
 
        if (del_timer(&ct->timeout)) {
-               death_by_timeout((unsigned long)ct);
-               /* Check if we indeed killed this entry. Reliable event
-                  delivery may have inserted it into the dying list. */
-               if (test_bit(IPS_DYING_BIT, &ct->status)) {
+               if (nf_ct_delete(ct, 0, 0)) {
                        dropped = 1;
                        NF_CT_STAT_INC_ATOMIC(net, early_drop);
                }
@@ -796,6 +800,11 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
        if (IS_ERR(ct))
                return (struct nf_conntrack_tuple_hash *)ct;
 
+       if (tmpl && nfct_synproxy(tmpl)) {
+               nfct_seqadj_ext_add(ct);
+               nfct_synproxy_ext_add(ct);
+       }
+
        timeout_ext = tmpl ? nf_ct_timeout_find(tmpl) : NULL;
        if (timeout_ext)
                timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext);
@@ -1192,7 +1201,7 @@ EXPORT_SYMBOL_GPL(nf_ct_port_nlattr_tuple_size);
 #endif
 
 /* Used by ipt_REJECT and ip6t_REJECT. */
-static void nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb)
+static void nf_conntrack_attach(struct sk_buff *nskb, const struct sk_buff *skb)
 {
        struct nf_conn *ct;
        enum ip_conntrack_info ctinfo;
@@ -1244,7 +1253,7 @@ found:
 
 void nf_ct_iterate_cleanup(struct net *net,
                           int (*iter)(struct nf_conn *i, void *data),
-                          void *data)
+                          void *data, u32 portid, int report)
 {
        struct nf_conn *ct;
        unsigned int bucket = 0;
@@ -1252,7 +1261,8 @@ void nf_ct_iterate_cleanup(struct net *net,
        while ((ct = get_next_corpse(net, iter, data, &bucket)) != NULL) {
                /* Time to push up daises... */
                if (del_timer(&ct->timeout))
-                       death_by_timeout((unsigned long)ct);
+                       nf_ct_delete(ct, portid, report);
+
                /* ... else the timer will get him soon. */
 
                nf_ct_put(ct);
@@ -1260,30 +1270,6 @@ void nf_ct_iterate_cleanup(struct net *net,
 }
 EXPORT_SYMBOL_GPL(nf_ct_iterate_cleanup);
 
-struct __nf_ct_flush_report {
-       u32 portid;
-       int report;
-};
-
-static int kill_report(struct nf_conn *i, void *data)
-{
-       struct __nf_ct_flush_report *fr = (struct __nf_ct_flush_report *)data;
-       struct nf_conn_tstamp *tstamp;
-
-       tstamp = nf_conn_tstamp_find(i);
-       if (tstamp && tstamp->stop == 0)
-               tstamp->stop = ktime_to_ns(ktime_get_real());
-
-       /* If we fail to deliver the event, death_by_timeout() will retry */
-       if (nf_conntrack_event_report(IPCT_DESTROY, i,
-                                     fr->portid, fr->report) < 0)
-               return 1;
-
-       /* Avoid the delivery of the destroy event in death_by_timeout(). */
-       set_bit(IPS_DYING_BIT, &i->status);
-       return 1;
-}
-
 static int kill_all(struct nf_conn *i, void *data)
 {
        return 1;
@@ -1301,11 +1287,7 @@ EXPORT_SYMBOL_GPL(nf_ct_free_hashtable);
 
 void nf_conntrack_flush_report(struct net *net, u32 portid, int report)
 {
-       struct __nf_ct_flush_report fr = {
-               .portid = portid,
-               .report = report,
-       };
-       nf_ct_iterate_cleanup(net, kill_report, &fr);
+       nf_ct_iterate_cleanup(net, kill_all, NULL, portid, report);
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_flush_report);
 
@@ -1351,6 +1333,7 @@ void nf_conntrack_cleanup_end(void)
        nf_ct_extend_unregister(&nf_ct_zone_extend);
 #endif
        nf_conntrack_proto_fini();
+       nf_conntrack_seqadj_fini();
        nf_conntrack_labels_fini();
        nf_conntrack_helper_fini();
        nf_conntrack_timeout_fini();
@@ -1386,7 +1369,7 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list)
 i_see_dead_people:
        busy = 0;
        list_for_each_entry(net, net_exit_list, exit_list) {
-               nf_ct_iterate_cleanup(net, kill_all, NULL);
+               nf_ct_iterate_cleanup(net, kill_all, NULL, 0, 0);
                nf_ct_release_dying_list(net);
                if (atomic_read(&net->ct.count) != 0)
                        busy = 1;
@@ -1556,6 +1539,10 @@ int nf_conntrack_init_start(void)
        if (ret < 0)
                goto err_labels;
 
+       ret = nf_conntrack_seqadj_init();
+       if (ret < 0)
+               goto err_seqadj;
+
 #ifdef CONFIG_NF_CONNTRACK_ZONES
        ret = nf_ct_extend_register(&nf_ct_zone_extend);
        if (ret < 0)
@@ -1580,6 +1567,8 @@ err_proto:
        nf_ct_extend_unregister(&nf_ct_zone_extend);
 err_extend:
 #endif
+       nf_conntrack_seqadj_fini();
+err_seqadj:
        nf_conntrack_labels_fini();
 err_labels:
        nf_conntrack_helper_fini();
@@ -1602,9 +1591,6 @@ void nf_conntrack_init_end(void)
        /* For use by REJECT target */
        RCU_INIT_POINTER(ip_ct_attach, nf_conntrack_attach);
        RCU_INIT_POINTER(nf_ct_destroy, destroy_conntrack);
-
-       /* Howto get NAT offsets */
-       RCU_INIT_POINTER(nf_ct_nat_offset, NULL);
 }
 
 /*
@@ -1691,8 +1677,3 @@ err_slabname:
 err_stat:
        return ret;
 }
-
-s16 (*nf_ct_nat_offset)(const struct nf_conn *ct,
-                       enum ip_conntrack_dir dir,
-                       u32 seq);
-EXPORT_SYMBOL_GPL(nf_ct_nat_offset);
index c63b618cd619eb01d0fe99413162a84edd09ac3c..4fd1ca94fd4a140b374385ded878af60b503b529 100644 (file)
@@ -293,6 +293,11 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class,
                       sizeof(exp->tuple.dst.u3) - len);
 
        exp->tuple.dst.u.all = *dst;
+
+#ifdef CONFIG_NF_NAT_NEEDED
+       memset(&exp->saved_addr, 0, sizeof(exp->saved_addr));
+       memset(&exp->saved_proto, 0, sizeof(exp->saved_proto));
+#endif
 }
 EXPORT_SYMBOL_GPL(nf_ct_expect_init);
 
index 355d2ef0809477a36176ff5287bd8bfc25faee8c..bb53f120e79cb3547b1f23eba8e3d26c91aa43a4 100644 (file)
@@ -8,12 +8,8 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/ctype.h>
 #include <linux/export.h>
-#include <linux/jhash.h>
-#include <linux/spinlock.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 
 #include <net/netfilter/nf_conntrack_ecache.h>
 #include <net/netfilter/nf_conntrack_labels.h>
index edc410e778f770b7d1bef94cf2de3d0caec0b184..eea936b70d15407be5f69681de0a8ecf0fbcbc05 100644 (file)
@@ -37,6 +37,7 @@
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_conntrack_expect.h>
 #include <net/netfilter/nf_conntrack_helper.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_tuple.h>
@@ -381,9 +382,8 @@ nla_put_failure:
        return -1;
 }
 
-#ifdef CONFIG_NF_NAT_NEEDED
 static int
-dump_nat_seq_adj(struct sk_buff *skb, const struct nf_nat_seq *natseq, int type)
+dump_ct_seq_adj(struct sk_buff *skb, const struct nf_ct_seqadj *seq, int type)
 {
        struct nlattr *nest_parms;
 
@@ -391,12 +391,12 @@ dump_nat_seq_adj(struct sk_buff *skb, const struct nf_nat_seq *natseq, int type)
        if (!nest_parms)
                goto nla_put_failure;
 
-       if (nla_put_be32(skb, CTA_NAT_SEQ_CORRECTION_POS,
-                        htonl(natseq->correction_pos)) ||
-           nla_put_be32(skb, CTA_NAT_SEQ_OFFSET_BEFORE,
-                        htonl(natseq->offset_before)) ||
-           nla_put_be32(skb, CTA_NAT_SEQ_OFFSET_AFTER,
-                        htonl(natseq->offset_after)))
+       if (nla_put_be32(skb, CTA_SEQADJ_CORRECTION_POS,
+                        htonl(seq->correction_pos)) ||
+           nla_put_be32(skb, CTA_SEQADJ_OFFSET_BEFORE,
+                        htonl(seq->offset_before)) ||
+           nla_put_be32(skb, CTA_SEQADJ_OFFSET_AFTER,
+                        htonl(seq->offset_after)))
                goto nla_put_failure;
 
        nla_nest_end(skb, nest_parms);
@@ -408,27 +408,24 @@ nla_put_failure:
 }
 
 static inline int
-ctnetlink_dump_nat_seq_adj(struct sk_buff *skb, const struct nf_conn *ct)
+ctnetlink_dump_ct_seq_adj(struct sk_buff *skb, const struct nf_conn *ct)
 {
-       struct nf_nat_seq *natseq;
-       struct nf_conn_nat *nat = nfct_nat(ct);
+       struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
+       struct nf_ct_seqadj *seq;
 
-       if (!(ct->status & IPS_SEQ_ADJUST) || !nat)
+       if (!(ct->status & IPS_SEQ_ADJUST) || !seqadj)
                return 0;
 
-       natseq = &nat->seq[IP_CT_DIR_ORIGINAL];
-       if (dump_nat_seq_adj(skb, natseq, CTA_NAT_SEQ_ADJ_ORIG) == -1)
+       seq = &seqadj->seq[IP_CT_DIR_ORIGINAL];
+       if (dump_ct_seq_adj(skb, seq, CTA_SEQ_ADJ_ORIG) == -1)
                return -1;
 
-       natseq = &nat->seq[IP_CT_DIR_REPLY];
-       if (dump_nat_seq_adj(skb, natseq, CTA_NAT_SEQ_ADJ_REPLY) == -1)
+       seq = &seqadj->seq[IP_CT_DIR_REPLY];
+       if (dump_ct_seq_adj(skb, seq, CTA_SEQ_ADJ_REPLY) == -1)
                return -1;
 
        return 0;
 }
-#else
-#define ctnetlink_dump_nat_seq_adj(a, b) (0)
-#endif
 
 static inline int
 ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct)
@@ -502,7 +499,7 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
            ctnetlink_dump_id(skb, ct) < 0 ||
            ctnetlink_dump_use(skb, ct) < 0 ||
            ctnetlink_dump_master(skb, ct) < 0 ||
-           ctnetlink_dump_nat_seq_adj(skb, ct) < 0)
+           ctnetlink_dump_ct_seq_adj(skb, ct) < 0)
                goto nla_put_failure;
 
        nlmsg_end(skb, nlh);
@@ -707,8 +704,8 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item)
                    ctnetlink_dump_master(skb, ct) < 0)
                        goto nla_put_failure;
 
-               if (events & (1 << IPCT_NATSEQADJ) &&
-                   ctnetlink_dump_nat_seq_adj(skb, ct) < 0)
+               if (events & (1 << IPCT_SEQADJ) &&
+                   ctnetlink_dump_ct_seq_adj(skb, ct) < 0)
                        goto nla_put_failure;
        }
 
@@ -1038,21 +1035,9 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
                }
        }
 
-       if (del_timer(&ct->timeout)) {
-               if (nf_conntrack_event_report(IPCT_DESTROY, ct,
-                                             NETLINK_CB(skb).portid,
-                                             nlmsg_report(nlh)) < 0) {
-                       nf_ct_delete_from_lists(ct);
-                       /* we failed to report the event, try later */
-                       nf_ct_dying_timeout(ct);
-                       nf_ct_put(ct);
-                       return 0;
-               }
-               /* death_by_timeout would report the event again */
-               set_bit(IPS_DYING_BIT, &ct->status);
-               nf_ct_delete_from_lists(ct);
-               nf_ct_put(ct);
-       }
+       if (del_timer(&ct->timeout))
+               nf_ct_delete(ct, NETLINK_CB(skb).portid, nlmsg_report(nlh));
+
        nf_ct_put(ct);
 
        return 0;
@@ -1451,66 +1436,65 @@ ctnetlink_change_protoinfo(struct nf_conn *ct, const struct nlattr * const cda[]
        return err;
 }
 
-#ifdef CONFIG_NF_NAT_NEEDED
-static const struct nla_policy nat_seq_policy[CTA_NAT_SEQ_MAX+1] = {
-       [CTA_NAT_SEQ_CORRECTION_POS]    = { .type = NLA_U32 },
-       [CTA_NAT_SEQ_OFFSET_BEFORE]     = { .type = NLA_U32 },
-       [CTA_NAT_SEQ_OFFSET_AFTER]      = { .type = NLA_U32 },
+static const struct nla_policy seqadj_policy[CTA_SEQADJ_MAX+1] = {
+       [CTA_SEQADJ_CORRECTION_POS]     = { .type = NLA_U32 },
+       [CTA_SEQADJ_OFFSET_BEFORE]      = { .type = NLA_U32 },
+       [CTA_SEQADJ_OFFSET_AFTER]       = { .type = NLA_U32 },
 };
 
 static inline int
-change_nat_seq_adj(struct nf_nat_seq *natseq, const struct nlattr * const attr)
+change_seq_adj(struct nf_ct_seqadj *seq, const struct nlattr * const attr)
 {
        int err;
-       struct nlattr *cda[CTA_NAT_SEQ_MAX+1];
+       struct nlattr *cda[CTA_SEQADJ_MAX+1];
 
-       err = nla_parse_nested(cda, CTA_NAT_SEQ_MAX, attr, nat_seq_policy);
+       err = nla_parse_nested(cda, CTA_SEQADJ_MAX, attr, seqadj_policy);
        if (err < 0)
                return err;
 
-       if (!cda[CTA_NAT_SEQ_CORRECTION_POS])
+       if (!cda[CTA_SEQADJ_CORRECTION_POS])
                return -EINVAL;
 
-       natseq->correction_pos =
-               ntohl(nla_get_be32(cda[CTA_NAT_SEQ_CORRECTION_POS]));
+       seq->correction_pos =
+               ntohl(nla_get_be32(cda[CTA_SEQADJ_CORRECTION_POS]));
 
-       if (!cda[CTA_NAT_SEQ_OFFSET_BEFORE])
+       if (!cda[CTA_SEQADJ_OFFSET_BEFORE])
                return -EINVAL;
 
-       natseq->offset_before =
-               ntohl(nla_get_be32(cda[CTA_NAT_SEQ_OFFSET_BEFORE]));
+       seq->offset_before =
+               ntohl(nla_get_be32(cda[CTA_SEQADJ_OFFSET_BEFORE]));
 
-       if (!cda[CTA_NAT_SEQ_OFFSET_AFTER])
+       if (!cda[CTA_SEQADJ_OFFSET_AFTER])
                return -EINVAL;
 
-       natseq->offset_after =
-               ntohl(nla_get_be32(cda[CTA_NAT_SEQ_OFFSET_AFTER]));
+       seq->offset_after =
+               ntohl(nla_get_be32(cda[CTA_SEQADJ_OFFSET_AFTER]));
 
        return 0;
 }
 
 static int
-ctnetlink_change_nat_seq_adj(struct nf_conn *ct,
-                            const struct nlattr * const cda[])
+ctnetlink_change_seq_adj(struct nf_conn *ct,
+                        const struct nlattr * const cda[])
 {
+       struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
        int ret = 0;
-       struct nf_conn_nat *nat = nfct_nat(ct);
 
-       if (!nat)
+       if (!seqadj)
                return 0;
 
-       if (cda[CTA_NAT_SEQ_ADJ_ORIG]) {
-               ret = change_nat_seq_adj(&nat->seq[IP_CT_DIR_ORIGINAL],
-                                        cda[CTA_NAT_SEQ_ADJ_ORIG]);
+       if (cda[CTA_SEQ_ADJ_ORIG]) {
+               ret = change_seq_adj(&seqadj->seq[IP_CT_DIR_ORIGINAL],
+                                    cda[CTA_SEQ_ADJ_ORIG]);
                if (ret < 0)
                        return ret;
 
                ct->status |= IPS_SEQ_ADJUST;
        }
 
-       if (cda[CTA_NAT_SEQ_ADJ_REPLY]) {
-               ret = change_nat_seq_adj(&nat->seq[IP_CT_DIR_REPLY],
-                                        cda[CTA_NAT_SEQ_ADJ_REPLY]);
+       if (cda[CTA_SEQ_ADJ_REPLY]) {
+               ret = change_seq_adj(&seqadj->seq[IP_CT_DIR_REPLY],
+                                    cda[CTA_SEQ_ADJ_REPLY]);
                if (ret < 0)
                        return ret;
 
@@ -1519,7 +1503,6 @@ ctnetlink_change_nat_seq_adj(struct nf_conn *ct,
 
        return 0;
 }
-#endif
 
 static int
 ctnetlink_attach_labels(struct nf_conn *ct, const struct nlattr * const cda[])
@@ -1585,13 +1568,12 @@ ctnetlink_change_conntrack(struct nf_conn *ct,
                ct->mark = ntohl(nla_get_be32(cda[CTA_MARK]));
 #endif
 
-#ifdef CONFIG_NF_NAT_NEEDED
-       if (cda[CTA_NAT_SEQ_ADJ_ORIG] || cda[CTA_NAT_SEQ_ADJ_REPLY]) {
-               err = ctnetlink_change_nat_seq_adj(ct, cda);
+       if (cda[CTA_SEQ_ADJ_ORIG] || cda[CTA_SEQ_ADJ_REPLY]) {
+               err = ctnetlink_change_seq_adj(ct, cda);
                if (err < 0)
                        return err;
        }
-#endif
+
        if (cda[CTA_LABELS]) {
                err = ctnetlink_attach_labels(ct, cda);
                if (err < 0)
@@ -1696,13 +1678,11 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
                        goto err2;
        }
 
-#ifdef CONFIG_NF_NAT_NEEDED
-       if (cda[CTA_NAT_SEQ_ADJ_ORIG] || cda[CTA_NAT_SEQ_ADJ_REPLY]) {
-               err = ctnetlink_change_nat_seq_adj(ct, cda);
+       if (cda[CTA_SEQ_ADJ_ORIG] || cda[CTA_SEQ_ADJ_REPLY]) {
+               err = ctnetlink_change_seq_adj(ct, cda);
                if (err < 0)
                        goto err2;
        }
-#endif
 
        memset(&ct->proto, 0, sizeof(ct->proto));
        if (cda[CTA_PROTOINFO]) {
@@ -1816,7 +1796,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
                                                      (1 << IPCT_ASSURED) |
                                                      (1 << IPCT_HELPER) |
                                                      (1 << IPCT_PROTOINFO) |
-                                                     (1 << IPCT_NATSEQADJ) |
+                                                     (1 << IPCT_SEQADJ) |
                                                      (1 << IPCT_MARK) | events,
                                                      ct, NETLINK_CB(skb).portid,
                                                      nlmsg_report(nlh));
@@ -1839,7 +1819,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
                                                      (1 << IPCT_HELPER) |
                                                      (1 << IPCT_LABEL) |
                                                      (1 << IPCT_PROTOINFO) |
-                                                     (1 << IPCT_NATSEQADJ) |
+                                                     (1 << IPCT_SEQADJ) |
                                                      (1 << IPCT_MARK),
                                                      ct, NETLINK_CB(skb).portid,
                                                      nlmsg_report(nlh));
@@ -1999,6 +1979,27 @@ out:
        return err == -EAGAIN ? -ENOBUFS : err;
 }
 
+static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = {
+       [CTA_EXPECT_MASTER]     = { .type = NLA_NESTED },
+       [CTA_EXPECT_TUPLE]      = { .type = NLA_NESTED },
+       [CTA_EXPECT_MASK]       = { .type = NLA_NESTED },
+       [CTA_EXPECT_TIMEOUT]    = { .type = NLA_U32 },
+       [CTA_EXPECT_ID]         = { .type = NLA_U32 },
+       [CTA_EXPECT_HELP_NAME]  = { .type = NLA_NUL_STRING,
+                                   .len = NF_CT_HELPER_NAME_LEN - 1 },
+       [CTA_EXPECT_ZONE]       = { .type = NLA_U16 },
+       [CTA_EXPECT_FLAGS]      = { .type = NLA_U32 },
+       [CTA_EXPECT_CLASS]      = { .type = NLA_U32 },
+       [CTA_EXPECT_NAT]        = { .type = NLA_NESTED },
+       [CTA_EXPECT_FN]         = { .type = NLA_NUL_STRING },
+};
+
+static struct nf_conntrack_expect *
+ctnetlink_alloc_expect(const struct nlattr *const cda[], struct nf_conn *ct,
+                      struct nf_conntrack_helper *helper,
+                      struct nf_conntrack_tuple *tuple,
+                      struct nf_conntrack_tuple *mask);
+
 #ifdef CONFIG_NETFILTER_NETLINK_QUEUE_CT
 static size_t
 ctnetlink_nfqueue_build_size(const struct nf_conn *ct)
@@ -2073,7 +2074,7 @@ ctnetlink_nfqueue_build(struct sk_buff *skb, struct nf_conn *ct)
                goto nla_put_failure;
 
        if ((ct->status & IPS_SEQ_ADJUST) &&
-           ctnetlink_dump_nat_seq_adj(skb, ct) < 0)
+           ctnetlink_dump_ct_seq_adj(skb, ct) < 0)
                goto nla_put_failure;
 
 #ifdef CONFIG_NF_CONNTRACK_MARK
@@ -2139,10 +2140,70 @@ ctnetlink_nfqueue_parse(const struct nlattr *attr, struct nf_conn *ct)
        return ret;
 }
 
+static int ctnetlink_nfqueue_exp_parse(const struct nlattr * const *cda,
+                                      const struct nf_conn *ct,
+                                      struct nf_conntrack_tuple *tuple,
+                                      struct nf_conntrack_tuple *mask)
+{
+       int err;
+
+       err = ctnetlink_parse_tuple(cda, tuple, CTA_EXPECT_TUPLE,
+                                   nf_ct_l3num(ct));
+       if (err < 0)
+               return err;
+
+       return ctnetlink_parse_tuple(cda, mask, CTA_EXPECT_MASK,
+                                    nf_ct_l3num(ct));
+}
+
+static int
+ctnetlink_nfqueue_attach_expect(const struct nlattr *attr, struct nf_conn *ct,
+                               u32 portid, u32 report)
+{
+       struct nlattr *cda[CTA_EXPECT_MAX+1];
+       struct nf_conntrack_tuple tuple, mask;
+       struct nf_conntrack_helper *helper = NULL;
+       struct nf_conntrack_expect *exp;
+       int err;
+
+       err = nla_parse_nested(cda, CTA_EXPECT_MAX, attr, exp_nla_policy);
+       if (err < 0)
+               return err;
+
+       err = ctnetlink_nfqueue_exp_parse((const struct nlattr * const *)cda,
+                                         ct, &tuple, &mask);
+       if (err < 0)
+               return err;
+
+       if (cda[CTA_EXPECT_HELP_NAME]) {
+               const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]);
+
+               helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct),
+                                                   nf_ct_protonum(ct));
+               if (helper == NULL)
+                       return -EOPNOTSUPP;
+       }
+
+       exp = ctnetlink_alloc_expect((const struct nlattr * const *)cda, ct,
+                                    helper, &tuple, &mask);
+       if (IS_ERR(exp))
+               return PTR_ERR(exp);
+
+       err = nf_ct_expect_related_report(exp, portid, report);
+       if (err < 0) {
+               nf_ct_expect_put(exp);
+               return err;
+       }
+
+       return 0;
+}
+
 static struct nfq_ct_hook ctnetlink_nfqueue_hook = {
        .build_size     = ctnetlink_nfqueue_build_size,
        .build          = ctnetlink_nfqueue_build,
        .parse          = ctnetlink_nfqueue_parse,
+       .attach_expect  = ctnetlink_nfqueue_attach_expect,
+       .seq_adjust     = nf_ct_tcp_seqadj_set,
 };
 #endif /* CONFIG_NETFILTER_NETLINK_QUEUE_CT */
 
@@ -2510,21 +2571,6 @@ static int ctnetlink_dump_exp_ct(struct sock *ctnl, struct sk_buff *skb,
        return err;
 }
 
-static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = {
-       [CTA_EXPECT_MASTER]     = { .type = NLA_NESTED },
-       [CTA_EXPECT_TUPLE]      = { .type = NLA_NESTED },
-       [CTA_EXPECT_MASK]       = { .type = NLA_NESTED },
-       [CTA_EXPECT_TIMEOUT]    = { .type = NLA_U32 },
-       [CTA_EXPECT_ID]         = { .type = NLA_U32 },
-       [CTA_EXPECT_HELP_NAME]  = { .type = NLA_NUL_STRING,
-                                   .len = NF_CT_HELPER_NAME_LEN - 1 },
-       [CTA_EXPECT_ZONE]       = { .type = NLA_U16 },
-       [CTA_EXPECT_FLAGS]      = { .type = NLA_U32 },
-       [CTA_EXPECT_CLASS]      = { .type = NLA_U32 },
-       [CTA_EXPECT_NAT]        = { .type = NLA_NESTED },
-       [CTA_EXPECT_FN]         = { .type = NLA_NUL_STRING },
-};
-
 static int
 ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
                     const struct nlmsghdr *nlh,
@@ -2747,76 +2793,26 @@ ctnetlink_parse_expect_nat(const struct nlattr *attr,
 #endif
 }
 
-static int
-ctnetlink_create_expect(struct net *net, u16 zone,
-                       const struct nlattr * const cda[],
-                       u_int8_t u3,
-                       u32 portid, int report)
+static struct nf_conntrack_expect *
+ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct,
+                      struct nf_conntrack_helper *helper,
+                      struct nf_conntrack_tuple *tuple,
+                      struct nf_conntrack_tuple *mask)
 {
-       struct nf_conntrack_tuple tuple, mask, master_tuple;
-       struct nf_conntrack_tuple_hash *h = NULL;
+       u_int32_t class = 0;
        struct nf_conntrack_expect *exp;
-       struct nf_conn *ct;
        struct nf_conn_help *help;
-       struct nf_conntrack_helper *helper = NULL;
-       u_int32_t class = 0;
-       int err = 0;
-
-       /* caller guarantees that those three CTA_EXPECT_* exist */
-       err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
-       if (err < 0)
-               return err;
-       err = ctnetlink_parse_tuple(cda, &mask, CTA_EXPECT_MASK, u3);
-       if (err < 0)
-               return err;
-       err = ctnetlink_parse_tuple(cda, &master_tuple, CTA_EXPECT_MASTER, u3);
-       if (err < 0)
-               return err;
-
-       /* Look for master conntrack of this expectation */
-       h = nf_conntrack_find_get(net, zone, &master_tuple);
-       if (!h)
-               return -ENOENT;
-       ct = nf_ct_tuplehash_to_ctrack(h);
-
-       /* Look for helper of this expectation */
-       if (cda[CTA_EXPECT_HELP_NAME]) {
-               const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]);
-
-               helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct),
-                                                   nf_ct_protonum(ct));
-               if (helper == NULL) {
-#ifdef CONFIG_MODULES
-                       if (request_module("nfct-helper-%s", helpname) < 0) {
-                               err = -EOPNOTSUPP;
-                               goto out;
-                       }
-
-                       helper = __nf_conntrack_helper_find(helpname,
-                                                           nf_ct_l3num(ct),
-                                                           nf_ct_protonum(ct));
-                       if (helper) {
-                               err = -EAGAIN;
-                               goto out;
-                       }
-#endif
-                       err = -EOPNOTSUPP;
-                       goto out;
-               }
-       }
+       int err;
 
        if (cda[CTA_EXPECT_CLASS] && helper) {
                class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS]));
-               if (class > helper->expect_class_max) {
-                       err = -EINVAL;
-                       goto out;
-               }
+               if (class > helper->expect_class_max)
+                       return ERR_PTR(-EINVAL);
        }
        exp = nf_ct_expect_alloc(ct);
-       if (!exp) {
-               err = -ENOMEM;
-               goto out;
-       }
+       if (!exp)
+               return ERR_PTR(-ENOMEM);
+
        help = nfct_help(ct);
        if (!help) {
                if (!cda[CTA_EXPECT_TIMEOUT]) {
@@ -2854,21 +2850,89 @@ ctnetlink_create_expect(struct net *net, u16 zone,
        exp->class = class;
        exp->master = ct;
        exp->helper = helper;
-       memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple));
-       memcpy(&exp->mask.src.u3, &mask.src.u3, sizeof(exp->mask.src.u3));
-       exp->mask.src.u.all = mask.src.u.all;
+       exp->tuple = *tuple;
+       exp->mask.src.u3 = mask->src.u3;
+       exp->mask.src.u.all = mask->src.u.all;
 
        if (cda[CTA_EXPECT_NAT]) {
                err = ctnetlink_parse_expect_nat(cda[CTA_EXPECT_NAT],
-                                                exp, u3);
+                                                exp, nf_ct_l3num(ct));
                if (err < 0)
                        goto err_out;
        }
-       err = nf_ct_expect_related_report(exp, portid, report);
+       return exp;
 err_out:
        nf_ct_expect_put(exp);
-out:
-       nf_ct_put(nf_ct_tuplehash_to_ctrack(h));
+       return ERR_PTR(err);
+}
+
+static int
+ctnetlink_create_expect(struct net *net, u16 zone,
+                       const struct nlattr * const cda[],
+                       u_int8_t u3, u32 portid, int report)
+{
+       struct nf_conntrack_tuple tuple, mask, master_tuple;
+       struct nf_conntrack_tuple_hash *h = NULL;
+       struct nf_conntrack_helper *helper = NULL;
+       struct nf_conntrack_expect *exp;
+       struct nf_conn *ct;
+       int err;
+
+       /* caller guarantees that those three CTA_EXPECT_* exist */
+       err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3);
+       if (err < 0)
+               return err;
+       err = ctnetlink_parse_tuple(cda, &mask, CTA_EXPECT_MASK, u3);
+       if (err < 0)
+               return err;
+       err = ctnetlink_parse_tuple(cda, &master_tuple, CTA_EXPECT_MASTER, u3);
+       if (err < 0)
+               return err;
+
+       /* Look for master conntrack of this expectation */
+       h = nf_conntrack_find_get(net, zone, &master_tuple);
+       if (!h)
+               return -ENOENT;
+       ct = nf_ct_tuplehash_to_ctrack(h);
+
+       if (cda[CTA_EXPECT_HELP_NAME]) {
+               const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]);
+
+               helper = __nf_conntrack_helper_find(helpname, u3,
+                                                   nf_ct_protonum(ct));
+               if (helper == NULL) {
+#ifdef CONFIG_MODULES
+                       if (request_module("nfct-helper-%s", helpname) < 0) {
+                               err = -EOPNOTSUPP;
+                               goto err_ct;
+                       }
+                       helper = __nf_conntrack_helper_find(helpname, u3,
+                                                           nf_ct_protonum(ct));
+                       if (helper) {
+                               err = -EAGAIN;
+                               goto err_ct;
+                       }
+#endif
+                       err = -EOPNOTSUPP;
+                       goto err_ct;
+               }
+       }
+
+       exp = ctnetlink_alloc_expect(cda, ct, helper, &tuple, &mask);
+       if (IS_ERR(exp)) {
+               err = PTR_ERR(exp);
+               goto err_ct;
+       }
+
+       err = nf_ct_expect_related_report(exp, portid, report);
+       if (err < 0)
+               goto err_exp;
+
+       return 0;
+err_exp:
+       nf_ct_expect_put(exp);
+err_ct:
+       nf_ct_put(ct);
        return err;
 }
 
index 0ab9636ac57e03308ee1f316b0f11ca49d4e826d..ce3004156eeb923171c2ef08eae6e3447ce7906e 100644 (file)
@@ -281,7 +281,7 @@ void nf_ct_l3proto_pernet_unregister(struct net *net,
        nf_ct_l3proto_unregister_sysctl(net, proto);
 
        /* Remove all contrack entries for this protocol */
-       nf_ct_iterate_cleanup(net, kill_l3proto, proto);
+       nf_ct_iterate_cleanup(net, kill_l3proto, proto, 0, 0);
 }
 EXPORT_SYMBOL_GPL(nf_ct_l3proto_pernet_unregister);
 
@@ -476,7 +476,7 @@ void nf_ct_l4proto_pernet_unregister(struct net *net,
        nf_ct_l4proto_unregister_sysctl(net, pn, l4proto);
 
        /* Remove all contrack entries for this protocol */
-       nf_ct_iterate_cleanup(net, kill_l4proto, l4proto);
+       nf_ct_iterate_cleanup(net, kill_l4proto, l4proto, 0, 0);
 }
 EXPORT_SYMBOL_GPL(nf_ct_l4proto_pernet_unregister);
 
index 7dcc376eea5f9205d1abf76f62a8d58eb54bc788..44d1ea32570a07338dc39f34624bd823b6f76916 100644 (file)
@@ -27,6 +27,8 @@
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
+#include <net/netfilter/nf_conntrack_synproxy.h>
 #include <net/netfilter/nf_log.h>
 #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
 #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
@@ -495,21 +497,6 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
        }
 }
 
-#ifdef CONFIG_NF_NAT_NEEDED
-static inline s16 nat_offset(const struct nf_conn *ct,
-                            enum ip_conntrack_dir dir,
-                            u32 seq)
-{
-       typeof(nf_ct_nat_offset) get_offset = rcu_dereference(nf_ct_nat_offset);
-
-       return get_offset != NULL ? get_offset(ct, dir, seq) : 0;
-}
-#define NAT_OFFSET(ct, dir, seq) \
-       (nat_offset(ct, dir, seq))
-#else
-#define NAT_OFFSET(ct, dir, seq)       0
-#endif
-
 static bool tcp_in_window(const struct nf_conn *ct,
                          struct ip_ct_tcp *state,
                          enum ip_conntrack_dir dir,
@@ -525,8 +512,8 @@ static bool tcp_in_window(const struct nf_conn *ct,
        struct ip_ct_tcp_state *receiver = &state->seen[!dir];
        const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
        __u32 seq, ack, sack, end, win, swin;
-       s16 receiver_offset;
-       bool res;
+       s32 receiver_offset;
+       bool res, in_recv_win;
 
        /*
         * Get the required data from the packet.
@@ -540,7 +527,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
                tcp_sack(skb, dataoff, tcph, &sack);
 
        /* Take into account NAT sequence number mangling */
-       receiver_offset = NAT_OFFSET(ct, !dir, ack - 1);
+       receiver_offset = nf_ct_seq_offset(ct, !dir, ack - 1);
        ack -= receiver_offset;
        sack -= receiver_offset;
 
@@ -649,14 +636,18 @@ static bool tcp_in_window(const struct nf_conn *ct,
                 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
                 receiver->td_scale);
 
+       /* Is the ending sequence in the receive window (if available)? */
+       in_recv_win = !receiver->td_maxwin ||
+                     after(end, sender->td_end - receiver->td_maxwin - 1);
+
        pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
                 before(seq, sender->td_maxend + 1),
-                after(end, sender->td_end - receiver->td_maxwin - 1),
+                (in_recv_win ? 1 : 0),
                 before(sack, receiver->td_end + 1),
                 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1));
 
        if (before(seq, sender->td_maxend + 1) &&
-           after(end, sender->td_end - receiver->td_maxwin - 1) &&
+           in_recv_win &&
            before(sack, receiver->td_end + 1) &&
            after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) {
                /*
@@ -725,7 +716,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
                        nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
                        "nf_ct_tcp: %s ",
                        before(seq, sender->td_maxend + 1) ?
-                       after(end, sender->td_end - receiver->td_maxwin - 1) ?
+                       in_recv_win ?
                        before(sack, receiver->td_end + 1) ?
                        after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG"
                        : "ACK is under the lower bound (possible overly delayed ACK)"
@@ -956,6 +947,21 @@ static int tcp_packet(struct nf_conn *ct,
                                  "state %s ", tcp_conntrack_names[old_state]);
                return NF_ACCEPT;
        case TCP_CONNTRACK_MAX:
+               /* Special case for SYN proxy: when the SYN to the server or
+                * the SYN/ACK from the server is lost, the client may transmit
+                * a keep-alive packet while in SYN_SENT state. This needs to
+                * be associated with the original conntrack entry in order to
+                * generate a new SYN with the correct sequence number.
+                */
+               if (nfct_synproxy(ct) && old_state == TCP_CONNTRACK_SYN_SENT &&
+                   index == TCP_ACK_SET && dir == IP_CT_DIR_ORIGINAL &&
+                   ct->proto.tcp.last_dir == IP_CT_DIR_ORIGINAL &&
+                   ct->proto.tcp.seen[dir].td_end - 1 == ntohl(th->seq)) {
+                       pr_debug("nf_ct_tcp: SYN proxy client keep alive\n");
+                       spin_unlock_bh(&ct->lock);
+                       return NF_ACCEPT;
+               }
+
                /* Invalid packet */
                pr_debug("nf_ct_tcp: Invalid dir=%i index=%u ostate=%u\n",
                         dir, get_conntrack_index(th), old_state);
diff --git a/net/netfilter/nf_conntrack_seqadj.c b/net/netfilter/nf_conntrack_seqadj.c
new file mode 100644 (file)
index 0000000..5f9bfd0
--- /dev/null
@@ -0,0 +1,238 @@
+#include <linux/types.h>
+#include <linux/netfilter.h>
+#include <net/tcp.h>
+
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_extend.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
+
+int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                     s32 off)
+{
+       enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
+       struct nf_conn_seqadj *seqadj;
+       struct nf_ct_seqadj *this_way;
+
+       if (off == 0)
+               return 0;
+
+       set_bit(IPS_SEQ_ADJUST_BIT, &ct->status);
+
+       seqadj = nfct_seqadj(ct);
+       this_way = &seqadj->seq[dir];
+       this_way->offset_before  = off;
+       this_way->offset_after   = off;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(nf_ct_seqadj_init);
+
+int nf_ct_seqadj_set(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                    __be32 seq, s32 off)
+{
+       struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
+       enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
+       struct nf_ct_seqadj *this_way;
+
+       if (off == 0)
+               return 0;
+
+       set_bit(IPS_SEQ_ADJUST_BIT, &ct->status);
+
+       spin_lock_bh(&ct->lock);
+       this_way = &seqadj->seq[dir];
+       if (this_way->offset_before == this_way->offset_after ||
+           before(this_way->correction_pos, seq)) {
+               this_way->correction_pos = seq;
+               this_way->offset_before  = this_way->offset_after;
+               this_way->offset_after  += off;
+       }
+       spin_unlock_bh(&ct->lock);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(nf_ct_seqadj_set);
+
+void nf_ct_tcp_seqadj_set(struct sk_buff *skb,
+                         struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                         s32 off)
+{
+       const struct tcphdr *th;
+
+       if (nf_ct_protonum(ct) != IPPROTO_TCP)
+               return;
+
+       th = (struct tcphdr *)(skb_network_header(skb) + ip_hdrlen(skb));
+       nf_ct_seqadj_set(ct, ctinfo, th->seq, off);
+}
+EXPORT_SYMBOL_GPL(nf_ct_tcp_seqadj_set);
+
+/* Adjust one found SACK option including checksum correction */
+static void nf_ct_sack_block_adjust(struct sk_buff *skb,
+                                   struct tcphdr *tcph,
+                                   unsigned int sackoff,
+                                   unsigned int sackend,
+                                   struct nf_ct_seqadj *seq)
+{
+       while (sackoff < sackend) {
+               struct tcp_sack_block_wire *sack;
+               __be32 new_start_seq, new_end_seq;
+
+               sack = (void *)skb->data + sackoff;
+               if (after(ntohl(sack->start_seq) - seq->offset_before,
+                         seq->correction_pos))
+                       new_start_seq = htonl(ntohl(sack->start_seq) -
+                                       seq->offset_after);
+               else
+                       new_start_seq = htonl(ntohl(sack->start_seq) -
+                                       seq->offset_before);
+
+               if (after(ntohl(sack->end_seq) - seq->offset_before,
+                         seq->correction_pos))
+                       new_end_seq = htonl(ntohl(sack->end_seq) -
+                                     seq->offset_after);
+               else
+                       new_end_seq = htonl(ntohl(sack->end_seq) -
+                                     seq->offset_before);
+
+               pr_debug("sack_adjust: start_seq: %d->%d, end_seq: %d->%d\n",
+                        ntohl(sack->start_seq), new_start_seq,
+                        ntohl(sack->end_seq), new_end_seq);
+
+               inet_proto_csum_replace4(&tcph->check, skb,
+                                        sack->start_seq, new_start_seq, 0);
+               inet_proto_csum_replace4(&tcph->check, skb,
+                                        sack->end_seq, new_end_seq, 0);
+               sack->start_seq = new_start_seq;
+               sack->end_seq = new_end_seq;
+               sackoff += sizeof(*sack);
+       }
+}
+
+/* TCP SACK sequence number adjustment */
+static unsigned int nf_ct_sack_adjust(struct sk_buff *skb,
+                                     unsigned int protoff,
+                                     struct tcphdr *tcph,
+                                     struct nf_conn *ct,
+                                     enum ip_conntrack_info ctinfo)
+{
+       unsigned int dir, optoff, optend;
+       struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
+
+       optoff = protoff + sizeof(struct tcphdr);
+       optend = protoff + tcph->doff * 4;
+
+       if (!skb_make_writable(skb, optend))
+               return 0;
+
+       dir = CTINFO2DIR(ctinfo);
+
+       while (optoff < optend) {
+               /* Usually: option, length. */
+               unsigned char *op = skb->data + optoff;
+
+               switch (op[0]) {
+               case TCPOPT_EOL:
+                       return 1;
+               case TCPOPT_NOP:
+                       optoff++;
+                       continue;
+               default:
+                       /* no partial options */
+                       if (optoff + 1 == optend ||
+                           optoff + op[1] > optend ||
+                           op[1] < 2)
+                               return 0;
+                       if (op[0] == TCPOPT_SACK &&
+                           op[1] >= 2+TCPOLEN_SACK_PERBLOCK &&
+                           ((op[1] - 2) % TCPOLEN_SACK_PERBLOCK) == 0)
+                               nf_ct_sack_block_adjust(skb, tcph, optoff + 2,
+                                                       optoff+op[1],
+                                                       &seqadj->seq[!dir]);
+                       optoff += op[1];
+               }
+       }
+       return 1;
+}
+
+/* TCP sequence number adjustment.  Returns 1 on success, 0 on failure */
+int nf_ct_seq_adjust(struct sk_buff *skb,
+                    struct nf_conn *ct, enum ip_conntrack_info ctinfo,
+                    unsigned int protoff)
+{
+       enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
+       struct tcphdr *tcph;
+       __be32 newseq, newack;
+       s32 seqoff, ackoff;
+       struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
+       struct nf_ct_seqadj *this_way, *other_way;
+       int res;
+
+       this_way  = &seqadj->seq[dir];
+       other_way = &seqadj->seq[!dir];
+
+       if (!skb_make_writable(skb, protoff + sizeof(*tcph)))
+               return 0;
+
+       tcph = (void *)skb->data + protoff;
+       spin_lock_bh(&ct->lock);
+       if (after(ntohl(tcph->seq), this_way->correction_pos))
+               seqoff = this_way->offset_after;
+       else
+               seqoff = this_way->offset_before;
+
+       if (after(ntohl(tcph->ack_seq) - other_way->offset_before,
+                 other_way->correction_pos))
+               ackoff = other_way->offset_after;
+       else
+               ackoff = other_way->offset_before;
+
+       newseq = htonl(ntohl(tcph->seq) + seqoff);
+       newack = htonl(ntohl(tcph->ack_seq) - ackoff);
+
+       inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0);
+       inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0);
+
+       pr_debug("Adjusting sequence number from %u->%u, ack from %u->%u\n",
+                ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq),
+                ntohl(newack));
+
+       tcph->seq = newseq;
+       tcph->ack_seq = newack;
+
+       res = nf_ct_sack_adjust(skb, protoff, tcph, ct, ctinfo);
+       spin_unlock_bh(&ct->lock);
+
+       return res;
+}
+EXPORT_SYMBOL_GPL(nf_ct_seq_adjust);
+
+s32 nf_ct_seq_offset(const struct nf_conn *ct,
+                    enum ip_conntrack_dir dir,
+                    u32 seq)
+{
+       struct nf_conn_seqadj *seqadj = nfct_seqadj(ct);
+       struct nf_ct_seqadj *this_way;
+
+       if (!seqadj)
+               return 0;
+
+       this_way = &seqadj->seq[dir];
+       return after(seq, this_way->correction_pos) ?
+                this_way->offset_after : this_way->offset_before;
+}
+EXPORT_SYMBOL_GPL(nf_ct_seq_offset);
+
+static struct nf_ct_ext_type nf_ct_seqadj_extend __read_mostly = {
+       .len    = sizeof(struct nf_conn_seqadj),
+       .align  = __alignof__(struct nf_conn_seqadj),
+       .id     = NF_CT_EXT_SEQADJ,
+};
+
+int nf_conntrack_seqadj_init(void)
+{
+       return nf_ct_extend_register(&nf_ct_seqadj_extend);
+}
+
+void nf_conntrack_seqadj_fini(void)
+{
+       nf_ct_extend_unregister(&nf_ct_seqadj_extend);
+}
index 038eee5c8f8548787bff468c40256d52bb6655fd..6f0f4f7f68a5f4a7f85c03b09a35b456bedc33a7 100644 (file)
@@ -25,6 +25,7 @@
 #include <net/netfilter/nf_nat_core.h>
 #include <net/netfilter/nf_nat_helper.h>
 #include <net/netfilter/nf_conntrack_helper.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
 #include <net/netfilter/nf_conntrack_zones.h>
 #include <linux/netfilter/nf_nat.h>
@@ -402,6 +403,9 @@ nf_nat_setup_info(struct nf_conn *ct,
                        ct->status |= IPS_SRC_NAT;
                else
                        ct->status |= IPS_DST_NAT;
+
+               if (nfct_help(ct))
+                       nfct_seqadj_ext_add(ct);
        }
 
        if (maniptype == NF_NAT_MANIP_SRC) {
@@ -497,7 +501,7 @@ static void nf_nat_l4proto_clean(u8 l3proto, u8 l4proto)
 
        rtnl_lock();
        for_each_net(net)
-               nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean);
+               nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean, 0, 0);
        rtnl_unlock();
 }
 
@@ -511,7 +515,7 @@ static void nf_nat_l3proto_clean(u8 l3proto)
        rtnl_lock();
 
        for_each_net(net)
-               nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean);
+               nf_ct_iterate_cleanup(net, nf_nat_proto_remove, &clean, 0, 0);
        rtnl_unlock();
 }
 
@@ -749,7 +753,7 @@ static void __net_exit nf_nat_net_exit(struct net *net)
 {
        struct nf_nat_proto_clean clean = {};
 
-       nf_ct_iterate_cleanup(net, &nf_nat_proto_remove, &clean);
+       nf_ct_iterate_cleanup(net, &nf_nat_proto_remove, &clean, 0, 0);
        synchronize_rcu();
        nf_ct_free_hashtable(net->ct.nat_bysource, net->ct.nat_htable_size);
 }
@@ -764,10 +768,6 @@ static struct nf_ct_helper_expectfn follow_master_nat = {
        .expectfn       = nf_nat_follow_master,
 };
 
-static struct nfq_ct_nat_hook nfq_ct_nat = {
-       .seq_adjust     = nf_nat_tcp_seq_adjust,
-};
-
 static int __init nf_nat_init(void)
 {
        int ret;
@@ -787,14 +787,9 @@ static int __init nf_nat_init(void)
        /* Initialize fake conntrack so that NAT will skip it */
        nf_ct_untracked_status_or(IPS_NAT_DONE_MASK);
 
-       BUG_ON(nf_nat_seq_adjust_hook != NULL);
-       RCU_INIT_POINTER(nf_nat_seq_adjust_hook, nf_nat_seq_adjust);
        BUG_ON(nfnetlink_parse_nat_setup_hook != NULL);
        RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook,
                           nfnetlink_parse_nat_setup);
-       BUG_ON(nf_ct_nat_offset != NULL);
-       RCU_INIT_POINTER(nf_ct_nat_offset, nf_nat_get_offset);
-       RCU_INIT_POINTER(nfq_ct_nat_hook, &nfq_ct_nat);
 #ifdef CONFIG_XFRM
        BUG_ON(nf_nat_decode_session_hook != NULL);
        RCU_INIT_POINTER(nf_nat_decode_session_hook, __nf_nat_decode_session);
@@ -813,10 +808,7 @@ static void __exit nf_nat_cleanup(void)
        unregister_pernet_subsys(&nf_nat_net_ops);
        nf_ct_extend_unregister(&nat_extend);
        nf_ct_helper_expectfn_unregister(&follow_master_nat);
-       RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL);
        RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL);
-       RCU_INIT_POINTER(nf_ct_nat_offset, NULL);
-       RCU_INIT_POINTER(nfq_ct_nat_hook, NULL);
 #ifdef CONFIG_XFRM
        RCU_INIT_POINTER(nf_nat_decode_session_hook, NULL);
 #endif
index 85e20a9190816f348a845937b8a4fe470a917744..2840abb5bb99a7590b228f13e5769a62902f3cf3 100644 (file)
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_ecache.h>
 #include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <net/netfilter/nf_nat.h>
 #include <net/netfilter/nf_nat_l3proto.h>
 #include <net/netfilter/nf_nat_l4proto.h>
 #include <net/netfilter/nf_nat_core.h>
 #include <net/netfilter/nf_nat_helper.h>
 
-#define DUMP_OFFSET(x) \
-       pr_debug("offset_before=%d, offset_after=%d, correction_pos=%u\n", \
-                x->offset_before, x->offset_after, x->correction_pos);
-
-static DEFINE_SPINLOCK(nf_nat_seqofs_lock);
-
-/* Setup TCP sequence correction given this change at this sequence */
-static inline void
-adjust_tcp_sequence(u32 seq,
-                   int sizediff,
-                   struct nf_conn *ct,
-                   enum ip_conntrack_info ctinfo)
-{
-       enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
-       struct nf_conn_nat *nat = nfct_nat(ct);
-       struct nf_nat_seq *this_way = &nat->seq[dir];
-
-       pr_debug("adjust_tcp_sequence: seq = %u, sizediff = %d\n",
-                seq, sizediff);
-
-       pr_debug("adjust_tcp_sequence: Seq_offset before: ");
-       DUMP_OFFSET(this_way);
-
-       spin_lock_bh(&nf_nat_seqofs_lock);
-
-       /* SYN adjust. If it's uninitialized, or this is after last
-        * correction, record it: we don't handle more than one
-        * adjustment in the window, but do deal with common case of a
-        * retransmit */
-       if (this_way->offset_before == this_way->offset_after ||
-           before(this_way->correction_pos, seq)) {
-               this_way->correction_pos = seq;
-               this_way->offset_before = this_way->offset_after;
-               this_way->offset_after += sizediff;
-       }
-       spin_unlock_bh(&nf_nat_seqofs_lock);
-
-       pr_debug("adjust_tcp_sequence: Seq_offset after: ");
-       DUMP_OFFSET(this_way);
-}
-
-/* Get the offset value, for conntrack */
-s16 nf_nat_get_offset(const struct nf_conn *ct,
-                     enum ip_conntrack_dir dir,
-                     u32 seq)
-{
-       struct nf_conn_nat *nat = nfct_nat(ct);
-       struct nf_nat_seq *this_way;
-       s16 offset;
-
-       if (!nat)
-               return 0;
-
-       this_way = &nat->seq[dir];
-       spin_lock_bh(&nf_nat_seqofs_lock);
-       offset = after(seq, this_way->correction_pos)
-                ? this_way->offset_after : this_way->offset_before;
-       spin_unlock_bh(&nf_nat_seqofs_lock);
-
-       return offset;
-}
-
 /* Frobs data inside this packet, which is linear. */
 static void mangle_contents(struct sk_buff *skb,
                            unsigned int dataoff,
@@ -142,30 +81,6 @@ static int enlarge_skb(struct sk_buff *skb, unsigned int extra)
        return 1;
 }
 
-void nf_nat_set_seq_adjust(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
-                          __be32 seq, s16 off)
-{
-       if (!off)
-               return;
-       set_bit(IPS_SEQ_ADJUST_BIT, &ct->status);
-       adjust_tcp_sequence(ntohl(seq), off, ct, ctinfo);
-       nf_conntrack_event_cache(IPCT_NATSEQADJ, ct);
-}
-EXPORT_SYMBOL_GPL(nf_nat_set_seq_adjust);
-
-void nf_nat_tcp_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
-                          u32 ctinfo, int off)
-{
-       const struct tcphdr *th;
-
-       if (nf_ct_protonum(ct) != IPPROTO_TCP)
-               return;
-
-       th = (struct tcphdr *)(skb_network_header(skb)+ ip_hdrlen(skb));
-       nf_nat_set_seq_adjust(ct, ctinfo, th->seq, off);
-}
-EXPORT_SYMBOL_GPL(nf_nat_tcp_seq_adjust);
-
 /* Generic function for mangling variable-length address changes inside
  * NATed TCP connections (like the PORT XXX,XXX,XXX,XXX,XXX,XXX
  * command in FTP).
@@ -210,8 +125,8 @@ int __nf_nat_mangle_tcp_packet(struct sk_buff *skb,
                             datalen, oldlen);
 
        if (adjust && rep_len != match_len)
-               nf_nat_set_seq_adjust(ct, ctinfo, tcph->seq,
-                                     (int)rep_len - (int)match_len);
+               nf_ct_seqadj_set(ct, ctinfo, tcph->seq,
+                                (int)rep_len - (int)match_len);
 
        return 1;
 }
@@ -271,145 +186,6 @@ nf_nat_mangle_udp_packet(struct sk_buff *skb,
 }
 EXPORT_SYMBOL(nf_nat_mangle_udp_packet);
 
-/* Adjust one found SACK option including checksum correction */
-static void
-sack_adjust(struct sk_buff *skb,
-           struct tcphdr *tcph,
-           unsigned int sackoff,
-           unsigned int sackend,
-           struct nf_nat_seq *natseq)
-{
-       while (sackoff < sackend) {
-               struct tcp_sack_block_wire *sack;
-               __be32 new_start_seq, new_end_seq;
-
-               sack = (void *)skb->data + sackoff;
-               if (after(ntohl(sack->start_seq) - natseq->offset_before,
-                         natseq->correction_pos))
-                       new_start_seq = htonl(ntohl(sack->start_seq)
-                                       - natseq->offset_after);
-               else
-                       new_start_seq = htonl(ntohl(sack->start_seq)
-                                       - natseq->offset_before);
-
-               if (after(ntohl(sack->end_seq) - natseq->offset_before,
-                         natseq->correction_pos))
-                       new_end_seq = htonl(ntohl(sack->end_seq)
-                                     - natseq->offset_after);
-               else
-                       new_end_seq = htonl(ntohl(sack->end_seq)
-                                     - natseq->offset_before);
-
-               pr_debug("sack_adjust: start_seq: %d->%d, end_seq: %d->%d\n",
-                        ntohl(sack->start_seq), new_start_seq,
-                        ntohl(sack->end_seq), new_end_seq);
-
-               inet_proto_csum_replace4(&tcph->check, skb,
-                                        sack->start_seq, new_start_seq, 0);
-               inet_proto_csum_replace4(&tcph->check, skb,
-                                        sack->end_seq, new_end_seq, 0);
-               sack->start_seq = new_start_seq;
-               sack->end_seq = new_end_seq;
-               sackoff += sizeof(*sack);
-       }
-}
-
-/* TCP SACK sequence number adjustment */
-static inline unsigned int
-nf_nat_sack_adjust(struct sk_buff *skb,
-                  unsigned int protoff,
-                  struct tcphdr *tcph,
-                  struct nf_conn *ct,
-                  enum ip_conntrack_info ctinfo)
-{
-       unsigned int dir, optoff, optend;
-       struct nf_conn_nat *nat = nfct_nat(ct);
-
-       optoff = protoff + sizeof(struct tcphdr);
-       optend = protoff + tcph->doff * 4;
-
-       if (!skb_make_writable(skb, optend))
-               return 0;
-
-       dir = CTINFO2DIR(ctinfo);
-
-       while (optoff < optend) {
-               /* Usually: option, length. */
-               unsigned char *op = skb->data + optoff;
-
-               switch (op[0]) {
-               case TCPOPT_EOL:
-                       return 1;
-               case TCPOPT_NOP:
-                       optoff++;
-                       continue;
-               default:
-                       /* no partial options */
-                       if (optoff + 1 == optend ||
-                           optoff + op[1] > optend ||
-                           op[1] < 2)
-                               return 0;
-                       if (op[0] == TCPOPT_SACK &&
-                           op[1] >= 2+TCPOLEN_SACK_PERBLOCK &&
-                           ((op[1] - 2) % TCPOLEN_SACK_PERBLOCK) == 0)
-                               sack_adjust(skb, tcph, optoff+2,
-                                           optoff+op[1], &nat->seq[!dir]);
-                       optoff += op[1];
-               }
-       }
-       return 1;
-}
-
-/* TCP sequence number adjustment.  Returns 1 on success, 0 on failure */
-int
-nf_nat_seq_adjust(struct sk_buff *skb,
-                 struct nf_conn *ct,
-                 enum ip_conntrack_info ctinfo,
-                 unsigned int protoff)
-{
-       struct tcphdr *tcph;
-       int dir;
-       __be32 newseq, newack;
-       s16 seqoff, ackoff;
-       struct nf_conn_nat *nat = nfct_nat(ct);
-       struct nf_nat_seq *this_way, *other_way;
-
-       dir = CTINFO2DIR(ctinfo);
-
-       this_way = &nat->seq[dir];
-       other_way = &nat->seq[!dir];
-
-       if (!skb_make_writable(skb, protoff + sizeof(*tcph)))
-               return 0;
-
-       tcph = (void *)skb->data + protoff;
-       if (after(ntohl(tcph->seq), this_way->correction_pos))
-               seqoff = this_way->offset_after;
-       else
-               seqoff = this_way->offset_before;
-
-       if (after(ntohl(tcph->ack_seq) - other_way->offset_before,
-                 other_way->correction_pos))
-               ackoff = other_way->offset_after;
-       else
-               ackoff = other_way->offset_before;
-
-       newseq = htonl(ntohl(tcph->seq) + seqoff);
-       newack = htonl(ntohl(tcph->ack_seq) - ackoff);
-
-       inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0);
-       inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0);
-
-       pr_debug("Adjusting sequence number from %u->%u, ack from %u->%u\n",
-                ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq),
-                ntohl(newack));
-
-       tcph->seq = newseq;
-       tcph->ack_seq = newack;
-
-       return nf_nat_sack_adjust(skb, protoff, tcph, ct, ctinfo);
-}
-
 /* Setup NAT on this expected conntrack so it follows master. */
 /* If we fail to get a free NAT slot, we'll get dropped on confirm */
 void nf_nat_follow_master(struct nf_conn *ct,
index 396e55d46f90c77ea25a88cc1e94decc76f81050..754536f2c67488acd4345cdcec3740916ab24fea 100644 (file)
@@ -34,9 +34,7 @@ sctp_manip_pkt(struct sk_buff *skb,
               const struct nf_conntrack_tuple *tuple,
               enum nf_nat_manip_type maniptype)
 {
-       struct sk_buff *frag;
        sctp_sctphdr_t *hdr;
-       __u32 crc32;
 
        if (!skb_make_writable(skb, hdroff + sizeof(*hdr)))
                return false;
@@ -51,11 +49,7 @@ sctp_manip_pkt(struct sk_buff *skb,
                hdr->dest = tuple->dst.u.sctp.port;
        }
 
-       crc32 = sctp_start_cksum((u8 *)hdr, skb_headlen(skb) - hdroff);
-       skb_walk_frags(skb, frag)
-               crc32 = sctp_update_cksum((u8 *)frag->data, skb_headlen(frag),
-                                         crc32);
-       hdr->checksum = sctp_end_cksum(crc32);
+       hdr->checksum = sctp_compute_cksum(skb, hdroff);
 
        return true;
 }
index dac11f73868e50df4e20add9e754d55629716f25..f9790405b7fff5ead6004bf4266fe4e96abbc6cb 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/netfilter/nf_nat_helper.h>
 #include <net/netfilter/nf_conntrack_helper.h>
 #include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
 #include <linux/netfilter/nf_conntrack_sip.h>
 
 MODULE_LICENSE("GPL");
@@ -308,7 +309,7 @@ static void nf_nat_sip_seq_adjust(struct sk_buff *skb, unsigned int protoff,
                return;
 
        th = (struct tcphdr *)(skb->data + protoff);
-       nf_nat_set_seq_adjust(ct, ctinfo, th->seq, off);
+       nf_ct_seqadj_set(ct, ctinfo, th->seq, off);
 }
 
 /* Handles expected signalling connections and media streams */
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
new file mode 100644 (file)
index 0000000..d23dc79
--- /dev/null
@@ -0,0 +1,432 @@
+/*
+ * Copyright (c) 2013 Patrick McHardy <kaber@trash.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <asm/unaligned.h>
+#include <net/tcp.h>
+#include <net/netns/generic.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter/xt_tcpudp.h>
+#include <linux/netfilter/xt_SYNPROXY.h>
+#include <net/netfilter/nf_conntrack.h>
+#include <net/netfilter/nf_conntrack_extend.h>
+#include <net/netfilter/nf_conntrack_seqadj.h>
+#include <net/netfilter/nf_conntrack_synproxy.h>
+
+int synproxy_net_id;
+EXPORT_SYMBOL_GPL(synproxy_net_id);
+
+void
+synproxy_parse_options(const struct sk_buff *skb, unsigned int doff,
+                      const struct tcphdr *th, struct synproxy_options *opts)
+{
+       int length = (th->doff * 4) - sizeof(*th);
+       u8 buf[40], *ptr;
+
+       ptr = skb_header_pointer(skb, doff + sizeof(*th), length, buf);
+       BUG_ON(ptr == NULL);
+
+       opts->options = 0;
+       while (length > 0) {
+               int opcode = *ptr++;
+               int opsize;
+
+               switch (opcode) {
+               case TCPOPT_EOL:
+                       return;
+               case TCPOPT_NOP:
+                       length--;
+                       continue;
+               default:
+                       opsize = *ptr++;
+                       if (opsize < 2)
+                               return;
+                       if (opsize > length)
+                               return;
+
+                       switch (opcode) {
+                       case TCPOPT_MSS:
+                               if (opsize == TCPOLEN_MSS) {
+                                       opts->mss = get_unaligned_be16(ptr);
+                                       opts->options |= XT_SYNPROXY_OPT_MSS;
+                               }
+                               break;
+                       case TCPOPT_WINDOW:
+                               if (opsize == TCPOLEN_WINDOW) {
+                                       opts->wscale = *ptr;
+                                       if (opts->wscale > 14)
+                                               opts->wscale = 14;
+                                       opts->options |= XT_SYNPROXY_OPT_WSCALE;
+                               }
+                               break;
+                       case TCPOPT_TIMESTAMP:
+                               if (opsize == TCPOLEN_TIMESTAMP) {
+                                       opts->tsval = get_unaligned_be32(ptr);
+                                       opts->tsecr = get_unaligned_be32(ptr + 4);
+                                       opts->options |= XT_SYNPROXY_OPT_TIMESTAMP;
+                               }
+                               break;
+                       case TCPOPT_SACK_PERM:
+                               if (opsize == TCPOLEN_SACK_PERM)
+                                       opts->options |= XT_SYNPROXY_OPT_SACK_PERM;
+                               break;
+                       }
+
+                       ptr += opsize - 2;
+                       length -= opsize;
+               }
+       }
+}
+EXPORT_SYMBOL_GPL(synproxy_parse_options);
+
+unsigned int synproxy_options_size(const struct synproxy_options *opts)
+{
+       unsigned int size = 0;
+
+       if (opts->options & XT_SYNPROXY_OPT_MSS)
+               size += TCPOLEN_MSS_ALIGNED;
+       if (opts->options & XT_SYNPROXY_OPT_TIMESTAMP)
+               size += TCPOLEN_TSTAMP_ALIGNED;
+       else if (opts->options & XT_SYNPROXY_OPT_SACK_PERM)
+               size += TCPOLEN_SACKPERM_ALIGNED;
+       if (opts->options & XT_SYNPROXY_OPT_WSCALE)
+               size += TCPOLEN_WSCALE_ALIGNED;
+
+       return size;
+}
+EXPORT_SYMBOL_GPL(synproxy_options_size);
+
+void
+synproxy_build_options(struct tcphdr *th, const struct synproxy_options *opts)
+{
+       __be32 *ptr = (__be32 *)(th + 1);
+       u8 options = opts->options;
+
+       if (options & XT_SYNPROXY_OPT_MSS)
+               *ptr++ = htonl((TCPOPT_MSS << 24) |
+                              (TCPOLEN_MSS << 16) |
+                              opts->mss);
+
+       if (options & XT_SYNPROXY_OPT_TIMESTAMP) {
+               if (options & XT_SYNPROXY_OPT_SACK_PERM)
+                       *ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
+                                      (TCPOLEN_SACK_PERM << 16) |
+                                      (TCPOPT_TIMESTAMP << 8) |
+                                      TCPOLEN_TIMESTAMP);
+               else
+                       *ptr++ = htonl((TCPOPT_NOP << 24) |
+                                      (TCPOPT_NOP << 16) |
+                                      (TCPOPT_TIMESTAMP << 8) |
+                                      TCPOLEN_TIMESTAMP);
+
+               *ptr++ = htonl(opts->tsval);
+               *ptr++ = htonl(opts->tsecr);
+       } else if (options & XT_SYNPROXY_OPT_SACK_PERM)
+               *ptr++ = htonl((TCPOPT_NOP << 24) |
+                              (TCPOPT_NOP << 16) |
+                              (TCPOPT_SACK_PERM << 8) |
+                              TCPOLEN_SACK_PERM);
+
+       if (options & XT_SYNPROXY_OPT_WSCALE)
+               *ptr++ = htonl((TCPOPT_NOP << 24) |
+                              (TCPOPT_WINDOW << 16) |
+                              (TCPOLEN_WINDOW << 8) |
+                              opts->wscale);
+}
+EXPORT_SYMBOL_GPL(synproxy_build_options);
+
+void synproxy_init_timestamp_cookie(const struct xt_synproxy_info *info,
+                                   struct synproxy_options *opts)
+{
+       opts->tsecr = opts->tsval;
+       opts->tsval = tcp_time_stamp & ~0x3f;
+
+       if (opts->options & XT_SYNPROXY_OPT_WSCALE)
+               opts->tsval |= info->wscale;
+       else
+               opts->tsval |= 0xf;
+
+       if (opts->options & XT_SYNPROXY_OPT_SACK_PERM)
+               opts->tsval |= 1 << 4;
+
+       if (opts->options & XT_SYNPROXY_OPT_ECN)
+               opts->tsval |= 1 << 5;
+}
+EXPORT_SYMBOL_GPL(synproxy_init_timestamp_cookie);
+
+void synproxy_check_timestamp_cookie(struct synproxy_options *opts)
+{
+       opts->wscale = opts->tsecr & 0xf;
+       if (opts->wscale != 0xf)
+               opts->options |= XT_SYNPROXY_OPT_WSCALE;
+
+       opts->options |= opts->tsecr & (1 << 4) ? XT_SYNPROXY_OPT_SACK_PERM : 0;
+
+       opts->options |= opts->tsecr & (1 << 5) ? XT_SYNPROXY_OPT_ECN : 0;
+}
+EXPORT_SYMBOL_GPL(synproxy_check_timestamp_cookie);
+
+unsigned int synproxy_tstamp_adjust(struct sk_buff *skb,
+                                   unsigned int protoff,
+                                   struct tcphdr *th,
+                                   struct nf_conn *ct,
+                                   enum ip_conntrack_info ctinfo,
+                                   const struct nf_conn_synproxy *synproxy)
+{
+       unsigned int optoff, optend;
+       u32 *ptr, old;
+
+       if (synproxy->tsoff == 0)
+               return 1;
+
+       optoff = protoff + sizeof(struct tcphdr);
+       optend = protoff + th->doff * 4;
+
+       if (!skb_make_writable(skb, optend))
+               return 0;
+
+       while (optoff < optend) {
+               unsigned char *op = skb->data + optoff;
+
+               switch (op[0]) {
+               case TCPOPT_EOL:
+                       return 1;
+               case TCPOPT_NOP:
+                       optoff++;
+                       continue;
+               default:
+                       if (optoff + 1 == optend ||
+                           optoff + op[1] > optend ||
+                           op[1] < 2)
+                               return 0;
+                       if (op[0] == TCPOPT_TIMESTAMP &&
+                           op[1] == TCPOLEN_TIMESTAMP) {
+                               if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY) {
+                                       ptr = (u32 *)&op[2];
+                                       old = *ptr;
+                                       *ptr = htonl(ntohl(*ptr) -
+                                                    synproxy->tsoff);
+                               } else {
+                                       ptr = (u32 *)&op[6];
+                                       old = *ptr;
+                                       *ptr = htonl(ntohl(*ptr) +
+                                                    synproxy->tsoff);
+                               }
+                               inet_proto_csum_replace4(&th->check, skb,
+                                                        old, *ptr, 0);
+                               return 1;
+                       }
+                       optoff += op[1];
+               }
+       }
+       return 1;
+}
+EXPORT_SYMBOL_GPL(synproxy_tstamp_adjust);
+
+static struct nf_ct_ext_type nf_ct_synproxy_extend __read_mostly = {
+       .len            = sizeof(struct nf_conn_synproxy),
+       .align          = __alignof__(struct nf_conn_synproxy),
+       .id             = NF_CT_EXT_SYNPROXY,
+};
+
+#ifdef CONFIG_PROC_FS
+static void *synproxy_cpu_seq_start(struct seq_file *seq, loff_t *pos)
+{
+       struct synproxy_net *snet = synproxy_pernet(seq_file_net(seq));
+       int cpu;
+
+       if (*pos == 0)
+               return SEQ_START_TOKEN;
+
+       for (cpu = *pos - 1; cpu < nr_cpu_ids; cpu++) {
+               if (!cpu_possible(cpu))
+                       continue;
+               *pos = cpu + 1;
+               return per_cpu_ptr(snet->stats, cpu);
+       }
+
+       return NULL;
+}
+
+static void *synproxy_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+       struct synproxy_net *snet = synproxy_pernet(seq_file_net(seq));
+       int cpu;
+
+       for (cpu = *pos; cpu < nr_cpu_ids; cpu++) {
+               if (!cpu_possible(cpu))
+                       continue;
+               *pos = cpu + 1;
+               return per_cpu_ptr(snet->stats, cpu);
+       }
+
+       return NULL;
+}
+
+static void synproxy_cpu_seq_stop(struct seq_file *seq, void *v)
+{
+       return;
+}
+
+static int synproxy_cpu_seq_show(struct seq_file *seq, void *v)
+{
+       struct synproxy_stats *stats = v;
+
+       if (v == SEQ_START_TOKEN) {
+               seq_printf(seq, "entries\t\tsyn_received\t"
+                               "cookie_invalid\tcookie_valid\t"
+                               "cookie_retrans\tconn_reopened\n");
+               return 0;
+       }
+
+       seq_printf(seq, "%08x\t%08x\t%08x\t%08x\t%08x\t%08x\n", 0,
+                  stats->syn_received,
+                  stats->cookie_invalid,
+                  stats->cookie_valid,
+                  stats->cookie_retrans,
+                  stats->conn_reopened);
+
+       return 0;
+}
+
+static const struct seq_operations synproxy_cpu_seq_ops = {
+       .start          = synproxy_cpu_seq_start,
+       .next           = synproxy_cpu_seq_next,
+       .stop           = synproxy_cpu_seq_stop,
+       .show           = synproxy_cpu_seq_show,
+};
+
+static int synproxy_cpu_seq_open(struct inode *inode, struct file *file)
+{
+       return seq_open_net(inode, file, &synproxy_cpu_seq_ops,
+                           sizeof(struct seq_net_private));
+}
+
+static const struct file_operations synproxy_cpu_seq_fops = {
+       .owner          = THIS_MODULE,
+       .open           = synproxy_cpu_seq_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release_net,
+};
+
+static int __net_init synproxy_proc_init(struct net *net)
+{
+       if (!proc_create("synproxy", S_IRUGO, net->proc_net_stat,
+                        &synproxy_cpu_seq_fops))
+               return -ENOMEM;
+       return 0;
+}
+
+static void __net_exit synproxy_proc_exit(struct net *net)
+{
+       remove_proc_entry("synproxy", net->proc_net_stat);
+}
+#else
+static int __net_init synproxy_proc_init(struct net *net)
+{
+       return 0;
+}
+
+static void __net_exit synproxy_proc_exit(struct net *net)
+{
+       return;
+}
+#endif /* CONFIG_PROC_FS */
+
+static int __net_init synproxy_net_init(struct net *net)
+{
+       struct synproxy_net *snet = synproxy_pernet(net);
+       struct nf_conntrack_tuple t;
+       struct nf_conn *ct;
+       int err = -ENOMEM;
+
+       memset(&t, 0, sizeof(t));
+       ct = nf_conntrack_alloc(net, 0, &t, &t, GFP_KERNEL);
+       if (IS_ERR(ct)) {
+               err = PTR_ERR(ct);
+               goto err1;
+       }
+
+       __set_bit(IPS_TEMPLATE_BIT, &ct->status);
+       __set_bit(IPS_CONFIRMED_BIT, &ct->status);
+       if (!nfct_seqadj_ext_add(ct))
+               goto err2;
+       if (!nfct_synproxy_ext_add(ct))
+               goto err2;
+
+       snet->tmpl = ct;
+
+       snet->stats = alloc_percpu(struct synproxy_stats);
+       if (snet->stats == NULL)
+               goto err2;
+
+       err = synproxy_proc_init(net);
+       if (err < 0)
+               goto err3;
+
+       return 0;
+
+err3:
+       free_percpu(snet->stats);
+err2:
+       nf_conntrack_free(ct);
+err1:
+       return err;
+}
+
+static void __net_exit synproxy_net_exit(struct net *net)
+{
+       struct synproxy_net *snet = synproxy_pernet(net);
+
+       nf_conntrack_free(snet->tmpl);
+       synproxy_proc_exit(net);
+       free_percpu(snet->stats);
+}
+
+static struct pernet_operations synproxy_net_ops = {
+       .init           = synproxy_net_init,
+       .exit           = synproxy_net_exit,
+       .id             = &synproxy_net_id,
+       .size           = sizeof(struct synproxy_net),
+};
+
+static int __init synproxy_core_init(void)
+{
+       int err;
+
+       err = nf_ct_extend_register(&nf_ct_synproxy_extend);
+       if (err < 0)
+               goto err1;
+
+       err = register_pernet_subsys(&synproxy_net_ops);
+       if (err < 0)
+               goto err2;
+
+       return 0;
+
+err2:
+       nf_ct_extend_unregister(&nf_ct_synproxy_extend);
+err1:
+       return err;
+}
+
+static void __exit synproxy_core_exit(void)
+{
+       unregister_pernet_subsys(&synproxy_net_ops);
+       nf_ct_extend_unregister(&nf_ct_synproxy_extend);
+}
+
+module_init(synproxy_core_init);
+module_exit(synproxy_core_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
diff --git a/net/netfilter/nf_tproxy_core.c b/net/netfilter/nf_tproxy_core.c
deleted file mode 100644 (file)
index 474d621..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Transparent proxy support for Linux/iptables
- *
- * Copyright (c) 2006-2007 BalaBit IT Ltd.
- * Author: Balazs Scheidler, Krisztian Kovacs
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#include <linux/module.h>
-
-#include <linux/net.h>
-#include <linux/if.h>
-#include <linux/netdevice.h>
-#include <net/udp.h>
-#include <net/netfilter/nf_tproxy_core.h>
-
-
-static void
-nf_tproxy_destructor(struct sk_buff *skb)
-{
-       struct sock *sk = skb->sk;
-
-       skb->sk = NULL;
-       skb->destructor = NULL;
-
-       if (sk)
-               sock_put(sk);
-}
-
-/* consumes sk */
-void
-nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
-{
-       /* assigning tw sockets complicates things; most
-        * skb->sk->X checks would have to test sk->sk_state first */
-       if (sk->sk_state == TCP_TIME_WAIT) {
-               inet_twsk_put(inet_twsk(sk));
-               return;
-       }
-
-       skb_orphan(skb);
-       skb->sk = sk;
-       skb->destructor = nf_tproxy_destructor;
-}
-EXPORT_SYMBOL_GPL(nf_tproxy_assign_sock);
-
-static int __init nf_tproxy_init(void)
-{
-       pr_info("NF_TPROXY: Transparent proxy support initialized, version 4.1.0\n");
-       pr_info("NF_TPROXY: Copyright (c) 2006-2007 BalaBit IT Ltd.\n");
-       return 0;
-}
-
-module_init(nf_tproxy_init);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Krisztian Kovacs");
-MODULE_DESCRIPTION("Transparent proxy support core routines");
index 962e9792e3179997db98a448a76fc909432d841f..d92cc317bf8b25a0c371b770688c860169c9dea8 100644 (file)
@@ -419,6 +419,7 @@ __build_packet_message(struct nfnl_log_net *log,
        nfmsg->version = NFNETLINK_V0;
        nfmsg->res_id = htons(inst->group_num);
 
+       memset(&pmsg, 0, sizeof(pmsg));
        pmsg.hw_protocol        = skb->protocol;
        pmsg.hook               = hooknum;
 
@@ -498,7 +499,10 @@ __build_packet_message(struct nfnl_log_net *log,
        if (indev && skb->dev &&
            skb->mac_header != skb->network_header) {
                struct nfulnl_msg_packet_hw phw;
-               int len = dev_parse_header(skb, phw.hw_addr);
+               int len;
+
+               memset(&phw, 0, sizeof(phw));
+               len = dev_parse_header(skb, phw.hw_addr);
                if (len > 0) {
                        phw.hw_addrlen = htons(len);
                        if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
index 971ea145ab3ea33a2d42ad0cf66e7025c1457832..95a98c8c1da65be10ea5499aba6291cdf8319fed 100644 (file)
@@ -463,7 +463,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
        if (indev && entskb->dev &&
            entskb->mac_header != entskb->network_header) {
                struct nfqnl_msg_packet_hw phw;
-               int len = dev_parse_header(entskb, phw.hw_addr);
+               int len;
+
+               memset(&phw, 0, sizeof(phw));
+               len = dev_parse_header(entskb, phw.hw_addr);
                if (len) {
                        phw.hw_addrlen = htons(len);
                        if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
@@ -859,6 +862,7 @@ static const struct nla_policy nfqa_verdict_policy[NFQA_MAX+1] = {
        [NFQA_MARK]             = { .type = NLA_U32 },
        [NFQA_PAYLOAD]          = { .type = NLA_UNSPEC },
        [NFQA_CT]               = { .type = NLA_UNSPEC },
+       [NFQA_EXP]              = { .type = NLA_UNSPEC },
 };
 
 static const struct nla_policy nfqa_verdict_batch_policy[NFQA_MAX+1] = {
@@ -987,9 +991,14 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
        if (entry == NULL)
                return -ENOENT;
 
-       rcu_read_lock();
-       if (nfqa[NFQA_CT] && (queue->flags & NFQA_CFG_F_CONNTRACK))
+       if (nfqa[NFQA_CT]) {
                ct = nfqnl_ct_parse(entry->skb, nfqa[NFQA_CT], &ctinfo);
+               if (ct && nfqa[NFQA_EXP]) {
+                       nfqnl_attach_expect(ct, nfqa[NFQA_EXP],
+                                           NETLINK_CB(skb).portid,
+                                           nlmsg_report(nlh));
+               }
+       }
 
        if (nfqa[NFQA_PAYLOAD]) {
                u16 payload_len = nla_len(nfqa[NFQA_PAYLOAD]);
@@ -1002,7 +1011,6 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
                if (ct)
                        nfqnl_ct_seq_adjust(skb, ct, ctinfo, diff);
        }
-       rcu_read_unlock();
 
        if (nfqa[NFQA_MARK])
                entry->skb->mark = ntohl(nla_get_be32(nfqa[NFQA_MARK]));
index ab61d66bc0b9e53fb5c0b657d0d954f8ea16cf3b..96cac50e0d122a8e602c6681eb017aa4c0f501bf 100644 (file)
@@ -87,12 +87,27 @@ nla_put_failure:
 void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
                         enum ip_conntrack_info ctinfo, int diff)
 {
-       struct nfq_ct_nat_hook *nfq_nat_ct;
+       struct nfq_ct_hook *nfq_ct;
 
-       nfq_nat_ct = rcu_dereference(nfq_ct_nat_hook);
-       if (nfq_nat_ct == NULL)
+       nfq_ct = rcu_dereference(nfq_ct_hook);
+       if (nfq_ct == NULL)
                return;
 
        if ((ct->status & IPS_NAT_MASK) && diff)
-               nfq_nat_ct->seq_adjust(skb, ct, ctinfo, diff);
+               nfq_ct->seq_adjust(skb, ct, ctinfo, diff);
+}
+
+int nfqnl_attach_expect(struct nf_conn *ct, const struct nlattr *attr,
+                       u32 portid, u32 report)
+{
+       struct nfq_ct_hook *nfq_ct;
+
+       if (nf_ct_is_untracked(ct))
+               return 0;
+
+       nfq_ct = rcu_dereference(nfq_ct_hook);
+       if (nfq_ct == NULL)
+               return -EOPNOTSUPP;
+
+       return nfq_ct->attach_expect(attr, ct, portid, report);
 }
index 7011c71646f0266eb75c856bc49fea7b5030bd52..6113cc7efffcd782cee9d8c2e07ffc399f6e67c4 100644 (file)
@@ -52,7 +52,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
 {
        const struct xt_tcpmss_info *info = par->targinfo;
        struct tcphdr *tcph;
-       unsigned int tcplen, i;
+       int len, tcp_hdrlen;
+       unsigned int i;
        __be16 oldval;
        u16 newmss;
        u8 *opt;
@@ -64,11 +65,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
        if (!skb_make_writable(skb, skb->len))
                return -1;
 
-       tcplen = skb->len - tcphoff;
+       len = skb->len - tcphoff;
+       if (len < (int)sizeof(struct tcphdr))
+               return -1;
+
        tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
+       tcp_hdrlen = tcph->doff * 4;
 
-       /* Header cannot be larger than the packet */
-       if (tcplen < tcph->doff*4)
+       if (len < tcp_hdrlen)
                return -1;
 
        if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
@@ -87,9 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
                newmss = info->mss;
 
        opt = (u_int8_t *)tcph;
-       for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
-               if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
-                   opt[i+1] == TCPOLEN_MSS) {
+       for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
+               if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
                        u_int16_t oldmss;
 
                        oldmss = (opt[i+2] << 8) | opt[i+3];
@@ -112,9 +115,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
        }
 
        /* There is data after the header so the option can't be added
-          without moving it, and doing so may make the SYN packet
-          itself too large. Accept the packet unmodified instead. */
-       if (tcplen > tcph->doff*4)
+        * without moving it, and doing so may make the SYN packet
+        * itself too large. Accept the packet unmodified instead.
+        */
+       if (len > tcp_hdrlen)
                return 0;
 
        /*
@@ -143,10 +147,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
                newmss = min(newmss, (u16)1220);
 
        opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
-       memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
+       memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
 
        inet_proto_csum_replace2(&tcph->check, skb,
-                                htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
+                                htons(len), htons(len + TCPOLEN_MSS), 1);
        opt[0] = TCPOPT_MSS;
        opt[1] = TCPOLEN_MSS;
        opt[2] = (newmss & 0xff00) >> 8;
index b68fa191710fe02bdb1b09f825ee6330c9bf570b..625fa1d636a01ccacb43c2fcae902d65a466b9db 100644 (file)
@@ -38,7 +38,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
        struct tcphdr *tcph;
        u_int16_t n, o;
        u_int8_t *opt;
-       int len;
+       int len, tcp_hdrlen;
 
        /* This is a fragment, no TCP header is available */
        if (par->fragoff != 0)
@@ -52,7 +52,9 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
                return NF_DROP;
 
        tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
-       if (tcph->doff * 4 > len)
+       tcp_hdrlen = tcph->doff * 4;
+
+       if (len < tcp_hdrlen)
                return NF_DROP;
 
        opt  = (u_int8_t *)tcph;
@@ -61,10 +63,10 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
         * Walk through all TCP options - if we find some option to remove,
         * set all octets to %TCPOPT_NOP and adjust checksum.
         */
-       for (i = sizeof(struct tcphdr); i < tcp_hdrlen(skb); i += optl) {
+       for (i = sizeof(struct tcphdr); i < tcp_hdrlen - 1; i += optl) {
                optl = optlen(opt, i);
 
-               if (i + optl > tcp_hdrlen(skb))
+               if (i + optl > tcp_hdrlen)
                        break;
 
                if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i]))
index d7f195388f66c5a76fcd62bd66ee6ac9567dd334..5d8a3a3cd5a7cd04b714d92a1366c04ad464e716 100644 (file)
@@ -15,7 +15,9 @@
 #include <linux/ip.h>
 #include <net/checksum.h>
 #include <net/udp.h>
+#include <net/tcp.h>
 #include <net/inet_sock.h>
+#include <net/inet_hashtables.h>
 #include <linux/inetdevice.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
 #define XT_TPROXY_HAVE_IPV6 1
 #include <net/if_inet6.h>
 #include <net/addrconf.h>
+#include <net/inet6_hashtables.h>
 #include <linux/netfilter_ipv6/ip6_tables.h>
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
 #endif
 
-#include <net/netfilter/nf_tproxy_core.h>
 #include <linux/netfilter/xt_TPROXY.h>
 
+enum nf_tproxy_lookup_t {
+        NFT_LOOKUP_LISTENER,
+        NFT_LOOKUP_ESTABLISHED,
+};
+
 static bool tproxy_sk_is_transparent(struct sock *sk)
 {
        if (sk->sk_state != TCP_TIME_WAIT) {
@@ -68,6 +75,157 @@ tproxy_laddr4(struct sk_buff *skb, __be32 user_laddr, __be32 daddr)
        return laddr ? laddr : daddr;
 }
 
+/*
+ * This is used when the user wants to intercept a connection matching
+ * an explicit iptables rule. In this case the sockets are assumed
+ * matching in preference order:
+ *
+ *   - match: if there's a fully established connection matching the
+ *     _packet_ tuple, it is returned, assuming the redirection
+ *     already took place and we process a packet belonging to an
+ *     established connection
+ *
+ *   - match: if there's a listening socket matching the redirection
+ *     (e.g. on-port & on-ip of the connection), it is returned,
+ *     regardless if it was bound to 0.0.0.0 or an explicit
+ *     address. The reasoning is that if there's an explicit rule, it
+ *     does not really matter if the listener is bound to an interface
+ *     or to 0. The user already stated that he wants redirection
+ *     (since he added the rule).
+ *
+ * Please note that there's an overlap between what a TPROXY target
+ * and a socket match will match. Normally if you have both rules the
+ * "socket" match will be the first one, effectively all packets
+ * belonging to established connections going through that one.
+ */
+static inline struct sock *
+nf_tproxy_get_sock_v4(struct net *net, const u8 protocol,
+                     const __be32 saddr, const __be32 daddr,
+                     const __be16 sport, const __be16 dport,
+                     const struct net_device *in,
+                     const enum nf_tproxy_lookup_t lookup_type)
+{
+       struct sock *sk;
+
+       switch (protocol) {
+       case IPPROTO_TCP:
+               switch (lookup_type) {
+               case NFT_LOOKUP_LISTENER:
+                       sk = inet_lookup_listener(net, &tcp_hashinfo,
+                                                   saddr, sport,
+                                                   daddr, dport,
+                                                   in->ifindex);
+
+                       /* NOTE: we return listeners even if bound to
+                        * 0.0.0.0, those are filtered out in
+                        * xt_socket, since xt_TPROXY needs 0 bound
+                        * listeners too
+                        */
+                       break;
+               case NFT_LOOKUP_ESTABLISHED:
+                       sk = inet_lookup_established(net, &tcp_hashinfo,
+                                                   saddr, sport, daddr, dport,
+                                                   in->ifindex);
+                       break;
+               default:
+                       BUG();
+               }
+               break;
+       case IPPROTO_UDP:
+               sk = udp4_lib_lookup(net, saddr, sport, daddr, dport,
+                                    in->ifindex);
+               if (sk) {
+                       int connected = (sk->sk_state == TCP_ESTABLISHED);
+                       int wildcard = (inet_sk(sk)->inet_rcv_saddr == 0);
+
+                       /* NOTE: we return listeners even if bound to
+                        * 0.0.0.0, those are filtered out in
+                        * xt_socket, since xt_TPROXY needs 0 bound
+                        * listeners too
+                        */
+                       if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
+                           (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
+                               sock_put(sk);
+                               sk = NULL;
+                       }
+               }
+               break;
+       default:
+               WARN_ON(1);
+               sk = NULL;
+       }
+
+       pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n",
+                protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk);
+
+       return sk;
+}
+
+#ifdef XT_TPROXY_HAVE_IPV6
+static inline struct sock *
+nf_tproxy_get_sock_v6(struct net *net, const u8 protocol,
+                     const struct in6_addr *saddr, const struct in6_addr *daddr,
+                     const __be16 sport, const __be16 dport,
+                     const struct net_device *in,
+                     const enum nf_tproxy_lookup_t lookup_type)
+{
+       struct sock *sk;
+
+       switch (protocol) {
+       case IPPROTO_TCP:
+               switch (lookup_type) {
+               case NFT_LOOKUP_LISTENER:
+                       sk = inet6_lookup_listener(net, &tcp_hashinfo,
+                                                  saddr, sport,
+                                                  daddr, ntohs(dport),
+                                                  in->ifindex);
+
+                       /* NOTE: we return listeners even if bound to
+                        * 0.0.0.0, those are filtered out in
+                        * xt_socket, since xt_TPROXY needs 0 bound
+                        * listeners too
+                        */
+                       break;
+               case NFT_LOOKUP_ESTABLISHED:
+                       sk = __inet6_lookup_established(net, &tcp_hashinfo,
+                                                       saddr, sport, daddr, ntohs(dport),
+                                                       in->ifindex);
+                       break;
+               default:
+                       BUG();
+               }
+               break;
+       case IPPROTO_UDP:
+               sk = udp6_lib_lookup(net, saddr, sport, daddr, dport,
+                                    in->ifindex);
+               if (sk) {
+                       int connected = (sk->sk_state == TCP_ESTABLISHED);
+                       int wildcard = ipv6_addr_any(&inet6_sk(sk)->rcv_saddr);
+
+                       /* NOTE: we return listeners even if bound to
+                        * 0.0.0.0, those are filtered out in
+                        * xt_socket, since xt_TPROXY needs 0 bound
+                        * listeners too
+                        */
+                       if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
+                           (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
+                               sock_put(sk);
+                               sk = NULL;
+                       }
+               }
+               break;
+       default:
+               WARN_ON(1);
+               sk = NULL;
+       }
+
+       pr_debug("tproxy socket lookup: proto %u %pI6:%u -> %pI6:%u, lookup type: %d, sock %p\n",
+                protocol, saddr, ntohs(sport), daddr, ntohs(dport), lookup_type, sk);
+
+       return sk;
+}
+#endif
+
 /**
  * tproxy_handle_time_wait4 - handle IPv4 TCP TIME_WAIT reopen redirections
  * @skb:       The skb being processed.
@@ -117,6 +275,15 @@ tproxy_handle_time_wait4(struct sk_buff *skb, __be32 laddr, __be16 lport,
        return sk;
 }
 
+/* assign a socket to the skb -- consumes sk */
+static void
+nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
+{
+       skb_orphan(skb);
+       skb->sk = sk;
+       skb->destructor = sock_edemux;
+}
+
 static unsigned int
 tproxy_tg4(struct sk_buff *skb, __be32 laddr, __be16 lport,
           u_int32_t mark_mask, u_int32_t mark_value)
index 68ff29f608679f598f718e3018bdd8e516963c2a..fab6eea1bf382704b07449d88deaece0aa9d7d7e 100644 (file)
@@ -202,7 +202,7 @@ static int addrtype_mt_checkentry_v1(const struct xt_mtchk_param *par)
                        return -EINVAL;
                }
                if ((info->source | info->dest) >= XT_ADDRTYPE_PROHIBIT) {
-                       pr_err("ipv6 PROHIBT (THROW, NAT ..) matching not supported\n");
+                       pr_err("ipv6 PROHIBIT (THROW, NAT ..) matching not supported\n");
                        return -EINVAL;
                }
                if ((info->source | info->dest) & XT_ADDRTYPE_BROADCAST) {
index f8b71911037ab172f3df8f6a82cb8d22191ab1d6..06df2b9110f5f2b9376c19e34241c257b31e5f63 100644 (file)
 #include <net/icmp.h>
 #include <net/sock.h>
 #include <net/inet_sock.h>
-#include <net/netfilter/nf_tproxy_core.h>
 #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
 
 #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
 #define XT_SOCKET_HAVE_IPV6 1
 #include <linux/netfilter_ipv6/ip6_tables.h>
+#include <net/inet6_hashtables.h>
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
 #endif
 
@@ -101,6 +101,43 @@ extract_icmp4_fields(const struct sk_buff *skb,
        return 0;
 }
 
+/* "socket" match based redirection (no specific rule)
+ * ===================================================
+ *
+ * There are connections with dynamic endpoints (e.g. FTP data
+ * connection) that the user is unable to add explicit rules
+ * for. These are taken care of by a generic "socket" rule. It is
+ * assumed that the proxy application is trusted to open such
+ * connections without explicit iptables rule (except of course the
+ * generic 'socket' rule). In this case the following sockets are
+ * matched in preference order:
+ *
+ *   - match: if there's a fully established connection matching the
+ *     _packet_ tuple
+ *
+ *   - match: if there's a non-zero bound listener (possibly with a
+ *     non-local address) We don't accept zero-bound listeners, since
+ *     then local services could intercept traffic going through the
+ *     box.
+ */
+static struct sock *
+xt_socket_get_sock_v4(struct net *net, const u8 protocol,
+                     const __be32 saddr, const __be32 daddr,
+                     const __be16 sport, const __be16 dport,
+                     const struct net_device *in)
+{
+       switch (protocol) {
+       case IPPROTO_TCP:
+               return __inet_lookup(net, &tcp_hashinfo,
+                                    saddr, sport, daddr, dport,
+                                    in->ifindex);
+       case IPPROTO_UDP:
+               return udp4_lib_lookup(net, saddr, sport, daddr, dport,
+                                      in->ifindex);
+       }
+       return NULL;
+}
+
 static bool
 socket_match(const struct sk_buff *skb, struct xt_action_param *par,
             const struct xt_socket_mtinfo1 *info)
@@ -156,9 +193,9 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par,
 #endif
 
        if (!sk)
-               sk = nf_tproxy_get_sock_v4(dev_net(skb->dev), protocol,
+               sk = xt_socket_get_sock_v4(dev_net(skb->dev), protocol,
                                           saddr, daddr, sport, dport,
-                                          par->in, NFT_LOOKUP_ANY);
+                                          par->in);
        if (sk) {
                bool wildcard;
                bool transparent = true;
@@ -172,7 +209,7 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par,
 
                /* Ignore non-transparent sockets,
                   if XT_SOCKET_TRANSPARENT is used */
-               if (info && info->flags & XT_SOCKET_TRANSPARENT)
+               if (info->flags & XT_SOCKET_TRANSPARENT)
                        transparent = ((sk->sk_state != TCP_TIME_WAIT &&
                                        inet_sk(sk)->transparent) ||
                                       (sk->sk_state == TCP_TIME_WAIT &&
@@ -196,7 +233,11 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par,
 static bool
 socket_mt4_v0(const struct sk_buff *skb, struct xt_action_param *par)
 {
-       return socket_match(skb, par, NULL);
+       static struct xt_socket_mtinfo1 xt_info_v0 = {
+               .flags = 0,
+       };
+
+       return socket_match(skb, par, &xt_info_v0);
 }
 
 static bool
@@ -261,6 +302,25 @@ extract_icmp6_fields(const struct sk_buff *skb,
        return 0;
 }
 
+static struct sock *
+xt_socket_get_sock_v6(struct net *net, const u8 protocol,
+                     const struct in6_addr *saddr, const struct in6_addr *daddr,
+                     const __be16 sport, const __be16 dport,
+                     const struct net_device *in)
+{
+       switch (protocol) {
+       case IPPROTO_TCP:
+               return inet6_lookup(net, &tcp_hashinfo,
+                                   saddr, sport, daddr, dport,
+                                   in->ifindex);
+       case IPPROTO_UDP:
+               return udp6_lib_lookup(net, saddr, sport, daddr, dport,
+                                      in->ifindex);
+       }
+
+       return NULL;
+}
+
 static bool
 socket_mt6_v1_v2(const struct sk_buff *skb, struct xt_action_param *par)
 {
@@ -298,9 +358,9 @@ socket_mt6_v1_v2(const struct sk_buff *skb, struct xt_action_param *par)
        }
 
        if (!sk)
-               sk = nf_tproxy_get_sock_v6(dev_net(skb->dev), tproto,
+               sk = xt_socket_get_sock_v6(dev_net(skb->dev), tproto,
                                           saddr, daddr, sport, dport,
-                                          par->in, NFT_LOOKUP_ANY);
+                                          par->in);
        if (sk) {
                bool wildcard;
                bool transparent = true;
@@ -314,7 +374,7 @@ socket_mt6_v1_v2(const struct sk_buff *skb, struct xt_action_param *par)
 
                /* Ignore non-transparent sockets,
                   if XT_SOCKET_TRANSPARENT is used */
-               if (info && info->flags & XT_SOCKET_TRANSPARENT)
+               if (info->flags & XT_SOCKET_TRANSPARENT)
                        transparent = ((sk->sk_state != TCP_TIME_WAIT &&
                                        inet_sk(sk)->transparent) ||
                                       (sk->sk_state == TCP_TIME_WAIT &&
index c15042f987bd8f5697338b88cc77ed6553a0d609..a1100640495d3d3b106e850e9af6a9cc4e1ed547 100644 (file)
@@ -691,8 +691,8 @@ static int netlbl_cipsov4_remove_cb(struct netlbl_dom_map *entry, void *arg)
 {
        struct netlbl_domhsh_walk_arg *cb_arg = arg;
 
-       if (entry->type == NETLBL_NLTYPE_CIPSOV4 &&
-           entry->type_def.cipsov4->doi == cb_arg->doi)
+       if (entry->def.type == NETLBL_NLTYPE_CIPSOV4 &&
+           entry->def.cipso->doi == cb_arg->doi)
                return netlbl_domhsh_remove_entry(entry, cb_arg->audit_info);
 
        return 0;
index 6bb1d42f0fac04c02a69ee1790d40baf7af53824..85d842e6e43187998232441f5e2228244cb1cb95 100644 (file)
@@ -84,15 +84,15 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)
 #endif /* IPv6 */
 
        ptr = container_of(entry, struct netlbl_dom_map, rcu);
-       if (ptr->type == NETLBL_NLTYPE_ADDRSELECT) {
+       if (ptr->def.type == NETLBL_NLTYPE_ADDRSELECT) {
                netlbl_af4list_foreach_safe(iter4, tmp4,
-                                           &ptr->type_def.addrsel->list4) {
+                                           &ptr->def.addrsel->list4) {
                        netlbl_af4list_remove_entry(iter4);
                        kfree(netlbl_domhsh_addr4_entry(iter4));
                }
 #if IS_ENABLED(CONFIG_IPV6)
                netlbl_af6list_foreach_safe(iter6, tmp6,
-                                           &ptr->type_def.addrsel->list6) {
+                                           &ptr->def.addrsel->list6) {
                        netlbl_af6list_remove_entry(iter6);
                        kfree(netlbl_domhsh_addr6_entry(iter6));
                }
@@ -213,21 +213,21 @@ static void netlbl_domhsh_audit_add(struct netlbl_dom_map *entry,
                if (addr4 != NULL) {
                        struct netlbl_domaddr4_map *map4;
                        map4 = netlbl_domhsh_addr4_entry(addr4);
-                       type = map4->type;
-                       cipsov4 = map4->type_def.cipsov4;
+                       type = map4->def.type;
+                       cipsov4 = map4->def.cipso;
                        netlbl_af4list_audit_addr(audit_buf, 0, NULL,
                                                  addr4->addr, addr4->mask);
 #if IS_ENABLED(CONFIG_IPV6)
                } else if (addr6 != NULL) {
                        struct netlbl_domaddr6_map *map6;
                        map6 = netlbl_domhsh_addr6_entry(addr6);
-                       type = map6->type;
+                       type = map6->def.type;
                        netlbl_af6list_audit_addr(audit_buf, 0, NULL,
                                                  &addr6->addr, &addr6->mask);
 #endif /* IPv6 */
                } else {
-                       type = entry->type;
-                       cipsov4 = entry->type_def.cipsov4;
+                       type = entry->def.type;
+                       cipsov4 = entry->def.cipso;
                }
                switch (type) {
                case NETLBL_NLTYPE_UNLABELED:
@@ -265,26 +265,25 @@ static int netlbl_domhsh_validate(const struct netlbl_dom_map *entry)
        if (entry == NULL)
                return -EINVAL;
 
-       switch (entry->type) {
+       switch (entry->def.type) {
        case NETLBL_NLTYPE_UNLABELED:
-               if (entry->type_def.cipsov4 != NULL ||
-                   entry->type_def.addrsel != NULL)
+               if (entry->def.cipso != NULL || entry->def.addrsel != NULL)
                        return -EINVAL;
                break;
        case NETLBL_NLTYPE_CIPSOV4:
-               if (entry->type_def.cipsov4 == NULL)
+               if (entry->def.cipso == NULL)
                        return -EINVAL;
                break;
        case NETLBL_NLTYPE_ADDRSELECT:
-               netlbl_af4list_foreach(iter4, &entry->type_def.addrsel->list4) {
+               netlbl_af4list_foreach(iter4, &entry->def.addrsel->list4) {
                        map4 = netlbl_domhsh_addr4_entry(iter4);
-                       switch (map4->type) {
+                       switch (map4->def.type) {
                        case NETLBL_NLTYPE_UNLABELED:
-                               if (map4->type_def.cipsov4 != NULL)
+                               if (map4->def.cipso != NULL)
                                        return -EINVAL;
                                break;
                        case NETLBL_NLTYPE_CIPSOV4:
-                               if (map4->type_def.cipsov4 == NULL)
+                               if (map4->def.cipso == NULL)
                                        return -EINVAL;
                                break;
                        default:
@@ -292,9 +291,9 @@ static int netlbl_domhsh_validate(const struct netlbl_dom_map *entry)
                        }
                }
 #if IS_ENABLED(CONFIG_IPV6)
-               netlbl_af6list_foreach(iter6, &entry->type_def.addrsel->list6) {
+               netlbl_af6list_foreach(iter6, &entry->def.addrsel->list6) {
                        map6 = netlbl_domhsh_addr6_entry(iter6);
-                       switch (map6->type) {
+                       switch (map6->def.type) {
                        case NETLBL_NLTYPE_UNLABELED:
                                break;
                        default:
@@ -402,32 +401,31 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
                        rcu_assign_pointer(netlbl_domhsh_def, entry);
                }
 
-               if (entry->type == NETLBL_NLTYPE_ADDRSELECT) {
+               if (entry->def.type == NETLBL_NLTYPE_ADDRSELECT) {
                        netlbl_af4list_foreach_rcu(iter4,
-                                              &entry->type_def.addrsel->list4)
+                                                  &entry->def.addrsel->list4)
                                netlbl_domhsh_audit_add(entry, iter4, NULL,
                                                        ret_val, audit_info);
 #if IS_ENABLED(CONFIG_IPV6)
                        netlbl_af6list_foreach_rcu(iter6,
-                                              &entry->type_def.addrsel->list6)
+                                                  &entry->def.addrsel->list6)
                                netlbl_domhsh_audit_add(entry, NULL, iter6,
                                                        ret_val, audit_info);
 #endif /* IPv6 */
                } else
                        netlbl_domhsh_audit_add(entry, NULL, NULL,
                                                ret_val, audit_info);
-       } else if (entry_old->type == NETLBL_NLTYPE_ADDRSELECT &&
-                  entry->type == NETLBL_NLTYPE_ADDRSELECT) {
+       } else if (entry_old->def.type == NETLBL_NLTYPE_ADDRSELECT &&
+                  entry->def.type == NETLBL_NLTYPE_ADDRSELECT) {
                struct list_head *old_list4;
                struct list_head *old_list6;
 
-               old_list4 = &entry_old->type_def.addrsel->list4;
-               old_list6 = &entry_old->type_def.addrsel->list6;
+               old_list4 = &entry_old->def.addrsel->list4;
+               old_list6 = &entry_old->def.addrsel->list6;
 
                /* we only allow the addition of address selectors if all of
                 * the selectors do not exist in the existing domain map */
-               netlbl_af4list_foreach_rcu(iter4,
-                                          &entry->type_def.addrsel->list4)
+               netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4)
                        if (netlbl_af4list_search_exact(iter4->addr,
                                                        iter4->mask,
                                                        old_list4)) {
@@ -435,8 +433,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
                                goto add_return;
                        }
 #if IS_ENABLED(CONFIG_IPV6)
-               netlbl_af6list_foreach_rcu(iter6,
-                                          &entry->type_def.addrsel->list6)
+               netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6)
                        if (netlbl_af6list_search_exact(&iter6->addr,
                                                        &iter6->mask,
                                                        old_list6)) {
@@ -446,7 +443,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
 #endif /* IPv6 */
 
                netlbl_af4list_foreach_safe(iter4, tmp4,
-                                           &entry->type_def.addrsel->list4) {
+                                           &entry->def.addrsel->list4) {
                        netlbl_af4list_remove_entry(iter4);
                        iter4->valid = 1;
                        ret_val = netlbl_af4list_add(iter4, old_list4);
@@ -457,7 +454,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
                }
 #if IS_ENABLED(CONFIG_IPV6)
                netlbl_af6list_foreach_safe(iter6, tmp6,
-                                           &entry->type_def.addrsel->list6) {
+                                           &entry->def.addrsel->list6) {
                        netlbl_af6list_remove_entry(iter6);
                        iter6->valid = 1;
                        ret_val = netlbl_af6list_add(iter6, old_list6);
@@ -538,18 +535,18 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
                struct netlbl_af4list *iter4;
                struct netlbl_domaddr4_map *map4;
 
-               switch (entry->type) {
+               switch (entry->def.type) {
                case NETLBL_NLTYPE_ADDRSELECT:
                        netlbl_af4list_foreach_rcu(iter4,
-                                            &entry->type_def.addrsel->list4) {
+                                            &entry->def.addrsel->list4) {
                                map4 = netlbl_domhsh_addr4_entry(iter4);
-                               cipso_v4_doi_putdef(map4->type_def.cipsov4);
+                               cipso_v4_doi_putdef(map4->def.cipso);
                        }
                        /* no need to check the IPv6 list since we currently
                         * support only unlabeled protocols for IPv6 */
                        break;
                case NETLBL_NLTYPE_CIPSOV4:
-                       cipso_v4_doi_putdef(entry->type_def.cipsov4);
+                       cipso_v4_doi_putdef(entry->def.cipso);
                        break;
                }
                call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
@@ -590,20 +587,21 @@ int netlbl_domhsh_remove_af4(const char *domain,
                entry_map = netlbl_domhsh_search(domain);
        else
                entry_map = netlbl_domhsh_search_def(domain);
-       if (entry_map == NULL || entry_map->type != NETLBL_NLTYPE_ADDRSELECT)
+       if (entry_map == NULL ||
+           entry_map->def.type != NETLBL_NLTYPE_ADDRSELECT)
                goto remove_af4_failure;
 
        spin_lock(&netlbl_domhsh_lock);
        entry_addr = netlbl_af4list_remove(addr->s_addr, mask->s_addr,
-                                          &entry_map->type_def.addrsel->list4);
+                                          &entry_map->def.addrsel->list4);
        spin_unlock(&netlbl_domhsh_lock);
 
        if (entry_addr == NULL)
                goto remove_af4_failure;
-       netlbl_af4list_foreach_rcu(iter4, &entry_map->type_def.addrsel->list4)
+       netlbl_af4list_foreach_rcu(iter4, &entry_map->def.addrsel->list4)
                goto remove_af4_single_addr;
 #if IS_ENABLED(CONFIG_IPV6)
-       netlbl_af6list_foreach_rcu(iter6, &entry_map->type_def.addrsel->list6)
+       netlbl_af6list_foreach_rcu(iter6, &entry_map->def.addrsel->list6)
                goto remove_af4_single_addr;
 #endif /* IPv6 */
        /* the domain mapping is empty so remove it from the mapping table */
@@ -616,7 +614,7 @@ remove_af4_single_addr:
         * shouldn't be a problem */
        synchronize_rcu();
        entry = netlbl_domhsh_addr4_entry(entry_addr);
-       cipso_v4_doi_putdef(entry->type_def.cipsov4);
+       cipso_v4_doi_putdef(entry->def.cipso);
        kfree(entry);
        return 0;
 
@@ -693,8 +691,8 @@ struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain)
  * responsible for ensuring that rcu_read_[un]lock() is called.
  *
  */
-struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
-                                                      __be32 addr)
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af4(const char *domain,
+                                                    __be32 addr)
 {
        struct netlbl_dom_map *dom_iter;
        struct netlbl_af4list *addr_iter;
@@ -702,15 +700,13 @@ struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
        dom_iter = netlbl_domhsh_search_def(domain);
        if (dom_iter == NULL)
                return NULL;
-       if (dom_iter->type != NETLBL_NLTYPE_ADDRSELECT)
-               return NULL;
 
-       addr_iter = netlbl_af4list_search(addr,
-                                         &dom_iter->type_def.addrsel->list4);
+       if (dom_iter->def.type != NETLBL_NLTYPE_ADDRSELECT)
+               return &dom_iter->def;
+       addr_iter = netlbl_af4list_search(addr, &dom_iter->def.addrsel->list4);
        if (addr_iter == NULL)
                return NULL;
-
-       return netlbl_domhsh_addr4_entry(addr_iter);
+       return &(netlbl_domhsh_addr4_entry(addr_iter)->def);
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
@@ -725,7 +721,7 @@ struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
  * responsible for ensuring that rcu_read_[un]lock() is called.
  *
  */
-struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af6(const char *domain,
                                                   const struct in6_addr *addr)
 {
        struct netlbl_dom_map *dom_iter;
@@ -734,15 +730,13 @@ struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
        dom_iter = netlbl_domhsh_search_def(domain);
        if (dom_iter == NULL)
                return NULL;
-       if (dom_iter->type != NETLBL_NLTYPE_ADDRSELECT)
-               return NULL;
 
-       addr_iter = netlbl_af6list_search(addr,
-                                         &dom_iter->type_def.addrsel->list6);
+       if (dom_iter->def.type != NETLBL_NLTYPE_ADDRSELECT)
+               return &dom_iter->def;
+       addr_iter = netlbl_af6list_search(addr, &dom_iter->def.addrsel->list6);
        if (addr_iter == NULL)
                return NULL;
-
-       return netlbl_domhsh_addr6_entry(addr_iter);
+       return &(netlbl_domhsh_addr6_entry(addr_iter)->def);
 }
 #endif /* IPv6 */
 
index 90872c4ca30f4ba9aad89089eff5dadfdff42717..b9be0eed89801ab194b8f6a97899e7bbf9c50ec3 100644 (file)
 #define NETLBL_DOMHSH_BITSIZE       7
 
 /* Domain mapping definition structures */
+struct netlbl_domaddr_map {
+       struct list_head list4;
+       struct list_head list6;
+};
+struct netlbl_dommap_def {
+       u32 type;
+       union {
+               struct netlbl_domaddr_map *addrsel;
+               struct cipso_v4_doi *cipso;
+       };
+};
 #define netlbl_domhsh_addr4_entry(iter) \
        container_of(iter, struct netlbl_domaddr4_map, list)
 struct netlbl_domaddr4_map {
-       u32 type;
-       union {
-               struct cipso_v4_doi *cipsov4;
-       } type_def;
+       struct netlbl_dommap_def def;
 
        struct netlbl_af4list list;
 };
 #define netlbl_domhsh_addr6_entry(iter) \
        container_of(iter, struct netlbl_domaddr6_map, list)
 struct netlbl_domaddr6_map {
-       u32 type;
-
-       /* NOTE: no 'type_def' union needed at present since we don't currently
-        *       support any IPv6 labeling protocols */
+       struct netlbl_dommap_def def;
 
        struct netlbl_af6list list;
 };
-struct netlbl_domaddr_map {
-       struct list_head list4;
-       struct list_head list6;
-};
+
 struct netlbl_dom_map {
        char *domain;
-       u32 type;
-       union {
-               struct cipso_v4_doi *cipsov4;
-               struct netlbl_domaddr_map *addrsel;
-       } type_def;
+       struct netlbl_dommap_def def;
 
        u32 valid;
        struct list_head list;
@@ -97,16 +95,16 @@ int netlbl_domhsh_remove_af4(const char *domain,
 int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
 int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info);
 struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain);
-struct netlbl_domaddr4_map *netlbl_domhsh_getentry_af4(const char *domain,
-                                                      __be32 addr);
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af4(const char *domain,
+                                                    __be32 addr);
+#if IS_ENABLED(CONFIG_IPV6)
+struct netlbl_dommap_def *netlbl_domhsh_getentry_af6(const char *domain,
+                                                  const struct in6_addr *addr);
+#endif /* IPv6 */
+
 int netlbl_domhsh_walk(u32 *skip_bkt,
                     u32 *skip_chain,
                     int (*callback) (struct netlbl_dom_map *entry, void *arg),
                     void *cb_arg);
 
-#if IS_ENABLED(CONFIG_IPV6)
-struct netlbl_domaddr6_map *netlbl_domhsh_getentry_af6(const char *domain,
-                                                 const struct in6_addr *addr);
-#endif /* IPv6 */
-
 #endif
index 7c94aedd0912777d6d0956f0f5b048f0f62ab97d..96a458e12f60ada2186c08ebbafe22c6e68ba06e 100644 (file)
@@ -122,7 +122,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
        }
 
        if (addr == NULL && mask == NULL)
-               entry->type = NETLBL_NLTYPE_UNLABELED;
+               entry->def.type = NETLBL_NLTYPE_UNLABELED;
        else if (addr != NULL && mask != NULL) {
                addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
                if (addrmap == NULL)
@@ -137,7 +137,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
                        map4 = kzalloc(sizeof(*map4), GFP_ATOMIC);
                        if (map4 == NULL)
                                goto cfg_unlbl_map_add_failure;
-                       map4->type = NETLBL_NLTYPE_UNLABELED;
+                       map4->def.type = NETLBL_NLTYPE_UNLABELED;
                        map4->list.addr = addr4->s_addr & mask4->s_addr;
                        map4->list.mask = mask4->s_addr;
                        map4->list.valid = 1;
@@ -154,7 +154,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
                        map6 = kzalloc(sizeof(*map6), GFP_ATOMIC);
                        if (map6 == NULL)
                                goto cfg_unlbl_map_add_failure;
-                       map6->type = NETLBL_NLTYPE_UNLABELED;
+                       map6->def.type = NETLBL_NLTYPE_UNLABELED;
                        map6->list.addr = *addr6;
                        map6->list.addr.s6_addr32[0] &= mask6->s6_addr32[0];
                        map6->list.addr.s6_addr32[1] &= mask6->s6_addr32[1];
@@ -174,8 +174,8 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
                        break;
                }
 
-               entry->type_def.addrsel = addrmap;
-               entry->type = NETLBL_NLTYPE_ADDRSELECT;
+               entry->def.addrsel = addrmap;
+               entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
        } else {
                ret_val = -EINVAL;
                goto cfg_unlbl_map_add_failure;
@@ -355,8 +355,8 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
        }
 
        if (addr == NULL && mask == NULL) {
-               entry->type_def.cipsov4 = doi_def;
-               entry->type = NETLBL_NLTYPE_CIPSOV4;
+               entry->def.cipso = doi_def;
+               entry->def.type = NETLBL_NLTYPE_CIPSOV4;
        } else if (addr != NULL && mask != NULL) {
                addrmap = kzalloc(sizeof(*addrmap), GFP_ATOMIC);
                if (addrmap == NULL)
@@ -367,8 +367,8 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
                addrinfo = kzalloc(sizeof(*addrinfo), GFP_ATOMIC);
                if (addrinfo == NULL)
                        goto out_addrinfo;
-               addrinfo->type_def.cipsov4 = doi_def;
-               addrinfo->type = NETLBL_NLTYPE_CIPSOV4;
+               addrinfo->def.cipso = doi_def;
+               addrinfo->def.type = NETLBL_NLTYPE_CIPSOV4;
                addrinfo->list.addr = addr->s_addr & mask->s_addr;
                addrinfo->list.mask = mask->s_addr;
                addrinfo->list.valid = 1;
@@ -376,8 +376,8 @@ int netlbl_cfg_cipsov4_map_add(u32 doi,
                if (ret_val != 0)
                        goto cfg_cipsov4_map_add_failure;
 
-               entry->type_def.addrsel = addrmap;
-               entry->type = NETLBL_NLTYPE_ADDRSELECT;
+               entry->def.addrsel = addrmap;
+               entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
        } else {
                ret_val = -EINVAL;
                goto out_addrmap;
@@ -657,14 +657,14 @@ int netlbl_sock_setattr(struct sock *sk,
        }
        switch (family) {
        case AF_INET:
-               switch (dom_entry->type) {
+               switch (dom_entry->def.type) {
                case NETLBL_NLTYPE_ADDRSELECT:
                        ret_val = -EDESTADDRREQ;
                        break;
                case NETLBL_NLTYPE_CIPSOV4:
                        ret_val = cipso_v4_sock_setattr(sk,
-                                                   dom_entry->type_def.cipsov4,
-                                                   secattr);
+                                                       dom_entry->def.cipso,
+                                                       secattr);
                        break;
                case NETLBL_NLTYPE_UNLABELED:
                        ret_val = 0;
@@ -754,23 +754,22 @@ int netlbl_conn_setattr(struct sock *sk,
 {
        int ret_val;
        struct sockaddr_in *addr4;
-       struct netlbl_domaddr4_map *af4_entry;
+       struct netlbl_dommap_def *entry;
 
        rcu_read_lock();
        switch (addr->sa_family) {
        case AF_INET:
                addr4 = (struct sockaddr_in *)addr;
-               af4_entry = netlbl_domhsh_getentry_af4(secattr->domain,
-                                                      addr4->sin_addr.s_addr);
-               if (af4_entry == NULL) {
+               entry = netlbl_domhsh_getentry_af4(secattr->domain,
+                                                  addr4->sin_addr.s_addr);
+               if (entry == NULL) {
                        ret_val = -ENOENT;
                        goto conn_setattr_return;
                }
-               switch (af4_entry->type) {
+               switch (entry->type) {
                case NETLBL_NLTYPE_CIPSOV4:
                        ret_val = cipso_v4_sock_setattr(sk,
-                                                  af4_entry->type_def.cipsov4,
-                                                  secattr);
+                                                       entry->cipso, secattr);
                        break;
                case NETLBL_NLTYPE_UNLABELED:
                        /* just delete the protocols we support for right now
@@ -812,36 +811,21 @@ int netlbl_req_setattr(struct request_sock *req,
                       const struct netlbl_lsm_secattr *secattr)
 {
        int ret_val;
-       struct netlbl_dom_map *dom_entry;
-       struct netlbl_domaddr4_map *af4_entry;
-       u32 proto_type;
-       struct cipso_v4_doi *proto_cv4;
+       struct netlbl_dommap_def *entry;
 
        rcu_read_lock();
-       dom_entry = netlbl_domhsh_getentry(secattr->domain);
-       if (dom_entry == NULL) {
-               ret_val = -ENOENT;
-               goto req_setattr_return;
-       }
        switch (req->rsk_ops->family) {
        case AF_INET:
-               if (dom_entry->type == NETLBL_NLTYPE_ADDRSELECT) {
-                       struct inet_request_sock *req_inet = inet_rsk(req);
-                       af4_entry = netlbl_domhsh_getentry_af4(secattr->domain,
-                                                           req_inet->rmt_addr);
-                       if (af4_entry == NULL) {
-                               ret_val = -ENOENT;
-                               goto req_setattr_return;
-                       }
-                       proto_type = af4_entry->type;
-                       proto_cv4 = af4_entry->type_def.cipsov4;
-               } else {
-                       proto_type = dom_entry->type;
-                       proto_cv4 = dom_entry->type_def.cipsov4;
+               entry = netlbl_domhsh_getentry_af4(secattr->domain,
+                                                  inet_rsk(req)->rmt_addr);
+               if (entry == NULL) {
+                       ret_val = -ENOENT;
+                       goto req_setattr_return;
                }
-               switch (proto_type) {
+               switch (entry->type) {
                case NETLBL_NLTYPE_CIPSOV4:
-                       ret_val = cipso_v4_req_setattr(req, proto_cv4, secattr);
+                       ret_val = cipso_v4_req_setattr(req,
+                                                      entry->cipso, secattr);
                        break;
                case NETLBL_NLTYPE_UNLABELED:
                        /* just delete the protocols we support for right now
@@ -899,23 +883,21 @@ int netlbl_skbuff_setattr(struct sk_buff *skb,
 {
        int ret_val;
        struct iphdr *hdr4;
-       struct netlbl_domaddr4_map *af4_entry;
+       struct netlbl_dommap_def *entry;
 
        rcu_read_lock();
        switch (family) {
        case AF_INET:
                hdr4 = ip_hdr(skb);
-               af4_entry = netlbl_domhsh_getentry_af4(secattr->domain,
-                                                      hdr4->daddr);
-               if (af4_entry == NULL) {
+               entry = netlbl_domhsh_getentry_af4(secattr->domain,hdr4->daddr);
+               if (entry == NULL) {
                        ret_val = -ENOENT;
                        goto skbuff_setattr_return;
                }
-               switch (af4_entry->type) {
+               switch (entry->type) {
                case NETLBL_NLTYPE_CIPSOV4:
-                       ret_val = cipso_v4_skbuff_setattr(skb,
-                                                  af4_entry->type_def.cipsov4,
-                                                  secattr);
+                       ret_val = cipso_v4_skbuff_setattr(skb, entry->cipso,
+                                                         secattr);
                        break;
                case NETLBL_NLTYPE_UNLABELED:
                        /* just delete the protocols we support for right now
index c5384ffc61469a422f1e5f4a9519131d95b56236..dd1c37d7acbcfa6d126a8056360b8d6a56985035 100644 (file)
@@ -104,7 +104,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                ret_val = -ENOMEM;
                goto add_failure;
        }
-       entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
+       entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
        if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
                size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
                entry->domain = kmalloc(tmp_size, GFP_KERNEL);
@@ -116,12 +116,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                            info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
        }
 
-       /* NOTE: internally we allow/use a entry->type value of
+       /* NOTE: internally we allow/use a entry->def.type value of
         *       NETLBL_NLTYPE_ADDRSELECT but we don't currently allow users
         *       to pass that as a protocol value because we need to know the
         *       "real" protocol */
 
-       switch (entry->type) {
+       switch (entry->def.type) {
        case NETLBL_NLTYPE_UNLABELED:
                break;
        case NETLBL_NLTYPE_CIPSOV4:
@@ -132,7 +132,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                cipsov4 = cipso_v4_doi_getdef(tmp_val);
                if (cipsov4 == NULL)
                        goto add_failure;
-               entry->type_def.cipsov4 = cipsov4;
+               entry->def.cipso = cipsov4;
                break;
        default:
                goto add_failure;
@@ -172,9 +172,9 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                map->list.addr = addr->s_addr & mask->s_addr;
                map->list.mask = mask->s_addr;
                map->list.valid = 1;
-               map->type = entry->type;
+               map->def.type = entry->def.type;
                if (cipsov4)
-                       map->type_def.cipsov4 = cipsov4;
+                       map->def.cipso = cipsov4;
 
                ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
                if (ret_val != 0) {
@@ -182,8 +182,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                        goto add_failure;
                }
 
-               entry->type = NETLBL_NLTYPE_ADDRSELECT;
-               entry->type_def.addrsel = addrmap;
+               entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
+               entry->def.addrsel = addrmap;
 #if IS_ENABLED(CONFIG_IPV6)
        } else if (info->attrs[NLBL_MGMT_A_IPV6ADDR]) {
                struct in6_addr *addr;
@@ -223,7 +223,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                map->list.addr.s6_addr32[3] &= mask->s6_addr32[3];
                map->list.mask = *mask;
                map->list.valid = 1;
-               map->type = entry->type;
+               map->def.type = entry->def.type;
 
                ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
                if (ret_val != 0) {
@@ -231,8 +231,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
                        goto add_failure;
                }
 
-               entry->type = NETLBL_NLTYPE_ADDRSELECT;
-               entry->type_def.addrsel = addrmap;
+               entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
+               entry->def.addrsel = addrmap;
 #endif /* IPv6 */
        }
 
@@ -281,14 +281,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
                        return ret_val;
        }
 
-       switch (entry->type) {
+       switch (entry->def.type) {
        case NETLBL_NLTYPE_ADDRSELECT:
                nla_a = nla_nest_start(skb, NLBL_MGMT_A_SELECTORLIST);
                if (nla_a == NULL)
                        return -ENOMEM;
 
-               netlbl_af4list_foreach_rcu(iter4,
-                                          &entry->type_def.addrsel->list4) {
+               netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) {
                        struct netlbl_domaddr4_map *map4;
                        struct in_addr addr_struct;
 
@@ -310,13 +309,13 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
                                return ret_val;
                        map4 = netlbl_domhsh_addr4_entry(iter4);
                        ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
-                                             map4->type);
+                                             map4->def.type);
                        if (ret_val != 0)
                                return ret_val;
-                       switch (map4->type) {
+                       switch (map4->def.type) {
                        case NETLBL_NLTYPE_CIPSOV4:
                                ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI,
-                                                 map4->type_def.cipsov4->doi);
+                                                     map4->def.cipso->doi);
                                if (ret_val != 0)
                                        return ret_val;
                                break;
@@ -325,8 +324,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
                        nla_nest_end(skb, nla_b);
                }
 #if IS_ENABLED(CONFIG_IPV6)
-               netlbl_af6list_foreach_rcu(iter6,
-                                          &entry->type_def.addrsel->list6) {
+               netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) {
                        struct netlbl_domaddr6_map *map6;
 
                        nla_b = nla_nest_start(skb, NLBL_MGMT_A_ADDRSELECTOR);
@@ -345,7 +343,7 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
                                return ret_val;
                        map6 = netlbl_domhsh_addr6_entry(iter6);
                        ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL,
-                                             map6->type);
+                                             map6->def.type);
                        if (ret_val != 0)
                                return ret_val;
 
@@ -356,14 +354,14 @@ static int netlbl_mgmt_listentry(struct sk_buff *skb,
                nla_nest_end(skb, nla_a);
                break;
        case NETLBL_NLTYPE_UNLABELED:
-               ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, entry->type);
+               ret_val = nla_put_u32(skb,NLBL_MGMT_A_PROTOCOL,entry->def.type);
                break;
        case NETLBL_NLTYPE_CIPSOV4:
-               ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, entry->type);
+               ret_val = nla_put_u32(skb,NLBL_MGMT_A_PROTOCOL,entry->def.type);
                if (ret_val != 0)
                        return ret_val;
                ret_val = nla_put_u32(skb, NLBL_MGMT_A_CV4DOI,
-                                     entry->type_def.cipsov4->doi);
+                                     entry->def.cipso->doi);
                break;
        }
 
index af3531926ee0c0339c6cc73725c50a1d7ec2a18d..8f0897407a2cf950240082cfde9ab07969f96404 100644 (file)
@@ -1541,7 +1541,7 @@ int __init netlbl_unlabel_defconf(void)
        entry = kzalloc(sizeof(*entry), GFP_KERNEL);
        if (entry == NULL)
                return -ENOMEM;
-       entry->type = NETLBL_NLTYPE_UNLABELED;
+       entry->def.type = NETLBL_NLTYPE_UNLABELED;
        ret_val = netlbl_domhsh_add_default(entry, &audit_info);
        if (ret_val != 0)
                return ret_val;
index 0c61b59175dca5d9276c0fa65489d22cec39b435..a17dda1bbee0704935c92c7d265268fb73c724a1 100644 (file)
@@ -294,14 +294,14 @@ static void **alloc_pg_vec(struct netlink_sock *nlk,
 {
        unsigned int block_nr = req->nm_block_nr;
        unsigned int i;
-       void **pg_vec, *ptr;
+       void **pg_vec;
 
        pg_vec = kcalloc(block_nr, sizeof(void *), GFP_KERNEL);
        if (pg_vec == NULL)
                return NULL;
 
        for (i = 0; i < block_nr; i++) {
-               pg_vec[i] = ptr = alloc_one_pg_vec_page(order);
+               pg_vec[i] = alloc_one_pg_vec_page(order);
                if (pg_vec[i] == NULL)
                        goto err1;
        }
@@ -595,7 +595,7 @@ static unsigned int netlink_poll(struct file *file, struct socket *sock,
                 * for dumps is performed here. A dump is allowed to continue
                 * if at least half the ring is unused.
                 */
-               while (nlk->cb != NULL && netlink_dump_space(nlk)) {
+               while (nlk->cb_running && netlink_dump_space(nlk)) {
                        err = netlink_dump(sk);
                        if (err < 0) {
                                sk->sk_err = err;
@@ -802,18 +802,6 @@ static void netlink_ring_set_copied(struct sock *sk, struct sk_buff *skb)
 #define netlink_mmap_sendmsg(sk, msg, dst_portid, dst_group, siocb)    0
 #endif /* CONFIG_NETLINK_MMAP */
 
-static void netlink_destroy_callback(struct netlink_callback *cb)
-{
-       kfree_skb(cb->skb);
-       kfree(cb);
-}
-
-static void netlink_consume_callback(struct netlink_callback *cb)
-{
-       consume_skb(cb->skb);
-       kfree(cb);
-}
-
 static void netlink_skb_destructor(struct sk_buff *skb)
 {
 #ifdef CONFIG_NETLINK_MMAP
@@ -872,12 +860,12 @@ static void netlink_sock_destruct(struct sock *sk)
 {
        struct netlink_sock *nlk = nlk_sk(sk);
 
-       if (nlk->cb) {
-               if (nlk->cb->done)
-                       nlk->cb->done(nlk->cb);
+       if (nlk->cb_running) {
+               if (nlk->cb.done)
+                       nlk->cb.done(&nlk->cb);
 
-               module_put(nlk->cb->module);
-               netlink_destroy_callback(nlk->cb);
+               module_put(nlk->cb.module);
+               kfree_skb(nlk->cb.skb);
        }
 
        skb_queue_purge(&sk->sk_receive_queue);
@@ -2350,7 +2338,8 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
 
        skb_free_datagram(sk, skb);
 
-       if (nlk->cb && atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) {
+       if (nlk->cb_running &&
+           atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) {
                ret = netlink_dump(sk);
                if (ret) {
                        sk->sk_err = ret;
@@ -2566,13 +2555,12 @@ static int netlink_dump(struct sock *sk)
        int alloc_size;
 
        mutex_lock(nlk->cb_mutex);
-
-       cb = nlk->cb;
-       if (cb == NULL) {
+       if (!nlk->cb_running) {
                err = -EINVAL;
                goto errout_skb;
        }
 
+       cb = &nlk->cb;
        alloc_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
 
        if (!netlink_rx_is_mmaped(sk) &&
@@ -2610,11 +2598,11 @@ static int netlink_dump(struct sock *sk)
 
        if (cb->done)
                cb->done(cb);
-       nlk->cb = NULL;
-       mutex_unlock(nlk->cb_mutex);
 
+       nlk->cb_running = false;
+       mutex_unlock(nlk->cb_mutex);
        module_put(cb->module);
-       netlink_consume_callback(cb);
+       consume_skb(cb->skb);
        return 0;
 
 errout_skb:
@@ -2632,59 +2620,51 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
        struct netlink_sock *nlk;
        int ret;
 
-       cb = kzalloc(sizeof(*cb), GFP_KERNEL);
-       if (cb == NULL)
-               return -ENOBUFS;
-
        /* Memory mapped dump requests need to be copied to avoid looping
         * on the pending state in netlink_mmap_sendmsg() while the CB hold
         * a reference to the skb.
         */
        if (netlink_skb_is_mmaped(skb)) {
                skb = skb_copy(skb, GFP_KERNEL);
-               if (skb == NULL) {
-                       kfree(cb);
+               if (skb == NULL)
                        return -ENOBUFS;
-               }
        } else
                atomic_inc(&skb->users);
 
-       cb->dump = control->dump;
-       cb->done = control->done;
-       cb->nlh = nlh;
-       cb->data = control->data;
-       cb->module = control->module;
-       cb->min_dump_alloc = control->min_dump_alloc;
-       cb->skb = skb;
-
        sk = netlink_lookup(sock_net(ssk), ssk->sk_protocol, NETLINK_CB(skb).portid);
        if (sk == NULL) {
-               netlink_destroy_callback(cb);
-               return -ECONNREFUSED;
+               ret = -ECONNREFUSED;
+               goto error_free;
        }
-       nlk = nlk_sk(sk);
 
+       nlk = nlk_sk(sk);
        mutex_lock(nlk->cb_mutex);
        /* A dump is in progress... */
-       if (nlk->cb) {
-               mutex_unlock(nlk->cb_mutex);
-               netlink_destroy_callback(cb);
+       if (nlk->cb_running) {
                ret = -EBUSY;
-               goto out;
+               goto error_unlock;
        }
        /* add reference of module which cb->dump belongs to */
-       if (!try_module_get(cb->module)) {
-               mutex_unlock(nlk->cb_mutex);
-               netlink_destroy_callback(cb);
+       if (!try_module_get(control->module)) {
                ret = -EPROTONOSUPPORT;
-               goto out;
+               goto error_unlock;
        }
 
-       nlk->cb = cb;
+       cb = &nlk->cb;
+       memset(cb, 0, sizeof(*cb));
+       cb->dump = control->dump;
+       cb->done = control->done;
+       cb->nlh = nlh;
+       cb->data = control->data;
+       cb->module = control->module;
+       cb->min_dump_alloc = control->min_dump_alloc;
+       cb->skb = skb;
+
+       nlk->cb_running = true;
+
        mutex_unlock(nlk->cb_mutex);
 
        ret = netlink_dump(sk);
-out:
        sock_put(sk);
 
        if (ret)
@@ -2694,6 +2674,13 @@ out:
         * signal not to send ACK even if it was requested.
         */
        return -EINTR;
+
+error_unlock:
+       sock_put(sk);
+       mutex_unlock(nlk->cb_mutex);
+error_free:
+       kfree_skb(skb);
+       return ret;
 }
 EXPORT_SYMBOL(__netlink_dump_start);
 
@@ -2916,14 +2903,14 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
                struct sock *s = v;
                struct netlink_sock *nlk = nlk_sk(s);
 
-               seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %pK %-8d %-8d %-8lu\n",
+               seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d %-8lu\n",
                           s,
                           s->sk_protocol,
                           nlk->portid,
                           nlk->groups ? (u32)nlk->groups[0] : 0,
                           sk_rmem_alloc_get(s),
                           sk_wmem_alloc_get(s),
-                          nlk->cb,
+                          nlk->cb_running,
                           atomic_read(&s->sk_refcnt),
                           atomic_read(&s->sk_drops),
                           sock_i_ino(s)
index eaa88d187cdcebc65152296213c3a82aaa6ab5ad..acbd774eeb7c5afd568d8eb9aa375ecc81949793 100644 (file)
@@ -32,7 +32,8 @@ struct netlink_sock {
        unsigned long           *groups;
        unsigned long           state;
        wait_queue_head_t       wait;
-       struct netlink_callback *cb;
+       bool                    cb_running;
+       struct netlink_callback cb;
        struct mutex            *cb_mutex;
        struct mutex            cb_def_mutex;
        void                    (*netlink_rcv)(struct sk_buff *skb);
index 2fd6dbea327a8b39d2ec0ed10b927d74bcdab408..512718adb0d59df5120e047c69c973556d1c6fb6 100644 (file)
@@ -571,7 +571,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
            !capable(CAP_NET_ADMIN))
                return -EPERM;
 
-       if (nlh->nlmsg_flags & NLM_F_DUMP) {
+       if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
                struct netlink_dump_control c = {
                        .dump = ops->dumpit,
                        .done = ops->done,
@@ -877,8 +877,10 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
 #ifdef CONFIG_MODULES
                if (res == NULL) {
                        genl_unlock();
+                       up_read(&cb_lock);
                        request_module("net-pf-%d-proto-%d-family-%s",
                                       PF_NETLINK, NETLINK_GENERIC, name);
+                       down_read(&cb_lock);
                        genl_lock();
                        res = genl_family_find_byname(name);
                }
index 27ee56b688a39eea9650f1dd0b434a3c42aa515b..6ecf491ad5098db632b294cf20ea5156870f0095 100644 (file)
@@ -4,6 +4,7 @@
 
 config OPENVSWITCH
        tristate "Open vSwitch"
+       select LIBCRC32C
        ---help---
          Open vSwitch is a multilayer Ethernet switch targeted at virtualized
          environments.  In addition to supporting a variety of features
@@ -40,3 +41,16 @@ config OPENVSWITCH_GRE
          Say N to exclude this support and reduce the binary size.
 
          If unsure, say Y.
+
+config OPENVSWITCH_VXLAN
+       bool "Open vSwitch VXLAN tunneling support"
+       depends on INET
+       depends on OPENVSWITCH
+       depends on VXLAN && !(OPENVSWITCH=y && VXLAN=m)
+       default y
+       ---help---
+         If you say Y here, then the Open vSwitch will be able create vxlan vport.
+
+         Say N to exclude this support and reduce the binary size.
+
+         If unsure, say Y.
index 01bddb2991e3578e74ee7894bc6eccb175905002..ea36e99089af57246c28f68a8e007d8e55c726ba 100644 (file)
@@ -10,6 +10,13 @@ openvswitch-y := \
        dp_notify.o \
        flow.o \
        vport.o \
-       vport-gre.o \
        vport-internal_dev.o \
        vport-netdev.o
+
+ifneq ($(CONFIG_OPENVSWITCH_VXLAN),)
+openvswitch-y += vport-vxlan.o
+endif
+
+ifneq ($(CONFIG_OPENVSWITCH_GRE),)
+openvswitch-y += vport-gre.o
+endif
index 22c5f399f1cf8119f13064559099ad7c30aae93d..65cfaa816075c93d933d4c6e17d13eaf6e92546f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2012 Nicira, Inc.
+ * Copyright (c) 2007-2013 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -22,6 +22,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/openvswitch.h>
+#include <linux/sctp.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/in6.h>
@@ -31,6 +32,7 @@
 #include <net/ipv6.h>
 #include <net/checksum.h>
 #include <net/dsfield.h>
+#include <net/sctp/checksum.h>
 
 #include "datapath.h"
 #include "vport.h"
@@ -352,6 +354,39 @@ static int set_tcp(struct sk_buff *skb, const struct ovs_key_tcp *tcp_port_key)
        return 0;
 }
 
+static int set_sctp(struct sk_buff *skb,
+                    const struct ovs_key_sctp *sctp_port_key)
+{
+       struct sctphdr *sh;
+       int err;
+       unsigned int sctphoff = skb_transport_offset(skb);
+
+       err = make_writable(skb, sctphoff + sizeof(struct sctphdr));
+       if (unlikely(err))
+               return err;
+
+       sh = sctp_hdr(skb);
+       if (sctp_port_key->sctp_src != sh->source ||
+           sctp_port_key->sctp_dst != sh->dest) {
+               __le32 old_correct_csum, new_csum, old_csum;
+
+               old_csum = sh->checksum;
+               old_correct_csum = sctp_compute_cksum(skb, sctphoff);
+
+               sh->source = sctp_port_key->sctp_src;
+               sh->dest = sctp_port_key->sctp_dst;
+
+               new_csum = sctp_compute_cksum(skb, sctphoff);
+
+               /* Carry any checksum errors through. */
+               sh->checksum = old_csum ^ old_correct_csum ^ new_csum;
+
+               skb->rxhash = 0;
+       }
+
+       return 0;
+}
+
 static int do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
 {
        struct vport *vport;
@@ -376,8 +411,10 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
        const struct nlattr *a;
        int rem;
 
+       BUG_ON(!OVS_CB(skb)->pkt_key);
+
        upcall.cmd = OVS_PACKET_CMD_ACTION;
-       upcall.key = &OVS_CB(skb)->flow->key;
+       upcall.key = OVS_CB(skb)->pkt_key;
        upcall.userdata = NULL;
        upcall.portid = 0;
 
@@ -459,6 +496,10 @@ static int execute_set_action(struct sk_buff *skb,
        case OVS_KEY_ATTR_UDP:
                err = set_udp(skb, nla_data(nested_attr));
                break;
+
+       case OVS_KEY_ATTR_SCTP:
+               err = set_sctp(skb, nla_data(nested_attr));
+               break;
        }
 
        return err;
@@ -535,6 +576,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb)
 {
        struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts);
 
+       OVS_CB(skb)->tun_key = NULL;
        return do_execute_actions(dp, skb, acts->actions,
                                         acts->actions_len, false);
 }
index f7e3a0d84c40488cd6744dce31c90bd0d942bd3b..2aa13bd7f2b2c53e1e999109df3b51c4326cdba1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2012 Nicira, Inc.
+ * Copyright (c) 2007-2013 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -165,7 +165,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu)
 {
        struct datapath *dp = container_of(rcu, struct datapath, rcu);
 
-       ovs_flow_tbl_destroy((__force struct flow_table *)dp->table);
+       ovs_flow_tbl_destroy((__force struct flow_table *)dp->table, false);
        free_percpu(dp->stats_percpu);
        release_net(ovs_dp_get_net(dp));
        kfree(dp->ports);
@@ -226,19 +226,18 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
        struct sw_flow_key key;
        u64 *stats_counter;
        int error;
-       int key_len;
 
        stats = this_cpu_ptr(dp->stats_percpu);
 
        /* Extract flow from 'skb' into 'key'. */
-       error = ovs_flow_extract(skb, p->port_no, &key, &key_len);
+       error = ovs_flow_extract(skb, p->port_no, &key);
        if (unlikely(error)) {
                kfree_skb(skb);
                return;
        }
 
        /* Look up flow. */
-       flow = ovs_flow_tbl_lookup(rcu_dereference(dp->table), &key, key_len);
+       flow = ovs_flow_lookup(rcu_dereference(dp->table), &key);
        if (unlikely(!flow)) {
                struct dp_upcall_info upcall;
 
@@ -253,6 +252,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
        }
 
        OVS_CB(skb)->flow = flow;
+       OVS_CB(skb)->pkt_key = &key;
 
        stats_counter = &stats->n_hit;
        ovs_flow_used(OVS_CB(skb)->flow, skb);
@@ -435,7 +435,7 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex,
        upcall->dp_ifindex = dp_ifindex;
 
        nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
-       ovs_flow_to_nlattrs(upcall_info->key, user_skb);
+       ovs_flow_to_nlattrs(upcall_info->key, upcall_info->key, user_skb);
        nla_nest_end(user_skb, nla);
 
        if (upcall_info->userdata)
@@ -468,7 +468,7 @@ static int flush_flows(struct datapath *dp)
 
        rcu_assign_pointer(dp->table, new_table);
 
-       ovs_flow_tbl_deferred_destroy(old_table);
+       ovs_flow_tbl_destroy(old_table, true);
        return 0;
 }
 
@@ -611,10 +611,12 @@ static int validate_tp_port(const struct sw_flow_key *flow_key)
 static int validate_and_copy_set_tun(const struct nlattr *attr,
                                     struct sw_flow_actions **sfa)
 {
-       struct ovs_key_ipv4_tunnel tun_key;
+       struct sw_flow_match match;
+       struct sw_flow_key key;
        int err, start;
 
-       err = ovs_ipv4_tun_from_nlattr(nla_data(attr), &tun_key);
+       ovs_match_init(&match, &key, NULL);
+       err = ovs_ipv4_tun_from_nlattr(nla_data(attr), &match, false);
        if (err)
                return err;
 
@@ -622,7 +624,8 @@ static int validate_and_copy_set_tun(const struct nlattr *attr,
        if (start < 0)
                return start;
 
-       err = add_action(sfa, OVS_KEY_ATTR_IPV4_TUNNEL, &tun_key, sizeof(tun_key));
+       err = add_action(sfa, OVS_KEY_ATTR_IPV4_TUNNEL, &match.key->tun_key,
+                       sizeof(match.key->tun_key));
        add_nested_action_end(*sfa, start);
 
        return err;
@@ -709,6 +712,12 @@ static int validate_set(const struct nlattr *a,
 
                return validate_tp_port(flow_key);
 
+       case OVS_KEY_ATTR_SCTP:
+               if (flow_key->ip.proto != IPPROTO_SCTP)
+                       return -EINVAL;
+
+               return validate_tp_port(flow_key);
+
        default:
                return -EINVAL;
        }
@@ -857,7 +866,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
        struct ethhdr *eth;
        int len;
        int err;
-       int key_len;
 
        err = -EINVAL;
        if (!a[OVS_PACKET_ATTR_PACKET] || !a[OVS_PACKET_ATTR_KEY] ||
@@ -890,11 +898,11 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
        if (IS_ERR(flow))
                goto err_kfree_skb;
 
-       err = ovs_flow_extract(packet, -1, &flow->key, &key_len);
+       err = ovs_flow_extract(packet, -1, &flow->key);
        if (err)
                goto err_flow_free;
 
-       err = ovs_flow_metadata_from_nlattrs(flow, key_len, a[OVS_PACKET_ATTR_KEY]);
+       err = ovs_flow_metadata_from_nlattrs(flow, a[OVS_PACKET_ATTR_KEY]);
        if (err)
                goto err_flow_free;
        acts = ovs_flow_actions_alloc(nla_len(a[OVS_PACKET_ATTR_ACTIONS]));
@@ -908,6 +916,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
                goto err_flow_free;
 
        OVS_CB(packet)->flow = flow;
+       OVS_CB(packet)->pkt_key = &flow->key;
        packet->priority = flow->key.phy.priority;
        packet->mark = flow->key.phy.skb_mark;
 
@@ -922,13 +931,13 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
        local_bh_enable();
        rcu_read_unlock();
 
-       ovs_flow_free(flow);
+       ovs_flow_free(flow, false);
        return err;
 
 err_unlock:
        rcu_read_unlock();
 err_flow_free:
-       ovs_flow_free(flow);
+       ovs_flow_free(flow, false);
 err_kfree_skb:
        kfree_skb(packet);
 err:
@@ -951,9 +960,10 @@ static struct genl_ops dp_packet_genl_ops[] = {
 
 static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats)
 {
+       struct flow_table *table;
        int i;
-       struct flow_table *table = ovsl_dereference(dp->table);
 
+       table = rcu_dereference_check(dp->table, lockdep_ovsl_is_held());
        stats->n_flows = ovs_flow_tbl_count(table);
 
        stats->n_hit = stats->n_missed = stats->n_lost = 0;
@@ -1044,7 +1054,8 @@ static int set_action_to_attr(const struct nlattr *a, struct sk_buff *skb)
                if (!start)
                        return -EMSGSIZE;
 
-               err = ovs_ipv4_tun_to_nlattr(skb, nla_data(ovs_key));
+               err = ovs_ipv4_tun_to_nlattr(skb, nla_data(ovs_key),
+                                            nla_data(ovs_key));
                if (err)
                        return err;
                nla_nest_end(skb, start);
@@ -1092,6 +1103,7 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts)
 {
        return NLMSG_ALIGN(sizeof(struct ovs_header))
                + nla_total_size(key_attr_size()) /* OVS_FLOW_ATTR_KEY */
+               + nla_total_size(key_attr_size()) /* OVS_FLOW_ATTR_MASK */
                + nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */
                + nla_total_size(1) /* OVS_FLOW_ATTR_TCP_FLAGS */
                + nla_total_size(8) /* OVS_FLOW_ATTR_USED */
@@ -1104,7 +1116,6 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp,
                                  u32 seq, u32 flags, u8 cmd)
 {
        const int skb_orig_len = skb->len;
-       const struct sw_flow_actions *sf_acts;
        struct nlattr *start;
        struct ovs_flow_stats stats;
        struct ovs_header *ovs_header;
@@ -1113,20 +1124,31 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp,
        u8 tcp_flags;
        int err;
 
-       sf_acts = ovsl_dereference(flow->sf_acts);
-
        ovs_header = genlmsg_put(skb, portid, seq, &dp_flow_genl_family, flags, cmd);
        if (!ovs_header)
                return -EMSGSIZE;
 
        ovs_header->dp_ifindex = get_dpifindex(dp);
 
+       /* Fill flow key. */
        nla = nla_nest_start(skb, OVS_FLOW_ATTR_KEY);
        if (!nla)
                goto nla_put_failure;
-       err = ovs_flow_to_nlattrs(&flow->key, skb);
+
+       err = ovs_flow_to_nlattrs(&flow->unmasked_key,
+                       &flow->unmasked_key, skb);
+       if (err)
+               goto error;
+       nla_nest_end(skb, nla);
+
+       nla = nla_nest_start(skb, OVS_FLOW_ATTR_MASK);
+       if (!nla)
+               goto nla_put_failure;
+
+       err = ovs_flow_to_nlattrs(&flow->key, &flow->mask->key, skb);
        if (err)
                goto error;
+
        nla_nest_end(skb, nla);
 
        spin_lock_bh(&flow->lock);
@@ -1161,6 +1183,11 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp,
         */
        start = nla_nest_start(skb, OVS_FLOW_ATTR_ACTIONS);
        if (start) {
+               const struct sw_flow_actions *sf_acts;
+
+               sf_acts = rcu_dereference_check(flow->sf_acts,
+                                               lockdep_ovsl_is_held());
+
                err = actions_to_attr(sf_acts->actions, sf_acts->actions_len, skb);
                if (!err)
                        nla_nest_end(skb, start);
@@ -1211,20 +1238,24 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
 {
        struct nlattr **a = info->attrs;
        struct ovs_header *ovs_header = info->userhdr;
-       struct sw_flow_key key;
-       struct sw_flow *flow;
+       struct sw_flow_key key, masked_key;
+       struct sw_flow *flow = NULL;
+       struct sw_flow_mask mask;
        struct sk_buff *reply;
        struct datapath *dp;
        struct flow_table *table;
        struct sw_flow_actions *acts = NULL;
+       struct sw_flow_match match;
        int error;
-       int key_len;
 
        /* Extract key. */
        error = -EINVAL;
        if (!a[OVS_FLOW_ATTR_KEY])
                goto error;
-       error = ovs_flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]);
+
+       ovs_match_init(&match, &key, &mask);
+       error = ovs_match_from_nlattrs(&match,
+                       a[OVS_FLOW_ATTR_KEY], a[OVS_FLOW_ATTR_MASK]);
        if (error)
                goto error;
 
@@ -1235,9 +1266,13 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                if (IS_ERR(acts))
                        goto error;
 
-               error = validate_and_copy_actions(a[OVS_FLOW_ATTR_ACTIONS], &key,  0, &acts);
-               if (error)
+               ovs_flow_key_mask(&masked_key, &key, &mask);
+               error = validate_and_copy_actions(a[OVS_FLOW_ATTR_ACTIONS],
+                                                 &masked_key, 0, &acts);
+               if (error) {
+                       OVS_NLERR("Flow actions may not be safe on all matching packets.\n");
                        goto err_kfree;
+               }
        } else if (info->genlhdr->cmd == OVS_FLOW_CMD_NEW) {
                error = -EINVAL;
                goto error;
@@ -1250,8 +1285,11 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                goto err_unlock_ovs;
 
        table = ovsl_dereference(dp->table);
-       flow = ovs_flow_tbl_lookup(table, &key, key_len);
+
+       /* Check if this is a duplicate flow */
+       flow = ovs_flow_lookup(table, &key);
        if (!flow) {
+               struct sw_flow_mask *mask_p;
                /* Bail out if we're not allowed to create a new flow. */
                error = -ENOENT;
                if (info->genlhdr->cmd == OVS_FLOW_CMD_SET)
@@ -1264,7 +1302,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                        new_table = ovs_flow_tbl_expand(table);
                        if (!IS_ERR(new_table)) {
                                rcu_assign_pointer(dp->table, new_table);
-                               ovs_flow_tbl_deferred_destroy(table);
+                               ovs_flow_tbl_destroy(table, true);
                                table = ovsl_dereference(dp->table);
                        }
                }
@@ -1277,14 +1315,30 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                }
                clear_stats(flow);
 
+               flow->key = masked_key;
+               flow->unmasked_key = key;
+
+               /* Make sure mask is unique in the system */
+               mask_p = ovs_sw_flow_mask_find(table, &mask);
+               if (!mask_p) {
+                       /* Allocate a new mask if none exsits. */
+                       mask_p = ovs_sw_flow_mask_alloc();
+                       if (!mask_p)
+                               goto err_flow_free;
+                       mask_p->key = mask.key;
+                       mask_p->range = mask.range;
+                       ovs_sw_flow_mask_insert(table, mask_p);
+               }
+
+               ovs_sw_flow_mask_add_ref(mask_p);
+               flow->mask = mask_p;
                rcu_assign_pointer(flow->sf_acts, acts);
 
                /* Put flow in bucket. */
-               ovs_flow_tbl_insert(table, flow, &key, key_len);
+               ovs_flow_insert(table, flow);
 
                reply = ovs_flow_cmd_build_info(flow, dp, info->snd_portid,
-                                               info->snd_seq,
-                                               OVS_FLOW_CMD_NEW);
+                                               info->snd_seq, OVS_FLOW_CMD_NEW);
        } else {
                /* We found a matching flow. */
                struct sw_flow_actions *old_acts;
@@ -1300,6 +1354,13 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                    info->nlhdr->nlmsg_flags & (NLM_F_CREATE | NLM_F_EXCL))
                        goto err_unlock_ovs;
 
+               /* The unmasked key has to be the same for flow updates. */
+               error = -EINVAL;
+               if (!ovs_flow_cmp_unmasked_key(flow, &key, match.range.end)) {
+                       OVS_NLERR("Flow modification message rejected, unmasked key does not match.\n");
+                       goto err_unlock_ovs;
+               }
+
                /* Update actions. */
                old_acts = ovsl_dereference(flow->sf_acts);
                rcu_assign_pointer(flow->sf_acts, acts);
@@ -1324,6 +1385,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
                                ovs_dp_flow_multicast_group.id, PTR_ERR(reply));
        return 0;
 
+err_flow_free:
+       ovs_flow_free(flow, false);
 err_unlock_ovs:
        ovs_unlock();
 err_kfree:
@@ -1341,12 +1404,16 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
        struct sw_flow *flow;
        struct datapath *dp;
        struct flow_table *table;
+       struct sw_flow_match match;
        int err;
-       int key_len;
 
-       if (!a[OVS_FLOW_ATTR_KEY])
+       if (!a[OVS_FLOW_ATTR_KEY]) {
+               OVS_NLERR("Flow get message rejected, Key attribute missing.\n");
                return -EINVAL;
-       err = ovs_flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]);
+       }
+
+       ovs_match_init(&match, &key, NULL);
+       err = ovs_match_from_nlattrs(&match, a[OVS_FLOW_ATTR_KEY], NULL);
        if (err)
                return err;
 
@@ -1358,7 +1425,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)
        }
 
        table = ovsl_dereference(dp->table);
-       flow = ovs_flow_tbl_lookup(table, &key, key_len);
+       flow = ovs_flow_lookup_unmasked_key(table, &match);
        if (!flow) {
                err = -ENOENT;
                goto unlock;
@@ -1387,8 +1454,8 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
        struct sw_flow *flow;
        struct datapath *dp;
        struct flow_table *table;
+       struct sw_flow_match match;
        int err;
-       int key_len;
 
        ovs_lock();
        dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
@@ -1401,12 +1468,14 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
                err = flush_flows(dp);
                goto unlock;
        }
-       err = ovs_flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]);
+
+       ovs_match_init(&match, &key, NULL);
+       err = ovs_match_from_nlattrs(&match, a[OVS_FLOW_ATTR_KEY], NULL);
        if (err)
                goto unlock;
 
        table = ovsl_dereference(dp->table);
-       flow = ovs_flow_tbl_lookup(table, &key, key_len);
+       flow = ovs_flow_lookup_unmasked_key(table, &match);
        if (!flow) {
                err = -ENOENT;
                goto unlock;
@@ -1418,13 +1487,13 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
                goto unlock;
        }
 
-       ovs_flow_tbl_remove(table, flow);
+       ovs_flow_remove(table, flow);
 
        err = ovs_flow_cmd_fill_info(flow, dp, reply, info->snd_portid,
                                     info->snd_seq, 0, OVS_FLOW_CMD_DEL);
        BUG_ON(err < 0);
 
-       ovs_flow_deferred_free(flow);
+       ovs_flow_free(flow, true);
        ovs_unlock();
 
        ovs_notify(reply, info, &ovs_dp_flow_multicast_group);
@@ -1440,22 +1509,21 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
        struct datapath *dp;
        struct flow_table *table;
 
-       ovs_lock();
+       rcu_read_lock();
        dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
        if (!dp) {
-               ovs_unlock();
+               rcu_read_unlock();
                return -ENODEV;
        }
 
-       table = ovsl_dereference(dp->table);
-
+       table = rcu_dereference(dp->table);
        for (;;) {
                struct sw_flow *flow;
                u32 bucket, obj;
 
                bucket = cb->args[0];
                obj = cb->args[1];
-               flow = ovs_flow_tbl_next(table, &bucket, &obj);
+               flow = ovs_flow_dump_next(table, &bucket, &obj);
                if (!flow)
                        break;
 
@@ -1468,7 +1536,7 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
                cb->args[0] = bucket;
                cb->args[1] = obj;
        }
-       ovs_unlock();
+       rcu_read_unlock();
        return skb->len;
 }
 
@@ -1664,7 +1732,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
                goto err_destroy_local_port;
 
        ovs_net = net_generic(ovs_dp_get_net(dp), ovs_net_id);
-       list_add_tail(&dp->list_node, &ovs_net->dps);
+       list_add_tail_rcu(&dp->list_node, &ovs_net->dps);
 
        ovs_unlock();
 
@@ -1678,7 +1746,7 @@ err_destroy_ports_array:
 err_destroy_percpu:
        free_percpu(dp->stats_percpu);
 err_destroy_table:
-       ovs_flow_tbl_destroy(ovsl_dereference(dp->table));
+       ovs_flow_tbl_destroy(ovsl_dereference(dp->table), false);
 err_free_dp:
        release_net(ovs_dp_get_net(dp));
        kfree(dp);
@@ -1702,7 +1770,7 @@ static void __dp_destroy(struct datapath *dp)
                                ovs_dp_detach_port(vport);
        }
 
-       list_del(&dp->list_node);
+       list_del_rcu(&dp->list_node);
 
        /* OVSP_LOCAL is datapath internal port. We need to make sure that
         * all port in datapath are destroyed first before freeing datapath.
@@ -1807,8 +1875,8 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
        int skip = cb->args[0];
        int i = 0;
 
-       ovs_lock();
-       list_for_each_entry(dp, &ovs_net->dps, list_node) {
+       rcu_read_lock();
+       list_for_each_entry_rcu(dp, &ovs_net->dps, list_node) {
                if (i >= skip &&
                    ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
                                         cb->nlh->nlmsg_seq, NLM_F_MULTI,
@@ -1816,7 +1884,7 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
                        break;
                i++;
        }
-       ovs_unlock();
+       rcu_read_unlock();
 
        cb->args[0] = i;
 
@@ -2076,9 +2144,6 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
        ovs_notify(reply, info, &ovs_dp_vport_multicast_group);
        return 0;
 
-       rtnl_unlock();
-       return 0;
-
 exit_free:
        kfree_skb(reply);
 exit_unlock:
@@ -2288,7 +2353,7 @@ static void rehash_flow_table(struct work_struct *work)
                        new_table = ovs_flow_tbl_rehash(old_table);
                        if (!IS_ERR(new_table)) {
                                rcu_assign_pointer(dp->table, new_table);
-                               ovs_flow_tbl_deferred_destroy(old_table);
+                               ovs_flow_tbl_destroy(old_table, true);
                        }
                }
        }
index a91486484916b4e5aa69bd82ee95d4a76cc25ce3..4d109c176ef3ce2bd7be0419a15839ab4f8a03f1 100644 (file)
@@ -88,11 +88,13 @@ struct datapath {
 /**
  * struct ovs_skb_cb - OVS data in skb CB
  * @flow: The flow associated with this packet.  May be %NULL if no flow.
+ * @pkt_key: The flow information extracted from the packet.  Must be nonnull.
  * @tun_key: Key for the tunnel that encapsulated this packet. NULL if the
  * packet is not being tunneled.
  */
 struct ovs_skb_cb {
        struct sw_flow          *flow;
+       struct sw_flow_key      *pkt_key;
        struct ovs_key_ipv4_tunnel  *tun_key;
 };
 #define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
@@ -183,4 +185,8 @@ struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
 
 int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb);
 void ovs_dp_notify_wq(struct work_struct *work);
+
+#define OVS_NLERR(fmt, ...) \
+       pr_info_once("netlink: " fmt, ##__VA_ARGS__)
+
 #endif /* datapath.h */
index 5c519b121e1be0ba26c40e136ace7b8eba42f62e..ad1aeeb4f373f2702a91b4478174a0a046ee3ab7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2011 Nicira, Inc.
+ * Copyright (c) 2007-2013 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -34,6 +34,7 @@
 #include <linux/if_arp.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
+#include <linux/sctp.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/icmp.h>
 
 static struct kmem_cache *flow_cache;
 
+static void ovs_sw_flow_mask_set(struct sw_flow_mask *mask,
+               struct sw_flow_key_range *range, u8 val);
+
+static void update_range__(struct sw_flow_match *match,
+                         size_t offset, size_t size, bool is_mask)
+{
+       struct sw_flow_key_range *range = NULL;
+       size_t start = rounddown(offset, sizeof(long));
+       size_t end = roundup(offset + size, sizeof(long));
+
+       if (!is_mask)
+               range = &match->range;
+       else if (match->mask)
+               range = &match->mask->range;
+
+       if (!range)
+               return;
+
+       if (range->start == range->end) {
+               range->start = start;
+               range->end = end;
+               return;
+       }
+
+       if (range->start > start)
+               range->start = start;
+
+       if (range->end < end)
+               range->end = end;
+}
+
+#define SW_FLOW_KEY_PUT(match, field, value, is_mask) \
+       do { \
+               update_range__(match, offsetof(struct sw_flow_key, field),  \
+                                    sizeof((match)->key->field), is_mask); \
+               if (is_mask) {                                              \
+                       if ((match)->mask)                                  \
+                               (match)->mask->key.field = value;           \
+               } else {                                                    \
+                       (match)->key->field = value;                        \
+               }                                                           \
+       } while (0)
+
+#define SW_FLOW_KEY_MEMCPY(match, field, value_p, len, is_mask) \
+       do { \
+               update_range__(match, offsetof(struct sw_flow_key, field),  \
+                               len, is_mask);                              \
+               if (is_mask) {                                              \
+                       if ((match)->mask)                                  \
+                               memcpy(&(match)->mask->key.field, value_p, len);\
+               } else {                                                    \
+                       memcpy(&(match)->key->field, value_p, len);         \
+               }                                                           \
+       } while (0)
+
+static u16 range_n_bytes(const struct sw_flow_key_range *range)
+{
+       return range->end - range->start;
+}
+
+void ovs_match_init(struct sw_flow_match *match,
+                   struct sw_flow_key *key,
+                   struct sw_flow_mask *mask)
+{
+       memset(match, 0, sizeof(*match));
+       match->key = key;
+       match->mask = mask;
+
+       memset(key, 0, sizeof(*key));
+
+       if (mask) {
+               memset(&mask->key, 0, sizeof(mask->key));
+               mask->range.start = mask->range.end = 0;
+       }
+}
+
+static bool ovs_match_validate(const struct sw_flow_match *match,
+               u64 key_attrs, u64 mask_attrs)
+{
+       u64 key_expected = 1 << OVS_KEY_ATTR_ETHERNET;
+       u64 mask_allowed = key_attrs;  /* At most allow all key attributes */
+
+       /* The following mask attributes allowed only if they
+        * pass the validation tests. */
+       mask_allowed &= ~((1 << OVS_KEY_ATTR_IPV4)
+                       | (1 << OVS_KEY_ATTR_IPV6)
+                       | (1 << OVS_KEY_ATTR_TCP)
+                       | (1 << OVS_KEY_ATTR_UDP)
+                       | (1 << OVS_KEY_ATTR_SCTP)
+                       | (1 << OVS_KEY_ATTR_ICMP)
+                       | (1 << OVS_KEY_ATTR_ICMPV6)
+                       | (1 << OVS_KEY_ATTR_ARP)
+                       | (1 << OVS_KEY_ATTR_ND));
+
+       /* Always allowed mask fields. */
+       mask_allowed |= ((1 << OVS_KEY_ATTR_TUNNEL)
+                      | (1 << OVS_KEY_ATTR_IN_PORT)
+                      | (1 << OVS_KEY_ATTR_ETHERTYPE));
+
+       /* Check key attributes. */
+       if (match->key->eth.type == htons(ETH_P_ARP)
+                       || match->key->eth.type == htons(ETH_P_RARP)) {
+               key_expected |= 1 << OVS_KEY_ATTR_ARP;
+               if (match->mask && (match->mask->key.eth.type == htons(0xffff)))
+                       mask_allowed |= 1 << OVS_KEY_ATTR_ARP;
+       }
+
+       if (match->key->eth.type == htons(ETH_P_IP)) {
+               key_expected |= 1 << OVS_KEY_ATTR_IPV4;
+               if (match->mask && (match->mask->key.eth.type == htons(0xffff)))
+                       mask_allowed |= 1 << OVS_KEY_ATTR_IPV4;
+
+               if (match->key->ip.frag != OVS_FRAG_TYPE_LATER) {
+                       if (match->key->ip.proto == IPPROTO_UDP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_UDP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_UDP;
+                       }
+
+                       if (match->key->ip.proto == IPPROTO_SCTP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_SCTP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_SCTP;
+                       }
+
+                       if (match->key->ip.proto == IPPROTO_TCP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_TCP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_TCP;
+                       }
+
+                       if (match->key->ip.proto == IPPROTO_ICMP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_ICMP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_ICMP;
+                       }
+               }
+       }
+
+       if (match->key->eth.type == htons(ETH_P_IPV6)) {
+               key_expected |= 1 << OVS_KEY_ATTR_IPV6;
+               if (match->mask && (match->mask->key.eth.type == htons(0xffff)))
+                       mask_allowed |= 1 << OVS_KEY_ATTR_IPV6;
+
+               if (match->key->ip.frag != OVS_FRAG_TYPE_LATER) {
+                       if (match->key->ip.proto == IPPROTO_UDP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_UDP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_UDP;
+                       }
+
+                       if (match->key->ip.proto == IPPROTO_SCTP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_SCTP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_SCTP;
+                       }
+
+                       if (match->key->ip.proto == IPPROTO_TCP) {
+                               key_expected |= 1 << OVS_KEY_ATTR_TCP;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_TCP;
+                       }
+
+                       if (match->key->ip.proto == IPPROTO_ICMPV6) {
+                               key_expected |= 1 << OVS_KEY_ATTR_ICMPV6;
+                               if (match->mask && (match->mask->key.ip.proto == 0xff))
+                                       mask_allowed |= 1 << OVS_KEY_ATTR_ICMPV6;
+
+                               if (match->key->ipv6.tp.src ==
+                                               htons(NDISC_NEIGHBOUR_SOLICITATION) ||
+                                   match->key->ipv6.tp.src == htons(NDISC_NEIGHBOUR_ADVERTISEMENT)) {
+                                       key_expected |= 1 << OVS_KEY_ATTR_ND;
+                                       if (match->mask && (match->mask->key.ipv6.tp.src == htons(0xffff)))
+                                               mask_allowed |= 1 << OVS_KEY_ATTR_ND;
+                               }
+                       }
+               }
+       }
+
+       if ((key_attrs & key_expected) != key_expected) {
+               /* Key attributes check failed. */
+               OVS_NLERR("Missing expected key attributes (key_attrs=%llx, expected=%llx).\n",
+                               key_attrs, key_expected);
+               return false;
+       }
+
+       if ((mask_attrs & mask_allowed) != mask_attrs) {
+               /* Mask attributes check failed. */
+               OVS_NLERR("Contain more than allowed mask fields (mask_attrs=%llx, mask_allowed=%llx).\n",
+                               mask_attrs, mask_allowed);
+               return false;
+       }
+
+       return true;
+}
+
 static int check_header(struct sk_buff *skb, int len)
 {
        if (unlikely(skb->len < len))
@@ -102,6 +299,12 @@ static bool udphdr_ok(struct sk_buff *skb)
                                  sizeof(struct udphdr));
 }
 
+static bool sctphdr_ok(struct sk_buff *skb)
+{
+       return pskb_may_pull(skb, skb_transport_offset(skb) +
+                                 sizeof(struct sctphdr));
+}
+
 static bool icmphdr_ok(struct sk_buff *skb)
 {
        return pskb_may_pull(skb, skb_transport_offset(skb) +
@@ -121,12 +324,7 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies)
        return cur_ms - idle_ms;
 }
 
-#define SW_FLOW_KEY_OFFSET(field)              \
-       (offsetof(struct sw_flow_key, field) +  \
-        FIELD_SIZEOF(struct sw_flow_key, field))
-
-static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key,
-                        int *key_lenp)
+static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key)
 {
        unsigned int nh_ofs = skb_network_offset(skb);
        unsigned int nh_len;
@@ -136,8 +334,6 @@ static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key,
        __be16 frag_off;
        int err;
 
-       *key_lenp = SW_FLOW_KEY_OFFSET(ipv6.label);
-
        err = check_header(skb, nh_ofs + sizeof(*nh));
        if (unlikely(err))
                return err;
@@ -176,6 +372,22 @@ static bool icmp6hdr_ok(struct sk_buff *skb)
                                  sizeof(struct icmp6hdr));
 }
 
+void ovs_flow_key_mask(struct sw_flow_key *dst, const struct sw_flow_key *src,
+                      const struct sw_flow_mask *mask)
+{
+       const long *m = (long *)((u8 *)&mask->key + mask->range.start);
+       const long *s = (long *)((u8 *)src + mask->range.start);
+       long *d = (long *)((u8 *)dst + mask->range.start);
+       int i;
+
+       /* The memory outside of the 'mask->range' are not set since
+        * further operations on 'dst' only uses contents within
+        * 'mask->range'.
+        */
+       for (i = 0; i < range_n_bytes(&mask->range); i += sizeof(long))
+               *d++ = *s++ & *m++;
+}
+
 #define TCP_FLAGS_OFFSET 13
 #define TCP_FLAG_MASK 0x3f
 
@@ -224,6 +436,7 @@ struct sw_flow *ovs_flow_alloc(void)
 
        spin_lock_init(&flow->lock);
        flow->sf_acts = NULL;
+       flow->mask = NULL;
 
        return flow;
 }
@@ -240,7 +453,7 @@ static struct flex_array *alloc_buckets(unsigned int n_buckets)
        struct flex_array *buckets;
        int i, err;
 
-       buckets = flex_array_alloc(sizeof(struct hlist_head *),
+       buckets = flex_array_alloc(sizeof(struct hlist_head),
                                   n_buckets, GFP_KERNEL);
        if (!buckets)
                return NULL;
@@ -263,7 +476,7 @@ static void free_buckets(struct flex_array *buckets)
        flex_array_free(buckets);
 }
 
-struct flow_table *ovs_flow_tbl_alloc(int new_size)
+static struct flow_table *__flow_tbl_alloc(int new_size)
 {
        struct flow_table *table = kmalloc(sizeof(*table), GFP_KERNEL);
 
@@ -281,17 +494,15 @@ struct flow_table *ovs_flow_tbl_alloc(int new_size)
        table->node_ver = 0;
        table->keep_flows = false;
        get_random_bytes(&table->hash_seed, sizeof(u32));
+       table->mask_list = NULL;
 
        return table;
 }
 
-void ovs_flow_tbl_destroy(struct flow_table *table)
+static void __flow_tbl_destroy(struct flow_table *table)
 {
        int i;
 
-       if (!table)
-               return;
-
        if (table->keep_flows)
                goto skip_flows;
 
@@ -302,32 +513,56 @@ void ovs_flow_tbl_destroy(struct flow_table *table)
                int ver = table->node_ver;
 
                hlist_for_each_entry_safe(flow, n, head, hash_node[ver]) {
-                       hlist_del_rcu(&flow->hash_node[ver]);
-                       ovs_flow_free(flow);
+                       hlist_del(&flow->hash_node[ver]);
+                       ovs_flow_free(flow, false);
                }
        }
 
+       BUG_ON(!list_empty(table->mask_list));
+       kfree(table->mask_list);
+
 skip_flows:
        free_buckets(table->buckets);
        kfree(table);
 }
 
+struct flow_table *ovs_flow_tbl_alloc(int new_size)
+{
+       struct flow_table *table = __flow_tbl_alloc(new_size);
+
+       if (!table)
+               return NULL;
+
+       table->mask_list = kmalloc(sizeof(struct list_head), GFP_KERNEL);
+       if (!table->mask_list) {
+               table->keep_flows = true;
+               __flow_tbl_destroy(table);
+               return NULL;
+       }
+       INIT_LIST_HEAD(table->mask_list);
+
+       return table;
+}
+
 static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu)
 {
        struct flow_table *table = container_of(rcu, struct flow_table, rcu);
 
-       ovs_flow_tbl_destroy(table);
+       __flow_tbl_destroy(table);
 }
 
-void ovs_flow_tbl_deferred_destroy(struct flow_table *table)
+void ovs_flow_tbl_destroy(struct flow_table *table, bool deferred)
 {
        if (!table)
                return;
 
-       call_rcu(&table->rcu, flow_tbl_destroy_rcu_cb);
+       if (deferred)
+               call_rcu(&table->rcu, flow_tbl_destroy_rcu_cb);
+       else
+               __flow_tbl_destroy(table);
 }
 
-struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *last)
+struct sw_flow *ovs_flow_dump_next(struct flow_table *table, u32 *bucket, u32 *last)
 {
        struct sw_flow *flow;
        struct hlist_head *head;
@@ -353,11 +588,13 @@ struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *la
        return NULL;
 }
 
-static void __flow_tbl_insert(struct flow_table *table, struct sw_flow *flow)
+static void __tbl_insert(struct flow_table *table, struct sw_flow *flow)
 {
        struct hlist_head *head;
+
        head = find_bucket(table, flow->hash);
        hlist_add_head_rcu(&flow->hash_node[table->node_ver], head);
+
        table->count++;
 }
 
@@ -377,8 +614,10 @@ static void flow_table_copy_flows(struct flow_table *old, struct flow_table *new
                head = flex_array_get(old->buckets, i);
 
                hlist_for_each_entry(flow, head, hash_node[old_ver])
-                       __flow_tbl_insert(new, flow);
+                       __tbl_insert(new, flow);
        }
+
+       new->mask_list = old->mask_list;
        old->keep_flows = true;
 }
 
@@ -386,7 +625,7 @@ static struct flow_table *__flow_tbl_rehash(struct flow_table *table, int n_buck
 {
        struct flow_table *new_table;
 
-       new_table = ovs_flow_tbl_alloc(n_buckets);
+       new_table = __flow_tbl_alloc(n_buckets);
        if (!new_table)
                return ERR_PTR(-ENOMEM);
 
@@ -405,28 +644,30 @@ struct flow_table *ovs_flow_tbl_expand(struct flow_table *table)
        return __flow_tbl_rehash(table, table->n_buckets * 2);
 }
 
-void ovs_flow_free(struct sw_flow *flow)
+static void __flow_free(struct sw_flow *flow)
 {
-       if (unlikely(!flow))
-               return;
-
        kfree((struct sf_flow_acts __force *)flow->sf_acts);
        kmem_cache_free(flow_cache, flow);
 }
 
-/* RCU callback used by ovs_flow_deferred_free. */
 static void rcu_free_flow_callback(struct rcu_head *rcu)
 {
        struct sw_flow *flow = container_of(rcu, struct sw_flow, rcu);
 
-       ovs_flow_free(flow);
+       __flow_free(flow);
 }
 
-/* Schedules 'flow' to be freed after the next RCU grace period.
- * The caller must hold rcu_read_lock for this to be sensible. */
-void ovs_flow_deferred_free(struct sw_flow *flow)
+void ovs_flow_free(struct sw_flow *flow, bool deferred)
 {
-       call_rcu(&flow->rcu, rcu_free_flow_callback);
+       if (!flow)
+               return;
+
+       ovs_sw_flow_mask_del_ref(flow->mask, deferred);
+
+       if (deferred)
+               call_rcu(&flow->rcu, rcu_free_flow_callback);
+       else
+               __flow_free(flow);
 }
 
 /* Schedules 'sf_acts' to be freed after the next RCU grace period.
@@ -497,18 +738,15 @@ static __be16 parse_ethertype(struct sk_buff *skb)
 }
 
 static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
-                       int *key_lenp, int nh_len)
+                       int nh_len)
 {
        struct icmp6hdr *icmp = icmp6_hdr(skb);
-       int error = 0;
-       int key_len;
 
        /* The ICMPv6 type and code fields use the 16-bit transport port
         * fields, so we need to store them in 16-bit network byte order.
         */
        key->ipv6.tp.src = htons(icmp->icmp6_type);
        key->ipv6.tp.dst = htons(icmp->icmp6_code);
-       key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
 
        if (icmp->icmp6_code == 0 &&
            (icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION ||
@@ -517,21 +755,17 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
                struct nd_msg *nd;
                int offset;
 
-               key_len = SW_FLOW_KEY_OFFSET(ipv6.nd);
-
                /* In order to process neighbor discovery options, we need the
                 * entire packet.
                 */
                if (unlikely(icmp_len < sizeof(*nd)))
-                       goto out;
-               if (unlikely(skb_linearize(skb))) {
-                       error = -ENOMEM;
-                       goto out;
-               }
+                       return 0;
+
+               if (unlikely(skb_linearize(skb)))
+                       return -ENOMEM;
 
                nd = (struct nd_msg *)skb_transport_header(skb);
                key->ipv6.nd.target = nd->target;
-               key_len = SW_FLOW_KEY_OFFSET(ipv6.nd);
 
                icmp_len -= sizeof(*nd);
                offset = 0;
@@ -541,7 +775,7 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
                        int opt_len = nd_opt->nd_opt_len * 8;
 
                        if (unlikely(!opt_len || opt_len > icmp_len))
-                               goto invalid;
+                               return 0;
 
                        /* Store the link layer address if the appropriate
                         * option is provided.  It is considered an error if
@@ -566,16 +800,14 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,
                }
        }
 
-       goto out;
+       return 0;
 
 invalid:
        memset(&key->ipv6.nd.target, 0, sizeof(key->ipv6.nd.target));
        memset(key->ipv6.nd.sll, 0, sizeof(key->ipv6.nd.sll));
        memset(key->ipv6.nd.tll, 0, sizeof(key->ipv6.nd.tll));
 
-out:
-       *key_lenp = key_len;
-       return error;
+       return 0;
 }
 
 /**
@@ -584,7 +816,6 @@ out:
  * Ethernet header
  * @in_port: port number on which @skb was received.
  * @key: output flow key
- * @key_lenp: length of output flow key
  *
  * The caller must ensure that skb->len >= ETH_HLEN.
  *
@@ -602,11 +833,9 @@ out:
  *      of a correct length, otherwise the same as skb->network_header.
  *      For other key->eth.type values it is left untouched.
  */
-int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
-                int *key_lenp)
+int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)
 {
-       int error = 0;
-       int key_len = SW_FLOW_KEY_OFFSET(eth);
+       int error;
        struct ethhdr *eth;
 
        memset(key, 0, sizeof(*key));
@@ -649,15 +878,13 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
                struct iphdr *nh;
                __be16 offset;
 
-               key_len = SW_FLOW_KEY_OFFSET(ipv4.addr);
-
                error = check_iphdr(skb);
                if (unlikely(error)) {
                        if (error == -EINVAL) {
                                skb->transport_header = skb->network_header;
                                error = 0;
                        }
-                       goto out;
+                       return error;
                }
 
                nh = ip_hdr(skb);
@@ -671,7 +898,7 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
                offset = nh->frag_off & htons(IP_OFFSET);
                if (offset) {
                        key->ip.frag = OVS_FRAG_TYPE_LATER;
-                       goto out;
+                       return 0;
                }
                if (nh->frag_off & htons(IP_MF) ||
                         skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
@@ -679,21 +906,24 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
 
                /* Transport layer. */
                if (key->ip.proto == IPPROTO_TCP) {
-                       key_len = SW_FLOW_KEY_OFFSET(ipv4.tp);
                        if (tcphdr_ok(skb)) {
                                struct tcphdr *tcp = tcp_hdr(skb);
                                key->ipv4.tp.src = tcp->source;
                                key->ipv4.tp.dst = tcp->dest;
                        }
                } else if (key->ip.proto == IPPROTO_UDP) {
-                       key_len = SW_FLOW_KEY_OFFSET(ipv4.tp);
                        if (udphdr_ok(skb)) {
                                struct udphdr *udp = udp_hdr(skb);
                                key->ipv4.tp.src = udp->source;
                                key->ipv4.tp.dst = udp->dest;
                        }
+               } else if (key->ip.proto == IPPROTO_SCTP) {
+                       if (sctphdr_ok(skb)) {
+                               struct sctphdr *sctp = sctp_hdr(skb);
+                               key->ipv4.tp.src = sctp->source;
+                               key->ipv4.tp.dst = sctp->dest;
+                       }
                } else if (key->ip.proto == IPPROTO_ICMP) {
-                       key_len = SW_FLOW_KEY_OFFSET(ipv4.tp);
                        if (icmphdr_ok(skb)) {
                                struct icmphdr *icmp = icmp_hdr(skb);
                                /* The ICMP type and code fields use the 16-bit
@@ -722,102 +952,175 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
                        memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst));
                        memcpy(key->ipv4.arp.sha, arp->ar_sha, ETH_ALEN);
                        memcpy(key->ipv4.arp.tha, arp->ar_tha, ETH_ALEN);
-                       key_len = SW_FLOW_KEY_OFFSET(ipv4.arp);
                }
        } else if (key->eth.type == htons(ETH_P_IPV6)) {
                int nh_len;             /* IPv6 Header + Extensions */
 
-               nh_len = parse_ipv6hdr(skb, key, &key_len);
+               nh_len = parse_ipv6hdr(skb, key);
                if (unlikely(nh_len < 0)) {
-                       if (nh_len == -EINVAL)
+                       if (nh_len == -EINVAL) {
                                skb->transport_header = skb->network_header;
-                       else
+                               error = 0;
+                       } else {
                                error = nh_len;
-                       goto out;
+                       }
+                       return error;
                }
 
                if (key->ip.frag == OVS_FRAG_TYPE_LATER)
-                       goto out;
+                       return 0;
                if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
                        key->ip.frag = OVS_FRAG_TYPE_FIRST;
 
                /* Transport layer. */
                if (key->ip.proto == NEXTHDR_TCP) {
-                       key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
                        if (tcphdr_ok(skb)) {
                                struct tcphdr *tcp = tcp_hdr(skb);
                                key->ipv6.tp.src = tcp->source;
                                key->ipv6.tp.dst = tcp->dest;
                        }
                } else if (key->ip.proto == NEXTHDR_UDP) {
-                       key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
                        if (udphdr_ok(skb)) {
                                struct udphdr *udp = udp_hdr(skb);
                                key->ipv6.tp.src = udp->source;
                                key->ipv6.tp.dst = udp->dest;
                        }
+               } else if (key->ip.proto == NEXTHDR_SCTP) {
+                       if (sctphdr_ok(skb)) {
+                               struct sctphdr *sctp = sctp_hdr(skb);
+                               key->ipv6.tp.src = sctp->source;
+                               key->ipv6.tp.dst = sctp->dest;
+                       }
                } else if (key->ip.proto == NEXTHDR_ICMP) {
-                       key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
                        if (icmp6hdr_ok(skb)) {
-                               error = parse_icmpv6(skb, key, &key_len, nh_len);
-                               if (error < 0)
-                                       goto out;
+                               error = parse_icmpv6(skb, key, nh_len);
+                               if (error)
+                                       return error;
                        }
                }
        }
 
-out:
-       *key_lenp = key_len;
-       return error;
+       return 0;
 }
 
-static u32 ovs_flow_hash(const struct sw_flow_key *key, int key_start, int key_len)
+static u32 ovs_flow_hash(const struct sw_flow_key *key, int key_start,
+                        int key_end)
 {
-       return jhash2((u32 *)((u8 *)key + key_start),
-                     DIV_ROUND_UP(key_len - key_start, sizeof(u32)), 0);
+       u32 *hash_key = (u32 *)((u8 *)key + key_start);
+       int hash_u32s = (key_end - key_start) >> 2;
+
+       /* Make sure number of hash bytes are multiple of u32. */
+       BUILD_BUG_ON(sizeof(long) % sizeof(u32));
+
+       return jhash2(hash_key, hash_u32s, 0);
 }
 
-static int flow_key_start(struct sw_flow_key *key)
+static int flow_key_start(const struct sw_flow_key *key)
 {
        if (key->tun_key.ipv4_dst)
                return 0;
        else
-               return offsetof(struct sw_flow_key, phy);
+               return rounddown(offsetof(struct sw_flow_key, phy),
+                                         sizeof(long));
+}
+
+static bool __cmp_key(const struct sw_flow_key *key1,
+               const struct sw_flow_key *key2,  int key_start, int key_end)
+{
+       const long *cp1 = (long *)((u8 *)key1 + key_start);
+       const long *cp2 = (long *)((u8 *)key2 + key_start);
+       long diffs = 0;
+       int i;
+
+       for (i = key_start; i < key_end;  i += sizeof(long))
+               diffs |= *cp1++ ^ *cp2++;
+
+       return diffs == 0;
 }
 
-struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *table,
-                               struct sw_flow_key *key, int key_len)
+static bool __flow_cmp_masked_key(const struct sw_flow *flow,
+               const struct sw_flow_key *key, int key_start, int key_end)
+{
+       return __cmp_key(&flow->key, key, key_start, key_end);
+}
+
+static bool __flow_cmp_unmasked_key(const struct sw_flow *flow,
+                 const struct sw_flow_key *key, int key_start, int key_end)
+{
+       return __cmp_key(&flow->unmasked_key, key, key_start, key_end);
+}
+
+bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
+               const struct sw_flow_key *key, int key_end)
+{
+       int key_start;
+       key_start = flow_key_start(key);
+
+       return __flow_cmp_unmasked_key(flow, key, key_start, key_end);
+
+}
+
+struct sw_flow *ovs_flow_lookup_unmasked_key(struct flow_table *table,
+                                      struct sw_flow_match *match)
+{
+       struct sw_flow_key *unmasked = match->key;
+       int key_end = match->range.end;
+       struct sw_flow *flow;
+
+       flow = ovs_flow_lookup(table, unmasked);
+       if (flow && (!ovs_flow_cmp_unmasked_key(flow, unmasked, key_end)))
+               flow = NULL;
+
+       return flow;
+}
+
+static struct sw_flow *ovs_masked_flow_lookup(struct flow_table *table,
+                                   const struct sw_flow_key *unmasked,
+                                   struct sw_flow_mask *mask)
 {
        struct sw_flow *flow;
        struct hlist_head *head;
-       u8 *_key;
-       int key_start;
+       int key_start = mask->range.start;
+       int key_end = mask->range.end;
        u32 hash;
+       struct sw_flow_key masked_key;
 
-       key_start = flow_key_start(key);
-       hash = ovs_flow_hash(key, key_start, key_len);
-
-       _key = (u8 *) key + key_start;
+       ovs_flow_key_mask(&masked_key, unmasked, mask);
+       hash = ovs_flow_hash(&masked_key, key_start, key_end);
        head = find_bucket(table, hash);
        hlist_for_each_entry_rcu(flow, head, hash_node[table->node_ver]) {
-
-               if (flow->hash == hash &&
-                   !memcmp((u8 *)&flow->key + key_start, _key, key_len - key_start)) {
+               if (flow->mask == mask &&
+                   __flow_cmp_masked_key(flow, &masked_key,
+                                         key_start, key_end))
                        return flow;
-               }
        }
        return NULL;
 }
 
-void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
-                        struct sw_flow_key *key, int key_len)
+struct sw_flow *ovs_flow_lookup(struct flow_table *tbl,
+                               const struct sw_flow_key *key)
+{
+       struct sw_flow *flow = NULL;
+       struct sw_flow_mask *mask;
+
+       list_for_each_entry_rcu(mask, tbl->mask_list, list) {
+               flow = ovs_masked_flow_lookup(tbl, key, mask);
+               if (flow)  /* Found */
+                       break;
+       }
+
+       return flow;
+}
+
+
+void ovs_flow_insert(struct flow_table *table, struct sw_flow *flow)
 {
-       flow->hash = ovs_flow_hash(key, flow_key_start(key), key_len);
-       memcpy(&flow->key, key, sizeof(flow->key));
-       __flow_tbl_insert(table, flow);
+       flow->hash = ovs_flow_hash(&flow->key, flow->mask->range.start,
+                       flow->mask->range.end);
+       __tbl_insert(table, flow);
 }
 
-void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow)
+void ovs_flow_remove(struct flow_table *table, struct sw_flow *flow)
 {
        BUG_ON(table->count == 0);
        hlist_del_rcu(&flow->hash_node[table->node_ver]);
@@ -837,6 +1140,7 @@ const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
        [OVS_KEY_ATTR_IPV6] = sizeof(struct ovs_key_ipv6),
        [OVS_KEY_ATTR_TCP] = sizeof(struct ovs_key_tcp),
        [OVS_KEY_ATTR_UDP] = sizeof(struct ovs_key_udp),
+       [OVS_KEY_ATTR_SCTP] = sizeof(struct ovs_key_sctp),
        [OVS_KEY_ATTR_ICMP] = sizeof(struct ovs_key_icmp),
        [OVS_KEY_ATTR_ICMPV6] = sizeof(struct ovs_key_icmpv6),
        [OVS_KEY_ATTR_ARP] = sizeof(struct ovs_key_arp),
@@ -844,149 +1148,84 @@ const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
        [OVS_KEY_ATTR_TUNNEL] = -1,
 };
 
-static int ipv4_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_len,
-                                 const struct nlattr *a[], u32 *attrs)
+static bool is_all_zero(const u8 *fp, size_t size)
 {
-       const struct ovs_key_icmp *icmp_key;
-       const struct ovs_key_tcp *tcp_key;
-       const struct ovs_key_udp *udp_key;
-
-       switch (swkey->ip.proto) {
-       case IPPROTO_TCP:
-               if (!(*attrs & (1 << OVS_KEY_ATTR_TCP)))
-                       return -EINVAL;
-               *attrs &= ~(1 << OVS_KEY_ATTR_TCP);
-
-               *key_len = SW_FLOW_KEY_OFFSET(ipv4.tp);
-               tcp_key = nla_data(a[OVS_KEY_ATTR_TCP]);
-               swkey->ipv4.tp.src = tcp_key->tcp_src;
-               swkey->ipv4.tp.dst = tcp_key->tcp_dst;
-               break;
-
-       case IPPROTO_UDP:
-               if (!(*attrs & (1 << OVS_KEY_ATTR_UDP)))
-                       return -EINVAL;
-               *attrs &= ~(1 << OVS_KEY_ATTR_UDP);
-
-               *key_len = SW_FLOW_KEY_OFFSET(ipv4.tp);
-               udp_key = nla_data(a[OVS_KEY_ATTR_UDP]);
-               swkey->ipv4.tp.src = udp_key->udp_src;
-               swkey->ipv4.tp.dst = udp_key->udp_dst;
-               break;
-
-       case IPPROTO_ICMP:
-               if (!(*attrs & (1 << OVS_KEY_ATTR_ICMP)))
-                       return -EINVAL;
-               *attrs &= ~(1 << OVS_KEY_ATTR_ICMP);
-
-               *key_len = SW_FLOW_KEY_OFFSET(ipv4.tp);
-               icmp_key = nla_data(a[OVS_KEY_ATTR_ICMP]);
-               swkey->ipv4.tp.src = htons(icmp_key->icmp_type);
-               swkey->ipv4.tp.dst = htons(icmp_key->icmp_code);
-               break;
-       }
-
-       return 0;
-}
-
-static int ipv6_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_len,
-                                 const struct nlattr *a[], u32 *attrs)
-{
-       const struct ovs_key_icmpv6 *icmpv6_key;
-       const struct ovs_key_tcp *tcp_key;
-       const struct ovs_key_udp *udp_key;
-
-       switch (swkey->ip.proto) {
-       case IPPROTO_TCP:
-               if (!(*attrs & (1 << OVS_KEY_ATTR_TCP)))
-                       return -EINVAL;
-               *attrs &= ~(1 << OVS_KEY_ATTR_TCP);
-
-               *key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
-               tcp_key = nla_data(a[OVS_KEY_ATTR_TCP]);
-               swkey->ipv6.tp.src = tcp_key->tcp_src;
-               swkey->ipv6.tp.dst = tcp_key->tcp_dst;
-               break;
-
-       case IPPROTO_UDP:
-               if (!(*attrs & (1 << OVS_KEY_ATTR_UDP)))
-                       return -EINVAL;
-               *attrs &= ~(1 << OVS_KEY_ATTR_UDP);
-
-               *key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
-               udp_key = nla_data(a[OVS_KEY_ATTR_UDP]);
-               swkey->ipv6.tp.src = udp_key->udp_src;
-               swkey->ipv6.tp.dst = udp_key->udp_dst;
-               break;
-
-       case IPPROTO_ICMPV6:
-               if (!(*attrs & (1 << OVS_KEY_ATTR_ICMPV6)))
-                       return -EINVAL;
-               *attrs &= ~(1 << OVS_KEY_ATTR_ICMPV6);
-
-               *key_len = SW_FLOW_KEY_OFFSET(ipv6.tp);
-               icmpv6_key = nla_data(a[OVS_KEY_ATTR_ICMPV6]);
-               swkey->ipv6.tp.src = htons(icmpv6_key->icmpv6_type);
-               swkey->ipv6.tp.dst = htons(icmpv6_key->icmpv6_code);
+       int i;
 
-               if (swkey->ipv6.tp.src == htons(NDISC_NEIGHBOUR_SOLICITATION) ||
-                   swkey->ipv6.tp.src == htons(NDISC_NEIGHBOUR_ADVERTISEMENT)) {
-                       const struct ovs_key_nd *nd_key;
+       if (!fp)
+               return false;
 
-                       if (!(*attrs & (1 << OVS_KEY_ATTR_ND)))
-                               return -EINVAL;
-                       *attrs &= ~(1 << OVS_KEY_ATTR_ND);
-
-                       *key_len = SW_FLOW_KEY_OFFSET(ipv6.nd);
-                       nd_key = nla_data(a[OVS_KEY_ATTR_ND]);
-                       memcpy(&swkey->ipv6.nd.target, nd_key->nd_target,
-                              sizeof(swkey->ipv6.nd.target));
-                       memcpy(swkey->ipv6.nd.sll, nd_key->nd_sll, ETH_ALEN);
-                       memcpy(swkey->ipv6.nd.tll, nd_key->nd_tll, ETH_ALEN);
-               }
-               break;
-       }
+       for (i = 0; i < size; i++)
+               if (fp[i])
+                       return false;
 
-       return 0;
+       return true;
 }
 
-static int parse_flow_nlattrs(const struct nlattr *attr,
-                             const struct nlattr *a[], u32 *attrsp)
+static int __parse_flow_nlattrs(const struct nlattr *attr,
+                             const struct nlattr *a[],
+                             u64 *attrsp, bool nz)
 {
        const struct nlattr *nla;
        u32 attrs;
        int rem;
 
-       attrs = 0;
+       attrs = *attrsp;
        nla_for_each_nested(nla, attr, rem) {
                u16 type = nla_type(nla);
                int expected_len;
 
-               if (type > OVS_KEY_ATTR_MAX || attrs & (1 << type))
+               if (type > OVS_KEY_ATTR_MAX) {
+                       OVS_NLERR("Unknown key attribute (type=%d, max=%d).\n",
+                                 type, OVS_KEY_ATTR_MAX);
+               }
+
+               if (attrs & (1 << type)) {
+                       OVS_NLERR("Duplicate key attribute (type %d).\n", type);
                        return -EINVAL;
+               }
 
                expected_len = ovs_key_lens[type];
-               if (nla_len(nla) != expected_len && expected_len != -1)
+               if (nla_len(nla) != expected_len && expected_len != -1) {
+                       OVS_NLERR("Key attribute has unexpected length (type=%d"
+                                 ", length=%d, expected=%d).\n", type,
+                                 nla_len(nla), expected_len);
                        return -EINVAL;
+               }
 
-               attrs |= 1 << type;
-               a[type] = nla;
+               if (!nz || !is_all_zero(nla_data(nla), expected_len)) {
+                       attrs |= 1 << type;
+                       a[type] = nla;
+               }
        }
-       if (rem)
+       if (rem) {
+               OVS_NLERR("Message has %d unknown bytes.\n", rem);
                return -EINVAL;
+       }
 
        *attrsp = attrs;
        return 0;
 }
 
+static int parse_flow_mask_nlattrs(const struct nlattr *attr,
+                             const struct nlattr *a[], u64 *attrsp)
+{
+       return __parse_flow_nlattrs(attr, a, attrsp, true);
+}
+
+static int parse_flow_nlattrs(const struct nlattr *attr,
+                             const struct nlattr *a[], u64 *attrsp)
+{
+       return __parse_flow_nlattrs(attr, a, attrsp, false);
+}
+
 int ovs_ipv4_tun_from_nlattr(const struct nlattr *attr,
-                            struct ovs_key_ipv4_tunnel *tun_key)
+                            struct sw_flow_match *match, bool is_mask)
 {
        struct nlattr *a;
        int rem;
        bool ttl = false;
-
-       memset(tun_key, 0, sizeof(*tun_key));
+       __be16 tun_flags = 0;
 
        nla_for_each_nested(a, attr, rem) {
                int type = nla_type(a);
@@ -1000,53 +1239,78 @@ int ovs_ipv4_tun_from_nlattr(const struct nlattr *attr,
                        [OVS_TUNNEL_KEY_ATTR_CSUM] = 0,
                };
 
-               if (type > OVS_TUNNEL_KEY_ATTR_MAX ||
-                       ovs_tunnel_key_lens[type] != nla_len(a))
+               if (type > OVS_TUNNEL_KEY_ATTR_MAX) {
+                       OVS_NLERR("Unknown IPv4 tunnel attribute (type=%d, max=%d).\n",
+                       type, OVS_TUNNEL_KEY_ATTR_MAX);
                        return -EINVAL;
+               }
+
+               if (ovs_tunnel_key_lens[type] != nla_len(a)) {
+                       OVS_NLERR("IPv4 tunnel attribute type has unexpected "
+                                 " length (type=%d, length=%d, expected=%d).\n",
+                                 type, nla_len(a), ovs_tunnel_key_lens[type]);
+                       return -EINVAL;
+               }
 
                switch (type) {
                case OVS_TUNNEL_KEY_ATTR_ID:
-                       tun_key->tun_id = nla_get_be64(a);
-                       tun_key->tun_flags |= TUNNEL_KEY;
+                       SW_FLOW_KEY_PUT(match, tun_key.tun_id,
+                                       nla_get_be64(a), is_mask);
+                       tun_flags |= TUNNEL_KEY;
                        break;
                case OVS_TUNNEL_KEY_ATTR_IPV4_SRC:
-                       tun_key->ipv4_src = nla_get_be32(a);
+                       SW_FLOW_KEY_PUT(match, tun_key.ipv4_src,
+                                       nla_get_be32(a), is_mask);
                        break;
                case OVS_TUNNEL_KEY_ATTR_IPV4_DST:
-                       tun_key->ipv4_dst = nla_get_be32(a);
+                       SW_FLOW_KEY_PUT(match, tun_key.ipv4_dst,
+                                       nla_get_be32(a), is_mask);
                        break;
                case OVS_TUNNEL_KEY_ATTR_TOS:
-                       tun_key->ipv4_tos = nla_get_u8(a);
+                       SW_FLOW_KEY_PUT(match, tun_key.ipv4_tos,
+                                       nla_get_u8(a), is_mask);
                        break;
                case OVS_TUNNEL_KEY_ATTR_TTL:
-                       tun_key->ipv4_ttl = nla_get_u8(a);
+                       SW_FLOW_KEY_PUT(match, tun_key.ipv4_ttl,
+                                       nla_get_u8(a), is_mask);
                        ttl = true;
                        break;
                case OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT:
-                       tun_key->tun_flags |= TUNNEL_DONT_FRAGMENT;
+                       tun_flags |= TUNNEL_DONT_FRAGMENT;
                        break;
                case OVS_TUNNEL_KEY_ATTR_CSUM:
-                       tun_key->tun_flags |= TUNNEL_CSUM;
+                       tun_flags |= TUNNEL_CSUM;
                        break;
                default:
                        return -EINVAL;
-
                }
        }
-       if (rem > 0)
-               return -EINVAL;
 
-       if (!tun_key->ipv4_dst)
-               return -EINVAL;
+       SW_FLOW_KEY_PUT(match, tun_key.tun_flags, tun_flags, is_mask);
 
-       if (!ttl)
+       if (rem > 0) {
+               OVS_NLERR("IPv4 tunnel attribute has %d unknown bytes.\n", rem);
                return -EINVAL;
+       }
+
+       if (!is_mask) {
+               if (!match->key->tun_key.ipv4_dst) {
+                       OVS_NLERR("IPv4 tunnel destination address is zero.\n");
+                       return -EINVAL;
+               }
+
+               if (!ttl) {
+                       OVS_NLERR("IPv4 tunnel TTL not specified.\n");
+                       return -EINVAL;
+               }
+       }
 
        return 0;
 }
 
 int ovs_ipv4_tun_to_nlattr(struct sk_buff *skb,
-                          const struct ovs_key_ipv4_tunnel *tun_key)
+                          const struct ovs_key_ipv4_tunnel *tun_key,
+                          const struct ovs_key_ipv4_tunnel *output)
 {
        struct nlattr *nla;
 
@@ -1054,23 +1318,24 @@ int ovs_ipv4_tun_to_nlattr(struct sk_buff *skb,
        if (!nla)
                return -EMSGSIZE;
 
-       if (tun_key->tun_flags & TUNNEL_KEY &&
-           nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, tun_key->tun_id))
+       if (output->tun_flags & TUNNEL_KEY &&
+           nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id))
                return -EMSGSIZE;
-       if (tun_key->ipv4_src &&
-           nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC, tun_key->ipv4_src))
+       if (output->ipv4_src &&
+               nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC, output->ipv4_src))
                return -EMSGSIZE;
-       if (nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST, tun_key->ipv4_dst))
+       if (output->ipv4_dst &&
+               nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST, output->ipv4_dst))
                return -EMSGSIZE;
-       if (tun_key->ipv4_tos &&
-           nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, tun_key->ipv4_tos))
+       if (output->ipv4_tos &&
+               nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->ipv4_tos))
                return -EMSGSIZE;
-       if (nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TTL, tun_key->ipv4_ttl))
+       if (nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TTL, output->ipv4_ttl))
                return -EMSGSIZE;
-       if ((tun_key->tun_flags & TUNNEL_DONT_FRAGMENT) &&
+       if ((output->tun_flags & TUNNEL_DONT_FRAGMENT) &&
                nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT))
                return -EMSGSIZE;
-       if ((tun_key->tun_flags & TUNNEL_CSUM) &&
+       if ((output->tun_flags & TUNNEL_CSUM) &&
                nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_CSUM))
                return -EMSGSIZE;
 
@@ -1078,176 +1343,390 @@ int ovs_ipv4_tun_to_nlattr(struct sk_buff *skb,
        return 0;
 }
 
-/**
- * ovs_flow_from_nlattrs - parses Netlink attributes into a flow key.
- * @swkey: receives the extracted flow key.
- * @key_lenp: number of bytes used in @swkey.
- * @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
- * sequence.
- */
-int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
-                     const struct nlattr *attr)
+static int metadata_from_nlattrs(struct sw_flow_match *match,  u64 *attrs,
+               const struct nlattr **a, bool is_mask)
 {
-       const struct nlattr *a[OVS_KEY_ATTR_MAX + 1];
-       const struct ovs_key_ethernet *eth_key;
-       int key_len;
-       u32 attrs;
-       int err;
+       if (*attrs & (1 << OVS_KEY_ATTR_PRIORITY)) {
+               SW_FLOW_KEY_PUT(match, phy.priority,
+                         nla_get_u32(a[OVS_KEY_ATTR_PRIORITY]), is_mask);
+               *attrs &= ~(1 << OVS_KEY_ATTR_PRIORITY);
+       }
 
-       memset(swkey, 0, sizeof(struct sw_flow_key));
-       key_len = SW_FLOW_KEY_OFFSET(eth);
+       if (*attrs & (1 << OVS_KEY_ATTR_IN_PORT)) {
+               u32 in_port = nla_get_u32(a[OVS_KEY_ATTR_IN_PORT]);
 
-       err = parse_flow_nlattrs(attr, a, &attrs);
-       if (err)
-               return err;
+               if (is_mask)
+                       in_port = 0xffffffff; /* Always exact match in_port. */
+               else if (in_port >= DP_MAX_PORTS)
+                       return -EINVAL;
 
-       /* Metadata attributes. */
-       if (attrs & (1 << OVS_KEY_ATTR_PRIORITY)) {
-               swkey->phy.priority = nla_get_u32(a[OVS_KEY_ATTR_PRIORITY]);
-               attrs &= ~(1 << OVS_KEY_ATTR_PRIORITY);
+               SW_FLOW_KEY_PUT(match, phy.in_port, in_port, is_mask);
+               *attrs &= ~(1 << OVS_KEY_ATTR_IN_PORT);
+       } else if (!is_mask) {
+               SW_FLOW_KEY_PUT(match, phy.in_port, DP_MAX_PORTS, is_mask);
        }
-       if (attrs & (1 << OVS_KEY_ATTR_IN_PORT)) {
-               u32 in_port = nla_get_u32(a[OVS_KEY_ATTR_IN_PORT]);
-               if (in_port >= DP_MAX_PORTS)
-                       return -EINVAL;
-               swkey->phy.in_port = in_port;
-               attrs &= ~(1 << OVS_KEY_ATTR_IN_PORT);
-       } else {
-               swkey->phy.in_port = DP_MAX_PORTS;
+
+       if (*attrs & (1 << OVS_KEY_ATTR_SKB_MARK)) {
+               uint32_t mark = nla_get_u32(a[OVS_KEY_ATTR_SKB_MARK]);
+
+               SW_FLOW_KEY_PUT(match, phy.skb_mark, mark, is_mask);
+               *attrs &= ~(1 << OVS_KEY_ATTR_SKB_MARK);
        }
-       if (attrs & (1 << OVS_KEY_ATTR_SKB_MARK)) {
-               swkey->phy.skb_mark = nla_get_u32(a[OVS_KEY_ATTR_SKB_MARK]);
-               attrs &= ~(1 << OVS_KEY_ATTR_SKB_MARK);
+       if (*attrs & (1 << OVS_KEY_ATTR_TUNNEL)) {
+               if (ovs_ipv4_tun_from_nlattr(a[OVS_KEY_ATTR_TUNNEL], match,
+                                       is_mask))
+                       return -EINVAL;
+               *attrs &= ~(1 << OVS_KEY_ATTR_TUNNEL);
        }
+       return 0;
+}
 
-       if (attrs & (1 << OVS_KEY_ATTR_TUNNEL)) {
-               err = ovs_ipv4_tun_from_nlattr(a[OVS_KEY_ATTR_TUNNEL], &swkey->tun_key);
-               if (err)
-                       return err;
+static int ovs_key_from_nlattrs(struct sw_flow_match *match,  u64 attrs,
+               const struct nlattr **a, bool is_mask)
+{
+       int err;
+       u64 orig_attrs = attrs;
 
-               attrs &= ~(1 << OVS_KEY_ATTR_TUNNEL);
-       }
+       err = metadata_from_nlattrs(match, &attrs, a, is_mask);
+       if (err)
+               return err;
 
-       /* Data attributes. */
-       if (!(attrs & (1 << OVS_KEY_ATTR_ETHERNET)))
-               return -EINVAL;
-       attrs &= ~(1 << OVS_KEY_ATTR_ETHERNET);
+       if (attrs & (1 << OVS_KEY_ATTR_ETHERNET)) {
+               const struct ovs_key_ethernet *eth_key;
 
-       eth_key = nla_data(a[OVS_KEY_ATTR_ETHERNET]);
-       memcpy(swkey->eth.src, eth_key->eth_src, ETH_ALEN);
-       memcpy(swkey->eth.dst, eth_key->eth_dst, ETH_ALEN);
+               eth_key = nla_data(a[OVS_KEY_ATTR_ETHERNET]);
+               SW_FLOW_KEY_MEMCPY(match, eth.src,
+                               eth_key->eth_src, ETH_ALEN, is_mask);
+               SW_FLOW_KEY_MEMCPY(match, eth.dst,
+                               eth_key->eth_dst, ETH_ALEN, is_mask);
+               attrs &= ~(1 << OVS_KEY_ATTR_ETHERNET);
+       }
 
-       if (attrs & (1u << OVS_KEY_ATTR_ETHERTYPE) &&
-           nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]) == htons(ETH_P_8021Q)) {
-               const struct nlattr *encap;
+       if (attrs & (1 << OVS_KEY_ATTR_VLAN)) {
                __be16 tci;
 
-               if (attrs != ((1 << OVS_KEY_ATTR_VLAN) |
-                             (1 << OVS_KEY_ATTR_ETHERTYPE) |
-                             (1 << OVS_KEY_ATTR_ENCAP)))
-                       return -EINVAL;
-
-               encap = a[OVS_KEY_ATTR_ENCAP];
                tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
-               if (tci & htons(VLAN_TAG_PRESENT)) {
-                       swkey->eth.tci = tci;
-
-                       err = parse_flow_nlattrs(encap, a, &attrs);
-                       if (err)
-                               return err;
-               } else if (!tci) {
-                       /* Corner case for truncated 802.1Q header. */
-                       if (nla_len(encap))
-                               return -EINVAL;
+               if (!(tci & htons(VLAN_TAG_PRESENT))) {
+                       if (is_mask)
+                               OVS_NLERR("VLAN TCI mask does not have exact match for VLAN_TAG_PRESENT bit.\n");
+                       else
+                               OVS_NLERR("VLAN TCI does not have VLAN_TAG_PRESENT bit set.\n");
 
-                       swkey->eth.type = htons(ETH_P_8021Q);
-                       *key_lenp = key_len;
-                       return 0;
-               } else {
                        return -EINVAL;
                }
-       }
+
+               SW_FLOW_KEY_PUT(match, eth.tci, tci, is_mask);
+               attrs &= ~(1 << OVS_KEY_ATTR_VLAN);
+       } else if (!is_mask)
+               SW_FLOW_KEY_PUT(match, eth.tci, htons(0xffff), true);
 
        if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) {
-               swkey->eth.type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]);
-               if (ntohs(swkey->eth.type) < ETH_P_802_3_MIN)
+               __be16 eth_type;
+
+               eth_type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]);
+               if (is_mask) {
+                       /* Always exact match EtherType. */
+                       eth_type = htons(0xffff);
+               } else if (ntohs(eth_type) < ETH_P_802_3_MIN) {
+                       OVS_NLERR("EtherType is less than minimum (type=%x, min=%x).\n",
+                                       ntohs(eth_type), ETH_P_802_3_MIN);
                        return -EINVAL;
+               }
+
+               SW_FLOW_KEY_PUT(match, eth.type, eth_type, is_mask);
                attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
-       } else {
-               swkey->eth.type = htons(ETH_P_802_2);
+       } else if (!is_mask) {
+               SW_FLOW_KEY_PUT(match, eth.type, htons(ETH_P_802_2), is_mask);
        }
 
-       if (swkey->eth.type == htons(ETH_P_IP)) {
+       if (attrs & (1 << OVS_KEY_ATTR_IPV4)) {
                const struct ovs_key_ipv4 *ipv4_key;
 
-               if (!(attrs & (1 << OVS_KEY_ATTR_IPV4)))
-                       return -EINVAL;
-               attrs &= ~(1 << OVS_KEY_ATTR_IPV4);
-
-               key_len = SW_FLOW_KEY_OFFSET(ipv4.addr);
                ipv4_key = nla_data(a[OVS_KEY_ATTR_IPV4]);
-               if (ipv4_key->ipv4_frag > OVS_FRAG_TYPE_MAX)
+               if (!is_mask && ipv4_key->ipv4_frag > OVS_FRAG_TYPE_MAX) {
+                       OVS_NLERR("Unknown IPv4 fragment type (value=%d, max=%d).\n",
+                               ipv4_key->ipv4_frag, OVS_FRAG_TYPE_MAX);
                        return -EINVAL;
-               swkey->ip.proto = ipv4_key->ipv4_proto;
-               swkey->ip.tos = ipv4_key->ipv4_tos;
-               swkey->ip.ttl = ipv4_key->ipv4_ttl;
-               swkey->ip.frag = ipv4_key->ipv4_frag;
-               swkey->ipv4.addr.src = ipv4_key->ipv4_src;
-               swkey->ipv4.addr.dst = ipv4_key->ipv4_dst;
-
-               if (swkey->ip.frag != OVS_FRAG_TYPE_LATER) {
-                       err = ipv4_flow_from_nlattrs(swkey, &key_len, a, &attrs);
-                       if (err)
-                               return err;
                }
-       } else if (swkey->eth.type == htons(ETH_P_IPV6)) {
-               const struct ovs_key_ipv6 *ipv6_key;
+               SW_FLOW_KEY_PUT(match, ip.proto,
+                               ipv4_key->ipv4_proto, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.tos,
+                               ipv4_key->ipv4_tos, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.ttl,
+                               ipv4_key->ipv4_ttl, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.frag,
+                               ipv4_key->ipv4_frag, is_mask);
+               SW_FLOW_KEY_PUT(match, ipv4.addr.src,
+                               ipv4_key->ipv4_src, is_mask);
+               SW_FLOW_KEY_PUT(match, ipv4.addr.dst,
+                               ipv4_key->ipv4_dst, is_mask);
+               attrs &= ~(1 << OVS_KEY_ATTR_IPV4);
+       }
 
-               if (!(attrs & (1 << OVS_KEY_ATTR_IPV6)))
-                       return -EINVAL;
-               attrs &= ~(1 << OVS_KEY_ATTR_IPV6);
+       if (attrs & (1 << OVS_KEY_ATTR_IPV6)) {
+               const struct ovs_key_ipv6 *ipv6_key;
 
-               key_len = SW_FLOW_KEY_OFFSET(ipv6.label);
                ipv6_key = nla_data(a[OVS_KEY_ATTR_IPV6]);
-               if (ipv6_key->ipv6_frag > OVS_FRAG_TYPE_MAX)
+               if (!is_mask && ipv6_key->ipv6_frag > OVS_FRAG_TYPE_MAX) {
+                       OVS_NLERR("Unknown IPv6 fragment type (value=%d, max=%d).\n",
+                               ipv6_key->ipv6_frag, OVS_FRAG_TYPE_MAX);
                        return -EINVAL;
-               swkey->ipv6.label = ipv6_key->ipv6_label;
-               swkey->ip.proto = ipv6_key->ipv6_proto;
-               swkey->ip.tos = ipv6_key->ipv6_tclass;
-               swkey->ip.ttl = ipv6_key->ipv6_hlimit;
-               swkey->ip.frag = ipv6_key->ipv6_frag;
-               memcpy(&swkey->ipv6.addr.src, ipv6_key->ipv6_src,
-                      sizeof(swkey->ipv6.addr.src));
-               memcpy(&swkey->ipv6.addr.dst, ipv6_key->ipv6_dst,
-                      sizeof(swkey->ipv6.addr.dst));
-
-               if (swkey->ip.frag != OVS_FRAG_TYPE_LATER) {
-                       err = ipv6_flow_from_nlattrs(swkey, &key_len, a, &attrs);
-                       if (err)
-                               return err;
                }
-       } else if (swkey->eth.type == htons(ETH_P_ARP) ||
-                  swkey->eth.type == htons(ETH_P_RARP)) {
+               SW_FLOW_KEY_PUT(match, ipv6.label,
+                               ipv6_key->ipv6_label, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.proto,
+                               ipv6_key->ipv6_proto, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.tos,
+                               ipv6_key->ipv6_tclass, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.ttl,
+                               ipv6_key->ipv6_hlimit, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.frag,
+                               ipv6_key->ipv6_frag, is_mask);
+               SW_FLOW_KEY_MEMCPY(match, ipv6.addr.src,
+                               ipv6_key->ipv6_src,
+                               sizeof(match->key->ipv6.addr.src),
+                               is_mask);
+               SW_FLOW_KEY_MEMCPY(match, ipv6.addr.dst,
+                               ipv6_key->ipv6_dst,
+                               sizeof(match->key->ipv6.addr.dst),
+                               is_mask);
+
+               attrs &= ~(1 << OVS_KEY_ATTR_IPV6);
+       }
+
+       if (attrs & (1 << OVS_KEY_ATTR_ARP)) {
                const struct ovs_key_arp *arp_key;
 
-               if (!(attrs & (1 << OVS_KEY_ATTR_ARP)))
+               arp_key = nla_data(a[OVS_KEY_ATTR_ARP]);
+               if (!is_mask && (arp_key->arp_op & htons(0xff00))) {
+                       OVS_NLERR("Unknown ARP opcode (opcode=%d).\n",
+                                 arp_key->arp_op);
                        return -EINVAL;
+               }
+
+               SW_FLOW_KEY_PUT(match, ipv4.addr.src,
+                               arp_key->arp_sip, is_mask);
+               SW_FLOW_KEY_PUT(match, ipv4.addr.dst,
+                       arp_key->arp_tip, is_mask);
+               SW_FLOW_KEY_PUT(match, ip.proto,
+                               ntohs(arp_key->arp_op), is_mask);
+               SW_FLOW_KEY_MEMCPY(match, ipv4.arp.sha,
+                               arp_key->arp_sha, ETH_ALEN, is_mask);
+               SW_FLOW_KEY_MEMCPY(match, ipv4.arp.tha,
+                               arp_key->arp_tha, ETH_ALEN, is_mask);
+
                attrs &= ~(1 << OVS_KEY_ATTR_ARP);
+       }
 
-               key_len = SW_FLOW_KEY_OFFSET(ipv4.arp);
-               arp_key = nla_data(a[OVS_KEY_ATTR_ARP]);
-               swkey->ipv4.addr.src = arp_key->arp_sip;
-               swkey->ipv4.addr.dst = arp_key->arp_tip;
-               if (arp_key->arp_op & htons(0xff00))
+       if (attrs & (1 << OVS_KEY_ATTR_TCP)) {
+               const struct ovs_key_tcp *tcp_key;
+
+               tcp_key = nla_data(a[OVS_KEY_ATTR_TCP]);
+               if (orig_attrs & (1 << OVS_KEY_ATTR_IPV4)) {
+                       SW_FLOW_KEY_PUT(match, ipv4.tp.src,
+                                       tcp_key->tcp_src, is_mask);
+                       SW_FLOW_KEY_PUT(match, ipv4.tp.dst,
+                                       tcp_key->tcp_dst, is_mask);
+               } else {
+                       SW_FLOW_KEY_PUT(match, ipv6.tp.src,
+                                       tcp_key->tcp_src, is_mask);
+                       SW_FLOW_KEY_PUT(match, ipv6.tp.dst,
+                                       tcp_key->tcp_dst, is_mask);
+               }
+               attrs &= ~(1 << OVS_KEY_ATTR_TCP);
+       }
+
+       if (attrs & (1 << OVS_KEY_ATTR_UDP)) {
+               const struct ovs_key_udp *udp_key;
+
+               udp_key = nla_data(a[OVS_KEY_ATTR_UDP]);
+               if (orig_attrs & (1 << OVS_KEY_ATTR_IPV4)) {
+                       SW_FLOW_KEY_PUT(match, ipv4.tp.src,
+                                       udp_key->udp_src, is_mask);
+                       SW_FLOW_KEY_PUT(match, ipv4.tp.dst,
+                                       udp_key->udp_dst, is_mask);
+               } else {
+                       SW_FLOW_KEY_PUT(match, ipv6.tp.src,
+                                       udp_key->udp_src, is_mask);
+                       SW_FLOW_KEY_PUT(match, ipv6.tp.dst,
+                                       udp_key->udp_dst, is_mask);
+               }
+               attrs &= ~(1 << OVS_KEY_ATTR_UDP);
+       }
+
+       if (attrs & (1 << OVS_KEY_ATTR_SCTP)) {
+               const struct ovs_key_sctp *sctp_key;
+
+               sctp_key = nla_data(a[OVS_KEY_ATTR_SCTP]);
+               if (orig_attrs & (1 << OVS_KEY_ATTR_IPV4)) {
+                       SW_FLOW_KEY_PUT(match, ipv4.tp.src,
+                                       sctp_key->sctp_src, is_mask);
+                       SW_FLOW_KEY_PUT(match, ipv4.tp.dst,
+                                       sctp_key->sctp_dst, is_mask);
+               } else {
+                       SW_FLOW_KEY_PUT(match, ipv6.tp.src,
+                                       sctp_key->sctp_src, is_mask);
+                       SW_FLOW_KEY_PUT(match, ipv6.tp.dst,
+                                       sctp_key->sctp_dst, is_mask);
+               }
+               attrs &= ~(1 << OVS_KEY_ATTR_SCTP);
+       }
+
+       if (attrs & (1 << OVS_KEY_ATTR_ICMP)) {
+               const struct ovs_key_icmp *icmp_key;
+
+               icmp_key = nla_data(a[OVS_KEY_ATTR_ICMP]);
+               SW_FLOW_KEY_PUT(match, ipv4.tp.src,
+                               htons(icmp_key->icmp_type), is_mask);
+               SW_FLOW_KEY_PUT(match, ipv4.tp.dst,
+                               htons(icmp_key->icmp_code), is_mask);
+               attrs &= ~(1 << OVS_KEY_ATTR_ICMP);
+       }
+
+       if (attrs & (1 << OVS_KEY_ATTR_ICMPV6)) {
+               const struct ovs_key_icmpv6 *icmpv6_key;
+
+               icmpv6_key = nla_data(a[OVS_KEY_ATTR_ICMPV6]);
+               SW_FLOW_KEY_PUT(match, ipv6.tp.src,
+                               htons(icmpv6_key->icmpv6_type), is_mask);
+               SW_FLOW_KEY_PUT(match, ipv6.tp.dst,
+                               htons(icmpv6_key->icmpv6_code), is_mask);
+               attrs &= ~(1 << OVS_KEY_ATTR_ICMPV6);
+       }
+
+       if (attrs & (1 << OVS_KEY_ATTR_ND)) {
+               const struct ovs_key_nd *nd_key;
+
+               nd_key = nla_data(a[OVS_KEY_ATTR_ND]);
+               SW_FLOW_KEY_MEMCPY(match, ipv6.nd.target,
+                       nd_key->nd_target,
+                       sizeof(match->key->ipv6.nd.target),
+                       is_mask);
+               SW_FLOW_KEY_MEMCPY(match, ipv6.nd.sll,
+                       nd_key->nd_sll, ETH_ALEN, is_mask);
+               SW_FLOW_KEY_MEMCPY(match, ipv6.nd.tll,
+                               nd_key->nd_tll, ETH_ALEN, is_mask);
+               attrs &= ~(1 << OVS_KEY_ATTR_ND);
+       }
+
+       if (attrs != 0)
+               return -EINVAL;
+
+       return 0;
+}
+
+/**
+ * ovs_match_from_nlattrs - parses Netlink attributes into a flow key and
+ * mask. In case the 'mask' is NULL, the flow is treated as exact match
+ * flow. Otherwise, it is treated as a wildcarded flow, except the mask
+ * does not include any don't care bit.
+ * @match: receives the extracted flow match information.
+ * @key: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
+ * sequence. The fields should of the packet that triggered the creation
+ * of this flow.
+ * @mask: Optional. Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink
+ * attribute specifies the mask field of the wildcarded flow.
+ */
+int ovs_match_from_nlattrs(struct sw_flow_match *match,
+                          const struct nlattr *key,
+                          const struct nlattr *mask)
+{
+       const struct nlattr *a[OVS_KEY_ATTR_MAX + 1];
+       const struct nlattr *encap;
+       u64 key_attrs = 0;
+       u64 mask_attrs = 0;
+       bool encap_valid = false;
+       int err;
+
+       err = parse_flow_nlattrs(key, a, &key_attrs);
+       if (err)
+               return err;
+
+       if ((key_attrs & (1 << OVS_KEY_ATTR_ETHERNET)) &&
+           (key_attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) &&
+           (nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]) == htons(ETH_P_8021Q))) {
+               __be16 tci;
+
+               if (!((key_attrs & (1 << OVS_KEY_ATTR_VLAN)) &&
+                     (key_attrs & (1 << OVS_KEY_ATTR_ENCAP)))) {
+                       OVS_NLERR("Invalid Vlan frame.\n");
                        return -EINVAL;
-               swkey->ip.proto = ntohs(arp_key->arp_op);
-               memcpy(swkey->ipv4.arp.sha, arp_key->arp_sha, ETH_ALEN);
-               memcpy(swkey->ipv4.arp.tha, arp_key->arp_tha, ETH_ALEN);
+               }
+
+               key_attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
+               tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
+               encap = a[OVS_KEY_ATTR_ENCAP];
+               key_attrs &= ~(1 << OVS_KEY_ATTR_ENCAP);
+               encap_valid = true;
+
+               if (tci & htons(VLAN_TAG_PRESENT)) {
+                       err = parse_flow_nlattrs(encap, a, &key_attrs);
+                       if (err)
+                               return err;
+               } else if (!tci) {
+                       /* Corner case for truncated 802.1Q header. */
+                       if (nla_len(encap)) {
+                               OVS_NLERR("Truncated 802.1Q header has non-zero encap attribute.\n");
+                               return -EINVAL;
+                       }
+               } else {
+                       OVS_NLERR("Encap attribute is set for a non-VLAN frame.\n");
+                       return  -EINVAL;
+               }
+       }
+
+       err = ovs_key_from_nlattrs(match, key_attrs, a, false);
+       if (err)
+               return err;
+
+       if (mask) {
+               err = parse_flow_mask_nlattrs(mask, a, &mask_attrs);
+               if (err)
+                       return err;
+
+               if (mask_attrs & 1ULL << OVS_KEY_ATTR_ENCAP)  {
+                       __be16 eth_type = 0;
+                       __be16 tci = 0;
+
+                       if (!encap_valid) {
+                               OVS_NLERR("Encap mask attribute is set for non-VLAN frame.\n");
+                               return  -EINVAL;
+                       }
+
+                       mask_attrs &= ~(1 << OVS_KEY_ATTR_ENCAP);
+                       if (a[OVS_KEY_ATTR_ETHERTYPE])
+                               eth_type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]);
+
+                       if (eth_type == htons(0xffff)) {
+                               mask_attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE);
+                               encap = a[OVS_KEY_ATTR_ENCAP];
+                               err = parse_flow_mask_nlattrs(encap, a, &mask_attrs);
+                       } else {
+                               OVS_NLERR("VLAN frames must have an exact match on the TPID (mask=%x).\n",
+                                               ntohs(eth_type));
+                               return -EINVAL;
+                       }
+
+                       if (a[OVS_KEY_ATTR_VLAN])
+                               tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
+
+                       if (!(tci & htons(VLAN_TAG_PRESENT))) {
+                               OVS_NLERR("VLAN tag present bit must have an exact match (tci_mask=%x).\n", ntohs(tci));
+                               return -EINVAL;
+                       }
+               }
+
+               err = ovs_key_from_nlattrs(match, mask_attrs, a, true);
+               if (err)
+                       return err;
+       } else {
+               /* Populate exact match flow's key mask. */
+               if (match->mask)
+                       ovs_sw_flow_mask_set(match->mask, &match->range, 0xff);
        }
 
-       if (attrs)
+       if (!ovs_match_validate(match, key_attrs, mask_attrs))
                return -EINVAL;
-       *key_lenp = key_len;
 
        return 0;
 }
@@ -1255,7 +1734,6 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
 /**
  * ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key.
  * @flow: Receives extracted in_port, priority, tun_key and skb_mark.
- * @key_len: Length of key in @flow.  Used for calculating flow hash.
  * @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute
  * sequence.
  *
@@ -1264,102 +1742,100 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
  * get the metadata, that is, the parts of the flow key that cannot be
  * extracted from the packet itself.
  */
-int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow, int key_len,
-                                  const struct nlattr *attr)
+
+int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
+               const struct nlattr *attr)
 {
        struct ovs_key_ipv4_tunnel *tun_key = &flow->key.tun_key;
-       const struct nlattr *nla;
-       int rem;
+       const struct nlattr *a[OVS_KEY_ATTR_MAX + 1];
+       u64 attrs = 0;
+       int err;
+       struct sw_flow_match match;
 
        flow->key.phy.in_port = DP_MAX_PORTS;
        flow->key.phy.priority = 0;
        flow->key.phy.skb_mark = 0;
        memset(tun_key, 0, sizeof(flow->key.tun_key));
 
-       nla_for_each_nested(nla, attr, rem) {
-               int type = nla_type(nla);
-
-               if (type <= OVS_KEY_ATTR_MAX && ovs_key_lens[type] > 0) {
-                       int err;
-
-                       if (nla_len(nla) != ovs_key_lens[type])
-                               return -EINVAL;
-
-                       switch (type) {
-                       case OVS_KEY_ATTR_PRIORITY:
-                               flow->key.phy.priority = nla_get_u32(nla);
-                               break;
-
-                       case OVS_KEY_ATTR_TUNNEL:
-                               err = ovs_ipv4_tun_from_nlattr(nla, tun_key);
-                               if (err)
-                                       return err;
-                               break;
-
-                       case OVS_KEY_ATTR_IN_PORT:
-                               if (nla_get_u32(nla) >= DP_MAX_PORTS)
-                                       return -EINVAL;
-                               flow->key.phy.in_port = nla_get_u32(nla);
-                               break;
-
-                       case OVS_KEY_ATTR_SKB_MARK:
-                               flow->key.phy.skb_mark = nla_get_u32(nla);
-                               break;
-                       }
-               }
-       }
-       if (rem)
+       err = parse_flow_nlattrs(attr, a, &attrs);
+       if (err)
                return -EINVAL;
 
-       flow->hash = ovs_flow_hash(&flow->key,
-                                  flow_key_start(&flow->key), key_len);
+       memset(&match, 0, sizeof(match));
+       match.key = &flow->key;
+
+       err = metadata_from_nlattrs(&match, &attrs, a, false);
+       if (err)
+               return err;
 
        return 0;
 }
 
-int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
+int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey,
+               const struct sw_flow_key *output, struct sk_buff *skb)
 {
        struct ovs_key_ethernet *eth_key;
        struct nlattr *nla, *encap;
+       bool is_mask = (swkey != output);
 
-       if (swkey->phy.priority &&
-           nla_put_u32(skb, OVS_KEY_ATTR_PRIORITY, swkey->phy.priority))
+       if (nla_put_u32(skb, OVS_KEY_ATTR_PRIORITY, output->phy.priority))
                goto nla_put_failure;
 
-       if (swkey->tun_key.ipv4_dst &&
-           ovs_ipv4_tun_to_nlattr(skb, &swkey->tun_key))
+       if ((swkey->tun_key.ipv4_dst || is_mask) &&
+           ovs_ipv4_tun_to_nlattr(skb, &swkey->tun_key, &output->tun_key))
                goto nla_put_failure;
 
-       if (swkey->phy.in_port != DP_MAX_PORTS &&
-           nla_put_u32(skb, OVS_KEY_ATTR_IN_PORT, swkey->phy.in_port))
-               goto nla_put_failure;
+       if (swkey->phy.in_port == DP_MAX_PORTS) {
+               if (is_mask && (output->phy.in_port == 0xffff))
+                       if (nla_put_u32(skb, OVS_KEY_ATTR_IN_PORT, 0xffffffff))
+                               goto nla_put_failure;
+       } else {
+               u16 upper_u16;
+               upper_u16 = !is_mask ? 0 : 0xffff;
 
-       if (swkey->phy.skb_mark &&
-           nla_put_u32(skb, OVS_KEY_ATTR_SKB_MARK, swkey->phy.skb_mark))
+               if (nla_put_u32(skb, OVS_KEY_ATTR_IN_PORT,
+                               (upper_u16 << 16) | output->phy.in_port))
+                       goto nla_put_failure;
+       }
+
+       if (nla_put_u32(skb, OVS_KEY_ATTR_SKB_MARK, output->phy.skb_mark))
                goto nla_put_failure;
 
        nla = nla_reserve(skb, OVS_KEY_ATTR_ETHERNET, sizeof(*eth_key));
        if (!nla)
                goto nla_put_failure;
+
        eth_key = nla_data(nla);
-       memcpy(eth_key->eth_src, swkey->eth.src, ETH_ALEN);
-       memcpy(eth_key->eth_dst, swkey->eth.dst, ETH_ALEN);
+       memcpy(eth_key->eth_src, output->eth.src, ETH_ALEN);
+       memcpy(eth_key->eth_dst, output->eth.dst, ETH_ALEN);
 
        if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
-               if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, htons(ETH_P_8021Q)) ||
-                   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, swkey->eth.tci))
+               __be16 eth_type;
+               eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0xffff);
+               if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
+                   nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.tci))
                        goto nla_put_failure;
                encap = nla_nest_start(skb, OVS_KEY_ATTR_ENCAP);
                if (!swkey->eth.tci)
                        goto unencap;
-       } else {
+       } else
                encap = NULL;
-       }
 
-       if (swkey->eth.type == htons(ETH_P_802_2))
+       if (swkey->eth.type == htons(ETH_P_802_2)) {
+               /*
+                * Ethertype 802.2 is represented in the netlink with omitted
+                * OVS_KEY_ATTR_ETHERTYPE in the flow key attribute, and
+                * 0xffff in the mask attribute.  Ethertype can also
+                * be wildcarded.
+                */
+               if (is_mask && output->eth.type)
+                       if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
+                                               output->eth.type))
+                               goto nla_put_failure;
                goto unencap;
+       }
 
-       if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, swkey->eth.type))
+       if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, output->eth.type))
                goto nla_put_failure;
 
        if (swkey->eth.type == htons(ETH_P_IP)) {
@@ -1369,12 +1845,12 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                if (!nla)
                        goto nla_put_failure;
                ipv4_key = nla_data(nla);
-               ipv4_key->ipv4_src = swkey->ipv4.addr.src;
-               ipv4_key->ipv4_dst = swkey->ipv4.addr.dst;
-               ipv4_key->ipv4_proto = swkey->ip.proto;
-               ipv4_key->ipv4_tos = swkey->ip.tos;
-               ipv4_key->ipv4_ttl = swkey->ip.ttl;
-               ipv4_key->ipv4_frag = swkey->ip.frag;
+               ipv4_key->ipv4_src = output->ipv4.addr.src;
+               ipv4_key->ipv4_dst = output->ipv4.addr.dst;
+               ipv4_key->ipv4_proto = output->ip.proto;
+               ipv4_key->ipv4_tos = output->ip.tos;
+               ipv4_key->ipv4_ttl = output->ip.ttl;
+               ipv4_key->ipv4_frag = output->ip.frag;
        } else if (swkey->eth.type == htons(ETH_P_IPV6)) {
                struct ovs_key_ipv6 *ipv6_key;
 
@@ -1382,15 +1858,15 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                if (!nla)
                        goto nla_put_failure;
                ipv6_key = nla_data(nla);
-               memcpy(ipv6_key->ipv6_src, &swkey->ipv6.addr.src,
+               memcpy(ipv6_key->ipv6_src, &output->ipv6.addr.src,
                                sizeof(ipv6_key->ipv6_src));
-               memcpy(ipv6_key->ipv6_dst, &swkey->ipv6.addr.dst,
+               memcpy(ipv6_key->ipv6_dst, &output->ipv6.addr.dst,
                                sizeof(ipv6_key->ipv6_dst));
-               ipv6_key->ipv6_label = swkey->ipv6.label;
-               ipv6_key->ipv6_proto = swkey->ip.proto;
-               ipv6_key->ipv6_tclass = swkey->ip.tos;
-               ipv6_key->ipv6_hlimit = swkey->ip.ttl;
-               ipv6_key->ipv6_frag = swkey->ip.frag;
+               ipv6_key->ipv6_label = output->ipv6.label;
+               ipv6_key->ipv6_proto = output->ip.proto;
+               ipv6_key->ipv6_tclass = output->ip.tos;
+               ipv6_key->ipv6_hlimit = output->ip.ttl;
+               ipv6_key->ipv6_frag = output->ip.frag;
        } else if (swkey->eth.type == htons(ETH_P_ARP) ||
                   swkey->eth.type == htons(ETH_P_RARP)) {
                struct ovs_key_arp *arp_key;
@@ -1400,11 +1876,11 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                        goto nla_put_failure;
                arp_key = nla_data(nla);
                memset(arp_key, 0, sizeof(struct ovs_key_arp));
-               arp_key->arp_sip = swkey->ipv4.addr.src;
-               arp_key->arp_tip = swkey->ipv4.addr.dst;
-               arp_key->arp_op = htons(swkey->ip.proto);
-               memcpy(arp_key->arp_sha, swkey->ipv4.arp.sha, ETH_ALEN);
-               memcpy(arp_key->arp_tha, swkey->ipv4.arp.tha, ETH_ALEN);
+               arp_key->arp_sip = output->ipv4.addr.src;
+               arp_key->arp_tip = output->ipv4.addr.dst;
+               arp_key->arp_op = htons(output->ip.proto);
+               memcpy(arp_key->arp_sha, output->ipv4.arp.sha, ETH_ALEN);
+               memcpy(arp_key->arp_tha, output->ipv4.arp.tha, ETH_ALEN);
        }
 
        if ((swkey->eth.type == htons(ETH_P_IP) ||
@@ -1419,11 +1895,11 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                                goto nla_put_failure;
                        tcp_key = nla_data(nla);
                        if (swkey->eth.type == htons(ETH_P_IP)) {
-                               tcp_key->tcp_src = swkey->ipv4.tp.src;
-                               tcp_key->tcp_dst = swkey->ipv4.tp.dst;
+                               tcp_key->tcp_src = output->ipv4.tp.src;
+                               tcp_key->tcp_dst = output->ipv4.tp.dst;
                        } else if (swkey->eth.type == htons(ETH_P_IPV6)) {
-                               tcp_key->tcp_src = swkey->ipv6.tp.src;
-                               tcp_key->tcp_dst = swkey->ipv6.tp.dst;
+                               tcp_key->tcp_src = output->ipv6.tp.src;
+                               tcp_key->tcp_dst = output->ipv6.tp.dst;
                        }
                } else if (swkey->ip.proto == IPPROTO_UDP) {
                        struct ovs_key_udp *udp_key;
@@ -1433,11 +1909,25 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                                goto nla_put_failure;
                        udp_key = nla_data(nla);
                        if (swkey->eth.type == htons(ETH_P_IP)) {
-                               udp_key->udp_src = swkey->ipv4.tp.src;
-                               udp_key->udp_dst = swkey->ipv4.tp.dst;
+                               udp_key->udp_src = output->ipv4.tp.src;
+                               udp_key->udp_dst = output->ipv4.tp.dst;
+                       } else if (swkey->eth.type == htons(ETH_P_IPV6)) {
+                               udp_key->udp_src = output->ipv6.tp.src;
+                               udp_key->udp_dst = output->ipv6.tp.dst;
+                       }
+               } else if (swkey->ip.proto == IPPROTO_SCTP) {
+                       struct ovs_key_sctp *sctp_key;
+
+                       nla = nla_reserve(skb, OVS_KEY_ATTR_SCTP, sizeof(*sctp_key));
+                       if (!nla)
+                               goto nla_put_failure;
+                       sctp_key = nla_data(nla);
+                       if (swkey->eth.type == htons(ETH_P_IP)) {
+                               sctp_key->sctp_src = swkey->ipv4.tp.src;
+                               sctp_key->sctp_dst = swkey->ipv4.tp.dst;
                        } else if (swkey->eth.type == htons(ETH_P_IPV6)) {
-                               udp_key->udp_src = swkey->ipv6.tp.src;
-                               udp_key->udp_dst = swkey->ipv6.tp.dst;
+                               sctp_key->sctp_src = swkey->ipv6.tp.src;
+                               sctp_key->sctp_dst = swkey->ipv6.tp.dst;
                        }
                } else if (swkey->eth.type == htons(ETH_P_IP) &&
                           swkey->ip.proto == IPPROTO_ICMP) {
@@ -1447,8 +1937,8 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                        if (!nla)
                                goto nla_put_failure;
                        icmp_key = nla_data(nla);
-                       icmp_key->icmp_type = ntohs(swkey->ipv4.tp.src);
-                       icmp_key->icmp_code = ntohs(swkey->ipv4.tp.dst);
+                       icmp_key->icmp_type = ntohs(output->ipv4.tp.src);
+                       icmp_key->icmp_code = ntohs(output->ipv4.tp.dst);
                } else if (swkey->eth.type == htons(ETH_P_IPV6) &&
                           swkey->ip.proto == IPPROTO_ICMPV6) {
                        struct ovs_key_icmpv6 *icmpv6_key;
@@ -1458,8 +1948,8 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                        if (!nla)
                                goto nla_put_failure;
                        icmpv6_key = nla_data(nla);
-                       icmpv6_key->icmpv6_type = ntohs(swkey->ipv6.tp.src);
-                       icmpv6_key->icmpv6_code = ntohs(swkey->ipv6.tp.dst);
+                       icmpv6_key->icmpv6_type = ntohs(output->ipv6.tp.src);
+                       icmpv6_key->icmpv6_code = ntohs(output->ipv6.tp.dst);
 
                        if (icmpv6_key->icmpv6_type == NDISC_NEIGHBOUR_SOLICITATION ||
                            icmpv6_key->icmpv6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
@@ -1469,10 +1959,10 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb)
                                if (!nla)
                                        goto nla_put_failure;
                                nd_key = nla_data(nla);
-                               memcpy(nd_key->nd_target, &swkey->ipv6.nd.target,
+                               memcpy(nd_key->nd_target, &output->ipv6.nd.target,
                                                        sizeof(nd_key->nd_target));
-                               memcpy(nd_key->nd_sll, swkey->ipv6.nd.sll, ETH_ALEN);
-                               memcpy(nd_key->nd_tll, swkey->ipv6.nd.tll, ETH_ALEN);
+                               memcpy(nd_key->nd_sll, output->ipv6.nd.sll, ETH_ALEN);
+                               memcpy(nd_key->nd_tll, output->ipv6.nd.tll, ETH_ALEN);
                        }
                }
        }
@@ -1491,6 +1981,8 @@ nla_put_failure:
  * Returns zero if successful or a negative error code. */
 int ovs_flow_init(void)
 {
+       BUILD_BUG_ON(sizeof(struct sw_flow_key) % sizeof(long));
+
        flow_cache = kmem_cache_create("sw_flow", sizeof(struct sw_flow), 0,
                                        0, NULL);
        if (flow_cache == NULL)
@@ -1504,3 +1996,84 @@ void ovs_flow_exit(void)
 {
        kmem_cache_destroy(flow_cache);
 }
+
+struct sw_flow_mask *ovs_sw_flow_mask_alloc(void)
+{
+       struct sw_flow_mask *mask;
+
+       mask = kmalloc(sizeof(*mask), GFP_KERNEL);
+       if (mask)
+               mask->ref_count = 0;
+
+       return mask;
+}
+
+void ovs_sw_flow_mask_add_ref(struct sw_flow_mask *mask)
+{
+       mask->ref_count++;
+}
+
+void ovs_sw_flow_mask_del_ref(struct sw_flow_mask *mask, bool deferred)
+{
+       if (!mask)
+               return;
+
+       BUG_ON(!mask->ref_count);
+       mask->ref_count--;
+
+       if (!mask->ref_count) {
+               list_del_rcu(&mask->list);
+               if (deferred)
+                       kfree_rcu(mask, rcu);
+               else
+                       kfree(mask);
+       }
+}
+
+static bool ovs_sw_flow_mask_equal(const struct sw_flow_mask *a,
+               const struct sw_flow_mask *b)
+{
+       u8 *a_ = (u8 *)&a->key + a->range.start;
+       u8 *b_ = (u8 *)&b->key + b->range.start;
+
+       return  (a->range.end == b->range.end)
+               && (a->range.start == b->range.start)
+               && (memcmp(a_, b_, range_n_bytes(&a->range)) == 0);
+}
+
+struct sw_flow_mask *ovs_sw_flow_mask_find(const struct flow_table *tbl,
+                                           const struct sw_flow_mask *mask)
+{
+       struct list_head *ml;
+
+       list_for_each(ml, tbl->mask_list) {
+               struct sw_flow_mask *m;
+               m = container_of(ml, struct sw_flow_mask, list);
+               if (ovs_sw_flow_mask_equal(mask, m))
+                       return m;
+       }
+
+       return NULL;
+}
+
+/**
+ * add a new mask into the mask list.
+ * The caller needs to make sure that 'mask' is not the same
+ * as any masks that are already on the list.
+ */
+void ovs_sw_flow_mask_insert(struct flow_table *tbl, struct sw_flow_mask *mask)
+{
+       list_add_rcu(&mask->list, tbl->mask_list);
+}
+
+/**
+ * Set 'range' fields in the mask to the value of 'val'.
+ */
+static void ovs_sw_flow_mask_set(struct sw_flow_mask *mask,
+               struct sw_flow_key_range *range, u8 val)
+{
+       u8 *m = (u8 *)&mask->key + range->start;
+
+       mask->range = *range;
+       memset(m, val, range_n_bytes(range));
+}
index 66ef7220293eab573f176d70878f7d6698e68a13..b65f885ac3dcc59468235d4aa4d64a6d047b406c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2011 Nicira, Inc.
+ * Copyright (c) 2007-2013 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -33,6 +33,8 @@
 #include <net/inet_ecn.h>
 
 struct sk_buff;
+struct sw_flow_mask;
+struct flow_table;
 
 struct sw_flow_actions {
        struct rcu_head rcu;
@@ -97,8 +99,8 @@ struct sw_flow_key {
                        } addr;
                        union {
                                struct {
-                                       __be16 src;             /* TCP/UDP source port. */
-                                       __be16 dst;             /* TCP/UDP destination port. */
+                                       __be16 src;             /* TCP/UDP/SCTP source port. */
+                                       __be16 dst;             /* TCP/UDP/SCTP destination port. */
                                } tp;
                                struct {
                                        u8 sha[ETH_ALEN];       /* ARP source hardware address. */
@@ -113,8 +115,8 @@ struct sw_flow_key {
                        } addr;
                        __be32 label;                   /* IPv6 flow label. */
                        struct {
-                               __be16 src;             /* TCP/UDP source port. */
-                               __be16 dst;             /* TCP/UDP destination port. */
+                               __be16 src;             /* TCP/UDP/SCTP source port. */
+                               __be16 dst;             /* TCP/UDP/SCTP destination port. */
                        } tp;
                        struct {
                                struct in6_addr target; /* ND target address. */
@@ -123,7 +125,7 @@ struct sw_flow_key {
                        } nd;
                } ipv6;
        };
-};
+} __aligned(__alignof__(long));
 
 struct sw_flow {
        struct rcu_head rcu;
@@ -131,6 +133,8 @@ struct sw_flow {
        u32 hash;
 
        struct sw_flow_key key;
+       struct sw_flow_key unmasked_key;
+       struct sw_flow_mask *mask;
        struct sw_flow_actions __rcu *sf_acts;
 
        spinlock_t lock;        /* Lock for values below. */
@@ -140,6 +144,20 @@ struct sw_flow {
        u8 tcp_flags;           /* Union of seen TCP flags. */
 };
 
+struct sw_flow_key_range {
+       size_t start;
+       size_t end;
+};
+
+struct sw_flow_match {
+       struct sw_flow_key *key;
+       struct sw_flow_key_range range;
+       struct sw_flow_mask *mask;
+};
+
+void ovs_match_init(struct sw_flow_match *match,
+               struct sw_flow_key *key, struct sw_flow_mask *mask);
+
 struct arp_eth_header {
        __be16      ar_hrd;     /* format of hardware address   */
        __be16      ar_pro;     /* format of protocol address   */
@@ -159,21 +177,21 @@ void ovs_flow_exit(void);
 
 struct sw_flow *ovs_flow_alloc(void);
 void ovs_flow_deferred_free(struct sw_flow *);
-void ovs_flow_free(struct sw_flow *flow);
+void ovs_flow_free(struct sw_flow *, bool deferred);
 
 struct sw_flow_actions *ovs_flow_actions_alloc(int actions_len);
 void ovs_flow_deferred_free_acts(struct sw_flow_actions *);
 
-int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *,
-                    int *key_lenp);
+int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *);
 void ovs_flow_used(struct sw_flow *, struct sk_buff *);
 u64 ovs_flow_used_time(unsigned long flow_jiffies);
-
-int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *);
-int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp,
+int ovs_flow_to_nlattrs(const struct sw_flow_key *,
+               const struct sw_flow_key *, struct sk_buff *);
+int ovs_match_from_nlattrs(struct sw_flow_match *match,
+                     const struct nlattr *,
                      const struct nlattr *);
-int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow, int key_len,
-                                 const struct nlattr *attr);
+int ovs_flow_metadata_from_nlattrs(struct sw_flow *flow,
+               const struct nlattr *attr);
 
 #define MAX_ACTIONS_BUFSIZE    (32 * 1024)
 #define TBL_MIN_BUCKETS                1024
@@ -182,6 +200,7 @@ struct flow_table {
        struct flex_array *buckets;
        unsigned int count, n_buckets;
        struct rcu_head rcu;
+       struct list_head *mask_list;
        int node_ver;
        u32 hash_seed;
        bool keep_flows;
@@ -197,22 +216,44 @@ static inline int ovs_flow_tbl_need_to_expand(struct flow_table *table)
        return (table->count > table->n_buckets);
 }
 
-struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *table,
-                                   struct sw_flow_key *key, int len);
-void ovs_flow_tbl_destroy(struct flow_table *table);
-void ovs_flow_tbl_deferred_destroy(struct flow_table *table);
+struct sw_flow *ovs_flow_lookup(struct flow_table *,
+                               const struct sw_flow_key *);
+struct sw_flow *ovs_flow_lookup_unmasked_key(struct flow_table *table,
+                                   struct sw_flow_match *match);
+
+void ovs_flow_tbl_destroy(struct flow_table *table, bool deferred);
 struct flow_table *ovs_flow_tbl_alloc(int new_size);
 struct flow_table *ovs_flow_tbl_expand(struct flow_table *table);
 struct flow_table *ovs_flow_tbl_rehash(struct flow_table *table);
-void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
-                        struct sw_flow_key *key, int key_len);
-void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
 
-struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx);
+void ovs_flow_insert(struct flow_table *table, struct sw_flow *flow);
+void ovs_flow_remove(struct flow_table *table, struct sw_flow *flow);
+
+struct sw_flow *ovs_flow_dump_next(struct flow_table *table, u32 *bucket, u32 *idx);
 extern const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1];
 int ovs_ipv4_tun_from_nlattr(const struct nlattr *attr,
-                        struct ovs_key_ipv4_tunnel *tun_key);
+                            struct sw_flow_match *match, bool is_mask);
 int ovs_ipv4_tun_to_nlattr(struct sk_buff *skb,
-                       const struct ovs_key_ipv4_tunnel *tun_key);
+                          const struct ovs_key_ipv4_tunnel *tun_key,
+                          const struct ovs_key_ipv4_tunnel *output);
+
+bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
+               const struct sw_flow_key *key, int key_end);
+
+struct sw_flow_mask {
+       int ref_count;
+       struct rcu_head rcu;
+       struct list_head list;
+       struct sw_flow_key_range range;
+       struct sw_flow_key key;
+};
 
+struct sw_flow_mask *ovs_sw_flow_mask_alloc(void);
+void ovs_sw_flow_mask_add_ref(struct sw_flow_mask *);
+void ovs_sw_flow_mask_del_ref(struct sw_flow_mask *, bool deferred);
+void ovs_sw_flow_mask_insert(struct flow_table *, struct sw_flow_mask *);
+struct sw_flow_mask *ovs_sw_flow_mask_find(const struct flow_table *,
+               const struct sw_flow_mask *);
+void ovs_flow_key_mask(struct sw_flow_key *dst, const struct sw_flow_key *src,
+                      const struct sw_flow_mask *mask);
 #endif /* flow.h */
index 493e9775dcdadb90ea383a26403d8bd11fc6face..21d5073e148e11005e9dfe9ca9411e1001ec0ab6 100644 (file)
@@ -16,7 +16,6 @@
  * 02110-1301, USA
  */
 
-#ifdef CONFIG_OPENVSWITCH_GRE
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/if.h>
@@ -271,5 +270,3 @@ const struct vport_ops ovs_gre_vport_ops = {
        .get_name       = gre_get_name,
        .send           = gre_tnl_send,
 };
-
-#endif /* OPENVSWITCH_GRE */
index 5982f3f62835359765c3b1f822f69053e2da4b90..09d93c13cfd69a295d533cad35ab857c9eeee2f0 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/llc.h>
 #include <linux/rtnetlink.h>
 #include <linux/skbuff.h>
+#include <linux/openvswitch.h>
 
 #include <net/llc.h>
 
@@ -74,6 +75,15 @@ static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb)
        return RX_HANDLER_CONSUMED;
 }
 
+static struct net_device *get_dpdev(struct datapath *dp)
+{
+       struct vport *local;
+
+       local = ovs_vport_ovsl(dp, OVSP_LOCAL);
+       BUG_ON(!local);
+       return netdev_vport_priv(local)->dev;
+}
+
 static struct vport *netdev_create(const struct vport_parms *parms)
 {
        struct vport *vport;
@@ -103,10 +113,15 @@ static struct vport *netdev_create(const struct vport_parms *parms)
        }
 
        rtnl_lock();
+       err = netdev_master_upper_dev_link(netdev_vport->dev,
+                                          get_dpdev(vport->dp));
+       if (err)
+               goto error_unlock;
+
        err = netdev_rx_handler_register(netdev_vport->dev, netdev_frame_hook,
                                         vport);
        if (err)
-               goto error_unlock;
+               goto error_master_upper_dev_unlink;
 
        dev_set_promiscuity(netdev_vport->dev, 1);
        netdev_vport->dev->priv_flags |= IFF_OVS_DATAPATH;
@@ -114,6 +129,8 @@ static struct vport *netdev_create(const struct vport_parms *parms)
 
        return vport;
 
+error_master_upper_dev_unlink:
+       netdev_upper_dev_unlink(netdev_vport->dev, get_dpdev(vport->dp));
 error_unlock:
        rtnl_unlock();
 error_put:
@@ -140,6 +157,7 @@ static void netdev_destroy(struct vport *vport)
        rtnl_lock();
        netdev_vport->dev->priv_flags &= ~IFF_OVS_DATAPATH;
        netdev_rx_handler_unregister(netdev_vport->dev);
+       netdev_upper_dev_unlink(netdev_vport->dev, get_dpdev(vport->dp));
        dev_set_promiscuity(netdev_vport->dev, -1);
        rtnl_unlock();
 
diff --git a/net/openvswitch/vport-vxlan.c b/net/openvswitch/vport-vxlan.c
new file mode 100644 (file)
index 0000000..36848bd
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2013 Nicira, Inc.
+ * Copyright (c) 2013 Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/net.h>
+#include <linux/rculist.h>
+#include <linux/udp.h>
+
+#include <net/icmp.h>
+#include <net/ip.h>
+#include <net/udp.h>
+#include <net/ip_tunnels.h>
+#include <net/udp.h>
+#include <net/rtnetlink.h>
+#include <net/route.h>
+#include <net/dsfield.h>
+#include <net/inet_ecn.h>
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
+#include <net/vxlan.h>
+
+#include "datapath.h"
+#include "vport.h"
+
+/**
+ * struct vxlan_port - Keeps track of open UDP ports
+ * @vs: vxlan_sock created for the port.
+ * @name: vport name.
+ */
+struct vxlan_port {
+       struct vxlan_sock *vs;
+       char name[IFNAMSIZ];
+};
+
+static inline struct vxlan_port *vxlan_vport(const struct vport *vport)
+{
+       return vport_priv(vport);
+}
+
+/* Called with rcu_read_lock and BH disabled. */
+static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, __be32 vx_vni)
+{
+       struct ovs_key_ipv4_tunnel tun_key;
+       struct vport *vport = vs->data;
+       struct iphdr *iph;
+       __be64 key;
+
+       /* Save outer tunnel values */
+       iph = ip_hdr(skb);
+       key = cpu_to_be64(ntohl(vx_vni) >> 8);
+       ovs_flow_tun_key_init(&tun_key, iph, key, TUNNEL_KEY);
+
+       ovs_vport_receive(vport, skb, &tun_key);
+}
+
+static int vxlan_get_options(const struct vport *vport, struct sk_buff *skb)
+{
+       struct vxlan_port *vxlan_port = vxlan_vport(vport);
+       __be16 dst_port = inet_sk(vxlan_port->vs->sock->sk)->inet_sport;
+
+       if (nla_put_u16(skb, OVS_TUNNEL_ATTR_DST_PORT, ntohs(dst_port)))
+               return -EMSGSIZE;
+       return 0;
+}
+
+static void vxlan_tnl_destroy(struct vport *vport)
+{
+       struct vxlan_port *vxlan_port = vxlan_vport(vport);
+
+       vxlan_sock_release(vxlan_port->vs);
+
+       ovs_vport_deferred_free(vport);
+}
+
+static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
+{
+       struct net *net = ovs_dp_get_net(parms->dp);
+       struct nlattr *options = parms->options;
+       struct vxlan_port *vxlan_port;
+       struct vxlan_sock *vs;
+       struct vport *vport;
+       struct nlattr *a;
+       u16 dst_port;
+       int err;
+
+       if (!options) {
+               err = -EINVAL;
+               goto error;
+       }
+       a = nla_find_nested(options, OVS_TUNNEL_ATTR_DST_PORT);
+       if (a && nla_len(a) == sizeof(u16)) {
+               dst_port = nla_get_u16(a);
+       } else {
+               /* Require destination port from userspace. */
+               err = -EINVAL;
+               goto error;
+       }
+
+       vport = ovs_vport_alloc(sizeof(struct vxlan_port),
+                               &ovs_vxlan_vport_ops, parms);
+       if (IS_ERR(vport))
+               return vport;
+
+       vxlan_port = vxlan_vport(vport);
+       strncpy(vxlan_port->name, parms->name, IFNAMSIZ);
+
+       vs = vxlan_sock_add(net, htons(dst_port), vxlan_rcv, vport, true);
+       if (IS_ERR(vs)) {
+               ovs_vport_free(vport);
+               return (void *)vs;
+       }
+       vxlan_port->vs = vs;
+
+       return vport;
+
+error:
+       return ERR_PTR(err);
+}
+
+static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
+{
+       struct net *net = ovs_dp_get_net(vport->dp);
+       struct vxlan_port *vxlan_port = vxlan_vport(vport);
+       __be16 dst_port = inet_sk(vxlan_port->vs->sock->sk)->inet_sport;
+       struct rtable *rt;
+       struct flowi4 fl;
+       __be16 src_port;
+       int port_min;
+       int port_max;
+       __be16 df;
+       int err;
+
+       if (unlikely(!OVS_CB(skb)->tun_key)) {
+               err = -EINVAL;
+               goto error;
+       }
+
+       /* Route lookup */
+       memset(&fl, 0, sizeof(fl));
+       fl.daddr = OVS_CB(skb)->tun_key->ipv4_dst;
+       fl.saddr = OVS_CB(skb)->tun_key->ipv4_src;
+       fl.flowi4_tos = RT_TOS(OVS_CB(skb)->tun_key->ipv4_tos);
+       fl.flowi4_mark = skb->mark;
+       fl.flowi4_proto = IPPROTO_UDP;
+
+       rt = ip_route_output_key(net, &fl);
+       if (IS_ERR(rt)) {
+               err = PTR_ERR(rt);
+               goto error;
+       }
+
+       df = OVS_CB(skb)->tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ?
+               htons(IP_DF) : 0;
+
+       skb->local_df = 1;
+
+       inet_get_local_port_range(&port_min, &port_max);
+       src_port = vxlan_src_port(port_min, port_max, skb);
+
+       err = vxlan_xmit_skb(net, vxlan_port->vs, rt, skb,
+                            fl.saddr, OVS_CB(skb)->tun_key->ipv4_dst,
+                            OVS_CB(skb)->tun_key->ipv4_tos,
+                            OVS_CB(skb)->tun_key->ipv4_ttl, df,
+                            src_port, dst_port,
+                            htonl(be64_to_cpu(OVS_CB(skb)->tun_key->tun_id) << 8));
+       if (err < 0)
+               ip_rt_put(rt);
+error:
+       return err;
+}
+
+static const char *vxlan_get_name(const struct vport *vport)
+{
+       struct vxlan_port *vxlan_port = vxlan_vport(vport);
+       return vxlan_port->name;
+}
+
+const struct vport_ops ovs_vxlan_vport_ops = {
+       .type           = OVS_VPORT_TYPE_VXLAN,
+       .create         = vxlan_tnl_create,
+       .destroy        = vxlan_tnl_destroy,
+       .get_name       = vxlan_get_name,
+       .get_options    = vxlan_get_options,
+       .send           = vxlan_tnl_send,
+};
index d4c7fa04ce08c2a148c01488d518776c4fcbb066..6f65dbe13812b15208e71745f4744db76e22c532 100644 (file)
@@ -42,6 +42,9 @@ static const struct vport_ops *vport_ops_list[] = {
 #ifdef CONFIG_OPENVSWITCH_GRE
        &ovs_gre_vport_ops,
 #endif
+#ifdef CONFIG_OPENVSWITCH_VXLAN
+       &ovs_vxlan_vport_ops,
+#endif
 };
 
 /* Protected by RCU read lock for reading, ovs_mutex for writing. */
@@ -200,7 +203,7 @@ out:
  *     ovs_vport_set_options - modify existing vport device (for kernel callers)
  *
  * @vport: vport to modify.
- * @port: New configuration.
+ * @options: New configuration.
  *
  * Modifies an existing device with the specified configuration (which is
  * dependent on device type).  ovs_mutex must be held.
@@ -325,6 +328,7 @@ int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb)
  *
  * @vport: vport that received the packet
  * @skb: skb that was received
+ * @tun_key: tunnel (if any) that carried packet
  *
  * Must be called with rcu_read_lock.  The packet cannot be shared and
  * skb->data should point to the Ethernet header.
index 376045c42f8b43ba156acb2fd723398b108208b6..1a9fbcec6e1bf9c1d9bc95a3ec9d711c02865a82 100644 (file)
@@ -199,6 +199,7 @@ void ovs_vport_record_error(struct vport *, enum vport_err_type err_type);
 extern const struct vport_ops ovs_netdev_vport_ops;
 extern const struct vport_ops ovs_internal_vport_ops;
 extern const struct vport_ops ovs_gre_vport_ops;
+extern const struct vport_ops ovs_vxlan_vport_ops;
 
 static inline void ovs_skb_postpush_rcsum(struct sk_buff *skb,
                                      const void *start, unsigned int len)
index 4b66c752eae5d99b2bfe5fa7832a1301d20519ef..1fdf9ab91c3fad327c4cd14bd67ed328fde93be7 100644 (file)
@@ -2181,7 +2181,7 @@ static struct sk_buff *packet_alloc_skb(struct sock *sk, size_t prepad,
                linear = len;
 
        skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
-                                  err);
+                                  err, 0);
        if (!skb)
                return NULL;
 
@@ -2638,51 +2638,6 @@ out:
        return err;
 }
 
-static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
-{
-       struct sock_exterr_skb *serr;
-       struct sk_buff *skb, *skb2;
-       int copied, err;
-
-       err = -EAGAIN;
-       skb = skb_dequeue(&sk->sk_error_queue);
-       if (skb == NULL)
-               goto out;
-
-       copied = skb->len;
-       if (copied > len) {
-               msg->msg_flags |= MSG_TRUNC;
-               copied = len;
-       }
-       err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
-       if (err)
-               goto out_free_skb;
-
-       sock_recv_timestamp(msg, sk, skb);
-
-       serr = SKB_EXT_ERR(skb);
-       put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
-                sizeof(serr->ee), &serr->ee);
-
-       msg->msg_flags |= MSG_ERRQUEUE;
-       err = copied;
-
-       /* Reset and regenerate socket error */
-       spin_lock_bh(&sk->sk_error_queue.lock);
-       sk->sk_err = 0;
-       if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) {
-               sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno;
-               spin_unlock_bh(&sk->sk_error_queue.lock);
-               sk->sk_error_report(sk);
-       } else
-               spin_unlock_bh(&sk->sk_error_queue.lock);
-
-out_free_skb:
-       kfree_skb(skb);
-out:
-       return err;
-}
-
 /*
  *     Pull a packet from our receive queue and hand it to the user.
  *     If necessary we block.
@@ -2708,7 +2663,8 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
 #endif
 
        if (flags & MSG_ERRQUEUE) {
-               err = packet_recv_error(sk, msg, len);
+               err = sock_recv_errqueue(sk, msg, len,
+                                        SOL_PACKET, PACKET_TX_TIMESTAMP);
                goto out;
        }
 
@@ -3259,9 +3215,11 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
 
                if (po->tp_version == TPACKET_V3) {
                        lv = sizeof(struct tpacket_stats_v3);
+                       st.stats3.tp_packets += st.stats3.tp_drops;
                        data = &st.stats3;
                } else {
                        lv = sizeof(struct tpacket_stats);
+                       st.stats1.tp_packets += st.stats1.tp_drops;
                        data = &st.stats1;
                }
 
index 1afd1381cdc75a576bffaac360685e3ab7bfa6d4..77e38f733496c407f2b8a351fac733d3195a655a 100644 (file)
@@ -793,7 +793,7 @@ static int pn_res_seq_show(struct seq_file *seq, void *v)
                struct sock **psk = v;
                struct sock *sk = *psk;
 
-               seq_printf(seq, "%02X %5d %lu%n",
+               seq_printf(seq, "%02X %5u %lu%n",
                           (int) (psk - pnres.sk),
                           from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
                           sock_i_ino(sk), &len);
index 281c1bded1f60f94934e406c9cafe076e4e2706d..51b968d3febb477be1e4183c8a94258c97fdcd18 100644 (file)
@@ -285,6 +285,45 @@ static struct Qdisc_ops *qdisc_lookup_ops(struct nlattr *kind)
        return q;
 }
 
+/* The linklayer setting were not transferred from iproute2, in older
+ * versions, and the rate tables lookup systems have been dropped in
+ * the kernel. To keep backward compatible with older iproute2 tc
+ * utils, we detect the linklayer setting by detecting if the rate
+ * table were modified.
+ *
+ * For linklayer ATM table entries, the rate table will be aligned to
+ * 48 bytes, thus some table entries will contain the same value.  The
+ * mpu (min packet unit) is also encoded into the old rate table, thus
+ * starting from the mpu, we find low and high table entries for
+ * mapping this cell.  If these entries contain the same value, when
+ * the rate tables have been modified for linklayer ATM.
+ *
+ * This is done by rounding mpu to the nearest 48 bytes cell/entry,
+ * and then roundup to the next cell, calc the table entry one below,
+ * and compare.
+ */
+static __u8 __detect_linklayer(struct tc_ratespec *r, __u32 *rtab)
+{
+       int low       = roundup(r->mpu, 48);
+       int high      = roundup(low+1, 48);
+       int cell_low  = low >> r->cell_log;
+       int cell_high = (high >> r->cell_log) - 1;
+
+       /* rtab is too inaccurate at rates > 100Mbit/s */
+       if ((r->rate > (100000000/8)) || (rtab[0] == 0)) {
+               pr_debug("TC linklayer: Giving up ATM detection\n");
+               return TC_LINKLAYER_ETHERNET;
+       }
+
+       if ((cell_high > cell_low) && (cell_high < 256)
+           && (rtab[cell_low] == rtab[cell_high])) {
+               pr_debug("TC linklayer: Detected ATM, low(%d)=high(%d)=%u\n",
+                        cell_low, cell_high, rtab[cell_high]);
+               return TC_LINKLAYER_ATM;
+       }
+       return TC_LINKLAYER_ETHERNET;
+}
+
 static struct qdisc_rate_table *qdisc_rtab_list;
 
 struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *tab)
@@ -308,6 +347,8 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *ta
                rtab->rate = *r;
                rtab->refcnt = 1;
                memcpy(rtab->data, nla_data(tab), 1024);
+               if (r->linklayer == TC_LINKLAYER_UNAWARE)
+                       r->linklayer = __detect_linklayer(r, rtab->data);
                rtab->next = qdisc_rtab_list;
                qdisc_rtab_list = rtab;
        }
index ca8e0a57d945dabeb51147f338cef363672040d5..1f9c31411f1998dec927fccf05362f09408558b4 100644 (file)
@@ -605,6 +605,7 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
                struct sockaddr_atmpvc pvc;
                int state;
 
+               memset(&pvc, 0, sizeof(pvc));
                pvc.sap_family = AF_ATMPVC;
                pvc.sap_addr.itf = flow->vcc->dev ? flow->vcc->dev->number : -1;
                pvc.sap_addr.vpi = flow->vcc->vpi;
index 71a568862557c26cb9fd97bfbd26531b55ad4283..7a42c81a19ebe55f0b6a137f89c55b46314f8cd7 100644 (file)
@@ -1465,6 +1465,7 @@ static int cbq_dump_wrr(struct sk_buff *skb, struct cbq_class *cl)
        unsigned char *b = skb_tail_pointer(skb);
        struct tc_cbq_wrropt opt;
 
+       memset(&opt, 0, sizeof(opt));
        opt.flags = 0;
        opt.allot = cl->allot;
        opt.priority = cl->priority + 1;
index 4626cef4b76ea631e32d082d34828ffd2e465459..48be3d5c0d9246117c03b0174da16a637129640c 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/rcupdate.h>
 #include <linux/list.h>
 #include <linux/slab.h>
+#include <linux/if_vlan.h>
 #include <net/sch_generic.h>
 #include <net/pkt_sched.h>
 #include <net/dst.h>
@@ -207,15 +208,19 @@ void __qdisc_run(struct Qdisc *q)
 
 unsigned long dev_trans_start(struct net_device *dev)
 {
-       unsigned long val, res = dev->trans_start;
+       unsigned long val, res;
        unsigned int i;
 
+       if (is_vlan_dev(dev))
+               dev = vlan_dev_real_dev(dev);
+       res = dev->trans_start;
        for (i = 0; i < dev->num_tx_queues; i++) {
                val = netdev_get_tx_queue(dev, i)->trans_start;
                if (val && time_after(val, res))
                        res = val;
        }
        dev->trans_start = res;
+
        return res;
 }
 EXPORT_SYMBOL(dev_trans_start);
@@ -904,6 +909,7 @@ void psched_ratecfg_precompute(struct psched_ratecfg *r,
        memset(r, 0, sizeof(*r));
        r->overhead = conf->overhead;
        r->rate_bytes_ps = conf->rate;
+       r->linklayer = (conf->linklayer & TC_LINKLAYER_MASK);
        r->mult = 1;
        /*
         * The deal here is to replace a divide by a reciprocal one
index c2124ea29f4594304c3b7ecb02af411ed62fbebe..c2178b15ca6e0bb0ed60eb885cc94177fd5b8e95 100644 (file)
@@ -100,7 +100,7 @@ struct htb_class {
        struct psched_ratecfg   ceil;
        s64                     buffer, cbuffer;/* token bucket depth/rate */
        s64                     mbuffer;        /* max wait time */
-       int                     prio;           /* these two are used only by leaves... */
+       u32                     prio;           /* these two are used only by leaves... */
        int                     quantum;        /* but stored for parent-to-leaf return */
 
        struct tcf_proto        *filter_list;   /* class attached filters */
@@ -1329,6 +1329,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
        struct htb_sched *q = qdisc_priv(sch);
        struct htb_class *cl = (struct htb_class *)*arg, *parent;
        struct nlattr *opt = tca[TCA_OPTIONS];
+       struct qdisc_rate_table *rtab = NULL, *ctab = NULL;
        struct nlattr *tb[TCA_HTB_MAX + 1];
        struct tc_htb_opt *hopt;
 
@@ -1350,6 +1351,18 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
        if (!hopt->rate.rate || !hopt->ceil.rate)
                goto failure;
 
+       /* Keeping backward compatible with rate_table based iproute2 tc */
+       if (hopt->rate.linklayer == TC_LINKLAYER_UNAWARE) {
+               rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB]);
+               if (rtab)
+                       qdisc_put_rtab(rtab);
+       }
+       if (hopt->ceil.linklayer == TC_LINKLAYER_UNAWARE) {
+               ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB]);
+               if (ctab)
+                       qdisc_put_rtab(ctab);
+       }
+
        if (!cl) {              /* new class */
                struct Qdisc *new_q;
                int prio;
index 82f6016d89abac391a8f0c03fdda7be6db2372b7..a6d788d45216a6f286e5aaea0cdb0587cd0f7848 100644 (file)
@@ -412,12 +412,9 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 
        /* If a delay is expected, orphan the skb. (orphaning usually takes
         * place at TX completion time, so _before_ the link transit delay)
-        * Ideally, this orphaning should be done after the rate limiting
-        * module, because this breaks TCP Small Queue, and other mechanisms
-        * based on socket sk_wmem_alloc.
         */
        if (q->latency || q->jitter)
-               skb_orphan(skb);
+               skb_orphan_partial(skb);
 
        /*
         * If we need to duplicate packet, then re-insert at top of the
index a7ab323849b616a152fb1332e2eabc63126b5aab..8056fb4e618a9bab5ce231ee86ac87db11ffdda7 100644 (file)
 
 #define FRAC_BITS              30      /* fixed point arithmetic */
 #define ONE_FP                 (1UL << FRAC_BITS)
-#define IWSUM                  (ONE_FP/QFQ_MAX_WSUM)
 
 #define QFQ_MTU_SHIFT          16      /* to support TSO/GSO */
 #define QFQ_MIN_LMAX           512     /* see qfq_slot_insert */
@@ -189,6 +188,7 @@ struct qfq_sched {
        struct qfq_aggregate    *in_serv_agg;   /* Aggregate being served. */
        u32                     num_active_agg; /* Num. of active aggregates */
        u32                     wsum;           /* weight sum */
+       u32                     iwsum;          /* inverse weight sum */
 
        unsigned long bitmaps[QFQ_MAX_STATE];       /* Group bitmaps. */
        struct qfq_group groups[QFQ_MAX_INDEX + 1]; /* The groups. */
@@ -314,6 +314,7 @@ static void qfq_update_agg(struct qfq_sched *q, struct qfq_aggregate *agg,
 
        q->wsum +=
                (int) agg->class_weight * (new_num_classes - agg->num_classes);
+       q->iwsum = ONE_FP / q->wsum;
 
        agg->num_classes = new_num_classes;
 }
@@ -340,6 +341,10 @@ static void qfq_destroy_agg(struct qfq_sched *q, struct qfq_aggregate *agg)
 {
        if (!hlist_unhashed(&agg->nonfull_next))
                hlist_del_init(&agg->nonfull_next);
+       q->wsum -= agg->class_weight;
+       if (q->wsum != 0)
+               q->iwsum = ONE_FP / q->wsum;
+
        if (q->in_serv_agg == agg)
                q->in_serv_agg = qfq_choose_next_agg(q);
        kfree(agg);
@@ -834,38 +839,60 @@ static void qfq_make_eligible(struct qfq_sched *q)
        }
 }
 
-
 /*
- * The index of the slot in which the aggregate is to be inserted must
- * not be higher than QFQ_MAX_SLOTS-2. There is a '-2' and not a '-1'
- * because the start time of the group may be moved backward by one
- * slot after the aggregate has been inserted, and this would cause
- * non-empty slots to be right-shifted by one position.
+ * The index of the slot in which the input aggregate agg is to be
+ * inserted must not be higher than QFQ_MAX_SLOTS-2. There is a '-2'
+ * and not a '-1' because the start time of the group may be moved
+ * backward by one slot after the aggregate has been inserted, and
+ * this would cause non-empty slots to be right-shifted by one
+ * position.
+ *
+ * QFQ+ fully satisfies this bound to the slot index if the parameters
+ * of the classes are not changed dynamically, and if QFQ+ never
+ * happens to postpone the service of agg unjustly, i.e., it never
+ * happens that the aggregate becomes backlogged and eligible, or just
+ * eligible, while an aggregate with a higher approximated finish time
+ * is being served. In particular, in this case QFQ+ guarantees that
+ * the timestamps of agg are low enough that the slot index is never
+ * higher than 2. Unfortunately, QFQ+ cannot provide the same
+ * guarantee if it happens to unjustly postpone the service of agg, or
+ * if the parameters of some class are changed.
+ *
+ * As for the first event, i.e., an out-of-order service, the
+ * upper bound to the slot index guaranteed by QFQ+ grows to
+ * 2 +
+ * QFQ_MAX_AGG_CLASSES * ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) *
+ * (current_max_weight/current_wsum) <= 2 + 8 * 128 * 1.
  *
- * If the weight and lmax (max_pkt_size) of the classes do not change,
- * then QFQ+ does meet the above contraint according to the current
- * values of its parameters. In fact, if the weight and lmax of the
- * classes do not change, then, from the theory, QFQ+ guarantees that
- * the slot index is never higher than
- * 2 + QFQ_MAX_AGG_CLASSES * ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) *
- * (QFQ_MAX_WEIGHT/QFQ_MAX_WSUM) = 2 + 8 * 128 * (1 / 64) = 18
+ * The following function deals with this problem by backward-shifting
+ * the timestamps of agg, if needed, so as to guarantee that the slot
+ * index is never higher than QFQ_MAX_SLOTS-2. This backward-shift may
+ * cause the service of other aggregates to be postponed, yet the
+ * worst-case guarantees of these aggregates are not violated.  In
+ * fact, in case of no out-of-order service, the timestamps of agg
+ * would have been even lower than they are after the backward shift,
+ * because QFQ+ would have guaranteed a maximum value equal to 2 for
+ * the slot index, and 2 < QFQ_MAX_SLOTS-2. Hence the aggregates whose
+ * service is postponed because of the backward-shift would have
+ * however waited for the service of agg before being served.
  *
- * When the weight of a class is increased or the lmax of the class is
- * decreased, a new aggregate with smaller slot size than the original
- * parent aggregate of the class may happen to be activated. The
- * activation of this aggregate should be properly delayed to when the
- * service of the class has finished in the ideal system tracked by
- * QFQ+. If the activation of the aggregate is not delayed to this
- * reference time instant, then this aggregate may be unjustly served
- * before other aggregates waiting for service. This may cause the
- * above bound to the slot index to be violated for some of these
- * unlucky aggregates.
+ * The other event that may cause the slot index to be higher than 2
+ * for agg is a recent change of the parameters of some class. If the
+ * weight of a class is increased or the lmax (max_pkt_size) of the
+ * class is decreased, then a new aggregate with smaller slot size
+ * than the original parent aggregate of the class may happen to be
+ * activated. The activation of this aggregate should be properly
+ * delayed to when the service of the class has finished in the ideal
+ * system tracked by QFQ+. If the activation of the aggregate is not
+ * delayed to this reference time instant, then this aggregate may be
+ * unjustly served before other aggregates waiting for service. This
+ * may cause the above bound to the slot index to be violated for some
+ * of these unlucky aggregates.
  *
  * Instead of delaying the activation of the new aggregate, which is
- * quite complex, the following inaccurate but simple solution is used:
- * if the slot index is higher than QFQ_MAX_SLOTS-2, then the
- * timestamps of the aggregate are shifted backward so as to let the
- * slot index become equal to QFQ_MAX_SLOTS-2.
+ * quite complex, the above-discussed capping of the slot index is
+ * used to handle also the consequences of a change of the parameters
+ * of a class.
  */
 static void qfq_slot_insert(struct qfq_group *grp, struct qfq_aggregate *agg,
                            u64 roundedS)
@@ -1136,7 +1163,7 @@ static struct sk_buff *qfq_dequeue(struct Qdisc *sch)
        else
                in_serv_agg->budget -= len;
 
-       q->V += (u64)len * IWSUM;
+       q->V += (u64)len * q->iwsum;
        pr_debug("qfq dequeue: len %u F %lld now %lld\n",
                 len, (unsigned long long) in_serv_agg->F,
                 (unsigned long long) q->V);
index bce5b79662a62b8bdc5e7c895a6ea4bcd147ed86..cef509985192a041f8d437adc35cd540e32f58bd 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -43,9 +40,6 @@
  *    Daisy Chang          <daisyc@us.ibm.com>
  *    Ryan Layer           <rmlayer@us.ibm.com>
  *    Kevin Gao             <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -846,12 +840,12 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
                else
                        spc_state = SCTP_ADDR_AVAILABLE;
                /* Don't inform ULP about transition from PF to
-                * active state and set cwnd to 1, see SCTP
+                * active state and set cwnd to 1 MTU, see SCTP
                 * Quick failover draft section 5.1, point 5
                 */
                if (transport->state == SCTP_PF) {
                        ulp_notify = false;
-                       transport->cwnd = 1;
+                       transport->cwnd = asoc->pathmtu;
                }
                transport->state = SCTP_ACTIVE;
                break;
index ba1dfc3f8def25701bca3546c883677b03088f5f..8c4fa5dec8245e984ddf637134ca82265c5ddfe5 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *   Vlad Yasevich     <vladislav.yasevich@hp.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/slab.h>
index 64977ea0f9c55e02988377ef6e2de73693607dea..077bb070052bac32e551cef707b0a6d6e3f65511 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Karl Knutson          <karl@athena.chicago.il.us>
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    Daisy Chang           <daisyc@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
index 5780565f5b7d0c885faacf86d96a742e1ebbdae5..bd0bdd0ba8f1ca956f8ec4f61c409f089ac6cbd9 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index c0044019db9eca2b84eaa9b11f28500bf0fb4086..3d9a9ff69c036e6f83d3b85470458647f413bf5c 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Karl Knutson <karl@athena.chicago.il.us>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
index f4998780d6df1171f4f1e616fc328dd92431c030..e89015d8935a160f3e0f3e571a976d1cd4823993 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -40,9 +37,6 @@
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    Daisy Chang          <daisyc@us.ibm.com>
  *    Sridhar Samudrala            <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <net/sctp/sctp.h>
index 9e3d257de0e0814274cf852ae883835bb4c72eac..09b8daac87c8039f2c5b33e04b109a44e6006038 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -40,9 +37,6 @@
  *    Jon Grimm <jgrimm@austin.ibm.com>
  *    Daisy Chang <daisyc@us.ibm.com>
  *    Dajiang Zhang <dajiang.zhang@nokia.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
index 3fa4d858c35a508b56cf56bce9a3c0078c6379c0..5f2068679f8339b8a85b85cf2dc7b185a663dd9c 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -43,9 +40,6 @@
  *    Daisy Chang <daisyc@us.ibm.com>
  *    Sridhar Samudrala <sri@us.ibm.com>
  *    Ardelle Fan <ardelle.fan@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
@@ -87,15 +81,7 @@ static inline int sctp_rcv_checksum(struct net *net, struct sk_buff *skb)
 {
        struct sctphdr *sh = sctp_hdr(skb);
        __le32 cmp = sh->checksum;
-       struct sk_buff *list;
-       __le32 val;
-       __u32 tmp = sctp_start_cksum((__u8 *)sh, skb_headlen(skb));
-
-       skb_walk_frags(skb, list)
-               tmp = sctp_update_cksum((__u8 *)list->data, skb_headlen(list),
-                                       tmp);
-
-       val = sctp_end_cksum(tmp);
+       __le32 val = sctp_compute_cksum(skb, 0);
 
        if (val != cmp) {
                /* CRC failure, dump it. */
index cb25f040fed03d85d7bf7b9b7248678655e1a716..5856932fdc38906ae78b3da2e170f0699634b24e 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Karl Knutson <karl@athena.chicago.il.us>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index 09ffcc912d236426b5c5f7724d7145db31b061bf..da613ceae28cc95b38dc1a3d7366c2f38b348d9b 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Le Yanqun                    <yanqun.le@nokia.com>
@@ -42,9 +39,6 @@
  *
  * Based on:
  *     linux/net/ipv6/tcp_ipv6.c
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -351,7 +345,7 @@ out:
 
                rt = (struct rt6_info *)dst;
                t->dst = dst;
-
+               t->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
                pr_debug("rt6_dst:%pI6 rt6_src:%pI6\n", &rt->rt6i_dst.addr,
                         &fl6->saddr);
        } else {
index fe012c44f8dff15e4882165e2718b11f919cf260..5ea573b37648b2591341b980c3ff1ab1632d202d 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Jon Grimm             <jgrimm@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index a46d1eb41762801e2d95011bf3af8327c57ebac2..0ac3a65daccb71cd78ae5e2c52696c33df7e16e4 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Karl Knutson          <karl@athena.chicago.il.us>
  *    Jon Grimm             <jgrimm@austin.ibm.com>
  *    Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index ef9e2bbc0f2f8d1dc497166b16bb6ea1d96c1124..94df7587786992fa0a6341caaed284beb1df42e0 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -41,9 +38,6 @@
  *    Hui Huang            <hui.huang@nokia.com>
  *    Sridhar Samudrala     <sri@us.ibm.com>
  *    Jon Grimm             <jgrimm@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index 794bb14decdea60ec58e68a59bc5a6b2feda4a01..ce1ffd811775b414b4d79f3a7b55a5145d599bc9 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -40,9 +37,6 @@
  *    Karl Knutson          <karl@athena.chicago.il.us>
  *    Ardelle Fan          <ardelle.fan@intel.com>
  *    Kevin Gao             <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
index e62c22535be424cc53311dfc5b8f4540faa47e59..cd72ae57aff13e9b5f26b3ebba2109480bc0223d 100644 (file)
@@ -155,13 +155,8 @@ static sctp_disposition_t jsctp_sf_eat_sack(struct net *net,
                        if (sp == asoc->peer.primary_path)
                                printl("*");
 
-                       if (sp->ipaddr.sa.sa_family == AF_INET)
-                               printl("%pI4 ", &sp->ipaddr.v4.sin_addr);
-                       else
-                               printl("%pI6 ", &sp->ipaddr.v6.sin6_addr);
-
-                       printl("%2u %8u %8u %8u %8u %8u ",
-                              sp->state, sp->cwnd, sp->ssthresh,
+                       printl("%pISc %2u %8u %8u %8u %8u %8u ",
+                              &sp->ipaddr, sp->state, sp->cwnd, sp->ssthresh,
                               sp->flight_size, sp->partial_bytes_acked,
                               sp->pathmtu);
                }
index 62526c4770505e0f741123bd009e91a90781f587..0c06421568427e4995ea0798c9ca8535ca5ff9b5 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Sridhar Samudrala <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
@@ -232,7 +226,7 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
                sk = epb->sk;
                if (!net_eq(sock_net(sk), seq_file_net(seq)))
                        continue;
-               seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
+               seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5u %5lu ", ep, sk,
                           sctp_sk(sk)->type, sk->sk_state, hash,
                           epb->bind_addr.port,
                           from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
@@ -342,7 +336,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
                        continue;
                seq_printf(seq,
                           "%8pK %8pK %-3d %-3d %-2d %-4d "
-                          "%4d %8d %8d %7d %5lu %-5d %5d ",
+                          "%4d %8d %8d %7u %5lu %-5d %5d ",
                           assoc, sk, sctp_sk(sk)->type, sk->sk_state,
                           assoc->state, hash,
                           assoc->assoc_id,
index 4a17494d736c4b6a50f0e838971204e1e901de43..5e17092f4adacbf0335dc33bcbde5a1f830b43df 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -41,9 +38,6 @@
  *    Sridhar Samudrala <sri@us.ibm.com>
  *    Daisy Chang <daisyc@us.ibm.com>
  *    Ardelle Fan <ardelle.fan@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -1547,7 +1541,7 @@ module_exit(sctp_exit);
  */
 MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-132");
 MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-132");
-MODULE_AUTHOR("Linux Kernel SCTP developers <lksctp-developers@lists.sourceforge.net>");
+MODULE_AUTHOR("Linux Kernel SCTP developers <linux-sctp@vger.kernel.org>");
 MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)");
 module_param_named(no_checksums, sctp_checksum_disable, bool, 0644);
 MODULE_PARM_DESC(no_checksums, "Disable checksums computing and verification");
index 362ae6e2fd93a6e145fefb15e5f6e5cf4579204b..01e97836ca6c95ddd378dbd4c9fec09041c4fc26 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -45,9 +42,6 @@
  *    Daisy Chang          <daisyc@us.ibm.com>
  *    Ardelle Fan          <ardelle.fan@intel.com>
  *    Kevin Gao             <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
 
-static struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
-                                         __u8 type, __u8 flags, int paylen);
+static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc,
+                                           __u8 type, __u8 flags, int paylen);
+static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc,
+                                        __u8 flags, int paylen);
+static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
+                                          __u8 type, __u8 flags, int paylen);
 static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
                                        const struct sctp_association *asoc,
                                        const struct sctp_chunk *init_chunk,
@@ -82,6 +80,28 @@ static int sctp_process_param(struct sctp_association *asoc,
 static void *sctp_addto_param(struct sctp_chunk *chunk, int len,
                              const void *data);
 
+/* Control chunk destructor */
+static void sctp_control_release_owner(struct sk_buff *skb)
+{
+       /*TODO: do memory release */
+}
+
+static void sctp_control_set_owner_w(struct sctp_chunk *chunk)
+{
+       struct sctp_association *asoc = chunk->asoc;
+       struct sk_buff *skb = chunk->skb;
+
+       /* TODO: properly account for control chunks.
+        * To do it right we'll need:
+        *  1) endpoint if association isn't known.
+        *  2) proper memory accounting.
+        *
+        *  For now don't do anything for now.
+        */
+       skb->sk = asoc ? asoc->base.sk : NULL;
+       skb->destructor = sctp_control_release_owner;
+}
+
 /* What was the inbound interface for this chunk? */
 int sctp_chunk_iif(const struct sctp_chunk *chunk)
 {
@@ -296,7 +316,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
         * PLEASE DO NOT FIXME [This version does not support Host Name.]
         */
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_INIT, 0, chunksize);
+       retval = sctp_make_control(asoc, SCTP_CID_INIT, 0, chunksize);
        if (!retval)
                goto nodata;
 
@@ -443,7 +463,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
                                        num_ext);
 
        /* Now allocate and fill out the chunk.  */
-       retval = sctp_make_chunk(asoc, SCTP_CID_INIT_ACK, 0, chunksize);
+       retval = sctp_make_control(asoc, SCTP_CID_INIT_ACK, 0, chunksize);
        if (!retval)
                goto nomem_chunk;
 
@@ -548,7 +568,7 @@ struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *asoc,
        cookie_len = asoc->peer.cookie_len;
 
        /* Build a cookie echo chunk.  */
-       retval = sctp_make_chunk(asoc, SCTP_CID_COOKIE_ECHO, 0, cookie_len);
+       retval = sctp_make_control(asoc, SCTP_CID_COOKIE_ECHO, 0, cookie_len);
        if (!retval)
                goto nodata;
        retval->subh.cookie_hdr =
@@ -593,7 +613,7 @@ struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
 {
        struct sctp_chunk *retval;
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_COOKIE_ACK, 0, 0);
+       retval = sctp_make_control(asoc, SCTP_CID_COOKIE_ACK, 0, 0);
 
        /* RFC 2960 6.4 Multi-homed SCTP Endpoints
         *
@@ -641,8 +661,8 @@ struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc,
        sctp_cwrhdr_t cwr;
 
        cwr.lowest_tsn = htonl(lowest_tsn);
-       retval = sctp_make_chunk(asoc, SCTP_CID_ECN_CWR, 0,
-                                sizeof(sctp_cwrhdr_t));
+       retval = sctp_make_control(asoc, SCTP_CID_ECN_CWR, 0,
+                                  sizeof(sctp_cwrhdr_t));
 
        if (!retval)
                goto nodata;
@@ -675,8 +695,8 @@ struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc,
        sctp_ecnehdr_t ecne;
 
        ecne.lowest_tsn = htonl(lowest_tsn);
-       retval = sctp_make_chunk(asoc, SCTP_CID_ECN_ECNE, 0,
-                                sizeof(sctp_ecnehdr_t));
+       retval = sctp_make_control(asoc, SCTP_CID_ECN_ECNE, 0,
+                                  sizeof(sctp_ecnehdr_t));
        if (!retval)
                goto nodata;
        retval->subh.ecne_hdr =
@@ -712,7 +732,7 @@ struct sctp_chunk *sctp_make_datafrag_empty(struct sctp_association *asoc,
                dp.ssn = htons(ssn);
 
        chunk_len = sizeof(dp) + data_len;
-       retval = sctp_make_chunk(asoc, SCTP_CID_DATA, flags, chunk_len);
+       retval = sctp_make_data(asoc, flags, chunk_len);
        if (!retval)
                goto nodata;
 
@@ -759,7 +779,7 @@ struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc)
                + sizeof(__u32) * num_dup_tsns;
 
        /* Create the chunk.  */
-       retval = sctp_make_chunk(asoc, SCTP_CID_SACK, 0, len);
+       retval = sctp_make_control(asoc, SCTP_CID_SACK, 0, len);
        if (!retval)
                goto nodata;
 
@@ -838,8 +858,8 @@ struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc,
        ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);
        shut.cum_tsn_ack = htonl(ctsn);
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_SHUTDOWN, 0,
-                                sizeof(sctp_shutdownhdr_t));
+       retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN, 0,
+                                  sizeof(sctp_shutdownhdr_t));
        if (!retval)
                goto nodata;
 
@@ -857,7 +877,7 @@ struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,
 {
        struct sctp_chunk *retval;
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_SHUTDOWN_ACK, 0, 0);
+       retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_ACK, 0, 0);
 
        /* RFC 2960 6.4 Multi-homed SCTP Endpoints
         *
@@ -886,7 +906,7 @@ struct sctp_chunk *sctp_make_shutdown_complete(
         */
        flags |= asoc ? 0 : SCTP_CHUNK_FLAG_T;
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_SHUTDOWN_COMPLETE, flags, 0);
+       retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_COMPLETE, flags, 0);
 
        /* RFC 2960 6.4 Multi-homed SCTP Endpoints
         *
@@ -925,7 +945,7 @@ struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc,
                        flags = SCTP_CHUNK_FLAG_T;
        }
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_ABORT, flags, hint);
+       retval = sctp_make_control(asoc, SCTP_CID_ABORT, flags, hint);
 
        /* RFC 2960 6.4 Multi-homed SCTP Endpoints
         *
@@ -1117,7 +1137,7 @@ struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
        struct sctp_chunk *retval;
        sctp_sender_hb_info_t hbinfo;
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_HEARTBEAT, 0, sizeof(hbinfo));
+       retval = sctp_make_control(asoc, SCTP_CID_HEARTBEAT, 0, sizeof(hbinfo));
 
        if (!retval)
                goto nodata;
@@ -1145,7 +1165,7 @@ struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *asoc,
 {
        struct sctp_chunk *retval;
 
-       retval  = sctp_make_chunk(asoc, SCTP_CID_HEARTBEAT_ACK, 0, paylen);
+       retval  = sctp_make_control(asoc, SCTP_CID_HEARTBEAT_ACK, 0, paylen);
        if (!retval)
                goto nodata;
 
@@ -1177,8 +1197,8 @@ static struct sctp_chunk *sctp_make_op_error_space(
 {
        struct sctp_chunk *retval;
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_ERROR, 0,
-                                sizeof(sctp_errhdr_t) + size);
+       retval = sctp_make_control(asoc, SCTP_CID_ERROR, 0,
+                                  sizeof(sctp_errhdr_t) + size);
        if (!retval)
                goto nodata;
 
@@ -1248,7 +1268,7 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc)
        if (unlikely(!hmac_desc))
                return NULL;
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_AUTH, 0,
+       retval = sctp_make_control(asoc, SCTP_CID_AUTH, 0,
                        hmac_desc->hmac_len + sizeof(sctp_authhdr_t));
        if (!retval)
                return NULL;
@@ -1351,8 +1371,8 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk)
 /* Create a new chunk, setting the type and flags headers from the
  * arguments, reserving enough space for a 'paylen' byte payload.
  */
-static struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
-                                         __u8 type, __u8 flags, int paylen)
+static struct sctp_chunk *_sctp_make_chunk(const struct sctp_association *asoc,
+                                           __u8 type, __u8 flags, int paylen)
 {
        struct sctp_chunk *retval;
        sctp_chunkhdr_t *chunk_hdr;
@@ -1385,14 +1405,27 @@ static struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
        if (sctp_auth_send_cid(type, asoc))
                retval->auth = 1;
 
-       /* Set the skb to the belonging sock for accounting.  */
-       skb->sk = sk;
-
        return retval;
 nodata:
        return NULL;
 }
 
+static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc,
+                                        __u8 flags, int paylen)
+{
+       return _sctp_make_chunk(asoc, SCTP_CID_DATA, flags, paylen);
+}
+
+static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc,
+                                           __u8 type, __u8 flags, int paylen)
+{
+       struct sctp_chunk *chunk = _sctp_make_chunk(asoc, type, flags, paylen);
+
+       if (chunk)
+               sctp_control_set_owner_w(chunk);
+
+       return chunk;
+}
 
 /* Release the memory occupied by a chunk.  */
 static void sctp_chunk_destroy(struct sctp_chunk *chunk)
@@ -2733,7 +2766,7 @@ static struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc,
        length += addrlen;
 
        /* Create the chunk.  */
-       retval = sctp_make_chunk(asoc, SCTP_CID_ASCONF, 0, length);
+       retval = sctp_make_control(asoc, SCTP_CID_ASCONF, 0, length);
        if (!retval)
                return NULL;
 
@@ -2917,7 +2950,7 @@ static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *as
        int                     length = sizeof(asconf) + vparam_len;
 
        /* Create the chunk.  */
-       retval = sctp_make_chunk(asoc, SCTP_CID_ASCONF_ACK, 0, length);
+       retval = sctp_make_control(asoc, SCTP_CID_ASCONF_ACK, 0, length);
        if (!retval)
                return NULL;
 
@@ -3448,7 +3481,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
 
        hint = (nstreams + 1) * sizeof(__u32);
 
-       retval = sctp_make_chunk(asoc, SCTP_CID_FWD_TSN, 0, hint);
+       retval = sctp_make_control(asoc, SCTP_CID_FWD_TSN, 0, hint);
 
        if (!retval)
                return NULL;
index 9da68852ee94fbf0a7dcb02b61ba90700d18f77c..666c668427996903b9baf185a831c1c10c75d8cb 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -42,9 +39,6 @@
  *    Daisy Chang          <daisyc@us.ibm.com>
  *    Sridhar Samudrala            <sri@us.ibm.com>
  *    Ardelle Fan          <ardelle.fan@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index f6b7109195a629563b7a49a06e32847fd3b23984..dfe3f36ff2aa27165b35a39d382583759cd3ebae 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -45,9 +42,6 @@
  *    Ardelle Fan          <ardelle.fan@intel.com>
  *    Ryan Layer           <rmlayer@us.ibm.com>
  *    Kevin Gao                    <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index 84d98d8a5a7417bd92ea919c56e0f8033073a6c4..c5999b2dde7dfa5fcd53e68cf3d7791e838e602b 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -41,9 +38,6 @@
  *    Daisy Chang          <daisyc@us.ibm.com>
  *    Ardelle Fan          <ardelle.fan@intel.com>
  *    Sridhar Samudrala            <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index c6670d2e3f8d1bfa7c7fd0cef617de4944ca95e0..d5d5882a2891ac4c1047faa002375ba829598bb5 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -52,9 +49,6 @@
  *    Ryan Layer           <rmlayer@us.ibm.com>
  *    Anup Pemmaiah         <pemmaiah@cc.usu.edu>
  *    Kevin Gao             <kevin.gao@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index da860352380872ad1964af228906178bf8b56531..6007124aefa018fd958b9481e012f3db2df5a5da 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Jon Grimm             <jgrimm@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/types.h>
index 9a5c4c9eddafa0e4f91cabb56847c8c80bf8b59b..6b36561a1b3b7cceab5f5a4a9dce7aa2bc362266 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Mingqin Liu           <liuming@us.ibm.com>
@@ -36,9 +33,6 @@
  *    Ardelle Fan           <ardelle.fan@intel.com>
  *    Ryan Layer            <rmlayer@us.ibm.com>
  *    Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <net/sctp/structs.h>
index bdbbc3fd7c14e9fa2c31d4faf7de9b7b64540292..e332efb124cc0c34f93786232353c37dd2e10ea1 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
@@ -43,9 +40,6 @@
  *    Hui Huang             <hui.huang@nokia.com>
  *    Sridhar Samudrala            <sri@us.ibm.com>
  *    Ardelle Fan          <ardelle.fan@intel.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -181,12 +175,12 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
                return;
        }
 
-       call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
-
        sctp_packet_free(&transport->packet);
 
        if (transport->asoc)
                sctp_association_put(transport->asoc);
+
+       call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
 }
 
 /* Start T3_rtx timer if it is not already running and update the heartbeat
index b46019568a86d15c71dc805c8d1b3e560866d726..fbda20028285a8bb67c1052601a9986b90f50258 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    Karl Knutson          <karl@athena.chicago.il.us>
  *    Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/slab.h>
index 44a45dbee4df37e835b258cb551e333aeb7582b9..81089ed654564db6367c27f174c9b8381557c512 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Ardelle Fan          <ardelle.fan@intel.com>
  *    Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/slab.h>
index 04e3d470f877e51cc3238a3939595c1d90b83b37..1c1484ed605d490686c8daa87e0a7e595b9fba3c 100644 (file)
  *
  * Please send any bug reports or fixes you make to the
  * email address(es):
- *    lksctp developers <lksctp-developers@lists.sourceforge.net>
- *
- * Or submit a bug report through the following website:
- *    http://www.sf.net/projects/lksctp
+ *    lksctp developers <linux-sctp@vger.kernel.org>
  *
  * Written or modified by:
  *    Jon Grimm             <jgrimm@us.ibm.com>
  *    La Monte H.P. Yarroll <piggy@acm.org>
  *    Sridhar Samudrala     <sri@us.ibm.com>
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorporated into the next SCTP release.
  */
 
 #include <linux/slab.h>
index 829b460acb87e61e88928f596589b51b0947411d..b2d7c629eeb9f2de785600ed189080af9be02a3e 100644 (file)
 #include <linux/atalk.h>
 #include <net/busy_poll.h>
 
-#ifdef CONFIG_NET_LL_RX_POLL
+#ifdef CONFIG_NET_RX_BUSY_POLL
 unsigned int sysctl_net_busy_read __read_mostly;
 unsigned int sysctl_net_busy_poll __read_mostly;
 #endif
index d304f41260f2d8be4822631be5deb86612b63860..af7ffd447fee2af42a642c3e608536a8459ecbe5 100644 (file)
@@ -120,7 +120,7 @@ static int gssp_rpc_create(struct net *net, struct rpc_clnt **_clnt)
        if (IS_ERR(clnt)) {
                dprintk("RPC:       failed to create AF_LOCAL gssproxy "
                                "client (errno %ld).\n", PTR_ERR(clnt));
-               result = -PTR_ERR(clnt);
+               result = PTR_ERR(clnt);
                *_clnt = NULL;
                goto out;
        }
@@ -328,7 +328,6 @@ void gssp_free_upcall_data(struct gssp_upcall_data *data)
        kfree(data->in_handle.data);
        kfree(data->out_handle.data);
        kfree(data->out_token.data);
-       kfree(data->mech_oid.data);
        free_svc_cred(&data->creds);
 }
 
index 357f613df7ff49d3460e37d3f338cb89c7029a69..3c85d1c8a0288db543fdb5cbec9d9ef5bd0f2f22 100644 (file)
@@ -430,7 +430,7 @@ static int dummy_enc_nameattr_array(struct xdr_stream *xdr,
 static int dummy_dec_nameattr_array(struct xdr_stream *xdr,
                                    struct gssx_name_attr_array *naa)
 {
-       struct gssx_name_attr dummy;
+       struct gssx_name_attr dummy = { .attr = {.len = 0} };
        u32 count, i;
        __be32 *p;
 
@@ -493,12 +493,13 @@ static int gssx_enc_name(struct xdr_stream *xdr,
        return err;
 }
 
+
 static int gssx_dec_name(struct xdr_stream *xdr,
                         struct gssx_name *name)
 {
-       struct xdr_netobj dummy_netobj;
-       struct gssx_name_attr_array dummy_name_attr_array;
-       struct gssx_option_array dummy_option_array;
+       struct xdr_netobj dummy_netobj = { .len = 0 };
+       struct gssx_name_attr_array dummy_name_attr_array = { .count = 0 };
+       struct gssx_option_array dummy_option_array = { .count = 0 };
        int err;
 
        /* name->display_name */
index d0347d148b34320fb2a12a3ed20c6a2e5222352c..09fb638bcaa42ea88ff1bc7a6d34b6605f34a0c7 100644 (file)
@@ -1180,6 +1180,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
                gm = gss_mech_get_by_OID(&ud->mech_oid);
                if (!gm)
                        goto out;
+               rsci.cred.cr_gss_mech = gm;
 
                status = -EINVAL;
                /* mech-specific data: */
@@ -1195,7 +1196,6 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
        rscp = rsc_update(cd, &rsci, rscp);
        status = 0;
 out:
-       gss_mech_put(gm);
        rsc_free(&rsci);
        if (rscp)
                cache_put(&rscp->h, cd);
index 9963584605c06e06992fc1d4d1c0a608b360a74b..ecbc4e3d83ad3f816caa51b6ec942461dac9f090 100644 (file)
@@ -309,6 +309,7 @@ static int rpc_client_register(const struct rpc_create_args *args,
        return 0;
 err_auth:
        pipefs_sb = rpc_get_sb_net(net);
+       rpc_unregister_client(clnt);
        __rpc_clnt_remove_pipedir(clnt);
 out:
        if (pipefs_sb)
@@ -1659,6 +1660,10 @@ call_connect(struct rpc_task *task)
                task->tk_action = call_connect_status;
                if (task->tk_status < 0)
                        return;
+               if (task->tk_flags & RPC_TASK_NOCONNECT) {
+                       rpc_exit(task, -ENOTCONN);
+                       return;
+               }
                xprt_connect(task);
        }
 }
index 74d948f5d5a1d399d13061ee5c910c2cacc6f720..779742cfc1ffe3178fc0c320b6d0832e0f420d64 100644 (file)
@@ -23,6 +23,7 @@ struct sunrpc_net {
        struct rpc_clnt *rpcb_local_clnt4;
        spinlock_t rpcb_clnt_lock;
        unsigned int rpcb_users;
+       unsigned int rpcb_is_af_local : 1;
 
        struct mutex gssp_lock;
        wait_queue_head_t gssp_wq;
index 3df764dc330cbdb398e7dbbd5c6558d894bfc386..1891a1022c17e9d7d4c1686ff30c2ef13ebbf7b8 100644 (file)
@@ -204,13 +204,15 @@ void rpcb_put_local(struct net *net)
 }
 
 static void rpcb_set_local(struct net *net, struct rpc_clnt *clnt,
-                       struct rpc_clnt *clnt4)
+                       struct rpc_clnt *clnt4,
+                       bool is_af_local)
 {
        struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
 
        /* Protected by rpcb_create_local_mutex */
        sn->rpcb_local_clnt = clnt;
        sn->rpcb_local_clnt4 = clnt4;
+       sn->rpcb_is_af_local = is_af_local ? 1 : 0;
        smp_wmb(); 
        sn->rpcb_users = 1;
        dprintk("RPC:       created new rpcb local clients (rpcb_local_clnt: "
@@ -238,6 +240,14 @@ static int rpcb_create_local_unix(struct net *net)
                .program        = &rpcb_program,
                .version        = RPCBVERS_2,
                .authflavor     = RPC_AUTH_NULL,
+               /*
+                * We turn off the idle timeout to prevent the kernel
+                * from automatically disconnecting the socket.
+                * Otherwise, we'd have to cache the mount namespace
+                * of the caller and somehow pass that to the socket
+                * reconnect code.
+                */
+               .flags          = RPC_CLNT_CREATE_NO_IDLE_TIMEOUT,
        };
        struct rpc_clnt *clnt, *clnt4;
        int result = 0;
@@ -263,7 +273,7 @@ static int rpcb_create_local_unix(struct net *net)
                clnt4 = NULL;
        }
 
-       rpcb_set_local(net, clnt, clnt4);
+       rpcb_set_local(net, clnt, clnt4, true);
 
 out:
        return result;
@@ -315,7 +325,7 @@ static int rpcb_create_local_net(struct net *net)
                clnt4 = NULL;
        }
 
-       rpcb_set_local(net, clnt, clnt4);
+       rpcb_set_local(net, clnt, clnt4, false);
 
 out:
        return result;
@@ -376,13 +386,16 @@ static struct rpc_clnt *rpcb_create(struct net *net, const char *hostname,
        return rpc_create(&args);
 }
 
-static int rpcb_register_call(struct rpc_clnt *clnt, struct rpc_message *msg)
+static int rpcb_register_call(struct sunrpc_net *sn, struct rpc_clnt *clnt, struct rpc_message *msg, bool is_set)
 {
-       int result, error = 0;
+       int flags = RPC_TASK_NOCONNECT;
+       int error, result = 0;
 
+       if (is_set || !sn->rpcb_is_af_local)
+               flags = RPC_TASK_SOFTCONN;
        msg->rpc_resp = &result;
 
-       error = rpc_call_sync(clnt, msg, RPC_TASK_SOFTCONN);
+       error = rpc_call_sync(clnt, msg, flags);
        if (error < 0) {
                dprintk("RPC:       failed to contact local rpcbind "
                                "server (errno %d).\n", -error);
@@ -439,16 +452,19 @@ int rpcb_register(struct net *net, u32 prog, u32 vers, int prot, unsigned short
                .rpc_argp       = &map,
        };
        struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
+       bool is_set = false;
 
        dprintk("RPC:       %sregistering (%u, %u, %d, %u) with local "
                        "rpcbind\n", (port ? "" : "un"),
                        prog, vers, prot, port);
 
        msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET];
-       if (port)
+       if (port != 0) {
                msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET];
+               is_set = true;
+       }
 
-       return rpcb_register_call(sn->rpcb_local_clnt, &msg);
+       return rpcb_register_call(sn, sn->rpcb_local_clnt, &msg, is_set);
 }
 
 /*
@@ -461,6 +477,7 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,
        const struct sockaddr_in *sin = (const struct sockaddr_in *)sap;
        struct rpcbind_args *map = msg->rpc_argp;
        unsigned short port = ntohs(sin->sin_port);
+       bool is_set = false;
        int result;
 
        map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
@@ -471,10 +488,12 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,
                        map->r_addr, map->r_netid);
 
        msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
-       if (port)
+       if (port != 0) {
                msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
+               is_set = true;
+       }
 
-       result = rpcb_register_call(sn->rpcb_local_clnt4, msg);
+       result = rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, is_set);
        kfree(map->r_addr);
        return result;
 }
@@ -489,6 +508,7 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,
        const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap;
        struct rpcbind_args *map = msg->rpc_argp;
        unsigned short port = ntohs(sin6->sin6_port);
+       bool is_set = false;
        int result;
 
        map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
@@ -499,10 +519,12 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,
                        map->r_addr, map->r_netid);
 
        msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
-       if (port)
+       if (port != 0) {
                msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
+               is_set = true;
+       }
 
-       result = rpcb_register_call(sn->rpcb_local_clnt4, msg);
+       result = rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, is_set);
        kfree(map->r_addr);
        return result;
 }
@@ -519,7 +541,7 @@ static int rpcb_unregister_all_protofamilies(struct sunrpc_net *sn,
        map->r_addr = "";
        msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
 
-       return rpcb_register_call(sn->rpcb_local_clnt4, msg);
+       return rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, false);
 }
 
 /**
index 305374d4fb985ec4942040447f91e8d8277ea10d..9c9caaa5e0d3129f8872350ded706321fb2509c2 100644 (file)
@@ -442,7 +442,7 @@ static void svc_tcp_write_space(struct sock *sk)
 {
        struct socket *sock = sk->sk_socket;
 
-       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock)
+       if (sk_stream_is_writeable(sk) && sock)
                clear_bit(SOCK_NOSPACE, &sock->flags);
        svc_write_space(sk);
 }
@@ -1193,7 +1193,9 @@ static int svc_tcp_has_wspace(struct svc_xprt *xprt)
        if (test_bit(XPT_LISTENER, &xprt->xpt_flags))
                return 1;
        required = atomic_read(&xprt->xpt_reserved) + serv->sv_max_mesg;
-       if (sk_stream_wspace(svsk->sk_sk) >= required)
+       if (sk_stream_wspace(svsk->sk_sk) >= required ||
+           (sk_stream_min_wspace(svsk->sk_sk) == 0 &&
+            atomic_read(&xprt->xpt_reserved) == 0))
                return 1;
        set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
        return 0;
index 8d2edddf48cf13c6d283bd8784e61c7601f23fc7..65b146297f5acfa8f5ab08e4d6f1ae0df865b4f6 100644 (file)
@@ -98,6 +98,7 @@ void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *ch,
  */
 static u32 *decode_write_list(u32 *va, u32 *vaend)
 {
+       unsigned long start, end;
        int nchunks;
 
        struct rpcrdma_write_array *ary =
@@ -113,9 +114,12 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
                return NULL;
        }
        nchunks = ntohl(ary->wc_nchunks);
-       if (((unsigned long)&ary->wc_array[0] +
-            (sizeof(struct rpcrdma_write_chunk) * nchunks)) >
-           (unsigned long)vaend) {
+
+       start = (unsigned long)&ary->wc_array[0];
+       end = (unsigned long)vaend;
+       if (nchunks < 0 ||
+           nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
+           (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
                dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
                        ary, nchunks, vaend);
                return NULL;
@@ -129,6 +133,7 @@ static u32 *decode_write_list(u32 *va, u32 *vaend)
 
 static u32 *decode_reply_array(u32 *va, u32 *vaend)
 {
+       unsigned long start, end;
        int nchunks;
        struct rpcrdma_write_array *ary =
                (struct rpcrdma_write_array *)va;
@@ -143,9 +148,12 @@ static u32 *decode_reply_array(u32 *va, u32 *vaend)
                return NULL;
        }
        nchunks = ntohl(ary->wc_nchunks);
-       if (((unsigned long)&ary->wc_array[0] +
-            (sizeof(struct rpcrdma_write_chunk) * nchunks)) >
-           (unsigned long)vaend) {
+
+       start = (unsigned long)&ary->wc_array[0];
+       end = (unsigned long)vaend;
+       if (nchunks < 0 ||
+           nchunks > (SIZE_MAX - start) / sizeof(struct rpcrdma_write_chunk) ||
+           (start + (sizeof(struct rpcrdma_write_chunk) * nchunks)) > end) {
                dprintk("svcrdma: ary=%p, wc_nchunks=%d, vaend=%p\n",
                        ary, nchunks, vaend);
                return NULL;
index ddf0602603bdef4ac0a6ad29a9815bae56f04626..d6656d7768f4e689e94aca67189a0634bd950fad 100644 (file)
@@ -1602,7 +1602,7 @@ static void xs_tcp_write_space(struct sock *sk)
        read_lock_bh(&sk->sk_callback_lock);
 
        /* from net/core/stream.c:sk_stream_write_space */
-       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+       if (sk_stream_is_writeable(sk))
                xs_write_space(sk);
 
        read_unlock_bh(&sk->sk_callback_lock);
index cb29ef7ba2f0b1d285c079d87ddf8c5a07c118af..609c30c808165191a69899e750439666addc29f8 100644 (file)
@@ -460,6 +460,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
 {
        struct tipc_link *l_ptr;
        struct tipc_link *temp_l_ptr;
+       struct tipc_link_req *temp_req;
 
        pr_info("Disabling bearer <%s>\n", b_ptr->name);
        spin_lock_bh(&b_ptr->lock);
@@ -468,9 +469,13 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
        list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
                tipc_link_delete(l_ptr);
        }
-       if (b_ptr->link_req)
-               tipc_disc_delete(b_ptr->link_req);
+       temp_req = b_ptr->link_req;
+       b_ptr->link_req = NULL;
        spin_unlock_bh(&b_ptr->lock);
+
+       if (temp_req)
+               tipc_disc_delete(temp_req);
+
        memset(b_ptr, 0, sizeof(struct tipc_bearer));
 }
 
index 19da5abe0fa6fb1ebcf185357bd46489310d9dc7..fd3fa57a410e18393aa6cc20136fcaa28c0f7e22 100644 (file)
@@ -355,8 +355,12 @@ static int tipc_open_listening_sock(struct tipc_server *s)
                return PTR_ERR(con);
 
        sock = tipc_create_listen_sock(con);
-       if (!sock)
+       if (!sock) {
+               idr_remove(&s->conn_idr, con->conid);
+               s->idr_in_use--;
+               kfree(con);
                return -EINVAL;
+       }
 
        tipc_register_callbacks(sock, con);
        return 0;
@@ -563,9 +567,14 @@ int tipc_server_start(struct tipc_server *s)
                kmem_cache_destroy(s->rcvbuf_cache);
                return ret;
        }
+       ret = tipc_open_listening_sock(s);
+       if (ret < 0) {
+               tipc_work_stop(s);
+               kmem_cache_destroy(s->rcvbuf_cache);
+               return ret;
+       }
        s->enabled = 1;
-
-       return tipc_open_listening_sock(s);
+       return ret;
 }
 
 void tipc_server_stop(struct tipc_server *s)
index c4ce243824bb19c6e600dd98da2d8a6d16747dc1..86de99ad297605d04356f9efd7be174d2f7c7993 100644 (file)
@@ -1479,7 +1479,8 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
                                 MAX_SKB_FRAGS * PAGE_SIZE);
 
        skb = sock_alloc_send_pskb(sk, len - data_len, data_len,
-                                  msg->msg_flags & MSG_DONTWAIT, &err);
+                                  msg->msg_flags & MSG_DONTWAIT, &err,
+                                  PAGE_ALLOC_COSTLY_ORDER);
        if (skb == NULL)
                goto out;
 
@@ -1596,6 +1597,10 @@ out:
        return err;
 }
 
+/* We use paged skbs for stream sockets, and limit occupancy to 32768
+ * bytes, and a minimun of a full page.
+ */
+#define UNIX_SKB_FRAGS_SZ (PAGE_SIZE << get_order(32768))
 
 static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
                               struct msghdr *msg, size_t len)
@@ -1609,6 +1614,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
        struct scm_cookie tmp_scm;
        bool fds_sent = false;
        int max_level;
+       int data_len;
 
        if (NULL == siocb->scm)
                siocb->scm = &tmp_scm;
@@ -1635,40 +1641,22 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
                goto pipe_err;
 
        while (sent < len) {
-               /*
-                *      Optimisation for the fact that under 0.01% of X
-                *      messages typically need breaking up.
-                */
-
-               size = len-sent;
+               size = len - sent;
 
                /* Keep two messages in the pipe so it schedules better */
-               if (size > ((sk->sk_sndbuf >> 1) - 64))
-                       size = (sk->sk_sndbuf >> 1) - 64;
+               size = min_t(int, size, (sk->sk_sndbuf >> 1) - 64);
 
-               if (size > SKB_MAX_ALLOC)
-                       size = SKB_MAX_ALLOC;
-
-               /*
-                *      Grab a buffer
-                */
+               /* allow fallback to order-0 allocations */
+               size = min_t(int, size, SKB_MAX_HEAD(0) + UNIX_SKB_FRAGS_SZ);
 
-               skb = sock_alloc_send_skb(sk, size, msg->msg_flags&MSG_DONTWAIT,
-                                         &err);
+               data_len = max_t(int, 0, size - SKB_MAX_HEAD(0));
 
-               if (skb == NULL)
+               skb = sock_alloc_send_pskb(sk, size - data_len, data_len,
+                                          msg->msg_flags & MSG_DONTWAIT, &err,
+                                          get_order(UNIX_SKB_FRAGS_SZ));
+               if (!skb)
                        goto out_err;
 
-               /*
-                *      If you pass two values to the sock_alloc_send_skb
-                *      it tries to grab the large buffer with GFP_NOFS
-                *      (which can fail easily), and if it fails grab the
-                *      fallback size buffer which is under a page and will
-                *      succeed. [Alan]
-                */
-               size = min_t(int, size, skb_tailroom(skb));
-
-
                /* Only send the fds in the first buffer */
                err = unix_scm_to_skb(siocb->scm, skb, !fds_sent);
                if (err < 0) {
@@ -1678,7 +1666,11 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
                max_level = err + 1;
                fds_sent = true;
 
-               err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
+               skb_put(skb, size - data_len);
+               skb->data_len = data_len;
+               skb->len = size;
+               err = skb_copy_datagram_from_iovec(skb, 0, msg->msg_iov,
+                                                  sent, size);
                if (err) {
                        kfree_skb(skb);
                        goto out_err;
@@ -1890,6 +1882,11 @@ static long unix_stream_data_wait(struct sock *sk, long timeo,
        return timeo;
 }
 
+static unsigned int unix_skb_len(const struct sk_buff *skb)
+{
+       return skb->len - UNIXCB(skb).consumed;
+}
+
 static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
                               struct msghdr *msg, size_t size,
                               int flags)
@@ -1977,8 +1974,8 @@ again:
                }
 
                skip = sk_peek_offset(sk, flags);
-               while (skip >= skb->len) {
-                       skip -= skb->len;
+               while (skip >= unix_skb_len(skb)) {
+                       skip -= unix_skb_len(skb);
                        last = skb;
                        skb = skb_peek_next(skb, &sk->sk_receive_queue);
                        if (!skb)
@@ -2005,8 +2002,9 @@ again:
                        sunaddr = NULL;
                }
 
-               chunk = min_t(unsigned int, skb->len - skip, size);
-               if (memcpy_toiovec(msg->msg_iov, skb->data + skip, chunk)) {
+               chunk = min_t(unsigned int, unix_skb_len(skb) - skip, size);
+               if (skb_copy_datagram_iovec(skb, UNIXCB(skb).consumed + skip,
+                                           msg->msg_iov, chunk)) {
                        if (copied == 0)
                                copied = -EFAULT;
                        break;
@@ -2016,14 +2014,14 @@ again:
 
                /* Mark read part of skb as used */
                if (!(flags & MSG_PEEK)) {
-                       skb_pull(skb, chunk);
+                       UNIXCB(skb).consumed += chunk;
 
                        sk_peek_offset_bwd(sk, chunk);
 
                        if (UNIXCB(skb).fp)
                                unix_detach_fds(siocb->scm, skb);
 
-                       if (skb->len)
+                       if (unix_skb_len(skb))
                                break;
 
                        skb_unlink(skb, &sk->sk_receive_queue);
@@ -2107,7 +2105,7 @@ long unix_inq_len(struct sock *sk)
        if (sk->sk_type == SOCK_STREAM ||
            sk->sk_type == SOCK_SEQPACKET) {
                skb_queue_walk(&sk->sk_receive_queue, skb)
-                       amount += skb->len;
+                       amount += unix_skb_len(skb);
        } else {
                skb = skb_peek(&sk->sk_receive_queue);
                if (skb)
index 593071dabd1cc7477169b24bc31979d8590465b6..545c08b8a1d482ac0c155ab755f6623c62ffcbe5 100644 (file)
@@ -96,8 +96,7 @@
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 #include <net/sock.h>
-
-#include "af_vsock.h"
+#include <net/af_vsock.h>
 
 static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr);
 static void vsock_sk_destruct(struct sock *sk);
@@ -347,7 +346,7 @@ void vsock_for_each_connected_socket(void (*fn)(struct sock *sk))
        for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) {
                struct vsock_sock *vsk;
                list_for_each_entry(vsk, &vsock_connected_table[i],
-                                   connected_table);
+                                   connected_table)
                        fn(sk_vsock(vsk));
        }
 
diff --git a/net/vmw_vsock/af_vsock.h b/net/vmw_vsock/af_vsock.h
deleted file mode 100644 (file)
index 7d64d36..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * VMware vSockets Driver
- *
- * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#ifndef __AF_VSOCK_H__
-#define __AF_VSOCK_H__
-
-#include <linux/kernel.h>
-#include <linux/workqueue.h>
-#include <linux/vm_sockets.h>
-
-#include "vsock_addr.h"
-
-#define LAST_RESERVED_PORT 1023
-
-#define vsock_sk(__sk)    ((struct vsock_sock *)__sk)
-#define sk_vsock(__vsk)   (&(__vsk)->sk)
-
-struct vsock_sock {
-       /* sk must be the first member. */
-       struct sock sk;
-       struct sockaddr_vm local_addr;
-       struct sockaddr_vm remote_addr;
-       /* Links for the global tables of bound and connected sockets. */
-       struct list_head bound_table;
-       struct list_head connected_table;
-       /* Accessed without the socket lock held. This means it can never be
-        * modified outsided of socket create or destruct.
-        */
-       bool trusted;
-       bool cached_peer_allow_dgram;   /* Dgram communication allowed to
-                                        * cached peer?
-                                        */
-       u32 cached_peer;  /* Context ID of last dgram destination check. */
-       const struct cred *owner;
-       /* Rest are SOCK_STREAM only. */
-       long connect_timeout;
-       /* Listening socket that this came from. */
-       struct sock *listener;
-       /* Used for pending list and accept queue during connection handshake.
-        * The listening socket is the head for both lists.  Sockets created
-        * for connection requests are placed in the pending list until they
-        * are connected, at which point they are put in the accept queue list
-        * so they can be accepted in accept().  If accept() cannot accept the
-        * connection, it is marked as rejected so the cleanup function knows
-        * to clean up the socket.
-        */
-       struct list_head pending_links;
-       struct list_head accept_queue;
-       bool rejected;
-       struct delayed_work dwork;
-       u32 peer_shutdown;
-       bool sent_request;
-       bool ignore_connecting_rst;
-
-       /* Private to transport. */
-       void *trans;
-};
-
-s64 vsock_stream_has_data(struct vsock_sock *vsk);
-s64 vsock_stream_has_space(struct vsock_sock *vsk);
-void vsock_pending_work(struct work_struct *work);
-struct sock *__vsock_create(struct net *net,
-                           struct socket *sock,
-                           struct sock *parent,
-                           gfp_t priority, unsigned short type);
-
-/**** TRANSPORT ****/
-
-struct vsock_transport_recv_notify_data {
-       u64 data1; /* Transport-defined. */
-       u64 data2; /* Transport-defined. */
-       bool notify_on_block;
-};
-
-struct vsock_transport_send_notify_data {
-       u64 data1; /* Transport-defined. */
-       u64 data2; /* Transport-defined. */
-};
-
-struct vsock_transport {
-       /* Initialize/tear-down socket. */
-       int (*init)(struct vsock_sock *, struct vsock_sock *);
-       void (*destruct)(struct vsock_sock *);
-       void (*release)(struct vsock_sock *);
-
-       /* Connections. */
-       int (*connect)(struct vsock_sock *);
-
-       /* DGRAM. */
-       int (*dgram_bind)(struct vsock_sock *, struct sockaddr_vm *);
-       int (*dgram_dequeue)(struct kiocb *kiocb, struct vsock_sock *vsk,
-                            struct msghdr *msg, size_t len, int flags);
-       int (*dgram_enqueue)(struct vsock_sock *, struct sockaddr_vm *,
-                            struct iovec *, size_t len);
-       bool (*dgram_allow)(u32 cid, u32 port);
-
-       /* STREAM. */
-       /* TODO: stream_bind() */
-       ssize_t (*stream_dequeue)(struct vsock_sock *, struct iovec *,
-                                 size_t len, int flags);
-       ssize_t (*stream_enqueue)(struct vsock_sock *, struct iovec *,
-                                 size_t len);
-       s64 (*stream_has_data)(struct vsock_sock *);
-       s64 (*stream_has_space)(struct vsock_sock *);
-       u64 (*stream_rcvhiwat)(struct vsock_sock *);
-       bool (*stream_is_active)(struct vsock_sock *);
-       bool (*stream_allow)(u32 cid, u32 port);
-
-       /* Notification. */
-       int (*notify_poll_in)(struct vsock_sock *, size_t, bool *);
-       int (*notify_poll_out)(struct vsock_sock *, size_t, bool *);
-       int (*notify_recv_init)(struct vsock_sock *, size_t,
-               struct vsock_transport_recv_notify_data *);
-       int (*notify_recv_pre_block)(struct vsock_sock *, size_t,
-               struct vsock_transport_recv_notify_data *);
-       int (*notify_recv_pre_dequeue)(struct vsock_sock *, size_t,
-               struct vsock_transport_recv_notify_data *);
-       int (*notify_recv_post_dequeue)(struct vsock_sock *, size_t,
-               ssize_t, bool, struct vsock_transport_recv_notify_data *);
-       int (*notify_send_init)(struct vsock_sock *,
-               struct vsock_transport_send_notify_data *);
-       int (*notify_send_pre_block)(struct vsock_sock *,
-               struct vsock_transport_send_notify_data *);
-       int (*notify_send_pre_enqueue)(struct vsock_sock *,
-               struct vsock_transport_send_notify_data *);
-       int (*notify_send_post_enqueue)(struct vsock_sock *, ssize_t,
-               struct vsock_transport_send_notify_data *);
-
-       /* Shutdown. */
-       int (*shutdown)(struct vsock_sock *, int);
-
-       /* Buffer sizes. */
-       void (*set_buffer_size)(struct vsock_sock *, u64);
-       void (*set_min_buffer_size)(struct vsock_sock *, u64);
-       void (*set_max_buffer_size)(struct vsock_sock *, u64);
-       u64 (*get_buffer_size)(struct vsock_sock *);
-       u64 (*get_min_buffer_size)(struct vsock_sock *);
-       u64 (*get_max_buffer_size)(struct vsock_sock *);
-
-       /* Addressing. */
-       u32 (*get_local_cid)(void);
-};
-
-/**** CORE ****/
-
-int vsock_core_init(const struct vsock_transport *t);
-void vsock_core_exit(void);
-
-/**** UTILS ****/
-
-void vsock_release_pending(struct sock *pending);
-void vsock_add_pending(struct sock *listener, struct sock *pending);
-void vsock_remove_pending(struct sock *listener, struct sock *pending);
-void vsock_enqueue_accept(struct sock *listener, struct sock *connected);
-void vsock_insert_connected(struct vsock_sock *vsk);
-void vsock_remove_bound(struct vsock_sock *vsk);
-void vsock_remove_connected(struct vsock_sock *vsk);
-struct sock *vsock_find_bound_socket(struct sockaddr_vm *addr);
-struct sock *vsock_find_connected_socket(struct sockaddr_vm *src,
-                                        struct sockaddr_vm *dst);
-void vsock_for_each_connected_socket(void (*fn)(struct sock *sk));
-
-#endif /* __AF_VSOCK_H__ */
index ffc11df02af22cf90c03df730110ea2a96f033cb..9d6986634e0bfaf1a4431cc8f6fc015f212e7042 100644 (file)
@@ -34,8 +34,8 @@
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 #include <net/sock.h>
+#include <net/af_vsock.h>
 
-#include "af_vsock.h"
 #include "vmci_transport_notify.h"
 
 static int vmci_transport_recv_dgram_cb(void *data, struct vmci_datagram *dg);
index fd88ea8924e4dd89d8f0dc7939e5ccc75e39a747..ce6c9623d5f069029ce58294bcc7de9bc3728fcd 100644 (file)
@@ -19,8 +19,8 @@
 #include <linux/vmw_vmci_defs.h>
 #include <linux/vmw_vmci_api.h>
 
-#include "vsock_addr.h"
-#include "af_vsock.h"
+#include <net/vsock_addr.h>
+#include <net/af_vsock.h>
 
 /* If the packet format changes in a release then this should change too. */
 #define VMCI_TRANSPORT_PACKET_VERSION 1
index ec2611b4ea0ee4fc073926c9a33347ace8de9e4f..82486ee55eaca4cc4f4b1cb414cc848c1239ec46 100644 (file)
@@ -17,8 +17,7 @@
 #include <linux/socket.h>
 #include <linux/stddef.h>
 #include <net/sock.h>
-
-#include "vsock_addr.h"
+#include <net/vsock_addr.h>
 
 void vsock_addr_init(struct sockaddr_vm *addr, u32 cid, u32 port)
 {
diff --git a/net/vmw_vsock/vsock_addr.h b/net/vmw_vsock/vsock_addr.h
deleted file mode 100644 (file)
index 9ccd531..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * VMware vSockets Driver
- *
- * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation version 2 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#ifndef _VSOCK_ADDR_H_
-#define _VSOCK_ADDR_H_
-
-#include <linux/vm_sockets.h>
-
-void vsock_addr_init(struct sockaddr_vm *addr, u32 cid, u32 port);
-int vsock_addr_validate(const struct sockaddr_vm *addr);
-bool vsock_addr_bound(const struct sockaddr_vm *addr);
-void vsock_addr_unbind(struct sockaddr_vm *addr);
-bool vsock_addr_equals_addr(const struct sockaddr_vm *addr,
-                           const struct sockaddr_vm *other);
-int vsock_addr_cast(const struct sockaddr *addr, size_t len,
-                   struct sockaddr_vm **out_addr);
-
-#endif
index e52cab3591dd78c373274bb64420f87383775e8c..ad8cc7bcf0651eb1f9f00085f779a80060372c15 100644 (file)
@@ -308,7 +308,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
 {
        BUG_ON(!policy->walk.dead);
 
-       if (del_timer(&policy->timer))
+       if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
                BUG();
 
        security_xfrm_policy_free(policy->security);
@@ -660,7 +660,13 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
        xfrm_pol_hold(policy);
        net->xfrm.policy_count[dir]++;
        atomic_inc(&flow_cache_genid);
-       rt_genid_bump(net);
+
+       /* After previous checking, family can either be AF_INET or AF_INET6 */
+       if (policy->family == AF_INET)
+               rt_genid_bump_ipv4(net);
+       else
+               rt_genid_bump_ipv6(net);
+
        if (delpol) {
                xfrm_policy_requeue(delpol, policy);
                __xfrm_policy_unlink(delpol, dir);
@@ -2126,8 +2132,6 @@ restart:
                 * have the xfrm_state's. We need to wait for KM to
                 * negotiate new SA's or bail out with error.*/
                if (net->xfrm.sysctl_larval_drop) {
-                       /* EREMOTE tells the caller to generate
-                        * a one-shot blackhole route. */
                        dst_release(dst);
                        xfrm_pols_put(pols, drop_pols);
                        XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES);
index 78f66fa92449c92865dfa8314020854ed704744f..4f8ace8558649bacdc2f0c426d89c058bd5559d6 100644 (file)
@@ -499,7 +499,8 @@ struct xfrm_state *xfrm_state_alloc(struct net *net)
                INIT_HLIST_NODE(&x->bydst);
                INIT_HLIST_NODE(&x->bysrc);
                INIT_HLIST_NODE(&x->byspi);
-               tasklet_hrtimer_init(&x->mtimer, xfrm_timer_handler, CLOCK_REALTIME, HRTIMER_MODE_ABS);
+               tasklet_hrtimer_init(&x->mtimer, xfrm_timer_handler,
+                                       CLOCK_BOOTTIME, HRTIMER_MODE_ABS);
                setup_timer(&x->rtimer, xfrm_replay_timer_handler,
                                (unsigned long)x);
                x->curlft.add_time = get_seconds();
@@ -990,11 +991,13 @@ void xfrm_state_insert(struct xfrm_state *x)
 EXPORT_SYMBOL(xfrm_state_insert);
 
 /* xfrm_state_lock is held */
-static struct xfrm_state *__find_acq_core(struct net *net, struct xfrm_mark *m,
+static struct xfrm_state *__find_acq_core(struct net *net,
+                                         const struct xfrm_mark *m,
                                          unsigned short family, u8 mode,
                                          u32 reqid, u8 proto,
                                          const xfrm_address_t *daddr,
-                                         const xfrm_address_t *saddr, int create)
+                                         const xfrm_address_t *saddr,
+                                         int create)
 {
        unsigned int h = xfrm_dst_hash(net, daddr, saddr, reqid, family);
        struct xfrm_state *x;
@@ -1399,9 +1402,9 @@ xfrm_state_lookup_byaddr(struct net *net, u32 mark,
 EXPORT_SYMBOL(xfrm_state_lookup_byaddr);
 
 struct xfrm_state *
-xfrm_find_acq(struct net *net, struct xfrm_mark *mark, u8 mode, u32 reqid, u8 proto,
-             const xfrm_address_t *daddr, const xfrm_address_t *saddr,
-             int create, unsigned short family)
+xfrm_find_acq(struct net *net, const struct xfrm_mark *mark, u8 mode, u32 reqid,
+             u8 proto, const xfrm_address_t *daddr,
+             const xfrm_address_t *saddr, int create, unsigned short family)
 {
        struct xfrm_state *x;
 
index 65f67cb0aefb22f323d8048c140417555c273c9d..6713f04e30ba8810415f88f7ed6e78cb5685f6f4 100644 (file)
@@ -50,8 +50,13 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
 
 static inline void selinux_xfrm_notify_policyload(void)
 {
+       struct net *net;
+
        atomic_inc(&flow_cache_genid);
-       rt_genid_bump(&init_net);
+       rtnl_lock();
+       for_each_net(net)
+               rt_genid_bump_all(net);
+       rtnl_unlock();
 }
 #else
 static inline int selinux_xfrm_enabled(void)
index 3f7682a387b730b9c75fc6e547de98d512b46dbb..eefbd10e408f18b87d35c35d729fabf088734d65 100644 (file)
@@ -1998,12 +1998,11 @@ static void smk_ipv6_port_label(struct socket *sock, struct sockaddr *address)
  *
  * Create or update the port list entry
  */
-static int smk_ipv6_port_check(struct sock *sk, struct sockaddr *address,
+static int smk_ipv6_port_check(struct sock *sk, struct sockaddr_in6 *address,
                                int act)
 {
        __be16 *bep;
        __be32 *be32p;
-       struct sockaddr_in6 *addr6;
        struct smk_port_label *spp;
        struct socket_smack *ssp = sk->sk_security;
        struct smack_known *skp;
@@ -2025,10 +2024,9 @@ static int smk_ipv6_port_check(struct sock *sk, struct sockaddr *address,
        /*
         * Get the IP address and port from the address.
         */
-       addr6 = (struct sockaddr_in6 *)address;
-       port = ntohs(addr6->sin6_port);
-       bep = (__be16 *)(&addr6->sin6_addr);
-       be32p = (__be32 *)(&addr6->sin6_addr);
+       port = ntohs(address->sin6_port);
+       bep = (__be16 *)(&address->sin6_addr);
+       be32p = (__be32 *)(&address->sin6_addr);
 
        /*
         * It's remote, so port lookup does no good.
@@ -2060,9 +2058,9 @@ auditout:
        ad.a.u.net->family = sk->sk_family;
        ad.a.u.net->dport = port;
        if (act == SMK_RECEIVING)
-               ad.a.u.net->v6info.saddr = addr6->sin6_addr;
+               ad.a.u.net->v6info.saddr = address->sin6_addr;
        else
-               ad.a.u.net->v6info.daddr = addr6->sin6_addr;
+               ad.a.u.net->v6info.daddr = address->sin6_addr;
 #endif
        return smk_access(skp, object, MAY_WRITE, &ad);
 }
@@ -2201,7 +2199,8 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,
        case PF_INET6:
                if (addrlen < sizeof(struct sockaddr_in6))
                        return -EINVAL;
-               rc = smk_ipv6_port_check(sock->sk, sap, SMK_CONNECTING);
+               rc = smk_ipv6_port_check(sock->sk, (struct sockaddr_in6 *)sap,
+                                               SMK_CONNECTING);
                break;
        }
        return rc;
@@ -3034,7 +3033,7 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,
                                int size)
 {
        struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name;
-       struct sockaddr *sap = (struct sockaddr *) msg->msg_name;
+       struct sockaddr_in6 *sap = (struct sockaddr_in6 *) msg->msg_name;
        int rc = 0;
 
        /*
@@ -3121,9 +3120,8 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
        return smack_net_ambient;
 }
 
-static int smk_skb_to_addr_ipv6(struct sk_buff *skb, struct sockaddr *sap)
+static int smk_skb_to_addr_ipv6(struct sk_buff *skb, struct sockaddr_in6 *sip)
 {
-       struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;
        u8 nexthdr;
        int offset;
        int proto = -EINVAL;
@@ -3181,7 +3179,7 @@ static int smack_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
        struct netlbl_lsm_secattr secattr;
        struct socket_smack *ssp = sk->sk_security;
        struct smack_known *skp;
-       struct sockaddr sadd;
+       struct sockaddr_in6 sadd;
        int rc = 0;
        struct smk_audit_info ad;
 #ifdef CONFIG_AUDIT
index 76e0d56950751a8a60074d5a9a7df6232a1ee472..823359ed95e16a0969ee6c28843a4777387d3561 100644 (file)
@@ -166,7 +166,9 @@ void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id)
        } else {
                printk(KERN_ERR "%s: DMA error on channel %d (DCSR=%#x)\n",
                        rtd->params->name, dma_ch, dcsr);
+               snd_pcm_stream_lock(substream);
                snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock(substream);
        }
 }
 EXPORT_SYMBOL(pxa2xx_pcm_dma_irq);
index 99db892d7299056568e5432bdd660ea14d3143c6..98969541cbcc9c62ff81afb9818d2399dd6e7eb0 100644 (file)
@@ -743,7 +743,7 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
        mutex_lock(&stream->device->lock);
        switch (_IOC_NR(cmd)) {
        case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
-               put_user(SNDRV_COMPRESS_VERSION,
+               retval = put_user(SNDRV_COMPRESS_VERSION,
                                (int __user *)arg) ? -EFAULT : 0;
                break;
        case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
index e3cb46fef2c76b4cca8d67a52f212deb41598caf..b3f39b5ed74234ff92d31162fc3af067a523c1ba 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/export.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
+#include <linux/workqueue.h>
 
 /*
  * common variables
@@ -60,6 +61,14 @@ static void free_devinfo(void *private);
 #define call_ctl(type,rec) snd_seq_kernel_client_ctl(system_client, type, rec)
 
 
+/* call snd_seq_oss_midi_lookup_ports() asynchronously */
+static void async_call_lookup_ports(struct work_struct *work)
+{
+       snd_seq_oss_midi_lookup_ports(system_client);
+}
+
+static DECLARE_WORK(async_lookup_work, async_call_lookup_ports);
+
 /*
  * create sequencer client for OSS sequencer
  */
@@ -85,9 +94,6 @@ snd_seq_oss_create_client(void)
        system_client = rc;
        debug_printk(("new client = %d\n", rc));
 
-       /* look up midi devices */
-       snd_seq_oss_midi_lookup_ports(system_client);
-
        /* create annoucement receiver port */
        memset(port, 0, sizeof(*port));
        strcpy(port->name, "Receiver");
@@ -115,6 +121,9 @@ snd_seq_oss_create_client(void)
        }
        rc = 0;
 
+       /* look up midi devices */
+       schedule_work(&async_lookup_work);
+
  __error:
        kfree(port);
        return rc;
@@ -160,6 +169,7 @@ receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic
 int
 snd_seq_oss_delete_client(void)
 {
+       cancel_work_sync(&async_lookup_work);
        if (system_client >= 0)
                snd_seq_delete_kernel_client(system_client);
 
index 677dc84590c79ae49dca0fb569fe4c98a44c068c..862d84893ee871c0467f5baf4667d769d6f7203e 100644 (file)
@@ -72,7 +72,7 @@ static int send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
  * look up the existing ports
  * this looks a very exhausting job.
  */
-int __init
+int
 snd_seq_oss_midi_lookup_ports(int client)
 {
        struct snd_seq_client_info *clinfo;
index 7e814a5c36770a767e97b608aa028388ec419095..4bbcc0fcd4eb0d7c988c06e21cc76afb1236969e 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/delay.h>
 
 #include <asm/visws/cobalt.h>
 
 #include "sound_config.h"
 
+static DEFINE_MUTEX(vwsnd_mutex);
+
 /*****************************************************************************/
 /* debug stuff */
 
 #ifdef VWSND_DEBUG
 
-static DEFINE_MUTEX(vwsnd_mutex);
 static int shut_up = 1;
 
 /*
index 185d54a5cb1af5765f2c2ae8f09af36f28f55de2..dc632cdc38706ec74c18978739e0819257e1d3a8 100644 (file)
@@ -769,7 +769,10 @@ static void snd_card_asihpi_timer_function(unsigned long data)
                                                s->number);
                                ds->drained_count++;
                                if (ds->drained_count > 20) {
+                                       unsigned long flags;
+                                       snd_pcm_stream_lock_irqsave(s, flags);
                                        snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
+                                       snd_pcm_stream_unlock_irqrestore(s, flags);
                                        continue;
                                }
                        } else {
index fe4c61bdb8bac5764556bce3da8301653042d2c3..f6dec3ea371fa8c8e4e580af71d980e4c6595545 100644 (file)
@@ -689,7 +689,9 @@ static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
        if (! dma->substream || ! dma->running)
                return;
        snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type);
+       snd_pcm_stream_lock(dma->substream);
        snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
+       snd_pcm_stream_unlock(dma->substream);
 }
 
 /*
index cf29b9a1d65d71dbcc0608b1db89bef5273a199b..289563ecb6dd704e0a3f89d81ca19afef63cf98a 100644 (file)
@@ -638,7 +638,9 @@ static void snd_atiixp_xrun_dma(struct atiixp_modem *chip,
        if (! dma->substream || ! dma->running)
                return;
        snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type);
+       snd_pcm_stream_lock(dma->substream);
        snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
+       snd_pcm_stream_unlock(dma->substream);
 }
 
 /*
index 7c11d46b84d3b3b0fd26b8bca560f6fb3017a8fc..48a9d004d6d938ac5365b52a83c6b67b7b18dcaa 100644 (file)
@@ -860,7 +860,7 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
                }
        }
        if (id < 0 && quirk) {
-               for (q = quirk; q->subvendor; q++) {
+               for (q = quirk; q->subvendor || q->subdevice; q++) {
                        unsigned int vendorid =
                                q->subdevice | (q->subvendor << 16);
                        unsigned int mask = 0xffff0000 | q->subdevice_mask;
index 8e77cbbad871dd4ff10263824d016487b1479813..e3c7ba8d7582643f9d1f52681251e16e3835d042 100644 (file)
@@ -522,7 +522,7 @@ static bool same_amp_caps(struct hda_codec *codec, hda_nid_t nid1,
 }
 
 #define nid_has_mute(codec, nid, dir) \
-       check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
+       check_amp_caps(codec, nid, dir, (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE))
 #define nid_has_volume(codec, nid, dir) \
        check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
 
@@ -624,7 +624,7 @@ static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid,
                if (enable)
                        val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
        }
-       if (caps & AC_AMPCAP_MUTE) {
+       if (caps & (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) {
                if (!enable)
                        val |= HDA_AMP_MUTE;
        }
@@ -648,7 +648,7 @@ static unsigned int get_amp_mask_to_modify(struct hda_codec *codec,
 {
        unsigned int mask = 0xff;
 
-       if (caps & AC_AMPCAP_MUTE) {
+       if (caps & (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) {
                if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_MUTE_CTL))
                        mask &= ~0x80;
        }
index 540bdef2f9040dc8276cee974429065c5121e63f..030ca8652a1cb3b5b8f825d684b69ec1bb2daacc 100644 (file)
@@ -2622,6 +2622,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
 { .id = 0x10de0043, .name = "GPU 43 HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de0044, .name = "GPU 44 HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de0051, .name = "GPU 51 HDMI/DP",  .patch = patch_generic_hdmi },
+{ .id = 0x10de0060, .name = "GPU 60 HDMI/DP",  .patch = patch_generic_hdmi },
 { .id = 0x10de0067, .name = "MCP67 HDMI",      .patch = patch_nvhdmi_2ch },
 { .id = 0x10de8001, .name = "MCP73 HDMI",      .patch = patch_nvhdmi_2ch },
 { .id = 0x11069f80, .name = "VX900 HDMI/DP",   .patch = patch_via_hdmi },
@@ -2674,6 +2675,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0042");
 MODULE_ALIAS("snd-hda-codec-id:10de0043");
 MODULE_ALIAS("snd-hda-codec-id:10de0044");
 MODULE_ALIAS("snd-hda-codec-id:10de0051");
+MODULE_ALIAS("snd-hda-codec-id:10de0060");
 MODULE_ALIAS("snd-hda-codec-id:10de0067");
 MODULE_ALIAS("snd-hda-codec-id:10de8001");
 MODULE_ALIAS("snd-hda-codec-id:11069f80");
index 8bd2261498680676c0b62b7861fbd5be2aa4daac..f303cd898515d5f20000ec5138400bfd93e63d85 100644 (file)
@@ -1031,6 +1031,7 @@ enum {
        ALC880_FIXUP_GPIO2,
        ALC880_FIXUP_MEDION_RIM,
        ALC880_FIXUP_LG,
+       ALC880_FIXUP_LG_LW25,
        ALC880_FIXUP_W810,
        ALC880_FIXUP_EAPD_COEF,
        ALC880_FIXUP_TCL_S700,
@@ -1089,6 +1090,14 @@ static const struct hda_fixup alc880_fixups[] = {
                        { }
                }
        },
+       [ALC880_FIXUP_LG_LW25] = {
+               .type = HDA_FIXUP_PINS,
+               .v.pins = (const struct hda_pintbl[]) {
+                       { 0x1a, 0x0181344f }, /* line-in */
+                       { 0x1b, 0x0321403f }, /* headphone */
+                       { }
+               }
+       },
        [ALC880_FIXUP_W810] = {
                .type = HDA_FIXUP_PINS,
                .v.pins = (const struct hda_pintbl[]) {
@@ -1341,6 +1350,7 @@ static const struct snd_pci_quirk alc880_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
        SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
        SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
+       SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
        SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
 
        /* Below is the copied entries from alc880_quirks.c.
@@ -4329,6 +4339,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
        SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
        SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
+       SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
        SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
        SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
index e2f83591161bbf3e7bf5f70ef732b8cd57b38587..6d1924c19abfdb41d1dddc27e119630c24995abc 100644 (file)
@@ -417,9 +417,11 @@ static void stac_update_outputs(struct hda_codec *codec)
                        val &= ~spec->eapd_mask;
                else
                        val |= spec->eapd_mask;
-               if (spec->gpio_data != val)
+               if (spec->gpio_data != val) {
+                       spec->gpio_data = val;
                        stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir,
                                      val);
+               }
        }
 }
 
@@ -2817,6 +2819,7 @@ static const struct hda_pintbl ecs202_pin_configs[] = {
 
 /* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
 static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
+       SND_PCI_QUIRK(0x0000, 0x0100, "Mac Mini", STAC_INTEL_MAC_V3),
        SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
        SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
        SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
@@ -3231,7 +3234,7 @@ static const struct hda_fixup stac927x_fixups[] = {
                        /* configure the analog microphone on some laptops */
                        { 0x0c, 0x90a79130 },
                        /* correct the front output jack as a hp out */
-                       { 0x0f, 0x0227011f },
+                       { 0x0f, 0x0221101f },
                        /* correct the front input jack as a mic */
                        { 0x0e, 0x02a79130 },
                        {}
@@ -3612,20 +3615,18 @@ static int stac_parse_auto_config(struct hda_codec *codec)
 static int stac_init(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec = codec->spec;
-       unsigned int gpio;
        int i;
 
        /* override some hints */
        stac_store_hints(codec);
 
        /* set up GPIO */
-       gpio = spec->gpio_data;
        /* turn on EAPD statically when spec->eapd_switch isn't set.
         * otherwise, unsol event will turn it on/off dynamically
         */
        if (!spec->eapd_switch)
-               gpio |= spec->eapd_mask;
-       stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
+               spec->gpio_data |= spec->eapd_mask;
+       stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
 
        snd_hda_gen_init(codec);
 
@@ -3915,6 +3916,7 @@ static void stac_setup_gpio(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec = codec->spec;
 
+       spec->gpio_mask |= spec->eapd_mask;
        if (spec->gpio_led) {
                if (!spec->vref_mute_led_nid) {
                        spec->gpio_mask |= spec->gpio_led;
index 1d38fd0bc4e26bd49772d7e030efb7e283e5687f..d12826526798fc47620e4cb613df9e95da8a8f7c 100644 (file)
@@ -81,7 +81,9 @@ static void atmel_pcm_dma_irq(u32 ssc_sr,
 
                /* stop RX and capture: will be enabled again at restart */
                ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable);
+               snd_pcm_stream_lock(substream);
                snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock(substream);
 
                /* now drain RHR and read status to remove xrun condition */
                ssc_readx(prtd->ssc->regs, SSC_RHR);
index d6f7694fcad4f78ae1cb300d8d9fe3a4ef3b11d1..c8a2de103c5f3b6b0cb5172f858c687795154d19 100644 (file)
@@ -341,7 +341,7 @@ static struct platform_driver au1xac97c_driver = {
        .remove         = au1xac97c_drvremove,
 };
 
-module_platform_driver(&au1xac97c_driver);
+module_platform_driver(au1xac97c_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Au1000/1500/1100 AC97C ASoC driver");
index efb1daecd0dd6136122aa8595c145630ff102b22..e82eb373a731402cb60699881aca15a84577f72f 100644 (file)
@@ -294,11 +294,12 @@ static int asoc_bfin_ac97_probe(struct platform_device *pdev)
        /* Request PB3 as reset pin */
        ret = devm_gpio_request_one(&pdev->dev,
                                    CONFIG_SND_BF5XX_RESET_GPIO_NUM,
-                                   GPIOF_OUT_INIT_HIGH, "SND_AD198x RESET") {
+                                   GPIOF_OUT_INIT_HIGH, "SND_AD198x RESET");
+       if (ret) {
                dev_err(&pdev->dev,
                        "Failed to request GPIO_%d for reset: %d\n",
                        CONFIG_SND_BF5XX_RESET_GPIO_NUM, ret);
-               goto gpio_err;
+               return ret;
        }
 #endif
 
index 15c635e33f4d99a42b6386cbc7e7c54e2bf807ef..0c3e22d90a8d903fbf1495936c5a97a79ab8a77e 100644 (file)
@@ -9,7 +9,6 @@
 #ifndef _BF5XX_AC97_H
 #define _BF5XX_AC97_H
 
-extern struct snd_ac97_bus_ops bf5xx_ac97_ops;
 extern struct snd_ac97 *ac97;
 /* Frame format in memory, only support stereo currently */
 struct ac97_frame {
index ac73c607410a73d92ff84a817c22bf6a99c25d5f..04491f0e8d1bde2636f8772e3b7d3bb65284d44a 100644 (file)
@@ -102,13 +102,13 @@ static struct ep93xx_ac97_info *ep93xx_ac97_info;
 
 static struct ep93xx_dma_data ep93xx_ac97_pcm_out = {
        .name           = "ac97-pcm-out",
-       .dma_port       = EP93XX_DMA_AAC1,
+       .port           = EP93XX_DMA_AAC1,
        .direction      = DMA_MEM_TO_DEV,
 };
 
 static struct ep93xx_dma_data ep93xx_ac97_pcm_in = {
        .name           = "ac97-pcm-in",
-       .dma_port       = EP93XX_DMA_AAC1,
+       .port           = EP93XX_DMA_AAC1,
        .direction      = DMA_DEV_TO_MEM,
 };
 
index 987f728718c52cad7ee2a5f1c5dd8dc2fc6d3f02..be2ba1b6fe4a3a344b062a7f693f8b1f83cce0ae 100644 (file)
@@ -195,6 +195,8 @@ static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0);
 
 static DECLARE_TLV_DB_SCALE(mix_tlv, -50, 50, 0);
 
+static DECLARE_TLV_DB_SCALE(beep_tlv, -56, 200, 0);
+
 static const unsigned int limiter_tlv[] = {
        TLV_DB_RANGE_HEAD(2),
        0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
@@ -451,7 +453,8 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = {
        SOC_ENUM("Beep Pitch", beep_pitch_enum),
        SOC_ENUM("Beep on Time", beep_ontime_enum),
        SOC_ENUM("Beep off Time", beep_offtime_enum),
-       SOC_SINGLE_TLV("Beep Volume", CS42L52_BEEP_VOL, 0, 0x1f, 0x07, hl_tlv),
+       SOC_SINGLE_SX_TLV("Beep Volume", CS42L52_BEEP_VOL,
+                       0, 0x07, 0x1f, beep_tlv),
        SOC_SINGLE("Beep Mixer Switch", CS42L52_BEEP_TONE_CTL, 5, 1, 1),
        SOC_ENUM("Beep Treble Corner Freq", beep_treble_enum),
        SOC_ENUM("Beep Bass Corner Freq", beep_bass_enum),
index 3eeada57e87de68b43394e3440805de03932d890..566a367c94fa0ce71ac04f86686923ed63ece58d 100644 (file)
@@ -1612,7 +1612,7 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute)
 
 static void max98088_sync_cache(struct snd_soc_codec *codec)
 {
-       u16 *reg_cache = codec->reg_cache;
+       u8 *reg_cache = codec->reg_cache;
        int i;
 
        if (!codec->cache_sync)
index d441559dc92caaa5f38a847effeebb681531f5a1..760e8bfeacaadef370eb0ce30e1ce5ad124da295 100644 (file)
@@ -38,7 +38,7 @@
 static const struct reg_default sgtl5000_reg_defaults[] = {
        { SGTL5000_CHIP_CLK_CTRL,               0x0008 },
        { SGTL5000_CHIP_I2S_CTRL,               0x0010 },
-       { SGTL5000_CHIP_SSS_CTRL,               0x0008 },
+       { SGTL5000_CHIP_SSS_CTRL,               0x0010 },
        { SGTL5000_CHIP_DAC_VOL,                0x3c3c },
        { SGTL5000_CHIP_PAD_STRENGTH,           0x015f },
        { SGTL5000_CHIP_ANA_HP_CTRL,            0x1818 },
@@ -153,6 +153,8 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
 static int power_vag_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
 {
+       const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
+
        switch (event) {
        case SND_SOC_DAPM_POST_PMU:
                snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
@@ -160,9 +162,17 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
                break;
 
        case SND_SOC_DAPM_PRE_PMD:
-               snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
-                       SGTL5000_VAG_POWERUP, 0);
-               msleep(400);
+               /*
+                * Don't clear VAG_POWERUP, when both DAC and ADC are
+                * operational to prevent inadvertently starving the
+                * other one of them.
+                */
+               if ((snd_soc_read(w->codec, SGTL5000_CHIP_ANA_POWER) &
+                               mask) != mask) {
+                       snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
+                               SGTL5000_VAG_POWERUP, 0);
+                       msleep(400);
+               }
                break;
        default:
                break;
@@ -388,7 +398,7 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = {
        SOC_DOUBLE("Capture Volume", SGTL5000_CHIP_ANA_ADC_CTRL, 0, 4, 0xf, 0),
        SOC_SINGLE_TLV("Capture Attenuate Switch (-6dB)",
                        SGTL5000_CHIP_ANA_ADC_CTRL,
-                       8, 2, 0, capture_6db_attenuate),
+                       8, 1, 0, capture_6db_attenuate),
        SOC_SINGLE("Capture ZC Switch", SGTL5000_CHIP_ANA_CTRL, 1, 1, 0),
 
        SOC_DOUBLE_TLV("Headphone Playback Volume",
@@ -1527,6 +1537,9 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
        if (IS_ERR(sgtl5000->mclk)) {
                ret = PTR_ERR(sgtl5000->mclk);
                dev_err(&client->dev, "Failed to get mclock: %d\n", ret);
+               /* Defer the probe to see if the clk will be provided later */
+               if (ret == -ENOENT)
+                       return -EPROBE_DEFER;
                return ret;
        }
 
index 4b69229a9818a789222db312657e008470668392..2f8c88931f690579f86d497d03ef7327a156a94c 100644 (file)
 #define SGTL5000_PLL_INT_DIV_MASK              0xf800
 #define SGTL5000_PLL_INT_DIV_SHIFT             11
 #define SGTL5000_PLL_INT_DIV_WIDTH             5
-#define SGTL5000_PLL_FRAC_DIV_MASK             0x0700
+#define SGTL5000_PLL_FRAC_DIV_MASK             0x07ff
 #define SGTL5000_PLL_FRAC_DIV_SHIFT            0
 #define SGTL5000_PLL_FRAC_DIV_WIDTH            11
 
index f5e835662cdca30477738e39ffe7d57f6305db78..10adc4145d4639e5e44d3c587a595f476650b6fa 100644 (file)
@@ -410,6 +410,16 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
                        rec->command, rec->length);
                len = rec->length + 8;
 
+               xfer = kzalloc(sizeof(*xfer), GFP_KERNEL);
+               if (!xfer) {
+                       dev_err(codec->dev, "Failed to allocate xfer\n");
+                       ret = -ENOMEM;
+                       goto abort;
+               }
+
+               xfer->codec = codec;
+               list_add_tail(&xfer->list, &xfer_list);
+
                out = kzalloc(len, GFP_KERNEL);
                if (!out) {
                        dev_err(codec->dev,
@@ -417,6 +427,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
                        ret = -ENOMEM;
                        goto abort1;
                }
+               xfer->t.rx_buf = out;
 
                img = kzalloc(len, GFP_KERNEL);
                if (!img) {
@@ -425,24 +436,13 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
                        ret = -ENOMEM;
                        goto abort1;
                }
+               xfer->t.tx_buf = img;
 
                byte_swap_64((u64 *)&rec->command, img, len);
 
-               xfer = kzalloc(sizeof(*xfer), GFP_KERNEL);
-               if (!xfer) {
-                       dev_err(codec->dev, "Failed to allocate xfer\n");
-                       ret = -ENOMEM;
-                       goto abort1;
-               }
-
-               xfer->codec = codec;
-               list_add_tail(&xfer->list, &xfer_list);
-
                spi_message_init(&xfer->m);
                xfer->m.complete = wm0010_boot_xfer_complete;
                xfer->m.context = xfer;
-               xfer->t.tx_buf = img;
-               xfer->t.rx_buf = out;
                xfer->t.len = len;
                xfer->t.bits_per_word = 8;
 
index 029f31c8e7036b12bd79543960279c356ab1806b..d8fc531c0e59f0604ae72a4a0a1af68d010317c3 100644 (file)
@@ -921,6 +921,7 @@ static struct snd_soc_dai_driver wm8978_dai = {
                .formats = WM8978_FORMATS,
        },
        .ops = &wm8978_dai_ops,
+       .symmetric_rates = 1,
 };
 
 static int wm8978_suspend(struct snd_soc_codec *codec)
index 1d4b1ec66e367f93bfcc43bb6eb5f47fcfe33fce..ba832b77c543af1cbdd13f2618836186c399f789 100644 (file)
@@ -3852,8 +3852,6 @@ static void wm8958_mic_work(struct work_struct *work)
                                                  mic_complete_work.work);
        struct snd_soc_codec *codec = wm8994->hubs.codec;
 
-       dev_crit(codec->dev, "MIC WORK %x\n", wm8994->mic_status);
-
        pm_runtime_get_sync(codec->dev);
 
        mutex_lock(&wm8994->accdet_lock);
@@ -3863,8 +3861,6 @@ static void wm8958_mic_work(struct work_struct *work)
        mutex_unlock(&wm8994->accdet_lock);
 
        pm_runtime_put(codec->dev);
-
-       dev_crit(codec->dev, "MIC WORK %x DONE\n", wm8994->mic_status);
 }
 
 static irqreturn_t wm8958_mic_irq(int irq, void *data)
index eb68c7db1cf3999cedcf8c8e0b515cb864dc1336..361e4c03646e32a9b73d76122a13e3e071c7a9b0 100644 (file)
@@ -1012,28 +1012,33 @@ int omap_mcbsp_init(struct platform_device *pdev)
                }
        }
 
-       res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
-       if (!res) {
-               dev_err(&pdev->dev, "invalid rx DMA channel\n");
-               return -ENODEV;
-       }
-       /* RX DMA request number, and port address configuration */
-       mcbsp->dma_req[1] = res->start;
-       mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1];
-       mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
-       mcbsp->dma_data[1].maxburst = 4;
+       if (!pdev->dev.of_node) {
+               res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
+               if (!res) {
+                       dev_err(&pdev->dev, "invalid tx DMA channel\n");
+                       return -ENODEV;
+               }
+               mcbsp->dma_req[0] = res->start;
+               mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0];
 
-       res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
-       if (!res) {
-               dev_err(&pdev->dev, "invalid tx DMA channel\n");
-               return -ENODEV;
+               res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
+               if (!res) {
+                       dev_err(&pdev->dev, "invalid rx DMA channel\n");
+                       return -ENODEV;
+               }
+               mcbsp->dma_req[1] = res->start;
+               mcbsp->dma_data[1].filter_data = &mcbsp->dma_req[1];
+       } else {
+               mcbsp->dma_data[0].filter_data = "tx";
+               mcbsp->dma_data[1].filter_data = "rx";
        }
-       /* TX DMA request number, and port address configuration */
-       mcbsp->dma_req[0] = res->start;
-       mcbsp->dma_data[0].filter_data = &mcbsp->dma_req[0];
+
        mcbsp->dma_data[0].addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
        mcbsp->dma_data[0].maxburst = 4;
 
+       mcbsp->dma_data[1].addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
+       mcbsp->dma_data[1].maxburst = 4;
+
        mcbsp->fclk = clk_get(&pdev->dev, "fck");
        if (IS_ERR(mcbsp->fclk)) {
                ret = PTR_ERR(mcbsp->fclk);
index 2ad0370146fda408ad40fc1d992fe3cd8a12d0f6..4db1f8e6e17268e042555fcae6f732d17fed7946 100644 (file)
@@ -57,7 +57,6 @@ struct omap_dmic {
        struct mutex mutex;
 
        struct snd_dmaengine_dai_dma_data dma_data;
-       unsigned int dma_req;
 };
 
 static inline void omap_dmic_write(struct omap_dmic *dmic, u16 reg, u32 val)
@@ -478,15 +477,7 @@ static int asoc_dmic_probe(struct platform_device *pdev)
        }
        dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG;
 
-       res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
-       if (!res) {
-               dev_err(dmic->dev, "invalid dma resource\n");
-               ret = -ENODEV;
-               goto err_put_clk;
-       }
-
-       dmic->dma_req = res->start;
-       dmic->dma_data.filter_data = &dmic->dma_req;
+       dmic->dma_data.filter_data = "up_link";
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
        if (!res) {
index eb05c7ed6d053519a13ec989efd81c890aa10c72..a49dc52f8abc03fac075a56c879aa2bdcaaa5568 100644 (file)
@@ -66,7 +66,6 @@ struct omap_mcpdm {
        bool restart;
 
        struct snd_dmaengine_dai_dma_data dma_data[2];
-       unsigned int dma_req[2];
 };
 
 /*
@@ -477,19 +476,8 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
        mcpdm->dma_data[0].addr = res->start + MCPDM_REG_DN_DATA;
        mcpdm->dma_data[1].addr = res->start + MCPDM_REG_UP_DATA;
 
-       res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "dn_link");
-       if (!res)
-               return -ENODEV;
-
-       mcpdm->dma_req[0] = res->start;
-       mcpdm->dma_data[0].filter_data = &mcpdm->dma_req[0];
-
-       res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "up_link");
-       if (!res)
-               return -ENODEV;
-
-       mcpdm->dma_req[1] = res->start;
-       mcpdm->dma_data[1].filter_data = &mcpdm->dma_req[1];
+       mcpdm->dma_data[0].filter_data = "dn_link";
+       mcpdm->dma_data[1].filter_data = "up_link";
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
        if (res == NULL)
index c28e042f2208175fa73d07d51587cf6bec150ac4..a11405de86e82bda8801e837ec48183093bd99db 100644 (file)
@@ -113,14 +113,25 @@ static int omap_pcm_open(struct snd_pcm_substream *substream)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_dmaengine_dai_dma_data *dma_data;
+       int ret;
 
        snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
 
        dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
 
-       return snd_dmaengine_pcm_open_request_chan(substream,
-                                                  omap_dma_filter_fn,
-                                                  dma_data->filter_data);
+       /* DT boot: filter_data is the DMA name */
+       if (rtd->cpu_dai->dev->of_node) {
+               struct dma_chan *chan;
+
+               chan = dma_request_slave_channel(rtd->cpu_dai->dev,
+                                                dma_data->filter_data);
+               ret = snd_dmaengine_pcm_open(substream, chan);
+       } else {
+               ret = snd_dmaengine_pcm_open_request_chan(substream,
+                                                         omap_dma_filter_fn,
+                                                         dma_data->filter_data);
+       }
+       return ret;
 }
 
 static int omap_pcm_mmap(struct snd_pcm_substream *substream,
index 1358c7de2521b7c296aaf2b031f78cf662523c96..d0740a762963d867bf75cce29d20c15c0a4b5097 100644 (file)
@@ -128,7 +128,9 @@ static irqreturn_t s6000_pcm_irq(int irq, void *data)
                    substream->runtime &&
                    snd_pcm_running(substream)) {
                        dev_dbg(pcm->dev, "xrun\n");
+                       snd_pcm_stream_lock(substream);
                        snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
+                       snd_pcm_stream_unlock(substream);
                        ret = IRQ_HANDLED;
                }
 
index 7a1734697434487e13b0dfeeeadb614ae24940d2..959c702235c8c6028d0946f29b622266f043ab2f 100644 (file)
@@ -742,13 +742,13 @@ static int config_setup(struct i2s_dai *i2s)
                return -EAGAIN;
        }
 
-       /* Don't bother RFS, BFS & PSR in Slave mode */
-       if (is_slave(i2s))
-               return 0;
-
        set_bfs(i2s, bfs);
        set_rfs(i2s, rfs);
 
+       /* Don't bother with PSR in Slave mode */
+       if (is_slave(i2s))
+               return 0;
+
        if (!(i2s->quirks & QUIRK_NO_MUXPSR)) {
                psr = i2s->rclk_srcrate / i2s->frmclk / rfs;
                writel(((psr - 1) << 8) | PSR_PSREN, i2s->addr + I2SPSR);
index 0ec070cf7231ebcc39a057061af8995d7f7574ff..d82ee386eab564d352eccd4209dff767b222e6f3 100644 (file)
@@ -3908,10 +3908,8 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
 {
        /* create platform component name */
        platform->name = fmt_single_name(dev, &platform->id);
-       if (platform->name == NULL) {
-               kfree(platform);
+       if (platform->name == NULL)
                return -ENOMEM;
-       }
 
        platform->dev = dev;
        platform->driver = platform_drv;
index b94190820e8cfa1b6c24e925f176196cc5efff98..4375c9f2b791006717f807cdddcb343bb0f8074c 100644 (file)
@@ -679,13 +679,14 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
                return -EINVAL;
        }
 
-       path = list_first_entry(&w->sources, struct snd_soc_dapm_path,
-                               list_sink);
-       if (!path) {
+       if (list_empty(&w->sources)) {
                dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name);
                return -EINVAL;
        }
 
+       path = list_first_entry(&w->sources, struct snd_soc_dapm_path,
+                               list_sink);
+
        ret = dapm_create_or_share_mixmux_kcontrol(w, 0, path);
        if (ret < 0)
                return ret;
@@ -2733,7 +2734,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
        }
 
        mutex_unlock(&card->dapm_mutex);
-       return 0;
+       return change;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
 
@@ -2861,7 +2862,6 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
        struct soc_enum *e =
                (struct soc_enum *)kcontrol->private_value;
        int change;
-       int ret = 0;
        int wi;
 
        if (ucontrol->value.enumerated.item[0] >= e->max)
@@ -2881,7 +2881,7 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
        }
 
        mutex_unlock(&card->dapm_mutex);
-       return ret;
+       return change;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
 
index e58233f7df616e6bb406f809cea23069c4059933..6c486625321bebb78b6f66370fda54a49a300fcb 100644 (file)
@@ -389,9 +389,9 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
        ac97->capture_dma_data.slave_id = of_dma[1];
 
        ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1;
-       ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-       ac97->capture_dma_data.maxburst = 4;
-       ac97->capture_dma_data.slave_id = of_dma[0];
+       ac97->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       ac97->playback_dma_data.maxburst = 4;
+       ac97->playback_dma_data.slave_id = of_dma[1];
 
        ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev);
        if (ret)
index 5eaa12cdc6ebd3bfcbd502beb1aff881c111d406..551b3c93ce932c77e9e05de4bcf01f5af63d1c94 100644 (file)
@@ -323,8 +323,8 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
        }
 
        spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT;
-       spdif->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-       spdif->capture_dma_data.maxburst = 4;
+       spdif->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       spdif->playback_dma_data.maxburst = 4;
        spdif->playback_dma_data.slave_id = dmareq->start;
 
        pm_runtime_enable(&pdev->dev);
index d04146cad61f4f2dd0227815d0f25970e22e4cae..47565fd045057344390592bb2a8d7a5374cc2209 100644 (file)
@@ -228,7 +228,7 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream,
                reg = TEGRA30_I2S_CIF_RX_CTRL;
        } else {
                val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX;
-               reg = TEGRA30_I2S_CIF_RX_CTRL;
+               reg = TEGRA30_I2S_CIF_TX_CTRL;
        }
 
        regmap_write(i2s->regmap, reg, val);
index 9e6e3ffd86bbbc4212e72eb3d0c7cd69e6d44c8e..23452ee617e11a5d304fffbd0da3e7bea805e0dc 100644 (file)
@@ -110,19 +110,37 @@ static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
 static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request,
                u8 reg, u8 value)
 {
-       u8 buffer[13]; /* 13: maximum length of message */
+       u8 *buffer;
+       int ret;
+
+       /* 13: maximum length of message */
+       buffer = kmalloc(13, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
 
        usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00);
-       return usb6fire_comm_send_buffer(buffer, rt->chip->dev);
+       ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
+
+       kfree(buffer);
+       return ret;
 }
 
 static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request,
                u8 reg, u8 vl, u8 vh)
 {
-       u8 buffer[13]; /* 13: maximum length of message */
+       u8 *buffer;
+       int ret;
+
+       /* 13: maximum length of message */
+       buffer = kmalloc(13, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
 
        usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh);
-       return usb6fire_comm_send_buffer(buffer, rt->chip->dev);
+       ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
+
+       kfree(buffer);
+       return ret;
 }
 
 int usb6fire_comm_init(struct sfire_chip *chip)
@@ -135,6 +153,12 @@ int usb6fire_comm_init(struct sfire_chip *chip)
        if (!rt)
                return -ENOMEM;
 
+       rt->receiver_buffer = kzalloc(COMM_RECEIVER_BUFSIZE, GFP_KERNEL);
+       if (!rt->receiver_buffer) {
+               kfree(rt);
+               return -ENOMEM;
+       }
+
        urb = &rt->receiver;
        rt->serial = 1;
        rt->chip = chip;
@@ -153,6 +177,7 @@ int usb6fire_comm_init(struct sfire_chip *chip)
        urb->interval = 1;
        ret = usb_submit_urb(urb, GFP_KERNEL);
        if (ret < 0) {
+               kfree(rt->receiver_buffer);
                kfree(rt);
                snd_printk(KERN_ERR PREFIX "cannot create comm data receiver.");
                return ret;
@@ -171,6 +196,9 @@ void usb6fire_comm_abort(struct sfire_chip *chip)
 
 void usb6fire_comm_destroy(struct sfire_chip *chip)
 {
-       kfree(chip->comm);
+       struct comm_runtime *rt = chip->comm;
+
+       kfree(rt->receiver_buffer);
+       kfree(rt);
        chip->comm = NULL;
 }
index 6a0840b0dcff2be78366119126e5842aa4ab325f..780d5ed8e5d8a39ff9bec150d9840fcbbef713d8 100644 (file)
@@ -24,7 +24,7 @@ struct comm_runtime {
        struct sfire_chip *chip;
 
        struct urb receiver;
-       u8 receiver_buffer[COMM_RECEIVER_BUFSIZE];
+       u8 *receiver_buffer;
 
        u8 serial; /* urb serial */
 
index 26722423330dd283b62d3fd4c5b77409913372cb..f3dd7266c391c7f17dae6220ed094f548a1d4507 100644 (file)
 #include "chip.h"
 #include "comm.h"
 
+enum {
+       MIDI_BUFSIZE = 64
+};
+
 static void usb6fire_midi_out_handler(struct urb *urb)
 {
        struct midi_runtime *rt = urb->context;
@@ -156,6 +160,12 @@ int usb6fire_midi_init(struct sfire_chip *chip)
        if (!rt)
                return -ENOMEM;
 
+       rt->out_buffer = kzalloc(MIDI_BUFSIZE, GFP_KERNEL);
+       if (!rt->out_buffer) {
+               kfree(rt);
+               return -ENOMEM;
+       }
+
        rt->chip = chip;
        rt->in_received = usb6fire_midi_in_received;
        rt->out_buffer[0] = 0x80; /* 'send midi' command */
@@ -169,6 +179,7 @@ int usb6fire_midi_init(struct sfire_chip *chip)
 
        ret = snd_rawmidi_new(chip->card, "6FireUSB", 0, 1, 1, &rt->instance);
        if (ret < 0) {
+               kfree(rt->out_buffer);
                kfree(rt);
                snd_printk(KERN_ERR PREFIX "unable to create midi.\n");
                return ret;
@@ -197,6 +208,9 @@ void usb6fire_midi_abort(struct sfire_chip *chip)
 
 void usb6fire_midi_destroy(struct sfire_chip *chip)
 {
-       kfree(chip->midi);
+       struct midi_runtime *rt = chip->midi;
+
+       kfree(rt->out_buffer);
+       kfree(rt);
        chip->midi = NULL;
 }
index c321006e5430ac763e593ecee6314c6cee8fd2d6..84851b9f55592f2ddc4b35781e1efa20cac5cd02 100644 (file)
 
 #include "common.h"
 
-enum {
-       MIDI_BUFSIZE = 64
-};
-
 struct midi_runtime {
        struct sfire_chip *chip;
        struct snd_rawmidi *instance;
@@ -32,7 +28,7 @@ struct midi_runtime {
        struct snd_rawmidi_substream *out;
        struct urb out_urb;
        u8 out_serial; /* serial number of out packet */
-       u8 out_buffer[MIDI_BUFSIZE];
+       u8 *out_buffer;
        int buffer_offset;
 
        void (*in_received)(struct midi_runtime *rt, u8 *data, int length);
index c5b9cac37dc4c205d1cff5128906f853d0ea7a76..b5eb97fdc842f79893adc8d359c4e519df82d700 100644 (file)
@@ -543,7 +543,7 @@ static snd_pcm_uframes_t usb6fire_pcm_pointer(
        snd_pcm_uframes_t ret;
 
        if (rt->panic || !sub)
-               return SNDRV_PCM_STATE_XRUN;
+               return SNDRV_PCM_POS_XRUN;
 
        spin_lock_irqsave(&sub->lock, flags);
        ret = sub->dma_off;
@@ -582,6 +582,33 @@ static void usb6fire_pcm_init_urb(struct pcm_urb *urb,
        urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB;
 }
 
+static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt)
+{
+       int i;
+
+       for (i = 0; i < PCM_N_URBS; i++) {
+               rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
+                               * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
+               if (!rt->out_urbs[i].buffer)
+                       return -ENOMEM;
+               rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
+                               * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
+               if (!rt->in_urbs[i].buffer)
+                       return -ENOMEM;
+       }
+       return 0;
+}
+
+static void usb6fire_pcm_buffers_destroy(struct pcm_runtime *rt)
+{
+       int i;
+
+       for (i = 0; i < PCM_N_URBS; i++) {
+               kfree(rt->out_urbs[i].buffer);
+               kfree(rt->in_urbs[i].buffer);
+       }
+}
+
 int usb6fire_pcm_init(struct sfire_chip *chip)
 {
        int i;
@@ -593,6 +620,13 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
        if (!rt)
                return -ENOMEM;
 
+       ret = usb6fire_pcm_buffers_init(rt);
+       if (ret) {
+               usb6fire_pcm_buffers_destroy(rt);
+               kfree(rt);
+               return ret;
+       }
+
        rt->chip = chip;
        rt->stream_state = STREAM_DISABLED;
        rt->rate = ARRAY_SIZE(rates);
@@ -614,6 +648,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
 
        ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm);
        if (ret < 0) {
+               usb6fire_pcm_buffers_destroy(rt);
                kfree(rt);
                snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n");
                return ret;
@@ -625,6 +660,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops);
 
        if (ret) {
+               usb6fire_pcm_buffers_destroy(rt);
                kfree(rt);
                snd_printk(KERN_ERR PREFIX
                                "error preallocating pcm buffers.\n");
@@ -639,17 +675,25 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
 void usb6fire_pcm_abort(struct sfire_chip *chip)
 {
        struct pcm_runtime *rt = chip->pcm;
+       unsigned long flags;
        int i;
 
        if (rt) {
                rt->panic = true;
 
-               if (rt->playback.instance)
+               if (rt->playback.instance) {
+                       snd_pcm_stream_lock_irqsave(rt->playback.instance, flags);
                        snd_pcm_stop(rt->playback.instance,
                                        SNDRV_PCM_STATE_XRUN);
-               if (rt->capture.instance)
+                       snd_pcm_stream_unlock_irqrestore(rt->playback.instance, flags);
+               }
+
+               if (rt->capture.instance) {
+                       snd_pcm_stream_lock_irqsave(rt->capture.instance, flags);
                        snd_pcm_stop(rt->capture.instance,
                                        SNDRV_PCM_STATE_XRUN);
+                       snd_pcm_stream_unlock_irqrestore(rt->capture.instance, flags);
+               }
 
                for (i = 0; i < PCM_N_URBS; i++) {
                        usb_poison_urb(&rt->in_urbs[i].instance);
@@ -661,6 +705,9 @@ void usb6fire_pcm_abort(struct sfire_chip *chip)
 
 void usb6fire_pcm_destroy(struct sfire_chip *chip)
 {
-       kfree(chip->pcm);
+       struct pcm_runtime *rt = chip->pcm;
+
+       usb6fire_pcm_buffers_destroy(rt);
+       kfree(rt);
        chip->pcm = NULL;
 }
index 9b01133ee3fe9c22d3f51557430f011846e5bc8a..f5779d6182c638b02253af7bc9ab73dfed7e1916 100644 (file)
@@ -32,7 +32,7 @@ struct pcm_urb {
        struct urb instance;
        struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
        /* END DO NOT SEPARATE */
-       u8 buffer[PCM_N_PACKETS_PER_URB * PCM_MAX_PACKET_SIZE];
+       u8 *buffer;
 
        struct pcm_urb *peer;
 };
index 7a444b5501d91d28a4e7e8fb5e044c2b4e7ea41b..659950e5b94f6b411577a84821f1a1c4d93b4593 100644 (file)
@@ -591,17 +591,16 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
        ep->stride = frame_bits >> 3;
        ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0;
 
-       /* calculate max. frequency */
-       if (ep->maxpacksize) {
+       /* assume max. frequency is 25% higher than nominal */
+       ep->freqmax = ep->freqn + (ep->freqn >> 2);
+       maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
+                               >> (16 - ep->datainterval);
+       /* but wMaxPacketSize might reduce this */
+       if (ep->maxpacksize && ep->maxpacksize < maxsize) {
                /* whatever fits into a max. size packet */
                maxsize = ep->maxpacksize;
                ep->freqmax = (maxsize / (frame_bits >> 3))
                                << (16 - ep->datainterval);
-       } else {
-               /* no max. packet size: just take 25% higher than nominal */
-               ep->freqmax = ep->freqn + (ep->freqn >> 2);
-               maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
-                               >> (16 - ep->datainterval);
        }
 
        if (ep->fill_max)
index 6430ed2a9f65d68d3d7741acd8475b5140c17f51..c21a3df9a0df1ef6900a468ee7af36ad7b57ab19 100644 (file)
@@ -503,7 +503,7 @@ static snd_pcm_uframes_t hiface_pcm_pointer(struct snd_pcm_substream *alsa_sub)
        snd_pcm_uframes_t dma_offset;
 
        if (rt->panic || !sub)
-               return SNDRV_PCM_STATE_XRUN;
+               return SNDRV_PCM_POS_XRUN;
 
        spin_lock_irqsave(&sub->lock, flags);
        dma_offset = sub->dma_off;
index 8b5d2c564e042af16fb6fa15290afb1df7f9b594..509315937f25a7ea7ef389b373b2ac3fd37651a5 100644 (file)
@@ -613,14 +613,24 @@ static int start_usb_playback(struct ua101 *ua)
 
 static void abort_alsa_capture(struct ua101 *ua)
 {
-       if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states))
+       unsigned long flags;
+
+       if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) {
+               snd_pcm_stream_lock_irqsave(ua->capture.substream, flags);
                snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock_irqrestore(ua->capture.substream, flags);
+       }
 }
 
 static void abort_alsa_playback(struct ua101 *ua)
 {
-       if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states))
+       unsigned long flags;
+
+       if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) {
+               snd_pcm_stream_lock_irqsave(ua->playback.substream, flags);
                snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN);
+               snd_pcm_stream_unlock_irqrestore(ua->playback.substream, flags);
+       }
 }
 
 static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream,
index d5438083fd6a8072c20275778f1f3b9fa0a42517..95558ef4a7a09c72ed52c4706348d765a40c4314 100644 (file)
@@ -888,6 +888,7 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
        case USB_ID(0x046d, 0x081b): /* HD Webcam c310 */
        case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */
        case USB_ID(0x046d, 0x0825): /* HD Webcam c270 */
+       case USB_ID(0x046d, 0x0826): /* HD Webcam c525 */
        case USB_ID(0x046d, 0x0991):
        /* Most audio usb devices lie about volume resolution.
         * Most Logitech webcams have res = 384.
index 1bc45e71f1fe0217d25ad6b85edd396458cf123d..0df9ede99dfd798730376574511fa1041f2f528c 100644 (file)
@@ -319,19 +319,19 @@ static int create_auto_midi_quirk(struct snd_usb_audio *chip,
        if (altsd->bNumEndpoints < 1)
                return -ENODEV;
        epd = get_endpoint(alts, 0);
-       if (!usb_endpoint_xfer_bulk(epd) ||
+       if (!usb_endpoint_xfer_bulk(epd) &&
            !usb_endpoint_xfer_int(epd))
                return -ENODEV;
 
        switch (USB_ID_VENDOR(chip->usb_id)) {
        case 0x0499: /* Yamaha */
                err = create_yamaha_midi_quirk(chip, iface, driver, alts);
-               if (err < 0 && err != -ENODEV)
+               if (err != -ENODEV)
                        return err;
                break;
        case 0x0582: /* Roland */
                err = create_roland_midi_quirk(chip, iface, driver, alts);
-               if (err < 0 && err != -ENODEV)
+               if (err != -ENODEV)
                        return err;
                break;
        }
index 4967fe9c938df0079a4f5d63881b15b627673094..63fb5219f0f8aad7a844eb1942b5cd728be678dc 100644 (file)
@@ -273,7 +273,11 @@ static void usX2Y_clients_stop(struct usX2Ydev *usX2Y)
                struct snd_usX2Y_substream *subs = usX2Y->subs[s];
                if (subs) {
                        if (atomic_read(&subs->state) >= state_PRERUNNING) {
+                               unsigned long flags;
+
+                               snd_pcm_stream_lock_irqsave(subs->pcm_substream, flags);
                                snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN);
+                               snd_pcm_stream_unlock_irqrestore(subs->pcm_substream, flags);
                        }
                        for (u = 0; u < NRURBS; u++) {
                                struct urb *urb = subs->urb[u];
index ca9fa4d32e07e3421ce4446f68d9a0601e51ac28..07819bfa7dba30390fedad9e962813f0c95d38c9 100644 (file)
@@ -1026,9 +1026,10 @@ kvp_get_ip_info(int family, char *if_name, int op,
 
                                if (sn_offset == 0)
                                        strcpy(sn_str, cidr_mask);
-                               else
+                               else {
+                                       strcat((char *)ip_buffer->sub_net, ";");
                                        strcat(sn_str, cidr_mask);
-                               strcat((char *)ip_buffer->sub_net, ";");
+                               }
                                sn_offset += strlen(sn_str) + 1;
                        }